incubator-connectors-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1242175 - in /incubator/lcf/branches/CONNECTORS-288: ./ connectors/elasticsearch/ connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ connectors/elasticsearch/connector/src/main/resources/org...
Date Wed, 08 Feb 2012 23:34:30 GMT
Author: kwright
Date: Wed Feb  8 23:34:30 2012
New Revision: 1242175

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

Modified:
    incubator/lcf/branches/CONNECTORS-288/build.xml
    incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchAction.java
    incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchConnection.java
    incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchConnector.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/ElasticSearchParam.java
    incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/Messages.java
    incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/resources/org/apache/manifoldcf/agents/output/elasticsearch/editConfiguration_en_US.html
    incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/resources/org/apache/manifoldcf/agents/output/elasticsearch/editConfiguration_en_US.js
    incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/resources/org/apache/manifoldcf/agents/output/elasticsearch/viewConfiguration_en_US.html
    incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/resources/org/apache/manifoldcf/agents/output/elasticsearch/viewConfiguration_ja_JP.html
    incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/pom.xml

Modified: incubator/lcf/branches/CONNECTORS-288/build.xml
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-288/build.xml?rev=1242175&r1=1242174&r2=1242175&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-288/build.xml (original)
+++ incubator/lcf/branches/CONNECTORS-288/build.xml Wed Feb  8 23:34:30 2012
@@ -1520,8 +1520,8 @@
             <param name="connector-name" value="elasticsearch"/>
         </antcall>
         <antcall target="general-add-output-connector">
-            <param name="connector-name" value="OpenSearchServer"/>
-            <param name="connector-class" value="org.apache.manifoldcf.agents.output.elasticsearch.OpenSearchServerConnector"/>
+            <param name="connector-name" value="ElasticSearch"/>
+            <param name="connector-class" value="org.apache.manifoldcf.agents.output.elasticsearch.ElasticSearchConnector"/>
         </antcall>
     </target>
 

Modified: incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchAction.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchAction.java?rev=1242175&r1=1242174&r2=1242175&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchAction.java
(original)
+++ incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchAction.java
Wed Feb  8 23:34:30 2012
@@ -23,15 +23,14 @@ import org.apache.manifoldcf.core.interf
 public class ElasticSearchAction extends ElasticSearchConnection {
 
   public enum CommandEnum {
-    optimize, reload;
+    _optimize, _refresh;
   }
 
   public ElasticSearchAction(CommandEnum cmd, ElasticSearchConfig config)
       throws ManifoldCFException {
     super(config);
     StringBuffer url = getApiUrl("action");
-    url.append("&action=");
-    url.append(cmd.name());
+    url.append("/"+cmd.name());
     GetMethod method = new GetMethod(url.toString());
     call(method);
     if ("OK".equals(checkXPath(xPathStatus)))

Modified: incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchConnection.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchConnection.java?rev=1242175&r1=1242174&r2=1242175&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchConnection.java
(original)
+++ incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchConnection.java
Wed Feb  8 23:34:30 2012
@@ -43,6 +43,8 @@ public class ElasticSearchConnection {
 
   private String serverLocation;
 
+  private String indexName;
+
   private String userName;
 
   private String apiKey;
@@ -71,6 +73,7 @@ public class ElasticSearchConnection {
     resultDescription = "";
     callUrlSnippet = null;
     serverLocation = config.getServerLocation();
+    indexName = config.getIndexName();
     userName = config.getUserName();
     apiKey = config.getApiKey();
   }
@@ -87,7 +90,7 @@ public class ElasticSearchConnection {
     StringBuffer url = new StringBuffer(serverLocation);
     if (!serverLocation.endsWith("/"))
       url.append('/');
-    url.append(command);
+    url.append(urlEncode(indexName));
     callUrlSnippet = url.toString();
     if (userName != null && apiKey != null && userName.length() > 0
         && apiKey.length() > 0) {

Modified: incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchConnector.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchConnector.java?rev=1242175&r1=1242174&r2=1242175&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchConnector.java
(original)
+++ incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchConnector.java
Wed Feb  8 23:34:30 2012
@@ -343,7 +343,7 @@ public class ElasticSearchConnector exte
       throws ManifoldCFException, ServiceInterruption {
     long startTime = System.currentTimeMillis();
     ElasticSearchAction oo = new ElasticSearchAction(
-        CommandEnum.optimize, getConfigParameters(null));
+        CommandEnum._optimize, getConfigParameters(null));
     activities.recordActivity(startTime, ELASTICSEARCH_OPTIMIZE_ACTIVITY,
         null, oo.getCallUrlSnippet(), oo.getResult().name(),
         oo.getResultDescription());

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=1242175&r1=1242174&r2=1242175&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
Wed Feb  8 23:34:30 2012
@@ -21,8 +21,6 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.PrintWriter;
-import java.net.MalformedURLException;
-import java.net.URL;
 
 import org.apache.commons.httpclient.methods.PutMethod;
 import org.apache.commons.httpclient.methods.RequestEntity;
@@ -52,7 +50,7 @@ public class ElasticSearchIndex extends 
 		}
 
 		public String getContentType() {
-			return "text/xml; charset=utf-8";
+			return "application/x-www-form-urlencoded";
 		}
 
 		public boolean isRepeatable() {
@@ -62,18 +60,16 @@ public class ElasticSearchIndex extends 
 		public void writeRequest(OutputStream out) throws IOException {
 			PrintWriter pw = new PrintWriter(out);
 			try {
-				pw.println("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
-				pw.println("<index>);");
-				pw.print("<document><field name=\"uri\"><value>");
-				pw.print(documentURI);
-				pw.println("</value></field>");
-				pw.print("<binary fileName=\"");
-				pw.print(fileName);
-				pw.println("\">");
+				pw.println("{");
+				pw.print("\"fieldname\" : ");
+				pw.println("\"" + documentURI + "\"");
+				pw.print("\"fileName\" : ");
+				pw.println("\"" + fileName + "\"");
+				pw.print("\"binaryvalue\" : \"aqaq");
 				Base64 base64 = new Base64();
 				base64.encodeStream(inputStream, pw);
-				pw.println("</binary></document>");
-				pw.println("</index>");
+				pw.println("\"");
+				pw.println("}");
 			} catch (ManifoldCFException e) {
 				throw new IOException(e.getMessage());
 			} finally {
@@ -85,7 +81,7 @@ public class ElasticSearchIndex extends 
 	public ElasticSearchIndex(String documentURI, InputStream inputStream,
 			ElasticSearchConfig config) throws ManifoldCFException {
 		super(config);
-		StringBuffer url = getApiUrl(getPath(documentURI));
+		StringBuffer url = getApiUrl("update");
 		PutMethod put = new PutMethod(url.toString());
 		RequestEntity entity = new IndexRequestEntity(documentURI, inputStream);
 		put.setRequestEntity(entity);
@@ -97,19 +93,4 @@ public class ElasticSearchIndex extends 
 		System.err.println(getResponse());
 	}
 
-	private String getPath(String documentURI) {
-		String path = null;
-		try {
-			URL url = new URL(documentURI);
-			path = url.getPath();
-			if (path != null && path.length() > 0)
-				path = path.substring(1);
-		} catch (MalformedURLException e) {
-			// It is not a url so it surely a path
-			e.printStackTrace();
-			path = documentURI;
-		}
-		return path;
-	}
-
 }

Modified: incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchParam.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchParam.java?rev=1242175&r1=1242174&r2=1242175&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchParam.java
(original)
+++ incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchParam.java
Wed Feb  8 23:34:30 2012
@@ -30,7 +30,7 @@ public class ElasticSearchParam extends 
   public enum ParameterEnum {
     SERVERLOCATION("http://localhost:9200/"),
 
-    INDEXNAME(""),
+    INDEXNAME("index"),
 
     USERNAME(""),
 

Modified: incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/Messages.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/Messages.java?rev=1242175&r1=1242174&r2=1242175&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/Messages.java
(original)
+++ incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/Messages.java
Wed Feb  8 23:34:30 2012
@@ -119,13 +119,5 @@ public class Messages extends org.apache
       substitutionParameters,mapToUpperCase);
   }
   
-  public static void outputResourceWithVelocity(IHTTPOutput output, Locale locale, String
resourceKey,
-      Map<String,String> substitutionParameters, boolean mapToUpperCase)
-      throws ManifoldCFException
-    {
-      outputResourceWithVelocity(output,createVelocityEngine(Messages.class),DEFAULT_PATH_NAME,locale,resourceKey,
-        substitutionParameters,mapToUpperCase);
-    }
-  
 }
 

Modified: incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/resources/org/apache/manifoldcf/agents/output/elasticsearch/editConfiguration_en_US.html
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/resources/org/apache/manifoldcf/agents/output/elasticsearch/editConfiguration_en_US.html?rev=1242175&r1=1242174&r2=1242175&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/resources/org/apache/manifoldcf/agents/output/elasticsearch/editConfiguration_en_US.html
(original)
+++ incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/resources/org/apache/manifoldcf/agents/output/elasticsearch/editConfiguration_en_US.html
Wed Feb  8 23:34:30 2012
@@ -17,49 +17,24 @@
 
 <table class="displaytable">
 	<tr>
-    <td class="description">
-      <nobr>
-        Protocol:
-      </nobr>
-    </td>
-    <td class="value">
-      <select id="protocol" name="protocol">
-      #if($PROTOCOL_BJ == "https")
-        <option value="http">http</option>
-        <option value="https" selected="selected">https</option>
-      #else
-        <option value="http" selected="selected">http</option>
-        <option value="https">https</option>
-      #end
-      </select>
-    </td>
-  </tr>
-  <tr>
-    <td class="description">
-      <nobr>
-        Server:
-      </nobr>
-    </td>
-    <td class="value">
-        <input id="server" name="server" type="text" size="32" value="$SERVER_A"/>
-    </td>
-  </tr>
-  <tr>
-    <td class="description">
-      <nobr>
-        Port:
-      </nobr>
-    </td>
-    <td class="value">
-        <input id="port" name="port" type="text" size="5" value="$PORT_A" />
-    </td>
-  </tr>
-	<tr>
-		<td class="description">
-		  <nobr>Cluster name:</nobr>
-		</td>
-		<td class="value">
-		  <input name="clusterName" value="$CLUSTERNAME:A" size="24" />
+		<td class="description"><nobr>Server Location</nobr> (URL):</td>
+		<td class="value"><input name="serverlocation"
+			value="${SERVERLOCATION:A}" size="48" />
 		</td>
 	</tr>
+	<tr>
+		<td class="description"><nobr>Index name:</nobr></td>
+		<td class="value"><input name="indexname" value="${INDEXNAME:A}"
+			size="24" /></td>
+	</tr>
+	<tr>
+		<td class="description"><nobr>User name:</nobr></td>
+		<td class="value"><input name="username" value="${USERNAME:A}"
+			size="24" /></td>
+	</tr>
+	<tr>
+		<td class="description"><nobr>API Key:</nobr></td>
+		<td class="value"><input name="apikey" value="${APIKEY:A}"
+			size="40" /></td>
+	</tr>
 </table>
\ No newline at end of file

Modified: incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/resources/org/apache/manifoldcf/agents/output/elasticsearch/editConfiguration_en_US.js
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/resources/org/apache/manifoldcf/agents/output/elasticsearch/editConfiguration_en_US.js?rev=1242175&r1=1242174&r2=1242175&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/resources/org/apache/manifoldcf/agents/output/elasticsearch/editConfiguration_en_US.js
(original)
+++ incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/resources/org/apache/manifoldcf/agents/output/elasticsearch/editConfiguration_en_US.js
Wed Feb  8 23:34:30 2012
@@ -18,36 +18,21 @@
 <script type="text/javascript">
 <!--
 function checkConfig() {
-	if (editconnection.server.value =="") {
-    alert("Server name must be not null");
-    SelectTab("Server");
-	  editconnection.server.focus();
-	  return false;
-  } else if(!editconnection.server.value.indexOf('/')==-1) {
-  	alert("Server name can't contain the character '/'");
-  	SelectTab("Server");
-	  editconnection.server.focus();
-	  return false;
-  }
-  if (editconnection.port.value == "")
-  {
-  	alert("The port must be not null");
-  	SelectTab("Server");
-  	editconnection.port.focus();
-  	return false;
-  } else if (!isInteger(editconnection.port.value)){
-  	alert("The server port must be a valid integer");
-  	SelectTab("Server");
-  	editconnection.port.focus();
-  	return false;
-  }
-  if(editconnection.path.value == ""){
-  		alert("Path must be not null");
-  		SelectTab("Server");
-		  editconnection.path.focus();
-		  return false;
-	  }
-  return true;
+	if (editconnection.serverlocation) {
+		if (editconnection.serverlocation.value == "") {
+			alert("Please supply a valid ElasticSearch server location");
+			editconnection.serverlocation.focus();
+			return false;
+		}
+	}
+	if (editconnection.indexname) {
+		if (editconnection.indexname.value == "") {
+			alert("Please supply a valid index name");
+			editconnection.indexname.focus();
+			return false;
+		}
+	}
+	return true;
 }
 
 function checkConfigForSave() {

Modified: incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/resources/org/apache/manifoldcf/agents/output/elasticsearch/viewConfiguration_en_US.html
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/resources/org/apache/manifoldcf/agents/output/elasticsearch/viewConfiguration_en_US.html?rev=1242175&r1=1242174&r2=1242175&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/resources/org/apache/manifoldcf/agents/output/elasticsearch/viewConfiguration_en_US.html
(original)
+++ incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/resources/org/apache/manifoldcf/agents/output/elasticsearch/viewConfiguration_en_US.html
Wed Feb  8 23:34:30 2012
@@ -21,10 +21,6 @@
 		<td class="value">${SERVERLOCATION:B}</td>
 	</tr>
 	<tr>
-		<td class="description"><nobr>Index name:</nobr></td>
-		<td class="value">${INDEXNAME:B}</td>
-	</tr>
-	<tr>
 		<td class="description"><nobr>User name:</nobr></td>
 		<td class="value">${USERNAME:B}</td>
 	</tr>

Modified: incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/resources/org/apache/manifoldcf/agents/output/elasticsearch/viewConfiguration_ja_JP.html
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/resources/org/apache/manifoldcf/agents/output/elasticsearch/viewConfiguration_ja_JP.html?rev=1242175&r1=1242174&r2=1242175&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/resources/org/apache/manifoldcf/agents/output/elasticsearch/viewConfiguration_ja_JP.html
(original)
+++ incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/resources/org/apache/manifoldcf/agents/output/elasticsearch/viewConfiguration_ja_JP.html
Wed Feb  8 23:34:30 2012
@@ -21,10 +21,6 @@
 		<td class="value">${SERVERLOCATION:B}</td>
 	</tr>
 	<tr>
-		<td class="description"><nobr>索引名:</nobr></td>
-		<td class="value">${INDEXNAME:B}</td>
-	</tr>
-	<tr>
 		<td class="description"><nobr>ユーザ名:</nobr></td>
 		<td class="value">${USERNAME:B}</td>
 	</tr>

Modified: incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/pom.xml
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/pom.xml?rev=1242175&r1=1242174&r2=1242175&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/pom.xml (original)
+++ incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/pom.xml Wed Feb  8 23:34:30
2012
@@ -34,13 +34,6 @@
     </developer>
   </developers>
   
-  <repositories>
-    <repository>
-      <id>sonatype</id>
-      <url>https://oss.sonatype.org/content/repositories/releases</url>
-    </repository>
-  </repositories>
-  
   <artifactId>mcf-elasticsearch-connector</artifactId>
   <name>ManifoldCF - Connectors - ElasticSearch</name>
 
@@ -79,11 +72,6 @@
 
   <dependencies>
     <dependency>
-      <groupId>org.elasticsearch</groupId>
-      <artifactId>elasticsearch</artifactId>
-      <version>0.18.7</version>
-    </dependency>
-    <dependency>
       <groupId>${project.groupId}</groupId>
       <artifactId>mcf-core</artifactId>
       <version>${project.version}</version>



Mime
View raw message