From b4d3e8fb81e04266baf9f54f44abd64a06402e78 Mon Sep 17 00:00:00 2001
From: neil_a_wilson <neil_a_wilson@localhost>
Date: Tue, 05 Dec 2006 21:41:50 +0000
Subject: [PATCH] Update the base DN registration process to address a number of issues:

---
 opendj-sdk/opends/src/server/org/opends/server/api/Backend.java |   92 +++++++++++++++++++++++++++++++++++++++------
 1 files changed, 79 insertions(+), 13 deletions(-)

diff --git a/opendj-sdk/opends/src/server/org/opends/server/api/Backend.java b/opendj-sdk/opends/src/server/org/opends/server/api/Backend.java
index a97914c..eba5623 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/api/Backend.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/api/Backend.java
@@ -29,6 +29,7 @@
 
 
 import java.util.ArrayList;
+import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Set;
 import java.util.concurrent.locks.Lock;
@@ -400,10 +401,18 @@
    * @param  controlOID  The OID of the control for which to make the
    *                     determination.
    *
-   * @return  <CODE>true</CODE> if this backend does support the
-   *          requested control, or <CODE>false</CODE>
+   * @return  {@code true} if this backends supports the control with
+   *          the specified OID, or {@code false} if it does not.
    */
-  public abstract boolean supportsControl(String controlOID);
+  public final boolean supportsControl(String controlOID)
+  {
+    assert debugEnter(CLASS_NAME, "supportsControl",
+                      String.valueOf(controlOID));
+
+    Set<String> supportedControls = getSupportedControls();
+    return ((supportedControls != null) &&
+            supportedControls.contains(controlOID));
+  }
 
 
 
@@ -424,10 +433,18 @@
    * @param  featureOID  The OID of the feature for which to make the
    *                     determination.
    *
-   * @return  <CODE>true</CODE> if this backend does support the
-   *          requested feature, or <CODE>false</CODE>
+   * @return  {@code true} if this backend supports the feature with
+   *          the specified OID, or {@code false} if it does not.
    */
-  public abstract boolean supportsFeature(String featureOID);
+  public final boolean supportsFeature(String featureOID)
+  {
+    assert debugEnter(CLASS_NAME, "supportsFeature",
+                      String.valueOf(featureOID));
+
+    Set<String> supportedFeatures = getSupportedFeatures();
+    return ((supportedFeatures != null) &&
+            supportedFeatures.contains(featureOID));
+  }
 
 
 
@@ -892,15 +909,64 @@
 
     synchronized (this)
     {
-      Backend[] newSubordinateBackends =
-           new Backend[subordinateBackends.length+1];
+      LinkedHashSet<Backend> backendSet =
+           new LinkedHashSet<Backend>();
 
-      System.arraycopy(subordinateBackends, 0, newSubordinateBackends,
-                       0, subordinateBackends.length);
-      newSubordinateBackends[subordinateBackends.length] =
-           subordinateBackend;
+      for (Backend b : subordinateBackends)
+      {
+        backendSet.add(b);
+      }
 
-      subordinateBackends = newSubordinateBackends;
+      if (backendSet.add(subordinateBackend))
+      {
+        Backend[] newSubordinateBackends =
+             new Backend[backendSet.size()];
+        backendSet.toArray(newSubordinateBackends);
+        subordinateBackends = newSubordinateBackends;
+      }
+    }
+  }
+
+
+
+  /**
+   * Removes the provided backend from the set of subordinate backends
+   * for this backend.
+   *
+   * @param  subordinateBackend  The backend to remove from the set of
+   *                             subordinate backends for this
+   *                             backend.
+   */
+  public void removeSubordinateBackend(Backend subordinateBackend)
+  {
+    assert debugEnter(CLASS_NAME, "removeSubordinateBackend",
+                      String.valueOf(subordinateBackend));
+
+    synchronized (this)
+    {
+      ArrayList<Backend> backendList =
+           new ArrayList<Backend>(subordinateBackends.length);
+
+      boolean found = false;
+      for (Backend b : subordinateBackends)
+      {
+        if (b.equals(subordinateBackend))
+        {
+          found = true;
+        }
+        else
+        {
+          backendList.add(b);
+        }
+      }
+
+      if (found)
+      {
+        Backend[] newSubordinateBackends =
+             new Backend[backendList.size()];
+        backendList.toArray(newSubordinateBackends);
+        subordinateBackends = newSubordinateBackends;
+      }
     }
   }
 

--
Gitblit v1.10.0