Search in sources :

Example 11 with ResourceSupport

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);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) EntityNotFoundException(eu.bcvsolutions.idm.core.api.exception.EntityNotFoundException) VsRequestDto(eu.bcvsolutions.idm.vs.dto.VsRequestDto) UUID(java.util.UUID) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) ResourceSupport(org.springframework.hateoas.ResourceSupport) IdmRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto) 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)

Example 12 with ResourceSupport

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;
}
Also used : ResourceSupport(org.springframework.hateoas.ResourceSupport) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 13 with ResourceSupport

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"));
}
Also used : AbstractMvcEndpoint(org.springframework.boot.actuate.endpoint.mvc.AbstractMvcEndpoint) MvcEndpoint(org.springframework.boot.actuate.endpoint.mvc.MvcEndpoint) ResourceSupport(org.springframework.hateoas.ResourceSupport) Test(org.junit.Test)

Example 14 with ResourceSupport

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);
}
Also used : HttpRequest(org.springframework.http.HttpRequest) ServletServerHttpRequest(org.springframework.http.server.ServletServerHttpRequest) ServletServerHttpRequest(org.springframework.http.server.ServletServerHttpRequest) ResourceSupport(org.springframework.hateoas.ResourceSupport) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 15 with ResourceSupport

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;
}
Also used : ResourceSupport(org.springframework.hateoas.ResourceSupport)

Aggregations

ResourceSupport (org.springframework.hateoas.ResourceSupport)18 ApiOperation (io.swagger.annotations.ApiOperation)11 ResponseEntity (org.springframework.http.ResponseEntity)9 EntityNotFoundException (eu.bcvsolutions.idm.core.api.exception.EntityNotFoundException)7 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)6 Test (org.junit.Test)4 AbstractMvcEndpoint (org.springframework.boot.actuate.endpoint.mvc.AbstractMvcEndpoint)4 MvcEndpoint (org.springframework.boot.actuate.endpoint.mvc.MvcEndpoint)4 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)4 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)4 Requestable (eu.bcvsolutions.idm.core.api.domain.Requestable)3 IdmRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto)3 IdmRoleRequestFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleRequestFilter)2 HiddenResourceSupport (org.opentosca.toscana.api.docs.HiddenResourceSupport)2 GetMapping (org.springframework.web.bind.annotation.GetMapping)2 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)1 IdmIdentityProjectionDto (eu.bcvsolutions.idm.core.api.dto.projection.IdmIdentityProjectionDto)1 AcceptedException (eu.bcvsolutions.idm.core.api.exception.AcceptedException)1 RoleRequestEvent (eu.bcvsolutions.idm.core.model.event.RoleRequestEvent)1 VsRequestDto (eu.bcvsolutions.idm.vs.dto.VsRequestDto)1