mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-19 06:55:23 +02:00
[226374] [api] Need default SystemMessageException specialisations
This commit is contained in:
parent
bda7058954
commit
4e8b4368e1
12 changed files with 488 additions and 67 deletions
|
@ -1,16 +1,17 @@
|
|||
/********************************************************************************
|
||||
* 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
|
||||
* 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:
|
||||
* 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
|
||||
********************************************************************************/
|
||||
package org.eclipse.rse.services.clientserver.messages;
|
||||
|
||||
|
@ -20,49 +21,52 @@ import org.eclipse.osgi.util.NLS;
|
|||
public class CommonMessages extends NLS {
|
||||
private static String BUNDLE_NAME = "org.eclipse.rse.services.clientserver.messages.CommonMessages";//$NON-NLS-1$
|
||||
|
||||
|
||||
|
||||
public static String MSG_EXCEPTION_OCCURRED;
|
||||
public static String MSG_ERROR_UNEXPECTED;
|
||||
|
||||
|
||||
|
||||
|
||||
public static String MSG_COMM_AUTH_FAILED;
|
||||
public static String MSG_COMM_AUTH_FAILED_DETAILS;
|
||||
public static String MSG_COMM_NETWORK_ERROR;
|
||||
|
||||
public static String MSG_EXPAND_FAILED;
|
||||
public static String MSG_EXPAND_CANCELLED;
|
||||
|
||||
|
||||
// operation status
|
||||
public static String MSG_OPERATION_RUNNING;
|
||||
public static String MSG_OPERATION_FINISHED;
|
||||
public static String MSG_OPERTION_STOPPED;
|
||||
public static String MSG_OPERATION_DISCONNECTED;
|
||||
|
||||
public static String MSG_OPERATION_DISCONNECTED;
|
||||
|
||||
public static String MSG_CONNECT_CANCELLED;
|
||||
public static String MSG_CONNECT_PROGRESS;
|
||||
public static String MSG_CONNECTWITHPORT_PROGRESS;
|
||||
public static String MSG_CONNECT_FAILED;
|
||||
public static String MSG_CONNECT_UNKNOWNHOST;
|
||||
|
||||
|
||||
public static String MSG_DISCONNECT_PROGRESS;
|
||||
public static String MSG_DISCONNECTWITHPORT_PROGRESS;
|
||||
public static String MSG_DISCONNECT_FAILED;
|
||||
public static String MSG_DISCONNECT_CANCELLED;
|
||||
|
||||
|
||||
public static String MSG_OPERATION_FAILED;
|
||||
public static String MSG_OPERATION_CANCELLED;
|
||||
|
||||
public static String MSG_OPERATION_UNSUPPORTED;
|
||||
public static String MSG_OPERATION_SECURITY_VIOLATION;
|
||||
|
||||
public static String MSG_RESOLVE_PROGRESS;
|
||||
|
||||
public static String MSG_QUERY_PROGRESS;
|
||||
public static String MSG_QUERY_PROPERTIES_PROGRESS;
|
||||
|
||||
|
||||
public static String MSG_SET_PROGRESS;
|
||||
public static String MSG_SET_PROPERTIES_PROGRESS;
|
||||
|
||||
public static String MSG_RUN_PROGRESS;
|
||||
public static String MSG_COPY_PROGRESS;
|
||||
|
||||
|
||||
|
||||
static {
|
||||
// load message values from bundle file
|
||||
NLS.initializeMessages(BUNDLE_NAME, CommonMessages.class);
|
||||
|
|
|
@ -13,6 +13,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
|
||||
# Xuan Chen (IBM) - [226784] [nls] Review Canceled vs. Cancelled in NLS Strings
|
||||
# Martin Oberhuber (Wind River) - [226374] [api] Need default SystemMessageException specialisations
|
||||
###############################################################################
|
||||
|
||||
# NLS_MESSAGEFORMAT_VAR
|
||||
|
@ -23,6 +24,7 @@ MSG_EXCEPTION_OCCURRED = An unexpected exception has occurred
|
|||
|
||||
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_NETWORK_ERROR=Operation failed due to network I/O error ''{0}''
|
||||
|
||||
MSG_ERROR_UNEXPECTED=An unexpected error occurred.
|
||||
|
||||
|
@ -36,7 +38,9 @@ MSG_OPERATION_FINISHED = {0} - Finished
|
|||
MSG_OPERTION_STOPPED = {0} - Cancelled
|
||||
MSG_OPERATION_DISCONNECTED = {0} - Disconnected
|
||||
MSG_OPERATION_FAILED = Operation failed with exception ''{0}''
|
||||
MSG_OPERATION_CANCELLED = Operation cancelled.
|
||||
MSG_OPERATION_CANCELLED = Operation cancelled.
|
||||
MSG_OPERATION_UNSUPPORTED = Operation not supported: ''{0}''
|
||||
MSG_OPERATION_SECURITY_VIOLATION=Operation failed. Security violation on ''{0}''
|
||||
|
||||
|
||||
# messages
|
||||
|
|
|
@ -10,12 +10,13 @@
|
|||
*
|
||||
* Contributors:
|
||||
* David McKnight (IBM) - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared
|
||||
* Martin Oberhuber (Wind River) - [226374] [api] Need default SystemMessageException specialisations
|
||||
********************************************************************************/
|
||||
package org.eclipse.rse.services.clientserver.messages;
|
||||
|
||||
/**
|
||||
* Common Global Message IDs to be used with the RSE SystemMessages mechanism.
|
||||
*
|
||||
*
|
||||
* Clients may use these IDs when creating message objects, or when calling
|
||||
* {@link org.eclipse.rse.ui.SystemBasePlugin#getPluginMessage(String)}. The
|
||||
* message IDs uniquely identify a particular situation each, and are used for
|
||||
|
@ -38,6 +39,8 @@ public interface ICommonMessageIds {
|
|||
|
||||
public static final String MSG_OPERATION_FAILED = "RSEG1066"; //$NON-NLS-1$
|
||||
public static final String MSG_OPERATION_CANCELLED = "RSEG1067"; //$NON-NLS-1$
|
||||
public static final String MSG_OPERATION_UNSUPPORTED = "RSEG9999";//FIXME //$NON-NLS-1$
|
||||
public static final String MSG_OPERATION_SECURITY_VIOLATION = "RSEG9999";//FIXME //$NON-NLS-1$
|
||||
|
||||
public static final String MSG_EXCEPTION_OCCURRED = "RSEG1003"; //$NON-NLS-1$
|
||||
public static final String MSG_EXCEPTION_DELETING = "RSEG1063"; //$NON-NLS-1$
|
||||
|
@ -48,6 +51,7 @@ public interface ICommonMessageIds {
|
|||
|
||||
public static final String MSG_COMM_AUTH_FAILED = "RSEC1002"; //$NON-NLS-1$
|
||||
public static final String MSG_COMM_PWD_INVALID = "RSEC1004"; //$NON-NLS-1$
|
||||
public static final String MSG_COMM_NETWORK_ERROR = "RSEC9999"; //FIXME //$NON-NLS-1$
|
||||
|
||||
public static final String MSG_EXPAND_FAILED = "RSEG1098"; //$NON-NLS-1$
|
||||
public static final String MSG_EXPAND_CANCELLED = "RSEG1067"; //$NON-NLS-1$
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 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
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.rse.services.clientserver.messages;
|
||||
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.osgi.util.NLS;
|
||||
|
||||
import org.eclipse.rse.internal.services.Activator;
|
||||
|
||||
/**
|
||||
* Exception thrown in case of errors due to network I/O Problems.
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
public class SystemNetworkIOException extends SystemRemoteMessageException {
|
||||
/**
|
||||
* A serialVersionUID is recommended for all serializable classes. This
|
||||
* trait is inherited from Throwable. This should be updated if there is a
|
||||
* schema change for this class.
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Default Constructor.
|
||||
* Clients are encouraged to use the more specific constructor with pluginId instead of this one.
|
||||
*
|
||||
*
|
||||
* @param remoteException exception from communication layer.
|
||||
*/
|
||||
public SystemNetworkIOException(Exception remoteException) {
|
||||
super(getMyMessage(Activator.PLUGIN_ID, remoteException), remoteException);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor with a plugin ID and exception cause.
|
||||
*
|
||||
* @param pluginId Plugin ID that caused the error.
|
||||
* @param remoteException exception from communication layer.
|
||||
*/
|
||||
public SystemNetworkIOException(String pluginId, Exception remoteException) {
|
||||
super(getMyMessage(pluginId, remoteException), remoteException);
|
||||
}
|
||||
|
||||
private static SystemMessage getMyMessage(String pluginId, Exception remoteException) {
|
||||
|
||||
String message = remoteException.getMessage();
|
||||
if (message == null) {
|
||||
message = remoteException.getClass().getName();
|
||||
}
|
||||
String msgTxt = NLS.bind(CommonMessages.MSG_COMM_NETWORK_ERROR, message);
|
||||
|
||||
String secondLevel = null;
|
||||
Throwable cause = remoteException.getCause();
|
||||
if (cause != null) {
|
||||
secondLevel = cause.getMessage();
|
||||
if (secondLevel == null) {
|
||||
secondLevel = cause.getClass().getName();
|
||||
if (secondLevel.equals(message)) {
|
||||
secondLevel = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
SystemMessage msg = new SimpleSystemMessage(pluginId, ICommonMessageIds.MSG_COMM_NETWORK_ERROR, IStatus.ERROR, msgTxt, secondLevel);
|
||||
return msg;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2008 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
|
||||
*
|
||||
* 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:
|
||||
* David McKnight (IBM) - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared
|
||||
* Martin Oberhuber (Wind River) - [226374] [api] Derived from RemoteFileCancelledException
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.rse.services.clientserver.messages;
|
||||
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
|
||||
import org.eclipse.rse.internal.services.Activator;
|
||||
|
||||
/**
|
||||
* Exception thrown when attempting an operation and the user cancelled it
|
||||
* before it could be completed.
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
public class SystemOperationCancelledException extends SystemMessageException {
|
||||
|
||||
/**
|
||||
* A serialVersionUID is recommended for all serializable classes. This
|
||||
* trait is inherited from Throwable. This should be updated if there is a
|
||||
* schema change for this class.
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static SystemMessage myMessage = null;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public SystemOperationCancelledException() {
|
||||
super(getMyMessage());
|
||||
}
|
||||
|
||||
private static SystemMessage getMyMessage() {
|
||||
if (myMessage == null) {
|
||||
myMessage = new SimpleSystemMessage(Activator.PLUGIN_ID, ICommonMessageIds.MSG_OPERATION_CANCELLED, IStatus.ERROR,
|
||||
CommonMessages.MSG_OPERATION_CANCELLED);
|
||||
}
|
||||
return myMessage;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 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
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.rse.services.clientserver.messages;
|
||||
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.osgi.util.NLS;
|
||||
|
||||
import org.eclipse.rse.internal.services.Activator;
|
||||
|
||||
/**
|
||||
* Generic exception thrown when anything fails and a child exception is
|
||||
* available to provide exception details.
|
||||
* <p>
|
||||
* The original remote system's exception message is always embedded and
|
||||
* retrievable via getRemoteException().
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
public class SystemOperationFailedException extends SystemRemoteMessageException {
|
||||
/**
|
||||
* A serialVersionUID is recommended for all serializable classes. This
|
||||
* trait is inherited from Throwable. This should be updated if there is a
|
||||
* schema change for this class.
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Default Constructor.
|
||||
* Clients are encouraged to use the more specific constructor with pluginId and operationPerformed instead of this one.
|
||||
*
|
||||
* @param remoteException the initial cause of this exception
|
||||
*/
|
||||
public SystemOperationFailedException(Exception remoteException) {
|
||||
super(getMyMessage(Activator.PLUGIN_ID, null, remoteException), remoteException);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor with plugin ID.
|
||||
* Clients are encouraged to use the more specific constructor with pluginId and operationPerformed instead of this one.
|
||||
*
|
||||
* @param remoteException the initial cause of this exception
|
||||
*/
|
||||
public SystemOperationFailedException(String pluginId, Exception remoteException) {
|
||||
super(getMyMessage(pluginId, null, remoteException), remoteException);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor with plugin ID and operation being performed.
|
||||
*
|
||||
* @param remoteException the initial cause of this exception
|
||||
*/
|
||||
public SystemOperationFailedException(String pluginId, String operationPerformed, Exception remoteException) {
|
||||
super(getMyMessage(pluginId, operationPerformed, remoteException), remoteException);
|
||||
}
|
||||
|
||||
private static SystemMessage getMyMessage(String pluginId, String operationPerformed, Exception remoteException) {
|
||||
|
||||
String message = remoteException.getMessage();
|
||||
if (message == null) {
|
||||
message = remoteException.getClass().getName();
|
||||
}
|
||||
String msgTxt = NLS.bind(CommonMessages.MSG_OPERATION_FAILED, message);
|
||||
|
||||
String secondLevel = null;
|
||||
Throwable cause = remoteException.getCause();
|
||||
if (cause != null) {
|
||||
secondLevel = cause.getMessage();
|
||||
if (secondLevel == null) {
|
||||
secondLevel = cause.getClass().getName();
|
||||
if (secondLevel.equals(message)) {
|
||||
secondLevel = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (operationPerformed != null) {
|
||||
// FIXME Use Java MessageFormat for better formatting
|
||||
secondLevel = (secondLevel != null) ? operationPerformed + " : " + secondLevel : operationPerformed; //$NON-NLS-1$
|
||||
}
|
||||
SystemMessage msg = new SimpleSystemMessage(pluginId, ICommonMessageIds.MSG_OPERATION_FAILED,
|
||||
IStatus.ERROR, msgTxt, secondLevel);
|
||||
return msg;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2008 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
|
||||
*
|
||||
* 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:
|
||||
* Martin Oberhuber (Wind River) - [226374] [api] Derived from RemoteFileException
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.rse.services.clientserver.messages;
|
||||
|
||||
|
||||
/**
|
||||
* Base class for remote system exceptions.
|
||||
* <p>
|
||||
* All remote system exceptions are guaranteed to have a translated message
|
||||
* retrievable via getMessage(), to make it easy to display to the user.
|
||||
* <p>
|
||||
* All child exceptions potentially contain an embedded exception that is the
|
||||
* original exception from the remote system.
|
||||
* <p>
|
||||
* Use {#link getRemoteException()} to retrieve that wrapped exception, if any.
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
public class SystemRemoteMessageException extends SystemMessageException {
|
||||
|
||||
/**
|
||||
* A serialVersionUID is recommended for all serializable classes. This
|
||||
* trait is inherited from Throwable. This should be updated if there is a
|
||||
* schema change for this class.
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private Exception wrappedException = null;
|
||||
|
||||
/**
|
||||
* Constructor with an error message for getMessage() to return, and a
|
||||
* wrapped exception to contain. It is accessed via getRemoteException().
|
||||
*
|
||||
* @param msg The fully resolved message
|
||||
* @param remoteException The exception to contain within this exception
|
||||
*/
|
||||
public SystemRemoteMessageException(SystemMessage msg, Exception remoteException) {
|
||||
super(msg);
|
||||
wrappedException = remoteException;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor with a plain text message, and a wrapped exception.
|
||||
*
|
||||
* @param msg The fully resolved message
|
||||
* @param remoteException The exception to contain within this exception
|
||||
*/
|
||||
public SystemRemoteMessageException(String msg, Exception remoteException) {
|
||||
super(msg);
|
||||
wrappedException = remoteException;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the original remote exception
|
||||
*/
|
||||
public Exception getRemoteException() {
|
||||
return wrappedException;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2008 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
|
||||
*
|
||||
* 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:
|
||||
* 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
|
||||
* Martin Oberhuber (Wind River) - [226374] Derived from RemoteFileSecurityException
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.rse.services.clientserver.messages;
|
||||
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.osgi.util.NLS;
|
||||
|
||||
/**
|
||||
* Exception thrown when attempting an operation and it fails for security
|
||||
* reasons. The original remote system's security message is always embedded and
|
||||
* retrievable via getRemoteException().
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
public class SystemRemoteSecurityException extends SystemRemoteMessageException {
|
||||
/**
|
||||
* A serialVersionUID is recommended for all serializable classes. This
|
||||
* trait is inherited from Throwable. This should be updated if there is a
|
||||
* schema change for this class.
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Constructor with plugin ID and operation being performed.
|
||||
*
|
||||
* @param pluginId ID of the plugin which detected the security violation
|
||||
* @param operationPerformed element or operation which could not be
|
||||
* accessed due to security restriction
|
||||
* @param remoteException the initial cause of this exception
|
||||
*/
|
||||
public SystemRemoteSecurityException(String pluginId, String operationPerformed, Exception remoteException) {
|
||||
super(getMyMessage(pluginId, operationPerformed, remoteException), remoteException);
|
||||
}
|
||||
|
||||
private static SystemMessage getMyMessage(String pluginId, String operationPerformed, Exception remoteException) {
|
||||
|
||||
String msgTxt = NLS.bind(CommonMessages.MSG_OPERATION_FAILED, operationPerformed);
|
||||
|
||||
String detailMessage = remoteException.getMessage();
|
||||
if (detailMessage == null) {
|
||||
detailMessage = remoteException.getClass().getName();
|
||||
}
|
||||
String secondLevel = null;
|
||||
Throwable cause = remoteException.getCause();
|
||||
if (cause != null) {
|
||||
secondLevel = cause.getMessage();
|
||||
if (secondLevel == null) {
|
||||
secondLevel = cause.getClass().getName();
|
||||
if (secondLevel.equals(detailMessage)) {
|
||||
secondLevel = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (secondLevel != null) {
|
||||
// FIXME Use MessageFormat
|
||||
detailMessage = detailMessage + " : " + secondLevel; //$NON-NLS-1$
|
||||
}
|
||||
SystemMessage msg = new SimpleSystemMessage(pluginId, ICommonMessageIds.MSG_OPERATION_SECURITY_VIOLATION, IStatus.ERROR, msgTxt, secondLevel);
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 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
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.rse.services.clientserver.messages;
|
||||
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.osgi.util.NLS;
|
||||
|
||||
/**
|
||||
* Exception thrown when an operation is requested from a Service that is not
|
||||
* supported by that service.
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
public class SystemUnsupportedOperationException extends SystemMessageException {
|
||||
|
||||
/**
|
||||
* A serialVersionUID is recommended for all serializable classes. This
|
||||
* trait is inherited from Throwable. This should be updated if there is a
|
||||
* schema change for this class.
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param pluginId ID of the plugin not supporting requested operation.
|
||||
* @param operation The operation being requested
|
||||
*/
|
||||
public SystemUnsupportedOperationException(String pluginId, String operation) {
|
||||
super(getMyMessage(pluginId, operation));
|
||||
}
|
||||
|
||||
private static SystemMessage getMyMessage(String pluginId, String operation) {
|
||||
|
||||
String msgTxt = NLS.bind(CommonMessages.MSG_OPERATION_UNSUPPORTED, operation);
|
||||
SystemMessage msg = new SimpleSystemMessage(pluginId, ICommonMessageIds.MSG_OPERATION_UNSUPPORTED, IStatus.ERROR, msgTxt);
|
||||
return msg;
|
||||
}
|
||||
|
||||
}
|
|
@ -15,47 +15,33 @@
|
|||
* Martin Oberhuber (Wind River) - [216351] Improve cancellation of SystemFetchOperation for files
|
||||
* 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
|
||||
* Martin Oberhuber (Wind River) - [226374] [api] Need default SystemMessageException specialisations
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.rse.services.files;
|
||||
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
|
||||
import org.eclipse.rse.internal.services.Activator;
|
||||
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.SystemOperationCancelledException;
|
||||
|
||||
/**
|
||||
* Exception thrown when attempting a file operation and the user cancelled it
|
||||
* before it could be completed.
|
||||
* before it could be completed. Used to extend RemoteFileException before 3.0
|
||||
*
|
||||
* @deprecated use SystemOperationCancelledException
|
||||
* @since 3.0
|
||||
*/
|
||||
public class RemoteFileCancelledException extends RemoteFileException {
|
||||
public class RemoteFileCancelledException extends SystemOperationCancelledException {
|
||||
|
||||
/**
|
||||
* A serialVersionUID is recommended for all serializable classes.
|
||||
* This trait is inherited from Throwable.
|
||||
* This should be updated if there is a schema change for this class.
|
||||
* A serialVersionUID is recommended for all serializable classes. This
|
||||
* trait is inherited from Throwable. This should be updated if there is a
|
||||
* schema change for this class.
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static SystemMessage myMessage = null;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public RemoteFileCancelledException() {
|
||||
super(getMyMessage());
|
||||
super();
|
||||
}
|
||||
|
||||
private static SystemMessage getMyMessage() {
|
||||
String msgTxt = CommonMessages.MSG_OPERATION_CANCELLED;
|
||||
|
||||
myMessage = new SimpleSystemMessage(Activator.PLUGIN_ID,
|
||||
ICommonMessageIds.MSG_OPERATION_CANCELLED,
|
||||
IStatus.ERROR, msgTxt);
|
||||
|
||||
return myMessage;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,14 +12,14 @@
|
|||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
* Martin Oberhuber (Wind River) - [226374] [api] Need default SystemMessageException specialisations
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.rse.services.files;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemRemoteMessageException;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -32,8 +32,11 @@ import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
|
|||
* original exception from the remote system.
|
||||
* <p>
|
||||
* Use {#link getRemoteException()} to retrieve that wrapped exception, if any.
|
||||
* Extends SystemRemoteMessageException since 3.0
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
public class RemoteFileException extends SystemMessageException
|
||||
public class RemoteFileException extends SystemRemoteMessageException
|
||||
{
|
||||
/**
|
||||
* A serialVersionUID is recommended for all serializable classes.
|
||||
|
@ -41,7 +44,6 @@ public class RemoteFileException extends SystemMessageException
|
|||
* This should be updated if there is a schema change for this class.
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private Exception wrappedException = null;
|
||||
|
||||
/**
|
||||
* Constructor for RemoteFileException with an error message for getMessage() to return.
|
||||
|
@ -79,8 +81,7 @@ public class RemoteFileException extends SystemMessageException
|
|||
*/
|
||||
public RemoteFileException(String msg, Exception remoteException)
|
||||
{
|
||||
super(msg);
|
||||
wrappedException = remoteException;
|
||||
super(msg, remoteException);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -99,17 +100,8 @@ public class RemoteFileException extends SystemMessageException
|
|||
*/
|
||||
public RemoteFileException(SystemMessage msg, Exception remoteException)
|
||||
{
|
||||
super(msg);
|
||||
wrappedException = remoteException;
|
||||
super(msg, remoteException);
|
||||
}
|
||||
/**
|
||||
* @return the original remote exception
|
||||
*/
|
||||
public Exception getRemoteException()
|
||||
{
|
||||
return wrappedException;
|
||||
}
|
||||
|
||||
|
||||
private static String getString(ResourceBundle bundle, String key)
|
||||
{
|
||||
|
|
|
@ -7,13 +7,14 @@
|
|||
*
|
||||
* 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,
|
||||
* 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:
|
||||
* 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
|
||||
* Martin Oberhuber (Wind River) - [226374] [api] Need default SystemMessageException specialisations
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.rse.services.files;
|
||||
|
@ -27,9 +28,11 @@ import org.eclipse.rse.services.clientserver.messages.SimpleSystemMessage;
|
|||
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
|
||||
|
||||
/**
|
||||
* Exception thrown when attempting an operation and it fails for security reasons.
|
||||
* The original remote system's security message is always embedded and retrievable
|
||||
* via getRemoteException().
|
||||
* Exception thrown when attempting an operation and it fails for security
|
||||
* reasons. The original remote system's security message is always embedded and
|
||||
* retrievable via getRemoteException().
|
||||
*
|
||||
* @deprecated Use SystemRemoteSecurityException
|
||||
*/
|
||||
public class RemoteFileSecurityException extends RemoteFileException {
|
||||
|
||||
|
@ -42,7 +45,7 @@ public class RemoteFileSecurityException extends RemoteFileException {
|
|||
private static SystemMessage myMessage = null;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* Constructor
|
||||
* @param remoteException the original cause of this exception.
|
||||
*/
|
||||
public RemoteFileSecurityException(Exception remoteException) {
|
||||
|
@ -56,11 +59,11 @@ public class RemoteFileSecurityException extends RemoteFileException {
|
|||
if (secondLevel == null) {
|
||||
secondLevel = remoteException.getClass().getName();
|
||||
}
|
||||
|
||||
|
||||
String msgTxt = RSEServicesMessages.FILEMSG_SECURITY_VIOLATION;
|
||||
String msgDetails = NLS.bind(RSEServicesMessages.FILEMSG_SECURITY_VIOLATION_DETAILS, secondLevel);
|
||||
|
||||
myMessage = new SimpleSystemMessage(Activator.PLUGIN_ID,
|
||||
|
||||
myMessage = new SimpleSystemMessage(Activator.PLUGIN_ID,
|
||||
"RSEF1001", //$NON-NLS-1$
|
||||
IStatus.ERROR, msgTxt, msgDetails);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue