Search in sources :

Example 1 with AssociationPatch

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

the class GroupITCase method link.

@Test
public void link() {
    GroupTO groupTO = getSampleTO("link");
    groupTO.getResources().clear();
    GroupTO actual = createGroup(groupTO).getEntity();
    assertNotNull(actual);
    try {
        resourceService.readConnObject(RESOURCE_NAME_LDAP, AnyTypeKind.GROUP.name(), actual.getKey());
        fail("This should not happen");
    } catch (Exception e) {
        assertNotNull(e);
    }
    AssociationPatch associationPatch = new AssociationPatch.Builder().key(actual.getKey()).action(ResourceAssociationAction.LINK).resource(RESOURCE_NAME_LDAP).build();
    assertNotNull(groupService.associate(associationPatch).readEntity(BulkActionResult.class));
    actual = groupService.read(actual.getKey());
    assertFalse(actual.getResources().isEmpty());
    try {
        resourceService.readConnObject(RESOURCE_NAME_LDAP, AnyTypeKind.GROUP.name(), actual.getKey());
        fail("This should not happen");
    } catch (Exception e) {
        assertNotNull(e);
    }
}
Also used : BulkActionResult(org.apache.syncope.common.lib.to.BulkActionResult) AssociationPatch(org.apache.syncope.common.lib.patch.AssociationPatch) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) NamingException(javax.naming.NamingException) AccessControlException(java.security.AccessControlException) ForbiddenException(javax.ws.rs.ForbiddenException) GroupTO(org.apache.syncope.common.lib.to.GroupTO) Test(org.junit.jupiter.api.Test)

Example 2 with AssociationPatch

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

the class GroupITCase method deprovisionUnlinked.

@Test
public void deprovisionUnlinked() {
    GroupTO groupTO = getSampleTO("deprovision");
    groupTO.getResources().clear();
    try {
        groupTO = createGroup(groupTO).getEntity();
        assertNotNull(groupTO);
        try {
            resourceService.readConnObject(RESOURCE_NAME_LDAP, AnyTypeKind.GROUP.name(), groupTO.getKey());
            fail("This should not happen");
        } catch (Exception e) {
            assertNotNull(e);
        }
        AssociationPatch associationPatch = new AssociationPatch.Builder().key(groupTO.getKey()).action(ResourceAssociationAction.PROVISION).resource(RESOURCE_NAME_LDAP).build();
        assertNotNull(groupService.associate(associationPatch).readEntity(BulkActionResult.class));
        groupTO = groupService.read(groupTO.getKey());
        assertTrue(groupTO.getResources().isEmpty());
        assertNotNull(resourceService.readConnObject(RESOURCE_NAME_LDAP, AnyTypeKind.GROUP.name(), groupTO.getKey()));
        DeassociationPatch deassociationPatch = new DeassociationPatch.Builder().key(groupTO.getKey()).action(ResourceDeassociationAction.DEPROVISION).resource(RESOURCE_NAME_LDAP).build();
        assertNotNull(groupService.deassociate(deassociationPatch).readEntity(BulkActionResult.class));
        groupTO = groupService.read(groupTO.getKey());
        assertNotNull(groupTO);
        assertTrue(groupTO.getResources().isEmpty());
        try {
            resourceService.readConnObject(RESOURCE_NAME_LDAP, AnyTypeKind.GROUP.name(), groupTO.getKey());
            fail("This should not happen");
        } catch (Exception e) {
            assertNotNull(e);
        }
    } finally {
        if (groupTO.getKey() != null) {
            groupService.delete(groupTO.getKey());
        }
    }
}
Also used : DeassociationPatch(org.apache.syncope.common.lib.patch.DeassociationPatch) BulkActionResult(org.apache.syncope.common.lib.to.BulkActionResult) AssociationPatch(org.apache.syncope.common.lib.patch.AssociationPatch) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) NamingException(javax.naming.NamingException) AccessControlException(java.security.AccessControlException) ForbiddenException(javax.ws.rs.ForbiddenException) GroupTO(org.apache.syncope.common.lib.to.GroupTO) Test(org.junit.jupiter.api.Test)

Example 3 with AssociationPatch

use of org.apache.syncope.common.lib.patch.AssociationPatch 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;
}
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 4 with AssociationPatch

use of org.apache.syncope.common.lib.patch.AssociationPatch 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;
}
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 5 with AssociationPatch

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

the class GroupITCase method assign.

@Test
public void assign() {
    GroupTO groupTO = getSampleTO("assign");
    groupTO.getResources().clear();
    try {
        groupTO = createGroup(groupTO).getEntity();
        assertNotNull(groupTO);
        try {
            resourceService.readConnObject(RESOURCE_NAME_LDAP, AnyTypeKind.GROUP.name(), groupTO.getKey());
            fail("This should not happen");
        } catch (Exception e) {
            assertNotNull(e);
        }
        AssociationPatch associationPatch = new AssociationPatch.Builder().key(groupTO.getKey()).action(ResourceAssociationAction.ASSIGN).resource(RESOURCE_NAME_LDAP).build();
        assertNotNull(groupService.associate(associationPatch).readEntity(BulkActionResult.class));
        groupTO = groupService.read(groupTO.getKey());
        assertFalse(groupTO.getResources().isEmpty());
        assertNotNull(resourceService.readConnObject(RESOURCE_NAME_LDAP, AnyTypeKind.GROUP.name(), groupTO.getKey()));
    } finally {
        if (groupTO.getKey() != null) {
            groupService.delete(groupTO.getKey());
        }
    }
}
Also used : BulkActionResult(org.apache.syncope.common.lib.to.BulkActionResult) AssociationPatch(org.apache.syncope.common.lib.patch.AssociationPatch) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) NamingException(javax.naming.NamingException) AccessControlException(java.security.AccessControlException) ForbiddenException(javax.ws.rs.ForbiddenException) GroupTO(org.apache.syncope.common.lib.to.GroupTO) Test(org.junit.jupiter.api.Test)

Aggregations

AssociationPatch (org.apache.syncope.common.lib.patch.AssociationPatch)11 BulkActionResult (org.apache.syncope.common.lib.to.BulkActionResult)11 AccessControlException (java.security.AccessControlException)8 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)8 Test (org.junit.jupiter.api.Test)8 NamingException (javax.naming.NamingException)4 ForbiddenException (javax.ws.rs.ForbiddenException)4 GroupTO (org.apache.syncope.common.lib.to.GroupTO)4 UserTO (org.apache.syncope.common.lib.to.UserTO)4 StatusPatch (org.apache.syncope.common.lib.patch.StatusPatch)3 DeassociationPatch (org.apache.syncope.common.lib.patch.DeassociationPatch)2