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);
}
}
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());
}
}
}
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;
}
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;
}
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());
}
}
}
Aggregations