manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1182697 - in /incubator/lcf/branches/CONNECTORS-256: connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/WikiConnector.java tests/wiki/src/test/java/org/apache/manifoldcf/wiki_tests/SanityDerbyTest.java
Date Thu, 13 Oct 2011 07:19:08 GMT
Author: kwright
Date: Thu Oct 13 07:19:08 2011
New Revision: 1182697

URL: http://svn.apache.org/viewvc?rev=1182697&view=rev
Log:
Add URL encoding for pipe symbols.

Modified:
    incubator/lcf/branches/CONNECTORS-256/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/WikiConnector.java
    incubator/lcf/branches/CONNECTORS-256/tests/wiki/src/test/java/org/apache/manifoldcf/wiki_tests/SanityDerbyTest.java

Modified: incubator/lcf/branches/CONNECTORS-256/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/WikiConnector.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-256/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/WikiConnector.java?rev=1182697&r1=1182696&r2=1182697&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-256/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/WikiConnector.java
(original)
+++ incubator/lcf/branches/CONNECTORS-256/connectors/wiki/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/wiki/WikiConnector.java
Thu Oct 13 07:19:08 2011
@@ -1419,7 +1419,14 @@ public class WikiConnector extends org.a
         sb.append("|");
       sb.append(documentIdentifiers[i]);
     }
-    return baseURL + "action=query&prop=info&pageids="+sb.toString()+"&inprop=url";
+    try
+    {
+      return baseURL + "action=query&prop=info&pageids="+URLEncoder.encode(sb.toString(),"utf-8")+"&inprop=url";
+    }
+    catch (UnsupportedEncodingException e)
+    {
+      throw new ManifoldCFException(e.getMessage(),e);
+    }
   }
 
   /** Thread to execute a "get timestamp" operation.  This thread both executes the operation
and parses the result. */
@@ -1723,7 +1730,14 @@ public class WikiConnector extends org.a
         sb.append("|");
       sb.append(documentIdentifiers[i]);
     }
-    return baseURL + "action=query&prop=revisions&pageids="+sb.toString()+"&rvprop=timestamp";
+    try
+    {
+      return baseURL + "action=query&prop=revisions&pageids="+URLEncoder.encode(sb.toString(),"utf-8")+"&rvprop=timestamp";
+    }
+    catch (UnsupportedEncodingException e)
+    {
+      throw new ManifoldCFException(e.getMessage(),e);
+    }
   }
 
   /** Thread to execute a "get timestamp" operation.  This thread both executes the operation
and parses the result. */
@@ -2303,7 +2317,7 @@ public class WikiConnector extends org.a
   protected String getGetDocInfoURL(String documentIdentifier)
     throws ManifoldCFException
   {
-    return baseURL + "action=query&prop=revisions&pageids="+documentIdentifier+"&rvprop=user|comment|content";
+    return baseURL + "action=query&prop=revisions&pageids="+documentIdentifier+"&rvprop=user%7ccomment%7ccontent";
   }
 
   /** Class representing the "api" context of a "get doc info" response */

Modified: incubator/lcf/branches/CONNECTORS-256/tests/wiki/src/test/java/org/apache/manifoldcf/wiki_tests/SanityDerbyTest.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-256/tests/wiki/src/test/java/org/apache/manifoldcf/wiki_tests/SanityDerbyTest.java?rev=1182697&r1=1182696&r2=1182697&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-256/tests/wiki/src/test/java/org/apache/manifoldcf/wiki_tests/SanityDerbyTest.java
(original)
+++ incubator/lcf/branches/CONNECTORS-256/tests/wiki/src/test/java/org/apache/manifoldcf/wiki_tests/SanityDerbyTest.java
Thu Oct 13 07:19:08 2011
@@ -48,10 +48,14 @@ public class SanityDerbyTest extends Bas
     initialListResources.put("Kre Mbaye","list_full_last.xml");
     
     initialTimestampQueryResources = new HashMap<String,String>();
-    initialTimestampQueryResources.put("14773725|19219017|19319577|19839654|30955295","get_timestamps.xml");
+    addCombinations(initialTimestampQueryResources,new String[]{"14773725","19219017","19319577","19839654","30955295"},"get_timestamps.xml");
+    // Use some individual overrides too
+    // MHL
     
     initialURLQueryResources = new HashMap<String,String>();
-    initialURLQueryResources.put("14773725|19219017|19319577|19839654|30955295","get_urls.xml");
+    addCombinations(initialURLQueryResources,new String[]{"14773725","19219017","19319577","19839654","30955295"},"get_urls.xml");
+    // Use some individual overrides too
+    // MHL
     
     initialDocInfoQueryResources = new HashMap<String,String>();
     initialDocInfoQueryResources.put("14773725","14773725.xml");
@@ -61,6 +65,62 @@ public class SanityDerbyTest extends Bas
     initialDocInfoQueryResources.put("30955295","30955295.xml");
     
   }
+
+  protected static void addCombinations(Map<String,String> target, String[] values,
String resource)
+  {
+    boolean[] vector = new boolean[values.length];
+    for (int i = 0 ; i < vector.length ; i++)
+    {
+      vector[i] = false;
+    }
+    
+    // Iterate through all the combinations.  Only take the ones that can exist.
+    while (true)
+    {
+      int result = 0;
+      for (int i = 0 ; i < vector.length ; i++)
+      {
+        result += vector[i]?1:0;
+      }
+      if (result != 0 && result <= 20)
+      {
+        // found one
+        StringBuilder sb = new StringBuilder();
+        boolean isFirst = true;
+        for (int i = 0 ; i < vector.length ; i++)
+        {
+          if (vector[i])
+          {
+            if (!isFirst)
+              sb.append("|");
+            else
+              isFirst = false;
+            sb.append(values[i]);
+          }
+        }
+        target.put(sb.toString(),resource);
+      }
+      // Now we increment.
+      int incLevel = 0;
+      while (incLevel < vector.length)
+      {
+        if (!vector[incLevel])
+        {
+          vector[incLevel] = true;
+          break;
+        }
+        // Had a carry
+        incLevel++;
+        for (int i = 0 ; i < incLevel ; i++)
+        {
+          vector[i] = false;
+        }
+      }
+      if (incLevel == vector.length)
+        break;
+    }
+        
+  }
   
   @Test
   public void sanityCheck()



Mime
View raw message