use of org.apache.syncope.common.lib.to.BulkActionResult in project syncope by apache.
the class AbstractAnyService method deassociate.
@Override
public Response deassociate(final DeassociationPatch patch) {
Date etagDate = findLastChange(patch.getKey());
checkETag(String.valueOf(etagDate.getTime()));
ProvisioningResult<TO> updated;
switch(patch.getAction()) {
case UNLINK:
updated = new ProvisioningResult<>();
updated.setEntity(getAnyLogic().unlink(patch.getKey(), patch.getResources()));
break;
case UNASSIGN:
updated = getAnyLogic().unassign(patch.getKey(), patch.getResources(), isNullPriorityAsync());
break;
case DEPROVISION:
updated = getAnyLogic().deprovision(patch.getKey(), patch.getResources(), isNullPriorityAsync());
break;
default:
updated = new ProvisioningResult<>();
updated.setEntity(getAnyLogic().read(patch.getKey()));
}
BulkActionResult result = new BulkActionResult();
if (patch.getAction() == ResourceDeassociationAction.UNLINK) {
patch.getResources().forEach(resource -> {
result.getResults().put(resource, updated.getEntity().getResources().contains(resource) ? BulkActionResult.Status.FAILURE : BulkActionResult.Status.SUCCESS);
});
} else {
updated.getPropagationStatuses().forEach(propagationStatusTO -> result.getResults().put(propagationStatusTO.getResource(), BulkActionResult.Status.valueOf(propagationStatusTO.getStatus().toString())));
}
return modificationResponse(result);
}
use of org.apache.syncope.common.lib.to.BulkActionResult in project syncope by apache.
the class TaskServiceImpl method bulk.
@Override
public BulkActionResult bulk(final BulkAction bulkAction) {
BulkActionResult result = new BulkActionResult();
switch(bulkAction.getType()) {
case DELETE:
for (String key : bulkAction.getTargets()) {
try {
result.getResults().put(logic.delete(null, key).getKey(), BulkActionResult.Status.SUCCESS);
} catch (Exception e) {
LOG.error("Error performing delete for task {}", key, e);
result.getResults().put(key, BulkActionResult.Status.FAILURE);
}
}
break;
case DRYRUN:
for (String key : bulkAction.getTargets()) {
try {
logic.execute(key, null, true);
result.getResults().put(key, BulkActionResult.Status.SUCCESS);
} catch (Exception e) {
LOG.error("Error performing dryrun for task {}", key, e);
result.getResults().put(key, BulkActionResult.Status.FAILURE);
}
}
break;
case EXECUTE:
for (String key : bulkAction.getTargets()) {
try {
logic.execute(key, null, false);
result.getResults().put(key, BulkActionResult.Status.SUCCESS);
} catch (Exception e) {
LOG.error("Error performing execute for task {}", key, e);
result.getResults().put(key, BulkActionResult.Status.FAILURE);
}
}
break;
default:
}
return result;
}
use of org.apache.syncope.common.lib.to.BulkActionResult in project syncope by apache.
the class AbstractAnyRestClient method provision.
public BulkActionResult provision(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.PROVISION).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 assign.
public BulkActionResult assign(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.ASSIGN).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 deprovision.
public BulkActionResult deprovision(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.DEPROVISION).resources(StatusUtils.buildStatusPatch(statuses).getResources()).build();
result = service.deassociate(deassociationPatch).readEntity(BulkActionResult.class);
resetClient(getAnyServiceClass());
}
return result;
}
Aggregations