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

Jean-Noël Rouvignac
19.03.2016 17ec2cfa9d04e6942a694ab5c3778ac26f17bb35
code cleanup

Use try-with-resources
Removed {@inheritDoc}
Removed code duplication
12 files modified
1589 ■■■■ changed files
opendj-server-legacy/src/main/java/org/opends/server/backends/BackupBackend.java 53 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/LDIFBackend.java 220 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/MemoryBackend.java 156 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/MonitorBackend.java 115 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/RootDSEBackend.java 40 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java 173 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/TrustStoreBackend.java 586 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/BackendImpl.java 28 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/BackendMonitor.java 4 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/task/TaskBackend.java 193 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tasks/ExportTask.java 14 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tasks/ImportTask.java 7 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/BackupBackend.java
@@ -88,8 +88,6 @@
{
  private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
  /** The current configuration state. */
  private BackupBackendCfg currentConfig;
@@ -158,7 +156,6 @@
    }
  }
  /**
   * Creates a new backend with the provided information.  All backend
   * implementations must implement a default constructor that use
@@ -171,9 +168,6 @@
    // Perform all initialization in initializeBackend.
  }
  /** {@inheritDoc} */
  @Override
  public void configureBackend(BackupBackendCfg config, ServerContext serverContext) throws ConfigException
  {
@@ -186,9 +180,6 @@
    currentConfig = config;
  }
  /** {@inheritDoc} */
  @Override
  public void openBackend()
         throws ConfigException, InitializationException
@@ -210,7 +201,6 @@
    this.baseDNs = Collections.singleton(backupBaseDN);
    // Determine the set of backup directories that we will use by default.
    Set<String> values = currentConfig.getBackupDirectory();
    backupDirectories = new LinkedHashMap<>(values.size());
@@ -220,7 +210,6 @@
      backupDirectories.put(dir, new CachedBackupDirectory(dir));
    }
    // Construct the backup base entry.
    LinkedHashMap<ObjectClass,String> objectClasses = new LinkedHashMap<>(2);
    objectClasses.put(DirectoryServer.getTopObjectClass(), OC_TOP);
@@ -257,9 +246,6 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  public void closeBackend()
  {
@@ -312,9 +298,6 @@
    return numEntries;
  }
  /** {@inheritDoc} */
  @Override
  public boolean isIndexed(AttributeType attributeType, IndexType indexType)
  {
@@ -322,9 +305,6 @@
    return true;
  }
  /** {@inheritDoc} */
  @Override
  public ConditionResult hasSubordinates(DN entryDN) throws DirectoryException
  {
@@ -336,14 +316,12 @@
    return ConditionResult.valueOf(ret != 0);
  }
  /** {@inheritDoc} */
  @Override
  public long getNumberOfEntriesInBaseDN(DN baseDN) throws DirectoryException {
    checkNotNull(baseDN, "baseDN must not be null");
    return getNumberOfSubordinates(baseDN, true) + 1;
  }
  /** {@inheritDoc} */
  @Override
  public long getNumberOfChildren(DN parentDN) throws DirectoryException {
    checkNotNull(parentDN, "parentDN must not be null");
@@ -430,7 +408,6 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  public Entry getEntry(DN entryDN)
         throws DirectoryException
@@ -442,14 +419,12 @@
          ERR_BACKEND_GET_ENTRY_NULL.get(getBackendID()));
    }
    // If the requested entry was the backend base entry, then retrieve it.
    if (entryDN.equals(backupBaseDN))
    {
      return backupBaseEntry.duplicate(true);
    }
    // See if the requested entry was one level below the backend base entry.
    // If so, then it must point to a backup directory.  Otherwise, it must be
    // two levels below the backup base entry and must point to a specific
@@ -476,8 +451,6 @@
    }
  }
  /**
   * Generates an entry for a backup directory based on the provided DN.  The
   * DN must contain an RDN component that specifies the path to the backup
@@ -505,7 +478,6 @@
                                   backupBaseDN, null);
    }
    // Get a handle to the backup directory and the information that it
    // contains.
    BackupDirectory backupDirectory;
@@ -531,7 +503,6 @@
                                   message);
    }
    // Construct the backup directory entry to return.
    LinkedHashMap<ObjectClass,String> ocMap = new LinkedHashMap<>(2);
    ocMap.put(DirectoryServer.getTopObjectClass(), OC_TOP);
@@ -552,8 +523,6 @@
    return e;
  }
  /**
   * Generates an entry for a backup based on the provided DN.  The DN must
   * have an RDN component that specifies the backup ID, and the parent DN must
@@ -694,7 +663,6 @@
    return new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
  }
  /** {@inheritDoc} */
  @Override
  public void addEntry(Entry entry, AddOperation addOperation)
         throws DirectoryException
@@ -703,9 +671,6 @@
        ERR_BACKEND_ADD_NOT_SUPPORTED.get(entry.getName(), getBackendID()));
  }
  /** {@inheritDoc} */
  @Override
  public void deleteEntry(DN entryDN, DeleteOperation deleteOperation)
         throws DirectoryException
@@ -714,9 +679,6 @@
        ERR_BACKEND_DELETE_NOT_SUPPORTED.get(entryDN, getBackendID()));
  }
  /** {@inheritDoc} */
  @Override
  public void replaceEntry(Entry oldEntry, Entry newEntry,
      ModifyOperation modifyOperation) throws DirectoryException
@@ -725,9 +687,6 @@
        ERR_BACKEND_MODIFY_NOT_SUPPORTED.get(oldEntry.getName(), getBackendID()));
  }
  /** {@inheritDoc} */
  @Override
  public void renameEntry(DN currentDN, Entry entry,
                                   ModifyDNOperation modifyDNOperation)
@@ -737,9 +696,6 @@
        ERR_BACKEND_MODIFY_DN_NOT_SUPPORTED.get(currentDN, getBackendID()));
  }
  /** {@inheritDoc} */
  @Override
  public void search(SearchOperation searchOperation)
         throws DirectoryException
@@ -749,7 +705,6 @@
    DN    baseDN    = searchOperation.getBaseDN();
    Entry baseEntry = getEntry(baseDN);
    // Look at the base DN and see if it's the backup base DN, a backup
    // directory entry DN, or a backup entry DN.
    DN parentDN;
@@ -777,7 +732,6 @@
            continue;
          }
          DN backupDirDN = makeChildDN(backupBaseDN, backupPathType,
                                       dir.getAbsolutePath());
@@ -816,7 +770,6 @@
        searchOperation.returnEntry(backupDirEntry, null);
      }
      if (scope != SearchScope.BASE_OBJECT)
      {
        AttributeType t =
@@ -907,7 +860,6 @@
        ERR_BACKEND_IMPORT_AND_EXPORT_NOT_SUPPORTED.get(getBackendID()));
  }
  /** {@inheritDoc} */
  @Override
  public LDIFImportResult importLDIF(LDIFImportConfig importConfig, ServerContext serverContext)
      throws DirectoryException
@@ -916,7 +868,6 @@
        ERR_BACKEND_IMPORT_AND_EXPORT_NOT_SUPPORTED.get(getBackendID()));
  }
  /** {@inheritDoc} */
  @Override
  public void createBackup(BackupConfig backupConfig)
  throws DirectoryException
@@ -925,7 +876,6 @@
        ERR_BACKEND_BACKUP_AND_RESTORE_NOT_SUPPORTED.get(getBackendID()));
  }
  /** {@inheritDoc} */
  @Override
  public void removeBackup(BackupDirectory backupDirectory,
                           String backupID)
@@ -935,7 +885,6 @@
        ERR_BACKEND_BACKUP_AND_RESTORE_NOT_SUPPORTED.get(getBackendID()));
  }
  /** {@inheritDoc} */
  @Override
  public void restoreBackup(RestoreConfig restoreConfig)
         throws DirectoryException
@@ -944,7 +893,6 @@
        ERR_BACKEND_BACKUP_AND_RESTORE_NOT_SUPPORTED.get(getBackendID()));
  }
  /** {@inheritDoc} */
  @Override
  public boolean isConfigurationChangeAcceptable(
       BackupBackendCfg cfg, List<LocalizableMessage> unacceptableReasons)
@@ -955,7 +903,6 @@
    return true;
  }
  /** {@inheritDoc} */
  @Override
  public ConfigChangeResult applyConfigurationChange(BackupBackendCfg cfg)
  {
opendj-server-legacy/src/main/java/org/opends/server/backends/LDIFBackend.java
@@ -22,6 +22,7 @@
import static org.opends.server.util.StaticUtils.*;
import java.io.File;
import java.io.IOException;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@@ -36,12 +37,12 @@
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.config.server.ConfigChangeResult;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.config.server.ConfigurationChangeListener;
import org.forgerock.opendj.ldap.ConditionResult;
import org.forgerock.opendj.ldap.DN;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.config.server.ConfigurationChangeListener;
import org.forgerock.opendj.server.config.server.LDIFBackendCfg;
import org.opends.server.api.AlertGenerator;
import org.opends.server.api.Backend;
@@ -84,8 +85,6 @@
{
  private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
  /** The base DNs for this backend. */
  private Set<DN> baseDNs;
@@ -117,7 +116,6 @@
  {
  }
  /** {@inheritDoc} */
  @Override
  public void openBackend()
         throws ConfigException, InitializationException
@@ -152,8 +150,6 @@
    readLDIF();
  }
  /**
   * Reads the contents of the LDIF backing file into memory.
   *
@@ -178,7 +174,6 @@
      return;
    }
    try
    {
      importLDIF(new LDIFImportConfig(ldifFile.getAbsolutePath()), false);
@@ -189,8 +184,6 @@
    }
  }
  /**
   * Writes the current set of entries to the target LDIF file.  The new LDIF
   * will first be created as a temporary file and then renamed into place.  The
@@ -207,7 +200,6 @@
    File tempFile = new File(ldifFile.getAbsolutePath() + ".new");
    File oldFile  = new File(ldifFile.getAbsolutePath() + ".old");
    // Write the new data to a temporary file.
    LDIFWriter writer;
    try
@@ -231,7 +223,6 @@
                                   m, e);
    }
    for (Entry entry : entryMap.values())
    {
      try
@@ -332,7 +323,6 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  public void closeBackend()
  {
@@ -387,7 +377,6 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  public boolean isIndexed(AttributeType attributeType, IndexType indexType)
  {
@@ -395,7 +384,6 @@
    return true;
  }
  /** {@inheritDoc} */
  @Override
  public ConditionResult hasSubordinates(DN entryDN)
         throws DirectoryException
@@ -430,7 +418,6 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  public long getNumberOfChildren(DN parentDN) throws DirectoryException
  {
@@ -438,7 +425,6 @@
    return getNumberOfSubordinates(parentDN, false);
  }
  /** {@inheritDoc} */
  @Override
  public long getNumberOfEntriesInBaseDN(DN baseDN) throws DirectoryException
  {
@@ -490,7 +476,6 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  public Entry getEntry(DN entryDN)
  {
@@ -506,7 +491,6 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  public boolean entryExists(DN entryDN)
  {
@@ -522,7 +506,6 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  public void addEntry(Entry entry, AddOperation addOperation)
         throws DirectoryException
@@ -565,27 +548,8 @@
        }
        else
        {
          DN matchedDN = null;
          if (parentDN != null)
          {
            while (true)
            {
              parentDN = DirectoryServer.getParentDNInSuffix(parentDN);
              if (parentDN == null)
              {
                break;
              }
              if (entryMap.containsKey(parentDN))
              {
                matchedDN = parentDN;
                break;
              }
            }
          }
          LocalizableMessage m = ERR_LDIF_BACKEND_ADD_MISSING_PARENT.get(entryDN);
          throw new DirectoryException(ResultCode.NO_SUCH_OBJECT, m, matchedDN, null);
          throw new DirectoryException(ResultCode.NO_SUCH_OBJECT, m, findMatchedDN(parentDN), null);
        }
      }
    }
@@ -595,7 +559,26 @@
    }
  }
  /** {@inheritDoc} */
  private DN findMatchedDN(DN parentDN)
  {
    if (parentDN != null)
    {
      while (true)
      {
        parentDN = DirectoryServer.getParentDNInSuffix(parentDN);
        if (parentDN == null)
        {
          return null;
        }
        else if (entryMap.containsKey(parentDN))
        {
          return parentDN;
        }
      }
    }
    return null;
  }
  @Override
  public void deleteEntry(DN entryDN, DeleteOperation deleteOperation)
         throws DirectoryException
@@ -628,7 +611,6 @@
        throw new DirectoryException(ResultCode.NO_SUCH_OBJECT, m, matchedDN, null);
      }
      // See if the target entry has any children.  If so, then we'll only
      // delete it if the request contains the subtree delete control (in
      // which case we'll delete the entire subtree).
@@ -693,8 +675,6 @@
    }
  }
  /**
   * Removes the specified entry and any subordinates that it may have from
   * the backend.  This method assumes that the caller holds the backend write
@@ -716,7 +696,6 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  public void replaceEntry(Entry oldEntry, Entry newEntry,
      ModifyOperation modifyOperation) throws DirectoryException
@@ -756,7 +735,6 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  public void renameEntry(DN currentDN, Entry entry,
                          ModifyDNOperation modifyDNOperation)
@@ -823,7 +801,6 @@
      }
      parentChildDNs.add(newDN);
      // If the entry has children, then we'll need to work on the whole
      // subtree.  Otherwise, just work on the target entry.
      Set<DN> childDNSet = childDNs.remove(currentDN);
@@ -844,8 +821,6 @@
    }
  }
  /**
   * Moves the specified entry and all of its children so that they are
   * appropriately placed below the given new parent DN.  This method assumes
@@ -893,7 +868,6 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  public void search(SearchOperation searchOperation)
         throws DirectoryException
@@ -907,7 +881,6 @@
      SearchScope  scope  = searchOperation.getScope();
      SearchFilter filter = searchOperation.getFilter();
      // Make sure the base entry exists if it's supposed to be in this backend.
      Entry baseEntry = entryMap.get(baseDN);
      if (baseEntry == null && handlesEntry(baseDN))
@@ -961,21 +934,18 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  public Set<String> getSupportedControls()
  {
    return supportedControls;
  }
  /** {@inheritDoc} */
  @Override
  public Set<String> getSupportedFeatures()
  {
    return Collections.emptySet();
  }
  /** {@inheritDoc} */
  @Override
  public boolean supports(BackendOperation backendOperation)
  {
@@ -990,53 +960,33 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  public void exportLDIF(LDIFExportConfig exportConfig)
         throws DirectoryException
  {
    backendLock.readLock().lock();
    try
    try (LDIFWriter ldifWriter = newLDIFWriter(exportConfig))
    {
      // Create the LDIF writer.
      LDIFWriter ldifWriter;
      try
      {
        ldifWriter = new LDIFWriter(exportConfig);
      }
      catch (Exception e)
      {
        logger.traceException(e);
        LocalizableMessage m = ERR_LDIF_BACKEND_CANNOT_CREATE_LDIF_WRITER.get(
                         stackTraceToSingleLineString(e));
        throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
                                     m, e);
      }
      // Walk through all the entries and write them to LDIF.
      DN entryDN = null;
      try
      for (Entry entry : entryMap.values())
      {
        for (Entry entry : entryMap.values())
        DN entryDN = entry.getName();
        try
        {
          entryDN = entry.getName();
          ldifWriter.writeEntry(entry);
        }
        catch (Exception e)
        {
          LocalizableMessage m =
              ERR_LDIF_BACKEND_CANNOT_WRITE_ENTRY_TO_LDIF.get(entryDN, stackTraceToSingleLineString(e));
          throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), m, e);
        }
      }
      catch (Exception e)
      {
        LocalizableMessage m = ERR_LDIF_BACKEND_CANNOT_WRITE_ENTRY_TO_LDIF.get(
            entryDN, stackTraceToSingleLineString(e));
        throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
                                     m, e);
      }
      finally
      {
        StaticUtils.close(ldifWriter);
      }
    }
    catch (IOException ignoreOnClose)
    {
      logger.traceException(ignoreOnClose);
    }
    finally
    {
@@ -1044,7 +994,20 @@
    }
  }
  /** {@inheritDoc} */
  private LDIFWriter newLDIFWriter(LDIFExportConfig exportConfig) throws DirectoryException
  {
    try
    {
      return new LDIFWriter(exportConfig);
    }
    catch (Exception e)
    {
      logger.traceException(e);
      LocalizableMessage m = ERR_LDIF_BACKEND_CANNOT_CREATE_LDIF_WRITER.get(stackTraceToSingleLineString(e));
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), m, e);
    }
  }
  @Override
  public LDIFImportResult importLDIF(LDIFImportConfig importConfig, ServerContext serverContext)
      throws DirectoryException
@@ -1068,25 +1031,11 @@
  {
    backendLock.writeLock().lock();
    try
    try (LDIFReader reader = newLDIFReader(importConfig))
    {
      LDIFReader reader;
      try
      {
        reader = new LDIFReader(importConfig);
      }
      catch (Exception e)
      {
        LocalizableMessage m = ERR_LDIF_BACKEND_CANNOT_CREATE_LDIF_READER.get(
                         stackTraceToSingleLineString(e));
        throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
                                     m, e);
      }
      entryMap.clear();
      childDNs.clear();
      try
      {
        while (true)
@@ -1109,10 +1058,7 @@
              throw new DirectoryException(
                             DirectoryServer.getServerErrorResultCode(), m, le);
            }
            else
            {
              continue;
            }
            continue;
          }
          // Make sure that we don't already have an entry with the same DN.  If
@@ -1127,7 +1073,6 @@
            continue;
          }
          // If the entry DN is a base DN, then add it with no more processing.
          if (baseDNs.contains(entryDN))
          {
@@ -1135,19 +1080,8 @@
            continue;
          }
          // Make sure that the parent exists.  If not, then reject the entry.
          boolean isBelowBaseDN = false;
          for (DN baseDN : baseDNs)
          {
            if (baseDN.isSuperiorOrEqualTo(entryDN))
            {
              isBelowBaseDN = true;
              break;
            }
          }
          if (! isBelowBaseDN)
          if (!isBelowBaseDN(entryDN))
          {
            LocalizableMessage m = ERR_LDIF_BACKEND_ENTRY_OUT_OF_SCOPE.get(
                ldifFilePath, currentConfig.dn(), entryDN);
@@ -1166,7 +1100,6 @@
            continue;
          }
          // The entry does not exist but its parent does, so add it and update
          // the set of children for the parent.
          entryMap.put(entryDN, e);
@@ -1181,7 +1114,6 @@
          childDNSet.add(entryDN);
        }
        if (writeLDIF)
        {
          writeLDIF();
@@ -1197,14 +1129,8 @@
      }
      catch (Exception e)
      {
        LocalizableMessage m = ERR_LDIF_BACKEND_ERROR_READING_LDIF.get(
                         stackTraceToSingleLineString(e));
        throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
                                     m, e);
      }
      finally
      {
        StaticUtils.close(reader);
        LocalizableMessage m = ERR_LDIF_BACKEND_ERROR_READING_LDIF.get(stackTraceToSingleLineString(e));
        throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), m, e);
      }
    }
    finally
@@ -1213,7 +1139,31 @@
    }
  }
  /** {@inheritDoc} */
  private boolean isBelowBaseDN(DN entryDN)
  {
    for (DN baseDN : baseDNs)
    {
      if (baseDN.isSuperiorOrEqualTo(entryDN))
      {
        return true;
      }
    }
    return false;
  }
  private LDIFReader newLDIFReader(LDIFImportConfig importConfig) throws DirectoryException
  {
    try
    {
      return new LDIFReader(importConfig);
    }
    catch (Exception e)
    {
      LocalizableMessage m = ERR_LDIF_BACKEND_CANNOT_CREATE_LDIF_READER.get(stackTraceToSingleLineString(e));
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), m, e);
    }
  }
  @Override
  public void createBackup(BackupConfig backupConfig)
         throws DirectoryException
@@ -1222,7 +1172,6 @@
    throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
  }
  /** {@inheritDoc} */
  @Override
  public void removeBackup(BackupDirectory backupDirectory, String backupID)
         throws DirectoryException
@@ -1231,7 +1180,6 @@
    throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
  }
  /** {@inheritDoc} */
  @Override
  public void restoreBackup(RestoreConfig restoreConfig)
         throws DirectoryException
@@ -1240,7 +1188,6 @@
    throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
  }
  /** {@inheritDoc} */
  @Override
  public void configureBackend(LDIFBackendCfg config, ServerContext serverContext) throws ConfigException
  {
@@ -1259,7 +1206,6 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  public boolean isConfigurationChangeAcceptable(LDIFBackendCfg configuration,
                      List<LocalizableMessage> unacceptableReasons)
@@ -1276,7 +1222,6 @@
    return configAcceptable;
  }
  /** {@inheritDoc} */
  @Override
  public ConfigChangeResult applyConfigurationChange(
                                 LDIFBackendCfg configuration)
@@ -1307,21 +1252,18 @@
    return ccr;
  }
  /** {@inheritDoc} */
  @Override
  public DN getComponentEntryDN()
  {
    return currentConfig.dn();
  }
  /** {@inheritDoc} */
  @Override
  public String getClassName()
  {
    return LDIFBackend.class.getName();
  }
  /** {@inheritDoc} */
  @Override
  public Map<String,String> getAlerts()
  {
opendj-server-legacy/src/main/java/org/opends/server/backends/MemoryBackend.java
@@ -26,12 +26,14 @@
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.Set;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ConditionResult;
import org.forgerock.opendj.ldap.DN;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.forgerock.opendj.ldap.schema.AttributeType;
@@ -48,7 +50,6 @@
import org.opends.server.types.BackupConfig;
import org.opends.server.types.BackupDirectory;
import org.opends.server.types.Control;
import org.forgerock.opendj.ldap.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
import org.opends.server.types.IndexType;
@@ -95,23 +96,16 @@
{
  private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
  /** The set of supported controls for this backend. */
  private static final Set<String> supportedControls = Collections.singleton(OID_SUBTREE_DELETE_CONTROL);
  /** The base DNs for this backend. */
  private Set<DN> baseDNs;
  /** The mapping between parent DNs and their immediate children. */
  private HashMap<DN,HashSet<DN>> childDNs;
  /** The set of supported controls for this backend. */
  private final Set<String> supportedControls =
      Collections.singleton(OID_SUBTREE_DELETE_CONTROL);
  private Map<DN, HashSet<DN>> childDNs;
  /** The mapping between entry DNs and the corresponding entries. */
  private LinkedHashMap<DN,Entry> entryMap;
  /**
   * Creates a new backend with the provided information.  All backend
   * implementations must implement a default constructor that use
@@ -124,7 +118,6 @@
    // Perform all initialization in initializeBackend.
  }
  /**
   * Set the base DNs for this backend.  This is used by the unit tests
   * to set the base DNs without having to provide a configuration
@@ -177,18 +170,13 @@
    }
  }
  /**
   * Removes any data that may have been stored in this backend.
   */
  /** Removes any data that may have been stored in this backend. */
  public synchronized void clearMemoryBackend()
  {
    entryMap.clear();
    childDNs.clear();
  }
  /** {@inheritDoc} */
  @Override
  public synchronized void closeBackend()
  {
@@ -224,7 +212,6 @@
    return -1;
  }
  /** {@inheritDoc} */
  @Override
  public boolean isIndexed(AttributeType attributeType, IndexType indexType)
  {
@@ -232,7 +219,6 @@
    return true;
  }
  /** {@inheritDoc} */
  @Override
  public synchronized ConditionResult hasSubordinates(DN entryDN)
         throws DirectoryException
@@ -245,14 +231,12 @@
    return ConditionResult.valueOf(ret != 0);
  }
  /** {@inheritDoc} */
  @Override
  public long getNumberOfEntriesInBaseDN(DN baseDN) throws DirectoryException {
    checkNotNull(baseDN, "baseDN must not be null");
    return getNumberOfSubordinates(baseDN, true) + 1;
  }
  /** {@inheritDoc} */
  @Override
  public long getNumberOfChildren(DN parentDN) throws DirectoryException {
    checkNotNull(parentDN, "parentDN must not be null");
@@ -286,7 +270,6 @@
    return count;
  }
  /** {@inheritDoc} */
  @Override
  public synchronized Entry getEntry(DN entryDN)
  {
@@ -299,14 +282,12 @@
    return entry;
  }
  /** {@inheritDoc} */
  @Override
  public synchronized boolean entryExists(DN entryDN)
  {
    return entryMap.containsKey(entryDN);
  }
  /** {@inheritDoc} */
  @Override
  public synchronized void addEntry(Entry entry, AddOperation addOperation)
         throws DirectoryException
@@ -321,7 +302,6 @@
          ERR_MEMORYBACKEND_ENTRY_ALREADY_EXISTS.get(entryDN));
    }
    // If the entry is one of the base DNs, then add it.
    if (baseDNs.contains(entryDN))
    {
@@ -329,7 +309,6 @@
      return;
    }
    // Get the parent DN and ensure that it exists in the backend.
    DN parentDN = DirectoryServer.getParentDNInSuffix(entryDN);
    if (parentDN == null)
@@ -354,7 +333,6 @@
    children.add(entryDN);
  }
  /** {@inheritDoc} */
  @Override
  public synchronized void deleteEntry(DN entryDN,
                                       DeleteOperation deleteOperation)
@@ -367,41 +345,34 @@
          ERR_BACKEND_ENTRY_DOESNT_EXIST.get(entryDN, getBackendID()));
    }
    // Check to see if the entry contains a subtree delete control.
    boolean subtreeDelete = deleteOperation != null
        && deleteOperation.getRequestControl(SubtreeDeleteControl.DECODER) != null;
    HashSet<DN> children = childDNs.get(entryDN);
    if (subtreeDelete)
    Set<DN> children = childDNs.get(entryDN);
    if (children != null && !children.isEmpty())
    {
      if (children != null)
      {
        HashSet<DN> childrenCopy = new HashSet<>(children);
        for (DN childDN : childrenCopy)
        {
          try
          {
            deleteEntry(childDN, null);
          }
          catch (Exception e)
          {
            // This shouldn't happen, but we want the delete to continue anyway
            // so just ignore it if it does for some reason.
            logger.traceException(e);
          }
        }
      }
    }
    else
    {
      // Make sure the entry doesn't have any children.  If it does, then throw
      // an exception.
      if (children != null && !children.isEmpty())
      // children exist
      if (!subtreeDelete)
      {
        throw new DirectoryException(ResultCode.NOT_ALLOWED_ON_NONLEAF,
            ERR_MEMORYBACKEND_CANNOT_DELETE_ENTRY_WITH_CHILDREN.get(entryDN));
      }
      Set<DN> childrenCopy = new HashSet<>(children);
      for (DN childDN : childrenCopy)
      {
        try
        {
          deleteEntry(childDN, null);
        }
        catch (Exception ignore)
        {
          // This shouldn't happen, but we want the delete to continue anyway
          // so just ignore it if it does for some reason.
          logger.traceException(ignore);
        }
      }
    }
@@ -425,7 +396,6 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  public synchronized void replaceEntry(Entry oldEntry, Entry newEntry,
      ModifyOperation modifyOperation) throws DirectoryException
@@ -440,12 +410,10 @@
          ERR_BACKEND_ENTRY_DOESNT_EXIST.get(entryDN, getBackendID()));
    }
    // Replace the old entry with the new one.
    entryMap.put(entryDN, e);
  }
  /** {@inheritDoc} */
  @Override
  public synchronized void renameEntry(DN currentDN, Entry entry,
                                       ModifyDNOperation modifyDNOperation)
@@ -460,9 +428,8 @@
          ERR_BACKEND_ENTRY_DOESNT_EXIST.get(currentDN, getBackendID()));
    }
    // Make sure that the target entry doesn't have any children.
    HashSet<DN> children  = childDNs.get(currentDN);
    Set<DN> children = childDNs.get(currentDN);
    if (children != null)
    {
      if (children.isEmpty())
@@ -476,7 +443,6 @@
      }
    }
    // Make sure that no entry exists with the new DN.
    if (entryMap.containsKey(e.getName()))
    {
@@ -484,25 +450,13 @@
          ERR_MEMORYBACKEND_ENTRY_ALREADY_EXISTS.get(e.getName()));
    }
    // Make sure that the new DN is in this backend.
    boolean matchFound = false;
    for (DN dn : baseDNs)
    {
      if (dn.isSuperiorOrEqualTo(e.getName()))
      {
        matchFound = true;
        break;
      }
    }
    if (! matchFound)
    if (!superiorExistsInBackend(e.getName()))
    {
      throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
          ERR_MEMORYBACKEND_CANNOT_RENAME_TO_ANOTHER_BACKEND.get(currentDN));
    }
    // Make sure that the parent of the new entry exists.
    DN parentDN = DirectoryServer.getParentDNInSuffix(e.getName());
    if (parentDN == null || !entryMap.containsKey(parentDN))
@@ -511,13 +465,23 @@
          ERR_MEMORYBACKEND_RENAME_PARENT_DOESNT_EXIST.get(currentDN, parentDN));
    }
    // Delete the current entry and add the new one.
    deleteEntry(currentDN, null);
    addEntry(e, null);
  }
  /** {@inheritDoc} */
  private boolean superiorExistsInBackend(DN dnToFind)
  {
    for (DN dn : baseDNs)
    {
      if (dn.isSuperiorOrEqualTo(dnToFind))
      {
        return true;
      }
    }
    return false;
  }
  @Override
  public synchronized void search(SearchOperation searchOperation)
         throws DirectoryException
@@ -527,7 +491,6 @@
    SearchScope  scope  = searchOperation.getScope();
    SearchFilter filter = searchOperation.getFilter();
    // Make sure the base entry exists if it's supposed to be in this backend.
    Entry baseEntry = entryMap.get(baseDN);
    if (baseEntry == null && handlesEntry(baseDN))
@@ -554,7 +517,6 @@
      baseEntry = baseEntry.duplicate(true);
    }
    // If it's a base-level search, then just get that entry and return it if it
    // matches the filter.
    if (scope == SearchScope.BASE_OBJECT)
@@ -578,21 +540,18 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  public Set<String> getSupportedControls()
  {
    return supportedControls;
  }
  /** {@inheritDoc} */
  @Override
  public Set<String> getSupportedFeatures()
  {
    return Collections.emptySet();
  }
  /** {@inheritDoc} */
  @Override
  public boolean supports(BackendOperation backendOperation)
  {
@@ -607,7 +566,6 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  public synchronized void exportLDIF(LDIFExportConfig exportConfig)
         throws DirectoryException
@@ -626,7 +584,6 @@
          ERR_MEMORYBACKEND_CANNOT_CREATE_LDIF_WRITER.get(e), e);
    }
    // Walk through all the entries and write them to LDIF.
    DN entryDN = null;
    try
@@ -648,26 +605,14 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  public synchronized LDIFImportResult importLDIF(LDIFImportConfig importConfig, ServerContext serverContext)
      throws DirectoryException
  {
    clearMemoryBackend();
    LDIFReader reader;
    try
    {
      reader = new LDIFReader(importConfig);
    }
    catch (Exception e)
    {
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
          ERR_MEMORYBACKEND_CANNOT_CREATE_LDIF_READER.get(e), e);
    }
    try
    try (LDIFReader reader = newLDIFReader(importConfig))
    {
      while (true)
      {
@@ -687,10 +632,7 @@
            throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
                ERR_MEMORYBACKEND_ERROR_READING_LDIF.get(e), le);
          }
          else
          {
            continue;
          }
          continue;
        }
        try
@@ -716,13 +658,21 @@
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
          ERR_MEMORYBACKEND_ERROR_DURING_IMPORT.get(e), e);
    }
    finally
  }
  private LDIFReader newLDIFReader(LDIFImportConfig importConfig) throws DirectoryException
  {
    try
    {
      reader.close();
      return new LDIFReader(importConfig);
    }
    catch (Exception e)
    {
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
          ERR_MEMORYBACKEND_CANNOT_CREATE_LDIF_READER.get(e), e);
    }
  }
  /** {@inheritDoc} */
  @Override
  public void createBackup(BackupConfig backupConfig)
         throws DirectoryException
@@ -731,7 +681,6 @@
    throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
  }
  /** {@inheritDoc} */
  @Override
  public void removeBackup(BackupDirectory backupDirectory,
                           String backupID)
@@ -741,7 +690,6 @@
    throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
  }
  /** {@inheritDoc} */
  @Override
  public void restoreBackup(RestoreConfig restoreConfig)
         throws DirectoryException
opendj-server-legacy/src/main/java/org/opends/server/backends/MonitorBackend.java
@@ -24,6 +24,7 @@
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -89,7 +90,7 @@
{
  private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
  /** The set of user-defined attributes that will be included in the base monitor entry.   */
  /** The set of user-defined attributes that will be included in the base monitor entry. */
  private ArrayList<Attribute> userDefinedAttributes;
  /** The set of objectclasses that will be used in monitor entries. */
  private final HashMap<ObjectClass, String> monitorObjectClasses = new LinkedHashMap<>(2);
@@ -112,7 +113,6 @@
    super();
  }
  /** {@inheritDoc} */
  @Override
  public void addEntry(final Entry entry, final AddOperation addOperation)
      throws DirectoryException
@@ -121,7 +121,6 @@
        ERR_BACKEND_ADD_NOT_SUPPORTED.get(entry.getName(), getBackendID()));
  }
  /** {@inheritDoc} */
  @Override
  public ConfigChangeResult applyConfigurationChange(
      final MonitorBackendCfg backendCfg)
@@ -226,7 +225,6 @@
    addAllNonMonitorConfigAttributes(attributes, attributesToAdd);
  }
  /** {@inheritDoc} */
  @Override
  public void createBackup(final BackupConfig backupConfig)
      throws DirectoryException
@@ -235,7 +233,6 @@
        ERR_BACKEND_BACKUP_AND_RESTORE_NOT_SUPPORTED.get(getBackendID()));
  }
  /** {@inheritDoc} */
  @Override
  public void deleteEntry(final DN entryDN,
      final DeleteOperation deleteOperation) throws DirectoryException
@@ -244,77 +241,69 @@
        ERR_BACKEND_DELETE_NOT_SUPPORTED.get(entryDN, getBackendID()));
  }
  /** {@inheritDoc} */
  @Override
  public boolean entryExists(final DN entryDN) throws DirectoryException
  {
    return getDIT().containsKey(entryDN);
  }
  /** {@inheritDoc} */
  @Override
  public void exportLDIF(final LDIFExportConfig exportConfig)
      throws DirectoryException
  {
    // TODO export-ldif reports nonsense for upTime etc.
    // Create the LDIF writer.
    LDIFWriter ldifWriter;
    try
    try (LDIFWriter ldifWriter = newLDIFWriter(exportConfig))
    {
      ldifWriter = new LDIFWriter(exportConfig);
    }
    catch (final Exception e)
    {
      logger.traceException(e);
      final LocalizableMessage message = ERR_ROOTDSE_UNABLE_TO_CREATE_LDIF_WRITER
          .get(stackTraceToSingleLineString(e));
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), message);
    }
    // Write the base monitor entry to the LDIF.
    try
    {
      ldifWriter.writeEntry(getBaseMonitorEntry());
    }
    catch (final Exception e)
    {
      logger.traceException(e);
      close(ldifWriter);
      final LocalizableMessage message = ERR_MONITOR_UNABLE_TO_EXPORT_BASE
          .get(stackTraceToSingleLineString(e));
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), message);
    }
    // Get all the monitor providers, convert them to entries, and write them to
    // LDIF.
    for (final MonitorProvider<?> monitorProvider : DirectoryServer
        .getMonitorProviders().values())
    {
      // Write the base monitor entry to the LDIF.
      try
      {
        // TODO implementation of export is incomplete
        ldifWriter.writeEntry(getBaseMonitorEntry());
      }
      catch (final Exception e)
      {
        logger.traceException(e);
        final LocalizableMessage message = ERR_MONITOR_UNABLE_TO_EXPORT_BASE.get(stackTraceToSingleLineString(e));
        throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), message);
      }
        close(ldifWriter);
        final LocalizableMessage message = ERR_MONITOR_UNABLE_TO_EXPORT_PROVIDER_ENTRY
            .get(monitorProvider.getMonitorInstanceName(), stackTraceToSingleLineString(e));
        throw new DirectoryException(
            DirectoryServer.getServerErrorResultCode(), message);
      // Get all the monitor providers, convert them to entries, and write them to LDIF.
      for (final MonitorProvider<?> monitorProvider : DirectoryServer.getMonitorProviders().values())
      {
        try
        {
          // TODO implementation of export is incomplete
        }
        catch (final Exception e)
        {
          logger.traceException(e);
          final LocalizableMessage message =
              ERR_MONITOR_UNABLE_TO_EXPORT_PROVIDER_ENTRY.get(monitorProvider.getMonitorInstanceName(),
                  stackTraceToSingleLineString(e));
          throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), message);
        }
      }
    }
    close(ldifWriter);
    catch (IOException ignoreOnClose)
    {
      logger.traceException(ignoreOnClose);
    }
  }
  /** {@inheritDoc} */
  private LDIFWriter newLDIFWriter(final LDIFExportConfig exportConfig) throws DirectoryException
  {
    try
    {
      return new LDIFWriter(exportConfig);
    }
    catch (final Exception e)
    {
      logger.traceException(e);
      final LocalizableMessage message = ERR_ROOTDSE_UNABLE_TO_CREATE_LDIF_WRITER.get(stackTraceToSingleLineString(e));
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), message);
    }
  }
  @Override
  public void closeBackend()
  {
@@ -364,28 +353,24 @@
    return getEntry(entryDN, dit);
  }
  /** {@inheritDoc} */
  @Override
  public long getEntryCount()
  {
    return getDIT().size();
  }
  /** {@inheritDoc} */
  @Override
  public Set<String> getSupportedControls()
  {
    return Collections.emptySet();
  }
  /** {@inheritDoc} */
  @Override
  public Set<String> getSupportedFeatures()
  {
    return Collections.emptySet();
  }
  /** {@inheritDoc} */
  @Override
  public ConditionResult hasSubordinates(final DN entryDN)
      throws DirectoryException
@@ -399,7 +384,6 @@
    return ConditionResult.UNDEFINED;
  }
  /** {@inheritDoc} */
  @Override
  public LDIFImportResult importLDIF(final LDIFImportConfig importConfig, ServerContext serverContext)
      throws DirectoryException
@@ -408,7 +392,6 @@
        ERR_BACKEND_IMPORT_NOT_SUPPORTED.get(getBackendID()));
  }
  /** {@inheritDoc} */
  @Override
  public void openBackend() throws ConfigException, InitializationException
  {
@@ -430,7 +413,6 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  public boolean isConfigurationChangeAcceptable(
      final MonitorBackendCfg backendCfg,
@@ -441,7 +423,6 @@
    return true;
  }
  /** {@inheritDoc} */
  @Override
  public boolean isIndexed(final AttributeType attributeType,
      final IndexType indexType)
@@ -450,14 +431,12 @@
    return true;
  }
  /** {@inheritDoc} */
  @Override
  public long getNumberOfEntriesInBaseDN(final DN baseDN) throws DirectoryException {
    checkNotNull(baseDN, "baseDN must not be null");
    return getNumberOfSubordinates(baseDN, true) + 1;
  }
  /** {@inheritDoc} */
  @Override
  public long getNumberOfChildren(final DN parentDN) throws DirectoryException {
    checkNotNull(parentDN, "parentDN must not be null");
@@ -487,7 +466,6 @@
    return count;
  }
  /** {@inheritDoc} */
  @Override
  public void removeBackup(final BackupDirectory backupDirectory,
      final String backupID) throws DirectoryException
@@ -496,7 +474,6 @@
        ERR_BACKEND_BACKUP_AND_RESTORE_NOT_SUPPORTED.get(getBackendID()));
  }
  /** {@inheritDoc} */
  @Override
  public void renameEntry(final DN currentDN, final Entry entry,
      final ModifyDNOperation modifyDNOperation) throws DirectoryException
@@ -505,7 +482,6 @@
        ERR_BACKEND_MODIFY_DN_NOT_SUPPORTED.get(currentDN, getBackendID()));
  }
  /** {@inheritDoc} */
  @Override
  public void replaceEntry(final Entry oldEntry, final Entry newEntry,
      final ModifyOperation modifyOperation) throws DirectoryException
@@ -514,7 +490,6 @@
        ERR_MONITOR_MODIFY_NOT_SUPPORTED.get(newEntry.getName(), configEntryDN));
  }
  /** {@inheritDoc} */
  @Override
  public void restoreBackup(final RestoreConfig restoreConfig)
      throws DirectoryException
@@ -523,7 +498,6 @@
        ERR_BACKEND_BACKUP_AND_RESTORE_NOT_SUPPORTED.get(getBackendID()));
  }
  /** {@inheritDoc} */
  @Override
  public void search(final SearchOperation searchOperation)
      throws DirectoryException
@@ -574,7 +548,6 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  public boolean supports(BackendOperation backendOperation)
  {
@@ -709,8 +682,6 @@
    return dit;
  }
  /**
   * Creates the monitor entry having the specified DN.
   *
@@ -741,8 +712,6 @@
    }
  }
  /**
   * Generates and returns a monitor entry based on the contents of the provided
   * monitor provider.
opendj-server-legacy/src/main/java/org/opends/server/backends/RootDSEBackend.java
@@ -127,8 +127,6 @@
   */
  private ConcurrentHashMap<DN, Backend<?>> subordinateBaseDNs;
  /**
   * Creates a new backend with the provided information.  All backend
   * implementations must implement a default constructor that use
@@ -165,13 +163,11 @@
    userDefinedAttributes = new ArrayList<>();
    addAllUserDefinedAttrs(userDefinedAttributes, configEntry);
    // Create the set of base DNs that we will handle.  In this case, it's just
    // the root DSE.
    rootDSEDN    = DN.rootDN();
    baseDNs = Collections.singleton(rootDSEDN);
    // Create the set of subordinate base DNs.  If this is specified in the
    // configuration, then use that set.  Otherwise, use the set of non-private
    // backends defined in the server.
@@ -189,13 +185,13 @@
        for (DN baseDN : subDNs)
        {
          Backend<?> backend = DirectoryServer.getBackend(baseDN);
          if (backend == null)
          if (backend != null)
          {
            logger.warn(WARN_ROOTDSE_NO_BACKEND_FOR_SUBORDINATE_BASE, baseDN);
            subordinateBaseDNs.put(baseDN, backend);
          }
          else
          {
            subordinateBaseDNs.put(baseDN, backend);
            logger.warn(WARN_ROOTDSE_NO_BACKEND_FOR_SUBORDINATE_BASE, baseDN);
          }
        }
      }
@@ -209,12 +205,10 @@
      throw new InitializationException(message, e);
    }
    // Determine whether all root DSE attributes should be treated as user
    // attributes.
    showAllAttributes = currentConfig.isShowAllAttributes();
    // Construct the set of "static" attributes that will always be present in
    // the root DSE.
    staticDSEAttributes = new ArrayList<>();
@@ -240,12 +234,10 @@
    }
    dseObjectClasses.put(rootDSEOC, OC_ROOT_DSE);
    // Set the backend ID for this backend. The identifier needs to be
    // specific enough to avoid conflict with user backend identifiers.
    setBackendID("__root.dse__");
    // Register as a change listener.
    currentConfig.addChangeListener(this);
  }
@@ -284,8 +276,6 @@
    currentConfig.removeChangeListener(this);
  }
  /**
   * Indicates whether the provided attribute is one that is used in the
   * configuration of this backend.
@@ -392,12 +382,10 @@
      return getRootDSE();
    }
    // This method should never be used to get anything other than the root DSE.
    // If we got here, then that appears to be the case, so log a message.
    logger.warn(WARN_ROOTDSE_GET_ENTRY_NONROOT, entryDN);
    // Go ahead and check the subordinate backends to see if we can find the
    // entry there.  Note that in order to avoid potential loop conditions, this
    // will only work if the set of subordinate bases has been explicitly
@@ -413,13 +401,10 @@
      }
    }
    // If we've gotten here, then we couldn't find the entry so return null.
    return null;
  }
  /**
   * Retrieves the root DSE entry for the Directory Server.
   *
@@ -430,8 +415,6 @@
    return getRootDSE(null);
  }
  /**
   * Retrieves the root DSE entry for the Directory Server.
   *
@@ -489,7 +472,6 @@
        ATTR_SUPPORTED_AUTH_PW_SCHEMES, DirectoryServer.getAuthPasswordStorageSchemes().keySet());
    addAttribute(supportedAuthPWSchemesAttr, dseUserAttrs, dseOperationalAttrs);
    // Obtain TLS protocol and cipher support.
    Collection<String> supportedTlsProtocols;
    Collection<String> supportedTlsCiphers;
@@ -604,7 +586,6 @@
      return true;
    }
    // If it was not the null DN, then iterate through the associated
    // subordinate backends to make the determination.
    for (Map.Entry<DN, Backend<?>> entry : getSubordinateBaseDNs().entrySet())
@@ -664,7 +645,6 @@
      throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
    }
    SearchFilter filter = searchOperation.getFilter();
    switch (searchOperation.getScope().asEnum())
    {
@@ -676,7 +656,6 @@
        }
        break;
      case SINGLE_LEVEL:
        for (Map.Entry<DN, Backend<?>> entry : getSubordinateBaseDNs().entrySet())
        {
@@ -692,7 +671,6 @@
        }
        break;
      case WHOLE_SUBTREE:
      case SUBORDINATES:
        try
@@ -785,7 +763,7 @@
  public boolean supports(BackendOperation backendOperation)
  {
    // We will only export the DSE entry itself.
    return backendOperation.equals(BackendOperation.LDIF_EXPORT);
    return BackendOperation.LDIF_EXPORT.equals(backendOperation);
  }
  @Override
@@ -808,7 +786,6 @@
                                   message);
    }
    // Write the root DSE entry itself to it.  Make sure to close the LDIF
    // writer when we're done.
    try
@@ -872,7 +849,6 @@
  {
    boolean configIsAcceptable = true;
    try
    {
      Set<DN> subDNs = cfg.getSubordinateBaseDN();
@@ -902,7 +878,6 @@
      configIsAcceptable = false;
    }
    return configIsAcceptable;
  }
@@ -911,7 +886,6 @@
  {
    final ConfigChangeResult ccr = new ConfigChangeResult();
    // Check to see if we should apply a new set of base DNs.
    ConcurrentHashMap<DN, Backend<?>> subBases;
    try
@@ -952,10 +926,8 @@
      subBases = null;
    }
    boolean newShowAll = cfg.isShowAllAttributes();
    // Check to see if there is a new set of user-defined attributes.
    ArrayList<Attribute> userAttrs = new ArrayList<>();
    try
@@ -972,7 +944,6 @@
      ccr.setResultCode(DirectoryServer.getServerErrorResultCode());
    }
    if (ccr.getResultCode() == ResultCode.SUCCESS)
    {
      subordinateBaseDNs = subBases;
@@ -987,7 +958,6 @@
        ccr.addMessage(INFO_ROOTDSE_USING_NEW_SUBORDINATE_BASE_DNS.get(basesStr));
      }
      if (showAllAttributes != newShowAll)
      {
        showAllAttributes = newShowAll;
@@ -995,12 +965,10 @@
                ATTR_ROOTDSE_SHOW_ALL_ATTRIBUTES, showAllAttributes));
      }
      userDefinedAttributes = userAttrs;
      ccr.addMessage(INFO_ROOTDSE_USING_NEW_USER_ATTRS.get());
    }
    return ccr;
  }
}
opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java
@@ -52,6 +52,7 @@
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.config.server.ConfigChangeResult;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.config.server.ConfigurationChangeListener;
import org.forgerock.opendj.ldap.AVA;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ConditionResult;
@@ -64,13 +65,11 @@
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.forgerock.opendj.ldap.schema.ObjectClassType;
import org.forgerock.opendj.config.server.ConfigurationChangeListener;
import org.forgerock.opendj.server.config.server.SchemaBackendCfg;
import org.opends.server.api.AlertGenerator;
import org.opends.server.api.Backend;
import org.opends.server.api.Backupable;
import org.opends.server.api.ClientConnection;
import org.opends.server.types.Entry;
import org.opends.server.core.AddOperation;
import org.opends.server.core.DeleteOperation;
import org.opends.server.core.DirectoryServer;
@@ -96,6 +95,7 @@
import org.opends.server.types.DITContentRule;
import org.opends.server.types.DITStructureRule;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
import org.opends.server.types.ExistingFileBehavior;
import org.opends.server.types.IndexType;
import org.opends.server.types.InitializationException;
@@ -256,7 +256,6 @@
    ObjectClass subschemaOC = DirectoryServer.getObjectClass(OC_SUBSCHEMA, true);
    schemaObjectClasses.put(subschemaOC, OC_SUBSCHEMA);
    configEntryDN = configEntry.getName();
    baseDNs = cfg.getBaseDN();
@@ -273,7 +272,6 @@
    modifyTimestamp =
         GeneralizedTimeSyntax.createGeneralizedTimeValue(newModifyTime);
    // Get the set of user-defined attributes for the configuration entry.  Any
    // attributes that we don't recognize will be included directly in the
    // schema entry.
@@ -318,7 +316,6 @@
      }
    }
    // Identify any differences that may exist between the concatenated schema
    // file from the last online modification and the current schema files.  If
    // there are any differences, then they should be from making changes to the
@@ -417,7 +414,6 @@
      logger.error(ERR_SCHEMA_ERROR_DETERMINING_SCHEMA_CHANGES, getExceptionMessage(e));
    }
    // Register with the Directory Server as a configurable component.
    currentConfig.addSchemaChangeListener(this);
  }
@@ -440,8 +436,6 @@
    }
  }
  /**
   * Indicates whether the provided attribute is one that is used in the
   * configuration of this backend.
@@ -522,7 +516,6 @@
    return null;
  }
  /**
   * Generates and returns a schema entry for the Directory Server.
   *
@@ -571,9 +564,7 @@
      }
    }
    /*
     * Add the schema definition attributes.
     */
    /* Add the schema definition attributes. */
    Schema schema = DirectoryServer.getSchema();
    buildSchemaAttribute(schema.getAttributeTypes(), userAttrs,
        operationalAttrs, attributeTypesType, includeSchemaFile,
@@ -642,8 +633,6 @@
    return e;
  }
  private void addAttributeToSchemaEntry(Attribute attribute,
      Map<AttributeType, List<Attribute>> userAttrs,
      Map<AttributeType, List<Attribute>> operationalAttrs)
@@ -659,8 +648,6 @@
    attrs.add(attribute);
  }
  private void buildSchemaAttribute(Collection<?> elements,
      Map<AttributeType, List<Attribute>> userAttrs,
      Map<AttributeType, List<Attribute>> operationalAttrs,
@@ -676,10 +663,7 @@
    AttributeBuilder builder = new AttributeBuilder(schemaAttributeType);
    for (Object element : elements)
    {
      /*
       * Add the file name to the description of the element if this was
       * requested by the caller.
       */
      /* Add the file name to the description of the element if this was requested by the caller. */
      String value;
      if (includeSchemaFile && element instanceof CommonSchemaElements)
      {
@@ -748,7 +732,6 @@
                                   message);
    }
    ArrayList<Modification> mods = new ArrayList<>(modifyOperation.getModifications());
    if (mods.isEmpty())
    {
@@ -918,7 +901,6 @@
          break;
        case DELETE:
          if (a.isEmpty())
          {
@@ -1073,7 +1055,6 @@
          break;
        case REPLACE:
          if (!m.isInternal()
              && !modifyOperation.isSynchronizationOperation())
@@ -1100,7 +1081,6 @@
      }
    }
    // If we've gotten here, then everything looks OK, re-write all the
    // modified Schema Files.
    updateSchemaFiles(newSchema, modifiedSchemaFiles);
@@ -1108,7 +1088,6 @@
    // Finally set DirectoryServer to use the new Schema.
    DirectoryServer.setSchema(newSchema);
    DN authzDN = modifyOperation.getAuthorizationDN();
    if (authzDN == null)
    {
@@ -1120,8 +1099,6 @@
                           System.currentTimeMillis());
  }
  /**
   * Re-write all schema files using the provided new Schema and list of
   * modified files.
@@ -1170,15 +1147,12 @@
      cleanUpTempSchemaFiles(tempSchemaFiles);
    }
    // Create a single file with all of the concatenated schema information
    // that we can use on startup to detect whether the schema files have been
    // edited with the server offline.
    Schema.writeConcatenatedSchema();
  }
  /**
   * Handles all processing required for adding the provided attribute type to
   * the given schema, replacing an existing type if necessary, and ensuring all
@@ -1460,8 +1434,6 @@
    }
  }
  /**
   * Handles all processing required for adding the provided objectclass to the
   * given schema, replacing an existing class if necessary, and ensuring
@@ -1513,7 +1485,6 @@
      }
    }
    // Make sure that the new objectclass doesn't reference an undefined
    // superior class, or an undefined required or optional attribute type,
    // and that none of them are OBSOLETE.
@@ -1565,7 +1536,6 @@
      }
    }
    // If there is no existing class, then we're adding a new objectclass.
    // Otherwise, we're replacing an existing one.
    if (existingClass == null)
@@ -1582,8 +1552,6 @@
    }
  }
  /**
   * Handles all processing required to remove the provided objectclass from the
   * server schema, ensuring all other metadata is properly updated.  Note that
@@ -1626,7 +1594,6 @@
      throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
    }
    // See if there is another modification later to add the objectclass back
    // into the schema.  If so, then it's a replace and we should ignore the
    // remove because adding it back will handle the replace.
@@ -1667,7 +1634,6 @@
      }
    }
    // Make sure that the objectclass isn't used as the superior class for any
    // other objectclass.
    for (ObjectClass oc : schema.getObjectClasses().values())
@@ -1684,7 +1650,6 @@
      }
    }
    // Make sure that the objectclass isn't used as the structural class for
    // any name form.
    List<NameForm> mappedForms = schema.getNameForm(removeClass);
@@ -1701,7 +1666,6 @@
      throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
    }
    // Make sure that the objectclass isn't used as a structural or auxiliary
    // class for any DIT content rule.
    for (DITContentRule dcr : schema.getDITContentRules().values())
@@ -1715,7 +1679,6 @@
      }
    }
    // If we've gotten here, then it's OK to remove the objectclass from the
    // schema.
    schema.deregisterObjectClass(removeClass);
@@ -1726,8 +1689,6 @@
    }
  }
  /**
   * Handles all processing required for adding the provided name form to the
   * the given schema, replacing an existing name form if necessary, and
@@ -1778,7 +1739,6 @@
      }
    }
    // Make sure that the new name form doesn't reference an undefined
    // structural class, or an undefined required or optional attribute type, or
    // that any of them are marked OBSOLETE.
@@ -1834,7 +1794,6 @@
      }
    }
    // If there is no existing class, then we're adding a new name form.
    // Otherwise, we're replacing an existing one.
    if (existingNF == null)
@@ -1851,8 +1810,6 @@
    }
  }
  /**
   * Handles all processing required to remove the provided name form from the
   * server schema, ensuring all other metadata is properly updated.  Note that
@@ -1894,7 +1851,6 @@
      throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
    }
    // See if there is another modification later to add the name form back
    // into the schema.  If so, then it's a replace and we should ignore the
    // remove because adding it back will handle the replace.
@@ -1935,7 +1891,6 @@
      }
    }
    // Make sure that the name form isn't referenced by any DIT structure
    // rule.
    DITStructureRule dsr = schema.getDITStructureRule(removeNF);
@@ -1946,7 +1901,6 @@
      throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
    }
    // If we've gotten here, then it's OK to remove the name form from the
    // schema.
    schema.deregisterNameForm(removeNF);
@@ -1957,8 +1911,6 @@
    }
  }
  /**
   * Handles all processing required for adding the provided DIT content rule to
   * the given schema, replacing an existing rule if necessary, and ensuring
@@ -2007,7 +1959,6 @@
      }
    }
    // Get the structural class for the new DIT content rule and see if there's
    // already an existing rule that is associated with that class.  If there
    // is, then it will only be acceptable if it's the DIT content rule that we
@@ -2023,7 +1974,6 @@
      throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
    }
    // Make sure that the new DIT content rule doesn't reference an undefined
    // structural or auxiliary class, or an undefined required, optional, or
    // prohibited attribute type.
@@ -2118,7 +2068,6 @@
      }
    }
    // If there is no existing rule, then we're adding a new DIT content rule.
    // Otherwise, we're replacing an existing one.
    if (existingDCR == null)
@@ -2136,8 +2085,6 @@
    }
  }
  /**
   * Handles all processing required to remove the provided DIT content rule
   * from the server schema, ensuring all other metadata is properly updated.
@@ -2174,7 +2121,6 @@
      throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
    }
    // Since DIT content rules don't have any dependencies, then we don't need
    // to worry about the difference between a remove or a replace.  We can
    // just remove the DIT content rule now, and if it is added back later then
@@ -2187,8 +2133,6 @@
    }
  }
  /**
   * Handles all processing required for adding the provided DIT structure rule
   * to the given schema, replacing an existing rule if necessary, and ensuring
@@ -2270,7 +2214,6 @@
      throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
    }
    // Make sure that the new DIT structure rule doesn't reference an undefined
    // name form or superior DIT structure rule.
    if (! schema.hasNameForm(nameForm.getOID()))
@@ -2286,7 +2229,6 @@
      throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
    }
    // If there are any superior rules, then make sure none of them are marked
    // OBSOLETE.
    for (DITStructureRule dsr : ditStructureRule.getSuperiorRules())
@@ -2299,7 +2241,6 @@
      }
    }
    // If there is no existing rule, then we're adding a new DIT structure rule.
    // Otherwise, we're replacing an existing one.
    if (existingDSR == null)
@@ -2317,8 +2258,6 @@
    }
  }
  /**
   * Handles all processing required to remove the provided DIT structure rule
   * from the server schema, ensuring all other metadata is properly updated.
@@ -2363,7 +2302,6 @@
      throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
    }
    // See if there is another modification later to add the DIT structure rule
    // back into the schema.  If so, then it's a replace and we should ignore
    // the remove because adding it back will handle the replace.
@@ -2404,7 +2342,6 @@
      }
    }
    // Make sure that the DIT structure rule isn't the superior for any other
    // DIT structure rule.
    for (DITStructureRule dsr : schema.getDITStructureRulesByID().values())
@@ -2417,7 +2354,6 @@
      }
    }
    // If we've gotten here, then it's OK to remove the DIT structure rule from
    // the schema.
    schema.deregisterDITStructureRule(removeDSR);
@@ -2428,8 +2364,6 @@
    }
  }
  /**
   * Handles all processing required for adding the provided matching rule use
   * to the given schema, replacing an existing use if necessary, and ensuring
@@ -2482,7 +2416,6 @@
      }
    }
    // Get the matching rule for the new matching rule use and see if there's
    // already an existing matching rule use that is associated with that
    // matching rule.  If there is, then it will only be acceptable if it's the
@@ -2506,7 +2439,6 @@
      throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
    }
    // Make sure that the new matching rule use doesn't reference an undefined
    // attribute type.
    for (AttributeType at : matchingRuleUse.getAttributes())
@@ -2525,7 +2457,6 @@
      }
    }
    // If there is no existing matching rule use, then we're adding a new one.
    // Otherwise, we're replacing an existing matching rule use.
    if (existingMRU == null)
@@ -2543,8 +2474,6 @@
    }
  }
  /**
   * Handles all processing required to remove the provided matching rule use
   * from the server schema, ensuring all other metadata is properly updated.
@@ -2583,7 +2512,6 @@
      throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
    }
    // Since matching rule uses don't have any dependencies, then we don't need
    // to worry about the difference between a remove or a replace.  We can
    // just remove the DIT content rule now, and if it is added back later then
@@ -2661,8 +2589,6 @@
    }
  }
  /** Gets rid of the ldap syntax description. */
  private void removeLdapSyntaxDescription(String definition, Schema schema, Set<String> modifiedSchemaFiles)
      throws DirectoryException
@@ -2692,8 +2618,6 @@
    }
  }
  /**
   * Creates an empty entry that may be used as the basis for a new schema file.
   *
@@ -2721,9 +2645,6 @@
    return new Entry(dn, objectClasses,  userAttributes, operationalAttributes);
  }
  /**
   * Writes a temporary version of the specified schema file.
   *
@@ -2790,7 +2711,6 @@
      schemaEntry.putAttribute(attributeTypesType, newArrayList(builder.toAttribute()));
    }
    // Add all of the appropriate objectclasses to the schema entry.  We need
    // to be careful of the ordering to ensure that any superior classes in the
    // same file are written before the subordinate classes.
@@ -2812,7 +2732,6 @@
      schemaEntry.putAttribute(objectClassesType, newArrayList(builder.toAttribute()));
    }
    // Add all of the appropriate name forms to the schema entry.  Since there
    // is no hierarchical relationship between name forms, we don't need to
    // worry about ordering.
@@ -2835,7 +2754,6 @@
      schemaEntry.putAttribute(nameFormsType, newArrayList(builder.toAttribute()));
    }
    // Add all of the appropriate DIT content rules to the schema entry.  Since
    // there is no hierarchical relationship between DIT content rules, we don't
    // need to worry about ordering.
@@ -2855,7 +2773,6 @@
      schemaEntry.putAttribute(ditContentRulesType, newArrayList(builder.toAttribute()));
    }
    // Add all of the appropriate DIT structure rules to the schema entry.  We
    // need to be careful of the ordering to ensure that any superior rules in
    // the same file are written before the subordinate rules.
@@ -2877,7 +2794,6 @@
      schemaEntry.putAttribute(ditStructureRulesType, newArrayList(builder.toAttribute()));
    }
    // Add all of the appropriate matching rule uses to the schema entry.  Since
    // there is no hierarchical relationship between matching rule uses, we
    // don't need to worry about ordering.
@@ -2897,7 +2813,6 @@
      schemaEntry.putAttribute(matchingRuleUsesType, newArrayList(builder.toAttribute()));
    }
    if (FILE_USER_SCHEMA_ELEMENTS.equals(schemaFile))
    {
      Map<String, Attribute> attributes = schema.getExtraAttributes();
@@ -2913,15 +2828,14 @@
    LDIFExportConfig exportConfig =
         new LDIFExportConfig(tempFile.getAbsolutePath(),
                              ExistingFileBehavior.OVERWRITE);
    LDIFWriter ldifWriter = new LDIFWriter(exportConfig);
    ldifWriter.writeEntry(schemaEntry);
    ldifWriter.close();
    try (LDIFWriter ldifWriter = new LDIFWriter(exportConfig))
    {
      ldifWriter.writeEntry(schemaEntry);
    }
    return tempFile;
  }
  /**
   * Adds the definition for the specified attribute type to the provided set of
   * attribute values, recursively adding superior types as appropriate.
@@ -2970,8 +2884,6 @@
    addedTypes.add(attributeType);
  }
  /**
   * Adds the definition for the specified objectclass to the provided set of
   * attribute values, recursively adding superior classes as appropriate.
@@ -3020,8 +2932,6 @@
    addedClasses.add(objectClass);
  }
  /**
   * Adds the definition for the specified DIT structure rule to the provided
   * set of attribute values, recursively adding superior rules as appropriate.
@@ -3070,8 +2980,6 @@
    addedDSRs.add(ditStructureRule);
  }
  /**
   * Moves the specified temporary schema files in place of the active versions.
   * If an error occurs in the process, then this method will attempt to restore
@@ -3102,7 +3010,6 @@
      origFileList.add(new File(schemaInstanceDir, name + ".orig"));
    }
    // If there are any old ".orig" files laying around from a previous
    // attempt, then try to clean them up.
    for (File f : origFileList)
@@ -3113,7 +3020,6 @@
      }
    }
    // Copy all of the currently-installed files with a ".orig" extension.  If
    // this fails, then try to clean up the copies.
    try
@@ -3167,7 +3073,6 @@
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), message, e);
    }
    // Try to copy all of the temporary files into place over the installed
    // files.  If this fails, then try to restore the originals.
    try
@@ -3247,8 +3152,6 @@
    }
  }
  /**
   * Creates a copy of the specified file.
   *
@@ -3259,14 +3162,10 @@
   */
  private void copyFile(File from, File to) throws IOException
  {
    byte[]           buffer        = new byte[4096];
    FileInputStream  inputStream   = null;
    FileOutputStream outputStream  = null;
    try
    try (FileInputStream inputStream = new FileInputStream(from);
        FileOutputStream outputStream = new FileOutputStream(to, false))
    {
      inputStream  = new FileInputStream(from);
      outputStream = new FileOutputStream(to, false);
      byte[] buffer = new byte[4096];
      int bytesRead = inputStream.read(buffer);
      while (bytesRead > 0)
      {
@@ -3274,14 +3173,8 @@
        bytesRead = inputStream.read(buffer);
      }
    }
    finally
    {
      close(inputStream, outputStream);
    }
  }
  /**
   * Performs any necessary cleanup in an attempt to delete any temporary schema
   * files that may have been left over after trying to install the new schema.
@@ -3332,7 +3225,6 @@
              matchedDN, null);
    }
    // If it's a onelevel or subordinate subtree search, then we will never
    // match anything since there isn't anything below the schema.
    SearchScope scope = searchOperation.getScope();
@@ -3342,7 +3234,6 @@
      return;
    }
    // Get the schema entry and see if it matches the filter.  If so, then send
    // it to the client.
    Entry schemaEntry = getSchemaEntry(baseDN, false);
@@ -3385,7 +3276,6 @@
                                   message);
    }
    // Write the root schema entry to it.  Make sure to close the LDIF
    // writer when we're done.
    try
@@ -3429,19 +3319,7 @@
  public LDIFImportResult importLDIF(LDIFImportConfig importConfig, ServerContext serverContext)
      throws DirectoryException
  {
    LDIFReader reader;
    try
    {
      reader = new LDIFReader(importConfig);
    }
    catch (Exception e)
    {
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
          ERR_MEMORYBACKEND_CANNOT_CREATE_LDIF_READER.get(e), e);
    }
    try
    try (LDIFReader reader = newLDIFReader(importConfig))
    {
      while (true)
      {
@@ -3481,12 +3359,20 @@
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
          ERR_MEMORYBACKEND_ERROR_DURING_IMPORT.get(e), e);
    }
    finally
    {
      close(reader);
    }
  }
  private LDIFReader newLDIFReader(LDIFImportConfig importConfig) throws DirectoryException
  {
    try
    {
      return new LDIFReader(importConfig);
    }
    catch (Exception e)
    {
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
          ERR_MEMORYBACKEND_CANNOT_CREATE_LDIF_READER.get(e), e);
    }
  }
  /**
   * Import an entry in a new schema by :
@@ -3689,7 +3575,6 @@
  {
    final ConfigChangeResult ccr = new ConfigChangeResult();
    // Check to see if we should apply a new set of base DNs.
    Set<DN> newBaseDNs;
    try
@@ -3710,12 +3595,10 @@
      newBaseDNs = null;
    }
    // Check to see if we should change the behavior regarding whether to show
    // all schema attributes.
    boolean newShowAllAttributes = backendCfg.isShowAllAttributes();
    // Check to see if there is a new set of user-defined attributes.
    ArrayList<Attribute> newUserAttrs = new ArrayList<>();
    try
@@ -3753,7 +3636,6 @@
      ccr.setResultCode(DirectoryServer.getServerErrorResultCode());
    }
    if (ccr.getResultCode() == ResultCode.SUCCESS)
    {
      // Determine the set of DNs to add and delete.  When this is done, the
@@ -3802,22 +3684,17 @@
        }
      }
      showAllAttributes = newShowAllAttributes;
      userDefinedAttributes = newUserAttrs;
      LocalizableMessage message = INFO_SCHEMA_USING_NEW_USER_ATTRS.get();
      ccr.addMessage(message);
    }
    currentConfig = backendCfg;
    return ccr;
  }
  /**
   * Indicates whether to treat common schema attributes like user attributes
   * rather than operational attributes.
@@ -3830,8 +3707,6 @@
    return showAllAttributes;
  }
  /**
   * Specifies whether to treat common schema attributes like user attributes
   * rather than operational attributes.
opendj-server-legacy/src/main/java/org/opends/server/backends/TrustStoreBackend.java
@@ -101,31 +101,23 @@
{
  private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
  /** The current configuration state. */
  private TrustStoreBackendCfg configuration;
  /** The set of base DNs for this backend. */
  private SortedSet<DN> baseDNs;
  /** The base entry. */
  private Entry baseEntry;
  /** The PIN needed to access the trust store backing file. */
  private char[] trustStorePIN;
  /** The path to the trust store backing file. */
  private String trustStoreFile;
  /** The type of trust store backing file to use. */
  private String trustStoreType;
  /** The certificate manager for the trust store. */
  private CertificateManager certificateManager;
  /**
   * Creates a new backend.  All backend
   * implementations must implement a default constructor that use
@@ -185,109 +177,8 @@
          trustStoreType, configEntryDN, getExceptionMessage(kse)));
    }
    trustStorePIN = getTrustStorePIN(configEntryDN);
    // Get the PIN needed to access the contents of the trust store file.  We
    // will offer several places to look for the PIN, and we will do so in the
    // following order:
    // - In a specified Java property
    // - In a specified environment variable
    // - In a specified file on the server filesystem.
    // - As the value of a configuration attribute.
    // In any case, the PIN must be in the clear.  If no PIN is provided, then
    // it will be assumed that none is required to access the information in the
    // trust store.
    String pinProperty = configuration.getTrustStorePinProperty();
    if (pinProperty == null)
    {
      String pinEnVar = configuration.getTrustStorePinEnvironmentVariable();
      if (pinEnVar == null)
      {
        String pinFilePath = configuration.getTrustStorePinFile();
        if (pinFilePath == null)
        {
          String pinStr = configuration.getTrustStorePin();
          if (pinStr == null)
          {
            // This should be an Error. Otherwise, programs fails.
            // Is there a Unit Test?
            trustStorePIN = null;
          }
          else
          {
            trustStorePIN = pinStr.toCharArray();
          }
        }
        else
        {
          File pinFile = getFileForPath(pinFilePath);
          if (! pinFile.exists())
          {
            try
            {
              // Generate a PIN.
              trustStorePIN = createKeystorePassword();
              // Store the PIN in the pin file.
              createPINFile(pinFile.getPath(), new String(trustStorePIN));
            }
            catch (Exception e)
            {
              throw new InitializationException(
                  ERR_TRUSTSTORE_PIN_FILE_CANNOT_CREATE.get(pinFilePath, configEntryDN));
            }
          }
          else
          {
            String pinStr;
            BufferedReader br = null;
            try
            {
              br = new BufferedReader(new FileReader(pinFile));
              pinStr = br.readLine();
            }
            catch (IOException ioe)
            {
              LocalizableMessage message = ERR_TRUSTSTORE_PIN_FILE_CANNOT_READ.
                  get(pinFilePath, configEntryDN, getExceptionMessage(ioe));
              throw new InitializationException(message, ioe);
            }
            finally
            {
              close(br);
            }
            if (pinStr == null)
            {
              throw new InitializationException(
                  ERR_TRUSTSTORE_PIN_FILE_EMPTY.get(pinFilePath, configEntryDN));
            }
            trustStorePIN = pinStr.toCharArray();
          }
        }
      }
      else
      {
        String pinStr = System.getenv(pinEnVar);
        if (pinStr == null)
        {
          throw new InitializationException(
              ERR_TRUSTSTORE_PIN_ENVAR_NOT_SET.get(pinProperty, configEntryDN));
        }
        trustStorePIN = pinStr.toCharArray();
      }
    }
    else
    {
      String pinStr = System.getProperty(pinProperty);
      if (pinStr == null)
      {
        throw new InitializationException(ERR_TRUSTSTORE_PIN_PROPERTY_NOT_SET.get(pinProperty, configEntryDN));
      }
      trustStorePIN = pinStr.toCharArray();
    }
    // Create a certificate manager.
    certificateManager =
         new CertificateManager(getFileForPath(trustStoreFile).getPath(),
                                trustStoreType,
@@ -316,7 +207,6 @@
    // Register this as a change listener.
    configuration.addTrustStoreChangeListener(this);
    // Register the trust store base as a private suffix.
    try
    {
@@ -329,7 +219,74 @@
    }
  }
  /** {@inheritDoc} */
  /**
   * Get the PIN needed to access the contents of the trust store file. We will offer several places
   * to look for the PIN, and we will do so in the following order:
   * <ol>
   * <li>In a specified Java property</li>
   * <li>In a specified environment variable</li>
   * <li>In a specified file on the server filesystem</li>
   * <li>As the value of a configuration attribute</li>
   * </ol>
   * In any case, the PIN must be in the clear. If no PIN is provided, then it will be assumed that
   * none is required to access the information in the trust store.
   */
  private char[] getTrustStorePIN(DN configEntryDN) throws InitializationException
  {
    final String pinProperty = configuration.getTrustStorePinProperty();
    if (pinProperty != null)
    {
      String pinStr = System.getProperty(pinProperty);
      if (pinStr == null)
      {
        throw new InitializationException(ERR_TRUSTSTORE_PIN_PROPERTY_NOT_SET.get(pinProperty, configEntryDN));
      }
      return pinStr.toCharArray();
    }
    final String pinEnVar = configuration.getTrustStorePinEnvironmentVariable();
    if (pinEnVar != null)
    {
      String pinStr = System.getenv(pinEnVar);
      if (pinStr == null)
      {
        throw new InitializationException(ERR_TRUSTSTORE_PIN_ENVAR_NOT_SET.get(pinProperty, configEntryDN));
      }
      return pinStr.toCharArray();
    }
    final String pinFilePath = configuration.getTrustStorePinFile();
    if (pinFilePath != null)
    {
      File pinFile = getFileForPath(pinFilePath);
      if (pinFile.exists())
      {
        String pinStr = readPinFromFile(pinFile, configEntryDN);
        if (pinStr == null)
        {
          throw new InitializationException(ERR_TRUSTSTORE_PIN_FILE_EMPTY.get(pinFilePath, configEntryDN));
        }
        return pinStr.toCharArray();
      }
      try
      {
        // Generate and store the PIN in the pin file.
        final char[] trustStorePIN = createKeystorePassword();
        createPINFile(pinFile.getPath(), new String(trustStorePIN));
        return trustStorePIN;
      }
      catch (Exception e)
      {
        throw new InitializationException(ERR_TRUSTSTORE_PIN_FILE_CANNOT_CREATE.get(pinFilePath, configEntryDN));
      }
    }
    String pinStr = configuration.getTrustStorePin();
    // else branch should be an Error. Otherwise, programs fails. Is there a Unit Test?
    return pinStr != null ? pinStr.toCharArray() : null;
  }
  @Override
  public void closeBackend()
  {
@@ -372,7 +329,6 @@
    return numEntries;
  }
  /** {@inheritDoc} */
  @Override
  public boolean isIndexed(AttributeType attributeType, IndexType indexType)
  {
@@ -380,7 +336,6 @@
    return true;
  }
  /** {@inheritDoc} */
  @Override
  public Entry getEntry(DN entryDN) throws DirectoryException
  {
@@ -391,14 +346,12 @@
          ERR_BACKEND_GET_ENTRY_NULL.get(getBackendID()));
    }
    // If the requested entry was the backend base entry, then retrieve it.
    if (entryDN.equals(getBaseDN()))
    {
      return baseEntry.duplicate(true);
    }
    // See if the requested entry was one level below the backend base entry.
    // If so, then it must point to a trust store entry.
    DN parentDN = DirectoryServer.getParentDNInSuffix(entryDN);
@@ -416,8 +369,6 @@
    return null;
  }
  /**
   * Generates an entry for a certificate based on the provided DN.  The
   * DN must contain an RDN component that specifies the alias of the
@@ -476,20 +427,17 @@
    userAttrs.put(t, Attributes.createAsList(t, v));
    t = DirectoryServer.getAttributeType(ATTR_CRYPTO_PUBLIC_KEY_CERTIFICATE);
    AttributeBuilder builder = new AttributeBuilder(t);
    builder.setOption("binary");
    builder.add(certValue);
    userAttrs.put(t, builder.toAttributeList());
    Entry e = new Entry(entryDN, ocMap, userAttrs, opAttrs);
    e.processVirtualAttributes();
    return e;
  }
  /** {@inheritDoc} */
  @Override
  public void addEntry(Entry entry, AddOperation addOperation)
         throws DirectoryException
@@ -520,7 +468,6 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  public void deleteEntry(DN entryDN, DeleteOperation deleteOperation)
         throws DirectoryException
@@ -541,7 +488,6 @@
    deleteCertificate(entryDN);
  }
  /** {@inheritDoc} */
  @Override
  public void replaceEntry(Entry oldEntry, Entry newEntry,
      ModifyOperation modifyOperation) throws DirectoryException
@@ -550,7 +496,6 @@
        ERR_BACKEND_MODIFY_NOT_SUPPORTED.get(oldEntry.getName(), getBackendID()));
  }
  /** {@inheritDoc} */
  @Override
  public void renameEntry(DN currentDN, Entry entry,
                          ModifyDNOperation modifyDNOperation)
@@ -560,7 +505,6 @@
        ERR_BACKEND_MODIFY_DN_NOT_SUPPORTED.get(currentDN, getBackendID()));
  }
  /** {@inheritDoc} */
  @Override
  public void search(SearchOperation searchOperation)
         throws DirectoryException
@@ -570,7 +514,6 @@
    DN    baseDN    = searchOperation.getBaseDN();
    Entry baseEntry = getEntry(baseDN);
    // Look at the base DN and see if it's the trust store base DN, or a
    // trust store entry DN.
    SearchScope  scope  = searchOperation.getScope();
@@ -603,7 +546,7 @@
        AttributeType certAliasType = DirectoryServer.getAttributeType(ATTR_CRYPTO_KEY_ID);
        for (String alias : aliases)
        {
          DN certDN = makeChildDN(this.getBaseDN(), certAliasType, alias);
          DN certDN = makeChildDN(getBaseDN(), certAliasType, alias);
          Entry certEntry;
          try
@@ -623,7 +566,7 @@
        }
      }
    }
    else if (this.getBaseDN().equals(DirectoryServer.getParentDNInSuffix(baseDN)))
    else if (getBaseDN().equals(DirectoryServer.getParentDNInSuffix(baseDN)))
    {
      Entry certEntry = getCertEntry(baseDN);
@@ -640,28 +583,24 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  public Set<String> getSupportedControls()
  {
    return Collections.emptySet();
  }
  /** {@inheritDoc} */
  @Override
  public Set<String> getSupportedFeatures()
  {
    return Collections.emptySet();
  }
  /** {@inheritDoc} */
  @Override
  public boolean supports(BackendOperation backendOperation)
  {
    return false;
  }
  /** {@inheritDoc} */
  @Override
  public void exportLDIF(LDIFExportConfig exportConfig)
         throws DirectoryException
@@ -670,7 +609,6 @@
        ERR_BACKEND_IMPORT_AND_EXPORT_NOT_SUPPORTED.get(getBackendID()));
  }
  /** {@inheritDoc} */
  @Override
  public LDIFImportResult importLDIF(LDIFImportConfig importConfig, ServerContext serverContext)
      throws DirectoryException
@@ -679,7 +617,6 @@
        ERR_BACKEND_IMPORT_AND_EXPORT_NOT_SUPPORTED.get(getBackendID()));
  }
  /** {@inheritDoc} */
  @Override
  public void createBackup(BackupConfig backupConfig)
       throws DirectoryException
@@ -688,7 +625,6 @@
        ERR_BACKEND_BACKUP_AND_RESTORE_NOT_SUPPORTED.get(getBackendID()));
  }
  /** {@inheritDoc} */
  @Override
  public void removeBackup(BackupDirectory backupDirectory,
                           String backupID)
@@ -698,7 +634,6 @@
        ERR_BACKEND_BACKUP_AND_RESTORE_NOT_SUPPORTED.get(getBackendID()));
  }
  /** {@inheritDoc} */
  @Override
  public void restoreBackup(RestoreConfig restoreConfig)
         throws DirectoryException
@@ -707,7 +642,6 @@
        ERR_BACKEND_BACKUP_AND_RESTORE_NOT_SUPPORTED.get(getBackendID()));
  }
  /** {@inheritDoc} */
  @Override
  public ConditionResult hasSubordinates(DN entryDN)
      throws DirectoryException
@@ -716,7 +650,6 @@
        ERR_HAS_SUBORDINATES_NOT_SUPPORTED.get());
  }
  /** {@inheritDoc} */
  @Override
  public long getNumberOfEntriesInBaseDN(DN baseDN) throws DirectoryException
  {
@@ -724,7 +657,6 @@
    throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, ERR_NUM_SUBORDINATES_NOT_SUPPORTED.get());
  }
  /** {@inheritDoc} */
  @Override
  public long getNumberOfChildren(DN parentDN) throws DirectoryException
  {
@@ -732,14 +664,12 @@
    throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, ERR_NUM_SUBORDINATES_NOT_SUPPORTED.get());
  }
  /** {@inheritDoc} */
  @Override
  public boolean isConfigurationChangeAcceptable(
       TrustStoreBackendCfg configuration, List<LocalizableMessage> unacceptableReasons)
  {
    boolean configAcceptable = true;
    DN cfgEntryDN = configuration.dn();
    final ConfigChangeResult ccr = new ConfigChangeResult();
    final DN cfgEntryDN = configuration.dn();
    // Get the path to the trust store file.
    String newTrustStoreFile = configuration.getTrustStoreFile();
@@ -748,19 +678,16 @@
      File f = getFileForPath(newTrustStoreFile);
      if (!f.exists() || !f.isFile())
      {
        unacceptableReasons.add(ERR_TRUSTSTORE_NO_SUCH_FILE.get(newTrustStoreFile, cfgEntryDN));
        configAcceptable = false;
        ccr.addMessage(ERR_TRUSTSTORE_NO_SUCH_FILE.get(newTrustStoreFile, cfgEntryDN));
      }
    }
    catch (Exception e)
    {
      logger.traceException(e);
      unacceptableReasons.add(ERR_TRUSTSTORE_CANNOT_DETERMINE_FILE.get(cfgEntryDN, getExceptionMessage(e)));
      configAcceptable = false;
      ccr.addMessage(ERR_TRUSTSTORE_CANNOT_DETERMINE_FILE.get(cfgEntryDN, getExceptionMessage(e)));
    }
    // Check to see if the trust store type is acceptable.
    String storeType = configuration.getTrustStoreType();
    if (storeType != null)
@@ -773,33 +700,26 @@
      {
        logger.traceException(kse);
        unacceptableReasons.add(ERR_TRUSTSTORE_INVALID_TYPE.get(
            storeType, cfgEntryDN, getExceptionMessage(kse)));
        configAcceptable = false;
        ccr.addMessage(ERR_TRUSTSTORE_INVALID_TYPE.get(storeType, cfgEntryDN, getExceptionMessage(kse)));
      }
    }
    // If there is a PIN property, then make sure the corresponding
    // property is set.
    String pinProp = configuration.getTrustStorePinProperty();
    if (pinProp != null && System.getProperty(pinProp) == null)
    {
      unacceptableReasons.add(ERR_TRUSTSTORE_PIN_PROPERTY_NOT_SET.get(pinProp, cfgEntryDN));
      configAcceptable = false;
      ccr.addMessage(ERR_TRUSTSTORE_PIN_PROPERTY_NOT_SET.get(pinProp, cfgEntryDN));
    }
    // If there is a PIN environment variable, then make sure the corresponding
    // environment variable is set.
    String pinEnVar = configuration.getTrustStorePinEnvironmentVariable();
    if (pinEnVar != null && System.getenv(pinEnVar) == null)
    {
      unacceptableReasons.add(ERR_TRUSTSTORE_PIN_ENVAR_NOT_SET.get(pinEnVar, cfgEntryDN));
      configAcceptable = false;
      ccr.addMessage(ERR_TRUSTSTORE_PIN_ENVAR_NOT_SET.get(pinEnVar, cfgEntryDN));
    }
    // If there is a PIN file, then make sure the file is readable if it exists.
    String pinFile = configuration.getTrustStorePinFile();
    if (pinFile != null)
@@ -807,38 +727,19 @@
      File f = new File(pinFile);
      if (f.exists())
      {
        String pinStr = null;
        BufferedReader br = null;
        try
        {
          br = new BufferedReader(new FileReader(pinFile));
          pinStr = br.readLine();
        }
        catch (IOException ioe)
        {
          unacceptableReasons.add(ERR_TRUSTSTORE_PIN_FILE_CANNOT_READ.get(
              pinFile, cfgEntryDN, getExceptionMessage(ioe)));
          configAcceptable = false;
        }
        finally
        {
          close(br);
        }
        String pinStr = readPinFromFile2(f, cfgEntryDN, ccr);
        if (pinStr == null)
        {
          unacceptableReasons.add(ERR_TRUSTSTORE_PIN_FILE_EMPTY.get(pinFile, cfgEntryDN));
          configAcceptable = false;
          ccr.addMessage(ERR_TRUSTSTORE_PIN_FILE_EMPTY.get(pinFile, cfgEntryDN));
        }
      }
    }
    return configAcceptable;
    final List<LocalizableMessage> messages = ccr.getMessages();
    unacceptableReasons.addAll(messages);
    return messages.isEmpty();
  }
  /** {@inheritDoc} */
  @Override
  public ConfigChangeResult applyConfigurationChange(TrustStoreBackendCfg cfg)
  {
@@ -854,7 +755,6 @@
      ccr.addMessage(ERR_TRUSTSTORE_NO_SUCH_FILE.get(newTrustStoreFile, configEntryDN));
    }
    // Get the trust store type.  If none is specified, then use the default
    // type.
    String newTrustStoreType = cfg.getTrustStoreType();
@@ -875,117 +775,7 @@
      ccr.setResultCode(DirectoryServer.getServerErrorResultCode());
    }
    // Get the PIN needed to access the contents of the trust store file.  We
    // will offer several places to look for the PIN, and we will do so in the
    // following order:
    // - In a specified Java property
    // - In a specified environment variable
    // - In a specified file on the server filesystem.
    // - As the value of a configuration attribute.
    // In any case, the PIN must be in the clear.  If no PIN is provided, then
    // it will be assumed that none is required to access the information in the
    // trust store.
    char[] newPIN = null;
    String newPINProperty = cfg.getTrustStorePinProperty();
    if (newPINProperty == null)
    {
      String newPINEnVar = cfg.getTrustStorePinEnvironmentVariable();
      if (newPINEnVar == null)
      {
        String newPINFile = cfg.getTrustStorePinFile();
        if (newPINFile == null)
        {
          String pinStr = cfg.getTrustStorePin();
          if (pinStr == null)
          {
            newPIN = null;
          }
          else
          {
            newPIN = pinStr.toCharArray();
          }
        }
        else
        {
          File pinFile = getFileForPath(newPINFile);
          if (! pinFile.exists())
          {
            try
            {
              // Generate a PIN.
              newPIN = createKeystorePassword();
              // Store the PIN in the pin file.
              createPINFile(pinFile.getPath(), new String(newPIN));
            }
            catch (Exception e)
            {
              ccr.setResultCode(DirectoryServer.getServerErrorResultCode());
              ccr.addMessage(ERR_TRUSTSTORE_PIN_FILE_CANNOT_CREATE.get(newPINFile, configEntryDN));
            }
          }
          else
          {
            String pinStr = null;
            BufferedReader br = null;
            try
            {
              br = new BufferedReader(new FileReader(pinFile));
              pinStr = br.readLine();
            }
            catch (IOException ioe)
            {
              ccr.setResultCode(DirectoryServer.getServerErrorResultCode());
              ccr.addMessage(ERR_TRUSTSTORE_PIN_FILE_CANNOT_READ.get(
                  newPINFile, configEntryDN, getExceptionMessage(ioe)));
            }
            finally
            {
              close(br);
            }
            if (pinStr == null)
            {
              ccr.setResultCode(DirectoryServer.getServerErrorResultCode());
              ccr.addMessage(ERR_TRUSTSTORE_PIN_FILE_EMPTY.get(newPINFile, configEntryDN));
            }
            else
            {
              newPIN = pinStr.toCharArray();
            }
          }
        }
      }
      else
      {
        String pinStr = System.getenv(newPINEnVar);
        if (pinStr == null)
        {
          ccr.setResultCode(DirectoryServer.getServerErrorResultCode());
          ccr.addMessage(ERR_TRUSTSTORE_PIN_ENVAR_NOT_SET.get(newPINEnVar, configEntryDN));
        }
        else
        {
          newPIN = pinStr.toCharArray();
        }
      }
    }
    else
    {
      String pinStr = System.getProperty(newPINProperty);
      if (pinStr == null)
      {
        ccr.setResultCode(DirectoryServer.getServerErrorResultCode());
        ccr.addMessage(ERR_TRUSTSTORE_PIN_PROPERTY_NOT_SET.get(newPINProperty, configEntryDN));
      }
      else
      {
        newPIN = pinStr.toCharArray();
      }
    }
    char[] newPIN = getTrustStorePIN2(cfg, ccr);
    if (ccr.getResultCode() == ResultCode.SUCCESS)
    {
@@ -1003,6 +793,123 @@
  }
  /**
   * Get the PIN needed to access the contents of the trust store file. We will offer several places
   * to look for the PIN, and we will do so in the following order:
   * <ol>
   * <li>In a specified Java property</li>
   * <li>In a specified environment variable</li>
   * <li>In a specified file on the server filesystem.</li>
   * <li>As the value of a configuration attribute.</li>
   * </ol>
   * In any case, the PIN must be in the clear. If no PIN is provided, then it will be assumed that
   * none is required to access the information in the trust store.
   */
  private char[] getTrustStorePIN2(TrustStoreBackendCfg cfg, ConfigChangeResult ccr)
  {
    String newPINProperty = cfg.getTrustStorePinProperty();
    if (newPINProperty == null)
    {
      String newPINEnVar = cfg.getTrustStorePinEnvironmentVariable();
      if (newPINEnVar == null)
      {
        String newPINFile = cfg.getTrustStorePinFile();
        if (newPINFile == null)
        {
          String pinStr = cfg.getTrustStorePin();
          return pinStr != null ? pinStr.toCharArray() : null;
        }
        else
        {
          File pinFile = getFileForPath(newPINFile);
          if (! pinFile.exists())
          {
            try
            {
              // Generate and store a PIN in the pin file.
              final char[] newPIN = createKeystorePassword();
              createPINFile(pinFile.getPath(), new String(newPIN));
              return newPIN;
            }
            catch (Exception e)
            {
              ccr.setResultCode(DirectoryServer.getServerErrorResultCode());
              ccr.addMessage(ERR_TRUSTSTORE_PIN_FILE_CANNOT_CREATE.get(newPINFile, cfg.dn()));
            }
          }
          else
          {
            String pinStr = readPinFromFile2(pinFile, cfg.dn(), ccr);
            if (pinStr == null)
            {
              ccr.setResultCode(DirectoryServer.getServerErrorResultCode());
              ccr.addMessage(ERR_TRUSTSTORE_PIN_FILE_EMPTY.get(newPINFile, cfg.dn()));
            }
            else
            {
              return pinStr.toCharArray();
            }
          }
        }
      }
      else
      {
        String pinStr = System.getenv(newPINEnVar);
        if (pinStr == null)
        {
          ccr.setResultCode(DirectoryServer.getServerErrorResultCode());
          ccr.addMessage(ERR_TRUSTSTORE_PIN_ENVAR_NOT_SET.get(newPINEnVar, cfg.dn()));
        }
        else
        {
          return pinStr.toCharArray();
        }
      }
    }
    else
    {
      String pinStr = System.getProperty(newPINProperty);
      if (pinStr == null)
      {
        ccr.setResultCode(DirectoryServer.getServerErrorResultCode());
        ccr.addMessage(ERR_TRUSTSTORE_PIN_PROPERTY_NOT_SET.get(newPINProperty, cfg.dn()));
      }
      else
      {
        return pinStr.toCharArray();
      }
    }
    return null;
  }
  private String readPinFromFile(File pinFile, DN cfgEntryDN) throws InitializationException
  {
    try (BufferedReader br = new BufferedReader(new FileReader(pinFile)))
    {
      return br.readLine();
    }
    catch (IOException ioe)
    {
      LocalizableMessage message =
          ERR_TRUSTSTORE_PIN_FILE_CANNOT_READ.get(pinFile, cfgEntryDN, getExceptionMessage(ioe));
      throw new InitializationException(message, ioe);
    }
  }
  private String readPinFromFile2(File pinFile, DN cfgEntryDN, ConfigChangeResult ccr)
  {
    try (BufferedReader br = new BufferedReader(new FileReader(pinFile)))
    {
      return br.readLine();
    }
    catch (IOException ioe)
    {
      ccr.setResultCode(DirectoryServer.getServerErrorResultCode());
      ccr.addMessage(ERR_TRUSTSTORE_PIN_FILE_CANNOT_READ.get(pinFile, cfgEntryDN, getExceptionMessage(ioe)));
      return null;
    }
  }
  /**
   * Create a new child DN from a given parent DN.  The child RDN is formed
   * from a given attribute type and string value.
   * @param parentDN The DN of the parent.
@@ -1017,7 +924,6 @@
    return parentDN.child(new RDN(rdnAttrType, attrValue));
  }
  /**
   * Retrieves a set of <CODE>KeyManager</CODE> objects that may be used for
   * interactions requiring access to a key manager.
@@ -1031,19 +937,7 @@
  public KeyManager[] getKeyManagers()
         throws DirectoryException
  {
    final KeyStore keyStore;
    try (final FileInputStream inputStream = new FileInputStream(getFileForPath(trustStoreFile)))
    {
      keyStore = KeyStore.getInstance(trustStoreType);
      keyStore.load(inputStream, trustStorePIN);
    }
    catch (Exception e)
    {
      LocalizableMessage message = ERR_TRUSTSTORE_CANNOT_LOAD.get(
          trustStoreFile, getExceptionMessage(e));
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
                                   message, e);
    }
    final KeyStore keyStore = loadKeyStore();
    try
    {
@@ -1064,6 +958,20 @@
    }
  }
  private KeyStore loadKeyStore() throws DirectoryException
  {
    try (FileInputStream inputStream = new FileInputStream(getFileForPath(trustStoreFile)))
    {
      final KeyStore keyStore = KeyStore.getInstance(trustStoreType);
      keyStore.load(inputStream, trustStorePIN);
      return keyStore;
    }
    catch (Exception e)
    {
      LocalizableMessage message = ERR_TRUSTSTORE_CANNOT_LOAD.get(trustStoreFile, getExceptionMessage(e));
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), message, e);
    }
  }
  /**
   * Retrieves a set of {@code TrustManager} objects that may be used
@@ -1078,30 +986,7 @@
  public TrustManager[] getTrustManagers()
         throws DirectoryException
  {
    KeyStore trustStore;
    FileInputStream inputStream = null;
    try
    {
      trustStore = KeyStore.getInstance(trustStoreType);
      inputStream =
           new FileInputStream(getFileForPath(trustStoreFile));
      trustStore.load(inputStream, trustStorePIN);
    }
    catch (Exception e)
    {
      logger.traceException(e);
      LocalizableMessage message = ERR_TRUSTSTORE_CANNOT_LOAD.get(
          trustStoreFile, getExceptionMessage(e));
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
                                   message, e);
    }
    finally
    {
      close(inputStream);
    }
    KeyStore trustStore = loadKeyStore();
    try
    {
@@ -1122,7 +1007,6 @@
    }
  }
  /**
   * Returns the key associated with the given alias, using the trust
   * store pin to recover it.
@@ -1137,29 +1021,7 @@
  public Key getKey(String alias)
         throws DirectoryException
  {
    KeyStore trustStore;
    FileInputStream inputStream = null;
    try
    {
      trustStore = KeyStore.getInstance(trustStoreType);
      inputStream =
           new FileInputStream(getFileForPath(trustStoreFile));
      trustStore.load(inputStream, trustStorePIN);
    }
    catch (Exception e)
    {
      logger.traceException(e);
      LocalizableMessage message = ERR_TRUSTSTORE_CANNOT_LOAD.get(
          trustStoreFile, getExceptionMessage(e));
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
                                   message, e);
    }
    finally
    {
      close(inputStream);
    }
    KeyStore trustStore = loadKeyStore();
    try
    {
@@ -1176,7 +1038,6 @@
    }
  }
  private void addCertificate(Entry entry)
       throws DirectoryException
  {
@@ -1268,16 +1129,10 @@
                                              certAlias, tempDir);
          try
          {
            FileOutputStream outputStream =
                 new FileOutputStream(tempFile.getPath(), false);
            try
            try (FileOutputStream outputStream = new FileOutputStream(tempFile.getPath(), false))
            {
              certBytes.copyTo(outputStream);
            }
            finally
            {
              outputStream.close();
            }
            certificateManager.addCertificate(certAlias, tempFile);
          }
@@ -1302,10 +1157,8 @@
      throw new DirectoryException(
           DirectoryServer.getServerErrorResultCode(), message, e);
    }
  }
  private void deleteCertificate(DN entryDN)
       throws DirectoryException
  {
@@ -1338,7 +1191,6 @@
    }
  }
  /**
   * Returns the validity period to be used to generate the ADS certificate.
   * @return The validity period to be used to generate the ADS certificate.
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/BackendImpl.java
@@ -163,7 +163,6 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  public void configureBackend(C cfg, ServerContext serverContext) throws ConfigException
  {
@@ -175,7 +174,6 @@
    storage = new TracedStorage(configureStorage(cfg, serverContext), cfg.getBackendId());
  }
  /** {@inheritDoc} */
  @Override
  public void openBackend() throws ConfigException, InitializationException
  {
@@ -218,7 +216,6 @@
    cfg.addPluggableChangeListener(this);
  }
  /** {@inheritDoc} */
  @Override
  public void closeBackend()
  {
@@ -279,7 +276,6 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  public boolean supports(BackendOperation backendOperation)
  {
@@ -295,14 +291,12 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  public Set<String> getSupportedFeatures()
  {
    return Collections.emptySet();
  }
  /** {@inheritDoc} */
  @Override
  public Set<String> getSupportedControls()
  {
@@ -315,7 +309,6 @@
    return baseDNs;
  }
  /** {@inheritDoc} */
  @Override
  public long getEntryCount()
  {
@@ -333,7 +326,6 @@
    return -1;
  }
  /** {@inheritDoc} */
  @Override
  public ConditionResult hasSubordinates(DN entryDN) throws DirectoryException
  {
@@ -366,7 +358,6 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  public long getNumberOfEntriesInBaseDN(DN baseDN) throws DirectoryException
  {
@@ -389,7 +380,6 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  public long getNumberOfChildren(DN parentDN) throws DirectoryException
  {
@@ -428,7 +418,6 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  public boolean entryExists(final DN entryDN) throws DirectoryException
  {
@@ -449,7 +438,6 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  public Entry getEntry(DN entryDN) throws DirectoryException
  {
@@ -470,7 +458,6 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  public void addEntry(Entry entry, AddOperation addOperation) throws DirectoryException, CanceledOperationException
  {
@@ -492,7 +479,6 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  public void deleteEntry(DN entryDN, DeleteOperation deleteOperation)
      throws DirectoryException, CanceledOperationException
@@ -515,7 +501,6 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  public void replaceEntry(Entry oldEntry, Entry newEntry, ModifyOperation modifyOperation)
      throws DirectoryException, CanceledOperationException
@@ -539,7 +524,6 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  public void renameEntry(DN currentDN, Entry entry, ModifyDNOperation modifyDNOperation)
      throws DirectoryException, CanceledOperationException
@@ -571,7 +555,6 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  public void search(SearchOperation searchOperation) throws DirectoryException, CanceledOperationException
  {
@@ -603,7 +586,6 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  public void exportLDIF(LDIFExportConfig exportConfig)
      throws DirectoryException
@@ -644,7 +626,6 @@
    return rootContainer == null;
  }
  /** {@inheritDoc} */
  @Override
  public LDIFImportResult importLDIF(LDIFImportConfig importConfig, ServerContext serverContext)
      throws DirectoryException
@@ -721,7 +702,6 @@
    return new OnDiskMergeImporter.StrategyImpl(serverContext, rootContainer, cfg);
  }
  /** {@inheritDoc} */
  @Override
  public long verifyBackend(VerifyConfig verifyConfig)
      throws InitializationException, ConfigException, DirectoryException
@@ -767,7 +747,6 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  public void rebuildBackend(RebuildConfig rebuildConfig, ServerContext serverContext)
      throws InitializationException, ConfigException, DirectoryException
@@ -824,14 +803,12 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  public void createBackup(BackupConfig backupConfig) throws DirectoryException
  {
    storage.createBackup(backupConfig);
  }
  /** {@inheritDoc} */
  @Override
  public void removeBackup(BackupDirectory backupDirectory, String backupID)
      throws DirectoryException
@@ -839,7 +816,6 @@
    storage.removeBackup(backupDirectory, backupID);
  }
  /** {@inheritDoc} */
  @Override
  public void restoreBackup(RestoreConfig restoreConfig) throws DirectoryException
  {
@@ -860,7 +836,6 @@
   */
  protected abstract Storage configureStorage(C cfg, ServerContext serverContext) throws ConfigException;
  /** {@inheritDoc} */
  @Override
  public boolean isConfigurationAcceptable(C config, List<LocalizableMessage> unacceptableReasons,
      ServerContext serverContext)
@@ -868,14 +843,12 @@
    return isConfigurationChangeAcceptable(config, unacceptableReasons);
  }
  /** {@inheritDoc} */
  @Override
  public boolean isConfigurationChangeAcceptable(PluggableBackendCfg cfg, List<LocalizableMessage> unacceptableReasons)
  {
    return true;
  }
  /** {@inheritDoc} */
  @Override
  public ConfigChangeResult applyConfigurationChange(final PluggableBackendCfg newCfg)
  {
@@ -1020,5 +993,4 @@
      throw new InitializationException(ERR_OPEN_ENV_FAIL.get(e.getMessage()), e);
    }
  }
}
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/BackendMonitor.java
@@ -25,8 +25,8 @@
import java.util.concurrent.atomic.AtomicInteger;
import org.forgerock.i18n.LocalizableMessage;
import org.opends.server.api.MonitorData;
import org.forgerock.opendj.server.config.server.MonitorProviderCfg;
import org.opends.server.api.MonitorData;
import org.opends.server.api.MonitorProvider;
import org.opends.server.types.SearchFilter;
import org.opends.server.util.TimeThread;
@@ -105,7 +105,7 @@
    MonitorData monitorAttrs = new MonitorData(5);
    Collection<String> needReindexValues = createNeedReindexValues();
    if (needReindexValues.size() > 0)
    if (!needReindexValues.isEmpty())
    {
      monitorAttrs.add("need-reindex", needReindexValues);
    }
opendj-server-legacy/src/main/java/org/opends/server/backends/task/TaskBackend.java
@@ -36,6 +36,7 @@
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.config.server.ConfigChangeResult;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.config.server.ConfigurationChangeListener;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ConditionResult;
import org.forgerock.opendj.ldap.DN;
@@ -43,9 +44,8 @@
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.util.Reject;
import org.forgerock.opendj.config.server.ConfigurationChangeListener;
import org.forgerock.opendj.server.config.server.TaskBackendCfg;
import org.forgerock.util.Reject;
import org.opends.server.api.Backend;
import org.opends.server.api.Backupable;
import org.opends.server.core.AddOperation;
@@ -85,29 +85,17 @@
       extends Backend<TaskBackendCfg>
       implements ConfigurationChangeListener<TaskBackendCfg>, Backupable
{
  private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
  /** The current configuration state. */
  private TaskBackendCfg currentConfig;
  /** The DN of the configuration entry for this backend. */
  private DN configEntryDN;
  /**
   * The DN of the entry that will serve as the parent for all recurring task
   * entries.
   */
  /** The DN of the entry that will serve as the parent for all recurring task entries. */
  private DN recurringTaskParentDN;
  /**
   * The DN of the entry that will serve as the parent for all scheduled task
   * entries.
   */
  /** The DN of the entry that will serve as the parent for all scheduled task entries. */
  private DN scheduledTaskParentDN;
  /** The DN of the entry that will serve as the root for all task entries. */
  private DN taskRootDN;
@@ -125,11 +113,7 @@
  /** The path to the task backing file. */
  private String taskBackingFile;
  /**
   * The task scheduler that will be responsible for actually invoking scheduled
   * tasks.
   */
  /** The task scheduler that will be responsible for actually invoking scheduled tasks. */
  private TaskScheduler taskScheduler;
  private ServerContext serverContext;
@@ -146,8 +130,6 @@
    // Perform all initialization in initializeBackend.
  }
  @Override
  public void configureBackend(TaskBackendCfg cfg, ServerContext serverContext) throws ConfigException
  {
@@ -206,12 +188,10 @@
      }
    }
    // Get the retention time that will be used to determine how long task
    // information stays around once the associated task is completed.
    retentionTime = cfg.getTaskRetentionTime();
    // Get the notification sender address.
    notificationSenderAddress = cfg.getNotificationSenderAddress();
    if (notificationSenderAddress == null)
@@ -227,16 +207,12 @@
      }
    }
    // Get the path to the task data backing file.
    taskBackingFile = cfg.getTaskBackingFile();
    currentConfig = cfg;
  }
  /** {@inheritDoc} */
  @Override
  public void openBackend()
         throws ConfigException, InitializationException
@@ -245,11 +221,9 @@
    taskScheduler = new TaskScheduler(serverContext, this);
    taskScheduler.start();
    // Register with the Directory Server as a configurable component.
    currentConfig.addTaskChangeListener(this);
    // Register the task base as a private suffix.
    try
    {
@@ -265,9 +239,6 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  public void closeBackend()
  {
@@ -321,9 +292,6 @@
    return -1;
  }
  /** {@inheritDoc} */
  @Override
  public boolean isIndexed(AttributeType attributeType, IndexType indexType)
  {
@@ -331,9 +299,6 @@
    return true;
  }
  /** {@inheritDoc} */
  @Override
  public ConditionResult hasSubordinates(DN entryDN)
         throws DirectoryException
@@ -346,14 +311,12 @@
    return ConditionResult.valueOf(ret != 0);
  }
  /** {@inheritDoc} */
  @Override
  public long getNumberOfEntriesInBaseDN(DN baseDN) throws DirectoryException {
    checkNotNull(baseDN, "baseDN must not be null");
    return numSubordinates(baseDN, true) + 1;
  }
  /** {@inheritDoc} */
  @Override
  public long getNumberOfChildren(DN parentDN) throws DirectoryException {
    checkNotNull(parentDN, "parentDN must not be null");
@@ -411,9 +374,6 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  public Entry getEntry(DN entryDN)
         throws DirectoryException
@@ -466,9 +426,6 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  public void addEntry(Entry entry, AddOperation addOperation)
         throws DirectoryException
@@ -510,9 +467,6 @@
    throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
  }
  /** {@inheritDoc} */
  @Override
  public void deleteEntry(DN entryDN, DeleteOperation deleteOperation)
         throws DirectoryException
@@ -535,7 +489,6 @@
        throw new DirectoryException(ResultCode.NO_SUCH_OBJECT, message);
      }
      // Look at the state of the task.  We will allow pending and completed
      // tasks to be removed, but not running tasks.
      TaskState state = t.getTaskState();
@@ -585,9 +538,6 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  public void replaceEntry(Entry oldEntry, Entry newEntry,
      ModifyOperation modifyOperation) throws DirectoryException
@@ -685,7 +635,7 @@
              LocalizableMessage message = INFO_TASKBE_RUNNING_TASK_CANCELLED.get();
              t.interruptTask(TaskState.STOPPED_BY_ADMINISTRATOR, message);
            }
              return;
            return;
          }
          else
          {
@@ -720,8 +670,6 @@
    }
  }
  /**
   * Helper to determine if requested modifications are acceptable.
   * @param modifyOperation associated with requested modifications.
@@ -765,9 +713,6 @@
    return true;
  }
  /** {@inheritDoc} */
  @Override
  public void renameEntry(DN currentDN, Entry entry,
                                   ModifyDNOperation modifyDNOperation)
@@ -777,9 +722,6 @@
        ERR_BACKEND_MODIFY_DN_NOT_SUPPORTED.get(currentDN, getBackendID()));
  }
  /** {@inheritDoc} */
  @Override
  public void search(SearchOperation searchOperation)
         throws DirectoryException, CanceledOperationException {
@@ -926,7 +868,6 @@
      }
    }
    if (searchRoot)
    {
      Entry e = taskScheduler.getTaskRootEntry();
@@ -936,7 +877,6 @@
      }
    }
    if (searchScheduledParent)
    {
      Entry e = taskScheduler.getScheduledTaskParentEntry();
@@ -946,14 +886,12 @@
      }
    }
    if (searchScheduledTasks
        && !taskScheduler.searchScheduledTasks(searchOperation))
    {
      return;
    }
    if (searchRecurringParent)
    {
      Entry e = taskScheduler.getRecurringTaskParentEntry();
@@ -963,7 +901,6 @@
      }
    }
    if (searchRecurringTasks
        && !taskScheduler.searchRecurringTasks(searchOperation))
    {
@@ -971,23 +908,18 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  public Set<String> getSupportedControls()
  {
    return Collections.emptySet();
  }
  /** {@inheritDoc} */
  @Override
  public Set<String> getSupportedFeatures()
  {
    return Collections.emptySet();
  }
  /** {@inheritDoc} */
  @Override
  public boolean supports(BackendOperation backendOperation)
  {
@@ -1003,44 +935,15 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  public void exportLDIF(LDIFExportConfig exportConfig)
         throws DirectoryException
  public void exportLDIF(LDIFExportConfig exportConfig) throws DirectoryException
  {
    File taskFile = getFileForPath(taskBackingFile);
    // Read from.
    LDIFReader ldifReader;
    try
    try (LDIFReader ldifReader = newLDIFReader(taskFile);
        LDIFWriter ldifWriter = newLDIFWriter(exportConfig))
    {
      ldifReader = new LDIFReader(new LDIFImportConfig(taskFile.getPath()));
    }
    catch (Exception e)
    {
      LocalizableMessage message = ERR_TASKS_CANNOT_EXPORT_TO_FILE.get(e);
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), message, e);
    }
    // Write to.
    LDIFWriter ldifWriter;
    try
    {
      ldifWriter = new LDIFWriter(exportConfig);
    }
    catch (Exception e)
    {
      logger.traceException(e);
      LocalizableMessage message = ERR_TASKS_CANNOT_EXPORT_TO_FILE.get(
          stackTraceToSingleLineString(e));
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
                                   message);
    }
    // Copy record by record.
    try
    {
      // Copy record by record.
      while (true)
      {
        Entry e = null;
@@ -1054,7 +957,7 @@
        }
        catch (LDIFException le)
        {
          if (! le.canContinueReading())
          if (!le.canContinueReading())
          {
            LocalizableMessage message = ERR_TASKS_CANNOT_EXPORT_TO_FILE.get(e);
            throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), message, le);
@@ -1068,13 +971,35 @@
    {
      logger.traceException(e);
    }
    finally
  }
  private LDIFReader newLDIFReader(File taskFile) throws DirectoryException
  {
    try
    {
      close(ldifWriter, ldifReader);
      return new LDIFReader(new LDIFImportConfig(taskFile.getPath()));
    }
    catch (Exception e)
    {
      LocalizableMessage message = ERR_TASKS_CANNOT_EXPORT_TO_FILE.get(e);
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), message, e);
    }
  }
  /** {@inheritDoc} */
  private LDIFWriter newLDIFWriter(LDIFExportConfig exportConfig) throws DirectoryException
  {
    try
    {
      return new LDIFWriter(exportConfig);
    }
    catch (Exception e)
    {
      logger.traceException(e);
      LocalizableMessage message = ERR_TASKS_CANNOT_EXPORT_TO_FILE.get(stackTraceToSingleLineString(e));
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), message);
    }
  }
  @Override
  public LDIFImportResult importLDIF(LDIFImportConfig importConfig, ServerContext sContext) throws DirectoryException
  {
@@ -1082,28 +1007,24 @@
        ERR_BACKEND_IMPORT_NOT_SUPPORTED.get(getBackendID()));
  }
  /** {@inheritDoc} */
  @Override
  public void createBackup(BackupConfig backupConfig) throws DirectoryException
  {
    new BackupManager(getBackendID()).createBackup(this, backupConfig);
  }
  /** {@inheritDoc} */
  @Override
  public void removeBackup(BackupDirectory backupDirectory, String backupID) throws DirectoryException
  {
    new BackupManager(getBackendID()).removeBackup(backupDirectory, backupID);
  }
  /** {@inheritDoc} */
  @Override
  public void restoreBackup(RestoreConfig restoreConfig) throws DirectoryException
  {
    new BackupManager(getBackendID()).restoreBackup(this, restoreConfig);
  }
  /** {@inheritDoc} */
  @Override
  public boolean isConfigurationAcceptable(TaskBackendCfg config,
                                           List<LocalizableMessage> unacceptableReasons,
@@ -1112,9 +1033,6 @@
    return isConfigAcceptable(config, unacceptableReasons, null);
  }
  /** {@inheritDoc} */
  @Override
  public boolean isConfigurationChangeAcceptable(TaskBackendCfg configEntry,
                                            List<LocalizableMessage> unacceptableReasons)
@@ -1123,8 +1041,6 @@
                              taskBackingFile);
  }
  /**
   * Indicates whether the provided configuration is acceptable for this task
   * backend.
@@ -1146,7 +1062,6 @@
  {
    boolean configIsAcceptable = true;
    try
    {
      String tmpBackingFile = config.getTaskBackingFile();
@@ -1204,15 +1119,11 @@
    return configIsAcceptable;
  }
  /** {@inheritDoc} */
  @Override
  public ConfigChangeResult applyConfigurationChange(TaskBackendCfg configEntry)
  {
    final ConfigChangeResult ccr = new ConfigChangeResult();
    String tmpBackingFile = taskBackingFile;
    try
    {
@@ -1256,10 +1167,8 @@
      ccr.setResultCode(DirectoryServer.getServerErrorResultCode());
    }
    long tmpRetentionTime = configEntry.getTaskRetentionTime();
    if (ccr.getResultCode() == ResultCode.SUCCESS)
    {
      // Everything looks OK, so apply the changes.
@@ -1270,7 +1179,6 @@
        ccr.addMessage(INFO_TASKBE_UPDATED_RETENTION_TIME.get(retentionTime));
      }
      if (! taskBackingFile.equals(tmpBackingFile))
      {
        taskBackingFile = tmpBackingFile;
@@ -1280,7 +1188,6 @@
      }
    }
    String tmpNotificationAddress = configEntry.getNotificationSenderAddress();
    if (tmpNotificationAddress == null)
    {
@@ -1296,13 +1203,10 @@
    }
    notificationSenderAddress = tmpNotificationAddress;
    currentConfig = configEntry;
    return ccr;
  }
  /**
   * Retrieves the DN of the configuration entry for this task backend.
   *
@@ -1313,8 +1217,6 @@
    return configEntryDN;
  }
  /**
   * Retrieves the path to the backing file that will hold the scheduled and
   * recurring task definitions.
@@ -1328,8 +1230,6 @@
    return f.getPath();
  }
  /**
   * Retrieves the sender address that should be used for e-mail notifications
   * of task completion.
@@ -1342,8 +1242,6 @@
    return notificationSenderAddress;
  }
  /**
   * Retrieves the length of time in seconds that information for a task should
   * be retained after processing on it has completed.
@@ -1356,8 +1254,6 @@
    return retentionTime;
  }
  /**
   * Retrieves the DN of the entry that is the root for all task information in
   * the Directory Server.
@@ -1370,8 +1266,6 @@
    return taskRootDN;
  }
  /**
   * Retrieves the DN of the entry that is the immediate parent for all
   * recurring task information in the Directory Server.
@@ -1384,8 +1278,6 @@
    return recurringTaskParentDN;
  }
  /**
   * Retrieves the DN of the entry that is the immediate parent for all
   * scheduled task information in the Directory Server.
@@ -1398,8 +1290,6 @@
    return scheduledTaskParentDN;
  }
  /**
   * Retrieves the scheduled task for the entry with the provided DN.
   *
@@ -1413,8 +1303,6 @@
    return taskScheduler.getScheduledTask(taskEntryDN);
  }
  /**
   * Retrieves the recurring task for the entry with the provided DN.
   *
@@ -1429,9 +1317,6 @@
    return taskScheduler.getRecurringTask(taskEntryDN);
  }
  /** {@inheritDoc} */
  @Override
  public File getDirectory()
  {
@@ -1450,21 +1335,18 @@
    };
  }
  /** {@inheritDoc} */
  @Override
  public ListIterator<Path> getFilesToBackup() throws DirectoryException
  {
    return BackupManager.getFiles(getDirectory(), getFilesToBackupFilter(), getBackendID()).listIterator();
  }
  /** {@inheritDoc} */
  @Override
  public boolean isDirectRestore()
  {
    return true;
  }
  /** {@inheritDoc} */
  @Override
  public Path beforeRestore() throws DirectoryException
  {
@@ -1472,13 +1354,10 @@
    return BackupManager.saveCurrentFilesToDirectory(this, getBackendID());
  }
  /** {@inheritDoc} */
  @Override
  public void afterRestore(Path restoreDirectory, Path saveDirectory) throws DirectoryException
  {
    // restore was successful, delete the save directory
    StaticUtils.recursiveDelete(saveDirectory.toFile());
  }
}
opendj-server-legacy/src/main/java/org/opends/server/tasks/ExportTask.java
@@ -58,10 +58,8 @@
 */
public class ExportTask extends Task
{
  private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
  /** Stores mapping between configuration attribute name and its label. */
  private static Map<String,LocalizableMessage> argDisplayMap = new HashMap<>();
  static {
@@ -97,19 +95,16 @@
  private LDIFExportConfig exportConfig;
  /** {@inheritDoc} */
  @Override
  public LocalizableMessage getDisplayName() {
    return INFO_TASK_EXPORT_NAME.get();
  }
  /** {@inheritDoc} */
  @Override
  public LocalizableMessage getAttributeDisplayName(String name) {
    return argDisplayMap.get(name);
  }
  /** {@inheritDoc} */
  @Override
  public void initializeTask() throws DirectoryException
  {
@@ -127,7 +122,6 @@
      }
    }
    Entry taskEntry = getTaskEntry();
    AttributeType typeWrapColumn = getAttributeType(ATTR_TASK_EXPORT_WRAP_COLUMN);
@@ -185,7 +179,6 @@
    return TaskUtils.getSingleValueString(attrs);
  }
  /** {@inheritDoc} */
  @Override
  public void interruptTask(TaskState interruptState, LocalizableMessage interruptReason)
  {
@@ -199,13 +192,11 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  public boolean isInterruptable() {
    return true;
  }
  /** {@inheritDoc} */
  @Override
  protected TaskState runTask()
  {
@@ -308,7 +299,6 @@
      }
    }
    ArrayList<DN> includeBranches;
    if (!includeBranchStrings.isEmpty())
    {
@@ -341,7 +331,6 @@
      includeBranches = defaultIncludeBranches;
    }
    // Create the LDIF export configuration to use when reading the LDIF.
    ExistingFileBehavior existingBehavior;
    if (appendToLDIF)
@@ -369,12 +358,10 @@
    // FIXME -- Should this be conditional?
    exportConfig.setInvokeExportPlugins(true);
    // Get the set of base DNs for the backend as an array.
    DN[] baseDNs = new DN[defaultIncludeBranches.size()];
    defaultIncludeBranches.toArray(baseDNs);
    // From here we must make sure we close the export config.
    try
    {
@@ -395,7 +382,6 @@
        return TaskState.STOPPED_BY_ERROR;
      }
      // From here we must make sure we release the shared backend lock.
      try
      {
opendj-server-legacy/src/main/java/org/opends/server/tasks/ImportTask.java
@@ -85,7 +85,6 @@
    argDisplayMap.put(ATTR_IMPORT_CLEAR_BACKEND, INFO_IMPORT_ARG_CLEAR_BACKEND.get());
  }
  private boolean isCompressed;
  private boolean isEncrypted;
  private boolean overwrite;
@@ -134,7 +133,6 @@
      }
    }
    Entry taskEntry = getTaskEntry();
    AttributeType typeLdifFile = getAttributeType(ATTR_IMPORT_LDIF_FILE);
@@ -423,7 +421,6 @@
      }
    }
    // Get the backend into which the LDIF should be imported.
    Backend<?> backend = null;
    HashSet<DN> defaultIncludeBranches;
@@ -645,7 +642,6 @@
      return TaskState.STOPPED_BY_ERROR;
    }
    try
    {
      // Acquire an exclusive lock for the backend.
@@ -667,7 +663,6 @@
        return TaskState.STOPPED_BY_ERROR;
      }
      // Launch the import.
      try
      {
@@ -718,7 +713,6 @@
          logger.warn(WARN_LDIFIMPORT_CANNOT_UNLOCK_BACKEND, backend.getBackendID(), getExceptionMessage(e));
          return TaskState.COMPLETED_WITH_ERRORS;
        }
      }
    }
    finally
@@ -742,7 +736,6 @@
      DirectoryServer.notifyImportEnded(backend, importConfig, true);
    }
    // Clean up after the import by closing the import config.
    importConfig.close();
    return getFinalTaskState();