incubator-connectors-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1242609 - in /incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main: java/org/apache/manifoldcf/agents/output/elasticsearch/ resources/org/apache/manifoldcf/agents/output/elasticsearch/
Date Thu, 09 Feb 2012 23:49:58 GMT
Author: kwright
Date: Thu Feb  9 23:49:58 2012
New Revision: 1242609

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

Modified:
    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/ElasticSearchConfig.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/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/ElasticSearchParam.java
    incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchSchema.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/editConfiguration_ja_JP.html
    incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/resources/org/apache/manifoldcf/agents/output/elasticsearch/editConfiguration_ja_JP.js
    incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/resources/org/apache/manifoldcf/agents/output/elasticsearch/hiddenConfiguration_en_US.html
    incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/resources/org/apache/manifoldcf/agents/output/elasticsearch/hiddenConfiguration_ja_JP.html

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=1242609&r1=1242608&r2=1242609&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
Thu Feb  9 23:49:58 2012
@@ -29,12 +29,11 @@ public class ElasticSearchAction extends
   public ElasticSearchAction(CommandEnum cmd, ElasticSearchConfig config)
       throws ManifoldCFException {
     super(config);
-    StringBuffer url = getApiUrl("action");
-    url.append("/"+cmd.name());
+    StringBuffer url = getApiUrl(cmd.toString());
     GetMethod method = new GetMethod(url.toString());
     call(method);
-    if ("OK".equals(checkXPath(xPathStatus)))
+    if ("true".equals(checkJson(jsonStatus)))
       return;
-    setResult(Result.ERROR, checkXPath(xPathException));
+    setResult(Result.ERROR, checkJson(jsonException));
   }
 }

Modified: incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchConfig.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchConfig.java?rev=1242609&r1=1242608&r2=1242609&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchConfig.java
(original)
+++ incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/java/org/apache/manifoldcf/agents/output/elasticsearch/ElasticSearchConfig.java
Thu Feb  9 23:49:58 2012
@@ -1,19 +1,19 @@
 /**
-* 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;
 
@@ -22,71 +22,76 @@ import org.apache.manifoldcf.core.interf
 
 public class ElasticSearchConfig extends ElasticSearchParam {
 
-  /**
+	/**
 	 * 
 	 */
-  private static final long serialVersionUID = -2071296573398352538L;
+	private static final long serialVersionUID = -2071296573398352538L;
 
-  /**
-   * Parameters used for the configuration
-   */
-  final private static ParameterEnum[] CONFIGURATIONLIST = {
-      ParameterEnum.SERVERLOCATION, ParameterEnum.INDEXNAME,
-      ParameterEnum.USERNAME, ParameterEnum.APIKEY };
-
-  /**
-   * Build a set of ElasticSearchParameters by reading ConfigParams. If the
-   * value returned by ConfigParams.getParameter is null, the default value is
-   * set.
-   * 
-   * @param paramList
-   * @param params
-   */
-  public ElasticSearchConfig(ConfigParams params) {
-    super(CONFIGURATIONLIST);
-    for (ParameterEnum param : CONFIGURATIONLIST) {
-      String value = params.getParameter(param.name());
-      if (value == null)
-        value = param.defaultValue;
-      put(param, value);
-    }
-  }
-
-  /**
-   * 
-   * @return a unique identifier for one index on one ElasticSearch instance.
-   */
-  public String getUniqueIndexIdentifier() {
-    StringBuffer sb = new StringBuffer();
-    sb.append(getServerLocation());
-    if (sb.charAt(sb.length() - 1) != '/')
-      sb.append('/');
-    sb.append(getIndexName());
-    return sb.toString();
-  }
-
-  public final static void contextToConfig(IPostParameters variableContext,
-      ConfigParams parameters) {
-    for (ParameterEnum param : CONFIGURATIONLIST) {
-      String p = variableContext.getParameter(param.name().toLowerCase());
-      if (p != null)
-        parameters.setParameter(param.name(), p);
-    }
-  }
-
-  final public String getServerLocation() {
-    return get(ParameterEnum.SERVERLOCATION);
-  }
-
-  final public String getIndexName() {
-    return get(ParameterEnum.INDEXNAME);
-  }
-
-  final public String getUserName() {
-    return get(ParameterEnum.USERNAME);
-  }
-
-  final public String getApiKey() {
-    return get(ParameterEnum.APIKEY);
-  }
+	/**
+	 * Parameters used for the configuration
+	 */
+	final private static ParameterEnum[] CONFIGURATIONLIST = {
+			ParameterEnum.SERVERLOCATION, ParameterEnum.INDEXNAME,
+			ParameterEnum.INDEXTYPE, ParameterEnum.USERNAME,
+			ParameterEnum.APIKEY };
+
+	/**
+	 * Build a set of ElasticSearchParameters by reading ConfigParams. If the
+	 * value returned by ConfigParams.getParameter is null, the default value is
+	 * set.
+	 * 
+	 * @param paramList
+	 * @param params
+	 */
+	public ElasticSearchConfig(ConfigParams params) {
+		super(CONFIGURATIONLIST);
+		for (ParameterEnum param : CONFIGURATIONLIST) {
+			String value = params.getParameter(param.name());
+			if (value == null)
+				value = param.defaultValue;
+			put(param, value);
+		}
+	}
+
+	/**
+	 * 
+	 * @return a unique identifier for one index on one ElasticSearch instance.
+	 */
+	public String getUniqueIndexIdentifier() {
+		StringBuffer sb = new StringBuffer();
+		sb.append(getServerLocation());
+		if (sb.charAt(sb.length() - 1) != '/')
+			sb.append('/');
+		sb.append(getIndexName());
+		return sb.toString();
+	}
+
+	public final static void contextToConfig(IPostParameters variableContext,
+			ConfigParams parameters) {
+		for (ParameterEnum param : CONFIGURATIONLIST) {
+			String p = variableContext.getParameter(param.name().toLowerCase());
+			if (p != null)
+				parameters.setParameter(param.name(), p);
+		}
+	}
+
+	final public String getServerLocation() {
+		return get(ParameterEnum.SERVERLOCATION);
+	}
+
+	final public String getIndexName() {
+		return get(ParameterEnum.INDEXNAME);
+	}
+
+	final public String getIndexType() {
+		return get(ParameterEnum.INDEXTYPE);
+	}
+
+	final public String getUserName() {
+		return get(ParameterEnum.USERNAME);
+	}
+
+	final public String getApiKey() {
+		return get(ParameterEnum.APIKEY);
+	}
 }

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=1242609&r1=1242608&r2=1242609&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
Thu Feb  9 23:49:58 2012
@@ -1,199 +1,162 @@
 /**
-* 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 java.io.IOException;
-import java.io.StringReader;
 import java.io.UnsupportedEncodingException;
 import java.net.URLEncoder;
 
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.xpath.XPath;
-import javax.xml.xpath.XPathExpression;
-import javax.xml.xpath.XPathExpressionException;
-import javax.xml.xpath.XPathFactory;
-
 import org.apache.commons.httpclient.HttpClient;
 import org.apache.commons.httpclient.HttpException;
 import org.apache.commons.httpclient.HttpMethod;
 import org.apache.commons.io.IOUtils;
 import org.apache.manifoldcf.core.interfaces.ManifoldCFException;
-import org.w3c.dom.Document;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
 
 public class ElasticSearchConnection {
 
-  private String serverLocation;
+	private String serverLocation;
 
-  private String indexName;
+	private String indexName;
 
-  private String userName;
+	private String userName;
 
-  private String apiKey;
+	private String apiKey;
 
-  private String resultDescription;
-
-  private String callUrlSnippet;
-
-  private String response;
-
-  private Document xmlResponse;
-
-  protected String xPathStatus = "/response/entry[@key='Status']/text()";
-  protected String xPathException = "/response/entry[@key='Exception']/text()";
-
-  public enum Result {
-    OK, ERROR, UNKNOWN;
-  }
-
-  private Result result;
-
-  protected ElasticSearchConnection(ElasticSearchConfig config) {
-    result = Result.UNKNOWN;
-    response = null;
-    xmlResponse = null;
-    resultDescription = "";
-    callUrlSnippet = null;
-    serverLocation = config.getServerLocation();
-    indexName = config.getIndexName();
-    userName = config.getUserName();
-    apiKey = config.getApiKey();
-  }
-
-  protected final String urlEncode(String t) throws ManifoldCFException {
-    try {
-      return URLEncoder.encode(t, "UTF-8");
-    } catch (UnsupportedEncodingException e) {
-      throw new ManifoldCFException(e);
-    }
-  }
-
-  protected StringBuffer getApiUrl(String command) throws ManifoldCFException {
-    StringBuffer url = new StringBuffer(serverLocation);
-    if (!serverLocation.endsWith("/"))
-      url.append('/');
-    url.append(urlEncode(indexName));
-    callUrlSnippet = url.toString();
-    if (userName != null && apiKey != null && userName.length() > 0
-        && apiKey.length() > 0) {
-      url.append("&login=");
-      url.append(urlEncode(userName));
-      url.append("&key=");
-      url.append(apiKey);
-    }
-    return url;
-  }
-
-  protected void call(HttpMethod method) throws ManifoldCFException {
-    HttpClient hc = new HttpClient();
-    try {
-      hc.executeMethod(method);
-      if (!checkResultCode(method.getStatusCode()))
-        throw new ManifoldCFException(getResultDescription());
-      response = IOUtils.toString(method.getResponseBodyAsStream());
-    } catch (HttpException e) {
-      setResult(Result.ERROR, e.getMessage());
-      throw new ManifoldCFException(e);
-    } catch (IOException e) {
-      setResult(Result.ERROR, e.getMessage());
-      throw new ManifoldCFException(e);
-    } finally {
-      if (method != null)
-        method.releaseConnection();
-    }
-  }
-
-  private void readXmlResponse() throws ManifoldCFException {
-    if (xmlResponse != null)
-      return;
-    StringReader sw = null;
-    try {
-      sw = new StringReader(response);
-      DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
-      dbf.setNamespaceAware(true); // never forget this!
-      DocumentBuilder builder;
-      builder = dbf.newDocumentBuilder();
-      xmlResponse = builder.parse(new InputSource(sw));
-    } catch (ParserConfigurationException e) {
-      throw new ManifoldCFException(e);
-    } catch (SAXException e) {
-      throw new ManifoldCFException(e);
-    } catch (IOException e) {
-      throw new ManifoldCFException(e);
-    } finally {
-      if (sw != null)
-        IOUtils.closeQuietly(sw);
-    }
-  }
-
-  protected String checkXPath(String xPathQuery) throws ManifoldCFException {
-    try {
-      readXmlResponse();
-      XPathFactory factory = XPathFactory.newInstance();
-      XPath xpath = factory.newXPath();
-      XPathExpression xPathExpr = xpath.compile(xPathQuery);
-      return xPathExpr.evaluate(xmlResponse);
-    } catch (XPathExpressionException e) {
-      throw new ManifoldCFException(e);
-    }
-  }
-
-  protected void setResult(Result res, String desc) {
-    if (res != null)
-      result = res;
-    if (desc != null)
-      if (desc.length() > 0)
-        resultDescription = desc;
-  }
-
-  public String getResultDescription() {
-    return resultDescription;
-  }
-
-  protected String getResponse() {
-    return response;
-  }
-
-  private boolean checkResultCode(int code) {
-    switch (code) {
-    case 0:
-      setResult(Result.UNKNOWN, null);
-      return false;
-    case 200:
-      setResult(Result.OK, null);
-      return true;
-    case 404:
-      setResult(Result.ERROR, "Server/page not found");
-      return false;
-    default:
-      setResult(Result.ERROR, null);
-      return false;
-    }
-  }
-
-  public Result getResult() {
-    return result;
-  }
-
-  public String getCallUrlSnippet() {
-    return callUrlSnippet;
-  }
+	private String resultDescription;
+
+	private String callUrlSnippet;
+
+	private String response;
+
+	protected String jsonStatus = "\"ok\"";
+	protected String jsonException = "\"error\"";
+
+	public enum Result {
+		OK, ERROR, UNKNOWN;
+	}
+
+	private Result result;
+
+	protected ElasticSearchConnection(ElasticSearchConfig config) {
+		result = Result.UNKNOWN;
+		response = null;
+		resultDescription = "";
+		callUrlSnippet = null;
+		serverLocation = config.getServerLocation();
+		indexName = config.getIndexName();
+		userName = config.getUserName();
+		apiKey = config.getApiKey();
+	}
+
+	protected final String urlEncode(String t) throws ManifoldCFException {
+		try {
+			return URLEncoder.encode(t, "UTF-8");
+		} catch (UnsupportedEncodingException e) {
+			throw new ManifoldCFException(e);
+		}
+	}
+
+	protected StringBuffer getApiUrl(String command) throws ManifoldCFException {
+		StringBuffer url = new StringBuffer(serverLocation);
+		if (!serverLocation.endsWith("/"))
+			url.append('/');
+		url.append(urlEncode(indexName));
+		url.append("/" + command);
+		callUrlSnippet = url.toString();
+		if (userName != null && apiKey != null && userName.length() > 0
+				&& apiKey.length() > 0) {
+			url.append("&login=");
+			url.append(urlEncode(userName));
+			url.append("&key=");
+			url.append(apiKey);
+		}
+		return url;
+	}
+
+	protected void call(HttpMethod method) throws ManifoldCFException {
+		HttpClient hc = new HttpClient();
+		try {
+			hc.executeMethod(method);
+			if (!checkResultCode(method.getStatusCode()))
+				throw new ManifoldCFException(getResultDescription());
+			response = IOUtils.toString(method.getResponseBodyAsStream());
+		} catch (HttpException e) {
+			setResult(Result.ERROR, e.getMessage());
+			throw new ManifoldCFException(e);
+		} catch (IOException e) {
+			setResult(Result.ERROR, e.getMessage());
+			throw new ManifoldCFException(e);
+		} finally {
+			if (method != null)
+				method.releaseConnection();
+		}
+	}
+
+	protected String checkJson(String jsonQuery) throws ManifoldCFException {
+		String result = null;
+		if (response != null) {
+			String[] tokens = response.replaceAll("\\{", "")
+					.replaceAll("\\}", "").split(",");
+			for (String token : tokens)
+				if (token.contains(jsonQuery))
+					result = token.substring(token.indexOf(":") + 1);
+		}
+		return result;
+	}
+
+	protected void setResult(Result res, String desc) {
+		if (res != null)
+			result = res;
+		if (desc != null)
+			if (desc.length() > 0)
+				resultDescription = desc;
+	}
+
+	public String getResultDescription() {
+		return resultDescription;
+	}
+
+	protected String getResponse() {
+		return response;
+	}
+
+	private boolean checkResultCode(int code) {
+		switch (code) {
+		case 0:
+			setResult(Result.UNKNOWN, null);
+			return false;
+		case 200:
+			setResult(Result.OK, null);
+			return true;
+		case 404:
+			setResult(Result.ERROR, "Server/page not found");
+			return false;
+		default:
+			setResult(Result.ERROR, null);
+			return false;
+		}
+	}
+
+	public Result getResult() {
+		return result;
+	}
+
+	public String getCallUrlSnippet() {
+		return callUrlSnippet;
+	}
 }

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=1242609&r1=1242608&r2=1242609&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
Thu Feb  9 23:49:58 2012
@@ -25,13 +25,13 @@ public class ElasticSearchDelete extends
   public ElasticSearchDelete(String documentURI,
       ElasticSearchConfig config) throws ManifoldCFException {
     super(config);
-    StringBuffer url = getApiUrl("delete");
+    StringBuffer url = getApiUrl("_delete");
     url.append("&uniq=");
     url.append(urlEncode(documentURI));
     GetMethod method = new GetMethod(url.toString());
     call(method);
-    if ("OK".equals(checkXPath(xPathStatus)))
+    if ("true".equals(checkJson(jsonStatus)))
       return;
-    setResult(Result.ERROR, checkXPath(xPathException));
+    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=1242609&r1=1242608&r2=1242609&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
Thu Feb  9 23:49:58 2012
@@ -81,14 +81,14 @@ public class ElasticSearchIndex extends 
 	public ElasticSearchIndex(String documentURI, InputStream inputStream,
 			ElasticSearchConfig config) throws ManifoldCFException {
 		super(config);
-		StringBuffer url = getApiUrl("update");
+		StringBuffer url = getApiUrl(config.getIndexType() + "/_update");
 		PutMethod put = new PutMethod(url.toString());
 		RequestEntity entity = new IndexRequestEntity(documentURI, inputStream);
 		put.setRequestEntity(entity);
 		call(put);
-		if ("OK".equals(checkXPath(xPathStatus)))
+		if ("true".equals(checkJson(jsonStatus)))
 			return;
-		String error = checkXPath(xPathException);
+		String error = checkJson(jsonException);
 		setResult(Result.ERROR, error);
 		System.err.println(getResponse());
 	}

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=1242609&r1=1242608&r2=1242609&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
Thu Feb  9 23:49:58 2012
@@ -32,6 +32,8 @@ public class ElasticSearchParam extends 
 
     INDEXNAME("index"),
 
+    INDEXTYPE("generictype"),
+
     USERNAME(""),
 
     APIKEY(""),

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=1242609&r1=1242608&r2=1242609&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
Thu Feb  9 23:49:58 2012
@@ -29,9 +29,9 @@ public class ElasticSearchSchema extends
     StringBuffer url = getApiUrl("schema");
     url.append("&cmd=indexList");
     GetMethod method = new GetMethod(url.toString());
-    String xpath = "count(/response/index[@name='" + indexName + "'])";
+    String json = "count(/response/index[@name='" + indexName + "'])";
     call(method);
-    if ("1".equals(checkXPath(xpath)))
+    if ("1".equals(checkJson(json)))
       return;
     setResult(Result.ERROR, "Index not found");
   }

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=1242609&r1=1242608&r2=1242609&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
Thu Feb  9 23:49:58 2012
@@ -28,6 +28,11 @@
 			size="24" /></td>
 	</tr>
 	<tr>
+		<td class="description"><nobr>Index type:</nobr></td>
+		<td class="value"><input name="indextype" value="${INDEXTYPE: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>

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=1242609&r1=1242608&r2=1242609&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
Thu Feb  9 23:49:58 2012
@@ -32,6 +32,13 @@ function checkConfig() {
 			return false;
 		}
 	}
+	if (editconnection.indextype) {
+		if (editconnection.indextype.value == "") {
+			alert("Please supply a valid index type");
+			editconnection.indextype.focus();
+			return false;
+		}
+	}
 	return true;
 }
 

Modified: incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/resources/org/apache/manifoldcf/agents/output/elasticsearch/editConfiguration_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/editConfiguration_ja_JP.html?rev=1242609&r1=1242608&r2=1242609&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/resources/org/apache/manifoldcf/agents/output/elasticsearch/editConfiguration_ja_JP.html
(original)
+++ incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/resources/org/apache/manifoldcf/agents/output/elasticsearch/editConfiguration_ja_JP.html
Thu Feb  9 23:49:58 2012
@@ -28,6 +28,11 @@
 			size="24" /></td>
 	</tr>
 	<tr>
+		<td class="description"><nobr>索引名:</nobr></td>
+		<td class="value"><input name="indextype" value="${INDEXTYPE:A}"
+			size="24" /></td>
+	</tr>
+	<tr>
 		<td class="description"><nobr>ユーザ名:</nobr></td>
 		<td class="value"><input name="username" value="${USERNAME:A}"
 			size="24" /></td>

Modified: incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/resources/org/apache/manifoldcf/agents/output/elasticsearch/editConfiguration_ja_JP.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_ja_JP.js?rev=1242609&r1=1242608&r2=1242609&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/resources/org/apache/manifoldcf/agents/output/elasticsearch/editConfiguration_ja_JP.js
(original)
+++ incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/resources/org/apache/manifoldcf/agents/output/elasticsearch/editConfiguration_ja_JP.js
Thu Feb  9 23:49:58 2012
@@ -32,6 +32,13 @@ function checkConfig() {
 			return false;
 		}
 	}
+	if (editconnection.indextype) {
+		if (editconnection.indextype.value == "") {
+			alert("正しい索引名を入力してください");
+			editconnection.indextype.focus();
+			return false;
+		}
+	}
 	return true;
 }
 

Modified: incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/resources/org/apache/manifoldcf/agents/output/elasticsearch/hiddenConfiguration_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/hiddenConfiguration_en_US.html?rev=1242609&r1=1242608&r2=1242609&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/resources/org/apache/manifoldcf/agents/output/elasticsearch/hiddenConfiguration_en_US.html
(original)
+++ incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/resources/org/apache/manifoldcf/agents/output/elasticsearch/hiddenConfiguration_en_US.html
Thu Feb  9 23:49:58 2012
@@ -16,5 +16,6 @@
 -->
 <input type="hidden" name="serverlocation" value="${SERVERLOCATION:A}" />
 <input type="hidden" name="indexname" value="${INDEXNAME:A}" />
+<input type="hidden" name="indextype" value="${INDEXTYPE:A}" />
 <input type="hidden" name="username" value="${USERNAME:A}" />
 <input type="hidden" name="apikey" value="${APIKEY:A}" />
\ No newline at end of file

Modified: incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/resources/org/apache/manifoldcf/agents/output/elasticsearch/hiddenConfiguration_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/hiddenConfiguration_ja_JP.html?rev=1242609&r1=1242608&r2=1242609&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/resources/org/apache/manifoldcf/agents/output/elasticsearch/hiddenConfiguration_ja_JP.html
(original)
+++ incubator/lcf/branches/CONNECTORS-288/connectors/elasticsearch/connector/src/main/resources/org/apache/manifoldcf/agents/output/elasticsearch/hiddenConfiguration_ja_JP.html
Thu Feb  9 23:49:58 2012
@@ -16,5 +16,6 @@
 -->
 <input type="hidden" name="serverlocation" value="${SERVERLOCATION:A}" />
 <input type="hidden" name="indexname" value="${INDEXNAME:A}" />
+<input type="hidden" name="indextype" value="${INDEXTYPE:A}" />
 <input type="hidden" name="username" value="${USERNAME:A}" />
 <input type="hidden" name="apikey" value="${APIKEY:A}" />
\ No newline at end of file



Mime
View raw message