use of org.springframework.hateoas.ResourceSupport in project CzechIdMng by bcvsolutions.
the class AbstractReadDtoController method get.
/**
* Returns response DTO by given backendId
*
* @param backendId
* @return
*/
@ApiOperation(value = "Read record", authorizations = { @Authorization(SwaggerConfig.AUTHENTICATION_BASIC), @Authorization(SwaggerConfig.AUTHENTICATION_CIDMST) })
public ResponseEntity<?> get(@ApiParam(value = "Record's uuid identifier or unique code, if record supports Codeable interface.", required = true) @PathVariable @NotNull String backendId) {
DTO dto = getDto(backendId);
if (dto == null) {
throw new EntityNotFoundException(getService().getEntityClass(), backendId);
}
ResourceSupport resource = toResource(dto);
if (resource == null) {
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
//
return new ResponseEntity<>(resource, HttpStatus.OK);
}
use of org.springframework.hateoas.ResourceSupport in project CzechIdMng by bcvsolutions.
the class IdmRoleRequestController method startRequest.
@ResponseBody
@RequestMapping(value = "/{backendId}/start", method = RequestMethod.PUT)
@PreAuthorize("hasAuthority('" + CoreGroupPermission.ROLE_REQUEST_UPDATE + "')")
@ApiOperation(value = "Start role request. Returns request doesn't contains concepts (from version 9.7.0!).", nickname = "startRoleRequest", response = IdmRoleRequestDto.class, tags = { IdmRoleRequestController.TAG }, authorizations = { @Authorization(value = SwaggerConfig.AUTHENTICATION_BASIC, scopes = { @AuthorizationScope(scope = CoreGroupPermission.ROLE_REQUEST_UPDATE, description = "") }), @Authorization(value = SwaggerConfig.AUTHENTICATION_CIDMST, scopes = { @AuthorizationScope(scope = CoreGroupPermission.ROLE_REQUEST_UPDATE, description = "") }) })
public ResponseEntity<?> startRequest(@ApiParam(value = "Role request's uuid identifier.", required = true) @PathVariable @NotNull String backendId) {
IdmRoleRequestDto requestDto = service.get(backendId, new IdmRoleRequestFilter(true), IdmBasePermission.READ);
// Validate
service.validate(requestDto);
// Start request
Map<String, Serializable> variables = new HashMap<>();
variables.put(RoleRequestApprovalProcessor.CHECK_RIGHT_PROPERTY, Boolean.TRUE);
RoleRequestEvent event = new RoleRequestEvent(RoleRequestEventType.EXCECUTE, requestDto, variables);
event.setPriority(PriorityType.HIGH);
//
requestDto = service.startRequest(event);
if (!requestDto.getState().isTerminatedState()) {
throw new AcceptedException();
}
ResourceSupport resource = toResource(requestDto);
ResponseEntity<ResourceSupport> response = new ResponseEntity<>(resource, HttpStatus.OK);
return response;
}
use of org.springframework.hateoas.ResourceSupport in project CzechIdMng by bcvsolutions.
the class IdmRoleRequestController method get.
@Override
@ResponseBody
@RequestMapping(value = "/{backendId}", method = RequestMethod.GET)
@PreAuthorize("hasAuthority('" + CoreGroupPermission.ROLE_REQUEST_READ + "')")
@ApiOperation(value = "Role request detail. Returns request doesn't contains concepts (from version 9.7.0!).", nickname = "getRoleRequest", response = IdmRoleRequestDto.class, tags = { IdmRoleRequestController.TAG }, authorizations = { @Authorization(value = SwaggerConfig.AUTHENTICATION_BASIC, scopes = { @AuthorizationScope(scope = CoreGroupPermission.ROLE_REQUEST_READ, description = "") }), @Authorization(value = SwaggerConfig.AUTHENTICATION_CIDMST, scopes = { @AuthorizationScope(scope = CoreGroupPermission.ROLE_REQUEST_READ, description = "") }) })
public ResponseEntity<?> get(@ApiParam(value = "Role request's uuid identifier.", required = true) @PathVariable @NotNull String backendId) {
//
IdmRoleRequestFilter filter = new IdmRoleRequestFilter();
filter.setIncludeApprovers(true);
IdmRoleRequestDto requestDto = getService().get(backendId, filter, IdmBasePermission.READ);
if (requestDto == null) {
throw new EntityNotFoundException(getService().getEntityClass(), backendId);
}
ResourceSupport resource = toResource(requestDto);
if (resource == null) {
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
return new ResponseEntity<>(resource, HttpStatus.OK);
}
use of org.springframework.hateoas.ResourceSupport in project CzechIdMng by bcvsolutions.
the class AbstractRequestDtoController method post.
/**
* Post DTO and convert to response
*
* @param dto
* @param requestId
* @return
*/
@ApiOperation(value = "Create / update record", authorizations = { //
@Authorization(SwaggerConfig.AUTHENTICATION_BASIC), //
@Authorization(SwaggerConfig.AUTHENTICATION_CIDMST) })
public //
ResponseEntity<?> post(//
@ApiParam(value = "Request ID", required = true) String requestId, @ApiParam(value = "Record (dto).", required = true) DTO dto) {
//
Requestable resultDto = requestManager.post(requestId, dto, IdmBasePermission.CREATE);
@SuppressWarnings("unchecked") ResourceSupport resource = toResource(requestId, (DTO) resultDto);
if (resource == null) {
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
return new ResponseEntity<>(resource, HttpStatus.CREATED);
}
use of org.springframework.hateoas.ResourceSupport in project CzechIdMng by bcvsolutions.
the class AbstractRequestDtoController method delete.
/**
* Deletes DTO by given id
*
* @param requestId
* @param backendId
* @return
*/
@ApiOperation(value = "Delete record", authorizations = { @Authorization(SwaggerConfig.AUTHENTICATION_BASIC), @Authorization(SwaggerConfig.AUTHENTICATION_CIDMST) })
public //
ResponseEntity<?> delete(//
@ApiParam(value = "Request ID", required = true) String requestId, @ApiParam(value = "Record's uuid identifier or unique code.", required = true) String backendId) {
//
DTO dto = getDto(requestId, backendId);
if (dto == null) {
throw new EntityNotFoundException(getService().getEntityClass(), backendId);
}
Requestable resultDto = requestManager.delete(requestId, dto, IdmBasePermission.DELETE);
@SuppressWarnings("unchecked") ResourceSupport resource = toResource(requestId, (DTO) resultDto);
if (resource == null) {
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
return new ResponseEntity<>(resource, HttpStatus.OK);
}
Aggregations