1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-24 16:53:50 +02:00

[230919] IFileService.delete() should not return a boolean

This commit is contained in:
Radoslav Gerganov 2008-05-23 08:59:40 +00:00
parent f39dcbdba6
commit c213611074
6 changed files with 36 additions and 23 deletions

View file

@ -44,6 +44,7 @@
* David McKnight (IBM) - [227406][api][dstore] need apis for getting buffer size in IDataStoreProvider * David McKnight (IBM) - [227406][api][dstore] need apis for getting buffer size in IDataStoreProvider
* David McKnight (IBM) - [229610] [api] File transfers should use workspace text file encoding * David McKnight (IBM) - [229610] [api] File transfers should use workspace text file encoding
* David McKnight (IBM) - [221211] [api][breaking][files] need batch operations to indicate which operations were successful * David McKnight (IBM) - [221211] [api][breaking][files] need batch operations to indicate which operations were successful
* Radoslav Gerganov (ProSyst) - [230919] IFileService.delete() should not return a boolean
*******************************************************************************/ *******************************************************************************/
package org.eclipse.rse.internal.services.dstore.files; package org.eclipse.rse.internal.services.dstore.files;
@ -1351,7 +1352,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
} }
public boolean delete(String remoteParent, String fileName, IProgressMonitor monitor) throws SystemMessageException public void delete(String remoteParent, String fileName, IProgressMonitor monitor) throws SystemMessageException
{ {
String remotePath = remoteParent + getSeparator(remoteParent) + fileName; String remotePath = remoteParent + getSeparator(remoteParent) + fileName;
DataElement de = getElementFor(remotePath); DataElement de = getElementFor(remotePath);
@ -1374,7 +1375,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
// When running a server older than 2.0.1 success is not set for directories, so we must // When running a server older than 2.0.1 success is not set for directories, so we must
// check if the source message is an empty string // check if the source message is an empty string
if (sourceMsg.equals(IServiceConstants.SUCCESS) || sourceMsg.equals("")) { //$NON-NLS-1$ if (sourceMsg.equals(IServiceConstants.SUCCESS) || sourceMsg.equals("")) { //$NON-NLS-1$
return true; return;
} }
String msgTxt = NLS.bind(ServiceResources.FILEMSG_DELETE_FILE_FAILED, FileSystemMessageUtil.getSourceLocation(status)); String msgTxt = NLS.bind(ServiceResources.FILEMSG_DELETE_FILE_FAILED, FileSystemMessageUtil.getSourceLocation(status));
String msgDetails = ServiceResources.FILEMSG_DELETE_FILE_FAILED_DETAILS; String msgDetails = ServiceResources.FILEMSG_DELETE_FILE_FAILED_DETAILS;

View file

@ -73,6 +73,7 @@
* David McKnight (IBM) - [216252] [api][nls] Resource Strings specific to subsystems should be moved from rse.ui into files.ui / shells.ui / processes.ui where possible * David McKnight (IBM) - [216252] [api][nls] Resource Strings specific to subsystems should be moved from rse.ui into files.ui / shells.ui / processes.ui where possible
* Javier Montalvo Orus (Symbian) - [212382] additional "initCommands" slot for ftpListingParsers extension point * Javier Montalvo Orus (Symbian) - [212382] additional "initCommands" slot for ftpListingParsers extension point
* Martin Oberhuber (Wind River) - [226262] Make IService IAdaptable * Martin Oberhuber (Wind River) - [226262] Make IService IAdaptable
* Radoslav Gerganov (ProSyst) - [230919] IFileService.delete() should not return a boolean
********************************************************************************/ ********************************************************************************/
package org.eclipse.rse.internal.services.files.ftp; package org.eclipse.rse.internal.services.files.ftp;
@ -111,6 +112,7 @@ import org.eclipse.rse.services.clientserver.IMatcher;
import org.eclipse.rse.services.clientserver.NamePatternMatcher; import org.eclipse.rse.services.clientserver.NamePatternMatcher;
import org.eclipse.rse.services.clientserver.PathUtility; import org.eclipse.rse.services.clientserver.PathUtility;
import org.eclipse.rse.services.clientserver.messages.SimpleSystemMessage; import org.eclipse.rse.services.clientserver.messages.SimpleSystemMessage;
import org.eclipse.rse.services.clientserver.messages.SystemElementNotFoundException;
import org.eclipse.rse.services.clientserver.messages.SystemLockTimeoutException; import org.eclipse.rse.services.clientserver.messages.SystemLockTimeoutException;
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;
@ -1024,7 +1026,7 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.rse.services.files.IFileService#delete(org.eclipse.core.runtime.IProgressMonitor, java.lang.String, java.lang.String) * @see org.eclipse.rse.services.files.IFileService#delete(org.eclipse.core.runtime.IProgressMonitor, java.lang.String, java.lang.String)
*/ */
public boolean delete(String remoteParent, String fileName, IProgressMonitor monitor) throws SystemMessageException { public void delete(String remoteParent, String fileName, IProgressMonitor monitor) throws SystemMessageException {
remoteParent = checkEncoding(remoteParent); remoteParent = checkEncoding(remoteParent);
fileName = checkEncoding(fileName); fileName = checkEncoding(fileName);
@ -1043,12 +1045,12 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil
catch (IOException e) catch (IOException e)
{ {
if (!file.exists()) if (!file.exists())
return false; throw new SystemElementNotFoundException(file.getAbsolutePath(), "delete"); //$NON-NLS-1$
throw new RemoteFileIOException(e); throw new RemoteFileIOException(e);
} }
catch (SystemMessageException e) { catch (SystemMessageException e) {
if (!file.exists()) if (!file.exists())
return false; throw new SystemElementNotFoundException(file.getAbsolutePath(), "delete"); //$NON-NLS-1$
throw e; throw e;
} }
finally { finally {
@ -1060,7 +1062,6 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil
} finally { } finally {
progressMonitor.end(); progressMonitor.end();
} }
return true;
} }
private void internalDelete(FTPClient ftpClient, String parentPath, String fileName, boolean isFile, MyProgressMonitor monitor) private void internalDelete(FTPClient ftpClient, String parentPath, String fileName, boolean isFile, MyProgressMonitor monitor)

View file

@ -37,6 +37,7 @@
* David McKnight (IBM) - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared * David McKnight (IBM) - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared
* Martin Oberhuber (Wind River) - [226262] Make IService IAdaptable * Martin Oberhuber (Wind River) - [226262] Make IService IAdaptable
* David McKnight (IBM) - [231211] Local xml file not opened when workspace encoding is different from local system encoding * David McKnight (IBM) - [231211] Local xml file not opened when workspace encoding is different from local system encoding
* Radoslav Gerganov (ProSyst) - [230919] IFileService.delete() should not return a boolean
*******************************************************************************/ *******************************************************************************/
package org.eclipse.rse.internal.services.local.files; package org.eclipse.rse.internal.services.local.files;
@ -82,6 +83,7 @@ import org.eclipse.rse.services.clientserver.archiveutils.VirtualChild;
import org.eclipse.rse.services.clientserver.messages.CommonMessages; import org.eclipse.rse.services.clientserver.messages.CommonMessages;
import org.eclipse.rse.services.clientserver.messages.ICommonMessageIds; 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.SystemElementNotFoundException;
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.clientserver.messages.SystemOperationCancelledException;
@ -1016,7 +1018,7 @@ public class LocalFileService extends AbstractFileService implements ILocalServi
return new LocalVirtualHostFile(child); return new LocalVirtualHostFile(child);
} }
public boolean delete(String remoteParent, String fileName, IProgressMonitor monitor) throws SystemMessageException public void delete(String remoteParent, String fileName, IProgressMonitor monitor) throws SystemMessageException
{ {
if (fileName.endsWith(ArchiveHandlerManager.VIRTUAL_SEPARATOR)) if (fileName.endsWith(ArchiveHandlerManager.VIRTUAL_SEPARATOR))
{ {
@ -1045,12 +1047,15 @@ public class LocalFileService extends AbstractFileService implements ILocalServi
{ {
result = fileToDelete.delete(); result = fileToDelete.delete();
} }
if (!result && fileToDelete.exists()) { if (!result) {
// Deletion failed without specification why... likely a Security if (fileToDelete.exists()) {
// problem? // Deletion failed without specification why... likely a Security
throw new RemoteFileSecurityException(null); // problem?
throw new RemoteFileSecurityException(null);
} else {
throw new SystemElementNotFoundException(fileToDelete.getAbsolutePath(), "delete"); //$NON-NLS-1$
}
} }
return result;
} }
public void deleteBatch(String[] remoteParents, String[] fileNames, IProgressMonitor monitor) throws SystemMessageException public void deleteBatch(String[] remoteParents, String[] fileNames, IProgressMonitor monitor) throws SystemMessageException

View file

@ -26,6 +26,7 @@
* Martin Oberhuber (Wind River) - [224799] Fix JSch encoding problems with Arabic filenames * Martin Oberhuber (Wind River) - [224799] Fix JSch encoding problems with Arabic filenames
* Martin Oberhuber (Wind River) - [226262] Make IService IAdaptable * Martin Oberhuber (Wind River) - [226262] Make IService IAdaptable
* Martin Oberhuber (Wind River) - [170910] Adopt RSE ITerminalService API for SSH * Martin Oberhuber (Wind River) - [170910] Adopt RSE ITerminalService API for SSH
* Radoslav Gerganov (ProSyst) - [230919] IFileService.delete() should not return a boolean
*******************************************************************************/ *******************************************************************************/
package org.eclipse.rse.internal.services.ssh.files; package org.eclipse.rse.internal.services.ssh.files;
@ -68,6 +69,7 @@ import org.eclipse.rse.services.clientserver.FileTypeMatcher;
import org.eclipse.rse.services.clientserver.IMatcher; import org.eclipse.rse.services.clientserver.IMatcher;
import org.eclipse.rse.services.clientserver.NamePatternMatcher; import org.eclipse.rse.services.clientserver.NamePatternMatcher;
import org.eclipse.rse.services.clientserver.PathUtility; import org.eclipse.rse.services.clientserver.PathUtility;
import org.eclipse.rse.services.clientserver.messages.SystemElementNotFoundException;
import org.eclipse.rse.services.clientserver.messages.SystemLockTimeoutException; import org.eclipse.rse.services.clientserver.messages.SystemLockTimeoutException;
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;
@ -891,7 +893,7 @@ public class SftpFileService extends AbstractFileService implements ISshService,
return result; return result;
} }
public boolean delete(String remoteParent, String fileName, IProgressMonitor monitor) throws SystemMessageException public void delete(String remoteParent, String fileName, IProgressMonitor monitor) throws SystemMessageException
{ {
String fullPath = concat(remoteParent, fileName); String fullPath = concat(remoteParent, fileName);
Activator.trace("SftpFileService.delete.waitForLock"); //$NON-NLS-1$ Activator.trace("SftpFileService.delete.waitForLock"); //$NON-NLS-1$
@ -905,14 +907,16 @@ public class SftpFileService extends AbstractFileService implements ISshService,
//bug 154419: test for dangling symbolic link //bug 154419: test for dangling symbolic link
if (e.id == ChannelSftp.SSH_FX_NO_SUCH_FILE) { if (e.id == ChannelSftp.SSH_FX_NO_SUCH_FILE) {
//simply try to delete --> if it really doesnt exist, this will throw an exception //simply try to delete --> if it really doesnt exist, this will throw an exception
//FIXME either throw SystemElementNotFoundException here OR add check for
//SSH_FX_NO_SUCH_FILE in makeSystemMessageException() and throw SENFE there
getChannel("SftpFileService.delete.rm").rm(fullPathRecoded); //$NON-NLS-1$ getChannel("SftpFileService.delete.rm").rm(fullPathRecoded); //$NON-NLS-1$
} else { } else {
throw e; throw e;
} }
} }
if (attrs==null) { if (attrs==null) {
//doesn't exist, nothing to do //doesn't exist, throw SystemElementNotFoundException
return false; throw new SystemElementNotFoundException(fullPath, "delete"); //$NON-NLS-1$
} else if (attrs.isDir()) { } else if (attrs.isDir()) {
try { try {
getChannel("SftpFileService.delete.rmdir").rmdir(fullPathRecoded); //$NON-NLS-1$ getChannel("SftpFileService.delete.rmdir").rmdir(fullPathRecoded); //$NON-NLS-1$
@ -942,7 +946,6 @@ public class SftpFileService extends AbstractFileService implements ISshService,
} else { } else {
throw new SystemLockTimeoutException(Activator.PLUGIN_ID); throw new SystemLockTimeoutException(Activator.PLUGIN_ID);
} }
return true;
} }
public void rename(String remoteParent, String oldName, String newName, IProgressMonitor monitor) throws SystemMessageException public void rename(String remoteParent, String oldName, String newName, IProgressMonitor monitor) throws SystemMessageException

View file

@ -25,6 +25,7 @@
* Martin Oberhuber (Wind River) - [cleanup] Fix API since tags * Martin Oberhuber (Wind River) - [cleanup] Fix API since tags
* David Dykstal (IBM) - [221211] clarifying javadoc on batch operations * David Dykstal (IBM) - [221211] clarifying javadoc on batch operations
* David Dykstal (IBM) - [221211] fix IFileService API for batch operations * David Dykstal (IBM) - [221211] fix IFileService API for batch operations
* Radoslav Gerganov (ProSyst) - [230919] IFileService.delete() should not return a boolean
*******************************************************************************/ *******************************************************************************/
package org.eclipse.rse.services.files; package org.eclipse.rse.services.files;
@ -410,15 +411,13 @@ public interface IFileService extends IService
* @param remoteParent the folder containing the file to delete * @param remoteParent the folder containing the file to delete
* @param fileName the name of the file or folder to delete * @param fileName the name of the file or folder to delete
* @param monitor the progress monitor * @param monitor the progress monitor
* @return <code>true</code> if the requested element was successfully
* deleted, or <code>false</code> if the element had not existed in the
* first place so the operation was a silent no-op.
* @throws SystemMessageException if an error occurs or the user canceled * @throws SystemMessageException if an error occurs or the user canceled
* the operation. * the operation. SystemElementNotFoundException is thrown if the remote
* file doesn't exist.
* *
* @since org.eclipse.rse.services 3.0 * @since org.eclipse.rse.services 3.0
*/ */
public boolean delete(String remoteParent, String fileName, IProgressMonitor monitor) throws SystemMessageException; public void delete(String remoteParent, String fileName, IProgressMonitor monitor) throws SystemMessageException;
/** /**
* Delete a set of files or folders on the host. Should throw an exception * Delete a set of files or folders on the host. Should throw an exception

View file

@ -13,6 +13,7 @@
* Radoslav Gerganov (ProSyst) - [230850] [WinCE] Implement setLastModified and setReadOnly in WinCEFileService * Radoslav Gerganov (ProSyst) - [230850] [WinCE] Implement setLastModified and setReadOnly in WinCEFileService
* Radoslav Gerganov (ProSyst) - [231425] [WinCE] Use the progress monitors in WinCEFileService * Radoslav Gerganov (ProSyst) - [231425] [WinCE] Use the progress monitors in WinCEFileService
* Radoslav Gerganov (ProSyst) - [230856] [WinCE] Improve the error handling in WinCEFileService * Radoslav Gerganov (ProSyst) - [230856] [WinCE] Improve the error handling in WinCEFileService
* Radoslav Gerganov (ProSyst) - [230919] IFileService.delete() should not return a boolean
*******************************************************************************/ *******************************************************************************/
package org.eclipse.rse.internal.services.wince.files; package org.eclipse.rse.internal.services.wince.files;
@ -36,6 +37,7 @@ import org.eclipse.rse.internal.subsystems.files.wince.Activator;
import org.eclipse.rse.services.clientserver.FileTypeMatcher; import org.eclipse.rse.services.clientserver.FileTypeMatcher;
import org.eclipse.rse.services.clientserver.IMatcher; import org.eclipse.rse.services.clientserver.IMatcher;
import org.eclipse.rse.services.clientserver.NamePatternMatcher; import org.eclipse.rse.services.clientserver.NamePatternMatcher;
import org.eclipse.rse.services.clientserver.messages.SystemElementNotFoundException;
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.clientserver.messages.SystemOperationCancelledException;
import org.eclipse.rse.services.clientserver.messages.SystemUnexpectedErrorException; import org.eclipse.rse.services.clientserver.messages.SystemUnexpectedErrorException;
@ -196,13 +198,16 @@ public class WinCEFileService extends AbstractFileService implements IWinCEServi
} }
} }
public boolean delete(String remoteParent, String fileName, IProgressMonitor monitor) throws SystemMessageException { public void delete(String remoteParent, String fileName, IProgressMonitor monitor) throws SystemMessageException {
String fullPath = concat(remoteParent, fileName); String fullPath = concat(remoteParent, fileName);
IRapiSession session = sessionProvider.getSession(); IRapiSession session = sessionProvider.getSession();
if (monitor == null) { if (monitor == null) {
monitor = new NullProgressMonitor(); monitor = new NullProgressMonitor();
} }
try { try {
if (!exist(session, fullPath)) {
throw new SystemElementNotFoundException(fullPath, "delete"); //$NON-NLS-1$
}
if (isDirectory(session, fullPath)) { if (isDirectory(session, fullPath)) {
// recursive delete if it is a directory // recursive delete if it is a directory
RapiFindData[] allFiles = session.findAllFiles(concat(fullPath, "*"), Rapi.FAF_NAME); //$NON-NLS-1$ RapiFindData[] allFiles = session.findAllFiles(concat(fullPath, "*"), Rapi.FAF_NAME); //$NON-NLS-1$
@ -221,7 +226,6 @@ public class WinCEFileService extends AbstractFileService implements IWinCEServi
} catch (RapiException e) { } catch (RapiException e) {
throw new RemoteFileIOException(e); throw new RemoteFileIOException(e);
} }
return true;
} }
public void download(String remoteParent, String remoteFile, File localFile, boolean isBinary, String hostEncoding, public void download(String remoteParent, String remoteFile, File localFile, boolean isBinary, String hostEncoding,