Search in sources :

Example 21 with IdmAutomaticRoleRequestDto

use of eu.bcvsolutions.idm.core.api.dto.IdmAutomaticRoleRequestDto in project CzechIdMng by bcvsolutions.

the class IdmAutomaticRoleRequestController method delete.

@Override
@ResponseBody
@RequestMapping(value = "/{backendId}", method = RequestMethod.DELETE)
@PreAuthorize("hasAuthority('" + CoreGroupPermission.AUTOMATIC_ROLE_REQUEST_DELETE + "')")
@ApiOperation(value = "Delete role request", nickname = "deleteRoleRequest", tags = { IdmAutomaticRoleRequestController.TAG }, authorizations = { @Authorization(value = SwaggerConfig.AUTHENTICATION_BASIC, scopes = { @AuthorizationScope(scope = CoreGroupPermission.AUTOMATIC_ROLE_REQUEST_DELETE, description = "") }), @Authorization(value = SwaggerConfig.AUTHENTICATION_CIDMST, scopes = { @AuthorizationScope(scope = CoreGroupPermission.AUTOMATIC_ROLE_REQUEST_DELETE, description = "") }) })
public ResponseEntity<?> delete(@ApiParam(value = "Role request's uuid identifier.", required = true) @PathVariable @NotNull String backendId) {
    IdmAutomaticRoleRequestService service = ((IdmAutomaticRoleRequestService) this.getService());
    IdmAutomaticRoleRequestDto dto = service.get(backendId);
    // 
    checkAccess(dto, IdmBasePermission.DELETE);
    // Request in Executed state can not be delete or change
    if (RequestState.EXECUTED == dto.getState()) {
        throw new RoleRequestException(CoreResultCode.ROLE_REQUEST_EXECUTED_CANNOT_DELETE, ImmutableMap.of("request", dto));
    }
    // Only request in Concept state, can be deleted. In others states, will be request set to Canceled state and save.
    if (RequestState.CONCEPT == dto.getState()) {
        service.delete(dto);
    } else {
        service.cancel(dto);
    }
    return new ResponseEntity<Object>(HttpStatus.NO_CONTENT);
}
Also used : RoleRequestException(eu.bcvsolutions.idm.core.api.exception.RoleRequestException) ResponseEntity(org.springframework.http.ResponseEntity) IdmAutomaticRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmAutomaticRoleRequestDto) IdmAutomaticRoleRequestService(eu.bcvsolutions.idm.core.api.service.IdmAutomaticRoleRequestService) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

IdmAutomaticRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmAutomaticRoleRequestDto)21 AcceptedException (eu.bcvsolutions.idm.core.api.exception.AcceptedException)13 UUID (java.util.UUID)12 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)10 RoleRequestException (eu.bcvsolutions.idm.core.api.exception.RoleRequestException)10 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)9 IdmRoleTreeNodeDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto)8 AbstractCoreWorkflowIntegrationTest (eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest)7 IdmAutomaticRoleAttributeDto (eu.bcvsolutions.idm.core.api.dto.IdmAutomaticRoleAttributeDto)7 IdmAutomaticRoleAttributeRuleDto (eu.bcvsolutions.idm.core.api.dto.IdmAutomaticRoleAttributeRuleDto)7 IdmAutomaticRoleAttributeRuleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmAutomaticRoleAttributeRuleRequestDto)7 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)7 IdmRoleGuaranteeDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleGuaranteeDto)7 Test (org.junit.Test)7 CoreException (eu.bcvsolutions.idm.core.api.exception.CoreException)6 IdmAutomaticRoleRequestService (eu.bcvsolutions.idm.core.api.service.IdmAutomaticRoleRequestService)5 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)5 AutomaticRoleRequestType (eu.bcvsolutions.idm.core.api.domain.AutomaticRoleRequestType)3 RequestOperationType (eu.bcvsolutions.idm.core.api.domain.RequestOperationType)3 RequestState (eu.bcvsolutions.idm.core.api.domain.RequestState)3