@NotExtensible @ThreadSafety(level=COMPLETELY_THREADSAFE) public class Task extends java.lang.Object implements java.io.Serializable
NOTE: This class, and other classes within the
com.unboundid.ldap.sdk.unboundidds
package structure, are only
supported for use against Ping Identity, UnboundID, and
Nokia/Alcatel-Lucent 8661 server products. These classes provide support
for proprietary functionality or for external specifications that are not
considered stable or mature enough to be guaranteed to work in an
interoperable way with other types of LDAP servers.
Task
subclass that provides the logic for the task. This does not need to
be provided when creating a new task from one of the task-specific
subclasses.TaskState
enum for information about the possible states that a task may
have.FailedDependencyAction
enum for the failed dependency action
values that may be used.getTaskID()
method can be used to retrieve the
task ID), but task properties (including those specific to the particular
type to task) may also be accessed using a generic API. For example, the
getTaskPropertyValues()
method retrieves a map that correlates the
TaskProperty
objects for the task with the values that have been set
for those properties. See the documentation for the TaskManager
class for an example that demonstrates accessing task information using the
generic API.
BackupTask
instance using the generic API, you
would use the BackupTask.BackupTask(Map)
constructor, in which the
provided map contains a mapping between the properties and their values for
that task. The getTaskSpecificProperties()
method may be used to
retrieve a list of the task-specific properties that may be provided when
scheduling a task, and the getCommonTaskProperties()
method may be
used to retrieve a list of properties that can be provided when scheduling
any type of task.Modifier | Constructor and Description |
---|---|
protected |
Task()
Creates a new uninitialized task instance which should only be used for
obtaining general information about this task, including the task name,
description, and supported properties.
|
|
Task(Entry entry)
Creates a new task from the provided entry.
|
|
Task(java.lang.String taskClassName,
java.util.Map<TaskProperty,java.util.List<java.lang.Object>> properties)
Creates a new task from the provided set of task properties.
|
|
Task(java.lang.String taskID,
java.lang.String taskClassName)
Creates a new unscheduled task with the specified task ID and class name.
|
|
Task(java.lang.String taskID,
java.lang.String taskClassName,
java.util.Date scheduledStartTime,
java.util.List<java.lang.String> dependencyIDs,
FailedDependencyAction failedDependencyAction,
java.util.List<java.lang.String> notifyOnCompletion,
java.util.List<java.lang.String> notifyOnError)
Creates a new unscheduled task with the provided information.
|
|
Task(java.lang.String taskID,
java.lang.String taskClassName,
java.util.Date scheduledStartTime,
java.util.List<java.lang.String> dependencyIDs,
FailedDependencyAction failedDependencyAction,
java.util.List<java.lang.String> notifyOnStart,
java.util.List<java.lang.String> notifyOnCompletion,
java.util.List<java.lang.String> notifyOnSuccess,
java.util.List<java.lang.String> notifyOnError,
java.lang.Boolean alertOnStart,
java.lang.Boolean alertOnSuccess,
java.lang.Boolean alertOnError)
Creates a new unscheduled task with the provided information.
|
Modifier and Type | Method and Description |
---|---|
Entry |
createTaskEntry()
Creates an entry that may be added to the Directory Server to create a new
instance of this task.
|
static Task |
decodeTask(Entry entry)
Decodes the provided entry as a scheduled task.
|
java.util.Date |
getActualStartTime()
Retrieves the time that this task actually started running.
|
protected java.util.List<Attribute> |
getAdditionalAttributes()
Retrieves a list of the additional attributes (other than attributes common
to all task types) that should be included when creating new task entries
of this type.
|
protected java.util.List<java.lang.String> |
getAdditionalObjectClasses()
Retrieves a list of the additional object classes (other than the base
"top" and "ds-task" classes) that should be included when creating new task
entries of this type.
|
java.lang.Boolean |
getAlertOnError()
Retrieves the flag that indicates whether the server should generate an
administrative alert if this task fails to complete successfully.
|
java.lang.Boolean |
getAlertOnStart()
Retrieves the flag that indicates whether the server should generate an
administrative alert when this task starts running.
|
java.lang.Boolean |
getAlertOnSuccess()
Retrieves the flag that indicates whether the server should generate an
administrative alert if this task completes successfully.
|
static java.util.List<Task> |
getAvailableTaskTypes()
Retrieves a list containing instances of the available task types.
|
static java.util.List<TaskProperty> |
getCommonTaskProperties()
Retrieves a list of task properties that may be provided when scheduling
any type of task.
|
java.util.Date |
getCompletionTime()
Retrieves the time that this task completed.
|
java.util.List<java.lang.String> |
getDependencyIDs()
Retrieves a list of the task IDs for tasks that must complete before this
task will be eligible to start.
|
FailedDependencyAction |
getFailedDependencyAction()
Retrieves the failed dependency action for this task, which indicates the
behavior that it should exhibit if any of its dependencies encounter a
failure.
|
java.util.List<java.lang.String> |
getLogMessages()
Retrieves the log messages for this task.
|
java.util.List<java.lang.String> |
getNotifyOnCompletionAddresses()
Retrieves a list of the e-mail addresses of the individuals that should be
notified whenever this task completes processing, regardless of whether it
was successful.
|
java.util.List<java.lang.String> |
getNotifyOnErrorAddresses()
Retrieves a list of the e-mail addresses of the individuals that should be
notified if this task stops processing prematurely due to an error or
other external action (e.g., server shutdown or administrative cancel).
|
java.util.List<java.lang.String> |
getNotifyOnStartAddresses()
Retrieves a list of the e-mail addresses of the individuals that should be
notified whenever this task starts running.
|
java.util.List<java.lang.String> |
getNotifyOnSuccessAddresses()
Retrieves a list of the e-mail addresses of the individuals that should be
notified if this task completes successfully.
|
java.util.Date |
getScheduledStartTime()
Retrieves the time that this task is/was scheduled to start running.
|
TaskState |
getState()
Retrieves the current state for this task.
|
java.lang.String |
getTaskClassName()
Retrieves the fully-qualified name of the Java class that provides the
logic for this class.
|
java.lang.String |
getTaskDescription()
Retrieves a human-readable description for this task.
|
protected Entry |
getTaskEntry()
Retrieves the entry from which this task was decoded, if available.
|
java.lang.String |
getTaskEntryDN()
Retrieves the DN of the entry in which this scheduled task is defined.
|
java.lang.String |
getTaskID()
Retrieves the task ID for this task.
|
java.lang.String |
getTaskName()
Retrieves a human-readable name for this task.
|
java.util.Map<TaskProperty,java.util.List<java.lang.Object>> |
getTaskPropertyValues()
Retrieves the values of the task properties for this task.
|
java.util.List<TaskProperty> |
getTaskSpecificProperties()
Retrieves a list of task-specific properties that may be provided when
scheduling a task of this type.
|
boolean |
isCompleted()
Indicates whether this task has completed execution.
|
boolean |
isPending()
Indicates whether this task is currently pending execution.
|
boolean |
isRunning()
Indicates whether this task is currently running.
|
protected static java.lang.Boolean |
parseBoolean(TaskProperty p,
java.util.List<java.lang.Object> values,
java.lang.Boolean defaultValue)
Parses the provided set of values for the associated task property as a
Boolean . |
protected static boolean |
parseBooleanValue(Entry taskEntry,
java.lang.String attributeName,
boolean defaultValue)
Parses the value of the specified attribute as a
boolean value, or
throws an exception if the value cannot be decoded as a boolean. |
protected static java.util.Date |
parseDate(TaskProperty p,
java.util.List<java.lang.Object> values,
java.util.Date defaultValue)
Parses the provided set of values for the associated task property as a
Date . |
protected static java.lang.Long |
parseLong(TaskProperty p,
java.util.List<java.lang.Object> values,
java.lang.Long defaultValue)
Parses the provided set of values for the associated task property as a
Long . |
protected static java.lang.String |
parseString(TaskProperty p,
java.util.List<java.lang.Object> values,
java.lang.String defaultValue)
Parses the provided set of values for the associated task property as a
String . |
protected static java.util.List<java.lang.String> |
parseStringList(Entry taskEntry,
java.lang.String attributeName)
Parses the values of the specified attribute as a list of strings.
|
protected static java.lang.String[] |
parseStrings(TaskProperty p,
java.util.List<java.lang.Object> values,
java.lang.String[] defaultValues)
Parses the provided set of values for the associated task property as a
String array. |
java.lang.String |
toString()
Retrieves a string representation of this task.
|
void |
toString(java.lang.StringBuilder buffer)
Appends a string representation of this task to the provided buffer.
|
protected Task()
public Task(@Nullable java.lang.String taskID, @NotNull java.lang.String taskClassName)
taskID
- The task ID to use for this task. If it is
null
then a UUID will be generated for use
as the task ID.taskClassName
- The fully-qualified name of the Java class that
provides the logic for the task. It must not be
null
.public Task(@Nullable java.lang.String taskID, @NotNull java.lang.String taskClassName, @Nullable java.util.Date scheduledStartTime, @Nullable java.util.List<java.lang.String> dependencyIDs, @Nullable FailedDependencyAction failedDependencyAction, @Nullable java.util.List<java.lang.String> notifyOnCompletion, @Nullable java.util.List<java.lang.String> notifyOnError)
taskID
- The task ID to use for this task.taskClassName
- The fully-qualified name of the Java class
that provides the logic for the task. It
must not be null
.scheduledStartTime
- The time that this task should start
running.dependencyIDs
- The list of task IDs that will be required
to complete before this task will be
eligible to start.failedDependencyAction
- Indicates what action should be taken if
any of the dependencies for this task do
not complete successfully.notifyOnCompletion
- The list of e-mail addresses of individuals
that should be notified when this task
completes.notifyOnError
- The list of e-mail addresses of individuals
that should be notified if this task does
not complete successfully.public Task(@Nullable java.lang.String taskID, @NotNull java.lang.String taskClassName, @Nullable java.util.Date scheduledStartTime, @Nullable java.util.List<java.lang.String> dependencyIDs, @Nullable FailedDependencyAction failedDependencyAction, @Nullable java.util.List<java.lang.String> notifyOnStart, @Nullable java.util.List<java.lang.String> notifyOnCompletion, @Nullable java.util.List<java.lang.String> notifyOnSuccess, @Nullable java.util.List<java.lang.String> notifyOnError, @Nullable java.lang.Boolean alertOnStart, @Nullable java.lang.Boolean alertOnSuccess, @Nullable java.lang.Boolean alertOnError)
taskID
- The task ID to use for this task.taskClassName
- The fully-qualified name of the Java class
that provides the logic for the task. It
must not be null
.scheduledStartTime
- The time that this task should start
running.dependencyIDs
- The list of task IDs that will be required
to complete before this task will be
eligible to start.failedDependencyAction
- Indicates what action should be taken if
any of the dependencies for this task do
not complete successfully.notifyOnStart
- The list of e-mail addresses of individuals
that should be notified when this task
starts running.notifyOnCompletion
- The list of e-mail addresses of individuals
that should be notified when this task
completes.notifyOnSuccess
- The list of e-mail addresses of individuals
that should be notified if this task
completes successfully.notifyOnError
- The list of e-mail addresses of individuals
that should be notified if this task does
not complete successfully.alertOnStart
- Indicates whether the server should send an
alert notification when this task starts.alertOnSuccess
- Indicates whether the server should send an
alert notification if this task completes
successfully.alertOnError
- Indicates whether the server should send an
alert notification if this task fails to
complete successfully.public Task(@NotNull Entry entry) throws TaskException
entry
- The entry to use to create this task.TaskException
- If the provided entry cannot be parsed as a
scheduled task.public Task(@NotNull java.lang.String taskClassName, @NotNull java.util.Map<TaskProperty,java.util.List<java.lang.Object>> properties) throws TaskException
taskClassName
- The fully-qualified name of the Java class that
provides the logic for the task. It must not be
null
.properties
- The set of task properties and their corresponding
values to use for the task. It must not be
null
.TaskException
- If the provided set of properties cannot be used to
create a valid scheduled task.@NotNull public static java.util.List<Task> getAvailableTaskTypes()
@NotNull public java.lang.String getTaskName()
@NotNull public java.lang.String getTaskDescription()
@Nullable protected final Entry getTaskEntry()
null
if
this task was not created from an existing entry.@NotNull public final java.lang.String getTaskEntryDN()
@NotNull public final java.lang.String getTaskID()
@NotNull public final java.lang.String getTaskClassName()
@NotNull public final TaskState getState()
public final boolean isPending()
true
if this task is currently pending execution, or
false
if not.public final boolean isRunning()
true
if this task is currently running, or false
if not.public final boolean isCompleted()
true
if this task has completed execution, or
false
if not.@Nullable public final java.util.Date getScheduledStartTime()
null
if that is not available and therefore the task
should start running as soon as all dependencies have been met.@Nullable public final java.util.Date getActualStartTime()
null
if that is not available (e.g., because the task has not yet
started).@Nullable public final java.util.Date getCompletionTime()
null
if it has not
yet completed.@NotNull public final java.util.List<java.lang.String> getDependencyIDs()
@Nullable public final FailedDependencyAction getFailedDependencyAction()
null
if it
is not available.@NotNull public final java.util.List<java.lang.String> getLogMessages()
@NotNull public final java.util.List<java.lang.String> getNotifyOnStartAddresses()
@NotNull public final java.util.List<java.lang.String> getNotifyOnCompletionAddresses()
@NotNull public final java.util.List<java.lang.String> getNotifyOnSuccessAddresses()
@NotNull public final java.util.List<java.lang.String> getNotifyOnErrorAddresses()
@Nullable public final java.lang.Boolean getAlertOnStart()
true
if the server should send an alert when this task
starts running, false
if the server should not send an
alert, or null
if it is not available.@Nullable public final java.lang.Boolean getAlertOnSuccess()
true
if the server should send an alert if this task
completes successfully, false
if the server should not
send an alert, or null
if it is not available.@Nullable public final java.lang.Boolean getAlertOnError()
true
if the server should send an alert if this task fails
to complete successfully, false
if the server should not
send an alert, or null
if it is not available.@NotNull public final Entry createTaskEntry()
protected static boolean parseBooleanValue(@NotNull Entry taskEntry, @NotNull java.lang.String attributeName, boolean defaultValue) throws TaskException
boolean
value, or
throws an exception if the value cannot be decoded as a boolean.taskEntry
- The entry containing the attribute to be parsed.attributeName
- The name of the attribute from which the value was
taken.defaultValue
- The default value to use if the provided value
string is null
.true
if the value string represents a boolean value of
true
, false
if the value string represents a
boolean value of false
, or the default value if the value
string is null
.TaskException
- If the provided value string cannot be parsed as a
boolean
value.@NotNull protected static java.util.List<java.lang.String> parseStringList(@NotNull Entry taskEntry, @NotNull java.lang.String attributeName)
taskEntry
- The entry containing the attribute to be parsed.attributeName
- The name of the attribute from which the value was
taken.@Nullable protected static java.lang.Boolean parseBoolean(@NotNull TaskProperty p, @NotNull java.util.List<java.lang.Object> values, @Nullable java.lang.Boolean defaultValue) throws TaskException
Boolean
.p
- The task property with which the values are
associated.values
- The provided values for the task property.defaultValue
- The default value to use if the provided object array
is empty.Boolean
value.TaskException
- If there is a problem with the provided values.@Nullable protected static java.util.Date parseDate(@NotNull TaskProperty p, @NotNull java.util.List<java.lang.Object> values, @Nullable java.util.Date defaultValue) throws TaskException
Date
.p
- The task property with which the values are
associated.values
- The provided values for the task property.defaultValue
- The default value to use if the provided object array
is empty.Date
value.TaskException
- If there is a problem with the provided values.@Nullable protected static java.lang.Long parseLong(@NotNull TaskProperty p, @NotNull java.util.List<java.lang.Object> values, @Nullable java.lang.Long defaultValue) throws TaskException
Long
.p
- The task property with which the values are
associated.values
- The provided values for the task property.defaultValue
- The default value to use if the provided object array
is empty.Long
value.TaskException
- If there is a problem with the provided values.@Nullable protected static java.lang.String parseString(@NotNull TaskProperty p, @NotNull java.util.List<java.lang.Object> values, @Nullable java.lang.String defaultValue) throws TaskException
String
.p
- The task property with which the values are
associated.values
- The provided values for the task property.defaultValue
- The default value to use if the provided object array
is empty.String
value.TaskException
- If there is a problem with the provided values.@Nullable protected static java.lang.String[] parseStrings(@NotNull TaskProperty p, @NotNull java.util.List<java.lang.Object> values, @Nullable java.lang.String[] defaultValues) throws TaskException
String
array.p
- The task property with which the values are
associated.values
- The provided values for the task property.defaultValues
- The set of default values to use if the provided
object array is empty.String
values.TaskException
- If there is a problem with the provided values.@NotNull protected java.util.List<java.lang.String> getAdditionalObjectClasses()
@NotNull protected java.util.List<Attribute> getAdditionalAttributes()
@NotNull public static Task decodeTask(@NotNull Entry entry) throws TaskException
entry
- The entry to be decoded.TaskException
- If the provided entry cannot be parsed as a
scheduled task.@NotNull public static java.util.List<TaskProperty> getCommonTaskProperties()
@NotNull public java.util.List<TaskProperty> getTaskSpecificProperties()
@NotNull public java.util.Map<TaskProperty,java.util.List<java.lang.Object>> getTaskPropertyValues()
Boolean
,
Date
, Long
, or String
. Task properties which do
not have any values will be included in the map with an empty value list.
super.getTaskPropertyValues()
and the
values of their own task-specific properties.@NotNull public final java.lang.String toString()
toString
in class java.lang.Object