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

jvergara
24.58.2009 66faa7347addc7e471fae7110da349485008adf2
Fix for issue 3826 (Exception in control panel LDAP browser)

Use DN class instead of String to compare DNs.
Handle the case where the node existed as a non-suffix node.
2 files modified
45 ■■■■ changed files
opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/browser/BrowserController.java 17 ●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/AbstractBrowseEntriesPanel.java 28 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/browser/BrowserController.java
@@ -258,8 +258,12 @@
   * @param suffixDn the DN of the suffix to be analyzed.
   * @return <CODE>true</CODE> if the provided String is the DN of a suffix
   * and <CODE>false</CODE> otherwise.
   * @throws IllegalArgumentException if a node with the given dn exists but
   * is not a suffix node.
   */
  public boolean hasSuffix(String suffixDn) {
  public boolean hasSuffix(String suffixDn)
  throws IllegalArgumentException
  {
    return (findSuffixNode(suffixDn, rootNode) != null);
  }
@@ -270,8 +274,11 @@
   * @param parentSuffixDn the DN of the parent suffix (or <CODE>null</CODE> if
   * there is no parent DN).
   * @return the TreePath of the new node.
   * @throws IllegalArgumentException if a node with the given dn exists.
   */
  public TreePath addSuffix(String suffixDn, String parentSuffixDn) {
  public TreePath addSuffix(String suffixDn, String parentSuffixDn)
  throws IllegalArgumentException
  {
    SuffixNode parentNode;
    if (parentSuffixDn != null) {
      parentNode = findSuffixNode(parentSuffixDn, rootNode);
@@ -1926,8 +1933,12 @@
   * @param suffixNode the node from which we start searching.
   * @return the SuffixNode associated with the provided DN.  <CODE>null</CODE>
   * if nothing is found.
   * @throws IllegalArgumentException if a node with the given dn exists but
   * is not a suffix node.
   */
  SuffixNode findSuffixNode(String suffixDn, SuffixNode suffixNode) {
  SuffixNode findSuffixNode(String suffixDn, SuffixNode suffixNode)
  throws IllegalArgumentException
  {
    SuffixNode result;
    if (Utilities.areDnsEqual(suffixNode.getDN(), suffixDn)) {
opendj-sdk/opends/src/guitools/org/opends/guitools/controlpanel/ui/AbstractBrowseEntriesPanel.java
@@ -664,6 +664,7 @@
    setPrimaryValid(lFilter);
    String s = getBaseDN();
    boolean displayAll = false;
    DN theDN = null;
    if (s != null)
    {
      displayAll = s.equals(ALL_BASE_DNS);
@@ -671,7 +672,7 @@
      {
        try
        {
          DN.decode(s);
          theDN = DN.decode(s);
        }
        catch (Throwable t)
        {
@@ -712,6 +713,10 @@
        {
          for (BaseDNDescriptor baseDN : backend.getBaseDns())
          {
            if ((theDN != null) && baseDN.getDn().equals(theDN))
            {
              isBaseDN = true;
            }
            String dn = Utilities.unescapeUtf8(baseDN.getDn().toString());
            if (displayAll)
            {
@@ -720,7 +725,6 @@
            else if (s.equals(dn))
            {
              controller.addSuffix(dn, null);
              isBaseDN = true;
            }
          }
        }
@@ -1331,16 +1335,22 @@
                }
                if (baseDN.getEntries() > 0)
                {
                  if (!controller.hasSuffix(dn))
                  try
                  {
                    if (displayAll)
                    if (!controller.hasSuffix(dn))
                    {
                      controller.addSuffix(dn, null);
                      if (displayAll || isBaseDN)
                      {
                        controller.addSuffix(dn, null);
                      }
                    }
                    else if (s.equals(dn))
                    {
                      controller.addSuffix(dn, null);
                    }
                  }
                  catch (IllegalArgumentException iae)
                  {
                    // The suffix node exists but is not a suffix node.
                    // Simply log a message.
                    LOG.log(Level.WARNING, "Suffix: "+dn+
                        " added as a non suffix node. Exception: "+iae, iae);
                  }
                }
              }