From d10da5e09878c255bd3b685fa87a04610db7d404 Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Mon, 04 Apr 2016 13:38:34 +0000
Subject: [PATCH] Fix compilation errors
---
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/DeleteSchemaElementsTask.java | 2
opendj-server-legacy/src/main/java/org/opends/server/core/ConfigurationBootstrapper.java | 32 +
opendj-server-legacy/src/main/java/org/opends/server/api/plugin/InternalDirectoryServerPlugin.java | 4
opendj-server-legacy/src/test/java/org/opends/server/schema/ConfigurableAttributeSyntaxTest.java | 8
opendj-server-legacy/src/main/java/org/opends/server/core/PluginConfigManager.java | 2
opendj-server-legacy/src/test/java/org/opends/server/api/plugin/DirectoryServerPluginTestCase.java | 7
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/NewSchemaElementsTask.java | 2
opendj-server-legacy/src/test/java/org/opends/server/extensions/BcryptPasswordStorageSchemeTestCase.java | 5
opendj-server-legacy/src/test/java/org/opends/server/replication/ProtocolWindowTest.java | 3
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/ResetUserPasswordTask.java | 2
opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/AciHandler.java | 5
opendj-server-legacy/src/main/java/org/opends/server/tools/LDIFDiff.java | 4
opendj-server-legacy/src/test/java/org/opends/server/replication/ReplicationTestCase.java | 3
opendj-server-legacy/src/test/java/org/opends/server/replication/GenerationIdTest.java | 7
opendj-server-legacy/src/main/java/org/opends/server/tools/LDIFSearch.java | 4
opendj-server-legacy/src/main/java/org/opends/server/types/DirectoryEnvironmentConfig.java | 14
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/ServerDescriptor.java | 7
opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/FractionalLDIFImportPlugin.java | 5
opendj-server-legacy/src/test/java/org/opends/server/backends/pluggable/DN2IDTest.java | 5
opendj-server-legacy/src/main/java/org/opends/server/core/MatchingRuleConfigManager.java | 3
opendj-server-legacy/src/main/java/org/opends/quicksetup/installer/InstallerHelper.java | 2
opendj-server-legacy/src/main/java/org/opends/server/tools/ExportLDIF.java | 5
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/Task.java | 6
opendj-server-legacy/src/test/java/org/opends/server/backends/jeb/JETestCase.java | 4
opendj-server-legacy/src/main/java/org/opends/server/api/plugin/DirectoryServerPlugin.java | 19
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/BackendStat.java | 5
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/ConfigReader.java | 7
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/ConfigFromFile.java | 7
opendj-server-legacy/src/main/java/org/opends/server/tools/BackendToolUtils.java | 75 +-
opendj-server-legacy/src/main/java/org/opends/server/loggers/CommonAudit.java | 32
opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/AssuredReplicationPluginTest.java | 5
opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/LDAPReplicationDomain.java | 14
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/DeleteIndexTask.java | 2
opendj-server-legacy/src/test/java/org/opends/server/backends/pluggable/pdb/PDBTestCase.java | 4
opendj-server-legacy/src/test/java/org/opends/server/backends/pluggable/StateTest.java | 4
opendj-server-legacy/src/main/java/org/opends/server/core/DirectoryServer.java | 242 +--------
opendj-server-legacy/src/test/java/org/opends/server/backends/pluggable/ControlsTestCase.java | 6
opendj-server-legacy/src/main/java/org/opends/server/tools/LDIFModify.java | 5
opendj-server-legacy/src/main/java/org/opends/server/tools/EncodePassword.java | 7
opendj-server-legacy/src/main/java/org/opends/server/tools/ListBackends.java | 65 -
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/AddToGroupTask.java | 4
opendj-server-legacy/src/test/java/org/opends/server/tools/ImportLDIFTestCase.java | 4
opendj-server-legacy/src/test/java/org/opends/server/core/PasswordPolicyTestCase.java | 7
opendj-server-legacy/src/main/java/org/opends/server/types/DirectoryConfig.java | 17
opendj-server-legacy/src/main/java/org/opends/server/tools/VerifyIndex.java | 4
opendj-server-legacy/src/test/java/org/opends/server/TestCaseUtils.java | 37 -
opendj-server-legacy/src/main/java/org/opends/server/tools/BackUpDB.java | 5
opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/UpgradeCli.java | 5
opendj-server-legacy/src/main/java/org/opends/server/tools/ImportLDIF.java | 5
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/AbstractVLVIndexPanel.java | 3
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/StatusPanel.java | 36
opendj-server-legacy/src/main/java/org/opends/server/core/BackendConfigManager.java | 5
opendj-server-legacy/src/main/java/org/opends/server/tasks/TaskUtils.java | 101 +--
opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendCompareOperation.java | 3
opendj-server-legacy/src/test/java/org/opends/server/ServerContextBuilder.java | 4
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/Utilities.java | 15
opendj-server-legacy/src/main/java/org/opends/server/admin/AdministrationConnector.java | 11
opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/FractionalReplicationTest.java | 3
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/DeleteBaseDNAndBackendTask.java | 9
opendj-server-legacy/src/main/java/org/opends/server/tools/RebuildIndex.java | 5
/dev/null | 149 ------
opendj-server-legacy/src/main/java/org/forgerock/opendj/adapter/server3x/Converters.java | 32 -
opendj-server-legacy/src/main/java/org/opends/server/tools/ConfigureDS.java | 287 +++++++----
opendj-server-legacy/src/test/java/org/opends/server/backends/pluggable/ID2ChildrenCountTest.java | 5
opendj-server-legacy/src/main/java/org/opends/server/extensions/ConfigFileHandler.java | 2
opendj-server-legacy/src/main/java/org/opends/server/tools/dsreplication/ReplicationCliArgumentParser.java | 4
opendj-server-legacy/src/main/java/org/opends/server/tools/RestoreDB.java | 5
opendj-server-legacy/src/test/java/org/opends/server/extensions/ErrorLogAccountStatusNotificationHandlerTestCase.java | 9
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/NewEntryTask.java | 2
69 files changed, 538 insertions(+), 880 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/forgerock/opendj/adapter/server3x/Converters.java b/opendj-server-legacy/src/main/java/org/forgerock/opendj/adapter/server3x/Converters.java
index 1dab49b..08f30e3 100644
--- a/opendj-server-legacy/src/main/java/org/forgerock/opendj/adapter/server3x/Converters.java
+++ b/opendj-server-legacy/src/main/java/org/forgerock/opendj/adapter/server3x/Converters.java
@@ -17,7 +17,6 @@
import static com.forgerock.opendj.ldap.CoreMessages.*;
import static com.forgerock.opendj.util.StaticUtils.*;
-
import static org.forgerock.opendj.ldap.LdapException.*;
import static org.opends.server.extensions.ExtensionsConstants.*;
import static org.opends.server.util.CollectionUtils.*;
@@ -46,8 +45,7 @@
import org.forgerock.opendj.ldap.responses.Responses;
import org.forgerock.opendj.ldap.responses.Result;
import org.forgerock.opendj.ldap.responses.SearchResultEntry;
-import org.forgerock.opendj.server.config.meta.BackendVLVIndexCfgDefn;
-import org.forgerock.util.Reject;
+import org.forgerock.opendj.server.config.meta.VirtualAttributeCfgDefn;
import org.opends.server.core.BindOperation;
import org.opends.server.core.CompareOperation;
import org.opends.server.core.DirectoryServer;
@@ -525,7 +523,7 @@
* The server scope value.
* @return The SDK scope value.
*/
- public static SearchScope from(org.opends.server.admin.std.meta.VirtualAttributeCfgDefn.Scope srvScope) {
+ public static SearchScope from(VirtualAttributeCfgDefn.Scope srvScope) {
if (srvScope != null) {
switch (srvScope) {
case BASE_OBJECT:
@@ -656,30 +654,4 @@
}
return ByteString.empty();
}
-
- /**
- * Converts from OpenDJ server
- * {@link org.opends.server.admin.std.meta.BackendVLVIndexCfgDefn.Scope} to
- * {@link org.forgerock.opendj.server.config.meta.BackendVLVIndexCfgDefn.Scope}.
- *
- * @param scope
- * The scope value.
- * @return The converted scope value.
- */
- public static BackendVLVIndexCfgDefn.Scope from(
- final org.opends.server.admin.std.meta.BackendVLVIndexCfgDefn.Scope scope) {
- Reject.ifNull(scope, "Provided scope to convert is null");
- switch (scope) {
- case BASE_OBJECT:
- return BackendVLVIndexCfgDefn.Scope.BASE_OBJECT;
- case SINGLE_LEVEL:
- return BackendVLVIndexCfgDefn.Scope.SINGLE_LEVEL;
- case SUBORDINATE_SUBTREE:
- return BackendVLVIndexCfgDefn.Scope.SUBORDINATE_SUBTREE;
- case WHOLE_SUBTREE:
- return BackendVLVIndexCfgDefn.Scope.WHOLE_SUBTREE;
- default:
- throw new IllegalArgumentException("Impossible to convert the unknown scope: " + scope);
- }
- }
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/ServerDescriptor.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/ServerDescriptor.java
index ced5354..c818e51 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/ServerDescriptor.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/ServerDescriptor.java
@@ -34,7 +34,6 @@
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.ldap.DN;
import org.opends.server.types.ObjectClass;
-import org.opends.server.types.OpenDsException;
import org.opends.server.types.Schema;
import com.forgerock.opendj.util.OperatingSystem;
@@ -61,7 +60,7 @@
private String instancePath;
private String openDSVersion;
private String javaVersion;
- private ArrayList<OpenDsException> exceptions = new ArrayList<>();
+ private ArrayList<Exception> exceptions = new ArrayList<>();
private boolean isWindowsServiceEnabled;
private boolean isSchemaEnabled;
private Schema schema;
@@ -467,7 +466,7 @@
* Returns the exceptions that occurred while reading the configuration.
* @return the exceptions that occurred while reading the configuration.
*/
- public List<OpenDsException> getExceptions()
+ public List<Exception> getExceptions()
{
return Collections.unmodifiableList(exceptions);
}
@@ -477,7 +476,7 @@
* @param exceptions exceptions that occurred while reading the
* configuration.
*/
- public void setExceptions(Collection<OpenDsException> exceptions)
+ public void setExceptions(Collection<Exception> exceptions)
{
this.exceptions.clear();
this.exceptions.addAll(exceptions);
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/AddToGroupTask.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/AddToGroupTask.java
index 19ce5f8..1bd0c67 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/AddToGroupTask.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/AddToGroupTask.java
@@ -177,7 +177,7 @@
}
});
- getInfo().getDirContext().modifyAttributes(
+ getInfo().getConnection().getLdapContext().modifyAttributes(
Utilities.getJNDIName(groupDn.toString()), mods);
SwingUtilities.invokeLater(new Runnable()
@@ -224,7 +224,7 @@
});
String filter = BrowserController.ALL_OBJECTS_FILTER;
NamingEnumeration<SearchResult> result =
- getInfo().getDirContext().search(
+ getInfo().getConnection().getLdapContext().search(
Utilities.getJNDIName(groupDn.toString()),
filter, ctls);
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/DeleteBaseDNAndBackendTask.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/DeleteBaseDNAndBackendTask.java
index d1ac934..8ce4d95 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/DeleteBaseDNAndBackendTask.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/DeleteBaseDNAndBackendTask.java
@@ -428,7 +428,7 @@
String backendName = backend.getBackendID();
DN dn = DN.valueOf("ds-cfg-backend-id" + "=" + backendName + ",cn=Backends,cn=config");
- Entry configEntry = DirectoryServer.getConfigHandler().getConfigEntry(dn);
+ Entry configEntry = DirectoryServer.getConfigurationHandler().getConfigEntry(dn);
DNConfigAttribute baseDNAttr =
new DNConfigAttribute(
@@ -436,7 +436,7 @@
INFO_CONFIG_BACKEND_ATTR_DESCRIPTION_BASE_DNS.get(),
true, true, false, newBaseDNs);
configEntry.putConfigAttribute(baseDNAttr);
- DirectoryServer.getConfigHandler().writeUpdatedConfig();
+ DirectoryServer.getConfigurationHandler().writeUpdatedConfig();
}
/**
@@ -476,7 +476,7 @@
private void deleteBackend(BackendDescriptor backend) throws OpenDsException, ConfigException
{
DN dn = DN.valueOf("ds-cfg-backend-id" + "=" + backend.getBackendID() + ",cn=Backends,cn=config");
- Utilities.deleteConfigSubtree(DirectoryServer.getConfigHandler(), dn);
+ Utilities.deleteConfigSubtree(DirectoryServer.getConfigurationHandler(), dn);
}
/**
@@ -660,8 +660,7 @@
{
domainName.set(dName);
DN entryDN = domain.dn();
- Utilities.deleteConfigSubtree(
- DirectoryServer.getConfigHandler(), entryDN);
+ Utilities.deleteConfigSubtree(DirectoryServer.getConfigurationHandler(), entryDN);
break;
}
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/DeleteIndexTask.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/DeleteIndexTask.java
index 3873f4b..203fc35 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/DeleteIndexTask.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/DeleteIndexTask.java
@@ -263,7 +263,7 @@
{
dn = "ds-cfg-attribute" + "=" + index.getName() + ",cn=Index," + backendId + ",cn=Backends,cn=config";
}
- DirectoryServer.getConfigHandler().deleteEntry(DN.valueOf(dn), null);
+ DirectoryServer.getConfigurationHandler().deleteEntry(DN.valueOf(dn), null);
}
/**
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/DeleteSchemaElementsTask.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/DeleteSchemaElementsTask.java
index 840157a..b0a8e23 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/DeleteSchemaElementsTask.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/DeleteSchemaElementsTask.java
@@ -288,7 +288,7 @@
BasicAttribute attr = new BasicAttribute(getSchemaFileAttributeName(element));
attr.add(getSchemaFileAttributeValue(element));
ModificationItem mod = new ModificationItem(DirContext.REMOVE_ATTRIBUTE, attr);
- getInfo().getDirContext().modifyAttributes(
+ getInfo().getConnection().getLdapContext().modifyAttributes(
ConfigConstants.DN_DEFAULT_SCHEMA_ROOT,
new ModificationItem[] { mod });
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/NewEntryTask.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/NewEntryTask.java
index 08fdc5c..15e6213 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/NewEntryTask.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/NewEntryTask.java
@@ -166,7 +166,7 @@
}
else
{
- ctx = getInfo().getDirContext();
+ ctx = getInfo().getConnection().getLdapContext();
useAdminCtx = true;
}
BasicAttributes attrs = new BasicAttributes();
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/NewSchemaElementsTask.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/NewSchemaElementsTask.java
index 77a7b27..775821f 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/NewSchemaElementsTask.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/NewSchemaElementsTask.java
@@ -322,7 +322,7 @@
final BasicAttribute attr = new BasicAttribute(schemaElement.getAttributeName());
attr.add(getElementDefinition(schemaElement));
final ModificationItem mod = new ModificationItem(DirContext.ADD_ATTRIBUTE, attr);
- getInfo().getDirContext().modifyAttributes(
+ getInfo().getConnection().getLdapContext().modifyAttributes(
ConfigConstants.DN_DEFAULT_SCHEMA_ROOT, new ModificationItem[] { mod });
}
catch (NamingException ne)
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/ResetUserPasswordTask.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/ResetUserPasswordTask.java
index 0f6e240..9835084 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/ResetUserPasswordTask.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/ResetUserPasswordTask.java
@@ -197,7 +197,7 @@
// The connections must be updated, just update the environment, which
// is what we use to clone connections and to launch scripts.
// The environment will also be used if we want to reconnect.
- getInfo().getDirContext().addToEnvironment(
+ getInfo().getConnection().getLdapContext().addToEnvironment(
Context.SECURITY_CREDENTIALS,
String.valueOf(newPassword));
if (getInfo().getUserDataDirContext() != null)
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/Task.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/Task.java
index e2ac99e..c14604c 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/Task.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/task/Task.java
@@ -18,7 +18,6 @@
import static com.forgerock.opendj.cli.Utils.*;
import static com.forgerock.opendj.util.OperatingSystem.*;
-
import static org.opends.messages.AdminToolMessages.*;
import java.io.File;
@@ -52,6 +51,7 @@
import org.opends.quicksetup.Installation;
import org.opends.quicksetup.UserData;
import org.forgerock.opendj.ldap.DN;
+import org.opends.server.core.ConfigurationHandler;
import org.opends.server.types.Schema;
import org.opends.server.util.Base64;
import org.opends.server.util.SetupUtils;
@@ -730,7 +730,7 @@
{
List<String> args = new ArrayList<>();
args.add("--configClass");
- args.add(org.opends.server.extensions.ConfigFileHandler.class.getName());
+ args.add(ConfigurationHandler.class.getName());
args.add("--configFile");
args.add(ConfigReader.configFile);
return args;
@@ -763,7 +763,7 @@
if (useAdminConnector)
{
- ctx = getInfo().getDirContext();
+ ctx = getInfo().getConnection().getLdapContext();
}
else
{
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/AbstractVLVIndexPanel.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/AbstractVLVIndexPanel.java
index 8c0274a..c7c537e 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/AbstractVLVIndexPanel.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/AbstractVLVIndexPanel.java
@@ -53,7 +53,6 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.LocalizedIllegalArgumentException;
-import org.forgerock.opendj.adapter.server3x.Converters;
import org.forgerock.opendj.config.LDAPProfile;
import org.forgerock.opendj.config.PropertyException;
import org.forgerock.opendj.config.client.ManagementContext;
@@ -1126,7 +1125,7 @@
if (isCreation || indexToModify.getScope() != searchScope)
{
- index.setScope(Converters.from(VLVIndexDescriptor.getBackendVLVIndexScope(searchScope)));
+ index.setScope(VLVIndexDescriptor.getBackendVLVIndexScope(searchScope));
}
if (isCreation || !indexToModify.getSortOrder().equals(sortOrder))
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/StatusPanel.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/StatusPanel.java
index f6f1fb9..67f9aaf 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/StatusPanel.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/StatusPanel.java
@@ -59,7 +59,8 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.LocalizableMessageBuilder;
import org.forgerock.opendj.ldap.DN;
-import org.opends.server.types.OpenDsException;
+import org.forgerock.opendj.ldap.LdapException;
+import org.forgerock.util.Utils;
/**
* The panel displaying the general status of the server (started/stopped),
@@ -222,7 +223,7 @@
pos = Utilities.getViewPositions(this);
}
- Collection<OpenDsException> exceptions = desc.getExceptions();
+ Collection<Exception> exceptions = desc.getExceptions();
if (exceptions.isEmpty())
{
boolean errorPaneVisible = false;
@@ -264,39 +265,32 @@
}
else
{
- ArrayList<LocalizableMessage> msgs = new ArrayList<>();
- for (OpenDsException oe : exceptions)
+ ArrayList<String> msgs = new ArrayList<>();
+ for (Exception e : exceptions)
{
- msgs.add(oe.getMessageObject());
+ msgs.add(e instanceof LdapException ? ((LdapException) e).getLocalizedMessage() : e.getMessage());
}
LocalizableMessage title = ERR_CTRL_PANEL_ERROR_READING_CONFIGURATION_SUMMARY.get();
- LocalizableMessageBuilder mb = new LocalizableMessageBuilder();
- for (LocalizableMessage error : msgs)
- {
- if (mb.length() > 0)
- {
- mb.append("<br>");
- }
- mb.append(error);
- }
+ StringBuilder sb = new StringBuilder();
+ Utils.joinAsString("<br>", msgs);
if (desc.getStatus() == ServerDescriptor.ServerStatus.STARTED)
{
if (!desc.isAuthenticated())
{
- mb.append("<br>");
- mb.append(INFO_CTRL_PANEL_AUTH_REQUIRED_TO_BROWSE_MONITORING_SUMMARY.get());
- mb.append("<br><br>").append(getAuthenticateHTML());
+ sb.append("<br>");
+ sb.append(INFO_CTRL_PANEL_AUTH_REQUIRED_TO_BROWSE_MONITORING_SUMMARY.get());
+ sb.append("<br><br>").append(getAuthenticateHTML());
}
}
else if (desc.getStatus() ==
ServerDescriptor.ServerStatus.NOT_CONNECTED_TO_REMOTE)
{
- mb.append("<br>");
- mb.append(INFO_CTRL_PANEL_CANNOT_CONNECT_TO_REMOTE_DETAILS.get(desc.getHostname()));
- mb.append("<br><br>").append(getAuthenticateHTML());
+ sb.append("<br>");
+ sb.append(INFO_CTRL_PANEL_CANNOT_CONNECT_TO_REMOTE_DETAILS.get(desc.getHostname()));
+ sb.append("<br><br>").append(getAuthenticateHTML());
}
updateErrorPane(errorPane, title, ColorAndFontConstants.errorTitleFont,
- mb.toMessage(), ColorAndFontConstants.defaultFont);
+ LocalizableMessage.raw(sb), ColorAndFontConstants.defaultFont);
if (!errorPane.isVisible())
{
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/ConfigFromFile.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/ConfigFromFile.java
index 92fbc40..a5679c1 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/ConfigFromFile.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/ConfigFromFile.java
@@ -42,7 +42,6 @@
import org.opends.guitools.controlpanel.datamodel.VLVIndexDescriptor;
import org.opends.guitools.controlpanel.datamodel.VLVSortOrder;
import org.opends.guitools.controlpanel.task.OfflineUpdateException;
-import org.forgerock.opendj.config.server.ServerManagementContext;
import org.forgerock.opendj.server.config.server.AdministrationConnectorCfg;
import org.forgerock.opendj.server.config.server.BackendCfg;
import org.forgerock.opendj.server.config.server.BackendIndexCfg;
@@ -121,7 +120,8 @@
{
logger.warn(LocalizableMessage.raw("Error reading configuration: " + oe, oe));
}
- exceptions = Collections.unmodifiableList(errors);
+ exceptions.addAll(errors);
+ exceptions = Collections.unmodifiableList(exceptions);
administrativeUsers = Collections.unmodifiableSet(alternateBindDNs);
listeners = Collections.unmodifiableSet(connectionHandlers);
backends = Collections.unmodifiableSet(backendDescriptors);
@@ -153,7 +153,8 @@
final List<OpenDsException> errors) throws OpenDsException, ConfigException
{
// Get the Directory Server configuration handler and use it.
- final RootCfg root = ServerManagementContext.getInstance().getRootConfiguration();
+ final RootCfg root =
+ DirectoryServer.getInstance().getServerContext().getServerManagementContext().getRootConfiguration();
readAdminConnector(root, errors);
readConnectionHandlers(connectionHandlers, root, errors);
isSchemaEnabled = root.getGlobalConfiguration().isCheckSchema();
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/ConfigReader.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/ConfigReader.java
index f216eae..b0588f6 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/ConfigReader.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/ConfigReader.java
@@ -32,6 +32,7 @@
import org.opends.guitools.controlpanel.datamodel.VLVSortOrder;
import org.opends.guitools.controlpanel.task.OfflineUpdateException;
import org.forgerock.opendj.server.config.meta.AdministrationConnectorCfgDefn;
+import org.opends.server.core.ConfigurationBackend;
import org.opends.server.core.DirectoryServer;
import org.opends.server.tools.tasks.TaskEntry;
import org.forgerock.opendj.ldap.DN;
@@ -78,7 +79,7 @@
Utilities.getInstanceRootDirectory(installRoot).getAbsolutePath();
configFile = instanceRoot + File.separator + "config" + File.separator +
"config.ldif";
- configClassName = ReadOnlyConfigFileHandler.class.getName();
+ configClassName = ConfigurationBackend.class.getName();
try
{
DirectoryEnvironmentConfig env = DirectoryServer.getEnvironmentConfig();
@@ -100,7 +101,7 @@
/**
* The exceptions that occurred reading the configuration.
*/
- protected List<OpenDsException> exceptions = Collections.emptyList();
+ protected List<Exception> exceptions = Collections.emptyList();
/**
* Whether the configuration has already been read or not.
@@ -204,7 +205,7 @@
* @return the list of exceptions that were encountered reading the
* configuration.
*/
- public List<OpenDsException> getExceptions()
+ public List<Exception> getExceptions()
{
return exceptions;
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/ReadOnlyConfigFileHandler.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/ReadOnlyConfigFileHandler.java
deleted file mode 100644
index e9039bd..0000000
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/ReadOnlyConfigFileHandler.java
+++ /dev/null
@@ -1,434 +0,0 @@
-/*
- * The contents of this file are subject to the terms of the Common Development and
- * Distribution License (the License). You may not use this file except in compliance with the
- * License.
- *
- * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
- * specific language governing permission and limitations under the License.
- *
- * When distributing Covered Software, include this CDDL Header Notice in each file and include
- * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
- * Header, with the fields enclosed by brackets [] replaced by your own identifying
- * information: "Portions Copyright [year] [name of copyright owner]".
- *
- * Copyright 2008-2010 Sun Microsystems, Inc.
- * Portions Copyright 2014-2016 ForgeRock AS.
- */
-package org.opends.guitools.controlpanel.util;
-
-import static org.forgerock.util.Reject.*;
-import static org.opends.messages.ConfigMessages.*;
-import static org.opends.server.util.StaticUtils.*;
-
-import java.io.File;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Set;
-
-import org.forgerock.i18n.LocalizableMessage;
-import org.forgerock.opendj.config.server.ConfigException;
-import org.forgerock.opendj.ldap.ConditionResult;
-import org.forgerock.opendj.server.config.server.BackendCfg;
-import org.opends.server.api.ConfigHandler;
-import org.opends.server.types.Entry;
-import org.opends.server.core.AddOperation;
-import org.opends.server.core.DeleteOperation;
-import org.opends.server.core.DirectoryServer;
-import org.opends.server.core.ModifyDNOperation;
-import org.opends.server.core.ModifyOperation;
-import org.opends.server.core.SearchOperation;
-import org.opends.server.core.ServerContext;
-import org.forgerock.opendj.ldap.schema.AttributeType;
-import org.opends.server.types.BackupConfig;
-import org.opends.server.types.BackupDirectory;
-import org.opends.server.types.CanceledOperationException;
-import org.forgerock.opendj.ldap.DN;
-import org.opends.server.types.DirectoryEnvironmentConfig;
-import org.opends.server.types.DirectoryException;
-import org.opends.server.types.Entry;
-import org.opends.server.types.IndexType;
-import org.opends.server.types.InitializationException;
-import org.opends.server.types.LDIFExportConfig;
-import org.opends.server.types.LDIFImportConfig;
-import org.opends.server.types.LDIFImportResult;
-import org.opends.server.types.RestoreConfig;
-import org.opends.server.util.LDIFException;
-import org.opends.server.util.LDIFReader;
-
-/**
- * A class used to read the configuration from a file. This config file
- * handler does not allow to modify the configuration, only to read it.
- */
-public class ReadOnlyConfigFileHandler extends ConfigHandler<BackendCfg>
-{
- /**
- * The mapping that holds all of the configuration entries that have been read
- * from the LDIF file.
- */
- private HashMap<DN,Entry> configEntries = new HashMap<>();
-
- /** The reference to the configuration root entry. */
- private Entry configRootEntry;
-
- /** The server root. */
- private String serverRoot;
-
- /** The instance root. */
- private String instanceRoot;
-
- private DN[] baseDNs;
-
- /** {@inheritDoc} */
- @Override
- public void finalizeConfigHandler()
- {
- finalizeBackend();
- }
-
- /** {@inheritDoc} */
- @Override
- public Entry getConfigEntry(DN entryDN) throws ConfigException
- {
- return configEntries.get(entryDN);
- }
-
- /** {@inheritDoc} */
- @Override
- public Entry getConfigRootEntry() throws ConfigException
- {
- return configRootEntry;
- }
-
- /** {@inheritDoc} */
- @Override
- public String getServerRoot()
- {
- return serverRoot;
- }
-
- /** {@inheritDoc} */
- @Override
- public String getInstanceRoot()
- {
- return instanceRoot;
- }
-
- /** {@inheritDoc} */
- @Override
- public synchronized void initializeConfigHandler(String configFile,
- boolean checkSchema)
- throws InitializationException
- {
- File f = new File(configFile);
- // We will use the LDIF reader to read the configuration file. Create an
- // LDIF import configuration to do this and then get the reader.
- LDIFReader reader = null;
- try
- {
- try
- {
- LDIFImportConfig importConfig =
- new LDIFImportConfig(f.getAbsolutePath());
-
- reader = new LDIFReader(importConfig);
- }
- catch (Throwable t)
- {
- throw new InitializationException(
- ERR_CONFIG_FILE_CANNOT_OPEN_FOR_READ.get(f.getAbsolutePath(), t), t);
- }
-
- if (! f.exists())
- {
- LocalizableMessage message =
- ERR_CONFIG_FILE_DOES_NOT_EXIST.get(f.getAbsolutePath());
- throw new InitializationException(message);
- }
-
- configEntries.clear();
-
- // Read the first entry from the configuration file.
- Entry entry;
- try
- {
- entry = reader.readEntry(checkSchema);
- if (entry == null)
- {
- LocalizableMessage message = ERR_CONFIG_FILE_EMPTY.get(f.getAbsolutePath());
- throw new InitializationException(message);
- }
- configRootEntry = new Entry(entry, null);
-
- baseDNs = new DN[] { configRootEntry.getDN() };
-
- configEntries.put(entry.getName(), configRootEntry);
- // Iterate through the rest of the configuration file and process the
- // remaining entries.
- while (entry != null)
- {
- // Read the next entry from the configuration.
- entry = reader.readEntry(checkSchema);
- if (entry != null)
- {
- DN entryDN = entry.getName();
- DN parentDN = entryDN.parent();
- Entry parentEntry = null;
- if (parentDN != null)
- {
- parentEntry = configEntries.get(parentDN);
- }
- if (parentEntry == null)
- {
- if (parentDN == null)
- {
- LocalizableMessage message = ERR_CONFIG_FILE_UNKNOWN_PARENT.get(
- entryDN, reader.getLastEntryLineNumber(), f.getAbsolutePath());
- throw new InitializationException(message);
- }
- else
- {
- LocalizableMessage message = ERR_CONFIG_FILE_NO_PARENT.get(entryDN,
- reader.getLastEntryLineNumber(), f.getAbsolutePath(), parentDN);
- throw new InitializationException(message);
- }
- }
- else
- {
- Entry configEntry = new Entry(entry, parentEntry);
- parentEntry.addChild(configEntry);
- configEntries.put(entryDN, configEntry);
- }
- }
- }
- }
- catch (InitializationException ie)
- {
- throw ie;
- }
- catch (LDIFException le)
- {
- throw new InitializationException(
- ERR_CONFIG_FILE_INVALID_LDIF_ENTRY.get(le.getLineNumber(), f.getAbsolutePath(), le), le);
- }
- catch (Throwable t)
- {
- throw new InitializationException(
- ERR_CONFIG_FILE_READ_ERROR.get(f.getAbsolutePath(), t), t);
- }
-
-
- // Determine the appropriate server root.
- File rootFile = DirectoryServer.getEnvironmentConfig().getServerRoot();
- serverRoot = rootFile.getAbsolutePath();
-
- File instanceRootFile =
- DirectoryEnvironmentConfig.getInstanceRootFromServerRoot(rootFile);
- instanceRoot = instanceRootFile.getAbsolutePath();
- }
- catch (InitializationException ie)
- {
- throw ie;
- }
- catch (Throwable t)
- {
- }
- finally
- {
- close(reader);
- }
- }
-
- /** {@inheritDoc} */
- @Override
- public void writeSuccessfulStartupConfig()
- {
- }
-
- /** {@inheritDoc} */
- @Override
- public void writeUpdatedConfig() throws DirectoryException
- {
- }
-
- /** {@inheritDoc} */
- @Override
- public void addEntry(Entry entry, AddOperation arg1)
- throws DirectoryException, CanceledOperationException
- {
- }
-
- /** {@inheritDoc} */
- @Override
- public void configureBackend(BackendCfg cfg, ServerContext serverContext) throws ConfigException
- {
- }
-
- /** {@inheritDoc} */
- @Override
- public void createBackup(BackupConfig arg0) throws DirectoryException
- {
- }
-
- /** {@inheritDoc} */
- @Override
- public void deleteEntry(DN arg0, DeleteOperation arg1)
- throws DirectoryException, CanceledOperationException
- {
- }
-
- /** {@inheritDoc} */
- @Override
- public void exportLDIF(LDIFExportConfig arg0) throws DirectoryException
- {
- }
-
- /** {@inheritDoc} */
- @Override
- public DN[] getBaseDNs()
- {
- return baseDNs;
- }
-
- /** {@inheritDoc} */
- @Override
- public Entry getEntry(DN entryDN)
- throws DirectoryException
- {
- Entry configEntry = configEntries.get(entryDN);
- if (configEntry != null)
- {
- return configEntry;
- }
- return null;
- }
-
- /** {@inheritDoc} */
- @Override
- public long getEntryCount()
- {
- return configEntries.size();
- }
-
- /** {@inheritDoc} */
- @Override
- public Set<String> getSupportedControls()
- {
- return Collections.emptySet();
- }
-
- /** {@inheritDoc} */
- @Override
- public Set<String> getSupportedFeatures()
- {
- return Collections.emptySet();
- }
-
- /** {@inheritDoc} */
- @Override
- public ConditionResult hasSubordinates(DN entryDN) throws DirectoryException
- {
- Entry baseEntry = configEntries.get(entryDN);
- if (baseEntry != null)
- {
- return ConditionResult.valueOf(baseEntry.hasChildren());
- }
- return ConditionResult.UNDEFINED;
- }
-
- /** {@inheritDoc} */
- @Override
- public LDIFImportResult importLDIF(LDIFImportConfig importConfig, ServerContext serverContext)
- throws DirectoryException
- {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override
- public void openBackend() throws ConfigException, InitializationException
- {
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean isIndexed(AttributeType arg0, IndexType arg1)
- {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override
- public long getNumberOfChildren(DN parentDN) throws DirectoryException {
- checkNotNull(parentDN, "parentDN must not be null");
- return numSubordinates(parentDN, false);
- }
-
- /** {@inheritDoc} */
- @Override
- public long getNumberOfEntriesInBaseDN(DN baseDN) throws DirectoryException {
- checkNotNull(baseDN, "baseDN must not be null");
- return numSubordinates(baseDN, true) + 1;
- }
-
- private long numSubordinates(DN entryDN, boolean subtree) throws DirectoryException
- {
- final Entry baseEntry = configEntries.get(entryDN);
- if (baseEntry == null)
- {
- return -1;
- }
-
- if(!subtree)
- {
- return baseEntry.getChildren().size();
- }
- long count = 0;
- for (Entry child : baseEntry.getChildren().values())
- {
- count += numSubordinates(child.getDN(), true);
- count++;
- }
- return count;
- }
-
- /** {@inheritDoc} */
- @Override
- public void removeBackup(BackupDirectory backupDirectory, String backupID)
- throws DirectoryException
- {
- }
-
- /** {@inheritDoc} */
- @Override
- public void renameEntry(DN currentDN, Entry entry, ModifyDNOperation modifyDNOperation)
- throws DirectoryException, CanceledOperationException
- {
- }
-
- /** {@inheritDoc} */
- @Override
- public void replaceEntry(Entry oldEntry, Entry newEntry, ModifyOperation modifyOperation)
- throws DirectoryException, CanceledOperationException
- {
- }
-
- /** {@inheritDoc} */
- @Override
- public void restoreBackup(RestoreConfig restoreConfig) throws DirectoryException
- {
- }
-
- /** {@inheritDoc} */
- @Override
- public void search(SearchOperation searchOperation)
- throws DirectoryException, CanceledOperationException
- {
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean supports(BackendOperation backendOperation)
- {
- return false;
- }
-}
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/Utilities.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/Utilities.java
index 4448a00..49b2bf9 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/Utilities.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/Utilities.java
@@ -113,10 +113,8 @@
import org.opends.quicksetup.Installation;
import org.opends.quicksetup.ui.UIFactory;
import org.opends.quicksetup.util.Utils;
-import org.forgerock.opendj.config.ConfigurationFramework;
-import org.opends.server.api.ConfigHandler;
-import org.opends.server.types.Entry;
-import org.opends.server.core.DirectoryServer;
+import org.opends.server.admin.ClassLoaderProvider;
+import org.opends.server.core.ConfigurationHandler;
import org.opends.server.core.LockFileManager;
import org.opends.server.schema.SchemaConstants;
import org.opends.server.schema.SomeSchemaElement;
@@ -2312,19 +2310,18 @@
* @throws OpenDsException if an error occurs.
* @throws ConfigException if an error occurs.
*/
- public static void deleteConfigSubtree(ConfigHandler confHandler, DN dn)
+ public static void deleteConfigSubtree(ConfigurationHandler confHandler, DN dn)
throws OpenDsException, ConfigException
{
- Entry confEntry = confHandler.getConfigEntry(dn);
+ org.forgerock.opendj.ldap.Entry confEntry = confHandler.getEntry(dn);
if (confEntry != null)
{
// Copy the values to avoid problems with this recursive method.
- ArrayList<DN> childDNs = new ArrayList<>(confEntry.getChildren().keySet());
- for (DN childDN : childDNs)
+ for (DN childDN : new ArrayList<>(confHandler.getChildren(dn)))
{
deleteConfigSubtree(confHandler, childDN);
}
- confHandler.deleteEntry(dn, null);
+ confHandler.deleteEntry(dn);
}
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/quicksetup/installer/InstallerHelper.java b/opendj-server-legacy/src/main/java/org/opends/quicksetup/installer/InstallerHelper.java
index 5778e3a..d5f9417 100644
--- a/opendj-server-legacy/src/main/java/org/opends/quicksetup/installer/InstallerHelper.java
+++ b/opendj-server-legacy/src/main/java/org/opends/quicksetup/installer/InstallerHelper.java
@@ -344,7 +344,7 @@
{
// Read the configuration file.
DN dn = DN.valueOf("ds-cfg-backend-id" + "=" + backendName + ",cn=Backends,cn=config");
- Utilities.deleteConfigSubtree(DirectoryServer.getConfigHandler(), dn);
+ Utilities.deleteConfigSubtree(DirectoryServer.getConfigurationHandler(), dn);
}
catch (OpenDsException | ConfigException ode)
{
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/admin/AdministrationConnector.java b/opendj-server-legacy/src/main/java/org/opends/server/admin/AdministrationConnector.java
index 061c687..be0f5eb 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/admin/AdministrationConnector.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/admin/AdministrationConnector.java
@@ -32,9 +32,9 @@
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.config.server.ConfigChangeResult;
import org.forgerock.opendj.config.server.ConfigException;
-import org.forgerock.opendj.ldap.AddressMask;
import org.forgerock.opendj.config.server.ConfigurationChangeListener;
-import org.opends.server.admin.server.ServerManagementContext;
+import org.forgerock.opendj.ldap.AddressMask;
+import org.forgerock.opendj.ldap.DN;
import org.forgerock.opendj.server.config.meta.LDAPConnectionHandlerCfgDefn.SSLClientAuthPolicy;
import org.forgerock.opendj.server.config.server.AdministrationConnectorCfg;
import org.forgerock.opendj.server.config.server.ConnectionHandlerCfg;
@@ -48,7 +48,6 @@
import org.opends.server.core.ServerContext;
import org.opends.server.core.SynchronousStrategy;
import org.opends.server.protocols.ldap.LDAPConnectionHandler;
-import org.forgerock.opendj.ldap.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.FilePermission;
import org.opends.server.types.InitializationException;
@@ -187,8 +186,7 @@
* This private class implements a fake LDAP connection Handler configuration.
* This allows to re-use the LDAPConnectionHandler as it is.
*/
- private static class LDAPConnectionCfgAdapter implements
- LDAPConnectionHandlerCfg
+ private static class LDAPConnectionCfgAdapter implements LDAPConnectionHandlerCfg
{
private final AdministrationConnectorCfg config;
@@ -449,8 +447,7 @@
{
try
{
- RootCfg root = ServerManagementContext.getInstance()
- .getRootConfiguration();
+ RootCfg root = serverContext.getServerManagementContext().getRootConfiguration();
AdministrationConnectorCfg config = root.getAdministrationConnector();
// Check if certificate generation is needed
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/api/ConfigHandler.java b/opendj-server-legacy/src/main/java/org/opends/server/api/ConfigHandler.java
deleted file mode 100644
index df31346..0000000
--- a/opendj-server-legacy/src/main/java/org/opends/server/api/ConfigHandler.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * The contents of this file are subject to the terms of the Common Development and
- * Distribution License (the License). You may not use this file except in compliance with the
- * License.
- *
- * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
- * specific language governing permission and limitations under the License.
- *
- * When distributing Covered Software, include this CDDL Header Notice in each file and include
- * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
- * Header, with the fields enclosed by brackets [] replaced by your own identifying
- * information: "Portions Copyright [year] [name of copyright owner]".
- *
- * Copyright 2006-2008 Sun Microsystems, Inc.
- * Portions Copyright 2014-2016 ForgeRock AS.
- */
-package org.opends.server.api;
-
-import org.opends.server.admin.std.server.BackendCfg;
-import org.opends.server.config.ConfigEntry;
-import org.forgerock.opendj.config.server.ConfigException;
-import org.forgerock.opendj.ldap.DN;
-import org.opends.server.types.DirectoryException;
-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.
- *
- * @param <C> the BackendCfg class in use with this ConfigHandler
- */
-@org.opends.server.types.PublicAPI(
- stability=org.opends.server.types.StabilityLevel.VOLATILE,
- mayInstantiate=false,
- mayExtend=true,
- mayInvoke=true)
-public abstract class ConfigHandler<C extends BackendCfg> extends Backend<C>
-{
- /**
- * Bootstraps this configuration handler using the information in
- * the provided configuration file. Depending on this configuration
- * handler implementation, the provided file may contain either the
- * entire server configuration or information that is needed to
- * access the configuration in some other location or repository.
- *
- * @param configFile The path to the file to use to initialize
- * this configuration handler.
- * @param checkSchema Indicates whether to perform schema checking
- * on the configuration data.
- *
- * @throws InitializationException If a problem occurs while
- * attempting to initialize this
- * configuration handler.
- */
- public abstract void initializeConfigHandler(String configFile,
- boolean checkSchema)
- throws InitializationException;
-
-
-
- /**
- * Finalizes this configuration handler so that it will release any
- * resources associated with it so that it will no longer be used.
- * This will be called when the Directory Server is shutting down,
- * as well as in the startup process once the schema has been read
- * so that the configuration can be re-read using the updated
- * schema.
- */
- public abstract void finalizeConfigHandler();
-
-
-
- /**
- * Retrieves the entry that is at the root of the Directory Server
- * configuration.
- *
- * @return The entry that is at the root of the Directory Server
- * configuration.
- *
- * @throws ConfigException If a problem occurs while interacting
- * with the configuration.
- */
- public abstract ConfigEntry getConfigRootEntry()
- throws ConfigException;
-
-
-
- /**
- * Retrieves the requested entry from the configuration.
- *
- * @param entryDN The distinguished name of the configuration
- * entry to retrieve.
- *
- * @return The requested configuration entry.
- *
- * @throws ConfigException If a problem occurs while interacting
- * with the configuration.
- */
- public abstract ConfigEntry getConfigEntry(DN entryDN)
- throws ConfigException;
-
-
-
- /**
- * Retrieves the absolute path of the Directory Server install
- * root.
- *
- * @return The absolute path of the Directory Server install root.
- */
- public abstract String getServerRoot();
-
-
- /**
- * Retrieves the absolute path of the Directory Server instance
- * root.
- *
- * @return The absolute path of the Directory Server instance root.
- */
- public abstract String getInstanceRoot();
-
-
- /**
- * Writes an updated version of the Directory Server configuration
- * to the repository. This should ensure that the stored
- * configuration matches the pending configuration.
- *
- * @throws DirectoryException If a problem is encountered while
- * writing the updated configuration.
- */
- public abstract void writeUpdatedConfig()
- throws DirectoryException;
-
-
-
- /**
- * Indicates that the Directory Server has started successfully and
- * that the configuration handler should save a copy of the current
- * configuration for use as a "last known good" reference. Note
- * that this may not be possible with some kinds of configuration
- * repositories, so it should be a best effort attempt.
- * <BR><BR>
- * This method should only be called by the Directory Server itself
- * when the server has started successfully. It should not be
- * invoked by any other component at any other time.
- */
- @org.opends.server.types.PublicAPI(
- stability=org.opends.server.types.StabilityLevel.VOLATILE,
- mayInstantiate=false,
- mayExtend=true,
- mayInvoke=false)
- public abstract void writeSuccessfulStartupConfig();
-}
-
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/api/plugin/DirectoryServerPlugin.java b/opendj-server-legacy/src/main/java/org/opends/server/api/plugin/DirectoryServerPlugin.java
index b6f5dc1..cdc0b8b 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/api/plugin/DirectoryServerPlugin.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/api/plugin/DirectoryServerPlugin.java
@@ -26,6 +26,7 @@
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.DN;
import org.opends.server.core.DeleteOperation;
+import org.opends.server.core.ServerContext;
import org.opends.server.types.*;
import org.opends.server.types.operation.*;
@@ -58,7 +59,8 @@
/** The plugin types for which this plugin is registered. */
private Set<PluginType> pluginTypes;
-
+ /** The server context. */
+ private ServerContext serverContext;
/**
* Creates a new instance of this Directory Server plugin. Every
@@ -71,7 +73,15 @@
{
}
-
+ /**
+ * Returns the server context.
+ *
+ * @return the server context.
+ */
+ protected ServerContext getServerContext()
+ {
+ return serverContext;
+ }
/**
* Indicates whether the provided configuration is acceptable for
@@ -104,6 +114,8 @@
* plugins regardless of type. This should only be called by the
* core Directory Server code during the course of loading a plugin.
*
+ * @param serverContext
+ * The server context.
* @param pluginDN
* The configuration entry name of this plugin.
* @param pluginTypes
@@ -118,9 +130,10 @@
mayInstantiate=false,
mayExtend=false,
mayInvoke=false)
- public final void initializeInternal(DN pluginDN,
+ public final void initializeInternal(ServerContext serverContext, DN pluginDN,
Set<PluginType> pluginTypes, boolean invokeForInternalOps)
{
+ this.serverContext = serverContext;
this.pluginDN = pluginDN;
this.pluginTypes = pluginTypes;
this.invokeForInternalOps = invokeForInternalOps;
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/api/plugin/InternalDirectoryServerPlugin.java b/opendj-server-legacy/src/main/java/org/opends/server/api/plugin/InternalDirectoryServerPlugin.java
index f628115..84fa766 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/api/plugin/InternalDirectoryServerPlugin.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/api/plugin/InternalDirectoryServerPlugin.java
@@ -23,6 +23,7 @@
import org.forgerock.opendj.server.config.server.PluginCfg;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.DN;
+import org.opends.server.core.DirectoryServer;
import org.opends.server.types.InitializationException;
/**
@@ -50,7 +51,8 @@
protected InternalDirectoryServerPlugin(DN componentDN,
Set<PluginType> pluginTypes, boolean invokeForInternalOps)
{
- initializeInternal(componentDN, pluginTypes,
+ // TODO: server context should be provided in constructor
+ initializeInternal(DirectoryServer.getInstance().getServerContext(), componentDN, pluginTypes,
invokeForInternalOps);
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/AciHandler.java b/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/AciHandler.java
index dff57ec..2273259 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/AciHandler.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/authorization/dseecompat/AciHandler.java
@@ -36,11 +36,12 @@
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.server.config.server.DseeCompatAccessControlHandlerCfg;
import org.opends.server.api.AccessControlHandler;
+import org.opends.server.api.Backend;
import org.opends.server.api.ClientConnection;
-import org.opends.server.api.ConfigHandler;
import org.opends.server.backends.pluggable.SuffixContainer;
import org.opends.server.controls.GetEffectiveRightsRequestControl;
import org.opends.server.core.BindOperation;
+import org.opends.server.core.ConfigurationBackend;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.ExtendedOperation;
import org.opends.server.core.ModifyDNOperation;
@@ -1036,7 +1037,7 @@
LinkedList<LocalizableMessage> failedACIMsgs = new LinkedList<>();
InternalClientConnection conn = getRootConnection();
- ConfigHandler<?> configBackend = DirectoryServer.getConfigHandler();
+ Backend<?> configBackend = DirectoryServer.getBackend(ConfigurationBackend.CONFIG_BACKEND_ID);
for (DN baseDN : configBackend.getBaseDNs())
{
try
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/BackendStat.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/BackendStat.java
index 2a08b1a..88398e8 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/BackendStat.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/BackendStat.java
@@ -17,7 +17,6 @@
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.util.StaticUtils.*;
-
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static com.forgerock.opendj.cli.Utils.*;
import static com.forgerock.opendj.cli.CommonArguments.*;
@@ -49,11 +48,11 @@
import org.opends.server.backends.pluggable.spi.ReadableTransaction;
import org.opends.server.backends.pluggable.spi.StorageRuntimeException;
import org.opends.server.backends.pluggable.spi.TreeName;
+import org.opends.server.core.ConfigurationHandler;
import org.opends.server.core.CoreConfigManager;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.DirectoryServer.DirectoryServerVersionHandler;
import org.opends.server.core.LockFileManager;
-import org.opends.server.extensions.ConfigFileHandler;
import org.opends.server.loggers.JDKLogging;
import org.opends.server.tools.BackendToolUtils;
import org.forgerock.opendj.ldap.DN;
@@ -358,7 +357,7 @@
.description(INFO_DESCRIPTION_CONFIG_CLASS.get())
.hidden()
.required()
- .defaultValue(ConfigFileHandler.class.getName())
+ .defaultValue(ConfigurationHandler.class.getName())
.valuePlaceholder(INFO_CONFIGCLASS_PLACEHOLDER.get())
.buildArgument();
configFile =
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/core/BackendConfigManager.java b/opendj-server-legacy/src/main/java/org/opends/server/core/BackendConfigManager.java
index 7e1efc2..1c32bd7 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/core/BackendConfigManager.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/core/BackendConfigManager.java
@@ -173,10 +173,9 @@
continue;
}
-
- // If this backend is a configuration manager, then we don't want to do
+ // If this backend is the configuration backend, then we don't want to do
// any more with it because the configuration will have already been started.
- if (backend instanceof ConfigHandler)
+ if (backend instanceof ConfigurationBackend)
{
continue;
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/core/ConfigurationBootstrapper.java b/opendj-server-legacy/src/main/java/org/opends/server/core/ConfigurationBootstrapper.java
index ca4c816..bd9adac 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/core/ConfigurationBootstrapper.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/core/ConfigurationBootstrapper.java
@@ -11,11 +11,16 @@
* Header, with the fields enclosed by brackets [] replaced by your own identifying
* information: "Portions Copyright [year] [name of copyright owner]".
*
- * Copyright 2014 ForgeRock AS.
+ * Copyright 2014-2016 ForgeRock AS.
*/
package org.opends.server.core;
+import java.lang.reflect.Constructor;
+
+import static org.opends.messages.CoreMessages.ERR_CANNOT_INSTANTIATE_CONFIG_HANDLER;
+
import org.forgerock.i18n.LocalizableMessage;
+import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.config.ConfigurationFramework;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.config.server.ServerManagementContext;
@@ -27,6 +32,8 @@
public class ConfigurationBootstrapper
{
+ private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
+
/**
* Bootstrap the server configuration.
* <p>
@@ -35,11 +42,14 @@
*
* @param serverContext
* The server context.
+ * @param configClass
+ * The actual configuration class to use.
* @return the server management context
* @throws InitializationException
* If an error occurs during bootstrapping.
*/
- public static ServerManagementContext bootstrap(ServerContext serverContext) throws InitializationException {
+ public static ServerManagementContext bootstrap(ServerContext serverContext, Class<ConfigurationHandler> configClass)
+ throws InitializationException {
final ConfigurationFramework configFramework = ConfigurationFramework.getInstance();
try
{
@@ -51,12 +61,24 @@
catch (ConfigException e)
{
// TODO : fix the message
- throw new InitializationException(LocalizableMessage.raw("Cannot initialize config framework"), e);
+ throw new InitializationException(LocalizableMessage.raw("Cannot initialize configuration framework"), e);
}
- final ConfigurationHandler configurationHandler = new ConfigurationHandler(serverContext);
+ // Load and instantiate the configuration handler class.
+ Class<ConfigurationHandler> handlerClass = configClass;
+ final ConfigurationHandler configurationHandler;
+ try
+ {
+ Constructor<ConfigurationHandler> cons = handlerClass.getConstructor(ServerContext.class);
+ configurationHandler = cons.newInstance(serverContext);
+ }
+ catch (Exception e)
+ {
+ logger.traceException(e);
+ LocalizableMessage message = ERR_CANNOT_INSTANTIATE_CONFIG_HANDLER.get(configClass, e.getLocalizedMessage());
+ throw new InitializationException(message, e);
+ }
configurationHandler.initialize();
-
return new ServerManagementContext(configurationHandler);
}
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/core/DirectoryServer.java b/opendj-server-legacy/src/main/java/org/opends/server/core/DirectoryServer.java
index 593511b..0417485 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/core/DirectoryServer.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/core/DirectoryServer.java
@@ -60,6 +60,7 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.LocalizedIllegalArgumentException;
import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.forgerock.opendj.adapter.server3x.Converters;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.DN;
import org.forgerock.opendj.ldap.ResultCode;
@@ -68,11 +69,6 @@
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.forgerock.opendj.ldap.schema.ObjectClassType;
import org.forgerock.opendj.ldap.schema.Syntax;
-import org.forgerock.util.Reject;
-import org.opends.server.admin.AdministrationConnector;
-import org.opends.server.admin.AdministrationDataSync;
-import org.forgerock.opendj.config.ConfigurationFramework;
-import org.forgerock.opendj.config.server.ServerManagementContext;
import org.forgerock.opendj.server.config.server.AlertHandlerCfg;
import org.forgerock.opendj.server.config.server.ConnectionHandlerCfg;
import org.forgerock.opendj.server.config.server.CryptoManagerCfg;
@@ -81,6 +77,10 @@
import org.forgerock.opendj.server.config.server.RootCfg;
import org.forgerock.opendj.server.config.server.RootDSEBackendCfg;
import org.forgerock.opendj.server.config.server.SynchronizationProviderCfg;
+import org.forgerock.util.Reject;
+import org.opends.server.admin.AdministrationConnector;
+import org.opends.server.admin.AdministrationDataSync;
+import org.opends.server.admin.ClassLoaderProvider;
import org.opends.server.api.AccessControlHandler;
import org.opends.server.api.AccountStatusNotificationHandler;
import org.opends.server.api.AlertGenerator;
@@ -92,10 +92,6 @@
import org.opends.server.api.CertificateMapper;
import org.opends.server.api.ClientConnection;
import org.opends.server.api.CompressedSchema;
-import org.opends.server.api.ConfigAddListener;
-import org.opends.server.api.ConfigChangeListener;
-import org.opends.server.api.ConfigDeleteListener;
-import org.opends.server.api.ConfigHandler;
import org.opends.server.api.ConnectionHandler;
import org.opends.server.api.DirectoryServerMBean;
import org.opends.server.api.EntryCache;
@@ -119,13 +115,11 @@
import org.opends.server.api.plugin.PluginResult;
import org.opends.server.api.plugin.PluginType;
import org.opends.server.backends.RootDSEBackend;
-import org.opends.server.types.Entry;
import org.opends.server.config.JMXMBean;
import org.opends.server.controls.PasswordPolicyErrorType;
import org.opends.server.controls.PasswordPolicyResponseControl;
import org.opends.server.crypto.CryptoManagerImpl;
import org.opends.server.crypto.CryptoManagerSync;
-import org.opends.server.extensions.ConfigFileHandler;
import org.opends.server.extensions.DiskSpaceMonitor;
import org.opends.server.extensions.JMXAlertHandler;
import org.opends.server.loggers.AccessLogger;
@@ -168,6 +162,7 @@
import org.opends.server.util.ActivateOnceNewConfigFrameworkIsUsed;
import org.opends.server.util.ActivateOnceSDKSchemaIsUsed;
import org.opends.server.util.BuildVersion;
+import org.opends.server.util.ModifyOnceSDKSchemaIsUsed;
import org.opends.server.util.MultiOutputStream;
import org.opends.server.util.RuntimeInformation;
import org.opends.server.util.SetupUtils;
@@ -293,10 +288,10 @@
private CertificateMapperConfigManager certificateMapperConfigManager;
/** The class used to provide the config handler implementation. */
- private Class<ConfigHandler> configClass;
+ private Class<ConfigurationHandler> configClass;
/** The configuration handler for the Directory Server. */
- private ConfigHandler configHandler;
+ private ConfigurationHandler configurationHandler;
/** The set of account status notification handlers defined in the server. */
private ConcurrentMap<DN, AccountStatusNotificationHandler>
@@ -1075,6 +1070,7 @@
environmentConfig.setConfigClass(cfgClass);
environmentConfig.setConfigFile(cfgFile);
+
initializeConfiguration();
}
@@ -1089,11 +1085,11 @@
* @throws InitializationException
*/
@ActivateOnceNewConfigFrameworkIsUsed("it will need adaptation to be activated before sdk schema is ready")
- @ActivateOnceSDKSchemaIsUsed
+ @ModifyOnceSDKSchemaIsUsed
private void initializeNG() throws InitializationException
{
- serverManagementContext = ConfigurationBootstrapper.bootstrap(serverContext);
- initializeSchemaNG();
+ //serverManagementContext = ConfigurationBootstrapper.bootstrap(serverContext);
+ //initializeSchemaNG();
// TODO : config backend should be initialized later, with the other backends
//ConfigBackend configBackend = new ConfigBackend();
@@ -1116,70 +1112,10 @@
}
}
- /**
- * Instantiates the configuration handler and loads the Directory Server
- * configuration.
- *
- * @throws InitializationException If a problem occurs while trying to
- * initialize the config handler.
- */
- public void initializeConfiguration()
- throws InitializationException
+ public void initializeConfiguration() throws InitializationException
{
this.configClass = environmentConfig.getConfigClass();
- this.configFile = environmentConfig.getConfigFile();
-
- // Make sure that administration framework definition classes are loaded.
- ClassLoaderProvider provider = ClassLoaderProvider.getInstance();
- if (! provider.isEnabled())
- {
- provider.enable();
- }
-
- // Load and instantiate the configuration handler class.
- Class<ConfigHandler> handlerClass = configClass;
- try
- {
- configHandler = handlerClass.newInstance();
- }
- catch (Exception e)
- {
- logger.traceException(e);
-
- LocalizableMessage message =
- ERR_CANNOT_INSTANTIATE_CONFIG_HANDLER.get(configClass, e.getLocalizedMessage());
- throw new InitializationException(message, e);
- }
-
- // Perform the handler-specific initialization.
- try
- {
- String path;
- try
- {
- path = configFile.getCanonicalPath();
- }
- catch (Exception ex)
- {
- path = configFile.getAbsolutePath();
- }
- configHandler.initializeConfigHandler(path, false);
- }
- catch (InitializationException ie)
- {
- logger.traceException(ie);
-
- throw ie;
- }
- catch (Exception e)
- {
- logger.traceException(e);
-
- LocalizableMessage message =
- ERR_CANNOT_INITIALIZE_CONFIG_HANDLER.get(
- configClass, configFile, e.getLocalizedMessage());
- throw new InitializationException(message, e);
- }
+ serverManagementContext = ConfigurationBootstrapper.bootstrap(serverContext, configClass);
}
/**
@@ -1277,7 +1213,7 @@
initializeSchema();
- commonAudit = new CommonAudit();
+ commonAudit = new CommonAudit(serverContext);
// Allow internal plugins to be registered.
pluginConfigManager.initializePluginConfigManager();
@@ -1338,8 +1274,10 @@
// Initialize both subentry manager and group manager
// for the configuration backend.
// TODO : why do we initialize these now ? Can't we do them after backend initialization ?
- subentryManager.performBackendPreInitializationProcessing(configHandler);
- groupManager.performBackendPreInitializationProcessing(configHandler);
+
+ Backend<?> configBackend = getConfigurationBackend();
+ subentryManager.performBackendPreInitializationProcessing(configBackend);
+ groupManager.performBackendPreInitializationProcessing(configBackend);
AccessControlConfigManager.getInstance().initializeAccessControl(serverContext);
@@ -1409,7 +1347,7 @@
// Write a copy of the config if needed.
if (saveConfigOnSuccessfulStartup)
{
- configHandler.writeSuccessfulStartupConfig();
+ configurationHandler.writeSuccessfulStartupConfig();
}
isRunning = true;
@@ -1434,14 +1372,14 @@
/** Delete "server.starting" and "hostname" files if they are present. */
private void deleteUnnecessaryFiles()
{
- File serverStartingFile = new File(configHandler.getInstanceRoot() + File.separator + "logs"
+ File serverStartingFile = new File(environmentConfig.getInstanceRoot() + File.separator + "logs"
+ File.separator + "server.starting");
if (serverStartingFile.exists())
{
serverStartingFile.delete();
}
- File hostNameFile = new File(configHandler.getInstanceRoot() + File.separator + SetupUtils.HOST_NAME_FILE);
+ File hostNameFile = new File(environmentConfig.getInstanceRoot() + File.separator + SetupUtils.HOST_NAME_FILE);
if (hostNameFile.exists())
{
hostNameFile.delete();
@@ -1595,72 +1533,6 @@
// With server schema in place set compressed schema.
compressedSchema = new DefaultCompressedSchema(serverContext);
-
- // At this point we have a problem, because none of the configuration is
- // usable because it was all read before we had a schema (and therefore all
- // of the attribute types and objectclasses are bogus and won't let us find
- // anything). So we have to re-read the configuration so that we can
- // continue the necessary startup process. In the process, we want to
- // preserve any configuration add/delete/change listeners that might have
- // been registered with the old configuration (which will primarily be
- // schema elements) so they can be re-registered with the new configuration.
- Map<String, List<ConfigAddListener>> addListeners = new LinkedHashMap<>();
- Map<String, List<ConfigDeleteListener>> deleteListeners = new LinkedHashMap<>();
- Map<String, List<ConfigChangeListener>> changeListeners = new LinkedHashMap<>();
- getChangeListeners(configHandler.getConfigRootEntry(), addListeners,
- deleteListeners, changeListeners);
-
- try
- {
- configHandler.finalizeConfigHandler();
- }
- catch (Exception e)
- {
- logger.traceException(e);
- }
-
- try
- {
- configHandler.initializeConfigHandler(configFile.getAbsolutePath(), true);
- }
- catch (InitializationException ie)
- {
- logger.traceException(ie);
-
- throw ie;
- }
- catch (Exception e)
- {
- logger.traceException(e);
-
- throw new InitializationException(ERR_CANNOT_INITIALIZE_CONFIG_HANDLER.get(
- configClass, configFile, e.getLocalizedMessage()));
- }
-
- // Re-register all of the change listeners with the configuration.
- for (String dnStr : addListeners.keySet())
- {
- for (ConfigAddListener listener : addListeners.get(dnStr))
- {
- configHandler.getConfigEntry(toDn(dnStr)).registerAddListener(listener);
- }
- }
-
- for (String dnStr : deleteListeners.keySet())
- {
- for (ConfigDeleteListener listener : deleteListeners.get(dnStr))
- {
- configHandler.getConfigEntry(toDn(dnStr)).registerDeleteListener(listener);
- }
- }
-
- for (String dnStr : changeListeners.keySet())
- {
- for (ConfigChangeListener listener : changeListeners.get(dnStr))
- {
- configHandler.getConfigEntry(toDn(dnStr)).registerChangeListener(listener);
- }
- }
}
private DN toDn(String dn) throws InitializationException
@@ -1686,41 +1558,9 @@
return directoryServer.compressedSchema;
}
- /**
- * Gets all of the add, delete, and change listeners from the provided
- * configuration entry and all of its descendants and puts them in the
- * appropriate lists.
- *
- * @param configEntry The configuration entry to be processed, along
- * with all of its descendants.
- * @param addListeners The set of add listeners mapped to the DN of the
- * corresponding configuration entry.
- * @param deleteListeners The set of delete listeners mapped to the DN of
- * the corresponding configuration entry.
- * @param changeListeners The set of change listeners mapped to the DN of
- * the corresponding configuration entry.
- */
- private void getChangeListeners(Entry configEntry,
- Map<String, List<ConfigAddListener>> addListeners,
- Map<String, List<ConfigDeleteListener>> deleteListeners,
- Map<String, List<ConfigChangeListener>> changeListeners)
+ private Backend<?> getConfigurationBackend()
{
- put(addListeners, configEntry, configEntry.getAddListeners());
- put(deleteListeners, configEntry, configEntry.getDeleteListeners());
- put(changeListeners, configEntry, configEntry.getChangeListeners());
-
- for (Entry child : configEntry.getChildren().values())
- {
- getChangeListeners(child, addListeners, deleteListeners, changeListeners);
- }
- }
-
- private <T> void put(Map<String, List<T>> listeners, Entry configEntry, List<T> cfgListeners)
- {
- if (cfgListeners != null && !cfgListeners.isEmpty())
- {
- listeners.put(configEntry.getName().toString(), cfgListeners);
- }
+ return getBackend(ConfigurationBackend.CONFIG_BACKEND_ID);
}
/**
@@ -1850,7 +1690,7 @@
{
try
{
- createAndRegisterWorkflows(configHandler);
+ createAndRegisterWorkflows(getConfigurationBackend());
createAndRegisterWorkflows(rootDSEBackend);
}
catch (DirectoryException de)
@@ -1887,9 +1727,8 @@
// The configuration backend has already been registered by this point
// so we need to handle it explicitly.
- // Because subentryManager may depend on the groupManager, let's
- // delay this.
- // groupManager.performBackendPreInitializationProcessing(configHandler);
+ // Because subentryManager may depend on the groupManager, let's delay this.
+ // groupManager.performBackendPreInitializationProcessing(configurationHandler);
}
/**
@@ -1989,8 +1828,7 @@
// at this point so we need to handle it explicitly here.
// However, subentryManager may have dependencies on the
// groupManager. So lets delay the backend initialization until then.
- // subentryManager.performBackendPreInitializationProcessing(
- // configHandler);
+ // subentryManager.performBackendPreInitializationProcessing(configurationHandler);
}
catch (DirectoryException de)
{
@@ -2042,9 +1880,9 @@
*
* @return A reference to the Directory Server configuration handler.
*/
- public static ConfigHandler getConfigHandler()
+ public static ConfigurationHandler getConfigurationHandler()
{
- return directoryServer.configHandler;
+ return directoryServer.configurationHandler;
}
/**
@@ -2158,7 +1996,7 @@
@Deprecated
public static Entry getConfigEntry(DN entryDN) throws ConfigException
{
- return directoryServer.configHandler.getConfigEntry(entryDN);
+ return Converters.to(directoryServer.configurationHandler.getEntry(entryDN));
}
/**
@@ -3119,7 +2957,7 @@
}
else
{
- for (AlertHandler alertHandler : directoryServer.alertHandlers)
+ for (AlertHandler<?> alertHandler : directoryServer.alertHandlers)
{
AlertHandlerCfg config = alertHandler.getAlertHandlerConfiguration();
Set<String> enabledAlerts = config.getEnabledAlertType();
@@ -3164,7 +3002,7 @@
* @return The requested password storage scheme, or {@code null} if no such
* scheme is defined.
*/
- public static PasswordStorageScheme getPasswordStorageScheme(DN configEntryDN)
+ public static PasswordStorageScheme<?> getPasswordStorageScheme(DN configEntryDN)
{
return directoryServer.passwordStorageSchemesByDN.get(configEntryDN);
}
@@ -5125,8 +4963,7 @@
* @param handler The connection handler to register with the Directory
* Server.
*/
- public static void registerConnectionHandler(
- ConnectionHandler<? extends ConnectionHandlerCfg>
+ public static void registerConnectionHandler(ConnectionHandler<? extends ConnectionHandlerCfg>
handler)
{
synchronized (directoryServer.connectionHandlers)
@@ -6170,7 +6007,7 @@
configClass = null;
configFile = null;
- configHandler = null;
+ configurationHandler = null;
coreConfigManager = null;
compressedSchema = null;
cryptoManager = null;
@@ -6727,14 +6564,14 @@
{
try
{
- if (configHandler == null)
+ if (configurationHandler == null)
{
// The config handler hasn't been initialized yet. Just return the DN
// of the root DSE.
return DN.rootDN();
}
- return configHandler.getConfigRootEntry().getDN();
+ return configurationHandler.getRootEntry().getName();
}
catch (Exception e)
{
@@ -6834,7 +6671,7 @@
.description(INFO_DSCORE_DESCRIPTION_CONFIG_CLASS.get())
.hidden()
.required()
- .defaultValue(ConfigFileHandler.class.getName())
+ .defaultValue(ConfigurationHandler.class.getName())
.valuePlaceholder(INFO_CONFIGCLASS_PLACEHOLDER.get())
.buildAndAddToParser(argParser);
configFile =
@@ -7136,8 +6973,7 @@
{
theDirectoryServer.setEnvironmentConfig(environmentConfig);
theDirectoryServer.bootstrapServer();
- theDirectoryServer.initializeConfiguration(configClass.getValue(),
- configFile.getValue());
+ theDirectoryServer.initializeConfiguration(configClass.getValue(), configFile.getValue());
}
catch (InitializationException ie)
{
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/core/MatchingRuleConfigManager.java b/opendj-server-legacy/src/main/java/org/opends/server/core/MatchingRuleConfigManager.java
index 025abff..5c59ab7 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/core/MatchingRuleConfigManager.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/core/MatchingRuleConfigManager.java
@@ -32,7 +32,6 @@
import org.forgerock.opendj.config.server.ConfigurationAddListener;
import org.forgerock.opendj.config.server.ConfigurationChangeListener;
import org.forgerock.opendj.config.server.ConfigurationDeleteListener;
-import org.forgerock.opendj.config.server.ServerManagementContext;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.forgerock.opendj.server.config.meta.MatchingRuleCfgDefn;
@@ -97,7 +96,7 @@
public void initializeMatchingRules()
throws ConfigException, InitializationException
{
- RootCfg rootConfiguration = ServerManagementContext.getInstance().getRootConfiguration();
+ RootCfg rootConfiguration = serverContext.getServerManagementContext().getRootConfiguration();
// Register as an add and delete listener with the root configuration so we
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/core/PluginConfigManager.java b/opendj-server-legacy/src/main/java/org/opends/server/core/PluginConfigManager.java
index b2f00a9..dd99e56 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/core/PluginConfigManager.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/core/PluginConfigManager.java
@@ -411,7 +411,7 @@
if (initialize)
{
- plugin.initializeInternal(configuration.dn(), pluginTypes,
+ plugin.initializeInternal(serverContext, configuration.dn(), pluginTypes,
configuration.isInvokeForInternalOperations());
plugin.initializePlugin(pluginTypes, configuration);
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/extensions/ConfigFileHandler.java b/opendj-server-legacy/src/main/java/org/opends/server/extensions/ConfigFileHandler.java
index f58f1d0..193b7cf 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/extensions/ConfigFileHandler.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/extensions/ConfigFileHandler.java
@@ -2054,7 +2054,7 @@
// this class as a backend and not as the config handler. We need it as a
// config handler to determine the path to the config file, so we can get
// that from the Directory Server object.
- return new File(((ConfigFileHandler) DirectoryServer.getConfigHandler()).configFile);
+ return new File(((ConfigFileHandler) DirectoryServer.getConfigurationHandler()).configFile);
}
/** {@inheritDoc} */
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/loggers/CommonAudit.java b/opendj-server-legacy/src/main/java/org/opends/server/loggers/CommonAudit.java
index 4a44075..f7fbd4f 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/loggers/CommonAudit.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/loggers/CommonAudit.java
@@ -77,8 +77,10 @@
import org.forgerock.opendj.server.config.server.SizeLimitLogRotationPolicyCfg;
import org.forgerock.opendj.server.config.server.TimeLimitLogRotationPolicyCfg;
import org.opends.server.types.Entry;
+import org.opends.server.types.ObjectClass;
import org.opends.server.core.DirectoryServer;
import org.forgerock.opendj.ldap.DN;
+import org.opends.server.core.ServerContext;
import org.opends.server.util.StaticUtils;
/**
@@ -119,14 +121,20 @@
private final AtomicBoolean trustTransactionIds = new AtomicBoolean(false);
+ private final ServerContext serverContext;
+
/**
* Creates the common audit.
*
+ * @param serverContext
+ * The server context.
+ *
* @throws ConfigException
* If an error occurs.
*/
- public CommonAudit() throws ConfigException
+ public CommonAudit(ServerContext serverContext) throws ConfigException
{
+ this.serverContext = serverContext;
configurationFramework = ConfigurationFramework.getInstance();
this.dependencyProvider = new CommonAuditDependencyProvider();
this.httpAccessAuditService = createAuditServiceWithoutHandlers();
@@ -184,7 +192,7 @@
*/
public RequestHandler getRequestHandler(LogPublisherCfg config) throws ConfigException
{
- if (new PublisherConfig(config).isHttpAccessLog())
+ if (new PublisherConfig(serverContext, config).isHttpAccessLog())
{
return httpAccessAuditService;
}
@@ -206,7 +214,7 @@
logger.trace(String.format("Setting up common audit for configuration entry: %s", newConfig.dn()));
try
{
- final PublisherConfig newPublisher = new PublisherConfig(newConfig);
+ final PublisherConfig newPublisher = new PublisherConfig(serverContext, newConfig);
String normalizedName = getConfigNormalizedName(newConfig);
if (newPublisher.isHttpAccessLog())
{
@@ -645,7 +653,7 @@
*/
public boolean isCommonAuditConfig(LogPublisherCfg config) throws ConfigException
{
- return new PublisherConfig(config).isCommonAudit();
+ return new PublisherConfig(serverContext, config).isCommonAudit();
}
/**
@@ -703,26 +711,26 @@
private LogType logType;
private AuditType auditType;
- PublisherConfig(LogPublisherCfg config) throws ConfigException
+ PublisherConfig(ServerContext serverContext, LogPublisherCfg config) throws ConfigException
{
this.config = config;
Entry configEntry = DirectoryServer.getConfigEntry(config.dn());
- if (configEntry.hasObjectClass("ds-cfg-csv-file-access-log-publisher"))
+ if (hasObjectClass(serverContext,configEntry, "ds-cfg-csv-file-access-log-publisher"))
{
auditType = AuditType.CSV;
logType = LogType.ACCESS;
}
- else if (configEntry.hasObjectClass("ds-cfg-csv-file-http-access-log-publisher"))
+ else if (hasObjectClass(serverContext,configEntry, "ds-cfg-csv-file-http-access-log-publisher"))
{
auditType = AuditType.CSV;
logType = LogType.HTTP_ACCESS;
}
- else if (configEntry.hasObjectClass("ds-cfg-external-access-log-publisher"))
+ else if (hasObjectClass(serverContext,configEntry, "ds-cfg-external-access-log-publisher"))
{
auditType = AuditType.EXTERNAL;
logType = LogType.ACCESS;
}
- else if (configEntry.hasObjectClass("ds-cfg-external-http-access-log-publisher"))
+ else if (hasObjectClass(serverContext,configEntry, "ds-cfg-external-http-access-log-publisher"))
{
auditType = AuditType.EXTERNAL;
logType = LogType.HTTP_ACCESS;
@@ -730,6 +738,12 @@
isCommonAudit = auditType != null;
}
+ private boolean hasObjectClass(ServerContext serverContext, Entry entry, String objectClassName)
+ {
+ ObjectClass objectClass = serverContext.getSchema().getObjectClass(objectClassName);
+ return objectClass != null && entry.hasObjectClass(objectClass);
+ }
+
DN getDn()
{
return config.dn();
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/FractionalLDIFImportPlugin.java b/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/FractionalLDIFImportPlugin.java
index 4d020e9..3402bdc 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/FractionalLDIFImportPlugin.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/FractionalLDIFImportPlugin.java
@@ -39,6 +39,7 @@
import org.opends.server.api.plugin.PluginResult;
import org.opends.server.api.plugin.PluginType;
import org.opends.server.core.DirectoryServer;
+import org.opends.server.core.ServerContext;
import org.opends.server.replication.plugin.LDAPReplicationDomain.FractionalConfig;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeBuilder;
@@ -167,7 +168,7 @@
* passed entry. Null if no configuration is found for the domain
* (not a replicated domain).
*/
- private static FractionalConfig getStaticReplicationDomainFractionalConfig(
+ private static FractionalConfig getStaticReplicationDomainFractionalConfig(ServerContext serverContext,
Entry entry) throws Exception {
RootCfg root = serverContext.getServerManagementContext().getRootConfiguration();
ReplicationSynchronizationProviderCfg sync =
@@ -275,7 +276,7 @@
try
{
localFractionalConfig =
- getStaticReplicationDomainFractionalConfig(entry);
+ getStaticReplicationDomainFractionalConfig(getServerContext(), entry);
} catch (Exception ex)
{
return PluginResult.ImportLDIF.stopEntryProcessing(
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/LDAPReplicationDomain.java b/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/LDAPReplicationDomain.java
index a981d2d..29b844f 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/LDAPReplicationDomain.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/LDAPReplicationDomain.java
@@ -59,6 +59,7 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.LocalizedIllegalArgumentException;
import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.forgerock.opendj.adapter.server3x.Converters;
import org.forgerock.opendj.config.server.ConfigChangeResult;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.AVA;
@@ -69,6 +70,7 @@
import org.forgerock.opendj.ldap.RDN;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
+import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.config.server.ConfigurationChangeListener;
import org.forgerock.opendj.server.config.meta.ReplicationDomainCfgDefn.IsolationPolicy;
import org.forgerock.opendj.server.config.server.ExternalChangelogDomainCfg;
@@ -85,6 +87,7 @@
import org.opends.server.config.ConfigConstants;
import org.opends.server.controls.PagedResultsControl;
import org.opends.server.core.AddOperation;
+import org.opends.server.core.ConfigurationHandler;
import org.opends.server.core.DeleteOperation;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.LockFileManager;
@@ -3862,9 +3865,9 @@
try
{
DN eclConfigEntryDN = DN.valueOf("cn=external changeLog," + config.dn());
- if (DirectoryServer.getConfigHandler().entryExists(eclConfigEntryDN))
+ if (DirectoryServer.getConfigurationHandler().hasEntry(eclConfigEntryDN))
{
- DirectoryServer.getConfigHandler().deleteEntry(eclConfigEntryDN, null);
+ DirectoryServer.getConfigurationHandler().deleteEntry(eclConfigEntryDN);
}
}
catch(Exception e)
@@ -3889,7 +3892,8 @@
try
{
DN configDn = config.dn();
- if (DirectoryServer.getConfigHandler().entryExists(configDn))
+ ConfigurationHandler configHandler = DirectoryServer.getConfigurationHandler();
+ if (configHandler.hasEntry(config.dn()))
{
try
{ eclDomCfg = domCfg.getExternalChangelogDomain();
@@ -3900,7 +3904,7 @@
// no ECL config provided hence create a default one
// create the default one
DN eclConfigEntryDN = DN.valueOf("cn=external changelog," + configDn);
- if (!DirectoryServer.getConfigHandler().entryExists(eclConfigEntryDN))
+ if (!configHandler.hasEntry(eclConfigEntryDN))
{
// no entry exist yet for the ECL config for this domain
// create it
@@ -3916,7 +3920,7 @@
ldifImportConfig.setValidateSchema(false);
LDIFReader reader = new LDIFReader(ldifImportConfig);
Entry eclEntry = reader.readEntry();
- DirectoryServer.getConfigHandler().addEntry(eclEntry, null);
+ configHandler.addEntry(Converters.from(eclEntry));
ldifImportConfig.close();
}
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tasks/TaskUtils.java b/opendj-server-legacy/src/main/java/org/opends/server/tasks/TaskUtils.java
index b2403c0..3afa943 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tasks/TaskUtils.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tasks/TaskUtils.java
@@ -16,6 +16,8 @@
*/
package org.opends.server.tasks;
+import static org.opends.server.config.ConfigConstants.ATTR_BACKEND_ID;
+
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -23,17 +25,18 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.forgerock.opendj.adapter.server3x.Converters;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.requests.ModifyRequest;
-import org.opends.messages.TaskMessages;
import org.forgerock.opendj.config.server.ServerManagementContext;
import org.forgerock.opendj.server.config.server.BackendCfg;
import org.forgerock.opendj.server.config.server.RootCfg;
import org.opends.server.api.Backend;
+import org.opends.server.tools.BackendToolUtils;
import org.opends.server.types.Entry;
-import org.opends.server.config.StringConfigAttribute;
+import org.opends.server.core.ConfigurationHandler;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.ModifyOperation;
import org.opends.server.types.Attribute;
@@ -42,7 +45,6 @@
import static org.forgerock.opendj.ldap.ModificationType.*;
import static org.forgerock.opendj.ldap.requests.Requests.*;
-import static org.opends.messages.ConfigMessages.*;
import static org.opends.messages.TaskMessages.*;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.config.ConfigConstants.*;
@@ -70,19 +72,7 @@
{
try
{
- StringConfigAttribute idStub =
- new StringConfigAttribute(
- ATTR_BACKEND_ID,
- INFO_CONFIG_BACKEND_ATTR_DESCRIPTION_BACKEND_ID.get(),
- true, false, true);
- StringConfigAttribute idAttr =
- (StringConfigAttribute) configEntry.getConfigAttribute(idStub);
- return idAttr.activeValue();
- }
- catch (org.opends.server.config.ConfigException ce)
- {
- logger.error(ERR_CANNOT_DETERMINE_BACKEND_ID, configEntry.getName(), ce.getMessage());
- return null;
+ return BackendToolUtils.getStringSingleValuedAttribute(configEntry, ATTR_BACKEND_ID);
}
catch (Exception e)
{
@@ -114,57 +104,38 @@
return configEntries;
}
- Entry baseEntry;
- try
- {
- baseEntry = DirectoryServer.getConfigEntry(backendBaseDN);
- }
- catch (ConfigException ce)
- {
- logger.error(ERR_CANNOT_RETRIEVE_BACKEND_BASE_ENTRY, DN_BACKEND_BASE, ce.getMessage());
- return configEntries;
- }
- catch (Exception e)
- {
- logger.error(ERR_CANNOT_RETRIEVE_BACKEND_BASE_ENTRY, DN_BACKEND_BASE, getExceptionMessage(e));
- return configEntries;
- }
-
-
// Iterate through the immediate children, attempting to parse them as
// backends.
- for (Entry configEntry : baseEntry.getChildren().values())
+ try
{
- // Get the backend ID attribute from the entry. If there isn't one, then
- // skip the entry.
- String backendID;
- try
+ ConfigurationHandler configHandler = DirectoryServer.getConfigurationHandler();
+ for (DN childrenDn : configHandler.getChildren(backendBaseDN))
{
- StringConfigAttribute idStub =
- new StringConfigAttribute(
- ATTR_BACKEND_ID,
- INFO_CONFIG_BACKEND_ATTR_DESCRIPTION_BACKEND_ID.get(),
- true, false, true);
- StringConfigAttribute idAttr =
- (StringConfigAttribute) configEntry.getConfigAttribute(idStub);
- if (idAttr == null)
+ // Get the backend ID attribute from the entry. If there isn't one, then
+ // skip the entry.
+ Entry configEntry = null;
+ String backendID;
+ try
{
+ configEntry = Converters.to(configHandler.getEntry(childrenDn));
+ backendID = BackendToolUtils.getStringSingleValuedAttribute(configEntry, ATTR_BACKEND_ID);
+ if (backendID == null)
+ {
+ continue;
+ }
+ }
+ catch (Exception e)
+ {
+ logger.error(ERR_CANNOT_DETERMINE_BACKEND_ID, childrenDn, getExceptionMessage(e));
continue;
}
- backendID = idAttr.activeValue();
- }
- catch (org.opends.server.config.ConfigException ce)
- {
- logger.error(ERR_CANNOT_DETERMINE_BACKEND_ID, configEntry.getName(), ce.getMessage());
- continue;
- }
- catch (Exception e)
- {
- logger.error(ERR_CANNOT_DETERMINE_BACKEND_ID, configEntry.getName(), getExceptionMessage(e));
- continue;
- }
- configEntries.put(backendID, configEntry);
+ configEntries.put(backendID, configEntry);
+ }
+ }
+ catch (ConfigException e)
+ {
+ logger.error(ERR_CANNOT_RETRIEVE_BACKEND_BASE_ENTRY, DN_BACKEND_BASE, e.getMessage());
}
return configEntries;
@@ -179,8 +150,7 @@
*/
public static BackendCfg getConfigEntry(Backend<?> backend)
{
- RootCfg root = ServerManagementContext.getInstance().
- getRootConfiguration();
+ RootCfg root = getServerManagementContext().getRootConfiguration();
try
{
return root.getBackend(backend.getBackendID());
@@ -191,7 +161,10 @@
}
}
-
+ private static ServerManagementContext getServerManagementContext()
+ {
+ return DirectoryServer.getInstance().getServerContext().getServerManagementContext();
+ }
/**
* Enables a backend using an internal modify operation on the
@@ -204,7 +177,7 @@
throws DirectoryException
{
DN configEntryDN;
- RootCfg root = serverContext.getServerManagementContext().getRootConfiguration();
+ RootCfg root = getServerManagementContext().getRootConfiguration();
try
{
BackendCfg cfg = root.getBackend(backendID);
@@ -240,7 +213,7 @@
public static void disableBackend(String backendID) throws DirectoryException
{
DN configEntryDN;
- RootCfg root = serverContext.getServerManagementContext().getRootConfiguration();
+ RootCfg root = getServerManagementContext().getRootConfiguration();
try
{
BackendCfg cfg = root.getBackend(backendID);
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/BackUpDB.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/BackUpDB.java
index e4d5ae3..711b497 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/BackUpDB.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/BackUpDB.java
@@ -20,7 +20,6 @@
import static org.opends.server.config.ConfigConstants.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
-
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static com.forgerock.opendj.cli.Utils.*;
import static com.forgerock.opendj.cli.CommonArguments.*;
@@ -42,10 +41,10 @@
import org.forgerock.opendj.server.config.server.BackendCfg;
import org.opends.server.api.Backend;
import org.opends.server.api.Backend.BackendOperation;
+import org.opends.server.core.ConfigurationHandler;
import org.opends.server.core.CoreConfigManager;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.LockFileManager;
-import org.opends.server.extensions.ConfigFileHandler;
import org.opends.server.loggers.DebugLogger;
import org.opends.server.loggers.ErrorLogPublisher;
import org.opends.server.loggers.ErrorLogger;
@@ -168,7 +167,7 @@
.description(INFO_DESCRIPTION_CONFIG_CLASS.get())
.hidden()
.required()
- .defaultValue(ConfigFileHandler.class.getName())
+ .defaultValue(ConfigurationHandler.class.getName())
.valuePlaceholder(INFO_CONFIGCLASS_PLACEHOLDER.get())
.buildAndAddToParser(argParser);
configFile =
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/BackendToolUtils.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/BackendToolUtils.java
index 8236d0c..93c9258 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/BackendToolUtils.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/BackendToolUtils.java
@@ -16,21 +16,22 @@
*/
package org.opends.server.tools;
+import java.util.ArrayList;
import java.util.List;
import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.forgerock.opendj.adapter.server3x.Converters;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.DN;
-import org.forgerock.opendj.config.server.ServerManagementContext;
+import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.server.config.server.BackendCfg;
import org.forgerock.opendj.server.config.server.RootCfg;
import org.opends.server.api.Backend;
import org.opends.server.types.Entry;
-import org.opends.server.config.DNConfigAttribute;
-import org.opends.server.config.StringConfigAttribute;
+import org.opends.server.core.ConfigurationHandler;
import org.opends.server.core.DirectoryServer;
+import org.opends.server.types.Attribute;
-import static org.opends.messages.ConfigMessages.*;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.config.ConfigConstants.*;
import static org.opends.server.util.StaticUtils.*;
@@ -64,13 +65,14 @@
{
try
{
- final DN backendBaseDN = getBackendBaseDN();
- final Entry baseEntry = getBaseEntry(backendBaseDN);
-
// Iterate through the immediate children, attempting to parse them as backends.
- final RootCfg root = ServerManagementContext.getInstance().getRootConfiguration();
- for (final Entry configEntry : baseEntry.getChildren().values())
+ final RootCfg root =
+ DirectoryServer.getInstance().getServerContext().getServerManagementContext().getRootConfiguration();
+ ConfigurationHandler configHandler = DirectoryServer.getConfigurationHandler();
+ final DN backendBaseDN = getBackendBaseDN();
+ for (final DN childrenDn : configHandler.getChildren(backendBaseDN))
{
+ Entry configEntry = Converters.to(configHandler.getEntry(childrenDn));
final String backendID = getBackendID(configEntry);
final String backendClassName = getBackendClassName(configEntry);
if (backendID == null || backendClassName == null)
@@ -109,16 +111,41 @@
}
}
+ /**
+ * Returns a string from the single valued attribute in provided entry.
+ *
+ * @param entry the entry
+ * @param attrName the attribute name
+ * @return the string value if available or {@code null}
+ */
+ public static String getStringSingleValuedAttribute(Entry entry, String attrName)
+ {
+ List<Attribute> attributes = entry.getAttribute(attrName);
+ if (!attributes.isEmpty())
+ {
+ Attribute attribute = attributes.get(0);
+ for (ByteString byteString : attribute)
+ {
+ return byteString.toString();
+ }
+ }
+ return null;
+ }
+
private static List<DN> getBaseDNsForEntry(final Entry configEntry) throws Exception
{
try
{
- final DNConfigAttribute baseDNStub = new DNConfigAttribute(
- ATTR_BACKEND_BASE_DN, INFO_CONFIG_BACKEND_ATTR_DESCRIPTION_BASE_DNS.get(), true, true, true);
- final DNConfigAttribute baseDNAttr = (DNConfigAttribute) configEntry.getConfigAttribute(baseDNStub);
- if (baseDNAttr != null)
+ List<Attribute> attributes = configEntry.getAttribute(ATTR_BACKEND_BASE_DN);
+ if (!attributes.isEmpty())
{
- return baseDNAttr.activeValues();
+ Attribute attribute = attributes.get(0);
+ List<DN> dns = new ArrayList<>();
+ for (ByteString byteString : attribute)
+ {
+ dns.add(DN.valueOf(byteString.toString()));
+ }
+ return dns;
}
logger.error(ERR_NO_BASES_FOR_BACKEND, configEntry.getName());
return null;
@@ -147,15 +174,7 @@
{
try
{
- final StringConfigAttribute classStub = new StringConfigAttribute(
- ATTR_BACKEND_CLASS, INFO_CONFIG_BACKEND_ATTR_DESCRIPTION_CLASS.get(), true, false, false);
- final StringConfigAttribute classAttr = (StringConfigAttribute) configEntry.getConfigAttribute(classStub);
- return classAttr != null ? classAttr.activeValue() : null;
- }
- catch (final org.opends.server.config.ConfigException ce)
- {
- logger.error(ERR_CANNOT_DETERMINE_BACKEND_CLASS, configEntry.getName(), ce.getMessage());
- throw ce;
+ return getStringSingleValuedAttribute(configEntry, ATTR_BACKEND_CLASS);
}
catch (final Exception e)
{
@@ -168,15 +187,7 @@
{
try
{
- final StringConfigAttribute idStub = new StringConfigAttribute(
- ATTR_BACKEND_ID, INFO_CONFIG_BACKEND_ATTR_DESCRIPTION_BACKEND_ID.get(), true, false, true);
- final StringConfigAttribute idAttr = (StringConfigAttribute) configEntry.getConfigAttribute(idStub);
- return idAttr != null ? idAttr.activeValue() : null;
- }
- catch (final org.opends.server.config.ConfigException ce)
- {
- logger.error(ERR_CANNOT_DETERMINE_BACKEND_ID, configEntry.getName(), ce.getMessage());
- throw ce;
+ return getStringSingleValuedAttribute(configEntry, ATTR_BACKEND_ID);
}
catch (final Exception e)
{
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/ConfigureDS.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/ConfigureDS.java
index ab74ca1..4d24de8 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/ConfigureDS.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/ConfigureDS.java
@@ -20,8 +20,6 @@
import static com.forgerock.opendj.cli.CliMessages.INFO_JMXPORT_PLACEHOLDER;
import static com.forgerock.opendj.cli.CliMessages.INFO_PORT_PLACEHOLDER;
import static org.opends.messages.ConfigMessages.*;
-import static org.opends.messages.ExtensionMessages.*;
-import static org.opends.messages.ProtocolMessages.*;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.config.ConfigConstants.*;
import static org.opends.server.util.ServerConstants.*;
@@ -47,29 +45,31 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.LocalizedIllegalArgumentException;
+import org.forgerock.opendj.adapter.server3x.Converters;
import org.forgerock.opendj.config.ManagedObjectDefinition;
import org.forgerock.opendj.ldap.DN;
+import org.forgerock.opendj.ldap.LinkedAttribute;
+import org.forgerock.opendj.ldap.LinkedHashMapEntry;
+import org.forgerock.opendj.ldap.AttributeDescription;
+import org.forgerock.opendj.ldap.ByteString;
+import org.forgerock.opendj.ldap.schema.AttributeType;
+import org.forgerock.opendj.ldap.schema.Syntax;
import org.forgerock.opendj.server.config.client.BackendCfgClient;
import org.forgerock.opendj.server.config.server.BackendCfg;
import org.opends.quicksetup.installer.Installer;
import org.forgerock.opendj.config.DefaultBehaviorProvider;
import org.forgerock.opendj.config.DefinedDefaultBehaviorProvider;
import org.forgerock.opendj.config.StringPropertyDefinition;
+import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.server.config.meta.CryptoManagerCfgDefn;
-import org.opends.server.api.ConfigHandler;
-import org.opends.server.config.BooleanConfigAttribute;
import org.opends.server.types.Entry;
-import org.opends.server.config.DNConfigAttribute;
-import org.opends.server.config.IntegerConfigAttribute;
-import org.opends.server.config.StringConfigAttribute;
+import org.opends.server.core.ConfigurationHandler;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.LockFileManager;
-import org.opends.server.extensions.ConfigFileHandler;
import org.opends.server.extensions.SaltedSHA512PasswordStorageScheme;
import org.opends.server.protocols.ldap.LDAPResultCode;
import org.opends.server.types.DirectoryEnvironmentConfig;
import org.opends.server.types.DirectoryException;
-import org.opends.server.types.Entry;
import org.opends.server.types.InitializationException;
import org.opends.server.types.LDIFImportConfig;
import org.opends.server.types.NullOutputStream;
@@ -157,9 +157,9 @@
}
}
- //FIXME: Find a better way to do to prevent hardcoded ldif entries.
private static final String NEW_LINE = System.getProperty("line.separator");
+ // FIXME: Find a better way to prevent hardcoded ldif entries.
private static final String JCKES_KEY_MANAGER_DN = "cn=JCEKS,cn=Key Manager Providers,cn=config";
private static final String JCKES_KEY_MANAGER_LDIF_ENTRY =
"dn: " + JCKES_KEY_MANAGER_DN + NEW_LINE
@@ -277,7 +277,7 @@
private final String serverLockFileName = LockFileManager.getServerLockFileName();
private final StringBuilder failureReason = new StringBuilder();
- private ConfigHandler<?> configHandler;
+ private ConfigurationHandler configHandler;
private ConfigureDS(final String[] args, final OutputStream outStream, final OutputStream errStream)
{
@@ -311,7 +311,7 @@
// Get the Directory Server configuration handler and use it to make the
// appropriate configuration changes.
- configHandler = DirectoryServer.getConfigHandler();
+ configHandler = DirectoryServer.getConfigurationHandler();
checkManagerProvider(keyManagerProviderDN, JCKES_KEY_MANAGER_DN, JCKES_KEY_MANAGER_LDIF_ENTRY, true);
checkManagerProvider(trustManagerProviderDN, JCKES_TRUST_MANAGER_DN, JCKES_TRUST_MANAGER_LDIF_ENTRY, false);
@@ -333,7 +333,7 @@
updateRootUser(rootDN, rootPW);
addFQDNDigestMD5();
updateCryptoCipher();
- writeUpdatedConfiguration();
+ printWrappedText(out, INFO_CONFIGDS_WROTE_UPDATED_CONFIG.get());
return SUCCESS;
}
@@ -372,10 +372,9 @@
.shortIdentifier(OPTION_SHORT_CONFIG_CLASS)
.description(INFO_DESCRIPTION_CONFIG_CLASS.get())
.hidden()
- .defaultValue(ConfigFileHandler.class.getName())
+ .defaultValue(ConfigurationHandler.class.getName())
.valuePlaceholder(INFO_CONFIGCLASS_PLACEHOLDER.get())
.buildAndAddToParser(argParser);
-
String defaultHostName;
try
{
@@ -714,7 +713,7 @@
Entry mangerConfigEntry;
while ((mangerConfigEntry = reader.readEntry()) != null)
{
- configHandler.addEntry(mangerConfigEntry, null);
+ configHandler.addEntry(Converters.from(mangerConfigEntry));
}
}
catch (final Exception e)
@@ -732,7 +731,7 @@
{
try
{
- configHandler.getConfigEntry(dn);
+ getConfigEntry(dn);
}
catch (final Exception e)
{
@@ -776,11 +775,10 @@
{
try
{
- final IntegerConfigAttribute portAttr = new IntegerConfigAttribute(
- ATTR_LISTEN_PORT, INFO_LDAP_CONNHANDLER_DESCRIPTION_LISTEN_PORT.get(),
- true, false, true, true, 1, true, 65535, ldapPort.getIntValue());
- final Entry configEntry = configHandler.getConfigEntry(DN.valueOf(DN_LDAP_CONNECTION_HANDLER));
- configEntry.putConfigAttribute(portAttr);
+ updateConfigEntryWithAttribute(
+ DN_LDAP_CONNECTION_HANDLER, ATTR_LISTEN_PORT,
+ DirectoryServer.getDefaultIntegerSyntax(),
+ ByteString.valueOfInt(ldapPort.getIntValue()));
}
catch (final Exception e)
{
@@ -795,11 +793,11 @@
{
try
{
- final IntegerConfigAttribute portAttr = new IntegerConfigAttribute(
- ATTR_LISTEN_PORT, INFO_LDAP_CONNHANDLER_DESCRIPTION_LISTEN_PORT.get(),
- true, false, true, true, 1, true, 65535, adminConnectorPort.getIntValue());
- final Entry configEntry = configHandler.getConfigEntry(DN.valueOf(DN_ADMIN_CONNECTOR));
- configEntry.putConfigAttribute(portAttr);
+ updateConfigEntryWithAttribute(
+ DN_ADMIN_CONNECTOR,
+ ATTR_LISTEN_PORT,
+ DirectoryServer.getDefaultIntegerSyntax(),
+ ByteString.valueOfInt(adminConnectorPort.getIntValue()));
}
catch (final Exception e)
{
@@ -814,15 +812,17 @@
{
try
{
- final IntegerConfigAttribute portAttr = new IntegerConfigAttribute(
- ATTR_LISTEN_PORT, INFO_LDAP_CONNHANDLER_DESCRIPTION_LISTEN_PORT.get(),
- true, false, true, true, 1, true, 65535, ldapsPort.getIntValue());
- final Entry configEntry = configHandler.getConfigEntry(DN.valueOf(DN_LDAPS_CONNECTION_HANDLER));
- configEntry.putConfigAttribute(portAttr);
+ updateConfigEntryWithAttribute(
+ DN_LDAPS_CONNECTION_HANDLER,
+ ATTR_LISTEN_PORT,
+ DirectoryServer.getDefaultIntegerSyntax(),
+ ByteString.valueOfInt(ldapsPort.getIntValue()));
- final BooleanConfigAttribute enablePortAttr = new BooleanConfigAttribute(
- ATTR_CONNECTION_HANDLER_ENABLED, INFO_LDAPS_CONNHANDLER_DESCRIPTION_ENABLE.get(), true, true);
- configEntry.putConfigAttribute(enablePortAttr);
+ updateConfigEntryWithAttribute(
+ DN_LDAPS_CONNECTION_HANDLER,
+ ATTR_CONNECTION_HANDLER_ENABLED,
+ DirectoryServer.getDefaultBooleanSyntax(),
+ ByteString.valueOfUtf8("TRUE"));
}
catch (final Exception e)
{
@@ -837,16 +837,17 @@
{
try
{
+ updateConfigEntryWithAttribute(
+ DN_JMX_CONNECTION_HANDLER,
+ ATTR_LISTEN_PORT,
+ DirectoryServer.getDefaultIntegerSyntax(),
+ ByteString.valueOfInt(jmxPort.getIntValue()));
- final IntegerConfigAttribute portAttr = new IntegerConfigAttribute(
- ATTR_LISTEN_PORT, INFO_JMX_CONNHANDLER_DESCRIPTION_LISTEN_PORT.get(),
- true, false, true, true, 1, true, 65535, jmxPort.getIntValue());
- final Entry configEntry = configHandler.getConfigEntry(DN.valueOf(DN_JMX_CONNECTION_HANDLER));
- configEntry.putConfigAttribute(portAttr);
-
- final BooleanConfigAttribute enablePortAttr = new BooleanConfigAttribute(
- ATTR_CONNECTION_HANDLER_ENABLED, INFO_JMX_CONNHANDLER_DESCRIPTION_ENABLE.get(), true, true);
- configEntry.putConfigAttribute(enablePortAttr);
+ updateConfigEntryWithAttribute(
+ DN_JMX_CONNECTION_HANDLER,
+ ATTR_CONNECTION_HANDLER_ENABLED,
+ DirectoryServer.getDefaultBooleanSyntax(),
+ ByteString.valueOfUtf8("TRUE"));
}
catch (final Exception e)
{
@@ -861,10 +862,11 @@
{
try
{
- final BooleanConfigAttribute startTLS = new BooleanConfigAttribute(
- ATTR_ALLOW_STARTTLS, INFO_LDAP_CONNHANDLER_DESCRIPTION_ALLOW_STARTTLS.get(), true, true);
- final Entry configEntry = configHandler.getConfigEntry(DN.valueOf(DN_LDAP_CONNECTION_HANDLER));
- configEntry.putConfigAttribute(startTLS);
+ updateConfigEntryWithAttribute(
+ DN_LDAP_CONNECTION_HANDLER,
+ ATTR_ALLOW_STARTTLS,
+ DirectoryServer.getDefaultBooleanSyntax(),
+ ByteString.valueOfUtf8("TRUE"));
}
catch (final Exception e)
{
@@ -882,10 +884,11 @@
try
{
// Enable the key manager
- final BooleanConfigAttribute enableAttr = new BooleanConfigAttribute(
- ATTR_KEYMANAGER_ENABLED, INFO_CONFIG_KEYMANAGER_DESCRIPTION_ENABLED.get(), true, true);
- final Entry configEntry = configHandler.getConfigEntry(DN.valueOf(keyManagerProviderDN.getValue()));
- configEntry.putConfigAttribute(enableAttr);
+ updateConfigEntryWithAttribute(
+ keyManagerProviderDN.getValue(),
+ ATTR_KEYMANAGER_ENABLED,
+ DirectoryServer.getDefaultBooleanSyntax(),
+ ByteString.valueOfUtf8("TRUE"));
}
catch (final Exception e)
{
@@ -901,11 +904,11 @@
{
try
{
- final StringConfigAttribute pathAttr = new StringConfigAttribute(
- ATTR_KEYSTORE_FILE, INFO_FILE_KEYMANAGER_DESCRIPTION_FILE.get(),
- true, true, true, keyManagerPath.getValue());
- final Entry configEntry = configHandler.getConfigEntry(DN.valueOf(keyManagerProviderDN.getValue()));
- configEntry.putConfigAttribute(pathAttr);
+ updateConfigEntryWithAttribute(
+ keyManagerProviderDN.getValue(),
+ ATTR_KEYSTORE_FILE,
+ DirectoryServer.getDefaultStringSyntax(),
+ ByteString.valueOfUtf8(keyManagerPath.getValue()));
}
catch (final Exception e)
{
@@ -922,11 +925,11 @@
{
try
{
- final StringConfigAttribute keyManagerProviderAttr = new StringConfigAttribute(
- ATTR_KEYMANAGER_DN, INFO_LDAP_CONNHANDLER_DESCRIPTION_KEYMANAGER_DN.get(),
- false, false, true, keyManagerProviderDN.getValue());
- final Entry configEntry = configHandler.getConfigEntry(DN.valueOf(attributeDN));
- configEntry.putConfigAttribute(keyManagerProviderAttr);
+ updateConfigEntryWithAttribute(
+ attributeDN,
+ ATTR_KEYMANAGER_DN,
+ DirectoryServer.getDefaultStringSyntax(),
+ ByteString.valueOfUtf8(keyManagerProviderDN.getValue()));
}
catch (final Exception e)
{
@@ -943,10 +946,11 @@
{
try
{
- final BooleanConfigAttribute enableAttr = new BooleanConfigAttribute(
- ATTR_TRUSTMANAGER_ENABLED, ERR_CONFIG_TRUSTMANAGER_DESCRIPTION_ENABLED.get(), true, true);
- final Entry configEntry = configHandler.getConfigEntry(DN.valueOf(trustManagerProviderDN.getValue()));
- configEntry.putConfigAttribute(enableAttr);
+ updateConfigEntryWithAttribute(
+ trustManagerProviderDN.getValue(),
+ ATTR_TRUSTMANAGER_ENABLED,
+ DirectoryServer.getDefaultBooleanSyntax(),
+ ByteString.valueOfUtf8("TRUE"));
}
catch (final Exception e)
{
@@ -960,17 +964,10 @@
if (certNickNames.isPresent())
{
- final StringConfigAttribute certNickNamesAttr = new StringConfigAttribute(
- ATTR_SSL_CERT_NICKNAME, INFO_LDAP_CONNHANDLER_DESCRIPTION_SSL_CERT_NICKNAME.get(),
- false, true, true, certNickNames.getValues());
- updateCertNicknameEntry(ldapPort, DN_LDAP_CONNECTION_HANDLER, certNickNamesAttr);
- updateCertNicknameEntry(ldapsPort, DN_LDAPS_CONNECTION_HANDLER, certNickNamesAttr);
- updateCertNicknameEntry(certNickNames, DN_HTTP_CONNECTION_HANDLER, certNickNamesAttr);
-
- final StringConfigAttribute certNickNamesJmxAttr = new StringConfigAttribute(
- ATTR_SSL_CERT_NICKNAME, INFO_JMX_CONNHANDLER_DESCRIPTION_SSL_CERT_NICKNAME.get(),
- false, false, true, certNickNames.getValues());
- updateCertNicknameEntry(jmxPort, DN_JMX_CONNECTION_HANDLER, certNickNamesJmxAttr);
+ updateCertNicknameEntry(ldapPort, DN_LDAP_CONNECTION_HANDLER, ATTR_SSL_CERT_NICKNAME, certNickNames.getValues());
+ updateCertNicknameEntry(ldapsPort, DN_LDAPS_CONNECTION_HANDLER, ATTR_SSL_CERT_NICKNAME, certNickNames.getValues());
+ updateCertNicknameEntry(certNickNames, DN_HTTP_CONNECTION_HANDLER, ATTR_SSL_CERT_NICKNAME, certNickNames.getValues());
+ updateCertNicknameEntry(jmxPort, DN_JMX_CONNECTION_HANDLER, ATTR_SSL_CERT_NICKNAME, certNickNames.getValues());
}
else
{
@@ -988,11 +985,11 @@
{
try
{
- final StringConfigAttribute trustManagerProviderAttr = new StringConfigAttribute(
- ATTR_TRUSTMANAGER_DN, INFO_LDAP_CONNHANDLER_DESCRIPTION_TRUSTMANAGER_DN.get(),
- false, false, true, trustManagerProviderDN.getValue());
- final Entry configEntry = configHandler.getConfigEntry(DN.valueOf(attributeDN));
- configEntry.putConfigAttribute(trustManagerProviderAttr);
+ updateConfigEntryWithAttribute(
+ attributeDN,
+ ATTR_TRUSTMANAGER_DN,
+ DirectoryServer.getDefaultStringSyntax(),
+ ByteString.valueOfUtf8(trustManagerProviderDN.getValue()));
}
catch (final Exception e)
{
@@ -1002,18 +999,27 @@
}
private void updateCertNicknameEntry(final Argument arg, final String attributeDN,
- final StringConfigAttribute configAttr) throws ConfigureDSException
+ final String attrName, final List<String> attrValues) throws ConfigureDSException
{
try
{
- Entry configEntry = configHandler.getConfigEntry(DN.valueOf(attributeDN));
if (arg.isPresent())
{
- configEntry.putConfigAttribute(configAttr);
+ Object[] values = new ByteString[attrValues.size()];
+ int index = 0;
+ for (String attrValue : attrValues)
+ {
+ values[index++] = ByteString.valueOfUtf8(attrValue);
+ }
+ updateConfigEntryWithAttribute(
+ attributeDN,
+ attrName,
+ DirectoryServer.getDefaultStringSyntax(),
+ values);
}
else
{
- configEntry.removeConfigAttribute(ATTR_SSL_CERT_NICKNAME);
+ updateConfigEntryByRemovingAttribute(attributeDN, ATTR_SSL_CERT_NICKNAME);
}
}
catch (final Exception e)
@@ -1026,8 +1032,7 @@
{
try
{
- final Entry configEntry = configHandler.getConfigEntry(DN.valueOf(attributeDN));
- configEntry.removeConfigAttribute(ATTR_SSL_CERT_NICKNAME.toLowerCase());
+ updateConfigEntryByRemovingAttribute(attributeDN, ATTR_SSL_CERT_NICKNAME);
}
catch (final Exception e)
{
@@ -1041,16 +1046,17 @@
{
try
{
- final DNConfigAttribute bindDNAttr = new DNConfigAttribute(
- ATTR_ROOTDN_ALTERNATE_BIND_DN, INFO_CONFIG_ROOTDN_DESCRIPTION_ALTERNATE_BIND_DN.get(),
- false, true, false, rootDN);
- final Entry configEntry = configHandler.getConfigEntry(DN.valueOf(DN_ROOT_USER));
- configEntry.putConfigAttribute(bindDNAttr);
-
+ updateConfigEntryWithAttribute(
+ DN_ROOT_USER,
+ ATTR_ROOTDN_ALTERNATE_BIND_DN,
+ DirectoryServer.getDefaultStringSyntax(),
+ ByteString.valueOfUtf8(rootDN.toString()));
final String encodedPassword = SaltedSHA512PasswordStorageScheme.encodeOffline(getBytes(rootPW));
- final StringConfigAttribute bindPWAttr = new StringConfigAttribute(
- ATTR_USER_PASSWORD, LocalizableMessage.EMPTY, false, false, false, encodedPassword);
- configEntry.putConfigAttribute(bindPWAttr);
+ updateConfigEntryWithAttribute(
+ DN_ROOT_USER,
+ ATTR_USER_PASSWORD,
+ DirectoryServer.getDefaultStringSyntax(),
+ ByteString.valueOfUtf8(encodedPassword));
}
catch (final Exception e)
{
@@ -1064,10 +1070,11 @@
{
try
{
- final StringConfigAttribute fqdnAttr = new StringConfigAttribute(
- "ds-cfg-server-fqdn", LocalizableMessage.EMPTY, false, false, false, hostName.getValue());
- final Entry configEntry = configHandler.getConfigEntry(DN.valueOf(DN_DIGEST_MD5_SASL_MECHANISM));
- configEntry.putConfigAttribute(fqdnAttr);
+ updateConfigEntryWithAttribute(
+ DN_DIGEST_MD5_SASL_MECHANISM,
+ "ds-cfg-server-fqdn",
+ DirectoryServer.getDefaultStringSyntax(),
+ ByteString.valueOfUtf8(hostName.getValue()));
}
catch (final Exception e)
{
@@ -1113,11 +1120,11 @@
{
try
{
- final StringConfigAttribute keyWrappingTransformation = new StringConfigAttribute(
- ATTR_CRYPTO_CIPHER_KEY_WRAPPING_TRANSFORMATION, LocalizableMessage.EMPTY,
- false, false, true, alternativeCipher);
- final Entry configEntry = configHandler.getConfigEntry(DN.valueOf(DN_CRYPTO_MANAGER));
- configEntry.putConfigAttribute(keyWrappingTransformation);
+ updateConfigEntryWithAttribute(
+ DN_CRYPTO_MANAGER,
+ ATTR_CRYPTO_CIPHER_KEY_WRAPPING_TRANSFORMATION,
+ DirectoryServer.getDefaultStringSyntax(),
+ ByteString.valueOfUtf8(alternativeCipher));
}
catch (final Exception e)
{
@@ -1128,17 +1135,73 @@
}
}
- private void writeUpdatedConfiguration() throws ConfigureDSException
+ /** Update a config entry with the provided attribute parameters. */
+ private void updateConfigEntryWithAttribute(String entryDn, String attributeName, Syntax syntax, Object...values)
+ throws DirectoryException, ConfigException
{
- try
+ org.forgerock.opendj.ldap.Entry configEntry = getConfigEntry(DN.valueOf(entryDn));
+ final org.forgerock.opendj.ldap.Entry newEntry = putAttribute(configEntry, attributeName, syntax, values);
+ configHandler.replaceEntry(configEntry, newEntry);
+ }
+
+ /** Update a config entry by removing the provided attribute. */
+ private void updateConfigEntryByRemovingAttribute(String entryDn, String attributeName)
+ throws DirectoryException, ConfigException
+ {
+ final org.forgerock.opendj.ldap.Entry configEntry = getConfigEntry(DN.valueOf(entryDn));
+ final Entry newEntry = removeAttribute(Converters.to(configEntry), attributeName);
+ configHandler.replaceEntry(configEntry, Converters.from(newEntry));
+ }
+
+ private org.forgerock.opendj.ldap.Entry getConfigEntry(DN dn) throws ConfigException
+ {
+ return configHandler.getEntry(dn);
+ }
+
+ /**
+ * Duplicate the provided entry, and put an attribute to the duplicated entry.
+ * <p>
+ * Provided entry is not modified.
+ *
+ * @return the duplicate entry, modified with the attribute
+ */
+ private org.forgerock.opendj.ldap.Entry putAttribute(
+ org.forgerock.opendj.ldap.Entry configEntry, String attrName, Syntax syntax, Object...values)
+ {
+ org.forgerock.opendj.ldap.Entry newEntry = new LinkedHashMapEntry(configEntry);
+ AttributeType attrType = DirectoryServer.getAttributeType(attrName, syntax);
+ newEntry.replaceAttribute(new LinkedAttribute(AttributeDescription.create(attrType), values));
+ return newEntry;
+ }
+
+ /**
+ * Duplicate the provided entry, and remove an attribute to the duplicated entry.
+ * <p>
+ * Provided entry is not modified.
+ *
+ * @return the duplicate entry, with removed attribute
+ */
+ private Entry removeAttribute(Entry entry, String attrName)
+ {
+ Entry duplicateEntry = entry.duplicate(false);
+ for (AttributeType t : entry.getUserAttributes().keySet())
{
- configHandler.writeUpdatedConfig();
- printWrappedText(out, INFO_CONFIGDS_WROTE_UPDATED_CONFIG.get());
+ if (t.hasNameOrOID(attrName))
+ {
+ entry.getUserAttributes().remove(t);
+ return duplicateEntry;
+ }
}
- catch (final DirectoryException de)
+
+ for (AttributeType t : entry.getOperationalAttributes().keySet())
{
- throw new ConfigureDSException(de, ERR_CONFIGDS_CANNOT_WRITE_UPDATED_CONFIG.get(de.getMessageObject()));
+ if (t.hasNameOrOID(attrName))
+ {
+ entry.getOperationalAttributes().remove(t);
+ return duplicateEntry;
+ }
}
+ return duplicateEntry;
}
/**
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/EncodePassword.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/EncodePassword.java
index 482929c..e3fd2b4 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/EncodePassword.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/EncodePassword.java
@@ -38,7 +38,6 @@
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.DN;
-import org.forgerock.opendj.config.server.ServerManagementContext;
import org.forgerock.opendj.server.config.server.BackendCfg;
import org.forgerock.opendj.server.config.server.LDIFBackendCfg;
import org.forgerock.opendj.server.config.server.RootCfg;
@@ -47,12 +46,12 @@
import org.opends.server.api.PasswordStorageScheme;
import org.opends.server.config.ConfigConstants;
import org.opends.server.types.Entry;
+import org.opends.server.core.ConfigurationHandler;
import org.opends.server.core.CoreConfigManager;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.DirectoryServer.DirectoryServerVersionHandler;
import org.opends.server.core.PasswordStorageSchemeConfigManager;
import org.opends.server.crypto.CryptoManagerSync;
-import org.opends.server.extensions.ConfigFileHandler;
import org.opends.server.loggers.JDKLogging;
import org.opends.server.schema.AuthPasswordSyntax;
import org.opends.server.schema.UserPasswordSyntax;
@@ -194,7 +193,7 @@
.description(INFO_DESCRIPTION_CONFIG_CLASS.get())
.hidden()
.required()
- .defaultValue(ConfigFileHandler.class.getName())
+ .defaultValue(ConfigurationHandler.class.getName())
.valuePlaceholder(INFO_CONFIGCLASS_PLACEHOLDER.get())
.buildAndAddToParser(argParser);
configFile =
@@ -715,7 +714,7 @@
throws InitializationException, ConfigException {
directoryServer.initializeRootDSE();
- RootCfg root = serverContext.getServerManagementContext().getRootConfiguration();
+ RootCfg root = directoryServer.getServerContext().getServerManagementContext().getRootConfiguration();
Entry backendRoot;
try {
DN configEntryDN = DN.valueOf(ConfigConstants.DN_BACKEND_BASE);
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/ExportLDIF.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/ExportLDIF.java
index c9ee057..26824ae 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/ExportLDIF.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/ExportLDIF.java
@@ -19,7 +19,6 @@
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.config.ConfigConstants.*;
import static org.opends.server.util.StaticUtils.*;
-
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static com.forgerock.opendj.cli.Utils.*;
import static com.forgerock.opendj.cli.CommonArguments.*;
@@ -37,10 +36,10 @@
import org.opends.server.api.Backend;
import org.opends.server.api.Backend.BackendOperation;
import org.opends.server.api.plugin.PluginType;
+import org.opends.server.core.ConfigurationHandler;
import org.opends.server.core.CoreConfigManager;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.LockFileManager;
-import org.opends.server.extensions.ConfigFileHandler;
import org.opends.server.loggers.DebugLogger;
import org.opends.server.loggers.ErrorLogPublisher;
import org.opends.server.loggers.ErrorLogger;
@@ -170,7 +169,7 @@
.description(INFO_DESCRIPTION_CONFIG_CLASS.get())
.hidden()
.required()
- .defaultValue(ConfigFileHandler.class.getName())
+ .defaultValue(ConfigurationHandler.class.getName())
.valuePlaceholder(INFO_CONFIGCLASS_PLACEHOLDER.get())
.buildAndAddToParser(argParser);
configFile =
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/ImportLDIF.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/ImportLDIF.java
index 9ee6fd9..0ebdb60 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/ImportLDIF.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/ImportLDIF.java
@@ -20,7 +20,6 @@
import static org.opends.server.config.ConfigConstants.*;
import static org.opends.server.util.StaticUtils.*;
import static com.forgerock.opendj.cli.CommonArguments.*;
-
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static com.forgerock.opendj.cli.Utils.*;
@@ -41,11 +40,11 @@
import org.opends.server.api.Backend;
import org.opends.server.api.Backend.BackendOperation;
import org.opends.server.api.plugin.PluginType;
+import org.opends.server.core.ConfigurationHandler;
import org.opends.server.core.CoreConfigManager;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.LockFileManager;
import org.opends.server.core.PluginConfigManager;
-import org.opends.server.extensions.ConfigFileHandler;
import org.opends.server.loggers.ErrorLogPublisher;
import org.opends.server.loggers.ErrorLogger;
import org.opends.server.loggers.JDKLogging;
@@ -282,7 +281,7 @@
.description(INFO_DESCRIPTION_CONFIG_CLASS.get())
.hidden()
.required()
- .defaultValue(ConfigFileHandler.class.getName())
+ .defaultValue(ConfigurationHandler.class.getName())
.valuePlaceholder(INFO_CONFIGCLASS_PLACEHOLDER.get())
.buildAndAddToParser(argParser);
configFile =
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/LDIFDiff.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/LDIFDiff.java
index 002cc14..1683012 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/LDIFDiff.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/LDIFDiff.java
@@ -36,9 +36,9 @@
import org.forgerock.opendj.ldap.DN;
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.schema.AttributeType;
+import org.opends.server.core.ConfigurationHandler;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.DirectoryServer.DirectoryServerVersionHandler;
-import org.opends.server.extensions.ConfigFileHandler;
import org.opends.server.loggers.JDKLogging;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeBuilder;
@@ -222,7 +222,7 @@
.shortIdentifier(OPTION_SHORT_CONFIG_CLASS)
.description(INFO_DESCRIPTION_CONFIG_CLASS.get())
.hidden()
- .defaultValue(ConfigFileHandler.class.getName())
+ .defaultValue(ConfigurationHandler.class.getName())
.valuePlaceholder(INFO_CONFIGCLASS_PLACEHOLDER.get())
.buildAndAddToParser(argParser);
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/LDIFModify.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/LDIFModify.java
index 709cc9c..f375027 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/LDIFModify.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/LDIFModify.java
@@ -19,7 +19,6 @@
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.protocols.ldap.LDAPResultCode.*;
import static org.opends.server.util.StaticUtils.*;
-
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static com.forgerock.opendj.cli.Utils.*;
import static com.forgerock.opendj.cli.CommonArguments.*;
@@ -37,9 +36,9 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.ByteString;
+import org.opends.server.core.ConfigurationHandler;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.DirectoryServer.DirectoryServerVersionHandler;
-import org.opends.server.extensions.ConfigFileHandler;
import org.opends.server.loggers.JDKLogging;
import org.opends.server.types.Attribute;
import org.forgerock.opendj.ldap.schema.AttributeType;
@@ -438,7 +437,7 @@
.shortIdentifier(OPTION_SHORT_CONFIG_CLASS)
.description(INFO_DESCRIPTION_CONFIG_CLASS.get())
.hidden()
- .defaultValue(ConfigFileHandler.class.getName())
+ .defaultValue(ConfigurationHandler.class.getName())
.valuePlaceholder(INFO_CONFIGCLASS_PLACEHOLDER.get())
.buildAndAddToParser(argParser);
sourceFile =
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/LDIFSearch.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/LDIFSearch.java
index c7c56ea..4f80f6b 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/LDIFSearch.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/LDIFSearch.java
@@ -37,9 +37,9 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.DN;
import org.forgerock.opendj.ldap.SearchScope;
+import org.opends.server.core.ConfigurationHandler;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.DirectoryServer.DirectoryServerVersionHandler;
-import org.opends.server.extensions.ConfigFileHandler;
import org.opends.server.loggers.JDKLogging;
import org.opends.server.protocols.ldap.LDAPResultCode;
import org.forgerock.opendj.ldap.schema.AttributeType;
@@ -178,7 +178,7 @@
.shortIdentifier(OPTION_SHORT_CONFIG_CLASS)
.description(INFO_DESCRIPTION_CONFIG_CLASS.get())
.hidden()
- .defaultValue(ConfigFileHandler.class.getName())
+ .defaultValue(ConfigurationHandler.class.getName())
.valuePlaceholder(INFO_CONFIGCLASS_PLACEHOLDER.get())
.buildAndAddToParser(argParser);
filterFile =
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/ListBackends.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/ListBackends.java
index 8173903..00f6015 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/ListBackends.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/ListBackends.java
@@ -16,6 +16,7 @@
*/
package org.opends.server.tools;
+import static org.opends.server.config.ConfigConstants.ATTR_BACKEND_BASE_DN;
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static com.forgerock.opendj.cli.Utils.*;
import static com.forgerock.opendj.cli.CommonArguments.*;
@@ -27,6 +28,7 @@
import java.io.OutputStream;
import java.io.PrintStream;
+import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@@ -34,15 +36,18 @@
import java.util.TreeSet;
import org.forgerock.i18n.LocalizableMessage;
+import org.forgerock.opendj.adapter.server3x.Converters;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.DN;
+import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.Entry;
import org.opends.server.config.DNConfigAttribute;
import org.opends.server.config.StringConfigAttribute;
+import org.opends.server.core.ConfigurationHandler;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.DirectoryServer.DirectoryServerVersionHandler;
-import org.opends.server.extensions.ConfigFileHandler;
import org.opends.server.loggers.JDKLogging;
+import org.opends.server.types.Attribute;
import org.opends.server.types.InitializationException;
import org.opends.server.types.NullOutputStream;
import org.opends.server.util.BuildVersion;
@@ -142,7 +147,7 @@
.description(INFO_DESCRIPTION_CONFIG_CLASS.get())
.hidden()
.required()
- .defaultValue(ConfigFileHandler.class.getName())
+ .defaultValue(ConfigurationHandler.class.getName())
.valuePlaceholder(INFO_CONFIGCLASS_PLACEHOLDER.get())
.buildAndAddToParser(argParser);
configFile =
@@ -467,53 +472,22 @@
throw new ConfigException(message, e);
}
- Entry baseEntry = null;
- try
- {
- baseEntry = DirectoryServer.getConfigEntry(backendBaseDN);
- }
- catch (ConfigException ce)
- {
- LocalizableMessage message = ERR_CANNOT_RETRIEVE_BACKEND_BASE_ENTRY.get(
- DN_BACKEND_BASE, ce.getMessage());
- throw new ConfigException(message, ce);
- }
- catch (Exception e)
- {
- LocalizableMessage message = ERR_CANNOT_RETRIEVE_BACKEND_BASE_ENTRY.get(
- DN_BACKEND_BASE, getExceptionMessage(e));
- throw new ConfigException(message, e);
- }
-
-
// Iterate through the immediate children, attempting to parse them as backends.
TreeMap<String,TreeSet<DN>> backendMap = new TreeMap<>();
- for (Entry configEntry : baseEntry.getChildren().values())
+ ConfigurationHandler configHandler = DirectoryServer.getConfigurationHandler();
+ for (DN childrenDn : configHandler.getChildren(backendBaseDN))
{
+ Entry configEntry = Converters.to(configHandler.getEntry(childrenDn));
// Get the backend ID attribute from the entry. If there isn't one, then
// skip the entry.
String backendID = null;
try
{
- LocalizableMessage msg = INFO_CONFIG_BACKEND_ATTR_DESCRIPTION_BACKEND_ID.get();
- StringConfigAttribute idStub =
- new StringConfigAttribute(ATTR_BACKEND_ID, msg,
- true, false, true);
- StringConfigAttribute idAttr =
- (StringConfigAttribute) configEntry.getConfigAttribute(idStub);
- if (idAttr == null)
+ backendID = BackendToolUtils.getStringSingleValuedAttribute(configEntry, ATTR_BACKEND_ID);
+ if (backendID == null)
{
continue;
}
- else
- {
- backendID = idAttr.activeValue();
- }
- }
- catch (ConfigException ce)
- {
- LocalizableMessage message = ERR_CANNOT_DETERMINE_BACKEND_ID.get(configEntry.getName(), ce.getMessage());
- throw new ConfigException(message, ce);
}
catch (Exception e)
{
@@ -527,15 +501,14 @@
TreeSet<DN> baseDNs = new TreeSet<>();
try
{
- LocalizableMessage msg = INFO_CONFIG_BACKEND_ATTR_DESCRIPTION_BASE_DNS.get();
- DNConfigAttribute baseDNStub =
- new DNConfigAttribute(ATTR_BACKEND_BASE_DN, msg,
- true, true, true);
- DNConfigAttribute baseDNAttr =
- (DNConfigAttribute) configEntry.getConfigAttribute(baseDNStub);
- if (baseDNAttr != null)
+ List<Attribute> attributes = configEntry.getAttribute(ATTR_BACKEND_BASE_DN);
+ if (!attributes.isEmpty())
{
- baseDNs.addAll(baseDNAttr.activeValues());
+ Attribute attribute = attributes.get(0);
+ for (ByteString byteString : attribute)
+ {
+ baseDNs.add(DN.valueOf(byteString.toString()));
+ }
}
}
catch (Exception e)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/RebuildIndex.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/RebuildIndex.java
index a2a951a..2867f1d 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/RebuildIndex.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/RebuildIndex.java
@@ -19,7 +19,6 @@
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.config.ConfigConstants.*;
import static org.opends.server.util.StaticUtils.*;
-
import static com.forgerock.opendj.cli.Utils.*;
import static com.forgerock.opendj.cli.CommonArguments.*;
@@ -38,10 +37,10 @@
import org.opends.server.api.Backend.BackendOperation;
import org.opends.server.backends.RebuildConfig;
import org.opends.server.backends.RebuildConfig.RebuildMode;
+import org.opends.server.core.ConfigurationHandler;
import org.opends.server.core.CoreConfigManager;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.LockFileManager;
-import org.opends.server.extensions.ConfigFileHandler;
import org.opends.server.loggers.DebugLogger;
import org.opends.server.loggers.ErrorLogPublisher;
import org.opends.server.loggers.ErrorLogger;
@@ -237,7 +236,7 @@
.description(INFO_DESCRIPTION_CONFIG_CLASS.get())
.hidden()
.required()
- .defaultValue(ConfigFileHandler.class.getName())
+ .defaultValue(ConfigurationHandler.class.getName())
.valuePlaceholder(INFO_CONFIGCLASS_PLACEHOLDER.get())
.buildAndAddToParser(argParser);
configFile =
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/RestoreDB.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/RestoreDB.java
index 594acd5..8acb924 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/RestoreDB.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/RestoreDB.java
@@ -19,7 +19,6 @@
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.config.ConfigConstants.*;
import static org.opends.server.util.StaticUtils.*;
-
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static com.forgerock.opendj.cli.Utils.*;
import static com.forgerock.opendj.cli.CommonArguments.*;
@@ -39,10 +38,10 @@
import org.forgerock.opendj.server.config.server.BackendCfg;
import org.opends.server.api.Backend;
import org.opends.server.api.Backend.BackendOperation;
+import org.opends.server.core.ConfigurationHandler;
import org.opends.server.core.CoreConfigManager;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.LockFileManager;
-import org.opends.server.extensions.ConfigFileHandler;
import org.opends.server.loggers.DebugLogger;
import org.opends.server.loggers.ErrorLogPublisher;
import org.opends.server.loggers.ErrorLogger;
@@ -163,7 +162,7 @@
.description(INFO_DESCRIPTION_CONFIG_CLASS.get())
.hidden()
.required()
- .defaultValue(ConfigFileHandler.class.getName())
+ .defaultValue(ConfigurationHandler.class.getName())
.valuePlaceholder(INFO_CONFIGCLASS_PLACEHOLDER.get())
.buildAndAddToParser(argParser);
configFile =
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/VerifyIndex.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/VerifyIndex.java
index 713e71a..e34dac6 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/VerifyIndex.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/VerifyIndex.java
@@ -35,11 +35,11 @@
import org.opends.server.api.Backend;
import org.opends.server.api.Backend.BackendOperation;
import org.opends.server.backends.VerifyConfig;
+import org.opends.server.core.ConfigurationHandler;
import org.opends.server.core.CoreConfigManager;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.DirectoryServer.DirectoryServerVersionHandler;
import org.opends.server.core.LockFileManager;
-import org.opends.server.extensions.ConfigFileHandler;
import org.opends.server.loggers.JDKLogging;
import org.opends.server.types.InitializationException;
import org.opends.server.types.NullOutputStream;
@@ -121,7 +121,7 @@
.description(INFO_DESCRIPTION_CONFIG_CLASS.get())
.hidden()
.required()
- .defaultValue(ConfigFileHandler.class.getName())
+ .defaultValue(ConfigurationHandler.class.getName())
.valuePlaceholder(INFO_CONFIGCLASS_PLACEHOLDER.get())
.buildAndAddToParser(argParser);
configFile =
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/dsreplication/ReplicationCliArgumentParser.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/dsreplication/ReplicationCliArgumentParser.java
index 0521d1a..5b1eb83 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/dsreplication/ReplicationCliArgumentParser.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/dsreplication/ReplicationCliArgumentParser.java
@@ -38,8 +38,8 @@
import org.opends.server.admin.client.cli.SecureConnectionCliArgs;
import org.opends.server.admin.client.cli.SecureConnectionCliParser;
import org.opends.server.admin.client.cli.TaskScheduleArgs;
+import org.opends.server.core.ConfigurationHandler;
import org.opends.server.core.DirectoryServer.DirectoryServerVersionHandler;
-import org.opends.server.extensions.ConfigFileHandler;
import org.opends.server.tasks.PurgeConflictsHistoricalTask;
import com.forgerock.opendj.cli.Argument;
@@ -448,7 +448,7 @@
defaultArgs.add(index++, advancedArg);
configClassArg =
- configClassArgument(ConfigFileHandler.class.getName());
+ configClassArgument(ConfigurationHandler.class.getName());
defaultArgs.add(index++, configClassArg);
configFileArg = configFileArgument();
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/UpgradeCli.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/UpgradeCli.java
index cf67fb9..aec1db5 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/UpgradeCli.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/upgrade/UpgradeCli.java
@@ -19,7 +19,6 @@
import static com.forgerock.opendj.cli.Utils.*;
import static com.forgerock.opendj.cli.CommonArguments.*;
import static javax.security.auth.callback.TextOutputCallback.*;
-
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.tools.upgrade.FormattedNotificationCallback.*;
import static org.opends.server.tools.upgrade.Upgrade.*;
@@ -40,8 +39,8 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.messages.RuntimeMessages;
+import org.opends.server.core.ConfigurationHandler;
import org.opends.server.core.DirectoryServer.DirectoryServerVersionHandler;
-import org.opends.server.extensions.ConfigFileHandler;
import org.opends.server.loggers.JDKLogging;
import org.opends.server.util.StaticUtils;
@@ -216,7 +215,7 @@
{
if (!globalArgumentsInitialized)
{
- configClass = configClassArgument(ConfigFileHandler.class.getName());
+ configClass = configClassArgument(ConfigurationHandler.class.getName());
configFile = configFileArgument();
noPrompt = noPromptArgument();
verbose = verboseArgument();
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/types/DirectoryConfig.java b/opendj-server-legacy/src/main/java/org/opends/server/types/DirectoryConfig.java
index dbef5ba..cb32ede 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/types/DirectoryConfig.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/types/DirectoryConfig.java
@@ -29,7 +29,6 @@
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.api.AlertGenerator;
-import org.opends.server.api.ConfigHandler;
import org.opends.server.api.ExtendedOperationHandler;
import org.opends.server.api.SASLMechanismHandler;
import org.opends.server.api.ServerShutdownListener;
@@ -78,22 +77,6 @@
return DirectoryServer.getOperatingSystem();
}
-
-
- /**
- * Retrieves a reference to the Directory Server configuration
- * handler.
- *
- * @return A reference to the Directory Server configuration
- * handler.
- */
- public static ConfigHandler getConfigHandler()
- {
- return DirectoryServer.getConfigHandler();
- }
-
-
-
/**
* Retrieves the requested entry from the Directory Server
* configuration.
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/types/DirectoryEnvironmentConfig.java b/opendj-server-legacy/src/main/java/org/opends/server/types/DirectoryEnvironmentConfig.java
index cf5e258..a6aa609 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/types/DirectoryEnvironmentConfig.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/types/DirectoryEnvironmentConfig.java
@@ -12,7 +12,7 @@
* information: "Portions Copyright [year] [name of copyright owner]".
*
* Copyright 2008-2010 Sun Microsystems, Inc.
- * Portions Copyright 2013-2015 ForgeRock AS.
+ * Portions Copyright 2013-2016 ForgeRock AS.
*/
package org.opends.server.types;
@@ -30,9 +30,8 @@
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.quicksetup.util.Utils;
-import org.opends.server.api.ConfigHandler;
+import org.opends.server.core.ConfigurationHandler;
import org.opends.server.core.DirectoryServer;
-import org.opends.server.extensions.ConfigFileHandler;
/**
* This class provides a set of properties that may control various
@@ -518,7 +517,7 @@
String className = getProperty(PROPERTY_CONFIG_CLASS);
if (className == null)
{
- return ConfigFileHandler.class;
+ return ConfigurationHandler.class;
}
else
{
@@ -528,7 +527,7 @@
}
catch (Exception e)
{
- return ConfigFileHandler.class;
+ return ConfigurationHandler.class;
}
}
}
@@ -557,15 +556,14 @@
{
checkServerIsRunning();
- if (!ConfigHandler.class.isAssignableFrom(configClass))
+ if (!ConfigurationHandler.class.isAssignableFrom(configClass))
{
throw new InitializationException(
ERR_DIRCFG_INVALID_CONFIG_CLASS.get(
configClass.getName()));
}
- String oldClassName = setProperty(PROPERTY_CONFIG_CLASS,
- configClass.getName());
+ String oldClassName = setProperty(PROPERTY_CONFIG_CLASS, configClass.getName());
if (oldClassName == null)
{
return null;
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendCompareOperation.java b/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendCompareOperation.java
index 8b87d98..b64ac7e 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendCompareOperation.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendCompareOperation.java
@@ -33,6 +33,7 @@
import org.opends.server.core.AccessControlConfigManager;
import org.opends.server.core.CompareOperation;
import org.opends.server.core.CompareOperationWrapper;
+import org.opends.server.core.ConfigurationBackend;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.Attribute;
import org.opends.server.types.CanceledOperationException;
@@ -152,7 +153,7 @@
// If the target entry is in the server configuration, then make sure the
// requester has the CONFIG_READ privilege.
- if (DirectoryServer.getConfigHandler().handlesEntry(entryDN)
+ if (DirectoryServer.getBackend(ConfigurationBackend.CONFIG_BACKEND_ID).handlesEntry(entryDN)
&& !clientConnection.hasPrivilege(Privilege.CONFIG_READ, this))
{
appendErrorMessage(ERR_COMPARE_CONFIG_INSUFFICIENT_PRIVILEGES.get());
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/ServerContextBuilder.java b/opendj-server-legacy/src/test/java/org/opends/server/ServerContextBuilder.java
index 4c1a536..b62d55f 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/ServerContextBuilder.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/ServerContextBuilder.java
@@ -21,6 +21,7 @@
import org.forgerock.opendj.config.server.ServerManagementContext;
import org.opends.server.core.ConfigurationBootstrapper;
+import org.opends.server.core.ConfigurationHandler;
import org.opends.server.core.ServerContext;
import org.opends.server.types.DirectoryEnvironmentConfig;
import org.opends.server.types.InitializationException;
@@ -80,7 +81,8 @@
public ServerContextBuilder withConfigurationBootstrapped()
throws InitializationException
{
- final ServerManagementContext serverManagementContext = ConfigurationBootstrapper.bootstrap(serverContext);
+ final ServerManagementContext serverManagementContext =
+ ConfigurationBootstrapper.bootstrap(serverContext, ConfigurationHandler.class);
when(serverContext.getServerManagementContext()).thenReturn(serverManagementContext);
return this;
}
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/TestCaseUtils.java b/opendj-server-legacy/src/test/java/org/opends/server/TestCaseUtils.java
index 8f66b3d..88b2189 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/TestCaseUtils.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/TestCaseUtils.java
@@ -39,11 +39,6 @@
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.DN;
import org.forgerock.opendj.ldap.ResultCode;
-import org.forgerock.opendj.config.client.ManagementContext;
-import org.opends.server.admin.client.ldap.JNDIDirContextAdaptor;
-import org.forgerock.opendj.config.client.ldap.LDAPConnection;
-import org.forgerock.opendj.config.client.ldap.LDAPManagementContext;
-import org.forgerock.opendj.server.config.client.RootCfgClient;
import org.opends.server.api.Backend;
import org.opends.server.api.WorkQueue;
import org.opends.server.api.plugin.PluginType;
@@ -52,9 +47,9 @@
import org.opends.server.backends.pluggable.EntryContainer;
import org.opends.server.backends.pluggable.RootContainer;
import org.opends.server.core.AddOperation;
+import org.opends.server.core.ConfigurationHandler;
import org.opends.server.core.DeleteOperation;
import org.opends.server.core.DirectoryServer;
-import org.opends.server.extensions.ConfigFileHandler;
import org.opends.server.loggers.*;
import org.opends.server.plugins.InvocationCounterPlugin;
import org.opends.server.protocols.ldap.BindRequestProtocolOp;
@@ -422,7 +417,7 @@
config.setInstanceRoot(testInstanceRoot);
config.setForceDaemonThreads(true);
- config.setConfigClass(ConfigFileHandler.class);
+ config.setConfigClass(ConfigurationHandler.class);
config.setConfigFile(new File(testConfigDir, "config.ldif"));
// Initialize the configuration framework for DSConfig.
@@ -1680,34 +1675,6 @@
}
/**
- * Gets the root configuration associated with the active server
- * instance. This root configuration can then be used to access and
- * modify the server's configuration using that administration
- * framework's strongly typed API.
- * <p>
- * Note: were possible the {@link #dsconfig(String...)} method
- * should be used in preference to this method in order to perform
- * end-to-end testing.
- *
- * @return Returns the root configuration associated with the active
- * server instance.
- * @throws Exception
- * If the management context could not be initialized
- * against the active server instance.
- */
- public static RootCfgClient getRootConfiguration() throws Exception
- {
- LDAPConnection connection = JNDIDirContextAdaptor.simpleSSLBind(
- "127.0.0.1",
- serverAdminPort,
- "cn=Directory Manager",
- "password");
-
- ManagementContext context = LDAPManagementContext.createFromContext(connection);
- return context.getRootConfiguration();
- }
-
- /**
* Return a String representation of all of the current threads.
* @return a dump of all Threads on the server
*/
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/admin/server/AggregationServerTest.java b/opendj-server-legacy/src/test/java/org/opends/server/admin/server/AggregationServerTest.java
deleted file mode 100644
index 7275639..0000000
--- a/opendj-server-legacy/src/test/java/org/opends/server/admin/server/AggregationServerTest.java
+++ /dev/null
@@ -1,962 +0,0 @@
-/*
- * The contents of this file are subject to the terms of the Common Development and
- * Distribution License (the License). You may not use this file except in compliance with the
- * License.
- *
- * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
- * specific language governing permission and limitations under the License.
- *
- * When distributing Covered Software, include this CDDL Header Notice in each file and include
- * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
- * Header, with the fields enclosed by brackets [] replaced by your own identifying
- * information: "Portions Copyright [year] [name of copyright owner]".
- *
- * Copyright 2007-2008 Sun Microsystems, Inc.
- * Portions Copyright 2013-2016 ForgeRock AS.
- */
-package org.opends.server.admin.server;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.SortedSet;
-import java.util.TreeSet;
-
-import javax.naming.ldap.LdapName;
-
-import org.forgerock.i18n.LocalizableMessage;
-import org.opends.server.TestCaseUtils;
-import org.opends.server.admin.*;
-import org.opends.server.admin.client.OperationRejectedException;
-import org.opends.server.admin.client.ldap.JNDIDirContextAdaptor;
-import org.opends.server.admin.condition.Conditions;
-import org.opends.server.admin.std.client.ConnectionHandlerCfgClient;
-import org.opends.server.admin.std.client.LDAPConnectionHandlerCfgClient;
-import org.opends.server.admin.std.client.RootCfgClient;
-import org.opends.server.admin.std.meta.LDAPConnectionHandlerCfgDefn;
-import org.opends.server.admin.std.server.ConnectionHandlerCfg;
-import org.opends.server.admin.std.server.RootCfg;
-import org.forgerock.opendj.config.server.ConfigException;
-import org.opends.server.core.DirectoryServer;
-import org.forgerock.opendj.config.server.ConfigChangeResult;
-import org.testng.Assert;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-/**
- * Test cases for aggregations on the server-side.
- */
-@Test(sequential = true)
-public final class AggregationServerTest extends AdminTestCase {
-
- /**
- * Dummy change listener for triggering change constraint
- * call-backs.
- */
- private static final class DummyChangeListener implements
- ConfigurationChangeListener<TestChildCfg> {
-
- /** {@inheritDoc} */
- @Override
- public ConfigChangeResult applyConfigurationChange(
- TestChildCfg configuration) {
- return new ConfigChangeResult();
- }
-
-
-
- /** {@inheritDoc} */
- @Override
- public boolean isConfigurationChangeAcceptable(TestChildCfg configuration,
- List<LocalizableMessage> unacceptableReasons) {
- return true;
- }
- }
-
-
-
- /**
- * Dummy delete listener for triggering delete constraint
- * call-backs.
- */
- private static final class DummyDeleteListener implements
- ConfigurationDeleteListener<TestChildCfg> {
-
- /** {@inheritDoc} */
- @Override
- public ConfigChangeResult applyConfigurationDelete(
- TestChildCfg configuration) {
- return new ConfigChangeResult();
- }
-
-
-
- /** {@inheritDoc} */
- @Override
- public boolean isConfigurationDeleteAcceptable(TestChildCfg configuration,
- List<LocalizableMessage> unacceptableReasons) {
- return true;
- }
- }
-
- private static final String TEST_CHILD_7_DN = "cn=test child 7,cn=test children,cn=test parent 1,cn=test parents,cn=config";
-
- private static final String TEST_CHILD_6_DN = "cn=test child 6,cn=test children,cn=test parent 1,cn=test parents,cn=config";
-
- /** The name of the test connection handler. */
- private static final String TEST_CONNECTION_HANDLER_NAME = "Test Connection Handler";
-
- /** Test child 1 LDIF. */
- private static final String[] TEST_CHILD_1 = new String[] {
- "dn: cn=test child 1,cn=test children,cn=test parent 1,cn=test parents,cn=config",
- "objectclass: top",
- "objectclass: ds-cfg-test-child-dummy",
- "cn: test child 1",
- "ds-cfg-enabled: true",
- "ds-cfg-java-class: org.opends.server.extensions.UserDefinedVirtualAttributeProvider",
- "ds-cfg-attribute-type: description",
- "ds-cfg-conflict-behavior: virtual-overrides-real"
- };
-
- /** Test child 2 LDIF. */
- private static final String[] TEST_CHILD_2 = new String[] {
- "dn: cn=test child 2,cn=test children,cn=test parent 1,cn=test parents,cn=config",
- "objectclass: top",
- "objectclass: ds-cfg-test-child-dummy",
- "cn: test child 2",
- "ds-cfg-enabled: true",
- "ds-cfg-java-class: org.opends.server.extensions.UserDefinedVirtualAttributeProvider",
- "ds-cfg-attribute-type: description",
- "ds-cfg-conflict-behavior: virtual-overrides-real",
- "ds-cfg-rotation-policy: cn=LDAP Connection Handler, cn=connection handlers, cn=config"
- };
-
- /** Test child 3 LDIF (invalid reference). */
- private static final String[] TEST_CHILD_3 = new String[] {
- "dn: cn=test child 3,cn=test children,cn=test parent 1,cn=test parents,cn=config",
- "objectclass: top",
- "objectclass: ds-cfg-test-child-dummy",
- "cn: test child 3",
- "ds-cfg-enabled: true",
- "ds-cfg-java-class: org.opends.server.extensions.UserDefinedVirtualAttributeProvider",
- "ds-cfg-attribute-type: description",
- "ds-cfg-conflict-behavior: virtual-overrides-real",
- "ds-cfg-rotation-policy: cn=LDAP Connection Handler, cn=bad rdn, cn=config"
- };
-
- /** Test child 4 LDIF. */
- private static final String[] TEST_CHILD_4 = new String[] {
- "dn: cn=test child 4,cn=test children,cn=test parent 1,cn=test parents,cn=config",
- "objectclass: top",
- "objectclass: ds-cfg-test-child-dummy",
- "cn: test child 4",
- "ds-cfg-enabled: true",
- "ds-cfg-java-class: org.opends.server.extensions.UserDefinedVirtualAttributeProvider",
- "ds-cfg-attribute-type: description",
- "ds-cfg-conflict-behavior: virtual-overrides-real",
- "ds-cfg-rotation-policy: cn=LDAP Connection Handler, cn=connection handlers, cn=config",
- "ds-cfg-rotation-policy: cn=LDAPS Connection Handler, cn=connection handlers, cn=config"
- };
-
- /** Test child 5 LDIF. */
- private static final String[] TEST_CHILD_5 = new String[] {
- "dn: cn=test child 5,cn=test children,cn=test parent 1,cn=test parents,cn=config",
- "objectclass: top",
- "objectclass: ds-cfg-test-child-dummy",
- "cn: test child 5",
- "ds-cfg-enabled: true",
- "ds-cfg-java-class: org.opends.server.extensions.UserDefinedVirtualAttributeProvider",
- "ds-cfg-attribute-type: description",
- "ds-cfg-conflict-behavior: virtual-overrides-real",
- "ds-cfg-rotation-policy: cn=BAD Connection Handler 1, cn=connection handlers, cn=config",
- "ds-cfg-rotation-policy: cn=BAD Connection Handler 2, cn=connection handlers, cn=config",
- "ds-cfg-rotation-policy: cn=LDAP Connection Handler, cn=connection handlers, cn=config"
- };
-
- /** Test child 6 LDIF. */
- private static final String[] TEST_CHILD_6 = new String[] {
- "dn: cn=test child 6,cn=test children,cn=test parent 1,cn=test parents,cn=config",
- "objectclass: top",
- "objectclass: ds-cfg-test-child-dummy",
- "cn: test child 6",
- "ds-cfg-enabled: true",
- "ds-cfg-java-class: org.opends.server.extensions.UserDefinedVirtualAttributeProvider",
- "ds-cfg-attribute-type: description",
- "ds-cfg-conflict-behavior: virtual-overrides-real",
- "ds-cfg-rotation-policy: cn=" + TEST_CONNECTION_HANDLER_NAME
- + ", cn=connection handlers, cn=config"
- };
-
- /** Test child 7 LDIF. */
- private static final String[] TEST_CHILD_7 = new String[] {
- "dn: cn=test child 7,cn=test children,cn=test parent 1,cn=test parents,cn=config",
- "objectclass: top",
- "objectclass: ds-cfg-test-child-dummy",
- "cn: test child 7",
- "ds-cfg-enabled: false",
- "ds-cfg-java-class: org.opends.server.extensions.UserDefinedVirtualAttributeProvider",
- "ds-cfg-attribute-type: description",
- "ds-cfg-conflict-behavior: virtual-overrides-real",
- "ds-cfg-rotation-policy: cn=" + TEST_CONNECTION_HANDLER_NAME
- + ", cn=connection handlers, cn=config"
- };
-
- /** Test LDIF. */
- private static final String[] TEST_LDIF = new String[] {
- // Base entries.
- "dn: cn=test parents,cn=config",
- "objectclass: top",
- "objectclass: ds-cfg-branch",
- "cn: test parents",
- "",
- // Parent 1.
- "dn: cn=test parent 1,cn=test parents,cn=config",
- "objectclass: top",
- "objectclass: ds-cfg-test-parent-dummy",
- "cn: test parent 1",
- "ds-cfg-enabled: true",
- "ds-cfg-java-class: org.opends.server.extensions.UserDefinedVirtualAttributeProvider",
- "ds-cfg-attribute-type: description",
- "ds-cfg-conflict-behavior: virtual-overrides-real",
- "",
- // Child base entries.
- "dn:cn=test children,cn=test parent 1,cn=test parents,cn=config",
- "objectclass: top",
- "objectclass: ds-cfg-branch",
- "cn: test children",
- ""
- };
-
- /** JNDI LDAP context. */
- private JNDIDirContextAdaptor adaptor;
-
- /**
- * The saved test child configuration "aggregation-property" property
- * definition.
- */
- private AggregationPropertyDefinition<ConnectionHandlerCfgClient, ConnectionHandlerCfg> aggregationPropertyDefinitionDefault;
-
- /**
- * An aggregation where the target must be enabled if the source is enabled.
- */
- private AggregationPropertyDefinition<ConnectionHandlerCfgClient, ConnectionHandlerCfg> aggregationPropertyDefinitionTargetAndSourceMustBeEnabled;
-
- /** An aggregation where the target must be enabled. */
- private AggregationPropertyDefinition<ConnectionHandlerCfgClient, ConnectionHandlerCfg> aggregationPropertyDefinitionTargetMustBeEnabled;
-
-
-
- /**
- * Sets up tests
- *
- * @throws Exception
- * If the server could not be initialized.
- */
- @BeforeClass
- public void setUp() throws Exception {
- // This test suite depends on having the schema available, so
- // we'll start the server.
- TestCaseUtils.startServer();
- TestCfg.setUp();
-
- // Add test managed objects.
- TestCaseUtils.addEntries(TEST_LDIF);
-
- // Save the aggregation property definition so that it can be
- // replaced and restored later.
- aggregationPropertyDefinitionDefault = TestChildCfgDefn.getInstance()
- .getAggregationPropertyPropertyDefinition();
-
- // Create the two test aggregation properties.
- AggregationPropertyDefinition.Builder<ConnectionHandlerCfgClient, ConnectionHandlerCfg> builder;
- TestChildCfgDefn d = TestChildCfgDefn.getInstance();
- builder = AggregationPropertyDefinition.createBuilder(d,
- "aggregation-property");
- builder.setOption(PropertyOption.MULTI_VALUED);
- builder.setAdministratorAction(new AdministratorAction(
- AdministratorAction.Type.NONE, d, "aggregation-property"));
- builder
- .setDefaultBehaviorProvider(new UndefinedDefaultBehaviorProvider<String>());
- builder.setParentPath("/");
- builder.setRelationDefinition("connection-handler");
- builder.setTargetIsEnabledCondition(Conditions.contains("enabled", "true"));
- aggregationPropertyDefinitionTargetMustBeEnabled = builder.getInstance();
- TestCfg
- .initializePropertyDefinition(aggregationPropertyDefinitionTargetMustBeEnabled);
-
- builder = AggregationPropertyDefinition.createBuilder(d,
- "aggregation-property");
- builder.setOption(PropertyOption.MULTI_VALUED);
- builder.setAdministratorAction(new AdministratorAction(
- AdministratorAction.Type.NONE, d, "aggregation-property"));
- builder
- .setDefaultBehaviorProvider(new UndefinedDefaultBehaviorProvider<String>());
- builder.setParentPath("/");
- builder.setRelationDefinition("connection-handler");
- builder.setTargetIsEnabledCondition(Conditions.contains("enabled", "true"));
- builder.setTargetNeedsEnablingCondition(Conditions.contains(
- "mandatory-boolean-property", "true"));
- aggregationPropertyDefinitionTargetAndSourceMustBeEnabled = builder
- .getInstance();
- TestCfg
- .initializePropertyDefinition(aggregationPropertyDefinitionTargetAndSourceMustBeEnabled);
- }
-
-
-
- /**
- * Tears down test environment.
- *
- * @throws Exception
- * If the test entries could not be removed.
- */
- @AfterClass
- public void tearDown() throws Exception {
- TestCfg.cleanup();
-
- // Restore the test child aggregation definition.
- TestCfg.addPropertyDefinition(aggregationPropertyDefinitionDefault);
-
- // Remove test entries.
- deleteSubtree("cn=test parents,cn=config");
- }
-
-
-
- /**
- * Tests that aggregation is rejected when the LDAP DN contains a
- * valid RDN but an invalid parent DN.
- *
- * @throws Exception
- * If the test unexpectedly fails.
- */
- @Test
- public void testAggregationBadBaseDN() throws Exception {
- // Add the entry.
- TestCaseUtils.addEntry(TEST_CHILD_3);
-
- try {
- TestParentCfg parent = getParent("test parent 1");
- parent.getTestChild("test child 3");
- Assert
- .fail("Unexpectedly added test child 3 when it had a bad aggregation value");
- } catch (ConfigException e) {
- // Check that we have a decoding exception as the cause and
- // there was only one cause the illegal property value.
- Throwable cause = e.getCause();
- if (cause instanceof ServerManagedObjectDecodingException) {
- ServerManagedObjectDecodingException de = (ServerManagedObjectDecodingException) cause;
-
- Collection<PropertyException> causes = de.getCauses();
- Assert.assertEquals(causes.size(), 1);
-
- cause = causes.iterator().next();
- if (cause instanceof PropertyException) {
- PropertyException pe = (PropertyException) cause;
- Assert.assertEquals(pe.getPropertyDefinition(), TestChildCfgDefn
- .getInstance().getAggregationPropertyPropertyDefinition());
- } else {
- // Got an unexpected cause.
- throw e;
- }
- } else {
- // Got an unexpected cause.
- throw e;
- }
- } finally {
- deleteSubtree("cn=test child 3,cn=test children,cn=test parent 1,cn=test parents,cn=config");
- }
- }
-
-
-
- /**
- * Tests that aggregation is rejected by a constraint violation when
- * the DN values are dangling.
- *
- * @throws Exception
- * If the test unexpectedly fails.
- */
- @Test
- public void testAggregationDanglingReference() throws Exception {
- // Add the entry.
- TestCaseUtils.addEntry(TEST_CHILD_5);
-
- try {
- TestParentCfg parent = getParent("test parent 1");
- parent.getTestChild("test child 5");
- Assert
- .fail("Unexpectedly added test child 5 when it had a dangling reference");
- } catch (ConfigException e) {
- // Check that we have a constraint violation as the cause.
- Throwable cause = e.getCause();
- if (cause instanceof ConstraintViolationException) {
- ConstraintViolationException cve = (ConstraintViolationException) cause;
- Collection<LocalizableMessage> causes = cve.getMessages();
- Assert.assertEquals(causes.size(), 2);
- } else {
- // Got an unexpected cause.
- throw e;
- }
- } finally {
- deleteSubtree("cn=test child 5,cn=test children,cn=test parent 1,cn=test parents,cn=config");
- }
- }
-
-
-
- /**
- * Tests that aggregation is rejected by a constraint violation when
- * an enabled component references a disabled component and the
- * referenced component must always be enabled.
- *
- * @throws Exception
- * If the test unexpectedly fails.
- */
- @Test
- public void testAggregationDisabledReference1() throws Exception {
- // Add the entry and the connection handler.
- TestCaseUtils.addEntry(TEST_CHILD_6);
- try {
- createConnectionHandler(false);
- } catch (Exception e) {
- deleteSubtree(TEST_CHILD_6_DN);
- throw e;
- }
-
- // Register the temporary aggregation definition.
- TestCfg.removeConstraint(aggregationPropertyDefinitionDefault
- .getSourceConstraint());
- TestCfg
- .addPropertyDefinition(aggregationPropertyDefinitionTargetMustBeEnabled);
- TestCfg.addConstraint(aggregationPropertyDefinitionTargetMustBeEnabled
- .getSourceConstraint());
-
- try {
- TestParentCfg parent = getParent("test parent 1");
- parent.getTestChild("test child 6");
- Assert
- .fail("Unexpectedly added test child 6 when it had a disabled reference");
- } catch (ConfigException e) {
- // Check that we have a constraint violation as the cause.
- Throwable cause = e.getCause();
- if (cause instanceof ConstraintViolationException) {
- ConstraintViolationException cve = (ConstraintViolationException) cause;
- Collection<LocalizableMessage> causes = cve.getMessages();
- Assert.assertEquals(causes.size(), 1);
- } else {
- // Got an unexpected cause.
- throw e;
- }
- } finally {
- // Put back the default aggregation definition.
- TestCfg.removeConstraint(aggregationPropertyDefinitionTargetMustBeEnabled
- .getSourceConstraint());
- TestCfg.addPropertyDefinition(aggregationPropertyDefinitionDefault);
- TestCfg.addConstraint(aggregationPropertyDefinitionDefault
- .getSourceConstraint());
-
- try {
- deleteSubtree(TEST_CHILD_6_DN);
- } finally {
- deleteConnectionHandler();
- }
- }
- }
-
-
-
- /**
- * Tests that aggregation is rejected by a constraint violation when
- * a disabled component references a disabled component and the
- * referenced component must always be enabled.
- *
- * @throws Exception
- * If the test unexpectedly fails.
- */
- @Test
- public void testAggregationDisabledReference2() throws Exception {
- // Add the entry.
- TestCaseUtils.addEntry(TEST_CHILD_7);
- try {
- createConnectionHandler(false);
- } catch (Exception e) {
- deleteSubtree(TEST_CHILD_7_DN);
- throw e;
- }
-
- // Register the temporary aggregation definition.
- TestCfg.removeConstraint(aggregationPropertyDefinitionDefault
- .getSourceConstraint());
- TestCfg
- .addPropertyDefinition(aggregationPropertyDefinitionTargetMustBeEnabled);
- TestCfg.addConstraint(aggregationPropertyDefinitionTargetMustBeEnabled
- .getSourceConstraint());
-
- try {
- TestParentCfg parent = getParent("test parent 1");
- parent.getTestChild("test child 7");
- Assert
- .fail("Unexpectedly added test child 7 when it had a disabled reference");
- } catch (ConfigException e) {
- // Check that we have a constraint violation as the cause.
- Throwable cause = e.getCause();
- if (cause instanceof ConstraintViolationException) {
- ConstraintViolationException cve = (ConstraintViolationException) cause;
- Collection<LocalizableMessage> causes = cve.getMessages();
- Assert.assertEquals(causes.size(), 1);
- } else {
- // Got an unexpected cause.
- throw e;
- }
- } finally {
- // Put back the default aggregation definition.
- TestCfg.removeConstraint(aggregationPropertyDefinitionTargetMustBeEnabled
- .getSourceConstraint());
- TestCfg.addPropertyDefinition(aggregationPropertyDefinitionDefault);
- TestCfg.addConstraint(aggregationPropertyDefinitionDefault
- .getSourceConstraint());
-
- try {
- deleteSubtree(TEST_CHILD_7_DN);
- } finally {
- deleteConnectionHandler();
- }
- }
- }
-
-
-
- /**
- * Tests that aggregation is rejected by a constraint violation when
- * an enabled component references a disabled component and the
- * referenced component must always be enabled when the referencing
- * component is enabled.
- *
- * @throws Exception
- * If the test unexpectedly fails.
- */
- @Test
- public void testAggregationDisabledReference3() throws Exception {
- // Add the entry.
- TestCaseUtils.addEntry(TEST_CHILD_6);
- try {
- createConnectionHandler(false);
- } catch (Exception e) {
- deleteSubtree(TEST_CHILD_6_DN);
- throw e;
- }
-
- // Register the temporary aggregation definition.
- TestCfg.removeConstraint(aggregationPropertyDefinitionDefault
- .getSourceConstraint());
- TestCfg
- .addPropertyDefinition(aggregationPropertyDefinitionTargetAndSourceMustBeEnabled);
- TestCfg
- .addConstraint(aggregationPropertyDefinitionTargetAndSourceMustBeEnabled
- .getSourceConstraint());
-
- try {
- TestParentCfg parent = getParent("test parent 1");
- parent.getTestChild("test child 6");
- Assert
- .fail("Unexpectedly added test child 6 when it had a disabled reference");
- } catch (ConfigException e) {
- // Check that we have a constraint violation as the cause.
- Throwable cause = e.getCause();
- if (cause instanceof ConstraintViolationException) {
- ConstraintViolationException cve = (ConstraintViolationException) cause;
- Collection<LocalizableMessage> causes = cve.getMessages();
- Assert.assertEquals(causes.size(), 1);
- } else {
- // Got an unexpected cause.
- throw e;
- }
- } finally {
- // Put back the default aggregation definition.
- TestCfg
- .removeConstraint(aggregationPropertyDefinitionTargetAndSourceMustBeEnabled
- .getSourceConstraint());
- TestCfg.addPropertyDefinition(aggregationPropertyDefinitionDefault);
- TestCfg.addConstraint(aggregationPropertyDefinitionDefault
- .getSourceConstraint());
-
- try {
- deleteSubtree(TEST_CHILD_6_DN);
- } finally {
- deleteConnectionHandler();
- }
- }
- }
-
-
-
- /**
- * Tests that aggregation is allowed when a disabled component
- * references a disabled component and the referenced component must
- * always be enabled when the referencing component is enabled.
- *
- * @throws Exception
- * If the test unexpectedly fails.
- */
- @Test
- public void testAggregationDisabledReference4() throws Exception {
- // Add the entry.
- TestCaseUtils.addEntry(TEST_CHILD_7);
- try {
- createConnectionHandler(false);
- } catch (Exception e) {
- deleteSubtree(TEST_CHILD_7_DN);
- throw e;
- }
-
- // Register the temporary aggregation definition.
- TestCfg.removeConstraint(aggregationPropertyDefinitionDefault
- .getSourceConstraint());
- TestCfg
- .addPropertyDefinition(aggregationPropertyDefinitionTargetAndSourceMustBeEnabled);
- TestCfg
- .addConstraint(aggregationPropertyDefinitionTargetAndSourceMustBeEnabled
- .getSourceConstraint());
-
- try {
- TestParentCfg parent = getParent("test parent 1");
- parent.getTestChild("test child 7");
- } finally {
- // Put back the default aggregation definition.
- TestCfg
- .removeConstraint(aggregationPropertyDefinitionTargetAndSourceMustBeEnabled
- .getSourceConstraint());
- TestCfg.addPropertyDefinition(aggregationPropertyDefinitionDefault);
- TestCfg.addConstraint(aggregationPropertyDefinitionDefault
- .getSourceConstraint());
-
- try {
- deleteSubtree(TEST_CHILD_7_DN);
- } finally {
- deleteConnectionHandler();
- }
- }
- }
-
-
-
- /**
- * Tests that aggregation contains no values when it contains does
- * not contain any DN attribute values.
- *
- * @throws Exception
- * If the test unexpectedly fails.
- */
- @Test
- public void testAggregationEmpty() throws Exception {
- // Add the entry.
- TestCaseUtils.addEntry(TEST_CHILD_1);
-
- try {
- TestParentCfg parent = getParent("test parent 1");
- assertChild1(parent.getTestChild("test child 1"));
- } finally {
- deleteSubtree("cn=test child 1,cn=test children,cn=test parent 1,cn=test parents,cn=config");
- }
- }
-
-
-
- /**
- * Tests that aggregation contains multiple valid values when it
- * contains a multiple valid DN attribute values.
- *
- * @throws Exception
- * If the test unexpectedly fails.
- */
- @Test
- public void testAggregationMultipleValues() throws Exception {
- // Add the entry.
- TestCaseUtils.addEntry(TEST_CHILD_4);
-
- try {
- TestParentCfg parent = getParent("test parent 1");
- assertChild4(parent.getTestChild("test child 4"));
- } finally {
- deleteSubtree("cn=test child 4,cn=test children,cn=test parent 1,cn=test parents,cn=config");
- }
- }
-
-
-
- /**
- * Tests that aggregation contains single valid value when it
- * contains a single valid DN attribute values.
- *
- * @throws Exception
- * If the test unexpectedly fails.
- */
- @Test
- public void testAggregationSingle() throws Exception {
- // Add the entry.
- TestCaseUtils.addEntry(TEST_CHILD_2);
-
- try {
- TestParentCfg parent = getParent("test parent 1");
- assertChild2(parent.getTestChild("test child 2"));
- } finally {
- deleteSubtree("cn=test child 2,cn=test children,cn=test parent 1,cn=test parents,cn=config");
- }
- }
-
-
-
- /**
- * Tests that it is impossible to delete a referenced component when
- * the referenced component must always exist regardless of whether
- * the referencing component is enabled or not.
- *
- * @throws Exception
- * If the test unexpectedly fails.
- */
- @Test
- public void testCannotDeleteReferencedComponent() throws Exception {
- // Add the entry.
- TestCaseUtils.addEntry(TEST_CHILD_7);
- try {
- createConnectionHandler(true);
- } catch (Exception e) {
- deleteSubtree(TEST_CHILD_7_DN);
- throw e;
- }
-
- // Register the temporary aggregation definition.
- TestCfg.removeConstraint(aggregationPropertyDefinitionDefault
- .getSourceConstraint());
- TestCfg
- .addPropertyDefinition(aggregationPropertyDefinitionTargetMustBeEnabled);
- TestCfg.addConstraint(aggregationPropertyDefinitionTargetMustBeEnabled
- .getSourceConstraint());
-
- ConfigurationDeleteListener<TestChildCfg> dl = new DummyDeleteListener();
- ConfigurationChangeListener<TestChildCfg> cl = new DummyChangeListener();
- try {
- // Retrieve the parent and child managed objects and register
- // delete and change listeners respectively in order to trigger
- // the constraint call-backs.
- TestParentCfg parent = getParent("test parent 1");
- parent.addTestChildDeleteListener(dl);
-
- TestChildCfg child = parent.getTestChild("test child 7");
- child.addChangeListener(cl);
-
- // Now attempt to delete the referenced connection handler.
- // This should fail.
- try {
- deleteConnectionHandler();
- Assert.fail("Successfully deleted a referenced component");
- } catch (OperationRejectedException e) {
- // This is the expected exception - do nothing.
- }
- } finally {
- try {
- deleteSubtree(TEST_CHILD_7_DN);
- } finally {
- try {
- deleteConnectionHandler();
- } catch (ManagedObjectNotFoundException e) {
- // Ignore as it may have been deleted already.
- } finally {
- // Remove the temporary delete listener.
- TestParentCfg parent = getParent("test parent 1");
- parent.removeTestChildDeleteListener(dl);
-
- // Put back the default aggregation definition.
- TestCfg
- .removeConstraint(aggregationPropertyDefinitionTargetMustBeEnabled
- .getSourceConstraint());
- TestCfg.addPropertyDefinition(aggregationPropertyDefinitionDefault);
- TestCfg.addConstraint(aggregationPropertyDefinitionDefault
- .getSourceConstraint());
- }
- }
- }
- }
-
-
-
- /**
- * Tests that it is impossible to disable a referenced component
- * when the referenced component must always be enabled regardless
- * of whether the referencing component is enabled or not.
- *
- * @throws Exception
- * If the test unexpectedly fails.
- */
- @Test
- public void testCannotDisableReferencedComponent() throws Exception {
- // Add the entry.
- TestCaseUtils.addEntry(TEST_CHILD_7);
- try {
- createConnectionHandler(true);
- } catch (Exception e) {
- deleteSubtree(TEST_CHILD_7_DN);
- throw e;
- }
-
- // Register the temporary aggregation definition.
- TestCfg.removeConstraint(aggregationPropertyDefinitionDefault
- .getSourceConstraint());
- TestCfg
- .addPropertyDefinition(aggregationPropertyDefinitionTargetMustBeEnabled);
- TestCfg.addConstraint(aggregationPropertyDefinitionTargetMustBeEnabled
- .getSourceConstraint());
-
- ConfigurationDeleteListener<TestChildCfg> dl = new DummyDeleteListener();
- ConfigurationChangeListener<TestChildCfg> cl = new DummyChangeListener();
- try {
- // Retrieve the parent and child managed objects and register
- // delete and change listeners respectively in order to trigger
- // the constraint call-backs.
- TestParentCfg parent = getParent("test parent 1");
- parent.addTestChildDeleteListener(dl);
-
- TestChildCfg child = parent.getTestChild("test child 7");
- child.addChangeListener(cl);
-
- // Now attempt to disable the referenced connection handler.
- // This should fail.
- try {
- RootCfgClient root = TestCaseUtils.getRootConfiguration();
- ConnectionHandlerCfgClient client = root
- .getConnectionHandler(TEST_CONNECTION_HANDLER_NAME);
- client.setEnabled(false);
- client.commit();
- Assert.fail("Successfully disabled a referenced component");
- } catch (OperationRejectedException e) {
- // This is the expected exception - do nothing.
- }
- } finally {
- try {
- deleteSubtree(TEST_CHILD_7_DN);
- } finally {
- try {
- deleteConnectionHandler();
- } finally {
- // Remove the temporary delete listener.
- TestParentCfg parent = getParent("test parent 1");
- parent.removeTestChildDeleteListener(dl);
-
- // Put back the default aggregation definition.
- TestCfg
- .removeConstraint(aggregationPropertyDefinitionTargetMustBeEnabled
- .getSourceConstraint());
- TestCfg.addPropertyDefinition(aggregationPropertyDefinitionDefault);
- TestCfg.addConstraint(aggregationPropertyDefinitionDefault
- .getSourceConstraint());
- }
- }
- }
- }
-
-
-
- /** Assert that the values of child 1 are correct. */
- private void assertChild1(TestChildCfg child) {
- Assert.assertEquals(child.getMandatoryClassProperty(),
- "org.opends.server.extensions.UserDefinedVirtualAttributeProvider");
- Assert.assertEquals(child.getMandatoryReadOnlyAttributeTypeProperty(),
- DirectoryServer.getAttributeType("description"));
- assertSetEquals(child.getAggregationProperty(), new String[0]);
- }
-
-
-
- /** Assert that the values of child 2 are correct. */
- private void assertChild2(TestChildCfg child) {
- Assert.assertEquals(child.getMandatoryClassProperty(),
- "org.opends.server.extensions.UserDefinedVirtualAttributeProvider");
- Assert.assertEquals(child.getMandatoryReadOnlyAttributeTypeProperty(),
- DirectoryServer.getAttributeType("description"));
-
- // Test normalization.
- assertSetEquals(child.getAggregationProperty(), "LDAP Connection Handler");
- assertSetEquals(child.getAggregationProperty(),
- " LDAP Connection Handler ");
- assertSetEquals(child.getAggregationProperty(),
- " ldap connection HANDLER ");
- }
-
-
-
- /** Assert that the values of child 4 are correct. */
- private void assertChild4(TestChildCfg child) {
- Assert.assertEquals(child.getMandatoryClassProperty(),
- "org.opends.server.extensions.UserDefinedVirtualAttributeProvider");
- Assert.assertEquals(child.getMandatoryReadOnlyAttributeTypeProperty(),
- DirectoryServer.getAttributeType("description"));
- assertSetEquals(child.getAggregationProperty(), "LDAPS Connection Handler",
- "LDAP Connection Handler");
- }
-
-
-
- /** Asserts that the actual set of DNs contains the expected values. */
- private void assertSetEquals(SortedSet<String> actual, String... expected) {
- SortedSet<String> values = new TreeSet<>(TestChildCfgDefn
- .getInstance().getAggregationPropertyPropertyDefinition());
- if (expected != null) {
- Collections.addAll(values, expected);
- }
- Assert.assertEquals((Object) actual, (Object) values);
- }
-
-
-
- /** Creates a test connection handler for testing. */
- private void createConnectionHandler(boolean enabled) throws Exception {
- int freePort = TestCaseUtils.findFreePort();
-
- RootCfgClient root = TestCaseUtils.getRootConfiguration();
- LDAPConnectionHandlerCfgClient client = root.createConnectionHandler(
- LDAPConnectionHandlerCfgDefn.getInstance(),
- TEST_CONNECTION_HANDLER_NAME, null);
- client.setEnabled(enabled);
- client.setListenPort(freePort);
- client.commit();
- }
-
-
-
- /** Deletes the test connection handler after testing. */
- private void deleteConnectionHandler() throws Exception {
- RootCfgClient root = TestCaseUtils.getRootConfiguration();
- root.removeConnectionHandler(TEST_CONNECTION_HANDLER_NAME);
- }
-
-
-
- /** Deletes the named sub-tree. */
- private void deleteSubtree(String dn) throws Exception {
- getAdaptor().deleteSubtree(new LdapName(dn));
- }
-
-
-
- /** Gets the JNDI connection for the test server instance. */
- private synchronized JNDIDirContextAdaptor getAdaptor() throws Exception {
- if (adaptor == null) {
- adaptor = JNDIDirContextAdaptor.simpleSSLBind("127.0.0.1", TestCaseUtils
- .getServerAdminPort(), "cn=directory manager", "password");
- }
- return adaptor;
- }
-
-
-
- /** Gets the named parent configuration. */
- private TestParentCfg getParent(String name) throws IllegalArgumentException,
- ConfigException {
- ServerManagementContext ctx = ServerManagementContext.getInstance();
- ServerManagedObject<RootCfg> root = ctx.getRootConfigurationManagedObject();
- return root.getChild(TestCfg.getTestOneToManyParentRelationDefinition(),
- name).getConfiguration();
- }
-}
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/admin/server/ConstraintTest.java b/opendj-server-legacy/src/test/java/org/opends/server/admin/server/ConstraintTest.java
deleted file mode 100644
index 8784450..0000000
--- a/opendj-server-legacy/src/test/java/org/opends/server/admin/server/ConstraintTest.java
+++ /dev/null
@@ -1,521 +0,0 @@
-/*
- * The contents of this file are subject to the terms of the Common Development and
- * Distribution License (the License). You may not use this file except in compliance with the
- * License.
- *
- * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
- * specific language governing permission and limitations under the License.
- *
- * When distributing Covered Software, include this CDDL Header Notice in each file and include
- * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
- * Header, with the fields enclosed by brackets [] replaced by your own identifying
- * information: "Portions Copyright [year] [name of copyright owner]".
- *
- * Copyright 2008 Sun Microsystems, Inc.
- * Portions Copyright 2014-2015 ForgeRock AS.
- */
-package org.opends.server.admin.server;
-
-import java.util.List;
-
-import javax.naming.OperationNotSupportedException;
-import javax.naming.ldap.LdapName;
-
-import org.forgerock.i18n.LocalizableMessage;
-import org.forgerock.opendj.config.server.ConfigException;
-import org.forgerock.opendj.ldap.ResultCode;
-import org.opends.server.TestCaseUtils;
-import org.opends.server.admin.AdminTestCase;
-import org.opends.server.admin.TestCfg;
-import org.opends.server.admin.TestChildCfg;
-import org.opends.server.admin.TestChildCfgDefn;
-import org.opends.server.admin.TestParentCfg;
-import org.opends.server.admin.client.ldap.JNDIDirContextAdaptor;
-import org.opends.server.admin.std.server.RootCfg;
-import org.opends.server.core.AddOperation;
-import org.forgerock.opendj.config.server.ConfigChangeResult;
-import org.opends.server.types.Entry;
-import org.testng.Assert;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import static org.opends.server.protocols.internal.InternalClientConnection.*;
-import static org.testng.Assert.*;
-
-/**
- * Test cases for constraints on the server-side.
- */
-public final class ConstraintTest extends AdminTestCase {
-
- /** Child DN. */
- private static final String TEST_CHILD_1_DN = "cn=test child 1,cn=test children,cn=test parent 1,cn=test parents,cn=config";
-
-
-
- /**
- * A test child add listener.
- */
- private static class AddListener implements
- ConfigurationAddListener<TestChildCfg> {
-
- /** {@inheritDoc} */
- @Override
- public ConfigChangeResult applyConfigurationAdd(TestChildCfg configuration) {
- return new ConfigChangeResult();
- }
-
-
-
- /** {@inheritDoc} */
- @Override
- public boolean isConfigurationAddAcceptable(TestChildCfg configuration,
- List<LocalizableMessage> unacceptableReasons) {
- return true;
- }
-
- }
-
-
-
- /**
- * A test child delete listener.
- */
- private static class DeleteListener implements
- ConfigurationDeleteListener<TestChildCfg> {
-
- /** {@inheritDoc} */
- @Override
- public ConfigChangeResult applyConfigurationDelete(
- TestChildCfg configuration) {
- return new ConfigChangeResult();
- }
-
-
-
- /** {@inheritDoc} */
- @Override
- public boolean isConfigurationDeleteAcceptable(TestChildCfg configuration,
- List<LocalizableMessage> unacceptableReasons) {
- return true;
- }
-
- }
-
-
-
- /**
- * A test child change listener.
- */
- private static class ChangeListener implements
- ConfigurationChangeListener<TestChildCfg> {
-
- /** {@inheritDoc} */
- @Override
- public ConfigChangeResult applyConfigurationChange(
- TestChildCfg configuration) {
- return new ConfigChangeResult();
- }
-
-
-
- /** {@inheritDoc} */
- @Override
- public boolean isConfigurationChangeAcceptable(TestChildCfg configuration,
- List<LocalizableMessage> unacceptableReasons) {
- return true;
- }
-
- }
-
- /** Test child 1 LDIF. */
- private static final String[] TEST_CHILD_1 = new String[] {
- "dn: cn=test child 1,cn=test children,cn=test parent 1,cn=test parents,cn=config",
- "objectclass: top",
- "objectclass: ds-cfg-test-child-dummy",
- "cn: test child 1",
- "ds-cfg-enabled: true",
- "ds-cfg-java-class: org.opends.server.extensions.UserDefinedVirtualAttributeProvider",
- "ds-cfg-attribute-type: description",
- "ds-cfg-conflict-behavior: virtual-overrides-real"
- };
-
- /** Test LDIF. */
- private static final String[] TEST_LDIF = new String[] {
- // Base entries.
- "dn: cn=test parents,cn=config",
- "objectclass: top",
- "objectclass: ds-cfg-branch",
- "cn: test parents",
- "",
- // Parent 1 - uses default values for
- // optional-multi-valued-dn-property.
- "dn: cn=test parent 1,cn=test parents,cn=config",
- "objectclass: top",
- "objectclass: ds-cfg-test-parent-dummy",
- "cn: test parent 1",
- "ds-cfg-enabled: true",
- "ds-cfg-java-class: org.opends.server.extensions.UserDefinedVirtualAttributeProvider",
- "ds-cfg-attribute-type: description",
- "ds-cfg-conflict-behavior: virtual-overrides-real",
- "",
- // Child base entries.
- "dn:cn=test children,cn=test parent 1,cn=test parents,cn=config",
- "objectclass: top",
- "objectclass: ds-cfg-branch",
- "cn: test children",
- "",
- };
-
- /** JNDI LDAP context. */
- private JNDIDirContextAdaptor adaptor;
-
-
-
- /**
- * Sets up tests
- *
- * @throws Exception
- * If the server could not be initialized.
- */
- @BeforeClass
- public void setUp() throws Exception {
- // This test suite depends on having the schema available, so
- // we'll start the server.
- TestCaseUtils.startServer();
- TestCfg.setUp();
-
- // Add test managed objects.
- TestCaseUtils.addEntries(TEST_LDIF);
- }
-
-
-
- /**
- * Tears down test environment.
- *
- * @throws Exception
- * If the test entries could not be removed.
- */
- @AfterClass
- public void tearDown() throws Exception {
- TestCfg.cleanup();
-
- // Remove test entries.
- deleteSubtree("cn=test parents,cn=config");
- }
-
-
-
- /**
- * Tests that retrieval can succeed.
- *
- * @throws Exception
- * If the test unexpectedly fails.
- */
- @Test
- public void testGetManagedObjectSuccess() throws Exception {
- MockConstraint constraint = new MockConstraint(true, false);
-
- try {
- TestCaseUtils.addEntry(TEST_CHILD_1);
- TestCfg.addConstraint(constraint);
-
- TestParentCfg parent = getParent("test parent 1");
- parent.getTestChild("test child 1");
- } finally {
- TestCfg.removeConstraint(constraint);
- deleteSubtreeNoException(TEST_CHILD_1_DN);
- }
- }
-
-
-
- /**
- * Tests that retrieval can fail.
- *
- * @throws Exception
- * If the test unexpectedly fails.
- */
- @Test
- public void testGetManagedObjectFail() throws Exception {
- MockConstraint constraint = new MockConstraint(false, true);
-
- try {
- TestCaseUtils.addEntry(TEST_CHILD_1);
- TestCfg.addConstraint(constraint);
-
- TestParentCfg parent = getParent("test parent 1");
- parent.getTestChild("test child 1");
- } catch (ConfigException e) {
- Throwable cause = e.getCause();
- if (cause instanceof ConstraintViolationException) {
- ConstraintViolationException cve = (ConstraintViolationException) cause;
- Assert.assertEquals(cve.getMessages().size(), 1);
- Assert.assertSame(cve.getManagedObject().getManagedObjectDefinition(),
- TestChildCfgDefn.getInstance());
- } else {
- // Wrong cause.
- throw e;
- }
- } finally {
- TestCfg.removeConstraint(constraint);
- deleteSubtreeNoException(TEST_CHILD_1_DN);
- }
- }
-
-
-
- /**
- * Tests that an add constraint can succeed.
- *
- * @throws Exception
- * If the test unexpectedly fails.
- */
- @Test
- public void testAddConstraintSuccess() throws Exception {
- TestParentCfg parent = getParent("test parent 1");
- AddListener listener = new AddListener();
- parent.addTestChildAddListener(listener);
-
- MockConstraint constraint = new MockConstraint(true, false);
- TestCfg.addConstraint(constraint);
-
- try {
- try {
- // Add the entry.
- addEntry(ResultCode.SUCCESS, TEST_CHILD_1);
- } finally {
- deleteSubtreeNoException(TEST_CHILD_1_DN);
- }
- } finally {
- TestCfg.removeConstraint(constraint);
- parent.removeTestChildAddListener(listener);
- }
- }
-
-
-
- /**
- * Tests that an add constraint can fail.
- *
- * @throws Exception
- * If the test unexpectedly fails.
- */
- @Test
- public void testAddConstraintFail() throws Exception {
- TestParentCfg parent = getParent("test parent 1");
- AddListener listener = new AddListener();
- parent.addTestChildAddListener(listener);
-
- MockConstraint constraint = new MockConstraint(false, true);
- TestCfg.addConstraint(constraint);
-
- try {
- try {
- // Add the entry.
- addEntry(ResultCode.UNWILLING_TO_PERFORM, TEST_CHILD_1);
- } finally {
- deleteSubtreeNoException(TEST_CHILD_1_DN);
- }
- } finally {
- TestCfg.removeConstraint(constraint);
- parent.removeTestChildAddListener(listener);
- }
- }
-
-
-
- /**
- * Tests that a delete constraint can succeed.
- *
- * @throws Exception
- * If the test unexpectedly fails.
- */
- @Test
- public void testDeleteConstraintSuccess() throws Exception {
- TestParentCfg parent = getParent("test parent 1");
- DeleteListener listener = new DeleteListener();
- parent.addTestChildDeleteListener(listener);
-
- MockConstraint constraint = new MockConstraint(false, true);
- TestCfg.addConstraint(constraint);
-
- try {
- // Add the entry.
- TestCaseUtils.addEntry(TEST_CHILD_1);
-
- // Now delete it - this should trigger the constraint.
- deleteSubtree(TEST_CHILD_1_DN);
- } finally {
- TestCfg.removeConstraint(constraint);
- parent.removeTestChildDeleteListener(listener);
- deleteSubtreeNoException(TEST_CHILD_1_DN);
- }
- }
-
-
-
- /**
- * Tests that a delete constraint can fail.
- *
- * @throws Exception
- * If the test unexpectedly fails.
- */
- @Test
- public void testDeleteConstraintFail() throws Exception {
- TestParentCfg parent = getParent("test parent 1");
- DeleteListener listener = new DeleteListener();
- parent.addTestChildDeleteListener(listener);
-
- MockConstraint constraint = new MockConstraint(true, false);
- TestCfg.addConstraint(constraint);
-
- try {
- // Add the entry.
- TestCaseUtils.addEntry(TEST_CHILD_1);
- try {
- // Now delete it - this should trigger the constraint.
- deleteSubtree(TEST_CHILD_1_DN);
-
- // Should not have succeeded.
- Assert.fail("Delete constraint failed to prevent deletion");
- } catch (OperationNotSupportedException e) {
- // Ignore - this is the expected exception.
- }
- } finally {
- TestCfg.removeConstraint(constraint);
- parent.removeTestChildDeleteListener(listener);
- deleteSubtreeNoException(TEST_CHILD_1_DN);
- }
- }
-
-
-
- /**
- * Tests that a modify constraint can succeed.
- *
- * @throws Exception
- * If the test unexpectedly fails.
- */
- @Test
- public void testChangeConstraintSuccess() throws Exception {
- TestParentCfg parent = getParent("test parent 1");
-
- MockConstraint constraint = new MockConstraint(true, false);
-
- try {
- // Add the entry.
- TestCaseUtils.addEntry(TEST_CHILD_1);
- TestChildCfg child = parent.getTestChild("test child 1");
-
- TestCfg.addConstraint(constraint);
- ChangeListener listener = new ChangeListener();
- child.addChangeListener(listener);
-
- // Now modify it.
- String[] changes = new String[] {
- "dn: cn=test child 1,cn=test children,cn=test parent 1,cn=test parents,cn=config",
- "changetype: modify",
- "replace: ds-cfg-base-dn",
- "ds-cfg-base-dn: dc=new value 1,dc=com",
- "ds-cfg-base-dn: dc=new value 2,dc=com",
- "-",
- "replace: ds-cfg-group-dn",
- "ds-cfg-group-dn: dc=new value 3,dc=com",
- "ds-cfg-group-dn: dc=new value 4,dc=com"
- };
-
- int result = TestCaseUtils.applyModifications(true, changes);
- Assert.assertEquals(result, ResultCode.SUCCESS.intValue());
- } finally {
- TestCfg.removeConstraint(constraint);
- deleteSubtreeNoException(TEST_CHILD_1_DN);
- }
- }
-
-
-
- /**
- * Tests that a modify constraint can fail.
- *
- * @throws Exception
- * If the test unexpectedly fails.
- */
- @Test
- public void testChangeConstraintFail() throws Exception {
- TestParentCfg parent = getParent("test parent 1");
- MockConstraint constraint = new MockConstraint(false, true);
-
- try {
- // Add the entry.
- TestCaseUtils.addEntry(TEST_CHILD_1);
- TestChildCfg child = parent.getTestChild("test child 1");
-
- TestCfg.addConstraint(constraint);
- ChangeListener listener = new ChangeListener();
- child.addChangeListener(listener);
-
- // Now modify it.
- String[] changes = new String[] {
- "dn: cn=test child 1,cn=test children,cn=test parent 1,cn=test parents,cn=config",
- "changetype: modify",
- "replace: ds-cfg-base-dn",
- "ds-cfg-base-dn: dc=new value 1,dc=com",
- "ds-cfg-base-dn: dc=new value 2,dc=com",
- "-",
- "replace: ds-cfg-group-dn",
- "ds-cfg-group-dn: dc=new value 3,dc=com",
- "ds-cfg-group-dn: dc=new value 4,dc=com"
- };
-
- int result = TestCaseUtils.applyModifications(true, changes);
- Assert.assertEquals(result, ResultCode.UNWILLING_TO_PERFORM.intValue());
- } finally {
- TestCfg.removeConstraint(constraint);
- deleteSubtreeNoException(TEST_CHILD_1_DN);
- }
- }
-
- /** Add an entry and check its result. */
- private void addEntry(ResultCode expected, String... lines) throws Exception {
- Entry entry = TestCaseUtils.makeEntry(lines);
- AddOperation add = getRootConnection().processAdd(entry);
- assertEquals(add.getResultCode(), expected, add.getErrorMessage().toString());
- }
-
- private void deleteSubtreeNoException(String dn)
- {
- try
- {
- deleteSubtree(dn);
- }
- catch (Exception e)
- {
- // Ignore.
- }
- }
-
- /** Deletes the named sub-tree. */
- private void deleteSubtree(String dn) throws Exception {
- getAdaptor().deleteSubtree(new LdapName(dn));
- }
-
- /** Gets the JNDI connection for the test server instance. */
- private synchronized JNDIDirContextAdaptor getAdaptor() throws Exception {
- if (adaptor == null) {
- adaptor = JNDIDirContextAdaptor.simpleSSLBind("127.0.0.1", TestCaseUtils
- .getServerAdminPort(), "cn=directory manager", "password");
- }
- return adaptor;
- }
-
- /** Gets the named parent configuration. */
- private TestParentCfg getParent(String name) throws Exception {
- ServerManagementContext ctx = ServerManagementContext.getInstance();
- ServerManagedObject<RootCfg> root = ctx.getRootConfigurationManagedObject();
- return root.getChild(
- TestCfg.getTestOneToManyParentRelationDefinition(), name)
- .getConfiguration();
- }
-}
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/admin/server/ListenerTest.java b/opendj-server-legacy/src/test/java/org/opends/server/admin/server/ListenerTest.java
deleted file mode 100644
index 87a90b7..0000000
--- a/opendj-server-legacy/src/test/java/org/opends/server/admin/server/ListenerTest.java
+++ /dev/null
@@ -1,554 +0,0 @@
-/*
- * The contents of this file are subject to the terms of the Common Development and
- * Distribution License (the License). You may not use this file except in compliance with the
- * License.
- *
- * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
- * specific language governing permission and limitations under the License.
- *
- * When distributing Covered Software, include this CDDL Header Notice in each file and include
- * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
- * Header, with the fields enclosed by brackets [] replaced by your own identifying
- * information: "Portions Copyright [year] [name of copyright owner]".
- *
- * Copyright 2007-2008 Sun Microsystems, Inc.
- * Portions Copyright 2014-2016 ForgeRock AS.
- */
-package org.opends.server.admin.server;
-
-import static org.testng.Assert.*;
-
-import java.util.List;
-
-import org.forgerock.i18n.LocalizableMessage;
-import org.opends.server.TestCaseUtils;
-import org.opends.server.admin.AdminTestCase;
-import org.opends.server.admin.TestCfg;
-import org.opends.server.admin.TestParentCfg;
-import org.opends.server.admin.std.server.RootCfg;
-import org.opends.server.api.ConfigAddListener;
-import org.opends.server.api.ConfigDeleteListener;
-import org.opends.server.config.ConfigEntry;
-import org.opends.server.core.DeleteOperation;
-import org.opends.server.core.DirectoryServer;
-import org.opends.server.protocols.internal.InternalClientConnection;
-import org.forgerock.opendj.config.server.ConfigChangeResult;
-import org.forgerock.opendj.ldap.DN;
-import org.forgerock.opendj.ldap.ResultCode;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-/**
- * Test cases for listener registration.
- */
-public final class ListenerTest extends AdminTestCase {
-
- /** Add listener implementation. */
- private static final class TestParentAddListener implements
- ConfigurationAddListener<TestParentCfg> {
-
- /** {@inheritDoc} */
- public ConfigChangeResult applyConfigurationAdd(TestParentCfg configuration) {
- // No implementation required.
- return null;
- }
-
-
-
- /** {@inheritDoc} */
- public boolean isConfigurationAddAcceptable(TestParentCfg configuration,
- List<LocalizableMessage> unacceptableReasons) {
- // No implementation required.
- return false;
- }
- }
-
-
-
- /** Delete listener implementation. */
- private static final class TestParentDeleteListener implements
- ConfigurationDeleteListener<TestParentCfg> {
-
- /** {@inheritDoc} */
- public ConfigChangeResult applyConfigurationDelete(
- TestParentCfg configuration) {
- // No implementation required.
- return null;
- }
-
-
-
- /** {@inheritDoc} */
- public boolean isConfigurationDeleteAcceptable(TestParentCfg configuration,
- List<LocalizableMessage> unacceptableReasons) {
- // No implementation required.
- return false;
- }
-
- }
-
-
-
- /**
- * Sets up tests
- *
- * @throws Exception
- * If the server could not be initialized.
- */
- @BeforeClass
- public void setUp() throws Exception {
- // This test suite depends on having the schema available, so
- // we'll start the server.
- TestCaseUtils.startServer();
- TestCfg.setUp();
- }
-
-
-
- /**
- * Tears down test environment.
- */
- @AfterClass
- public void tearDown() {
- TestCfg.cleanup();
- }
-
-
-
- /**
- * Checks that a ConfigAddListenerAdaptor is delayed when its
- * associated instantiable relation entry does not exist.
- *
- * @throws Exception
- * If an unexpected exception occurred.
- */
- @Test
- public void testConfigAddListenerAdaptorInstantiableDelayed()
- throws Exception {
- ServerManagementContext ctx = ServerManagementContext.getInstance();
- ServerManagedObject<RootCfg> root = ctx.getRootConfigurationManagedObject();
- ConfigurationAddListener<TestParentCfg> listener = new TestParentAddListener();
- root.registerAddListener(TestCfg.getTestOneToManyParentRelationDefinition(), listener);
-
- // Make sure that the relation entry does not exist.
- DN relationDN = DN.valueOf("cn=test parents,cn=config");
- ConfigEntry configEntry = DirectoryServer.getConfigEntry(relationDN);
- assertNull(configEntry, "Relation entry " + relationDN + " already exists");
-
- // Make sure that the listener was delayed and registered against
- // the parent.
- DN parentDN = DN.valueOf("cn=config");
- configEntry = DirectoryServer.getConfigEntry(parentDN);
- assertNotNull(configEntry, "Relation parent entry " + parentDN
- + " does not exist");
-
- boolean isFound = false;
- for (ConfigAddListener l : configEntry.getAddListeners()) {
- if (l instanceof DelayedConfigAddListener) {
- DelayedConfigAddListener dl = (DelayedConfigAddListener) l;
- ConfigAddListener tmp = dl.getDelayedAddListener();
- if (tmp instanceof ConfigAddListenerAdaptor) {
- ConfigAddListenerAdaptor<?> al = (ConfigAddListenerAdaptor<?>) tmp;
- if (extractListener(al) == listener) {
- isFound = true;
- }
- }
- }
- }
-
- if (!isFound) {
- fail("Unable to locate delayed listener in entry " + parentDN);
- }
-
- // Now make sure that the delayed listener is removed from the
- // parent and the add listener register against the relation entry
- // when it is created.
- String[] entry = new String[] {
- "dn: cn=test parents,cn=config",
- "objectclass: top",
- "objectclass: ds-cfg-branch",
- "cn: test-parents"
- };
- TestCaseUtils.addEntry(entry);
-
- // Check the delayed listener is removed.
- for (ConfigAddListener l : configEntry.getAddListeners()) {
- if (l instanceof DelayedConfigAddListener) {
- DelayedConfigAddListener dl = (DelayedConfigAddListener) l;
- ConfigAddListener tmp = dl.getDelayedAddListener();
- if (tmp instanceof ConfigAddListenerAdaptor) {
- ConfigAddListenerAdaptor<?> al = (ConfigAddListenerAdaptor<?>) tmp;
- if (extractListener(al) == listener) {
- fail("Delayed listener still exists in entry " + parentDN
- + " when it should have been removed");
-
- // Clean up.
- configEntry.deregisterAddListener(dl);
- }
- }
- }
- }
-
- // Check the add listener is registered.
- configEntry = DirectoryServer.getConfigEntry(relationDN);
- assertNotNull(configEntry, "Relation entry " + relationDN
- + " does not exist");
-
- isFound = false;
- for (ConfigAddListener l : configEntry.getAddListeners()) {
- if (l instanceof ConfigAddListenerAdaptor) {
- ConfigAddListenerAdaptor<?> al = (ConfigAddListenerAdaptor<?>) l;
- if (extractListener(al) == listener) {
- isFound = true;
-
- // Clean up.
- configEntry.deregisterAddListener(al);
- }
- }
- }
-
- if (!isFound) {
- fail("Unable to locate listener adaptor in entry " + relationDN);
- }
-
- // Remove the test entry.
- InternalClientConnection conn = InternalClientConnection
- .getRootConnection();
- DeleteOperation deleteOperation = conn.processDelete(relationDN);
- assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS);
- }
-
-
-
- /**
- * Checks that a ConfigAddListenerAdaptor is not delayed when its
- * associated instantiable relation entry already exists.
- *
- * @throws Exception
- * If an unexpected exception occurred.
- */
- @Test
- public void testConfigAddListenerAdaptorInstantiableImmediate()
- throws Exception {
- ServerManagementContext ctx = ServerManagementContext.getInstance();
- ServerManagedObject<RootCfg> root = ctx.getRootConfigurationManagedObject();
- ConfigurationAddListener<TestParentCfg> listener = new TestParentAddListener();
- root.registerAddListener(TestCfg.getTestOneToManyParentRelationDefinition(), listener);
-
- // Add the relation entry.
- String[] entry = new String[] {
- "dn: cn=test parents,cn=config",
- "objectclass: top",
- "objectclass: ds-cfg-branch",
- "cn: test-parents"
- };
- TestCaseUtils.addEntry(entry);
-
- // Make sure that the relation entry exist.
- DN relationDN = DN.valueOf("cn=test parents,cn=config");
- ConfigEntry configEntry = DirectoryServer.getConfigEntry(relationDN);
- assertNotNull(configEntry, "Relation entry " + relationDN
- + " does not exist");
-
- // Check the add listener is registered.
- boolean isFound = false;
- for (ConfigAddListener l : configEntry.getAddListeners()) {
- if (l instanceof ConfigAddListenerAdaptor) {
- ConfigAddListenerAdaptor<?> al = (ConfigAddListenerAdaptor<?>) l;
- if (extractListener(al) == listener) {
- isFound = true;
-
- // Clean up.
- configEntry.deregisterAddListener(al);
- }
- }
- }
-
- if (!isFound) {
- fail("Unable to locate listener adaptor in entry " + relationDN);
- }
-
- // Remove the test entry.
- InternalClientConnection conn = InternalClientConnection
- .getRootConnection();
- DeleteOperation deleteOperation = conn.processDelete(relationDN);
- assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS);
- }
-
-
-
- /**
- * Checks that a ConfigAddListenerAdaptor is registered for optional
- * relations.
- *
- * @throws Exception
- * If an unexpected exception occurred.
- */
- @Test
- public void testConfigAddListenerAdaptorOptional() throws Exception {
- ServerManagementContext ctx = ServerManagementContext.getInstance();
- ServerManagedObject<RootCfg> root = ctx.getRootConfigurationManagedObject();
- ConfigurationAddListener<TestParentCfg> listener = new TestParentAddListener();
- root.registerAddListener(TestCfg.getTestOneToZeroOrOneParentRelationDefinition(),
- listener);
-
- // Make sure that the relation entry exists.
- DN relationDN = DN.valueOf("cn=config");
- ConfigEntry configEntry = DirectoryServer.getConfigEntry(relationDN);
- assertNotNull(configEntry, "Relation entry " + relationDN
- + " does not exist");
-
- // Check the add listener is registered.
- boolean isFound = false;
- for (ConfigAddListener l : configEntry.getAddListeners()) {
- if (l instanceof ConfigAddListenerAdaptor) {
- ConfigAddListenerAdaptor<?> al = (ConfigAddListenerAdaptor<?>) l;
- if (extractListener(al) == listener) {
- isFound = true;
-
- // Clean up.
- configEntry.deregisterAddListener(al);
- }
- }
- }
-
- if (!isFound) {
- fail("Unable to locate listener adaptor in entry " + relationDN);
- }
- }
-
-
-
- /**
- * Checks that a ConfigDeleteListenerAdaptor is delayed when its
- * associated instantiable relation entry does not exist.
- *
- * @throws Exception
- * If an unexpected exception occurred.
- */
- @Test
- public void testConfigDeleteListenerAdaptorInstantiableDelayed()
- throws Exception {
- ServerManagementContext ctx = ServerManagementContext.getInstance();
- ServerManagedObject<RootCfg> root = ctx.getRootConfigurationManagedObject();
- ConfigurationDeleteListener<TestParentCfg> listener = new TestParentDeleteListener();
- root.registerDeleteListener(TestCfg.getTestOneToManyParentRelationDefinition(), listener);
-
- // Make sure that the relation entry does not exist.
- DN relationDN = DN.valueOf("cn=test parents,cn=config");
- ConfigEntry configEntry = DirectoryServer.getConfigEntry(relationDN);
- assertNull(configEntry, "Relation entry " + relationDN + " already exists");
-
- // Make sure that the listener was delayed and registered against
- // the parent.
- DN parentDN = DN.valueOf("cn=config");
- configEntry = DirectoryServer.getConfigEntry(parentDN);
- assertNotNull(configEntry, "Relation parent entry " + parentDN
- + " does not exist");
-
- boolean isFound = false;
- for (ConfigAddListener l : configEntry.getAddListeners()) {
- if (l instanceof DelayedConfigAddListener) {
- DelayedConfigAddListener dl = (DelayedConfigAddListener) l;
- ConfigDeleteListener tmp = dl.getDelayedDeleteListener();
- if (tmp instanceof ConfigDeleteListenerAdaptor) {
- ConfigDeleteListenerAdaptor<?> al = (ConfigDeleteListenerAdaptor<?>) tmp;
- if (extractListener(al) == listener) {
- isFound = true;
- }
- }
- }
- }
-
- if (!isFound) {
- fail("Unable to locate delayed listener in entry " + parentDN);
- }
-
- // Now make sure that the delayed listener is removed from the
- // parent and the add listener register against the relation entry
- // when it is created.
- String[] entry = new String[] {
- "dn: cn=test parents,cn=config",
- "objectclass: top",
- "objectclass: ds-cfg-branch",
- "cn: test-parents"
- };
- TestCaseUtils.addEntry(entry);
-
- // Check the delayed listener is removed.
- for (ConfigAddListener l : configEntry.getAddListeners()) {
- if (l instanceof DelayedConfigAddListener) {
- DelayedConfigAddListener dl = (DelayedConfigAddListener) l;
- ConfigDeleteListener tmp = dl.getDelayedDeleteListener();
- if (tmp instanceof ConfigDeleteListenerAdaptor) {
- ConfigDeleteListenerAdaptor<?> al = (ConfigDeleteListenerAdaptor<?>) tmp;
- if (extractListener(al) == listener) {
- fail("Delayed listener still exists in entry " + parentDN
- + " when it should have been removed");
-
- // Clean up.
- configEntry.deregisterAddListener(dl);
- }
- }
- }
- }
-
- // Check the add listener is registered.
- configEntry = DirectoryServer.getConfigEntry(relationDN);
- assertNotNull(configEntry, "Relation entry " + relationDN
- + " does not exist");
-
- isFound = false;
- for (ConfigDeleteListener l : configEntry.getDeleteListeners()) {
- if (l instanceof ConfigDeleteListenerAdaptor) {
- ConfigDeleteListenerAdaptor<?> al = (ConfigDeleteListenerAdaptor<?>) l;
- if (extractListener(al) == listener) {
- isFound = true;
-
- // Clean up.
- configEntry.deregisterDeleteListener(al);
- }
- }
- }
-
- if (!isFound) {
- fail("Unable to locate listener adaptor in entry " + relationDN);
- }
-
- // Remove the test entry.
- InternalClientConnection conn = InternalClientConnection
- .getRootConnection();
- DeleteOperation deleteOperation = conn.processDelete(relationDN);
- assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS);
- }
-
-
-
- /**
- * Checks that a ConfigDeleteListenerAdaptor is not delayed when its
- * associated instantiable relation entry already exists.
- *
- * @throws Exception
- * If an unexpected exception occurred.
- */
- @Test
- public void testConfigDeleteListenerAdaptorInstantiableImmediate()
- throws Exception {
- ServerManagementContext ctx = ServerManagementContext.getInstance();
- ServerManagedObject<RootCfg> root = ctx.getRootConfigurationManagedObject();
- ConfigurationDeleteListener<TestParentCfg> listener = new TestParentDeleteListener();
- root.registerDeleteListener(TestCfg.getTestOneToManyParentRelationDefinition(), listener);
-
- // Add the relation entry.
- String[] entry = new String[] {
- "dn: cn=test parents,cn=config",
- "objectclass: top",
- "objectclass: ds-cfg-branch",
- "cn: test-parents"
- };
- TestCaseUtils.addEntry(entry);
-
- // Make sure that the relation entry exist.
- DN relationDN = DN.valueOf("cn=test parents,cn=config");
- ConfigEntry configEntry = DirectoryServer.getConfigEntry(relationDN);
- assertNotNull(configEntry, "Relation entry " + relationDN
- + " does not exist");
-
- // Check the add listener is registered.
- boolean isFound = false;
- for (ConfigDeleteListener l : configEntry.getDeleteListeners()) {
- if (l instanceof ConfigDeleteListenerAdaptor) {
- ConfigDeleteListenerAdaptor<?> al = (ConfigDeleteListenerAdaptor<?>) l;
- if (extractListener(al) == listener) {
- isFound = true;
-
- // Clean up.
- configEntry.deregisterDeleteListener(al);
- }
- }
- }
-
- if (!isFound) {
- fail("Unable to locate listener adaptor in entry " + relationDN);
- }
-
- // Remove the test entry.
- InternalClientConnection conn = InternalClientConnection
- .getRootConnection();
- DeleteOperation deleteOperation = conn.processDelete(relationDN);
- assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS);
- }
-
-
-
- /**
- * Checks that a ConfigDeleteListenerAdaptor is registered for
- * optional relations.
- *
- * @throws Exception
- * If an unexpected exception occurred.
- */
- @Test
- public void testConfigDeleteListenerAdaptorOptional() throws Exception {
- ServerManagementContext ctx = ServerManagementContext.getInstance();
- ServerManagedObject<RootCfg> root = ctx.getRootConfigurationManagedObject();
- ConfigurationDeleteListener<TestParentCfg> listener = new TestParentDeleteListener();
- root.registerDeleteListener(TestCfg.getTestOneToZeroOrOneParentRelationDefinition(),
- listener);
-
- // Make sure that the relation entry exists.
- DN relationDN = DN.valueOf("cn=config");
- ConfigEntry configEntry = DirectoryServer.getConfigEntry(relationDN);
- assertNotNull(configEntry, "Relation entry " + relationDN
- + " does not exist");
-
- // Check the add listener is registered.
- boolean isFound = false;
- for (ConfigDeleteListener l : configEntry.getDeleteListeners()) {
- if (l instanceof ConfigDeleteListenerAdaptor) {
- ConfigDeleteListenerAdaptor<?> al = (ConfigDeleteListenerAdaptor<?>) l;
- if (extractListener(al) == listener) {
- isFound = true;
-
- // Clean up.
- configEntry.deregisterDeleteListener(al);
- }
- }
- }
-
- if (!isFound) {
- fail("Unable to locate listener adaptor in entry " + relationDN);
- }
- }
-
-
-
- /** Attempt to extract an add listener from the provided adaptor. */
- private ConfigurationAddListener<?> extractListener(
- ConfigAddListenerAdaptor<?> al) {
- ServerManagedObjectAddListener<?> al2 = al
- .getServerManagedObjectAddListener();
- if (al2 instanceof ServerManagedObjectAddListenerAdaptor) {
- ServerManagedObjectAddListenerAdaptor<?> al3 =
- (ServerManagedObjectAddListenerAdaptor<?>) al2;
- return al3.getConfigurationAddListener();
- }
- return null;
- }
-
-
-
- /** Attempt to extract a delete listener from the provided adaptor. */
- private ConfigurationDeleteListener<?> extractListener(
- ConfigDeleteListenerAdaptor<?> al) {
- ServerManagedObjectDeleteListener<?> al2 = al
- .getServerManagedObjectDeleteListener();
- if (al2 instanceof ServerManagedObjectDeleteListenerAdaptor) {
- ServerManagedObjectDeleteListenerAdaptor<?> al3 =
- (ServerManagedObjectDeleteListenerAdaptor<?>) al2;
- return al3.getConfigurationDeleteListener();
- }
- return null;
- }
-}
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/admin/server/MockConstraint.java b/opendj-server-legacy/src/test/java/org/opends/server/admin/server/MockConstraint.java
deleted file mode 100644
index 66a84ae..0000000
--- a/opendj-server-legacy/src/test/java/org/opends/server/admin/server/MockConstraint.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * The contents of this file are subject to the terms of the Common Development and
- * Distribution License (the License). You may not use this file except in compliance with the
- * License.
- *
- * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
- * specific language governing permission and limitations under the License.
- *
- * When distributing Covered Software, include this CDDL Header Notice in each file and include
- * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
- * Header, with the fields enclosed by brackets [] replaced by your own identifying
- * information: "Portions Copyright [year] [name of copyright owner]".
- *
- * Copyright 2008 Sun Microsystems, Inc.
- * Portions Copyright 2014-2016 ForgeRock AS.
- */
-package org.opends.server.admin.server;
-
-
-
-import java.util.Collection;
-import java.util.Collections;
-
-import org.forgerock.i18n.LocalizableMessage;
-import org.opends.server.admin.Constraint;
-import org.opends.server.admin.client.ClientConstraintHandler;
-import org.opends.server.config.ConfigEntry;
-import org.forgerock.opendj.config.server.ConfigException;
-import org.opends.server.core.DirectoryServer;
-import org.forgerock.opendj.ldap.DN;
-import org.testng.Assert;
-
-
-
-/**
- * A mock constraint which can be configured to refuse various types
- * of operation.
- */
-public final class MockConstraint extends Constraint {
-
- /**
- * Mock server constraint handler.
- */
- private class Handler extends ServerConstraintHandler {
-
- /** {@inheritDoc} */
- @Override
- public boolean isDeleteAllowed(ServerManagedObject<?> managedObject,
- Collection<LocalizableMessage> unacceptableReasons) throws ConfigException {
- if (!isDeleteAllowed) {
- unacceptableReasons
- .add(LocalizableMessage.raw("Configuration cannot be deleted."));
- }
-
- return isDeleteAllowed;
- }
-
-
-
- /** {@inheritDoc} */
- @Override
- public boolean isUsable(ServerManagedObject<?> managedObject,
- Collection<LocalizableMessage> unacceptableReasons) throws ConfigException {
- if (!isUsable) {
- unacceptableReasons.add(LocalizableMessage.raw("Configuration is not usable."));
- }
-
- return isUsable;
- }
-
-
-
- /** {@inheritDoc} */
- @Override
- public void performPostAdd(ServerManagedObject<?> managedObject)
- throws ConfigException {
- // Make sure that the associated config entry exists.
- DN targetDN = managedObject.getDN();
- ConfigEntry configEntry = DirectoryServer.getConfigEntry(targetDN);
- Assert.assertNotNull(configEntry);
- }
-
-
-
- /** {@inheritDoc} */
- @Override
- public void performPostDelete(ServerManagedObject<?> managedObject)
- throws ConfigException {
- // Make sure that the associated config entry does not exist.
- DN targetDN = managedObject.getDN();
- ConfigEntry configEntry = DirectoryServer.getConfigEntry(targetDN);
- Assert.assertNull(configEntry);
- }
-
-
-
- /** {@inheritDoc} */
- @Override
- public void performPostModify(ServerManagedObject<?> managedObject)
- throws ConfigException {
- // Make sure that the associated config entry exists.
- DN targetDN = managedObject.getDN();
- ConfigEntry configEntry = DirectoryServer.getConfigEntry(targetDN);
- Assert.assertNotNull(configEntry);
- }
-
- }
-
- /** Determines if delete operations are allowed. */
- private final boolean isDeleteAllowed;
-
- /** Determines if configurations can be decoded. */
- private final boolean isUsable;
-
-
-
- /**
- * Creates a new mock constraint.
- *
- * @param isUsable
- * Determines if configurations can be decoded.
- * @param isDeleteAllowed
- * Determines if delete operations are allowed.
- */
- public MockConstraint(boolean isUsable, boolean isDeleteAllowed) {
- this.isUsable = isUsable;
- this.isDeleteAllowed = isDeleteAllowed;
- }
-
-
-
- /** {@inheritDoc} */
- public Collection<ClientConstraintHandler> getClientConstraintHandlers() {
- return Collections.emptySet();
- }
-
-
-
- /** {@inheritDoc} */
- public Collection<ServerConstraintHandler> getServerConstraintHandlers() {
- return Collections.<ServerConstraintHandler> singleton(new Handler());
- }
-
-}
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/api/ConfigChangeListenerTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/api/ConfigChangeListenerTestCase.java
deleted file mode 100644
index bc343b8..0000000
--- a/opendj-server-legacy/src/test/java/org/opends/server/api/ConfigChangeListenerTestCase.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * The contents of this file are subject to the terms of the Common Development and
- * Distribution License (the License). You may not use this file except in compliance with the
- * License.
- *
- * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
- * specific language governing permission and limitations under the License.
- *
- * When distributing Covered Software, include this CDDL Header Notice in each file and include
- * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
- * Header, with the fields enclosed by brackets [] replaced by your own identifying
- * information: "Portions Copyright [year] [name of copyright owner]".
- *
- * Copyright 2006-2008 Sun Microsystems, Inc.
- * Portions Copyright 2014-2016 ForgeRock AS.
- */
-package org.opends.server.api;
-
-import java.util.ArrayList;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-
-import org.opends.server.TestCaseUtils;
-import org.forgerock.i18n.LocalizableMessageBuilder;
-import org.opends.server.config.ConfigEntry;
-import org.opends.server.core.DirectoryServer;
-import org.forgerock.opendj.ldap.DN;
-import static org.testng.Assert.*;
-
-
-
-/**
- * A set of generic test cases for config change listeners.
- */
-public class ConfigChangeListenerTestCase
- extends APITestCase
-{
- /**
- * Ensures that the Directory Server is running.
- *
- * @throws Exception If an unexpected problem occurs.
- */
- @BeforeClass
- public void startServer()
- throws Exception
- {
- TestCaseUtils.startServer();
- }
-
-
-
- /**
- * Retrieves the set of config change listeners registered with the server.
- *
- * @return The set of config change listeners registered with the server.
- *
- * @throws Exception If an unexpected problem occurs.
- */
- @DataProvider(name = "configChangeListeners")
- public Object[][] getConfigChangeListeners()
- throws Exception
- {
- ArrayList<DN> dns = new ArrayList<>();
- ArrayList<ConfigChangeListener> listeners = new ArrayList<>();
- getChangeListeners(DirectoryServer.getConfigHandler().getConfigRootEntry(), dns, listeners);
-
- Object[][] componentArray = new Object[listeners.size()][1];
- for (int i=0; i < componentArray.length; i++)
- {
- componentArray[i] = new Object[] { dns.get(i), listeners.get(i) };
- }
- return componentArray;
- }
-
-
-
- /**
- * Retrieves the config change listeners from the provided configuration
- * entry, as well as recursively from all of the its subordinate entries.
- *
- * @param configEntry The configuration entry from which to retrieve the
- * change listeners.
- * @param dns The list into which to add the DNs of the
- * configuration entries with the change listeners.
- * @param listeners The list into which to add all identified change
- * listeners.
- */
- private void getChangeListeners(ConfigEntry configEntry,
- ArrayList<DN> dns,
- ArrayList<ConfigChangeListener> listeners)
- {
- for (ConfigChangeListener l : configEntry.getChangeListeners())
- {
- dns.add(configEntry.getDN());
- listeners.add(l);
- }
-
- if (configEntry.hasChildren())
- {
- for (ConfigEntry e : configEntry.getChildren().values())
- {
- getChangeListeners(e, dns, listeners);
- }
- }
- }
-
-
-
- /**
- * Tests the <CODE>configChangeIsAccpetable</CODE> method with the current
- * configuration.
- *
- * @param dn The DN of the configuration entry for the provided listener.
- * @param l The listener to be tested.
- *
- * @throws Exception If an unexpected problem occurs.
- */
- @Test(dataProvider = "configChangeListeners")
- public void testConfigChangeIsAcceptable(DN dn, ConfigChangeListener l)
- throws Exception
- {
- ConfigEntry e = DirectoryServer.getConfigEntry(dn);
- assertNotNull(e);
-
- LocalizableMessageBuilder unacceptableReason = new LocalizableMessageBuilder();
- assertTrue(l.configChangeIsAcceptable(e, unacceptableReason),
- unacceptableReason.toString());
- }
-}
-
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/api/plugin/DirectoryServerPluginTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/api/plugin/DirectoryServerPluginTestCase.java
index 82f4f19..cb34e97 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/api/plugin/DirectoryServerPluginTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/api/plugin/DirectoryServerPluginTestCase.java
@@ -29,6 +29,7 @@
import org.forgerock.opendj.config.server.AdminTestCaseUtils;
import org.forgerock.opendj.server.config.meta.PluginCfgDefn;
import org.forgerock.opendj.server.config.server.PluginCfg;
+import org.opends.server.core.DirectoryServer;
import org.opends.server.plugins.NullPlugin;
import org.opends.server.types.DisconnectReason;
import org.forgerock.opendj.ldap.DN;
@@ -807,7 +808,8 @@
HashSet<PluginType> pluginTypes = new HashSet<>();
Collections.addAll(pluginTypes, PluginType.values());
- nullPlugin.initializeInternal(configuration.dn(), pluginTypes,
+ nullPlugin.initializeInternal(DirectoryServer.getInstance().getServerContext(),
+ configuration.dn(), pluginTypes,
configuration.isInvokeForInternalOperations());
assertEquals(nullPlugin.getPluginEntryDN(), pluginEntryDN);
}
@@ -889,7 +891,8 @@
HashSet<PluginType> pluginTypes = new HashSet<>();
Collections.addAll(pluginTypes, PluginType.values());
- nullPlugin.initializeInternal(configuration.dn(), pluginTypes,
+ nullPlugin.initializeInternal(DirectoryServer.getInstance().getServerContext(),
+ configuration.dn(), pluginTypes,
configuration.isInvokeForInternalOperations());
assertEquals(nullPlugin.getPluginTypes(), pluginTypes);
}
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/backends/jeb/JETestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/backends/jeb/JETestCase.java
index 4e95f97..e022567 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/backends/jeb/JETestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/backends/jeb/JETestCase.java
@@ -16,7 +16,7 @@
package org.opends.server.backends.jeb;
import static org.mockito.Mockito.when;
-import static org.opends.server.ConfigurationMock.legacyMockCfg;
+import static org.opends.server.ConfigurationMock.mockCfg;
import org.forgerock.opendj.server.config.server.JEBackendCfg;
import org.opends.server.backends.pluggable.PluggableBackendImplTestCase;
@@ -35,7 +35,7 @@
@Override
protected JEBackendCfg createBackendCfg()
{
- JEBackendCfg backendCfg = legacyMockCfg(JEBackendCfg.class);
+ JEBackendCfg backendCfg = mockCfg(JEBackendCfg.class);
when(backendCfg.getBackendId()).thenReturn("JETestCase");
when(backendCfg.getDBDirectory()).thenReturn("JETestCase");
when(backendCfg.getDBDirectoryPermissions()).thenReturn("755");
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/backends/pluggable/ControlsTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/backends/pluggable/ControlsTestCase.java
index 9c029e7..0fd4d87 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/backends/pluggable/ControlsTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/backends/pluggable/ControlsTestCase.java
@@ -17,7 +17,7 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.*;
-import static org.opends.server.ConfigurationMock.legacyMockCfg;
+import static org.opends.server.ConfigurationMock.mockCfg;
import static org.opends.server.TestCaseUtils.makeEntry;
import static org.opends.server.protocols.internal.InternalClientConnection.getRootConnection;
import static org.opends.server.protocols.internal.Requests.newSearchRequest;
@@ -124,7 +124,7 @@
final DN baseDN = DN.valueOf(BACKEND_BASE_DN);
- final PDBBackendCfg backendCfg = legacyMockCfg(PDBBackendCfg.class);
+ final PDBBackendCfg backendCfg = mockCfg(PDBBackendCfg.class);
when(backendCfg.dn()).thenReturn(baseDN);
when(backendCfg.getBackendId()).thenReturn(BACKEND_NAME);
when(backendCfg.getBaseDN()).thenReturn(newTreeSet(baseDN));
@@ -155,7 +155,7 @@
private void createVlvIndex(final DN baseDN, final PDBBackendCfg backendCfg, final String sortOrder)
throws ConfigException
{
- final BackendVLVIndexCfg vlvIndexCfg = legacyMockCfg(BackendVLVIndexCfg.class);
+ final BackendVLVIndexCfg vlvIndexCfg = mockCfg(BackendVLVIndexCfg.class);
when(vlvIndexCfg.getName()).thenReturn(sortOrder);
when(vlvIndexCfg.getBaseDN()).thenReturn(baseDN);
when(vlvIndexCfg.getFilter()).thenReturn(VLV_FILTER);
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/backends/pluggable/DN2IDTest.java b/opendj-server-legacy/src/test/java/org/opends/server/backends/pluggable/DN2IDTest.java
index e68bbcb..dfcf944 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/backends/pluggable/DN2IDTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/backends/pluggable/DN2IDTest.java
@@ -53,6 +53,7 @@
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+@SuppressWarnings("javadoc")
@Test(groups = { "precommit", "pluggablebackend" }, sequential = true)
public class DN2IDTest extends DirectoryServerTestCase
{
@@ -308,7 +309,7 @@
private static PDBBackendCfg createBackendCfg() throws ConfigException, DirectoryException
{
String homeDirName = "pdb_test";
- PDBBackendCfg backendCfg = legacyMockCfg(PDBBackendCfg.class);
+ PDBBackendCfg backendCfg = mockCfg(PDBBackendCfg.class);
when(backendCfg.getBackendId()).thenReturn("persTest" + homeDirName);
when(backendCfg.getDBDirectory()).thenReturn(homeDirName);
@@ -320,7 +321,7 @@
when(backendCfg.listBackendIndexes()).thenReturn(new String[] { "sn" });
when(backendCfg.listBackendVLVIndexes()).thenReturn(new String[0]);
- BackendIndexCfg indexCfg = legacyMockCfg(BackendIndexCfg.class);
+ BackendIndexCfg indexCfg = mockCfg(BackendIndexCfg.class);
when(indexCfg.getIndexType()).thenReturn(newTreeSet(IndexType.PRESENCE, IndexType.EQUALITY));
when(indexCfg.getAttribute()).thenReturn(DirectoryServer.getAttributeType("sn"));
when(backendCfg.getBackendIndex("sn")).thenReturn(indexCfg);
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/backends/pluggable/ID2ChildrenCountTest.java b/opendj-server-legacy/src/test/java/org/opends/server/backends/pluggable/ID2ChildrenCountTest.java
index 6c25d8f..d2117a9 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/backends/pluggable/ID2ChildrenCountTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/backends/pluggable/ID2ChildrenCountTest.java
@@ -52,6 +52,7 @@
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+@SuppressWarnings("javadoc")
@Test(groups = { "precommit", "pluggablebackend" }, sequential = true)
public class ID2ChildrenCountTest extends DirectoryServerTestCase
{
@@ -224,7 +225,7 @@
private PDBBackendCfg createBackendCfg() throws ConfigException, DirectoryException
{
String homeDirName = "pdb_test";
- PDBBackendCfg backendCfg = legacyMockCfg(PDBBackendCfg.class);
+ PDBBackendCfg backendCfg = mockCfg(PDBBackendCfg.class);
when(backendCfg.getBackendId()).thenReturn("persTest" + homeDirName);
when(backendCfg.getDBDirectory()).thenReturn(homeDirName);
@@ -236,7 +237,7 @@
when(backendCfg.listBackendIndexes()).thenReturn(new String[] { "sn" });
when(backendCfg.listBackendVLVIndexes()).thenReturn(new String[0]);
- BackendIndexCfg indexCfg = legacyMockCfg(BackendIndexCfg.class);
+ BackendIndexCfg indexCfg = mockCfg(BackendIndexCfg.class);
when(indexCfg.getIndexType()).thenReturn(newTreeSet(IndexType.PRESENCE, IndexType.EQUALITY));
when(indexCfg.getAttribute()).thenReturn(DirectoryServer.getAttributeType("sn"));
when(backendCfg.getBackendIndex("sn")).thenReturn(indexCfg);
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/backends/pluggable/StateTest.java b/opendj-server-legacy/src/test/java/org/opends/server/backends/pluggable/StateTest.java
index 1f12499..b90e09e 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/backends/pluggable/StateTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/backends/pluggable/StateTest.java
@@ -171,7 +171,7 @@
private PDBBackendCfg createBackendCfg() throws ConfigException, DirectoryException
{
String homeDirName = "pdb_test";
- PDBBackendCfg backendCfg = legacyMockCfg(PDBBackendCfg.class);
+ PDBBackendCfg backendCfg = mockCfg(PDBBackendCfg.class);
when(backendCfg.getBackendId()).thenReturn("persTest" + homeDirName);
when(backendCfg.getDBDirectory()).thenReturn(homeDirName);
@@ -183,7 +183,7 @@
when(backendCfg.listBackendIndexes()).thenReturn(new String[] { "sn" });
when(backendCfg.listBackendVLVIndexes()).thenReturn(new String[0]);
- BackendIndexCfg indexCfg = legacyMockCfg(BackendIndexCfg.class);
+ BackendIndexCfg indexCfg = mockCfg(BackendIndexCfg.class);
when(indexCfg.getIndexType()).thenReturn(newTreeSet(IndexType.PRESENCE, IndexType.EQUALITY));
when(indexCfg.getAttribute()).thenReturn(DirectoryServer.getAttributeType("sn"));
when(backendCfg.getBackendIndex("sn")).thenReturn(indexCfg);
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/backends/pluggable/pdb/PDBTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/backends/pluggable/pdb/PDBTestCase.java
index 8bed2ce..acc2754 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/backends/pluggable/pdb/PDBTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/backends/pluggable/pdb/PDBTestCase.java
@@ -17,7 +17,7 @@
package org.opends.server.backends.pluggable.pdb;
import static org.mockito.Mockito.when;
-import static org.opends.server.ConfigurationMock.legacyMockCfg;
+import static org.opends.server.ConfigurationMock.mockCfg;
import org.forgerock.opendj.server.config.server.PDBBackendCfg;
import org.opends.server.backends.pdb.PDBBackend;
@@ -39,7 +39,7 @@
@Override
protected PDBBackendCfg createBackendCfg()
{
- PDBBackendCfg backendCfg = legacyMockCfg(PDBBackendCfg.class);
+ PDBBackendCfg backendCfg = mockCfg(PDBBackendCfg.class);
when(backendCfg.getBackendId()).thenReturn("PDBTestCase");
when(backendCfg.getDBDirectory()).thenReturn("PDBTestCase");
when(backendCfg.getDBDirectoryPermissions()).thenReturn("755");
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/core/PasswordPolicyTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/core/PasswordPolicyTestCase.java
index 135cb2f..9211a83 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/core/PasswordPolicyTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/core/PasswordPolicyTestCase.java
@@ -2162,13 +2162,8 @@
public void testInvalidConstructor(Entry e)
throws Exception
{
- DN parentDN = DN.valueOf("cn=Password Policies,cn=config");
- Entry parentEntry = DirectoryServer.getConfigEntry(parentDN);
- Entry configEntry = new Entry(e, parentEntry);
-
PasswordPolicyCfg configuration =
- AdminTestCaseUtils.getConfiguration(PasswordPolicyCfgDefn.getInstance(),
- configEntry);
+ AdminTestCaseUtils.getConfiguration(PasswordPolicyCfgDefn.getInstance(), e);
new PasswordPolicyFactory().createAuthenticationPolicy(configuration);
}
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/extensions/BcryptPasswordStorageSchemeTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/extensions/BcryptPasswordStorageSchemeTestCase.java
index 71d182b..7bf5674 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/extensions/BcryptPasswordStorageSchemeTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/extensions/BcryptPasswordStorageSchemeTestCase.java
@@ -47,10 +47,7 @@
new BcryptPasswordStorageScheme();
BcryptPasswordStorageSchemeCfg configuration =
- AdminTestCaseUtils.getConfiguration(
- BcryptPasswordStorageSchemeCfgDefn.getInstance(),
- configEntry.getEntry()
- );
+ AdminTestCaseUtils.getConfiguration(BcryptPasswordStorageSchemeCfgDefn.getInstance(), configEntry);
scheme.initializePasswordStorageScheme(configuration);
return scheme;
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/extensions/ConfigFileHandlerTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/extensions/ConfigFileHandlerTestCase.java
deleted file mode 100644
index 3f01b42..0000000
--- a/opendj-server-legacy/src/test/java/org/opends/server/extensions/ConfigFileHandlerTestCase.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * The contents of this file are subject to the terms of the Common Development and
- * Distribution License (the License). You may not use this file except in compliance with the
- * License.
- *
- * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
- * specific language governing permission and limitations under the License.
- *
- * When distributing Covered Software, include this CDDL Header Notice in each file and include
- * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
- * Header, with the fields enclosed by brackets [] replaced by your own identifying
- * information: "Portions Copyright [year] [name of copyright owner]".
- *
- * Copyright 2008-2010 Sun Microsystems, Inc.
- * Portions Copyright 2015-2016 ForgeRock AS.
- */
-package org.opends.server.extensions;
-
-
-
-import java.io.File;
-import java.util.ArrayList;
-
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import org.opends.server.TestCaseUtils;
-import org.opends.server.types.Entry;
-import org.opends.server.core.DirectoryServer;
-import org.forgerock.opendj.ldap.DN;
-
-import static org.testng.Assert.*;
-
-import static org.opends.server.util.ServerConstants.*;
-
-
-
-/**
- * A set of test cases for the config file handler.
- */
-public class ConfigFileHandlerTestCase
- extends ExtensionsTestCase
-{
- /**
- * Makes sure that the server is running before performing any tests.
- *
- * @throws Exception If an unexpected problem occurs.
- */
- @BeforeClass
- public void setUp()
- throws Exception
- {
- TestCaseUtils.startServer();
-
- String buildRoot = System.getProperty(TestCaseUtils.PROPERTY_BUILD_ROOT);
- String buildDir = System.getProperty(TestCaseUtils.PROPERTY_BUILD_DIR,
- buildRoot + File.separator + "build");
- String startOKFile = buildDir + File.separator +
- "unit-tests" + File.separator + "package-instance" +
- File.separator + "config" + File.separator +
- "config.ldif.startok";
-
- assertTrue(new File(startOKFile).exists(),
- startOKFile + " does not exist but it should");
- assertFalse(new File(startOKFile + ".tmp").exists(),
- startOKFile + ".tmp exists but should not");
- assertFalse(new File(startOKFile + ".old").exists(),
- startOKFile + ".old exists but should not");
- }
-
-
-
- /**
- * Tests to verify that attempts to change the structural object class of a
- * config entry will be rejected.
- *
- * @throws Exception If an unexpected problem occurs.
- */
- @Test
- public void testChangingStructuralClass()
- throws Exception
- {
- int resultCode = TestCaseUtils.applyModifications(true,
- "dn: cn=config",
- "changetype: modify",
- "replace: objectClass",
- "objectClass: top",
- "objectClass: device",
- "objectClass: extensibleObject"
- );
-
- assertFalse(resultCode == 0);
- }
-
-
-
- /**
- * Tests to ensure that none of the configuration entries are using the
- * extensibleObject object class.
- */
- @Test
- public void testNoExtensibleObjects()
- throws Exception
- {
- ArrayList<DN> violatingDNs = new ArrayList<>();
- recursivelyTestNoExtensibleObjects(
- DirectoryServer.getConfigHandler().getConfigRootEntry(), violatingDNs);
-
- if (! violatingDNs.isEmpty())
- {
- StringBuilder message = new StringBuilder();
- message.append("The extensibleObject object class is not allowed for use in the server configuration.")
- .append(EOL);
- message.append("Configuration entries containing the extensibleObject object class:").append(EOL);
- for (DN dn : violatingDNs)
- {
- message.append("- ").append(dn).append(EOL);
- }
-
- throw new AssertionError(message.toString());
- }
- }
-
-
-
- /**
- * Tests that the provided configuration entry does not contain the
- * extensibleObject object class, and neither do any of its subordinate
- * entries.
- *
- * @param configEntry The configuration entry to be checked.
- * @param violatingDNs A list to which the DN of any entry containing the
- * extensibleObject class should be added.
- */
- private void recursivelyTestNoExtensibleObjects(Entry configEntry,
- ArrayList<DN> violatingDNs)
- {
- if (configEntry.hasObjectClass("extensibleObject"))
- {
- violatingDNs.add(configEntry.getName());
- }
-
- for (Entry ce : configEntry.getChildren().values())
- {
- recursivelyTestNoExtensibleObjects(ce, violatingDNs);
- }
- }
-}
-
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/extensions/ErrorLogAccountStatusNotificationHandlerTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/extensions/ErrorLogAccountStatusNotificationHandlerTestCase.java
index 40de27d..194eea9 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/extensions/ErrorLogAccountStatusNotificationHandlerTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/extensions/ErrorLogAccountStatusNotificationHandlerTestCase.java
@@ -129,7 +129,7 @@
* Tests to ensure that the notification handler initialization fails with an
* invalid configuration.
*
- * @param e The configuration entry to use to initialize the account status
+ * @param configEntry The configuration entry to use to initialize the account status
* notificaton handler.
*
* @throws Exception If an unexpected problem occurs.
@@ -137,14 +137,9 @@
@Test(dataProvider = "invalidConfigs",
expectedExceptions = { ConfigException.class,
InitializationException.class })
- public void testInalidConfigs(Entry e)
+ public void testInvalidConfigs(Entry configEntry)
throws Exception
{
- DN parentDN =
- DN.valueOf("cn=Account Status Notification Handlers,cn=config");
- Entry parentEntry = DirectoryServer.getConfigEntry(parentDN);
- Entry configEntry = new Entry(e, parentEntry);
-
ErrorLogAccountStatusNotificationHandler handler =
new ErrorLogAccountStatusNotificationHandler();
ErrorLogAccountStatusNotificationHandlerCfg configuration =
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/replication/GenerationIdTest.java b/opendj-server-legacy/src/test/java/org/opends/server/replication/GenerationIdTest.java
index da8029f..db2cc9b 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/replication/GenerationIdTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/replication/GenerationIdTest.java
@@ -415,13 +415,12 @@
DN synchroServerDN = DN.valueOf(synchroServerStringDN);
- Entry ecle = DirectoryServer.getConfigHandler().getEntry(
- DN.valueOf("cn=external changelog," + synchroServerStringDN));
+ Entry ecle = DirectoryServer.getConfigEntry(DN.valueOf("cn=external changelog," + synchroServerStringDN));
if (ecle!=null)
{
- DirectoryServer.getConfigHandler().deleteEntry(ecle.getName(), null);
+ DirectoryServer.getConfigurationHandler().deleteEntry(ecle.getName());
}
- DirectoryServer.getConfigHandler().deleteEntry(synchroServerDN, null);
+ DirectoryServer.getConfigurationHandler().deleteEntry(synchroServerDN);
assertNull(DirectoryServer.getConfigEntry(synchroServerEntry.getName()),
"Unable to delete the synchronized domain");
synchroServerEntry = null;
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/replication/ProtocolWindowTest.java b/opendj-server-legacy/src/test/java/org/opends/server/replication/ProtocolWindowTest.java
index 6aa72e9..ed507f6 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/replication/ProtocolWindowTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/replication/ProtocolWindowTest.java
@@ -23,6 +23,7 @@
import org.assertj.core.api.Assertions;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.forgerock.opendj.adapter.server3x.Converters;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.TestCaseUtils;
import org.opends.server.core.AddOperation;
@@ -102,7 +103,7 @@
Entry repDomainEntry = TestCaseUtils.entryFromLdifString(synchroServerLdif);
// Configure replication domain
- DirectoryServer.getConfigHandler().addEntry(repDomainEntry, null);
+ DirectoryServer.getConfigurationHandler().addEntry(Converters.from(repDomainEntry));
assertNotNull(DirectoryServer.getConfigEntry(repDomainEntry.getName()),
"Unable to add the synchronized server");
configEntriesToCleanup.add(repDomainEntry.getName());
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/replication/ReplicationTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/replication/ReplicationTestCase.java
index 089902e..151a01c 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/replication/ReplicationTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/replication/ReplicationTestCase.java
@@ -28,6 +28,7 @@
import org.assertj.core.api.SoftAssertions;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.forgerock.opendj.adapter.server3x.Converters;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ModificationType;
@@ -464,7 +465,7 @@
{
if (configEntry != null)
{
- DirectoryServer.getConfigHandler().addEntry(configEntry, null);
+ DirectoryServer.getConfigurationHandler().addEntry(Converters.from(configEntry));
assertNotNull(DirectoryServer.getConfigEntry(configEntry.getName()), errorMessage);
configEntriesToCleanup.add(configEntry.getName());
}
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/AssuredReplicationPluginTest.java b/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/AssuredReplicationPluginTest.java
index 53ede73..6fdfd36 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/AssuredReplicationPluginTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/AssuredReplicationPluginTest.java
@@ -27,6 +27,7 @@
import org.assertj.core.data.MapEntry;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.forgerock.opendj.adapter.server3x.Converters;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.DN;
import org.forgerock.opendj.ldap.ResultCode;
@@ -217,7 +218,7 @@
Entry domainCfgEntry = TestCaseUtils.entryFromLdifString(configEntryLdif);
// Add the config entry to create the replicated domain
- DirectoryServer.getConfigHandler().addEntry(domainCfgEntry, null);
+ DirectoryServer.getConfigurationHandler().addEntry(Converters.from(domainCfgEntry));
assertNotNull(DirectoryServer.getConfigEntry(domainCfgEntry.getName()),
"Unable to add the domain config entry: " + configEntryLdif);
@@ -245,7 +246,7 @@
Entry domainCfgEntry = TestCaseUtils.entryFromLdifString(configEntryLdif);
// Add the config entry to create the replicated domain
- DirectoryServer.getConfigHandler().addEntry(domainCfgEntry, null);
+ DirectoryServer.getConfigurationHandler().addEntry(Converters.from(domainCfgEntry));
assertNotNull(DirectoryServer.getConfigEntry(domainCfgEntry.getName()),
"Unable to add the domain config entry: " + configEntryLdif);
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/FractionalReplicationTest.java b/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/FractionalReplicationTest.java
index 008c55b..ce9943c 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/FractionalReplicationTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/FractionalReplicationTest.java
@@ -20,6 +20,7 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.forgerock.opendj.adapter.server3x.Converters;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.DN;
import org.forgerock.opendj.ldap.ModificationType;
@@ -505,7 +506,7 @@
fractionalDomainCfgEntry = TestCaseUtils.entryFromLdifString(configEntryLdif);
// Add the config entry to create the replicated domain
- DirectoryServer.getConfigHandler().addEntry(fractionalDomainCfgEntry, null);
+ DirectoryServer.getConfigurationHandler().addEntry(Converters.from(fractionalDomainCfgEntry));
assertNotNull(DirectoryServer.getConfigEntry(fractionalDomainCfgEntry.getName()),
"Unable to add the domain config entry: " + configEntryLdif);
}
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/schema/ConfigurableAttributeSyntaxTest.java b/opendj-server-legacy/src/test/java/org/opends/server/schema/ConfigurableAttributeSyntaxTest.java
index 48fcf0a..71f2acb 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/schema/ConfigurableAttributeSyntaxTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/schema/ConfigurableAttributeSyntaxTest.java
@@ -35,7 +35,7 @@
public Object[][] createSyntaxTest() throws Exception
{
// some config object used later in the test
- Entry strictConfig = new Entry(TestCaseUtils.makeEntry(
+ Entry strictConfig = TestCaseUtils.makeEntry(
"dn: cn=Telephone Number,cn=Syntaxes,cn=config",
"objectClass: top",
"objectClass: ds-cfg-telephone-number-attribute-syntax",
@@ -44,9 +44,9 @@
"ds-cfg-enabled: true",
"ds-cfg-java-class: org.opends.server.schema.TelephoneNumberSyntax",
"cn: Telephone Number"
- ), null);
+ );
- Entry relaxedConfig = new Entry(TestCaseUtils.makeEntry(
+ Entry relaxedConfig = TestCaseUtils.makeEntry(
"dn: cn=Telephone Number,cn=Syntaxes,cn=config",
"objectClass: top",
"objectClass: ds-cfg-telephone-number-attribute-syntax",
@@ -55,7 +55,7 @@
"ds-cfg-enabled: true",
"ds-cfg-java-class: org.opends.server.schema.TelephoneNumberSyntax",
"cn: Telephone Number"
- ), null);
+ );
// fill this table with tables containing :
// - the configEntry that must be applied before the test.
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/tools/ImportLDIFTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/tools/ImportLDIFTestCase.java
index d814520..36ae09b 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/tools/ImportLDIFTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/tools/ImportLDIFTestCase.java
@@ -24,7 +24,6 @@
import java.io.PrintStream;
import org.opends.server.TestCaseUtils;
-import org.forgerock.opendj.config.server.ServerManagementContext;
import org.forgerock.opendj.server.config.server.RootCfg;
import org.opends.server.core.DirectoryServer;
import org.opends.server.tasks.TaskUtils;
@@ -463,7 +462,8 @@
{
try
{
- final RootCfg root = ServerManagementContext.getInstance().getRootConfiguration();
+ final RootCfg root =
+ DirectoryServer.getInstance().getServerContext().getServerManagementContext().getRootConfiguration();
final String errorMsg = "Unexpected content in reject file:\n\n" + readFile(reject)
+ "\n\nThe backend was configured with the following base DNs: "
+ root.getBackend(beID).getBaseDN() + "\n\n";
--
Gitblit v1.10.0