From 1ad53161c35dfbd2c08b1f124d237f5f3cad9110 Mon Sep 17 00:00:00 2001
From: jdemendi <jdemendi@localhost>
Date: Thu, 19 Jul 2007 07:46:13 +0000
Subject: [PATCH] This set of changes is aiming at having a more consistent and clean code when an operation is canceled.

---
 opends/src/server/org/opends/server/core/SearchOperationBasis.java |   64 ++++++++++++++++++++++++--------
 1 files changed, 48 insertions(+), 16 deletions(-)

diff --git a/opends/src/server/org/opends/server/core/SearchOperationBasis.java b/opends/src/server/org/opends/server/core/SearchOperationBasis.java
index 7710d7c..d95e942 100644
--- a/opends/src/server/org/opends/server/core/SearchOperationBasis.java
+++ b/opends/src/server/org/opends/server/core/SearchOperationBasis.java
@@ -1151,8 +1151,7 @@
 
 
       // Invoke the post-response search plugins.
-      DirectoryServer.getPluginConfigManager().
-           invokePostResponseSearchPlugins(this);
+      invokePostResponsePlugins();
     }
   }
 
@@ -1631,17 +1630,18 @@
     setTimeLimitExpiration(timeLimitExpiration);
 
     // Check for and handle a request to cancel this operation.
-    if (getCancelRequest() != null)
+    if (cancelRequest != null)
     {
-      indicateCancelled(getCancelRequest());
+      indicateCancelled(cancelRequest);
       setProcessingStopTime();
       logSearchResultDone(this);
       return;
     }
 
+
     // Create a labeled block of code that we can break out of if a problem is
     // detected.
-    searchProcessing:
+searchProcessing:
     {
       PreParsePluginResult preParseResult =
         pluginConfigManager.invokePreParseSearchPlugins(this);
@@ -1677,13 +1677,9 @@
 
 
       // Check for and handle a request to cancel this operation.
-      if (getCancelRequest() != null)
+      if (cancelRequest != null)
       {
-        indicateCancelled(getCancelRequest());
-        setProcessingStopTime();
-        logSearchResultDone(this);
-        pluginConfigManager.invokePostResponseSearchPlugins(this);
-        return;
+        break searchProcessing;
       }
 
 
@@ -1710,17 +1706,37 @@
       workflow.execute(this);
     }
 
-    // Check for and handle a request to cancel this operation.
-    if ((getCancelRequest() != null) ||
-        (getCancelResult() == CancelResult.CANCELED))
+
+    // Check for a terminated connection.
+    if (getCancelResult() == CancelResult.CANCELED)
     {
-      indicateCancelled(getCancelRequest());
+      // Stop the processing timer.
       setProcessingStopTime();
+
+      // Log the add response message.
       logSearchResultDone(this);
-      pluginConfigManager.invokePostResponseSearchPlugins(this);
+
       return;
     }
 
+    // Check for and handle a request to cancel this operation.
+    if (cancelRequest != null)
+    {
+      indicateCancelled(cancelRequest);
+
+      // Stop the processing timer.
+      setProcessingStopTime();
+
+      // Log the search response message.
+      logSearchResultDone(this);
+
+      // Invoke the post-response search plugins.
+      invokePostResponsePlugins();
+
+      return;
+    }
+
+
     // Indicate that it is now too late to attempt to cancel the operation.
     setCancelResult(CancelResult.TOO_LATE);
 
@@ -1743,6 +1759,22 @@
     }
   }
 
+
+  /**
+   * Invokes the post response plugins.
+   */
+  private void invokePostResponsePlugins()
+  {
+    // Get the plugin config manager that will be used for invoking plugins.
+    PluginConfigManager pluginConfigManager =
+      DirectoryServer.getPluginConfigManager();
+
+    // Invoke the post response plugins that have been registered with
+    // the current operation
+    pluginConfigManager.invokePostResponseSearchPlugins(this);
+  }
+
+
   /**
    * Updates the error message and the result code of the operation.
    *

--
Gitblit v1.10.0