Search in sources :

Example 51 with ResponseStatus

use of org.springframework.web.bind.annotation.ResponseStatus in project plumdo-work by wengwh.

the class ProcessDefinitionAuthorizeResource method createAuthorize.

@RequestMapping(value = "/process-definition/{processDefinitionId}/authorize", method = RequestMethod.POST, name = "流程定义授权创建")
@ResponseStatus(value = HttpStatus.CREATED)
public void createAuthorize(@PathVariable String processDefinitionId, @RequestBody ProcessDefinitionAuthorizeRequest authorizeRequest) {
    ProcessDefinition processDefinition = getProcessDefinitionFromRequest(processDefinitionId);
    validateAuthorizeArguments(authorizeRequest.getIdentityId(), authorizeRequest.getType());
    if (ProcessDefinitionAuthorizeRequest.AUTHORIZE_GROUP.equals(authorizeRequest.getType())) {
        repositoryService.addCandidateStarterGroup(processDefinition.getId(), authorizeRequest.getIdentityId());
    } else if (ProcessDefinitionAuthorizeRequest.AUTHORIZE_USER.equals(authorizeRequest.getType())) {
        repositoryService.addCandidateStarterUser(processDefinition.getId(), authorizeRequest.getIdentityId());
    }
}
Also used : ProcessDefinition(org.flowable.engine.repository.ProcessDefinition) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 52 with ResponseStatus

use of org.springframework.web.bind.annotation.ResponseStatus in project plumdo-work by wengwh.

the class ProcessDefinitionResource method createProcessDefinition.

@RequestMapping(value = "/process-definition", method = RequestMethod.POST, produces = "application/json", name = "流程定义创建")
@ResponseStatus(value = HttpStatus.CREATED)
public ProcessDefinitionResponse createProcessDefinition(@RequestParam(value = "tenantId", required = false) String tenantId, HttpServletRequest request) {
    if (request instanceof MultipartHttpServletRequest == false) {
        throw new FlowableIllegalArgumentException("Multipart request is required");
    }
    MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
    if (multipartRequest.getFileMap().size() == 0) {
        throw new FlowableIllegalArgumentException("Multipart request with file content is required");
    }
    MultipartFile file = multipartRequest.getFileMap().values().iterator().next();
    try {
        DeploymentBuilder deploymentBuilder = repositoryService.createDeployment();
        String fileName = file.getOriginalFilename();
        if (StringUtils.isEmpty(fileName) || !(fileName.endsWith(".bpmn20.xml") || fileName.endsWith(".bpmn") || fileName.toLowerCase().endsWith(".bar") || fileName.toLowerCase().endsWith(".zip"))) {
            fileName = file.getName();
        }
        if (fileName.endsWith(".bpmn20.xml") || fileName.endsWith(".bpmn")) {
            deploymentBuilder.addInputStream(fileName, file.getInputStream());
        } else if (fileName.toLowerCase().endsWith(".bar") || fileName.toLowerCase().endsWith(".zip")) {
            deploymentBuilder.addZipInputStream(new ZipInputStream(file.getInputStream()));
        } else {
            throw new FlowableIllegalArgumentException("File must be of type .bpmn20.xml, .bpmn, .bar or .zip");
        }
        deploymentBuilder.name(fileName);
        if (tenantId != null) {
            deploymentBuilder.tenantId(tenantId);
        }
        String deploymentId = deploymentBuilder.deploy().getId();
        ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().deploymentId(deploymentId).singleResult();
        return restResponseFactory.createProcessDefinitionResponse(processDefinition);
    } catch (Exception e) {
        if (e instanceof FlowableException) {
            throw (FlowableException) e;
        }
        throw new FlowableException(e.getMessage(), e);
    }
}
Also used : MultipartFile(org.springframework.web.multipart.MultipartFile) ZipInputStream(java.util.zip.ZipInputStream) FlowableException(org.flowable.engine.common.api.FlowableException) FlowableIllegalArgumentException(org.flowable.engine.common.api.FlowableIllegalArgumentException) ProcessDefinition(org.flowable.engine.repository.ProcessDefinition) DeploymentBuilder(org.flowable.engine.repository.DeploymentBuilder) FlowableForbiddenException(com.plumdo.flow.exception.FlowableForbiddenException) FlowableException(org.flowable.engine.common.api.FlowableException) FlowableIllegalArgumentException(org.flowable.engine.common.api.FlowableIllegalArgumentException) FlowableObjectNotFoundException(org.flowable.engine.common.api.FlowableObjectNotFoundException) MultipartHttpServletRequest(org.springframework.web.multipart.MultipartHttpServletRequest) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 53 with ResponseStatus

use of org.springframework.web.bind.annotation.ResponseStatus in project plumdo-work by wengwh.

the class ModelDeployResource method deployModel.

@RequestMapping(value = "/model/{modelId}/deploy", method = RequestMethod.POST, produces = "application/json", name = "模型部署")
@ResponseStatus(value = HttpStatus.CREATED)
@Transactional(propagation = Propagation.REQUIRED)
public ProcessDefinitionResponse deployModel(@PathVariable String modelId) {
    Model model = getModelFromRequest(modelId);
    Deployment deployment = managementService.executeCommand(new DeployModelCmd(model.getId()));
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().deploymentId(deployment.getId()).singleResult();
    return restResponseFactory.createProcessDefinitionResponse(processDefinition);
}
Also used : Model(org.flowable.engine.repository.Model) Deployment(org.flowable.engine.repository.Deployment) ProcessDefinition(org.flowable.engine.repository.ProcessDefinition) DeployModelCmd(com.plumdo.flow.cmd.DeployModelCmd) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) Transactional(org.springframework.transaction.annotation.Transactional)

Example 54 with ResponseStatus

use of org.springframework.web.bind.annotation.ResponseStatus in project plumdo-work by wengwh.

the class ModelResource method deleteModel.

@RequestMapping(value = "/model/{modelId}", method = RequestMethod.DELETE, name = "模型删除")
@ResponseStatus(value = HttpStatus.NO_CONTENT)
public void deleteModel(@PathVariable String modelId) {
    Model model = getModelFromRequest(modelId);
    repositoryService.deleteModel(model.getId());
}
Also used : Model(org.flowable.engine.repository.Model) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 55 with ResponseStatus

use of org.springframework.web.bind.annotation.ResponseStatus in project plumdo-work by wengwh.

the class FormDefinitionJsonResource method getEditorJson.

@ApiOperation(value = "获取表单定义设计内容", notes = "根据表单定义的id来获取表单定义设计内容")
@ApiImplicitParam(name = "id", value = "表单定义ID", required = true, dataType = "Long", paramType = "path")
@RequestMapping(value = "/form-definitions/{id}/json", method = RequestMethod.GET)
@ResponseStatus(value = HttpStatus.OK)
public String getEditorJson(@PathVariable Long id) throws UnsupportedEncodingException {
    FormDefinition formDefinition = getFormDefinitionFromRequest(id);
    String editorJson = null;
    if (formDefinition.getEditorSourceBytes() == null) {
        editorJson = objectMapper.createArrayNode().toString();
    } else {
        editorJson = new String(formDefinition.getEditorSourceBytes(), "utf-8");
    }
    return editorJson;
}
Also used : FormDefinition(com.plumdo.form.entity.FormDefinition) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) ApiOperation(io.swagger.annotations.ApiOperation) ApiImplicitParam(io.swagger.annotations.ApiImplicitParam) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)149 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)118 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)36 ApiOperation (io.swagger.annotations.ApiOperation)31 WebMessageException (org.hisp.dhis.dxf2.webmessage.WebMessageException)26 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)19 GetMapping (org.springframework.web.bind.annotation.GetMapping)18 ApiResponses (io.swagger.annotations.ApiResponses)14 User (org.hisp.dhis.user.User)14 Transactional (org.springframework.transaction.annotation.Transactional)14 Date (java.util.Date)13 Configuration (org.hisp.dhis.configuration.Configuration)12 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)12 Period (org.hisp.dhis.period.Period)11 ArrayList (java.util.ArrayList)10 QualifiedName (com.netflix.metacat.common.QualifiedName)9 ApiOperation (com.wordnik.swagger.annotations.ApiOperation)9 ApiImplicitParam (io.swagger.annotations.ApiImplicitParam)9 Calendar (java.util.Calendar)9 Task (org.flowable.engine.task.Task)8