Class TaskResource


  • @Path("/tasks")
    @Consumes("application/json")
    @Produces("application/json")
    @Controller
    public class TaskResource
    extends java.lang.Object
    A task in a release.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      javax.ws.rs.core.Response abortTask​(java.lang.String taskId, CommentView comment)
      Aborts a task.
      com.xebialabs.xlrelease.views.BulkActionResultView abortTasks​(CommentTasksView comment)
      Aborts tasks.
      CommentView addComment​(java.lang.String taskId, CommentView commentView)
      Adds a comment to a task.
      com.xebialabs.xlrelease.views.BulkActionResultView addCommentToTasks​(CommentTasksView commentTasksView)  
      TaskFullView addTask​(java.lang.String containerId, TaskForm taskForm)
      Adds a new task to a container (phase or task group).
      java.util.Set<UserView> addWatcher​(java.lang.String taskId, UserView watcherView)  
      TaskFullView changeTaskType​(java.lang.String taskId, java.lang.String targetType)
      Change task type to the target task type.
      javax.ws.rs.core.Response completeTask​(java.lang.String taskId, CommentView comment)
      Completes a running task manually.
      com.xebialabs.xlrelease.views.BulkActionResultView completeTasks​(CommentTasksView commentTasksView)
      Completes tasks manually.
      void deleteTask​(java.lang.String taskId)
      Deletes a task.
      com.xebialabs.xlrelease.views.BulkActionResultView deleteTasks​(java.util.List<java.lang.String> taskIds)  
      javax.ws.rs.core.Response failTask​(java.lang.String taskId, CommentView comment)
      Fails a task.
      com.xebialabs.xlrelease.views.BulkActionResultView failTasks​(CommentTasksView comment)
      Fails tasks.
      void followLog​(java.lang.String taskId, java.lang.String executionId)
      Streams entries for a given task execution.
      void followTask​(java.lang.String taskId)  
      java.util.Set<java.lang.String> getAllTags()  
      java.util.List<CommentView> getCommentsOfTask​(java.lang.String taskId)
      Returns the comments associated with a task.
      com.xebialabs.xlrelease.domain.TaskWithPropertiesDefinition getCustomScriptProperties​(java.lang.String scriptDefinitionType)
      Returns the properties used to configure a custom task type.
      TaskFullView getTask​(java.lang.String taskId)
      Returns the details of a task.
      java.util.List<com.xebialabs.xlrelease.api.v1.views.TaskAccessView> getTaskAccesses()
      Returns all task accesses.
      java.util.Collection<com.xebialabs.xlrelease.domain.TaskDefinition> getTaskDefinitions()
      Returns the custom task definitions created through Digital.ai Release's extensibility mechanism.
      java.util.List<TaskExecutionLogView> getTaskExecutions​(java.lang.String taskId)
      Retrieve list of task executions.
      TaskReleaseView getTaskRelease​(java.lang.String taskId)
      Returns a release view for given task.
      TaskSearchView getTasksByRelease​(TasksFilters tasksFilters, java.lang.Integer limitTasksHint)
      Returns the list of tasks accessible to the current user, grouped by release.
      javax.ws.rs.core.Response log​(java.lang.String taskId, java.lang.String executionId, java.lang.Long job, java.lang.Long chunk)  
      java.util.List<TaskPollingView> poll​(DomainIdsForm form)
      Returns a list of tasks.
      void pong​(java.lang.String taskId, java.lang.String executionId)  
      com.xebialabs.xlrelease.views.BulkActionResultView reassignTasks​(ReassignTasksView reassignTasks)  
      void reassignToOwner​(java.lang.String taskId, TaskFullView updatedTask)
      Reassigns a task to a different owner.
      void reassignToTeam​(java.lang.String taskId, TaskFullView updatedTask)
      Reassigns a task to a different team.
      void removeOwner​(java.lang.String taskId)
      Deletes a task owner.
      void removeTeam​(java.lang.String taskId)
      Removes the team of a task.
      java.util.Set<UserView> removeWatcher​(java.lang.String taskId, java.lang.String username)  
      javax.ws.rs.core.Response reopenTask​(java.lang.String taskId, CommentView comment)
      Reopens a task that had been completed in advance.
      com.xebialabs.xlrelease.views.BulkActionResultView reopenTasks​(CommentTasksView comment)
      Reopens tasks.
      javax.ws.rs.core.Response retryTask​(java.lang.String taskId, CommentView comment)
      Retries a task.
      com.xebialabs.xlrelease.views.BulkActionResultView retryTasks​(CommentTasksView comment)
      Retries tasks.
      javax.ws.rs.core.Response skipTask​(java.lang.String taskId, CommentView comment)
      Skips a manual task.
      com.xebialabs.xlrelease.views.BulkActionResultView skipTasks​(CommentTasksView comment)
      Skips tasks.
      javax.ws.rs.core.Response startNow​(java.lang.String taskId, CommentView comment)
      Forces a pending task to start immediately.
      void unfollowLog​(java.lang.String taskId, java.lang.String executionId)  
      void unfollowTask​(java.lang.String taskId)  
      TaskFullView updateTask​(java.lang.String taskId, TaskFullView updatedTask)
      Updates a task and notifies the new owner if the task has been reassigned.
      void updateTaskAccesses​(java.util.List<com.xebialabs.xlrelease.api.v1.views.TaskAccessView> taskAccesses)
      Update task accesses.
      java.util.Set<UserView> updateWatchers​(java.lang.String taskId, java.util.Set<UserView> watchersView)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TaskResource

        @Autowired
        public TaskResource​(com.xebialabs.xlrelease.api.v1.TaskApi taskApi,
                            ReleaseService releaseService,
                            TaskService taskService,
                            com.xebialabs.xlrelease.security.PermissionChecker permissions,
                            TaskAccessService taskAccessService,
                            TaskSearchService taskSearchService,
                            com.xebialabs.xlrelease.actors.ReleaseActorService releaseActorService,
                            TasksViewConverter tasksViewConverter,
                            UserViewConverter userViewConverter,
                            CommentViewConverter commentViewConverter,
                            TaskGranularPermissions taskPermissionChecker,
                            com.xebialabs.xlrelease.scheduler.logs.TaskExecutionLogService taskExecutionLogService,
                            com.xebialabs.xlrelease.service.SseService sseService)
    • Method Detail

      • addTask

        @POST
        @Timed
        @Path("{containerId:.*(Phase|Task)[^/-]*}")
        public TaskFullView addTask​(@PathParam("containerId")
                                    java.lang.String containerId,
                                    TaskForm taskForm)
        Adds a new task to a container (phase or task group).
        Parameters:
        containerId - the identifier of the container
        taskForm - the information of the new task
        Returns:
        the new task
      • getTask

        @GET
        @Timed
        @Path("{taskId:[^/]*Task[^/-]*}")
        public TaskFullView getTask​(@PathParam("taskId")
                                    java.lang.String taskId)
        Returns the details of a task.
        Parameters:
        taskId - the identifier of the task
        Returns:
        the task
      • getTasksByRelease

        @POST
        @Timed
        @Path("search")
        public TaskSearchView getTasksByRelease​(TasksFilters tasksFilters,
                                                @QueryParam("limitTasksHint")
                                                java.lang.Integer limitTasksHint)
        Returns the list of tasks accessible to the current user, grouped by release.
        Parameters:
        tasksFilters - the TasksFilters criteria
        limitTasksHint - the number of tasks after which search will be aborted (actual number of tasks may be more than requested), optional, the default value is 100.
        Returns:
        the matching tasks, grouped by release.
      • completeTask

        @POST
        @Timed
        @Path("{taskId:.*Task[^/-]*}/complete")
        public javax.ws.rs.core.Response completeTask​(@PathParam("taskId")
                                                      java.lang.String taskId,
                                                      CommentView comment)
        Completes a running task manually.
        Parameters:
        taskId - the identifier of the task
        comment - the comment to associate to the action
        Returns:
        HTTP status 200 to indicate success
      • completeTasks

        @POST
        @Timed
        @Path("complete")
        public com.xebialabs.xlrelease.views.BulkActionResultView completeTasks​(CommentTasksView commentTasksView)
        Completes tasks manually.
        Parameters:
        commentTasksView - the comment view to associate to the action
        Returns:
        HTTP status 200 to indicate success
      • skipTask

        @POST
        @Timed
        @Path("{taskId:.*Task[^/-]*}/skip")
        public javax.ws.rs.core.Response skipTask​(@PathParam("taskId")
                                                  java.lang.String taskId,
                                                  CommentView comment)
        Skips a manual task.
        Parameters:
        taskId - the identifier of the task
        comment - the comment to associate to the action
        Returns:
        HTTP status 200 to indicate success
      • skipTasks

        @POST
        @Timed
        @Path("skip")
        public com.xebialabs.xlrelease.views.BulkActionResultView skipTasks​(CommentTasksView comment)
        Skips tasks.
        Parameters:
        comment - the comment to associate to the action
      • failTask

        @POST
        @Timed
        @Path("{taskId:.*Task[^/-]*}/fail")
        public javax.ws.rs.core.Response failTask​(@PathParam("taskId")
                                                  java.lang.String taskId,
                                                  CommentView comment)
        Fails a task.
        Parameters:
        taskId - the identifier of the task
        comment - the comment to associate to the action
        Returns:
        HTTP status 200 to indicate success
      • failTasks

        @POST
        @Timed
        @Path("fail")
        public com.xebialabs.xlrelease.views.BulkActionResultView failTasks​(CommentTasksView comment)
        Fails tasks.
        Parameters:
        comment - a comment describing the 'fail' action.
      • abortTask

        @POST
        @Timed
        @Path("{taskId:.*Task[^/-]*}/abort")
        public javax.ws.rs.core.Response abortTask​(@PathParam("taskId")
                                                   java.lang.String taskId,
                                                   CommentView comment)
        Aborts a task.
        Parameters:
        taskId - the identifier of the task
        comment - the comment to associate to the action
        Returns:
        HTTP status 200 to indicate success
      • retryTask

        @POST
        @Timed
        @Path("{taskId:.*Task[^/-]*}/retry")
        public javax.ws.rs.core.Response retryTask​(@PathParam("taskId")
                                                   java.lang.String taskId,
                                                   CommentView comment)
        Retries a task.
        Parameters:
        taskId - the identifier of the task
        comment - the comment to associate to the action
        Returns:
        HTTP status 200 to indicate success
      • retryTasks

        @POST
        @Timed
        @Path("retry")
        public com.xebialabs.xlrelease.views.BulkActionResultView retryTasks​(CommentTasksView comment)
        Retries tasks.
        Parameters:
        comment - the comment to associate to the action
      • abortTasks

        @POST
        @Timed
        @Path("abort")
        public com.xebialabs.xlrelease.views.BulkActionResultView abortTasks​(CommentTasksView comment)
        Aborts tasks.
        Parameters:
        comment - the comment to associate to the action
      • startNow

        @POST
        @Timed
        @Path("{taskId:.*Task[^/-]*}/startNow")
        public javax.ws.rs.core.Response startNow​(@PathParam("taskId")
                                                  java.lang.String taskId,
                                                  CommentView comment)
        Forces a pending task to start immediately.
        Parameters:
        taskId - the identifier of the task
        comment - the comment to associate to the action
        Returns:
        HTTP status 200 to indicate success
      • reopenTask

        @POST
        @Timed
        @Path("{taskId:.*Task[^/-]*}/reopen")
        public javax.ws.rs.core.Response reopenTask​(@PathParam("taskId")
                                                    java.lang.String taskId,
                                                    CommentView comment)
        Reopens a task that had been completed in advance.
        Parameters:
        taskId - the identifier of the task
        comment - the comment to associate to the action
        Returns:
        HTTP status 200 to indicate success
      • reopenTasks

        @POST
        @Timed
        @Path("reopen")
        public com.xebialabs.xlrelease.views.BulkActionResultView reopenTasks​(CommentTasksView comment)
        Reopens tasks.
        Parameters:
        comment - the comment to associate to the action
      • getCommentsOfTask

        @GET
        @Timed
        @Path("{taskId:.*Task[^/-]*}/comments")
        public java.util.List<CommentView> getCommentsOfTask​(@PathParam("taskId")
                                                             java.lang.String taskId)
        Returns the comments associated with a task.
        Parameters:
        taskId - the identifier of the task
        Returns:
        the comments
      • addComment

        @POST
        @Timed
        @Path("{taskId:.*Task[^/-]*}/comments")
        public CommentView addComment​(@PathParam("taskId")
                                      java.lang.String taskId,
                                      CommentView commentView)
        Adds a comment to a task.
        Parameters:
        taskId - the identifier of the task
        commentView - the comment's data
        Returns:
        the comment
      • addCommentToTasks

        @POST
        @Timed
        @Path("comments")
        public com.xebialabs.xlrelease.views.BulkActionResultView addCommentToTasks​(CommentTasksView commentTasksView)
      • updateTask

        @PUT
        @Timed
        @Path("{taskId:.*Task[^/-]*}")
        public TaskFullView updateTask​(@PathParam("taskId")
                                       java.lang.String taskId,
                                       TaskFullView updatedTask)
        Updates a task and notifies the new owner if the task has been reassigned.
        Parameters:
        taskId - the identifier of the task
        updatedTask - the new task values
        Returns:
        the updated task
      • changeTaskType

        @POST
        @Timed
        @Path("{taskId:.*Task[^/-]*}/changeType")
        public TaskFullView changeTaskType​(@PathParam("taskId")
                                           java.lang.String taskId,
                                           @QueryParam("targetType")
                                           java.lang.String targetType)
        Change task type to the target task type.
        Parameters:
        taskId - the identifier of the task
        targetType - the new task type
        Returns:
        new task
      • reassignTasks

        @PUT
        @Timed
        @Path("reassign")
        public com.xebialabs.xlrelease.views.BulkActionResultView reassignTasks​(ReassignTasksView reassignTasks)
      • reassignToOwner

        @PUT
        @Timed
        @Path("{taskId:.*Task[^/-]*}/owner")
        public void reassignToOwner​(@PathParam("taskId")
                                    java.lang.String taskId,
                                    TaskFullView updatedTask)
        Reassigns a task to a different owner.
        Parameters:
        taskId - the identifier of the task
        updatedTask - the details of the updated task, including the new owner
      • removeOwner

        @DELETE
        @Timed
        @Path("{taskId:.*Task[^/-]*}/owner")
        public void removeOwner​(@PathParam("taskId")
                                java.lang.String taskId)
        Deletes a task owner.
        Parameters:
        taskId - the identifier of the task
      • reassignToTeam

        @PUT
        @Timed
        @Path("{taskId:.*Task[^/-]*}/team")
        public void reassignToTeam​(@PathParam("taskId")
                                   java.lang.String taskId,
                                   TaskFullView updatedTask)
        Reassigns a task to a different team.
        Parameters:
        taskId - the identifier of the task
        updatedTask - the details of the updated task, including the new team
      • removeTeam

        @DELETE
        @Timed
        @Path("{taskId:.*Task[^/-]*}/team")
        public void removeTeam​(@PathParam("taskId")
                               java.lang.String taskId)
        Removes the team of a task.
        Parameters:
        taskId - the identifier of the task
      • deleteTasks

        @DELETE
        public com.xebialabs.xlrelease.views.BulkActionResultView deleteTasks​(java.util.List<java.lang.String> taskIds)
      • deleteTask

        @DELETE
        @Timed
        @Path("{taskId:.*Task[^/-]*}")
        public void deleteTask​(@PathParam("taskId")
                               java.lang.String taskId)
        Deletes a task.
        Parameters:
        taskId - the identifier of the task
      • poll

        @POST
        @Timed
        @Path("poll")
        public java.util.List<TaskPollingView> poll​(DomainIdsForm form)
        Returns a list of tasks.
        Parameters:
        form - the identifiers of the tasks
        Returns:
        the tasks
      • getTaskDefinitions

        @GET
        @Timed
        @Path("task-definitions")
        public java.util.Collection<com.xebialabs.xlrelease.domain.TaskDefinition> getTaskDefinitions()
        Returns the custom task definitions created through Digital.ai Release's extensibility mechanism.
        Returns:
        the definitions
      • getCustomScriptProperties

        @GET
        @Timed
        @Path("task-definitions/{scriptDefinitionType}")
        public com.xebialabs.xlrelease.domain.TaskWithPropertiesDefinition getCustomScriptProperties​(@PathParam("scriptDefinitionType")
                                                                                                     java.lang.String scriptDefinitionType)
        Returns the properties used to configure a custom task type.
        Parameters:
        scriptDefinitionType - the task type
        Returns:
        the definition of the type, which includes the properties
      • getTaskAccesses

        @GET
        @Timed
        @Path("types-access")
        public java.util.List<com.xebialabs.xlrelease.api.v1.views.TaskAccessView> getTaskAccesses()
        Returns all task accesses. It's necessary to have the 'security#edit' permission to call this end point.
        Returns:
        the task accesses
      • updateTaskAccesses

        @PUT
        @Timed
        @Path("types-access")
        public void updateTaskAccesses​(java.util.List<com.xebialabs.xlrelease.api.v1.views.TaskAccessView> taskAccesses)
        Update task accesses. It's necessary to have the 'security#edit' permission to call this end point.
        Parameters:
        taskAccesses - the task accesses to save
      • getTaskRelease

        @GET
        @Timed
        @Path("{taskId:.*Task[^/-]*}/release")
        public TaskReleaseView getTaskRelease​(@PathParam("taskId")
                                              java.lang.String taskId)
        Returns a release view for given task.
        Parameters:
        taskId - the task identifier
        Returns:
        task release view
      • getAllTags

        @GET
        @Path("tags")
        public java.util.Set<java.lang.String> getAllTags()
      • addWatcher

        @Path("{taskId:.*Task[^/-]*}/watchers")
        @POST
        public java.util.Set<UserView> addWatcher​(@PathParam("taskId")
                                                  java.lang.String taskId,
                                                  UserView watcherView)
      • removeWatcher

        @Path("{taskId:.*Task[^/-]*}/watchers/{username}")
        @DELETE
        public java.util.Set<UserView> removeWatcher​(@PathParam("taskId")
                                                     java.lang.String taskId,
                                                     @PathParam("username")
                                                     java.lang.String username)
      • updateWatchers

        @Path("{taskId:.*Task[^/-]*}/watchers")
        @PUT
        public java.util.Set<UserView> updateWatchers​(@PathParam("taskId")
                                                      java.lang.String taskId,
                                                      java.util.Set<UserView> watchersView)
      • followLog

        @POST
        @Path("{taskId:.*Task[^/-]*}/execution/{executionId}/log/follow")
        public void followLog​(@PathParam("taskId")
                              java.lang.String taskId,
                              @PathParam("executionId")
                              java.lang.String executionId)
        Streams entries for a given task execution.

        IMPORTANT: streamed events MAY BE DUPLICATED if fromStart is true

        Parameters:
        taskId - task id of the task
        executionId - execution id of the task (This is not the same as the custom script task execution id)
      • pong

        @POST
        @Path("{taskId:.*Task[^/-]*}/execution/{executionId}/log/pong")
        public void pong​(@PathParam("taskId")
                         java.lang.String taskId,
                         @PathParam("executionId")
                         java.lang.String executionId)
      • unfollowLog

        @DELETE
        @Path("{taskId:.*Task[^/-]*}/execution/{executionId}/log/follow")
        public void unfollowLog​(@PathParam("taskId")
                                java.lang.String taskId,
                                @PathParam("executionId")
                                java.lang.String executionId)
      • log

        @GET
        @Path("{taskId:.*Task[^/-]*}/execution/{executionId}/log")
        @Produces("text/plain")
        public javax.ws.rs.core.Response log​(@PathParam("taskId")
                                             java.lang.String taskId,
                                             @PathParam("executionId")
                                             java.lang.String executionId,
                                             @QueryParam("job") @DefaultValue("9223372036854775807")
                                             java.lang.Long job,
                                             @QueryParam("chunk") @DefaultValue("9223372036854775807")
                                             java.lang.Long chunk)
      • getTaskExecutions

        @GET
        @Path("{taskId:.*Task[^/-]*}/executions")
        public java.util.List<TaskExecutionLogView> getTaskExecutions​(@PathParam("taskId")
                                                                      java.lang.String taskId)
        Retrieve list of task executions. It's a starting point of execution flows to display task execution logs.

        execution flow 1:

        • UI hits `GET getTaskExecutions` and in response gets all task executions
        • UI gets back information: (id - execution id, executionNo - order, modified date, end date, latest_job_id, latest_chunk)
        • UI decides to ask `GET followLog` to stream log entries - and it will get event with current status: (status, latest_job_id, latest_chunk_id)
          • status can be: 'in_progress', 'closed' or 'unknown'
          • if status is 'unknown' latest_job_id is -1 and latest_chunk is -1
        • IN PARALLEL: UI invokes `GET log` endpoint with 'latest_job_id' and 'latest_chunk' parameters and fetches content up until that point (100s of streamed megabytes) - if needed backend can also discard everything but latest 40KB of data (or whatever we choose)
        • UI decides how to present this data AND any incoming events to the user

        execution flow 2:

        • UI hits `GET getTaskExecutions` and in response gets all task executions
        • UI gets back information: (id - execution id, executionNo - order, modified date, end date, latest_job_id, latest_chunk)
        • UI decides to ask `GET followLog` to stream log entries - and it will get event with current status: (status, latest_job_id, latest_chunk_id)
          • status can be: 'in_progress', 'closed' or 'unknown'
          • if status is 'unknown' latest_job_id is -1 and latest_chunk is -1
        Parameters:
        taskId - task id
        Returns:
        list of task execution data
      • followTask

        @POST
        @Path("{taskId:.*Task[^/-]*}/follow")
        public void followTask​(@PathParam("taskId")
                               java.lang.String taskId)
      • unfollowTask

        @DELETE
        @Path("{taskId:.*Task[^/-]*}/follow")
        public void unfollowTask​(@PathParam("taskId")
                                 java.lang.String taskId)