From 6b91643447398f13e01a4e02f8431e5263fc9bff Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Wed, 20 Feb 2008 09:22:09 +0000
Subject: [PATCH] Fix for issue 2962 (Setup should allow non-secure replication port while LDAP access is SSL-enabled)

---
 opends/src/ads/org/opends/admin/ads/TopologyCache.java |   31 ++++++++++++++++++++++++++++++-
 1 files changed, 30 insertions(+), 1 deletions(-)

diff --git a/opends/src/ads/org/opends/admin/ads/TopologyCache.java b/opends/src/ads/org/opends/admin/ads/TopologyCache.java
index 8a9ef30..c3cf586 100644
--- a/opends/src/ads/org/opends/admin/ads/TopologyCache.java
+++ b/opends/src/ads/org/opends/admin/ads/TopologyCache.java
@@ -31,6 +31,7 @@
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.LinkedHashSet;
 import java.util.Map;
 import java.util.Set;
 import java.util.logging.Level;
@@ -41,6 +42,7 @@
 import org.opends.admin.ads.ADSContext.ServerProperty;
 import org.opends.admin.ads.util.ApplicationTrustManager;
 import org.opends.admin.ads.util.ConnectionUtils;
+import org.opends.admin.ads.util.PreferredConnection;
 import org.opends.admin.ads.util.ServerLoader;
 
 /**
@@ -57,6 +59,8 @@
   private String pwd;
   private Set<ServerDescriptor> servers = new HashSet<ServerDescriptor>();
   private Set<SuffixDescriptor> suffixes = new HashSet<SuffixDescriptor>();
+  private LinkedHashSet<PreferredConnection> preferredConnections =
+    new LinkedHashSet<PreferredConnection>();
 
   private final boolean isMultiThreaded = true;
   private final static int MULTITHREAD_TIMEOUT = 90 * 1000;
@@ -173,6 +177,30 @@
   }
 
   /**
+   * Sets the list of LDAP URLs and connection type that are preferred to be
+   * used to connect to the servers.  When we have a server to which we can
+   * connect using a URL on the list we will try to use it.
+   * @param cnx the list of preferred connections.
+   */
+  public void setPreferredConnections(LinkedHashSet<PreferredConnection> cnx)
+  {
+    preferredConnections.clear();
+    preferredConnections.addAll(cnx);
+  }
+
+  /**
+   * Returns the list of LDAP URLs and connection type that are preferred to be
+   * used to connect to the servers.  If a URL is on this list, when we have a
+   * server to which we can connect using that URL and the associated connection
+   * type we will try to use it.
+   * @return the list of preferred connections.
+   */
+  public LinkedHashSet<PreferredConnection> getPreferredConnections()
+  {
+    return new LinkedHashSet<PreferredConnection>(preferredConnections);
+  }
+
+  /**
    * Returns a Set containing all the servers that are registered in the ADS.
    * @return a Set containing all the servers that are registered in the ADS.
    */
@@ -240,7 +268,8 @@
       Map<ServerProperty,Object> serverProperties)
   {
     return new ServerLoader(serverProperties, dn, pwd,
-        trustManager == null ? null : trustManager.createCopy());
+        trustManager == null ? null : trustManager.createCopy(),
+            getPreferredConnections());
   }
 
   /**

--
Gitblit v1.10.0