Search in sources :

Example 1 with Resource

use of org.springframework.hateoas.Resource in project CzechIdMng by bcvsolutions.

the class IdmPasswordPolicyController method validate.

/**
 * Validate password by given password policy id
 *
 * @param backendId
 * @return
 */
@RequestMapping(value = "/{backendId}/validate", method = RequestMethod.POST)
@ApiOperation(value = "Validate password", nickname = "validatePassword", response = IdmPasswordValidationDto.class, tags = { IdmPasswordPolicyController.TAG }, notes = "Validate password by password policy.")
public Resource<IdmPasswordValidationDto> validate(@ApiParam(value = "Policy's uuid identifier.", required = true) @PathVariable String backendId, @Valid @RequestBody(required = true) IdmPasswordValidationDto password) {
    IdmPasswordPolicyDto passwordPolicy = getPasswordPolicy(backendId);
    // 
    this.passwordPolicyService.validate(password, passwordPolicy);
    // 
    password.setValid(true);
    // 
    return new Resource<IdmPasswordValidationDto>(password);
}
Also used : IdmPasswordPolicyDto(eu.bcvsolutions.idm.core.api.dto.IdmPasswordPolicyDto) Resource(org.springframework.hateoas.Resource) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with Resource

use of org.springframework.hateoas.Resource in project CzechIdMng by bcvsolutions.

the class WorkflowDefinitionController method post.

/**
 * Upload new deployment to Activiti engine
 *
 * @param name
 * @param fileName
 * @param data
 * @return
 * @throws IOException
 */
@ResponseBody
@RequestMapping(method = RequestMethod.POST)
@PreAuthorize("hasAuthority('" + CoreGroupPermission.WORKFLOW_DEFINITION_CREATE + "') or hasAuthority('" + CoreGroupPermission.WORKFLOW_DEFINITION_UPDATE + "')")
@ApiOperation(value = "Create / update workflow definition", nickname = "postWorkflowDefinition", response = WorkflowDeploymentDto.class, tags = { WorkflowDefinitionController.TAG }, authorizations = { @Authorization(value = SwaggerConfig.AUTHENTICATION_BASIC, scopes = { @AuthorizationScope(scope = CoreGroupPermission.WORKFLOW_DEFINITION_CREATE, description = ""), @AuthorizationScope(scope = CoreGroupPermission.WORKFLOW_DEFINITION_UPDATE, description = "") }), @Authorization(value = SwaggerConfig.AUTHENTICATION_CIDMST, scopes = { @AuthorizationScope(scope = CoreGroupPermission.WORKFLOW_DEFINITION_CREATE, description = ""), @AuthorizationScope(scope = CoreGroupPermission.WORKFLOW_DEFINITION_UPDATE, description = "") }) }, notes = "Upload new deployment to Activiti engine." + " If definition with iven key exists, new deployment version is added." + " All running task instances process with their deployment version." + " Newly added version will be used for new instances.")
public Resource<WorkflowDeploymentDto> post(String name, String fileName, MultipartFile data) throws IOException {
    WorkflowDeploymentDto deployment = deploymentService.create(name, fileName, data.getInputStream());
    Link selfLink = ControllerLinkBuilder.linkTo(this.getClass()).slash(deployment.getId()).withSelfRel();
    return new Resource<WorkflowDeploymentDto>(deployment, selfLink);
}
Also used : InputStreamResource(org.springframework.core.io.InputStreamResource) Resource(org.springframework.hateoas.Resource) WorkflowDeploymentDto(eu.bcvsolutions.idm.core.workflow.api.dto.WorkflowDeploymentDto) Link(org.springframework.hateoas.Link) 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 3 with Resource

use of org.springframework.hateoas.Resource in project CzechIdMng by bcvsolutions.

the class AbstractReadDtoController method toResource.

/**
 * Converts DTO to ResourceSupport
 *
 * @param dto
 * @return
 */
protected ResourceSupport toResource(DTO dto) {
    Link selfLink = ControllerLinkBuilder.linkTo(this.getClass()).slash(dto.getId()).withSelfRel();
    Resource<DTO> resourceSupport = new Resource<DTO>(dto, selfLink);
    return resourceSupport;
}
Also used : Resource(org.springframework.hateoas.Resource) Link(org.springframework.hateoas.Link)

Aggregations

Resource (org.springframework.hateoas.Resource)3 ApiOperation (io.swagger.annotations.ApiOperation)2 Link (org.springframework.hateoas.Link)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 IdmPasswordPolicyDto (eu.bcvsolutions.idm.core.api.dto.IdmPasswordPolicyDto)1 WorkflowDeploymentDto (eu.bcvsolutions.idm.core.workflow.api.dto.WorkflowDeploymentDto)1 InputStreamResource (org.springframework.core.io.InputStreamResource)1 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1