manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rh...@apache.org
Subject svn commit: r1791418 [1/3] - in /manifoldcf/branches/CONNECTORS-1290-2/connectors/nuxeo: ./ connector/src/main/java/org/apache/manifoldcf/authorities/authorities/nuxeo/ connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/ connector/s...
Date Fri, 14 Apr 2017 21:20:25 GMT
Author: rharo
Date: Fri Apr 14 21:20:25 2017
New Revision: 1791418

URL: http://svn.apache.org/viewvc?rev=1791418&view=rev
Log:
CONNECTORS-1290: Upgrading Branch to New Connector version using official Nuxeo Java Client

Modified:
    manifoldcf/branches/CONNECTORS-1290-2/connectors/nuxeo/build.xml
    manifoldcf/branches/CONNECTORS-1290-2/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/nuxeo/Messages.java
    manifoldcf/branches/CONNECTORS-1290-2/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/nuxeo/NuxeoAuthorityConnector.java
    manifoldcf/branches/CONNECTORS-1290-2/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/Messages.java
    manifoldcf/branches/CONNECTORS-1290-2/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/NuxeoConfiguration.java
    manifoldcf/branches/CONNECTORS-1290-2/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/NuxeoRepositoryConnector.java
    manifoldcf/branches/CONNECTORS-1290-2/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/exception/NuxeoException.java
    manifoldcf/branches/CONNECTORS-1290-2/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/model/Attachment.java
    manifoldcf/branches/CONNECTORS-1290-2/connectors/nuxeo/connector/src/main/native2ascii/org/apache/manifoldcf/authorities/authorities/nuxeo/common_en_US.properties
    manifoldcf/branches/CONNECTORS-1290-2/connectors/nuxeo/connector/src/main/native2ascii/org/apache/manifoldcf/authorities/authorities/nuxeo/common_es_ES.properties
    manifoldcf/branches/CONNECTORS-1290-2/connectors/nuxeo/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/connectors/nuxeo/common_en_US.properties
    manifoldcf/branches/CONNECTORS-1290-2/connectors/nuxeo/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/connectors/nuxeo/common_es_ES.properties
    manifoldcf/branches/CONNECTORS-1290-2/connectors/nuxeo/connector/src/main/resources/org/apache/manifoldcf/authorities/authorities/nuxeo/editConfiguration_conf.js
    manifoldcf/branches/CONNECTORS-1290-2/connectors/nuxeo/connector/src/main/resources/org/apache/manifoldcf/authorities/authorities/nuxeo/editConfiguration_conf_server.html
    manifoldcf/branches/CONNECTORS-1290-2/connectors/nuxeo/connector/src/main/resources/org/apache/manifoldcf/authorities/authorities/nuxeo/viewConfiguration_conf.html
    manifoldcf/branches/CONNECTORS-1290-2/connectors/nuxeo/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/nuxeo/editConfiguration_conf.js
    manifoldcf/branches/CONNECTORS-1290-2/connectors/nuxeo/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/nuxeo/editConfiguration_conf_server.html
    manifoldcf/branches/CONNECTORS-1290-2/connectors/nuxeo/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/nuxeo/editSpecification_conf.js
    manifoldcf/branches/CONNECTORS-1290-2/connectors/nuxeo/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/nuxeo/editSpecification_confDocuments.html
    manifoldcf/branches/CONNECTORS-1290-2/connectors/nuxeo/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/nuxeo/editSpecification_confDocumentsType.html
    manifoldcf/branches/CONNECTORS-1290-2/connectors/nuxeo/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/nuxeo/viewConfiguration_conf.html
    manifoldcf/branches/CONNECTORS-1290-2/connectors/nuxeo/connector/src/main/resources/org/apache/manifoldcf/crawler/connectors/nuxeo/viewSpecification_conf.html
    manifoldcf/branches/CONNECTORS-1290-2/connectors/nuxeo/connector/src/test/java/org/apache/manifoldcf/authorities/nuxeo/tests/NuxeoAuthorityTest.java
    manifoldcf/branches/CONNECTORS-1290-2/connectors/nuxeo/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/nuxeo/tests/NuxeoConnectorTest.java
    manifoldcf/branches/CONNECTORS-1290-2/connectors/nuxeo/pom.xml

Modified: manifoldcf/branches/CONNECTORS-1290-2/connectors/nuxeo/build.xml
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1290-2/connectors/nuxeo/build.xml?rev=1791418&r1=1791417&r2=1791418&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-1290-2/connectors/nuxeo/build.xml (original)
+++ manifoldcf/branches/CONNECTORS-1290-2/connectors/nuxeo/build.xml Fri Apr 14 21:20:25 2017
@@ -33,6 +33,7 @@
     <path id="connector-classpath">
         <path refid="mcf-connector-build.connector-classpath"/>
         <fileset dir="../../lib">
+             <include name="nuxeo-java-client*.jar"/>
         </fileset>
     </path>
 
@@ -40,6 +41,7 @@
         <mkdir dir="dist/lib"/>
         <copy todir="dist/lib">
             <fileset dir="../../lib">
+                <include name="nuxeo-java-client*.jar"/>
             </fileset>
         </copy>
     </target>

Modified: manifoldcf/branches/CONNECTORS-1290-2/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/nuxeo/Messages.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1290-2/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/nuxeo/Messages.java?rev=1791418&r1=1791417&r2=1791418&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-1290-2/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/nuxeo/Messages.java (original)
+++ manifoldcf/branches/CONNECTORS-1290-2/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/nuxeo/Messages.java Fri Apr 14 21:20:25 2017
@@ -1,21 +1,3 @@
-/* $Id$ */
-
-/**
-* 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.authorities.nuxeo;
 
 import java.util.Locale;
@@ -26,97 +8,97 @@ import org.apache.manifoldcf.core.interf
 
 public class Messages extends org.apache.manifoldcf.ui.i18n.Messages {
 
-  public static final String DEFAULT_BUNDLE_NAME = "org.apache.manifoldcf.authorities.authorities.nuxeo.common";
-  public static final String DEFAULT_PATH_NAME = "org.apache.manifoldcf.authorities.authorities.nuxeo";
+	public static final String DEFAULT_BUNDLE_NAME = "org.apache.manifoldcf.authorities.authorities.nuxeo.common";
+	public static final String DEFAULT_PATH_NAME = "org.apache.manifoldcf.authorities.authorities.nuxeo";
 
-  /** 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);
-  }
+	/** 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);
+	}
 
 }

Modified: manifoldcf/branches/CONNECTORS-1290-2/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/nuxeo/NuxeoAuthorityConnector.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1290-2/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/nuxeo/NuxeoAuthorityConnector.java?rev=1791418&r1=1791417&r2=1791418&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-1290-2/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/nuxeo/NuxeoAuthorityConnector.java (original)
+++ manifoldcf/branches/CONNECTORS-1290-2/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/nuxeo/NuxeoAuthorityConnector.java Fri Apr 14 21:20:25 2017
@@ -1,21 +1,3 @@
-/* $Id$ */
-
-/**
-* 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.authorities.nuxeo;
 
 import java.io.IOException;
@@ -25,7 +7,6 @@ import java.util.Locale;
 import java.util.Map;
 
 import org.apache.commons.lang.StringUtils;
-import org.apache.manifoldcf.agents.interfaces.ServiceInterruption;
 import org.apache.manifoldcf.authorities.authorities.BaseAuthorityConnector;
 import org.apache.manifoldcf.authorities.interfaces.AuthorizationResponse;
 import org.apache.manifoldcf.core.interfaces.ConfigParams;
@@ -35,7 +16,9 @@ import org.apache.manifoldcf.core.interf
 import org.apache.manifoldcf.core.interfaces.IThreadContext;
 import org.apache.manifoldcf.core.interfaces.ManifoldCFException;
 import org.apache.manifoldcf.crawler.connectors.nuxeo.NuxeoConfiguration;
-import org.apache.manifoldcf.crawler.connectors.nuxeo.client.NuxeoClient;
+import org.nuxeo.client.api.NuxeoClient;
+import org.nuxeo.client.api.objects.user.User;
+import org.nuxeo.client.internals.spi.NuxeoClientException;
 
 /**
  *
@@ -46,281 +29,312 @@ import org.apache.manifoldcf.crawler.con
  */
 public class NuxeoAuthorityConnector extends BaseAuthorityConnector {
 
-  // Configuration tabs
-  private static final String CONF_SERVER_TAB_PROPERTY = "NuxeoAuthorityConnector.Server";
+	// Configuration tabs
+	private static final String CONF_SERVER_TAB_PROPERTY = "NuxeoAuthorityConnector.Server";
+
+	// Prefix for nuxeo configuration and specification parameters
+	private static final String PARAMETER_PREFIX = "nuxeo_";
 
-  // Prefix for nuxeo configuration and specification parameters
-  private static final String PARAMETER_PREFIX = "nuxeo_";
+	// Templates
+	/**
+	 * Javascript to check the configuration parameters
+	 */
+	private static final String EDIT_CONFIG_HEADER_FORWARD = "editConfiguration_conf.js";
+
+	/**
+	 * Server edit tab template
+	 */
+	private static final String EDIT_CONFIG_FORWARD_SERVER = "editConfiguration_conf_server.html";
+
+	/**
+	 * Server view tab template
+	 */
+	private static final String VIEW_CONFIG_FORWARD = "viewConfiguration_conf.html";
+
+	/* Nuxeo instance parameters */
+	protected String protocol = null;
+	protected String host = null;
+	protected String port = null;
+	protected String path = null;
+	protected String username = null;
+	protected String password = null;
+
+	protected NuxeoClient nuxeoClient = null;
+
+	// Constructor
+	public NuxeoAuthorityConnector() {
+		super();
+	}
+
+	public void setNuxeoClient(NuxeoClient nuxeoClient) {
+		this.nuxeoClient = nuxeoClient;
+	}
+
+	// Close the connection.
+	public void disconenct() throws ManifoldCFException {
+		if (nuxeoClient != null)
+			nuxeoClient = null;
+
+		protocol = null;
+		host = null;
+		port = null;
+		path = null;
+		username = null;
+		password = null;
+	}
+
+	/** CONNECTION **/
+
+	// Makes connection to server
+	@Override
+	public void connect(ConfigParams configParams) {
+		super.connect(configParams);
+
+		protocol = params.getParameter(NuxeoConfiguration.Server.PROTOCOL);
+		host = params.getParameter(NuxeoConfiguration.Server.HOST);
+		port = params.getParameter(NuxeoConfiguration.Server.PORT);
+		path = params.getParameter(NuxeoConfiguration.Server.PATH);
+		username = params.getParameter(NuxeoConfiguration.Server.USERNAME);
+		password = params.getObfuscatedParameter(NuxeoConfiguration.Server.PASSWORD);
+
+		try {
+			initNuxeoClient();
+		} catch (ManifoldCFException manifoldCFException) {
+			manifoldCFException.printStackTrace();
+		}
+	}
+
+	/**
+	 * Check the connection
+	 */
+	@Override
+	public String check() throws ManifoldCFException {
+		try {
+			if (!isConnected()) {
+				initNuxeoClient();
+			}
+
+			Boolean result = null;
+			try {
+				getGroupsByUser("Administrator");
+				result = true;
+			} catch (Exception ex) {
+				result = false;
+			}
+
+			if (result)
+				return super.check();
+			else
+				throw new ManifoldCFException("Nuxeo instance could not be reached");
+
+		} catch (ManifoldCFException manifoldCFException) {
+			return "Connection failed: " + manifoldCFException.getMessage();
+		} catch (Exception e) {
+			return "Connection failed: " + e.getMessage();
+		}
+	}
+
+	/**
+	 * Initialize Nuxeo client using the configured parameters.
+	 * 
+	 * @throws ManifoldCFException
+	 */
+	private void initNuxeoClient() throws ManifoldCFException {
+		if (nuxeoClient == null) {
+
+			if (StringUtils.isEmpty(protocol)) {
+				throw new ManifoldCFException(
+						"Parameter " + NuxeoConfiguration.Server.PROTOCOL + " required but not set");
+			}
+
+			if (StringUtils.isEmpty(host)) {
+				throw new ManifoldCFException("Parameter " + NuxeoConfiguration.Server.HOST + " required but not set");
+			}
+
+			String url = getUrl();
+			nuxeoClient = new NuxeoClient(url, username, password);
+
+		}
+
+	}
+
+	/**
+	 * Formatter URL
+	 * 
+	 * @throws ManifoldCFException
+	 */
+	public String getUrl() throws ManifoldCFException {
+		int portInt;
+		if (port != null && port.length() > 0) {
+			try {
+				portInt = Integer.parseInt(port);
+			} catch (NumberFormatException formatException) {
+				throw new ManifoldCFException("Bad number: " + formatException.getMessage(), formatException);
+			}
+		} else {
+			if (protocol.toLowerCase(Locale.ROOT).equals("http")) {
+				portInt = 80;
+			} else {
+				portInt = 443;
+			}
+		}
+
+		String url = protocol + "://" + host + ":" + portInt + "/" + path;
+
+		return url;
+	}
+
+	/**
+	 * @return true if the connector instance is connected.
+	 */
+	@Override
+	public boolean isConnected() {
+		return nuxeoClient != null;
+	}
+
+	/** VIEW CONFIGURATION **/
+	@Override
+	public void viewConfiguration(IThreadContext threadContext, IHTTPOutput out, Locale locale, ConfigParams parameters)
+			throws ManifoldCFException, IOException {
+
+		Map<String, String> paramMap = new HashMap<String, String>();
+
+		fillInServerConfigurationMap(paramMap, out, parameters);
+
+		Messages.outputResourceWithVelocity(out, locale, VIEW_CONFIG_FORWARD, paramMap, true);
+	}
+
+	private static void fillInServerConfigurationMap(Map<String, String> serverMap, IPasswordMapperActivity mapper,
+			ConfigParams parameters) {
+
+		String nuxeoProtocol = parameters.getParameter(NuxeoConfiguration.Server.PROTOCOL);
+		String nuxeoHost = parameters.getParameter(NuxeoConfiguration.Server.HOST);
+		String nuxeoPort = parameters.getParameter(NuxeoConfiguration.Server.PORT);
+		String nuxeoPath = parameters.getParameter(NuxeoConfiguration.Server.PATH);
+		String nuxeoUsername = parameters.getParameter(NuxeoConfiguration.Server.USERNAME);
+		String nuxeoPassword = parameters.getParameter(NuxeoConfiguration.Server.PASSWORD);
+
+		if (nuxeoProtocol == null)
+			nuxeoProtocol = NuxeoConfiguration.Server.PROTOCOL_DEFAULT_VALUE;
+		if (nuxeoHost == null)
+			nuxeoHost = NuxeoConfiguration.Server.HOST_DEFAULT_VALUE;
+		if (nuxeoPort == null)
+			nuxeoPort = NuxeoConfiguration.Server.PORT_DEFAULT_VALUE;
+		if (nuxeoPath == null)
+			nuxeoPath = NuxeoConfiguration.Server.PATH_DEFAULT_VALUE;
+		if (nuxeoUsername == null)
+			nuxeoUsername = NuxeoConfiguration.Server.USERNAME_DEFAULT_VALUE;
+		if (nuxeoPassword == null)
+			nuxeoPassword = NuxeoConfiguration.Server.PASSWORD_DEFAULT_VALUE;
+		else
+			nuxeoPassword = mapper.mapKeyToPassword(nuxeoPassword);
+
+		serverMap.put(PARAMETER_PREFIX + NuxeoConfiguration.Server.PROTOCOL, nuxeoProtocol);
+		serverMap.put(PARAMETER_PREFIX + NuxeoConfiguration.Server.HOST, nuxeoHost);
+		serverMap.put(PARAMETER_PREFIX + NuxeoConfiguration.Server.PORT, nuxeoPort);
+		serverMap.put(PARAMETER_PREFIX + NuxeoConfiguration.Server.PATH, nuxeoPath);
+		serverMap.put(PARAMETER_PREFIX + NuxeoConfiguration.Server.USERNAME, nuxeoUsername);
+		serverMap.put(PARAMETER_PREFIX + NuxeoConfiguration.Server.PASSWORD, nuxeoPassword);
+	}
+
+	/** CONFIGURATION CONNECTOR **/
+	@Override
+	public void outputConfigurationHeader(IThreadContext threadContext, IHTTPOutput out, Locale locale,
+			ConfigParams parameters, List<String> tabsArray) throws ManifoldCFException, IOException {
+
+		// Server tab
+		tabsArray.add(Messages.getString(locale, CONF_SERVER_TAB_PROPERTY));
+
+		Map<String, String> paramMap = new HashMap<String, String>();
+
+		// Fill in the parameters form each tab
+		fillInServerConfigurationMap(paramMap, out, parameters);
+
+		Messages.outputResourceWithVelocity(out, locale, EDIT_CONFIG_HEADER_FORWARD, paramMap, true);
+	}
+
+	@Override
+	public void outputConfigurationBody(IThreadContext threadContext, IHTTPOutput out, Locale locale,
+			ConfigParams parameters, String tabName) throws ManifoldCFException, IOException {
+
+		// Call the Velocity tempaltes for each tab
+		Map<String, String> paramMap = new HashMap<String, String>();
+
+		// Set the tab name
+		paramMap.put("TabName", tabName);
+
+		// Fill in the parameters
+		fillInServerConfigurationMap(paramMap, out, parameters);
+
+		// Server tab
+		Messages.outputResourceWithVelocity(out, locale, EDIT_CONFIG_FORWARD_SERVER, paramMap, true);
+	}
+
+	@Override
+	public String processConfigurationPost(IThreadContext thredContext, IPostParameters variableContext,
+			ConfigParams parameters) {
+
+		String nuxeoProtocol = variableContext.getParameter(PARAMETER_PREFIX + NuxeoConfiguration.Server.PROTOCOL);
+		if (nuxeoProtocol != null)
+			parameters.setParameter(NuxeoConfiguration.Server.PROTOCOL, nuxeoProtocol);
+
+		String nuxeoHost = variableContext.getParameter(PARAMETER_PREFIX + NuxeoConfiguration.Server.HOST);
+		if (nuxeoHost != null)
+			parameters.setParameter(NuxeoConfiguration.Server.HOST, nuxeoHost);
+
+		String nuxeoPort = variableContext.getParameter(PARAMETER_PREFIX + NuxeoConfiguration.Server.PORT);
+		if (nuxeoPort != null)
+			parameters.setParameter(NuxeoConfiguration.Server.PORT, nuxeoPort);
+
+		String nuxeoPath = variableContext.getParameter(PARAMETER_PREFIX + NuxeoConfiguration.Server.PATH);
+		if (nuxeoPath != null)
+			parameters.setParameter(NuxeoConfiguration.Server.PATH, nuxeoPath);
+
+		String nuxeoUsername = variableContext.getParameter(PARAMETER_PREFIX + NuxeoConfiguration.Server.USERNAME);
+		if (nuxeoUsername != null)
+			parameters.setParameter(NuxeoConfiguration.Server.USERNAME, nuxeoUsername);
+
+		String nuxeoPassword = variableContext.getParameter(PARAMETER_PREFIX + NuxeoConfiguration.Server.PASSWORD);
+		if (nuxeoPassword != null)
+			parameters.setObfuscatedParameter(NuxeoConfiguration.Server.PASSWORD,
+					variableContext.mapKeyToPassword(nuxeoPassword));
+
+		return null; // It returns null if the configuration has been successful
+	}
+
+	/** AUTHORITY **/
+	@Override
+	public AuthorizationResponse getDefaultAuthorizationResponse(String userName) {
+		return RESPONSE_UNREACHABLE;
+	}
+
+	@Override
+	public AuthorizationResponse getAuthorizationResponse(String username) {
+		try {
+			List<String> authorities = getGroupsByUser(username);
+			if (authorities == null || authorities.isEmpty()) {
+				return RESPONSE_USERNOTFOUND;
+			} else {
+				return new AuthorizationResponse(authorities.toArray(new String[0]), AuthorizationResponse.RESPONSE_OK);
+			}
+
+		} catch (NuxeoClientException e) {
+			return RESPONSE_USERNOTFOUND;
+		} catch (Exception e) {
+			return RESPONSE_UNREACHABLE;
+		}
+	}
+
+	public List<String> getGroupsByUser(String username) {
+
+		List<String> authorities = null;
+
+		User user = nuxeoClient.getUserManager().fetchUser(username);
+		if (user != null) {
+			authorities = user.getGroups();
+			authorities.add(user.getUserName());
+		}
 
-  // Templates
-  /**
-   * Javascript to check the configuration parameters
-   */
-  private static final String EDIT_CONFIG_HEADER_FORWARD = "editConfiguration_conf.js";
-
-  /**
-   * Server edit tab template
-   */
-  private static final String EDIT_CONFIG_FORWARD_SERVER = "editConfiguration_conf_server.html";
-
-  /**
-   * Server view tab template
-   */
-  private static final String VIEW_CONFIG_FORWARD = "viewConfiguration_conf.html";
-
-  /* Nuxeo instance parameters */
-  protected String protocol = null;
-  protected String host = null;
-  protected String port = null;
-  protected String path = null;
-  protected String username = null;
-  protected String password = null;
-
-  protected NuxeoClient nuxeoClient = null;
-
-  //Constructor
-  public NuxeoAuthorityConnector() {
-    super();
-  }
-
-  public void setNuxeoClient(NuxeoClient nuxeoClient) {
-    this.nuxeoClient = nuxeoClient;
-  }
-
-  // Close the connection.
-  public void disconenct() throws ManifoldCFException {
-    if (nuxeoClient != null)
-      nuxeoClient = null;
-
-    protocol = null;
-    host = null;
-    port = null;
-    path = null;
-    username = null;
-    password = null;
-  }
-
-  /** CONNECTION **/
-  
-  //Makes connection to server
-  @Override
-  public void connect(ConfigParams configParams) {
-    super.connect(configParams);
-
-    protocol = params.getParameter(NuxeoConfiguration.Server.PROTOCOL);
-    host = params.getParameter(NuxeoConfiguration.Server.HOST);
-    port = params.getParameter(NuxeoConfiguration.Server.PORT);
-    path = params.getParameter(NuxeoConfiguration.Server.PATH);
-    username = params.getParameter(NuxeoConfiguration.Server.USERNAME);
-    password = params.getObfuscatedParameter(NuxeoConfiguration.Server.PASSWORD);
-
-    try {
-      initNuxeoClient();
-    } catch (ManifoldCFException manifoldCFException) {
-      manifoldCFException.printStackTrace();
-    }
-  }
-
-  /**
-   * Check the connection
-   */
-  @Override
-  public String check() throws ManifoldCFException {
-    try {
-      if (!isConnected()) {
-        initNuxeoClient();
-      }
-
-      Boolean result = nuxeoClient.checkAuth();
-
-      if (result)
-        return super.check();
-      else
-        throw new ManifoldCFException("Nuxeo instance could not be reached");
-
-    } catch (ServiceInterruption serviceInterruption) {
-      return "Connection temporarily failed: " + serviceInterruption.getMessage();
-    } catch (ManifoldCFException manifoldCFException) {
-      return "Connection failed: " + manifoldCFException.getMessage();
-    } catch (Exception e) {
-      return "Connection failed: " + e.getMessage();
-    }
-  }
-
-  /**
-   * Initialize Nuxeo client using the configured parameters.
-   * 
-   * @throws ManifoldCFException
-   */
-  private void initNuxeoClient() throws ManifoldCFException {
-    int portInt;
-
-    if (nuxeoClient == null) {
-
-      if (StringUtils.isEmpty(protocol)) {
-        throw new ManifoldCFException(
-            "Parameter " + NuxeoConfiguration.Server.PROTOCOL + " required but not set");
-      }
-
-      if (StringUtils.isEmpty(host)) {
-        throw new ManifoldCFException("Parameter " + NuxeoConfiguration.Server.HOST + " required but not set");
-      }
-
-      if (port != null && port.length() > 0) {
-        try {
-          portInt = Integer.parseInt(port);
-        } catch (NumberFormatException formatException) {
-          throw new ManifoldCFException("Bad number: " + formatException.getMessage(), formatException);
-        }
-      } else {
-        if (protocol.toLowerCase(Locale.ROOT).equals("http")) {
-          portInt = 80;
-        } else {
-          portInt = 443;
-        }
-      }
-
-      nuxeoClient = new NuxeoClient(protocol, host, portInt, path, username, password);
-
-    }
-  }
-
-  /**
-   * @return true if the connector instance is connected.
-   */
-  @Override
-  public boolean isConnected() {
-    return nuxeoClient != null;
-  }
-
-  /** VIEW CONFIGURATION **/
-  @Override
-  public void viewConfiguration(IThreadContext threadContext, IHTTPOutput out, Locale locale, ConfigParams parameters)
-      throws ManifoldCFException, IOException {
-
-    Map<String, String> paramMap = new HashMap<String, String>();
-
-    fillInServerConfigurationMap(paramMap, out, parameters);
-
-    Messages.outputResourceWithVelocity(out, locale, VIEW_CONFIG_FORWARD, paramMap, true);
-  }
-
-  private static void fillInServerConfigurationMap(Map<String, String> serverMap, IPasswordMapperActivity mapper,
-      ConfigParams parameters) {
-
-    String nuxeoProtocol = parameters.getParameter(NuxeoConfiguration.Server.PROTOCOL);
-    String nuxeoHost = parameters.getParameter(NuxeoConfiguration.Server.HOST);
-    String nuxeoPort = parameters.getParameter(NuxeoConfiguration.Server.PORT);
-    String nuxeoPath = parameters.getParameter(NuxeoConfiguration.Server.PATH);
-    String nuxeoUsername = parameters.getParameter(NuxeoConfiguration.Server.USERNAME);
-    String nuxeoPassword = parameters.getParameter(NuxeoConfiguration.Server.PASSWORD);
-
-    if (nuxeoProtocol == null)
-      nuxeoProtocol = NuxeoConfiguration.Server.PROTOCOL_DEFAULT_VALUE;
-    if (nuxeoHost == null)
-      nuxeoHost = NuxeoConfiguration.Server.HOST_DEFAULT_VALUE;
-    if (nuxeoPort == null)
-      nuxeoPort = NuxeoConfiguration.Server.PORT_DEFAULT_VALUE;
-    if (nuxeoPath == null)
-      nuxeoPath = NuxeoConfiguration.Server.PATH_DEFAULT_VALUE;
-    if (nuxeoUsername == null)
-      nuxeoUsername = NuxeoConfiguration.Server.USERNAME_DEFAULT_VALUE;
-    if (nuxeoPassword == null)
-      nuxeoPassword = NuxeoConfiguration.Server.PASSWORD_DEFAULT_VALUE;
-    else
-      nuxeoPassword = mapper.mapKeyToPassword(nuxeoPassword);
-
-    serverMap.put(PARAMETER_PREFIX + NuxeoConfiguration.Server.PROTOCOL, nuxeoProtocol);
-    serverMap.put(PARAMETER_PREFIX + NuxeoConfiguration.Server.HOST, nuxeoHost);
-    serverMap.put(PARAMETER_PREFIX + NuxeoConfiguration.Server.PORT, nuxeoPort);
-    serverMap.put(PARAMETER_PREFIX + NuxeoConfiguration.Server.PATH, nuxeoPath);
-    serverMap.put(PARAMETER_PREFIX + NuxeoConfiguration.Server.USERNAME, nuxeoUsername);
-    serverMap.put(PARAMETER_PREFIX + NuxeoConfiguration.Server.PASSWORD, nuxeoPassword);
-  }
-
-  /** CONFIGURATION CONNECTOR **/
-  @Override
-  public void outputConfigurationHeader(IThreadContext threadContext, IHTTPOutput out, Locale locale,
-      ConfigParams parameters, List<String> tabsArray) throws ManifoldCFException, IOException {
-
-    // Server tab
-    tabsArray.add(Messages.getString(locale, CONF_SERVER_TAB_PROPERTY));
-
-    Map<String, String> paramMap = new HashMap<String, String>();
-
-    // Fill in the parameters form each tab
-    fillInServerConfigurationMap(paramMap, out, parameters);
-
-    Messages.outputResourceWithVelocity(out, locale, EDIT_CONFIG_HEADER_FORWARD, paramMap, true);
-  }
-
-  @Override
-  public void outputConfigurationBody(IThreadContext threadContext, IHTTPOutput out, Locale locale,
-      ConfigParams parameters, String tabName) throws ManifoldCFException, IOException {
-
-    // Call the Velocity tempaltes for each tab
-    Map<String, String> paramMap = new HashMap<String, String>();
-
-    // Set the tab name
-    paramMap.put("TabName", tabName);
-
-    // Fill in the parameters
-    fillInServerConfigurationMap(paramMap, out, parameters);
-
-    // Server tab
-    Messages.outputResourceWithVelocity(out, locale, EDIT_CONFIG_FORWARD_SERVER, paramMap, true);
-  }
-
-  @Override
-  public String processConfigurationPost(IThreadContext thredContext, IPostParameters variableContext,
-      ConfigParams parameters) {
-
-    String nuxeoProtocol = variableContext.getParameter(PARAMETER_PREFIX + NuxeoConfiguration.Server.PROTOCOL);
-    if (nuxeoProtocol != null)
-      parameters.setParameter(NuxeoConfiguration.Server.PROTOCOL, nuxeoProtocol);
-
-    String nuxeoHost = variableContext.getParameter(PARAMETER_PREFIX + NuxeoConfiguration.Server.HOST);
-    if (nuxeoHost != null)
-      parameters.setParameter(NuxeoConfiguration.Server.HOST, nuxeoHost);
-
-    String nuxeoPort = variableContext.getParameter(PARAMETER_PREFIX + NuxeoConfiguration.Server.PORT);
-    if (nuxeoPort != null)
-      parameters.setParameter(NuxeoConfiguration.Server.PORT, nuxeoPort);
-
-    String nuxeoPath = variableContext.getParameter(PARAMETER_PREFIX + NuxeoConfiguration.Server.PATH);
-    if (nuxeoPath != null)
-      parameters.setParameter(NuxeoConfiguration.Server.PATH, nuxeoPath);
-
-    String nuxeoUsername = variableContext.getParameter(PARAMETER_PREFIX + NuxeoConfiguration.Server.USERNAME);
-    if (nuxeoUsername != null)
-      parameters.setParameter(NuxeoConfiguration.Server.USERNAME, nuxeoUsername);
-
-    String nuxeoPassword = variableContext.getParameter(PARAMETER_PREFIX + NuxeoConfiguration.Server.PASSWORD);
-    if (nuxeoPassword != null)
-      parameters.setObfuscatedParameter(NuxeoConfiguration.Server.PASSWORD,
-          variableContext.mapKeyToPassword(nuxeoPassword));
-
-    return null; // It returns null if the configuration has been successful
-  }
-
-  /** AUTHORITY **/
-  @Override
-  public AuthorizationResponse getDefaultAuthorizationResponse(String userName) {
-    return RESPONSE_UNREACHABLE;
-  }
-
-  @Override
-  public AuthorizationResponse getAuthorizationResponse(String username) throws ManifoldCFException {
-    try {
-      List<String> authorities = nuxeoClient.getUserAuthorities(username);
-      if (authorities == null || authorities.isEmpty()) {
-        return RESPONSE_USERNOTFOUND;
-      } else {
-        return new AuthorizationResponse(authorities.toArray(new String[0]), AuthorizationResponse.RESPONSE_OK);
-      }
-
-    } catch (Exception e) {
-      return RESPONSE_UNREACHABLE;
-    }
-  }
+		return authorities;
+	}
 }

Modified: manifoldcf/branches/CONNECTORS-1290-2/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/Messages.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1290-2/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/Messages.java?rev=1791418&r1=1791417&r2=1791418&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-1290-2/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/Messages.java (original)
+++ manifoldcf/branches/CONNECTORS-1290-2/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/Messages.java Fri Apr 14 21:20:25 2017
@@ -1,21 +1,3 @@
-/* $Id$ */
-
-/**
-* 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.nuxeo;
 
 import java.util.Locale;
@@ -26,98 +8,98 @@ import org.apache.manifoldcf.core.interf
 
 public class Messages extends org.apache.manifoldcf.ui.i18n.Messages {
 
-  public static final String DEFAULT_BUNDLE_NAME = "org.apache.manifoldcf.crawler.connectors.nuxeo.common";
-  public static final String DEFAULT_PATH_NAME = "org.apache.manifoldcf.crawler.connectors.nuxeo";
+	public static final String DEFAULT_BUNDLE_NAME = "org.apache.manifoldcf.crawler.connectors.nuxeo.common";
+	public static final String DEFAULT_PATH_NAME = "org.apache.manifoldcf.crawler.connectors.nuxeo";
 
-  /** 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);
-  }
+	/** 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);
+	}
 
 }

Modified: manifoldcf/branches/CONNECTORS-1290-2/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/NuxeoConfiguration.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1290-2/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/NuxeoConfiguration.java?rev=1791418&r1=1791417&r2=1791418&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-1290-2/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/NuxeoConfiguration.java (original)
+++ manifoldcf/branches/CONNECTORS-1290-2/connectors/nuxeo/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/nuxeo/NuxeoConfiguration.java Fri Apr 14 21:20:25 2017
@@ -1,21 +1,3 @@
-/* $Id$ */
-
-/**
-* 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.nuxeo;
 
 /**
@@ -29,35 +11,35 @@ package org.apache.manifoldcf.crawler.co
  */
 public class NuxeoConfiguration {
 
-  public static interface Server {
+	public static interface Server {
 
-    public static final String USERNAME = "username";
-    public static final String PASSWORD = "password";
-    public static final String PROTOCOL = "protocol";
-    public static final String HOST = "host";
-    public static final String PORT = "port";
-    public static final String PATH = "path";
-
-    public static final String PROTOCOL_DEFAULT_VALUE = "http";
-    public static final String HOST_DEFAULT_VALUE = "";
-    public static final String PORT_DEFAULT_VALUE = "8080";
-    public static final String PATH_DEFAULT_VALUE = "/nuxeo";
-    public static final String USERNAME_DEFAULT_VALUE = "";
-    public static final String PASSWORD_DEFAULT_VALUE = "";
-
-  }
-
-  public static interface Specification {
-
-    public static final String DOMAINS = "domains";
-    public static final String DOMAIN = "domain";
-    public static final String DOMAIN_KEY = "key";
-    public static final String DOCUMENTS = "documents";
-    public static final String PROCESS_TAGS = "process_tags";
-    public static final String PROCESS_ATTACHMENTS = "process_attachments";
-    public static final String DOCUMENTS_TYPE = "documentsType";
-    public static final String DOCUMENT_TYPE = "documentType";
-    public static final String DOCUMENT_TYPE_KEY = "key";
+		public static final String USERNAME = "username";
+		public static final String PASSWORD = "password";
+		public static final String PROTOCOL = "protocol";
+		public static final String HOST = "host";
+		public static final String PORT = "port";
+		public static final String PATH = "path";
+
+		public static final String PROTOCOL_DEFAULT_VALUE = "http";
+		public static final String HOST_DEFAULT_VALUE = "";
+		public static final String PORT_DEFAULT_VALUE = "8080";
+		public static final String PATH_DEFAULT_VALUE = "/nuxeo";
+		public static final String USERNAME_DEFAULT_VALUE = "";
+		public static final String PASSWORD_DEFAULT_VALUE = "";
+
+	}
+
+	public static interface Specification {
+
+		public static final String DOMAINS = "domains";
+		public static final String DOMAIN = "domain";
+		public static final String DOMAIN_KEY = "key";
+		public static final String DOCUMENTS = "documents";
+		public static final String PROCESS_TAGS = "process_tags";
+		public static final String PROCESS_ATTACHMENTS = "process_attachments";
+		public static final String DOCUMENTS_TYPE = "documentsType";
+		public static final String DOCUMENT_TYPE = "documentType";
+		public static final String DOCUMENT_TYPE_KEY = "key";
 
-  }
+	}
 }



Mime
View raw message