X-Git-Url: http://git.phpeclipse.com diff --git a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/actions/mediawiki/connect/MediaWikiConnector.java b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/actions/mediawiki/connect/MediaWikiConnector.java index ca80eec..efc1fc9 100644 --- a/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/actions/mediawiki/connect/MediaWikiConnector.java +++ b/archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/actions/mediawiki/connect/MediaWikiConnector.java @@ -69,7 +69,12 @@ public class MediaWikiConnector { /** * Delay a new store to 1 second */ - private Throttle storeThrottle = new Throttle(1000); + private Throttle loadThrottle = new Throttle(WikiEditorPlugin.HTTP_GET_THROTTLE); + + /** + * Delay a new store to 1 second + */ + private Throttle storeThrottle = new Throttle(WikiEditorPlugin.HTTP_PUT_THROTTLE); class Throttle { private long nextTime = 0; @@ -80,6 +85,12 @@ public class MediaWikiConnector { this.minimumDelay = minimumDelay; } + public Throttle(String key) { + Preferences prefs = WikiEditorPlugin.getDefault().getPluginPreferences(); + String minimumDelay = prefs.getString(key); + this.minimumDelay = Integer.parseInt(minimumDelay); + } + /** this is called from the client */ public synchronized void delay() throws InterruptedException { long delay = nextTime - System.currentTimeMillis(); @@ -311,24 +322,25 @@ public class MediaWikiConnector { return result; } - public Loaded loadCategory(String actionURL, String charSet, String title) throws UnexpectedAnswerException, MethodException, + public String loadHTMLPage(String actionURL, String charSet) throws UnexpectedAnswerException, MethodException, PageNotEditableException { GetMethod method = new GetMethod(actionURL); - method.setFollowRedirects(false); + method.setFollowRedirects(true); method.addRequestHeader("User-Agent", userAgent); - NameValuePair[] params = new NameValuePair[] { new NameValuePair("title", title) }; - method.setQueryString(EncodingUtil.formUrlEncode(params, charSet)); +// NameValuePair[] params = new NameValuePair[] { new NameValuePair("title", title) }; +// method.setQueryString(EncodingUtil.formUrlEncode(params, charSet)); - Loaded result; + String result = ""; try { int responseCode = client.executeMethod(method); String responseBody = method.getResponseBodyAsString(); // log(method); if (responseCode == 200) { - Parsed parsed = parseBody(charSet, responseBody); - Content content = new Content(parsed.timestamp, parsed.body); - result = new Loaded(actionURL, charSet, parsed.title, content); + result = responseBody; +// Parsed parsed = parseBody(charSet, responseBody); +// Content content = new Content(parsed.timestamp, parsed.body); +// result = new Loaded(actionURL, charSet, parsed.title, content); } else { throw new UnexpectedAnswerException("load not successful: expected 200 OK, got " + method.getStatusLine()); } @@ -344,7 +356,7 @@ public class MediaWikiConnector { public ArrayList loadXML(IWikipedia config, String actionURL, String pages) throws UnexpectedAnswerException, MethodException, InterruptedException { - storeThrottle.delay(); + loadThrottle.delay(); PostMethod method = new PostMethod(actionURL); method.setFollowRedirects(false); method.addRequestHeader("User-Agent", userAgent);