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

Jean-Noël Rouvignac
03.52.2016 83ae76453e0b08ead8c12bd71c85445bdbbdb590
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/browser/NodeRefresher.java
@@ -510,16 +510,10 @@
          while (sr.hasNext())
          {
            entry = sr.readEntry();
            String name;
            if (entry.getName().isRootDN())
            {
              name = remoteDn;
              entry.setName(remoteDn);
            }
            else
            {
              name = unquoteRelativeName(entry.getName().toString()) + "," + remoteDn;
            }
            entry.setName(name);
            found = true;
          }
          if (!found)
@@ -728,23 +722,13 @@
            continue;
          }
          String name = unquoteRelativeName(r.getName().toString()) + "," + parentDn;
          boolean add = false;
          if (useCustomFilter())
          {
            // Check that is an immediate child: use a faster method by just
            // comparing the number of components.
            DN dn = null;
            try
            {
              dn = DN.valueOf(name);
              add = dn.size() == parentComponents + 1;
            }
            catch (Throwable t)
            {
              throw new RuntimeException("Error decoding dns: "+t, t);
            }
            final DN dn = r.getName();
            add = dn.size() == parentComponents + 1;
            if (!add)
            {
              // Is not a direct child.  Check if the parent has been added,
@@ -766,7 +750,6 @@
          }
          if (add)
          {
            r.setName(name);
            childEntries.add(r);
            // Time to time we update the display
            if (childEntries.size() >= 20) {
@@ -914,32 +897,6 @@
    }
  }
  /**
   * Removes the quotes surrounding the provided name.  JNDI can return relative
   * names with this format.
   * @param name the relative name to be treated.
   * @return an String representing the provided relative name without
   * surrounding quotes.
   */
  private String unquoteRelativeName(String name)
  {
    if (name.length() > 0 && name.charAt(0) == '"')
    {
      if (name.charAt(name.length() - 1) == '"')
      {
        return name.substring(1, name.length() - 1);
      }
      else
      {
        return name.substring(1);
      }
    }
    else
    {
      return name;
    }
  }
  /** DEBUG : Dump the state of the task. */
  void dump() {
    System.out.println("=============");
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/CustomSearchResult.java
@@ -24,8 +24,6 @@
import java.util.SortedSet;
import java.util.TreeSet;
import javax.naming.CompositeName;
import javax.naming.Name;
import javax.naming.NamingException;
import org.forgerock.opendj.ldap.AttributeDescription;
@@ -34,7 +32,6 @@
import org.forgerock.opendj.ldap.responses.SearchResultEntry;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.ldap.schema.ObjectClass;
import org.opends.guitools.controlpanel.util.Utilities;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.AttributeBuilder;
import org.opends.server.types.Entry;
@@ -73,43 +70,11 @@
  /**
   * Constructor of a search result using a SearchResult as basis.
   * @param sr the SearchResult.
   * @param baseDN the base DN of the search that returned the SearchResult.
   * @throws NamingException if there is an error retrieving the attribute
   * values.
   * @throws NamingException if there is an error retrieving the attribute values.
   */
  public CustomSearchResult(SearchResultEntry sr, String baseDN)
  throws NamingException
  public CustomSearchResult(SearchResultEntry sr) throws NamingException
  {
    String sName = sr.getName().toString();
    Name name;
    if (baseDN != null && baseDN.length() > 0)
    {
      if (sName != null && sName.length() > 0)
      {
        name = new CompositeName(sName);
        name.add(baseDN);
      }
      else {
        name = Utilities.getJNDIName(baseDN);
      }
    }
    else {
      name = new CompositeName(sName);
    }
    StringBuilder buf = new StringBuilder();
    for (int i=0; i<name.size(); i++)
    {
      String n = name.get(i);
      if (n != null && n.length() > 0)
      {
        if (buf.length() != 0)
        {
          buf.append(",");
        }
        buf.append(n);
      }
    }
    dn = buf.toString();
    dn = sr.getName().toString();
    attributes = new HashMap<>();
    attrNames = new TreeSet<>();
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/DeleteEntryTask.java
@@ -328,7 +328,7 @@
        SearchResultEntry sr = entryDNs.readEntry();
        if (!sr.getName().equals(""))
        {
          CustomSearchResult res = new CustomSearchResult(sr, dnToRemove.toString());
          CustomSearchResult res = new CustomSearchResult(sr);
          entryDNFound = DN.valueOf(res.getDN());
          deleteSubtreeRecursively(conn, entryDNFound, null, toNotify);
        }
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/LDAPEntryReader.java
@@ -25,7 +25,6 @@
import org.forgerock.opendj.ldap.requests.Requests;
import org.forgerock.opendj.ldap.requests.SearchRequest;
import org.forgerock.opendj.ldap.responses.SearchResultEntry;
import org.forgerock.opendj.ldif.ConnectionEntryReader;
import org.opends.admin.ads.util.ConnectionWrapper;
import org.opends.guitools.controlpanel.datamodel.CustomSearchResult;
import org.opends.guitools.controlpanel.event.EntryReadErrorEvent;
@@ -63,23 +62,12 @@
    isOver = false;
    final String filter = "(|(objectclass=*)(objectclass=ldapsubentry))";
    SearchRequest request = Requests.newSearchRequest(dn, BASE_OBJECT, filter, "*", "+");
    try (ConnectionEntryReader entryReader = conn.getConnection().search(request))
    SearchResultEntry sr = conn.getConnection().searchSingleEntry(request);
    if (isInterrupted())
    {
      SearchResultEntry sr = null;
      while (entryReader.hasNext())
      {
        sr = entryReader.readEntry();
      }
      return new CustomSearchResult(sr, dn);
      isOver = true;
    }
    finally
    {
      if (isInterrupted())
      {
        isOver = true;
      }
    }
    return new CustomSearchResult(sr);
  }
  @Override