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

Jean-Noël Rouvignac
09.41.2016 642ce9c35148314aa41a95af1e8609ae170b67fe
Simplify AttributeBuilder API usage:
- new AttributeBuilder(AttributeType, AttribueType.getNameOrOID()) => new AttributeBuilder(AttributeType)
- new AttributeBuilder(DirectoryServer.getAttributeType(name)) => new AttributeBuilder(name)
10 files modified
72 ■■■■ changed files
opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/AciHandler.java 2 ●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/RootDSEBackend.java 4 ●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/plugins/LastModPlugin.java 16 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tasks/AddSchemaFileTask.java 15 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/makeldif/TemplateEntry.java 8 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/types/AttributeBuilder.java 15 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/types/Entry.java 3 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/util/LDIFReader.java 2 ●●● patch | view | raw | blame | history
opendj-server-legacy/src/test/java/org/opends/server/types/EntrySchemaCheckingTestCase.java 3 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/test/java/org/opends/server/util/TestLDIFReader.java 4 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/AciHandler.java
@@ -420,7 +420,7 @@
    }
    // Load the values, a bind rule might want to evaluate them.
    final AttributeBuilder builder = new AttributeBuilder(refAttrType, ATTR_REFERRAL_URL);
    final AttributeBuilder builder = new AttributeBuilder(refAttrType);
    builder.addAllStrings(reference.getReferralURLs());
    final Entry e = new Entry(dn, null, null, null);
opendj-server-legacy/src/main/java/org/opends/server/backends/RootDSEBackend.java
@@ -570,9 +570,7 @@
   */
  private Attribute createAttribute(String name, Collection<? extends Object> values)
  {
    AttributeType type = DirectoryServer.getAttributeType(name);
    AttributeBuilder builder = new AttributeBuilder(type, name);
    AttributeBuilder builder = new AttributeBuilder(name);
    builder.addAllStrings(values);
    return builder.toAttribute();
  }
opendj-server-legacy/src/main/java/org/opends/server/plugins/LastModPlugin.java
@@ -35,7 +35,12 @@
import org.opends.server.api.plugin.PluginResult;
import org.opends.server.api.plugin.PluginType;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.*;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeBuilder;
import org.opends.server.types.Attributes;
import org.opends.server.types.DirectoryConfig;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Modification;
import org.opends.server.types.operation.PreOperationAddOperation;
import org.opends.server.types.operation.PreOperationModifyDNOperation;
import org.opends.server.types.operation.PreOperationModifyOperation;
@@ -129,8 +134,7 @@
               doPreOperation(PreOperationAddOperation addOperation)
  {
    // Create the attribute list for the creatorsName attribute, if appropriate.
    AttributeBuilder builder = new AttributeBuilder(creatorsNameType,
        OP_ATTR_CREATORS_NAME);
    AttributeBuilder builder = new AttributeBuilder(creatorsNameType);
    DN creatorDN = addOperation.getAuthorizationDN();
    if (creatorDN == null)
    {
@@ -161,8 +165,7 @@
       doPreOperation(PreOperationModifyOperation modifyOperation)
  {
    // Create the modifiersName attribute.
    AttributeBuilder builder = new AttributeBuilder(modifiersNameType,
        OP_ATTR_MODIFIERS_NAME);
    AttributeBuilder builder = new AttributeBuilder(modifiersNameType);
    DN modifierDN = modifyOperation.getAuthorizationDN();
    if (modifierDN == null)
    {
@@ -219,8 +222,7 @@
       doPreOperation(PreOperationModifyDNOperation modifyDNOperation)
  {
    // Create the modifiersName attribute.
    AttributeBuilder builder = new AttributeBuilder(modifiersNameType,
        OP_ATTR_MODIFIERS_NAME);
    AttributeBuilder builder = new AttributeBuilder(modifiersNameType);
    DN modifierDN = modifyDNOperation.getAuthorizationDN();
    if (modifierDN == null)
    {
opendj-server-legacy/src/main/java/org/opends/server/tasks/AddSchemaFileTask.java
@@ -34,8 +34,16 @@
import org.opends.server.backends.task.TaskState;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.SchemaConfigManager;
import org.opends.server.types.*;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeBuilder;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
import org.opends.server.types.InitializationException;
import org.opends.server.types.LockManager.DNLock;
import org.opends.server.types.Modification;
import org.opends.server.types.Operation;
import org.opends.server.types.Privilege;
import org.opends.server.types.Schema;
import static org.opends.messages.TaskMessages.*;
import static org.opends.server.config.ConfigConstants.*;
@@ -180,7 +188,7 @@
          {
            Attribute a = m.getAttribute();
            AttributeType attrType = a.getAttributeDescription().getAttributeType();
            AttributeBuilder builder = new AttributeBuilder(attrType, attrType.getNameOrOID());
            AttributeBuilder builder = new AttributeBuilder(attrType);
            for (ByteString v : a)
            {
              String s = v.toString();
@@ -201,8 +209,7 @@
              builder.add(s);
            }
            mods.add(new Modification(m.getModificationType(), builder
                .toAttribute()));
            mods.add(new Modification(m.getModificationType(), builder.toAttribute()));
          }
        }
        catch (ConfigException | InitializationException e)
opendj-server-legacy/src/main/java/org/opends/server/tools/makeldif/TemplateEntry.java
@@ -255,7 +255,7 @@
      }
      else if (t.isOperational())
      {
        AttributeBuilder builder = new AttributeBuilder(t, t.getNameOrOID());
        AttributeBuilder builder = new AttributeBuilder(t);
        for (TemplateValue v : valueList)
        {
          builder.add(v.getValue().toString());
@@ -265,7 +265,7 @@
      }
      else
      {
        AttributeBuilder builder = new AttributeBuilder(t, t.getNameOrOID());
        AttributeBuilder builder = new AttributeBuilder(t);
        AttributeBuilder urlBuilder = null;
        AttributeBuilder base64Builder = null;
        for (TemplateValue v : valueList)
@@ -276,7 +276,7 @@
          {
            if (urlBuilder == null)
            {
              urlBuilder = new AttributeBuilder(t, t.getNameOrOID());
              urlBuilder = new AttributeBuilder(t);
            }
            urlBuilder.add(value);
          }
@@ -284,7 +284,7 @@
          {
            if (base64Builder == null)
            {
              base64Builder = new AttributeBuilder(t, t.getNameOrOID());
              base64Builder = new AttributeBuilder(t);
            }
            base64Builder.add(value);
          }
opendj-server-legacy/src/main/java/org/opends/server/types/AttributeBuilder.java
@@ -829,18 +829,17 @@
  /**
   * Creates a new attribute builder with the specified attribute name
   * and no options and no values.
   * Creates a new attribute builder with the specified attribute description and no values.
   * <p>
   * If the attribute name cannot be found in the schema, a new
   * attribute type is created using the default attribute syntax.
   * If the attribute name cannot be found in the schema, a new attribute type is created using the
   * default attribute syntax.
   *
   * @param attributeName
   *          The attribute name for this attribute builder.
   * @param attributeDescription
   *          The attribute description for this attribute builder.
   */
  public AttributeBuilder(String attributeName)
  public AttributeBuilder(String attributeDescription)
  {
    this(AttributeDescription.valueOf(attributeName));
    this(AttributeDescription.valueOf(attributeDescription));
  }
opendj-server-legacy/src/main/java/org/opends/server/types/Entry.java
@@ -374,8 +374,7 @@
    if(objectClassAttribute == null)
    {
      AttributeType ocType = DirectoryServer.getObjectClassAttributeType();
      AttributeBuilder builder = new AttributeBuilder(ocType, ATTR_OBJECTCLASS);
      AttributeBuilder builder = new AttributeBuilder(DirectoryServer.getObjectClassAttributeType());
      builder.addAllStrings(objectClasses.values());
      objectClassAttribute = builder.toAttribute();
    }
opendj-server-legacy/src/main/java/org/opends/server/util/LDIFReader.java
@@ -1321,7 +1321,7 @@
    // Reconstruct the object class attribute.
    AttributeType ocType = DirectoryServer.getObjectClassAttributeType();
    AttributeBuilder builder = new AttributeBuilder(ocType, "objectClass");
    AttributeBuilder builder = new AttributeBuilder(ocType);
    builder.addAllStrings(objectClasses.values());
    Map<AttributeType, List<Attribute>> attributes = toAttributesMap(attrBuilders);
    if (attributes.get(ocType) == null)
opendj-server-legacy/src/test/java/org/opends/server/types/EntrySchemaCheckingTestCase.java
@@ -446,8 +446,7 @@
    AttributeType creatorsNameType = DirectoryServer.getAttributeType("creatorsname");
    assertTrue(creatorsNameType.isOperational());
    AttributeBuilder builder = new AttributeBuilder(creatorsNameType,
        "creatorsName");
    AttributeBuilder builder = new AttributeBuilder(creatorsNameType);
    builder.add("cn=Directory Manager");
    builder.add("cn=Another User");
    e.addAttribute(builder.toAttribute(), new LinkedList<ByteString>());
opendj-server-legacy/src/test/java/org/opends/server/util/TestLDIFReader.java
@@ -436,7 +436,7 @@
      Assert.assertEquals(add.getDN(), dn);
      List<Attribute> attrs = new ArrayList<>();
      AttributeBuilder builder = new AttributeBuilder(AT_OC, "objectclass");
      AttributeBuilder builder = new AttributeBuilder(AT_OC);
      builder.add("top");
      builder.add("person");
      builder.add("organizationalPerson");
@@ -514,7 +514,7 @@
      mod = i.next().toModification();
      Assert.assertEquals(mod.getModificationType(),
          ModificationType.REPLACE);
      builder = new AttributeBuilder(AT_TELN, "telephonenumber");
      builder = new AttributeBuilder(AT_TELN);
      builder.add("+1 408 555 1234");
      builder.add("+1 408 555 5678");
      Assert.assertEquals(mod.getAttribute(), builder.toAttribute());