Search in sources :

Example 11 with BulkActionResult

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;
}
Also used : BulkActionResult(org.apache.syncope.common.lib.to.BulkActionResult)

Example 12 with BulkActionResult

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;
}
Also used : DeassociationPatch(org.apache.syncope.common.lib.patch.DeassociationPatch) BulkActionResult(org.apache.syncope.common.lib.to.BulkActionResult)

Example 13 with BulkActionResult

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;
}
Also used : StatusPatch(org.apache.syncope.common.lib.patch.StatusPatch) BulkActionResult(org.apache.syncope.common.lib.to.BulkActionResult) AssociationPatch(org.apache.syncope.common.lib.patch.AssociationPatch)

Example 14 with BulkActionResult

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;
}
Also used : DeassociationPatch(org.apache.syncope.common.lib.patch.DeassociationPatch) BulkActionResult(org.apache.syncope.common.lib.to.BulkActionResult)

Example 15 with BulkActionResult

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;
}
Also used : BulkActionResult(org.apache.syncope.common.lib.to.BulkActionResult) NotSupportedException(javax.ws.rs.NotSupportedException)

Aggregations

BulkActionResult (org.apache.syncope.common.lib.to.BulkActionResult)18 StatusPatch (org.apache.syncope.common.lib.patch.StatusPatch)6 Date (java.util.Date)3 AssociationPatch (org.apache.syncope.common.lib.patch.AssociationPatch)3 DeassociationPatch (org.apache.syncope.common.lib.patch.DeassociationPatch)3 AnyTO (org.apache.syncope.common.lib.to.AnyTO)3 AttrTO (org.apache.syncope.common.lib.to.AttrTO)3 UserTO (org.apache.syncope.common.lib.to.UserTO)3 NotFoundException (org.apache.syncope.core.persistence.api.dao.NotFoundException)3 BadRequestException (javax.ws.rs.BadRequestException)2 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)2 PropagationStatus (org.apache.syncope.common.lib.to.PropagationStatus)2 ProvisioningResult (org.apache.syncope.common.lib.to.ProvisioningResult)2 UserService (org.apache.syncope.common.rest.api.service.UserService)2 Test (org.junit.jupiter.api.Test)2 SchedulerException (org.quartz.SchedulerException)2 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)2 NotSupportedException (javax.ws.rs.NotSupportedException)1 BooleanReplacePatchItem (org.apache.syncope.common.lib.patch.BooleanReplacePatchItem)1 UserPatch (org.apache.syncope.common.lib.patch.UserPatch)1