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

Jean-Noel Rouvignac
26.47.2015 6637153a58af50420660a656d04ef48eedda2a9c
BackendImpl.java, Importer.java:
Removed code duplication regarding whether to clear a backend before an import.

Suffix.java:
Code cleanup
3 files modified
34 ■■■■■ changed files
opendj3-server-dev/src/server/org/opends/server/backends/jeb/BackendImpl.java 8 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/backends/jeb/importLDIF/Importer.java 17 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/backends/jeb/importLDIF/Suffix.java 9 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/backends/jeb/BackendImpl.java
@@ -729,10 +729,7 @@
    try
    {
      final EnvironmentConfig envConfig = getEnvConfigForImport();
      if (!importConfig.appendToExistingData()
          && (importConfig.clearBackend() || cfg.getBaseDN().size() <= 1))
      if (Importer.mustClearBackend(importConfig, cfg))
      {
        // We have the writer lock on the environment, now delete the
        // environment and re-open it. Only do this when we are
@@ -747,7 +744,8 @@
        }
      }
      Importer importer = new Importer(importConfig, cfg, envConfig);
      final EnvironmentConfig envConfig = getEnvConfigForImport();
      final Importer importer = new Importer(importConfig, cfg, envConfig);
      rootContainer = initializeRootContainer(envConfig);
      return importer.processImport(rootContainer);
    }
opendj3-server-dev/src/server/org/opends/server/backends/jeb/importLDIF/Importer.java
@@ -297,9 +297,7 @@
    // Determine the number of indexes.
    this.indexCount = getTotalIndexCount(localDBBackendCfg);
    this.clearedBackend =
        !importConfiguration.appendToExistingData()
            && (importConfiguration.clearBackend() || localDBBackendCfg.getBaseDN().size() <= 1);
    this.clearedBackend = mustClearBackend(importConfiguration, localDBBackendCfg);
    this.scratchFileWriterList =
        new ArrayList<ScratchFileWriterTask>(indexCount);
    this.scratchFileWriterFutures = new CopyOnWriteArrayList<Future<Void>>();
@@ -326,6 +324,19 @@
    }
  }
  /**
   * Returns whether the backend must be cleared.
   *
   * @param importCfg the import configuration object
   * @param backendCfg the backend configuration object
   * @return true if the backend must be cleared, false otherwise
   */
  public static boolean mustClearBackend(LDIFImportConfig importCfg, LocalDBBackendCfg backendCfg)
  {
    return !importCfg.appendToExistingData()
        && (importCfg.clearBackend() || backendCfg.getBaseDN().size() <= 1);
  }
  private File getTempDir(LocalDBBackendCfg localDBBackendCfg, String tmpDirectory)
  {
    File parentDir;
opendj3-server-dev/src/server/org/opends/server/backends/jeb/importLDIF/Suffix.java
@@ -253,16 +253,11 @@
      logger.error(ERR_JEB_IMPORT_LDIF_PENDING_ERR, e.getMessage());
      throw e;
    }
    //Check the DN cache.
    boolean parentThere = dnCache.contains(dn);
    //If the parent isn't found in the DN cache, then check the dn2id database
    //for the DN only if the backend wasn't cleared.
    if(!parentThere
    boolean parentThere = !dnCache.contains(dn)
        && !clearedBackend
        && getDN2ID().get(null, dn, LockMode.DEFAULT) != null)
    {
      parentThere = true;
    }
        && getDN2ID().get(null, dn, LockMode.DEFAULT) != null;
    //Add the DN to the parent set if needed.
    if (parentThere) {
      synchronized(synchObject) {