incubator-connectors-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1299508 - in /incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch: ElasticSearchDelete.java ElasticSearchIndex.java
Date Mon, 12 Mar 2012 00:43:57 GMT
Author: kwright
Date: Mon Mar 12 00:43:57 2012
New Revision: 1299508

URL: http://svn.apache.org/viewvc?rev=1299508&view=rev
Log:
Use encoded URI as document key.

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=1299508&r1=1299507&r2=1299508&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 Mar 12 00:43:57 2012
@@ -31,11 +31,11 @@ public class ElasticSearchDelete extends
     super(config, client);
     try
     {
-      String fileName = java.net.URLEncoder.encode(documentURI,"utf-8");
+      String idField = 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+"'...");
+          + "/" + idField);
+      System.out.println("Deleting '"+idField+"'...");
       call(method);
       System.out.println("... completed");
       System.out.println(jsonStatus);

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=1299508&r1=1299507&r2=1299508&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 Mar 12 00:43:57 2012
@@ -36,25 +36,12 @@ public class ElasticSearchIndex extends 
   private class IndexRequestEntity implements RequestEntity
   {
 
-    private String documentURI;
-
     private InputStream inputStream;
 
-    private String fileName;
-
-    public IndexRequestEntity(String documentURI, InputStream inputStream)
+    public IndexRequestEntity(InputStream inputStream)
       throws ManifoldCFException
     {
-      this.documentURI = documentURI;
       this.inputStream = inputStream;
-      try
-      {
-        this.fileName = java.net.URLEncoder.encode(documentURI,"utf-8");
-      }
-      catch (java.io.UnsupportedEncodingException e)
-      {
-        throw new ManifoldCFException(e.getMessage(),e);
-      }
     }
 
     public long getContentLength()
@@ -78,10 +65,10 @@ public class ElasticSearchIndex extends 
       try
       {
         pw.print("{");
-        pw.print("\"fieldName\" : ");
-        pw.print("\"" + documentURI + "\"" + ",");
-        pw.print("\"fileName\" : ");
-        pw.print("\"" + fileName + "\"" + ",");
+        //pw.print("\"fieldName\" : ");
+        //pw.print("\"" + documentURI + "\"" + ",");
+        //pw.print("\"fileName\" : ");
+        //pw.print("\"" + fileName + "\"" + ",");
         pw.print("\"binaryValue\" : \"");
         Base64 base64 = new Base64();
         base64.encodeStream(inputStream, pw);
@@ -101,10 +88,20 @@ public class ElasticSearchIndex extends 
       ElasticSearchConfig config) throws ManifoldCFException
   {
     super(config, client);
-    String fileName = FilenameUtils.getName(documentURI);
-    StringBuffer url = getApiUrl(config.getIndexType() + "/" + fileName, false);
+    
+    String idField;
+    try
+    {
+      idField = java.net.URLEncoder.encode(documentURI,"utf-8");
+    }
+    catch (java.io.UnsupportedEncodingException e)
+    {
+      throw new ManifoldCFException(e.getMessage(),e);
+    }
+
+    StringBuffer url = getApiUrl(config.getIndexType() + "/" + idField, false);
     PutMethod put = new PutMethod(url.toString());
-    RequestEntity entity = new IndexRequestEntity(documentURI, inputStream);
+    RequestEntity entity = new IndexRequestEntity(inputStream);
     put.setRequestEntity(entity);
     call(put);
     if ("true".equals(checkJson(jsonStatus)))



Mime
View raw message