From e0e6d30a905e47931a89b7e9063d752a6f28106d Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Wed, 05 Feb 2014 22:45:49 +0000
Subject: [PATCH] OPENDJ-1235: Migrate configuration framework
---
opendj-config/src/main/java/org/forgerock/opendj/config/IntegerPropertyDefinition.java | 6
opendj-config/src/test/java/org/forgerock/opendj/config/ConfigurationMock.java | 2
opendj-config/src/main/java/org/forgerock/opendj/config/client/ldap/LDAPDriver.java | 27
opendj-config/src/test/java/org/forgerock/opendj/config/server/AggregationServerTest.java | 23
opendj-config/src/test/java/org/forgerock/opendj/config/server/DefaultBehaviorTest.java | 9
opendj-config/src/main/java/org/forgerock/opendj/config/SizePropertyDefinition.java | 6
opendj-config/src/main/java/org/forgerock/opendj/config/DNPropertyDefinition.java | 6
opendj-config/src/main/java/org/forgerock/opendj/config/client/ldap/LDAPManagementContext.java | 28
opendj-config/src/main/java/org/forgerock/opendj/config/client/spi/PropertySet.java | 8
opendj-config/src/main/java/org/forgerock/opendj/config/AbstractManagedObjectDefinition.java | 7
opendj-config/src/main/java/org/forgerock/opendj/config/ManagedObjectPath.java | 6
opendj-config/src/test/java/org/forgerock/opendj/config/client/ldap/LDAPClientTest.java | 105 +--
opendj-config/src/main/java/org/forgerock/opendj/config/AggregationPropertyDefinition.java | 6
opendj-config/src/main/java/org/forgerock/opendj/config/client/spi/AbstractManagedObject.java | 19
opendj-config/src/main/java/org/forgerock/opendj/config/conditions/ContainsCondition.java | 3
opendj-config/src/main/java/org/forgerock/opendj/config/StringPropertyDefinition.java | 6
opendj-config/src/test/java/org/forgerock/opendj/config/server/ListenerTest.java | 21
opendj-config/src/main/java/org/forgerock/opendj/config/ConfigurationFramework.java | 804 +++++++++++++++++++++++++++++++++
opendj-config/src/test/java/org/forgerock/opendj/config/server/ConstraintTest.java | 11
opendj-config/src/main/java/org/forgerock/opendj/config/IPAddressMaskPropertyDefinition.java | 4
opendj-config/src/main/java/org/forgerock/opendj/config/PropertyDefinition.java | 12
opendj-config/src/main/java/org/forgerock/opendj/config/EnumPropertyDefinition.java | 4
opendj-config/src/test/java/org/forgerock/opendj/config/DurationPropertyDefinitionTest.java | 14
opendj-config/src/main/java/org/forgerock/opendj/config/client/ldap/LDAPManagedObject.java | 3
opendj-config/src/test/java/org/forgerock/opendj/config/SizePropertyDefinitionTest.java | 10
opendj-config/src/main/java/org/forgerock/opendj/config/client/spi/Driver.java | 14
opendj-config/src/test/java/org/forgerock/opendj/config/EnumPropertyDefinitionTest.java | 6
opendj-config/src/main/java/org/forgerock/opendj/config/client/IllegalManagedObjectNameException.java | 19
opendj-config/src/main/java/org/forgerock/opendj/config/server/ServerManagementContext.java | 40 -
opendj-config/src/main/java/org/forgerock/opendj/config/Reference.java | 2
opendj-config/src/test/java/org/forgerock/opendj/config/DNPropertyDefinitionTest.java | 8
opendj-config/src/main/java/org/forgerock/opendj/config/ManagedObjectDefinitionResource.java | 2
opendj-config/src/main/java/org/forgerock/opendj/config/DefaultManagedObject.java | 2
opendj-config/src/test/java/org/forgerock/opendj/config/IntegerPropertyDefinitionTest.java | 10
opendj-config/src/main/java/org/forgerock/opendj/config/ClassPropertyDefinition.java | 15
opendj-config/src/main/java/org/forgerock/opendj/config/ACIPropertyDefinition.java | 4
opendj-config/src/test/java/org/forgerock/opendj/config/AttributeTypePropertyDefinitionTest.java | 17
opendj-config/src/test/java/org/forgerock/opendj/config/client/ldap/AggregationClientTest.java | 23
opendj-config/src/main/java/org/forgerock/opendj/config/ManagedObjectDefinitionI18NResource.java | 2
/dev/null | 54 --
opendj-config/src/main/java/org/forgerock/opendj/config/DurationPropertyDefinition.java | 6
opendj-config/src/test/java/org/forgerock/opendj/config/BooleanPropertyDefinitionTest.java | 8
opendj-config/src/main/java/org/forgerock/opendj/config/AttributeTypePropertyDefinition.java | 29
opendj-config/src/main/java/org/forgerock/opendj/config/BooleanPropertyDefinition.java | 4
opendj-config/src/test/java/org/forgerock/opendj/config/StringPropertyDefinitionTest.java | 10
opendj-config/src/main/java/org/forgerock/opendj/config/IPAddressPropertyDefinition.java | 4
46 files changed, 1,041 insertions(+), 388 deletions(-)
diff --git a/opendj-config/src/main/java/org/forgerock/opendj/config/ACIPropertyDefinition.java b/opendj-config/src/main/java/org/forgerock/opendj/config/ACIPropertyDefinition.java
index ff5b776..179a2b9 100644
--- a/opendj-config/src/main/java/org/forgerock/opendj/config/ACIPropertyDefinition.java
+++ b/opendj-config/src/main/java/org/forgerock/opendj/config/ACIPropertyDefinition.java
@@ -85,7 +85,7 @@
* {@inheritDoc}
*/
@Override
- public void validateValue(Aci value, PropertyDefinitionsOptions options) {
+ public void validateValue(Aci value) {
Reject.ifNull(value);
// No additional validation required.
@@ -95,7 +95,7 @@
* {@inheritDoc}
*/
@Override
- public Aci decodeValue(String value, PropertyDefinitionsOptions options) {
+ public Aci decodeValue(String value) {
Reject.ifNull(value);
try {
diff --git a/opendj-config/src/main/java/org/forgerock/opendj/config/AbstractManagedObjectDefinition.java b/opendj-config/src/main/java/org/forgerock/opendj/config/AbstractManagedObjectDefinition.java
index 566fbc3..96f8a14 100644
--- a/opendj-config/src/main/java/org/forgerock/opendj/config/AbstractManagedObjectDefinition.java
+++ b/opendj-config/src/main/java/org/forgerock/opendj/config/AbstractManagedObjectDefinition.java
@@ -796,9 +796,10 @@
for (AggregationPropertyDefinition<?, ?> apd : getAllAggregationPropertyDefinitions()) {
apd.initialize();
- // Now register the aggregation property in the referenced managed
- // object
- // definition for reverse lookups.
+ /*
+ * Now register the aggregation property in the referenced managed
+ * object definition for reverse lookups.
+ */
registerReverseAggregationPropertyDefinition(apd);
}
diff --git a/opendj-config/src/main/java/org/forgerock/opendj/config/AggregationPropertyDefinition.java b/opendj-config/src/main/java/org/forgerock/opendj/config/AggregationPropertyDefinition.java
index ee96379..4466189 100644
--- a/opendj-config/src/main/java/org/forgerock/opendj/config/AggregationPropertyDefinition.java
+++ b/opendj-config/src/main/java/org/forgerock/opendj/config/AggregationPropertyDefinition.java
@@ -812,11 +812,11 @@
* {@inheritDoc}
*/
@Override
- public String decodeValue(String value, PropertyDefinitionsOptions options) {
+ public String decodeValue(String value) {
Reject.ifNull(value);
try {
- validateValue(value, options);
+ validateValue(value);
return value;
} catch (PropertyException e) {
throw PropertyException.illegalPropertyValueException(this, value);
@@ -980,7 +980,7 @@
* {@inheritDoc}
*/
@Override
- public void validateValue(String value, PropertyDefinitionsOptions options) {
+ public void validateValue(String value) {
try {
Reference.parseName(parentPath, relationDefinition, value);
} catch (IllegalArgumentException e) {
diff --git a/opendj-config/src/main/java/org/forgerock/opendj/config/AttributeTypePropertyDefinition.java b/opendj-config/src/main/java/org/forgerock/opendj/config/AttributeTypePropertyDefinition.java
index 40eb41e..fa82135 100644
--- a/opendj-config/src/main/java/org/forgerock/opendj/config/AttributeTypePropertyDefinition.java
+++ b/opendj-config/src/main/java/org/forgerock/opendj/config/AttributeTypePropertyDefinition.java
@@ -31,7 +31,7 @@
import java.util.EnumSet;
import org.forgerock.opendj.ldap.schema.AttributeType;
-import org.opends.server.core.DirectoryServer;
+import org.forgerock.opendj.ldap.schema.Schema;
/**
* Attribute type property definition.
@@ -109,21 +109,22 @@
* {@inheritDoc}
*/
@Override
- public AttributeType decodeValue(String value, PropertyDefinitionsOptions options) {
+ public AttributeType decodeValue(String value) {
Reject.ifNull(value);
- String name = value.trim().toLowerCase();
- AttributeType type = DirectoryServer.getAttributeType(name, !options.checkSchemaForAttributes());
-
- if (type == null) {
+ final String name = value.trim();
+ if (!ConfigurationFramework.getInstance().isClient()
+ && !Schema.getDefaultSchema().hasAttributeType(name)) {
+ // If this is the server then the attribute type must be defined.
throw PropertyException.illegalPropertyValueException(this, value);
- } else {
- try {
- validateValue(type, options);
- return type;
- } catch (PropertyException e) {
- throw PropertyException.illegalPropertyValueException(this, value);
- }
+ }
+ final AttributeType type =
+ Schema.getDefaultSchema().asNonStrictSchema().getAttributeType(name);
+ try {
+ validateValue(type);
+ return type;
+ } catch (PropertyException e) {
+ throw PropertyException.illegalPropertyValueException(this, value);
}
}
@@ -139,7 +140,7 @@
* {@inheritDoc}
*/
@Override
- public void validateValue(AttributeType value, PropertyDefinitionsOptions options) {
+ public void validateValue(AttributeType value) {
Reject.ifNull(value);
// No implementation required.
diff --git a/opendj-config/src/main/java/org/forgerock/opendj/config/BooleanPropertyDefinition.java b/opendj-config/src/main/java/org/forgerock/opendj/config/BooleanPropertyDefinition.java
index c00d1bc..bf39a6e 100644
--- a/opendj-config/src/main/java/org/forgerock/opendj/config/BooleanPropertyDefinition.java
+++ b/opendj-config/src/main/java/org/forgerock/opendj/config/BooleanPropertyDefinition.java
@@ -97,7 +97,7 @@
* {@inheritDoc}
*/
@Override
- public void validateValue(Boolean value, PropertyDefinitionsOptions options) {
+ public void validateValue(Boolean value) {
Reject.ifNull(value);
// No additional validation required.
@@ -107,7 +107,7 @@
* {@inheritDoc}
*/
@Override
- public Boolean decodeValue(String value, PropertyDefinitionsOptions options) {
+ public Boolean decodeValue(String value) {
Reject.ifNull(value);
String nvalue = value.trim().toLowerCase();
diff --git a/opendj-config/src/main/java/org/forgerock/opendj/config/ClassLoaderProvider.java b/opendj-config/src/main/java/org/forgerock/opendj/config/ClassLoaderProvider.java
deleted file mode 100644
index f86c9e5..0000000
--- a/opendj-config/src/main/java/org/forgerock/opendj/config/ClassLoaderProvider.java
+++ /dev/null
@@ -1,721 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- * Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- * Copyright 2008-2009 Sun Microsystems, Inc.
- * Portions copyright 2012-2014 ForgeRock AS.
- */
-package org.forgerock.opendj.config;
-
-import static com.forgerock.opendj.ldap.AdminMessages.*;
-import static com.forgerock.opendj.ldap.ExtensionMessages.*;
-import static com.forgerock.opendj.util.StaticUtils.*;
-
-import org.forgerock.util.Reject;
-
-import java.io.ByteArrayOutputStream;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileFilter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.PrintStream;
-import java.lang.reflect.Method;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-import java.util.jar.Attributes;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
-import java.util.jar.Manifest;
-
-import org.forgerock.i18n.LocalizableMessage;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
-import org.forgerock.opendj.config.server.ConfigException;
-import org.forgerock.opendj.server.config.meta.RootCfgDefn;
-import org.opends.server.core.DirectoryServer;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.forgerock.opendj.ldap.AdminMessages;
-
-/**
- * Manages the class loader which should be used for loading configuration
- * definition classes and associated extensions.
- * <p>
- * For extensions which define their own extended configuration definitions, the
- * class loader will make sure that the configuration definition classes are
- * loaded and initialized.
- * <p>
- * Initially the class loader provider is disabled, and calls to the
- * {@link #getClassLoader()} will return the system default class loader.
- * <p>
- * Applications <b>MUST NOT</b> maintain persistent references to the class
- * loader as it can change at run-time.
- */
-public final class ClassLoaderProvider {
-
- private static final String MANIFEST =
- "META-INF/services/org.forgerock.opendj.config.AbstractManagedObjectDefinition";
- private static final LocalizedLogger adminLogger = LocalizedLogger.getLocalizedLogger(AdminMessages
- .resourceName());
- private static final Logger debugLogger = LoggerFactory.getLogger(ClassLoaderProvider.class);
-
- /**
- * Private URLClassLoader implementation. This is only required so that we
- * can provide access to the addURL method.
- */
- private static final class MyURLClassLoader extends URLClassLoader {
-
- /**
- * Create a class loader with the default parent class loader.
- */
- public MyURLClassLoader() {
- super(new URL[0]);
- }
-
- /**
- * Create a class loader with the provided parent class loader.
- *
- * @param parent
- * The parent class loader.
- */
- public MyURLClassLoader(ClassLoader parent) {
- super(new URL[0], parent);
- }
-
- /**
- * Add a Jar file to this class loader.
- *
- * @param jarFile
- * The name of the Jar file.
- * @throws MalformedURLException
- * If a protocol handler for the URL could not be found, or
- * if some other error occurred while constructing the URL.
- * @throws SecurityException
- * If a required system property value cannot be accessed.
- */
- public void addJarFile(File jarFile) throws MalformedURLException {
- addURL(jarFile.toURI().toURL());
- }
-
- }
-
- // The name of the lib directory.
- private static final String LIB_DIR = "lib";
-
- // The name of the extensions directory.
- private static final String EXTENSIONS_DIR = "extensions";
-
- // The singleton instance.
- private static final ClassLoaderProvider INSTANCE = new ClassLoaderProvider();
-
- // Attribute name in jar's MANIFEST corresponding to the revision number.
- private static final String REVISION_NUMBER = "Revision-Number";
-
- // The attribute names for build information is name, version and revision
- // number
- private static final String[] BUILD_INFORMATION_ATTRIBUTE_NAMES =
- new String[] { Attributes.Name.EXTENSION_NAME.toString(), Attributes.Name.IMPLEMENTATION_VERSION.toString(),
- REVISION_NUMBER };
-
- /**
- * Get the single application wide class loader provider instance.
- *
- * @return Returns the single application wide class loader provider
- * instance.
- */
- public static ClassLoaderProvider getInstance() {
- return INSTANCE;
- }
-
- // Set of registered Jar files.
- private Set<File> jarFiles = new HashSet<File>();
-
- // Underlying class loader used to load classes and resources (null
- // if disabled).
- //
- // We contain a reference to the URLClassLoader rather than
- // sub-class it so that it is possible to replace the loader at
- // run-time. For example, when removing or replacing extension Jar
- // files (the URLClassLoader only supports adding new
- // URLs, not removal).
- private MyURLClassLoader loader = null;
-
- // Private constructor.
- private ClassLoaderProvider() {
- // No implementation required.
- }
-
- /**
- * Add the named extensions to this class loader provider.
- *
- * @param extensions
- * The names of the extensions to be loaded. The names should not
- * contain any path elements and must be located within the
- * extensions folder.
- * @throws ConfigException
- * If one of the extensions could not be loaded and initialized.
- * @throws IllegalStateException
- * If this class loader provider is disabled.
- * @throws IllegalArgumentException
- * If one of the extension names was not a single relative path
- * name element or was an absolute path.
- */
- public synchronized void addExtension(String... extensions) throws ConfigException {
- Reject.ifNull(extensions);
-
- if (loader == null) {
- throw new IllegalStateException("Class loader provider is disabled.");
- }
-
- File libPath = new File(DirectoryServer.getInstanceRoot(), LIB_DIR);
- File extensionsPath = new File(libPath, EXTENSIONS_DIR);
-
- ArrayList<File> files = new ArrayList<File>(extensions.length);
- for (String extension : extensions) {
- File file = new File(extensionsPath, extension);
-
- // For security reasons we need to make sure that the file name
- // passed in did not contain any path elements and names a file
- // in the extensions folder.
-
- // Can handle potential null parent.
- if (!extensionsPath.equals(file.getParentFile())) {
- throw new IllegalArgumentException("Illegal file name: " + extension);
- }
-
- // The file is valid.
- files.add(file);
- }
-
- // Add the extensions.
- addExtension(files.toArray(new File[files.size()]));
- }
-
- /**
- * Disable this class loader provider and removed any registered extensions.
- *
- * @throws IllegalStateException
- * If this class loader provider is already disabled.
- */
- public synchronized void disable() {
- if (loader == null) {
- throw new IllegalStateException("Class loader provider already disabled.");
- }
- loader = null;
- jarFiles = new HashSet<File>();
- }
-
- /**
- * Enable this class loader provider using the application's class loader as
- * the parent class loader.
- *
- * @throws ConfigException
- * If the class loader provider could not initialize
- * successfully.
- * @throws IllegalStateException
- * If this class loader provider is already enabled.
- */
- public synchronized void enable() throws ConfigException {
- enable(RootCfgDefn.class.getClassLoader());
- }
-
- /**
- * Enable this class loader provider using the provided parent class loader.
- *
- * @param parent
- * The parent class loader.
- * @throws ConfigException
- * If the class loader provider could not initialize
- * successfully.
- * @throws IllegalStateException
- * If this class loader provider is already enabled.
- */
- public synchronized void enable(ClassLoader parent) throws ConfigException {
- if (loader != null) {
- throw new IllegalStateException("Class loader provider already enabled.");
- }
-
- if (parent != null) {
- loader = new MyURLClassLoader(parent);
- } else {
- loader = new MyURLClassLoader();
- }
-
- // Forcefully load all configuration definition classes in
- // OpenDS.jar.
- initializeCoreComponents();
-
- // Put extensions jars into the class loader and load all
- // configuration definition classes in that they contain.
- // First load the extension from the install directory, then
- // from the instance directory.
- File libDir;
- File installExtensionsPath;
- File instanceExtensionsPath;
-
- // load install dir extension
- libDir = new File(DirectoryServer.getServerRoot(), LIB_DIR);
- try {
- installExtensionsPath = new File(libDir, EXTENSIONS_DIR).getCanonicalFile();
- } catch (Exception e) {
- installExtensionsPath = new File(libDir, EXTENSIONS_DIR);
- }
- initializeAllExtensions(installExtensionsPath);
-
- // load instance dir extension
- libDir = new File(DirectoryServer.getInstanceRoot(), LIB_DIR);
- try {
- instanceExtensionsPath = new File(libDir, EXTENSIONS_DIR).getCanonicalFile();
- } catch (Exception e) {
- instanceExtensionsPath = new File(libDir, EXTENSIONS_DIR);
- }
- if (!installExtensionsPath.getAbsolutePath().equals(instanceExtensionsPath.getAbsolutePath())) {
- initializeAllExtensions(instanceExtensionsPath);
- }
- }
-
- /**
- * Gets the class loader which should be used for loading classes and
- * resources. When this class loader provider is disabled, the system
- * default class loader will be returned by default.
- * <p>
- * Applications <b>MUST NOT</b> maintain persistent references to the class
- * loader as it can change at run-time.
- *
- * @return Returns the class loader which should be used for loading classes
- * and resources.
- */
- public synchronized ClassLoader getClassLoader() {
- if (loader != null) {
- return loader;
- } else {
- return ClassLoader.getSystemClassLoader();
- }
- }
-
- /**
- * Indicates whether this class loader provider is enabled.
- *
- * @return Returns <code>true</code> if this class loader provider is
- * enabled.
- */
- public synchronized boolean isEnabled() {
- return loader != null;
- }
-
- /**
- * Add the named extensions to this class loader.
- *
- * @param extensions
- * The names of the extensions to be loaded.
- * @throws ConfigException
- * If one of the extensions could not be loaded and initialized.
- */
- private synchronized void addExtension(File... extensions) throws ConfigException {
- // First add the Jar files to the class loader.
- List<JarFile> jars = new LinkedList<JarFile>();
- for (File extension : extensions) {
- if (jarFiles.contains(extension)) {
- // Skip this file as it is already loaded.
- continue;
- }
-
- // Attempt to load it.
- jars.add(loadJarFile(extension));
-
- // Register the Jar file with the class loader.
- try {
- loader.addJarFile(extension);
- } catch (Exception e) {
- debugLogger.trace("Unable to register the jar file with the class loader", e);
- LocalizableMessage message =
- ERR_ADMIN_CANNOT_OPEN_JAR_FILE.get(extension.getName(), extension.getParent(),
- stackTraceToSingleLineString(e, true));
- throw new ConfigException(message);
- }
- jarFiles.add(extension);
- }
-
- // Now forcefully load the configuration definition classes.
- for (JarFile jar : jars) {
- initializeExtension(jar);
- }
- }
-
- /**
- * Prints out all information about extensions.
- *
- * @return a String instance representing all information about extensions;
- * <code>null</code> if there is no information available.
- */
- public String printExtensionInformation() {
- File extensionsPath =
- new File(new StringBuilder(DirectoryServer.getServerRoot()).append(File.separator).append(LIB_DIR)
- .append(File.separator).append(EXTENSIONS_DIR).toString());
-
- if (!extensionsPath.exists() || !extensionsPath.isDirectory()) {
- // no extensions' directory
- return null;
- }
-
- File[] extensions = extensionsPath.listFiles(new FileFilter() {
- public boolean accept(File pathname) {
- // only files with names ending with ".jar"
- return pathname.isFile() && pathname.getName().endsWith(".jar");
- }
- });
-
- if (extensions.length == 0) {
- return null;
- }
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- PrintStream ps = new PrintStream(baos);
- // prints:
- // --
- // Name Build number Revision number
- ps.printf("--%s %-20s %-20s %-20s%s", EOL, "Name", "Build number", "Revision number", EOL);
-
- for (File extension : extensions) {
- // retrieve MANIFEST entry and display name, build number and
- // revision number
- try {
- JarFile jarFile = new JarFile(extension);
- JarEntry entry = jarFile.getJarEntry(MANIFEST);
- if (entry == null) {
- continue;
- }
-
- String[] information = getBuildInformation(jarFile);
-
- ps.append("Extension: ");
- boolean addBlank = false;
- for (String name : information) {
- if (addBlank) {
- ps.append(addBlank ? " " : ""); // add blank if not
- // first append
- } else {
- addBlank = true;
- }
-
- ps.printf("%-20s", name);
- }
- ps.append(EOL);
- } catch (Exception e) {
- // ignore extra information for this extension
- }
- }
-
- return baos.toString();
- }
-
- /**
- * Returns a String array with the following information : <br>
- * index 0: the name of the extension. <br>
- * index 1: the build number of the extension. <br>
- * index 2: the revision number of the extension.
- *
- * @param extension
- * the jar file of the extension
- * @return a String array containing the name, the build number and the
- * revision number of the extension given in argument
- * @throws java.io.IOException
- * thrown if the jar file has been closed.
- */
- private String[] getBuildInformation(JarFile extension) throws IOException {
- String[] result = new String[3];
-
- // retrieve MANIFEST entry and display name, version and revision
- Manifest manifest = extension.getManifest();
-
- if (manifest != null) {
- Attributes attributes = manifest.getMainAttributes();
-
- int index = 0;
- for (String name : BUILD_INFORMATION_ATTRIBUTE_NAMES) {
- String value = attributes.getValue(name);
- if (value == null) {
- value = "<unknown>";
- }
- result[index++] = value;
- }
- }
-
- return result;
- }
-
- /**
- * Put extensions jars into the class loader and load all configuration
- * definition classes in that they contain.
- *
- * @param extensionsPath
- * Indicates where extensions are located.
- * @throws ConfigException
- * If the extensions folder could not be accessed or if a
- * extension jar file could not be accessed or if one of the
- * configuration definition classes could not be initialized.
- */
- private void initializeAllExtensions(File extensionsPath) throws ConfigException {
-
- try {
- if (!extensionsPath.exists()) {
- // The extensions directory does not exist. This is not a
- // critical problem.
- adminLogger.error(ERR_ADMIN_NO_EXTENSIONS_DIR, String.valueOf(extensionsPath));
- return;
- }
-
- if (!extensionsPath.isDirectory()) {
- // The extensions directory is not a directory. This is more
- // critical.
- LocalizableMessage message =
- ERR_ADMIN_EXTENSIONS_DIR_NOT_DIRECTORY.get(String.valueOf(extensionsPath));
- throw new ConfigException(message);
- }
-
- // Get each extension file name.
- FileFilter filter = new FileFilter() {
-
- /**
- * Must be a Jar file.
- */
- public boolean accept(File pathname) {
- if (!pathname.isFile()) {
- return false;
- }
-
- String name = pathname.getName();
- return name.endsWith(".jar");
- }
-
- };
-
- // Add and initialize the extensions.
- addExtension(extensionsPath.listFiles(filter));
- } catch (ConfigException e) {
- debugLogger.trace("Unable to initialize all extensions", e);
- throw e;
- } catch (Exception e) {
- debugLogger.trace("Unable to initialize all extensions", e);
- LocalizableMessage message =
- ERR_ADMIN_EXTENSIONS_CANNOT_LIST_FILES.get(String.valueOf(extensionsPath),
- stackTraceToSingleLineString(e, true));
- throw new ConfigException(message, e);
- }
- }
-
- /**
- * Make sure all core configuration definitions are loaded.
- *
- * @throws ConfigException
- * If the core manifest file could not be read or if one of the
- * configuration definition classes could not be initialized.
- */
- private void initializeCoreComponents() throws ConfigException {
- InputStream is = RootCfgDefn.class.getResourceAsStream(MANIFEST);
- if (is == null) {
- LocalizableMessage message = ERR_ADMIN_CANNOT_FIND_CORE_MANIFEST.get(MANIFEST);
- throw new ConfigException(message);
- }
- try {
- loadDefinitionClasses(is);
- } catch (ConfigException e) {
- debugLogger.trace("Unable to initialize core components", e);
- LocalizableMessage message =
- ERR_CLASS_LOADER_CANNOT_LOAD_CORE.get(MANIFEST,
- stackTraceToSingleLineString(e, true));
- throw new ConfigException(message);
- }
- }
-
- /**
- * Make sure all the configuration definition classes in a extension are
- * loaded.
- *
- * @param jarFile
- * The extension's Jar file.
- * @throws ConfigException
- * If the extension jar file could not be accessed or if one of
- * the configuration definition classes could not be
- * initialized.
- */
- private void initializeExtension(JarFile jarFile) throws ConfigException {
- JarEntry entry = jarFile.getJarEntry(MANIFEST);
- if (entry != null) {
- InputStream is;
- try {
- is = jarFile.getInputStream(entry);
- } catch (Exception e) {
- debugLogger.trace("Unable to get input stream from jar", e);
- LocalizableMessage message =
- ERR_ADMIN_CANNOT_READ_EXTENSION_MANIFEST.get(MANIFEST, jarFile.getName(),
- stackTraceToSingleLineString(e, true));
- throw new ConfigException(message);
- }
-
- try {
- loadDefinitionClasses(is);
- } catch (ConfigException e) {
- debugLogger.trace("Unable to load classes from input stream", e);
- LocalizableMessage message =
- ERR_CLASS_LOADER_CANNOT_LOAD_EXTENSION.get(jarFile.getName(), MANIFEST,
- stackTraceToSingleLineString(e, true));
- throw new ConfigException(message);
- }
- try {
- // Log build information of extensions in the error log
- String[] information = getBuildInformation(jarFile);
- LocalizableMessage message =
- NOTE_LOG_EXTENSION_INFORMATION.get(jarFile.getName(), information[1], information[2]);
- LocalizedLogger.getLocalizedLogger(message.resourceName()).error(message);
- } catch (Exception e) {
- // Do not log information for that extension
- }
- }
- }
-
- /**
- * Forcefully load configuration definition classes named in a manifest
- * file.
- *
- * @param is
- * The manifest file input stream.
- * @throws ConfigException
- * If the definition classes could not be loaded and
- * initialized.
- */
- private void loadDefinitionClasses(InputStream is) throws ConfigException {
- BufferedReader reader = new BufferedReader(new InputStreamReader(is));
- List<AbstractManagedObjectDefinition<?, ?>> definitions =
- new LinkedList<AbstractManagedObjectDefinition<?, ?>>();
- while (true) {
- String className;
- try {
- className = reader.readLine();
- } catch (IOException e) {
- LocalizableMessage msg =
- ERR_CLASS_LOADER_CANNOT_READ_MANIFEST_FILE.get(String.valueOf(e.getMessage()));
- throw new ConfigException(msg, e);
- }
-
- // Break out when the end of the manifest is reached.
- if (className == null) {
- break;
- }
-
- // Skip blank lines.
- className = className.trim();
- if (className.length() == 0) {
- continue;
- }
-
- // Skip lines beginning with #.
- if (className.startsWith("#")) {
- continue;
- }
-
- debugLogger.trace("Loading class " + className);
-
- // Load the class and get an instance of it if it is a definition.
- Class<?> theClass;
- try {
- theClass = Class.forName(className, true, loader);
- } catch (Exception e) {
- LocalizableMessage msg =
- ERR_CLASS_LOADER_CANNOT_LOAD_CLASS.get(className, String.valueOf(e.getMessage()));
- throw new ConfigException(msg, e);
- }
- if (AbstractManagedObjectDefinition.class.isAssignableFrom(theClass)) {
- // We need to instantiate it using its getInstance() static
- // method.
- Method method;
- try {
- method = theClass.getMethod("getInstance");
- } catch (Exception e) {
- LocalizableMessage msg =
- ERR_CLASS_LOADER_CANNOT_FIND_GET_INSTANCE_METHOD.get(className,
- String.valueOf(e.getMessage()));
- throw new ConfigException(msg, e);
- }
-
- // Get the definition instance.
- AbstractManagedObjectDefinition<?, ?> d;
- try {
- d = (AbstractManagedObjectDefinition<?, ?>) method.invoke(null);
- } catch (Exception e) {
- LocalizableMessage msg =
- ERR_CLASS_LOADER_CANNOT_INVOKE_GET_INSTANCE_METHOD.get(className,
- String.valueOf(e.getMessage()));
- throw new ConfigException(msg, e);
- }
- definitions.add(d);
- }
- }
-
- // Initialize any definitions that were loaded.
- for (AbstractManagedObjectDefinition<?, ?> d : definitions) {
- try {
- d.initialize();
- } catch (Exception e) {
- LocalizableMessage msg =
- ERR_CLASS_LOADER_CANNOT_INITIALIZE_DEFN.get(d.getName(), d.getClass().getName(),
- String.valueOf(e.getMessage()));
- throw new ConfigException(msg, e);
- }
- }
- }
-
- /**
- * Load the named Jar file.
- *
- * @param jar
- * The name of the Jar file to load.
- * @return Returns the loaded Jar file.
- * @throws ConfigException
- * If the Jar file could not be loaded.
- */
- private JarFile loadJarFile(File jar) throws ConfigException {
- JarFile jarFile;
-
- try {
- // Load the extension jar file.
- jarFile = new JarFile(jar);
- } catch (Exception e) {
- debugLogger.trace("Unable to load jar file: " + jar, e);
-
- LocalizableMessage message =
- ERR_ADMIN_CANNOT_OPEN_JAR_FILE.get(jar.getName(), jar.getParent(),
- stackTraceToSingleLineString(e, true));
- throw new ConfigException(message);
- }
- return jarFile;
- }
-
-}
diff --git a/opendj-config/src/main/java/org/forgerock/opendj/config/ClassPropertyDefinition.java b/opendj-config/src/main/java/org/forgerock/opendj/config/ClassPropertyDefinition.java
index f5f1284..9f51ee9 100644
--- a/opendj-config/src/main/java/org/forgerock/opendj/config/ClassPropertyDefinition.java
+++ b/opendj-config/src/main/java/org/forgerock/opendj/config/ClassPropertyDefinition.java
@@ -43,9 +43,8 @@
* <p>
* Note that in a client/server environment, the client is probably not capable
* of validating the Java class (e.g. it will not be able to load it nor have
- * access to the interfaces it is supposed to implement). For this reason, it is
- * possible to switch off validation in the client by using the appropriate
- * {@link PropertyDefinitionsOptions}.
+ * access to the interfaces it is supposed to implement). For this reason,
+ * validation is disabled in client applications.
*/
public final class ClassPropertyDefinition extends PropertyDefinition<String> {
@@ -117,7 +116,7 @@
// Load a named class.
private static Class<?> loadClass(String className, boolean initialize) throws ClassNotFoundException {
- return Class.forName(className, initialize, ClassLoaderProvider.getInstance().getClassLoader());
+ return Class.forName(className, initialize, ConfigurationFramework.getInstance().getClassLoader());
}
// List of interfaces which property values must implement.
@@ -152,11 +151,11 @@
* {@inheritDoc}
*/
@Override
- public String decodeValue(String value, PropertyDefinitionsOptions options) {
+ public String decodeValue(String value) {
Reject.ifNull(value);
try {
- validateValue(value, options);
+ validateValue(value);
} catch (PropertyException e) {
throw PropertyException.illegalPropertyValueException(this, value, e.getCause());
}
@@ -219,7 +218,7 @@
* {@inheritDoc}
*/
@Override
- public void validateValue(String value, PropertyDefinitionsOptions options) {
+ public void validateValue(String value) {
Reject.ifNull(value);
// Always make sure the name is a valid class name.
@@ -229,7 +228,7 @@
* If additional validation is enabled then attempt to load the class
* and check the interfaces that it implements/extends.
*/
- if (options.allowClassValidation()) {
+ if (!ConfigurationFramework.getInstance().isClient()) {
validateClassInterfaces(value, false);
}
}
diff --git a/opendj-config/src/main/java/org/forgerock/opendj/config/ConfigurationFramework.java b/opendj-config/src/main/java/org/forgerock/opendj/config/ConfigurationFramework.java
new file mode 100644
index 0000000..fafe7e3
--- /dev/null
+++ b/opendj-config/src/main/java/org/forgerock/opendj/config/ConfigurationFramework.java
@@ -0,0 +1,804 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
+ * or http://forgerock.org/license/CDDLv1.0.html.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at legal-notices/CDDLv1_0.txt.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information:
+ * Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ *
+ *
+ * Copyright 2008-2009 Sun Microsystems, Inc.
+ * Portions copyright 2012-2014 ForgeRock AS.
+ */
+package org.forgerock.opendj.config;
+
+import static com.forgerock.opendj.ldap.AdminMessages.*;
+import static com.forgerock.opendj.ldap.ExtensionMessages.NOTE_LOG_EXTENSION_INFORMATION;
+import static com.forgerock.opendj.util.StaticUtils.EOL;
+import static com.forgerock.opendj.util.StaticUtils.stackTraceToSingleLineString;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.PrintStream;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+import java.util.jar.Attributes;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+
+import org.forgerock.i18n.LocalizableMessage;
+import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.forgerock.opendj.config.server.ConfigException;
+import org.forgerock.opendj.server.config.meta.RootCfgDefn;
+import org.forgerock.util.Reject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.forgerock.opendj.ldap.AdminMessages;
+
+/**
+ * This class is responsible for managing the configuration framework including:
+ * <ul>
+ * <li>loading core components during application initialization
+ * <li>loading extensions during and after application initialization
+ * <li>changing the property validation strategy based on whether the
+ * application is a client or server.
+ * </ul>
+ * This class defines a class loader which will be used for loading components.
+ * For extensions which define their own extended configuration definitions, the
+ * class loader will make sure that the configuration definition classes are
+ * loaded and initialized.
+ * <p>
+ * Initially the configuration framework is disabled, and calls to the
+ * {@link #getClassLoader()} will return the system default class loader.
+ * <p>
+ * Applications <b>MUST NOT</b> maintain persistent references to the class
+ * loader as it can change at run-time.
+ */
+public final class ConfigurationFramework {
+ /**
+ * Private URLClassLoader implementation. This is only required so that we
+ * can provide access to the addURL method.
+ */
+ private static final class MyURLClassLoader extends URLClassLoader {
+
+ /**
+ * Create a class loader with the default parent class loader.
+ */
+ public MyURLClassLoader() {
+ super(new URL[0]);
+ }
+
+ /**
+ * Create a class loader with the provided parent class loader.
+ *
+ * @param parent
+ * The parent class loader.
+ */
+ public MyURLClassLoader(final ClassLoader parent) {
+ super(new URL[0], parent);
+ }
+
+ /**
+ * Add a Jar file to this class loader.
+ *
+ * @param jarFile
+ * The name of the Jar file.
+ * @throws MalformedURLException
+ * If a protocol handler for the URL could not be found, or
+ * if some other error occurred while constructing the URL.
+ * @throws SecurityException
+ * If a required system property value cannot be accessed.
+ */
+ public void addJarFile(final File jarFile) throws MalformedURLException {
+ addURL(jarFile.toURI().toURL());
+ }
+
+ }
+
+ private static final String MANIFEST =
+ "META-INF/services/org.forgerock.opendj.config.AbstractManagedObjectDefinition";
+
+ private static final LocalizedLogger adminLogger = LocalizedLogger
+ .getLocalizedLogger(AdminMessages.resourceName());
+ private static final Logger debugLogger = LoggerFactory.getLogger(ConfigurationFramework.class);
+
+ // The name of the lib directory.
+ private static final String LIB_DIR = "lib";
+
+ // The name of the extensions directory.
+ private static final String EXTENSIONS_DIR = "extensions";
+
+ // The singleton instance.
+ private static final ConfigurationFramework INSTANCE = new ConfigurationFramework();
+
+ // Attribute name in jar's MANIFEST corresponding to the revision number.
+ private static final String REVISION_NUMBER = "Revision-Number";
+
+ // The attribute names for build information is name, version and revision
+ // number
+ private static final String[] BUILD_INFORMATION_ATTRIBUTE_NAMES = new String[] {
+ Attributes.Name.EXTENSION_NAME.toString(),
+ Attributes.Name.IMPLEMENTATION_VERSION.toString(), REVISION_NUMBER };
+
+ /**
+ * Returns the single application wide configuration framework instance.
+ *
+ * @return The single application wide configuration framework instance.
+ */
+ public static ConfigurationFramework getInstance() {
+ return INSTANCE;
+ }
+
+ // Set of registered Jar files.
+ private Set<File> jarFiles = new HashSet<File>();
+
+ // Underlying class loader used to load classes and resources (null
+ // if disabled).
+ //
+ // We contain a reference to the URLClassLoader rather than
+ // sub-class it so that it is possible to replace the loader at
+ // run-time. For example, when removing or replacing extension Jar
+ // files (the URLClassLoader only supports adding new
+ // URLs, not removal).
+ private MyURLClassLoader loader = null;
+
+ private boolean isClient = true;
+ private String installPath;
+ private String instancePath;
+ private ClassLoader parent;
+
+ // Private constructor.
+ private ConfigurationFramework() {
+ // No implementation required.
+ }
+
+ /**
+ * Loads the named extensions into the configuration framework.
+ *
+ * @param extensions
+ * The names of the extensions to be loaded. The names should not
+ * contain any path elements and must be located within the
+ * extensions folder.
+ * @throws ConfigException
+ * If one of the extensions could not be loaded and initialized.
+ * @throws IllegalStateException
+ * If the configuration framework has not yet been initialized.
+ * @throws IllegalArgumentException
+ * If one of the extension names was not a single relative path
+ * name element or was an absolute path.
+ */
+ public synchronized void addExtension(final String... extensions) throws ConfigException {
+ Reject.ifNull(extensions);
+ ensureInitialized();
+
+ final File libPath = new File(instancePath, LIB_DIR);
+ final File extensionsPath = new File(libPath, EXTENSIONS_DIR);
+
+ final ArrayList<File> files = new ArrayList<File>(extensions.length);
+ for (final String extension : extensions) {
+ final File file = new File(extensionsPath, extension);
+
+ // For security reasons we need to make sure that the file name
+ // passed in did not contain any path elements and names a file
+ // in the extensions folder.
+
+ // Can handle potential null parent.
+ if (!extensionsPath.equals(file.getParentFile())) {
+ throw new IllegalArgumentException("Illegal file name: " + extension);
+ }
+
+ // The file is valid.
+ files.add(file);
+ }
+
+ // Add the extensions.
+ addExtension(files.toArray(new File[files.size()]));
+ }
+
+ /**
+ * Returns the class loader which should be used for loading classes and
+ * resources. When this configuration framework is disabled, the system
+ * default class loader will be returned by default.
+ * <p>
+ * Applications <b>MUST NOT</b> maintain persistent references to the class
+ * loader as it can change at run-time.
+ *
+ * @return Returns the class loader which should be used for loading classes
+ * and resources.
+ */
+ public synchronized ClassLoader getClassLoader() {
+ if (loader != null) {
+ return loader;
+ } else {
+ return ClassLoader.getSystemClassLoader();
+ }
+ }
+
+ /**
+ * Initializes the configuration framework using the application's class
+ * loader as the parent class loader, and the current working directory as
+ * the install and instance path.
+ *
+ * @return The configuration framework.
+ * @throws ConfigException
+ * If the configuration framework could not initialize
+ * successfully.
+ * @throws IllegalStateException
+ * If the configuration framework has already been initialized.
+ */
+ public ConfigurationFramework initialize() throws ConfigException {
+ return initialize(null);
+ }
+
+ /**
+ * Initializes the configuration framework using the application's class
+ * loader as the parent class loader, and the provided install/instance
+ * path.
+ *
+ * @param installAndInstancePath
+ * The path where application binaries and data are located.
+ * @return The configuration framework.
+ * @throws ConfigException
+ * If the configuration framework could not initialize
+ * successfully.
+ * @throws IllegalStateException
+ * If the configuration framework has already been initialized.
+ */
+ public ConfigurationFramework initialize(final String installAndInstancePath)
+ throws ConfigException {
+ return initialize(installAndInstancePath, installAndInstancePath);
+ }
+
+ /**
+ * Initializes the configuration framework using the application's class
+ * loader as the parent class loader, and the provided install and instance
+ * paths.
+ *
+ * @param installPath
+ * The path where application binaries are located.
+ * @param instancePath
+ * The path where application data are located.
+ * @return The configuration framework.
+ * @throws ConfigException
+ * If the configuration framework could not initialize
+ * successfully.
+ * @throws IllegalStateException
+ * If the configuration framework has already been initialized.
+ */
+ public ConfigurationFramework initialize(final String installPath, final String instancePath)
+ throws ConfigException {
+ return initialize(installPath, instancePath, RootCfgDefn.class.getClassLoader());
+ }
+
+ /**
+ * Initializes the configuration framework using the provided parent class
+ * loader and install and instance paths.
+ *
+ * @param installPath
+ * The path where application binaries are located.
+ * @param instancePath
+ * The path where application data are located.
+ * @param parent
+ * The parent class loader.
+ * @return The configuration framework.
+ * @throws ConfigException
+ * If the configuration framework could not initialize
+ * successfully.
+ * @throws IllegalStateException
+ * If the configuration framework has already been initialized.
+ */
+ public synchronized ConfigurationFramework initialize(final String installPath,
+ final String instancePath, final ClassLoader parent) throws ConfigException {
+ if (loader != null) {
+ throw new IllegalStateException("configuration framework already initialized.");
+ }
+ this.installPath = installPath == null ? System.getProperty("user.dir") : installPath;
+ this.instancePath = instancePath == null ? installPath : instancePath;
+ this.parent = parent;
+ initialize0();
+ return this;
+ }
+
+ /**
+ * Returns {@code true} if the configuration framework is being used within
+ * a client application. Client applications will perform less property
+ * value validation than server applications because they do not have
+ * resources available such as the server schema.
+ *
+ * @return {@code true} if the configuration framework is being used within
+ * a client application.
+ */
+ public boolean isClient() {
+ return isClient;
+ }
+
+ /**
+ * Returns {@code true} if the configuration framework has been enabled.
+ *
+ * @return {@code true} if the configuration framework has been enabled.
+ */
+ public synchronized boolean isEnabled() {
+ return loader != null;
+ }
+
+ /**
+ * Prints out all information about extensions.
+ *
+ * @return A string representing all information about extensions;
+ * <code>null</code> if there is no information available.
+ */
+ public String printExtensionInformation() {
+ final File extensionsPath =
+ new File(new StringBuilder(installPath).append(File.separator).append(LIB_DIR)
+ .append(File.separator).append(EXTENSIONS_DIR).toString());
+
+ if (!extensionsPath.exists() || !extensionsPath.isDirectory()) {
+ // no extensions' directory
+ return null;
+ }
+
+ final File[] extensions = extensionsPath.listFiles(new FileFilter() {
+ @Override
+ public boolean accept(final File pathname) {
+ // only files with names ending with ".jar"
+ return pathname.isFile() && pathname.getName().endsWith(".jar");
+ }
+ });
+
+ if (extensions.length == 0) {
+ return null;
+ }
+
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ final PrintStream ps = new PrintStream(baos);
+ // prints:
+ // --
+ // Name Build number Revision number
+ ps.printf("--%s %-20s %-20s %-20s%s", EOL, "Name", "Build number",
+ "Revision number", EOL);
+
+ for (final File extension : extensions) {
+ // retrieve MANIFEST entry and display name, build number and
+ // revision number
+ try {
+ final JarFile jarFile = new JarFile(extension);
+ final JarEntry entry = jarFile.getJarEntry(MANIFEST);
+ if (entry == null) {
+ continue;
+ }
+
+ final String[] information = getBuildInformation(jarFile);
+
+ ps.append("Extension: ");
+ boolean addBlank = false;
+ for (final String name : information) {
+ if (addBlank) {
+ ps.append(addBlank ? " " : ""); // add blank if not
+ // first append
+ } else {
+ addBlank = true;
+ }
+
+ ps.printf("%-20s", name);
+ }
+ ps.append(EOL);
+ } catch (final Exception e) {
+ // ignore extra information for this extension
+ }
+ }
+
+ return baos.toString();
+ }
+
+ /**
+ * Reloads the configuration framework.
+ *
+ * @throws ConfigException
+ * If the configuration framework could not initialize
+ * successfully.
+ * @throws IllegalStateException
+ * If the configuration framework has not yet been initialized.
+ */
+ public synchronized void reload() throws ConfigException {
+ ensureInitialized();
+ loader = null;
+ jarFiles = new HashSet<File>();
+ initialize0();
+ }
+
+ /**
+ * Specifies whether or not the configuration framework is being used within
+ * a client application. Client applications will perform less property
+ * value validation than server applications because they do not have
+ * resources available such as the server schema.
+ *
+ * @param isClient
+ * {@code true} if the configuration framework is being used
+ * within a client application.
+ * @return The configuration framework.
+ */
+ public ConfigurationFramework setIsClient(final boolean isClient) {
+ this.isClient = isClient;
+ return this;
+ }
+
+ private void addExtension(final File... extensions) throws ConfigException {
+ // First add the Jar files to the class loader.
+ final List<JarFile> jars = new LinkedList<JarFile>();
+ for (final File extension : extensions) {
+ if (jarFiles.contains(extension)) {
+ // Skip this file as it is already loaded.
+ continue;
+ }
+
+ // Attempt to load it.
+ jars.add(loadJarFile(extension));
+
+ // Register the Jar file with the class loader.
+ try {
+ loader.addJarFile(extension);
+ } catch (final Exception e) {
+ debugLogger.trace("Unable to register the jar file with the class loader", e);
+ final LocalizableMessage message =
+ ERR_ADMIN_CANNOT_OPEN_JAR_FILE.get(extension.getName(), extension
+ .getParent(), stackTraceToSingleLineString(e, true));
+ throw new ConfigException(message);
+ }
+ jarFiles.add(extension);
+ }
+
+ // Now forcefully load the configuration definition classes.
+ for (final JarFile jar : jars) {
+ initializeExtension(jar);
+ }
+ }
+
+ private void ensureInitialized() {
+ if (loader == null) {
+ throw new IllegalStateException("configuration framework is disabled.");
+ }
+ }
+
+ /**
+ * Returns a String array with the following information : <br>
+ * index 0: the name of the extension. <br>
+ * index 1: the build number of the extension. <br>
+ * index 2: the revision number of the extension.
+ *
+ * @param extension
+ * the jar file of the extension
+ * @return a String array containing the name, the build number and the
+ * revision number of the extension given in argument
+ * @throws java.io.IOException
+ * thrown if the jar file has been closed.
+ */
+ private String[] getBuildInformation(final JarFile extension) throws IOException {
+ final String[] result = new String[3];
+
+ // retrieve MANIFEST entry and display name, version and revision
+ final Manifest manifest = extension.getManifest();
+
+ if (manifest != null) {
+ final Attributes attributes = manifest.getMainAttributes();
+
+ int index = 0;
+ for (final String name : BUILD_INFORMATION_ATTRIBUTE_NAMES) {
+ String value = attributes.getValue(name);
+ if (value == null) {
+ value = "<unknown>";
+ }
+ result[index++] = value;
+ }
+ }
+
+ return result;
+ }
+
+ private void initialize0() throws ConfigException {
+ if (parent != null) {
+ loader = new MyURLClassLoader(parent);
+ } else {
+ loader = new MyURLClassLoader();
+ }
+
+ // Forcefully load all configuration definition classes in
+ // OpenDS.jar.
+ initializeCoreComponents();
+
+ // Put extensions jars into the class loader and load all
+ // configuration definition classes in that they contain.
+ // First load the extension from the install directory, then
+ // from the instance directory.
+ File libDir;
+ File installExtensionsPath;
+ File instanceExtensionsPath;
+
+ // load install dir extension
+ libDir = new File(installPath, LIB_DIR);
+ try {
+ installExtensionsPath = new File(libDir, EXTENSIONS_DIR).getCanonicalFile();
+ } catch (final Exception e) {
+ installExtensionsPath = new File(libDir, EXTENSIONS_DIR);
+ }
+ initializeAllExtensions(installExtensionsPath);
+
+ // load instance dir extension
+ libDir = new File(instancePath, LIB_DIR);
+ try {
+ instanceExtensionsPath = new File(libDir, EXTENSIONS_DIR).getCanonicalFile();
+ } catch (final Exception e) {
+ instanceExtensionsPath = new File(libDir, EXTENSIONS_DIR);
+ }
+ if (!installExtensionsPath.getAbsolutePath().equals(
+ instanceExtensionsPath.getAbsolutePath())) {
+ initializeAllExtensions(instanceExtensionsPath);
+ }
+ }
+
+ /**
+ * Put extensions jars into the class loader and load all configuration
+ * definition classes in that they contain.
+ *
+ * @param extensionsPath
+ * Indicates where extensions are located.
+ * @throws ConfigException
+ * If the extensions folder could not be accessed or if a
+ * extension jar file could not be accessed or if one of the
+ * configuration definition classes could not be initialized.
+ */
+ private void initializeAllExtensions(final File extensionsPath) throws ConfigException {
+ try {
+ if (!extensionsPath.exists()) {
+ // The extensions directory does not exist. This is not a
+ // critical problem.
+ adminLogger.error(ERR_ADMIN_NO_EXTENSIONS_DIR, String.valueOf(extensionsPath));
+ return;
+ }
+
+ if (!extensionsPath.isDirectory()) {
+ // The extensions directory is not a directory. This is more
+ // critical.
+ final LocalizableMessage message =
+ ERR_ADMIN_EXTENSIONS_DIR_NOT_DIRECTORY.get(String.valueOf(extensionsPath));
+ throw new ConfigException(message);
+ }
+
+ // Get each extension file name.
+ final FileFilter filter = new FileFilter() {
+
+ /**
+ * Must be a Jar file.
+ */
+ @Override
+ public boolean accept(final File pathname) {
+ if (!pathname.isFile()) {
+ return false;
+ }
+
+ final String name = pathname.getName();
+ return name.endsWith(".jar");
+ }
+
+ };
+
+ // Add and initialize the extensions.
+ addExtension(extensionsPath.listFiles(filter));
+ } catch (final ConfigException e) {
+ debugLogger.trace("Unable to initialize all extensions", e);
+ throw e;
+ } catch (final Exception e) {
+ debugLogger.trace("Unable to initialize all extensions", e);
+ final LocalizableMessage message =
+ ERR_ADMIN_EXTENSIONS_CANNOT_LIST_FILES.get(String.valueOf(extensionsPath),
+ stackTraceToSingleLineString(e, true));
+ throw new ConfigException(message, e);
+ }
+ }
+
+ /**
+ * Make sure all core configuration definitions are loaded.
+ *
+ * @throws ConfigException
+ * If the core manifest file could not be read or if one of the
+ * configuration definition classes could not be initialized.
+ */
+ private void initializeCoreComponents() throws ConfigException {
+ final InputStream is = RootCfgDefn.class.getResourceAsStream(MANIFEST);
+ if (is == null) {
+ final LocalizableMessage message = ERR_ADMIN_CANNOT_FIND_CORE_MANIFEST.get(MANIFEST);
+ throw new ConfigException(message);
+ }
+ try {
+ loadDefinitionClasses(is);
+ } catch (final ConfigException e) {
+ debugLogger.trace("Unable to initialize core components", e);
+ final LocalizableMessage message =
+ ERR_CLASS_LOADER_CANNOT_LOAD_CORE.get(MANIFEST, stackTraceToSingleLineString(e,
+ true));
+ throw new ConfigException(message);
+ }
+ }
+
+ /**
+ * Make sure all the configuration definition classes in a extension are
+ * loaded.
+ *
+ * @param jarFile
+ * The extension's Jar file.
+ * @throws ConfigException
+ * If the extension jar file could not be accessed or if one of
+ * the configuration definition classes could not be
+ * initialized.
+ */
+ private void initializeExtension(final JarFile jarFile) throws ConfigException {
+ final JarEntry entry = jarFile.getJarEntry(MANIFEST);
+ if (entry != null) {
+ InputStream is;
+ try {
+ is = jarFile.getInputStream(entry);
+ } catch (final Exception e) {
+ debugLogger.trace("Unable to get input stream from jar", e);
+ final LocalizableMessage message =
+ ERR_ADMIN_CANNOT_READ_EXTENSION_MANIFEST.get(MANIFEST, jarFile.getName(),
+ stackTraceToSingleLineString(e, true));
+ throw new ConfigException(message);
+ }
+
+ try {
+ loadDefinitionClasses(is);
+ } catch (final ConfigException e) {
+ debugLogger.trace("Unable to load classes from input stream", e);
+ final LocalizableMessage message =
+ ERR_CLASS_LOADER_CANNOT_LOAD_EXTENSION.get(jarFile.getName(), MANIFEST,
+ stackTraceToSingleLineString(e, true));
+ throw new ConfigException(message);
+ }
+ try {
+ // Log build information of extensions in the error log
+ final String[] information = getBuildInformation(jarFile);
+ final LocalizableMessage message =
+ NOTE_LOG_EXTENSION_INFORMATION.get(jarFile.getName(), information[1],
+ information[2]);
+ LocalizedLogger.getLocalizedLogger(message.resourceName()).error(message);
+ } catch (final Exception e) {
+ // Do not log information for that extension
+ }
+ }
+ }
+
+ /**
+ * Forcefully load configuration definition classes named in a manifest
+ * file.
+ *
+ * @param is
+ * The manifest file input stream.
+ * @throws ConfigException
+ * If the definition classes could not be loaded and
+ * initialized.
+ */
+ private void loadDefinitionClasses(final InputStream is) throws ConfigException {
+ final BufferedReader reader = new BufferedReader(new InputStreamReader(is));
+ final List<AbstractManagedObjectDefinition<?, ?>> definitions =
+ new LinkedList<AbstractManagedObjectDefinition<?, ?>>();
+ while (true) {
+ String className;
+ try {
+ className = reader.readLine();
+ } catch (final IOException e) {
+ final LocalizableMessage msg =
+ ERR_CLASS_LOADER_CANNOT_READ_MANIFEST_FILE.get(String.valueOf(e
+ .getMessage()));
+ throw new ConfigException(msg, e);
+ }
+
+ // Break out when the end of the manifest is reached.
+ if (className == null) {
+ break;
+ }
+
+ // Skip blank lines.
+ className = className.trim();
+ if (className.length() == 0) {
+ continue;
+ }
+
+ // Skip lines beginning with #.
+ if (className.startsWith("#")) {
+ continue;
+ }
+
+ debugLogger.trace("Loading class " + className);
+
+ // Load the class and get an instance of it if it is a definition.
+ Class<?> theClass;
+ try {
+ theClass = Class.forName(className, true, loader);
+ } catch (final Exception e) {
+ final LocalizableMessage msg =
+ ERR_CLASS_LOADER_CANNOT_LOAD_CLASS.get(className, String.valueOf(e
+ .getMessage()));
+ throw new ConfigException(msg, e);
+ }
+ if (AbstractManagedObjectDefinition.class.isAssignableFrom(theClass)) {
+ // We need to instantiate it using its getInstance() static
+ // method.
+ Method method;
+ try {
+ method = theClass.getMethod("getInstance");
+ } catch (final Exception e) {
+ final LocalizableMessage msg =
+ ERR_CLASS_LOADER_CANNOT_FIND_GET_INSTANCE_METHOD.get(className, String
+ .valueOf(e.getMessage()));
+ throw new ConfigException(msg, e);
+ }
+
+ // Get the definition instance.
+ AbstractManagedObjectDefinition<?, ?> d;
+ try {
+ d = (AbstractManagedObjectDefinition<?, ?>) method.invoke(null);
+ } catch (final Exception e) {
+ final LocalizableMessage msg =
+ ERR_CLASS_LOADER_CANNOT_INVOKE_GET_INSTANCE_METHOD.get(className,
+ String.valueOf(e.getMessage()));
+ throw new ConfigException(msg, e);
+ }
+ definitions.add(d);
+ }
+ }
+
+ // Initialize any definitions that were loaded.
+ for (final AbstractManagedObjectDefinition<?, ?> d : definitions) {
+ try {
+ d.initialize();
+ } catch (final Exception e) {
+ final LocalizableMessage msg =
+ ERR_CLASS_LOADER_CANNOT_INITIALIZE_DEFN.get(d.getName(), d.getClass()
+ .getName(), String.valueOf(e.getMessage()));
+ throw new ConfigException(msg, e);
+ }
+ }
+ }
+
+ private JarFile loadJarFile(final File jar) throws ConfigException {
+ try {
+ // Load the extension jar file.
+ return new JarFile(jar);
+ } catch (final Exception e) {
+ debugLogger.trace("Unable to load jar file: " + jar, e);
+
+ final LocalizableMessage message =
+ ERR_ADMIN_CANNOT_OPEN_JAR_FILE.get(jar.getName(), jar.getParent(),
+ stackTraceToSingleLineString(e, true));
+ throw new ConfigException(message);
+ }
+ }
+
+}
diff --git a/opendj-config/src/main/java/org/forgerock/opendj/config/DNPropertyDefinition.java b/opendj-config/src/main/java/org/forgerock/opendj/config/DNPropertyDefinition.java
index 39c76b5..9ce7c5c 100644
--- a/opendj-config/src/main/java/org/forgerock/opendj/config/DNPropertyDefinition.java
+++ b/opendj-config/src/main/java/org/forgerock/opendj/config/DNPropertyDefinition.java
@@ -134,7 +134,7 @@
* {@inheritDoc}
*/
@Override
- public void validateValue(DN value, PropertyDefinitionsOptions options) {
+ public void validateValue(DN value) {
Reject.ifNull(value);
if (baseDN != null) {
@@ -154,12 +154,12 @@
* {@inheritDoc}
*/
@Override
- public DN decodeValue(String value, PropertyDefinitionsOptions options) {
+ public DN decodeValue(String value) {
Reject.ifNull(value);
try {
DN dn = DN.valueOf(value);
- validateValue(dn, options);
+ validateValue(dn);
return dn;
} catch (PropertyException e) {
throw PropertyException.illegalPropertyValueException(this, value);
diff --git a/opendj-config/src/main/java/org/forgerock/opendj/config/DefaultManagedObject.java b/opendj-config/src/main/java/org/forgerock/opendj/config/DefaultManagedObject.java
index 247c132..e0d4015 100644
--- a/opendj-config/src/main/java/org/forgerock/opendj/config/DefaultManagedObject.java
+++ b/opendj-config/src/main/java/org/forgerock/opendj/config/DefaultManagedObject.java
@@ -147,7 +147,7 @@
if (stringValues != null) {
for (String stringValue : stringValues) {
// TODO : is it correct to have no validation ?
- values.add(pd.decodeValue(stringValue, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS));
+ values.add(pd.decodeValue(stringValue));
}
}
return values;
diff --git a/opendj-config/src/main/java/org/forgerock/opendj/config/DurationPropertyDefinition.java b/opendj-config/src/main/java/org/forgerock/opendj/config/DurationPropertyDefinition.java
index 245bff8..0318fe9 100644
--- a/opendj-config/src/main/java/org/forgerock/opendj/config/DurationPropertyDefinition.java
+++ b/opendj-config/src/main/java/org/forgerock/opendj/config/DurationPropertyDefinition.java
@@ -392,7 +392,7 @@
* {@inheritDoc}
*/
@Override
- public void validateValue(Long value, PropertyDefinitionsOptions options) {
+ public void validateValue(Long value) {
Reject.ifNull(value);
long nvalue = baseUnit.toMilliSeconds(value);
@@ -436,7 +436,7 @@
* {@inheritDoc}
*/
@Override
- public Long decodeValue(String value, PropertyDefinitionsOptions options) {
+ public Long decodeValue(String value) {
Reject.ifNull(value);
// First check for the special "unlimited" value when necessary.
@@ -463,7 +463,7 @@
// Convert the value a long in the property's required unit.
Long i = (long) baseUnit.fromMilliSeconds(ms);
try {
- validateValue(i, options);
+ validateValue(i);
} catch (PropertyException e) {
throw PropertyException.illegalPropertyValueException(this, value);
}
diff --git a/opendj-config/src/main/java/org/forgerock/opendj/config/EnumPropertyDefinition.java b/opendj-config/src/main/java/org/forgerock/opendj/config/EnumPropertyDefinition.java
index 07af2c7..01405aa 100644
--- a/opendj-config/src/main/java/org/forgerock/opendj/config/EnumPropertyDefinition.java
+++ b/opendj-config/src/main/java/org/forgerock/opendj/config/EnumPropertyDefinition.java
@@ -150,7 +150,7 @@
* {@inheritDoc}
*/
@Override
- public E decodeValue(String value, PropertyDefinitionsOptions options) {
+ public E decodeValue(String value) {
Reject.ifNull(value);
String nvalue = value.trim().toLowerCase();
@@ -219,7 +219,7 @@
* {@inheritDoc}
*/
@Override
- public void validateValue(E value, PropertyDefinitionsOptions options) {
+ public void validateValue(E value) {
Reject.ifNull(value);
// No additional validation required.
diff --git a/opendj-config/src/main/java/org/forgerock/opendj/config/IPAddressMaskPropertyDefinition.java b/opendj-config/src/main/java/org/forgerock/opendj/config/IPAddressMaskPropertyDefinition.java
index b2ad5fb..e6b8c30 100644
--- a/opendj-config/src/main/java/org/forgerock/opendj/config/IPAddressMaskPropertyDefinition.java
+++ b/opendj-config/src/main/java/org/forgerock/opendj/config/IPAddressMaskPropertyDefinition.java
@@ -86,7 +86,7 @@
* {@inheritDoc}
*/
@Override
- public void validateValue(AddressMask value, PropertyDefinitionsOptions options) {
+ public void validateValue(AddressMask value) {
Reject.ifNull(value);
// No additional validation required.
@@ -96,7 +96,7 @@
* {@inheritDoc}
*/
@Override
- public AddressMask decodeValue(String value, PropertyDefinitionsOptions options) {
+ public AddressMask decodeValue(String value) {
Reject.ifNull(value);
try {
diff --git a/opendj-config/src/main/java/org/forgerock/opendj/config/IPAddressPropertyDefinition.java b/opendj-config/src/main/java/org/forgerock/opendj/config/IPAddressPropertyDefinition.java
index 4c7b551..3b06b5c 100644
--- a/opendj-config/src/main/java/org/forgerock/opendj/config/IPAddressPropertyDefinition.java
+++ b/opendj-config/src/main/java/org/forgerock/opendj/config/IPAddressPropertyDefinition.java
@@ -85,7 +85,7 @@
* {@inheritDoc}
*/
@Override
- public void validateValue(InetAddress value, PropertyDefinitionsOptions options) {
+ public void validateValue(InetAddress value) {
Reject.ifNull(value);
// No additional validation required.
@@ -95,7 +95,7 @@
* {@inheritDoc}
*/
@Override
- public InetAddress decodeValue(String value, PropertyDefinitionsOptions options) {
+ public InetAddress decodeValue(String value) {
Reject.ifNull(value);
try {
diff --git a/opendj-config/src/main/java/org/forgerock/opendj/config/IntegerPropertyDefinition.java b/opendj-config/src/main/java/org/forgerock/opendj/config/IntegerPropertyDefinition.java
index 9924207..8d2afc4 100644
--- a/opendj-config/src/main/java/org/forgerock/opendj/config/IntegerPropertyDefinition.java
+++ b/opendj-config/src/main/java/org/forgerock/opendj/config/IntegerPropertyDefinition.java
@@ -229,7 +229,7 @@
* {@inheritDoc}
*/
@Override
- public void validateValue(Integer value, PropertyDefinitionsOptions options) {
+ public void validateValue(Integer value) {
Reject.ifNull(value);
if (!allowUnlimited && value < lowerLimit) {
@@ -266,7 +266,7 @@
* {@inheritDoc}
*/
@Override
- public Integer decodeValue(String value, PropertyDefinitionsOptions options) {
+ public Integer decodeValue(String value) {
Reject.ifNull(value);
if (allowUnlimited) {
@@ -283,7 +283,7 @@
}
try {
- validateValue(i, options);
+ validateValue(i);
} catch (PropertyException e) {
throw PropertyException.illegalPropertyValueException(this, value);
}
diff --git a/opendj-config/src/main/java/org/forgerock/opendj/config/ManagedObjectDefinitionI18NResource.java b/opendj-config/src/main/java/org/forgerock/opendj/config/ManagedObjectDefinitionI18NResource.java
index 6d4a132..fca5190 100644
--- a/opendj-config/src/main/java/org/forgerock/opendj/config/ManagedObjectDefinitionI18NResource.java
+++ b/opendj-config/src/main/java/org/forgerock/opendj/config/ManagedObjectDefinitionI18NResource.java
@@ -282,7 +282,7 @@
if (resourceBundle == null) {
String baseName = prefix + "." + d.getClass().getName();
resourceBundle =
- ResourceBundle.getBundle(baseName, locale, ClassLoaderProvider.getInstance().getClassLoader());
+ ResourceBundle.getBundle(baseName, locale, ConfigurationFramework.getInstance().getClassLoader());
map.put(locale, resourceBundle);
}
diff --git a/opendj-config/src/main/java/org/forgerock/opendj/config/ManagedObjectDefinitionResource.java b/opendj-config/src/main/java/org/forgerock/opendj/config/ManagedObjectDefinitionResource.java
index 630336b..f434ce3 100644
--- a/opendj-config/src/main/java/org/forgerock/opendj/config/ManagedObjectDefinitionResource.java
+++ b/opendj-config/src/main/java/org/forgerock/opendj/config/ManagedObjectDefinitionResource.java
@@ -110,7 +110,7 @@
// Load the resource file.
String baseName = prefix + "." + d.getClass().getName();
String path = baseName.replace('.', '/') + ".properties";
- InputStream stream = ClassLoaderProvider.getInstance().getClassLoader().getResourceAsStream(path);
+ InputStream stream = ConfigurationFramework.getInstance().getClassLoader().getResourceAsStream(path);
if (stream == null) {
throw new MissingResourceException("Can't find resource " + path, baseName, "");
diff --git a/opendj-config/src/main/java/org/forgerock/opendj/config/ManagedObjectPath.java b/opendj-config/src/main/java/org/forgerock/opendj/config/ManagedObjectPath.java
index f319ee7..1e6645a 100644
--- a/opendj-config/src/main/java/org/forgerock/opendj/config/ManagedObjectPath.java
+++ b/opendj-config/src/main/java/org/forgerock/opendj/config/ManagedObjectPath.java
@@ -39,7 +39,7 @@
import org.forgerock.opendj.ldap.DN;
import org.forgerock.opendj.ldap.RDN;
import org.forgerock.opendj.ldap.schema.AttributeType;
-import org.opends.server.core.DirectoryServer;
+import org.forgerock.opendj.ldap.schema.Schema;
/**
* A path which can be used to determine the location of a managed object
@@ -140,7 +140,7 @@
// Now add the single RDN representing the named instance.
String type = profile.getRelationChildRDNType(r);
- AttributeType attrType = DirectoryServer.getAttributeType(type.toLowerCase(), true);
+ AttributeType attrType = Schema.getDefaultSchema().getAttributeType(type);
dn = dn.child(new RDN(attrType, name));
}
@@ -154,7 +154,7 @@
// Now add the single RDN representing the instance.
String type = profile.getRelationChildRDNType(r);
- AttributeType attrType = DirectoryServer.getAttributeType(type.toLowerCase(), true);
+ AttributeType attrType = Schema.getDefaultSchema().getAttributeType(type);
dn = dn.child(new RDN(attrType, d.getName()));
}
diff --git a/opendj-config/src/main/java/org/forgerock/opendj/config/PropertyDefinition.java b/opendj-config/src/main/java/org/forgerock/opendj/config/PropertyDefinition.java
index e0d30fd..4ec9ec1 100644
--- a/opendj-config/src/main/java/org/forgerock/opendj/config/PropertyDefinition.java
+++ b/opendj-config/src/main/java/org/forgerock/opendj/config/PropertyDefinition.java
@@ -244,7 +244,7 @@
* <p>
* This method only casts the object to the required type; it does not
* validate the value once it has been cast. Subsequent validation should be
- * performed using the method {@link #validateValue(Object, PropertyDefinitionsOptions)}.
+ * performed using the method {@link #validateValue(Object)}.
* <p>
* This method guarantees the following expression is always
* <code>true</code>:
@@ -318,13 +318,11 @@
*
* @param value
* The property string value (must not be <code>null</code>).
- * @param options
- * Options to use when decoding value.
* @return Returns the decoded property value.
* @throws PropertyException
* If the property value string is invalid.
*/
- public abstract T decodeValue(String value, PropertyDefinitionsOptions options);
+ public abstract T decodeValue(String value);
/**
* Encode the provided property value into its string representation.
@@ -510,7 +508,7 @@
* This method may throw an exception if the provided value is invalid.
* However, applications should not assume that implementations of this
* method will always validate a value. This task is the responsibility of
- * {@link #validateValue(Object, PropertyDefinitionsOptions)}.
+ * {@link #validateValue(Object)}.
* <p>
* This default implementation simply returns the string representation of
* the provided value. Sub-classes might want to override this method if
@@ -564,12 +562,10 @@
*
* @param value
* The property value (must not be <code>null</code>).
- * @param options
- * Options to use when decoding value.
* @throws PropertyException
* If the property value is invalid.
*/
- public abstract void validateValue(T value, PropertyDefinitionsOptions options);
+ public abstract void validateValue(T value);
/**
* Performs any run-time initialization required by this property
diff --git a/opendj-config/src/main/java/org/forgerock/opendj/config/PropertyDefinitionsOptions.java b/opendj-config/src/main/java/org/forgerock/opendj/config/PropertyDefinitionsOptions.java
deleted file mode 100644
index a6fed87..0000000
--- a/opendj-config/src/main/java/org/forgerock/opendj/config/PropertyDefinitionsOptions.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- * Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- * Copyright 2013 ForgeRock AS.
- */
-package org.forgerock.opendj.config;
-
-/**
- * Provides options for {@code PropertyDefinition property definitions}.
- * <p>
- * These options are used by some {@code PropertyDefinition} methods to define
- * strategy used when processing value(s) of a property definition.
- */
-public final class PropertyDefinitionsOptions {
-
- /** Immutable options with no validation of java classes or LDAP attributes. */
- public static final PropertyDefinitionsOptions NO_VALIDATION_OPTIONS = new PropertyDefinitionsOptions().
- setAllowClassValidation(false).
- setCheckSchemaForAttributes(false).
- freeze();
-
- /** By default, class validation is enabled. */
- private boolean allowClassValidation = true;
-
- /** By default, attributes validation against the schema is enabled. */
- private boolean checkSchemaForAttributes = true;
-
- /**
- * If true, then the instance is frozen so state can't be changed (object is
- * immutable).
- */
- private boolean isFrozen = false;
-
- /**
- * Creates a new set of properties options with default settings. By
- * default, class validation and attributes checking are enabled.
- */
- public PropertyDefinitionsOptions() {
- // empty implementation
- }
-
- /**
- * Determine whether or not class property definitions should validate class
- * name property values. Validation involves checking that the class exists
- * and that it implements the required interfaces.
- *
- * @return Returns <code>true</code> if class property definitions should
- * validate class name property values.
- */
- public boolean allowClassValidation() {
- return allowClassValidation;
- }
-
- /**
- * Specify whether or not class property definitions should validate class
- * name property values. Validation involves checking that the class exists
- * and that it implements the required interfaces.
- * <p>
- * By default validation is switched on.
- *
- * @param value
- * <code>true</code> if class property definitions should
- * validate class name property values.
- * @return A reference to this definitions options.
- */
- public PropertyDefinitionsOptions setAllowClassValidation(boolean value) {
- if (isFrozen) {
- throw new IllegalStateException("This object is frozen, it can't be changed");
- }
- allowClassValidation = value;
- return this;
- }
-
- /**
- * Determines whether or not attribute type names should be validated
- * against the schema.
- *
- * @return Returns <code>true</code> if attribute type names should be
- * validated against the schema.
- */
- public boolean checkSchemaForAttributes() {
- return checkSchemaForAttributes;
- }
-
- /**
- * Specify whether or not attribute type names should be validated against
- * the schema.
- * <p>
- * By default validation is switched on.
- *
- * @param value
- * <code>true</code> if attribute type names should be validated
- * against the schema.
- * @return A reference to this definitions options.
- */
- public PropertyDefinitionsOptions setCheckSchemaForAttributes(boolean value) {
- if (isFrozen) {
- throw new IllegalStateException("This object is frozen, it can't be changed");
- }
- checkSchemaForAttributes = value;
- return this;
- }
-
- /**
- * Freeze this object, making it effectively immutable.
- * <p>
- * Once this method is called, all {@code set} methods will throw
- * an IllegalStateException if called.
- *
- * @return A reference to this definitions options.
- */
- public PropertyDefinitionsOptions freeze() {
- isFrozen = true;
- return this;
- }
-
-}
diff --git a/opendj-config/src/main/java/org/forgerock/opendj/config/Reference.java b/opendj-config/src/main/java/org/forgerock/opendj/config/Reference.java
index 4f29adb..ef6d591 100644
--- a/opendj-config/src/main/java/org/forgerock/opendj/config/Reference.java
+++ b/opendj-config/src/main/java/org/forgerock/opendj/config/Reference.java
@@ -190,7 +190,7 @@
if (pd != null) {
try {
// TODO : is it correct to have no validation ?
- T tvalue = pd.decodeValue(name, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ T tvalue = pd.decodeValue(name);
return pd.normalizeValue(tvalue);
} catch (PropertyException e) {
// Fall through to default normalization.
diff --git a/opendj-config/src/main/java/org/forgerock/opendj/config/SizePropertyDefinition.java b/opendj-config/src/main/java/org/forgerock/opendj/config/SizePropertyDefinition.java
index 26d1cc7..0e38cb9 100644
--- a/opendj-config/src/main/java/org/forgerock/opendj/config/SizePropertyDefinition.java
+++ b/opendj-config/src/main/java/org/forgerock/opendj/config/SizePropertyDefinition.java
@@ -230,7 +230,7 @@
* {@inheritDoc}
*/
@Override
- public void validateValue(Long value, PropertyDefinitionsOptions options) {
+ public void validateValue(Long value) {
Reject.ifNull(value);
if (!allowUnlimited && value < lowerLimit) {
@@ -276,7 +276,7 @@
* {@inheritDoc}
*/
@Override
- public Long decodeValue(String value, PropertyDefinitionsOptions options) {
+ public Long decodeValue(String value) {
Reject.ifNull(value);
// First check for the special "unlimited" value when necessary.
@@ -295,7 +295,7 @@
}
try {
- validateValue(i, options);
+ validateValue(i);
} catch (PropertyException e) {
throw PropertyException.illegalPropertyValueException(this, value);
}
diff --git a/opendj-config/src/main/java/org/forgerock/opendj/config/StringPropertyDefinition.java b/opendj-config/src/main/java/org/forgerock/opendj/config/StringPropertyDefinition.java
index 2a4a9b0..8dc7810 100644
--- a/opendj-config/src/main/java/org/forgerock/opendj/config/StringPropertyDefinition.java
+++ b/opendj-config/src/main/java/org/forgerock/opendj/config/StringPropertyDefinition.java
@@ -170,11 +170,11 @@
* {@inheritDoc}
*/
@Override
- public String decodeValue(String value, PropertyDefinitionsOptions options) {
+ public String decodeValue(String value) {
Reject.ifNull(value);
try {
- validateValue(value, options);
+ validateValue(value);
} catch (PropertyException e) {
throw PropertyException.illegalPropertyValueException(this, value);
}
@@ -269,7 +269,7 @@
* {@inheritDoc}
*/
@Override
- public void validateValue(String value, PropertyDefinitionsOptions options) {
+ public void validateValue(String value) {
Reject.ifNull(value);
if (pattern != null) {
diff --git a/opendj-config/src/main/java/org/forgerock/opendj/config/client/IllegalManagedObjectNameException.java b/opendj-config/src/main/java/org/forgerock/opendj/config/client/IllegalManagedObjectNameException.java
index d39cc79..0b6177e 100644
--- a/opendj-config/src/main/java/org/forgerock/opendj/config/client/IllegalManagedObjectNameException.java
+++ b/opendj-config/src/main/java/org/forgerock/opendj/config/client/IllegalManagedObjectNameException.java
@@ -32,7 +32,6 @@
import org.forgerock.opendj.config.OperationsException;
import org.forgerock.opendj.config.PropertyDefinition;
import org.forgerock.opendj.config.PropertyDefinitionUsageBuilder;
-import org.forgerock.opendj.config.PropertyDefinitionsOptions;
/**
* Thrown when an attempt is made to create a new managed object with an illegal
@@ -51,19 +50,20 @@
private static final long serialVersionUID = 7491748228684293291L;
/** Create the message. */
- private static LocalizableMessage createMessage(String illegalName, PropertyDefinition<?> namingPropertyDefinition,
- PropertyDefinitionsOptions options) {
+ private static LocalizableMessage createMessage(String illegalName,
+ PropertyDefinition<?> namingPropertyDefinition) {
if (illegalName.length() == 0) {
return ERR_ILLEGAL_MANAGED_OBJECT_NAME_EXCEPTION_EMPTY.get();
} else if (illegalName.trim().length() == 0) {
return ERR_ILLEGAL_MANAGED_OBJECT_NAME_EXCEPTION_BLANK.get();
} else if (namingPropertyDefinition != null) {
try {
- namingPropertyDefinition.decodeValue(illegalName, options);
+ namingPropertyDefinition.decodeValue(illegalName);
} catch (PropertyException e) {
PropertyDefinitionUsageBuilder builder = new PropertyDefinitionUsageBuilder(true);
return ERR_ILLEGAL_MANAGED_OBJECT_NAME_EXCEPTION_SYNTAX.get(illegalName,
- namingPropertyDefinition.getName(), builder.getUsage(namingPropertyDefinition));
+ namingPropertyDefinition.getName(), builder
+ .getUsage(namingPropertyDefinition));
}
}
@@ -83,7 +83,7 @@
* The illegal managed object name.
*/
public IllegalManagedObjectNameException(String illegalName) {
- this(illegalName, null, null);
+ this(illegalName, null);
}
/**
@@ -93,12 +93,9 @@
* The illegal managed object name.
* @param namingPropertyDefinition
* The naming property definition.
- * @param options
- * Options to decode property definition values.
*/
- public IllegalManagedObjectNameException(String illegalName, PropertyDefinition<?> namingPropertyDefinition,
- PropertyDefinitionsOptions options) {
- super(createMessage(illegalName, namingPropertyDefinition, options));
+ public IllegalManagedObjectNameException(String illegalName, PropertyDefinition<?> namingPropertyDefinition) {
+ super(createMessage(illegalName, namingPropertyDefinition));
this.illegalName = illegalName;
this.namingPropertyDefinition = namingPropertyDefinition;
diff --git a/opendj-config/src/main/java/org/forgerock/opendj/config/client/ldap/LDAPDriver.java b/opendj-config/src/main/java/org/forgerock/opendj/config/client/ldap/LDAPDriver.java
index 236db07..7fa3165 100644
--- a/opendj-config/src/main/java/org/forgerock/opendj/config/client/ldap/LDAPDriver.java
+++ b/opendj-config/src/main/java/org/forgerock/opendj/config/client/ldap/LDAPDriver.java
@@ -53,7 +53,6 @@
import org.forgerock.opendj.config.ManagedObjectPath;
import org.forgerock.opendj.config.PropertyDefinition;
import org.forgerock.opendj.config.PropertyDefinitionVisitor;
-import org.forgerock.opendj.config.PropertyDefinitionsOptions;
import org.forgerock.opendj.config.PropertyOption;
import org.forgerock.opendj.config.Reference;
import org.forgerock.opendj.config.RelationDefinition;
@@ -81,9 +80,6 @@
* A visitor which is used to decode property LDAP values.
*/
private static final class ValueDecoder extends PropertyDefinitionVisitor<Object, String> {
-
- private final PropertyDefinitionsOptions options;
-
/**
* Decodes the provided property LDAP value.
*
@@ -93,21 +89,19 @@
* The property definition.
* @param value
* The LDAP string representation.
- * @param options
- * Decoding options for property definitions.
* @return Returns the decoded LDAP value.
* @throws PropertyException
* If the property value could not be decoded because it was
* invalid.
*/
- public static <P> P decode(PropertyDefinition<P> pd, Object value, PropertyDefinitionsOptions options) {
+ public static <P> P decode(PropertyDefinition<P> pd, Object value) {
String s = String.valueOf(value);
- return pd.castValue(pd.accept(new ValueDecoder(options), s));
+ return pd.castValue(pd.accept(new ValueDecoder(), s));
}
// Prevent instantiation.
- private ValueDecoder(PropertyDefinitionsOptions options) {
- this.options = options;
+ private ValueDecoder() {
+ // Do nothing.
}
/**
@@ -132,7 +126,7 @@
@Override
public <T> Object visitUnknown(PropertyDefinition<T> d, String p) {
// By default the property definition's decoder will do.
- return d.decodeValue(p, options);
+ return d.decodeValue(p);
}
}
@@ -152,11 +146,8 @@
* The LDAP connection.
* @param profile
* The LDAP profile.
- * @param propertyDefOptions
- * Options used to validate property definitions values
*/
- public LDAPDriver(LDAPConnection connection, LDAPProfile profile, PropertyDefinitionsOptions propertyDefOptions) {
- super(propertyDefOptions);
+ public LDAPDriver(LDAPConnection connection, LDAPProfile profile) {
this.connection = connection;
this.profile = profile;
}
@@ -264,10 +255,9 @@
// Decode the values.
SortedSet<P> values = new TreeSet<P>(propertyDef);
- PropertyDefinitionsOptions options = context.getPropertyDefOptions();
if (attribute != null) {
for (ByteString byteValue : attribute) {
- P value = ValueDecoder.decode(propertyDef, byteValue, options);
+ P value = ValueDecoder.decode(propertyDef, byteValue);
values.add(value);
}
}
@@ -489,10 +479,9 @@
// Get the property's active values.
SortedSet<P> activeValues = new TreeSet<P>(propertyDef);
- PropertyDefinitionsOptions options = context.getPropertyDefOptions();
if (attribute != null) {
for (ByteString byteValue : attribute) {
- P value = ValueDecoder.decode(propertyDef, byteValue, options);
+ P value = ValueDecoder.decode(propertyDef, byteValue);
activeValues.add(value);
}
}
diff --git a/opendj-config/src/main/java/org/forgerock/opendj/config/client/ldap/LDAPManagedObject.java b/opendj-config/src/main/java/org/forgerock/opendj/config/client/ldap/LDAPManagedObject.java
index 24054a8..fc46e5a 100644
--- a/opendj-config/src/main/java/org/forgerock/opendj/config/client/ldap/LDAPManagedObject.java
+++ b/opendj-config/src/main/java/org/forgerock/opendj/config/client/ldap/LDAPManagedObject.java
@@ -126,8 +126,7 @@
LDAPManagedObject(LDAPDriver driver, ManagedObjectDefinition<T, ? extends Configuration> d,
ManagedObjectPath<T, ? extends Configuration> path, PropertySet properties, boolean existsOnServer,
PropertyDefinition<?> namingPropertyDefinition) {
- super(d, path, properties, existsOnServer, namingPropertyDefinition,
- driver.getManagementContext().getPropertyDefOptions());
+ super(d, path, properties, existsOnServer, namingPropertyDefinition);
this.driver = driver;
}
diff --git a/opendj-config/src/main/java/org/forgerock/opendj/config/client/ldap/LDAPManagementContext.java b/opendj-config/src/main/java/org/forgerock/opendj/config/client/ldap/LDAPManagementContext.java
index 76ca873..784be53 100644
--- a/opendj-config/src/main/java/org/forgerock/opendj/config/client/ldap/LDAPManagementContext.java
+++ b/opendj-config/src/main/java/org/forgerock/opendj/config/client/ldap/LDAPManagementContext.java
@@ -27,7 +27,6 @@
package org.forgerock.opendj.config.client.ldap;
import org.forgerock.opendj.config.LDAPProfile;
-import org.forgerock.opendj.config.PropertyDefinitionsOptions;
import org.forgerock.opendj.config.client.ManagementContext;
import org.forgerock.opendj.config.client.spi.Driver;
import org.forgerock.util.Reject;
@@ -44,15 +43,12 @@
* The LDAP connection.
* @param profile
* The LDAP profile.
- * @param options
- * Options to decode values of property definitions.
* @return Returns the new management context.
*/
- public static ManagementContext createFromContext(LDAPConnection connection, LDAPProfile profile,
- PropertyDefinitionsOptions options) {
- Reject.ifNull(connection, profile, options);
- LDAPDriver driver = new LDAPDriver(connection, profile, options);
- LDAPManagementContext context = new LDAPManagementContext(driver, options);
+ public static ManagementContext createFromContext(LDAPConnection connection, LDAPProfile profile) {
+ Reject.ifNull(connection, profile);
+ LDAPDriver driver = new LDAPDriver(connection, profile);
+ LDAPManagementContext context = new LDAPManagementContext(driver);
driver.setManagementContext(context);
return context;
}
@@ -60,13 +56,9 @@
/** The LDAP management context driver. */
private final LDAPDriver driver;
- /** Options to validate and decode values of property definitions. */
- private final PropertyDefinitionsOptions options;
-
/** Private constructor. */
- private LDAPManagementContext(LDAPDriver driver, PropertyDefinitionsOptions options) {
+ private LDAPManagementContext(LDAPDriver driver) {
this.driver = driver;
- this.options = options;
}
/** {@inheritDoc} */
@@ -74,14 +66,4 @@
protected Driver getDriver() {
return driver;
}
-
- /**
- * Returns the property definitions options.
- *
- * @return the options to validate and decode values of property
- * definitions.
- */
- protected PropertyDefinitionsOptions getPropertyDefOptions() {
- return options;
- }
}
diff --git a/opendj-config/src/main/java/org/forgerock/opendj/config/client/spi/AbstractManagedObject.java b/opendj-config/src/main/java/org/forgerock/opendj/config/client/spi/AbstractManagedObject.java
index 4212f8c..cd328ec 100644
--- a/opendj-config/src/main/java/org/forgerock/opendj/config/client/spi/AbstractManagedObject.java
+++ b/opendj-config/src/main/java/org/forgerock/opendj/config/client/spi/AbstractManagedObject.java
@@ -48,7 +48,6 @@
import org.forgerock.opendj.config.ManagedObjectPath;
import org.forgerock.opendj.config.OptionalRelationDefinition;
import org.forgerock.opendj.config.PropertyDefinition;
-import org.forgerock.opendj.config.PropertyDefinitionsOptions;
import org.forgerock.opendj.config.PropertyOption;
import org.forgerock.opendj.config.RelationDefinition;
import org.forgerock.opendj.config.RelationDefinitionVisitor;
@@ -226,9 +225,6 @@
// The managed object's properties.
private final PropertySet properties;
- /** Decoding options for property definitions values. */
- private final PropertyDefinitionsOptions propertyDefOptions;
-
/**
* Creates a new abstract managed object.
*
@@ -244,17 +240,15 @@
* committed).
* @param namingPropertyDefinition
* Optional naming property definition.
- * @param propertyDefOptions TODO
*/
protected AbstractManagedObject(ManagedObjectDefinition<T, ? extends Configuration> d,
ManagedObjectPath<T, ? extends Configuration> path, PropertySet properties, boolean existsOnServer,
- PropertyDefinition<?> namingPropertyDefinition, PropertyDefinitionsOptions propertyDefOptions) {
+ PropertyDefinition<?> namingPropertyDefinition) {
this.definition = d;
this.path = path;
this.properties = properties;
this.existsOnServer = existsOnServer;
this.namingPropertyDefinition = namingPropertyDefinition;
- this.propertyDefOptions = propertyDefOptions;
}
/**
@@ -349,9 +343,9 @@
PropertyDefinition<?> pd = r.getNamingPropertyDefinition();
if (pd != null) {
try {
- pd.decodeValue(name, propertyDefOptions);
+ pd.decodeValue(name);
} catch (PropertyException e) {
- throw new IllegalManagedObjectNameException(name, pd, propertyDefOptions);
+ throw new IllegalManagedObjectNameException(name, pd);
}
}
@@ -667,7 +661,7 @@
throw PropertyException.propertyIsReadOnlyException(pd);
}
- properties.setPropertyValues(pd, values, propertyDefOptions);
+ properties.setPropertyValues(pd, values);
// If this is a naming property then update the name.
if (pd.equals(namingPropertyDefinition)) {
@@ -812,9 +806,8 @@
// Set the naming property if there is one.
if (namingPropertyDefinition != null) {
- P value = namingPropertyDefinition.decodeValue(name, propertyDefOptions);
- childProperties.setPropertyValues(namingPropertyDefinition, Collections.singleton(value),
- propertyDefOptions);
+ P value = namingPropertyDefinition.decodeValue(name);
+ childProperties.setPropertyValues(namingPropertyDefinition, Collections.singleton(value));
}
return newInstance(d, p, childProperties, false, namingPropertyDefinition);
diff --git a/opendj-config/src/main/java/org/forgerock/opendj/config/client/spi/Driver.java b/opendj-config/src/main/java/org/forgerock/opendj/config/client/spi/Driver.java
index 712b90b..1e68ac5 100644
--- a/opendj-config/src/main/java/org/forgerock/opendj/config/client/spi/Driver.java
+++ b/opendj-config/src/main/java/org/forgerock/opendj/config/client/spi/Driver.java
@@ -52,7 +52,6 @@
import org.forgerock.opendj.config.ManagedObjectPath;
import org.forgerock.opendj.config.OptionalRelationDefinition;
import org.forgerock.opendj.config.PropertyDefinition;
-import org.forgerock.opendj.config.PropertyDefinitionsOptions;
import org.forgerock.opendj.config.PropertyNotFoundException;
import org.forgerock.opendj.config.PropertyOption;
import org.forgerock.opendj.config.RelationDefinition;
@@ -137,7 +136,7 @@
for (String stringValue : stringValues) {
try {
- values.add(nextProperty.decodeValue(stringValue, propertyDefOptions));
+ values.add(nextProperty.decodeValue(stringValue));
} catch (PropertyException e) {
exception = PropertyException.defaultBehaviorException(nextProperty, e);
break;
@@ -227,7 +226,7 @@
Collection<T> tmp = find(target, pd2);
Collection<T> values = new ArrayList<T>(tmp.size());
for (T value : tmp) {
- pd1.validateValue(value, propertyDefOptions);
+ pd1.validateValue(value);
values.add(value);
}
return values;
@@ -253,16 +252,11 @@
}
};
- private final PropertyDefinitionsOptions propertyDefOptions;
-
/**
* Creates a new abstract driver.
- *
- * @param propertyDefOptions
- * Decoding options for property definitions values.
*/
- protected Driver(PropertyDefinitionsOptions propertyDefOptions) {
- this.propertyDefOptions = propertyDefOptions;
+ protected Driver() {
+ // Do nothing.
}
/**
diff --git a/opendj-config/src/main/java/org/forgerock/opendj/config/client/spi/PropertySet.java b/opendj-config/src/main/java/org/forgerock/opendj/config/client/spi/PropertySet.java
index 7d524e6..718cd92 100644
--- a/opendj-config/src/main/java/org/forgerock/opendj/config/client/spi/PropertySet.java
+++ b/opendj-config/src/main/java/org/forgerock/opendj/config/client/spi/PropertySet.java
@@ -35,7 +35,6 @@
import org.forgerock.opendj.config.PropertyException;
import org.forgerock.opendj.config.PropertyDefinition;
-import org.forgerock.opendj.config.PropertyDefinitionsOptions;
import org.forgerock.opendj.config.PropertyOption;
/**
@@ -281,8 +280,6 @@
* property (an empty set indicates that the property should be
* reset to its default behavior). The set will not be referenced
* by this managed object.
- * @param options
- * Options to validate property definitions values.
* @throws PropertyException
* If a new pending value is deemed to be invalid according to
* the property definition.
@@ -295,8 +292,7 @@
* If the specified property definition is not associated with
* this managed object.
*/
- <T> void setPropertyValues(PropertyDefinition<T> d, Collection<T> values,
- PropertyDefinitionsOptions options) {
+ <T> void setPropertyValues(PropertyDefinition<T> d, Collection<T> values) {
MyProperty<T> property = (MyProperty<T>) getProperty(d);
if (values.size() > 1 && !d.hasOption(PropertyOption.MULTI_VALUED)) {
@@ -316,7 +312,7 @@
throw new NullPointerException();
}
- d.validateValue(e, options);
+ d.validateValue(e);
}
// Update the property.
diff --git a/opendj-config/src/main/java/org/forgerock/opendj/config/conditions/ContainsCondition.java b/opendj-config/src/main/java/org/forgerock/opendj/config/conditions/ContainsCondition.java
index fbe60aa..0a45a28 100644
--- a/opendj-config/src/main/java/org/forgerock/opendj/config/conditions/ContainsCondition.java
+++ b/opendj-config/src/main/java/org/forgerock/opendj/config/conditions/ContainsCondition.java
@@ -29,7 +29,6 @@
import org.forgerock.opendj.config.AbstractManagedObjectDefinition;
import org.forgerock.opendj.config.PropertyDefinition;
-import org.forgerock.opendj.config.PropertyDefinitionsOptions;
import org.forgerock.opendj.config.client.ManagedObject;
import org.forgerock.opendj.config.client.ManagementContext;
import org.forgerock.opendj.config.server.ConfigException;
@@ -151,7 +150,7 @@
// Creates the new private implementation.
private <T> void buildImpl(PropertyDefinition<T> pd) {
- T value = pd.decodeValue(propertyStringValue, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ T value = pd.decodeValue(propertyStringValue);
this.impl = new Impl<T>(pd, value);
}
diff --git a/opendj-config/src/main/java/org/forgerock/opendj/config/server/ServerManagementContext.java b/opendj-config/src/main/java/org/forgerock/opendj/config/server/ServerManagementContext.java
index 98e9a1f..f52db78 100644
--- a/opendj-config/src/main/java/org/forgerock/opendj/config/server/ServerManagementContext.java
+++ b/opendj-config/src/main/java/org/forgerock/opendj/config/server/ServerManagementContext.java
@@ -44,7 +44,6 @@
import java.util.TreeSet;
import org.forgerock.i18n.LocalizableMessage;
-import org.opends.server.core.DirectoryServer;
import org.forgerock.opendj.server.config.meta.RootCfgDefn;
import org.forgerock.opendj.server.config.server.RootCfg;
import org.forgerock.opendj.config.AbsoluteInheritedDefaultBehaviorProvider;
@@ -63,7 +62,6 @@
import org.forgerock.opendj.config.ManagedObjectPath;
import org.forgerock.opendj.config.PropertyDefinition;
import org.forgerock.opendj.config.PropertyDefinitionVisitor;
-import org.forgerock.opendj.config.PropertyDefinitionsOptions;
import org.forgerock.opendj.config.PropertyNotFoundException;
import org.forgerock.opendj.config.PropertyOption;
import org.forgerock.opendj.config.Reference;
@@ -78,6 +76,7 @@
import org.forgerock.opendj.ldap.DN;
import org.forgerock.opendj.ldap.Entry;
import org.forgerock.opendj.ldap.schema.AttributeType;
+import org.forgerock.opendj.ldap.schema.Schema;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -143,7 +142,7 @@
for (String stringValue : stringValues) {
try {
- values.add(nextProperty.decodeValue(stringValue, propertyDefOptions));
+ values.add(nextProperty.decodeValue(stringValue));
} catch (PropertyException e) {
exception = PropertyException.defaultBehaviorException(nextProperty, e);
break;
@@ -234,7 +233,7 @@
if (attributeValues.size() > 0) {
Collection<T> pvalues = new ArrayList<T>();
for (String value : attributeValues) {
- pvalues.add(ValueDecoder.decode(propDef1, value, propertyDefOptions));
+ pvalues.add(ValueDecoder.decode(propDef1, value));
}
return pvalues;
} else {
@@ -242,7 +241,7 @@
Collection<T> tmp = find(target, propDef2);
Collection<T> pvalues = new ArrayList<T>(tmp.size());
for (T value : tmp) {
- propDef1.validateValue(value, propertyDefOptions);
+ propDef1.validateValue(value);
pvalues.add(value);
}
return pvalues;
@@ -289,8 +288,6 @@
*/
private static final class ValueDecoder extends PropertyDefinitionVisitor<Object, String> {
- private final PropertyDefinitionsOptions options;
-
/**
* Decodes the provided property LDAP value.
*
@@ -300,21 +297,18 @@
* The property definition.
* @param value
* The LDAP string representation.
- * @param options
- * Options to decode property definitions values.
* @return Returns the decoded LDAP value.
* @throws PropertyException
* If the property value could not be decoded because it was
* invalid.
*/
- public static <P> P decode(PropertyDefinition<P> propertyDef, String value,
- PropertyDefinitionsOptions options) {
- return propertyDef.castValue(propertyDef.accept(new ValueDecoder(options), value));
+ public static <P> P decode(PropertyDefinition<P> propertyDef, String value) {
+ return propertyDef.castValue(propertyDef.accept(new ValueDecoder(), value));
}
// Prevent instantiation.
- private ValueDecoder(PropertyDefinitionsOptions options) {
- this.options = options;
+ private ValueDecoder() {
+ // Do nothing.
}
/**
@@ -339,7 +333,7 @@
@Override
public <T> Object visitUnknown(PropertyDefinition<T> d, String p) {
// By default the property definition's decoder will do.
- return d.decodeValue(p, options);
+ return d.decodeValue(p);
}
}
@@ -354,23 +348,13 @@
private final ConfigurationRepository configRepository;
/**
- * Options to use when decoding and validating values of property
- * definitions.
- */
- private final PropertyDefinitionsOptions propertyDefOptions;
-
- /**
* Creates a context from the provided configuration repository.
*
* @param repository
* The repository of configuration entries.
- * @param propertyDefOptions
- * Options to use when decoding and validating values
- * of property definitions.
*/
- ServerManagementContext(ConfigurationRepository repository, PropertyDefinitionsOptions propertyDefOptions) {
+ ServerManagementContext(ConfigurationRepository repository) {
configRepository = repository;
- this.propertyDefOptions = propertyDefOptions;
}
/**
@@ -715,7 +699,7 @@
// The property has values defined for it.
for (String value : attributeValues) {
try {
- pvalues.add(ValueDecoder.decode(propertyDef, value, propertyDefOptions));
+ pvalues.add(ValueDecoder.decode(propertyDef, value));
} catch (PropertyException e) {
exception = e;
}
@@ -758,7 +742,7 @@
// We should log a warning here if this is the case
// since the attribute should have been defined.
String attrID = LDAPProfile.getInstance().getAttributeName(d, pd);
- AttributeType type = DirectoryServer.getAttributeType(attrID, true);
+ AttributeType type = Schema.getDefaultSchema().getAttributeType(attrID);
Iterable<Attribute> attributes = configEntry.getAllAttributes(AttributeDescription.create(type));
List<String> values = new ArrayList<String>();
for (Attribute attribute : attributes) {
diff --git a/opendj-config/src/main/java/org/opends/server/core/DirectoryServer.java b/opendj-config/src/main/java/org/opends/server/core/DirectoryServer.java
deleted file mode 100644
index a7b548a..0000000
--- a/opendj-config/src/main/java/org/opends/server/core/DirectoryServer.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- * Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- * Copyright 2013 ForgeRock AS.
- */
-package org.opends.server.core;
-
-import org.forgerock.opendj.ldap.schema.AttributeType;
-import org.forgerock.opendj.ldap.schema.Schema;
-import org.forgerock.opendj.ldap.schema.UnknownSchemaElementException;
-
-/**
- * TODO : this is a stub, with some default implementations for some methods,
- * and no implementation for others.
- */
-public final class DirectoryServer {
-
- private DirectoryServer() {
- // no implementation yet
- }
-
- /**
- * Retrieves the attribute type for the provided lowercase name or OID. It
- * can optionally return a generated "default" version if the requested
- * attribute type is not defined in the schema.
- *
- * @param lowerName
- * The lowercase name or OID for the attribute type to retrieve.
- * @param returnDefault
- * Indicates whether to generate a default version if the
- * requested attribute type is not defined in the server schema.
- * @return The requested attribute type, or <CODE>null</CODE> if there is no
- * attribute with the specified type defined in the server schema
- * and a default type should not be returned.
- */
- public static AttributeType getAttributeType(String lowerName, boolean returnDefault) {
- if (returnDefault) {
- return getAttributeType(lowerName);
- } else {
- try {
- return Schema.getDefaultSchema().asStrictSchema().getAttributeType(lowerName);
- } catch (UnknownSchemaElementException e) {
- return null;
- }
- }
- }
-
- /**
- * Retrieves the attribute type for the provided lowercase name or OID.
- *
- * @param lowerName
- * The lowercase attribute name or OID for the attribute type to
- * retrieve.
- * @return The requested attribute type, or <CODE>null</CODE> if there is no
- * attribute with the specified type defined in the server schema.
- */
- public static AttributeType getAttributeType(String lowerName) {
- return Schema.getDefaultSchema().getAttributeType(lowerName);
- }
-
- /**
- * Returns the directory of server instance.
- *
- * @return the instance root directory
- */
- public static String getInstanceRoot() {
- throw new RuntimeException("Not implemented");
- }
-
- /**
- * Returns the root directory of server.
- *
- * @return the server root directory
- */
- public static String getServerRoot() {
- throw new RuntimeException("Not implemented");
- }
-
-}
diff --git a/opendj-config/src/main/java/org/opends/server/core/package-info.java b/opendj-config/src/main/java/org/opends/server/core/package-info.java
deleted file mode 100644
index 3dc1c49..0000000
--- a/opendj-config/src/main/java/org/opends/server/core/package-info.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- * Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- * Copyright 2006-2008 Sun Microsystems, Inc.
- */
-/**
- * Contains various classes that comprise the core of the Directory Server
- * codebase. This includes:
- * <BR>
- * <UL>
- * <LI>
- * The code that is invoked to initialize the various components of the
- * Directory Server when it is started.
- * </LI>
- * <LI>
- * The code that is invoked whenever the Directory Server is in the process
- * of shutting down.
- * </LI>
- * <LI>
- * The various types of operations that may be processed within the
- * Directory Server.
- * </LI>
- * <LI>
- * Data structures for important elements of Directory Server data,
- * including attributes, objectclasses, DNs, entries.
- * </LI>
- * <LI>
- * The implementation of the work queue and worker threads responsible for
- * processing operations requested by clients.
- * </LI>
- * </UL>
- */
-package org.opends.server.core;
-
diff --git a/opendj-config/src/test/java/org/forgerock/opendj/config/AttributeTypePropertyDefinitionTest.java b/opendj-config/src/test/java/org/forgerock/opendj/config/AttributeTypePropertyDefinitionTest.java
index d47deec..c1d4141 100644
--- a/opendj-config/src/test/java/org/forgerock/opendj/config/AttributeTypePropertyDefinitionTest.java
+++ b/opendj-config/src/test/java/org/forgerock/opendj/config/AttributeTypePropertyDefinitionTest.java
@@ -39,7 +39,7 @@
@Test
public void testValidateValue() {
AttributeTypePropertyDefinition propertyDef = createPropertyDefinition();
- propertyDef.validateValue(Schema.getDefaultSchema().getAttributeType("cn"), new PropertyDefinitionsOptions());
+ propertyDef.validateValue(Schema.getDefaultSchema().getAttributeType("cn"));
}
@DataProvider(name = "valueLegalData")
@@ -51,13 +51,13 @@
public void testDecodeValue(String value) {
AttributeTypePropertyDefinition propertyDef = createPropertyDefinition();
AttributeType expected = Schema.getDefaultSchema().getAttributeType(value);
- assertEquals(propertyDef.decodeValue(value, new PropertyDefinitionsOptions()), expected);
+ assertEquals(propertyDef.decodeValue(value), expected);
}
@Test(dataProvider = "valueLegalData")
public void testEncodeValue(String value) {
AttributeTypePropertyDefinition propertyDef = createPropertyDefinition();
- assertEquals(propertyDef.encodeValue(propertyDef.decodeValue(value, new PropertyDefinitionsOptions())), value);
+ assertEquals(propertyDef.encodeValue(propertyDef.decodeValue(value)), value);
}
@DataProvider(name = "valueIllegalData")
@@ -67,14 +67,19 @@
@Test(dataProvider = "valueIllegalData", expectedExceptions = { PropertyException.class })
public void testDecodeValueIllegal(String value) {
- AttributeTypePropertyDefinition propertyDef = createPropertyDefinition();
- propertyDef.decodeValue(value, new PropertyDefinitionsOptions());
+ ConfigurationFramework.getInstance().setIsClient(false);
+ try {
+ AttributeTypePropertyDefinition propertyDef = createPropertyDefinition();
+ propertyDef.decodeValue(value);
+ } finally {
+ ConfigurationFramework.getInstance().setIsClient(true);
+ }
}
@Test(dataProvider = "valueIllegalData")
public void testDecodeValueIllegalNoSchemaCheck(String value) {
AttributeTypePropertyDefinition propertyDef = createPropertyDefinition();
- AttributeType type = propertyDef.decodeValue(value, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ AttributeType type = propertyDef.decodeValue(value);
assertEquals(type.getNameOrOID(), value);
}
diff --git a/opendj-config/src/test/java/org/forgerock/opendj/config/BooleanPropertyDefinitionTest.java b/opendj-config/src/test/java/org/forgerock/opendj/config/BooleanPropertyDefinitionTest.java
index ba84176..a196670 100644
--- a/opendj-config/src/test/java/org/forgerock/opendj/config/BooleanPropertyDefinitionTest.java
+++ b/opendj-config/src/test/java/org/forgerock/opendj/config/BooleanPropertyDefinitionTest.java
@@ -45,13 +45,13 @@
@Test
public void testValidateValue() {
BooleanPropertyDefinition def = createPropertyDefinition();
- def.validateValue(Boolean.TRUE, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ def.validateValue(Boolean.TRUE);
}
@Test(expectedExceptions = NullPointerException.class)
public void testValidateValueIllegal() {
BooleanPropertyDefinition def = createPropertyDefinition();
- def.validateValue(null, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ def.validateValue(null);
}
@DataProvider(name = "decodeValueData")
@@ -62,7 +62,7 @@
@Test(dataProvider = "decodeValueData")
public void testDecodeValue(String value, Boolean expected) {
BooleanPropertyDefinition def = createPropertyDefinition();
- assertEquals(def.decodeValue(value, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS), expected);
+ assertEquals(def.decodeValue(value), expected);
}
@DataProvider(name = "decodeValueDataIllegal")
@@ -74,7 +74,7 @@
PropertyException.class })
public void testDecodeValueIllegal(String value) {
BooleanPropertyDefinition def = createPropertyDefinition();
- def.decodeValue(value, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ def.decodeValue(value);
}
private BooleanPropertyDefinition createPropertyDefinition() {
diff --git a/opendj-config/src/test/java/org/forgerock/opendj/config/ConfigurationMock.java b/opendj-config/src/test/java/org/forgerock/opendj/config/ConfigurationMock.java
index 1c27e00..b0a7cf8 100644
--- a/opendj-config/src/test/java/org/forgerock/opendj/config/ConfigurationMock.java
+++ b/opendj-config/src/test/java/org/forgerock/opendj/config/ConfigurationMock.java
@@ -182,7 +182,7 @@
public Collection<T> visitDefined(DefinedDefaultBehaviorProvider<T> provider, Void p) {
SortedSet<T> values = new TreeSet<T>();
for (String stringValue : provider.getDefaultValues()) {
- values.add(propertyDef.decodeValue(stringValue, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS));
+ values.add(propertyDef.decodeValue(stringValue));
}
return values;
}
diff --git a/opendj-config/src/test/java/org/forgerock/opendj/config/DNPropertyDefinitionTest.java b/opendj-config/src/test/java/org/forgerock/opendj/config/DNPropertyDefinitionTest.java
index f114d8e..e950b8e 100644
--- a/opendj-config/src/test/java/org/forgerock/opendj/config/DNPropertyDefinitionTest.java
+++ b/opendj-config/src/test/java/org/forgerock/opendj/config/DNPropertyDefinitionTest.java
@@ -94,7 +94,7 @@
"test-property");
localBuilder.setBaseDN(baseDN);
DNPropertyDefinition propertyDef = localBuilder.getInstance();
- propertyDef.validateValue(DN.valueOf(valueToValidate), PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ propertyDef.validateValue(DN.valueOf(valueToValidate));
}
@Test(dataProvider = "illegalValues", expectedExceptions = PropertyException.class)
@@ -103,7 +103,7 @@
"test-property");
localBuilder.setBaseDN(baseDN);
DNPropertyDefinition propertyDef = localBuilder.getInstance();
- propertyDef.validateValue(DN.valueOf(valueToValidate), PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ propertyDef.validateValue(DN.valueOf(valueToValidate));
}
@Test(dataProvider = "legalValues")
@@ -112,7 +112,7 @@
"test-property");
localBuilder.setBaseDN(baseDN);
DNPropertyDefinition propertyDef = localBuilder.getInstance();
- propertyDef.decodeValue(valueToValidate, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ propertyDef.decodeValue(valueToValidate);
}
@Test(dataProvider = "illegalValues", expectedExceptions = PropertyException.class)
@@ -121,6 +121,6 @@
"test-property");
localBuilder.setBaseDN(baseDN);
DNPropertyDefinition propertyDef = localBuilder.getInstance();
- propertyDef.decodeValue(valueToValidate, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ propertyDef.decodeValue(valueToValidate);
}
}
diff --git a/opendj-config/src/test/java/org/forgerock/opendj/config/DurationPropertyDefinitionTest.java b/opendj-config/src/test/java/org/forgerock/opendj/config/DurationPropertyDefinitionTest.java
index f8b584c..7d897f5 100644
--- a/opendj-config/src/test/java/org/forgerock/opendj/config/DurationPropertyDefinitionTest.java
+++ b/opendj-config/src/test/java/org/forgerock/opendj/config/DurationPropertyDefinitionTest.java
@@ -124,7 +124,7 @@
DurationPropertyDefinition.Builder builder = createTestBuilder();
builder.setAllowUnlimited(true);
DurationPropertyDefinition def = buildTestDefinition(builder);
- def.decodeValue("unlimited", PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ def.decodeValue("unlimited");
}
@Test(expectedExceptions = PropertyException.class)
@@ -132,7 +132,7 @@
DurationPropertyDefinition.Builder builder = createTestBuilder();
builder.setAllowUnlimited(false);
DurationPropertyDefinition def = buildTestDefinition(builder);
- def.decodeValue("unlimited", PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ def.decodeValue("unlimited");
}
@Test(expectedExceptions = PropertyException.class)
@@ -140,7 +140,7 @@
DurationPropertyDefinition.Builder builder = createTestBuilder();
builder.setAllowUnlimited(false);
DurationPropertyDefinition def = buildTestDefinition(builder);
- def.validateValue(-1L, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ def.validateValue(-1L);
}
@DataProvider(name = "validateValueData")
@@ -163,7 +163,7 @@
builder.setUpperLimit(higherLimitInMillis);
builder.setAllowUnlimited(isAllowUnlimited);
DurationPropertyDefinition def = buildTestDefinition(builder);
- def.validateValue(valueInSeconds, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ def.validateValue(valueInSeconds);
}
@DataProvider(name = "illegalValidateValueData")
@@ -185,7 +185,7 @@
builder.setUpperLimit(highLimitInMillis);
builder.setAllowUnlimited(isAllowUnlimited);
DurationPropertyDefinition def = buildTestDefinition(builder);
- def.validateValue(valueInSeconds, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ def.validateValue(valueInSeconds);
}
@DataProvider(name = "encodeValueData")
@@ -304,7 +304,7 @@
builder.setMaximumUnit(DurationUnit.DAYS);
DurationPropertyDefinition def = buildTestDefinition(builder);
- assertThat(def.decodeValue(valueToDecode, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS)).
+ assertThat(def.decodeValue(valueToDecode)).
isEqualTo(expectedValue);
}
@@ -338,7 +338,7 @@
builder.setLowerLimit(5L);
builder.setUpperLimit(10L);
DurationPropertyDefinition def = buildTestDefinition(builder);
- def.decodeValue(valueToDecode, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ def.decodeValue(valueToDecode);
}
private DurationPropertyDefinition.Builder createTestBuilder() {
diff --git a/opendj-config/src/test/java/org/forgerock/opendj/config/EnumPropertyDefinitionTest.java b/opendj-config/src/test/java/org/forgerock/opendj/config/EnumPropertyDefinitionTest.java
index 6cb5697..ac48f49 100644
--- a/opendj-config/src/test/java/org/forgerock/opendj/config/EnumPropertyDefinitionTest.java
+++ b/opendj-config/src/test/java/org/forgerock/opendj/config/EnumPropertyDefinitionTest.java
@@ -94,7 +94,7 @@
@Test(dataProvider = "decodeValueData")
public void testDecodeValue(String value, TestEnum expectedValue) {
EnumPropertyDefinition<?> def = builder.getInstance();
- assertEquals(def.decodeValue(value, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS), expectedValue);
+ assertEquals(def.decodeValue(value), expectedValue);
}
/**
@@ -117,7 +117,7 @@
PropertyException.class })
public void testDecodeValueIllegalData(String value) {
EnumPropertyDefinition<?> def = builder.getInstance();
- def.decodeValue(value, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ def.decodeValue(value);
}
/**
@@ -135,7 +135,7 @@
@Test
public void testValidateValue() {
EnumPropertyDefinition<TestEnum> def = builder.getInstance();
- def.validateValue(TestEnum.ONE, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ def.validateValue(TestEnum.ONE);
}
}
diff --git a/opendj-config/src/test/java/org/forgerock/opendj/config/IntegerPropertyDefinitionTest.java b/opendj-config/src/test/java/org/forgerock/opendj/config/IntegerPropertyDefinitionTest.java
index 10412c1..a523dd3 100644
--- a/opendj-config/src/test/java/org/forgerock/opendj/config/IntegerPropertyDefinitionTest.java
+++ b/opendj-config/src/test/java/org/forgerock/opendj/config/IntegerPropertyDefinitionTest.java
@@ -92,7 +92,7 @@
IntegerPropertyDefinition.Builder builder = createTestBuilder();
builder.setAllowUnlimited(true);
IntegerPropertyDefinition propertyDef = buildTestDefinition(builder);
- propertyDef.decodeValue("unlimited", PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ propertyDef.decodeValue("unlimited");
}
@Test(expectedExceptions = PropertyException.class)
@@ -100,7 +100,7 @@
IntegerPropertyDefinition.Builder builder = createTestBuilder();
builder.setAllowUnlimited(false);
IntegerPropertyDefinition propertyDef = buildTestDefinition(builder);
- propertyDef.decodeValue("unlimited", PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ propertyDef.decodeValue("unlimited");
}
@Test(expectedExceptions = PropertyException.class)
@@ -108,7 +108,7 @@
IntegerPropertyDefinition.Builder builder = createTestBuilder();
builder.setAllowUnlimited(false);
IntegerPropertyDefinition propertyDef = buildTestDefinition(builder);
- propertyDef.validateValue(-1, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ propertyDef.validateValue(-1);
}
@DataProvider(name = "validateValueData")
@@ -128,7 +128,7 @@
builder.setUpperLimit(high);
builder.setAllowUnlimited(allowUnlimited);
IntegerPropertyDefinition propertyDef = buildTestDefinition(builder);
- propertyDef.validateValue(valueToValidate, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ propertyDef.validateValue(valueToValidate);
}
@DataProvider(name = "illegalValidateValueData")
@@ -152,7 +152,7 @@
builder.setUpperLimit(high);
builder.setAllowUnlimited(allowUnlimited);
IntegerPropertyDefinition propertyDef = buildTestDefinition(builder);
- propertyDef.validateValue(value, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ propertyDef.validateValue(value);
}
@DataProvider(name = "encodeValueData")
diff --git a/opendj-config/src/test/java/org/forgerock/opendj/config/SizePropertyDefinitionTest.java b/opendj-config/src/test/java/org/forgerock/opendj/config/SizePropertyDefinitionTest.java
index ed58ee2..90ee9e6 100644
--- a/opendj-config/src/test/java/org/forgerock/opendj/config/SizePropertyDefinitionTest.java
+++ b/opendj-config/src/test/java/org/forgerock/opendj/config/SizePropertyDefinitionTest.java
@@ -99,7 +99,7 @@
SizePropertyDefinition.Builder builder = createTestBuilder();
builder.setAllowUnlimited(true);
SizePropertyDefinition propertyDef = buildTestDefinition(builder);
- propertyDef.decodeValue("unlimited", PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ propertyDef.decodeValue("unlimited");
}
@Test(expectedExceptions = PropertyException.class)
@@ -107,7 +107,7 @@
SizePropertyDefinition.Builder builder = createTestBuilder();
builder.setAllowUnlimited(false);
SizePropertyDefinition propertyDef = buildTestDefinition(builder);
- propertyDef.decodeValue("unlimited", PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ propertyDef.decodeValue("unlimited");
}
@Test(expectedExceptions = PropertyException.class)
@@ -115,7 +115,7 @@
SizePropertyDefinition.Builder builder = createTestBuilder();
builder.setAllowUnlimited(false);
SizePropertyDefinition propertyDef = buildTestDefinition(builder);
- propertyDef.validateValue(-1L, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ propertyDef.validateValue(-1L);
}
@DataProvider(name = "validateValueData")
@@ -135,7 +135,7 @@
builder.setUpperLimit(high);
builder.setAllowUnlimited(isAllowUnlimited);
SizePropertyDefinition propertyDef = buildTestDefinition(builder);
- propertyDef.validateValue(valueToValidate, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ propertyDef.validateValue(valueToValidate);
}
@DataProvider(name = "illegalValidateValueData")
@@ -159,7 +159,7 @@
builder.setUpperLimit(high);
builder.setAllowUnlimited(allowUnlimited);
SizePropertyDefinition propertyDef = buildTestDefinition(builder);
- propertyDef.validateValue(valueToValidate, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ propertyDef.validateValue(valueToValidate);
}
@DataProvider(name = "encodeValueData")
diff --git a/opendj-config/src/test/java/org/forgerock/opendj/config/StringPropertyDefinitionTest.java b/opendj-config/src/test/java/org/forgerock/opendj/config/StringPropertyDefinitionTest.java
index 98e20af..a1dd324 100644
--- a/opendj-config/src/test/java/org/forgerock/opendj/config/StringPropertyDefinitionTest.java
+++ b/opendj-config/src/test/java/org/forgerock/opendj/config/StringPropertyDefinitionTest.java
@@ -36,33 +36,33 @@
@Test
public void testValidateValueNoPattern() {
StringPropertyDefinition d = getDefinition(true, null);
- d.validateValue("abc", PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ d.validateValue("abc");
}
@Test
public void testValidateValuePatternMatches() {
StringPropertyDefinition d = getDefinition(true, "^[a-z]+$");
- d.validateValue("abc", PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ d.validateValue("abc");
}
// TODO : I18N problem
@Test(enabled = false, expectedExceptions = PropertyException.class)
public void testValidateValuePatternDoesNotMatch() {
StringPropertyDefinition d = getDefinition(true, "^[a-z]+$");
- d.validateValue("abc123", PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ d.validateValue("abc123");
}
@Test
public void testDecodeValuePatternMatches() {
StringPropertyDefinition d = getDefinition(true, "^[a-z]+$");
- assertEquals(d.decodeValue("abc", PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS), "abc");
+ assertEquals(d.decodeValue("abc"), "abc");
}
// TODO : I18N problem
@Test(enabled = false, expectedExceptions = PropertyException.class)
public void testDecodeValuePatternDoesNotMatch() {
StringPropertyDefinition d = getDefinition(true, "^[a-z]+$");
- d.decodeValue("abc123", PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ d.decodeValue("abc123");
}
// Create a string property definition.
diff --git a/opendj-config/src/test/java/org/forgerock/opendj/config/client/ldap/AggregationClientTest.java b/opendj-config/src/test/java/org/forgerock/opendj/config/client/ldap/AggregationClientTest.java
index 7d07292..5835fe0 100644
--- a/opendj-config/src/test/java/org/forgerock/opendj/config/client/ldap/AggregationClientTest.java
+++ b/opendj-config/src/test/java/org/forgerock/opendj/config/client/ldap/AggregationClientTest.java
@@ -34,7 +34,6 @@
import org.forgerock.opendj.config.AdminTestCase;
import org.forgerock.opendj.config.PropertyException;
import org.forgerock.opendj.config.LDAPProfile;
-import org.forgerock.opendj.config.PropertyDefinitionsOptions;
import org.forgerock.opendj.config.TestCfg;
import org.forgerock.opendj.config.TestChildCfgClient;
import org.forgerock.opendj.config.TestChildCfgDefn;
@@ -42,8 +41,8 @@
import org.forgerock.opendj.config.client.ManagedObject;
import org.forgerock.opendj.config.client.ManagedObjectDecodingException;
import org.forgerock.opendj.config.client.ManagementContext;
+import org.forgerock.opendj.ldap.schema.Schema;
import org.forgerock.opendj.server.config.client.RootCfgClient;
-import org.opends.server.core.DirectoryServer;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
@@ -177,8 +176,7 @@
public void testAggregationEmpty() throws Exception {
MockLDAPConnection c = new MockLDAPConnection();
c.importLDIF(TEST_LDIF);
- ManagementContext ctx = LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
- PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ ManagementContext ctx = LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance());
TestParentCfgClient parent = getTestParent(ctx, "test parent 1");
TestChildCfgClient child = parent.getTestChild("test child 1");
assertSetEquals(child.getAggregationProperty(), new String[0]);
@@ -195,8 +193,7 @@
public void testAggregationSingle() throws Exception {
MockLDAPConnection c = new MockLDAPConnection();
c.importLDIF(TEST_LDIF);
- ManagementContext ctx = LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
- PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ ManagementContext ctx = LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance());
TestParentCfgClient parent = getTestParent(ctx, "test parent 1");
TestChildCfgClient child = parent.getTestChild("test child 2");
@@ -217,8 +214,7 @@
public void testAggregationMultiple() throws Exception {
MockLDAPConnection c = new MockLDAPConnection();
c.importLDIF(TEST_LDIF);
- ManagementContext ctx = LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
- PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ ManagementContext ctx = LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance());
TestParentCfgClient parent = getTestParent(ctx, "test parent 1");
TestChildCfgClient child = parent.getTestChild("test child 3");
assertSetEquals(child.getAggregationProperty(), "LDAPS Connection Handler", "LDAP Connection Handler");
@@ -235,8 +231,7 @@
public void testAggregationBadBaseDN() throws Exception {
MockLDAPConnection c = new MockLDAPConnection();
c.importLDIF(TEST_LDIF);
- ManagementContext ctx = LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
- PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ ManagementContext ctx = LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance());
TestParentCfgClient parent = getTestParent(ctx, "test parent 1");
try {
@@ -278,12 +273,11 @@
c.addExpectedAttribute("ds-cfg-rotation-policy",
"cn=LDAP Connection Handler,cn=connection handlers, cn=config");
- ManagementContext ctx = LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
- PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ ManagementContext ctx = LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance());
TestParentCfgClient parent = getTestParent(ctx, "test parent 1");
TestChildCfgClient child = parent.createTestChild(TestChildCfgDefn.getInstance(), "test child new", null);
child.setMandatoryBooleanProperty(true);
- child.setMandatoryReadOnlyAttributeTypeProperty(DirectoryServer.getAttributeType("description"));
+ child.setMandatoryReadOnlyAttributeTypeProperty(Schema.getDefaultSchema().getAttributeType("description"));
child.setAggregationProperty(Collections.singleton("LDAP Connection Handler"));
child.commit();
@@ -305,8 +299,7 @@
c.addExpectedModification("ds-cfg-rotation-policy",
"cn=HTTP Connection Handler,cn=connection handlers, cn=config",
"cn=JMX Connection Handler,cn=connection handlers, cn=config");
- ManagementContext ctx = LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
- PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ ManagementContext ctx = LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance());
TestParentCfgClient parent = getTestParent(ctx, "test parent 1");
TestChildCfgClient child = parent.getTestChild("test child 2");
child.setAggregationProperty(Arrays.asList("JMX Connection Handler", "HTTP Connection Handler"));
diff --git a/opendj-config/src/test/java/org/forgerock/opendj/config/client/ldap/LDAPClientTest.java b/opendj-config/src/test/java/org/forgerock/opendj/config/client/ldap/LDAPClientTest.java
index 70b0d43..7cc6c8e 100644
--- a/opendj-config/src/test/java/org/forgerock/opendj/config/client/ldap/LDAPClientTest.java
+++ b/opendj-config/src/test/java/org/forgerock/opendj/config/client/ldap/LDAPClientTest.java
@@ -37,7 +37,6 @@
import org.forgerock.opendj.config.LDAPProfile;
import org.forgerock.opendj.config.ManagedObjectAlreadyExistsException;
import org.forgerock.opendj.config.ManagedObjectNotFoundException;
-import org.forgerock.opendj.config.PropertyDefinitionsOptions;
import org.forgerock.opendj.config.TestCfg;
import org.forgerock.opendj.config.TestChildCfgClient;
import org.forgerock.opendj.config.TestChildCfgDefn;
@@ -51,8 +50,9 @@
import org.forgerock.opendj.ldap.ErrorResultException;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.responses.SearchResultEntry;
+import org.forgerock.opendj.ldap.schema.AttributeType;
+import org.forgerock.opendj.ldap.schema.Schema;
import org.forgerock.opendj.server.config.client.RootCfgClient;
-import org.opends.server.core.DirectoryServer;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
@@ -234,12 +234,11 @@
c.addExpectedAttribute("ds-cfg-attribute-type", "description");
ManagementContext ctx =
- LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
- PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance());
TestParentCfgClient parent = getTestParent(ctx, "test parent 1");
TestChildCfgClient child = parent.createTestChild(TestChildCfgDefn.getInstance(), "test child new", null);
child.setMandatoryBooleanProperty(true);
- child.setMandatoryReadOnlyAttributeTypeProperty(DirectoryServer.getAttributeType("description"));
+ child.setMandatoryReadOnlyAttributeTypeProperty(getAttributeType("description"));
child.commit();
c.assertEntryIsCreated();
@@ -262,12 +261,11 @@
};
conn.importLDIF(TEST_LDIF);
ManagementContext ctx =
- LDAPManagementContext.createFromContext(conn, LDAPProfile.getInstance(),
- PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ LDAPManagementContext.createFromContext(conn, LDAPProfile.getInstance());
try {
TestParentCfgClient parent = createTestParent(ctx, "test parent new");
parent.setMandatoryBooleanProperty(true);
- parent.setMandatoryReadOnlyAttributeTypeProperty(DirectoryServer.getAttributeType("description"));
+ parent.setMandatoryReadOnlyAttributeTypeProperty(getAttributeType("description"));
parent.commit();
} catch (Exception e) {
if (expectedExceptionClass.equals(ErrorResultException.class)) {
@@ -297,11 +295,10 @@
c.addExpectedAttribute("ds-cfg-attribute-type", "description");
ManagementContext ctx =
- LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
- PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance());
TestParentCfgClient parent = createTestParent(ctx, "test parent new");
parent.setMandatoryBooleanProperty(true);
- parent.setMandatoryReadOnlyAttributeTypeProperty(DirectoryServer.getAttributeType("description"));
+ parent.setMandatoryReadOnlyAttributeTypeProperty(getAttributeType("description"));
parent.commit();
c.assertEntryIsCreated();
}
@@ -317,15 +314,14 @@
MockLDAPConnection c = new MockLDAPConnection();
c.importLDIF(TEST_LDIF);
ManagementContext ctx =
- LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
- PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance());
TestParentCfgClient parent = getTestParent(ctx, "test parent 1");
TestChildCfgClient child = parent.getTestChild("test child 3");
Assert.assertEquals(child.isMandatoryBooleanProperty(), Boolean.TRUE);
Assert.assertEquals(child.getMandatoryClassProperty(),
"org.opends.server.extensions.UserDefinedVirtualAttributeProvider");
Assert.assertEquals(child.getMandatoryReadOnlyAttributeTypeProperty(),
- DirectoryServer.getAttributeType("description"));
+ getAttributeType("description"));
assertDNSetEquals(child.getOptionalMultiValuedDNProperty1(), "dc=default value c3v1,dc=com",
"dc=default value c3v2,dc=com");
assertDNSetEquals(child.getOptionalMultiValuedDNProperty2(), "dc=default value c3v3,dc=com",
@@ -343,15 +339,14 @@
MockLDAPConnection c = new MockLDAPConnection();
c.importLDIF(TEST_LDIF);
ManagementContext ctx =
- LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
- PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance());
TestParentCfgClient parent = getTestParent(ctx, "test parent 1");
TestChildCfgClient child = parent.getTestChild("test child 1");
Assert.assertEquals(child.isMandatoryBooleanProperty(), Boolean.TRUE);
Assert.assertEquals(child.getMandatoryClassProperty(),
"org.opends.server.extensions.UserDefinedVirtualAttributeProvider");
Assert.assertEquals(child.getMandatoryReadOnlyAttributeTypeProperty(),
- DirectoryServer.getAttributeType("description"));
+ getAttributeType("description"));
assertDNSetEquals(child.getOptionalMultiValuedDNProperty1(), "dc=domain1,dc=com", "dc=domain2,dc=com",
"dc=domain3,dc=com");
assertDNSetEquals(child.getOptionalMultiValuedDNProperty2(), "dc=domain1,dc=com", "dc=domain2,dc=com",
@@ -381,8 +376,7 @@
};
c.importLDIF(TEST_LDIF);
ManagementContext ctx =
- LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
- PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance());
try {
getTestParent(ctx, "test parent 2");
} catch (Exception e) {
@@ -406,14 +400,13 @@
MockLDAPConnection c = new MockLDAPConnection();
c.importLDIF(TEST_LDIF);
ManagementContext ctx =
- LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
- PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance());
TestParentCfgClient parent = getTestParent(ctx, "test parent 2");
Assert.assertEquals(parent.isMandatoryBooleanProperty(), Boolean.TRUE);
Assert.assertEquals(parent.getMandatoryClassProperty(),
"org.opends.server.extensions.UserDefinedVirtualAttributeProvider");
Assert.assertEquals(parent.getMandatoryReadOnlyAttributeTypeProperty(),
- DirectoryServer.getAttributeType("description"));
+ getAttributeType("description"));
assertDNSetEquals(parent.getOptionalMultiValuedDNProperty(), "dc=default value p2v1,dc=com",
"dc=default value p2v2,dc=com");
}
@@ -429,14 +422,13 @@
MockLDAPConnection c = new MockLDAPConnection();
c.importLDIF(TEST_LDIF);
ManagementContext ctx =
- LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
- PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance());
TestParentCfgClient parent = getTestParent(ctx, "test parent 1");
Assert.assertEquals(parent.isMandatoryBooleanProperty(), Boolean.TRUE);
Assert.assertEquals(parent.getMandatoryClassProperty(),
"org.opends.server.extensions.UserDefinedVirtualAttributeProvider");
Assert.assertEquals(parent.getMandatoryReadOnlyAttributeTypeProperty(),
- DirectoryServer.getAttributeType("description"));
+ getAttributeType("description"));
assertDNSetEquals(parent.getOptionalMultiValuedDNProperty(), "dc=domain1,dc=com", "dc=domain2,dc=com",
"dc=domain3,dc=com");
}
@@ -461,8 +453,7 @@
c.addExpectedAttribute("ds-cfg-attribute-type", "description");
ManagementContext ctx =
- LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
- PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance());
TestParentCfgClient parent = getTestParent(ctx, "test parent 1");
TestChildCfgClient child = parent.createTestChild(TestChildCfgDefn.getInstance(), "test child new", null);
@@ -478,7 +469,7 @@
// Check that the default values are not committed.
child.setMandatoryBooleanProperty(true);
- child.setMandatoryReadOnlyAttributeTypeProperty(DirectoryServer.getAttributeType("description"));
+ child.setMandatoryReadOnlyAttributeTypeProperty(getAttributeType("description"));
child.commit();
c.assertEntryIsCreated();
@@ -504,8 +495,7 @@
c.addExpectedAttribute("ds-cfg-attribute-type", "description");
ManagementContext ctx =
- LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
- PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance());
TestParentCfgClient parent = getTestParent(ctx, "test parent 2");
TestChildCfgClient child = parent.createTestChild(TestChildCfgDefn.getInstance(), "test child new", null);
@@ -521,7 +511,7 @@
// Check that the default values are not committed.
child.setMandatoryBooleanProperty(true);
- child.setMandatoryReadOnlyAttributeTypeProperty(DirectoryServer.getAttributeType("description"));
+ child.setMandatoryReadOnlyAttributeTypeProperty(getAttributeType("description"));
child.commit();
c.assertEntryIsCreated();
@@ -538,8 +528,7 @@
MockLDAPConnection c = new MockLDAPConnection();
c.importLDIF(TEST_LDIF);
ManagementContext ctx =
- LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
- PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance());
TestParentCfgClient parent = getTestParent(ctx, "test parent 1");
String[] actual = parent.listTestChildren();
String[] expected = new String[] { "test child 1", "test child 2", "test child 3" };
@@ -557,8 +546,7 @@
MockLDAPConnection c = new MockLDAPConnection();
c.importLDIF(TEST_LDIF);
ManagementContext ctx =
- LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
- PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance());
TestParentCfgClient parent = getTestParent(ctx, "test parent 3");
String[] actual = parent.listTestChildren();
String[] expected = new String[] {};
@@ -576,8 +564,7 @@
MockLDAPConnection c = new MockLDAPConnection();
c.importLDIF(TEST_LDIF);
ManagementContext ctx =
- LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
- PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance());
String[] actual = listTestParents(ctx);
String[] expected = new String[] { "test parent 1", "test parent 2", "test parent 3" };
Assert.assertEqualsNoOrder(actual, expected);
@@ -593,8 +580,7 @@
public void testListTopLevelManagedObjectsEmpty() throws Exception {
MockLDAPConnection c = new MockLDAPConnection();
ManagementContext ctx =
- LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
- PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance());
String[] actual = listTestParents(ctx);
String[] expected = new String[] {};
Assert.assertEqualsNoOrder(actual, expected);
@@ -614,8 +600,7 @@
c.importLDIF(TEST_LDIF);
c.addExpectedModification("ds-cfg-base-dn");
ManagementContext ctx =
- LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
- PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance());
TestParentCfgClient parent = getTestParent(ctx, "test parent 1");
TestChildCfgClient child = parent.getTestChild("test child 2");
child.setOptionalMultiValuedDNProperty1(Collections.<DN> emptySet());
@@ -635,8 +620,7 @@
new ModifyEntryMockLDAPConnection("cn=test parent 1,cn=test parents,cn=config");
c.importLDIF(TEST_LDIF);
ManagementContext ctx =
- LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
- PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance());
TestParentCfgClient parent = getTestParent(ctx, "test parent 1");
parent.commit();
Assert.assertFalse(c.isEntryModified());
@@ -656,8 +640,7 @@
c.addExpectedModification("ds-cfg-enabled", "false");
c.addExpectedModification("ds-cfg-base-dn", "dc=mod1,dc=com", "dc=mod2,dc=com");
ManagementContext ctx =
- LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
- PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance());
TestParentCfgClient parent = getTestParent(ctx, "test parent 1");
parent.setMandatoryBooleanProperty(false);
parent.setOptionalMultiValuedDNProperty(Arrays.asList(DN.valueOf("dc=mod1,dc=com"),
@@ -679,8 +662,7 @@
"cn=test child 1,cn=test children,cn=test parent 1,cn=test parents,cn=config");
c.importLDIF(TEST_LDIF);
ManagementContext ctx =
- LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
- PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance());
TestParentCfgClient parent = getTestParent(ctx, "test parent 1");
parent.removeTestChild("test child 1");
c.assertSubtreeIsDeleted();
@@ -698,8 +680,7 @@
new DeleteSubtreeMockLDAPConnection("cn=test parent 1,cn=test parents,cn=config");
c.importLDIF(TEST_LDIF);
ManagementContext ctx =
- LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
- PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance());
removeTestParent(ctx, "test parent 1");
c.assertSubtreeIsDeleted();
}
@@ -729,12 +710,11 @@
c.addExpectedAttribute("ds-cfg-attribute-type", "description");
ManagementContext ctx =
- LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
- PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance());
TestParentCfgClient parent = getTestParent(ctx, "test parent 1");
TestChildCfgClient child = parent.createTestChild(TestChildCfgDefn.getInstance(), "test child new", null);
child.setMandatoryBooleanProperty(true);
- child.setMandatoryReadOnlyAttributeTypeProperty(DirectoryServer.getAttributeType("description"));
+ child.setMandatoryReadOnlyAttributeTypeProperty(getAttributeType("description"));
child.commit();
c.assertEntryIsCreated();
@@ -769,12 +749,11 @@
conn.addExpectedAttribute("ds-cfg-attribute-type", "description");
ManagementContext ctx =
- LDAPManagementContext.createFromContext(conn, LDAPProfile.getInstance(),
- PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ LDAPManagementContext.createFromContext(conn, LDAPProfile.getInstance());
TestParentCfgClient parent = getTestParent(ctx, "test parent 1");
TestChildCfgClient child = parent.createTestChild(TestChildCfgDefn.getInstance(), "test child new", null);
child.setMandatoryBooleanProperty(true);
- child.setMandatoryReadOnlyAttributeTypeProperty(DirectoryServer.getAttributeType("description"));
+ child.setMandatoryReadOnlyAttributeTypeProperty(getAttributeType("description"));
child.commit();
Assert.fail("The add constraint failed to prevent creation of the managed object");
} finally {
@@ -801,8 +780,7 @@
"cn=test child 1,cn=test children,cn=test parent 1,cn=test parents,cn=config");
c.importLDIF(TEST_LDIF);
ManagementContext ctx =
- LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
- PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance());
TestParentCfgClient parent = getTestParent(ctx, "test parent 1");
parent.removeTestChild("test child 1");
c.assertSubtreeIsDeleted();
@@ -830,8 +808,7 @@
"cn=test child 1,cn=test children,cn=test parent 1,cn=test parents,cn=config");
c.importLDIF(TEST_LDIF);
ManagementContext ctx =
- LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
- PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance());
TestParentCfgClient parent = getTestParent(ctx, "test parent 1");
parent.removeTestChild("test child 1");
Assert.fail("The remove constraint failed to prevent removal of the managed object");
@@ -860,8 +837,7 @@
c.importLDIF(TEST_LDIF);
c.addExpectedModification("ds-cfg-base-dn");
ManagementContext ctx =
- LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
- PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance());
TestParentCfgClient parent = getTestParent(ctx, "test parent 1");
TestChildCfgClient child = parent.getTestChild("test child 2");
child.setOptionalMultiValuedDNProperty1(Collections.<DN> emptySet());
@@ -892,8 +868,7 @@
c.importLDIF(TEST_LDIF);
c.addExpectedModification("ds-cfg-base-dn");
ManagementContext ctx =
- LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance(),
- PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ LDAPManagementContext.createFromContext(c, LDAPProfile.getInstance());
TestParentCfgClient parent = getTestParent(ctx, "test parent 1");
TestChildCfgClient child = parent.getTestChild("test child 2");
child.setOptionalMultiValuedDNProperty1(Collections.<DN> emptySet());
@@ -940,4 +915,8 @@
ManagedObject<RootCfgClient> root = context.getRootConfigurationManagedObject();
root.removeChild(TestCfg.getTestOneToManyParentRelationDefinition(), name);
}
+
+ private AttributeType getAttributeType(String type) {
+ return Schema.getDefaultSchema().getAttributeType(type);
+ }
}
diff --git a/opendj-config/src/test/java/org/forgerock/opendj/config/server/AggregationServerTest.java b/opendj-config/src/test/java/org/forgerock/opendj/config/server/AggregationServerTest.java
index c6a7604..dc2d16c 100644
--- a/opendj-config/src/test/java/org/forgerock/opendj/config/server/AggregationServerTest.java
+++ b/opendj-config/src/test/java/org/forgerock/opendj/config/server/AggregationServerTest.java
@@ -43,7 +43,6 @@
import org.forgerock.opendj.config.AdministratorAction;
import org.forgerock.opendj.config.AggregationPropertyDefinition;
import org.forgerock.opendj.config.PropertyException;
-import org.forgerock.opendj.config.PropertyDefinitionsOptions;
import org.forgerock.opendj.config.PropertyOption;
import org.forgerock.opendj.config.TestCfg;
import org.forgerock.opendj.config.TestChildCfg;
@@ -296,7 +295,7 @@
ConfigurationRepository configRepository =
createConfigRepositoryWithEntries(TEST_PARENT_1, TEST_CHILD_3, LDAP_CONN_HANDLER_ENTRY);
ServerManagementContext context =
- new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ new ServerManagementContext(configRepository);
TestParentCfg parentCfg = getParentCfg(TEST_PARENT_1, context);
try {
parentCfg.getTestChild(entryName(TEST_CHILD_3));
@@ -321,7 +320,7 @@
ConfigurationRepository configRepository =
createConfigRepositoryWithEntries(TEST_PARENT_1, TEST_CHILD_5, LDAP_CONN_HANDLER_ENTRY);
ServerManagementContext context =
- new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ new ServerManagementContext(configRepository);
TestParentCfg parentCfg = getParentCfg(TEST_PARENT_1, context);
try {
@@ -344,7 +343,7 @@
ConfigurationRepository configRepository =
createConfigRepositoryWithEntries(TEST_PARENT_1, TEST_CHILD_6, TEST_CONNECTION_HANDLER_ENTRY_DISABLED);
ServerManagementContext context =
- new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ new ServerManagementContext(configRepository);
registerAggregationDefinitionWithTargetEnabled();
@@ -371,7 +370,7 @@
ConfigurationRepository configRepository =
createConfigRepositoryWithEntries(TEST_PARENT_1, TEST_CHILD_7, TEST_CONNECTION_HANDLER_ENTRY_DISABLED);
ServerManagementContext context =
- new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ new ServerManagementContext(configRepository);
registerAggregationDefinitionWithTargetEnabled();
@@ -399,7 +398,7 @@
ConfigurationRepository configRepository =
createConfigRepositoryWithEntries(TEST_PARENT_1, TEST_CHILD_6, TEST_CONNECTION_HANDLER_ENTRY_DISABLED);
ServerManagementContext context =
- new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ new ServerManagementContext(configRepository);
registerAggregationDefinitionWithTargetAndSourceEnabled();
@@ -426,7 +425,7 @@
ConfigurationRepository configRepository =
createConfigRepositoryWithEntries(TEST_PARENT_1, TEST_CHILD_7, TEST_CONNECTION_HANDLER_ENTRY_DISABLED);
ServerManagementContext context =
- new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ new ServerManagementContext(configRepository);
registerAggregationDefinitionWithTargetAndSourceEnabled();
@@ -446,7 +445,7 @@
public void testAggregationEmpty() throws Exception {
ConfigurationRepository configRepository = createConfigRepositoryWithEntries(TEST_PARENT_1, TEST_CHILD_1);
ServerManagementContext context =
- new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ new ServerManagementContext(configRepository);
TestParentCfg parentCfg = getParentCfg(TEST_PARENT_1, context);
TestChildCfg testChildCfg = parentCfg.getTestChild(entryName(TEST_CHILD_1));
@@ -467,7 +466,7 @@
createConfigRepositoryWithEntries(TEST_PARENT_1, TEST_CHILD_4, LDAP_CONN_HANDLER_ENTRY,
LDAPS_CONN_HANDLER_ENTRY);
ServerManagementContext context =
- new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ new ServerManagementContext(configRepository);
TestParentCfg parentCfg = getParentCfg(TEST_PARENT_1, context);
TestChildCfg testChildCfg = parentCfg.getTestChild(entryName(TEST_CHILD_4));
@@ -487,7 +486,7 @@
ConfigurationRepository configRepository =
createConfigRepositoryWithEntries(TEST_PARENT_1, TEST_CHILD_2, LDAP_CONN_HANDLER_ENTRY);
ServerManagementContext context =
- new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ new ServerManagementContext(configRepository);
TestParentCfg parentCfg = getParentCfg(TEST_PARENT_1, context);
TestChildCfg testChildCfg = parentCfg.getTestChild(entryName(TEST_CHILD_2));
@@ -513,7 +512,7 @@
createConfigRepositoryWithEntries(TEST_PARENTS, TEST_PARENT_1, TEST_BASE_CHILD, TEST_CHILD_7,
CONN_HANDLER_ENTRY, TEST_CONNECTION_HANDLER_ENTRY_ENABLED);
ServerManagementContext context =
- new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ new ServerManagementContext(configRepository);
registerAggregationDefinitionWithTargetEnabled();
@@ -551,7 +550,7 @@
createConfigRepositoryWithEntries(TEST_PARENTS, TEST_PARENT_1, TEST_BASE_CHILD, TEST_CHILD_7,
CONN_HANDLER_ENTRY, TEST_CONNECTION_HANDLER_ENTRY_ENABLED);
ServerManagementContext context =
- new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ new ServerManagementContext(configRepository);
registerAggregationDefinitionWithTargetEnabled();
diff --git a/opendj-config/src/test/java/org/forgerock/opendj/config/server/ConstraintTest.java b/opendj-config/src/test/java/org/forgerock/opendj/config/server/ConstraintTest.java
index 1dcc9df..078f9bc 100644
--- a/opendj-config/src/test/java/org/forgerock/opendj/config/server/ConstraintTest.java
+++ b/opendj-config/src/test/java/org/forgerock/opendj/config/server/ConstraintTest.java
@@ -36,7 +36,6 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.LocalizableMessageBuilder;
import org.forgerock.opendj.config.AdminTestCase;
-import org.forgerock.opendj.config.PropertyDefinitionsOptions;
import org.forgerock.opendj.config.TestCfg;
import org.forgerock.opendj.config.TestChildCfg;
import org.forgerock.opendj.config.TestChildCfgDefn;
@@ -146,7 +145,7 @@
ConfigurationRepository configRepository =
createConfigRepositoryWithEntries(TEST_PARENT_1, TEST_BASE_CHILD, TEST_CHILD_1);
ServerManagementContext context =
- new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ new ServerManagementContext(configRepository);
MockConstraint constraint = new MockConstraint(true, false, configRepository);
try {
TestCfg.addConstraint(constraint);
@@ -165,7 +164,7 @@
ConfigurationRepository configRepository =
createConfigRepositoryWithEntries(TEST_PARENT_1, TEST_BASE_CHILD, TEST_CHILD_1);
ServerManagementContext context =
- new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ new ServerManagementContext(configRepository);
MockConstraint constraint = new MockConstraint(false, true, configRepository);
try {
TestCfg.addConstraint(constraint);
@@ -202,7 +201,7 @@
ConfigurationRepository configRepository =
createConfigRepositoryWithEntries(TEST_PARENT_1, TEST_BASE_CHILD, TEST_CHILD_1);
ServerManagementContext context =
- new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ new ServerManagementContext(configRepository);
TestParentCfg parentCfg = getParentCfg(TEST_PARENT_1, context);
parentCfg.addTestChildAddListener(new AddListener());
MockConstraint constraint = new MockConstraint(isUsableConstraint, false, configRepository);
@@ -225,7 +224,7 @@
ConfigurationRepository configRepository =
createConfigRepositoryWithEntries(TEST_PARENT_1, TEST_BASE_CHILD, TEST_CHILD_1);
ServerManagementContext context =
- new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ new ServerManagementContext(configRepository);
TestParentCfg parentCfg = getParentCfg(TEST_PARENT_1, context);
parentCfg.addTestChildDeleteListener(new DeleteListener());
MockConstraint constraint = new MockConstraint(false, isDeleteAllowedConstraint, configRepository);
@@ -248,7 +247,7 @@
ConfigurationRepository configRepository =
createConfigRepositoryWithEntries(TEST_PARENT_1, TEST_BASE_CHILD, TEST_CHILD_1);
ServerManagementContext context =
- new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ new ServerManagementContext(configRepository);
MockConstraint constraint = new MockConstraint(isUsableConstraint, false, configRepository);
TestParentCfg parentCfg = getParentCfg(TEST_PARENT_1, context);
TestChildCfg childCfg = parentCfg.getTestChild(entryName(TEST_CHILD_1));
diff --git a/opendj-config/src/test/java/org/forgerock/opendj/config/server/DefaultBehaviorTest.java b/opendj-config/src/test/java/org/forgerock/opendj/config/server/DefaultBehaviorTest.java
index a3f9d60..9f3092d 100644
--- a/opendj-config/src/test/java/org/forgerock/opendj/config/server/DefaultBehaviorTest.java
+++ b/opendj-config/src/test/java/org/forgerock/opendj/config/server/DefaultBehaviorTest.java
@@ -39,7 +39,6 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.LocalizableMessageBuilder;
import org.forgerock.opendj.config.AdminTestCase;
-import org.forgerock.opendj.config.PropertyDefinitionsOptions;
import org.forgerock.opendj.config.TestCfg;
import org.forgerock.opendj.config.TestChildCfg;
import org.forgerock.opendj.config.TestParentCfg;
@@ -266,7 +265,7 @@
ConfigurationRepository configRepository =
createConfigRepositoryWithEntries(testParent, testBaseChild, testChild);
ServerManagementContext context =
- new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ new ServerManagementContext(configRepository);
TestParentCfg parentCfg = getParentCfg(testParent, context);
// assert
@@ -285,7 +284,7 @@
ConfigurationRepository configRepository =
createConfigRepositoryWithEntries(testParent, testBaseChild, testChild);
ServerManagementContext context =
- new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ new ServerManagementContext(configRepository);
TestParentCfg parentCfg = getParentCfg(testParent, context);
TestConfigurationAddListener addListener = new TestConfigurationAddListener();
parentCfg.addTestChildAddListener(addListener);
@@ -332,7 +331,7 @@
ConfigurationRepository configRepository =
createConfigRepositoryWithEntries(TEST_PARENT_1, TEST_CHILD_BASE_1, TEST_CHILD_1);
ServerManagementContext context =
- new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ new ServerManagementContext(configRepository);
TestParentCfg parentCfg = getParentCfg(TEST_PARENT_1, context);
TestChildCfg childCfg = parentCfg.getTestChild(entryName(TEST_CHILD_1));
TestConfigurationChangeListener changeListener = new TestConfigurationChangeListener();
@@ -362,7 +361,7 @@
public void testParentValues(Entry parentEntry, List<String> valuesForOptionalDNProperty) throws Exception {
ConfigurationRepository configRepository = createConfigRepositoryWithEntries(parentEntry);
ServerManagementContext context =
- new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ new ServerManagementContext(configRepository);
TestParentCfg parent = getParentCfg(parentEntry, context);
assertThat(parent.getMandatoryClassProperty()).isEqualTo(
diff --git a/opendj-config/src/test/java/org/forgerock/opendj/config/server/ListenerTest.java b/opendj-config/src/test/java/org/forgerock/opendj/config/server/ListenerTest.java
index 40b963e..d330fdb 100644
--- a/opendj-config/src/test/java/org/forgerock/opendj/config/server/ListenerTest.java
+++ b/opendj-config/src/test/java/org/forgerock/opendj/config/server/ListenerTest.java
@@ -37,7 +37,6 @@
import java.util.Arrays;
import org.forgerock.opendj.config.AdminTestCase;
-import org.forgerock.opendj.config.PropertyDefinitionsOptions;
import org.forgerock.opendj.config.TestCfg;
import org.forgerock.opendj.config.TestParentCfg;
import org.forgerock.opendj.config.server.spi.ConfigAddListener;
@@ -115,7 +114,7 @@
public void testRegisterAddListenerWithInstantiableRelationImmediate() throws Exception {
ConfigurationRepository configRepository = createConfigRepositoryWithDNs(ROOT_CONFIG_DN, TEST_PARENTS_DN);
ServerManagementContext context =
- new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ new ServerManagementContext(configRepository);
ServerManagedObject<RootCfg> root = context.getRootConfigurationManagedObject();
root.registerAddListener(TestCfg.getTestOneToManyParentRelationDefinition(),
@@ -128,7 +127,7 @@
public void testRegisterAddListenerWithInstantiableRelationDelayed() throws Exception {
ConfigurationRepository configRepository = createConfigRepositoryWithDNs(ROOT_CONFIG_DN);
ServerManagementContext context =
- new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ new ServerManagementContext(configRepository);
ServerManagedObject<RootCfg> root = context.getRootConfigurationManagedObject();
ConfigurationAddListener<TestParentCfg> parentListener = mock(ConfigurationAddListener.class);
@@ -148,7 +147,7 @@
public void testRegisterAddListenerWithInstantiableRelationDelayedThenActualized() throws Exception {
ConfigurationRepository configRepository = createConfigRepositoryWithDNs(ROOT_CONFIG_DN);
ServerManagementContext context =
- new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ new ServerManagementContext(configRepository);
ServerManagedObject<RootCfg> root = context.getRootConfigurationManagedObject();
// register a listener to root
@@ -176,7 +175,7 @@
public void testRegisterAddListenerWithOptionalRelation() throws Exception {
ConfigurationRepository configRepository = createConfigRepositoryWithDNs(ROOT_CONFIG_DN);
ServerManagementContext context =
- new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ new ServerManagementContext(configRepository);
ServerManagedObject<RootCfg> root = context.getRootConfigurationManagedObject();
root.registerAddListener(TestCfg.getTestOneToZeroOrOneParentRelationDefinition(),
@@ -189,7 +188,7 @@
public void testRegisterDeleteListenerWithInstantiableRelationImmediate() throws Exception {
ConfigurationRepository configRepository = createConfigRepositoryWithDNs(ROOT_CONFIG_DN, TEST_PARENTS_DN);
ServerManagementContext context =
- new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ new ServerManagementContext(configRepository);
ServerManagedObject<RootCfg> root = context.getRootConfigurationManagedObject();
root.registerDeleteListener(TestCfg.getTestOneToManyParentRelationDefinition(),
@@ -202,7 +201,7 @@
public void testRegisterDeleteListenerWithInstantiableRelationDelayed() throws Exception {
ConfigurationRepository configRepository = createConfigRepositoryWithDNs(ROOT_CONFIG_DN);
ServerManagementContext context =
- new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ new ServerManagementContext(configRepository);
ServerManagedObject<RootCfg> root = context.getRootConfigurationManagedObject();
ConfigurationDeleteListener<TestParentCfg> parentListener = mock(ConfigurationDeleteListener.class);
@@ -222,7 +221,7 @@
public void testRegisterDeleteListenerWithOptionalRelation() throws Exception {
ConfigurationRepository configRepository = createConfigRepositoryWithDNs(ROOT_CONFIG_DN);
ServerManagementContext context =
- new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ new ServerManagementContext(configRepository);
ServerManagedObject<RootCfg> root = context.getRootConfigurationManagedObject();
root.registerDeleteListener(TestCfg.getTestOneToZeroOrOneParentRelationDefinition(),
@@ -235,7 +234,7 @@
public void testRegisterChangeListener() throws Exception {
ConfigurationRepository configRepository = createConfigRepositoryWithDNs(ROOT_CONFIG_DN);
ServerManagementContext context =
- new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ new ServerManagementContext(configRepository);
ServerManagedObject<RootCfg> root = context.getRootConfigurationManagedObject();
root.setConfigDN(ROOT_CONFIG_DN);
@@ -249,7 +248,7 @@
// arrange
ConfigurationRepository configRepository = createConfigRepositoryWithDNs(ROOT_CONFIG_DN, TEST_PARENTS_DN);
ServerManagementContext context =
- new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ new ServerManagementContext(configRepository);
ServerManagedObject<RootCfg> root = context.getRootConfigurationManagedObject();
ConfigurationAddListener<TestParentCfg> parentListener = mock(ConfigurationAddListener.class);
@@ -269,7 +268,7 @@
// arrange
ConfigurationRepository configRepository = createConfigRepositoryWithDNs(ROOT_CONFIG_DN);
ServerManagementContext context =
- new ServerManagementContext(configRepository, PropertyDefinitionsOptions.NO_VALIDATION_OPTIONS);
+ new ServerManagementContext(configRepository);
ServerManagedObject<RootCfg> root = context.getRootConfigurationManagedObject();
ConfigurationAddListener<TestParentCfg> parentListener = mock(ConfigurationAddListener.class);
--
Gitblit v1.10.0