manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1157173 - in /incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver: ./ connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/ connector/src/main/resource/org/apache/manifoldcf/agents/output/opensearchser...
Date Fri, 12 Aug 2011 16:07:40 GMT
Author: kwright
Date: Fri Aug 12 16:07:39 2011
New Revision: 1157173

URL: http://svn.apache.org/viewvc?rev=1157173&view=rev
Log:
Add new files from patch.

Added:
    incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerConfig.java
    incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerSchema.java
    incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerSpecs.java
    incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/resource/org/apache/manifoldcf/agents/output/opensearchserver/configuration.js
    incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/resource/org/apache/manifoldcf/agents/output/opensearchserver/specifications.html
    incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/resource/org/apache/manifoldcf/agents/output/opensearchserver/viewSpec.html
Modified:
    incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/   (props changed)

Propchange: incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Aug 12 16:07:39 2011
@@ -0,0 +1,4 @@
+build
+lib
+dist
+

Added: incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerConfig.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerConfig.java?rev=1157173&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerConfig.java
(added)
+++ incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerConfig.java
Fri Aug 12 16:07:39 2011
@@ -0,0 +1,76 @@
+package org.apache.manifoldcf.agents.output.opensearchserver;
+
+import org.apache.manifoldcf.core.interfaces.ConfigParams;
+import org.apache.manifoldcf.core.interfaces.IPostParameters;
+
+public class OpenSearchServerConfig extends OpenSearchServerParam {
+
+	/**
+	 * 
+	 */
+	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 OpenSearchServerParameters by reading ConfigParams. If the
+	 * value returned by ConfigParams.getParameter is null, the default value is
+	 * set.
+	 * 
+	 * @param paramList
+	 * @param params
+	 */
+	public OpenSearchServerConfig(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 OpenSearchServer
+	 *         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);
+	}
+}

Added: incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerSchema.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerSchema.java?rev=1157173&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerSchema.java
(added)
+++ incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerSchema.java
Fri Aug 12 16:07:39 2011
@@ -0,0 +1,21 @@
+package org.apache.manifoldcf.agents.output.opensearchserver;
+
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.manifoldcf.core.interfaces.ManifoldCFException;
+
+public class OpenSearchServerSchema extends OpenSearchServerConnection {
+
+	public OpenSearchServerSchema(OpenSearchServerConfig config)
+			throws ManifoldCFException {
+		super(config);
+		String indexName = config.getIndexName();
+		StringBuffer url = getApiUrl("schema");
+		url.append("&cmd=indexList");
+		GetMethod method = new GetMethod(url.toString());
+		String xpath = "count(/response/index[@name='" + indexName + "'])";
+		call(method);
+		if ("1".equals(checkXPath(xpath)))
+			return;
+		setResult(Result.ERROR, "Index not found");
+	}
+}

Added: incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerSpecs.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerSpecs.java?rev=1157173&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerSpecs.java
(added)
+++ incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerSpecs.java
Fri Aug 12 16:07:39 2011
@@ -0,0 +1,137 @@
+package org.apache.manifoldcf.agents.output.opensearchserver;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.manifoldcf.core.interfaces.ConfigurationNode;
+import org.apache.manifoldcf.core.interfaces.IPostParameters;
+import org.apache.manifoldcf.core.interfaces.ManifoldCFException;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+public class OpenSearchServerSpecs extends OpenSearchServerParam {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1859653440572662025L;
+
+	final public static ParameterEnum[] SPECIFICATIONLIST = {
+			ParameterEnum.MAXFILESIZE, ParameterEnum.MIMETYPES,
+			ParameterEnum.EXTENSIONS };
+
+	final public static String OPENSEARCHSERVER_SPECS_NODE = "OPENSEARCHSERVER_SPECS_NODE";
+
+	private Set<String> extensionSet;
+
+	private Set<String> mimeTypeSet;
+
+	/**
+	 * Build a set of OpenSearchServer parameters by reading an JSON object
+	 * 
+	 * @param json
+	 * @throws JSONException
+	 * @throws ManifoldCFException
+	 */
+	public OpenSearchServerSpecs(JSONObject json) throws JSONException,
+			ManifoldCFException {
+		super(SPECIFICATIONLIST);
+		extensionSet = null;
+		mimeTypeSet = null;
+		for (ParameterEnum param : SPECIFICATIONLIST) {
+			String value = null;
+			value = json.getString(param.name());
+			if (value == null)
+				value = param.defaultValue;
+			put(param, value);
+		}
+		extensionSet = createStringSet(getExtensions());
+		mimeTypeSet = createStringSet(getMimeTypes());
+	}
+
+	/**
+	 * Build a set of OpenSearchServer parameters by reading an instance of
+	 * SpecificationNode.
+	 * 
+	 * @param node
+	 * @throws ManifoldCFException
+	 */
+	public OpenSearchServerSpecs(ConfigurationNode node)
+			throws ManifoldCFException {
+		super(SPECIFICATIONLIST);
+		for (ParameterEnum param : SPECIFICATIONLIST) {
+			String value = null;
+			if (node != null)
+				value = node.getAttributeValue(param.name());
+			if (value == null)
+				value = param.defaultValue;
+			put(param, value);
+		}
+		extensionSet = createStringSet(getExtensions());
+		mimeTypeSet = createStringSet(getMimeTypes());
+	}
+
+	public static void contextToSpecNode(IPostParameters variableContext,
+			ConfigurationNode specNode) {
+		for (ParameterEnum param : SPECIFICATIONLIST) {
+			String p = variableContext.getParameter(param.name().toLowerCase());
+			if (p != null)
+				specNode.setAttribute(param.name(), p);
+		}
+	}
+
+	/**
+	 * 
+	 * @return a JSON representation of the parameter list
+	 */
+	public JSONObject toJson() {
+		return new JSONObject(this);
+	}
+
+	public long getMaxFileSize() {
+		return Long.parseLong(get(ParameterEnum.MAXFILESIZE));
+	}
+
+	public String getMimeTypes() {
+		return get(ParameterEnum.MIMETYPES);
+	}
+
+	public String getExtensions() {
+		return get(ParameterEnum.EXTENSIONS);
+	}
+
+	private final static TreeSet<String> createStringSet(String content)
+			throws ManifoldCFException {
+		TreeSet<String> set = new TreeSet<String>();
+		BufferedReader br = null;
+		StringReader sr = null;
+		try {
+			sr = new StringReader(content);
+			br = new BufferedReader(sr);
+			String line = null;
+			while ((line = br.readLine()) != null) {
+				line = line.trim();
+				if (line.length() > 0)
+					set.add(line);
+			}
+			return set;
+		} catch (IOException e) {
+			throw new ManifoldCFException(e);
+		} finally {
+			if (br != null)
+				IOUtils.closeQuietly(br);
+		}
+	}
+
+	public boolean checkExtension(String extension) {
+		return extensionSet.contains(extension);
+	}
+
+	public boolean checkMimeType(String mimeType) {
+		return mimeTypeSet.contains(mimeType);
+	}
+}

Added: incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/resource/org/apache/manifoldcf/agents/output/opensearchserver/configuration.js
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/resource/org/apache/manifoldcf/agents/output/opensearchserver/configuration.js?rev=1157173&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/resource/org/apache/manifoldcf/agents/output/opensearchserver/configuration.js
(added)
+++ incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/resource/org/apache/manifoldcf/agents/output/opensearchserver/configuration.js
Fri Aug 12 16:07:39 2011
@@ -0,0 +1,25 @@
+<script type="text/javascript">
+<!--
+function checkConfig() {
+	if (editconnection.serverlocation) {
+		if (editconnection.serverlocation.value == "") {
+			alert("Please supply a valid OpenSearchServer 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() {
+	return checkConfig();
+}
+-->
+</script>
\ No newline at end of file

Added: incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/resource/org/apache/manifoldcf/agents/output/opensearchserver/specifications.html
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/resource/org/apache/manifoldcf/agents/output/opensearchserver/specifications.html?rev=1157173&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/resource/org/apache/manifoldcf/agents/output/opensearchserver/specifications.html
(added)
+++ incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/resource/org/apache/manifoldcf/agents/output/opensearchserver/specifications.html
Fri Aug 12 16:07:39 2011
@@ -0,0 +1,18 @@
+<table class="displaytable">
+	<tr>
+		<td class="description"><nobr>Max file size</nobr> (bytes):</td>
+		<td class="value"><input name="maxfilesize"
+			value="${MAXFILESIZE}" size="24" /></td>
+	</tr>
+	<tr>
+		<td class="description"><nobr>Allowed MIME Types :</nobr>
+		</td>
+		<td class="value"><textarea rows="10" cols="64" name="mimetypes">${MIMETYPES}</textarea>
+		</td>
+	</tr>
+	<tr>
+		<td class="description"><nobr>Allowed file</nobr> extensions:</td>
+		<td class="value"><textarea rows="10" cols="12" name="extensions">${EXTENSIONS}</textarea>
+		</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/viewSpec.html
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/resource/org/apache/manifoldcf/agents/output/opensearchserver/viewSpec.html?rev=1157173&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/resource/org/apache/manifoldcf/agents/output/opensearchserver/viewSpec.html
(added)
+++ incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/resource/org/apache/manifoldcf/agents/output/opensearchserver/viewSpec.html
Fri Aug 12 16:07:39 2011
@@ -0,0 +1,14 @@
+<table class="displaytable">
+	<tr>
+		<td class="description"><nobr>Max file size</nobr> (bytes):</td>
+		<td class="value">${MAXFILESIZE}</td>
+	</tr>
+	<tr>
+		<td class="description"><nobr>Allowed MIME types:</nobr></td>
+		<td class="value">${MIMETYPES}</td>
+	</tr>
+	<tr>
+		<td class="description"><nobr>Allowed file</nobr> extensions:</td>
+		<td class="value">${EXTENSIONS}</td>
+	</tr>
+</table>
\ No newline at end of file



Mime
View raw message