Fix issues 1966 and 1792.
Add support for hiding relations and, using this feature, prevent users from access root DN user configurations through the CLI.
To make it easier to add new features to relation definitions in the future I have refactored the RelationDefinition classes so that they provide a Builder API for incrementally constructing new definitions.
1 files added
12 files modified
| | |
| | | </xsd:documentation> |
| | | </xsd:annotation> |
| | | </xsd:attribute> |
| | | <xsd:attribute name="hidden" type="xsd:boolean" use="optional" |
| | | default="false"> |
| | | <xsd:annotation> |
| | | <xsd:documentation> |
| | | Indicates whether or not this relation should be hidden from |
| | | client applications. Hidden relations should rarely be used |
| | | but are sometimes required in order to provide functionality |
| | | that needs to be exposed in management APIs but not in |
| | | front-ends such as CLIs. |
| | | </xsd:documentation> |
| | | </xsd:annotation> |
| | | </xsd:attribute> |
| | | </xsd:complexType> |
| | | <xsd:complexType name="admin-action-type"> |
| | | <xsd:annotation> |
| | |
| | | <xsl:with-param name="value" select="@managed-object-name" /> |
| | | </xsl:call-template> |
| | | </xsl:variable> |
| | | <xsl:variable name="java-relation-builder-type"> |
| | | <xsl:choose> |
| | | <xsl:when test="adm:one-to-one"> |
| | | <xsl:text>SingletonRelationDefinition</xsl:text> |
| | | </xsl:when> |
| | | <xsl:when test="adm:one-to-zero-or-one"> |
| | | <xsl:text>OptionalRelationDefinition</xsl:text> |
| | | </xsl:when> |
| | | <xsl:when test="adm:one-to-many"> |
| | | <xsl:text>InstantiableRelationDefinition</xsl:text> |
| | | </xsl:when> |
| | | <xsl:otherwise> |
| | | <xsl:message terminate="yes"> |
| | | <xsl:value-of |
| | | select="concat('Unknown relation type "', local-name(*), '" in relation "', @name, '".')" /> |
| | | </xsl:message> |
| | | </xsl:otherwise> |
| | | </xsl:choose> |
| | | <xsl:value-of |
| | | select="concat('.Builder<', $java-managed-object-name, 'CfgClient, ', $java-managed-object-name, 'Cfg>')" /> |
| | | </xsl:variable> |
| | | <xsl:value-of |
| | | select="concat(' // Build the "', $relation-name, '" relation definition.
', |
| | | ' static {
', |
| | | ' RD_', $java-relation-name, ' = new ')" /> |
| | | <xsl:choose> |
| | | <xsl:when test="adm:one-to-one"> |
| | | <xsl:text>SingletonRelationDefinition<</xsl:text> |
| | | </xsl:when> |
| | | <xsl:when test="adm:one-to-zero-or-one"> |
| | | <xsl:text>OptionalRelationDefinition<</xsl:text> |
| | | </xsl:when> |
| | | <xsl:when test="adm:one-to-many"> |
| | | <xsl:text>InstantiableRelationDefinition<</xsl:text> |
| | | </xsl:when> |
| | | <xsl:otherwise> |
| | | <xsl:message terminate="yes"> |
| | | <xsl:value-of |
| | | select="concat('Unknown relation type "', local-name(*), '" in relation "', @name, '".')" /> |
| | | </xsl:message> |
| | | </xsl:otherwise> |
| | | </xsl:choose> |
| | | <xsl:value-of |
| | | select="concat($java-managed-object-name, 'CfgClient, ', $java-managed-object-name, 'Cfg>(
', |
| | | ' INSTANCE, "', @name, '", ')" /> |
| | | ' ', $java-relation-builder-type, ' builder =
', |
| | | ' new ', $java-relation-builder-type, '(INSTANCE, "', @name, '", ')" /> |
| | | <xsl:if test="adm:one-to-many"> |
| | | <xsl:value-of |
| | | select="concat('"', adm:one-to-many/@plural-name, '", ')" /> |
| | | </xsl:if> |
| | | <xsl:value-of |
| | | select="concat($java-managed-object-name, 'CfgDefn.getInstance()')" /> |
| | | <xsl:if test="adm:one-to-many"> |
| | | <xsl:value-of select="', '" /> |
| | | <xsl:choose> |
| | | <xsl:when test="adm:one-to-many/@naming-property"> |
| | | <xsl:variable name="java-property-name"> |
| | | <xsl:call-template name="name-to-java"> |
| | | <xsl:with-param name="value" |
| | | select="adm:one-to-many/@naming-property" /> |
| | | </xsl:call-template> |
| | | </xsl:variable> |
| | | <xsl:value-of |
| | | select="concat($java-managed-object-name, |
| | | select="concat($java-managed-object-name, 'CfgDefn.getInstance());
')" /> |
| | | <xsl:if test="adm:one-to-many/@naming-property"> |
| | | <xsl:variable name="java-property-name"> |
| | | <xsl:call-template name="name-to-java"> |
| | | <xsl:with-param name="value" |
| | | select="adm:one-to-many/@naming-property" /> |
| | | </xsl:call-template> |
| | | </xsl:variable> |
| | | <xsl:value-of |
| | | select="concat(' builder.setNamingProperty(', |
| | | $java-managed-object-name, |
| | | 'CfgDefn.getInstance().get', |
| | | $java-property-name, 'PropertyDefinition()')" /> |
| | | </xsl:when> |
| | | <xsl:otherwise> |
| | | <xsl:value-of select="'null'" /> |
| | | </xsl:otherwise> |
| | | </xsl:choose> |
| | | $java-property-name, 'PropertyDefinition());
')" /> |
| | | </xsl:if> |
| | | <xsl:value-of select="');
'" /> |
| | | <xsl:if test="@hidden='true'"> |
| | | <xsl:value-of |
| | | select="' builder.setOption(RelationOption.HIDDEN);
'" /> |
| | | </xsl:if> |
| | | <xsl:value-of |
| | | select="concat(' RD_', $java-relation-name, ' = builder.getInstance();
')" /> |
| | | <xsl:value-of |
| | | select="concat(' INSTANCE.registerRelationDefinition(RD_', $java-relation-name,');
')" /> |
| | | <xsl:value-of select="' }
'" /> |
| | |
| | | select="concat(@managed-object-package, '.server.', $java-class-name, 'Cfg')" /> |
| | | </xsl:element> |
| | | </xsl:for-each> |
| | | <xsl:if |
| | | test="$this-local-relations[@hidden='true']"> |
| | | <import>org.opends.server.admin.RelationOption</import> |
| | | </xsl:if> |
| | | <xsl:if test="$this-all-relations/adm:one-to-many"> |
| | | <import> |
| | | org.opends.server.admin.InstantiableRelationDefinition |
| | |
| | | </ldap:object-class> |
| | | </adm:profile> |
| | | |
| | | <adm:relation name="root-dn-user"> |
| | | <adm:relation name="root-dn-user" hidden="true"> |
| | | <adm:one-to-many /> |
| | | <adm:profile name="ldap"> |
| | | <ldap:rdn-sequence /> |
| | |
| | | |
| | | |
| | | |
| | | import static org.opends.server.util.Validator.ensureNotNull; |
| | | import static org.opends.server.util.Validator.*; |
| | | |
| | | |
| | | |
| | |
| | | <C extends ConfigurationClient, S extends Configuration> |
| | | extends RelationDefinition<C, S> { |
| | | |
| | | // The plural name of the relation. |
| | | private final String pluralName; |
| | | /** |
| | | * An interface for incrementally constructing aggregation relation |
| | | * definitions. |
| | | * |
| | | * @param <C> |
| | | * The type of client managed object configuration that |
| | | * this relation definition refers to. |
| | | * @param <S> |
| | | * The type of server managed object configuration that |
| | | * this relation definition refers to. |
| | | */ |
| | | public static class Builder |
| | | <C extends ConfigurationClient, S extends Configuration> |
| | | extends AbstractBuilder<C, S, AggregationRelationDefinition<C, S>> { |
| | | |
| | | // The maximum number of referenced managed objects. |
| | | private int maxOccurs = 0; |
| | | |
| | | // The minimum number of referenced managed objects. |
| | | private int minOccurs = 0; |
| | | |
| | | // The path identifying the location of the referenced managed |
| | | // objects. |
| | | private ManagedObjectPath path; |
| | | |
| | | // The plural name of the relation. |
| | | private final String pluralName; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Creates a new builder which can be used to incrementally build |
| | | * an aggregation relation definition. |
| | | * |
| | | * @param pd |
| | | * The parent managed object definition. |
| | | * @param name |
| | | * The name of the relation. |
| | | * @param pluralName |
| | | * The plural name of the relation. |
| | | * @param cd |
| | | * The child managed object definition. |
| | | */ |
| | | public Builder(AbstractManagedObjectDefinition<?, ?> pd, String name, |
| | | String pluralName, AbstractManagedObjectDefinition<C, S> cd) { |
| | | super(pd, name, cd); |
| | | this.pluralName = pluralName; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Set the maximum number of referenced managed objects. |
| | | * |
| | | * @param maxOccurs |
| | | * The maximum number of referenced managed objects (or |
| | | * zero if there is no upper limit). |
| | | */ |
| | | public void setMaxOccurs(int maxOccurs) { |
| | | this.maxOccurs = maxOccurs; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Set the minimum number of referenced managed objects. |
| | | * |
| | | * @param minOccurs |
| | | * The minimum number of referenced managed objects. |
| | | */ |
| | | public void setMinOccurs(int minOccurs) { |
| | | this.minOccurs = minOccurs; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Set the path identifying the location of the referenced managed |
| | | * objects. |
| | | * |
| | | * @param path |
| | | * The path identifying the location of the referenced |
| | | * managed objects. |
| | | */ |
| | | public void setPath(ManagedObjectPath path) { |
| | | this.path = path; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | protected AggregationRelationDefinition<C, S> buildInstance( |
| | | Common<C, S> common) { |
| | | return new AggregationRelationDefinition<C, S>(common, pluralName, path, |
| | | minOccurs, maxOccurs); |
| | | } |
| | | |
| | | } |
| | | |
| | | // The maximum number of referenced managed objects. |
| | | private final int maxOccurs; |
| | | |
| | | // The minimum number of referenced managed objects. |
| | | private final int minOccurs; |
| | | |
| | | // The path identifying the location of the referenced managed |
| | | // objects. |
| | | private final ManagedObjectPath path; |
| | | |
| | | // The minimum number of referenced managed objects. |
| | | private final int minOccurs; |
| | | |
| | | // The maximum number of referenced managed objects. |
| | | private final int maxOccurs; |
| | | // The plural name of the relation. |
| | | private final String pluralName; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Create a new aggregation managed object relation definition. |
| | | * |
| | | * @param pd |
| | | * The parent managed object definition. |
| | | * @param name |
| | | * The name of this relation. |
| | | * @param pluralName |
| | | * The plural name of the relation. |
| | | * @param cd |
| | | * The child managed object definition. |
| | | * @param path |
| | | * The path identifying the location of the referenced |
| | | * managed objects. |
| | | * @param minOccurs |
| | | * The minimum number of referenced managed objects. |
| | | * @param maxOccurs |
| | | * The maximum number of referenced managed objects (or |
| | | * zero if there is no upper limit). |
| | | * @throws IllegalArgumentException |
| | | * If minOccurs is less than zero or maxOccurs is less |
| | | * than minOccurs. |
| | | */ |
| | | public AggregationRelationDefinition( |
| | | AbstractManagedObjectDefinition<?, ?> pd, String name, String pluralName, |
| | | AbstractManagedObjectDefinition<C, S> cd, |
| | | // Private constructor. |
| | | private AggregationRelationDefinition(Common<C, S> common, String pluralName, |
| | | ManagedObjectPath path, int minOccurs, int maxOccurs) |
| | | throws IllegalArgumentException { |
| | | super(pd, name, cd); |
| | | super(common); |
| | | |
| | | ensureNotNull(path); |
| | | |
| | | if (minOccurs < 0) { |
| | | throw new IllegalArgumentException( |
| | | "minOccurs is less than zero"); |
| | | throw new IllegalArgumentException("minOccurs is less than zero"); |
| | | } |
| | | |
| | | if (maxOccurs != 0 && maxOccurs < minOccurs) { |
| | | throw new IllegalArgumentException( |
| | | "maxOccurs is less than minOccurs"); |
| | | throw new IllegalArgumentException("maxOccurs is less than minOccurs"); |
| | | } |
| | | |
| | | this.pluralName = pluralName; |
| | |
| | | |
| | | |
| | | /** |
| | | * Get the plural name of the relation. |
| | | * |
| | | * @return Returns the plural name of the relation. |
| | | * {@inheritDoc} |
| | | */ |
| | | public final String getPluralName() { |
| | | return pluralName; |
| | | @Override |
| | | public <R, P> R accept(RelationDefinitionVisitor<R, P> v, P p) { |
| | | return v.visitAggregation(this, p); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Get the maximum number of referenced managed objects. |
| | | * |
| | | * @return Returns the maximum number of referenced managed objects |
| | | * (or zero if there is no upper limit). |
| | | */ |
| | | public int getMaxOccurs() { |
| | | return maxOccurs; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Get the minimum number of referenced managed objects. |
| | | * |
| | | * @return Returns the minimum number of referenced managed objects. |
| | | */ |
| | | public int getMinOccurs() { |
| | | return minOccurs; |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | |
| | | /** |
| | | * Get the minimum number of referenced managed objects. |
| | | * Get the plural name of the relation. |
| | | * |
| | | * @return Returns the minimum number of referenced managed objects. |
| | | * @return Returns the plural name of the relation. |
| | | */ |
| | | public int getMinOccurs() { |
| | | return minOccurs; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Get the maximum number of referenced managed objects. |
| | | * |
| | | * @return Returns the maximum number of referenced managed objects |
| | | * (or zero if there is no upper limit). |
| | | */ |
| | | public int getMaxOccurs() { |
| | | return maxOccurs; |
| | | public final String getPluralName() { |
| | | return pluralName; |
| | | } |
| | | |
| | | |
| | |
| | | builder.append(maxOccurs); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public <R, P> R accept(RelationDefinitionVisitor<R, P> v, P p) { |
| | | return v.visitAggregation(this, p); |
| | | } |
| | | } |
| | |
| | | |
| | | |
| | | |
| | | import static org.opends.server.util.Validator.*; |
| | | |
| | | import java.util.Locale; |
| | | |
| | | |
| | |
| | | <C extends ConfigurationClient, S extends Configuration> |
| | | extends RelationDefinition<C, S> { |
| | | |
| | | /** |
| | | * An interface for incrementally constructing instantiable relation |
| | | * definitions. |
| | | * |
| | | * @param <C> |
| | | * The type of client managed object configuration that |
| | | * this relation definition refers to. |
| | | * @param <S> |
| | | * The type of server managed object configuration that |
| | | * this relation definition refers to. |
| | | */ |
| | | public static class Builder |
| | | <C extends ConfigurationClient, S extends Configuration> |
| | | extends AbstractBuilder<C, S, InstantiableRelationDefinition<C, S>> { |
| | | |
| | | // The optional naming property definition. |
| | | private PropertyDefinition<?> namingPropertyDefinition; |
| | | |
| | | // The plural name of the relation. |
| | | private final String pluralName; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Creates a new builder which can be used to incrementally build |
| | | * an instantiable relation definition. |
| | | * |
| | | * @param pd |
| | | * The parent managed object definition. |
| | | * @param name |
| | | * The name of the relation. |
| | | * @param pluralName |
| | | * The plural name of the relation. |
| | | * @param cd |
| | | * The child managed object definition. |
| | | */ |
| | | public Builder(AbstractManagedObjectDefinition<?, ?> pd, String name, |
| | | String pluralName, AbstractManagedObjectDefinition<C, S> cd) { |
| | | super(pd, name, cd); |
| | | this.pluralName = pluralName; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Sets the naming property for the instantiable relation |
| | | * definition. |
| | | * |
| | | * @param namingPropertyDefinition |
| | | * The property of the child managed object definition |
| | | * which should be used for naming, or <code>null</code> |
| | | * if this relation does not use a property for naming. |
| | | */ |
| | | public final void setNamingProperty( |
| | | PropertyDefinition<?> namingPropertyDefinition) { |
| | | ensureNotNull(namingPropertyDefinition); |
| | | this.namingPropertyDefinition = namingPropertyDefinition; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | protected InstantiableRelationDefinition<C, S> buildInstance( |
| | | Common<C, S> common) { |
| | | return new InstantiableRelationDefinition<C, S>(common, pluralName, |
| | | namingPropertyDefinition); |
| | | } |
| | | |
| | | } |
| | | |
| | | // The optional naming property definition. |
| | | private final PropertyDefinition<?> namingPropertyDefinition; |
| | | |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * Create a new instantiable managed object relation definition. |
| | | * |
| | | * @param pd |
| | | * The parent managed object definition. |
| | | * @param name |
| | | * The name of the relation. |
| | | * @param pluralName |
| | | * The plural name of the relation. |
| | | * @param cd |
| | | * The child managed object definition. |
| | | * @param namingPropertyDefinition |
| | | * The property of the child managed object definition |
| | | * which should be used for naming, or <code>null</code> |
| | | * if this relation does not use a property for naming. |
| | | */ |
| | | public InstantiableRelationDefinition( |
| | | AbstractManagedObjectDefinition<?, ?> pd, String name, String pluralName, |
| | | AbstractManagedObjectDefinition<C, S> cd, |
| | | PropertyDefinition<?> namingPropertyDefinition) { |
| | | super(pd, name, cd); |
| | | // Private constructor. |
| | | private InstantiableRelationDefinition(Common<C, S> common, |
| | | String pluralName, PropertyDefinition<?> namingPropertyDefinition) { |
| | | super(common); |
| | | this.pluralName = pluralName; |
| | | this.namingPropertyDefinition = namingPropertyDefinition; |
| | | } |
| | |
| | | extends RelationDefinition<C, S> { |
| | | |
| | | /** |
| | | * Create a new optional managed object relation definition. |
| | | * An interface for incrementally constructing optional relation |
| | | * definitions. |
| | | * |
| | | * @param pd |
| | | * The parent managed object definition. |
| | | * @param name |
| | | * The name of the relation. |
| | | * @param cd |
| | | * The child managed object definition. |
| | | * @param <C> |
| | | * The type of client managed object configuration that |
| | | * this relation definition refers to. |
| | | * @param <S> |
| | | * The type of server managed object configuration that |
| | | * this relation definition refers to. |
| | | */ |
| | | public OptionalRelationDefinition( |
| | | AbstractManagedObjectDefinition<?, ?> pd, String name, |
| | | AbstractManagedObjectDefinition<C, S> cd) { |
| | | super(pd, name, cd); |
| | | public static class Builder |
| | | <C extends ConfigurationClient, S extends Configuration> |
| | | extends AbstractBuilder<C, S, OptionalRelationDefinition<C, S>> { |
| | | |
| | | /** |
| | | * Creates a new builder which can be used to incrementally build |
| | | * an optional relation definition. |
| | | * |
| | | * @param pd |
| | | * The parent managed object definition. |
| | | * @param name |
| | | * The name of the relation. |
| | | * @param cd |
| | | * The child managed object definition. |
| | | */ |
| | | public Builder(AbstractManagedObjectDefinition<?, ?> pd, String name, |
| | | AbstractManagedObjectDefinition<C, S> cd) { |
| | | super(pd, name, cd); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | protected OptionalRelationDefinition<C, S> buildInstance( |
| | | Common<C, S> common) { |
| | | return new OptionalRelationDefinition<C, S>(common); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | // Private constructor. |
| | | private OptionalRelationDefinition(Common<C, S> common) { |
| | | super(common); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public <R, P> R accept(RelationDefinitionVisitor<R, P> v, P p) { |
| | | return v.visitOptional(this, p); |
| | | } |
| | | |
| | | |
| | |
| | | builder.append(" minOccurs=0 maxOccurs=1"); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public <R, P> R accept(RelationDefinitionVisitor<R, P> v, P p) { |
| | | return v.visitOptional(this, p); |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | |
| | | |
| | | import static org.opends.server.util.Validator.*; |
| | | |
| | | import java.util.EnumSet; |
| | | import java.util.Locale; |
| | | import java.util.MissingResourceException; |
| | | import java.util.Set; |
| | | |
| | | |
| | | |
| | |
| | | public abstract class RelationDefinition |
| | | <C extends ConfigurationClient, S extends Configuration> { |
| | | |
| | | // The name of the relation. |
| | | private final String name; |
| | | /** |
| | | * An interface for incrementally constructing relation definitions. |
| | | * |
| | | * @param <C> |
| | | * The type of client managed object configuration that |
| | | * this relation definition refers to. |
| | | * @param <S> |
| | | * The type of server managed object configuration that |
| | | * this relation definition refers to. |
| | | * @param <D> |
| | | * The type of relation definition constructed by this |
| | | * builder. |
| | | */ |
| | | protected abstract static class AbstractBuilder |
| | | <C extends ConfigurationClient, S extends Configuration, |
| | | D extends RelationDefinition<C, S>> { |
| | | |
| | | // The definition of the parent managed object. |
| | | private final AbstractManagedObjectDefinition<?, ?> pd; |
| | | // Common fields. |
| | | private final Common<C, S> common; |
| | | |
| | | // The definition of the child managed object. |
| | | private final AbstractManagedObjectDefinition<C, S> cd; |
| | | |
| | | |
| | | /** |
| | | * Create a property definition builder. |
| | | * |
| | | * @param pd |
| | | * The parent managed object definition. |
| | | * @param name |
| | | * The name of the relation. |
| | | * @param cd |
| | | * The child managed object definition. |
| | | */ |
| | | protected AbstractBuilder(AbstractManagedObjectDefinition<?, ?> pd, |
| | | String name, AbstractManagedObjectDefinition<C, S> cd) { |
| | | this.common = new Common<C, S>(pd, name, cd); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Construct a relation definition based on the properties of this |
| | | * builder. |
| | | * |
| | | * @return The new relation definition. |
| | | */ |
| | | public final D getInstance() { |
| | | return buildInstance(common); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Add a relation definition option. |
| | | * |
| | | * @param option |
| | | * The relation option. |
| | | */ |
| | | public final void setOption(RelationOption option) { |
| | | ensureNotNull(option); |
| | | common.options.add(option); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Build a relation definition based on the properties of this |
| | | * builder. |
| | | * |
| | | * @param common |
| | | * The common fields of the new relation definition. |
| | | * @return The new relation definition. |
| | | */ |
| | | protected abstract D buildInstance(Common<C, S> common); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Opaque structure containing fields common to all relation |
| | | * definition types. |
| | | * |
| | | * @param <C> |
| | | * The type of client managed object configuration that |
| | | * this relation definition refers to. |
| | | * @param <S> |
| | | * The type of server managed object configuration that |
| | | * this relation definition refers to. |
| | | */ |
| | | protected static final class Common |
| | | <C extends ConfigurationClient, S extends Configuration> { |
| | | |
| | | // The definition of the child managed object. |
| | | private final AbstractManagedObjectDefinition<C, S> cd; |
| | | |
| | | // The name of the relation. |
| | | private final String name; |
| | | |
| | | // Options applicable to this definition. |
| | | private final Set<RelationOption> options; |
| | | |
| | | // The definition of the parent managed object. |
| | | private final AbstractManagedObjectDefinition<?, ?> pd; |
| | | |
| | | |
| | | |
| | | // Private constructor. |
| | | private Common(AbstractManagedObjectDefinition<?, ?> pd, String name, |
| | | AbstractManagedObjectDefinition<C, S> cd) { |
| | | this.name = name; |
| | | this.pd = pd; |
| | | this.cd = cd; |
| | | this.options = EnumSet.noneOf(RelationOption.class); |
| | | } |
| | | } |
| | | |
| | | // Common fields. |
| | | private final Common<C, S> common; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Create a new managed object relation definition with the |
| | | * specified name and referenced managed object definition. |
| | | * specified common fields. |
| | | * |
| | | * @param pd |
| | | * The parent managed object definition. |
| | | * @param name |
| | | * The name of the relation. |
| | | * @param cd |
| | | * The child managed object definition. |
| | | * @param common |
| | | * The common fields of the new relation definition. |
| | | */ |
| | | protected RelationDefinition( |
| | | AbstractManagedObjectDefinition<?, ?> pd, String name, |
| | | AbstractManagedObjectDefinition<C, S> cd) { |
| | | this.name = name; |
| | | this.pd = pd; |
| | | this.cd = cd; |
| | | protected RelationDefinition(Common<C, S> common) { |
| | | this.common = common; |
| | | } |
| | | |
| | | |
| | |
| | | * @return Returns the definition of the child managed object. |
| | | */ |
| | | public final AbstractManagedObjectDefinition<C, S> getChildDefinition() { |
| | | return cd; |
| | | return common.cd; |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | public final String getDescription(Locale locale) { |
| | | try { |
| | | String property = "relation." + name + ".description"; |
| | | return ManagedObjectDefinitionI18NResource.getInstance() |
| | | .getMessage(getParentDefinition(), property, locale); |
| | | String property = "relation." + common.name + ".description"; |
| | | return ManagedObjectDefinitionI18NResource.getInstance().getMessage( |
| | | getParentDefinition(), property, locale); |
| | | } catch (MissingResourceException e) { |
| | | return null; |
| | | } |
| | |
| | | * @return Returns the name of the relation. |
| | | */ |
| | | public final String getName() { |
| | | return name; |
| | | return common.name; |
| | | } |
| | | |
| | | |
| | |
| | | * @return Returns the definition of the parent managed object. |
| | | */ |
| | | public final AbstractManagedObjectDefinition<?, ?> getParentDefinition() { |
| | | return pd; |
| | | return common.pd; |
| | | } |
| | | |
| | | |
| | |
| | | * specified locale. |
| | | */ |
| | | public final String getSynopsis(Locale locale) { |
| | | String property = "relation." + name + ".synopsis"; |
| | | return ManagedObjectDefinitionI18NResource.getInstance() |
| | | .getMessage(getParentDefinition(), property, locale); |
| | | String property = "relation." + common.name + ".synopsis"; |
| | | return ManagedObjectDefinitionI18NResource.getInstance().getMessage( |
| | | getParentDefinition(), property, locale); |
| | | } |
| | | |
| | | |
| | |
| | | * definition in the specified locale. |
| | | */ |
| | | public final String getUserFriendlyName(Locale locale) { |
| | | String property = "relation." + name + ".user-friendly-name"; |
| | | return ManagedObjectDefinitionI18NResource.getInstance() |
| | | .getMessage(getParentDefinition(), property, locale); |
| | | String property = "relation." + common.name + ".user-friendly-name"; |
| | | return ManagedObjectDefinitionI18NResource.getInstance().getMessage( |
| | | getParentDefinition(), property, locale); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Check if the specified option is set for this relation |
| | | * definition. |
| | | * |
| | | * @param option |
| | | * The option to test. |
| | | * @return Returns <code>true</code> if the option is set, or |
| | | * <code>false</code> otherwise. |
| | | */ |
| | | public final boolean hasOption(RelationOption option) { |
| | | return common.options.contains(option); |
| | | } |
| | | |
| | | |
| New file |
| | |
| | | /* |
| | | * 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; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This enumeration contains various options that can be associated |
| | | * with relation definitions. |
| | | * <p> |
| | | * Only one option is supported at the moment, but others may be added |
| | | * in future. |
| | | */ |
| | | public enum RelationOption { |
| | | /** |
| | | * Use this option to identify relations which must not be directly |
| | | * exposed in client applications. |
| | | */ |
| | | HIDDEN; |
| | | } |
| | |
| | | |
| | | /** |
| | | * A managed object composite relationship definition which represents |
| | | * a compososition of a single managed object (i.e. the managed object |
| | | * a composition of a single managed object (i.e. the managed object |
| | | * must be present). |
| | | * |
| | | * @param <C> |
| | |
| | | extends RelationDefinition<C, S> { |
| | | |
| | | /** |
| | | * Create a new singleton managed object relation definition. |
| | | * An interface for incrementally constructing singleton relation |
| | | * definitions. |
| | | * |
| | | * @param pd |
| | | * The parent managed object definition. |
| | | * @param name |
| | | * The name of the relation. |
| | | * @param cd |
| | | * The child managed object definition. |
| | | * @param <C> |
| | | * The type of client managed object configuration that |
| | | * this relation definition refers to. |
| | | * @param <S> |
| | | * The type of server managed object configuration that |
| | | * this relation definition refers to. |
| | | */ |
| | | public SingletonRelationDefinition(AbstractManagedObjectDefinition<?, ?> pd, |
| | | String name, AbstractManagedObjectDefinition<C, S> cd) { |
| | | super(pd, name, cd); |
| | | public static class Builder |
| | | <C extends ConfigurationClient, S extends Configuration> |
| | | extends AbstractBuilder<C, S, SingletonRelationDefinition<C, S>> { |
| | | |
| | | /** |
| | | * Creates a new builder which can be used to incrementally build |
| | | * an singleton relation definition. |
| | | * |
| | | * @param pd |
| | | * The parent managed object definition. |
| | | * @param name |
| | | * The name of the relation. |
| | | * @param cd |
| | | * The child managed object definition. |
| | | */ |
| | | public Builder(AbstractManagedObjectDefinition<?, ?> pd, String name, |
| | | AbstractManagedObjectDefinition<C, S> cd) { |
| | | super(pd, name, cd); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | protected SingletonRelationDefinition<C, S> buildInstance( |
| | | Common<C, S> common) { |
| | | return new SingletonRelationDefinition<C, S>(common); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | // Private constructor. |
| | | private SingletonRelationDefinition(Common<C, S> common) { |
| | | super(common); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public <R, P> R accept(RelationDefinitionVisitor<R, P> v, P p) { |
| | | return v.visitSingleton(this, p); |
| | | } |
| | | |
| | | |
| | |
| | | builder.append(" minOccurs=1 maxOccurs=1"); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public <R, P> R accept(RelationDefinitionVisitor<R, P> v, P p) { |
| | | return v.visitSingleton(this, p); |
| | | } |
| | | |
| | | } |
| | |
| | | import org.opends.server.admin.OptionalRelationDefinition; |
| | | import org.opends.server.admin.RelationDefinition; |
| | | import org.opends.server.admin.RelationDefinitionVisitor; |
| | | import org.opends.server.admin.RelationOption; |
| | | import org.opends.server.admin.SingletonRelationDefinition; |
| | | import org.opends.server.util.args.ArgumentException; |
| | | import org.opends.server.util.args.SubCommandArgumentParser; |
| | |
| | | |
| | | // Do not process inherited relation definitions. |
| | | for (RelationDefinition<?, ?> r : d.getRelationDefinitions()) { |
| | | r.accept(this, path); |
| | | if (!r.hasOption(RelationOption.HIDDEN)) { |
| | | r.accept(this, path); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | // Create a one-to-many relation for test-parent components. |
| | | static { |
| | | RD_TEST_ONE_TO_MANY_PARENT = new InstantiableRelationDefinition<TestParentCfgClient, TestParentCfg>( |
| | | InstantiableRelationDefinition.Builder<TestParentCfgClient, TestParentCfg> builder = |
| | | new InstantiableRelationDefinition.Builder<TestParentCfgClient, TestParentCfg>( |
| | | RootCfgDefn.getInstance(), "test-one-to-many-parent", |
| | | "test-one-to-many-parents", TestParentCfgDefn.getInstance(), null); |
| | | "test-one-to-many-parents", TestParentCfgDefn.getInstance()); |
| | | RD_TEST_ONE_TO_MANY_PARENT = builder.getInstance(); |
| | | } |
| | | |
| | | // Create a one-to-many relation for test-parent components. |
| | | static { |
| | | RD_TEST_ONE_TO_ZERO_OR_ONE_PARENT = new OptionalRelationDefinition<TestParentCfgClient, TestParentCfg>( |
| | | OptionalRelationDefinition.Builder<TestParentCfgClient, TestParentCfg> builder = |
| | | new OptionalRelationDefinition.Builder<TestParentCfgClient, TestParentCfg>( |
| | | RootCfgDefn.getInstance(), "test-one-to-zero-or-one-parent", |
| | | TestParentCfgDefn.getInstance()); |
| | | RD_TEST_ONE_TO_ZERO_OR_ONE_PARENT = builder.getInstance(); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | // Build the "test-children" relation definition. |
| | | static { |
| | | RD_TEST_CHILDREN = new InstantiableRelationDefinition<TestChildCfgClient, TestChildCfg>( |
| | | INSTANCE, "multiple-children", "test-children", TestChildCfgDefn.getInstance(), null); |
| | | InstantiableRelationDefinition.Builder<TestChildCfgClient, TestChildCfg> builder = |
| | | new InstantiableRelationDefinition.Builder<TestChildCfgClient, TestChildCfg>( |
| | | INSTANCE, "multiple-children", "test-children", TestChildCfgDefn |
| | | .getInstance()); |
| | | RD_TEST_CHILDREN = builder.getInstance(); |
| | | INSTANCE.registerRelationDefinition(RD_TEST_CHILDREN); |
| | | } |
| | | |
| | |
| | | |
| | | // Build the "optional-test-child" relation definition. |
| | | static { |
| | | RD_OPTIONAL_TEST_CHILD = new OptionalRelationDefinition<TestChildCfgClient, TestChildCfg>( |
| | | OptionalRelationDefinition.Builder<TestChildCfgClient, TestChildCfg> builder = |
| | | new OptionalRelationDefinition.Builder<TestChildCfgClient, TestChildCfg>( |
| | | INSTANCE, "optional-test-child", TestChildCfgDefn.getInstance()); |
| | | RD_OPTIONAL_TEST_CHILD = builder.getInstance(); |
| | | INSTANCE.registerRelationDefinition(RD_OPTIONAL_TEST_CHILD); |
| | | } |
| | | |
| | |
| | | // First create the path. |
| | | ManagedObjectPath<? extends ConfigurationClient, ? extends Configuration> path = ManagedObjectPath |
| | | .emptyPath(); |
| | | |
| | | final SingletonRelationDefinition<TestChildCfgClient, TestChildCfg> r2 = new SingletonRelationDefinition<TestChildCfgClient, TestChildCfg>( |
| | | |
| | | SingletonRelationDefinition.Builder<TestChildCfgClient, TestChildCfg> b = |
| | | new SingletonRelationDefinition.Builder<TestChildCfgClient, TestChildCfg>( |
| | | TestParentCfgDefn.getInstance(), "singleton-test-child", |
| | | TestChildCfgDefn.getInstance()); |
| | | final SingletonRelationDefinition<TestChildCfgClient, TestChildCfg> r2 = b.getInstance(); |
| | | LDAPProfile.Wrapper wrapper = new LDAPProfile.Wrapper() { |
| | | |
| | | /** |