From c30a14be35ba387e61b960740f6afc1b9774bb3d Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Mon, 04 Apr 2016 13:38:34 +0000
Subject: [PATCH] Add ConnectionWrapper to replace all uses of InitialLdapContext

---
 opendj-server-legacy/src/main/java/org/opends/admin/ads/ADSContext.java |   25 +++++++++++++++++++------
 1 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/admin/ads/ADSContext.java b/opendj-server-legacy/src/main/java/org/opends/admin/ads/ADSContext.java
index 765e571..e34ec18 100644
--- a/opendj-server-legacy/src/main/java/org/opends/admin/ads/ADSContext.java
+++ b/opendj-server-legacy/src/main/java/org/opends/admin/ads/ADSContext.java
@@ -12,7 +12,7 @@
  * information: "Portions Copyright [year] [name of copyright owner]".
  *
  * Copyright 2007-2010 Sun Microsystems, Inc.
- * Portions Copyright 2012-2015 ForgeRock AS.
+ * Portions Copyright 2012-2016 ForgeRock AS.
  */
 package org.opends.admin.ads;
 
@@ -54,6 +54,7 @@
 import org.forgerock.i18n.slf4j.LocalizedLogger;
 import org.opends.admin.ads.ADSContextException.ErrorType;
 import org.opends.admin.ads.util.ConnectionUtils;
+import org.opends.admin.ads.util.ConnectionWrapper;
 import org.opends.quicksetup.Constants;
 import org.opends.server.schema.SchemaConstants;
 
@@ -320,16 +321,18 @@
 
   /** The context used to retrieve information. */
   private final InitialLdapContext dirContext;
+  private final ConnectionWrapper connectionWrapper;
 
   /**
    * Constructor of the ADSContext.
    *
-   * @param dirContext
-   *          the DirContext that must be used to retrieve information.
+   * @param connectionWrapper
+   *          provide connection either via JNDI or Ldap Connection
    */
-  public ADSContext(InitialLdapContext dirContext)
+  public ADSContext(ConnectionWrapper connectionWrapper)
   {
-    this.dirContext = dirContext;
+    this.connectionWrapper = connectionWrapper;
+    this.dirContext = connectionWrapper.getLdapContext();
   }
 
   /**
@@ -343,6 +346,16 @@
   }
 
   /**
+   * Returns the connection used to retrieve information by this ADSContext.
+   *
+   * @return the connection
+   */
+  public ConnectionWrapper getConnection()
+  {
+    return connectionWrapper;
+  }
+
+  /**
    * Method called to register a server in the ADS.
    *
    * @param serverProperties
@@ -2228,7 +2241,7 @@
     {
       ben = getDefaultBackendName();
     }
-    helper.createAdministrationSuffix(getDirContext(), ben);
+    helper.createAdministrationSuffix(connectionWrapper, ben);
   }
 
   /**

--
Gitblit v1.10.0