From 85f51e5a07aa823b2b363304007ed812c73ecc59 Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Tue, 19 Apr 2016 12:59:38 +0000
Subject: [PATCH] Changed Backend.getBaseDNs() return type from DN[] to Set<DN>
---
opendj-server-legacy/src/main/java/org/opends/server/backends/MemoryBackend.java | 38 ++++++++++++--------------------------
1 files changed, 12 insertions(+), 26 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/MemoryBackend.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/MemoryBackend.java
index 9303e3a..91c9b16 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/MemoryBackend.java
+++ b/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;
--
Gitblit v1.10.0