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

Jean-Noel Rouvignac
26.01.2015 c0a5d19fa897c532ced3e13e01f18f869270e9a0
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/ReadOnlyConfigFileHandler.java
@@ -346,8 +346,8 @@
  /** {@inheritDoc} */
  @Override
  public LDIFImportResult importLDIF(LDIFImportConfig arg0)
  throws DirectoryException
  public LDIFImportResult importLDIF(LDIFImportConfig importConfig, ServerContext serverContext)
      throws DirectoryException
  {
    return null;
  }
opendj-server-legacy/src/main/java/org/opends/server/api/Backend.java
@@ -637,15 +637,13 @@
   * returns {@code true}.  Note that the server will not explicitly
   * initialize this backend before calling this method.
   *
   * @param  importConfig  The configuration to use when performing
   *                       the import.
   *
   * @param  importConfig  The configuration to use when performing the import.
   * @param  serverContext The server context
   * @return  Information about the result of the import processing.
   *
   * @throws  DirectoryException  If a problem occurs while performing
   *                              the LDIF import.
   */
  public abstract LDIFImportResult importLDIF(LDIFImportConfig importConfig)
  public abstract LDIFImportResult importLDIF(LDIFImportConfig importConfig, ServerContext serverContext)
         throws DirectoryException;
  /**
@@ -683,8 +681,8 @@
   * @throws DirectoryException
   *           If a Directory Server error occurs.
   */
  public void rebuildBackend(RebuildConfig rebuildConfig) throws InitializationException, ConfigException,
      DirectoryException
  public void rebuildBackend(RebuildConfig rebuildConfig, ServerContext serverContext)
      throws InitializationException, ConfigException, DirectoryException
  {
    throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
        ERR_INDEXES_NOT_SUPPORTED.get(getBackendID()));
opendj-server-legacy/src/main/java/org/opends/server/backends/BackupBackend.java
@@ -934,8 +934,8 @@
  /** {@inheritDoc} */
  @Override
  public LDIFImportResult importLDIF(LDIFImportConfig importConfig)
         throws DirectoryException
  public LDIFImportResult importLDIF(LDIFImportConfig importConfig, ServerContext serverContext)
      throws DirectoryException
  {
    throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
        ERR_BACKEND_IMPORT_AND_EXPORT_NOT_SUPPORTED.get(getBackendID()));
opendj-server-legacy/src/main/java/org/opends/server/backends/ChangelogBackend.java
@@ -622,7 +622,7 @@
  /** {@inheritDoc} */
  @Override
  public LDIFImportResult importLDIF(LDIFImportConfig importConfig)
  public LDIFImportResult importLDIF(LDIFImportConfig importConfig, ServerContext serverContext)
      throws DirectoryException
  {
    throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
opendj-server-legacy/src/main/java/org/opends/server/backends/LDIFBackend.java
@@ -1033,14 +1033,12 @@
  /** {@inheritDoc} */
  @Override
  public LDIFImportResult importLDIF(LDIFImportConfig importConfig)
         throws DirectoryException
  public LDIFImportResult importLDIF(LDIFImportConfig importConfig, ServerContext serverContext)
      throws DirectoryException
  {
    return importLDIF(importConfig, true);
  }
  /**
   * Processes an LDIF import operation, optionally writing the resulting LDIF
   * to disk.
opendj-server-legacy/src/main/java/org/opends/server/backends/MemoryBackend.java
@@ -668,8 +668,8 @@
  /** {@inheritDoc} */
  @Override
  public synchronized LDIFImportResult importLDIF(LDIFImportConfig importConfig)
         throws DirectoryException
  public synchronized LDIFImportResult importLDIF(LDIFImportConfig importConfig, ServerContext serverContext)
      throws DirectoryException
  {
    clearMemoryBackend();
opendj-server-legacy/src/main/java/org/opends/server/backends/MonitorBackend.java
@@ -405,7 +405,7 @@
  /** {@inheritDoc} */
  @Override
  public LDIFImportResult importLDIF(final LDIFImportConfig importConfig)
  public LDIFImportResult importLDIF(final LDIFImportConfig importConfig, ServerContext serverContext)
      throws DirectoryException
  {
    throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
opendj-server-legacy/src/main/java/org/opends/server/backends/NullBackend.java
@@ -387,8 +387,8 @@
  /** {@inheritDoc} */
  @Override
  public LDIFImportResult importLDIF(LDIFImportConfig importConfig)
         throws DirectoryException
  public LDIFImportResult importLDIF(LDIFImportConfig importConfig, ServerContext serverContext)
      throws DirectoryException
  {
    LDIFReader reader;
    try
opendj-server-legacy/src/main/java/org/opends/server/backends/RootDSEBackend.java
@@ -928,8 +928,8 @@
  /** {@inheritDoc} */
  @Override
  public LDIFImportResult importLDIF(LDIFImportConfig importConfig)
         throws DirectoryException
  public LDIFImportResult importLDIF(LDIFImportConfig importConfig, ServerContext serverContext)
      throws DirectoryException
  {
    throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
        ERR_BACKEND_IMPORT_AND_EXPORT_NOT_SUPPORTED.get(getBackendID()));
opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java
@@ -3628,8 +3628,8 @@
  /** {@inheritDoc} */
  @Override
  public LDIFImportResult importLDIF(LDIFImportConfig importConfig)
         throws DirectoryException
  public LDIFImportResult importLDIF(LDIFImportConfig importConfig, ServerContext serverContext)
      throws DirectoryException
  {
    LDIFReader reader;
    try
opendj-server-legacy/src/main/java/org/opends/server/backends/TrustStoreBackend.java
@@ -699,8 +699,8 @@
  /** {@inheritDoc} */
  @Override
  public LDIFImportResult importLDIF(LDIFImportConfig importConfig)
         throws DirectoryException
  public LDIFImportResult importLDIF(LDIFImportConfig importConfig, ServerContext serverContext)
      throws DirectoryException
  {
    throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
        ERR_BACKEND_IMPORT_AND_EXPORT_NOT_SUPPORTED.get(getBackendID()));
opendj-server-legacy/src/main/java/org/opends/server/backends/jeb/BackendImpl.java
@@ -682,7 +682,7 @@
  /** {@inheritDoc} */
  @Override
  public LDIFImportResult importLDIF(LDIFImportConfig importConfig)
  public LDIFImportResult importLDIF(LDIFImportConfig importConfig, ServerContext serverContext)
      throws DirectoryException
  {
    RuntimeInformation.logInfo();
@@ -828,8 +828,8 @@
  /** {@inheritDoc} */
  @Override
  public void rebuildBackend(RebuildConfig rebuildConfig)
          throws InitializationException, ConfigException, DirectoryException
  public void rebuildBackend(RebuildConfig rebuildConfig, ServerContext serverContext)
      throws InitializationException, ConfigException, DirectoryException
  {
    // If the backend already has the root container open, we must use the same
    // underlying root container
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/BackendImpl.java
@@ -641,7 +641,8 @@
  /** {@inheritDoc} */
  @Override
  public LDIFImportResult importLDIF(LDIFImportConfig importConfig) throws DirectoryException
  public LDIFImportResult importLDIF(LDIFImportConfig importConfig, ServerContext serverContext)
      throws DirectoryException
  {
    RuntimeInformation.logInfo();
@@ -669,7 +670,7 @@
      }
      rootContainer = initializeRootContainer();
      return rootContainer.importLDIF(importConfig);
      return rootContainer.importLDIF(importConfig, serverContext);
    }
    catch (StorageRuntimeException e)
    {
@@ -764,7 +765,7 @@
  /** {@inheritDoc} */
  @Override
  public void rebuildBackend(RebuildConfig rebuildConfig)
  public void rebuildBackend(RebuildConfig rebuildConfig, ServerContext serverContext)
      throws InitializationException, ConfigException, DirectoryException
  {
    // If the backend already has the root container open, we must use the same
@@ -787,7 +788,7 @@
      {
        rootContainer = initializeRootContainer();
      }
      final Importer importer = new Importer(rebuildConfig, (PersistitBackendCfg) cfg); // FIXME JNR remove cast
      final Importer importer = new Importer(rebuildConfig, (PersistitBackendCfg) cfg, serverContext); // FIXME JNR remove cast
      importer.rebuildIndexes(rootContainer);
    }
    catch (ExecutionException execEx)
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/Importer.java
@@ -110,6 +110,7 @@
import org.opends.server.backends.pluggable.spi.WriteOperation;
import org.opends.server.backends.pluggable.spi.WriteableTransaction;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.ServerContext;
import org.opends.server.extensions.DiskSpaceMonitor;
import org.opends.server.types.AttributeType;
import org.opends.server.types.DN;
@@ -192,6 +193,7 @@
  private final LDIFImportConfig importConfiguration;
  /** Backend configuration. */
  private final PersistitBackendCfg backendConfiguration;
  private final ServerContext serverContext;
  /** LDIF reader. */
  private ImportLDIFReader reader;
@@ -286,11 +288,12 @@
   * @throws ConfigException
   *           If a problem occurs during initialization.
   */
  Importer(RebuildConfig rebuildConfig, PersistitBackendCfg cfg)
  Importer(RebuildConfig rebuildConfig, PersistitBackendCfg cfg, ServerContext serverContext)
      throws InitializationException, StorageRuntimeException, ConfigException
  {
    this.importConfiguration = null;
    this.backendConfiguration = cfg;
    this.serverContext = serverContext;
    this.tmpEnv = null;
    this.threadCount = 1;
    this.rebuildManager = new RebuildIndexManager(rebuildConfig, cfg);
@@ -324,12 +327,13 @@
   * @throws StorageRuntimeException
   *           If an error occurred when opening the DB.
   */
  Importer(LDIFImportConfig importConfiguration, PersistitBackendCfg backendCfg)
  Importer(LDIFImportConfig importConfiguration, PersistitBackendCfg backendCfg, ServerContext serverContext)
      throws InitializationException, ConfigException, StorageRuntimeException
  {
    this.rebuildManager = null;
    this.importConfiguration = importConfiguration;
    this.backendConfiguration = backendCfg;
    this.serverContext = serverContext;
    if (importConfiguration.getThreadCount() == 0)
    {
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/RootContainer.java
@@ -60,6 +60,7 @@
import org.opends.server.backends.pluggable.spi.WriteableTransaction;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.SearchOperation;
import org.opends.server.core.ServerContext;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
@@ -175,13 +176,14 @@
   *
   * @param importConfig
   *          The configuration to use when performing the import.
   * @param serverContext The server context
   * @return information about the result of the import processing.
   * @throws DirectoryException
   *           If a problem occurs while performing the LDIF import.
   */
  LDIFImportResult importLDIF(LDIFImportConfig importConfig) throws DirectoryException
  LDIFImportResult importLDIF(LDIFImportConfig importConfig, ServerContext serverContext) throws DirectoryException
  {//TODO JNR may call importLDIFWithSuccessiveAdds(importConfig) depending on configured import strategy
    return importLDIFWithOnDiskMerge(importConfig);
    return importLDIFWithOnDiskMerge(importConfig, serverContext);
  }
  private LDIFImportResult importLDIFWithSuccessiveAdds(LDIFImportConfig importConfig) throws DirectoryException
@@ -312,11 +314,11 @@
    timerService.awaitTermination(20, TimeUnit.SECONDS);
  }
  private LDIFImportResult importLDIFWithOnDiskMerge(final LDIFImportConfig importConfig) throws DirectoryException
  private LDIFImportResult importLDIFWithOnDiskMerge(final LDIFImportConfig importConfig, ServerContext serverContext) throws DirectoryException
  {
    try
    {
      final Importer importer = new Importer(importConfig, (PersistitBackendCfg) config); // TODO JNR remove cast
      final Importer importer = new Importer(importConfig, (PersistitBackendCfg) config, serverContext); // TODO JNR remove cast
      return importer.processImport(this);
    }
    catch (DirectoryException e)
opendj-server-legacy/src/main/java/org/opends/server/backends/task/TaskBackend.java
@@ -1080,8 +1080,7 @@
  /** {@inheritDoc} */
  @Override
  public LDIFImportResult importLDIF(LDIFImportConfig importConfig)
         throws DirectoryException
  public LDIFImportResult importLDIF(LDIFImportConfig importConfig, ServerContext sContext) throws DirectoryException
  {
    throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
        ERR_BACKEND_IMPORT_NOT_SUPPORTED.get(getBackendID()));
opendj-server-legacy/src/main/java/org/opends/server/extensions/ConfigFileHandler.java
@@ -1949,7 +1949,7 @@
  /** {@inheritDoc} */
  @Override
  public LDIFImportResult importLDIF(LDIFImportConfig importConfig)
  public LDIFImportResult importLDIF(LDIFImportConfig importConfig, ServerContext serverContext)
         throws DirectoryException
  {
    LocalizableMessage message = ERR_CONFIG_FILE_UNWILLING_TO_IMPORT.get();
opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/LDAPReplicationDomain.java
@@ -3594,7 +3594,7 @@
      // Process import
      preBackendImport(backend);
      backend.importLDIF(importConfig);
      backend.importLDIF(importConfig, DirectoryServer.getInstance().getServerContext());
      stateSavingDisabled = false;
    }
opendj-server-legacy/src/main/java/org/opends/server/tasks/ImportTask.java
@@ -762,7 +762,7 @@
      // Launch the import.
      try
      {
        backend.importLDIF(importConfig);
        backend.importLDIF(importConfig, DirectoryServer.getInstance().getServerContext());
      }
      catch (DirectoryException de)
      {
opendj-server-legacy/src/main/java/org/opends/server/tasks/RebuildTask.java
@@ -248,7 +248,7 @@
    // Launch the rebuild process.
    try
    {
      backend.rebuildBackend(rebuildConfig);
      backend.rebuildBackend(rebuildConfig, DirectoryServer.getInstance().getServerContext());
    }
    catch (InitializationException e)
    {
opendj-server-legacy/src/main/java/org/opends/server/tools/ImportLDIF.java
@@ -1188,7 +1188,8 @@
    int retCode = 0;
    try
    {
      LDIFImportResult importResult = backend.importLDIF(importConfig);
      LDIFImportResult importResult =
          backend.importLDIF(importConfig, DirectoryServer.getInstance().getServerContext());
      if (countRejects.isPresent())
      {
        if (importResult.getEntriesRejected() > Integer.MAX_VALUE)
opendj-server-legacy/src/main/java/org/opends/server/tools/RebuildIndex.java
@@ -587,7 +587,7 @@
    int returnCode = 0;
    try
    {
      backend.rebuildBackend(rebuildConfig);
      backend.rebuildBackend(rebuildConfig, DirectoryServer.getInstance().getServerContext());
    }
    catch (InitializationException e)
    {
opendj-server-legacy/src/test/java/org/opends/server/backends/SchemaBackendTestCase.java
@@ -26,6 +26,11 @@
 */
package org.opends.server.backends;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.opends.server.protocols.internal.Requests.*;
import static org.opends.server.util.StaticUtils.*;
import static org.testng.Assert.*;
import java.io.File;
import java.util.Map;
@@ -47,11 +52,6 @@
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.opends.server.protocols.internal.Requests.*;
import static org.opends.server.util.StaticUtils.*;
import static org.testng.Assert.*;
/**
 * A set of test cases for the schema backend.
 */
@@ -5401,8 +5401,7 @@
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test
  public void testImportLDIF()
         throws Exception
  public void testImportLDIF() throws Exception
  {
    File tempFile = File.createTempFile("schema", "testImportLDIF");
    tempFile.deleteOnExit();
@@ -5413,10 +5412,8 @@
    schemaBackend.exportLDIF(exportConfig);
    LDIFImportConfig importConfig =
         new LDIFImportConfig(tempFile.getAbsolutePath());
    schemaBackend.importLDIF(importConfig);
    LDIFImportConfig importConfig = new LDIFImportConfig(tempFile.getAbsolutePath());
    schemaBackend.importLDIF(importConfig, DirectoryServer.getInstance().getServerContext());
  }
@@ -5427,8 +5424,7 @@
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test
  public void testGetComponentEntryDN()
         throws Exception
  public void testGetComponentEntryDN() throws Exception
  {
    DN configEntryDN =
            DN.valueOf("ds-cfg-backend-id=schema,cn=Backends,cn=config");
opendj-server-legacy/src/test/java/org/opends/server/backends/jeb/TestImportJob.java
@@ -624,7 +624,7 @@
    TaskUtils.disableBackend(backendID);
    try
    {
      backend.importLDIF(importConfig);
      backend.importLDIF(importConfig, DirectoryServer.getInstance().getServerContext());
    }
    finally
    {
opendj-server-legacy/src/test/java/org/opends/server/backends/jeb/TestRebuildJob.java
@@ -161,8 +161,7 @@
    RebuildConfig rebuildConfig = new RebuildConfig();
    rebuildConfig.setBaseDN(baseDNs[0]);
    rebuildConfig.addRebuildIndex(index);
    backend = DirectoryServer.getBackend(backendID);
    backend.rebuildBackend(rebuildConfig);
    rebuildBackend(backendID, rebuildConfig);
    if(index.contains(".") && !index.startsWith("vlv."))
    {
@@ -188,8 +187,7 @@
    RebuildConfig rebuildConfig = new RebuildConfig();
    rebuildConfig.setBaseDN(baseDNs[0]);
    rebuildConfig.addRebuildIndex("id2entry");
    backend = DirectoryServer.getBackend(backendID);
    backend.rebuildBackend(rebuildConfig);
    rebuildBackend(backendID, rebuildConfig);
  }
@@ -207,11 +205,10 @@
    RebuildConfig rebuildConfig = new RebuildConfig();
    rebuildConfig.setBaseDN(baseDNs[0]);
    rebuildConfig.addRebuildIndex("id2entry");
    backend = DirectoryServer.getBackend(backendID);
    TaskUtils.disableBackend(backendID);
    try {
      backend.rebuildBackend(rebuildConfig);
      rebuildBackend(backendID, rebuildConfig);
    } finally {
      TaskUtils.enableBackend(backendID);
    }
@@ -224,8 +221,7 @@
    RebuildConfig rebuildConfig = new RebuildConfig();
    rebuildConfig.setBaseDN(baseDNs[0]);
    rebuildConfig.addRebuildIndex(index);
    backend = DirectoryServer.getBackend(backendID);
    backend.rebuildBackend(rebuildConfig);
    rebuildBackend(backendID, rebuildConfig);
  }
  @Test(dataProvider = "systemIndexes",
@@ -236,8 +232,7 @@
    RebuildConfig rebuildConfig = new RebuildConfig();
    rebuildConfig.setBaseDN(baseDNs[0]);
    rebuildConfig.addRebuildIndex(index);
    backend = DirectoryServer.getBackend(backendID);
    backend.rebuildBackend(rebuildConfig);
    rebuildBackend(backendID, rebuildConfig);
  }
  @Test(dataProvider = "systemIndexes")
@@ -248,9 +243,8 @@
    rebuildConfig.setBaseDN(baseDNs[0]);
    rebuildConfig.addRebuildIndex(index);
    backend = DirectoryServer.getBackend(backendID);
    TaskUtils.disableBackend(backendID);
    backend.rebuildBackend(rebuildConfig);
    rebuildBackend(backendID, rebuildConfig);
    //TODO: Verify dn2uri database as well.
    if (!"dn2uri".equalsIgnoreCase(index))
@@ -296,11 +290,10 @@
  private void rebuildIndexes(RebuildConfig rebuildConfig) throws Exception
  {
    backend = DirectoryServer.getBackend(backendID);
    TaskUtils.disableBackend(backendID);
    try
    {
      backend.rebuildBackend(rebuildConfig);
      rebuildBackend(backendID, rebuildConfig);
      assertEquals(verifyBackend(null), 0);
    }
    finally
@@ -309,6 +302,12 @@
    }
  }
  private void rebuildBackend(String backendID, RebuildConfig rebuildConfig) throws Exception
  {
    backend = DirectoryServer.getBackend(backendID);
    backend.rebuildBackend(rebuildConfig, DirectoryServer.getInstance().getServerContext());
  }
  @Test
  public void testRebuildRedundentIndexes() throws Exception
  {
opendj-server-legacy/src/test/java/org/opends/server/backends/pluggable/PluggableBackendImplTestCase.java
@@ -793,7 +793,7 @@
    importConf.setClearBackend(true);
    importConf.writeRejectedEntries(rejectedEntries);
    try {
      backend.importLDIF(importConf);
      backend.importLDIF(importConf, DirectoryServer.getInstance().getServerContext());
    }
    finally {
      importConf.close();
opendj-server-legacy/src/test/java/org/opends/server/protocols/ldap/LDAPBinaryOptionTestCase.java
@@ -26,6 +26,10 @@
 */
package org.opends.server.protocols.ldap;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.opends.server.protocols.internal.Requests.*;
import static org.testng.Assert.*;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
@@ -51,10 +55,6 @@
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.opends.server.protocols.internal.Requests.*;
import static org.testng.Assert.*;
/**
 * This class defines a set of test cases for testing the binary transfer option
 * functionality across different protocol versions of LDAP.
@@ -519,6 +519,6 @@
    importConfig = new LDIFImportConfig(ldif.getAbsolutePath());
    TestCaseUtils.initializeTestBackend(false);
    backend = DirectoryServer.getBackend("test");
    backend.importLDIF(importConfig);
    backend.importLDIF(importConfig, DirectoryServer.getInstance().getServerContext());
  }
}
opendj-server-legacy/src/test/java/org/opends/server/replication/GenerationIdTest.java
@@ -26,6 +26,10 @@
 */
package org.opends.server.replication;
import static org.opends.server.TestCaseUtils.*;
import static org.opends.server.util.StaticUtils.*;
import static org.testng.Assert.*;
import java.io.File;
import java.net.SocketTimeoutException;
import java.util.ArrayList;
@@ -66,10 +70,6 @@
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import static org.opends.server.TestCaseUtils.*;
import static org.opends.server.util.StaticUtils.*;
import static org.testng.Assert.*;
/**
 * Tests contained here:
 *
@@ -505,7 +505,7 @@
    LDIFImportConfig importConfig = new LDIFImportConfig(ldifFile.getAbsolutePath());
    MemoryBackend memoryBackend = (MemoryBackend) DirectoryServer.getBackend(TEST_BACKEND_ID);
    memoryBackend.importLDIF(importConfig);
    memoryBackend.importLDIF(importConfig, DirectoryServer.getInstance().getServerContext());
  }
  private String createEntry(UUID uid)