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

Jean-Noel Rouvignac
06.08.2015 b03b09d3f95870b445d078ecbc80588e0508ce57
Code cleanup
1 files modified
46 ■■■■ changed files
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/Importer.java 46 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/Importer.java
@@ -260,7 +260,7 @@
   * @param rebuildConfig
   *          The rebuild index configuration.
   * @param cfg
   *          The local DB back-end configuration.
   *          The backend configuration.
   * @throws InitializationException
   *           If a problem occurs during initialization.
   * @throws StorageRuntimeException
@@ -292,7 +292,7 @@
   * @param importCfg
   *          The LDIF import configuration.
   * @param backendCfg
   *          The local DB back-end configuration.
   *          The backend configuration.
   * @throws InitializationException
   *           If a problem occurs during initialization.
   * @throws ConfigException
@@ -1396,7 +1396,7 @@
      if (oldEntry == null)
      {
        if (validateDNs && !dnSanityCheck(txn, entryDN, entry, suffix))
        if (validateDNs && !dnSanityCheck(txn, entry, suffix))
        {
          suffix.removePending(entryDN);
          return;
@@ -1521,7 +1521,7 @@
        throws DirectoryException, StorageRuntimeException, InterruptedException
    {
      DN entryDN = entry.getName();
      if (validateDNs && !dnSanityCheck(txn, entryDN, entry, suffix))
      if (validateDNs && !dnSanityCheck(txn, entry, suffix))
      {
        suffix.removePending(entryDN);
        return;
@@ -1535,30 +1535,23 @@
      importCount.getAndIncrement();
    }
    /** Examine the DN for duplicates and missing parents. */
    boolean dnSanityCheck(WriteableTransaction txn, DN entryDN, Entry entry, Suffix suffix)
    /**
     * Examine the DN for duplicates and missing parents.
     *
     * @return true if the import operation can proceed with the provided entry, false otherwise
     */
    boolean dnSanityCheck(WriteableTransaction txn, Entry entry, Suffix suffix)
        throws StorageRuntimeException, InterruptedException
    {
      //Perform parent checking.
      DN entryDN = entry.getName();
      DN parentDN = suffix.getEntryContainer().getParentWithinBase(entryDN);
      if (parentDN != null && !suffix.isParentProcessed(txn, parentDN, dnCache, clearedBackend))
      {
        reader.rejectEntry(entry, ERR_IMPORT_PARENT_NOT_FOUND.get(parentDN));
        return false;
      }
      //If the backend was not cleared, then the dn2id needs to checked first
      //for DNs that might not exist in the DN cache. If the DN is not in
      //the suffixes dn2id DB, then the dn cache is used.
      if (!clearedBackend)
      {
        EntryID id = suffix.getDN2ID().get(txn, entryDN);
        if (id != null || !dnCache.insert(entryDN))
        {
          reader.rejectEntry(entry, WARN_IMPORT_ENTRY_EXISTS.get());
          return false;
        }
      }
      else if (!dnCache.insert(entryDN))
      if (!insert(txn, entryDN, suffix, dnCache))
      {
        reader.rejectEntry(entry, WARN_IMPORT_ENTRY_EXISTS.get());
        return false;
@@ -1566,6 +1559,17 @@
      return true;
    }
    private boolean insert(WriteableTransaction txn, DN entryDN, Suffix suffix, DNCache dnCache)
    {
      //If the backend was not cleared, then first check dn2id
      //for DNs that might not exist in the DN cache.
      if (!clearedBackend && suffix.getDN2ID().get(txn, entryDN) != null)
      {
        return false;
      }
      return dnCache.insert(entryDN);
    }
    void processIndexes(Suffix suffix, Entry entry, EntryID entryID) throws StorageRuntimeException,
        InterruptedException
    {
@@ -2659,7 +2663,7 @@
    /** Rebuild index configuration. */
    private final RebuildConfig rebuildConfig;
    /** Local DB backend configuration. */
    /** Backend configuration. */
    private final PluggableBackendCfg cfg;
    /** Map of index keys to indexes. */
@@ -3748,6 +3752,7 @@
            }));
          }
        });
        return updateResult.get();
      }
      catch (StorageRuntimeException e)
      {
@@ -3757,7 +3762,6 @@
      {
        throw new StorageRuntimeException(e);
      }
      return updateResult.get();
    }
    /** Return true if the specified DN is in the DNs saved as a result of hash collisions. */