diff --git a/rse/plugins/org.eclipse.rse.connectorservice.ssh/src/org/eclipse/rse/internal/connectorservice/ssh/SshConnectorResources.java b/rse/plugins/org.eclipse.rse.connectorservice.ssh/src/org/eclipse/rse/internal/connectorservice/ssh/SshConnectorResources.java index 3da2e17821b..8864966b853 100644 --- a/rse/plugins/org.eclipse.rse.connectorservice.ssh/src/org/eclipse/rse/internal/connectorservice/ssh/SshConnectorResources.java +++ b/rse/plugins/org.eclipse.rse.connectorservice.ssh/src/org/eclipse/rse/internal/connectorservice/ssh/SshConnectorResources.java @@ -1,16 +1,17 @@ /******************************************************************************* - * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others. - * 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 - * - * Contributors: - * Martin Oberhuber (Wind River) - initial API and implementation - * Martin Oberhuber (Wind River) - copy dialogs from team.cvs.ui + * Copyright (c) 2006, 2009 Wind River Systems, Inc. and others. + * 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 + * + * Contributors: + * Martin Oberhuber (Wind River) - initial API and implementation + * Martin Oberhuber (Wind River) - copy dialogs from team.cvs.ui * David McKnight (IBM) - [216252] [api][nls] Resource Strings specific to subsystems should be moved from rse.ui into files.ui / shells.ui / processes.ui where possible * David McKnight (IBM) - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared * Johnson Ma (Wind River) - [218880] Add UI setting for ssh keepalives + * Martin Oberhuber (Wind River) - [227135] Cryptic exception when sftp-server is missing *******************************************************************************/ package org.eclipse.rse.internal.connectorservice.ssh; @@ -27,10 +28,11 @@ public class SshConnectorResources extends NLS { public static String SshConnectorService_Name; public static String SshConnectorService_Description; - + public static String SshConnectorService_ErrorDisconnecting; public static String SshConnectorService_Info; public static String SshConnectorService_Warning; + public static String SshConnectorService_Missing_sshd; //These are from org.eclipse.team.cvs.ui.CVSUIMessages public static String UserValidationDialog_required; @@ -44,9 +46,9 @@ public class SshConnectorResources extends NLS { public static String KeyboardInteractiveDialog_message; public static String KeyboardInteractiveDialog_labelConnection; - + public static String SSH_SETTINGS_LABEL; public static String PROPERTY_LABEL_TIMEOUT; public static String PROPERTY_LABEL_KEEPALIVE; - + } diff --git a/rse/plugins/org.eclipse.rse.connectorservice.ssh/src/org/eclipse/rse/internal/connectorservice/ssh/SshConnectorResources.properties b/rse/plugins/org.eclipse.rse.connectorservice.ssh/src/org/eclipse/rse/internal/connectorservice/ssh/SshConnectorResources.properties index 3743d6707e1..4f3f72e1f5b 100644 --- a/rse/plugins/org.eclipse.rse.connectorservice.ssh/src/org/eclipse/rse/internal/connectorservice/ssh/SshConnectorResources.properties +++ b/rse/plugins/org.eclipse.rse.connectorservice.ssh/src/org/eclipse/rse/internal/connectorservice/ssh/SshConnectorResources.properties @@ -1,5 +1,5 @@ ################################################################################ -# Copyright (c) 2006, 2008 Wind River Systems, Inc. and others. +# Copyright (c) 2006, 2009 Wind River Systems, Inc. and others. # 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 @@ -11,6 +11,7 @@ # David McKnight (IBM) - [216252] [api][nls] Resource Strings specific to subsystems should be moved from rse.ui into files.ui / shells.ui / processes.ui where possible # David McKnight (IBM) - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared # Johnson Ma (Wind River) - [218880] Add UI setting for ssh keepalives +# Martin Oberhuber (Wind River) - [227135] Cryptic exception when sftp-server is missing ################################################################################ # NLS_MESSAGEFORMAT_VAR @@ -22,6 +23,7 @@ SshConnectorService_Description=SSH Connector Service Description SshConnectorService_ErrorDisconnecting=ConnectionStatusListener: Error disconnecting SshConnectorService_Warning=Warning SshConnectorService_Info=Info +SshConnectorService_Missing_sshd=Failed to connect sshd on "{0}:{1}" #These are from cvs.ui/messages.properties UserValidationDialog_required=Password Required diff --git a/rse/plugins/org.eclipse.rse.connectorservice.ssh/src/org/eclipse/rse/internal/connectorservice/ssh/SshConnectorService.java b/rse/plugins/org.eclipse.rse.connectorservice.ssh/src/org/eclipse/rse/internal/connectorservice/ssh/SshConnectorService.java index 021779664dc..b9dbb0afe48 100644 --- a/rse/plugins/org.eclipse.rse.connectorservice.ssh/src/org/eclipse/rse/internal/connectorservice/ssh/SshConnectorService.java +++ b/rse/plugins/org.eclipse.rse.connectorservice.ssh/src/org/eclipse/rse/internal/connectorservice/ssh/SshConnectorService.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2009 Wind River Systems, Inc. and others. * 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 - * + * * Contributors: * Martin Oberhuber (Wind River) - initial API and implementation * David Dykstal (IBM) - 168977: refactoring IConnectorService and ServerLauncher hierarchies @@ -18,6 +18,7 @@ * David McKnight (IBM) - [216252] [api][nls] Resource Strings specific to subsystems should be moved from rse.ui into files.ui / shells.ui / processes.ui where possible * David McKnight (IBM) - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared * Johnson Ma (Wind River) - [218880] Add UI setting for ssh keepalives + * Martin Oberhuber (Wind River) - [227135] Cryptic exception when sftp-server is missing *******************************************************************************/ package org.eclipse.rse.internal.connectorservice.ssh; @@ -60,6 +61,7 @@ import org.eclipse.rse.services.clientserver.messages.CommonMessages; import org.eclipse.rse.services.clientserver.messages.ICommonMessageIds; import org.eclipse.rse.services.clientserver.messages.SimpleSystemMessage; import org.eclipse.rse.services.clientserver.messages.SystemMessage; +import org.eclipse.rse.services.clientserver.messages.SystemOperationFailedException; import org.eclipse.rse.ui.RSEUIPlugin; import org.eclipse.rse.ui.SystemBasePlugin; import org.eclipse.rse.ui.messages.SystemMessageDialog; @@ -192,7 +194,8 @@ public class SshConnectorService extends StandardConnectorService implements ISs if(e.toString().indexOf("Auth cancel")>=0) { //$NON-NLS-1$ throw new OperationCanceledException(); } - throw e; + throw new SystemOperationFailedException(Activator.PLUGIN_ID, NLS.bind(SshConnectorResources.SshConnectorService_Missing_sshd, + host, Integer.toString(getSshPort())), e); } userInfo.connectionMade(); fSessionLostHandler = new SessionLostHandler(this); @@ -272,7 +275,7 @@ public class SshConnectorService extends StandardConnectorService implements ISs * Handle session-lost events. * This is generic for any sort of connector service. * Most of this is extracted from dstore's ConnectionStatusListener. - * + * * TODO should be refactored to make it generally available, and allow * dstore to derive from it. */ diff --git a/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/internal/services/ssh/SshServiceResources.java b/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/internal/services/ssh/SshServiceResources.java index fdc547e57c0..93200bf273f 100644 --- a/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/internal/services/ssh/SshServiceResources.java +++ b/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/internal/services/ssh/SshServiceResources.java @@ -1,14 +1,15 @@ /******************************************************************************* * Copyright (c) 2006, 2009 Wind River Systems, Inc. - * 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 - * - * Contributors: - * Martin Oberhuber (Wind River) - initial API and implementation + * 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 + * + * Contributors: + * Martin Oberhuber (Wind River) - initial API and implementation * Yu-Fen Kuo (MontaVista) - [170910] Integrate the TM Terminal View with RSE * Anna Dushistova (MontaVista) - [261478] Remove SshShellService, SshHostShell (or deprecate and schedule for removal in 3.2) + * Martin Oberhuber (Wind River) - [227135] Cryptic exception when sftp-server is missing *******************************************************************************/ package org.eclipse.rse.internal.services.ssh; @@ -18,24 +19,19 @@ import org.eclipse.osgi.util.NLS; public class SshServiceResources extends NLS { private static final String BUNDLE_NAME = "org.eclipse.rse.internal.services.ssh.SshServiceResources"; //$NON-NLS-1$ - public static String SftpFileService_Error_download_size; - - public static String SftpFileService_Error_upload_size; - - public static String SshPlugin_Unexpected_Exception; - + public static String SftpFileService_Name; public static String SftpFileService_Description; - public static String SftpFileService_Error_JschSessionLost; - + public static String SftpFileService_Error_download_size; + public static String SftpFileService_Error_upload_size; + public static String SftpFileService_Error_no_sftp; public static String SftpFileService_Msg_Progress; - public static String SftpFileService_Name; + public static String SshPlugin_Unexpected_Exception; public static String SshTerminalService_Name; - public static String SshTerminalService_Description; - + static { // initialize resource bundle NLS.initializeMessages(BUNDLE_NAME, SshServiceResources.class); diff --git a/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/internal/services/ssh/SshServiceResources.properties b/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/internal/services/ssh/SshServiceResources.properties index 1bc4a258fbe..2f7a35c168d 100644 --- a/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/internal/services/ssh/SshServiceResources.properties +++ b/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/internal/services/ssh/SshServiceResources.properties @@ -9,6 +9,7 @@ # Martin Oberhuber (Wind River) - initial API and implementation # Yu-Fen Kuo (MontaVista) - [170910] Integrate the TM Terminal View with RSE # Anna Dushistova (MontaVista) - [261478] Remove SshShellService, SshHostShell (or deprecate and schedule for removal in 3.2) +# Martin Oberhuber (Wind River) - [227135] Cryptic exception when sftp-server is missing ################################################################################ # NLS_MESSAGEFORMAT_VAR @@ -20,7 +21,8 @@ SftpFileService_Name=Ssh / Sftp File Service SftpFileService_Description=Access a remote file system via Ssh / Sftp protocol SftpFileService_Error_JschSessionLost=jsch session lost SftpFileService_Error_upload_size=Ssh upload: file size mismatch for {0} -SftpFileService_Error_download_size=Ssh download: file size mismatch for {0} +SftpFileService_Error_download_size=Ssh download: file size mismatch for {0} +SftpFileService_Error_no_sftp=Failed to connect SFTP subsystem: Remote host may not have sftp-server installed SftpFileService_Msg_Progress={0,number,integer} KB of {1,number,integer} KB complete ({2,number,percent}) SshTerminalService_Name=SSH Terminal Service diff --git a/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/internal/services/ssh/files/SftpFileService.java b/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/internal/services/ssh/files/SftpFileService.java index 15767e1899f..d8bc6a76d44 100644 --- a/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/internal/services/ssh/files/SftpFileService.java +++ b/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/internal/services/ssh/files/SftpFileService.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2009 Wind River Systems, Inc. and others. * 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 @@ -35,6 +35,7 @@ * David McKnight (IBM) - [235472] [ssh] RSE doesn't show correct properties of the file system root ("/") * Martin Oberhuber (Wind River) - [238703] getFile() needs to lstat for consistency with internalFetch() * Martin Oberhuber (Wind River) - [237616][ssh] Dont perform forced setLastModified during upload + * Martin Oberhuber (Wind River) - [227135] Cryptic exception when sftp-server is missing *******************************************************************************/ package org.eclipse.rse.internal.services.ssh.files; @@ -82,6 +83,7 @@ import org.eclipse.rse.services.clientserver.messages.SystemLockTimeoutException import org.eclipse.rse.services.clientserver.messages.SystemMessage; import org.eclipse.rse.services.clientserver.messages.SystemMessageException; import org.eclipse.rse.services.clientserver.messages.SystemOperationCancelledException; +import org.eclipse.rse.services.clientserver.messages.SystemOperationFailedException; import org.eclipse.rse.services.clientserver.messages.SystemUnexpectedErrorException; import org.eclipse.rse.services.files.AbstractFileService; import org.eclipse.rse.services.files.HostFilePermissions; @@ -177,6 +179,8 @@ public class SftpFileService extends AbstractFileService implements ISshService, private static String defaultEncoding = new java.io.InputStreamReader(new java.io.ByteArrayInputStream(new byte[0])).getEncoding(); /** Indicates the encoding that our JSch channel uses */ private String fJSchChannelEncoding = defaultEncoding; + private long fLastConnectFailureTime = 0; + private static long CONNECT_RETRY_MILLIS = 10000; //re-try unsuccessful sftp connect attempt after 10 seconds // public SftpFileService(SshConnectorService conn) { // fConnector = conn; @@ -338,8 +342,11 @@ public class SftpFileService extends AbstractFileService implements ISshService, } public void connect() throws SystemMessageException { - Activator.trace("SftpFileService.connecting..."); //$NON-NLS-1$ + if (fLastConnectFailureTime > 0 && System.currentTimeMillis() - fLastConnectFailureTime < CONNECT_RETRY_MILLIS) { + throw new SystemOperationFailedException(Activator.PLUGIN_ID, SshServiceResources.SftpFileService_Error_no_sftp); + } try { + Activator.trace("SftpFileService.connecting..."); //$NON-NLS-1$ Session session = fSessionProvider.getSession(); Channel channel=session.openChannel("sftp"); //$NON-NLS-1$ channel.connect(); @@ -349,7 +356,8 @@ public class SftpFileService extends AbstractFileService implements ISshService, Activator.trace("SftpFileService.connected"); //$NON-NLS-1$ } catch(Exception e) { Activator.trace("SftpFileService.connecting failed: "+e.toString()); //$NON-NLS-1$ - throw makeSystemMessageException(e); + fLastConnectFailureTime = System.currentTimeMillis(); + throw new SystemOperationFailedException(Activator.PLUGIN_ID, SshServiceResources.SftpFileService_Error_no_sftp, e); } } @@ -1118,13 +1126,13 @@ public class SftpFileService extends AbstractFileService implements ISshService, public void initService(IProgressMonitor monitor) { Activator.trace("SftpFileService.initService"); //$NON-NLS-1$ super.initService(monitor); - try - { - connect(); - } - catch (Exception e) - { - } + // try + // { + // connect(); + // } + // catch (Exception e) + // { + // } } public void uninitService(IProgressMonitor monitor) { diff --git a/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/archiveutils/ArchiveHandlerManager.java b/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/archiveutils/ArchiveHandlerManager.java index f3052fe26cc..226fdd7de9e 100644 --- a/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/archiveutils/ArchiveHandlerManager.java +++ b/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/archiveutils/ArchiveHandlerManager.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2008 IBM Corporation and others. + * Copyright (c) 2003, 2009 IBM Corporation and others. * 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 @@ -18,6 +18,7 @@ * Xuan Chen (IBM) - [218491] ArchiveHandlerManager#cleanUpVirtualPath is messing up the file separators (with updated fix) * Johnson Ma (Wind River) - [195402] [api] add tar.gz archive support * Martin Oberhuber (Wind River) - [199854][api] Improve error reporting for archive handlers + * Martin Oberhuber (Wind River) - [227135] Cryptic exception when sftp-server is missing *******************************************************************************/ package org.eclipse.rse.services.clientserver.archiveutils; @@ -308,11 +309,11 @@ public class ArchiveHandlerManager catch (InvocationTargetException e) { //Throwable target = e.getCause(); - throw new SystemOperationFailedException(IClientServerConstants.PLUGIN_ID, "instantiate handler for " + file.getName(), e); //$NON-NLS-1$ + throw new SystemOperationFailedException(IClientServerConstants.PLUGIN_ID, "Failed to instantiate handler for " + file.getName(), e); //$NON-NLS-1$ } catch (Exception e) { - throw new SystemOperationFailedException(IClientServerConstants.PLUGIN_ID, "instantiate handler for " + file.getName(), e); //$NON-NLS-1$ + throw new SystemOperationFailedException(IClientServerConstants.PLUGIN_ID, "Failed to instantiate handler for " + file.getName(), e); //$NON-NLS-1$ } _handlers.put(file, handler); return handler; @@ -500,7 +501,7 @@ public class ArchiveHandlerManager /** * Create an empty archive - * + * * @throws SystemMessageException in case of an error * @since 3.0 returns void but throws SystemMessageException */ diff --git a/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/messages/CommonMessages.java b/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/messages/CommonMessages.java index cc89d0e304c..f2d20178ec2 100644 --- a/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/messages/CommonMessages.java +++ b/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/messages/CommonMessages.java @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (c) 2008 IBM Corporation. All rights reserved. + * Copyright (c) 2008, 2009 IBM Corporation and others. 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 @@ -12,6 +12,7 @@ * David McKnight (IBM) - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared * David McKnight (IBM) - [223204] [cleanup] fix broken nls strings in files.ui and others * Martin Oberhuber (Wind River) - [226374] [api] Need default SystemMessageException specialisations + * Martin Oberhuber (Wind River) - [227135] Cryptic exception when sftp-server is missing ********************************************************************************/ package org.eclipse.rse.services.clientserver.messages; @@ -27,7 +28,12 @@ public class CommonMessages extends NLS { public static String MSG_EXCEPTION_OCCURRED; public static String MSG_ERROR_UNEXPECTED; - + /** + * General message format for concatenating a message with a cause + * + * @since 3.1 + */ + public static String MSG_FAILURE_WITH_CAUSE; public static String MSG_COMM_AUTH_FAILED; public static String MSG_COMM_AUTH_FAILED_DETAILS; diff --git a/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/messages/CommonMessages.properties b/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/messages/CommonMessages.properties index 5a10a076407..bf63a500ca3 100644 --- a/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/messages/CommonMessages.properties +++ b/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/messages/CommonMessages.properties @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2008 IBM Corporation and others. +# Copyright (c) 2008, 2009 IBM Corporation and others. # 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 @@ -14,6 +14,7 @@ # David McKnight (IBM) - [223204] [cleanup] fix broken nls strings in files.ui and others # Xuan Chen (IBM) - [226784] [nls] Review Canceled vs. Cancelled in NLS Strings # Martin Oberhuber (Wind River) - [226374] [api] Need default SystemMessageException specialisations +# Martin Oberhuber (Wind River) - [227135] Cryptic exception when sftp-server is missing ############################################################################### # NLS_MESSAGEFORMAT_VAR @@ -21,6 +22,7 @@ MSG_EXCEPTION_OCCURRED = An unexpected exception has occurred +MSG_FAILURE_WITH_CAUSE = {0}: {1} 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. diff --git a/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/messages/SystemOperationFailedException.java b/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/messages/SystemOperationFailedException.java index de769288f7f..c60585db593 100644 --- a/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/messages/SystemOperationFailedException.java +++ b/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/messages/SystemOperationFailedException.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Wind River Systems, Inc. and others. + * Copyright (c) 2008, 2009 Wind River Systems, Inc. and others. * 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 @@ -7,6 +7,7 @@ * * Contributors: * Martin Oberhuber (Wind River) - initial API and implementation + * Martin Oberhuber (Wind River) - [227135] Cryptic exception when sftp-server is missing *******************************************************************************/ package org.eclipse.rse.services.clientserver.messages; @@ -65,39 +66,52 @@ public class SystemOperationFailedException extends SystemRemoteMessageException } /** - * Constructor with plugin ID and operation being performed. + * Constructor with plugin ID and user message. * - * @param remoteException the initial cause of this exception + * @param pluginId ID of the plugin issuing the message. + * @param userMessage user-readable message detailing cause of the + * exception, or null. If not specified, a generic + * message will be used ("Operation failed with exception"). + * @param remoteException the initial cause of this exception. Will be added + * to the user message. */ - public SystemOperationFailedException(String pluginId, String operationPerformed, Exception remoteException) { - super(getMyMessage(pluginId, operationPerformed, remoteException), remoteException); + public SystemOperationFailedException(String pluginId, String userMessage, Exception remoteException) { + super(getMyMessage(pluginId, userMessage, remoteException), remoteException); } - private static SystemMessage getMyMessage(String pluginId, String operationPerformed, Exception remoteException) { + private static SystemMessage getMyMessage(String pluginId, String userMessage, Exception remoteException) { - String message = operationPerformed; + String exceptionMessage = null; String secondLevel = null; if (remoteException != null) { - message = remoteException.getMessage(); - if (message == null) { - message = remoteException.getClass().getName(); + exceptionMessage = remoteException.getMessage(); + if (exceptionMessage == null) { + exceptionMessage = remoteException.getClass().getName(); } Throwable cause = remoteException.getCause(); if (cause != null) { secondLevel = cause.getMessage(); if (secondLevel == null) { secondLevel = cause.getClass().getName(); - if (secondLevel.equals(message)) { + if (secondLevel.equals(exceptionMessage)) { secondLevel = null; } } } - if (operationPerformed != null) { - // FIXME Use Java MessageFormat for better formatting - secondLevel = (secondLevel != null) ? operationPerformed + " : " + secondLevel : operationPerformed; //$NON-NLS-1$ - } } - String msgTxt = NLS.bind(CommonMessages.MSG_OPERATION_FAILED, message); + String msgTxt = userMessage; + if (msgTxt == null) { + // no user text -- use standard message with (non-localized) + // exception message + second level + msgTxt = NLS.bind(CommonMessages.MSG_OPERATION_FAILED, exceptionMessage); + } else if (secondLevel == null) { + // user text but no second level -- move exception text to 2nd level + secondLevel = exceptionMessage; + } else { + // user text, exception and second level -- concatenate user text + // and exception + msgTxt = NLS.bind(CommonMessages.MSG_FAILURE_WITH_CAUSE, userMessage, exceptionMessage); + } SystemMessage msg = new SimpleSystemMessage(pluginId, ICommonMessageIds.MSG_OPERATION_FAILED, IStatus.ERROR, msgTxt, secondLevel); diff --git a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/SystemViewRemoteOutputAdapter.java b/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/SystemViewRemoteOutputAdapter.java index c63ddb47391..da11d03f92a 100644 --- a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/SystemViewRemoteOutputAdapter.java +++ b/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/SystemViewRemoteOutputAdapter.java @@ -29,6 +29,7 @@ * David McKnight (IBM) - [233349] Could not drag and drop file from Shell view to local folder. * David McKnight (IBM) - [233475] Cannot drag and drop file/folder within the shell output * Kevin Doyle (IBM) - [247297] Double Clicking on a Shell doesn't open that Shell + * Martin Oberhuber (Wind River) - [227135] Cryptic exception when sftp-server is missing *******************************************************************************/ package org.eclipse.rse.shells.ui.view; @@ -377,9 +378,12 @@ implements ISystemRemoteElementAdapter } /** - * Returns the associated IRemoteFile for this line of remote output if one exists + * Returns the associated IRemoteFile for this line of remote output if one + * exists + * * @param output the line of remote output - * @return the associated remote file + * @return the associated remote file, or null if an error + * occurred */ public static IRemoteFile outputToFile(IRemoteOutput output) {