Search in sources :

Example 11 with DeassociationPatch

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

the class UserITCase method unlink.

@Test
public void unlink() {
    UserTO userTO = getUniqueSampleTO("unlink@syncope.apache.org");
    userTO.getResources().clear();
    userTO.getMemberships().clear();
    userTO.getVirAttrs().clear();
    userTO.getAuxClasses().add("csv");
    userTO.getResources().add(RESOURCE_NAME_CSV);
    UserTO actual = createUser(userTO).getEntity();
    assertNotNull(actual);
    assertNotNull(resourceService.readConnObject(RESOURCE_NAME_CSV, AnyTypeKind.USER.name(), actual.getKey()));
    DeassociationPatch deassociationPatch = new DeassociationPatch.Builder().key(actual.getKey()).action(ResourceDeassociationAction.UNLINK).resource(RESOURCE_NAME_CSV).build();
    assertNotNull(userService.deassociate(deassociationPatch).readEntity(BulkActionResult.class));
    actual = userService.read(actual.getKey());
    assertNotNull(actual);
    assertTrue(actual.getResources().isEmpty());
    assertNotNull(resourceService.readConnObject(RESOURCE_NAME_CSV, AnyTypeKind.USER.name(), actual.getKey()));
}
Also used : DeassociationPatch(org.apache.syncope.common.lib.patch.DeassociationPatch) UserTO(org.apache.syncope.common.lib.to.UserTO) BulkActionResult(org.apache.syncope.common.lib.to.BulkActionResult) Test(org.junit.jupiter.api.Test)

Example 12 with DeassociationPatch

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

use of org.apache.syncope.common.lib.patch.DeassociationPatch 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)

Aggregations

DeassociationPatch (org.apache.syncope.common.lib.patch.DeassociationPatch)13 BulkActionResult (org.apache.syncope.common.lib.to.BulkActionResult)13 Test (org.junit.jupiter.api.Test)10 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)7 UserTO (org.apache.syncope.common.lib.to.UserTO)6 AccessControlException (java.security.AccessControlException)5 GroupTO (org.apache.syncope.common.lib.to.GroupTO)5 NamingException (javax.naming.NamingException)3 ForbiddenException (javax.ws.rs.ForbiddenException)3 AssociationPatch (org.apache.syncope.common.lib.patch.AssociationPatch)2 UserPatch (org.apache.syncope.common.lib.patch.UserPatch)2 JdbcTemplate (org.springframework.jdbc.core.JdbcTemplate)2 Map (java.util.Map)1 DataSource (javax.sql.DataSource)1 Response (javax.ws.rs.core.Response)1 SyncopeClient (org.apache.syncope.client.lib.SyncopeClient)1 AttrPatch (org.apache.syncope.common.lib.patch.AttrPatch)1 MembershipPatch (org.apache.syncope.common.lib.patch.MembershipPatch)1 PasswordPatch (org.apache.syncope.common.lib.patch.PasswordPatch)1 AttrTO (org.apache.syncope.common.lib.to.AttrTO)1