Search in sources :

Example 1 with RelationshipTypeTO

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();
}
Also used : RelationshipTypeTO(org.apache.syncope.common.lib.to.RelationshipTypeTO) URI(java.net.URI)

Example 2 with RelationshipTypeTO

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;
}
Also used : RelationshipTypeTO(org.apache.syncope.common.lib.to.RelationshipTypeTO) RelationshipType(org.apache.syncope.core.persistence.api.entity.RelationshipType) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 3 with RelationshipTypeTO

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;
}
Also used : RelationshipTypeTO(org.apache.syncope.common.lib.to.RelationshipTypeTO)

Example 4 with 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());
    }
}
Also used : Response(javax.ws.rs.core.Response) RelationshipTypeService(org.apache.syncope.common.rest.api.service.RelationshipTypeService) RelationshipTypeTO(org.apache.syncope.common.lib.to.RelationshipTypeTO) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) Test(org.junit.jupiter.api.Test)

Example 5 with RelationshipTypeTO

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());
    }
}
Also used : RelationshipTypeTO(org.apache.syncope.common.lib.to.RelationshipTypeTO) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) Test(org.junit.jupiter.api.Test)

Aggregations

RelationshipTypeTO (org.apache.syncope.common.lib.to.RelationshipTypeTO)6 Test (org.junit.jupiter.api.Test)3 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)2 URI (java.net.URI)1 Response (javax.ws.rs.core.Response)1 RelationshipTypeService (org.apache.syncope.common.rest.api.service.RelationshipTypeService)1 NotFoundException (org.apache.syncope.core.persistence.api.dao.NotFoundException)1 RelationshipType (org.apache.syncope.core.persistence.api.entity.RelationshipType)1 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)1