use of org.springframework.hateoas.ResourceSupport in project CzechIdMng by bcvsolutions.
the class VsRequestController method get.
@Override
@ResponseBody
@RequestMapping(value = "/{backendId}", method = RequestMethod.GET)
@PreAuthorize("hasAuthority('" + VirtualSystemGroupPermission.VS_REQUEST_READ + "')")
@ApiOperation(value = "Request detail", nickname = "getRequest", response = VsRequestDto.class, tags = { VsRequestController.TAG }, authorizations = { @Authorization(value = SwaggerConfig.AUTHENTICATION_BASIC, scopes = { @AuthorizationScope(scope = VirtualSystemGroupPermission.VS_REQUEST_READ, description = "") }), @Authorization(value = SwaggerConfig.AUTHENTICATION_CIDMST, scopes = { @AuthorizationScope(scope = VirtualSystemGroupPermission.VS_REQUEST_READ, description = "") }) })
public ResponseEntity<?> get(@ApiParam(value = "Request's uuid identifier.", required = true) @PathVariable @NotNull String backendId) {
VsRequestDto request = this.getDto(backendId);
if (request == null) {
throw new EntityNotFoundException(getService().getEntityClass(), backendId);
}
UUID roleRequestId = request.getRoleRequestId();
if (roleRequestId != null) {
IdmRoleRequestDto roleRequestDto = rolerequestService.get(roleRequestId);
if (roleRequestDto != null) {
UUID roleRequestCreatorId = roleRequestDto.getCreatorId();
if (roleRequestCreatorId != null) {
IdmIdentityDto roleRequestCreator = identityService.get(roleRequestCreatorId);
roleRequestDto.getEmbedded().put(Auditable.PROPERTY_CREATOR, roleRequestCreator);
}
request.getEmbedded().put(IdmConceptRoleRequestService.ROLE_REQUEST_FIELD, roleRequestDto);
}
}
ResourceSupport resource = toResource(request);
if (resource == null) {
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
//
return new ResponseEntity<>(resource, HttpStatus.OK);
}
use of org.springframework.hateoas.ResourceSupport in project tutorials by eugenp.
the class IndexController method index.
@GetMapping
public ResourceSupport index() {
ResourceSupport index = new ResourceSupport();
index.add(linkTo(CRUDController.class).withRel("crud"));
return index;
}
use of org.springframework.hateoas.ResourceSupport in project spring-boot by spring-projects.
the class LinksEnhancerTests method hrefNotAddedToRelTwice.
@Test
public void hrefNotAddedToRelTwice() throws Exception {
MvcEndpoint endpoint = new TestMvcEndpoint(new TestEndpoint("a"));
MvcEndpoint otherEndpoint = new TestMvcEndpoint(new TestEndpoint("a"));
LinksEnhancer enhancer = getLinksEnhancer(Arrays.asList(endpoint, otherEndpoint));
ResourceSupport support = new ResourceSupport();
enhancer.addEndpointLinks(support, "");
assertThat(support.getLinks()).haveExactly(1, getCondition("a", "a"));
}
use of org.springframework.hateoas.ResourceSupport in project connectors-workspace-one by vmware.
the class ConnectorRootController method getRoot.
@GetMapping(path = "/", produces = MediaTypes.HAL_JSON_VALUE)
public ResponseEntity<ResourceSupport> getRoot(HttpServletRequest servletRequest) {
HttpRequest request = new ServletServerHttpRequest(servletRequest);
ResourceSupport resource = new ResourceSupport();
addMetadata(resource, request);
addCards(resource, request);
addImage(resource, request);
addAuth(resource, request);
return ResponseEntity.ok().cacheControl(CacheControl.maxAge(maxAge, unit)).body(resource);
}
use of org.springframework.hateoas.ResourceSupport in project CzechIdMng by bcvsolutions.
the class IdmIdentityController method toResource.
@Override
public ResourceSupport toResource(IdmIdentityDto dto) {
ResourceSupport resource = super.toResource(dto);
//
// add additional links to enable / disable identity
resource.add(ControllerLinkBuilder.linkTo(this.getClass()).slash(dto.getId()).slash("profile").withRel("profile"), ControllerLinkBuilder.linkTo(this.getClass()).slash(dto.getId()).slash("form-values").withRel("form-values"));
//
return resource;
}
Aggregations