diff options
Diffstat (limited to 'juick-xmpp-ft/src/main/java/com/juick/components')
4 files changed, 54 insertions, 4 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 6726a156..4a85b046 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,5 +1,6 @@ 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; @@ -15,10 +16,7 @@ import rocks.xmpp.extensions.filetransfer.FileTransferManager; import rocks.xmpp.extensions.oob.model.x.OobX; import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; +import java.net.*; import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; @@ -32,6 +30,7 @@ public class XMPPFTServer { private static final Logger logger = LoggerFactory.getLogger(XMPPFTServer.class); public XMPPFTServer(Environment env) { + URL.setURLStreamHandlerFactory(new JuickURLStreamHandlerFactory()); 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)); 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 new file mode 100644 index 00000000..f467f75b --- /dev/null +++ b/juick-xmpp-ft/src/main/java/com/juick/components/url/JuickURLConnection.java @@ -0,0 +1,18 @@ +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 new file mode 100644 index 00000000..0a4d2ae3 --- /dev/null +++ b/juick-xmpp-ft/src/main/java/com/juick/components/url/JuickURLStreamHandler.java @@ -0,0 +1,16 @@ +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 new file mode 100644 index 00000000..d7c9559e --- /dev/null +++ b/juick-xmpp-ft/src/main/java/com/juick/components/url/JuickURLStreamHandlerFactory.java @@ -0,0 +1,17 @@ +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; + } +} |