Project

General

Profile

« Previous | Next » 

Revision a9c45e1e

Added by Patrick Plitzner over 5 years ago

fix #7844 Add timeout to login dialog

View differences:

eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/remoting/source/CdmServerInfo.java
13 13
import java.io.FileNotFoundException;
14 14
import java.io.FileOutputStream;
15 15
import java.io.IOException;
16
import java.net.InetSocketAddress;
16 17
import java.net.Socket;
17 18
import java.util.ArrayList;
18 19
import java.util.Collections;
......
272 273
        return null;
273 274
    }
274 275

  
275
    public boolean pingServer() {
276
    public boolean pingServer() throws CDMServerException, IOException {
276 277
        if(isLocalhostMgd()) {
277 278
            return true;
278 279
        }
279
        try {
280
            Socket s = new Socket(server, port);
281
            logger.info("[CDM-Server] Available @ " + server + ":" + port );
282
            updateInfo();
283
            return true;
284
        } catch (IOException ioe) {
285

  
286
        } catch (CDMServerException e) {
287

  
288
        }
289
        return false;
280
        Socket s = new Socket();
281
        s.connect(new InetSocketAddress(server, port), 2000);
282
        logger.info("[CDM-Server] Available @ " + server + ":" + port );
283
        updateInfo();
284
        return true;
290 285
    }
291 286

  
292 287
    public boolean pingInstance(CdmInstanceInfo instance, int port) throws CDMServerException  {
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/Messages.java
155 155
    public static String PresenceAbsenceTermDetailElement_COLOR_NOT_SET;
156 156
    public static String PresenceAbsenceTermDetailElement_LABEL_COLOR;
157 157
    public static String RemotingLoginDialog_CHOOSE_COMPATIBLE_CDM_SERVER;
158

  
159

  
158 160
    public static String RemotingLoginDialog_DEFAULT_LOGIN;
161

  
162

  
159 163
	public static String RemotingLoginDialog_LABEL_ADVANCED;
164

  
165

  
160 166
	public static String RemotingLoginDialog_LABEL_CDM_INSTANCE;
167

  
168

  
161 169
	public static String RemotingLoginDialog_LABEL_CDM_SERVER;
170

  
171

  
162 172
	public static String RemotingLoginDialog_LABEL_CONNECT;
173

  
174

  
163 175
	public static String RemotingLoginDialog_LABEL_EDITOR_CDM_VERSION;
176

  
177

  
164 178
	public static String RemotingLoginDialog_LABEL_EDITOR_CDMLIB_VERSION;
179

  
180

  
165 181
	public static String RemotingLoginDialog_LABEL_LOGIN;
182

  
183

  
166 184
	public static String RemotingLoginDialog_LABEL_LOGIN_COLON;
185

  
186

  
167 187
	public static String RemotingLoginDialog_LABEL_PASSWORD;
188

  
189

  
168 190
	public static String RemotingLoginDialog_LABEL_PORT;
191

  
192

  
169 193
	public static String RemotingLoginDialog_LABEL_REFRESH;
194

  
195

  
170 196
	public static String RemotingLoginDialog_LABEL_REMEMBER_ME;
197

  
198

  
171 199
	public static String RemotingLoginDialog_RETRIEVE_SERVER_INSTANCES;
200

  
201

  
172 202
	public static String RemotingLoginDialog_LABEL_SERVER_CDM_VERSION;
203

  
204

  
173 205
	public static String RemotingLoginDialog_LABEL_SERVER_CDMLIB_VERSION;
206

  
207

  
174 208
	public static String RemotingLoginDialog_LABEL_STOP_MANAGED_SERVER;
209

  
210

  
175 211
	public static String RemotingLoginDialog_LOGIN_CANNOT_BE_EMPTY;
212

  
213

  
176 214
	public static String RemotingLoginDialog_MESSAGE_PORT_SHOULD_BE_INTEGER;
215

  
216

  
177 217
	public static String RemotingLoginDialog_PASSWORD_CANNOT_BE_EMPTY;
218

  
219

  
178 220
	public static String RemotingLoginDialog_SERVER_LAUNCH_ERROR;
221

  
222

  
179 223
	public static String RemotingLoginDialog_STATUS_AVAILABLE;
224

  
225

  
180 226
	public static String RemotingLoginDialog_STATUS_CHECKING;
227

  
228

  
181 229
	public static String RemotingLoginDialog_STATUS_ERROR;
182 230
	public static String RemotingLoginDialog_STATUS_NO_INSTANCES_FOUND;
231

  
232

  
183 233
	public static String RemotingLoginDialog_STATUS_NOT_AVAILABLE;
234

  
235

  
184 236
	public static String RemotingLoginDialog_STATUS_NOT_COMPATIBLE;
237

  
238

  
185 239
	public static String RemotingLoginDialog_STATUS_NOT_STARTED;
240

  
241

  
186 242
	public static String RemotingLoginDialog_STATUS_REMOTING_NOT_ACTIVATED;
187 243
	public static String RemotingLoginDialog_STATUS_RETRIEVING;
244

  
245

  
188 246
	public static String RemotingLoginDialog_STATUS_STARTED;
247

  
248

  
189 249
	public static String RemotingLoginDialog_UPDATE_EDITOR;
190
	public static String RemotingLoginDialog_COULD_NOT_STOP_SERVER;
250

  
251

  
252
	public static String RemotingLoginDialog_CONNECTION_FAILED_MESSAGE;
253

  
254

  
255
    public static String RemotingLoginDialog_CONNECTION_FAILED_TITLE;
256

  
257

  
258
    public static String RemotingLoginDialog_COULD_NOT_STOP_SERVER;
259

  
260

  
191 261
	public static String RemotingLoginDialog_ERROR_GENERATING_CONFIG_FILE;
262

  
263

  
192 264
	public static String RemotingLoginDialog_ERROR_STARTING_SERVER;
265

  
266

  
193 267
	public static String RemotingLoginDialog_ERROR_STOPPING_SERVER;
268

  
269

  
194 270
	public static String RemotingLoginDialog_GENERATING_CONFIG_FILE;
271

  
272

  
195 273
	public static String RemotingLoginDialog_JOB_SERVER_LAUNCH;
274

  
275

  
196 276
	public static String RemotingLoginDialog_STARTING_MGD_SERVER;
277

  
197 278
	public static String RemotingLoginDialog_TASK_LAUNCHING_SERVER;
279

  
280

  
198 281
    public static String SearchManager_LARGE_RESULT_EXPECTED;
199 282
    public static String SearchManager_LONG_SEARCH_WARNING;
200 283
	public static String SupplementalDataViewPart_VIEWER_NAME;
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/messages.properties
80 80
CdmStoreConnector_UPDATE_EDITOR_OR_CHOOSE_COMPATIBLE_DATASOURCE=Please update the Taxonomic Editor (Help->Check for Updates) or choose a compatible datasource
81 81
ConfiguratorComposite_CONFIGURE=Configure
82 82

  
83
RemotingLoginDialog_CONNECTION_FAILED_MESSAGE=Could not connect to CDM Server.
84
RemotingLoginDialog_CONNECTION_FAILED_TITLE=Connection failed
83 85
RemotingLoginDialog_DEFAULT_LOGIN=Default: %s (login), %s (password)
84 86
RemotingLoginDialog_CHOOSE_COMPATIBLE_CDM_SERVER=Please choose a compatible cdm-server or update the chosen cdm-server
85 87
RemotingLoginDialog_LABEL_ADVANCED=advanced
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/messages_de.properties
80 80
CdmStoreConnector_UPDATE_EDITOR_OR_CHOOSE_COMPATIBLE_DATASOURCE=Bitte aktualisieren Sie den Taxonomic Editor (Hilfe->Suche nach Updates) oder w?hlen sie eine kompatible Datenquelle
81 81
ConfiguratorComposite_CONFIGURE=Einstellungen
82 82

  
83
RemotingLoginDialog_CONNECTION_FAILED_MESSAGE=Eine Verbindung zum CDM-Server konnte nicht hergestellt werden.
84
RemotingLoginDialog_CONNECTION_FAILED_TITLE=Verbindung fehlgeschlagen
83 85
RemotingLoginDialog_DEFAULT_LOGIN=Standard: %s (Login), %s (Kennwort)
84 86
RemotingLoginDialog_CHOOSE_COMPATIBLE_CDM_SERVER=Bitte w?hlen Sie einen kompatiblen CDM-Server oder aktualisieren sie den CDM-Server
85 87
RemotingLoginDialog_LABEL_ADVANCED=Erweitert
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/RemotingLoginDialog.java
88 88
    /**
89 89
     *
90 90
     */
91
    private static final String DEFAULT_PASS = "00000";
91
    private static final String DEFAULT_PASS = "00000"; //$NON-NLS-1$
92 92
    /**
93 93
     *
94 94
     */
95
    private static final String DEFAULT_USER = "admin";
95
    private static final String DEFAULT_USER = "admin"; //$NON-NLS-1$
96 96
    private static final String UBUNTU = "Ubuntu"; //$NON-NLS-1$
97 97
	protected Object result;
98 98
    protected Shell shlConnect;
......
591 591
                    txtPort.setEditable(true);
592 592
                    txtPort.setEnabled(true);
593 593
                }
594
                if(selectedCsii.pingServer()) {
595
                    txtCdmServerStatus.setText(STATUS_AVAILABLE);
596
                    populateCdmInstanceCombo(true);
597
                    String serverVersionTimestamp = generateLastModifiedTooltip(selectedCsii.getCdmlibLastModified());
598
                    txtServerVersion.setText(selectedCsii.getCdmlibServicesVersion() + ":" + serverVersionTimestamp); //$NON-NLS-1$
599
                } else {
600
                    txtCdmServerStatus.setText(STATUS_NOT_AVAILABLE);
601
                    comboCdmInstance.removeAll();
602
                    disableCdmInstanceControls("", "");
594
                try {
595
                    if(selectedCsii.pingServer()) {
596
                        txtCdmServerStatus.setText(STATUS_AVAILABLE);
597
                        populateCdmInstanceCombo(true);
598
                        String serverVersionTimestamp = generateLastModifiedTooltip(selectedCsii.getCdmlibLastModified());
599
                        txtServerVersion.setText(selectedCsii.getCdmlibServicesVersion() + ":" + serverVersionTimestamp); //$NON-NLS-1$
600
                    } else {
601
                        txtCdmServerStatus.setText(STATUS_NOT_AVAILABLE);
602
                        comboCdmInstance.removeAll();
603
                        disableCdmInstanceControls("", ""); //$NON-NLS-1$ //$NON-NLS-2$
604
                    }
605
                } catch (CDMServerException | IOException e) {
606
                    MessagingUtils.errorDialog(Messages.RemotingLoginDialog_CONNECTION_FAILED_TITLE, this,
607
                            Messages.RemotingLoginDialog_CONNECTION_FAILED_MESSAGE,
608
                            TaxeditorStorePlugin.PLUGIN_ID, e, true, true);
603 609
                }
604 610
            }
605 611
            updatePort();
eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/ui/dialogs/CdmServerInfoTest.java
8 8
 */
9 9
package eu.etaxonomy.taxeditor.ui.dialogs;
10 10

  
11
import java.io.IOException;
11 12
import java.util.List;
12 13

  
13 14
import org.junit.Assert;
......
31 32
public class CdmServerInfoTest extends UnitilsJUnit4 {
32 33

  
33 34
    @Test
34
    public void pingServersTest() {
35
    public void pingServersTest() throws CDMServerException, IOException {
35 36
        List<CdmServerInfo> servers = CdmServerInfo.getCdmServers();
36 37
        for(CdmServerInfo server : servers) {
37 38
            server.pingServer();

Also available in: Unified diff