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

Nicolas Capponi
26.08.2015 8b3cd28204e15e0a98ce038b355f100cd7c44e3c
opendj-server-legacy/replace.rb
@@ -406,7 +406,7 @@
  ###############################  List of replacements to run #################################
  REPLACEMENTS = [ SYNTAXES_TO_SDK, SYNTAXES_TO_SDK_SCM ]
  REPLACEMENTS = [ ATTRTYPE ]
  ################################### Processing methods ########################################
opendj-server-legacy/resource/admin/property-types/attribute-type.xsl
@@ -22,6 +22,7 @@
  !
  !
  !      Copyright 2008 Sun Microsystems, Inc.
  !      Portions copyright 2015-2016 ForgeRock AS
  ! -->
<xsl:stylesheet version="1.0" xmlns:adm="http://www.opends.org/admin"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
@@ -29,7 +30,7 @@
    Templates for processing attribute type properties.
  -->
  <xsl:template match="adm:attribute-type" mode="java-value-imports">
    <import>org.opends.server.types.AttributeType</import>
    <import>org.forgerock.opendj.ldap.schema.AttributeType</import>
  </xsl:template>
  <xsl:template match="adm:attribute-type" mode="java-value-type">
    <xsl:value-of select="'AttributeType'" />
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/CustomSearchResult.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.guitools.controlpanel.datamodel;
@@ -45,10 +45,10 @@
import javax.naming.directory.SearchResult;
import org.forgerock.opendj.ldap.ByteString;
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.opends.server.types.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
import org.opends.server.types.ObjectClass;
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/IndexDescriptor.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2015 ForgeRock AS
 *      Portions Copyright 2015-2016 ForgeRock AS
 */
package org.opends.guitools.controlpanel.datamodel;
@@ -33,7 +33,7 @@
import java.util.SortedSet;
import java.util.TreeSet;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
/**
 * The class used to describe the index configuration (the normal index: the one
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/ServerDescriptor.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.guitools.controlpanel.datamodel;
@@ -39,8 +39,9 @@
import org.opends.guitools.controlpanel.util.ConfigFromDirContext;
import org.opends.quicksetup.UserData;
import org.opends.server.schema.SomeSchemaElement;
import org.opends.server.tools.tasks.TaskEntry;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.ObjectClass;
import org.opends.server.types.OpenDsException;
@@ -563,17 +564,19 @@
  private static boolean areAttributeTypesEqual(Schema schema1, Schema schema2)
  {
    final Map<String, AttributeType> attrs1 = schema1.getAttributeTypes();
    final Map<String, AttributeType> attrs2 = schema2.getAttributeTypes();
    final List<AttributeType> attrs1 = new ArrayList<>(schema1.getAttributeTypes());
    final List<AttributeType> attrs2 = new ArrayList<>(schema2.getAttributeTypes());
    if (attrs1.size() != attrs2.size())
    {
      return false;
    }
    for (String name : attrs1.keySet())
    Collections.sort(attrs1);
    Collections.sort(attrs2);
    for (int i = 0; i < attrs1.size(); i++)
    {
      AttributeType attr1 = attrs1.get(name);
      AttributeType attr2 = attrs2.get(name);
      if (attr2 == null && !areAttributesEqual(attr1, attr2))
      AttributeType attr1 = attrs1.get(i);
      AttributeType attr2 = attrs2.get(i);
      if (attr2 == null || !areAttributesEqual(attr1, attr2))
      {
        return false;
      }
@@ -620,7 +623,8 @@
        && attr1.isOperational() == attr2.isOperational()
        && attr1.isSingleValue() == attr2.isSingleValue()
        && areEqual(attr1.getApproximateMatchingRule(), attr2.getApproximateMatchingRule())
        && areEqual(getDefinitionWithFileName(attr1), getDefinitionWithFileName(attr2))
        && areEqual(new SomeSchemaElement(attr1).getDefinitionWithFileName(),
            new SomeSchemaElement(attr2).getDefinitionWithFileName())
        && areEqual(attr1.getDescription(), attr2.getDescription())
        && areEqual(attr1.getEqualityMatchingRule(), attr2.getEqualityMatchingRule())
        && areEqual(attr1.getOrderingMatchingRule(), attr2.getOrderingMatchingRule())
@@ -629,8 +633,7 @@
        && areEqual(attr1.getSyntax(), attr2.getSyntax())
        && areEqual(attr1.getSyntax().getOID(), attr2.getSyntax().getOID())
        && areEqual(attr1.getExtraProperties().keySet(), attr2.getExtraProperties().keySet())
        && areEqual(toSet(attr1.getNormalizedNames()), toSet(attr2.getNormalizedNames()))
        && areEqual(toSet(attr1.getUserDefinedNames()), toSet(attr2.getUserDefinedNames()));
        && areEqual(toSet(attr1.getNames()), toSet(attr2.getNames()));
  }
  /**
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/DeleteSchemaElementsTask.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2015 ForgeRock AS.
 *      Portions Copyright 2013-2016 ForgeRock AS.
 */
package org.opends.guitools.controlpanel.task;
@@ -46,26 +46,27 @@
import javax.naming.directory.ModificationItem;
import javax.swing.SwingUtilities;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.LocalizableMessageDescriptor.Arg1;
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo;
import org.opends.guitools.controlpanel.ui.ColorAndFontConstants;
import org.opends.guitools.controlpanel.ui.ProgressDialog;
import org.opends.guitools.controlpanel.util.Utilities;
import org.forgerock.i18n.LocalizableMessage;
import org.opends.server.config.ConfigConstants;
import org.opends.server.core.DirectoryServer;
import org.opends.server.schema.SomeSchemaElement;
import org.opends.server.types.Attributes;
import org.opends.server.types.AttributeType;
import org.opends.server.types.CommonSchemaElements;
import org.opends.server.types.Entry;
import org.opends.server.types.ExistingFileBehavior;
import org.opends.server.types.LDIFExportConfig;
import org.opends.server.types.LDIFImportConfig;
import org.opends.server.types.Modification;
import org.forgerock.opendj.ldap.ModificationType;
import org.opends.server.types.ObjectClass;
import org.opends.server.types.OpenDsException;
import org.opends.server.types.Schema;
import org.opends.server.types.SchemaFileElement;
import org.opends.server.util.LDIFReader;
import org.opends.server.util.LDIFWriter;
import org.opends.server.util.StaticUtils;
@@ -232,131 +233,20 @@
   */
  private void updateSchema() throws OpenDsException
  {
    final boolean[] isFirst = {true};
    final int totalNumber = ocsToDelete.size() + attrsToDelete.size();
    int numberDeleted = 0;
    for (ObjectClass objectClass : ocsToDelete)
    {
      final ObjectClass fObjectclass = objectClass;
      SwingUtilities.invokeLater(new Runnable()
      {
        @Override
        public void run()
        {
          if (!isFirst[0])
          {
            getProgressDialog().appendProgressHtml("<br><br>");
          }
          isFirst[0] = false;
          printEquivalentCommandToDelete(fObjectclass);
          getProgressDialog().appendProgressHtml(
              Utilities.getProgressWithPoints(
                  INFO_CTRL_PANEL_DELETING_OBJECTCLASS.get(
                      fObjectclass.getNameOrOID()),
                  ColorAndFontConstants.progressFont));
        }
      });
      if (isServerRunning())
      {
        try
        {
          BasicAttribute attr = new BasicAttribute(
              getSchemaFileAttributeName(objectClass));
          attr.add(getSchemaFileAttributeValue(objectClass));
          ModificationItem mod =
            new ModificationItem(DirContext.REMOVE_ATTRIBUTE, attr);
          getInfo().getDirContext().modifyAttributes(
              ConfigConstants.DN_DEFAULT_SCHEMA_ROOT,
              new ModificationItem[]  { mod });
        }
        catch (NamingException ne)
        {
          throw new OnlineUpdateException(
              ERR_CTRL_PANEL_ERROR_UPDATING_SCHEMA.get(ne), ne);
        }
      }
      else
      {
        updateSchemaFile(objectClass);
      }
      numberDeleted ++;
      final int fNumberDeleted = numberDeleted;
      SwingUtilities.invokeLater(new Runnable()
      {
        @Override
        public void run()
        {
          getProgressDialog().getProgressBar().setIndeterminate(false);
          getProgressDialog().getProgressBar().setValue(
              (fNumberDeleted * 100) / totalNumber);
          getProgressDialog().appendProgressHtml(
              Utilities.getProgressDone(ColorAndFontConstants.progressFont));
        }
      });
      final SomeSchemaElement element = new SomeSchemaElement(objectClass);
      deleteSchemaElement(element, numberDeleted, totalNumber, INFO_CTRL_PANEL_DELETING_OBJECTCLASS);
      numberDeleted++;
    }
    for (AttributeType attribute : attrsToDelete)
    {
      final AttributeType fAttribute = attribute;
      SwingUtilities.invokeLater(new Runnable()
      {
        @Override
        public void run()
        {
          if (!isFirst[0])
          {
            getProgressDialog().appendProgressHtml("<br><br>");
          }
          isFirst[0] = false;
          printEquivalentCommandToDelete(fAttribute);
          getProgressDialog().appendProgressHtml(
              Utilities.getProgressWithPoints(
                  INFO_CTRL_PANEL_DELETING_ATTRIBUTE.get(
                      fAttribute.getNameOrOID()),
                  ColorAndFontConstants.progressFont));
        }
      });
      if (isServerRunning())
      {
        try
        {
          BasicAttribute attr = new BasicAttribute(
              getSchemaFileAttributeName(attribute));
          attr.add(getSchemaFileAttributeValue(attribute));
          ModificationItem mod = new ModificationItem(
              DirContext.REMOVE_ATTRIBUTE,
              attr);
          getInfo().getDirContext().modifyAttributes(
              ConfigConstants.DN_DEFAULT_SCHEMA_ROOT,
              new ModificationItem[]  { mod });
        }
        catch (NamingException ne)
        {
          throw new OnlineUpdateException(
              ERR_CTRL_PANEL_ERROR_UPDATING_SCHEMA.get(ne), ne);
        }
      }
      else
      {
        updateSchemaFile(attribute);
      }
      numberDeleted ++;
      final int fNumberDeleted = numberDeleted;
      SwingUtilities.invokeLater(new Runnable()
      {
        @Override
        public void run()
        {
          getProgressDialog().getProgressBar().setIndeterminate(false);
          getProgressDialog().getProgressBar().setValue(
              (fNumberDeleted * 100) / totalNumber);
          getProgressDialog().appendProgressHtml(
              Utilities.getProgressDone(ColorAndFontConstants.progressFont));
        }
      });
      final SomeSchemaElement element = new SomeSchemaElement(attribute);
      deleteSchemaElement(element, numberDeleted, totalNumber, INFO_CTRL_PANEL_DELETING_ATTRIBUTE);
      numberDeleted++;
    }
    if (!ocsToAdd.isEmpty() || !attrsToAdd.isEmpty())
@@ -381,12 +271,67 @@
    }
  }
  private void deleteSchemaElement(final SomeSchemaElement element, final int numberDeleted, final int totalNumber,
      final Arg1<Object> deletingElementMsg) throws OnlineUpdateException, OpenDsException
  {
    SwingUtilities.invokeLater(new Runnable()
    {
      @Override
      public void run()
      {
        final boolean isFirst = numberDeleted == 0;
        if (!isFirst)
        {
          getProgressDialog().appendProgressHtml("<br><br>");
        }
        printEquivalentCommandToDelete(element);
        getProgressDialog().appendProgressHtml(
            Utilities.getProgressWithPoints(
                deletingElementMsg.get(element.getNameOrOID()), ColorAndFontConstants.progressFont));
      }
    });
    if (isServerRunning())
    {
      try
      {
        BasicAttribute attr = new BasicAttribute(getSchemaFileAttributeName(element));
        attr.add(getSchemaFileAttributeValue(element));
        ModificationItem mod = new ModificationItem(DirContext.REMOVE_ATTRIBUTE, attr);
        getInfo().getDirContext().modifyAttributes(
            ConfigConstants.DN_DEFAULT_SCHEMA_ROOT,
            new ModificationItem[]  { mod });
      }
      catch (NamingException ne)
      {
        throw new OnlineUpdateException(ERR_CTRL_PANEL_ERROR_UPDATING_SCHEMA.get(ne), ne);
      }
    }
    else
    {
      updateSchemaFile(element);
    }
    final int fNumberDeleted = numberDeleted + 1;
    SwingUtilities.invokeLater(new Runnable()
    {
      @Override
      public void run()
      {
        getProgressDialog().getProgressBar().setIndeterminate(false);
        getProgressDialog().getProgressBar().setValue((fNumberDeleted * 100) / totalNumber);
        getProgressDialog().appendProgressHtml(
            Utilities.getProgressDone(ColorAndFontConstants.progressFont));
      }
    });
  }
  /**
   * Updates the schema file by deleting the provided schema element.
   * @param schemaElement the schema element to be deleted.
   * @throws OpenDsException if an error occurs.
   */
  private void updateSchemaFile(CommonSchemaElements schemaElement)
  private void updateSchemaFile(SomeSchemaElement schemaElement)
  throws OpenDsException
  {
    String schemaFile = getSchemaFile(schemaElement);
@@ -425,9 +370,9 @@
   * @param element the schema element.
   * @return the schema file for a given schema element.
   */
  private String getSchemaFile(SchemaFileElement element)
  private String getSchemaFile(SomeSchemaElement element)
  {
    String schemaFile = CommonSchemaElements.getSchemaFile(element);
    String schemaFile = element.getSchemaFile();
    if (schemaFile == null)
    {
      schemaFile = ConfigConstants.FILE_USER_SCHEMA_ELEMENTS;
@@ -449,9 +394,9 @@
   * @return the attribute name in the schema entry that corresponds to the
   * provided schema element.
   */
  private String getSchemaFileAttributeName(CommonSchemaElements element)
  private String getSchemaFileAttributeName(SomeSchemaElement element)
  {
    if (element instanceof AttributeType)
    if (element.isAttributeType())
    {
      return "attributeTypes";
    }
@@ -466,7 +411,7 @@
   * @param element the schema element.
   * @return the value in the schema file for the provided element.
   */
  private String getSchemaFileAttributeValue(CommonSchemaElements element)
  private String getSchemaFileAttributeValue(SomeSchemaElement element)
  {
    return element.toString();
  }
@@ -476,7 +421,7 @@
   * progress dialog.
   * @param element the schema element to be deleted.
   */
  private void printEquivalentCommandToDelete(CommonSchemaElements element)
  private void printEquivalentCommandToDelete(SomeSchemaElement element)
  {
    String schemaFile = getSchemaFile(element);
    String attrName = getSchemaFileAttributeName(element);
@@ -484,7 +429,7 @@
    if (!isServerRunning())
    {
      LocalizableMessage msg;
      if (element instanceof AttributeType)
      if (element.isAttributeType())
      {
        msg = INFO_CTRL_PANEL_EQUIVALENT_CMD_TO_DELETE_ATTRIBUTE_OFFLINE.get(
            element.getNameOrOID(), schemaFile);
@@ -510,7 +455,7 @@
          args);
      LocalizableMessage msg;
      if (element instanceof AttributeType)
      if (element.isAttributeType())
      {
        msg = INFO_CTRL_PANEL_EQUIVALENT_CMD_TO_DELETE_ATTRIBUTE_ONLINE.get(
            element.getNameOrOID());
@@ -543,38 +488,13 @@
      if (attr.equals(attrToDelete.getSuperiorType()))
      {
        isSuperior = true;
        AttributeType newSuperior = attr.getSuperiorType();
        while (newSuperior != null &&
            providedAttrsToDelete.contains(newSuperior))
        {
          newSuperior = newSuperior.getSuperiorType();
        }
        break;
      }
    }
    if (isSuperior)
    {
      ArrayList<String> allNames = new ArrayList<>(attrToDelete.getNormalizedNames());
      Map<String, List<String>> extraProperties =
        cloneExtraProperties(attrToDelete);
      return new AttributeType(
          "",
          attrToDelete.getPrimaryName(),
          allNames,
          attrToDelete.getOID(),
          attrToDelete.getDescription(),
          null,
          attrToDelete.getSyntax(),
          attrToDelete.getApproximateMatchingRule(),
          attrToDelete.getEqualityMatchingRule(),
          attrToDelete.getOrderingMatchingRule(),
          attrToDelete.getSubstringMatchingRule(),
          attrToDelete.getUsage(),
          attrToDelete.isCollective(),
          attrToDelete.isNoUserModification(),
          attrToDelete.isObsolete(),
          attrToDelete.isSingleValue(),
          extraProperties);
       // get a new attribute without the superior type
       return SomeSchemaElement.changeSuperiorType(attrToDelete, null);
    }
    else
    {
@@ -771,7 +691,7 @@
      AttributeType attribute, Schema schema)
  {
    LinkedHashSet<AttributeType> children = new LinkedHashSet<>();
    for (AttributeType attr : schema.getAttributeTypes().values())
    for (AttributeType attr : schema.getAttributeTypes())
    {
      if (attribute.equals(attr.getSuperiorType()))
      {
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/ModifyAttributeTask.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2009-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.guitools.controlpanel.task;
@@ -41,11 +41,12 @@
import javax.swing.SwingUtilities;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo;
import org.opends.guitools.controlpanel.ui.ColorAndFontConstants;
import org.opends.guitools.controlpanel.ui.ProgressDialog;
import org.opends.guitools.controlpanel.util.Utilities;
import org.opends.server.types.AttributeType;
import org.opends.server.schema.SomeSchemaElement;
import org.opends.server.types.ObjectClass;
import org.opends.server.types.OpenDsException;
import org.opends.server.types.Schema;
@@ -155,28 +156,8 @@
    }
    else if (oldAttribute.equals(attrToDelete.getSuperiorType()))
    {
      ArrayList<String> allNames = new ArrayList<>(attrToDelete.getNormalizedNames());
      Map<String, List<String>> extraProperties =
        DeleteSchemaElementsTask.cloneExtraProperties(attrToDelete);
      AttributeType newSuperior = newAttribute;
      return new AttributeType(
          "",
          attrToDelete.getPrimaryName(),
          allNames,
          attrToDelete.getOID(),
          attrToDelete.getDescription(),
          newSuperior,
          attrToDelete.getSyntax(),
          attrToDelete.getApproximateMatchingRule(),
          attrToDelete.getEqualityMatchingRule(),
          attrToDelete.getOrderingMatchingRule(),
          attrToDelete.getSubstringMatchingRule(),
          attrToDelete.getUsage(),
          attrToDelete.isCollective(),
          attrToDelete.isNoUserModification(),
          attrToDelete.isObsolete(),
          attrToDelete.isSingleValue(),
          extraProperties);
      // get a new attribute with the new superior type
      return SomeSchemaElement.changeSuperiorType(attrToDelete, newAttribute);
    }
    else
    {
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/ModifyObjectClassTask.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2009-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.guitools.controlpanel.task;
@@ -44,7 +44,7 @@
import org.opends.guitools.controlpanel.ui.ProgressDialog;
import org.opends.guitools.controlpanel.util.Utilities;
import org.forgerock.i18n.LocalizableMessage;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.ObjectClass;
import org.opends.server.types.OpenDsException;
import org.opends.server.types.Schema;
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/NewSchemaElementsTask.java
@@ -22,18 +22,18 @@
 *
 *
 *      Copyright 2009 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2015 ForgeRock AS.
 *      Portions Copyright 2013-2016 ForgeRock AS.
 */
package org.opends.guitools.controlpanel.task;
import static org.forgerock.util.Utils.*;
import static org.opends.messages.AdminToolMessages.*;
import static org.opends.server.types.CommonSchemaElements.*;
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
@@ -49,6 +49,7 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo;
import org.opends.guitools.controlpanel.ui.ColorAndFontConstants;
@@ -56,9 +57,8 @@
import org.opends.guitools.controlpanel.util.Utilities;
import org.opends.server.config.ConfigConstants;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.AttributeType;
import org.opends.server.schema.SomeSchemaElement;
import org.opends.server.types.Attributes;
import org.opends.server.types.CommonSchemaElements;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
import org.opends.server.types.ExistingFileBehavior;
@@ -67,10 +67,10 @@
import org.opends.server.types.Modification;
import org.opends.server.types.ObjectClass;
import org.opends.server.types.OpenDsException;
import org.opends.server.types.SchemaFileElement;
import org.opends.server.util.LDIFReader;
import org.opends.server.util.LDIFWriter;
import org.opends.server.util.ServerConstants;
import org.opends.server.util.StaticUtils;
/**
 * An abstract class used to re-factor some code between the different tasks
@@ -158,8 +158,8 @@
    }
    else
    {
      final List<String> attrNames = getElementsNameOrOID(attrsToAdd);
      final List<String> ocNames = getElementsNameOrOID(ocsToAdd);
      final List<String> attrNames = getElementsNameOrOID(attributeTypesToSchemaElements(attrsToAdd));
      final List<String> ocNames = getElementsNameOrOID(objectClassesToSchemaElements(ocsToAdd));
      if (ocNames.isEmpty())
      {
        return INFO_CTRL_PANEL_NEW_ATTRIBUTES_TASK_DESCRIPTION.get(joinAsString(", ", attrNames));
@@ -176,10 +176,10 @@
    }
  }
  private <T extends CommonSchemaElements> List<String> getElementsNameOrOID(final Collection<T> schemaElements)
  private List<String> getElementsNameOrOID(final Collection<SomeSchemaElement> schemaElements)
  {
    final List<String> nameOrOIDs = new ArrayList<>();
    for (CommonSchemaElements schemaElement : schemaElements)
    for (SomeSchemaElement schemaElement : schemaElements)
    {
      nameOrOIDs.add(schemaElement.getNameOrOID());
    }
@@ -252,15 +252,15 @@
  private void updateSchemaOffline() throws OpenDsException
  {
    // Group the changes in the same schema file.
    final Map<String, List<AttributeType>> hmAttrs = copy(attrsToAdd);
    final Map<String, List<ObjectClass>> hmOcs = copy(ocsToAdd);
    final Set<String> allFileNames = new LinkedHashSet<>(hmAttrs.keySet());
    allFileNames.addAll(hmOcs.keySet());
    final Map<String, List<SomeSchemaElement>> mapAttrs = copy(attributeTypesToSchemaElements(attrsToAdd));
    final Map<String, List<SomeSchemaElement>> mapClasses = copy(objectClassesToSchemaElements(ocsToAdd));
    final Set<String> allFileNames = new LinkedHashSet<>(mapAttrs.keySet());
    allFileNames.addAll(mapClasses.keySet());
    for (String fileName : allFileNames)
    {
      List<AttributeType> attrs = get(hmAttrs, fileName);
      List<ObjectClass> ocs = get(hmOcs, fileName);
      List<AttributeType> attrs = schemaElementsToAttributeTypes(get(mapAttrs, fileName));
      List<ObjectClass> ocs = schemaElementsToObjectClasses(get(mapClasses, fileName));
      if ("".equals(fileName))
      {
@@ -271,9 +271,9 @@
    }
  }
  private <T extends SchemaFileElement> List<T> get(Map<String, List<T>> hmElems, String fileName)
  private List<SomeSchemaElement> get(Map<String, List<SomeSchemaElement>> hmElems, String fileName)
  {
    List<T> elems = hmElems.get(fileName);
    List<SomeSchemaElement> elems = hmElems.get(fileName);
    if (elems != null)
    {
      return elems;
@@ -281,17 +281,17 @@
    return Collections.emptyList();
  }
  private <T extends SchemaFileElement> Map<String, List<T>> copy(Set<T> elemsToAdd)
  private Map<String, List<SomeSchemaElement>> copy(Set<SomeSchemaElement> elemsToAdd)
  {
    Map<String, List<T>> hmElems = new LinkedHashMap<>();
    for (T elem : elemsToAdd)
    Map<String, List<SomeSchemaElement>> hmElems = new LinkedHashMap<>();
    for (SomeSchemaElement elem : elemsToAdd)
    {
      String fileName = CommonSchemaElements.getSchemaFile(elem);
      String fileName = elem.getSchemaFile();
      if (fileName == null)
      {
        fileName = "";
      }
      List<T> elems = hmElems.get(fileName);
      List<SomeSchemaElement> elems = hmElems.get(fileName);
      if (elems == null)
      {
        elems = new ArrayList<>();
@@ -304,15 +304,17 @@
  private void addAttributeOnline(final AttributeType attribute) throws OpenDsException
  {
    addSchemaElementOnline(attribute, INFO_CTRL_PANEL_CREATING_ATTRIBUTE_PROGRESS.get(attribute.getNameOrOID()));
    addSchemaElementOnline(new SomeSchemaElement(attribute),
        INFO_CTRL_PANEL_CREATING_ATTRIBUTE_PROGRESS.get(attribute.getNameOrOID()));
  }
  private void addObjectClassOnline(final ObjectClass objectClass) throws OpenDsException
  {
    addSchemaElementOnline(objectClass, INFO_CTRL_PANEL_CREATING_OBJECTCLASS_PROGRESS.get(objectClass.getNameOrOID()));
    addSchemaElementOnline(new SomeSchemaElement(objectClass),
        INFO_CTRL_PANEL_CREATING_OBJECTCLASS_PROGRESS.get(objectClass.getNameOrOID()));
  }
  private void addSchemaElementOnline(final CommonSchemaElements schemaElement, final LocalizableMessage progressMsg)
  private void addSchemaElementOnline(final SomeSchemaElement schemaElement, final LocalizableMessage progressMsg)
      throws OpenDsException
  {
    SwingUtilities.invokeLater(new Runnable()
@@ -327,7 +329,7 @@
    });
    try
    {
      final BasicAttribute attr = new BasicAttribute(getAttributeName(schemaElement));
      final BasicAttribute attr = new BasicAttribute(schemaElement.getAttributeName());
      attr.add(getElementDefinition(schemaElement));
      final ModificationItem mod = new ModificationItem(DirContext.ADD_ATTRIBUTE, attr);
      getInfo().getDirContext().modifyAttributes(
@@ -348,35 +350,31 @@
    });
  }
  private String getValueOffline(CommonSchemaElements element)
  private String getValueOffline(SomeSchemaElement element)
  {
    final Map<String, List<String>> props = element.getExtraProperties();
    List<String> previousValues = props.get(ServerConstants.SCHEMA_PROPERTY_FILENAME);
    setExtraProperty(element, ServerConstants.SCHEMA_PROPERTY_FILENAME, null);
    element.setExtraPropertySingleValue(null, ServerConstants.SCHEMA_PROPERTY_FILENAME, null);
    String attributeWithoutFileDefinition = getElementDefinition(element);
    if (previousValues != null && !previousValues.isEmpty())
    {
      element.setExtraProperty(ServerConstants.SCHEMA_PROPERTY_FILENAME, new ArrayList<String>(previousValues));
      element.setExtraPropertyMultipleValues(null,
          ServerConstants.SCHEMA_PROPERTY_FILENAME, new ArrayList<String>(previousValues));
    }
    return attributeWithoutFileDefinition;
  }
  private String getElementDefinition(CommonSchemaElements element)
  private String getElementDefinition(SomeSchemaElement element)
  {
    final List<String> names = new ArrayList<>(element.getNormalizedNames());
    if (element instanceof AttributeType)
    final List<String> names = new ArrayList<>();
    for (final String name : element.getNames())
    {
      return getAttributeTypeDefinition((AttributeType) element, names);
      names.add(StaticUtils.toLowerCase(name));
    }
    else if (element instanceof ObjectClass)
    {
      return getObjectClassDefinition((ObjectClass) element, names);
    }
    else
    {
      throw new IllegalArgumentException("Unsupported schema element: " + element.getClass().getName());
    }
    return element.isAttributeType()
        ? getAttributeTypeDefinition(element.getAttributeType(), names)
        : getObjectClassDefinition(element.getObjectClass(), names);
  }
  private String getAttributeTypeDefinition(final AttributeType attributeType, final List<String> names)
@@ -427,22 +425,22 @@
    appendCollection(buffer, "NAME", names);
    appendDescription(buffer, objectClass.getDescription());
    appendIfTrue(buffer, " OBSOLETE", objectClass.isObsolete());
    appendOIDs(buffer, "SUP", objectClass.getSuperiorClasses());
    appendOIDs(buffer, "SUP", objectClassesToSchemaElements(objectClass.getSuperiorClasses()));
    appendIfNotNull(buffer, " ", objectClass.getObjectClassType());
    appendOIDs(buffer, "MUST", objectClass.getRequiredAttributes());
    appendOIDs(buffer, "MAY", objectClass.getOptionalAttributes());
    appendOIDs(buffer, "MUST", attributeTypesToSchemaElements(objectClass.getRequiredAttributes()));
    appendOIDs(buffer, "MAY", attributeTypesToSchemaElements(objectClass.getOptionalAttributes()));
    appendExtraProperties(buffer, objectClass.getExtraProperties());
    buffer.append(")");
    return buffer.toString();
  }
  private <T extends CommonSchemaElements> void appendOIDs(final StringBuilder buffer, final String label,
      final Collection<T> schemaElements)
  private void appendOIDs(final StringBuilder buffer, final String label,
      final Collection<SomeSchemaElement> schemaElements)
  {
    if (!schemaElements.isEmpty())
    {
      final Iterator<T> iterator = schemaElements.iterator();
      final Iterator<SomeSchemaElement> iterator = schemaElements.iterator();
      final String firstOID = iterator.next().getOID();
      buffer.append(" ").append(label).append(" ( ").append(firstOID);
      while (iterator.hasNext())
@@ -453,6 +451,46 @@
    }
  }
  private Set<SomeSchemaElement> objectClassesToSchemaElements(final Collection<ObjectClass> classes)
  {
    Set<SomeSchemaElement> elements = new HashSet<>();
    for (ObjectClass objectClass : classes)
    {
      elements.add(new SomeSchemaElement(objectClass));
    }
    return elements;
  }
  private Set<SomeSchemaElement> attributeTypesToSchemaElements(final Collection<AttributeType> types)
  {
    Set<SomeSchemaElement> elements = new HashSet<>();
    for (AttributeType type : types)
    {
      elements.add(new SomeSchemaElement(type));
    }
    return elements;
  }
  private List<AttributeType> schemaElementsToAttributeTypes(final Collection<SomeSchemaElement> elements)
  {
    List<AttributeType> types = new ArrayList<>();
    for (SomeSchemaElement element : elements)
    {
      types.add(element.getAttributeType());
    }
    return types;
  }
  private List<ObjectClass> schemaElementsToObjectClasses(final Collection<SomeSchemaElement> elements)
  {
    List<ObjectClass> classes = new ArrayList<>();
    for (SomeSchemaElement element : elements)
    {
      classes.add(element.getObjectClass());
    }
    return classes;
  }
  private void appendIfTrue(final StringBuilder buffer, final String label, final boolean labelIsActive)
  {
    if (labelIsActive)
@@ -513,7 +551,7 @@
    }
  }
  private void printEquivalentCommandLineToAddOnline(CommonSchemaElements element)
  private void printEquivalentCommandLineToAddOnline(SomeSchemaElement element)
  {
    List<String> args = new ArrayList<>();
    args.add("-a");
@@ -521,13 +559,13 @@
    args.add(getNoPropertiesFileArgument());
    final String equivalentCmdLine = getEquivalentCommandLine(getCommandLinePath("ldapmodify"), args);
    final String elementID = element.getNameOrOID();
    final LocalizableMessage msg = element instanceof AttributeType ?
        INFO_CTRL_PANEL_EQUIVALENT_CMD_TO_ADD_ATTRIBUTE_ONLINE.get(elementID)
      : INFO_CTRL_PANEL_EQUIVALENT_CMD_TO_ADD_OBJECTCLASS_ONLINE.get(elementID);
    final StringBuilder sb = new StringBuilder();
    final String attName = getAttributeName(element);
    sb.append(msg).append("<br><b>")
    final String attName = element.getAttributeName();
    final String elementId = element.getNameOrOID();
    final LocalizableMessage message = element.isAttributeType()
        ? INFO_CTRL_PANEL_EQUIVALENT_CMD_TO_ADD_ATTRIBUTE_ONLINE.get(elementId)
        : INFO_CTRL_PANEL_EQUIVALENT_CMD_TO_ADD_OBJECTCLASS_ONLINE.get(elementId);
    sb.append(message).append("<br><b>")
      .append(equivalentCmdLine).append("<br>")
      .append("dn: cn=schema<br>")
      .append("changetype: modify<br>")
@@ -536,16 +574,12 @@
    getProgressDialog().appendProgressHtml(Utilities.applyFont(sb.toString(), ColorAndFontConstants.progressFont));
  }
  private String getAttributeName(CommonSchemaElements element)
  {
    return element instanceof AttributeType ? ConfigConstants.ATTR_ATTRIBUTE_TYPES : ConfigConstants.ATTR_OBJECTCLASSES;
  }
  private void updateSchemaOffline(
      String file, final List<AttributeType> attributes, final List<ObjectClass> objectClasses) throws OpenDsException
  {
    final List<CommonSchemaElements> schemaElements = new ArrayList<CommonSchemaElements>(attributes);
    schemaElements.addAll(objectClasses);
    final List<SomeSchemaElement> schemaElements =
        new ArrayList<SomeSchemaElement>(attributeTypesToSchemaElements(attributes));
    schemaElements.addAll(objectClassesToSchemaElements(objectClasses));
    if (file == null)
    {
      file = ConfigConstants.FILE_USER_SCHEMA_ELEMENTS;
@@ -595,7 +629,7 @@
      updateSchemaUndefinedFile(fileName, schemaElements);
    }
    for (CommonSchemaElements schemaElement : schemaElements)
    for (SomeSchemaElement schemaElement : schemaElements)
    {
      notifyConfigurationElementCreated(schemaElement);
    }
@@ -610,7 +644,7 @@
  }
  private String equivalentCommandToAddOffline(
      String schemaFile, boolean isSchemaFileDefined, List<CommonSchemaElements> schemaElements)
      String schemaFile, boolean isSchemaFileDefined, List<SomeSchemaElement> schemaElements)
  {
    List<String> names = getElementsNameOrOID(schemaElements);
@@ -632,9 +666,9 @@
      }
    }
    for (CommonSchemaElements schemaElement : schemaElements)
    for (SomeSchemaElement schemaElement : schemaElements)
    {
      sb.append(getAttributeName(schemaElement)).append(": ").append(getValueOffline(schemaElement)).append("<br>");
      sb.append(schemaElement.getAttributeName()).append(": ").append(getValueOffline(schemaElement)).append("<br>");
    }
    sb.append("</b><br><br>");
@@ -692,7 +726,7 @@
   * @throws OpenDsException
   *           if an error occurs updating the schema file.
   */
  private void updateSchemaFile(String schemaFile, List<CommonSchemaElements> schemaElements)
  private void updateSchemaFile(String schemaFile, List<SomeSchemaElement> schemaElements)
      throws OpenDsException
  {
    try (final LDIFExportConfig exportConfig = new LDIFExportConfig(schemaFile, ExistingFileBehavior.OVERWRITE))
@@ -714,26 +748,26 @@
    }
  }
  private void addElementsToEntry(List<CommonSchemaElements> schemaElements, Entry schemaEntry)
  private void addElementsToEntry(List<SomeSchemaElement> schemaElements, Entry schemaEntry)
      throws DirectoryException
  {
    for (CommonSchemaElements schemaElement : schemaElements)
    for (SomeSchemaElement schemaElement : schemaElements)
    {
      final Modification mod = new Modification(ModificationType.ADD,
          Attributes.create(getAttributeName(schemaElement).toLowerCase(), getValueOffline(schemaElement)));
          Attributes.create(schemaElement.getAttributeName().toLowerCase(), getValueOffline(schemaElement)));
      schemaEntry.applyModification(mod);
    }
  }
  private void updateSchemaUndefinedFile(String schemaFile, List<CommonSchemaElements> schemaElements)
  private void updateSchemaUndefinedFile(String schemaFile, List<SomeSchemaElement> schemaElements)
      throws OfflineUpdateException
  {
    try (LDIFExportConfig exportConfig = new LDIFExportConfig(schemaFile, ExistingFileBehavior.FAIL))
    {
      List<String> lines = getSchemaEntryLines();
      for (final CommonSchemaElements schemaElement : schemaElements)
      for (final SomeSchemaElement schemaElement : schemaElements)
      {
        lines.add(getAttributeName(schemaElement) + ": " + getValueOffline(schemaElement));
        lines.add(schemaElement.getAttributeName() + ": " + getValueOffline(schemaElement));
      }
      for (String line : lines)
      {
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/AbstractBrowseEntriesPanel.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.guitools.controlpanel.ui;
@@ -105,7 +105,7 @@
import org.opends.quicksetup.ui.CertificateDialog;
import org.opends.quicksetup.util.UIKeyStore;
import org.opends.server.protocols.ldap.LDAPFilter;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.LDAPException;
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/AbstractIndexPanel.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.guitools.controlpanel.ui;
@@ -61,7 +61,7 @@
import org.opends.guitools.controlpanel.util.Utilities;
import org.opends.quicksetup.Installation;
import org.opends.server.config.ConfigException;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.OpenDsException;
/**
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/AbstractVLVIndexPanel.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.guitools.controlpanel.ui;
@@ -89,7 +89,8 @@
import org.opends.quicksetup.Installation;
import org.opends.server.config.ConfigException;
import org.opends.server.protocols.ldap.LDAPFilter;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.schema.SomeSchemaElement;
import org.opends.server.types.FilterType;
import org.opends.server.types.LDAPException;
import org.opends.server.types.OpenDsException;
@@ -327,16 +328,17 @@
        configurationAttrNames.clear();
        customAttrNames.clear();
        for (AttributeType attr : schema.getAttributeTypes().values())
        for (AttributeType attr : schema.getAttributeTypes())
        {
          String name = attr.getPrimaryName();
          SomeSchemaElement element = new SomeSchemaElement(attr);
          String name = attr.getNameOrOID();
          if (!isDefined(name))
          {
            if (Utilities.isStandard(attr))
            if (Utilities.isStandard(element))
            {
              standardAttrNames.add(name);
            }
            else if (Utilities.isConfiguration(attr))
            else if (Utilities.isConfiguration(element))
            {
              configurationAttrNames.add(name);
            }
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/AttributeSyntaxPanel.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.guitools.controlpanel.ui;
@@ -48,7 +48,7 @@
import org.opends.guitools.controlpanel.util.Utilities;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.Schema;
/**
@@ -76,23 +76,27 @@
  }
  /** {@inheritDoc} */
  @Override
  public LocalizableMessage getTitle()
  {
    return INFO_CTRL_PANEL_ATTRIBUTE_SYNTAX_TITLE.get();
  }
  /** {@inheritDoc} */
  @Override
  public Component getPreferredFocusComponent()
  {
    return usedByAttributes;
  }
  /** {@inheritDoc} */
  @Override
  public void configurationChanged(ConfigurationChangeEvent ev)
  {
  }
  /** {@inheritDoc} */
  @Override
  public void okClicked()
  {
  }
@@ -153,6 +157,7 @@
    MouseAdapter clickListener = new MouseAdapter()
    {
      @Override
      public void mouseClicked(MouseEvent ev)
      {
        if (ev.getClickCount() == 1)
@@ -166,6 +171,7 @@
    KeyAdapter keyListener = new KeyAdapter()
    {
      /** {@inheritDoc} */
      @Override
      public void keyTyped(KeyEvent ev)
      {
        if (ev.getKeyChar() == KeyEvent.VK_SPACE ||
@@ -205,7 +211,7 @@
    Comparator<String> lowerCaseComparator = new LowerCaseComparator();
    TreeSet<String> attributes = new TreeSet<>(lowerCaseComparator);
    for (AttributeType attr : schema.getAttributeTypes().values())
    for (AttributeType attr : schema.getAttributeTypes())
    {
      if (syntax == attr.getSyntax())
      {
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/BrowseEntriesPanel.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.guitools.controlpanel.ui;
@@ -87,7 +87,7 @@
import org.opends.guitools.controlpanel.util.LDAPEntryReader;
import org.opends.guitools.controlpanel.util.Utilities;
import org.forgerock.i18n.LocalizableMessage;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.ObjectClass;
import org.opends.server.types.OpenDsException;
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/BrowseSchemaPanel.java
@@ -22,11 +22,12 @@
 *
 *
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.guitools.controlpanel.ui;
import static org.opends.messages.AdminToolMessages.*;
import static org.opends.server.util.StaticUtils.*;
import java.awt.Component;
import java.awt.Dimension;
@@ -43,6 +44,7 @@
import java.util.Collection;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
@@ -74,6 +76,7 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.LocalizableMessageBuilder;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.guitools.controlpanel.browser.IconPool;
@@ -91,8 +94,7 @@
import org.opends.guitools.controlpanel.util.LowerCaseComparator;
import org.opends.guitools.controlpanel.util.Utilities;
import org.opends.guitools.controlpanel.util.ViewPositions;
import org.opends.server.types.AttributeType;
import org.opends.server.types.CommonSchemaElements;
import org.opends.server.schema.SomeSchemaElement;
import org.opends.server.types.ObjectClass;
import org.opends.server.types.Schema;
@@ -134,7 +136,7 @@
  private JPopupMenu popup;
  private CommonSchemaElements lastCreatedElement;
  private SomeSchemaElement lastCreatedElement;
  private final CategoryTreeNode attributes = new CategoryTreeNode(INFO_CTRL_PANEL_ATTRIBUTES_CATEGORY_NODE.get());
  private final CategoryTreeNode objectClasses =
@@ -664,13 +666,14 @@
    {
      if (mustAdd(oc))
      {
        SomeSchemaElement element = new SomeSchemaElement(oc);
        String name = oc.getPrimaryName();
        if (Utilities.isStandard(oc))
        if (Utilities.isStandard(element))
        {
          standardOcNames.add(name);
          hmStandardOcs.put(name, new StandardObjectClassTreeNode(name, oc));
        }
        else if (Utilities.isConfiguration(oc))
        else if (Utilities.isConfiguration(element))
        {
          configurationOcNames.add(name);
          hmConfigurationOcs.put(name, new ConfigurationObjectClassTreeNode(name, oc));
@@ -689,17 +692,18 @@
    Map<String, ConfigurationAttributeTreeNode> hmConfigurationAttrs = new HashMap<>();
    Set<String> customAttrNames = new TreeSet<>(lowerCaseComparator);
    Map<String, CustomAttributeTreeNode> hmCustomAttrs = new HashMap<>();
    for (AttributeType attr : lastSchema.getAttributeTypes().values())
    for (AttributeType attr : lastSchema.getAttributeTypes())
    {
      SomeSchemaElement element = new SomeSchemaElement(attr);
      if (mustAdd(attr))
      {
        String name = attr.getPrimaryName();
        if (Utilities.isStandard(attr))
        String name = attr.getNameOrOID();
        if (Utilities.isStandard(element))
        {
          standardAttrNames.add(name);
          hmStandardAttrs.put(name, new StandardAttributeTreeNode(name, attr));
        }
        else if (Utilities.isConfiguration(attr))
        else if (Utilities.isConfiguration(element))
        {
          configurationAttrNames.add(name);
          hmConfigurationAttrs.put(name, new ConfigurationAttributeTreeNode(name, attr));
@@ -714,7 +718,7 @@
    Set<String> matchingRuleNames = new TreeSet<>(lowerCaseComparator);
    Map<String, MatchingRuleTreeNode> hmMatchingRules = new HashMap<>();
    for (MatchingRule matchingRule : lastSchema.getMatchingRules().values())
    for (MatchingRule matchingRule : lastSchema.getMatchingRules())
    {
      if (mustAdd(matchingRule))
      {
@@ -726,7 +730,7 @@
    Set<String> syntaxNames = new TreeSet<>(lowerCaseComparator);
    Map<String, AttributeSyntaxTreeNode> hmSyntaxes = new HashMap<>();
    for (Syntax syntax : lastSchema.getSyntaxes().values())
    for (Syntax syntax : lastSchema.getSyntaxes())
    {
      if (mustAdd(syntax))
      {
@@ -862,15 +866,7 @@
          {
            if (lastCreatedElement != null)
            {
              if (node instanceof CustomObjectClassTreeNode && lastCreatedElement instanceof ObjectClass)
              {
                if (name.equals(lastCreatedElement.getNameOrOID()))
                {
                  newSelectionPath = new TreePath(node.getPath());
                  lastCreatedElement = null;
                }
              }
              else if (node instanceof CustomAttributeTreeNode && lastCreatedElement instanceof AttributeType
              if (node instanceof CustomObjectClassTreeNode
                  && name.equals(lastCreatedElement.getNameOrOID()))
              {
                newSelectionPath = new TreePath(node.getPath());
@@ -1163,23 +1159,27 @@
  private boolean mustAddAttributeName(AttributeType attr, String attrName)
  {
    return mustAdd(attrName, attr.getOID(), attr.getPrimaryName(), attr.getNormalizedNames());
    return mustAdd(attrName, attr.getOID(), attr.getNameOrOID(), new HashSet<String>(attr.getNames()));
  }
  private boolean mustAddObjectClassName(ObjectClass oc, String ocName)
  {
    return mustAdd(ocName, oc.getOID(), oc.getPrimaryName(), oc.getNormalizedNames());
    return mustAdd(ocName, oc.getOID(), oc.getNameOrOID(), oc.getNormalizedNames());
  }
  private boolean mustAdd(String name, String oid, String primaryName, Set<String> names)
  /** Provided names may not be normalized. */
  private boolean mustAdd(String name, String oid, String primaryNameOrOID, Set<String> names)
  {
    List<String> values = new ArrayList<>(names.size() + 2);
    values.add(oid);
    if (primaryName != null)
    if (!primaryNameOrOID.equals(oid))
    {
      values.add(primaryName);
      values.add(primaryNameOrOID);
    }
    values.addAll(names);
    for (String v : names)
    {
      values.add(toLowerCase(v));
    }
    return matchFilter(values, name, false);
  }
@@ -1459,9 +1459,9 @@
  private void configurationElementCreated(ConfigurationElementCreatedEvent ev)
  {
    Object o = ev.getConfigurationObject();
    if (o instanceof CommonSchemaElements)
    if (o instanceof SomeSchemaElement)
    {
      lastCreatedElement = (CommonSchemaElements) o;
      lastCreatedElement = (SomeSchemaElement) o;
    }
  }
@@ -1596,7 +1596,7 @@
    // Analyze attributes
    for (AttributeType attribute : attrsToDelete)
    {
      for (AttributeType attr : schema.getAttributeTypes().values())
      for (AttributeType attr : schema.getAttributeTypes())
      {
        if (attribute.equals(attr.getSuperiorType()))
        {
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/CustomAttributePanel.java
@@ -22,13 +22,12 @@
 *
 *
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.guitools.controlpanel.ui;
import static org.opends.guitools.controlpanel.util.Utilities.*;
import static org.opends.messages.AdminToolMessages.*;
import static org.opends.server.types.CommonSchemaElements.*;
import static org.opends.server.util.CollectionUtils.*;
import java.awt.Component;
@@ -75,8 +74,10 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.LocalizableMessageBuilder;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeUsage;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.forgerock.opendj.ldap.schema.SchemaBuilder;
import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.guitools.controlpanel.datamodel.ServerDescriptor;
import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent;
@@ -91,7 +92,7 @@
import org.opends.guitools.controlpanel.ui.renderer.SchemaElementComboBoxCellRenderer;
import org.opends.guitools.controlpanel.util.LowerCaseComparator;
import org.opends.guitools.controlpanel.util.Utilities;
import org.opends.server.types.AttributeType;
import org.opends.server.schema.SomeSchemaElement;
import org.opends.server.types.ObjectClass;
import org.opends.server.types.Schema;
import org.opends.server.util.ServerConstants;
@@ -529,11 +530,7 @@
  void update(AttributeType attr, Schema schema)
  {
    ignoreChangeEvents = true;
    String n = attr.getPrimaryName();
    if (n == null)
    {
      n = "";
    }
    String n = attr.getNameOrOID();
    titlePanel.setDetails(LocalizableMessage.raw(n));
    name.setText(n);
@@ -554,14 +551,15 @@
    lastAliases.addAll(someAliases);
    this.aliases.setText(Utilities.getStringFromCollection(someAliases, ", "));
    String sOrigin = Utilities.getOrigin(attr);
    SomeSchemaElement element = new SomeSchemaElement(attr);
    String sOrigin = Utilities.getOrigin(element);
    if (sOrigin == null)
    {
      sOrigin = "";
    }
    origin.setText(sOrigin);
    String sFile = getSchemaFile(attr);
    String sFile = element.getSchemaFile();
    if (sFile == null)
    {
      sFile = "";
@@ -643,9 +641,8 @@
      LowerCaseComparator lowerCase = new LowerCaseComparator();
      Map<String, Syntax> syntaxNameMap = new TreeMap<>(lowerCase);
      for (String key : schema.getSyntaxes().keySet())
      for (Syntax syntax : schema.getSyntaxes())
      {
        Syntax syntax = schema.getSyntax(key);
        String name = syntax.getName();
        if (name == null)
        {
@@ -658,9 +655,8 @@
      updateComboBoxModel(newSyntaxes, (DefaultComboBoxModel) syntax.getModel());
      Map<String, AttributeType> attributeNameMap = new TreeMap<>(lowerCase);
      for (String key : schema.getAttributeTypes().keySet())
      for (AttributeType attr : schema.getAttributeTypes())
      {
        AttributeType attr = schema.getAttributeType(key);
        attributeNameMap.put(attr.getNameOrOID(), attr);
      }
      List<Object> newParents = new ArrayList<>();
@@ -669,17 +665,16 @@
      updateComboBoxModel(newParents, (DefaultComboBoxModel) parent.getModel());
      final Map<String, MatchingRule> matchingRuleNameMap = new TreeMap<>(lowerCase);
      for (String key : schema.getMatchingRules().keySet())
      for (MatchingRule rule : schema.getMatchingRules())
      {
        MatchingRule rule = schema.getMatchingRule(key);
        matchingRuleNameMap.put(rule.getNameOrOID(), rule);
      }
      final List<MatchingRule> availableMatchingRules = new ArrayList<>(matchingRuleNameMap.values());
      JComboBox[] combos = {approximate, equality, ordering, substring};
      for (JComboBox<LocalizableMessage> combo : combos)
      for (JComboBox combo : combos)
      {
        final DefaultComboBoxModel<LocalizableMessage> model = (DefaultComboBoxModel) combo.getModel();
        final DefaultComboBoxModel model = (DefaultComboBoxModel) combo.getModel();
        final List<Object> el = new ArrayList<Object>(availableMatchingRules);
        el.add(0, model.getSize() != 0 ? model.getElementAt(0) : NO_MATCHING_RULE);
        updateComboBoxModel(el, model);
@@ -761,7 +756,7 @@
    TreeSet<String> dependentClasses = new TreeSet<>();
    if (schema != null)
    {
      for (AttributeType attr : schema.getAttributeTypes().values())
      for (AttributeType attr : schema.getAttributeTypes())
      {
        if (attribute.equals(attr.getSuperiorType()))
        {
@@ -1100,20 +1095,24 @@
  private AttributeType getNewAttribute()
  {
    return new AttributeType("", getAttributeName(),
        getAllNames(),
        getOID(),
        getDescription(),
        getSuperior(),
        (Syntax)syntax.getSelectedItem(),
        getMatchingRule(approximate),
        getMatchingRule(equality),
        getMatchingRule(ordering),
        getMatchingRule(substring),
        (AttributeUsage)usage.getSelectedItem(),
        collective.isSelected(), nonModifiable.isSelected(),
        obsolete.isSelected(), singleValued.isSelected(),
        getExtraProperties());
    return new SchemaBuilder().buildAttributeType(getOID())
        .names(getAllNames())
        .description(getDescription())
        .superiorType(getSuperior().getNameOrOID())
        .syntax(((Syntax) syntax.getSelectedItem()).getOID())
        .approximateMatchingRule(getMatchingRule(approximate).getNameOrOID())
        .equalityMatchingRule(getMatchingRule(equality).getNameOrOID())
        .orderingMatchingRule(getMatchingRule(ordering).getNameOrOID())
        .substringMatchingRule(getMatchingRule(substring).getNameOrOID())
        .usage((AttributeUsage)usage.getSelectedItem())
        .collective(collective.isSelected())
        .obsolete(obsolete.isSelected())
        .noUserModification(nonModifiable.isSelected())
        .singleValue(singleValued.isSelected())
        .extraProperties(getExtraProperties())
        .addToSchema()
      .toSchema()
      .getAttributeType(getOID());
  }
  private void updateDefaultMatchingRuleNames()
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/CustomObjectClassPanel.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.guitools.controlpanel.ui;
@@ -69,6 +69,7 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.LocalizableMessageBuilder;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.ldap.schema.ObjectClassType;
import org.opends.guitools.controlpanel.datamodel.ServerDescriptor;
import org.opends.guitools.controlpanel.datamodel.SortableListModel;
@@ -86,7 +87,7 @@
import org.opends.guitools.controlpanel.ui.components.TitlePanel;
import org.opends.guitools.controlpanel.ui.renderer.SchemaElementComboBoxCellRenderer;
import org.opends.guitools.controlpanel.util.Utilities;
import org.opends.server.types.AttributeType;
import org.opends.server.schema.SomeSchemaElement;
import org.opends.server.types.ObjectClass;
import org.opends.server.types.Schema;
import org.opends.server.util.ServerConstants;
@@ -528,7 +529,7 @@
    lastAliases.addAll(aliases);
    this.aliases.setText(Utilities.getStringFromCollection(aliases, ", "));
    String sOrigin = Utilities.getOrigin(oc);
    String sOrigin = Utilities.getOrigin(new SomeSchemaElement(oc));
    if (sOrigin == null)
    {
      sOrigin = "";
@@ -1037,8 +1038,7 @@
        attributes.getSelectedList2()
    };
    attributes.getAvailableListModel().clear();
    Collection<AttributeType> allAttrs =
      schema.getAttributeTypes().values();
    Collection<AttributeType> allAttrs = schema.getAttributeTypes();
    attributes.getAvailableListModel().addAll(allAttrs);
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/IndexPanel.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.guitools.controlpanel.ui;
@@ -73,7 +73,7 @@
import org.opends.server.admin.std.client.BackendIndexCfgClient;
import org.opends.server.admin.std.client.PluggableBackendCfgClient;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.OpenDsException;
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/ManageTasksPanel.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2009-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.guitools.controlpanel.ui;
@@ -65,6 +65,7 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo;
import org.opends.guitools.controlpanel.datamodel.CustomSearchResult;
import org.opends.guitools.controlpanel.datamodel.ServerDescriptor;
@@ -79,7 +80,6 @@
import org.opends.server.tools.tasks.TaskEntry;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeBuilder;
import org.opends.server.types.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
import org.opends.server.types.ObjectClass;
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/MatchingRulePanel.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.guitools.controlpanel.ui;
@@ -32,7 +32,6 @@
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.Comparator;
import java.util.TreeSet;
import javax.swing.DefaultListModel;
@@ -46,7 +45,7 @@
import org.opends.guitools.controlpanel.util.LowerCaseComparator;
import org.opends.guitools.controlpanel.util.Utilities;
import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.Schema;
import static org.opends.messages.AdminToolMessages.*;
@@ -206,7 +205,7 @@
    oid.setText(matchingRule.getOID());
    Syntax s = null;
    String syntaxOID = matchingRule.getSyntax().getOID();
    for (Syntax candidate : schema.getSyntaxes().values())
    for (Syntax candidate : schema.getSyntaxes())
    {
      if (candidate.getOID().equals(syntaxOID))
      {
@@ -230,9 +229,8 @@
    }
    description.setText(n);
    Comparator<String> lowerCaseComparator = new LowerCaseComparator();
    TreeSet<String> attributes = new TreeSet<>(lowerCaseComparator);
    for (AttributeType attr : schema.getAttributeTypes().values())
    TreeSet<String> attributes = new TreeSet<>(new LowerCaseComparator());
    for (AttributeType attr : schema.getAttributeTypes())
    {
      if (matchingRule.equals(attr.getApproximateMatchingRule()) ||
          matchingRule.equals(attr.getEqualityMatchingRule()) ||
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/NewAttributePanel.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.guitools.controlpanel.ui;
@@ -58,6 +58,7 @@
import org.forgerock.i18n.LocalizableMessageBuilder;
import org.forgerock.opendj.ldap.schema.AttributeUsage;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.forgerock.opendj.ldap.schema.SchemaBuilder;
import org.opends.guitools.controlpanel.datamodel.ServerDescriptor;
import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent;
import org.opends.guitools.controlpanel.event.ConfigurationElementCreatedListener;
@@ -69,7 +70,7 @@
import org.opends.guitools.controlpanel.util.Utilities;
import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.config.ConfigConstants;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.ObjectClass;
import org.opends.server.types.Schema;
import org.opends.server.util.ServerConstants;
@@ -189,9 +190,8 @@
      schema = s;
      Map<String, Syntax> syntaxNameMap = new HashMap<>();
      for (String key : schema.getSyntaxes().keySet())
      for (Syntax syntax : schema.getSyntaxes())
      {
        Syntax syntax = schema.getSyntax(key);
        String name = syntax.getName();
        if (name == null)
        {
@@ -209,9 +209,8 @@
      updateComboBoxModel(newSyntaxes, (DefaultComboBoxModel) syntax.getModel());
      Map<String, AttributeType> attributeNameMap = new HashMap<>();
      for (String key : schema.getAttributeTypes().keySet())
      for (AttributeType attr : schema.getAttributeTypes())
      {
        AttributeType attr = schema.getAttributeType(key);
        attributeNameMap.put(attr.getNameOrOID(), attr);
      }
      orderedKeys.clear();
@@ -226,9 +225,8 @@
      final List<MatchingRule> availableMatchingRules = new ArrayList<>();
      final Map<String, MatchingRule> matchingRuleNameMap = new HashMap<>();
      for (String key : schema.getMatchingRules().keySet())
      for (MatchingRule rule : schema.getMatchingRules())
      {
        MatchingRule rule = schema.getMatchingRule(key);
        matchingRuleNameMap.put(rule.getNameOrOID(), rule);
      }
@@ -240,9 +238,9 @@
      }
      final JComboBox[] combos = { approximate, equality, ordering, substring };
      for (int i = 0; i < combos.length; i++)
      for (JComboBox combo : combos)
      {
        final DefaultComboBoxModel model = (DefaultComboBoxModel) combos[i].getModel();
        final DefaultComboBoxModel model = (DefaultComboBoxModel) combo.getModel();
        final List<Object> el = new ArrayList<Object>(availableMatchingRules);
        el.add(0, model.getSize() == 0 ? NO_MATCHING_RULE : model.getElementAt(0));
        updateComboBoxModel(el, model);
@@ -438,7 +436,7 @@
  static LocalizableMessage getSchemaElementType(String name, Schema schema)
  {
    final String lowerCase = name.toLowerCase();
    if (schema.getAttributeType(lowerCase) != null)
    if (schema.hasAttributeType(lowerCase))
    {
      return INFO_CTRL_PANEL_TYPE_ATTRIBUTE.get();
    }
@@ -455,7 +453,7 @@
      return INFO_CTRL_PANEL_TYPE_MATCHING_RULE.get();
    }
    for (Syntax attr : schema.getSyntaxes().values())
    for (Syntax attr : schema.getSyntaxes())
    {
      if (name.equalsIgnoreCase(attr.getName()))
      {
@@ -463,7 +461,7 @@
      }
    }
    for (MatchingRule rule : schema.getMatchingRules().values())
    for (MatchingRule rule : schema.getMatchingRules())
    {
      String n = rule.getNameOrOID();
      if (n != null && n.equalsIgnoreCase(name))
@@ -726,22 +724,23 @@
  private AttributeType getAttribute()
  {
    return new AttributeType("",
                             getAttributeName(),
                             getAllNames(),
                             getOID(),
                             getDescription(),
                             getSuperior(),
                             (Syntax) syntax.getSelectedItem(),
                             getApproximateMatchingRule(),
                             getEqualityMatchingRule(),
                             getOrderingMatchingRule(),
                             getSubstringMatchingRule(),
                             (AttributeUsage) usage.getSelectedItem(),
                             collective.isSelected(),
                             nonModifiable.isSelected(),
                             obsolete.isSelected(),
                             singleValued.isSelected(),
                             getExtraProperties());
    return new SchemaBuilder().buildAttributeType(getOID())
      .names(getAllNames())
      .description(getDescription())
      .superiorType(getSuperior().getNameOrOID())
      .syntax(((Syntax) syntax.getSelectedItem()).getOID())
      .approximateMatchingRule(getApproximateMatchingRule().getOID())
      .equalityMatchingRule(getEqualityMatchingRule().getOID())
      .orderingMatchingRule(getOrderingMatchingRule().getOID())
      .substringMatchingRule(getSubstringMatchingRule().getOID())
      .usage((AttributeUsage)usage.getSelectedItem())
      .collective(collective.isSelected())
      .obsolete(obsolete.isSelected())
      .noUserModification(nonModifiable.isSelected())
      .singleValue(singleValued.isSelected())
      .extraProperties(getExtraProperties())
      .addToSchema()
      .toSchema()
      .getAttributeType(getOID());
  }
}
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/NewIndexPanel.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.guitools.controlpanel.ui;
@@ -66,7 +66,8 @@
import org.opends.server.admin.std.client.PluggableBackendCfgClient;
import org.opends.server.admin.std.meta.BackendIndexCfgDefn;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.schema.SomeSchemaElement;
import org.opends.server.types.DN;
import org.opends.server.types.OpenDsException;
import org.opends.server.types.Schema;
@@ -141,16 +142,17 @@
      TreeSet<String> standardAttrNames = new TreeSet<>();
      TreeSet<String> configurationAttrNames = new TreeSet<>();
      TreeSet<String> customAttrNames = new TreeSet<>();
      for (AttributeType attr : schema.getAttributeTypes().values())
      for (AttributeType attr : schema.getAttributeTypes())
      {
        String name = attr.getPrimaryName();
        SomeSchemaElement element = new SomeSchemaElement(attr);
        String name = attr.getNameOrOID();
        if (!indexExists(backend, name))
        {
          if (Utilities.isStandard(attr))
          if (Utilities.isStandard(element))
          {
            standardAttrNames.add(name);
          }
          else if (Utilities.isConfiguration(attr))
          else if (Utilities.isConfiguration(element))
          {
            configurationAttrNames.add(name);
          }
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/NewObjectClassPanel.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.guitools.controlpanel.ui;
@@ -73,7 +73,7 @@
import org.opends.guitools.controlpanel.ui.renderer.SchemaElementComboBoxCellRenderer;
import org.opends.guitools.controlpanel.util.Utilities;
import org.opends.server.config.ConfigConstants;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.ObjectClass;
import org.opends.server.types.Schema;
import org.opends.server.util.ServerConstants;
@@ -364,8 +364,7 @@
        attributes.getSelectedList2()
    };
    attributes.getAvailableListModel().clear();
    Collection<AttributeType> allAttrs =
      schema.getAttributeTypes().values();
    Collection<AttributeType> allAttrs = schema.getAttributeTypes();
    attributes.getAvailableListModel().addAll(allAttrs);
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/SchemaBrowserRightPanel.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.guitools.controlpanel.ui;
@@ -44,7 +44,7 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.schema.Syntax;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.ObjectClass;
import org.opends.server.types.Schema;
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/SchemaElementPanel.java
@@ -22,10 +22,12 @@
 *
 *
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2015 ForgeRock AS.
 *      Portions Copyright 2015-2016 ForgeRock AS.
 */
package org.opends.guitools.controlpanel.ui;
import static org.opends.server.util.StaticUtils.*;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Set;
@@ -34,9 +36,9 @@
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.guitools.controlpanel.event.SchemaElementSelectionEvent;
import org.opends.guitools.controlpanel.event.SchemaElementSelectionListener;
import org.opends.server.types.AttributeType;
import org.opends.server.types.ObjectClass;
import org.opends.server.types.Schema;
@@ -139,7 +141,7 @@
   */
  protected Set<String> getAliases(AttributeType attr)
  {
    return getAliases(attr.getNormalizedNames(), attr.getPrimaryName());
    return getAliases(attr.getNames(), toLowerCase(attr.getNameOrOID()));
  }
  /**
@@ -152,7 +154,7 @@
    return getAliases(oc.getNormalizedNames(), oc.getPrimaryName());
  }
  private Set<String> getAliases(Set<String> names, String primaryName)
  private Set<String> getAliases(Iterable<String> names, String primaryName)
  {
    Set<String> aliases = new LinkedHashSet<>();
    if (primaryName == null)
@@ -163,7 +165,7 @@
    {
      if (!name.equalsIgnoreCase(primaryName))
      {
        aliases.add(name);
        aliases.add(toLowerCase(name));
      }
    }
    return aliases;
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/SimplifiedViewEntryPanel.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2015 ForgeRock AS.
 *      Portions Copyright 2013-2016 ForgeRock AS.
 */
package org.opends.guitools.controlpanel.ui;
@@ -92,6 +92,7 @@
import org.opends.guitools.controlpanel.ui.nodes.DndBrowserNodes;
import org.opends.guitools.controlpanel.util.Utilities;
import org.opends.server.schema.SchemaConstants;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import org.opends.server.util.Base64;
import org.opends.server.util.LDIFReader;
@@ -1180,9 +1181,9 @@
    Schema schema = getInfo().getServerDescriptor().getSchema();
    if (schema != null)
    {
      AttributeType attr = schema.getAttributeType(attrName.toLowerCase());
      if (attr != null)
      if (schema.hasAttributeType(attrName.toLowerCase()))
      {
        AttributeType attr = schema.getAttributeType(attrName.toLowerCase());
        isSingleValue = attr.isSingleValue();
      }
    }
@@ -1199,9 +1200,9 @@
    Schema schema = getInfo().getServerDescriptor().getSchema();
    if (schema != null)
    {
      AttributeType attr = schema.getAttributeType(attrName.toLowerCase());
      if (attr != null)
      if (schema.hasAttributeType(attrName.toLowerCase()))
      {
        AttributeType attr = schema.getAttributeType(attrName.toLowerCase());
        List<Object> ocs = sr.getAttributeValues(
            ServerConstants.OBJECTCLASS_ATTRIBUTE_TYPE_NAME);
        for (Object o : ocs)
@@ -1445,9 +1446,9 @@
      Schema schema = getInfo().getServerDescriptor().getSchema();
      if (schema != null)
      {
        AttributeType attr = schema.getAttributeType(attrName.toLowerCase());
        if (attr != null)
        if (schema.hasAttributeType(attrName.toLowerCase()))
        {
          AttributeType attr = schema.getAttributeType(attrName.toLowerCase());
          // There is no name for a regex syntax.
          String syntaxName = attr.getSyntax().getName();
          if (syntaxName!=null) {
@@ -1553,10 +1554,9 @@
                {
                  String aName =
                    Utilities.getAttributeNameWithoutOptions(attrName);
                  AttributeType attr =
                    schema.getAttributeType(aName.toLowerCase());
                  if (attr != null)
                  if (schema.hasAttributeType(aName.toLowerCase()))
                  {
                    AttributeType attr = schema.getAttributeType(aName.toLowerCase());
                    attributeTypes.add(attr);
                    attributeNames.add(attrName);
                    attributeValues.add(ByteString.valueOfUtf8((String) o));
@@ -1845,7 +1845,6 @@
      this.attrName = attrName;
    }
    @Override
    public void actionPerformed(ActionEvent ev)
    {
      addBrowseClicked(attrName, tc);
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/StandardAttributePanel.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.guitools.controlpanel.ui;
@@ -52,7 +52,8 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.LocalizableMessageBuilder;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.schema.SomeSchemaElement;
import org.opends.server.types.ObjectClass;
import org.opends.server.types.Schema;
@@ -246,11 +247,7 @@
   */
  public void update(AttributeType attr, Schema schema)
  {
    String n = attr.getPrimaryName();
    if (n == null)
    {
      n = NOT_APPLICABLE.toString();
    }
    String n = attr.getNameOrOID();
    titlePanel.setDetails(LocalizableMessage.raw(n));
    name.setText(n);
    AttributeType superior = attr.getSuperiorType();
@@ -260,15 +257,11 @@
    }
    else
    {
      n = superior.getPrimaryName();
    }
    if (n == null)
    {
      n = NOT_APPLICABLE.toString();
      n = superior.getNameOrOID();
    }
    parent.setText(n);
    oid.setText(attr.getOID());
    origin.setText(StandardObjectClassPanel.getOrigin(attr).toString());
    origin.setText(StandardObjectClassPanel.getOrigin(new SomeSchemaElement(attr)).toString());
    n = attr.getDescription();
    if (n == null)
    {
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/StandardObjectClassPanel.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.guitools.controlpanel.ui;
@@ -55,13 +55,11 @@
import org.opends.guitools.controlpanel.util.Utilities;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.LocalizableMessageBuilder;
import org.opends.server.types.AttributeType;
import org.opends.server.types.CommonSchemaElements;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.schema.SomeSchemaElement;
import org.opends.server.types.ObjectClass;
import org.opends.server.types.Schema;
import static org.opends.server.types.CommonSchemaElements.*;
/**
 * The panel that displays a standard object class definition.
 *
@@ -261,10 +259,10 @@
   * @param element the schema element.
   * @return the message describing the schema element origin (file, RFC, etc.).
   */
  static LocalizableMessage getOrigin(CommonSchemaElements element)
  static LocalizableMessage getOrigin(SomeSchemaElement element)
  {
    LocalizableMessageBuilder returnValue = new LocalizableMessageBuilder();
    String fileName = getSchemaFile(element);
    String fileName = element.getSchemaFile();
    String xOrigin = Utilities.getOrigin(element);
    if (xOrigin != null)
    {
@@ -309,7 +307,7 @@
    name.setText(n);
    parent.setText(getSuperiorText(oc));
    oid.setText(oc.getOID());
    origin.setText(getOrigin(oc).toString());
    origin.setText(getOrigin(new SomeSchemaElement(oc)).toString());
    n = oc.getDescription();
    if (n == null)
    {
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/TableViewEntryPanel.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.guitools.controlpanel.ui;
@@ -64,6 +64,7 @@
import org.opends.guitools.controlpanel.util.Utilities;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import org.opends.server.util.LDIFReader;
import org.opends.server.util.ServerConstants;
@@ -335,10 +336,9 @@
              {
                String aName =
                  Utilities.getAttributeNameWithoutOptions(attrName);
                AttributeType attr =
                  schema.getAttributeType(aName.toLowerCase());
                if (attr != null)
                if (schema.hasAttributeType(aName.toLowerCase()))
                {
                  AttributeType attr = schema.getAttributeType(aName.toLowerCase());
                  attributeTypes.add(attr);
                  attributeNames.add(attrName);
                  attributeValues.add(ByteString.valueOfUtf8((String) o));
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/ViewEntryPanel.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.guitools.controlpanel.ui;
@@ -57,7 +57,7 @@
import org.opends.guitools.controlpanel.ui.nodes.BasicNode;
import org.opends.guitools.controlpanel.util.Utilities;
import org.opends.server.schema.SchemaConstants;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.Attributes;
import org.opends.server.types.Entry;
import org.opends.server.types.ObjectClass;
@@ -357,7 +357,7 @@
    {
      schemaReadOnlyAttributes.clear();
      schemaReadOnlyAttributesLowerCase.clear();
      for (AttributeType attr : schema.getAttributeTypes().values())
      for (AttributeType attr : schema.getAttributeTypes())
      {
        if (attr.isNoUserModification())
        {
@@ -487,10 +487,10 @@
    // Check all the attributes that we consider binaries.
    if (schema != null)
    {
      AttributeType attr = schema.getAttributeType(
          Utilities.getAttributeNameWithoutOptions(attrName).toLowerCase());
      if (attr != null)
      String attributeName = Utilities.getAttributeNameWithoutOptions(attrName).toLowerCase();
      if (schema.hasAttributeType(attributeName))
      {
        AttributeType attr = schema.getAttributeType(attributeName);
        Syntax syntax = attr.getSyntax();
        if (syntax != null)
        {
@@ -574,9 +574,9 @@
    attrName = Utilities.getAttributeNameWithoutOptions(attrName);
    if (schema != null)
    {
      AttributeType attrType = schema.getAttributeType(attrName.toLowerCase());
      if (attrType != null)
      if (schema.hasAttributeType(attrName.toLowerCase()))
      {
        AttributeType attrType = schema.getAttributeType(attrName.toLowerCase());
        isEditable = !attrType.isNoUserModification();
      }
    }
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/nodes/ConfigurationAttributeTreeNode.java
@@ -22,17 +22,13 @@
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Portions copyright 2015-2016 ForgeRock AS
 */
package org.opends.guitools.controlpanel.ui.nodes;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
/**
 * Class of the nodes that represent a configuration attribute in the 'Manage
 * Schema' tree.
 *
 */
/** Class of the nodes that represent a configuration attribute in the 'Manage Schema' tree. */
public class ConfigurationAttributeTreeNode extends SchemaElementTreeNode
{
  private static final long serialVersionUID = 428949987639862400L;
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/nodes/CustomAttributeTreeNode.java
@@ -22,17 +22,13 @@
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Portions copyright 2015-2016 ForgeRock AS
 */
package org.opends.guitools.controlpanel.ui.nodes;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
/**
 * Class of the nodes that represent a custom attribute in the 'Manage
 * Schema' tree.
 *
 */
/** Class of the nodes that represent a custom attribute in the 'Manage Schema' tree. */
public class CustomAttributeTreeNode extends SchemaElementTreeNode
{
  private static final long serialVersionUID = -9198486156950262507L;
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/nodes/StandardAttributeTreeNode.java
@@ -22,17 +22,13 @@
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Portions copyright 2015-2016 ForgeRock AS
 */
package org.opends.guitools.controlpanel.ui.nodes;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
/**
 * Class of the nodes that represent a standard attribute in the 'Manage
 * Schema' tree.
 *
 */
/** Class of the nodes that represent a standard attribute in the 'Manage Schema' tree. */
public class StandardAttributeTreeNode extends SchemaElementTreeNode
{
  private static final long serialVersionUID = -3439217150360205524L;
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/ReadOnlyConfigFileHandler.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.guitools.controlpanel.util;
@@ -48,7 +48,7 @@
import org.opends.server.core.ModifyOperation;
import org.opends.server.core.SearchOperation;
import org.opends.server.core.ServerContext;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.BackupConfig;
import org.opends.server.types.BackupDirectory;
import org.opends.server.types.CanceledOperationException;
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/RemoteSchemaLoader.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2009-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2015 ForgeRock AS
 *      Portions Copyright 2013-2016 ForgeRock AS
 */
package org.opends.guitools.controlpanel.util;
@@ -38,7 +38,6 @@
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ByteStringBuilder;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.forgerock.opendj.ldap.schema.MatchingRuleImpl;
import org.forgerock.opendj.ldap.schema.SchemaBuilder;
@@ -50,14 +49,11 @@
import org.opends.server.core.ServerContext;
import org.opends.server.replication.plugin.HistoricalCsnOrderingMatchingRuleImpl;
import org.opends.server.schema.AciSyntax;
import org.opends.server.schema.AttributeTypeSyntax;
import org.opends.server.schema.LDAPSyntaxDescriptionSyntax;
import org.opends.server.schema.ObjectClassSyntax;
import org.opends.server.schema.SchemaConstants;
import org.opends.server.schema.SubtreeSpecificationSyntax;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.InitializationException;
import org.opends.server.types.LDAPSyntaxDescription;
import org.opends.server.types.Schema;
/** Class used to retrieve the schema from the schema files. */
@@ -133,11 +129,12 @@
    for (AttributeSyntax<?> syntax : syntaxes)
    {
      final ServerContext serverContext = DirectoryServer.getInstance().getServerContext();
      if (!serverContext.getSchemaNG().hasSyntax(syntax.getOID()))
      final org.forgerock.opendj.ldap.schema.Schema schemaNG = serverContext.getSchemaNG();
      if (!schemaNG.hasSyntax(syntax.getOID()))
      {
        syntax.initializeSyntax(null, serverContext);
      }
      schema.registerSyntax(syntax.getSDKSyntax(serverContext.getSchemaNG()), true);
      schema.registerSyntax(syntax.getSDKSyntax(schemaNG), true);
    }
  }
@@ -145,14 +142,15 @@
      final MatchingRuleImpl impl)
      throws InitializationException, ConfigException, DirectoryException
  {
    final org.forgerock.opendj.ldap.schema.Schema schemaNG = schema.getSchemaNG();
    final MatchingRule matchingRule;
    if (CoreSchema.getInstance().hasMatchingRule(name))
    if (schemaNG.hasMatchingRule(name))
    {
      matchingRule = CoreSchema.getInstance().getMatchingRule(name);
      matchingRule = schemaNG.getMatchingRule(name);
    }
    else
    {
      matchingRule = new SchemaBuilder(CoreSchema.getInstance()).buildMatchingRule(oid)
      matchingRule = new SchemaBuilder(schemaNG).buildMatchingRule(oid)
                                                                .names(name)
                                                                .syntaxOID(syntaxOID)
                                                                .implementation(impl)
@@ -183,7 +181,7 @@
          switch (schemaAttr)
          {
          case ConfigConstants.ATTR_ATTRIBUTE_TYPES_LC:
            schema.registerAttributeType(AttributeTypeSyntax.decodeAttributeType(sb, schema, false), true);
            schema.registerAttributeType(sb.toString(), null, true);
            break;
          case ConfigConstants.ATTR_OBJECTCLASSES_LC:
            schema.registerObjectClass(ObjectClassSyntax.decodeObjectClass(sb, schema, false), true);
@@ -214,9 +212,7 @@
      {
        try
        {
          final LDAPSyntaxDescription syntaxDesc = LDAPSyntaxDescriptionSyntax.decodeLDAPSyntax(
              sb, DirectoryServer.getInstance().getServerContext(), schema, false, false);
          schema.registerLdapSyntaxDescription(syntaxDesc, true);
          schema.registerLdapSyntaxDescription(sb.toString(), true);
        }
        catch (DirectoryException e)
        {
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/SchemaLoader.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2015 ForgeRock AS.
 *      Portions Copyright 2013-2016 ForgeRock AS.
 */
package org.opends.guitools.controlpanel.util;
@@ -42,7 +42,7 @@
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.SchemaConfigManager;
import org.opends.server.schema.SchemaConstants;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.InitializationException;
import org.opends.server.types.ObjectClass;
@@ -84,14 +84,13 @@
    }
    for (String name : ATTRIBUTES_TO_KEEP)
    {
      AttributeType attr = sc.getAttributeType(name.toLowerCase());
      if (attr != null)
      if (sc.hasAttributeType(name))
      {
        attributesToKeep.add(attr);
        attributesToKeep.add(sc.getAttributeType(name));
      }
    }
    matchingRulesToKeep.addAll(sc.getMatchingRules().values());
    syntaxesToKeep.addAll(sc.getSyntaxes().values());
    matchingRulesToKeep.addAll(sc.getMatchingRules());
    syntaxesToKeep.addAll(sc.getSyntaxes());
  }
  private static String getSchemaDirectoryPath()
@@ -176,8 +175,7 @@
    //  initialize the server schema.
    for (String schemaFile : fileNames)
    {
      // no server context to pass
      SchemaConfigManager.loadSchemaFile(null, schema, schemaFile);
      SchemaConfigManager.loadSchemaFile(schema, schemaFile);
    }
  }
@@ -191,7 +189,8 @@
   */
  protected Schema getBaseSchema() throws DirectoryException
  {
    Schema schema = new Schema();
    // start from default schema
    Schema schema = new Schema(org.forgerock.opendj.ldap.schema.Schema.getDefaultSchema());
    for (MatchingRule mr : matchingRulesToKeep)
    {
      schema.registerMatchingRule(mr, true);
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/Utilities.java
@@ -22,15 +22,13 @@
 *
 *
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.guitools.controlpanel.util;
import static org.opends.admin.ads.util.ConnectionUtils.*;
import static org.opends.messages.AdminToolMessages.*;
import static org.opends.quicksetup.Installation.*;
import static org.opends.server.types.CommonSchemaElements.*;
import static com.forgerock.opendj.cli.Utils.*;
import static com.forgerock.opendj.util.OperatingSystem.*;
@@ -129,13 +127,12 @@
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.LockFileManager;
import org.opends.server.schema.SchemaConstants;
import org.opends.server.types.AttributeType;
import org.opends.server.types.CommonSchemaElements;
import org.opends.server.schema.SomeSchemaElement;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.OpenDsException;
import org.opends.server.types.RDN;
import org.opends.server.types.Schema;
import org.opends.server.types.SchemaFileElement;
import org.opends.server.util.ServerConstants;
import org.opends.server.util.StaticUtils;
@@ -2039,20 +2036,17 @@
   * @return <CODE>true</CODE> if the provided schema element is part of the
   * standard and <CODE>false</CODE> otherwise.
   */
  public static boolean isStandard(SchemaFileElement fileElement)
  public static boolean isStandard(SomeSchemaElement fileElement)
  {
    final String fileName = getSchemaFile(fileElement);
    final String fileName = fileElement.getSchemaFile();
    if (fileName != null)
    {
      return contains(standardSchemaFileNames, fileName) || fileName.toLowerCase().contains("-rfc");
    }
    else if (fileElement instanceof CommonSchemaElements)
    String xOrigin = getOrigin(fileElement);
    if (xOrigin != null)
    {
      String xOrigin = getOrigin(fileElement);
      if (xOrigin != null)
      {
        return contains(standardSchemaOrigins, xOrigin) || xOrigin.startsWith("RFC ") || xOrigin.startsWith("draft-");
      }
      return contains(standardSchemaOrigins, xOrigin) || xOrigin.startsWith("RFC ") || xOrigin.startsWith("draft-");
    }
    return false;
  }
@@ -2064,20 +2058,17 @@
   * @return <CODE>true</CODE> if the provided schema element is part of the
   * configuration and <CODE>false</CODE> otherwise.
   */
  public static boolean isConfiguration(SchemaFileElement fileElement)
  public static boolean isConfiguration(SomeSchemaElement fileElement)
  {
    String fileName = getSchemaFile(fileElement);
    String fileName = fileElement.getSchemaFile();
    if (fileName != null)
    {
      return contains(configurationSchemaFileNames, fileName);
    }
    else if (fileElement instanceof CommonSchemaElements)
    String xOrigin = getOrigin(fileElement);
    if (xOrigin != null)
    {
      String xOrigin = getOrigin(fileElement);
      if (xOrigin != null)
      {
        return contains(configurationSchemaOrigins, xOrigin);
      }
      return contains(configurationSchemaOrigins, xOrigin);
    }
    return false;
  }
@@ -2099,10 +2090,9 @@
   * @param element the schema element.
   * @return the origin of the provided schema element.
   */
  public static String getOrigin(SchemaFileElement element)
  public static String getOrigin(SomeSchemaElement element)
  {
    return CommonSchemaElements.getSingleValueProperty(
        element, ServerConstants.SCHEMA_PROPERTY_ORIGIN);
    return element.getOrigin();
  }
  /**
@@ -2131,20 +2121,17 @@
   */
  public static boolean hasImageSyntax(String attrName, Schema schema)
  {
    attrName = Utilities.getAttributeNameWithoutOptions(attrName).toLowerCase();
    attrName = Utilities.getAttributeNameWithoutOptions(attrName);
    if ("photo".equals(attrName))
    {
      return true;
    }
    // Check all the attributes that we consider binaries.
    if (schema != null)
    if (schema != null && schema.hasAttributeType(attrName))
    {
      AttributeType attr = schema.getAttributeType(attrName);
      if (attr != null)
      {
        String syntaxOID = attr.getSyntax().getOID();
        return SchemaConstants.SYNTAX_JPEG_OID.equals(syntaxOID);
      }
      String syntaxOID = attr.getSyntax().getOID();
      return SchemaConstants.SYNTAX_JPEG_OID.equals(syntaxOID);
    }
    return false;
  }
@@ -2181,9 +2168,9 @@
    if (schema != null)
    {
      attrName = Utilities.getAttributeNameWithoutOptions(attrName).toLowerCase();
      AttributeType attr = schema.getAttributeType(attrName);
      if (attr != null)
      if (schema.hasAttributeType(attrName))
      {
        AttributeType attr = schema.getAttributeType(attrName);
        return contains(oids, attr.getSyntax().getOID());
      }
    }
opendj-server-legacy/src/main/java/org/opends/server/admin/AdministrationDataSync.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2012-2015 ForgeRock AS
 *      Portions Copyright 2012-2016 ForgeRock AS
 */
package org.opends.server.admin;
@@ -42,7 +42,7 @@
import org.opends.server.protocols.internal.Requests;
import org.opends.server.protocols.internal.SearchRequest;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.Attributes;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
opendj-server-legacy/src/main/java/org/opends/server/admin/AttributeTypePropertyDefinition.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.admin;
@@ -31,7 +31,7 @@
import java.util.EnumSet;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
/** Attribute type property definition. */
public final class AttributeTypePropertyDefinition extends
opendj-server-legacy/src/main/java/org/opends/server/admin/ManagedObjectPath.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.admin;
@@ -37,6 +37,7 @@
import org.opends.server.admin.std.meta.RootCfgDefn;
import org.opends.server.admin.std.server.RootCfg;
import org.opends.server.core.DirectoryServer;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
/**
opendj-server-legacy/src/main/java/org/opends/server/admin/PropertyValueVisitor.java
@@ -22,20 +22,17 @@
 *
 *
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 *      Portions copyright 2015-2016 ForgeRock AS
 */
package org.opends.server.admin;
import java.net.InetAddress;
import org.forgerock.opendj.ldap.AddressMask;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.authorization.dseecompat.Aci;
/**
 * A visitor of property values, in the style of the visitor design
 * pattern. Classes implementing this interface can query a property a
opendj-server-legacy/src/main/java/org/opends/server/admin/server/ServerManagementContext.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2009 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.admin.server;
@@ -75,7 +75,7 @@
import org.opends.server.config.ConfigEntry;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DN;
/**
opendj-server-legacy/src/main/java/org/opends/server/api/AttributeSyntax.java
@@ -22,32 +22,31 @@
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2012-2015 ForgeRock AS.
 *      Portions Copyright 2012-2016 ForgeRock AS.
 */
package org.opends.server.api;
import org.forgerock.i18n.LocalizableMessage;
import java.util.List;
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.opends.server.core.ServerContext;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.LocalizableMessageBuilder;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.types.InitializationException;
import org.opends.server.util.RemoveOnceSDKSchemaIsUsed;
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.forgerock.opendj.ldap.schema.Schema;
import org.forgerock.opendj.ldap.schema.Syntax;
import org.forgerock.i18n.LocalizableMessageBuilder;
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.opends.server.core.ServerContext;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.InitializationException;
import org.opends.server.util.RemoveOnceSDKSchemaIsUsed;
/**
 * This class defines the set of methods and structures that must be
 * implemented by a Directory Server module that implements an
 * attribute syntax.
 *
 * @param  <T>  The type of configuration handled by this attribute
 *              syntax.
 * @param  <T>  The type of configuration handled by this attribute syntax.
 */
@org.opends.server.types.PublicAPI(
     stability=org.opends.server.types.StabilityLevel.VOLATILE,
@@ -58,25 +57,22 @@
public abstract class AttributeSyntax<T extends AttributeSyntaxCfg>
{
  /**
   * Initializes this attribute syntax based on the information in the
   * provided configuration entry.
   * Initializes this attribute syntax based on the information in the provided configuration entry.
   *
   * @param  configuration  The configuration to use to initialize
   *                        this attribute syntax.
   * @param configuration
   *          The configuration to use to initialize this attribute syntax.
   * @param serverContext
   *            The server context.
   *
   * @throws  ConfigException  If an unrecoverable problem arises in
   *                           the process of performing the
   *                           initialization.
   *
   * @throws  InitializationException  If a problem occurs during
   *                                   initialization that is not
   *                                   related to the server
   *                                   configuration.
   *          The server context.
   * @throws ConfigException
   *           If an unrecoverable problem arises in the process of performing the initialization.
   * @throws DirectoryException
   *           If an unrecoverable problem arises in the process of performing the initialization.
   * @throws InitializationException
   *           If a problem occurs during initialization that is not related to the server
   *           configuration.
   */
  public void initializeSyntax(T configuration, ServerContext serverContext)
         throws ConfigException, InitializationException
      throws ConfigException, DirectoryException, InitializationException
  {
    // not implemented
  }
opendj-server-legacy/src/main/java/org/opends/server/api/AuthenticationPolicy.java
@@ -21,7 +21,7 @@
 * CDDL HEADER END
 *
 *
 *      Portions Copyright 2011-2015 ForgeRock AS.
 *      Portions Copyright 2011-2016 ForgeRock AS.
 *      Portions Copyright 2014 ForgeRock AS
 */
package org.opends.server.api;
@@ -35,6 +35,7 @@
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.core.DirectoryServer;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.util.TimeThread;
opendj-server-legacy/src/main/java/org/opends/server/api/AuthenticationPolicyState.java
@@ -21,7 +21,7 @@
 * CDDL HEADER END
 *
 *
 *      Portions Copyright 2011-2015 ForgeRock AS.
 *      Portions Copyright 2011-2016 ForgeRock AS.
 *      Portions Copyright 2014 ForgeRock AS
 */
package org.opends.server.api;
@@ -34,9 +34,9 @@
import org.forgerock.opendj.ldap.ConditionResult;
import org.forgerock.opendj.ldap.GeneralizedTime;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
opendj-server-legacy/src/main/java/org/opends/server/api/Backend.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.api;
@@ -55,7 +55,7 @@
import org.opends.server.core.SearchOperation;
import org.opends.server.core.ServerContext;
import org.opends.server.monitors.BackendMonitor;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.BackupConfig;
import org.opends.server.types.BackupDirectory;
import org.opends.server.types.CanceledOperationException;
opendj-server-legacy/src/main/java/org/opends/server/api/ClientConnection.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.api;
@@ -48,7 +48,7 @@
import org.opends.server.core.PluginConfigManager;
import org.opends.server.core.SearchOperation;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.AuthenticationInfo;
import org.opends.server.types.CancelRequest;
import org.opends.server.types.CancelResult;
opendj-server-legacy/src/main/java/org/opends/server/api/CompressedSchema.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2009 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2015 ForgeRock AS.
 *      Portions Copyright 2013-2016 ForgeRock AS.
 */
package org.opends.server.api;
@@ -41,18 +41,25 @@
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import net.jcip.annotations.GuardedBy;
import org.forgerock.opendj.ldap.ByteSequenceReader;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ByteStringBuilder;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.ldap.schema.Schema;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.ServerContext;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeBuilder;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.Attributes;
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.ByteSequenceReader;
import org.forgerock.opendj.ldap.ByteStringBuilder;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.ObjectClass;
import org.opends.server.util.RemoveOnceSDKSchemaIsUsed;
/**
 * This class provides a utility for interacting with compressed representations
@@ -66,14 +73,128 @@
    mayInvoke = false)
public class CompressedSchema
{
  /** Maps attribute description to ID. */
  private final List<Entry<AttributeType, Set<String>>> adDecodeMap = new CopyOnWriteArrayList<>();
  /** Maps ID to attribute description. */
  private final Map<Entry<AttributeType, Set<String>>, Integer> adEncodeMap = new ConcurrentHashMap<>();
  /** The map between encoded representations and object class sets. */
  private final List<Map<ObjectClass, String>> ocDecodeMap = new CopyOnWriteArrayList<>();
  /** The map between object class sets and encoded representations. */
  private final Map<Map<ObjectClass, String>, Integer> ocEncodeMap = new ConcurrentHashMap<>();
  /** Encloses all the encode and decode mappings for attribute and object classes. */
  private static final class Mappings
  {
    /** Maps encoded representation's ID to its attribute description (the List's index is the ID). */
    private final List<Entry<AttributeType, Set<String>>> adDecodeMap = new CopyOnWriteArrayList<>();
    /** Maps attribute description to its encoded representation's ID. */
    private final Map<Entry<AttributeType, Set<String>>, Integer> adEncodeMap;
    /** Maps encoded representation's ID to its object class (the List's index is the ID). */
    private final List<Map<ObjectClass, String>> ocDecodeMap = new CopyOnWriteArrayList<>();
    /** Maps object class to its encoded representation's ID. */
    private final Map<Map<ObjectClass, String>, Integer> ocEncodeMap;
    private Mappings()
    {
      this.adEncodeMap = new ConcurrentHashMap<>();
      this.ocEncodeMap = new ConcurrentHashMap<>();
    }
    private Mappings(int adEncodeMapSize, int ocEncodeMapSize)
    {
      this.adEncodeMap = new ConcurrentHashMap<>(adEncodeMapSize);
      this.ocEncodeMap = new ConcurrentHashMap<>(ocEncodeMapSize);
    }
  }
  private final ServerContext serverContext;
  /** Lock to update the maps. */
  final ReadWriteLock lock = new ReentrantReadWriteLock();
  private final Lock exclusiveLock = lock.writeLock();
  private final Lock sharedLock = lock.readLock();
  /** Schema used to build the compressed information. */
  @GuardedBy("lock")
  private Schema schemaNG;
  @GuardedBy("lock")
  private Mappings mappings = new Mappings();
  /**
   * Creates a new empty instance of this compressed schema.
   *
   * @param serverContext
   *            The server context.
   */
  public CompressedSchema(ServerContext serverContext)
  {
    this.serverContext = serverContext;
  }
  private Mappings getMappings()
  {
    sharedLock.lock();
    try
    {
      return mappings;
    }
    finally
    {
      sharedLock.unlock();
    }
  }
  private Mappings reloadMappingsIfSchemaChanged(boolean force)
  {
    // @RemoveOnceSDKSchemaIsUsed remove the "force" parameter
    sharedLock.lock();
    boolean shared = true;
    try
    {
      Schema currentSchema = serverContext.getSchemaNG();
      if (force || schemaNG != currentSchema)
      {
        sharedLock.unlock();
        exclusiveLock.lock();
        shared = false;
        currentSchema = serverContext.getSchemaNG();
        if (force || schemaNG != currentSchema)
        {
          // build new maps from existing ones
          Mappings newMappings = new Mappings(mappings.adEncodeMap.size(), mappings.ocEncodeMap.size());
          reloadAttributeTypeMaps(mappings, newMappings);
          reloadObjectClassesMap(mappings, newMappings);
          mappings = newMappings;
          schemaNG = currentSchema;
        }
      }
      return mappings;
    }
    finally
    {
      (shared ? sharedLock : exclusiveLock).unlock();
    }
  }
  /**
   * Reload the attribute types maps. This should be called when schema has changed, because some
   * types may be out dated.
   */
  private void reloadAttributeTypeMaps(Mappings mappings, Mappings newMappings)
  {
    for (Entry<Entry<AttributeType, Set<String>>, Integer> entry : mappings.adEncodeMap.entrySet())
    {
      Entry<AttributeType, Set<String>> ad = entry.getKey();
      Integer id = entry.getValue();
      loadAttributeToMaps(id, ad.getKey().getNameOrOID(), ad.getValue(), newMappings);
    }
  }
  /**
   * Reload the object classes maps. This should be called when schema has changed, because some
   * classes may be out dated.
   */
  private void reloadObjectClassesMap(Mappings mappings, Mappings newMappings)
  {
    for (Entry<Map<ObjectClass, String>, Integer> entry : mappings.ocEncodeMap.entrySet())
    {
      Map<ObjectClass, String> ocMap = entry.getKey();
      Integer id = entry.getValue();
      loadObjectClassesToMaps(id, ocMap.values(), newMappings, false);
    }
  }
  /**
   * Decodes the contents of the provided array as an attribute at the current
@@ -89,40 +210,27 @@
      throws DirectoryException
  {
    // First decode the encoded attribute description id.
    final int length = reader.readBERLength();
    final byte[] idBytes = new byte[length];
    reader.readBytes(idBytes);
    final int id = decodeId(idBytes);
    final int id = decodeId(reader);
    // Look up the attribute description.
    Entry<AttributeType, Set<String>> ad = adDecodeMap.get(id);
    // Before returning the attribute, make sure that the attribute type is not stale.
    final Mappings mappings = reloadMappingsIfSchemaChanged(false);
    final Entry<AttributeType, Set<String>> ad = mappings.adDecodeMap.get(id);
    if (ad == null)
    {
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
          ERR_COMPRESSEDSCHEMA_UNRECOGNIZED_AD_TOKEN.get(id));
    }
    // Before returning the attribute, make sure that the attribute type is not
    // stale.
    AttributeType attrType = ad.getKey();
    Set<String> options = ad.getValue();
    if (attrType.isDirty())
    {
      ad = loadAttribute(idBytes, attrType.getNameOrOID(), options);
      attrType = ad.getKey();
      options = ad.getValue();
    }
    // Determine the number of values for the attribute.
    final int numValues = reader.readBERLength();
    // For the common case of a single value with no options, generate
    // less garbage.
    // For the common case of a single value with no options, generate less garbage.
    if (numValues == 1 && options.isEmpty())
    {
      final int valueLength = reader.readBERLength();
      final ByteSequence valueBytes = reader.readByteSequence(valueLength);
      return Attributes.create(attrType, valueBytes.toByteString());
      return Attributes.create(attrType, readValue(reader));
    }
    else
    {
@@ -131,15 +239,16 @@
      builder.setOptions(options);
      for (int i = 0; i < numValues; i++)
      {
        final int valueLength = reader.readBERLength();
        final ByteSequence valueBytes = reader.readByteSequence(valueLength);
        builder.add(valueBytes.toByteString());
        builder.add(readValue(reader));
      }
      return builder.toAttribute();
    }
  }
  private ByteString readValue(final ByteSequenceReader reader)
  {
    return reader.readByteSequence(reader.readBERLength()).toByteString();
  }
  /**
   * Decodes an object class set from the provided byte string.
@@ -155,35 +264,44 @@
      final ByteSequenceReader reader) throws DirectoryException
  {
    // First decode the encoded object class id.
    final int length = reader.readBERLength();
    final byte[] idBytes = new byte[length];
    reader.readBytes(idBytes);
    final int id = decodeId(idBytes);
    final int id = decodeId(reader);
    // Look up the object classes.
    final Map<ObjectClass, String> ocMap = ocDecodeMap.get(id);
    if (ocMap != null)
    final Mappings mappings = getMappings();
    Map<ObjectClass, String> ocMap = mappings.ocDecodeMap.get(id);
    if (ocMap == null)
    {
      // Before returning the object classes, make sure that none of them are
      // stale.
      for (final ObjectClass oc : ocMap.keySet())
      {
        if (oc.isDirty())
        {
          // Found at least one object class which is dirty so refresh them.
          return loadObjectClasses(idBytes, ocMap.values());
        }
      }
      return ocMap;
    }
    else
    {
      // @RemoveOnceSDKSchemaIsUsed remove this first check (check is performed again later)
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
          ERR_COMPRESSEDSCHEMA_UNKNOWN_OC_TOKEN.get(id));
    }
    // Before returning the object classes, make sure that none of them are stale.
    boolean forceReload = isAnyObjectClassDirty(ocMap.keySet());
    final Mappings newMappings = reloadMappingsIfSchemaChanged(forceReload);
    if (mappings != newMappings)
    {
      ocMap = newMappings.ocDecodeMap.get(id);
      if (ocMap == null)
      {
        throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
            ERR_COMPRESSEDSCHEMA_UNKNOWN_OC_TOKEN.get(id));
      }
    }
    return ocMap;
  }
  @RemoveOnceSDKSchemaIsUsed
  private boolean isAnyObjectClassDirty(Set<ObjectClass> objectClasses)
  {
    for (final ObjectClass oc : objectClasses)
    {
      if (oc.isDirty())
      {
        return true;
      }
    }
    return false;
  }
  /**
   * Encodes the information in the provided attribute to a byte array.
@@ -202,24 +320,7 @@
    // Re-use or allocate a new ID.
    final AttributeType type = attribute.getAttributeType();
    final Set<String> options = attribute.getOptions();
    final Entry<AttributeType, Set<String>> ad = new SimpleImmutableEntry<>(type, options);
    // Use double checked locking to avoid lazy registration races.
    Integer id = adEncodeMap.get(ad);
    if (id == null)
    {
      synchronized (adEncodeMap)
      {
        id = adEncodeMap.get(ad);
        if (id == null)
        {
          id = adDecodeMap.size();
          adDecodeMap.add(ad);
          adEncodeMap.put(ad, id);
          storeAttribute(encodeId(id), type.getNameOrOID(), options);
        }
      }
    }
    int id = getAttributeId(new SimpleImmutableEntry<>(type, options));
    // Encode the attribute.
    final byte[] idBytes = encodeId(id);
@@ -233,7 +334,38 @@
    }
  }
  private int getAttributeId(final Entry<AttributeType, Set<String>> ad) throws DirectoryException
  {
    // avoid lazy registration races
    boolean shared = true;
    sharedLock.lock();
    try
    {
      Integer id = mappings.adEncodeMap.get(ad);
      if (id != null)
      {
        return id;
      }
      sharedLock.unlock();
      exclusiveLock.lock();
      shared = false;
      id = mappings.adEncodeMap.get(ad);
      if (id == null)
      {
        id = mappings.adDecodeMap.size();
        mappings.adDecodeMap.add(ad);
        mappings.adEncodeMap.put(ad, id);
        storeAttribute(encodeId(id), ad.getKey().getNameOrOID(), ad.getValue());
      }
      return id;
    }
    finally
    {
      (shared ? sharedLock : exclusiveLock).unlock();
    }
  }
  /**
   * Encodes the provided set of object classes to a byte array. If the same set
@@ -253,22 +385,7 @@
      final Map<ObjectClass, String> objectClasses) throws DirectoryException
  {
    // Re-use or allocate a new ID.
    // Use double checked locking to avoid lazy registration races.
    Integer id = ocEncodeMap.get(objectClasses);
    if (id == null)
    {
      synchronized (ocEncodeMap)
      {
        id = ocEncodeMap.get(objectClasses);
        if (id == null)
        {
          id = ocDecodeMap.size();
          ocDecodeMap.add(objectClasses);
          ocEncodeMap.put(objectClasses, id);
          storeObjectClasses(encodeId(id), objectClasses.values());
        }
      }
    }
    int id = getObjectClassId(objectClasses);
    // Encode the object classes.
    final byte[] idBytes = encodeId(id);
@@ -276,31 +393,58 @@
    builder.appendBytes(idBytes);
  }
  private int getObjectClassId(final Map<ObjectClass, String> objectClasses) throws DirectoryException
  {
    // avoid lazy registration races
    boolean shared = true;
    sharedLock.lock();
    try
    {
      Integer id = mappings.ocEncodeMap.get(objectClasses);
      if (id != null)
      {
        return id;
      }
      sharedLock.unlock();
      exclusiveLock.lock();
      shared = false;
      id = mappings.ocEncodeMap.get(objectClasses);
      if (id == null)
      {
        id = mappings.ocDecodeMap.size();
        mappings.ocDecodeMap.add(objectClasses);
        mappings.ocEncodeMap.put(objectClasses, id);
        storeObjectClasses(encodeId(id), objectClasses.values());
      }
      return id;
    }
    finally
    {
      (shared ? sharedLock : exclusiveLock).unlock();
    }
  }
  /**
   * Returns a view of the encoded attributes in this compressed schema which
   * can be used for saving the entire content to disk. The iterator returned by
   * this method is not thread safe.
   * Returns a view of the encoded attributes in this compressed schema which can be used for saving
   * the entire content to disk.
   * <p>
   * The iterator returned by this method is not thread safe.
   *
   * @return A view of the encoded attributes in this compressed schema.
   */
  protected final Iterable<Entry<byte[],
                                 Entry<String,
                                       Collection<String>>>> getAllAttributes()
  protected final Iterable<Entry<byte[], Entry<String, Collection<String>>>> getAllAttributes()
  {
    return new Iterable<Entry<byte[], Entry<String, Collection<String>>>>()
    {
      @Override
      public Iterator<Entry<byte[],
                            Entry<String, Collection<String>>>> iterator()
      public Iterator<Entry<byte[], Entry<String, Collection<String>>>> iterator()
      {
        return new Iterator<Entry<byte[], Entry<String, Collection<String>>>>()
        {
          private int id = 0;
          private int id;
          private List<Entry<AttributeType, Set<String>>> adDecodeMap = getMappings().adDecodeMap;
          @Override
          public boolean hasNext()
@@ -308,8 +452,6 @@
            return id < adDecodeMap.size();
          }
          @Override
          public Entry<byte[], Entry<String, Collection<String>>> next()
          {
@@ -322,8 +464,6 @@
                    .getKey().getNameOrOID(), ad.getValue()));
          }
          @Override
          public void remove()
          {
@@ -334,27 +474,25 @@
    };
  }
  /**
   * Returns a view of the encoded object classes in this compressed schema
   * which can be used for saving the entire content to disk. The iterator
   * returned by this method is not thread safe.
   * Returns a view of the encoded object classes in this compressed schema which can be used for
   * saving the entire content to disk.
   * <p>
   * The iterator returned by this method is not thread safe.
   *
   * @return A view of the encoded object classes in this compressed schema.
   */
  protected final Iterable<Entry<byte[],
                                 Collection<String>>> getAllObjectClasses()
  protected final Iterable<Entry<byte[], Collection<String>>> getAllObjectClasses()
  {
    return new Iterable<Entry<byte[], Collection<String>>>()
    {
      @Override
      public Iterator<Entry<byte[], Collection<String>>> iterator()
      {
        return new Iterator<Map.Entry<byte[], Collection<String>>>()
        {
          private int id = 0;
          private int id;
          private final List<Map<ObjectClass, String>> ocDecodeMap = getMappings().ocDecodeMap;
          @Override
          public boolean hasNext()
@@ -397,28 +535,52 @@
      final byte[] encodedAttribute, final String attributeName,
      final Collection<String> attributeOptions)
  {
    final AttributeType type = DirectoryServer.getAttributeTypeOrDefault(toLowerCase(attributeName));
    final int id = decodeId(encodedAttribute);
    return loadAttributeToMaps(id, attributeName, attributeOptions, getMappings());
  }
  /**
   * Loads an attribute into provided encode and decode maps, given its id, name, and options.
   *
   * @param id
   *          the id computed on the attribute.
   * @param attributeName
   *          The user provided attribute type name.
   * @param attributeOptions
   *          The non-null but possibly empty set of attribute options.
   * @param mappings
   *          attribute description encodeMap and decodeMap maps id to entry
   * @return The attribute type description.
   */
  private Entry<AttributeType, Set<String>> loadAttributeToMaps(final int id, final String attributeName,
      final Collection<String> attributeOptions, final Mappings mappings)
  {
    final AttributeType type = DirectoryServer.getAttributeTypeOrDefault(attributeName);
    final Set<String> options = getOptions(attributeOptions);
    final Entry<AttributeType, Set<String>> ad = new SimpleImmutableEntry<>(type, options);
    final int id = decodeId(encodedAttribute);
    synchronized (adEncodeMap)
    exclusiveLock.lock();
    try
    {
      adEncodeMap.put(ad, id);
      if (id < adDecodeMap.size())
      mappings.adEncodeMap.put(ad, id);
      if (id < mappings.adDecodeMap.size())
      {
        adDecodeMap.set(id, ad);
        mappings.adDecodeMap.set(id, ad);
      }
      else
      {
        // Grow the decode array.
        while (id > adDecodeMap.size())
        while (id > mappings.adDecodeMap.size())
        {
          adDecodeMap.add(null);
          mappings.adDecodeMap.add(null);
        }
        adDecodeMap.add(ad);
        mappings.adDecodeMap.add(ad);
      }
      return ad;
    }
    return ad;
    finally
    {
      exclusiveLock.unlock();
    }
  }
  private Set<String> getOptions(final Collection<String> attributeOptions)
@@ -449,6 +611,29 @@
      final byte[] encodedObjectClasses,
      final Collection<String> objectClassNames)
  {
    final int id = decodeId(encodedObjectClasses);
    return loadObjectClassesToMaps(id, objectClassNames, mappings, true);
  }
  /**
   * Loads a set of object classes into provided encode and decode maps, given the id and set of
   * names.
   *
   * @param id
   *          the id computed on the object classes set.
   * @param objectClassNames
   *          The user provided set of object class names.
   * @param mappings
   *          .ocEncodeMap maps id to entry
   * @param mappings
   *          .ocDecodeMap maps entry to id
   * @param sync
   *          indicates if update of maps should be synchronized
   * @return The object class set.
   */
  private final Map<ObjectClass, String> loadObjectClassesToMaps(int id, final Collection<String> objectClassNames,
      Mappings mappings, boolean sync)
  {
    final LinkedHashMap<ObjectClass, String> ocMap = new LinkedHashMap<>(objectClassNames.size());
    for (final String name : objectClassNames)
    {
@@ -456,28 +641,42 @@
      final ObjectClass oc = DirectoryServer.getObjectClass(lowerName, true);
      ocMap.put(oc, name);
    }
    final int id = decodeId(encodedObjectClasses);
    synchronized (ocEncodeMap)
    if (sync)
    {
      ocEncodeMap.put(ocMap, id);
      if (id < ocDecodeMap.size())
      exclusiveLock.lock();
      try
      {
        ocDecodeMap.set(id, ocMap);
        updateObjectClassesMaps(id, mappings, ocMap);
      }
      else
      finally
      {
        // Grow the decode array.
        while (id > ocDecodeMap.size())
        {
          ocDecodeMap.add(null);
        }
        ocDecodeMap.add(ocMap);
        exclusiveLock.unlock();
      }
    }
    else
    {
      updateObjectClassesMaps(id, mappings, ocMap);
    }
    return ocMap;
  }
  private void updateObjectClassesMaps(int id, Mappings mappings, LinkedHashMap<ObjectClass, String> ocMap)
  {
    mappings.ocEncodeMap.put(ocMap, id);
    if (id < mappings.ocDecodeMap.size())
    {
      mappings.ocDecodeMap.set(id, ocMap);
    }
    else
    {
      // Grow the decode array.
      while (id > mappings.ocDecodeMap.size())
      {
        mappings.ocDecodeMap.add(null);
      }
      mappings.ocDecodeMap.add(ocMap);
    }
  }
  /**
   * Persists the provided encoded attribute. The default implementation is to
@@ -502,8 +701,6 @@
    // Do nothing by default.
  }
  /**
   * Persists the provided encoded object classes. The default implementation is
   * to do nothing. Calls to this method are synchronized, so implementations
@@ -524,8 +721,6 @@
    // Do nothing by default.
  }
  /**
   * Decodes the provided encoded schema element ID.
   *
@@ -544,7 +739,13 @@
    return id - 1; // Subtract 1 to compensate for old behavior.
  }
  private int decodeId(final ByteSequenceReader reader)
  {
    final int length = reader.readBERLength();
    final byte[] idBytes = new byte[length];
    reader.readBytes(idBytes);
    return decodeId(idBytes);
  }
  /**
   * Encodes the provided schema element ID.
opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/AciContainer.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.authorization.dseecompat;
@@ -43,6 +43,7 @@
import org.opends.server.core.AddOperation;
import org.opends.server.core.SearchOperation;
import org.opends.server.protocols.ldap.LDAPClientConnection;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
/**
opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/AciEffectiveRights.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.authorization.dseecompat;
@@ -33,9 +33,9 @@
import java.util.Set;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.Attributes;
import org.opends.server.types.Entry;
@@ -640,9 +640,7 @@
    //Check if the aclRightsInfo attribute was requested.
    if(hasAttrMask(mask,ACL_RIGHTS_INFO)) {
      //Build the attribute type.
      String typeStr=
              aclRightsInfoAttrLogsStr + ";" + rightStr + ";" +
              aType.getPrimaryName();
      String typeStr = aclRightsInfoAttrLogsStr + ";" + rightStr + ";" + aType.getNameOrOID();
      AttributeType attributeType = DirectoryServer.getAttributeTypeOrDefault(typeStr);
      Attribute attr = Attributes.create(attributeType, container.getEvalSummary());
      // The attribute type might have already been added, probably
@@ -751,7 +749,7 @@
    String attrStr="NULL";
    if(aType != null)
    {
      attrStr=aType.getPrimaryName();
      attrStr = aType.getNameOrOID();
    }
    if(evalCtx.getTargAttrFiltersAciName() != null)
    {
opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/AciEvalContext.java
@@ -22,13 +22,13 @@
 *
 *
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.authorization.dseecompat;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.api.Group;
import java.net.InetAddress;
opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/AciHandler.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 *      Portions Copyright 2013 Manuel Gaupp
 */
package org.opends.server.authorization.dseecompat;
@@ -53,6 +53,7 @@
import org.opends.server.protocols.internal.InternalSearchOperation;
import org.opends.server.protocols.internal.SearchRequest;
import org.opends.server.protocols.ldap.LDAPControl;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import org.opends.server.workflowelement.localbackend.*;
opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/AciListenerManager.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.authorization.dseecompat;
@@ -44,6 +44,7 @@
import org.opends.server.protocols.internal.InternalSearchOperation;
import org.opends.server.protocols.internal.SearchRequest;
import org.opends.server.protocols.ldap.LDAPControl;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import org.opends.server.types.operation.*;
import org.opends.server.workflowelement.localbackend.LocalBackendSearchOperation;
opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/AciTargetMatchContext.java
@@ -22,11 +22,11 @@
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.authorization.dseecompat;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.Entry;
import java.util.List;
opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/AciTargets.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2015 ForgeRock AS
 *      Portions Copyright 2013-2016 ForgeRock AS
 */
package org.opends.server.authorization.dseecompat;
@@ -33,7 +33,7 @@
import java.util.regex.Pattern;
import org.forgerock.i18n.LocalizableMessage;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DN;
import org.forgerock.opendj.ldap.SearchScope;
opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/GroupDN.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2015 ForgeRock AS
 *      Portions Copyright 2013-2016 ForgeRock AS
 */
package org.opends.server.authorization.dseecompat;
@@ -39,6 +39,7 @@
import org.opends.server.api.Group;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.GroupManager;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
/**
opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/ParentInheritance.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.authorization.dseecompat;
@@ -36,7 +36,7 @@
import java.util.regex.Matcher;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.LDAPURL;
import org.opends.server.types.DirectoryException;
opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/PatternRDN.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.authorization.dseecompat;
@@ -42,6 +42,7 @@
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.core.DirectoryServer;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
/**
opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/TargAttrFilterList.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2015 ForgeRock AS
 *      Portions Copyright 2013-2016 ForgeRock AS
 */
package org.opends.server.authorization.dseecompat;
@@ -35,7 +35,7 @@
import org.forgerock.i18n.LocalizableMessage;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.SearchFilter;
opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/TargAttrFilters.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2015 ForgeRock AS
 *      Portions Copyright 2013-2016 ForgeRock AS
 */
package org.opends.server.authorization.dseecompat;
@@ -36,6 +36,7 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
/**
opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/TargetAttr.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Portions Copyright 2012-2015 ForgeRock AS
 *      Portions Copyright 2012-2016 ForgeRock AS
 */
package org.opends.server.authorization.dseecompat;
@@ -34,7 +34,7 @@
import org.forgerock.i18n.LocalizableMessage;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
/**
 * A class representing an ACI's targetattr keyword.
opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/UserAttr.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.authorization.dseecompat;
@@ -35,6 +35,7 @@
import org.opends.server.core.DirectoryServer;
import org.opends.server.protocols.internal.InternalSearchOperation;
import org.opends.server.protocols.internal.SearchRequest;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import static org.opends.messages.AccessControlMessages.*;
opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/UserDN.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2015 ForgeRock AS
 *      Portions Copyright 2013-2016 ForgeRock AS
 */
package org.opends.server.authorization.dseecompat;
@@ -34,6 +34,7 @@
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.SearchScope;
import org.opends.server.core.DirectoryServer;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import static org.opends.messages.AccessControlMessages.*;
@@ -424,4 +425,4 @@
        }
    }
}
}
opendj-server-legacy/src/main/java/org/opends/server/backends/BackupBackend.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.backends;
@@ -56,6 +56,7 @@
import org.opends.server.core.SearchOperation;
import org.opends.server.core.ServerContext;
import org.opends.server.schema.GeneralizedTimeSyntax;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
/**
opendj-server-legacy/src/main/java/org/opends/server/backends/ChangelogBackend.java
@@ -21,7 +21,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2014-2015 ForgeRock AS.
 *      Copyright 2014-2016 ForgeRock AS.
 */
package org.opends.server.backends;
@@ -93,7 +93,7 @@
import org.opends.server.replication.server.changelog.file.ECLMultiDomainDBCursor;
import org.opends.server.replication.server.changelog.file.MultiDomainDBCursor;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.Attributes;
import org.opends.server.types.BackupConfig;
import org.opends.server.types.BackupDirectory;
@@ -814,7 +814,7 @@
  {
    return filter.getFilterType() == filterType
           && filter.getAttributeType() != null
           && filter.getAttributeType().getPrimaryName().equalsIgnoreCase(primaryName);
           && filter.getAttributeType().getNameOrOID().equalsIgnoreCase(primaryName);
  }
  /** Search the changelog when a cookie control is provided. */
opendj-server-legacy/src/main/java/org/opends/server/backends/LDIFBackend.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2007-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.backends;
@@ -48,6 +48,7 @@
import org.opends.server.api.Backend;
import org.opends.server.controls.SubtreeDeleteControl;
import org.opends.server.core.*;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import org.opends.server.util.LDIFException;
import org.opends.server.util.LDIFReader;
opendj-server-legacy/src/main/java/org/opends/server/backends/MemoryBackend.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.backends;
@@ -54,7 +54,7 @@
import org.opends.server.core.ModifyOperation;
import org.opends.server.core.SearchOperation;
import org.opends.server.core.ServerContext;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.BackupConfig;
import org.opends.server.types.BackupDirectory;
import org.opends.server.types.Control;
opendj-server-legacy/src/main/java/org/opends/server/backends/MonitorBackend.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2012-2015 ForgeRock AS.
 *      Portions Copyright 2012-2016 ForgeRock AS.
 */
package org.opends.server.backends;
@@ -51,6 +51,7 @@
import org.opends.server.api.MonitorProvider;
import org.opends.server.config.ConfigEntry;
import org.opends.server.core.*;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import org.opends.server.util.DynamicConstants;
import org.opends.server.util.LDIFWriter;
opendj-server-legacy/src/main/java/org/opends/server/backends/NullBackend.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.backends;
@@ -52,7 +52,7 @@
import org.opends.server.core.ModifyOperation;
import org.opends.server.core.SearchOperation;
import org.opends.server.core.ServerContext;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.BackupConfig;
import org.opends.server.types.BackupDirectory;
import org.opends.server.types.DN;
opendj-server-legacy/src/main/java/org/opends/server/backends/RootDSEBackend.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.backends;
@@ -68,6 +68,7 @@
import org.opends.server.core.ModifyOperation;
import org.opends.server.core.SearchOperation;
import org.opends.server.core.ServerContext;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import org.opends.server.util.BuildVersion;
import org.opends.server.util.LDIFWriter;
opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.backends;
@@ -68,10 +68,10 @@
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.forgerock.opendj.ldap.schema.ObjectClassType;
import org.forgerock.opendj.ldap.schema.SchemaBuilder;
import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.server.SchemaBackendCfg;
@@ -92,11 +92,10 @@
import org.opends.server.schema.DITContentRuleSyntax;
import org.opends.server.schema.DITStructureRuleSyntax;
import org.opends.server.schema.GeneralizedTimeSyntax;
import org.opends.server.schema.LDAPSyntaxDescriptionSyntax;
import org.opends.server.schema.MatchingRuleUseSyntax;
import org.opends.server.schema.NameFormSyntax;
import org.opends.server.schema.ObjectClassSyntax;
import org.opends.server.schema.SchemaUpdater;
import org.opends.server.schema.SomeSchemaElement;
import org.opends.server.types.*;
import org.opends.server.util.BackupManager;
import org.opends.server.util.DynamicConstants;
@@ -565,14 +564,14 @@
     * Add the schema definition attributes.
     */
    Schema schema = DirectoryServer.getSchema();
    buildSchemaAttribute(schema.getAttributeTypes().values(), userAttrs,
    buildSchemaAttribute(schema.getAttributeTypes(), userAttrs,
        operationalAttrs, attributeTypesType, includeSchemaFile,
        AttributeTypeSyntax.isStripSyntaxMinimumUpperBound(),
        ignoreShowAllOption);
    buildSchemaAttribute(schema.getObjectClasses().values(), userAttrs,
        operationalAttrs, objectClassesType, includeSchemaFile, false,
        ignoreShowAllOption);
    buildSchemaAttribute(schema.getMatchingRules().values(), userAttrs,
    buildSchemaAttribute(schema.getMatchingRules(), userAttrs,
        operationalAttrs, matchingRulesType, includeSchemaFile, false,
        ignoreShowAllOption);
@@ -584,7 +583,7 @@
     * updates to fail. This means that you'll always have to explicitly request
     * these attributes in order to be able to see them.
     */
    buildSchemaAttribute(schema.getSyntaxes().values(), userAttrs,
    buildSchemaAttribute(schema.getSyntaxes(), userAttrs,
        operationalAttrs, ldapSyntaxesType, includeSchemaFile, false, true);
    buildSchemaAttribute(schema.getNameFormsByNameOrOID().values(), userAttrs,
        operationalAttrs, nameFormsType, includeSchemaFile, false, true);
@@ -775,22 +774,8 @@
          {
            for (ByteString v : a)
            {
              AttributeType type;
              try
              {
                type = AttributeTypeSyntax.decodeAttributeType(v, newSchema, false);
              }
              catch (DirectoryException de)
              {
                logger.traceException(de);
                LocalizableMessage message = ERR_SCHEMA_MODIFY_CANNOT_DECODE_ATTRTYPE.get(
                    v, de.getMessageObject());
                throw new DirectoryException(
                    ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, de);
              }
              addAttributeType(type, newSchema, modifiedSchemaFiles);
              AttributeType attributeType = newSchema.parseAttributeType(v.toString());
              addAttributeType(attributeType, newSchema, modifiedSchemaFiles);
            }
          }
          else if (at.equals(objectClassesType))
@@ -907,10 +892,9 @@
          {
            for (ByteString v : a)
            {
              LDAPSyntaxDescription lsd;
              try
              {
                lsd = LDAPSyntaxDescriptionSyntax.decodeLDAPSyntax(v, serverContext, newSchema, false, false);
                addLdapSyntaxDescription(v.toString(), newSchema, modifiedSchemaFiles);
              }
              catch (DirectoryException de)
              {
@@ -921,7 +905,6 @@
                throw new DirectoryException(
                    ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, de);
              }
              addLdapSyntaxDescription(lsd, newSchema, modifiedSchemaFiles);
            }
          }
          else
@@ -948,23 +931,8 @@
          {
            for (ByteString v : a)
            {
              AttributeType type;
              try
              {
                type = AttributeTypeSyntax.decodeAttributeType(v, newSchema, false);
              }
              catch (DirectoryException de)
              {
                logger.traceException(de);
                LocalizableMessage message = ERR_SCHEMA_MODIFY_CANNOT_DECODE_ATTRTYPE.get(
                    v, de.getMessageObject());
                throw new DirectoryException(
                    ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, de);
              }
              removeAttributeType(type, newSchema, mods, pos,
                  modifiedSchemaFiles);
              AttributeType type = newSchema.parseAttributeType(v.toString());
              removeAttributeType(type, newSchema, modifiedSchemaFiles);
            }
          }
          else if (at.equals(objectClassesType))
@@ -1082,10 +1050,9 @@
          {
            for (ByteString v : a)
            {
              LDAPSyntaxDescription lsd;
              try
              {
                lsd = LDAPSyntaxDescriptionSyntax.decodeLDAPSyntax(v, serverContext, newSchema, false, true);
                removeLdapSyntaxDescription(v.toString(), newSchema, modifiedSchemaFiles);
              }
              catch (DirectoryException de)
              {
@@ -1097,7 +1064,6 @@
                throw new DirectoryException(
                    ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, de);
              }
              removeLdapSyntaxDescription(lsd, newSchema, modifiedSchemaFiles);
            }
          }
          else
@@ -1234,24 +1200,20 @@
   *                              the provided attribute type to the server
   *                              schema.
   */
  private void addAttributeType(AttributeType attributeType, Schema schema,
                                Set<String> modifiedSchemaFiles)
  private void addAttributeType(AttributeType attributeType, Schema schema, Set<String> modifiedSchemaFiles)
          throws DirectoryException
  {
    // First, see if the specified attribute type already exists.  We'll check
    // the OID and all of the names, which means that it's possible there could
    // be more than one match (although if there is, then we'll refuse the
    // operation).
    AttributeType existingType =
         schema.getAttributeType(attributeType.getOID());
    for (String name : attributeType.getNormalizedNames())
    // Check if there is only a single attribute type for each name
    // This is not checked by the SDK schema.
    AttributeType existingType = schema.getAttributeType(attributeType.getOID());
    for (String name : attributeType.getNames())
    {
      AttributeType t = schema.getAttributeType(name);
      if (t == null)
      if (t.isPlaceHolder())
      {
        continue;
      }
      else if (existingType == null)
      if (existingType.isPlaceHolder())
      {
        existingType = t;
      }
@@ -1260,89 +1222,56 @@
        // NOTE:  We really do want to use "!=" instead of "! t.equals()"
        // because we want to check whether it's the same object instance, not
        // just a logical equivalent.
        LocalizableMessage message = ERR_SCHEMA_MODIFY_MULTIPLE_CONFLICTS_FOR_ADD_ATTRTYPE.
            get(attributeType.getNameOrOID(), existingType.getNameOrOID(),
                t.getNameOrOID());
        LocalizableMessage message = ERR_SCHEMA_MODIFY_MULTIPLE_CONFLICTS_FOR_ADD_ATTRTYPE.get(
            attributeType.getNameOrOID(), existingType.getNameOrOID(), t.getNameOrOID());
        throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
      }
    }
    // Make sure that the new attribute type doesn't reference an undefined
    // or OBSOLETE superior attribute type.
    // Make sure that the new attribute type doesn't reference an
    // OBSOLETE superior attribute type.
    AttributeType superiorType = attributeType.getSuperiorType();
    if (superiorType != null)
    if (superiorType != null && superiorType.isObsolete())
    {
      if (! schema.hasAttributeType(superiorType.getOID()))
      {
        LocalizableMessage message = ERR_SCHEMA_MODIFY_UNDEFINED_SUPERIOR_ATTRIBUTE_TYPE.
            get(attributeType.getNameOrOID(), superiorType.getNameOrOID());
        throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
      }
      else if (superiorType.isObsolete())
      {
        LocalizableMessage message = ERR_SCHEMA_MODIFY_OBSOLETE_SUPERIOR_ATTRIBUTE_TYPE.
            get(attributeType.getNameOrOID(), superiorType.getNameOrOID());
        throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
      }
      LocalizableMessage message = ERR_SCHEMA_MODIFY_OBSOLETE_SUPERIOR_ATTRIBUTE_TYPE.get(
          attributeType.getNameOrOID(), superiorType.getNameOrOID());
      throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
    }
    // Make sure that none of the associated matching rules are marked OBSOLETE.
    MatchingRule mr = attributeType.getEqualityMatchingRule();
    if (mr != null && mr.isObsolete())
    {
      LocalizableMessage message = ERR_SCHEMA_MODIFY_ATTRTYPE_OBSOLETE_MR.get(
          attributeType.getNameOrOID(), mr.getNameOrOID());
      throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
    }
    mr = attributeType.getOrderingMatchingRule();
    if (mr != null && mr.isObsolete())
    {
      LocalizableMessage message = ERR_SCHEMA_MODIFY_ATTRTYPE_OBSOLETE_MR.get(
          attributeType.getNameOrOID(), mr.getNameOrOID());
      throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
    }
    mr = attributeType.getSubstringMatchingRule();
    if (mr != null && mr.isObsolete())
    {
      LocalizableMessage message = ERR_SCHEMA_MODIFY_ATTRTYPE_OBSOLETE_MR.get(
          attributeType.getNameOrOID(), mr.getNameOrOID());
      throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
    }
    mr = attributeType.getApproximateMatchingRule();
    if (mr != null && mr.isObsolete())
    {
      LocalizableMessage message = ERR_SCHEMA_MODIFY_ATTRTYPE_OBSOLETE_MR.get(
          attributeType.getNameOrOID(), mr.getNameOrOID());
      throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
    }
    throwIfObsoleteMatchingRule(attributeType, attributeType.getEqualityMatchingRule());
    throwIfObsoleteMatchingRule(attributeType, attributeType.getOrderingMatchingRule());
    throwIfObsoleteMatchingRule(attributeType, attributeType.getSubstringMatchingRule());
    throwIfObsoleteMatchingRule(attributeType, attributeType.getApproximateMatchingRule());
    // If there is no existing type, then we're adding a new attribute.
    // Otherwise, we're replacing an existing one.
    if (existingType == null)
    if (existingType.isPlaceHolder())
    {
      schema.registerAttributeType(attributeType, false);
      addNewSchemaElement(modifiedSchemaFiles, attributeType);
      String schemaFile = addNewSchemaElement(modifiedSchemaFiles, new SomeSchemaElement(attributeType));
      schema.registerAttributeType(attributeType, schemaFile, false);
    }
    else
    {
      schema.deregisterAttributeType(existingType);
      schema.registerAttributeType(attributeType, false);
      schema.rebuildDependentElements(existingType);
      replaceExistingSchemaElement(modifiedSchemaFiles, attributeType,
          existingType);
      String schemaFile = replaceExistingSchemaElement(
          modifiedSchemaFiles, new SomeSchemaElement(attributeType), new SomeSchemaElement(existingType));
      schema.registerAttributeType(attributeType, schemaFile, false);
      schema.rebuildDependentElements(new SomeSchemaElement(existingType));
    }
  }
  private void throwIfObsoleteMatchingRule(AttributeType attributeType, MatchingRule mr) throws DirectoryException
  {
    if (mr != null && mr.isObsolete())
    {
      throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
          ERR_SCHEMA_MODIFY_ATTRTYPE_OBSOLETE_MR.get(attributeType.getNameOrOID(), mr.getNameOrOID()));
    }
  }
  private void addNewSchemaElement(Set<String> modifiedSchemaFiles,
      SchemaFileElement elem)
  private void addNewSchemaElement(Set<String> modifiedSchemaFiles, SchemaFileElement elem)
  {
    String schemaFile = getSchemaFile(elem);
    if (schemaFile == null || schemaFile.length() == 0)
@@ -1350,11 +1279,17 @@
      schemaFile = FILE_USER_SCHEMA_ELEMENTS;
      setSchemaFile(elem, schemaFile);
    }
    modifiedSchemaFiles.add(schemaFile);
  }
  /** Update list of modified files and return the schema file to use for the added element (may be null). */
  private String addNewSchemaElement(Set<String> modifiedSchemaFiles, SomeSchemaElement elem)
  {
    String schemaFile = elem.getSchemaFile();
    String finalFile = schemaFile != null ? schemaFile : FILE_USER_SCHEMA_ELEMENTS;
    modifiedSchemaFiles.add(finalFile);
    return schemaFile == null ? finalFile : null;
  }
  private <T extends SchemaFileElement> void replaceExistingSchemaElement(
      Set<String> modifiedSchemaFiles, T newElem, T existingElem)
@@ -1382,7 +1317,32 @@
    }
  }
  /** Update list of modified files and return the schema file to use for the new element (may be null). */
  private String replaceExistingSchemaElement(
      Set<String> modifiedSchemaFiles, SomeSchemaElement newElem, SomeSchemaElement existingElem)
  {
    String newSchemaFile = newElem.getSchemaFile();
    String oldSchemaFile = existingElem.getSchemaFile();
    if (newSchemaFile == null)
    {
      if (oldSchemaFile == null)
      {
        oldSchemaFile = FILE_USER_SCHEMA_ELEMENTS;
      }
      modifiedSchemaFiles.add(oldSchemaFile);
      return oldSchemaFile;
    }
    else if (oldSchemaFile == null || oldSchemaFile.equals(newSchemaFile))
    {
      modifiedSchemaFiles.add(newSchemaFile);
    }
    else
    {
      modifiedSchemaFiles.add(newSchemaFile);
      modifiedSchemaFiles.add(oldSchemaFile);
    }
    return null;
  }
  /**
   * Handles all processing required to remove the provided attribute type from
@@ -1411,67 +1371,22 @@
   *                              the provided attribute type from the server
   *                              schema.
   */
  private void removeAttributeType(AttributeType attributeType, Schema schema,
                                   ArrayList<Modification> modifications,
                                   int currentPosition,
                                   Set<String> modifiedSchemaFiles)
  private void removeAttributeType(AttributeType attributeType, Schema schema, Set<String> modifiedSchemaFiles)
          throws DirectoryException
  {
    // See if the specified attribute type is actually defined in the server
    // schema.  If not, then fail.
    AttributeType removeType = schema.getAttributeType(attributeType.getOID());
    if (removeType == null || !removeType.equals(attributeType))
    if (removeType.isPlaceHolder() || !removeType.equals(attributeType))
    {
      LocalizableMessage message = ERR_SCHEMA_MODIFY_REMOVE_NO_SUCH_ATTRIBUTE_TYPE.get(
          attributeType.getNameOrOID());
      throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
    }
    // See if there is another modification later to add the attribute type back
    // into the schema.  If so, then it's a replace and we should ignore the
    // remove because adding it back will handle the replace.
    for (int i=currentPosition+1; i < modifications.size(); i++)
    {
      Modification m = modifications.get(i);
      Attribute    a = m.getAttribute();
      if (m.getModificationType() != ModificationType.ADD
          || !a.getAttributeType().equals(attributeTypesType))
      {
        continue;
      }
      for (ByteString v : a)
      {
        AttributeType at;
        try
        {
          at = AttributeTypeSyntax.decodeAttributeType(v, schema, true);
        }
        catch (DirectoryException de)
        {
          logger.traceException(de);
          LocalizableMessage message = ERR_SCHEMA_MODIFY_CANNOT_DECODE_ATTRTYPE.get(
              v, de.getMessageObject());
          throw new DirectoryException(
                         ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, de);
        }
        if (attributeType.getOID().equals(at.getOID()))
        {
          // We found a match where the attribute type is added back later, so
          // we don't need to do anything else here.
          return;
        }
      }
    }
    // Make sure that the attribute type isn't used as the superior type for
    // any other attributes.
    for (AttributeType at : schema.getAttributeTypes().values())
    for (AttributeType at : schema.getAttributeTypes())
    {
      AttributeType superiorType = at.getSuperiorType();
      if (superiorType != null && superiorType.equals(removeType))
@@ -1482,7 +1397,6 @@
      }
    }
    // Make sure that the attribute type isn't used as a required or optional
    // attribute type in any objectclass.
    for (ObjectClass oc : schema.getObjectClasses().values())
@@ -1496,7 +1410,6 @@
      }
    }
    // Make sure that the attribute type isn't used as a required or optional
    // attribute type in any name form.
    for (List<NameForm> mappedForms :
@@ -1515,7 +1428,6 @@
      }
    }
    // Make sure that the attribute type isn't used as a required, optional, or
    // prohibited attribute type in any DIT content rule.
    for (DITContentRule dcr : schema.getDITContentRules().values())
@@ -1530,7 +1442,6 @@
      }
    }
    // Make sure that the attribute type isn't referenced by any matching rule
    // use.
    for (MatchingRuleUse mru : schema.getMatchingRuleUses().values())
@@ -1543,11 +1454,10 @@
      }
    }
    // If we've gotten here, then it's OK to remove the attribute type from
    // the schema.
    schema.deregisterAttributeType(removeType);
    String schemaFile = getSchemaFile(removeType);
    String schemaFile = new SomeSchemaElement(removeType).getSchemaFile();
    if (schemaFile != null)
    {
      modifiedSchemaFiles.add(schemaFile);
@@ -1672,8 +1582,7 @@
      schema.deregisterObjectClass(existingClass);
      schema.registerObjectClass(objectClass, false);
      schema.rebuildDependentElements(existingClass);
      replaceExistingSchemaElement(modifiedSchemaFiles, objectClass,
          existingClass);
      replaceExistingSchemaElement(modifiedSchemaFiles, objectClass, existingClass);
    }
  }
@@ -2691,80 +2600,76 @@
    }
  }
  /**
   * Handles all processing required for adding the provided ldap syntax
   * description to the given schema, replacing an existing ldap syntax
   * description if necessary, and ensuring all other metadata is properly
   * updated.
   * Handles all processing required for adding the provided ldap syntax description to the given
   * schema, replacing an existing ldap syntax description if necessary, and ensuring all other
   * metadata is properly updated.
   *
   * @param  ldapSyntaxDesc   The ldap syntax description to add or replace in
   *                               the server schema.
   * @param  schema               The schema to which the name form should be
   *                              added.
   * @param  modifiedSchemaFiles  The names of the schema files containing
   *                              schema elements that have been updated as part
   *                              of the schema modification.
   *
   * @throws  DirectoryException  If a problem occurs while attempting to add
   *                              the provided ldap syntax description to the
   *                              server schema.
   * @param definition
   *          The definition of the ldap syntax description to add or replace in the server schema.
   * @param schema
   *          The schema to which the LDAP syntax description should be added.
   * @param modifiedSchemaFiles
   *          The names of the schema files containing schema elements that have been updated as
   *          part of the schema modification.
   * @throws DirectoryException
   *           If a problem occurs while attempting to add the provided ldap syntax description to
   *           the server schema.
   */
  private void addLdapSyntaxDescription(LDAPSyntaxDescription ldapSyntaxDesc,
                           Schema schema,
                           Set<String> modifiedSchemaFiles)
  private void addLdapSyntaxDescription(final String definition, Schema schema, Set<String> modifiedSchemaFiles)
          throws DirectoryException
  {
       //Check if there is an existing syntax with this oid.
    String oid = ldapSyntaxDesc.getSyntax().getOID();
    // Check if there is an existing syntax with this oid.
    String oid =
        Schema.parseOID(definition, ResultCode.INVALID_ATTRIBUTE_SYNTAX, ERR_ATTR_SYNTAX_LDAPSYNTAX_EMPTY_VALUE);
    // We allow only unimplemented syntaxes to be substituted.
    if(schema.getSyntax(oid) !=null)
    if (schema.hasSyntax(oid))
    {
      LocalizableMessage message =
          ERR_ATTR_SYNTAX_INVALID_LDAP_SYNTAX.get(ldapSyntaxDesc, oid);
      throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
                                     message);
      LocalizableMessage message = ERR_ATTR_SYNTAX_INVALID_LDAP_SYNTAX.get(definition, oid);
      throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
    }
    LDAPSyntaxDescription existingLSD = schema.getLdapSyntaxDescription(oid);
    SchemaUpdater schemaUpdater = serverContext.getSchemaUpdater();
    org.forgerock.opendj.ldap.schema.Schema newSchema = null;
    // If there is no existing lsd, then we're adding a new ldapsyntax.
    // Otherwise, we're replacing an existing one.
    if (existingLSD == null)
    {
      schema.registerLdapSyntaxDescription(ldapSyntaxDesc, false);
      addNewSchemaElement(modifiedSchemaFiles, ldapSyntaxDesc);
      String def = Schema.addSchemaFileToElementDefinitionIfAbsent(definition, FILE_USER_SCHEMA_ELEMENTS);
      schema.registerLdapSyntaxDescription(def, false);
      // update schema NG
      newSchema = schemaUpdater.getSchemaBuilder().buildSyntax(ldapSyntaxDesc.getSyntax()).addToSchema().toSchema();
      schemaUpdater.updateSchema(newSchema);
      String schemaFile = getSchemaFile(schema.getLdapSyntaxDescription(oid));
      modifiedSchemaFiles.add(schemaFile);
    }
    else
    {
      schema.deregisterLdapSyntaxDescription(existingLSD);
      schema.registerLdapSyntaxDescription(ldapSyntaxDesc, false);
      // update schema NG
      SchemaBuilder schemaBuilder = schemaUpdater.getSchemaBuilder();
      schemaBuilder.removeSyntax(oid);
      newSchema = schemaBuilder.buildSyntax(ldapSyntaxDesc.getSyntax()).addToSchema().toSchema();
      schemaUpdater.updateSchema(newSchema);
      String oldSchemaFile = getSchemaFile(existingLSD);
      String schemaFile = oldSchemaFile != null && oldSchemaFile.length() > 0 ?
          oldSchemaFile : FILE_USER_SCHEMA_ELEMENTS;
      String def = Schema.addSchemaFileToElementDefinitionIfAbsent(definition, schemaFile);
      schema.registerLdapSyntaxDescription(def, false);
      schema.rebuildDependentElements(existingLSD);
      replaceExistingSchemaElement(modifiedSchemaFiles, ldapSyntaxDesc, existingLSD);
      String newSchemaFile = getSchemaFile(schema.getLdapSyntaxDescription(oid));
      if (oldSchemaFile != null)
      {
        modifiedSchemaFiles.add(oldSchemaFile);
      }
      if (newSchemaFile != null)
      {
        modifiedSchemaFiles.add(newSchemaFile);
      }
    }
  }
  /** Gets rid of the ldap syntax description. */
  private void removeLdapSyntaxDescription(LDAPSyntaxDescription ldapSyntaxDesc,
                                    Schema schema,
                                    Set<String> modifiedSchemaFiles)
          throws DirectoryException
  private void removeLdapSyntaxDescription(String definition, Schema schema, Set<String> modifiedSchemaFiles)
      throws DirectoryException
  {
    /*
     * See if the specified ldap syntax description is actually defined in the
@@ -2772,22 +2677,17 @@
     * part of the ldapsyntaxes attribute. A virtual value is not searched and
     * hence never deleted.
     */
    String oid = ldapSyntaxDesc.getSyntax().getOID();
    LDAPSyntaxDescription removeLSD = schema.getLdapSyntaxDescription(oid);
    String oid =
        Schema.parseOID(definition, ResultCode.INVALID_ATTRIBUTE_SYNTAX, ERR_ATTR_SYNTAX_LDAPSYNTAX_EMPTY_VALUE);
    if (removeLSD == null || !removeLSD.equals(ldapSyntaxDesc))
    LDAPSyntaxDescription removeLSD = schema.getLdapSyntaxDescription(oid);
    if (removeLSD == null)
    {
      LocalizableMessage message =
          ERR_SCHEMA_MODIFY_REMOVE_NO_SUCH_LSD.get(oid);
      throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
    }
    // update schema NG
    SchemaUpdater schemaUpdater = serverContext.getSchemaUpdater();
    SchemaBuilder schemaBuilder = schemaUpdater.getSchemaBuilder();
    schemaBuilder.removeSyntax(oid);
    schemaUpdater.updateSchema(schemaBuilder.toSchema());
    schema.deregisterLdapSyntaxDescription(removeLSD);
    String schemaFile = getSchemaFile(removeLSD);
    if (schemaFile != null)
@@ -2886,9 +2786,10 @@
    // same file are written before the subordinate types.
    Set<AttributeType> addedTypes = new HashSet<>();
    values = new LinkedHashSet<>();
    for (AttributeType at : schema.getAttributeTypes().values())
    for (AttributeType at : schema.getAttributeTypes())
    {
      if (schemaFile.equals(getSchemaFile(at)))
      String atSchemaFile = new SomeSchemaElement(at).getSchemaFile();
      if (schemaFile.equals(atSchemaFile))
      {
        addAttrTypeToSchemaFile(schema, schemaFile, at, values, addedTypes, 0);
      }
@@ -3070,7 +2971,7 @@
    AttributeType superiorType = attributeType.getSuperiorType();
    if (superiorType != null &&
        schemaFile.equals(getSchemaFile(superiorType)) &&
        schemaFile.equals(new SomeSchemaElement(attributeType).getSchemaFile()) &&
        !addedTypes.contains(superiorType))
    {
      addAttrTypeToSchemaFile(schema, schemaFile, superiorType, values,
@@ -3618,8 +3519,8 @@
  private void importEntry(Entry newSchemaEntry)
          throws DirectoryException
  {
    Schema schema = DirectoryServer.getSchema();
    Schema newSchema = DirectoryServer.getSchema().duplicate();
    Schema schema = serverContext.getSchema();
    Schema newSchema = schema.duplicate();
    TreeSet<String> modifiedSchemaFiles = new TreeSet<>();
    // Get the attributeTypes attribute from the entry.
@@ -3628,8 +3529,7 @@
    {
      attrTypeSyntax = CoreSchema.getAttributeTypeDescriptionSyntax();
    }
    AttributeType attributeAttrType = DirectoryServer.getAttributeTypeOrDefault(
        ATTR_ATTRIBUTE_TYPES_LC, ATTR_ATTRIBUTE_TYPES, attrTypeSyntax);
    AttributeType attributeAttrType = CoreSchema.getAttributeTypesAttributeType();
    // loop on the attribute types in the entry just received
    // and add them in the existing schema.
@@ -3641,8 +3541,8 @@
      for (ByteString v : a)
      {
        // Parse the attribute type.
        AttributeType attrType = AttributeTypeSyntax.decodeAttributeType(v, schema, false);
        String schemaFile = getSchemaFile(attrType);
        AttributeType attrType = schema.parseAttributeType(v.toString());
        String schemaFile = new SomeSchemaElement(attrType).getSchemaFile();
        if (CONFIG_SCHEMA_ELEMENTS_FILE.equals(schemaFile))
        {
          // Don't import the file containing the definitions of the
@@ -3676,14 +3576,10 @@
    // loop on all the attribute types in the current schema and delete
    // them from the new schema if they are not in the imported schema entry.
    ConcurrentHashMap<String, AttributeType> currentAttrTypes =
      newSchema.getAttributeTypes();
    for (AttributeType removeType : currentAttrTypes.values())
    for (AttributeType removeType : newSchema.getAttributeTypes())
    {
      String schemaFile = getSchemaFile(removeType);
      if (CONFIG_SCHEMA_ELEMENTS_FILE.equals(schemaFile)
          || CORE_SCHEMA_ELEMENTS_FILE.equals(schemaFile))
      String schemaFile = new SomeSchemaElement(removeType).getSchemaFile();
      if (CONFIG_SCHEMA_ELEMENTS_FILE.equals(schemaFile) || CORE_SCHEMA_ELEMENTS_FILE.equals(schemaFile))
      {
        // Don't import the file containing the definitions of the
        // Schema elements used for configuration because these
@@ -3696,7 +3592,7 @@
        newSchema.deregisterAttributeType(removeType);
        if (schemaFile != null)
        {
              modifiedSchemaFiles.add(schemaFile);
          modifiedSchemaFiles.add(schemaFile);
        }
      }
    }
@@ -3708,8 +3604,7 @@
    {
      ocSyntax = CoreSchema.getObjectClassDescriptionSyntax();
    }
    AttributeType objectclassAttrType = DirectoryServer.getAttributeTypeOrDefault(
        ATTR_OBJECTCLASSES_LC, ATTR_OBJECTCLASSES, ocSyntax);
    AttributeType objectclassAttrType = CoreSchema.getObjectClassAttributeType();
    oidList.clear();
    List<Attribute> ocList = newSchemaEntry.getAttribute(objectclassAttrType);
@@ -3761,10 +3656,9 @@
      }
    }
    // loop on all the attribute types in the current schema and delete
    // loop on all the object classes in the current schema and delete
    // them from the new schema if they are not in the imported schema entry.
    ConcurrentHashMap<String, ObjectClass> currentObjectClasses =
      newSchema.getObjectClasses();
    ConcurrentHashMap<String, ObjectClass> currentObjectClasses = newSchema.getObjectClasses();
    for (ObjectClass removeClass : currentObjectClasses.values())
    {
opendj-server-legacy/src/main/java/org/opends/server/backends/TrustStoreBackend.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2007-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.backends;
@@ -78,6 +78,7 @@
import org.opends.server.core.ModifyOperation;
import org.opends.server.core.SearchOperation;
import org.opends.server.core.ServerContext;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import org.opends.server.util.CertificateManager;
import org.opends.server.util.Platform.KeyType;
opendj-server-legacy/src/main/java/org/opends/server/backends/jeb/JEMonitor.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.backends.jeb;
@@ -34,12 +34,12 @@
import java.util.List;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.admin.std.server.MonitorProviderCfg;
import org.opends.server.api.MonitorProvider;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.Attributes;
import com.sleepycat.je.Environment;
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/AttributeIndex.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 *      Portions Copyright 2014 Manuel Gaupp
 */
package org.opends.server.backends.pluggable;
@@ -56,6 +56,7 @@
import org.opends.server.backends.pluggable.spi.WriteOperation;
import org.opends.server.backends.pluggable.spi.WriteableTransaction;
import org.opends.server.core.DirectoryServer;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import org.opends.server.util.StaticUtils;
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/BackendImpl.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2007-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2015 ForgeRock AS
 *      Portions Copyright 2013-2016 ForgeRock AS
 */
package org.opends.server.backends.pluggable;
@@ -66,7 +66,7 @@
import org.opends.server.core.ModifyOperation;
import org.opends.server.core.SearchOperation;
import org.opends.server.core.ServerContext;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.BackupConfig;
import org.opends.server.types.BackupDirectory;
import org.opends.server.types.CanceledOperationException;
@@ -123,6 +123,8 @@
      OID_SERVER_SIDE_SORT_REQUEST_CONTROL,
      OID_VLV_REQUEST_CONTROL);
  private ServerContext serverContext;
  /**
   * Begin a Backend API method that accesses the {@link EntryContainer} for <code>entryDN</code>
   * and returns it.
@@ -177,6 +179,7 @@
    Reject.ifNull(cfg, "cfg must not be null");
    this.cfg = cfg;
    this.serverContext = serverContext;
    baseDNs = this.cfg.getBaseDN().toArray(new DN[0]);
    storage = new TracedStorage(configureStorage(cfg, serverContext), cfg.getBackendId());
  }
@@ -1021,7 +1024,7 @@
          throws ConfigException, InitializationException {
    // Open the storage
    try {
      final RootContainer rc = new RootContainer(getBackendID(), storage, cfg);
      final RootContainer rc = new RootContainer(getBackendID(), serverContext, storage, cfg);
      rc.open(accessMode);
      return rc;
    }
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DN2URI.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2012-2015 ForgeRock AS
 *      Portions Copyright 2012-2016 ForgeRock AS
 */
package org.opends.server.backends.pluggable;
@@ -54,7 +54,7 @@
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.SearchOperation;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/EntryContainer.java
@@ -97,7 +97,7 @@
import org.opends.server.core.SearchOperation;
import org.opends.server.protocols.ldap.LDAPResultCode;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.Attributes;
import org.opends.server.types.CanceledOperationException;
import org.opends.server.types.Control;
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/ImportLDIFReader.java
@@ -20,7 +20,7 @@
 *
 * CDDL HEADER END
 *
 *      Copyright 2015 ForgeRock AS
 *      Copyright 2015-2016 ForgeRock AS
 */
package org.opends.server.backends.pluggable;
@@ -41,7 +41,7 @@
import org.forgerock.util.Reject;
import org.opends.server.api.plugin.PluginResult;
import org.opends.server.types.AttributeBuilder;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
import org.opends.server.types.LDIFImportConfig;
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/IndexFilter.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions copyright 2011-2015 ForgeRock AS
 *      Portions copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.backends.pluggable;
@@ -36,7 +36,7 @@
import org.opends.server.backends.pluggable.AttributeIndex.IndexFilterType;
import org.opends.server.backends.pluggable.spi.ReadableTransaction;
import org.opends.server.core.SearchOperation;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.FilterType;
import org.opends.server.types.SearchFilter;
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/IndexQueryFactoryImpl.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2009-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.backends.pluggable;
@@ -37,6 +37,7 @@
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.ldap.spi.IndexQueryFactory;
import org.forgerock.opendj.ldap.spi.IndexingOptions;
import org.forgerock.util.Utils;
@@ -44,7 +45,6 @@
import org.opends.server.backends.pluggable.spi.Cursor;
import org.opends.server.backends.pluggable.spi.ReadableTransaction;
import org.opends.server.backends.pluggable.spi.StorageRuntimeException;
import org.opends.server.types.AttributeType;
/**
 * This class is an implementation of IndexQueryFactory which creates
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/PersistentCompressedSchema.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2015 ForgeRock AS.
 *      Portions Copyright 2013-2016 ForgeRock AS.
 */
package org.opends.server.backends.pluggable;
@@ -46,6 +46,7 @@
import org.opends.server.backends.pluggable.spi.WriteOperation;
import org.opends.server.backends.pluggable.spi.WriteableTransaction;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.ServerContext;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.InitializationException;
@@ -80,6 +81,8 @@
  /**
   * Creates a new instance of this compressed schema manager.
   *
   * @param serverContext
   *          The server context.
   * @param storage
   *          A reference to the storage in which the trees will be held.
   * @param txn a non null transaction
@@ -92,9 +95,10 @@
   *           If an error occurs while loading and processing the compressed
   *           schema definitions.
   */
  PersistentCompressedSchema(final Storage storage, WriteableTransaction txn, AccessMode accessMode)
      throws StorageRuntimeException, InitializationException
  PersistentCompressedSchema(ServerContext serverContext, final Storage storage, WriteableTransaction txn,
      AccessMode accessMode) throws StorageRuntimeException, InitializationException
  {
    super(serverContext);
    this.storage = storage;
    load(txn, accessMode.isWriteable());
  }
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/RootContainer.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.backends.pluggable;
@@ -55,6 +55,7 @@
import org.opends.server.backends.pluggable.spi.WriteOperation;
import org.opends.server.backends.pluggable.spi.WriteableTransaction;
import org.opends.server.core.SearchOperation;
import org.opends.server.core.ServerContext;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.InitializationException;
@@ -89,18 +90,23 @@
  /** The compressed schema manager for this backend. */
  private PersistentCompressedSchema compressedSchema;
  private final ServerContext serverContext;
  /**
   * Creates a new RootContainer object representing a storage.
   *
   * @param config
   *          The configuration of the backend.
   * @param backendID
   *          A reference to the backend that is creating this root
   *          container.
   * @param serverContext
   *          The server context.
   * @param config
   *          The configuration of the backend.
   */
  RootContainer(String backendID, Storage storage, PluggableBackendCfg config)
  RootContainer(String backendID, ServerContext serverContext, Storage storage, PluggableBackendCfg config)
  {
    this.backendId = backendID;
    this.serverContext = serverContext;
    this.storage = storage;
    this.config = config;
@@ -140,7 +146,7 @@
        @Override
        public void run(WriteableTransaction txn) throws Exception
        {
          compressedSchema = new PersistentCompressedSchema(storage, txn, accessMode);
          compressedSchema = new PersistentCompressedSchema(serverContext, storage, txn, accessMode);
          openAndRegisterEntryContainers(txn, config.getBaseDN(), accessMode);
        }
      });
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/VLVIndex.java
@@ -69,7 +69,7 @@
import org.opends.server.core.SearchOperation;
import org.opends.server.protocols.ldap.LDAPResultCode;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/VerifyJob.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.backends.pluggable;
@@ -60,7 +60,7 @@
import org.opends.server.backends.pluggable.spi.SequentialCursor;
import org.opends.server.backends.pluggable.spi.StorageRuntimeException;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
opendj-server-legacy/src/main/java/org/opends/server/backends/task/RecurringTask.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.backends.task;
@@ -43,7 +43,7 @@
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.ServerContext;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.Attributes;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
opendj-server-legacy/src/main/java/org/opends/server/backends/task/Task.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.backends.task;
@@ -47,6 +47,7 @@
import org.opends.messages.Severity;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.ServerContext;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import org.opends.server.types.LockManager.DNLock;
import org.opends.server.util.EMailMessage;
opendj-server-legacy/src/main/java/org/opends/server/backends/task/TaskBackend.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.backends.task;
@@ -58,6 +58,7 @@
import org.opends.server.api.Backupable;
import org.opends.server.config.ConfigEntry;
import org.opends.server.core.*;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import org.opends.server.types.LockManager.DNLock;
import org.opends.server.util.BackupManager;
opendj-server-legacy/src/main/java/org/opends/server/backends/task/TaskScheduler.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2015 ForgeRock AS
 *      Portions Copyright 2013-2016 ForgeRock AS
 */
package org.opends.server.backends.task;
@@ -42,6 +42,7 @@
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.api.AlertGenerator;
import org.opends.server.api.DirectoryThread;
import org.opends.server.core.DirectoryServer;
opendj-server-legacy/src/main/java/org/opends/server/config/ConfigEntry.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.config;
@@ -34,13 +34,13 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.api.ConfigAddListener;
import org.opends.server.api.ConfigChangeListener;
import org.opends.server.api.ConfigDeleteListener;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeBuilder;
import org.opends.server.types.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
import org.opends.server.types.ObjectClass;
opendj-server-legacy/src/main/java/org/opends/server/config/DNConfigAttribute.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.config;
@@ -222,6 +222,7 @@
   *
   * @return  The name of the data type for this configuration attribute.
   */
  @Override
  public String getDataType()
  {
    return "DN";
@@ -234,6 +235,7 @@
   *
   * @return  The attribute syntax for this configuration attribute.
   */
  @Override
  public Syntax getSyntax()
  {
    return DirectoryServer.getDefaultStringSyntax();
@@ -486,6 +488,7 @@
   * configuration attribute.  This will not take any action if there are no
   * pending values.
   */
  @Override
  public void applyPendingValues()
  {
    if (! hasPendingValues())
@@ -511,6 +514,7 @@
   * @return  <CODE>true</CODE> if the provided value is acceptable for use in
   *          this attribute, or <CODE>false</CODE> if not.
   */
  @Override
  public boolean valueIsAcceptable(ByteString value, StringBuilder rejectReason)
  {
    // Make sure that the value is not null.
@@ -557,6 +561,7 @@
   * @throws  ConfigException  If an unrecoverable problem occurs while
   *                           performing the conversion.
   */
  @Override
  public LinkedHashSet<ByteString> stringsToValues(List<String> valueStrings, boolean allowFailures)
         throws ConfigException
  {
@@ -633,6 +638,7 @@
   * @return  The string representations of the set of active values for this
   *          configuration attribute.
   */
  @Override
  public List<String> activeValuesToStrings()
  {
    ArrayList<String> valueStrings = new ArrayList<>(activeValues.size());
@@ -657,6 +663,7 @@
   *          configuration attribute, or <CODE>null</CODE> if there are no
   *          pending values.
   */
  @Override
  public List<String> pendingValuesToStrings()
  {
    if (hasPendingValues())
@@ -694,6 +701,7 @@
   *                           single-valued and the provided attribute has
   *                           multiple values).
   */
  @Override
  public ConfigAttribute getConfigAttribute(List<Attribute> attributeList)
         throws ConfigException
  {
@@ -889,6 +897,7 @@
   *          configuration attribute, or <CODE>null</CODE> if it does not have
   *          any active values.
   */
  @Override
  public  javax.management.Attribute toJMXAttribute()
  {
      return _toJMXAttribute(false) ;
@@ -901,6 +910,7 @@
   * @return  A JMX attribute containing the pending value set for this
   *          configuration attribute.
   */
  @Override
  public  javax.management.Attribute toJMXAttributePending()
  {
      return _toJMXAttribute(true) ;
@@ -917,6 +927,7 @@
   * @param  attributeList  The attribute list to which the JMX attribute(s)
   *                        should be added.
   */
  @Override
  public void toJMXAttribute(AttributeList attributeList)
  {
    if (!activeValues.isEmpty())
@@ -987,6 +998,7 @@
   * @param  attributeInfoList  The list to which the attribute information
   *                            should be added.
   */
  @Override
  public void toJMXAttributeInfo(List<MBeanAttributeInfo> attributeInfoList)
  {
    attributeInfoList.add(new MBeanAttributeInfo(getName(), getType(),
@@ -1009,6 +1021,7 @@
   * @return  A JMX <CODE>MBeanParameterInfo</CODE> object that describes this
   *          configuration attribute.
   */
  @Override
  public MBeanParameterInfo toJMXParameterInfo()
  {
    return new MBeanParameterInfo(getName(), getType(), String.valueOf(getDescription()));
@@ -1030,6 +1043,7 @@
   *                           acceptable value for this configuration
   *                           attribute.
   */
  @Override
  public void setValue(javax.management.Attribute jmxAttribute)
         throws ConfigException
  {
@@ -1137,6 +1151,7 @@
   *
   * @return  A duplicate of this configuration attribute.
   */
  @Override
  public ConfigAttribute duplicate()
  {
    return new DNConfigAttribute(getName(), getDescription(), isRequired(),
opendj-server-legacy/src/main/java/org/opends/server/config/IntegerConfigAttribute.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.config;
@@ -43,8 +43,8 @@
import org.opends.server.types.Attribute;
import org.opends.server.util.CollectionUtils;
import static org.opends.messages.ConfigMessages.*;
import static org.opends.server.config.ConfigConstants.*;
import static org.opends.messages.ConfigMessages.*;
/**
 * This class defines an integer configuration attribute, which can hold zero or
@@ -275,6 +275,7 @@
   *
   * @return  The name of the data type for this configuration attribute.
   */
  @Override
  public String getDataType()
  {
    return "Integer";
@@ -285,6 +286,7 @@
   *
   * @return  The attribute syntax for this configuration attribute.
   */
  @Override
  public Syntax getSyntax()
  {
    return DirectoryServer.getDefaultIntegerSyntax();
@@ -674,6 +676,7 @@
   * configuration attribute.  This will not take any action if there are no
   * pending values.
   */
  @Override
  public void applyPendingValues()
  {
    if (! hasPendingValues())
@@ -697,6 +700,7 @@
   * @return  <CODE>true</CODE> if the provided value is acceptable for use in
   *          this attribute, or <CODE>false</CODE> if not.
   */
  @Override
  public boolean valueIsAcceptable(ByteString value, StringBuilder rejectReason)
  {
    // First, make sure we can represent it as a long.
@@ -753,6 +757,7 @@
   * @throws  ConfigException  If an unrecoverable problem occurs while
   *                           performing the conversion.
   */
  @Override
  public LinkedHashSet<ByteString>
              stringsToValues(List<String> valueStrings, boolean allowFailures)
         throws ConfigException
@@ -832,6 +837,7 @@
   * @return  The string representations of the set of active values for this
   *          configuration attribute.
   */
  @Override
  public List<String> activeValuesToStrings()
  {
    return toListOfString(activeValues);
@@ -848,6 +854,7 @@
   *          configuration attribute, or <CODE>null</CODE> if there are no
   *          pending values.
   */
  @Override
  public List<String> pendingValuesToStrings()
  {
    if (hasPendingValues())
@@ -888,6 +895,7 @@
   *                           single-valued and the provided attribute has
   *                           multiple values).
   */
  @Override
  public ConfigAttribute getConfigAttribute(List<Attribute> attributeList)
         throws ConfigException
  {
@@ -1122,6 +1130,7 @@
   *          configuration attribute, or <CODE>null</CODE> if it does not have
   *          any active values.
   */
  @Override
  public javax.management.Attribute toJMXAttribute()
  {
    return _toJMXAttribute(false);
@@ -1134,6 +1143,7 @@
   * @return  A JMX attribute containing the pending value set for this
   *          configuration attribute.
   */
  @Override
  public  javax.management.Attribute toJMXAttributePending()
  {
      return _toJMXAttribute(true);
@@ -1150,6 +1160,7 @@
   * @param  attributeList  The attribute list to which the JMX attribute(s)
   *                        should be added.
   */
  @Override
  public void toJMXAttribute(AttributeList attributeList)
  {
    if (!activeValues.isEmpty())
@@ -1219,6 +1230,7 @@
   * @param  attributeInfoList  The list to which the attribute information
   *                            should be added.
   */
  @Override
  public void toJMXAttributeInfo(List<MBeanAttributeInfo> attributeInfoList)
  {
    if (isMultiValued())
@@ -1266,6 +1278,7 @@
   * @return  A JMX <CODE>MBeanParameterInfo</CODE> object that describes this
   *          configuration attribute.
   */
  @Override
  public MBeanParameterInfo toJMXParameterInfo()
  {
    if (isMultiValued())
@@ -1291,6 +1304,7 @@
   *                           acceptable value for this configuration
   *                           attribute.
   */
  @Override
  public void setValue(javax.management.Attribute jmxAttribute)
         throws ConfigException
  {
@@ -1393,6 +1407,7 @@
   *
   * @return  A duplicate of this configuration attribute.
   */
  @Override
  public ConfigAttribute duplicate()
  {
    return new IntegerConfigAttribute(getName(), getDescription(), isRequired(),
opendj-server-legacy/src/main/java/org/opends/server/config/JMXMBean.java
@@ -22,7 +22,7 @@
 *
 *
 *      Portions Copyright 2006-2007-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2015 ForgeRock AS
 *      Portions Copyright 2013-2016 ForgeRock AS
 */
package org.opends.server.config;
@@ -64,7 +64,7 @@
import org.opends.server.protocols.internal.SearchRequest;
import org.opends.server.protocols.jmx.Credential;
import org.opends.server.protocols.jmx.JmxClientConnection;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.InvokableMethod;
opendj-server-legacy/src/main/java/org/opends/server/config/MultiChoiceConfigAttribute.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.config;
@@ -44,8 +44,8 @@
import org.opends.server.types.Attribute;
import org.opends.server.util.CollectionUtils;
import static org.opends.messages.ConfigMessages.*;
import static org.opends.server.config.ConfigConstants.*;
import static org.opends.messages.ConfigMessages.*;
/**
 * This class defines a multi-choice configuration attribute, which can hold
@@ -260,6 +260,7 @@
   *
   * @return  The name of the data type for this configuration attribute.
   */
  @Override
  public String getDataType()
  {
    return "MultiChoice";
@@ -272,6 +273,7 @@
   *
   * @return  The attribute syntax for this configuration attribute.
   */
  @Override
  public Syntax getSyntax()
  {
    return DirectoryServer.getDefaultStringSyntax();
@@ -503,6 +505,7 @@
   * configuration attribute.  This will not take any action if there are no
   * pending values.
   */
  @Override
  public void applyPendingValues()
  {
    if (! hasPendingValues())
@@ -528,6 +531,7 @@
   * @return  <CODE>true</CODE> if the provided value is acceptable for use in
   *          this attribute, or <CODE>false</CODE> if not.
   */
  @Override
  public boolean valueIsAcceptable(ByteString value,
                                   StringBuilder rejectReason)
  {
@@ -572,6 +576,7 @@
   * @throws  ConfigException  If an unrecoverable problem occurs while
   *                           performing the conversion.
   */
  @Override
  public LinkedHashSet<ByteString>
              stringsToValues(List<String> valueStrings, boolean allowFailures)
         throws ConfigException
@@ -638,6 +643,7 @@
   *
   * @return The string representations of the set of active values for this configuration attribute.
   */
  @Override
  public List<String> activeValuesToStrings()
  {
    return activeValues;
@@ -656,6 +662,7 @@
   *          configuration attribute, or <CODE>null</CODE> if there are no
   *          pending values.
   */
  @Override
  public List<String> pendingValuesToStrings()
  {
    if (hasPendingValues())
@@ -688,6 +695,7 @@
   *                           single-valued and the provided attribute has
   *                           multiple values).
   */
  @Override
  public ConfigAttribute getConfigAttribute(List<Attribute> attributeList)
         throws ConfigException
  {
@@ -872,6 +880,7 @@
   *          configuration attribute, or <CODE>null</CODE> if it does not have
   *          any active values.
   */
  @Override
  public javax.management.Attribute toJMXAttribute()
  {
      return _toJMXAttribute(false) ;
@@ -885,6 +894,7 @@
   *          configuration attribute, or <CODE>null</CODE> if it does not have
   *          any active values.
   */
  @Override
  public javax.management.Attribute toJMXAttributePending()
  {
    return _toJMXAttribute(true) ;
@@ -902,6 +912,7 @@
   * @param  attributeList  The attribute list to which the JMX attribute(s)
   *                        should be added.
   */
  @Override
  public void toJMXAttribute(AttributeList attributeList)
  {
    if (!activeValues.isEmpty())
@@ -965,6 +976,7 @@
   * @param  attributeInfoList  The list to which the attribute information
   *                            should be added.
   */
  @Override
  public void toJMXAttributeInfo(List<MBeanAttributeInfo> attributeInfoList)
  {
    attributeInfoList.add(new MBeanAttributeInfo(getName(), getType(),
@@ -987,6 +999,7 @@
   * @return  A JMX <CODE>MBeanParameterInfo</CODE> object that describes this
   *          configuration attribute.
   */
  @Override
  public MBeanParameterInfo toJMXParameterInfo()
  {
    return new MBeanParameterInfo(getName(), getType(), String.valueOf(getDescription()));
@@ -1008,6 +1021,7 @@
   *                           acceptable value for this configuration
   *                           attribute.
   */
  @Override
  public void setValue(javax.management.Attribute jmxAttribute)
         throws ConfigException
  {
@@ -1068,6 +1082,7 @@
   *
   * @return  A duplicate of this configuration attribute.
   */
  @Override
  public ConfigAttribute duplicate()
  {
    return new MultiChoiceConfigAttribute(getName(), getDescription(),
opendj-server-legacy/src/main/java/org/opends/server/config/StringConfigAttribute.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.config;
@@ -226,6 +226,7 @@
   *
   * @return  The name of the data type for this configuration attribute.
   */
  @Override
  public String getDataType()
  {
    return "String";
@@ -238,6 +239,7 @@
   *
   * @return  The attribute syntax for this configuration attribute.
   */
  @Override
  public Syntax getSyntax()
  {
    return DirectoryServer.getDefaultStringSyntax();
@@ -450,6 +452,7 @@
   * configuration attribute.  This will not take any action if there are no
   * pending values.
   */
  @Override
  public void applyPendingValues()
  {
    if (! hasPendingValues())
@@ -475,6 +478,7 @@
   * @return  <CODE>true</CODE> if the provided value is acceptable for use in
   *          this attribute, or <CODE>false</CODE> if not.
   */
  @Override
  public boolean valueIsAcceptable(ByteString value,
                                   StringBuilder rejectReason)
  {
@@ -508,6 +512,7 @@
   * @throws  ConfigException  If an unrecoverable problem occurs while
   *                           performing the conversion.
   */
  @Override
  public LinkedHashSet<ByteString> stringsToValues(List<String> valueStrings, boolean allowFailures)
      throws ConfigException
  {
@@ -568,6 +573,7 @@
   * @return  The string representations of the set of active values for this
   *          configuration attribute.
   */
  @Override
  public List<String> activeValuesToStrings()
  {
    return activeValues;
@@ -586,6 +592,7 @@
   *          configuration attribute, or <CODE>null</CODE> if there are no
   *          pending values.
   */
  @Override
  public List<String> pendingValuesToStrings()
  {
    if (hasPendingValues())
@@ -618,6 +625,7 @@
   *                           single-valued and the provided attribute has
   *                           multiple values).
   */
  @Override
  public ConfigAttribute getConfigAttribute(List<Attribute> attributeList)
         throws ConfigException
  {
@@ -781,6 +789,7 @@
   *          configuration attribute, or <CODE>null</CODE> if it does not have
   *          any active values.
   */
  @Override
  public javax.management.Attribute toJMXAttribute()
  {
    return _toJMXAttribute(false) ;
@@ -794,6 +803,7 @@
   *          configuration attribute, or <CODE>null</CODE> if it does not have
   *          any active values.
   */
  @Override
  public javax.management.Attribute toJMXAttributePending()
  {
    return _toJMXAttribute(true) ;
@@ -812,6 +822,7 @@
   * @param  attributeList  The attribute list to which the JMX attribute(s)
   *                        should be added.
   */
  @Override
  public void toJMXAttribute(AttributeList attributeList)
  {
    if (!activeValues.isEmpty())
@@ -875,6 +886,7 @@
   * @param  attributeInfoList  The list to which the attribute information
   *                            should be added.
   */
  @Override
  public void toJMXAttributeInfo(List<MBeanAttributeInfo> attributeInfoList)
  {
    attributeInfoList.add(new MBeanAttributeInfo(getName(), getType(),
@@ -897,6 +909,7 @@
   * @return  A JMX <CODE>MBeanParameterInfo</CODE> object that describes this
   *          configuration attribute.
   */
  @Override
  public MBeanParameterInfo toJMXParameterInfo()
  {
    return new MBeanParameterInfo(getName(), getType(), String.valueOf(getDescription()));
@@ -918,6 +931,7 @@
   *                           acceptable value for this configuration
   *                           attribute.
   */
  @Override
  public void setValue(javax.management.Attribute jmxAttribute)
         throws ConfigException
  {
@@ -978,6 +992,7 @@
   *
   * @return  A duplicate of this configuration attribute.
   */
  @Override
  public ConfigAttribute duplicate()
  {
    return new StringConfigAttribute(getName(), getDescription(), isRequired(),
opendj-server-legacy/src/main/java/org/opends/server/controls/GetEffectiveRightsRequestControl.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2009 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.controls;
@@ -37,8 +37,8 @@
import org.forgerock.opendj.io.ASN1Writer;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.AttributeType;
import org.opends.server.types.Control;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
@@ -82,7 +82,7 @@
  private static final class Decoder
      implements ControlDecoder<GetEffectiveRightsRequestControl>
  {
    /** {@inheritDoc} */
    @Override
    public GetEffectiveRightsRequestControl decode(boolean isCritical,
        ByteString value) throws DirectoryException
    {
@@ -138,6 +138,7 @@
      }
    }
    @Override
    public String getOID()
    {
      return OID_GET_EFFECTIVE_RIGHTS;
@@ -212,13 +213,6 @@
    this.rawAttrs=attrs;
  }
  /**
   * Writes this control's value to an ASN.1 writer. The value (if any) must be
   * written as an ASN1OctetString.
   *
   * @param writer The ASN.1 output stream to write to.
   * @throws IOException If a problem occurs while writing to the stream.
   */
  @Override
  public void writeValue(ASN1Writer writer) throws IOException {
    writer.writeStartSequence(ASN1.UNIVERSAL_OCTET_STRING_TYPE);
opendj-server-legacy/src/main/java/org/opends/server/controls/MatchedValuesControl.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.controls;
import org.forgerock.i18n.LocalizableMessage;
@@ -33,6 +33,7 @@
import java.io.IOException;
import org.forgerock.opendj.io.*;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.ByteString;
opendj-server-legacy/src/main/java/org/opends/server/controls/MatchedValuesFilter.java
@@ -23,7 +23,7 @@
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2014 Manuel Gaupp
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.controls;
@@ -38,11 +38,11 @@
import org.forgerock.opendj.ldap.Assertion;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.DecodeException;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.forgerock.util.Reject;
import org.opends.server.core.DirectoryServer;
import org.opends.server.protocols.ldap.LDAPResultCode;
import org.opends.server.types.AttributeType;
import org.opends.server.types.LDAPException;
import org.opends.server.types.RawFilter;
opendj-server-legacy/src/main/java/org/opends/server/controls/ServerSideSortRequestControl.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.controls;
@@ -36,9 +36,11 @@
import org.opends.server.core.DirectoryServer;
import org.forgerock.opendj.io.*;
import org.opends.server.protocols.ldap.LDAPResultCode;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.ByteString;
import static org.opends.messages.ProtocolMessages.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
@@ -80,6 +82,7 @@
      implements ControlDecoder<ServerSideSortRequestControl>
  {
    /** {@inheritDoc} */
    @Override
    public ServerSideSortRequestControl decode(boolean isCritical,
                                               ByteString value)
        throws DirectoryException
@@ -166,6 +169,7 @@
      }
    }
    @Override
    public String getOID()
    {
      return OID_SERVER_SIDE_SORT_REQUEST_CONTROL;
opendj-server-legacy/src/main/java/org/opends/server/core/AddOperation.java
@@ -22,13 +22,14 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.core;
import java.util.List;
import java.util.Map;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ByteString;
opendj-server-legacy/src/main/java/org/opends/server/core/AddOperationBasis.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2007-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2015 ForgeRock AS
 *      Portions Copyright 2013-2016 ForgeRock AS
 */
package org.opends.server.core;
@@ -37,6 +37,7 @@
import org.opends.server.api.ClientConnection;
import org.opends.server.protocols.ldap.LDAPAttribute;
import org.opends.server.protocols.ldap.LDAPResultCode;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import org.opends.server.types.operation.PostResponseAddOperation;
import org.opends.server.types.operation.PreParseAddOperation;
opendj-server-legacy/src/main/java/org/opends/server/core/AddOperationWrapper.java
@@ -22,13 +22,14 @@
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2015 ForgeRock AS
 *      Portions Copyright 2013-2016 ForgeRock AS
 */
package org.opends.server.core;
import java.util.List;
import java.util.Map;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ByteString;
opendj-server-legacy/src/main/java/org/opends/server/core/AttributeSyntaxConfigManager.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.core;
@@ -35,7 +35,11 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.config.server.ConfigChangeResult;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.ldap.schema.Schema;
import org.forgerock.opendj.ldap.schema.Syntax;
import org.forgerock.util.Utils;
import org.opends.server.admin.ClassPropertyDefinition;
import org.opends.server.admin.server.ConfigurationAddListener;
@@ -46,9 +50,6 @@
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.opends.server.admin.std.server.RootCfg;
import org.opends.server.api.AttributeSyntax;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.config.server.ConfigChangeResult;
import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.InitializationException;
@@ -133,8 +134,16 @@
          AttributeSyntax<?> syntax = loadSyntax(className, syntaxConfiguration, true);
          try
          {
            Syntax sdkSyntax = syntax.getSDKSyntax(serverContext.getSchemaNG());
            serverContext.getSchema().registerSyntax(sdkSyntax, false);
            Schema schemaNG = serverContext.getSchemaNG();
            Syntax sdkSyntax = syntax.getSDKSyntax(schemaNG);
            // skip the syntax registration if already defined in the (core) schema
            if (!schemaNG.hasSyntax(sdkSyntax.getOID()))
            {
              // The syntaxes configuration options (e.g. strictness, support for zero length values, etc)
              // are set by the call to loadSyntax() which calls initializeSyntax()
              // which updates the SDK schema options.
              serverContext.getSchema().registerSyntax(sdkSyntax, false);
            }
            syntaxes.put(syntaxConfiguration.dn(), syntax);
          }
          catch (DirectoryException de)
@@ -243,7 +252,7 @@
    if (syntax != null)
    {
      String oid = syntax.getOID();
      for (AttributeType at : DirectoryServer.getAttributeTypes().values())
      for (AttributeType at : DirectoryServer.getAttributeTypes())
      {
        if (oid.equals(at.getSyntax().getOID()))
        {
@@ -310,7 +319,7 @@
      if (syntax != null)
      {
        String oid = syntax.getOID();
        for (AttributeType at : DirectoryServer.getAttributeTypes().values())
        for (AttributeType at : DirectoryServer.getAttributeTypes())
        {
          if (oid.equals(at.getSyntax().getOID()))
          {
opendj-server-legacy/src/main/java/org/opends/server/core/CompareOperation.java
@@ -22,12 +22,13 @@
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.core;
import java.util.Set;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ByteString;
opendj-server-legacy/src/main/java/org/opends/server/core/CompareOperationBasis.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2007-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2015 ForgeRock AS
 *      Portions Copyright 2013-2016 ForgeRock AS
 */
package org.opends.server.core;
@@ -35,6 +35,7 @@
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.api.ClientConnection;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import org.opends.server.types.operation.PostResponseCompareOperation;
import org.opends.server.types.operation.PreParseCompareOperation;
opendj-server-legacy/src/main/java/org/opends/server/core/CompareOperationWrapper.java
@@ -22,13 +22,13 @@
 *
 *
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2015 ForgeRock AS
 *      Portions Copyright 2013-2016 ForgeRock AS
 */
package org.opends.server.core;
import java.util.Set;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.DN;
opendj-server-legacy/src/main/java/org/opends/server/core/CoreConfigManager.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS.
 *      Portions Copyright 2011-2016 ForgeRock AS.
 */
package org.opends.server.core;
@@ -32,9 +32,6 @@
import org.forgerock.opendj.config.server.ConfigChangeResult;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.schema.Schema;
import org.forgerock.opendj.ldap.schema.SchemaBuilder;
import org.forgerock.opendj.ldap.schema.SchemaOptions;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.server.ServerManagementContext;
import org.opends.server.admin.std.meta.GlobalCfgDefn;
@@ -45,9 +42,9 @@
import org.opends.server.admin.std.server.RootCfg;
import org.opends.server.api.AuthenticationPolicy;
import org.opends.server.loggers.CommonAudit;
import org.opends.server.schema.SchemaUpdater;
import org.opends.server.types.*;
import static org.forgerock.opendj.ldap.schema.SchemaOptions.*;
import static org.opends.messages.ConfigMessages.*;
import static org.opends.server.core.DirectoryServer.*;
import static org.opends.server.util.ServerConstants.*;
@@ -120,19 +117,16 @@
      }
    }
    // Apply the configuration to the server.
    applyGlobalConfiguration(globalConfig, serverContext);
  }
  /**
   * Applies the settings in the provided configuration to the Directory Server.
   *
   * @param  globalConfig  The configuration settings to be applied.
   */
  private static void applyGlobalConfiguration(GlobalCfg globalConfig, ServerContext serverContext)
  private static void applyGlobalConfiguration(final GlobalCfg globalConfig, final ServerContext serverContext)
      throws ConfigException
  {
    setCheckSchema(globalConfig.isCheckSchema());
    setDefaultPasswordPolicyDN(globalConfig.getDefaultPasswordPolicyDN());
@@ -170,17 +164,16 @@
      commonAudit.setTrustTransactionIds(globalConfig.isTrustTransactionIds());
    }
    // Update the "new" schema with configuration changes
    SchemaUpdater schemaUpdater = serverContext.getSchemaUpdater();
    SchemaBuilder schemaBuilder = schemaUpdater.getSchemaBuilder();
    boolean allowMalformedNames = globalConfig.isAllowAttributeNameExceptions();
    schemaBuilder.setOption(SchemaOptions.ALLOW_MALFORMED_NAMES_AND_OPTIONS, allowMalformedNames);
    Schema schema = schemaBuilder.toSchema();
    if (!globalConfig.isCheckSchema())
    // Update the "new" schema with configuration changes if necessary
    try
    {
      schema = schema.asNonStrictSchema();
      final boolean allowMalformedNames = globalConfig.isAllowAttributeNameExceptions();
      serverContext.getSchema().updateSchemaOption(ALLOW_MALFORMED_NAMES_AND_OPTIONS, allowMalformedNames);
    }
    schemaUpdater.updateSchema(schema);
    catch (DirectoryException e)
    {
      throw new ConfigException(e.getMessageObject(), e);
    }
  }
  private static AcceptRejectWarn convert(InvalidAttributeSyntaxBehavior invalidAttributeSyntaxBehavior)
@@ -326,8 +319,6 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  public boolean isConfigurationChangeAcceptable(GlobalCfg configuration,
                      List<LocalizableMessage> unacceptableReasons)
@@ -346,8 +337,7 @@
        }
        catch (RuntimeException e)
        {
          LocalizableMessage message = ERR_CONFIG_CORE_INVALID_SMTP_SERVER.get(server);
          unacceptableReasons.add(message);
          unacceptableReasons.add(ERR_CONFIG_CORE_INVALID_SMTP_SERVER.get(server));
          configAcceptable = false;
        }
      }
@@ -370,17 +360,19 @@
    return configAcceptable;
  }
  /** {@inheritDoc} */
  @Override
  public ConfigChangeResult applyConfigurationChange(GlobalCfg configuration)
  {
    final ConfigChangeResult ccr = new ConfigChangeResult();
    applyGlobalConfiguration(configuration, serverContext);
    try
    {
      applyGlobalConfiguration(configuration, serverContext);
    }
    catch (ConfigException e)
    {
      ccr.setResultCode(DirectoryServer.getServerErrorResultCode());
      ccr.addMessage(e.getMessageObject());
    }
    return ccr;
  }
}
opendj-server-legacy/src/main/java/org/opends/server/core/DefaultCompressedSchema.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2015 ForgeRock AS.
 *      Portions Copyright 2013-2016 ForgeRock AS.
 */
package org.opends.server.core;
@@ -63,9 +63,13 @@
  /**
   * Creates a new instance of this compressed schema manager.
   *
   * @param serverContext
   *            The server context.
   */
  public DefaultCompressedSchema()
  public DefaultCompressedSchema(ServerContext serverContext)
  {
    super(serverContext);
    load();
  }
opendj-server-legacy/src/main/java/org/opends/server/core/DirectoryServer.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2010-2015 ForgeRock AS.
 *      Portions Copyright 2010-2016 ForgeRock AS.
 */
package org.opends.server.core;
@@ -69,11 +69,10 @@
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.schema.AttributeUsage;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.forgerock.opendj.ldap.schema.ObjectClassType;
import org.forgerock.opendj.ldap.schema.SchemaBuilder;
import org.forgerock.opendj.ldap.schema.Syntax;
import org.forgerock.util.Reject;
import org.opends.server.admin.AdministrationConnector;
@@ -113,7 +112,6 @@
import org.opends.server.api.InitializationCompletedListener;
import org.opends.server.api.InvokableComponent;
import org.opends.server.api.KeyManagerProvider;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.api.MonitorProvider;
import org.opends.server.api.PasswordGenerator;
import org.opends.server.api.PasswordStorageScheme;
@@ -151,32 +149,7 @@
import org.opends.server.monitors.ConnectionHandlerMonitor;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.protocols.internal.InternalConnectionHandler;
import org.opends.server.schema.BooleanEqualityMatchingRuleFactory;
import org.opends.server.schema.CaseExactEqualityMatchingRuleFactory;
import org.opends.server.schema.CaseExactIA5EqualityMatchingRuleFactory;
import org.opends.server.schema.CaseExactIA5SubstringMatchingRuleFactory;
import org.opends.server.schema.CaseExactOrderingMatchingRuleFactory;
import org.opends.server.schema.CaseExactSubstringMatchingRuleFactory;
import org.opends.server.schema.CaseIgnoreEqualityMatchingRuleFactory;
import org.opends.server.schema.CaseIgnoreIA5EqualityMatchingRuleFactory;
import org.opends.server.schema.CaseIgnoreIA5SubstringMatchingRuleFactory;
import org.opends.server.schema.CaseIgnoreOrderingMatchingRuleFactory;
import org.opends.server.schema.CaseIgnoreSubstringMatchingRuleFactory;
import org.opends.server.schema.DistinguishedNameEqualityMatchingRuleFactory;
import org.opends.server.schema.DoubleMetaphoneApproximateMatchingRuleFactory;
import org.opends.server.schema.GeneralizedTimeEqualityMatchingRuleFactory;
import org.opends.server.schema.GeneralizedTimeOrderingMatchingRuleFactory;
import org.opends.server.schema.IntegerEqualityMatchingRuleFactory;
import org.opends.server.schema.IntegerOrderingMatchingRuleFactory;
import org.opends.server.schema.ObjectIdentifierEqualityMatchingRuleFactory;
import org.opends.server.schema.OctetStringEqualityMatchingRuleFactory;
import org.opends.server.schema.OctetStringOrderingMatchingRuleFactory;
import org.opends.server.schema.OctetStringSubstringMatchingRuleFactory;
import org.opends.server.schema.SchemaUpdater;
import org.opends.server.schema.TelephoneNumberEqualityMatchingRuleFactory;
import org.opends.server.schema.TelephoneNumberSubstringMatchingRuleFactory;
import org.opends.server.types.AcceptRejectWarn;
import org.opends.server.types.AttributeType;
import org.opends.server.types.BackupConfig;
import org.opends.server.types.Control;
import org.opends.server.types.DITContentRule;
@@ -204,7 +177,6 @@
import org.opends.server.util.ActivateOnceSDKSchemaIsUsed;
import org.opends.server.util.BuildVersion;
import org.opends.server.util.MultiOutputStream;
import org.opends.server.util.RemoveOnceSDKSchemaIsUsed;
import org.opends.server.util.RuntimeInformation;
import org.opends.server.util.SetupUtils;
import org.opends.server.util.TimeThread;
@@ -281,8 +253,6 @@
  /** The account status notification handler config manager for the server. */
  private AccountStatusNotificationHandlerConfigManager accountStatusNotificationHandlerConfigManager;
  /** The attribute type used to reference the "objectclass" attribute. */
  private AttributeType objectClassAttributeType;
  /** The authenticated users manager for the server. */
  private AuthenticatedUsers authenticatedUsers;
  /** The configuration manager that will handle the server backends. */
@@ -636,19 +606,6 @@
  /** The schema for the Directory Server. */
  private Schema schema;
  /**
   * The schema for the Directory Server.
   * <p>
   * This schema is synchronized indirectly to the existing schema, because
   * syntaxes are defined in schemaNG (i.e, migrated to SDK classes) and there
   * is currently no way to handle the SchemaOptions in the configuration (e.g.
   * SchemaOptions.ALLOW_ZERO_LENGTH_DIRECTORY_STRINGS).
   * Thus, configuration of the legacy syntaxes are kept, and any change related
   * to them is synchronized with this schema.
   */
  @RemoveOnceSDKSchemaIsUsed("'schema' field will then be a reference to a SDK schema")
  private org.forgerock.opendj.ldap.schema.Schema schemaNG;
  /** The schema configuration manager for the Directory Server. */
  private SchemaConfigManager schemaConfigManager;
@@ -753,64 +710,36 @@
   */
  private class DirectoryServerContext implements ServerContext
  {
    /** {@inheritDoc} */
    @Override
    public String getInstanceRoot()
    {
      return DirectoryServer.getInstanceRoot();
    }
    /** {@inheritDoc} */
    @Override
    public String getServerRoot()
    {
      return DirectoryServer.getServerRoot();
    }
    /** {@inheritDoc} */
    @Override
    public Schema getSchema()
    {
      return directoryServer.schema;
    }
    /** {@inheritDoc} */
    @Override
    public org.forgerock.opendj.ldap.schema.Schema getSchemaNG()
    {
      return directoryServer.schemaNG;
      return directoryServer.schema.getSchemaNG();
    }
    /** {@inheritDoc} */
    @Override
    public DirectoryEnvironmentConfig getEnvironment()
    {
      return directoryServer.environmentConfig;
    }
    /** {@inheritDoc} */
    @Override
    public SchemaUpdater getSchemaUpdater()
    {
      return new SchemaUpdater()
      {
        @Override
        public boolean updateSchema(org.forgerock.opendj.ldap.schema.Schema schema)
        {
          schemaNG = schema;
          return true;
        }
        @Override
        public SchemaBuilder getSchemaBuilder()
        {
          return new SchemaBuilder(schemaNG);
        }
      };
    }
    /** {@inheritDoc} */
    @Override
    public org.forgerock.opendj.config.server.ServerManagementContext getServerManagementContext()
    {
@@ -958,15 +887,13 @@
  {
    synchronized (directoryServer)
    {
      // Set default values for variables that may be needed during schema
      // processing.
      // Set default values for variables that may be needed during schema processing.
      directoryServer.syntaxEnforcementPolicy = AcceptRejectWarn.REJECT;
      // Create the server schema and initialize and register a minimal set of
      // matching rules and attribute syntaxes.
      directoryServer.schema = new Schema();
      directoryServer.schemaNG = new SchemaBuilder("mainSchema").addSchema(CoreSchema.getInstance(), true).toSchema();
      directoryServer.bootstrapMatchingRules();
      org.forgerock.opendj.ldap.schema.Schema coreSchema = org.forgerock.opendj.ldap.schema.Schema.getCoreSchema();
      directoryServer.schema = new Schema(coreSchema);
      directoryServer.bootstrapAttributeSyntaxes();
      // Perform any additional initialization that might be necessary before
@@ -1525,61 +1452,6 @@
  }
  /**
   * Registers a basic set of matching rules with the server that should always
   * be available regardless of the server configuration and may be needed for
   * configuration processing.
   */
  private void bootstrapMatchingRules()
  {
    MatchingRuleFactory<?>[] factories =
            new MatchingRuleFactory<?>[] {
              new DoubleMetaphoneApproximateMatchingRuleFactory(),
              new BooleanEqualityMatchingRuleFactory(),
              new CaseExactEqualityMatchingRuleFactory(),
              new CaseExactIA5EqualityMatchingRuleFactory(),
              new CaseIgnoreEqualityMatchingRuleFactory(),
              new CaseIgnoreIA5EqualityMatchingRuleFactory(),
              new DistinguishedNameEqualityMatchingRuleFactory(),
              new GeneralizedTimeEqualityMatchingRuleFactory(),
              new IntegerEqualityMatchingRuleFactory(),
              new OctetStringEqualityMatchingRuleFactory(),
              new ObjectIdentifierEqualityMatchingRuleFactory(),
              new TelephoneNumberEqualityMatchingRuleFactory(),
              new CaseExactOrderingMatchingRuleFactory(),
              new CaseIgnoreOrderingMatchingRuleFactory(),
              new GeneralizedTimeOrderingMatchingRuleFactory(),
              new IntegerOrderingMatchingRuleFactory(),
              new OctetStringOrderingMatchingRuleFactory(),
              new CaseExactSubstringMatchingRuleFactory(),
              new CaseExactIA5SubstringMatchingRuleFactory(),
              new CaseIgnoreSubstringMatchingRuleFactory(),
              new CaseIgnoreIA5SubstringMatchingRuleFactory(),
              new OctetStringSubstringMatchingRuleFactory(),
              new TelephoneNumberSubstringMatchingRuleFactory()};
    MatchingRuleFactory<?> currentFactory = null;
    try
    {
      for(MatchingRuleFactory<?> factory: factories)
      {
        currentFactory = factory;
        currentFactory.initializeMatchingRule(null);
        for(MatchingRule matchingRule: currentFactory.getMatchingRules())
        {
         registerMatchingRule(matchingRule, true);
        }
      }
    }
    catch (Exception e)
    {
      logger.traceException(e);
      logger.error(ERR_CANNOT_BOOTSTRAP_MATCHING_RULE, currentFactory.getClass().getName(),
              stackTraceToSingleLineString(e));
    }
  }
  /**
   * Registers a basic set of attribute syntaxes with the server that should
   * always be available regardless of the server configuration and may be
   * needed for configuration processing.
@@ -1722,7 +1594,7 @@
    schemaConfigManager.initializeSchemaFromFiles();
    // With server schema in place set compressed schema.
    compressedSchema = new DefaultCompressedSchema();
    compressedSchema = new DefaultCompressedSchema(serverContext);
    // At this point we have a problem, because none of the configuration is
    // usable because it was all read before we had a schema (and therefore all
@@ -2403,13 +2275,10 @@
  /**
   * Retrieves the set of matching rules registered with the Directory Server.
   * The mapping will be between the lowercase name or OID for each matching
   * rule and the matching rule implementation.  The same matching rule instance
   * may be included multiple times with different keys.
   *
   * @return  The set of matching rules registered with the Directory Server.
   */
  public static ConcurrentMap<String, MatchingRule> getMatchingRules()
  public static Collection<MatchingRule> getMatchingRules()
  {
    return directoryServer.schema.getMatchingRules();
  }
@@ -2638,7 +2507,7 @@
   * @return The set of attribute type definitions that have been
   *         defined in the Directory Server.
   */
  public static ConcurrentMap<String, AttributeType> getAttributeTypes()
  public static Collection<AttributeType> getAttributeTypes()
  {
    return directoryServer.schema.getAttributeTypes();
  }
@@ -2654,7 +2523,8 @@
   */
  public static AttributeType getAttributeTypeOrNull(String lowerName)
  {
    return directoryServer.schema.getAttributeType(lowerName);
    AttributeType attrType = directoryServer.schema.getAttributeType(lowerName);
    return attrType.isPlaceHolder() ? null : attrType;
  }
  /**
@@ -2706,12 +2576,7 @@
   */
  public static AttributeType getAttributeTypeOrDefault(String lowerName, String upperName, Syntax syntax)
  {
    AttributeType attrType = getAttributeTypeOrNull(lowerName);
    if (attrType == null)
    {
      attrType = getDefaultAttributeType(upperName, syntax);
    }
    return attrType;
    return directoryServer.schema.getAttributeType(upperName, syntax);
  }
  /**
@@ -2732,8 +2597,7 @@
                                           boolean overwriteExisting)
         throws DirectoryException
  {
    directoryServer.schema.registerAttributeType(attributeType,
                                                 overwriteExisting);
    directoryServer.schema.registerAttributeType(attributeType, overwriteExisting);
  }
  /**
@@ -2754,78 +2618,7 @@
   */
  public static AttributeType getObjectClassAttributeType()
  {
    if (directoryServer.objectClassAttributeType == null)
    {
      directoryServer.objectClassAttributeType =
           directoryServer.schema.getAttributeType(
                OBJECTCLASS_ATTRIBUTE_TYPE_NAME);
      if (directoryServer.objectClassAttributeType == null)
      {
        Syntax oidSyntax = directoryServer.schema.getSyntax(SYNTAX_OID_NAME);
        if (oidSyntax == null)
        {
          try
          {
            oidSyntax = CoreSchema.getOIDSyntax();
            directoryServer.schema.registerSyntax(oidSyntax, true);
          }
          catch (Exception e)
          {
            logger.traceException(e);
          }
        }
        String definition =
             "( 2.5.4.0 NAME 'objectClass' EQUALITY objectIdentifierMatch " +
             "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 X-ORIGIN 'RFC 2256' )";
        directoryServer.objectClassAttributeType =
            newAttributeType(definition, "objectClass", OBJECTCLASS_ATTRIBUTE_TYPE_OID, oidSyntax);
        try
        {
          directoryServer.schema.registerAttributeType(
                 directoryServer.objectClassAttributeType, true);
        }
        catch (Exception e)
        {
          // This should never happen.
          logger.traceException(e);
        }
      }
    }
    return directoryServer.objectClassAttributeType;
  }
  /**
   * Causes the Directory Server to construct a new attribute type definition
   * with the provided name and syntax.  This should only be used if there is no
   * real attribute type for the specified name.
   * <p>
   * TODO remove once we switch to the SDK Schema
   * <p>
   * FIXME move to {@link org.opends.server.types.Schema}?
   *
   * @param  name    The name to use for the attribute type, as provided by the user.
   * @param  syntax  The syntax to use for the attribute type.
   *
   * @return  The constructed attribute type definition.
   */
  public static AttributeType getDefaultAttributeType(String name, Syntax syntax)
  {
    String oid        = toLowerCase(name) + "-oid";
    String definition = "( " + oid + " NAME '" + name + "' SYNTAX " +
                        syntax.getOID() + " )";
    // Temporary attribute types are immediately dirty.
    return newAttributeType(definition, name, oid, syntax).setDirty();
  }
  private static AttributeType newAttributeType(String definition, String name, String oid, Syntax syntax)
  {
    return new AttributeType(definition, name, Collections.singleton(name), oid, null, null, syntax,
        AttributeUsage.USER_APPLICATIONS, false, false, false, false);
    return directoryServer.schema.getAttributeType(OBJECTCLASS_ATTRIBUTE_TYPE_NAME);
  }
  /**
@@ -2833,7 +2626,7 @@
   *
   * @return The set of attribute syntaxes defined in the Directory Server.
   */
  public static ConcurrentMap<String, Syntax> getAttributeSyntaxes()
  public static Collection<Syntax> getAttributeSyntaxes()
  {
    return directoryServer.schema.getSyntaxes();
  }
@@ -6447,7 +6240,6 @@
    cryptoManager            = null;
    entryCache               = null;
    environmentConfig        = null;
    objectClassAttributeType = null;
    schemaDN                 = null;
    shutdownHook             = null;
    workQueue                = null;
opendj-server-legacy/src/main/java/org/opends/server/core/MatchingRuleConfigManager.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.core;
@@ -36,7 +36,9 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.config.server.ConfigChangeResult;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.forgerock.util.Utils;
import org.opends.server.admin.ClassPropertyDefinition;
@@ -48,12 +50,12 @@
import org.opends.server.admin.std.server.MatchingRuleCfg;
import org.opends.server.admin.std.server.RootCfg;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.config.server.ConfigChangeResult;
import org.opends.server.schema.CollationMatchingRuleFactory;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.InitializationException;
import org.opends.server.types.MatchingRuleUse;
import org.opends.server.types.Schema;
/**
 * This class defines a utility that will be used to manage the set of matching
@@ -76,9 +78,17 @@
   */
  private ConcurrentHashMap<DN,MatchingRuleFactory> matchingRuleFactories;
  /** Creates a new instance of this matching rule config manager. */
  public MatchingRuleConfigManager()
  private final ServerContext serverContext;
  /**
   * Creates a new instance of this matching rule config manager.
   *
   * @param serverContext
   *          The server context.
   */
  public MatchingRuleConfigManager(ServerContext serverContext)
  {
    this.serverContext = serverContext;
    matchingRuleFactories = new ConcurrentHashMap<>();
  }
@@ -100,8 +110,7 @@
         throws ConfigException, InitializationException
  {
    // Get the root configuration object.
    ServerManagementContext managementContext =
         ServerManagementContext.getInstance();
    ServerManagementContext managementContext = ServerManagementContext.getInstance();
    RootCfg rootConfiguration =
         managementContext.getRootConfiguration();
@@ -111,7 +120,6 @@
    rootConfiguration.addMatchingRuleAddListener(this);
    rootConfiguration.addMatchingRuleDeleteListener(this);
    //Initialize the existing matching rules.
    for (String name : rootConfiguration.listMatchingRules())
    {
@@ -123,14 +131,18 @@
        String className = mrConfiguration.getJavaClass();
        try
        {
          MatchingRuleFactory<?> factory =
               loadMatchingRuleFactory(className, mrConfiguration, true);
          MatchingRuleFactory<?> factory = loadMatchingRuleFactory(className, mrConfiguration, true);
          try
          {
            for(MatchingRule matchingRule: factory.getMatchingRules())
            {
              DirectoryServer.registerMatchingRule(matchingRule, false);
              Schema schema = serverContext.getSchema();
              // skip the matching rule registration if already defined in the (core) schema
              if (!schema.hasMatchingRule(matchingRule.getNameOrOID()))
              {
                DirectoryServer.registerMatchingRule(matchingRule, false);
              }
            }
            matchingRuleFactories.put(mrConfiguration.dn(), factory);
          }
@@ -237,7 +249,7 @@
    {
      if (matchingRule != null)
      {
        for (AttributeType at : DirectoryServer.getAttributeTypes().values())
        for (AttributeType at : DirectoryServer.getAttributeTypes())
        {
          final String attr = at.getNameOrOID();
          if (!isDeleteAcceptable(at.getApproximateMatchingRule(), matchingRule, attr, unacceptableReasons)
@@ -339,7 +351,7 @@
      {
        if (matchingRule != null)
        {
          for (AttributeType at : DirectoryServer.getAttributeTypes().values())
          for (AttributeType at : DirectoryServer.getAttributeTypes())
          {
            final String attr = at.getNameOrOID();
            if (!isDisableAcceptable(at.getApproximateMatchingRule(), matchingRule, attr, unacceptableReasons)
@@ -488,6 +500,13 @@
           propertyDefinition.loadClass(className,
                                        MatchingRuleFactory.class);
      factory = matchingRuleFactoryClass.newInstance();
      // specific behavior for collation
      // in order to avoid useless injection of context server for all factories
      if (factory instanceof CollationMatchingRuleFactory)
      {
        CollationMatchingRuleFactory collationFactory = (CollationMatchingRuleFactory) factory;
        collationFactory.setServerContext(serverContext);
      }
      if (initialize)
      {
opendj-server-legacy/src/main/java/org/opends/server/core/ModifyOperationBasis.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2007-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2012-2015 ForgeRock AS.
 *      Portions Copyright 2012-2016 ForgeRock AS.
 */
package org.opends.server.core;
@@ -36,6 +36,7 @@
import org.opends.server.protocols.ldap.LDAPAttribute;
import org.opends.server.protocols.ldap.LDAPModification;
import org.opends.server.protocols.ldap.LDAPResultCode;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import org.opends.server.types.operation.PostResponseModifyOperation;
import org.opends.server.types.operation.PreParseModifyOperation;
opendj-server-legacy/src/main/java/org/opends/server/core/PasswordPolicy.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions copyright 2011-2015 ForgeRock AS.
 *      Portions copyright 2011-2016 ForgeRock AS.
 */
package org.opends.server.core;
@@ -33,7 +33,7 @@
import org.opends.server.admin.std.meta.PasswordPolicyCfgDefn.*;
import org.opends.server.api.*;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
opendj-server-legacy/src/main/java/org/opends/server/core/PasswordPolicyFactory.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS.
 *      Portions Copyright 2011-2016 ForgeRock AS.
 */
package org.opends.server.core;
@@ -46,6 +46,7 @@
import org.opends.server.admin.std.meta.PasswordPolicyCfgDefn.StateUpdateFailurePolicy;
import org.opends.server.admin.std.server.PasswordPolicyCfg;
import org.opends.server.api.*;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
/**
opendj-server-legacy/src/main/java/org/opends/server/core/PasswordPolicyState.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.core;
@@ -72,7 +72,7 @@
import org.opends.server.types.AccountStatusNotificationType;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeBuilder;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.Attributes;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
opendj-server-legacy/src/main/java/org/opends/server/core/SchemaConfigManager.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.core;
@@ -38,8 +38,9 @@
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.forgerock.opendj.ldap.schema.SchemaBuilder;
import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.schema.*;
import org.opends.server.types.*;
@@ -80,7 +81,9 @@
  public SchemaConfigManager(ServerContext serverContext)
  {
    this.serverContext = serverContext;
    schema = new Schema();
    // the manager will build the schema from scratch, but we need to start from
    // core schema for SDK schema
    schema = new Schema(org.forgerock.opendj.ldap.schema.Schema.getCoreSchema());
  }
@@ -134,8 +137,7 @@
  public void initializeMatchingRules()
         throws ConfigException, InitializationException
  {
    MatchingRuleConfigManager matchingRuleConfigManager =
         new MatchingRuleConfigManager();
    MatchingRuleConfigManager matchingRuleConfigManager = new MatchingRuleConfigManager(serverContext);
    matchingRuleConfigManager.initializeMatchingRules();
  }
@@ -300,7 +302,7 @@
    // from that entry and parse them to initialize the server schema.
    for (String schemaFile : fileNames)
    {
      loadSchemaFile(serverContext, schema, schemaFile, false);
      loadSchemaFile(schema, schemaFile, false);
    }
  }
@@ -309,9 +311,6 @@
  /**
   * Loads the contents of the specified schema file into the provided schema.
   *
   * @param serverContext
   *          The server context.
   *
   * @param  schema      The schema in which the contents of the schema file are
   *                     to be loaded.
   * @param  schemaFile  The name of the schema file to be loaded into the
@@ -327,10 +326,10 @@
   *                                   the schema elements that is not related
   *                                   to the server configuration.
   */
  public static List<Modification> loadSchemaFile(ServerContext serverContext, Schema schema, String schemaFile)
  public static List<Modification> loadSchemaFile(Schema schema, String schemaFile)
         throws ConfigException, InitializationException
  {
    return loadSchemaFile(serverContext, schema, schemaFile, true);
    return loadSchemaFile(schema, schemaFile, true);
  }
@@ -360,7 +359,7 @@
   *                                   the schema elements that is not related
   *                                   to the server configuration.
   */
  private static List<Modification> loadSchemaFile(ServerContext serverContext, Schema schema, String schemaFile,
  private static List<Modification> loadSchemaFile(Schema schema, String schemaFile,
      boolean failOnError) throws ConfigException, InitializationException
  {
    // Create an LDIF reader to use when reading the files.
@@ -464,8 +463,7 @@
      }
    }
    parseLdapSyntaxesDefinitions(serverContext, schema, schemaFile, failOnError,
        ldapSyntaxList);
    parseLdapSyntaxesDefinitions(schema, schemaFile, failOnError, ldapSyntaxList);
    parseAttributeTypeDefinitions(schema, schemaFile, failOnError, attrList);
    parseObjectclassDefinitions(schema, schemaFile, failOnError, ocList);
    parseNameFormDefinitions(schema, schemaFile, failOnError, nfList);
@@ -485,7 +483,7 @@
      syntax = CoreSchema.getLDAPSyntaxDescriptionSyntax();
    }
    AttributeType ldapSyntaxAttrType = getAttributeType(schema, ATTR_LDAP_SYNTAXES, ATTR_LDAP_SYNTAXES_LC, syntax);
    AttributeType ldapSyntaxAttrType = schema.getAttributeType(ATTR_LDAP_SYNTAXES, syntax);
    return createAddModifications(entry, mods, ldapSyntaxAttrType);
  }
@@ -498,8 +496,7 @@
    {
      syntax = CoreSchema.getAttributeTypeDescriptionSyntax();
    }
    AttributeType attributeAttrType = getAttributeType(
        schema, ATTR_ATTRIBUTE_TYPES, ATTR_ATTRIBUTE_TYPES_LC, syntax);
    AttributeType attributeAttrType = schema.getAttributeType(ATTR_ATTRIBUTE_TYPES, syntax);
    return createAddModifications(entry, mods, attributeAttrType);
  }
@@ -513,7 +510,7 @@
    {
      syntax = CoreSchema.getObjectClassDescriptionSyntax();
    }
    AttributeType objectclassAttrType = getAttributeType(schema, ATTR_OBJECTCLASSES, ATTR_OBJECTCLASSES_LC, syntax);
    AttributeType objectclassAttrType = schema.getAttributeType(ATTR_OBJECTCLASSES, syntax);
    return createAddModifications(entry, mods, objectclassAttrType);
  }
@@ -527,8 +524,7 @@
    {
      syntax = CoreSchema.getNameFormDescriptionSyntax();
    }
    AttributeType nameFormAttrType = getAttributeType(
        schema, ATTR_NAME_FORMS, ATTR_NAME_FORMS_LC, syntax);
    AttributeType nameFormAttrType = schema.getAttributeType(ATTR_NAME_FORMS, syntax);
    return createAddModifications(entry, mods, nameFormAttrType);
  }
@@ -542,8 +538,7 @@
    {
      syntax = CoreSchema.getDITContentRuleDescriptionSyntax();
    }
    AttributeType dcrAttrType = getAttributeType(
        schema, ATTR_DIT_CONTENT_RULES, ATTR_DIT_CONTENT_RULES_LC, syntax);
    AttributeType dcrAttrType = schema.getAttributeType(ATTR_DIT_CONTENT_RULES, syntax);
    return createAddModifications(entry, mods, dcrAttrType);
  }
@@ -557,7 +552,7 @@
    {
      syntax = CoreSchema.getDITStructureRuleDescriptionSyntax();
    }
    AttributeType dsrAttrType = getAttributeType(schema, ATTR_DIT_STRUCTURE_RULES, ATTR_DIT_STRUCTURE_RULES_LC, syntax);
    AttributeType dsrAttrType = schema.getAttributeType(ATTR_DIT_STRUCTURE_RULES, syntax);
    return createAddModifications(entry, mods, dsrAttrType);
  }
@@ -571,21 +566,10 @@
    {
      syntax = CoreSchema.getMatchingRuleUseDescriptionSyntax();
    }
    AttributeType mruAttrType = getAttributeType(schema, ATTR_MATCHING_RULE_USE, ATTR_MATCHING_RULE_USE_LC, syntax);
    AttributeType mruAttrType = schema.getAttributeType(ATTR_MATCHING_RULE_USE, syntax);
    return createAddModifications(entry, mods, mruAttrType);
  }
  private static AttributeType getAttributeType(Schema schema, String attrName,
      String attrLowerName, Syntax syntax)
  {
    final AttributeType attrType = schema.getAttributeType(attrLowerName);
    if (attrType != null)
    {
      return attrType;
    }
    return DirectoryServer.getDefaultAttributeType(attrName, syntax);
  }
  private static List<Attribute> createAddModifications(Entry entry,
      List<Modification> mods, AttributeType attrType)
  {
@@ -598,7 +582,7 @@
  }
  /** Parse the ldapsyntaxes definitions if there are any. */
  private static void parseLdapSyntaxesDefinitions(ServerContext serverContext, Schema schema,
  private static void parseLdapSyntaxesDefinitions(Schema schema,
      String schemaFile, boolean failOnError, List<Attribute> ldapSyntaxList)
      throws ConfigException
  {
@@ -608,56 +592,36 @@
      {
        for (ByteString v : a)
        {
          LDAPSyntaxDescription syntaxDescription;
          final String definition = Schema.addSchemaFileToElementDefinitionIfAbsent(v.toString(), schemaFile);
          try
          {
            syntaxDescription = LDAPSyntaxDescriptionSyntax.decodeLDAPSyntax(v, serverContext, schema, false, false);
            setExtraProperty(syntaxDescription, SCHEMA_PROPERTY_FILENAME, null);
            setSchemaFile(syntaxDescription, schemaFile);
            schema.registerLdapSyntaxDescription(definition, failOnError);
          }
          catch (DirectoryException de)
          {
            logger.traceException(de);
            LocalizableMessage message = WARN_CONFIG_SCHEMA_CANNOT_PARSE_LDAP_SYNTAX.get(
                    schemaFile,
                    de.getMessageObject());
            reportError(failOnError, de, message);
            continue;
          }
          catch (Exception e)
          {
            logger.traceException(e);
            LocalizableMessage message = WARN_CONFIG_SCHEMA_CANNOT_PARSE_LDAP_SYNTAX.get(
                    schemaFile, v + ":  " + getExceptionMessage(e));
            reportError(failOnError, e, message);
            continue;
          }
           // Register it with the schema.  We will allow duplicates, with the
          // later definition overriding any earlier definition, but we want
          // to trap them and log a warning.
          try
          {
            schema.registerLdapSyntaxDescription(syntaxDescription, failOnError);
            registerLdapSyntaxInSchemaNG(serverContext, syntaxDescription, failOnError);
          }
          catch (DirectoryException de)
          {
            logger.traceException(de);
            logger.warn(WARN_CONFIG_SCHEMA_CONFLICTING_LDAP_SYNTAX, schemaFile, de.getMessageObject());
            try
            if (de.getResultCode().equals(ResultCode.CONSTRAINT_VIOLATION))
            {
              schema.registerLdapSyntaxDescription(syntaxDescription, true);
              registerLdapSyntaxInSchemaNG(serverContext, syntaxDescription, true);
              // Register it with the schema.  We will allow duplicates, with the
              // later definition overriding any earlier definition, but we want
              // to trap them and log a warning.
              logger.warn(WARN_CONFIG_SCHEMA_CONFLICTING_LDAP_SYNTAX, schemaFile, de.getMessageObject());
              try
              {
                schema.registerLdapSyntaxDescription(definition, true);
              }
              catch (Exception e)
              {
                // This should never happen.
                logger.traceException(e);
              }
            }
            catch (Exception e)
            else
            {
              // This should never happen.
              logger.traceException(e);
              LocalizableMessage message = WARN_CONFIG_SCHEMA_CANNOT_PARSE_LDAP_SYNTAX.get(
                  schemaFile, de.getMessageObject());
              reportError(failOnError, de, message);
            }
          }
        }
@@ -665,81 +629,50 @@
    }
  }
  private static void registerLdapSyntaxInSchemaNG(ServerContext serverContext, LDAPSyntaxDescription syntaxDescription,
      boolean overwrite)
  {
     // The server context may be null when this code is reached through non-server code (e.g. gui tools)
     if (serverContext != null)
     {
        SchemaUpdater schemaUpdater = serverContext.getSchemaUpdater();
        Syntax.Builder builder = schemaUpdater.getSchemaBuilder().buildSyntax(syntaxDescription.getSyntax());
        SchemaBuilder schemaBuilder = overwrite ? builder.addToSchemaOverwrite() : builder.addToSchema();
        schemaUpdater.updateSchema(schemaBuilder.toSchema());
     }
  }
  /** Parse the attribute type definitions if there are any. */
  private static void parseAttributeTypeDefinitions(Schema schema,
      String schemaFile, boolean failOnError, List<Attribute> attrList)
      throws ConfigException
  private static void parseAttributeTypeDefinitions(
      Schema schema, String schemaFile, boolean failOnError, List<Attribute> attrList)
          throws ConfigException
  {
    if (attrList != null)
    {
      List<String> definitions = new ArrayList<>();
      for (Attribute a : attrList)
      {
        for (ByteString v : a)
        {
          // Parse the attribute type.
          AttributeType attrType;
          try
          {
            attrType = AttributeTypeSyntax.decodeAttributeType(v, schema, false);
            setExtraProperty(attrType, SCHEMA_PROPERTY_FILENAME, null);
            setSchemaFile(attrType, schemaFile);
          }
          catch (DirectoryException de)
          {
            logger.traceException(de);
          definitions.add(v.toString());
        }
      }
      try
      {
        schema.registerAttributeTypes(definitions, schemaFile, !failOnError);
      }
      catch (DirectoryException de)
      {
        logger.traceException(de);
            LocalizableMessage message = WARN_CONFIG_SCHEMA_CANNOT_PARSE_ATTR_TYPE.get(
                    schemaFile, de.getMessageObject());
            reportError(failOnError, de, message);
            continue;
          }
          catch (Exception e)
          {
            logger.traceException(e);
            LocalizableMessage message = WARN_CONFIG_SCHEMA_CANNOT_PARSE_ATTR_TYPE.get(
                    schemaFile, v + ":  " + getExceptionMessage(e));
            reportError(failOnError, e, message);
            continue;
          }
          // Register it with the schema.  We will allow duplicates, with the
        if (de.getResultCode().equals(ResultCode.CONSTRAINT_VIOLATION))
        {
          // Register it with the schema. We will allow duplicates, with the
          // later definition overriding any earlier definition, but we want
          // to trap them and log a warning.
          logger.warn(WARN_CONFIG_SCHEMA_CONFLICTING_ATTR_TYPE, schemaFile, de.getMessageObject());
          try
          {
            schema.registerAttributeType(attrType, failOnError);
            schema.registerAttributeTypes(definitions, schemaFile, true);
          }
          catch (DirectoryException de)
          catch (DirectoryException e)
          {
            logger.traceException(de);
            logger.warn(WARN_CONFIG_SCHEMA_CONFLICTING_ATTR_TYPE, schemaFile, de.getMessageObject());
            try
            {
              schema.registerAttributeType(attrType, true);
            }
            catch (Exception e)
            {
              // This should never happen.
              logger.traceException(e);
            }
            // This should never happen
            logger.traceException(e);
          }
        }
        else
        {
          LocalizableMessage message = WARN_CONFIG_SCHEMA_CANNOT_PARSE_ATTR_TYPE.get(schemaFile, de.getMessageObject());
          reportError(failOnError, de, message);
        }
      }
    }
  }
opendj-server-legacy/src/main/java/org/opends/server/core/SchemaHandler.java
@@ -21,12 +21,15 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2014-2015 ForgeRock AS
 *      Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.core;
import static org.forgerock.util.Utils.*;
import static org.opends.messages.ConfigMessages.*;
import static org.opends.server.replication.plugin.HistoricalCsnOrderingMatchingRuleImpl.*;
import static org.opends.server.schema.AciSyntax.*;
import static org.opends.server.schema.SubtreeSpecificationSyntax.*;
import static org.opends.server.util.StaticUtils.*;
import java.io.File;
@@ -51,8 +54,10 @@
import org.forgerock.opendj.server.config.server.SchemaProviderCfg;
import org.forgerock.util.Utils;
import org.opends.server.schema.SchemaProvider;
import org.opends.server.schema.SchemaUpdater;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.InitializationException;
import org.opends.server.types.Schema.SchemaUpdater;
import org.opends.server.util.ActivateOnceSDKSchemaIsUsed;
/**
 * Responsible for loading the server schema.
@@ -64,6 +69,7 @@
 *   <li>Load all schema files located in the schema directory.</li>
 * </ul>
 */
@ActivateOnceSDKSchemaIsUsed
public final class SchemaHandler
{
  private static final String CORE_SCHEMA_PROVIDER_NAME = "Core Schema";
@@ -101,18 +107,47 @@
    this.serverContext = serverContext;
    final RootCfg rootConfiguration = serverContext.getServerManagementContext().getRootConfiguration();
    final SchemaUpdater schemaUpdater = serverContext.getSchemaUpdater();
    final org.opends.server.types.Schema schema = serverContext.getSchema();
    // Start from the core schema (TODO: or start with empty schema and add core schema in core schema provider ?)
    final SchemaBuilder schemaBuilder = new SchemaBuilder(Schema.getCoreSchema());
    schema.exclusiveLock();
    try
    {
      // Start from the core schema (TODO: or start with empty schema and add core schema in core schema provider ?)
      final SchemaBuilder schemaBuilder = new SchemaBuilder(Schema.getCoreSchema());
    // Take providers into account.
    loadSchemaFromProviders(rootConfiguration, schemaBuilder, schemaUpdater);
      // Take providers into account.
      loadSchemaFromProviders(rootConfiguration, schemaBuilder);
    // Take schema files into account (TODO : or load files using provider mechanism ?)
    completeSchemaFromFiles(schemaBuilder);
      // Take schema files into account (TODO : or load files using provider mechanism ?)
      completeSchemaFromFiles(schemaBuilder);
    schemaUpdater.updateSchema(schemaBuilder.toSchema());
      try
      {
        schema.updateSchema(new SchemaUpdater()
        {
          @Override
          public Schema update(SchemaBuilder ignored)
          {
            // see RemoteSchemaLoader.readSchema()
            addAciSyntax(schemaBuilder);
            addSubtreeSpecificationSyntax(schemaBuilder);
            addHistoricalCsnOrderingMatchingRule(schemaBuilder);
            // Uses the builder incrementally updated instead of the default provided by the method.
            // This is why it is necessary to explicitly lock/unlock the schema updater.
            return schemaBuilder.toSchema();
          }
        });
      }
      catch (DirectoryException e)
      {
        throw new ConfigException(e.getMessageObject(), e);
      }
    }
    finally
    {
      schema.exclusiveUnlock();
    }
  }
  /**
@@ -123,22 +158,21 @@
   * @param schemaBuilder
   *          The schema builder that providers should update.
   * @param schemaUpdater
   *          The updater that providers should use when applying a
   *          configuration change.
   *          The updater that providers should use when applying a configuration change.
   */
  private void loadSchemaFromProviders(final RootCfg rootConfiguration, final SchemaBuilder schemaBuilder,
      final SchemaUpdater schemaUpdater)  throws ConfigException, InitializationException {
  private void loadSchemaFromProviders(final RootCfg rootConfiguration, final SchemaBuilder schemaBuilder)
      throws ConfigException, InitializationException {
    for (final String name : rootConfiguration.listSchemaProviders())
    {
      final SchemaProviderCfg config = rootConfiguration.getSchemaProvider(name);
      if (config.isEnabled())
      {
        loadSchemaProvider(config.getJavaClass(), config, schemaBuilder, schemaUpdater, true);
        loadSchemaProvider(config.getJavaClass(), config, schemaBuilder, true);
      }
      else if (name.equals(CORE_SCHEMA_PROVIDER_NAME)) {
      else if (name.equals(CORE_SCHEMA_PROVIDER_NAME))
      {
        // TODO : use correct message ERR_CORE_SCHEMA_NOT_ENABLED
        LocalizableMessage message = LocalizableMessage.raw("Core Schema can't be disabled");
        throw new ConfigException(message);
        throw new ConfigException(LocalizableMessage.raw("Core Schema can't be disabled"));
      }
    }
  }
@@ -147,11 +181,10 @@
   * Load the schema provider from the provided class name.
   * <p>
   * If {@code} initialize} is {@code true}, then the provider is initialized,
   * and the provided schema builder is updated with schema elements fropm the
   * provider.
   * and the provided schema builder is updated with schema elements from the provider.
   */
  private <T extends SchemaProviderCfg> SchemaProvider<T> loadSchemaProvider(final String className,
      final T config, final SchemaBuilder schemaBuilder, final SchemaUpdater schemaUpdater, final boolean initialize)
      final T config, final SchemaBuilder schemaBuilder, final boolean initialize)
      throws InitializationException
  {
    try
@@ -160,13 +193,14 @@
      final Class<? extends SchemaProvider> providerClass = propertyDef.loadClass(className, SchemaProvider.class);
      final SchemaProvider<T> provider = providerClass.newInstance();
      if (initialize) {
        provider.initialize(config, schemaBuilder, schemaUpdater);
      if (initialize)
      {
        provider.initialize(serverContext, config, schemaBuilder);
      }
      else {
      else
      {
        final List<LocalizableMessage> unacceptableReasons = new ArrayList<>();
        final boolean isAcceptable = provider.isConfigurationAcceptable(config, unacceptableReasons);
        if (!isAcceptable)
        if (!provider.isConfigurationAcceptable(config, unacceptableReasons))
        {
          final String reasons = Utils.joinAsString(".  ", unacceptableReasons);
          // TODO : fix message, eg CONFIG SCHEMA PROVIDER CONFIG NOT ACCEPTABLE
@@ -176,11 +210,11 @@
      return provider;
    }
    catch (Exception e)
      {
        // TODO : fix message
        throw new InitializationException(ERR_CONFIG_SCHEMA_SYNTAX_CANNOT_INITIALIZE.
            get(className, config.dn(), stackTraceToSingleLineString(e)), e);
      }
    {
      // TODO : fix message
      throw new InitializationException(ERR_CONFIG_SCHEMA_SYNTAX_CANNOT_INITIALIZE.get(
          className, config.dn(), stackTraceToSingleLineString(e)), e);
    }
  }
  /**
opendj-server-legacy/src/main/java/org/opends/server/core/SearchOperationBasis.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.core;
@@ -49,7 +49,7 @@
import org.opends.server.types.AbstractOperation;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeBuilder;
import org.opends.server.types.AttributeType;
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;
opendj-server-legacy/src/main/java/org/opends/server/core/ServerContext.java
@@ -21,14 +21,13 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2014-2015 ForgeRock AS.
 *      Copyright 2014-2016 ForgeRock AS.
 */
package org.opends.server.core;
import org.forgerock.opendj.config.server.ServerManagementContext;
import org.opends.server.extensions.DiskSpaceMonitor;
import org.opends.server.loggers.CommonAudit;
import org.opends.server.schema.SchemaUpdater;
import org.opends.server.types.DirectoryEnvironmentConfig;
import org.opends.server.types.Schema;
@@ -71,14 +70,6 @@
  org.forgerock.opendj.ldap.schema.Schema getSchemaNG();
  /**
   * Returns the schema updater, which provides
   * a mean to update the server's current schema.
   *
   * @return the schema updater
   */
  SchemaUpdater getSchemaUpdater();
  /**
   * Returns the environment of the server.
   *
   * @return the environment
opendj-server-legacy/src/main/java/org/opends/server/core/SubentryPasswordPolicy.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS.
 *      Portions Copyright 2011-2016 ForgeRock AS.
 */
package org.opends.server.core;
@@ -39,6 +39,7 @@
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.admin.std.meta.PasswordPolicyCfgDefn.StateUpdateFailurePolicy;
import org.opends.server.admin.std.server.PasswordValidatorCfg;
import org.opends.server.api.AccountStatusNotificationHandler;
opendj-server-legacy/src/main/java/org/opends/server/crypto/CryptoManagerImpl.java
@@ -23,7 +23,7 @@
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2009 Parametric Technology Corporation (PTC)
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.crypto;
@@ -79,6 +79,7 @@
import org.opends.server.tools.LDAPConnectionOptions;
import org.opends.server.tools.LDAPReader;
import org.opends.server.tools.LDAPWriter;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import org.opends.server.util.Base64;
import org.opends.server.util.SelectableCertificateKeyManager;
opendj-server-legacy/src/main/java/org/opends/server/crypto/CryptoManagerSync.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.crypto;
@@ -60,7 +60,7 @@
import org.opends.server.protocols.internal.SearchRequest;
import org.opends.server.protocols.ldap.LDAPControl;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.Control;
import org.opends.server.types.CryptoManagerException;
import org.opends.server.types.DN;
opendj-server-legacy/src/main/java/org/opends/server/extensions/AttributeValuePasswordValidator.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Portions Copyright 2012-2015 ForgeRock AS.
 *      Portions Copyright 2012-2016 ForgeRock AS.
 */
package org.opends.server.extensions;
@@ -35,6 +35,7 @@
import org.opends.server.admin.std.server.AttributeValuePasswordValidatorCfg;
import org.opends.server.admin.std.server.PasswordValidatorCfg;
import org.opends.server.api.PasswordValidator;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import org.forgerock.opendj.config.server.ConfigChangeResult;
import org.forgerock.opendj.ldap.ByteString;
opendj-server-legacy/src/main/java/org/opends/server/extensions/ConfigFileHandler.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.extensions;
@@ -75,6 +75,7 @@
import org.opends.server.core.ServerContext;
import org.opends.server.schema.GeneralizedTimeSyntax;
import org.opends.server.tools.LDIFModify;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import org.opends.server.util.BackupManager;
import org.opends.server.util.LDIFException;
opendj-server-legacy/src/main/java/org/opends/server/extensions/DiskSpaceMonitor.java
@@ -22,7 +22,7 @@
 *
 *
 *       Copyright 2010 Sun Microsystems, Inc.
 *       Portions Copyright 2014-2015 ForgeRock AS
 *       Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.extensions;
@@ -56,7 +56,7 @@
import org.opends.server.api.ServerShutdownListener;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.Attributes;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
opendj-server-legacy/src/main/java/org/opends/server/extensions/DynamicGroup.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.extensions;
@@ -37,12 +37,12 @@
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.SearchScope;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.admin.std.server.DynamicGroupImplementationCfg;
import org.opends.server.api.Group;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.ServerContext;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryConfig;
import org.opends.server.types.DirectoryException;
opendj-server-legacy/src/main/java/org/opends/server/extensions/EntryDNVirtualAttributeProvider.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2012-2015 ForgeRock AS
 *      Portions Copyright 2012-2016 ForgeRock AS
 */
package org.opends.server.extensions;
@@ -38,6 +38,7 @@
import org.opends.server.api.VirtualAttributeProvider;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.SearchOperation;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import static org.opends.server.util.ServerConstants.*;
opendj-server-legacy/src/main/java/org/opends/server/extensions/ExactMatchIdentityMapper.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.extensions;
@@ -50,6 +50,7 @@
import org.opends.server.protocols.internal.InternalSearchOperation;
import org.opends.server.protocols.internal.SearchRequest;
import static org.opends.server.protocols.internal.Requests.*;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import static org.opends.messages.ExtensionMessages.*;
opendj-server-legacy/src/main/java/org/opends/server/extensions/ExternalSASLMechanismHandler.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2015 ForgeRock AS
 *      Portions Copyright 2013-2016 ForgeRock AS
 */
package org.opends.server.extensions;
@@ -44,6 +44,7 @@
import org.opends.server.core.BindOperation;
import org.opends.server.core.DirectoryServer;
import org.opends.server.protocols.ldap.LDAPClientConnection;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import static org.opends.messages.ExtensionMessages.*;
opendj-server-legacy/src/main/java/org/opends/server/extensions/FingerprintCertificateMapper.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2007-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2012-2015 ForgeRock AS
 *      Portions Copyright 2012-2016 ForgeRock AS
 */
package org.opends.server.extensions;
@@ -53,6 +53,7 @@
import org.opends.server.protocols.internal.InternalSearchOperation;
import org.opends.server.protocols.internal.SearchRequest;
import static org.opends.server.protocols.internal.Requests.*;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import static org.opends.messages.ExtensionMessages.*;
opendj-server-legacy/src/main/java/org/opends/server/extensions/GoverningStructureRuleVirtualAttributeProvider.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2009 Sun Microsystems, Inc.
 *      Portions Copyright 2012-2015 ForgeRock AS
 *      Portions Copyright 2012-2016 ForgeRock AS
 */
package org.opends.server.extensions;
@@ -36,6 +36,7 @@
import org.opends.server.api.VirtualAttributeProvider;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.SearchOperation;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import static org.opends.messages.ExtensionMessages.*;
opendj-server-legacy/src/main/java/org/opends/server/extensions/IsMemberOfVirtualAttributeProvider.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.extensions;
@@ -39,6 +39,7 @@
import org.opends.server.api.VirtualAttributeProvider;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.SearchOperation;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import static org.opends.server.util.ServerConstants.*;
opendj-server-legacy/src/main/java/org/opends/server/extensions/LDAPPassThroughAuthenticationPolicyFactory.java
@@ -21,7 +21,7 @@
 * CDDL HEADER END
 *
 *
 *      Portions Copyright 2011-2015 ForgeRock AS.
 *      Portions Copyright 2011-2016 ForgeRock AS.
 */
package org.opends.server.extensions;
@@ -48,6 +48,7 @@
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.meta.LDAPPassThroughAuthenticationPolicyCfgDefn.MappingPolicy;
import org.opends.server.admin.std.server.LDAPPassThroughAuthenticationPolicyCfg;
@@ -67,7 +68,6 @@
import org.opends.server.tools.LDAPReader;
import org.opends.server.tools.LDAPWriter;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
opendj-server-legacy/src/main/java/org/opends/server/extensions/PasswordModifyExtendedOperation.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.extensions;
@@ -57,6 +57,7 @@
import org.forgerock.opendj.ldap.ByteStringBuilder;
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.server.ExtendedOperationHandlerCfg;
import org.opends.server.admin.std.server.PasswordModifyExtendedOperationHandlerCfg;
@@ -78,7 +79,6 @@
import org.opends.server.types.AccountStatusNotificationProperty;
import org.opends.server.types.AdditionalLogItem;
import org.opends.server.types.AttributeBuilder;
import org.opends.server.types.AttributeType;
import org.opends.server.types.AuthenticationInfo;
import org.opends.server.types.Control;
import org.opends.server.types.DN;
opendj-server-legacy/src/main/java/org/opends/server/extensions/RegularExpressionIdentityMapper.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.extensions;
@@ -57,6 +57,7 @@
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.protocols.internal.InternalSearchOperation;
import org.opends.server.protocols.internal.SearchRequest;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
/**
opendj-server-legacy/src/main/java/org/opends/server/extensions/SMTPAccountStatusNotificationHandler.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 *      Portions copyright 2015 Edan Idzerda
 */
package org.opends.server.extensions;
@@ -46,6 +46,7 @@
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.util.Utils;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.server.AccountStatusNotificationHandlerCfg;
@@ -56,7 +57,6 @@
import org.opends.server.types.AccountStatusNotificationProperty;
import org.opends.server.types.AccountStatusNotificationType;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.Entry;
import org.opends.server.types.InitializationException;
import org.opends.server.util.EMailMessage;
opendj-server-legacy/src/main/java/org/opends/server/extensions/StaticGroup.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.extensions;
@@ -51,7 +51,7 @@
import org.opends.server.core.ServerContext;
import org.opends.server.protocols.ldap.LDAPControl;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.Attributes;
import org.opends.server.types.Control;
import org.opends.server.types.DN;
opendj-server-legacy/src/main/java/org/opends/server/extensions/SubjectAttributeToUserAttributeCertificateMapper.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2007-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2012-2015 ForgeRock AS
 *      Portions Copyright 2012-2016 ForgeRock AS
 *      Portions Copyright 2013 Manuel Gaupp
 */
package org.opends.server.extensions;
@@ -59,7 +59,7 @@
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.protocols.internal.InternalSearchOperation;
import org.opends.server.protocols.internal.SearchRequest;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
@@ -421,7 +421,7 @@
  /**
   * Tries to normalize the given attribute name; if normalization is not
   * Normalizes the given attribute name; if normalization is not
   * possible the original String value is returned.
   *
   * @param   attrName  The attribute name which should be normalized.
@@ -430,14 +430,6 @@
  private static String normalizeAttributeName(String attrName)
  {
    AttributeType attrType = DirectoryServer.getAttributeTypeOrNull(attrName);
    if (attrType != null)
    {
      String attrNameNormalized = attrType.getNormalizedPrimaryNameOrOID();
      if (attrNameNormalized != null)
      {
        return attrNameNormalized;
      }
    }
    return attrName;
    return attrType != null ? attrType.getNormalizedNameOrOID() : attrName;
  }
}
opendj-server-legacy/src/main/java/org/opends/server/extensions/SubjectDNToUserAttributeCertificateMapper.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2007-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2012-2015 ForgeRock AS
 *      Portions Copyright 2012-2016 ForgeRock AS
 */
package org.opends.server.extensions;
@@ -42,6 +42,7 @@
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.server.CertificateMapperCfg;
import org.opends.server.admin.std.server.SubjectDNToUserAttributeCertificateMapperCfg;
opendj-server-legacy/src/main/java/org/opends/server/extensions/UserAttributeNotificationMessageTemplateElement.java
@@ -22,15 +22,15 @@
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.extensions;
import org.forgerock.i18n.LocalizableMessageBuilder;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.AccountStatusNotification;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.Entry;
/**
opendj-server-legacy/src/main/java/org/opends/server/extensions/VirtualStaticGroup.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.extensions;
@@ -36,12 +36,12 @@
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.admin.std.server.VirtualStaticGroupImplementationCfg;
import org.opends.server.api.Group;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.ServerContext;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
opendj-server-legacy/src/main/java/org/opends/server/monitors/BackendMonitor.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.monitors;
@@ -38,6 +38,7 @@
import org.opends.server.api.MonitorProvider;
import org.opends.server.core.DirectoryServer;
import org.opends.server.schema.BooleanSyntax;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
/**
opendj-server-legacy/src/main/java/org/opends/server/monitors/ConnectionHandlerMonitor.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.monitors;
@@ -37,6 +37,7 @@
import org.opends.server.api.ConnectionHandler;
import org.opends.server.api.MonitorProvider;
import org.opends.server.core.DirectoryServer;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
/**
opendj-server-legacy/src/main/java/org/opends/server/monitors/ParallelWorkQueueMonitor.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.monitors;
@@ -36,7 +36,7 @@
import org.opends.server.api.MonitorProvider;
import org.opends.server.extensions.ParallelWorkQueue;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.Attributes;
import org.opends.server.types.InitializationException;
opendj-server-legacy/src/main/java/org/opends/server/monitors/TraditionalWorkQueueMonitor.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.monitors;
@@ -36,7 +36,7 @@
import org.opends.server.api.MonitorProvider;
import org.opends.server.extensions.TraditionalWorkQueue;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.Attributes;
import org.opends.server.types.InitializationException;
opendj-server-legacy/src/main/java/org/opends/server/plugins/EntryUUIDPlugin.java
@@ -22,13 +22,12 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.plugins;
import static org.opends.messages.PluginMessages.*;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -37,7 +36,6 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.config.server.ConfigChangeResult;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.schema.AttributeUsage;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.meta.PluginCfgDefn;
import org.opends.server.admin.std.server.EntryUUIDPluginCfg;
@@ -46,6 +44,7 @@
import org.opends.server.api.plugin.PluginResult;
import org.opends.server.api.plugin.PluginType;
import org.opends.server.core.DirectoryServer;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import org.opends.server.types.operation.PreOperationAddOperation;
@@ -62,56 +61,20 @@
       extends DirectoryServerPlugin<EntryUUIDPluginCfg>
       implements ConfigurationChangeListener<EntryUUIDPluginCfg>
{
  /**
   * The name of the entryUUID attribute type.
   */
  /** The name of the entryUUID attribute type. */
  private static final String ENTRYUUID = "entryuuid";
  /** The attribute type for the "entryUUID" attribute. */
  private final AttributeType entryUUIDType;
  /** The current configuration for this plugin. */
  private EntryUUIDPluginCfg currentConfig;
  /**
   * Creates a new instance of this Directory Server plugin.  Every plugin must
   * implement a default constructor (it is the only one that will be used to
   * create plugins defined in the configuration), and every plugin constructor
   * must call <CODE>super()</CODE> as its first element.
   */
  /** Mandatory default constructor of this Directory Server plugin. */
  public EntryUUIDPlugin()
  {
    super();
    // Get the entryUUID attribute type.  This needs to be done in the
    // constructor in order to make the associated variables "final".
    AttributeType at = DirectoryServer.getAttributeTypeOrNull(ENTRYUUID);
    if (at == null)
    {
      String definition =
           "( 1.3.6.1.1.16.4 NAME 'entryUUID' DESC 'UUID of the entry' " +
           "EQUALITY uuidMatch ORDERING uuidOrderingMatch " +
           "SYNTAX 1.3.6.1.1.16.1 SINGLE-VALUE NO-USER-MODIFICATION " +
           "USAGE directoryOperation X-ORIGIN 'RFC 4530' )";
      at = new AttributeType(definition, ENTRYUUID,
                             Collections.singleton(ENTRYUUID), ENTRYUUID, null,
                             null, DirectoryConfig.getDefaultAttributeSyntax(),
                             AttributeUsage.DIRECTORY_OPERATION, false, true,
                             false, true);
    }
    entryUUIDType = at;
    entryUUIDType = DirectoryServer.getAttributeTypeOrDefault(ENTRYUUID);
  }
  /** {@inheritDoc} */
  @Override
  public final void initializePlugin(Set<PluginType> pluginTypes,
                                     EntryUUIDPluginCfg configuration)
opendj-server-legacy/src/main/java/org/opends/server/plugins/LDAPADListPlugin.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2015 ForgeRock AS.
 *      Portions Copyright 2013-2016 ForgeRock AS.
 */
package org.opends.server.plugins;
@@ -40,7 +40,7 @@
import org.opends.server.api.plugin.PluginType;
import org.opends.server.api.plugin.PluginResult;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.config.server.ConfigChangeResult;
import org.opends.server.types.DirectoryConfig;
import org.opends.server.types.ObjectClass;
opendj-server-legacy/src/main/java/org/opends/server/plugins/LastModPlugin.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.plugins;
@@ -35,6 +35,7 @@
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.meta.PluginCfgDefn;
import org.opends.server.admin.std.server.LastModPluginCfg;
opendj-server-legacy/src/main/java/org/opends/server/plugins/PasswordPolicyImportPlugin.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS.
 *      Portions Copyright 2011-2016 ForgeRock AS.
 */
package org.opends.server.plugins;
@@ -59,6 +59,7 @@
import org.opends.server.core.SubentryPasswordPolicy;
import org.opends.server.schema.AuthPasswordSyntax;
import org.opends.server.schema.UserPasswordSyntax;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
/**
@@ -115,9 +116,6 @@
    super();
  }
  /** {@inheritDoc} */
  @Override
  public final void initializePlugin(Set<PluginType> pluginTypes,
                         PasswordPolicyImportPluginCfg configuration)
@@ -243,16 +241,14 @@
    processImportBegin(null, null);
  }
  /** {@inheritDoc} */
  @Override
  public void processImportBegin(Backend backend, LDIFImportConfig config)
  {
    // Find the set of attribute types with the auth password and user password
    // syntax defined in the schema.
    HashSet<AttributeType> authPWTypes = new HashSet<>();
    HashSet<AttributeType> userPWTypes = new HashSet<>();
    for (AttributeType t : DirectoryServer.getAttributeTypes().values())
    for (AttributeType t : DirectoryServer.getAttributeTypes())
    {
      if (t.getSyntax().getOID().equals(SYNTAX_AUTH_PASSWORD_OID))
      {
@@ -293,18 +289,13 @@
    userPasswordTypes = userTypesArray;
  }
  /** {@inheritDoc} */
  @Override
  public void processImportEnd(Backend backend, LDIFImportConfig config,
                               boolean successful)
  {
    // No implementation is required.
  }
  /** {@inheritDoc} */
  @Override
  public final PluginResult.ImportLDIF
               doLDIFImport(LDIFImportConfig importConfig, Entry entry)
@@ -552,9 +543,6 @@
    return PluginResult.ImportLDIF.continueEntryProcessing();
  }
  /** {@inheritDoc} */
  @Override
  public boolean isConfigurationAcceptable(PluginCfg configuration,
                                           List<LocalizableMessage> unacceptableReasons)
@@ -564,9 +552,7 @@
    return isConfigurationChangeAcceptable(config, unacceptableReasons);
  }
  /** {@inheritDoc} */
  @Override
  public boolean isConfigurationChangeAcceptable(
                      PasswordPolicyImportPluginCfg configuration,
                      List<LocalizableMessage> unacceptableReasons)
@@ -674,9 +660,7 @@
    return configAcceptable;
  }
  /** {@inheritDoc} */
  @Override
  public ConfigChangeResult applyConfigurationChange(
                                 PasswordPolicyImportPluginCfg configuration)
  {
opendj-server-legacy/src/main/java/org/opends/server/plugins/ReferentialIntegrityPlugin.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS.
 *      Portions Copyright 2011-2016 ForgeRock AS.
 *      Portions copyright 2011 profiq s.r.o.
 */
package org.opends.server.plugins;
@@ -73,6 +73,7 @@
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.protocols.internal.InternalSearchOperation;
import org.opends.server.protocols.internal.SearchRequest;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import org.opends.server.types.operation.PostOperationDeleteOperation;
import org.opends.server.types.operation.PostOperationModifyDNOperation;
@@ -349,13 +350,11 @@
      if (attrType == null || !theAttributeTypes.contains(attrType))
      {
        isAcceptable = false;
        unacceptableReasons.add(
          ERR_PLUGIN_REFERENT_ATTR_NOT_LISTED.get(attr));
        unacceptableReasons.add(ERR_PLUGIN_REFERENT_ATTR_NOT_LISTED.get(attr));
      }
      /* Verify the filter.
       */
      try
      {
        SearchFilter.createFilterFromString(filtStr);
@@ -366,7 +365,6 @@
        unacceptableReasons.add(
          ERR_PLUGIN_REFERENT_BAD_FILTER.get(filtStr, de.getMessage()));
      }
    }
    return isAcceptable;
opendj-server-legacy/src/main/java/org/opends/server/plugins/SambaPasswordPlugin.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2011-2012 profiq s.r.o.
 *      Portions Copyright 2011-2015 ForgeRock AS.
 *      Portions Copyright 2011-2016 ForgeRock AS.
 */
package org.opends.server.plugins;
@@ -55,6 +55,7 @@
import org.opends.server.extensions.PasswordModifyExtendedOperation;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.protocols.ldap.LDAPFilter;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.types.operation.PostOperationExtendedOperation;
@@ -1043,4 +1044,4 @@
    this.timeStampProvider = (timeStampProvider == null)
                             ? DEFAULT_TIMESTAMP_PROVIDER : timeStampProvider;
  }
}
}
opendj-server-legacy/src/main/java/org/opends/server/plugins/SevenBitCleanPlugin.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.plugins;
@@ -42,6 +42,7 @@
import org.forgerock.opendj.config.server.ConfigChangeResult;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.ByteString;
opendj-server-legacy/src/main/java/org/opends/server/plugins/UniqueAttributePlugin.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.plugins;
@@ -52,6 +52,7 @@
import org.opends.server.protocols.internal.InternalSearchOperation;
import org.opends.server.protocols.internal.SearchRequest;
import org.opends.server.schema.SchemaConstants;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import org.opends.server.types.operation.*;
opendj-server-legacy/src/main/java/org/opends/server/protocols/internal/InternalClientConnection.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.protocols.internal;
@@ -38,6 +38,7 @@
import org.opends.server.api.ClientConnection;
import org.opends.server.api.ConnectionHandler;
import org.opends.server.core.*;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import org.opends.server.util.AddChangeRecordEntry;
import org.opends.server.util.DeleteChangeRecordEntry;
opendj-server-legacy/src/main/java/org/opends/server/protocols/ldap/LDAPFilter.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.protocols.ldap;
@@ -38,9 +38,9 @@
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ByteStringBuilder;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.AttributeType;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.FilterType;
import org.opends.server.types.LDAPException;
opendj-server-legacy/src/main/java/org/opends/server/protocols/ldap/LDAPStatistics.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2012-2015 ForgeRock AS
 *      Portions Copyright 2012-2016 ForgeRock AS
 */
package org.opends.server.protocols.ldap;
@@ -38,9 +38,7 @@
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.admin.std.server.MonitorProviderCfg;
import org.opends.server.api.MonitorProvider;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.Attributes;
import org.opends.server.types.DirectoryConfig;
import org.opends.server.types.ObjectClass;
@@ -594,8 +592,7 @@
   */
  protected Attribute createAttribute(String name, Object value)
  {
    AttributeType attrType = DirectoryServer.getAttributeTypeOrNull(name.toLowerCase());
    return Attributes.create(attrType, String.valueOf(value));
    return Attributes.create(name, String.valueOf(value));
  }
opendj-server-legacy/src/main/java/org/opends/server/protocols/ldap/SearchResultEntryProtocolOp.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.protocols.ldap;
@@ -41,10 +41,10 @@
import org.forgerock.opendj.io.ASN1Writer;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeBuilder;
import org.opends.server.types.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
import org.opends.server.types.LDAPException;
opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/AttrHistorical.java
@@ -23,7 +23,7 @@
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2014 ForgeRock, AS.
 *      Portions Copyright 2015 ForgeRock AS.
 *      Portions Copyright 2015-2016 ForgeRock AS.
 */
package org.opends.server.replication.plugin;
@@ -32,7 +32,7 @@
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.replication.common.CSN;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.Entry;
import org.opends.server.types.Modification;
opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/AttrHistoricalMultiple.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.replication.plugin;
@@ -36,9 +36,9 @@
import org.opends.server.replication.common.CSN;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeBuilder;
import org.opends.server.types.AttributeType;
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.
opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/AttrHistoricalSingle.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.replication.plugin;
@@ -36,7 +36,7 @@
import org.forgerock.opendj.ldap.ModificationType;
import org.opends.server.replication.common.CSN;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.Entry;
import org.opends.server.types.Modification;
opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/EntryHistorical.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.replication.plugin;
@@ -37,6 +37,7 @@
import org.opends.server.core.DirectoryServer;
import org.opends.server.replication.common.CSN;
import org.opends.server.replication.protocol.OperationContext;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import org.opends.server.types.operation.PreOperationAddOperation;
import org.opends.server.types.operation.PreOperationModifyDNOperation;
opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/FractionalLDIFImportPlugin.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2009 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.replication.plugin;
@@ -32,6 +32,7 @@
import org.forgerock.opendj.config.server.ConfigChangeResult;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.util.Utils;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.server.ServerManagementContext;
opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/HistoricalAttributeValue.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2015 ForgeRock AS.
 *      Portions Copyright 2013-2016 ForgeRock AS.
 */
package org.opends.server.replication.plugin;
@@ -35,12 +35,12 @@
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.core.DirectoryServer;
import org.opends.server.replication.common.CSN;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeBuilder;
import org.opends.server.types.AttributeDescription;
import org.opends.server.types.AttributeType;
import org.opends.server.types.Modification;
/**
opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/HistoricalCsnOrderingMatchingRuleImpl.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2012-2015 ForgeRock AS.
 *      Portions Copyright 2012-2016 ForgeRock AS.
 */
package org.opends.server.replication.plugin;
@@ -38,6 +38,7 @@
import org.forgerock.opendj.ldap.DecodeException;
import org.forgerock.opendj.ldap.schema.MatchingRuleImpl;
import org.forgerock.opendj.ldap.schema.Schema;
import org.forgerock.opendj.ldap.schema.SchemaBuilder;
import org.forgerock.opendj.ldap.spi.IndexQueryFactory;
import org.forgerock.opendj.ldap.spi.Indexer;
import org.forgerock.opendj.ldap.spi.IndexingOptions;
@@ -181,11 +182,26 @@
    };
  }
  /** {@inheritDoc} */
  @Override
  public Collection<? extends Indexer> createIndexers(IndexingOptions options)
  {
    return indexers;
  }
  /**
   * Adds the historical csn ordering matching rule to the provided schema builder.
   *
   * @param builder
   *          where to add the historical csn ordering matching rule
   * @return the provided builder
   */
  public static SchemaBuilder addHistoricalCsnOrderingMatchingRule(SchemaBuilder builder)
  {
    return builder
        .buildMatchingRule("1.3.6.1.4.1.26027.1.4.4")
        .names("historicalCsnOrderingMatch")
        .syntaxOID("1.3.6.1.4.1.1466.115.121.1.40")
        .implementation(new HistoricalCsnOrderingMatchingRuleImpl())
        .addToSchema();
  }
}
opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/LDAPReplicationDomain.java
@@ -92,6 +92,7 @@
import org.opends.server.replication.service.ReplicationDomain;
import org.opends.server.tasks.PurgeConflictsHistoricalTask;
import org.opends.server.tasks.TaskUtils;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import org.opends.server.types.operation.*;
import org.opends.server.util.LDIFReader;
@@ -879,7 +880,7 @@
    {
      // Get attribute from attributes1
      AttributeType attributeType1 = schema.getAttributeType(attrName1);
      if (attributeType1 == null)
      if (attributeType1.isPlaceHolder())
      {
        throw new ConfigException(
          NOTE_ERR_FRACTIONAL_CONFIG_UNKNOWN_ATTRIBUTE_TYPE.get(attrName1));
@@ -889,7 +890,7 @@
      for (String attrName2 : attributes2)
      {
        AttributeType attributeType2 = schema.getAttributeType(attrName2);
        if (attributeType2 == null)
        if (attributeType2.isPlaceHolder())
        {
          throw new ConfigException(
            NOTE_ERR_FRACTIONAL_CONFIG_UNKNOWN_ATTRIBUTE_TYPE.get(attrName2));
@@ -978,7 +979,7 @@
        // Does the attribute exist ?
        AttributeType attributeType = schema.getAttributeType(attrName);
        if (attributeType != null)
        if (!attributeType.isPlaceHolder())
        {
          // No more checking for the extensibleObject class
          if (!isExtensibleObjectClass
@@ -1296,7 +1297,7 @@
   private static boolean isFractionalProhibited(AttributeType attrType)
   {
     String attributeName = attrType.getPrimaryName();
     String attributeName = attrType.getNameOrOID();
     return (attributeName != null && isFractionalProhibitedAttr(attributeName))
         || isFractionalProhibitedAttr(attrType.getOID());
   }
@@ -1304,12 +1305,11 @@
  private static boolean canRemoveAttribute(AttributeType attributeType,
      boolean fractionalExclusive, Set<String> fractionalConcernedAttributes)
  {
    String attributeName = attributeType.getPrimaryName();
    String attributeName = attributeType.getNameOrOID();
    String attributeOid = attributeType.getOID();
    // Is the current attribute part of the established list ?
    boolean foundAttribute =
        contains(fractionalConcernedAttributes, attributeName, attributeOid);
    boolean foundAttribute = contains(fractionalConcernedAttributes, attributeName, attributeOid);
    // Now remove the attribute or modification if:
    // - exclusive mode and attribute is in configuration
    // - inclusive mode and attribute is not in configuration
@@ -1323,11 +1323,9 @@
        || (!foundAttribute && !fractionalExclusive);
  }
  private static boolean contains(Set<String> attrNames, String attrName,
      String attrOID)
  private static boolean contains(Set<String> attrNames, String attrName, String attrOID)
  {
    return attrNames.contains(attrOID)
        || (attrName != null && attrNames.contains(attrName.toLowerCase()));
    return attrNames.contains(attrOID) || attrNames.contains(attrName.toLowerCase());
  }
  /**
opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/PersistentServerState.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2012-2015 ForgeRock AS.
 *      Portions Copyright 2012-2016 ForgeRock AS.
 */
package org.opends.server.replication.plugin;
@@ -35,6 +35,7 @@
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.ModifyOperationBasis;
import org.opends.server.protocols.internal.InternalSearchOperation;
@@ -44,7 +45,6 @@
import org.opends.server.replication.common.CSN;
import org.opends.server.replication.common.ServerState;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.RawModification;
opendj-server-legacy/src/main/java/org/opends/server/replication/protocol/AddMsg.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.replication.protocol;
@@ -43,6 +43,7 @@
import org.opends.server.protocols.ldap.LDAPAttribute;
import org.opends.server.replication.common.CSN;
import org.opends.server.replication.plugin.EntryHistorical;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import org.opends.server.types.operation.PostOperationAddOperation;
opendj-server-legacy/src/main/java/org/opends/server/replication/protocol/ModifyCommonMsg.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2009-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2015 ForgeRock AS
 *      Portions Copyright 2013-2016 ForgeRock AS
 */
package org.opends.server.replication.protocol;
@@ -39,6 +39,7 @@
import org.opends.server.protocols.ldap.LDAPModification;
import org.opends.server.replication.common.CSN;
import org.opends.server.replication.plugin.EntryHistorical;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
/**
opendj-server-legacy/src/main/java/org/opends/server/replication/server/ReplicationServer.java
@@ -65,7 +65,7 @@
import org.opends.server.replication.server.changelog.file.ECLEnabledDomainPredicate;
import org.opends.server.replication.server.changelog.file.FileChangelogDB;
import org.opends.server.replication.service.DSRSShutdownSync;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.HostPort;
opendj-server-legacy/src/main/java/org/opends/server/schema/AciSyntax.java
@@ -22,18 +22,21 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.schema;
import static org.opends.server.schema.SchemaConstants.*;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.schema.Schema;
import org.forgerock.opendj.ldap.schema.SchemaBuilder;
import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.opends.server.api.AttributeSyntax;
import org.opends.server.core.ServerContext;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Schema.SchemaUpdater;
/**
 * This class implements the access control information (aci) attribute syntax.
@@ -52,53 +55,55 @@
    super();
  }
  /** {@inheritDoc} */
  @Override
  public void initializeSyntax(AttributeSyntaxCfg configuration, ServerContext serverContext) throws ConfigException
  public void initializeSyntax(AttributeSyntaxCfg configuration, ServerContext serverContext)
      throws ConfigException, DirectoryException
  {
    // Add the Aci syntax to the "new" schema
    SchemaUpdater schemaUpdater = serverContext.getSchemaUpdater();
    SchemaBuilder builder = schemaUpdater.getSchemaBuilder().buildSyntax(SYNTAX_ACI_OID)
      .description(SYNTAX_ACI_DESCRIPTION)
      .implementation(new AciSyntaxImpl())
      .addToSchema();
    schemaUpdater.updateSchema(builder.toSchema());
    serverContext.getSchema().updateSchema(new SchemaUpdater()
    {
      @Override
      public Schema update(SchemaBuilder builder)
      {
        return addAciSyntax(builder).toSchema();
      }
    });
  }
  /** {@inheritDoc} */
  /**
   * Adds the ACI syntax to the provided schema builder.
   *
   * @param builder
   *          where to add the ACI syntax
   * @return the provided builder
   */
  public static SchemaBuilder addAciSyntax(SchemaBuilder builder)
  {
    return builder
        .buildSyntax(SYNTAX_ACI_OID)
        .description(SYNTAX_ACI_DESCRIPTION)
        .implementation(new AciSyntaxImpl())
        .addToSchema();
  }
  @Override
  public Syntax getSDKSyntax(org.forgerock.opendj.ldap.schema.Schema schema)
  {
    return schema.getSyntax(SchemaConstants.SYNTAX_ACI_OID);
  }
  /**
   * Retrieves the common name for this attribute syntax.
   *
   * @return  The common name for this attribute syntax.
   */
  @Override
  public String getName()
  {
    return SYNTAX_ACI_NAME;
  }
  /**
   * Retrieves the OID for this attribute syntax.
   *
   * @return  The OID for this attribute syntax.
   */
  @Override
  public String getOID()
  {
    return SYNTAX_ACI_OID;
  }
  /**
   * Retrieves a description for this attribute syntax.
   *
   * @return  A description for this attribute syntax.
   */
  @Override
  public String getDescription()
  {
opendj-server-legacy/src/main/java/org/opends/server/schema/AttributeTypeSyntax.java
@@ -22,48 +22,34 @@
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.schema;
import static org.opends.messages.SchemaMessages.*;
import static org.opends.server.config.ConfigConstants.*;
import static org.forgerock.opendj.ldap.schema.SchemaOptions.*;
import static org.opends.server.schema.SchemaConstants.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.config.server.ConfigChangeResult;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.schema.AttributeUsage;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.forgerock.opendj.ldap.schema.SchemaOptions;
import org.forgerock.opendj.ldap.schema.Schema;
import org.forgerock.opendj.ldap.schema.Syntax;
import org.forgerock.util.Option;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.server.AttributeTypeDescriptionAttributeSyntaxCfg;
import org.opends.server.api.AttributeSyntax;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.ServerContext;
import org.opends.server.types.AttributeType;
import org.opends.server.types.CommonSchemaElements;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.InitializationException;
import org.opends.server.types.Schema;
import org.opends.server.util.RemoveOnceSDKSchemaIsUsed;
/**
 * This class defines the attribute type description syntax, which is used to
 * hold attribute type definitions in the server schema.  The format of this
 * syntax is defined in RFC 2252.
 */
@RemoveOnceSDKSchemaIsUsed
public class AttributeTypeSyntax
       extends AttributeSyntax<AttributeTypeDescriptionAttributeSyntaxCfg>
       implements
@@ -94,13 +80,10 @@
    super();
  }
  /** {@inheritDoc} */
  @Override
  public void
  initializeSyntax(AttributeTypeDescriptionAttributeSyntaxCfg configuration, ServerContext serverContext)
         throws ConfigException, InitializationException
      throws ConfigException, InitializationException, DirectoryException
  {
    this.serverContext = serverContext;
@@ -115,1318 +98,53 @@
    currentConfig = configuration;
    currentConfig.addAttributeTypeDescriptionChangeListener(this);
    stripMinimumUpperBound=configuration.isStripSyntaxMinUpperBound();
    updateNewSchema();
    stripMinimumUpperBound = configuration.isStripSyntaxMinUpperBound();
    serverContext.getSchema().updateSchemaOption(STRIP_UPPER_BOUND_FOR_ATTRIBUTE_TYPE, stripMinimumUpperBound);
  }
  /** Update the option in new schema if it changes from current value. */
  private void updateNewSchema()
  {
    Option<Boolean> option = SchemaOptions.STRIP_UPPER_BOUND_FOR_ATTRIBUTE_TYPE;
    if (isStripSyntaxMinimumUpperBound() != serverContext.getSchemaNG().getOption(option))
    {
      SchemaUpdater schemaUpdater = serverContext.getSchemaUpdater();
      schemaUpdater.updateSchema(
          schemaUpdater.getSchemaBuilder().setOption(option, stripMinimumUpperBound).toSchema());
    }
  }
  /** {@inheritDoc} */
  @Override
  public Syntax getSDKSyntax(org.forgerock.opendj.ldap.schema.Schema schema)
  public Syntax getSDKSyntax(Schema schema)
  {
    return schema.getSyntax(SchemaConstants.SYNTAX_ATTRIBUTE_TYPE_OID);
  }
  /** {@inheritDoc} */
  @Override
  public String getName()
  {
    return SYNTAX_ATTRIBUTE_TYPE_NAME;
  }
  /** {@inheritDoc} */
  @Override
  public String getOID()
  {
    return SYNTAX_ATTRIBUTE_TYPE_OID;
  }
  /** {@inheritDoc} */
  @Override
  public String getDescription()
  {
    return SYNTAX_ATTRIBUTE_TYPE_DESCRIPTION;
  }
  /**
   * Decodes the contents of the provided ASN.1 octet string as an attribute
   * type definition according to the rules of this syntax.  Note that the
   * provided octet string value does not need to be normalized (and in fact, it
   * should not be in order to allow the desired capitalization to be
   * preserved).
   *
   * @param  value                 The ASN.1 octet string containing the value
   *                               to decode (it does not need to be
   *                               normalized).
   * @param  schema                The schema to use to resolve references to
   *                               other schema elements.
   * @param  allowUnknownElements  Indicates whether to allow values that
   *                               reference a superior attribute type which are
   *                               not defined in the server schema. This should
   *                               only be true when called by
   *                               {@code valueIsAcceptable}.
   *
   * @return  The decoded attribute type definition.
   *
   * @throws  DirectoryException  If the provided value cannot be decoded as an
   *                              attribute type definition.
   */
  public static AttributeType decodeAttributeType(ByteSequence value,
                                                  Schema schema,
                                                  boolean allowUnknownElements)
         throws DirectoryException
  {
    // Get string representations of the provided value using the provided form
    // and with all lowercase characters.
    String valueStr = value.toString();
    String lowerStr = toLowerCase(valueStr);
    // We'll do this a character at a time.  First, skip over any leading
    // whitespace.
    int pos    = 0;
    int length = valueStr.length();
    while (pos < length && valueStr.charAt(pos) == ' ')
    {
      pos++;
    }
    if (pos >= length)
    {
      // This means that the value was empty or contained only whitespace.  That
      // is illegal.
      LocalizableMessage message = ERR_ATTR_SYNTAX_ATTRTYPE_EMPTY_VALUE.get();
      throw new DirectoryException(
              ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
    }
    // The next character must be an open parenthesis.  If it is not, then that
    // is an error.
    char c = valueStr.charAt(pos++);
    if (c != '(')
    {
      LocalizableMessage message = ERR_ATTR_SYNTAX_ATTRTYPE_EXPECTED_OPEN_PARENTHESIS.get(valueStr, pos - 1, c);
      throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
    }
    // Skip over any spaces immediately following the opening parenthesis.
    while (pos < length && ((c = valueStr.charAt(pos)) == ' '))
    {
      pos++;
    }
    if (pos >= length)
    {
      // This means that the end of the value was reached before we could find
      // the OID.  Ths is illegal.
      LocalizableMessage message = ERR_ATTR_SYNTAX_ATTRTYPE_TRUNCATED_VALUE.get(valueStr);
      throw new DirectoryException(
              ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
    }
    // The next set of characters must be the OID.  Strictly speaking, this
    // should only be a numeric OID, but we'll also allow for the
    // "attrname-oid" case as well.  Look at the first character to figure out
    // which we will be using.
    int oidStartPos = pos;
    if (isDigit(c))
    {
      // This must be a numeric OID.  In that case, we will accept only digits
      // and periods, but not consecutive periods.
      boolean lastWasPeriod = false;
      while (pos < length
              && ((c = valueStr.charAt(pos)) != ' ')
              && ((c = valueStr.charAt(pos)) != ')'))
      {
        if (c == '.')
        {
          if (lastWasPeriod)
          {
            LocalizableMessage message =
              ERR_ATTR_SYNTAX_ATTRTYPE_DOUBLE_PERIOD_IN_NUMERIC_OID.
                  get(valueStr, pos - 1);
            throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
                                         message);
          }
          else
          {
            lastWasPeriod = true;
          }
        }
        else if (! isDigit(c))
        {
          // This must have been an illegal character.
          LocalizableMessage message =
            ERR_ATTR_SYNTAX_ATTRTYPE_ILLEGAL_CHAR_IN_NUMERIC_OID.get(valueStr, c, pos - 1);
          throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
        }
        else
        {
          lastWasPeriod = false;
        }
        pos++;
      }
    }
    else
    {
      // This must be a "fake" OID.  In this case, we will only accept
      // alphabetic characters, numeric digits, and the hyphen.
      while (pos < length
          && ((c = valueStr.charAt(pos)) != ' ')
          && ((c = valueStr.charAt(pos)) != ')'))
      {
        if (isAlpha(c)
            || isDigit(c)
            || c == '-'
            || (c == '_' && DirectoryServer.allowAttributeNameExceptions()))
        {
          // This is fine.  It is an acceptable character.
          pos++;
        }
        else
        {
          // This must have been an illegal character.
          LocalizableMessage message = ERR_ATTR_SYNTAX_ATTRTYPE_ILLEGAL_CHAR_IN_STRING_OID.get(valueStr, c, pos - 1);
          throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
        }
      }
    }
    // If we're at the end of the value, then it isn't a valid attribute type
    // description.  Otherwise, parse out the OID.
    String oid;
    if (pos >= length)
    {
      LocalizableMessage message = ERR_ATTR_SYNTAX_ATTRTYPE_TRUNCATED_VALUE.get(valueStr);
      throw new DirectoryException(
              ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
    }
    else
    {
      oid = lowerStr.substring(oidStartPos, pos);
    }
    // Skip over the space(s) after the OID.
    while (pos < length && ((c = valueStr.charAt(pos)) == ' '))
    {
      pos++;
    }
    if (pos >= length)
    {
      // This means that the end of the value was reached before we could find
      // the OID.  Ths is illegal.
      LocalizableMessage message = ERR_ATTR_SYNTAX_ATTRTYPE_TRUNCATED_VALUE.get(valueStr);
      throw new DirectoryException(
              ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
    }
    // At this point, we should have a pretty specific syntax that describes
    // what may come next, but some of the components are optional and it would
    // be pretty easy to put something in the wrong order, so we will be very
    // flexible about what we can accept.  Just look at the next token, figure
    // out what it is and how to treat what comes after it, then repeat until
    // we get to the end of the value.  But before we start, set default values
    // for everything else we might need to know.
    String  primaryName = oid;
    List<String> typeNames = new LinkedList<>();
    String description = null;
    AttributeType superiorType = null;
    Syntax syntax = DirectoryServer.getDefaultAttributeSyntax();
    MatchingRule approximateMatchingRule = null;
    MatchingRule equalityMatchingRule = null;
    MatchingRule orderingMatchingRule = null;
    MatchingRule substringMatchingRule = null;
    AttributeUsage attributeUsage = AttributeUsage.USER_APPLICATIONS;
    boolean isCollective = false;
    boolean isNoUserModification = false;
    boolean isObsolete = false;
    boolean isSingleValue = false;
    HashMap<String,List<String>> extraProperties = new LinkedHashMap<>();
    while (true)
    {
      StringBuilder tokenNameBuffer = new StringBuilder();
      pos = readTokenName(valueStr, tokenNameBuffer, pos);
      String tokenName = tokenNameBuffer.toString();
      String lowerTokenName = toLowerCase(tokenName);
      if (")".equals(tokenName))
      {
        // We must be at the end of the value.  If not, then that's a problem.
        if (pos < length)
        {
          LocalizableMessage message =
            ERR_ATTR_SYNTAX_ATTRTYPE_UNEXPECTED_CLOSE_PARENTHESIS.
                get(valueStr, pos - 1);
          throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
                                       message);
        }
        break;
      }
      else if ("name".equals(lowerTokenName))
      {
        // This specifies the set of names for the attribute type.  It may be a
        // single name in single quotes, or it may be an open parenthesis
        // followed by one or more names in single quotes separated by spaces.
        c = valueStr.charAt(pos++);
        if (c == '\'')
        {
          StringBuilder userBuffer  = new StringBuilder();
          StringBuilder lowerBuffer = new StringBuilder();
          pos = readQuotedString(valueStr, lowerStr, userBuffer, lowerBuffer, pos - 1);
          primaryName = userBuffer.toString();
          typeNames.add(primaryName);
        }
        else if (c == '(')
        {
          StringBuilder userBuffer  = new StringBuilder();
          StringBuilder lowerBuffer = new StringBuilder();
          pos = readQuotedString(valueStr, lowerStr, userBuffer, lowerBuffer,
                                 pos);
          primaryName = userBuffer.toString();
          typeNames.add(primaryName);
          while (true)
          {
            if (valueStr.charAt(pos) == ')')
            {
              // Skip over any spaces after the parenthesis.
              pos++;
              while (pos < length && ((c = valueStr.charAt(pos)) == ' '))
              {
                pos++;
              }
              break;
            }
            userBuffer  = new StringBuilder();
            lowerBuffer = new StringBuilder();
            pos = readQuotedString(valueStr, lowerStr, userBuffer, lowerBuffer, pos);
            typeNames.add(userBuffer.toString());
          }
        }
        else
        {
          // This is an illegal character.
          LocalizableMessage message = ERR_ATTR_SYNTAX_ATTRTYPE_ILLEGAL_CHAR.get(valueStr, c, pos - 1);
          throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
        }
        //RFC 2251: A specification may also assign one or more textual names
        //for an attribute type.  These names MUST begin with a letter, and
        //only contain ASCII letters, digit characters and hyphens.
        //The global config hasn't been read so far. Allow the name exceptions
        //during startup.
        boolean allowExceptions = DirectoryServer.isRunning()?
                           DirectoryServer.allowAttributeNameExceptions():true;
        //Iterate over all the names and throw an exception if it is invalid.
        for(String name : typeNames)
        {
          for(int index=0; index < name.length(); index++)
          {
            char ch = name.charAt(index);
            switch(ch)
            {
              case '-':
              //hyphen is allowed but not as the first byte.
                if (index==0)
                {
                  throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
                      ERR_ATTR_SYNTAX_ATTR_ILLEGAL_INITIAL_DASH.get(value));
                }
                break;
              case '_':
              // This will never be allowed as the first character.  It
              // may be allowed for subsequent characters if the attribute
              // name exceptions option is enabled.
                if (index==0)
                {
                  throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
                      ERR_ATTR_SYNTAX_ATTR_ILLEGAL_INITIAL_UNDERSCORE.get(
                          value, ATTR_ALLOW_ATTRIBUTE_NAME_EXCEPTIONS));
                }
                else if (!allowExceptions)
                {
                  throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
                      ERR_ATTR_SYNTAX_ATTR_ILLEGAL_UNDERSCORE_CHAR.get(
                          value, ATTR_ALLOW_ATTRIBUTE_NAME_EXCEPTIONS));
                }
                break;
              default:
              //Only digits and ascii letters are allowed but the first byte
              //can not be a digit.
                if(index ==0 && isDigit(ch) && !allowExceptions)
                {
                  throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
                      ERR_ATTR_SYNTAX_ATTR_ILLEGAL_INITIAL_DIGIT.get(
                          value, ch, ATTR_ALLOW_ATTRIBUTE_NAME_EXCEPTIONS));
                }
                else if (!(('0'<=ch && ch<='9')
                    || ('A'<=ch && ch<='Z')
                    || ('a'<=ch && ch<='z')))
                {
                  throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
                      ERR_ATTR_SYNTAX_ATTR_ILLEGAL_CHAR.get(value, ch, index));
                }
                break;
            }
          }
        }
      }
      else if ("desc".equals(lowerTokenName))
      {
        // This specifies the description for the attribute type.  It is an
        // arbitrary string of characters enclosed in single quotes.
        StringBuilder descriptionBuffer = new StringBuilder();
        pos = readQuotedString(valueStr, descriptionBuffer, pos);
        description = descriptionBuffer.toString();
      }
      else if ("obsolete".equals(lowerTokenName))
      {
        // This indicates whether the attribute type should be considered
        // obsolete.  We do not need to do any more parsing for this token.
        isObsolete = true;
      }
      else if ("sup".equals(lowerTokenName))
      {
        // This specifies the name or OID of the superior attribute type from
        // which this attribute type should inherit its properties.
        StringBuilder woidBuffer = new StringBuilder();
        pos = readWOID(lowerStr, woidBuffer, pos);
        String woidString = woidBuffer.toString();
        superiorType = schema.getAttributeType(woidString);
        if (superiorType == null)
        {
          if (allowUnknownElements)
          {
            superiorType = DirectoryServer.getAttributeTypeOrDefault(woidString);
          }
          else
          {
            // This is bad because we don't know what the superior attribute
            // type is so we can't base this attribute type on it.
            LocalizableMessage message = WARN_ATTR_SYNTAX_ATTRTYPE_UNKNOWN_SUPERIOR_TYPE.get(oid, woidString);
            throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
          }
        }
        // Use the information in the superior type to provide defaults for the
        // rest of the components in this attribute type description.
        // Technically, the definition of the superior type should be provided
        // before the matching rule, syntax, single-value, collective,
        // no-user-modification, and usage components, and in that case we won't
        // undo something else that has already been set by an earlier
        // definition.  However, if the information is provided out-of-order,
        // then it is possible that this could overwrite some desired setting
        // that is different from that of the supertype.
        approximateMatchingRule = superiorType.getApproximateMatchingRule();
        equalityMatchingRule    = superiorType.getEqualityMatchingRule();
        orderingMatchingRule    = superiorType.getOrderingMatchingRule();
        substringMatchingRule   = superiorType.getSubstringMatchingRule();
        syntax                  = superiorType.getSyntax();
        isSingleValue           = superiorType.isSingleValue();
        isCollective            = superiorType.isCollective();
        isNoUserModification    = superiorType.isNoUserModification();
        attributeUsage          = superiorType.getUsage();
      }
      else if ("equality".equals(lowerTokenName))
      {
        // This specifies the name or OID of the equality matching rule to use
        // for this attribute type.
        StringBuilder woidBuffer = new StringBuilder();
        pos = readWOID(lowerStr, woidBuffer, pos);
        MatchingRule emr =
             schema.getMatchingRule(woidBuffer.toString());
        if (emr == null)
        {
          // This is bad because we have no idea what the equality matching
          // rule should be.
          LocalizableMessage message = WARN_ATTR_SYNTAX_ATTRTYPE_UNKNOWN_EQUALITY_MR.get(oid, woidBuffer);
          throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
        }
        else
        {
          equalityMatchingRule = emr;
        }
      }
      else if ("ordering".equals(lowerTokenName))
      {
        // This specifies the name or OID of the ordering matching rule to use
        // for this attribute type.
        StringBuilder woidBuffer = new StringBuilder();
        pos = readWOID(lowerStr, woidBuffer, pos);
        MatchingRule omr = schema.getMatchingRule(woidBuffer.toString());
        if (omr == null)
        {
          // This is bad because we have no idea what the ordering matching
          // rule should be.
          LocalizableMessage message = WARN_ATTR_SYNTAX_ATTRTYPE_UNKNOWN_ORDERING_MR.get(oid, woidBuffer);
          throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
        }
        else
        {
          orderingMatchingRule = omr;
        }
      }
      else if ("substr".equals(lowerTokenName))
      {
        // This specifies the name or OID of the substring matching rule to use
        // for this attribute type.
        StringBuilder woidBuffer = new StringBuilder();
        pos = readWOID(lowerStr, woidBuffer, pos);
        MatchingRule smr = schema.getMatchingRule(woidBuffer.toString());
        if (smr == null)
        {
          // This is bad because we have no idea what the substring matching
          // rule should be.
          LocalizableMessage message = WARN_ATTR_SYNTAX_ATTRTYPE_UNKNOWN_SUBSTRING_MR.get(oid, woidBuffer);
          throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
        }
        else
        {
          substringMatchingRule = smr;
        }
      }
      else if ("syntax".equals(lowerTokenName))
      {
        // This specifies the numeric OID of the syntax for this matching rule.
        // It may optionally be immediately followed by an open curly brace, an
        // integer value, and a close curly brace to suggest the minimum number
        // of characters that should be allowed in values of that type.  This
        // implementation will ignore any such length because it does not
        // impose any practical limit on the length of attribute values.
        boolean inBrace         = false;
        boolean lastWasPeriod   = false;
        StringBuilder oidBuffer = new StringBuilder();
        while (pos < length)
        {
          c = lowerStr.charAt(pos++);
          if (inBrace)
          {
            // The only thing we'll allow here will be numeric digits and the
            // closing curly brace.
            if (c == '}')
            {
              // The next character must be a space or a closing parenthesis.
              c = lowerStr.charAt(pos);
              if (c != ' ' && c != ')')
              {
                LocalizableMessage message =
                  ERR_ATTR_SYNTAX_ATTRTYPE_ILLEGAL_CHAR_IN_NUMERIC_OID.get(valueStr, c, pos - 1);
                throw new DirectoryException(
                               ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
              }
              break;
            }
            else if (! isDigit(c))
            {
              LocalizableMessage message =
                ERR_ATTR_SYNTAX_ATTRTYPE_ILLEGAL_CHAR_IN_NUMERIC_OID.get(valueStr, c, pos - 1);
              throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
                                           message);
            }
          }
          else
          {
            if (isDigit(c))
            {
              oidBuffer.append(c);
              lastWasPeriod = false;
            }
            else if (c == '.')
            {
              if (lastWasPeriod)
              {
                LocalizableMessage message =
                    ERR_ATTR_SYNTAX_ATTRTYPE_DOUBLE_PERIOD_IN_NUMERIC_OID.
                      get(valueStr, pos - 1);
                throw new DirectoryException(
                               ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
              }
              else
              {
                oidBuffer.append(c);
                lastWasPeriod = true;
              }
            }
            else if (c == '{')
            {
              // It's the start of the length specification.
              inBrace = true;
            }
            else if (c == ' ')
            {
              // It's the end of the value.
              break;
            }
            else if(c == ')')
            {
              // As per RFC 4512 (4.1.2) it is end of the value.
              --pos;
              break;
            }
            else
            {
              LocalizableMessage message =
                ERR_ATTR_SYNTAX_ATTRTYPE_ILLEGAL_CHAR_IN_NUMERIC_OID.get(valueStr, c, pos - 1);
              throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
                                           message);
            }
          }
        }
        syntax = schema.getSyntax(oidBuffer.toString());
        if (syntax == null)
        {
          LocalizableMessage message = WARN_ATTR_SYNTAX_ATTRTYPE_UNKNOWN_SYNTAX.get(oid, oidBuffer);
          throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
                                       message);
        }
        if (approximateMatchingRule == null)
        {
          approximateMatchingRule = syntax.getApproximateMatchingRule();
        }
        if (equalityMatchingRule == null)
        {
          equalityMatchingRule = syntax.getEqualityMatchingRule();
        }
        if (orderingMatchingRule == null)
        {
          orderingMatchingRule = syntax.getOrderingMatchingRule();
        }
        if (substringMatchingRule == null)
        {
          substringMatchingRule = syntax.getSubstringMatchingRule();
        }
      }
      else if ("single-value".equals(lowerTokenName))
      {
        // This indicates that attributes of this type are allowed to have at
        // most one value.  We do not need any more parsing for this token.
        isSingleValue = true;
      }
      else if ("collective".equals(lowerTokenName))
      {
        // This indicates that attributes of this type are collective (i.e.,
        // have their values generated dynamically in some way).  We do not need
        // any more parsing for this token.
        isCollective = true;
      }
      else if ("no-user-modification".equals(lowerTokenName))
      {
        // This indicates that the values of attributes of this type are not to
        // be modified by end users.  We do not need any more parsing for this
        // token.
        isNoUserModification = true;
      }
      else if ("usage".equals(lowerTokenName))
      {
        // This specifies the usage string for this attribute type.  It should
        // be followed by one of the strings "userApplications",
        // "directoryOperation", "distributedOperation", or "dSAOperation".
        StringBuilder usageBuffer = new StringBuilder();
        while (pos < length)
        {
          c = lowerStr.charAt(pos++);
          if (c == ' ')
          {
            break;
          }
          else if(c == ')')
          {
            pos--;
            break;
          }
          else
          {
            usageBuffer.append(c);
          }
        }
        String usageStr = usageBuffer.toString();
        if ("userapplications".equals(usageStr))
        {
          attributeUsage = AttributeUsage.USER_APPLICATIONS;
        }
        else if ("directoryoperation".equals(usageStr))
        {
          attributeUsage = AttributeUsage.DIRECTORY_OPERATION;
        }
        else if ("distributedoperation".equals(usageStr))
        {
          attributeUsage = AttributeUsage.DISTRIBUTED_OPERATION;
        }
        else if ("dsaoperation".equals(usageStr))
        {
          attributeUsage = AttributeUsage.DSA_OPERATION;
        }
        else
        {
          // This must be an illegal usage.
          attributeUsage = AttributeUsage.USER_APPLICATIONS;
          LocalizableMessage message = WARN_ATTR_SYNTAX_ATTRTYPE_INVALID_ATTRIBUTE_USAGE.get(oid, usageStr);
          throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
        }
      }
      else
      {
        // This must be a non-standard property and it must be followed by
        // either a single value in single quotes or an open parenthesis
        // followed by one or more values in single quotes separated by spaces
        // followed by a close parenthesis.
        List<String> valueList = new ArrayList<>();
        pos = readExtraParameterValues(valueStr, valueList, pos);
        extraProperties.put(tokenName, valueList);
      }
    }
    List<String> approxRules = extraProperties.get(SCHEMA_PROPERTY_APPROX_RULE);
    if (approxRules != null && !approxRules.isEmpty())
    {
      String ruleName  = approxRules.get(0);
      String lowerName = toLowerCase(ruleName);
      MatchingRule amr = schema.getMatchingRule(lowerName);
      if (amr == null)
      {
        // This is bad because we have no idea what the approximate matching
        // rule should be.
        LocalizableMessage message = WARN_ATTR_SYNTAX_ATTRTYPE_UNKNOWN_APPROXIMATE_MR.get(oid, ruleName);
        throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
      }
      else
      {
        approximateMatchingRule = amr;
      }
    }
    // If there is a superior type, then it must have the same usage as the
    // subordinate type.  Also, if the superior type is collective, then so must
    // the subordinate type be collective.
    if (superiorType != null)
    {
      if (superiorType.getUsage() != attributeUsage)
      {
        LocalizableMessage message = WARN_ATTR_SYNTAX_ATTRTYPE_INVALID_SUPERIOR_USAGE.get(
            oid, attributeUsage, superiorType.getNameOrOID());
        throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
      }
      if (superiorType.isCollective() && !isCollective)
      {
        throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
            WARN_ATTR_SYNTAX_ATTRTYPE_NONCOLLECTIVE_FROM_COLLECTIVE
                .get(oid, superiorType.getNameOrOID()));
      }
    }
    // If the attribute type is NO-USER-MODIFICATION, then it must not have a
    // usage of userApplications.
    if (isNoUserModification
        && attributeUsage == AttributeUsage.USER_APPLICATIONS)
    {
      LocalizableMessage message =
          WARN_ATTR_SYNTAX_ATTRTYPE_NO_USER_MOD_NOT_OPERATIONAL.get(oid);
      throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
    }
    CommonSchemaElements.checkSafeProperties(extraProperties);
    return new AttributeType(value.toString(), primaryName, typeNames, oid,
                             description, superiorType, syntax,
                             approximateMatchingRule, equalityMatchingRule,
                             orderingMatchingRule, substringMatchingRule,
                             attributeUsage, isCollective, isNoUserModification,
                             isObsolete, isSingleValue, extraProperties);
  }
  /**
   * Reads the next token name from the attribute type definition, skipping over
   * any leading or trailing spaces, and appends it to the provided buffer.
   *
   * @param  valueStr   The string representation of the attribute type
   *                    definition.
   * @param  tokenName  The buffer into which the token name will be written.
   * @param  startPos   The position in the provided string at which to start
   *                    reading the token name.
   *
   * @return  The position of the first character that is not part of the token
   *          name or one of the trailing spaces after it.
   *
   * @throws  DirectoryException  If a problem is encountered while reading the
   *                              token name.
   */
  private static int readTokenName(String valueStr, StringBuilder tokenName,
                                   int startPos)
          throws DirectoryException
  {
    // Skip over any spaces at the beginning of the value.
    char c = '\u0000';
    int  length = valueStr.length();
    while (startPos < length && ((c = valueStr.charAt(startPos)) == ' '))
    {
      startPos++;
    }
    if (startPos >= length)
    {
      LocalizableMessage message = ERR_ATTR_SYNTAX_ATTRTYPE_TRUNCATED_VALUE.get(valueStr);
      throw new DirectoryException(
              ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
    }
    // Read until we find the next space.
    while (startPos < length
        && ((c = valueStr.charAt(startPos)) != ' ')
        && ((c = valueStr.charAt(startPos)) != ')'))
    {
      tokenName.append(c);
      startPos++;
    }
    //We may be left with only ')' which is not part of the token yet.
    //Let us see if it is the case.
    if(tokenName.length()==0 && c == ')')
    {
      tokenName.append(c);
      startPos++;
    }
    // Skip over any trailing spaces after the value.
    while (startPos < length && ((c = valueStr.charAt(startPos)) == ' '))
    {
      startPos++;
    }
    // Return the position of the first non-space character after the token.
    return startPos;
  }
  /**
   * Reads the value of a string enclosed in single quotes, skipping over the
   * quotes and any leading or trailing spaces, and appending the string to the
   * provided buffer.
   *
   * @param  valueStr     The user-provided representation of the attribute type
   *                      definition.
   * @param  valueBuffer  The buffer into which the user-provided representation
   *                      of the value will be placed.
   * @param  startPos     The position in the provided string at which to start
   *                      reading the quoted string.
   *
   * @return  The position of the first character that is not part of the quoted
   *          string or one of the trailing spaces after it.
   *
   * @throws  DirectoryException  If a problem is encountered while reading the
   *                              quoted string.
   */
  private static int readQuotedString(String valueStr,
                                      StringBuilder valueBuffer, int startPos)
          throws DirectoryException
  {
    // Skip over any spaces at the beginning of the value.
    char c = '\u0000';
    int  length = valueStr.length();
    while (startPos < length && ((c = valueStr.charAt(startPos)) == ' '))
    {
      startPos++;
    }
    if (startPos >= length)
    {
      LocalizableMessage message = ERR_ATTR_SYNTAX_ATTRTYPE_TRUNCATED_VALUE.get(valueStr);
      throw new DirectoryException(
              ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
    }
    // The next character must be a single quote.
    if (c != '\'')
    {
      LocalizableMessage message = WARN_ATTR_SYNTAX_ATTRTYPE_EXPECTED_QUOTE_AT_POS.get(valueStr, startPos, c);
      throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
    }
    // Read until we find the closing quote.
    startPos++;
    while (startPos < length && ((c = valueStr.charAt(startPos)) != '\''))
    {
      valueBuffer.append(c);
      startPos++;
    }
    // Skip over any trailing spaces after the value.
    startPos++;
    while (startPos < length && ((c = valueStr.charAt(startPos)) == ' '))
    {
      startPos++;
    }
    // If we're at the end of the value, then that's illegal.
    if (startPos >= length)
    {
      LocalizableMessage message = ERR_ATTR_SYNTAX_ATTRTYPE_TRUNCATED_VALUE.get(valueStr);
      throw new DirectoryException(
              ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
    }
    // Return the position of the first non-space character after the token.
    return startPos;
  }
  /**
   * Reads the value of a string enclosed in single quotes, skipping over the
   * quotes and any leading or trailing spaces, and appending the string to the
   * provided buffer.
   *
   * @param  valueStr     The user-provided representation of the attribute type
   *                      definition.
   * @param  lowerStr     The all-lowercase representation of the attribute type
   *                      definition.
   * @param  userBuffer   The buffer into which the user-provided representation
   *                      of the value will be placed.
   * @param  lowerBuffer  The buffer into which the all-lowercase representation
   *                      of the value will be placed.
   * @param  startPos     The position in the provided string at which to start
   *                      reading the quoted string.
   *
   * @return  The position of the first character that is not part of the quoted
   *          string or one of the trailing spaces after it.
   *
   * @throws  DirectoryException  If a problem is encountered while reading the
   *                              quoted string.
   */
  private static int readQuotedString(String valueStr, String lowerStr,
                                      StringBuilder userBuffer,
                                      StringBuilder lowerBuffer, int startPos)
          throws DirectoryException
  {
    // Skip over any spaces at the beginning of the value.
    char c = '\u0000';
    int  length = lowerStr.length();
    while (startPos < length && ((c = lowerStr.charAt(startPos)) == ' '))
    {
      startPos++;
    }
    if (startPos >= length)
    {
      LocalizableMessage message = ERR_ATTR_SYNTAX_ATTRTYPE_TRUNCATED_VALUE.get(lowerStr);
      throw new DirectoryException(
              ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
    }
    // The next character must be a single quote.
    if (c != '\'')
    {
      LocalizableMessage message = WARN_ATTR_SYNTAX_ATTRTYPE_EXPECTED_QUOTE_AT_POS.get(valueStr, startPos, c);
      throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
    }
    // Read until we find the closing quote.
    startPos++;
    while (startPos < length && ((c = lowerStr.charAt(startPos)) != '\''))
    {
      lowerBuffer.append(c);
      userBuffer.append(valueStr.charAt(startPos));
      startPos++;
    }
    // Skip over any trailing spaces after the value.
    startPos++;
    while (startPos < length && ((c = lowerStr.charAt(startPos)) == ' '))
    {
      startPos++;
    }
    // If we're at the end of the value, then that's illegal.
    if (startPos >= length)
    {
      LocalizableMessage message = ERR_ATTR_SYNTAX_ATTRTYPE_TRUNCATED_VALUE.get(lowerStr);
      throw new DirectoryException(
              ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
    }
    // Return the position of the first non-space character after the token.
    return startPos;
  }
  /**
   * Reads the attribute description or numeric OID from the provided string,
   * skipping over any leading or trailing spaces, and appending the value to
   * the provided buffer.
   *
   * @param  lowerStr    The string from which the name or OID is to be read.
   * @param  woidBuffer  The buffer into which the name or OID should be
   *                     appended.
   * @param  startPos    The position at which to start reading.
   *
   * @return  The position of the first character after the name or OID that is
   *          not a space.
   *
   * @throws  DirectoryException  If a problem is encountered while reading the
   *                              name or OID.
   */
  private static int readWOID(String lowerStr, StringBuilder woidBuffer,
                              int startPos)
          throws DirectoryException
  {
    // Skip over any spaces at the beginning of the value.
    char c = '\u0000';
    int  length = lowerStr.length();
    while (startPos < length && ((c = lowerStr.charAt(startPos)) == ' '))
    {
      startPos++;
    }
    if (startPos >= length)
    {
      LocalizableMessage message = ERR_ATTR_SYNTAX_ATTRTYPE_TRUNCATED_VALUE.get(lowerStr);
      throw new DirectoryException(
              ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
    }
    // The next character must be either numeric (for an OID) or alphabetic (for
    // an attribute description).
    if (isDigit(c))
    {
      // This must be a numeric OID.  In that case, we will accept only digits
      // and periods, but not consecutive periods.
      boolean lastWasPeriod = false;
      while (startPos < length && ((c = lowerStr.charAt(startPos++)) != ' '))
      {
        if (c == '.')
        {
          if (lastWasPeriod)
          {
            throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
                ERR_ATTR_SYNTAX_ATTRTYPE_DOUBLE_PERIOD_IN_NUMERIC_OID
                    .get(lowerStr, startPos - 1));
          }
          else
          {
            woidBuffer.append(c);
            lastWasPeriod = true;
          }
        }
        else if (! isDigit(c))
        {
          // Technically, this must be an illegal character.  However, it is
          // possible that someone just got sloppy and did not include a space
          // between the name/OID and a closing parenthesis.  In that case,
          // we'll assume it's the end of the value.  What's more, we'll have
          // to prematurely return to nasty side effects from stripping off
          // additional characters.
          if (c == ')')
          {
            return startPos - 1;
          }
          // This must have been an illegal character.
          LocalizableMessage message =
              ERR_ATTR_SYNTAX_ATTRTYPE_ILLEGAL_CHAR_IN_NUMERIC_OID.get(lowerStr, c, startPos-1);
          throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
        }
        else
        {
          woidBuffer.append(c);
          lastWasPeriod = false;
        }
      }
    }
    else if (isAlpha(c))
    {
      // This must be an attribute description.  In this case, we will only
      // accept alphabetic characters, numeric digits, and the hyphen.
      while (startPos < length && ((c = lowerStr.charAt(startPos++)) != ' '))
      {
        if (isAlpha(c)
            || isDigit(c)
            || c == '-'
            || (c == '_' && DirectoryServer.allowAttributeNameExceptions()))
        {
          woidBuffer.append(c);
        }
        else
        {
          // Technically, this must be an illegal character.  However, it is
          // possible that someone just got sloppy and did not include a space
          // between the name/OID and a closing parenthesis.  In that case,
          // we'll assume it's the end of the value.  What's more, we'll have
          // to prematurely return to nasty side effects from stripping off
          // additional characters.
          if (c == ')')
          {
            return startPos - 1;
          }
          // This must have been an illegal character.
          LocalizableMessage message = ERR_ATTR_SYNTAX_ATTRTYPE_ILLEGAL_CHAR_IN_STRING_OID.get(
              lowerStr, c, startPos - 1);
          throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
        }
      }
    }
    else
    {
      LocalizableMessage message = ERR_ATTR_SYNTAX_ATTRTYPE_ILLEGAL_CHAR.get(lowerStr, c, startPos);
      throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
    }
    // Skip over any trailing spaces after the value.
    while (startPos < length && ((c = lowerStr.charAt(startPos)) == ' '))
    {
      startPos++;
    }
    // If we're at the end of the value, then that's illegal.
    if (startPos >= length)
    {
      LocalizableMessage message = ERR_ATTR_SYNTAX_ATTRTYPE_TRUNCATED_VALUE.get(lowerStr);
      throw new DirectoryException(
              ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
    }
    // Return the position of the first non-space character after the token.
    return startPos;
  }
  /**
   * Reads the value for an "extra" parameter.  It will handle a single unquoted
   * word (which is technically illegal, but we'll allow it), a single quoted
   * string, or an open parenthesis followed by a space-delimited set of quoted
   * strings or unquoted words followed by a close parenthesis.
   *
   * @param  valueStr   The string containing the information to be read.
   * @param  valueList  The list of "extra" parameter values read so far.
   * @param  startPos   The position in the value string at which to start
   *                    reading.
   *
   * @return  The "extra" parameter value that was read.
   *
   * @throws  DirectoryException  If a problem occurs while attempting to read
   *                              the value.
   */
  private static int readExtraParameterValues(String valueStr,
                          List<String> valueList, int startPos)
          throws DirectoryException
  {
    // Skip over any leading spaces.
    int length = valueStr.length();
    char c = '\u0000';
    while (startPos < length && ((c = valueStr.charAt(startPos)) == ' '))
    {
      startPos++;
    }
    if (startPos >= length)
    {
      LocalizableMessage message =
          ERR_ATTR_SYNTAX_ATTRTYPE_TRUNCATED_VALUE.get(valueStr);
      throw new DirectoryException(
              ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
    }
    // Look at the next character.  If it is a quote, then parse until the next
    // quote and end.  If it is an open parenthesis, then parse individual
    // values until the close parenthesis and end.  Otherwise, parse until the
    // next space and end.
    if (c == '\'')
    {
      // Parse until the closing quote.
      StringBuilder valueBuffer = new StringBuilder();
      startPos++;
      while (startPos < length && ((c = valueStr.charAt(startPos)) != '\''))
      {
        valueBuffer.append(c);
        startPos++;
      }
      startPos++;
      valueList.add(valueBuffer.toString());
    }
    else if (c == '(')
    {
      startPos++;
      // We're expecting a list of values. Quoted, space separated.
      while (true)
      {
        // Skip over any leading spaces;
        while (startPos < length && ((c = valueStr.charAt(startPos)) == ' '))
        {
          startPos++;
        }
        if (startPos >= length)
        {
          LocalizableMessage message =
              ERR_ATTR_SYNTAX_ATTRTYPE_TRUNCATED_VALUE.get(valueStr);
          throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
                                       message);
        }
        if (c == ')')
        {
          // This is the end of the list.
          startPos++;
          break;
        }
        else if (c == '(')
        {
          // This is an illegal character.
          LocalizableMessage message =
              ERR_ATTR_SYNTAX_ATTRSYNTAX_EXTENSION_INVALID_CHARACTER.get(
                      valueStr, startPos);
          throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
                                       message);
        }
        else if (c == '\'')
        {
          // We have a quoted string
          StringBuilder valueBuffer = new StringBuilder();
          startPos++;
          while (startPos < length
              && ((c = valueStr.charAt(startPos)) != '\''))
          {
            valueBuffer.append(c);
            startPos++;
          }
          valueList.add(valueBuffer.toString());
          startPos++;
        }
        else
        {
          //Consider unquoted string
          StringBuilder valueBuffer = new StringBuilder();
          while (startPos < length
              && ((c = valueStr.charAt(startPos)) != ' '))
          {
            valueBuffer.append(c);
            startPos++;
          }
          valueList.add(valueBuffer.toString());
        }
        if (startPos >= length)
        {
          LocalizableMessage message =
              ERR_ATTR_SYNTAX_ATTRTYPE_TRUNCATED_VALUE.get(valueStr);
          throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
                                       message);
        }
      }
    }
    else
    {
      // Parse until the next space.
      StringBuilder valueBuffer = new StringBuilder();
      while (startPos < length && ((c = valueStr.charAt(startPos)) != ' '))
      {
        valueBuffer.append(c);
        startPos++;
      }
      valueList.add(valueBuffer.toString());
    }
    // Skip over any trailing spaces.
    while (startPos < length && valueStr.charAt(startPos) == ' ')
    {
      startPos++;
    }
    if (startPos >= length)
    {
      LocalizableMessage message =
          ERR_ATTR_SYNTAX_ATTRTYPE_TRUNCATED_VALUE.get(valueStr);
      throw new DirectoryException(
              ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
    }
    return startPos;
  }
  /** {@inheritDoc} */
  @Override
  public ConfigChangeResult applyConfigurationChange(
              AttributeTypeDescriptionAttributeSyntaxCfg configuration)
  {
    ConfigChangeResult ccr = new ConfigChangeResult();
    currentConfig = configuration;
    stripMinimumUpperBound = configuration.isStripSyntaxMinUpperBound();
    updateNewSchema();
    return new ConfigChangeResult();
    try
    {
      serverContext.getSchema().updateSchemaOption(STRIP_UPPER_BOUND_FOR_ATTRIBUTE_TYPE, stripMinimumUpperBound);
    }
    catch (DirectoryException e)
    {
      ccr.setResultCode(e.getResultCode());
      ccr.addMessage(e.getMessageObject());
    }
    return ccr;
  }
  /** {@inheritDoc} */
  @Override
  public boolean isConfigurationChangeAcceptable(
                      AttributeTypeDescriptionAttributeSyntaxCfg configuration,
opendj-server-legacy/src/main/java/org/opends/server/schema/CertificateSyntax.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2012-2015 ForgeRock AS
 *      Portions Copyright 2012-2016 ForgeRock AS
 *      Portions Copyright 2013-2014 Manuel Gaupp
 */
package org.opends.server.schema;
@@ -37,11 +37,11 @@
import org.forgerock.opendj.ldap.schema.Schema;
import org.forgerock.opendj.ldap.schema.SchemaOptions;
import org.forgerock.opendj.ldap.schema.Syntax;
import org.forgerock.util.Option;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.server.CertificateAttributeSyntaxCfg;
import org.opends.server.api.AttributeSyntax;
import org.opends.server.core.ServerContext;
import org.opends.server.types.DirectoryException;
/**
@@ -69,37 +69,22 @@
    super();
  }
  /** {@inheritDoc} */
  @Override
  public void initializeSyntax(CertificateAttributeSyntaxCfg configuration, ServerContext serverContext)
         throws ConfigException
      throws ConfigException, DirectoryException
  {
    this.config = configuration;
    this.serverContext = serverContext;
    updateNewSchema();
    serverContext.getSchema().updateSchemaOption(SchemaOptions.ALLOW_MALFORMED_CERTIFICATES, !config.isStrictFormat());
    config.addCertificateChangeListener(this);
  }
  /** Update the option in new schema if it changes from current value. */
  private void updateNewSchema()
  {
    Option<Boolean> option = SchemaOptions.ALLOW_MALFORMED_CERTIFICATES;
    if (config.isStrictFormat() == serverContext.getSchemaNG().getOption(option))
    {
      SchemaUpdater schemaUpdater = serverContext.getSchemaUpdater();
      schemaUpdater.updateSchema(
          schemaUpdater.getSchemaBuilder().setOption(option, !config.isStrictFormat()).toSchema());
    }
  }
  /** {@inheritDoc} */
  @Override
  public Syntax getSDKSyntax(Schema schema)
  {
    return schema.getSyntax(SchemaConstants.SYNTAX_CERTIFICATE_OID);
  }
  /** {@inheritDoc} */
  @Override
  public boolean isConfigurationChangeAcceptable(
      CertificateAttributeSyntaxCfg configuration,
@@ -109,14 +94,23 @@
    return true;
  }
  /** {@inheritDoc} */
  @Override
  public ConfigChangeResult applyConfigurationChange(
      CertificateAttributeSyntaxCfg configuration)
  {
    this.config = configuration;
    updateNewSchema();
    return new ConfigChangeResult();
    final ConfigChangeResult ccr = new ConfigChangeResult();
    try
    {
      serverContext.getSchema()
          .updateSchemaOption(SchemaOptions.ALLOW_MALFORMED_CERTIFICATES, !config.isStrictFormat());
    }
    catch (DirectoryException e)
    {
      ccr.setResultCode(e.getResultCode());
      ccr.addMessage(e.getMessageObject());
    }
    return ccr;
  }
  /**
opendj-server-legacy/src/main/java/org/opends/server/schema/CollationMatchingRuleFactory.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2012-2015 ForgeRock AS
 *      Portions Copyright 2012-2016 ForgeRock AS
 */
package org.opends.server.schema;
@@ -45,6 +45,7 @@
import org.opends.server.admin.std.server.CollationMatchingRuleCfg;
import org.opends.server.api.MatchingRuleFactory;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.ServerContext;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.InitializationException;
import org.opends.server.util.CollectionUtils;
@@ -70,6 +71,8 @@
  /** Map of OID and the Matching Rule. */
  private final Map<String, MatchingRule> matchingRules = new HashMap<>();
  private ServerContext serverContext;
  /** Creates a new instance of CollationMatchingRuleFactory. */
  public CollationMatchingRuleFactory()
@@ -77,6 +80,17 @@
    super();
  }
  /**
   * Sets the server context.
   *
   * @param serverContext
   *            The server context.
   */
  public void setServerContext(ServerContext serverContext)
  {
    this.serverContext = serverContext;
  }
  /** {@inheritDoc} */
  @Override
  public final Collection<org.forgerock.opendj.ldap.schema.MatchingRule> getMatchingRules()
@@ -196,13 +210,13 @@
    // Clear the associated matching rules.
    resetRules();
    final Schema coreSchema = CoreSchema.getInstance();
    final Schema schema = serverContext.getSchemaNG();
    for (String collation : configuration.getCollation())
    {
      // validation has already been performed in isConfigurationChangeAcceptable()
      CollationMapper mapper = new CollationMapper(collation);
      String nOID = mapper.getNumericOID();
      addMatchingRule(nOID, coreSchema.getMatchingRule(nOID));
      addMatchingRule(nOID, schema.getMatchingRule(nOID));
    }
    try
opendj-server-legacy/src/main/java/org/opends/server/schema/CoreSchemaProvider.java
@@ -21,7 +21,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2014 ForgeRock AS.
 *      Copyright 2014-2016 ForgeRock AS.
 *      Portions Copyright 2014-2015 ForgeRock AS
 */
package org.opends.server.schema;
@@ -34,10 +34,14 @@
import org.forgerock.opendj.config.server.ConfigChangeResult;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.config.server.ConfigurationChangeListener;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.schema.Schema;
import org.forgerock.opendj.ldap.schema.SchemaBuilder;
import org.forgerock.opendj.server.config.server.CoreSchemaCfg;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.ServerContext;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.InitializationException;
import org.opends.server.types.Schema.SchemaUpdater;
/**
 * Provides the core schema, which includes core matching rules and syntaxes.
@@ -50,20 +54,14 @@
  /** The current configuration of core schema. */
  private CoreSchemaCfg currentConfig;
  /** The current schema builder. */
  private SchemaBuilder currentSchemaBuilder;
  private ServerContext serverContext;
  /** Updater to notify schema update when configuration changes. */
  private SchemaUpdater schemaUpdater;
  /** {@inheritDoc} */
  @Override
  public void initialize(final CoreSchemaCfg configuration, final SchemaBuilder initialSchemaBuilder,
      final SchemaUpdater schemaUpdater) throws ConfigException, InitializationException
  public void initialize(final ServerContext serverContext, final CoreSchemaCfg configuration,
      final SchemaBuilder initialSchemaBuilder) throws ConfigException, InitializationException
  {
    this.serverContext = serverContext;
    this.currentConfig = configuration;
    this.currentSchemaBuilder = initialSchemaBuilder;
    this.schemaUpdater = schemaUpdater;
    updateSchemaFromConfiguration(initialSchemaBuilder, configuration);
@@ -107,14 +105,12 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  public void finalizeProvider()
  {
    currentConfig.removeCoreSchemaChangeListener(this);
  }
  /** {@inheritDoc} */
  @Override
  public boolean isConfigurationAcceptable(final CoreSchemaCfg configuration,
      final List<LocalizableMessage> unacceptableReasons)
@@ -123,14 +119,6 @@
    return true;
  }
  /** {@inheritDoc} */
  @Override
  public SchemaBuilder getSchema()
  {
    return currentSchemaBuilder;
  }
  /** {@inheritDoc} */
  @Override
  public boolean isConfigurationChangeAcceptable(final CoreSchemaCfg configuration,
      final List<LocalizableMessage> unacceptableReasons)
@@ -145,20 +133,29 @@
    return true;
  }
  /** {@inheritDoc} */
  @Override
  public ConfigChangeResult applyConfigurationChange(final CoreSchemaCfg configuration)
  {
    currentSchemaBuilder = schemaUpdater.getSchemaBuilder();
    updateSchemaFromConfiguration(currentSchemaBuilder, configuration);
    final boolean isUpdated = schemaUpdater.updateSchema(currentSchemaBuilder.toSchema());
    // TODO : fix result code + log an error in case of failure
    final ConfigChangeResult result = new ConfigChangeResult();
    result.setResultCode(isUpdated ? ResultCode.SUCCESS : ResultCode.OTHER);
    return result;
    final ConfigChangeResult ccr = new ConfigChangeResult();
    // TODO : the server schema should probably be renamed to something like ServerSchema
    // Even after migration to SDK schema, it will be probably be kept
    try
    {
      serverContext.getSchema().updateSchema(new SchemaUpdater()
      {
        @Override
        public Schema update(SchemaBuilder builder)
        {
          updateSchemaFromConfiguration(builder, configuration);
          return builder.toSchema();
        }
      });
    }
    catch (DirectoryException e)
    {
      ccr.setResultCode(DirectoryServer.getServerErrorResultCode());
      ccr.addMessage(e.getMessageObject());
    }
    return ccr;
  }
}
opendj-server-legacy/src/main/java/org/opends/server/schema/CountryStringSyntax.java
@@ -22,12 +22,12 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2012-2015 ForgeRock AS
 *      Portions Copyright 2012-2016 ForgeRock AS
 *      Portions Copyright 2012 Manuel Gaupp
 */
package org.opends.server.schema;
import static org.forgerock.opendj.ldap.schema.SchemaOptions.*;
import static org.opends.server.schema.SchemaConstants.*;
import java.util.List;
@@ -36,13 +36,12 @@
import org.forgerock.opendj.config.server.ConfigChangeResult;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.schema.Schema;
import org.forgerock.opendj.ldap.schema.SchemaOptions;
import org.forgerock.opendj.ldap.schema.Syntax;
import org.forgerock.util.Option;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.server.CountryStringAttributeSyntaxCfg;
import org.opends.server.api.AttributeSyntax;
import org.opends.server.core.ServerContext;
import org.opends.server.types.DirectoryException;
/**
 * This class defines the country string attribute syntax, which should be a
@@ -71,37 +70,22 @@
    super();
  }
  /** {@inheritDoc} */
  @Override
  public void initializeSyntax(CountryStringAttributeSyntaxCfg configuration, ServerContext serverContext)
         throws ConfigException
      throws ConfigException, DirectoryException
  {
    this.config = configuration;
    this.serverContext = serverContext;
    updateNewSchema();
    serverContext.getSchema().updateSchemaOption(STRICT_FORMAT_FOR_COUNTRY_STRINGS, config.isStrictFormat());
    config.addCountryStringChangeListener(this);
  }
  /** Update the option in new schema if it changes from current value. */
  private void updateNewSchema()
  {
    Option<Boolean> option = SchemaOptions.STRICT_FORMAT_FOR_COUNTRY_STRINGS;
    if (config.isStrictFormat() != serverContext.getSchemaNG().getOption(option))
    {
      SchemaUpdater schemaUpdater = serverContext.getSchemaUpdater();
      schemaUpdater.updateSchema(
          schemaUpdater.getSchemaBuilder().setOption(option, config.isStrictFormat()).toSchema());
    }
  }
  /** {@inheritDoc} */
  @Override
  public Syntax getSDKSyntax(Schema schema)
  {
    return schema.getSyntax(SchemaConstants.SYNTAX_COUNTRY_STRING_OID);
  }
  /** {@inheritDoc} */
  @Override
  public boolean isConfigurationChangeAcceptable(
      CountryStringAttributeSyntaxCfg configuration,
@@ -111,46 +95,36 @@
    return true;
  }
  /** {@inheritDoc} */
  @Override
  public ConfigChangeResult applyConfigurationChange(
      CountryStringAttributeSyntaxCfg configuration)
  public ConfigChangeResult applyConfigurationChange(CountryStringAttributeSyntaxCfg configuration)
  {
    this.config = configuration;
    updateNewSchema();
    return new ConfigChangeResult();
    final ConfigChangeResult ccr = new ConfigChangeResult();
    try
    {
      serverContext.getSchema().updateSchemaOption(STRICT_FORMAT_FOR_COUNTRY_STRINGS, config.isStrictFormat());
    }
    catch (DirectoryException e)
    {
      ccr.setResultCode(e.getResultCode());
      ccr.addMessage(e.getMessageObject());
    }
    return ccr;
  }
  /**
   * Retrieves the common name for this attribute syntax.
   *
   * @return  The common name for this attribute syntax.
   */
  @Override
  public String getName()
  {
    return SYNTAX_COUNTRY_STRING_NAME;
  }
  /**
   * Retrieves the OID for this attribute syntax.
   *
   * @return  The OID for this attribute syntax.
   */
  @Override
  public String getOID()
  {
    return SYNTAX_COUNTRY_STRING_OID;
  }
  /**
   * Retrieves a description for this attribute syntax.
   *
   * @return  A description for this attribute syntax.
   */
  @Override
  public String getDescription()
  {
opendj-server-legacy/src/main/java/org/opends/server/schema/DITContentRuleSyntax.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.schema;
@@ -39,12 +39,12 @@
import org.forgerock.i18n.LocalizableMessageDescriptor.Arg2;
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.ldap.schema.ObjectClassType;
import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.opends.server.api.AttributeSyntax;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.AttributeType;
import org.opends.server.types.DITContentRule;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.ObjectClass;
@@ -660,16 +660,9 @@
  {
    String woidString = woidBuffer.toString();
    AttributeType attr = schema.getAttributeType(woidString);
    if (attr == null)
    if (attr.isPlaceHolder() && !allowUnknownElements)
    {
      // This isn't good because it means that the DIT content rule
      // refers to an attribute type that we don't know anything about.
      if (!allowUnknownElements)
      {
        throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
            msg.get(valueStr, woidString));
      }
      attr = DirectoryServer.getAttributeTypeOrDefault(woidString);
      throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, msg.get(valueStr, woidString));
    }
    return attr;
  }
opendj-server-legacy/src/main/java/org/opends/server/schema/DirectoryStringSyntax.java
@@ -22,9 +22,11 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2012-2015 ForgeRock AS
 *      Portions Copyright 2012-2016 ForgeRock AS
 */
package org.opends.server.schema;
import static org.forgerock.opendj.ldap.schema.SchemaOptions.*;
import static org.opends.server.schema.SchemaConstants.*;
import java.util.List;
@@ -33,13 +35,12 @@
import org.forgerock.opendj.config.server.ConfigChangeResult;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.schema.Schema;
import org.forgerock.opendj.ldap.schema.SchemaOptions;
import org.forgerock.opendj.ldap.schema.Syntax;
import org.forgerock.util.Option;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.server.DirectoryStringAttributeSyntaxCfg;
import org.opends.server.api.AttributeSyntax;
import org.opends.server.core.ServerContext;
import org.opends.server.types.DirectoryException;
/**
@@ -72,10 +73,9 @@
    super();
  }
  /** {@inheritDoc} */
  @Override
  public void initializeSyntax(DirectoryStringAttributeSyntaxCfg configuration, ServerContext serverContext)
         throws ConfigException
      throws ConfigException, DirectoryException
  {
    this.serverContext = serverContext;
@@ -91,64 +91,33 @@
    currentConfig = configuration;
    currentConfig.addDirectoryStringChangeListener(this);
    allowZeroLengthValues = currentConfig.isAllowZeroLengthValues();
    updateNewSchema();
    serverContext.getSchema().updateSchemaOption(ALLOW_ZERO_LENGTH_DIRECTORY_STRINGS, allowZeroLengthValues);
  }
  /** Update the option in new schema if it changes from current value. */
  private void updateNewSchema()
  {
    Option<Boolean> option = SchemaOptions.ALLOW_ZERO_LENGTH_DIRECTORY_STRINGS;
    if (allowZeroLengthValues != serverContext.getSchemaNG().getOption(option))
    {
      SchemaUpdater schemaUpdater = serverContext.getSchemaUpdater();
      schemaUpdater.updateSchema(
          schemaUpdater.getSchemaBuilder().setOption(option, allowZeroLengthValues).toSchema());
    }
  }
  /** {@inheritDoc} */
  @Override
  public Syntax getSDKSyntax(Schema schema)
  {
    return schema.getSyntax(SchemaConstants.SYNTAX_DIRECTORY_STRING_OID);
  }
  /**
   * Performs any finalization that may be necessary for this attribute syntax.
   */
  @Override
  public void finalizeSyntax()
  {
    currentConfig.removeDirectoryStringChangeListener(this);
  }
  /**
   * Retrieves the common name for this attribute syntax.
   *
   * @return  The common name for this attribute syntax.
   */
  @Override
  public String getName()
  {
    return SYNTAX_DIRECTORY_STRING_NAME;
  }
  /**
   * Retrieves the OID for this attribute syntax.
   *
   * @return  The OID for this attribute syntax.
   */
  @Override
  public String getOID()
  {
    return SYNTAX_DIRECTORY_STRING_OID;
  }
  /**
   * Retrieves a description for this attribute syntax.
   *
   * @return  A description for this attribute syntax.
   */
  @Override
  public String getDescription()
  {
@@ -170,7 +139,6 @@
    return allowZeroLengthValues;
  }
  /** {@inheritDoc} */
  @Override
  public boolean isConfigurationChangeAcceptable(
                      DirectoryStringAttributeSyntaxCfg configuration,
@@ -180,16 +148,22 @@
    return true;
  }
  /** {@inheritDoc} */
  @Override
  public ConfigChangeResult applyConfigurationChange(
              DirectoryStringAttributeSyntaxCfg configuration)
  {
    currentConfig = configuration;
    allowZeroLengthValues = configuration.isAllowZeroLengthValues();
    updateNewSchema();
    return new ConfigChangeResult();
    final ConfigChangeResult ccr = new ConfigChangeResult();
    try
    {
      serverContext.getSchema().updateSchemaOption(ALLOW_ZERO_LENGTH_DIRECTORY_STRINGS, allowZeroLengthValues);
    }
    catch (DirectoryException e)
    {
      ccr.setResultCode(e.getResultCode());
      ccr.addMessage(e.getMessageObject());
    }
    return ccr;
  }
}
opendj-server-legacy/src/main/java/org/opends/server/schema/JPEGSyntax.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2012-2015 ForgeRock AS
 *      Portions Copyright 2012-2016 ForgeRock AS
 *
 */
package org.opends.server.schema;
@@ -37,11 +37,11 @@
import org.forgerock.opendj.ldap.schema.Schema;
import org.forgerock.opendj.ldap.schema.SchemaOptions;
import org.forgerock.opendj.ldap.schema.Syntax;
import org.forgerock.util.Option;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.server.JPEGAttributeSyntaxCfg;
import org.opends.server.api.AttributeSyntax;
import org.opends.server.core.ServerContext;
import org.opends.server.types.DirectoryException;
/**
 * This class implements the JPEG attribute syntax.  This is actually
@@ -70,70 +70,40 @@
    super();
  }
  /** {@inheritDoc} */
  @Override
  public void initializeSyntax(JPEGAttributeSyntaxCfg configuration, ServerContext serverContext)
         throws ConfigException
      throws ConfigException, DirectoryException
  {
    this.config = configuration;
    this.serverContext = serverContext;
    updateNewSchema();
    serverContext.getSchema().updateSchemaOption(SchemaOptions.ALLOW_MALFORMED_JPEG_PHOTOS, !config.isStrictFormat());
    config.addJPEGChangeListener(this);
  }
  /** Update the option in new schema if it changes from current value. */
  private void updateNewSchema()
  {
    Option<Boolean> option = SchemaOptions.ALLOW_MALFORMED_JPEG_PHOTOS;
    if (config.isStrictFormat() == serverContext.getSchemaNG().getOption(option))
    {
      SchemaUpdater schemaUpdater = serverContext.getSchemaUpdater();
      schemaUpdater.updateSchema(
          schemaUpdater.getSchemaBuilder().setOption(option, !config.isStrictFormat()).toSchema());
    }
  }
  /** {@inheritDoc} */
  @Override
  public Syntax getSDKSyntax(Schema schema)
  {
    return schema.getSyntax(SchemaConstants.SYNTAX_JPEG_OID);
  }
  /**
   * Retrieves the common name for this attribute syntax.
   *
   * @return  The common name for this attribute syntax.
   */
  @Override
  public String getName()
  {
    return SYNTAX_JPEG_NAME;
  }
  /**
   * Retrieves the OID for this attribute syntax.
   *
   * @return  The OID for this attribute syntax.
   */
  @Override
  public String getOID()
  {
    return SYNTAX_JPEG_OID;
  }
  /**
   * Retrieves a description for this attribute syntax.
   *
   * @return  A description for this attribute syntax.
   */
  @Override
  public String getDescription()
  {
    return SYNTAX_JPEG_DESCRIPTION;
  }
  /** {@inheritDoc} */
  @Override
  public boolean isConfigurationChangeAcceptable(
                      JPEGAttributeSyntaxCfg configuration,
@@ -143,14 +113,22 @@
    return true;
  }
  /** {@inheritDoc} */
  @Override
  public ConfigChangeResult applyConfigurationChange(
              JPEGAttributeSyntaxCfg configuration)
  {
    this.config = configuration;
    updateNewSchema();
    return new ConfigChangeResult();
    final ConfigChangeResult ccr = new ConfigChangeResult();
    try
    {
      serverContext.getSchema().updateSchemaOption(SchemaOptions.ALLOW_MALFORMED_JPEG_PHOTOS, !config.isStrictFormat());
    }
    catch (DirectoryException e)
    {
      ccr.setResultCode(e.getResultCode());
      ccr.addMessage(e.getMessageObject());
    }
    return ccr;
  }
}
opendj-server-legacy/src/main/java/org/opends/server/schema/LDAPSyntaxDescriptionSyntax.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.schema;
@@ -41,14 +41,12 @@
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.forgerock.opendj.ldap.schema.SchemaBuilder;
import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.opends.server.api.AttributeSyntax;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.ServerContext;
import org.opends.server.types.CommonSchemaElements;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.LDAPSyntaxDescription;
@@ -190,8 +188,6 @@
   * @param  value                 The byte sequence containing the value
   *                               to decode (it does not need to be
   *                               normalized).
   * @param serverContext
   *            The server context.
   * @param  schema                The schema to use to resolve references to
   *                               other schema elements.
   * @param  allowUnknownElements  Indicates whether to allow values that are
@@ -207,8 +203,9 @@
   * @throws  DirectoryException  If the provided value cannot be decoded as an
   *                              ldapsyntax definition.
   */
  public static LDAPSyntaxDescription decodeLDAPSyntax(ByteSequence value, ServerContext serverContext,
          Schema schema, boolean allowUnknownElements, boolean forDelete) throws DirectoryException
  public static LDAPSyntaxDescription decodeLDAPSyntax(
      ByteSequence value, Schema schema, boolean allowUnknownElements, boolean forDelete)
          throws DirectoryException
  {
    // Get string representations of the provided value using the provided form.
    String valueStr = value.toString();
@@ -275,24 +272,17 @@
          if (lastWasPeriod)
          {
            LocalizableMessage message =
              ERR_ATTR_SYNTAX_LDAPSYNTAX_DOUBLE_PERIOD_IN_NUMERIC_OID.
                  get(valueStr, pos-1);
            throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
                                         message);
              ERR_ATTR_SYNTAX_LDAPSYNTAX_DOUBLE_PERIOD_IN_NUMERIC_OID.get(valueStr, pos-1);
            throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
          }
          else
          {
            lastWasPeriod = true;
          }
          lastWasPeriod = true;
        }
        else if (! isDigit(c))
        {
          // This must have been an illegal character.
          LocalizableMessage message =
              ERR_ATTR_SYNTAX_LDAPSYNTAX_ILLEGAL_CHAR_IN_NUMERIC_OID.
                get(valueStr, c, pos-1);
          throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX,
                                       message);
              ERR_ATTR_SYNTAX_LDAPSYNTAX_ILLEGAL_CHAR_IN_NUMERIC_OID.get(valueStr, c, pos-1);
          throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message);
        }
        else
        {
@@ -394,8 +384,7 @@
      }
      else
      {
        SchemaBuilder schemaBuilder = serverContext != null ?
            serverContext.getSchemaUpdater().getSchemaBuilder() : new SchemaBuilder(CoreSchema.getInstance());
        SchemaBuilder schemaBuilder = new SchemaBuilder(schema.getSchemaNG());
        if (lowerTokenName.equals("x-subst"))
        {
@@ -528,7 +517,7 @@
    CommonSchemaElements.checkSafeProperties(extraProperties);
    //Since we reached here it means everything is OK.
    return new LDAPSyntaxDescription(valueStr, syntax, extraProperties);
    return new LDAPSyntaxDescription(valueStr, syntax.getOID(), extraProperties);
  }
  /**
opendj-server-legacy/src/main/java/org/opends/server/schema/MatchingRuleUseSyntax.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.schema;
import static org.opends.messages.SchemaMessages.*;
@@ -37,12 +37,12 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.opends.server.api.AttributeSyntax;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.AttributeType;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.MatchingRuleUse;
import org.opends.server.types.Schema;
@@ -442,16 +442,10 @@
  {
    String woidString = woidBuffer.toString();
    AttributeType attr = schema.getAttributeType(woidString);
    if (attr == null)
    if (attr.isPlaceHolder() && !allowUnknownElements)
    {
      // This isn't good because it means that the matching rule use
      // refers to an attribute type that we don't know anything about.
      if (!allowUnknownElements)
      {
        throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
            ERR_ATTR_SYNTAX_MRUSE_UNKNOWN_ATTR.get(oid, woidString));
      }
      attr = DirectoryServer.getAttributeTypeOrDefault(woidString);
      throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
          ERR_ATTR_SYNTAX_MRUSE_UNKNOWN_ATTR.get(oid, woidString));
    }
    return attr;
  }
opendj-server-legacy/src/main/java/org/opends/server/schema/NameFormSyntax.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.schema;
@@ -39,12 +39,12 @@
import org.forgerock.i18n.LocalizableMessageDescriptor.Arg2;
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.ldap.schema.ObjectClassType;
import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.opends.server.api.AttributeSyntax;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.AttributeType;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.NameForm;
import org.opends.server.types.ObjectClass;
@@ -531,16 +531,9 @@
  {
    String woidString = woidBuffer.toString();
    AttributeType attr = schema.getAttributeType(woidString);
    if (attr == null)
    if (attr.isPlaceHolder() && !allowUnknownElements)
    {
      // This isn't good because it means that the name form
      // refers to an attribute type that we don't know anything about.
      if (!allowUnknownElements)
      {
        throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
            msg.get(oid, woidString));
      }
      attr = DirectoryServer.getAttributeTypeOrDefault(woidString);
      throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, msg.get(oid, woidString));
    }
    return attr;
  }
opendj-server-legacy/src/main/java/org/opends/server/schema/ObjectClassSyntax.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2012-2015 ForgeRock AS
 *      Portions Copyright 2012-2016 ForgeRock AS
 */
package org.opends.server.schema;
@@ -43,12 +43,12 @@
import org.forgerock.i18n.LocalizableMessageDescriptor.Arg2;
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.ldap.schema.ObjectClassType;
import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.opends.server.api.AttributeSyntax;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.AttributeType;
import org.opends.server.types.CommonSchemaElements;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.ObjectClass;
@@ -719,16 +719,10 @@
  {
    String woidString = woidBuffer.toString();
    AttributeType attr = schema.getAttributeType(woidString);
    if (attr == null)
    if (attr.isPlaceHolder() && !allowUnknownElements)
    {
      // This isn't good because it means that the objectclass
      // refers to an attribute type that we don't know anything about.
      if (!allowUnknownElements)
      {
        LocalizableMessage message = msg.get(oid, woidString);
        throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
      }
      attr = DirectoryServer.getAttributeTypeOrDefault(woidString);
      LocalizableMessage message = msg.get(oid, woidString);
      throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
    }
    return attr;
  }
opendj-server-legacy/src/main/java/org/opends/server/schema/SchemaProvider.java
@@ -21,8 +21,8 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2014 ForgeRock AS.
 *      Portions Copyright 2014 ForgeRock AS
 *      Copyright 2014-2016 ForgeRock AS.
 *      Portions Copyright 2014-2015 ForgeRock AS
 */
package org.opends.server.schema;
@@ -32,6 +32,7 @@
import org.forgerock.opendj.ldap.schema.SchemaBuilder;
import org.forgerock.opendj.server.config.server.SchemaProviderCfg;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.ServerContext;
import org.opends.server.types.InitializationException;
/**
@@ -50,12 +51,12 @@
   * Initialize the schema provider from provided configuration and schema
   * builder.
   *
   * @param serverContext
   *            The server context.
   * @param configuration
   *          Configuration of the provider.
   * @param initialSchemaBuilder
   *          Schema builder to update during initialization phase.
   * @param schemaUpdater
   *          The updater to call when applying a configuration change.
   * @throws ConfigException
   *           If a configuration problem arises in the process of performing
   *           the initialization.
@@ -63,7 +64,7 @@
   *           If a problem that is not configuration-related occurs during
   *           initialization.
   */
  void initialize(T configuration, SchemaBuilder initialSchemaBuilder, SchemaUpdater schemaUpdater)
  void initialize(ServerContext serverContext, T configuration, SchemaBuilder initialSchemaBuilder)
      throws ConfigException, InitializationException;
  /**
@@ -85,10 +86,4 @@
   */
  boolean isConfigurationAcceptable(T configuration, List<LocalizableMessage> unacceptableReasons);
  /**
   * Returns the schema builder, as updated by this provider.
   *
   * @return the schema builder resulting from this provider.
   */
  SchemaBuilder getSchema();
}
opendj-server-legacy/src/main/java/org/opends/server/schema/SchemaUpdater.java
File was deleted
opendj-server-legacy/src/main/java/org/opends/server/schema/SomeSchemaElement.java
New file
@@ -0,0 +1,307 @@
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 *
 *
 *      Copyright 2015-2016 ForgeRock AS
 */
package org.opends.server.schema;
import static org.opends.server.util.ServerConstants.*;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.ldap.schema.Schema;
import org.forgerock.opendj.ldap.schema.SchemaBuilder;
import org.opends.server.config.ConfigConstants;
import org.opends.server.core.ServerContext;
import org.opends.server.types.CommonSchemaElements;
import org.opends.server.types.ObjectClass;
import org.opends.server.types.SchemaFileElement;
import org.opends.server.util.RemoveOnceSDKSchemaIsUsed;
import org.opends.server.util.ServerConstants;
/**
 * Represents a schema element which is either a SDK attribute type or an objectclass from the server.
 * <p>
 * In absence of a common interface, this class allows to process all elements in the same way,
 * and to provide useful server-oriented methods like {@code getSchemaFile()} or
 * {@code getOrigin()}.
 */
@RemoveOnceSDKSchemaIsUsed("This class is a temporary mechanism"
    + " to manage in the same way SDK and server schema element classes")
public class SomeSchemaElement implements SchemaFileElement
{
  private final ObjectClass objectClass;
  private AttributeType attributeType;
  /**
   * Builds SomeSchemaElement.
   *
   * @param objectClass
   *          the common schema element to wrap
   */
  public SomeSchemaElement(ObjectClass objectClass)
  {
    this.objectClass = objectClass;
    this.attributeType = null;
  }
  /**
   * Builds SomeSchemaElement.
   *
   * @param attributeType
   *          the attribute type element to wrap
   */
  public SomeSchemaElement(AttributeType attributeType)
  {
    this.objectClass = null;
    this.attributeType = attributeType;
  }
  /**
   * Returns the wrapped schema element as an object class.
   *
   * @return the wrapped object class
   */
  public ObjectClass getObjectClass()
  {
    return objectClass;
  }
  /**
   * Returns the wrapped schema element as an attribute type.
   *
   * @return the wrapped attribute type
   */
  public AttributeType getAttributeType()
  {
    return attributeType;
  }
  /**
   * Returns whether the wrapped element is an attribute type.
   *
   * @return {@code true} when the wrapped element is an attribute type, {@code false} otherwise
   */
  public boolean isAttributeType()
  {
    return attributeType != null;
  }
  /**
   * Returns whether the wrapped element is an object class.
   *
   * @return {@code true} when the wrapped element is an object class, {@code false} otherwise
   */
  public boolean isObjectClass()
  {
    return objectClass != null;
  }
  /**
   * Returns the OID of the wrapped element.
   *
   * @return the OID of the wrapped element.
   */
  public String getOID()
  {
    return attributeType != null ? attributeType.getOID() : objectClass.getOID();
  }
  /**
   * Returns the name or OID of the wrapped element.
   *
   * @return the name or OID of the wrapped element.
   */
  public String getNameOrOID()
  {
    return attributeType != null ? attributeType.getNameOrOID() : objectClass.getNameOrOID();
  }
  /**
   * Returns the names of the wrapped element.
   *
   * @return the names of the wrapped element.
   */
  public Iterable<String> getNames()
  {
    return attributeType != null ? attributeType.getNames() : objectClass.getNormalizedNames();
  }
  @Override
  public Map<String, List<String>> getExtraProperties()
  {
    return attributeType != null ? attributeType.getExtraProperties() : objectClass.getExtraProperties();
  }
  @Override
  public String toString()
  {
    return attributeType != null ? attributeType.toString() : objectClass.toString();
  }
  /**
   * Retrieves the definition string used to create this attribute
   * type and including the X-SCHEMA-FILE extension.
   *
   * @return  The definition string used to create this attribute
   *          type including the X-SCHEMA-FILE extension.
   */
  public String getDefinitionWithFileName()
  {
    final String schemaFile = getSchemaFile();
    final String definition = toString();
    if (schemaFile != null)
    {
      int pos = definition.lastIndexOf(')');
      return definition.substring(0, pos).trim() + " " + SCHEMA_PROPERTY_FILENAME + " '" + schemaFile + "' )";
    }
    return definition;
  }
  /**
   * Returns the name of the schema file that contains the definition of the wrapped element.
   *
   * @return the name of the schema file that contains the definition of the wrapped element.
   */
  public String getSchemaFile()
  {
    return getExtraPropertySingleValue(ServerConstants.SCHEMA_PROPERTY_FILENAME);
  }
  /**
   * Sets the name of the schema file that contains the definition of the wrapped element.
   *
   * @param serverContext
   *          the server context
   * @param schemaFile
   *          the name of the schema file that contains the definition of the wrapped element.
   */
  public void setSchemaFile(ServerContext serverContext, String schemaFile)
  {
    setExtraPropertySingleValue(serverContext, SCHEMA_PROPERTY_FILENAME, schemaFile);
  }
  /**
   * Returns the origin of the provided schema element.
   * @return the origin of the provided schema element.
   */
  public String getOrigin()
  {
    return getExtraPropertySingleValue(ServerConstants.SCHEMA_PROPERTY_ORIGIN);
  }
  private String getExtraPropertySingleValue(String schemaPropertyOrigin)
  {
    if (objectClass != null)
    {
      return CommonSchemaElements.getSingleValueProperty(objectClass, schemaPropertyOrigin);
    }
    List<String> values = attributeType.getExtraProperties().get(schemaPropertyOrigin);
    return values != null && !values.isEmpty() ? values.get(0) : null;
  }
  /**
   * Returns the attribute name of the wrapped element.
   * @return the attribute name of the wrapped element.
   */
  public String getAttributeName()
  {
    return attributeType!= null ? ConfigConstants.ATTR_ATTRIBUTE_TYPES : ConfigConstants.ATTR_OBJECTCLASSES;
  }
  /**
   * Sets a single-valued extra property on the wrapped element.
   *
   * @param serverContext
   *          the server context
   * @param property
   *          the property to set
   * @param value
   *          the value to set
   */
  public void setExtraPropertySingleValue(ServerContext serverContext, String property, String value)
  {
    if (attributeType != null)
    {
      List<String> values = value != null ?  Arrays.asList(value) : null;
      setExtraPropertyMultipleValues(serverContext, property, values);
    }
    else
    {
      CommonSchemaElements.setExtraProperty(objectClass, property, value);
    }
  }
  /**
   * Sets a multi-valued extra property on the wrapped element.
   *
   * @param serverContext
   *          the server context
   * @param property
   *          the property to set
   * @param values
   *          the values to set
   */
  public void setExtraPropertyMultipleValues(ServerContext serverContext, String property, List<String> values)
  {
    if (attributeType != null)
    {
      SchemaBuilder schemaBuilder = serverContext != null ?
          new SchemaBuilder(serverContext.getSchemaNG()) : new SchemaBuilder(Schema.getDefaultSchema());
      AttributeType.Builder builder =
          schemaBuilder.buildAttributeType(attributeType).removeExtraProperty(property, (String) null);
      if (values != null  && !values.isEmpty())
      {
        builder.extraProperties(property, values);
      }
      attributeType = builder.addToSchemaOverwrite().toSchema().getAttributeType(attributeType.getNameOrOID());
    }
    else
    {
      objectClass.setExtraProperty(property, values);
    }
  }
  /**
   * Returns a copy of the provided attribute type, changing the superior attribute type.
   *
   * @param attributeType
   *          the attribute type for which a modified copy must be built
   * @param newSuperiorType
   *          the new superior attribute type to set, {@code null} means remove the superior type
   * @return an attribute type builder to build an updated copy of the provided attribute type
   */
  public static AttributeType changeSuperiorType(AttributeType attributeType, AttributeType newSuperiorType)
  {
    String superiorTypeOID = newSuperiorType != null ? newSuperiorType.getNameOrOID() : null;
    Schema schema = new SchemaBuilder()
      .buildAttributeType(attributeType)
      .superiorType(superiorTypeOID)
      .addToSchemaOverwrite()
      .toSchema();
    return schema.getAttributeType(attributeType.getNameOrOID());
  }
}
opendj-server-legacy/src/main/java/org/opends/server/schema/SubtreeSpecificationSyntax.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.schema;
@@ -32,17 +32,17 @@
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ByteSequence;
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.forgerock.opendj.ldap.schema.Schema;
import org.forgerock.opendj.ldap.schema.SchemaBuilder;
import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.opends.server.api.AttributeSyntax;
import org.opends.server.core.ServerContext;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Schema.SchemaUpdater;
import org.opends.server.types.SubtreeSpecification;
/**
 * This class defines the subtree specification attribute syntax,
 * which is used to specify the scope of sub-entries (RFC 3672).
@@ -63,76 +63,61 @@
    // No implementation required.
  }
  /** {@inheritDoc} */
  @Override
  public void initializeSyntax(AttributeSyntaxCfg configuration, ServerContext serverContext)
      throws ConfigException
      throws ConfigException, DirectoryException
  {
    // Add the subtree specification syntax to the "new" schema
    SchemaUpdater schemaUpdater = serverContext.getSchemaUpdater();
    SchemaBuilder builder = schemaUpdater.getSchemaBuilder().buildSyntax(SYNTAX_SUBTREE_SPECIFICATION_OID)
      .description(SYNTAX_SUBTREE_SPECIFICATION_DESCRIPTION)
      .implementation(new SubtreeSpecificationSyntaxImpl())
      .addToSchema();
    schemaUpdater.updateSchema(builder.toSchema());
    serverContext.getSchema().updateSchema(new SchemaUpdater()
    {
      @Override
      public Schema update(SchemaBuilder builder)
      {
        return addSubtreeSpecificationSyntax(builder).toSchema();
      }
    });
  }
  /** {@inheritDoc} */
  /**
   * Adds the subtree specification syntax to the provided schema builder.
   *
   * @param builder
   *          where to add the subtree specification syntax
   * @return the provided builder
   */
  public static SchemaBuilder addSubtreeSpecificationSyntax(SchemaBuilder builder)
  {
    return builder
        .buildSyntax(SYNTAX_SUBTREE_SPECIFICATION_OID)
        .description(SYNTAX_SUBTREE_SPECIFICATION_DESCRIPTION)
        .implementation(new SubtreeSpecificationSyntaxImpl())
        .addToSchema();
  }
  @Override
  public Syntax getSDKSyntax(Schema schema)
  {
    return schema.getSyntax(SchemaConstants.SYNTAX_SUBTREE_SPECIFICATION_OID);
  }
  /**
   * Retrieves the common name for this attribute syntax.
   *
   * @return The common name for this attribute syntax.
   */
  @Override
  public String getName() {
    return SYNTAX_SUBTREE_SPECIFICATION_NAME;
  }
  /**
   * Retrieves the OID for this attribute syntax.
   *
   * @return The OID for this attribute syntax.
   */
  @Override
  public String getOID() {
    return SYNTAX_SUBTREE_SPECIFICATION_OID;
  }
  /**
   * Retrieves a description for this attribute syntax.
   *
   * @return A description for this attribute syntax.
   */
  @Override
  public String getDescription() {
    return SYNTAX_SUBTREE_SPECIFICATION_DESCRIPTION;
  }
  /**
   * Indicates whether the provided value is acceptable for use in an
   * attribute with this syntax. If it is not, then the reason may be
   * appended to the provided buffer.
   *
   * @param value
   *          The value for which to make the determination.
   * @param invalidReason
   *          The buffer to which the invalid reason should be appended.
   * @return <CODE>true</CODE> if the provided value is acceptable for
   *         use with this syntax, or <CODE>false</CODE> if not.
   */
  @Override
  public boolean valueIsAcceptable(ByteSequence value,
                                   LocalizableMessageBuilder invalidReason) {
    // Use the subtree specification code to make this determination.
    try {
      SubtreeSpecification.valueOf(DN.rootDN(), value.toString());
@@ -146,14 +131,12 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  public boolean isBEREncodingRequired()
  {
    return false;
  }
  /** {@inheritDoc} */
  @Override
  public boolean isHumanReadable()
  {
opendj-server-legacy/src/main/java/org/opends/server/schema/TelephoneNumberSyntax.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2012-2015 ForgeRock AS
 *      Portions Copyright 2012-2016 ForgeRock AS
 */
package org.opends.server.schema;
@@ -36,11 +36,11 @@
import org.forgerock.opendj.ldap.schema.Schema;
import org.forgerock.opendj.ldap.schema.SchemaOptions;
import org.forgerock.opendj.ldap.schema.Syntax;
import org.forgerock.util.Option;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.server.TelephoneNumberAttributeSyntaxCfg;
import org.opends.server.api.AttributeSyntax;
import org.opends.server.core.ServerContext;
import org.opends.server.types.DirectoryException;
/**
 * This class implements the telephone number attribute syntax, which is defined
@@ -74,87 +74,54 @@
    super();
  }
  /** {@inheritDoc} */
  @Override
  public void initializeSyntax(TelephoneNumberAttributeSyntaxCfg configuration, ServerContext serverContext)
         throws ConfigException
      throws ConfigException, DirectoryException
  {
    this.serverContext = serverContext;
    // We may or may not have access to the config entry.  If we do, then see if
    // we should use the strict compliance mode.  If not, just assume that we
    // won't.
    // we should use the strict compliance mode. If not, just assume that we won't.
    strictMode = false;
    if (configuration != null)
    {
      currentConfig = configuration;
      currentConfig.addTelephoneNumberChangeListener(this);
      strictMode = currentConfig.isStrictFormat();
      updateNewSchema();
      serverContext.getSchema().updateSchemaOption(SchemaOptions.ALLOW_NON_STANDARD_TELEPHONE_NUMBERS, !strictMode);
    }
  }
  /** Update the option in new schema if it changes from current value. */
  private void updateNewSchema()
  {
    Option<Boolean> option = SchemaOptions.ALLOW_NON_STANDARD_TELEPHONE_NUMBERS;
    if (strictMode == serverContext.getSchemaNG().getOption(option))
    {
      SchemaUpdater schemaUpdater = serverContext.getSchemaUpdater();
      schemaUpdater.updateSchema(schemaUpdater.getSchemaBuilder().setOption(option, !strictMode).toSchema());
    }
  }
  /** {@inheritDoc} */
  @Override
  public Syntax getSDKSyntax(Schema schema)
  {
    return schema.getSyntax(SchemaConstants.SYNTAX_TELEPHONE_OID);
  }
  /**
   * Performs any finalization that may be necessary for this attribute syntax.
   */
  @Override
  public void finalizeSyntax()
  {
    currentConfig.removeTelephoneNumberChangeListener(this);
  }
  /**
   * Retrieves the common name for this attribute syntax.
   *
   * @return  The common name for this attribute syntax.
   */
  @Override
  public String getName()
  {
    return SYNTAX_TELEPHONE_NAME;
  }
  /**
   * Retrieves the OID for this attribute syntax.
   *
   * @return  The OID for this attribute syntax.
   */
  @Override
  public String getOID()
  {
    return SYNTAX_TELEPHONE_OID;
  }
  /**
   * Retrieves a description for this attribute syntax.
   *
   * @return  A description for this attribute syntax.
   */
  @Override
  public String getDescription()
  {
    return SYNTAX_TELEPHONE_DESCRIPTION;
  }
  /** {@inheritDoc} */
  @Override
  public boolean isConfigurationChangeAcceptable(
                      TelephoneNumberAttributeSyntaxCfg configuration,
@@ -164,16 +131,23 @@
    return true;
  }
  /** {@inheritDoc} */
  @Override
  public ConfigChangeResult applyConfigurationChange(
              TelephoneNumberAttributeSyntaxCfg configuration)
  {
    currentConfig = configuration;
    strictMode = configuration.isStrictFormat();
    updateNewSchema();
    return new ConfigChangeResult();
    final ConfigChangeResult ccr = new ConfigChangeResult();
    try
    {
      serverContext.getSchema().updateSchemaOption(SchemaOptions.ALLOW_NON_STANDARD_TELEPHONE_NUMBERS, !strictMode);
    }
    catch (DirectoryException e)
    {
      ccr.setResultCode(e.getResultCode());
      ccr.addMessage(e.getMessageObject());
    }
    return ccr;
  }
}
opendj-server-legacy/src/main/java/org/opends/server/tasks/AddSchemaFileTask.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2015 ForgeRock AS.
 *      Portions Copyright 2013-2016 ForgeRock AS.
 */
package org.opends.server.tasks;
@@ -36,6 +36,7 @@
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.admin.std.server.SynchronizationProviderCfg;
import org.opends.server.api.ClientConnection;
import org.opends.server.api.SynchronizationProvider;
@@ -149,7 +150,7 @@
    {
      try
      {
        SchemaConfigManager.loadSchemaFile(getServerContext(), schema, schemaFile);
        SchemaConfigManager.loadSchemaFile(schema, schemaFile);
      }
      catch (ConfigException | InitializationException e)
      {
@@ -184,8 +185,7 @@
      {
        try
        {
          List<Modification> modList =
               SchemaConfigManager.loadSchemaFile(getServerContext(), schema, schemaFile);
          List<Modification> modList = SchemaConfigManager.loadSchemaFile(schema, schemaFile);
          for (Modification m : modList)
          {
            Attribute a = m.getAttribute();
opendj-server-legacy/src/main/java/org/opends/server/tasks/BackupTask.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.tasks;
@@ -46,6 +46,7 @@
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.messages.Severity;
import org.opends.messages.TaskMessages;
import org.opends.server.admin.std.server.BackendCfg;
@@ -57,7 +58,6 @@
import org.opends.server.config.ConfigEntry;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.LockFileManager;
import org.opends.server.types.AttributeType;
import org.opends.server.types.BackupConfig;
import org.opends.server.types.BackupDirectory;
import org.opends.server.types.DirectoryException;
opendj-server-legacy/src/main/java/org/opends/server/tasks/DisconnectClientTask.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.tasks;
@@ -40,7 +40,7 @@
import org.opends.server.backends.task.TaskState;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.DisconnectReason;
import org.opends.server.types.Entry;
opendj-server-legacy/src/main/java/org/opends/server/tasks/ExportTask.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.tasks;
@@ -53,7 +53,7 @@
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.LockFileManager;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
opendj-server-legacy/src/main/java/org/opends/server/tasks/ImportTask.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2015 ForgeRock AS
 *      Portions Copyright 2013-2016 ForgeRock AS
 */
package org.opends.server.tasks;
@@ -55,7 +55,7 @@
import org.opends.server.core.LockFileManager;
import org.opends.server.tools.makeldif.TemplateFile;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
opendj-server-legacy/src/main/java/org/opends/server/tasks/InitializeTargetTask.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2015 ForgeRock AS
 *      Portions Copyright 2013-2016 ForgeRock AS
 */
package org.opends.server.tasks;
@@ -42,7 +42,7 @@
import org.opends.server.backends.task.TaskState;
import org.opends.server.replication.plugin.LDAPReplicationDomain;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
opendj-server-legacy/src/main/java/org/opends/server/tasks/InitializeTask.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2015 ForgeRock AS
 *      Portions Copyright 2013-2016 ForgeRock AS
 */
package org.opends.server.tasks;
@@ -40,7 +40,7 @@
import org.opends.server.backends.task.TaskState;
import org.opends.server.replication.plugin.LDAPReplicationDomain;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
opendj-server-legacy/src/main/java/org/opends/server/tasks/PurgeConflictsHistoricalTask.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2015 ForgeRock AS
 *      Portions Copyright 2013-2016 ForgeRock AS
 */
package org.opends.server.tasks;
@@ -36,6 +36,7 @@
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.replication.common.CSN;
import org.opends.server.replication.plugin.LDAPReplicationDomain;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.util.TimeThread;
opendj-server-legacy/src/main/java/org/opends/server/tasks/RebuildTask.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2012-2015 ForgeRock AS.
 *      Portions Copyright 2012-2016 ForgeRock AS.
 */
package org.opends.server.tasks;
@@ -49,7 +49,7 @@
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.LockFileManager;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
opendj-server-legacy/src/main/java/org/opends/server/tasks/ResetChangeNumberTask.java
@@ -21,19 +21,19 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2015 ForgeRock AS
 *      Copyright 2015-2016 ForgeRock AS
 */
package org.opends.server.tasks;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.backends.task.Task;
import org.opends.server.backends.task.TaskState;
import org.opends.server.replication.common.CSN;
import org.opends.server.replication.server.ReplicationServer;
import org.opends.server.replication.server.changelog.api.ChangelogException;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
opendj-server-legacy/src/main/java/org/opends/server/tasks/RestoreTask.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.tasks;
@@ -52,7 +52,7 @@
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.LockFileManager;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.BackupDirectory;
import org.opends.server.types.BackupInfo;
import org.opends.server.types.DN;
opendj-server-legacy/src/main/java/org/opends/server/tasks/SetGenerationIdTask.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2015 ForgeRock AS
 *      Portions Copyright 2013-2016 ForgeRock AS
 */
package org.opends.server.tasks;
@@ -41,7 +41,7 @@
import org.opends.server.replication.plugin.LDAPReplicationDomain;
import org.opends.server.replication.service.ReplicationDomain;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
opendj-server-legacy/src/main/java/org/opends/server/tasks/ShutdownTask.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.tasks;
@@ -40,7 +40,7 @@
import org.opends.server.backends.task.TaskState;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
import org.opends.server.types.Operation;
opendj-server-legacy/src/main/java/org/opends/server/tools/ExportLDIF.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2012-2015 ForgeRock AS.
 *      Portions Copyright 2012-2016 ForgeRock AS.
 */
package org.opends.server.tools;
@@ -59,7 +59,7 @@
import org.opends.server.protocols.ldap.LDAPAttribute;
import org.opends.server.tasks.ExportTask;
import org.opends.server.tools.tasks.TaskTool;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.ExistingFileBehavior;
opendj-server-legacy/src/main/java/org/opends/server/tools/ImportLDIF.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS.
 *      Portions Copyright 2011-2016 ForgeRock AS.
 */
package org.opends.server.tools;
@@ -64,7 +64,7 @@
import org.opends.server.tasks.ImportTask;
import org.opends.server.tools.makeldif.TemplateFile;
import org.opends.server.tools.tasks.TaskTool;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.ExistingFileBehavior;
opendj-server-legacy/src/main/java/org/opends/server/tools/LDIFDiff.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2015 ForgeRock AS.
 *      Portions Copyright 2013-2016 ForgeRock AS.
 */
package org.opends.server.tools;
@@ -47,7 +47,7 @@
import org.opends.server.loggers.JDKLogging;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeBuilder;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
opendj-server-legacy/src/main/java/org/opends/server/tools/LDIFModify.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2012-2015 ForgeRock AS.
 *      Portions Copyright 2012-2016 ForgeRock AS.
 */
package org.opends.server.tools;
@@ -51,7 +51,7 @@
import org.opends.server.extensions.ConfigFileHandler;
import org.opends.server.loggers.JDKLogging;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
opendj-server-legacy/src/main/java/org/opends/server/tools/LDIFSearch.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2015 ForgeRock AS.
 *      Portions Copyright 2013-2016 ForgeRock AS.
 */
package org.opends.server.tools;
@@ -50,6 +50,7 @@
import org.opends.server.extensions.ConfigFileHandler;
import org.opends.server.loggers.JDKLogging;
import org.opends.server.protocols.ldap.LDAPResultCode;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import org.opends.server.util.BuildVersion;
import org.opends.server.util.LDIFException;
opendj-server-legacy/src/main/java/org/opends/server/tools/makeldif/AttributeValueTag.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.tools.makeldif;
import org.forgerock.i18n.LocalizableMessage;
@@ -32,7 +32,7 @@
import java.util.List;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.InitializationException;
import static org.opends.messages.ToolMessages.*;
opendj-server-legacy/src/main/java/org/opends/server/tools/makeldif/Branch.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.tools.makeldif;
@@ -38,7 +38,7 @@
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
opendj-server-legacy/src/main/java/org/opends/server/tools/makeldif/IfAbsentTag.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.tools.makeldif;
import org.forgerock.i18n.LocalizableMessage;
@@ -32,7 +32,7 @@
import java.util.List;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.InitializationException;
import static org.opends.messages.ToolMessages.*;
opendj-server-legacy/src/main/java/org/opends/server/tools/makeldif/IfPresentTag.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.tools.makeldif;
import org.forgerock.i18n.LocalizableMessage;
@@ -32,7 +32,7 @@
import java.util.List;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.InitializationException;
import static org.opends.messages.ToolMessages.*;
opendj-server-legacy/src/main/java/org/opends/server/tools/makeldif/MakeLDIF.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2015 ForgeRock AS.
 *      Portions Copyright 2013-2016 ForgeRock AS.
 */
package org.opends.server.tools.makeldif;
@@ -43,7 +43,7 @@
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.DirectoryServer.DirectoryServerVersionHandler;
import org.opends.server.loggers.JDKLogging;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.ExistingFileBehavior;
import org.opends.server.types.InitializationException;
import org.opends.server.types.LDIFExportConfig;
opendj-server-legacy/src/main/java/org/opends/server/tools/makeldif/Template.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.tools.makeldif;
@@ -33,7 +33,7 @@
import java.util.HashSet;
import java.util.Map;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DN;
import static org.opends.messages.ToolMessages.*;
opendj-server-legacy/src/main/java/org/opends/server/tools/makeldif/TemplateEntry.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.tools.makeldif;
@@ -37,6 +37,7 @@
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.core.DirectoryServer;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import org.opends.server.util.LDIFException;
@@ -168,7 +169,7 @@
            return null;
          }
          names[i]  = t.getPrimaryName();
          names[i]  = t.getNameOrOID();
          values[i] = ByteString.valueOfUtf8(v.getValue().toString());
        }
opendj-server-legacy/src/main/java/org/opends/server/tools/makeldif/TemplateFile.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2015 ForgeRock AS.
 *      Portions Copyright 2013-2016 ForgeRock AS.
 */
package org.opends.server.tools.makeldif;
@@ -43,7 +43,7 @@
import java.util.StringTokenizer;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.InitializationException;
opendj-server-legacy/src/main/java/org/opends/server/tools/makeldif/TemplateLine.java
@@ -22,11 +22,11 @@
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2015 ForgeRock AS
 *      Portions Copyright 2015-2016 ForgeRock AS
 */
package org.opends.server.tools.makeldif;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
/**
 * This class defines a line that may appear in a template or branch.  It may
opendj-server-legacy/src/main/java/org/opends/server/tools/makeldif/TemplateValue.java
@@ -22,13 +22,13 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2015 ForgeRock AS.
 *      Portions Copyright 2015-2016 ForgeRock AS.
 */
package org.opends.server.tools.makeldif;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
opendj-server-legacy/src/main/java/org/opends/server/tools/tasks/TaskEntry.java
@@ -22,17 +22,17 @@
 *
 *
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.tools.tasks;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.backends.task.FailedDependencyAction;
import org.opends.server.backends.task.Task;
import org.opends.server.backends.task.TaskState;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
@@ -133,7 +133,7 @@
    // Build a map of non-superior attribute value pairs for display
    Map<AttributeType, List<Attribute>> attrMap = entry.getUserAttributes();
    for (AttributeType type : attrMap.keySet()) {
      String typeName = type.getNameOrOID();
      String typeName = type.getNormalizedNameOrOID();
      // See if we've handled it already above
      if (!supAttrNames.contains(typeName)) {
opendj-server-legacy/src/main/java/org/opends/server/types/Attribute.java
@@ -22,10 +22,12 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.types;
import org.forgerock.opendj.ldap.schema.AttributeType;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
opendj-server-legacy/src/main/java/org/opends/server/types/AttributeBuilder.java
@@ -22,10 +22,12 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2012-2015 ForgeRock AS
 *      Portions Copyright 2012-2016 ForgeRock AS
 */
package org.opends.server.types;
import org.forgerock.opendj.ldap.schema.AttributeType;
import java.util.AbstractSet;
import java.util.Collection;
import java.util.Collections;
opendj-server-legacy/src/main/java/org/opends/server/types/AttributeDescription.java
@@ -20,7 +20,7 @@
 *
 * CDDL HEADER END
 *
 *      Copyright 2015 ForgeRock AS
 *      Copyright 2015-2016 ForgeRock AS
 */
package org.opends.server.types;
@@ -32,6 +32,7 @@
import java.util.SortedSet;
import java.util.TreeSet;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.util.Reject;
/** Temporary class until we move to {@link org.forgerock.opendj.ldap.AttributeDescription}. */
opendj-server-legacy/src/main/java/org/opends/server/types/AttributeType.java
File was deleted
opendj-server-legacy/src/main/java/org/opends/server/types/Attributes.java
@@ -22,21 +22,22 @@
 *
 *
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.types;
import static org.opends.server.util.CollectionUtils.*;
import static org.opends.server.util.StaticUtils.*;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.core.DirectoryServer;
import static org.opends.server.util.CollectionUtils.*;
import static org.opends.server.util.StaticUtils.*;
/**
 * This class contains various methods for manipulating
 * {@link Attribute}s as well as static factory methods for
opendj-server-legacy/src/main/java/org/opends/server/types/CollectiveVirtualAttribute.java
@@ -22,11 +22,13 @@
 *
 *
 *      Copyright 2009 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.types;
import org.forgerock.opendj.ldap.schema.AttributeType;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
opendj-server-legacy/src/main/java/org/opends/server/types/DITContentRule.java
@@ -22,10 +22,12 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2015 ForgeRock AS.
 *      Portions Copyright 2013-2016 ForgeRock AS.
 */
package org.opends.server.types;
import org.forgerock.opendj.ldap.schema.AttributeType;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
opendj-server-legacy/src/main/java/org/opends/server/types/DN.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2012-2015 ForgeRock AS
 *      Portions Copyright 2012-2016 ForgeRock AS
 */
package org.opends.server.types;
@@ -44,6 +44,7 @@
import org.forgerock.opendj.ldap.ByteStringBuilder;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.util.Reject;
import org.opends.server.core.DirectoryServer;
@@ -659,7 +660,6 @@
      // Create the new RDN with the provided information.
      RDN rdn = newRDN(attributeName, parsedValue);
      // Skip over any spaces that might be after the attribute value.
      b = ' ';
      while (dnReader.remaining() > 0 && (b = dnReader.readByte()) == ' ')
@@ -768,11 +768,8 @@
        // Parse the value for this RDN component.
        parsedValue = parseAttributeValue(dnReader);
        addValue(attributeName, rdn, parsedValue);
        // Skip over any spaces that might be after the attribute value.
        // Skip over any spaces that might be after the attribute value.
        b = ' ';
@@ -1082,9 +1079,6 @@
        // Parse the value for this RDN component.
        parsedValue.clear();
        pos = parseAttributeValue(dnString, pos, parsedValue);
        // Create the new RDN with the provided information.
        addValue(attributeName, rdn, parsedValue.toByteString());
@@ -2613,5 +2607,6 @@
  {
    return toNormalizedByteString().compareTo(other.toNormalizedByteString());
  }
}
opendj-server-legacy/src/main/java/org/opends/server/types/DirectoryConfig.java
@@ -22,10 +22,13 @@
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2015 ForgeRock AS.
 *      Portions Copyright 2013-2016 ForgeRock AS.
 */
package org.opends.server.types;
import org.forgerock.opendj.ldap.schema.AttributeType;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -179,16 +182,12 @@
  /**
   * Retrieves the set of matching rules registered with the Directory
   * Server.  The mapping will be between the lowercase name or OID
   * for each matching rule and the matching rule implementation.  The
   * same matching rule instance may be included multiple times with
   * different keys.  The returned map must not be altered by the
   * caller.
   * Server.
   *
   * @return  The set of matching rules registered with the Directory
   *          Server.
   */
  public static Map<String,MatchingRule> getMatchingRules()
  public static Collection<MatchingRule> getMatchingRules()
  {
    return DirectoryServer.getMatchingRules();
  }
@@ -354,7 +353,7 @@
   * @return The set of attribute type definitions that have been
   *         defined in the Directory Server.
   */
  public static Map<String,AttributeType> getAttributeTypes()
  public static Collection<AttributeType> getAttributeTypes()
  {
    return DirectoryServer.getAttributeTypes();
  }
@@ -373,35 +372,18 @@
  /**
   * Retrieves the set of attribute syntaxes defined in the Directory
   * Server.  The mapping will be between the OID and the
   * corresponding syntax implementation.  The returned map must not
   * be altered by the caller.
   * Server.
   *
   * @return  The set of attribute syntaxes defined in the Directory
   *          Server.
   */
  public static Map<String,Syntax>
       getAttributeSyntaxes()
  public static Collection<Syntax> getAttributeSyntaxes()
  {
    return DirectoryServer.getAttributeSyntaxes();
  }
  /**
   * Retrieves the default attribute syntax that should be used for
   * attributes that are not defined in the server schema.
   *
   * @return  The default attribute syntax that should be used for
   *          attributes that are not defined in the server schema.
   */
  public static Syntax getDefaultAttributeSyntax()
  {
    return DirectoryServer.getDefaultAttributeSyntax();
  }
  /**
   * Retrieves the default attribute syntax that should be used for
   * attributes that are not defined in the server schema and are
   * meant to store binary values.
   *
opendj-server-legacy/src/main/java/org/opends/server/types/Entry.java
@@ -22,10 +22,12 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.types;
import org.forgerock.opendj.ldap.schema.AttributeType;
import java.io.BufferedWriter;
import java.io.IOException;
import java.util.*;
@@ -485,21 +487,18 @@
    }
    // Check sub-types.
    if (attributeType.mayHaveSubordinateTypes())
    for (AttributeType subType : schema.getSubTypes(attributeType))
    {
      for (AttributeType subType : schema.getSubTypes(attributeType))
      attributes = getAttributes(subType);
      if (attributes != null)
      {
        attributes = getAttributes(subType);
        if (attributes != null)
        for (Attribute attribute : attributes)
        {
          for (Attribute attribute : attributes)
          // It's possible that there could be an attribute without any values,
          // which we should treat as not having the requested attribute.
          if (!attribute.isEmpty() && attribute.hasAllOptions(options))
          {
            // It's possible that there could be an attribute without any values,
            // which we should treat as not having the requested attribute.
            if (!attribute.isEmpty() && attribute.hasAllOptions(options))
            {
              return true;
            }
            return true;
          }
        }
      }
@@ -601,7 +600,7 @@
  public List<Attribute> getAttribute(AttributeType attributeType,
                                      boolean includeSubordinates)
  {
    if (includeSubordinates && attributeType.mayHaveSubordinateTypes())
    if (includeSubordinates && !attributeType.isObjectClass())
    {
      List<Attribute> attributes = new LinkedList<>();
      addAllIfNotNull(attributes, userAttributes.get(attributeType));
@@ -718,7 +717,7 @@
                                      Set<String> options)
  {
    List<Attribute> attributes = new LinkedList<>();
    if (attributeType.mayHaveSubordinateTypes())
    if (!attributeType.isObjectClass())
    {
      addAllIfNotNull(attributes, userAttributes.get(attributeType));
      addAllIfNotNull(attributes, operationalAttributes.get(attributeType));
@@ -824,18 +823,13 @@
  private List<Attribute> getAttribute(AttributeType attributeType,
      Map<AttributeType, List<Attribute>> attrs)
  {
    if (attributeType.mayHaveSubordinateTypes())
    List<Attribute> attributes = new LinkedList<>();
    addAllIfNotNull(attributes, attrs.get(attributeType));
    for (AttributeType at : schema.getSubTypes(attributeType))
    {
      List<Attribute> attributes = new LinkedList<>();
      addAllIfNotNull(attributes, attrs.get(attributeType));
      for (AttributeType at : schema.getSubTypes(attributeType))
      {
        addAllIfNotNull(attributes, attrs.get(at));
      }
      return attributes;
      addAllIfNotNull(attributes, attrs.get(at));
    }
    List<Attribute> results = attrs.get(attributeType);
    return results != null ? results : Collections.<Attribute> emptyList();
    return attributes;
  }
@@ -858,12 +852,9 @@
    List<Attribute> attributes = new LinkedList<>();
    addAllIfNotNull(attributes, attrs.get(attributeType));
    if (attributeType.mayHaveSubordinateTypes())
    for (AttributeType at : schema.getSubTypes(attributeType))
    {
      for (AttributeType at : schema.getSubTypes(attributeType))
      {
        addAllIfNotNull(attributes, attrs.get(at));
      }
      addAllIfNotNull(attributes, attrs.get(at));
    }
    onlyKeepAttributesWithAllOptions(attributes, options);
@@ -914,22 +905,17 @@
      return true;
    }
    if (attributeType.mayHaveSubordinateTypes())
    for (AttributeType at : schema.getSubTypes(attributeType))
    {
      for (AttributeType at : schema.getSubTypes(attributeType))
      if (attributes.containsKey(at))
      {
        if (attributes.containsKey(at))
        {
          return true;
        }
        return true;
      }
    }
    return false;
  }
  /**
   * Retrieves the requested operational attribute element(s) for the
   * specified attribute type.  The list returned may include multiple
@@ -2946,8 +2932,7 @@
        for (Attribute collectiveAttr : collectiveAttrList)
        {
          AttributeType attributeType = collectiveAttr.getAttributeType();
          if (exclusionsNameSet.contains(
                  attributeType.getNormalizedPrimaryNameOrOID()))
          if (exclusionsNameSet.contains(attributeType.getNormalizedNameOrOID()))
          {
            continue;
          }
opendj-server-legacy/src/main/java/org/opends/server/types/LDAPSyntaxDescription.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2009 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2015 ForgeRock AS.
 *      Portions Copyright 2013-2016 ForgeRock AS.
 */
package org.opends.server.types;
@@ -34,8 +34,6 @@
import java.util.List;
import java.util.Map;
import org.forgerock.opendj.ldap.schema.Syntax;
/**
 * This class defines a data structure for storing and interacting
 * with an ldap syntax, which defines the custom ldap syntaxes.
@@ -58,36 +56,24 @@
  /** The definition string used to create this ldap syntax description. */
  private final String definition;
  /** The description for this ldap syntax description. */
  private final String description;
  /** The OID of the enclosed ldap syntax description. */
  private final String oid;
  /** The LDAPSyntaxDescritpionSyntax associated with this ldap syntax. */
  private Syntax syntax;
  /**
   * Creates a new ldap syntax definition with the provided
   * information.
   * Creates a new ldap syntax definition with the provided information.
   *
   * @param  definition          The definition string used to create
   *                             this ldap syntax.  It must not be
   *                             {@code null}.
   * @param syntax    The ldap syntax description syntax
   *                            associated with this ldap syntax.
   * @param  extraProperties     A set of extra properties for this
   *                             ldap syntax description.
   * @param definition
   *          The definition string used to create this ldap syntax. It must not be {@code null}.
   * @param oid
   *          oid of the syntax
   * @param extraProperties
   *          A set of extra properties for this ldap syntax description.
   */
  public LDAPSyntaxDescription(String definition, Syntax syntax, Map<String,List<String>> extraProperties)
  public LDAPSyntaxDescription(String definition, String oid, Map<String,List<String>> extraProperties)
  {
    ifNull(definition, syntax);
    ifNull(definition, oid);
    this.syntax = syntax;
    this.oid = syntax.getOID();
    this.description = syntax.getDescription();
    this.oid = oid;
    int schemaFilePos = definition.indexOf(SCHEMA_PROPERTY_FILENAME);
    if (schemaFilePos > 0)
@@ -123,32 +109,6 @@
    }
  }
   /**
   * Retrieves the ldap syntax description syntax associated with
    * this ldap syntax.
   *
   * @return  The description syntax for this definition.
   */
  public Syntax getSyntax()
  {
    return syntax;
  }
  /**
   * Retrieves the description for this ldap syntax description.
   *
   * @return  The description for this ldap syntax description, or
   *                {@code true} if there is none.
   */
  public String getDescription()
  {
    return description;
  }
  /**
   * Returns the oid.
   *
opendj-server-legacy/src/main/java/org/opends/server/types/LDIFExportConfig.java
@@ -22,10 +22,12 @@
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2015 ForgeRock AS.
 *      Portions Copyright 2013-2016 ForgeRock AS.
 */
package org.opends.server.types;
import org.forgerock.opendj.ldap.schema.AttributeType;
import java.io.*;
import java.util.ArrayList;
import java.util.HashSet;
opendj-server-legacy/src/main/java/org/opends/server/types/LDIFImportConfig.java
@@ -22,10 +22,12 @@
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2012-2015 ForgeRock AS
 *      Portions Copyright 2012-2016 ForgeRock AS
 */
package org.opends.server.types;
import org.forgerock.opendj.ldap.schema.AttributeType;
import static org.opends.messages.UtilityMessages.*;
import java.io.*;
opendj-server-legacy/src/main/java/org/opends/server/types/MatchingRuleUse.java
@@ -22,10 +22,12 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2015 ForgeRock AS.
 *      Portions Copyright 2013-2016 ForgeRock AS.
 */
package org.opends.server.types;
import org.forgerock.opendj.ldap.schema.AttributeType;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
opendj-server-legacy/src/main/java/org/opends/server/types/NameForm.java
@@ -22,10 +22,12 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2015 ForgeRock AS.
 *      Portions Copyright 2013-2016 ForgeRock AS.
 */
package org.opends.server.types;
import org.forgerock.opendj.ldap.schema.AttributeType;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
opendj-server-legacy/src/main/java/org/opends/server/types/ObjectClass.java
@@ -22,10 +22,12 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2015 ForgeRock AS.
 *      Portions Copyright 2013-2016 ForgeRock AS.
 */
package org.opends.server.types;
import org.forgerock.opendj.ldap.schema.AttributeType;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
opendj-server-legacy/src/main/java/org/opends/server/types/RDN.java
@@ -22,10 +22,12 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2015 ForgeRock AS
 *      Portions Copyright 2013-2016 ForgeRock AS
 */
package org.opends.server.types;
import org.forgerock.opendj.ldap.schema.AttributeType;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.CharBuffer;
@@ -88,7 +90,7 @@
  {
    Reject.ifNull(attributeType, attributeValue);
    attributeTypes  = new AttributeType[] { attributeType };
    attributeNames  = new String[] { attributeType.getPrimaryName() };
    attributeNames  = new String[] { attributeType.getNameOrOID() };
    attributeValues = new ByteString[] { attributeValue };
  }
@@ -666,16 +668,11 @@
    // don't return it yet because this could be a multi-valued RDN.
    String name            = attributeName.toString();
    String lowerName       = toLowerCase(name);
    AttributeType attrType = DirectoryServer.getAttributeTypeOrNull(lowerName);
    if (attrType == null)
    {
      // This must be an attribute type that we don't know about.
      // In that case, we'll create a new attribute using the default
      // syntax.  If this is a problem, it will be caught later either
      // by not finding the target entry or by not allowing the entry
      // to be added.
      attrType = DirectoryServer.getAttributeTypeOrDefault(name);
    }
    // If using default is a problem, it will be caught later either
    // by not finding the target entry or by not allowing the entry
    // to be added.
    AttributeType attrType = DirectoryServer.getAttributeTypeOrDefault(lowerName, name);
    RDN rdn = new RDN(attrType, name, parsedValue.toByteString());
@@ -785,17 +782,7 @@
      {
        name      = attributeName.toString();
        lowerName = toLowerCase(name);
        attrType  = DirectoryServer.getAttributeTypeOrNull(lowerName);
        if (attrType == null)
        {
          // This must be an attribute type that we don't know about.
          // In that case, we'll create a new attribute using the
          // default syntax.  If this is a problem, it will be caught
          // later either by not finding the target entry or by not
          // allowing the entry to be added.
          attrType = DirectoryServer.getAttributeTypeOrDefault(name);
        }
        attrType = DirectoryServer.getAttributeTypeOrDefault(lowerName.toString(), name);
        rdn.addValue(attrType, name, ByteString.empty());
        return rdn;
@@ -810,16 +797,10 @@
      // Update the RDN to include the new attribute/value.
      name            = attributeName.toString();
      lowerName       = toLowerCase(name);
      attrType = DirectoryServer.getAttributeTypeOrNull(lowerName);
      if (attrType == null)
      {
        // This must be an attribute type that we don't know about.
        // In that case, we'll create a new attribute using the
        // default syntax.  If this is a problem, it will be caught
        // later either by not finding the target entry or by not
        // allowing the entry to be added.
        attrType = DirectoryServer.getAttributeTypeOrDefault(name);
      }
      // If using default is a problem, it will be caught later either
      // by not finding the target entry or by not allowing the entry
      // to be added.
      attrType = DirectoryServer.getAttributeTypeOrDefault(lowerName, name);
      rdn.addValue(attrType, name, parsedValue.toByteString());
@@ -1091,7 +1072,7 @@
   */
  private ByteStringBuilder normalizeAVAToByteString(int position, final ByteStringBuilder builder)
  {
    builder.appendUtf8(attributeTypes[position].getNormalizedPrimaryNameOrOID());
    builder.appendUtf8(attributeTypes[position].getNormalizedNameOrOID());
    builder.appendUtf8("=");
    final ByteString value = getEqualityNormalizedValue(position);
    if (value.length() > 0)
@@ -1156,7 +1137,7 @@
   */
  private StringBuilder normalizeAVAToUrlSafeString(int position, StringBuilder builder)
  {
      builder.append(attributeTypes[position].getNormalizedPrimaryNameOrOID());
      builder.append(attributeTypes[position].getNormalizedNameOrOID());
      builder.append('=');
      ByteString value = getEqualityNormalizedValue(position);
@@ -1164,7 +1145,7 @@
      {
        return builder;
      }
      final boolean hasAttributeName = attributeTypes[position].getPrimaryName() != null;
      final boolean hasAttributeName = !attributeTypes[position].getNames().isEmpty();
      final boolean isHumanReadable = attributeTypes[position].getSyntax().isHumanReadable();
      if (!hasAttributeName || !isHumanReadable)
      {
opendj-server-legacy/src/main/java/org/opends/server/types/Schema.java
@@ -22,12 +22,20 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.types;
import java.io.*;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.FilenameFilter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashSet;
@@ -37,26 +45,38 @@
import java.util.Set;
import java.util.TreeSet;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.LocalizableMessageDescriptor.Arg0;
import org.forgerock.i18n.LocalizedIllegalArgumentException;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.ldap.schema.ConflictingSchemaElementException;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.forgerock.opendj.ldap.schema.SchemaBuilder;
import org.forgerock.opendj.ldap.schema.Syntax;
import org.forgerock.opendj.ldap.schema.UnknownSchemaElementException;
import org.forgerock.util.Option;
import org.forgerock.util.Utils;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.SchemaConfigManager;
import org.opends.server.schema.AttributeTypeSyntax;
import org.opends.server.schema.DITContentRuleSyntax;
import org.opends.server.schema.DITStructureRuleSyntax;
import org.opends.server.schema.MatchingRuleUseSyntax;
import org.opends.server.schema.NameFormSyntax;
import org.opends.server.schema.ObjectClassSyntax;
import org.opends.server.schema.SomeSchemaElement;
import org.opends.server.util.ServerConstants;
import org.opends.server.util.StaticUtils;
import static org.opends.messages.BackendMessages.*;
import static org.opends.messages.CoreMessages.*;
import static org.opends.messages.SchemaMessages.*;
import static org.opends.server.config.ConfigConstants.*;
import static org.opends.server.types.CommonSchemaElements.*;
import static org.opends.server.util.CollectionUtils.*;
@@ -78,6 +98,7 @@
 *   <LI>DIT structure rule definitions</LI>
 *   <LI>Name form definitions</LI>
 * </UL>
 * It always uses non-strict {@link org.forgerock.opendj.ldap.schema.Schema} under the hood.
 */
@org.opends.server.types.PublicAPI(
     stability=org.opends.server.types.StabilityLevel.UNCOMMITTED,
@@ -89,16 +110,10 @@
  private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
  /**
   * The set of subordinate attribute types registered within the server schema.
   * Provides for each attribute type having at least one subordinate type the complete list of
   * its descendants.
   */
  private ConcurrentHashMap<AttributeType,List<AttributeType>>
               subordinateTypes;
  /**
   * The set of attribute type definitions for this schema, mapped between the
   * lowercase names and OID for the definition and the attribute type itself.
   */
  private ConcurrentHashMap<String,AttributeType> attributeTypes;
  private Map<AttributeType, List<AttributeType>> subordinateTypes;
  /**
   * The set of objectclass definitions for this schema, mapped between the
@@ -107,23 +122,9 @@
  private ConcurrentHashMap<String,ObjectClass> objectClasses;
  /**
   * The set of attribute syntaxes for this schema, mapped between the OID for
   * the syntax and the syntax itself.
   */
  private ConcurrentHashMap<String,Syntax> syntaxes;
  /**
   * The default attribute syntax to use for attributes with no defined syntax.
   */
  private Syntax defaultSyntax;
  /**
   * The entire set of matching rules for this schema, mapped between the
   * lowercase names and OID for the definition and the matching rule itself.
   */
  private ConcurrentHashMap<String,MatchingRule> matchingRules;
  private String defaultSyntaxOID;
  /**
   * The set of matching rule uses for this schema, mapped between the matching
@@ -187,186 +188,378 @@
   */
  private Map<String, Attribute> extraAttributes = new HashMap<>();
  /**
   * The SDK schema.
   * <p>
   * It will progressively take over server implementation of the schema.
   * <p>
   * @GuardedBy("exclusiveLock")
   */
  private volatile org.forgerock.opendj.ldap.schema.Schema schemaNG;
  /** Creates a new schema structure with all elements initialized but empty. */
  public Schema()
  /** Guards updates to the schema. */
  private final Lock exclusiveLock = new ReentrantLock();
  /**
   * Creates a new schema structure with all elements initialized but empty.
   *
   * @param schemaNG
   *          The SDK schema
   */
  public Schema(org.forgerock.opendj.ldap.schema.Schema schemaNG)
  {
    attributeTypes = new ConcurrentHashMap<>();
    objectClasses = new ConcurrentHashMap<>();
    syntaxes = new ConcurrentHashMap<>();
    matchingRules = new ConcurrentHashMap<>();
    matchingRuleUses = new ConcurrentHashMap<>();
    ditContentRules = new ConcurrentHashMap<>();
    ditStructureRulesByID = new ConcurrentHashMap<>();
    ditStructureRulesByNameForm = new ConcurrentHashMap<>();
    nameFormsByOC = new ConcurrentHashMap<>();
    nameFormsByName = new ConcurrentHashMap<>();
    ldapSyntaxDescriptions = new ConcurrentHashMap<>();
    subordinateTypes = new ConcurrentHashMap<>();
    setSchemaNG(schemaNG);
    objectClasses = new ConcurrentHashMap<String,ObjectClass>();
    matchingRuleUses = new ConcurrentHashMap<MatchingRule,MatchingRuleUse>();
    ditContentRules = new ConcurrentHashMap<ObjectClass,DITContentRule>();
    ditStructureRulesByID = new ConcurrentHashMap<Integer,DITStructureRule>();
    ditStructureRulesByNameForm = new ConcurrentHashMap<NameForm,DITStructureRule>();
    nameFormsByOC = new ConcurrentHashMap<ObjectClass,List<NameForm>>();
    nameFormsByName = new ConcurrentHashMap<String,NameForm>();
    ldapSyntaxDescriptions = new ConcurrentHashMap<String,LDAPSyntaxDescription>();
    subordinateTypes = new ConcurrentHashMap<AttributeType,List<AttributeType>>();
    oldestModificationTime    = System.currentTimeMillis();
    youngestModificationTime  = oldestModificationTime;
  }
  /**
   * Returns the SDK schema.
   *
   * @return the SDK schema
   */
  public org.forgerock.opendj.ldap.schema.Schema getSchemaNG()
  {
    return schemaNG;
  }
  /**
   * Retrieves the attribute type definitions for this schema, as a
   * mapping between the lowercase names and OIDs for the attribute
   * type and the attribute type itself.  Each attribute type may be
   * associated with multiple keys (once for the OID and again for
   * each name).  The contents of the returned mapping must not be
   * altered.
   * Retrieves the attribute type definitions for this schema.
   *
   * @return  The attribute type definitions for this schema.
   */
  public ConcurrentHashMap<String,AttributeType> getAttributeTypes()
  public Collection<AttributeType> getAttributeTypes()
  {
    return attributeTypes;
    return schemaNG.getAttributeTypes();
  }
  /**
   * Indicates whether this schema definition includes an attribute
   * type with the provided name or OID.
   *
   * @param  lowerName  The name or OID for which to make the
   *                    determination, formatted in all lowercase
   *                    characters.
   *
   * @param  nameOrOid  The name or OID for which to make the determination, ignoring case considerations
   * @return  {@code true} if this schema contains an attribute type
   *          with the provided name or OID, or {@code false} if not.
   */
  public boolean hasAttributeType(String lowerName)
  public boolean hasAttributeType(String nameOrOid)
  {
    return attributeTypes.containsKey(lowerName);
    return schemaNG.hasAttributeType(nameOrOid);
  }
  /**
   * Retrieves the attribute type definition with the specified name
   * or OID.
   * Retrieves the attribute type definition with the specified name or OID.
   *
   * @param  lowerName  The name or OID of the attribute type to
   *                    retrieve, formatted in all lowercase
   *                    characters.
   *
   * @return  The requested attribute type, or <CODE>null</CODE> if no
   *          type is registered with the provided name or OID.
   * @param nameOrOid
   *          The name or OID of the attribute type to retrieve, ignoring case considerations
   * @return The requested attribute type
   */
  public AttributeType getAttributeType(String lowerName)
  public AttributeType getAttributeType(String nameOrOid)
  {
    return attributeTypes.get(lowerName);
  }
  /**
   * Registers the provided attribute type definition with this
   * schema.
   *
   * @param  attributeType      The attribute type to register with
   *                            this schema.
   * @param  overwriteExisting  Indicates whether to overwrite an
   *                            existing mapping if there are any
   *                            conflicts (i.e., another attribute
   *                            type with the same OID or name).
   *
   * @throws  DirectoryException  If a conflict is encountered and the
   *                              <CODE>overwriteExisting</CODE> flag
   *                              is set to <CODE>false</CODE>
   */
  public void registerAttributeType(AttributeType attributeType,
                                    boolean overwriteExisting)
         throws DirectoryException
  {
    synchronized (attributeTypes)
    try
    {
      if (! overwriteExisting)
      {
        String oid = toLowerCase(attributeType.getOID());
        if (attributeTypes.containsKey(oid))
        {
          AttributeType conflictingType = attributeTypes.get(oid);
          LocalizableMessage message = ERR_SCHEMA_CONFLICTING_ATTRIBUTE_OID.
              get(attributeType.getNameOrOID(), oid,
                  conflictingType.getNameOrOID());
          throw new DirectoryException(
                         ResultCode.CONSTRAINT_VIOLATION, message);
        }
        for (String name : attributeType.getNormalizedNames())
        {
          if (attributeTypes.containsKey(name))
          {
            AttributeType conflictingType = attributeTypes.get(name);
            LocalizableMessage message = ERR_SCHEMA_CONFLICTING_ATTRIBUTE_NAME.
                get(attributeType.getNameOrOID(), name,
                    conflictingType.getNameOrOID());
            throw new DirectoryException(
                           ResultCode.CONSTRAINT_VIOLATION, message);
          }
        }
      }
      AttributeType old = attributeTypes.put(
          toLowerCase(attributeType.getOID()), attributeType);
      if (old != null && old != attributeType)
      {
        // Mark the old attribute type as stale so that caches (such as
        // compressed schema) can detect changes.
        old.setDirty();
      }
      for (String name : attributeType.getNormalizedNames())
      {
        attributeTypes.put(name, attributeType);
      }
      AttributeType superiorType = attributeType.getSuperiorType();
      if (superiorType != null)
      {
        registerSubordinateType(attributeType, superiorType);
      }
      return schemaNG.getAttributeType(nameOrOid);
    }
    catch (UnknownSchemaElementException e)
    {
      // It should never happen because we only use non-strict schemas
      throw new RuntimeException(e);
    }
  }
  /**
   * Deregisters the provided attribute type definition with this
   * schema.
   * Retrieves the attribute type definition with the specified name or OID.
   *
   * @param  attributeType  The attribute type to deregister with this
   *                        schema.
   * @param nameOrOid
   *          The name or OID of the attribute type to retrieve, ignoring case considerations
   * @param syntax
   *          The syntax to use when creating the temporary "place-holder" attribute type.
   * @return The requested attribute type
   */
  public void deregisterAttributeType(AttributeType attributeType)
  public AttributeType getAttributeType(String nameOrOid, Syntax syntax)
  {
    synchronized (attributeTypes)
    try
    {
      if (attributeTypes.remove(toLowerCase(attributeType.getOID()),
          attributeType))
      {
        // Mark the old attribute type as stale so that caches (such as
        // compressed schema) can detect changes.
        attributeType.setDirty();
      }
      for (String name : attributeType.getNormalizedNames())
      {
        attributeTypes.remove(name, attributeType);
      }
      AttributeType superiorType = attributeType.getSuperiorType();
      if (superiorType != null)
      {
        deregisterSubordinateType(attributeType, superiorType);
      }
      return schemaNG.getAttributeType(nameOrOid, syntax);
    }
    catch (UnknownSchemaElementException e)
    {
      // It should never happen because we only use non-strict schemas
      throw new RuntimeException(e);
    }
  }
  /**
   * Parses an attribute type from its provided definition.
   *
   * @param definition
   *          The definition of the attribute type
   * @return the attribute type
   * @throws DirectoryException
   *            If an error occurs
   */
  public AttributeType parseAttributeType(final String definition) throws DirectoryException
  {
    try
    {
      SchemaBuilder builder = new SchemaBuilder(schemaNG);
      builder.addAttributeType(definition, true);
      org.forgerock.opendj.ldap.schema.Schema newSchema = builder.toSchema();
      rejectSchemaWithWarnings(newSchema);
      return newSchema.getAttributeType(parseAttributeTypeOID(definition));
    }
    catch (UnknownSchemaElementException e)
    {
      // this should never happen
      LocalizableMessage msg = ERR_ATTR_TYPE_CANNOT_REGISTER.get(definition);
      throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, msg, e);
    }
    catch (LocalizedIllegalArgumentException e)
    {
      throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, e.getMessageObject(), e);
    }
  }
  /**
   * Registers a list of attribute types from their provided definitions.
   * <p>
   * This method allows to do only one schema change for multiple definitions,
   * thus avoiding the cost (and the issue of stale schema references) of rebuilding a new schema for each definition.
   *
   * @param definitions
   *          The definitions of the attribute types
   * @param schemaFile
   *          The schema file where these definitions belong, can be {@code null}
   * @param overwrite
   *          Indicates whether to overwrite the attribute
   *          type if it already exists based on OID or name
   * @throws DirectoryException
   *            If an error occurs
   */
  public void registerAttributeTypes(final List<String> definitions, final String schemaFile, final boolean overwrite)
      throws DirectoryException
  {
    exclusiveLock.lock();
    try
    {
      SchemaBuilder builder = new SchemaBuilder(schemaNG);
      for (String definition : definitions)
      {
        String defWithFile = schemaFile != null ?
            addSchemaFileToElementDefinitionIfAbsent(definition, schemaFile) : definition;
        builder.addAttributeType(defWithFile, overwrite);
      }
      switchSchema(builder.toSchema());
      for (String definition : definitions)
      {
        updateSubordinateTypes(schemaNG.getAttributeType(parseAttributeTypeOID(definition)));
      }
    }
    catch (ConflictingSchemaElementException | UnknownSchemaElementException e)
    {
      throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, e.getMessageObject(), e);
    }
    catch (LocalizedIllegalArgumentException e)
    {
      throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, e.getMessageObject(), e);
    }
    finally
    {
      exclusiveLock.unlock();
    }
  }
  /**
   * Registers an attribute type from its provided definition.
   *
   * @param definition
   *          The definition of the attribute type
   * @param schemaFile
   *          The schema file where this definition belongs,
   *          maybe {@code null}
   * @param overwrite
   *          Indicates whether to overwrite the attribute
   *          type if it already exists based on OID or name
   * @throws DirectoryException
   *            If an error occurs
   */
  public void registerAttributeType(final String definition, final String schemaFile, final boolean overwrite)
      throws DirectoryException
  {
    registerAttributeTypes(Arrays.asList(definition), schemaFile, overwrite);
  }
  /**
   * Registers the provided attribute type definition with this schema.
   *
   * @param attributeType
   *          The attribute type to register with this schema.
   * @param overwriteExisting
   *          Indicates whether to overwrite an existing mapping if there are
   *          any conflicts (i.e., another attribute type with the same OID or
   *          name).
   * @throws DirectoryException
   *           If a conflict is encountered and the
   *           <CODE>overwriteExisting</CODE> flag is set to <CODE>false</CODE>
   */
  public void registerAttributeType(final AttributeType attributeType, final boolean overwriteExisting)
      throws DirectoryException
  {
    registerAttributeType(attributeType, null, overwriteExisting);
  }
  /**
   * Registers the provided attribute type definition with this schema.
   *
   * @param attributeType
   *          The attribute type to register with this schema.
   * @param schemaFile
   *          The schema file where this definition belongs, maybe {@code null}
   * @param overwriteExisting
   *          Indicates whether to overwrite an existing mapping if there are
   *          any conflicts (i.e., another attribute type with the same OID or
   *          name).
   * @throws DirectoryException
   *           If a conflict is encountered and the
   *           <CODE>overwriteExisting</CODE> flag is set to <CODE>false</CODE>
   */
  public void registerAttributeType(final AttributeType attributeType, final String schemaFile,
      final boolean overwriteExisting) throws DirectoryException
  {
    exclusiveLock.lock();
    try
    {
      SchemaBuilder builder = new SchemaBuilder(schemaNG);
      AttributeType.Builder b = builder.buildAttributeType(attributeType);
      if (schemaFile != null)
      {
        b.removeExtraProperty(SCHEMA_PROPERTY_FILENAME).extraProperties(SCHEMA_PROPERTY_FILENAME, schemaFile);
      }
      if (overwriteExisting)
      {
        b.addToSchemaOverwrite();
      }
      else
      {
        b.addToSchema();
      }
      switchSchema(builder.toSchema());
      updateSubordinateTypes(attributeType);
    }
    catch (LocalizedIllegalArgumentException e)
    {
      throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, e.getMessageObject(), e);
    }
    finally
    {
      exclusiveLock.unlock();
    }
  }
  private String parseAttributeTypeOID(String definition) throws DirectoryException
  {
    return parseOID(definition, ResultCode.INVALID_ATTRIBUTE_SYNTAX, ERR_ATTR_SYNTAX_ATTRTYPE_EMPTY_VALUE);
  }
  /**
   * Returns the OID from the provided attribute type definition, assuming the
   * definition is valid.
   * <p>
   * This method does not perform any check.
   *
   * @param definition
   *          The definition, assumed to be valid
   * @param parsingErrorResultCode the result code to use if a problem occurs while parsing the definition
   * @param parsingErrorMsg the message to use if a problem occurs while parsing the definition
   * @return the OID, which is never {@code null}
   * @throws DirectoryException
   *           If a problem occurs while parsing the definition
   */
  public static String parseOID(String definition, ResultCode parsingErrorResultCode, Arg0 parsingErrorMsg)
      throws DirectoryException
  {
    try
    {
      int pos = 0;
      int length = definition.length();
      // Skip over any leading whitespace.
      while (pos < length && (definition.charAt(pos) == ' '))
      {
        pos++;
      }
      // Skip the open parenthesis.
      pos++;
      // Skip over any spaces immediately following the opening parenthesis.
      while (pos < length && definition.charAt(pos) == ' ')
      {
        pos++;
      }
      // The next set of characters must be the OID.
      int oidStartPos = pos;
      while (pos < length && definition.charAt(pos) != ' ' && definition.charAt(pos) != ')')
      {
        pos++;
      }
      return definition.substring(oidStartPos, pos);
    }
    catch (IndexOutOfBoundsException e)
    {
      throw new DirectoryException(parsingErrorResultCode, parsingErrorMsg.get(), e);
    }
  }
  /**
   * Deregisters the provided attribute type definition with this schema.
   *
   * @param  attributeType  The attribute type to deregister with this schema.
   */
  public void deregisterAttributeType(final AttributeType attributeType)
  {
    exclusiveLock.lock();
    try
    {
      SchemaBuilder builder = new SchemaBuilder(schemaNG);
      if (builder.removeAttributeType(attributeType.getNameOrOID()))
      {
        AttributeType superiorType = attributeType.getSuperiorType();
        if (superiorType != null)
        {
          deregisterSubordinateType(attributeType, superiorType);
        }
        setSchemaNG(builder.toSchema());
      }
    }
    finally
    {
      exclusiveLock.unlock();
    }
  }
  private void setSchemaNG(org.forgerock.opendj.ldap.schema.Schema newSchemaNG)
  {
    schemaNG = newSchemaNG.asNonStrictSchema();
  }
  private void updateSubordinateTypes(AttributeType attributeType)
  {
    AttributeType superiorType = attributeType.getSuperiorType();
    if (superiorType != null)
    {
      registerSubordinateType(attributeType, superiorType);
    }
  }
  /**
   * Registers the provided attribute type as a subtype of the given
@@ -378,18 +571,15 @@
   * @param  superiorType   The superior type for which to register
   *                        the given attribute type as a subtype.
   */
  private void registerSubordinateType(AttributeType attributeType,
                                       AttributeType superiorType)
  private void registerSubordinateType(AttributeType attributeType, AttributeType superiorType)
  {
    List<AttributeType> subTypes = subordinateTypes.get(superiorType);
    if (subTypes == null)
    {
      superiorType.setMayHaveSubordinateTypes();
      subordinateTypes.put(superiorType, newLinkedList(attributeType));
    }
    else if (! subTypes.contains(attributeType))
    else if (!subTypes.contains(attributeType))
    {
      superiorType.setMayHaveSubordinateTypes();
      subTypes.add(attributeType);
      AttributeType higherSuperior = superiorType.getSuperiorType();
@@ -400,8 +590,6 @@
    }
  }
  /**
   * Deregisters the provided attribute type as a subtype of the given
   * superior attribute type, recursively following any additional
@@ -412,8 +600,7 @@
   * @param  superiorType   The superior type for which to deregister
   *                        the given attribute type as a subtype.
   */
  private void deregisterSubordinateType(AttributeType attributeType,
                                         AttributeType superiorType)
  private void deregisterSubordinateType(AttributeType attributeType, AttributeType superiorType)
  {
    List<AttributeType> subTypes = subordinateTypes.get(superiorType);
    if (subTypes != null && subTypes.remove(attributeType))
@@ -426,8 +613,6 @@
    }
  }
  /**
   * Retrieves the set of subtypes registered for the given attribute
   * type.
@@ -442,14 +627,7 @@
  public List<AttributeType> getSubTypes(AttributeType attributeType)
  {
    List<AttributeType> subTypes = subordinateTypes.get(attributeType);
    if (subTypes == null)
    {
      return Collections.emptyList();
    }
    else
    {
      return subTypes;
    }
    return subTypes != null ? subTypes : Collections.<AttributeType> emptyList();
  }
@@ -524,7 +702,8 @@
                                  boolean overwriteExisting)
         throws DirectoryException
  {
    synchronized (objectClasses)
    exclusiveLock.lock();
    try
    {
      if (! overwriteExisting)
      {
@@ -569,6 +748,10 @@
        objectClasses.put(name, objectClass);
      }
    }
    finally
    {
      exclusiveLock.unlock();
    }
  }
@@ -600,72 +783,40 @@
  /**
   * Retrieves the attribute syntax definitions for this schema, as a
   * mapping between the OID for the syntax and the syntax itself.
   * Each syntax should only be present once, since its only key is
   * its OID.  The contents of the returned mapping must not be
   * altered.
   * Retrieves the attribute syntax definitions for this schema.
   *
   * @return  The attribute syntax definitions for this schema.
   */
  public ConcurrentHashMap<String,Syntax> getSyntaxes()
  public Collection<Syntax> getSyntaxes()
  {
    return syntaxes;
    return schemaNG.getSyntaxes();
  }
  /**
   * Indicates whether this schema definition includes an attribute
   * syntax with the provided name or OID.
   * syntax with the provided OID.
   *
   * @param  lowerName  The name or OID for which to make the
   *                    determination, formatted in all lowercase
   *                    characters.
   *
   * @param  oid  The OID for which to make the determination
   * @return  {@code true} if this schema contains an attribute syntax
   *          with the provided name or OID, or {@code false} if not.
   *          with the provided OID, or {@code false} if not.
   */
  public boolean hasSyntax(String lowerName)
  public boolean hasSyntax(String oid)
  {
    return syntaxes.containsKey(lowerName);
  }
  /**
   * Retrieves the requested attribute syntax.
   *
   * @param oid
   *          The OID of the syntax to retrieve.
   * @param allowDefault
   *          Indicates whether to return the default attribute syntax if the
   *          requested syntax is unknown.
   * @return The requested attribute syntax, the default syntax if the requested
   *         syntax is unknown and the caller has indicated that the default is
   *         acceptable, or <CODE>null</CODE> otherwise.
   */
  public Syntax getSyntax(String oid, boolean allowDefault)
  {
    Syntax syntax = getSyntax(oid);
    if (syntax == null && allowDefault)
    {
      return getDefaultSyntax();
    }
    return syntax;
    return schemaNG.hasSyntax(oid);
  }
  /**
   * Retrieves the attribute syntax definition with the OID.
   *
   * @param  lowerName  The OID of the attribute syntax to retrieve,
   *                    formatted in all lowercase characters.
   *
   * @return  The requested attribute syntax, or <CODE>null</CODE> if
   *          no syntax is registered with the provided OID.
   * @param  oid  The OID of the attribute syntax to retrieve.
   * @return  The requested attribute syntax,
   *          or {@code null} if no syntax is registered with the provided OID.
   */
  public Syntax getSyntax(String lowerName)
  public Syntax getSyntax(String oid)
  {
    return syntaxes.get(lowerName);
    return schemaNG.getSyntax(oid);
  }
  /**
@@ -677,7 +828,7 @@
   */
  public Syntax getDefaultSyntax()
  {
    return defaultSyntax;
    return schemaNG.getSyntax(defaultSyntaxOID);
  }
@@ -688,10 +839,9 @@
   * @param defaultSyntax
   *            The defautl syntax to use.
   */
  public void registerDefaultSyntax(
      Syntax defaultSyntax)
  public void registerDefaultSyntax(Syntax defaultSyntax)
  {
    this.defaultSyntax = defaultSyntax;
    this.defaultSyntaxOID = defaultSyntax.getOID();
  }
@@ -711,45 +861,75 @@
   *                              <CODE>overwriteExisting</CODE> flag
   *                              is set to <CODE>false</CODE>
   */
  public void registerSyntax(Syntax syntax,
                             boolean overwriteExisting)
         throws DirectoryException
  public void registerSyntax(final Syntax syntax, final boolean overwriteExisting) throws DirectoryException
  {
    synchronized (syntaxes)
    exclusiveLock.lock();
    try
    {
      if (! overwriteExisting)
      SchemaBuilder builder = new SchemaBuilder(schemaNG);
      Syntax.Builder b = builder.buildSyntax(syntax);
      if (overwriteExisting)
      {
        String oid = toLowerCase(syntax.getOID());
        if (syntaxes.containsKey(oid))
        {
          Syntax conflictingSyntax = syntaxes.get(oid);
          LocalizableMessage message = ERR_SCHEMA_CONFLICTING_SYNTAX_OID.
              get(syntax.getName(), oid,
                  conflictingSyntax.getName());
          throw new DirectoryException(
                         ResultCode.CONSTRAINT_VIOLATION, message);
        }
        b.addToSchemaOverwrite();
      }
      syntaxes.put(toLowerCase(syntax.getOID()), syntax);
      else
      {
        b.addToSchema();
      }
      switchSchema(builder.toSchema());
    }
    catch (LocalizedIllegalArgumentException e)
    {
      throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, e.getMessageObject(), e);
    }
    finally
    {
      exclusiveLock.unlock();
    }
  }
  private void registerSyntax(final String definition, final boolean overwriteExisting) throws DirectoryException
  {
    exclusiveLock.lock();
    try
    {
      org.forgerock.opendj.ldap.schema.Schema newSchema =
          new SchemaBuilder(schemaNG)
          .addSyntax(definition, overwriteExisting)
          .toSchema();
      switchSchema(newSchema);
    }
    catch (ConflictingSchemaElementException | UnknownSchemaElementException e)
    {
      throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, e.getMessageObject(), e);
    }
    catch (LocalizedIllegalArgumentException e)
    {
      throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, e.getMessageObject(), e);
    }
    finally
    {
      exclusiveLock.unlock();
    }
  }
  /**
   * Deregisters the provided attribute syntax definition with this
   * schema.
   * Deregisters the provided attribute syntax definition with this schema.
   *
   * @param  syntax  The attribute syntax to deregister with this
   *                 schema.
   * @param  syntax  The attribute syntax to deregister with this schema.
   */
  public void deregisterSyntax(Syntax syntax)
  public void deregisterSyntax(final Syntax syntax)
  {
    synchronized (syntaxes)
    exclusiveLock.lock();
    try
    {
      syntaxes.remove(toLowerCase(syntax.getOID()), syntax);
      SchemaBuilder builder = new SchemaBuilder(schemaNG);
      builder.removeSyntax(syntax.getOID());
      setSchemaNG(builder.toSchema());
    }
    finally
    {
      exclusiveLock.unlock();
    }
  }
@@ -764,32 +944,11 @@
   *
   * @return  The ldap syntax definitions for this schema.
   */
  public ConcurrentHashMap<String,LDAPSyntaxDescription>
          getLdapSyntaxDescriptions()
  public ConcurrentHashMap<String,LDAPSyntaxDescription> getLdapSyntaxDescriptions()
  {
    return ldapSyntaxDescriptions;
  }
  /**
   * Indicates whether this schema definition includes an ldap
   * syntax description with the provided name or OID.
   *
   * @param  lowerName  The OID for which to make the
   *                    determination, formatted in all lowercase
   *                    characters.
   *
   * @return  {@code true} if this schema contains an ldap syntax
   *          with the provided name or OID, or {@code false} if not.
   */
  public boolean hasLdapSyntaxDescription(String lowerName)
  {
    return ldapSyntaxDescriptions.containsKey(lowerName);
  }
  /**
   * Retrieves the ldap syntax definition with the OID.
   *
@@ -799,33 +958,25 @@
   * @return  The requested ldap syntax, or <CODE>null</CODE> if
   *          no syntax is registered with the provided OID.
   */
  public LDAPSyntaxDescription getLdapSyntaxDescription(
          String lowerName)
  public LDAPSyntaxDescription getLdapSyntaxDescription(String lowerName)
  {
    return ldapSyntaxDescriptions.get(lowerName);
  }
  /**
   * Registers the provided ldap syntax description with this
   * schema.
   * Registers the provided ldap syntax description with this schema.
   *
   * @param  syntax    The ldap syntax description to register
   *                              with this schema.
   * @param  overwriteExisting  Indicates whether to overwrite an
   *                            existing mapping if there are any
   *                            conflicts (i.e., another ldap
   *                            syntax with the same OID).
   *
   * @throws  DirectoryException  If a conflict is encountered and
   *                              <CODE>overwriteExisting</CODE> flag
   *                              is set to <CODE>false</CODE>
   * @param definition
   *          The ldap syntax definition to register with this schema.
   * @param overwriteExisting
   *          Indicates whether to overwrite an existing mapping if there are
   *          any conflicts (i.e., another ldap syntax with the same OID).
   * @throws DirectoryException
   *           If a conflict is encountered and <CODE>overwriteExisting</CODE>
   *           flag is set to <CODE>false</CODE>
   */
  public void registerLdapSyntaxDescription(
                            LDAPSyntaxDescription syntax,
                             boolean overwriteExisting)
         throws DirectoryException
  public void registerLdapSyntaxDescription(String definition, boolean overwriteExisting)
      throws DirectoryException
  {
    /**
     * ldapsyntaxes is part real and part virtual. For any
@@ -835,71 +986,65 @@
     * virtual syntax set to make this available through virtual
     * ldapsyntaxes attribute.
     */
    synchronized (ldapSyntaxDescriptions)
    exclusiveLock.lock();
    try
    {
      String oid = toLowerCase(syntax.getSyntax().getOID());
      String oid = parseAttributeTypeOID(definition);
      if (! overwriteExisting && ldapSyntaxDescriptions.containsKey(oid))
      {
         throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
        throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
            ERR_SCHEMA_MODIFY_MULTIPLE_CONFLICTS_FOR_ADD_LDAP_SYNTAX.get(oid));
      }
      ldapSyntaxDescriptions.put(oid, syntax);
      // Register the attribute syntax with the schema.
      // It will ensure syntax is available along with the other virtual values for ldapsyntaxes.
      registerSyntax(definition, overwriteExisting);
      //Register the attribute syntax with the schema. It will ensure
      // syntax is available along with the other virtual values for
      // ldapsyntaxes.
      registerSyntax(syntax.getSyntax(), overwriteExisting);
      Syntax syntax = schemaNG.getSyntax(oid);
      LDAPSyntaxDescription syntaxDesc = new LDAPSyntaxDescription(definition, oid, syntax.getExtraProperties());
      ldapSyntaxDescriptions.put(oid, syntaxDesc);
    }
  }
  /**
   * Deregisters the provided ldap syntax description with this
   * schema.
   *
   * @param  syntax  The ldap syntax to deregister with this
   *                 schema.
   */
  public void deregisterLdapSyntaxDescription(
          LDAPSyntaxDescription syntax)
  {
    synchronized (ldapSyntaxDescriptions)
    finally
    {
      //Remove the real value.
      ldapSyntaxDescriptions.remove(
       toLowerCase(syntax.getSyntax().getOID()),
       syntax);
      try
      {
        //Get rid of this from the virtual ldapsyntaxes.
        deregisterSyntax(syntax.getSyntax());
      }
      catch (Exception e)
      {
        deregisterSyntax(syntax.getSyntax());
      }
      exclusiveLock.unlock();
    }
  }
  /**
   * Retrieves the entire set of matching rule definitions for this
   * schema, as a mapping between the lowercase names and OIDs for the
   * matching rule and the matching rule itself.  Each matching rule
   * may be associated with multiple keys (once for the OID and again
   * for each name).  This should be a superset of the sets of
   * approximate, equality, ordering, and substring matching rules.
   * The contents of the returned mapping must not be altered.
   * Deregisters the provided ldap syntax description with this schema.
   *
   * @return  The matching rule definitions for this schema.
   * @param syntaxDesc
   *          The ldap syntax to deregister with this schema.
   */
  public ConcurrentHashMap<String,MatchingRule> getMatchingRules()
  public void deregisterLdapSyntaxDescription(LDAPSyntaxDescription syntaxDesc)
  {
    return matchingRules;
    exclusiveLock.lock();
    try
    {
      // Remove the real value.
      ldapSyntaxDescriptions.remove(toLowerCase(syntaxDesc.getOID()), syntaxDesc);
      // Get rid of this from the virtual ldapsyntaxes.
      deregisterSyntax(getSyntax(syntaxDesc.getOID()));
    }
    finally
    {
      exclusiveLock.unlock();
    }
  }
  /**
   * Retrieves all matching rule definitions for this schema.
   *
   * @return The matching rule definitions for this schema
   */
  public Collection<MatchingRule> getMatchingRules()
  {
    return schemaNG.getMatchingRules();
  }
@@ -908,34 +1053,26 @@
   * Indicates whether this schema definition includes a matching rule
   * with the provided name or OID.
   *
   * @param  lowerName  The name or OID for which to make the
   *                    determination, formatted in all lowercase
   *                    characters.
   *
   * @param  nameOrOid  The name or OID for which to make the determination, ignoring case considerations
   * @return  {@code true} if this schema contains a matching rule
   *          with the provided name or OID, or {@code false} if not.
   */
  public boolean hasMatchingRule(String lowerName)
  public boolean hasMatchingRule(String nameOrOid)
  {
    return matchingRules.containsKey(lowerName);
    return schemaNG.hasMatchingRule(nameOrOid);
  }
  /**
   * Retrieves the matching rule definition with the specified name or
   * OID.
   * Retrieves the matching rule definition with the specified name or OID.
   *
   * @param  lowerName  The name or OID of the matching rule to
   *                    retrieve, formatted in all lowercase
   *                    characters.
   *
   * @return  The requested matching rule, or <CODE>null</CODE> if no
   *          rule is registered with the provided name or OID.
   * @param nameOrOid The name or OID of the matching rule to retrieve, ignoring case considerations
   * @return The requested matching rule, or {@code null} if no rule is registered with the provided name or OID.
   */
  public MatchingRule getMatchingRule(String lowerName)
  public MatchingRule getMatchingRule(String nameOrOid)
  {
    return matchingRules.get(lowerName);
    return schemaNG.getMatchingRule(nameOrOid);
  }
@@ -943,87 +1080,81 @@
  /**
   * Registers the provided matching rule definition with this schema.
   *
   * @param  matchingRule       The matching rule to register with
   *                            this schema.
   * @param  overwriteExisting  Indicates whether to overwrite an
   *                            existing mapping if there are any
   *                            conflicts (i.e.,
   *                            another matching rule with the same
   *                            OID or name).
   *
   * @throws  DirectoryException  If a conflict is encountered and the
   *                              <CODE>overwriteExisting</CODE> flag
   *                              is set to <CODE>false</CODE>
   * @param matchingRule
   *          The matching rule to register with this schema.
   * @param overwriteExisting
   *          Indicates whether to overwrite an existing mapping if there are
   *          any conflicts (i.e., another matching rule with the same OID or
   *          name).
   * @throws DirectoryException
   *           If a conflict is encountered and the
   *           {@code overwriteExisting} flag is set to {@code false}
   */
  public void registerMatchingRule(MatchingRule matchingRule, boolean overwriteExisting)
  public void registerMatchingRule(final MatchingRule matchingRule, final boolean overwriteExisting)
         throws DirectoryException
  {
    synchronized (matchingRules)
    exclusiveLock.lock();
    try
    {
      if (!overwriteExisting)
      {
        String oid = toLowerCase(matchingRule.getOID());
        if (matchingRules.containsKey(oid))
        {
          MatchingRule conflictingRule = matchingRules.get(oid);
          LocalizableMessage message =
              ERR_SCHEMA_CONFLICTING_MR_OID.get(matchingRule.getNameOrOID(),
                  oid, conflictingRule.getNameOrOID());
          throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
        }
        // check all names of the matching rules because it is not checked by SDK schema
        for (String name : matchingRule.getNames())
        {
          if (name != null)
          if (schemaNG.hasMatchingRule(name))
          {
            name = toLowerCase(name);
            if (matchingRules.containsKey(name))
            {
              MatchingRule conflictingRule = matchingRules.get(name);
            Collection<MatchingRule> conflictingRules = schemaNG.getMatchingRulesWithName(name);
            // there should be only one
            MatchingRule conflictingRule = conflictingRules.iterator().next();
              LocalizableMessage message =
                  ERR_SCHEMA_CONFLICTING_MR_NAME.get(matchingRule.getOID(),
                      name, conflictingRule.getOID());
              throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
                  message);
            }
            LocalizableMessage message =
                ERR_SCHEMA_CONFLICTING_MR_NAME.get(matchingRule.getOID(), name, conflictingRule.getOID());
            throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
          }
        }
      }
      matchingRules.put(toLowerCase(matchingRule.getOID()), matchingRule);
      for (String name : matchingRule.getNames())
      // now register the matching rule
      SchemaBuilder builder = new SchemaBuilder(schemaNG);
      MatchingRule.Builder b = builder.buildMatchingRule(matchingRule);
      if (overwriteExisting)
      {
        if (name != null)
        {
          matchingRules.put(toLowerCase(name), matchingRule);
        }
        b.addToSchemaOverwrite();
      }
      else
      {
        b.addToSchema();
      }
      switchSchema(builder.toSchema());
    }
    catch (LocalizedIllegalArgumentException e)
    {
      throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, e.getMessageObject(), e);
    }
    finally
    {
      exclusiveLock.unlock();
    }
  }
  /**
   * Deregisters the provided matching rule definition with this
   * schema.
   * Deregisters the provided matching rule definition with this schema.
   *
   * @param  matchingRule  The matching rule to deregister with this
   *                       schema.
   * @param matchingRule
   *          The matching rule to deregister with this schema.
   */
  public void deregisterMatchingRule(MatchingRule matchingRule)
  public void deregisterMatchingRule(final MatchingRule matchingRule)
  {
    synchronized (matchingRules)
    exclusiveLock.lock();
    try
    {
      matchingRules.remove(toLowerCase(matchingRule.getOID()), matchingRule);
      for (String name : matchingRule.getNames())
      {
        if (name != null)
        {
          matchingRules.remove(toLowerCase(name), matchingRule);
        }
      }
      SchemaBuilder builder = new SchemaBuilder(schemaNG);
      builder.removeMatchingRule(matchingRule.getNameOrOID());
      setSchemaNG(builder.toSchema());
    }
    finally
    {
      exclusiveLock.unlock();
    }
  }
@@ -1047,23 +1178,6 @@
  /**
   * Indicates whether this schema definition includes a matching rule
   * use for the provided matching rule.
   *
   * @param  matchingRule  The matching rule for which to make the
   *                       determination.
   *
   * @return  {@code true} if this schema contains a matching rule use
   *          for the provided matching rule, or {@code false} if not.
   */
  public boolean hasMatchingRuleUse(MatchingRule matchingRule)
  {
    return matchingRuleUses.containsKey(matchingRule);
  }
  /**
   * Retrieves the matching rule use definition for the specified
   * matching rule.
   *
@@ -1158,23 +1272,6 @@
  /**
   * Indicates whether this schema definition includes a DIT content
   * rule for the provided objectclass.
   *
   * @param  objectClass  The objectclass for which to make the
   *                      determination.
   *
   * @return  {@code true} if this schema contains a DIT content rule
   *          for the provided objectclass, or {@code false} if not.
   */
  public boolean hasDITContentRule(ObjectClass objectClass)
  {
    return ditContentRules.containsKey(objectClass);
  }
  /**
   * Retrieves the DIT content rule definition for the specified
   * objectclass.
   *
@@ -1286,40 +1383,6 @@
  /**
   * Indicates whether this schema definition includes a DIT structure
   * rule with the provided rule ID.
   *
   * @param  ruleID  The rule ID for which to make the determination.
   *
   * @return  {@code true} if this schema contains a DIT structure
   *          rule with the provided rule ID, or {@code false} if not.
   */
  public boolean hasDITStructureRule(int ruleID)
  {
    return ditStructureRulesByID.containsKey(ruleID);
  }
  /**
   * Indicates whether this schema definition includes a DIT structure
   * rule for the provided name form.
   *
   * @param  nameForm  The name form for which to make the
   *                   determination.
   *
   * @return  {@code true} if this schema contains a DIT structure
   *          rule for the provided name form, or {@code false} if
   *          not.
   */
  public boolean hasDITStructureRule(NameForm nameForm)
  {
    return ditStructureRulesByNameForm.containsKey(nameForm);
  }
  /**
   * Retrieves the DIT structure rule definition with the provided
   * rule ID.
   *
@@ -1469,23 +1532,6 @@
  /**
   * Indicates whether this schema definition includes a name form for
   * the specified objectclass.
   *
   * @param  objectClass  The objectclass for which to make the
   *                      determination.
   *
   * @return  {@code true} if this schema contains a name form for the
   *          provided objectclass, or {@code false} if not.
   */
  public boolean hasNameForm(ObjectClass objectClass)
  {
    return nameFormsByOC.containsKey(objectClass);
  }
  /**
   * Indicates whether this schema definition includes a name form
   * with the specified name or OID.
   *
@@ -1714,8 +1760,6 @@
    this.youngestModificationTime = youngestModificationTime;
  }
  /**
   * Recursively rebuilds all schema elements that are dependent upon
   * the provided element.  This must be invoked whenever an existing
@@ -1757,12 +1801,33 @@
   * @throws  DirectoryException  If a problem occurs while rebuilding
   *                              any of the schema elements.
   */
  public void rebuildDependentElements(SchemaFileElement element)
         throws DirectoryException
  public void rebuildDependentElements(SchemaFileElement element) throws DirectoryException
  {
    try
    {
      rebuildDependentElements(element, 0);
      // increase the depth for each level of recursion to protect against errors due to circular references.
      final int depth = 0;
      if (element instanceof SomeSchemaElement)
      {
        SomeSchemaElement elt = (SomeSchemaElement) element;
        if (elt.isAttributeType())
        {
          rebuildDependentElements(elt.getAttributeType(), depth);
        }
      }
      else if (element instanceof ObjectClass)
      {
        rebuildDependentElements((ObjectClass) element, depth);
      }
      else if (element instanceof NameForm)
      {
        rebuildDependentElements((NameForm) element, depth);
      }
      else if (element instanceof DITStructureRule)
      {
        rebuildDependentElements((DITStructureRule) element, depth);
      }
    }
    catch (DirectoryException de)
    {
@@ -1774,194 +1839,157 @@
      {
        LocalizableMessage message =
            ERR_SCHEMA_CIRCULAR_DEPENDENCY_REFERENCE.get(element);
        throw new DirectoryException(de.getResultCode(), message,
                                     de);
        throw new DirectoryException(de.getResultCode(), message, de);
      }
      // It wasn't a circular reference error, so just re-throw the
      // exception.
      // It wasn't a circular reference error, so just re-throw the exception.
      throw de;
    }
  }
  /**
   * Recursively rebuilds all schema elements that are dependent upon
   * the provided element, increasing the depth for each level of
   * recursion to protect against errors due to circular references.
   *
   * @param  element  The element for which to recursively rebuild all
   *                  dependent elements.
   * @param  depth    The current recursion depth.
   *
   * @throws  DirectoryException  If a problem occurs while rebuilding
   *                              any of the schema elements.
   */
  private void rebuildDependentElements(SchemaFileElement element,
                                        int depth)
          throws DirectoryException
  private void circularityCheck(int depth, SchemaFileElement element) throws DirectoryException
  {
    if (depth > 20)
    {
      // FIXME -- Is this an appropriate maximum depth for detecting
      // circular references?
      // FIXME use a stack of already traversed elements and verify we're updating them only once instead of depth only
      throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
          ERR_SCHEMA_CIRCULAR_DEPENDENCY_REFERENCE.get(element));
    }
  }
  private void rebuildDependentElements(AttributeType type, int depth) throws DirectoryException
  {
    circularityCheck(depth, null);
    // Figure out what type of element we're dealing with and make the
    // appropriate determinations for that element.
    if (element instanceof AttributeType)
    for (AttributeType at : schemaNG.getAttributeTypes())
    {
      AttributeType t = (AttributeType) element;
      for (AttributeType at : attributeTypes.values())
      if ((at.getSuperiorType() != null) && at.getSuperiorType().equals(type))
      {
        if (at.getSuperiorType() != null && at.getSuperiorType().equals(t))
        {
          AttributeType newAT = recreateFromDefinition(at);
          deregisterAttributeType(at);
          registerAttributeType(newAT, true);
          rebuildDependentElements(at, depth+1);
        }
        deregisterAttributeType(at);
        registerAttributeType(at.toString(), getSchemaFileName(at), true);
        rebuildDependentElements(at, depth + 1);
      }
    }
      for (ObjectClass oc : objectClasses.values())
    for (ObjectClass oc : objectClasses.values())
    {
      if (oc.getRequiredAttributes().contains(type) || oc.getOptionalAttributes().contains(type))
      {
        if (oc.getRequiredAttributes().contains(t) ||
            oc.getOptionalAttributes().contains(t))
        {
          ObjectClass newOC = recreateFromDefinition(oc);
          deregisterObjectClass(oc);
          registerObjectClass(newOC, true);
          rebuildDependentElements(oc, depth+1);
        }
        ObjectClass newOC = recreateFromDefinition(oc);
        deregisterObjectClass(oc);
        registerObjectClass(newOC, true);
        rebuildDependentElements(oc, depth + 1);
      }
    }
      for (List<NameForm> mappedForms : nameFormsByOC.values())
    for (List<NameForm> mappedForms : nameFormsByOC.values())
    {
      for (NameForm nf : mappedForms)
      {
        for(NameForm nf : mappedForms)
        if (nf.getRequiredAttributes().contains(type) || nf.getOptionalAttributes().contains(type))
        {
          if (nf.getRequiredAttributes().contains(t) ||
              nf.getOptionalAttributes().contains(t))
          {
            NameForm newNF = recreateFromDefinition(nf);
            deregisterNameForm(nf);
            registerNameForm(newNF, true);
            rebuildDependentElements(nf, depth+1);
          }
        }
      }
      for (DITContentRule dcr : ditContentRules.values())
      {
        if (dcr.getRequiredAttributes().contains(t) ||
            dcr.getOptionalAttributes().contains(t) ||
            dcr.getProhibitedAttributes().contains(t))
        {
          DITContentRule newDCR = recreateFromDefinition(dcr);
          deregisterDITContentRule(dcr);
          registerDITContentRule(newDCR, true);
          rebuildDependentElements(dcr, depth+1);
        }
      }
      for (MatchingRuleUse mru : matchingRuleUses.values())
      {
        if (mru.getAttributes().contains(t))
        {
          MatchingRuleUse newMRU = recreateFromDefinition(mru);
          deregisterMatchingRuleUse(mru);
          registerMatchingRuleUse(newMRU, true);
          rebuildDependentElements(mru, depth+1);
          NameForm newNF = recreateFromDefinition(nf);
          deregisterNameForm(nf);
          registerNameForm(newNF, true);
          rebuildDependentElements(nf, depth + 1);
        }
      }
    }
    else if (element instanceof ObjectClass)
    for (DITContentRule dcr : ditContentRules.values())
    {
      ObjectClass c = (ObjectClass) element;
      for (ObjectClass oc : objectClasses.values())
      if (dcr.getRequiredAttributes().contains(type) || dcr.getOptionalAttributes().contains(type)
          || dcr.getProhibitedAttributes().contains(type))
      {
        if (oc.getSuperiorClasses().contains(c))
        {
          ObjectClass newOC = recreateFromDefinition(oc);
          deregisterObjectClass(oc);
          registerObjectClass(newOC, true);
          rebuildDependentElements(oc, depth+1);
        }
      }
      List<NameForm> mappedForms = nameFormsByOC.get(c);
      if(mappedForms != null)
      {
        for(NameForm nf : mappedForms)
        {
          if (nf != null)
          {
            NameForm newNF = recreateFromDefinition(nf);
            deregisterNameForm(nf);
            registerNameForm(newNF, true);
            rebuildDependentElements(nf, depth+1);
          }
        }
      }
      for (DITContentRule dcr : ditContentRules.values())
      {
        if (dcr.getStructuralClass().equals(c) ||
            dcr.getAuxiliaryClasses().contains(c))
        {
          DITContentRule newDCR = recreateFromDefinition(dcr);
          deregisterDITContentRule(dcr);
          registerDITContentRule(newDCR, true);
          rebuildDependentElements(dcr, depth+1);
        }
        DITContentRule newDCR = recreateFromDefinition(dcr);
        deregisterDITContentRule(dcr);
        registerDITContentRule(newDCR, true);
      }
    }
    else if (element instanceof NameForm)
    for (MatchingRuleUse mru : matchingRuleUses.values())
    {
      NameForm n = (NameForm) element;
      DITStructureRule dsr = ditStructureRulesByNameForm.get(n);
      if (dsr != null)
      if (mru.getAttributes().contains(type))
      {
        DITStructureRule newDSR = recreateFromDefinition(dsr);
        deregisterDITStructureRule(dsr);
        registerDITStructureRule(newDSR, true);
        rebuildDependentElements(dsr, depth+1);
      }
    }
    else if (element instanceof DITStructureRule)
    {
      DITStructureRule d = (DITStructureRule) element;
      for (DITStructureRule dsr : ditStructureRulesByID.values())
      {
        if (dsr.getSuperiorRules().contains(d))
        {
          DITStructureRule newDSR = recreateFromDefinition(dsr);
          deregisterDITStructureRule(dsr);
          registerDITStructureRule(newDSR, true);
          rebuildDependentElements(dsr, depth+1);
        }
        MatchingRuleUse newMRU = recreateFromDefinition(mru);
        deregisterMatchingRuleUse(mru);
        registerMatchingRuleUse(newMRU, true);
      }
    }
  }
  private AttributeType recreateFromDefinition(AttributeType attrType)
      throws DirectoryException
  private void rebuildDependentElements(ObjectClass c, int depth) throws DirectoryException
  {
    ByteString value = ByteString.valueOfUtf8(attrType.toString());
    AttributeType copy =
        AttributeTypeSyntax.decodeAttributeType(value, this, false);
    setSchemaFile(copy, getSchemaFile(attrType));
    if (attrType.mayHaveSubordinateTypes())
    circularityCheck(depth, c);
    for (ObjectClass oc : objectClasses.values())
    {
      copy.setMayHaveSubordinateTypes();
      if (oc.getSuperiorClasses().contains(c))
      {
        ObjectClass newOC = recreateFromDefinition(oc);
        deregisterObjectClass(oc);
        registerObjectClass(newOC, true);
        rebuildDependentElements(oc, depth + 1);
      }
    }
    return copy;
    List<NameForm> mappedForms = nameFormsByOC.get(c);
    if (mappedForms != null)
    {
      for (NameForm nf : mappedForms)
      {
        if (nf != null)
        {
          NameForm newNF = recreateFromDefinition(nf);
          deregisterNameForm(nf);
          registerNameForm(newNF, true);
          rebuildDependentElements(nf, depth + 1);
        }
      }
    }
    for (DITContentRule dcr : ditContentRules.values())
    {
      if (dcr.getStructuralClass().equals(c) || dcr.getAuxiliaryClasses().contains(c))
      {
        DITContentRule newDCR = recreateFromDefinition(dcr);
        deregisterDITContentRule(dcr);
        registerDITContentRule(newDCR, true);
      }
    }
  }
  private void rebuildDependentElements(NameForm n, int depth) throws DirectoryException
  {
    circularityCheck(depth, n);
    DITStructureRule dsr = ditStructureRulesByNameForm.get(n);
    if (dsr != null)
    {
      DITStructureRule newDSR = recreateFromDefinition(dsr);
      deregisterDITStructureRule(dsr);
      registerDITStructureRule(newDSR, true);
      rebuildDependentElements(dsr, depth + 1);
    }
  }
  private void rebuildDependentElements(DITStructureRule d, int depth) throws DirectoryException
  {
    circularityCheck(depth, d);
    for (DITStructureRule dsr : ditStructureRulesByID.values())
    {
      if (dsr.getSuperiorRules().contains(d))
      {
        DITStructureRule newDSR = recreateFromDefinition(dsr);
        deregisterDITStructureRule(dsr);
        registerDITStructureRule(newDSR, true);
        rebuildDependentElements(dsr, depth + 1);
      }
    }
  }
  private String getSchemaFileName(AttributeType attributeType)
  {
    List<String> values = attributeType.getExtraProperties().get(ServerConstants.SCHEMA_PROPERTY_FILENAME);
    return values != null && ! values.isEmpty() ? values.get(0) : null;
  }
  private DITContentRule recreateFromDefinition(DITContentRule dcr)
@@ -2022,13 +2050,10 @@
   */
  public Schema duplicate()
  {
    Schema dupSchema = new Schema();
    Schema dupSchema = new Schema(schemaNG);
    dupSchema.attributeTypes.putAll(attributeTypes);
    dupSchema.subordinateTypes.putAll(subordinateTypes);
    dupSchema.objectClasses.putAll(objectClasses);
    dupSchema.syntaxes.putAll(syntaxes);
    dupSchema.matchingRules.putAll(matchingRules);
    dupSchema.matchingRuleUses.putAll(matchingRuleUses);
    dupSchema.ditContentRules.putAll(ditContentRules);
    dupSchema.ditStructureRulesByID.putAll(ditStructureRulesByID);
@@ -2104,76 +2129,26 @@
      concatFilePath = concatFile.getAbsolutePath();
      File tempFile = new File(concatFilePath + ".tmp");
      BufferedWriter writer =
           new BufferedWriter(new FileWriter(tempFile, false));
      writer.write("dn: " + DirectoryServer.getSchemaDN());
      writer.newLine();
      writer.write("objectClass: top");
      writer.newLine();
      writer.write("objectClass: ldapSubentry");
      writer.newLine();
      writer.write("objectClass: subschema");
      writer.newLine();
      for (String line : attributeTypes)
      try (BufferedWriter writer = new BufferedWriter(new FileWriter(tempFile, false)))
      {
        writer.write(ATTR_ATTRIBUTE_TYPES);
        writer.write(": ");
        writer.write(line);
        writer.write("dn: " + DirectoryServer.getSchemaDN());
        writer.newLine();
      }
      for (String line : objectClasses)
      {
        writer.write(ATTR_OBJECTCLASSES);
        writer.write(": ");
        writer.write(line);
        writer.write("objectClass: top");
        writer.newLine();
      }
      for (String line : nameForms)
      {
        writer.write(ATTR_NAME_FORMS);
        writer.write(": ");
        writer.write(line);
        writer.write("objectClass: ldapSubentry");
        writer.newLine();
      }
      for (String line : ditContentRules)
      {
        writer.write(ATTR_DIT_CONTENT_RULES);
        writer.write(": ");
        writer.write(line);
        writer.write("objectClass: subschema");
        writer.newLine();
        writeLines(writer, ATTR_ATTRIBUTE_TYPES, attributeTypes);
        writeLines(writer, ATTR_OBJECTCLASSES, objectClasses);
        writeLines(writer, ATTR_NAME_FORMS, nameForms);
        writeLines(writer, ATTR_DIT_CONTENT_RULES, ditContentRules);
        writeLines(writer, ATTR_DIT_STRUCTURE_RULES, ditStructureRules);
        writeLines(writer, ATTR_MATCHING_RULE_USE, matchingRuleUses);
        writeLines(writer, ATTR_LDAP_SYNTAXES, ldapSyntaxes);
      }
      for (String line : ditStructureRules)
      {
        writer.write(ATTR_DIT_STRUCTURE_RULES);
        writer.write(": ");
        writer.write(line);
        writer.newLine();
      }
      for (String line : matchingRuleUses)
      {
        writer.write(ATTR_MATCHING_RULE_USE);
        writer.write(": ");
        writer.write(line);
        writer.newLine();
      }
      for (String line : ldapSyntaxes)
      {
        writer.write(ATTR_LDAP_SYNTAXES);
        writer.write(": ");
        writer.write(line);
        writer.newLine();
      }
      writer.close();
      if (concatFile.exists())
      {
        concatFile.delete();
@@ -2193,6 +2168,17 @@
    }
  }
  private static void writeLines(BufferedWriter writer, String beforeColumn, Set<String> lines) throws IOException
  {
    for (String line : lines)
    {
      writer.write(beforeColumn);
      writer.write(": ");
      writer.write(line);
      writer.newLine();
    }
  }
  /**
@@ -2516,10 +2502,9 @@
       mayInvoke=true)
  public synchronized void destroy()
  {
    if (attributeTypes != null)
    if (schemaNG != null)
    {
      attributeTypes.clear();
      attributeTypes = null;
      schemaNG = null;
    }
    if (ditContentRules != null)
@@ -2540,12 +2525,6 @@
      ditStructureRulesByNameForm = null;
    }
    if (matchingRules != null)
    {
      matchingRules.clear();
      matchingRules = null;
    }
    if (matchingRuleUses != null)
    {
      matchingRuleUses.clear();
@@ -2582,18 +2561,122 @@
      extraAttributes = null;
    }
    if (syntaxes != null)
    {
      syntaxes.clear();
      syntaxes = null;
    }
    if(ldapSyntaxDescriptions != null)
    {
      ldapSyntaxDescriptions.clear();
      ldapSyntaxDescriptions = null;
    }
  }
  /**
   * Update the schema using the provided schema updater.
   * <p>
   * An implicit lock is performed, so it is in general not necessary
   * to call the {code lock()}  and {code unlock() methods.
   * However, these method should be used if/when the SchemaBuilder passed
   * as an argument to the updater is not used to return the schema
   * (see for example usage in {@code CoreSchemaProvider} class). This
   * case should remain exceptional.
   *
   * @param updater
   *          the updater that returns a new schema
   * @throws DirectoryException if there is any problem updating the schema
   */
  public void updateSchema(SchemaUpdater updater) throws DirectoryException
  {
    exclusiveLock.lock();
    try
    {
      switchSchema(updater.update(new SchemaBuilder(schemaNG)));
    }
    finally
    {
      exclusiveLock.unlock();
    }
  }
  /** Interface to update a schema provided a schema builder. */
  public interface SchemaUpdater
  {
    /**
     * Returns an updated schema.
     *
     * @param builder
     *          The builder on the current schema
     * @return the new schema
     */
    org.forgerock.opendj.ldap.schema.Schema update(SchemaBuilder builder);
  }
  /**
   * Updates the schema option  if the new value differs from the old value.
   *
   * @param <T> the schema option's type
   * @param option the schema option to update
   * @param newValue the new value for the schema option
   * @throws DirectoryException if there is any problem updating the schema
   */
  public <T> void updateSchemaOption(final Option<T> option, final T newValue) throws DirectoryException
  {
    final T oldValue = schemaNG.getOption(option);
    if (!oldValue.equals(newValue))
    {
      updateSchema(new SchemaUpdater()
      {
        @Override
        public org.forgerock.opendj.ldap.schema.Schema update(SchemaBuilder builder)
        {
          return builder.setOption(option, newValue).toSchema();
        }
      });
    }
  }
  /** Takes an exclusive lock on the schema. */
  public void exclusiveLock()
  {
    exclusiveLock.lock();
  }
  /** Releases an exclusive lock on the schema. */
  public void exclusiveUnlock()
  {
    exclusiveLock.unlock();
  }
  /**
   * Adds the provided schema file to the provided schema element definition.
   *
   * @param definition
   *            The schema element definition
   * @param schemaFile
   *            The name of the schema file to include in the definition
   * @return  The definition string of the element
   *          including the X-SCHEMA-FILE extension.
   */
  public static String addSchemaFileToElementDefinitionIfAbsent(String definition, String schemaFile)
  {
    if (schemaFile != null && !definition.contains(SCHEMA_PROPERTY_FILENAME))
    {
      int pos = definition.lastIndexOf(')');
      return definition.substring(0, pos).trim() + " " + SCHEMA_PROPERTY_FILENAME + " '" + schemaFile + "' )";
    }
    return definition;
  }
  private void switchSchema(org.forgerock.opendj.ldap.schema.Schema newSchema) throws DirectoryException
  {
    rejectSchemaWithWarnings(newSchema);
    setSchemaNG(newSchema);
  }
  private void rejectSchemaWithWarnings(org.forgerock.opendj.ldap.schema.Schema newSchema) throws DirectoryException
  {
    Collection<LocalizableMessage> warnings = newSchema.getWarnings();
    if (!warnings.isEmpty())
    {
      throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
          ERR_SCHEMA_HAS_WARNINGS.get(warnings.size(), Utils.joinAsString("; ", warnings)));
    }
  }
}
opendj-server-legacy/src/main/java/org/opends/server/types/SearchFilter.java
@@ -22,11 +22,12 @@
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 *      Portions Copyright 2013-2014 Manuel Gaupp
 */
package org.opends.server.types;
import org.forgerock.opendj.ldap.schema.AttributeType;
import static org.opends.messages.CoreMessages.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
opendj-server-legacy/src/main/java/org/opends/server/types/SortKey.java
@@ -22,10 +22,12 @@
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.types;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.schema.MatchingRule;
opendj-server-legacy/src/main/java/org/opends/server/types/SubEntry.java
@@ -22,10 +22,12 @@
 *
 *
 *      Copyright 2009-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.types;
import org.forgerock.opendj.ldap.schema.AttributeType;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
opendj-server-legacy/src/main/java/org/opends/server/types/VirtualAttribute.java
@@ -22,10 +22,12 @@
 *
 *
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2012-2015 ForgeRock AS.
 *      Portions Copyright 2012-2016 ForgeRock AS.
 */
package org.opends.server.types;
import org.forgerock.opendj.ldap.schema.AttributeType;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
opendj-server-legacy/src/main/java/org/opends/server/types/VirtualAttributeRule.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.types;
@@ -33,6 +33,7 @@
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.SearchScope;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.util.Utils;
import org.opends.server.admin.std.meta.VirtualAttributeCfgDefn;
import org.opends.server.admin.std.server.VirtualAttributeCfg;
opendj-server-legacy/src/main/java/org/opends/server/types/operation/PostOperationAddOperation.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.types.operation;
@@ -32,7 +32,7 @@
import java.util.Map;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
opendj-server-legacy/src/main/java/org/opends/server/types/operation/PostOperationCompareOperation.java
@@ -22,13 +22,13 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.types.operation;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
opendj-server-legacy/src/main/java/org/opends/server/types/operation/PostResponseAddOperation.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.types.operation;
@@ -31,6 +31,7 @@
import java.util.List;
import java.util.Map;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ByteString;
opendj-server-legacy/src/main/java/org/opends/server/types/operation/PostResponseCompareOperation.java
@@ -22,12 +22,13 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.types.operation;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ByteString;
opendj-server-legacy/src/main/java/org/opends/server/types/operation/PostSynchronizationAddOperation.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.types.operation;
@@ -32,7 +32,7 @@
import java.util.Map;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
opendj-server-legacy/src/main/java/org/opends/server/types/operation/PreOperationAddOperation.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.types.operation;
@@ -32,7 +32,7 @@
import java.util.Map;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
opendj-server-legacy/src/main/java/org/opends/server/types/operation/PreOperationCompareOperation.java
@@ -22,13 +22,13 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.types.operation;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
opendj-server-legacy/src/main/java/org/opends/server/util/AddChangeRecordEntry.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.util;
@@ -35,7 +35,7 @@
import java.util.Map;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DN;
opendj-server-legacy/src/main/java/org/opends/server/util/LDIFReader.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2012-2015 ForgeRock AS
 *      Portions Copyright 2012-2016 ForgeRock AS
 */
package org.opends.server.util;
@@ -58,7 +58,7 @@
import org.opends.server.types.AcceptRejectWarn;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeBuilder;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.Attributes;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
opendj-server-legacy/src/main/java/org/opends/server/util/LDIFWriter.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2015 ForgeRock AS.
 *      Portions Copyright 2013-2016 ForgeRock AS.
 */
package org.opends.server.util;
@@ -38,6 +38,7 @@
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.tools.makeldif.TemplateEntry;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import static org.forgerock.util.Reject.*;
opendj-server-legacy/src/main/java/org/opends/server/util/StaticUtils.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.util;
@@ -56,6 +56,7 @@
import org.opends.server.api.ClientConnection;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.ServerContext;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import com.forgerock.opendj.cli.Argument;
opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendAddOperation.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.workflowelement.localbackend;
@@ -58,7 +58,7 @@
import org.opends.server.schema.UserPasswordSyntax;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeBuilder;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.Attributes;
import org.opends.server.types.CanceledOperationException;
import org.opends.server.types.Control;
opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendBindOperation.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS.
 *      Portions Copyright 2011-2016 ForgeRock AS.
 */
package org.opends.server.workflowelement.localbackend;
@@ -34,6 +34,7 @@
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.admin.std.meta.PasswordPolicyCfgDefn;
import org.opends.server.api.AuthenticationPolicyState;
import org.opends.server.api.Backend;
opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendCompareOperation.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.workflowelement.localbackend;
@@ -35,6 +35,7 @@
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.api.AccessControlHandler;
import org.opends.server.api.Backend;
import org.opends.server.api.ClientConnection;
opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyDNOperation.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.workflowelement.localbackend;
@@ -50,7 +50,7 @@
import org.opends.server.core.ModifyDNOperationWrapper;
import org.opends.server.core.PersistentSearch;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.Attributes;
import org.opends.server.types.CanceledOperationException;
import org.opends.server.types.Control;
opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2011 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.workflowelement.localbackend;
@@ -69,7 +69,7 @@
import org.opends.server.types.AccountStatusNotificationType;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeBuilder;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.AuthenticationInfo;
import org.opends.server.types.CanceledOperationException;
import org.opends.server.types.Control;
opendj-server-legacy/src/messages/org/opends/messages/schema.properties
@@ -20,7 +20,7 @@
# CDDL HEADER END
#
#      Copyright 2006-2010 Sun Microsystems, Inc.
#      Portions Copyright 2011-2015 ForgeRock AS
#      Portions Copyright 2011-2016 ForgeRock AS
#      Portions Copyright 2012-2014 Manuel Gaupp
@@ -906,3 +906,6 @@
 characters at the end of the assertion
ERR_CERTIFICATE_MATCH_GSER_INVALID_339=An error occurred while parsing the \
 GSER String: "%s"
ERR_ATTR_TYPE_CANNOT_REGISTER_340=Attribute type could not be registered from definition: %s
ERR_SCHEMA_HAS_WARNINGS_341=There should be no warnings on the schema, \
 but instead got %d warnings: %s
opendj-server-legacy/src/test/java/org/opends/server/ServerContextBuilder.java
@@ -21,7 +21,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2014-2015 ForgeRock AS.
 *      Copyright 2014-2016 ForgeRock AS.
 */
package org.opends.server;
@@ -30,11 +30,8 @@
import java.io.File;
import org.forgerock.opendj.config.server.ServerManagementContext;
import org.forgerock.opendj.ldap.schema.Schema;
import org.forgerock.opendj.ldap.schema.SchemaBuilder;
import org.opends.server.core.ConfigurationBootstrapper;
import org.opends.server.core.ServerContext;
import org.opends.server.schema.SchemaUpdater;
import org.opends.server.types.DirectoryEnvironmentConfig;
import org.opends.server.types.InitializationException;
@@ -72,9 +69,10 @@
    return this;
  }
  public ServerContextBuilder schemaNG(Schema schema)
  public ServerContextBuilder schema(org.opends.server.types.Schema schema)
  {
    when(serverContext.getSchemaNG()).thenReturn(schema);
    when(serverContext.getSchema()).thenReturn(schema);
    when(serverContext.getSchemaNG()).thenReturn(schema.getSchemaNG());
    return this;
  }
@@ -85,12 +83,6 @@
    return this;
  }
  public ServerContextBuilder schemaUpdater(SchemaUpdater updater)
  {
    when(serverContext.getSchemaUpdater()).thenReturn(updater);
    return this;
  }
  /**
   * Ensure that configuration is fully bootstrapped. Only use when necessary as
   * it will impact test performance.
@@ -98,38 +90,9 @@
  public ServerContextBuilder withConfigurationBootstrapped()
      throws InitializationException
  {
    if (serverContext.getSchemaUpdater() == null) {
      throw new RuntimeException("You must set a non-null schema updater to bootstrap configuration.");
    }
    final ServerManagementContext serverManagementContext =
        ConfigurationBootstrapper.bootstrap(serverContext);
    when(serverContext.getServerManagementContext()).thenReturn(
        serverManagementContext);
    final ServerManagementContext serverManagementContext = ConfigurationBootstrapper.bootstrap(serverContext);
    when(serverContext.getServerManagementContext()).thenReturn(serverManagementContext);
    return this;
  }
  /** A mock for schema updater. */
  public static final class MockSchemaUpdater implements SchemaUpdater
  {
    private Schema schema;
    public MockSchemaUpdater(Schema schema)
    {
      this.schema = schema;
    }
    @Override
    public boolean updateSchema(Schema schema)
    {
      this.schema = schema;
      return true;
    }
    @Override
    public SchemaBuilder getSchemaBuilder()
    {
      return new SchemaBuilder(schema);
    }
  }
}
opendj-server-legacy/src/test/java/org/opends/server/TestCaseUtils.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 *      Portions Copyright 2013 Manuel Gaupp
 */
package org.opends.server;
@@ -214,16 +214,7 @@
  public static void startFakeServer() throws Exception
  {
    schemaBeforeStartingFakeServer = DirectoryServer.getSchema();
    DirectoryServer.setSchema(initializeInMemory(new Schema()));
  }
  private static Schema initializeInMemory(final Schema schema) throws Exception
  {
    for (AttributeType attributeType : AttributeTypeConstants.ALL)
    {
      schema.registerAttributeType(attributeType, true);
    }
    return schema;
    DirectoryServer.setSchema(new Schema(org.forgerock.opendj.ldap.schema.Schema.getDefaultSchema()));
  }
  /**
opendj-server-legacy/src/test/java/org/opends/server/admin/AttributeTypePropertyDefinitionTest.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Portions Copyright 2015 ForgeRock AS.
 *      Portions Copyright 2015-2016 ForgeRock AS.
 */
package org.opends.server.admin;
@@ -32,7 +32,7 @@
import org.opends.server.DirectoryServerTestCase;
import org.opends.server.admin.std.meta.RootCfgDefn;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
opendj-server-legacy/src/test/java/org/opends/server/admin/TestChildCfg.java
@@ -22,19 +22,16 @@
 *
 *
 *      Copyright 2007-2008 Sun Microsystems, Inc.
 *      Portions copyright 2015-2016 ForgeRock AS
 */
package org.opends.server.admin;
import java.util.SortedSet;
import org.opends.server.admin.Configuration;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DN;
/**
 * A server-side interface for querying Test Child settings.
 * <p>
opendj-server-legacy/src/test/java/org/opends/server/admin/TestChildCfgClient.java
@@ -22,22 +22,19 @@
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Portions copyright 2015-2016 ForgeRock AS
 */
package org.opends.server.admin;
import java.util.Collection;
import java.util.SortedSet;
import org.opends.server.admin.ConfigurationClient;
import org.opends.server.admin.PropertyException;
import org.opends.server.admin.ManagedObjectDefinition;
import org.opends.server.admin.TestChildCfg;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DN;
/**
 * A client-side interface for reading and modifying Test Child
 * settings.
opendj-server-legacy/src/test/java/org/opends/server/admin/TestChildCfgDefn.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2007-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2015 ForgeRock AS.
 *      Portions Copyright 2015-2016 ForgeRock AS.
 */
package org.opends.server.admin;
@@ -56,7 +56,7 @@
import org.opends.server.admin.std.server.ConnectionHandlerCfg;
import org.opends.server.admin.server.ServerManagedObject;
import org.opends.server.admin.TestChildCfg;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DN;
opendj-server-legacy/src/test/java/org/opends/server/admin/TestParentCfg.java
@@ -22,23 +22,19 @@
 *
 *
 *      Copyright 2007-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.admin;
import java.util.SortedSet;
import org.opends.server.admin.Configuration;
import org.opends.server.admin.server.ConfigurationAddListener;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.server.ConfigurationDeleteListener;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DN;
/**
 * A server-side interface for querying Test Parent settings.
 * <p>
opendj-server-legacy/src/test/java/org/opends/server/admin/TestParentCfgClient.java
@@ -22,11 +22,10 @@
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Portions copyright 2015-2016 ForgeRock AS
 */
package org.opends.server.admin;
import java.util.Collection;
import java.util.SortedSet;
import org.opends.server.admin.client.AuthorizationException;
@@ -40,11 +39,9 @@
import org.opends.server.admin.DefinitionDecodingException;
import org.opends.server.admin.ManagedObjectDefinition;
import org.opends.server.admin.ManagedObjectNotFoundException;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DN;
/**
 * A client-side interface for reading and modifying Test Parent
 * settings.
opendj-server-legacy/src/test/java/org/opends/server/admin/TestParentCfgDefn.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2007-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.admin;
@@ -60,7 +60,7 @@
import org.opends.server.admin.server.ServerManagedObject;
import org.opends.server.admin.UndefinedDefaultBehaviorProvider;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DN;
opendj-server-legacy/src/test/java/org/opends/server/admin/ValidateConfigDefinitionsTest.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.admin;
@@ -38,7 +38,7 @@
import org.opends.server.DirectoryServerTestCase;
import org.opends.server.TestCaseUtils;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.ObjectClass;
import org.opends.server.types.Schema;
import org.testng.Assert;
@@ -188,13 +188,14 @@
    Schema schema = DirectoryServer.getSchema();
    AttributeType attrType = schema.getAttributeType(ldapAttrName.toLowerCase());
    // LDAP attribute exists
    if (attrType == null) {
    if (!schema.hasAttributeType(ldapAttrName.toLowerCase()))
    {
      errors.append(propName + " property on config object " + objName + " is declared" +
               " to use ldap attribute " + ldapAttrName + ", but this attribute is not in the schema ").append(EOL + EOL);
    } else {
      AttributeType attrType = schema.getAttributeType(ldapAttrName.toLowerCase());
      // LDAP attribute is multivalued if the property is multivalued
      if (propDef.hasOption(PropertyOption.MULTI_VALUED) && attrType.isSingleValue()) {
opendj-server-legacy/src/test/java/org/opends/server/admin/client/spi/PropertySetTest.java
old mode 100755 new mode 100644
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.admin.client.spi;
opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/TargetAttrTestCase.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2012-2015 ForgeRock AS
 *      Portions Copyright 2012-2016 ForgeRock AS
 */
package org.opends.server.authorization.dseecompat;
@@ -33,7 +33,7 @@
import java.util.Map;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
opendj-server-legacy/src/test/java/org/opends/server/backends/SchemaBackendTestCase.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2015 ForgeRock AS.
 *      Portions Copyright 2013-2016 ForgeRock AS.
 */
package org.opends.server.backends;
@@ -43,6 +43,7 @@
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.forgerock.opendj.ldap.schema.Schema;
import org.forgerock.opendj.ldap.schema.SchemaBuilder;
@@ -58,7 +59,17 @@
import org.opends.server.protocols.internal.SearchRequest;
import org.opends.server.schema.SchemaConstants;
import org.opends.server.tools.LDAPModify;
import org.opends.server.types.*;
import org.opends.server.types.DITContentRule;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
import org.opends.server.types.ExistingFileBehavior;
import org.opends.server.types.InitializationException;
import org.opends.server.types.LDIFExportConfig;
import org.opends.server.types.LDIFImportConfig;
import org.opends.server.types.MatchingRuleUse;
import org.opends.server.types.ObjectClass;
import org.opends.server.types.SearchFilter;
import org.opends.server.util.CollectionUtils;
import org.opends.server.util.ServerConstants;
import org.testng.annotations.BeforeClass;
@@ -3169,10 +3180,15 @@
              "X-ORIGIN 'SchemaBackendTestCase' )");
    int ruleID = 999001;
    assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
    assertSchemaHasDITStructureRule(ruleID, false);
    assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0);
    assertTrue(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
    assertSchemaHasDITStructureRule(ruleID, true);
  }
  private void assertSchemaHasDITStructureRule(int ruleID, boolean expected)
  {
    assertEquals(DirectoryServer.getSchema().getDITStructureRulesByID().containsKey(ruleID), expected);
  }
  /**
@@ -3215,10 +3231,10 @@
              "X-ORIGIN 'SchemaBackendTestCase' )");
    int ruleID = 999002;
    assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
    assertSchemaHasDITStructureRule(ruleID, false);
    assertEquals(runModify(argsPermissive(), ldif, System.err), 0);
    assertTrue(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
    assertSchemaHasDITStructureRule(ruleID, true);
  }
  /**
@@ -3255,14 +3271,14 @@
              "X-ORIGIN 'SchemaBackendTestCase' )");
    int ruleID = 999010;
    assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
    assertSchemaHasDITStructureRule(ruleID, false);
    File schemaFile = new File(SchemaConfigManager.getSchemaDirectoryPath(),
                               "98-schema-test-dsr.ldif");
    assertFalse(schemaFile.exists());
    assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0);
    assertTrue(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
    assertSchemaHasDITStructureRule(ruleID, true);
    assertTrue(schemaFile.exists());
  }
@@ -3314,10 +3330,10 @@
              "X-ORIGIN 'SchemaBackendTestCase' )");
    int ruleID = 999003;
    assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
    assertSchemaHasDITStructureRule(ruleID, false);
    assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0);
    assertTrue(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
    assertSchemaHasDITStructureRule(ruleID, true);
  }
  /**
@@ -3340,10 +3356,10 @@
              "X-ORIGIN 'SchemaBackendTestCase' )");
    int ruleID = 999004;
    assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
    assertSchemaHasDITStructureRule(ruleID, false);
    assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
    assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
    assertSchemaHasDITStructureRule(ruleID, false);
  }
  /**
@@ -3377,10 +3393,10 @@
              "X-ORIGIN 'SchemaBackendTestCase' )");
    int ruleID = 999005;
    assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
    assertSchemaHasDITStructureRule(ruleID, false);
    assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
    assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
    assertSchemaHasDITStructureRule(ruleID, false);
  }
  /**
@@ -3499,10 +3515,10 @@
              "X-ORIGIN 'SchemaBackendTestCase' )");
    int ruleID = 999006;
    assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
    assertSchemaHasDITStructureRule(ruleID, false);
    assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0);
    assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
    assertSchemaHasDITStructureRule(ruleID, false);
  }
  /**
@@ -3556,10 +3572,10 @@
              "X-ORIGIN 'SchemaBackendTestCase' )");
    int ruleID = 999007;
    assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
    assertSchemaHasDITStructureRule(ruleID, false);
    assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
    assertTrue(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
    assertSchemaHasDITStructureRule(ruleID, true);
    ldif = toLdif(
         "dn: cn=schema",
@@ -3575,7 +3591,7 @@
              "X-ORIGIN 'SchemaBackendTestCase' )");
    assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0);
    assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
    assertSchemaHasDITStructureRule(ruleID, false);
  }
  private MatchingRule getMatchingRule(String name, String oid, boolean isObsolete)
@@ -3612,7 +3628,7 @@
              "NAME 'testAddMRUSuccessful' APPLIES cn " +
              "X-ORIGIN 'SchemaBackendTestCase' )");
    assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule));
    assertSchemaDoesNotHaveMatchingRuleUse(matchingRule);
    assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0);
@@ -3644,7 +3660,7 @@
              "X-SCHEMA-FILE '98-schema-test-mru.ldif' " +
              "X-ORIGIN 'SchemaBackendTestCase' )");
    assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule));
    assertSchemaDoesNotHaveMatchingRuleUse(matchingRule);
    File schemaFile = new File(SchemaConfigManager.getSchemaDirectoryPath(),
                               "98-schema-test-mru.ldif");
@@ -3688,7 +3704,7 @@
              "NAME 'testReplaceMRUSuccessful' APPLIES ( cn $ sn ) " +
              "X-ORIGIN 'SchemaBackendTestCase' )");
    assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule));
    assertSchemaDoesNotHaveMatchingRuleUse(matchingRule);
    assertEquals(runModify(argsPermissive(), ldif, System.err), 0);
@@ -3730,7 +3746,7 @@
              "NAME 'testRemoveAndAddMRU' APPLIES ( cn $ sn ) " +
              "X-ORIGIN 'SchemaBackendTestCase' )");
    assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule));
    assertSchemaDoesNotHaveMatchingRuleUse(matchingRule);
    assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0);
@@ -3769,7 +3785,7 @@
              "NAME 'testAddMRUMRConflict2' APPLIES sn " +
              "X-ORIGIN 'SchemaBackendTestCase' )");
    assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule));
    assertSchemaDoesNotHaveMatchingRuleUse(matchingRule);
    assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
@@ -3822,7 +3838,7 @@
              "APPLIES xxxundefinedxxx " +
              "X-ORIGIN 'SchemaBackendTestCase' )");
    assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule));
    assertSchemaDoesNotHaveMatchingRuleUse(matchingRule);
    assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
  }
@@ -3850,11 +3866,16 @@
              "APPLIES ( cn $ xxxundefinedxxx ) " +
              "X-ORIGIN 'SchemaBackendTestCase' )");
    assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule));
    assertSchemaDoesNotHaveMatchingRuleUse(matchingRule);
    assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
  }
  private void assertSchemaDoesNotHaveMatchingRuleUse(MatchingRule matchingRule)
  {
    assertFalse(DirectoryServer.getSchema().getMatchingRuleUses().containsKey(matchingRule));
  }
  /**
   * Tests the behavior of the schema backend when attempting to add a new
   * matching rule whose matching rule is OBSOLETE.
@@ -3876,7 +3897,7 @@
              "NAME 'testAddMatchingRuleUseObsoleteMatchingRule' " +
              "APPLIES cn X-ORIGIN 'SchemaBackendTestCase' )");
    assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule));
    assertSchemaDoesNotHaveMatchingRuleUse(matchingRule);
    assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
  }
@@ -3907,7 +3928,7 @@
              "APPLIES testAddMRUObsoleteAT " +
              "X-ORIGIN 'SchemaBackendTestCase' )");
    assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule));
    assertSchemaDoesNotHaveMatchingRuleUse(matchingRule);
    assertNotEquals(runModify(argsNotPermissive(), ldif), 0);
  }
@@ -3964,7 +3985,7 @@
              "NAME 'testRemoveMRUSuccessful' APPLIES cn " +
              "X-ORIGIN 'SchemaBackendTestCase' )");
    assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule));
    assertSchemaDoesNotHaveMatchingRuleUse(matchingRule);
    assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0);
@@ -4236,7 +4257,8 @@
              "X-ORIGIN 'SchemaBackendTestCase' )");
    String attrName = "testmatchingruleusematchingruleat1";
    assertNull(DirectoryServer.getSchema().getAttributeType(attrName));
    assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName));
    assertEquals(runModify(argsNotPermissive(), ldif, System.err), 20);
  }
@@ -4272,7 +4294,7 @@
         "dn: cn=schema",
         "changetype: modify",
         "add: objectClasses",
         "objectClasses: ( testissue1318oc1-oid NAME 'testIssue1381OC1' )",
         "objectClasses: ( testissue1318oc1-oid NAME 'testIssue1381OC1')",
         "",
         "dn: cn=schema",
         "changetype: modify",
@@ -4280,7 +4302,7 @@
         "objectClasses: ( testissue1318oc1-oid NAME 'testIssue1381OC1' )",
         "-",
         "add: attributeTypes",
         "attributeTypes: ( testissue1318at-oid NAME 'testIssue1381AT' )",
         "attributeTypes: ( testissue1318at-oid NAME 'testIssue1381AT' SUP name)",
         "-",
         "add: objectClasses",
         "objectClasses: ( testissue1318oc2-oid NAME 'testIssue1381OC2' " +
opendj-server-legacy/src/test/java/org/opends/server/backends/pluggable/PluggableBackendImplTestCase.java
@@ -21,7 +21,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2015 ForgeRock AS
 *      Copyright 2015-2016 ForgeRock AS
 */
package org.opends.server.backends.pluggable;
@@ -79,10 +79,11 @@
import org.opends.server.core.ModifyDNOperation;
import org.opends.server.core.ModifyOperation;
import org.opends.server.core.SearchOperation;
import org.opends.server.core.ServerContext;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.protocols.internal.InternalSearchOperation;
import org.opends.server.protocols.internal.SearchRequest;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.BackupConfig;
import org.opends.server.types.BackupDirectory;
import org.opends.server.types.DN;
@@ -1144,8 +1145,10 @@
    when(backendCfg.listBackendIndexes()).thenReturn(new String[0]);
    when(backendCfg.listBackendVLVIndexes()).thenReturn(new String[0]);
    final Storage storage = backend.configureStorage(backendCfg, DirectoryServer.getInstance().getServerContext());
    final RootContainer readOnlyContainer = new RootContainer(backend.getBackendID(), storage, backendCfg);
    ServerContext serverContext = DirectoryServer.getInstance().getServerContext();
    final Storage storage = backend.configureStorage(backendCfg, serverContext);
    final RootContainer readOnlyContainer =
        new RootContainer(backend.getBackendID(), serverContext, storage, backendCfg);
    // Put backend offline so that export LDIF open read-only container
    backend.finalizeBackend();
opendj-server-legacy/src/test/java/org/opends/server/backends/pluggable/TestDnKeyFormat.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.backends.pluggable;
@@ -35,6 +35,7 @@
import org.opends.server.DirectoryServerTestCase;
import org.opends.server.TestCaseUtils;
import org.opends.server.core.DirectoryServer;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import org.opends.server.util.LDIFReader;
import org.opends.server.util.StaticUtils;
opendj-server-legacy/src/test/java/org/opends/server/controls/MatchedValuesControlTest.java
@@ -23,7 +23,7 @@
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2014 Manuel Gaupp
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.controls;
@@ -31,13 +31,10 @@
import java.util.ArrayList;
import java.util.List;
import org.opends.server.api.MatchingRuleFactory;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.core.DirectoryServer;
import org.opends.server.schema.BooleanEqualityMatchingRuleFactory;
import org.opends.server.schema.DistinguishedNameEqualityMatchingRuleFactory;
import org.opends.server.schema.IntegerEqualityMatchingRuleFactory;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ByteStringBuilder;
import org.forgerock.opendj.io.ASN1Writer;
@@ -48,11 +45,9 @@
import static org.testng.Assert.*;
/**
 * Test MatchedValuesControl.
 */
public class MatchedValuesControlTest
    extends ControlsTestCase
/** Test MatchedValuesControl. */
@SuppressWarnings("javadoc")
public class MatchedValuesControlTest extends ControlsTestCase
{
  /**
@@ -673,24 +668,15 @@
    }
  }
  @DataProvider(name = "extensibleMatchFilterData")
  public Object[][] createExtensibleMatchFilterData() throws Exception
  @DataProvider
  public Object[][] extensibleMatchFilterData() throws Exception
  {
    MatchingRuleFactory<?> factory = new BooleanEqualityMatchingRuleFactory();
    factory.initializeMatchingRule(null);
    MatchingRule booleanEquality = factory.getMatchingRules().iterator().next();
    factory = new IntegerEqualityMatchingRuleFactory();
    factory.initializeMatchingRule(null);
    MatchingRule integerEquality = factory.getMatchingRules().iterator().next();
    factory = new DistinguishedNameEqualityMatchingRuleFactory();
    factory.initializeMatchingRule(null);
    MatchingRule distinguishedEquality = factory.getMatchingRules().iterator().next();
    return new Object[][]
    {
    { "description", booleanEquality, "description" },
    { "objectclass", integerEquality ,"top" },
    { "fakeobjecttype", distinguishedEquality, "fakevalue" }, };
      { "description", CoreSchema.getBooleanMatchingRule(), "description" },
      { "objectclass", CoreSchema.getIntegerMatchingRule(), "top" },
      { "fakeobjecttype", CoreSchema.getDistinguishedNameMatchingRule(), "fakevalue" },
    };
  }
  /**
opendj-server-legacy/src/test/java/org/opends/server/controls/ServerSideSortControlTestCase.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.controls;
@@ -38,7 +38,7 @@
import org.opends.server.protocols.internal.InternalSearchOperation;
import org.opends.server.protocols.internal.SearchRequest;
import org.opends.server.protocols.ldap.LDAPControl;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.Control;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
opendj-server-legacy/src/test/java/org/opends/server/controls/VLVControlTestCase.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.controls;
@@ -43,6 +43,7 @@
import org.opends.server.protocols.internal.SearchRequest;
import org.opends.server.protocols.ldap.LDAPControl;
import org.opends.server.protocols.ldap.LDAPResultCode;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
opendj-server-legacy/src/test/java/org/opends/server/core/AddOperationTestCase.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS.
 *      Portions Copyright 2011-2016 ForgeRock AS.
 */
package org.opends.server.core;
@@ -50,7 +50,7 @@
import org.opends.server.tools.LDAPReader;
import org.opends.server.tools.LDAPWriter;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.Attributes;
import org.opends.server.types.CancelRequest;
import org.opends.server.types.CancelResult;
opendj-server-legacy/src/test/java/org/opends/server/core/PasswordPolicyTestCase.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.core;
@@ -45,6 +45,7 @@
import org.opends.server.config.ConfigEntry;
import org.opends.server.schema.UserPasswordSyntax;
import org.opends.server.tools.LDAPModify;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import org.opends.server.util.TimeThread;
opendj-server-legacy/src/test/java/org/opends/server/core/SchemaHandlerTestCase.java
@@ -21,7 +21,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2014-2015 ForgeRock AS.
 *      Copyright 2014-2016 ForgeRock AS.
 */
package org.opends.server.core;
@@ -30,12 +30,8 @@
import java.io.File;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.schema.Schema;
import org.opends.server.ServerContextBuilder.MockSchemaUpdater;
import org.opends.server.TestCaseUtils;
import org.opends.server.schema.SchemaUpdater;
import org.opends.server.types.InitializationException;
import org.testng.annotations.Test;
@SuppressWarnings("javadoc")
@@ -47,12 +43,8 @@
  @Test
  public void testSchemaInitialization() throws Exception
  {
    MockSchemaUpdater schemaUpdater = new MockSchemaUpdater(Schema.getEmptySchema());
    initializeSchemaHandler(schemaUpdater);
    assertThat(schemaUpdater.getSchemaBuilder()).isNotNull();
    Schema schema = schemaUpdater.getSchemaBuilder().toSchema();
    org.opends.server.types.Schema schema = new org.opends.server.types.Schema(Schema.getCoreSchema());
    initializeSchemaHandler(schema);
    assertThat(schema.getMatchingRules()).isNotEmpty(); // some matching rules defined
    schema.getSyntax(DIRECTORY_STRING_SYNTAX_OID);
@@ -61,15 +53,14 @@
    schema.getObjectClass("changeLogEntry"); // from file 03-changelog.ldif
  }
  private void initializeSchemaHandler(SchemaUpdater updater) throws InitializationException, ConfigException
  private void initializeSchemaHandler(org.opends.server.types.Schema schema) throws Exception
  {
    final ServerContext serverContext = aServerContext().
        schemaDirectory(new File(TestCaseUtils.getBuildRoot(), "resource/schema")).
        configFile(TestCaseUtils.getTestResource("config-small.ldif")).
        schemaUpdater(updater).
        withConfigurationBootstrapped().
        build();
    final ServerContext serverContext = aServerContext()
        .schemaDirectory(new File(TestCaseUtils.getBuildRoot(), "resource/schema"))
        .configFile(TestCaseUtils.getTestResource("config-small.ldif"))
        .withConfigurationBootstrapped()
        .schema(schema)
        .build();
    SchemaHandler schemaHandler = new SchemaHandler();
    schemaHandler.initialize(serverContext);
opendj-server-legacy/src/test/java/org/opends/server/core/SubentryManagerTestCase.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2009-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.core;
@@ -44,7 +44,7 @@
import org.opends.server.tools.LDAPDelete;
import org.opends.server.tools.LDAPModify;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
opendj-server-legacy/src/test/java/org/opends/server/core/SubentryPasswordPolicyTestCase.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS.
 *      Portions Copyright 2011-2016 ForgeRock AS.
 */
package org.opends.server.core;
@@ -34,7 +34,7 @@
import org.opends.server.TestCaseUtils;
import org.opends.server.api.AuthenticationPolicy;
import org.opends.server.api.PasswordValidator;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
import org.opends.server.util.StaticUtils;
@@ -288,9 +288,7 @@
    assertEquals(policy.getLockoutDuration(), 300);
    assertEquals(policy.getLockoutFailureCount(), 3);
    assertEquals(policy.isForceChangeOnReset(), true);
    assertTrue(policy.getPasswordAttribute(
            ).getPrimaryName().equalsIgnoreCase(
            "authPassword"));
    assertTrue(policy.getPasswordAttribute().getNameOrOID().equalsIgnoreCase("authPassword"));
    assertEquals(policy.getMinPasswordAge(), 600);
    assertEquals(policy.getMaxPasswordAge(), 2147483647);
    assertEquals(policy.getPasswordHistoryCount(), 5);
opendj-server-legacy/src/test/java/org/opends/server/core/TestModifyDNOperation.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS.
 *      Portions Copyright 2011-2016 ForgeRock AS.
 *      Portions copyright 2013 Manuel Gaupp
 */
package org.opends.server.core;
@@ -40,6 +40,7 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.TestCaseUtils;
import org.opends.server.controls.ProxiedAuthV1Control;
import org.opends.server.controls.ProxiedAuthV2Control;
@@ -56,7 +57,6 @@
import org.opends.server.tools.LDAPModify;
import org.opends.server.tools.LDAPWriter;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.CancelRequest;
import org.opends.server.types.CancelResult;
import org.opends.server.types.Control;
opendj-server-legacy/src/test/java/org/opends/server/extensions/EntityTagVirtualAttributeProviderTestCase.java
@@ -21,7 +21,7 @@
 * CDDL HEADER END
 *
 *
 *      Portions Copyright 2012-2015 ForgeRock AS
 *      Portions Copyright 2012-2016 ForgeRock AS
 */
package org.opends.server.extensions;
@@ -60,7 +60,7 @@
import org.opends.server.protocols.internal.SearchRequest;
import org.opends.server.protocols.ldap.LDAPFilter;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.Attributes;
import org.opends.server.types.Control;
import org.opends.server.types.DN;
opendj-server-legacy/src/test/java/org/opends/server/extensions/EntryDNVirtualAttributeProviderTestCase.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.extensions;
@@ -33,6 +33,7 @@
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ConditionResult;
import org.forgerock.opendj.ldap.SearchScope;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.TestCaseUtils;
import org.opends.server.admin.std.meta.VirtualAttributeCfgDefn;
import org.opends.server.api.VirtualAttributeProvider;
@@ -41,7 +42,6 @@
import org.opends.server.protocols.internal.SearchRequest;
import org.opends.server.protocols.ldap.LDAPControl;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
import org.opends.server.types.SearchFilter;
opendj-server-legacy/src/test/java/org/opends/server/extensions/EntryUUIDVirtualAttributeProviderTestCase.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.extensions;
@@ -32,6 +32,7 @@
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.SearchScope;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.TestCaseUtils;
import org.opends.server.admin.std.meta.VirtualAttributeCfgDefn;
import org.opends.server.core.DirectoryServer;
@@ -39,7 +40,6 @@
import org.opends.server.protocols.internal.SearchRequest;
import org.opends.server.protocols.ldap.LDAPControl;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
import org.opends.server.types.SearchFilter;
opendj-server-legacy/src/test/java/org/opends/server/extensions/ExactMatchIdentityMapperTestCase.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.extensions;
@@ -43,6 +43,7 @@
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.protocols.ldap.LDAPAttribute;
import org.opends.server.protocols.ldap.LDAPModification;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
opendj-server-legacy/src/test/java/org/opends/server/extensions/ExtensionTestUtils.java
@@ -21,7 +21,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2013-2014 ForgeRock AS
 *      Copyright 2013-2016 ForgeRock AS
 */
package org.opends.server.extensions;
@@ -29,7 +29,7 @@
import org.opends.server.protocols.internal.InternalSearchOperation;
import org.opends.server.protocols.internal.SearchRequest;
import org.opends.server.schema.SchemaConstants;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
@@ -37,9 +37,7 @@
import static org.opends.server.protocols.internal.Requests.*;
import static org.testng.Assert.*;
/**
 * Utility class providing common code for extensions tests.
 */
/** Utility class providing common code for extensions tests. */
@SuppressWarnings("javadoc")
class ExtensionTestUtils
{
opendj-server-legacy/src/test/java/org/opends/server/extensions/GoverningStructureRuleVirtualAttributeProviderTestCase.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2009 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.extensions;
@@ -40,7 +40,7 @@
import org.opends.server.protocols.internal.SearchRequest;
import org.opends.server.protocols.ldap.LDAPControl;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
import org.opends.server.types.SearchFilter;
opendj-server-legacy/src/test/java/org/opends/server/extensions/HasSubordinatesVirtualAttributeProviderTestCase.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2015 ForgeRock AS
 *      Portions Copyright 2013-2016 ForgeRock AS
 */
package org.opends.server.extensions;
@@ -39,7 +39,7 @@
import org.opends.server.protocols.internal.SearchRequest;
import org.opends.server.protocols.ldap.LDAPControl;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
import org.testng.annotations.BeforeClass;
opendj-server-legacy/src/test/java/org/opends/server/extensions/IsMemberOfVirtualAttributeProviderTestCase.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.extensions;
@@ -42,7 +42,7 @@
import org.opends.server.protocols.internal.InternalSearchOperation;
import org.opends.server.protocols.internal.SearchRequest;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
import org.opends.server.types.SearchFilter;
opendj-server-legacy/src/test/java/org/opends/server/extensions/LDAPPassThroughAuthenticationPolicyTestCase.java
@@ -21,7 +21,7 @@
 * CDDL HEADER END
 *
 *
 *      Portions Copyright 2011-2015 ForgeRock AS.
 *      Portions Copyright 2011-2016 ForgeRock AS.
 */
package org.opends.server.extensions;
@@ -57,6 +57,7 @@
import org.opends.server.schema.UserPasswordSyntax;
import org.opends.server.tools.LDAPReader;
import org.opends.server.tools.LDAPWriter;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import org.opends.server.util.StaticUtils;
import org.opends.server.util.TimeThread;
opendj-server-legacy/src/test/java/org/opends/server/extensions/NumSubordinatesVirtualAttributeProviderTestCase.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.extensions;
@@ -37,7 +37,7 @@
import org.opends.server.protocols.internal.SearchRequest;
import org.opends.server.protocols.ldap.LDAPControl;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
import org.testng.annotations.BeforeClass;
opendj-server-legacy/src/test/java/org/opends/server/extensions/PasswordModifyExtendedOperationTestCase.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2015 ForgeRock AS.
 *      Portions Copyright 2013-2016 ForgeRock AS.
 */
package org.opends.server.extensions;
@@ -43,6 +43,7 @@
import org.opends.server.core.*;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.tools.LDAPPasswordModify;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
opendj-server-legacy/src/test/java/org/opends/server/extensions/StructuralObjectClassVirtualAttributeProviderTestCase.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2009 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.extensions;
@@ -38,7 +38,7 @@
import org.opends.server.protocols.internal.SearchRequest;
import org.opends.server.protocols.ldap.LDAPControl;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
import org.opends.server.types.SearchFilter;
opendj-server-legacy/src/test/java/org/opends/server/extensions/SubjectAttributeToUserAttributeCertificateMapperTestCase.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Portions Copyright 2012-2015 ForgeRock AS
 *      Portions Copyright 2012-2016 ForgeRock AS
 *      Portions Copyright 2013 Manuel Gaupp
 */
package org.opends.server.extensions;
@@ -49,7 +49,7 @@
import org.opends.server.tools.LDAPSearch;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeBuilder;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.Attributes;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
opendj-server-legacy/src/test/java/org/opends/server/extensions/SubjectDNToUserAttributeCertificateMapperTestCase.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Portions Copyright 2012-2015 ForgeRock AS
 *      Portions Copyright 2012-2016 ForgeRock AS
 */
package org.opends.server.extensions;
@@ -48,7 +48,7 @@
import org.opends.server.tools.LDAPSearch;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeBuilder;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.Attributes;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
opendj-server-legacy/src/test/java/org/opends/server/extensions/SubschemaSubentryVirtualAttributeProviderTestCase.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.extensions;
@@ -38,7 +38,7 @@
import org.opends.server.protocols.internal.SearchRequest;
import org.opends.server.protocols.ldap.LDAPControl;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
import org.opends.server.types.SearchFilter;
opendj-server-legacy/src/test/java/org/opends/server/extensions/UserDefinedVirtualAttributeProviderTestCase.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2012-2015 ForgeRock AS
 *      Portions Copyright 2012-2016 ForgeRock AS
 */
package org.opends.server.extensions;
@@ -40,7 +40,7 @@
import org.opends.server.protocols.internal.SearchRequest;
import org.opends.server.tools.LDAPModify;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.VirtualAttributeRule;
import org.testng.annotations.BeforeClass;
opendj-server-legacy/src/test/java/org/opends/server/extensions/VirtualStaticGroupTestCase.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2012-2015 ForgeRock AS
 *      Portions Copyright 2012-2016 ForgeRock AS
 */
package org.opends.server.extensions;
@@ -41,6 +41,7 @@
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.protocols.internal.InternalSearchOperation;
import org.opends.server.protocols.internal.SearchRequest;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
opendj-server-legacy/src/test/java/org/opends/server/plugins/DelayPreOpPlugin.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.plugins;
@@ -37,8 +37,8 @@
import org.forgerock.opendj.io.ASN1;
import org.forgerock.opendj.io.ASN1Reader;
import org.forgerock.opendj.io.ASN1Writer;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.admin.std.server.PluginCfg;
import org.opends.server.api.plugin.DirectoryServerPlugin;
import org.opends.server.api.plugin.PluginResult;
opendj-server-legacy/src/test/java/org/opends/server/plugins/EntryUUIDPluginTestCase.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.plugins;
@@ -41,7 +41,7 @@
import org.opends.server.admin.std.server.EntryUUIDPluginCfg;
import org.opends.server.api.plugin.PluginType;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
import org.opends.server.types.LDIFImportConfig;
opendj-server-legacy/src/test/java/org/opends/server/plugins/LastModPluginTestCase.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.plugins;
@@ -46,7 +46,7 @@
import org.opends.server.core.ModifyDNOperation;
import org.opends.server.core.ModifyOperation;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.Attributes;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryConfig;
opendj-server-legacy/src/test/java/org/opends/server/plugins/ReferentialIntegrityPluginTestCase.java
@@ -23,7 +23,7 @@
 *
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 *      Portions copyright 2011 profiq s.r.o.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.plugins;
@@ -36,6 +36,7 @@
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.TestCaseUtils;
import org.opends.server.admin.server.AdminTestCaseUtils;
import org.opends.server.admin.std.meta.ReferentialIntegrityPluginCfgDefn;
@@ -47,7 +48,6 @@
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.protocols.internal.InternalSearchOperation;
import org.opends.server.protocols.internal.SearchRequest;
import org.opends.server.types.AttributeType;
import org.opends.server.types.Attributes;
import org.opends.server.types.Control;
import org.opends.server.types.DN;
opendj-server-legacy/src/test/java/org/opends/server/plugins/UniqueAttributePluginTestCase.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.plugins;
@@ -42,6 +42,7 @@
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.ModifyDNOperation;
import org.opends.server.core.ModifyOperation;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import org.testng.annotations.*;
opendj-server-legacy/src/test/java/org/opends/server/plugins/UpdatePreOpPlugin.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.plugins;
@@ -38,7 +38,7 @@
import org.opends.server.api.plugin.PluginResult;
import org.opends.server.api.plugin.PluginType;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Modification;
import org.opends.server.types.ObjectClass;
opendj-server-legacy/src/test/java/org/opends/server/protocols/ldap/TestAddResponseProtocolOp.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.protocols.ldap;
@@ -43,7 +43,7 @@
import org.opends.server.DirectoryServerTestCase;
import org.opends.server.TestCaseUtils;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.LDAPException;
import org.opends.server.types.RDN;
opendj-server-legacy/src/test/java/org/opends/server/protocols/ldap/TestCompareResponseProtocolOp.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.protocols.ldap;
@@ -36,9 +36,9 @@
import org.forgerock.opendj.io.ASN1Writer;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ByteStringBuilder;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.TestCaseUtils;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.LDAPException;
import org.opends.server.types.RDN;
opendj-server-legacy/src/test/java/org/opends/server/protocols/ldap/TestDeleteResponseProtocolOp.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.protocols.ldap;
@@ -36,9 +36,9 @@
import org.forgerock.opendj.io.ASN1Writer;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ByteStringBuilder;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.TestCaseUtils;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.LDAPException;
import org.opends.server.types.RDN;
opendj-server-legacy/src/test/java/org/opends/server/protocols/ldap/TestLDAPConnectionHandler.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2012-2015 ForgeRock AS.
 *      Portions Copyright 2012-2016 ForgeRock AS.
 */
package org.opends.server.protocols.ldap;
@@ -41,7 +41,7 @@
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.Attributes;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
opendj-server-legacy/src/test/java/org/opends/server/protocols/ldap/TestModifyDNResponseProtocolOp.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.protocols.ldap;
@@ -43,7 +43,7 @@
import org.opends.server.DirectoryServerTestCase;
import org.opends.server.TestCaseUtils;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.LDAPException;
import org.opends.server.types.RDN;
opendj-server-legacy/src/test/java/org/opends/server/protocols/ldap/TestModifyResponseProtocolOp.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.protocols.ldap;
@@ -36,9 +36,9 @@
import org.forgerock.opendj.io.ASN1Writer;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ByteStringBuilder;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.TestCaseUtils;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.LDAPException;
import org.opends.server.types.RDN;
opendj-server-legacy/src/test/java/org/opends/server/replication/GenerationIdTest.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.replication;
@@ -66,7 +66,7 @@
import org.opends.server.replication.service.ReplicationBroker;
import org.opends.server.tasks.LdifFileWriter;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
opendj-server-legacy/src/test/java/org/opends/server/replication/SchemaReplicationTest.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2012-2015 ForgeRock AS.
 *      Portions Copyright 2012-2016 ForgeRock AS.
 */
package org.opends.server.replication;
@@ -130,7 +130,7 @@
    {
      // Modify the schema
      Attribute attr = Attributes.create("attributetypes",
          "( 2.5.44.77.33 NAME 'dummy' )");
          "( 2.5.44.77.33 NAME 'dummy' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )");
      Modification mod = new Modification(ADD, attr);
      processModify(baseDN, mod);
opendj-server-legacy/src/test/java/org/opends/server/replication/UpdateOperationTest.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.replication;
@@ -48,6 +48,7 @@
import org.opends.server.replication.common.CSNGenerator;
import org.opends.server.replication.protocol.*;
import org.opends.server.replication.service.ReplicationBroker;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import org.opends.server.util.TestTimer;
import org.opends.server.util.TimeThread;
opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/AttrHistoricalMultipleTest.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2015 ForgeRock AS.
 *      Portions Copyright 2013-2016 ForgeRock AS.
 */
package org.opends.server.replication.plugin;
@@ -40,13 +40,13 @@
import org.forgerock.i18n.LocalizableMessageBuilder;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.TestCaseUtils;
import org.opends.server.core.DirectoryServer;
import org.opends.server.replication.ReplicationTestCase;
import org.opends.server.replication.common.CSN;
import org.opends.server.replication.common.CSNGenerator;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.Attributes;
import org.opends.server.types.Entry;
import org.opends.server.types.Modification;
opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/FractionalReplicationTest.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2009-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.replication.plugin;
@@ -45,6 +45,7 @@
import org.opends.server.replication.server.ReplicationServer;
import org.opends.server.replication.service.FakeReplicationDomain;
import org.opends.server.replication.service.ReplicationDomain;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/HistoricalCsnOrderingTest.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.replication.plugin;
@@ -50,6 +50,7 @@
import org.opends.server.replication.server.ReplServerFakeConfiguration;
import org.opends.server.replication.server.ReplicationServer;
import org.opends.server.replication.service.ReplicationBroker;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import org.opends.server.util.TimeThread;
import org.testng.annotations.Test;
opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/HistoricalTest.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.replication.plugin;
@@ -33,6 +33,7 @@
import org.assertj.core.api.Assertions;
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.TestCaseUtils;
import org.opends.server.core.DirectoryServer;
import org.opends.server.protocols.internal.InternalClientConnection;
@@ -341,7 +342,7 @@
  private static void publishModify(ReplicationBroker broker, CSN changeNum,
      DN dn, String entryuuid, AttributeType attrType, String newValue)
  {
    Attribute attr = Attributes.create(attrType.getNameOrOID(), newValue);
    Attribute attr = Attributes.create(attrType.getNormalizedNameOrOID(), newValue);
    List<Modification> mods = newArrayList(new Modification(ModificationType.ADD, attr));
    broker.publish(new ModifyMsg(changeNum, dn, mods, entryuuid));
  }
opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/ModifyConflictTest.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.replication.plugin;
@@ -42,6 +42,7 @@
import org.opends.server.replication.protocol.LDAPUpdateMsg;
import org.opends.server.replication.protocol.ModifyContext;
import org.opends.server.replication.protocol.ReplicationMsg;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import org.opends.server.workflowelement.localbackend.LocalBackendModifyOperation;
import org.testng.annotations.Test;
opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/ModifyReplaySingleValuedAttributeTest.java
@@ -20,7 +20,7 @@
 *
 * CDDL HEADER END
 *
 *      Copyright 2015 ForgeRock AS
 *      Copyright 2015-2016 ForgeRock AS
 */
package org.opends.server.replication.plugin;
@@ -37,13 +37,13 @@
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.TestCaseUtils;
import org.opends.server.replication.ReplicationTestCase;
import org.opends.server.replication.common.CSN;
import org.opends.server.replication.protocol.ModifyContext;
import org.opends.server.replication.protocol.OperationContext;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.Attributes;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
opendj-server-legacy/src/test/java/org/opends/server/replication/protocol/ProtocolCompatibilityTest.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2009-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.replication.protocol;
@@ -42,6 +42,7 @@
import org.opends.server.core.ModifyOperationBasis;
import org.opends.server.replication.ReplicationTestCase;
import org.opends.server.replication.common.*;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import org.opends.server.util.TimeThread;
import org.testng.annotations.AfterClass;
@@ -1299,7 +1300,7 @@
    assertEquals(msg.getDetails().toString(), errorDetails);
  }
  @DataProvider(name = "initializeTargetMsgV3")
  @DataProvider
  public Object[][] createInitializeTargetMsgV3()
  {
    return new Object[][] {
@@ -1320,7 +1321,7 @@
    assertEquals(msg.getEntryCount(), entryCount);
  }
  @DataProvider(name = "initializeRequestMsgV3")
  @DataProvider
  public Object[][] createInitializeRequestMsgV3()
  {
    return new Object[][] {
opendj-server-legacy/src/test/java/org/opends/server/replication/protocol/SynchronizationMsgTest.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.replication.protocol;
@@ -37,6 +37,7 @@
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.replication.ReplicationTestCase;
import org.opends.server.replication.common.*;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import org.opends.server.util.TimeThread;
import org.opends.server.workflowelement.localbackend.LocalBackendAddOperation;
opendj-server-legacy/src/test/java/org/opends/server/schema/AttributeSyntaxTest.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2012-2015 ForgeRock AS
 *      Portions Copyright 2012-2016 ForgeRock AS
 */
package org.opends.server.schema;
@@ -39,6 +39,7 @@
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@SuppressWarnings("javadoc")
@RemoveOnceSDKSchemaIsUsed
public abstract class AttributeSyntaxTest extends SchemaTestCase
{
@@ -57,12 +58,12 @@
   * Get an instance of the attribute syntax that must be tested.
   *
   * @return An instance of the attribute syntax that must be tested.
   * @throws Exception
   *           if a problem occurs
   */
  protected abstract AttributeSyntax<?> getRule();
  protected abstract AttributeSyntax<?> getRule() throws Exception;
  /**
   * Test the normalization and the approximate comparison.
   */
  /** Test the normalization and the approximate comparison. */
  @Test(dataProvider= "acceptableValues")
  public void testAcceptableValues(String value, Boolean result) throws Exception
  {
@@ -75,7 +76,7 @@
    LocalizableMessageBuilder reason = new LocalizableMessageBuilder();
    // test the valueIsAcceptable method
    Boolean liveResult =
    boolean liveResult =
      syntax.valueIsAcceptable(ByteString.valueOfUtf8(value), reason);
    assertSame(liveResult, result, syntax + ".valueIsAcceptable gave bad result for " + value + " reason : " + reason);
opendj-server-legacy/src/test/java/org/opends/server/schema/AttributeTypeSyntaxTest.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.schema;
@@ -30,15 +30,15 @@
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.ldap.schema.Schema;
import org.forgerock.opendj.ldap.schema.SchemaBuilder;
import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.TestCaseUtils;
import org.opends.server.api.AttributeSyntax;
import org.opends.server.core.DirectoryServer;
import org.opends.server.protocols.internal.InternalSearchOperation;
import org.opends.server.protocols.internal.SearchRequest;
import org.opends.server.types.AttributeType;
import org.opends.server.util.RemoveOnceSDKSchemaIsUsed;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@@ -47,21 +47,16 @@
import static org.opends.server.protocols.internal.Requests.*;
import static org.testng.Assert.*;
/**
 * Test the AttributeTypeSyntax.
 */
/** Test the AttributeTypeSyntax. */
@RemoveOnceSDKSchemaIsUsed
public class AttributeTypeSyntaxTest extends AttributeSyntaxTest
{
  /** {@inheritDoc} */
  @Override
  protected AttributeSyntax getRule()
  {
    return new AttributeTypeSyntax();
  }
  /** {@inheritDoc} */
  @Override
  @DataProvider(name="acceptableValues")
  public Object[][] createAcceptableValues()
@@ -127,37 +122,29 @@
  @Test
  public void testXAPPROXExtension() throws Exception
  {
    MatchingRule mrule = Schema.getCoreSchema().getMatchingRule("ds-mr-double-metaphone-approx");
    // Get a reference to the attribute type syntax implementation in the
    // server.
    Syntax attrTypeSyntax = DirectoryServer.getSchema().getSyntax("1.3.6.1.4.1.1466.115.121.1.3", false);
    org.opends.server.types.Schema schema = DirectoryServer.getSchema();
    Syntax attrTypeSyntax = schema.getSyntax("1.3.6.1.4.1.1466.115.121.1.3");
    assertNotNull(attrTypeSyntax);
    // Create an attribute type definition and verify that it is acceptable.
    ByteString definition = ByteString.valueOfUtf8(
      "( testxapproxtype-oid NAME 'testXApproxType' " +
           "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 " +
           "X-APPROX 'ds-mr-double-metaphone-approx' )");
    LocalizableMessageBuilder invalidReason = new LocalizableMessageBuilder();
    assertTrue(attrTypeSyntax.valueIsAcceptable(definition, invalidReason),
            invalidReason.toString());
    assertTrue(attrTypeSyntax.valueIsAcceptable(definition, invalidReason), invalidReason.toString());
    // Verify that we can decode the attribute type and that it has the
    // correct approximate matching rule.
    AttributeType attrType =
         AttributeTypeSyntax.decodeAttributeType(definition,
                                                 DirectoryServer.getSchema(),
                                                 false);
    assertNotNull(attrType);
    Schema newSchema = new SchemaBuilder(schema.getSchemaNG())
      .addAttributeType(definition.toString(), false)
      .toSchema();
    AttributeType attrType = newSchema.getAttributeType("testXApproxType");
    assertNotNull(attrType.getApproximateMatchingRule());
    assertEquals(attrType.getApproximateMatchingRule(), mrule);
    assertEquals(attrType.getApproximateMatchingRule(), schema.getMatchingRule("ds-mr-double-metaphone-approx"));
  }
  /**
   * Tests a situation when two radically different equality and substring
   * matching rules (such as Case Ignore and Case Exact) are used to define an
opendj-server-legacy/src/test/java/org/opends/server/schema/BinaryAttributeSyntaxTest.java
@@ -22,23 +22,24 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2012-2015 ForgeRock AS
 *      Portions Copyright 2012-2016 ForgeRock AS
 */
package org.opends.server.schema;
import static org.testng.Assert.*;
import org.opends.server.api.AttributeSyntax;
import org.opends.server.util.RemoveOnceSDKSchemaIsUsed;
import org.forgerock.i18n.LocalizableMessageBuilder;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.schema.Schema;
import org.forgerock.opendj.ldap.schema.SchemaBuilder;
import org.forgerock.opendj.ldap.schema.SchemaOptions;
import org.forgerock.opendj.ldap.schema.Syntax;
import org.forgerock.i18n.LocalizableMessageBuilder;
import org.opends.server.api.AttributeSyntax;
import org.opends.server.util.RemoveOnceSDKSchemaIsUsed;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@SuppressWarnings("javadoc")
@RemoveOnceSDKSchemaIsUsed
public abstract class BinaryAttributeSyntaxTest extends SchemaTestCase
{
@@ -57,8 +58,9 @@
   * Get an instance of the attribute syntax that must be tested.
   *
   * @return An instance of the attribute syntax that must be tested.
   * @throws Exception if a problem occurs
   */
  protected abstract AttributeSyntax getRule();
  protected abstract AttributeSyntax<?> getRule() throws Exception;
  /**
   * Test the normalization and the approximate comparison.
opendj-server-legacy/src/test/java/org/opends/server/schema/CertificateSyntaxTest.java
@@ -22,36 +22,32 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2012-2015 ForgeRock AS
 *      Portions Copyright 2012-2016 ForgeRock AS
 */
package org.opends.server.schema;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.schema.Schema;
import org.opends.server.ServerContextBuilder;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.opends.server.admin.std.server.CertificateAttributeSyntaxCfg;
import org.opends.server.api.AttributeSyntax;
import org.opends.server.core.ServerContext;
import org.forgerock.opendj.config.server.ConfigException;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.schema.Schema;
import org.opends.server.types.DN;
import org.opends.server.util.Base64;
import org.opends.server.util.RemoveOnceSDKSchemaIsUsed;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
/**
 * Test the CertificateSyntax.
 */
/** Test the CertificateSyntax. */
@RemoveOnceSDKSchemaIsUsed
@Test
public class CertificateSyntaxTest extends BinaryAttributeSyntaxTest
{
  /** {@inheritDoc} */
  @Override
  protected AttributeSyntax<?> getRule()
  protected AttributeSyntax<?> getRule() throws Exception
  {
    CertificateSyntax syntax = new CertificateSyntax();
    CertificateAttributeSyntaxCfg cfg = new CertificateAttributeSyntaxCfg()
@@ -132,24 +128,13 @@
      }
    };
    try
    {
      Schema schema = Schema.getCoreSchema();
      ServerContext serverContext = ServerContextBuilder.aServerContext()
          .schemaNG(schema)
          .schemaUpdater(new ServerContextBuilder.MockSchemaUpdater(schema)).build();
      syntax.initializeSyntax(cfg, serverContext);
    }
    catch (ConfigException e)
    {
      // Should never happen.
      throw new RuntimeException(e);
    }
    ServerContext serverContext = ServerContextBuilder.aServerContext()
        .schema(new org.opends.server.types.Schema(Schema.getCoreSchema()))
        .build();
    syntax.initializeSyntax(cfg, serverContext);
    return syntax;
  }
  /** {@inheritDoc} */
  @Override
  @DataProvider(name="acceptableValues")
  public Object[][] createAcceptableValues()
@@ -205,6 +190,4 @@
      return new Object[][] {};
    }
  }
}
opendj-server-legacy/src/test/java/org/opends/server/schema/CoreSchemaProviderTestCase.java
@@ -21,7 +21,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2014-2015 ForgeRock AS.
 *      Copyright 2014-2016 ForgeRock AS.
 */
package org.opends.server.schema;
@@ -29,14 +29,19 @@
import org.forgerock.opendj.ldap.schema.SchemaBuilder;
import org.forgerock.opendj.server.config.server.CoreSchemaCfg;
import org.opends.server.ConfigurationMock;
import org.opends.server.TestCaseUtils;
import org.opends.server.core.CoreTestCase;
import org.opends.server.core.ServerContext;
import org.testng.annotations.Test;
import static org.assertj.core.api.Assertions.*;
import static org.forgerock.opendj.ldap.schema.SchemaOptions.*;
import static org.mockito.Mockito.*;
import static org.opends.server.ServerContextBuilder.*;
import static org.opends.server.util.CollectionUtils.*;
import java.io.File;
@SuppressWarnings("javadoc")
public class CoreSchemaProviderTestCase extends CoreTestCase
{
@@ -49,11 +54,23 @@
    CoreSchemaCfg coreSchemaCfg = ConfigurationMock.mockCfg(CoreSchemaCfg.class);
    CoreSchemaProvider provider = new CoreSchemaProvider();
    provider.initialize(coreSchemaCfg, new SchemaBuilder(), mock(SchemaUpdater.class));
    org.opends.server.types.Schema schema = new org.opends.server.types.Schema( Schema.getCoreSchema());
    provider.initialize(getServerContext(schema), coreSchemaCfg, new SchemaBuilder());
    verify(coreSchemaCfg).addCoreSchemaChangeListener(provider);
  }
  private ServerContext getServerContext(org.opends.server.types.Schema schema) throws Exception
  {
    return aServerContext()
        .schemaDirectory(new File(TestCaseUtils.getBuildRoot(), "resource/schema"))
        .configFile(TestCaseUtils.getTestResource("config-small.ldif"))
        .withConfigurationBootstrapped()
        .schema(schema)
        .build();
  }
  @Test
  public void testEnableZeroLengthDirectoryStrings() throws Exception
  {
@@ -62,7 +79,8 @@
    SchemaBuilder schemaBuilder = new SchemaBuilder();
    CoreSchemaProvider provider = new CoreSchemaProvider();
    provider.initialize(coreSchemaCfg, schemaBuilder, mock(SchemaUpdater.class));
    org.opends.server.types.Schema schema = new org.opends.server.types.Schema( Schema.getCoreSchema());
    provider.initialize(getServerContext(schema), coreSchemaCfg, schemaBuilder);
    assertThat(schemaBuilder.toSchema().getOption(ALLOW_ZERO_LENGTH_DIRECTORY_STRINGS)).isTrue();
  }
@@ -75,7 +93,8 @@
    SchemaBuilder schemaBuilder = new SchemaBuilder(Schema.getCoreSchema());
    CoreSchemaProvider provider = new CoreSchemaProvider();
    provider.initialize(coreSchemaCfg, schemaBuilder, mock(SchemaUpdater.class));
    org.opends.server.types.Schema schema = new org.opends.server.types.Schema( Schema.getCoreSchema());
    provider.initialize(getServerContext(schema), coreSchemaCfg, schemaBuilder);
    assertThat(schemaBuilder.toSchema().hasSyntax(DIRECTORY_STRING_SYNTAX_OID)).isFalse();
  }
@@ -88,7 +107,8 @@
    SchemaBuilder schemaBuilder = new SchemaBuilder(Schema.getCoreSchema());
    CoreSchemaProvider provider = new CoreSchemaProvider();
    provider.initialize(coreSchemaCfg, schemaBuilder, mock(SchemaUpdater.class));
    org.opends.server.types.Schema schema = new org.opends.server.types.Schema( Schema.getCoreSchema());
    provider.initialize(getServerContext(schema), coreSchemaCfg, schemaBuilder);
    assertThat(schemaBuilder.toSchema().hasMatchingRule(DIRECTORY_STRING_SYNTAX_OID)).isFalse();
  }
opendj-server-legacy/src/test/java/org/opends/server/schema/CountryStringSyntaxTest.java
@@ -22,35 +22,31 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2012-2015 ForgeRock AS
 *      Portions Copyright 2012-2016 ForgeRock AS
 *      Portions Copyright 2012 Manuel Gaupp
 */
package org.opends.server.schema;
import org.forgerock.opendj.ldap.schema.Schema;
import org.opends.server.ServerContextBuilder;
import org.opends.server.api.AttributeSyntax;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.server.AttributeSyntaxCfg;
import org.opends.server.admin.std.server.CountryStringAttributeSyntaxCfg;
import org.opends.server.api.AttributeSyntax;
import org.opends.server.core.ServerContext;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.schema.Schema;
import org.opends.server.types.DN;
import org.opends.server.util.RemoveOnceSDKSchemaIsUsed;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
/**
 * Test the CountryStringSyntax.
 */
/** Test the CountryStringSyntax. */
@RemoveOnceSDKSchemaIsUsed
@Test
public class CountryStringSyntaxTest extends AttributeSyntaxTest
{
  /** {@inheritDoc} */
  @Override
  protected AttributeSyntax getRule()
  protected AttributeSyntax<?> getRule() throws Exception
  {
    CountryStringSyntax syntax = new CountryStringSyntax();
    CountryStringAttributeSyntaxCfg cfg = new CountryStringAttributeSyntaxCfg()
@@ -132,24 +128,13 @@
      }
    };
    try
    {
      Schema schema = Schema.getCoreSchema();
      ServerContext serverContext = ServerContextBuilder.aServerContext()
        .schemaNG(schema)
        .schemaUpdater(new ServerContextBuilder.MockSchemaUpdater(schema)).build();
      syntax.initializeSyntax(cfg, serverContext);
    }
    catch (ConfigException e)
    {
      // Should never happen.
      throw new RuntimeException(e);
    }
    ServerContext serverContext = ServerContextBuilder.aServerContext()
        .schema(new org.opends.server.types.Schema(Schema.getCoreSchema()))
        .build();
    syntax.initializeSyntax(cfg, serverContext);
    return syntax;
  }
  /** {@inheritDoc} */
  @Override
  @DataProvider(name="acceptableValues")
  public Object[][] createAcceptableValues()
@@ -164,5 +149,4 @@
        {"\u00D6\u00C4", false},
    };
  }
}
opendj-server-legacy/src/test/java/org/opends/server/schema/FakeEntryIndex.java
@@ -20,7 +20,7 @@
 *
 * CDDL HEADER END
 *
 *      Copyright 2015 ForgeRock AS
 *      Copyright 2015-2016 ForgeRock AS
 */
package org.opends.server.schema;
@@ -40,13 +40,13 @@
import org.forgerock.opendj.ldap.Assertion;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.DecodeException;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.forgerock.opendj.ldap.schema.Schema;
import org.forgerock.opendj.ldap.spi.Indexer;
import org.forgerock.opendj.ldap.spi.IndexingOptions;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
import org.opends.server.types.SearchFilter;
opendj-server-legacy/src/test/java/org/opends/server/schema/GenericSchemaTestCase.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS.
 *      Portions Copyright 2014-2016 ForgeRock AS.
 *
 */
package org.opends.server.schema;
@@ -33,12 +33,12 @@
import java.util.TreeSet;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.TestCaseUtils;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.Entry;
import org.opends.server.types.LDIFImportConfig;
import org.opends.server.types.NameForm;
@@ -83,7 +83,7 @@
    TreeSet<String> invalidOIDs = new TreeSet<>();
    Schema schema = DirectoryServer.getSchema();
    for (Syntax as : schema.getSyntaxes().values())
    for (Syntax as : schema.getSyntaxes())
    {
      if (! isNumericOID(as.getOID()))
      {
@@ -117,7 +117,7 @@
    TreeSet<String> invalidOIDs = new TreeSet<>();
    Schema schema = DirectoryServer.getSchema();
    for (MatchingRule mr : schema.getMatchingRules().values())
    for (MatchingRule mr : schema.getMatchingRules())
    {
      if (! isNumericOID(mr.getOID()))
      {
@@ -190,8 +190,7 @@
      {
        for (ByteString v : a)
        {
          AttributeType at = AttributeTypeSyntax.decodeAttributeType(
              v, DirectoryServer.getSchema(),true);
          AttributeType at = DirectoryServer.getSchema().parseAttributeType(v.toString());
          if (! isNumericOID(at.getOID()))
          {
            invalidOIDs.add(at.getNameOrOID());
opendj-server-legacy/src/test/java/org/opends/server/schema/TimeBasedMatchingRuleTest.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2009-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2010-2015 ForgeRock AS.
 *      Portions Copyright 2010-2016 ForgeRock AS.
 */
package org.opends.server.schema;
@@ -40,11 +40,11 @@
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ConditionResult;
import org.forgerock.opendj.ldap.DecodeException;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.opends.server.TestCaseUtils;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
import org.opends.server.types.FilterType;
opendj-server-legacy/src/test/java/org/opends/server/tasks/AddSchemaFileTaskTestCase.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2015 ForgeRock AS.
 *      Portions Copyright 2013-2016 ForgeRock AS.
 */
package org.opends.server.tasks;
@@ -108,7 +108,7 @@
      "objectClass: ldapSubentry",
      "objectClass: subschema",
      "attributeTypes: ( testaddvalidschemafileat-oid " +
           "NAME 'testAddValidSchemaFileAT' )",
           "NAME 'testAddValidSchemaFileAT' SUP name)",
      "objectClasses: ( testaddvalidschemafileoc-oid " +
           "NAME 'testAddValidSchemaFileOC' STRUCTURAL " +
           "MUST testAddValidSchemaFileAT )",
@@ -179,7 +179,7 @@
      "objectClass: ldapSubentry",
      "objectClass: subschema",
      "attributeTypes: ( testaddmultiplevalidschemafiles1at-oid " +
           "NAME 'testAddMultipleValidSchemaFiles1AT' )",
           "NAME 'testAddMultipleValidSchemaFiles1AT' SUP name)",
      "objectClasses: ( testaddmultiplevalidschemafiles1oc-oid " +
           "NAME 'testAddMultipleValidSchemaFiles1OC' STRUCTURAL " +
           "MUST testAddMultipleValidSchemaFiles1AT )",
@@ -212,7 +212,7 @@
      "objectClass: ldapSubentry",
      "objectClass: subschema",
      "attributeTypes: ( testaddmultiplevalidschemafiles2at-oid " +
           "NAME 'testAddMultipleValidSchemaFiles2AT' )",
           "NAME 'testAddMultipleValidSchemaFiles2AT' SUP name)",
      "objectClasses: ( testaddmultiplevalidschemafiles2oc-oid " +
           "NAME 'testAddMultipleValidSchemaFiles2OC' STRUCTURAL " +
           "MUST testAddMultipleValidSchemaFiles2AT )",
opendj-server-legacy/src/test/java/org/opends/server/types/AttributeBuilderTest.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS.
 *      Portions Copyright 2011-2016 ForgeRock AS.
 */
package org.opends.server.types;
@@ -30,9 +30,16 @@
import static org.opends.server.util.CollectionUtils.*;
import static org.testng.Assert.*;
import java.util.*;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Set;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.TestCaseUtils;
import org.opends.server.core.DirectoryServer;
import org.testng.Assert;
opendj-server-legacy/src/test/java/org/opends/server/types/AttributeTypeConstants.java
File was deleted
opendj-server-legacy/src/test/java/org/opends/server/types/AttributeTypeTest.java
@@ -20,12 +20,13 @@
 *
 * CDDL HEADER END
 *
 *      Copyright 2015 ForgeRock AS
 *      Copyright 2015-2016 ForgeRock AS
 */
package org.opends.server.types;
import static org.opends.server.core.DirectoryServer.*;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.DirectoryServerTestCase;
import org.opends.server.TestCaseUtils;
import org.testng.Assert;
opendj-server-legacy/src/test/java/org/opends/server/types/EntrySchemaCheckingTestCase.java
@@ -22,10 +22,12 @@
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.types;
import org.forgerock.opendj.ldap.schema.AttributeType;
import static org.opends.server.types.AcceptRejectWarn.*;
import static org.testng.Assert.*;
opendj-server-legacy/src/test/java/org/opends/server/types/PrivilegeTestCase.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2007-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.types;
@@ -43,6 +43,7 @@
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.TestCaseUtils;
import org.opends.server.admin.std.meta.GlobalCfgDefn.DisabledPrivilege;
import org.opends.server.admin.std.meta.RootDNCfgDefn;
@@ -951,18 +952,20 @@
      "objectClass: top",
      "objectClass: ldapSubentry",
      "objectClass: subschema",
      "attributeTypes: ( " + identifier.toLowerCase() + "-oid " +
           "NAME '" + identifier + "' )"
      "attributeTypes: ( " + identifier.toLowerCase() + "-oid"
          + " NAME '" + identifier + "'"
          + " SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )"
    };
    File validFile = new File(schemaDirectory, "05-" + identifier + ".ldif");
    BufferedWriter writer = new BufferedWriter(new FileWriter(validFile));
    for (String line : fileLines)
    try (BufferedWriter writer = new BufferedWriter(new FileWriter(validFile)))
    {
      writer.write(line);
      writer.newLine();
      for (String line : fileLines)
      {
        writer.write(line);
        writer.newLine();
      }
    }
    writer.close();
    assertPrivilege(conn, hasPrivilege,
      "dn: ds-task-id=" + UUID.randomUUID() + ",cn=Scheduled Tasks,cn=Tasks",
@@ -2278,8 +2281,7 @@
    // We won't use an internal connection here because these are not notified
    // of dynamic changes to authentication info.
    Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort());
    try
    try (Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()))
    {
      TestCaseUtils.configureSocket(s);
      LDAPReader r = new LDAPReader(s);
@@ -2331,10 +2333,6 @@
      DeleteOperation deleteOperation = rootConnection.processDelete("cn=Test User,o=test");
      assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS);
    }
    finally
    {
      s.close();
    }
  }
opendj-server-legacy/src/test/java/org/opends/server/types/SearchFilterTests.java
@@ -23,10 +23,12 @@
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2014 Manuel Gaupp
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.types;
import org.forgerock.opendj.ldap.schema.AttributeType;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Collections;
opendj-server-legacy/src/test/java/org/opends/server/types/TestAttributeType.java
File was deleted
opendj-server-legacy/src/test/java/org/opends/server/types/TestDN.java
@@ -22,10 +22,12 @@
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2012-2015 ForgeRock AS
 *      Portions Copyright 2012-2016 ForgeRock AS
 */
package org.opends.server.types;
import org.forgerock.opendj.ldap.schema.AttributeType;
import static org.assertj.core.api.Assertions.*;
import static org.opends.server.TestCaseUtils.*;
import static org.opends.server.core.DirectoryServer.*;
@@ -1152,10 +1154,11 @@
    DN dn1 = DN.valueOf(first);
    DN dn2 = DN.valueOf(second);
    String msg = "DN equality for <" + first + "> and <" + second + ">";
    if (result == 0) {
      assertEquals   (dn1, dn2, "DN equality for <" + first + "> and <" + second + ">");
      assertEquals   (dn1, dn2, msg);
    } else {
      assertNotEquals(dn1, dn2, "DN equality for <" + first + "> and <" + second + ">");
      assertNotEquals(dn1, dn2, msg);
    }
  }
opendj-server-legacy/src/test/java/org/opends/server/types/TestEntry.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.types;
@@ -40,9 +40,9 @@
import org.forgerock.i18n.LocalizableMessageBuilder;
import org.forgerock.i18n.LocalizedIllegalArgumentException;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.TestCaseUtils;
import org.opends.server.core.DirectoryServer;
import org.opends.server.schema.AttributeTypeSyntax;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@@ -226,9 +226,7 @@
    String string = "( 2.5.18.6 NAME 'subtreeSpecification' "
        + "SYNTAX 1.3.6.1.4.1.1466.115.121.1.45 )";
    AttributeType type = AttributeTypeSyntax.decodeAttributeType(
        ByteString.valueOfUtf8(string),
        DirectoryServer.getSchema(), false);
    AttributeType type = DirectoryServer.getSchema().parseAttributeType(string);
    // Test values.
    String[] values = new String[] { "{ }",
opendj-server-legacy/src/test/java/org/opends/server/types/TestObjectClass.java
@@ -22,10 +22,12 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2015 ForgeRock AS
 *      Portions Copyright 2013-2016 ForgeRock AS
 */
package org.opends.server.types;
import org.forgerock.opendj.ldap.schema.AttributeType;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
opendj-server-legacy/src/test/java/org/opends/server/types/TestRDN.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.types;
@@ -33,6 +33,7 @@
import java.util.ArrayList;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.TestCaseUtils;
import org.opends.server.core.DirectoryServer;
import org.testng.annotations.BeforeClass;
opendj-server-legacy/src/test/java/org/opends/server/types/VirtualAttributeRuleTestCase.java
@@ -22,10 +22,12 @@
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.types;
import org.forgerock.opendj.ldap.schema.AttributeType;
import java.util.Collections;
import java.util.LinkedHashSet;
opendj-server-legacy/src/test/java/org/opends/server/types/VirtualAttributeTestCase.java
@@ -22,10 +22,12 @@
 *
 *
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2015 ForgeRock AS
 *      Portions Copyright 2011-2016 ForgeRock AS
 */
package org.opends.server.types;
import org.forgerock.opendj.ldap.schema.AttributeType;
import java.util.Collections;
import java.util.LinkedHashSet;
opendj-server-legacy/src/test/java/org/opends/server/util/TestAddChangeRecordEntry.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.util;
@@ -35,7 +35,7 @@
import org.opends.server.TestCaseUtils;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.Attributes;
import org.opends.server.types.DN;
import org.testng.Assert;
opendj-server-legacy/src/test/java/org/opends/server/util/TestLDIFReader.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014-2015 ForgeRock AS
 *      Portions Copyright 2014-2016 ForgeRock AS
 */
package org.opends.server.util;
@@ -39,6 +39,7 @@
import org.forgerock.opendj.ldap.ModificationType;
import org.opends.server.TestCaseUtils;
import org.opends.server.core.DirectoryServer;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.*;
import org.testng.Assert;
import org.testng.annotations.AfterClass;