From 8532a5133e996e61765be126f8b4d25984745fd1 Mon Sep 17 00:00:00 2001
From: matthew_swift <matthew_swift@localhost>
Date: Mon, 03 Sep 2007 13:33:50 +0000
Subject: [PATCH] Partial fix for issue 1451: admin framework constraint and dependency support.
---
opends/src/server/org/opends/server/admin/AbstractManagedObjectDefinition.java | 73 ++++++++++++++++++++++++++++++++++++
1 files changed, 72 insertions(+), 1 deletions(-)
diff --git a/opends/src/server/org/opends/server/admin/AbstractManagedObjectDefinition.java b/opends/src/server/org/opends/server/admin/AbstractManagedObjectDefinition.java
index 2c7769f..8d6c75e 100644
--- a/opends/src/server/org/opends/server/admin/AbstractManagedObjectDefinition.java
+++ b/opends/src/server/org/opends/server/admin/AbstractManagedObjectDefinition.java
@@ -26,7 +26,6 @@
*/
package org.opends.server.admin;
-import org.opends.messages.Message;
@@ -35,12 +34,14 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.MissingResourceException;
import java.util.Set;
+import org.opends.messages.Message;
import org.opends.server.admin.DefinitionDecodingException.Reason;
@@ -68,6 +69,10 @@
// The parent managed object definition if applicable.
private final AbstractManagedObjectDefinition<? super C, ? super S> parent;
+ // The set of constraints associated with this managed object
+ // definition.
+ private final Collection<Constraint> constraints;
+
// The set of property definitions applicable to this managed object
// definition.
private final Map<String, PropertyDefinition<?>> propertyDefinitions;
@@ -76,6 +81,10 @@
// definition.
private final Map<String, RelationDefinition<?, ?>> relationDefinitions;
+ // The set of all constraints associated with this managed object
+ // definition including inherited constraints.
+ private final Collection<Constraint> allConstraints;
+
// The set of all property definitions associated with this managed
// object definition including inherited property definitions.
private final Map<String, PropertyDefinition<?>> allPropertyDefinitions;
@@ -106,8 +115,10 @@
AbstractManagedObjectDefinition<? super C, ? super S> parent) {
this.name = name;
this.parent = parent;
+ this.constraints = new LinkedList<Constraint>();
this.propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
this.relationDefinitions = new HashMap<String, RelationDefinition<?,?>>();
+ this.allConstraints = new LinkedList<Constraint>();
this.allPropertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
this.allRelationDefinitions =
new HashMap<String, RelationDefinition<?, ?>>();
@@ -119,6 +130,8 @@
if (parent != null) {
parent.children.put(name, this);
+ allConstraints.addAll(parent.getAllConstraints());
+
for (PropertyDefinition<?> pd : parent.getAllPropertyDefinitions()) {
allPropertyDefinitions.put(pd.getName(), pd);
}
@@ -158,6 +171,20 @@
/**
+ * Get all the constraints associated with this type of managed
+ * object. The returned collection will contain inherited
+ * constraints.
+ *
+ * @return Returns an unmodifiable collection containing all the
+ * constraints associated with this type of managed object.
+ */
+ public final Collection<Constraint> getAllConstraints() {
+ return Collections.unmodifiableCollection(allConstraints);
+ }
+
+
+
+ /**
* Get all the property definitions associated with this type of
* managed object. The returned collection will contain inherited
* property definitions.
@@ -263,6 +290,19 @@
/**
+ * Get the constraints defined by this managed object definition.
+ * The returned collection will not contain inherited constraints.
+ *
+ * @return Returns an unmodifiable collection containing the
+ * constraints defined by this managed object definition.
+ */
+ public final Collection<Constraint> getConstraints() {
+ return Collections.unmodifiableCollection(constraints);
+ }
+
+
+
+ /**
* Gets the optional description of this managed object definition
* in the default locale.
*
@@ -635,6 +675,22 @@
/**
+ * Deregister a constraint from the managed object definition.
+ * <p>
+ * This method <b>must not</b> be called by applications and is
+ * only intended for internal testing.
+ *
+ * @param constraint
+ * The constraint to be deregistered.
+ */
+ protected final void deregisterConstraint(Constraint constraint) {
+ constraints.remove(constraint);
+ allConstraints.remove(constraint);
+ }
+
+
+
+ /**
* Deregister a relation definition from the managed object
* definition.
* <p>
@@ -655,6 +711,21 @@
/**
+ * Register a constraint with the managed object definition.
+ * <p>
+ * This method <b>must not</b> be called by applications.
+ *
+ * @param constraint
+ * The constraint to be registered.
+ */
+ protected final void registerConstraint(Constraint constraint) {
+ constraints.add(constraint);
+ allConstraints.add(constraint);
+ }
+
+
+
+ /**
* Register a property definition with the managed object definition,
* overriding any existing property definition with the same name.
* <p>
--
Gitblit v1.10.0