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

Jean-Noel Rouvignac
16.10.2015 1ef65104c4113a1c6fad7ee93bc9862218a4bc68
AutoRefactor: common code in if else statements
29 files modified
1041 ■■■■■ changed files
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/DeleteIndexTask.java 18 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/NewSchemaElementsTask.java 88 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/InclusionExclusionPanel.java 16 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/NewAttributePanel.java 22 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/ProgressDialog.java 57 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/SimplifiedViewEntryPanel.java 169 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/quicksetup/ui/Utilities.java 13 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/admin/AggregationPropertyDefinition.java 26 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/LDIFBackend.java 8 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/RootDSEBackend.java 77 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java 127 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/Index.java 3 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/config/DNConfigAttribute.java 13 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/config/IntegerConfigAttribute.java 12 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/config/JMXMBean.java 3 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/config/MultiChoiceConfigAttribute.java 12 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/config/StringConfigAttribute.java 12 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/plugins/ReferentialIntegrityPlugin.java 16 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/protocols/ldap/BindRequestProtocolOp.java 66 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/replication/server/changelog/file/BlockLogReader.java 3 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPDelete.java 22 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPModify.java 21 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/LDIFSearch.java 17 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/ManageTasks.java 7 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/makeldif/RDNTag.java 8 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/makeldif/TemplateEntry.java 152 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/types/LockManager.java 30 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/util/LDIFWriter.java 12 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyDNOperation.java 11 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/DeleteIndexTask.java
@@ -22,9 +22,8 @@
 *
 *
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2014 ForgeRock AS
 *      Portions Copyright 2014-2015 ForgeRock AS
 */
package org.opends.guitools.controlpanel.task;
import static org.opends.messages.AdminToolMessages.*;
@@ -273,20 +272,19 @@
   */
  private void deleteIndex(AbstractIndexDescriptor index) throws OpenDsException
  {
    String backendId = Utilities.getRDNString("ds-cfg-backend-id", index.getBackend().getBackendID());
    String dn;
    if (isVLVIndex(index))
    {
      String dn = Utilities.getRDNString("ds-cfg-name", index.getName())+
      ",cn=VLV Index,"+Utilities.getRDNString("ds-cfg-backend-id",
          index.getBackend().getBackendID())+",cn=Backends,cn=config";
      DirectoryServer.getConfigHandler().deleteEntry(DN.valueOf(dn), null);
      dn = Utilities.getRDNString("ds-cfg-name", index.getName())
          + ",cn=VLV Index," + backendId + ",cn=Backends,cn=config";
    }
    else
    {
      String dn = Utilities.getRDNString("ds-cfg-attribute", index.getName())+
      ",cn=Index,"+Utilities.getRDNString("ds-cfg-backend-id",
          index.getBackend().getBackendID())+",cn=Backends,cn=config";
      DirectoryServer.getConfigHandler().deleteEntry(DN.valueOf(dn), null);
      dn = Utilities.getRDNString("ds-cfg-attribute", index.getName())
          + ",cn=Index," + backendId + ",cn=Backends,cn=config";
    }
    DirectoryServer.getConfigHandler().deleteEntry(DN.valueOf(dn), null);
  }
  /**
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/NewSchemaElementsTask.java
@@ -22,9 +22,8 @@
 *
 *
 *      Copyright 2009 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2014 ForgeRock AS.
 *      Portions Copyright 2013-2015 ForgeRock AS.
 */
package org.opends.guitools.controlpanel.task;
import static org.forgerock.util.Utils.*;
@@ -514,38 +513,38 @@
    final boolean isSchemaFileDefined = isSchemaFileDefined(fileName);
    SwingUtilities.invokeLater(new Runnable()
    {
      /**
       * {@inheritDoc}
       */
      /** {@inheritDoc} */
      @Override
      public void run()
      {
        printEquivalentCommandToAddOffline(fileName, isSchemaFileDefined,
            attributes, objectClasses);
        final ProgressDialog progressDialog = getProgressDialog();
        final String command = equivalentCommandToAddOffline(
            fileName, isSchemaFileDefined, attributes, objectClasses);
        progressDialog.appendProgressHtml(
            Utilities.applyFont(command,
                ColorAndFontConstants.progressFont));
        if (attributes.size() == 1 && objectClasses.isEmpty())
        {
          String attributeName = attributes.get(0).getNameOrOID();
          getProgressDialog().appendProgressHtml(
          progressDialog.appendProgressHtml(
              Utilities.getProgressWithPoints(
                  INFO_CTRL_PANEL_CREATING_ATTRIBUTE_PROGRESS.get(
                      attributeName),
                  INFO_CTRL_PANEL_CREATING_ATTRIBUTE_PROGRESS.get(attributeName),
                      ColorAndFontConstants.progressFont));
        }
        else if (objectClasses.size() == 1 && attributes.isEmpty())
        {
          String ocName = objectClasses.get(0).getNameOrOID();
          getProgressDialog().appendProgressHtml(
          progressDialog.appendProgressHtml(
              Utilities.getProgressWithPoints(
                  INFO_CTRL_PANEL_CREATING_OBJECTCLASS_PROGRESS.get(
                      ocName),
                  INFO_CTRL_PANEL_CREATING_OBJECTCLASS_PROGRESS.get(ocName),
                      ColorAndFontConstants.progressFont));
        }
        else
        {
          getProgressDialog().appendProgressHtml(
          progressDialog.appendProgressHtml(
              Utilities.getProgressWithPoints(
                  INFO_CTRL_PANEL_UPDATING_SCHEMA_FILE_PROGRESS.get(
                      fileName),
                  INFO_CTRL_PANEL_UPDATING_SCHEMA_FILE_PROGRESS.get(fileName),
                      ColorAndFontConstants.progressFont));
        }
      }
@@ -572,7 +571,7 @@
    });
  }
  private void printEquivalentCommandToAddOffline(String schemaFile,
  private String equivalentCommandToAddOffline(String schemaFile,
      boolean isSchemaFileDefined,
      List<AttributeType> attributes,
      List<ObjectClass> objectClasses)
@@ -586,54 +585,37 @@
    {
      names.add(oc.getNameOrOID());
    }
    final String namesString = joinAsString(", ", names);
    final StringBuilder sb = new StringBuilder();
    if (isSchemaFileDefined)
    {
      StringBuilder sb = new StringBuilder();
      sb.append(
          INFO_CTRL_PANEL_EQUIVALENT_CMD_TO_ADD_SCHEMA_ELEMENT_OFFLINE.get(
          joinAsString(", ", names),
          schemaFile))
      sb.append(INFO_CTRL_PANEL_EQUIVALENT_CMD_TO_ADD_SCHEMA_ELEMENT_OFFLINE.get(namesString, schemaFile))
        .append("<br><b>");
      for (AttributeType attribute : attributes)
      {
        sb.append(getAttributeName(attribute)).append(": ")
            .append(getValueOffline(attribute)).append("<br>");
      }
      for (ObjectClass oc : objectClasses)
      {
        sb.append(getAttributeName(oc)).append(": ")
            .append(getValueOffline(oc)).append("<br>");
      }
      sb.append("</b><br><br>");
      getProgressDialog().appendProgressHtml(Utilities.applyFont(sb.toString(),
          ColorAndFontConstants.progressFont));
    }
    else
    {
      StringBuilder sb = new StringBuilder();
      sb.append(INFO_CTRL_PANEL_EQUIVALENT_CMD_TO_ADD_SCHEMA_ENTRY_OFFLINE.get(
          joinAsString(", ", names),
          schemaFile)).append("<br><b>");
      sb.append(INFO_CTRL_PANEL_EQUIVALENT_CMD_TO_ADD_SCHEMA_ENTRY_OFFLINE.get(namesString, schemaFile))
        .append("<br><b>");
      for (String line : getSchemaEntryLines())
      {
        sb.append(line);
        sb.append("<br>");
      }
      for (AttributeType attribute : attributes)
      {
        sb.append(getAttributeName(attribute)).append(": ")
            .append(getValueOffline(attribute)).append("<br>");
      }
      for (ObjectClass oc : objectClasses)
      {
        sb.append(getAttributeName(oc)).append(": ")
            .append(getValueOffline(oc)).append("<br>");
      }
      sb.append("</b><br><br>");
      getProgressDialog().appendProgressHtml(Utilities.applyFont(sb.toString(),
          ColorAndFontConstants.progressFont));
    }
    for (AttributeType attribute : attributes)
    {
      sb.append(getAttributeName(attribute)).append(": ")
          .append(getValueOffline(attribute)).append("<br>");
    }
    for (ObjectClass oc : objectClasses)
    {
      sb.append(getAttributeName(oc)).append(": ")
          .append(getValueOffline(oc)).append("<br>");
    }
    sb.append("</b><br><br>");
    return sb.toString();
  }
  /**
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/InclusionExclusionPanel.java
@@ -373,24 +373,20 @@
  {
    for (int i=0; i<extraComponentLabels.length; i++)
    {
      gbc.gridy ++;
      gbc.gridx = 0;
      gbc.insets.left = labelInsetLeft;
      gbc.anchor = GridBagConstraints.NORTHWEST;
      gbc.insets.top = 10;
      if (extraComponentLabels[i] == null)
      {
        gbc.gridy ++;
        gbc.gridx = 0;
        gbc.insets.left = labelInsetLeft;
        gbc.anchor = GridBagConstraints.NORTHWEST;
        gbc.insets.top = 10;
        gbc.gridwidth = 2;
        gbc.weightx = 1.0;
        panel.add(extraComponents[i], gbc);
      }
      else
      {
        gbc.gridy ++;
        gbc.gridx = 0;
        gbc.insets.left = labelInsetLeft;
        gbc.anchor = GridBagConstraints.NORTHWEST;
        gbc.insets.top = 10;
        gbc.gridwidth = 1;
        gbc.weightx = 0.0;
        panel.add(extraComponentLabels[i], gbc);
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/NewAttributePanel.java
@@ -716,23 +716,15 @@
      {
        DefaultComboBoxModel model = (DefaultComboBoxModel)combos[i].getModel();
        int index = combos[i].getSelectedIndex();
        if (rules[i] != null)
        if (model.getSize() > 0)
        {
          if (model.getSize() > 0)
          {
            model.removeElementAt(0);
          }
          model.insertElementAt(INFO_CTRL_PANEL_DEFAULT_DEFINED_IN_SYNTAX.get(
              rules[i].getNameOrOID()), 0);
          model.removeElementAt(0);
        }
        else
        {
          if (model.getSize() > 0)
          {
            model.removeElementAt(0);
          }
          model.insertElementAt(NO_MATCHING_RULE, 0);
        }
        final LocalizableMessage msg = rules[i] != null
            ? INFO_CTRL_PANEL_DEFAULT_DEFINED_IN_SYNTAX.get(rules[i].getNameOrOID())
            : NO_MATCHING_RULE;
        model.insertElementAt(msg, 0);
        combos[i].setSelectedIndex(index);
      }
    }
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/ProgressDialog.java
@@ -496,56 +496,45 @@
      scroll.setVisible(showDetails);
      extraStrut.setVisible(!showDetails);
      details.setSelected(showDetails);
      if (showDetails)
      final Window dialog = Utilities.getParentDialog(this);
      if (dialog != null)
      {
        final Window dialog = Utilities.getParentDialog(this);
        if (dialog != null)
        final Runnable repaint = new Runnable()
        {
          lastCollapsedHeight = dialog.getSize().height;
          public void run()
          {
            invalidate();
            dialog.invalidate();
            dialog.repaint();
          }
        };
        final Dimension dialogSize = dialog.getSize();
        if (showDetails)
        {
          lastCollapsedHeight = dialogSize.height;
          if (lastExpandedHeight == -1)
          {
            dialog.setSize(new Dimension(dialog.getSize().width,
                dialog.getSize().height + heightDiff));
            dialog.setSize(new Dimension(dialogSize.width, dialogSize.height + heightDiff));
          }
          else
          {
            dialog.setSize(new Dimension(dialog.getSize().width,
                lastExpandedHeight));
            dialog.setSize(new Dimension(dialogSize.width, lastExpandedHeight));
          }
          SwingUtilities.invokeLater(new Runnable()
          {
            public void run()
            {
              invalidate();
              dialog.invalidate();
              dialog.repaint();
            }
          });
          SwingUtilities.invokeLater(repaint);
        }
      }
      else
      {
        final Window dialog = Utilities.getParentDialog(this);
        if (dialog != null)
        else
        {
          lastExpandedHeight = dialog.getSize().height;
          lastExpandedHeight = dialogSize.height;
          if (lastCollapsedHeight == -1)
          {
            packParentDialog();
          }
          else
          {
            dialog.setSize(new Dimension(dialog.getSize().width,
                lastCollapsedHeight));
            SwingUtilities.invokeLater(new Runnable()
            {
              public void run()
              {
                invalidate();
                dialog.invalidate();
                dialog.repaint();
              }
            });
            dialog.setSize(new Dimension(dialogSize.width, lastCollapsedHeight));
            SwingUtilities.invokeLater(repaint);
          }
        }
      }
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/SimplifiedViewEntryPanel.java
@@ -26,8 +26,9 @@
 */
package org.opends.guitools.controlpanel.ui;
import static com.forgerock.opendj.cli.Utils.*;
import static org.opends.messages.AdminToolMessages.*;
import static com.forgerock.opendj.cli.Utils.OBFUSCATED_VALUE;
import java.awt.Component;
import java.awt.GridBagConstraints;
@@ -76,6 +77,9 @@
import javax.swing.text.JTextComponent;
import javax.swing.tree.TreePath;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.LocalizableMessageBuilder;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.guitools.controlpanel.datamodel.BinaryValue;
import org.opends.guitools.controlpanel.datamodel.CheckEntrySyntaxException;
import org.opends.guitools.controlpanel.datamodel.CustomSearchResult;
@@ -87,9 +91,6 @@
import org.opends.guitools.controlpanel.ui.nodes.BrowserNodeInfo;
import org.opends.guitools.controlpanel.ui.nodes.DndBrowserNodes;
import org.opends.guitools.controlpanel.util.Utilities;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.LocalizableMessageBuilder;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.schema.SchemaConstants;
import org.opends.server.types.*;
import org.opends.server.util.Base64;
@@ -98,7 +99,6 @@
/**
 * The panel displaying a simplified view of an entry.
 *
 */
public class SimplifiedViewEntryPanel extends ViewEntryPanel
{
@@ -929,25 +929,18 @@
      }
      else if (!isBinary)
      {
        Set<String> sValues = new TreeSet<String>();
        for (Object value : values)
        {
          sValues.add(String.valueOf(value));
        }
        Set<String> sValues = toStrings(values);
        LocalizableMessage text = LocalizableMessage.raw(Utilities.getStringFromCollection(sValues, "\n"));
        final JTextArea ta;
        JComponent toAdd;
        if (values.size() > 15)
        {
          ta = Utilities.createNonEditableTextArea(
              LocalizableMessage.raw(Utilities.getStringFromCollection(sValues, "\n")),
              15, 20);
          ta = Utilities.createNonEditableTextArea(text, 15, 20);
          toAdd = Utilities.createScrollPane(ta);
        }
        else
        {
          ta = Utilities.createNonEditableTextArea(
              LocalizableMessage.raw(Utilities.getStringFromCollection(sValues, "\n")),
              values.size(), 20);
          ta = Utilities.createNonEditableTextArea(text, values.size(), 20);
          toAdd = ta;
        }
        panel.add(toAdd, gbc);
@@ -989,6 +982,16 @@
    return panel;
  }
  private Set<String> toStrings(Collection<Object> objects)
  {
    Set<String> results = new TreeSet<String>();
    for (Object o : objects)
    {
      results.add(String.valueOf(o));
    }
    return results;
  }
  private JComponent getReadWriteComponent(final String attrName,
      List<Object> values)
  {
@@ -1063,14 +1066,9 @@
      }
      else if (isPassword(attrName) || isConfirmPassword(attrName))
      {
        JPasswordField pf;
        if (o.equals(""))
        JPasswordField pf = Utilities.createPasswordField();
        if (!o.equals(""))
        {
          pf = Utilities.createPasswordField();
        }
        else
        {
          pf = Utilities.createPasswordField();
          pf.setText(getPasswordStringValue(o));
        }
        panel.add(pf, gbc);
@@ -1082,80 +1080,48 @@
        {
          final JTextField tf = Utilities.createMediumTextField();
          tf.setText(String.valueOf(o));
          gbc.gridx = 0;
          panel.add(tf, gbc);
          if (mustAddBrowseButton(attrName))
          {
            gbc.gridx = 0;
            panel.add(tf, gbc);
            gbc.insets.left = 5;
            gbc.weightx = 0.0;
            gbc.gridx ++;
            gbc.anchor = GridBagConstraints.NORTH;
            JButton browse = Utilities.createButton(
                INFO_CTRL_PANEL_BROWSE_BUTTON_LABEL.get());
            browse.addActionListener(new ActionListener()
            {
              /**
               * {@inheritDoc}
               */
              public void actionPerformed(ActionEvent ev)
              {
                addBrowseClicked(attrName, tf);
              }
            });
            JButton browse = Utilities.createButton(INFO_CTRL_PANEL_BROWSE_BUTTON_LABEL.get());
            browse.addActionListener(new AddBrowseClickedActionListener(tf, attrName));
            panel.add(browse, gbc);
            new DropTarget(tf, dropTargetListener);
          }
          else
          {
            gbc.gridx = 0;
            panel.add(tf, gbc);
          }
          components.add(new EditorComponent(tf));
        }
        else
        {
          Set<String> sValues = new TreeSet<String>();
          for (Object value : values)
          {
            sValues.add(String.valueOf(value));
          }
          Set<String> sValues = toStrings(values);
          final LocalizableMessage text = LocalizableMessage.raw(Utilities.getStringFromCollection(sValues, "\n"));
          final JTextArea ta;
          JComponent toAdd;
          if (values.size() > 15)
          {
            ta = Utilities.createTextArea(
                LocalizableMessage.raw(Utilities.getStringFromCollection(sValues, "\n")),
                15, 20);
            ta = Utilities.createTextArea(text, 15, 20);
            toAdd = Utilities.createScrollPane(ta);
          }
          else
          {
            ta = Utilities.createTextAreaWithBorder(
                LocalizableMessage.raw(Utilities.getStringFromCollection(sValues, "\n")),
                values.size(), 20);
            ta = Utilities.createTextAreaWithBorder(text, values.size(), 20);
            toAdd = ta;
          }
          panel.add(toAdd, gbc);
          if (mustAddBrowseButton(attrName))
          {
            panel.add(toAdd, gbc);
            gbc.insets.left = 5;
            gbc.weightx = 0.0;
            gbc.gridx ++;
            gbc.anchor = GridBagConstraints.NORTH;
            final JButton browse = Utilities.createButton(
                INFO_CTRL_PANEL_BROWSE_BUTTON_LABEL.get());
            browse.addActionListener(new ActionListener()
            {
              /**
               * {@inheritDoc}
               */
              public void actionPerformed(ActionEvent ev)
              {
                addBrowseClicked(attrName, ta);
              }
            });
            if (attrName.equalsIgnoreCase(
                ServerConstants.ATTR_UNIQUE_MEMBER_LC))
            browse.addActionListener(new AddBrowseClickedActionListener(ta, attrName));
            if (attrName.equalsIgnoreCase(ServerConstants.ATTR_UNIQUE_MEMBER_LC))
            {
              browse.setText(
                  INFO_CTRL_PANEL_ADD_MEMBERS_BUTTON.get().toString());
@@ -1163,10 +1129,6 @@
            panel.add(browse, gbc);
            new DropTarget(ta, dropTargetListener);
          }
          else
          {
            panel.add(toAdd, gbc);
          }
          components.add(new EditorComponent(ta));
        }
        break;
@@ -1757,10 +1719,10 @@
    browseEntriesPanel.setMultipleSelection(!isSingleValue(attrName));
    browseEntriesDlg.setVisible(true);
    if (textComponent instanceof JTextArea)
    String[] dns = browseEntriesPanel.getDNs();
    if (dns.length > 0)
    {
      String[] dns = browseEntriesPanel.getDNs();
      if (dns.length > 0)
      if (textComponent instanceof JTextArea)
      {
        StringBuilder sb = new StringBuilder();
        sb.append(textComponent.getText());
@@ -1775,11 +1737,7 @@
        textComponent.setText(sb.toString());
        textComponent.setCaretPosition(sb.length());
      }
    }
    else
    {
      String[] dns = browseEntriesPanel.getDNs();
      if (dns.length > 0)
      else
      {
        textComponent.setText(dns[0]);
      }
@@ -1918,28 +1876,43 @@
  private boolean hasValue(EditorComponent editor)
  {
    boolean hasValue = false;
    Object value = editor.getValue();
    if (value != null)
    if (value instanceof byte[])
    {
      if (value instanceof byte[])
      {
        hasValue = ((byte[])value).length > 0;
      }
      else if (value instanceof String)
      {
        hasValue = ((String)value).trim().length() > 0;
      }
      else if (value instanceof Collection<?>)
      {
        hasValue = ((Collection<?>)value).size() > 0;
      }
      else
      {
        hasValue = true;
      }
      return ((byte[])value).length > 0;
    }
    return hasValue;
    else if (value instanceof String)
    {
      return ((String)value).trim().length() > 0;
    }
    else if (value instanceof Collection<?>)
    {
      return ((Collection<?>)value).size() > 0;
    }
    else if (value != null)
    {
      return true;
    }
    return false;
  }
  /** Calls #addBrowseClicked(). */
  private final class AddBrowseClickedActionListener implements ActionListener
  {
    private final JTextComponent tc;
    private final String attrName;
    private AddBrowseClickedActionListener(JTextComponent tc, String attrName)
    {
      this.tc = tc;
      this.attrName = attrName;
    }
    @Override
    public void actionPerformed(ActionEvent ev)
    {
      addBrowseClicked(attrName, tc);
    }
  }
  /**
@@ -1953,7 +1926,7 @@
    private Component comp;
    /**
     * Creats an EditorComponent using a text component.
     * Creates an EditorComponent using a text component.
     * @param tf the text component.
     */
    public EditorComponent(JTextComponent tf)
opendj-server-legacy/src/main/java/org/opends/quicksetup/ui/Utilities.java
@@ -272,11 +272,6 @@
            {
              // It does fit on the line, so add it.
              lineBuffer.append(delimBuffer).append(word);
              if (delimBuffer.length() > 0)
              {
                delimBuffer = new StringBuilder();
              }
            }
            else
            {
@@ -287,11 +282,11 @@
              lineBuffer = new StringBuilder();
              lineBuffer.append(word);
            }
              if (delimBuffer.length() > 0)
              {
                delimBuffer = new StringBuilder();
              }
            if (delimBuffer.length() > 0)
            {
              delimBuffer = new StringBuilder();
            }
          }
        }
opendj-server-legacy/src/main/java/org/opends/server/admin/AggregationPropertyDefinition.java
@@ -652,18 +652,18 @@
      boolean isAcceptable = true;
      for (ManagedObject<?> mo : findReferences(context,
          getManagedObjectDefinition(), path.getName())) {
        LocalizableMessage msg;
        String name = mo.getManagedObjectPath().getName();
        if (name == null) {
          LocalizableMessage msg = ERR_CLIENT_REFINT_CANNOT_DELETE_WITHOUT_NAME.get(
          msg = ERR_CLIENT_REFINT_CANNOT_DELETE_WITHOUT_NAME.get(
              getName(), mo.getManagedObjectDefinition().getUserFriendlyName(),
              getManagedObjectDefinition().getUserFriendlyName());
          unacceptableReasons.add(msg);
        } else {
          LocalizableMessage msg = ERR_CLIENT_REFINT_CANNOT_DELETE_WITH_NAME.get(
          msg = ERR_CLIENT_REFINT_CANNOT_DELETE_WITH_NAME.get(
              getName(), mo.getManagedObjectDefinition().getUserFriendlyName(),
              name, getManagedObjectDefinition().getUserFriendlyName());
          unacceptableReasons.add(msg);
        }
        unacceptableReasons.add(msg);
        isAcceptable = false;
      }
      return isAcceptable;
@@ -691,20 +691,18 @@
          getManagedObjectDefinition(), managedObject.getManagedObjectPath()
              .getName())) {
        if (targetNeedsEnablingCondition.evaluate(context, mo)) {
          LocalizableMessage msg;
          String name = mo.getManagedObjectPath().getName();
          if (name == null) {
            LocalizableMessage msg = ERR_CLIENT_REFINT_CANNOT_DISABLE_WITHOUT_NAME.get(
                managedObject.getManagedObjectDefinition()
                    .getUserFriendlyName(), getName(), mo
                    .getManagedObjectDefinition().getUserFriendlyName());
            unacceptableReasons.add(msg);
            msg = ERR_CLIENT_REFINT_CANNOT_DISABLE_WITHOUT_NAME.get(
                managedObject.getManagedObjectDefinition().getUserFriendlyName(),
                getName(), mo.getManagedObjectDefinition().getUserFriendlyName());
          } else {
            LocalizableMessage msg = ERR_CLIENT_REFINT_CANNOT_DISABLE_WITH_NAME.get(
                managedObject.getManagedObjectDefinition()
                    .getUserFriendlyName(), getName(), mo
                    .getManagedObjectDefinition().getUserFriendlyName(), name);
            unacceptableReasons.add(msg);
            msg = ERR_CLIENT_REFINT_CANNOT_DISABLE_WITH_NAME.get(
                managedObject.getManagedObjectDefinition().getUserFriendlyName(),
                getName(), mo.getManagedObjectDefinition().getUserFriendlyName(), name);
          }
          unacceptableReasons.add(msg);
          isAcceptable = false;
        }
      }
opendj-server-legacy/src/main/java/org/opends/server/backends/LDIFBackend.java
@@ -616,9 +616,6 @@
            }
          }
        }
        writeLDIF();
        return;
      }
      else
      {
@@ -652,10 +649,9 @@
        {
          subtreeDelete(childDN);
        }
        writeLDIF();
        return;
      }
      writeLDIF();
    }
    finally
    {
opendj-server-legacy/src/main/java/org/opends/server/backends/RootDSEBackend.java
@@ -576,61 +576,8 @@
        supportedTlsCiphers);
    addAttribute(supportedTLSCiphersAttr, dseUserAttrs, dseOperationalAttrs);
    // Add all the standard "static" attributes.
    for (Attribute a : staticDSEAttributes)
    {
      AttributeType type = a.getAttributeType();
      if (type.isOperational() && !showAllAttributes)
      {
        List<Attribute> attrs = dseOperationalAttrs.get(type);
        if (attrs == null)
        {
          attrs = new ArrayList<Attribute>();
          dseOperationalAttrs.put(type, attrs);
        }
        attrs.add(a);
      }
      else
      {
        List<Attribute> attrs = dseUserAttrs.get(type);
        if (attrs == null)
        {
          attrs = new ArrayList<Attribute>();
          dseUserAttrs.put(type, attrs);
        }
        attrs.add(a);
      }
    }
    // Add all the user-defined attributes.
    for (Attribute a : userDefinedAttributes)
    {
      AttributeType type = a.getAttributeType();
      if (type.isOperational() && !showAllAttributes)
      {
        List<Attribute> attrs = dseOperationalAttrs.get(type);
        if (attrs == null)
        {
          attrs = new ArrayList<Attribute>();
          dseOperationalAttrs.put(type, attrs);
        }
        attrs.add(a);
      }
      else
      {
        List<Attribute> attrs = dseUserAttrs.get(type);
        if (attrs == null)
        {
          attrs = new ArrayList<Attribute>();
          dseUserAttrs.put(type, attrs);
        }
        attrs.add(a);
      }
    }
    addAll(staticDSEAttributes, dseUserAttrs, dseOperationalAttrs);
    addAll(userDefinedAttributes, dseUserAttrs, dseOperationalAttrs);
    // Construct and return the entry.
    Entry e = new Entry(rootDSEDN, dseObjectClasses, dseUserAttrs,
@@ -639,6 +586,26 @@
    return e;
  }
  private void addAll(ArrayList<Attribute> attributes,
      Map<AttributeType, List<Attribute>> userAttrs, Map<AttributeType, List<Attribute>> operationalAttrs)
  {
    for (Attribute a : attributes)
    {
      AttributeType type = a.getAttributeType();
      final Map<AttributeType, List<Attribute>> attrsMap = type.isOperational() && !showAllAttributes
          ? operationalAttrs
          : userAttrs;
      List<Attribute> attrs = attrsMap.get(type);
      if (attrs == null)
      {
        attrs = new ArrayList<Attribute>();
        attrsMap.put(type, attrs);
      }
      attrs.add(a);
    }
  }
  private void addAttribute(Attribute publicNamingContextAttr,
opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java
@@ -329,37 +329,28 @@
    // attributes that we don't recognize will be included directly in the
    // schema entry.
    userDefinedAttributes = new ArrayList<Attribute>();
    for (List<Attribute> attrs :
         configEntry.getEntry().getUserAttributes().values())
    {
      for (Attribute a : attrs)
      {
        if (! isSchemaConfigAttribute(a))
        {
          userDefinedAttributes.add(a);
        }
      }
    }
    for (List<Attribute> attrs :
         configEntry.getEntry().getOperationalAttributes().values())
    {
      for (Attribute a : attrs)
      {
        if (! isSchemaConfigAttribute(a))
        {
          userDefinedAttributes.add(a);
        }
      }
    }
    addAll(configEntry.getEntry().getUserAttributes().values());
    addAll(configEntry.getEntry().getOperationalAttributes().values());
    // Determine whether to show all attributes.
    showAllAttributes = cfg.isShowAllAttributes();
    currentConfig = cfg;
  }
  private void addAll(Collection<List<Attribute>> attrsList)
  {
    for (List<Attribute> attrs : attrsList)
    {
      for (Attribute a : attrs)
      {
        if (! isSchemaConfigAttribute(a))
        {
          userDefinedAttributes.add(a);
        }
      }
    }
  }
  /** {@inheritDoc} */
  @Override
  public void initializeBackend()
@@ -453,18 +444,13 @@
      // Create a list of modifications and add any differences between the old
      // and new schema into them.
      List<Modification> mods = new LinkedList<Modification>();
      Schema.compareConcatenatedSchema(oldATs, newATs, attributeTypesType,
                                       mods);
      Schema.compareConcatenatedSchema(oldATs, newATs, attributeTypesType, mods);
      Schema.compareConcatenatedSchema(oldOCs, newOCs, objectClassesType, mods);
      Schema.compareConcatenatedSchema(oldNFs, newNFs, nameFormsType, mods);
      Schema.compareConcatenatedSchema(oldDCRs, newDCRs, ditContentRulesType,
                                       mods);
      Schema.compareConcatenatedSchema(oldDSRs, newDSRs, ditStructureRulesType,
                                       mods);
      Schema.compareConcatenatedSchema(oldMRUs, newMRUs, matchingRuleUsesType,
                                       mods);
      Schema.compareConcatenatedSchema(oldLSDs, newLSDs, ldapSyntaxesType,
                                      mods);
      Schema.compareConcatenatedSchema(oldDCRs, newDCRs, ditContentRulesType, mods);
      Schema.compareConcatenatedSchema(oldDSRs, newDSRs, ditStructureRulesType, mods);
      Schema.compareConcatenatedSchema(oldMRUs, newMRUs, matchingRuleUsesType, mods);
      Schema.compareConcatenatedSchema(oldLSDs, newLSDs, ldapSyntaxesType, mods);
      if (! mods.isEmpty())
      {
        // TODO : Raise an alert notification.
@@ -657,8 +643,7 @@
      for (int i = 0; i < numAVAs; i++)
      {
        AttributeType attrType = rdn.getAttributeType(i);
        Attribute attribute = Attributes.create(attrType,
            rdn.getAttributeValue(i));
        Attribute attribute = Attributes.create(attrType, rdn.getAttributeValue(i));
        addAttributeToSchemaEntry(attribute, userAttrs, operationalAttrs);
      }
    }
@@ -708,21 +693,16 @@
      }
    }
    addAttributeToSchemaEntry(
        Attributes.create(creatorsNameType, creatorsName), userAttrs,
        operationalAttrs);
        Attributes.create(creatorsNameType, creatorsName), userAttrs, operationalAttrs);
    addAttributeToSchemaEntry(
        Attributes.create(createTimestampType, createTimestamp), userAttrs,
        operationalAttrs);
        Attributes.create(createTimestampType, createTimestamp), userAttrs, operationalAttrs);
    addAttributeToSchemaEntry(
        Attributes.create(modifiersNameType, modifiersName), userAttrs,
        operationalAttrs);
        Attributes.create(modifiersNameType, modifiersName), userAttrs, operationalAttrs);
    addAttributeToSchemaEntry(
        Attributes.create(modifyTimestampType, modifyTimestamp), userAttrs,
        operationalAttrs);
        Attributes.create(modifyTimestampType, modifyTimestamp), userAttrs, operationalAttrs);
    // Add the extra attributes.
    for (Attribute attribute : DirectoryServer.getSchema().getExtraAttributes()
        .values())
    for (Attribute attribute : DirectoryServer.getSchema().getExtraAttributes().values())
    {
      addAttributeToSchemaEntry(attribute, userAttrs, operationalAttrs);
    }
@@ -734,8 +714,7 @@
    }
    // Construct and return the entry.
    Entry e = new Entry(entryDN, schemaObjectClasses, userAttrs,
        operationalAttrs);
    Entry e = new Entry(entryDN, schemaObjectClasses, userAttrs, operationalAttrs);
    e.processVirtualAttributes();
    return e;
  }
@@ -747,26 +726,14 @@
      Map<AttributeType, List<Attribute>> operationalAttrs)
  {
    AttributeType type = attribute.getAttributeType();
    if (type.isOperational())
    Map<AttributeType, List<Attribute>> attrsMap = type.isOperational() ? operationalAttrs : userAttrs;
    List<Attribute> attrs = attrsMap.get(type);
    if (attrs == null)
    {
      List<Attribute> attrs = operationalAttrs.get(type);
      if (attrs == null)
      {
        attrs = new ArrayList<Attribute>(1);
        operationalAttrs.put(type, attrs);
      }
      attrs.add(attribute);
      attrs = new ArrayList<Attribute>(1);
      attrsMap.put(type, attrs);
    }
    else
    {
      List<Attribute> attrs = userAttrs.get(type);
      if (attrs == null)
      {
        attrs = new ArrayList<Attribute>();
        userAttrs.put(type, attrs);
      }
      attrs.add(attribute);
    }
    attrs.add(attribute);
  }
@@ -3386,25 +3353,20 @@
        }
      }
      LocalizableMessage message;
      if (allCleaned)
      {
        LocalizableMessage message = ERR_SCHEMA_MODIFY_CANNOT_WRITE_ORIG_FILES_CLEANED.get(
            getExceptionMessage(e));
        throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
                                     message, e);
        message = ERR_SCHEMA_MODIFY_CANNOT_WRITE_ORIG_FILES_CLEANED.get(getExceptionMessage(e));
      }
      else
      {
        LocalizableMessage message = ERR_SCHEMA_MODIFY_CANNOT_WRITE_ORIG_FILES_NOT_CLEANED
                .get(getExceptionMessage(e));
        message = ERR_SCHEMA_MODIFY_CANNOT_WRITE_ORIG_FILES_NOT_CLEANED.get(getExceptionMessage(e));
        DirectoryServer.sendAlertNotification(this,
                             ALERT_TYPE_CANNOT_COPY_SCHEMA_FILES,
                             message);
        throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
                                     message, e);
      }
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), message, e);
    }
@@ -3446,25 +3408,20 @@
        }
      }
      LocalizableMessage message;
      if (allRestored)
      {
        LocalizableMessage message = ERR_SCHEMA_MODIFY_CANNOT_WRITE_NEW_FILES_RESTORED.get(
            getExceptionMessage(e));
        throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
                                     message, e);
        message = ERR_SCHEMA_MODIFY_CANNOT_WRITE_NEW_FILES_RESTORED.get(getExceptionMessage(e));
      }
      else
      {
        LocalizableMessage message = ERR_SCHEMA_MODIFY_CANNOT_WRITE_NEW_FILES_NOT_RESTORED
                .get(getExceptionMessage(e));
        message = ERR_SCHEMA_MODIFY_CANNOT_WRITE_NEW_FILES_NOT_RESTORED.get(getExceptionMessage(e));
        DirectoryServer.sendAlertNotification(this,
                             ALERT_TYPE_CANNOT_WRITE_NEW_SCHEMA_FILES,
                             message);
        throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
                                     message, e);
      }
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), message, e);
    }
    deleteFiles(origFileList);
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/Index.java
@@ -202,14 +202,13 @@
        entryLimitExceededCount++;
      }
      value = newImportIDSet.valueToByteString();
      put(txn, key, value);
    } else {
      if(!importIdSet.isDefined()) {
        entryLimitExceededCount++;
      }
      value = importIdSet.valueToByteString();
      put(txn, key, value);
    }
    put(txn, key, value);
  }
  /**
opendj-server-legacy/src/main/java/org/opends/server/config/DNConfigAttribute.java
@@ -161,17 +161,8 @@
    super(name, description, isRequired, isMultiValued, requiresAdminAction,
          getValueSet(values));
    if (values == null)
    {
      activeValues  = new ArrayList<DN>();
      pendingValues = activeValues;
    }
    else
    {
      activeValues  = values;
      pendingValues = activeValues;
    }
    activeValues  = values != null ? values : new ArrayList<DN>();
    pendingValues = activeValues;
  }
opendj-server-legacy/src/main/java/org/opends/server/config/IntegerConfigAttribute.java
@@ -218,16 +218,8 @@
    this.hasUpperBound = hasUpperBound;
    this.upperBound    = upperBound;
    if (values == null)
    {
      activeValues  = new ArrayList<Long>();
      pendingValues = activeValues;
    }
    else
    {
      activeValues  = values;
      pendingValues = activeValues;
    }
    activeValues  = values != null ? values : new ArrayList<Long>();
    pendingValues = activeValues;
  }
opendj-server-legacy/src/main/java/org/opends/server/config/JMXMBean.java
@@ -632,13 +632,12 @@
              String[] valueArray = new String[stringValues.size()];
              stringValues.toArray(valueArray);
              attrList.add(new Attribute(name, valueArray));
              break monitorLoop;
            }
            else
            {
              attrList.add(new Attribute(name, value.toString()));
              break monitorLoop;
            }
            break monitorLoop;
          }
        }
      }
opendj-server-legacy/src/main/java/org/opends/server/config/MultiChoiceConfigAttribute.java
@@ -190,16 +190,8 @@
    this.allowedValues = allowedValues;
    if (values == null)
    {
      activeValues  = new ArrayList<String>();
      pendingValues = activeValues;
    }
    else
    {
      activeValues  = values;
      pendingValues = activeValues;
    }
    activeValues  = values != null ? values : new ArrayList<String>();
    pendingValues = activeValues;
  }
opendj-server-legacy/src/main/java/org/opends/server/config/StringConfigAttribute.java
@@ -164,16 +164,8 @@
          getValueSet(values));
    if (values == null)
    {
      activeValues  = new ArrayList<String>();
      pendingValues = activeValues;
    }
    else
    {
      activeValues  = values;
      pendingValues = activeValues;
    }
    activeValues  = values != null ? values : new ArrayList<String>();
    pendingValues = activeValues;
  }
opendj-server-legacy/src/main/java/org/opends/server/plugins/ReferentialIntegrityPlugin.java
@@ -1224,19 +1224,13 @@
        DN valueEntryDN = DN.decode(attrVal);
        final Entry valueEntry;
        if (currentConfiguration.getCheckReferencesScopeCriteria() == CheckReferencesScopeCriteria.NAMING_CONTEXT)
        if (currentConfiguration.getCheckReferencesScopeCriteria() == CheckReferencesScopeCriteria.NAMING_CONTEXT
            && valueEntryDN.matchesBaseAndScope(entryBaseDN, SearchScope.SUBORDINATES))
        {
          if (valueEntryDN.matchesBaseAndScope(entryBaseDN, SearchScope.SUBORDINATES))
          {
            return PluginResult.PreOperation.stopProcessing(ResultCode.CONSTRAINT_VIOLATION,
                ERR_PLUGIN_REFERENT_NAMINGCONTEXT_MISMATCH.get(valueEntryDN, attr.getName(), entryDN));
          }
          valueEntry = DirectoryServer.getEntry(valueEntryDN);
          return PluginResult.PreOperation.stopProcessing(ResultCode.CONSTRAINT_VIOLATION,
              ERR_PLUGIN_REFERENT_NAMINGCONTEXT_MISMATCH.get(valueEntryDN, attr.getName(), entryDN));
        }
        else
        {
          valueEntry = DirectoryServer.getEntry(valueEntryDN);
        }
        valueEntry = DirectoryServer.getEntry(valueEntryDN);
        // Verify that the value entry exists in the backend.
        if (valueEntry == null)
opendj-server-legacy/src/main/java/org/opends/server/protocols/ldap/BindRequestProtocolOp.java
@@ -22,48 +22,42 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014 ForgeRock AS
 *      Portions Copyright 2014-2015 ForgeRock AS
 */
package org.opends.server.protocols.ldap;
import java.io.IOException;
import org.forgerock.opendj.io.*;
import org.opends.server.types.AuthenticationType;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import static org.opends.server.protocols.ldap.LDAPConstants.*;
import static org.opends.server.util.ServerConstants.*;
/**
 * This class defines the structures and methods for an LDAP bind request
 * protocol op, which is used to authenticate a user to the Directory Server.
 */
public class BindRequestProtocolOp
       extends ProtocolOp
public class BindRequestProtocolOp extends ProtocolOp
{
  private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
  // The bind DN for this request.
  /** The bind DN for this request. */
  private ByteString dn;
  // The SASL credentials for this request.
  /** The SASL credentials for this request. */
  private ByteString saslCredentials;
  // The simple authentication password for this request.
  /** The simple authentication password for this request. */
  private ByteString simplePassword;
  // The authentication type for this request.
  /** The authentication type for this request. */
  private AuthenticationType authenticationType;
  // The protocol version for this bind request.
  /** The protocol version for this bind request. */
  private int protocolVersion;
  // The SASL mechanism for this request.
  /** The SASL mechanism for this request. */
  private String saslMechanism;
@@ -249,29 +243,24 @@
   */
  public void toString(StringBuilder buffer)
  {
    buffer.append("BindRequest(version=");
    buffer.append(protocolVersion);
    buffer.append("BindRequest(version=").append(protocolVersion);
    buffer.append(", dn=");
    if (dn != null)
    {
      buffer.append(dn.toString());
      buffer.append(dn);
    }
    if (authenticationType == AuthenticationType.SIMPLE)
    {
      buffer.append(", password=");
      buffer.append(simplePassword.toString());
      buffer.append(", password=").append(simplePassword);
    }
    else
    {
      buffer.append(", saslMechanism=");
      buffer.append(saslMechanism);
      buffer.append(", saslMechanism=").append(saslMechanism);
      if (saslCredentials != null)
      {
        buffer.append(", saslCredentials=");
        buffer.append(saslCredentials.toString());
        buffer.append(", saslCredentials=").append(saslCredentials);
      }
    }
@@ -296,42 +285,27 @@
      indentBuf.append(' ');
    }
    buffer.append(indentBuf);
    buffer.append("Bind Request");
    buffer.append(EOL);
    buffer.append(indentBuf).append("Bind Request").append(EOL);
    buffer.append(indentBuf).append("  Protocol Version:  ").append(protocolVersion).append(EOL);
    buffer.append(indentBuf);
    buffer.append("  Protocol Version:  ");
    buffer.append(protocolVersion);
    buffer.append(EOL);
    buffer.append(indentBuf);
    buffer.append("  DN:  ");
    buffer.append(indentBuf).append("  DN:  ");
    if (dn != null)
    {
      buffer.append(dn.toString());
      buffer.append(dn);
    }
    buffer.append(EOL);
    if (authenticationType == AuthenticationType.SIMPLE)
    {
      buffer.append(indentBuf);
      buffer.append("  Simple Password:  ");
      buffer.append(String.valueOf(simplePassword));
      buffer.append(EOL);
      buffer.append(indentBuf).append("  Simple Password:  ").append(simplePassword).append(EOL);
    }
    else
    {
      buffer.append(indentBuf);
      buffer.append("  SASL Mechanism:  ");
      buffer.append(saslMechanism);
      buffer.append(EOL);
      buffer.append(indentBuf).append("  SASL Mechanism:  ").append(saslMechanism).append(EOL);
      if (saslCredentials != null)
      {
        buffer.append(indentBuf);
        buffer.append("  SASL Credentials:");
        buffer.append(EOL);
        buffer.append(indentBuf).append("  SASL Credentials:").append(EOL);
        buffer.append(saslCredentials.toHexPlusAsciiString(indent+4));
      }
    }
opendj-server-legacy/src/main/java/org/opends/server/replication/server/changelog/file/BlockLogReader.java
@@ -366,7 +366,6 @@
      // skip the offset
      reader.skipBytes(SIZE_OF_BLOCK_OFFSET);
      lengthBytes.append(reader, SIZE_OF_RECORD_SIZE - distanceToBlockStart);
      return lengthBytes.toByteString().toInt();
    }
    else
    {
@@ -376,8 +375,8 @@
        reader.skipBytes(SIZE_OF_BLOCK_OFFSET);
      }
      lengthBytes.append(reader, SIZE_OF_RECORD_SIZE);
      return lengthBytes.toByteString().toInt();
    }
    return lengthBytes.toByteString().toInt();
  }
  /**
opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPDelete.java
@@ -41,7 +41,6 @@
import java.io.PrintStream;
import java.io.Reader;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.concurrent.atomic.AtomicInteger;
import org.forgerock.i18n.LocalizableMessage;
@@ -686,23 +685,14 @@
    connectionOptions.setSASLExternal(saslExternal.isPresent());
    if(saslOptions.isPresent())
    {
      LinkedList<String> values = saslOptions.getValues();
      for(String saslOption : values)
      for (String saslOption : saslOptions.getValues())
      {
        if(saslOption.startsWith("mech="))
        boolean val = saslOption.startsWith("mech=")
            ? connectionOptions.setSASLMechanism(saslOption)
            : connectionOptions.addSASLProperty(saslOption);
        if (!val)
        {
          boolean val = connectionOptions.setSASLMechanism(saslOption);
          if(val == false)
          {
            return CLIENT_SIDE_PARAM_ERROR;
          }
        } else
        {
          boolean val = connectionOptions.addSASLProperty(saslOption);
          if(val == false)
          {
            return CLIENT_SIDE_PARAM_ERROR;
          }
          return CLIENT_SIDE_PARAM_ERROR;
        }
      }
    }
opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPModify.java
@@ -1066,23 +1066,14 @@
    connectionOptions.setSASLExternal(saslExternal.isPresent());
    if(saslOptions.isPresent())
    {
      LinkedList<String> values = saslOptions.getValues();
      for(String saslOption : values)
      for (String saslOption : saslOptions.getValues())
      {
        if(saslOption.startsWith("mech="))
        boolean val = saslOption.startsWith("mech=")
            ? connectionOptions.setSASLMechanism(saslOption)
            : connectionOptions.addSASLProperty(saslOption);
        if (!val)
        {
          boolean val = connectionOptions.setSASLMechanism(saslOption);
          if(val == false)
          {
            return CLIENT_SIDE_PARAM_ERROR;
          }
        } else
        {
          boolean val = connectionOptions.addSASLProperty(saslOption);
          if(val == false)
          {
            return CLIENT_SIDE_PARAM_ERROR;
          }
          return CLIENT_SIDE_PARAM_ERROR;
        }
      }
    }
opendj-server-legacy/src/main/java/org/opends/server/tools/LDIFSearch.java
@@ -272,7 +272,7 @@
    //Return objectclass attribute unless analysis of the arguments determines
    //otherwise.
    boolean            includeObjectclassAttrs = true;
    LinkedList<String> attributeNames;
    final LinkedList<String> attributeNames = new LinkedList<String>();
    LinkedList<String> objectClassNames    = new LinkedList<String>();
    LinkedList<String> filterStrings = new LinkedList<String>();
    if (filterFile.isPresent())
@@ -304,13 +304,8 @@
      }
      ArrayList<String> trailingArguments = argParser.getTrailingArguments();
      if ((trailingArguments == null) || trailingArguments.isEmpty())
      if (trailingArguments != null && !trailingArguments.isEmpty())
      {
        attributeNames = new LinkedList<String>();
      }
      else
      {
        attributeNames = new LinkedList<String>();
        for (String attributeName : trailingArguments)
        {
          String lowerName = toLowerCase(attributeName);
@@ -349,7 +344,6 @@
        filterStrings = new LinkedList<String>();
        filterStrings.add(iterator.next());
        attributeNames = new LinkedList<String>();
        while (iterator.hasNext())
        {
          String lowerName = toLowerCase(iterator.next());
@@ -373,8 +367,9 @@
      }
    }
    if (attributeNames.isEmpty() && objectClassNames.isEmpty() &&
        (! allOperationalAttrs))
    if (attributeNames.isEmpty()
        && objectClassNames.isEmpty()
        && !allOperationalAttrs)
    {
      // This will be true if no attributes were requested, which is effectively
      // all user attributes.  It will also be true if just "*" was included,
@@ -389,7 +384,7 @@
         attributeNames.isEmpty())
        includeObjectclassAttrs=false;
      //If "objectclass" isn't specified in the attributes to return, then
      //don't include objectclass attribiute.
      //don't include objectclass attribute.
      if(!attributeNames.isEmpty() && objectClassNames.isEmpty() &&
         !attributeNames.contains("objectclass"))
         includeObjectclassAttrs=false;
opendj-server-legacy/src/main/java/org/opends/server/tools/ManageTasks.java
@@ -709,14 +709,13 @@
        table.appendCell(INFO_TASKINFO_FIELD_STATUS.get());
        table.appendCell(taskEntry.getState());
        table.startRow();
        table.appendCell(INFO_TASKINFO_FIELD_SCHEDULED_START.get());
        if (TaskState.isRecurring(taskEntry.getTaskState())) {
          table.startRow();
          table.appendCell(INFO_TASKINFO_FIELD_SCHEDULED_START.get());
          m = taskEntry.getScheduleTab();
          table.appendCell(m);
        } else {
          table.startRow();
          table.appendCell(INFO_TASKINFO_FIELD_SCHEDULED_START.get());
          m = taskEntry.getScheduledStartTime();
          if (m == null || m.equals(LocalizableMessage.EMPTY)) {
            table.appendCell(INFO_TASKINFO_IMMEDIATE_EXECUTION.get());
opendj-server-legacy/src/main/java/org/opends/server/tools/makeldif/RDNTag.java
@@ -154,15 +154,11 @@
                                 TemplateValue templateValue)
  {
    DN dn = templateEntry.getDN();
    if ((dn == null) || dn.isRootDN())
    {
      return TagResult.SUCCESS_RESULT;
    }
    else
    if (dn != null && !dn.isRootDN())
    {
      dn.rdn().toString(templateValue.getValue());
      return TagResult.SUCCESS_RESULT;
    }
    return TagResult.SUCCESS_RESULT;
  }
}
opendj-server-legacy/src/main/java/org/opends/server/tools/makeldif/TemplateEntry.java
@@ -22,10 +22,13 @@
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2014 ForgeRock AS
 *      Portions Copyright 2014-2015 ForgeRock AS
 */
package org.opends.server.tools.makeldif;
import static org.opends.server.util.LDIFWriter.*;
import static org.opends.server.util.StaticUtils.*;
import java.io.BufferedWriter;
import java.io.IOException;
import java.util.ArrayList;
@@ -37,9 +40,6 @@
import org.opends.server.types.*;
import org.opends.server.util.LDIFException;
import static org.opends.server.util.LDIFWriter.*;
import static org.opends.server.util.StaticUtils.*;
/**
 * This class defines an entry that is generated using a MakeLDIF branch or
 * template.
@@ -315,9 +315,7 @@
          builder.add(v.getValue().toString());
        }
        ArrayList<Attribute> attrList = new ArrayList<Attribute>(1);
        attrList.add(builder.toAttribute());
        operationalAttributes.put(t, attrList);
        operationalAttributes.put(t, asList(builder));
      }
      else
      {
@@ -346,22 +344,14 @@
          }
        }
        ArrayList<Attribute> attrList = new ArrayList<Attribute>(1);
        attrList.add(builder.toAttribute());
        userAttributes.put(t, attrList);
        userAttributes.put(t, asList(builder));
        if (urlBuilder != null)
        {
          ArrayList<Attribute> urlAttrList = new ArrayList<Attribute>(1);
          urlAttrList.add(urlBuilder.toAttribute());
          urlAttributes.put(t, urlAttrList);
          urlAttributes.put(t, asList(urlBuilder));
        }
        if (base64Builder != null)
        {
          ArrayList<Attribute> base64AttrList = new ArrayList<Attribute>(1);
          base64AttrList.add(base64Builder.toAttribute());
          base64Attributes.put(t, base64AttrList);
          base64Attributes.put(t, asList(base64Builder));
        }
      }
    }
@@ -373,8 +363,7 @@
    // First, write the DN.  It will always be included.
    StringBuilder dnLine = new StringBuilder();
    dnLine.append("dn");
    StringBuilder dnLine = new StringBuilder("dn");
    appendLDIFSeparatorAndValue(dnLine,
        ByteString.valueOf(getDN().toString()));
    writeLDIFLine(dnLine, writer, wrapLines, wrapColumn);
@@ -393,9 +382,7 @@
      {
        for (String s : objectClasses.values())
        {
          StringBuilder ocLine = new StringBuilder();
          ocLine.append("objectClass: ");
          ocLine.append(s);
          StringBuilder ocLine = new StringBuilder("objectClass: ").append(s);
          writeLDIFLine(ocLine, writer, wrapLines, wrapColumn);
        }
      }
@@ -407,8 +394,7 @@
    {
      if (exportConfig.includeAttribute(attrType))
      {
        List<Attribute> attrList = userAttributes.get(attrType);
        for (Attribute a : attrList)
        for (Attribute a : userAttributes.get(attrType))
        {
          if (a.isVirtual() &&
              (! exportConfig.includeVirtualAttributes()))
@@ -416,72 +402,23 @@
            continue;
          }
          StringBuilder attrName = attrNameWithOptions(a);
          if (typesOnly)
          {
            StringBuilder attrName = new StringBuilder(a.getName());
            for (String o : a.getOptions())
            {
              attrName.append(";");
              attrName.append(o);
            }
            attrName.append(":");
            writeLDIFLine(attrName, writer, wrapLines, wrapColumn);
          }
          else
          {
            StringBuilder attrName = new StringBuilder(a.getName());
            for (String o : a.getOptions())
            {
              attrName.append(";");
              attrName.append(o);
            }
            List<Attribute> urlAttrList = urlAttributes.get(attrType);
            List<Attribute> base64AttrList = base64Attributes.get(attrType);
            for (ByteString v : a)
            {
              StringBuilder attrLine = new StringBuilder();
              attrLine.append(attrName);
              boolean isURLValue = false;
              if (urlAttrList != null)
              {
                for (Attribute urlAttr : urlAttrList)
                {
                  for (ByteString urlValue : urlAttr)
                  {
                    if (urlValue.equals(v))
                    {
                      isURLValue = true;
                      break;
                    }
                  }
                  if (isURLValue)
                  {
                    break;
                  }
                }
              }
              boolean isBase64Value = false;
              if (base64AttrList != null)
              {
                for (Attribute base64Attr : base64AttrList)
                {
                  for (ByteString base64Value : base64Attr)
                  {
                    if (base64Value.equals(v))
                    {
                      isBase64Value = true;
                      break;
                    }
                  }
                  if (isBase64Value)
                  {
                    break;
                  }
                }
              }
              StringBuilder attrLine = new StringBuilder(attrName);
              boolean isURLValue = contains(urlAttrList, v);
              boolean isBase64Value = contains(base64AttrList, v);
              appendLDIFSeparatorAndValue(attrLine,
                                          v,
                                          isURLValue,
@@ -501,9 +438,7 @@
      {
        if (exportConfig.includeAttribute(attrType))
        {
          List<Attribute> attrList =
               operationalAttributes.get(attrType);
          for (Attribute a : attrList)
          for (Attribute a : operationalAttributes.get(attrType))
          {
            if (a.isVirtual() &&
                (! exportConfig.includeVirtualAttributes()))
@@ -511,31 +446,18 @@
              continue;
            }
            StringBuilder attrName = attrNameWithOptions(a);
            if (typesOnly)
            {
              StringBuilder attrName = new StringBuilder(a.getName());
              for (String o : a.getOptions())
              {
                attrName.append(";");
                attrName.append(o);
              }
              attrName.append(":");
              writeLDIFLine(attrName, writer, wrapLines, wrapColumn);
            }
            else
            {
              StringBuilder attrName = new StringBuilder(a.getName());
              for (String o : a.getOptions())
              {
                attrName.append(";");
                attrName.append(o);
              }
              for (ByteString v : a)
              {
                StringBuilder attrLine = new StringBuilder();
                attrLine.append(attrName);
                StringBuilder attrLine = new StringBuilder(attrName);
                appendLDIFSeparatorAndValue(attrLine, v);
                writeLDIFLine(attrLine, writer, wrapLines, wrapColumn);
              }
@@ -548,8 +470,42 @@
    // Make sure there is a blank line after the entry.
    writer.newLine();
    return true;
  }
}
  private StringBuilder attrNameWithOptions(Attribute a)
  {
    StringBuilder attrName = new StringBuilder(a.getName());
    for (String o : a.getOptions())
    {
      attrName.append(";");
      attrName.append(o);
    }
    return attrName;
  }
  private ArrayList<Attribute> asList(AttributeBuilder builder)
  {
    ArrayList<Attribute> attrList = new ArrayList<Attribute>(1);
    attrList.add(builder.toAttribute());
    return attrList;
  }
  private boolean contains(List<Attribute> urlAttrList, ByteString v)
  {
    if (urlAttrList != null)
    {
      for (Attribute urlAttr : urlAttrList)
      {
        for (ByteString urlValue : urlAttr)
        {
          if (urlValue.equals(v))
          {
            return true;
          }
        }
      }
    }
    return false;
  }
}
opendj-server-legacy/src/main/java/org/opends/server/types/LockManager.java
@@ -591,34 +591,24 @@
  {
    // Get the corresponding read-write lock from the lock table.
    ReentrantReadWriteLock existingLock = lockTable.get(entryDN);
    if (existingLock == null)
    {
      // This shouldn't happen, but if it does then all we can do is
      // release the lock and return.
      lock.unlock();
      return;
    }
    // See if there's anything waiting on the lock.  If so, then we
    // can't remove it from the table when we unlock it.
    if (existingLock.hasQueuedThreads() ||
        (existingLock.getReadLockCount() > 1))
    // it should never be null, if it is is then all we can do is
    // release the lock and return.
    lock.unlock();
    if (existingLock != null
        && !existingLock.hasQueuedThreads()
        && existingLock.getReadLockCount() <= 1)
    {
      lock.unlock();
      return;
    }
    else
    {
      lock.unlock();
      synchronized (existingLock)
      {
        if ((! existingLock.isWriteLocked()) &&
            (existingLock.getReadLockCount() == 0))
        if (!existingLock.isWriteLocked()
            && existingLock.getReadLockCount() == 0)
        {
          // If there's nothing waiting on the lock,
          // then we can remove it from the table when we unlock it.
          lockTable.remove(entryDN, existingLock);
        }
      }
      return;
    }
  }
opendj-server-legacy/src/main/java/org/opends/server/util/LDIFWriter.java
@@ -638,16 +638,8 @@
    // Write the changetype.  Some older tools may not support the "moddn"
    // changetype, so only use it if a newSuperior element has been provided,
    // but use modrdn elsewhere.
    if (newSuperior == null)
    {
      StringBuilder changeTypeLine = new StringBuilder("changetype: modrdn");
      writeLDIFLine(changeTypeLine, writer, wrapLines, wrapColumn);
    }
    else
    {
      StringBuilder changeTypeLine = new StringBuilder("changetype: moddn");
      writeLDIFLine(changeTypeLine, writer, wrapLines, wrapColumn);
    }
    String changeType = newSuperior == null ? "changetype: modrdn" : "changetype: moddn";
    writeLDIFLine(new StringBuilder(changeType), writer, wrapLines, wrapColumn);
    // Write the newRDN element.
opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyDNOperation.java
@@ -404,6 +404,10 @@
        return;
      }
      // Apply any changes to the entry based on the change in its RDN.
      // Also perform schema checking on the updated entry.
      applyRDNChanges(modifications);
      // If the operation is not a synchronization operation,
      // - Apply the RDN changes.
      // - Invoke the pre-operation modify DN plugins.
@@ -412,10 +416,6 @@
      // - apply the operation as it was originally done on the master.
      if (!isSynchronizationOperation())
      {
        // Apply any changes to the entry based on the change in its RDN.
        // Also perform schema checking on the updated entry.
        applyRDNChanges(modifications);
        // Check for a request to cancel this operation.
        checkIfCanceled(false);
@@ -446,9 +446,6 @@
      }
      else
      {
        // This is a synchronization operation
        // Apply the modifications as they were originally done.
        applyRDNChanges(modifications);
        applyPreOpModifications(modifications, 0, false);
      }