From 12f788c17b8c281179f0819352f02b612b0219e2 Mon Sep 17 00:00:00 2001
From: matthew_swift <matthew_swift@localhost>
Date: Mon, 02 Feb 2009 23:37:54 +0000
Subject: [PATCH] Fix issue 3734 - Make network group policies extensible.
---
opendj-sdk/opends/src/server/org/opends/server/admin/client/spi/AbstractManagedObject.java | 134 ++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 133 insertions(+), 1 deletions(-)
diff --git a/opendj-sdk/opends/src/server/org/opends/server/admin/client/spi/AbstractManagedObject.java b/opendj-sdk/opends/src/server/org/opends/server/admin/client/spi/AbstractManagedObject.java
index 0f1902b..947256d 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/admin/client/spi/AbstractManagedObject.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/admin/client/spi/AbstractManagedObject.java
@@ -22,7 +22,7 @@
* CDDL HEADER END
*
*
- * Copyright 2008 Sun Microsystems, Inc.
+ * Copyright 2008-2009 Sun Microsystems, Inc.
*/
package org.opends.server.admin.client.spi;
@@ -59,7 +59,9 @@
import org.opends.server.admin.PropertyOption;
import org.opends.server.admin.RelationDefinition;
import org.opends.server.admin.RelationDefinitionVisitor;
+import org.opends.server.admin.SetRelationDefinition;
import org.opends.server.admin.SingletonRelationDefinition;
+import org.opends.server.admin.DefinitionDecodingException.Reason;
import org.opends.server.admin.client.AuthorizationException;
import org.opends.server.admin.client.ClientConstraintHandler;
import org.opends.server.admin.client.CommunicationException;
@@ -163,6 +165,25 @@
+ /**
+ * {@inheritDoc}
+ */
+ public <C extends ConfigurationClient, S extends Configuration>
+ Void visitSet(
+ SetRelationDefinition<C, S> rd, Void p) {
+ for (String name : rd.getDefaultManagedObjectNames()) {
+ DefaultManagedObject<? extends C, ? extends S> dmo = rd
+ .getDefaultManagedObject(name);
+ ManagedObjectDefinition<? extends C, ? extends S> d = dmo
+ .getManagedObjectDefinition();
+ ManagedObject<? extends C> child = createChild(rd, d, null);
+ createDefaultManagedObject(d, child, dmo);
+ }
+ return null;
+ }
+
+
+
// Create the child managed object.
private void createDefaultManagedObject(ManagedObjectDefinition<?, ?> d,
ManagedObject<?> child, DefaultManagedObject<?, ?> dmo) {
@@ -411,6 +432,24 @@
/**
* {@inheritDoc}
*/
+ public final <C extends ConfigurationClient, S extends Configuration,
+ CC extends C>
+ ManagedObject<CC> createChild(
+ SetRelationDefinition<C, S> r,
+ ManagedObjectDefinition<CC, ? extends S> d,
+ Collection<DefaultBehaviorException> exceptions)
+ throws IllegalArgumentException {
+ validateRelationDefinition(r);
+
+ ManagedObjectPath<CC, ? extends S> childPath = path.child(r, d);
+ return createNewManagedObject(d, childPath, null, null, exceptions);
+ }
+
+
+
+ /**
+ * {@inheritDoc}
+ */
public final <C extends ConfigurationClient, S extends Configuration>
ManagedObject<? extends C> getChild(
InstantiableRelationDefinition<C, S> r, String name)
@@ -463,6 +502,40 @@
/**
* {@inheritDoc}
*/
+ public final <C extends ConfigurationClient, S extends Configuration>
+ ManagedObject<? extends C> getChild(
+ SetRelationDefinition<C, S> r, String name)
+ throws IllegalArgumentException, DefinitionDecodingException,
+ ManagedObjectDecodingException, ManagedObjectNotFoundException,
+ ConcurrentModificationException, AuthorizationException,
+ CommunicationException {
+ validateRelationDefinition(r);
+ ensureThisManagedObjectExists();
+ Driver ctx = getDriver();
+
+ AbstractManagedObjectDefinition<C, S> d = r.getChildDefinition();
+ AbstractManagedObjectDefinition<? extends C, ? extends S> cd;
+
+ try
+ {
+ cd = d.getChild(name);
+ }
+ catch (IllegalArgumentException e)
+ {
+ // Unrecognized definition name - report this as a decoding
+ // exception.
+ throw new DefinitionDecodingException(d,
+ Reason.WRONG_TYPE_INFORMATION);
+ }
+
+ return ctx.getManagedObject(path.child(r, cd));
+ }
+
+
+
+ /**
+ * {@inheritDoc}
+ */
public final T getConfiguration() {
return definition.createClientConfiguration(this);
}
@@ -590,6 +663,39 @@
* {@inheritDoc}
*/
public final <C extends ConfigurationClient, S extends Configuration>
+ String[] listChildren(
+ SetRelationDefinition<C, S> r) throws IllegalArgumentException,
+ ConcurrentModificationException, AuthorizationException,
+ CommunicationException {
+ return listChildren(r, r.getChildDefinition());
+ }
+
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public final <C extends ConfigurationClient, S extends Configuration>
+ String[] listChildren(
+ SetRelationDefinition<C, S> r,
+ AbstractManagedObjectDefinition<? extends C, ? extends S> d)
+ throws IllegalArgumentException, ConcurrentModificationException,
+ AuthorizationException, CommunicationException {
+ validateRelationDefinition(r);
+ Driver ctx = getDriver();
+ try {
+ return ctx.listManagedObjects(path, r, d);
+ } catch (ManagedObjectNotFoundException e) {
+ throw new ConcurrentModificationException();
+ }
+ }
+
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public final <C extends ConfigurationClient, S extends Configuration>
void removeChild(
InstantiableRelationDefinition<C, S> r, String name)
throws IllegalArgumentException, ManagedObjectNotFoundException,
@@ -641,6 +747,32 @@
/**
* {@inheritDoc}
*/
+ public final <C extends ConfigurationClient, S extends Configuration>
+ void removeChild(
+ SetRelationDefinition<C, S> r, String name)
+ throws IllegalArgumentException, ManagedObjectNotFoundException,
+ OperationRejectedException, ConcurrentModificationException,
+ AuthorizationException, CommunicationException {
+ validateRelationDefinition(r);
+ Driver ctx = getDriver();
+ boolean found;
+
+ try {
+ found = ctx.deleteManagedObject(path, r, name);
+ } catch (ManagedObjectNotFoundException e) {
+ throw new ConcurrentModificationException();
+ }
+
+ if (!found) {
+ throw new ManagedObjectNotFoundException();
+ }
+ }
+
+
+
+ /**
+ * {@inheritDoc}
+ */
public final <PD> void setPropertyValue(PropertyDefinition<PD> pd, PD value)
throws IllegalPropertyValueException, PropertyIsReadOnlyException,
PropertyIsMandatoryException, IllegalArgumentException {
--
Gitblit v1.10.0