From 35af51f9683f5ef8cec66baca7b89aa1e1cbc44e Mon Sep 17 00:00:00 2001
From: coulbeck <coulbeck@localhost>
Date: Fri, 11 May 2007 23:27:30 +0000
Subject: [PATCH] Issue 1532: Remove ConfigEntry from Backend API. (DS-1532)
---
opends/src/server/org/opends/server/core/BackendConfigManager.java | 68 -
opends/tests/unit-tests-testng/src/server/org/opends/server/backends/jeb/TestVerifyJob.java | 1332 ++++++++++++-------------
opends/tests/unit-tests-testng/src/server/org/opends/server/tools/ImportLDIFTestCase.java | 48
opends/src/admin/defn/org/opends/server/admin/std/RootConfiguration.xml | 2
opends/src/server/org/opends/server/tools/RebuildIndex.java | 13
opends/src/server/org/opends/server/backends/jeb/BackupManager.java | 14
opends/src/server/org/opends/server/tools/BackendToolUtils.java | 26
opends/src/server/org/opends/server/tools/ImportLDIF.java | 13
opends/tests/unit-tests-testng/resource/config-changes.ldif | 2
opends/src/server/org/opends/server/tasks/RebuildTask.java | 11
opends/src/server/org/opends/server/tools/ExportLDIF.java | 17
opends/tests/unit-tests-testng/src/server/org/opends/server/backends/jeb/TestEntryContainer.java | 3
opends/src/server/org/opends/server/backends/RootDSEBackend.java | 46
opends/src/server/org/opends/server/tasks/RestoreTask.java | 8
opends/tests/unit-tests-testng/src/server/org/opends/server/backends/jeb/TestImportJob.java | 10
opends/src/server/org/opends/server/replication/plugin/ReplicationDomain.java | 319 -----
opends/src/server/org/opends/server/tasks/ImportTask.java | 11
opends/src/server/org/opends/server/backends/SchemaBackend.java | 56
opends/src/server/org/opends/server/tasks/TaskUtils.java | 118 +
opends/src/server/org/opends/server/admin/server/ServerManagedObject.java | 2
opends/src/server/org/opends/server/backends/BackupBackend.java | 111 -
opends/src/server/org/opends/server/api/Backend.java | 64
opends/src/server/org/opends/server/tasks/BackupTask.java | 11
opends/src/server/org/opends/server/tools/RestoreDB.java | 21
opends/src/server/org/opends/server/api/AccessControlProvider.java | 4
opends/tests/unit-tests-testng/src/server/org/opends/server/backends/SchemaBackendTestCase.java | 32
opends/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java | 39
opends/src/server/org/opends/server/tools/BackUpDB.java | 23
opends/src/server/org/opends/server/backends/MemoryBackend.java | 50
opends/src/server/org/opends/server/core/DirectoryServer.java | 14
opends/src/server/org/opends/server/backends/jeb/RootContainer.java | 2
opends/src/server/org/opends/server/backends/MonitorBackend.java | 129 -
opends/src/server/org/opends/server/messages/ToolMessages.java | 2
opends/src/server/org/opends/server/api/ConfigHandler.java | 1
opends/src/server/org/opends/server/backends/jeb/Config.java | 36
opends/src/server/org/opends/server/tools/VerifyIndex.java | 15
opends/src/server/org/opends/server/tasks/ExportTask.java | 12
opends/src/server/org/opends/server/messages/JebMessages.java | 7
opends/src/server/org/opends/server/backends/jeb/BackendImpl.java | 157 --
opends/tests/unit-tests-testng/src/server/org/opends/server/backends/jeb/TestRebuildJob.java | 29
opends/tests/unit-tests-testng/src/server/org/opends/server/backends/jeb/TestBackendImpl.java | 4
opends/src/server/org/opends/server/extensions/ConfigFileHandler.java | 94 -
opends/src/server/org/opends/server/backends/task/TaskBackend.java | 59
43 files changed, 1,224 insertions(+), 1,811 deletions(-)
diff --git a/opends/src/admin/defn/org/opends/server/admin/std/RootConfiguration.xml b/opends/src/admin/defn/org/opends/server/admin/std/RootConfiguration.xml
index ce2d70f..15e899e 100644
--- a/opends/src/admin/defn/org/opends/server/admin/std/RootConfiguration.xml
+++ b/opends/src/admin/defn/org/opends/server/admin/std/RootConfiguration.xml
@@ -163,7 +163,7 @@
<adm:one-to-one />
<adm:profile name="ldap">
<ldap:rdn-sequence>
- cn=config
+ cn=Root DSE,cn=config
</ldap:rdn-sequence>
</adm:profile>
</adm:relation>
diff --git a/opends/src/server/org/opends/server/admin/server/ServerManagedObject.java b/opends/src/server/org/opends/server/admin/server/ServerManagedObject.java
index ddf788d..67741d3 100644
--- a/opends/src/server/org/opends/server/admin/server/ServerManagedObject.java
+++ b/opends/src/server/org/opends/server/admin/server/ServerManagedObject.java
@@ -179,7 +179,7 @@
* If one or more of the managed object's properties could
* not be decoded.
*/
- public static <S extends Configuration>
+ static <S extends Configuration>
ServerManagedObject<? extends S> decode(
ManagedObjectPath path,
AbstractManagedObjectDefinition<?, S> definition,
diff --git a/opends/src/server/org/opends/server/api/AccessControlProvider.java b/opends/src/server/org/opends/server/api/AccessControlProvider.java
index f3573ba..9c954c8 100644
--- a/opends/src/server/org/opends/server/api/AccessControlProvider.java
+++ b/opends/src/server/org/opends/server/api/AccessControlProvider.java
@@ -40,8 +40,8 @@
* should specify the name of a class implementing this interface.
*
* @param <T>
- * The type of connection handler configuration handled by
- * this connection handler implementation.
+ * The type of access control configuration handled by
+ * this access control provider implementation.
*/
public interface AccessControlProvider
<T extends AccessControlHandlerCfg>
diff --git a/opends/src/server/org/opends/server/api/Backend.java b/opends/src/server/org/opends/server/api/Backend.java
index 75640d6..f756d59 100644
--- a/opends/src/server/org/opends/server/api/Backend.java
+++ b/opends/src/server/org/opends/server/api/Backend.java
@@ -34,7 +34,6 @@
import java.util.Set;
import java.util.concurrent.locks.Lock;
-import org.opends.server.config.ConfigEntry;
import org.opends.server.config.ConfigException;
import org.opends.server.core.AddOperation;
import org.opends.server.core.DeleteOperation;
@@ -58,7 +57,7 @@
import static org.opends.server.messages.BackendMessages.*;
import static org.opends.server.messages.MessageHandler.*;
-
+import org.opends.server.admin.Configuration;
/**
@@ -111,14 +110,24 @@
/**
- * Initializes this backend based on the information in the provided
- * configuration entry.
+ * Configure this backend based on the information in the provided
+ * configuration.
*
- * @param configEntry The configuration entry that contains the
- * information to use to initialize this
- * backend.
- * @param baseDNs The set of base DNs that have been
- * configured for this backend.
+ * @param cfg The configuration of this backend.
+ *
+ * @throws ConfigException
+ * If there is an error in the configuration.
+ */
+ public abstract void configureBackend(Configuration cfg)
+ throws ConfigException;
+
+
+
+ /**
+ * Initializes this backend based on the information provided
+ * when the backend was configured.
+ *
+ * @see #configureBackend
*
* @throws ConfigException If an unrecoverable problem arises in
* the process of performing the
@@ -129,8 +138,7 @@
* related to the server
* configuration.
*/
- public abstract void initializeBackend(ConfigEntry configEntry,
- DN[] baseDNs)
+ public abstract void initializeBackend()
throws ConfigException, InitializationException;
@@ -453,18 +461,13 @@
* <CODE>true</CODE>. Note that the server will not explicitly
* initialize this backend before calling this method.
*
- * @param configEntry The configuration entry for this backend.
- * @param baseDNs The set of base DNs configured for this
- * backend.
* @param exportConfig The configuration to use when performing
* the export.
*
* @throws DirectoryException If a problem occurs while performing
* the LDIF export.
*/
- public abstract void exportLDIF(ConfigEntry configEntry,
- DN[] baseDNs,
- LDIFExportConfig exportConfig)
+ public abstract void exportLDIF(LDIFExportConfig exportConfig)
throws DirectoryException;
@@ -486,18 +489,13 @@
* returns <CODE>true</CODE>. Note that the server will not
* explicitly initialize this backend before calling this method.
*
- * @param configEntry The configuration entry for this backend.
- * @param baseDNs The set of base DNs configured for this
- * backend.
* @param importConfig The configuration to use when performing
* the import.
*
* @throws DirectoryException If a problem occurs while performing
* the LDIF import.
*/
- public abstract void importLDIF(ConfigEntry configEntry,
- DN[] baseDNs,
- LDIFImportConfig importConfig)
+ public abstract void importLDIF(LDIFImportConfig importConfig)
throws DirectoryException;
@@ -546,15 +544,13 @@
* <CODE>true</CODE>. Note that the server will not explicitly
* initialize this backend before calling this method.
*
- * @param configEntry The configuration entry for this backend.
* @param backupConfig The configuration to use when performing
* the backup.
*
* @throws DirectoryException If a problem occurs while performing
* the backup.
*/
- public abstract void createBackup(ConfigEntry configEntry,
- BackupConfig backupConfig)
+ public abstract void createBackup(BackupConfig backupConfig)
throws DirectoryException;
@@ -597,15 +593,13 @@
* <CODE>true</CODE>. Note that the server will not explicitly
* initialize this backend before calling this method.
*
- * @param configEntry The configuration entry for this backend.
* @param restoreConfig The configuration to use when performing
* the restore.
*
* @throws DirectoryException If a problem occurs while performing
* the restore.
*/
- public abstract void restoreBackup(ConfigEntry configEntry,
- RestoreConfig restoreConfig)
+ public abstract void restoreBackup(RestoreConfig restoreConfig)
throws DirectoryException;
@@ -847,9 +841,9 @@
{
boolean thisMatches = false;
DN[] subBaseDNs = b.getBaseDNs();
- for (int i=0; i < subBaseDNs.length; i++)
+ for (DN dn : subBaseDNs)
{
- if (subBaseDNs[i].equals(subSuffixDN))
+ if (dn.equals(subSuffixDN))
{
if (subBaseDNs.length > 1)
{
@@ -977,14 +971,14 @@
public boolean handlesEntry(DN entryDN)
{
DN[] baseDNs = getBaseDNs();
- for (int i=0; i < baseDNs.length; i++)
+ for (DN dn : baseDNs)
{
- if (entryDN.isDescendantOf(baseDNs[i]))
+ if (entryDN.isDescendantOf(dn))
{
Backend[] subBackends = subordinateBackends;
- for (int j=0; j < subBackends.length; j++)
+ for (Backend b : subBackends)
{
- if (subBackends[j].handlesEntry(entryDN))
+ if (b.handlesEntry(entryDN))
{
return false;
}
diff --git a/opends/src/server/org/opends/server/api/ConfigHandler.java b/opends/src/server/org/opends/server/api/ConfigHandler.java
index 5d5f00e..a2ed265 100644
--- a/opends/src/server/org/opends/server/api/ConfigHandler.java
+++ b/opends/src/server/org/opends/server/api/ConfigHandler.java
@@ -35,7 +35,6 @@
import org.opends.server.types.InitializationException;
-
/**
* This class defines the set of methods and structures that must be
* implemented by a Directory Server configuration handler.
diff --git a/opends/src/server/org/opends/server/backends/BackupBackend.java b/opends/src/server/org/opends/server/backends/BackupBackend.java
index e7dadb6..e2f26cd 100644
--- a/opends/src/server/org/opends/server/backends/BackupBackend.java
+++ b/opends/src/server/org/opends/server/backends/BackupBackend.java
@@ -33,14 +33,12 @@
import org.opends.server.api.Backend;
import org.opends.server.config.ConfigException;
-import org.opends.server.config.ConfigEntry;
import org.opends.server.core.AddOperation;
import org.opends.server.core.DeleteOperation;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.ModifyOperation;
import org.opends.server.core.ModifyDNOperation;
import org.opends.server.core.SearchOperation;
-import org.opends.server.core.BackendConfigManager;
import org.opends.server.protocols.asn1.ASN1OctetString;
import org.opends.server.schema.BooleanSyntax;
import org.opends.server.schema.GeneralizedTimeSyntax;
@@ -72,9 +70,10 @@
import static org.opends.server.messages.MessageHandler.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
+import org.opends.server.util.Validator;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.server.BackupBackendCfg;
-import org.opends.server.admin.std.meta.BackupBackendCfgDefn;
+import org.opends.server.admin.Configuration;
/**
@@ -125,25 +124,32 @@
}
-
/**
* {@inheritDoc}
*/
- public void initializeBackend(ConfigEntry configEntry, DN[] baseDNs)
- throws ConfigException, InitializationException
+ public void configureBackend(Configuration config) throws ConfigException
{
// Make sure that a configuration entry was provided. If not, then we will
// not be able to complete initialization.
- if (configEntry == null)
+ if (config == null)
{
int msgID = MSGID_BACKUP_CONFIG_ENTRY_NULL;
String message = getMessage(msgID);
throw new ConfigException(msgID, message);
}
- BackupBackendCfg cfg = getBackupBackendCfg(configEntry);
+ Validator.ensureTrue(config instanceof BackupBackendCfg);
+ currentConfig = (BackupBackendCfg)config;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void initializeBackend()
+ throws ConfigException, InitializationException
+ {
// Create the set of base DNs that we will handle. In this case, it's just
// the DN of the base backup entry.
try
@@ -167,7 +173,7 @@
// Determine the set of backup directories that we will use by default.
- Set<String> values = cfg.getBackupDirectory();
+ Set<String> values = currentConfig.getBackupDirectory();
backupDirectories = new LinkedHashSet<File>(values.size());
for (String s : values)
{
@@ -215,8 +221,7 @@
// Register this as a change listener.
- currentConfig = cfg;
- cfg.addBackupChangeListener(this);
+ currentConfig.addBackupChangeListener(this);
// Register the backup base as a private suffix.
@@ -1063,20 +1068,9 @@
/**
- * Exports the contents of this backend to LDIF. This method should only be
- * called if <CODE>supportsLDIFExport</CODE> returns <CODE>true</CODE>. Note
- * that the server will not explicitly initialize this backend before calling
- * this method.
- *
- * @param configEntry The configuration entry for this backend.
- * @param baseDNs The set of base DNs configured for this backend.
- * @param exportConfig The configuration to use when performing the export.
- *
- * @throws DirectoryException If a problem occurs while performing the LDIF
- * export.
+ * {@inheritDoc}
*/
- public void exportLDIF(ConfigEntry configEntry, DN[] baseDNs,
- LDIFExportConfig exportConfig)
+ public void exportLDIF(LDIFExportConfig exportConfig)
throws DirectoryException
{
int msgID = MSGID_BACKUP_EXPORT_NOT_SUPPORTED;
@@ -1103,20 +1097,9 @@
/**
- * Imports information from an LDIF file into this backend. This method
- * should only be called if <CODE>supportsLDIFImport</CODE> returns
- * <CODE>true</CODE>. Note that the server will not explicitly initialize
- * this backend before calling this method.
- *
- * @param configEntry The configuration entry for this backend.
- * @param baseDNs The set of base DNs configured for this backend.
- * @param importConfig The configuration to use when performing the import.
- *
- * @throws DirectoryException If a problem occurs while performing the LDIF
- * import.
+ * {@inheritDoc}
*/
- public void importLDIF(ConfigEntry configEntry, DN[] baseDNs,
- LDIFImportConfig importConfig)
+ public void importLDIF(LDIFImportConfig importConfig)
throws DirectoryException
{
// This backend does not support LDIF imports.
@@ -1172,20 +1155,10 @@
/**
- * Creates a backup of the contents of this backend in a form that may be
- * restored at a later date if necessary. This method should only be called
- * if <CODE>supportsBackup</CODE> returns <CODE>true</CODE>. Note that the
- * server will not explicitly initialize this backend before calling this
- * method.
- *
- * @param configEntry The configuration entry for this backend.
- * @param backupConfig The configuration to use when performing the backup.
- *
- * @throws DirectoryException If a problem occurs while performing the
- * backup.
+ * {@inheritDoc}
*/
- public void createBackup(ConfigEntry configEntry, BackupConfig backupConfig)
- throws DirectoryException
+ public void createBackup(BackupConfig backupConfig)
+ throws DirectoryException
{
// This backend does not provide a backup/restore mechanism.
int msgID = MSGID_BACKUP_BACKUP_AND_RESTORE_NOT_SUPPORTED;
@@ -1236,20 +1209,9 @@
/**
- * Restores a backup of the contents of this backend. This method should only
- * be called if <CODE>supportsRestore</CODE> returns <CODE>true</CODE>. Note
- * that the server will not explicitly initialize this backend before calling
- * this method.
- *
- * @param configEntry The configuration entry for this backend.
- * @param restoreConfig The configuration to use when performing the
- * restore.
- *
- * @throws DirectoryException If a problem occurs while performing the
- * restore.
+ * {@inheritDoc}
*/
- public void restoreBackup(ConfigEntry configEntry,
- RestoreConfig restoreConfig)
+ public void restoreBackup(RestoreConfig restoreConfig)
throws DirectoryException
{
// This backend does not provide a backup/restore mechanism.
@@ -1265,8 +1227,7 @@
* {@inheritDoc}
*/
public boolean isConfigurationChangeAcceptable(
- BackupBackendCfg configEntry,
- List<String> unacceptableReasons)
+ BackupBackendCfg cfg, List<String> unacceptableReasons)
{
// We'll accept anything here. The only configurable attribute is the
// default set of backup directories, but that doesn't require any
@@ -1278,22 +1239,21 @@
/**
* {@inheritDoc}
*/
- public ConfigChangeResult applyConfigurationChange(
- BackupBackendCfg configEntry)
+ public ConfigChangeResult applyConfigurationChange(BackupBackendCfg cfg)
{
ResultCode resultCode = ResultCode.SUCCESS;
boolean adminActionRequired = false;
ArrayList<String> messages = new ArrayList<String>();
- Set<String> values = configEntry.getBackupDirectory();
+ Set<String> values = cfg.getBackupDirectory();
backupDirectories = new LinkedHashSet<File>(values.size());
for (String s : values)
{
backupDirectories.add(getFileForPath(s));
}
- currentConfig = configEntry;
+ currentConfig = cfg;
return new ConfigChangeResult(resultCode, adminActionRequired, messages);
}
@@ -1314,18 +1274,5 @@
}
- /**
- * Gets the backup backend configuration corresponding to a backup
- * backend config entry.
- *
- * @param configEntry A backup backend config entry.
- * @return Returns the backup backend configuration.
- * @throws ConfigException If the config entry could not be decoded.
- */
- static BackupBackendCfg getBackupBackendCfg(ConfigEntry configEntry)
- throws ConfigException {
- return BackendConfigManager.getConfiguration(
- BackupBackendCfgDefn.getInstance(), configEntry);
- }
}
diff --git a/opends/src/server/org/opends/server/backends/MemoryBackend.java b/opends/src/server/org/opends/server/backends/MemoryBackend.java
index 9eec47c..07b8ac8 100644
--- a/opends/src/server/org/opends/server/backends/MemoryBackend.java
+++ b/opends/src/server/org/opends/server/backends/MemoryBackend.java
@@ -34,7 +34,6 @@
import java.util.LinkedList;
import org.opends.server.api.Backend;
-import org.opends.server.config.ConfigEntry;
import org.opends.server.config.ConfigException;
import org.opends.server.core.AddOperation;
import org.opends.server.core.DeleteOperation;
@@ -58,6 +57,7 @@
import org.opends.server.util.LDIFException;
import org.opends.server.util.LDIFReader;
import org.opends.server.util.LDIFWriter;
+import org.opends.server.util.Validator;
import static org.opends.server.loggers.debug.DebugLogger.debugCaught;
import static org.opends.server.loggers.debug.DebugLogger.debugEnabled;
@@ -66,7 +66,8 @@
import static org.opends.server.messages.MessageHandler.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
-
+import org.opends.server.admin.std.server.BackendCfg;
+import org.opends.server.admin.Configuration;
/**
@@ -135,13 +136,38 @@
}
+ /**
+ * 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
+ * object when initializing the backend.
+ * @param baseDNs The set of base DNs to be served by this memory backend.
+ */
+ public void setBaseDNs(DN[] baseDNs)
+ {
+ this.baseDNs = baseDNs;
+ }
+
/**
* {@inheritDoc}
*/
- public synchronized void initializeBackend(ConfigEntry configEntry,
- DN[] baseDNs)
- throws ConfigException, InitializationException
+ public void configureBackend(Configuration config) throws ConfigException
+ {
+ if (config != null)
+ {
+ Validator.ensureTrue(config instanceof BackendCfg);
+ BackendCfg cfg = (BackendCfg)config;
+ DN[] baseDNs = new DN[cfg.getBackendBaseDN().size()];
+ cfg.getBackendBaseDN().toArray(baseDNs);
+ setBaseDNs(baseDNs);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public synchronized void initializeBackend()
+ 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
@@ -154,9 +180,6 @@
throw new ConfigException(msgID, message);
}
-
- this.baseDNs = baseDNs;
-
baseDNSet = new HashSet<DN>();
for (DN dn : baseDNs)
{
@@ -643,8 +666,7 @@
/**
* {@inheritDoc}
*/
- public synchronized void exportLDIF(ConfigEntry configEntry, DN[] baseDNs,
- LDIFExportConfig exportConfig)
+ public synchronized void exportLDIF(LDIFExportConfig exportConfig)
throws DirectoryException
{
// Create the LDIF writer.
@@ -716,8 +738,7 @@
/**
* {@inheritDoc}
*/
- public synchronized void importLDIF(ConfigEntry configEntry, DN[] baseDNs,
- LDIFImportConfig importConfig)
+ public synchronized void importLDIF(LDIFImportConfig importConfig)
throws DirectoryException
{
clearMemoryBackend();
@@ -820,7 +841,7 @@
/**
* {@inheritDoc}
*/
- public void createBackup(ConfigEntry configEntry, BackupConfig backupConfig)
+ public void createBackup(BackupConfig backupConfig)
throws DirectoryException
{
int msgID = MSGID_MEMORYBACKEND_BACKUP_RESTORE_NOT_SUPPORTED;
@@ -860,8 +881,7 @@
/**
* {@inheritDoc}
*/
- public void restoreBackup(ConfigEntry configEntry,
- RestoreConfig restoreConfig)
+ public void restoreBackup(RestoreConfig restoreConfig)
throws DirectoryException
{
int msgID = MSGID_MEMORYBACKEND_BACKUP_RESTORE_NOT_SUPPORTED;
diff --git a/opends/src/server/org/opends/server/backends/MonitorBackend.java b/opends/src/server/org/opends/server/backends/MonitorBackend.java
index 3dd69e2..25990d1 100644
--- a/opends/src/server/org/opends/server/backends/MonitorBackend.java
+++ b/opends/src/server/org/opends/server/backends/MonitorBackend.java
@@ -45,7 +45,6 @@
import org.opends.server.core.ModifyOperation;
import org.opends.server.core.ModifyDNOperation;
import org.opends.server.core.SearchOperation;
-import org.opends.server.core.BackendConfigManager;
import org.opends.server.protocols.asn1.ASN1OctetString;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
@@ -68,6 +67,7 @@
import org.opends.server.util.DynamicConstants;
import org.opends.server.util.LDIFWriter;
import org.opends.server.util.TimeThread;
+import org.opends.server.util.Validator;
import static org.opends.server.config.ConfigConstants.*;
import static org.opends.server.loggers.debug.DebugLogger.debugCaught;
@@ -80,6 +80,7 @@
import static org.opends.server.util.StaticUtils.*;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.server.BackendCfg;
+import org.opends.server.admin.Configuration;
/**
@@ -132,13 +133,18 @@
}
-
/**
* {@inheritDoc}
*/
- public void initializeBackend(ConfigEntry configEntry, DN[] baseDNs)
- throws ConfigException, InitializationException
+ public void configureBackend(Configuration config) throws ConfigException
{
+ Validator.ensureNotNull(config);
+ Validator.ensureTrue(config instanceof BackendCfg);
+
+ BackendCfg cfg = (BackendCfg)config;
+ ConfigEntry configEntry = DirectoryServer.getConfigEntry(cfg.dn());
+
+
// Make sure that a configuration entry was provided. If not, then we will
// not be able to complete initialization.
if (configEntry == null)
@@ -148,7 +154,6 @@
throw new ConfigException(msgID, message);
}
- BackendCfg cfg = BackendConfigManager.getBackendCfg(configEntry);
configEntryDN = configEntry.getDN();
@@ -180,6 +185,20 @@
}
+ // Construct the set of objectclasses to include in the base monitor entry.
+ monitorObjectClasses = new LinkedHashMap<ObjectClass,String>(2);
+ ObjectClass topOC = DirectoryServer.getObjectClass(OC_TOP, true);
+ monitorObjectClasses.put(topOC, OC_TOP);
+
+ ObjectClass monitorOC = DirectoryServer.getObjectClass(OC_MONITOR_ENTRY,
+ true);
+ monitorObjectClasses.put(monitorOC, OC_MONITOR_ENTRY);
+
+
+ // Define an empty sets for the supported controls and features.
+ supportedControls = new HashSet<String>(0);
+ supportedFeatures = new HashSet<String>(0);
+
// Create the set of base DNs that we will handle. In this case, it's just
// the DN of the base monitor entry.
try
@@ -195,31 +214,24 @@
int msgID = MSGID_MONITOR_CANNOT_DECODE_MONITOR_ROOT_DN;
String message = getMessage(msgID, getExceptionMessage(e));
- throw new InitializationException(msgID, message, e);
+ throw new ConfigException(msgID, message, e);
}
// FIXME -- Deal with this more correctly.
this.baseDNs = new DN[] { baseMonitorDN };
- // Construct the set of objectclasses to include in the base monitor entry.
- monitorObjectClasses = new LinkedHashMap<ObjectClass,String>(2);
- ObjectClass topOC = DirectoryServer.getObjectClass(OC_TOP, true);
- monitorObjectClasses.put(topOC, OC_TOP);
-
- ObjectClass monitorOC = DirectoryServer.getObjectClass(OC_MONITOR_ENTRY,
- true);
- monitorObjectClasses.put(monitorOC, OC_MONITOR_ENTRY);
-
-
- // Define an empty sets for the supported controls and features.
- supportedControls = new HashSet<String>(0);
- supportedFeatures = new HashSet<String>(0);
-
-
- // Register with the Directory Server as a configurable component.
currentConfig = cfg;
- cfg.addChangeListener(this);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void initializeBackend()
+ throws ConfigException, InitializationException
+ {
+ // Register with the Directory Server as a configurable component.
+ currentConfig.addChangeListener(this);
// Register the monitor base as a private suffix.
@@ -951,72 +963,11 @@
/**
* {@inheritDoc}
*/
- public void exportLDIF(ConfigEntry configEntry, DN[] baseDNs,
- LDIFExportConfig exportConfig)
+ public void exportLDIF(LDIFExportConfig exportConfig)
throws DirectoryException
{
// TODO export-ldif reports nonsense for upTime etc.
- configEntryDN = configEntry.getDN();
-
-
- // Get the set of user-defined attributes for the configuration entry. Any
- // attributes that we don't recognize will be included directly in the base
- // monitor entry.
- userDefinedAttributes = new ArrayList<Attribute>();
- for (List<Attribute> attrs :
- configEntry.getEntry().getUserAttributes().values())
- {
- for (Attribute a : attrs)
- {
- if (! isMonitorConfigAttribute(a))
- {
- userDefinedAttributes.add(a);
- }
- }
- }
- for (List<Attribute> attrs :
- configEntry.getEntry().getOperationalAttributes().values())
- {
- for (Attribute a : attrs)
- {
- if (! isMonitorConfigAttribute(a))
- {
- userDefinedAttributes.add(a);
- }
- }
- }
-
-
- // Create the set of base DNs that we will handle. In this case, it's just
- // the DN of the base monitor entry.
- try
- {
- baseMonitorDN = DN.decode(DN_MONITOR_ROOT);
- }
- catch (Exception e)
- {
- if (debugEnabled())
- {
- debugCaught(DebugLogLevel.ERROR, e);
- }
-
- int msgID = MSGID_MONITOR_CANNOT_DECODE_MONITOR_ROOT_DN;
- String message = getMessage(msgID, getExceptionMessage(e));
- throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
- message, msgID, e);
- }
-
- // Construct the set of objectclasses to include in the base monitor entry.
- monitorObjectClasses = new LinkedHashMap<ObjectClass,String>(2);
- ObjectClass topOC = DirectoryServer.getObjectClass(OC_TOP, true);
- monitorObjectClasses.put(topOC, OC_TOP);
-
- ObjectClass monitorOC = DirectoryServer.getObjectClass(OC_MONITOR_ENTRY,
- true);
- monitorObjectClasses.put(monitorOC, OC_MONITOR_ENTRY);
-
-
// Create the LDIF writer.
LDIFWriter ldifWriter;
try
@@ -1140,8 +1091,7 @@
/**
* {@inheritDoc}
*/
- public void importLDIF(ConfigEntry configEntry, DN[] baseDNs,
- LDIFImportConfig importConfig)
+ public void importLDIF(LDIFImportConfig importConfig)
throws DirectoryException
{
// This backend does not support LDIF imports.
@@ -1199,7 +1149,7 @@
/**
* {@inheritDoc}
*/
- public void createBackup(ConfigEntry configEntry, BackupConfig backupConfig)
+ public void createBackup(BackupConfig backupConfig)
throws DirectoryException
{
// This backend does not provide a backup/restore mechanism.
@@ -1253,8 +1203,7 @@
/**
* {@inheritDoc}
*/
- public void restoreBackup(ConfigEntry configEntry,
- RestoreConfig restoreConfig)
+ public void restoreBackup(RestoreConfig restoreConfig)
throws DirectoryException
{
// This backend does not provide a backup/restore mechanism.
diff --git a/opends/src/server/org/opends/server/backends/RootDSEBackend.java b/opends/src/server/org/opends/server/backends/RootDSEBackend.java
index 5b492c5..fff0b3b 100644
--- a/opends/src/server/org/opends/server/backends/RootDSEBackend.java
+++ b/opends/src/server/org/opends/server/backends/RootDSEBackend.java
@@ -47,7 +47,6 @@
import org.opends.server.core.ModifyOperation;
import org.opends.server.core.ModifyDNOperation;
import org.opends.server.core.SearchOperation;
-import org.opends.server.core.BackendConfigManager;
import org.opends.server.protocols.asn1.ASN1OctetString;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
@@ -71,6 +70,7 @@
import org.opends.server.types.ResultCode;
import org.opends.server.types.SearchFilter;
import org.opends.server.util.LDIFWriter;
+import org.opends.server.util.Validator;
import static org.opends.server.config.ConfigConstants.*;
import static org.opends.server.loggers.debug.DebugLogger.debugCaught;
@@ -84,8 +84,8 @@
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
import org.opends.server.admin.std.server.RootDSEBackendCfg;
-import org.opends.server.admin.std.meta.RootDSEBackendCfgDefn;
import org.opends.server.admin.server.ConfigurationChangeListener;
+import org.opends.server.admin.Configuration;
/**
@@ -156,13 +156,26 @@
}
+ /**
+ * {@inheritDoc}
+ */
+ public void configureBackend(Configuration config) throws ConfigException
+ {
+ Validator.ensureNotNull(config);
+ Validator.ensureTrue(config instanceof RootDSEBackendCfg);
+ currentConfig = (RootDSEBackendCfg)config;
+ configEntryDN = config.dn();
+ }
/**
* {@inheritDoc}
*/
- public void initializeBackend(ConfigEntry configEntry, DN[] baseDNs)
+ public void initializeBackend()
throws ConfigException, InitializationException
{
+ ConfigEntry configEntry =
+ DirectoryServer.getConfigEntry(configEntryDN);
+
// Make sure that a configuration entry was provided. If not, then we will
// not be able to complete initialization.
if (configEntry == null)
@@ -172,10 +185,6 @@
throw new ConfigException(msgID, message);
}
- configEntryDN = configEntry.getDN();
- RootDSEBackendCfg cfg = getRootDSEBackendCfg(configEntry);
-
-
// Get the set of user-defined attributes for the configuration entry. Any
// attributes that we don't recognize will be included directly in the root
// DSE.
@@ -215,7 +224,7 @@
// backends defined in the server.
try
{
- Set<DN> subDNs = cfg.getSubordinateBaseDN();
+ Set<DN> subDNs = currentConfig.getSubordinateBaseDN();
if (subDNs.isEmpty())
{
// This is fine -- we'll just use the set of user-defined suffixes.
@@ -256,7 +265,7 @@
// Determine whether all root DSE attributes should be treated as user
// attributes.
- showAllAttributes = cfg.isShowAllAttributes();
+ showAllAttributes = currentConfig.isShowAllAttributes();
// Construct the set of "static" attributes that will always be present in
@@ -303,8 +312,7 @@
// Register as a change listener.
- currentConfig = cfg;
- cfg.addChangeListener(this);
+ currentConfig.addChangeListener(this);
}
@@ -1119,8 +1127,7 @@
/**
* {@inheritDoc}
*/
- public void exportLDIF(ConfigEntry configEntry, DN[] baseDNs,
- LDIFExportConfig exportConfig)
+ public void exportLDIF(LDIFExportConfig exportConfig)
throws DirectoryException
{
// Create the LDIF writer.
@@ -1197,8 +1204,7 @@
/**
* {@inheritDoc}
*/
- public void importLDIF(ConfigEntry configEntry, DN[] baseDNs,
- LDIFImportConfig importConfig)
+ public void importLDIF(LDIFImportConfig importConfig)
throws DirectoryException
{
// This backend does not support LDIF imports.
@@ -1256,7 +1262,7 @@
/**
* {@inheritDoc}
*/
- public void createBackup(ConfigEntry configEntry, BackupConfig backupConfig)
+ public void createBackup(BackupConfig backupConfig)
throws DirectoryException
{
// This backend does not provide a backup/restore mechanism.
@@ -1310,8 +1316,7 @@
/**
* {@inheritDoc}
*/
- public void restoreBackup(ConfigEntry configEntry,
- RestoreConfig restoreConfig)
+ public void restoreBackup(RestoreConfig restoreConfig)
throws DirectoryException
{
// This backend does not provide a backup/restore mechanism.
@@ -1542,10 +1547,5 @@
- private static RootDSEBackendCfg getRootDSEBackendCfg(ConfigEntry configEntry)
- throws ConfigException {
- return BackendConfigManager.getConfiguration(
- RootDSEBackendCfgDefn.getInstance(), configEntry);
- }
}
diff --git a/opends/src/server/org/opends/server/backends/SchemaBackend.java b/opends/src/server/org/opends/server/backends/SchemaBackend.java
index c98fdc9..fb56164 100644
--- a/opends/src/server/org/opends/server/backends/SchemaBackend.java
+++ b/opends/src/server/org/opends/server/backends/SchemaBackend.java
@@ -69,7 +69,6 @@
import org.opends.server.core.ModifyDNOperation;
import org.opends.server.core.SchemaConfigManager;
import org.opends.server.core.SearchOperation;
-import org.opends.server.core.BackendConfigManager;
import org.opends.server.schema.AttributeTypeSyntax;
import org.opends.server.schema.DITContentRuleSyntax;
import org.opends.server.schema.DITStructureRuleSyntax;
@@ -112,6 +111,7 @@
import org.opends.server.util.DynamicConstants;
import org.opends.server.util.LDIFException;
import org.opends.server.util.LDIFWriter;
+import org.opends.server.util.Validator;
import org.opends.server.types.DebugLogLevel;
import static org.opends.server.config.ConfigConstants.*;
@@ -123,8 +123,8 @@
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
import org.opends.server.admin.std.server.SchemaBackendCfg;
-import org.opends.server.admin.std.meta.SchemaBackendCfgDefn;
import org.opends.server.admin.server.ConfigurationChangeListener;
+import org.opends.server.admin.Configuration;
import static org.opends.server.messages.ConfigMessages.*;
@@ -247,29 +247,24 @@
/**
- * Initialization shared by multiple backend methods.
- * @param configEntry The configuration entry that contains the
- * information to use to initialize this
- * backend.
- * @param baseDNs The set of base DNs that have been
- * configured for this backend.
- * @throws ConfigException If an unrecoverable problem arises in
- * the process of performing the
- * initialization.
+ * {@inheritDoc}
*/
- private void initializeCommon(ConfigEntry configEntry, DN[] baseDNs)
+ public void configureBackend(Configuration config)
throws ConfigException
{
// Make sure that a configuration entry was provided. If not, then we will
// not be able to complete initialization.
- if (configEntry == null)
+ if (config == null)
{
int msgID = MSGID_SCHEMA_CONFIG_ENTRY_NULL;
String message = getMessage(msgID);
throw new ConfigException(msgID, message);
}
- SchemaBackendCfg cfg = getSchemaBackendCfg(configEntry);
+ Validator.ensureTrue(config instanceof SchemaBackendCfg);
+ SchemaBackendCfg cfg = (SchemaBackendCfg)config;
+ ConfigEntry configEntry = DirectoryServer.getConfigEntry(cfg.dn());
+
configEntryDN = configEntry.getDN();
// Get all of the attribute types that we will use for schema elements.
@@ -321,6 +316,9 @@
configEntryDN = configEntry.getDN();
+
+ DN[] baseDNs = new DN[cfg.getBackendBaseDN().size()];
+ cfg.getBackendBaseDN().toArray(baseDNs);
this.baseDNs = baseDNs;
creatorsName = new AttributeValue(creatorsNameType, baseDNs[0].toString());
@@ -375,11 +373,9 @@
/**
* {@inheritDoc}
*/
- public void initializeBackend(ConfigEntry configEntry, DN[] baseDNs)
+ public void initializeBackend()
throws ConfigException, InitializationException
{
- initializeCommon(configEntry, baseDNs);
-
// Register each of the suffixes with the Directory Server. Also, register
// the first one as the schema base.
DirectoryServer.setSchemaDN(baseDNs[0]);
@@ -4150,20 +4146,9 @@
/**
* {@inheritDoc}
*/
- public void exportLDIF(ConfigEntry configEntry, DN[] baseDNs,
- LDIFExportConfig exportConfig)
+ public void exportLDIF(LDIFExportConfig exportConfig)
throws DirectoryException
{
- try
- {
- initializeCommon(configEntry, baseDNs);
- }
- catch (ConfigException e)
- {
- throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
- e.getMessage(), e.getMessageID());
- }
-
// Create the LDIF writer.
LDIFWriter ldifWriter;
try
@@ -4239,8 +4224,7 @@
/**
* {@inheritDoc}
*/
- public void importLDIF(ConfigEntry configEntry, DN[] baseDNs,
- LDIFImportConfig importConfig)
+ public void importLDIF(LDIFImportConfig importConfig)
throws DirectoryException
{
// This backend does not support LDIF imports.
@@ -4301,7 +4285,7 @@
/**
* {@inheritDoc}
*/
- public void createBackup(ConfigEntry configEntry, BackupConfig backupConfig)
+ public void createBackup(BackupConfig backupConfig)
throws DirectoryException
{
// Get the properties to use for the backup. We don't care whether or not
@@ -4697,8 +4681,7 @@
/**
* {@inheritDoc}
*/
- public void restoreBackup(ConfigEntry configEntry,
- RestoreConfig restoreConfig)
+ public void restoreBackup(RestoreConfig restoreConfig)
throws DirectoryException
{
// First, make sure that the requested backup exists.
@@ -5458,10 +5441,5 @@
- private static SchemaBackendCfg getSchemaBackendCfg(ConfigEntry configEntry)
- throws ConfigException {
- return BackendConfigManager.getConfiguration(
- SchemaBackendCfgDefn.getInstance(), configEntry);
- }
}
diff --git a/opends/src/server/org/opends/server/backends/jeb/BackendImpl.java b/opends/src/server/org/opends/server/backends/jeb/BackendImpl.java
index 065d5f2..3da0091 100644
--- a/opends/src/server/org/opends/server/backends/jeb/BackendImpl.java
+++ b/opends/src/server/org/opends/server/backends/jeb/BackendImpl.java
@@ -37,14 +37,12 @@
import org.opends.server.api.Backend;
import org.opends.server.api.MonitorProvider;
import org.opends.server.config.ConfigException;
-import org.opends.server.config.ConfigEntry;
import org.opends.server.core.AddOperation;
import org.opends.server.core.DeleteOperation;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.ModifyOperation;
import org.opends.server.core.ModifyDNOperation;
import org.opends.server.core.SearchOperation;
-import org.opends.server.core.BackendConfigManager;
import org.opends.server.util.LDIFException;
import org.opends.server.util.Validator;
@@ -57,8 +55,8 @@
import org.opends.server.types.*;
import static org.opends.server.util.ServerConstants.*;
import org.opends.server.admin.std.server.JEBackendCfg;
-import org.opends.server.admin.std.meta.JEBackendCfgDefn;
import org.opends.server.admin.server.ConfigurationChangeListener;
+import org.opends.server.admin.Configuration;
/**
* This is an implementation of a Directory Server Backend which stores entries
@@ -73,7 +71,7 @@
* The configuration of this JE backend.
*/
private Config config;
- private JEBackendCfg currentConfig;
+ private JEBackendCfg cfg;
/**
* The root JE container to use for this backend.
@@ -214,16 +212,28 @@
/**
* {@inheritDoc}
*/
- public void initializeBackend(ConfigEntry configEntry, DN[] baseDNs)
- throws ConfigException, InitializationException
+ public void configureBackend(Configuration cfg)
+ throws ConfigException
{
- Validator.ensureNotNull(configEntry);
- JEBackendCfg backendCfg = getJEBackendCfg(configEntry);
+ Validator.ensureNotNull(cfg);
+ Validator.ensureTrue(cfg instanceof JEBackendCfg);
// Initialize a config object
- config = new Config();
- config.initializeConfig(backendCfg, baseDNs);
+ Config config = new Config();
+ config.initializeConfig((JEBackendCfg)cfg);
+ this.cfg = (JEBackendCfg)cfg;
+ this.config = config;
+ }
+
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void initializeBackend()
+ throws ConfigException, InitializationException
+ {
// Open the database environment
try
{
@@ -243,7 +253,7 @@
try
{
- rootContainer.openEntryContainers(baseDNs);
+ rootContainer.openEntryContainers(config.getBaseDNs());
}
catch (DatabaseException databaseException)
{
@@ -264,7 +274,8 @@
{
// Log an informational message about the number of entries.
int msgID = MSGID_JEB_BACKEND_STARTED;
- String message = getMessage(msgID, rootContainer.getEntryCount());
+ String message = getMessage(msgID, cfg.getBackendId(),
+ rootContainer.getEntryCount());
logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.NOTICE, message,
msgID);
}
@@ -280,7 +291,7 @@
message, databaseException);
}
- for (DN dn : baseDNs)
+ for (DN dn : config.getBaseDNs())
{
try
{
@@ -307,10 +318,9 @@
DirectoryServer.registerMonitorProvider(monitorProvider);
// Register this backend as a change listener.
- currentConfig = backendCfg;
- backendCfg.addJEChangeListener(this);
- backendCfg.addJEChangeListener(config);
- backendCfg.addJEChangeListener(rootContainer);
+ cfg.addJEChangeListener(this);
+ cfg.addJEChangeListener(config);
+ cfg.addJEChangeListener(rootContainer);
}
/**
@@ -325,9 +335,9 @@
public void finalizeBackend()
{
// Deregister as a change listener.
- currentConfig.removeJEChangeListener(rootContainer);
- currentConfig.removeJEChangeListener(config);
- currentConfig.removeJEChangeListener(this);
+ cfg.removeJEChangeListener(rootContainer);
+ cfg.removeJEChangeListener(config);
+ cfg.removeJEChangeListener(this);
// Deregister our base DNs.
for (DN dn : rootContainer.getBaseDNs())
@@ -379,9 +389,6 @@
// Make sure the thread counts are zero for next initialization.
threadTotalCount.set(0);
threadWriteCount.set(0);
-
- // We will not reuse the config object.
- config = null;
}
@@ -871,28 +878,9 @@
/**
* {@inheritDoc}
*/
- public void exportLDIF(ConfigEntry configEntry, DN[] baseDNs,
- LDIFExportConfig exportConfig)
+ public void exportLDIF(LDIFExportConfig exportConfig)
throws DirectoryException
{
- // Initialize a config object.
- config = new Config();
-
- try
- {
- config.initializeConfig(configEntry, baseDNs);
- }
- catch (ConfigException e)
- {
- if (debugEnabled())
- {
- debugCaught(DebugLogLevel.ERROR, e);
- }
- throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
- e.getMessage(),
- e.getMessageID());
- }
-
// If the backend already has the root container open, we must use the same
// underlying root container
boolean openRootContainer = rootContainer == null;
@@ -906,7 +894,7 @@
rootContainer.open(config.getBackendDirectory(),
config.getBackendPermission(),
true, false, false, false, true, true);
- rootContainer.openEntryContainers(baseDNs);
+ rootContainer.openEntryContainers(config.getBaseDNs());
}
ExportJob exportJob = new ExportJob(exportConfig);
@@ -981,28 +969,9 @@
/**
* {@inheritDoc}
*/
- public void importLDIF(ConfigEntry configEntry, DN[] baseDNs,
- LDIFImportConfig importConfig)
+ public void importLDIF(LDIFImportConfig importConfig)
throws DirectoryException
{
- // Initialize a config object.
- config = new Config();
-
- try
- {
- config.initializeConfig(configEntry, baseDNs);
- }
- catch (ConfigException e)
- {
- if (debugEnabled())
- {
- debugCaught(DebugLogLevel.ERROR, e);
- }
- throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
- e.getMessage(),
- e.getMessageID());
- }
-
try
{
ImportJob importJob = new ImportJob(this, config, importConfig);
@@ -1047,9 +1016,6 @@
/**
* Verify the integrity of the backend instance.
* @param verifyConfig The verify configuration.
- * @param configEntry The backend instance configuration entry.
- * @param baseDNs The set of base DNs that have been configured for this
- * backend.
* @param statEntry Optional entry to save stats into.
* @throws ConfigException If an unrecoverable problem arises during
* initialization.
@@ -1058,14 +1024,9 @@
* configuration.
* @throws DirectoryException If a Directory Server error occurs.
*/
- public void verifyBackend(VerifyConfig verifyConfig, ConfigEntry configEntry,
- DN[] baseDNs, Entry statEntry)
+ public void verifyBackend(VerifyConfig verifyConfig, Entry statEntry)
throws InitializationException, ConfigException, DirectoryException
{
- // Initialize a config object.
- config = new Config();
- config.initializeConfig(configEntry, baseDNs);
-
// If the backend already has the root container open, we must use the same
// underlying root container
boolean openRootContainer = rootContainer == null;
@@ -1079,7 +1040,7 @@
rootContainer.open(config.getBackendDirectory(),
config.getBackendPermission(),
true, false, false, false, true, true);
- rootContainer.openEntryContainers(baseDNs);
+ rootContainer.openEntryContainers(config.getBaseDNs());
}
VerifyJob verifyJob = new VerifyJob(config, verifyConfig);
@@ -1133,9 +1094,6 @@
* Rebuild index(es) in the backend instance. Note that the server will not
* explicitly initialize this backend before calling this method.
* @param rebuildConfig The rebuild configuration.
- * @param configEntry The backend instance configuration entry.
- * @param baseDNs The set of base DNs that have been configured for this
- * backend.
* @throws ConfigException If an unrecoverable problem arises during
* initialization.
* @throws InitializationException If a problem occurs during initialization
@@ -1143,12 +1101,9 @@
* configuration.
* @throws DirectoryException If a Directory Server error occurs.
*/
- public void rebuildBackend(RebuildConfig rebuildConfig,
- ConfigEntry configEntry, DN[] baseDNs)
+ public void rebuildBackend(RebuildConfig rebuildConfig)
throws InitializationException, ConfigException, DirectoryException
{
- JEBackendCfg backendCfg = getJEBackendCfg(configEntry);
-
// If the backend already has the root container open, we must use the same
// underlying root container
boolean openRootContainer = rootContainer == null;
@@ -1168,14 +1123,10 @@
{
if (openRootContainer)
{
- // Initialize a config object.
- config = new Config();
- config.initializeConfig(backendCfg, baseDNs);
-
// Open the database environment
rootContainer = new RootContainer(config, this);
rootContainer.open();
- rootContainer.openEntryContainers(baseDNs);
+ rootContainer.openEntryContainers(config.getBaseDNs());
}
RebuildJob rebuildJob = new RebuildJob(rebuildConfig);
@@ -1229,12 +1180,12 @@
/**
* {@inheritDoc}
*/
- public void createBackup(ConfigEntry configEntry, BackupConfig backupConfig)
+ public void createBackup(BackupConfig backupConfig)
throws DirectoryException
{
BackupManager backupManager =
new BackupManager(getBackendID());
- backupManager.createBackup(configEntry, backupConfig);
+ backupManager.createBackup(cfg, backupConfig);
}
@@ -1255,13 +1206,12 @@
/**
* {@inheritDoc}
*/
- public void restoreBackup(ConfigEntry configEntry,
- RestoreConfig restoreConfig)
+ public void restoreBackup(RestoreConfig restoreConfig)
throws DirectoryException
{
BackupManager backupManager =
new BackupManager(getBackendID());
- backupManager.restoreBackup(configEntry, restoreConfig);
+ backupManager.restoreBackup(cfg, restoreConfig);
}
@@ -1346,7 +1296,7 @@
}
// Put the new configuration in place.
- currentConfig = cfg;
+ this.cfg = cfg;
}
catch (Exception e)
{
@@ -1375,37 +1325,16 @@
* Clears all the entries from the backend. This method is for test cases
* that use the JE backend.
*
- * @param configEntry The configuration entry that contains the information
- * to use to initialize this backend.
- * @param baseDNs The set of base DNs that have been configured for this
- * backend.
- *
* @throws ConfigException If an unrecoverable problem arises in the
* process of performing the initialization.
*
* @throws JebException If an error occurs while removing the data.
*/
- public void clearBackend(ConfigEntry configEntry, DN[] baseDNs)
+ public void clearBackend()
throws ConfigException, JebException
{
- Config config = new Config();
- config.initializeConfig(configEntry, baseDNs);
EnvManager.removeFiles(config.getBackendDirectory().getPath());
}
- /**
- * Gets the JE backend configuration corresponding to a JE
- * backend config entry.
- *
- * @param configEntry A JE backend config entry.
- * @return Returns the JE backend configuration.
- * @throws ConfigException If the config entry could not be decoded.
- */
- static JEBackendCfg getJEBackendCfg(ConfigEntry configEntry)
- throws ConfigException {
- return BackendConfigManager.getConfiguration(
- JEBackendCfgDefn.getInstance(), configEntry);
- }
-
}
diff --git a/opends/src/server/org/opends/server/backends/jeb/BackupManager.java b/opends/src/server/org/opends/server/backends/jeb/BackupManager.java
index 65ac7f1..291f9ff 100644
--- a/opends/src/server/org/opends/server/backends/jeb/BackupManager.java
+++ b/opends/src/server/org/opends/server/backends/jeb/BackupManager.java
@@ -26,7 +26,6 @@
*/
package org.opends.server.backends.jeb;
-import org.opends.server.config.ConfigEntry;
import org.opends.server.config.ConfigException;
import org.opends.server.core.DirectoryServer;
import org.opends.server.util.DynamicConstants;
@@ -77,6 +76,7 @@
import static org.opends.server.messages.JebMessages.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
+import org.opends.server.admin.std.server.JEBackendCfg;
/**
* A backup manager for JE backends.
@@ -138,19 +138,19 @@
* log files that are unchanged since the previous backup. The remaining
* zip entries are the JE log files themselves, which, for an incremental,
* only include those files that have changed.
- * @param configEntry The configuration entry of the backend instance for
+ * @param cfg The configuration of the backend instance for
* which the backup is required.
* @param backupConfig The configuration to use when performing the backup.
* @throws DirectoryException If a Directory Server error occurs.
*/
- public void createBackup(ConfigEntry configEntry, BackupConfig backupConfig)
+ public void createBackup(JEBackendCfg cfg, BackupConfig backupConfig)
throws DirectoryException
{
// Parse our backend configuration.
Config config = new Config();
try
{
- config.initializeConfig(configEntry, null);
+ config.initializeConfig(cfg);
}
catch (ConfigException e)
{
@@ -747,12 +747,12 @@
/**
* Restore a JE backend from backup, or verify the backup.
- * @param configEntry The configuration entry of the backend instance to be
+ * @param cfg The configuration of the backend instance to be
* restored.
* @param restoreConfig The configuration to use when performing the restore.
* @throws DirectoryException If a Directory Server error occurs.
*/
- public void restoreBackup(ConfigEntry configEntry,
+ public void restoreBackup(JEBackendCfg cfg,
RestoreConfig restoreConfig)
throws DirectoryException
{
@@ -767,7 +767,7 @@
Config config = new Config();
try
{
- config.initializeConfig(configEntry, null);
+ config.initializeConfig(cfg);
}
catch (ConfigException e)
{
diff --git a/opends/src/server/org/opends/server/backends/jeb/Config.java b/opends/src/server/org/opends/server/backends/jeb/Config.java
index 2d54346..63a1cf3 100644
--- a/opends/src/server/org/opends/server/backends/jeb/Config.java
+++ b/opends/src/server/org/opends/server/backends/jeb/Config.java
@@ -201,50 +201,32 @@
/**
- * Initialize this JE backend configuration from a configuration entry.
+ * Initialize this JE backend configuration from its configuration.
*
- * @param configEntry The backend configuration entry.
- * @param baseDNs The set of base DNs that have been configured for this
- * backend.
+ * @param cfg The backend configuration.
* @throws ConfigException If there is an error in the configuration entry.
*/
- public void initializeConfig(ConfigEntry configEntry, DN[] baseDNs)
+ public void initializeConfig(JEBackendCfg cfg)
throws ConfigException
{
- initializeConfig(BackendImpl.getJEBackendCfg(configEntry), configEntry,
- baseDNs);
+ initializeConfig(cfg, DirectoryServer.getConfigEntry(cfg.dn()));
}
/**
- * Initialize this JE backend configuration from a configuration entry.
- *
- * @param cfg The backend configuration entry.
- * @param baseDNs The set of base DNs that have been configured for this
- * backend.
- * @throws ConfigException If there is an error in the configuration entry.
- */
- public void initializeConfig(JEBackendCfg cfg, DN[] baseDNs)
- throws ConfigException
- {
- initializeConfig(cfg, DirectoryServer.getConfigEntry(cfg.dn()), baseDNs);
- }
-
-
- /**
- * Initialize this JE backend configuration from a configuration object
+ * Initialize this JE backend configuration from its configuration object
* and its configuration entry.
*
* @param cfg The backend configuration object.
* @param configEntry The backend configuration entry.
- * @param baseDNs The set of base DNs that have been configured for this
- * backend.
* @throws ConfigException If there is an error in the configuration entry.
*/
- private void initializeConfig(JEBackendCfg cfg, ConfigEntry configEntry,
- DN[] baseDNs)
+ private void initializeConfig(JEBackendCfg cfg, ConfigEntry configEntry)
throws ConfigException
{
+ DN[] baseDNs = new DN[cfg.getBackendBaseDN().size()];
+ cfg.getBackendBaseDN().toArray(baseDNs);
+
// Set the base DNs.
this.baseDNs = baseDNs;
diff --git a/opends/src/server/org/opends/server/backends/jeb/RootContainer.java b/opends/src/server/org/opends/server/backends/jeb/RootContainer.java
index e5663bf..6575b38 100644
--- a/opends/src/server/org/opends/server/backends/jeb/RootContainer.java
+++ b/opends/src/server/org/opends/server/backends/jeb/RootContainer.java
@@ -493,7 +493,7 @@
entryContainers.remove(baseDN);
}
- env.close();
+ if (env != null) env.close();
}
/**
diff --git a/opends/src/server/org/opends/server/backends/task/TaskBackend.java b/opends/src/server/org/opends/server/backends/task/TaskBackend.java
index bd8b9bd..8e8dd38 100644
--- a/opends/src/server/org/opends/server/backends/task/TaskBackend.java
+++ b/opends/src/server/org/opends/server/backends/task/TaskBackend.java
@@ -43,7 +43,6 @@
import org.opends.server.core.ModifyOperation;
import org.opends.server.core.ModifyDNOperation;
import org.opends.server.core.SearchOperation;
-import org.opends.server.core.BackendConfigManager;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
import org.opends.server.types.BackupConfig;
@@ -68,8 +67,8 @@
import static org.opends.server.util.StaticUtils.*;
import org.opends.server.util.Validator;
import org.opends.server.admin.std.server.TaskBackendCfg;
-import org.opends.server.admin.std.meta.TaskBackendCfgDefn;
import org.opends.server.admin.server.ConfigurationChangeListener;
+import org.opends.server.admin.Configuration;
/**
@@ -136,13 +135,19 @@
/**
* {@inheritDoc}
*/
- public void initializeBackend(ConfigEntry configEntry, DN[] baseDNs)
- throws ConfigException, InitializationException
+ public void configureBackend(Configuration config) throws ConfigException
{
- Validator.ensureNotNull(configEntry);
- TaskBackendCfg cfg = getTaskBackendCfg(configEntry);
+ Validator.ensureNotNull(config);
+ Validator.ensureTrue(config instanceof TaskBackendCfg);
- configEntryDN = cfg.dn();
+ TaskBackendCfg cfg = (TaskBackendCfg)config;
+
+ DN[] baseDNs = new DN[cfg.getBackendBaseDN().size()];
+ cfg.getBackendBaseDN().toArray(baseDNs);
+
+ ConfigEntry configEntry = DirectoryServer.getConfigEntry(cfg.dn());
+
+ configEntryDN = configEntry.getDN();
// Make sure that the provided set of base DNs contains exactly one value.
@@ -183,7 +188,7 @@
String message = getMessage(msgID,
String.valueOf(recurringTaskBaseString),
getExceptionMessage(e));
- throw new InitializationException(msgID, message, e);
+ throw new ConfigException(msgID, message, e);
}
String scheduledTaskBaseString = SCHEDULED_TASK_BASE_RDN + "," +
@@ -204,7 +209,7 @@
String message = getMessage(msgID,
String.valueOf(scheduledTaskBaseString),
getExceptionMessage(e));
- throw new InitializationException(msgID, message, e);
+ throw new ConfigException(msgID, message, e);
}
}
@@ -217,20 +222,26 @@
// Get the path to the task data backing file.
taskBackingFile = cfg.getTaskBackingFile();
+ // Define an empty sets for the supported controls and features.
+ supportedControls = new HashSet<String>(0);
+ supportedFeatures = new HashSet<String>(0);
+ currentConfig = cfg;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void initializeBackend()
+ throws ConfigException, InitializationException
+ {
// Create the scheduler and initialize it from the backing file.
taskScheduler = new TaskScheduler(this);
taskScheduler.start();
- // Define an empty sets for the supported controls and features.
- supportedControls = new HashSet<String>(0);
- supportedFeatures = new HashSet<String>(0);
-
-
// Register with the Directory Server as a configurable component.
- currentConfig = cfg;
- cfg.addTaskChangeListener(this);
+ currentConfig.addTaskChangeListener(this);
// Register the task base as a private suffix.
@@ -930,8 +941,7 @@
/**
* {@inheritDoc}
*/
- public void exportLDIF(ConfigEntry configEntry, DN[] baseDNs,
- LDIFExportConfig exportConfig)
+ public void exportLDIF(LDIFExportConfig exportConfig)
throws DirectoryException
{
// FIXME -- Implement support for exporting to LDIF.
@@ -957,8 +967,7 @@
/**
* {@inheritDoc}
*/
- public void importLDIF(ConfigEntry configEntry, DN[] baseDNs,
- LDIFImportConfig importConfig)
+ public void importLDIF(LDIFImportConfig importConfig)
throws DirectoryException
{
// This backend does not support LDIF imports.
@@ -1016,7 +1025,7 @@
/**
* {@inheritDoc}
*/
- public void createBackup(ConfigEntry configEntry, BackupConfig backupConfig)
+ public void createBackup(BackupConfig backupConfig)
throws DirectoryException
{
// NYI -- Create the backup.
@@ -1062,8 +1071,7 @@
/**
* {@inheritDoc}
*/
- public void restoreBackup(ConfigEntry configEntry,
- RestoreConfig restoreConfig)
+ public void restoreBackup(RestoreConfig restoreConfig)
throws DirectoryException
{
// NYI -- Restore the backup.
@@ -1350,10 +1358,5 @@
- private static TaskBackendCfg getTaskBackendCfg(ConfigEntry configEntry)
- throws ConfigException {
- return BackendConfigManager.getConfiguration(
- TaskBackendCfgDefn.getInstance(), configEntry);
- }
}
diff --git a/opends/src/server/org/opends/server/core/BackendConfigManager.java b/opends/src/server/org/opends/server/core/BackendConfigManager.java
index 7acd8b9..c7f6dab 100644
--- a/opends/src/server/org/opends/server/core/BackendConfigManager.java
+++ b/opends/src/server/org/opends/server/core/BackendConfigManager.java
@@ -53,16 +53,9 @@
import org.opends.server.admin.server.ConfigurationAddListener;
import org.opends.server.admin.server.ConfigurationDeleteListener;
import org.opends.server.admin.server.ServerManagementContext;
-import org.opends.server.admin.server.ServerManagedObject;
-import org.opends.server.admin.server.ConfigExceptionFactory;
-import org.opends.server.admin.server.ServerManagedObjectDecodingException;
import org.opends.server.admin.std.server.BackendCfg;
import org.opends.server.admin.std.server.RootCfg;
import org.opends.server.admin.std.meta.BackendCfgDefn;
-import org.opends.server.admin.Configuration;
-import org.opends.server.admin.AbstractManagedObjectDefinition;
-import org.opends.server.admin.ManagedObjectPath;
-import org.opends.server.admin.DefinitionDecodingException;
/**
@@ -285,12 +278,9 @@
// Perform the necessary initialization for the backend entry.
- DN[] baseDNs = new DN[backendCfg.getBackendBaseDN().size()];
- baseDNs = backendCfg.getBackendBaseDN().toArray(baseDNs);
try
{
- backend.initializeBackend(
- DirectoryServer.getConfigEntry(backendCfg.dn()), baseDNs);
+ initializeBackend(backend, backendCfg);
}
catch (Exception e)
{
@@ -769,8 +759,7 @@
try
{
- backend.initializeBackend(
- DirectoryServer.getConfigEntry(cfg.dn()), baseDNs);
+ initializeBackend(backend, cfg);
}
catch (Exception e)
{
@@ -1146,8 +1135,7 @@
// Perform the necessary initialization for the backend entry.
try
{
- backend.initializeBackend(
- DirectoryServer.getConfigEntry(cfg.dn()), baseDNs);
+ initializeBackend(backend, cfg);
}
catch (Exception e)
{
@@ -1364,53 +1352,13 @@
}
}
- /**
- * Gets the configuration corresponding to a config entry.
- *
- * @param <S>
- * The type of server configuration.
- * @param definition
- * The required definition of the required managed object.
- * @param configEntry
- * A configuration entry.
- * @return Returns the server-side configuration.
- * @throws ConfigException
- * If the entry could not be decoded.
- */
- public static <S extends Configuration> S getConfiguration(
- AbstractManagedObjectDefinition<?, S> definition, ConfigEntry configEntry)
- throws ConfigException {
-
- try {
- ServerManagedObject<? extends S> mo = ServerManagedObject
- .decode(ManagedObjectPath.emptyPath(), definition,
- configEntry);
- return mo.getConfiguration();
- } catch (DefinitionDecodingException e) {
- throw ConfigExceptionFactory.getInstance()
- .createDecodingExceptionAdaptor(configEntry.getDN(), e);
- } catch (ServerManagedObjectDecodingException e) {
- throw ConfigExceptionFactory.getInstance()
- .createDecodingExceptionAdaptor(e);
- }
- }
-
-
-
- /**
- * Gets the backend configuration corresponding to a backend config entry.
- *
- * @param configEntry A backend config entry.
- * @return Returns the backend configuration.
- * @throws ConfigException If the config entry could not be decoded.
- */
- public static BackendCfg getBackendCfg(ConfigEntry configEntry)
- throws ConfigException
+ @SuppressWarnings("unchecked")
+ private static void initializeBackend(Backend backend, BackendCfg cfg)
+ throws ConfigException, InitializationException
{
- return getConfiguration(BackendCfgDefn.getInstance(), configEntry);
+ backend.configureBackend(cfg);
+ backend.initializeBackend();
}
-
-
}
diff --git a/opends/src/server/org/opends/server/core/DirectoryServer.java b/opends/src/server/org/opends/server/core/DirectoryServer.java
index 296bc41..eb2986c 100644
--- a/opends/src/server/org/opends/server/core/DirectoryServer.java
+++ b/opends/src/server/org/opends/server/core/DirectoryServer.java
@@ -48,8 +48,11 @@
import javax.management.MBeanServerFactory;
import org.opends.server.admin.ClassLoaderProvider;
+import org.opends.server.admin.server.ServerManagementContext;
import org.opends.server.admin.std.server.PasswordValidatorCfg;
import org.opends.server.admin.std.server.SynchronizationProviderCfg;
+import org.opends.server.admin.std.server.RootDSEBackendCfg;
+import org.opends.server.admin.std.server.RootCfg;
import org.opends.server.api.*;
import org.opends.server.api.plugin.PluginType;
import org.opends.server.api.plugin.StartupPluginResult;
@@ -2190,11 +2193,12 @@
// Make sure to initialize the root DSE backend separately after all other
// backends.
- ConfigEntry rootDSEConfigEntry;
+ RootDSEBackendCfg rootDSECfg;
try
{
- DN rootDSEConfigDN = DN.decode(DN_ROOT_DSE_CONFIG);
- rootDSEConfigEntry = configHandler.getConfigEntry(rootDSEConfigDN);
+ RootCfg root =
+ ServerManagementContext.getInstance().getRootConfiguration();
+ rootDSECfg = root.getRootDSEBackend();
}
catch (Exception e)
{
@@ -2208,9 +2212,9 @@
throw new InitializationException(msgID, message, e);
}
- DN[] baseDNs = { DN.nullDN() };
rootDSEBackend = new RootDSEBackend();
- rootDSEBackend.initializeBackend(rootDSEConfigEntry, baseDNs);
+ rootDSEBackend.configureBackend(rootDSECfg);
+ rootDSEBackend.initializeBackend();
}
diff --git a/opends/src/server/org/opends/server/extensions/ConfigFileHandler.java b/opends/src/server/org/opends/server/extensions/ConfigFileHandler.java
index 9e937d0..e3bf9a4 100644
--- a/opends/src/server/org/opends/server/extensions/ConfigFileHandler.java
+++ b/opends/src/server/org/opends/server/extensions/ConfigFileHandler.java
@@ -113,7 +113,7 @@
import static org.opends.server.messages.MessageHandler.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
-
+import org.opends.server.admin.Configuration;
/**
@@ -1095,24 +1095,18 @@
}
+ /**
+ * {@inheritDoc}
+ */
+ public void configureBackend(Configuration cfg) throws ConfigException
+ {
+ // No action is required.
+ }
/**
- * Initializes this backend based on the information in the provided
- * configuration entry.
- *
- * @param configEntry The configuration entry that contains the information
- * to use to initialize this backend.
- * @param baseDNs The set of base DNs that have been configured for this
- * backend.
- *
- * @throws ConfigException If an unrecoverable problem arises in the
- * process of performing the initialization.
- *
- * @throws InitializationException If a problem occurs during initialization
- * that is not related to the server
- * configuration.
+ * {@inheritDoc}
*/
- public void initializeBackend(ConfigEntry configEntry, DN[] baseDNs)
+ public void initializeBackend()
throws ConfigException, InitializationException
{
// No action is required, since all initialization was performed in the
@@ -2005,7 +1999,7 @@
new LDIFExportConfig(tempConfig, ExistingFileBehavior.OVERWRITE);
// FIXME -- Add all the appropriate configuration options.
- exportLDIF(configRootEntry, baseDNs, exportConfig);
+ writeLDIF(exportConfig);
}
catch (Exception e)
{
@@ -2245,24 +2239,20 @@
/**
- * Exports the contents of this backend to LDIF. This method should only be
- * called if <CODE>supportsLDIFExport</CODE> returns <CODE>true</CODE>. Note
- * that the server will not explicitly initialize this backend before calling
- * this method.
- *
- * @param configEntry The configuration entry for this backend.
- * @param baseDNs The set of base DNs configured for this backend.
- * @param exportConfig The configuration to use when performing the export.
- *
- * @throws DirectoryException If a problem occurs while performing the LDIF
- * export.
+ * {@inheritDoc}
*/
- public void exportLDIF(ConfigEntry configEntry, DN[] baseDNs,
- LDIFExportConfig exportConfig)
+ public void exportLDIF(LDIFExportConfig exportConfig)
throws DirectoryException
{
// TODO We would need export-ldif to initialize this backend.
+ writeLDIF(exportConfig);
+ }
+
+
+ private void writeLDIF(LDIFExportConfig exportConfig)
+ throws DirectoryException
+ {
LDIFWriter writer;
try
{
@@ -2366,20 +2356,9 @@
/**
- * Imports information from an LDIF file into this backend. This method
- * should only be called if <CODE>supportsLDIFImport</CODE> returns
- * <CODE>true</CODE>. Note that the server will not explicitly initialize
- * this backend before calling this method.
- *
- * @param configEntry The configuration entry for this backend.
- * @param baseDNs The set of base DNs configured for this backend.
- * @param importConfig The configuration to use when performing the import.
- *
- * @throws DirectoryException If a problem occurs while performing the LDIF
- * import.
+ * {@inheritDoc}
*/
- public void importLDIF(ConfigEntry configEntry, DN[] baseDNs,
- LDIFImportConfig importConfig)
+ public void importLDIF(LDIFImportConfig importConfig)
throws DirectoryException
{
int msgID = MSGID_CONFIG_FILE_UNWILLING_TO_IMPORT;
@@ -2437,19 +2416,9 @@
/**
- * Creates a backup of the contents of this backend in a form that may be
- * restored at a later date if necessary. This method should only be called
- * if <CODE>supportsBackup</CODE> returns <CODE>true</CODE>. Note that the
- * server will not explicitly initialize this backend before calling this
- * method.
- *
- * @param configEntry The configuration entry for this backend.
- * @param backupConfig The configuration to use when performing the backup.
- *
- * @throws DirectoryException If a problem occurs while performing the
- * backup.
+ * {@inheritDoc}
*/
- public void createBackup(ConfigEntry configEntry, BackupConfig backupConfig)
+ public void createBackup(BackupConfig backupConfig)
throws DirectoryException
{
// Get the properties to use for the backup. We don't care whether or not
@@ -2881,20 +2850,9 @@
/**
- * Restores a backup of the contents of this backend. This method should only
- * be called if <CODE>supportsRestore</CODE> returns <CODE>true</CODE>. Note
- * that the server will not explicitly initialize this backend before calling
- * this method.
- *
- * @param configEntry The configuration entry for this backend.
- * @param restoreConfig The configuration to use when performing the
- * restore.
- *
- * @throws DirectoryException If a problem occurs while performing the
- * restore.
+ * {@inheritDoc}
*/
- public void restoreBackup(ConfigEntry configEntry,
- RestoreConfig restoreConfig)
+ public void restoreBackup(RestoreConfig restoreConfig)
throws DirectoryException
{
// First, make sure that the requested backup exists.
diff --git a/opends/src/server/org/opends/server/messages/JebMessages.java b/opends/src/server/org/opends/server/messages/JebMessages.java
index 037ddaa..ca73563 100644
--- a/opends/src/server/org/opends/server/messages/JebMessages.java
+++ b/opends/src/server/org/opends/server/messages/JebMessages.java
@@ -289,8 +289,8 @@
/**
* The message ID of an informational message indicating that a JE backend
* instance has started, and providing the current number of entries
- * stored in the backend. This message takes one argument which is the
- * current number of entries stored in the backend.
+ * stored in the backend. This message takes two arguments which are the
+ * backend ID and the current number of entries stored in the backend.
*/
public static final int MSGID_JEB_BACKEND_STARTED =
CATEGORY_MASK_JEB | SEVERITY_MASK_NOTICE | 42;
@@ -1239,7 +1239,8 @@
registerMessage(MSGID_JEB_IO_ERROR,
"I/O error during backend operation: %s");
registerMessage(MSGID_JEB_BACKEND_STARTED,
- "A database backend containing %d entries has started");
+ "The database backend %s containing %d entries has " +
+ "started");
registerMessage(MSGID_JEB_IMPORT_PARENT_NOT_FOUND,
"The parent entry '%s' does not exist");
registerMessage(MSGID_JEB_IMPORT_ENTRY_EXISTS,
diff --git a/opends/src/server/org/opends/server/messages/ToolMessages.java b/opends/src/server/org/opends/server/messages/ToolMessages.java
index e43ace7..eaf42e8 100644
--- a/opends/src/server/org/opends/server/messages/ToolMessages.java
+++ b/opends/src/server/org/opends/server/messages/ToolMessages.java
@@ -1827,7 +1827,7 @@
/**
* The message ID for the message that will be used if the backend selected
* for an LDIF import does not support that operation. This takes a single
- * argument, which is the requested base DN.
+ * argument, which is the requested backend ID.
*/
public static final int MSGID_LDIFIMPORT_CANNOT_IMPORT =
CATEGORY_MASK_TOOLS | SEVERITY_MASK_SEVERE_ERROR | 214;
diff --git a/opends/src/server/org/opends/server/replication/plugin/ReplicationDomain.java b/opends/src/server/org/opends/server/replication/plugin/ReplicationDomain.java
index 93d7ba1..5c811fd 100644
--- a/opends/src/server/org/opends/server/replication/plugin/ReplicationDomain.java
+++ b/opends/src/server/org/opends/server/replication/plugin/ReplicationDomain.java
@@ -26,14 +26,10 @@
*/
package org.opends.server.replication.plugin;
-import static org.opends.server.config.ConfigConstants.ATTR_BACKEND_BASE_DN;
-import static org.opends.server.config.ConfigConstants.ATTR_BACKEND_CLASS;
-import static org.opends.server.config.ConfigConstants.ATTR_BACKEND_ID;
import static org.opends.server.config.ConfigConstants.DN_BACKEND_BASE;
import static org.opends.server.loggers.ErrorLogger.logError;
import static org.opends.server.loggers.debug.DebugLogger.debugEnabled;
import static org.opends.server.loggers.debug.DebugLogger.debugInfo;
-import static org.opends.server.messages.ConfigMessages.*;
import static org.opends.server.messages.MessageHandler.getMessage;
import static org.opends.server.messages.ToolMessages.*;
import static org.opends.server.messages.ReplicationMessages.*;
@@ -57,16 +53,14 @@
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.server.MultimasterDomainCfg;
+import org.opends.server.admin.std.server.BackendCfg;
import org.opends.server.api.Backend;
import org.opends.server.api.DirectoryThread;
import org.opends.server.api.SynchronizationProvider;
import org.opends.server.backends.jeb.BackendImpl;
import org.opends.server.backends.task.Task;
import org.opends.server.backends.task.TaskState;
-import org.opends.server.config.ConfigEntry;
import org.opends.server.config.ConfigException;
-import org.opends.server.config.DNConfigAttribute;
-import org.opends.server.config.StringConfigAttribute;
import org.opends.server.core.AddOperation;
import org.opends.server.core.DeleteOperation;
import org.opends.server.core.DirectoryServer;
@@ -251,9 +245,8 @@
// Null when none is being processed.
private IEContext ieContext = null;
- // The backend informations necessary to make an import or export.
+ // The backend information necessary to make an import or export.
private Backend backend;
- private ConfigEntry backendConfigEntry;
private List<DN> branches = new ArrayList<DN>(0);
private int listenerThreadNumber = 10;
@@ -1859,13 +1852,9 @@
String dn) throws Exception
{
BackendImpl backend = (BackendImpl)DirectoryServer.getBackend(beID);
- DN[] baseDNs = backend.getBaseDNs();
-
- // FIXME Should getConfigEntry be part of TaskUtils ?
- ConfigEntry configEntry = TaskUtils.getConfigEntry(backend);
// FIXME Should setBackendEnabled be part of TaskUtils ?
- TaskUtils.setBackendEnabled(configEntry, false);
+ TaskUtils.disableBackend(beID);
try
{
@@ -1879,7 +1868,7 @@
try
{
- backend.clearBackend(configEntry, baseDNs);
+ backend.clearBackend();
}
finally
{
@@ -1888,7 +1877,7 @@
}
finally
{
- TaskUtils.setBackendEnabled(configEntry, true);
+ TaskUtils.enableBackend(beID);
}
if (createBaseEntry)
@@ -1951,12 +1940,14 @@
ReplLDIFOutputStream os = new ReplLDIFOutputStream(this);
LDIFExportConfig exportConfig = new LDIFExportConfig(os);
+ List<DN> includeBranches = new ArrayList<DN>(1);
+ includeBranches.add(this.baseDN);
+ exportConfig.setIncludeBranches(includeBranches);
// Launch the export.
try
{
- DN[] baseDNs = {this.baseDN};
- backend.exportLDIF(backendConfigEntry, baseDNs, exportConfig);
+ backend.exportLDIF(exportConfig);
}
catch (DirectoryException de)
{
@@ -2020,14 +2011,6 @@
*/
protected void retrievesBackendInfos(DN baseDN) throws DirectoryException
{
- ArrayList<Backend> backendList = new ArrayList<Backend>();
- ArrayList<ConfigEntry> entryList = new ArrayList<ConfigEntry>();
- ArrayList<List<DN>> dnList = new ArrayList<List<DN>>();
-
- Backend backend = null;
- ConfigEntry backendConfigEntry = null;
- List<DN> branches = new ArrayList<DN>(0);
-
// Retrieves the backend related to this domain
Backend domainBackend = DirectoryServer.getBackend(baseDN);
if (domainBackend == null)
@@ -2038,44 +2021,9 @@
ResultCode.OTHER, message, msgID, null);
}
- // Retrieves its config entry and its DNs
- int code = getBackends(backendList, entryList, dnList);
- if (code != 0)
- {
- int msgID = MSGID_CANNOT_DECODE_BASE_DN;
- String message = getMessage(msgID, DN_BACKEND_BASE);
- throw new DirectoryException(
- ResultCode.OTHER, message, msgID, null);
- }
-
- int numBackends = backendList.size();
- for (int i=0; i < numBackends; i++)
- {
- Backend b = backendList.get(i);
-
- if (domainBackend.getBackendID() != b.getBackendID())
- {
- continue;
- }
-
- if (backend == null)
- {
- backend = domainBackend;
- backendConfigEntry = entryList.get(i).duplicate();
- branches = dnList.get(i);
- }
- else
- {
- int msgID = MSGID_LDIFIMPORT_MULTIPLE_BACKENDS_FOR_ID;
- String message = getMessage(msgID, domainBackend.getBackendID());
- logError(ErrorLogCategory.BACKEND, ErrorLogSeverity.SEVERE_ERROR,
- message, msgID);
- throw new DirectoryException(
- ResultCode.OTHER, message, msgID, null);
- }
- }
-
- if (backend == null)
+ // Retrieves its configuration
+ BackendCfg backendCfg = TaskUtils.getConfigEntry(domainBackend);
+ if (backendCfg == null)
{
int msgID = MSGID_LDIFIMPORT_NO_BACKENDS_FOR_ID;
String message = getMessage(msgID, domainBackend.getBackendID());
@@ -2084,10 +2032,11 @@
throw new DirectoryException(
ResultCode.OTHER, message, msgID, null);
}
- else if (! backend.supportsLDIFExport())
+
+ if (! domainBackend.supportsLDIFExport())
{
int msgID = MSGID_LDIFIMPORT_CANNOT_IMPORT;
- String message = getMessage(msgID, 0); // FIXME
+ String message = getMessage(msgID, domainBackend.getBackendID());
logError(ErrorLogCategory.BACKEND,
ErrorLogSeverity.SEVERE_ERROR, message, msgID);
throw new DirectoryException(
@@ -2095,9 +2044,12 @@
}
- this.backend = backend;
- this.backendConfigEntry = backendConfigEntry;
- this.branches = branches;
+ this.backend = domainBackend;
+ this.branches = new ArrayList<DN>(backendCfg.getBackendBaseDN().size());
+ for (DN dn : backendCfg.getBackendBaseDN())
+ {
+ this.branches.add(dn);
+ }
}
@@ -2127,216 +2079,6 @@
}
/**
- * Retrieves information about the backends defined in the Directory Server
- * configuration.
- *
- * @param backendList A list into which instantiated (but not initialized)
- * backend instances will be placed.
- * @param entryList A list into which the config entries associated with
- * the backends will be placed.
- * @param dnList A list into which the set of base DNs for each backend
- * will be placed.
- */
- private static int getBackends(ArrayList<Backend> backendList,
- ArrayList<ConfigEntry> entryList,
- ArrayList<List<DN>> dnList)
- throws DirectoryException
- {
- // Get the base entry for all backend configuration.
- DN backendBaseDN = null;
- try
- {
- backendBaseDN = DN.decode(DN_BACKEND_BASE);
- }
- catch (DirectoryException de)
- {
- int msgID = MSGID_CANNOT_DECODE_BASE_DN;
- String message = getMessage(msgID, DN_BACKEND_BASE, de.getErrorMessage());
- throw new DirectoryException(
- ResultCode.OTHER, message, msgID, null);
- }
- catch (Exception e)
- {
- int msgID = MSGID_CANNOT_DECODE_BASE_DN;
- String message = getMessage(msgID, DN_BACKEND_BASE,
- stackTraceToSingleLineString(e));
- throw new DirectoryException(
- ResultCode.OTHER, message, msgID, null);
- }
-
- ConfigEntry baseEntry = null;
- try
- {
- baseEntry = DirectoryServer.getConfigEntry(backendBaseDN);
- }
- catch (ConfigException ce)
- {
- int msgID = MSGID_CANNOT_RETRIEVE_BACKEND_BASE_ENTRY;
- String message = getMessage(msgID, DN_BACKEND_BASE, ce.getMessage());
- throw new DirectoryException(
- ResultCode.OTHER, message, msgID, null);
- }
- catch (Exception e)
- {
- int msgID = MSGID_CANNOT_RETRIEVE_BACKEND_BASE_ENTRY;
- String message = getMessage(msgID, DN_BACKEND_BASE,
- stackTraceToSingleLineString(e));
- throw new DirectoryException(
- ResultCode.OTHER, message, msgID, null);
- }
-
-
- // Iterate through the immediate children, attempting to parse them as
- // backends.
- for (ConfigEntry configEntry : baseEntry.getChildren().values())
- {
- // Get the backend ID attribute from the entry. If there isn't one, then
- // skip the entry.
- String backendID = null;
- try
- {
- int msgID = MSGID_CONFIG_BACKEND_ATTR_DESCRIPTION_BACKEND_ID;
- StringConfigAttribute idStub =
- new StringConfigAttribute(ATTR_BACKEND_ID, getMessage(msgID),
- true, false, true);
- StringConfigAttribute idAttr =
- (StringConfigAttribute) configEntry.getConfigAttribute(idStub);
- if (idAttr == null)
- {
- continue;
- }
- else
- {
- backendID = idAttr.activeValue();
- }
- }
- catch (ConfigException ce)
- {
- int msgID = MSGID_CANNOT_DETERMINE_BACKEND_ID;
- String message = getMessage(msgID, String.valueOf(configEntry.getDN()),
- ce.getMessage());
- throw new DirectoryException(
- ResultCode.OTHER, message, msgID, null);
- }
- catch (Exception e)
- {
- int msgID = MSGID_CANNOT_DETERMINE_BACKEND_ID;
- String message = getMessage(msgID, String.valueOf(configEntry.getDN()),
- stackTraceToSingleLineString(e));
- throw new DirectoryException(
- ResultCode.OTHER, message, msgID, null);
- }
-
-
- // Get the backend class name attribute from the entry. If there isn't
- // one, then just skip the entry.
- String backendClassName = null;
- try
- {
- int msgID = MSGID_CONFIG_BACKEND_ATTR_DESCRIPTION_CLASS;
- StringConfigAttribute classStub =
- new StringConfigAttribute(ATTR_BACKEND_CLASS, getMessage(msgID),
- true, false, false);
- StringConfigAttribute classAttr =
- (StringConfigAttribute) configEntry.getConfigAttribute(classStub);
- if (classAttr == null)
- {
- continue;
- }
- else
- {
- backendClassName = classAttr.activeValue();
- }
- }
- catch (ConfigException ce)
- {
- int msgID = MSGID_CANNOT_DETERMINE_BACKEND_CLASS;
- String message = getMessage(msgID, String.valueOf(configEntry.getDN()),
- ce.getMessage());
- throw new DirectoryException(
- ResultCode.OTHER, message, msgID, null);
- }
- catch (Exception e)
- {
- int msgID = MSGID_CANNOT_DETERMINE_BACKEND_CLASS;
- String message = getMessage(msgID, String.valueOf(configEntry.getDN()),
- stackTraceToSingleLineString(e));
- throw new DirectoryException(
- ResultCode.OTHER, message, msgID, null);
- }
-
- Class backendClass = null;
- try
- {
- backendClass = Class.forName(backendClassName);
- }
- catch (Exception e)
- {
- int msgID = MSGID_CANNOT_LOAD_BACKEND_CLASS;
- String message = getMessage(msgID, backendClassName,
- String.valueOf(configEntry.getDN()),
- stackTraceToSingleLineString(e));
- throw new DirectoryException(
- ResultCode.OTHER, message, msgID, null);
- }
-
- Backend backend = null;
- try
- {
- backend = (Backend) backendClass.newInstance();
- backend.setBackendID(backendID);
- }
- catch (Exception e)
- {
- int msgID = MSGID_CANNOT_INSTANTIATE_BACKEND_CLASS;
- String message = getMessage(msgID, backendClassName,
- String.valueOf(configEntry.getDN()),
- stackTraceToSingleLineString(e));
- throw new DirectoryException(
- ResultCode.OTHER, message, msgID, null); }
-
-
- // Get the base DN attribute from the entry. If there isn't one, then
- // just skip this entry.
- List<DN> baseDNs = null;
- try
- {
- int msgID = MSGID_CONFIG_BACKEND_ATTR_DESCRIPTION_BASE_DNS;
- DNConfigAttribute baseDNStub =
- new DNConfigAttribute(ATTR_BACKEND_BASE_DN, getMessage(msgID),
- true, true, true);
- DNConfigAttribute baseDNAttr =
- (DNConfigAttribute) configEntry.getConfigAttribute(baseDNStub);
- if (baseDNAttr == null)
- {
- msgID = MSGID_NO_BASES_FOR_BACKEND;
- String message = getMessage(msgID,
- String.valueOf(configEntry.getDN()));
- throw new DirectoryException(
- DirectoryServer.getServerErrorResultCode(), message,msgID, null);
- }
- else
- {
- baseDNs = baseDNAttr.activeValues();
- }
- }
- catch (Exception e)
- {
- int msgID = MSGID_CANNOT_DETERMINE_BASES_FOR_BACKEND;
- String message = getMessage(msgID, String.valueOf(configEntry.getDN()),
- stackTraceToSingleLineString(e));
- throw new DirectoryException(
- ResultCode.OTHER, message, msgID, null); }
-
-
- backendList.add(backend);
- entryList.add(configEntry);
- dnList.add(baseDNs);
- }
- return 0;
- }
-
- /**
* Initializes this domain from another source server.
*
* @param source The source from which to initialize
@@ -2526,11 +2268,9 @@
/**
* Process backend before import.
* @param backend The backend.
- * @param backendConfigEntry The config entry of the backend.
* @throws Exception
*/
- private void preBackendImport(Backend backend,
- ConfigEntry backendConfigEntry)
+ private void preBackendImport(Backend backend)
throws Exception
{
// Stop saving state
@@ -2540,7 +2280,7 @@
clearJEBackend(false,backend.getBackendID(),null);
// FIXME setBackendEnabled should be part of TaskUtils ?
- TaskUtils.setBackendEnabled(backendConfigEntry, false);
+ TaskUtils.disableBackend(backend.getBackendID());
// Acquire an exclusive lock for the backend.
String lockFile = LockFileManager.getBackendLockFileName(backend);
@@ -2583,9 +2323,8 @@
ieContext.entryLeftCount = initializeMessage.getEntryCount();
ieContext.initTaskCounters(initializeMessage.getEntryCount());
- preBackendImport(this.backend, this.backendConfigEntry);
+ preBackendImport(this.backend);
- DN[] baseDNs = {baseDN};
ieContext.ldifImportInputStream = new ReplLDIFInputStream(this);
importConfig =
new LDIFImportConfig(ieContext.ldifImportInputStream);
@@ -2596,7 +2335,7 @@
// ExistingFileBehavior.OVERWRITE);
// Process import
- this.backend.importLDIF(this.backendConfigEntry, baseDNs, importConfig);
+ this.backend.importLDIF(importConfig);
stateSavingDisabled = false;
@@ -2616,7 +2355,7 @@
importConfig.close();
// Re-enable backend
- closeBackendImport(this.backend, this.backendConfigEntry);
+ closeBackendImport(this.backend);
// Update the task that initiated the import
if ((ieContext != null ) && (ieContext.initializeTask != null))
@@ -2635,11 +2374,9 @@
/**
* Make post import operations.
* @param backend The backend implied in the import.
- * @param backendConfigEntry The config entry of the backend.
* @exception DirectoryException Thrown when an error occurs.
*/
- protected void closeBackendImport(Backend backend,
- ConfigEntry backendConfigEntry)
+ protected void closeBackendImport(Backend backend)
throws DirectoryException
{
String lockFile = LockFileManager.getBackendLockFileName(backend);
@@ -2657,7 +2394,7 @@
}
// FIXME setBackendEnabled should be part taskUtils ?
- TaskUtils.setBackendEnabled(backendConfigEntry, true);
+ TaskUtils.enableBackend(backend.getBackendID());
}
/**
diff --git a/opends/src/server/org/opends/server/tasks/BackupTask.java b/opends/src/server/org/opends/server/tasks/BackupTask.java
index d1bd7a2..00c80f8 100644
--- a/opends/src/server/org/opends/server/tasks/BackupTask.java
+++ b/opends/src/server/org/opends/server/tasks/BackupTask.java
@@ -32,7 +32,6 @@
import static org.opends.server.messages.ToolMessages.*;
import static org.opends.server.messages.MessageHandler.getMessage;
import static org.opends.server.util.ServerConstants.DATE_FORMAT_GMT_TIME;
-import static org.opends.server.loggers.ErrorLogger.logError;
import static org.opends.server.util.StaticUtils.*;
import static org.opends.server.util.ServerConstants.
BACKUP_DIRECTORY_DESCRIPTOR_FILE;
@@ -56,6 +55,7 @@
import org.opends.server.types.Operation;
import org.opends.server.types.Privilege;
import org.opends.server.types.ResultCode;
+import org.opends.server.admin.std.server.BackendCfg;
import java.util.ArrayList;
import java.util.Date;
@@ -358,7 +358,7 @@
private boolean backupBackend(Backend b, File backupLocation)
{
// Get the config entry for this backend.
- ConfigEntry configEntry = configEntries.get(b.getBackendID());
+ BackendCfg cfg = TaskUtils.getConfigEntry(b);
// If the directory doesn't exist, then create it. If it does exist, then
@@ -396,8 +396,7 @@
}
else
{
- backupDir = new BackupDirectory(backupLocation.getPath(),
- configEntry.getDN());
+ backupDir = new BackupDirectory(backupLocation.getPath(), cfg.dn());
}
}
else
@@ -417,7 +416,7 @@
}
backupDir = new BackupDirectory(backupLocation.getPath(),
- configEntry.getDN());
+ cfg.dn());
}
@@ -435,7 +434,7 @@
try
{
DirectoryServer.notifyBackupBeginning(b, backupConfig);
- b.createBackup(configEntry, backupConfig);
+ b.createBackup(backupConfig);
DirectoryServer.notifyBackupEnded(b, backupConfig, true);
}
catch (DirectoryException de)
diff --git a/opends/src/server/org/opends/server/tasks/ExportTask.java b/opends/src/server/org/opends/server/tasks/ExportTask.java
index 1b6ebd6..cbb902c 100644
--- a/opends/src/server/org/opends/server/tasks/ExportTask.java
+++ b/opends/src/server/org/opends/server/tasks/ExportTask.java
@@ -32,14 +32,12 @@
import static org.opends.server.messages.ToolMessages.*;
import static org.opends.server.messages.MessageHandler.getMessage;
import static org.opends.server.util.StaticUtils.*;
-import static org.opends.server.loggers.ErrorLogger.logError;
import org.opends.server.backends.task.Task;
import org.opends.server.backends.task.TaskState;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.LockFileManager;
import org.opends.server.api.Backend;
import org.opends.server.api.ClientConnection;
-import org.opends.server.config.ConfigEntry;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.DirectoryException;
@@ -311,7 +309,6 @@
// Get the backend into which the LDIF should be imported.
Backend backend;
- ConfigEntry configEntry;
ArrayList<DN> defaultIncludeBranches;
backend = DirectoryServer.getBackend(backendID);
@@ -333,9 +330,6 @@
return TaskState.STOPPED_BY_ERROR;
}
- // Get the config entry for this backend.
- configEntry = TaskUtils.getConfigEntry(backend);
-
defaultIncludeBranches = new ArrayList<DN>(backend.getBaseDNs().length);
for (DN dn : backend.getBaseDNs())
{
@@ -347,7 +341,7 @@
{
for (String s : excludeBranchStrings)
{
- DN excludeBranch = null;
+ DN excludeBranch;
try
{
excludeBranch = DN.decode(s);
@@ -383,7 +377,7 @@
includeBranches = new ArrayList<DN>();
for (String s : includeBranchStrings)
{
- DN includeBranch = null;
+ DN includeBranch;
try
{
includeBranch = DN.decode(s);
@@ -493,7 +487,7 @@
try
{
DirectoryServer.notifyExportBeginning(backend, exportConfig);
- backend.exportLDIF(configEntry, baseDNs, exportConfig);
+ backend.exportLDIF(exportConfig);
DirectoryServer.notifyExportEnded(backend, exportConfig, true);
}
catch (DirectoryException de)
diff --git a/opends/src/server/org/opends/server/tasks/ImportTask.java b/opends/src/server/org/opends/server/tasks/ImportTask.java
index 1234638..c3e9a41 100644
--- a/opends/src/server/org/opends/server/tasks/ImportTask.java
+++ b/opends/src/server/org/opends/server/tasks/ImportTask.java
@@ -42,7 +42,6 @@
import org.opends.server.core.LockFileManager;
import org.opends.server.api.Backend;
import org.opends.server.api.ClientConnection;
-import org.opends.server.config.ConfigEntry;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.DirectoryException;
@@ -285,7 +284,6 @@
// Get the backend into which the LDIF should be imported.
Backend backend;
- ConfigEntry configEntry;
ArrayList<DN> defaultIncludeBranches;
ArrayList<DN> excludeBranches = new ArrayList<DN>();
@@ -308,9 +306,6 @@
return TaskState.STOPPED_BY_ERROR;
}
- // Get the config entry for this backend.
- configEntry = TaskUtils.getConfigEntry(backend);
-
// Find backends with subordinate base DNs that should be excluded from the
// import.
@@ -479,7 +474,7 @@
// Disable the backend.
try
{
- TaskUtils.setBackendEnabled(configEntry, false);
+ TaskUtils.disableBackend(backendID);
}
catch (DirectoryException e)
{
@@ -530,7 +525,7 @@
// Launch the import.
try
{
- backend.importLDIF(configEntry, baseDNs, importConfig);
+ backend.importLDIF(importConfig);
}
catch (DirectoryException de)
{
@@ -599,7 +594,7 @@
// Enable the backend.
try
{
- TaskUtils.setBackendEnabled(configEntry, true);
+ TaskUtils.enableBackend(backendID);
// It is necessary to retrieve the backend structure again
// because disabling and enabling it again may have resulted
// in a new backend being registered to the server.
diff --git a/opends/src/server/org/opends/server/tasks/RebuildTask.java b/opends/src/server/org/opends/server/tasks/RebuildTask.java
index 7423855b..4c9c9c7 100644
--- a/opends/src/server/org/opends/server/tasks/RebuildTask.java
+++ b/opends/src/server/org/opends/server/tasks/RebuildTask.java
@@ -45,7 +45,6 @@
import org.opends.server.core.LockFileManager;
import org.opends.server.api.ClientConnection;
import org.opends.server.api.Backend;
-import org.opends.server.config.ConfigEntry;
import static org.opends.server.core.DirectoryServer.getAttributeType;
import static org.opends.server.util.StaticUtils.*;
@@ -184,10 +183,6 @@
return TaskState.STOPPED_BY_ERROR;
}
- // Get the config entry for this backend.
- ConfigEntry configEntry = TaskUtils.getConfigEntry(backend);
- DN[] baseDNs = backend.getBaseDNs();
-
// Acquire a shared lock for the backend if we are rebuilding attribute
// indexes only. If we are rebuilding one or more system indexes, we have
// to aquire exclusive lock.
@@ -198,7 +193,7 @@
// Disable the backend.
try
{
- TaskUtils.setBackendEnabled(configEntry, false);
+ TaskUtils.disableBackend(backend.getBackendID());
}
catch (DirectoryException e)
{
@@ -265,7 +260,7 @@
try
{
BackendImpl jebBackend = (BackendImpl)backend;
- jebBackend.rebuildBackend(rebuildConfig, configEntry, baseDNs);
+ jebBackend.rebuildBackend(rebuildConfig);
}
catch (Exception e)
{
@@ -311,7 +306,7 @@
// Enable the backend.
try
{
- TaskUtils.setBackendEnabled(configEntry, true);
+ TaskUtils.enableBackend(backend.getBackendID());
}
catch (DirectoryException e)
{
diff --git a/opends/src/server/org/opends/server/tasks/RestoreTask.java b/opends/src/server/org/opends/server/tasks/RestoreTask.java
index 1683058..672b48d 100644
--- a/opends/src/server/org/opends/server/tasks/RestoreTask.java
+++ b/opends/src/server/org/opends/server/tasks/RestoreTask.java
@@ -250,10 +250,10 @@
// Get the DN of the backend configuration entry from the backup.
DN configEntryDN = backupDir.getConfigEntryDN();
- // Get the backend configuration entry.
ConfigEntry configEntry;
try
{
+ // Get the backend configuration entry.
configEntry = DirectoryServer.getConfigEntry(configEntryDN);
}
catch (ConfigException e)
@@ -298,7 +298,7 @@
// Disable the backend.
try
{
- TaskUtils.setBackendEnabled(configEntry, false);
+ TaskUtils.disableBackend(backendID);
}
catch (DirectoryException e)
{
@@ -325,7 +325,7 @@
// Perform the restore.
try
{
- backend.restoreBackup(configEntry, restoreConfig);
+ backend.restoreBackup(restoreConfig);
}
catch (DirectoryException de)
{
@@ -363,7 +363,7 @@
// Enable the backend.
try
{
- TaskUtils.setBackendEnabled(configEntry, true);
+ TaskUtils.enableBackend(backendID);
// it is necessary to retrieve the backend structure again
// because disabling and enabling it again may have resulted
// in a new backend being registered to the server.
diff --git a/opends/src/server/org/opends/server/tasks/TaskUtils.java b/opends/src/server/org/opends/server/tasks/TaskUtils.java
index 5208d12..a4caaa1 100644
--- a/opends/src/server/org/opends/server/tasks/TaskUtils.java
+++ b/opends/src/server/org/opends/server/tasks/TaskUtils.java
@@ -57,6 +57,9 @@
import org.opends.server.types.ModificationType;
import org.opends.server.types.RawModification;
import org.opends.server.types.ResultCode;
+import org.opends.server.admin.std.server.BackendCfg;
+import org.opends.server.admin.std.server.RootCfg;
+import org.opends.server.admin.server.ServerManagementContext;
import java.util.ArrayList;
import java.util.LinkedHashSet;
@@ -89,8 +92,7 @@
true, false, true);
StringConfigAttribute idAttr =
(StringConfigAttribute) configEntry.getConfigAttribute(idStub);
- String backendID = idAttr.activeValue();
- return backendID;
+ return idAttr.activeValue();
}
catch (ConfigException ce)
{
@@ -126,7 +128,7 @@
// FIXME The error messages should not be the LDIF import messages
// Get the base entry for all backend configuration.
- DN backendBaseDN = null;
+ DN backendBaseDN;
try
{
backendBaseDN = DN.decode(DN_BACKEND_BASE);
@@ -151,7 +153,7 @@
return configEntries;
}
- ConfigEntry baseEntry = null;
+ ConfigEntry baseEntry;
try
{
baseEntry = DirectoryServer.getConfigEntry(backendBaseDN);
@@ -183,7 +185,7 @@
{
// Get the backend ID attribute from the entry. If there isn't one, then
// skip the entry.
- String backendID = null;
+ String backendID;
try
{
int msgID = MSGID_CONFIG_BACKEND_ATTR_DESCRIPTION_BACKEND_ID;
@@ -235,35 +237,47 @@
* @return The configuration entry of the backend, or null if it could not
* be found.
*/
- public static ConfigEntry getConfigEntry(Backend backend)
+ public static BackendCfg getConfigEntry(Backend backend)
{
- Map<String,ConfigEntry> configEntries = getBackendConfigEntries();
- return configEntries.get(backend.getBackendID());
+ RootCfg root = ServerManagementContext.getInstance().
+ getRootConfiguration();
+ try
+ {
+ return root.getBackend(backend.getBackendID());
+ }
+ catch (ConfigException e)
+ {
+ return null;
+ }
}
/**
- * Enable or disable a backend using an internal modify operation on the
+ * Enables a backend using an internal modify operation on the
* backend configuration entry.
*
- * @param configEntry The configuration entry of the backend to be enabled
- * or disabled.
- * @param enable Specifies whether the backend should be enabled or disabled.
+ * @param backendID Identifies the backend to be enabled.
* @throws DirectoryException If the internal modify operation failed.
*/
- public static void setBackendEnabled(ConfigEntry configEntry, boolean enable)
+ public static void enableBackend(String backendID)
throws DirectoryException
{
+ DN configEntryDN;
+ RootCfg root = ServerManagementContext.getInstance().getRootConfiguration();
+ try
+ {
+ BackendCfg cfg = root.getBackend(backendID);
+ configEntryDN = cfg.dn();
+ }
+ catch (ConfigException e)
+ {
+ throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
+ e.getMessage(), e.getMessageID(), e);
+ }
+
ArrayList<ASN1OctetString> valueList = new ArrayList<ASN1OctetString>(1);
- if (enable)
- {
- valueList.add(new ASN1OctetString("TRUE"));
- }
- else
- {
- valueList.add(new ASN1OctetString("FALSE"));
- }
+ valueList.add(new ASN1OctetString("TRUE"));
LDAPAttribute a = new LDAPAttribute(ATTR_BACKEND_ENABLED, valueList);
LDAPModification m = new LDAPModification(ModificationType.REPLACE, a);
@@ -273,7 +287,7 @@
InternalClientConnection conn =
InternalClientConnection.getRootConnection();
- String backendDNString = configEntry.getDN().toString();
+ String backendDNString = configEntryDN.toString();
ASN1OctetString rawEntryDN =
new ASN1OctetString(backendDNString);
ModifyOperation internalModify = conn.processModify(rawEntryDN, modList);
@@ -282,14 +296,58 @@
if (resultCode != ResultCode.SUCCESS)
{
int msgID;
- if (enable)
- {
- msgID = TaskMessages.MSGID_TASK_CANNOT_ENABLE_BACKEND;
- }
- else
- {
- msgID = TaskMessages.MSGID_TASK_CANNOT_DISABLE_BACKEND;
- }
+ msgID = TaskMessages.MSGID_TASK_CANNOT_ENABLE_BACKEND;
+ String message = getMessage(msgID, backendDNString);
+ throw new DirectoryException(resultCode, message, msgID);
+ }
+ }
+
+
+
+ /**
+ * Disables a backend using an internal modify operation on the
+ * backend configuration entry.
+ *
+ * @param backendID Identifies the backend to be disabled.
+ * @throws DirectoryException If the internal modify operation failed.
+ */
+ public static void disableBackend(String backendID)
+ throws DirectoryException
+ {
+ DN configEntryDN;
+ RootCfg root = ServerManagementContext.getInstance().getRootConfiguration();
+ try
+ {
+ BackendCfg cfg = root.getBackend(backendID);
+ configEntryDN = cfg.dn();
+ }
+ catch (ConfigException e)
+ {
+ throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
+ e.getMessage(), e.getMessageID(), e);
+ }
+
+ ArrayList<ASN1OctetString> valueList = new ArrayList<ASN1OctetString>(1);
+ valueList.add(new ASN1OctetString("FALSE"));
+ LDAPAttribute a = new LDAPAttribute(ATTR_BACKEND_ENABLED, valueList);
+
+ LDAPModification m = new LDAPModification(ModificationType.REPLACE, a);
+
+ ArrayList<RawModification> modList = new ArrayList<RawModification>(1);
+ modList.add(m);
+
+ InternalClientConnection conn =
+ InternalClientConnection.getRootConnection();
+ String backendDNString = configEntryDN.toString();
+ ASN1OctetString rawEntryDN =
+ new ASN1OctetString(backendDNString);
+ ModifyOperation internalModify = conn.processModify(rawEntryDN, modList);
+
+ ResultCode resultCode = internalModify.getResultCode();
+ if (resultCode != ResultCode.SUCCESS)
+ {
+ int msgID;
+ msgID = TaskMessages.MSGID_TASK_CANNOT_DISABLE_BACKEND;
String message = getMessage(msgID, backendDNString);
throw new DirectoryException(resultCode, message, msgID);
}
diff --git a/opends/src/server/org/opends/server/tools/BackUpDB.java b/opends/src/server/org/opends/server/tools/BackUpDB.java
index c80462a..e72074d 100644
--- a/opends/src/server/org/opends/server/tools/BackUpDB.java
+++ b/opends/src/server/org/opends/server/tools/BackUpDB.java
@@ -38,7 +38,6 @@
import java.util.TimeZone;
import org.opends.server.api.Backend;
-import org.opends.server.config.ConfigEntry;
import org.opends.server.config.ConfigException;
import org.opends.server.core.CoreConfigManager;
import org.opends.server.core.DirectoryServer;
@@ -66,7 +65,7 @@
import static org.opends.server.util.StaticUtils.*;
import org.opends.server.util.StaticUtils;
import static org.opends.server.tools.ToolConstants.*;
-
+import org.opends.server.admin.std.server.BackendCfg;
/**
@@ -366,8 +365,8 @@
{
try
{
- directoryServer.bootstrapClient();
- directoryServer.initializeJMX();
+ DirectoryServer.bootstrapClient();
+ DirectoryServer.initializeJMX();
}
catch (Exception e)
{
@@ -506,15 +505,15 @@
// Get information about the backends defined in the server, and determine
// whether we are backing up multiple backends or a single backend.
ArrayList<Backend> backendList = new ArrayList<Backend>();
- ArrayList<ConfigEntry> entryList = new ArrayList<ConfigEntry>();
+ ArrayList<BackendCfg> entryList = new ArrayList<BackendCfg>();
ArrayList<List<DN>> dnList = new ArrayList<List<DN>>();
BackendToolUtils.getBackends(backendList, entryList, dnList);
int numBackends = backendList.size();
boolean multiple;
ArrayList<Backend> backendsToArchive = new ArrayList<Backend>(numBackends);
- HashMap<String,ConfigEntry> configEntries =
- new HashMap<String,ConfigEntry>(numBackends);
+ HashMap<String,BackendCfg> configEntries =
+ new HashMap<String,BackendCfg>(numBackends);
if (backUpAll.isPresent())
{
for (int i=0; i < numBackends; i++)
@@ -629,7 +628,7 @@
// Get the config entry for this backend.
- ConfigEntry configEntry = configEntries.get(b.getBackendID());
+ BackendCfg configEntry = configEntries.get(b.getBackendID());
// Get the path to the directory to use for this backup. If we will be
@@ -650,7 +649,7 @@
// If the directory doesn't exist, then create it. If it does exist, then
// see if it has a backup descriptor file.
- BackupDirectory backupDir = null;
+ BackupDirectory backupDir;
backupDirFile = new File(backupDirPath);
if (backupDirFile.exists())
{
@@ -731,7 +730,7 @@
}
else
{
- backupDir = new BackupDirectory(backupDirPath, configEntry.getDN());
+ backupDir = new BackupDirectory(backupDirPath, configEntry.dn());
}
}
else
@@ -773,7 +772,7 @@
continue;
}
- backupDir = new BackupDirectory(backupDirPath, configEntry.getDN());
+ backupDir = new BackupDirectory(backupDirPath, configEntry.dn());
}
@@ -826,7 +825,7 @@
// Perform the backup.
try
{
- b.createBackup(configEntry, backupConfig);
+ b.createBackup(backupConfig);
}
catch (DirectoryException de)
{
diff --git a/opends/src/server/org/opends/server/tools/BackendToolUtils.java b/opends/src/server/org/opends/server/tools/BackendToolUtils.java
index cfb0214..0965381 100644
--- a/opends/src/server/org/opends/server/tools/BackendToolUtils.java
+++ b/opends/src/server/org/opends/server/tools/BackendToolUtils.java
@@ -43,6 +43,9 @@
import static org.opends.server.messages.ConfigMessages.*;
import static org.opends.server.loggers.ErrorLogger.*;
import static org.opends.server.util.StaticUtils.*;
+import org.opends.server.admin.std.server.BackendCfg;
+import org.opends.server.admin.std.server.RootCfg;
+import org.opends.server.admin.server.ServerManagementContext;
import java.util.ArrayList;
import java.util.List;
@@ -66,12 +69,13 @@
* @return 0 if everything went fine. 1 if an error occurred.
*
*/
+ @SuppressWarnings("unchecked")
public static int getBackends(ArrayList<Backend> backendList,
- ArrayList<ConfigEntry> entryList,
- ArrayList<List<DN>> dnList)
+ ArrayList<BackendCfg> entryList,
+ ArrayList<List<DN>> dnList)
{
// Get the base entry for all backend configuration.
- DN backendBaseDN = null;
+ DN backendBaseDN;
try
{
backendBaseDN = DN.decode(DN_BACKEND_BASE);
@@ -94,7 +98,7 @@
return 1;
}
- ConfigEntry baseEntry = null;
+ ConfigEntry baseEntry;
try
{
baseEntry = DirectoryServer.getConfigEntry(backendBaseDN);
@@ -120,11 +124,12 @@
// Iterate through the immediate children, attempting to parse them as
// backends.
+ RootCfg root = ServerManagementContext.getInstance().getRootConfiguration();
for (ConfigEntry configEntry : baseEntry.getChildren().values())
{
// Get the backend ID attribute from the entry. If there isn't one, then
// skip the entry.
- String backendID = null;
+ String backendID;
try
{
int msgID = MSGID_CONFIG_BACKEND_ATTR_DESCRIPTION_BACKEND_ID;
@@ -164,7 +169,7 @@
// Get the backend class name attribute from the entry. If there isn't
// one, then just skip the entry.
- String backendClassName = null;
+ String backendClassName;
try
{
int msgID = MSGID_CONFIG_BACKEND_ATTR_DESCRIPTION_CLASS;
@@ -201,7 +206,7 @@
return 1;
}
- Class backendClass = null;
+ Class backendClass;
try
{
backendClass = Class.forName(backendClassName);
@@ -217,11 +222,14 @@
return 1;
}
- Backend backend = null;
+ Backend backend;
+ BackendCfg cfg;
try
{
backend = (Backend) backendClass.newInstance();
backend.setBackendID(backendID);
+ cfg = root.getBackend(backendID);
+ backend.configureBackend(cfg);
}
catch (Exception e)
{
@@ -271,7 +279,7 @@
backendList.add(backend);
- entryList.add(configEntry);
+ entryList.add(cfg);
dnList.add(baseDNs);
}
return 0;
diff --git a/opends/src/server/org/opends/server/tools/ExportLDIF.java b/opends/src/server/org/opends/server/tools/ExportLDIF.java
index d9eb6fd..b4bf59a 100644
--- a/opends/src/server/org/opends/server/tools/ExportLDIF.java
+++ b/opends/src/server/org/opends/server/tools/ExportLDIF.java
@@ -34,7 +34,6 @@
import org.opends.server.api.Backend;
import org.opends.server.api.plugin.PluginType;
-import org.opends.server.config.ConfigEntry;
import org.opends.server.config.ConfigException;
import org.opends.server.core.CoreConfigManager;
import org.opends.server.core.DirectoryServer;
@@ -65,7 +64,7 @@
import static org.opends.server.util.StaticUtils.*;
import org.opends.server.util.StaticUtils;
import static org.opends.server.tools.ToolConstants.*;
-
+import org.opends.server.admin.std.server.BackendCfg;
/**
@@ -312,8 +311,8 @@
{
try
{
- directoryServer.bootstrapClient();
- directoryServer.initializeJMX();
+ DirectoryServer.bootstrapClient();
+ DirectoryServer.initializeJMX();
}
catch (Exception e)
{
@@ -600,13 +599,12 @@
// and also finding backends with subordinate base DNs that should be
// excluded from the export.
Backend backend = null;
- ConfigEntry configEntry = null;
List<DN> baseDNList = null;
List<DN> defaultIncludeBranches = null;
ArrayList<DN> excludeBranches = null;
ArrayList<Backend> backendList = new ArrayList<Backend>();
- ArrayList<ConfigEntry> entryList = new ArrayList<ConfigEntry>();
+ ArrayList<BackendCfg> entryList = new ArrayList<BackendCfg>();
ArrayList<List<DN>> dnList = new ArrayList<List<DN>>();
BackendToolUtils.getBackends(backendList, entryList, dnList);
@@ -622,7 +620,6 @@
if (backend == null)
{
backend = b;
- configEntry = entryList.get(i);
baseDNList = dnList.get(i);
defaultIncludeBranches = dnList.get(i);
}
@@ -658,7 +655,7 @@
excludeBranches = new ArrayList<DN>();
for (String s : excludeBranchStrings.getValues())
{
- DN excludeBranch = null;
+ DN excludeBranch;
try
{
excludeBranch = DN.decode(s);
@@ -694,7 +691,7 @@
includeBranches = new ArrayList<DN>();
for (String s : includeBranchStrings.getValues())
{
- DN includeBranch = null;
+ DN includeBranch;
try
{
includeBranch = DN.decode(s);
@@ -811,7 +808,7 @@
// Launch the export.
try
{
- backend.exportLDIF(configEntry, baseDNs, exportConfig);
+ backend.exportLDIF(exportConfig);
}
catch (DirectoryException de)
{
diff --git a/opends/src/server/org/opends/server/tools/ImportLDIF.java b/opends/src/server/org/opends/server/tools/ImportLDIF.java
index 6648072..5eb0586 100644
--- a/opends/src/server/org/opends/server/tools/ImportLDIF.java
+++ b/opends/src/server/org/opends/server/tools/ImportLDIF.java
@@ -36,7 +36,6 @@
import org.opends.server.api.Backend;
import org.opends.server.api.plugin.PluginType;
-import org.opends.server.config.ConfigEntry;
import org.opends.server.config.ConfigException;
import org.opends.server.core.CoreConfigManager;
import org.opends.server.core.DirectoryServer;
@@ -69,7 +68,7 @@
import static org.opends.server.util.StaticUtils.*;
import org.opends.server.util.StaticUtils;
import static org.opends.server.tools.ToolConstants.*;
-
+import org.opends.server.admin.std.server.BackendCfg;
/**
@@ -720,12 +719,11 @@
// imported and finding backends with subordinate base DNs that should be
// excluded from the import.
Backend backend = null;
- ConfigEntry configEntry = null;
List<DN> defaultIncludeBranches = null;
List<DN> excludeBranches = new ArrayList<DN>();
ArrayList<Backend> backendList = new ArrayList<Backend>();
- ArrayList<ConfigEntry> entryList = new ArrayList<ConfigEntry>();
+ ArrayList<BackendCfg> entryList = new ArrayList<BackendCfg>();
ArrayList<List<DN>> dnList = new ArrayList<List<DN>>();
int code = BackendToolUtils.getBackends(backendList, entryList, dnList);
if (code != 0)
@@ -745,7 +743,6 @@
if (backend == null)
{
backend = b;
- configEntry = entryList.get(i);
defaultIncludeBranches = dnList.get(i);
}
else
@@ -797,7 +794,7 @@
for (String s : excludeBranchStrings.getValues())
{
- DN excludeBranch = null;
+ DN excludeBranch;
try
{
excludeBranch = DN.decode(s);
@@ -836,7 +833,7 @@
includeBranches = new ArrayList<DN>();
for (String s : includeBranchStrings.getValues())
{
- DN includeBranch = null;
+ DN includeBranch;
try
{
includeBranch = DN.decode(s);
@@ -1025,7 +1022,7 @@
int retCode = 0;
try
{
- backend.importLDIF(configEntry, baseDNs, importConfig);
+ backend.importLDIF(importConfig);
}
catch (DirectoryException de)
{
diff --git a/opends/src/server/org/opends/server/tools/RebuildIndex.java b/opends/src/server/org/opends/server/tools/RebuildIndex.java
index a9c5a3d..e609d96 100644
--- a/opends/src/server/org/opends/server/tools/RebuildIndex.java
+++ b/opends/src/server/org/opends/server/tools/RebuildIndex.java
@@ -35,7 +35,6 @@
import static org.opends.server.messages.ToolMessages.*;
import org.opends.server.config.ConfigException;
-import org.opends.server.config.ConfigEntry;
import static org.opends.server.loggers.ErrorLogger.logError;
import org.opends.server.loggers.ThreadFilterTextErrorLogPublisher;
import org.opends.server.loggers.TextWriter;
@@ -51,6 +50,7 @@
import org.opends.server.api.Backend;
import org.opends.server.backends.jeb.BackendImpl;
import org.opends.server.backends.jeb.RebuildConfig;
+import org.opends.server.admin.std.server.BackendCfg;
import java.util.ArrayList;
import java.util.List;
@@ -349,7 +349,7 @@
}
// Decode the base DN provided by the user.
- DN rebuildBaseDN = null;
+ DN rebuildBaseDN;
try
{
rebuildBaseDN = DN.decode(baseDNString.getValue());
@@ -375,11 +375,10 @@
// Get information about the backends defined in the server.
Backend backend = null;
- ConfigEntry configEntry = null;
- DN[] baseDNArray = null;
+ DN[] baseDNArray;
ArrayList<Backend> backendList = new ArrayList<Backend>();
- ArrayList<ConfigEntry> entryList = new ArrayList<ConfigEntry>();
+ ArrayList<BackendCfg> entryList = new ArrayList<BackendCfg>();
ArrayList<List<DN>> dnList = new ArrayList<List<DN>>();
int code = BackendToolUtils.getBackends(backendList, entryList, dnList);
@@ -387,7 +386,6 @@
for (int i=0; i < numBackends; i++)
{
Backend b = backendList.get(i);
- ConfigEntry entry = entryList.get(i);
List<DN> baseDNs = dnList.get(i);
for (DN baseDN : baseDNs)
@@ -397,7 +395,6 @@
if (backend == null)
{
backend = b;
- configEntry = entry;
baseDNArray = new DN[baseDNs.size()];
baseDNs.toArray(baseDNArray);
}
@@ -470,7 +467,7 @@
try
{
BackendImpl jebBackend = (BackendImpl)backend;
- jebBackend.rebuildBackend(rebuildConfig, configEntry, baseDNArray);
+ jebBackend.rebuildBackend(rebuildConfig);
}
catch (Exception e)
{
diff --git a/opends/src/server/org/opends/server/tools/RestoreDB.java b/opends/src/server/org/opends/server/tools/RestoreDB.java
index cb9798a..a8f0d6d 100644
--- a/opends/src/server/org/opends/server/tools/RestoreDB.java
+++ b/opends/src/server/org/opends/server/tools/RestoreDB.java
@@ -36,7 +36,6 @@
import java.util.List;
import org.opends.server.api.Backend;
-import org.opends.server.config.ConfigEntry;
import org.opends.server.config.ConfigException;
import org.opends.server.core.CoreConfigManager;
import org.opends.server.core.DirectoryServer;
@@ -65,7 +64,7 @@
import static org.opends.server.util.StaticUtils.*;
import org.opends.server.util.StaticUtils;
import static org.opends.server.tools.ToolConstants.*;
-
+import org.opends.server.admin.std.server.BackendCfg;
/**
@@ -231,8 +230,8 @@
{
try
{
- directoryServer.bootstrapClient();
- directoryServer.initializeJMX();
+ DirectoryServer.bootstrapClient();
+ DirectoryServer.initializeJMX();
}
catch (Exception e)
{
@@ -369,7 +368,7 @@
// Open the backup directory and make sure it is valid.
- BackupDirectory backupDir = null;
+ BackupDirectory backupDir;
try
{
backupDir = BackupDirectory.readBackupDirectoryDescriptor(
@@ -454,7 +453,7 @@
// If a backup ID was specified, then make sure it is valid. If none was
// provided, then choose the latest backup from the archive.
- String backupID = null;
+ String backupID;
if (backupIDString.isPresent())
{
backupID = backupIDString.getValue();
@@ -495,22 +494,20 @@
// Get information about the backends defined in the server and determine
// which to use for the restore.
ArrayList<Backend> backendList = new ArrayList<Backend>();
- ArrayList<ConfigEntry> entryList = new ArrayList<ConfigEntry>();
+ ArrayList<BackendCfg> entryList = new ArrayList<BackendCfg>();
ArrayList<List<DN>> dnList = new ArrayList<List<DN>>();
BackendToolUtils.getBackends(backendList, entryList, dnList);
Backend backend = null;
- ConfigEntry configEntry = null;
int numBackends = backendList.size();
for (int i=0; i < numBackends; i++)
{
Backend b = backendList.get(i);
- ConfigEntry e = entryList.get(i);
- if (e.getDN().equals(configEntryDN))
+ BackendCfg e = entryList.get(i);
+ if (e.dn().equals(configEntryDN))
{
backend = b;
- configEntry = e;
break;
}
}
@@ -568,7 +565,7 @@
// Perform the restore.
try
{
- backend.restoreBackup(configEntry, restoreConfig);
+ backend.restoreBackup(restoreConfig);
}
catch (DirectoryException de)
{
diff --git a/opends/src/server/org/opends/server/tools/VerifyIndex.java b/opends/src/server/org/opends/server/tools/VerifyIndex.java
index ceaecf4..4359a78 100644
--- a/opends/src/server/org/opends/server/tools/VerifyIndex.java
+++ b/opends/src/server/org/opends/server/tools/VerifyIndex.java
@@ -31,7 +31,6 @@
import org.opends.server.api.Backend;
import org.opends.server.backends.jeb.BackendImpl;
import org.opends.server.backends.jeb.VerifyConfig;
-import org.opends.server.config.ConfigEntry;
import org.opends.server.config.ConfigException;
import org.opends.server.core.CoreConfigManager;
import org.opends.server.core.DirectoryServer;
@@ -60,7 +59,7 @@
import static org.opends.server.util.StaticUtils.*;
import org.opends.server.util.StaticUtils;
import static org.opends.server.tools.ToolConstants.*;
-
+import org.opends.server.admin.std.server.BackendCfg;
/**
@@ -362,7 +361,7 @@
// Decode the base DN provided by the user.
- DN verifyBaseDN = null;
+ DN verifyBaseDN ;
try
{
verifyBaseDN = DN.decode(baseDNString.getValue());
@@ -390,11 +389,9 @@
// Get information about the backends defined in the server. Iterate
// through them, finding the one backend to be verified.
Backend backend = null;
- ConfigEntry configEntry = null;
- DN[] baseDNArray = null;
ArrayList<Backend> backendList = new ArrayList<Backend>();
- ArrayList<ConfigEntry> entryList = new ArrayList<ConfigEntry>();
+ ArrayList<BackendCfg> entryList = new ArrayList<BackendCfg>();
ArrayList<List<DN>> dnList = new ArrayList<List<DN>>();
BackendToolUtils.getBackends(backendList, entryList, dnList);
@@ -402,7 +399,6 @@
for (int i=0; i < numBackends; i++)
{
Backend b = backendList.get(i);
- ConfigEntry entry = entryList.get(i);
List<DN> baseDNs = dnList.get(i);
for (DN baseDN : baseDNs)
@@ -412,9 +408,6 @@
if (backend == null)
{
backend = b;
- configEntry = entry;
- baseDNArray = new DN[baseDNs.size()];
- baseDNs.toArray(baseDNArray);
}
else
{
@@ -496,7 +489,7 @@
try
{
BackendImpl jebBackend = (BackendImpl)backend;
- jebBackend.verifyBackend(verifyConfig, configEntry, baseDNArray, null);
+ jebBackend.verifyBackend(verifyConfig, null);
}
catch (Exception e)
{
diff --git a/opends/tests/unit-tests-testng/resource/config-changes.ldif b/opends/tests/unit-tests-testng/resource/config-changes.ldif
index d653288..dcf1d3d 100644
--- a/opends/tests/unit-tests-testng/resource/config-changes.ldif
+++ b/opends/tests/unit-tests-testng/resource/config-changes.ldif
@@ -523,7 +523,7 @@
objectClass: ds-cfg-je-backend
ds-cfg-backend-enabled: true
ds-cfg-backend-class: org.opends.server.backends.jeb.BackendImpl
-ds-cfg-backend-id: indexTestRoot
+ds-cfg-backend-id: indexRoot
ds-cfg-backend-writability-mode: enabled
ds-cfg-backend-base-dn: dc=test,dc=com
ds-cfg-backend-base-dn: dc=test1,dc=com
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java
index a27e69a..66014ff 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java
@@ -36,7 +36,6 @@
import java.util.HashMap;
import java.util.Enumeration;
import java.util.Map;
-import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.logging.Logger;
import java.util.logging.Handler;
@@ -50,7 +49,6 @@
import org.opends.server.backends.MemoryBackend;
import org.opends.server.backends.jeb.BackendImpl;
import org.opends.server.config.ConfigException;
-import org.opends.server.config.ConfigEntry;
import org.opends.server.core.AddOperation;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.LockFileManager;
@@ -74,13 +72,7 @@
import org.opends.server.types.FilePermission;
import org.opends.server.types.InitializationException;
import org.opends.server.types.OperatingSystem;
-import org.opends.server.types.NullOutputStream;
import org.opends.server.types.ResultCode;
-import org.opends.server.util.ChangeRecordEntry;
-import org.opends.server.util.AddChangeRecordEntry;
-import org.opends.server.util.DeleteChangeRecordEntry;
-import org.opends.server.util.ModifyChangeRecordEntry;
-import org.opends.server.util.ModifyDNChangeRecordEntry;
import static org.testng.Assert.*;
import static org.testng.Assert.assertEquals;
@@ -395,7 +387,7 @@
* @throws SocketException in case of underlying exception.
*/
private static ServerSocket bindPort(int port)
- throws IOException, SocketException
+ throws IOException
{
ServerSocket serverLdapSocket;
serverLdapSocket = new ServerSocket();
@@ -411,7 +403,7 @@
* @throws IOException in case of underlying exception.
* @throws SocketException in case of underlying exception.
*/
- public static ServerSocket bindFreePort() throws IOException, SocketException
+ public static ServerSocket bindFreePort() throws IOException
{
ServerSocket serverLdapSocket;
serverLdapSocket = new ServerSocket();
@@ -459,7 +451,8 @@
{
memoryBackend = new MemoryBackend();
memoryBackend.setBackendID("test");
- memoryBackend.initializeBackend(null, new DN[] { baseDN });
+ memoryBackend.setBaseDNs(new DN[] { baseDN });
+ memoryBackend.initializeBackend();
DirectoryServer.registerBackend(memoryBackend);
}
@@ -490,10 +483,8 @@
throws Exception
{
BackendImpl backend = (BackendImpl)DirectoryServer.getBackend(beID);
- DN[] baseDNs = backend.getBaseDNs();
- ConfigEntry configEntry = TaskUtils.getConfigEntry(backend);
- TaskUtils.setBackendEnabled(configEntry, false);
+ TaskUtils.disableBackend(beID);
try
{
@@ -507,7 +498,7 @@
try
{
- backend.clearBackend(configEntry, baseDNs);
+ backend.clearBackend();
}
finally
{
@@ -516,7 +507,7 @@
}
finally
{
- TaskUtils.setBackendEnabled(configEntry, true);
+ TaskUtils.enableBackend(beID);
}
if (createBaseEntry)
@@ -705,7 +696,7 @@
LDIFReader reader = new LDIFReader(ldifImportConfig);
List<Entry> entries = new ArrayList<Entry>();
- Entry entry = null;
+ Entry entry;
while ((entry = reader.readEntry()) != null) {
entries.add(entry);
}
@@ -760,8 +751,8 @@
*/
public static String makeLdif(String... lines) {
StringBuilder buffer = new StringBuilder();
- for (int i = 0; i < lines.length; i++) {
- buffer.append(lines[i]).append(EOL);
+ for (String line : lines) {
+ buffer.append(line).append(EOL);
}
// Append an extra line so we can append LDIF Strings.
buffer.append(EOL);
@@ -1084,7 +1075,7 @@
}
/**
- * @return clear everything written to System.out since the last time
+ * clear everything written to System.out since the last time
* clearSystemOutContents was called.
*/
public synchronized static void clearSystemOutContents() {
@@ -1092,7 +1083,7 @@
}
/**
- * @return clear everything written to System.err since the last time
+ * clear everything written to System.err since the last time
* clearSystemErrContents was called.
*/
public synchronized static void clearSystemErrContents() {
@@ -1157,8 +1148,8 @@
*/
private static byte[] readFileBytes(File file)
throws IOException {
- FileInputStream fis = null;
- byte[] bytes = null;
+ FileInputStream fis;
+ byte[] bytes;
fis = new FileInputStream(file);
bytes = readInputStreamBytes(fis, true);
return bytes;
@@ -1175,7 +1166,7 @@
ByteArrayOutputStream bout = new ByteArrayOutputStream(1024);
try {
byte[] buf = new byte[1024];
- int bytesRead = 0;
+ int bytesRead;
while ((bytesRead = is.read(buf)) != -1) {
bout.write(buf, 0, bytesRead);
} // end of while ((read(buf) != -1)
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/backends/SchemaBackendTestCase.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/backends/SchemaBackendTestCase.java
index f621287..ad41d50 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/backends/SchemaBackendTestCase.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/backends/SchemaBackendTestCase.java
@@ -30,29 +30,23 @@
import java.io.File;
import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
import org.testng.annotations.BeforeClass;
-import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.opends.server.TestCaseUtils;
-import org.opends.server.config.ConfigEntry;
+import org.opends.server.admin.std.server.SchemaBackendCfg;
import org.opends.server.config.ConfigException;
import org.opends.server.core.AddOperation;
import org.opends.server.core.DeleteOperation;
import org.opends.server.core.DirectoryServer;
-import org.opends.server.core.ModifyOperation;
import org.opends.server.core.ModifyDNOperation;
import org.opends.server.core.SchemaConfigManager;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.protocols.internal.InternalSearchOperation;
import org.opends.server.tools.LDAPModify;
-import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.AttributeValue;
-import org.opends.server.types.ByteStringFactory;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.DITContentRule;
import org.opends.server.types.DN;
@@ -62,10 +56,7 @@
import org.opends.server.types.LDIFExportConfig;
import org.opends.server.types.LDIFImportConfig;
import org.opends.server.types.MatchingRuleUse;
-import org.opends.server.types.Modification;
-import org.opends.server.types.ModificationType;
import org.opends.server.types.ObjectClass;
-import org.opends.server.types.RDN;
import org.opends.server.types.ResultCode;
import org.opends.server.types.SearchFilter;
import org.opends.server.types.SearchScope;
@@ -86,7 +77,6 @@
private SchemaBackend schemaBackend;
-
/**
* Ensures that the Directory Server is running and gets a reference to the
* schema backend.
@@ -117,7 +107,7 @@
throws Exception
{
SchemaBackend schemaBackend = new SchemaBackend();
- schemaBackend.initializeBackend(null, new DN[0]);
+ schemaBackend.configureBackend(null);
}
@@ -5346,20 +5336,13 @@
public void testExportLDIF()
throws Exception
{
- DN configEntryDN =
- DN.decode("ds-cfg-backend-id=schema,cn=Backends,cn=config");
- DN[] baseDNs = { DN.decode("cn=schema") };
-
- ConfigEntry configEntry =
- DirectoryServer.getConfigHandler().getConfigEntry(configEntryDN);
-
File tempFile = File.createTempFile("schema", "testExportLDIF");
tempFile.deleteOnExit();
LDIFExportConfig exportConfig =
new LDIFExportConfig(tempFile.getAbsolutePath(),
ExistingFileBehavior.OVERWRITE);
- schemaBackend.exportLDIF(configEntry, baseDNs, exportConfig);
+ schemaBackend.exportLDIF(exportConfig);
assertTrue(tempFile.exists());
assertTrue(tempFile.length() > 0);
@@ -5376,20 +5359,13 @@
public void testImportLDIF()
throws Exception
{
- DN configEntryDN =
- DN.decode("cn=schema,cn=Backends,cn=config");
- DN[] baseDNs = { DN.decode("cn=schema") };
-
- ConfigEntry configEntry =
- DirectoryServer.getConfigHandler().getConfigEntry(configEntryDN);
-
File tempFile = File.createTempFile("schema", "testImportLDIF");
tempFile.deleteOnExit();
LDIFImportConfig importConfig =
new LDIFImportConfig(tempFile.getAbsolutePath());
- schemaBackend.importLDIF(configEntry, baseDNs, importConfig);
+ schemaBackend.importLDIF(importConfig);
}
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/backends/jeb/TestBackendImpl.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/backends/jeb/TestBackendImpl.java
index 67c3943..748f9d6 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/backends/jeb/TestBackendImpl.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/backends/jeb/TestBackendImpl.java
@@ -79,7 +79,7 @@
homeDirName = "db_index_test";
- backend = (BackendImpl)DirectoryServer.getBackend("indexTestRoot");
+ backend = (BackendImpl)DirectoryServer.getBackend("indexRoot");
topEntries = TestCaseUtils.makeEntries(
"dn: dc=test,dc=com",
@@ -1160,7 +1160,7 @@
"ds-cfg-backend-enabled: true",
"ds-cfg-backend-writability-mode: enabled",
"ds-cfg-backend-class: org.opends.server.backends.jeb.BackendImpl",
- "ds-cfg-backend-id: indexTestRoot",
+ "ds-cfg-backend-id: indexRoot",
"ds-cfg-backend-directory:: " +
Base64.encode(homeDirName.getBytes()),
"ds-cfg-backend-import-temp-directory: importTmp");
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/backends/jeb/TestEntryContainer.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/backends/jeb/TestEntryContainer.java
index bba1d8f..819c4d5 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/backends/jeb/TestEntryContainer.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/backends/jeb/TestEntryContainer.java
@@ -179,8 +179,7 @@
JEBackendCfg cfg = AdminTestCaseUtils.getConfiguration(
JEBackendCfgDefn.getInstance(), configEntry);
Config backendConfig = new Config();
- backendConfig.initializeConfig(cfg,
- cfg.getBackendBaseDN().toArray(new DN[0]));
+ backendConfig.initializeConfig(cfg);
RootContainer rootContainer = new RootContainer(backendConfig, null);
rootContainer.open(new File(homeDirName),
new FilePermission(true, true, true),
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/backends/jeb/TestImportJob.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/backends/jeb/TestImportJob.java
index acda6d8..390899c 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/backends/jeb/TestImportJob.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/backends/jeb/TestImportJob.java
@@ -27,8 +27,10 @@
package org.opends.server.backends.jeb;
import org.opends.server.TestCaseUtils;
+import org.opends.server.admin.std.server.JEBackendCfg;
+import org.opends.server.admin.std.meta.JEBackendCfgDefn;
+import org.opends.server.admin.server.AdminTestCaseUtils;
import org.opends.server.core.DirectoryServer;
-import org.opends.server.protocols.asn1.ASN1OctetString;
import org.opends.server.config.ConfigEntry;
import org.opends.server.util.Base64;
import static org.opends.server.util.ServerConstants.OC_TOP;
@@ -36,7 +38,6 @@
import org.opends.server.types.*;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
-import org.testng.annotations.AfterTest;
import org.testng.annotations.AfterClass;
import static org.testng.Assert.*;
import static org.testng.Assert.assertEquals;
@@ -47,7 +48,6 @@
import java.io.ByteArrayOutputStream;
import java.util.*;
-import com.sleepycat.je.DatabaseEntry;
public class TestImportJob extends JebTestCase
{
@@ -248,6 +248,8 @@
"ds-cfg-backend-import-temp-directory:: " + Base64.encode(importDirName.getBytes()));
ConfigEntry backendConfigEntry = new ConfigEntry(configEntry, null);
+ JEBackendCfg cfg = AdminTestCaseUtils.getConfiguration(
+ JEBackendCfgDefn.getInstance(), configEntry);
Entry indexEntry = TestCaseUtils.makeEntry(
"dn: cn=Index,ds-cfg-backend-id=userRoot,cn=Backends,cn=config\n" +
@@ -280,7 +282,7 @@
};
backendConfig = new Config();
- backendConfig.initializeConfig(backendConfigEntry, baseDNs);
+ backendConfig.initializeConfig(cfg);
}
@AfterClass
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/backends/jeb/TestRebuildJob.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/backends/jeb/TestRebuildJob.java
index 4858277..90e16e8 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/backends/jeb/TestRebuildJob.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/backends/jeb/TestRebuildJob.java
@@ -35,7 +35,6 @@
import org.opends.server.tasks.TaskUtils;
import static org.opends.server.util.ServerConstants.OC_TOP;
import static org.opends.server.util.ServerConstants.OC_EXTENSIBLE_OBJECT;
-import org.opends.server.config.ConfigEntry;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.*;
@@ -46,8 +45,6 @@
public class TestRebuildJob extends JebTestCase
{
- private String cfgDN=
- "ds-cfg-backend-id=rebuildRoot,cn=Backends,cn=config";
private String beID="rebuildRoot";
private static String suffix="dc=rebuild,dc=jeb";
private static String vBranch="ou=rebuild tests," + suffix;
@@ -55,9 +52,7 @@
//Attribute type in stat entry containing error count
private String errorCount="verify-error-count";
- private DN configDN;
private DN[] baseDNs;
- private ConfigEntry configEntry;
private BackendImpl be;
@DataProvider(name = "systemIndexes")
@@ -131,11 +126,9 @@
@BeforeClass
public void setup() throws Exception {
TestCaseUtils.startServer();
- configDN = DN.decode(cfgDN);
baseDNs = new DN[] {
DN.decode(suffix)
};
- configEntry = DirectoryServer.getConfigEntry(configDN);
}
@AfterClass
@@ -169,7 +162,7 @@
rebuildConfig.setBaseDN(baseDNs[0]);
rebuildConfig.addRebuildIndex(index);
be=(BackendImpl) DirectoryServer.getBackend(beID);
- be.rebuildBackend(rebuildConfig, configEntry, baseDNs);
+ be.rebuildBackend(rebuildConfig);
assertEquals(verifyBackend("mail"), 0);
@@ -183,7 +176,7 @@
rebuildConfig.setBaseDN(baseDNs[0]);
rebuildConfig.addRebuildIndex(index);
be=(BackendImpl) DirectoryServer.getBackend(beID);
- be.rebuildBackend(rebuildConfig, configEntry, baseDNs);
+ be.rebuildBackend(rebuildConfig);
}
@Test(dataProvider = "systemIndexes",
@@ -195,21 +188,21 @@
rebuildConfig.setBaseDN(baseDNs[0]);
rebuildConfig.addRebuildIndex(index);
be=(BackendImpl) DirectoryServer.getBackend(beID);
- be.rebuildBackend(rebuildConfig, configEntry, baseDNs);
+ be.rebuildBackend(rebuildConfig);
}
@Test(dataProvider = "systemIndexes")
public void testRebuildSystemIndexesOffline(String index) throws Exception
{
- cleanAndLoad(10);
+ cleanAndLoad(10);
RebuildConfig rebuildConfig = new RebuildConfig();
rebuildConfig.setBaseDN(baseDNs[0]);
rebuildConfig.addRebuildIndex(index);
be=(BackendImpl) DirectoryServer.getBackend(beID);
- TaskUtils.setBackendEnabled(configEntry, false);
+ TaskUtils.disableBackend(beID);
- be.rebuildBackend(rebuildConfig, configEntry, baseDNs);
+ be.rebuildBackend(rebuildConfig);
//TODO: Verify dn2uri database as well.
if(!index.equalsIgnoreCase("dn2uri"))
@@ -217,7 +210,7 @@
assertEquals(verifyBackend(index), 0);
}
- TaskUtils.setBackendEnabled(configEntry, true);
+ TaskUtils.enableBackend(beID);
}
@Test
@@ -231,13 +224,13 @@
be=(BackendImpl) DirectoryServer.getBackend(beID);
- TaskUtils.setBackendEnabled(configEntry, false);
+ TaskUtils.disableBackend(beID);
- be.rebuildBackend(rebuildConfig, configEntry, baseDNs);
+ be.rebuildBackend(rebuildConfig);
assertEquals(verifyBackend(null), 0);
- TaskUtils.setBackendEnabled(configEntry, true);
+ TaskUtils.enableBackend(beID);
}
@Test
@@ -293,7 +286,7 @@
verifyConfig.addCleanIndex(index);
}
Entry statEntry=bldStatEntry("");
- be.verifyBackend(verifyConfig, configEntry, baseDNs, statEntry);
+ be.verifyBackend(verifyConfig, statEntry);
return getStatEntryCount(statEntry, errorCount);
}
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/backends/jeb/TestVerifyJob.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/backends/jeb/TestVerifyJob.java
index 58940c0..a8b36d3 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/backends/jeb/TestVerifyJob.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/backends/jeb/TestVerifyJob.java
@@ -26,7 +26,6 @@
*/
package org.opends.server.backends.jeb;
-import org.opends.server.config.ConfigEntry;
import org.opends.server.core.DirectoryServer;
import org.opends.server.TestCaseUtils;
import org.opends.server.types.*;
@@ -50,696 +49,689 @@
public class TestVerifyJob extends JebTestCase
{
- private String cfgDN=
- "ds-cfg-backend-id=verifyRoot,cn=Backends,cn=config";
- //Root suffix for verify backend
- private static String suffix="dc=verify,dc=jeb";
- private static String vBranch="ou=verify tests," + suffix;
- private String beID="verifyRoot";
- private String numUsersLine="define numusers= #numEntries#";
- //Attribute type in stat entry containing error count
- private String errorCount="verify-error-count";
- private DN configDN;
- private DN[] baseDNs;
- private ConfigEntry configEntry;
- private BackendImpl be;
- private RootContainer rContainer;
- private EntryContainer eContainer;
- private DN2ID dn2id;
- private ID2Entry id2entry;
- private Index id2child;
- private Index id2subtree;
- private Transaction txn;
-
- //Some DNs needed mostly for DN2ID tests
- private String junkDN="cn=junk," + vBranch;
- private String junkDN1="cn=junk1," + vBranch;
- private String junkDN2="cn=junk2," + vBranch;
- private String junkDN3="cn=junk3," + vBranch;
- //This DN has no parent
- private String noParentDN="cn=junk1,cn=junk22," + vBranch;
- //Parent child combo for id2child/subtree type tests
- private String pDN="cn=junk222," + vBranch;
- private String cDN="cn=junk4,cn=junk222," + vBranch;
- //Bad DN
- private String badDN="this is a bad DN";
- //This index file should not exist
- private String badIndexName="badIndexName";
-
- @DataProvider(name = "indexes")
- public Object[][] indexes() {
- return new Object[][] {
- { "telephoneNumber"},
- {"givenName"},
- { "id2subtree"},
- {"id2children"},
- {"dn2id"}
- };
- }
-
- private static String[] template = new String[] {
- "define suffix="+suffix,
- "define maildomain=example.com",
- "define numusers= #numEntries#",
- "",
- "branch: [suffix]",
- "",
- "branch: " + vBranch,
- "subordinateTemplate: person:[numusers]",
- "",
- "template: person",
- "rdnAttr: uid",
- "objectClass: top",
- "objectClass: person",
- "objectClass: organizationalPerson",
- "objectClass: inetOrgPerson",
- "givenName: ABOVE LIMIT",
- "sn: <last>",
- "cn: {givenName} {sn}",
- "initials: {givenName:1}<random:chars:" +
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ:1>{sn:1}",
- "employeeNumber: <sequential:0>",
- "uid: user.{employeeNumber}",
- "mail: {uid}@[maildomain]",
- "userPassword: password",
- "telephoneNumber: <random:telephone>",
- "homePhone: <random:telephone>",
- "pager: <random:telephone>",
- "mobile: <random:telephone>",
- "street: <random:numeric:5> <file:streets> Street",
- "l: <file:cities>",
- "st: <file:states>",
- "postalCode: <random:numeric:5>",
- "postalAddress: {cn}${street}${l}, {st} {postalCode}",
- "description: This is the description for {cn}.",
- ""};
+ //Root suffix for verify backend
+ private static String suffix="dc=verify,dc=jeb";
+ private static String vBranch="ou=verify tests," + suffix;
+ private String beID="verifyRoot";
+ private String numUsersLine="define numusers= #numEntries#";
+ //Attribute type in stat entry containing error count
+ private String errorCount="verify-error-count";
+ private DN[] baseDNs;
+ private BackendImpl be;
+ private EntryContainer eContainer;
+ private DN2ID dn2id;
+ private ID2Entry id2entry;
+ private Index id2child;
+ private Index id2subtree;
+ private Transaction txn;
- @BeforeClass
- public void setup() throws Exception {
- TestCaseUtils.startServer();
- configDN = DN.decode(cfgDN);
- baseDNs = new DN[] {
- DN.decode(suffix)
- };
- configEntry = DirectoryServer.getConfigEntry(configDN);
- }
-
- @AfterClass
- public void cleanUp() throws Exception {
- TestCaseUtils.clearJEBackend(false, beID, suffix);
- }
-
- /**
- * Performs a ncomplete verify against a backend using the
- * entries loaded in the setup initializer.
- *
- * @throws Exception if error count is not equal to 0.
- */
+ //Some DNs needed mostly for DN2ID tests
+ private String junkDN="cn=junk," + vBranch;
+ private String junkDN1="cn=junk1," + vBranch;
+ private String junkDN2="cn=junk2," + vBranch;
+ private String junkDN3="cn=junk3," + vBranch;
+ //This DN has no parent
+ private String noParentDN="cn=junk1,cn=junk22," + vBranch;
+ //Parent child combo for id2child/subtree type tests
+ private String pDN="cn=junk222," + vBranch;
+ private String cDN="cn=junk4,cn=junk222," + vBranch;
+ //Bad DN
+ private String badDN="this is a bad DN";
+ //This index file should not exist
+ private String badIndexName="badIndexName";
- @Test()
- public void testCompleteVerifyJob() throws Exception {
- cleanAndLoad(9);
- VerifyConfig verifyConfig = new VerifyConfig();
- verifyConfig.setBaseDN(baseDNs[0]);
- Entry statEntry=bldStatEntry("");
- be=(BackendImpl) DirectoryServer.getBackend(beID);
- be.verifyBackend(verifyConfig, configEntry, baseDNs, statEntry);
- assertEquals(getStatEntryCount(statEntry, errorCount), 0);
- }
+ @DataProvider(name = "indexes")
+ public Object[][] indexes() {
+ return new Object[][] {
+ { "telephoneNumber"},
+ {"givenName"},
+ { "id2subtree"},
+ {"id2children"},
+ {"dn2id"}
+ };
+ }
- /**
- * Adds more than "entry limit" number of entries and runs clean
- * verify against two indexes.
- *
- * @throws Exception if error count is not equal to 0.
- */
- @Test()
- public void testEntryLimitVerifyJob() throws Exception {
- cleanAndLoad(25);
- VerifyConfig verifyConfig = new VerifyConfig();
- verifyConfig.setBaseDN(baseDNs[0]);
- verifyConfig.addCleanIndex("telephoneNumber");
- verifyConfig.addCleanIndex("givenName");
- Entry statEntry=bldStatEntry("");
- be=(BackendImpl) DirectoryServer.getBackend(beID);
- be.verifyBackend(verifyConfig, configEntry, baseDNs, statEntry);
- assertEquals(getStatEntryCount(statEntry, errorCount), 0);
- }
+ private static String[] template = new String[] {
+ "define suffix="+suffix,
+ "define maildomain=example.com",
+ "define numusers= #numEntries#",
+ "",
+ "branch: [suffix]",
+ "",
+ "branch: " + vBranch,
+ "subordinateTemplate: person:[numusers]",
+ "",
+ "template: person",
+ "rdnAttr: uid",
+ "objectClass: top",
+ "objectClass: person",
+ "objectClass: organizationalPerson",
+ "objectClass: inetOrgPerson",
+ "givenName: ABOVE LIMIT",
+ "sn: <last>",
+ "cn: {givenName} {sn}",
+ "initials: {givenName:1}<random:chars:" +
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ:1>{sn:1}",
+ "employeeNumber: <sequential:0>",
+ "uid: user.{employeeNumber}",
+ "mail: {uid}@[maildomain]",
+ "userPassword: password",
+ "telephoneNumber: <random:telephone>",
+ "homePhone: <random:telephone>",
+ "pager: <random:telephone>",
+ "mobile: <random:telephone>",
+ "street: <random:numeric:5> <file:streets> Street",
+ "l: <file:cities>",
+ "st: <file:states>",
+ "postalCode: <random:numeric:5>",
+ "postalAddress: {cn}${street}${l}, {st} {postalCode}",
+ "description: This is the description for {cn}.",
+ ""};
- /**
- * Runs clean verify jobs against a set of indexes (defined in
- * indexes array).
- * @param index An element of the indexes array.
- * @throws Exception if the error count is not equal to 0.
- */
-
- @Test(dataProvider = "indexes")
- public void testCleanVerifyJob(String index) throws Exception {
- cleanAndLoad(9);
- VerifyConfig verifyConfig = new VerifyConfig();
- verifyConfig.setBaseDN(baseDNs[0]);
- verifyConfig.addCleanIndex(index);
- Entry statEntry=bldStatEntry("");
- be=(BackendImpl) DirectoryServer.getBackend(beID);
- be.verifyBackend(verifyConfig, configEntry, baseDNs, statEntry);
- assertEquals(getStatEntryCount(statEntry, errorCount), 0);
- }
-
- /*
+ @BeforeClass
+ public void setup() throws Exception {
+ TestCaseUtils.startServer();
+ baseDNs = new DN[] {
+ DN.decode(suffix)
+ };
+ }
+
+ @AfterClass
+ public void cleanUp() throws Exception {
+ TestCaseUtils.clearJEBackend(false, beID, suffix);
+ }
+
+ /**
+ * Performs a ncomplete verify against a backend using the
+ * entries loaded in the setup initializer.
+ *
+ * @throws Exception if error count is not equal to 0.
+ */
+
+ @Test()
+ public void testCompleteVerifyJob() throws Exception {
+ cleanAndLoad(9);
+ VerifyConfig verifyConfig = new VerifyConfig();
+ verifyConfig.setBaseDN(baseDNs[0]);
+ Entry statEntry=bldStatEntry("");
+ be=(BackendImpl) DirectoryServer.getBackend(beID);
+ be.verifyBackend(verifyConfig, statEntry);
+ assertEquals(getStatEntryCount(statEntry, errorCount), 0);
+ }
+
+ /**
+ * Adds more than "entry limit" number of entries and runs clean
+ * verify against two indexes.
+ *
+ * @throws Exception if error count is not equal to 0.
+ */
+ @Test()
+ public void testEntryLimitVerifyJob() throws Exception {
+ cleanAndLoad(25);
+ VerifyConfig verifyConfig = new VerifyConfig();
+ verifyConfig.setBaseDN(baseDNs[0]);
+ verifyConfig.addCleanIndex("telephoneNumber");
+ verifyConfig.addCleanIndex("givenName");
+ Entry statEntry=bldStatEntry("");
+ be=(BackendImpl) DirectoryServer.getBackend(beID);
+ be.verifyBackend(verifyConfig, statEntry);
+ assertEquals(getStatEntryCount(statEntry, errorCount), 0);
+ }
+
+ /**
+ * Runs clean verify jobs against a set of indexes (defined in
+ * indexes array).
+ * @param index An element of the indexes array.
+ * @throws Exception if the error count is not equal to 0.
+ */
+
+ @Test(dataProvider = "indexes")
+ public void testCleanVerifyJob(String index) throws Exception {
+ cleanAndLoad(9);
+ VerifyConfig verifyConfig = new VerifyConfig();
+ verifyConfig.setBaseDN(baseDNs[0]);
+ verifyConfig.addCleanIndex(index);
+ Entry statEntry=bldStatEntry("");
+ be=(BackendImpl) DirectoryServer.getBackend(beID);
+ be.verifyBackend(verifyConfig, statEntry);
+ assertEquals(getStatEntryCount(statEntry, errorCount), 0);
+ }
+
+ /*
* Begin Clean index tests. These are tests that cursor through an index
* file and validate it's keys and idlists against the id2entry database entries.
* The complete index tests go the other way. They cursor the id2entry database
* and validate each entry against the various index files.
*/
- /**
- * Runs clean verify against the dn2id index after adding
- * various errors in that index file.
- *
- * @throws Exception if the error count is not equal to 5.
- */
- @Test()
- public void testCleanDN2ID() throws Exception {
- preTest(3);
- //Add a junk DN and non-existent entry id to DN2ID index
- DN testDN=DN.decode(junkDN);
- EntryID id=new EntryID(45);
- assertTrue(dn2id.insert(txn, testDN, id));
- //Make two DN keys point at same entry.
- testDN=DN.decode(junkDN1);
- id=new EntryID(3);
- assertTrue(dn2id.insert(txn, testDN, id));
- //Add badDN key with bad entry id
- DatabaseEntry key=
- new DatabaseEntry(StaticUtils.getBytes(badDN));
- DatabaseEntry data =
- new EntryID(37).getDatabaseEntry();
- assertTrue(dn2id.putRaw(txn, key, data));
- //Add DN key with malformed entryID
- key=new DatabaseEntry(StaticUtils.getBytes(junkDN2));
- data= new DatabaseEntry(new byte[3]);
- assertTrue(dn2id.putRaw(txn, key, data));
- //Try to break JebFormat version
- addID2EntryReturnKey(junkDN3, 20, true);
- id=new EntryID(20);
- assertTrue(dn2id.insert(txn, DN.decode(junkDN3), id));
- performBECleanVerify("dn2id", 5);
- }
+ /**
+ * Runs clean verify against the dn2id index after adding
+ * various errors in that index file.
+ *
+ * @throws Exception if the error count is not equal to 5.
+ */
+ @Test()
+ public void testCleanDN2ID() throws Exception {
+ preTest(3);
+ //Add a junk DN and non-existent entry id to DN2ID index
+ DN testDN=DN.decode(junkDN);
+ EntryID id=new EntryID(45);
+ assertTrue(dn2id.insert(txn, testDN, id));
+ //Make two DN keys point at same entry.
+ testDN=DN.decode(junkDN1);
+ id=new EntryID(3);
+ assertTrue(dn2id.insert(txn, testDN, id));
+ //Add badDN key with bad entry id
+ DatabaseEntry key=
+ new DatabaseEntry(StaticUtils.getBytes(badDN));
+ DatabaseEntry data =
+ new EntryID(37).getDatabaseEntry();
+ assertTrue(dn2id.putRaw(txn, key, data));
+ //Add DN key with malformed entryID
+ key=new DatabaseEntry(StaticUtils.getBytes(junkDN2));
+ data= new DatabaseEntry(new byte[3]);
+ assertTrue(dn2id.putRaw(txn, key, data));
+ //Try to break JebFormat version
+ addID2EntryReturnKey(junkDN3, 20, true);
+ id=new EntryID(20);
+ assertTrue(dn2id.insert(txn, DN.decode(junkDN3), id));
+ performBECleanVerify("dn2id", 5);
+ }
- /**
- * Runs clean verify against the id2children index after adding
- * various errors in that index file.
- *
- * @throws Exception if the error count is not equal to 6.
- */
- @Test() public void testCleanID2Children() throws Exception {
- preTest(3);
- //Add malformed key
- byte[] shortBytes = new byte[3];
- DatabaseEntry key= new DatabaseEntry(shortBytes);
- EntryIDSet idSet=new EntryIDSet();
- id2child.writeKey(txn, key, idSet);
- //Try to break JebFormat version of key entry
- key=addID2EntryReturnKey(junkDN, 4, true);
- idSet=new EntryIDSet(new byte[16], new byte[16]);
- id2child.writeKey(txn, key, idSet);
- //put invalid key -- no EntryID matches
- key= new EntryID(45).getDatabaseEntry();
- id2child.writeKey(txn, key, idSet);
- //invalid ids in id list
- key=addID2EntryReturnKey(junkDN1, 5, false);
- byte[] idBytes=new byte[24];
- //doesn't exist
- idBytes[3] = (byte)0xff;
- //not a child
- idBytes[15] = (byte)1;
- //bad jeb format
- idBytes[23] = (byte) 0x04;
- idSet=new EntryIDSet(null, idBytes);
- id2child.writeKey(txn, key, idSet);
- performBECleanVerify("id2children", 6);
- }
+ /**
+ * Runs clean verify against the id2children index after adding
+ * various errors in that index file.
+ *
+ * @throws Exception if the error count is not equal to 6.
+ */
+ @Test() public void testCleanID2Children() throws Exception {
+ preTest(3);
+ //Add malformed key
+ byte[] shortBytes = new byte[3];
+ DatabaseEntry key= new DatabaseEntry(shortBytes);
+ EntryIDSet idSet=new EntryIDSet();
+ id2child.writeKey(txn, key, idSet);
+ //Try to break JebFormat version of key entry
+ key=addID2EntryReturnKey(junkDN, 4, true);
+ idSet=new EntryIDSet(new byte[16], new byte[16]);
+ id2child.writeKey(txn, key, idSet);
+ //put invalid key -- no EntryID matches
+ key= new EntryID(45).getDatabaseEntry();
+ id2child.writeKey(txn, key, idSet);
+ //invalid ids in id list
+ key=addID2EntryReturnKey(junkDN1, 5, false);
+ byte[] idBytes=new byte[24];
+ //doesn't exist
+ idBytes[3] = (byte)0xff;
+ //not a child
+ idBytes[15] = (byte)1;
+ //bad jeb format
+ idBytes[23] = (byte) 0x04;
+ idSet=new EntryIDSet(null, idBytes);
+ id2child.writeKey(txn, key, idSet);
+ performBECleanVerify("id2children", 6);
+ }
- /**
- * Runs clean verify against the id2subtree index after adding
- * various errors in that index file.
- *
- * @throws Exception if the error count is not equal to 7.
- */
- @Test() public void testCleanID2Subtree() throws Exception {
- preTest(4);
- //break key
- byte[] shortBytes = new byte[3];
- DatabaseEntry key= new DatabaseEntry(shortBytes);
- EntryIDSet idSet=new EntryIDSet();
- id2subtree.writeKey(txn, key, idSet);
- //put invalid ids into entry 3 idlist
- key= new EntryID(3).getDatabaseEntry();
- byte[] idBytes=new byte[16];
- //invalid id
- idBytes[3] = (byte)0xff;
- //non-subordinate
- idBytes[15] = (byte)1;
- idSet=new EntryIDSet(null, idBytes);
- id2subtree.writeKey(txn, key, idSet);
- //Try to break JebFormat version of key entry
- key=addID2EntryReturnKey(junkDN, 4, true);
- idBytes[3]=(byte) 0x04;
- idBytes[15]=(byte)0x00;
- EntryIDSet idSet1=new EntryIDSet(null, idBytes);
- id2subtree.writeKey(txn, key, idSet1);
- //put invalid key -- no EntryID matches
- key= new EntryID(45).getDatabaseEntry();
- idSet=new EntryIDSet(null, idBytes);
- id2subtree.writeKey(txn, key, idSet);
- performBECleanVerify("id2subtree", 7);
- }
+ /**
+ * Runs clean verify against the id2subtree index after adding
+ * various errors in that index file.
+ *
+ * @throws Exception if the error count is not equal to 7.
+ */
+ @Test() public void testCleanID2Subtree() throws Exception {
+ preTest(4);
+ //break key
+ byte[] shortBytes = new byte[3];
+ DatabaseEntry key= new DatabaseEntry(shortBytes);
+ EntryIDSet idSet=new EntryIDSet();
+ id2subtree.writeKey(txn, key, idSet);
+ //put invalid ids into entry 3 idlist
+ key= new EntryID(3).getDatabaseEntry();
+ byte[] idBytes=new byte[16];
+ //invalid id
+ idBytes[3] = (byte)0xff;
+ //non-subordinate
+ idBytes[15] = (byte)1;
+ idSet=new EntryIDSet(null, idBytes);
+ id2subtree.writeKey(txn, key, idSet);
+ //Try to break JebFormat version of key entry
+ key=addID2EntryReturnKey(junkDN, 4, true);
+ idBytes[3]=(byte) 0x04;
+ idBytes[15]=(byte)0x00;
+ EntryIDSet idSet1=new EntryIDSet(null, idBytes);
+ id2subtree.writeKey(txn, key, idSet1);
+ //put invalid key -- no EntryID matches
+ key= new EntryID(45).getDatabaseEntry();
+ idSet=new EntryIDSet(null, idBytes);
+ id2subtree.writeKey(txn, key, idSet);
+ performBECleanVerify("id2subtree", 7);
+ }
- /**
- * Runs clean verify against the telephoneNumber.equality index
- * after adding various errors in that index file.
- *
- * @throws Exception if the error count is not equal to 4.
- */
- @Test() public void testCleanAttrIndex() throws Exception {
- String phoneType="telephoneNumber";
- preTest(3);
- //Need to open a second database against this index
- //so we can manipulate it. We can't get the index DB handle
- //any other way.
- DatabaseConfig config = new DatabaseConfig();
- config.setAllowCreate(true);
- config.setTransactional(true);
- Database db=
- eContainer.openDatabase(config, phoneType + ".equality");
- //Add entry with bad JEB format Version
- addID2EntryReturnKey(junkDN, 4, true);
- //Add phone number with various bad id list entryIDs
- byte[] subBytes = StaticUtils.getBytes("0009999999");
- DatabaseEntry key= new DatabaseEntry(subBytes);
- byte[] dataBytes=new byte[32];
- //put duplicate ids in list
- dataBytes[7] = (byte)1;
- dataBytes[15] = (byte)1;
- //put id that doesn't exist
- dataBytes[23] = (byte)0xff;
- //point to bad entry added above
- dataBytes[31] = (byte) 0x04;
- DatabaseEntry data= new DatabaseEntry(dataBytes);
- OperationStatus status = EntryContainer.put(db, txn, key, data);
- assertTrue(status == OperationStatus.SUCCESS);
- //really 5 errors, but duplicate reference doesn't increment error
- //count for some reason
- performBECleanVerify(phoneType, 4);
- }
-
- /*
+ /**
+ * Runs clean verify against the telephoneNumber.equality index
+ * after adding various errors in that index file.
+ *
+ * @throws Exception if the error count is not equal to 4.
+ */
+ @Test() public void testCleanAttrIndex() throws Exception {
+ String phoneType="telephoneNumber";
+ preTest(3);
+ //Need to open a second database against this index
+ //so we can manipulate it. We can't get the index DB handle
+ //any other way.
+ DatabaseConfig config = new DatabaseConfig();
+ config.setAllowCreate(true);
+ config.setTransactional(true);
+ Database db=
+ eContainer.openDatabase(config, phoneType + ".equality");
+ //Add entry with bad JEB format Version
+ addID2EntryReturnKey(junkDN, 4, true);
+ //Add phone number with various bad id list entryIDs
+ byte[] subBytes = StaticUtils.getBytes("0009999999");
+ DatabaseEntry key= new DatabaseEntry(subBytes);
+ byte[] dataBytes=new byte[32];
+ //put duplicate ids in list
+ dataBytes[7] = (byte)1;
+ dataBytes[15] = (byte)1;
+ //put id that doesn't exist
+ dataBytes[23] = (byte)0xff;
+ //point to bad entry added above
+ dataBytes[31] = (byte) 0x04;
+ DatabaseEntry data= new DatabaseEntry(dataBytes);
+ OperationStatus status = EntryContainer.put(db, txn, key, data);
+ assertTrue(status == OperationStatus.SUCCESS);
+ //really 5 errors, but duplicate reference doesn't increment error
+ //count for some reason
+ performBECleanVerify(phoneType, 4);
+ }
+
+ /*
* Begin complete verify index tests. As described above, these are
- * tests that cursor through the id2entry database and validate
+ * tests that cursor through the id2entry database and validate
* each entry against the various index files.
- *
- */
-
- /**
- * Runs complete verify against the telephoneNumber index
- * after adding various errors in the id2entry file.
- *
- * @throws Exception if the error count is not equal to 3.
- */
- @Test() public void testVerifyID2Entry() throws Exception {
- preTest(3);
- //Add entry with short id
- byte[] shortBytes = new byte[3];
- DatabaseEntry key= new DatabaseEntry(shortBytes);
- Entry testEntry=bldStatEntry(junkDN);
- byte []entryBytes =
- JebFormat.entryToDatabase(testEntry, new DataConfig());
- DatabaseEntry data= new DatabaseEntry(entryBytes);
- assertTrue(id2entry.putRaw(txn, key, data));
-
- //add entry with ramdom bytes
- DatabaseEntry key1= new EntryID(4).getDatabaseEntry();
- byte []eBytes = new byte[459];
- for(int i=0;i<459;i++) {
- eBytes[i]=(byte) (i*2);
- }
- //set version correctly
- eBytes[0]=0x01;
- DatabaseEntry data1= new DatabaseEntry(eBytes);
- assertTrue(id2entry.putRaw(txn, key1, data1));
- performBECompleteVerify("telephoneNumber", 3);
- }
-
- /**
*
- * Runs complete verify against the dn2id index
- * after adding various errors in the dn2id file.
- *
- * @throws Exception if the error count is not equal to 3.
*/
- @Test() public void testVerifyDN2ID() throws Exception {
- preTest(9);
- //add entry but no corresponding dn2id key
- addID2EntryReturnKey(junkDN, 10, false);
- //entry has dn2id key but its entryID -- don't need key
- addID2EntryReturnKey(junkDN1, 11, false);
- //insert key with bad entry id (45 instead of 10)
- DN testDN=DN.decode(junkDN1);
- EntryID id=new EntryID(45);
- assertTrue(dn2id.insert(txn, testDN, id));
- //entry has no parent in dn2id
- addID2EntryReturnKey(noParentDN, 12, false);
- //add the key/id
- testDN=DN.decode(noParentDN);
- id=new EntryID(12);
- assertTrue(dn2id.insert(txn, testDN, id));
- performBECompleteVerify("dn2id", 3);
- }
-
- /**
- *
- * Runs complete verify against the id2children index
- * after adding various errors in the id2children file.
- *
- * @throws Exception if the error count is not equal to 3.
- */
- @Test() public void testVerifyID2Children() throws Exception {
- preTest(9);
- //Add dn with no parent
- DatabaseEntry key=addID2EntryReturnKey(noParentDN, 10, false);
- byte[] idBytes=new byte[16];
- idBytes[7]=(byte) 0x0A;
- EntryIDSet idSet=new EntryIDSet(null, idBytes);
- id2child.writeKey(txn, key, idSet);
- //Add child entry - don't worry about key
- addID2EntryReturnKey(cDN, 11, false);
- //Add its parent entry -- need the key
- DatabaseEntry keyp=addID2EntryReturnKey(pDN, 12, false);
- //add parent key/IDSet with bad IDset id
- byte[] idBytesp=new byte[16];
- idBytesp[7]=(byte) 0xFF;
- EntryIDSet idSetp=new EntryIDSet(null, idBytesp);
- id2child.writeKey(txn, keyp, idSetp);
- performBECompleteVerify("id2children", 3);
- }
-
- /**
- *
- * Runs complete verify against the id2children index
- * after adding various errors in the id2children file.
- * This is a second test because the key needed to have
- * null idlist. This test is really just for coverage and
- * should have a 0 error count.
- *
- * @throws Exception if the error count is not equal to 0.
- */
- @Test() public void testVerifyID2Children1() throws Exception {
- preTest(2);
- //Add child entry - don't worry about key
- addID2EntryReturnKey(pDN, 10, false);
- //add parent key/IDSet with null keyset
- EntryIDSet idSetp=new EntryIDSet();
- DatabaseEntry key= new EntryID(2).getDatabaseEntry();
- id2child.writeKey(txn, key, idSetp);
- performBECompleteVerify("id2children", 0);
- }
-
- /**
- *
- * Runs complete verify against the id2subtree index
- * after adding various errors in the id2subtree file.
- *
- * @throws Exception if the error count is not equal to 3.
- */
- @Test
- public void testVerifyID2Subtree() throws Exception {
- preTest(2);
- //Add entry with no parent
- addID2EntryReturnKey(noParentDN, 3, false);
- performBECompleteVerify("id2subtree", 3);
- }
-
- /**
- *
- * Runs complete verify against the id2subtree index
- * after adding various errors in the id2subtree file.
- * This is a second test because the key needed to have
- * null idlist.
- *
- * @throws Exception if the error count is not equal to 1.
- */
- @Test
- public void testVerifyID2Subtree1() throws Exception {
- preTest(2);
- //Add child entry - don't worry about key
- addID2EntryReturnKey(pDN, 3, false);
- //add parent key/IDSet with null keyset
- EntryIDSet idSet=new EntryIDSet();
- DatabaseEntry key= new EntryID(2).getDatabaseEntry();
- id2subtree.writeKey(txn, key, idSet);
- performBECompleteVerify("id2subtree", 1);
- }
- /**
- * Runs complete verify against the mail indexes
- * (equality, presence, substring, ordering)
- * after adding various errors to each of these index files.
- * @throws Exception if the error count is not equal to 6.
- */
- @Test() public void testVerifyAttribute() throws Exception {
- String mailType="mail";
- preTest(4);
- //Need to open a second databases against this index
- //so we can manipulate it.
- DatabaseConfig config = new DatabaseConfig();
- config.setAllowCreate(true);
- config.setTransactional(true);
- //Get db handles to each index.
- Database dbEq=
- eContainer.openDatabase(config, mailType + ".equality");
- Database dbPres=
- eContainer.openDatabase(config, mailType + ".presence");
- Database dbSub=
- eContainer.openDatabase(config, mailType + ".substring");
- Database dbOr=
- eContainer.openDatabase(config, mailType + ".ordering");
- //Add invalid idlist ids to both equality and ordering indexes.
- DatabaseEntry key=
- new DatabaseEntry(StaticUtils.getBytes("user.0@example.com"));
- byte[] dataBytes=new byte[16];
- //put duplicate ids in list
- dataBytes[7] = (byte)0xff;
- dataBytes[15] = (byte)0xfe;
- DatabaseEntry data= new DatabaseEntry(dataBytes);
- OperationStatus status = EntryContainer.put(dbEq, txn, key, data);
- assertTrue(status == OperationStatus.SUCCESS);
- status = EntryContainer.put(dbOr, txn, key, data);
- assertTrue(status == OperationStatus.SUCCESS);
- //Add null idlist to both equality and ordering indexes.
- key =
- new DatabaseEntry(StaticUtils.getBytes("user.1@example.com"));
- data= new DatabaseEntry(new EntryIDSet().toDatabase());
- status = EntryContainer.put(dbEq, txn, key, data);
- assertTrue(status == OperationStatus.SUCCESS);
- status = EntryContainer.put(dbOr, txn, key, data);
- assertTrue(status == OperationStatus.SUCCESS);
- //Add invalid idlist ids to presence index.
- key =
- new DatabaseEntry(StaticUtils.getBytes("+"));
- data = new DatabaseEntry(dataBytes);
- status = EntryContainer.put(dbPres, txn, key, data);
- assertTrue(status == OperationStatus.SUCCESS);
- //Add invalid idlist ids to substring index.
- key =
- new DatabaseEntry(StaticUtils.getBytes("@examp"));
- data = new DatabaseEntry(dataBytes);
- status = EntryContainer.put(dbSub, txn, key, data);
- assertTrue(status == OperationStatus.SUCCESS);
- performBECompleteVerify(mailType, 6);
- }
+ /**
+ * Runs complete verify against the telephoneNumber index
+ * after adding various errors in the id2entry file.
+ *
+ * @throws Exception if the error count is not equal to 3.
+ */
+ @Test() public void testVerifyID2Entry() throws Exception {
+ preTest(3);
+ //Add entry with short id
+ byte[] shortBytes = new byte[3];
+ DatabaseEntry key= new DatabaseEntry(shortBytes);
+ Entry testEntry=bldStatEntry(junkDN);
+ byte []entryBytes =
+ JebFormat.entryToDatabase(testEntry, new DataConfig());
+ DatabaseEntry data= new DatabaseEntry(entryBytes);
+ assertTrue(id2entry.putRaw(txn, key, data));
- /* Various tests not either clean or complete */
-
-
- /**
- * Try to verify a non-indexed attribute.
- * @throws Exception if error count is not equal to 0.
- */
- @Test(expectedExceptions=Exception.class)
- public void testVerifyNotIndexed() throws Exception {
- cleanAndLoad(2);
- VerifyConfig verifyConfig = new VerifyConfig();
- verifyConfig.setBaseDN(baseDNs[0]);
- verifyConfig.addCleanIndex("userPassword");
- Entry statEntry=bldStatEntry("");
- be=(BackendImpl) DirectoryServer.getBackend(beID);
- be.verifyBackend(verifyConfig, configEntry, baseDNs, statEntry);
- assertEquals(getStatEntryCount(statEntry, errorCount), 0);
+ //add entry with ramdom bytes
+ DatabaseEntry key1= new EntryID(4).getDatabaseEntry();
+ byte []eBytes = new byte[459];
+ for(int i=0;i<459;i++) {
+ eBytes[i]=(byte) (i*2);
}
-
- /**
- * Try to verify an nonexistent attribute.
- * @throws Exception if verify backend fails.
- */
- @Test(expectedExceptions=Exception.class)
- public void testInvalidIndex() throws Exception {
- cleanAndLoad(2);
- VerifyConfig verifyConfig = new VerifyConfig();
- verifyConfig.setBaseDN(baseDNs[0]);
- verifyConfig.addCleanIndex(badIndexName);
- Entry statEntry=bldStatEntry("");
- be=(BackendImpl) DirectoryServer.getBackend(beID);
- be.verifyBackend(verifyConfig, configEntry, baseDNs, statEntry);
- }
-
- /* end tests */
-
- /**
- * Adds an entry to the id2entry database with a dn and id passed into the
- * method. Optional flag to set the Jeb version byte for those types of tests.
- * @param dn the dn string to put in the entry.
- * @param id to use as the id2entry key,
- * @param trashFormat true if first byte should be changed to invalid value.
- * @return Database entry key of the entry.
- * @throws Exception if the entry is not added to the id2entry database.
- */
- private DatabaseEntry addID2EntryReturnKey(String dn, long id, boolean trashFormat)
- throws Exception {
- DatabaseEntry key= new EntryID(id).getDatabaseEntry();
- Entry testEntry=bldStatEntry(dn);
- byte []entryBytes =
- JebFormat.entryToDatabase(testEntry, new DataConfig());
- if(trashFormat)
- entryBytes[0] = 0x67;
- DatabaseEntry data= new DatabaseEntry(entryBytes);
- assertTrue(id2entry.putRaw(txn, key, data));
- return key;
- }
-
- /**
- * Wrapper to do a clean verify.
- * @param indexToDo index file to run verify against.
- * @param expectedErrors number of errors expected for this test.
- * @throws Exception if the verify fails.
- */
- private void performBECleanVerify(String indexToDo,
- int expectedErrors) throws Exception {
- performBEVerify(indexToDo, expectedErrors, true);
- }
-
- /**
- * Wrapper to do a complete verify.
- * @param indexToDo index file to run verify against.
- * @param expectedErrors number of errors expected for this test.
- * @throws Exception if the verify fails.
- */
- private void performBECompleteVerify(String indexToDo,
- int expectedErrors) throws Exception {
- performBEVerify(indexToDo, expectedErrors, false);
- }
-
- /**
- * Performs either a clean or complete verify depending on
- * flag passed in.
- *
- * @param indexToDo index file to run verify against.
- * @param expectedErrors number of errors expected for this test.
- * @param clean do clean verify if true.
- * @throws Exception if the verify fails.
- */
- private void performBEVerify(String indexToDo,
- int expectedErrors, boolean clean) throws Exception {
- EntryContainer.transactionCommit(txn);
- VerifyConfig verifyConfig = new VerifyConfig();
- verifyConfig.setBaseDN(baseDNs[0]);
- if(!clean)
- verifyConfig.addCompleteIndex(indexToDo);
- else
- verifyConfig.addCleanIndex(indexToDo);
- Entry statEntry=bldStatEntry("");
- be.verifyBackend(verifyConfig, configEntry, baseDNs, statEntry);
- assertEquals(getStatEntryCount(statEntry, errorCount), expectedErrors);
- }
-
-
- /**
- * Does a pretest setup. Creates some number of entries, gets
- * backend, rootcontainer, entryContainer objects, as well as
- * various index objects.
- * Also starts a transaction.
- * @param numEntries number of entries to add to the verify backend.
- * @throws Exception if entries cannot be loaded.
- */
- private void preTest(int numEntries) throws Exception {
- cleanAndLoad(numEntries);
- be=(BackendImpl) DirectoryServer.getBackend(beID);
- rContainer= be.getRootContainer();
- eContainer= rContainer.getEntryContainer(DN.decode(suffix));
- id2child=eContainer.getID2Children();
- id2entry=eContainer.getID2Entry();
- id2subtree=eContainer.getID2Subtree();
- dn2id=eContainer.getDN2ID();
- txn = eContainer.beginTransaction();
- }
-
- /**
- * Cleans verify backend and loads some number of entries.
- * @param numEntries number of entries to load into the backend.
- * @throws Exception if the entries are not loaded or created.
- */
- private void cleanAndLoad(int numEntries) throws Exception {
- TestCaseUtils.clearJEBackend(false, beID, suffix);
- template[2]=numUsersLine;
- template[2]=
- template[2].replaceAll("#numEntries#", String.valueOf(numEntries));
- createLoadEntries(template, numEntries);
- }
+ //set version correctly
+ eBytes[0]=0x01;
+ DatabaseEntry data1= new DatabaseEntry(eBytes);
+ assertTrue(id2entry.putRaw(txn, key1, data1));
+ performBECompleteVerify("telephoneNumber", 3);
+ }
- /**
- * Gets information from the stat entry and returns that value as a Long.
- * @param e entry to search.
- * @param type attribute type
- * @return Long
- * @throws NumberFormatException if the attribute value cannot be parsed.
- */
- private long getStatEntryCount(Entry e, String type)
- throws NumberFormatException {
- AttributeType attrType =
- DirectoryServer.getAttributeType(type);
- if (attrType == null)
- attrType = DirectoryServer.getDefaultAttributeType(type);
- List<Attribute> attrList = e.getAttribute(attrType, null);
- LinkedHashSet<AttributeValue> values =
- attrList.get(0).getValues();
- AttributeValue v = values.iterator().next();
- long retVal = Long.parseLong(v.getStringValue());
- return (retVal);
- }
+ /**
+ *
+ * Runs complete verify against the dn2id index
+ * after adding various errors in the dn2id file.
+ *
+ * @throws Exception if the error count is not equal to 3.
+ */
+ @Test() public void testVerifyDN2ID() throws Exception {
+ preTest(9);
+ //add entry but no corresponding dn2id key
+ addID2EntryReturnKey(junkDN, 10, false);
+ //entry has dn2id key but its entryID -- don't need key
+ addID2EntryReturnKey(junkDN1, 11, false);
+ //insert key with bad entry id (45 instead of 10)
+ DN testDN=DN.decode(junkDN1);
+ EntryID id=new EntryID(45);
+ assertTrue(dn2id.insert(txn, testDN, id));
+ //entry has no parent in dn2id
+ addID2EntryReturnKey(noParentDN, 12, false);
+ //add the key/id
+ testDN=DN.decode(noParentDN);
+ id=new EntryID(12);
+ assertTrue(dn2id.insert(txn, testDN, id));
+ performBECompleteVerify("dn2id", 3);
+ }
- /**
- * Builds an entry suitable for using in the verify job to gather statistics about
- * the verify.
- * @param dn to put into the entry.
- * @return a suitable entry.
- * @throws DirectoryException if the cannot be created.
- */
- private Entry bldStatEntry(String dn) throws DirectoryException {
- DN entryDN = DN.decode(dn);
- HashMap<ObjectClass, String> ocs = new HashMap<ObjectClass, String>(2);
- ObjectClass topOC = DirectoryServer.getObjectClass(OC_TOP);
- if (topOC == null) {
- topOC = DirectoryServer.getDefaultObjectClass(OC_TOP);
- }
- ocs.put(topOC, OC_TOP);
- ObjectClass extensibleObjectOC = DirectoryServer
- .getObjectClass(OC_EXTENSIBLE_OBJECT);
- if (extensibleObjectOC == null) {
- extensibleObjectOC = DirectoryServer
- .getDefaultObjectClass(OC_EXTENSIBLE_OBJECT);
- }
- ocs.put(extensibleObjectOC, OC_EXTENSIBLE_OBJECT);
- return new Entry(entryDN, ocs,
- new LinkedHashMap<AttributeType, List<Attribute>>(0),
- new HashMap<AttributeType, List<Attribute>>(0));
+ /**
+ *
+ * Runs complete verify against the id2children index
+ * after adding various errors in the id2children file.
+ *
+ * @throws Exception if the error count is not equal to 3.
+ */
+ @Test() public void testVerifyID2Children() throws Exception {
+ preTest(9);
+ //Add dn with no parent
+ DatabaseEntry key=addID2EntryReturnKey(noParentDN, 10, false);
+ byte[] idBytes=new byte[16];
+ idBytes[7]=(byte) 0x0A;
+ EntryIDSet idSet=new EntryIDSet(null, idBytes);
+ id2child.writeKey(txn, key, idSet);
+ //Add child entry - don't worry about key
+ addID2EntryReturnKey(cDN, 11, false);
+ //Add its parent entry -- need the key
+ DatabaseEntry keyp=addID2EntryReturnKey(pDN, 12, false);
+ //add parent key/IDSet with bad IDset id
+ byte[] idBytesp=new byte[16];
+ idBytesp[7]=(byte) 0xFF;
+ EntryIDSet idSetp=new EntryIDSet(null, idBytesp);
+ id2child.writeKey(txn, keyp, idSetp);
+ performBECompleteVerify("id2children", 3);
+ }
+
+ /**
+ *
+ * Runs complete verify against the id2children index
+ * after adding various errors in the id2children file.
+ * This is a second test because the key needed to have
+ * null idlist. This test is really just for coverage and
+ * should have a 0 error count.
+ *
+ * @throws Exception if the error count is not equal to 0.
+ */
+ @Test() public void testVerifyID2Children1() throws Exception {
+ preTest(2);
+ //Add child entry - don't worry about key
+ addID2EntryReturnKey(pDN, 10, false);
+ //add parent key/IDSet with null keyset
+ EntryIDSet idSetp=new EntryIDSet();
+ DatabaseEntry key= new EntryID(2).getDatabaseEntry();
+ id2child.writeKey(txn, key, idSetp);
+ performBECompleteVerify("id2children", 0);
+ }
+
+ /**
+ *
+ * Runs complete verify against the id2subtree index
+ * after adding various errors in the id2subtree file.
+ *
+ * @throws Exception if the error count is not equal to 3.
+ */
+ @Test
+ public void testVerifyID2Subtree() throws Exception {
+ preTest(2);
+ //Add entry with no parent
+ addID2EntryReturnKey(noParentDN, 3, false);
+ performBECompleteVerify("id2subtree", 3);
+ }
+
+ /**
+ *
+ * Runs complete verify against the id2subtree index
+ * after adding various errors in the id2subtree file.
+ * This is a second test because the key needed to have
+ * null idlist.
+ *
+ * @throws Exception if the error count is not equal to 1.
+ */
+ @Test
+ public void testVerifyID2Subtree1() throws Exception {
+ preTest(2);
+ //Add child entry - don't worry about key
+ addID2EntryReturnKey(pDN, 3, false);
+ //add parent key/IDSet with null keyset
+ EntryIDSet idSet=new EntryIDSet();
+ DatabaseEntry key= new EntryID(2).getDatabaseEntry();
+ id2subtree.writeKey(txn, key, idSet);
+ performBECompleteVerify("id2subtree", 1);
+ }
+
+ /**
+ * Runs complete verify against the mail indexes
+ * (equality, presence, substring, ordering)
+ * after adding various errors to each of these index files.
+ * @throws Exception if the error count is not equal to 6.
+ */
+ @Test() public void testVerifyAttribute() throws Exception {
+ String mailType="mail";
+ preTest(4);
+ //Need to open a second databases against this index
+ //so we can manipulate it.
+ DatabaseConfig config = new DatabaseConfig();
+ config.setAllowCreate(true);
+ config.setTransactional(true);
+ //Get db handles to each index.
+ Database dbEq=
+ eContainer.openDatabase(config, mailType + ".equality");
+ Database dbPres=
+ eContainer.openDatabase(config, mailType + ".presence");
+ Database dbSub=
+ eContainer.openDatabase(config, mailType + ".substring");
+ Database dbOr=
+ eContainer.openDatabase(config, mailType + ".ordering");
+ //Add invalid idlist ids to both equality and ordering indexes.
+ DatabaseEntry key=
+ new DatabaseEntry(StaticUtils.getBytes("user.0@example.com"));
+ byte[] dataBytes=new byte[16];
+ //put duplicate ids in list
+ dataBytes[7] = (byte)0xff;
+ dataBytes[15] = (byte)0xfe;
+ DatabaseEntry data= new DatabaseEntry(dataBytes);
+ OperationStatus status = EntryContainer.put(dbEq, txn, key, data);
+ assertTrue(status == OperationStatus.SUCCESS);
+ status = EntryContainer.put(dbOr, txn, key, data);
+ assertTrue(status == OperationStatus.SUCCESS);
+ //Add null idlist to both equality and ordering indexes.
+ key =
+ new DatabaseEntry(StaticUtils.getBytes("user.1@example.com"));
+ data= new DatabaseEntry(new EntryIDSet().toDatabase());
+ status = EntryContainer.put(dbEq, txn, key, data);
+ assertTrue(status == OperationStatus.SUCCESS);
+ status = EntryContainer.put(dbOr, txn, key, data);
+ assertTrue(status == OperationStatus.SUCCESS);
+ //Add invalid idlist ids to presence index.
+ key =
+ new DatabaseEntry(StaticUtils.getBytes("+"));
+ data = new DatabaseEntry(dataBytes);
+ status = EntryContainer.put(dbPres, txn, key, data);
+ assertTrue(status == OperationStatus.SUCCESS);
+ //Add invalid idlist ids to substring index.
+ key =
+ new DatabaseEntry(StaticUtils.getBytes("@examp"));
+ data = new DatabaseEntry(dataBytes);
+ status = EntryContainer.put(dbSub, txn, key, data);
+ assertTrue(status == OperationStatus.SUCCESS);
+ performBECompleteVerify(mailType, 6);
+ }
+
+ /* Various tests not either clean or complete */
+
+
+ /**
+ * Try to verify a non-indexed attribute.
+ * @throws Exception if error count is not equal to 0.
+ */
+ @Test(expectedExceptions=Exception.class)
+ public void testVerifyNotIndexed() throws Exception {
+ cleanAndLoad(2);
+ VerifyConfig verifyConfig = new VerifyConfig();
+ verifyConfig.setBaseDN(baseDNs[0]);
+ verifyConfig.addCleanIndex("userPassword");
+ Entry statEntry=bldStatEntry("");
+ be=(BackendImpl) DirectoryServer.getBackend(beID);
+ be.verifyBackend(verifyConfig, statEntry);
+ assertEquals(getStatEntryCount(statEntry, errorCount), 0);
+ }
+
+ /**
+ * Try to verify an nonexistent attribute.
+ * @throws Exception if verify backend fails.
+ */
+ @Test(expectedExceptions=Exception.class)
+ public void testInvalidIndex() throws Exception {
+ cleanAndLoad(2);
+ VerifyConfig verifyConfig = new VerifyConfig();
+ verifyConfig.setBaseDN(baseDNs[0]);
+ verifyConfig.addCleanIndex(badIndexName);
+ Entry statEntry=bldStatEntry("");
+ be=(BackendImpl) DirectoryServer.getBackend(beID);
+ be.verifyBackend(verifyConfig, statEntry);
+ }
+
+ /* end tests */
+
+ /**
+ * Adds an entry to the id2entry database with a dn and id passed into the
+ * method. Optional flag to set the Jeb version byte for those types of tests.
+ * @param dn the dn string to put in the entry.
+ * @param id to use as the id2entry key,
+ * @param trashFormat true if first byte should be changed to invalid value.
+ * @return Database entry key of the entry.
+ * @throws Exception if the entry is not added to the id2entry database.
+ */
+ private DatabaseEntry addID2EntryReturnKey(String dn, long id, boolean trashFormat)
+ throws Exception {
+ DatabaseEntry key= new EntryID(id).getDatabaseEntry();
+ Entry testEntry=bldStatEntry(dn);
+ byte []entryBytes =
+ JebFormat.entryToDatabase(testEntry, new DataConfig());
+ if(trashFormat)
+ entryBytes[0] = 0x67;
+ DatabaseEntry data= new DatabaseEntry(entryBytes);
+ assertTrue(id2entry.putRaw(txn, key, data));
+ return key;
+ }
+
+ /**
+ * Wrapper to do a clean verify.
+ * @param indexToDo index file to run verify against.
+ * @param expectedErrors number of errors expected for this test.
+ * @throws Exception if the verify fails.
+ */
+ private void performBECleanVerify(String indexToDo,
+ int expectedErrors) throws Exception {
+ performBEVerify(indexToDo, expectedErrors, true);
+ }
+
+ /**
+ * Wrapper to do a complete verify.
+ * @param indexToDo index file to run verify against.
+ * @param expectedErrors number of errors expected for this test.
+ * @throws Exception if the verify fails.
+ */
+ private void performBECompleteVerify(String indexToDo,
+ int expectedErrors) throws Exception {
+ performBEVerify(indexToDo, expectedErrors, false);
+ }
+
+ /**
+ * Performs either a clean or complete verify depending on
+ * flag passed in.
+ *
+ * @param indexToDo index file to run verify against.
+ * @param expectedErrors number of errors expected for this test.
+ * @param clean do clean verify if true.
+ * @throws Exception if the verify fails.
+ */
+ private void performBEVerify(String indexToDo,
+ int expectedErrors, boolean clean) throws Exception {
+ EntryContainer.transactionCommit(txn);
+ VerifyConfig verifyConfig = new VerifyConfig();
+ verifyConfig.setBaseDN(baseDNs[0]);
+ if(!clean)
+ verifyConfig.addCompleteIndex(indexToDo);
+ else
+ verifyConfig.addCleanIndex(indexToDo);
+ Entry statEntry=bldStatEntry("");
+ be.verifyBackend(verifyConfig, statEntry);
+ assertEquals(getStatEntryCount(statEntry, errorCount), expectedErrors);
+ }
+
+
+ /**
+ * Does a pretest setup. Creates some number of entries, gets
+ * backend, rootcontainer, entryContainer objects, as well as
+ * various index objects.
+ * Also starts a transaction.
+ * @param numEntries number of entries to add to the verify backend.
+ * @throws Exception if entries cannot be loaded.
+ */
+ private void preTest(int numEntries) throws Exception {
+ cleanAndLoad(numEntries);
+ be=(BackendImpl) DirectoryServer.getBackend(beID);
+ RootContainer rContainer = be.getRootContainer();
+ eContainer= rContainer.getEntryContainer(DN.decode(suffix));
+ id2child=eContainer.getID2Children();
+ id2entry=eContainer.getID2Entry();
+ id2subtree=eContainer.getID2Subtree();
+ dn2id=eContainer.getDN2ID();
+ txn = eContainer.beginTransaction();
+ }
+
+ /**
+ * Cleans verify backend and loads some number of entries.
+ * @param numEntries number of entries to load into the backend.
+ * @throws Exception if the entries are not loaded or created.
+ */
+ private void cleanAndLoad(int numEntries) throws Exception {
+ TestCaseUtils.clearJEBackend(false, beID, suffix);
+ template[2]=numUsersLine;
+ template[2]=
+ template[2].replaceAll("#numEntries#", String.valueOf(numEntries));
+ createLoadEntries(template, numEntries);
+ }
+
+ /**
+ * Gets information from the stat entry and returns that value as a Long.
+ * @param e entry to search.
+ * @param type attribute type
+ * @return Long
+ * @throws NumberFormatException if the attribute value cannot be parsed.
+ */
+ private long getStatEntryCount(Entry e, String type)
+ throws NumberFormatException {
+ AttributeType attrType =
+ DirectoryServer.getAttributeType(type);
+ if (attrType == null)
+ attrType = DirectoryServer.getDefaultAttributeType(type);
+ List<Attribute> attrList = e.getAttribute(attrType, null);
+ LinkedHashSet<AttributeValue> values =
+ attrList.get(0).getValues();
+ AttributeValue v = values.iterator().next();
+ long retVal = Long.parseLong(v.getStringValue());
+ return (retVal);
+ }
+
+ /**
+ * Builds an entry suitable for using in the verify job to gather statistics about
+ * the verify.
+ * @param dn to put into the entry.
+ * @return a suitable entry.
+ * @throws DirectoryException if the cannot be created.
+ */
+ private Entry bldStatEntry(String dn) throws DirectoryException {
+ DN entryDN = DN.decode(dn);
+ HashMap<ObjectClass, String> ocs = new HashMap<ObjectClass, String>(2);
+ ObjectClass topOC = DirectoryServer.getObjectClass(OC_TOP);
+ if (topOC == null) {
+ topOC = DirectoryServer.getDefaultObjectClass(OC_TOP);
}
+ ocs.put(topOC, OC_TOP);
+ ObjectClass extensibleObjectOC = DirectoryServer
+ .getObjectClass(OC_EXTENSIBLE_OBJECT);
+ if (extensibleObjectOC == null) {
+ extensibleObjectOC = DirectoryServer
+ .getDefaultObjectClass(OC_EXTENSIBLE_OBJECT);
+ }
+ ocs.put(extensibleObjectOC, OC_EXTENSIBLE_OBJECT);
+ return new Entry(entryDN, ocs,
+ new LinkedHashMap<AttributeType, List<Attribute>>(0),
+ new HashMap<AttributeType, List<Attribute>>(0));
+ }
}
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/tools/ImportLDIFTestCase.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/tools/ImportLDIFTestCase.java
index 7779193..b0b2e08 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/tools/ImportLDIFTestCase.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/tools/ImportLDIFTestCase.java
@@ -26,35 +26,21 @@
*/
package org.opends.server.tools;
-import static org.opends.server.config.ConfigConstants.DN_BACKEND_BASE;
import org.testng.annotations.BeforeClass;
-import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.opends.server.TestCaseUtils;
-import org.opends.server.config.ConfigEntry;
-import org.opends.server.util.Base64;
-import org.opends.server.api.Backend;
-import org.opends.server.backends.jeb.BackendImpl;
import org.opends.server.core.DirectoryServer;
-import org.opends.server.core.LockFileManager;
import static org.testng.Assert.*;
import java.io.*;
import java.util.*;
-import org.testng.annotations.BeforeClass;
import org.testng.annotations.AfterClass;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-import org.opends.server.tools.ToolsTestCase;
import org.opends.server.tasks.TaskUtils;
-import org.opends.server.tools.ImportLDIF;
-import org.opends.server.types.ResultCode;
import org.opends.server.types.Entry;
import org.opends.server.types.DN;
import org.opends.server.types.Attribute;
-import static org.testng.Assert.*;
@@ -63,9 +49,7 @@
private File tempDir;
private String ldifFilePath;
String configFilePath ;
- private BackendImpl backend;
private String homeDirName;
- private ConfigEntry backendConfigEntry;
private String beID;
/**
@@ -78,10 +62,8 @@
{
TestCaseUtils.startServer();
beID = "userRoot";
- configFilePath = DirectoryServer.getInstance().getConfigFile();
- backend = (BackendImpl)DirectoryServer.getBackend(beID);
- backendConfigEntry = TaskUtils.getConfigEntry(backend);
- TaskUtils.setBackendEnabled(backendConfigEntry, false);
+ configFilePath = DirectoryServer.getConfigFile();
+ TaskUtils.disableBackend(beID);
String entry =
"dn: dc=example,dc=com\n" +
@@ -194,7 +176,7 @@
String rejectFilePath = reject.getAbsolutePath();
String[] args =
{
- "-f", DirectoryServer.getInstance().getConfigFile(),
+ "-f", DirectoryServer.getConfigFile(),
"-l",ldifFilePath,
"-n", beID,
"-R", rejectFilePath
@@ -231,7 +213,7 @@
String[] args =
{
- "-f", DirectoryServer.getInstance().getConfigFile(),
+ "-f", DirectoryServer.getConfigFile(),
"-l",ldifFilePath,
"-n", beID,
"-R",rejectFilePath,
@@ -263,7 +245,7 @@
String rejectFilePath = reject.getAbsolutePath();
String[] args =
{
- "-f", DirectoryServer.getInstance().getConfigFile(),
+ "-f", DirectoryServer.getConfigFile(),
"-l",ldifFilePath,
"-n", beID,
"-R",rejectFilePath,
@@ -289,7 +271,7 @@
String rejectFilePath = reject.getAbsolutePath();
String[] args =
{
- "-f", DirectoryServer.getInstance().getConfigFile(),
+ "-f", DirectoryServer.getConfigFile(),
"-l",ldifFilePath,
"-n", beID,
"-R",rejectFilePath,
@@ -320,7 +302,7 @@
String rejectFilePath = reject.getAbsolutePath();
String[] args =
{
- "-f", DirectoryServer.getInstance().getConfigFile(),
+ "-f", DirectoryServer.getConfigFile(),
"-l",ldifFilePath,
"-n", beID,
"-R",rejectFilePath,
@@ -351,7 +333,7 @@
String rejectFilePath = reject.getAbsolutePath();
String[] args =
{
- "-f", DirectoryServer.getInstance().getConfigFile(),
+ "-f", DirectoryServer.getConfigFile(),
"-l",ldifFilePath,
"-n", beID,
"-R",rejectFilePath,
@@ -390,7 +372,7 @@
String rejectFilePath = reject.getAbsolutePath();
String[] args =
{
- "-f", DirectoryServer.getInstance().getConfigFile(),
+ "-f", DirectoryServer.getConfigFile(),
"-l",ldifFilePath,
"-n", beID,
"-R",rejectFilePath,
@@ -446,21 +428,21 @@
{
if(attrs != null && attrs.length > 0)
{
- TaskUtils.setBackendEnabled(backendConfigEntry, true);
+ TaskUtils.enableBackend(beID);
Entry entry = DirectoryServer.getEntry(DN.decode(
" uid=user.0,dc=example,dc=com"));
- TaskUtils.setBackendEnabled(backendConfigEntry,false);
+ TaskUtils.disableBackend(beID);
assertNotNull(entry);
List<Attribute> list = entry.getAttributes();
- for(int i=0;i<attrs.length;i++)
+ for(Attribute a : attrs)
{
if(assertType)
{
- assertTrue(list.contains(attrs[i]));
+ assertTrue(list.contains(a));
}
else
{
- assertFalse(list.contains(attrs[i]));
+ assertFalse(list.contains(a));
}
}
}
@@ -477,7 +459,7 @@
public void cleanUp() throws Exception
{
//reinstate the backend.
- TaskUtils.setBackendEnabled(backendConfigEntry, true);
+ TaskUtils.enableBackend(beID);
TestCaseUtils.deleteDirectory(tempDir);
}
}
--
Gitblit v1.10.0