org.apache.wiki.workflow
Class WorkflowBuilder

java.lang.Object
  extended by org.apache.wiki.workflow.WorkflowBuilder

public final class WorkflowBuilder
extends Object

Factory class that creates common Workflow instances such as a standard approval workflow.


Method Summary
 Workflow buildApprovalWorkflow(Principal submitter, String workflowApproverKey, Task prepTask, String decisionKey, Fact[] facts, Task completionTask, String rejectedMessageKey)
          Builds an approval workflow that requests approval from a named user, Group or Role before running a Task.
static WorkflowBuilder getBuilder(WikiEngine engine)
          Returns the WorkflowBuilder instance for a WikiEngine.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getBuilder

public static WorkflowBuilder getBuilder(WikiEngine engine)
Returns the WorkflowBuilder instance for a WikiEngine. Only one WorkflowBuilder exists for a given engine.

Parameters:
engine - the wiki engine
Returns:
the workflow builder

buildApprovalWorkflow

public Workflow buildApprovalWorkflow(Principal submitter,
                                      String workflowApproverKey,
                                      Task prepTask,
                                      String decisionKey,
                                      Fact[] facts,
                                      Task completionTask,
                                      String rejectedMessageKey)
                               throws WikiException

Builds an approval workflow that requests approval from a named user, Group or Role before running a Task.

The Principal who approves the activity is determined by looking up the property jspwiki.approver.workflowApproverKey in jspwiki.properties. If that Principal resolves to a known user, Group Role, a Decision will be placed in the respective workflow queue (or multiple queues, if necessary). Only one approver needs to make the Decision, and if the request is approved, the completion task will be executed. If the request is denied, a SimpleNotification with a message corresponding to the rejectedMessage message key will be placed in the submitter's workflow queue.

To help approvers determine how to make the Decision, callers can supply an array of Fact objects to this method, which will be added to the Decision in the order they appear in the array. These items will be displayed in the web UI. In addition, the value of the first Fact will also be added as the third message argument for the workflow (the first two are always the submitter and the approver). For example, the PageManager code that creates the "save page approval" workflow adds the name of the page as its first Fact; this results in the page name being substituted correctly into the resulting message: "Save wiki page <strong>{2}</strong>".

Parameters:
submitter - the user submitting the request
workflowApproverKey - the key that names the user, Group or Role who must approve the request. The key is looked up in jspwiki.properties, and is derived by prepending jspwiki.approver to the value of workflowApproverKey
prepTask - the initial task that should run before the Decision step is processed. If this parameter is null, the Decision will run as the first Step instead
decisionKey - the message key in default.properties that contains the text that will appear in approvers' workflow queues indicating they need to make a Decision; for example, decision.saveWikiPage. In the i18n message bundle file, this key might return text that reads "Approve page <strong>{2}</strong>"
facts - an array of Fact objects that will be shown to the approver to aid decision-making. The facts will be displayed in the order supplied in the array
completionTask - the Task that will run if the Decision is approved
rejectedMessageKey - the message key in default.properties that contains the text that will appear in the submitter's workflow queue if request was not approved; for example, notification.saveWikiPage.reject. In the i18n message bundle file, this key might might return text that reads "Your request to save page <strong>{2}</strong> was rejected." If this parameter is null, no message will be sent
Returns:
the created workflow
Throws:
WikiException - if the name of the approving user, Role or Group cannot be determined


Copyright © {inceptionYear}-2014 The Apache Software Foundation. All rights reserved.