1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-14 20:45:22 +02:00

[199854][api] Improve error reporting for archive handlers

This commit is contained in:
Martin Oberhuber 2008-05-07 03:56:37 +00:00
parent 70ada1aa61
commit 9fedb82d9e
4 changed files with 152 additions and 180 deletions

View file

@ -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.SimpleSystemMessage;
import org.eclipse.rse.services.clientserver.messages.SystemMessage; import org.eclipse.rse.services.clientserver.messages.SystemMessage;
import org.eclipse.rse.services.clientserver.messages.SystemMessageException; 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.AbstractFileService;
import org.eclipse.rse.services.files.HostFilePermissions; import org.eclipse.rse.services.files.HostFilePermissions;
import org.eclipse.rse.services.files.IFilePermissionsService; 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.IHostFile;
import org.eclipse.rse.services.files.IHostFilePermissions; import org.eclipse.rse.services.files.IHostFilePermissions;
import org.eclipse.rse.services.files.IHostFilePermissionsContainer; 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.RemoteFileException;
import org.eclipse.rse.services.files.RemoteFileIOException; import org.eclipse.rse.services.files.RemoteFileIOException;
import org.eclipse.rse.services.files.RemoteFileSecurityException; 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)
{ {
} throw new RemoteFileIOException(Activator.PLUGIN_ID, e);
catch (IOException e)
{
e.printStackTrace();
} }
finally finally
{ {
@ -348,8 +346,7 @@ public class LocalFileService extends AbstractFileService implements ILocalServi
if (isCancelled) if (isCancelled)
{ {
// TODO inspect this throw new SystemOperationCancelledException();
throw new RemoteFileCancelledException();
} }
} }
catch (IOException e) catch (IOException e)
@ -387,16 +384,11 @@ public class LocalFileService extends AbstractFileService implements ILocalServi
try try
{ {
if (!destinationFile.exists()) if (!destinationFile.exists())
{ {
File parentDir = destinationFile.getParentFile(); File parentDir = destinationFile.getParentFile();
parentDir.mkdirs(); parentDir.mkdirs();
} }
// encoding conversion required if it a text file but not an xml file // encoding conversion required if it a text file but not an xml file
boolean isEncodingConversionRequired = !isBinary; 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(Activator.PLUGIN_ID, 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;
} }
finally finally
{ {
@ -486,14 +465,14 @@ public class LocalFileService extends AbstractFileService implements ILocalServi
if (isCancelled) if (isCancelled)
{ {
throw new RemoteFileCancelledException(); throw new SystemOperationCancelledException();
// return false; // return false;
} else if (file.exists()) { } else if (file.exists()) {
destinationFile.setLastModified(file.lastModified()); destinationFile.setLastModified(file.lastModified());
//TODO check if we want to preserve permissions //TODO check if we want to preserve permissions
//if(!file.canWrite()) destinationFile.setReadOnly(); //if(!file.canWrite()) destinationFile.setReadOnly();
if (destinationFile.length() != file.length()) { if (destinationFile.length() != file.length()) {
throw new RemoteFileCancelledException(); throw new SystemOperationCancelledException();
// System.err.println("local.upload: size mismach on "+destinationFile.getAbsolutePath()); //$NON-NLS-1$ // System.err.println("local.upload: size mismach on "+destinationFile.getAbsolutePath()); //$NON-NLS-1$
// return false; // 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 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; ISystemArchiveHandler handler = null;
String path = ""; //$NON-NLS-1$ String path = ""; //$NON-NLS-1$
if (ArchiveHandlerManager.isVirtual(destination.getAbsolutePath())) if (ArchiveHandlerManager.isVirtual(destination.getAbsolutePath()))
@ -539,17 +516,13 @@ public class LocalFileService extends AbstractFileService implements ILocalServi
checkArchiveOperationStatusThread.start(); checkArchiveOperationStatusThread.start();
} }
if (file.isDirectory()) try {
{ if (file.isDirectory()) {
ok = handler.add(file, path, newName, sourceEncoding, targetEncoding, _fileTypeRegistry, archiveOperationMonitor); handler.add(file, path, newName, sourceEncoding, targetEncoding, _fileTypeRegistry, archiveOperationMonitor);
} } else {
else handler.add(file, path, newName, sourceEncoding, targetEncoding, isText, archiveOperationMonitor);
{ }
ok = handler.add(file, path, newName, sourceEncoding, targetEncoding, isText, archiveOperationMonitor); } catch (SystemMessageException e) {
}
if (!ok)
{
if (null != monitor && monitor.isCanceled()) if (null != monitor && monitor.isCanceled())
{ {
//This operation has been cancelled by the user. //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."); // 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 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, SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID,
ILocalMessageIds.FILEMSG_FILE_NOT_SAVED, ILocalMessageIds.FILEMSG_FILE_NOT_SAVED,
IStatus.ERROR, msgTxt, msgDetails); IStatus.ERROR, msgTxt, e);
throw new SystemMessageException(msg); 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 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) if (isCancelled)
{ {
throw new RemoteFileCancelledException(); throw new SystemOperationCancelledException();
// return false; // return false;
} else if (destinationFile!=null) { } else if (destinationFile!=null) {
destinationFile.setLastModified(localFile.lastModified()); 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 // File lengths can be different if the encodings are different
/* if (destinationFile.length() != localFile.length()) { /* if (destinationFile.length() != localFile.length()) {
// throw new RemoteFileCancelledException(); // throw new SystemOperationCancelledException();
System.err.println("local.upload: size mismach on "+destinationFile.getAbsolutePath()); //$NON-NLS-1$ System.err.println("local.upload: size mismach on "+destinationFile.getAbsolutePath()); //$NON-NLS-1$
return false; 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); LocalFileNameFilter fFilter = new LocalFileNameFilter(fileFilter, type);
File localParent = new File(remoteParent); File localParent = new File(remoteParent);
boolean isArchive = false; boolean isArchive = false;
@ -723,30 +695,26 @@ public class LocalFileService extends AbstractFileService implements ILocalServi
isVirtual = ArchiveHandlerManager.isVirtual(remoteParent); isVirtual = ArchiveHandlerManager.isVirtual(remoteParent);
} }
if (isVirtual || isArchive) { if (isVirtual || isArchive) {
try { VirtualChild[] contents = null;
VirtualChild[] contents = null; File theFile = getContainingArchive(localParent);
File theFile = getContainingArchive(localParent); if (isArchive) {
if (isArchive) { contents = ArchiveHandlerManager.getInstance().getContents(localParent, ""); //$NON-NLS-1$
contents = ArchiveHandlerManager.getInstance().getContents(localParent, ""); //$NON-NLS-1$ } else if (isVirtual) {
} else if (isVirtual) { AbsoluteVirtualPath avp = new AbsoluteVirtualPath(remoteParent);
AbsoluteVirtualPath avp = new AbsoluteVirtualPath(remoteParent); contents = ArchiveHandlerManager.getInstance().getContents(theFile, avp.getVirtualPart());
contents = ArchiveHandlerManager.getInstance().getContents(theFile, avp.getVirtualPart()); }
} if (contents == null) {
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) {
return 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 { } else {
// allow cancel before doing the os query // allow cancel before doing the os query
if (monitor != null && monitor.isCanceled()) { if (monitor != null && monitor.isCanceled()) {
return null; throw new SystemOperationCancelledException();
} }
/* bug 220241 - don't need this block of code /* bug 220241 - don't need this block of code
* listFiles() with a filter will still return all folders (they don't have to match) * 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)) if (name.endsWith(ArchiveHandlerManager.VIRTUAL_SEPARATOR))
{ {
@ -909,12 +877,13 @@ public class LocalFileService extends AbstractFileService implements ILocalServi
fileToCreate.createNewFile(); fileToCreate.createNewFile();
if (ArchiveHandlerManager.getInstance().isArchive(fileToCreate)) 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, SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID,
ILocalMessageIds.FILEMSG_ARCHIVE_CORRUPTED, ILocalMessageIds.FILEMSG_ARCHIVE_CORRUPTED,
IStatus.ERROR, IStatus.ERROR,
LocalServiceResources.FILEMSG_ARCHIVE_CORRUPTED, LocalServiceResources.FILEMSG_ARCHIVE_CORRUPTED_DETAILS); LocalServiceResources.FILEMSG_ARCHIVE_CORRUPTED, e);
throw new SystemMessageException(msg); throw new SystemMessageException(msg);
} }
} }
@ -947,21 +916,19 @@ public class LocalFileService extends AbstractFileService implements ILocalServi
CheckArchiveOperationStatusThread checkArchiveOperationStatusThread = new CheckArchiveOperationStatusThread(archiveOperationMonitor, monitor); CheckArchiveOperationStatusThread checkArchiveOperationStatusThread = new CheckArchiveOperationStatusThread(archiveOperationMonitor, monitor);
checkArchiveOperationStatusThread.start(); checkArchiveOperationStatusThread.start();
} }
boolean ok = handler.createFile(child.fullName, archiveOperationMonitor); try {
handler.createFile(child.fullName, archiveOperationMonitor);
if (!ok) } catch (SystemMessageException e) {
{
if (null != monitor && monitor.isCanceled()) if (null != monitor && monitor.isCanceled())
{ {
//This operation has been cancelled by the user. //This operation has been cancelled by the user.
throw getCancelledException(); throw getCancelledException();
} }
String msgTxt = NLS.bind(LocalServiceResources.FILEMSG_CREATE_VIRTUAL_FAILED, newFile); 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, SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID,
ILocalMessageIds.FILEMSG_CREATE_VIRTUAL_FAILED, ILocalMessageIds.FILEMSG_CREATE_VIRTUAL_FAILED,
IStatus.ERROR, msgTxt, msgDetails); IStatus.ERROR, msgTxt, e);
throw new SystemMessageException(msg); throw new SystemMessageException(msg);
} }
} }
@ -1027,10 +994,9 @@ public class LocalFileService extends AbstractFileService implements ILocalServi
CheckArchiveOperationStatusThread checkArchiveOperationStatusThread = new CheckArchiveOperationStatusThread(archiveOperationMonitor, monitor); CheckArchiveOperationStatusThread checkArchiveOperationStatusThread = new CheckArchiveOperationStatusThread(archiveOperationMonitor, monitor);
checkArchiveOperationStatusThread.start(); checkArchiveOperationStatusThread.start();
} }
boolean ok = handler.createFolder(child.fullName, archiveOperationMonitor); try {
handler.createFolder(child.fullName, archiveOperationMonitor);
if (!ok) } catch (SystemMessageException e) {
{
if (null != monitor && monitor.isCanceled()) if (null != monitor && monitor.isCanceled())
{ {
//This operation has been cancelled by the user. //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 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, SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID,
ILocalMessageIds.FILEMSG_CREATE_VIRTUAL_FAILED, ILocalMessageIds.FILEMSG_CREATE_VIRTUAL_FAILED,
IStatus.ERROR, msgTxt, msgDetails); IStatus.ERROR, msgTxt, e);
throw new SystemMessageException(msg); throw new SystemMessageException(msg);
} }
} }
return new LocalVirtualHostFile(child); return new LocalVirtualHostFile(child);
@ -1209,9 +1176,9 @@ public class LocalFileService extends AbstractFileService implements ILocalServi
checkArchiveOperationStatusThread.start(); checkArchiveOperationStatusThread.start();
} }
boolean retval = handler.rename(child.fullName, newName, archiveOperationMonitor); try {
if (!retval) handler.rename(child.fullName, newName, archiveOperationMonitor);
{ } catch (SystemMessageException e) {
if (null != monitor && monitor.isCanceled()) if (null != monitor && monitor.isCanceled())
{ {
//This operation has been cancelled by the user. //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 // for 192705, we need to throw an exception when rename fails
String msgTxt = NLS.bind(LocalServiceResources.FILEMSG_RENAME_FILE_FAILED, child.fullName); 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, throw new SystemMessageException(new SimpleSystemMessage(Activator.PLUGIN_ID,
ILocalMessageIds.FILEMSG_RENAME_FILE_FAILED, ILocalMessageIds.FILEMSG_RENAME_FILE_FAILED,
IStatus.ERROR, msgTxt, msgDetails)); IStatus.ERROR,
msgTxt, e));
} }
return retval;
} }
return false; return false;
} }
@ -1413,9 +1380,9 @@ public class LocalFileService extends AbstractFileService implements ILocalServi
checkArchiveOperationStatusThread.start(); checkArchiveOperationStatusThread.start();
} }
File destinationFile = new File(targetFolder, child.name); File destinationFile = new File(targetFolder, child.name);
boolean returnValue = child.getExtractedFile(destinationFile, sourceEncoding, isText, archiveOperationMonitor); try {
if (!returnValue) child.getExtractedFile(destinationFile, sourceEncoding, isText, archiveOperationMonitor);
{ } catch (SystemMessageException e) {
if (destinationFile.isDirectory()) if (destinationFile.isDirectory())
{ {
deleteContents(destinationFile, monitor); 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 // for 192705, we need to throw an exception when rename fails
String msgTxt = NLS.bind(LocalServiceResources.FILEMSG_RENAME_FILE_FAILED, child.fullName); 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, throw new SystemMessageException(new SimpleSystemMessage(Activator.PLUGIN_ID,
ILocalMessageIds.FILEMSG_RENAME_FILE_FAILED, ILocalMessageIds.FILEMSG_RENAME_FILE_FAILED,
IStatus.ERROR, msgTxt, msgDetails)); IStatus.ERROR,
msgTxt, e));
} }
return returnValue;
} }
if (null != monitor) if (null != monitor)

View file

@ -7,10 +7,10 @@
* *
* Initial Contributors: * Initial Contributors:
* The following IBM employees contributed to the Remote System Explorer * The following IBM employees contributed to the Remote System Explorer
* component that contains this file: David McKnight, Kushal Munir, * component that contains this file: David McKnight, Kushal Munir,
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
* *
* Contributors: * Contributors:
* Kevin Doyle (IBM) - [189828] renameTo() now passes proper name to _child.renameTo() * 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. * 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.ArchiveHandlerManager;
import org.eclipse.rse.services.clientserver.archiveutils.VirtualChild; 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 File _parentArchive;
protected VirtualChild _child; protected VirtualChild _child;
public LocalVirtualHostFile(VirtualChild child) public LocalVirtualHostFile(VirtualChild child)
{ {
super(child.getContainingArchive()); super(child.getContainingArchive());
_child = child; _child = child;
_parentArchive = _child.getContainingArchive(); _parentArchive = _child.getContainingArchive();
} }
public String getName() public String getName()
{ {
return _child.name; return _child.name;
} }
public String getParentPath() public String getParentPath()
{ {
return _parentArchive.getAbsolutePath() + ArchiveHandlerManager.VIRTUAL_SEPARATOR + _child.path; return _parentArchive.getAbsolutePath() + ArchiveHandlerManager.VIRTUAL_SEPARATOR + _child.path;
} }
@ -50,16 +51,16 @@ public class LocalVirtualHostFile extends LocalHostFile
return _child.isDirectory; return _child.isDirectory;
} }
public boolean isRoot() public boolean isRoot()
{ {
return false; return false;
} }
public boolean isFile() public boolean isFile()
{ {
return !_child.isDirectory; return !_child.isDirectory;
} }
public File getFile() public File getFile()
{ {
return _parentArchive; return _parentArchive;
@ -67,24 +68,28 @@ public class LocalVirtualHostFile extends LocalHostFile
public boolean exists() public boolean exists()
{ {
return _child.exists(); try {
return _child.exists();
} catch (SystemMessageException e) {
return false;
}
} }
public String getAbsolutePath() public String getAbsolutePath()
{ {
return _child.getContainingArchive().getAbsolutePath() + ArchiveHandlerManager.VIRTUAL_SEPARATOR + _child.fullName; return _child.getContainingArchive().getAbsolutePath() + ArchiveHandlerManager.VIRTUAL_SEPARATOR + _child.fullName;
} }
public VirtualChild getChild() public VirtualChild getChild()
{ {
return _child; return _child;
} }
public boolean isHidden() public boolean isHidden()
{ {
return false; return false;
} }
public boolean isArchive() public boolean isArchive()
{ {
return false; return false;
@ -101,7 +106,7 @@ public class LocalVirtualHostFile extends LocalHostFile
newName = newAbsolutePath.substring(i + ArchiveHandlerManager.VIRTUAL_SEPARATOR.length()); newName = newAbsolutePath.substring(i + ArchiveHandlerManager.VIRTUAL_SEPARATOR.length());
_child.renameTo(newName); _child.renameTo(newName);
} }
public long getModifiedDate() public long getModifiedDate()
{ {
if (null != _child) if (null != _child)

View file

@ -7,10 +7,10 @@
* *
* Initial Contributors: * Initial Contributors:
* The following IBM employees contributed to the Remote System Explorer * The following IBM employees contributed to the Remote System Explorer
* component that contains this file: David McKnight, Kushal Munir, * component that contains this file: David McKnight, Kushal Munir,
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
* *
* Contributors: * Contributors:
* Michael Berger (IBM) - Bug 147791 - symbolic links can cause circular search. * 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 * 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.AbsoluteVirtualPath;
import org.eclipse.rse.services.clientserver.archiveutils.ArchiveHandlerManager; import org.eclipse.rse.services.clientserver.archiveutils.ArchiveHandlerManager;
import org.eclipse.rse.services.clientserver.archiveutils.VirtualChild; 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.SystemSearchFileNameMatcher;
import org.eclipse.rse.services.clientserver.search.SystemSearchLineMatch; import org.eclipse.rse.services.clientserver.search.SystemSearchLineMatch;
import org.eclipse.rse.services.clientserver.search.SystemSearchMatch; import org.eclipse.rse.services.clientserver.search.SystemSearchMatch;
@ -83,7 +84,7 @@ public class LocalSearchHandler implements ISearchHandler
/** /**
* Constructor for local search handler. * Constructor for local search handler.
* *
* @param searchConfig a search configuration. * @param searchConfig a search configuration.
* @param fileService the file service to search. * @param fileService the file service to search.
*/ */
@ -111,7 +112,7 @@ public class LocalSearchHandler implements ISearchHandler
_fs = fileService; _fs = fileService;
_searchString = searchConfig.getSearchString(); _searchString = searchConfig.getSearchString();
boolean includeSubfolders = _searchString.isIncludeSubfolders(); boolean includeSubfolders = _searchString.isIncludeSubfolders();
@ -149,16 +150,16 @@ public class LocalSearchHandler implements ISearchHandler
// start search // start search
// pass in the context of the target file // pass in the context of the target file
internalSearch(_theFile, _depth, _theRmtFile); try {
internalSearch(_theFile, _depth, _theRmtFile);
_isDone = true; _isDone = true;
if (!_isCancelled) {
if (!_isCancelled) _searchConfig.setStatus(IHostSearchConstants.FINISHED);
{ } else {
_searchConfig.setStatus(IHostSearchConstants.FINISHED); _searchConfig.setStatus(IHostSearchConstants.CANCELLED);
} }
else } catch (SystemMessageException e) {
{ _isDone = false;
_searchConfig.setStatus(IHostSearchConstants.CANCELLED); _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; boolean foundFile = false;
@ -254,8 +255,8 @@ public class LocalSearchHandler implements ISearchHandler
_searchConfig.addResult(file); _searchConfig.addResult(file);
_searchConfig.addResults(file, results); _searchConfig.addResults(file, results);
} }
//_searchConfig.addResult(file); //_searchConfig.addResult(file);
} }
// otherwise add the file to the search results // otherwise add the file to the search results
@ -337,15 +338,7 @@ public class LocalSearchHandler implements ISearchHandler
VirtualChild[] virtualchildren = null; VirtualChild[] virtualchildren = null;
try virtualchildren = ArchiveHandlerManager.getInstance().getContents(archive, virtualPath);
{
virtualchildren = ArchiveHandlerManager.getInstance().getContents(archive, virtualPath);
}
catch (IOException e)
{
//SystemPlugin.logError("An erorr occured trying to retrieve virtual file " + virtualPath
// + " for " + archive.getAbsolutePath(), e);
}
if (virtualchildren != null) if (virtualchildren != null)
{ {
@ -463,11 +456,10 @@ public class LocalSearchHandler implements ISearchHandler
/** /**
* Returns whether classification matches. * Returns whether classification matches.
* *
* @param absolutePath * @param absolutePath the absolute path of the file for which we want to
* the absolute path of the file for which we want to check * check classification.
* classification.
* @return <code>true</code> if the classification matches, * @return <code>true</code> if the classification matches,
* <code>false</code> otherwise. * <code>false</code> otherwise.
*/ */
protected boolean doesClassificationMatch(String absolutePath) 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 * Converts from system line matches to remote search results that will show
* up in the remote search view. * up in the remote search view.
* *
* @param remoteFile * @param remoteFile
* the remote file for which line matches have been found. * the remote file for which line matches have been found.
* @param lineMatches * @param lineMatches

View file

@ -7,10 +7,10 @@
* *
* Initial Contributors: * Initial Contributors:
* The following IBM employees contributed to the Remote System Explorer * The following IBM employees contributed to the Remote System Explorer
* component that contains this file: David McKnight, Kushal Munir, * component that contains this file: David McKnight, Kushal Munir,
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
* *
* Contributors: * Contributors:
* {Name} (company) - description of contribution. * {Name} (company) - description of contribution.
* Xuan Chen (IBM) - [200872] [Archives] Size Property displays size of Archive not of file inside Archive * 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 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.internal.services.local.files.LocalVirtualHostFile;
import org.eclipse.rse.services.clientserver.archiveutils.ArchiveHandlerManager; import org.eclipse.rse.services.clientserver.archiveutils.ArchiveHandlerManager;
import org.eclipse.rse.services.clientserver.archiveutils.VirtualChild; 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.servicesubsystem.FileServiceSubSystem;
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileContext; import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileContext;
import org.eclipse.rse.subsystems.files.core.subsystems.IVirtualRemoteFile; import org.eclipse.rse.subsystems.files.core.subsystems.IVirtualRemoteFile;
@ -41,7 +44,7 @@ public class LocalVirtualFile extends LocalFile implements IVirtualRemoteFile
protected File _parentArchive; protected File _parentArchive;
protected LocalVirtualHostFile _node; protected LocalVirtualHostFile _node;
protected String _absolutePath = null; protected String _absolutePath = null;
public LocalVirtualFile(FileServiceSubSystem ss, IRemoteFileContext context, LocalVirtualHostFile node) public LocalVirtualFile(FileServiceSubSystem ss, IRemoteFileContext context, LocalVirtualHostFile node)
{ {
super(ss, context, context.getParentRemoteFile(), node); super(ss, context, context.getParentRemoteFile(), node);
@ -49,43 +52,43 @@ public class LocalVirtualFile extends LocalFile implements IVirtualRemoteFile
_parentArchive = _node.getChild().getContainingArchive(); _parentArchive = _node.getChild().getContainingArchive();
} }
public String getAbsolutePath() public String getAbsolutePath()
{ {
return _parentArchive.getAbsolutePath() + ArchiveHandlerManager.VIRTUAL_SEPARATOR + getVirtualFullName(); return _parentArchive.getAbsolutePath() + ArchiveHandlerManager.VIRTUAL_SEPARATOR + getVirtualFullName();
} }
public File getParentArchive() public File getParentArchive()
{ {
return _parentArchive; return _parentArchive;
} }
public VirtualChild getVirtualChild() public VirtualChild getVirtualChild()
{ {
return _node.getChild(); return _node.getChild();
} }
public boolean isVirtual() public boolean isVirtual()
{ {
return true; return true;
} }
public String getVirtualFullName() public String getVirtualFullName()
{ {
return _node.getChild().fullName; return _node.getChild().fullName;
} }
public String getVirtualFullPath() public String getVirtualFullPath()
{ {
return _node.getChild().path; return _node.getChild().path;
} }
public String getVirtualName() public String getVirtualName()
{ {
return _node.getChild().name; return _node.getChild().name;
} }
public void setVirtualFullName(String string) public void setVirtualFullName(String string)
{ {
_node.getChild().renameTo(string); _node.getChild().renameTo(string);
} }
@ -94,8 +97,8 @@ public class LocalVirtualFile extends LocalFile implements IVirtualRemoteFile
{ {
return _node.getChild().getSize(); return _node.getChild().getSize();
} }
public void setVirtualFullPath(String string) public void setVirtualFullPath(String string)
{ {
if (string.equals("")) //$NON-NLS-1$ 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$ 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$ _node.getChild().renameTo(_node.getChild().path + "/" + string); //$NON-NLS-1$
} }
} }
public File getFileWrapper() public File getFileWrapper()
{ {
return _node.getFile(); return _node.getFile();
} }
public boolean canRead() public boolean canRead()
{ {
return _parentArchive.canRead(); return _parentArchive.canRead();
} }
public boolean canWrite() public boolean canWrite()
{ {
return _parentArchive.canWrite(); return _parentArchive.canWrite();
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile#getComment() * @see org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile#getComment()
*/ */
public String getComment() public String getComment()
{ {
return _node.getChild().getComment(); return _node.getChild().getComment();
} }
@ -145,7 +148,7 @@ public class LocalVirtualFile extends LocalFile implements IVirtualRemoteFile
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile#getCompressedSize() * @see org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile#getCompressedSize()
*/ */
public long getCompressedSize() public long getCompressedSize()
{ {
return _node.getChild().getCompressedSize(); return _node.getChild().getCompressedSize();
} }
@ -153,7 +156,7 @@ public class LocalVirtualFile extends LocalFile implements IVirtualRemoteFile
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile#getCompressionMethod() * @see org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile#getCompressionMethod()
*/ */
public String getCompressionMethod() public String getCompressionMethod()
{ {
return _node.getChild().getCompressionMethod(); return _node.getChild().getCompressionMethod();
} }
@ -161,35 +164,40 @@ public class LocalVirtualFile extends LocalFile implements IVirtualRemoteFile
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile#getCompressionRatio() * @see org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile#getCompressionRatio()
*/ */
public double getCompressionRatio() public double getCompressionRatio()
{ {
return _node.getChild().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(); return _node.getChild().getContainingArchive().getAbsolutePath();
} }
public long getExpandedSize() public long getExpandedSize()
{ {
return _node.getSize(); return _node.getSize();
} }
public boolean isVirtualFile() public boolean isVirtualFile()
{ {
return !_node.getChild().isDirectory; return !_node.getChild().isDirectory;
} }
public boolean isVirtualFolder() public boolean isVirtualFolder()
{ {
return _node.getChild().isDirectory; return _node.getChild().isDirectory;
} }