You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@manifoldcf.apache.org by kw...@apache.org on 2013/03/07 10:35:24 UTC

svn commit: r1453742 - in /manifoldcf/integration/elasticsearch/trunk: pom.xml src/main/java/org/apache/manifoldcf/elasticsearch/QueryModifier.java

Author: kwright
Date: Thu Mar  7 09:35:23 2013
New Revision: 1453742

URL: http://svn.apache.org/r1453742
Log:
Add a pom, get everything so far to build.

Added:
    manifoldcf/integration/elasticsearch/trunk/pom.xml   (with props)
Modified:
    manifoldcf/integration/elasticsearch/trunk/src/main/java/org/apache/manifoldcf/elasticsearch/QueryModifier.java

Added: manifoldcf/integration/elasticsearch/trunk/pom.xml
URL: http://svn.apache.org/viewvc/manifoldcf/integration/elasticsearch/trunk/pom.xml?rev=1453742&view=auto
==============================================================================
--- manifoldcf/integration/elasticsearch/trunk/pom.xml (added)
+++ manifoldcf/integration/elasticsearch/trunk/pom.xml Thu Mar  7 09:35:23 2013
@@ -0,0 +1,157 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+  <parent>
+    <groupId>org.apache</groupId>
+    <artifactId>apache</artifactId>
+    <version>9</version>
+    <relativePath />
+  </parent>
+
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.manifoldcf.elasticsearch</groupId>
+
+  <name>ManifoldCF ElasticSearch Plugin</name>
+  <artifactId>elasticsearch-plugin-mcf</artifactId>
+  <version>0.1-SNAPSHOT</version>
+  <packaging>jar</packaging>
+  <description>ManifoldCF Plugin for ElasticSearch</description>
+  <inceptionYear>2013</inceptionYear>
+
+  <!-- Move these to the parent pom, when I create a parent pom -->
+  <properties>
+    <elasticsearch.version>0.20.5</elasticsearch.version>
+    <lucene.version>3.6.2</lucene.version>
+    <junit.version>4.8.2</junit.version>
+    <slf4j.version>1.6.6</slf4j.version>
+    <log4j.version>1.2.16</log4j.version>
+    <httpcomponent.version>4.2.3</httpcomponent.version>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.elasticsearch</groupId>
+      <artifactId>elasticsearch</artifactId>
+      <version>${elasticsearch.version}</version>
+      <scope>compile</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.lucene</groupId>
+      <artifactId>lucene-core</artifactId>
+      <version>${lucene.version}</version>
+      <scope>compile</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.httpcomponents</groupId>
+      <artifactId>httpclient</artifactId>
+      <version>${httpcomponent.version}</version>
+      <scope>compile</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>log4j</groupId>
+      <artifactId>log4j</artifactId>
+      <version>${log4j.version}</version>
+      <scope>compile</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-api</artifactId>
+      <version>${slf4j.version}</version>
+      <scope>compile</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit-dep</artifactId>
+      <version>${junit.version}</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+  
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <argLine>-Xmx1024m</argLine>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>2.3.2</version>
+        <configuration>
+          <source>1.6</source>
+          <target>1.6</target>
+        </configuration>
+      </plugin>
+      <!-- plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-source-plugin</artifactId>
+        <version>2.1.2</version>
+        <executions>
+          <execution>
+            <id>attach-sources</id>
+            <goals>
+              <goal>jar</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin -->
+      <!--plugin>
+        <artifactId>maven-assembly-plugin</artifactId>
+        <version>2.3</version>
+        <configuration>
+          <appendAssemblyId>false</appendAssemblyId>
+          <outputDirectory>${project.build.directory}/releases/</outputDirectory>
+          <descriptors>
+            <descriptor>${basedir}/src/main/assemblies/plugin.xml</descriptor>
+          </descriptors>
+        </configuration>
+        <executions>
+          <execution>
+            <phase>package</phase>
+            <goals>
+              <goal>single</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin -->
+      <plugin>
+        <artifactId>maven-resources-plugin</artifactId>
+        <version>2.5</version>
+        <configuration>
+          <encoding>UTF-8</encoding>
+        </configuration>
+      </plugin>
+      <plugin>
+        <artifactId>maven-clean-plugin</artifactId>
+        <version>2.4.1</version>
+      </plugin>
+
+    </plugins>
+  </build>
+
+</project>
\ No newline at end of file

Propchange: manifoldcf/integration/elasticsearch/trunk/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: manifoldcf/integration/elasticsearch/trunk/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: manifoldcf/integration/elasticsearch/trunk/src/main/java/org/apache/manifoldcf/elasticsearch/QueryModifier.java
URL: http://svn.apache.org/viewvc/manifoldcf/integration/elasticsearch/trunk/src/main/java/org/apache/manifoldcf/elasticsearch/QueryModifier.java?rev=1453742&r1=1453741&r2=1453742&view=diff
==============================================================================
--- manifoldcf/integration/elasticsearch/trunk/src/main/java/org/apache/manifoldcf/elasticsearch/QueryModifier.java (original)
+++ manifoldcf/integration/elasticsearch/trunk/src/main/java/org/apache/manifoldcf/elasticsearch/QueryModifier.java Thu Mar  7 09:35:23 2013
@@ -18,10 +18,12 @@
 */
 package org.apache.manifoldcf.elasticsearch;
 
+import java.io.*;
 import java.util.*;
 import java.net.*;
 
 import org.apache.lucene.search.*;
+import org.apache.lucene.index.*;
 
 import org.apache.http.client.HttpClient;
 import org.apache.http.HttpStatus;
@@ -37,7 +39,9 @@ import org.apache.http.impl.client.Defau
 import org.apache.http.impl.client.DefaultRedirectStrategy;
 import org.apache.http.conn.ClientConnectionManager;
 import org.apache.http.impl.conn.PoolingClientConnectionManager;
-import org.slf4j.*;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /** This class represents the main Java API for modifying Lucene queries
 * within ElasticSearch.  It is a singleton class whose main public method
@@ -69,7 +73,7 @@ public class QueryModifier
   /** Constructor, which includes configuration information */
   public QueryModifier(ConfigurationParameters cp)
   {
-    authorityBaseURL = cp.authorityBaseURL;
+    authorityBaseURL = cp.authorityServiceBaseURL;
     fieldAllowDocument = cp.allowFieldPrefix+"document";
     fieldDenyDocument = cp.denyFieldPrefix+"document";
     fieldAllowShare = cp.allowFieldPrefix+"share";
@@ -81,7 +85,7 @@ public class QueryModifier
     // Set up client pool etc, if there's indication that we should do that
     if (authorityBaseURL != null)
     {
-      PoolingClientConnectionManager localConnectionManager = new PoolingClientConnManager();
+      PoolingClientConnectionManager localConnectionManager = new PoolingClientConnectionManager();
       localConnectionManager.setMaxTotal(poolSize);
       localConnectionManager.setDefaultMaxPerRoute(poolSize);
       connectionManager = localConnectionManager;
@@ -90,11 +94,16 @@ public class QueryModifier
       params.setBooleanParameter(CoreConnectionPNames.TCP_NODELAY,true);
       params.setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK,false);
       params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT,socketTimeout);
-      params.setIntParameter(CoreConnectionPNames.CONNECT_TIMEOUT,connectionTimeout);
+      params.setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT,connectionTimeout);
       DefaultHttpClient localClient = new DefaultHttpClient(connectionManager,params);
       localClient.setRedirectStrategy(new DefaultRedirectStrategy());
       httpClient = localClient;
     }
+    else
+    {
+      connectionManager = null;
+      httpClient = null;
+    }
   }
   
   /** Shut down the pool etc.
@@ -191,7 +200,7 @@ public class QueryModifier
 
   /** Get access tokens given a username */
   protected List<String> getAccessTokens(String authenticatedUserName)
-    throws QueryModificationException
+    throws QueryModifierException
   {
     try
     {
@@ -203,8 +212,8 @@ public class QueryModifier
         int rval = httpResponse.getStatusLine().getStatusCode();
         if (rval != 200)
         {
-          String response = EntityUtils.toString(httpResponse.getEntity(),null);
-          throw new QueryModificationException("Couldn't fetch user's access tokens from ManifoldCF authority service: "+Integer.toString(rval)+"; "+response);
+          String response = EntityUtils.toString(httpResponse.getEntity(),"utf-8");
+          throw new QueryModifierException("Couldn't fetch user's access tokens from ManifoldCF authority service: "+Integer.toString(rval)+"; "+response);
         }
         InputStream is = httpResponse.getEntity().getContent();
         try
@@ -259,7 +268,7 @@ public class QueryModifier
     }
     catch (IOException e)
     {
-      throw new QueryModificationException("IO exception: "+e.getMessage(),e);
+      throw new QueryModifierException("IO exception: "+e.getMessage(),e);
     }
   }