From 99ddeac22409c8fc15c4b1580e1dee779558b934 Mon Sep 17 00:00:00 2001 From: David McKnight Date: Mon, 25 Feb 2008 19:08:08 +0000 Subject: [PATCH] [216252] removing IService.getMessage --- .../internal/services/local/Activator.java | 4 +- .../services/local/LocalServiceResources.java | 25 ++++- .../local/LocalServiceResources.properties | 29 ++++- .../local/files/LocalFileService.java | 100 +++++++++++------- .../services/files/AbstractFileService.java | 11 +- 5 files changed, 118 insertions(+), 51 deletions(-) diff --git a/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/Activator.java b/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/Activator.java index 2478490b85c..f2828f6dff0 100644 --- a/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/Activator.java +++ b/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/Activator.java @@ -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] use SimpleSystemMessage instead of getMessage() *******************************************************************************/ package org.eclipse.rse.internal.services.local; @@ -31,6 +31,8 @@ public class Activator extends Plugin { //The shared instance. private static Activator plugin; + public static final String PLUGIN_ID = "org.eclipse.rse.services.local"; //$NON-NLS-1$ + /** * Returns the shared instance. */ diff --git a/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/LocalServiceResources.java b/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/LocalServiceResources.java index 791c61af5a8..1a1d3c6d6b4 100644 --- a/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/LocalServiceResources.java +++ b/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/LocalServiceResources.java @@ -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] use SimpleSystemMessage instead of getMessage() *******************************************************************************/ package org.eclipse.rse.internal.services.local; @@ -31,6 +31,29 @@ public class LocalServiceResources extends NLS public static String Local_Process_Service_Description; public static String Local_Shell_Service_Description; + public static String MSG_OPERATION_CANCELED; + + public static String FILEMSG_FILE_NOT_SAVED; + public static String FILEMSG_FILE_NOT_SAVED_DETAILS; + + public static String FILEMSG_ARCHIVE_CORRUPTED; + public static String FILEMSG_ARCHIVE_CORRUPTED_DETAILS; + + public static String FILEMSG_CREATE_VIRTUAL_FAILED; + public static String FILEMSG_CREATE_VIRTUAL_FAILED_DETAILS; + + public static String FILEMSG_DELETE_VIRTUAL_FAILED; + public static String FILEMSG_DELETE_VIRTUAL_FAILED_DETAILS; + + public static String FILEMSG_RENAME_FILE_FAILED; + public static String FILEMSG_RENAME_FILE_FAILED_DETAILS; + + public static String FILEMSG_COPY_FILE_FAILED; + public static String FILEMSG_COPY_FILE_FAILED_DETAILS; + + public static String FILEMSG_DELETING; + public static String FILEMSG_COPYING; + static { // load message values from bundle file NLS.initializeMessages(BUNDLE_NAME, LocalServiceResources.class); diff --git a/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/LocalServiceResources.properties b/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/LocalServiceResources.properties index 07dafb47de6..0bfdab95e15 100644 --- a/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/LocalServiceResources.properties +++ b/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/LocalServiceResources.properties @@ -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] use SimpleSystemMessage instead of getMessage() ############################################################################### # NLS_MESSAGEFORMAT_VAR @@ -25,3 +25,30 @@ Local_Shell_Service_Name=Local Shell Service Local_File_Service_Description=The Local File Service uses Java API to provide service to the Files subsystem on the local machine. Local_Process_Service_Description=The Local File Service uses Java API to provide service to the Processes subsystem on the local machine. Local_Shell_Service_Description=The Local File Service uses Java API to provide service to the Shells subsystem on the local machine. + + +MSG_OPERATION_CANCELED=Operation canceled. + +FILEMSG_FILE_NOT_SAVED= File {0} was not completely saved on {1}. The file was saved in the local file system. +FILEMSG_FILE_NOT_SAVED_DETAILS=An error occurred while saving the file on the server. A possible cause is the connection to the server was terminated. The file may only have been saved partially on the server. However, it was saved locally to help you recover. You will be asked to save the local copy to the server the next time you connect. + +FILEMSG_ARCHIVE_CORRUPTED=The archive is corrupted or unreadable. +FILEMSG_ARCHIVE_CORRUPTED_DETAILS=The archive cannot be opened because its format is unrecognized, or its contents are damaged in some way. + +FILEMSG_CREATE_VIRTUAL_FAILED = Creation of the virtual file or folder {0} failed. +FILEMSG_CREATE_VIRTUAL_FAILED_DETAILS = There was an error creating the virtual file or folder. The virtual file or folder was not created. + +FILEMSG_DELETE_VIRTUAL_FAILED = Deletion of the virtual file or folder {0} failed. +FILEMSG_DELETE_VIRTUAL_FAILED_DETAILS=There was an error deleting the virtual file or folder. The virtual file or folder was not deleted. + +FILEMSG_RENAME_FILE_FAILED=Renaming of the object {0} failed +FILEMSG_RENAME_FILE_FAILED_DETAILS=Rename operation failed because, the object to rename does not exist, or the object with new object name already exists, or the user does not have enough authority to rename the object + +FILEMSG_COPY_FILE_FAILED=Copy of the file or folder {0} failed +FILEMSG_COPY_FILE_FAILED_DETAILS=The file system reported the copy operation failed. You may not have authority to the target folder, or it may be in use + + +FILEMSG_DELETING =Deleting {0}... +FILEMSG_COPYING =Copying {0}... + + diff --git a/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/files/LocalFileService.java b/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/files/LocalFileService.java index 5dda28f55f5..5eb575ef48b 100644 --- a/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/files/LocalFileService.java +++ b/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/files/LocalFileService.java @@ -32,6 +32,7 @@ * David McKnight (IBM) - [209593] [api] add support for "file permissions" and "owner" properties for unix files * Radoslav Gerganov (ProSyst) - [218173] [local] non-generic filters don't work * Martin Oberhuber (Wind River) - [188330] Problems Copying files with $ in name + * David McKnight (IBM) - [216252] use SimpleSystemMessage instead of getMessage() *******************************************************************************/ package org.eclipse.rse.internal.services.local.files; @@ -56,6 +57,9 @@ import java.util.List; import java.util.StringTokenizer; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.osgi.util.NLS; +import org.eclipse.rse.internal.services.local.Activator; import org.eclipse.rse.internal.services.local.ILocalService; import org.eclipse.rse.internal.services.local.LocalServiceResources; import org.eclipse.rse.services.clientserver.FileTypeMatcher; @@ -71,6 +75,7 @@ import org.eclipse.rse.services.clientserver.archiveutils.ArchiveHandlerManager; import org.eclipse.rse.services.clientserver.archiveutils.ISystemArchiveHandler; import org.eclipse.rse.services.clientserver.archiveutils.VirtualChild; import org.eclipse.rse.services.clientserver.messages.ISystemMessageProvider; +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.services.files.AbstractFileService; @@ -543,11 +548,12 @@ public class LocalFileService extends AbstractFileService implements IFileServic if (null != monitor && monitor.isCanceled()) { //This operation has been canceled by the user. - throw new SystemMessageException(getMessage("RSEG1067")); //$NON-NLS-1$ + throw new SystemMessageException(new SimpleSystemMessage(Activator.PLUGIN_ID, IStatus.CANCEL, LocalServiceResources.MSG_OPERATION_CANCELED)); } // SystemPlugin.logError("LocalFileSubSystemImpl.copyToArchive(): Handler's add() method returned false."); - SystemMessage msg = getMessage("RSEF5006"); //$NON-NLS-1$ - msg.makeSubstitution(destination.getName(), "localhost"); //$NON-NLS-1$ + String msgTxt = NLS.bind(LocalServiceResources.FILEMSG_FILE_NOT_SAVED, destination.getName(), "localhost"); + String msgDetails = LocalServiceResources.FILEMSG_FILE_NOT_SAVED_DETAILS; + SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, IStatus.ERROR, msgTxt, msgDetails); throw new SystemMessageException(msg); } else @@ -895,8 +901,9 @@ public class LocalFileService extends AbstractFileService implements IFileServic { if (!ArchiveHandlerManager.getInstance().createEmptyArchive(fileToCreate)) { - // SystemPlugin.logError("LocalFileSubSystemImpl.createFile(): HandlerManager's createEmptyArchive() method returned false."); - throw new SystemMessageException(getMessage("RSEG1122")); //$NON-NLS-1$ + SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, IStatus.ERROR, + LocalServiceResources.FILEMSG_ARCHIVE_CORRUPTED, LocalServiceResources.FILEMSG_ARCHIVE_CORRUPTED_DETAILS); + throw new SystemMessageException(msg); } } } @@ -935,10 +942,12 @@ public class LocalFileService extends AbstractFileService implements IFileServic if (null != monitor && monitor.isCanceled()) { //This operation has been canceled by the user. - throw new SystemMessageException(getMessage("RSEG1067")); //$NON-NLS-1$ + throw new SystemMessageException(new SimpleSystemMessage(Activator.PLUGIN_ID, IStatus.CANCEL, LocalServiceResources.MSG_OPERATION_CANCELED)); } - SystemMessage msg = getMessage("RSEG1124"); //$NON-NLS-1$ - msg.makeSubstitution(newFile); + + String msgTxt = NLS.bind(LocalServiceResources.FILEMSG_CREATE_VIRTUAL_FAILED, newFile); + String msgDetails = LocalServiceResources.FILEMSG_CREATE_VIRTUAL_FAILED_DETAILS; + SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, IStatus.ERROR, msgTxt, msgDetails); throw new SystemMessageException(msg); } } @@ -947,8 +956,9 @@ public class LocalFileService extends AbstractFileService implements IFileServic private void throwCorruptArchiveException(String classAndMethod) throws SystemMessageException { - // SystemPlugin.logError(classAndMethod + ": Couldn't instantiate archive handler. Archive could be corrupted."); - throw new SystemMessageException(getMessage("RSEG1122")); //$NON-NLS-1$ + SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, IStatus.ERROR, + LocalServiceResources.FILEMSG_ARCHIVE_CORRUPTED, LocalServiceResources.FILEMSG_ARCHIVE_CORRUPTED_DETAILS); + throw new SystemMessageException(msg); } protected File getContainingArchive(File file) @@ -1008,10 +1018,12 @@ public class LocalFileService extends AbstractFileService implements IFileServic if (null != monitor && monitor.isCanceled()) { //This operation has been canceled by the user. - throw new SystemMessageException(getMessage("RSEG1067")); //$NON-NLS-1$ + throw new SystemMessageException(new SimpleSystemMessage(Activator.PLUGIN_ID, IStatus.CANCEL, LocalServiceResources.MSG_OPERATION_CANCELED)); } - SystemMessage msg = getMessage("RSEG1124"); //$NON-NLS-1$ - msg.makeSubstitution(newFolder); + + String msgTxt = NLS.bind(LocalServiceResources.FILEMSG_CREATE_VIRTUAL_FAILED, newFolder); + String msgDetails = LocalServiceResources.FILEMSG_CREATE_VIRTUAL_FAILED_DETAILS; + SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, IStatus.ERROR, msgTxt, msgDetails); throw new SystemMessageException(msg); } } @@ -1051,12 +1063,12 @@ public class LocalFileService extends AbstractFileService implements IFileServic public boolean deleteBatch(String[] remoteParents, String[] fileNames, IProgressMonitor monitor) throws SystemMessageException { boolean ok = true; - SystemMessage msg = getMessage("RSEF1315"); //$NON-NLS-1$ - String deletingMessage = msg.makeSubstitution("").getLevelOneText(); //$NON-NLS-1$ + String deletingMessage = NLS.bind(LocalServiceResources.FILEMSG_DELETING, ""); monitor.beginTask(deletingMessage, remoteParents.length); for (int i = 0; i < remoteParents.length; i++) { - monitor.subTask(msg.makeSubstitution(fileNames[i]).getLevelOneText()); + deletingMessage = NLS.bind(LocalServiceResources.FILEMSG_DELETING, fileNames[i]); + monitor.subTask(deletingMessage); ok = ok && delete(remoteParents[i], fileNames[i], monitor); monitor.worked(1); } @@ -1110,10 +1122,12 @@ public class LocalFileService extends AbstractFileService implements IFileServic if (monitor != null && monitor.isCanceled()) { //This operation has been canceled by the user. - throw new SystemMessageException(getMessage("RSEG1067")); //$NON-NLS-1$ + throw new SystemMessageException(new SimpleSystemMessage(Activator.PLUGIN_ID, IStatus.CANCEL, LocalServiceResources.MSG_OPERATION_CANCELED)); } // SystemPlugin.logError("LocalFileSubSystemImpl.deleteFromArchive(): Archive Handler's delete method returned false. Couldn't delete virtual object."); - throw new SystemMessageException(getMessage("RSEG1125").makeSubstitution(destination)); //$NON-NLS-1$ + String msgTxt = NLS.bind(LocalServiceResources.FILEMSG_DELETE_VIRTUAL_FAILED, destination); + String msgDetails = LocalServiceResources.FILEMSG_DELETE_VIRTUAL_FAILED_DETAILS; + throw new SystemMessageException(new SimpleSystemMessage(Activator.PLUGIN_ID, IStatus.ERROR, msgTxt, msgDetails)); } return true; } @@ -1136,7 +1150,9 @@ public class LocalFileService extends AbstractFileService implements IFileServic if (!result) { // for 192705, we need to throw an exception when rename fails - throw new SystemMessageException(getMessage("RSEF1301").makeSubstitution(newFile)); //$NON-NLS-1$ + String msgTxt = NLS.bind(LocalServiceResources.FILEMSG_RENAME_FILE_FAILED, newFile); + String msgDetails = LocalServiceResources.FILEMSG_RENAME_FILE_FAILED_DETAILS; + throw new SystemMessageException(new SimpleSystemMessage(Activator.PLUGIN_ID, IStatus.ERROR, msgTxt, msgDetails)); } return result; } @@ -1180,11 +1196,13 @@ public class LocalFileService extends AbstractFileService implements IFileServic if (null != monitor && monitor.isCanceled()) { //This operation has been canceled by the user. - throw new SystemMessageException(getMessage("RSEG1067")); //$NON-NLS-1$ + throw new SystemMessageException(new SimpleSystemMessage(Activator.PLUGIN_ID, IStatus.CANCEL, LocalServiceResources.MSG_OPERATION_CANCELED)); } - // SystemPlugin.logError("LocalFileSubSystemImpl.renameVirtualFile(): Archive Handler's rename method returned false. Couldn't rename virtual object."); - //SystemMessageDialog.displayErrorMessage(shell, RSEUIPlugin.getPluginMessage(ISystemMessages.FILEMSG_RENAME_FILE_FAILED).makeSubstitution(file.toString())); - throw new SystemMessageException(getMessage("RSEF1301").makeSubstitution(child.fullName)); //$NON-NLS-1$ + + // for 192705, we need to throw an exception when rename fails + String msgTxt = NLS.bind(LocalServiceResources.FILEMSG_RENAME_FILE_FAILED, child.fullName); + String msgDetails = LocalServiceResources.FILEMSG_RENAME_FILE_FAILED_DETAILS; + throw new SystemMessageException(new SimpleSystemMessage(Activator.PLUGIN_ID, IStatus.ERROR, msgTxt, msgDetails)); } return retval; } @@ -1395,11 +1413,13 @@ public class LocalFileService extends AbstractFileService implements IFileServic if (monitor != null && monitor.isCanceled()) { //This operation has been canceled by the user. - throw new SystemMessageException(getMessage("RSEG1067")); //$NON-NLS-1$ + throw new SystemMessageException(new SimpleSystemMessage(Activator.PLUGIN_ID, IStatus.CANCEL, LocalServiceResources.MSG_OPERATION_CANCELED)); } - // SystemPlugin.logError("LocalFileSubSystemImpl.renameVirtualFile(): Archive Handler's rename method returned false. Couldn't rename virtual object."); - //SystemMessageDialog.displayErrorMessage(shell, RSEUIPlugin.getPluginMessage(ISystemMessages.FILEMSG_RENAME_FILE_FAILED).makeSubstitution(file.toString())); - throw new SystemMessageException(getMessage("RSEF1301").makeSubstitution(child.fullName)); //$NON-NLS-1$ + + // for 192705, we need to throw an exception when rename fails + String msgTxt = NLS.bind(LocalServiceResources.FILEMSG_RENAME_FILE_FAILED, child.fullName); + String msgDetails = LocalServiceResources.FILEMSG_RENAME_FILE_FAILED_DETAILS; + throw new SystemMessageException(new SimpleSystemMessage(Activator.PLUGIN_ID, IStatus.ERROR, msgTxt, msgDetails)); } return returnValue; } @@ -1413,7 +1433,7 @@ public class LocalFileService extends AbstractFileService implements IFileServic if (monitor != null && monitor.isCanceled()) { //This operation has been canceled by the user. - throw new SystemMessageException(getMessage("RSEG1067")); //$NON-NLS-1$ + throw new SystemMessageException(new SimpleSystemMessage(Activator.PLUGIN_ID, IStatus.CANCEL, LocalServiceResources.MSG_OPERATION_CANCELED)); } if (child.isDirectory) { @@ -1425,14 +1445,19 @@ public class LocalFileService extends AbstractFileService implements IFileServic } catch (IOException e) { - // SystemPlugin.logError("LocalFileSubSystemImpl.copy(): Could not create temp file.", e); - throw new SystemMessageException(getMessage("Copy failed")); //$NON-NLS-1$ + String msgTxt = NLS.bind(LocalServiceResources.FILEMSG_COPY_FILE_FAILED, sourceFolderOrFile); + String msgDetails = LocalServiceResources.FILEMSG_COPY_FILE_FAILED_DETAILS; + + throw new SystemMessageException(new SimpleSystemMessage(Activator.PLUGIN_ID, IStatus.ERROR, msgTxt, msgDetails)); } tempSource.delete(); if (!tempSource.mkdir()) { + String msgTxt = NLS.bind(LocalServiceResources.FILEMSG_COPY_FILE_FAILED, sourceFolderOrFile); + String msgDetails = LocalServiceResources.FILEMSG_COPY_FILE_FAILED_DETAILS; + // SystemPlugin.logError("LocalFileSubSystemImpl.copy(): Couldn't create temp dir."); - throw new SystemMessageException(getMessage("RSEG1306").makeSubstitution(sourceFolderOrFile)); //$NON-NLS-1$ + throw new SystemMessageException(new SimpleSystemMessage(Activator.PLUGIN_ID, IStatus.ERROR, msgTxt, msgDetails)); } ISystemArchiveHandler handler = child.getHandler(); if (handler == null) @@ -1450,7 +1475,7 @@ public class LocalFileService extends AbstractFileService implements IFileServic if (monitor != null && monitor.isCanceled()) { //This operation has been canceled by the user. - throw new SystemMessageException(getMessage("RSEG1067")); //$NON-NLS-1$ + throw new SystemMessageException(new SimpleSystemMessage(Activator.PLUGIN_ID, IStatus.CANCEL, LocalServiceResources.MSG_OPERATION_CANCELED)); } } return returnValue; @@ -1513,12 +1538,12 @@ public class LocalFileService extends AbstractFileService implements IFileServic public boolean copyBatch(String[] srcParents, String[] srcNames, String tgtParent, IProgressMonitor monitor) throws SystemMessageException { boolean ok = true; - SystemMessage msg = getMessage("RSEG1117"); //$NON-NLS-1$ - String deletingMessage = msg.makeSubstitution("").getLevelOneText(); //$NON-NLS-1$ + String deletingMessage = NLS.bind(LocalServiceResources.FILEMSG_COPYING, ""); monitor.beginTask(deletingMessage, srcParents.length); for (int i = 0; i < srcParents.length; i++) { - monitor.subTask(msg.makeSubstitution(srcNames[i]).getLevelOneText()); + deletingMessage = NLS.bind(LocalServiceResources.FILEMSG_COPYING, srcNames[i]); + monitor.subTask(deletingMessage); ok = ok && copy(srcParents[i], srcNames[i], tgtParent, srcNames[i], monitor); monitor.worked(1); } @@ -1637,10 +1662,7 @@ public class LocalFileService extends AbstractFileService implements IFileServic return stream; } - - public SystemMessage getMessage(String messageID) { - return (_msgProvider != null ? _msgProvider.getMessage(messageID) : super.getMessage(messageID)); - } + public int getCapabilities(IHostFile file) { int capabilities = 0; diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/AbstractFileService.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/AbstractFileService.java index c3e8b451b7e..52e652bd5dd 100644 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/AbstractFileService.java +++ b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/AbstractFileService.java @@ -23,6 +23,7 @@ * Xuan Chen (IBM) - [210555] [regression] NPE when deleting a file on SSH * Kevin Doyle (IBM) - [208778] [efs][api] RSEFileStore#getOutputStream() does not support EFS#APPEND * David McKnight (IBM) - [209704] added supportsEncodingConversion() + * David McKnight (IBM) - [216252] use SimpleSystemMessage instead of getMessage() *******************************************************************************/ package org.eclipse.rse.services.files; @@ -35,7 +36,6 @@ import java.util.List; import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.rse.services.clientserver.messages.SystemMessage; import org.eclipse.rse.services.clientserver.messages.SystemMessageException; @@ -123,14 +123,7 @@ public abstract class AbstractFileService implements IFileService return true; } } - - /** - * Dummy impl for now - */ - public SystemMessage getMessage(String messageID) - { - return null; - } + public boolean deleteBatch(String[] remoteParents, String[] fileNames, IProgressMonitor monitor) throws SystemMessageException {