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 9225b17..ca80eec 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 @@ -55,8 +55,8 @@ public class MediaWikiConnector { + ".*]*\\svalue=\"(\\d*)\"[^>]*\\sname=\"wpEdittime\"[^>]*>" + ".*", Pattern.DOTALL); // - private static final Pattern EDIT_TOKEN = Pattern.compile(".*.*", - Pattern.DOTALL); + private static final Pattern EDIT_TOKEN = Pattern.compile( + ".*.*", Pattern.DOTALL); //setup default user agent final static public String userAgent = "plog4u.org/0.0"; @@ -311,6 +311,37 @@ public class MediaWikiConnector { return result; } + public Loaded loadCategory(String actionURL, String charSet, String title) throws UnexpectedAnswerException, MethodException, + PageNotEditableException { + GetMethod method = new GetMethod(actionURL); + method.setFollowRedirects(false); + method.addRequestHeader("User-Agent", userAgent); + NameValuePair[] params = new NameValuePair[] { new NameValuePair("title", title) }; + method.setQueryString(EncodingUtil.formUrlEncode(params, charSet)); + + Loaded 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); + } else { + throw new UnexpectedAnswerException("load not successful: expected 200 OK, got " + method.getStatusLine()); + } + } catch (HttpException e) { + throw new MethodException("method failed", e); + } catch (IOException e) { + throw new MethodException("method failed", e); + } finally { + method.releaseConnection(); + } + return result; + } + public ArrayList loadXML(IWikipedia config, String actionURL, String pages) throws UnexpectedAnswerException, MethodException, InterruptedException { storeThrottle.delay();