Package org.apache.wiki.workflow

# Class Task

java.lang.Object
org.apache.wiki.workflow.AbstractStep
org.apache.wiki.workflow.Task

All Implemented Interfaces:
  `Serializable`, `Step`

Direct Known Subclasses:
  `PreSaveWikiPageTask`, `SaveUserProfileTask`, `SaveWikiPageTask`

public abstract class Task extends AbstractStep
AbstractStep subclass that executes instructions, uninterrupted, and results in an Outcome. Concrete classes only need to implement `AbstractStep.execute(org.apache.wiki.api.core.Context)`. When the execution step completes, `execute` must return `Outcome.STEP_COMPLETE`, `Outcome.STEP_CONTINUE` or `Outcome.STEP_ABORT`. Subclasses can add any errors by calling the helper method `AbstractStep.addError(String)`. The execute method should generally capture and add errors to the error list instead of throwing a WikiException.

Since:
  2.5
See Also:
  - Serialized Form

## Field Summary

### Fields inherited from interface org.apache.wiki.workflow.Step

`TIME_NOT_SET`

## Constructor Summary

Constructors
Constructor
Description
`Task(int workflowId, Map<String,Serializable> workflowContext, String messageKey)`
Constructs a new instance of a Task, with an associated Workflow and message key.
`Task(String messageKey)`
Public constructor that creates a new Task with a specified message key.

## Method Summary

Modifier and Type
Method
Description
`final Principal`
`getActor()`
Returns `SystemPrincipal.SYSTEM_USER`.
`final Step`
`getSuccessor()`
Identifies the next Step after this Task finishes successfully.
`final void`
`setSuccessor(Step step)`
Sets the successor Step to this one, which will be triggered if the Task completes successfully (that is, `Step.getOutcome()` returns `Outcome.STEP_COMPLETE`.

### Methods inherited from class org.apache.wiki.workflow.AbstractStep

`addError, addSuccessor, execute, getAvailableOutcomes, getEndTime, getErrors, getMessageKey, getOutcome, getStartTime, getSuccessor, getWorkflowContext, getWorkflowId, isCompleted, isStarted, setOutcome, setWorkflow, start`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### Task

public Task(String messageKey)
Public constructor that creates a new Task with a specified message key. After construction, the protected method `AbstractStep.setWorkflow(int, Map)` should be called.

Parameters:
  `messageKey` - the Step's message key, such as `decision.editPageApproval`. By convention, the message prefix should be a lower-case version of the Step's type, plus a period (e.g., `task.` and `decision.`).

### Task

public Task(int workflowId, Map<String,Serializable> workflowContext, String messageKey)
Constructs a new instance of a Task, with an associated Workflow and message key.

Parameters:
  `workflowId` - the parent workflow id to set
  `workflowContext` - the parent workflow context to set
  `messageKey` - the i18n message key

## Method Details

### getActor

public final Principal getActor()
Returns `SystemPrincipal.SYSTEM_USER`.

Specified by:
  `getActor` in interface `Step`
Specified by:
  `getActor` in class `AbstractStep`
Returns:
  the system principal

### setSuccessor

public final void setSuccessor(Step step)
Sets the successor Step to this one, which will be triggered if the Task completes successfully (that is, `Step.getOutcome()` returns `Outcome.STEP_COMPLETE`. This method is really a convenient shortcut for `Step.addSuccessor(Outcome, Step)`, where the first parameter is `Outcome.STEP_COMPLETE`.

Parameters:
  `step` - the successor

### getSuccessor

public final Step getSuccessor()
Identifies the next Step after this Task finishes successfully. This method will always return the value set in method `setSuccessor(Step)`, regardless of the current completion state.

Returns:
  the next step