Search in sources :

Example 1 with FlowableForbiddenException

use of com.plumdo.flow.exception.FlowableForbiddenException in project plumdo-work by wengwh.

the class ProcessDefinitionResource method deleteProcessDefinition.

@RequestMapping(value = "/process-definition/{processDefinitionId}", method = RequestMethod.DELETE, produces = "application/json", name = "流程定义删除")
@ResponseStatus(value = HttpStatus.NO_CONTENT)
public void deleteProcessDefinition(@PathVariable String processDefinitionId, @RequestParam(value = "cascade", required = false, defaultValue = "false") Boolean cascade) {
    ProcessDefinition processDefinition = getProcessDefinitionFromRequest(processDefinitionId);
    if (processDefinition.getDeploymentId() == null) {
        throw new FlowableObjectNotFoundException("No found deployment ");
    }
    if (cascade) {
        repositoryService.deleteDeployment(processDefinition.getDeploymentId(), true);
    } else {
        long count = runtimeService.createProcessInstanceQuery().processDefinitionId(processDefinitionId).count();
        if (count != 0) {
            throw new FlowableForbiddenException("Cannot delete a process-definition that have process-instance");
        }
        repositoryService.deleteDeployment(processDefinition.getDeploymentId());
    }
}
Also used : FlowableObjectNotFoundException(org.flowable.engine.common.api.FlowableObjectNotFoundException) ProcessDefinition(org.flowable.engine.repository.ProcessDefinition) FlowableForbiddenException(com.plumdo.flow.exception.FlowableForbiddenException) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

FlowableForbiddenException (com.plumdo.flow.exception.FlowableForbiddenException)1 FlowableObjectNotFoundException (org.flowable.engine.common.api.FlowableObjectNotFoundException)1 ProcessDefinition (org.flowable.engine.repository.ProcessDefinition)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)1