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

Jean-Noël Rouvignac
25.35.2016 2721ee7ac9cf93655cd8945befdaa1ee75dacfdf
Manual fixes/changes post inlining DirectoryServer.getConfigurationHandler()
10 files modified
112 ■■■■ changed files
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/DeleteBaseDNAndBackendTask.java 14 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/ConfigurationBackend.java 8 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/core/BackendConfigManager.java 8 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/LDAPReplicationDomain.java 8 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/BackendToolUtils.java 8 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/test/java/org/opends/server/replication/GenerationIdTest.java 4 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/test/java/org/opends/server/replication/ProtocolWindowTest.java 12 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/test/java/org/opends/server/replication/ReplicationTestCase.java 3 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/AssuredReplicationPluginTest.java 17 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/FractionalReplicationTest.java 30 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/DeleteBaseDNAndBackendTask.java
@@ -59,6 +59,7 @@
import org.opends.guitools.controlpanel.util.Utilities;
import org.opends.server.config.ConfigurationHandler;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.ServerContext;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.OpenDsException;
@@ -426,7 +427,7 @@
  private void updateConfigEntryWithAttribute(DN entryDn, String attrName, List<DN> newBaseDNs)
      throws DirectoryException, ConfigException
  {
    ConfigurationHandler configHandler = DirectoryServer.getInstance().getServerContext().getConfigurationHandler();
    ConfigurationHandler configHandler = getServerContext().getConfigurationHandler();
    final Entry configEntry = configHandler.getEntry(entryDn);
    final Entry newEntry = LinkedHashMapEntry.deepCopyOfEntry(configEntry);
    AttributeType attrType = Schema.getDefaultSchema().getAttributeType(
@@ -470,7 +471,7 @@
  private void deleteBackend(BackendDescriptor backend) throws OpenDsException, ConfigException
  {
    DN dn = DN.valueOf("ds-cfg-backend-id" + "=" + backend.getBackendID() + ",cn=Backends,cn=config");
    Utilities.deleteConfigSubtree(DirectoryServer.getInstance().getServerContext().getConfigurationHandler(), dn);
    Utilities.deleteConfigSubtree(getServerContext().getConfigurationHandler(), dn);
  }
  /**
@@ -625,7 +626,7 @@
        }
        else
        {
          RootCfg root = DirectoryServer.getInstance().getServerContext().getRootConfig();
          RootCfg root = getServerContext().getRootConfig();
          ReplicationSynchronizationProviderCfg sync = null;
          try
          {
@@ -649,7 +650,7 @@
                {
                  domainName.set(dName);
                  DN entryDN = domain.dn();
                  Utilities.deleteConfigSubtree(DirectoryServer.getInstance().getServerContext().getConfigurationHandler(), entryDN);
                  Utilities.deleteConfigSubtree(getServerContext().getConfigurationHandler(), entryDN);
                  break;
                }
              }
@@ -702,6 +703,11 @@
    }
  }
  private ServerContext getServerContext()
  {
    return DirectoryServer.getInstance().getServerContext();
  }
  /**
   * Return the dsconfig arguments required to delete a replication domain.
   * @param domainName the name of the domain to be deleted.
opendj-server-legacy/src/main/java/org/opends/server/backends/ConfigurationBackend.java
@@ -43,9 +43,9 @@
import org.forgerock.opendj.server.config.meta.LocalBackendCfgDefn.WritabilityMode;
import org.forgerock.opendj.server.config.server.BackendCfg;
import org.forgerock.opendj.server.config.server.LocalBackendCfg;
import org.opends.server.api.LocalBackend;
import org.opends.server.api.Backupable;
import org.opends.server.api.ClientConnection;
import org.opends.server.api.LocalBackend;
import org.opends.server.backends.ConfigurationBackend.ConfigurationBackendCfg;
import org.opends.server.config.ConfigurationHandler;
import org.opends.server.core.AddOperation;
@@ -205,16 +205,14 @@
   *
   * @param serverContext
   *            The server context.
   * @param configurationHandler
   *            Contains the configuration entries.
   * @throws InitializationException
   *            If an errors occurs.
   */
  public ConfigurationBackend(ServerContext serverContext, ConfigurationHandler configurationHandler)
  public ConfigurationBackend(ServerContext serverContext)
      throws InitializationException
  {
    this.serverContext = serverContext;
    this.configurationHandler = configurationHandler;
    this.configurationHandler = serverContext.getConfigurationHandler();
    this.configRootEntry = Converters.to(configurationHandler.getRootEntry());
    baseDNs = Collections.singleton(configRootEntry.getName());
opendj-server-legacy/src/main/java/org/opends/server/core/BackendConfigManager.java
@@ -19,8 +19,7 @@
import static org.forgerock.opendj.ldap.ResultCode.*;
import static org.opends.messages.ConfigMessages.*;
import static org.opends.messages.CoreMessages.*;
import static org.opends.server.core.BackendConfigManager.NamingContextFilter.PUBLIC;
import static org.opends.server.core.BackendConfigManager.NamingContextFilter.TOP_LEVEL;
import static org.opends.server.core.BackendConfigManager.NamingContextFilter.*;
import static org.opends.server.core.DirectoryServer.*;
import static org.opends.server.util.StaticUtils.*;
@@ -54,8 +53,8 @@
import org.forgerock.opendj.server.config.server.RootCfg;
import org.forgerock.opendj.server.config.server.RootDSEBackendCfg;
import org.forgerock.util.Reject;
import org.opends.server.api.LocalBackend;
import org.opends.server.api.Backend;
import org.opends.server.api.LocalBackend;
import org.opends.server.api.LocalBackendInitializationListener;
import org.opends.server.backends.ConfigurationBackend;
import org.opends.server.backends.RootDSEBackend;
@@ -129,8 +128,7 @@
  public void initializeBackendConfig(Collection<String> backendIDsToStart)
         throws ConfigException, InitializationException
  {
    final ConfigurationBackend configBackend =
        new ConfigurationBackend(serverContext, DirectoryServer.getInstance().getServerContext().getConfigurationHandler());
    final ConfigurationBackend configBackend = new ConfigurationBackend(serverContext);
    initializeBackend(configBackend, configBackend.getBackendCfg());
    // Register add and delete listeners.
opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/LDAPReplicationDomain.java
@@ -3876,9 +3876,9 @@
    try
    {
      DN eclConfigEntryDN = DN.valueOf("cn=external changeLog," + config.dn());
      if (DirectoryServer.getInstance().getServerContext().getConfigurationHandler().hasEntry(eclConfigEntryDN))
      if (getServerContext().getConfigurationHandler().hasEntry(eclConfigEntryDN))
      {
        DirectoryServer.getInstance().getServerContext().getConfigurationHandler().deleteEntry(eclConfigEntryDN);
        getServerContext().getConfigurationHandler().deleteEntry(eclConfigEntryDN);
      }
    }
    catch(Exception e)
@@ -3903,7 +3903,7 @@
    try
    {
      DN configDn = config.dn();
      ConfigurationHandler configHandler = DirectoryServer.getInstance().getServerContext().getConfigurationHandler();
      ConfigurationHandler configHandler = getServerContext().getConfigurationHandler();
      if (configHandler.hasEntry(config.dn()))
      {
        try
@@ -4834,7 +4834,7 @@
       * For each class in specificClassesAttributes1, check that the attribute
       * list is equivalent to specificClassesAttributes2 attribute list
       */
      Schema schema = DirectoryServer.getInstance().getServerContext().getSchema();
      Schema schema = getServerContext().getSchema();
      for (Map.Entry<String, Set<String>> entry : specificClassesAttrs1.entrySet())
      {
        String className1 = entry.getKey();
opendj-server-legacy/src/main/java/org/opends/server/tools/BackendToolUtils.java
@@ -29,6 +29,7 @@
import org.opends.server.api.LocalBackend;
import org.opends.server.config.ConfigurationHandler;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.ServerContext;
import org.opends.server.types.Attribute;
import org.opends.server.types.Entry;
@@ -66,8 +67,9 @@
    try
    {
      // Iterate through the immediate children, attempting to parse them as backends.
      final RootCfg root = DirectoryServer.getInstance().getServerContext().getRootConfig();
      ConfigurationHandler configHandler = DirectoryServer.getInstance().getServerContext().getConfigurationHandler();
      ServerContext serverContext = DirectoryServer.getInstance().getServerContext();
      final RootCfg root = serverContext.getRootConfig();
      ConfigurationHandler configHandler = serverContext.getConfigurationHandler();
      final DN backendBaseDN = getBackendBaseDN();
      for (final DN childrenDn : configHandler.getChildren(backendBaseDN))
      {
@@ -87,7 +89,7 @@
          backend = (LocalBackend) backendClass.newInstance();
          backend.setBackendID(backendID);
          cfg = root.getBackend(backendID);
          backend.configureBackend(cfg, DirectoryServer.getInstance().getServerContext());
          backend.configureBackend(cfg, serverContext);
        }
        catch (final Exception e)
        {
opendj-server-legacy/src/test/java/org/opends/server/replication/GenerationIdTest.java
@@ -415,9 +415,9 @@
      Entry ecle = DirectoryServer.getEntry(DN.valueOf("cn=external changelog," + synchroServerStringDN));
      if (ecle!=null)
      {
        DirectoryServer.getInstance().getServerContext().getConfigurationHandler().deleteEntry(ecle.getName());
        getServerContext().getConfigurationHandler().deleteEntry(ecle.getName());
      }
      DirectoryServer.getInstance().getServerContext().getConfigurationHandler().deleteEntry(synchroServerDN);
      getServerContext().getConfigurationHandler().deleteEntry(synchroServerDN);
      assertNull(DirectoryServer.getEntry(synchroServerEntry.getName()),
        "Unable to delete the synchronized domain");
      synchroServerEntry = null;
opendj-server-legacy/src/test/java/org/opends/server/replication/ProtocolWindowTest.java
@@ -16,6 +16,11 @@
 */
package org.opends.server.replication;
import static org.forgerock.opendj.ldap.SearchScope.*;
import static org.opends.server.TestCaseUtils.*;
import static org.opends.server.protocols.internal.Requests.*;
import static org.testng.Assert.*;
import java.net.SocketTimeoutException;
import java.util.List;
import java.util.NoSuchElementException;
@@ -45,11 +50,6 @@
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import static org.forgerock.opendj.ldap.SearchScope.*;
import static org.opends.server.TestCaseUtils.*;
import static org.opends.server.protocols.internal.Requests.*;
import static org.testng.Assert.*;
/**
 * Test the constructors, encoders and decoders of the Replication AckMsg,
 * ModifyMsg, ModifyDnMsg, AddMsg and Delete MSG.
@@ -104,7 +104,7 @@
    // @formatter:on
    // Configure replication domain
    DirectoryServer.getInstance().getServerContext().getConfigurationHandler().addEntry(Converters.from(repDomainEntry));
    getServerContext().getConfigurationHandler().addEntry(Converters.from(repDomainEntry));
    assertNotNull(DirectoryServer.getEntry(repDomainEntry.getName()),
          "Unable to add the synchronized server");
    configEntriesToCleanup.add(repDomainEntry.getName());
opendj-server-legacy/src/test/java/org/opends/server/replication/ReplicationTestCase.java
@@ -21,6 +21,7 @@
import static org.forgerock.opendj.ldap.ModificationType.*;
import static org.forgerock.opendj.ldap.ResultCode.*;
import static org.forgerock.opendj.ldap.SearchScope.*;
import static org.opends.server.TestCaseUtils.*;
import static org.opends.server.backends.task.TaskState.*;
import static org.opends.server.config.ConfigConstants.*;
import static org.opends.server.protocols.internal.Requests.*;
@@ -457,7 +458,7 @@
  {
    if (configEntry != null)
    {
      DirectoryServer.getInstance().getServerContext().getConfigurationHandler().addEntry(Converters.from(configEntry));
      getServerContext().getConfigurationHandler().addEntry(Converters.from(configEntry));
      assertNotNull(DirectoryServer.getEntry(configEntry.getName()), errorMessage);
      configEntriesToCleanup.add(configEntry.getName());
    }
opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/AssuredReplicationPluginTest.java
@@ -46,7 +46,6 @@
import org.forgerock.opendj.ldap.DN;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.opends.server.TestCaseUtils;
import org.opends.server.core.AddOperation;
import org.opends.server.core.DeleteOperation;
import org.opends.server.core.DirectoryServer;
@@ -172,7 +171,7 @@
  {
    super.setUp();
    replServerPort = TestCaseUtils.findFreePort();
    replServerPort = findFreePort();
    // Create base dns for each tested modes
    addEntry("dn: " + SAFE_DATA_DN,
@@ -189,7 +188,7 @@
  /** Add an entry in the database. */
  private void addEntry(String... ldifLines) throws Exception
  {
    Entry entry = TestCaseUtils.makeEntry(ldifLines);
    Entry entry = makeEntry(ldifLines);
    debugInfo("AddEntry " + entry.getName());
    AddOperation addOp = connection.processAdd(entry);
    waitOpResult(addOp, ResultCode.SUCCESS);
@@ -244,10 +243,10 @@
      default:
        fail("Unexpected assured level.");
    }
    Entry domainCfgEntry = TestCaseUtils.entryFromLdifString(configEntryLdif);
    Entry domainCfgEntry = entryFromLdifString(configEntryLdif);
    // Add the config entry to create the replicated domain
    DirectoryServer.getInstance().getServerContext().getConfigurationHandler().addEntry(Converters.from(domainCfgEntry));
    getServerContext().getConfigurationHandler().addEntry(Converters.from(domainCfgEntry));
    assertNotNull(DirectoryServer.getEntry(domainCfgEntry.getName()),
      "Unable to add the domain config entry: " + configEntryLdif);
@@ -262,7 +261,7 @@
  {
    // Create a not assured config entry ldif
    // @formatter:off
    Entry domainCfgEntry = TestCaseUtils.makeEntry(
    Entry domainCfgEntry = makeEntry(
        "dn: cn=" + testName + ", cn=domains, " + SYNCHRO_PLUGIN_DN,
        "objectClass: top",
        "objectClass: ds-cfg-replication-domain",
@@ -278,7 +277,7 @@
    // @formatter:on
    // Add the config entry to create the replicated domain
    DirectoryServer.getInstance().getServerContext().getConfigurationHandler().addEntry(Converters.from(domainCfgEntry));
    getServerContext().getConfigurationHandler().addEntry(Converters.from(domainCfgEntry));
    assertNotNull(DirectoryServer.getEntry(domainCfgEntry.getName()),
      "Unable to add the domain config entry: " + domainCfgEntry);
@@ -1117,7 +1116,7 @@
      /* Send an update from the RS and get the ack */
      // Make the RS send an assured add message
      Entry entry = TestCaseUtils.makeEntry(
      Entry entry = makeEntry(
          "dn: ou=assured-sr-reply-entry," + SAFE_READ_DN,
          "objectClass: top",
          "objectClass: organizationalUnit");
@@ -1203,7 +1202,7 @@
      // Make the RS send an assured add message: we expect a read timeout as
      // safe data should be ignored by DS
      Entry entry = TestCaseUtils.makeEntry(
      Entry entry = makeEntry(
          "dn: ou=assured-sd-reply-entry," + SAFE_DATA_DN,
          "objectClass: top",
          "objectClass: organizationalUnit");
opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/FractionalReplicationTest.java
@@ -137,7 +137,7 @@
  {
    super.setUp();
    replServerPort = TestCaseUtils.findFreePort();
    replServerPort = findFreePort();
  }
  /** Returns a bunch of single values for fractional-exclude configuration attribute. */
@@ -251,7 +251,6 @@
   * Returns a bunch of single values for fractional-include configuration
   * attribute
   */
  @SuppressWarnings("unused")
  @DataProvider(name = "testIncludePrecommitProvider")
  private Object[][] testIncludePrecommitProvider()
  {
@@ -265,7 +264,6 @@
   * Returns a bunch of single values for fractional-include configuration
   * attribute
   */
  @SuppressWarnings("unused")
  @DataProvider(name = "testIncludeNightlyProvider")
  private Object[][] testIncludeNightlyProvider()
  {
@@ -378,7 +376,7 @@
    fractionalDomainCfgEntry = null;
    replicationServer = null;
    TestCaseUtils.initializeTestBackend(false);
    initializeTestBackend(false);
    gen = new CSNGenerator(DS2_ID, 0L);
  }
@@ -471,7 +469,7 @@
        "objectClass: domain\n" +
        "dc: example\n";
      }
      addEntry(TestCaseUtils.entryFromLdifString(topEntryLdif));
      addEntry(entryFromLdifString(topEntryLdif));
      /**
       * Create the domain with the passed fractional configuration
@@ -502,10 +500,10 @@
        }
          i++;
      }
      fractionalDomainCfgEntry = TestCaseUtils.entryFromLdifString(configEntryLdif);
      fractionalDomainCfgEntry = entryFromLdifString(configEntryLdif);
      // Add the config entry to create the replicated domain
      DirectoryServer.getInstance().getServerContext().getConfigurationHandler().addEntry(Converters.from(fractionalDomainCfgEntry));
      getServerContext().getConfigurationHandler().addEntry(Converters.from(fractionalDomainCfgEntry));
      assertNotNull(DirectoryServer.getEntry(fractionalDomainCfgEntry.getName()),
        "Unable to add the domain config entry: " + configEntryLdif);
    }
@@ -587,7 +585,7 @@
      }
      // Create an update message to add an entry.
      replicationDomain.publish(newAddMsg(TestCaseUtils.entryFromLdifString(entryLdif), ENTRY_UUID));
      replicationDomain.publish(newAddMsg(entryFromLdifString(entryLdif), ENTRY_UUID));
  }
  /**
@@ -767,7 +765,6 @@
   * Returns a bunch of single values for fractional configuration
   * attributes
   */
  @SuppressWarnings("unused")
  @DataProvider(name = "testInitWithFullUpdateExcludePrecommitProvider")
  private Object[][] testInitWithFullUpdateExcludePrecommitProvider()
  {
@@ -781,7 +778,6 @@
   * Returns a bunch of single values for fractional configuration
   * attributes
   */
  @SuppressWarnings("unused")
  @DataProvider(name = "testInitWithFullUpdateExcludeNightlyProvider")
  private Object[][] testInitWithFullUpdateExcludeNightlyProvider()
  {
@@ -1005,7 +1001,6 @@
   * Returns a bunch of single values for fractional configuration
   * attributes
   */
  @SuppressWarnings("unused")
  @DataProvider(name = "testInitWithFullUpdateIncludePrecommitProvider")
  private Object[][] testInitWithFullUpdateIncludePrecommitProvider()
  {
@@ -1019,7 +1014,6 @@
   * Returns a bunch of single values for fractional configuration
   * attributes
   */
  @SuppressWarnings("unused")
  @DataProvider(name = "testInitWithFullUpdateIncludeNightlyProvider")
  private Object[][] testInitWithFullUpdateIncludeNightlyProvider()
  {
@@ -1207,7 +1201,7 @@
      // Perform add operation with forbidden attribute in RDN
      // @formatter:off
      Entry entry = TestCaseUtils.makeEntry(
      Entry entry = makeEntry(
          "dn: displayName=ValueToBeKept," + TEST_ROOT_DN_STRING,
          "objectClass: top",
          "objectClass: person",
@@ -1239,7 +1233,7 @@
      // Perform add operation with forbidden attribute in RDN
      // @formatter:off
      entry = TestCaseUtils.makeEntry(
      entry = makeEntry(
          "dn: displayName=ValueToBeKept+givenName=ValueToBeKeptToo," + TEST_ROOT_DN_STRING,
          "objectClass: top",
          "objectClass: person",
@@ -1295,7 +1289,7 @@
      createFakeReplicationDomain(true, readGenIdFromSuffixRootEntry(TEST_ROOT_DN_STRING));
      // @formatter:off
      Entry entry = TestCaseUtils.makeEntry(
      Entry entry = makeEntry(
          "dn: displayName=ValueToBeKept," + TEST_ROOT_DN_STRING,
          "objectClass: top",
          "objectClass: person",
@@ -1329,7 +1323,7 @@
      // Perform add operation with forbidden attribute in RDN
      // @formatter:off
      entry = TestCaseUtils.makeEntry(
      entry = makeEntry(
          "dn: displayName=ValueToBeKept+description=ValueToBeKeptToo," + TEST_ROOT_DN_STRING,
          "objectClass: top",
          "objectClass: person",
@@ -1389,7 +1383,7 @@
      // Perform add operation with forbidden attribute in RDN
      String entryName = "displayName=ValueToBeKept+givenName=ValueToBeRemoved," + TEST_ROOT_DN_STRING ;
      // @formatter:off
      Entry entry = TestCaseUtils.makeEntry(
      Entry entry = makeEntry(
          "dn: " + entryName,
          "objectClass: top",
          "objectClass: person",
@@ -1470,7 +1464,7 @@
      // Perform add operation with forbidden attribute in RDN
      String entryName = "displayName=ValueToBeKept+description=ValueToBeRemoved," + TEST_ROOT_DN_STRING ;
      // @formatter:off
      Entry entry = TestCaseUtils.makeEntry(
      Entry entry = makeEntry(
          "dn: " + entryName,
          "objectClass: top",
          "objectClass: person",