Repository: syncope Updated Branches: refs/heads/master f96afc989 -> 4434d4145
[SYNCOPE-1229] It is now possible to properly delete all task executions Project: http://git-wip-us.apache.org/repos/asf/syncope/repo Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/4434d414 Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/4434d414 Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/4434d414 Branch: refs/heads/master Commit: 4434d414511f9b730616dca0384d71321df971f5 Parents: f96afc9 Author: skylark17 <[email protected]> Authored: Wed Nov 15 09:28:39 2017 +0100 Committer: skylark17 <[email protected]> Committed: Wed Nov 15 09:29:13 2017 +0100 ---------------------------------------------------------------------- .../client/console/bulk/BulkContent.java | 48 ++++++++++++++------ 1 file changed, 35 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/syncope/blob/4434d414/client/console/src/main/java/org/apache/syncope/client/console/bulk/BulkContent.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/bulk/BulkContent.java b/client/console/src/main/java/org/apache/syncope/client/console/bulk/BulkContent.java index 7d52f16..0445f83 100644 --- a/client/console/src/main/java/org/apache/syncope/client/console/bulk/BulkContent.java +++ b/client/console/src/main/java/org/apache/syncope/client/console/bulk/BulkContent.java @@ -41,7 +41,9 @@ import org.apache.syncope.client.console.wicket.markup.html.form.ActionLink.Acti import org.apache.syncope.client.console.wicket.markup.html.form.ActionsPanel; import org.apache.syncope.common.lib.to.BulkAction; import org.apache.syncope.common.lib.to.BulkActionResult; +import org.apache.syncope.common.lib.to.ExecTO; import org.apache.syncope.common.lib.types.StandardEntitlement; +import org.apache.syncope.common.lib.to.BulkActionResult.Status; import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.extensions.ajax.markup.html.repeater.data.table.AjaxFallbackDefaultDataTable; import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn; @@ -137,22 +139,42 @@ public class BulkContent<T extends Serializable, S> extends MultilevelPanel.Seco BulkActionResult res = null; try { - if (items.iterator().next() instanceof StatusBean) { + T singleItem = items.iterator().next(); + if (singleItem instanceof StatusBean) { throw new IllegalArgumentException("Invalid items"); } - final BulkAction bulkAction = new BulkAction(); - bulkAction.setType(BulkAction.Type.valueOf(actionToBeAddresed.name())); - items.forEach(item -> { - try { - bulkAction.getTargets().add(getTargetId(item, keyFieldName).toString()); - } catch (IllegalAccessException | InvocationTargetException e) { - LOG.error("Error retrieving item id {}", keyFieldName, e); - } - }); - res = BulkActionResult.class.cast( - bulkActionExecutor.getClass().getMethod("bulkAction", BulkAction.class).invoke( - bulkActionExecutor, bulkAction)); + if (singleItem instanceof ExecTO) { + res = new BulkActionResult(); + final Map<String, Status> results = res.getResults(); + items.forEach(item -> { + ExecTO exec = ExecTO.class.cast(item); + String key = exec.getKey(); + + try { + bulkActionExecutor.getClass().getMethod("deleteExecution", + String.class).invoke(bulkActionExecutor, exec.getKey()); + results.put(String.valueOf(key), BulkActionResult.Status.SUCCESS); + } catch (Exception e) { + LOG.error("Error deleting execution {} of task {}", exec.getKey(), key, e); + results.put(String.valueOf(key), BulkActionResult.Status.FAILURE); + } + }); + } else { + final BulkAction bulkAction = new BulkAction(); + bulkAction.setType(BulkAction.Type.valueOf(actionToBeAddresed.name())); + items.forEach(item -> { + try { + bulkAction.getTargets().add(getTargetId(item, keyFieldName).toString()); + } catch (IllegalAccessException | InvocationTargetException e) { + LOG.error("Error retrieving item id {}", keyFieldName, e); + } + }); + res = BulkActionResult.class.cast( + bulkActionExecutor.getClass().getMethod("bulkAction", + BulkAction.class).invoke(bulkActionExecutor, bulkAction)); + } + } catch (IllegalArgumentException biae) { if (!(items.iterator().next() instanceof StatusBean)) { throw new IllegalArgumentException("Invalid items");
