manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1628999 [1/2] - in /manifoldcf/branches/CONNECTORS-1037/connectors: ./ alfresco-webscript/ alfresco-webscript/connector/ alfresco-webscript/connector/src/ alfresco-webscript/connector/src/main/ alfresco-webscript/connector/src/main/java/ a...
Date Thu, 02 Oct 2014 15:33:57 GMT
Author: kwright
Date: Thu Oct  2 15:33:55 2014
New Revision: 1628999

URL: http://svn.apache.org/r1628999
Log:
Import contribution of alfresco-webscript connector

Added:
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/build.xml
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/java/
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/java/org/
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/java/org/apache/
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/java/org/apache/manifoldcf/
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/java/org/apache/manifoldcf/authorities/
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/java/org/apache/manifoldcf/authorities/alfresco/
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/java/org/apache/manifoldcf/authorities/alfresco/AlfrescoAuthorityConnector.java
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/java/org/apache/manifoldcf/authorities/alfresco/ConfigurationHandler.java
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/java/org/apache/manifoldcf/authorities/alfresco/Messages.java
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/java/org/apache/manifoldcf/crawler/
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/webscript/
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/webscript/AlfrescoConnector.java
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/webscript/ConfigurationHandler.java
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/webscript/Messages.java
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/native2ascii/
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/native2ascii/org/
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/native2ascii/org/apache/
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/native2ascii/org/apache/manifoldcf/
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/native2ascii/org/apache/manifoldcf/authorities/
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/native2ascii/org/apache/manifoldcf/authorities/alfresco/
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/native2ascii/org/apache/manifoldcf/authorities/alfresco/common_en.properties
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/native2ascii/org/apache/manifoldcf/authorities/alfresco/common_en_US.properties
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/connectors/
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/connectors/alfresco/
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/connectors/alfresco/webscript/
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/connectors/alfresco/webscript/common_en.properties
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/connectors/alfresco/webscript/common_en_US.properties
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/resources/
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/resources/org/
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/resources/org/apache/
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/resources/org/apache/manifoldcf/
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/resources/org/apache/manifoldcf/authorities/
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/resources/org/apache/manifoldcf/authorities/alfresco/
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/resources/org/apache/manifoldcf/authorities/alfresco/editConfiguration.js
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/resources/org/apache/manifoldcf/authorities/alfresco/editConfiguration_Server.html
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/resources/org/apache/manifoldcf/authorities/alfresco/viewConfiguration.html
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/resources/org/apache/manifoldcf/crawler/
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/alfresco/
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/alfresco/webscript/
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/alfresco/webscript/editConfiguration.js
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/alfresco/webscript/editConfiguration_Server.html
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/alfresco/webscript/viewConfiguration.html
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/test/
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/test/java/
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/test/java/org/
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/test/java/org/apache/
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/test/java/org/apache/manifoldcf/
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/test/java/org/apache/manifoldcf/crawler/
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/alfresco/
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/alfresco/webscript/
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/alfresco/webscript/tests/
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/alfresco/webscript/tests/AlfrescoAuthorityConnectorTest.java
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/alfresco/webscript/tests/AlfrescoConnectorTest.java
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/test/resources/
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/test/resources/authorities.sample.json
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/test/resources/metadata.sample.json
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/test/resources/multi.authorities.sample.json
    manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/pom.xml
Modified:
    manifoldcf/branches/CONNECTORS-1037/connectors/pom.xml

Added: manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/build.xml
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/build.xml?rev=1628999&view=auto
==============================================================================
--- manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/build.xml (added)
+++ manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/build.xml Thu Oct  2 15:33:55 2014
@@ -0,0 +1,90 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<project name="alfresco-webscript" default="all">
+
+    <import file="../connector-build.xml"/>
+
+    <target name="calculate-testcode-condition">
+        <available file="test-materials-proprietary/alfresco.war" property="alfrescoTestcodeStatus"/>
+        <condition property="tests-present">
+            <isset property="alfrescoTestcodeStatus"/>
+        </condition>
+    </target>
+
+    <target name="pretest-warn" depends="calculate-testcode-condition" unless="tests-present">
+        <echo message="Alfresco Connector integration tests cannot be be performed without alfresco.war"/>
+    </target>
+
+    <path id="connector-classpath">
+        <path refid="mcf-connector-build.connector-classpath"/>
+        <fileset dir="lib-proprietary" includes="*.jar"/>
+        <fileset dir="../../lib">
+            <include name="axis*.jar"/>	
+            <include name="saaj*.jar"/>	
+            <include name="commons-discovery*.jar"/>
+            <include name="jaxrpc*.jar"/>
+            <include name="mail*.jar"/>
+            <include name="opensaml*.jar"/>
+            <include name="wsdl4j*.jar"/>
+            <include name="wss4j*.jar"/>
+            <!--include name="xalan*.jar"/-->
+            <!--include name="xercesImpl*.jar"/-->
+            <include name="xmlsec*.jar"/>
+        </fileset>
+    </path>
+
+    <path id="connector-test-classpath">
+        <path refid="mcf-connector-build.connector-test-classpath"/>
+        <fileset file="../../lib/h2*.jar"/>
+    </path>
+    
+    <target name="lib" depends="mcf-connector-build.lib,precompile-check" if="canBuild">
+        <mkdir dir="dist/lib"/>
+        <copy todir="dist/lib">
+            <fileset dir="../../lib">
+                <include name="axis*.jar"/>	
+                <include name="saaj*.jar"/>	
+                <include name="commons-discovery*.jar"/>
+                <include name="jaxrpc*.jar"/>
+                <include name="mail*.jar"/>
+                <include name="opensaml*.jar"/>
+                <include name="wsdl4j*.jar"/>
+                <include name="wss4j*.jar"/>
+                <!--include name="xalan*.jar"/-->
+                <!--include name="xercesImpl*.jar"/-->
+                <include name="xmlsec*.jar"/>
+            </fileset>
+        </copy>
+    </target>
+
+    <target name="build-test-materials" depends="pretest-check" if="canTest">
+        <mkdir dir="build/alfresco-war"/>
+        <copy todir="build/alfresco-war">
+            <fileset dir="test-materials-proprietary">
+                <include name="alfresco*.war"/>
+            </fileset>
+        </copy>
+    </target>
+
+    <target name="download-cleanup">
+        <delete>
+            <fileset dir="lib-proprietary" excludes="README*.txt"/>
+        </delete>
+    </target>
+
+</project>

Added: manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/java/org/apache/manifoldcf/authorities/alfresco/AlfrescoAuthorityConnector.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/java/org/apache/manifoldcf/authorities/alfresco/AlfrescoAuthorityConnector.java?rev=1628999&view=auto
==============================================================================
--- manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/java/org/apache/manifoldcf/authorities/alfresco/AlfrescoAuthorityConnector.java (added)
+++ manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/java/org/apache/manifoldcf/authorities/alfresco/AlfrescoAuthorityConnector.java Thu Oct  2 15:33:55 2014
@@ -0,0 +1,162 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.manifoldcf.authorities.alfresco;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Locale;
+
+import org.alfresco.consulting.indexer.client.AlfrescoClient;
+import org.alfresco.consulting.indexer.client.AlfrescoDownException;
+import org.alfresco.consulting.indexer.client.AlfrescoUser;
+import org.alfresco.consulting.indexer.client.WebScriptsAlfrescoClient;
+import org.apache.manifoldcf.authorities.authorities.BaseAuthorityConnector;
+import org.apache.manifoldcf.authorities.interfaces.AuthorizationResponse;
+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;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class AlfrescoAuthorityConnector extends BaseAuthorityConnector {
+  private static final Logger logger = LoggerFactory.getLogger(AlfrescoAuthorityConnector.class);
+  
+  
+  private AlfrescoClient alfrescoClient;
+  
+  private static final AuthorizationResponse denied = new AuthorizationResponse(
+          new String[] { "DEAD_AUTHORITY" }, AuthorizationResponse.RESPONSE_UNREACHABLE);
+  
+  public void setClient(AlfrescoClient client) {
+    alfrescoClient = client;
+  }
+
+  @Override
+  public void connect(ConfigParams config) {
+    super.connect(config);
+
+    String protocol = getConfig(config, "protocol", "http");
+    String hostname = getConfig(config, "hostname", "localhost");
+    String endpoint = getConfig(config, "endpoint", "/alfresco/service");
+    String username = getConfig(config, "username", null);
+    String password = getConfig(config, "password", null);
+
+    alfrescoClient = new WebScriptsAlfrescoClient(protocol, hostname, endpoint,
+            null, null, username, password);
+  }
+
+  private static String getConfig(ConfigParams config,
+                                  String parameter,
+                                  String defaultValue) {
+    final String protocol = config.getParameter(parameter);
+    if (protocol == null) {
+      return defaultValue;
+    }
+    return protocol;
+  }
+
+  /*
+   * (non-Javadoc)
+   * @see org.apache.manifoldcf.core.connector.BaseConnector#check()
+   */
+  @Override
+  public String check() throws ManifoldCFException {
+	  try{
+		  alfrescoClient.fetchUserAuthorities("admin");
+		  return "Connection Working!";
+	  }catch(AlfrescoDownException e){
+		  logger.error(e.getMessage());
+		  return "Connection not Working!. Check the configuration";
+	  }
+  }
+
+  /*
+   * (non-Javadoc)
+   * @see org.apache.manifoldcf.core.connector.BaseConnector#disconnect()
+   */
+  @Override
+  public void disconnect() throws ManifoldCFException {
+    super.disconnect();
+  }
+  
+  /*
+   * (non-Javadoc)
+   * @see org.apache.manifoldcf.authorities.authorities.BaseAuthorityConnector#getDefaultAuthorizationResponse(java.lang.String)
+   */
+  @Override
+  public AuthorizationResponse getDefaultAuthorizationResponse(String userName)
+  {
+      return denied;
+  }
+  
+  /*
+   * (non-Javadoc)
+   * @see org.apache.manifoldcf.authorities.authorities.BaseAuthorityConnector#getAuthorizationResponse(java.lang.String)
+   */
+  @Override
+  public AuthorizationResponse getAuthorizationResponse(String userName)
+    throws ManifoldCFException {
+	  try{
+		  AlfrescoUser permissions = alfrescoClient.fetchUserAuthorities(userName);
+		  if(permissions.getUsername() == null 
+				  || permissions.getUsername().isEmpty()
+				  || permissions.getAuthorities().isEmpty())
+			  return new AuthorizationResponse(null, AuthorizationResponse.RESPONSE_USERNOTFOUND);
+		  else
+			  return new AuthorizationResponse(
+					  permissions.getAuthorities().toArray(new String[permissions.getAuthorities().size()]), 
+					  AuthorizationResponse.RESPONSE_OK);
+	  }catch(AlfrescoDownException e){
+		  return new AuthorizationResponse(null, AuthorizationResponse.RESPONSE_UNREACHABLE);
+	  }
+  }
+
+  @Override
+  public void outputConfigurationHeader(IThreadContext threadContext,
+                                        IHTTPOutput out, Locale locale, ConfigParams parameters,
+                                        List<String> tabsArray) throws ManifoldCFException, IOException {
+    ConfigurationHandler.outputConfigurationHeader(threadContext, out, locale,
+            parameters, tabsArray);
+  }
+
+  @Override
+  public void outputConfigurationBody(IThreadContext threadContext,
+                                      IHTTPOutput out, Locale locale, ConfigParams parameters, String tabName)
+          throws ManifoldCFException, IOException {
+    ConfigurationHandler.outputConfigurationBody(threadContext, out, locale,
+            parameters, tabName);
+  }
+
+  @Override
+  public String processConfigurationPost(IThreadContext threadContext,
+                                         IPostParameters variableContext, Locale locale, ConfigParams parameters)
+          throws ManifoldCFException {
+    return ConfigurationHandler.processConfigurationPost(threadContext,
+            variableContext, locale, parameters);
+  }
+
+  @Override
+  public void viewConfiguration(IThreadContext threadContext, IHTTPOutput out,
+                                Locale locale, ConfigParams parameters) throws ManifoldCFException,
+          IOException {
+    ConfigurationHandler.viewConfiguration(threadContext, out, locale,
+            parameters);
+  }  
+}

Added: manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/java/org/apache/manifoldcf/authorities/alfresco/ConfigurationHandler.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/java/org/apache/manifoldcf/authorities/alfresco/ConfigurationHandler.java?rev=1628999&view=auto
==============================================================================
--- manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/java/org/apache/manifoldcf/authorities/alfresco/ConfigurationHandler.java (added)
+++ manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/java/org/apache/manifoldcf/authorities/alfresco/ConfigurationHandler.java Thu Oct  2 15:33:55 2014
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.manifoldcf.authorities.alfresco;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringWriter;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import org.apache.commons.io.IOUtils;
+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;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.VelocityEngine;
+
+public class ConfigurationHandler {
+  private static final String PARAM_PROTOCOL = "protocol";
+  private static final String PARAM_HOSTNAME = "hostname";
+  private static final String PARAM_ENDPOINT = "endpoint";
+  private static final String PARAM_USERNAME = "username";
+  private static final String PARAM_PASSWORD = "password";
+  
+  private static final String EDIT_CONFIG_HEADER = "editConfiguration.js";
+  private static final String EDIT_CONFIG_SERVER = "editConfiguration_Server.html";
+  private static final String VIEW_CONFIG = "viewConfiguration.html";
+
+  private static final Map<String, String> DEFAULT_CONFIGURATION_PARAMETERS = new HashMap<String, String>();
+  static {
+    DEFAULT_CONFIGURATION_PARAMETERS.put(PARAM_PROTOCOL, "http");
+    DEFAULT_CONFIGURATION_PARAMETERS.put(PARAM_HOSTNAME, "localhost");
+    DEFAULT_CONFIGURATION_PARAMETERS.put(PARAM_ENDPOINT, "/alfresco/service");
+     DEFAULT_CONFIGURATION_PARAMETERS.put(PARAM_USERNAME, "");
+    DEFAULT_CONFIGURATION_PARAMETERS.put(PARAM_PASSWORD, "");
+  }
+
+  private ConfigurationHandler() {
+  }
+
+  public static void outputConfigurationHeader(IThreadContext threadContext,
+      IHTTPOutput out, Locale locale, ConfigParams parameters,
+      List<String> tabsArray) throws ManifoldCFException, IOException {
+    tabsArray.add("Server");
+    InputStream inputStream = ConfigurationHandler.class.getResourceAsStream("/org/apache/manifoldcf/authorities/alfresco/" + EDIT_CONFIG_HEADER);
+    StringWriter writer = new StringWriter();
+    IOUtils.copy(inputStream, writer, "UTF-8");
+    inputStream.close();
+    out.print(writer.toString());
+  }
+
+  private static void fillInParameters(Map<String, String> paramMap,
+      ConfigParams parameters) {
+    for (Map.Entry<String, String> parameter : DEFAULT_CONFIGURATION_PARAMETERS
+        .entrySet()) {
+      String paramValue = parameters.getParameter(parameter.getKey());
+      if (paramValue == null) {
+        paramValue = parameter.getValue();
+      }
+      paramMap.put(parameter.getKey(), paramValue);
+    }
+  }
+
+  public static void outputConfigurationBody(IThreadContext threadContext,
+      IHTTPOutput out, Locale locale, ConfigParams parameters, String tabName)
+      throws ManifoldCFException, IOException {
+    Map<String, String> paramMap = new HashMap<String, String>();
+    paramMap.put("tabName", tabName);
+    fillInParameters(paramMap, parameters);
+    VelocityEngine velocityEngine = Messages.createVelocityEngine(ConfigurationHandler.class);
+    VelocityContext context = createVelocityContext(paramMap);
+    StringWriter w = new StringWriter();
+    velocityEngine.mergeTemplate(EDIT_CONFIG_SERVER, "UTF-8", context, w);
+    out.print(w.toString());
+  }
+
+  private static VelocityContext createVelocityContext(Map<String, String> paramMap) {
+    VelocityContext context = new VelocityContext();
+    for (Map.Entry<String, String> entry : paramMap.entrySet()) {
+      context.put(entry.getKey(), entry.getValue());
+    }
+    return context;
+  }
+
+  public static String processConfigurationPost(IThreadContext threadContext,
+      IPostParameters variableContext, Locale locale, ConfigParams parameters)
+      throws ManifoldCFException {
+    for (String paramName : DEFAULT_CONFIGURATION_PARAMETERS.keySet()) {
+      String paramValue = variableContext.getParameter(paramName);
+      if (paramValue != null) {
+        parameters.setParameter(paramName, paramValue);
+      }
+    }
+    return null;
+  }
+
+  public static void viewConfiguration(IThreadContext threadContext,
+      IHTTPOutput out, Locale locale, ConfigParams parameters)
+      throws ManifoldCFException, IOException {
+    Map<String, String> paramMap = new HashMap<String, String>();
+    fillInParameters(paramMap, parameters);
+    VelocityEngine velocityEngine = Messages.createVelocityEngine(ConfigurationHandler.class);
+    VelocityContext context = createVelocityContext(paramMap);
+    StringWriter w = new StringWriter();
+    velocityEngine.mergeTemplate(VIEW_CONFIG, "UTF-8", context, w);
+    out.print(w.toString());
+  }
+}

Added: manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/java/org/apache/manifoldcf/authorities/alfresco/Messages.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/java/org/apache/manifoldcf/authorities/alfresco/Messages.java?rev=1628999&view=auto
==============================================================================
--- manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/java/org/apache/manifoldcf/authorities/alfresco/Messages.java (added)
+++ manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/java/org/apache/manifoldcf/authorities/alfresco/Messages.java Thu Oct  2 15:33:55 2014
@@ -0,0 +1,138 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.manifoldcf.authorities.alfresco;
+
+import java.util.Locale;
+import java.util.Map;
+import org.apache.manifoldcf.core.interfaces.ManifoldCFException;
+import org.apache.manifoldcf.core.interfaces.IHTTPOutput;
+
+public class Messages extends org.apache.manifoldcf.ui.i18n.Messages
+{
+    public static final String DEFAULT_BUNDLE_NAME="org.apache.manifoldcf.authorities.afresco.common";
+    public static final String DEFAULT_PATH_NAME="org.apache.manifoldcf.authorities.afresco";
+
+    /** Constructor - do no instantiate
+     */
+    protected Messages()
+    {
+    }
+
+    public static String getString(Locale locale, String messageKey)
+    {
+        return getString(DEFAULT_BUNDLE_NAME, locale, messageKey, null);
+    }
+
+    public static String getAttributeString(Locale locale, String messageKey)
+    {
+        return getAttributeString(DEFAULT_BUNDLE_NAME, locale, messageKey, null);
+    }
+
+    public static String getBodyString(Locale locale, String messageKey)
+    {
+        return getBodyString(DEFAULT_BUNDLE_NAME, locale, messageKey, null);
+    }
+
+    public static String getAttributeJavascriptString(Locale locale, String messageKey)
+    {
+        return getAttributeJavascriptString(DEFAULT_BUNDLE_NAME, locale, messageKey, null);
+    }
+
+    public static String getBodyJavascriptString(Locale locale, String messageKey)
+    {
+        return getBodyJavascriptString(DEFAULT_BUNDLE_NAME, locale, messageKey, null);
+    }
+
+    public static String getString(Locale locale, String messageKey, Object[] args)
+    {
+        return getString(DEFAULT_BUNDLE_NAME, locale, messageKey, args);
+    }
+
+    public static String getAttributeString(Locale locale, String messageKey, Object[] args)
+    {
+        return getAttributeString(DEFAULT_BUNDLE_NAME, locale, messageKey, args);
+    }
+
+    public static String getBodyString(Locale locale, String messageKey, Object[] args)
+    {
+        return getBodyString(DEFAULT_BUNDLE_NAME, locale, messageKey, args);
+    }
+
+    public static String getAttributeJavascriptString(Locale locale, String messageKey, Object[] args)
+    {
+        return getAttributeJavascriptString(DEFAULT_BUNDLE_NAME, locale, messageKey, args);
+    }
+
+    public static String getBodyJavascriptString(Locale locale, String messageKey, Object[] args)
+    {
+        return getBodyJavascriptString(DEFAULT_BUNDLE_NAME, locale, messageKey, args);
+    }
+
+    // More general methods which allow bundlenames and class loaders to be specified.
+
+    public static String getString(String bundleName, Locale locale, String messageKey, Object[] args)
+    {
+        return getString(Messages.class, bundleName, locale, messageKey, args);
+    }
+
+    public static String getAttributeString(String bundleName, Locale locale, String messageKey, Object[] args)
+    {
+        return getAttributeString(Messages.class, bundleName, locale, messageKey, args);
+    }
+
+    public static String getBodyString(String bundleName, Locale locale, String messageKey, Object[] args)
+    {
+        return getBodyString(Messages.class, bundleName, locale, messageKey, args);
+    }
+
+    public static String getAttributeJavascriptString(String bundleName, Locale locale, String messageKey, Object[] args)
+    {
+        return getAttributeJavascriptString(Messages.class, bundleName, locale, messageKey, args);
+    }
+
+    public static String getBodyJavascriptString(String bundleName, Locale locale, String messageKey, Object[] args)
+    {
+        return getBodyJavascriptString(Messages.class, bundleName, locale, messageKey, args);
+    }
+
+    // Resource output
+
+    public static void outputResource(IHTTPOutput output, Locale locale, String resourceKey,
+                                      Map<String,String> substitutionParameters, boolean mapToUpperCase)
+            throws ManifoldCFException
+    {
+        outputResource(output,Messages.class,DEFAULT_PATH_NAME,locale,resourceKey,
+                substitutionParameters,mapToUpperCase);
+    }
+
+    public static void outputResourceWithVelocity(IHTTPOutput output, Locale locale, String resourceKey,
+                                                  Map<String,String> substitutionParameters, boolean mapToUpperCase)
+            throws ManifoldCFException
+    {
+        outputResourceWithVelocity(output,Messages.class,DEFAULT_BUNDLE_NAME,DEFAULT_PATH_NAME,locale,resourceKey,
+                substitutionParameters,mapToUpperCase);
+    }
+
+    public static void outputResourceWithVelocity(IHTTPOutput output, Locale locale, String resourceKey,
+                                                  Map<String,Object> contextObjects)
+            throws ManifoldCFException
+    {
+        outputResourceWithVelocity(output,Messages.class,DEFAULT_BUNDLE_NAME,DEFAULT_PATH_NAME,locale,resourceKey,
+                contextObjects);
+    }
+
+}

Added: manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/webscript/AlfrescoConnector.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/webscript/AlfrescoConnector.java?rev=1628999&view=auto
==============================================================================
--- manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/webscript/AlfrescoConnector.java (added)
+++ manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/webscript/AlfrescoConnector.java Thu Oct  2 15:33:55 2014
@@ -0,0 +1,305 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.manifoldcf.crawler.connectors.alfresco.webscript;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+import org.alfresco.consulting.indexer.client.AlfrescoClient;
+import org.alfresco.consulting.indexer.client.AlfrescoDownException;
+import org.alfresco.consulting.indexer.client.AlfrescoResponse;
+import org.alfresco.consulting.indexer.client.WebScriptsAlfrescoClient;
+import org.apache.manifoldcf.agents.interfaces.RepositoryDocument;
+import org.apache.manifoldcf.agents.interfaces.ServiceInterruption;
+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;
+import org.apache.manifoldcf.core.interfaces.Specification;
+import org.apache.manifoldcf.crawler.connectors.BaseRepositoryConnector;
+import org.apache.manifoldcf.crawler.interfaces.IExistingVersions;
+import org.apache.manifoldcf.crawler.interfaces.IProcessActivity;
+import org.apache.manifoldcf.crawler.interfaces.ISeedingActivity;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class AlfrescoConnector extends BaseRepositoryConnector {
+  private static final Logger logger = LoggerFactory.getLogger(AlfrescoConnector.class);
+  private static final String ACTIVITY_FETCH = "fetch document";
+  private static final String[] activitiesList = new String[]{ACTIVITY_FETCH};
+  private AlfrescoClient alfrescoClient;
+  private Boolean enableDocumentProcessing = Boolean.TRUE;
+  
+  private static final String CONTENT_URL_PROPERTY = "contentUrlPath";
+  private static final String AUTHORITIES_PROPERTY = "readableAuthorities";
+  
+  // Static Fields
+  private static final String FIELD_UUID = "uuid";
+  private static final String FIELD_NODEREF = "nodeRef";
+  private static final String FIELD_TYPE = "type";
+  private static final String FIELD_NAME = "name";
+
+  @Override
+  public int getConnectorModel() {
+    return MODEL_ADD_CHANGE_DELETE; // We return only incremental documents.
+  }
+
+  public void setClient(AlfrescoClient client) {
+    alfrescoClient = client;
+  }
+
+  @Override
+  public void connect(ConfigParams config) {
+    super.connect(config);
+
+    String protocol = getConfig(config, "protocol", "http");
+    String hostname = getConfig(config, "hostname", "localhost");
+    String endpoint = getConfig(config, "endpoint", "/alfresco/service");
+    String storeProtocol = getConfig(config, "storeprotocol", "workspace");
+    String storeId = getConfig(config, "storeid", "SpacesStore");
+    String username = getConfig(config, "username", null);
+    String password = getConfig(config, "password", null);
+    this.enableDocumentProcessing = new Boolean(getConfig(config, "enabledocumentprocessing", "false"));
+
+    alfrescoClient = new WebScriptsAlfrescoClient(protocol, hostname, endpoint,
+            storeProtocol, storeId, username, password);
+  }
+
+  private static String getConfig(ConfigParams config,
+                                  String parameter,
+                                  String defaultValue) {
+    final String protocol = config.getParameter(parameter);
+    if (protocol == null) {
+      return defaultValue;
+    }
+    return protocol;
+  }
+
+  @Override
+  public String check() throws ManifoldCFException {
+    return super.check();
+  }
+
+  @Override
+  public void disconnect() throws ManifoldCFException {
+    super.disconnect();
+  }
+
+  @Override
+  public String[] getActivitiesList() {
+    return activitiesList;
+  }
+
+  @Override
+  public int getMaxDocumentRequest() {
+    return 20;
+  }
+
+  @Override
+  public String addSeedDocuments(ISeedingActivity activities, Specification spec,
+                                              String lastSeedVersion, long seedTime, int jobMode) throws ManifoldCFException, ServiceInterruption {
+    try {
+      long lastTransactionId = 0;
+      long lastAclChangesetId = 0;
+      
+      if(lastSeedVersion != null && !lastSeedVersion.isEmpty()){
+    	  StringTokenizer tokenizer = new StringTokenizer(lastSeedVersion,"|");
+
+    	  if (tokenizer.countTokens() == 2) {
+    		  lastTransactionId = new Long(tokenizer.nextToken());
+    		  lastAclChangesetId = new Long(tokenizer.nextToken());
+    	  }
+      }
+      
+      logger.info("Starting from transaction id: {} and acl changeset id: {}", lastTransactionId, lastAclChangesetId);
+      
+      long transactionIdsProcessed;
+      long aclChangesetsProcessed;
+      do {
+        final AlfrescoResponse response = alfrescoClient.
+        		fetchNodes(lastTransactionId, 
+        				lastAclChangesetId,
+        				ConfigurationHandler.getFilters(spec));
+        int count = 0;
+        for (Map<String, Object> doc : response.getDocuments()) {
+//          String json = gson.toJson(doc);
+//          activities.addSeedDocument(json);
+          String uuid = doc.get("uuid").toString();
+          activities.addSeedDocument(uuid);
+          count++;
+        }
+        logger.info("Fetched and added {} seed documents", count);
+
+        transactionIdsProcessed = response.getLastTransactionId() - lastTransactionId;
+        aclChangesetsProcessed = response.getLastAclChangesetId() - lastAclChangesetId;
+
+        lastTransactionId = response.getLastTransactionId();
+        lastAclChangesetId = response.getLastAclChangesetId();
+
+        logger.info("transaction_id={}, acl_changeset_id={}", lastTransactionId, lastAclChangesetId);
+      } while (transactionIdsProcessed > 0 || aclChangesetsProcessed > 0);
+
+      logger.info("Recording {} as last transaction id and {} as last changeset id", lastTransactionId, lastAclChangesetId);
+      return lastTransactionId + "|" + lastAclChangesetId;
+    } catch (AlfrescoDownException e) {
+      throw new ManifoldCFException(e);
+    }
+  }
+
+@Override
+public void processDocuments(String[] documentIdentifiers, IExistingVersions statuses, Specification spec,
+                             IProcessActivity activities, int jobMode, boolean usesDefaultAuthority)
+        throws ManifoldCFException, ServiceInterruption {
+
+    for (String doc : documentIdentifiers) {
+      String nextVersion = statuses.getIndexedVersionString(doc);	
+    	
+      // Calling again Alfresco API because Document's actions are lost from seeding method
+      AlfrescoResponse response = alfrescoClient.fetchNode(doc);
+      if(response.getDocumentList().isEmpty()){ // Not found seeded document. Could reflect an error in Alfresco
+    	  logger.error("Invalid Seeded Document from Alfresco with ID {}", doc);
+    	  activities.noDocument(doc, nextVersion);
+    	  continue;
+      }
+      Map<String, Object> map = response.getDocumentList().get(0); // Should be only one
+      RepositoryDocument rd = new RepositoryDocument();
+      String uuid = map.containsKey(FIELD_UUID) ? map.get(FIELD_UUID).toString() : doc;
+      String nodeRef = map.containsKey(FIELD_NODEREF) ? map.get(FIELD_NODEREF).toString() : "";
+      rd.addField(FIELD_NODEREF, nodeRef);
+      String type = map.containsKey(FIELD_TYPE) ? map.get(FIELD_TYPE).toString() : "";
+      rd.addField(FIELD_TYPE, type);
+      String name =  map.containsKey(FIELD_NAME) ? map.get(FIELD_NAME).toString() : "";
+      rd.setFileName(name);
+
+      if ((Boolean) map.get("deleted")) {
+        activities.deleteDocument(uuid);
+      } else {
+        if (this.enableDocumentProcessing) {
+          try{
+          	processMetaData(rd,uuid);
+          }catch(AlfrescoDownException e){
+        	  logger.error("Invalid Document from Alfresco with ID {}", uuid, e);
+        	  activities.noDocument(doc, nextVersion);
+        	  continue; // No Metadata, No Content....skip document
+          }
+        }
+        try {
+        	if(rd.getBinaryStream() == null){
+        		byte[] empty = new byte[0];
+        		rd.setBinary(new ByteArrayInputStream(empty), 0L);
+        	}
+        	logger.info("Ingesting with id: {}, URI {} and rd {}", uuid, nodeRef, rd.getFileName());
+			activities.ingestDocumentWithException(uuid, "", uuid, rd);
+		} catch (IOException e) {
+			throw new ManifoldCFException(
+					"Error Ingesting Document with ID " + String.valueOf(uuid), e);
+		}
+      }
+    }
+  }
+  
+  private void processMetaData(RepositoryDocument rd,
+		  String uuid) throws ManifoldCFException, AlfrescoDownException {
+    Map<String,Object> properties = alfrescoClient.fetchMetadata(uuid);
+    for(String property : properties.keySet()) {
+      Object propertyValue = properties.get(property);
+      rd.addField(property,propertyValue.toString());
+    }
+    
+    // Document Binary Content
+    String contentUrlPath = (String) properties.get(CONTENT_URL_PROPERTY);
+    if(contentUrlPath != null && !contentUrlPath.isEmpty()){
+    	InputStream binaryContent = alfrescoClient.fetchContent(contentUrlPath);
+    	if(binaryContent != null) // Content-based Alfresco Document
+    		rd.setBinary(binaryContent, 0L);
+    }
+    
+    // Indexing Permissions
+    @SuppressWarnings("unchecked")
+	List<String> permissions = (List<String>) properties.remove(AUTHORITIES_PROPERTY);
+    if(permissions != null){
+    	rd.setSecurityACL(RepositoryDocument.SECURITY_TYPE_DOCUMENT,
+    		permissions.toArray(new String[permissions.size()]));
+    }
+  }
+
+  @Override
+  public void outputConfigurationHeader(IThreadContext threadContext,
+                                        IHTTPOutput out, Locale locale, ConfigParams parameters,
+                                        List<String> tabsArray) throws ManifoldCFException, IOException {
+    ConfigurationHandler.outputConfigurationHeader(threadContext, out, locale,
+            parameters, tabsArray);
+  }
+
+  @Override
+  public void outputConfigurationBody(IThreadContext threadContext,
+                                      IHTTPOutput out, Locale locale, ConfigParams parameters, String tabName)
+          throws ManifoldCFException, IOException {
+    ConfigurationHandler.outputConfigurationBody(threadContext, out, locale,
+            parameters, tabName);
+  }
+
+  @Override
+  public String processConfigurationPost(IThreadContext threadContext,
+                                         IPostParameters variableContext, Locale locale, ConfigParams parameters)
+          throws ManifoldCFException {
+    return ConfigurationHandler.processConfigurationPost(threadContext,
+            variableContext, locale, parameters);
+  }
+
+  @Override
+  public void viewConfiguration(IThreadContext threadContext, IHTTPOutput out,
+                                Locale locale, ConfigParams parameters) throws ManifoldCFException,
+          IOException {
+    ConfigurationHandler.viewConfiguration(threadContext, out, locale,
+            parameters);
+  }
+  
+  
+   @Override
+   public void outputSpecificationHeader(IHTTPOutput out, Locale locale, Specification os,
+     int connectionSequenceNumber, List<String> tabsArray)
+     throws ManifoldCFException, IOException{
+	   ConfigurationHandler.outputSpecificationHeader(out, locale, os, connectionSequenceNumber, tabsArray);
+   }
+   
+   @Override
+   public void outputSpecificationBody(IHTTPOutput out, Locale locale, Specification os,
+		    int connectionSequenceNumber, int actualSequenceNumber, String tabName) throws ManifoldCFException, IOException{
+	   ConfigurationHandler.outputSpecificationBody(out, locale, os, connectionSequenceNumber, actualSequenceNumber, tabName);
+   }
+   
+   @Override
+   public String processSpecificationPost(IPostParameters variableContext, Locale locale, Specification os,
+			  int connectionSequenceNumber) throws ManifoldCFException{
+	   return ConfigurationHandler.processSpecificationPost(variableContext, locale, os, connectionSequenceNumber);
+   }
+   
+   @Override
+   public void viewSpecification(IHTTPOutput out, Locale locale, Specification os,
+			  int connectionSequenceNumber) throws ManifoldCFException, IOException{
+	   ConfigurationHandler.viewSpecification(out, locale, os, connectionSequenceNumber);
+   }
+  
+}

Added: manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/webscript/ConfigurationHandler.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/webscript/ConfigurationHandler.java?rev=1628999&view=auto
==============================================================================
--- manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/webscript/ConfigurationHandler.java (added)
+++ manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/webscript/ConfigurationHandler.java Thu Oct  2 15:33:55 2014
@@ -0,0 +1,486 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.manifoldcf.crawler.connectors.alfresco.webscript;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringWriter;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import org.alfresco.consulting.indexer.client.AlfrescoFilters;
+import org.apache.commons.io.IOUtils;
+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;
+import org.apache.manifoldcf.core.interfaces.Specification;
+import org.apache.manifoldcf.core.interfaces.SpecificationNode;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.VelocityEngine;
+
+import com.google.common.collect.ImmutableMultimap;
+
+public class ConfigurationHandler {
+  private static final String PARAM_PROTOCOL = "protocol";
+  private static final String PARAM_HOSTNAME = "hostname";
+  private static final String PARAM_ENDPOINT = "endpoint";
+  private static final String PARAM_STORE_PROTOCOL = "storeprotocol";
+  private static final String PARAM_ENABLE_DOCUMENT_PROCESSING = "enabledocumentprocessing";
+  private static final String PARAM_STORE_ID = "storeid";
+  private static final String PARAM_USERNAME = "username";
+  private static final String PARAM_PASSWORD = "password";
+  
+  // Output Specification for Filtering
+  /** Node describing a Site */
+  public static final String NODE_SITE = "site";
+  /** Attribute describing a site name */
+  public static final String ATTRIBUTE_SITE = "site_name";
+  
+  /** Node describing a MimeType */
+  public static final String NODE_MIMETYPE = "mimetype";
+  /** Attribute describing a MimeType name */
+  public static final String ATTRIBUTE_MIMETYPE = "mimetype_name";
+  
+  /** Node describing an Aspect */
+  public static final String NODE_ASPECT = "aspect";
+  /** Attribute describing an aspect name */
+  public static final String ATTRIBUTE_ASPECT = "aspect_name";
+  
+  /** Node describing a Metadata */
+  public static final String NODE_METADATA = "metadata";
+  /** Attribute describing an aspect name */
+  public static final String ATTRIBUTE_METADATA_SOURCE = "metadata_source";
+  /** Attribute describing an aspect value */
+  public static final String ATTRIBUTE_METADATA_TARGET = "metadata_value";
+  
+  public static final ImmutableMultimap<String, String> SPECIFICATION_MAP =
+	        ImmutableMultimap.<String, String>builder().
+	        put(NODE_SITE, ATTRIBUTE_SITE).
+	        put(NODE_MIMETYPE, ATTRIBUTE_MIMETYPE).
+	        put(NODE_ASPECT, ATTRIBUTE_ASPECT).
+	        put(NODE_METADATA, ATTRIBUTE_METADATA_SOURCE).
+	        put(NODE_METADATA, ATTRIBUTE_METADATA_TARGET).build();
+
+  private static final String EDIT_CONFIG_HEADER = "editConfiguration.js";
+  private static final String EDIT_CONFIG_SERVER = "editConfiguration_Server.html";
+  private static final String VIEW_CONFIG = "viewConfiguration.html";
+
+  private static final Map<String, String> DEFAULT_CONFIGURATION_PARAMETERS = new HashMap<String, String>();
+  static {
+    DEFAULT_CONFIGURATION_PARAMETERS.put(PARAM_PROTOCOL, "http");
+    DEFAULT_CONFIGURATION_PARAMETERS.put(PARAM_HOSTNAME, "localhost");
+    DEFAULT_CONFIGURATION_PARAMETERS.put(PARAM_ENDPOINT, "/alfresco/service");
+    DEFAULT_CONFIGURATION_PARAMETERS.put(PARAM_STORE_PROTOCOL, "workspace");
+    DEFAULT_CONFIGURATION_PARAMETERS.put(PARAM_ENABLE_DOCUMENT_PROCESSING,"true");
+    DEFAULT_CONFIGURATION_PARAMETERS.put(PARAM_STORE_ID, "SpacesStore");
+    DEFAULT_CONFIGURATION_PARAMETERS.put(PARAM_USERNAME, "");
+    DEFAULT_CONFIGURATION_PARAMETERS.put(PARAM_PASSWORD, "");
+  }
+
+  private ConfigurationHandler() {
+  }
+
+  public static void outputConfigurationHeader(IThreadContext threadContext,
+      IHTTPOutput out, Locale locale, ConfigParams parameters,
+      List<String> tabsArray) throws ManifoldCFException, IOException {
+    tabsArray.add("Server");
+    InputStream inputStream = ConfigurationHandler.class.getResourceAsStream("/org/apache/manifoldcf/crawler/connectors/alfresco/webscript/" + EDIT_CONFIG_HEADER);
+    StringWriter writer = new StringWriter();
+    IOUtils.copy(inputStream, writer, "UTF-8");
+    inputStream.close();
+    out.print(writer.toString());
+  }
+
+  private static void fillInParameters(Map<String, String> paramMap,
+      ConfigParams parameters) {
+    for (Map.Entry<String, String> parameter : DEFAULT_CONFIGURATION_PARAMETERS
+        .entrySet()) {
+      String paramValue = parameters.getParameter(parameter.getKey());
+      if (paramValue == null) {
+        paramValue = parameter.getValue();
+      }
+      paramMap.put(parameter.getKey(), paramValue);
+    }
+  }
+
+  public static void outputConfigurationBody(IThreadContext threadContext,
+      IHTTPOutput out, Locale locale, ConfigParams parameters, String tabName)
+      throws ManifoldCFException, IOException {
+    Map<String, String> paramMap = new HashMap<String, String>();
+    paramMap.put("tabName", tabName);
+    fillInParameters(paramMap, parameters);
+    VelocityEngine velocityEngine = Messages.createVelocityEngine(ConfigurationHandler.class);
+    VelocityContext context = createVelocityContext(paramMap);
+    StringWriter w = new StringWriter();
+    velocityEngine.mergeTemplate(EDIT_CONFIG_SERVER, "UTF-8", context, w);
+    out.print(w.toString());
+  }
+
+  private static VelocityContext createVelocityContext(Map<String, String> paramMap) {
+    VelocityContext context = new VelocityContext();
+    for (Map.Entry<String, String> entry : paramMap.entrySet()) {
+      context.put(entry.getKey(), entry.getValue());
+    }
+    return context;
+  }
+
+  public static String processConfigurationPost(IThreadContext threadContext,
+      IPostParameters variableContext, Locale locale, ConfigParams parameters)
+      throws ManifoldCFException {
+    for (String paramName : DEFAULT_CONFIGURATION_PARAMETERS.keySet()) {
+      String paramValue = variableContext.getParameter(paramName);
+      if (paramValue != null) {
+        parameters.setParameter(paramName, paramValue);
+      }
+    }
+    return null;
+  }
+
+  public static void viewConfiguration(IThreadContext threadContext,
+      IHTTPOutput out, Locale locale, ConfigParams parameters)
+      throws ManifoldCFException, IOException {
+    Map<String, String> paramMap = new HashMap<String, String>();
+    fillInParameters(paramMap, parameters);
+    VelocityEngine velocityEngine = Messages.createVelocityEngine(ConfigurationHandler.class);
+    VelocityContext context = createVelocityContext(paramMap);
+    StringWriter w = new StringWriter();
+    velocityEngine.mergeTemplate(VIEW_CONFIG, "UTF-8", context, w);
+    out.print(w.toString());
+  }
+  
+  public static void outputSpecificationHeader(IHTTPOutput out, Locale locale, Specification os,
+    int connectionSequenceNumber, List<String> tabsArray)
+    throws ManifoldCFException, IOException
+  {
+    String seqPrefix = "s"+connectionSequenceNumber+"_";
+    tabsArray.add(Messages.getString(locale, "Alfresco.FilteringConfiguration"));
+    out.print(
+    		"<script type=\"text/javascript\">\n"+
+    		"<!--\n"+
+    		"function "+seqPrefix+"checkSpecification()\n"+
+    		"{\n"+
+    		"  return true;\n"+
+    		"}\n"+
+    		"\n");
+    
+    for(String node:SPECIFICATION_MAP.keySet()){
+    	out.print(
+    			"function "+seqPrefix+"add"+node+"()\n"+
+    			"{\n");
+    	Collection<String> vars = SPECIFICATION_MAP.get(node);
+    	for(String var:vars){
+            Object[] args = new String[]{node,var};
+    		out.print(
+    				"if (editjob."+seqPrefix+var+".value == \"\")\n"+
+        			"  {\n"+
+//        			"    alert(\"Value of "+ node + "." + var + " can't be NULL" +"\");\n"+
+                    "    alert(\""+ Messages.getBodyJavascriptString(locale, "Alfresco.ParamNullError",args) + "\");\n"+
+        			"    editjob."+seqPrefix+var+".focus();\n"+
+        			"    return;\n"+
+        			"  }\n"
+    				);
+    	}
+    			
+    	out.print("editjob."+seqPrefix+node+"_op.value=\""+ Messages.getBodyJavascriptString(locale, "Alfresco.Add") + "\";\n"+
+    			"  postFormSetAnchor(\""+seqPrefix+"+"+node+"\");\n"+
+    			"}\n"+
+    			"\n"+
+    	"function "+seqPrefix+"delete"+node+"(i)\n"+
+    			"{\n"+
+    			"  // Set the operation\n"+
+    			"  eval(\"editjob."+seqPrefix+node+"_\"+i+\"_op.value=\\\"" + Messages.getBodyJavascriptString(locale, "Alfresco.Delete") + "\\\"\");\n"+
+    			"  // Submit\n"+
+    			"  if (editjob."+seqPrefix+node+"_count.value==i)\n"+
+    			"    postFormSetAnchor(\""+seqPrefix+node+"\");\n"+
+    			"  else\n"+
+    			"    postFormSetAnchor(\""+seqPrefix+node+"_\"+i)\n"+
+    			"  // Undo, so we won't get two deletes next time\n"+
+    			"  eval(\"editjob."+seqPrefix+node+"_\"+i+\"_op.value=\\\""+ Messages.getBodyJavascriptString(locale, "Alfresco.Continue") + "\\\"\");\n"+
+    			"}\n"+
+    			"\n");
+    }
+    		
+    out.print("\n"+
+    		"\n"+
+    		"//-->\n"+
+    		"</script>\n");		
+  }
+
+  
+  public static void outputSpecificationBody(IHTTPOutput out, Locale locale, Specification os,
+		  int connectionSequenceNumber, int actualSequenceNumber, String tabName)
+				  throws ManifoldCFException, IOException
+  {
+	  String seqPrefix = "s"+connectionSequenceNumber+"_";
+	  int i;
+	  // Field Mapping tab
+	  if (tabName.equals(Messages.getString(locale, "Alfresco.FilteringConfiguration")) && connectionSequenceNumber == actualSequenceNumber)
+	  {
+		  for(String node:SPECIFICATION_MAP.keySet()){
+			  out.print(
+					  "<table class=\"displaytable\">\n"+
+							  "  <tr><td class=\"separator\" colspan=\"2\"><hr/></td></tr>\n"+
+							  "  <tr>\n"+
+							  "    <td class=\"description\"><nobr>" + node + " filtering:</nobr></td>\n"+
+							  "    <td class=\"boxcell\">\n"+
+							  "      <table class=\"formtable\">\n"+
+							  "        <tr class=\"formheaderrow\">\n"+
+							  "          <td class=\"formcolumnheader\"></td>\n");
+			  Collection<String> vars = SPECIFICATION_MAP.get(node);
+			  for(String var:vars){
+				  out.print("<td class=\"formcolumnheader\"><nobr>" + var + "</nobr></td>\n");
+			  }
+			  out.print("</tr>\n");
+			  
+			  int fieldCounter = 0;
+			  i = 0;
+			  while (i < os.getChildCount()) {
+				  SpecificationNode sn = os.getChild(i++);
+				  if (sn.getType().equals(node)) {
+					  String prefix = seqPrefix+node+"_" + Integer.toString(fieldCounter);
+					  out.print(
+							  "        <tr class=\""+(((fieldCounter % 2)==0)?"evenformrow":"oddformrow")+"\">\n"+
+									  "          <td class=\"formcolumncell\">\n"+
+									  "            <a name=\""+prefix+"\">\n"+
+									  "              <input type=\"button\" value=\""+ Messages.getBodyJavascriptString(locale, "Alfresco.Delete") + "\" alt=\""+ Messages.getBodyJavascriptString(locale, "Alfresco.Delete") + ""+Integer.toString(fieldCounter+1)+"\" onclick='javascript:"+seqPrefix+"delete"+node+"("+Integer.toString(fieldCounter)+");'/>\n"+
+									  "              <input type=\"hidden\" name=\""+prefix+"_op\" value=\""+ Messages.getBodyJavascriptString(locale, "Alfresco.Continue") + "\"/>\n");
+					  for(String var:vars){
+						  out.print("<input type=\"hidden\" name=\""+prefix+"_"+var+"\" value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(sn.getAttributeValue(var))+"\"/>\n");
+					  }
+
+					  out.print("            </a>\n"+
+							  "          </td>\n");
+					  for(String var:vars){
+						  out.print(
+								  "       <td class=\"formcolumncell\">\n"+
+										  "            <nobr>"+org.apache.manifoldcf.ui.util.Encoder.bodyEscape(sn.getAttributeValue(var))+"</nobr>\n"+
+								  "          </td>\n");
+					  }
+					  fieldCounter++;
+
+				  }
+			  }
+			  if (fieldCounter == 0)
+		      {
+		        out.print(
+		        		"<tr class=\"formrow\"><td class=\"formmessage\" colspan=\"3\">"+ Messages.getBodyJavascriptString(locale, "Alfresco.NoFilteringConfiguration") + "</td></tr>\n");
+		      }
+			  
+			  out.print(
+						"        <tr class=\"formrow\"><td class=\"formseparator\" colspan=\"3\"><hr/></td></tr>\n"+
+						"        <tr class=\"formrow\">\n"+
+						"          <td class=\"formcolumncell\">\n"+
+						"            <a name=\""+seqPrefix+node+"\">\n"+
+						"              <input type=\"button\" value=\""+ Messages.getBodyJavascriptString(locale, "Alfresco.Add") + "\" alt=\""+ Messages.getBodyJavascriptString(locale, "Alfresco.Add") + " " + node + "\" onclick=\"javascript:"+seqPrefix+"add"+node+"();\"/>\n"+
+						"            </a>\n"+
+						"            <input type=\"hidden\" name=\""+seqPrefix+node+"_count\" value=\""+fieldCounter+"\"/>\n"+
+						"            <input type=\"hidden\" name=\""+seqPrefix+node+"_op\" value=\""+ Messages.getBodyJavascriptString(locale, "Alfresco.Continue") +"\"/>\n"+
+						"          </td>\n");
+			  for(String var:vars){
+				  out.print("          <td class=\"formcolumncell\">\n"+
+						"            <nobr><input type=\"text\" size=\"15\" name=\""+seqPrefix+var+"\" value=\"\"/></nobr>\n"+
+						"          </td>\n");
+			  }
+
+			 out.print("</tr>\n"+
+						"      </table>\n"+
+						"    </td>\n"+
+						"  </tr>\n");
+						
+
+		  }
+	  }
+	  else{
+	      for(String node:SPECIFICATION_MAP.keySet()){
+	    	  i = 0;
+		      int fieldCounter = 0;  
+		      while (i < os.getChildCount()) {
+		    	  SpecificationNode sn = os.getChild(i++);
+		    	  if(sn.getType().equals(node)){
+		    		String prefix = seqPrefix+node+"_" + Integer.toString(fieldCounter);  
+		    		for(String var:SPECIFICATION_MAP.get(node)){
+		    			out.print(
+		    					"<input type=\"hidden\" name=\""+prefix+"_"+var+"\" value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(sn.getAttributeValue(var))+"\"/>\n");
+		    		}
+		    		fieldCounter++;
+		    	  }
+		      }
+		      
+		      out.print("<input type=\"hidden\" name=\""+seqPrefix+node+"_count\" value=\""+Integer.toString(fieldCounter)+"\"/>\n");
+	      }
+	    }
+	  }
+		  
+  public static String processSpecificationPost(IPostParameters variableContext, Locale locale, Specification os,
+		  int connectionSequenceNumber) throws ManifoldCFException {
+	  // Remove old Nodes
+	  int i;
+
+	  String seqPrefix = "s"+connectionSequenceNumber+"_";
+	 	 	  
+	  for(String node:SPECIFICATION_MAP.keySet()){
+		  
+		  String x = variableContext.getParameter(seqPrefix+node+"_count");
+		  if (x != null && x.length() > 0){
+			  
+			  i = 0;
+			  while (i < os.getChildCount())
+			  {
+				  SpecificationNode specNode = os.getChild(i);
+				  if (specNode.getType().equals(node))
+					  os.removeChild(i);
+				  else
+					  i++;
+			  }
+
+			  Collection<String> vars = SPECIFICATION_MAP.get(node);
+
+			  int count = Integer.parseInt(x);
+			  i = 0;
+			  while (i < count)
+			  {
+				  String prefix = seqPrefix+node+"_"+Integer.toString(i);
+				  String op = variableContext.getParameter(prefix+"_op");
+				  if (op == null || !op.equals(Messages.getBodyJavascriptString(locale, "Alfresco.Delete")))
+				  {
+					  SpecificationNode specNode = new SpecificationNode(node);
+					  for(String var:vars){
+						  String value = variableContext.getParameter(prefix+"_"+var);
+						  if(value == null)
+							  value = "";
+						  specNode.setAttribute(var, value);
+					  }
+					  os.addChild(os.getChildCount(), specNode);
+				  }
+				  i++;
+			  }
+
+			  String addop = variableContext.getParameter(seqPrefix+node+"_op");
+			  if (addop != null && addop.equals(Messages.getBodyJavascriptString(locale, "Alfresco.Add")))
+			  {
+				  SpecificationNode specNode = new SpecificationNode(node);
+				  for(String var:vars){
+					  String value = variableContext.getParameter(seqPrefix+var);
+					  if(value == null)
+						  value = "";
+					  specNode.setAttribute(var, value);
+				  }
+				  os.addChild(os.getChildCount(), specNode);
+			  }
+		  }
+	  }
+
+	  return null;
+  }
+  
+  public static void viewSpecification(IHTTPOutput out, Locale locale, Specification os,
+		  int connectionSequenceNumber)
+				  throws ManifoldCFException, IOException
+  {
+	  int i = 0;
+
+
+
+
+	  for(String node:SPECIFICATION_MAP.keySet()){
+		  Collection<String> vars = SPECIFICATION_MAP.get(node);
+		  out.print(
+				  "\n"+
+						  "<table class=\"displaytable\">\n"+
+						  "  <tr>\n"+
+						  "    <td class=\"description\"><nobr>"+ Messages.getBodyJavascriptString(locale, "Alfresco.SpecificFilteringConfiguration",new String[]{node}) +"</nobr></td>\n"+
+						  "    <td class=\"boxcell\">\n"+
+						  "      <table class=\"formtable\">\n"+
+						  "        <tr class=\"formheaderrow\">\n");
+		  for(String var:vars)
+			  out.print(
+					  "          <td class=\"formcolumnheader\"><nobr>" + var + "</nobr></td>\n");
+						  
+		 out.print("        </tr>\n");
+		 
+		 int fieldCounter = 0;
+		  i = 0;
+		 
+		  while (i < os.getChildCount()) {
+			  SpecificationNode sn = os.getChild(i++);
+			  if (sn.getType().equals(node)) {
+				  out.print(
+						  "        <tr class=\""+(((fieldCounter % 2)==0)?"evenformrow":"oddformrow")+"\">\n");
+				  for(String var:vars)
+					  out.print(
+								  "          <td class=\"formcolumncell\">\n"+
+								  "            <nobr>"+org.apache.manifoldcf.ui.util.Encoder.bodyEscape(sn.getAttributeValue(var))+"</nobr>\n"+
+								  "          </td>\n");
+				  out.print(
+								  "        </tr>\n");
+				  fieldCounter++;
+			  }
+		  }
+
+		  if (fieldCounter == 0)
+		  {
+			  out.print(
+					  "        <tr class=\"formrow\"><td class=\"formmessage\" colspan=\"3\">"+ Messages.getBodyJavascriptString(locale, "Alfresco.NoSpecificFilteringConfiguration",new String[]{node}) + "</td></tr>\n"
+					  );
+		  }
+		  out.print(
+				  "      </table>\n"+
+						  "    </td>\n"+
+						  "  </tr>\n"+
+						  "  </tr>\n"+
+						  "</table>\n");
+	  }
+  }
+  
+  public static String getSpecificationVersion(Specification os){
+	  StringBuilder builder = new StringBuilder();
+	  int i = 0;
+	  while(i < os.getChildCount()){
+		  SpecificationNode node = os.getChild(i);
+		  Collection<String> vars = SPECIFICATION_MAP.get(node.getType());
+		  for(String var:vars)
+			  builder.append(node.getAttributeValue(var)).append("+");
+		  i++;
+	  }
+	  return builder.toString();
+  }
+  
+  public static AlfrescoFilters getFilters(Specification spec) {
+		AlfrescoFilters filters = new AlfrescoFilters();
+		for(int i = 0; i < spec.getChildCount(); i++){
+			SpecificationNode node = spec.getChild(i);
+			if(node.getType().equals(NODE_SITE))
+				filters.addSiteFilter(node.getAttributeValue(ATTRIBUTE_SITE));
+			else if(node.getType().equals(NODE_MIMETYPE))
+				filters.addMimetypeFilter(node.getAttributeValue(ATTRIBUTE_MIMETYPE));
+			else if(node.getType().equals(NODE_ASPECT))
+				filters.addAspectFilter(
+						node.getAttributeValue(ATTRIBUTE_ASPECT));
+			else if(node.getType().equals(NODE_METADATA))
+				filters.addMetadataFilter(
+						node.getAttributeValue(ATTRIBUTE_METADATA_SOURCE),
+						node.getAttributeValue(ATTRIBUTE_METADATA_TARGET));
+		}
+		
+		return filters;
+	}
+}

Added: manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/webscript/Messages.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/webscript/Messages.java?rev=1628999&view=auto
==============================================================================
--- manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/webscript/Messages.java (added)
+++ manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/alfresco/webscript/Messages.java Thu Oct  2 15:33:55 2014
@@ -0,0 +1,138 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.manifoldcf.crawler.connectors.alfresco.webscript;
+
+import java.util.Locale;
+import java.util.Map;
+import org.apache.manifoldcf.core.interfaces.ManifoldCFException;
+import org.apache.manifoldcf.core.interfaces.IHTTPOutput;
+
+public class Messages extends org.apache.manifoldcf.ui.i18n.Messages
+{
+    public static final String DEFAULT_BUNDLE_NAME="org.apache.manifoldcf.crawler.connectors.alfresco.webscript.common";
+    public static final String DEFAULT_PATH_NAME="org.apache.manifoldcf.crawler.connectors.alfresco.webscript";
+
+    /** Constructor - do no instantiate
+     */
+    protected Messages()
+    {
+    }
+
+    public static String getString(Locale locale, String messageKey)
+    {
+        return getString(DEFAULT_BUNDLE_NAME, locale, messageKey, null);
+    }
+
+    public static String getAttributeString(Locale locale, String messageKey)
+    {
+        return getAttributeString(DEFAULT_BUNDLE_NAME, locale, messageKey, null);
+    }
+
+    public static String getBodyString(Locale locale, String messageKey)
+    {
+        return getBodyString(DEFAULT_BUNDLE_NAME, locale, messageKey, null);
+    }
+
+    public static String getAttributeJavascriptString(Locale locale, String messageKey)
+    {
+        return getAttributeJavascriptString(DEFAULT_BUNDLE_NAME, locale, messageKey, null);
+    }
+
+    public static String getBodyJavascriptString(Locale locale, String messageKey)
+    {
+        return getBodyJavascriptString(DEFAULT_BUNDLE_NAME, locale, messageKey, null);
+    }
+
+    public static String getString(Locale locale, String messageKey, Object[] args)
+    {
+        return getString(DEFAULT_BUNDLE_NAME, locale, messageKey, args);
+    }
+
+    public static String getAttributeString(Locale locale, String messageKey, Object[] args)
+    {
+        return getAttributeString(DEFAULT_BUNDLE_NAME, locale, messageKey, args);
+    }
+
+    public static String getBodyString(Locale locale, String messageKey, Object[] args)
+    {
+        return getBodyString(DEFAULT_BUNDLE_NAME, locale, messageKey, args);
+    }
+
+    public static String getAttributeJavascriptString(Locale locale, String messageKey, Object[] args)
+    {
+        return getAttributeJavascriptString(DEFAULT_BUNDLE_NAME, locale, messageKey, args);
+    }
+
+    public static String getBodyJavascriptString(Locale locale, String messageKey, Object[] args)
+    {
+        return getBodyJavascriptString(DEFAULT_BUNDLE_NAME, locale, messageKey, args);
+    }
+
+    // More general methods which allow bundlenames and class loaders to be specified.
+
+    public static String getString(String bundleName, Locale locale, String messageKey, Object[] args)
+    {
+        return getString(Messages.class, bundleName, locale, messageKey, args);
+    }
+
+    public static String getAttributeString(String bundleName, Locale locale, String messageKey, Object[] args)
+    {
+        return getAttributeString(Messages.class, bundleName, locale, messageKey, args);
+    }
+
+    public static String getBodyString(String bundleName, Locale locale, String messageKey, Object[] args)
+    {
+        return getBodyString(Messages.class, bundleName, locale, messageKey, args);
+    }
+
+    public static String getAttributeJavascriptString(String bundleName, Locale locale, String messageKey, Object[] args)
+    {
+        return getAttributeJavascriptString(Messages.class, bundleName, locale, messageKey, args);
+    }
+
+    public static String getBodyJavascriptString(String bundleName, Locale locale, String messageKey, Object[] args)
+    {
+        return getBodyJavascriptString(Messages.class, bundleName, locale, messageKey, args);
+    }
+
+    // Resource output
+
+    public static void outputResource(IHTTPOutput output, Locale locale, String resourceKey,
+                                      Map<String,String> substitutionParameters, boolean mapToUpperCase)
+            throws ManifoldCFException
+    {
+        outputResource(output,Messages.class,DEFAULT_PATH_NAME,locale,resourceKey,
+                substitutionParameters,mapToUpperCase);
+    }
+
+    public static void outputResourceWithVelocity(IHTTPOutput output, Locale locale, String resourceKey,
+                                                  Map<String,String> substitutionParameters, boolean mapToUpperCase)
+            throws ManifoldCFException
+    {
+        outputResourceWithVelocity(output,Messages.class,DEFAULT_BUNDLE_NAME,DEFAULT_PATH_NAME,locale,resourceKey,
+                substitutionParameters,mapToUpperCase);
+    }
+
+    public static void outputResourceWithVelocity(IHTTPOutput output, Locale locale, String resourceKey,
+                                                  Map<String,Object> contextObjects)
+            throws ManifoldCFException
+    {
+        outputResourceWithVelocity(output,Messages.class,DEFAULT_BUNDLE_NAME,DEFAULT_PATH_NAME,locale,resourceKey,
+                contextObjects);
+    }
+
+}

Added: manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/native2ascii/org/apache/manifoldcf/authorities/alfresco/common_en.properties
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/native2ascii/org/apache/manifoldcf/authorities/alfresco/common_en.properties?rev=1628999&view=auto
==============================================================================
--- manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/native2ascii/org/apache/manifoldcf/authorities/alfresco/common_en.properties (added)
+++ manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/native2ascii/org/apache/manifoldcf/authorities/alfresco/common_en.properties Thu Oct  2 15:33:55 2014
@@ -0,0 +1,3 @@
+Alfresco.Continue=Continue
+Alfresco.Delete=Delete
+Alfresco.Add=Add
\ No newline at end of file

Added: manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/native2ascii/org/apache/manifoldcf/authorities/alfresco/common_en_US.properties
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/native2ascii/org/apache/manifoldcf/authorities/alfresco/common_en_US.properties?rev=1628999&view=auto
==============================================================================
--- manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/native2ascii/org/apache/manifoldcf/authorities/alfresco/common_en_US.properties (added)
+++ manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/native2ascii/org/apache/manifoldcf/authorities/alfresco/common_en_US.properties Thu Oct  2 15:33:55 2014
@@ -0,0 +1,3 @@
+Alfresco.Continue=Continue
+Alfresco.Delete=Delete
+Alfresco.Add=Add
\ No newline at end of file

Added: manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/connectors/alfresco/webscript/common_en.properties
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/connectors/alfresco/webscript/common_en.properties?rev=1628999&view=auto
==============================================================================
--- manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/connectors/alfresco/webscript/common_en.properties (added)
+++ manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/connectors/alfresco/webscript/common_en.properties Thu Oct  2 15:33:55 2014
@@ -0,0 +1,8 @@
+Alfresco.FilteringConfiguration=Alfresco Filtering Configuration
+Alfresco.SpecificFilteringConfiguration=Alfresco {0} Filtering Configuration
+Alfresco.NoSpecificFilteringConfiguration=No Filtering Configuration Specificied for {0}
+Alfresco.NoFilteringConfiguration=No Filtering Configuration Specified
+Alfresco.ParamNullError=Value of {0}.{1} can't be NULL
+Alfresco.Continue=Continue
+Alfresco.Delete=Delete
+Alfresco.Add=Add
\ No newline at end of file

Added: manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/connectors/alfresco/webscript/common_en_US.properties
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/connectors/alfresco/webscript/common_en_US.properties?rev=1628999&view=auto
==============================================================================
--- manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/connectors/alfresco/webscript/common_en_US.properties (added)
+++ manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/connectors/alfresco/webscript/common_en_US.properties Thu Oct  2 15:33:55 2014
@@ -0,0 +1,8 @@
+Alfresco.FilteringConfiguration=Alfresco Filtering Configuration
+Alfresco.SpecificFilteringConfiguration=Alfresco {0} Filtering Configuration
+Alfresco.NoSpecificFilteringConfiguration=No Filtering Configuration Specificied for {0}
+Alfresco.NoFilteringConfiguration=No Filtering Configuration Specified
+Alfresco.ParamNullError=Value of {0}.{1} can't be NULL
+Alfresco.Continue=Continue
+Alfresco.Delete=Delete
+Alfresco.Add=Add
\ No newline at end of file

Added: manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/resources/org/apache/manifoldcf/authorities/alfresco/editConfiguration.js
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/resources/org/apache/manifoldcf/authorities/alfresco/editConfiguration.js?rev=1628999&view=auto
==============================================================================
--- manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/resources/org/apache/manifoldcf/authorities/alfresco/editConfiguration.js (added)
+++ manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/resources/org/apache/manifoldcf/authorities/alfresco/editConfiguration.js Thu Oct  2 15:33:55 2014
@@ -0,0 +1,29 @@
+<script type="text/javascript">
+<!--
+function checkConfig() {
+	return true;
+}
+
+function checkConfigForSave() {
+	if (editconnection.protocol.value == "") {
+		alert("Protocol must not be empty!");
+		SelectTab("Server");
+		editconnection.protocol.focus();
+		return false;
+	}
+	if (editconnection.hostname.value == "") {
+		alert("Hostname must not be empty!");
+		SelectTab("Server");
+		editconnection.hostname.focus();
+		return false;
+	}
+	if (editconnection.endpoint.value == "") {
+		alert("Endpoint must not be empty!");
+		SelectTab("Server");
+		editconnection.endpoint.focus();
+		return false;
+	}
+	return true;
+}
+// -->
+</script>

Added: manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/resources/org/apache/manifoldcf/authorities/alfresco/editConfiguration_Server.html
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/resources/org/apache/manifoldcf/authorities/alfresco/editConfiguration_Server.html?rev=1628999&view=auto
==============================================================================
--- manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/resources/org/apache/manifoldcf/authorities/alfresco/editConfiguration_Server.html (added)
+++ manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/resources/org/apache/manifoldcf/authorities/alfresco/editConfiguration_Server.html Thu Oct  2 15:33:55 2014
@@ -0,0 +1,50 @@
+#if($tabName == "Server")
+<table class="displaytable">
+	<tr>
+		<td class="description">
+			<nobr>Protocol</nobr>
+		</td>
+		<td class="value">
+			<input name="protocol" type="text" size="32" value="$protocol" />
+		</td>
+	</tr>
+	<tr>
+		<td class="description">
+			<nobr>Hostname</nobr>
+		</td>
+		<td class="value">
+			<input name="hostname" type="text" size="32" value="$hostname"/>
+		</td>
+	</tr>
+	<tr>
+		<td class="description">
+			<nobr>Endpoint</nobr>
+		</td>
+		<td class="value">
+			<input name="endpoint" type="text" size="32" value="$endpoint" />
+		</td>
+	</tr>
+	<tr>
+		<td class="description">
+			<nobr>Username</nobr>
+		</td>
+		<td class="value">
+			<input name="username" type="text" size="32" value="$username"/>
+		</td>
+	</tr>
+	<tr>
+		<td class="description">
+			<nobr>Password</nobr>
+		</td>
+		<td class="value">
+			<input name="password" type="password" size="32" value="$password"/>
+		</td>
+	</tr>
+</table>
+#else
+<input type="hidden" name="protocol" value="$protocol" />
+<input type="hidden" name="hostname" value="$hostname" />
+<input type="hidden" name="endpoint" value="$endpoint" />
+<input type="hidden" name="username" value="$username" />
+<input type="hidden" name="password" value="$password" />
+#end

Added: manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/resources/org/apache/manifoldcf/authorities/alfresco/viewConfiguration.html
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/resources/org/apache/manifoldcf/authorities/alfresco/viewConfiguration.html?rev=1628999&view=auto
==============================================================================
--- manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/resources/org/apache/manifoldcf/authorities/alfresco/viewConfiguration.html (added)
+++ manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/resources/org/apache/manifoldcf/authorities/alfresco/viewConfiguration.html Thu Oct  2 15:33:55 2014
@@ -0,0 +1,42 @@
+<table class="displaytable">
+	<tr>
+		<td class="description" colspan="1">
+			<nobr>Protocol:</nobr>
+		</td>
+		<td class="value" colspan="3">
+			<nobr>$protocol</nobr><br/>
+		</td>
+	</tr>
+	<tr>
+		<td class="description" colspan="1">
+			<nobr>Hostname:</nobr>
+		</td>
+		<td class="value" colspan="3">
+			<nobr>$hostname</nobr><br/>
+		</td>
+	</tr>
+	<tr>
+		<td class="description" colspan="1">
+			<nobr>Endpoint:</nobr>
+		</td>
+		<td class="value" colspan="3">
+			<nobr>$endpoint</nobr><br/>
+		</td>
+	</tr>
+	<tr>
+		<td class="description" colspan="1">
+			<nobr>Username:</nobr>
+		</td>
+		<td class="value" colspan="3">
+			<nobr>$username</nobr><br/>
+		</td>
+	</tr>
+	<tr>
+		<td class="description" colspan="1">
+			<nobr>Password:</nobr>
+		</td>
+		<td class="value" colspan="3">
+			<nobr>********</nobr><br/>
+		</td>
+	</tr>
+</table>

Added: manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/alfresco/webscript/editConfiguration.js
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/alfresco/webscript/editConfiguration.js?rev=1628999&view=auto
==============================================================================
--- manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/alfresco/webscript/editConfiguration.js (added)
+++ manifoldcf/branches/CONNECTORS-1037/connectors/alfresco-webscript/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/alfresco/webscript/editConfiguration.js Thu Oct  2 15:33:55 2014
@@ -0,0 +1,41 @@
+<script type="text/javascript">
+<!--
+function checkConfig() {
+	return true;
+}
+
+function checkConfigForSave() {
+	if (editconnection.protocol.value == "") {
+		alert("Protocol must not be empty!");
+		SelectTab("Server");
+		editconnection.protocol.focus();
+		return false;
+	}
+	if (editconnection.hostname.value == "") {
+		alert("Hostname must not be empty!");
+		SelectTab("Server");
+		editconnection.hostname.focus();
+		return false;
+	}
+	if (editconnection.endpoint.value == "") {
+		alert("Endpoint must not be empty!");
+		SelectTab("Server");
+		editconnection.endpoint.focus();
+		return false;
+	}
+	if (editconnection.storeprotocol.value == "") {
+		alert("Store protocol must no be empty!");
+		SelectTab("Server");
+		editconnection.storeprotocol.focus();
+		return false;
+	}
+	if (editconnection.storeid.value == "") {
+		alert("Store id must no be empty!");
+		SelectTab("Server");
+		editconnection.storeid.focus();
+		return false;
+	}
+	return true;
+}
+// -->
+</script>



Mime
View raw message