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

Nicolas Capponi
01.37.2016 43a01cb8d6c368843baa014eb80be265bfe092e7
OPENDJ-3038 Merge ServerSchemaElement class into SchemaUtils class
1 files deleted
11 files modified
319 ■■■■■ changed files
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/ServerDescriptor.java 7 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/DeleteSchemaElementsTask.java 3 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/NewSchemaElementsTask.java 4 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/BrowseSchemaPanel.java 1 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/CustomAttributePanel.java 8 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/CustomObjectClassPanel.java 7 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/StandardObjectClassPanel.java 7 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/Utilities.java 12 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/NullBackend.java 4 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java 52 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/schema/ServerSchemaElement.java 126 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/util/SchemaUtils.java 88 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/ServerDescriptor.java
@@ -16,6 +16,8 @@
 */
package org.opends.guitools.controlpanel.datamodel;
import static org.opends.server.util.SchemaUtils.getElementDefinitionWithFileName;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
@@ -38,7 +40,6 @@
import com.forgerock.opendj.util.OperatingSystem;
import static org.opends.guitools.controlpanel.datamodel.BasicMonitoringAttributes.*;
import static org.opends.server.schema.ServerSchemaElement.*;
/**
 * This is just a class used to provide a data model describing what the
@@ -607,7 +608,7 @@
        && attr1.isOperational() == attr2.isOperational()
        && attr1.isSingleValue() == attr2.isSingleValue()
        && areEqual(attr1.getApproximateMatchingRule(), attr2.getApproximateMatchingRule())
        && areEqual(getDefinitionWithFileName(attr1), getDefinitionWithFileName(attr2))
        && areEqual(getElementDefinitionWithFileName(attr1), getElementDefinitionWithFileName(attr2))
        && areEqual(attr1.getDescription(), attr2.getDescription())
        && areEqual(attr1.getEqualityMatchingRule(), attr2.getEqualityMatchingRule())
        && areEqual(attr1.getOrderingMatchingRule(), attr2.getOrderingMatchingRule())
@@ -631,7 +632,7 @@
  private static boolean areObjectClassesEqual(ObjectClass oc1, ObjectClass oc2)
  {
    return oc1.getOID().equals(oc2.getOID())
        && areEqual(getDefinitionWithFileName(oc1), getDefinitionWithFileName(oc2))
        && areEqual(getElementDefinitionWithFileName(oc1), getElementDefinitionWithFileName(oc2))
        && areEqual(oc1.getDescription(), oc2.getDescription())
        && areEqual(oc1.getObjectClassType(), oc2.getObjectClassType())
        && areEqual(oc1.getDeclaredOptionalAttributes(), oc2.getDeclaredOptionalAttributes())
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/DeleteSchemaElementsTask.java
@@ -52,7 +52,6 @@
import org.opends.guitools.controlpanel.util.Utilities;
import org.opends.server.config.ConfigConstants;
import org.opends.server.core.DirectoryServer;
import org.opends.server.schema.ServerSchemaElement;
import org.opends.server.types.Attributes;
import org.opends.server.types.Entry;
import org.opends.server.types.LDIFExportConfig;
@@ -348,7 +347,7 @@
   */
  private String getSchemaFile(SchemaElement element)
  {
    String schemaFile = ServerSchemaElement.getSchemaFile(element);
    String schemaFile = getElementSchemaFile(element);
    if (schemaFile == null)
    {
      schemaFile = ConfigConstants.FILE_USER_SCHEMA_ELEMENTS;
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/NewSchemaElementsTask.java
@@ -20,7 +20,7 @@
import static org.forgerock.util.Utils.*;
import static org.opends.messages.AdminToolMessages.*;
import static org.opends.guitools.controlpanel.util.Utilities.*;
import static org.opends.server.schema.ServerSchemaElement.getSchemaFile;
import static org.opends.server.util.SchemaUtils.getElementSchemaFile;
import java.io.File;
import java.util.ArrayList;
@@ -275,7 +275,7 @@
    Map<String, List<SchemaElement>> hmElems = new LinkedHashMap<>();
    for (SchemaElement elem : elemsToAdd)
    {
      String fileName = getSchemaFile(elem);
      String fileName = getElementSchemaFile(elem);
      if (fileName == null)
      {
        fileName = "";
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/BrowseSchemaPanel.java
@@ -99,7 +99,6 @@
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.schema.ServerSchemaElement;
import org.opends.server.types.Schema;
/** The pane that is displayed when the user clicks on 'Browse Schema'. */
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/CustomAttributePanel.java
@@ -16,10 +16,12 @@
 */
package org.opends.guitools.controlpanel.ui;
import static org.opends.server.util.SchemaUtils.getElementSchemaFile;
import static org.opends.guitools.controlpanel.util.Utilities.*;
import static org.opends.messages.AdminToolMessages.*;
import static org.opends.server.schema.ServerSchemaElement.*;
import static org.opends.server.util.CollectionUtils.*;
import static org.opends.server.util.SchemaUtils.getElementOrigin;
import java.awt.Component;
import java.awt.Container;
@@ -526,14 +528,14 @@
    lastAliases.addAll(someAliases);
    this.aliases.setText(Utilities.getStringFromCollection(someAliases, ", "));
    String sOrigin = getOrigin(attr);
    String sOrigin = getElementOrigin(attr);
    if (sOrigin == null)
    {
      sOrigin = "";
    }
    origin.setText(sOrigin);
    String sFile = getSchemaFile(attr);
    String sFile = getElementSchemaFile(attr);
    if (sFile == null)
    {
      sFile = "";
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/CustomObjectClassPanel.java
@@ -16,8 +16,9 @@
 */
package org.opends.guitools.controlpanel.ui;
import static org.opends.server.util.SchemaUtils.getElementSchemaFile;
import static org.opends.messages.AdminToolMessages.*;
import static org.opends.server.schema.ServerSchemaElement.*;
import static org.opends.server.util.CollectionUtils.*;
import static org.opends.server.util.SchemaUtils.*;
@@ -499,14 +500,14 @@
    lastAliases.addAll(aliases);
    this.aliases.setText(Utilities.getStringFromCollection(aliases, ", "));
    String sOrigin = getOrigin(oc);
    String sOrigin = getElementOrigin(oc);
    if (sOrigin == null)
    {
      sOrigin = "";
    }
    origin.setText(sOrigin);
    String sFile = getSchemaFile(oc);
    String sFile = getElementSchemaFile(oc);
    if (sFile == null)
    {
      sFile = "";
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/StandardObjectClassPanel.java
@@ -18,7 +18,7 @@
package org.opends.guitools.controlpanel.ui;
import static org.opends.messages.AdminToolMessages.*;
import static org.opends.server.schema.ServerSchemaElement.*;
import static org.opends.server.util.SchemaUtils.*;
import static org.opends.server.util.StaticUtils.*;
import java.awt.Component;
@@ -50,7 +50,6 @@
import org.opends.guitools.controlpanel.ui.components.TitlePanel;
import org.opends.guitools.controlpanel.util.LowerCaseComparator;
import org.opends.guitools.controlpanel.util.Utilities;
import org.opends.server.schema.ServerSchemaElement;
import org.opends.server.types.Schema;
/** The panel that displays a standard object class definition. */
@@ -244,8 +243,8 @@
  static LocalizableMessage getOrigin(SchemaElement element)
  {
    LocalizableMessageBuilder returnValue = new LocalizableMessageBuilder();
    String fileName = getSchemaFile(element);
    String xOrigin = ServerSchemaElement.getOrigin(element);
    String fileName = getElementSchemaFile(element);
    String xOrigin = getElementOrigin(element);
    if (xOrigin != null)
    {
      returnValue.append(xOrigin);
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/Utilities.java
@@ -16,6 +16,8 @@
 */
package org.opends.guitools.controlpanel.util;
import static org.opends.server.util.SchemaUtils.getElementSchemaFile;
import static com.forgerock.opendj.cli.Utils.*;
import static com.forgerock.opendj.util.OperatingSystem.*;
import static org.forgerock.opendj.ldap.DereferenceAliasesPolicy.*;
@@ -25,7 +27,7 @@
import static org.opends.admin.ads.util.PreferredConnection.Type.*;
import static org.opends.messages.AdminToolMessages.*;
import static org.opends.quicksetup.Installation.*;
import static org.opends.server.schema.ServerSchemaElement.*;
import static org.opends.server.util.SchemaUtils.*;
import java.awt.Color;
import java.awt.Component;
@@ -1997,12 +1999,12 @@
   */
  public static boolean isStandard(SchemaElement fileElement)
  {
    final String fileName = getSchemaFile(fileElement);
    final String fileName = getElementSchemaFile(fileElement);
    if (fileName != null)
    {
      return standardSchemaFileNames.contains(fileName) || fileName.toLowerCase().contains("-rfc");
    }
    String xOrigin = getOrigin(fileElement);
    String xOrigin = getElementOrigin(fileElement);
    if (xOrigin != null)
    {
      return standardSchemaOrigins.contains(xOrigin) || xOrigin.startsWith("RFC ") || xOrigin.startsWith("draft-");
@@ -2019,12 +2021,12 @@
   */
  public static boolean isConfiguration(SchemaElement fileElement)
  {
    String fileName = getSchemaFile(fileElement);
    String fileName = getElementSchemaFile(fileElement);
    if (fileName != null)
    {
      return configurationSchemaFileNames.contains(fileName);
    }
    String xOrigin = getOrigin(fileElement);
    String xOrigin = getElementOrigin(fileElement);
    if (xOrigin != null)
    {
      return configurationSchemaOrigins.contains(xOrigin);
opendj-server-legacy/src/main/java/org/opends/server/backends/NullBackend.java
@@ -18,7 +18,7 @@
import static org.forgerock.opendj.ldap.schema.CoreSchema.*;
import static org.opends.messages.BackendMessages.*;
import static org.opends.server.schema.ServerSchemaElement.*;
import static org.opends.server.util.SchemaUtils.getElementSchemaFile;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
@@ -150,7 +150,7 @@
    String nulOCName = "nullbackendobject";
    ObjectClass nulOC = DirectoryServer.getSchema().getObjectClass(nulOCName);
    try {
      DirectoryServer.getSchema().registerObjectClass(nulOC, getSchemaFile(nulOC), false);
      DirectoryServer.getSchema().registerObjectClass(nulOC, getElementSchemaFile(nulOC), false);
    } catch (DirectoryException de) {
      logger.traceException(de);
      throw new InitializationException(de.getMessageObject());
opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java
@@ -24,9 +24,9 @@
import static org.opends.server.config.ConfigConstants.*;
import static org.opends.server.core.DirectoryServer.*;
import static org.opends.server.schema.GeneralizedTimeSyntax.*;
import static org.opends.server.schema.ServerSchemaElement.*;
import static org.opends.server.util.CollectionUtils.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.SchemaUtils.*;
import static org.opends.server.util.StaticUtils.*;
import java.io.File;
@@ -573,7 +573,7 @@
    for (SchemaElement element : elements)
    {
      /* Add the file name to the description of the element if this was requested by the caller. */
      String value = includeSchemaFile ? getDefinitionWithFileName(element) : element.toString();
      String value = includeSchemaFile ? getElementDefinitionWithFileName(element) : element.toString();
      if (stripSyntaxMinimumUpperBound && value.indexOf('{') != -1)
      {
        // Strip the minimum upper bound value from the attribute value.
@@ -1015,7 +1015,7 @@
   */
  private String addNewSchemaElement(Set<String> modifiedSchemaFiles, SchemaElement elem)
  {
    String schemaFile = getSchemaFile(elem);
    String schemaFile = getElementSchemaFile(elem);
    String finalFile = schemaFile != null ? schemaFile : FILE_USER_SCHEMA_ELEMENTS;
    modifiedSchemaFiles.add(finalFile);
    return schemaFile == null ? finalFile : null;
@@ -1028,8 +1028,8 @@
  private String replaceExistingSchemaElement(Set<String> modifiedSchemaFiles, SchemaElement newElem,
      SchemaElement existingElem)
  {
    String newSchemaFile = getSchemaFile(newElem);
    String oldSchemaFile = getSchemaFile(existingElem);
    String newSchemaFile = getElementSchemaFile(newElem);
    String oldSchemaFile = getElementSchemaFile(existingElem);
    if (newSchemaFile == null)
    {
      if (oldSchemaFile == null)
@@ -1166,7 +1166,7 @@
    // If we've gotten here, then it's OK to remove the attribute type from the schema.
    schema.deregisterAttributeType(removeType);
    addIfNotNull(modifiedSchemaFiles, getSchemaFile(removeType));
    addIfNotNull(modifiedSchemaFiles, getElementSchemaFile(removeType));
  }
  /**
@@ -1356,7 +1356,7 @@
    // If we've gotten here, then it's OK to remove the objectclass from the schema.
    schema.deregisterObjectClass(removeClass);
    addIfNotNull(modifiedSchemaFiles, getSchemaFile(removeClass));
    addIfNotNull(modifiedSchemaFiles, getElementSchemaFile(removeClass));
  }
  /**
@@ -1485,7 +1485,7 @@
    // Now remove the name form from the schema.
    schema.deregisterNameForm(removeNF);
    addIfNotNull(modifiedSchemaFiles, getSchemaFile(removeNF));
    addIfNotNull(modifiedSchemaFiles, getElementSchemaFile(removeNF));
  }
  /**
@@ -1592,7 +1592,7 @@
    // just remove the DIT content rule now, and if it is added back later then
    // there still won't be any conflict.
    schema.deregisterDITContentRule(removeDCR);
    addIfNotNull(modifiedSchemaFiles, getSchemaFile(removeDCR));
    addIfNotNull(modifiedSchemaFiles, getElementSchemaFile(removeDCR));
  }
  /**
@@ -1756,7 +1756,7 @@
    // If we've gotten here, then it's OK to remove the DIT structure rule from the schema.
    schema.deregisterDITStructureRule(removeDSR);
    addIfNotNull(modifiedSchemaFiles, getSchemaFile(removeDSR));
    addIfNotNull(modifiedSchemaFiles, getElementSchemaFile(removeDSR));
  }
  /**
@@ -1862,7 +1862,7 @@
    // just remove the DIT content rule now, and if it is added back later then
    // there still won't be any conflict.
    schema.deregisterMatchingRuleUse(removeMRU);
    addIfNotNull(modifiedSchemaFiles, getSchemaFile(removeMRU));
    addIfNotNull(modifiedSchemaFiles, getElementSchemaFile(removeMRU));
  }
  /**
@@ -1901,19 +1901,19 @@
      String def = Schema.addSchemaFileToElementDefinitionIfAbsent(definition, FILE_USER_SCHEMA_ELEMENTS);
      schema.registerSyntax(def, false);
      modifiedSchemaFiles.add(getSchemaFile(schema.getSyntax(oid)));
      modifiedSchemaFiles.add(getElementSchemaFile(schema.getSyntax(oid)));
    }
    else
    {
      schema.deregisterSyntax(existingLS);
      String oldSchemaFile = getSchemaFile(existingLS);
      String oldSchemaFile = getElementSchemaFile(existingLS);
      String schemaFile = oldSchemaFile != null && oldSchemaFile.length() > 0 ?
          oldSchemaFile : FILE_USER_SCHEMA_ELEMENTS;
      String def = Schema.addSchemaFileToElementDefinitionIfAbsent(definition, schemaFile);
      schema.registerSyntax(def, false);
      String newSchemaFile = getSchemaFile(schema.getSyntax(oid));
      String newSchemaFile = getElementSchemaFile(schema.getSyntax(oid));
      addIfNotNull(modifiedSchemaFiles, oldSchemaFile);
      addIfNotNull(modifiedSchemaFiles, newSchemaFile);
    }
@@ -1940,7 +1940,7 @@
    }
    schema.deregisterSyntax(removeLS);
    addIfNotNull(modifiedSchemaFiles, getSchemaFile(removeLS));
    addIfNotNull(modifiedSchemaFiles, getElementSchemaFile(removeLS));
  }
  /**
@@ -2092,7 +2092,7 @@
    Set<ByteString> values = new LinkedHashSet<>();
    for (SchemaElement schemaElement : schemaElements)
    {
      if (schemaFile.equals(getSchemaFile(schemaElement)))
      if (schemaFile.equals(getElementSchemaFile(schemaElement)))
      {
        values.add(ByteString.valueOfUtf8(schemaElement.toString()));
      }
@@ -2107,7 +2107,7 @@
    Set<ByteString> values = new LinkedHashSet<>();
    for (AttributeType at : schema.getAttributeTypes())
    {
      if (schemaFile.equals(getSchemaFile(at)))
      if (schemaFile.equals(getElementSchemaFile(at)))
      {
        addAttrTypeToSchemaFile(schema, schemaFile, at, values, addedTypes, 0);
      }
@@ -2121,7 +2121,7 @@
    Set<ByteString> values = new LinkedHashSet<>();
    for (ObjectClass oc : schema.getObjectClasses())
    {
      if (schemaFile.equals(getSchemaFile(oc)))
      if (schemaFile.equals(getElementSchemaFile(oc)))
      {
        addObjectClassToSchemaFile(schema, schemaFile, oc, values, addedClasses, 0);
      }
@@ -2136,7 +2136,7 @@
    Set<ByteString> values = new LinkedHashSet<>();
    for (DITStructureRule dsr : schema.getDITStructureRules())
    {
      if (schemaFile.equals(getSchemaFile(dsr)))
      if (schemaFile.equals(getElementSchemaFile(dsr)))
      {
        addDITStructureRuleToSchemaFile(schema, schemaFile, dsr, values, addedDSRs, 0);
      }
@@ -2191,7 +2191,7 @@
    AttributeType superiorType = attributeType.getSuperiorType();
    if (superiorType != null &&
        schemaFile.equals(getSchemaFile(attributeType)) &&
        schemaFile.equals(getElementSchemaFile(attributeType)) &&
        !addedTypes.contains(superiorType))
    {
      addAttrTypeToSchemaFile(schema, schemaFile, superiorType, values,
@@ -2239,7 +2239,7 @@
    for(ObjectClass superiorClass : objectClass.getSuperiorClasses())
    {
      if (schemaFile.equals(getSchemaFile(superiorClass)) &&
      if (schemaFile.equals(getElementSchemaFile(superiorClass)) &&
          !addedClasses.contains(superiorClass))
      {
        addObjectClassToSchemaFile(schema, schemaFile, superiorClass, values,
@@ -2287,7 +2287,7 @@
    for (DITStructureRule dsr : ditStructureRule.getSuperiorRules())
    {
      if (schemaFile.equals(getSchemaFile(dsr)) && !addedDSRs.contains(dsr))
      if (schemaFile.equals(getElementSchemaFile(dsr)) && !addedDSRs.contains(dsr))
      {
        addDITStructureRuleToSchemaFile(schema, schemaFile, dsr, values,
                                        addedDSRs, depth+1);
@@ -2721,7 +2721,7 @@
      for (ByteString v : a)
      {
        AttributeType attrType = schema.parseAttributeType(v.toString());
        String schemaFile = getSchemaFile(attrType);
        String schemaFile = getElementSchemaFile(attrType);
        if (is02ConfigLdif(schemaFile))
        {
          continue;
@@ -2749,7 +2749,7 @@
    // them from the new schema if they are not in the imported schema entry.
    for (AttributeType removeType : newSchema.getAttributeTypes())
    {
      String schemaFile = getSchemaFile(removeType);
      String schemaFile = getElementSchemaFile(removeType);
      if (is02ConfigLdif(schemaFile) || CORE_SCHEMA_ELEMENTS_FILE.equals(schemaFile))
      {
        // Also never delete anything from the core schema file.
@@ -2772,7 +2772,7 @@
        // It IS important here to allow the unknown elements that could
        // appear in the new config schema.
        ObjectClass newObjectClass = newSchema.parseObjectClass(v.toString());
        String schemaFile = getSchemaFile(newObjectClass);
        String schemaFile = getElementSchemaFile(newObjectClass);
        if (is02ConfigLdif(schemaFile))
        {
          continue;
@@ -2800,7 +2800,7 @@
    // them from the new schema if they are not in the imported schema entry.
    for (ObjectClass removeClass : newSchema.getObjectClasses())
    {
      String schemaFile = getSchemaFile(removeClass);
      String schemaFile = getElementSchemaFile(removeClass);
      if (is02ConfigLdif(schemaFile))
      {
        continue;
opendj-server-legacy/src/main/java/org/opends/server/schema/ServerSchemaElement.java
File was deleted
opendj-server-legacy/src/main/java/org/opends/server/util/SchemaUtils.java
@@ -15,15 +15,21 @@
 */
package org.opends.server.util;
import static org.opends.server.types.Schema.addSchemaFileToElementDefinitionIfAbsent;
import static org.opends.server.schema.SchemaConstants.SYNTAX_AUTH_PASSWORD_OID;
import static org.opends.server.schema.SchemaConstants.SYNTAX_USER_PASSWORD_OID;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.ldap.schema.ObjectClass;
import org.forgerock.opendj.ldap.schema.Schema;
import org.forgerock.opendj.ldap.schema.SchemaBuilder;
import org.forgerock.opendj.ldap.schema.SchemaElement;
import org.opends.server.core.ServerContext;
/** Utility methods related to schema. */
public class SchemaUtils
@@ -67,6 +73,60 @@
  }
  /**
   * Retrieves the definition string used to create the provided schema element and including the
   * X-SCHEMA-FILE extension.
   *
   * @param element
   *            The schema element.
   * @return The definition string used to create the schema element including the X-SCHEMA-FILE
   *         extension.
   */
  public static String getElementDefinitionWithFileName(SchemaElement element)
  {
    final String definition = element.toString();
    return addSchemaFileToElementDefinitionIfAbsent(definition, SchemaUtils.getElementSchemaFile(element));
  }
  /**
   * Returns the origin of the provided schema element.
   *
   * @param element
   *            The schema element.
   * @return the origin of the schema element as defined in the extra properties.
   */
  public static String getElementOrigin(SchemaElement element)
  {
    return getElementPropertyAsSingleValue(element, ServerConstants.SCHEMA_PROPERTY_ORIGIN);
  }
  /**
   * Returns the single value of the provided extra property for the provided schema element.
   *
   * @param element
   *            The schema element.
   * @param property
   *            The name of property to retrieve.
   * @return the single value of the extra property
   */
  public static String getElementPropertyAsSingleValue(SchemaElement element, String property)
  {
    List<String> values = element.getExtraProperties().get(property);
    return values != null && !values.isEmpty() ? values.get(0) : null;
  }
  /**
   * Returns the schema file of the provided schema element.
   *
   * @param element
   *            The schema element.
   * @return the schema file of schema element.
   */
  public static String getElementSchemaFile(SchemaElement element)
  {
    return getElementPropertyAsSingleValue(element, ServerConstants.SCHEMA_PROPERTY_FILENAME);
  }
  /**
   * Returns a new collection with the result of calling {@link ObjectClass#getNameOrOID()} on each
   * element of the provided collection.
   *
@@ -101,4 +161,32 @@
    }
    return results;
  }
  /**
   * Returns the new updated attribute type with the provided extra property and its values.
   *
   * @param serverContext
   *          the server context
   * @param attributeType
   *          attribute type to update
   * @param property
   *          the property to set
   * @param values
   *          the values to set
   * @return the new updated attribute type
   */
  public static AttributeType getNewAttributeTypeWithProperty(ServerContext serverContext, AttributeType attributeType,
      String property, String...values)
  {
    SchemaBuilder schemaBuilder =
         new SchemaBuilder(serverContext != null ? serverContext.getSchemaNG() : Schema.getDefaultSchema());
    AttributeType.Builder builder =
        schemaBuilder.buildAttributeType(attributeType).removeExtraProperty(property, (String) null);
    if (values != null && values.length > 0)
    {
      builder.extraProperties(property, values);
      return builder.addToSchemaOverwrite().toSchema().getAttributeType(attributeType.getNameOrOID());
    }
    return attributeType;
  }
}