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

Jean-Noël Rouvignac
04.53.2016 85f51e5a07aa823b2b363304007ed812c73ecc59
opendj-server-legacy/src/main/java/org/opends/server/backends/MemoryBackend.java
@@ -58,6 +58,7 @@
import org.opends.server.types.LDIFImportResult;
import org.opends.server.types.RestoreConfig;
import org.opends.server.types.SearchFilter;
import org.opends.server.util.CollectionUtils;
import org.opends.server.util.LDIFException;
import org.opends.server.util.LDIFReader;
import org.opends.server.util.LDIFWriter;
@@ -97,14 +98,11 @@
  /** The base DNs for this backend. */
  private DN[] baseDNs;
  private Set<DN> baseDNs;
  /** The mapping between parent DNs and their immediate children. */
  private HashMap<DN,HashSet<DN>> childDNs;
  /** The base DNs for this backend, in a hash set. */
  private HashSet<DN> baseDNSet;
  /** The set of supported controls for this backend. */
  private final Set<String> supportedControls =
      Collections.singleton(OID_SUBTREE_DELETE_CONTROL);
@@ -133,42 +131,32 @@
   * object when initializing the backend.
   * @param baseDNs The set of base DNs to be served by this memory backend.
   */
  public void setBaseDNs(DN[] baseDNs)
  public void setBaseDNs(DN... baseDNs)
  {
    this.baseDNs = baseDNs;
    this.baseDNs = CollectionUtils.newHashSet(baseDNs);
  }
  /** {@inheritDoc} */
  @Override
  public void configureBackend(MemoryBackendCfg config, ServerContext serverContext) throws ConfigException
  {
    if (config != null)
    {
      MemoryBackendCfg cfg = config;
      DN[] baseDNs = new DN[cfg.getBaseDN().size()];
      cfg.getBaseDN().toArray(baseDNs);
      setBaseDNs(baseDNs);
      this.baseDNs = config.getBaseDN();
    }
  }
  /** {@inheritDoc} */
  @Override
  public synchronized void openBackend()
       throws ConfigException, InitializationException
  {
    // We won't support anything other than exactly one base DN in this
    // implementation.  If we were to add such support in the future, we would
    // likely want to separate the data for each base DN into a separate entry
    // map.
    if (baseDNs == null || baseDNs.length != 1)
    // We won't support anything other than exactly one base DN in this implementation.
    // If we were to add such support in the future, we would likely want
    // to separate the data for each base DN into a separate entry map.
    if (baseDNs == null || baseDNs.size() != 1)
    {
      LocalizableMessage message = ERR_MEMORYBACKEND_REQUIRE_EXACTLY_ONE_BASE.get();
      throw new ConfigException(message);
      throw new ConfigException(ERR_MEMORYBACKEND_REQUIRE_EXACTLY_ONE_BASE.get());
    }
    baseDNSet = new HashSet<>();
    Collections.addAll(baseDNSet, baseDNs);
    entryMap = new LinkedHashMap<>();
    childDNs = new HashMap<>();
@@ -219,14 +207,12 @@
    }
  }
  /** {@inheritDoc} */
  @Override
  public DN[] getBaseDNs()
  public Set<DN> getBaseDNs()
  {
    return baseDNs;
  }
  /** {@inheritDoc} */
  @Override
  public synchronized long getEntryCount()
  {
@@ -337,7 +323,7 @@
    // If the entry is one of the base DNs, then add it.
    if (baseDNSet.contains(entryDN))
    if (baseDNs.contains(entryDN))
    {
      entryMap.put(entryDN, e);
      return;