@Override public BulkActionResult bulk(final BulkAction bulkAction) { BulkActionResult result = new BulkActionResult(); if (bulkAction.getType() == BulkAction.Type.DELETE) { for (String name : bulkAction.getTargets()) { try { result.getResults().put(logic.delete(name).getKey(), BulkActionResult.Status.SUCCESS); } catch (Exception e) { LOG.error("Error performing delete for resource {}", name, e); result.getResults().put(name, BulkActionResult.Status.FAILURE); } } } return result; }
@Override public BulkActionResult bulkDeassociation( final String key, final String anyTypeKey, final ResourceDeassociationAction type, final List<AnyKey> keys) { AbstractResourceAssociator<? extends AnyTO> associator = anyTypeKey.equalsIgnoreCase(AnyTypeKind.USER.name()) ? userLogic : anyTypeKey.equalsIgnoreCase(AnyTypeKind.GROUP.name()) ? groupLogic : anyObjectLogic; BulkActionResult result = new BulkActionResult(); for (AnyKey anyKey : keys) { Set<String> resources = Collections.singleton(key); try { switch (type) { case DEPROVISION: associator.deprovision(anyKey.getElement(), resources); break; case UNASSIGN: associator.unassign(anyKey.getElement(), resources); break; case UNLINK: associator.unlink(anyKey.getElement(), resources); break; default: } result .getResults() .put(String.valueOf(anyKey.getElement()), BulkActionResult.Status.SUCCESS); } catch (Exception e) { LOG.warn("While executing {} on {} {}", type, anyTypeKey, anyKey.getElement(), e); result .getResults() .put(String.valueOf(anyKey.getElement()), BulkActionResult.Status.FAILURE); } } return result; }