OSDN Git Service

TODO解消
authoryukihane <yukihane.feather@gmail.com>
Tue, 30 Aug 2011 10:23:51 +0000 (19:23 +0900)
committeryukihane <yukihane.feather@gmail.com>
Tue, 30 Aug 2011 10:23:51 +0000 (19:23 +0900)
frontend/nbproject/project.properties
frontend/src/saccubus/worker/impl/download/Download.java

index 3e5c6f9..53e0ad3 100644 (file)
@@ -39,8 +39,7 @@ javac.classpath=\
     ${libs.Commons-Collections.classpath}:\\r
     ${libs.toplink.classpath}:\\r
     ${libs.H2_DB.classpath}:\\r
-    ${libs.Commons-CLI.classpath}:\\r
-    ${libs.HttpComponents.classpath}\r
+    ${libs.Commons-CLI.classpath}\r
 # Space-separated list of extra javac options\r
 javac.compilerargs=\r
 javac.deprecation=true\r
@@ -90,7 +89,8 @@ run.classpath=\
     ${build.classes.dir}:\\r
     ${libs.Rome.classpath}:\\r
     ${libs.groovy-all.classpath}:\\r
-    ${libs.NekoHtml.classpath}\r
+    ${libs.NekoHtml.classpath}:\\r
+    ${libs.HttpComponents.classpath}\r
 run.jvmargs=-Djava.util.logging.config.file=inqubuslogging.properties\r
 run.test.classpath=\\r
     ${javac.test.classpath}:\\r
index 3aefdb9..8d089d3 100644 (file)
@@ -4,7 +4,6 @@ import static saccubus.worker.impl.download.DownloadStatus.*;
 
 import java.io.File;
 import java.io.IOException;
-import java.net.URISyntaxException;
 import java.util.Date;
 import java.util.logging.Logger;
 import nicobrowser.GetFlvResult;
@@ -13,7 +12,6 @@ import nicobrowser.NicoHttpClient;
 import nicobrowser.ProgressListener;
 import nicobrowser.WayBackInfo;
 import nicobrowser.entity.NicoContent.Status;
-import org.apache.http.HttpException;
 import saccubus.worker.Worker;
 import saccubus.worker.WorkerListener;
 import saccubus.worker.profile.CommentProfile;
@@ -54,7 +52,8 @@ public class Download extends Worker<DownloadResult, DownloadProgress> {
      * @param listener
      * @param flag
      */
-    public Download(DownloadProfile profile, String videoId, WorkerListener<DownloadResult, DownloadProgress> listener, int wait) {
+    public Download(DownloadProfile profile, String videoId, WorkerListener<DownloadResult, DownloadProgress> listener,
+            int wait) {
         super(listener);
         this.videoId = videoId;
         this.profile = profile;
@@ -164,18 +163,14 @@ public class Download extends Worker<DownloadResult, DownloadProgress> {
      * @throws IOException ログイン失敗.
      * @throws InterruptedException ログイン失敗.
      */
-    // TODO HttpException を投げるのをやめたい. コンパイル時にHttpComponentが必要になるので.
-    private NicoHttpClient createClientAndLogin() throws IOException, InterruptedException, HttpException {
+    private NicoHttpClient createClientAndLogin() throws IOException, InterruptedException {
         final NicoHttpClient client = createClient(profile.getProxyProfile());
-        final boolean hasLogin;
-        try {
-            hasLogin = client.login(profile.getLoginInfo().getMail(), profile.getLoginInfo().getPassword());
-            if (!hasLogin) {
-                throw new IOException("login fail");
-            }
-        } catch (URISyntaxException ex) {
-            throw new IOException("login fail", ex);
+
+        final boolean hasLogin = client.login(profile.getLoginInfo().getMail(), profile.getLoginInfo().getPassword());
+        if (!hasLogin) {
+            throw new IOException("login fail");
         }
+
         return client;
     }
 
@@ -212,7 +207,7 @@ public class Download extends Worker<DownloadResult, DownloadProgress> {
         synchronized (timeLockObj) {
             final long now = new Date().getTime();
             final long needSleep = (waitDownload * 1000L) - (now - lastStartTime);
-            if(needSleep > 0L) {
+            if (needSleep > 0L) {
                 publish(new DownloadProgress(DownloadStatus.PROCESS, -1.0, "過剰アクセス抑制待機 " + needSleep / 1000));
                 Thread.sleep(needSleep);
             }