incubator-connectors-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1243123 - in /incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch: ElasticSearchDelete.java ElasticSearchIndex.java ElasticSearchSchema.java
Date Sat, 11 Feb 2012 19:09:06 GMT
Author: kwright
Date: Sat Feb 11 19:09:05 2012
New Revision: 1243123

URL: http://svn.apache.org/viewvc?rev=1243123&view=rev
Log:
Commit latest patch.

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
    incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchSchema.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=1243123&r1=1243122&r2=1243123&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
Sat Feb 11 19:09:05 2012
@@ -1,37 +1,38 @@
 /**
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 
 package org.apache.manifoldcf.agents.output.elasticsearch;
 
-import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.methods.DeleteMethod;
+import org.apache.commons.io.FilenameUtils;
 import org.apache.manifoldcf.core.interfaces.ManifoldCFException;
 
 public class ElasticSearchDelete extends ElasticSearchConnection {
 
-  public ElasticSearchDelete(String documentURI,
-      ElasticSearchConfig config) throws ManifoldCFException {
-    super(config);
-    StringBuffer url = getApiUrl("_delete");
-    url.append("&uniq=");
-    url.append(urlEncode(documentURI));
-    GetMethod method = new GetMethod(url.toString());
-    call(method);
-    if ("true".equals(checkJson(jsonStatus)))
-      return;
-    setResult(Result.ERROR, checkJson(jsonException));
-  }
+	public ElasticSearchDelete(String documentURI, ElasticSearchConfig config)
+			throws ManifoldCFException {
+		super(config);
+		String fileName = FilenameUtils.getName(documentURI);
+		DeleteMethod method = new DeleteMethod(config.getServerLocation());
+		method.setPath("/" + config.getIndexName() + "/"
+				+ config.getIndexType() + "/" + fileName);
+		call(method);
+		if ("true".equals(checkJson(jsonStatus)))
+			return;
+		setResult(Result.ERROR, checkJson(jsonException));
+	}
 }

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=1243123&r1=1243122&r2=1243123&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
Sat Feb 11 19:09:05 2012
@@ -60,16 +60,16 @@ public class ElasticSearchIndex extends 
 		public void writeRequest(OutputStream out) throws IOException {
 			PrintWriter pw = new PrintWriter(out);
 			try {
-				pw.println("{");
-				pw.print("\"fieldname\" : ");
-				pw.println("\"" + documentURI + "\"");
+				pw.print("{");
+				pw.print("\"fieldName\" : ");
+				pw.print("\"" + documentURI + "\"" + ",");
 				pw.print("\"fileName\" : ");
-				pw.println("\"" + fileName + "\"");
-				pw.print("\"binaryvalue\" : \"aqaq");
+				pw.print("\"" + fileName + "\"" + ",");
+				pw.print("\"binaryValue\" : \"");
 				Base64 base64 = new Base64();
 				base64.encodeStream(inputStream, pw);
-				pw.println("\"");
-				pw.println("}");
+				pw.print("\"");
+				pw.print("}");
 			} catch (ManifoldCFException e) {
 				throw new IOException(e.getMessage());
 			} finally {
@@ -81,7 +81,8 @@ public class ElasticSearchIndex extends 
 	public ElasticSearchIndex(String documentURI, InputStream inputStream,
 			ElasticSearchConfig config) throws ManifoldCFException {
 		super(config);
-		StringBuffer url = getApiUrl(config.getIndexType() + "/_update");
+		String fileName = FilenameUtils.getName(documentURI);
+		StringBuffer url = getApiUrl(config.getIndexType() + "/" + fileName);
 		PutMethod put = new PutMethod(url.toString());
 		RequestEntity entity = new IndexRequestEntity(documentURI, inputStream);
 		put.setRequestEntity(entity);

Modified: incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchSchema.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchSchema.java?rev=1243123&r1=1243122&r2=1243123&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchSchema.java
(original)
+++ incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchSchema.java
Sat Feb 11 19:09:05 2012
@@ -1,38 +0,0 @@
-/**
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-package org.apache.manifoldcf.agents.output.elasticsearch;
-
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.apache.manifoldcf.core.interfaces.ManifoldCFException;
-
-public class ElasticSearchSchema extends ElasticSearchConnection {
-
-  public ElasticSearchSchema(ElasticSearchConfig config)
-      throws ManifoldCFException {
-    super(config);
-    String indexName = config.getIndexName();
-    StringBuffer url = getApiUrl("schema");
-    url.append("&cmd=indexList");
-    GetMethod method = new GetMethod(url.toString());
-    String json = "count(/response/index[@name='" + indexName + "'])";
-    call(method);
-    if ("1".equals(checkJson(json)))
-      return;
-    setResult(Result.ERROR, "Index not found");
-  }
-}



Mime
View raw message