From e943b08ede8a3a7180714bb3862621725183635a Mon Sep 17 00:00:00 2001 From: Rogiel Date: Mon, 16 Jan 2012 13:28:59 -0200 Subject: [PATCH] Implements zshare.net and filesonic.com services --- .../httpchannel/service/DownloadChannel.java | 3 +- .../httpchannel/service/UploadChannel.java | 3 +- .../httpchannel-captcha-recaptcha/pom.xml | 0 .../captcha/impl/AjaxReCaptchaService.java | 0 .../captcha/impl/BaseReCaptchaService.java | 0 .../impl/EmbeddedReCaptchaService.java | 0 .../httpchannel/captcha/impl/ReCaptcha.java | 0 .../impl/AjaxReCaptchaServiceTest.java | 0 .../pom.xml | 2 +- .../service/impl/HotFileService.java | 3 +- .../service/impl/UploadHereService.java | 2 +- .../service/impl/UploadKingService.java | 6 ++-- httpchannel-service/pom.xml | 3 ++ .../service/channel/LinkedUploadChannel.java | 12 ++++++-- .../LinkedUploadChannelContentBody.java | 3 +- pom.xml | 29 ++----------------- .../main/assembly}/distribution-bin.xml | 11 +++++-- 17 files changed, 33 insertions(+), 44 deletions(-) rename {httpchannel-capcha => httpchannel-captcha}/httpchannel-captcha-recaptcha/pom.xml (100%) rename {httpchannel-capcha => httpchannel-captcha}/httpchannel-captcha-recaptcha/src/main/java/com/rogiel/httpchannel/captcha/impl/AjaxReCaptchaService.java (100%) rename {httpchannel-capcha => httpchannel-captcha}/httpchannel-captcha-recaptcha/src/main/java/com/rogiel/httpchannel/captcha/impl/BaseReCaptchaService.java (100%) rename {httpchannel-capcha => httpchannel-captcha}/httpchannel-captcha-recaptcha/src/main/java/com/rogiel/httpchannel/captcha/impl/EmbeddedReCaptchaService.java (100%) rename {httpchannel-capcha => httpchannel-captcha}/httpchannel-captcha-recaptcha/src/main/java/com/rogiel/httpchannel/captcha/impl/ReCaptcha.java (100%) rename {httpchannel-capcha => httpchannel-captcha}/httpchannel-captcha-recaptcha/src/test/java/com/rogiel/httpchannel/captcha/impl/AjaxReCaptchaServiceTest.java (100%) rename {httpchannel-capcha => httpchannel-captcha}/pom.xml (90%) rename {assembly => src/main/assembly}/distribution-bin.xml (72%) diff --git a/httpchannel-api/src/main/java/com/rogiel/httpchannel/service/DownloadChannel.java b/httpchannel-api/src/main/java/com/rogiel/httpchannel/service/DownloadChannel.java index 5eda04a..f53112b 100644 --- a/httpchannel-api/src/main/java/com/rogiel/httpchannel/service/DownloadChannel.java +++ b/httpchannel-api/src/main/java/com/rogiel/httpchannel/service/DownloadChannel.java @@ -16,7 +16,6 @@ */ package com.rogiel.httpchannel.service; -import java.io.Closeable; import java.nio.channels.Channel; import java.nio.channels.ReadableByteChannel; @@ -32,7 +31,7 @@ import java.nio.channels.ReadableByteChannel; * * @author Rogiel */ -public interface DownloadChannel extends ReadableByteChannel, Closeable { +public interface DownloadChannel extends HttpChannel, ReadableByteChannel { /** * @return the file size */ diff --git a/httpchannel-api/src/main/java/com/rogiel/httpchannel/service/UploadChannel.java b/httpchannel-api/src/main/java/com/rogiel/httpchannel/service/UploadChannel.java index f2ed303..193cc85 100644 --- a/httpchannel-api/src/main/java/com/rogiel/httpchannel/service/UploadChannel.java +++ b/httpchannel-api/src/main/java/com/rogiel/httpchannel/service/UploadChannel.java @@ -16,7 +16,6 @@ */ package com.rogiel.httpchannel.service; -import java.io.Closeable; import java.io.IOException; import java.net.URL; import java.nio.channels.Channel; @@ -36,7 +35,7 @@ import com.rogiel.httpchannel.service.exception.UploadLinkNotFoundException; * * @author Rogiel */ -public interface UploadChannel extends WritableByteChannel, Closeable { +public interface UploadChannel extends HttpChannel, WritableByteChannel { /** * @return the file size */ diff --git a/httpchannel-capcha/httpchannel-captcha-recaptcha/pom.xml b/httpchannel-captcha/httpchannel-captcha-recaptcha/pom.xml similarity index 100% rename from httpchannel-capcha/httpchannel-captcha-recaptcha/pom.xml rename to httpchannel-captcha/httpchannel-captcha-recaptcha/pom.xml diff --git a/httpchannel-capcha/httpchannel-captcha-recaptcha/src/main/java/com/rogiel/httpchannel/captcha/impl/AjaxReCaptchaService.java b/httpchannel-captcha/httpchannel-captcha-recaptcha/src/main/java/com/rogiel/httpchannel/captcha/impl/AjaxReCaptchaService.java similarity index 100% rename from httpchannel-capcha/httpchannel-captcha-recaptcha/src/main/java/com/rogiel/httpchannel/captcha/impl/AjaxReCaptchaService.java rename to httpchannel-captcha/httpchannel-captcha-recaptcha/src/main/java/com/rogiel/httpchannel/captcha/impl/AjaxReCaptchaService.java diff --git a/httpchannel-capcha/httpchannel-captcha-recaptcha/src/main/java/com/rogiel/httpchannel/captcha/impl/BaseReCaptchaService.java b/httpchannel-captcha/httpchannel-captcha-recaptcha/src/main/java/com/rogiel/httpchannel/captcha/impl/BaseReCaptchaService.java similarity index 100% rename from httpchannel-capcha/httpchannel-captcha-recaptcha/src/main/java/com/rogiel/httpchannel/captcha/impl/BaseReCaptchaService.java rename to httpchannel-captcha/httpchannel-captcha-recaptcha/src/main/java/com/rogiel/httpchannel/captcha/impl/BaseReCaptchaService.java diff --git a/httpchannel-capcha/httpchannel-captcha-recaptcha/src/main/java/com/rogiel/httpchannel/captcha/impl/EmbeddedReCaptchaService.java b/httpchannel-captcha/httpchannel-captcha-recaptcha/src/main/java/com/rogiel/httpchannel/captcha/impl/EmbeddedReCaptchaService.java similarity index 100% rename from httpchannel-capcha/httpchannel-captcha-recaptcha/src/main/java/com/rogiel/httpchannel/captcha/impl/EmbeddedReCaptchaService.java rename to httpchannel-captcha/httpchannel-captcha-recaptcha/src/main/java/com/rogiel/httpchannel/captcha/impl/EmbeddedReCaptchaService.java diff --git a/httpchannel-capcha/httpchannel-captcha-recaptcha/src/main/java/com/rogiel/httpchannel/captcha/impl/ReCaptcha.java b/httpchannel-captcha/httpchannel-captcha-recaptcha/src/main/java/com/rogiel/httpchannel/captcha/impl/ReCaptcha.java similarity index 100% rename from httpchannel-capcha/httpchannel-captcha-recaptcha/src/main/java/com/rogiel/httpchannel/captcha/impl/ReCaptcha.java rename to httpchannel-captcha/httpchannel-captcha-recaptcha/src/main/java/com/rogiel/httpchannel/captcha/impl/ReCaptcha.java diff --git a/httpchannel-capcha/httpchannel-captcha-recaptcha/src/test/java/com/rogiel/httpchannel/captcha/impl/AjaxReCaptchaServiceTest.java b/httpchannel-captcha/httpchannel-captcha-recaptcha/src/test/java/com/rogiel/httpchannel/captcha/impl/AjaxReCaptchaServiceTest.java similarity index 100% rename from httpchannel-capcha/httpchannel-captcha-recaptcha/src/test/java/com/rogiel/httpchannel/captcha/impl/AjaxReCaptchaServiceTest.java rename to httpchannel-captcha/httpchannel-captcha-recaptcha/src/test/java/com/rogiel/httpchannel/captcha/impl/AjaxReCaptchaServiceTest.java diff --git a/httpchannel-capcha/pom.xml b/httpchannel-captcha/pom.xml similarity index 90% rename from httpchannel-capcha/pom.xml rename to httpchannel-captcha/pom.xml index 1ed1a8f..043f161 100644 --- a/httpchannel-capcha/pom.xml +++ b/httpchannel-captcha/pom.xml @@ -7,7 +7,7 @@ 1.0.0 .. - httpchannel-capcha + httpchannel-captcha pom HttpChannel/CaptchaService diff --git a/httpchannel-service/httpchannel-service-hotfile/src/main/java/com/rogiel/httpchannel/service/impl/HotFileService.java b/httpchannel-service/httpchannel-service-hotfile/src/main/java/com/rogiel/httpchannel/service/impl/HotFileService.java index f508da8..2b72687 100644 --- a/httpchannel-service/httpchannel-service-hotfile/src/main/java/com/rogiel/httpchannel/service/impl/HotFileService.java +++ b/httpchannel-service/httpchannel-service-hotfile/src/main/java/com/rogiel/httpchannel/service/impl/HotFileService.java @@ -220,8 +220,7 @@ public class HotFileService extends AbstractHttpService implements Service, protected class DownloaderImpl extends AbstractHttpDownloader { - public DownloaderImpl(URL url, - NullDownloaderConfiguration configuration) { + public DownloaderImpl(URL url, NullDownloaderConfiguration configuration) { super(url, configuration); } diff --git a/httpchannel-service/httpchannel-service-uploadhere/src/main/java/com/rogiel/httpchannel/service/impl/UploadHereService.java b/httpchannel-service/httpchannel-service-uploadhere/src/main/java/com/rogiel/httpchannel/service/impl/UploadHereService.java index 69861ec..3cf62e5 100644 --- a/httpchannel-service/httpchannel-service-uploadhere/src/main/java/com/rogiel/httpchannel/service/impl/UploadHereService.java +++ b/httpchannel-service/httpchannel-service-uploadhere/src/main/java/com/rogiel/httpchannel/service/impl/UploadHereService.java @@ -276,7 +276,7 @@ public class UploadHereService extends AbstractHttpService implements Service, @Override public void logout() throws IOException { - post("http://www.uploadking.com/login").parameter("do", "logout") + post("http://www.uploadhere.com/login").parameter("do", "logout") .request(); // TODO check logout status } diff --git a/httpchannel-service/httpchannel-service-uploadking/src/main/java/com/rogiel/httpchannel/service/impl/UploadKingService.java b/httpchannel-service/httpchannel-service-uploadking/src/main/java/com/rogiel/httpchannel/service/impl/UploadKingService.java index 69c33d9..b885cf6 100644 --- a/httpchannel-service/httpchannel-service-uploadking/src/main/java/com/rogiel/httpchannel/service/impl/UploadKingService.java +++ b/httpchannel-service/httpchannel-service-uploadking/src/main/java/com/rogiel/httpchannel/service/impl/UploadKingService.java @@ -40,7 +40,7 @@ import com.rogiel.httpchannel.util.PatternUtils; import com.rogiel.httpchannel.util.htmlparser.HTMLPage; /** - * This service handles uploads to UploadKing.com. + * This service handles uploads to zshare.net. * * @author Rogiel * @since 1.0 @@ -103,7 +103,7 @@ public class UploadKingService extends AbstractHttpService implements Service, @Override public long getMaximumFilesize() { - return 1 * 1024 * 1024 * 1024; + return 500 * 1024 * 1024; } @Override @@ -191,7 +191,7 @@ public class UploadKingService extends AbstractHttpService implements Service, final String uploadID = page.getInputValue("UPLOAD_IDENTIFIER"); final LinkedUploadChannel channel = createLinkedChannel(this); - uploadFuture = multipartPost(url).parameter("file_0", channel) + uploadFuture = multipartPost(url).parameter("file", channel) .parameter("u", userCookie) .parameter("UPLOAD_IDENTIFIER", uploadID).asStringAsync(); return waitChannelLink(channel, uploadFuture); diff --git a/httpchannel-service/pom.xml b/httpchannel-service/pom.xml index 83db7e5..6aee4ee 100644 --- a/httpchannel-service/pom.xml +++ b/httpchannel-service/pom.xml @@ -17,6 +17,9 @@ httpchannel-service-megaupload httpchannel-service-hotfile httpchannel-service-multiupload + httpchannel-service-zshare + + httpchannel-service-filesonic diff --git a/httpchannel-util/src/main/java/com/rogiel/httpchannel/service/channel/LinkedUploadChannel.java b/httpchannel-util/src/main/java/com/rogiel/httpchannel/service/channel/LinkedUploadChannel.java index abe22ef..8d44811 100644 --- a/httpchannel-util/src/main/java/com/rogiel/httpchannel/service/channel/LinkedUploadChannel.java +++ b/httpchannel-util/src/main/java/com/rogiel/httpchannel/service/channel/LinkedUploadChannel.java @@ -19,6 +19,7 @@ package com.rogiel.httpchannel.service.channel; import java.io.IOException; import java.net.URL; import java.nio.ByteBuffer; +import java.nio.channels.ClosedChannelException; import java.nio.channels.WritableByteChannel; import com.rogiel.httpchannel.service.UploadChannel; @@ -49,7 +50,14 @@ public class LinkedUploadChannel implements UploadChannel { public int write(ByteBuffer src) throws IOException { if (channel == null) throw new IOException("Channel is not linked yet"); - return channel.write(src); + if(!open) + throw new ClosedChannelException(); + try { + return channel.write(src); + } catch(IOException e) { + close(); + throw e; + } } @Override @@ -85,7 +93,7 @@ public class LinkedUploadChannel implements UploadChannel { return downloadLink; } - public void linkChannel(WritableByteChannel channel) throws IOException { + protected void linkChannel(WritableByteChannel channel) throws IOException { if (this.channel != null) throw new IOException("This channel is already linked."); this.channel = channel; diff --git a/httpchannel-util/src/main/java/com/rogiel/httpchannel/service/channel/LinkedUploadChannelContentBody.java b/httpchannel-util/src/main/java/com/rogiel/httpchannel/service/channel/LinkedUploadChannelContentBody.java index c61f0fc..c28a8cb 100644 --- a/httpchannel-util/src/main/java/com/rogiel/httpchannel/service/channel/LinkedUploadChannelContentBody.java +++ b/httpchannel-util/src/main/java/com/rogiel/httpchannel/service/channel/LinkedUploadChannelContentBody.java @@ -49,10 +49,9 @@ public class LinkedUploadChannelContentBody extends AbstractContentBody { public void writeTo(OutputStream out) throws IOException { final WritableByteChannel outputChannel = Channels.newChannel(out); channel.linkChannel(outputChannel); - while (channel.isOpen() && outputChannel.isOpen()) { try { - Thread.sleep(500); + Thread.sleep(50); } catch (InterruptedException e) { } } diff --git a/pom.xml b/pom.xml index bc9d52d..0c02893 100644 --- a/pom.xml +++ b/pom.xml @@ -15,8 +15,7 @@ httpchannel-service httpchannel-util httpchannel-channelcopy - - httpchannel-capcha + httpchannel-captcha @@ -37,36 +36,12 @@ 1.7 - - org.apache.maven.plugins - maven-jar-plugin - - - package - - jar - - - - - - org.apache.maven.plugins - maven-install-plugin - - - package - - install - - - - org.apache.maven.plugins maven-assembly-plugin - assembly/distribution-bin.xml + src/main/assembly/distribution-bin.xml diff --git a/assembly/distribution-bin.xml b/src/main/assembly/distribution-bin.xml similarity index 72% rename from assembly/distribution-bin.xml rename to src/main/assembly/distribution-bin.xml index c74c0a7..86a8414 100644 --- a/assembly/distribution-bin.xml +++ b/src/main/assembly/distribution-bin.xml @@ -9,12 +9,19 @@ - false + true + true + true + + + com/rogiel/httpchannel/** + + false - httpchannel-service httpchannel-api + httpchannel-service