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 aeb3eb54da7..cfc6a48b39f 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 @@ -83,6 +83,7 @@ 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.SystemMessageException; +import org.eclipse.rse.services.clientserver.messages.SystemOperationCancelledException; import org.eclipse.rse.services.files.AbstractFileService; import org.eclipse.rse.services.files.HostFilePermissions; import org.eclipse.rse.services.files.IFilePermissionsService; @@ -90,7 +91,6 @@ import org.eclipse.rse.services.files.IFileService; import org.eclipse.rse.services.files.IHostFile; import org.eclipse.rse.services.files.IHostFilePermissions; import org.eclipse.rse.services.files.IHostFilePermissionsContainer; -import org.eclipse.rse.services.files.RemoteFileCancelledException; import org.eclipse.rse.services.files.RemoteFileException; import org.eclipse.rse.services.files.RemoteFileIOException; import org.eclipse.rse.services.files.RemoteFileSecurityException; @@ -322,15 +322,13 @@ public class LocalFileService extends AbstractFileService implements ILocalServi } } - catch (FileNotFoundException e) + catch (SystemMessageException e) { + throw e; } - catch (UnsupportedEncodingException e) + catch (Exception e) { - } - catch (IOException e) - { - e.printStackTrace(); + throw new RemoteFileIOException(Activator.PLUGIN_ID, e); } finally { @@ -348,8 +346,7 @@ public class LocalFileService extends AbstractFileService implements ILocalServi if (isCancelled) { - // TODO inspect this - throw new RemoteFileCancelledException(); + throw new SystemOperationCancelledException(); } } catch (IOException e) @@ -387,16 +384,11 @@ public class LocalFileService extends AbstractFileService implements ILocalServi try { - - if (!destinationFile.exists()) { File parentDir = destinationFile.getParentFile(); parentDir.mkdirs(); } - - - // encoding conversion required if it a text file but not an xml file boolean isEncodingConversionRequired = !isBinary; @@ -453,22 +445,9 @@ public class LocalFileService extends AbstractFileService implements ILocalServi } } } - catch (FileNotFoundException e) + catch (Exception e) { -// SystemPlugin.logError("Local copy: " + file.getAbsolutePath(), e); - throw new RemoteFileIOException(e); - } - catch (UnsupportedEncodingException e) - { -// SystemPlugin.logError("Local copy: " + file.getAbsolutePath(), e); - throw new RemoteFileIOException(e); -// return false; - } - catch (IOException e) - { - // SystemPlugin.logError("Local copy: " + file.getAbsolutePath(), e); - throw new RemoteFileIOException(e); -// return false; + throw new RemoteFileIOException(Activator.PLUGIN_ID, e); } finally { @@ -486,14 +465,14 @@ public class LocalFileService extends AbstractFileService implements ILocalServi if (isCancelled) { - throw new RemoteFileCancelledException(); + throw new SystemOperationCancelledException(); // return false; } else if (file.exists()) { destinationFile.setLastModified(file.lastModified()); //TODO check if we want to preserve permissions //if(!file.canWrite()) destinationFile.setReadOnly(); if (destinationFile.length() != file.length()) { - throw new RemoteFileCancelledException(); + throw new SystemOperationCancelledException(); // System.err.println("local.upload: size mismach on "+destinationFile.getAbsolutePath()); //$NON-NLS-1$ // return false; } @@ -509,8 +488,6 @@ public class LocalFileService extends AbstractFileService implements ILocalServi private boolean copyToArchive(File file, File destination, String newName, IProgressMonitor monitor, String sourceEncoding, String targetEncoding, boolean isText) throws SystemMessageException { - boolean ok = false; - ISystemArchiveHandler handler = null; String path = ""; //$NON-NLS-1$ if (ArchiveHandlerManager.isVirtual(destination.getAbsolutePath())) @@ -539,17 +516,13 @@ public class LocalFileService extends AbstractFileService implements ILocalServi checkArchiveOperationStatusThread.start(); } - if (file.isDirectory()) - { - ok = handler.add(file, path, newName, sourceEncoding, targetEncoding, _fileTypeRegistry, archiveOperationMonitor); - } - else - { - ok = handler.add(file, path, newName, sourceEncoding, targetEncoding, isText, archiveOperationMonitor); - } - - if (!ok) - { + try { + if (file.isDirectory()) { + handler.add(file, path, newName, sourceEncoding, targetEncoding, _fileTypeRegistry, archiveOperationMonitor); + } else { + handler.add(file, path, newName, sourceEncoding, targetEncoding, isText, archiveOperationMonitor); + } + } catch (SystemMessageException e) { if (null != monitor && monitor.isCanceled()) { //This operation has been cancelled by the user. @@ -557,14 +530,13 @@ public class LocalFileService extends AbstractFileService implements ILocalServi } // SystemPlugin.logError("LocalFileSubSystemImpl.copyToArchive(): Handler's add() method returned false."); String msgTxt = NLS.bind(LocalServiceResources.FILEMSG_FILE_NOT_SAVED, destination.getName(), "localhost"); //$NON-NLS-1$ - String msgDetails = LocalServiceResources.FILEMSG_FILE_NOT_SAVED_DETAILS; + //String msgDetails = LocalServiceResources.FILEMSG_FILE_NOT_SAVED_DETAILS; SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, ILocalMessageIds.FILEMSG_FILE_NOT_SAVED, - IStatus.ERROR, msgTxt, msgDetails); + IStatus.ERROR, msgTxt, e); throw new SystemMessageException(msg); } - else - return true; + return true; } public void upload(File localFile, String remoteParent, String remoteFile, boolean isBinary, String srcEncoding, String hostEncoding, IProgressMonitor monitor) throws SystemMessageException @@ -675,7 +647,7 @@ public class LocalFileService extends AbstractFileService implements ILocalServi if (isCancelled) { - throw new RemoteFileCancelledException(); + throw new SystemOperationCancelledException(); // return false; } else if (destinationFile!=null) { destinationFile.setLastModified(localFile.lastModified()); @@ -684,7 +656,7 @@ public class LocalFileService extends AbstractFileService implements ILocalServi // File lengths can be different if the encodings are different /* if (destinationFile.length() != localFile.length()) { - // throw new RemoteFileCancelledException(); + // throw new SystemOperationCancelledException(); System.err.println("local.upload: size mismach on "+destinationFile.getAbsolutePath()); //$NON-NLS-1$ return false; }*/ @@ -696,7 +668,7 @@ public class LocalFileService extends AbstractFileService implements ILocalServi } } - protected IHostFile[] internalFetch(String remoteParent, String fileFilter, int type, IProgressMonitor monitor) { + protected IHostFile[] internalFetch(String remoteParent, String fileFilter, int type, IProgressMonitor monitor) throws SystemMessageException { LocalFileNameFilter fFilter = new LocalFileNameFilter(fileFilter, type); File localParent = new File(remoteParent); boolean isArchive = false; @@ -723,30 +695,26 @@ public class LocalFileService extends AbstractFileService implements ILocalServi isVirtual = ArchiveHandlerManager.isVirtual(remoteParent); } if (isVirtual || isArchive) { - try { - VirtualChild[] contents = null; - File theFile = getContainingArchive(localParent); - if (isArchive) { - contents = ArchiveHandlerManager.getInstance().getContents(localParent, ""); //$NON-NLS-1$ - } else if (isVirtual) { - AbsoluteVirtualPath avp = new AbsoluteVirtualPath(remoteParent); - contents = ArchiveHandlerManager.getInstance().getContents(theFile, avp.getVirtualPart()); - } - if (contents == null) { - return null; - } - IHostFile[] results = new LocalVirtualHostFile[contents.length]; - for (int i = 0; i < contents.length; i++) { - results[i] = new LocalVirtualHostFile(contents[i]); - } - return results; - } catch (IOException e) { + VirtualChild[] contents = null; + File theFile = getContainingArchive(localParent); + if (isArchive) { + contents = ArchiveHandlerManager.getInstance().getContents(localParent, ""); //$NON-NLS-1$ + } else if (isVirtual) { + AbsoluteVirtualPath avp = new AbsoluteVirtualPath(remoteParent); + contents = ArchiveHandlerManager.getInstance().getContents(theFile, avp.getVirtualPart()); + } + if (contents == null) { return null; } + IHostFile[] results = new LocalVirtualHostFile[contents.length]; + for (int i = 0; i < contents.length; i++) { + results[i] = new LocalVirtualHostFile(contents[i]); + } + return results; } else { // allow cancel before doing the os query if (monitor != null && monitor.isCanceled()) { - return null; + throw new SystemOperationCancelledException(); } /* bug 220241 - don't need this block of code * listFiles() with a filter will still return all folders (they don't have to match) @@ -846,7 +814,7 @@ public class LocalFileService extends AbstractFileService implements ILocalServi - public IHostFile getFile(String remoteParent, String name, IProgressMonitor monitor) + public IHostFile getFile(String remoteParent, String name, IProgressMonitor monitor) throws SystemMessageException { if (name.endsWith(ArchiveHandlerManager.VIRTUAL_SEPARATOR)) { @@ -909,12 +877,13 @@ public class LocalFileService extends AbstractFileService implements ILocalServi fileToCreate.createNewFile(); if (ArchiveHandlerManager.getInstance().isArchive(fileToCreate)) { - if (!ArchiveHandlerManager.getInstance().createEmptyArchive(fileToCreate)) - { + try { + ArchiveHandlerManager.getInstance().createEmptyArchive(fileToCreate); + } catch (SystemMessageException e) { SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, ILocalMessageIds.FILEMSG_ARCHIVE_CORRUPTED, IStatus.ERROR, - LocalServiceResources.FILEMSG_ARCHIVE_CORRUPTED, LocalServiceResources.FILEMSG_ARCHIVE_CORRUPTED_DETAILS); + LocalServiceResources.FILEMSG_ARCHIVE_CORRUPTED, e); throw new SystemMessageException(msg); } } @@ -947,21 +916,19 @@ public class LocalFileService extends AbstractFileService implements ILocalServi CheckArchiveOperationStatusThread checkArchiveOperationStatusThread = new CheckArchiveOperationStatusThread(archiveOperationMonitor, monitor); checkArchiveOperationStatusThread.start(); } - boolean ok = handler.createFile(child.fullName, archiveOperationMonitor); - - if (!ok) - { + try { + handler.createFile(child.fullName, archiveOperationMonitor); + } catch (SystemMessageException e) { if (null != monitor && monitor.isCanceled()) { //This operation has been cancelled by the user. throw getCancelledException(); } - String msgTxt = NLS.bind(LocalServiceResources.FILEMSG_CREATE_VIRTUAL_FAILED, newFile); - String msgDetails = LocalServiceResources.FILEMSG_CREATE_VIRTUAL_FAILED_DETAILS; + //String msgDetails = LocalServiceResources.FILEMSG_CREATE_VIRTUAL_FAILED_DETAILS; SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, ILocalMessageIds.FILEMSG_CREATE_VIRTUAL_FAILED, - IStatus.ERROR, msgTxt, msgDetails); + IStatus.ERROR, msgTxt, e); throw new SystemMessageException(msg); } } @@ -1027,10 +994,9 @@ public class LocalFileService extends AbstractFileService implements ILocalServi CheckArchiveOperationStatusThread checkArchiveOperationStatusThread = new CheckArchiveOperationStatusThread(archiveOperationMonitor, monitor); checkArchiveOperationStatusThread.start(); } - boolean ok = handler.createFolder(child.fullName, archiveOperationMonitor); - - if (!ok) - { + try { + handler.createFolder(child.fullName, archiveOperationMonitor); + } catch (SystemMessageException e) { if (null != monitor && monitor.isCanceled()) { //This operation has been cancelled by the user. @@ -1038,11 +1004,12 @@ public class LocalFileService extends AbstractFileService implements ILocalServi } String msgTxt = NLS.bind(LocalServiceResources.FILEMSG_CREATE_VIRTUAL_FAILED, newFolder); - String msgDetails = LocalServiceResources.FILEMSG_CREATE_VIRTUAL_FAILED_DETAILS; + //String msgDetails = LocalServiceResources.FILEMSG_CREATE_VIRTUAL_FAILED_DETAILS; SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, ILocalMessageIds.FILEMSG_CREATE_VIRTUAL_FAILED, - IStatus.ERROR, msgTxt, msgDetails); + IStatus.ERROR, msgTxt, e); throw new SystemMessageException(msg); + } } return new LocalVirtualHostFile(child); @@ -1209,9 +1176,9 @@ public class LocalFileService extends AbstractFileService implements ILocalServi checkArchiveOperationStatusThread.start(); } - boolean retval = handler.rename(child.fullName, newName, archiveOperationMonitor); - if (!retval) - { + try { + handler.rename(child.fullName, newName, archiveOperationMonitor); + } catch (SystemMessageException e) { if (null != monitor && monitor.isCanceled()) { //This operation has been cancelled by the user. @@ -1220,12 +1187,12 @@ public class LocalFileService extends AbstractFileService implements ILocalServi // 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; + //String msgDetails = LocalServiceResources.FILEMSG_RENAME_FILE_FAILED_DETAILS; throw new SystemMessageException(new SimpleSystemMessage(Activator.PLUGIN_ID, ILocalMessageIds.FILEMSG_RENAME_FILE_FAILED, - IStatus.ERROR, msgTxt, msgDetails)); + IStatus.ERROR, + msgTxt, e)); } - return retval; } return false; } @@ -1413,9 +1380,9 @@ public class LocalFileService extends AbstractFileService implements ILocalServi checkArchiveOperationStatusThread.start(); } File destinationFile = new File(targetFolder, child.name); - boolean returnValue = child.getExtractedFile(destinationFile, sourceEncoding, isText, archiveOperationMonitor); - if (!returnValue) - { + try { + child.getExtractedFile(destinationFile, sourceEncoding, isText, archiveOperationMonitor); + } catch (SystemMessageException e) { if (destinationFile.isDirectory()) { deleteContents(destinationFile, monitor); @@ -1433,12 +1400,12 @@ public class LocalFileService extends AbstractFileService implements ILocalServi // 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; + //String msgDetails = LocalServiceResources.FILEMSG_RENAME_FILE_FAILED_DETAILS; throw new SystemMessageException(new SimpleSystemMessage(Activator.PLUGIN_ID, ILocalMessageIds.FILEMSG_RENAME_FILE_FAILED, - IStatus.ERROR, msgTxt, msgDetails)); + IStatus.ERROR, + msgTxt, e)); } - return returnValue; } if (null != monitor) diff --git a/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/files/LocalVirtualHostFile.java b/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/files/LocalVirtualHostFile.java index c79942b547a..60713e5dbe5 100644 --- a/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/files/LocalVirtualHostFile.java +++ b/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/files/LocalVirtualHostFile.java @@ -7,10 +7,10 @@ * * 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: * Kevin Doyle (IBM) - [189828] renameTo() now passes proper name to _child.renameTo() * Xuan Chen (IBM) - [214251] [archive] "Last Modified Time" changed for all virtual files/folders if rename/paste/delete of one virtual file. @@ -22,25 +22,26 @@ import java.io.File; import org.eclipse.rse.services.clientserver.archiveutils.ArchiveHandlerManager; import org.eclipse.rse.services.clientserver.archiveutils.VirtualChild; +import org.eclipse.rse.services.clientserver.messages.SystemMessageException; -public class LocalVirtualHostFile extends LocalHostFile +public class LocalVirtualHostFile extends LocalHostFile { protected File _parentArchive; protected VirtualChild _child; - + public LocalVirtualHostFile(VirtualChild child) { super(child.getContainingArchive()); _child = child; _parentArchive = _child.getContainingArchive(); } - - public String getName() + + public String getName() { return _child.name; } - public String getParentPath() + public String getParentPath() { return _parentArchive.getAbsolutePath() + ArchiveHandlerManager.VIRTUAL_SEPARATOR + _child.path; } @@ -50,16 +51,16 @@ public class LocalVirtualHostFile extends LocalHostFile return _child.isDirectory; } - public boolean isRoot() + public boolean isRoot() { return false; } - public boolean isFile() + public boolean isFile() { return !_child.isDirectory; } - + public File getFile() { return _parentArchive; @@ -67,24 +68,28 @@ public class LocalVirtualHostFile extends LocalHostFile public boolean exists() { - return _child.exists(); + try { + return _child.exists(); + } catch (SystemMessageException e) { + return false; + } } - + public String getAbsolutePath() { return _child.getContainingArchive().getAbsolutePath() + ArchiveHandlerManager.VIRTUAL_SEPARATOR + _child.fullName; } - + public VirtualChild getChild() { return _child; } - + public boolean isHidden() { return false; } - + public boolean isArchive() { return false; @@ -101,7 +106,7 @@ public class LocalVirtualHostFile extends LocalHostFile newName = newAbsolutePath.substring(i + ArchiveHandlerManager.VIRTUAL_SEPARATOR.length()); _child.renameTo(newName); } - + public long getModifiedDate() { if (null != _child) diff --git a/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/search/LocalSearchHandler.java b/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/search/LocalSearchHandler.java index cfe1c95da38..6255af4623c 100644 --- a/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/search/LocalSearchHandler.java +++ b/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/search/LocalSearchHandler.java @@ -7,10 +7,10 @@ * * 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: * Michael Berger (IBM) - Bug 147791 - symbolic links can cause circular search. * Xuan Chen (IBM) - [160775] [api] rename (at least within a zip) blocks UI threadj @@ -37,6 +37,7 @@ import org.eclipse.rse.services.clientserver.SystemSearchString; import org.eclipse.rse.services.clientserver.archiveutils.AbsoluteVirtualPath; import org.eclipse.rse.services.clientserver.archiveutils.ArchiveHandlerManager; import org.eclipse.rse.services.clientserver.archiveutils.VirtualChild; +import org.eclipse.rse.services.clientserver.messages.SystemMessageException; import org.eclipse.rse.services.clientserver.search.SystemSearchFileNameMatcher; import org.eclipse.rse.services.clientserver.search.SystemSearchLineMatch; import org.eclipse.rse.services.clientserver.search.SystemSearchMatch; @@ -83,7 +84,7 @@ public class LocalSearchHandler implements ISearchHandler /** * Constructor for local search handler. - * + * * @param searchConfig a search configuration. * @param fileService the file service to search. */ @@ -111,7 +112,7 @@ public class LocalSearchHandler implements ISearchHandler _fs = fileService; _searchString = searchConfig.getSearchString(); - + boolean includeSubfolders = _searchString.isIncludeSubfolders(); @@ -149,16 +150,16 @@ public class LocalSearchHandler implements ISearchHandler // start search // pass in the context of the target file - internalSearch(_theFile, _depth, _theRmtFile); - - _isDone = true; - - if (!_isCancelled) - { - _searchConfig.setStatus(IHostSearchConstants.FINISHED); - } - else - { + try { + internalSearch(_theFile, _depth, _theRmtFile); + _isDone = true; + if (!_isCancelled) { + _searchConfig.setStatus(IHostSearchConstants.FINISHED); + } else { + _searchConfig.setStatus(IHostSearchConstants.CANCELLED); + } + } catch (SystemMessageException e) { + _isDone = false; _searchConfig.setStatus(IHostSearchConstants.CANCELLED); } } @@ -185,7 +186,7 @@ public class LocalSearchHandler implements ISearchHandler } } - private boolean internalSearch(File theFile, int depth, IHostFile context) + private boolean internalSearch(File theFile, int depth, IHostFile context) throws SystemMessageException { boolean foundFile = false; @@ -254,8 +255,8 @@ public class LocalSearchHandler implements ISearchHandler _searchConfig.addResult(file); _searchConfig.addResults(file, results); } - - + + //_searchConfig.addResult(file); } // otherwise add the file to the search results @@ -337,15 +338,7 @@ public class LocalSearchHandler implements ISearchHandler VirtualChild[] virtualchildren = null; - try - { - virtualchildren = ArchiveHandlerManager.getInstance().getContents(archive, virtualPath); - } - catch (IOException e) - { - //SystemPlugin.logError("An erorr occured trying to retrieve virtual file " + virtualPath - // + " for " + archive.getAbsolutePath(), e); - } + virtualchildren = ArchiveHandlerManager.getInstance().getContents(archive, virtualPath); if (virtualchildren != null) { @@ -463,11 +456,10 @@ public class LocalSearchHandler implements ISearchHandler /** * Returns whether classification matches. * - * @param absolutePath - * the absolute path of the file for which we want to check - * classification. + * @param absolutePath the absolute path of the file for which we want to + * check classification. * @return true if the classification matches, - * false otherwise. + * false otherwise. */ protected boolean doesClassificationMatch(String absolutePath) { @@ -486,7 +478,7 @@ public class LocalSearchHandler implements ISearchHandler /** * Converts from system line matches to remote search results that will show * up in the remote search view. - * + * * @param remoteFile * the remote file for which line matches have been found. * @param lineMatches diff --git a/rse/plugins/org.eclipse.rse.subsystems.files.local/src/org/eclipse/rse/internal/subsystems/files/local/model/LocalVirtualFile.java b/rse/plugins/org.eclipse.rse.subsystems.files.local/src/org/eclipse/rse/internal/subsystems/files/local/model/LocalVirtualFile.java index 70d325a9b38..2dc8d58e08f 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.files.local/src/org/eclipse/rse/internal/subsystems/files/local/model/LocalVirtualFile.java +++ b/rse/plugins/org.eclipse.rse.subsystems.files.local/src/org/eclipse/rse/internal/subsystems/files/local/model/LocalVirtualFile.java @@ -7,10 +7,10 @@ * * 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: * {Name} (company) - description of contribution. * Xuan Chen (IBM) - [200872] [Archives] Size Property displays size of Archive not of file inside Archive @@ -21,9 +21,12 @@ package org.eclipse.rse.internal.subsystems.files.local.model; import java.io.File; +import org.eclipse.rse.core.model.ISystemMessageObject; +import org.eclipse.rse.core.model.SystemMessageObject; import org.eclipse.rse.internal.services.local.files.LocalVirtualHostFile; import org.eclipse.rse.services.clientserver.archiveutils.ArchiveHandlerManager; import org.eclipse.rse.services.clientserver.archiveutils.VirtualChild; +import org.eclipse.rse.services.clientserver.messages.SystemMessageException; import org.eclipse.rse.subsystems.files.core.servicesubsystem.FileServiceSubSystem; import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileContext; import org.eclipse.rse.subsystems.files.core.subsystems.IVirtualRemoteFile; @@ -41,7 +44,7 @@ public class LocalVirtualFile extends LocalFile implements IVirtualRemoteFile protected File _parentArchive; protected LocalVirtualHostFile _node; protected String _absolutePath = null; - + public LocalVirtualFile(FileServiceSubSystem ss, IRemoteFileContext context, LocalVirtualHostFile node) { super(ss, context, context.getParentRemoteFile(), node); @@ -49,43 +52,43 @@ public class LocalVirtualFile extends LocalFile implements IVirtualRemoteFile _parentArchive = _node.getChild().getContainingArchive(); } - + public String getAbsolutePath() { - return _parentArchive.getAbsolutePath() + ArchiveHandlerManager.VIRTUAL_SEPARATOR + getVirtualFullName(); + return _parentArchive.getAbsolutePath() + ArchiveHandlerManager.VIRTUAL_SEPARATOR + getVirtualFullName(); } - + public File getParentArchive() { return _parentArchive; } - + public VirtualChild getVirtualChild() { return _node.getChild(); } - + public boolean isVirtual() { return true; } - - public String getVirtualFullName() + + public String getVirtualFullName() { return _node.getChild().fullName; } - public String getVirtualFullPath() + public String getVirtualFullPath() { return _node.getChild().path; } - public String getVirtualName() + public String getVirtualName() { return _node.getChild().name; } - public void setVirtualFullName(String string) + public void setVirtualFullName(String string) { _node.getChild().renameTo(string); } @@ -94,8 +97,8 @@ public class LocalVirtualFile extends LocalFile implements IVirtualRemoteFile { return _node.getChild().getSize(); } - - public void setVirtualFullPath(String string) + + public void setVirtualFullPath(String string) { if (string.equals("")) //$NON-NLS-1$ { @@ -107,7 +110,7 @@ public class LocalVirtualFile extends LocalFile implements IVirtualRemoteFile } } - public void setVirtualName(String string) + public void setVirtualName(String string) { if (_node.getChild().path.equals("")) //$NON-NLS-1$ { @@ -118,26 +121,26 @@ public class LocalVirtualFile extends LocalFile implements IVirtualRemoteFile _node.getChild().renameTo(_node.getChild().path + "/" + string); //$NON-NLS-1$ } } - + public File getFileWrapper() { return _node.getFile(); } - public boolean canRead() + public boolean canRead() { return _parentArchive.canRead(); } - public boolean canWrite() + public boolean canWrite() { return _parentArchive.canWrite(); - } + } /* (non-Javadoc) * @see org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile#getComment() */ - public String getComment() + public String getComment() { return _node.getChild().getComment(); } @@ -145,7 +148,7 @@ public class LocalVirtualFile extends LocalFile implements IVirtualRemoteFile /* (non-Javadoc) * @see org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile#getCompressedSize() */ - public long getCompressedSize() + public long getCompressedSize() { return _node.getChild().getCompressedSize(); } @@ -153,7 +156,7 @@ public class LocalVirtualFile extends LocalFile implements IVirtualRemoteFile /* (non-Javadoc) * @see org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile#getCompressionMethod() */ - public String getCompressionMethod() + public String getCompressionMethod() { return _node.getChild().getCompressionMethod(); } @@ -161,35 +164,40 @@ public class LocalVirtualFile extends LocalFile implements IVirtualRemoteFile /* (non-Javadoc) * @see org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile#getCompressionRatio() */ - public double getCompressionRatio() + public double getCompressionRatio() { return _node.getChild().getCompressionRatio(); } - - public Object getFile(String srcEncoding, boolean isText) + + public Object getFile(String srcEncoding, boolean isText) { - return _node.getChild().getExtractedFile(srcEncoding, isText, null); + try { + return _node.getChild().getExtractedFile(srcEncoding, isText, null); + } catch (SystemMessageException e) { + //FIXME check if this is OK, or should we better return null? + return new SystemMessageObject(e.getSystemMessage(), ISystemMessageObject.MSGTYPE_ERROR, null); + } } - public String getContainingArchiveFullName() + public String getContainingArchiveFullName() { return _node.getChild().getContainingArchive().getAbsolutePath(); } - public long getExpandedSize() + public long getExpandedSize() { return _node.getSize(); } - public boolean isVirtualFile() + public boolean isVirtualFile() { return !_node.getChild().isDirectory; } - public boolean isVirtualFolder() + public boolean isVirtualFolder() { return _node.getChild().isDirectory; }