001    /*
002     * CDDL HEADER START
003     *
004     * The contents of this file are subject to the terms of the
005     * Common Development and Distribution License, Version 1.0 only
006     * (the "License").  You may not use this file except in compliance
007     * with the License.
008     *
009     * You can obtain a copy of the license at
010     * trunk/opends/resource/legal-notices/OpenDS.LICENSE
011     * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
012     * See the License for the specific language governing permissions
013     * and limitations under the License.
014     *
015     * When distributing Covered Code, include this CDDL HEADER in each
016     * file and include the License file at
017     * trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
018     * add the following below this CDDL HEADER, with the fields enclosed
019     * by brackets "[]" replaced with your own identifying information:
020     *      Portions Copyright [yyyy] [name of copyright owner]
021     *
022     * CDDL HEADER END
023     *
024     *
025     *      Copyright 2008 Sun Microsystems, Inc.
026     */
027    package org.opends.server.core;
028    
029    
030    import org.opends.server.types.DN;
031    import org.opends.server.types.SearchScope;
032    
033    
034    /**
035     * This class is the base class used to build the workflow topology.
036     * A workflow topology is a tree of workflows. Each node in the tree
037     * is attached to a WorkflowImpl which contains the task tree (ie. the
038     * processing).
039     *
040     * There are two types of workflow nodes. The first one is used to build
041     * nodes in the workflow topology (WorkflowTopologyNode) and the second
042     * one is used to implement the root DSE node (RootDseWorkflowTopology).
043     */
044    
045    public abstract class WorkflowTopology implements Workflow
046    {
047      // The workflow implementation containing the task tree (ie. the processing)
048      private WorkflowImpl workflowImpl = null;
049    
050    
051      /**
052       * Each workflow node may have specific tasks to be executed before
053       * the workflow task tree. The tasks to execute before are stored in
054       * the following array, which is empty at the moment (implementation
055       * will come later on when needed).
056       */
057      // private WorkflowElement[] preWorkflowElements = null;
058    
059    
060      /**
061       * Each workflow node may have specific tasks to be executed after
062       * the workflow task tree. The tasks to execute after are stored in
063       * the following array, which is empty at the moment (implementation
064       * will come later on when needed).
065       */
066      // private WorkflowElement[] postWorkflowElements = null;
067    
068    
069      /**
070       * Create a new instance of the workflow topology base class.
071       * The instance is initialized with the workflow implementation which
072       * contains the task tree (ie. the processing).
073       *
074       * @param workflowImpl the workflow which contains the processing
075       */
076      protected WorkflowTopology(WorkflowImpl workflowImpl)
077      {
078        this.workflowImpl = workflowImpl;
079      }
080    
081    
082      /**
083       * Returns the workflow implementation which contains the task tree
084       * (ie. the processing).
085       *
086       * @return the workflow implementation which contains the processing
087       */
088      public WorkflowImpl getWorkflowImpl()
089      {
090        return workflowImpl;
091      }
092    
093    
094      /**
095       * Gets the base DN of the workflow node. The base DN of the workflow
096       * node is the base DN of the attached workflow implementation containing
097       * the processing.
098       *
099       * @return the base DN of the workflow containing the processing.
100       */
101      public DN getBaseDN()
102      {
103        return getWorkflowImpl().getBaseDN();
104      }
105    
106    
107      /**
108       * Elaborates a new search scope according to the current search scope.
109       * The new scope is intended to be used for searches on subordinate
110       * workflows.
111       *
112       * @param currentScope  the current search scope
113       * @return the new scope to use for searches on subordinate workflows,
114       *         <code>null</code> when current scope is 'base'
115       */
116    
117      protected SearchScope elaborateScopeForSearchInSubordinates(
118          SearchScope currentScope
119          )
120      {
121        switch (currentScope)
122        {
123        case BASE_OBJECT:
124          return null;
125        case SINGLE_LEVEL:
126          return SearchScope.BASE_OBJECT;
127        case SUBORDINATE_SUBTREE:
128        case WHOLE_SUBTREE:
129          return SearchScope.WHOLE_SUBTREE;
130        default:
131          return currentScope;
132        }
133      }
134    
135    }