use of org.apache.syncope.common.lib.to.RelationshipTypeTO in project syncope by apache.
the class RelationshipTypeServiceImpl method create.
@Override
public Response create(final RelationshipTypeTO anyTypeTO) {
RelationshipTypeTO created = logic.create(anyTypeTO);
URI location = uriInfo.getAbsolutePathBuilder().path(created.getKey()).build();
return Response.created(location).header(RESTHeaders.RESOURCE_KEY, created.getKey()).build();
}
use of org.apache.syncope.common.lib.to.RelationshipTypeTO in project syncope by apache.
the class RelationshipTypeLogic method delete.
@PreAuthorize("hasRole('" + StandardEntitlement.RELATIONSHIPTYPE_DELETE + "')")
public RelationshipTypeTO delete(final String key) {
RelationshipType relationshipType = relationshipTypeDAO.find(key);
if (relationshipType == null) {
LOG.error("Could not find relationshipType '" + key + "'");
throw new NotFoundException(key);
}
RelationshipTypeTO deleted = binder.getRelationshipTypeTO(relationshipType);
relationshipTypeDAO.delete(key);
return deleted;
}
use of org.apache.syncope.common.lib.to.RelationshipTypeTO in project syncope by apache.
the class RelationshipTypeDataBinderImpl method getRelationshipTypeTO.
@Override
public RelationshipTypeTO getRelationshipTypeTO(final RelationshipType relationshipType) {
RelationshipTypeTO relationshipTypeTO = new RelationshipTypeTO();
relationshipTypeTO.setKey(relationshipType.getKey());
relationshipTypeTO.setDescription(relationshipType.getDescription());
return relationshipTypeTO;
}
use of org.apache.syncope.common.lib.to.RelationshipTypeTO in project syncope by apache.
the class RelationshipTypeITCase method crud.
@Test
public void crud() {
RelationshipTypeTO newType = new RelationshipTypeTO();
newType.setKey("new type");
newType.setDescription("description");
Response response = relationshipTypeService.create(newType);
assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatusInfo().getStatusCode());
newType = getObject(response.getLocation(), RelationshipTypeService.class, RelationshipTypeTO.class);
assertNotNull(newType);
assertEquals("description", newType.getDescription());
newType.setDescription("new description");
relationshipTypeService.update(newType);
newType = relationshipTypeService.read(newType.getKey());
assertNotNull(newType);
assertEquals("new description", newType.getDescription());
relationshipTypeService.delete(newType.getKey());
try {
relationshipTypeService.read(newType.getKey());
fail("This should not happen");
} catch (SyncopeClientException e) {
assertEquals(ClientExceptionType.NotFound, e.getType());
}
}
use of org.apache.syncope.common.lib.to.RelationshipTypeTO in project syncope by apache.
the class RelationshipTypeITCase method createInvalidName.
@Test
public void createInvalidName() {
RelationshipTypeTO newType = new RelationshipTypeTO();
newType.setKey("membership");
try {
relationshipTypeService.create(newType);
fail("This should not happen");
} catch (SyncopeClientException e) {
assertEquals(ClientExceptionType.InvalidRelationshipType, e.getType());
}
}
Aggregations