public abstract class TaskTool extends com.forgerock.opendj.cli.Tool implements TaskScheduleInformation
Modifier and Type | Field and Description |
---|---|
protected boolean |
canInitializeServer
true if the server needs to be initialized during the tool execution. |
static 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.
|
protected static String |
OPTION_LONG_COMPRESS
The value for the long option compress.
|
protected static String |
OPTION_LONG_TMP_DIRECTORY
The value for the tmp directory long option.
|
protected static Character |
OPTION_SHORT_BACKEND_ID
The value for the "backendId" short option.
|
protected static char |
OPTION_SHORT_COMPRESS
The value for the short option compress.
|
Modifier | Constructor and Description |
---|---|
protected |
TaskTool(OutputStream out,
OutputStream err,
String className,
LocalizableMessage toolDescription,
boolean canInitializeServer)
Creates a new task tool instance with provided standard and error out streams.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addAttribute(Entry taskEntry,
String attrName,
com.forgerock.opendj.cli.Argument argument)
Adds the provided attribute with the argument value(s) to the provided task entry only if the argument has
been provided on the command line.
|
protected void |
addAttributeIfArgumentPresent(Entry taskEntry,
String attrName,
com.forgerock.opendj.cli.Argument argument)
Adds the attribute with the argument value to the task entry if the argument corresponding to the
attribute has been provided on the command line.
|
protected void |
cleanup()
Cleanup task environment after offline run.
|
protected com.forgerock.opendj.cli.ArgumentParser |
getArgumentParser()
Returns the
ArgumentParser used by this tool. |
Collection<String> |
getDependencyIds()
Gets a list of task IDs upon which this task is dependent.
|
FailedDependencyAction |
getFailedDependencyAction()
Gets the action to take should one of the dependent task fail.
|
Collection<String> |
getNotifyUponCompletionEmailAddresses()
Gets a list of email address to which an email will be sent when this task completes.
|
Collection<String> |
getNotifyUponErrorEmailAddresses()
Gets a list of email address to which an email will be sent if this task encounters an error during execution.
|
String |
getRecurringDateTime()
Gets the date/time pattern for recurring task schedule.
|
Date |
getStartDateTime()
Gets the date at which this task should be scheduled to start.
|
protected boolean |
isEmbedded()
Returns
true if the tool is running in embedded mode. |
protected com.forgerock.opendj.cli.ReturnCode |
process()
Either invokes initiates this tool's local action or schedule this tool using the tasks interface based on user
input.
|
protected abstract com.forgerock.opendj.cli.ReturnCode |
processLocal()
Called when this utility should perform its actions locally in this JVM.
|
com.forgerock.opendj.cli.ReturnCode |
run(String... args)
Run this
Tool tool with the provided arguments. |
protected static void |
runEmbeddedOffline(TaskTool taskTool,
com.forgerock.opendj.cli.ArgumentsBuilder arguments)
Adds the --offline and --noPropertyFile arguments to the provided arguments and
runs the provided taskTool.
|
protected boolean |
runOffline()
/**
Indicates whether we must return if the command must be run in off-line mode.
|
protected abstract com.forgerock.opendj.cli.ReturnCode |
runTaskTool(String[] args)
Runs the concrete tool implementation with the provided arguments.
|
protected void |
shutdownBackends()
Shutdowns all backends.
|
protected void |
validateArguments(String[] args)
Parses the provided arguments and validates task arguments.
|
protected void |
validateTaskArgs()
Validates arguments related to task scheduling.
|
askConfirmation, askPort, close, confirmAction, enableConsoleLoggingIfVerbose, errPrintln, errPrintln, errPrintln, errPrintlnSurroundedByBlankLines, errPrintVerboseMessage, flush, flushLogStream, getErrorStream, getErrStream, getInputStream, getOutputStream, isFullyInteractive, isQuiet, isScriptFriendly, isVerbose, logVerboseMessage, mayPrompt, parseArguments, pressReturnToContinue, print, println, println, println, println, printlnNoWrap, printlnSurroundedByBlankLines, printNoWrap, readInput, readInput, readInputAllowEmpty, readLineOfInput, readPassword, readPassword, readValidatedInput, readValidatedInput, report
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addTaskAttributes, getTaskClass, getTaskId, getTaskObjectclass
protected static final String OPTION_LONG_COMPRESS
protected static final char OPTION_SHORT_COMPRESS
protected static final Character OPTION_SHORT_BACKEND_ID
protected static final String OPTION_LONG_TMP_DIRECTORY
public static final String NOW
protected final boolean canInitializeServer
true
if the server needs to be initialized during the tool execution.protected TaskTool(OutputStream out, OutputStream err, String className, LocalizableMessage toolDescription, boolean canInitializeServer)
Provided OutputStream
s will be wrapped as PrintStream
.
out
- The output stream (may be null
).err
- The error stream (may be null
).className
- The name of the tool class.toolDescription
- The localized tool description.canInitializeServer
- true
if the server can be initialized, false
otherwise (basically, because this is
executed in the context of a unit-test).protected static void runEmbeddedOffline(TaskTool taskTool, com.forgerock.opendj.cli.ArgumentsBuilder arguments) throws com.forgerock.opendj.cli.ClientException
protected abstract com.forgerock.opendj.cli.ReturnCode processLocal() throws com.forgerock.opendj.cli.ClientException
com.forgerock.opendj.cli.ClientException
- If an error occurs while running the toolprotected void cleanup()
protected final void shutdownBackends()
protected void validateTaskArgs() throws com.forgerock.opendj.cli.ArgumentException, com.forgerock.opendj.cli.ClientException
ArgumentParser.parseArguments
has
been called.com.forgerock.opendj.cli.ArgumentException
- if there is a problem with the arguments.com.forgerock.opendj.cli.ClientException
- if there is a problem with one of the values provided by the user.protected final void validateArguments(String[] args) throws com.forgerock.opendj.cli.ClientException
args
- The command line arguments.com.forgerock.opendj.cli.ClientException
- If the argument parsing fails.public Date getStartDateTime()
TaskScheduleInformation
getStartDateTime
in interface TaskScheduleInformation
public String getRecurringDateTime()
TaskScheduleInformation
getRecurringDateTime
in interface TaskScheduleInformation
public Collection<String> getDependencyIds()
TaskScheduleInformation
getDependencyIds
in interface TaskScheduleInformation
public FailedDependencyAction getFailedDependencyAction()
TaskScheduleInformation
getFailedDependencyAction
in interface TaskScheduleInformation
public Collection<String> getNotifyUponCompletionEmailAddresses()
TaskScheduleInformation
getNotifyUponCompletionEmailAddresses
in interface TaskScheduleInformation
public Collection<String> getNotifyUponErrorEmailAddresses()
TaskScheduleInformation
getNotifyUponErrorEmailAddresses
in interface TaskScheduleInformation
public com.forgerock.opendj.cli.ReturnCode run(String... args) throws com.forgerock.opendj.cli.ClientException
com.forgerock.opendj.cli.Tool
Tool
tool with the provided arguments.
Output and errors will be written on the provided streams.
This method can be used to run the tool programmatically.
run
in class com.forgerock.opendj.cli.Tool
args
- Arguments set to pass to the tool.ReturnCode
.com.forgerock.opendj.cli.ClientException
- If an error occurs while running the tool.protected abstract com.forgerock.opendj.cli.ReturnCode runTaskTool(String[] args) throws com.forgerock.opendj.cli.ClientException
args
- The command line arguments.ReturnCode
returned by the tool execution.com.forgerock.opendj.cli.ClientException
- If an error occurs during tool execution.protected final com.forgerock.opendj.cli.ReturnCode process() throws com.forgerock.opendj.cli.ClientException
com.forgerock.opendj.cli.ClientException
- If an error occurs during tool execution.protected boolean runOffline()
true
if we must return if the command must be run in off-line mode and false
otherwise.protected boolean isEmbedded()
true
if the tool is running in embedded mode.
Embedded mode would not change JDK logging configuration and will used running jvm slf4j loggers implementation
true
if the tool is running in embedded mode.protected void addAttributeIfArgumentPresent(Entry taskEntry, String attrName, com.forgerock.opendj.cli.Argument argument)
taskEntry
- The task Entry
to updateattrName
- The attribute corresponding to the argumentargument
- The argument representing the attributeprotected void addAttribute(Entry taskEntry, String attrName, com.forgerock.opendj.cli.Argument argument)
protected com.forgerock.opendj.cli.ArgumentParser getArgumentParser()
ArgumentParser
used by this tool.ArgumentParser
used by this tool.Copyright 2010-2022 ForgeRock AS.