RefreshJob loads max 10 articles at a time; there's a delay of 1 second for the next...
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.wiki / src / net / sourceforge / phpeclipse / wiki / actions / mediawiki / connect / MediaWikiConnector.java
index 4c1abb6..07cc568 100644 (file)
@@ -15,7 +15,6 @@ import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import net.sourceforge.phpeclipse.wiki.actions.mediawiki.config.IWikipedia;
-import net.sourceforge.phpeclipse.wiki.actions.mediawiki.config.WikipediaDE;
 import net.sourceforge.phpeclipse.wiki.actions.mediawiki.exceptions.MethodException;
 import net.sourceforge.phpeclipse.wiki.actions.mediawiki.exceptions.PageNotEditableException;
 import net.sourceforge.phpeclipse.wiki.actions.mediawiki.exceptions.UnexpectedAnswerException;
@@ -131,6 +130,13 @@ public class MediaWikiConnector {
       } else if (responseCode == 200 && responseBody.matches(config.getLoginWrongPw()) || responseCode == 200
           && responseBody.matches(config.getLoginNoUser())) {
         result = false;
+        if (responseBody.matches(config.getLoginNoUser())) {
+          throw new UnexpectedAnswerException("login not successful: wrong user name: "+user);
+        } else if (responseBody.matches(config.getLoginWrongPw())) {
+          throw new UnexpectedAnswerException("login not successful: wrong password for user: "+user);
+        } else {
+          throw new UnexpectedAnswerException("logout not successful: responseCode == 200");
+        }
       } else {
         throw new UnexpectedAnswerException("login not successful: " + method.getStatusLine());
       }
@@ -177,6 +183,7 @@ public class MediaWikiConnector {
       } else if (responseCode == 200) {
         //### should check for a failure message
         result = false;
+        throw new UnexpectedAnswerException("logout not successful: responseCode == 200");
       } else {
         throw new UnexpectedAnswerException("logout not successful: " + method.getStatusLine());
       }
@@ -244,7 +251,8 @@ public class MediaWikiConnector {
     return result;
   }
 
-  public ArrayList loadXML(IWikipedia config, String actionURL, String pages) throws UnexpectedAnswerException, MethodException {
+  public ArrayList loadXML(IWikipedia config, String actionURL, String pages) throws UnexpectedAnswerException, MethodException , InterruptedException{
+    storeThrottle.delay();  
     PostMethod method = new PostMethod(actionURL);
     method.setFollowRedirects(false);
     method.addRequestHeader("User-Agent", userAgent);
@@ -495,7 +503,7 @@ public class MediaWikiConnector {
     } catch (UnexpectedAnswerException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
-    } catch (MethodException e) {
+    } catch (Exception e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     }