Class TaskController


  • @RestController
    @EnableHypermediaSupport(type=HAL)
    public class TaskController
    extends Object
    Controller for all Task related endpoints.
    • 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 request
        filterParameter - the filter parameters
        sortParameter - the sort parameters
        pagingParameter - 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.NotAuthorizedException
        This 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 thrown
        pro.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.NotAuthorizedException
        This 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.NotAuthorizedException
        This endpoint claims a Task if possible.
        Parameters:
        taskId - the Id of the Task which should be claimed
        userName - 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 parameters
        sortParameter - the sort parameters
        Returns:
        the claimed Task
        Throws:
        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 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.NotAuthorizedException
        This 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.NotAuthorizedException
        This 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.NotAuthorizedException
        This 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.NotAuthorizedException
        This 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 thrown
        pro.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.InvalidStateException
        This 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 CLAIMED
        pro.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
        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 exist
        pro.taskana.classification.api.exceptions.ClassificationNotFoundException - if the referenced Classification does not exist
        pro.taskana.common.api.exceptions.NotAuthorizedException - if the current user is not authorized to append a Task to the referenced Workbasket
        pro.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-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.InvalidStateException
        This endpoint transfers a given Task to a given Workbasket, if possible.
        Parameters:
        taskId - the Id of the Task which should be transferred
        workbasketId - the Id of the destination Workbasket
        setTransferFlag - 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 exist
        pro.taskana.workbasket.api.exceptions.WorkbasketNotFoundException - if the requested Workbasket does not exist
        pro.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
        This endpoint updates a requested Task.
        Parameters:
        taskId - the Id of the Task which should be updated
        taskRepresentationModel - 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 provided
        pro.taskana.common.api.exceptions.ConcurrencyException - if the Task has been updated by a different process in the meantime
        pro.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.InvalidStateException - if an attempt is made to change the owner of the Task and the Task is not in state READY.