org.opends.server.core
Class WorkflowTopologyNode

java.lang.Object
  extended by org.opends.server.core.WorkflowTopology
      extended by org.opends.server.core.WorkflowTopologyNode
All Implemented Interfaces:
Workflow

public class WorkflowTopologyNode
extends WorkflowTopology

This class implements a workflow node. A workflow node is used to build a tree of workflows (aka workflow topology). Each node may have a parent node and/or subordinate nodes. A node with no parent is a naming context. Each node in the workflow topology is linked to a WorkflowImpl which contains the real processing. The base DN of the workflow node is the base DN of the related WorkflowImpl. How the workflow topology is built? A workflow node is a subordinate of another workflow node when the base DN of the former workflow is an ancestor of the base DN of the latter workflow. A subtree search on a workflow node is performed on the node itself as well as on all the subordinate nodes.


Constructor Summary
WorkflowTopologyNode(WorkflowImpl workflowImpl, WorkflowElement[] preWorkflowElements, WorkflowElement[] postWorkflowElements)
          Creates a new node for a workflow topology.
 
Method Summary
 void execute(Operation operation)
          Executes an operation on a set of data being identified by the workflow node base DN.
 WorkflowTopologyNode getParent()
          Gets the parent workflow.
 DN getParentBaseDN(DN dn)
          Gets the base DN of the workflow that handles a given dn.
 java.util.ArrayList<WorkflowTopologyNode> getSubordinates()
          Gets the list of workflow subordinates.
 WorkflowTopologyNode getWorkflowCandidate(DN requestDN)
          Gets the highest workflow in the topology that can handle the requestDN.
 boolean insertSubordinate(WorkflowTopologyNode newWorkflow)
          Tries to insert a new workflow in the subordinate list of one of the current workflow subordinate, or in the current workflow subordinate list.
 boolean isPrivate()
          Indicates whether the root workflow element is encapsulating a private local backend or not.
 void remove()
          Removes the current workflow from the parent subordinate list and attach the workflow subordinates to the parent workflow.
 void removeSubordinate(WorkflowTopologyNode subordinate)
          Remove a workflow from the subordinate list.
 void setParent(WorkflowTopologyNode parent)
          Sets the parent workflow.
 java.lang.StringBuilder toString(java.lang.String leftMargin)
          Dumps info from the current workflow for debug purpose.
 
Methods inherited from class org.opends.server.core.WorkflowTopology
elaborateScopeForSearchInSubordinates, getBaseDN, getWorkflowImpl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WorkflowTopologyNode

public WorkflowTopologyNode(WorkflowImpl workflowImpl,
                            WorkflowElement[] preWorkflowElements,
                            WorkflowElement[] postWorkflowElements)
Creates a new node for a workflow topology. The new node is initialized with a WorkflowImpl which contains the real processing. Optionally, the node may have tasks to be executed before and/or after the real processing. In the current implementation, such pre and post workflow elements are not used.

Parameters:
workflowImpl - the real processing attached to the node
preWorkflowElements - the list of tasks to be executed before the real processing
postWorkflowElements - the list of tasks to be executed after the real processing
Method Detail

execute

public void execute(Operation operation)
             throws CanceledOperationException
Executes an operation on a set of data being identified by the workflow node base DN.

Parameters:
operation - the operation to execute
Throws:
CanceledOperationException - if this operation should be cancelled.

setParent

public void setParent(WorkflowTopologyNode parent)
Sets the parent workflow.

Parameters:
parent - the parent workflow of the current workflow

getParent

public WorkflowTopologyNode getParent()
Gets the parent workflow.

Returns:
the parent workflow.

isPrivate

public boolean isPrivate()
Indicates whether the root workflow element is encapsulating a private local backend or not.

Returns:
true if the root workflow element encapsulates a private local backend

getParentBaseDN

public DN getParentBaseDN(DN dn)
Gets the base DN of the workflow that handles a given dn. The elected workflow may be the current workflow or one of its subordiante workflows.

Parameters:
dn - the DN for which we are looking a parent DN
Returns:
the base DN which is the parent of the dn, null if no parent DN was found

removeSubordinate

public void removeSubordinate(WorkflowTopologyNode subordinate)
Remove a workflow from the subordinate list.

Parameters:
subordinate - the subordinate to remove from the subordinate list

insertSubordinate

public boolean insertSubordinate(WorkflowTopologyNode newWorkflow)
Tries to insert a new workflow in the subordinate list of one of the current workflow subordinate, or in the current workflow subordinate list.

Parameters:
newWorkflow - the new workflow to insert
Returns:
true if the new workflow has been inserted in any subordinate list

remove

public void remove()
Removes the current workflow from the parent subordinate list and attach the workflow subordinates to the parent workflow. Example: the workflow to remove is w2 w1 w1 | / \ w2 ==> w3 w4 / \ w3 w4 - Subordinate list of w1 is updated with w3 and w4. - Parent workflow of w3 and w4 is now w1.


getSubordinates

public java.util.ArrayList<WorkflowTopologyNode> getSubordinates()
Gets the list of workflow subordinates.

Returns:
the list of workflow subordinates

getWorkflowCandidate

public WorkflowTopologyNode getWorkflowCandidate(DN requestDN)
Gets the highest workflow in the topology that can handle the requestDN. The highest workflow is either the current workflow or one of its subordinates.

Parameters:
requestDN - The DN for which we search for a workflow
Returns:
the highest workflow that can handle the requestDN null if none was found

toString

public java.lang.StringBuilder toString(java.lang.String leftMargin)
Dumps info from the current workflow for debug purpose.

Parameters:
leftMargin - white spaces used to indent the traces
Returns:
a string buffer that contains trace information