public abstract class Task extends Object
Modifier and Type | Class and Description |
---|---|
static class |
Task.State
The state on which the task can be.
|
static class |
Task.Type
The different task types.
|
Modifier and Type | Field and Description |
---|---|
protected ApplicationPrintStream |
errorPrintStream
The print stream for the error logs.
|
protected Throwable |
lastException
The last exception encountered during the task execution.
|
protected ApplicationPrintStream |
outPrintStream
The print stream for the standard output logs.
|
protected Integer |
returnCode
The return code of the task.
|
protected Task.State |
state
The current state of the task.
|
Modifier | Constructor and Description |
---|---|
protected |
Task(ControlPanelInfo info,
ProgressDialog progressDialog)
Constructor of the task.
|
Modifier and Type | Method and Description |
---|---|
void |
addConfigurationElementCreatedListener(ConfigurationElementCreatedListener listener)
Adds a configuration element created listener.
|
abstract boolean |
canLaunch(Task taskToBeLaunched,
Collection<LocalizableMessage> incompatibilityReasons)
Informs of whether the task to be launched can be launched or not.
|
protected int |
executeCommandLine(String commandLineName,
String[] args)
Executes a command-line synchronously.
|
abstract Set<String> |
getBackends()
Returns the names of the backends that are affected by the task.
|
protected abstract List<String> |
getCommandLineArguments()
Returns the list of command-line arguments.
|
protected abstract String |
getCommandLinePath()
Returns the full path of the command-line associated with this task or
null if there is not a command-line (or a single command-line)
associated with the task. |
protected String |
getCommandLinePath(String scriptBasicName)
Returns the full path of the command-line for a given script name.
|
String |
getCommandLineToDisplay()
Returns the command-line to be displayed (when we display the equivalent
command-line).
|
protected List<String> |
getConfigCommandLineArguments()
Returns the command-line arguments that correspond to the configuration.
|
protected List<String> |
getConnectionCommandLineArguments()
Returns the list of arguments related to the connection (host, port, bind
DN, etc.).
|
protected List<String> |
getConnectionCommandLineArguments(boolean useAdminConnector,
boolean addConnectionTypeParameters)
Returns the list of arguments related to the connection (host, port, bind
DN, etc.).
|
static String |
getEquivalentCommandLine(String cmdName,
List<String> args)
Returns the equivalent command line in HTML without font properties.
|
String |
getErrorLogs()
Returns the error logs of the task.
|
ApplicationPrintStream |
getErrorPrintStream()
Returns the print stream for the error logs.
|
protected LocalizableMessage |
getIncompatibilityMessage(Task taskRunning,
Task taskToBeLaunched)
Returns the incompatible message between two tasks.
|
ControlPanelInfo |
getInfo()
Returns the ControlPanelInfo object.
|
Throwable |
getLastException()
Returns last exception encountered during the task execution.
|
String |
getLogs()
Returns the logs of the task.
|
protected String |
getNoPropertiesFileArgument()
Returns the noPropertiesFile argument.
|
protected List<String> |
getObfuscatedCommandLineArguments(List<String> clearArgs)
Returns the list of obfuscated command-line arguments.
|
ApplicationPrintStream |
getOutPrintStream()
Returns the print stream for the output logs.
|
String |
getOutputLogs()
Returns the output logs of the task.
|
Process |
getProcess()
Returns the process that the task launched.
|
protected ProgressDialog |
getProgressDialog()
Returns the progress dialog.
|
Integer |
getReturnCode()
Returns the return code (this makes sense when the task launches a
command-line, it will return the error code returned by the command-line).
|
ServerDescriptor |
getServer()
Returns the server descriptor on which the task was launched.
|
Task.State |
getState()
Returns the state of the task.
|
abstract LocalizableMessage |
getTaskDescription()
The description of the task.
|
abstract Task.Type |
getType()
Returns the type of the task.
|
protected boolean |
isServerRunning()
Commodity method to know if the server is running or not.
|
protected void |
notifyConfigurationElementCreated(Object configObject)
Notifies the configuration element created listener that a new object has
been created.
|
protected String |
obfuscateLDIFLine(String line)
Obfuscates (if required) the attribute value in an LDIF line, and escapes any HTML-like content.
|
void |
postOperation()
Method that is called when everything is finished after updating the
progress dialog.
|
protected void |
printEquivalentCommandLine(String cmdName,
List<String> args,
LocalizableMessage msg)
Prints the equivalent command line.
|
protected void |
printEquivalentCommandToModify(org.forgerock.opendj.ldap.Dn dn,
Collection<org.forgerock.opendj.ldap.Modification> mods,
boolean useAdminCtx)
Prints the equivalent modify command line in the progress dialog.
|
protected void |
printEquivalentRenameCommand(org.forgerock.opendj.ldap.Dn oldDN,
org.forgerock.opendj.ldap.Dn newDN,
boolean useAdminCtx)
Prints the equivalent rename command line in the progress dialog.
|
boolean |
regenerateDescriptor()
Tells whether a new server descriptor should be regenerated when the task
is over.
|
void |
removeConfigurationElementCreatedListener(ConfigurationElementCreatedListener listener)
Removes a configuration element created listener.
|
protected boolean |
runningOnSameServer(Task task)
Check whether the provided task and this task run on the same server.
|
abstract void |
runTask()
Execute the task.
|
protected void |
startPollingAndInitializeConfiguration()
Initializes the configuration and starts the polling.
|
protected void |
stopPollingAndInitializeConfiguration()
Stops the polling and initializes the configuration.
|
protected Task.State state
protected Integer returnCode
protected Throwable lastException
protected final ApplicationPrintStream errorPrintStream
protected final ApplicationPrintStream outPrintStream
protected Task(ControlPanelInfo info, ProgressDialog progressDialog)
info
- the control panel information.progressDialog
- the progress dialog where the task progress will be
displayed.public abstract Set<String> getBackends()
public ControlPanelInfo getInfo()
protected void stopPollingAndInitializeConfiguration() throws DirectoryException, InitializationException
DirectoryException
- if the configuration cannot be deregisteredInitializationException
- if a problem occurs during configuration initializationprotected void startPollingAndInitializeConfiguration() throws InitializationException
InitializationException
- if a problem occurs during configuration initializationpublic String getErrorLogs()
public String getOutputLogs()
public Task.State getState()
public Throwable getLastException()
null
if no exception was found.public Integer getReturnCode()
public Process getProcess()
null
if not process was launched.protected ProgressDialog getProgressDialog()
public boolean regenerateDescriptor()
true
so that the configuration will be re-read and
all the ConfigChangeListeners will receive a notification with the new
configuration.true
if a new server descriptor must be regenerated
when the task is over and false
otherwise.public void postOperation()
public abstract LocalizableMessage getTaskDescription()
public void addConfigurationElementCreatedListener(ConfigurationElementCreatedListener listener)
listener
- the listener.public void removeConfigurationElementCreatedListener(ConfigurationElementCreatedListener listener)
listener
- the listener.protected void notifyConfigurationElementCreated(Object configObject)
configObject
- the created object.protected String obfuscateLDIFLine(String line)
line
- the line of the LDIF file that must be treated.protected int executeCommandLine(String commandLineName, String[] args)
commandLineName
- the command line full path.args
- the arguments for the command-line.public abstract boolean canLaunch(Task taskToBeLaunched, Collection<LocalizableMessage> incompatibilityReasons)
true
.taskToBeLaunched
- the Task that we are trying to launch.incompatibilityReasons
- the list of incompatibility reasons that
must be updated.true
if the task that we are trying to launch can be
launched in parallel with this task and false
otherwise.public abstract void runTask()
public abstract Task.Type getType()
protected boolean runningOnSameServer(Task task)
task
- the task the task to be analyzed.true
if both tasks run on the same server and
false
otherwise.public ServerDescriptor getServer()
protected abstract String getCommandLinePath()
null
if there is not a command-line (or a single command-line)
associated with the task.protected String getCommandLinePath(String scriptBasicName)
scriptBasicName
- the script basic name (with no extension).protected abstract List<String> getCommandLineArguments()
protected List<String> getObfuscatedCommandLineArguments(List<String> clearArgs)
clearArgs
- the arguments in clear.protected List<String> getConfigCommandLineArguments()
protected List<String> getConnectionCommandLineArguments()
protected List<String> getConnectionCommandLineArguments(boolean useAdminConnector, boolean addConnectionTypeParameters)
useAdminConnector
- use the administration connector to generate
the command line.addConnectionTypeParameters
- add the connection type parameters
(--useSSL or --useStartTLS parameters: for ldapadd, ldapdelete, etc.).protected String getNoPropertiesFileArgument()
public String getCommandLineToDisplay()
protected boolean isServerRunning()
true
if the server is running and false
otherwise.public ApplicationPrintStream getErrorPrintStream()
public ApplicationPrintStream getOutPrintStream()
protected void printEquivalentCommandToModify(org.forgerock.opendj.ldap.Dn dn, Collection<org.forgerock.opendj.ldap.Modification> mods, boolean useAdminCtx)
dn
- the dn of the modified entry.mods
- the modifications.useAdminCtx
- use the administration connector.public static String getEquivalentCommandLine(String cmdName, List<String> args)
cmdName
- the command name.args
- the arguments for the command line.protected void printEquivalentCommandLine(String cmdName, List<String> args, LocalizableMessage msg)
cmdName
- the command name.args
- the arguments for the command line.msg
- the message associated with the command line.protected void printEquivalentRenameCommand(org.forgerock.opendj.ldap.Dn oldDN, org.forgerock.opendj.ldap.Dn newDN, boolean useAdminCtx)
oldDN
- the old DN of the entry.newDN
- the new DN of the entry.useAdminCtx
- use the administration connector.protected LocalizableMessage getIncompatibilityMessage(Task taskRunning, Task taskToBeLaunched)
taskRunning
- the task that is running.taskToBeLaunched
- the task that we are trying to launch.Copyright © 2010-2017 ForgeRock AS. All Rights Reserved.