use of org.springframework.hateoas.ResourceSupport in project CzechIdMng by bcvsolutions.
the class IdmIdentityProjectionController method get.
@ResponseBody
@RequestMapping(value = "/{backendId}", method = RequestMethod.GET)
@PreAuthorize("hasAuthority('" + CoreGroupPermission.IDENTITY_READ + "')")
@ApiOperation(value = "Identity projection detail", nickname = "getIdentityProjection", response = IdmIdentityProjectionDto.class, tags = { IdmIdentityProjectionController.TAG }, authorizations = { @Authorization(value = SwaggerConfig.AUTHENTICATION_BASIC, scopes = { @AuthorizationScope(scope = CoreGroupPermission.IDENTITY_READ, description = "") }), @Authorization(value = SwaggerConfig.AUTHENTICATION_CIDMST, scopes = { @AuthorizationScope(scope = CoreGroupPermission.IDENTITY_READ, description = "") }) })
public ResponseEntity<?> get(@ApiParam(value = "Identity's uuid identifier or username.", required = true) @PathVariable @NotNull String backendId) {
IdmIdentityProjectionDto dto = getDto(backendId);
if (dto == null) {
throw new EntityNotFoundException(identityService.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 AbstractRequestDtoController method get.
/**
* Returns response DTO by given backendId
*
* @param backendId
* @param requestId
* @return
*/
@ApiOperation(value = "Read record", authorizations = { //
@Authorization(SwaggerConfig.AUTHENTICATION_BASIC), //
@Authorization(SwaggerConfig.AUTHENTICATION_CIDMST) })
public ResponseEntity<?> get(@PathVariable @NotNull String requestId, //
@ApiParam(value = "Record's uuid identifier or unique code, if record supports Codeable interface.", required = true) @PathVariable @NotNull String backendId) {
//
DTO dto = getDto(requestId, backendId);
if (dto == null) {
throw new EntityNotFoundException(getService().getEntityClass(), backendId);
}
ResourceSupport resource = toResource(requestId, 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 AbstractRequestDtoController method put.
/**
* Update DTO by given backendId and convert to response
*
* @param requestId
* @param backendId
* @param dto
* @return
*/
@ApiOperation(value = "Update record", authorizations = { @Authorization(SwaggerConfig.AUTHENTICATION_BASIC), @Authorization(SwaggerConfig.AUTHENTICATION_CIDMST) })
public //
ResponseEntity<?> put(//
@ApiParam(value = "Request ID", required = true) String requestId, //
@ApiParam(value = "Record's uuid identifier or unique code", required = true) String backendId, @ApiParam(value = "Record (dto).", required = true) DTO dto) {
//
DTO updatedDto = getDto(requestId, backendId);
if (updatedDto == null) {
throw new EntityNotFoundException(getService().getEntityClass(), backendId);
}
Requestable resultDto = requestManager.post(requestId, dto, IdmBasePermission.UPDATE);
@SuppressWarnings("unchecked") ResourceSupport resource = toResource(requestId, (DTO) resultDto);
if (resource == null) {
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
return new ResponseEntity<>(resource, HttpStatus.OK);
}
Aggregations