aboutsummaryrefslogtreecommitdiff
path: root/juick-xmpp-ft/src/main/java/com/juick/components/XMPPFTServer.java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-11-12 11:13:08 +0300
committerGravatar Vitaly Takmazov2016-11-12 11:13:08 +0300
commit5a9bfa524dcd27f357a8838acb7f150660061ae6 (patch)
tree865c3d4a04a69b71f5595114abae5dc170d31135 /juick-xmpp-ft/src/main/java/com/juick/components/XMPPFTServer.java
parent294544ff5db35e6d16c59dc0fbbc0d3665fc6f41 (diff)
xmpp-ft: drop Juick URL boilerplate as babbler now supports URI
Diffstat (limited to 'juick-xmpp-ft/src/main/java/com/juick/components/XMPPFTServer.java')
-rw-r--r--juick-xmpp-ft/src/main/java/com/juick/components/XMPPFTServer.java27
1 files changed, 5 insertions, 22 deletions
diff --git a/juick-xmpp-ft/src/main/java/com/juick/components/XMPPFTServer.java b/juick-xmpp-ft/src/main/java/com/juick/components/XMPPFTServer.java
index 14d65de9..99287562 100644
--- a/juick-xmpp-ft/src/main/java/com/juick/components/XMPPFTServer.java
+++ b/juick-xmpp-ft/src/main/java/com/juick/components/XMPPFTServer.java
@@ -1,6 +1,5 @@
package com.juick.components;
-import com.juick.components.url.JuickURLStreamHandlerFactory;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.math.NumberUtils;
@@ -16,9 +15,8 @@ import rocks.xmpp.extensions.filetransfer.FileTransferManager;
import rocks.xmpp.extensions.oob.model.x.OobX;
import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.net.*;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
@@ -32,22 +30,7 @@ public class XMPPFTServer {
private static final Logger logger = LoggerFactory.getLogger(XMPPFTServer.class);
public XMPPFTServer(Environment env) {
- try {
- Class tomcathfc = Class.forName("org.apache.catalina.webresources.TomcatURLStreamHandlerFactory");
- if (tomcathfc != null) {
- try {
- Method m = tomcathfc.getMethod("getInstance");
- Object tomcathfo = m.invoke(null);
- m = tomcathfo.getClass().getMethod("addUserFactory", URLStreamHandlerFactory.class);
- m.invoke(tomcathfo, new JuickURLStreamHandlerFactory());
- } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
- logger.error("init error", e);
- }
- }
- } catch (ClassNotFoundException e) {
- URL.setURLStreamHandlerFactory(new JuickURLStreamHandlerFactory());
- }
- ExternalComponent component = ExternalComponent.create(env.getProperty("component_name", "files"),
+ @SuppressWarnings("unchecked") ExternalComponent component = ExternalComponent.create(env.getProperty("component_name", "files"),
env.getProperty("component_password", "secret"), env.getProperty("component_host", "localhost"),
NumberUtils.toInt(env.getProperty("component_port", "5347"), 5347));
String tmpDir = env.getProperty("upload_tmp_dir", "/tmp");
@@ -74,9 +57,9 @@ public class XMPPFTServer {
msg.setBody(e.getDescription());
try {
String attachmentUrl = String.format("juick://%s", targetFilename);
- msg.addExtension(new OobX(new URI(attachmentUrl).toURL(), "!!!!Juick!!"));
+ msg.addExtension(new OobX(new URI(attachmentUrl), "!!!!Juick!!"));
component.sendMessage(msg);
- } catch (MalformedURLException | URISyntaxException e1) {
+ } catch (URISyntaxException e1) {
logger.warn("attachment error", e1);
}
}