From 218b40d6e175f5b58b89ff7e0b3050577d3aff2f Mon Sep 17 00:00:00 2001
From: matthew_swift <matthew_swift@localhost>
Date: Mon, 10 Nov 2008 13:41:49 +0000
Subject: [PATCH] This change fixes issue 3567:

---
 opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java |   84 +++++++++++++++++++++++------------------
 1 files changed, 47 insertions(+), 37 deletions(-)

diff --git a/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java b/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java
index 0f903f0..dc83bc6 100644
--- a/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java
+++ b/opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java
@@ -65,6 +65,7 @@
 import org.opends.server.core.ModifyOperation;
 import org.opends.server.core.ModifyOperationWrapper;
 import org.opends.server.core.PasswordPolicyState;
+import org.opends.server.core.PersistentSearch;
 import org.opends.server.core.PluginConfigManager;
 import org.opends.server.loggers.debug.DebugTracer;
 import org.opends.server.protocols.asn1.ASN1OctetString;
@@ -293,16 +294,16 @@
   /**
    * Process this modify operation against a local backend.
    *
-   * @param  backend  The backend in which the modify operation should be
-   *                  performed.
-   *
-   * @throws CanceledOperationException if this operation should be
-   * cancelled
+   * @param wfe
+   *          The local backend work-flow element.
+   * @throws CanceledOperationException
+   *           if this operation should be cancelled
    */
-  void processLocalModify(Backend backend) throws CanceledOperationException {
+  void processLocalModify(final LocalBackendWorkflowElement wfe)
+      throws CanceledOperationException
+  {
     boolean executePostOpPlugins = false;
-
-    this.backend = backend;
+    this.backend = wfe.getBackend();
 
     clientConnection = getClientConnection();
 
@@ -690,11 +691,46 @@
     }
 
 
-    // Notify any change notification listeners that might be registered with
-    // the server.
+    // Register a post-response call-back which will notify persistent
+    // searches and change listeners.
     if (getResultCode() == ResultCode.SUCCESS)
     {
-      notifyChangeListeners();
+      registerPostResponseCallback(new Runnable()
+      {
+
+        public void run()
+        {
+          // Notify persistent searches.
+          for (PersistentSearch psearch : wfe.getPersistentSearches())
+          {
+            psearch.processModify(modifiedEntry, getChangeNumber(),
+                currentEntry);
+          }
+
+          // Notify change listeners.
+          for (ChangeNotificationListener changeListener : DirectoryServer
+              .getChangeNotificationListeners())
+          {
+            try
+            {
+              changeListener
+                  .handleModifyOperation(LocalBackendModifyOperation.this,
+                      currentEntry, modifiedEntry);
+            }
+            catch (Exception e)
+            {
+              if (debugEnabled())
+              {
+                TRACER.debugCaught(DebugLogLevel.ERROR, e);
+              }
+
+              Message message = ERR_MODIFY_ERROR_NOTIFYING_CHANGE_LISTENER
+                  .get(getExceptionMessage(e));
+              logError(message);
+            }
+          }
+        }
+      });
     }
   }
 
@@ -2228,32 +2264,6 @@
 
 
 
-  /**
-   * Notify any registered change listeners about this update.
-   */
-  private void notifyChangeListeners()
-  {
-    for (ChangeNotificationListener changeListener :
-         DirectoryServer.getChangeNotificationListeners())
-    {
-      try
-      {
-        changeListener.handleModifyOperation(this, currentEntry, modifiedEntry);
-      }
-      catch (Exception e)
-      {
-        if (debugEnabled())
-        {
-          TRACER.debugCaught(DebugLogLevel.ERROR, e);
-        }
-
-        Message message = ERR_MODIFY_ERROR_NOTIFYING_CHANGE_LISTENER.get(
-            getExceptionMessage(e));
-        logError(message);
-      }
-    }
-  }
-
   private boolean handleConflictResolution() {
       boolean returnVal = true;
 

--
Gitblit v1.10.0