manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1294388 - in /incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch: ElasticSearchDelete.java ElasticSearchIndex.java
Date Mon, 27 Feb 2012 23:13:49 GMT
Author: kwright
Date: Mon Feb 27 23:13:49 2012
New Revision: 1294388

URL: http://svn.apache.org/viewvc?rev=1294388&view=rev
Log:
Attempt to use url-encoding to make a url palatable for elastic search filename.  Doesn't
work though.

Modified:
    incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchDelete.java
    incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchIndex.java

Modified: incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchDelete.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchDelete.java?rev=1294388&r1=1294387&r2=1294388&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchDelete.java
(original)
+++ incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchDelete.java
Mon Feb 27 23:13:49 2012
@@ -29,16 +29,23 @@ public class ElasticSearchDelete extends
       throws ManifoldCFException
   {
     super(config, client);
-    String fileName = FilenameUtils.getName(documentURI);
-    DeleteMethod method = new DeleteMethod(config.getServerLocation());
-    method.setPath("/" + config.getIndexName() + "/" + config.getIndexType()
-        + "/" + fileName);
-    System.out.println("Deleting '"+documentURI+"'...");
-    call(method);
-    System.out.println("... completed");
-    System.out.println(jsonStatus);
-    if ("ok".equals(jsonStatus))
-      return;
-    setResult(Result.ERROR, checkJson(jsonException));
+    try
+    {
+      String fileName = java.net.URLEncoder.encode(documentURI,"utf-8");
+      DeleteMethod method = new DeleteMethod(config.getServerLocation());
+      method.setPath("/" + config.getIndexName() + "/" + config.getIndexType()
+          + "/" + fileName);
+      System.out.println("Deleting '"+fileName+"'...");
+      call(method);
+      System.out.println("... completed");
+      System.out.println(jsonStatus);
+      if ("ok".equals(jsonStatus))
+        return;
+      setResult(Result.ERROR, checkJson(jsonException));
+    }
+    catch (java.io.UnsupportedEncodingException e)
+    {
+      throw new ManifoldCFException(e.getMessage(),e);
+    }
   }
 }

Modified: incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchIndex.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchIndex.java?rev=1294388&r1=1294387&r2=1294388&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchIndex.java
(original)
+++ incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchIndex.java
Mon Feb 27 23:13:49 2012
@@ -43,10 +43,18 @@ public class ElasticSearchIndex extends 
     private String fileName;
 
     public IndexRequestEntity(String documentURI, InputStream inputStream)
+      throws ManifoldCFException
     {
       this.documentURI = documentURI;
       this.inputStream = inputStream;
-      this.fileName = FilenameUtils.getName(documentURI);
+      try
+      {
+        this.fileName = java.net.URLEncoder.encode(documentURI,"utf-8");
+      }
+      catch (java.io.UnsupportedEncodingException e)
+      {
+        throw new ManifoldCFException(e.getMessage(),e);
+      }
     }
 
     public long getContentLength()



Mime
View raw message