From aaff8bbe83e02bba861c5cf1c6645dedc4e0ac1d Mon Sep 17 00:00:00 2001
From: neil_a_wilson <neil_a_wilson@localhost>
Date: Tue, 07 Aug 2007 21:45:40 +0000
Subject: [PATCH] Add support for a new type of plugin which can be used to detect changes and take some action whenever a subordinate entry is modified as a result of a modify DN operation that targets an entry that has one or more children (i.e., a subtree move or subtree rename operation).  At present, subordinate modify DN plugins are not allowed to change the contents of the entry as it is being moved/renamed, but an appropriate API is in place if we decide to add this functionality in the future.

---
 opends/tests/unit-tests-testng/src/server/org/opends/server/plugins/InvocationCounterPlugin.java |   48 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 48 insertions(+), 0 deletions(-)

diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/plugins/InvocationCounterPlugin.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/plugins/InvocationCounterPlugin.java
index a2f4ce8..4308d4a 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/plugins/InvocationCounterPlugin.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/plugins/InvocationCounterPlugin.java
@@ -28,6 +28,7 @@
 
 
 
+import java.util.List;
 import java.util.Set;
 import java.util.concurrent.atomic.AtomicInteger;
 
@@ -46,11 +47,13 @@
 import org.opends.server.api.plugin.SearchEntryPluginResult;
 import org.opends.server.api.plugin.SearchReferencePluginResult;
 import org.opends.server.api.plugin.StartupPluginResult;
+import org.opends.server.api.plugin.SubordinateModifyDNPluginResult;
 import org.opends.server.types.DisconnectReason;
 import org.opends.server.types.Entry;
 import org.opends.server.types.IntermediateResponse;
 import org.opends.server.types.LDIFExportConfig;
 import org.opends.server.types.LDIFImportConfig;
+import org.opends.server.types.Modification;
 import org.opends.server.types.SearchResultEntry;
 import org.opends.server.types.SearchResultReference;
 import org.opends.server.types.operation.*;
@@ -88,6 +91,8 @@
   private static AtomicInteger postResponseCounter    = new AtomicInteger(0);
   private static AtomicInteger searchEntryCounter     = new AtomicInteger(0);
   private static AtomicInteger searchReferenceCounter = new AtomicInteger(0);
+  private static AtomicInteger subordinateModifyDNCounter =
+                                    new AtomicInteger(0);
   private static AtomicInteger intermediateResponseCounter =
                                     new AtomicInteger(0);
   private static AtomicInteger postConnectCounter     = new AtomicInteger(0);
@@ -781,6 +786,48 @@
    * {@inheritDoc}
    */
   @Override()
+  public SubordinateModifyDNPluginResult processSubordinateModifyDN(
+              SubordinateModifyDNOperation modifyDNOperation, Entry oldEntry,
+              Entry newEntry, List<Modification> modifications)
+  {
+    subordinateModifyDNCounter.incrementAndGet();
+    return SubordinateModifyDNPluginResult.SUCCESS;
+  }
+
+
+
+
+  /**
+   * Retrieves the number of times the subordinate modify DN plugins have been
+   * called since the last reset.
+   *
+   * @return  The number of times the subordinate modify DN plugins have been
+   *          called since the last reset.
+   */
+  public static int getSubordinateModifyDNCount()
+  {
+    return subordinateModifyDNCounter.get();
+  }
+
+
+
+  /**
+   * Resets the subordinate modify DN plugin invocation count to zero.
+   *
+   * @return  The subordinate modify DN plugin invocation count before it was
+   *          reset.
+   */
+  public static int resetSubordinateModifyDNCount()
+  {
+    return subordinateModifyDNCounter.getAndSet(0);
+  }
+
+
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override()
   public IntermediateResponsePluginResult processIntermediateResponse(
               IntermediateResponse intermediateResponse)
   {
@@ -986,6 +1033,7 @@
     resetPostResponseCount();
     resetSearchEntryCount();
     resetSearchReferenceCount();
+    resetSubordinateModifyDNCount();
     resetIntermediateResponseCount();
     resetPostConnectCount();
     resetPostDisconnectCount();

--
Gitblit v1.10.0