Package pro.taskana.task.rest
Class TaskController
- java.lang.Object
-
- pro.taskana.task.rest.TaskController
-
@RestController @EnableHypermediaSupport(type=HAL) public class TaskController extends Object
Controller for allTaskrelated endpoints.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTaskController.TaskQuerySortBystatic classTaskController.TaskQuerySortParameter
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.springframework.http.ResponseEntity<TaskRepresentationModel>cancelClaimTask(String taskId)This endpoint cancels the claim of an existing Task if it was claimed by the current user before.org.springframework.http.ResponseEntity<TaskRepresentationModel>cancelTask(String taskId)This endpoint cancels a Task.org.springframework.http.ResponseEntity<TaskRepresentationModel>claimTask(String taskId, String userName)This endpoint claims a Task if possible.org.springframework.http.ResponseEntity<TaskRepresentationModel>completeTask(String taskId)This endpoint completes a Task.org.springframework.http.ResponseEntity<TaskRepresentationModel>createTask(TaskRepresentationModel taskRepresentationModel)This endpoint creates a persistent Task.org.springframework.http.ResponseEntity<TaskRepresentationModel>deleteTask(String taskId)This endpoint deletes a Task.org.springframework.http.ResponseEntity<TaskSummaryCollectionRepresentationModel>deleteTasks(TaskQueryFilterParameter filterParameter)This endpoint deletes an aggregation of Tasks and returns the deleted Tasks.org.springframework.http.ResponseEntity<TaskRepresentationModel>forceCancelClaimTask(String taskId)This endpoint force cancels the claim of an existing Task.org.springframework.http.ResponseEntity<TaskRepresentationModel>getTask(String taskId)This endpoint retrieves a specific Task.org.springframework.http.ResponseEntity<TaskSummaryPagedRepresentationModel>getTasks(javax.servlet.http.HttpServletRequest request, TaskQueryFilterParameter filterParameter, TaskController.TaskQuerySortParameter sortParameter, QueryPagingParameter<pro.taskana.task.api.models.TaskSummary,pro.taskana.task.api.TaskQuery> pagingParameter)This endpoint retrieves a list of existing Tasks.org.springframework.http.ResponseEntity<TaskRepresentationModel>selectAndClaimTask(TaskQueryFilterParameter filterParameter, TaskController.TaskQuerySortParameter sortParameter)This endpoint selects the first Task returned by the Task Query and claims it.org.springframework.http.ResponseEntity<TaskRepresentationModel>transferTask(String taskId, String workbasketId, Boolean setTransferFlag)This endpoint transfers a given Task to a given Workbasket, if possible.org.springframework.http.ResponseEntity<TaskRepresentationModel>updateTask(String taskId, TaskRepresentationModel taskRepresentationModel)This endpoint updates a requested Task.
-
-
-
Method Detail
-
getTasks
@GetMapping(path="/api/v1/tasks") @Transactional(readOnly=true, rollbackFor=java.lang.Exception.class) public org.springframework.http.ResponseEntity<TaskSummaryPagedRepresentationModel> getTasks(javax.servlet.http.HttpServletRequest request, TaskQueryFilterParameter filterParameter, TaskController.TaskQuerySortParameter sortParameter, QueryPagingParameter<pro.taskana.task.api.models.TaskSummary,pro.taskana.task.api.TaskQuery> pagingParameter)This endpoint retrieves a list of existing Tasks. Filters can be applied.- Parameters:
request- the HTTP requestfilterParameter- the filter parameterssortParameter- the sort parameterspagingParameter- the paging parameters- Returns:
- the Tasks with the given filter, sort and paging options.
-
deleteTasks
@DeleteMapping(path="/api/v1/tasks") @Transactional(readOnly=true, rollbackFor=java.lang.Exception.class) public org.springframework.http.ResponseEntity<TaskSummaryCollectionRepresentationModel> deleteTasks(TaskQueryFilterParameter filterParameter) throws pro.taskana.common.api.exceptions.InvalidArgumentException, pro.taskana.common.api.exceptions.NotAuthorizedExceptionThis endpoint deletes an aggregation of Tasks and returns the deleted Tasks. Filters can be applied.- Parameters:
filterParameter- the filter parameters.- Returns:
- the deleted task summaries.
- Throws:
pro.taskana.common.api.exceptions.InvalidArgumentException- TODO: this is never thrownpro.taskana.common.api.exceptions.NotAuthorizedException- if the current user is not authorized to delete the requested Tasks.
-
getTask
@GetMapping(path="/api/v1/tasks/{taskId}") @Transactional(readOnly=true, rollbackFor=java.lang.Exception.class) public org.springframework.http.ResponseEntity<TaskRepresentationModel> getTask(@PathVariable String taskId) throws pro.taskana.task.api.exceptions.TaskNotFoundException, pro.taskana.common.api.exceptions.NotAuthorizedExceptionThis endpoint retrieves a specific Task.- Parameters:
taskId- the Id of the requested Task- Returns:
- the requested Task
- Throws:
pro.taskana.task.api.exceptions.TaskNotFoundException- if the requested Task does not exist.pro.taskana.common.api.exceptions.NotAuthorizedException- if the current user is not authorized to get the requested Task.
-
claimTask
@PostMapping(path="/api/v1/tasks/{taskId}/claim") @Transactional(rollbackFor=java.lang.Exception.class) public org.springframework.http.ResponseEntity<TaskRepresentationModel> claimTask(@PathVariable String taskId, @RequestBody(required=false) String userName) throws pro.taskana.task.api.exceptions.TaskNotFoundException, pro.taskana.task.api.exceptions.InvalidStateException, pro.taskana.task.api.exceptions.InvalidOwnerException, pro.taskana.common.api.exceptions.NotAuthorizedExceptionThis endpoint claims a Task if possible.- Parameters:
taskId- the Id of the Task which should be claimeduserName- TODO: this is currently not used- Returns:
- the claimed Task
- Throws:
pro.taskana.task.api.exceptions.TaskNotFoundException- if the requested Task does not exist.pro.taskana.task.api.exceptions.InvalidStateException- if the state of the requested Task is not READY.pro.taskana.task.api.exceptions.InvalidOwnerException- if the Task is already claimed by someone else.pro.taskana.common.api.exceptions.NotAuthorizedException- if the current user has no read permissions for the requested Task.
-
selectAndClaimTask
@PostMapping(path="/api/v1/tasks/select-and-claim") @Transactional(rollbackFor=java.lang.Exception.class) public org.springframework.http.ResponseEntity<TaskRepresentationModel> selectAndClaimTask(TaskQueryFilterParameter filterParameter, TaskController.TaskQuerySortParameter sortParameter) throws pro.taskana.task.api.exceptions.InvalidOwnerException, pro.taskana.common.api.exceptions.NotAuthorizedException
This endpoint selects the first Task returned by the Task Query and claims it.- Parameters:
filterParameter- the filter parameterssortParameter- the sort parameters- Returns:
- the claimed Task
- Throws:
pro.taskana.task.api.exceptions.InvalidOwnerException- if the Task is already claimed by someone elsepro.taskana.common.api.exceptions.NotAuthorizedException- if the current user has no read permission for the Workbasket the Task is in
-
cancelClaimTask
@DeleteMapping(path="/api/v1/tasks/{taskId}/claim") @Transactional(rollbackFor=java.lang.Exception.class) public org.springframework.http.ResponseEntity<TaskRepresentationModel> cancelClaimTask(@PathVariable String taskId) throws pro.taskana.task.api.exceptions.TaskNotFoundException, pro.taskana.task.api.exceptions.InvalidStateException, pro.taskana.task.api.exceptions.InvalidOwnerException, pro.taskana.common.api.exceptions.NotAuthorizedExceptionThis endpoint cancels the claim of an existing Task if it was claimed by the current user before.- Parameters:
taskId- the Id of the requested Task.- Returns:
- the unclaimed Task.
- Throws:
pro.taskana.task.api.exceptions.TaskNotFoundException- if the requested Task does not exist.pro.taskana.task.api.exceptions.InvalidStateException- if the Task is already in an end state.pro.taskana.task.api.exceptions.InvalidOwnerException- if the Task is claimed by a different user.pro.taskana.common.api.exceptions.NotAuthorizedException- if the current user has no read permission for the Workbasket the Task is in
-
forceCancelClaimTask
@DeleteMapping(path="/api/v1/tasks/{taskId}/claim/force") @Transactional(rollbackFor=java.lang.Exception.class) public org.springframework.http.ResponseEntity<TaskRepresentationModel> forceCancelClaimTask(@PathVariable String taskId) throws pro.taskana.task.api.exceptions.TaskNotFoundException, pro.taskana.task.api.exceptions.InvalidStateException, pro.taskana.task.api.exceptions.InvalidOwnerException, pro.taskana.common.api.exceptions.NotAuthorizedExceptionThis endpoint force cancels the claim of an existing Task.- Parameters:
taskId- the Id of the requested Task.- Returns:
- the unclaimed Task.
- Throws:
pro.taskana.task.api.exceptions.TaskNotFoundException- if the requested Task does not exist.pro.taskana.task.api.exceptions.InvalidStateException- if the Task is already in an end state.pro.taskana.task.api.exceptions.InvalidOwnerException- if the Task is claimed by a different user.pro.taskana.common.api.exceptions.NotAuthorizedException- if the current user has no read permission for the Workbasket the Task is in
-
completeTask
@PostMapping(path="/api/v1/tasks/{taskId}/complete") @Transactional(rollbackFor=java.lang.Exception.class) public org.springframework.http.ResponseEntity<TaskRepresentationModel> completeTask(@PathVariable String taskId) throws pro.taskana.task.api.exceptions.TaskNotFoundException, pro.taskana.task.api.exceptions.InvalidOwnerException, pro.taskana.task.api.exceptions.InvalidStateException, pro.taskana.common.api.exceptions.NotAuthorizedExceptionThis endpoint completes a Task.- Parameters:
taskId- Id of the requested Task to complete.- Returns:
- the completed Task
- Throws:
pro.taskana.task.api.exceptions.TaskNotFoundException- if the requested Task does not exist.pro.taskana.task.api.exceptions.InvalidOwnerException- if current user is not the owner of the Task or an administrator.pro.taskana.task.api.exceptions.InvalidStateException- if Task wasn't claimed previously.pro.taskana.common.api.exceptions.NotAuthorizedException- if the current user has no read permission for the Workbasket the Task is in
-
deleteTask
@DeleteMapping(path="/api/v1/tasks/{taskId}") @Transactional(rollbackFor=java.lang.Exception.class) public org.springframework.http.ResponseEntity<TaskRepresentationModel> deleteTask(@PathVariable String taskId) throws pro.taskana.task.api.exceptions.TaskNotFoundException, pro.taskana.task.api.exceptions.InvalidStateException, pro.taskana.common.api.exceptions.NotAuthorizedExceptionThis endpoint deletes a Task.- Parameters:
taskId- the Id of the Task which should be deleted.- Returns:
- the deleted Task.
- Throws:
pro.taskana.task.api.exceptions.TaskNotFoundException- if the requested Task does not exist.pro.taskana.task.api.exceptions.InvalidStateException- TODO: this is never thrownpro.taskana.common.api.exceptions.NotAuthorizedException- if the current user is not authorized to delete the requested Task.
-
cancelTask
@PostMapping(path="/api/v1/tasks/{taskId}/cancel") @Transactional(rollbackFor=java.lang.Exception.class) public org.springframework.http.ResponseEntity<TaskRepresentationModel> cancelTask(@PathVariable String taskId) throws pro.taskana.task.api.exceptions.TaskNotFoundException, pro.taskana.common.api.exceptions.NotAuthorizedException, pro.taskana.task.api.exceptions.InvalidStateExceptionThis endpoint cancels a Task. Cancellation marks a Task as obsolete. The actual work the Task was referring to is no longer required- Parameters:
taskId- Id of the requested Task to cancel.- Returns:
- the cancelled Task
- Throws:
pro.taskana.task.api.exceptions.TaskNotFoundException- if the requested Task does not exist.pro.taskana.task.api.exceptions.InvalidStateException- if the task is not in state READY or CLAIMEDpro.taskana.common.api.exceptions.NotAuthorizedException- if the current user has no read permission for the Workbasket the Task is in
-
createTask
@PostMapping(path="/api/v1/tasks") @Transactional(rollbackFor=java.lang.Exception.class) public org.springframework.http.ResponseEntity<TaskRepresentationModel> createTask(@RequestBody TaskRepresentationModel taskRepresentationModel) throws pro.taskana.workbasket.api.exceptions.WorkbasketNotFoundException, pro.taskana.classification.api.exceptions.ClassificationNotFoundException, pro.taskana.common.api.exceptions.NotAuthorizedException, pro.taskana.task.api.exceptions.TaskAlreadyExistException, pro.taskana.common.api.exceptions.InvalidArgumentException, pro.taskana.task.api.exceptions.AttachmentPersistenceException, pro.taskana.task.api.exceptions.ObjectReferencePersistenceException
This endpoint creates a persistent Task.- Parameters:
taskRepresentationModel- the Task which should be created.- Returns:
- the created Task
- Throws:
pro.taskana.workbasket.api.exceptions.WorkbasketNotFoundException- if the referenced Workbasket does not existpro.taskana.classification.api.exceptions.ClassificationNotFoundException- if the referenced Classification does not existpro.taskana.common.api.exceptions.NotAuthorizedException- if the current user is not authorized to append a Task to the referenced Workbasketpro.taskana.task.api.exceptions.TaskAlreadyExistException- if the requested Task already exists.pro.taskana.common.api.exceptions.InvalidArgumentException- if any input is semantically wrong.pro.taskana.task.api.exceptions.AttachmentPersistenceException- if an Attachment with ID will be added multiple times without using the task-methodspro.taskana.task.api.exceptions.ObjectReferencePersistenceException- if an ObjectReference with ID will be added multiple times without using the task-methods
-
transferTask
@PostMapping(path="/api/v1/tasks/{taskId}/transfer/{workbasketId}") @Transactional(rollbackFor=java.lang.Exception.class) public org.springframework.http.ResponseEntity<TaskRepresentationModel> transferTask(@PathVariable String taskId, @PathVariable String workbasketId, @RequestBody(required=false) Boolean setTransferFlag) throws pro.taskana.task.api.exceptions.TaskNotFoundException, pro.taskana.workbasket.api.exceptions.WorkbasketNotFoundException, pro.taskana.common.api.exceptions.NotAuthorizedException, pro.taskana.task.api.exceptions.InvalidStateExceptionThis endpoint transfers a given Task to a given Workbasket, if possible.- Parameters:
taskId- the Id of the Task which should be transferredworkbasketId- the Id of the destination WorkbasketsetTransferFlag- sets the tansfer flag of the task (default: true)- Returns:
- the successfully transferred Task.
- Throws:
pro.taskana.task.api.exceptions.TaskNotFoundException- if the requested Task does not existpro.taskana.workbasket.api.exceptions.WorkbasketNotFoundException- if the requested Workbasket does not existpro.taskana.common.api.exceptions.NotAuthorizedException- if the current user has no authorization to transfer the Task.pro.taskana.task.api.exceptions.InvalidStateException- if the Task is in a state which does not allow transferring.
-
updateTask
@PutMapping(path="/api/v1/tasks/{taskId}") @Transactional(rollbackFor=java.lang.Exception.class) public org.springframework.http.ResponseEntity<TaskRepresentationModel> updateTask(@PathVariable("taskId") String taskId, @RequestBody TaskRepresentationModel taskRepresentationModel) throws pro.taskana.task.api.exceptions.TaskNotFoundException, pro.taskana.classification.api.exceptions.ClassificationNotFoundException, pro.taskana.common.api.exceptions.InvalidArgumentException, pro.taskana.common.api.exceptions.ConcurrencyException, pro.taskana.common.api.exceptions.NotAuthorizedException, pro.taskana.task.api.exceptions.AttachmentPersistenceException, pro.taskana.task.api.exceptions.InvalidStateException, pro.taskana.task.api.exceptions.ObjectReferencePersistenceExceptionThis endpoint updates a requested Task.- Parameters:
taskId- the Id of the Task which should be updatedtaskRepresentationModel- the new Task for the requested id.- Returns:
- the updated Task
- Throws:
pro.taskana.task.api.exceptions.TaskNotFoundException- if the requested Task does not exist.pro.taskana.classification.api.exceptions.ClassificationNotFoundException- if the updated Classification does not exist.pro.taskana.common.api.exceptions.InvalidArgumentException- if any semantically invalid parameter was providedpro.taskana.common.api.exceptions.ConcurrencyException- if the Task has been updated by a different process in the meantimepro.taskana.common.api.exceptions.NotAuthorizedException- if the current user is not authorized.pro.taskana.task.api.exceptions.AttachmentPersistenceException- if the modified Task contains two attachments with the same id.pro.taskana.task.api.exceptions.ObjectReferencePersistenceException- if the modified Task contains two object references with the same id.pro.taskana.task.api.exceptions.InvalidStateException- if an attempt is made to change the owner of the Task and the Task is not in state READY.
-
-