use of org.activiti.rest.exception.ActivitiForbiddenException in project Activiti by Activiti.
the class TaskResource method deleteTask.
@RequestMapping(value = "/runtime/tasks/{taskId}", method = RequestMethod.DELETE)
public void deleteTask(@PathVariable String taskId, @RequestParam(value = "cascadeHistory", required = false) Boolean cascadeHistory, @RequestParam(value = "deleteReason", required = false) String deleteReason, HttpServletResponse response) {
Task taskToDelete = getTaskFromRequest(taskId);
if (taskToDelete.getExecutionId() != null) {
// Can't delete a task that is part of a process instance
throw new ActivitiForbiddenException("Cannot delete a task that is part of a process-instance.");
}
if (cascadeHistory != null) {
// Ignore delete-reason since the task-history (where the reason is recorded) will be deleted anyway
taskService.deleteTask(taskToDelete.getId(), cascadeHistory);
} else {
// Delete with delete-reason
taskService.deleteTask(taskToDelete.getId(), deleteReason);
}
response.setStatus(HttpStatus.NO_CONTENT.value());
}
Aggregations