diff options
5 files changed, 8 insertions, 75 deletions
diff --git a/juick-xmpp-ft/build.gradle b/juick-xmpp-ft/build.gradle index cb19cbb3..dd230a4b 100644 --- a/juick-xmpp-ft/build.gradle +++ b/juick-xmpp-ft/build.gradle @@ -5,6 +5,7 @@ apply plugin: 'com.github.ben-manes.versions' repositories { mavenCentral() + maven { url "https://jitpack.io" } } def springFrameworkVersion = '4.3.4.RELEASE' @@ -23,8 +24,8 @@ dependencies { compile 'org.apache.httpcomponents:httpclient:4.5.2' compile 'org.apache.commons:commons-dbcp2:2.1.1' compile 'com.mitchellbosecke:pebble-spring4:2.2.3' - compile 'rocks.xmpp:xmpp-core-client:0.7.2' - compile 'rocks.xmpp:xmpp-extensions-client:0.7.2' + compile 'org.bitbucket.sco0ter.babbler:xmpp-core-client:279e488e51' + compile 'org.bitbucket.sco0ter.babbler:xmpp-extensions-client:279e488e51' providedRuntime 'mysql:mysql-connector-java:5.1.39' } 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); } } diff --git a/juick-xmpp-ft/src/main/java/com/juick/components/url/JuickURLConnection.java b/juick-xmpp-ft/src/main/java/com/juick/components/url/JuickURLConnection.java deleted file mode 100644 index f467f75b..00000000 --- a/juick-xmpp-ft/src/main/java/com/juick/components/url/JuickURLConnection.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.juick.components.url; - -import java.io.IOException; -import java.net.URL; -import java.net.URLConnection; - -/** - * Created by vitalyster on 11.11.2016. - */ -public class JuickURLConnection extends URLConnection { - protected JuickURLConnection(URL url) { - super(url); - } - @Override - public void connect() throws IOException { - - } -} diff --git a/juick-xmpp-ft/src/main/java/com/juick/components/url/JuickURLStreamHandler.java b/juick-xmpp-ft/src/main/java/com/juick/components/url/JuickURLStreamHandler.java deleted file mode 100644 index 0a4d2ae3..00000000 --- a/juick-xmpp-ft/src/main/java/com/juick/components/url/JuickURLStreamHandler.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.juick.components.url; - -import java.io.IOException; -import java.net.URL; -import java.net.URLConnection; -import java.net.URLStreamHandler; - -/** - * Created by vitalyster on 11.11.2016. - */ -public class JuickURLStreamHandler extends URLStreamHandler { - @Override - protected URLConnection openConnection(URL u) throws IOException { - return new JuickURLConnection(u); - } -} diff --git a/juick-xmpp-ft/src/main/java/com/juick/components/url/JuickURLStreamHandlerFactory.java b/juick-xmpp-ft/src/main/java/com/juick/components/url/JuickURLStreamHandlerFactory.java deleted file mode 100644 index d7c9559e..00000000 --- a/juick-xmpp-ft/src/main/java/com/juick/components/url/JuickURLStreamHandlerFactory.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.juick.components.url; - -import java.net.URLStreamHandler; -import java.net.URLStreamHandlerFactory; - -/** - * Created by vitalyster on 11.11.2016. - */ -public class JuickURLStreamHandlerFactory implements URLStreamHandlerFactory { - @Override - public URLStreamHandler createURLStreamHandler(String protocol) { - if ("juick".equals(protocol)) { - return new JuickURLStreamHandler(); - } - return null; - } -} |