Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice')
-rw-r--r--rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/Activator.java76
-rw-r--r--rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/ConnectorServiceResources.java32
-rw-r--r--rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/ConnectorServiceResources.properties20
-rw-r--r--rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/DStoreConnectorService.java1329
-rw-r--r--rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/DStoreConnectorServiceManager.java113
-rw-r--r--rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/IUniversalDStoreConstants.java70
-rw-r--r--rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/IUniversalDStoreMessages.java60
-rw-r--r--rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/IUniversalDStoreSubSystem.java26
-rw-r--r--rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/IUniversalSubSystemConfiguration.java26
-rw-r--r--rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/RexecDstoreServer.java1197
-rw-r--r--rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/util/ConnectionStatusListener.java272
-rw-r--r--rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/util/ICommunicationsDiagnostic.java82
-rw-r--r--rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/util/ICommunicationsDiagnosticFactory.java29
-rw-r--r--rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/util/StatusMonitor.java456
-rw-r--r--rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/util/StatusMonitorFactory.java78
15 files changed, 0 insertions, 3866 deletions
diff --git a/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/Activator.java b/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/Activator.java
deleted file mode 100644
index efd7676d3..000000000
--- a/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/Activator.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2006 IBM Corporation. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * {Name} (company) - description of contribution.
- ********************************************************************************/
-
-package org.eclipse.rse.connectorservice.dstore;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.rse.core.SystemBasePlugin;
-import org.eclipse.rse.ui.ISystemPreferencesConstants;
-import org.eclipse.rse.ui.RSEUIPlugin;
-import org.osgi.framework.BundleContext;
-
-
-/**
- * The main plugin class to be used in the desktop.
- */
-public class Activator extends SystemBasePlugin {
-
- //The shared instance.
- private static Activator plugin;
-
- /**
- * The constructor.
- */
- public Activator() {
- plugin = this;
- }
-
- /**
- * This method is called upon plug-in activation
- */
- public void start(BundleContext context) throws Exception
- {
- super.start(context);
- IPreferenceStore store = RSEUIPlugin.getDefault().getPreferenceStore();
- store.setDefault(IUniversalDStoreConstants.RESID_PREF_SOCKET_TIMEOUT, IUniversalDStoreConstants.DEFAULT_PREF_SOCKET_TIMEOUT);
- store.setDefault(ISystemPreferencesConstants.ALERT_SSL, ISystemPreferencesConstants.DEFAULT_ALERT_SSL);
- store.setDefault(ISystemPreferencesConstants.ALERT_NONSSL, ISystemPreferencesConstants.DEFAULT_ALERT_NON_SSL);
-
- }
-
- /**
- * This method is called when the plug-in is stopped
- */
- public void stop(BundleContext context) throws Exception {
- super.stop(context);
- plugin = null;
- }
-
- /**
- * Returns the shared instance.
- */
- public static Activator getDefault() {
- return plugin;
- }
-
-
-
- protected void initializeImageRegistry()
- {
- // TODO Auto-generated method stub
-
- }
-} \ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/ConnectorServiceResources.java b/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/ConnectorServiceResources.java
deleted file mode 100644
index 99c4c4d96..000000000
--- a/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/ConnectorServiceResources.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2006 IBM Corporation. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * {Name} (company) - description of contribution.
- ********************************************************************************/
-
-package org.eclipse.rse.connectorservice.dstore;
-
-import org.eclipse.osgi.util.NLS;
-
-public class ConnectorServiceResources extends NLS
-{
- private static String BUNDLE_NAME = "org.eclipse.rse.connectorservice.dstore.ConnectorServiceResources";//$NON-NLS-1$
-
- public static String DStore_ConnectorService_Label;
- public static String DStore_ConnectorService_Description;
-
- static {
- // load message values from bundle file
- NLS.initializeMessages(BUNDLE_NAME, ConnectorServiceResources.class);
- }
-} \ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/ConnectorServiceResources.properties b/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/ConnectorServiceResources.properties
deleted file mode 100644
index 6d39a835e..000000000
--- a/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/ConnectorServiceResources.properties
+++ /dev/null
@@ -1,20 +0,0 @@
-################################################################################
-# Copyright (c) 2006 IBM Corporation. All rights reserved.
-# This program and the accompanying materials are made available under the terms
-# of the Eclipse Public License v1.0 which accompanies this distribution, and is
-# available at http://www.eclipse.org/legal/epl-v10.html
-#
-# Initial Contributors:
-# The following IBM employees contributed to the Remote System Explorer
-# component that contains this file: David McKnight, Kushal Munir,
-# Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
-# Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
-#
-# Contributors:
-# {Name} (company) - description of contribution.
-################################################################################
-
-
-
-DStore_ConnectorService_Label=DStore Connector Service
-DStore_ConnectorService_Description=The DStore Connector Service uses RSE's DataStore protocol to connect to the host. You must have a DataStore daemon or server running on the remote machine. \ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/DStoreConnectorService.java b/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/DStoreConnectorService.java
deleted file mode 100644
index 1933b0a21..000000000
--- a/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/DStoreConnectorService.java
+++ /dev/null
@@ -1,1329 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2002, 2006 IBM Corporation. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * {Name} (company) - description of contribution.
- ********************************************************************************/
-
-package org.eclipse.rse.connectorservice.dstore;
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-import java.security.cert.X509Certificate;
-import java.util.List;
-import java.util.Vector;
-
-import javax.net.ssl.SSLException;
-import javax.net.ssl.SSLHandshakeException;
-
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.dstore.core.client.ClientConnection;
-import org.eclipse.dstore.core.client.ClientSSLProperties;
-import org.eclipse.dstore.core.client.ConnectionStatus;
-import org.eclipse.dstore.core.java.IRemoteClassInstance;
-import org.eclipse.dstore.core.java.RemoteClassLoader;
-import org.eclipse.dstore.core.model.DE;
-import org.eclipse.dstore.core.model.DataElement;
-import org.eclipse.dstore.core.model.DataStore;
-import org.eclipse.dstore.core.model.IDataStoreConstants;
-import org.eclipse.dstore.core.model.IDataStoreProvider;
-import org.eclipse.dstore.core.model.ISSLProperties;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.rse.connectorservice.dstore.util.ConnectionStatusListener;
-import org.eclipse.rse.connectorservice.dstore.util.StatusMonitor;
-import org.eclipse.rse.connectorservice.dstore.util.StatusMonitorFactory;
-import org.eclipse.rse.core.IRSESystemType;
-import org.eclipse.rse.core.RSECorePlugin;
-import org.eclipse.rse.core.SystemBasePlugin;
-import org.eclipse.rse.core.comm.ISystemKeystoreProvider;
-import org.eclipse.rse.core.comm.SystemKeystoreProviderManager;
-import org.eclipse.rse.core.model.IHost;
-import org.eclipse.rse.core.model.SystemSignonInformation;
-import org.eclipse.rse.core.subsystems.AbstractConnectorService;
-import org.eclipse.rse.core.subsystems.CommunicationsEvent;
-import org.eclipse.rse.core.subsystems.IRemoteServerLauncher;
-import org.eclipse.rse.core.subsystems.IServerLauncher;
-import org.eclipse.rse.core.subsystems.IServerLauncherProperties;
-import org.eclipse.rse.core.subsystems.ServerLaunchType;
-import org.eclipse.rse.core.subsystems.SubSystem;
-import org.eclipse.rse.dstore.universal.miners.environment.EnvironmentMiner;
-import org.eclipse.rse.services.clientserver.messages.SystemMessage;
-import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
-import org.eclipse.rse.ui.ISystemMessages;
-import org.eclipse.rse.ui.ISystemPreferencesConstants;
-import org.eclipse.rse.ui.RSEUIPlugin;
-import org.eclipse.rse.ui.SystemPropertyResources;
-import org.eclipse.rse.ui.actions.DisplayHidableSystemMessageAction;
-import org.eclipse.rse.ui.actions.DisplaySystemMessageAction;
-import org.eclipse.rse.ui.messages.SystemMessageDialog;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.Version;
-
-/**
- * System class required by the remote systems framework.
- * This represents the live connection at tool runtime.
- * <p>
- * The universal subsystems are based on datastore technology so we use that
- * to do the connection.
- */
-public class DStoreConnectorService extends AbstractConnectorService implements IDataStoreProvider
-{
-
- private ClientConnection clientConnection = null;
- private ConnectionStatusListener _connectionStatusListener = null;
-
- // Shortcut to sysInfo to save time
- private transient DataElement sysInfo = null;
- private transient DataElement installInfo = null;
- private transient DataElement clientIP = null;
- private static String DSTORE_PACKAGE = "org.eclipse.dstore.core"; //$NON-NLS-1$
-
- private Exception connectException;
- //private Hashtable restrictedTypes = null;
- private IServerLauncher starter;
-
-
- private class ShowConnectMessage implements Runnable
- {
- private SystemMessage _msg;
- public ShowConnectMessage(SystemMessage msg)
- {
- _msg = msg;
- }
-
- public void run()
- {
- SystemMessageDialog dlg = new SystemMessageDialog(SystemBasePlugin.getActiveWorkbenchShell(), _msg);
- dlg.open();
- }
- }
-
- /**
- * Constructor when we don't have a subsystem yet.
- * Call setSubSystem after.
- */
- public DStoreConnectorService(String name, String description, IHost host)
- {
- super(name, description, host, 0);
- }
-
-
-
- /*
- * Set the subsystem, when its not known at constructor time
- *
- public void setSubSystem(SubSystem ss)
- {
- super.setSubSystem(ss);
- setDaemonLaunchEnabled((SubSystemImpl)ss, false);
- }*/
-
-
- public int getServerVersion()
- {
- return clientConnection.getServerVersion();
- }
-
- public int getServerMinor()
- {
- return clientConnection.getServerMinor();
- }
-
- /**
- * Retrieve the value of a property which is contained in the environment miners
- * system info child. Currently supported properties:
- * <ul>
- * <li>os.name
- * <li>os.version
- * <li>user.home
- * <li>temp.dir
- * </ul>
- * @return The String value of the property or "" if the property was not found.
- */
- private String getSystemInfoProperty(String propertyName)
- {
- // System properties require a connection
- if (!isConnected())
- {
- try
- {
- getPrimarySubSystem().connect();
- }
- catch (Exception e)
- {
- SystemBasePlugin.logError("UniversalSystem.getSystemInfoProperty: error during connect", e);
- return ""; //$NON-NLS-1$
- }
- }
-
- String propertyValue = null;
- DataElement envMinerData = null;
- DataStore ds = getDataStore();
-
- // Check if we have sysInfo cached already
- if (sysInfo == null)
- {
- envMinerData = ds.findMinerInformation(EnvironmentMiner.MINER_ID);
- if (envMinerData != null)
- {
- sysInfo = ds.find(envMinerData, DE.A_NAME, "systemInfo", 1); //$NON-NLS-1$
- }
- }
-
- if (sysInfo != null)
- {
- DataElement propertyNode = ds.find(sysInfo, DE.A_NAME, propertyName, 1);
- if (propertyNode != null)
- {
- propertyValue = propertyNode.getSource();
- }
- else
- propertyValue = ""; //$NON-NLS-1$
- }
- else
- {
- SystemBasePlugin.logError("UniversalSystem.getSystemInfoNode: sysInfo node not found", null);
- SystemBasePlugin.logError("UniversalSystem.getSystemInfoNode: miner data = " + envMinerData, null);
- propertyValue = ""; //$NON-NLS-1$
- }
-
- return propertyValue;
- }
-
- /**
- * Return the version, release, modification of the remote system
- */
- public String getVersionReleaseModification()
- {
- if (!isConnected())
- return SystemPropertyResources.RESID_TERM_NOTAVAILABLE;
-
- StringBuffer buffer = new StringBuffer(getSystemInfoProperty("os.name")); //$NON-NLS-1$
- buffer.append(" "); //$NON-NLS-1$
- buffer.append(getSystemInfoProperty("os.version")); //$NON-NLS-1$
-
- return buffer.toString();
- }
-
- /**
- * Return the home directory of the remote system for the current user, if available.
- */
- public String getHomeDirectory()
- {
- return getSystemInfoProperty("user.home"); //$NON-NLS-1$
- }
-
- public boolean runClassInstanceRemotely(IRemoteClassInstance instance)
- {
- DataStore dataStore = getDataStore();
- dataStore.registerLocalClassLoader(instance.getClass().getClassLoader());
- dataStore.runRemoteClassInstance(instance);
- return true;
- }
-
- /**
- * Return the location where the RSE server is installed
- * @return the server install location
- */
- public String getServerInstallPath()
- {
- if (clientConnection != null)
- {
- if (installInfo == null)
- {
- DataStore ds = clientConnection.getDataStore();
- installInfo = ds.queryInstall();
- }
- return installInfo.getAttribute(DE.A_SOURCE);
- }
- return ""; //$NON-NLS-1$
- }
-
- /**
- * Return the Client IP that the RSE server is connected to. When connected,
- * the client IP is obtained from the server-side. When not-connected,
- * the fall back is to get the IP locally (note that the IP obtained locally
- * may be not be what you want when using VPN).
- * @return the client ip
- */
- public String getClientIP()
- {
- if (clientConnection != null && clientConnection.isConnected())
- {
- if (clientIP == null)
- {
- DataStore ds = clientConnection.getDataStore();
- clientIP = ds.queryClientIP();
- }
- return clientIP.getAttribute(DE.A_SOURCE);
- }
-
- // fall back to getting local machine ip address
- // this may be incorrect for the server in certain cases
- // like over VPN
- return RSECorePlugin.getLocalMachineIPAddress();
- }
-
- /**
- * Return the temp directory of the remote system for the current user, if available.
- */
- public String getTempDirectory()
- {
- return getSystemInfoProperty("temp.dir"); //$NON-NLS-1$
- }
-
- protected int getSocketTimeOutValue()
- {
- IPreferenceStore store = RSEUIPlugin.getDefault().getPreferenceStore();
- return store.getInt(IUniversalDStoreConstants.RESID_PREF_SOCKET_TIMEOUT);
- }
-
- /**
- * @see org.eclipse.rse.core.subsystems.IConnectorService#disconnect()
- */
- public void internalDisconnect(IProgressMonitor monitor) throws Exception
- {
- try
- {
- if (clientConnection != null)
- {
- // Is disconnect being called because the network (connection) went down?
- if (_connectionStatusListener != null && _connectionStatusListener.isConnectionDown())
- {
- notifyError();
- }
- else
- {
- // Fire comm event to signal state about to change
- fireCommunicationsEvent(CommunicationsEvent.BEFORE_DISCONNECT);
- }
-
- DataStore dataStore = getDataStore();
- if (dataStore != null && _connectionStatusListener != null)
- {
- dataStore.getDomainNotifier().removeDomainListener(_connectionStatusListener);
- }
-
- clientConnection.disconnect();
-
-// Fire comm event to signal state changed
- notifyDisconnection();
- clientConnection = null;
- // DKM - no need to clear uid cache
- clearPasswordCache(false); // clear in-memory password
- //clearUserIdCache(); // Clear any cached local user IDs
- sysInfo = null;
- installInfo = null;
- clientIP = null;
-
-
- }
- }
- catch (Exception exc)
- {
- throw new java.lang.reflect.InvocationTargetException(exc);
- }
- }
-
- private IRemoteServerLauncher getDStoreServerLauncher()
- {
- IServerLauncherProperties sl = getRemoteServerLauncherProperties();
- //System.out.println("in UniversalSystem#getServerLauncher: sl = "+sl);
- if (sl != null && sl instanceof IRemoteServerLauncher)
- {
- return (IRemoteServerLauncher)sl;
- }
- else
- //return ((SubSystemConfigurationImpl)ss.getParentSubSystemConfiguration()).getDefaultIBMServerLauncher(ss);
- return null; // should never happen!
- }
-
- protected void setPluginPathProperty()
- {
- Bundle bundle = RSEUIPlugin.getDefault().getBundle();
- URL pluginsURL = bundle.getEntry("/"); //$NON-NLS-1$
-
- try
- {
- String path = FileLocator.resolve(pluginsURL).getPath();
- File systemsPluginDir = new File(path);
- path = systemsPluginDir.getParentFile().getAbsolutePath();
- String version = (String)(bundle.getHeaders().get(org.osgi.framework.Constants.BUNDLE_VERSION));
- Version v = new Version(version);
- String versionString = v.toString();
- String dstorePath = getDStorePath(path, versionString);
- System.setProperty("A_PLUGIN_PATH", dstorePath); //$NON-NLS-1$
- }
- catch (IOException e)
- {
- }
- }
-
- private String getDStorePath(String pluginDir, String version)
- {
- File dstorePath = new File(pluginDir + "/" + DSTORE_PACKAGE + "_" + version); //$NON-NLS-1$ //$NON-NLS-2$
- if (!dstorePath.exists())
- {
- // might be in workspace
- dstorePath = new File(pluginDir + "/" + DSTORE_PACKAGE); //$NON-NLS-1$
- }
-
- return dstorePath.getAbsolutePath();
- }
-
-// /**
-// * Specify if you support connecting to a running daemon
-// * @deprecated use {@link #enableServerLaunchType(ISubSystem, ServerLaunchType, boolean)}
-// * or your subsystem factory should override {@link org.eclipse.rse.core.subsystems.SubSystemConfiguration#supportsServerLaunchType(ServerLaunchType)}
-// */
-// public void setDaemonLaunchEnabled(SubSystem subsystemImpl, boolean enable) {
-// enableServerLaunchType(subsystemImpl, ServerLaunchType.DAEMON_LITERAL, enable);
-// }
-
-// /**
-// * Return if you support connecting to a running daemon
-// * @deprecated Use instead {@link #isEnabledServerLaunchType(ISubSystem, ServerLaunchType)}
-// * or {@link org.eclipse.rse.core.subsystems.SubSystemConfiguration#supportsServerLaunchType(ServerLaunchType)}
-// */
-// public boolean getDaemonLaunchEnabled(SubSystem subsystemImpl) {
-// return isEnabledServerLaunchType(subsystemImpl, ServerLaunchType.DAEMON_LITERAL);
-// }
-
-// /**
-// * Specify if you support remotely launching a server script
-// * @deprecated use {@link #enableServerLaunchType(ISubSystem, ServerLaunchType, boolean)}
-// * or your subsystem factory should override {@link org.eclipse.rse.core.subsystems.SubSystemConfiguration#supportsServerLaunchType(ServerLaunchType)}
-// */
-// public void setRexecLaunchEnabled(SubSystem subsystemImpl, boolean enable) {
-// enableServerLaunchType(subsystemImpl, ServerLaunchType.REXEC_LITERAL, enable);
-// }
-
- /**
- * Return if you support remotely launching a server script
- * @deprecated Use instead {@link #isEnabledServerLaunchType(ISubSystem, ServerLaunchType)}
- * or {@link org.eclipse.rse.core.subsystems.SubSystemConfiguration#supportsServerLaunchType(ServerLaunchType)}
- */
- public boolean getRexecLaunchEnabled(SubSystem subsystemImpl) {
- return isEnabledServerLaunchType(subsystemImpl, ServerLaunchType.REXEC_LITERAL);
- }
-
-// /**
-// * Specify if you support connecting to a server already running
-// * @deprecated use {@link #enableServerLaunchType(ISubSystem, ServerLaunchType, boolean)}
-// * or your subsystem factory should override {@link org.eclipse.rse.core.subsystems.SubSystemConfiguration#supportsServerLaunchType(ServerLaunchType)}
-// */
-// public void setNoLaunchEnabled(SubSystem subsystemImpl, boolean enable) {
-// enableServerLaunchType(subsystemImpl, ServerLaunchType.RUNNING_LITERAL, enable);
-// }
-
- /**
- * Return if you support connecting to a server already running
- * @deprecated Use instead {@link #isEnabledServerLaunchType(ISubSystem, ServerLaunchType)}
- * or {@link org.eclipse.rse.core.subsystems.SubSystemConfiguration#supportsServerLaunchType(ServerLaunchType)}
- */
- public boolean getNoLaunchEnabled(SubSystem subsystemImpl) {
- return isEnabledServerLaunchType(subsystemImpl, ServerLaunchType.RUNNING_LITERAL);
- }
-
- /**
- * Return the remote server launcher, which implements IServerLauncher.
- * This is called by the default implementation of connect, if
- * subsystem.getParentSubSystemConfiguration().supportsServerLaunchProperties returns true.
- */
- public IServerLauncher getRemoteServerLauncher()
- {
- if (starter == null)
- starter = new RexecDstoreServer();
- ((RexecDstoreServer)starter).setClientConnection(clientConnection);
- ((RexecDstoreServer)starter).setSocketTimeoutValue(getSocketTimeOutValue());
- return starter;
- }
-
-
-
- /**
- * @see org.eclipse.rse.core.subsystems.IConnectorService#connect(IProgressMonitor)
- */
- protected synchronized void internalConnect(IProgressMonitor monitor) throws Exception
- {
- if (isConnected()) {
- return;
- }
-
- // set A_PLUGIN_PATH so that dstore picks up the property
- setPluginPathProperty();
-
- // Fire comm event to signal state about to change
- fireCommunicationsEvent(CommunicationsEvent.BEFORE_CONNECT);
-
- ConnectionStatus connectStatus = null;
- ConnectionStatus launchStatus = null;
-
- clientConnection = new ClientConnection(getPrimarySubSystem().getHost().getAliasName());
-
- clientConnection.setHost(getHostName());
- clientConnection.setPort(Integer.toString(getPort()));
-
-// ISubSystem ss = getPrimarySubSystem();
- getPrimarySubSystem();
- IRemoteServerLauncher serverLauncher = getDStoreServerLauncher();
-
- ServerLaunchType serverLauncherType = null;
- boolean autoDetectSSL = true;
- if (serverLauncher != null)
- {
- serverLauncherType = serverLauncher.getServerLaunchType();
- autoDetectSSL = serverLauncher.getAutoDetectSSL();
- }
- else
- {
- // System.out.println("server launcher is null");
- }
-
- //long t1 = System.currentTimeMillis();
- SystemMessage msg = null;
- boolean launchFailed = false;
-
- // get Socket Timeout Value Preference
- int timeout = getSocketTimeOutValue();
-
- if (serverLauncherType == ServerLaunchType.REXEC_LITERAL)
- {
- if (monitor != null)
- {
- SystemMessage cmsg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_STARTING_SERVER_VIA_REXEC);
- monitor.subTask(cmsg.getLevelOneText());
- }
-
- SystemSignonInformation info = getPasswordInformation();
-
- // GC: - if failed to get a connection in another way, try
- // starting the datastore server with rexec
- IServerLauncher starter = getRemoteServerLauncher();
- starter.setSignonInformation(info);
- starter.setServerLauncherProperties(serverLauncher);
- if (autoDetectSSL) timeout = 3000;
- else setSSLProperties(isUsingSSL());
-
- int iServerPort = launchUsingRexec(monitor, info, serverLauncher);
-
- if(iServerPort != 0)
- {
- clientConnection.setPort("" + iServerPort); //$NON-NLS-1$
-
- if (monitor != null)
- {
- SystemMessage cmsg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_CONNECTING_TO_SERVER);
- cmsg.makeSubstitution(clientConnection.getPort());
- monitor.subTask(cmsg.getLevelOneText());
- }
-
- // connect to launched server
- connectStatus = clientConnection.connect(null, timeout);
- if (!connectStatus.isConnected() && connectStatus.getMessage().startsWith(ClientConnection.CANNOT_CONNECT) && autoDetectSSL)
- {
- if (setSSLProperties(true))
- {
- iServerPort = launchUsingRexec(monitor, info, serverLauncher);
- if (iServerPort != 0)
- {
- clientConnection.setPort("" + iServerPort); //$NON-NLS-1$
- connectStatus = clientConnection.connect(null, timeout);
- }
- }
- }
- }
- else
- {
- launchFailed = true;
- connectStatus = new ConnectionStatus(false);
- msg = starter.getErrorMessage();
- String errorMsg = null;
- if (msg == null)
- {
- errorMsg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_COMM_CONNECT_FAILED).getLevelOneText();
- }
- else
- {
- errorMsg = msg.getLevelTwoText();
- }
- connectStatus.setMessage(errorMsg);
- }
- }
- // Start the server via the daemon
- else if (serverLauncherType == ServerLaunchType.DAEMON_LITERAL)
- {
- if (monitor != null)
- {
- SystemMessage cmsg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_STARTING_SERVER_VIA_DAEMON);
- monitor.subTask(cmsg.getLevelOneText());
- }
-
- // DY: getLocalUserId() may return null for Windows connections because
- // we no longer prompt for userid / pwd. But for other connections the userid
- // should be the same as the one stored in the password info (and for Windows
- // this will be the temp remoteuser userid.
- //launchStatus = clientConnection.launchServer(getLocalUserId(), getPassword(getPasswordInformation()));
- SystemSignonInformation info = getPasswordInformation();
- int daemonPort = serverLauncher.getDaemonPort();
-
- /* String daemonPortStr = getSubSystem().getVendorAttribute("IBM", "DAEMON_PORT");
- if (daemonPortStr != null && daemonPortStr.length() > 0)
- {
- daemonPort = Integer.parseInt(daemonPortStr);
- }*/
-
- // DKM - changed to use protected member so that others can override
- //launchStatus = clientConnection.launchServer(info.getUserid(), info.getPassword(), daemonPort);
- boolean usedSSL = false;
- launchStatus = launchServer(clientConnection, info, daemonPort, monitor);
- if (!launchStatus.isConnected() && !clientConnection.isKnownStatus(launchStatus.getMessage()))
- {
- if (setSSLProperties(true))
- {
- usedSSL = true;
- launchStatus = launchServer(clientConnection, info, daemonPort, monitor);
- }
- }
-
- if (!launchStatus.isConnected())
- {
- String launchMsg = launchStatus.getMessage();
- // If password has expired and must be changed
- if (launchMsg != null && (isPasswordExpired(launchMsg) || isNewPasswordInvalid(launchMsg)))
- {
- NewPasswordInfo newPasswordInfo = null;
- while (launchMsg != null && (isPasswordExpired(launchMsg) || isNewPasswordInvalid(launchMsg)))
- {
- newPasswordInfo = promptForNewPassword(isPasswordExpired(launchMsg) ? RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_VALIDATE_PASSWORD_EXPIRED) : RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_VALIDATE_PASSWORD_INVALID));
- launchStatus = changePassword(clientConnection, getPasswordInformation(), serverLauncher, monitor, newPasswordInfo.newPassword);
- launchMsg = launchStatus.getMessage();
- }
- if (newPasswordInfo != null)
- {
- setPassword(info.getUserid(), newPasswordInfo.newPassword, newPasswordInfo.savePassword);
- info = getPasswordInformation();
- }
- if (launchMsg != null && launchMsg.equals(IDataStoreConstants.ATTEMPT_RECONNECT))
- {
- internalConnect(monitor);
- return;
- }
- }
- else if (isPortOutOfRange(launchMsg))
- {
- launchFailed = true;
-
- SystemMessage cmsg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_PORT_OUT_RANGE);
- int colonIndex = launchMsg.indexOf(':');
- String portRange = launchMsg.substring(colonIndex + 1);
- cmsg.makeSubstitution(portRange);
-
- ShowConnectMessage msgAction = new ShowConnectMessage(cmsg);
- Display.getDefault().asyncExec(msgAction);
- return;
- }
- else
- {
- launchFailed = true;
- SystemBasePlugin.logError("Error launching server: " + launchStatus.getMessage(), null);
- }
- }
- if (launchStatus.isConnected())
- {
- if (monitor != null)
- {
- SystemMessage cmsg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_CONNECTING_TO_SERVER);
- cmsg.makeSubstitution(clientConnection.getPort());
- monitor.subTask(cmsg.getLevelOneText());
- }
- // connect to launched server
- connectStatus = clientConnection.connect(launchStatus.getTicket(), timeout);
- Throwable conE = connectStatus.getException();
- if (!connectStatus.isConnected() &&
- (connectStatus.getMessage().startsWith(ClientConnection.CANNOT_CONNECT) ||
- conE instanceof SSLException
- )
- )
- {
- if (conE instanceof SSLHandshakeException)
- {
- List certs = connectStatus.getUntrustedCertificates();
- if (certs != null && certs.size() > 0)
- {
- ISystemKeystoreProvider provider = SystemKeystoreProviderManager.getInstance().getDefaultProvider();
- if (provider != null)
- {
- if (provider.importCertificates(certs, getHostName()))
- {
- connect(monitor);
- return;
- }
- else
- {
- throw new InterruptedException();
- }
- }
- }
-
- }
- launchStatus = launchServer(clientConnection, info, daemonPort, monitor);
- if (!launchStatus.isConnected())
- {
- launchFailed = true;
- }
- else
- {
- if (setSSLProperties(!usedSSL))
- {
- connectStatus = clientConnection.connect(launchStatus.getTicket(), timeout);
- }
- }
- }
- if (!connectStatus.isConnected() && connectStatus.isSLLProblem())
- {
- importCertsAndReconnect(connectStatus, monitor);
- return;
- }
-
- /*
- if (connectStatus != null && connectStatus.getMessage().startsWith(ClientConnection.INCOMPATIBLE_UPDATE))
- {
- // offer to update it
- clientConnection.getDataStore().queryInstall();
- }
- */
- }
- else
- {
- connectStatus = new ConnectionStatus(false);
- connectStatus.setMessage(
- RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_COMM_CONNECT_FAILED).getLevelOneText());
- }
- }
- else if (serverLauncherType == ServerLaunchType.RUNNING_LITERAL)
- {
- if (monitor != null)
- {
- SystemMessage cmsg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_CONNECTING_TO_SERVER);
- cmsg.makeSubstitution(clientConnection.getPort());
- monitor.subTask(cmsg.getLevelOneText());
- }
- // connection directly
- boolean useSSL = isUsingSSL();
- setSSLProperties(useSSL);
- connectStatus = clientConnection.connect(null, timeout);
- }
- // server launcher type is unknown
- else
- {
- SystemSignonInformation info = getPasswordInformation();
- connectStatus = launchServer(clientConnection, info, serverLauncher, monitor);
- if (!connectStatus.isConnected() && !clientConnection.isKnownStatus(connectStatus.getMessage()))
- {
- if (setSSLProperties(true))
- {
- connectStatus = launchServer(clientConnection, info, serverLauncher, monitor);
- if (!connectStatus.isConnected() && connectStatus.isSLLProblem())
- {
- importCertsAndReconnect(connectStatus, monitor);
- return;
- }
- }
- }
-
- }
-
- // if connected
- if (connectStatus != null && connectStatus.isConnected())
- {
- IPreferenceStore store = RSEUIPlugin.getDefault().getPreferenceStore();
- if (clientConnection.getDataStore().usingSSL() && store.getBoolean(ISystemPreferencesConstants.ALERT_SSL))
- {
- msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_COMM_USING_SSL);
- msg.makeSubstitution(getHostName());
- DisplayHidableSystemMessageAction msgAction = new DisplayHidableSystemMessageAction(msg, store, ISystemPreferencesConstants.ALERT_SSL);
- Display.getDefault().syncExec(msgAction);
- if (msgAction.getReturnCode() != IDialogConstants.YES_ID)
- {
- internalDisconnect(monitor);
- throw new InterruptedException();
- }
- }
- else if (!clientConnection.getDataStore().usingSSL() && store.getBoolean(ISystemPreferencesConstants.ALERT_NONSSL))
- {
- msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_COMM_NOT_USING_SSL);
- msg.makeSubstitution(getHostName());
- DisplayHidableSystemMessageAction msgAction = new DisplayHidableSystemMessageAction(msg, store, ISystemPreferencesConstants.ALERT_NONSSL);
- Display.getDefault().syncExec(msgAction);
- if (msgAction.getReturnCode() != IDialogConstants.YES_ID)
- {
- internalDisconnect(monitor);
- throw new InterruptedException();
- }
- }
-
- DataStore dataStore = clientConnection.getDataStore();
-
- _connectionStatusListener = new ConnectionStatusListener(dataStore.getStatus(), this);
- dataStore.getDomainNotifier().addDomainListener(_connectionStatusListener);
-
-
-
- // DKM: dataStore needs a miners location
- // for now, I'll use dstore.miners as default location
- // (I've inserted the universal miner in it's minerFile.dat file)
-
- // DY: defect 46811 The minerFile.dat does not exist in this directory which causes a
- // java.io.FileNotFoundException to be printed to the console (not very
- // encouraging for the end user.) So I'm setting it to the current directory (.)
- // which should be where the code is run from
- //dataStore.addMinersLocation("org.eclipse.dstore.miners");
-
-
- StatusMonitor statusMonitor = StatusMonitorFactory.getInstance().getStatusMonitorFor(this, dataStore);
-
- if (launchStatus != null && launchStatus.isConnected())
- {
- //dataStore.showTicket(launchStatus.getTicket()); // send security token to server, this must be done first
- DataElement ticket = dataStore.createTicket(launchStatus.getTicket());
- dataStore.queryShowTicket(ticket);
- //statusMonitor.waitForUpdate(ticketStatus);
- }
- else
- {
- dataStore.showTicket(null);
- }
-
- if (dataStore.isDoSpirit()) dataStore.queryServerSpiritState();
-
- // Fire comm event to signal state changed
- fireCommunicationsEvent(CommunicationsEvent.AFTER_CONNECT);
-
- // is there a warning message?
- String message = connectStatus.getMessage();
- if (message != null)
- {
- if (message.startsWith(ClientConnection.CLIENT_OLDER))
- {
-
- msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_COMM_CLIENT_OLDER_WARNING);
- msg.makeSubstitution(getHostName());
- }
- else if (message.startsWith(ClientConnection.SERVER_OLDER))
- {
- msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_COMM_SERVER_OLDER_WARNING);
- msg.makeSubstitution(getHostName());
- }
- ShowConnectMessage msgAction = new ShowConnectMessage(msg);
- Display.getDefault().asyncExec(msgAction);
- }
-
- // register the classloader for this plugin with the datastore
- dataStore.registerLocalClassLoader(getClass().getClassLoader());
-
- int serverVersion = getServerVersion();
- if (serverVersion >= 8 || (serverVersion == 7 && getServerMinor() >= 1))
- {
- // register the preference for remote class caching with the datastore
- store.setDefault(IUniversalDStoreConstants.RESID_PREF_CACHE_REMOTE_CLASSES, IUniversalDStoreConstants.DEFAULT_PREF_CACHE_REMOTE_CLASSES);
- boolean cacheRemoteClasses = store.getBoolean(IUniversalDStoreConstants.RESID_PREF_CACHE_REMOTE_CLASSES);
-
- dataStore.setPreference(RemoteClassLoader.CACHING_PREFERENCE, cacheRemoteClasses ? "true" : "false"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- else
- {
- dataStore.addMinersLocation("."); //$NON-NLS-1$
- // older servers initialized in one shot
- DataElement schemaStatus = dataStore.getSchema();
-
- // Initialzie the miners
- if (monitor != null)
- {
- SystemMessage imsg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_INITIALIZING_SERVER);
- monitor.subTask(imsg.getLevelOneText());
- }
- DataElement initStatus = dataStore.initMiners();
- statusMonitor.waitForUpdate(schemaStatus);
- statusMonitor.waitForUpdate(initStatus);
- }
- //long t2 = System.currentTimeMillis();
- //System.out.println("connect time = "+(t2 - t1));
- }
- else
- {
- // if daemon launch failed because of an SSL problem
- if (launchFailed && launchStatus != null && launchStatus.isSLLProblem())
- {
- if (launchStatus.isSLLProblem())
- {
- launchStatus.getException();
-
- List certs = launchStatus.getUntrustedCertificates();
- if (certs.size() > 0)
- {
- ISystemKeystoreProvider provider = SystemKeystoreProviderManager.getInstance().getDefaultProvider();
- if (provider != null)
- {
- if (provider.importCertificates(certs, getHostName()))
- {
- internalConnect(monitor);
- return;
- }
- }
- }
- else
- {
-
- msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_CONNECT_SSL_EXCEPTION);
- msg.makeSubstitution(launchStatus.getMessage());
- }
- }
- }
-
- // if daemon launch failed (SSL or otherwise)
- if (launchFailed && launchStatus != null)
- {
- String launchMsg = launchStatus.getMessage();
- if (launchStatus.getException() != null)
- {
- Throwable exception = launchStatus.getException();
- msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_CONNECT_DAEMON_FAILED_EXCEPTION);
- msg.makeSubstitution(getHostName(), ""+serverLauncher.getDaemonPort(), exception); //$NON-NLS-1$
- }
- else if (launchMsg != null && launchMsg.indexOf(IDataStoreConstants.AUTHENTICATION_FAILED) != -1)
- {
- if (launchFailed)
- {
- clearPasswordCache(true);
- }
-
- // Display error message
- msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_COMM_AUTH_FAILED);
- msg.makeSubstitution(getHostName());
- DisplaySystemMessageAction msgAction = new DisplaySystemMessageAction(msg);
- Display.getDefault().syncExec(msgAction);
-
- // Re-prompt for password
- connectException = null;
- Display.getDefault().syncExec(new Runnable()
- {
- public void run()
- {
- try
- {
- promptForPassword(true);
- }
- catch (InterruptedException e)
- {
- connectException = e;
- }
- }
- });
-
- // Check if the user cancelled the prompt
- if (connectException instanceof InterruptedException)
- {
- throw connectException;
- }
-
- // Try to connect again. This is a recursive call, but will only
- // call if the user presses OK on the password prompt dialog, otherwise
- // it will continue and return
- internalConnect(monitor);
-
- // Since we got here we must be connected so skip error checking below
- return;
- }
- // If password has expired and must be changed
- else if (launchMsg != null && (isPasswordExpired(launchMsg) || isNewPasswordInvalid(launchMsg)))
- {
- NewPasswordInfo newPasswordInfo = null;
- while (launchMsg != null && (isPasswordExpired(launchMsg) || isNewPasswordInvalid(launchMsg)))
- {
- newPasswordInfo = promptForNewPassword(isPasswordExpired(launchMsg) ? RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_VALIDATE_PASSWORD_EXPIRED) : RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_VALIDATE_PASSWORD_INVALID));
- launchStatus = changePassword(clientConnection, getPasswordInformation(), serverLauncher, monitor, newPasswordInfo.newPassword);
- launchMsg = launchStatus.getMessage();
- }
- if (newPasswordInfo != null)
- {
- setPassword(getPasswordInformation().getUserid(), newPasswordInfo.newPassword, newPasswordInfo.savePassword);
- }
- if (launchMsg != null && launchMsg.equals(IDataStoreConstants.ATTEMPT_RECONNECT))
- {
- internalConnect(monitor);
- return;
- }
- }
- else if (launchMsg != null)
- {
- msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_CONNECT_DAEMON_FAILED);
- msg.makeSubstitution(getHostName(), clientConnection.getPort(), launchMsg);
- }
- }
-
- // if connection failed for known reason
- else if (connectStatus != null && !connectStatus.isConnected())
- {
- if (connectStatus.getMessage().startsWith(ClientConnection.INCOMPATIBLE_SERVER_UPDATE))
- {
- msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_COMM_INCOMPATIBLE_UPDATE);
- msg.makeSubstitution(getHostName());
- }
- else if (connectStatus.getMessage().startsWith(ClientConnection.INCOMPATIBLE_PROTOCOL))
- {
- msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_COMM_INCOMPATIBLE_PROTOCOL);
- msg.makeSubstitution(getHostName());
- }
- else
- {
- Throwable exception = connectStatus.getException();
- if (exception != null)
- {
- msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_CONNECT_FAILED);
- msg.makeSubstitution(getHostName(), exception);
- }
- }
- }
-
- // if connect failed for unknown reason
- else if (connectStatus == null)
- {
- SystemBasePlugin.logError("Failed to connect to remote system", null);
- msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_COMM_CONNECT_FAILED);
- msg.makeSubstitution(getHostName());
- }
-
- // if, for some reason, we don't have a message
- if (msg == null)
- {
- SystemBasePlugin.logError("Failed to connect to remote system" + connectStatus.getMessage(), null);
- msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_COMM_CONNECT_FAILED);
- msg.makeSubstitution(getHostName());
- }
-
- clientConnection.disconnect();
- clientConnection = null;
-
- // yantzi: artemis 6.0, check for invalid login (user ID / pwd) and reprompt for signon information
- if (msg.getFullMessageID().startsWith(ISystemMessages.MSG_COMM_INVALID_LOGIN))
- {
- if (launchFailed)
- {
- clearPasswordCache(true);
- }
-
- DisplaySystemMessageAction msgAction = new DisplaySystemMessageAction(msg);
- Display.getDefault().syncExec(msgAction);
-
- // Re-prompt for password
- connectException = null;
- Display.getDefault().syncExec(new Runnable()
- {
- public void run()
- {
- try
- {
- promptForPassword(true);
- }
- catch (InterruptedException e)
- {
- connectException = e;
- }
- }
- });
-
- // Check if the user cancelled the prompt
- if (connectException instanceof InterruptedException)
- {
- throw connectException;
- }
-
- // Try to connect again. This is a recursive call, but will only
- // call if the user presses OK on the password prompt dialog, otherwise
- // it will continue and return
- internalConnect(monitor);
-
- // we are connected from recursive so continue
- return;
- }
-
- throw new SystemMessageException(msg);
- }
- }
-
- protected boolean isPortOutOfRange(String message)
- {
- return message.indexOf(IDataStoreConstants.PORT_OUT_RANGE) != -1;
- }
-
- protected boolean isPasswordExpired(String message)
- {
- return message.indexOf(IDataStoreConstants.PASSWORD_EXPIRED) != -1;
- }
-
- protected boolean isNewPasswordInvalid(String message)
- {
- return message.indexOf(IDataStoreConstants.NEW_PASSWORD_INVALID) != -1;
- }
-
- protected void importCertsAndReconnect(ConnectionStatus connectStatus, IProgressMonitor monitor) throws Exception
- {
- List certs = connectStatus.getUntrustedCertificates();
- if (certs != null && certs.size() > 0)
- {
- ISystemKeystoreProvider provider = SystemKeystoreProviderManager.getInstance().getDefaultProvider();
- if (provider != null)
- {
- if (provider.importCertificates(certs, getHostName()))
- {
- internalConnect(monitor);
- return;
- }
- else
- {
- throw new InterruptedException();
- }
- }
- }
- }
-
- protected int launchUsingRexec(IProgressMonitor monitor, SystemSignonInformation info, IServerLauncherProperties serverLauncherProperties) throws Exception
- {
- IServerLauncher starter = getRemoteServerLauncher();
- starter.setSignonInformation(info);
- starter.setServerLauncherProperties(serverLauncherProperties);
-
- String serverPort = (String)starter.launch(monitor);
- if (monitor.isCanceled())
- {
- SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_OPERATION_CANCELLED);
- throw new SystemMessageException(msg);
- }
-
- int iServerPort = 0;
- if (serverPort != null)
- {
- iServerPort = Integer.parseInt(serverPort);
- }
- return iServerPort;
- }
-
- protected boolean setSSLProperties(boolean enable)
- {
- ISystemKeystoreProvider provider = SystemKeystoreProviderManager.getInstance().getDefaultProvider();
- if (provider != null)
- {
- String keyStore = provider.getKeyStorePath();
- String password = provider.getKeyStorePassword();
-
- ISSLProperties properties = new ClientSSLProperties(enable, keyStore, password);
- clientConnection.setSSLProperties(properties);
- return true;
- }
- else return false;
- }
-
-
-
- protected boolean promptForTrusting( X509Certificate cert)
- {
- return true;
- }
-
-
- /*
- * Launch a DataStore server using a daemon. This method can be overridden if a custom implementation is required.
- * The default implementation uses the daemon client that is built into ClientConnection.
- */
- protected ConnectionStatus launchServer(ClientConnection clientConnection, SystemSignonInformation info, int daemonPort, IProgressMonitor monitor)
- {
- return launchServer(clientConnection, info, daemonPort, monitor, 0);
- }
-
-
- /*
- * Launch a DataStore server using a daemon. This method can be overridden if a custom implementation is required.
- * The default implementation uses the daemon client that is built into ClientConnection.
- */
- protected ConnectionStatus launchServer(ClientConnection clientConnection, SystemSignonInformation info, int daemonPort, IProgressMonitor monitor, int timeout)
- {
- return clientConnection.launchServer(info.getUserid(), info.getPassword(), daemonPort, timeout);
- }
-
- /*
- * Launch a DataStore server using a specified server launcher. By default, this method does nothing since UniversalSystem does
- * not know how to handle this particular launch type. This method should be overridden to provide a custom implementation
- * of the launch.
- */
- protected ConnectionStatus launchServer(ClientConnection clientConnection, SystemSignonInformation info, IServerLauncherProperties launcher, IProgressMonitor monitor)
- {
- return null;
- }
-
- /**
- * Change the password on a remote system and optionally remain connected to it. Subclasses must implement this
- * method if they wish to
- * @param clientConnection The connection on which the password must be changed
- * @param info The old SystemSignonInformation, including the old password.
- * @param serverLauncherProperties The properties of the server launcher used to connect to the server. Use this object to get the type of serverlauncher, if your implementation varies depending on the type.
- * @param monitor a progress monitor
- * @param newPassword the new password to which the old one will be changed.
- * @return the status of the password change and optionally the connection. If the new password is rejected by the remote
- * system, return new ConnectionStatus(false, IDataStoreConstants.NEW_PASSWORD_INVALID).
- * If the system is now connected, and the server is ready to be connected, construct a new ConnectionStatus(true) and if using the RSE daemon, set the ticket on it
- * to the ticket number of the server. If you wish to just have the UniversalSystem attempt a reconnect from the beginning after changing the password,
- * return new ConnectionStatus(true, IDataStoreConstants.ATTEMPT_RECONNECT).
- */
- protected ConnectionStatus changePassword(ClientConnection clientConnection, SystemSignonInformation info, IServerLauncherProperties serverLauncherProperties, IProgressMonitor monitor, String newPassword)
- {
- return new ConnectionStatus(false, IDataStoreConstants.AUTHENTICATION_FAILED);
- }
-
- /**
- * @see org.eclipse.rse.core.subsystems.IConnectorService#isConnected()
- */
- public boolean isConnected()
- {
- if (clientConnection != null)
- {
- return clientConnection.isConnected();
- }
-
- return false;
- }
-
- /**
- * Shortcut to checking if the network is down
- */
- public boolean isNetworkError()
- {
- if (_connectionStatusListener != null)
- {
- return _connectionStatusListener.isConnectionDown();
- }
-
- return false;
- }
-
- /**
- * Show any warning messages returned by host api calls.
- * @param shell Parent UI
- * @param warnings Vector of String or toString()'able messages.
- */
- public void showWarningMsgs(Shell shell, Vector warnings)
- {
- for (int idx = 0; idx < warnings.size(); idx++)
- {
- SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_GENERIC_W);
- msg.makeSubstitution((warnings.elementAt(idx)).toString());
- SystemMessageDialog msgDlg = new SystemMessageDialog(shell, msg);
- msgDlg.open();
- }
- }
-
- /**
- * @return The DataStore currently being used by this connection.
- */
- public DataStore getDataStore()
- {
- if (clientConnection != null)
- {
- return clientConnection.getDataStore();
- }
- else
- {
- return null;
- }
- }
-
- /**
- * @see org.eclipse.rse.core.subsystems.AbstractConnectorService#getPasswordInformation()
- */
- public SystemSignonInformation getPasswordInformation()
- {
- // For Windows we want to avoid the signon prompt (because we never
- // really authenticate with the remote system and this would be decieving
- // for the end user
-
- if (getPrimarySubSystem().getHost().getSystemType().equals(IRSESystemType.SYSTEMTYPE_WINDOWS))
- {
- String userid = getPrimarySubSystem().getUserId();
- if (userid == null)
- {
- userid = "remoteuser"; //$NON-NLS-1$
- }
- SystemSignonInformation info = new SystemSignonInformation(getPrimarySubSystem().getHost().getHostName(),
- userid, "", IRSESystemType.SYSTEMTYPE_WINDOWS); //$NON-NLS-1$
- return info;
- }
- else
- {
- return super.getPasswordInformation();
- }
- }
-
- /**
- * @see org.eclipse.rse.core.subsystems.AbstractConnectorService#isPasswordCached()
- */
-// public boolean isPasswordCached() // DWD is this method needed?
-// {
-// // For Windows we never prompt for userid / password so we don't need
-// // to clear the password cache
-// if (getPrimarySubSystem().getHost().getSystemType().equals(IRSESystemType.SYSTEMTYPE_WINDOWS))
-// {
-// return false;
-// }
-// else
-// {
-// return super.isPasswordCached();
-// }
-// }
-
-
-
-
-
- public boolean hasRemoteServerLauncherProperties()
- {
- return getRemoteServerLauncherProperties() != null;
- }
-
-
-
- public boolean supportsRemoteServerLaunching()
- {
- return true;
- }
-
-
-
- public boolean supportsServerLaunchProperties()
- {
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.rse.core.subsystems.AbstractConnectorService#requiresPassword()
- */
- public boolean requiresPassword() {
- IHost host = getHost();
- String systemType = host.getSystemType();
- boolean requiresPassword = !systemType.equals("Windows");
- return requiresPassword;
- }
-
-} \ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/DStoreConnectorServiceManager.java b/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/DStoreConnectorServiceManager.java
deleted file mode 100644
index 8861f7cae..000000000
--- a/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/DStoreConnectorServiceManager.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2002, 2006 IBM Corporation. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * {Name} (company) - description of contribution.
- ********************************************************************************/
-
-package org.eclipse.rse.connectorservice.dstore;
-import org.eclipse.rse.core.model.IHost;
-import org.eclipse.rse.core.subsystems.AbstractConnectorServiceManager;
-import org.eclipse.rse.core.subsystems.IConnectorService;
-import org.eclipse.rse.core.subsystems.ISubSystem;
-
-
-
-/**
- * ISystem manager class.
- * There should be only one of these instantiated.
- * Use getTheUniversalSystemManager to get that singleton.
- * <p>
- * The job of this manager is to manage and return ISystem objects.
- * It ensures there is only ever one per unique SystemConnection,
- * so that both the file and cmd subsystems can share the same system object.
- */
-public class DStoreConnectorServiceManager extends AbstractConnectorServiceManager
-{
- private static DStoreConnectorServiceManager inst = null;
-
- /**
- * Private constructor to ensure not instantiated this way.
- * Use getTheUniversalSystemManager instead.
- */
- private DStoreConnectorServiceManager()
- {
- }
-
- /**
- * Return singleton instance of this class
- */
- public static DStoreConnectorServiceManager getTheUniversalSystemManager()
- {
- if (inst == null)
- inst = new DStoreConnectorServiceManager();
- return inst;
- }
-
- /**
- * Return true if the singleton has been created.
- * This saves creating it at shutdown just to test for isConnected.
- */
- public static boolean isInstantiated()
- {
- return (inst != null);
- }
-
- // -------------------------------------
- // ABSTRACT METHODS FROM PARENT CLASS...
- // -------------------------------------
-
- /**
- * Return the actual ISystem object. We return an instance of UniversalSystem.
- */
- public IConnectorService createConnectorService(IHost host)
- {
- IConnectorService service = new DStoreConnectorService(ConnectorServiceResources.DStore_ConnectorService_Label, ConnectorServiceResources.DStore_ConnectorService_Description, host);
- return service;
- }
-
- /**
- * For all subsystems in a particular SystemConnection, we need to know which
- * ones are to share a single ISystem object. To do this, we need a key which
- * is canonical for all subsystems in a given connection. This can be anything,
- * but is typically a unique interface that all subsystems supported a shared
- * ISystem object implement.
- * <p>
- * Whatever is returned from here is used as the key into a hashtable to find the
- * singleton ISystem object in getSystemObject.
- * <p>
- * @return IUniversalSubSystem.class
- */
- public Class getSubSystemCommonInterface(ISubSystem subsystem)
- {
- return IUniversalDStoreSubSystem.class;
- }
- /**
- * Given another subsystem, return true if that subsystem shares a single ISystem object
- * with this one. You must override this to return true if you recognize that subsystem
- * as one of your own. You are guaranteed the other subsystem will be from the same
- * SystemConnection as this one.
- * <p>
- * You can't assume a SystemConnection will you only have subsystems of that you created,
- * so you should only return true if it implements your interface or you know it is an
- * instance of your subsystem class.
- * <p>
- * This should simply return (otherSubSystem instanceof interface) where interface is
- * the same one returned from getSubSystemCommonInterface
- *
- * @return true if otherSubSystem instanceof IUniversalSubSystem
- */
- public boolean sharesSystem(ISubSystem otherSubSystem)
- {
- return (otherSubSystem instanceof IUniversalDStoreSubSystem);
- }
-} \ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/IUniversalDStoreConstants.java b/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/IUniversalDStoreConstants.java
deleted file mode 100644
index d8fe70b59..000000000
--- a/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/IUniversalDStoreConstants.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2002, 2006 IBM Corporation. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * {Name} (company) - description of contribution.
- ********************************************************************************/
-
-package org.eclipse.rse.connectorservice.dstore;
-/**
- * Constants used throughout the UniversalSystem plugin
- */
-public interface IUniversalDStoreConstants
-{
-
-
- public static final String PLUGIN_ID ="org.eclipse.rse.connectorservice.dstore";
-
- public static final String PREFIX = PLUGIN_ID + ".";
-
- // prefix for context sensitive help
- public static final String HELP_PREFIX = PREFIX;
-
- // Resource Bundle ids
- public static final String RESID_PREFIX = PREFIX + "ui.";
-
- // Icons
- public static final String ICON_DIR = "icons";
- public static final String ICON_PATH = java.io.File.separator + ICON_DIR + java.io.File.separator;
- public static final String ICON_SUFFIX = "Icon";
- public static final String ICON_EXT = ".gif";
-
- //public static final String ICON_SYSTEM_LIBRARY_ROOT = "system400Library";
- //public static final String ICON_SYSTEM_LIBRARY = ICON_SYSTEM_LIBRARY_ROOT + ICON_EXT;
- //public static final String ICON_SYSTEM_LIBRARY_ID = PREFIX + ICON_SYSTEM_LIBRARY_ROOT + ICON_SUFFIX;
-
- // -------------------------
- // Action prefixes.
- // SYstemBaseAction class adds "label" to get text and "tooltip" and "description" to get hover help
- // -------------------------
- // action ids
- public static final String ACTION_PREFIX = RESID_PREFIX + "action.";
- public static final String RESID_RUN_REMOTECMD_PREFIX = ACTION_PREFIX+"RunRemoteCommand";
-
-
- // -------------------------
- // Preferences...
- // -------------------------
- public static final String RESID_PREF_PREFIX = RESID_PREFIX+"preferences.";
- public static final String RESID_PREF_ROOT_TITLE = RESID_PREF_PREFIX+"root.title";
-
- // RemoteClassLoader caching preferences
- public static final String RESID_PREF_CACHE_REMOTE_CLASSES = RESID_PREF_PREFIX + "cacheremoteclasses";
- public static final boolean DEFAULT_PREF_CACHE_REMOTE_CLASSES = true;
-
- // Socket timeout preference
- public static final String RESID_PREF_SOCKET_TIMEOUT = RESID_PREF_PREFIX + "sockettimeout";
- public static final int DEFAULT_PREF_SOCKET_TIMEOUT = 300000;
-
- public static final String RESID_PREF_DO_KEEPALIVE = RESID_PREF_PREFIX + "dokeepalive";
- public static final boolean DEFAULT_PREF_DO_KEEPALIVE = true;
-} \ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/IUniversalDStoreMessages.java b/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/IUniversalDStoreMessages.java
deleted file mode 100644
index 525516f36..000000000
--- a/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/IUniversalDStoreMessages.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * {Name} (company) - description of contribution.
- ********************************************************************************/
-
-package org.eclipse.rse.connectorservice.dstore;
-
-/**
- * Message IDs
- */
-public interface IUniversalDStoreMessages
-{
-
-
- public static final String PLUGIN_ID ="org.eclipse.rse.connectorservice.dstore";
- public static final String PREFIX = PLUGIN_ID+".";
- // Resource Bundle ids
- public static final String RESID_PREFIX = PREFIX+"ui.";
- // Messages prefixes
- public static final String MSG_PREFIX = RESID_PREFIX+"msg.";
- public static final String MSG_TITLE = MSG_PREFIX + "Title";
-
- // Messages
- public static final String MSG_CONNECTION_PREFIX = MSG_PREFIX + "Connection.";
- public static final String MSG_CONNECTION_FAILED = MSG_CONNECTION_PREFIX + "Failed";
- public static final String MSG_CONNECTION_UNKNOWN_HOST = MSG_CONNECTION_PREFIX + "UnknownHost";
- public static final String MSG_CONNECTION_VERIFY = MSG_CONNECTION_PREFIX + "Verify";
- public static final String MSG_CONNECTION_COMMPROPERTIES = MSG_CONNECTION_PREFIX + "CommProperties";
-
- // RSE Server Connection Messages
- public static final String MSG_SIGNON_PREFIX = MSG_PREFIX + "Signon.";
- public static final String MSG_SIGNON_PASSWORD_ERROR = MSG_SIGNON_PREFIX + "PasswordError";
- public static final String MSG_SIGNON_PASSWORD_INCORRECT = MSG_SIGNON_PREFIX + "PasswordIncorrect";
- public static final String MSG_SIGNON_PASSWORD_INCORRECT_USER_DISABLED= MSG_SIGNON_PREFIX + "PasswordIncorrectUserDisabled";
- public static final String MSG_SIGNON_PASSWORD_EXPIRED = MSG_SIGNON_PREFIX + "PasswordExpired";
- public static final String MSG_SIGNON_USERID_INVALID = MSG_SIGNON_PREFIX + "UserIDInvalid";
- public static final String MSG_SIGNON_USERID_DISABLED = MSG_SIGNON_PREFIX + "UserIDDisabled";
- public static final String MSG_SIGNON_USERID_ERROR = MSG_SIGNON_PREFIX + "UserIDError";
-
- public static final String MSG_DATASTORE_PREFIX = MSG_PREFIX + "DataStore.";
- public static final String MSG_DATASTORE_STARTSERVER = MSG_DATASTORE_PREFIX + "StartServer";
- public static final String MSG_DATASTORE_CONNECTSERVER = MSG_DATASTORE_PREFIX + "ConnectServer";
- public static final String MSG_DATASTORE_INITIALIZESERVER = MSG_DATASTORE_PREFIX + "InitializeServer";
- public static final String MSG_DATASTORE_INITIALIZECODESERVER = MSG_DATASTORE_PREFIX + "InitializeCODEServer";
-
- public static final String MSG_CMD_PREFIX = MSG_PREFIX + "Command.";
- public static final String MSG_CMDNAME_EMPTY = MSG_CMD_PREFIX + "Required";
- public static final String MSG_CMDNAME_NOTVALID = MSG_CMD_PREFIX + "NotValid";
-} \ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/IUniversalDStoreSubSystem.java b/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/IUniversalDStoreSubSystem.java
deleted file mode 100644
index f291564a1..000000000
--- a/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/IUniversalDStoreSubSystem.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2002, 2006 IBM Corporation. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * {Name} (company) - description of contribution.
- ********************************************************************************/
-
-package org.eclipse.rse.connectorservice.dstore;
-/**
- * Simply a tag to indicate this factory is one our universal subsystems.
- */
-public interface IUniversalDStoreSubSystem
-{
-
-
-
-} \ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/IUniversalSubSystemConfiguration.java b/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/IUniversalSubSystemConfiguration.java
deleted file mode 100644
index 95e52a035..000000000
--- a/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/IUniversalSubSystemConfiguration.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2002, 2006 IBM Corporation. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * {Name} (company) - description of contribution.
- ********************************************************************************/
-
-package org.eclipse.rse.connectorservice.dstore;
-/**
- * Simply a tag to indicate this factory is one our universal subsystem factories.
- */
-public interface IUniversalSubSystemConfiguration
-{
-
-
-
-} \ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/RexecDstoreServer.java b/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/RexecDstoreServer.java
deleted file mode 100644
index 521336d74..000000000
--- a/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/RexecDstoreServer.java
+++ /dev/null
@@ -1,1197 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2002, 2006 IBM Corporation. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * {Name} (company) - description of contribution.
- ********************************************************************************/
-
-package org.eclipse.rse.connectorservice.dstore;
-
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.EOFException;
-import java.net.Socket;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.dstore.core.client.ClientConnection;
-import org.eclipse.dstore.core.client.ConnectionStatus;
-import org.eclipse.rse.core.SystemBasePlugin;
-import org.eclipse.rse.core.model.SystemSignonInformation;
-import org.eclipse.rse.core.subsystems.IRemoteServerLauncher;
-import org.eclipse.rse.core.subsystems.IServerLauncher;
-import org.eclipse.rse.core.subsystems.IServerLauncherProperties;
-import org.eclipse.rse.services.clientserver.messages.SystemMessage;
-import org.eclipse.rse.ui.ISystemMessages;
-import org.eclipse.rse.ui.RSEUIPlugin;
-
-/**
- * Launch Datastore server on selected host using the rexec
- * protocol
- */
-public class RexecDstoreServer implements IServerLauncher
-{
- private SystemMessage _errorMessage;
- private SystemSignonInformation signonInfo;
- //private String host = null;
- private String cwd = null;
- private String invocation = null;
- //private String userID = null;
- private int rexecPort = 512; // the port where rexecd normally listens
- private String cmd = null;
- //private String pwd = null;
- private static String ASCII_TEST_STRING = "ASCII";
- private static String PORT_LEADING_STRING = "Server Started Successfully";
- private static final String EZYRD11E="EZYRD11E";
- private ClientConnection clientConnection;
- private IServerLauncherProperties propertyInfo;
- private boolean isModeChecked = false;
- private boolean checkPort =true;
- private boolean logInfo = false;
- private int _socketTimeoutValue = IUniversalDStoreConstants.DEFAULT_PREF_SOCKET_TIMEOUT;
-
- private static char[] ebcdictounicode =
- {
- 0x0000,
- 0x0001,
- 0x0002,
- 0x0003,
- 0x0000,
- 0x0009,
- 0x0000,
- 0x007F,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x000B,
- 0x000C,
- 0x000D,
- 0x000E,
- 0x000F,
- 0x0010,
- 0x0011,
- 0x0012,
- 0x0013,
- 0x0000,
- 0x000A,
- 0x0008,
- 0x0000,
- 0x0018,
- 0x0019,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x001C,
- 0x0000,
- 0x0000,
- 0x000A,
- 0x0017,
- 0x001B,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0005,
- 0x0006,
- 0x0007,
- 0x0000,
- 0x0000,
- 0x0016,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0004,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0014,
- 0x0015,
- 0x0000,
- 0x001A,
- 0x0020,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x002E,
- 0x003C,
- 0x0028,
- 0x002B,
- 0x007C,
- 0x0026,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0021,
- 0x0024,
- 0x002A,
- 0x0029,
- 0x003B,
- 0x0000,
- 0x002D,
- 0x002F,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x007C,
- 0x002C,
- 0x0025,
- 0x005F,
- 0x003E,
- 0x003F,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0060,
- 0x003A,
- 0x0023,
- 0x0040,
- 0x0027,
- 0x003D,
- 0x0022,
- 0x0000,
- 0x0061,
- 0x0062,
- 0x0063,
- 0x0064,
- 0x0065,
- 0x0066,
- 0x0067,
- 0x0068,
- 0x0069,
- 0x0000,
- 0x007B,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x002B,
- 0x0000,
- 0x006A,
- 0x006B,
- 0x006C,
- 0x006D,
- 0x006E,
- 0x006F,
- 0x0070,
- 0x0071,
- 0x0072,
- 0x0000,
- 0x007D,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0073,
- 0x0074,
- 0x0075,
- 0x0076,
- 0x0077,
- 0x0078,
- 0x0079,
- 0x007A,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x005B,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x005D,
- 0x0000,
- 0x002D,
- 0x007D,
- 0x0041,
- 0x0042,
- 0x0043,
- 0x0044,
- 0x0045,
- 0x0046,
- 0x0047,
- 0x0048,
- 0x0049,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x007D,
- 0x004A,
- 0x004B,
- 0x004C,
- 0x004D,
- 0x004E,
- 0x004F,
- 0x0050,
- 0x0051,
- 0x0052,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x005C,
- 0x0000,
- 0x0053,
- 0x0054,
- 0x0055,
- 0x0056,
- 0x0057,
- 0x0058,
- 0x0059,
- 0x005A,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0030,
- 0x0031,
- 0x0032,
- 0x0033,
- 0x0034,
- 0x0035,
- 0x0036,
- 0x0037,
- 0x0038,
- 0x0039,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000,
- 0x0000 };
-
- /**
- * Constructor
- */
- public RexecDstoreServer()
- {
- super();
- }
-
- /**
- * Set the datastore client connection. This is reset for each connect()
- */
- public void setClientConnection(ClientConnection clientConnection)
- {
- this.clientConnection = clientConnection;
- }
-
- /**
- * Set the remote system signon information
- */
- public void setSignonInformation(SystemSignonInformation info)
- {
- this.signonInfo = info;
- }
-
- /**
- * Get the remote system signon information, as set in
- * {@link #setSignonInformation(SystemSignonInformation)}
- */
- public SystemSignonInformation getSignonInformation()
- {
- return signonInfo;
- }
-
- /**
- * Set the object which contains the user-specified properties that
- * are used by this launcher
- */
- public void setServerLauncherProperties(IServerLauncherProperties propertyInfo)
- {
- this.propertyInfo = propertyInfo;
- // set path...
- this.cwd = ((IRemoteServerLauncher)propertyInfo).getServerPath();
- char separatorChar = signonInfo.getSystemType().equals("Windows") ? '\\' : '/';
- if (cwd.length() > 0 && cwd.charAt(cwd.length() - 1) != separatorChar)
- cwd += separatorChar;
- // set script...
- this.invocation = ((IRemoteServerLauncher)propertyInfo).getServerScript();
- }
-
- /**
- * Get the object which contians the user-specified properties that are
- * used by this launcher. As set in {@link #setServerLauncherProperties(IServerLauncherProperties)}.
- */
- public IServerLauncherProperties getServerLauncherProperties()
- {
- return propertyInfo;
- }
-
- /**
- * Determine if the remote server needs to be launched or not.
- * Generally is always false.
- */
- public boolean isLaunched()
- {
- return false;
- }
-
- /**
- * Send a command to the host via rexec to launch the datastore server
- * under the specified user ID/pwd. the datastore server will emit
- * messages that include the port number on which the server is listening
- * for client connections
- *
- * @return port number as String
- */
- /*
- * There used to be a problem in IBM Communications Server for z/OS and
- * the message from the REXEC daemon was in EBCDIC. see APAR PQ76782.
- * Since this problem was fixed in Communication Server, there is no need to convert EBCDIC to ASCII
- */
- // updated method
- public Object launch(IProgressMonitor monitor) throws Exception
- {
-
- boolean isEBCDICTest=false;
- isModeChecked= false;
- checkPort=true;
- _errorMessage = null;
- String port = new String("0"); // default no port
- //String hostResponse = ""; //buffer to hold all the messages, so that it can be printed out later
- String originalHostResponse="";
- String convertedHostResponse="";
- String debugOptions = System.getProperty("REXEC_DEBUG");
- if (debugOptions!= null){
- if (debugOptions.toUpperCase().indexOf("LOG") > -1)
- logInfo = true;
- if (debugOptions.toUpperCase().indexOf("EBCDIC") > -1)
- isEBCDICTest=true;
- }
- boolean isEBCDIC = false;
- try
- {
-
- // establish socket for rexec connection
- Socket rexecCall = new Socket(signonInfo.getHostname(), rexecPort); // rexec listens here - 512
-
- // set socket timeout value
- rexecCall.setSoTimeout(_socketTimeoutValue);
-
- // set up data streams on rexec socket
- DataOutputStream rxOut = new DataOutputStream(rexecCall.getOutputStream());
- DataInputStream rxIn = new DataInputStream(rexecCall.getInputStream());
-
- // we're not opening a socket for stderr to circumvent problems that
- // may arise if the client is behind a firewall with respect to the
- // host, in which case the rexec daemon may have trouble connecting
- // to the client error port.
- // Not sending a port number at this point indicates to the daemon
- // that there is no error socket to establish.
- rxOut.writeByte(0); // send null terminator
- rxOut.flush();
-
- // send userid and password on rexec socket
- rxOut.writeBytes(signonInfo.getUserid());
- rxOut.writeByte(0); // send null terminator
- rxOut.writeBytes(signonInfo.getPassword());
- rxOut.writeByte(0); // send null terminator
- rxOut.flush();
-
- // send the command on rexec socket to start datastore daemon listening
- // on any port
- // TODO - assumes a particular script and location to start the server,
- // this should be stored in some resource bundle later
- //cmd = new String ("echo USSTEST;cd ~/dstore;start_anyport");
- //cmd = new String("echo " + ASCII_TEST_STRING + ";cd ~/rseserver;start_anyport");
- cmd = new String("echo " + ASCII_TEST_STRING + ";cd " + this.cwd + ";" + this.invocation);
- //cmd = new String("echo " + ASCII_TEST_STRING + ";cd " + this.cwd + ";" + this.invocation + " " + System.getProperty("user.name"));
- logMessage("The command is " + cmd);
- SystemBasePlugin.logInfo("RexecDstoreServer :");
-
- rxOut.writeBytes(cmd);
- rxOut.writeByte(0); // send null terminator
- rxOut.flush();
-
- int inBytes = rxIn.available(); // any data available?
-
- int timeout = 600; // 60 second to connect
-
- while (inBytes == 0 && timeout > 0)
- {
- if (monitor.isCanceled()) // Cancel button pressed?
- return "0";
-
- // try for more input
- Thread.sleep(100);
- inBytes = rxIn.available();
- timeout--;
- }
-
- if (timeout == 0) {
- SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_COMM_INVALID_LOGIN);
- msg.makeSubstitution(signonInfo.getHostname(), "");
- _errorMessage = msg;
- return port;
- }
-
- // get command output on socket, one byte at a time until
- // got the datastore port number or EOF is reached for this input
- String maybePort=null;
- while (true ){
- if (monitor.isCanceled())
- return "0";
- byte aByte = rxIn.readByte();
- if (isEBCDICTest)
- aByte = convertFromASCIIToEBCDIC(aByte); // for EBCDIC Test
- if (aByte == 0) // drop the null
- continue;
- originalHostResponse += (char)aByte;
- logMessage("Host response is " + originalHostResponse);
- if (!isModeChecked)
- {
- convertedHostResponse += convertFromEBCDICToASCII(aByte);
- logMessage("Host response is converted to " + convertedHostResponse);
- if (originalHostResponse.indexOf(ASCII_TEST_STRING) > -1)
- { // It's ASCII mode
- isModeChecked = true;
- logMessage("This is the ASCII mode. ");
- }
- else if (convertedHostResponse.indexOf(ASCII_TEST_STRING) > -1)
- { // It's EBCDIC mode
- logMessage("This is the EBCDIC mode. ");
- isModeChecked = true;
- isEBCDIC = true;
- }
- }
- else
- {
- if (isEBCDIC)
- {
- convertedHostResponse += convertFromEBCDICToASCII(aByte);
- logMessage("Host response is converted to " + convertedHostResponse);
- if(checkPort)
- { // It's EBCDIC mode
- maybePort = extractPortNumber (convertedHostResponse);
- }
- }
- else if (checkPort)
- { // it's ASCII
- maybePort = extractPortNumber (originalHostResponse);
- }
- if (maybePort == null)
- continue ;
- port = maybePort;
- break;
- }
- }
- // -----------------------------------------------------------------
- // Close input/output streams and socket
- // -----------------------------------------------------------------
- rxIn.close();
- rxOut.close();
- rexecCall.close();
- logMessage("Going to return port " + port);
- return port;
- }
- catch (EOFException e)
- {
- // do nothing
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- // if no port is found, create error message
- String hostMessage = originalHostResponse;
- if (isEBCDIC) // pick up the right messages
- hostMessage = convertedHostResponse;
- int index = hostMessage.indexOf(ASCII_TEST_STRING);
- if (index > -1) // remove the embedded ASCII_TEST_STRING
- hostMessage = hostMessage.substring(0,index) + hostMessage.substring(index+1+ASCII_TEST_STRING.length());
- if (hostMessage.indexOf(EZYRD11E) >0 ){
- SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_COMM_INVALID_LOGIN);
- msg.makeSubstitution(signonInfo.getHostname(), hostMessage);
- _errorMessage = msg;
- } else {
- SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_COMM_REXEC_NOTSTARTED);
- msg.makeSubstitution(""+rexecPort, signonInfo.getHostname(), hostMessage);
- _errorMessage = msg;
-
- }
-
- return port;
- }
- /**
- * @param newLine
- * @return
- */
- /*
- private String checkCodePage(String newLine) {
- // check in which mode the host is sending the message back
- if (isModeChecked)
- return newLine;
- if (newLine.indexOf(ASCII_TEST_STRING) > -1){ // It's ASCII mode
- isASCIIMode = true;
- isModeChecked = true;
- } else { // Check whether it's EBCDIC mode
- String convertedNewLine = convertFromEBCDICToASCII(newLine.toCharArray());
- if (convertedNewLine.indexOf(ASCII_TEST_STRING) > -1){
- isASCIIMode = false;
- isModeChecked = true;
- }
- }
- return newLine;
- }
- */
- /* wait until host responds with some data - at least should send null byte */
-/* char cChar;
- int inBytes = rxIn.available(); // any data available?
- StringBuffer buf = new StringBuffer();
- String chunk = null;
-
- while (inBytes == 0)
- {
- if (monitor.isCanceled())
- return "0";
-
- // try for more input
- Thread.sleep(100);
-
- inBytes = rxIn.available();
- }
-
- // get command output on socket, one byte at a time until
- // got the datastore port number or EOF is reached for this input
- byte[] bDSPort = new byte[4];
- byte[] byteBuf = new byte[8];
- int index;
- if (inBytes > 0)
- {
- byte aByte = rxIn.readByte();
- cChar = (char)aByte; // discard first null byte
-
-// port = getPortASCII(rxIn);
- // should have at least 8 bytes plus newline from the "echo USSTEST" command. This is
- // used to test if the data being returned is ASCII or EBCDIC
- for (index = 0; index < ASCII_TEST_STRING.length(); index++)
- { // include newline too
- aByte = rxIn.readByte();
- cChar = (char)aByte;
- buf.append(cChar);
- byteBuf[index] = aByte;
- }
- chunk = new String(buf);
-
- if (chunk.indexOf(ASCII_TEST_STRING) >= 0)
- {
- // returned data is ASCII
- port = getPortASCII(rxIn);
- }
- else
- {
-
- chunk = convertFromEBCDICToASCII(byteBuf);
- if (chunk.indexOf(ASCII_TEST_STRING) >= 0)
- {
-
- // returned data is EBCDIC
- port = getPortEBCDIC(rxIn);
- }
- else
- {
- // rexec error!
- // there's an error
- while (cChar != '\n')
- {
- cChar = (char) rxIn.readByte();
- buf.append(cChar);
- }
- SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_COMM_INVALID_LOGIN);
- msg.makeSubstitution(signonInfo.getHostname(), buf.toString());
- _errorMessage = msg;
- }
- }
- }
- rxIn.close();
- rxOut.close();
- rexecCall.close();
-
- }
- catch (Exception e)
- {
- System.out.println(e);
- SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_COMM_REXEC_NOTSTARTED);
- msg.makeSubstitution(""+rexecPort, signonInfo.getHostname(), e.getMessage());
- _errorMessage = msg;
- }
-
- return port;
- } // end of launch method
- */
- /* original method
- public Object launch(IProgressMonitor monitor) throws Exception
- {
- _errorMessage = null;
- String port = new String("0"); // default no port
- try
- {
-
- // establish socket for rexec connection
- Socket rexecCall = new Socket(signonInfo.getHostname(), rexecPort); // rexec listens here - 512
-
- // set up data streams on rexec socket
- DataOutputStream rxOut = new DataOutputStream(rexecCall.getOutputStream());
- DataInputStream rxIn = new DataInputStream(rexecCall.getInputStream());
-
- // we're not opening a socket for stderr to circumvent problems that
- // may arise if the client is behind a firewall with respect to the
- // host, in which case the rexec daemon may have trouble connecting
- // to the client error port.
- // Not sending a port number at this point indicates to the daemon
- // that there is no error socket to establish.
- rxOut.writeByte((int) 0); // send null terminator
- rxOut.flush();
-
- // send userid and password on rexec socket
- rxOut.writeBytes(signonInfo.getUserid());
- rxOut.writeByte((int) 0); // send null terminator
- rxOut.writeBytes(signonInfo.getPassword());
- rxOut.writeByte((int) 0); // send null terminator
- rxOut.flush();
-
- // send the command on rexec socket to start datastore daemon listening
- // on any port
- // TODO - assumes a particular script and location to start the server,
- // this should be stored in some resource bundle later
- //cmd = new String ("echo USSTEST;cd ~/dstore;start_anyport");
- //cmd = new String("echo " + ASCII_TEST_STRING + ";cd ~/rseserver;start_anyport");
- cmd = new String("echo " + ASCII_TEST_STRING + ";cd " + this.cwd + ";" + this.invocation);
-
- rxOut.writeBytes(cmd);
- rxOut.writeByte((int) 0); // send null terminator
- rxOut.flush();
-
- // wait until host responds with some data - at least should send null byte
-
- char cChar;
- int inBytes = rxIn.available(); // any data available?
- StringBuffer buf = new StringBuffer();
- String chunk = null;
-
- while (inBytes == 0)
- {
- if (monitor.isCanceled())
- return "0";
-
- // try for more input
- Thread.sleep(100);
-
- inBytes = rxIn.available();
- }
-
- // get command output on socket, one byte at a time until
- // got the datastore port number or EOF is reached for this input
- byte[] bDSPort = new byte[4];
- byte[] byteBuf = new byte[8];
- int index;
- if (inBytes > 0)
- {
- byte aByte = rxIn.readByte();
- cChar = (char)aByte; // discard first null byte
-
- // should have at least 8 bytes plus newline from the "echo USSTEST" command. This is
- // used to test if the data being returned is ASCII or EBCDIC
- for (index = 0; index < ASCII_TEST_STRING.length(); index++)
- { // include newline too
- aByte = rxIn.readByte();
- cChar = (char)aByte;
- buf.append(cChar);
- byteBuf[index] = aByte;
- }
- chunk = new String(buf);
-
- if (chunk.indexOf(ASCII_TEST_STRING) >= 0)
- {
- // returned data is ASCII
- port = getPortASCII(rxIn);
- }
- else
- {
-
- chunk = convertFromEBCDICToASCII(byteBuf);
- if (chunk.indexOf(ASCII_TEST_STRING) >= 0)
- {
-
- // returned data is EBCDIC
- port = getPortEBCDIC(rxIn);
- }
- else
- {
- // rexec error!
- // there's an error
- while (cChar != '\n')
- {
- cChar = (char) rxIn.readByte();
- buf.append(cChar);
- }
- SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_COMM_INVALID_LOGIN);
- msg.makeSubstitution(signonInfo.getHostname(), buf.toString());
- _errorMessage = msg;
- }
- }
-
- }
- rxIn.close();
- rxOut.close();
- rexecCall.close();
-
- }
- catch (Exception e)
- {
- System.out.println(e);
- SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_COMM_REXEC_NOTSTARTED);
- msg.makeSubstitution(""+rexecPort, signonInfo.getHostname(), e.getMessage());
- _errorMessage = msg;
- }
-
- return port;
- } // end of launch method
-*/
- /**
- * Determine if we are connected to the remote server or not.
- * @return true if we are connected, false otherwise.
- */
- public boolean isConnected()
- {
- if (clientConnection != null)
- {
- return clientConnection.isConnected();
- }
- return false;
- }
-
- /**
- * Connect to the remote server.
- * @see #getErrorMessage()
- * @param monitor a monitor for showing progress
- * @param connectPort the port to use for launching the server
- * @return Anything you want.
- */
- public Object connect(IProgressMonitor monitor, int connectPort) throws Exception
- {
- clientConnection.setPort(Integer.toString(connectPort));
-
- if (monitor != null)
- {
- SystemMessage cmsg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_CONNECTING_TO_SERVER);
- cmsg.makeSubstitution(clientConnection.getPort());
- monitor.subTask(cmsg.getLevelOneText());
- }
-
- // connect to launched server
- ConnectionStatus connectStatus = clientConnection.connect(null);
-
- return connectStatus;
- }
-
- /**
- * Disconnect from the remote server
- * @see #getErrorMessage()
- */
- public void disconnect() throws Exception
- {
- if (clientConnection != null)
- {
- /* TODO!
- // Is disconnect being called because the network (connection) went down?
- if (_connectionStatusListener != null && _connectionStatusListener.isConnectionDown())
- {
- fireCommunicationsEvent(CommunicationsEvent.CONNECTION_ERROR);
- }
- else
- {
- // Fire comm event to signal state about to change
- fireCommunicationsEvent(CommunicationsEvent.BEFORE_DISCONNECT);
- }
-
- DataStore dataStore = getDataStore();
- if (dataStore != null && _connectionStatusListener != null)
- {
- dataStore.getDomainNotifier().removeDomainListener(_connectionStatusListener);
- }
-
- clientConnection.disconnect();
- clientConnection = null;
- getUserId(); // Clear any cached local user IDs
- sysInfo = null;
-
- // Fire comm event to signal state changed
- fireCommunicationsEvent(CommunicationsEvent.AFTER_DISCONNECT);
- */
- clientConnection.disconnect();
- clientConnection = null;
- }
- }
-
- /**
- * Return the last error message issued
- */
- public SystemMessage getErrorMessage()
- {
- return _errorMessage;
- }
-
- // ------------------
- // PRIVATE METHODS...
- // ------------------
-/*
- // sam private String convertFromEBCDICToASCII(byte[] eBytes)
- private String convertFromEBCDICToASCII(char[] eBytes)
- {
-
- StringBuffer buf = new StringBuffer();
- for (int i = 0; i < eBytes.length; i++)
- {
- byte bByte = (byte)eBytes[i];
- int index = bByte;
- if (index < 0)
- {
- index = 256 + index;
- }
- char cChar = ebcdictounicode[index];
- buf.append(cChar);
- }
- return buf.toString();
- }
-*/
- /**
- * Read the data returned on the rexec port as ASCII characters and
- * detect the port number in the datastore server messages
- * @param rxIn
- * @return String port number
- */
- /*
- private String getPortASCII(DataInputStream rxIn)
- {
- String port = new String("0"); // default to no port
- char cChar;
- byte bByte;
- int numPortChars = 5;
- byte[] bDSPort = new byte[numPortChars];
- StringBuffer buf = new StringBuffer();
- StringBuffer diagnosticString = new StringBuffer();
- String chunk = null;
- boolean serverStartedMsg = false;
- while (true)
- {
- try
- {
- cChar = (char) rxIn.readByte();
- if (cChar == '\n')
- { // hit a newline
- chunk = new String(buf);
-
- // DKM: need to handle mixed order cases
-
- if (chunk.indexOf("Server Started Successfully") >= 0)
- {
- serverStartedMsg = true;
- // this server output precedes the datastore server port number
- buf.delete(0, buf.length()); // clear buffer
-
- // might have already got port
- // check first
- if (port.equals("0"))
- {
- rxIn.read(bDSPort, 0, numPortChars); // get next 4 bytes - datastore port #
- for (int i = 0; i < numPortChars; i++)
- {
- char c = (char) bDSPort[i];
- if (Character.isDigit(c))
- buf.append(c);
- }
- port = new String(buf); // got port where datastore server is listening
-
- // check for valid port
- try
- {
- int possiblePort = Integer.parseInt(port);
- break;
-
- }
- catch (Exception e)
- {
- // not valid
- }
- }
-
- }
- else
- {
- // might be the port
- try
- {
- int possiblePort = Integer.parseInt(chunk);
- port = chunk;
- if (serverStartedMsg)
- break;
- }
- catch (Exception e)
- {
- }
- }
-
- buf.delete(0, buf.length()); // clear buffer
- }
- else
- {
- diagnosticString.append(cChar);
- buf.append(cChar);
- }
- }
- // EOF indicates no more lines to come through on error socket
- catch (EOFException e)
- {
- break;
- }
- catch (IOException e)
- {
- break;
- }
- } // end of while true
-
- // if port is somethign wierd...log this
- if (port.equals("0"))
- {
- // port is weird!
-
- try
- {
-
- int available = rxIn.available();
- while (available > 0)
- {
- rxIn.read(bDSPort, 0, numPortChars);
- for (int i = 0; i < numPortChars; i++)
- {
- char c = (char) bDSPort[i];
- diagnosticString.append(c);
- }
- available = rxIn.available();
- }
-
- }
- catch (Exception ex)
- {
- }
-
- SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_COMM_SERVER_NOTSTARTED);
- diagnosticString.insert(0, "\n\n");
- msg.makeSubstitution(signonInfo.getHostname(), diagnosticString.toString());
-
- _errorMessage = msg;
- }
-
- return port;
- }
-*/
- /**
- * Read the data returned on the rexec port as EBCDIC characters and
- * convert to unicode. Detect the port number in the datastore server messages
- * @param rxIn
- * @return String port number
- */
- /*
- private String getPortEBCDIC(DataInputStream rxIn)
- {
- String port = new String("0"); // default to no port
- int index;
- char cChar;
- byte bByte;
- byte[] bDSPort = new byte[4];
- StringBuffer buf = new StringBuffer();
- String chunk = null;
- while (true)
- {
- try
- {
- bByte = rxIn.readByte();
- index = bByte;
- if (index < 0)
- {
- index = 256 + index;
- }
- cChar = ebcdictounicode[index];
- if (cChar == '\n')
- { // hit a newline
- chunk = new String(buf);
-
- if (chunk.indexOf("Server Started Successfully") >= 0)
- {
- // this server output precedes the datastore server port number
- buf.delete(0, buf.length()); // clear buffer
- rxIn.read(bDSPort, 0, 4); // get next 4 bytes - datastore port #
- for (int i = 0; i < 4; i++)
- {
- index = bDSPort[i];
- if (index < 0)
- {
- index = 256 + index;
- }
- buf.append(ebcdictounicode[index]);
- }
- port = new String(buf); // got port where datastore server is listening
- break;
- }
- buf.delete(0, buf.length()); // clear buffer
- }
- else
- {
- buf.append(cChar);
- }
- }
- // EOF indicates no more lines to come through on error socket
- catch (EOFException e)
- {
- break;
- }
- catch (IOException e)
- {
- break;
- }
- } // end of while true
- return port;
- }
- */
- private String extractPortNumber (String hostResponse) {
- String port ="0";
- logMessage("Going to find port number. ");
- int index = hostResponse.indexOf(PORT_LEADING_STRING);
- if ( index < 0 )
- return null;
- logMessage("Found the leading string. ");
- String portString = hostResponse.substring(index + PORT_LEADING_STRING.length());
- logMessage("Removed the leading string as " + portString);
- if (portString != null && portString.startsWith("\n"))
- portString = portString.substring(1);
- //if (portString.length() < 4)
- // return null;
-
- // change to support 5 digit ports
- StringBuffer portBuffer = new StringBuffer();
- for (int i = 0; i < portString.length(); i++)
- {
- char c = portString.charAt(i);
- if (Character.isDigit(c))
- {
- portBuffer.append(c);
- }
- }
-
- if (portString.length() != portBuffer.length())
- {
- port = portBuffer.toString();
- // old code - didn't support 5 digits
- //port = portString.substring(0,4);
-
- logMessage("Got the port " + port);
- try
- {
- Integer.parseInt(port);
- logMessage("Going to return port " + port);
- return port;
- }
- catch (RuntimeException e)
- {
- e.printStackTrace();
- logMessage("Got the wrong port " + port);
- checkPort=false;
- return null;
- }
- }
- else
- {
- return null;
- }
- }
- private char convertFromEBCDICToASCII(byte eByte)
- {
- int index = eByte;
- if (index < 0)
- {
- index = 256 + index;
- }
- return ebcdictounicode[index];
- }
- private byte convertFromASCIIToEBCDIC(byte eByte)
- {
- int index = eByte;
- for (int i = 0; i <ebcdictounicode.length; i++) {
- if (index == ebcdictounicode[i]){
- if (i > 128)
- return (byte )(i - 256);
- return (byte)i;
- }
-
- }
- return (byte)0;
- }
- private void logMessage (String message) {
- if (logInfo)
- SystemBasePlugin.logError("RexecDstoreServer :" + message);
- }
-
- public void setSocketTimeoutValue(int value)
- {
- _socketTimeoutValue = value;
- }
-} \ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/util/ConnectionStatusListener.java b/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/util/ConnectionStatusListener.java
deleted file mode 100644
index 3f2baee2e..000000000
--- a/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/util/ConnectionStatusListener.java
+++ /dev/null
@@ -1,272 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2002, 2006 IBM Corporation. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * {Name} (company) - description of contribution.
- ********************************************************************************/
-
-package org.eclipse.rse.connectorservice.dstore.util;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.dstore.core.model.DataElement;
-import org.eclipse.dstore.extra.internal.extra.DomainEvent;
-import org.eclipse.dstore.extra.internal.extra.IDomainListener;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.rse.core.SystemBasePlugin;
-import org.eclipse.rse.core.model.ISystemRegistry;
-import org.eclipse.rse.core.subsystems.IConnectorService;
-import org.eclipse.rse.core.subsystems.SubSystemConfiguration;
-import org.eclipse.rse.services.clientserver.messages.SystemMessage;
-import org.eclipse.rse.ui.ISystemMessages;
-import org.eclipse.rse.ui.RSEUIPlugin;
-import org.eclipse.rse.ui.messages.SystemMessageDialog;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-
-public class ConnectionStatusListener implements IDomainListener, IRunnableWithProgress
-{
-
-
- protected DataElement _dataStoreStatus;
- protected IConnectorService _connection;
- protected boolean _connectionDown = false;
-
- /**
- * @param status The status element for the DataStore handling this connection.
- */
- public ConnectionStatusListener(DataElement status, IConnectorService connection)
- {
- _dataStoreStatus = status;
- _connection = connection;
- }
-
- protected Shell internalGetShell()
- {
- Shell activeShell = SystemBasePlugin.getActiveWorkbenchShell();
- if (activeShell != null)
- {
- return activeShell;
- }
-
- IWorkbenchWindow window = null;
- try
- {
- window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- }
- catch (Exception e)
- {
- return null;
- }
- if (window == null)
- {
-
- IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
- if (windows != null && windows.length > 0)
- {
- return windows[0].getShell();
- }
-
- }
- else
- {
- return window.getShell();
- }
-
- return null;
- }
-
- /**
- * The handleConnectionDown method is invoked if the network connection between the
- * client and server goes down while connected. Currently this method displays
- * an error to the user and the subsytem is disconnected.
- */
- protected void handleConnectionDown()
- {
- Display.getDefault().asyncExec(new ConnectionDown(this));
- }
-
- class ConnectionDown implements Runnable
- {
- private ConnectionStatusListener _listener;
- public ConnectionDown(ConnectionStatusListener listener)
- {
- _listener = listener;
- }
-
- public void run()
- {
- Shell shell = getShell();
- _connectionDown = true;
- SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_CONNECT_UNKNOWNHOST);
- msg.makeSubstitution(_connection.getPrimarySubSystem().getHost().getAliasName());
- SystemMessageDialog dialog = new SystemMessageDialog(internalGetShell(), msg);
- dialog.open();
- try
- {
- IRunnableContext runnableContext = getRunnableContext(getShell());
- runnableContext.run(false,true,_listener); // inthread, cancellable, IRunnableWithProgress
- _connection.reset();
- ISystemRegistry sr = RSEUIPlugin.getDefault().getSystemRegistry();
- sr.connectedStatusChange(_connection.getPrimarySubSystem(), false, true, true);
- }
- catch (InterruptedException exc) // user cancelled
- {
- if (shell != null)
- showDisconnectCancelledMessage(shell, _connection.getHostName(), _connection.getPort());
- }
- catch (java.lang.reflect.InvocationTargetException invokeExc) // unexpected error
- {
- Exception exc = (Exception)invokeExc.getTargetException();
- if (shell != null)
- showDisconnectErrorMessage(shell, _connection.getHostName(), _connection.getPort(), exc);
- }
- catch (Exception e)
- {
- SystemBasePlugin.logError("ConnectionStatusListener: Error disconnecting", e);
- }
- }
- }
-
- /**
- * @see IDomainListener#listeningTo(DomainEvent)
- */
- public boolean listeningTo(DomainEvent event)
- {
- if (_dataStoreStatus == event.getParent())
- {
- return true;
- }
- return false;
- }
-
- /**
- * @see IDomainListener#domainChanged(DomainEvent)
- */
- public void domainChanged(DomainEvent event)
- {
- if (!_dataStoreStatus.getName().equals("okay"))
- {
- handleConnectionDown();
- }
- }
-
- /**
- * @see IDomainListener#getShell()
- */
- public Shell getShell()
- {
- return internalGetShell();
- }
-
- /**
- * Callback method for the ISystem to determine if the connection is down. This is
- * called by the disconnect method to determine if we can do saves or not.
- */
- public boolean isConnectionDown()
- {
- return _connectionDown;
- }
-
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException
- {
- String message = null;
- message = SubSystemConfiguration.getDisconnectingMessage(_connection.getHostName(), _connection.getPort());
- monitor.beginTask(message, IProgressMonitor.UNKNOWN);
- try
- {
- _connection.disconnect(monitor);
- }
- catch(Exception exc)
- {
- if (exc instanceof java.lang.reflect.InvocationTargetException)
- throw (java.lang.reflect.InvocationTargetException)exc;
- if (exc instanceof java.lang.InterruptedException)
- throw (java.lang.InterruptedException)exc;
- throw new java.lang.reflect.InvocationTargetException(exc);
- }
- finally
- {
- monitor.done();
- }
- }
- /**
- * Get the progress monitor dialog for this operation. We try to
- * use one for all phases of a single operation, such as connecting
- * and resolving.
- */
- protected IRunnableContext getRunnableContext(Shell rshell)
- {
- Shell shell = getShell();
- // for other cases, use statusbar
- IWorkbenchWindow win = SystemBasePlugin.getActiveWorkbenchWindow();
- if (win != null)
- {
- Shell winShell = RSEUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell();
- if (winShell != null && !winShell.isDisposed() && winShell.isVisible())
- {
- SystemBasePlugin.logInfo("Using active workbench window as runnable context");
- shell = winShell;
- return win;
- }
- else
- {
- win = null;
- }
- }
-
- if (shell == null || shell.isDisposed() || !shell.isVisible())
- {
- SystemBasePlugin.logInfo("Using progress monitor dialog with given shell as parent");
- shell = rshell;
- }
-
-
- IRunnableContext dlg = new ProgressMonitorDialog(rshell);
- return dlg;
- }
-
- /**
- * Show an error message when the disconnection fails.
- * Shows a common message by default.
- * Overridable.
- */
- protected void showDisconnectErrorMessage(Shell shell, String hostName, int port, Exception exc)
- {
- //SystemMessage.displayMessage(SystemMessage.MSGTYPE_ERROR,shell,RSEUIPlugin.getResourceBundle(),
- // ISystemMessages.MSG_DISCONNECT_FAILED,
- // hostName, exc.getMessage());
- //RSEUIPlugin.logError("Disconnect failed",exc); // temporary
- SystemMessageDialog msgDlg = new SystemMessageDialog(shell,
- RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_DISCONNECT_FAILED).makeSubstitution(hostName,exc));
- msgDlg.setException(exc);
- msgDlg.open();
- }
- /**
- * Show an error message when the user cancels the disconnection.
- * Shows a common message by default.
- * Overridable.
- */
- protected void showDisconnectCancelledMessage(Shell shell, String hostName, int port)
- {
- //SystemMessage.displayMessage(SystemMessage.MSGTYPE_ERROR, shell, RSEUIPlugin.getResourceBundle(),
- // ISystemMessages.MSG_DISCONNECT_CANCELLED, hostName);
- SystemMessageDialog msgDlg = new SystemMessageDialog(shell,
- RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_DISCONNECT_CANCELLED).makeSubstitution(hostName));
- msgDlg.open();
- }
-} \ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/util/ICommunicationsDiagnostic.java b/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/util/ICommunicationsDiagnostic.java
deleted file mode 100644
index 7738e6d64..000000000
--- a/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/util/ICommunicationsDiagnostic.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2002, 2006 IBM Corporation. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * {Name} (company) - description of contribution.
- ********************************************************************************/
-
-package org.eclipse.rse.connectorservice.dstore.util;
-
-import org.eclipse.rse.core.subsystems.IConnectorService;
-
-/**
- * An interface for ICommunicationsDiagnostic class
- */
-public interface ICommunicationsDiagnostic extends Runnable {
-
-
-
- public static final int CANCEL_WAIT_REQUESTED = 1;
-
-
- /**
- * Setup for the diagnostic
- *
- * @param
- * String id: assign an ID for this diagnostic instance
- * boolean quiet: true if user to be prompted for a dialog
- * String server: the host network name
- * ISystem system: the connection to be investigated
- * String str1, str2, str3: optional strings
- */
- public void setUp(String id, boolean quiet, String server, IConnectorService system, String str1, String str2, String str3);
-
- /**
- * Log an error in the .log file
- *
- * @param
- * String text: message text to be logged
- */
- public void logError(String text);
-
- /**
- * Check if network is down
- * @param None
- * @return true or false
- *
- */
- public boolean isNetworkDown();
-
- /**
- * Check if host server is still active
- * @param None
- * @return true or false
- */
- public boolean isServerActive();
-
- /**
- * Dispaly a message dialog
- *
- * @param
- * int id: message to be displayed.
- */
- public void displayMessage(String id);
-
- /**
- * diagnosticStatus
- *
- * @return status
- */
- public int diagnosticStatus();
-
-
-} \ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/util/ICommunicationsDiagnosticFactory.java b/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/util/ICommunicationsDiagnosticFactory.java
deleted file mode 100644
index 3bc4c334c..000000000
--- a/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/util/ICommunicationsDiagnosticFactory.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2006 IBM Corporation. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * {Name} (company) - description of contribution.
- ********************************************************************************/
-
-package org.eclipse.rse.connectorservice.dstore.util;
-
-/**
- * Factory for creating ICommunicationsDiagnostic instances.
- */
-public interface ICommunicationsDiagnosticFactory
-{
-
- /**
- * Factory method for creating instances
- */
- public ICommunicationsDiagnostic createInstance();
-} \ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/util/StatusMonitor.java b/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/util/StatusMonitor.java
deleted file mode 100644
index 6727437cc..000000000
--- a/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/util/StatusMonitor.java
+++ /dev/null
@@ -1,456 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2002, 2006 IBM Corporation. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * {Name} (company) - description of contribution.
- ********************************************************************************/
-
-package org.eclipse.rse.connectorservice.dstore.util;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.dstore.core.model.DE;
-import org.eclipse.dstore.core.model.DataElement;
-import org.eclipse.dstore.core.model.DataStore;
-import org.eclipse.dstore.extra.internal.extra.DomainEvent;
-import org.eclipse.dstore.extra.internal.extra.IDomainListener;
-import org.eclipse.rse.core.SystemBasePlugin;
-import org.eclipse.rse.core.subsystems.CommunicationsEvent;
-import org.eclipse.rse.core.subsystems.ICommunicationsListener;
-import org.eclipse.rse.core.subsystems.IConnectorService;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-
-/*
- * This utility class can be used to monitor the status of one more more status DataElements.
- * Only one instanceof of this class is required per DataStore for use in monitoring statuses.
- * This is intended to be used in place of StatusChangeListeners
- *
- * * <p>
- * The following is one example of the use of the StatusMonitor. The code:
- * <blockquote><pre>
- * DataElement status = dataStore.command(dsCmd, args, deObj);
- *
- * StatusMonitor smon = StatusMonitorFactory.getInstance().getStatusMonitorFor(getSystem(), ds);
- * smon.waitForUpdate(status, monitor);
- * </pre></blockquote>
- */
-public class StatusMonitor implements IDomainListener, ICommunicationsListener
-{
-
- protected Shell _shell;
- protected IConnectorService _system;
-
-
- protected boolean _networkDown = false;
-
- protected List _workingStatuses;
- protected List _cancelledStatuses;
- protected List _doneStatuses;
-
- protected DataStore _dataStore;
-
- protected class FindShell implements Runnable
- {
- private Shell shell;
-
- /**
- * @see Runnable#run()
- */
- public void run()
- {
- try {
- Shell[] shells = Display.getCurrent().getShells();
- for (int loop = 0; loop < shells.length && shell == null; loop++) {
- if (shells[loop].isEnabled()) {
- shell = shells[loop];
- }
- }
- } catch (Exception e) {
- SystemBasePlugin.logError("StatusChangeListener.FindShell exception: ", e);
- }
- }
- }
-
- /**
- * Construct a StatusChangeListener
- *
- * @param system the system associated with this monitor
- * @param dataStore the dataStore associated with this monitor
- * @param factory the diagnostic factory for this monitor
- */
- public StatusMonitor(IConnectorService system, DataStore dataStore, ICommunicationsDiagnosticFactory factory)
- {
- _system = system;
- _dataStore = dataStore;
- reInit();
- }
-
- /**
- * Construct a StatusChangeListener
- *
- * @param system the system associated with this monitor
- * @param dataStore the dataStore associated with this monitor
- */
- public StatusMonitor(IConnectorService system, DataStore dataStore)
- {
- this(system, dataStore, null);
- }
-
- public void reInit()
- {
- _networkDown = false;
- _system.addCommunicationsListener(this);
- _workingStatuses = new ArrayList();
- _doneStatuses = new ArrayList();
- _cancelledStatuses = new ArrayList();
- _dataStore.getDomainNotifier().addDomainListener(this);
- }
-
- public DataStore getDataStore()
- {
- return _dataStore;
- }
-
- public void dispose()
- {
- _system.removeCommunicationsListener(this);
- _workingStatuses.clear();
- _doneStatuses.clear();
- _cancelledStatuses.clear();
- _dataStore.getDomainNotifier().removeDomainListener(this);
- }
-
- /**
- * @see IDomainListener#listeningTo(DomainEvent)
- */
- public boolean listeningTo(DomainEvent event)
- {
- if (_workingStatuses.size() == 0)
- {
- return true;
- }
-
- DataElement parent = (DataElement)event.getParent();
- if (_workingStatuses.contains(parent))
- {
- return determineStatusDone(parent);
- }
-
- return false;
- }
-
-
-
- /**
- * @see IDomainListener#domainChanged(DomainEvent)
- */
- public void domainChanged(DomainEvent event)
- {
- if (_workingStatuses.size() == 0)
- {
- return;
- }
-
- DataElement parent = (DataElement)event.getParent();
- if (_workingStatuses.contains(parent))
- {
- boolean isStatusDone = determineStatusDone(parent);
- if (isStatusDone)
- {
- setDone(parent);
- }
- }
- }
-
-
- /**
- * Determines whether the status is done.
- * @return <code>true</code> if status done, <code>false</code> otherwise.
- */
- protected boolean determineStatusDone(DataElement status)
- {
- return status.getAttribute(DE.A_VALUE).equals("done") || status.getAttribute(DE.A_NAME).equals("done");
- }
-
- /**
- * @see org.eclipse.rse.core.subsystems.ICommunicationsListener#isPassiveCommunicationsListener()
- */
- public boolean isPassiveCommunicationsListener()
- {
- return false;
- }
-
- /**
- * setDone(boolean)
- */
- public synchronized void setDone(DataElement status)
- {
- _workingStatuses.remove(status);
- _doneStatuses.add(status);
- }
-
-
- public synchronized void setCancelled(DataElement status)
- {
- _workingStatuses.remove(status);
- _cancelledStatuses.add(status);
- }
-
- public synchronized void setWorking(DataElement status)
- {
- _workingStatuses.add(status);
- }
-
-
- public boolean wasCancelled(DataElement status)
- {
- if (_cancelledStatuses.contains(status))
- {
- return true;
- }
- return false;
- }
-
- /**
- * @see IDomainListener#getShell()
- */
- public Shell getShell()
- {
- // dy: DomainNotifier (which calls this method) requires the shell not be disposed
- //if (shell == null) {
- if (_shell == null || _shell.isDisposed())
- {
- FindShell findShell = new FindShell();
- Display.getDefault().syncExec(findShell);
- _shell = findShell.shell;
- }
- return _shell;
- }
-
- /**
- * @see ICommunicationsListener#communicationsStateChange(CommunicationsEvent)
- */
- public void communicationsStateChange(CommunicationsEvent e)
- {
- if (e.getState() == CommunicationsEvent.CONNECTION_ERROR)
- {
- _networkDown = true;
- }
- else if (e.getState() == CommunicationsEvent.AFTER_DISCONNECT)
- {
- _networkDown = true;
- }
- }
-
- /**
- * Test if the StatusChangeListener returned because the network connection to the
- * remote system was broken.
- */
- public boolean isNetworkDown()
- {
- return _networkDown;
- }
-
- public DataElement waitForUpdate(DataElement status) throws InterruptedException
- {
- return waitForUpdate(status, null, 0);
- }
-
- public DataElement waitForUpdate(DataElement status, IProgressMonitor monitor) throws InterruptedException
- {
- return waitForUpdate(status, monitor, 0);
- }
-
- public DataElement waitForUpdate(DataElement status, int wait) throws InterruptedException
- {
- return waitForUpdate(status, null, wait);
- }
-
- public synchronized DataElement waitForUpdate(DataElement status, IProgressMonitor monitor, int wait) throws InterruptedException
- {
- if (_networkDown && status.getDataStore().isConnected())
- {
- reInit();
- }
- if (determineStatusDone(status))
- {
- setDone(status);
- return status;
- }
-
- setWorking(status);
-
- Display display = Display.getCurrent();
-
- // Prevent infinite looping by introducing a threshold for wait
- int WaitThreshold = 600; //default. sleep(100ms) for 600 times
- if ( wait > 0 )
- WaitThreshold = wait*10; // 1 second means 10 sleep(100ms)
- else if ( wait == -1 ) // force a diagnostic
- WaitThreshold = -1;
-
- if (display != null)
- {
- // Current thread is UI thread
- while (_workingStatuses.contains(status))
- {
- // while (display.readAndDispatch()) {
- //Process everything on event queue
- // }
-
- if ((monitor != null) && (monitor.isCanceled()))
- {
- setCancelled(status);
- throw new InterruptedException();
- }
-
- boolean statusDone = determineStatusDone(status);
-
- if (statusDone)
- {
- setDone(status);
- }
- else
- {
- Thread.sleep(100);
-
- if (WaitThreshold > 0) // update timer count if
- // threshold not reached
- --WaitThreshold; // decrement the timer count
-
- if (WaitThreshold == 0)
- {
- // no diagnostic factory but there is a timeout
- return status; // returning the undone status object
- }
- else if (_networkDown)
- {
- dispose();
- throw new InterruptedException();
- }
- }
- }
-
- }
- else
- {
- // Current thread is not UI thread
- while (_workingStatuses.contains(status))
- {
-
- if ((monitor != null) && (monitor.isCanceled()))
- {
- setCancelled(status);
- throw new InterruptedException();
- }
-
- boolean statusDone = determineStatusDone(status);
-
- if (statusDone)
- {
- setDone(status);
- }
- else
- {
- Thread.sleep(100);
-
- if (WaitThreshold > 0) // update timer count if
- // threshold not reached
- --WaitThreshold; // decrement the timer count
-
- if (WaitThreshold == 0)
- {
- // no diagnostic factory but there is a timeout
- return status; // returning the undone status object
- }
- else if (_networkDown)
- {
- dispose();
- throw new InterruptedException();
- }
- }
- }
- }
-
-
- return status;
- }
-
-
- /**
- * Start diagnostic
- *
- * @param Class diagnostic is the an implementation of ICommunicationsDiagnostic
- * @param boolean quiet is the flag to indicate if user should be prompted
- * - true for no prompt
- * @return ICommunciationsDiagnostic class instance
- */
- public ICommunicationsDiagnostic whatIsGoingOn(ICommunicationsDiagnosticFactory factory, boolean quiet, DataElement target) throws InterruptedException //@01
- {
- if (target == null)
- return null;
-
- ICommunicationsDiagnostic d = null;
- try {
- String name = target.getName(); /* Get the current element status name: started/working/done */
- /* Log the current status */
- SystemBasePlugin.logError("StatusChangeListener."+name+": " + "Communications Diagnostic started");
- SystemBasePlugin.logError("StatusChangeListener."+name +
- ": done = " + _doneStatuses.contains(target) +
- "; cancelled = " + _cancelledStatuses.contains(target)+
- "; _networkDown = " + _networkDown );
-
- DataStore ds = _dataStore;
- /* Log the status in DataStore */
- SystemBasePlugin.logError("StatusChangeListener."+name+"(DataStore): " + " isConnected = " + ds.isConnected() + "; isWaiting = " + ds.isWaiting(target));
-
- /*Log all nested DataElement's in target's parent*/
- List deList = target.getParent().getNestedData();
- if ( deList != null && !deList.isEmpty() ) {
- int num = deList.size();
- for ( int i = 0; i < num; i++)
- {
- DataElement child = (DataElement) deList.get(i);
- if (child != null) {
- SystemBasePlugin.logError("StatusChangeListener."+name+".child"+i+"(DataElement): " + child.toString());
- DataElement descriptor = child.getDescriptor();
- if (descriptor != null)
- SystemBasePlugin.logError("StatusChangeListener."+name+".child"+i+"(Descriptor): " + descriptor.toString());
- }
- }
- }
- //Spawn off a diagnostic to check more stuff
- if (factory != null) {
- d = factory.createInstance();
-
- //Initialize the diagnostic instance
- //Set diagnostic id(name), server name(ds.getName()), this connection(system)
- d.setUp(name, quiet, ds.getName(),_system, null ,null, null);
-
- new Thread(d).start();
- }
-
- }
- catch (Exception e)
- {
- SystemBasePlugin.logError("StatusChangeListener.ICommunicationsDiagnostic exception: ", e);
- }
-
- return d; // return the created diagnostic class instance
- }
-
-
-} \ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/util/StatusMonitorFactory.java b/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/util/StatusMonitorFactory.java
deleted file mode 100644
index a132b6e5d..000000000
--- a/rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/util/StatusMonitorFactory.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- * The following IBM employees contributed to the Remote System Explorer
- * component that contains this file: David McKnight, Kushal Munir,
- * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
- * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
- *
- * Contributors:
- * {Name} (company) - description of contribution.
- ********************************************************************************/
-
-package org.eclipse.rse.connectorservice.dstore.util;
-
-import java.util.HashMap;
-
-import org.eclipse.dstore.core.model.DataStore;
-import org.eclipse.rse.core.subsystems.IConnectorService;
-
-/**
- * Factory for finding and creating the StatusMonitor class for a given system
- */
-public class StatusMonitorFactory
-{
- protected HashMap _monitorMap;
- protected static StatusMonitorFactory _instance;
-
- public static StatusMonitorFactory getInstance()
- {
- if (_instance == null)
- {
- _instance = new StatusMonitorFactory();
- }
- return _instance;
- }
-
- public StatusMonitorFactory()
- {
- _monitorMap= new HashMap();
- }
-
- public void removeStatusMonitorFor(IConnectorService system)
- {
- StatusMonitor monitor = (StatusMonitor)_monitorMap.remove(system);
- if (monitor != null)
- {
- monitor.dispose();
- }
- }
-
- public StatusMonitor getStatusMonitorFor(IConnectorService system, DataStore dataStore)
- {
- return getStatusMonitorFor(system, dataStore, null);
- }
-
- public StatusMonitor getStatusMonitorFor(IConnectorService system, DataStore dataStore, ICommunicationsDiagnosticFactory diagnosticFactory)
- {
- StatusMonitor monitor = (StatusMonitor)_monitorMap.get(system);
- if (monitor == null)
- {
- monitor = new StatusMonitor(system, dataStore, diagnosticFactory);
- _monitorMap.put(system, monitor);
- }
- DataStore mDataStore = monitor.getDataStore();
- if (mDataStore != dataStore)
- {
- removeStatusMonitorFor(system);
- monitor = new StatusMonitor(system, dataStore, diagnosticFactory);
- _monitorMap.put(system, monitor);
- }
-
- return monitor;
- }
-} \ No newline at end of file

Back to the top