### Eclipse Workspace Patch 1.0 #P org.eclipse.rse.services Index: clientserver/org/eclipse/rse/services/clientserver/messages/SystemMessageException.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/messages/SystemMessageException.java,v retrieving revision 1.2 diff -u -r1.2 SystemMessageException.java --- clientserver/org/eclipse/rse/services/clientserver/messages/SystemMessageException.java 16 Aug 2006 16:31:36 -0000 1.2 +++ clientserver/org/eclipse/rse/services/clientserver/messages/SystemMessageException.java 11 Feb 2008 16:06:59 -0000 @@ -56,15 +56,6 @@ return msg; } - /** - * Tests if the SystemMessage encapsulated by this exception has a long id equal to the - * argument. - * @param longMessageID the String containing the message id to test. - * @return true if the long message id of the message is equal to the supplied message id. - */ - public boolean hasLongID(String longMessageID) { - return getSystemMessage().hasLongID(longMessageID); - } /** * Set the SystemMessage being wrapped Index: clientserver/org/eclipse/rse/services/clientserver/messages/SystemMessage.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/messages/SystemMessage.java,v retrieving revision 1.6 diff -u -r1.6 SystemMessage.java --- clientserver/org/eclipse/rse/services/clientserver/messages/SystemMessage.java 5 Jun 2007 10:37:08 -0000 1.6 +++ clientserver/org/eclipse/rse/services/clientserver/messages/SystemMessage.java 11 Feb 2008 16:06:59 -0000 @@ -12,7 +12,7 @@ * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. * * Contributors: - * {Name} (company) - description of contribution. + * David McKnight (IBM) - [216252] SystemMessages using RSEStatus *******************************************************************************/ package org.eclipse.rse.services.clientserver.messages; @@ -51,6 +51,9 @@ * Unexpected message indicator (same as warning but will log exception & stack in message log) */ public static final char UNEXPECTED = 'U'; + + + // Private variables private char subPrefix = '%'; @@ -58,7 +61,10 @@ private String level1NS, level2NS; // level 1 & 2 with NO substitution made private String level1WS, level2WS; // level 1 & 2 with substitutions made. private String component, subComponent; - private String messageNumber; + + + private String messageNumber; + private int numSubs = -1; private Object[] subs = null; @@ -80,13 +86,18 @@ subComponent = sub.toUpperCase(); messageNumber = number.toUpperCase(); setIndicator(ind); - level1NS = l1.trim(); - level2NS = l2.trim(); - level1WS = l1.trim(); - level2WS = l2.trim(); - + if (l1 != null){ + level1NS = l1.trim(); + level1WS = l1.trim(); + } + if (l2 != null){ + level2NS = l2.trim(); + level2WS = l2.trim(); + } } + + /** * Use this method to override the default indicator of the message * @param ind the new indicator. See constants for values. @@ -122,19 +133,6 @@ return messageNumber; } - /** - * @return the component of this message. - */ - public String getComponent() { - return component; - } - - /** - * @return the subcomponent of this message. - */ - public String getSubComponent() { - return subComponent; - } /** * Use this method to retrieve the unique number of substitution variables @@ -190,33 +188,6 @@ return component + subComponent + messageNumber + indicator; } - /** - * Use this method to retrieve 'long' message ID format: - * Component + SubComponent + Number. - * The long message ID is used for retrieving messages from a message file. - * @return String - the long message ID - **/ - public String getLongMessageID() { - return component + subComponent + messageNumber; - } - - /** - * Use this method to retrieve 'standard' message ID format: - * Component + Number - * @return String - the full message ID - **/ - public String getMessageID() { - return component + messageNumber; - } - - /** - * Tests if this message has a long id equal to the one supplied in the argument. - * @param messageId the long message id to compare against. - * @return a boolean indicating if the message ids are equal. - */ - public boolean hasLongID(String messageId) { - return getLongMessageID().equals(messageId); - } /** * Use this method to set substitution value %1. Index: clientserver/org/eclipse/rse/services/clientserver/messages/SimpleSystemMessage.java =================================================================== RCS file: clientserver/org/eclipse/rse/services/clientserver/messages/SimpleSystemMessage.java diff -N clientserver/org/eclipse/rse/services/clientserver/messages/SimpleSystemMessage.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ clientserver/org/eclipse/rse/services/clientserver/messages/SimpleSystemMessage.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,105 @@ +/******************************************************************************** + * Copyright (c) 2008 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. + * + * Contributors: + * {Name} (company) - description of contribution. + ********************************************************************************/ +package org.eclipse.rse.services.clientserver.messages; + +import java.io.PrintWriter; +import java.io.StringWriter; + +import org.eclipse.core.runtime.IStatus; + +public class SimpleSystemMessage extends SystemMessage { + + /** + * alternative to message number for ids? + */ + private String _pluginId; + + /** + * Constructor for messages that use explicit strings and severities rather than + * parsing a message file. This is part of the work to migrate away from the message + * file stuff. + * + * @param pluginId the id of the originating plugin + * @param severity using IStatus severities + * @param msg the message text + */ + public SimpleSystemMessage(String pluginId, int severity, String msg) throws IndicatorException { + this(pluginId, severity, msg, (String)null); + } + + /** + * Constructor for messages that use explicit strings and severities rather than + * parsing a message file. This is part of the work to migrate away from the message + * file stuff. + * + * @param pluginId the id of the originating plugin + * @param severity using IStatus severities + * @param msg the message text + * @param msgDetails the message details + */ + public SimpleSystemMessage(String pluginId, int severity, String msg, String msgDetails) throws IndicatorException { + super("RSE", "G", "-", severityToIndicator(severity), msg, msgDetails); //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$ + _pluginId = pluginId; + } + + /** + * Constructor for messages that use explicit strings and severities rather than + * parsing a message file. This is part of the work to migrate away from the message + * file stuff. + * + * @param pluginId the id of the originating plugin + * @param severity using IStatus severities + * @param msg the message text + * @param e an exception to convert into details + */ + public SimpleSystemMessage(String pluginId, int severity, String msg, Throwable e) throws IndicatorException { + super("RSE", "G", "-", severityToIndicator(severity), msg, throwableToDetails(e)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + _pluginId = pluginId; + + } + + private static String throwableToDetails(Throwable e){ + // transform exception stack into a string + StringWriter excWriter = new StringWriter(); + e.printStackTrace(new PrintWriter(excWriter)); + String dmsg = e.toString(); + if ((dmsg == null) || (e instanceof ClassCastException)) dmsg = e.getClass().getName(); + String msgDetails = dmsg + "\n" + excWriter.toString(); //$NON-NLS-1$ + return msgDetails; + } + + private static char severityToIndicator(int severity){ + char ind = COMPLETION; + if ((severity & IStatus.CANCEL) != 0){ + ind = UNEXPECTED; + } + else if ((severity & IStatus.ERROR) != 0){ + ind = ERROR; + } + else if ((severity & IStatus.INFO) != 0){ + ind = INFORMATION; + } + else if ((severity & IStatus.OK) != 0){ + ind = COMPLETION; + } + else if ((severity & IStatus.WARNING) != 0){ + ind = WARNING; + } + return ind; + } + + public String getFullMessageID() { + return _pluginId + ":" + getIndicator(); + } +} #P org.eclipse.rse.connectorservice.dstore Index: src/org/eclipse/rse/internal/connectorservice/dstore/ConnectorServiceResources.properties =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/internal/connectorservice/dstore/ConnectorServiceResources.properties,v retrieving revision 1.2 diff -u -r1.2 ConnectorServiceResources.properties --- src/org/eclipse/rse/internal/connectorservice/dstore/ConnectorServiceResources.properties 5 Jun 2007 10:42:59 -0000 1.2 +++ src/org/eclipse/rse/internal/connectorservice/dstore/ConnectorServiceResources.properties 11 Feb 2008 16:07:00 -0000 @@ -20,3 +20,68 @@ 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. + +MSG_CONNECT_UNKNOWNHOST=Connect failed. Host {0} not found or not responding + +MSG_DISCONNECT_FAILED=Disconnect from {0} failed with exception + +MSG_DISCONNECT_CANCELLED=Disconnect from {0} was canceled + +MSG_COMM_CONNECT_FAILED=Connection to {0} could not be established. +MSG_COMM_CONNECT_FAILED_DETAILS=A socket connection to {0} could not be established. If you are connecting via the communications daemon make sure the daemon is running on the remote system. If you are connecting directly to the communications server make sure the server is started on the remote system. If you are connecting using REXEC, make sure that the server is installed on the remote system and that the REXEC service is running on that system. + + +MSG_CONNECT_SSL_EXCEPTION = Unable to establish a secure connection with the Remote System Explorer host server. +MSG_CONNECT_SSL_EXCEPTION_DETAILS = Make sure both the client and server are configured to use SSL. The SSL handshake between client and server failed with the following exception: {0} + +MSG_STARTING_SERVER_VIA_REXEC = Remote System Explorer host server using REXEC + +MSG_STARTING_SERVER_VIA_DAEMON = Starting Remote System Explorer host server using daemon + +MSG_CONNECTING_TO_SERVER= Connecting to Remote System Explorer host server on port {0} +MSG_INITIALIZING_SERVER= Initializing Remote System Explorer host server +MSG_PORT_OUT_RANGE = The specified server port is out of the allowed range: {0} + +MSG_VALIDATE_PASSWORD_EMPTY=Enter password +MSG_VALIDATE_PASSWORD_EMPTY_DETAILS=You must specify your password. + +MSG_VALIDATE_PASSWORD_EXPIRED=Password has expired +MSG_VALIDATE_PASSWORD_EXPIRED_DETAILS=Your password has expired, and must be reset before continuing. + +MSG_VALIDATE_PASSWORD_INVALID=The new password is invalid. +MSG_VALIDATE_PASSWORD_INVALID_DETAILS=The remote system indicated that the new password is unacceptable. Please ensure the new password follows all password rules for the remote system. + +MSG_COMM_USING_SSL=Communication with the remote system {0} has been secured using SSL. Continue? +MSG_COMM_NOT_USING_SSL=Connection {0} has not been secured using SSL. Proceed anyway? + +MSG_COMM_SERVER_OLDER_WARNING=The host server running on remote system {0} is an older version than the RSE client. +MSG_COMM_SERVER_OLDER_WARNING_DETAILS=It is recommended that the client and server versions match. +MSG_COMM_CLIENT_OLDER_WARNING=The host server running on remote system {0} is a newer version than the RSE client. +MSG_COMM_CLIENT_OLDER_WARNING_DETAILS=It is recommended that the client and server versions match. + + +MSG_CONNECT_DAEMON_FAILED=Daemon failed to launch server on {0} using port {1} +MSG_CONNECT_DAEMON_FAILED_EXCEPTION=Failed to connect to the daemon on {0} using port %2 with an unexpected exception + +MSG_COMM_AUTH_FAILED=Invalid password or user ID +MSG_COMM_AUTH_FAILED_DETAILS=Authentication with {0} failed because the password or user ID is not correct. + +MSG_COMM_PWD_INVALID=The saved password is not correct. +MSG_COMM_PWD_INVALID_DETAILS=The saved password for user ID {0} on host {1} is not correct. Please enter the password and try again. + + +MSG_COMM_INCOMPATIBLE_PROTOCOL=Incompatible host server running on remote system {0}. +MSG_COMM_INCOMPATIBLE_PROTOCOL_DETAILS=The host server is not a Remote System Explorer server. + +MSG_COMM_INCOMPATIBLE_UPDATE=Incompatible Remote System Explorer host server running on remote system {0}. +MSG_COMM_INCOMPATIBLE_UPDATE_DETAILS=The host server needs to be updated to work with the current client. + +MSG_CONNECT_FAILED=Connect to %1 failed with an unexpected exception + +MSG_OPERATION_CANCELLED=Operation cancelled. + + + + + + Index: src/org/eclipse/rse/internal/connectorservice/dstore/ConnectorServiceResources.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/internal/connectorservice/dstore/ConnectorServiceResources.java,v retrieving revision 1.3 diff -u -r1.3 ConnectorServiceResources.java --- src/org/eclipse/rse/internal/connectorservice/dstore/ConnectorServiceResources.java 5 Jun 2007 10:42:58 -0000 1.3 +++ src/org/eclipse/rse/internal/connectorservice/dstore/ConnectorServiceResources.java 11 Feb 2008 16:07:00 -0000 @@ -26,6 +26,56 @@ public static String DStore_ConnectorService_Label; public static String DStore_ConnectorService_Description; + public static String MSG_CONNECT_UNKNOWNHOST; + + public static String MSG_DISCONNECT_FAILED; + public static String MSG_DISCONNECT_CANCELLED; + + public static String MSG_CONNECT_SSL_EXCEPTION; + public static String MSG_CONNECT_SSL_EXCEPTION_DETAILS; + public static String MSG_STARTING_SERVER_VIA_REXEC; + public static String MSG_STARTING_SERVER_VIA_DAEMON; + + public static String MSG_CONNECTING_TO_SERVER; + public static String MSG_INITIALIZING_SERVER; + public static String MSG_PORT_OUT_RANGE; + + public static String MSG_COMM_CONNECT_FAILED; + public static String MSG_COMM_CONNECT_FAILED_DETAILS; + + public static String MSG_VALIDATE_PASSWORD_EMPTY; + public static String MSG_VALIDATE_PASSWORD_EXPIRED; + public static String MSG_VALIDATE_PASSWORD_INVALID; + + public static String MSG_VALIDATE_PASSWORD_EMPTY_DETAILS; + public static String MSG_VALIDATE_PASSWORD_EXPIRED_DETAILS; + public static String MSG_VALIDATE_PASSWORD_INVALID_DETAILS; + + public static String MSG_COMM_USING_SSL; + public static String MSG_COMM_NOT_USING_SSL; + + public static String MSG_COMM_SERVER_OLDER_WARNING; + public static String MSG_COMM_CLIENT_OLDER_WARNING; + public static String MSG_COMM_SERVER_OLDER_WARNING_DETAILS; + public static String MSG_COMM_CLIENT_OLDER_WARNING_DETAILS; + + public static String MSG_CONNECT_DAEMON_FAILED; + public static String MSG_CONNECT_DAEMON_FAILED_EXCEPTION; + + public static String MSG_COMM_AUTH_FAILED; + public static String MSG_COMM_PWD_INVALID; + public static String MSG_COMM_AUTH_FAILED_DETAILS; + public static String MSG_COMM_PWD_INVALID_DETAILS; + + public static String MSG_COMM_INCOMPATIBLE_PROTOCOL; + public static String MSG_COMM_INCOMPATIBLE_UPDATE; + public static String MSG_COMM_INCOMPATIBLE_PROTOCOL_DETAILS; + public static String MSG_COMM_INCOMPATIBLE_UPDATE_DETAILS; + + public static String MSG_CONNECT_FAILED; + + public static String MSG_OPERATION_CANCELLED; + static { // load message values from bundle file NLS.initializeMessages(BUNDLE_NAME, ConnectorServiceResources.class); Index: src/org/eclipse/rse/internal/connectorservice/dstore/Activator.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/internal/connectorservice/dstore/Activator.java,v retrieving revision 1.2 diff -u -r1.2 Activator.java --- src/org/eclipse/rse/internal/connectorservice/dstore/Activator.java 15 May 2007 23:53:27 -0000 1.2 +++ src/org/eclipse/rse/internal/connectorservice/dstore/Activator.java 11 Feb 2008 16:07:00 -0000 @@ -32,6 +32,8 @@ //The shared instance. private static Activator plugin; + public final static String PLUGIN_ID = "org.eclipse.rse.connectorservice.dstore"; //$NON-NLS-1$ + /** * The constructor. */ Index: src/org/eclipse/rse/connectorservice/dstore/DStoreConnectorService.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/DStoreConnectorService.java,v retrieving revision 1.55 diff -u -r1.55 DStoreConnectorService.java --- src/org/eclipse/rse/connectorservice/dstore/DStoreConnectorService.java 29 Jan 2008 15:25:20 -0000 1.55 +++ src/org/eclipse/rse/connectorservice/dstore/DStoreConnectorService.java 11 Feb 2008 16:07:00 -0000 @@ -28,6 +28,7 @@ import java.io.IOException; import java.net.URL; import java.security.cert.X509Certificate; +import java.text.MessageFormat; import java.util.List; import java.util.Vector; @@ -36,6 +37,7 @@ import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.dstore.core.client.ClientConnection; import org.eclipse.dstore.core.client.ConnectionStatus; @@ -66,11 +68,14 @@ import org.eclipse.rse.core.subsystems.ServerLaunchType; import org.eclipse.rse.core.subsystems.SubSystem; import org.eclipse.rse.dstore.universal.miners.IUniversalDataStoreConstants; +import org.eclipse.rse.internal.connectorservice.dstore.Activator; +import org.eclipse.rse.internal.connectorservice.dstore.ConnectorServiceResources; import org.eclipse.rse.internal.connectorservice.dstore.RexecDstoreServer; import org.eclipse.rse.internal.ui.SystemPropertyResources; +import org.eclipse.rse.services.clientserver.messages.IndicatorException; +import org.eclipse.rse.services.clientserver.messages.SimpleSystemMessage; 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.SystemBasePlugin; @@ -549,8 +554,8 @@ { if (monitor != null) { - SystemMessage cmsg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_STARTING_SERVER_VIA_REXEC); - monitor.subTask(cmsg.getLevelOneText()); + String cmsg = ConnectorServiceResources.MSG_STARTING_SERVER_VIA_REXEC; + monitor.subTask(cmsg); } SystemSignonInformation info = getSignonInformation(); @@ -571,9 +576,8 @@ if (monitor != null) { - SystemMessage cmsg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_CONNECTING_TO_SERVER); - cmsg.makeSubstitution(clientConnection.getPort()); - monitor.subTask(cmsg.getLevelOneText()); + String cmsg = MessageFormat.format(ConnectorServiceResources.MSG_CONNECTING_TO_SERVER, new Object[] {clientConnection.getPort()}); + monitor.subTask(cmsg); } // connect to launched server @@ -599,7 +603,7 @@ String errorMsg = null; if (msg == null) { - errorMsg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_COMM_CONNECT_FAILED).getLevelOneText(); + errorMsg = ConnectorServiceResources.MSG_COMM_CONNECT_FAILED; } else { @@ -613,8 +617,8 @@ { if (monitor != null) { - SystemMessage cmsg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_STARTING_SERVER_VIA_DAEMON); - monitor.subTask(cmsg.getLevelOneText()); + String cmsg = ConnectorServiceResources.MSG_STARTING_SERVER_VIA_DAEMON; + monitor.subTask(cmsg); } // DY: getLocalUserId() may return null for Windows connections because @@ -685,8 +689,19 @@ SystemSignonInformation newCredentials = null; while (launchMsg != null && (isPasswordExpired(launchMsg) || isNewPasswordInvalid(launchMsg))) { - String messageId = isPasswordExpired(launchMsg) ? ISystemMessages.MSG_VALIDATE_PASSWORD_EXPIRED : ISystemMessages.MSG_VALIDATE_PASSWORD_INVALID; - SystemMessage message = RSEUIPlugin.getPluginMessage(messageId); + String pmsg = null; + String pmsgDetails = null; + boolean expired = isPasswordExpired(launchMsg); + if (expired){ + pmsg = ConnectorServiceResources.MSG_VALIDATE_PASSWORD_EXPIRED; + pmsgDetails = ConnectorServiceResources.MSG_VALIDATE_PASSWORD_EXPIRED_DETAILS; + } + else { + pmsg = ConnectorServiceResources.MSG_VALIDATE_PASSWORD_INVALID; + pmsgDetails = ConnectorServiceResources.MSG_VALIDATE_PASSWORD_INVALID_DETAILS; + } + + SystemMessage message = createSystemMessage(IStatus.ERROR, pmsg, pmsgDetails); getCredentialsProvider().repairCredentials(message); newCredentials = (SystemSignonInformation) getCredentialsProvider().getCredentials(); launchStatus = changePassword(clientConnection, oldCredentials, serverLauncher, monitor, newCredentials.getPassword()); @@ -706,12 +721,14 @@ { 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); + String pmsg = MessageFormat.format(ConnectorServiceResources.MSG_PORT_OUT_RANGE, new Object[]{portRange}); + SystemMessage message = createSystemMessage(IStatus.ERROR, pmsg); + + ShowConnectMessage msgAction = new ShowConnectMessage(message); Display.getDefault().asyncExec(msgAction); return; } @@ -725,9 +742,8 @@ { if (monitor != null) { - SystemMessage cmsg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_CONNECTING_TO_SERVER); - cmsg.makeSubstitution(clientConnection.getPort()); - monitor.subTask(cmsg.getLevelOneText()); + String pmsg = MessageFormat.format(ConnectorServiceResources.MSG_CONNECTING_TO_SERVER, new Object[]{clientConnection.getPort()}); + monitor.subTask(pmsg); } // connect to launched server connectStatus = clientConnection.connect(launchStatus.getTicket(), timeout); @@ -789,17 +805,17 @@ else { connectStatus = new ConnectionStatus(false); - connectStatus.setMessage( - RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_COMM_CONNECT_FAILED).getLevelOneText()); + + String cmsg = ConnectorServiceResources.MSG_COMM_CONNECT_FAILED; + connectStatus.setMessage(cmsg); } } 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()); + String cmsg = MessageFormat.format(ConnectorServiceResources.MSG_CONNECTING_TO_SERVER, new Object[] {clientConnection.getPort()}); + monitor.subTask(cmsg); } // connection directly boolean useSSL = isUsingSSL(); @@ -832,8 +848,9 @@ 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()); + String cmsg = MessageFormat.format(ConnectorServiceResources.MSG_COMM_USING_SSL, new Object[] {getHostName()}); + msg = createSystemMessage(IStatus.ERROR, cmsg); + DisplayHidableSystemMessageAction msgAction = new DisplayHidableSystemMessageAction(msg, store, ISystemPreferencesConstants.ALERT_SSL); Display.getDefault().syncExec(msgAction); if (msgAction.getReturnCode() != IDialogConstants.YES_ID) @@ -844,8 +861,9 @@ } else if (!clientConnection.getDataStore().usingSSL() && store.getBoolean(ISystemPreferencesConstants.ALERT_NONSSL)) { - msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_COMM_NOT_USING_SSL); - msg.makeSubstitution(getHostName()); + String cmsg = MessageFormat.format(ConnectorServiceResources.MSG_COMM_NOT_USING_SSL, new Object[] {getHostName()}); + msg = createSystemMessage(IStatus.ERROR, cmsg); + DisplayHidableSystemMessageAction msgAction = new DisplayHidableSystemMessageAction(msg, store, ISystemPreferencesConstants.ALERT_NONSSL); Display.getDefault().syncExec(msgAction); if (msgAction.getReturnCode() != IDialogConstants.YES_ID) @@ -900,14 +918,18 @@ { if (message.startsWith(ClientConnection.CLIENT_OLDER)) { - - msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_COMM_CLIENT_OLDER_WARNING); - msg.makeSubstitution(getHostName()); + String cmsg = ConnectorServiceResources.MSG_COMM_CLIENT_OLDER_WARNING; + String cmsgDetail = MessageFormat.format(ConnectorServiceResources.MSG_COMM_CLIENT_OLDER_WARNING_DETAILS, new Object[]{getHostName()}); + + msg = createSystemMessage(IStatus.WARNING, cmsg, cmsgDetail); + } else if (message.startsWith(ClientConnection.SERVER_OLDER)) { - msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_COMM_SERVER_OLDER_WARNING); - msg.makeSubstitution(getHostName()); + String cmsg = ConnectorServiceResources.MSG_COMM_SERVER_OLDER_WARNING; + String cmsgDetail = MessageFormat.format(ConnectorServiceResources.MSG_COMM_SERVER_OLDER_WARNING_DETAILS, new Object[]{getHostName()}); + + msg = createSystemMessage(IStatus.WARNING, cmsg, cmsgDetail); } if (store.getBoolean(IUniversalDStoreConstants.ALERT_MISMATCHED_SERVER)){ @@ -937,8 +959,8 @@ // Initialzie the miners if (monitor != null) { - SystemMessage imsg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_INITIALIZING_SERVER); - monitor.subTask(imsg.getLevelOneText()); + String imsg = ConnectorServiceResources.MSG_INITIALIZING_SERVER; + monitor.subTask(imsg); } DataElement initStatus = dataStore.initMiners(); //statusMonitor.waitForUpdate(schemaStatus); @@ -971,9 +993,8 @@ } else { - - msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_CONNECT_SSL_EXCEPTION); - msg.makeSubstitution(launchStatus.getMessage()); + String cmsg = MessageFormat.format(ConnectorServiceResources.MSG_CONNECT_SSL_EXCEPTION, new Object[] {launchStatus.getMessage()}); + msg = createSystemMessage(IStatus.ERROR, cmsg); } } } @@ -985,8 +1006,9 @@ if (launchStatus.getException() != null && serverLauncher != null) { Throwable exception = launchStatus.getException(); - msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_CONNECT_DAEMON_FAILED_EXCEPTION); - msg.makeSubstitution(getHostName(), ""+serverLauncher.getDaemonPort(), exception); //$NON-NLS-1$ + String fmsg = MessageFormat.format(ConnectorServiceResources.MSG_CONNECT_DAEMON_FAILED_EXCEPTION, new Object[] {getHostName(), ""+serverLauncher.getDaemonPort()}); + + msg = createSystemMessage(IStatus.ERROR, fmsg, exception); } else if (launchMsg != null && launchMsg.indexOf(IDataStoreConstants.AUTHENTICATION_FAILED) != -1) { @@ -996,8 +1018,11 @@ } // Display error message - msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_COMM_AUTH_FAILED); - msg.makeSubstitution(getHostName()); + String msgTxt = ConnectorServiceResources.MSG_COMM_AUTH_FAILED; + String msgDetails = MessageFormat.format(ConnectorServiceResources.MSG_COMM_AUTH_FAILED_DETAILS, new Object[] { getHostName()}); + + msg = createSystemMessage(IStatus.ERROR, msgTxt, msgDetails); + DisplaySystemMessageAction msgAction = new DisplaySystemMessageAction(msg); Display.getDefault().syncExec(msgAction); @@ -1039,8 +1064,15 @@ SystemSignonInformation newCredentials = null; while (launchMsg != null && (isPasswordExpired(launchMsg) || isNewPasswordInvalid(launchMsg))) { - String messageId = isPasswordExpired(launchMsg) ? ISystemMessages.MSG_VALIDATE_PASSWORD_EXPIRED : ISystemMessages.MSG_VALIDATE_PASSWORD_INVALID; - SystemMessage message = RSEUIPlugin.getPluginMessage(messageId); + String msgTxt = ConnectorServiceResources.MSG_VALIDATE_PASSWORD_INVALID; + String msgDetails = ConnectorServiceResources.MSG_VALIDATE_PASSWORD_INVALID_DETAILS; + if (isPasswordExpired(launchMsg)){ + msgTxt = ConnectorServiceResources.MSG_VALIDATE_PASSWORD_EXPIRED; + msgDetails = ConnectorServiceResources.MSG_VALIDATE_PASSWORD_EXPIRED_DETAILS; + } + + SystemMessage message = createSystemMessage(IStatus.ERROR, msgTxt, msgDetails); + getCredentialsProvider().repairCredentials(message); newCredentials = (SystemSignonInformation) getCredentialsProvider().getCredentials(); launchStatus = changePassword(clientConnection, oldCredentials, serverLauncher, monitor, newCredentials.getPassword()); @@ -1070,8 +1102,8 @@ } else if (launchMsg != null) { - msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_CONNECT_DAEMON_FAILED); - msg.makeSubstitution(getHostName(), clientConnection.getPort(), launchMsg); + String msgTxt = MessageFormat.format(ConnectorServiceResources.MSG_CONNECT_DAEMON_FAILED, new Object[] { getHostName(), clientConnection.getPort()}); + msg = createSystemMessage(IStatus.ERROR, msgTxt, launchMsg); } } @@ -1080,21 +1112,25 @@ { if (connectStatus.getMessage().startsWith(ClientConnection.INCOMPATIBLE_SERVER_UPDATE)) { - msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_COMM_INCOMPATIBLE_UPDATE); - msg.makeSubstitution(getHostName()); + String msgTxt = MessageFormat.format(ConnectorServiceResources.MSG_COMM_INCOMPATIBLE_UPDATE, new Object[] {getHostName()}); + String msgDetails = ConnectorServiceResources.MSG_COMM_INCOMPATIBLE_UPDATE_DETAILS; + + msg = createSystemMessage(IStatus.ERROR, msgTxt, msgDetails); } else if (connectStatus.getMessage().startsWith(ClientConnection.INCOMPATIBLE_PROTOCOL)) { - msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_COMM_INCOMPATIBLE_PROTOCOL); - msg.makeSubstitution(getHostName()); + String msgTxt = MessageFormat.format(ConnectorServiceResources.MSG_COMM_INCOMPATIBLE_PROTOCOL, new Object[] {getHostName()}); + String msgDetails = ConnectorServiceResources.MSG_COMM_INCOMPATIBLE_PROTOCOL_DETAILS; + + msg = createSystemMessage(IStatus.ERROR, msgTxt, msgDetails); } else { Throwable exception = connectStatus.getException(); if (exception != null) { - msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_CONNECT_FAILED); - msg.makeSubstitution(getHostName(), exception); + String msgTxt = MessageFormat.format(ConnectorServiceResources.MSG_CONNECT_FAILED, new Object[]{getHostName()}); + msg = createSystemMessage(IStatus.ERROR, msgTxt, exception); } } } @@ -1103,23 +1139,25 @@ else if (connectStatus == null) { SystemBasePlugin.logError("Failed to connect to remote system", null); //$NON-NLS-1$ - msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_COMM_CONNECT_FAILED); - msg.makeSubstitution(getHostName()); + String msgTxt = MessageFormat.format(ConnectorServiceResources.MSG_COMM_CONNECT_FAILED, new Object[] {getHostName()}); + String msgDetails = MessageFormat.format(ConnectorServiceResources.MSG_COMM_CONNECT_FAILED_DETAILS, new Object[] {getHostName()}); + msg = createSystemMessage(IStatus.ERROR, msgTxt, msgDetails); } // if, for some reason, we don't have a message if (msg == null && connectStatus != null) { SystemBasePlugin.logError("Failed to connect to remote system" + connectStatus.getMessage(), null); //$NON-NLS-1$ - msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_COMM_CONNECT_FAILED); - msg.makeSubstitution(getHostName()); + String msgTxt = MessageFormat.format(ConnectorServiceResources.MSG_COMM_CONNECT_FAILED, new Object[] {getHostName()}); + String msgDetails = MessageFormat.format(ConnectorServiceResources.MSG_COMM_CONNECT_FAILED_DETAILS, new Object[] {getHostName()}); + msg = createSystemMessage(IStatus.ERROR, msgTxt, msgDetails); } clientConnection.disconnect(); clientConnection = null; // yantzi: artemis 6.0, check for invalid login (user ID / pwd) and reprompt for signon information - if (msg != null && msg.getFullMessageID().startsWith(ISystemMessages.MSG_COMM_INVALID_LOGIN)) + if (msg != null && msg.getLevelOneText().startsWith(ConnectorServiceResources.MSG_COMM_AUTH_FAILED)) { if (launchFailed) { @@ -1210,7 +1248,7 @@ String serverPort = (String)starter.launch(monitor); if (monitor.isCanceled()) { - SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_OPERATION_CANCELLED); + SystemMessage msg = createSystemMessage(IStatus.CANCEL, ConnectorServiceResources.MSG_OPERATION_CANCELLED); throw new SystemMessageException(msg); } @@ -1328,8 +1366,7 @@ { for (int idx = 0; idx < warnings.size(); idx++) { - SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_GENERIC_W); - msg.makeSubstitution((warnings.elementAt(idx)).toString()); + SystemMessage msg = createSystemMessage(IStatus.WARNING, warnings.elementAt(idx).toString()); SystemMessageDialog msgDlg = new SystemMessageDialog(shell, msg); msgDlg.open(); } @@ -1383,4 +1420,27 @@ return result; } + protected SystemMessage createSystemMessage(int severity, String msg) { + return createSystemMessage(severity, msg, (String)null); + } + + protected SystemMessage createSystemMessage(int severity, String msg, Throwable e) { + try { + return new SimpleSystemMessage(Activator.PLUGIN_ID, severity, msg, e); + } + catch (IndicatorException ex){ + } + return null; + } + + protected SystemMessage createSystemMessage(int severity, String msg, String msgDetails) { + try { + return new SimpleSystemMessage(Activator.PLUGIN_ID, severity, msg, msgDetails); + } + catch (IndicatorException e){ + } + return null; + } + + } \ No newline at end of file Index: src/org/eclipse/rse/connectorservice/dstore/util/ConnectionStatusListener.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.connectorservice.dstore/src/org/eclipse/rse/connectorservice/dstore/util/ConnectionStatusListener.java,v retrieving revision 1.12 diff -u -r1.12 ConnectionStatusListener.java --- src/org/eclipse/rse/connectorservice/dstore/util/ConnectionStatusListener.java 5 Nov 2007 21:16:04 -0000 1.12 +++ src/org/eclipse/rse/connectorservice/dstore/util/ConnectionStatusListener.java 11 Feb 2008 16:07:00 -0000 @@ -12,13 +12,18 @@ * * Contributors: * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry + * David McKnight (IBM) - [216252] SystemMessages using RSEStatus ********************************************************************************/ package org.eclipse.rse.connectorservice.dstore.util; +import java.io.PrintWriter; +import java.io.StringWriter; import java.lang.reflect.InvocationTargetException; +import java.text.MessageFormat; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; import org.eclipse.dstore.core.model.DataElement; import org.eclipse.dstore.extra.DomainEvent; import org.eclipse.dstore.extra.IDomainListener; @@ -29,8 +34,11 @@ 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.internal.connectorservice.dstore.Activator; +import org.eclipse.rse.internal.connectorservice.dstore.ConnectorServiceResources; +import org.eclipse.rse.services.clientserver.messages.IndicatorException; +import org.eclipse.rse.services.clientserver.messages.SimpleSystemMessage; 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.SystemBasePlugin; import org.eclipse.rse.ui.messages.SystemMessageDialog; @@ -113,10 +121,17 @@ { 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(); + + String fmsgStr = MessageFormat.format(ConnectorServiceResources.MSG_CONNECT_UNKNOWNHOST, new Object[] {_connection.getPrimarySubSystem().getHost().getAliasName()}); + try { + SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, IStatus.ERROR, fmsgStr); + + SystemMessageDialog dialog = new SystemMessageDialog(internalGetShell(), msg); + dialog.open(); + } + catch (IndicatorException e){ + + } try { IRunnableContext runnableContext = getRunnableContext(getShell()); @@ -245,14 +260,23 @@ */ 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(); + String dfailedMsg = MessageFormat.format(ConnectorServiceResources.MSG_DISCONNECT_FAILED, new Object[] {hostName}); + + StringWriter excWriter = new StringWriter(); + exc.printStackTrace(new PrintWriter(excWriter)); + String dmsg = exc.toString(); + if ((dmsg == null) || (exc instanceof ClassCastException)) dmsg = exc.getClass().getName(); + String details = dmsg + "\n" + excWriter.toString(); //$NON-NLS-1$ + + try{ + SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, IStatus.ERROR, dfailedMsg, details); + + SystemMessageDialog msgDlg = new SystemMessageDialog(shell, msg); + msgDlg.setException(exc); + msgDlg.open(); + } + catch (Exception e){ + } } /** * Show an error message when the user cancels the disconnection. @@ -261,10 +285,13 @@ */ 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(); + String msg = MessageFormat.format(ConnectorServiceResources.MSG_DISCONNECT_CANCELLED, new Object[] {hostName}); + + try { + SystemMessageDialog msgDlg = new SystemMessageDialog(shell, new SimpleSystemMessage(Activator.PLUGIN_ID, IStatus.CANCEL, msg)); + msgDlg.open(); + } + catch (IndicatorException e){ + } } } \ No newline at end of file