commit a9c45e1e62a5e2b4af8107dba4cb1a27f9f3c076
Author: Patrick Plitzner <p.plitzner@bgbm.org>
Date:   Tue Oct 23 13:43:40 2018 +0200

    fix #7844 Add timeout to login dialog

diff --git a/eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/remoting/source/CdmServerInfo.java b/eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/remoting/source/CdmServerInfo.java
index f4cd60862..e2ecfa793 100644
--- a/eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/remoting/source/CdmServerInfo.java
+++ b/eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/remoting/source/CdmServerInfo.java
@@ -13,6 +13,7 @@ import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
+import java.net.InetSocketAddress;
 import java.net.Socket;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -272,21 +273,15 @@ public class CdmServerInfo {
         return null;
     }
 
-    public boolean pingServer() {
+    public boolean pingServer() throws CDMServerException, IOException {
         if(isLocalhostMgd()) {
             return true;
         }
-        try {
-            Socket s = new Socket(server, port);
-            logger.info("[CDM-Server] Available @ " + server + ":" + port );
-            updateInfo();
-            return true;
-        } catch (IOException ioe) {
-
-        } catch (CDMServerException e) {
-
-        }
-        return false;
+        Socket s = new Socket();
+        s.connect(new InetSocketAddress(server, port), 2000);
+        logger.info("[CDM-Server] Available @ " + server + ":" + port );
+        updateInfo();
+        return true;
     }
 
     public boolean pingInstance(CdmInstanceInfo instance, int port) throws CDMServerException  {
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/Messages.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/Messages.java
index c832de57e..caec734e0 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/Messages.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/Messages.java
@@ -155,46 +155,129 @@ public class Messages extends NLS {
     public static String PresenceAbsenceTermDetailElement_COLOR_NOT_SET;
     public static String PresenceAbsenceTermDetailElement_LABEL_COLOR;
     public static String RemotingLoginDialog_CHOOSE_COMPATIBLE_CDM_SERVER;
+
+
     public static String RemotingLoginDialog_DEFAULT_LOGIN;
+
+
 	public static String RemotingLoginDialog_LABEL_ADVANCED;
+
+
 	public static String RemotingLoginDialog_LABEL_CDM_INSTANCE;
+
+
 	public static String RemotingLoginDialog_LABEL_CDM_SERVER;
+
+
 	public static String RemotingLoginDialog_LABEL_CONNECT;
+
+
 	public static String RemotingLoginDialog_LABEL_EDITOR_CDM_VERSION;
+
+
 	public static String RemotingLoginDialog_LABEL_EDITOR_CDMLIB_VERSION;
+
+
 	public static String RemotingLoginDialog_LABEL_LOGIN;
+
+
 	public static String RemotingLoginDialog_LABEL_LOGIN_COLON;
+
+
 	public static String RemotingLoginDialog_LABEL_PASSWORD;
+
+
 	public static String RemotingLoginDialog_LABEL_PORT;
+
+
 	public static String RemotingLoginDialog_LABEL_REFRESH;
+
+
 	public static String RemotingLoginDialog_LABEL_REMEMBER_ME;
+
+
 	public static String RemotingLoginDialog_RETRIEVE_SERVER_INSTANCES;
+
+
 	public static String RemotingLoginDialog_LABEL_SERVER_CDM_VERSION;
+
+
 	public static String RemotingLoginDialog_LABEL_SERVER_CDMLIB_VERSION;
+
+
 	public static String RemotingLoginDialog_LABEL_STOP_MANAGED_SERVER;
+
+
 	public static String RemotingLoginDialog_LOGIN_CANNOT_BE_EMPTY;
+
+
 	public static String RemotingLoginDialog_MESSAGE_PORT_SHOULD_BE_INTEGER;
+
+
 	public static String RemotingLoginDialog_PASSWORD_CANNOT_BE_EMPTY;
+
+
 	public static String RemotingLoginDialog_SERVER_LAUNCH_ERROR;
+
+
 	public static String RemotingLoginDialog_STATUS_AVAILABLE;
+
+
 	public static String RemotingLoginDialog_STATUS_CHECKING;
+
+
 	public static String RemotingLoginDialog_STATUS_ERROR;
 	public static String RemotingLoginDialog_STATUS_NO_INSTANCES_FOUND;
+
+
 	public static String RemotingLoginDialog_STATUS_NOT_AVAILABLE;
+
+
 	public static String RemotingLoginDialog_STATUS_NOT_COMPATIBLE;
+
+
 	public static String RemotingLoginDialog_STATUS_NOT_STARTED;
+
+
 	public static String RemotingLoginDialog_STATUS_REMOTING_NOT_ACTIVATED;
 	public static String RemotingLoginDialog_STATUS_RETRIEVING;
+
+
 	public static String RemotingLoginDialog_STATUS_STARTED;
+
+
 	public static String RemotingLoginDialog_UPDATE_EDITOR;
-	public static String RemotingLoginDialog_COULD_NOT_STOP_SERVER;
+
+
+	public static String RemotingLoginDialog_CONNECTION_FAILED_MESSAGE;
+
+
+    public static String RemotingLoginDialog_CONNECTION_FAILED_TITLE;
+
+
+    public static String RemotingLoginDialog_COULD_NOT_STOP_SERVER;
+
+
 	public static String RemotingLoginDialog_ERROR_GENERATING_CONFIG_FILE;
+
+
 	public static String RemotingLoginDialog_ERROR_STARTING_SERVER;
+
+
 	public static String RemotingLoginDialog_ERROR_STOPPING_SERVER;
+
+
 	public static String RemotingLoginDialog_GENERATING_CONFIG_FILE;
+
+
 	public static String RemotingLoginDialog_JOB_SERVER_LAUNCH;
+
+
 	public static String RemotingLoginDialog_STARTING_MGD_SERVER;
+
 	public static String RemotingLoginDialog_TASK_LAUNCHING_SERVER;
+
+
     public static String SearchManager_LARGE_RESULT_EXPECTED;
     public static String SearchManager_LONG_SEARCH_WARNING;
 	public static String SupplementalDataViewPart_VIEWER_NAME;
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/messages.properties b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/messages.properties
index c6de25a4c..57817e185 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/messages.properties
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/messages.properties
@@ -80,6 +80,8 @@ CdmStoreConnector_UPDATE_DATASOUREC_OR_CHOOSE_NEW_DATASOURCE=Please update the c
 CdmStoreConnector_UPDATE_EDITOR_OR_CHOOSE_COMPATIBLE_DATASOURCE=Please update the Taxonomic Editor (Help->Check for Updates) or choose a compatible datasource
 ConfiguratorComposite_CONFIGURE=Configure
 
+RemotingLoginDialog_CONNECTION_FAILED_MESSAGE=Could not connect to CDM Server.
+RemotingLoginDialog_CONNECTION_FAILED_TITLE=Connection failed
 RemotingLoginDialog_DEFAULT_LOGIN=Default: %s (login), %s (password)
 RemotingLoginDialog_CHOOSE_COMPATIBLE_CDM_SERVER=Please choose a compatible cdm-server or update the chosen cdm-server
 RemotingLoginDialog_LABEL_ADVANCED=advanced
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/messages_de.properties b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/messages_de.properties
index 8ac1ed053..4a41dcde6 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/messages_de.properties
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/messages_de.properties
@@ -80,6 +80,8 @@ CdmStoreConnector_UPDATE_DATASOUREC_OR_CHOOSE_NEW_DATASOURCE=Bitte aktualisieren
 CdmStoreConnector_UPDATE_EDITOR_OR_CHOOSE_COMPATIBLE_DATASOURCE=Bitte aktualisieren Sie den Taxonomic Editor (Hilfe->Suche nach Updates) oder wählen sie eine kompatible Datenquelle
 ConfiguratorComposite_CONFIGURE=Einstellungen
 
+RemotingLoginDialog_CONNECTION_FAILED_MESSAGE=Eine Verbindung zum CDM-Server konnte nicht hergestellt werden.
+RemotingLoginDialog_CONNECTION_FAILED_TITLE=Verbindung fehlgeschlagen
 RemotingLoginDialog_DEFAULT_LOGIN=Standard: %s (Login), %s (Kennwort)
 RemotingLoginDialog_CHOOSE_COMPATIBLE_CDM_SERVER=Bitte wählen Sie einen kompatiblen CDM-Server oder aktualisieren sie den CDM-Server
 RemotingLoginDialog_LABEL_ADVANCED=Erweitert
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/RemotingLoginDialog.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/RemotingLoginDialog.java
index 060ac6292..c66bc40e2 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/RemotingLoginDialog.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/RemotingLoginDialog.java
@@ -88,11 +88,11 @@ public class RemotingLoginDialog extends Dialog implements ICDMServerError {
     /**
      *
      */
-    private static final String DEFAULT_PASS = "00000";
+    private static final String DEFAULT_PASS = "00000"; //$NON-NLS-1$
     /**
      *
      */
-    private static final String DEFAULT_USER = "admin";
+    private static final String DEFAULT_USER = "admin"; //$NON-NLS-1$
     private static final String UBUNTU = "Ubuntu"; //$NON-NLS-1$
 	protected Object result;
     protected Shell shlConnect;
@@ -591,15 +591,21 @@ public class RemotingLoginDialog extends Dialog implements ICDMServerError {
                     txtPort.setEditable(true);
                     txtPort.setEnabled(true);
                 }
-                if(selectedCsii.pingServer()) {
-                    txtCdmServerStatus.setText(STATUS_AVAILABLE);
-                    populateCdmInstanceCombo(true);
-                    String serverVersionTimestamp = generateLastModifiedTooltip(selectedCsii.getCdmlibLastModified());
-                    txtServerVersion.setText(selectedCsii.getCdmlibServicesVersion() + ":" + serverVersionTimestamp); //$NON-NLS-1$
-                } else {
-                    txtCdmServerStatus.setText(STATUS_NOT_AVAILABLE);
-                    comboCdmInstance.removeAll();
-                    disableCdmInstanceControls("", "");
+                try {
+                    if(selectedCsii.pingServer()) {
+                        txtCdmServerStatus.setText(STATUS_AVAILABLE);
+                        populateCdmInstanceCombo(true);
+                        String serverVersionTimestamp = generateLastModifiedTooltip(selectedCsii.getCdmlibLastModified());
+                        txtServerVersion.setText(selectedCsii.getCdmlibServicesVersion() + ":" + serverVersionTimestamp); //$NON-NLS-1$
+                    } else {
+                        txtCdmServerStatus.setText(STATUS_NOT_AVAILABLE);
+                        comboCdmInstance.removeAll();
+                        disableCdmInstanceControls("", ""); //$NON-NLS-1$ //$NON-NLS-2$
+                    }
+                } catch (CDMServerException | IOException e) {
+                    MessagingUtils.errorDialog(Messages.RemotingLoginDialog_CONNECTION_FAILED_TITLE, this,
+                            Messages.RemotingLoginDialog_CONNECTION_FAILED_MESSAGE,
+                            TaxeditorStorePlugin.PLUGIN_ID, e, true, true);
                 }
             }
             updatePort();
diff --git a/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/ui/dialogs/CdmServerInfoTest.java b/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/ui/dialogs/CdmServerInfoTest.java
index d294c17dd..3c4297b2a 100644
--- a/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/ui/dialogs/CdmServerInfoTest.java
+++ b/eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/ui/dialogs/CdmServerInfoTest.java
@@ -8,6 +8,7 @@
  */
 package eu.etaxonomy.taxeditor.ui.dialogs;
 
+import java.io.IOException;
 import java.util.List;
 
 import org.junit.Assert;
@@ -31,7 +32,7 @@ import eu.etaxonomy.taxeditor.remoting.source.CdmServerInfoConfig;
 public class CdmServerInfoTest extends UnitilsJUnit4 {
 
     @Test
-    public void pingServersTest() {
+    public void pingServersTest() throws CDMServerException, IOException {
         List<CdmServerInfo> servers = CdmServerInfo.getCdmServers();
         for(CdmServerInfo server : servers) {
             server.pingServer();
