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 2011/08/17 13:13:29 UTC

svn commit: r1158630 - /incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/

Author: kwright
Date: Wed Aug 17 11:13:29 2011
New Revision: 1158630

URL: http://svn.apache.org/viewvc?rev=1158630&view=rev
Log:
Merge in rc1 patch.

Modified:
    incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerAction.java
    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/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/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

Modified: incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerAction.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerAction.java?rev=1158630&r1=1158629&r2=1158630&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerAction.java (original)
+++ incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerAction.java Wed Aug 17 11:13:29 2011
@@ -5,20 +5,20 @@ import org.apache.manifoldcf.core.interf
 
 public class OpenSearchServerAction extends OpenSearchServerConnection {
 
-	public enum CommandEnum {
-		optimize, reload;
-	}
+  public enum CommandEnum {
+    optimize, reload;
+  }
 
-	public OpenSearchServerAction(CommandEnum cmd, OpenSearchServerConfig config)
-			throws ManifoldCFException {
-		super(config);
-		StringBuffer url = getApiUrl("action");
-		url.append("&action=");
-		url.append(cmd.name());
-		GetMethod method = new GetMethod(url.toString());
-		call(method);
-		if ("OK".equals(checkXPath(xPathStatus)))
-			return;
-		setResult(Result.ERROR, checkXPath(xPathException));
-	}
+  public OpenSearchServerAction(CommandEnum cmd, OpenSearchServerConfig config)
+      throws ManifoldCFException {
+    super(config);
+    StringBuffer url = getApiUrl("action");
+    url.append("&action=");
+    url.append(cmd.name());
+    GetMethod method = new GetMethod(url.toString());
+    call(method);
+    if ("OK".equals(checkXPath(xPathStatus)))
+      return;
+    setResult(Result.ERROR, checkXPath(xPathException));
+  }
 }

Modified: 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=1158630&r1=1158629&r2=1158630&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerConfig.java (original)
+++ incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerConfig.java Wed Aug 17 11:13:29 2011
@@ -5,72 +5,71 @@ import org.apache.manifoldcf.core.interf
 
 public class OpenSearchServerConfig extends OpenSearchServerParam {
 
-	/**
+  /**
 	 * 
 	 */
-	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 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);
-	}
+  /**
+   * 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);
+  }
 }

Modified: 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=1158630&r1=1158629&r2=1158630&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerConnection.java (original)
+++ incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerConnection.java Wed Aug 17 11:13:29 2011
@@ -24,161 +24,161 @@ import org.xml.sax.SAXException;
 
 public class OpenSearchServerConnection {
 
-	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 OpenSearchServerConnection(OpenSearchServerConfig 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(command);
-		url.append("?use=");
-		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;
+
+  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 OpenSearchServerConnection(OpenSearchServerConfig 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(command);
+    url.append("?use=");
+    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;
+  }
 }

Modified: 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=1158630&r1=1158629&r2=1158630&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerConnector.java (original)
+++ incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerConnector.java Wed Aug 17 11:13:29 2011
@@ -33,304 +33,295 @@ import org.json.JSONObject;
 
 public class OpenSearchServerConnector extends BaseOutputConnector {
 
-	private final static String OPENSEARCHSERVER_INDEXATION_ACTIVITY = "Indexation";
-	private final static String OPENSEARCHSERVER_DELETION_ACTIVITY = "Deletion";
-	private final static String OPENSEARCHSERVER_OPTIMIZE_ACTIVITY = "Optimize";
-
-	private final static String[] OPENSEARCHSERVER_ACTIVITIES = {
-			OPENSEARCHSERVER_INDEXATION_ACTIVITY,
-			OPENSEARCHSERVER_DELETION_ACTIVITY,
-			OPENSEARCHSERVER_OPTIMIZE_ACTIVITY };
-
-	private final static String OPENSEARCHSERVER_TAB_PARAMETER = "Parameters";
-	private final static String OPENSEARCHSERVER_TAB_OPENSEARCHSERVER = "OpenSearchServer";
-
-	private String specsCacheOutpuDescription;
-	private OpenSearchServerSpecs specsCache;
-
-	public OpenSearchServerConnector() {
-		specsCacheOutpuDescription = null;
-		specsCache = null;
-	}
-
-	@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,
-			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)
-				if (params != null)
-					out.println(params.replace(line));
-				else
-					out.println(line);
-		} 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(OPENSEARCHSERVER_TAB_PARAMETER);
-		outputResource("configuration.js", out, null);
-	}
-
-	@Override
-	public void outputConfigurationBody(IThreadContext threadContext,
-			IHTTPOutput out, ConfigParams parameters, String tabName)
-			throws ManifoldCFException, IOException {
-		super.outputConfigurationBody(threadContext, out, parameters, tabName);
-		if (OPENSEARCHSERVER_TAB_PARAMETER.equals(tabName)) {
-			outputResource("configuration.html", out,
-					getConfigParameters(parameters));
-		}
-	}
-
-	@Override
-	public void outputSpecificationHeader(IHTTPOutput out,
-			OutputSpecification os, List<String> tabsArray)
-			throws ManifoldCFException, IOException {
-		super.outputSpecificationHeader(out, os, tabsArray);
-		tabsArray.add(OPENSEARCHSERVER_TAB_OPENSEARCHSERVER);
-	}
-
-	final private SpecificationNode getSpecNode(OutputSpecification os) {
-		int l = os.getChildCount();
-		for (int i = 0; i < l; i++) {
-			SpecificationNode node = os.getChild(i);
-			if (OpenSearchServerSpecs.OPENSEARCHSERVER_SPECS_NODE.equals(node
-					.getType())) {
-				return node;
-			}
-		}
-		return null;
-	}
-
-	@Override
-	public void outputSpecificationBody(IHTTPOutput out,
-			OutputSpecification os, String tabName) throws ManifoldCFException,
-			IOException {
-		super.outputSpecificationBody(out, os, tabName);
-		if (OPENSEARCHSERVER_TAB_OPENSEARCHSERVER.equals(tabName)) {
-			outputResource("specifications.html", out, getSpecParameters(os));
-		}
-	}
-
-	@Override
-	public String processSpecificationPost(IPostParameters variableContext,
-			OutputSpecification os) throws ManifoldCFException {
-		ConfigurationNode specNode = getSpecNode(os);
-		boolean bAdd = (specNode == null);
-		if (bAdd) {
-			specNode = new SpecificationNode(
-					OpenSearchServerSpecs.OPENSEARCHSERVER_SPECS_NODE);
-		}
-		OpenSearchServerSpecs.contextToSpecNode(variableContext, specNode);
-		if (bAdd)
-			os.addChild(os.getChildCount(), specNode);
-		return null;
-	}
-
-	/**
-	 * Build a Set of OpenSearchServer parameters. If configParams is null,
-	 * getConfiguration() is used.
-	 * 
-	 * @param configParams
-	 */
-	final private OpenSearchServerConfig getConfigParameters(
-			ConfigParams configParams) {
-		if (configParams == null)
-			configParams = getConfiguration();
-		synchronized (this) {
-			return new OpenSearchServerConfig(configParams);
-		}
-	}
-
-	final private OpenSearchServerSpecs getSpecParameters(OutputSpecification os)
-			throws ManifoldCFException {
-		return new OpenSearchServerSpecs(getSpecNode(os));
-	}
-
-	final private OpenSearchServerSpecs getSpecsCache(String outputDescription)
-			throws ManifoldCFException {
-		try {
-			synchronized (this) {
-				if (!outputDescription.equals(specsCacheOutpuDescription))
-					specsCache = null;
-				if (specsCache == null)
-					specsCache = new OpenSearchServerSpecs(new JSONObject(
-							outputDescription));
-				return specsCache;
-			}
-		} catch (JSONException e) {
-			throw new ManifoldCFException(e);
-		}
-	}
-
-	@Override
-	public String getOutputDescription(OutputSpecification os)
-			throws ManifoldCFException {
-		OpenSearchServerSpecs specs = new OpenSearchServerSpecs(getSpecNode(os));
-		return specs.toJson().toString();
-	}
-
-	@Override
-	public boolean checkLengthIndexable(String outputDescription, long length)
-			throws ManifoldCFException, ServiceInterruption {
-		OpenSearchServerSpecs specs = getSpecsCache(outputDescription);
-		long maxFileSize = specs.getMaxFileSize();
-		if (length > maxFileSize)
-			return false;
-		return super.checkLengthIndexable(outputDescription, length);
-	}
-
-	@Override
-	public boolean checkDocumentIndexable(String outputDescription,
-			File localFile) throws ManifoldCFException, ServiceInterruption {
-		OpenSearchServerSpecs specs = getSpecsCache(outputDescription);
-		return specs.checkExtension(FilenameUtils.getExtension(localFile
-				.getName()));
-	}
-
-	@Override
-	public boolean checkMimeTypeIndexable(String outputDescription,
-			String mimeType) throws ManifoldCFException, ServiceInterruption {
-		OpenSearchServerSpecs specs = getSpecsCache(outputDescription);
-		return specs.checkMimeType(mimeType);
-	}
-
-	@Override
-	public void viewConfiguration(IThreadContext threadContext,
-			IHTTPOutput out, ConfigParams parameters)
-			throws ManifoldCFException, IOException {
-		outputResource("view.html", out, getConfigParameters(parameters));
-	}
-
-	@Override
-	public void viewSpecification(IHTTPOutput out, OutputSpecification os)
-			throws ManifoldCFException, IOException {
-		outputResource("viewSpec.html", out, getSpecParameters(os));
-	}
-
-	@Override
-	public String processConfigurationPost(IThreadContext threadContext,
-			IPostParameters variableContext, ConfigParams parameters)
-			throws ManifoldCFException {
-		OpenSearchServerConfig.contextToConfig(variableContext, parameters);
-		return null;
-	}
-
-	private static Map<String, Integer> ossInstances = null;
-
-	private synchronized final Integer addInstance(OpenSearchServerConfig config) {
-		if (ossInstances == null)
-			ossInstances = new TreeMap<String, Integer>();
-		synchronized (ossInstances) {
-			String uii = config.getUniqueIndexIdentifier();
-			Integer count = ossInstances.get(uii);
-			if (count == null) {
-				count = new Integer(1);
-				ossInstances.put(uii, count);
-			} else
-				count++;
-			return count;
-		}
-	}
-
-	private synchronized final void removeInstance(OpenSearchServerConfig config) {
-		if (ossInstances == null)
-			return;
-		synchronized (ossInstances) {
-			String uii = config.getUniqueIndexIdentifier();
-			Integer count = ossInstances.get(uii);
-			if (count == null)
-				return;
-			if (--count == 0)
-				ossInstances.remove(uii);
-		}
-	}
-
-	@Override
-	public int addOrReplaceDocument(String documentURI,
-			String outputDescription, RepositoryDocument document,
-			String authorityNameString, IOutputAddActivity activities)
-			throws ManifoldCFException, ServiceInterruption {
-		OpenSearchServerConfig config = getConfigParameters(null);
-		Integer count = addInstance(config);
-		synchronized (count) {
-			InputStream inputStream = document.getBinaryStream();
-			try {
-				long startTime = System.currentTimeMillis();
-				OpenSearchServerIndex oi = new OpenSearchServerIndex(
-						documentURI, inputStream, config);
-				activities.recordActivity(startTime,
-						OPENSEARCHSERVER_INDEXATION_ACTIVITY, document
-								.getBinaryLength(), documentURI, oi.getResult()
-								.name(), oi.getResultDescription());
-				if (oi.getResult() != Result.OK)
-					return DOCUMENTSTATUS_REJECTED;
-			} finally {
-				IOUtils.closeQuietly(inputStream);
-				removeInstance(config);
-			}
-			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,
-				getConfigParameters(null));
-		activities.recordActivity(startTime,
-				OPENSEARCHSERVER_DELETION_ACTIVITY, null, documentURI, od
-						.getResult().name(), od.getResultDescription());
-	}
-
-	@Override
-	public String check() throws ManifoldCFException {
-		OpenSearchServerSchema oss = new OpenSearchServerSchema(
-				getConfigParameters(null));
-		return oss.getResult().name() + " " + oss.getResultDescription();
-	}
-
-	@Override
-	public void noteJobComplete(IOutputNotifyActivity activities)
-			throws ManifoldCFException, ServiceInterruption {
-		long startTime = System.currentTimeMillis();
-		OpenSearchServerAction oo = new OpenSearchServerAction(
-				CommandEnum.optimize, getConfigParameters(null));
-		activities.recordActivity(startTime,
-				OPENSEARCHSERVER_OPTIMIZE_ACTIVITY, null,
-				oo.getCallUrlSnippet(), oo.getResult().name(),
-				oo.getResultDescription());
-	}
+  private final static String OPENSEARCHSERVER_INDEXATION_ACTIVITY = "Indexation";
+  private final static String OPENSEARCHSERVER_DELETION_ACTIVITY = "Deletion";
+  private final static String OPENSEARCHSERVER_OPTIMIZE_ACTIVITY = "Optimize";
+
+  private final static String[] OPENSEARCHSERVER_ACTIVITIES = {
+      OPENSEARCHSERVER_INDEXATION_ACTIVITY, OPENSEARCHSERVER_DELETION_ACTIVITY,
+      OPENSEARCHSERVER_OPTIMIZE_ACTIVITY };
+
+  private final static String OPENSEARCHSERVER_TAB_PARAMETER = "Parameters";
+  private final static String OPENSEARCHSERVER_TAB_OPENSEARCHSERVER = "OpenSearchServer";
+
+  private String specsCacheOutpuDescription;
+  private OpenSearchServerSpecs specsCache;
+
+  public OpenSearchServerConnector() {
+    specsCacheOutpuDescription = null;
+    specsCache = null;
+  }
+
+  @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,
+      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)
+        if (params != null)
+          out.println(params.replace(line));
+        else
+          out.println(line);
+    } 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(OPENSEARCHSERVER_TAB_PARAMETER);
+    outputResource("configuration.js", out, null);
+  }
+
+  @Override
+  public void outputConfigurationBody(IThreadContext threadContext,
+      IHTTPOutput out, ConfigParams parameters, String tabName)
+      throws ManifoldCFException, IOException {
+    super.outputConfigurationBody(threadContext, out, parameters, tabName);
+    if (OPENSEARCHSERVER_TAB_PARAMETER.equals(tabName)) {
+      outputResource("configuration.html", out, getConfigParameters(parameters));
+    }
+  }
+
+  @Override
+  public void outputSpecificationHeader(IHTTPOutput out,
+      OutputSpecification os, List<String> tabsArray)
+      throws ManifoldCFException, IOException {
+    super.outputSpecificationHeader(out, os, tabsArray);
+    tabsArray.add(OPENSEARCHSERVER_TAB_OPENSEARCHSERVER);
+  }
+
+  final private SpecificationNode getSpecNode(OutputSpecification os) {
+    int l = os.getChildCount();
+    for (int i = 0; i < l; i++) {
+      SpecificationNode node = os.getChild(i);
+      if (OpenSearchServerSpecs.OPENSEARCHSERVER_SPECS_NODE.equals(node
+          .getType())) {
+        return node;
+      }
+    }
+    return null;
+  }
+
+  @Override
+  public void outputSpecificationBody(IHTTPOutput out, OutputSpecification os,
+      String tabName) throws ManifoldCFException, IOException {
+    super.outputSpecificationBody(out, os, tabName);
+    if (OPENSEARCHSERVER_TAB_OPENSEARCHSERVER.equals(tabName)) {
+      outputResource("specifications.html", out, getSpecParameters(os));
+    }
+  }
+
+  @Override
+  public String processSpecificationPost(IPostParameters variableContext,
+      OutputSpecification os) throws ManifoldCFException {
+    ConfigurationNode specNode = getSpecNode(os);
+    boolean bAdd = (specNode == null);
+    if (bAdd) {
+      specNode = new SpecificationNode(
+          OpenSearchServerSpecs.OPENSEARCHSERVER_SPECS_NODE);
+    }
+    OpenSearchServerSpecs.contextToSpecNode(variableContext, specNode);
+    if (bAdd)
+      os.addChild(os.getChildCount(), specNode);
+    return null;
+  }
+
+  /**
+   * Build a Set of OpenSearchServer parameters. If configParams is null,
+   * getConfiguration() is used.
+   * 
+   * @param configParams
+   */
+  final private OpenSearchServerConfig getConfigParameters(
+      ConfigParams configParams) {
+    if (configParams == null)
+      configParams = getConfiguration();
+    synchronized (this) {
+      return new OpenSearchServerConfig(configParams);
+    }
+  }
+
+  final private OpenSearchServerSpecs getSpecParameters(OutputSpecification os)
+      throws ManifoldCFException {
+    return new OpenSearchServerSpecs(getSpecNode(os));
+  }
+
+  final private OpenSearchServerSpecs getSpecsCache(String outputDescription)
+      throws ManifoldCFException {
+    try {
+      synchronized (this) {
+        if (!outputDescription.equals(specsCacheOutpuDescription))
+          specsCache = null;
+        if (specsCache == null)
+          specsCache = new OpenSearchServerSpecs(new JSONObject(
+              outputDescription));
+        return specsCache;
+      }
+    } catch (JSONException e) {
+      throw new ManifoldCFException(e);
+    }
+  }
+
+  @Override
+  public String getOutputDescription(OutputSpecification os)
+      throws ManifoldCFException {
+    OpenSearchServerSpecs specs = new OpenSearchServerSpecs(getSpecNode(os));
+    return specs.toJson().toString();
+  }
+
+  @Override
+  public boolean checkLengthIndexable(String outputDescription, long length)
+      throws ManifoldCFException, ServiceInterruption {
+    OpenSearchServerSpecs specs = getSpecsCache(outputDescription);
+    long maxFileSize = specs.getMaxFileSize();
+    if (length > maxFileSize)
+      return false;
+    return super.checkLengthIndexable(outputDescription, length);
+  }
+
+  @Override
+  public boolean checkDocumentIndexable(String outputDescription, File localFile)
+      throws ManifoldCFException, ServiceInterruption {
+    OpenSearchServerSpecs specs = getSpecsCache(outputDescription);
+    return specs
+        .checkExtension(FilenameUtils.getExtension(localFile.getName()));
+  }
+
+  @Override
+  public boolean checkMimeTypeIndexable(String outputDescription,
+      String mimeType) throws ManifoldCFException, ServiceInterruption {
+    OpenSearchServerSpecs specs = getSpecsCache(outputDescription);
+    return specs.checkMimeType(mimeType);
+  }
+
+  @Override
+  public void viewConfiguration(IThreadContext threadContext, IHTTPOutput out,
+      ConfigParams parameters) throws ManifoldCFException, IOException {
+    outputResource("view.html", out, getConfigParameters(parameters));
+  }
+
+  @Override
+  public void viewSpecification(IHTTPOutput out, OutputSpecification os)
+      throws ManifoldCFException, IOException {
+    outputResource("viewSpec.html", out, getSpecParameters(os));
+  }
+
+  @Override
+  public String processConfigurationPost(IThreadContext threadContext,
+      IPostParameters variableContext, ConfigParams parameters)
+      throws ManifoldCFException {
+    OpenSearchServerConfig.contextToConfig(variableContext, parameters);
+    return null;
+  }
+
+  private static Map<String, Integer> ossInstances = null;
+
+  private synchronized final Integer addInstance(OpenSearchServerConfig config) {
+    if (ossInstances == null)
+      ossInstances = new TreeMap<String, Integer>();
+    synchronized (ossInstances) {
+      String uii = config.getUniqueIndexIdentifier();
+      Integer count = ossInstances.get(uii);
+      if (count == null) {
+        count = new Integer(1);
+        ossInstances.put(uii, count);
+      } else
+        count++;
+      return count;
+    }
+  }
+
+  private synchronized final void removeInstance(OpenSearchServerConfig config) {
+    if (ossInstances == null)
+      return;
+    synchronized (ossInstances) {
+      String uii = config.getUniqueIndexIdentifier();
+      Integer count = ossInstances.get(uii);
+      if (count == null)
+        return;
+      if (--count == 0)
+        ossInstances.remove(uii);
+    }
+  }
+
+  @Override
+  public int addOrReplaceDocument(String documentURI, String outputDescription,
+      RepositoryDocument document, String authorityNameString,
+      IOutputAddActivity activities) throws ManifoldCFException,
+      ServiceInterruption {
+    OpenSearchServerConfig config = getConfigParameters(null);
+    Integer count = addInstance(config);
+    synchronized (count) {
+      InputStream inputStream = document.getBinaryStream();
+      try {
+        long startTime = System.currentTimeMillis();
+        OpenSearchServerIndex oi = new OpenSearchServerIndex(documentURI,
+            inputStream, config);
+        activities.recordActivity(startTime,
+            OPENSEARCHSERVER_INDEXATION_ACTIVITY, document.getBinaryLength(),
+            documentURI, oi.getResult().name(), oi.getResultDescription());
+        if (oi.getResult() != Result.OK)
+          return DOCUMENTSTATUS_REJECTED;
+      } finally {
+        removeInstance(config);
+      }
+      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,
+        getConfigParameters(null));
+    activities.recordActivity(startTime, OPENSEARCHSERVER_DELETION_ACTIVITY,
+        null, documentURI, od.getResult().name(), od.getResultDescription());
+  }
+
+  @Override
+  public String check() throws ManifoldCFException {
+    OpenSearchServerSchema oss = new OpenSearchServerSchema(
+        getConfigParameters(null));
+    return oss.getResult().name() + " " + oss.getResultDescription();
+  }
+
+  @Override
+  public void noteJobComplete(IOutputNotifyActivity activities)
+      throws ManifoldCFException, ServiceInterruption {
+    long startTime = System.currentTimeMillis();
+    OpenSearchServerAction oo = new OpenSearchServerAction(
+        CommandEnum.optimize, getConfigParameters(null));
+    activities.recordActivity(startTime, OPENSEARCHSERVER_OPTIMIZE_ACTIVITY,
+        null, oo.getCallUrlSnippet(), oo.getResult().name(),
+        oo.getResultDescription());
+  }
 
 }

Modified: 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=1158630&r1=1158629&r2=1158630&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerDelete.java (original)
+++ incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerDelete.java Wed Aug 17 11:13:29 2011
@@ -5,16 +5,16 @@ import org.apache.manifoldcf.core.interf
 
 public class OpenSearchServerDelete extends OpenSearchServerConnection {
 
-	public OpenSearchServerDelete(String documentURI,
-			OpenSearchServerConfig 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 ("OK".equals(checkXPath(xPathStatus)))
-			return;
-		setResult(Result.ERROR, checkXPath(xPathException));
-	}
+  public OpenSearchServerDelete(String documentURI,
+      OpenSearchServerConfig 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 ("OK".equals(checkXPath(xPathStatus)))
+      return;
+    setResult(Result.ERROR, checkXPath(xPathException));
+  }
 }

Modified: 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=1158630&r1=1158629&r2=1158630&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerIndex.java (original)
+++ incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerIndex.java Wed Aug 17 11:13:29 2011
@@ -14,69 +14,68 @@ import org.apache.manifoldcf.core.interf
 
 public class OpenSearchServerIndex extends OpenSearchServerConnection {
 
-	private class IndexRequestEntity implements RequestEntity {
+  private class IndexRequestEntity implements RequestEntity {
 
-		private String documentURI;
+    private String documentURI;
 
-		private InputStream inputStream;
+    private InputStream inputStream;
 
-		private String fileName;
+    private String fileName;
 
-		public IndexRequestEntity(String documentURI, InputStream inputStream) {
-			this.documentURI = documentURI;
-			this.inputStream = inputStream;
-			this.fileName = FilenameUtils.getName(documentURI);
-		}
-
-		public long getContentLength() {
-			return -1;
-		}
-
-		public String getContentType() {
-			return "text/xml; charset=utf-8";
-		}
-
-		public boolean isRepeatable() {
-			return false;
-		}
-
-		public void writeRequest(OutputStream out) throws IOException {
-			PrintWriter pw = new PrintWriter(out);
-			try {
-				pw.println("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
-				pw.println("<index>);");
-				pw.print("<document><field name=\"uri\"><value>");
-				pw.print(documentURI);
-				pw.println("</value></field>");
-				pw.print("<binary fileName=\"");
-				pw.print(fileName);
-				pw.println("\">");
-				Base64 base64 = new Base64();
-				base64.encodeStream(inputStream, pw);
-				pw.println("</binary></document>");
-				pw.println("</index>");
-			} catch (ManifoldCFException e) {
-				throw new IOException(e.getMessage());
-			} finally {
-				IOUtils.closeQuietly(pw);
-			}
-		}
-
-	}
-
-	public OpenSearchServerIndex(String documentURI, InputStream inputStream,
-			OpenSearchServerConfig config) throws ManifoldCFException {
-		super(config);
-		StringBuffer url = getApiUrl("update");
-		PutMethod put = new PutMethod(url.toString());
-		RequestEntity entity = new IndexRequestEntity(documentURI, inputStream);
-		put.setRequestEntity(entity);
-		call(put);
-		if ("OK".equals(checkXPath(xPathStatus)))
-			return;
-		String error = checkXPath(xPathException);
-		setResult(Result.ERROR, error);
-		System.err.println(getResponse());
-	}
+    public IndexRequestEntity(String documentURI, InputStream inputStream) {
+      this.documentURI = documentURI;
+      this.inputStream = inputStream;
+      this.fileName = FilenameUtils.getName(documentURI);
+    }
+
+    public long getContentLength() {
+      return -1;
+    }
+
+    public String getContentType() {
+      return "text/xml; charset=utf-8";
+    }
+
+    public boolean isRepeatable() {
+      return false;
+    }
+
+    public void writeRequest(OutputStream out) throws IOException {
+      PrintWriter pw = new PrintWriter(out);
+      try {
+        pw.println("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
+        pw.println("<index>);");
+        pw.print("<document><field name=\"uri\"><value>");
+        pw.print(documentURI);
+        pw.println("</value></field>");
+        pw.print("<binary fileName=\"");
+        pw.print(fileName);
+        pw.println("\">");
+        Base64 base64 = new Base64();
+        base64.encodeStream(inputStream, pw);
+        pw.println("</binary></document>");
+        pw.println("</index>");
+      } catch (ManifoldCFException e) {
+        throw new IOException(e.getMessage());
+      } finally {
+        IOUtils.closeQuietly(pw);
+      }
+    }
+  }
+
+  public OpenSearchServerIndex(String documentURI, InputStream inputStream,
+      OpenSearchServerConfig config) throws ManifoldCFException {
+    super(config);
+    StringBuffer url = getApiUrl("update");
+    PutMethod put = new PutMethod(url.toString());
+    RequestEntity entity = new IndexRequestEntity(documentURI, inputStream);
+    put.setRequestEntity(entity);
+    call(put);
+    if ("OK".equals(checkXPath(xPathStatus)))
+      return;
+    String error = checkXPath(xPathException);
+    setResult(Result.ERROR, error);
+    System.err.println(getResponse());
+  }
 
 }

Modified: 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=1158630&r1=1158629&r2=1158630&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerParam.java (original)
+++ incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerParam.java Wed Aug 17 11:13:29 2011
@@ -7,66 +7,65 @@ import org.apache.manifoldcf.agents.outp
 
 public class OpenSearchServerParam extends HashMap<ParameterEnum, String> {
 
-	/**
-	 * Parameters constants
-	 */
-	public enum ParameterEnum {
-		SERVERLOCATION("http://localhost:8080/"),
-
-		INDEXNAME("index"),
-
-		USERNAME(""),
-
-		APIKEY(""),
-
-		FIELDLIST(""),
-
-		MAXFILESIZE("16777216"),
-
-		MIMETYPES(
-				"application/msword\n"
-						+ "application/vnd.ms-excel\n"
-						+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document\n"
-						+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\n"
-						+ "text/html\n"
-						+ "application/pdf\n"
-						+ "application/vnd.ms-powerpoint\n"
-						+ "application/vnd.openxmlformats-officedocument.presentationml.presentation\n"
-						+ "application/vnd.oasis.opendocument.text\n"
-						+ "application/vnd.oasis.opendocument.spreadsheet\n"
-						+ "application/vnd.oasis.opendocument.formula\n"
-						+ "application/rtf\n" + "text/plain\n" + "audio/mpeg\n"
-						+ "audio/x-wav\n" + "audio/ogg\n" + "audio/flac\n"
-						+ "application/x-bittorrent"),
-
-		EXTENSIONS("doc\n" + "docx\n" + "xls\n" + "xlsx\n" + "ppt\n" + "pptx\n"
-				+ "html\n" + "pdf\n" + "odt\n" + "ods\n" + "rtf\n" + "txt\n"
-				+ "mp3\n" + "mp4\n" + "wav\n" + "ogg\n" + "flac\n" + "torrent");
-
-		final protected String defaultValue;
-
-		private ParameterEnum(String defaultValue) {
-			this.defaultValue = defaultValue;
-		}
-	}
-
-	private static final long serialVersionUID = -1593234685772720029L;
-
-	protected OpenSearchServerParam(ParameterEnum[] params) {
-		super(params.length);
-	}
-
-	/**
-	 * Replace the variables ${PARAMNAME} with the value contained in the set.
-	 * 
-	 * @param text
-	 * @return
-	 */
-	final public String replace(String text) {
-		for (Map.Entry<ParameterEnum, String> entry : this.entrySet())
-			text = text.replace("${" + entry.getKey().name() + "}",
-					entry.getValue());
-		return text;
-	}
+  /**
+   * Parameters constants
+   */
+  public enum ParameterEnum {
+    SERVERLOCATION("http://localhost:8080/"),
+
+    INDEXNAME("index"),
+
+    USERNAME(""),
+
+    APIKEY(""),
+
+    FIELDLIST(""),
+
+    MAXFILESIZE("16777216"),
+
+    MIMETYPES(
+        "application/msword\n"
+            + "application/vnd.ms-excel\n"
+            + "application/vnd.openxmlformats-officedocument.wordprocessingml.document\n"
+            + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\n"
+            + "text/html\n"
+            + "application/pdf\n"
+            + "application/vnd.ms-powerpoint\n"
+            + "application/vnd.openxmlformats-officedocument.presentationml.presentation\n"
+            + "application/vnd.oasis.opendocument.text\n"
+            + "application/vnd.oasis.opendocument.spreadsheet\n"
+            + "application/vnd.oasis.opendocument.formula\n"
+            + "application/rtf\n" + "text/plain\n" + "audio/mpeg\n"
+            + "audio/x-wav\n" + "audio/ogg\n" + "audio/flac\n"
+            + "application/x-bittorrent"),
+
+    EXTENSIONS("doc\n" + "docx\n" + "xls\n" + "xlsx\n" + "ppt\n" + "pptx\n"
+        + "html\n" + "pdf\n" + "odt\n" + "ods\n" + "rtf\n" + "txt\n" + "mp3\n"
+        + "mp4\n" + "wav\n" + "ogg\n" + "flac\n" + "torrent");
+
+    final protected String defaultValue;
+
+    private ParameterEnum(String defaultValue) {
+      this.defaultValue = defaultValue;
+    }
+  }
+
+  private static final long serialVersionUID = -1593234685772720029L;
+
+  protected OpenSearchServerParam(ParameterEnum[] params) {
+    super(params.length);
+  }
+
+  /**
+   * Replace the variables ${PARAMNAME} with the value contained in the set.
+   * 
+   * @param text
+   * @return
+   */
+  final public String replace(String text) {
+    for (Map.Entry<ParameterEnum, String> entry : this.entrySet())
+      text = text.replace("${" + entry.getKey().name() + "}", entry.getValue());
+    return text;
+  }
 
 }

Modified: 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=1158630&r1=1158629&r2=1158630&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerSchema.java (original)
+++ incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerSchema.java Wed Aug 17 11:13:29 2011
@@ -5,17 +5,17 @@ import org.apache.manifoldcf.core.interf
 
 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");
-	}
+  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");
+  }
 }

Modified: 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=1158630&r1=1158629&r2=1158630&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerSpecs.java (original)
+++ incubator/lcf/branches/CONNECTORS-224/connectors/opensearchserver/connector/src/main/java/org/apache/manifoldcf/agents/output/opensearchserver/OpenSearchServerSpecs.java Wed Aug 17 11:13:29 2011
@@ -15,123 +15,123 @@ import org.json.JSONObject;
 
 public class OpenSearchServerSpecs extends OpenSearchServerParam {
 
-	/**
+  /**
 	 * 
 	 */
-	private static final long serialVersionUID = 1859653440572662025L;
+  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);
-	}
+  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);
+  }
 }