Class TaskTool

    • Field Detail

      • NOW

        public static final String NOW
        Magic value used to indicate that the user would like to schedule this operation to run immediately as a task as opposed to running the operation in the local VM.
        See Also:
        Constant Field Values
      • runOfflineArg

        protected BooleanArgument runOfflineArg
        Argument used to know if the tool should be run in offline mode.
    • Constructor Detail

      • TaskTool

        public TaskTool()
    • Method Detail

      • processLocal

        protected abstract int processLocal​(boolean initializeServer,
                                            PrintStream out,
                                            PrintStream err)
        Called when this utility should perform its actions locally in this JVM.
        Parameters:
        initializeServer - indicates whether to initialize the directory server in the case of a local action
        out - stream to write messages; may be null
        err - stream to write messages; may be null
        Returns:
        int indicating the result of this action
      • cleanup

        protected void cleanup()
        Cleanup task environment after offline run. Default implementation does nothing. Tasks which initialize some static part of the DirectoryServer instance (e.g admin data local backends) must override this method to shutdown all needed component to prevent JVM environment alteration.
      • createArgParser

        protected LDAPConnectionArgumentParser createArgParser​(String className,
                                                               org.forgerock.i18n.LocalizableMessage toolDescription)
        Creates an argument parser prepopulated with arguments for processing input for scheduling tasks with the task backend.
        Parameters:
        className - of this tool
        toolDescription - of this tool
        Returns:
        LDAPConnectionArgumentParser for processing CLI input
      • getOfflineDescriptionMessage

        protected org.forgerock.i18n.LocalizableMessage getOfflineDescriptionMessage()
      • validateTaskArgs

        protected void validateTaskArgs()
                                 throws ArgumentException,
                                        ClientException
        Validates arguments related to task scheduling. This should be called after the ArgumentParser.parseArguments has been called.
        Throws:
        ArgumentException - if there is a problem with the arguments.
        ClientException - if there is a problem with one of the values provided by the user.
      • getStartDateTime

        public Date getStartDateTime()
        Gets the date at which this task should be scheduled to start.
        Specified by:
        getStartDateTime in interface TaskScheduleInformation
        Returns:
        date/time at which the task should be scheduled
      • getRecurringDateTime

        public String getRecurringDateTime()
        Gets the date/time pattern for recurring task schedule.
        Specified by:
        getRecurringDateTime in interface TaskScheduleInformation
        Returns:
        recurring date/time pattern at which the task should be scheduled.
      • process

        protected int process​(LDAPConnectionArgumentParser argParser,
                              boolean initializeServer,
                              PrintStream out,
                              PrintStream err)
        Either invokes initiates this tool's local action or schedule this tool using the tasks interface based on user input.
        Parameters:
        argParser - used to parse user arguments
        initializeServer - indicates whether to initialize the directory server in the case of a local action
        out - stream to write messages; may be null
        err - stream to write messages; may be null
        Returns:
        int indicating the result of this action
      • runOffline

        public boolean runOffline()
        Indicates whether we must return if the command must be run in off-line mode.
        Returns:
        true if we must return if the command must be run in off-line mode and false otherwise.