Search in sources :

Example 11 with UserService

use of org.apache.syncope.common.rest.api.service.UserService 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

UserTO (org.apache.syncope.common.lib.to.UserTO)11 UserService (org.apache.syncope.common.rest.api.service.UserService)11 Test (org.junit.jupiter.api.Test)8 ProvisioningResult (org.apache.syncope.common.lib.to.ProvisioningResult)7 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)5 UserPatch (org.apache.syncope.common.lib.patch.UserPatch)5 GenericType (javax.ws.rs.core.GenericType)4 SyncopeClient (org.apache.syncope.client.lib.SyncopeClient)4 Response (javax.ws.rs.core.Response)3 StatusPatch (org.apache.syncope.common.lib.patch.StatusPatch)3 StringReplacePatchItem (org.apache.syncope.common.lib.patch.StringReplacePatchItem)3 BulkActionResult (org.apache.syncope.common.lib.to.BulkActionResult)3 PagedResult (org.apache.syncope.common.lib.to.PagedResult)3 RoleTO (org.apache.syncope.common.lib.to.RoleTO)3 AnyQuery (org.apache.syncope.common.rest.api.beans.AnyQuery)3 AccessControlException (java.security.AccessControlException)2 Map (java.util.Map)2 ForbiddenException (javax.ws.rs.ForbiddenException)2 PasswordPatch (org.apache.syncope.common.lib.patch.PasswordPatch)2 StringPatchItem (org.apache.syncope.common.lib.patch.StringPatchItem)2