From 1b4603e10c65c535a04e66c9fad1c602abb854c8 Mon Sep 17 00:00:00 2001
From: jdemendi <jdemendi@localhost>
Date: Tue, 25 Mar 2008 17:17:45 +0000
Subject: [PATCH] rollback fix for 2991, return entry should go through workflow elements

---
 opends/src/server/org/opends/server/core/SearchOperationWrapper.java                              |   48 -----------
 opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendWorkflowElement.java |   46 -----------
 opends/src/server/org/opends/server/workflowelement/WorkflowElement.java                          |  101 -------------------------
 3 files changed, 2 insertions(+), 193 deletions(-)

diff --git a/opends/src/server/org/opends/server/core/SearchOperationWrapper.java b/opends/src/server/org/opends/server/core/SearchOperationWrapper.java
index f4545c9..31864f9 100644
--- a/opends/src/server/org/opends/server/core/SearchOperationWrapper.java
+++ b/opends/src/server/org/opends/server/core/SearchOperationWrapper.java
@@ -41,7 +41,6 @@
 import org.opends.server.types.SearchResultEntry;
 import org.opends.server.types.SearchResultReference;
 import org.opends.server.types.SearchScope;
-import org.opends.server.workflowelement.WorkflowElement;
 
 
 /**
@@ -55,24 +54,6 @@
   // The wrapped operation.
   private SearchOperation search;
 
-  // The workflow element which has invoked the current operation.
-  // The returned entries and returned references must be sent to that
-  // workflow element.
-  private WorkflowElement<?> callingWorkflowElement = null;
-
-  /**
-   * Set the calling workflow element.
-   *
-   * @param callingWorkflowElement  the workflow element which has invoked
-   *                                the current operation
-   */
-  public void setCallingWorkflowElement(
-      WorkflowElement<?> callingWorkflowElement
-      )
-  {
-    this.callingWorkflowElement = callingWorkflowElement;
-  }
-
   /**
    * Creates a new search operation based on the provided search operation.
    *
@@ -91,20 +72,7 @@
   {
     boolean result;
 
-    // If the calling workflow element is defined then send the return
-    // entry to the workflow element, otherwise send the entry to the
-    // calling operation.
-    // Sometimes, the calling workflow element might not be set for
-    // an internal operation because the internal search is done using
-    // a local backend operation instead of an operation basis.
-    if (callingWorkflowElement != null)
-    {
-      result = callingWorkflowElement.returnEntry(entry, controls);
-    }
-    else
-    {
-      result = this.search.returnEntry(entry, controls);
-    }
+    result = this.search.returnEntry(entry, controls);
 
     return result;
   }
@@ -116,19 +84,7 @@
   {
     boolean result;
 
-    // If the calling workflow element is not set then send the
-    // reference to the calling operation, otherwise send the reference
-    // to the calling workflow element.
-    // an internal operation because the internal search is done using
-    // a local backend operation instead of an operation basis.
-    if (callingWorkflowElement != null)
-    {
-      result = callingWorkflowElement.returnReference(dn, reference);
-    }
-    else
-    {
-      result = this.search.returnReference(dn, reference);
-    }
+    result = this.search.returnReference(dn, reference);
 
     return result;
   }
diff --git a/opends/src/server/org/opends/server/workflowelement/WorkflowElement.java b/opends/src/server/org/opends/server/workflowelement/WorkflowElement.java
index 0e0b74e..21c7194 100644
--- a/opends/src/server/org/opends/server/workflowelement/WorkflowElement.java
+++ b/opends/src/server/org/opends/server/workflowelement/WorkflowElement.java
@@ -35,12 +35,7 @@
 import org.opends.messages.Message;
 import org.opends.server.admin.std.server.WorkflowElementCfg;
 import org.opends.server.config.ConfigException;
-import org.opends.server.core.SearchOperationBasis;
-import org.opends.server.types.Control;
-import org.opends.server.types.DN;
-import org.opends.server.types.Entry;
 import org.opends.server.types.Operation;
-import org.opends.server.types.SearchResultReference;
 import org.opends.server.types.CanceledOperationException;
 
 
@@ -77,13 +72,6 @@
   private static Object registeredWorkflowElementsLock = new Object();
 
 
-  // The original operation basis which has invoked the workflow.
-  // This original operation basis is only useful for the search
-  // operation, for the returned entry and returned reference to be
-  // processed before they are sent back to the client application.
-  private Operation originalOperationBasis = null;
-
-
   // The parent of the workflow element (null if the workflow element is
   // the root of the processing tree).
   private WorkflowElement<?> parent = null;
@@ -111,17 +99,6 @@
 
 
   /**
-   * Set the original operation basis which has invoked the workflow.
-   *
-   * @param operation  the operation basis which has invoked the workflow
-   */
-  protected void setOriginalOperationBasis(Operation operation)
-  {
-    this.originalOperationBasis = operation;
-  }
-
-
-  /**
    * Set the parent of the current workflow element.
    *
    * @param parent  the parent of the workflow element
@@ -287,83 +264,5 @@
     }
   }
 
-
-  /**
-   * Used as a callback for workflow elements to indicate that the provided
-   * entry matches the search criteria and that additional processing should
-   * be performed to potentially send it back to the client.
-   *
-   * @param  entry     The entry that matches the search criteria and should be
-   *                   sent to the client.
-   * @param  controls  The set of controls to include with the entry (may be
-   *                   <CODE>null</CODE> if none are needed).
-   *
-   * @return  <CODE>true</CODE> if the caller should continue processing the
-   *          search request and sending additional entries and references, or
-   *          <CODE>false</CODE> if not for some reason (e.g., the size limit
-   *          has been reached or the search has been abandoned).
-   */
-  public boolean returnEntry(
-      Entry entry,
-      List<Control> controls)
-  {
-    boolean result;
-
-    // If the workflow element has a parent then send the entry
-    // to the parent, otherwise send the entry to the operation
-    // basis. The operation basis will be in charge of sending
-    // the entry to the client application.
-    if (parent == null)
-    {
-      SearchOperationBasis searchOperationBasis =
-        (SearchOperationBasis) originalOperationBasis;
-      result = searchOperationBasis.returnEntry(entry, controls);
-    }
-    else
-    {
-      result = parent.returnEntry(entry, controls);
-    }
-
-    return result;
-  }
-
-
-  /**
-   * Used as a callback for workflow elements to indicate that the provided
-   * search reference was encountered during processing and that additional
-   * processing should be performed to potentially send it back to the client.
-   *
-   * @param  reference  The search reference to send to the client.
-   * @param  dn         The DN related to the specified search reference.
-   *
-   * @return  <CODE>true</CODE> if the caller should continue processing the
-   *          search request and sending additional entries and references , or
-   *          <CODE>false</CODE> if not for some reason (e.g., the size limit
-   *          has been reached or the search has been abandoned).
-   */
-  public boolean returnReference(
-      DN dn,
-      SearchResultReference reference)
-  {
-    boolean result;
-
-    // If the workflow element has a parent then send the reference
-    // to the parent, otherwise send the reference to the operation
-    // basis. The operation basis will be in charge of sending
-    // the reference to the client application.
-    if (parent == null)
-    {
-      SearchOperationBasis searchOperationBasis =
-        (SearchOperationBasis) originalOperationBasis;
-      result = searchOperationBasis.returnReference(dn, reference);
-    }
-    else
-    {
-      result = parent.returnReference(dn, reference);
-    }
-
-    return result;
-  }
-
 }
 
diff --git a/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendWorkflowElement.java b/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendWorkflowElement.java
index c4fa635..6f39879 100644
--- a/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendWorkflowElement.java
+++ b/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendWorkflowElement.java
@@ -344,15 +344,8 @@
         break;
 
       case SEARCH:
-        // First of all store the original operation basis so that returned
-        // entries can be sent to it later on
-        setOriginalOperationBasis(operation);
-
         LocalBackendSearchOperation searchOperation =
              new LocalBackendSearchOperation((SearchOperation) operation);
-        // Set the calling workflow element so that returnEntry and
-        // returnReference callbacks can be invoked later on.
-        searchOperation.setCallingWorkflowElement(this);
         searchOperation.processLocalSearch(backend);
         break;
 
@@ -431,44 +424,5 @@
                                   newAttachment);
   }
 
-
-
-  /**
-   * {@inheritDoc}
-   */
-  public boolean returnEntry(
-      Entry entry,
-      List<Control> controls)
-  {
-    boolean result;
-
-    // There is no specific processing to perform on the returned entry.
-    // Just let the superclass execute the generic processing on the
-    // returned entry.
-    result = super.returnEntry(entry, controls);
-
-    return result;
-  }
-
-
-
-  /**
-   * {@inheritDoc}
-   */
-  public boolean returnReference(
-      DN dn,
-      SearchResultReference reference)
-  {
-    boolean result;
-
-    // There is no specific processing to perform on the returned reference.
-    // Just let the superclass execute the generic processing on the
-    // returned reference.
-    result = super.returnReference(dn, reference);
-
-    return result;
-  }
-
-
 }
 

--
Gitblit v1.10.0