From b9a150bea0257e577bbc1e930a2a3b23f8c04d92 Mon Sep 17 00:00:00 2001
From: Nicolas Capponi <nicolas.capponi@forgerock.com>
Date: Fri, 07 Mar 2014 13:42:40 +0000
Subject: [PATCH] Checkpoint commit for OPENDJ-1308 Migrate schema support

---
 opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/CertificateMapperConfigManager.java    |   12 +-
 opendj-sdk/opendj3-server-dev/src/server/org/opends/server/admin/AdministrationConnector.java          |    7 +
 opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/RootDNConfigManager.java               |   26 +++--
 opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/IdentityMapperConfigManager.java       |   13 ++-
 opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/AlertHandlerConfigManager.java         |   17 ++--
 opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/EntryCacheConfigManager.java           |    9 +
 opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/KeyManagerProviderConfigManager.java   |   12 +-
 opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/DirectoryServer.java                   |   83 +++-----------------
 opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/TrustManagerProviderConfigManager.java |   12 +-
 9 files changed, 79 insertions(+), 112 deletions(-)

diff --git a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/admin/AdministrationConnector.java b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/admin/AdministrationConnector.java
index e5b73c2..08e300f 100644
--- a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/admin/AdministrationConnector.java
+++ b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/admin/AdministrationConnector.java
@@ -27,6 +27,7 @@
 package org.opends.server.admin;
 
 import static org.opends.messages.AdminMessages.*;
+
 import java.io.File;
 import java.io.FileWriter;
 import java.io.PrintWriter;
@@ -35,6 +36,7 @@
 import java.util.List;
 import java.util.SortedSet;
 import java.util.TreeSet;
+
 import javax.naming.ldap.Rdn;
 
 import org.forgerock.opendj.ldap.AddressMask;
@@ -51,6 +53,7 @@
 import org.opends.server.admin.std.server.LDAPConnectionHandlerCfg;
 import org.opends.server.admin.std.server.RootCfg;
 import org.opends.server.config.ConfigException;
+import org.opends.server.core.ServerContext;
 import org.opends.server.core.SynchronousStrategy;
 import org.opends.server.protocols.ldap.LDAPConnectionHandler;
 import org.opends.server.types.ConfigChangeResult;
@@ -592,11 +595,13 @@
   /**
    * Creates a self-signed JKS certificate if needed.
    *
+   * @param serverContext
+   *          The server context.
    * @throws InitializationException
    *           If an unexpected error occurred whilst trying to create the
    *           certificate.
    */
-  public static void createSelfSignedCertificateIfNeeded()
+  public static void createSelfSignedCertificateIfNeeded(ServerContext serverContext)
       throws InitializationException
   {
     try
diff --git a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/AlertHandlerConfigManager.java b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/AlertHandlerConfigManager.java
index 4b480d6..5b31427 100644
--- a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/AlertHandlerConfigManager.java
+++ b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/AlertHandlerConfigManager.java
@@ -66,22 +66,23 @@
 
   private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
 
-  // A mapping between the DNs of the config entries and the associated alert
-  // handlers.
-  private ConcurrentHashMap<DN,AlertHandler> alertHandlers;
+  /** A mapping between the DNs of the config entries and the associated alert handlers. */
+  private final ConcurrentHashMap<DN,AlertHandler> alertHandlers;
 
-
+  private final ServerContext serverContext;
 
   /**
    * Creates a new instance of this alert handler config manager.
+   *
+   * @param serverContext
+   *          The server context.
    */
-  public AlertHandlerConfigManager()
+  public AlertHandlerConfigManager(ServerContext serverContext)
   {
-    alertHandlers = new ConcurrentHashMap<DN,AlertHandler>();
+    this.serverContext = serverContext;
+    alertHandlers = new ConcurrentHashMap<DN, AlertHandler>();
   }
 
-
-
   /**
    * Initializes all alert handlers currently defined in the Directory Server
    * configuration.  This should only be called at Directory Server startup.
diff --git a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/CertificateMapperConfigManager.java b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/CertificateMapperConfigManager.java
index dc7c19c..a2d3120 100644
--- a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/CertificateMapperConfigManager.java
+++ b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/CertificateMapperConfigManager.java
@@ -72,18 +72,20 @@
   // certificate mappers.
   private ConcurrentHashMap<DN,CertificateMapper> certificateMappers;
 
-
+  private final ServerContext serverContext;
 
   /**
    * Creates a new instance of this certificate mapper config manager.
+   *
+   * @param serverContext
+   *          The server context.
    */
-  public CertificateMapperConfigManager()
+  public CertificateMapperConfigManager(ServerContext serverContext)
   {
-    certificateMappers = new ConcurrentHashMap<DN,CertificateMapper>();
+    this.serverContext = serverContext;
+    certificateMappers = new ConcurrentHashMap<DN, CertificateMapper>();
   }
 
-
-
   /**
    * Initializes all certificate mappers currently defined in the Directory
    * Server configuration.  This should only be called at Directory Server
diff --git a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/DirectoryServer.java b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/DirectoryServer.java
index ab354b6..988d939 100644
--- a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/DirectoryServer.java
+++ b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/DirectoryServer.java
@@ -1527,38 +1527,32 @@
       // registered.
       pluginConfigManager.initializePluginConfigManager();
 
-      // Initialize all the virtual attribute handlers.
+      // Virtual attribute handlers.
       virtualAttributeConfigManager.initializeVirtualAttributes();
 
-      // Initialize the core Directory Server configuration.
+      // The core Directory Server configuration.
       coreConfigManager = new CoreConfigManager(serverContext);
       coreConfigManager.initializeCoreConfig();
 
-      // Initialize the Directory Server crypto manager.
       initializeCryptoManager();
 
-      // Initialize the log rotation policies.
       rotationPolicyConfigManager = new LogRotationPolicyConfigManager(serverContext);
       rotationPolicyConfigManager.initializeLogRotationPolicyConfig();
 
-      // Initialize the log retention policies.
       retentionPolicyConfigManager = new LogRetentionPolicyConfigManager(serverContext);
       retentionPolicyConfigManager.initializeLogRetentionPolicyConfig();
 
-
-      // Initialize the server loggers.
+      // The server loggers.
       loggerConfigManager = new LoggerConfigManager(serverContext);
       loggerConfigManager.initializeLoggerConfig();
 
       RuntimeInformation.logInfo();
 
-      // Initialize the server alert handlers.
-      initializeAlertHandlers();
-
+      new AlertHandlerConfigManager(serverContext).initializeAlertHandlers();
 
       // Initialize the default entry cache. We have to have one before
       // <CODE>initializeBackends()</CODE> method kicks in further down.
-      entryCacheConfigManager = new EntryCacheConfigManager();
+      entryCacheConfigManager = new EntryCacheConfigManager(serverContext);
       entryCacheConfigManager.initializeDefaultEntryCache();
 
       // Initialize the administration connector self signed certificate if
@@ -1566,36 +1560,25 @@
       // picked up.
       if (startConnectionHandlers)
       {
-        AdministrationConnector.createSelfSignedCertificateIfNeeded();
+        AdministrationConnector.createSelfSignedCertificateIfNeeded(serverContext);
       }
 
-      // Initialize the key manager provider.
-      keyManagerProviderConfigManager = new KeyManagerProviderConfigManager();
+      keyManagerProviderConfigManager = new KeyManagerProviderConfigManager(serverContext);
       keyManagerProviderConfigManager.initializeKeyManagerProviders();
 
-      // Initialize the trust manager provider.
-      trustManagerProviderConfigManager =
-           new TrustManagerProviderConfigManager();
+      trustManagerProviderConfigManager = new TrustManagerProviderConfigManager(serverContext);
       trustManagerProviderConfigManager.initializeTrustManagerProviders();
 
-      // Initialize the certificate mapper.
-      certificateMapperConfigManager = new CertificateMapperConfigManager();
+      certificateMapperConfigManager = new CertificateMapperConfigManager(serverContext);
       certificateMapperConfigManager.initializeCertificateMappers();
 
+      identityMapperConfigManager = new IdentityMapperConfigManager(serverContext);
+      identityMapperConfigManager.initializeIdentityMappers();
 
-      // Initialize the identity mappers.
-      initializeIdentityMappers();
+      initializeRootDNConfigManager();
 
-
-      // Initialize the root DNs.
-      rootDNConfigManager = new RootDNConfigManager();
-      rootDNConfigManager.initializeRootDNs();
-
-
-      // Initialize the subentry manager.
       initializeSubentryManager();
 
-      // Initialize the group manager.
       initializeGroupManager();
 
       // Now we can initialize both subentry manager and group manager
@@ -1955,25 +1938,6 @@
 
 
   /**
-   * Initializes the set of alert handlers defined in the Directory Server.
-   *
-   * @throws  ConfigException  If there is a configuration problem with any of
-   *                           the alert handlers.
-   *
-   * @throws  InitializationException  If a problem occurs while initializing
-   *                                   the alert handlers that is not related to
-   *                                   the server configuration.
-   */
-  private void initializeAlertHandlers()
-          throws ConfigException, InitializationException
-  {
-    new AlertHandlerConfigManager().initializeAlertHandlers();
-  }
-
-
-
-
-  /**
    * Initializes the schema elements for the Directory Server, including the
    * matching rules, attribute syntaxes, attribute types, and object classes.
    *
@@ -2735,25 +2699,6 @@
 
 
   /**
-   * Initializes the set of identity mappers for the Directory Server.
-   *
-   * @throws  ConfigException  If there is a configuration problem with any of
-   *                           the extended operation handlers.
-   *
-   * @throws  InitializationException  If a problem occurs while initializing
-   *                                   the extended operation handlers that is
-   *                                   not related to the server configuration.
-   */
-  private void initializeIdentityMappers()
-          throws ConfigException, InitializationException
-  {
-    identityMapperConfigManager = new IdentityMapperConfigManager();
-    identityMapperConfigManager.initializeIdentityMappers();
-  }
-
-
-
-  /**
    * Initializes the set of extended operation handlers for the Directory
    * Server.
    *
@@ -2841,8 +2786,6 @@
     }
     catch (DirectoryException de)
     {
-      logger.traceException(de);
-
       throw new InitializationException(de.getMessageObject());
     }
   }
@@ -2949,7 +2892,7 @@
    */
   public void initializeRootDNConfigManager()
          throws ConfigException, InitializationException{
-    rootDNConfigManager = new RootDNConfigManager();
+    rootDNConfigManager = new RootDNConfigManager(serverContext);
     rootDNConfigManager.initializeRootDNs();
   }
 
diff --git a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/EntryCacheConfigManager.java b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/EntryCacheConfigManager.java
index f3db338..e3b2fbf 100644
--- a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/EntryCacheConfigManager.java
+++ b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/EntryCacheConfigManager.java
@@ -85,12 +85,17 @@
   private static final String
     DEFAULT_ENTRY_CACHE_MONITOR_PROVIDER = "Entry Caches";
 
+  private final ServerContext serverContext;
+
   /**
    * Creates a new instance of this entry cache config manager.
+   *
+   * @param serverContext
+   *          The server context.
    */
-  public EntryCacheConfigManager()
+  public EntryCacheConfigManager(ServerContext serverContext)
   {
-    // No implementation is required.
+    this.serverContext = serverContext;
   }
 
 
diff --git a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/IdentityMapperConfigManager.java b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/IdentityMapperConfigManager.java
index d92045b..afe556c 100644
--- a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/IdentityMapperConfigManager.java
+++ b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/IdentityMapperConfigManager.java
@@ -67,17 +67,20 @@
 
   private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
 
-  // A mapping between the DNs of the config entries and the associated identity
-  // mappers.
-  private ConcurrentHashMap<DN,IdentityMapper> identityMappers;
+  /** A mapping between the DNs of the config entries and the associated identity mappers. */
+  private final ConcurrentHashMap<DN,IdentityMapper> identityMappers;
 
-
+  private final ServerContext serverContext;
 
   /**
    * Creates a new instance of this identity mapper config manager.
+   *
+   * @param serverContext
+   *          The server context.
    */
-  public IdentityMapperConfigManager()
+  public IdentityMapperConfigManager(ServerContext serverContext)
   {
+    this.serverContext = serverContext;
     identityMappers = new ConcurrentHashMap<DN,IdentityMapper>();
   }
 
diff --git a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/KeyManagerProviderConfigManager.java b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/KeyManagerProviderConfigManager.java
index cb6dd3e..ab5ad1e 100644
--- a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/KeyManagerProviderConfigManager.java
+++ b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/KeyManagerProviderConfigManager.java
@@ -70,20 +70,22 @@
 
   // A mapping between the DNs of the config entries and the associated key
   // manager providers.
-  private ConcurrentHashMap<DN,KeyManagerProvider> providers;
+  private final ConcurrentHashMap<DN,KeyManagerProvider> providers;
 
-
+  private final ServerContext serverContext;
 
   /**
    * Creates a new instance of this key manager provider config manager.
+   *
+   * @param serverContext
+   *          The server context.
    */
-  public KeyManagerProviderConfigManager()
+  public KeyManagerProviderConfigManager(ServerContext serverContext)
   {
+    this.serverContext = serverContext;
     providers = new ConcurrentHashMap<DN,KeyManagerProvider>();
   }
 
-
-
   /**
    * Initializes all key manager providers currently defined in the Directory
    * Server configuration.  This should only be called at Directory Server
diff --git a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/RootDNConfigManager.java b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/RootDNConfigManager.java
index 429f55d..92eedbf 100644
--- a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/RootDNConfigManager.java
+++ b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/RootDNConfigManager.java
@@ -29,6 +29,8 @@
 
 
 
+
+
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
@@ -73,30 +75,32 @@
   // "cn=Root DNs,cn=config" entry itself.
   private RootPrivilegeChangeListener rootPrivilegeChangeListener;
 
-
+  private final ServerContext serverContext;
 
   /**
    * Creates a new instance of this root DN config manager.
+   *
+   * @param serverContext
+   *          The server context.
    */
-  public RootDNConfigManager()
+  public RootDNConfigManager(ServerContext serverContext)
   {
-    alternateBindDNs = new ConcurrentHashMap<DN,HashSet<DN>>();
+    this.serverContext = serverContext;
+    alternateBindDNs = new ConcurrentHashMap<DN, HashSet<DN>>();
     rootPrivilegeChangeListener = new RootPrivilegeChangeListener();
   }
 
-
-
   /**
    * Initializes all of the root users currently defined in the Directory Server
    * configuration, as well as the set of privileges that root users will
    * inherit by default.
    *
-   * @throws  ConfigException  If a configuration problem causes the identity
-   *                           mapper initialization process to fail.
-   *
-   * @throws  InitializationException  If a problem occurs while initializing
-   *                                   the identity mappers that is not related
-   *                                   to the server configuration.
+   * @throws ConfigException
+   *           If a configuration problem causes the identity mapper
+   *           initialization process to fail.
+   * @throws InitializationException
+   *           If a problem occurs while initializing the identity mappers that
+   *           is not related to the server configuration.
    */
   public void initializeRootDNs()
          throws ConfigException, InitializationException
diff --git a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/TrustManagerProviderConfigManager.java b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/TrustManagerProviderConfigManager.java
index a94067a..ece08b5 100644
--- a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/TrustManagerProviderConfigManager.java
+++ b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/core/TrustManagerProviderConfigManager.java
@@ -70,20 +70,22 @@
 
   // A mapping between the DNs of the config entries and the associated trust
   // manager providers.
-  private ConcurrentHashMap<DN,TrustManagerProvider> providers;
+  private final ConcurrentHashMap<DN,TrustManagerProvider> providers;
 
-
+  private final ServerContext serverContext;
 
   /**
    * Creates a new instance of this trust manager provider config manager.
+   *
+   * @param serverContext
+   *          The server context.
    */
-  public TrustManagerProviderConfigManager()
+  public TrustManagerProviderConfigManager(ServerContext serverContext)
   {
+    this.serverContext = serverContext;
     providers = new ConcurrentHashMap<DN,TrustManagerProvider>();
   }
 
-
-
   /**
    * Initializes all trust manager providers currently defined in the Directory
    * Server configuration.  This should only be called at Directory Server

--
Gitblit v1.10.0