From 609077ed606e3b094e303f298e8dca10567bc3e2 Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Fri, 05 Aug 2016 18:42:07 +0000
Subject: [PATCH] Partial OPENDJ-2625 Convert all code that uses JNDI to use the SDK instead

---
 opendj-server-legacy/src/main/java/org/opends/quicksetup/util/ServerController.java |   29 ++++++++++++-----------------
 1 files changed, 12 insertions(+), 17 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/quicksetup/util/ServerController.java b/opendj-server-legacy/src/main/java/org/opends/quicksetup/util/ServerController.java
index 3278e98..a4ee88a 100644
--- a/opendj-server-legacy/src/main/java/org/opends/quicksetup/util/ServerController.java
+++ b/opendj-server-legacy/src/main/java/org/opends/quicksetup/util/ServerController.java
@@ -23,20 +23,19 @@
 import java.util.List;
 import java.util.Map;
 
-import javax.naming.NamingException;
-
 import org.forgerock.i18n.LocalizableMessage;
 import org.forgerock.i18n.LocalizableMessageBuilder;
 import org.forgerock.i18n.slf4j.LocalizedLogger;
 import org.forgerock.opendj.ldap.DN;
+import org.forgerock.opendj.ldap.LdapException;
 import org.opends.admin.ads.util.ConnectionWrapper;
-import org.opends.admin.ads.util.PreferredConnection.Type;
 import org.opends.quicksetup.Application;
 import org.opends.quicksetup.ApplicationException;
 import org.opends.quicksetup.Configuration;
 import org.opends.quicksetup.Installation;
 import org.opends.quicksetup.ReturnCode;
 import org.opends.quicksetup.installer.InstallerHelper;
+import org.opends.server.types.HostPort;
 import org.opends.server.util.SetupUtils;
 
 import com.forgerock.opendj.cli.CliConstants;
@@ -45,6 +44,7 @@
 import static com.forgerock.opendj.cli.Utils.*;
 import static com.forgerock.opendj.util.OperatingSystem.*;
 
+import static org.opends.admin.ads.util.PreferredConnection.Type.*;
 import static org.opends.messages.QuickSetupMessages.*;
 import static org.opends.server.util.CollectionUtils.*;
 
@@ -457,22 +457,17 @@
 
     for (int i=0; i<50 && !connected; i++)
     {
-      String hostName = getHostName(i);
-      String ldapUrl = "ldaps://"+hostName+":" + port;
-      try
+      int timeout = CliConstants.DEFAULT_LDAP_CONNECT_TIMEOUT;
+      if (application != null && application.getUserData() != null)
       {
-        int timeout = CliConstants.DEFAULT_LDAP_CONNECT_TIMEOUT;
-        if (application != null && application.getUserData() != null)
-        {
-          timeout = application.getUserData().getConnectTimeout();
-        }
-        try (ConnectionWrapper conn =
-            new ConnectionWrapper(ldapUrl, Type.LDAPS, userDn, userPw, timeout, null))
-        {
-          return;
-        }
+        timeout = application.getUserData().getConnectTimeout();
       }
-      catch (NamingException ne)
+      HostPort hp = new HostPort(getHostName(i), port);
+      try (ConnectionWrapper conn = new ConnectionWrapper(hp, LDAPS, userDn, userPw, timeout, null))
+      {
+        return;
+      }
+      catch (LdapException ne)
       {
         logger.warn(LocalizableMessage.raw("Could not connect to server: "+ne, ne));
       }

--
Gitblit v1.10.0