diff --git a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/resources/SystemEditableRemoteFile.java b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/resources/SystemEditableRemoteFile.java index b1aa9777e1d..612bea53e96 100644 --- a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/resources/SystemEditableRemoteFile.java +++ b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/resources/SystemEditableRemoteFile.java @@ -13,6 +13,7 @@ * Contributors: * Martin Oberhuber (Wind River) - [175262] IHost.getSystemType() should return IRSESystemType * Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods + * Martin Oberhuber (Wind River) - [183824] Forward SystemMessageException from IRemoteFileSubsystem ********************************************************************************/ package org.eclipse.rse.files.ui.resources; @@ -599,7 +600,14 @@ public class SystemEditableRemoteFile implements ISystemEditableRemoteObject, IP return false; } - subsystem.download(remoteFile, localPath, remoteFile.getEncoding(), monitor); + try + { + subsystem.download(remoteFile, localPath, remoteFile.getEncoding(), monitor); + } + catch (SystemMessageException e) + { + SystemMessageDialog.displayMessage(e); + } if (monitor.isCanceled()) { return false; diff --git a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/resources/UniversalFileTransferUtility.java b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/resources/UniversalFileTransferUtility.java index 778b0f8ba6b..0e99a1c59be 100644 --- a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/resources/UniversalFileTransferUtility.java +++ b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/resources/UniversalFileTransferUtility.java @@ -16,6 +16,7 @@ * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core * Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API + * Martin Oberhuber (Wind River) - [183824] Forward SystemMessageException from IRemoteFileSubsystem ********************************************************************************/ package org.eclipse.rse.files.ui.resources; @@ -217,7 +218,7 @@ public class UniversalFileTransferUtility } } } - catch (final RemoteFileIOException e) + catch (final SystemMessageException e) { runInDisplayThread(new Runnable() { public void run() { @@ -1162,6 +1163,10 @@ public class UniversalFileTransferUtility newFilePathList.add(newPath); } } + catch (SystemMessageException e) + { + SystemMessageDialog.displayMessage(e); + } catch (CoreException e) { e.printStackTrace(); @@ -1378,6 +1383,10 @@ public class UniversalFileTransferUtility return newTargetFolder; } + catch (SystemMessageException e) + { + SystemMessageDialog.displayMessage(e); + } catch (CoreException e) { e.printStackTrace(); @@ -1456,15 +1465,19 @@ public class UniversalFileTransferUtility monitor.done(); } + catch (SystemMessageException e) + { + SystemMessageDialog.displayMessage(e); + } catch (Exception e) { e.printStackTrace(); - if (newPath == null) cleanup(destinationArchive, null); - else cleanup(destinationArchive, new File(newPath)); throw e; } - if (newPath == null) cleanup(destinationArchive, null); - else cleanup(destinationArchive, new File(newPath)); + finally { + if (newPath == null) cleanup(destinationArchive, null); + else cleanup(destinationArchive, new File(newPath)); + } } protected static void setReadOnly(IFile file, boolean flag) @@ -1698,6 +1711,11 @@ public class UniversalFileTransferUtility } } } + catch (SystemMessageException e) + { + SystemMessageDialog.displayMessage(e); + cleanup(cpdest, dest); + } catch (Exception e) { e.printStackTrace(); @@ -1718,6 +1736,10 @@ public class UniversalFileTransferUtility { arc1.getParentRemoteFileSubSystem().delete(arc1, null); } + catch (SystemMessageException e) + { + SystemMessageDialog.displayMessage(e); + } catch (Exception e) { e.printStackTrace(); diff --git a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/actions/SystemCombineAction.java b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/actions/SystemCombineAction.java index 049b62878c1..944b693a7a8 100644 --- a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/actions/SystemCombineAction.java +++ b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/actions/SystemCombineAction.java @@ -13,6 +13,7 @@ * Contributors: * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core * Martin Oberhuber (Wind River) - [184095] Replace systemTypeName by IRSESystemType + * Martin Oberhuber (Wind River) - [183824] Forward SystemMessageException from IRemoteFileSubsystem ********************************************************************************/ package org.eclipse.rse.internal.files.ui.actions; @@ -113,7 +114,7 @@ public class SystemCombineAction extends SystemExtractToAction { } catch (SystemMessageException e) { - System.out.println(e.getMessage()); + SystemMessageDialog.displayMessage(e); } IProgressMonitor monitor = new NullProgressMonitor(); for (int i = 0; i < _selected.size(); i++) diff --git a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/actions/SystemExtractAction.java b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/actions/SystemExtractAction.java index e9e534cad82..a7a19c9511d 100644 --- a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/actions/SystemExtractAction.java +++ b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/actions/SystemExtractAction.java @@ -12,6 +12,7 @@ * * Contributors: * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core + * Martin Oberhuber (Wind River) - [183824] Forward SystemMessageException from IRemoteFileSubsystem ********************************************************************************/ package org.eclipse.rse.internal.files.ui.actions; @@ -169,8 +170,8 @@ public class SystemExtractAction extends SystemBaseAction SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_OPERATION_FAILED); SystemMessageDialog dlg = new SystemMessageDialog(getShell(), msg); dlg.open(); - System.out.println(e.getMessage()); - System.out.println("Could not extract " + sources[j].getAbsolutePath()); //$NON-NLS-1$ + //System.out.println(e.getMessage()); + //System.out.println("Could not extract " + sources[j].getAbsolutePath()); //$NON-NLS-1$ } } } diff --git a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/actions/SystemUploadConflictAction.java b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/actions/SystemUploadConflictAction.java index cbfb16fece0..33d8acb2e36 100644 --- a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/actions/SystemUploadConflictAction.java +++ b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/actions/SystemUploadConflictAction.java @@ -12,6 +12,7 @@ * * Contributors: * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core + * Martin Oberhuber (Wind River) - [183824] Forward SystemMessageException from IRemoteFileSubsystem ********************************************************************************/ package org.eclipse.rse.internal.files.ui.actions; @@ -147,13 +148,13 @@ public class SystemUploadConflictAction extends SystemBaseAction implements Runn properties.setDirty(false); properties.setUsedBinaryTransfer(_remoteFile.isBinary()); } - catch (RemoteFileSecurityException e) + catch (final SystemMessageException e) { - e.printStackTrace(); - } - catch (RemoteFileIOException e) - { - e.printStackTrace(); + Display.getDefault().asyncExec(new Runnable() { + public void run() { + SystemMessageDialog.displayMessage(e); + } + }); } catch (Exception e) { diff --git a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/propertypages/SystemFilePropertyPage.java b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/propertypages/SystemFilePropertyPage.java index 7c2e893410e..17776aff5b4 100644 --- a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/propertypages/SystemFilePropertyPage.java +++ b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/propertypages/SystemFilePropertyPage.java @@ -13,6 +13,7 @@ * Contributors: * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API + * Martin Oberhuber (Wind River) - [183824] Forward SystemMessageException from IRemoteFileSubsystem ********************************************************************************/ package org.eclipse.rse.internal.files.ui.propertypages; @@ -26,6 +27,7 @@ import java.util.List; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.rse.core.events.ISystemResourceChangeEvents; import org.eclipse.rse.internal.subsystems.files.core.SystemFileResources; +import org.eclipse.rse.services.clientserver.messages.SystemMessageException; import org.eclipse.rse.services.files.RemoteFileIOException; import org.eclipse.rse.services.files.RemoteFileSecurityException; import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; @@ -462,6 +464,9 @@ public class SystemFilePropertyPage extends SystemBasePropertyPage catch (RemoteFileSecurityException exc) { setMessage(RSEUIPlugin.getPluginMessage(ISystemMessages.FILEMSG_SECURITY_ERROR)); } + catch (SystemMessageException e) { + setMessage(e.getSystemMessage()); + } } // set the encoding diff --git a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/view/SystemViewRemoteFileAdapter.java b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/view/SystemViewRemoteFileAdapter.java index 9bf539335da..2b7f7de7900 100644 --- a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/view/SystemViewRemoteFileAdapter.java +++ b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/view/SystemViewRemoteFileAdapter.java @@ -16,6 +16,7 @@ * Martin Oberhuber (Wind River) - [182454] improve getAbsoluteName() documentation * Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API + * Martin Oberhuber (Wind River) - [183824] Forward SystemMessageException from IRemoteFileSubsystem ********************************************************************************/ package org.eclipse.rse.internal.files.ui.view; @@ -96,8 +97,6 @@ import org.eclipse.rse.services.clientserver.SystemSearchString; import org.eclipse.rse.services.clientserver.archiveutils.ArchiveHandlerManager; import org.eclipse.rse.services.clientserver.messages.SystemMessage; import org.eclipse.rse.services.clientserver.messages.SystemMessageException; -import org.eclipse.rse.services.files.RemoteFileIOException; -import org.eclipse.rse.services.files.RemoteFileSecurityException; import org.eclipse.rse.services.search.HostSearchResultSet; import org.eclipse.rse.services.search.IHostSearchConstants; import org.eclipse.rse.services.search.IHostSearchResultConfiguration; @@ -1957,6 +1956,10 @@ public class SystemViewRemoteFileAdapter resultSet.setMessage(msg); } } + catch (SystemMessageException e) + { + SystemMessageDialog.displayMessage(e); + } catch (Exception e) { e.printStackTrace(); @@ -1982,6 +1985,10 @@ public class SystemViewRemoteFileAdapter } } } + catch (SystemMessageException e) + { + SystemMessageDialog.displayMessage(e); + } catch (Exception e) { e.printStackTrace(); @@ -2214,15 +2221,11 @@ public class SystemViewRemoteFileAdapter return result; } - catch (RemoteFileIOException e) + catch (SystemMessageException e) { return e.getSystemMessage(); } - catch (RemoteFileSecurityException e) - { - return e.getSystemMessage(); - } catch (Exception e) { } diff --git a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/importexport/files/RemoteExporter.java b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/importexport/files/RemoteExporter.java index 6f2cdc59d59..53a6dd5fa9f 100644 --- a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/importexport/files/RemoteExporter.java +++ b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/importexport/files/RemoteExporter.java @@ -1,5 +1,3 @@ -package org.eclipse.rse.internal.importexport.files; - /******************************************************************************* * Copyright (c) 2000, 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials @@ -9,7 +7,10 @@ package org.eclipse.rse.internal.importexport.files; * * Contributors: * IBM Corporation - initial API and implementation + * Martin Oberhuber (Wind River) - [183824] Forward SystemMessageException from IRemoteFileSubsystem *******************************************************************************/ +package org.eclipse.rse.internal.importexport.files; + import java.io.File; import java.io.IOException; @@ -20,8 +21,7 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.rse.core.model.IHost; import org.eclipse.rse.services.clientserver.SystemEncodingUtil; -import org.eclipse.rse.services.files.RemoteFileException; -import org.eclipse.rse.services.files.RemoteFileSecurityException; +import org.eclipse.rse.services.clientserver.messages.SystemMessageException; import org.eclipse.rse.subsystems.files.core.model.RemoteFileUtility; import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem; @@ -61,8 +61,9 @@ class RemoteExporter { /** * Writes the passed resource to the specified location recursively + * @throws SystemMessageException TODO */ - public void write(IResource resource, IPath destinationPath) throws IOException, CoreException, RemoteFileSecurityException, RemoteFileException { + public void write(IResource resource, IPath destinationPath) throws IOException, CoreException, SystemMessageException { if (resource.getType() == IResource.FILE) writeFile((IFile) resource, destinationPath); else @@ -71,8 +72,9 @@ class RemoteExporter { /** * Exports the passed container's children + * @throws SystemMessageException TODO */ - protected void writeChildren(IContainer folder, IPath destinationPath) throws IOException, CoreException, RemoteFileSecurityException, RemoteFileException { + protected void writeChildren(IContainer folder, IPath destinationPath) throws IOException, CoreException, SystemMessageException { if (folder.isAccessible()) { IResource[] children = folder.members(); for (int i = 0; i < children.length; i++) { @@ -85,8 +87,9 @@ class RemoteExporter { /** * Writes the passed file resource to the specified destination on the remote * file system + * @throws SystemMessageException TODO */ - protected void writeFile(IFile file, IPath destinationPath) throws IOException, CoreException, RemoteFileSecurityException, RemoteFileException { + protected void writeFile(IFile file, IPath destinationPath) throws IOException, CoreException, SystemMessageException { IRemoteFileSubSystem rfss = RemoteFileUtility.getFileSubSystem((IHost) _host); String dest = destinationPath.toString(); char sep = rfss.getSeparatorChar(); @@ -100,8 +103,9 @@ class RemoteExporter { /** * Writes the passed resource to the specified location recursively + * @throws SystemMessageException TODO */ - protected void writeResource(IResource resource, IPath destinationPath) throws IOException, CoreException, RemoteFileSecurityException, RemoteFileException { + protected void writeResource(IResource resource, IPath destinationPath) throws IOException, CoreException, SystemMessageException { if (resource.getType() == IResource.FILE) writeFile((IFile) resource, destinationPath); else { diff --git a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/importexport/files/UniFilePlus.java b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/importexport/files/UniFilePlus.java index be864c105a9..5b0892369d5 100644 --- a/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/importexport/files/UniFilePlus.java +++ b/rse/plugins/org.eclipse.rse.importexport/src/org/eclipse/rse/internal/importexport/files/UniFilePlus.java @@ -8,6 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API + * Martin Oberhuber (Wind River) - [183824] Forward SystemMessageException from IRemoteFileSubsystem *******************************************************************************/ package org.eclipse.rse.internal.importexport.files; @@ -78,6 +79,8 @@ public class UniFilePlus extends File { throw new SecurityException(exc.getMessage()); else throw new IOException(exc.getMessage()); + } catch (SystemMessageException e) { + throw new IOException(e.getMessage()); } if (newFile != null) { remoteFile = newFile; @@ -95,6 +98,10 @@ public class UniFilePlus extends File { Exception e = exc.getRemoteException(); if ((e != null) && (e instanceof SecurityException)) throw (SecurityException) e; throw new SecurityException(exc.getMessage()); + } catch (SystemMessageException e) { + //TODO should there be more user feedback? + SystemBasePlugin.logMessage(e.getSystemMessage()); + ok = false; } return ok; } @@ -286,6 +293,9 @@ public class UniFilePlus extends File { Exception e = exc.getRemoteException(); if ((e != null) && (e instanceof SecurityException)) throw (SecurityException) e; throw new SecurityException(exc.getMessage()); + } catch (SystemMessageException e) { + //TODO should there be more user feedback? + SystemBasePlugin.logMessage(e.getSystemMessage()); } if (dir != null) remoteFile = dir; return (dir != null); @@ -299,6 +309,9 @@ public class UniFilePlus extends File { Exception e = exc.getRemoteException(); if ((e != null) && (e instanceof SecurityException)) throw (SecurityException) e; throw new SecurityException(exc.getMessage()); + } catch (SystemMessageException e) { + //TODO should there be more user feedback? + SystemBasePlugin.logMessage(e.getSystemMessage()); } if (dir != null) remoteFile = dir; return (dir != null); @@ -312,6 +325,9 @@ public class UniFilePlus extends File { Exception e = exc.getRemoteException(); if ((e != null) && (e instanceof SecurityException)) throw (SecurityException) e; throw new SecurityException(exc.getMessage()); + } catch (SystemMessageException e) { + //TODO should there be more user feedback? + SystemBasePlugin.logMessage(e.getSystemMessage()); } return ok; } @@ -326,6 +342,9 @@ public class UniFilePlus extends File { Exception e = exc.getRemoteException(); if ((e != null) && (e instanceof SecurityException)) throw (SecurityException) e; throw new SecurityException(exc.getMessage()); + } catch (SystemMessageException e) { + //TODO should there be more user feedback? + SystemBasePlugin.logMessage(e.getSystemMessage()); } return ok; } @@ -338,6 +357,9 @@ public class UniFilePlus extends File { Exception e = exc.getRemoteException(); if ((e != null) && (e instanceof SecurityException)) throw (SecurityException) e; throw new SecurityException(exc.getMessage()); + } catch (SystemMessageException e) { + //TODO should there be more user feedback? + SystemBasePlugin.logMessage(e.getSystemMessage()); } return ok; } diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/IFileService.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/IFileService.java index dea9219b0ec..c97b6784a95 100644 --- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/IFileService.java +++ b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/IFileService.java @@ -12,6 +12,7 @@ * * Contributors: * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API + * Martin Oberhuber (Wind River) - [183824] Forward SystemMessageException from IRemoteFileSubsystem ********************************************************************************/ package org.eclipse.rse.services.files; @@ -25,7 +26,6 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.rse.services.IService; import org.eclipse.rse.services.clientserver.messages.SystemMessageException; - /** * A IFileService is an abstraction of a file service that runs over some sort of connection. * It can be shared among multiple instances of a subsystem. At some point this file @@ -69,7 +69,8 @@ public interface IFileService extends IService * @param monitor the monitor for this potentially long running operation * @return true if the file was uploaded * @throws SystemMessageException if an error occurs. - * Typically this would be one of those in the RemoteFileException family. + * Typically this would be one of those in the + * {@link RemoteFileException} family. */ public boolean upload(File localFile, String remoteParent, String remoteFile, boolean isBinary, String srcEncoding, String hostEncoding, IProgressMonitor monitor) throws SystemMessageException; @@ -84,7 +85,8 @@ public interface IFileService extends IService * @param monitor the monitor for this potentially long running operation * @return true if the file was copied from the remote system. * @throws SystemMessageException if an error occurs. - * Typically this would be one of those in the RemoteFileException family. + * Typically this would be one of those in the + * {@link RemoteFileException} family. */ public boolean download(String remoteParent, String remoteFile, File localFile, boolean isBinary, String hostEncoding, IProgressMonitor monitor) throws SystemMessageException; diff --git a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/servicesubsystem/FileServiceSubSystem.java b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/servicesubsystem/FileServiceSubSystem.java index 3437ad39403..d00cfda85f8 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/servicesubsystem/FileServiceSubSystem.java +++ b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/servicesubsystem/FileServiceSubSystem.java @@ -17,6 +17,7 @@ * Martin Oberhuber (Wind River) - [168596] FileServiceSubSystem.isCaseSensitive() * Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API + * Martin Oberhuber (Wind River) - [183824] Forward SystemMessageException from IRemoteFileSubsystem *******************************************************************************/ package org.eclipse.rse.subsystems.files.core.servicesubsystem; @@ -27,6 +28,7 @@ import java.io.OutputStream; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.rse.core.SystemBasePlugin; import org.eclipse.rse.core.model.IHost; import org.eclipse.rse.core.subsystems.IConnectorService; import org.eclipse.rse.core.subsystems.IServiceSubSystemConfiguration; @@ -40,9 +42,6 @@ import org.eclipse.rse.services.clientserver.messages.SystemMessage; import org.eclipse.rse.services.clientserver.messages.SystemMessageException; import org.eclipse.rse.services.files.IFileService; import org.eclipse.rse.services.files.IHostFile; -import org.eclipse.rse.services.files.RemoteFileIOException; -import org.eclipse.rse.services.files.RemoteFileSecurityException; -import org.eclipse.rse.services.files.RemoteFolderNotEmptyException; import org.eclipse.rse.services.search.IHostSearchResultConfiguration; import org.eclipse.rse.services.search.IHostSearchResultSet; import org.eclipse.rse.services.search.ISearchService; @@ -54,8 +53,6 @@ import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileContext; import org.eclipse.rse.subsystems.files.core.subsystems.RemoteFileSubSystem; import org.eclipse.rse.ui.ISystemMessages; import org.eclipse.rse.ui.RSEUIPlugin; -import org.eclipse.rse.ui.messages.SystemMessageDialog; -import org.eclipse.swt.widgets.Display; public final class FileServiceSubSystem extends RemoteFileSubSystem implements IFileServiceSubSystem { @@ -434,15 +431,11 @@ public final class FileServiceSubSystem extends RemoteFileSubSystem implements I - /** - * Get the remote file and save it locally. The file is saved in the encoding - * specified. - * @param file remote file that represents the file to be obtained - * @param localpath the absolute path of the local file - * @param encoding the encoding of the local file - * @param monitor progress monitor + /* + * (non-Javadoc) + * @see org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem#download(org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile, java.lang.String, java.lang.String, org.eclipse.core.runtime.IProgressMonitor) */ - public void download(IRemoteFile file, String localpath, String encoding, IProgressMonitor monitor) + public void download(IRemoteFile file, String localpath, String encoding, IProgressMonitor monitor) throws SystemMessageException { //Fixing bug 158534. TODO remove when bug 162688 is fixed. if (monitor==null) { @@ -450,16 +443,7 @@ public final class FileServiceSubSystem extends RemoteFileSubSystem implements I } String parentPath = file.getParentPath(); File localFile = new File(localpath); - try - { - getFileService().download(parentPath, file.getName(), localFile, isBinary(file), file.getEncoding(), monitor); - } - catch (SystemMessageException e) - { - SystemMessageDialog dlg = new SystemMessageDialog(getShell(), e.getSystemMessage()); - dlg.open(); - } - + getFileService().download(parentPath, file.getName(), localFile, isBinary(file), file.getEncoding(), monitor); if (monitor.isCanceled()) { localFile.delete(); @@ -487,15 +471,11 @@ public final class FileServiceSubSystem extends RemoteFileSubSystem implements I } } - /** - * Put the local copy of the remote file back to the remote location. The file - * is assumed to be in the encoding of the local operating system - * @param source the absolute path of the local copy - * @param srcEncoding The encoding of the local copy - * @param remotePath remote file that represents the file on the server - * @param rmtEncoding The encoding of the remote file. + /* + * (non-Javadoc) + * @see org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem#upload(java.lang.String, java.lang.String, java.lang.String, java.lang.String, org.eclipse.core.runtime.IProgressMonitor) */ - public void upload(String source, String srcEncoding, String remotePath, String rmtEncoding, IProgressMonitor monitor) throws RemoteFileSecurityException, RemoteFileIOException { + public void upload(String source, String srcEncoding, String remotePath, String rmtEncoding, IProgressMonitor monitor) throws SystemMessageException { int slashIndex = remotePath.lastIndexOf(getSeparator()); if (slashIndex > -1) { String remoteParentPath = remotePath.substring(0, slashIndex); @@ -507,27 +487,15 @@ public final class FileServiceSubSystem extends RemoteFileSubSystem implements I remoteParentPath = avp.getPath(); remoteFileName = avp.getName(); } - try - { - getFileService().upload(new File(source), remoteParentPath, remoteFileName, isBinary, srcEncoding, rmtEncoding, monitor); - } - catch (SystemMessageException e) - { - SystemMessageDialog dlg = new SystemMessageDialog(getShell(), e.getSystemMessage()); - dlg.open(); - } + getFileService().upload(new File(source), remoteParentPath, remoteFileName, isBinary, srcEncoding, rmtEncoding, monitor); } } - /** - * Put the local copy of the remote file back to the remote location. The file - * is assumed to be in the encoding of the local operating system - * @param source the absolute path of the local copy - * @param destination location to copy to - * @param encoding The encoding of the local copy - * @param monitor progress monitor + /* + * (non-Javadoc) + * @see org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem#upload(java.lang.String, org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile, java.lang.String, org.eclipse.core.runtime.IProgressMonitor) */ - public void upload(String source, IRemoteFile destination, String encoding, IProgressMonitor monitor) throws RemoteFileSecurityException, RemoteFileIOException + public void upload(String source, IRemoteFile destination, String encoding, IProgressMonitor monitor) throws SystemMessageException { String remoteParentPath = destination.getParentPath(); String remoteFileName = destination.getName(); @@ -537,39 +505,22 @@ public final class FileServiceSubSystem extends RemoteFileSubSystem implements I if (!destination.canWrite()) { SystemMessage msg = RSEUIPlugin.getPluginMessage("RSEF5003").makeSubstitution(remoteFileName, getHostName()); //$NON-NLS-1$ - SystemMessageDialog dlg = new SystemMessageDialog(getShell(), msg); - dlg.open(); - return; - } - - try - { - getFileService().upload(new File(source), remoteParentPath, remoteFileName, isBinary, encoding, hostEncoding, monitor); - } - catch (SystemMessageException e) - { - SystemMessageDialog dlg = new SystemMessageDialog(getShell(), e.getSystemMessage()); - dlg.open(); + throw new SystemMessageException(msg); } + getFileService().upload(new File(source), remoteParentPath, remoteFileName, isBinary, encoding, hostEncoding, monitor); } - public boolean copy(IRemoteFile sourceFolderOrFile, IRemoteFile targetFolder, String newName, IProgressMonitor monitor) throws RemoteFileSecurityException, RemoteFileIOException + /* + * (non-Javadoc) + * @see org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem#copy(org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile, org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile, java.lang.String, org.eclipse.core.runtime.IProgressMonitor) + */ + public boolean copy(IRemoteFile sourceFolderOrFile, IRemoteFile targetFolder, String newName, IProgressMonitor monitor) throws SystemMessageException { IFileService service = getFileService(); - try - { - return service.copy(sourceFolderOrFile.getParentPath(), sourceFolderOrFile.getName(), targetFolder.getAbsolutePath(), newName, monitor); - } - catch (SystemMessageException e) - { - Display dis = Display.getDefault(); - SystemMessageDialog dlg = new SystemMessageDialog(getShell(), e.getSystemMessage()); - dis.syncExec(new SystemMessageDialogRunnable(dlg)); - } - return false; + return service.copy(sourceFolderOrFile.getParentPath(), sourceFolderOrFile.getName(), targetFolder.getAbsolutePath(), newName, monitor); } - public boolean copyBatch(IRemoteFile[] sourceFolderOrFiles, IRemoteFile targetFolder, IProgressMonitor monitor) throws RemoteFileSecurityException, RemoteFileIOException + public boolean copyBatch(IRemoteFile[] sourceFolderOrFiles, IRemoteFile targetFolder, IProgressMonitor monitor) throws SystemMessageException { IFileService service = getFileService(); String[] sourceParents = new String[sourceFolderOrFiles.length]; @@ -580,17 +531,7 @@ public final class FileServiceSubSystem extends RemoteFileSubSystem implements I sourceParents[i] = sourceFolderOrFiles[i].getParentPath(); sourceNames[i] = sourceFolderOrFiles[i].getName(); } - try - { - return service.copyBatch(sourceParents, sourceNames, targetFolder.getAbsolutePath(), monitor); - } - catch (SystemMessageException e) - { - Display dis = Display.getDefault(); - SystemMessageDialog dlg = new SystemMessageDialog(getShell(), e.getSystemMessage()); - dis.syncExec(new SystemMessageDialogRunnable(dlg)); - } - return false; + return service.copyBatch(sourceParents, sourceNames, targetFolder.getAbsolutePath(), monitor); } public IRemoteFile getParentFolder(IRemoteFile folderOrFile, IProgressMonitor monitor) @@ -605,75 +546,42 @@ public final class FileServiceSubSystem extends RemoteFileSubSystem implements I } } - public IRemoteFile createFile(IRemoteFile fileToCreate, IProgressMonitor monitor) throws RemoteFileSecurityException, RemoteFileIOException + public IRemoteFile createFile(IRemoteFile fileToCreate, IProgressMonitor monitor) throws SystemMessageException { IFileService service = getFileService(); String parent = fileToCreate.getParentPath(); String name = fileToCreate.getName(); - IHostFile newFile = null; - - try - { - newFile = service.createFile(parent, name, monitor); - } - catch (SystemMessageException e) - { - SystemMessageDialog dlg = new SystemMessageDialog(getShell(), e.getSystemMessage()); - SystemMessageDialogRunnable runnable = new SystemMessageDialogRunnable(dlg); - Display.getDefault().asyncExec(runnable); - - return null; - } + IHostFile newFile = service.createFile(parent, name, monitor); return getHostFileToRemoteFileAdapter().convertToRemoteFile(this, getDefaultContext(), fileToCreate.getParentRemoteFile(), newFile); } - public IRemoteFile createFolder(IRemoteFile folderToCreate, IProgressMonitor monitor) throws RemoteFileSecurityException, RemoteFileIOException + public IRemoteFile createFolder(IRemoteFile folderToCreate, IProgressMonitor monitor) throws SystemMessageException { IFileService service = getFileService(); String parent = folderToCreate.getParentPath(); String name = folderToCreate.getName(); - IHostFile newFolder = null; - try - { - newFolder = service.createFolder(parent, name, monitor); - } - catch (SystemMessageException e) - { - SystemMessageDialog dlg = new SystemMessageDialog(getShell(), e.getSystemMessage()); - dlg.open(); - return null; - } + IHostFile newFolder = service.createFolder(parent, name, monitor); return getHostFileToRemoteFileAdapter().convertToRemoteFile(this, getDefaultContext(), folderToCreate.getParentRemoteFile(), newFolder); } - public IRemoteFile createFolders(IRemoteFile folderToCreate, IProgressMonitor monitor) throws RemoteFileSecurityException, RemoteFileIOException + public IRemoteFile createFolders(IRemoteFile folderToCreate, IProgressMonitor monitor) throws SystemMessageException { return createFolder(folderToCreate, monitor); } - public boolean delete(IRemoteFile folderOrFile, IProgressMonitor monitor) throws RemoteFolderNotEmptyException, RemoteFileSecurityException, RemoteFileIOException + public boolean delete(IRemoteFile folderOrFile, IProgressMonitor monitor) throws SystemMessageException { - boolean result = false; IFileService service = getFileService(); String parent = folderOrFile.getParentPath(); String name = folderOrFile.getName(); - try - { - result = service.delete(parent, name, monitor); - folderOrFile.markStale(true); - } - catch (SystemMessageException e) - { - SystemMessageDialog dlg = new SystemMessageDialog(getShell(), e.getSystemMessage()); - dlg.open(); - return false; - } + boolean result = service.delete(parent, name, monitor); + folderOrFile.markStale(true); return result; } - public boolean deleteBatch(IRemoteFile[] folderOrFiles, IProgressMonitor monitor) throws RemoteFolderNotEmptyException, RemoteFileSecurityException, RemoteFileIOException + public boolean deleteBatch(IRemoteFile[] folderOrFiles, IProgressMonitor monitor) throws SystemMessageException { - boolean result = false; + String[] parents = new String[folderOrFiles.length]; String[] names = new String[folderOrFiles.length]; for (int i = 0; i < folderOrFiles.length; i++) @@ -685,95 +593,46 @@ public final class FileServiceSubSystem extends RemoteFileSubSystem implements I removeCachedRemoteFile(folderOrFiles[i]); } IFileService service = getFileService(); - try - { - result = service.deleteBatch(parents, names, monitor); - } - catch (SystemMessageException e) - { - SystemMessageDialog dlg = new SystemMessageDialog(getShell(), e.getSystemMessage()); - dlg.open(); - return false; - } - return result; + return service.deleteBatch(parents, names, monitor); } - public boolean rename(IRemoteFile folderOrFile, String newName, IProgressMonitor monitor) throws RemoteFileSecurityException, RemoteFileIOException + public boolean rename(IRemoteFile folderOrFile, String newName, IProgressMonitor monitor) throws SystemMessageException { - boolean result = false; removeCachedRemoteFile(folderOrFile); IFileService service = getFileService(); String srcParent = folderOrFile.getParentPath(); String oldName = folderOrFile.getName(); String newPath = srcParent + folderOrFile.getSeparator() + newName; - try - { - result = service.rename(srcParent, oldName, newName, monitor); - folderOrFile.getHostFile().renameTo(newPath); - } - catch (SystemMessageException e) - { - SystemMessageDialog dlg = new SystemMessageDialog(getShell(), e.getSystemMessage()); - dlg.open(); - return false; - } + boolean result = service.rename(srcParent, oldName, newName, monitor); + folderOrFile.getHostFile().renameTo(newPath); return result; } - public boolean move(IRemoteFile sourceFolderOrFile, IRemoteFile targetFolder, String newName, IProgressMonitor monitor) throws RemoteFileSecurityException, RemoteFileIOException + public boolean move(IRemoteFile sourceFolderOrFile, IRemoteFile targetFolder, String newName, IProgressMonitor monitor) throws SystemMessageException { - boolean result = false; IFileService service = getFileService(); String srcParent = sourceFolderOrFile.getParentPath(); String srcName = sourceFolderOrFile.getName(); String tgtParent = targetFolder.getAbsolutePath(); - try - { - removeCachedRemoteFile(sourceFolderOrFile); - result = service.move(srcParent, srcName, tgtParent, newName, monitor); - sourceFolderOrFile.markStale(true); - targetFolder.markStale(true); - } - catch (SystemMessageException e) - { - SystemMessageDialog dlg = new SystemMessageDialog(getShell(), e.getSystemMessage()); - dlg.open(); - return false; - } + removeCachedRemoteFile(sourceFolderOrFile); + boolean result = service.move(srcParent, srcName, tgtParent, newName, monitor); + sourceFolderOrFile.markStale(true); + targetFolder.markStale(true); return result; } - - public boolean setLastModified(IRemoteFile folderOrFile, long newDate, IProgressMonitor monitor) throws RemoteFileSecurityException, RemoteFileIOException + public boolean setLastModified(IRemoteFile folderOrFile, long newDate, IProgressMonitor monitor) throws SystemMessageException { String name = folderOrFile.getName(); String parent = folderOrFile.getParentPath(); - try - { - return _hostFileService.setLastModified(parent, name, newDate, monitor); - } - catch (SystemMessageException e) - { - SystemMessageDialog dlg = new SystemMessageDialog(getShell(), e.getSystemMessage()); - dlg.open(); - return false; - } + return _hostFileService.setLastModified(parent, name, newDate, monitor); } - public boolean setReadOnly(IRemoteFile folderOrFile, boolean readOnly, IProgressMonitor monitor) throws RemoteFileSecurityException, RemoteFileIOException + public boolean setReadOnly(IRemoteFile folderOrFile, boolean readOnly, IProgressMonitor monitor) throws SystemMessageException { String name = folderOrFile.getName(); String parent = folderOrFile.getParentPath(); - try - { - return _hostFileService.setReadOnly(parent, name, readOnly, monitor); - } - catch (SystemMessageException e) - { - SystemMessageDialog dlg = new SystemMessageDialog(getShell(), e.getSystemMessage()); - dlg.open(); - return false; - } + return _hostFileService.setReadOnly(parent, name, readOnly, monitor); } public ILanguageUtilityFactory getLanguageUtilityFactory() @@ -886,18 +745,12 @@ public final class FileServiceSubSystem extends RemoteFileSubSystem implements I * @see RemoteFileSubSystem#getRemoteEncoding() */ public String getRemoteEncoding() { - String encoding = null; - try { - encoding = getFileService().getEncoding(null); + return getFileService().getEncoding(null); + } catch (SystemMessageException e) { + SystemBasePlugin.logMessage(e.getSystemMessage()); } - catch (SystemMessageException e) { - SystemMessageDialog dlg = new SystemMessageDialog(getShell(), e.getSystemMessage()); - dlg.open(); - encoding = super.getRemoteEncoding(); - } - - return encoding; + return super.getRemoteEncoding(); } /** diff --git a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/subsystems/IRemoteFileSubSystem.java b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/subsystems/IRemoteFileSubSystem.java index 5d26c17e2fd..b8d4a6c6170 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/subsystems/IRemoteFileSubSystem.java +++ b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/subsystems/IRemoteFileSubSystem.java @@ -14,6 +14,7 @@ * Contributors: * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API + * Martin Oberhuber (Wind River) - [183824] Forward SystemMessageException from IRemoteFileSubsystem *******************************************************************************/ package org.eclipse.rse.subsystems.files.core.subsystems; @@ -27,9 +28,7 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.rse.core.model.SystemRemoteResourceSet; import org.eclipse.rse.core.subsystems.ISubSystem; import org.eclipse.rse.services.clientserver.messages.SystemMessageException; -import org.eclipse.rse.services.files.RemoteFileIOException; -import org.eclipse.rse.services.files.RemoteFileSecurityException; -import org.eclipse.rse.services.files.RemoteFolderNotEmptyException; +import org.eclipse.rse.services.files.RemoteFileException; import org.eclipse.rse.services.search.IHostSearchResultConfiguration; import org.eclipse.rse.subsystems.files.core.ILanguageUtilityFactory; @@ -45,10 +44,6 @@ import org.eclipse.rse.subsystems.files.core.ILanguageUtilityFactory; * The idea is to encourage a common API and GUI layer that works * with any remote unix-like file system on any remote operating system. */ -/** - * @lastgen interface RemoteFileSubSystem extends SubSystem {} - */ - public interface IRemoteFileSubSystem extends ISubSystem { // ---------------------- @@ -191,6 +186,7 @@ public interface IRemoteFileSubSystem extends ISubSystem { * @param monitor the progress monitor */ public IRemoteFile[] listFiles(IRemoteFile parent, String fileNameFilter, IRemoteFileContext context, IProgressMonitor monitor) throws SystemMessageException; + /** * Given a search configuration, searches for its results. * @param searchConfig a search configuration. @@ -203,7 +199,6 @@ public interface IRemoteFileSubSystem extends ISubSystem { */ public void cancelSearch(IHostSearchResultConfiguration searchConfig); - /** * Given a folder or file, return its parent folder object. * @param folderOrFile folder or file to return parent of. @@ -295,8 +290,11 @@ public interface IRemoteFileSubSystem extends ISubSystem { * * @param fileToCreate The object representing the file to be created. * @return The same input object returned for convenience. Will throw exception if it fails. + * @throws SystemMessageException if an error occurs. + * Typically this would be one of those in the + * {@link RemoteFileException} family. */ - public IRemoteFile createFile(IRemoteFile fileToCreate, IProgressMonitor monitor) throws RemoteFileSecurityException, RemoteFileIOException; + public IRemoteFile createFile(IRemoteFile fileToCreate, IProgressMonitor monitor) throws SystemMessageException; /** * Create a new folder, given its IRemoteFile object (these do not have to represent existing folders) @@ -312,8 +310,11 @@ public interface IRemoteFileSubSystem extends ISubSystem { * @param folderToCreate The object representing the folder to be created. * @param monitor the progress monitor * @return The same input object returned for convenience. Will throw exception if it fails. + * @throws SystemMessageException if an error occurs. + * Typically this would be one of those in the + * {@link RemoteFileException} family. */ - public IRemoteFile createFolder(IRemoteFile folderToCreate, IProgressMonitor monitor) throws RemoteFileSecurityException, RemoteFileIOException; + public IRemoteFile createFolder(IRemoteFile folderToCreate, IProgressMonitor monitor) throws SystemMessageException; /** * Given an IRemoteFile for a folder, this will create that folder and any missing parent folders in its path. @@ -327,12 +328,13 @@ public interface IRemoteFileSubSystem extends ISubSystem { * @see #getParentFolder(IRemoteFile, IProgressMonitor) * * @param folderToCreate The object representing the folder to be created, along with its parents. - * @param monitor the progress monitr + * @param monitor the progress monitor * @return The same input object returned for convenience. Will throw exception if it fails. + * @throws SystemMessageException if an error occurs. + * Typically this would be one of those in the + * {@link RemoteFileException} family. */ - public IRemoteFile createFolders(IRemoteFile folderToCreate, IProgressMonitor monitor) throws RemoteFileSecurityException, RemoteFileIOException; - - + public IRemoteFile createFolders(IRemoteFile folderToCreate, IProgressMonitor monitor) throws SystemMessageException; /** * Delete the given remote file or folder. @@ -343,8 +345,11 @@ public interface IRemoteFileSubSystem extends ISubSystem { * @param folderOrFile represents the object to be deleted. * @param monitor progressMonitor * @return false if the given folder/file didn't exist to begin with, else true. Throws an exception if anything fails. + * @throws SystemMessageException if an error occurs. + * Typically this would be one of those in the + * {@link RemoteFileException} family. */ - public boolean delete(IRemoteFile folderOrFile, IProgressMonitor monitor) throws RemoteFolderNotEmptyException, RemoteFileSecurityException, RemoteFileIOException; + public boolean delete(IRemoteFile folderOrFile, IProgressMonitor monitor) throws SystemMessageException; /** * Delete the given batch of remote file or folder. @@ -356,20 +361,24 @@ public interface IRemoteFileSubSystem extends ISubSystem { * @param folderOrFiles represents the objects to be deleted. * @param monitor progressMonitor * @return false if any of the given folder/file dont exist to begin with, else true. Throws an exception if anything fails. + * @throws SystemMessageException if an error occurs. + * Typically this would be one of those in the + * {@link RemoteFileException} family. */ - public boolean deleteBatch(IRemoteFile[] folderOrFiles, IProgressMonitor monitor) throws RemoteFolderNotEmptyException, RemoteFileSecurityException, RemoteFileIOException; + public boolean deleteBatch(IRemoteFile[] folderOrFiles, IProgressMonitor monitor) throws SystemMessageException; - /** * Rename the given remote file or folder. This renames it in memory and, iff it exists, on disk. * @param folderOrFile represents the object to be renamed. * @param newName new name to give it. * @param monitor the progress monitor * @return false if the given folder/file didn't exist on disk (still renamed in memory), else true. Throws an exception if anything fails. + * @throws SystemMessageException if an error occurs. + * Typically this would be one of those in the + * {@link RemoteFileException} family. */ - public boolean rename(IRemoteFile folderOrFile, String newName, IProgressMonitor monitor) throws RemoteFileSecurityException, RemoteFileIOException; + public boolean rename(IRemoteFile folderOrFile, String newName, IProgressMonitor monitor) throws SystemMessageException; - /** * Move a file or folder to a new target parent folder. * @@ -377,9 +386,12 @@ public interface IRemoteFileSubSystem extends ISubSystem { * @param targetFolder The folder to move to. No guarantee it is on the same system, so be sure to check getSystemConnection()! * @param newName The new name for the moved file or folder * @param monitor progress monitor - * @return false true iff the move succeeded + * @return true if the move succeeded + * @throws SystemMessageException if an error occurs. + * Typically this would be one of those in the + * {@link RemoteFileException} family. */ - public boolean move(IRemoteFile sourceFolderOrFile, IRemoteFile targetFolder, String newName,IProgressMonitor monitor) throws RemoteFileSecurityException, RemoteFileIOException; + public boolean move(IRemoteFile sourceFolderOrFile, IRemoteFile targetFolder, String newName,IProgressMonitor monitor) throws SystemMessageException; /** * Set the last modified date for the given file or folder. Like a Unix "touch" operation. @@ -387,21 +399,25 @@ public interface IRemoteFileSubSystem extends ISubSystem { * @param folderOrFile represents the object to be renamed. * @param newDate new date, in milliseconds from epoch, to assign. * @param monitor the progress monitor - * * @return false if the given folder/file didn't exist on disk (operation fails), else true. Throws an exception if anything fails. + * @throws SystemMessageException if an error occurs. + * Typically this would be one of those in the + * {@link RemoteFileException} family. */ - public boolean setLastModified(IRemoteFile folderOrFile, long newDate, IProgressMonitor monitor) throws RemoteFileSecurityException, RemoteFileIOException; + public boolean setLastModified(IRemoteFile folderOrFile, long newDate, IProgressMonitor monitor) throws SystemMessageException; /** - * Set a files readonly permissions. + * Set a files read-only permissions. * Folder or file must exist on disk for this to succeed. * @param folderOrFile represents the object to be renamed. - * @param readOnly whether to set it to be readonly or not + * @param readOnly whether to set it to be read-only or not * @param monitor the progress monitor - * * @return false if the given folder/file didn't exist on disk (operation fails), else true. Throws an exception if anything fails. + * @throws SystemMessageException if an error occurs. + * Typically this would be one of those in the + * {@link RemoteFileException} family. */ - public boolean setReadOnly(IRemoteFile folderOrFile, boolean readOnly, IProgressMonitor monitor) throws RemoteFileSecurityException, RemoteFileIOException; + public boolean setReadOnly(IRemoteFile folderOrFile, boolean readOnly, IProgressMonitor monitor) throws SystemMessageException; // ---------------------------- @@ -411,72 +427,92 @@ public interface IRemoteFileSubSystem extends ISubSystem { // Beginning of methods for downloading remote files from the server /** - * Copy a file or folder to a new target parent folder. - * - * @param sourceFolderOrFile The file or folder to copy - * @param targetFolder The folder to copy to. No guarantee it is on the same system, so be sure to check getSystemConnection()! - * @param newName The new name for the copied file or folder - * @return false true iff the copy succeeded - */ - public boolean copy(IRemoteFile sourceFolderOrFile, IRemoteFile targetFolder, String newName, IProgressMonitor monitor) throws RemoteFileSecurityException, RemoteFileIOException; + * Copy a file or folder to a new target parent folder. + * + * @param sourceFolderOrFile The file or folder to copy + * @param targetFolder The folder to copy to. No guarantee it is on the same system, so be sure to check getSystemConnection()! + * @param newName The new name for the copied file or folder + * @param monitor progress monitor + * @return true if the copy succeeded + * @throws SystemMessageException if an error occurs. + * Typically this would be one of those in the + * {@link RemoteFileException} family. + */ + public boolean copy(IRemoteFile sourceFolderOrFile, IRemoteFile targetFolder, String newName, IProgressMonitor monitor) throws SystemMessageException; /** * Copy a set of remote files or folders to a new target parent folder. Precondition: Sources and target must all be on the same system! * @param sourceFolderOrFile The file or folder to copy * @param targetFolder The folder to copy to. - * @return false true iff all copies succeeded + * @param monitor progress monitor + * @return true if all copies succeeded + * @throws SystemMessageException if an error occurs. + * Typically this would be one of those in the + * {@link RemoteFileException} family. */ - public boolean copyBatch(IRemoteFile[] sourceFolderOrFile, IRemoteFile targetFolder, IProgressMonitor monitor) throws RemoteFileSecurityException, RemoteFileIOException; + public boolean copyBatch(IRemoteFile[] sourceFolderOrFile, IRemoteFile targetFolder, IProgressMonitor monitor) throws SystemMessageException; /** - * Get the remote file and save it locally. The file is saved in the encoding - * specified. Two exceptions: if the remote file is binary, encoding does not apply. - * If the remote file is a XML file, then it will be copied to local in the encoding - * specified in the XML declaration, or as determined from the XML specification. + * Get the remote file and save it locally. + * + * The file is saved in the encoding specified, with two exceptions: + * * @param source remote file that represents the file to be obtained * @param destination the absolute path of the local file * @param encoding the encoding of the local file * @param monitor the progress monitor + * @throws SystemMessageException if an error occurs. + * Typically this would be one of those in the + * {@link RemoteFileException} family. */ - public void download(IRemoteFile source, String destination, String encoding, IProgressMonitor monitor) throws RemoteFileSecurityException, RemoteFileIOException; + public void download(IRemoteFile source, String destination, String encoding, IProgressMonitor monitor) throws SystemMessageException; /** - * Put the local copy of the remote file back to the remote location. The file - * is assumed to be in the encoding specified. - * Two exceptions: if the local file is binary, encoding does not apply. - * If the local file is a XML file, then it will be copied to remote in the encoding - * specified in the XML declaration, or as determined from the XML specification. + * Put the local copy of the remote file back to the remote location. + * + * The file is assumed to be in the encoding specified, with + * two exceptions: + * * @param source the absolute path of the local copy * @param destination remote file that represents the file on the server * @param encoding the encoding of the local copy * @param monitor the progress monitor + * @throws SystemMessageException if an error occurs. + * Typically this would be one of those in the + * {@link RemoteFileException} family. */ - public void upload(String source, IRemoteFile destination, String encoding, IProgressMonitor monitor) throws RemoteFileSecurityException, RemoteFileIOException; + public void upload(String source, IRemoteFile destination, String encoding, IProgressMonitor monitor) throws SystemMessageException; /** - * Put the local copy of the remote file back to the remote location. The file - * is assumed to be in the encoding of the local operating system. - * Two exceptions: if the local file is binary, encoding does not apply. - * If the local file is a XML file, then it will be copied to remote in the encoding - * specified in the XML declaration, or as determined from the XML specification. + * Put the local copy of the remote file back to the remote location. + * + * The file is assumed to be in the encoding of the local operating system, + * with two exceptions: + * * @param source the absolute path of the local copy * @param srcEncoding the encoding of the local copy * @param remotePath remote file that represents the file on the server * @param rmtEncoding the encoding of the remote file. + * @throws SystemMessageException if an error occurs. + * Typically this would be one of those in the + * {@link RemoteFileException} family. */ - public void upload(String source, String srcEncoding, String remotePath, String rmtEncoding, IProgressMonitor monitor) throws RemoteFileSecurityException, RemoteFileIOException; - - /** - * @generated This field/method will be replaced during code generation - * @return The value of the HomeFolder attribute - */ - String getHomeFolder(); - - /** - * @generated This field/method will be replaced during code generation - * @param value The new value of the HomeFolder attribute - */ - void setHomeFolder(String value); + public void upload(String source, String srcEncoding, String remotePath, String rmtEncoding, IProgressMonitor monitor) throws SystemMessageException; /** * Returns a language utility factory associated with this subsystem. @@ -491,7 +527,6 @@ public interface IRemoteFileSubSystem extends ISubSystem { */ public int getUnusedPort(); - /** * Return a list of roots/drives on the remote system. * This version is called by RemoteFileSubSystemImpl's resolveFilterString(s) diff --git a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/subsystems/RemoteFileSubSystem.java b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/subsystems/RemoteFileSubSystem.java index fce311ac756..eedef0b659a 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/subsystems/RemoteFileSubSystem.java +++ b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/subsystems/RemoteFileSubSystem.java @@ -15,6 +15,7 @@ * Martin Oberhuber (Wind River) - Fix 162962 - recursive removeCachedRemoteFile() * Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core * Martin Oberhuber (Wind River) - [182454] improve getAbsoluteName() documentation + * Martin Oberhuber (Wind River) - [183824] Forward SystemMessageException from IRemoteFileSubsystem *******************************************************************************/ package org.eclipse.rse.subsystems.files.core.subsystems; @@ -25,6 +26,7 @@ import java.io.BufferedReader; import java.io.DataInputStream; import java.io.IOException; import java.io.InputStreamReader; +import java.lang.reflect.InvocationTargetException; import java.net.InetAddress; import java.net.UnknownHostException; import java.util.ArrayList; @@ -88,16 +90,6 @@ import org.eclipse.ui.dialogs.PropertyPage; public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFileSubSystem, ICommunicationsListener { - /** - * The default value of the '{@link #getHomeFolder() Home Folder}' attribute. - * - * - * @see #getHomeFolder() - * @generated - * @ordered - */ - protected static final String HOME_FOLDER_EDEFAULT = null; - public boolean osVarsSet, osWindows, osWindows95, osWindowsNT; public String osName, osCmdShell; // variables to affect the list method for subsetting folder contents @@ -112,21 +104,13 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi protected ArrayList _searchHistory; - // all created IRemoteFiles mapped in cache to quick retreival + // all created IRemoteFiles mapped in cache to quick retrieval protected HashMap _cachedRemoteFiles = new HashMap(); - /** - * @generated This field/method will be replaced during code generation. + * Default constructor. Do not call directly! Rather, use the mof generated factory method to create. + * After instantiation, be sure to call {@link #setSubSystemConfiguration(ISubSystemConfiguration)}. */ - /** - * @generated This field/method will be replaced during code generation. - */ - protected String homeFolder = HOME_FOLDER_EDEFAULT; - /** - * Default constructor. Do not call directly! Rather, use the mof generated factory method to create. - * After instantiation, be sure to call {@link #setSubSystemConfiguration(ISubSystemConfiguration)}. - */ public RemoteFileSubSystem(IHost host, IConnectorService connectorService) { super(host, connectorService); @@ -833,7 +817,7 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi * Do one filter string relative resolve */ protected Object[] internalResolveOneFilterString(IProgressMonitor monitor, Object parent, RemoteFileFilterString fs, boolean sort) - throws java.lang.reflect.InvocationTargetException, java.lang.InterruptedException, SystemMessageException + throws InvocationTargetException, InterruptedException, SystemMessageException { currFilterString = fs; String filterString = fs.toStringNoSwitches(); @@ -958,9 +942,6 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi return listFoldersAndFiles(parent, fileNameFilter, context, monitor); } - - - /** * Given a folder or file, return its parent folder name, fully qualified * @param folderOrFile folder or file to return parent of. @@ -970,8 +951,7 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi return folderOrFile.getParentPath(); } - - /** + /* * @see org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem#getRemoteSearchResultObject(java.lang.String) */ public IRemoteSearchResult getRemoteSearchResultObject(String key) throws SystemMessageException { @@ -1245,22 +1225,6 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi return rc; } // end runCmd method - /** - * @generated This field/method will be replaced during code generation - */ - public String getHomeFolder() - { - return homeFolder; - } - - /** - * @generated This field/method will be replaced during code generation. - */ - public void setHomeFolder(String newHomeFolder) - { - homeFolder = newHomeFolder; - } - public void initializeSubSystem(IProgressMonitor monitor) { getConnectorService().addCommunicationsListener(this); @@ -1406,27 +1370,12 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi return true; } - /** - * @generated This field/method will be replaced during code generation. - */ - public String toString() - { - StringBuffer result = new StringBuffer(super.toString()); - result.append(" (homeFolder: "); //$NON-NLS-1$ - result.append(homeFolder); - result.append(')'); - return result.toString(); - } - - - /** * Returns -1 by default. Subclasses should override if necessary. * @see org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem#getUnusedPort() */ public int getUnusedPort() { - return -1; } @@ -1492,7 +1441,8 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi } /** - * Returns the local platform encoding by default. Subclasses should override to return the actual remote encoding. + * Returns the local platform encoding by default. + * Subclasses should override to return the actual remote encoding. * @see org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem#getRemoteEncoding() */ public String getRemoteEncoding() { diff --git a/rse/plugins/org.eclipse.rse.subsystems.files.dstore/src/org/eclipse/rse/internal/subsystems/files/dstore/DStoreFileSubSystemSearchResultConfiguration.java b/rse/plugins/org.eclipse.rse.subsystems.files.dstore/src/org/eclipse/rse/internal/subsystems/files/dstore/DStoreFileSubSystemSearchResultConfiguration.java index 7cd2df7273f..e47b91c35c1 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.files.dstore/src/org/eclipse/rse/internal/subsystems/files/dstore/DStoreFileSubSystemSearchResultConfiguration.java +++ b/rse/plugins/org.eclipse.rse.subsystems.files.dstore/src/org/eclipse/rse/internal/subsystems/files/dstore/DStoreFileSubSystemSearchResultConfiguration.java @@ -13,6 +13,7 @@ * * Contributors: * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API + * Martin Oberhuber (Wind River) - [183824] Forward SystemMessageException from IRemoteFileSubsystem *******************************************************************************/ package org.eclipse.rse.internal.subsystems.files.dstore; @@ -26,6 +27,7 @@ import org.eclipse.dstore.extra.DomainEvent; import org.eclipse.rse.core.subsystems.RemoteChildrenContentsType; import org.eclipse.rse.internal.services.dstore.search.DStoreSearchResultConfiguration; import org.eclipse.rse.services.clientserver.SystemSearchString; +import org.eclipse.rse.services.clientserver.messages.SystemMessageException; import org.eclipse.rse.services.search.IHostSearchConstants; import org.eclipse.rse.services.search.IHostSearchResult; import org.eclipse.rse.services.search.IHostSearchResultSet; @@ -35,6 +37,7 @@ import org.eclipse.rse.subsystems.files.core.servicesubsystem.OutputRefresh; import org.eclipse.rse.subsystems.files.core.subsystems.IHostFileToRemoteFileAdapter; import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; import org.eclipse.rse.subsystems.files.core.subsystems.RemoteSearchResultsContentsType; +import org.eclipse.rse.ui.messages.SystemMessageDialog; import org.eclipse.swt.widgets.Display; public class DStoreFileSubSystemSearchResultConfiguration extends DStoreSearchResultConfiguration @@ -103,6 +106,10 @@ public class DStoreFileSubSystemSearchResultConfiguration extends DStoreSearchRe } convertedResults[i] = remoteFile; } + catch (SystemMessageException e) + { + SystemMessageDialog.displayMessage(e); + } catch (Exception e) { diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/messages/SystemMessageDialog.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/messages/SystemMessageDialog.java index 8c45e8b145e..f5bff40d5fc 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/messages/SystemMessageDialog.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/messages/SystemMessageDialog.java @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (c) 2002, 2006 IBM Corporation. All rights reserved. + * Copyright (c) 2002, 2007 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 @@ -11,7 +11,7 @@ * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. * * Contributors: - * {Name} (company) - description of contribution. + * Martin Oberhuber (Wind River) - [183824] Forward SystemMessageException from IRemoteFileSubsystem ********************************************************************************/ package org.eclipse.rse.ui.messages; @@ -47,8 +47,6 @@ import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; - - /** */ public class SystemMessageDialog extends ErrorDialog implements Listener { @@ -585,7 +583,7 @@ public class SystemMessageDialog extends ErrorDialog implements Listener { */ public static Shell getDefaultShell() { - return Display.getCurrent().getActiveShell(); + return SystemBasePlugin.getActiveWorkbenchShell(); } /** @@ -627,17 +625,24 @@ public class SystemMessageDialog extends ErrorDialog implements Listener { displayErrorMessage(shell,msg); } - - /** * Display this wrapped system message to the user */ - public static void displayMessage(org.eclipse.swt.widgets.Shell shell, SystemMessageException msgEx) + public static void displayMessage(Shell shell, SystemMessageException msgEx) { if (msgEx != null) SystemMessageDialog.displayErrorMessage(shell, msgEx.getSystemMessage()); } + /** + * Display this wrapped system message to the user + */ + public static void displayMessage(SystemMessageException msgEx) + { + if (msgEx != null) + SystemMessageDialog.displayErrorMessage(getDefaultShell(), msgEx.getSystemMessage()); + } + /** * For ease of use for simple host error messages that are xlated already. */ diff --git a/rse/plugins/org.eclipse.rse.ui/systems/org/eclipse/rse/core/SystemBasePlugin.java b/rse/plugins/org.eclipse.rse.ui/systems/org/eclipse/rse/core/SystemBasePlugin.java index 54a9c5d0034..d5c0d4e276e 100644 --- a/rse/plugins/org.eclipse.rse.ui/systems/org/eclipse/rse/core/SystemBasePlugin.java +++ b/rse/plugins/org.eclipse.rse.ui/systems/org/eclipse/rse/core/SystemBasePlugin.java @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (c) 2002, 2006 IBM Corporation. All rights reserved. + * Copyright (c) 2002, 2007 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 @@ -11,7 +11,7 @@ * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. * * Contributors: - * {Name} (company) - description of contribution. + * Martin Oberhuber (Wind River) - [183824] Forward SystemMessageException from IRemoteFileSubsystem ********************************************************************************/ package org.eclipse.rse.core; @@ -78,11 +78,13 @@ public abstract class SystemBasePlugin extends AbstractUIPlugin public static Shell getActiveWorkbenchShell() { IWorkbenchWindow window = getActiveWorkbenchWindow(); - if (window != null) { return window.getShell(); } - + Display d = Display.getCurrent(); + if (d!=null) return d.getActiveShell(); + d = Display.getDefault(); + if (d!=null) return d.getActiveShell(); return null; }