From 40c232bb1ea09338ddbc93f2be3db6b340575fba Mon Sep 17 00:00:00 2001
From: Nicolas Capponi <nicolas.capponi@forgerock.com>
Date: Fri, 01 Jul 2016 13:46:08 +0000
Subject: [PATCH] OPENDJ-3038 Remove CommonSchemaElements class and transform ServerSchemaElement to an utility class

---
 opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/BrowseSchemaPanel.java          |   21 +-
 opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/DeleteSchemaElementsTask.java |   25 +-
 opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/CustomObjectClassPanel.java     |    5 
 opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/ServerDescriptor.java    |    6 
 opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/ModifyAttributeTask.java      |    4 
 opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/AbstractVLVIndexPanel.java      |    6 
 opendj-server-legacy/src/main/java/org/opends/server/backends/NullBackend.java                         |    4 
 opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/StandardObjectClassPanel.java   |   10 
 opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/Utilities.java                |   80 ++++----
 opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/NewSchemaElementsTask.java    |   82 ++++----
 /dev/null                                                                                              |  162 ------------------
 opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/StandardAttributePanel.java     |    3 
 opendj-server-legacy/src/main/java/org/opends/server/schema/ServerSchemaElement.java                   |   93 +++------
 opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java                       |    2 
 opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/NewIndexPanel.java              |    6 
 opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/CustomAttributePanel.java       |    7 
 16 files changed, 162 insertions(+), 354 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/ServerDescriptor.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/ServerDescriptor.java
index 54a31c8..2ae8d92 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/ServerDescriptor.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/ServerDescriptor.java
@@ -32,14 +32,13 @@
 import org.forgerock.opendj.ldap.schema.ObjectClass;
 import org.opends.guitools.controlpanel.util.ConfigFromDirContext;
 import org.opends.quicksetup.UserData;
-import org.opends.server.schema.ServerSchemaElement;
 import org.opends.server.tools.tasks.TaskEntry;
 import org.opends.server.types.Schema;
 
 import com.forgerock.opendj.util.OperatingSystem;
 
 import static org.opends.guitools.controlpanel.datamodel.BasicMonitoringAttributes.*;
-import static org.opends.server.types.CommonSchemaElements.*;
+import static org.opends.server.schema.ServerSchemaElement.*;
 
 /**
  * This is just a class used to provide a data model describing what the
@@ -608,8 +607,7 @@
         && attr1.isOperational() == attr2.isOperational()
         && attr1.isSingleValue() == attr2.isSingleValue()
         && areEqual(attr1.getApproximateMatchingRule(), attr2.getApproximateMatchingRule())
-        && areEqual(new ServerSchemaElement(attr1).getDefinitionWithFileName(),
-            new ServerSchemaElement(attr2).getDefinitionWithFileName())
+        && areEqual(getDefinitionWithFileName(attr1), getDefinitionWithFileName(attr2))
         && areEqual(attr1.getDescription(), attr2.getDescription())
         && areEqual(attr1.getEqualityMatchingRule(), attr2.getEqualityMatchingRule())
         && areEqual(attr1.getOrderingMatchingRule(), attr2.getOrderingMatchingRule())
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/DeleteSchemaElementsTask.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/DeleteSchemaElementsTask.java
index db28e62..3184ebc 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/DeleteSchemaElementsTask.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/DeleteSchemaElementsTask.java
@@ -222,15 +222,13 @@
     int numberDeleted = 0;
     for (ObjectClass objectClass : ocsToDelete)
     {
-      final ServerSchemaElement element = new ServerSchemaElement(objectClass);
-      deleteSchemaElement(element, numberDeleted, totalNumber, INFO_CTRL_PANEL_DELETING_OBJECTCLASS);
+      deleteSchemaElement(objectClass, numberDeleted, totalNumber, INFO_CTRL_PANEL_DELETING_OBJECTCLASS);
       numberDeleted++;
     }
 
     for (AttributeType attribute : attrsToDelete)
     {
-      final ServerSchemaElement element = new ServerSchemaElement(attribute);
-      deleteSchemaElement(element, numberDeleted, totalNumber, INFO_CTRL_PANEL_DELETING_ATTRIBUTE);
+      deleteSchemaElement(attribute, numberDeleted, totalNumber, INFO_CTRL_PANEL_DELETING_ATTRIBUTE);
       numberDeleted++;
     }
 
@@ -256,7 +254,7 @@
     }
   }
 
-  private void deleteSchemaElement(final ServerSchemaElement element, final int numberDeleted, final int totalNumber,
+  private void deleteSchemaElement(final SchemaElement element, final int numberDeleted, final int totalNumber,
       final Arg1<Object> deletingElementMsg) throws OnlineUpdateException, OpenDsException
   {
     SwingUtilities.invokeLater(new Runnable()
@@ -317,7 +315,7 @@
    * @param schemaElement the schema element to be deleted.
    * @throws OpenDsException if an error occurs.
    */
-  private void updateSchemaFile(ServerSchemaElement schemaElement) throws OpenDsException
+  private void updateSchemaFile(SchemaElement schemaElement) throws OpenDsException
   {
     String schemaFile = getSchemaFile(schemaElement);
 
@@ -348,9 +346,9 @@
    * @param element the schema element.
    * @return the schema file for a given schema element.
    */
-  private String getSchemaFile(ServerSchemaElement element)
+  private String getSchemaFile(SchemaElement element)
   {
-    String schemaFile = element.getSchemaFile();
+    String schemaFile = ServerSchemaElement.getSchemaFile(element);
     if (schemaFile == null)
     {
       schemaFile = ConfigConstants.FILE_USER_SCHEMA_ELEMENTS;
@@ -370,7 +368,7 @@
    * @param element the schema element.
    * @return the value in the schema file for the provided element.
    */
-  private String getSchemaFileAttributeValue(ServerSchemaElement element)
+  private String getSchemaFileAttributeValue(SchemaElement element)
   {
     return element.toString();
   }
@@ -380,7 +378,7 @@
    * progress dialog.
    * @param element the schema element to be deleted.
    */
-  private void printEquivalentCommandToDelete(ServerSchemaElement element)
+  private void printEquivalentCommandToDelete(SchemaElement element)
   {
     String schemaFile = getSchemaFile(element);
     String attrName = getAttributeConfigName(element);
@@ -413,7 +411,7 @@
     getProgressDialog().appendProgressHtml(Utilities.applyFont(msg, ColorAndFontConstants.progressFont));
   }
 
-  private LocalizableMessage getEquivalentCommandOfflineMsg(ServerSchemaElement element, String schemaFile)
+  private LocalizableMessage getEquivalentCommandOfflineMsg(SchemaElement element, String schemaFile)
   {
     String nameOrOID = getElementNameOrOID(element);
     if (isAttributeType(element))
@@ -423,7 +421,7 @@
     return INFO_CTRL_PANEL_EQUIVALENT_CMD_TO_DELETE_OBJECTCLASS_OFFLINE.get(nameOrOID, schemaFile);
   }
 
-  private LocalizableMessage getEquivalentCommandOnlineMsg(ServerSchemaElement element)
+  private LocalizableMessage getEquivalentCommandOnlineMsg(SchemaElement element)
   {
     String nameOrOID = getElementNameOrOID(element);
     if (isAttributeType(element))
@@ -446,8 +444,7 @@
     }
     if (isSuperior)
     {
-       // get a new attribute without the superior type
-       return updateAttributeTypeWithNewSuperiorType(attrToDelete, null);
+       return getNewAttributeTypeWithNewSuperiorType(attrToDelete, null);
     }
     else
     {
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/ModifyAttributeTask.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/ModifyAttributeTask.java
index 28b19e7..d2c98ea 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/ModifyAttributeTask.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/ModifyAttributeTask.java
@@ -16,6 +16,8 @@
  */
 package org.opends.guitools.controlpanel.task;
 
+import static org.opends.guitools.controlpanel.util.Utilities.getNewAttributeTypeWithNewSuperiorType;
+
 import static org.opends.messages.AdminToolMessages.*;
 import static org.opends.server.util.CollectionUtils.*;
 import static org.opends.server.util.SchemaUtils.*;
@@ -148,7 +150,7 @@
     else if (oldAttribute.equals(attrToDelete.getSuperiorType()))
     {
       // get a new attribute with the new superior type
-      return Utilities.updateAttributeTypeWithNewSuperiorType(attrToDelete, newAttribute);
+      return getNewAttributeTypeWithNewSuperiorType(attrToDelete, newAttribute);
     }
     else
     {
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/NewSchemaElementsTask.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/NewSchemaElementsTask.java
index c844e09..5a70d48 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/NewSchemaElementsTask.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/NewSchemaElementsTask.java
@@ -16,11 +16,11 @@
  */
 package org.opends.guitools.controlpanel.task;
 
-
 import static org.forgerock.opendj.ldap.ModificationType.*;
 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 java.io.File;
 import java.util.ArrayList;
@@ -43,13 +43,13 @@
 import org.forgerock.i18n.LocalizableMessage;
 import org.forgerock.opendj.ldap.schema.AttributeType;
 import org.forgerock.opendj.ldap.schema.ObjectClass;
+import org.forgerock.opendj.ldap.schema.SchemaElement;
 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.config.ConfigConstants;
 import org.opends.server.core.DirectoryServer;
-import org.opends.server.schema.ServerSchemaElement;
 import org.opends.server.types.Attribute;
 import org.opends.server.types.Attributes;
 import org.opends.server.types.DirectoryException;
@@ -169,10 +169,10 @@
     }
   }
 
-  private List<String> getElementsNameOrOID(final Collection<ServerSchemaElement> schemaElements)
+  private List<String> getElementsNameOrOID(final Collection<SchemaElement> schemaElements)
   {
     final List<String> nameOrOIDs = new ArrayList<>();
-    for (ServerSchemaElement schemaElement : schemaElements)
+    for (SchemaElement schemaElement : schemaElements)
     {
       nameOrOIDs.add(getElementNameOrOID(schemaElement));
     }
@@ -245,8 +245,8 @@
   private void updateSchemaOffline() throws OpenDsException
   {
     // Group the changes in the same schema file.
-    final Map<String, List<ServerSchemaElement>> mapAttrs = copy(attributeTypesToSchemaElements(attrsToAdd));
-    final Map<String, List<ServerSchemaElement>> mapClasses = copy(objectClassesToSchemaElements(ocsToAdd));
+    final Map<String, List<SchemaElement>> mapAttrs = copy(attributeTypesToSchemaElements(attrsToAdd));
+    final Map<String, List<SchemaElement>> mapClasses = copy(objectClassesToSchemaElements(ocsToAdd));
     final Set<String> allFileNames = new LinkedHashSet<>(mapAttrs.keySet());
     allFileNames.addAll(mapClasses.keySet());
 
@@ -264,23 +264,23 @@
     }
   }
 
-  private List<ServerSchemaElement> get(Map<String, List<ServerSchemaElement>> hmElems, String fileName)
+  private List<SchemaElement> get(Map<String, List<SchemaElement>> hmElems, String fileName)
   {
-    List<ServerSchemaElement> elems = hmElems.get(fileName);
-    return elems != null ? elems : Collections.<ServerSchemaElement> emptyList();
+    List<SchemaElement> elems = hmElems.get(fileName);
+    return elems != null ? elems : Collections.<SchemaElement> emptyList();
   }
 
-  private Map<String, List<ServerSchemaElement>> copy(Set<ServerSchemaElement> elemsToAdd)
+  private Map<String, List<SchemaElement>> copy(Set<SchemaElement> elemsToAdd)
   {
-    Map<String, List<ServerSchemaElement>> hmElems = new LinkedHashMap<>();
-    for (ServerSchemaElement elem : elemsToAdd)
+    Map<String, List<SchemaElement>> hmElems = new LinkedHashMap<>();
+    for (SchemaElement elem : elemsToAdd)
     {
-      String fileName = elem.getSchemaFile();
+      String fileName = getSchemaFile(elem);
       if (fileName == null)
       {
         fileName = "";
       }
-      List<ServerSchemaElement> elems = hmElems.get(fileName);
+      List<SchemaElement> elems = hmElems.get(fileName);
       if (elems == null)
       {
         elems = new ArrayList<>();
@@ -293,17 +293,17 @@
 
   private void addAttributeOnline(final AttributeType attribute) throws OpenDsException
   {
-    addSchemaElementOnline(new ServerSchemaElement(attribute),
+    addSchemaElementOnline(attribute,
         INFO_CTRL_PANEL_CREATING_ATTRIBUTE_PROGRESS.get(attribute.getNameOrOID()));
   }
 
   private void addObjectClassOnline(final ObjectClass objectClass) throws OpenDsException
   {
-    addSchemaElementOnline(new ServerSchemaElement(objectClass),
+    addSchemaElementOnline(objectClass,
         INFO_CTRL_PANEL_CREATING_OBJECTCLASS_PROGRESS.get(objectClass.getNameOrOID()));
   }
 
-  private void addSchemaElementOnline(final ServerSchemaElement schemaElement, final LocalizableMessage progressMsg)
+  private void addSchemaElementOnline(final SchemaElement schemaElement, final LocalizableMessage progressMsg)
       throws OpenDsException
   {
     SwingUtilities.invokeLater(new Runnable()
@@ -340,48 +340,48 @@
   }
 
   /** Returns the definition for provided element without the file name. */
-  private String getValueOffline(ServerSchemaElement element)
+  private String getValueOffline(SchemaElement element)
   {
     return updateSchemaElementExtraPropertySingleValue(null, element, ServerConstants.SCHEMA_PROPERTY_FILENAME, null)
         .toString();
   }
 
-  private Set<ServerSchemaElement> objectClassesToSchemaElements(final Collection<ObjectClass> classes)
+  private Set<SchemaElement> objectClassesToSchemaElements(final Collection<ObjectClass> classes)
   {
-    Set<ServerSchemaElement> elements = new HashSet<>();
+    Set<SchemaElement> elements = new HashSet<>();
     for (ObjectClass objectClass : classes)
     {
-      elements.add(new ServerSchemaElement(objectClass));
+      elements.add(objectClass);
     }
     return elements;
   }
 
-  private Set<ServerSchemaElement> attributeTypesToSchemaElements(final Collection<AttributeType> types)
+  private Set<SchemaElement> attributeTypesToSchemaElements(final Collection<AttributeType> types)
   {
-    Set<ServerSchemaElement> elements = new HashSet<>();
+    Set<SchemaElement> elements = new HashSet<>();
     for (AttributeType type : types)
     {
-      elements.add(new ServerSchemaElement(type));
+      elements.add(type);
     }
     return elements;
   }
 
-  private List<AttributeType> schemaElementsToAttributeTypes(final Collection<ServerSchemaElement> elements)
+  private List<AttributeType> schemaElementsToAttributeTypes(final Collection<SchemaElement> elements)
   {
     List<AttributeType> types = new ArrayList<>();
-    for (ServerSchemaElement element : elements)
+    for (SchemaElement element : elements)
     {
-      types.add((AttributeType) element.asSchemaElement());
+      types.add((AttributeType) element);
     }
     return types;
   }
 
-  private List<ObjectClass> schemaElementsToObjectClasses(final Collection<ServerSchemaElement> elements)
+  private List<ObjectClass> schemaElementsToObjectClasses(final Collection<SchemaElement> elements)
   {
     List<ObjectClass> classes = new ArrayList<>();
-    for (ServerSchemaElement element : elements)
+    for (SchemaElement element : elements)
     {
-      classes.add((ObjectClass) element.asSchemaElement());
+      classes.add((ObjectClass) element);
     }
     return classes;
   }
@@ -411,7 +411,7 @@
     }
   }
 
-  private void printEquivalentCommandLineToAddOnline(ServerSchemaElement element)
+  private void printEquivalentCommandLineToAddOnline(SchemaElement element)
   {
     List<String> args = new ArrayList<>();
     args.add("-a");
@@ -437,8 +437,8 @@
   private void updateSchemaOffline(
       String file, final List<AttributeType> attributes, final List<ObjectClass> objectClasses) throws OpenDsException
   {
-    final List<ServerSchemaElement> schemaElements =
-        new ArrayList<ServerSchemaElement>(attributeTypesToSchemaElements(attributes));
+    final List<SchemaElement> schemaElements =
+        new ArrayList<SchemaElement>(attributeTypesToSchemaElements(attributes));
     schemaElements.addAll(objectClassesToSchemaElements(objectClasses));
     if (file == null)
     {
@@ -489,7 +489,7 @@
       updateSchemaUndefinedFile(fileName, schemaElements);
     }
 
-    for (ServerSchemaElement schemaElement : schemaElements)
+    for (SchemaElement schemaElement : schemaElements)
     {
       notifyConfigurationElementCreated(schemaElement);
     }
@@ -504,7 +504,7 @@
   }
 
   private String equivalentCommandToAddOffline(
-      String schemaFile, boolean isSchemaFileDefined, List<ServerSchemaElement> schemaElements)
+      String schemaFile, boolean isSchemaFileDefined, List<SchemaElement> schemaElements)
   {
     List<String> names = getElementsNameOrOID(schemaElements);
 
@@ -526,7 +526,7 @@
       }
     }
 
-    for (ServerSchemaElement element : schemaElements)
+    for (SchemaElement element : schemaElements)
     {
       sb.append(getAttributeConfigName(element)).append(": ").append(getValueOffline(element)).append("<br>");
     }
@@ -586,7 +586,7 @@
    * @throws OpenDsException
    *           if an error occurs updating the schema file.
    */
-  private void updateSchemaFile(String schemaFile, List<ServerSchemaElement> schemaElements)
+  private void updateSchemaFile(String schemaFile, List<SchemaElement> schemaElements)
       throws OpenDsException
   {
     try (final LDIFExportConfig exportConfig = new LDIFExportConfig(schemaFile, ExistingFileBehavior.OVERWRITE))
@@ -608,23 +608,23 @@
     }
   }
 
-  private void addElementsToEntry(List<ServerSchemaElement> schemaElements, Entry schemaEntry)
+  private void addElementsToEntry(List<SchemaElement> schemaElements, Entry schemaEntry)
       throws DirectoryException
   {
-    for (ServerSchemaElement element : schemaElements)
+    for (SchemaElement element : schemaElements)
     {
       Attribute attr = Attributes.create(getAttributeConfigName(element), getValueOffline(element));
       schemaEntry.applyModification(new Modification(ADD, attr));
     }
   }
 
-  private void updateSchemaUndefinedFile(String schemaFile, List<ServerSchemaElement> schemaElements)
+  private void updateSchemaUndefinedFile(String schemaFile, List<SchemaElement> schemaElements)
       throws OfflineUpdateException
   {
     try (LDIFExportConfig exportConfig = new LDIFExportConfig(schemaFile, ExistingFileBehavior.FAIL))
     {
       List<String> lines = getSchemaEntryLines();
-      for (final ServerSchemaElement element : schemaElements)
+      for (final SchemaElement element : schemaElements)
       {
         lines.add(getAttributeConfigName(element) + ": " + getValueOffline(element));
       }
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/AbstractVLVIndexPanel.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/AbstractVLVIndexPanel.java
index 80a9e49..cb34fcb 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/AbstractVLVIndexPanel.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/AbstractVLVIndexPanel.java
@@ -80,7 +80,6 @@
 import org.opends.quicksetup.Installation;
 import org.opends.server.config.ConfigException;
 import org.opends.server.protocols.ldap.LDAPFilter;
-import org.opends.server.schema.ServerSchemaElement;
 import org.opends.server.types.FilterType;
 import org.opends.server.types.LDAPException;
 import org.opends.server.types.OpenDsException;
@@ -320,15 +319,14 @@
 
         for (AttributeType attr : schema.getAttributeTypes())
         {
-          ServerSchemaElement element = new ServerSchemaElement(attr);
           String name = attr.getNameOrOID();
           if (!isDefined(name))
           {
-            if (Utilities.isStandard(element))
+            if (Utilities.isStandard(attr))
             {
               standardAttrNames.add(name);
             }
-            else if (Utilities.isConfiguration(element))
+            else if (Utilities.isConfiguration(attr))
             {
               configurationAttrNames.add(name);
             }
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/BrowseSchemaPanel.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/BrowseSchemaPanel.java
index f4eabd6..4df822c 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/BrowseSchemaPanel.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/BrowseSchemaPanel.java
@@ -16,8 +16,6 @@
  */
 package org.opends.guitools.controlpanel.ui;
 
-import static org.opends.guitools.controlpanel.util.Utilities.getElementNameOrOID;
-
 import static org.opends.messages.AdminToolMessages.*;
 import static org.opends.server.util.StaticUtils.*;
 
@@ -71,6 +69,7 @@
 import org.forgerock.opendj.ldap.schema.AttributeType;
 import org.forgerock.opendj.ldap.schema.MatchingRule;
 import org.forgerock.opendj.ldap.schema.ObjectClass;
+import org.forgerock.opendj.ldap.schema.SchemaElement;
 import org.forgerock.opendj.ldap.schema.Syntax;
 import org.opends.guitools.controlpanel.browser.IconPool;
 import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo;
@@ -141,7 +140,7 @@
 
   private JPopupMenu popup;
 
-  private ServerSchemaElement lastCreatedElement;
+  private SchemaElement lastCreatedElement;
 
   private final CategoryTreeNode attributes = new CategoryTreeNode(INFO_CTRL_PANEL_ATTRIBUTES_CATEGORY_NODE.get());
   private final CategoryTreeNode objectClasses =
@@ -671,14 +670,13 @@
     {
       if (mustAdd(oc))
       {
-        ServerSchemaElement element = new ServerSchemaElement(oc);
         String name = oc.getNameOrOID();
-        if (Utilities.isStandard(element))
+        if (Utilities.isStandard(oc))
         {
           standardOcNames.add(name);
           hmStandardOcs.put(name, new StandardObjectClassTreeNode(name, oc));
         }
-        else if (Utilities.isConfiguration(element))
+        else if (Utilities.isConfiguration(oc))
         {
           configurationOcNames.add(name);
           hmConfigurationOcs.put(name, new ConfigurationObjectClassTreeNode(name, oc));
@@ -699,16 +697,15 @@
     Map<String, CustomAttributeTreeNode> hmCustomAttrs = new HashMap<>();
     for (AttributeType attr : lastSchema.getAttributeTypes())
     {
-      ServerSchemaElement element = new ServerSchemaElement(attr);
       if (mustAdd(attr))
       {
         String name = attr.getNameOrOID();
-        if (Utilities.isStandard(element))
+        if (Utilities.isStandard(attr))
         {
           standardAttrNames.add(name);
           hmStandardAttrs.put(name, new StandardAttributeTreeNode(name, attr));
         }
-        else if (Utilities.isConfiguration(element))
+        else if (Utilities.isConfiguration(attr))
         {
           configurationAttrNames.add(name);
           hmConfigurationAttrs.put(name, new ConfigurationAttributeTreeNode(name, attr));
@@ -872,7 +869,7 @@
             if (lastCreatedElement != null)
             {
               if (node instanceof CustomObjectClassTreeNode
-                  && name.equals(getElementNameOrOID(lastCreatedElement)))
+                  && name.equals(Utilities.getElementNameOrOID(lastCreatedElement)))
               {
                 newSelectionPath = new TreePath(node.getPath());
                 lastCreatedElement = null;
@@ -1464,9 +1461,9 @@
   private void configurationElementCreated(ConfigurationElementCreatedEvent ev)
   {
     Object o = ev.getConfigurationObject();
-    if (o instanceof ServerSchemaElement)
+    if (o instanceof SchemaElement)
     {
-      lastCreatedElement = (ServerSchemaElement) o;
+      lastCreatedElement = (SchemaElement) o;
     }
   }
 
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/CustomAttributePanel.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/CustomAttributePanel.java
index 29ddce9..5df2ca2 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/CustomAttributePanel.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/CustomAttributePanel.java
@@ -18,6 +18,7 @@
 
 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 java.awt.Component;
@@ -83,7 +84,6 @@
 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.schema.ServerSchemaElement;
 import org.opends.server.types.Schema;
 import org.opends.server.util.ServerConstants;
 import org.opends.server.util.StaticUtils;
@@ -526,15 +526,14 @@
     lastAliases.addAll(someAliases);
     this.aliases.setText(Utilities.getStringFromCollection(someAliases, ", "));
 
-    ServerSchemaElement element = new ServerSchemaElement(attr);
-    String sOrigin = element.getOrigin();
+    String sOrigin = getOrigin(attr);
     if (sOrigin == null)
     {
       sOrigin = "";
     }
     origin.setText(sOrigin);
 
-    String sFile = element.getSchemaFile();
+    String sFile = getSchemaFile(attr);
     if (sFile == null)
     {
       sFile = "";
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/CustomObjectClassPanel.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/CustomObjectClassPanel.java
index abe8968..4bb5706 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/CustomObjectClassPanel.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/CustomObjectClassPanel.java
@@ -17,7 +17,7 @@
 package org.opends.guitools.controlpanel.ui;
 
 import static org.opends.messages.AdminToolMessages.*;
-import static org.opends.server.types.CommonSchemaElements.*;
+import static org.opends.server.schema.ServerSchemaElement.*;
 import static org.opends.server.util.CollectionUtils.*;
 import static org.opends.server.util.SchemaUtils.*;
 
@@ -80,7 +80,6 @@
 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.schema.ServerSchemaElement;
 import org.opends.server.types.Schema;
 import org.opends.server.util.ServerConstants;
 import org.opends.server.util.StaticUtils;
@@ -500,7 +499,7 @@
     lastAliases.addAll(aliases);
     this.aliases.setText(Utilities.getStringFromCollection(aliases, ", "));
 
-    String sOrigin = new ServerSchemaElement(oc).getOrigin();
+    String sOrigin = getOrigin(oc);
     if (sOrigin == null)
     {
       sOrigin = "";
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/NewIndexPanel.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/NewIndexPanel.java
index eeb96f3..64e97ec 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/NewIndexPanel.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/NewIndexPanel.java
@@ -52,7 +52,6 @@
 import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent;
 import org.opends.guitools.controlpanel.task.Task;
 import org.opends.guitools.controlpanel.util.Utilities;
-import org.opends.server.schema.ServerSchemaElement;
 import org.opends.server.types.Schema;
 
 /** Panel that appears when the user defines a new index. */
@@ -125,15 +124,14 @@
       TreeSet<String> customAttrNames = new TreeSet<>();
       for (AttributeType attr : schema.getAttributeTypes())
       {
-        ServerSchemaElement element = new ServerSchemaElement(attr);
         String name = attr.getNameOrOID();
         if (!indexExists(backend, name))
         {
-          if (Utilities.isStandard(element))
+          if (Utilities.isStandard(attr))
           {
             standardAttrNames.add(name);
           }
-          else if (Utilities.isConfiguration(element))
+          else if (Utilities.isConfiguration(attr))
           {
             configurationAttrNames.add(name);
           }
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/StandardAttributePanel.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/StandardAttributePanel.java
index 1891cc0..dd20605 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/StandardAttributePanel.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/StandardAttributePanel.java
@@ -44,7 +44,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 attribute definition. */
@@ -237,7 +236,7 @@
     n = superior != null ? superior.getNameOrOID() : null;
     parent.setText(n);
     oid.setText(attr.getOID());
-    origin.setText(StandardObjectClassPanel.getOrigin(new ServerSchemaElement(attr)).toString());
+    origin.setText(StandardObjectClassPanel.getOrigin(attr).toString());
     n = attr.getDescription();
     if (n == null)
     {
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/StandardObjectClassPanel.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/StandardObjectClassPanel.java
index 53429a7..a55a809 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/StandardObjectClassPanel.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/StandardObjectClassPanel.java
@@ -18,6 +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.StaticUtils.*;
 
 import java.awt.Component;
@@ -44,6 +45,7 @@
 import org.forgerock.i18n.LocalizableMessageBuilder;
 import org.forgerock.opendj.ldap.schema.AttributeType;
 import org.forgerock.opendj.ldap.schema.ObjectClass;
+import org.forgerock.opendj.ldap.schema.SchemaElement;
 import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent;
 import org.opends.guitools.controlpanel.ui.components.TitlePanel;
 import org.opends.guitools.controlpanel.util.LowerCaseComparator;
@@ -239,11 +241,11 @@
    * @param element the schema element.
    * @return the message describing the schema element origin (file, RFC, etc.).
    */
-  static LocalizableMessage getOrigin(ServerSchemaElement element)
+  static LocalizableMessage getOrigin(SchemaElement element)
   {
     LocalizableMessageBuilder returnValue = new LocalizableMessageBuilder();
-    String fileName = element.getSchemaFile();
-    String xOrigin = element.getOrigin();
+    String fileName = getSchemaFile(element);
+    String xOrigin = ServerSchemaElement.getOrigin(element);
     if (xOrigin != null)
     {
       returnValue.append(xOrigin);
@@ -287,7 +289,7 @@
     name.setText(n);
     parent.setText(getSuperiorText(oc));
     oid.setText(oc.getOID());
-    origin.setText(getOrigin(new ServerSchemaElement(oc)).toString());
+    origin.setText(getOrigin(oc).toString());
     n = oc.getDescription();
     if (n == null)
     {
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/Utilities.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/Utilities.java
index 626d44e..1c10f6c 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/Utilities.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/Utilities.java
@@ -25,6 +25,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 java.awt.Color;
 import java.awt.Component;
@@ -133,7 +134,6 @@
 import org.opends.server.core.LockFileManager;
 import org.opends.server.core.ServerContext;
 import org.opends.server.schema.SchemaConstants;
-import org.opends.server.schema.ServerSchemaElement;
 import org.opends.server.types.OpenDsException;
 import org.opends.server.types.Schema;
 import org.opends.server.util.SchemaUtils;
@@ -1995,14 +1995,14 @@
    * @return {@code true} if the provided schema element is part of the standard,
    *         {@code false} otherwise.
    */
-  public static boolean isStandard(ServerSchemaElement fileElement)
+  public static boolean isStandard(SchemaElement fileElement)
   {
-    final String fileName = fileElement.getSchemaFile();
+    final String fileName = getSchemaFile(fileElement);
     if (fileName != null)
     {
       return standardSchemaFileNames.contains(fileName) || fileName.toLowerCase().contains("-rfc");
     }
-    String xOrigin = fileElement.getOrigin();
+    String xOrigin = getOrigin(fileElement);
     if (xOrigin != null)
     {
       return standardSchemaOrigins.contains(xOrigin) || xOrigin.startsWith("RFC ") || xOrigin.startsWith("draft-");
@@ -2017,14 +2017,14 @@
    * @return {@code true} if the provided schema element is part of the configuration,
    *         {@code false} otherwise.
    */
-  public static boolean isConfiguration(ServerSchemaElement fileElement)
+  public static boolean isConfiguration(SchemaElement fileElement)
   {
-    String fileName = fileElement.getSchemaFile();
+    String fileName = getSchemaFile(fileElement);
     if (fileName != null)
     {
       return configurationSchemaFileNames.contains(fileName);
     }
-    String xOrigin = fileElement.getOrigin();
+    String xOrigin = getOrigin(fileElement);
     if (xOrigin != null)
     {
       return configurationSchemaOrigins.contains(xOrigin);
@@ -2816,9 +2816,9 @@
    *            Element to check.
    * @return {@code true} iff element is an attribute type.
    */
-  public static boolean isAttributeType(ServerSchemaElement element)
+  public static boolean isAttributeType(SchemaElement element)
   {
-    return element.asSchemaElement() instanceof AttributeType;
+    return element instanceof AttributeType;
   }
 
   /**
@@ -2829,7 +2829,7 @@
    *            Using any other schema element will return invalid result.
    * @return Either "attributeTypes" or "objectClasses"
    */
-  public static String getAttributeConfigName(ServerSchemaElement element)
+  public static String getAttributeConfigName(SchemaElement element)
   {
     return isAttributeType(element) ? ConfigConstants.ATTR_ATTRIBUTE_TYPES : ConfigConstants.ATTR_OBJECTCLASSES;
   }
@@ -2842,14 +2842,17 @@
    *            Using any other schema element will yield an exception.
    * @return Either "attributeTypes" or "objectClasses"
    */
-  public static String getElementNameOrOID(ServerSchemaElement element)
+  public static String getElementNameOrOID(SchemaElement element)
   {
-    SchemaElement elem = element.asSchemaElement();
-    if (elem instanceof AttributeType)
+    if (element instanceof AttributeType)
     {
-      return ((AttributeType) elem).getNameOrOID();
+      return ((AttributeType) element).getNameOrOID();
     }
-    return ((ObjectClass) elem).getNameOrOID();
+    else if (element instanceof ObjectClass)
+    {
+      return ((ObjectClass) element).getNameOrOID();
+    }
+    throw new RuntimeException("getElementNameOrOID() not implemented for element of type " + element.getClass());
   }
 
   /**
@@ -2860,14 +2863,17 @@
    *            Using any other schema element will yield an exception.
    * @return Either "attributeTypes" or "objectClasses"
    */
-  public static String getElementOID(ServerSchemaElement element)
+  public static String getElementOID(SchemaElement element)
   {
-    SchemaElement elem = element.asSchemaElement();
-    if (elem instanceof AttributeType)
+    if (element instanceof AttributeType)
     {
-      return ((AttributeType) elem).getOID();
+      return ((AttributeType) element).getOID();
     }
-    return ((ObjectClass) elem).getOID();
+    else if (element instanceof ObjectClass)
+    {
+      return ((ObjectClass) element).getOID();
+    }
+    throw new RuntimeException("getElementOID() not implemented for element of type " + element.getClass());
   }
 
   /**
@@ -2879,7 +2885,7 @@
    *            new superior type to use.
    * @return the new attribute type
    */
-  public static AttributeType updateAttributeTypeWithNewSuperiorType(AttributeType attributeType,
+  public static AttributeType getNewAttributeTypeWithNewSuperiorType(AttributeType attributeType,
       AttributeType newSuperiorType)
   {
     String superiorTypeOID = newSuperiorType != null ? newSuperiorType.getNameOrOID() : null;
@@ -2905,8 +2911,8 @@
    *          the value to set
    * @return the updated schema element
    */
-  public static ServerSchemaElement updateSchemaElementExtraPropertySingleValue(ServerContext serverContext,
-      ServerSchemaElement element, String property, String value)
+  public static SchemaElement updateSchemaElementExtraPropertySingleValue(ServerContext serverContext,
+      SchemaElement element, String property, String value)
   {
     List<String> values = value != null ? Arrays.asList(value) : null;
     return updateSchemaElementExtraPropertyMultiplesValues(serverContext, element, property, values);
@@ -2926,32 +2932,34 @@
    *          the list of values to set
    * @return the updated schema element
    */
-  public static ServerSchemaElement updateSchemaElementExtraPropertyMultiplesValues(ServerContext serverContext,
-      ServerSchemaElement element, String property, List<String> values)
+  public static SchemaElement updateSchemaElementExtraPropertyMultiplesValues(ServerContext serverContext,
+      SchemaElement element, String property, List<String> values)
   {
     org.forgerock.opendj.ldap.schema.Schema schemaNG = serverContext != null ?
         serverContext.getSchemaNG() : org.forgerock.opendj.ldap.schema.Schema.getDefaultSchema();
     SchemaBuilder schemaBuilder = new SchemaBuilder(schemaNG);
-    SchemaElement elem = element.asSchemaElement();
-    if (elem instanceof AttributeType)
+    if (element instanceof AttributeType)
     {
-       AttributeType attr = (AttributeType) elem;
+      AttributeType attr = (AttributeType) element;
       AttributeType.Builder builder =
           schemaBuilder.buildAttributeType(attr).removeExtraProperty(property, (String) null);
       if (values != null  && !values.isEmpty())
       {
         builder.extraProperties(property, values);
       }
-      return new ServerSchemaElement(builder.addToSchemaOverwrite().toSchema().getAttributeType(attr.getNameOrOID()));
+      return builder.addToSchemaOverwrite().toSchema().getAttributeType(attr.getNameOrOID());
     }
-    // It is an object class
-    ObjectClass oc = (ObjectClass) elem;
-    ObjectClass.Builder builder = schemaBuilder.buildObjectClass(oc).removeExtraProperty(property, (String) null);
-    if (values != null && !values.isEmpty())
+    else if (element instanceof ObjectClass)
     {
-      builder.extraProperties(property, values);
+      ObjectClass oc = (ObjectClass) element;
+      ObjectClass.Builder builder = schemaBuilder.buildObjectClass(oc).removeExtraProperty(property, (String) null);
+      if (values != null && !values.isEmpty())
+      {
+        builder.extraProperties(property, values);
+      }
+      return builder.addToSchemaOverwrite().toSchema().getObjectClass(oc.getNameOrOID());
     }
-    return new ServerSchemaElement(builder.addToSchemaOverwrite().toSchema().getObjectClass(oc.getNameOrOID()));
+    throw new RuntimeException("updateSchemaElementExtraPropertyMultiplesValues() not implemented for element of type "
+        + element.getClass());
   }
-
 }
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/NullBackend.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/NullBackend.java
index b72707e..7baca5b 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/NullBackend.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/NullBackend.java
@@ -18,6 +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.ServerConstants.*;
 import static org.opends.server.util.StaticUtils.*;
 
@@ -45,7 +46,6 @@
 import org.opends.server.core.ModifyOperation;
 import org.opends.server.core.SearchOperation;
 import org.opends.server.core.ServerContext;
-import org.opends.server.schema.ServerSchemaElement;
 import org.opends.server.types.BackupConfig;
 import org.opends.server.types.BackupDirectory;
 import org.opends.server.types.DirectoryException;
@@ -150,7 +150,7 @@
     String nulOCName = "nullbackendobject";
     ObjectClass nulOC = DirectoryServer.getSchema().getObjectClass(nulOCName);
     try {
-      DirectoryServer.getSchema().registerObjectClass(nulOC, new ServerSchemaElement(nulOC).getSchemaFile(), false);
+      DirectoryServer.getSchema().registerObjectClass(nulOC, getSchemaFile(nulOC), false);
     } catch (DirectoryException de) {
       logger.traceException(de);
       throw new InitializationException(de.getMessageObject());
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java
index 0131773..25fb218 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java
@@ -24,7 +24,7 @@
 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.types.CommonSchemaElements.*;
+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.StaticUtils.*;
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/schema/ServerSchemaElement.java b/opendj-server-legacy/src/main/java/org/opends/server/schema/ServerSchemaElement.java
index 4ecf477..b455cb8 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/schema/ServerSchemaElement.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/schema/ServerSchemaElement.java
@@ -15,89 +15,58 @@
  */
 package org.opends.server.schema;
 
-import static org.opends.server.types.Schema.*;
+import static org.opends.server.types.Schema.addSchemaFileToElementDefinitionIfAbsent;
+import static org.opends.messages.SchemaMessages.ERR_ATTR_SYNTAX_ILLEGAL_X_SCHEMA_FILE;
+import static org.opends.server.util.ServerConstants.SCHEMA_PROPERTY_FILENAME;
 
 import java.util.List;
-import java.util.Map;
 
+import org.forgerock.i18n.LocalizableMessage;
+import org.forgerock.opendj.ldap.ResultCode;
 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.SchemaElement;
 import org.opends.server.core.ServerContext;
+import org.opends.server.types.DirectoryException;
 import org.opends.server.util.ServerConstants;
 
 /**
- * Provides common operations for server schema elements.
+ * Utility class that provides common operations over schema elements in a server context.
  */
 public class ServerSchemaElement
 {
 
-  /** The underlying schema element. */
-  private final SchemaElement element;
+  private ServerSchemaElement()
+  {
+    // prevent instantiation
+  }
 
   /**
-   * Creates an element.
+   * Retrieves the definition string used to create the provided schema element and including the
+   * X-SCHEMA-FILE extension.
    *
    * @param element
-   *            The schema element to wrap.
+   *            The schema element.
+   * @return The definition string used to create the schema element including the X-SCHEMA-FILE
+   *         extension.
    */
-  public ServerSchemaElement(SchemaElement element)
-  {
-    this.element = element;
-  }
-
-  /**
-   * Returns this schema element.
-   *
-   * @return this schema element
-   */
-  public SchemaElement asSchemaElement()
-  {
-    return this.element;
-  }
-
-  /**
-   * Retrieves the definition string used to create this schema element
-   * 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()
+  public static String getDefinitionWithFileName(SchemaElement element)
   {
     final String definition = element.toString();
-    return addSchemaFileToElementDefinitionIfAbsent(definition, getSchemaFile());
+    return addSchemaFileToElementDefinitionIfAbsent(definition, getSchemaFile(element));
   }
 
   /**
-   * Returns the description of this schema element.
+   * Returns the single value of the provided extra property for the provided schema element.
    *
-   * @return The description of this schema element, or the empty string if it does not have a description.
-   */
-  public String getDescription()
-  {
-    return element.getDescription();
-  }
-
-  /**
-   * Returns a map of extra properties of this schema element.
-   *
-   * @return An unmodifiable map containing all of the extra properties associated with this schema element.
-   */
-  public Map<String, List<String>> getExtraProperties()
-  {
-    return element.getExtraProperties();
-  }
-
-  /**
-   * Returns the single value of the provided extra property.
-   *
+   * @param element
+   *            The schema element.
    * @param property
    *            The name of property to retrieve.
-   * @return the single value of the property
+   * @return the single value of the extra property
    */
-  public String getExtraPropertyAsSingleValue(String property)
+  public static String getExtraPropertyAsSingleValue(SchemaElement element, String property)
   {
     List<String> values = element.getExtraProperties().get(property);
     return values != null && !values.isEmpty() ? values.get(0) : null;
@@ -106,21 +75,25 @@
   /**
    * Returns the origin of the provided schema element.
    *
-   * @return 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 String getOrigin()
+  public static String getOrigin(SchemaElement element)
   {
-    return getExtraPropertyAsSingleValue(ServerConstants.SCHEMA_PROPERTY_ORIGIN);
+    return getExtraPropertyAsSingleValue(element, ServerConstants.SCHEMA_PROPERTY_ORIGIN);
   }
 
   /**
    * Returns the schema file of the provided schema element.
    *
-   * @return the schema file of the provided schema element.
+   * @param element
+   *            The schema element.
+   * @return the schema file of schema element.
    */
-  public String getSchemaFile()
+  public static String getSchemaFile(SchemaElement element)
   {
-    return getExtraPropertyAsSingleValue(ServerConstants.SCHEMA_PROPERTY_FILENAME);
+    return getExtraPropertyAsSingleValue(element, ServerConstants.SCHEMA_PROPERTY_FILENAME);
   }
 
   /**
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/types/CommonSchemaElements.java b/opendj-server-legacy/src/main/java/org/opends/server/types/CommonSchemaElements.java
deleted file mode 100644
index acb30f3..0000000
--- a/opendj-server-legacy/src/main/java/org/opends/server/types/CommonSchemaElements.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * The contents of this file are subject to the terms of the Common Development and
- * Distribution License (the License). You may not use this file except in compliance with the
- * License.
- *
- * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
- * specific language governing permission and limitations under the License.
- *
- * When distributing Covered Software, include this CDDL Header Notice in each file and include
- * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
- * Header, with the fields enclosed by brackets [] replaced by your own identifying
- * information: "Portions Copyright [year] [name of copyright owner]".
- *
- * Copyright 2006-2009 Sun Microsystems, Inc.
- * Portions Copyright 2013-2016 ForgeRock AS.
- */
-package org.opends.server.types;
-
-import static org.forgerock.util.Reject.*;
-import static org.opends.messages.SchemaMessages.*;
-import static org.opends.server.util.CollectionUtils.*;
-import static org.opends.server.util.ServerConstants.*;
-
-import java.util.List;
-import java.util.Map;
-
-import org.forgerock.i18n.LocalizableMessage;
-import org.forgerock.opendj.ldap.ResultCode;
-import org.forgerock.opendj.ldap.schema.SchemaElement;
-import org.opends.server.util.RemoveOnceSDKSchemaIsUsed;
-
-/**
- * Utility class to retrieve information from a SchemaElement and to set extra property
- * for a SchemaElement.
- * <p>
- * Note that {@code setSchemaFile()} method works ONLY for non-SDK classes, because SDK schema
- * elements are immutable, so modifying the map for extra properties has no effect on the actual
- * element.
- */
-@RemoveOnceSDKSchemaIsUsed("All read methods can be provided by ServerSchemaElement class. Write method" +
- " has to rebuild fully the schema element within the schema, which means specific code for each element")
-public final class CommonSchemaElements
-{
-  private CommonSchemaElements()
-  {
-    // private for utility classes
-  }
-
-  /**
-   * Check if the extra schema properties contain safe filenames.
-   *
-   * @param extraProperties
-   *          The schema properties to check.
-   *
-   * @throws DirectoryException
-   *          If a provided value was unsafe.
-   */
-  public static void checkSafeProperties(Map <String,List<String>>
-      extraProperties)
-      throws DirectoryException
-  {
-    // Check that X-SCHEMA-FILE doesn't contain unsafe characters
-    List<String> filenames = extraProperties.get(SCHEMA_PROPERTY_FILENAME);
-    if (filenames != null && !filenames.isEmpty()) {
-      String filename = filenames.get(0);
-      if (filename.indexOf('/') != -1 || filename.indexOf('\\') != -1)
-      {
-        LocalizableMessage message = ERR_ATTR_SYNTAX_ILLEGAL_X_SCHEMA_FILE.get(filename);
-        throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION,
-            message);
-      }
-    }
-  }
-
-  /**
-   * Retrieves the name of the schema file that contains the
-   * definition for this schema definition.
-   *
-   * @param elem The element where to get the schema file from
-   * @return The name of the schema file that contains the definition
-   *         for this schema definition, or <code>null</code> if it
-   *         is not known or if it is not stored in any schema file.
-   */
-  public static String getSchemaFile(SchemaElement elem)
-  {
-    return getSingleValueProperty(elem, SCHEMA_PROPERTY_FILENAME);
-  }
-
-  /**
-   * Retrieves the name of a single value property for this schema element.
-   *
-   * @param elem The element where to get the single value property from
-   * @param propertyName The name of the property to get
-   * @return The single value for this property, or <code>null</code> if it
-   *         is this property is not set.
-   */
-  public static String getSingleValueProperty(SchemaElement elem,
-      String propertyName)
-  {
-    List<String> values = elem.getExtraProperties().get(propertyName);
-    if (values != null && !values.isEmpty()) {
-      return values.get(0);
-    }
-    return null;
-  }
-
-  /**
-   * Specifies the name of the schema file that contains the
-   * definition for this schema element.  If a schema file is already
-   * defined in the set of extra properties, then it will be
-   * overwritten.  If the provided schema file value is {@code null},
-   * then any existing schema file definition will be removed.
-   *
-   * @param elem The element where to set the schema file
-   * @param  schemaFile  The name of the schema file that contains the
-   *                     definition for this schema element.
-   */
-  public static void setSchemaFile(SchemaElement elem, String schemaFile)
-  {
-    setExtraProperty(elem, SCHEMA_PROPERTY_FILENAME, schemaFile);
-  }
-
-  /**
-   * Sets the value for an "extra" property for this schema element.
-   * If a property already exists with the specified name, then it
-   * will be overwritten.  If the value is {@code null}, then any
-   * existing property with the given name will be removed.
-   *
-   * @param elem The element where to set the extra property
-   * @param  name   The name for the "extra" property.  It must not be
-   *                {@code null}.
-   * @param  value  The value for the "extra" property.  If it is
-   *                {@code null}, then any existing definition will be removed.
-   */
-  private static void setExtraProperty(SchemaElement elem, String name, String value)
-  {
-    ifNull(name);
-
-    if (value == null)
-    {
-      elem.getExtraProperties().remove(name);
-    }
-    else
-    {
-      elem.getExtraProperties().put(name, newLinkedList(value));
-    }
-  }
-
-  /**
-   * Retrieves the definition string used to create this attribute
-   * type and including the X-SCHEMA-FILE extension.
-   *
-   * @param elem The element where to get definition from
-   * @return  The definition string used to create this attribute
-   *          type including the X-SCHEMA-FILE extension.
-   */
-  public static String getDefinitionWithFileName(SchemaElement elem)
-  {
-    final String definition = elem.toString();
-    return Schema.addSchemaFileToElementDefinitionIfAbsent(definition, getSchemaFile(elem));
-  }
-}

--
Gitblit v1.10.0