Search in sources :

Example 11 with StatusPatch

use of org.apache.syncope.common.lib.patch.StatusPatch 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 12 with StatusPatch

use of org.apache.syncope.common.lib.patch.StatusPatch in project syncope by apache.

the class UserRestClient method reactivate.

public BulkActionResult reactivate(final String etag, final String userKey, final List<StatusBean> statuses) {
    StatusPatch statusPatch = StatusUtils.buildStatusPatch(statuses, true);
    statusPatch.setKey(userKey);
    statusPatch.setType(StatusPatchType.REACTIVATE);
    BulkActionResult result;
    synchronized (this) {
        result = new BulkActionResult();
        Map<String, BulkActionResult.Status> res = result.getResults();
        UserService service = getService(etag, UserService.class);
        @SuppressWarnings("unchecked") ProvisioningResult<UserTO> provisions = (ProvisioningResult<UserTO>) service.status(statusPatch).readEntity(ProvisioningResult.class);
        if (statusPatch.isOnSyncope()) {
            res.put(StringUtils.capitalize(Constants.SYNCOPE), "active".equalsIgnoreCase(provisions.getEntity().getStatus()) ? BulkActionResult.Status.SUCCESS : BulkActionResult.Status.FAILURE);
        }
        for (PropagationStatus status : provisions.getPropagationStatuses()) {
            res.put(status.getResource(), BulkActionResult.Status.valueOf(status.getStatus().name()));
        }
        resetClient(UserService.class);
    }
    return result;
}
Also used : PropagationStatus(org.apache.syncope.common.lib.to.PropagationStatus) UserService(org.apache.syncope.common.rest.api.service.UserService) UserTO(org.apache.syncope.common.lib.to.UserTO) ProvisioningResult(org.apache.syncope.common.lib.to.ProvisioningResult) StatusPatch(org.apache.syncope.common.lib.patch.StatusPatch) PropagationStatus(org.apache.syncope.common.lib.to.PropagationStatus) BulkActionResult(org.apache.syncope.common.lib.to.BulkActionResult)

Aggregations

StatusPatch (org.apache.syncope.common.lib.patch.StatusPatch)12 ProvisioningResult (org.apache.syncope.common.lib.to.ProvisioningResult)7 UserTO (org.apache.syncope.common.lib.to.UserTO)7 BulkActionResult (org.apache.syncope.common.lib.to.BulkActionResult)6 Test (org.junit.jupiter.api.Test)5 AssociationPatch (org.apache.syncope.common.lib.patch.AssociationPatch)3 UserPatch (org.apache.syncope.common.lib.patch.UserPatch)3 ConnObjectTO (org.apache.syncope.common.lib.to.ConnObjectTO)2 MembershipTO (org.apache.syncope.common.lib.to.MembershipTO)2 PropagationStatus (org.apache.syncope.common.lib.to.PropagationStatus)2 ResourceTO (org.apache.syncope.common.lib.to.ResourceTO)2 UserService (org.apache.syncope.common.rest.api.service.UserService)2 AccessControlException (java.security.AccessControlException)1 List (java.util.List)1 Entry (java.util.Map.Entry)1 BadRequestException (javax.ws.rs.BadRequestException)1 Response (javax.ws.rs.core.Response)1 SyncopeClient (org.apache.syncope.client.lib.SyncopeClient)1 BooleanReplacePatchItem (org.apache.syncope.common.lib.patch.BooleanReplacePatchItem)1 AnyTO (org.apache.syncope.common.lib.to.AnyTO)1