org.apache.lenya.cms.workflow
Class WorkflowFactory

java.lang.Object
  extended by org.apache.lenya.cms.workflow.WorkflowFactory

public class WorkflowFactory
extends java.lang.Object

Workflow factory.


Field Summary
static java.lang.String WORKFLOW_DIRECTORY
           
 
Constructor Summary
protected WorkflowFactory()
          Creates a new instance of WorkflowFactory
 
Method Summary
 WorkflowInstance buildInstance(Document document)
          Creates a new workflow instance.
 Situation buildSituation(Role[] roles, Identity identity)
          Creates a situation for a set of roles and an identity.
 Situation buildSituation(java.lang.String[] roleIds, java.lang.String userId, java.lang.String machineIp)
          Builds a situation from a role name set, a user ID and a machine IP address.
 SynchronizedWorkflowInstances buildSynchronizedInstance(Document document)
          Creates a new synchronized workflow instances object..
protected static Workflow buildWorkflow(Publication publication, java.lang.String workflowFileName)
          Builds a workflow for a given publication.
static void deleteHistory(Document document)
          Deletes the history of a document.
static History getHistory(Document document)
          Returns the workflow history of a document.
 boolean hasWorkflow(Document document)
          Checks if a workflow is assigned to the document.
static void initHistory(Document sourceDocument, Document destinationDocument, Situation situation)
          Initializes the workflow history of a document that is a copy of another document.
static void initHistory(Document document, java.lang.String workflowId, Situation situation)
          Initializes the history of a document.
static void moveHistory(Document oldDocument, Document newDocument)
          Moves the history of a document.
static WorkflowFactory newInstance()
          Returns an instance of the workflow factory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WORKFLOW_DIRECTORY

public static final java.lang.String WORKFLOW_DIRECTORY
Constructor Detail

WorkflowFactory

protected WorkflowFactory()
Creates a new instance of WorkflowFactory

Method Detail

newInstance

public static WorkflowFactory newInstance()
Returns an instance of the workflow factory.

Returns:
A workflow factory.

buildInstance

public WorkflowInstance buildInstance(Document document)
                               throws WorkflowException
Creates a new workflow instance.

Parameters:
document - The document to create the instance for.
Returns:
A workflow instance.
Throws:
WorkflowException - when something went wrong.

buildSynchronizedInstance

public SynchronizedWorkflowInstances buildSynchronizedInstance(Document document)
                                                        throws WorkflowException
Creates a new synchronized workflow instances object..

Parameters:
document - The document to create the instances for.
Returns:
A synchronized workflow instances object.
Throws:
WorkflowException - when something went wrong.

moveHistory

public static void moveHistory(Document oldDocument,
                               Document newDocument)
                        throws WorkflowException
Moves the history of a document.

Parameters:
oldDocument - The document to move the instance for.
newDocument - The new document.
Throws:
WorkflowException - when something went wrong.

deleteHistory

public static void deleteHistory(Document document)
                          throws WorkflowException
Deletes the history of a document.

Parameters:
document - The document to delete the instance for.
Throws:
WorkflowException - when something went wrong.

hasWorkflow

public boolean hasWorkflow(Document document)
Checks if a workflow is assigned to the document. This is done by looking for the workflow history file.

Parameters:
document - The document to check.
Returns:
true if the document has a workflow, false otherwise.

buildWorkflow

protected static Workflow buildWorkflow(Publication publication,
                                        java.lang.String workflowFileName)
                                 throws WorkflowException
Builds a workflow for a given publication.

Parameters:
publication - The publication.
workflowFileName - The workflow definition filename.
Returns:
A workflow object.
Throws:
WorkflowException - when something went wrong.

buildSituation

public Situation buildSituation(Role[] roles,
                                Identity identity)
                         throws WorkflowException
Creates a situation for a set of roles and an identity.

Parameters:
roles - The roles.
identity - The identity.
Returns:
A workflow situation.
Throws:
WorkflowException - when something went wrong.

buildSituation

public Situation buildSituation(java.lang.String[] roleIds,
                                java.lang.String userId,
                                java.lang.String machineIp)
Builds a situation from a role name set, a user ID and a machine IP address.

Parameters:
roleIds - The role IDs.
userId - The user ID.
machineIp - The machine IP address.
Returns:
A situation.

initHistory

public static void initHistory(Document document,
                               java.lang.String workflowId,
                               Situation situation)
                        throws WorkflowException
Initializes the history of a document.

Parameters:
document - The document object.
workflowId - The ID of the workflow.
situation - The current situation.
Throws:
WorkflowException - When something goes wrong.

getHistory

public static History getHistory(Document document)
Returns the workflow history of a document.

Parameters:
document - A document.
Returns:
A workflow history.

initHistory

public static void initHistory(Document sourceDocument,
                               Document destinationDocument,
                               Situation situation)
                        throws WorkflowException
Initializes the workflow history of a document that is a copy of another document.

Parameters:
sourceDocument - The original document.
destinationDocument - The document to initialize the history for.
Throws:
WorkflowException - When something goes wrong.


Copyright © 1999-2005 Apache Software Foundation. All Rights Reserved.