Return-Path: X-Original-To: apmail-incubator-connectors-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-connectors-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5242A90D3 for ; Sat, 11 Feb 2012 19:09:28 +0000 (UTC) Received: (qmail 44951 invoked by uid 500); 11 Feb 2012 19:09:28 -0000 Delivered-To: apmail-incubator-connectors-commits-archive@incubator.apache.org Received: (qmail 44889 invoked by uid 500); 11 Feb 2012 19:09:27 -0000 Mailing-List: contact connectors-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: connectors-dev@incubator.apache.org Delivered-To: mailing list connectors-commits@incubator.apache.org Received: (qmail 44882 invoked by uid 99); 11 Feb 2012 19:09:27 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 11 Feb 2012 19:09:27 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 11 Feb 2012 19:09:26 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 67CB0238897D; Sat, 11 Feb 2012 19:09:06 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: connectors-commits@incubator.apache.org From: kwright@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120211190906.67CB0238897D@eris.apache.org> 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"); - } -}