From e6edbcc813d2c8f040497e9e809cf8e63c3222ad Mon Sep 17 00:00:00 2001
From: Nicolas Capponi <nicolas.capponi@forgerock.com>
Date: Mon, 07 Nov 2016 15:05:30 +0000
Subject: [PATCH] OPENDJ-3417 Update retrieval of controls and features to use backends methods

---
 opendj-server-legacy/src/main/java/org/opends/server/api/LocalBackend.java          |    6 ------
 opendj-server-legacy/src/main/java/org/opends/server/core/DirectoryServer.java      |   20 ++++++++++++++++----
 opendj-server-legacy/src/main/java/org/opends/server/backends/RootDSEBackend.java   |   14 +-------------
 opendj-server-legacy/src/main/java/org/opends/server/core/BackendConfigManager.java |   10 ----------
 opendj-server-legacy/src/main/java/org/opends/server/api/Backend.java               |    7 -------
 5 files changed, 17 insertions(+), 40 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/server/api/Backend.java b/opendj-server-legacy/src/main/java/org/opends/server/api/Backend.java
index 034ffa6..bd6d6ba 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/api/Backend.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/api/Backend.java
@@ -112,13 +112,6 @@
   public abstract boolean isDefaultRoute();
 
   /**
-   * Retrieves the password storage schemes defined for this backend.
-   *
-   * @return the set of supported password storage schemes
-   */
-  public abstract Set<PasswordStorageScheme<?>> getSupportedPasswordStorageSchemes();
-
-  /**
    * Retrieves the OIDs of the controls that may be supported by this
    * backend.
    *
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/api/LocalBackend.java b/opendj-server-legacy/src/main/java/org/opends/server/api/LocalBackend.java
index afe752c..4c525c9 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/api/LocalBackend.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/api/LocalBackend.java
@@ -21,7 +21,6 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.HashSet;
 import java.util.LinkedHashSet;
 import java.util.Queue;
 import java.util.Set;
@@ -707,11 +706,6 @@
     return persistentSearches;
   }
 
-  @Override
-  public Set<PasswordStorageScheme<?>> getSupportedPasswordStorageSchemes() {
-    return new HashSet<PasswordStorageScheme<?>>(DirectoryServer.getPasswordStorageSchemes());
-  }
-
   /**
    * Retrieves the total number of entries contained in this backend,
    * if that information is available.
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/RootDSEBackend.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/RootDSEBackend.java
index fc300ea..4b235a8 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/RootDSEBackend.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/RootDSEBackend.java
@@ -335,7 +335,7 @@
     addAttribute(privateNamingContextAttr, dseUserAttrs, dseOperationalAttrs);
 
     // Add the "supportedControl" attribute.
-    Attribute supportedControlAttr = createAttribute(ATTR_SUPPORTED_CONTROL, getAllControls());
+    Attribute supportedControlAttr = createAttribute(ATTR_SUPPORTED_CONTROL, DirectoryServer.getSupportedControls());
     addAttribute(supportedControlAttr, dseUserAttrs, dseOperationalAttrs);
 
     // Add the "supportedExtension" attribute.
@@ -414,18 +414,6 @@
     return e;
   }
 
-  private Set<String> getAllControls()
-  {
-    // TODO: this duplicates what is done in DirectoryServer (see DirectoryServer.getSupportedControls())
-    // How should this be handled ?
-    final Set<String> controls = new HashSet<>();
-    for (Backend<?> backend : serverContext.getBackendConfigManager().getAllBackends())
-    {
-      controls.addAll(backend.getSupportedControls());
-    }
-    return controls;
-  }
-
   private Set<DN> getAllPublicNamingContexts()
   {
     Set<DN> namingContexts = new HashSet<>();
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/core/BackendConfigManager.java b/opendj-server-legacy/src/main/java/org/opends/server/core/BackendConfigManager.java
index d39be75..2bd03e8 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/core/BackendConfigManager.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/core/BackendConfigManager.java
@@ -533,16 +533,6 @@
       }
       localBackends.put(backendID, backend);
 
-      for (String oid : backend.getSupportedControls())
-      {
-        registerSupportedControl(oid);
-      }
-
-      for (String oid : backend.getSupportedFeatures())
-      {
-        registerSupportedFeature(oid);
-      }
-
       LocalBackendMonitor monitor = new LocalBackendMonitor(backend);
       monitor.initializeMonitorProvider(null);
       backend.setBackendMonitor(monitor);
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/core/DirectoryServer.java b/opendj-server-legacy/src/main/java/org/opends/server/core/DirectoryServer.java
index 44b0d21..40a62e8 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/core/DirectoryServer.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/core/DirectoryServer.java
@@ -83,6 +83,7 @@
 import org.opends.server.api.AlertGenerator;
 import org.opends.server.api.AlertHandler;
 import org.opends.server.api.AuthenticationPolicy;
+import org.opends.server.api.Backend;
 import org.opends.server.api.LocalBackend;
 import org.opends.server.api.BackupTaskListener;
 import org.opends.server.api.CertificateMapper;
@@ -3627,9 +3628,15 @@
    */
   public static TreeSet<String> getSupportedControls()
   {
-    return directoryServer.supportedControls;
+    TreeSet<String> controls = new TreeSet<>(directoryServer.supportedControls);
+    for (Backend<?> backend : directoryServer.backendConfigManager.getAllBackends())
+    {
+      controls.addAll(backend.getSupportedControls());
+    }
+    return controls;
   }
 
+
   /**
    * Indicates whether the specified OID is registered with the Directory Server
    * as a supported control.
@@ -3642,7 +3649,7 @@
    */
   public static boolean isSupportedControl(String controlOID)
   {
-    return directoryServer.supportedControls.contains(controlOID);
+    return getSupportedControls().contains(controlOID);
   }
 
   /**
@@ -3686,7 +3693,12 @@
    */
   public static TreeSet<String> getSupportedFeatures()
   {
-    return directoryServer.supportedFeatures;
+    TreeSet<String> features = new TreeSet<>(directoryServer.supportedFeatures);
+    for (Backend<?> backend : directoryServer.backendConfigManager.getAllBackends())
+    {
+      features.addAll(backend.getSupportedFeatures());
+    }
+    return features;
   }
 
   /**
@@ -3701,7 +3713,7 @@
    */
   public static boolean isSupportedFeature(String featureOID)
   {
-    return directoryServer.supportedFeatures.contains(featureOID);
+    return getSupportedFeatures().contains(featureOID);
   }
 
   /**

--
Gitblit v1.10.0