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

Jean-Noël Rouvignac
04.05.2016 9529c418255af8de0cceb952afd006b60b9927a1
Make CustomSearchResult closer to SDK's Entry

CustomSearchResult.getAttributeValues() => CustomSearchResult.getAttribute()
8 files modified
75 ■■■■ changed files
opendj-server-legacy/src/main/java/org/opends/admin/ads/util/ConnectionUtils.java 3 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/browser/BrowserController.java 22 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/CustomSearchResult.java 5 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/ModifyEntryTask.java 3 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/DuplicateEntryPanel.java 3 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/LDIFViewEntryPanel.java 14 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/SimplifiedViewEntryPanel.java 19 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/Utilities.java 6 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/admin/ads/util/ConnectionUtils.java
@@ -41,6 +41,7 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.DN;
import org.forgerock.opendj.ldap.Entry;
import org.forgerock.opendj.ldap.responses.SearchResultEntry;
import org.opends.server.replication.plugin.EntryHistorical;
import org.opends.server.schema.SchemaConstants;
@@ -555,7 +556,7 @@
   *          the attribute description
   * @return The first attribute value in this attribute decoded as a UTF-8 string.
   */
  public static String firstValueAsString(SearchResultEntry sr, String attrDesc)
  public static String firstValueAsString(Entry sr, String attrDesc)
  {
    org.forgerock.opendj.ldap.Attribute attr = sr.getAttribute(attrDesc);
    return (attr != null && !attr.isEmpty()) ? attr.firstValueAsString() : null;
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/browser/BrowserController.java
@@ -25,7 +25,6 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Enumeration;
import java.util.List;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
@@ -48,8 +47,8 @@
import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.DN;
import org.forgerock.opendj.ldap.Entry;
import org.forgerock.opendj.ldap.responses.SearchResultEntry;
import org.opends.admin.ads.ADSContext;
import org.opends.admin.ads.util.ConnectionWrapper;
@@ -1756,11 +1755,10 @@
   * Get the value of the numSubordinates attribute.
   * If numSubordinates is not present, returns 0.
   * @param entry the entry to analyze.
   * @throws NamingException if an error occurs.
   * @return the value of the numSubordinates attribute.  0 if the attribute
   * could not be found.
   */
  private static int getNumSubOrdinates(SearchResultEntry entry) throws NamingException
  private static int getNumSubOrdinates(Entry entry)
  {
    return toInt(firstValueAsString(entry, NUMSUBORDINATES_ATTR));
  }
@@ -1769,13 +1767,11 @@
   * Returns whether the entry has subordinates or not.  It uses an algorithm
   * based in hasSubordinates and numSubordinates attributes.
   * @param entry the entry to analyze.
   * @throws NamingException if an error occurs.
   * @return {@code true} if the entry has subordinates according to the values
   * of hasSubordinates and numSubordinates, returns {@code false} if none of
   * the attributes could be found.
   */
  public static boolean getHasSubOrdinates(SearchResultEntry entry)
  throws NamingException
  public static boolean getHasSubOrdinates(Entry entry)
  {
    String v = firstValueAsString(entry, HASSUBORDINATES_ATTR);
    if (v != null) {
@@ -1793,9 +1789,7 @@
   */
  private static int getNumSubOrdinates(CustomSearchResult entry)
  {
    List<ByteString> vs = entry.getAttributeValues(NUMSUBORDINATES_ATTR);
    String v = !vs.isEmpty() ? vs.get(0).toString() : null;
    return toInt(v);
    return getNumSubOrdinates(entry.getSdkEntry());
  }
  private static int toInt(String v)
@@ -1824,13 +1818,7 @@
   */
  public static boolean getHasSubOrdinates(CustomSearchResult entry)
  {
    List<ByteString> vs = entry.getAttributeValues(HASSUBORDINATES_ATTR);
    String v = !vs.isEmpty() ? vs.get(0).toString() : null;
    if (v != null)
    {
      return "true".equalsIgnoreCase(v);
    }
    return getNumSubOrdinates(entry) > 0;
    return getHasSubOrdinates(entry.getSdkEntry());
  }
  /**
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/CustomSearchResult.java
@@ -112,6 +112,11 @@
    return entry.getAllAttributes();
  }
  public Entry getSdkEntry()
  {
    return entry;
  }
  /**
   * Returns all the attribute names of the entry.
   * @return the attribute names of the entry.
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/ModifyEntryTask.java
@@ -454,7 +454,8 @@
  {
    for (AVA ava : rdn)
    {
      if (entry.getAttributeValues(ava.getAttributeName()).isEmpty())
      org.forgerock.opendj.ldap.Attribute attr = entry.getAttribute(ava.getAttributeName());
      if (attr == null || attr.isEmpty())
      {
        return false;
      }
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/DuplicateEntryPanel.java
@@ -475,7 +475,8 @@
            rdnAttribute = sr.getName().rdn().getFirstAVA().getAttributeType().getNameOrOID();
            updateDNValue();
            boolean hasPassword = !sr.getAttributeValues(ATTR_USER_PASSWORD).isEmpty();
            Attribute userPwdAttr = sr.getAttribute(ATTR_USER_PASSWORD);
            boolean hasPassword = userPwdAttr != null && !userPwdAttr.isEmpty();
            lPassword.setVisible(hasPassword);
            password.setVisible(hasPassword);
            lconfirmPassword.setVisible(hasPassword);
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/LDIFViewEntryPanel.java
@@ -208,14 +208,18 @@
      sb = new StringBuilder();
      for (String attrName : schemaReadOnlyAttributes)
      {
        for (ByteString v : sr.getAttributeValues(attrName))
        Attribute attr = sr.getAttribute(attrName);
        if (attr != null)
        {
          if (oneLineAdded)
          for (ByteString v : attr)
          {
            sb.append("\n");
            if (oneLineAdded)
            {
              sb.append("\n");
            }
            oneLineAdded = true;
            sb.append(getLDIFLine(attrName, v));
          }
          oneLineAdded = true;
          sb.append(getLDIFLine(attrName, v));
        }
      }
      final Point p2 = sameEntry ?
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/SimplifiedViewEntryPanel.java
@@ -676,11 +676,9 @@
    // Put first the attributes associated with the objectclass in hmOrderedAttrNames
    LinkedHashSet<String> attrNames = new LinkedHashSet<>();
    List<ByteString> values = sr.getAttributeValues(OBJECTCLASS_ATTRIBUTE_TYPE_NAME);
    for (ByteString oc : values)
    for (ByteString ocName : sr.getAttribute(OBJECTCLASS_ATTRIBUTE_TYPE_NAME))
    {
      String ocName = oc.toString();
      String[] attrs = hmOrdereredAttrNames.get(ocName.toLowerCase());
      String[] attrs = hmOrdereredAttrNames.get(ocName.toString().toLowerCase());
      if (attrs != null)
      {
        for (String attr : attrs)
@@ -718,10 +716,9 @@
      if (schema != null)
      {
        List<ByteString> ocs = sr.getAttributeValues(OBJECTCLASS_ATTRIBUTE_TYPE_NAME);
        for (ByteString oc : ocs)
        for (ByteString ocName : sr.getAttribute(OBJECTCLASS_ATTRIBUTE_TYPE_NAME))
        {
          ObjectClass objectClass = schema.getObjectClass(oc.toString());
          ObjectClass objectClass = schema.getObjectClass(ocName.toString());
          if (!objectClass.isPlaceHolder())
          {
            for (AttributeType attr : objectClass.getRequiredAttributes())
@@ -1147,8 +1144,7 @@
      AttributeType attrType = attrDesc.getAttributeType();
      if (!attrType.isPlaceHolder())
      {
        List<ByteString> ocs = sr.getAttributeValues(OBJECTCLASS_ATTRIBUTE_TYPE_NAME);
        for (ByteString oc : ocs)
        for (ByteString oc : sr.getAttribute(OBJECTCLASS_ATTRIBUTE_TYPE_NAME))
        {
          ObjectClass objectClass = schema.getObjectClass(oc.toString());
          if (!objectClass.isPlaceHolder() && objectClass.isRequired(attrType))
@@ -1340,10 +1336,9 @@
  private boolean isAttrName(String attrName, CustomSearchResult sr)
  {
    for (ByteString v : sr.getAttributeValues(OBJECTCLASS_ATTRIBUTE_TYPE_NAME))
    for (ByteString ocName : sr.getAttribute(OBJECTCLASS_ATTRIBUTE_TYPE_NAME))
    {
      String ocName = v.toString();
      String attr = hmNameAttrNames.get(ocName.toLowerCase());
      String attr = hmNameAttrNames.get(ocName.toString().toLowerCase());
      if (attr != null && attr.equalsIgnoreCase(attrName))
      {
        return true;
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/Utilities.java
@@ -2420,10 +2420,10 @@
  {
    if (sr != null)
    {
      final List<ByteString> values = sr.getAttributeValues(attrName);
      if (!values.isEmpty())
      final Attribute attr = sr.getAttribute(attrName);
      if (attr != null && !attr.isEmpty())
      {
        final ByteString v = values.get(0);
        final ByteString v = attr.iterator().next();
        if (v != null)
        {
          return v.toString();