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

Jean-Noël Rouvignac
01.24.2016 c38f72900e121badd214396309a318991940f01d
OPENDJ-3037 remove two register*() methods from Schema class
7 files modified
112 ■■■■ changed files
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/SchemaLoader.java 5 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/NullBackend.java 5 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java 4 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tasks/AddSchemaFileTask.java 21 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/types/Schema.java 45 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/test/java/org/opends/server/plugins/EntryUUIDPluginTestCase.java 8 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/test/java/org/opends/server/plugins/LastModPluginTestCase.java 24 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/SchemaLoader.java
@@ -194,12 +194,11 @@
      {
        builder.buildAttributeType(attr).addToSchemaOverwrite();
      }
      Schema schema = new Schema(builder.toSchema());
      for (ObjectClass oc : objectclassesToKeep)
      {
        schema.registerObjectClass(oc, true);
        builder.buildObjectClass(oc).addToSchemaOverwrite();
      }
      return schema;
      return new Schema(builder.toSchema());
    }
    catch (LocalizedIllegalArgumentException e)
    {
opendj-server-legacy/src/main/java/org/opends/server/backends/NullBackend.java
@@ -33,6 +33,7 @@
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.ObjectClass;
import org.forgerock.opendj.server.config.server.BackendCfg;
import org.opends.server.api.Backend;
import org.opends.server.controls.PagedResultsControl;
@@ -43,6 +44,7 @@
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;
@@ -52,7 +54,6 @@
import org.opends.server.types.LDIFExportConfig;
import org.opends.server.types.LDIFImportConfig;
import org.opends.server.types.LDIFImportResult;
import org.forgerock.opendj.ldap.schema.ObjectClass;
import org.opends.server.types.RestoreConfig;
import org.opends.server.util.CollectionUtils;
import org.opends.server.util.LDIFException;
@@ -148,7 +149,7 @@
    String nulOCName = "nullbackendobject";
    ObjectClass nulOC = DirectoryServer.getObjectClass(nulOCName);
    try {
      DirectoryServer.getSchema().registerObjectClass(nulOC, false);
      DirectoryServer.getSchema().registerObjectClass(nulOC, new ServerSchemaElement(nulOC).getSchemaFile(), false);
    } catch (DirectoryException de) {
      logger.traceException(de);
      throw new InitializationException(de.getMessageObject());
opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java
@@ -2987,7 +2987,7 @@
          AttributeType oldAttrType = schema.getAttributeType(attrType.getOID());
          if (oldAttrType == null || !oldAttrType.toString().equals(attrType.toString()))
          {
            newSchema.registerAttributeType(attrType, true);
            newSchema.registerAttributeType(attrType, schemaFile, true);
            if (schemaFile != null)
            {
@@ -3054,7 +3054,7 @@
          ObjectClass oldObjectClass = schema.getObjectClass(newObjectClass.getOID());
          if (oldObjectClass.isPlaceHolder() || !oldObjectClass.toString().equals(newObjectClass.toString()))
          {
            newSchema.registerObjectClass(newObjectClass, true);
            newSchema.registerObjectClass(newObjectClass, schemaFile, true);
            if (schemaFile != null)
            {
opendj-server-legacy/src/main/java/org/opends/server/tasks/AddSchemaFileTask.java
@@ -48,7 +48,6 @@
import static org.opends.messages.TaskMessages.*;
import static org.opends.server.config.ConfigConstants.*;
import static org.opends.server.core.DirectoryServer.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
/**
@@ -187,26 +186,10 @@
          for (Modification m : modList)
          {
            Attribute a = m.getAttribute();
            AttributeType attrType = a.getAttributeDescription().getAttributeType();
            AttributeBuilder builder = new AttributeBuilder(attrType);
            AttributeBuilder builder = new AttributeBuilder(a.getAttributeDescription());
            for (ByteString v : a)
            {
              String s = v.toString();
              if (!s.contains(SCHEMA_PROPERTY_FILENAME))
              {
                if (s.endsWith(" )"))
                {
                 s = s.substring(0, s.length()-1) + SCHEMA_PROPERTY_FILENAME +
                     " '" + schemaFile + "' )";
                }
                else if (s.endsWith(")"))
                {
                 s = s.substring(0, s.length()-1) + " " +
                     SCHEMA_PROPERTY_FILENAME + " '" + schemaFile + "' )";
                }
              }
              builder.add(s);
              builder.add(Schema.addSchemaFileToElementDefinitionIfAbsent(v.toString(), schemaFile));
            }
            mods.add(new Modification(m.getModificationType(), builder.toAttribute()));
opendj-server-legacy/src/main/java/org/opends/server/types/Schema.java
@@ -67,7 +67,6 @@
import org.forgerock.opendj.ldap.schema.NameForm;
import org.forgerock.opendj.ldap.schema.ObjectClass;
import org.forgerock.opendj.ldap.schema.SchemaBuilder;
import org.forgerock.opendj.ldap.schema.SchemaElement;
import org.forgerock.opendj.ldap.schema.Syntax;
import org.forgerock.opendj.ldap.schema.UnknownSchemaElementException;
import org.forgerock.util.Option;
@@ -75,7 +74,6 @@
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.SchemaConfigManager;
import org.opends.server.util.Base64;
import org.opends.server.util.ServerConstants;
/**
 * This class defines a data structure that holds information about
@@ -496,25 +494,6 @@
   *
   * @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
@@ -841,24 +820,6 @@
   *
   * @param objectClass
   *          The objectclass to register with this schema.
   * @param overwriteExisting
   *          Indicates whether to overwrite an existing mapping if there are any conflicts (i.e.,
   *          another objectclass 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 registerObjectClass(ObjectClass objectClass, boolean overwriteExisting) throws DirectoryException
  {
    String schemaFile = getSchemaFileName(objectClass);
    registerObjectClass(objectClass, schemaFile, overwriteExisting);
  }
  /**
   * Registers the provided objectclass definition with this schema.
   *
   * @param objectClass
   *          The objectclass to register with this schema.
   * @param schemaFile
   *          The schema file where this definition belongs, maybe {@code null}
   * @param overwriteExisting
@@ -1985,12 +1946,6 @@
    registerObjectClasses(Collections.singletonList(definition), schemaFile, overwriteExisting);
  }
  private String getSchemaFileName(SchemaElement element)
  {
    List<String> values = element.getExtraProperties().get(ServerConstants.SCHEMA_PROPERTY_FILENAME);
    return values != null && ! values.isEmpty() ? values.get(0) : null;
  }
  /**
   * Creates a new {@link Schema} object that is a duplicate of this one. It elements may be added
   * and removed from the duplicate without impacting this version.
opendj-server-legacy/src/test/java/org/opends/server/plugins/EntryUUIDPluginTestCase.java
@@ -24,13 +24,13 @@
import java.util.UUID;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.TestCaseUtils;
import org.forgerock.opendj.ldap.DN;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.server.config.meta.EntryUUIDPluginCfgDefn;
import org.opends.server.TestCaseUtils;
import org.opends.server.api.plugin.PluginType;
import org.opends.server.core.DirectoryServer;
import org.opends.server.extensions.InitializationUtils;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.ldap.DN;
import org.opends.server.types.Entry;
import org.opends.server.types.InitializationException;
import org.opends.server.types.LDIFImportConfig;
@@ -145,7 +145,7 @@
    plugin.finalizePlugin();
    DirectoryServer.getSchema().registerAttributeType(entryUUIDType, false);
    DirectoryServer.getSchema().registerAttributeType(entryUUIDType, null, false);
  }
opendj-server-legacy/src/test/java/org/opends/server/plugins/LastModPluginTestCase.java
@@ -24,24 +24,24 @@
import java.util.List;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.DN;
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.RDN;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.TestCaseUtils;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.server.config.meta.LastModPluginCfgDefn;
import org.opends.server.TestCaseUtils;
import org.opends.server.api.plugin.PluginType;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.ModifyDNOperation;
import org.opends.server.core.ModifyOperation;
import org.opends.server.extensions.InitializationUtils;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.opends.server.types.Attributes;
import org.forgerock.opendj.ldap.DN;
import org.opends.server.types.DirectoryConfig;
import org.opends.server.types.Entry;
import org.opends.server.types.InitializationException;
import org.opends.server.types.Modification;
import org.forgerock.opendj.ldap.RDN;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@@ -138,11 +138,11 @@
  public void testInitializeWithValidConfigs(Entry e)
         throws Exception
  {
    LastModPlugin plugin = pp(e);
    LastModPlugin plugin = initializePlugin(e);
    plugin.finalizePlugin();
  }
  private LastModPlugin pp(Entry e) throws ConfigException, InitializationException {
  private LastModPlugin initializePlugin(Entry e) throws ConfigException, InitializationException {
    return InitializationUtils.initializePlugin(new LastModPlugin(), e, LastModPluginCfgDefn.getInstance());
  }
@@ -169,14 +169,14 @@
    DirectoryServer.getSchema().deregisterAttributeType(mnType);
    LastModPlugin plugin = pp(e);
    LastModPlugin plugin = initializePlugin(e);
    plugin.finalizePlugin();
    DirectoryServer.getSchema().registerAttributeType(ctType, false);
    DirectoryServer.getSchema().registerAttributeType(cnType, false);
    DirectoryServer.getSchema().registerAttributeType(mtType, false);
    DirectoryServer.getSchema().registerAttributeType(mnType, false);
    DirectoryServer.getSchema().registerAttributeType(ctType, null, false);
    DirectoryServer.getSchema().registerAttributeType(cnType, null, false);
    DirectoryServer.getSchema().registerAttributeType(mtType, null, false);
    DirectoryServer.getSchema().registerAttributeType(mnType, null, false);
  }
@@ -236,7 +236,7 @@
  public void testInitializeWithInvalidConfigs(Entry e)
         throws Exception
  {
    LastModPlugin plugin = pp(e);
    LastModPlugin plugin = initializePlugin(e);
    plugin.finalizePlugin();
  }