Search in sources :

Example 6 with RevisionDoesNotExistException

use of org.hibernate.envers.exception.RevisionDoesNotExistException in project CzechIdMng by bcvsolutions.

the class IdmRoleController method findRevision.

@ResponseBody
@RequestMapping(value = "{backendId}/revisions/{revId}", method = RequestMethod.GET)
@PreAuthorize("hasAuthority('" + CoreGroupPermission.ROLE_READ + "')")
@ApiOperation(value = "Role audit - read revision detail", nickname = "getRoleRevision", tags = { IdmIdentityController.TAG }, authorizations = { @Authorization(value = SwaggerConfig.AUTHENTICATION_BASIC, scopes = { @AuthorizationScope(scope = CoreGroupPermission.ROLE_READ, description = "") }), @Authorization(value = SwaggerConfig.AUTHENTICATION_CIDMST, scopes = { @AuthorizationScope(scope = CoreGroupPermission.ROLE_READ, description = "") }) })
public ResponseEntity<?> findRevision(@ApiParam(value = "Role's uuid identifier or code.", required = true) @PathVariable("backendId") String backendId, @ApiParam(value = "Revision identifier.", required = true) @PathVariable("revId") Long revId) {
    IdmRoleDto originalDto = getDto(backendId);
    if (originalDto == null) {
        throw new ResultCodeException(CoreResultCode.NOT_FOUND, ImmutableMap.of("role", backendId));
    }
    // 
    IdmRole revisionRole;
    try {
        revisionRole = this.auditService.findRevision(IdmRole.class, originalDto.getId(), revId);
    // checkAccess(revisionRole, IdmBasePermission.READ);
    } catch (RevisionDoesNotExistException ex) {
        throw new ResultCodeException(CoreResultCode.NOT_FOUND, ImmutableMap.of("revision", backendId), ex);
    }
    // TODO: dto
    return new ResponseEntity<>(revisionRole, HttpStatus.OK);
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) ResponseEntity(org.springframework.http.ResponseEntity) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) IdmRole(eu.bcvsolutions.idm.core.model.entity.IdmRole) RevisionDoesNotExistException(org.hibernate.envers.exception.RevisionDoesNotExistException) 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

RevisionDoesNotExistException (org.hibernate.envers.exception.RevisionDoesNotExistException)6 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)3 ApiOperation (io.swagger.annotations.ApiOperation)3 NonUniqueResultException (org.hibernate.NonUniqueResultException)3 AuditException (org.hibernate.envers.exception.AuditException)3 ResponseEntity (org.springframework.http.ResponseEntity)3 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)3 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)1 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)1 IdmTreeNodeDto (eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto)1 IdmIdentity (eu.bcvsolutions.idm.core.model.entity.IdmIdentity)1 IdmRole (eu.bcvsolutions.idm.core.model.entity.IdmRole)1 IdmTreeNode (eu.bcvsolutions.idm.core.model.entity.IdmTreeNode)1 Date (java.util.Date)1 HashSet (java.util.HashSet)1