package net.sourceforge.phpeclipse.wiki.actions.mediawiki.connect;
//Parts of this sources are copied and modified from the jEdit Wikipedia plugin:
//http://www.djini.de/software/wikipedia/index.html
//
//The modified sources are available under the "Common Public License"
//with permission from the original author: Daniel Wunsch
import java.io.IOException;
import java.io.StringReader;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.ArrayList;
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.exceptions.MethodException;
import net.sourceforge.phpeclipse.wiki.actions.mediawiki.exceptions.PageNotEditableException;
import net.sourceforge.phpeclipse.wiki.actions.mediawiki.exceptions.UnexpectedAnswerException;
import net.sourceforge.phpeclipse.wiki.editor.WikiEditorPlugin;
import org.apache.commons.httpclient.ConnectMethod;
import org.apache.commons.httpclient.HostConfiguration;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpConnection;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.httpclient.HttpState;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.httpclient.URI;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.protocol.Protocol;
import org.apache.commons.httpclient.util.EncodingUtil;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Preferences;
/**
* This class gets the wikitext from a wikipedia edit page
*
* The basic coding was copied from the commons-httpclient example MediaWikiConnector.java
*/
public class MediaWikiConnector {
//pattern used to scarp an edit page
private static final Pattern BODY_PATTERN = Pattern.compile(
/*
* action=".*?title=(.*?)(&|\")