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

Jean-Noël Rouvignac
29.54.2016 52015235de899f6960c7364e4990aa013327b874
Prep work for OPENDJ-2803 Migrate Attribute

AttributeBuilder.java:
Added AttributeBuilder(AttributeDescription).
Removed AttributeBuilder(Attribute, boolean omitValues).

*.java:
Consequence of the changes to AttributeBuilder
13 files modified
182 ■■■■■ changed files
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/CustomSearchResult.java 13 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/ManageTasksPanel.java 76 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/core/SearchOperationBasis.java 8 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/plugins/PasswordPolicyImportPlugin.java 6 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/AttrHistoricalMultiple.java 6 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/LDIFDiff.java 2 ●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/types/AttributeBuilder.java 45 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/types/Attributes.java 2 ●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/types/Entry.java 2 ●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/util/LDIFReader.java 10 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendAddOperation.java 2 ●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java 6 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/test/java/org/opends/server/types/AttributeBuilderTest.java 4 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/CustomSearchResult.java
@@ -35,11 +35,11 @@
import javax.naming.directory.SearchResult;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.DN;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.guitools.controlpanel.util.Utilities;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.AttributeBuilder;
import org.forgerock.opendj.ldap.DN;
import org.opends.server.types.Entry;
import org.opends.server.types.ObjectClass;
import org.opends.server.types.OpenDsException;
@@ -92,7 +92,6 @@
      {
        name = new CompositeName(sName);
        name.add(baseDN);
      }
      else {
        name = Utilities.getJNDIName(baseDN);
@@ -181,7 +180,7 @@
    return attrNames;
  }
  /** {@inheritDoc} */
  @Override
  public int compareTo(CustomSearchResult o) {
    if (this.equals(o))
    {
@@ -205,7 +204,7 @@
    return sr;
  }
  /** {@inheritDoc} */
  @Override
  public boolean equals(Object o)
  {
    if (o == this)
@@ -234,12 +233,12 @@
    return true;
  }
  /** {@inheritDoc} */
  @Override
  public String toString() {
    return toString;
  }
  /** {@inheritDoc} */
  @Override
  public int hashCode() {
    return hashCode;
  }
@@ -310,7 +309,7 @@
      else
      {
        AttributeType attrType = DirectoryServer.getAttributeType(attrName);
        AttributeBuilder builder = new AttributeBuilder(attribute, true);
        AttributeBuilder builder = new AttributeBuilder(attribute.getAttributeDescription());
        for (Object value : getAttributeValues(attrName))
        {
          ByteString bs;
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/ManageTasksPanel.java
@@ -14,7 +14,6 @@
 * Copyright 2009-2010 Sun Microsystems, Inc.
 * Portions Copyright 2014-2016 ForgeRock AS.
 */
package org.opends.guitools.controlpanel.ui;
import static org.forgerock.util.Utils.*;
@@ -55,6 +54,7 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.DN;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo;
import org.opends.guitools.controlpanel.datamodel.CustomSearchResult;
@@ -70,37 +70,25 @@
import org.opends.server.tools.tasks.TaskEntry;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeBuilder;
import org.forgerock.opendj.ldap.DN;
import org.opends.server.types.Entry;
import org.opends.server.types.ObjectClass;
import org.opends.server.types.OpenDsException;
/**
 * The panel displaying the list of scheduled tasks.
 *
 */
/** The panel displaying the list of scheduled tasks. */
public class ManageTasksPanel extends StatusGenericPanel
{
  private static final long serialVersionUID = -8034784684412532193L;
  private JLabel lNoTasksFound;
  /**
   * Remove task button.
   */
  /** Remove task button. */
  private JButton cancelTask;
  /**
   * The scroll that contains the list of tasks (actually is a table).
   */
  /** The scroll that contains the list of tasks (actually is a table). */
  private JScrollPane tableScroll;
  /**
   * The table of tasks.
   */
  /** The table of tasks. */
  private JTable taskTable;
  /**
   * The model of the table.
   */
  /** The model of the table. */
  private TaskTableModel tableModel;
  private ManageTasksMenuBar menuBar;
@@ -126,31 +114,30 @@
    createLayout();
  }
  /** {@inheritDoc} */
  @Override
  public LocalizableMessage getTitle()
  {
    return INFO_CTRL_PANEL_TASK_TO_SCHEDULE_LIST_TITLE.get();
  }
  /** {@inheritDoc} */
  @Override
  public boolean requiresScroll()
  {
    return false;
  }
  /** {@inheritDoc} */
  @Override
  public GenericDialog.ButtonType getButtonType()
  {
    return GenericDialog.ButtonType.CLOSE;
  }
  /** {@inheritDoc} */
  @Override
  public void okClicked()
  {
    // Nothing to do, it only contains a close button.
  }
  /** {@inheritDoc} */
  @Override
  public JMenuBar getMenuBar()
  {
@@ -161,7 +148,7 @@
    return menuBar;
  }
  /** {@inheritDoc} */
  @Override
  public Component getPreferredFocusComponent()
  {
    return taskTable;
@@ -235,6 +222,7 @@
       * Updates the table model contents and sorts its contents depending on
       * the sort options set by the user.
       */
      @Override
      public void forceResort()
      {
        Set<String> selectedIds = getSelectedIds();
@@ -271,7 +259,7 @@
    add(Box.createVerticalGlue(), gbc);
    cancelTask.addActionListener(new ActionListener()
    {
      /** {@inheritDoc} */
      @Override
      public void actionPerformed(ActionEvent ev)
      {
        cancelTaskClicked();
@@ -324,7 +312,7 @@
    ListSelectionListener listener = new ListSelectionListener()
    {
      /** {@inheritDoc} */
      @Override
      public void valueChanged(ListSelectionEvent ev)
      {
        tableSelected();
@@ -334,10 +322,7 @@
    listener.valueChanged(null);
  }
  /**
   * Creates the details panel.
   *
   */
  /** Creates the details panel. */
  private void createDetailsPanel()
  {
    detailsPanel = new JPanel(new GridBagLayout());
@@ -371,10 +356,7 @@
        Box.createVerticalStrut(logs.getPreferredSize().height), gbc);
  }
  /**
   * Method called when the table is selected.
   *
   */
  /** Method called when the table is selected. */
  private void tableSelected()
  {
    List<TaskEntry> tasks = getSelectedTasks(true);
@@ -640,8 +622,6 @@
    }
  }
  /**
   * Gets the Entry object equivalent to the provided CustomSearchResult.
   * The method assumes that the schema in DirectoryServer has been initialized.
@@ -665,7 +645,7 @@
      // See if this is an objectclass or an attribute.  Then get the
      // corresponding definition and add the value to the appropriate hash.
      if (attrName.equalsIgnoreCase("objectclass"))
      if ("objectclass".equalsIgnoreCase(attrName))
      {
        for (Object value : csr.getAttributeValues(attrName))
        {
@@ -685,7 +665,7 @@
      else
      {
        AttributeType attrType = DirectoryServer.getAttributeType(attrName);
        AttributeBuilder builder = new AttributeBuilder(attribute, true);
        AttributeBuilder builder = new AttributeBuilder(attribute.getAttributeDescription());
        for (Object value : csr.getAttributeValues(attrName))
        {
          ByteString bs;
@@ -775,6 +755,7 @@
    final ManageTasksPanel p = new ManageTasksPanel();
    Thread t = new Thread(new Runnable()
    {
      @Override
      public void run()
      {
        try
@@ -791,6 +772,7 @@
          try
          {
            SwingUtilities.invokeLater(new Runnable(){
              @Override
              public void run()
              {
                Set<TaskEntry> tasks = p.createRandomTasksList();
@@ -817,8 +799,8 @@
    });
    t.start();
    SwingUtilities.invokeLater(new Runnable(){
      @Override
      public void run()
      {
        GenericDialog dlg = new GenericDialog(Utilities.createFrame(), p);
@@ -830,10 +812,7 @@
    t = null;
  }
  /**
   * Displays a dialog allowing the user to select which operations to display.
   *
   */
  /** Displays a dialog allowing the user to select which operations to display. */
  private void operationViewClicked()
  {
    if (operationViewDlg == null)
@@ -858,7 +837,7 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  public void configurationChanged(ConfigurationChangeEvent ev)
  {
    updateErrorPaneIfServerRunningAndAuthRequired(ev.getNewDescriptor(),
@@ -870,7 +849,7 @@
    {
      SwingUtilities.invokeLater(new Runnable()
      {
        /** {@inheritDoc} */
        @Override
        public void run()
        {
          Set<String> selectedIds = getSelectedIds();
@@ -927,10 +906,7 @@
    setSelectedIds(selectedIds);
  }
  /**
   * The specific menu bar of this panel.
   *
   */
  /** The specific menu bar of this panel. */
  class ManageTasksMenuBar extends MainMenuBar
  {
    private static final long serialVersionUID = 5051878116443370L;
@@ -944,7 +920,6 @@
      super(info);
    }
    /** {@inheritDoc} */
    @Override
    protected void addMenus()
    {
@@ -968,6 +943,7 @@
      menu.add(viewOperations);
      viewOperations.addActionListener(new ActionListener()
      {
        @Override
        public void actionPerformed(ActionEvent ev)
        {
          operationViewClicked();
opendj-server-legacy/src/main/java/org/opends/server/core/SearchOperationBasis.java
@@ -27,9 +27,11 @@
import org.forgerock.i18n.LocalizedIllegalArgumentException;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.DN;
import org.forgerock.opendj.ldap.DereferenceAliasesPolicy;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.api.AccessControlHandler;
import org.opends.server.api.AuthenticationPolicyState;
import org.opends.server.api.ClientConnection;
@@ -40,12 +42,10 @@
import org.opends.server.types.AbstractOperation;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeBuilder;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.CancelRequest;
import org.opends.server.types.CancelResult;
import org.opends.server.types.CanceledOperationException;
import org.opends.server.types.Control;
import org.forgerock.opendj.ldap.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
import org.opends.server.types.OperationType;
@@ -608,7 +608,7 @@
        {
          // Assume that the attribute will be either empty or contain
          // very few values.
          AttributeBuilder builder = new AttributeBuilder(a, true);
          AttributeBuilder builder = new AttributeBuilder(a.getAttributeDescription());
          for (ByteString v : a)
          {
            if (matchedValuesControl.valueMatches(t, v))
@@ -634,7 +634,7 @@
        {
          // Assume that the attribute will be either empty or contain
          // very few values.
          AttributeBuilder builder = new AttributeBuilder(a, true);
          AttributeBuilder builder = new AttributeBuilder(a.getAttributeDescription());
          for (ByteString v : a)
          {
            if (matchedValuesControl.valueMatches(t, v))
opendj-server-legacy/src/main/java/org/opends/server/plugins/PasswordPolicyImportPlugin.java
@@ -344,7 +344,7 @@
          for (Attribute a : attrList)
          {
            AttributeBuilder builder = new AttributeBuilder(a, true);
            AttributeBuilder builder = new AttributeBuilder(a.getAttributeDescription());
            boolean gotError = false;
            for (ByteString value : a)
@@ -419,7 +419,7 @@
    {
      for (Attribute a : entry.getAttribute(t))
      {
        AttributeBuilder builder = new AttributeBuilder(a, true);
        AttributeBuilder builder = new AttributeBuilder(a.getAttributeDescription());
        boolean gotError = false;
        for (ByteString value : a)
@@ -462,7 +462,7 @@
    {
      for (Attribute a : entry.getAttribute(t))
      {
        AttributeBuilder builder = new AttributeBuilder(a, true);
        AttributeBuilder builder = new AttributeBuilder(a.getAttributeDescription());
        boolean gotError = false;
        for (ByteString value : a)
opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/AttrHistoricalMultiple.java
@@ -23,12 +23,12 @@
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.replication.common.CSN;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeBuilder;
import org.opends.server.types.Entry;
import org.opends.server.types.Modification;
import org.forgerock.opendj.ldap.schema.AttributeType;
/**
 * This class is used to store historical information for multiple valued attributes.
@@ -281,7 +281,7 @@
       */
      boolean conflict = false;
      Attribute addedValues = m.getAttribute();
      m.setAttribute(new AttributeBuilder(addedValues, true).toAttribute());
      m.setAttribute(new AttributeBuilder(addedValues.getAttributeDescription()).toAttribute());
      processDeleteConflict(csn, m, modifiedEntry);
      Attribute keptValues = m.getAttribute();
@@ -386,7 +386,7 @@
    {
      // We are processing a DELETE attribute modification
      m.setModificationType(ModificationType.REPLACE);
      AttributeBuilder builder = new AttributeBuilder(modAttr, true);
      AttributeBuilder builder = new AttributeBuilder(modAttr.getAttributeDescription());
      for (Iterator<AttrValueHistorical> it = valuesHist.keySet().iterator(); it.hasNext();)
      {
opendj-server-legacy/src/main/java/org/opends/server/tools/LDIFDiff.java
@@ -915,7 +915,7 @@
          LinkedList<Modification> attrMods = new LinkedList<>();
          for (ByteString v : a)
          {
            AttributeBuilder builder = new AttributeBuilder(a, true);
            AttributeBuilder builder = new AttributeBuilder(a.getAttributeDescription());
            builder.add(v);
            Attribute attr = builder.toAttribute();
opendj-server-legacy/src/main/java/org/opends/server/types/AttributeBuilder.java
@@ -792,37 +792,22 @@
   */
  public AttributeBuilder(Attribute attribute)
  {
    this(attribute, false);
  }
  /**
   * Creates a new attribute builder from an existing attribute,
   * optionally omitting the values contained in the provided
   * attribute.
   * <p>
   * Modifications to the attribute builder will not impact the
   * provided attribute.
   *
   * @param attribute
   *          The attribute to be copied.
   * @param omitValues
   *          <CODE>true</CODE> if the values should be omitted.
   */
  public AttributeBuilder(Attribute attribute, boolean omitValues)
  {
    this(attribute.getAttributeDescription().getAttributeType(), attribute.getName());
    setOptions(attribute.getAttributeDescription().getOptions());
    if (!omitValues)
    {
    this(attribute.getAttributeDescription());
      addAll(attribute);
    }
  /**
   * Creates a new attribute builder with the specified description.
   *
   * @param attributeDescription
   *          The attribute description for this attribute builder.
   */
  public AttributeBuilder(AttributeDescription attributeDescription)
  {
    this(attributeDescription.getAttributeType(), attributeDescription.getNameOrOID());
    setOptions(attributeDescription.getOptions());
  }
  /**
   * Creates a new attribute builder with the specified type and no
   * options and no values.
@@ -1299,18 +1284,16 @@
        options.add(option);
        return true;
      }
      break;
      return false;
    default:
      if (normalizedOptions.add(toLowerCase(option)))
      {
        options.add(option);
        return true;
      }
      break;
    }
    return false;
  }
  }
opendj-server-legacy/src/main/java/org/opends/server/types/Attributes.java
@@ -223,7 +223,7 @@
   */
  public static Attribute empty(Attribute attribute)
  {
    return new AttributeBuilder(attribute, true).toAttribute();
    return new AttributeBuilder(attribute.getAttributeDescription()).toAttribute();
  }
opendj-server-legacy/src/main/java/org/opends/server/types/Entry.java
@@ -1088,7 +1088,7 @@
    }
    // Increment each attribute value by the specified amount.
    AttributeBuilder builder = new AttributeBuilder(a, true);
    AttributeBuilder builder = new AttributeBuilder(a.getAttributeDescription());
    for (ByteString v : a)
    {
opendj-server-legacy/src/main/java/org/opends/server/util/LDIFReader.java
@@ -826,7 +826,7 @@
       //The attribute is not being ignored so check for binary option.
      if (checkSchema
          && !attrType.getSyntax().isBEREncodingRequired()
          && attribute.getAttributeDescription().hasOption("binary"))
 && attrDesc.hasOption("binary"))
      {
        LocalizableMessage message = ERR_LDIF_INVALID_ATTR_OPTION.get(
          entryDN, lastEntryLineNumber, attrName);
@@ -867,7 +867,7 @@
      final List<AttributeBuilder> attrList = attrBuilders.get(attrType);
      if (attrList == null)
      {
        AttributeBuilder builder = new AttributeBuilder(attribute, true);
        AttributeBuilder builder = new AttributeBuilder(attrDesc);
        builder.add(attributeValue);
        attrBuilders.put(attrType, newArrayList(builder));
        return;
@@ -900,7 +900,7 @@
      // No set of matching options was found, so create a new one and
      // add it to the list.
      AttributeBuilder builder = new AttributeBuilder(attribute, true);
      AttributeBuilder builder = new AttributeBuilder(attrDesc);
      builder.add(attributeValue);
      attrList.add(builder);
    }
@@ -951,7 +951,7 @@
    ByteString value = parseSingleValue(lines, line, entryDN,
        colonPos, attrName);
    AttributeBuilder builder = new AttributeBuilder(attribute, true);
    AttributeBuilder builder = new AttributeBuilder(attribute.getAttributeDescription());
    builder.add(value);
    return builder.toAttribute();
  }
@@ -1332,7 +1332,7 @@
      // Now go through the rest of the attributes till the "-" line is reached.
      Attribute modAttr = LDIFReader.parseAttrDescription(attrDescr);
      AttributeBuilder builder = new AttributeBuilder(modAttr, true);
      AttributeBuilder builder = new AttributeBuilder(modAttr.getAttributeDescription());
      while (! lines.isEmpty())
      {
        line = lines.remove();
opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendAddOperation.java
@@ -706,7 +706,7 @@
    List<PasswordStorageScheme<?>> defaultStorageSchemes =
         passwordPolicy.getDefaultPasswordStorageSchemes();
    AttributeBuilder builder = new AttributeBuilder(passwordAttr, true);
    AttributeBuilder builder = new AttributeBuilder(passwordAttr.getAttributeDescription());
    for (ByteString value : passwordAttr)
    {
      // See if the password is pre-encoded.
opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java
@@ -960,7 +960,7 @@
    // pre-encoded. If so, then check to see if we'll allow it.
    // Otherwise, store the clear-text values for later validation
    // and update the attribute with the encoded values.
    AttributeBuilder builder = new AttributeBuilder(pwAttr, true);
    AttributeBuilder builder = new AttributeBuilder(pwAttr.getAttributeDescription());
    for (ByteString v : pwAttr)
    {
      if (pwPolicyState.passwordIsPreEncoded(v))
@@ -1013,7 +1013,7 @@
      numPasswords = 0;
    }
    AttributeBuilder builder = new AttributeBuilder(pwAttr, true);
    AttributeBuilder builder = new AttributeBuilder(pwAttr.getAttributeDescription());
    for (ByteString v : pwAttr)
    {
      if (pwPolicyState.passwordIsPreEncoded(v))
@@ -1414,7 +1414,7 @@
    }
    // Increment each attribute value by the specified amount.
    AttributeBuilder builder = new AttributeBuilder(a, true);
    AttributeBuilder builder = new AttributeBuilder(a.getAttributeDescription());
    for (ByteString existingValue : a)
    {
      long currentValue;
opendj-server-legacy/src/test/java/org/opends/server/types/AttributeBuilderTest.java
@@ -323,7 +323,7 @@
        {
            35,
            new AttributeBuilder(createAttribute(cnType, "CN", threeOptions,
                threeValues), false).toAttribute(),
                threeValues)).toAttribute(),
            cnType,
            "CN",
            threeOptions,
@@ -332,7 +332,7 @@
        {
            36,
            new AttributeBuilder(createAttribute(cnType, "CN", threeOptions,
                threeValues), true).toAttribute(),
                threeValues).getAttributeDescription()).toAttribute(),
            cnType,
            "CN",
            threeOptions,