manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sch...@apache.org
Subject svn commit: r1812793 [1/2] - in /manifoldcf/branches/CONNECTORS-1468: ./ connectors/ connectors/rocketchat/ connectors/rocketchat/connector/ connectors/rocketchat/connector/src/ connectors/rocketchat/connector/src/main/ connectors/rocketchat/connector/...
Date Fri, 20 Oct 2017 22:23:24 GMT
Author: schuch
Date: Fri Oct 20 22:23:24 2017
New Revision: 1812793

URL: http://svn.apache.org/viewvc?rev=1812793&view=rev
Log:
Implemented the Rocket.Chat notification connector

Added:
    manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/   (with props)
    manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/.gitignore
    manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/build.xml   (with props)
    manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/
    manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/
    manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/
    manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/java/
    manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/java/org/
    manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/java/org/apache/
    manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/java/org/apache/manifoldcf/
    manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/java/org/apache/manifoldcf/crawler/
    manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/java/org/apache/manifoldcf/crawler/notifications/
    manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/java/org/apache/manifoldcf/crawler/notifications/rocketchat/
    manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/java/org/apache/manifoldcf/crawler/notifications/rocketchat/Messages.java   (with props)
    manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/java/org/apache/manifoldcf/crawler/notifications/rocketchat/RocketChatConfig.java   (with props)
    manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/java/org/apache/manifoldcf/crawler/notifications/rocketchat/RocketChatConnector.java   (with props)
    manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/java/org/apache/manifoldcf/crawler/notifications/rocketchat/RocketChatCredentials.java   (with props)
    manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/java/org/apache/manifoldcf/crawler/notifications/rocketchat/RocketChatMessage.java   (with props)
    manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/java/org/apache/manifoldcf/crawler/notifications/rocketchat/RocketChatSession.java   (with props)
    manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/native2ascii/
    manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/native2ascii/org/
    manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/native2ascii/org/apache/
    manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/native2ascii/org/apache/manifoldcf/
    manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/
    manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/notifications/
    manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/notifications/rocketchat/
    manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/notifications/rocketchat/common_en_US.properties   (with props)
    manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/notifications/rocketchat/common_es_ES.properties   (with props)
    manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/notifications/rocketchat/common_ja_JP.properties   (with props)
    manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/notifications/rocketchat/common_zh_CN.properties   (with props)
    manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/resources/
    manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/resources/org/
    manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/resources/org/apache/
    manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/resources/org/apache/manifoldcf/
    manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/resources/org/apache/manifoldcf/crawler/
    manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/resources/org/apache/manifoldcf/crawler/notifications/
    manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/resources/org/apache/manifoldcf/crawler/notifications/rocketchat/
    manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/resources/org/apache/manifoldcf/crawler/notifications/rocketchat/ConfigurationHeader.js   (with props)
    manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/resources/org/apache/manifoldcf/crawler/notifications/rocketchat/ConfigurationView.html   (with props)
    manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/resources/org/apache/manifoldcf/crawler/notifications/rocketchat/Configuration_Server.html   (with props)
    manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/resources/org/apache/manifoldcf/crawler/notifications/rocketchat/SpecificationHeader.js   (with props)
    manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/resources/org/apache/manifoldcf/crawler/notifications/rocketchat/SpecificationView.html   (with props)
    manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/resources/org/apache/manifoldcf/crawler/notifications/rocketchat/Specification_Message.html   (with props)
    manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/pom.xml   (with props)
Modified:
    manifoldcf/branches/CONNECTORS-1468/CHANGES.txt
    manifoldcf/branches/CONNECTORS-1468/connectors/pom.xml

Modified: manifoldcf/branches/CONNECTORS-1468/CHANGES.txt
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1468/CHANGES.txt?rev=1812793&r1=1812792&r2=1812793&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-1468/CHANGES.txt (original)
+++ manifoldcf/branches/CONNECTORS-1468/CHANGES.txt Fri Oct 20 22:23:24 2017
@@ -3,6 +3,9 @@ $Id$
 
 ======================= 2.9-dev =====================
 
+CONNECTORS-1468: Adds Rocket.Chat Notification Connector
+(Markus Schuch)
+
 CONNECTORS-1459: Allow the Tika service to override the mime type
 in the metadata.
 (Julien Massiera)

Modified: manifoldcf/branches/CONNECTORS-1468/connectors/pom.xml
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1468/connectors/pom.xml?rev=1812793&r1=1812792&r2=1812793&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-1468/connectors/pom.xml (original)
+++ manifoldcf/branches/CONNECTORS-1468/connectors/pom.xml Fri Oct 20 22:23:24 2017
@@ -72,6 +72,7 @@
     <module>opennlp</module>
     <module>nuxeo</module>
     <module>contentlimiter</module>
+    <module>rocketchat</module>
   </modules>
 
 </project>

Propchange: manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Oct 20 22:23:24 2017
@@ -0,0 +1,2 @@
+build
+dist

Added: manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/.gitignore
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/.gitignore?rev=1812793&view=auto
==============================================================================
--- manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/.gitignore (added)
+++ manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/.gitignore Fri Oct 20 22:23:24 2017
@@ -0,0 +1,3 @@
+/.classpath
+/.project
+/.settings/

Added: manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/build.xml
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/build.xml?rev=1812793&view=auto
==============================================================================
--- manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/build.xml (added)
+++ manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/build.xml Fri Oct 20 22:23:24 2017
@@ -0,0 +1,40 @@
+<!--
+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="rocketchat" default="all">
+
+    <property environment="env"/>
+    <condition property="mcf-dist" value="${env.MCFDISTPATH}">
+        <isset property="env.MCFDISTPATH"/>
+    </condition>
+    <property name="abs-dist" location="../../dist"/>
+    <condition property="mcf-dist" value="${abs-dist}">
+        <not>
+            <isset property="env.MCFDISTPATH"/>
+        </not>
+    </condition>
+
+    <import file="${mcf-dist}/connector-build.xml"/>
+
+    <target name="deliver-connector" depends="mcf-connector-build.deliver-connector">
+        <antcall target="general-add-notification-connector">
+            <param name="connector-label" value="Rocket.Chat"/>
+            <param name="connector-class" value="org.apache.manifoldcf.crawler.notifications.rocketchat.RocketChatConnector"/>
+        </antcall>
+    </target>
+
+</project>
\ No newline at end of file

Propchange: manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/build.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/java/org/apache/manifoldcf/crawler/notifications/rocketchat/Messages.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/java/org/apache/manifoldcf/crawler/notifications/rocketchat/Messages.java?rev=1812793&view=auto
==============================================================================
--- manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/java/org/apache/manifoldcf/crawler/notifications/rocketchat/Messages.java (added)
+++ manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/java/org/apache/manifoldcf/crawler/notifications/rocketchat/Messages.java Fri Oct 20 22:23:24 2017
@@ -0,0 +1,142 @@
+/* $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.notifications.rocketchat;
+
+import java.util.Locale;
+import java.util.Map;
+import org.apache.manifoldcf.core.interfaces.ManifoldCFException;
+import org.apache.manifoldcf.crawler.notifications.rocketchat.Messages;
+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.notifications.rocketchat.common";
+  public static final String DEFAULT_PATH_NAME="org.apache.manifoldcf.crawler.notifications.rocketchat";
+
+  /** 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);
+  }
+
+}
+

Propchange: manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/java/org/apache/manifoldcf/crawler/notifications/rocketchat/Messages.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/java/org/apache/manifoldcf/crawler/notifications/rocketchat/RocketChatConfig.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/java/org/apache/manifoldcf/crawler/notifications/rocketchat/RocketChatConfig.java?rev=1812793&view=auto
==============================================================================
--- manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/java/org/apache/manifoldcf/crawler/notifications/rocketchat/RocketChatConfig.java (added)
+++ manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/java/org/apache/manifoldcf/crawler/notifications/rocketchat/RocketChatConfig.java Fri Oct 20 22:23:24 2017
@@ -0,0 +1,88 @@
+/* $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.notifications.rocketchat;
+
+
+/**
+* Parameters data for the Rocket.Chat notification connector.
+*/
+public class RocketChatConfig {
+
+  /**
+   * Rocket.Chat Server URL
+   */
+  public static final String SERVER_URL_PARAM = "serverUrl";
+  
+  /**
+   * Rocket.Chat Username or Email
+   */
+  public static final String USER_PARAM = "user";
+  
+  /**
+   * Rocket.Chat Password
+   */
+  public static final String PASSWORD_PARAM = "password";
+
+  /**
+   * Proxy Host
+   */
+  public static final String PROXY_HOST_PARAM = "proxyHost";
+
+  /**
+   * Proxy Port
+   */
+
+  public static final String PROXY_PORT_PARAM = "proxyPort";
+
+  /**
+   * Proxy Username
+   */
+  public static final String PROXY_USERNAME_PARAM = "proxyUsername";
+
+  /**
+   * Proxy Password
+   */
+  public static final String PROXY_PASSWORD_PARAM = "proxyPassword";
+
+  /**
+   * Proxy Domain
+   */
+  public static final String PROXY_DOMAIN_PARAM = "proxyDomain";
+
+  /**
+  * URL template
+  */
+  public static final String URL_PARAM = "url";
+
+  // Specification nodes
+  public static final String NODE_FINISHED = "finished";
+  public static final String NODE_ERRORABORTED = "erroraborted";
+  public static final String NODE_MANUALABORTED = "manualaborted";
+  public static final String NODE_MANUALPAUSED = "manualpaused";
+  public static final String NODE_SCHEDULEPAUSED = "schedulepaused";
+  public static final String NODE_RESTARTED = "restarted";
+
+  public static final String NODE_CHANNEL = "channel";
+  public static final String NODE_MESSAGE = "message";
+
+  public static final String ATTRIBUTE_NAME = "name";
+  public static final String ATTRIBUTE_VALUE = "value";
+
+
+}
\ No newline at end of file

Propchange: manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/java/org/apache/manifoldcf/crawler/notifications/rocketchat/RocketChatConfig.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/java/org/apache/manifoldcf/crawler/notifications/rocketchat/RocketChatConnector.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/java/org/apache/manifoldcf/crawler/notifications/rocketchat/RocketChatConnector.java?rev=1812793&view=auto
==============================================================================
--- manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/java/org/apache/manifoldcf/crawler/notifications/rocketchat/RocketChatConnector.java (added)
+++ manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/java/org/apache/manifoldcf/crawler/notifications/rocketchat/RocketChatConnector.java Fri Oct 20 22:23:24 2017
@@ -0,0 +1,924 @@
+/* $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.notifications.rocketchat;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+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.core.interfaces.ConfigParams;
+import org.apache.manifoldcf.core.interfaces.IHTTPOutput;
+import org.apache.manifoldcf.core.interfaces.IPasswordMapperActivity;
+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.manifoldcf.crawler.system.Logging;
+
+/**
+*/
+public class RocketChatConnector extends org.apache.manifoldcf.crawler.notifications.BaseNotificationConnector {
+
+  protected final static long SESSION_EXPIRATION_MILLISECONDS = 300000L;
+
+  // Local variables.
+  protected long sessionExpiration = -1L;
+
+  // Parameters for establishing a session
+
+  protected String serverUrl = null;
+  protected String user;
+  protected String password;
+
+  // Parameters for proxy connection
+  protected RocketChatSession.ProxySettings proxySettings = null;
+
+  // Local session handle
+  protected RocketChatSession session = null;
+
+  //////////////////////////////////Start of Basic Connector Methods/////////////////////////
+
+  /**
+  * Connect.
+  *
+  * @param configParameters is the set of configuration parameters, which
+  * in this case describe the root directory.
+  */
+  @Override
+  public void connect(ConfigParams configParameters) {
+    super.connect(configParameters);
+    this.serverUrl = configParameters.getParameter(RocketChatConfig.SERVER_URL_PARAM);
+    this.user = configParameters.getParameter(RocketChatConfig.USER_PARAM);
+    this.password = configParameters.getObfuscatedParameter(RocketChatConfig.PASSWORD_PARAM);
+
+    String proxyHost = configParameters.getParameter(RocketChatConfig.PROXY_HOST_PARAM);
+    String proxyPortString = configParameters.getParameter(RocketChatConfig.PROXY_PORT_PARAM);
+    if(StringUtils.isNotEmpty(proxyHost) && StringUtils.isNotEmpty(proxyPortString)) {
+      String proxyUsername = configParameters.getParameter(RocketChatConfig.PROXY_USERNAME_PARAM);
+      String proxyPassword = configParameters.getObfuscatedParameter(RocketChatConfig.PROXY_PASSWORD_PARAM);
+      String proxyDomain = configParameters.getParameter(RocketChatConfig.PROXY_DOMAIN_PARAM);
+      this.proxySettings = new RocketChatSession.ProxySettings(proxyHost, proxyPortString, proxyUsername, proxyPassword, proxyDomain);
+    } else {
+      Logging.connectors.info("Using no proxy settings - no proxyHost and no proxyPort found.");
+    }
+  }
+
+  /**
+  * Close the connection. Call this before discarding this instance of the
+  * repository connector.
+  */
+  @Override
+  public void disconnect()
+    throws ManifoldCFException {
+    this.serverUrl = null;
+    this.user = null;
+    this.password = null;
+    this.proxySettings = null;
+    finalizeConnection();
+    super.disconnect();
+  }
+
+  /**
+  * This method is periodically called for all connectors that are connected but not
+  * in active use.
+  */
+  @Override
+  public void poll() throws ManifoldCFException {
+    if (session != null)
+    {
+      if (System.currentTimeMillis() >= sessionExpiration)
+        finalizeConnection();
+    }
+  }
+
+  /**
+  * Test the connection. Returns a string describing the connection integrity.
+  *
+  * @return the connection's status as a displayable string.
+  */
+  @Override
+  public String check()
+      throws ManifoldCFException {
+    try {
+      checkConnection();
+      return super.check();
+    } catch (ServiceInterruption e) {
+      return "Connection temporarily failed: " + e.getMessage();
+    } catch (ManifoldCFException e) {
+      return "Connection failed: " + e.getMessage();
+    }
+  }
+
+  protected void checkConnection() throws ManifoldCFException, ServiceInterruption {
+    // Force a re-connection
+    finalizeConnection();
+    getSession();
+    try {
+      CheckConnectionThread cct = new CheckConnectionThread(session);
+      cct.start();
+      cct.finishUp();
+    } catch (InterruptedException e) {
+      throw new ManifoldCFException(e.getMessage(),ManifoldCFException.INTERRUPTED);
+    } catch (IOException e) {
+      handleIOException(e,"checking the connection");
+    }
+  }
+
+  protected void getSession()
+    throws ManifoldCFException, ServiceInterruption {
+    if (session == null) {
+
+      // Check that all the required parameters are there.
+      if (serverUrl == null)
+        throw new ManifoldCFException("Missing serverUrl parameter");
+      if (user == null)
+        throw new ManifoldCFException("Missing user parameter");
+      if (password == null)
+        throw new ManifoldCFException("Missing password parameter");
+
+      // Create a session.
+      try {
+        ConnectThread connectThread = new ConnectThread(serverUrl, user, password, proxySettings);
+        connectThread.start();
+        session = connectThread.finishUp();
+      } catch (InterruptedException e) {
+        throw new ManifoldCFException(e.getMessage(),ManifoldCFException.INTERRUPTED);
+      } catch (IOException e) {
+        handleIOException(e, "connecting");
+      }
+    }
+    sessionExpiration = System.currentTimeMillis() + SESSION_EXPIRATION_MILLISECONDS;
+  }
+
+  protected void finalizeConnection() {
+    if (session != null) {
+      try {
+        CloseSessionThread closeSessionThread = new CloseSessionThread(session);
+        closeSessionThread.start();
+        closeSessionThread.finishUp();
+      } catch (InterruptedException e) {
+      } catch (IOException e) {
+        Logging.connectors.warn("Error while closing connection to server: " + e.getMessage(),e);
+      } finally {
+        session = null;
+      }
+    }
+  }
+
+  ///////////////////////////////End of Basic Connector Methods////////////////////////////////////////
+
+  //////////////////////////////Start of Notification Connector Method///////////////////////////////////
+
+  /** Notify of job stop due to error abort.
+  *@param spec is the notification specification.
+  */
+  @Override
+  public void notifyOfJobStopErrorAbort(final Specification spec)
+    throws ManifoldCFException, ServiceInterruption {
+    sendRocketChatMessage(spec, RocketChatConfig.NODE_ERRORABORTED);
+  }
+
+  /** Notify of job stop due to manual abort.
+  *@param spec is the notification specification.
+  */
+  @Override
+  public void notifyOfJobStopManualAbort(final Specification spec)
+    throws ManifoldCFException, ServiceInterruption {
+    sendRocketChatMessage(spec, RocketChatConfig.NODE_MANUALABORTED);
+  }
+
+  /** Notify of job stop due to manual pause.
+  *@param spec is the notification specification.
+  */
+  @Override
+  public void notifyOfJobStopManualPause(final Specification spec)
+    throws ManifoldCFException, ServiceInterruption {
+    sendRocketChatMessage(spec, RocketChatConfig.NODE_MANUALPAUSED);
+  }
+
+  /** Notify of job stop due to schedule pause.
+  *@param spec is the notification specification.
+  */
+  @Override
+  public void notifyOfJobStopSchedulePause(final Specification spec)
+    throws ManifoldCFException, ServiceInterruption {
+    sendRocketChatMessage(spec, RocketChatConfig.NODE_SCHEDULEPAUSED);
+  }
+
+  /** Notify of job stop due to restart.
+  *@param spec is the notification specification.
+  */
+  @Override
+  public void notifyOfJobStopRestart(final Specification spec)
+    throws ManifoldCFException, ServiceInterruption {
+    sendRocketChatMessage(spec, RocketChatConfig.NODE_RESTARTED);
+  }
+
+  /** Notify of job end.
+  *@param spec is the notification specification.
+  */
+  @Override
+  public void notifyOfJobEnd(final Specification spec)
+    throws ManifoldCFException, ServiceInterruption {
+    sendRocketChatMessage(spec, RocketChatConfig.NODE_FINISHED);
+  }
+
+  protected void sendRocketChatMessage(final Specification spec, final String nodeType)
+    throws ManifoldCFException, ServiceInterruption
+  {
+    String channel = "";
+    String message = "";
+    for (int i = 0; i < spec.getChildCount(); i++) {
+      SpecificationNode sn = spec.getChild(i);
+      if (sn.getType().equals(RocketChatConfig.NODE_CHANNEL))
+        channel = sn.getAttributeValue(RocketChatConfig.ATTRIBUTE_VALUE);
+      else if (sn.getType().equals(RocketChatConfig.NODE_MESSAGE))
+        message = sn.getAttributeValue(RocketChatConfig.ATTRIBUTE_VALUE);
+    }
+    // Look for node of the specified type
+    if (nodeType != null)
+    {
+      for (int i = 0; i < spec.getChildCount(); i++) {
+        SpecificationNode childNode = spec.getChild(i);
+        if (childNode.getType().equals(nodeType))
+        {
+          for (int j = 0; j < childNode.getChildCount(); j++) {
+            SpecificationNode sn = childNode.getChild(j);
+            if (sn.getType().equals(RocketChatConfig.NODE_CHANNEL))
+              channel = sn.getAttributeValue(RocketChatConfig.ATTRIBUTE_VALUE);
+            else if (sn.getType().equals(RocketChatConfig.NODE_MESSAGE))
+              message = sn.getAttributeValue(RocketChatConfig.ATTRIBUTE_VALUE);
+          }
+        }
+      }
+    }
+
+    if (StringUtils.isBlank(message)) {
+      return;
+    }
+
+    // Construct and send a rocketchat message
+    getSession();
+
+    SendThread st = new SendThread(session, channel, message);
+    st.start();
+    try {
+      st.finishUp();
+    } catch (InterruptedException e) {
+      throw new ManifoldCFException(e.getMessage(),ManifoldCFException.INTERRUPTED);
+    } catch (IOException e) {
+      handleIOException(e,"sending rocketchat message");
+    }
+  }
+
+
+  //////////////////////////////End of Notification Connector Methods///////////////////////////////////
+
+
+  ///////////////////////////////////////Start of Configuration UI/////////////////////////////////////
+
+  /**
+  * Output the configuration header section.
+  * This method is called in the head section of the connector's configuration page. Its purpose is to
+  * add the required tabs to the list, and to output any javascript methods that might be needed by
+  * the configuration editing HTML.
+  * The connector does not need to be connected for this method to be called.
+  *
+  * @param threadContext is the local thread context.
+  * @param out is the output to which any HTML should be sent.
+  * @param locale is the desired locale.
+  * @param parameters are the configuration parameters, as they currently exist, for this connection being configured.
+  * @param tabsArray is an array of tab names. Add to this array any tab names that are specific to the connector.
+  */
+  @Override
+  public void outputConfigurationHeader(IThreadContext threadContext, IHTTPOutput out,
+    Locale locale, ConfigParams parameters, List<String> tabsArray)
+    throws ManifoldCFException, IOException {
+    tabsArray.add(Messages.getString(locale, "RocketChatConnector.RestAPI"));
+    // Map the parameters
+    Map<String, Object> paramMap = new HashMap<String, Object>();
+
+    // Fill in the parameters from each tab
+    fillInServerConfigurationMap(paramMap, out, parameters);
+
+    // Output the Javascript - only one Velocity template for all tabs
+    Messages.outputResourceWithVelocity(out, locale, "ConfigurationHeader.js", paramMap);
+  }
+
+  @Override
+  public void outputConfigurationBody(IThreadContext threadContext, IHTTPOutput out,
+    Locale locale, ConfigParams parameters, String tabName)
+    throws ManifoldCFException, IOException {
+    // Output the Server tab
+    Map<String, Object> paramMap = new HashMap<String, Object>();
+    // Set the tab name
+    paramMap.put("TabName", tabName);
+    // Fill in the parameters
+    fillInServerConfigurationMap(paramMap, out, parameters);
+    Messages.outputResourceWithVelocity(out, locale, "Configuration_Server.html", paramMap);
+  }
+
+  private static void fillInServerConfigurationMap(Map<String, Object> paramMap, IPasswordMapperActivity mapper, ConfigParams parameters) {
+    String serverUrl = getEmptyOnNull(parameters, RocketChatConfig.SERVER_URL_PARAM);
+    String user = getEmptyOnNull(parameters, RocketChatConfig.USER_PARAM);
+    String password = parameters.getObfuscatedParameter(RocketChatConfig.PASSWORD_PARAM);
+    if (password == null) {
+      password = StringUtils.EMPTY;
+    } else {
+      password = mapper.mapPasswordToKey(password);
+    }
+    
+    String proxyHost = getEmptyOnNull(parameters, RocketChatConfig.PROXY_HOST_PARAM);
+    String proxyPort = getEmptyOnNull(parameters, RocketChatConfig.PROXY_PORT_PARAM);
+    String proxyUsername = getEmptyOnNull(parameters, RocketChatConfig.PROXY_USERNAME_PARAM);
+
+    String proxyPassword = parameters.getObfuscatedParameter(RocketChatConfig.PROXY_PASSWORD_PARAM);
+    if(proxyPassword == null) {
+      proxyPassword = StringUtils.EMPTY;
+    } else {
+      proxyPassword = mapper.mapPasswordToKey(proxyPassword);
+    }
+
+    String proxyDomain = getEmptyOnNull(parameters, RocketChatConfig.PROXY_DOMAIN_PARAM);
+
+    paramMap.put("SERVER_URL", serverUrl);
+    paramMap.put("USER", user);
+    paramMap.put("PASSWORD", password);
+    paramMap.put("PROXY_HOST", proxyHost);
+    paramMap.put("PROXY_PORT", proxyPort);
+    paramMap.put("PROXY_USERNAME", proxyUsername);
+    paramMap.put("PROXY_PASSWORD", proxyPassword);
+    paramMap.put("PROXY_DOMAIN", proxyDomain);
+  }
+
+  private static String getEmptyOnNull(ConfigParams parameters, String key) {
+    String value = parameters.getParameter(key);
+    if (value == null) {
+      value = StringUtils.EMPTY;
+    }
+    return value;
+  }
+
+  /**
+  * Process a configuration post.
+  * This method is called at the start of the connector's configuration page, whenever there is a possibility
+  * that form data for a connection has been posted. Its purpose is to gather form information and modify
+  * the configuration parameters accordingly.
+  * The name of the posted form is always "editconnection".
+  * The connector does not need to be connected for this method to be called.
+  *
+  * @param threadContext is the local thread context.
+  * @param variableContext is the set of variables available from the post, including binary file post information.
+  * @param parameters are the configuration parameters, as they currently exist, for this connection being configured.
+  * @return null if all is well, or a string error message if there is an error that should prevent saving of the
+  * connection (and cause a redirection to an error page).
+  */
+  @Override
+  public String processConfigurationPost(IThreadContext threadContext, IPostParameters variableContext,
+    ConfigParams parameters) throws ManifoldCFException {
+
+    final String serverUrl = variableContext.getParameter("serverUrl");
+    if (serverUrl != null) {
+      parameters.setParameter(RocketChatConfig.SERVER_URL_PARAM, serverUrl);
+    }
+
+    final String user = variableContext.getParameter("user");
+    if (user != null) {
+      parameters.setParameter(RocketChatConfig.USER_PARAM, user);
+    }
+    
+    final String password = variableContext.getParameter("password");
+    if (password != null) {
+      parameters.setObfuscatedParameter(RocketChatConfig.PASSWORD_PARAM, variableContext.mapKeyToPassword(password));
+    }
+    
+    final String proxyHost = variableContext.getParameter("proxyHost");
+    if (proxyHost != null) {
+      parameters.setParameter(RocketChatConfig.PROXY_HOST_PARAM, proxyHost);
+    }
+
+    final String proxyPort = variableContext.getParameter("proxyPort");
+    if (StringUtils.isNotEmpty(proxyPort)) {
+      try {
+        Integer.parseInt(proxyPort);
+      } catch (NumberFormatException e) {
+        Logging.connectors.warn("Proxy port must be a number. Found " + proxyPort);
+        throw new ManifoldCFException("Proxy Port must be a number: " + e.getMessage(), e);
+      }
+      parameters.setParameter(RocketChatConfig.PROXY_PORT_PARAM, proxyPort);
+    } else if(proxyPort != null){
+      parameters.setParameter(RocketChatConfig.PROXY_PORT_PARAM, proxyPort);
+    }
+
+    final String proxyUsername = variableContext.getParameter("proxyUsername");
+    if (proxyUsername != null) {
+      parameters.setParameter(RocketChatConfig.PROXY_USERNAME_PARAM, proxyUsername);
+    }
+
+    final String proxyPassword = variableContext.getParameter("proxyPassword");
+    if (proxyPassword != null) {
+      parameters.setObfuscatedParameter(RocketChatConfig.PROXY_PASSWORD_PARAM, variableContext.mapKeyToPassword(proxyPassword));
+    }
+
+    final String proxyDomain = variableContext.getParameter("proxyDomain");
+    if (proxyDomain != null) {
+      parameters.setParameter(RocketChatConfig.PROXY_DOMAIN_PARAM, proxyDomain);
+    }
+
+    return null;
+  }
+
+  /**
+  * View configuration. This method is called in the body section of the
+  * connector's view configuration page. Its purpose is to present the
+  * connection information to the user. The coder can presume that the HTML that
+  * is output from this configuration will be within appropriate <html> and
+  * <body> tags.
+  *
+  * @param threadContext is the local thread context.
+  * @param out is the output to which any HTML should be sent.
+  * @param parameters are the configuration parameters, as they currently exist, for
+  * this connection being configured.
+  */
+  @Override
+  public void viewConfiguration(IThreadContext threadContext, IHTTPOutput out,
+    Locale locale, ConfigParams parameters) throws ManifoldCFException, IOException {
+    Map<String, Object> paramMap = new HashMap<String, Object>();
+
+    // Fill in map from each tab
+    fillInServerConfigurationMap(paramMap, out, parameters);
+
+    Messages.outputResourceWithVelocity(out, locale, "ConfigurationView.html", paramMap);
+  }
+
+
+  /////////////////////////////////End of configuration UI////////////////////////////////////////////////////
+
+
+  /////////////////////////////////Start of Specification UI//////////////////////////////////////////////////
+
+  /** Output the specification header section.
+  * This method is called in the head section of a job page which has selected a repository connection of the
+  * current type.  Its purpose is to add the required tabs to the list, and to output any javascript methods
+  * that might be needed by the job editing HTML.
+  * The connector will be connected before this method can be called.
+  *@param out is the output to which any HTML should be sent.
+  *@param locale is the locale the output is preferred to be in.
+  *@param ds is the current document specification for this job.
+  *@param connectionSequenceNumber is the unique number of this connection within the job.
+  *@param tabsArray is an array of tab names.  Add to this array any tab names that are specific to the connector.
+  */
+  @Override
+  public void outputSpecificationHeader(IHTTPOutput out, Locale locale, Specification ds,
+    int connectionSequenceNumber, List<String> tabsArray)
+    throws ManifoldCFException, IOException {
+    Map<String, Object> paramMap = new HashMap<String, Object>();
+    paramMap.put("SeqNum", Integer.toString(connectionSequenceNumber));
+    // Add the tabs
+    tabsArray.add(Messages.getString(locale, "RocketChatConnector.Message"));
+    Messages.outputResourceWithVelocity(out, locale, "SpecificationHeader.js", paramMap);
+  }
+
+  /** Output the specification body section.
+  * This method is called in the body section of a job page which has selected a repository connection of the
+  * current type.  Its purpose is to present the required form elements for editing.
+  * The coder can presume that the HTML that is output from this configuration will be within appropriate
+  *  <html>, <body>, and <form> tags.  The name of the form is always "editjob".
+  * The connector will be connected before this method can be called.
+  *@param out is the output to which any HTML should be sent.
+  *@param locale is the locale the output is preferred to be in.
+  *@param ds is the current document specification for this job.
+  *@param connectionSequenceNumber is the unique number of this connection within the job.
+  *@param actualSequenceNumber is the connection within the job that has currently been selected.
+  *@param tabName is the current tab name.  (actualSequenceNumber, tabName) form a unique tuple within
+  *  the job.
+  */
+  @Override
+  public void outputSpecificationBody(IHTTPOutput out, Locale locale, Specification ds,
+    int connectionSequenceNumber, int actualSequenceNumber, String tabName)
+    throws ManifoldCFException, IOException {
+    outputMessageTab(out, locale, ds, tabName, connectionSequenceNumber, actualSequenceNumber);
+  }
+
+  /**
+* Take care of "Message" tab.
+*/
+  protected void outputMessageTab(IHTTPOutput out, Locale locale,
+    Specification ds, String tabName, int connectionSequenceNumber, int actualSequenceNumber)
+    throws ManifoldCFException, IOException {
+    Map<String, Object> paramMap = new HashMap<String, Object>();
+    paramMap.put("TabName", tabName);
+    paramMap.put("SeqNum", Integer.toString(connectionSequenceNumber));
+    paramMap.put("SelectedNum", Integer.toString(actualSequenceNumber));
+    fillInMessageTab(paramMap, ds);
+    Messages.outputResourceWithVelocity(out, locale, "Specification_Message.html", paramMap);
+  }
+
+  /**
+  * Fill in Velocity context for Metadata tab.
+  */
+  protected static void fillInMessageTab(Map<String, Object> paramMap,
+    Specification ds) {
+
+    // Preload default values, for backwards compatibility
+    String channel = "";
+    String message = "";
+    for (int i = 0; i < ds.getChildCount(); i++) {
+      SpecificationNode sn = ds.getChild(i);
+      if (sn.getType().equals(RocketChatConfig.NODE_CHANNEL)) {
+        channel = sn.getAttributeValue(RocketChatConfig.ATTRIBUTE_VALUE);
+      } else if (sn.getType().equals(RocketChatConfig.NODE_MESSAGE)) {
+        message = sn.getAttributeValue(RocketChatConfig.ATTRIBUTE_VALUE);
+      }
+    }
+    // If ANY of the above are non-empty, we create a new dummy record
+    if (channel.length() > 0) {
+      // Add the dummy records
+      addRecord(paramMap, RocketChatConfig.NODE_FINISHED, channel, message);
+      addRecord(paramMap, RocketChatConfig.NODE_ERRORABORTED, channel, message);
+      addRecord(paramMap, RocketChatConfig.NODE_MANUALABORTED, channel, message);
+      addRecord(paramMap, RocketChatConfig.NODE_MANUALPAUSED, channel, message);
+      addRecord(paramMap, RocketChatConfig.NODE_SCHEDULEPAUSED, channel, message);
+      addRecord(paramMap, RocketChatConfig.NODE_RESTARTED, channel, message);
+
+    }
+    else
+    {
+      // Initialize all records with blanks
+      addRecord(paramMap, RocketChatConfig.NODE_FINISHED, "", "");
+      addRecord(paramMap, RocketChatConfig.NODE_ERRORABORTED, "", "");
+      addRecord(paramMap, RocketChatConfig.NODE_MANUALABORTED, "", "");
+      addRecord(paramMap, RocketChatConfig.NODE_MANUALPAUSED, "", "");
+      addRecord(paramMap, RocketChatConfig.NODE_SCHEDULEPAUSED, "", "");
+      addRecord(paramMap, RocketChatConfig.NODE_RESTARTED, "" ,"");
+
+      // Loop through nodes and pick them out that way
+      for (int i = 0; i < ds.getChildCount(); i++) {
+        SpecificationNode childNode = ds.getChild(i);
+        if (childNode.getType().equals(RocketChatConfig.NODE_FINISHED) ||
+          childNode.getType().equals(RocketChatConfig.NODE_ERRORABORTED) ||
+          childNode.getType().equals(RocketChatConfig.NODE_MANUALABORTED) ||
+          childNode.getType().equals(RocketChatConfig.NODE_MANUALPAUSED) ||
+          childNode.getType().equals(RocketChatConfig.NODE_SCHEDULEPAUSED) ||
+          childNode.getType().equals(RocketChatConfig.NODE_RESTARTED)) {
+          channel = "";
+          message = "";
+          for (int j = 0; j < childNode.getChildCount(); j++) {
+            SpecificationNode sn = childNode.getChild(j);
+            if (sn.getType().equals(RocketChatConfig.NODE_CHANNEL)) {
+              channel = sn.getAttributeValue(RocketChatConfig.ATTRIBUTE_VALUE);
+            } else if (sn.getType().equals(RocketChatConfig.NODE_MESSAGE)) {
+              message = sn.getAttributeValue(RocketChatConfig.ATTRIBUTE_VALUE);
+            }
+          }
+          addRecord(paramMap, childNode.getType(), channel, message);
+        }
+      }
+    }
+  }
+
+  protected static void addRecord(Map<String,Object> paramMap, String nodeType, String channel, String message) {
+    paramMap.put(nodeType+"_CHANNEL", channel);
+    paramMap.put(nodeType+"_MESSAGE", message);
+  }
+
+  /** Process a specification post.
+  * This method is called at the start of job's edit or view page, whenever there is a possibility that form
+  * data for a connection has been posted.  Its purpose is to gather form information and modify the
+  * document specification accordingly.  The name of the posted form is always "editjob".
+  * The connector will be connected before this method can be called.
+  *@param variableContext contains the post data, including binary file-upload information.
+  *@param locale is the locale the output is preferred to be in.
+  *@param ds is the current document specification for this job.
+  *@param connectionSequenceNumber is the unique number of this connection within the job.
+  *@return null if all is well, or a string error message if there is an error that should prevent saving of
+  * the job (and cause a redirection to an error page).
+  */
+  @Override
+  public String processSpecificationPost(IPostParameters variableContext, Locale locale, Specification ds,
+    int connectionSequenceNumber)
+    throws ManifoldCFException {
+
+    return processMessageTab(variableContext, ds, connectionSequenceNumber);
+  }
+
+  protected String processMessageTab(IPostParameters variableContext, Specification ds,
+    int connectionSequenceNumber)
+    throws ManifoldCFException {
+
+    String seqPrefix = "s"+connectionSequenceNumber+"_";
+
+    // Remove legacy nodes always
+    removeNodes(ds, RocketChatConfig.NODE_CHANNEL);
+    removeNodes(ds, RocketChatConfig.NODE_MESSAGE);
+
+    // Gather all different kinds.
+    gatherRecord(ds, seqPrefix, variableContext, RocketChatConfig.NODE_FINISHED);
+    gatherRecord(ds, seqPrefix, variableContext, RocketChatConfig.NODE_ERRORABORTED);
+    gatherRecord(ds, seqPrefix, variableContext, RocketChatConfig.NODE_MANUALABORTED);
+    gatherRecord(ds, seqPrefix, variableContext, RocketChatConfig.NODE_MANUALPAUSED);
+    gatherRecord(ds, seqPrefix, variableContext, RocketChatConfig.NODE_SCHEDULEPAUSED);
+    gatherRecord(ds, seqPrefix, variableContext, RocketChatConfig.NODE_RESTARTED);
+
+    return null;
+  }
+
+  protected static void gatherRecord(Specification ds, String seqPrefix, IPostParameters variableContext, String nodeType) {
+    removeNodes(ds, nodeType);
+    SpecificationNode sn = new SpecificationNode(nodeType);
+    String channel = variableContext.getParameter(seqPrefix + nodeType + "_channel");
+    if (channel != null)
+    {
+      addNodeValue(sn, RocketChatConfig.NODE_CHANNEL, channel);
+    }
+    String message = variableContext.getParameter(seqPrefix + nodeType + "_message");
+    if (message != null)
+    {
+      addNodeValue(sn, RocketChatConfig.NODE_MESSAGE, message);
+    }
+    ds.addChild(ds.getChildCount(),sn);
+  }
+
+  /** View specification.
+  * This method is called in the body section of a job's view page.  Its purpose is to present the document
+  * specification information to the user.  The coder can presume that the HTML that is output from
+  * this configuration will be within appropriate <html> and <body> tags.
+  * The connector will be connected before this method can be called.
+  *@param out is the output to which any HTML should be sent.
+  *@param locale is the locale the output is preferred to be in.
+  *@param ds is the current document specification for this job.
+  *@param connectionSequenceNumber is the unique number of this connection within the job.
+  */
+  @Override
+  public void viewSpecification(IHTTPOutput out, Locale locale, Specification ds,
+    int connectionSequenceNumber)
+    throws ManifoldCFException, IOException {
+    Map<String, Object> paramMap = new HashMap<String, Object>();
+    paramMap.put("SeqNum", Integer.toString(connectionSequenceNumber));
+    fillInMessageTab(paramMap, ds);
+    Messages.outputResourceWithVelocity(out, locale, "SpecificationView.html", paramMap);
+  }
+
+  ///////////////////////////////////////End of specification UI///////////////////////////////////////////////
+
+  protected static void removeNodes(Specification ds, String nodeTypeName) {
+    int i = 0;
+    while (i < ds.getChildCount()) {
+      SpecificationNode sn = ds.getChild(i);
+      if (sn.getType().equals(nodeTypeName))
+        ds.removeChild(i);
+      else
+        i++;
+    }
+  }
+
+  protected static void addNodeValue(SpecificationNode ds, String nodeType, String value)
+  {
+    SpecificationNode sn = new SpecificationNode(nodeType);
+    sn.setAttribute(RocketChatConfig.ATTRIBUTE_VALUE,value);
+    ds.addChild(ds.getChildCount(),sn);
+  }
+
+
+  /** Handle Messaging exceptions in a consistent global manner */
+  protected static void handleIOException(IOException e, String context)
+    throws ManifoldCFException, ServiceInterruption
+  {
+    Logging.connectors.error("RocketChat: Error "+context+": "+e.getMessage(),e);
+    throw new ManifoldCFException("Error "+context+": "+e.getMessage(),e);
+  }
+
+  /** Class to set up connection.
+  */
+  protected static class ConnectThread extends Thread
+  {
+    protected final String serverUrl;
+    protected final String user;
+    protected final String password;
+    protected final RocketChatSession.ProxySettings proxySettings;
+
+    // Local session handle
+    protected RocketChatSession session = null;
+    protected Throwable exception = null;
+
+    public ConnectThread(String serverUrl, String user, String password, RocketChatSession.ProxySettings proxySettings)
+    {
+      this.serverUrl = serverUrl;
+      this.user = user;
+      this.password = password;
+      this.proxySettings = proxySettings;
+      setDaemon(true);
+    }
+
+    public void run()
+    {
+      try
+      {
+        session = new RocketChatSession(serverUrl, user, password, proxySettings);
+      }
+      catch (Throwable e)
+      {
+        exception = e;
+      }
+    }
+
+    public RocketChatSession finishUp()
+      throws IOException, InterruptedException
+    {
+      try
+      {
+        join();
+        if (exception != null)
+        {
+          if (exception instanceof RuntimeException)
+            throw (RuntimeException)exception;
+          else if (exception instanceof Error)
+            throw (Error)exception;
+          else if (exception instanceof IOException)
+            throw (IOException)exception;
+          else
+            throw new RuntimeException("Unknown exception type: "+exception.getClass().getName()+": "+exception.getMessage(),exception);
+        }
+        return session;
+      } catch (InterruptedException e) {
+        this.interrupt();
+        throw e;
+      }
+    }
+  }
+
+  /** Class to close the session.
+  */
+  protected static class CloseSessionThread extends Thread
+  {
+    protected final RocketChatSession session;
+
+    protected Throwable exception = null;
+
+    public CloseSessionThread(RocketChatSession session)
+    {
+      this.session = session;
+      setDaemon(true);
+    }
+
+    public void run()
+    {
+      try
+      {
+        session.close();
+      }
+      catch (Throwable e)
+      {
+        exception = e;
+      }
+    }
+
+    public void finishUp()
+      throws IOException, InterruptedException
+    {
+      try
+      {
+        join();
+        if (exception != null)
+        {
+          if (exception instanceof RuntimeException)
+            throw (RuntimeException)exception;
+          else if (exception instanceof Error)
+            throw (Error)exception;
+          else if (exception instanceof IOException)
+            throw (IOException)exception;
+          else
+            throw new RuntimeException("Unknown exception type: "+exception.getClass().getName()+": "+exception.getMessage(),exception);
+        }
+      } catch (InterruptedException e) {
+        this.interrupt();
+        throw e;
+      }
+    }
+  }
+
+  /** Class to check the connection.
+  */
+  protected static class CheckConnectionThread extends Thread
+  {
+    protected final RocketChatSession session;
+
+    protected Throwable exception = null;
+
+    public CheckConnectionThread(RocketChatSession session)
+    {
+      this.session = session;
+      setDaemon(true);
+    }
+
+    public void run()
+    {
+      try
+      {
+        session.checkConnection();
+      }
+      catch (Throwable e)
+      {
+        exception = e;
+      }
+    }
+
+    public void finishUp()
+      throws IOException, InterruptedException
+    {
+      try
+      {
+        join();
+        if (exception != null)
+        {
+          if (exception instanceof RuntimeException)
+            throw (RuntimeException)exception;
+          else if (exception instanceof Error)
+            throw (Error)exception;
+          else if (exception instanceof IOException)
+            throw (IOException)exception;
+          else
+            throw new RuntimeException("Unknown exception type: "+exception.getClass().getName()+": "+exception.getMessage(),exception);
+        }
+      } catch (InterruptedException e) {
+        this.interrupt();
+        throw e;
+      }
+    }
+  }
+
+  /** Class to send Rocket.Chat messages.
+  */
+  protected static class SendThread extends Thread
+  {
+    protected final RocketChatSession session;
+    protected final String channel;
+    protected final String message;
+
+    protected Throwable exception = null;
+
+    public SendThread(RocketChatSession session, String channel, String message)
+    {
+      this.session = session;
+      this.channel = channel;
+      this.message = message;
+      setDaemon(true);
+    }
+
+    public void run()
+    {
+      try
+      {
+        session.send(channel, message);
+      }
+      catch (Throwable e)
+      {
+        exception = e;
+      }
+    }
+
+    public void finishUp()
+      throws IOException, InterruptedException
+    {
+      try
+      {
+        join();
+        if (exception != null)
+        {
+          if (exception instanceof RuntimeException)
+            throw (RuntimeException)exception;
+          else if (exception instanceof Error)
+            throw (Error)exception;
+          else if (exception instanceof IOException)
+            throw (IOException)exception;
+          else
+            throw new RuntimeException("Unknown exception type: "+exception.getClass().getName()+": "+exception.getMessage(),exception);
+        }
+      } catch (InterruptedException e) {
+        this.interrupt();
+        throw e;
+      }
+    }
+  }
+}
\ No newline at end of file

Propchange: manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/java/org/apache/manifoldcf/crawler/notifications/rocketchat/RocketChatConnector.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/java/org/apache/manifoldcf/crawler/notifications/rocketchat/RocketChatCredentials.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/java/org/apache/manifoldcf/crawler/notifications/rocketchat/RocketChatCredentials.java?rev=1812793&view=auto
==============================================================================
--- manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/java/org/apache/manifoldcf/crawler/notifications/rocketchat/RocketChatCredentials.java (added)
+++ manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/java/org/apache/manifoldcf/crawler/notifications/rocketchat/RocketChatCredentials.java Fri Oct 20 22:23:24 2017
@@ -0,0 +1,25 @@
+package org.apache.manifoldcf.crawler.notifications.rocketchat;
+
+public class RocketChatCredentials {
+
+  private String user;
+  
+  private String password;
+
+  public String getUser() {
+    return user;
+  }
+
+  public void setUser(String user) {
+    this.user = user;
+  }
+
+  public String getPassword() {
+    return password;
+  }
+
+  public void setPassword(String password) {
+    this.password = password;
+  }
+  
+}

Propchange: manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/java/org/apache/manifoldcf/crawler/notifications/rocketchat/RocketChatCredentials.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/java/org/apache/manifoldcf/crawler/notifications/rocketchat/RocketChatMessage.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/java/org/apache/manifoldcf/crawler/notifications/rocketchat/RocketChatMessage.java?rev=1812793&view=auto
==============================================================================
--- manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/java/org/apache/manifoldcf/crawler/notifications/rocketchat/RocketChatMessage.java (added)
+++ manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/java/org/apache/manifoldcf/crawler/notifications/rocketchat/RocketChatMessage.java Fri Oct 20 22:23:24 2017
@@ -0,0 +1,53 @@
+/* $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.notifications.rocketchat;
+
+public class RocketChatMessage {
+
+  private String channel;
+
+  private String text;
+
+  private String alias;
+  
+  public String getChannel() {
+    return channel;
+  }
+
+  public void setChannel(String channel) {
+    this.channel = channel;
+  }
+
+  public String getText() {
+    return text;
+  }
+
+  public void setText(String text) {
+    this.text = text;
+  }
+
+  public String getAlias() {
+    return alias;
+  }
+
+  public void setAlias(String alias) {
+    this.alias = alias;
+  }
+
+}

Propchange: manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/java/org/apache/manifoldcf/crawler/notifications/rocketchat/RocketChatMessage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/java/org/apache/manifoldcf/crawler/notifications/rocketchat/RocketChatSession.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/java/org/apache/manifoldcf/crawler/notifications/rocketchat/RocketChatSession.java?rev=1812793&view=auto
==============================================================================
--- manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/java/org/apache/manifoldcf/crawler/notifications/rocketchat/RocketChatSession.java (added)
+++ manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/java/org/apache/manifoldcf/crawler/notifications/rocketchat/RocketChatSession.java Fri Oct 20 22:23:24 2017
@@ -0,0 +1,351 @@
+/* $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.notifications.rocketchat;
+
+import java.io.IOException;
+import java.text.MessageFormat;
+
+import javax.net.ssl.SSLSocketFactory;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.http.Header;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpHost;
+import org.apache.http.HttpStatus;
+import org.apache.http.auth.AuthScope;
+import org.apache.http.auth.NTCredentials;
+import org.apache.http.client.ClientProtocolException;
+import org.apache.http.client.CredentialsProvider;
+import org.apache.http.client.HttpResponseException;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.entity.EntityBuilder;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.conn.ssl.NoopHostnameVerifier;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import org.apache.http.entity.ContentType;
+import org.apache.http.impl.client.BasicCredentialsProvider;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.message.BasicHeader;
+import org.apache.http.util.EntityUtils;
+import org.apache.manifoldcf.connectorcommon.common.InterruptibleSocketFactory;
+import org.apache.manifoldcf.connectorcommon.interfaces.KeystoreManagerFactory;
+import org.apache.manifoldcf.core.interfaces.ManifoldCFException;
+import org.apache.manifoldcf.crawler.system.Logging;
+
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+/** This class represents a Rocket.Chat REST API session, without any protection
+* from threads waiting on sockets, etc.
+*/
+public class RocketChatSession
+{
+
+  private static String currentHost = null;
+
+  private CloseableHttpClient httpClient;
+  private ObjectMapper objectMapper;
+  private final String serverUrl;
+  private final String user;
+  private final String password;
+
+  static
+  {
+    // Find the current host name
+    try
+    {
+      java.net.InetAddress addr = java.net.InetAddress.getLocalHost();
+
+      // Get hostname
+      currentHost = addr.getHostName();
+    }
+    catch (java.net.UnknownHostException e)
+    {
+    }
+  }
+
+  /**
+   * Create a session.
+   * @param serverUrl - the serverUrl of the Rocket.Chat server to post the message to.
+   * @param user
+   * @param password
+   * @param proxySettingsOrNull - the proxy settings or null if not necessary.
+   * @throws ManifoldCFException
+   */
+  public RocketChatSession(final String serverUrl, String user, String password, final ProxySettings proxySettingsOrNull) throws ManifoldCFException
+  {
+    this.serverUrl = serverUrl.replaceAll("/$", "");
+    this.user = user;
+    this.password = password;
+    this.objectMapper = new ObjectMapper();
+    this.objectMapper.setSerializationInclusion(Include.NON_NULL);
+
+    int connectionTimeout = 60000;
+    int socketTimeout = 900000;
+
+    final RequestConfig.Builder requestBuilder = RequestConfig.custom()
+        .setSocketTimeout(socketTimeout)
+        .setConnectTimeout(connectionTimeout)
+        .setConnectionRequestTimeout(socketTimeout);
+
+    if(proxySettingsOrNull != null) {
+      addProxySettings(requestBuilder, proxySettingsOrNull);
+    }
+
+    // Create a ssl socket factory trusting everything.
+    // Reason: manifoldcf wishes connectors to encapsulate certificate handling
+    //         per connection and not rely on the global keystore.
+    //         A configurable keystore seems overkill for the Rocket.Chat notification use case
+    //         so we trust everything.
+    SSLSocketFactory httpsSocketFactory = KeystoreManagerFactory.getTrustingSecureSocketFactory();
+    SSLConnectionSocketFactory myFactory = new SSLConnectionSocketFactory(new InterruptibleSocketFactory(httpsSocketFactory,connectionTimeout),
+        NoopHostnameVerifier.INSTANCE);
+
+    httpClient = HttpClientBuilder.create()
+        .setDefaultRequestConfig(requestBuilder.build())
+        .setSSLSocketFactory(myFactory)
+        .build();
+  }
+
+  private void addProxySettings(RequestConfig.Builder requestBuilder, ProxySettings proxySettingsOrNull)
+  {
+    if (proxySettingsOrNull.hasUsername()) {
+      CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
+      credentialsProvider.setCredentials(
+          new AuthScope(proxySettingsOrNull.getHost(), proxySettingsOrNull.getPort()),
+          new NTCredentials(proxySettingsOrNull.getUsername(),
+              (proxySettingsOrNull.getPassword() == null) ? "" : proxySettingsOrNull.getPassword(),
+                  currentHost,
+                  (proxySettingsOrNull.getDomain() == null) ? "" : proxySettingsOrNull.getDomain()));
+    }
+
+    HttpHost proxy = new HttpHost(proxySettingsOrNull.getHost(), proxySettingsOrNull.getPort());
+    requestBuilder.setProxy(proxy);
+  }
+
+  public void checkConnection() throws IOException
+  {
+    // test connection
+    HttpGet infoGet = new HttpGet(serverUrl + "/api/v1/info");
+    int statusCode;
+    Boolean success = null;
+    String error = "";
+    try (CloseableHttpResponse response = httpClient.execute(infoGet)) {
+      statusCode = response.getStatusLine().getStatusCode();
+      JsonNode jsonResponse = objectMapper.readTree(response.getEntity().getContent());
+      JsonNode successNode = jsonResponse.get("success");
+      JsonNode errorNode = jsonResponse.get("error");
+      if (successNode != null) {
+        success = successNode.asBoolean();
+      } else if (errorNode != null) {
+        error = errorNode.asText();
+      }
+
+      // the API responds with { "success" : true }
+      boolean isExpectedStatus = statusCode == HttpStatus.SC_OK;
+      boolean isConnectionOk = isExpectedStatus && success != null && success;
+      if (!isConnectionOk) {
+        String messageTemplate = "connection failed: status {0}, message: {1}";
+        String statusInfo = isExpectedStatus ? "ok" : statusCode + " is unexpected";
+        String details = success != null ? "success " + success : error;
+        String message = MessageFormat.format(messageTemplate, statusInfo, details);
+        throw new ClientProtocolException(message);
+      }
+    }
+    
+    // test login
+    Header[] authHeader = null;
+    try {
+      authHeader = login();
+    } finally {
+      if (authHeader != null) {
+        logout(authHeader);
+      }
+    }
+
+  }
+
+  public void send(String channel, String message) throws IOException
+  {
+    Header[] authHeader = null;
+    try {
+      authHeader = login();
+    
+      HttpPost messagePost = new HttpPost(serverUrl + "/api/v1/chat.postMessage");
+      messagePost.setHeaders(authHeader);
+  
+      RocketChatMessage rocketChatMessage = new RocketChatMessage();
+      if (StringUtils.isNotBlank(channel)) {
+        rocketChatMessage.setChannel(channel);
+      }
+      rocketChatMessage.setText(message);
+      rocketChatMessage.setAlias("Apache ManifoldCF");
+  
+      String json = objectMapper.writeValueAsString(rocketChatMessage);
+  
+      HttpEntity entity = EntityBuilder.create()
+          .setContentType(ContentType.APPLICATION_JSON)
+          .setText(json)
+          .build();
+  
+      messagePost.setEntity(entity);
+      try (CloseableHttpResponse response = httpClient.execute(messagePost)) {
+        int statusCode = response.getStatusLine().getStatusCode();
+        if (statusCode == HttpStatus.SC_OK || statusCode == HttpStatus.SC_CREATED) {
+          EntityUtils.consume(response.getEntity());
+        } else {
+          Logging.connectors.error("Sending Rocket.Chat message failed with statusline " + response.getStatusLine());
+          Logging.connectors.debug("  Response was: " + EntityUtils.toString(response.getEntity()));
+        }
+      }
+    } finally {
+      if (authHeader != null) {
+        logout(authHeader);
+      }
+    }
+  }
+  
+  private Header[] login() throws IOException {
+    HttpPost loginPost = new HttpPost(serverUrl + "/api/v1/login");
+    RocketChatCredentials credentials = new RocketChatCredentials();
+    credentials.setUser(user);
+    credentials.setPassword(password);
+    String json = objectMapper.writeValueAsString(credentials);
+    
+    HttpEntity entity = EntityBuilder.create()
+        .setContentType(ContentType.APPLICATION_JSON)
+        .setText(json)
+        .build();
+
+    loginPost.setEntity(entity);
+    try (CloseableHttpResponse response = httpClient.execute(loginPost)) {
+      int statusCode = response.getStatusLine().getStatusCode();
+      if (statusCode == HttpStatus.SC_OK) {
+        
+        JsonNode jsonResponse = objectMapper.readTree(response.getEntity().getContent());
+        JsonNode dataNode = jsonResponse.get("data");
+        JsonNode errorNode = jsonResponse.get("error");
+        if (dataNode != null) {
+          String authToken = dataNode.get("authToken").asText();
+          String userId = dataNode.get("userId").asText();
+          
+          return new Header[] {
+              new BasicHeader("X-Auth-Token", authToken),
+              new BasicHeader("X-User-Id", userId)
+          };  
+        } else {
+          String message;
+          if (errorNode != null) {
+            message = errorNode.asText();
+          } else {
+            message = "login response did not contain authentication data";
+          }
+          throw new ClientProtocolException(message);
+        }
+        
+        
+      } else {
+        Logging.connectors.error("Login to Rocket.Chat failed with statusline " + response.getStatusLine());
+        Logging.connectors.debug("  Response was: " + EntityUtils.toString(response.getEntity()));
+        throw new HttpResponseException(statusCode, response.getStatusLine().getReasonPhrase());
+      }
+    }
+  }
+  
+  private void logout(Header[] authHeader) throws IOException {
+    HttpGet logoutGet = new HttpGet(serverUrl + "/api/v1/logout");
+    logoutGet.setHeaders(authHeader);
+    try (CloseableHttpResponse response = httpClient.execute(logoutGet)) {
+      int statusCode = response.getStatusLine().getStatusCode();
+      if (statusCode != HttpStatus.SC_OK) {
+        Logging.connectors.error("Logout from Rocket.Chat failed with statusline " + response.getStatusLine());
+        Logging.connectors.debug("  Response was: " + EntityUtils.toString(response.getEntity()));
+      }
+    }
+  }
+
+  public void close() throws IOException
+  {
+    httpClient.close();
+    httpClient = null;
+    objectMapper = null;
+  }
+
+  protected static final class ProxySettings {
+    private String host;
+    private int port = -1;
+    private String username;
+    private String password;
+    private String domain;
+
+    public ProxySettings(String host, String portString, String username, String password, String domain) {
+      this.host = host;
+      if(StringUtils.isNotEmpty(portString)) {
+        try {
+          this.port = Integer.parseInt(portString);
+        } catch (NumberFormatException e) {
+          Logging.connectors.warn("Proxy port must be an number. Found " + portString);
+        }
+      }
+      this.username = username;
+      this.password = password;
+      this.domain = domain;
+    }
+
+    public String getHost() {
+      return host;
+    }
+
+    public int getPort() {
+      return port;
+    }
+
+    public String getUsername() {
+      return username;
+    }
+
+    public boolean hasUsername() {
+      return StringUtils.isNotEmpty(this.username);
+    }
+
+    public String getPassword() {
+      return password;
+    }
+
+    public String getDomain() {
+      return domain;
+    }
+
+    @Override
+    public String toString() {
+      final StringBuilder sb = new StringBuilder("ProxySettings{");
+      sb.append("host='").append(host).append('\'');
+      sb.append(", port=").append(port);
+      sb.append(", username='").append(username).append('\'');
+      sb.append(", password='").append(password).append('\'');
+      sb.append(", domain='").append(domain).append('\'');
+      sb.append('}');
+      return sb.toString();
+    }
+  }
+}
\ No newline at end of file

Propchange: manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/java/org/apache/manifoldcf/crawler/notifications/rocketchat/RocketChatSession.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/notifications/rocketchat/common_en_US.properties
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/notifications/rocketchat/common_en_US.properties?rev=1812793&view=auto
==============================================================================
--- manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/notifications/rocketchat/common_en_US.properties (added)
+++ manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/notifications/rocketchat/common_en_US.properties Fri Oct 20 22:23:24 2017
@@ -0,0 +1,42 @@
+# 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.
+
+RocketChatConnector.RestAPI=Rocket.Chat REST API
+RocketChatConnector.Message=Message
+
+RocketChatConnector.EnterAServerUrl=Enter a Rocket.Chat server URL
+RocketChatConnector.EnterAUser=Enter a user (username or email)
+RocketChatConnector.EnterAPassword=Enter a password
+RocketChatConnector.ProxyPortMustBeAnInteger=Proxy port must be an integer
+RocketChatConnector.ProxyPortMustBeGivenWithHost=Proxy port must be given when proxy host is configured
+
+RocketChatConnector.ServerUrlColon=Server URL:
+RocketChatConnector.UserColon=User:
+RocketChatConnector.PasswordColon=Password:
+RocketChatConnector.ProxyHostColon=Proxy Host:
+RocketChatConnector.ProxyPortColon=Proxy Port:
+RocketChatConnector.ProxyUsernameColon=Proxy NTLM Username:
+RocketChatConnector.ProxyPasswordColon=Proxy NTLM Password:
+RocketChatConnector.ProxyDomainColon=Proxy NTLM Authentication Domain:
+
+RocketChatConnector.JobFinished=Job finished
+RocketChatConnector.JobStopErrorAbort=Job stopped due to error abort
+RocketChatConnector.JobStopManualAbort=Job stopped due to manual abort
+RocketChatConnector.JobStopManualPause=Job stopped due to manual pause
+RocketChatConnector.JobStopSchedulePause=Job stopped due to scheduled pause
+RocketChatConnector.JobStopRestart=Job stopped due to job restart
+
+RocketChatConnector.ChannelColon=Channel:
+RocketChatConnector_MessageColon=Message:

Propchange: manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/notifications/rocketchat/common_en_US.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Added: manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/notifications/rocketchat/common_es_ES.properties
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/notifications/rocketchat/common_es_ES.properties?rev=1812793&view=auto
==============================================================================
--- manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/notifications/rocketchat/common_es_ES.properties (added)
+++ manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/notifications/rocketchat/common_es_ES.properties Fri Oct 20 22:23:24 2017
@@ -0,0 +1,42 @@
+# 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.
+
+RocketChatConnector.RestAPI=Rocket.Chat REST API
+RocketChatConnector.Message=Message
+
+RocketChatConnector.EnterAServerUrl=Enter a Rocket.Chat server URL
+RocketChatConnector.EnterAUser=Enter a user (username or email)
+RocketChatConnector.EnterAPassword=Enter a password
+RocketChatConnector.ProxyPortMustBeAnInteger=Proxy port must be an integer
+RocketChatConnector.ProxyPortMustBeGivenWithHost=Proxy port must be given when proxy host is configured
+
+RocketChatConnector.ServerUrlColon=Server URL:
+RocketChatConnector.UserColon=User:
+RocketChatConnector.PasswordColon=Password:
+RocketChatConnector.ProxyHostColon=Proxy Host:
+RocketChatConnector.ProxyPortColon=Proxy Port:
+RocketChatConnector.ProxyUsernameColon=Proxy NTLM Username:
+RocketChatConnector.ProxyPasswordColon=Proxy NTLM Password:
+RocketChatConnector.ProxyDomainColon=Proxy NTLM Authentication Domain:
+
+RocketChatConnector.JobFinished=Job finished
+RocketChatConnector.JobStopErrorAbort=Job stopped due to error abort
+RocketChatConnector.JobStopManualAbort=Job stopped due to manual abort
+RocketChatConnector.JobStopManualPause=Job stopped due to manual pause
+RocketChatConnector.JobStopSchedulePause=Job stopped due to scheduled pause
+RocketChatConnector.JobStopRestart=Job stopped due to job restart
+
+RocketChatConnector.ChannelColon=Channel:
+RocketChatConnector_MessageColon=Message:

Propchange: manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/notifications/rocketchat/common_es_ES.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Added: manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/notifications/rocketchat/common_ja_JP.properties
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/notifications/rocketchat/common_ja_JP.properties?rev=1812793&view=auto
==============================================================================
--- manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/notifications/rocketchat/common_ja_JP.properties (added)
+++ manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/notifications/rocketchat/common_ja_JP.properties Fri Oct 20 22:23:24 2017
@@ -0,0 +1,42 @@
+# 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.
+
+RocketChatConnector.RestAPI=Rocket.Chat REST API
+RocketChatConnector.Message=Message
+
+RocketChatConnector.EnterAServerUrl=Enter a Rocket.Chat server URL
+RocketChatConnector.EnterAUser=Enter a user (username or email)
+RocketChatConnector.EnterAPassword=Enter a password
+RocketChatConnector.ProxyPortMustBeAnInteger=Proxy port must be an integer
+RocketChatConnector.ProxyPortMustBeGivenWithHost=Proxy port must be given when proxy host is configured
+
+RocketChatConnector.ServerUrlColon=Server URL:
+RocketChatConnector.UserColon=User:
+RocketChatConnector.PasswordColon=Password:
+RocketChatConnector.ProxyHostColon=Proxy Host:
+RocketChatConnector.ProxyPortColon=Proxy Port:
+RocketChatConnector.ProxyUsernameColon=Proxy NTLM Username:
+RocketChatConnector.ProxyPasswordColon=Proxy NTLM Password:
+RocketChatConnector.ProxyDomainColon=Proxy NTLM Authentication Domain:
+
+RocketChatConnector.JobFinished=Job finished
+RocketChatConnector.JobStopErrorAbort=Job stopped due to error abort
+RocketChatConnector.JobStopManualAbort=Job stopped due to manual abort
+RocketChatConnector.JobStopManualPause=Job stopped due to manual pause
+RocketChatConnector.JobStopSchedulePause=Job stopped due to scheduled pause
+RocketChatConnector.JobStopRestart=Job stopped due to job restart
+
+RocketChatConnector.ChannelColon=Channel:
+RocketChatConnector_MessageColon=Message:

Propchange: manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/notifications/rocketchat/common_ja_JP.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Added: manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/notifications/rocketchat/common_zh_CN.properties
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/notifications/rocketchat/common_zh_CN.properties?rev=1812793&view=auto
==============================================================================
--- manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/notifications/rocketchat/common_zh_CN.properties (added)
+++ manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/notifications/rocketchat/common_zh_CN.properties Fri Oct 20 22:23:24 2017
@@ -0,0 +1,42 @@
+# 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.
+
+RocketChatConnector.RestAPI=Rocket.Chat REST API
+RocketChatConnector.Message=Message
+
+RocketChatConnector.EnterAServerUrl=Enter a Rocket.Chat server URL
+RocketChatConnector.EnterAUser=Enter a user (username or email)
+RocketChatConnector.EnterAPassword=Enter a password
+RocketChatConnector.ProxyPortMustBeAnInteger=Proxy port must be an integer
+RocketChatConnector.ProxyPortMustBeGivenWithHost=Proxy port must be given when proxy host is configured
+
+RocketChatConnector.ServerUrlColon=Server URL:
+RocketChatConnector.UserColon=User:
+RocketChatConnector.PasswordColon=Password:
+RocketChatConnector.ProxyHostColon=Proxy Host:
+RocketChatConnector.ProxyPortColon=Proxy Port:
+RocketChatConnector.ProxyUsernameColon=Proxy NTLM Username:
+RocketChatConnector.ProxyPasswordColon=Proxy NTLM Password:
+RocketChatConnector.ProxyDomainColon=Proxy NTLM Authentication Domain:
+
+RocketChatConnector.JobFinished=Job finished
+RocketChatConnector.JobStopErrorAbort=Job stopped due to error abort
+RocketChatConnector.JobStopManualAbort=Job stopped due to manual abort
+RocketChatConnector.JobStopManualPause=Job stopped due to manual pause
+RocketChatConnector.JobStopSchedulePause=Job stopped due to scheduled pause
+RocketChatConnector.JobStopRestart=Job stopped due to job restart
+
+RocketChatConnector.ChannelColon=Channel:
+RocketChatConnector_MessageColon=Message:

Propchange: manifoldcf/branches/CONNECTORS-1468/connectors/rocketchat/connector/src/main/native2ascii/org/apache/manifoldcf/crawler/notifications/rocketchat/common_zh_CN.properties
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message