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());
}
}
Aggregations