incubator-connectors-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1154886 - in /incubator/lcf/branches/CONNECTORS-224: ./ connectors/opensearchserver/ connectors/opensearchserver/connector/ connectors/opensearchserver/connector/src/ connectors/opensearchserver/connector/src/main/ connectors/opensearchser...
Date Mon, 08 Aug 2011 09:23:03 GMT
Author: kwright
Date: Mon Aug  8 09:23:03 2011
New Revision: 1154886

URL: http://svn.apache.org/viewvc?rev=1154886&view=rev
Log:
Apply first patch for opensearchserver connector

Added:
    incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/
    incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/build.xml
    incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/
    incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/
    incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/
    incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/
    incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/
    incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/
    incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/
    incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/
    incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/
    incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/
    incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerConnection.java
    incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerConnector.java
    incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerDelete.java
    incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerIndex.java
    incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerParam.java
    incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/resource/
    incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/resource/org/
    incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/resource/org/apache/
    incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/resource/org/apache/manifoldcf/
    incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/resource/org/apache/manifoldcf/agents/
    incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/resource/org/apache/manifoldcf/agents/output/
    incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/resource/org/apache/manifoldcf/agents/output/opensearchserver/
    incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/resource/org/apache/manifoldcf/agents/output/opensearchserver/configuration.html
    incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/resource/org/apache/manifoldcf/agents/output/opensearchserver/view.html
Modified:
    incubator/lcf/branches/CONNECTORS-224/build.xml

Modified: incubator/lcf/branches/CONNECTORS-224/build.xml
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-224/build.xml?rev=1154886&r1=1154885&r2=1154886&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-224/build.xml (original)
+++ incubator/lcf/branches/CONNECTORS-224/build.xml Mon Aug  8 09:23:03 2011
@@ -54,6 +54,8 @@
         <delete dir="connectors/memex/lib"/>
         <ant dir="connectors/meridio" target="clean"/>
         <delete dir="connectors/meridio/lib"/>
+    	<ant dir="connectors/opensearchserver" target="clean"/>
+    	<delete dir="connectors/opensearchserver/lib"/>
         <ant dir="connectors/nullauthority" target="clean"/>
         <delete dir="connectors/nullauthority/lib"/>
         <ant dir="connectors/nulloutput" target="clean"/>
@@ -659,6 +661,20 @@
         <ant dir="connectors/meridio" target="run-tests"/>
     </target>
 
+    <target name="setup-opensearchserver-connector" depends="build-framework">
+        <mkdir dir="connectors/opensearchserver/lib"/>
+        <copy todir="connectors/opensearchserver/lib">
+            <fileset dir="framework/lib"/>
+        </copy>
+        <copy todir="connectors/opensearchserver/lib">
+            <fileset dir="framework/build/jar"/>
+        </copy>
+    </target>
+
+	<target name="build-opensearchserver-connector" depends="setup-opensearchserver-connector">
+	     <ant dir="connectors/opensearchserver" target="build"/>
+	</target>
+
     <target name="run-tests-postgresql-meridio-connector" depends="setup-meridio-connector,setup-meridio-connector-tests">
         <ant dir="connectors/meridio" target="run-tests-postgresql"/>
     </target>
@@ -1264,6 +1280,20 @@
         </copy>
     </target>
 
+    <target name="calculate-opensearchserver-condition" depends="build-opensearchserver-connector">
+	    <available file="connectors/opensearchserver/dist/lib" type="dir" property="opensearchserver.exists"/>
+	    <condition property="opensearchserver.include">
+	        <isset property="opensearchserver.exists"/>
+	    </condition>
+    </target>
+
+   <target name="deliver-opensearchserver-connector" depends="calculate-opensearchserver-condition"
if="opensearchserver.include">
+        <mkdir dir="dist/lib"/>
+        <copy todir="dist/lib">
+            <fileset dir="connectors/opensearchserver/dist/lib"/>
+        </copy>
+    </target>
+
     <target name="calculate-nullauthority-condition" depends="build-nullauthority-connector">
         <available file="connectors/nullauthority/dist/lib" type="dir" property="nullauthority.exists"/>
         <condition property="nullauthority.include">
@@ -1579,6 +1609,15 @@
         <replace file="dist/example/connectors.xml" token="&lt;!-- Add your output
connectors here --&gt;" value="&lt;!-- Add your output connectors here --&gt;&#0010;
 &lt;outputconnector name=&quot;Solr&quot; class=&quot;org.apache.manifoldcf.agents.output.solr.SolrConnector&quot;/&gt;"/>
     </target>
 
+   <target name="deliver-opensearchserver-example" depends="deliver-framework-example,calculate-opensearchserver-condition"
if="opensearchserver.include">
+        <mkdir dir="dist/example/connector-lib"/>
+        <copy todir="dist/example/connector-lib">
+            <fileset dir="connectors/opensearchserver/dist/lib"/>
+        </copy>
+        <replace file="dist/example/connectors.xml" token="&lt;!-- Add your output
connectors here --&gt;" value="&lt;!-- Add your output connectors here --&gt;&#0010;
 &lt;outputconnector name=&quot;OpenSearchServer&quot; class=&quot;org.apache.manifoldcf.agents.output.opensearchserver.OpenSearchServerConnector&quot;/&gt;"/>
+    </target>
+
+	
     <target name="deliver-webcrawler-example" depends="deliver-framework-example,calculate-webcrawler-condition"
if="webcrawler.include">
         <mkdir dir="dist/example/connector-lib"/>
         <copy todir="dist/example/connector-lib">
@@ -1587,7 +1626,7 @@
         <replace file="dist/example/connectors.xml" token="&lt;!-- Add your repository
connectors here --&gt;" value="&lt;!-- Add your repository connectors here --&gt;&#0010;
 &lt;repositoryconnector name=&quot;Web&quot; class=&quot;org.apache.manifoldcf.crawler.connectors.webcrawler.WebcrawlerConnector&quot;/&gt;"/>
     </target>
 
-    <target name="deliver-example" depends="deliver-framework-example,deliver-activedirectory-example,deliver-cmis-example,deliver-documentum-example,deliver-filesystem-example,deliver-filenet-example,deliver-gts-example,deliver-jcifs-example,deliver-jdbc-example,deliver-livelink-example,deliver-memex-example,deliver-meridio-example,deliver-nullauthority-example,deliver-nulloutput-example,deliver-rss-example,deliver-sharepoint-example,deliver-solr-example,deliver-webcrawler-example">
+    <target name="deliver-example" depends="deliver-framework-example,deliver-activedirectory-example,deliver-cmis-example,deliver-documentum-example,deliver-filesystem-example,deliver-filenet-example,deliver-gts-example,deliver-jcifs-example,deliver-jdbc-example,deliver-livelink-example,deliver-memex-example,deliver-meridio-example,deliver-nullauthority-example,deliver-nulloutput-example,deliver-opensearchserver-example,deliver-rss-example,deliver-sharepoint-example,deliver-solr-example,deliver-webcrawler-example">
         <!-- Build a manifest file.  There doesn't seem to be any good way to do this
automatically in ant without developing my own
         custom task, so I've hard coded all the class path libs. -->
         <mkdir dir="build/example"/>
@@ -1975,7 +2014,7 @@
     <target name="deliver-open-connectors" depends="deliver-nullauthority-connector,deliver-activedirectory-connector,deliver-cmis-connector,deliver-filesystem-connector,deliver-rss-connector,deliver-webcrawler-connector,deliver-jdbc-connector"/>
     <target name="deliver-open-connectors-doc" depends="deliver-nullauthority-connector-doc,deliver-activedirectory-connector-doc,deliver-cmis-connector-doc,deliver-filesystem-connector-doc,deliver-rss-connector-doc,deliver-webcrawler-connector-doc,deliver-jdbc-connector-doc"/>
     
-    <target name="deliver-output-connectors" depends="deliver-gts-connector,deliver-solr-connector,deliver-nulloutput-connector"/>
+    <target name="deliver-output-connectors" depends="deliver-gts-connector,deliver-solr-connector,deliver-nulloutput-connector,deliver-opensearchserver-connector"/>
     <target name="deliver-output-connectors-doc" depends="deliver-gts-connector-doc,deliver-solr-connector-doc,deliver-nulloutput-connector-doc"/>
     
     <target name="deliver-lgpl-connectors" depends="deliver-jcifs-connector"/>
@@ -1983,7 +2022,6 @@
     
     <target name="deliver-proprietary-connectors" depends="deliver-documentum-connector,deliver-filenet-connector,deliver-livelink-connector,deliver-memex-connector,deliver-meridio-connector,deliver-sharepoint-connector"/>
     <target name="deliver-proprietary-connectors-doc" depends="deliver-documentum-connector-doc,deliver-filenet-connector-doc,deliver-livelink-connector-doc,deliver-memex-connector-doc,deliver-meridio-connector-doc,deliver-sharepoint-connector-doc"/>
-        
 
     <target name="build" depends="deliver-framework,deliver-open-connectors,deliver-output-connectors,deliver-lgpl-connectors,deliver-proprietary-connectors,deliver-example"/>
     <target name="javadoc" depends="deliver-framework-doc,deliver-open-connectors-doc,deliver-output-connectors-doc,deliver-lgpl-connectors-doc,deliver-proprietary-connectors-doc"/>

Added: incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/build.xml
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/build.xml?rev=1154886&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/build.xml (added)
+++ incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/build.xml Mon Aug  8
09:23:03 2011
@@ -0,0 +1,38 @@
+<project default="all">
+
+	<target name="clean">
+		<delete dir="build" />
+		<delete dir="dist" />
+	</target>
+
+	<target name="compile-connector">
+		<mkdir dir="build/connector/classes" />
+		<javac srcdir="connector/src/main/java" destdir="build/connector/classes" target="1.5"
source="1.5" debug="true" debuglevel="lines,vars,source">
+			<classpath>
+				<fileset dir="lib" includes="*.jar" />
+			</classpath>
+		</javac>
+	</target>
+
+	<target name="jar-connector" depends="compile-connector">
+		<mkdir dir="build/jar" />
+		<jar destfile="build/jar/mcf-opensearchserver-connector.jar">
+			<fileset dir="build/connector/classes" />
+			<fileset dir="connector/src/main/resource" />
+		</jar>
+	</target>
+
+	<target name="lib" depends="jar-connector">
+		<mkdir dir="dist/lib" />
+		<copy todir="dist/lib" file="build/jar/mcf-opensearchserver-connector.jar" />
+	</target>
+
+	<target name="build" depends="lib" />
+	<target name="build-tests">
+		<mkdir dir="build/test-jar" />
+	</target>
+	<target name="run-tests" />
+
+	<target name="all" depends="build,build-tests,run-tests" />
+
+</project>

Added: incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerConnection.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerConnection.java?rev=1154886&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerConnection.java
(added)
+++ incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerConnection.java
Mon Aug  8 09:23:03 2011
@@ -0,0 +1,14 @@
+package org.apache.manifoldcf.agents.output.opensearchserver;
+
+public class OpenSearchServerConnection {
+
+	public String getResultDescription() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	public String getResultCode() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+}

Added: incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerConnector.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerConnector.java?rev=1154886&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerConnector.java
(added)
+++ incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerConnector.java
Mon Aug  8 09:23:03 2011
@@ -0,0 +1,139 @@
+package org.apache.manifoldcf.agents.output.opensearchserver;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.UnsupportedEncodingException;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.manifoldcf.agents.interfaces.IOutputAddActivity;
+import org.apache.manifoldcf.agents.interfaces.IOutputRemoveActivity;
+import org.apache.manifoldcf.agents.interfaces.RepositoryDocument;
+import org.apache.manifoldcf.agents.interfaces.ServiceInterruption;
+import org.apache.manifoldcf.agents.output.BaseOutputConnector;
+import org.apache.manifoldcf.core.interfaces.ConfigParams;
+import org.apache.manifoldcf.core.interfaces.IHTTPOutput;
+import org.apache.manifoldcf.core.interfaces.IPostParameters;
+import org.apache.manifoldcf.core.interfaces.IThreadContext;
+import org.apache.manifoldcf.core.interfaces.ManifoldCFException;
+
+public class OpenSearchServerConnector extends BaseOutputConnector {
+
+	private final static String OPENSEARCHSERVER_INDEXATION_ACTIVITY = "Indexation";
+	private final static String OPENSEARCHSERVER_DELETION_ACTIVTY = "Deletion";
+
+	private final static String[] OPENSEARCHSERVER_ACTIVITIES = {
+			OPENSEARCHSERVER_INDEXATION_ACTIVITY,
+			OPENSEARCHSERVER_DELETION_ACTIVTY };
+
+	@Override
+	public String[] getActivitiesList() {
+		return OPENSEARCHSERVER_ACTIVITIES;
+	}
+
+	/**
+	 * Read the content of a resource, replace the variable ${PARAMNAME} with
+	 * the value and copy it to the out.
+	 * 
+	 * @param resName
+	 * @param out
+	 * @throws ManifoldCFException
+	 */
+	private void outputResource(String resName, IHTTPOutput out,
+			Set<OpenSearchServerParam> params) throws ManifoldCFException {
+		InputStream is = getClass().getResourceAsStream(resName);
+		BufferedReader br = null;
+		try {
+			br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
+			String line;
+			while ((line = br.readLine()) != null)
+				out.println(OpenSearchServerParam.replace(line, params));
+		} catch (UnsupportedEncodingException e) {
+			throw new ManifoldCFException(e);
+		} catch (IOException e) {
+			throw new ManifoldCFException(e);
+		} finally {
+			if (br != null)
+				IOUtils.closeQuietly(br);
+			if (is != null)
+				IOUtils.closeQuietly(is);
+		}
+	}
+
+	@Override
+	public void outputConfigurationHeader(IThreadContext threadContext,
+			IHTTPOutput out, ConfigParams parameters, List<String> tabsArray)
+			throws ManifoldCFException, IOException {
+		super.outputConfigurationHeader(threadContext, out, parameters,
+				tabsArray);
+		tabsArray.add("Parameters");
+	}
+
+	@Override
+	public void outputConfigurationBody(IThreadContext threadContext,
+			IHTTPOutput out, ConfigParams parameters, String tabName)
+			throws ManifoldCFException, IOException {
+		super.outputConfigurationBody(threadContext, out, parameters, tabName);
+		Set<OpenSearchServerParam> params = OpenSearchServerParam
+				.getParameters(OpenSearchServerParam.CONFIGURATIONLIST,
+						parameters);
+		if ("Parameters".equals(tabName))
+			outputResource("configuration.html", out, params);
+	}
+
+	@Override
+	public void viewConfiguration(IThreadContext threadContext,
+			IHTTPOutput out, ConfigParams parameters)
+			throws ManifoldCFException, IOException {
+		Set<OpenSearchServerParam> params = OpenSearchServerParam
+				.getParameters(OpenSearchServerParam.CONFIGURATIONLIST,
+						parameters);
+		outputResource("view.html", out, params);
+	}
+
+	@Override
+	public String processConfigurationPost(IThreadContext threadContext,
+			IPostParameters variableContext, ConfigParams parameters)
+			throws ManifoldCFException {
+		OpenSearchServerParam.contextToConfig(
+				OpenSearchServerParam.CONFIGURATIONLIST, variableContext,
+				parameters);
+		return null;
+	}
+
+	@Override
+	public int addOrReplaceDocument(String documentURI,
+			String outputDescription, RepositoryDocument document,
+			String authorityNameString, IOutputAddActivity activities)
+			throws ManifoldCFException, ServiceInterruption {
+		InputStream inputStream = document.getBinaryStream();
+		try {
+			long startTime = System.currentTimeMillis();
+			OpenSearchServerIndex oi = new OpenSearchServerIndex(documentURI,
+					inputStream);
+			activities.recordActivity(startTime,
+					OPENSEARCHSERVER_INDEXATION_ACTIVITY,
+					document.getBinaryLength(), documentURI,
+					oi.getResultCode(), oi.getResultDescription());
+		} finally {
+			IOUtils.closeQuietly(inputStream);
+		}
+		return DOCUMENTSTATUS_ACCEPTED;
+	}
+
+	@Override
+	public void removeDocument(String documentURI, String outputDescription,
+			IOutputRemoveActivity activities) throws ManifoldCFException,
+			ServiceInterruption {
+		long startTime = System.currentTimeMillis();
+		OpenSearchServerDelete od = new OpenSearchServerDelete(documentURI);
+		activities.recordActivity(startTime, OPENSEARCHSERVER_DELETION_ACTIVTY,
+				null, documentURI, od.getResultCode(),
+				od.getResultDescription());
+		System.out.flush();
+	}
+
+}

Added: incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerDelete.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerDelete.java?rev=1154886&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerDelete.java
(added)
+++ incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerDelete.java
Mon Aug  8 09:23:03 2011
@@ -0,0 +1,9 @@
+package org.apache.manifoldcf.agents.output.opensearchserver;
+
+public class OpenSearchServerDelete extends OpenSearchServerConnection {
+
+	public OpenSearchServerDelete(String documentURI) {
+		// TODO Auto-generated constructor stub
+	}
+
+}

Added: incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerIndex.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerIndex.java?rev=1154886&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerIndex.java
(added)
+++ incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerIndex.java
Mon Aug  8 09:23:03 2011
@@ -0,0 +1,10 @@
+package org.apache.manifoldcf.agents.output.opensearchserver;
+
+import java.io.InputStream;
+
+public class OpenSearchServerIndex extends OpenSearchServerConnection {
+
+	public OpenSearchServerIndex(String documentURI, InputStream inputStream) {
+	}
+
+}

Added: incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerParam.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerParam.java?rev=1154886&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerParam.java
(added)
+++ incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerParam.java
Mon Aug  8 09:23:03 2011
@@ -0,0 +1,86 @@
+package org.apache.manifoldcf.agents.output.opensearchserver;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.manifoldcf.core.interfaces.ConfigParams;
+import org.apache.manifoldcf.core.interfaces.IPostParameters;
+
+public class OpenSearchServerParam {
+
+	/**
+	 * Parameters constants
+	 */
+	private enum ParameterEnum {
+		SERVERLOCATION("http://localhost:8080/"),
+
+		INDEXNAME("index"),
+
+		USERNAME(""),
+
+		APIKEY("");
+
+		final protected String defaultValue;
+
+		private ParameterEnum(String defaultValue) {
+			this.defaultValue = defaultValue;
+		}
+	}
+
+	final public ParameterEnum key;
+	final public String value;
+
+	protected OpenSearchServerParam(ParameterEnum key, String value) {
+		this.key = key;
+		this.value = value;
+	}
+
+	/**
+	 * Parameters used for the configuration
+	 */
+	final public static ParameterEnum[] CONFIGURATIONLIST = {
+			ParameterEnum.SERVERLOCATION, ParameterEnum.INDEXNAME,
+			ParameterEnum.USERNAME, ParameterEnum.APIKEY };
+
+	/**
+	 * Build a set of OpenSearchServerParameters by reading ConfigParams. If the
+	 * value returned by ConfigParams.getParameter is null, the default value is
+	 * set.
+	 * 
+	 * @param params
+	 * @return
+	 */
+	final public static Set<OpenSearchServerParam> getParameters(
+			ParameterEnum[] paramList, ConfigParams params) {
+		Set<OpenSearchServerParam> ossParams = new HashSet<OpenSearchServerParam>();
+		for (ParameterEnum param : paramList) {
+			String value = params.getParameter(param.name());
+			if (value == null)
+				value = param.defaultValue;
+			ossParams.add(new OpenSearchServerParam(param, value));
+		}
+		return ossParams;
+	}
+
+	/**
+	 * Replace the variables ${PARAMNAME} with the value contained in the set.
+	 * 
+	 * @param text
+	 * @param params
+	 */
+	final public static String replace(String text,
+			Set<OpenSearchServerParam> params) {
+		for (OpenSearchServerParam param : params)
+			text = text.replace("${" + param.key.name() + "}", param.value);
+		return text;
+	}
+
+	public static void contextToConfig(ParameterEnum[] paramList,
+			IPostParameters variableContext, ConfigParams parameters) {
+		for (ParameterEnum param : paramList) {
+			String p = variableContext.getParameter(param.name().toLowerCase());
+			if (p != null)
+				parameters.setParameter(param.name(), p);
+		}
+	}
+}

Added: incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/resource/org/apache/manifoldcf/agents/output/opensearchserver/configuration.html
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/resource/org/apache/manifoldcf/agents/output/opensearchserver/configuration.html?rev=1154886&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/resource/org/apache/manifoldcf/agents/output/opensearchserver/configuration.html
(added)
+++ incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/resource/org/apache/manifoldcf/agents/output/opensearchserver/configuration.html
Mon Aug  8 09:23:03 2011
@@ -0,0 +1,23 @@
+<table class="displaytable">
+	<tr>
+		<td class="description"><nobr>Server Location</nobr> (URL):</td>
+		<td class="value"><input name="serverlocation"
+			value="${SERVERLOCATION}" size="48" />
+		</td>
+	</tr>
+	<tr>
+		<td class="description"><nobr>Index name:</nobr></td>
+		<td class="value"><input name="indexname" value="${INDEXNAME}"
+			size="24" /></td>
+	</tr>
+	<tr>
+		<td class="description"><nobr>User name:</nobr></td>
+		<td class="value"><input name="username" value="${USERNAME}"
+			size="24" /></td>
+	</tr>
+	<tr>
+		<td class="description"><nobr>API Key:</nobr></td>
+		<td class="value"><input name="apikey" value="${APIKEY}"
+			size="40" /></td>
+	</tr>
+</table>
\ No newline at end of file

Added: incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/resource/org/apache/manifoldcf/agents/output/opensearchserver/view.html
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/resource/org/apache/manifoldcf/agents/output/opensearchserver/view.html?rev=1154886&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/resource/org/apache/manifoldcf/agents/output/opensearchserver/view.html
(added)
+++ incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/resource/org/apache/manifoldcf/agents/output/opensearchserver/view.html
Mon Aug  8 09:23:03 2011
@@ -0,0 +1,18 @@
+<table class="displaytable">
+	<tr>
+		<td class="description"><nobr>Server Location</nobr> (URL):</td>
+		<td class="value">${SERVERLOCATION}</td>
+	</tr>
+	<tr>
+		<td class="description"><nobr>Index name:</nobr></td>
+		<td class="value">${INDEXNAME}</td>
+	</tr>
+	<tr>
+		<td class="description"><nobr>User name:</nobr></td>
+		<td class="value">${USERNAME}</td>
+	</tr>
+	<tr>
+		<td class="description"><nobr>API Key:</nobr></td>
+		<td class="value">${APIKEY}</td>
+	</tr>
+</table>
\ No newline at end of file



Mime
View raw message