Added some more console messages
authoraxelcl <axelcl>
Sat, 22 Jan 2005 13:23:18 +0000 (13:23 +0000)
committeraxelcl <axelcl>
Sat, 22 Jan 2005 13:23:18 +0000 (13:23 +0000)
archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/actions/CreateFilesJob.java
archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/actions/mediawiki/LoadWikipediaSQLAction.java
archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/actions/mediawiki/RefreshJob.java
archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/actions/mediawiki/connect/MediaWikiConnector.java
archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/actions/mediawiki/connect/XMLReader.java
archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/actions/mediawiki/post/PostJob.java
archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/editor/WikiEditorPlugin.java
archive/net.sourceforge.phpeclipse.wiki/src/net/sourceforge/phpeclipse/wiki/internal/Configuration.java

index 82f7769..1b384c7 100644 (file)
@@ -42,9 +42,12 @@ public class CreateFilesJob extends WorkspaceJob {
         }
         try {
           if (!file.exists()) {
+            monitor.subTask("Create File: "+file.getLocation().toString());
             file.create(source, true, monitor);
           } else {
-            console.println("File: " + file.getLocation().toString() + "\n==>file already exists!");
+            String message = "File: " + file.getLocation().toString() + "\n==>file already exists!";
+            monitor.subTask(message);
+            console.println(message);
           }
         } catch (CoreException e) {
           if (file != null) {
index 1d0b92c..3344736 100644 (file)
@@ -50,56 +50,6 @@ public class LoadWikipediaSQLAction implements IEditorActionDelegate {
 
   private IWorkbenchWindow window;
 
-  private void createFolder(IFolder folderHandle, IProgressMonitor monitor) throws CoreException {
-    try {
-      // Create the folder resource in the workspace
-      // Recursive to create any folders which do not exist already
-      if (!folderHandle.exists()) {
-        IContainer parent = folderHandle.getParent();
-        if (parent instanceof IFolder && (!((IFolder) parent).exists())) {
-          createFolder((IFolder) parent, monitor);
-        }
-        folderHandle.create(false, true, monitor);
-      }
-    } catch (CoreException e) {
-      // If the folder already existed locally, just refresh to get contents
-      if (e.getStatus().getCode() == IResourceStatus.PATH_OCCUPIED)
-        folderHandle.refreshLocal(IResource.DEPTH_INFINITE, new SubProgressMonitor(monitor, 500));
-      else
-        throw e;
-    }
-  }
-
-  /**
-   * Creates a folder resource handle for the folder with the given workspace path. This method does not create the folder resource;
-   * this is the responsibility of <code>createFolder</code>.
-   * 
-   * @param folderPath
-   *          the path of the folder resource to create a handle for
-   * @return the new folder resource handle
-   * @see #createFolder
-   */
-  private IFolder createFolderHandle(IPath folderPath) {
-    return IDEWorkbenchPlugin.getPluginWorkspace().getRoot().getFolder(folderPath);
-  }
-
-  private void createNewFileIfNeeded(IFile file, String word) throws CoreException {
-    if (!file.exists()) {
-      createWikiFile(file, word);
-    }
-  }
-
-  private void createWikiFile(IFile file, String word) throws CoreException {
-    IContainer parent = file.getParent();
-    if (parent instanceof IFolder && (!((IFolder) parent).exists())) {
-      createFolder((IFolder) parent, null);
-    }
-    String newText = "<!--" + word + "-->";
-    byte[] buffer = newText.getBytes();
-    ByteArrayInputStream source = new ByteArrayInputStream(buffer);
-    file.create(source, true, null);
-  }
-
   public void dispose() {
   }
 
@@ -155,9 +105,6 @@ public class LoadWikipediaSQLAction implements IEditorActionDelegate {
   }
 
   public void openWikiLinkOnSelection() {
-    IDocument doc = getDocument();
-    ITextSelection selection = (ITextSelection) fEditor.getSelectionProvider().getSelection();
-    int pos = selection.getOffset();
     IFileEditorInput ei = (IFileEditorInput) fEditor.getEditorInput();
     openWikiFile(ei.getFile());
   }
index 49dec5b..321c369 100644 (file)
@@ -46,7 +46,7 @@ public class RefreshJob extends WorkspaceJob {
     ProblemConsole console = new ProblemConsole();
     IFile file = null;
     try {
-      monitor.beginTask("Refresh Wikis", 100);
+      monitor.beginTask("Download Wiki Articles: ", 100);
       //      ArrayList wikiTitles = new ArrayList();
       //      for (int i = 0; i < files.length; i++) {
       //        wikiTitles.add( Util.getReadableWikiName(files[i]) );
@@ -68,6 +68,7 @@ public class RefreshJob extends WorkspaceJob {
         url = configuration.getActionUrl() + "/" + configuration.getSpecialNs() + ":Export";
       }
       // get a list of Parsed elements
+      monitor.subTask("Downloading (XML Import)");
       ArrayList list = mwc.loadXML(configuration, url, buffer.toString());
       String body;
 
@@ -79,6 +80,7 @@ public class RefreshJob extends WorkspaceJob {
           if (body != null) {
             file = (IFile) map.get(wikiTitle);
             if (file != null) {
+              monitor.subTask("Modify file: "+file.getLocation().toString());
               updateFileContent(console, file, parsed, body, configuration, monitor);
             }
           }
index 4c1abb6..7d42d9b 100644 (file)
@@ -131,6 +131,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 +184,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());
       }
index 8cdfc20..013ff3b 100644 (file)
@@ -30,8 +30,11 @@ import org.xml.sax.SAXParseException;
  */
 public class XMLReader {
   private static final String TITLE_TAG = "title"; //$NON-NLS-1$
+
   private static final String TIMESTAMP_TAG = "timestamp"; //$NON-NLS-1$
+
   private static final String TEXT_TAG = "text"; //$NON-NLS-1$
+
   private static final String PAGE_TAG = "page"; //$NON-NLS-1$
 
   public XMLReader() {
@@ -86,20 +89,20 @@ public class XMLReader {
   private static void traverse(String eleName, Node cNode, Parsed parsed) {
     switch (cNode.getNodeType()) {
     case Node.DOCUMENT_NODE:
-//      System.out.println("DOCUMENT_NODE " + cNode.getNodeName());
+      //      System.out.println("DOCUMENT_NODE " + cNode.getNodeName());
       processChildren(eleName, cNode.getChildNodes(), parsed);
       break;
 
     case Node.ELEMENT_NODE:
       eleName = cNode.getNodeName();
-//      System.out.println("ELEMENT_NODE " + eleName);
-//      NamedNodeMap attributeMap = cNode.getAttributes();
-//      int numAttrs = attributeMap.getLength();
-//      for (int i = 0; i < attributeMap.getLength(); i++) {
-//        Attr attribute = (Attr) attributeMap.item(i);
-//        String attrName = attribute.getNodeName();
-//        String attrValue = attribute.getNodeValue();
-//      }
+      //      System.out.println("ELEMENT_NODE " + eleName);
+      //      NamedNodeMap attributeMap = cNode.getAttributes();
+      //      int numAttrs = attributeMap.getLength();
+      //      for (int i = 0; i < attributeMap.getLength(); i++) {
+      //        Attr attribute = (Attr) attributeMap.item(i);
+      //        String attrName = attribute.getNodeName();
+      //        String attrValue = attribute.getNodeValue();
+      //      }
       processChildren(eleName, cNode.getChildNodes(), parsed);
       break;
     case Node.CDATA_SECTION_NODE:
@@ -127,10 +130,59 @@ public class XMLReader {
   }
 
   /**
+   * Read the first timestamp found in the Wikipedia xml stream
+   * 
+   * @param stream
+   * @return
+   * @throws Exception
+   */
+  public static String getTimestamp(InputStream stream) throws Exception {
+    //  Create a factory object for creating DOM parsers
+    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+    //  Now use the factory to create a DOM parser (a.k.a. a DocumentBuilder)
+    DocumentBuilder parser = factory.newDocumentBuilder();
+    //  Parse the file and build a Document tree to represent its content
+    Document document = parser.parse(stream);
+    //  Ask the document for a list of all <page> tags it contains
+    NodeList timestamps = document.getElementsByTagName(TIMESTAMP_TAG);
+    //  Loop through those <mediawiki> elements one at a time, and extract the
+    //  content of their <page> tags.
+    int numPages = timestamps.getLength();
+    for (int i = 0; i < numPages; i++) {
+      ElementNode page = (ElementNode) timestamps.item(i); // A <timestamp>
+      return page.getChildNodes().item(0).getNodeValue();
+    }
+    return null;
+  }
+  
+  /**
+   * Get the timestamp as java Date Format String
+   * 
+   * @param stream
+   * @return
+   * @throws Exception
+   */
+  public static String getDateTimestamp(InputStream stream) throws Exception {
+    String timestamp = getTimestamp(stream);
+    if (timestamp!=null) {
+      StringBuffer buffer = new StringBuffer();
+      // 2004-11-22T12:41:10Z
+      buffer.append(timestamp.substring(0,4));  //year
+      buffer.append(timestamp.substring(5,7));  //month
+      buffer.append(timestamp.substring(8,10)); //day
+      buffer.append(timestamp.substring(11,13));//hour
+      buffer.append(timestamp.substring(14,16));//minute
+      buffer.append(timestamp.substring(17,19));//second
+      return buffer.toString();
+    } 
+    return null;
+  }
+
+  /**
    * Reads the wikipedia xml data from the given stream
    * 
    * @param stream
-   * @return 
+   * @return
    * @throws CoreException
    */
   public static ArrayList readFromStream(Reader stream) throws CoreException {
@@ -144,8 +196,7 @@ public class XMLReader {
       Document document = parser.parse(new InputSource(stream));
       //  Ask the document for a list of all <page> tags it contains
       NodeList pages = document.getElementsByTagName(PAGE_TAG);
-      //  Loop through those <mediawiki> elements one at a time, and extract the
-      //  content of their <page> tags.
+      //  Loop through those <page> elements one at a time
       int numPages = pages.getLength();
 
       for (int i = 0; i < numPages; i++) {
@@ -162,7 +213,7 @@ public class XMLReader {
     } catch (IOException e) {
       throwReadException(e);
     } catch (SAXParseException e) {
-//      System.out.println("SAXParseException in line:" + e.getLineNumber() + " column:" + e.getColumnNumber());
+      //      System.out.println("SAXParseException in line:" + e.getLineNumber() + " column:" + e.getColumnNumber());
       throwReadException(e);
     } catch (SAXException e) {
       throwReadException(e);
@@ -174,7 +225,7 @@ public class XMLReader {
     Node node = attributes.getNamedItem(name);
     return node == null ? null : node.getNodeValue();
   }
-  
+
   //  public static void saveToFile(File file) throws CoreException {
   //    OutputStream stream = null;
   //    try {
@@ -347,9 +398,9 @@ public class XMLReader {
           + "\r\n" + "[[Kategorie:Rhetorischer Begriff]]\r\n"
           + "[[en:Synaesthesia]] [[es:Sinestesia]] [[sv:Synestesi]] [[tr:Sinestezi]]</text>\r\n" + "    </revision>\r\n"
           + "  </page>\r\n" + "</mediawiki>";
-      StringReader st = new StringReader(test2);
+      StringReader st = new StringReader(test);
 
-      readFromStream(st);
+      System.out.println(readFromStream(st));
     } catch (CoreException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
index 5767954..24f807e 100644 (file)
@@ -3,14 +3,15 @@ package net.sourceforge.phpeclipse.wiki.actions.mediawiki.post;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.StringWriter;
-import java.util.Date;
 import java.util.HashMap;
 
 import net.sourceforge.phpeclipse.wiki.actions.ProblemConsole;
 import net.sourceforge.phpeclipse.wiki.actions.mediawiki.config.IWikipedia;
 import net.sourceforge.phpeclipse.wiki.actions.mediawiki.connect.Content;
 import net.sourceforge.phpeclipse.wiki.actions.mediawiki.connect.MediaWikiConnector;
+import net.sourceforge.phpeclipse.wiki.actions.mediawiki.connect.XMLReader;
 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 net.sourceforge.phpeclipse.wiki.internal.Configuration;
@@ -20,10 +21,13 @@ import net.sourceforge.phpeclipse.wiki.velocity.EditorText;
 import org.apache.velocity.VelocityContext;
 import org.apache.velocity.app.Velocity;
 import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.resources.WorkspaceJob;
 import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.core.runtime.jobs.Job;
 import org.eclipse.ui.progress.IProgressConstants;
@@ -77,25 +81,20 @@ public class PostJob extends WorkspaceJob {
     return template;
   }
 
-  private void selectWiki(String body, MediaWikiConnector connector, String actionUrl, String wikiName) {
+  private void selectWiki(String timestamp, String body, MediaWikiConnector connector, String actionUrl, String wikiName)
+      throws UnexpectedAnswerException, MethodException, PageNotEditableException, InterruptedException {
 
-    try {
-      String url = generateUrl(configuration.getURL(), wikiName);
-
-      Date d = new Date();
-      Content content = new Content(String.valueOf(d.getTime()), body);
+    String url = generateUrl(configuration.getURL(), wikiName);
+    //      System.out.println(timestamp);
+    Content content = new Content(timestamp, body);
 
-      connector.store(wikipedia, actionUrl, wikiName, content, "", false, false);
+    connector.store(wikipedia, actionUrl, wikiName, content, "", false, false);
 
-    } catch (Exception e) {
-      e.printStackTrace();
-      WikiEditorPlugin.getDefault()
-          .reportError("Exception occured: ", e.getMessage() + "\nSee stacktrace in /.metadata/.log file.");
-    }
   }
 
   public IStatus runInWorkspace(IProgressMonitor monitor) {
     boolean success = false;
+    IFile file = null;
     MediaWikiConnector connector = null;
     InputStream is = null;
     ProblemConsole console = new ProblemConsole();
@@ -105,15 +104,18 @@ public class PostJob extends WorkspaceJob {
       actionUrl = wikipedia.getActionUrl();
     }
     try {
-      monitor.beginTask("Refresh Wikis", 100);
+      if (files.length>0) {
+        // prefetch for error messages
+        file = files[0];
+      }
+      monitor.beginTask("Upload Wiki Articles: ", 100);
       int partWork = 100 / files.length;
       int work = 0;
-      int autoCreateIndex = -1;
       StringBuffer buffer = new StringBuffer();
       HashMap map = new HashMap();
       String wikiTitle;
-      IFile file = null;
 
+      monitor.subTask("Login user:"+user);
       connector = new MediaWikiConnector();
       success = connector.login(wikipedia, actionUrl, user, password, false);
       if (success) {
@@ -123,18 +125,37 @@ public class PostJob extends WorkspaceJob {
             is = file.getContents();
             String wikiName = Util.getFileWikiName(file);
             String body = StoreWikipediaAction.getInputStreamAsString(is, wikipedia.getCharSet());
-            autoCreateIndex = body.indexOf(WikiEditorPlugin.AUTOMATICALLY_CREATED);
-            if (autoCreateIndex < 0) {
-              selectWiki(body, connector, actionUrl, wikiName);
+            char ch;
+            boolean noContent = checkNoContent(body);
+            String srcBasePath = Util.getWikiTextsPath(file);
+            String binBasePath = Util.getProjectsWikiOutputPath(file.getProject(), WikiEditorPlugin.HTML_OUTPUT_PATH);
+
+            String filename = Util.getXMLFileName(file, binBasePath, srcBasePath);
+            IPath path = new Path(filename);
+            IFile xmlFile = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(path);
+            String timestamp = null;
+            if (xmlFile.exists()) {
+              try {
+                timestamp = XMLReader.getDateTimestamp(xmlFile.getContents());
+              } catch (Exception e2) {
+              }
+            }
+            if (timestamp == null) {
+              //              Date d = new Date();
+              //              timestamp = String.valueOf(d.getTime());
+              timestamp = "";
+            }
+
+            if (noContent) {
+              console.println("File: " + file.getLocation().toString() + "\n==>upload not allowed; Wiki text contains no content");
             } else {
-              console.println("File: " + file.getLocation().toString() + "\n==>no upload allowed; Wiki text contains string: "
-                  + WikiEditorPlugin.AUTOMATICALLY_CREATED);
+              monitor.subTask("Upload: " + file.getLocation().toString());
+              selectWiki(timestamp, body, connector, actionUrl, wikiName);
             }
 
           } catch (CoreException e1) {
             if (file != null) {
-              console.println("File: " + file.getLocation().toString() + "\n==>CoreException: "
-                  + e1.getMessage());
+              console.println("File: " + file.getLocation().toString() + "\n==>CoreException: " + e1.getMessage());
             }
           }
           if (monitor.isCanceled()) {
@@ -156,15 +177,32 @@ public class PostJob extends WorkspaceJob {
       //        } catch(CoreException e) {
       //          return e.getStatus();
     } catch (IOException e) {
+      if (file != null) {
+        console.println("File: " + file.getLocation().toString());
+      }
       console.println("==>IOException: " + e.getMessage());
     } catch (UnexpectedAnswerException e) {
       console.println("==>UnexpectedAnswerException: " + e.getMessage());
+    } catch (InterruptedException e) {
+      if (file != null) {
+        console.println("File: " + file.getLocation().toString());
+      }
+      console.println("==>InterruptedException: " + e.getMessage());
+    } catch (PageNotEditableException e) {
+      if (file != null) {
+        console.println("File: " + file.getLocation().toString());
+      }
+      console.println("==>PageNotEditableException: " + e.getMessage());
     } catch (MethodException e) {
+      if (file != null) {
+        console.println("File: " + file.getLocation().toString());
+      }
       console.println("==>HTTP-MethodException: " + e.getMessage());
     } finally {
       monitor.done();
       if (success && connector != null) {
         try {
+          monitor.subTask("Logout!");
           connector.logout(wikipedia, actionUrl);
         } catch (UnexpectedAnswerException e1) {
           console.println("==>UnexpectedAnswerException: " + e1.getMessage());
@@ -186,6 +224,43 @@ public class PostJob extends WorkspaceJob {
     return Status.CANCEL_STATUS;
   }
 
+  /**
+   * @param body
+   * @param j
+   * @return
+   */
+  private boolean checkNoContent(String body) {
+    char ch;
+    boolean noContent = true;
+    int j = 0;
+    try {
+      while (true) {
+        ch = body.charAt(j++);
+        if (!Character.isWhitespace(ch)) {
+          if (ch == '<' && body.charAt(j) == '!' && body.charAt(j + 1) == '-' && body.charAt(j + 2) == '-') {
+            //<!-- ... -->
+            j += 3;
+            while (true) {
+              ch = body.charAt(j++);
+              if (ch == '-' && body.charAt(j) == '-' && body.charAt(j + 1) == '>') {
+                j += 2;
+                break;
+              }
+            }
+          } else if (ch == '<' && body.charAt(j) == 'b' && body.charAt(j + 1) == 'r' && body.charAt(j + 2) == '>') {
+            // <br>
+          } else {
+            noContent = false;
+            break;
+          }
+        }
+      }
+    } catch (IndexOutOfBoundsException e) {
+
+    }
+    return noContent;
+  }
+
   public boolean isModal(Job job) {
     Boolean isModal = (Boolean) job.getProperty(IProgressConstants.PROPERTY_IN_DIALOG);
     if (isModal == null) {
index eebe5e1..fa131a4 100644 (file)
@@ -129,8 +129,8 @@ public class WikiEditorPlugin extends AbstractUIPlugin {
   public final static String LOCAL_CSS_URL = "__local_css_url";
 
   public final static String EXPORT_CSS_URL = "__export_css_url";
-
-  public final static String PREF_STRING_CONFIGURATIONS = "__configurations3";
+  public final static String PREF_STRING_CONFIGURATIONS = "__configurations4";
 
   public final static String CONFIG_MEMENTO = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<configurations>"
       + "<config name=\"Google Search\" type-id=\"HTTP Query\" url=\"http://www.google.com/search?q=$text.selection\"/>"
@@ -140,8 +140,8 @@ public class WikiEditorPlugin extends AbstractUIPlugin {
       + "<config name=\"Plog4U.de Download\" type-id=\"" + PLOG4U_DE_LOAD
       + "\" url=\"http://www.plog4u.de/index.php/Spezial:Export\"/>" + "<config name=\"Plog4U.org Download\" type-id=\""
       + PLOG4U_ORG_LOAD + "\" url=\"http://www.plog4u.org/index.php/Special:Export\"/>"
-      + "<config name=\"Plog4U.de Upload\" type-id=\"" + PLOG4U_DE_STORE + "\" url=\"http://en.wikipedia.org/w/index.php\"/>"
-      + "<config name=\"Plog4U.org Upload\" type-id=\"" + PLOG4U_ORG_STORE + "\" url=\"http://en.wikibooks.org/w/index.php\"/>"
+      + "<config name=\"Plog4U.de Upload\" type-id=\"" + PLOG4U_DE_STORE + "\" url=\"http://www.plog4u.de/index.php\"/>"
+      + "<config name=\"Plog4U.org Upload\" type-id=\"" + PLOG4U_ORG_STORE + "\" url=\"http://www.plog4u.org/index.php\"/>"
 
       + "<config name=\"WikipediaEN Download\" type-id=\"" + PREFIX_LOAD
       + "WikipediaEN\" url=\"http://en.wikipedia.org/wiki/Special:Export\"/>" + "<config name=\"WikibooksEN Download\" type-id=\""
index c961a81..d3b5875 100644 (file)
@@ -44,24 +44,264 @@ public class Configuration implements IConfiguration, Comparable {
 
   protected String fType = "";
 
-  private static final char[] SCRAMBLING_TABLE=new char[] {
-       0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,
-       16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,
-       114,120,53,79,96,109,72,108,70,64,76,67,116,74,68,87,
-       111,52,75,119,49,34,82,81,95,65,112,86,118,110,122,105,
-       41,57,83,43,46,102,40,89,38,103,45,50,42,123,91,35,
-       125,55,54,66,124,126,59,47,92,71,115,78,88,107,106,56,
-       36,121,117,104,101,100,69,73,99,63,94,93,39,37,61,48,
-       58,113,32,90,44,98,60,51,33,97,62,77,84,80,85,223,
-       225,216,187,166,229,189,222,188,141,249,148,200,184,136,248,190,
-       199,170,181,204,138,232,218,183,255,234,220,247,213,203,226,193,
-       174,172,228,252,217,201,131,230,197,211,145,238,161,179,160,212,
-       207,221,254,173,202,146,224,151,140,196,205,130,135,133,143,246,
-       192,159,244,239,185,168,215,144,139,165,180,157,147,186,214,176,
-       227,231,219,169,175,156,206,198,129,164,150,210,154,177,134,127,
-       182,128,158,208,162,132,167,209,149,241,153,251,237,236,171,195,
-       243,233,253,240,194,250,191,155,142,137,245,235,163,242,178,152
-       };
+  private static final char[] SCRAMBLING_TABLE = new char[] {
+      0,
+      1,
+      2,
+      3,
+      4,
+      5,
+      6,
+      7,
+      8,
+      9,
+      10,
+      11,
+      12,
+      13,
+      14,
+      15,
+      16,
+      17,
+      18,
+      19,
+      20,
+      21,
+      22,
+      23,
+      24,
+      25,
+      26,
+      27,
+      28,
+      29,
+      30,
+      31,
+      114,
+      120,
+      53,
+      79,
+      96,
+      109,
+      72,
+      108,
+      70,
+      64,
+      76,
+      67,
+      116,
+      74,
+      68,
+      87,
+      111,
+      52,
+      75,
+      119,
+      49,
+      34,
+      82,
+      81,
+      95,
+      65,
+      112,
+      86,
+      118,
+      110,
+      122,
+      105,
+      41,
+      57,
+      83,
+      43,
+      46,
+      102,
+      40,
+      89,
+      38,
+      103,
+      45,
+      50,
+      42,
+      123,
+      91,
+      35,
+      125,
+      55,
+      54,
+      66,
+      124,
+      126,
+      59,
+      47,
+      92,
+      71,
+      115,
+      78,
+      88,
+      107,
+      106,
+      56,
+      36,
+      121,
+      117,
+      104,
+      101,
+      100,
+      69,
+      73,
+      99,
+      63,
+      94,
+      93,
+      39,
+      37,
+      61,
+      48,
+      58,
+      113,
+      32,
+      90,
+      44,
+      98,
+      60,
+      51,
+      33,
+      97,
+      62,
+      77,
+      84,
+      80,
+      85,
+      223,
+      225,
+      216,
+      187,
+      166,
+      229,
+      189,
+      222,
+      188,
+      141,
+      249,
+      148,
+      200,
+      184,
+      136,
+      248,
+      190,
+      199,
+      170,
+      181,
+      204,
+      138,
+      232,
+      218,
+      183,
+      255,
+      234,
+      220,
+      247,
+      213,
+      203,
+      226,
+      193,
+      174,
+      172,
+      228,
+      252,
+      217,
+      201,
+      131,
+      230,
+      197,
+      211,
+      145,
+      238,
+      161,
+      179,
+      160,
+      212,
+      207,
+      221,
+      254,
+      173,
+      202,
+      146,
+      224,
+      151,
+      140,
+      196,
+      205,
+      130,
+      135,
+      133,
+      143,
+      246,
+      192,
+      159,
+      244,
+      239,
+      185,
+      168,
+      215,
+      144,
+      139,
+      165,
+      180,
+      157,
+      147,
+      186,
+      214,
+      176,
+      227,
+      231,
+      219,
+      169,
+      175,
+      156,
+      206,
+      198,
+      129,
+      164,
+      150,
+      210,
+      154,
+      177,
+      134,
+      127,
+      182,
+      128,
+      158,
+      208,
+      162,
+      132,
+      167,
+      209,
+      149,
+      241,
+      153,
+      251,
+      237,
+      236,
+      171,
+      195,
+      243,
+      233,
+      253,
+      240,
+      194,
+      250,
+      191,
+      155,
+      142,
+      137,
+      245,
+      235,
+      163,
+      242,
+      178,
+      152 };
+
   public Configuration() {
     this(WikiEditorPlugin.HTTP_QUERY); // default type
   }
@@ -137,7 +377,7 @@ public class Configuration implements IConfiguration, Comparable {
     memento.putString(MEMENTO_TYPE_ID, fType);
     memento.putString(MEMENTO_USER, fUser);
     memento.putString(MEMENTO_URL, fUrl);
-    String result = 'A'+scramblePassword(fPassword);
+    String result = 'A' + scramblePassword(fPassword);
     memento.putString(MEMENTO_PASSWORD, result);
   }
 
@@ -163,7 +403,7 @@ public class Configuration implements IConfiguration, Comparable {
       fUrl = "";
     }
     String result = memento.getString(MEMENTO_PASSWORD);
-    
+
     if (result == null) {
       fPassword = "";
     } else {
@@ -200,7 +440,7 @@ public class Configuration implements IConfiguration, Comparable {
     return 1;
   }
 
-  private static String scramblePassword(String password)  {
+  private static String scramblePassword(String password) {
     int length = password.length();
     char[] out = new char[length];
     for (int i = 0; i < length; i++) {
@@ -211,19 +451,18 @@ public class Configuration implements IConfiguration, Comparable {
   }
 
   public boolean isUserComplete() {
-    if (fUser==null || fUser.equals("")) {
+    if (fUser == null || fUser.equals("")) {
       return false;
     }
-    if (fPassword==null || fPassword.equals("")) {
+    if (fPassword == null || fPassword.equals("")) {
       return false;
     }
     return true;
   }
+
   /**
-   * Asks the user to enter a password. Places the results in the supplied string[]. 
-   * result[0] must contain the username, 
-   * result[1] must contain the fPassword. 
-   * If the user canceled, both values must be zero.
+   * Asks the user to enter a password. Places the results in the supplied string[]. result[0] must contain the username, result[1]
+   * must contain the fPassword. If the user canceled, both values must be zero.
    * 
    * @param location
    *          the location to obtain the fPassword for
@@ -238,7 +477,7 @@ public class Configuration implements IConfiguration, Comparable {
    */
   public boolean promptForPassword(final String username, final String message, final boolean userMutable, final String[] result) {
     if (isUserComplete()) {
-      result[0] = fUser; 
+      result[0] = fUser;
       result[1] = fPassword;
       return true;
     }
@@ -250,7 +489,7 @@ public class Configuration implements IConfiguration, Comparable {
     }
     UserValidationDialog dialog = new UserValidationDialog(shell, fUrl, (username == null) ? "" : username, message);//$NON-NLS-1$
     dialog.setUsernameMutable(userMutable);
-    dialog.open(); 
+    dialog.open();
     result[0] = dialog.getUsername();
     result[1] = dialog.getPassword();
     if (dialog.getAllowCaching()) {
@@ -259,4 +498,19 @@ public class Configuration implements IConfiguration, Comparable {
     }
     return dialog.getAllowCaching();
   }
+
+  /*
+   * (non-Javadoc)
+   * 
+   * @see java.lang.Object#equals(java.lang.Object)
+   */
+  public boolean equals(Object obj) {
+    if (obj instanceof Configuration) {
+      if (fName == null || ((Configuration) obj).fName == null) {
+        return false;
+      }
+      return fName.equals(((Configuration) obj).fName);
+    }
+    return false;
+  }
 }
\ No newline at end of file