use of org.apache.syncope.common.lib.to.BulkActionResult in project syncope by apache.
the class ResourceServiceImpl method bulkDeassociation.
@Override
public BulkActionResult bulkDeassociation(final ResourceDeassociationPatch patch) {
AbstractResourceAssociator<? extends AnyTO> associator = patch.getAnyTypeKey().equalsIgnoreCase(AnyTypeKind.USER.name()) ? userLogic : patch.getAnyTypeKey().equalsIgnoreCase(AnyTypeKind.GROUP.name()) ? groupLogic : anyObjectLogic;
BulkActionResult result = new BulkActionResult();
for (String anyKey : patch.getAnyKyes()) {
Set<String> resources = Collections.singleton(patch.getKey());
try {
switch(patch.getAction()) {
case DEPROVISION:
associator.deprovision(anyKey, resources, isNullPriorityAsync());
break;
case UNASSIGN:
associator.unassign(anyKey, resources, isNullPriorityAsync());
break;
case UNLINK:
associator.unlink(anyKey, resources);
break;
default:
}
result.getResults().put(anyKey, BulkActionResult.Status.SUCCESS);
} catch (Exception e) {
LOG.warn("While executing {} on {} {}", patch.getAction(), patch.getAnyTypeKey(), anyKey, e);
result.getResults().put(anyKey, BulkActionResult.Status.FAILURE);
}
}
return result;
}
use of org.apache.syncope.common.lib.to.BulkActionResult in project syncope by apache.
the class AbstractAnyRestClient method unlink.
public BulkActionResult unlink(final String etag, final String key, final List<StatusBean> statuses) {
BulkActionResult result;
synchronized (this) {
AnyService<?> service = getService(etag, getAnyServiceClass());
DeassociationPatch deassociationPatch = new DeassociationPatch.Builder().key(key).action(ResourceDeassociationAction.UNLINK).resources(StatusUtils.buildStatusPatch(statuses).getResources()).build();
result = service.deassociate(deassociationPatch).readEntity(BulkActionResult.class);
resetClient(getAnyServiceClass());
}
return result;
}
use of org.apache.syncope.common.lib.to.BulkActionResult in project syncope by apache.
the class AbstractAnyRestClient method link.
public BulkActionResult link(final String etag, final String key, final List<StatusBean> statuses) {
BulkActionResult result;
synchronized (this) {
AnyService<?> service = getService(etag, getAnyServiceClass());
StatusPatch statusPatch = StatusUtils.buildStatusPatch(statuses);
AssociationPatch associationPatch = new AssociationPatch.Builder().key(key).action(ResourceAssociationAction.LINK).onSyncope(statusPatch.isOnSyncope()).resources(statusPatch.getResources()).build();
result = service.associate(associationPatch).readEntity(BulkActionResult.class);
resetClient(getAnyServiceClass());
}
return result;
}
use of org.apache.syncope.common.lib.to.BulkActionResult in project syncope by apache.
the class AbstractAnyRestClient method unassign.
public BulkActionResult unassign(final String etag, final String key, final List<StatusBean> statuses) {
BulkActionResult result;
synchronized (this) {
AnyService<?> service = getService(etag, getAnyServiceClass());
DeassociationPatch deassociationPatch = new DeassociationPatch.Builder().key(key).action(ResourceDeassociationAction.UNASSIGN).resources(StatusUtils.buildStatusPatch(statuses).getResources()).build();
result = service.deassociate(deassociationPatch).readEntity(BulkActionResult.class);
resetClient(getAnyServiceClass());
}
return result;
}
use of org.apache.syncope.common.lib.to.BulkActionResult in project syncope by apache.
the class ReportRestClient method bulkAction.
public BulkActionResult bulkAction(final BulkAction action) {
BulkActionResult result = new BulkActionResult();
switch(action.getType()) {
case DELETE:
for (String target : action.getTargets()) {
delete(target);
result.getResults().put(target, BulkActionResult.Status.SUCCESS);
}
break;
case EXECUTE:
for (String target : action.getTargets()) {
startExecution(target, null);
result.getResults().put(target, BulkActionResult.Status.SUCCESS);
}
break;
default:
throw new NotSupportedException(action.getType().name());
}
return result;
}
Aggregations