From 810b8008ba14264e3db94571bb8a7a5c4cc0ce52 Mon Sep 17 00:00:00 2001 From: Kushal Munir < kmunir@ca.ibm.com> Date: Thu, 9 Nov 2006 13:37:23 +0000 Subject: [PATCH] Bug 163565: Multiple files are not deleted when one of them fails to be deleted --- .../src/org/eclipse/rse/services/files/IFileService.java | 4 +++- .../files/core/subsystems/IRemoteFileSubSystem.java | 3 ++- .../UI/org/eclipse/rse/internal/ui/view/SystemView.java | 9 +++++++++ .../eclipse/rse/ui/view/ISystemViewElementAdapter.java | 5 ++++- .../UI/org/eclipse/rse/ui/view/SystemView.java | 9 +++++++++ 5 files changed, 27 insertions(+), 3 deletions(-) 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 00453c48501..b7867b58482 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 @@ -184,7 +184,9 @@ public interface IFileService extends IService public boolean delete(IProgressMonitor monitor, String remoteParent, String fileName) throws SystemMessageException; /** - * Deletes a set of files or folders on the host + * Deletes a set of files or folders on the host. Should throw an exception if some files and folders were deleted and others were not + * due to an exception during the operation. Without an exception thrown in such cases, views may not be refreshed correctly to account + * for deleted resources. * @param monitor the progress monitor * @param remoteParents the array of folders containing the files to delete * @param fileNames the names of the files or folders to delete 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 2c1816128c9..6ef28becff5 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 @@ -313,7 +313,8 @@ public interface IRemoteFileSubSystem extends ISubSystem{ * - * + * Should throw an exception if some files and folders were deleted and others were not due to an exception during the operation. + * Without an exception thrown in such cases, views may not be refreshed correctly to account for deleted resources. * @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. diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemView.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemView.java index 5555d47ba97..f2af2f58542 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemView.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemView.java @@ -4337,6 +4337,8 @@ public class SystemView extends TreeViewer implements ISystemTree, ISystemResour boolean ok = true; boolean anyOk = false; Vector deletedVector = new Vector(); + + // keep track of the current set SystemRemoteElementResourceSet set = null; try { @@ -4359,7 +4361,10 @@ public class SystemView extends TreeViewer implements ISystemTree, ISystemResour ISystemViewElementAdapter srcAdapter = set.getAdapter(); if (srcSubSystem != null) { + + // this call can throw an exception ok = srcAdapter.doDeleteBatch(getShell(), set.getResourceSet(), monitor); + if (ok) { anyOk = true; deletedVector.addAll(set.getResourceSet()); @@ -4377,6 +4382,10 @@ public class SystemView extends TreeViewer implements ISystemTree, ISystemResour // refresh all parents if selection is remote objects if (selectionIsRemoteObject) { + // we only need to iterate over the last set in the list of sets since presumably the sets before did not cause any exceptions + // if elements in the list before were deleted successfully, then the code after this catch block will handle them (by firing delete events) + // for the current set that caused the exception, we refresh the parents of the elements in the set (since we don't know which + // elements in the set may have been deleted successfully before the exception occurred). if (set != null) { List list = set.getResourceSet(); diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/ISystemViewElementAdapter.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/ISystemViewElementAdapter.java index 32b50bba543..a3264d9f33e 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/ISystemViewElementAdapter.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/ISystemViewElementAdapter.java @@ -235,7 +235,10 @@ public interface ISystemViewElementAdapter extends IPropertySource, ISystemDragD throws Exception; /** - * Perform the delete on the given set of items. This is after the user has been asked to confirm deletion. + * Perform the delete on the given set of items. This is after the user has been asked to confirm deletion. Should throw an exception + * if some elements were deleted and others were not due to an exception during the operation. Without an exception + * thrown in such cases, views may not be refreshed correctly to account for deleted resources. + * @return true if the delete was successful, false if it was not. */ public boolean doDeleteBatch(Shell shell, List resourceSet, IProgressMonitor monitor) throws Exception; diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/SystemView.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/SystemView.java index 5555d47ba97..f2af2f58542 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/SystemView.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/view/SystemView.java @@ -4337,6 +4337,8 @@ public class SystemView extends TreeViewer implements ISystemTree, ISystemResour boolean ok = true; boolean anyOk = false; Vector deletedVector = new Vector(); + + // keep track of the current set SystemRemoteElementResourceSet set = null; try { @@ -4359,7 +4361,10 @@ public class SystemView extends TreeViewer implements ISystemTree, ISystemResour ISystemViewElementAdapter srcAdapter = set.getAdapter(); if (srcSubSystem != null) { + + // this call can throw an exception ok = srcAdapter.doDeleteBatch(getShell(), set.getResourceSet(), monitor); + if (ok) { anyOk = true; deletedVector.addAll(set.getResourceSet()); @@ -4377,6 +4382,10 @@ public class SystemView extends TreeViewer implements ISystemTree, ISystemResour // refresh all parents if selection is remote objects if (selectionIsRemoteObject) { + // we only need to iterate over the last set in the list of sets since presumably the sets before did not cause any exceptions + // if elements in the list before were deleted successfully, then the code after this catch block will handle them (by firing delete events) + // for the current set that caused the exception, we refresh the parents of the elements in the set (since we don't know which + // elements in the set may have been deleted successfully before the exception occurred). if (set != null) { List list = set.getResourceSet();