mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

jvergara
13.54.2010 ca8222868cc9467a49dea172db7f0ac80d94faff
Fix for issue 4484 (Follow Referrals functionality is broken).
The code was not complete. Fix some issues in different areas.
4 files modified
66 ■■■■■ changed files
opends/src/guitools/org/opends/guitools/controlpanel/browser/BrowserController.java 13 ●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/browser/LDAPConnectionPool.java 26 ●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/browser/NodeSearcherQueue.java 16 ●●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/ui/BrowseEntriesPanel.java 11 ●●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/browser/BrowserController.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 */
package org.opends.guitools.controlpanel.browser;
@@ -1148,7 +1148,8 @@
      boolean isConfigurationNode)
  throws NamingException {
    InitialLdapContext result;
    if (followReferrals && (node.getRemoteUrl() != null)) {
    if (followReferrals && (node.getRemoteUrl() != null))
    {
      result = connectionPool.getConnection(node.getRemoteUrl());
    }
    else {
@@ -1676,7 +1677,7 @@
      // Note: logically we should unconditionaly call:
      //  startRefreshNode(child, false, true);
      //
      // However doing that saturates _refreshQueue
      // However doing that saturates refreshQueue
      // with many nodes. And, by design, RefreshTask
      // won't do anything on a node if:
      //    - this node has no subordinates
@@ -2080,7 +2081,8 @@
  {
    String[] result = null;
    Set<String> values = ConnectionUtils.getValues(entry, "objectClass");
    if (values != null) {
    if (values != null)
    {
      for (String value : values)
      {
        boolean isReferral = value.equalsIgnoreCase("referral");
@@ -2091,10 +2093,9 @@
          {
            result = new String[refValues.size()];
            refValues.toArray(result);
            break;
          }
          break;
        }
        break;
      }
    }
    return result;
opends/src/guitools/org/opends/guitools/controlpanel/browser/LDAPConnectionPool.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 */
package org.opends.guitools.controlpanel.browser;
@@ -39,6 +39,7 @@
import org.opends.admin.ads.util.ApplicationTrustManager;
import org.opends.admin.ads.util.ConnectionUtils;
import org.opends.guitools.controlpanel.event.ReferralAuthenticationListener;
import org.opends.server.types.DN;
import org.opends.server.types.LDAPURL;
import org.opends.server.types.SearchScope;
@@ -59,7 +60,7 @@
 * returned connection is simply connected (ie anonymous bind).
 * <BR><BR>
 * LDAPConnectionPool shares connections and maintains a usage counter
 * for each connection: two calls to getConnection() withe the same URL
 * for each connection: two calls to getConnection() with the same URL
 * will return the same connection. Two calls to releaseConnection() will
 * be needed to make the connection 'potentially disconnectable'.
 * <BR><BR>
@@ -209,9 +210,20 @@
    synchronized(cr) {
      try {
        if (cr.ctx == null) {
          cr.ctx = createLDAPConnection(ldapUrl,
              authTable.get(key));
          boolean registerAuth = false;
          AuthRecord authRecord = authTable.get(key);
          if (authRecord == null)
          {
            // Best-effort: try with an already registered authentication
            authRecord = authTable.values().iterator().next();
            registerAuth = true;
          }
          cr.ctx = createLDAPConnection(ldapUrl, authRecord);
          cr.ctx.setRequestControls(requestControls);
          if (registerAuth)
          {
            authTable.put(key, authRecord);
          }
        }
      }
      catch(NamingException x) {
@@ -309,7 +321,7 @@
   * If authentication data are already available for the protocol/host/port
   * specified in the LDAPURl, they are replaced by the new data.
   * If true is passed as 'connect' parameter, registerAuth() creates the
   * connection and attemps to connect() and bind() . If connect() or bind()
   * connection and attempts to connect() and bind() . If connect() or bind()
   * fail, registerAuth() forwards the NamingException and does not register
   * the authentication data.
   * @param ldapUrl the LDAP URL of the server.
@@ -495,6 +507,10 @@
  {
    InitialLdapContext ctx;
    // Take the base DN out of the URL and only keep the protocol, host and port
    ldapUrl = new LDAPURL(ldapUrl.getScheme(), ldapUrl.getHost(),
          ldapUrl.getPort(), (DN)null, null, null, null, null);
    if (isSecureLDAPUrl(ldapUrl))
    {
      ctx = ConnectionUtils.createLdapsContext(ldapUrl.toString(), ar.dn,
opends/src/guitools/org/opends/guitools/controlpanel/browser/NodeSearcherQueue.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 */
package org.opends.guitools.controlpanel.browser;
@@ -233,9 +233,10 @@
   */
  public void run() {
    boolean interrupted = false;
    while (!interrupted) {
      try {
    while (!interrupted)
    {
      try
      {
        // Fetch and process a node also
        // taking care of update events
        AbstractNodeTask task = fetch();
@@ -246,11 +247,8 @@
        interrupted = true;
      }
      catch(Exception x) {
        // At this level, either it's an interruption
        // either it's a bug...
        if (! (x instanceof InterruptedException)) {
          x.printStackTrace();
        }
        // At this level it is a bug...
        x.printStackTrace();
      }
    }
  }
opends/src/guitools/org/opends/guitools/controlpanel/ui/BrowseEntriesPanel.java
@@ -543,7 +543,16 @@
    }
    if (node != null)
    {
      String dn = node.getDN();
      String dn;
      if (controller.getFollowReferrals() && node.getRemoteUrl() != null)
      {
        dn = node.getRemoteUrl().getRawBaseDN();
      }
      else
      {
        dn = node.getDN();
      }
      try
      {
        InitialLdapContext ctx =