Class TaskClient


  • public final class TaskClient
    extends Object
    Helper class for interacting with the task backend on behalf of utilities that are capable of being scheduled.
    • Constructor Detail

      • TaskClient

        public TaskClient​(Connection conn)
        Creates a new TaskClient for interacting with the task backend remotely.
        Parameters:
        conn - for accessing the task backend
    • Method Detail

      • getTaskId

        public static String getTaskId​(Entry taskEntry)
        Returns the ID of the provided task entry.
        Parameters:
        taskEntry - The task Entry.
        Returns:
        the ID of the provided task Entry.
        Throws:
        IllegalArgumentException - If the task ID cannot be retrieve from the provided Entry.
      • getTaskDn

        public static String getTaskDn​(Entry taskEntry)
        Uses provided task entry attributes to create a DN for the provided task entry.
        Parameters:
        taskEntry - The task Entry.
        Returns:
        A String representing the DN of the provided task Entry.
      • waitUntilTaskIsDone

        public TaskEntry waitUntilTaskIsDone​(String taskId,
                                             PrintStream stream)
                                      throws LdapException,
                                             TaskClientException
        Wait until the task with the provided id is done.

        The provided taskClient is used for retrieving task information. During the execution, tasks logs are printed on the provided stream.

        Parameters:
        taskId - A string representing the ID of the task to retrieve.
        stream - The stream to use for printing task logs, may be null.
        Returns:
        A task entry object representing the task done.
        Throws:
        LdapException - If an error occurs while retrieving task information from the server.
        TaskClientException - If there is no task with the requested ID.
      • createTask

        public static Entry createTask​(TaskScheduleInformation information)
        Creates an Entry for the task described in the provided TaskScheduleInformation.
        Parameters:
        information - The scheduling information from which to create the task entry.
        Returns:
        A new entry representing a task.
      • getTaskEntries

        public List<TaskEntry> getTaskEntries()
                                       throws LdapException
        Gets all the ds-task entries from the task root.
        Returns:
        list of entries from the task root
        Throws:
        LdapException - if there is a problem getting information out to the directory
      • getTaskEntry

        public TaskEntry getTaskEntry​(String taskId)
                               throws LdapException,
                                      TaskClientException
        Gets the entry of the task associated to the provided identifier.
        Parameters:
        taskId - of the entry to retrieve
        Returns:
        Entry for the task
        Throws:
        LdapException - if there is a problem getting information out to the directory
        TaskClientException - if there is no task with the requested id
      • cancelTask

        public void cancelTask​(String taskId)
                        throws TaskClientException,
                               LdapException
        Changes that the state of the task in the backend to a canceled state.
        Parameters:
        taskId - if the task to cancel
        Throws:
        LdapException - if there is a problem getting information out to the directory
        TaskClientException - if there is no task with the requested id or if the task has finished and cannot be completed