/* * 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 * trunk/opends/resource/legal-notices/OpenDS.LICENSE * or https://OpenDS.dev.java.net/OpenDS.LICENSE. * 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 * trunk/opends/resource/legal-notices/OpenDS.LICENSE. 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 * * * Portions Copyright 2007 Sun Microsystems, Inc. */ package org.opends.server.admin; import static org.opends.messages.AdminMessages.*; import static org.opends.server.util.Validator.*; import java.util.Collection; import java.util.Collections; import java.util.EnumSet; import java.util.SortedSet; import org.opends.messages.Message; import org.opends.server.admin.client.ClientConstraintHandler; import org.opends.server.admin.server.ServerConstraintHandler; import org.opends.server.admin.server.ServerManagedObject; import org.opends.server.admin.server.ServerManagementContext; import org.opends.server.config.ConfigException; import org.opends.server.types.DN; /** * Aggregation property definition. *
* An aggregation property names one or more managed objects which are * required by the managed object associated with this property. An * aggregation property definition takes care to perform referential * integrity checks: referenced managed objects cannot be deleted. Nor * can an aggregation reference non-existent managed objects. * Referential integrity checks are not performed during value * validation. Instead they are performed when changes to the managed * object are committed. *
* An aggregation property definition can optionally identify two * properties: *
enabled property in the aggregated managed
* object - the property must be a {@link BooleanPropertyDefinition}
* and indicate whether the aggregated managed object is enabled or
* not. If specified, the administration framework will prevent the
* aggregated managed object from being disabled while it is
* referenced
* enabled property in this property's managed
* object - the property must be a {@link BooleanPropertyDefinition}
* and indicate whether this property's managed object is enabled or
* not. If specified, and as long as there is an equivalent
* enabled property defined for the aggregated managed
* object, the enabled property in the aggregated
* managed object will only be checked when this property is true.
*
* This must be defined before the property definition can be
* built.
*
* @param d
* The definition of the type of referenced managed
* objects.
*/
public final void setManagedObjectDefinition(
AbstractManagedObjectDefinition
* This must be defined before the property definition can be
* built.
*
* @param p
* The name of the managed object which is the parent of
* the aggregated managed objects.
*/
public final void setParentPath(ManagedObjectPath, ?> p) {
this.p = p;
}
/**
* Sets the relation in the parent managed object which contains
* the aggregated managed objects.
*
* This must be defined before the property definition can be
* built.
*
* @param rdName
* The name of a relation in the parent managed object
* which contains the aggregated managed objects.
*/
public final void setRelationDefinition(String rdName) {
this.rdName = rdName;
}
/**
* Sets the optional boolean "enabled" property in this managed
* object. When this property is true, the enabled property in the
* aggregated managed object must also be true.
*
* By default no source property is defined. When it is defined,
* the target property must also be defined.
*
* @param sourceEnabledPropertyName
* The optional boolean "enabled" property in this
* managed object.
*/
public final void setSourceEnabledPropertyName(
String sourceEnabledPropertyName) {
this.sourceEnabledPropertyName = sourceEnabledPropertyName;
}
/**
* Sets the optional boolean "enabled" property in the aggregated
* managed object. This property must not be false while the
* aggregated managed object is referenced.
*
* By default no target property is defined. It must be defined,
* if the source property is defined.
*
* @param targetEnabledPropertyName
* The optional boolean "enabled" property in the
* aggregated managed object.
*/
public final void setTargetEnabledPropertyName(
String targetEnabledPropertyName) {
this.targetEnabledPropertyName = targetEnabledPropertyName;
}
/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
@Override
protected AggregationPropertyDefinition
* The type of server managed object configuration that
* this aggregation property definition refers to.
* @param d
* The managed object definition associated with this
* property definition.
* @param propertyName
* The property name.
* @return Returns the new aggregation property definition builder.
*/
public static null if none is
* defined.
* @throws IllegalArgumentException
* If the named property does not exist in this property's
* associated managed object definition.
* @throws ClassCastException
* If the named property does exist but is not a
* {@link BooleanPropertyDefinition}.
*/
public final BooleanPropertyDefinition getSourceEnabledPropertyDefinition()
throws IllegalArgumentException, ClassCastException {
if (sourceEnabledPropertyName == null) {
return null;
}
AbstractManagedObjectDefinition, ?> d = getManagedObjectDefinition();
PropertyDefinition> pd;
pd = d.getPropertyDefinition(sourceEnabledPropertyName);
// Runtime cast is required to workaround a
// bug in JDK versions prior to 1.5.0_08.
return BooleanPropertyDefinition.class.cast(pd);
}
/**
* Gets the optional boolean "enabled" property in the aggregated
* managed object. This property must not be false while the
* aggregated managed object is referenced.
*
* @return Returns the optional boolean "enabled" property in the
* aggregated managed object, or null if none
* is defined.
* @throws IllegalArgumentException
* If the named property does not exist in the aggregated
* managed object's definition.
* @throws ClassCastException
* If the named property does exist but is not a
* {@link BooleanPropertyDefinition}.
*/
public final BooleanPropertyDefinition getTargetEnabledPropertyDefinition()
throws IllegalArgumentException, ClassCastException {
if (targetEnabledPropertyName == null) {
return null;
}
AbstractManagedObjectDefinition, ?> d;
PropertyDefinition> pd;
d = relationDefinition.getChildDefinition();
pd = d.getPropertyDefinition(targetEnabledPropertyName);
// Runtime cast is required to workaround a
// bug in JDK versions prior to 1.5.0_08.
return BooleanPropertyDefinition.class.cast(pd);
}
/**
* {@inheritDoc}
*/
@Override
public String normalizeValue(String value)
throws IllegalPropertyValueException {
try {
Reference