Search in sources :

Example 1 with ActivitiForbiddenException

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());
}
Also used : ActivitiForbiddenException(org.activiti.rest.exception.ActivitiForbiddenException) Task(org.activiti.engine.task.Task) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

Task (org.activiti.engine.task.Task)1 ActivitiForbiddenException (org.activiti.rest.exception.ActivitiForbiddenException)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1