| | |
| | | import org.opends.server.admin.DefaultBehaviorException; |
| | | import org.opends.server.admin.DefaultManagedObject; |
| | | import org.opends.server.admin.DefinitionDecodingException; |
| | | import org.opends.server.admin.IllegalPropertyValueException; |
| | | import org.opends.server.admin.IllegalPropertyValueStringException; |
| | | import org.opends.server.admin.InstantiableRelationDefinition; |
| | | import org.opends.server.admin.ManagedObjectAlreadyExistsException; |
| | |
| | | import org.opends.server.admin.PropertyDefinition; |
| | | import org.opends.server.admin.PropertyIsMandatoryException; |
| | | import org.opends.server.admin.PropertyIsReadOnlyException; |
| | | import org.opends.server.admin.PropertyIsSingleValuedException; |
| | | import org.opends.server.admin.PropertyOption; |
| | | import org.opends.server.admin.RelationDefinition; |
| | | import org.opends.server.admin.RelationDefinitionVisitor; |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> Void visitInstantiable( |
| | | InstantiableRelationDefinition<C, S> rd, Void p) { |
| | | InstantiableRelationDefinition<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(); |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> Void visitOptional( |
| | | OptionalRelationDefinition<C, S> rd, Void p) { |
| | | OptionalRelationDefinition<C, S> rd, Void p) { |
| | | if (rd.getDefaultManagedObject() != null) { |
| | | DefaultManagedObject<? extends C, ? extends S> dmo = rd.getDefaultManagedObject(); |
| | | ManagedObjectDefinition<? extends C, ? extends S> d = dmo.getManagedObjectDefinition(); |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> Void visitSingleton( |
| | | SingletonRelationDefinition<C, S> rd, Void p) { |
| | | SingletonRelationDefinition<C, S> rd, Void p) { |
| | | // Do nothing - not possible to create singletons |
| | | // dynamically. |
| | | return null; |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> Void visitSet(SetRelationDefinition<C, S> rd, |
| | | Void p) { |
| | | Void p) { |
| | | for (String name : rd.getDefaultManagedObjectNames()) { |
| | | DefaultManagedObject<? extends C, ? extends S> dmo = rd.getDefaultManagedObject(name); |
| | | ManagedObjectDefinition<? extends C, ? extends S> d = dmo.getManagedObjectDefinition(); |
| | |
| | | |
| | | // Create the child managed object. |
| | | private void createDefaultManagedObject(ManagedObjectDefinition<?, ?> d, ManagedObject<?> child, |
| | | DefaultManagedObject<?, ?> dmo) { |
| | | DefaultManagedObject<?, ?> dmo) { |
| | | for (PropertyDefinition<?> pd : d.getAllPropertyDefinitions()) { |
| | | setPropertyValues(child, pd, dmo); |
| | | } |
| | |
| | | * The relation definition. |
| | | */ |
| | | private void createDefaultManagedObjects(RelationDefinition<?, ?> rd) throws ErrorResultException, |
| | | ConcurrentModificationException, MissingMandatoryPropertiesException, |
| | | ManagedObjectAlreadyExistsException, OperationRejectedException { |
| | | ConcurrentModificationException, MissingMandatoryPropertiesException, |
| | | ManagedObjectAlreadyExistsException, OperationRejectedException { |
| | | rd.accept(this, null); |
| | | |
| | | if (ere != null) { |
| | |
| | | } |
| | | |
| | | // Set property values. |
| | | private <PD> void setPropertyValues(ManagedObject<?> mo, PropertyDefinition<PD> pd, |
| | | DefaultManagedObject<?, ?> dmo) { |
| | | private <P> void setPropertyValues(ManagedObject<?> mo, PropertyDefinition<P> pd, |
| | | DefaultManagedObject<?, ?> dmo) { |
| | | mo.setPropertyValues(pd, dmo.getPropertyValues(pd)); |
| | | } |
| | | } |
| | |
| | | * Optional naming property definition. |
| | | */ |
| | | protected AbstractManagedObject(ManagedObjectDefinition<T, ? extends Configuration> d, |
| | | ManagedObjectPath<T, ? extends Configuration> path, PropertySet properties, boolean existsOnServer, |
| | | PropertyDefinition<?> namingPropertyDefinition) { |
| | | ManagedObjectPath<T, ? extends Configuration> path, PropertySet properties, boolean existsOnServer, |
| | | PropertyDefinition<?> namingPropertyDefinition) { |
| | | this.definition = d; |
| | | this.path = path; |
| | | this.properties = properties; |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public final void commit() throws ManagedObjectAlreadyExistsException, MissingMandatoryPropertiesException, |
| | | ConcurrentModificationException, OperationRejectedException, ErrorResultException { |
| | | ConcurrentModificationException, OperationRejectedException, ErrorResultException { |
| | | // First make sure all mandatory properties are defined. |
| | | List<PropertyIsMandatoryException> exceptions = new LinkedList<PropertyIsMandatoryException>(); |
| | | |
| | |
| | | } |
| | | |
| | | if (!exceptions.isEmpty()) { |
| | | throw new MissingMandatoryPropertiesException(definition.getUserFriendlyName(), exceptions, !existsOnServer); |
| | | throw new MissingMandatoryPropertiesException(definition.getUserFriendlyName(), exceptions, |
| | | !existsOnServer); |
| | | } |
| | | |
| | | // Now enforce any constraints. |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public final <C extends ConfigurationClient, S extends Configuration, CC extends C> ManagedObject<CC> createChild( |
| | | InstantiableRelationDefinition<C, S> r, ManagedObjectDefinition<CC, ? extends S> d, String name, |
| | | Collection<DefaultBehaviorException> exceptions) throws IllegalManagedObjectNameException, |
| | | IllegalArgumentException { |
| | | @Override |
| | | public final <C extends ConfigurationClient, S extends Configuration, C1 extends C> ManagedObject<C1> createChild( |
| | | InstantiableRelationDefinition<C, S> r, ManagedObjectDefinition<C1, ? extends S> d, String name, |
| | | Collection<DefaultBehaviorException> exceptions) throws IllegalManagedObjectNameException { |
| | | validateRelationDefinition(r); |
| | | |
| | | // Empty names are not allowed. |
| | |
| | | } |
| | | } |
| | | |
| | | ManagedObjectPath<CC, ? extends S> childPath = path.child(r, d, name); |
| | | ManagedObjectPath<C1, ? extends S> childPath = path.child(r, d, name); |
| | | return createNewManagedObject(d, childPath, pd, name, exceptions); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public final <C extends ConfigurationClient, S extends Configuration, CC extends C> ManagedObject<CC> createChild( |
| | | OptionalRelationDefinition<C, S> r, ManagedObjectDefinition<CC, ? extends S> d, |
| | | Collection<DefaultBehaviorException> exceptions) throws IllegalArgumentException { |
| | | @Override |
| | | public final <C extends ConfigurationClient, S extends Configuration, C1 extends C> ManagedObject<C1> createChild( |
| | | OptionalRelationDefinition<C, S> r, ManagedObjectDefinition<C1, ? extends S> d, |
| | | Collection<DefaultBehaviorException> exceptions) { |
| | | validateRelationDefinition(r); |
| | | ManagedObjectPath<CC, ? extends S> childPath = path.child(r, d); |
| | | ManagedObjectPath<C1, ? extends S> childPath = path.child(r, d); |
| | | return createNewManagedObject(d, childPath, null, null, exceptions); |
| | | } |
| | | |
| | | /** |
| | | * {@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 { |
| | | @Override |
| | | public final <C extends ConfigurationClient, S extends Configuration, C1 extends C> ManagedObject<C1> createChild( |
| | | SetRelationDefinition<C, S> r, ManagedObjectDefinition<C1, ? extends S> d, |
| | | Collection<DefaultBehaviorException> exceptions) { |
| | | validateRelationDefinition(r); |
| | | |
| | | ManagedObjectPath<CC, ? extends S> childPath = path.child(r, d); |
| | | ManagedObjectPath<C1, ? extends S> childPath = path.child(r, d); |
| | | return createNewManagedObject(d, childPath, null, null, exceptions); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public final <C extends ConfigurationClient, S extends Configuration> ManagedObject<? extends C> getChild( |
| | | InstantiableRelationDefinition<C, S> r, String name) throws IllegalArgumentException, |
| | | DefinitionDecodingException, ManagedObjectDecodingException, ManagedObjectNotFoundException, |
| | | ConcurrentModificationException, ErrorResultException { |
| | | InstantiableRelationDefinition<C, S> r, String name) throws DefinitionDecodingException, |
| | | ManagedObjectDecodingException, ManagedObjectNotFoundException, ConcurrentModificationException, |
| | | ErrorResultException { |
| | | validateRelationDefinition(r); |
| | | ensureThisManagedObjectExists(); |
| | | Driver ctx = getDriver(); |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public final <C extends ConfigurationClient, S extends Configuration> ManagedObject<? extends C> getChild( |
| | | OptionalRelationDefinition<C, S> r) throws IllegalArgumentException, DefinitionDecodingException, |
| | | ManagedObjectDecodingException, ManagedObjectNotFoundException, ConcurrentModificationException, |
| | | ErrorResultException { |
| | | OptionalRelationDefinition<C, S> r) throws DefinitionDecodingException, ManagedObjectDecodingException, |
| | | ManagedObjectNotFoundException, ConcurrentModificationException, ErrorResultException { |
| | | validateRelationDefinition(r); |
| | | ensureThisManagedObjectExists(); |
| | | Driver ctx = getDriver(); |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public final <C extends ConfigurationClient, S extends Configuration> ManagedObject<? extends C> getChild( |
| | | SingletonRelationDefinition<C, S> r) throws IllegalArgumentException, DefinitionDecodingException, |
| | | ManagedObjectDecodingException, ManagedObjectNotFoundException, ConcurrentModificationException, |
| | | ErrorResultException { |
| | | SingletonRelationDefinition<C, S> r) throws DefinitionDecodingException, ManagedObjectDecodingException, |
| | | ManagedObjectNotFoundException, ConcurrentModificationException, ErrorResultException { |
| | | validateRelationDefinition(r); |
| | | ensureThisManagedObjectExists(); |
| | | Driver ctx = getDriver(); |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public final <C extends ConfigurationClient, S extends Configuration> ManagedObject<? extends C> getChild( |
| | | SetRelationDefinition<C, S> r, String name) throws IllegalArgumentException, DefinitionDecodingException, |
| | | ManagedObjectDecodingException, ManagedObjectNotFoundException, ConcurrentModificationException, |
| | | ErrorResultException { |
| | | SetRelationDefinition<C, S> r, String name) throws DefinitionDecodingException, |
| | | ManagedObjectDecodingException, ManagedObjectNotFoundException, ConcurrentModificationException, |
| | | ErrorResultException { |
| | | validateRelationDefinition(r); |
| | | ensureThisManagedObjectExists(); |
| | | Driver ctx = getDriver(); |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public final T getConfiguration() { |
| | | return definition.createClientConfiguration(this); |
| | | } |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public final ManagedObjectDefinition<T, ? extends Configuration> getManagedObjectDefinition() { |
| | | return definition; |
| | | } |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public final ManagedObjectPath<T, ? extends Configuration> getManagedObjectPath() { |
| | | return path; |
| | | } |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public final <PD> SortedSet<PD> getPropertyDefaultValues(PropertyDefinition<PD> pd) throws IllegalArgumentException { |
| | | return new TreeSet<PD>(getProperty(pd).getDefaultValues()); |
| | | @Override |
| | | public final <P> SortedSet<P> getPropertyDefaultValues(PropertyDefinition<P> pd) { |
| | | return new TreeSet<P>(getProperty(pd).getDefaultValues()); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public final <PD> PD getPropertyValue(PropertyDefinition<PD> pd) throws IllegalArgumentException { |
| | | Set<PD> values = getProperty(pd).getEffectiveValues(); |
| | | @Override |
| | | public final <P> P getPropertyValue(PropertyDefinition<P> pd) { |
| | | Set<P> values = getProperty(pd).getEffectiveValues(); |
| | | if (values.isEmpty()) { |
| | | return null; |
| | | } else { |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public final <PD> SortedSet<PD> getPropertyValues(PropertyDefinition<PD> pd) throws IllegalArgumentException { |
| | | return new TreeSet<PD>(getProperty(pd).getEffectiveValues()); |
| | | @Override |
| | | public final <P> SortedSet<P> getPropertyValues(PropertyDefinition<P> pd) { |
| | | return new TreeSet<P>(getProperty(pd).getEffectiveValues()); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public final <C extends ConfigurationClient, S extends Configuration> boolean hasChild( |
| | | OptionalRelationDefinition<C, S> r) throws IllegalArgumentException, ConcurrentModificationException, |
| | | ErrorResultException { |
| | | OptionalRelationDefinition<C, S> r) throws ConcurrentModificationException, ErrorResultException { |
| | | validateRelationDefinition(r); |
| | | Driver ctx = getDriver(); |
| | | try { |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public final boolean isPropertyPresent(PropertyDefinition<?> pd) throws IllegalArgumentException { |
| | | @Override |
| | | public final boolean isPropertyPresent(PropertyDefinition<?> pd) { |
| | | return !getProperty(pd).isEmpty(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public final <C extends ConfigurationClient, S extends Configuration> String[] listChildren( |
| | | InstantiableRelationDefinition<C, S> r) throws IllegalArgumentException, ConcurrentModificationException, |
| | | ErrorResultException { |
| | | InstantiableRelationDefinition<C, S> r) throws ConcurrentModificationException, ErrorResultException { |
| | | return listChildren(r, r.getChildDefinition()); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public final <C extends ConfigurationClient, S extends Configuration> String[] listChildren( |
| | | InstantiableRelationDefinition<C, S> r, AbstractManagedObjectDefinition<? extends C, ? extends S> d) |
| | | throws IllegalArgumentException, ConcurrentModificationException, ErrorResultException { |
| | | InstantiableRelationDefinition<C, S> r, AbstractManagedObjectDefinition<? extends C, ? extends S> d) |
| | | throws ConcurrentModificationException, ErrorResultException { |
| | | validateRelationDefinition(r); |
| | | Driver ctx = getDriver(); |
| | | try { |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public final <C extends ConfigurationClient, S extends Configuration> String[] listChildren( |
| | | SetRelationDefinition<C, S> r) throws IllegalArgumentException, ConcurrentModificationException, |
| | | ErrorResultException { |
| | | SetRelationDefinition<C, S> r) throws ConcurrentModificationException, ErrorResultException { |
| | | return listChildren(r, r.getChildDefinition()); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public final <C extends ConfigurationClient, S extends Configuration> String[] listChildren( |
| | | SetRelationDefinition<C, S> r, AbstractManagedObjectDefinition<? extends C, ? extends S> d) |
| | | throws IllegalArgumentException, ConcurrentModificationException, ErrorResultException { |
| | | SetRelationDefinition<C, S> r, AbstractManagedObjectDefinition<? extends C, ? extends S> d) |
| | | throws ConcurrentModificationException, ErrorResultException { |
| | | validateRelationDefinition(r); |
| | | Driver ctx = getDriver(); |
| | | try { |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public final <C extends ConfigurationClient, S extends Configuration> void removeChild( |
| | | InstantiableRelationDefinition<C, S> r, String name) throws IllegalArgumentException, |
| | | ManagedObjectNotFoundException, OperationRejectedException, ConcurrentModificationException, |
| | | ErrorResultException { |
| | | InstantiableRelationDefinition<C, S> r, String name) throws ManagedObjectNotFoundException, |
| | | OperationRejectedException, ConcurrentModificationException, ErrorResultException { |
| | | validateRelationDefinition(r); |
| | | Driver ctx = getDriver(); |
| | | boolean found; |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public final <C extends ConfigurationClient, S extends Configuration> void removeChild( |
| | | OptionalRelationDefinition<C, S> r) throws IllegalArgumentException, ManagedObjectNotFoundException, |
| | | OperationRejectedException, ConcurrentModificationException, ErrorResultException { |
| | | OptionalRelationDefinition<C, S> r) throws ManagedObjectNotFoundException, OperationRejectedException, |
| | | ConcurrentModificationException, ErrorResultException { |
| | | validateRelationDefinition(r); |
| | | Driver ctx = getDriver(); |
| | | boolean found; |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public final <C extends ConfigurationClient, S extends Configuration> void removeChild( |
| | | SetRelationDefinition<C, S> r, String name) throws IllegalArgumentException, |
| | | ManagedObjectNotFoundException, OperationRejectedException, ConcurrentModificationException, |
| | | ErrorResultException { |
| | | SetRelationDefinition<C, S> r, String name) throws ManagedObjectNotFoundException, |
| | | OperationRejectedException, ConcurrentModificationException, ErrorResultException { |
| | | validateRelationDefinition(r); |
| | | Driver ctx = getDriver(); |
| | | boolean found; |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public final <PD> void setPropertyValue(PropertyDefinition<PD> pd, PD value) throws IllegalPropertyValueException, |
| | | PropertyIsReadOnlyException, PropertyIsMandatoryException, IllegalArgumentException { |
| | | @Override |
| | | public final <P> void setPropertyValue(PropertyDefinition<P> pd, P value) { |
| | | if (value == null) { |
| | | setPropertyValues(pd, Collections.<PD> emptySet()); |
| | | setPropertyValues(pd, Collections.<P> emptySet()); |
| | | } else { |
| | | setPropertyValues(pd, Collections.singleton(value)); |
| | | } |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public final <PD> void setPropertyValues(PropertyDefinition<PD> pd, Collection<PD> values) |
| | | throws IllegalPropertyValueException, PropertyIsSingleValuedException, PropertyIsReadOnlyException, |
| | | PropertyIsMandatoryException, IllegalArgumentException { |
| | | @Override |
| | | public final <P> void setPropertyValues(PropertyDefinition<P> pd, Collection<P> values) { |
| | | if (pd.hasOption(PropertyOption.MONITORING)) { |
| | | throw new PropertyIsReadOnlyException(pd); |
| | | } |
| | |
| | | * @throws ErrorResultException |
| | | * If any other error occurs. |
| | | */ |
| | | protected abstract void addNewManagedObject() throws ErrorResultException, |
| | | OperationRejectedException, ConcurrentModificationException, ManagedObjectAlreadyExistsException; |
| | | protected abstract void addNewManagedObject() throws ErrorResultException, OperationRejectedException, |
| | | ConcurrentModificationException, ManagedObjectAlreadyExistsException; |
| | | |
| | | /** |
| | | * Gets the management context driver associated with this managed object. |
| | |
| | | /** |
| | | * Gets the property associated with the specified property definition. |
| | | * |
| | | * @param <PD> |
| | | * @param <P> |
| | | * The underlying type of the property. |
| | | * @param pd |
| | | * The Property definition. |
| | |
| | | * If this property provider does not recognize the requested |
| | | * property definition. |
| | | */ |
| | | protected final <PD> Property<PD> getProperty(PropertyDefinition<PD> pd) throws IllegalArgumentException { |
| | | protected final <P> Property<P> getProperty(PropertyDefinition<P> pd) { |
| | | return properties.getProperty(pd); |
| | | } |
| | | |
| | |
| | | * @throws OperationRejectedException |
| | | * If the managed object cannot be added due to some client-side |
| | | * or server-side constraint which cannot be satisfied. |
| | | * @throws AuthorizationException |
| | | * If the server refuses to modify this managed object because |
| | | * the client does not have the correct privileges. |
| | | * @throws CommunicationException |
| | | * If the client cannot contact the server due to an underlying |
| | | * communication problem. |
| | | * @throws ErrorResultException |
| | | * If any other error occurs. |
| | | */ |
| | | protected abstract void modifyExistingManagedObject() throws ConcurrentModificationException, |
| | | OperationRejectedException, ErrorResultException; |
| | | OperationRejectedException, ErrorResultException; |
| | | |
| | | /** |
| | | * Creates a new managed object. |
| | |
| | | * @return Returns the new managed object. |
| | | */ |
| | | protected abstract <M extends ConfigurationClient> ManagedObject<M> newInstance(ManagedObjectDefinition<M, ?> d, |
| | | ManagedObjectPath<M, ?> path, PropertySet properties, boolean existsOnServer, |
| | | PropertyDefinition<?> namingPropertyDefinition); |
| | | ManagedObjectPath<M, ?> path, PropertySet properties, boolean existsOnServer, |
| | | PropertyDefinition<?> namingPropertyDefinition); |
| | | |
| | | // Creates a new managed object with no active values, just default |
| | | // values. |
| | | private <M extends ConfigurationClient, PD> ManagedObject<M> createNewManagedObject( |
| | | ManagedObjectDefinition<M, ?> d, ManagedObjectPath<M, ?> p, |
| | | PropertyDefinition<PD> namingPropertyDefinition, String name, |
| | | Collection<DefaultBehaviorException> exceptions) { |
| | | private <M extends ConfigurationClient, P> ManagedObject<M> createNewManagedObject( |
| | | ManagedObjectDefinition<M, ?> d, ManagedObjectPath<M, ?> p, PropertyDefinition<P> namingPropertyDefinition, |
| | | String name, Collection<DefaultBehaviorException> exceptions) { |
| | | PropertySet childProperties = new PropertySet(); |
| | | for (PropertyDefinition<?> pd : d.getAllPropertyDefinitions()) { |
| | | try { |
| | |
| | | |
| | | // Set the naming property if there is one. |
| | | if (namingPropertyDefinition != null) { |
| | | PD value = namingPropertyDefinition.decodeValue(name); |
| | | P value = namingPropertyDefinition.decodeValue(name); |
| | | childProperties.setPropertyValues(namingPropertyDefinition, Collections.singleton(value)); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | // Create an empty property. |
| | | private <PD> void createProperty(PropertySet properties, ManagedObjectPath<?, ?> p, PropertyDefinition<PD> pd) |
| | | throws DefaultBehaviorException { |
| | | private <P> void createProperty(PropertySet properties, ManagedObjectPath<?, ?> p, PropertyDefinition<P> pd) { |
| | | try { |
| | | Driver context = getDriver(); |
| | | Collection<PD> defaultValues = context.findDefaultValues(p, pd, true); |
| | | properties.addProperty(pd, defaultValues, Collections.<PD> emptySet()); |
| | | Collection<P> defaultValues = context.findDefaultValues(p, pd, true); |
| | | properties.addProperty(pd, defaultValues, Collections.<P> emptySet()); |
| | | } catch (DefaultBehaviorException e) { |
| | | // Make sure that we have still created the property. |
| | | properties.addProperty(pd, Collections.<PD> emptySet(), Collections.<PD> emptySet()); |
| | | properties.addProperty(pd, Collections.<P> emptySet(), Collections.<P> emptySet()); |
| | | throw e; |
| | | } |
| | | } |
| | |
| | | |
| | | // Validate that a relation definition belongs to this managed |
| | | // object. |
| | | private void validateRelationDefinition(RelationDefinition<?, ?> rd) throws IllegalArgumentException { |
| | | private void validateRelationDefinition(RelationDefinition<?, ?> rd) { |
| | | ManagedObjectDefinition<T, ?> d = getManagedObjectDefinition(); |
| | | RelationDefinition<?, ?> tmp = d.getRelationDefinition(rd.getName()); |
| | | if (tmp != rd) { |
| | | throw new IllegalArgumentException("The relation " + rd.getName() + " is not associated with a " |
| | | + d.getName()); |
| | | + d.getName()); |
| | | } |
| | | } |
| | | |