Checkpoint commit for OPENDJ-1235 : Migrate configuration framework
* Fix all checkstyle errors.
* Migrate missing package-info.java files for some packages
113 files modified
6 files added
| | |
| | | /** |
| | | * ACI property definition. |
| | | */ |
| | | public class ACIPropertyDefinition extends PropertyDefinition<Aci> { |
| | | |
| | | public final class ACIPropertyDefinition extends PropertyDefinition<Aci> { |
| | | |
| | | /** |
| | | * An interface for incrementally constructing ACI property |
| | | * definitions. |
| | | * An interface for incrementally constructing ACI property definitions. |
| | | */ |
| | | public static class Builder extends |
| | | AbstractBuilder<Aci, ACIPropertyDefinition> { |
| | | public static final class Builder extends AbstractBuilder<Aci, ACIPropertyDefinition> { |
| | | |
| | | // Private constructor |
| | | private Builder( |
| | | AbstractManagedObjectDefinition<?, ?> d, String propertyName) { |
| | | private Builder(AbstractManagedObjectDefinition<?, ?> d, String propertyName) { |
| | | super(d, propertyName); |
| | | } |
| | | |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | protected ACIPropertyDefinition buildInstance( |
| | | AbstractManagedObjectDefinition<?, ?> d, |
| | | String propertyName, EnumSet<PropertyOption> options, |
| | | AdministratorAction adminAction, |
| | | protected ACIPropertyDefinition buildInstance(AbstractManagedObjectDefinition<?, ?> d, String propertyName, |
| | | EnumSet<PropertyOption> options, AdministratorAction adminAction, |
| | | DefaultBehaviorProvider<Aci> defaultBehavior) { |
| | | return new ACIPropertyDefinition(d, propertyName, options, |
| | | adminAction, defaultBehavior); |
| | | return new ACIPropertyDefinition(d, propertyName, options, adminAction, defaultBehavior); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Create a ACI property definition builder. |
| | | * |
| | | * @param d |
| | | * The managed object definition associated with this |
| | | * property definition. |
| | | * The managed object definition associated with this property |
| | | * definition. |
| | | * @param propertyName |
| | | * The property name. |
| | | * @return Returns the new ACI property definition builder. |
| | | */ |
| | | public static Builder createBuilder( |
| | | AbstractManagedObjectDefinition<?, ?> d, String propertyName) { |
| | | public static Builder createBuilder(AbstractManagedObjectDefinition<?, ?> d, String propertyName) { |
| | | return new Builder(d, propertyName); |
| | | } |
| | | |
| | | |
| | | // Private constructor. |
| | | private ACIPropertyDefinition( |
| | | AbstractManagedObjectDefinition<?, ?> d, String propertyName, |
| | | EnumSet<PropertyOption> options, |
| | | AdministratorAction adminAction, |
| | | private ACIPropertyDefinition(AbstractManagedObjectDefinition<?, ?> d, String propertyName, |
| | | EnumSet<PropertyOption> options, AdministratorAction adminAction, |
| | | DefaultBehaviorProvider<Aci> defaultBehavior) { |
| | | super(d, Aci.class, propertyName, options, adminAction, |
| | | defaultBehavior); |
| | | super(d, Aci.class, propertyName, options, adminAction, defaultBehavior); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void validateValue(Aci value) |
| | | throws IllegalPropertyValueException { |
| | | public void validateValue(Aci value) { |
| | | Reject.ifNull(value); |
| | | |
| | | // No additional validation required. |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public Aci decodeValue(String value) |
| | | throws IllegalPropertyValueStringException { |
| | | public Aci decodeValue(String value) { |
| | | Reject.ifNull(value); |
| | | |
| | | try { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | |
| | | return v.visitACI(this, value, p); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | |
| | | * |
| | | * Copyright 2007-2010 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.server.admin; |
| | | |
| | | import java.util.ArrayList; |
| | |
| | | * <code>null</code> parent, unless the definition is being used |
| | | * for testing). |
| | | */ |
| | | protected AbstractManagedObjectDefinition(String name, AbstractManagedObjectDefinition<? super C, ? super S> parent) { |
| | | protected AbstractManagedObjectDefinition(String name, |
| | | AbstractManagedObjectDefinition<? super C, ? super S> parent) { |
| | | this.name = name; |
| | | this.parent = parent; |
| | | this.constraints = new LinkedList<Constraint>(); |
| | |
| | | * definition. |
| | | */ |
| | | public final Collection<AbstractManagedObjectDefinition<? extends C, ? extends S>> getAllChildren() { |
| | | List<AbstractManagedObjectDefinition<? extends C, ? extends S>> list = new ArrayList<AbstractManagedObjectDefinition<? extends C, ? extends S>>( |
| | | children.values()); |
| | | List<AbstractManagedObjectDefinition<? extends C, ? extends S>> list = |
| | | new ArrayList<AbstractManagedObjectDefinition<? extends C, ? extends S>>(children.values()); |
| | | |
| | | for (AbstractManagedObjectDefinition<? extends C, ? extends S> child : children.values()) { |
| | | list.addAll(child.getAllChildren()); |
| | |
| | | // This method does not used a cached set of relations because |
| | | // relations may be updated after child definitions have been |
| | | // defined. |
| | | List<RelationDefinition<? super C, ? super S>> rdlist = new LinkedList<RelationDefinition<? super C, ? super S>>(); |
| | | List<RelationDefinition<? super C, ? super S>> rdlist = |
| | | new LinkedList<RelationDefinition<? super C, ? super S>>(); |
| | | |
| | | if (parent != null) { |
| | | rdlist.addAll(parent.getAllReverseRelationDefinitions()); |
| | |
| | | * empty or if the requested subordinate managed object |
| | | * definition was not found. |
| | | */ |
| | | public final AbstractManagedObjectDefinition<? extends C, ? extends S> getChild(String name) |
| | | throws IllegalArgumentException { |
| | | public final AbstractManagedObjectDefinition<? extends C, ? extends S> getChild(String name) { |
| | | if ((name == null) || (name.length() == 0)) { |
| | | throw new IllegalArgumentException("null or empty managed object name"); |
| | | } |
| | |
| | | * @throws UnsupportedOperationException |
| | | * If this managed object definition is the {@link TopCfgDefn}. |
| | | */ |
| | | public final LocalizableMessage getDescription() throws UnsupportedOperationException { |
| | | public final LocalizableMessage getDescription() { |
| | | return getDescription(Locale.getDefault()); |
| | | } |
| | | |
| | |
| | | * @throws UnsupportedOperationException |
| | | * If this managed object definition is the {@link TopCfgDefn}. |
| | | */ |
| | | public final LocalizableMessage getDescription(Locale locale) throws UnsupportedOperationException { |
| | | public final LocalizableMessage getDescription(Locale locale) { |
| | | try { |
| | | return ManagedObjectDefinitionI18NResource.getInstance().getMessage(this, "description", locale); |
| | | } catch (MissingResourceException e) { |
| | |
| | | * If the specified property name was null or empty or if the |
| | | * requested property definition was not found. |
| | | */ |
| | | public final PropertyDefinition<?> getPropertyDefinition(String name) throws IllegalArgumentException { |
| | | public final PropertyDefinition<?> getPropertyDefinition(String name) { |
| | | if ((name == null) || (name.length() == 0)) { |
| | | throw new IllegalArgumentException("null or empty property name"); |
| | | } |
| | |
| | | * If the specified relation name was null or empty or if the |
| | | * requested relation definition was not found. |
| | | */ |
| | | public final RelationDefinition<?, ?> getRelationDefinition(String name) throws IllegalArgumentException { |
| | | public final RelationDefinition<?, ?> getRelationDefinition(String name) { |
| | | if ((name == null) || (name.length() == 0)) { |
| | | throw new IllegalArgumentException("null or empty relation name"); |
| | | } |
| | |
| | | * or if the requested aggregation property definition was not |
| | | * found. |
| | | */ |
| | | public final AggregationPropertyDefinition<?, ?> getAggregationPropertyDefinition(String name) |
| | | throws IllegalArgumentException { |
| | | public final AggregationPropertyDefinition<?, ?> getAggregationPropertyDefinition(String name) { |
| | | if ((name == null) || (name.length() == 0)) { |
| | | throw new IllegalArgumentException("null or empty aggregation property name"); |
| | | } |
| | |
| | | * @throws UnsupportedOperationException |
| | | * If this managed object definition is the {@link TopCfgDefn}. |
| | | */ |
| | | public final LocalizableMessage getSynopsis() throws UnsupportedOperationException { |
| | | public final LocalizableMessage getSynopsis() { |
| | | return getSynopsis(Locale.getDefault()); |
| | | } |
| | | |
| | |
| | | * @throws UnsupportedOperationException |
| | | * If this managed object definition is the {@link TopCfgDefn}. |
| | | */ |
| | | public final LocalizableMessage getSynopsis(Locale locale) throws UnsupportedOperationException { |
| | | public final LocalizableMessage getSynopsis(Locale locale) { |
| | | return ManagedObjectDefinitionI18NResource.getInstance().getMessage(this, "synopsis", locale); |
| | | } |
| | | |
| | |
| | | * @throws UnsupportedOperationException |
| | | * If this managed object definition is the {@link TopCfgDefn}. |
| | | */ |
| | | public final LocalizableMessage getUserFriendlyName() throws UnsupportedOperationException { |
| | | public final LocalizableMessage getUserFriendlyName() { |
| | | return getUserFriendlyName(Locale.getDefault()); |
| | | } |
| | | |
| | |
| | | * @throws UnsupportedOperationException |
| | | * If this managed object definition is the {@link TopCfgDefn}. |
| | | */ |
| | | public final LocalizableMessage getUserFriendlyName(Locale locale) throws UnsupportedOperationException { |
| | | public final LocalizableMessage getUserFriendlyName(Locale locale) { |
| | | return LocalizableMessage.raw(ManagedObjectDefinitionI18NResource.getInstance().getMessage(this, |
| | | "user-friendly-name", locale)); |
| | | } |
| | |
| | | * @throws UnsupportedOperationException |
| | | * If this managed object definition is the {@link TopCfgDefn}. |
| | | */ |
| | | public final LocalizableMessage getUserFriendlyPluralName() throws UnsupportedOperationException { |
| | | public final LocalizableMessage getUserFriendlyPluralName() { |
| | | return getUserFriendlyPluralName(Locale.getDefault()); |
| | | } |
| | | |
| | |
| | | * @throws UnsupportedOperationException |
| | | * If this managed object definition is the {@link TopCfgDefn}. |
| | | */ |
| | | public final LocalizableMessage getUserFriendlyPluralName(Locale locale) throws UnsupportedOperationException { |
| | | return ManagedObjectDefinitionI18NResource.getInstance().getMessage(this, |
| | | "user-friendly-plural-name", locale); |
| | | public final LocalizableMessage getUserFriendlyPluralName(Locale locale) { |
| | | return ManagedObjectDefinitionI18NResource.getInstance() |
| | | .getMessage(this, "user-friendly-plural-name", locale); |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | // Register a relation definition in the referenced managed object |
| | | // definition's reverse lookup table. |
| | | private <CC extends ConfigurationClient, SS extends Configuration> void registerReverseRelationDefinition( |
| | | RelationDefinition<CC, SS> rd) { |
| | | private <C1 extends ConfigurationClient, S1 extends Configuration> void registerReverseRelationDefinition( |
| | | RelationDefinition<C1, S1> rd) { |
| | | rd.getChildDefinition().reverseRelationDefinitions.add(rd); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | for (AbstractManagedObjectDefinition<? extends C, ? extends S> child : d.getChildren()) { |
| | | AbstractManagedObjectDefinition<? extends C, ? extends S> rd = resolveManagedObjectDefinitionAux(child, r); |
| | | AbstractManagedObjectDefinition<? extends C, ? extends S> rd = |
| | | resolveManagedObjectDefinitionAux(child, r); |
| | | if (rd != null) { |
| | | return rd; |
| | | } |
| | |
| | | * The type of server managed object configuration that this |
| | | * aggregation property definition refers to. |
| | | */ |
| | | public static class Builder<C extends ConfigurationClient, S extends Configuration> extends |
| | | public static final class Builder<C extends ConfigurationClient, S extends Configuration> extends |
| | | AbstractBuilder<String, AggregationPropertyDefinition<C, S>> { |
| | | |
| | | // The string representation of the managed object path specifying |
| | |
| | | /** |
| | | * A change listener which prevents the named component from being disabled. |
| | | */ |
| | | private class ReferentialIntegrityChangeListener implements ServerManagedObjectChangeListener<S> { |
| | | private final class ReferentialIntegrityChangeListener implements ServerManagedObjectChangeListener<S> { |
| | | |
| | | // The error message which should be returned if an attempt is |
| | | // made to disable the referenced component. |
| | |
| | | } catch (ConfigException e) { |
| | | // The condition could not be evaluated. |
| | | debugLogger.trace("Unable to perform post add", e); |
| | | LocalizableMessage message = ERR_REFINT_UNABLE_TO_EVALUATE_TARGET_CONDITION.get(mo |
| | | .getManagedObjectDefinition().getUserFriendlyName(), String.valueOf(mo.getDN()), |
| | | getExceptionMessage(e)); |
| | | LocalizedLogger logger = LocalizedLogger |
| | | .getLocalizedLogger(ERR_REFINT_UNABLE_TO_EVALUATE_TARGET_CONDITION.resourceName()); |
| | | LocalizableMessage message = |
| | | ERR_REFINT_UNABLE_TO_EVALUATE_TARGET_CONDITION.get(mo.getManagedObjectDefinition() |
| | | .getUserFriendlyName(), String.valueOf(mo.getDN()), getExceptionMessage(e)); |
| | | LocalizedLogger logger = |
| | | LocalizedLogger.getLocalizedLogger(ERR_REFINT_UNABLE_TO_EVALUATE_TARGET_CONDITION.resourceName()); |
| | | logger.error(message); |
| | | unacceptableReasons.add(message); |
| | | return false; |
| | |
| | | /** |
| | | * A delete listener which prevents the named component from being deleted. |
| | | */ |
| | | private class ReferentialIntegrityDeleteListener implements ConfigurationDeleteListener<S> { |
| | | private final class ReferentialIntegrityDeleteListener implements ConfigurationDeleteListener<S> { |
| | | |
| | | // The DN of the referenced configuration entry. |
| | | private final DN dn; |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isUsable(ServerManagedObject<?> managedObject, Collection<LocalizableMessage> unacceptableReasons) |
| | | throws ConfigException { |
| | | public boolean isUsable(ServerManagedObject<?> managedObject, |
| | | Collection<LocalizableMessage> unacceptableReasons) throws ConfigException { |
| | | SortedSet<String> names = managedObject.getPropertyValues(AggregationPropertyDefinition.this); |
| | | ServerManagementContext context = managedObject.getServerContext(); |
| | | LocalizableMessage thisUFN = managedObject.getManagedObjectDefinition().getUserFriendlyName(); |
| | |
| | | String thatDN = path.toDN().toString(); |
| | | |
| | | if (!context.managedObjectExists(path)) { |
| | | LocalizableMessage msg = ERR_SERVER_REFINT_DANGLING_REFERENCE.get(name, getName(), thisUFN, thisDN, thatUFN, |
| | | thatDN); |
| | | LocalizableMessage msg = |
| | | ERR_SERVER_REFINT_DANGLING_REFERENCE.get(name, getName(), thisUFN, thisDN, thatUFN, thatDN); |
| | | unacceptableReasons.add(msg); |
| | | isUsable = false; |
| | | } else if (needsEnabling) { |
| | |
| | | // required. |
| | | ServerManagedObject<? extends S> ref = context.getManagedObject(path); |
| | | if (!targetIsEnabledCondition.evaluate(ref)) { |
| | | LocalizableMessage msg = ERR_SERVER_REFINT_TARGET_DISABLED.get(name, getName(), thisUFN, thisDN, thatUFN, |
| | | thatDN); |
| | | LocalizableMessage msg = |
| | | ERR_SERVER_REFINT_TARGET_DISABLED.get(name, getName(), thisUFN, thisDN, thatUFN, thatDN); |
| | | unacceptableReasons.add(msg); |
| | | isUsable = false; |
| | | } |
| | |
| | | String thatDN = dn.toString(); |
| | | |
| | | // Register the delete listener. |
| | | LocalizableMessage msg = ERR_SERVER_REFINT_CANNOT_DELETE.get(thatUFN, thatDN, getName(), thisUFN, thisDN); |
| | | LocalizableMessage msg = |
| | | ERR_SERVER_REFINT_CANNOT_DELETE.get(thatUFN, thatDN, getName(), thisUFN, thisDN); |
| | | ReferentialIntegrityDeleteListener dl = new ReferentialIntegrityDeleteListener(dn, msg); |
| | | parent.registerDeleteListener(getRelationDefinition(), dl); |
| | | dlist.add(dl); |
| | |
| | | try { |
| | | ref = context.getManagedObject(path); |
| | | } catch (DefinitionDecodingException e) { |
| | | LocalizableMessage msg = ERR_CLIENT_REFINT_TARGET_INVALID.get(ufn, name, getName(), |
| | | e.getMessageObject()); |
| | | LocalizableMessage msg = |
| | | ERR_CLIENT_REFINT_TARGET_INVALID.get(ufn, name, getName(), e.getMessageObject()); |
| | | unacceptableReasons.add(msg); |
| | | isAcceptable = false; |
| | | continue; |
| | | } catch (ManagedObjectDecodingException e) { |
| | | LocalizableMessage msg = ERR_CLIENT_REFINT_TARGET_INVALID.get(ufn, name, getName(), |
| | | e.getMessageObject()); |
| | | LocalizableMessage msg = |
| | | ERR_CLIENT_REFINT_TARGET_INVALID.get(ufn, name, getName(), e.getMessageObject()); |
| | | unacceptableReasons.add(msg); |
| | | isAcceptable = false; |
| | | continue; |
| | |
| | | for (ManagedObject<?> mo : findReferences(context, getManagedObjectDefinition(), path.getName())) { |
| | | String name = mo.getManagedObjectPath().getName(); |
| | | if (name == null) { |
| | | LocalizableMessage msg = ERR_CLIENT_REFINT_CANNOT_DELETE_WITHOUT_NAME.get(getName(), mo |
| | | .getManagedObjectDefinition().getUserFriendlyName(), getManagedObjectDefinition() |
| | | .getUserFriendlyName()); |
| | | LocalizableMessage msg = |
| | | ERR_CLIENT_REFINT_CANNOT_DELETE_WITHOUT_NAME.get(getName(), mo.getManagedObjectDefinition() |
| | | .getUserFriendlyName(), getManagedObjectDefinition().getUserFriendlyName()); |
| | | unacceptableReasons.add(msg); |
| | | } else { |
| | | LocalizableMessage msg = ERR_CLIENT_REFINT_CANNOT_DELETE_WITH_NAME.get(getName(), mo |
| | | .getManagedObjectDefinition().getUserFriendlyName(), name, getManagedObjectDefinition() |
| | | .getUserFriendlyName()); |
| | | LocalizableMessage msg = |
| | | ERR_CLIENT_REFINT_CANNOT_DELETE_WITH_NAME.get(getName(), mo.getManagedObjectDefinition() |
| | | .getUserFriendlyName(), name, getManagedObjectDefinition().getUserFriendlyName()); |
| | | unacceptableReasons.add(msg); |
| | | } |
| | | isAcceptable = false; |
| | |
| | | if (targetNeedsEnablingCondition.evaluate(context, mo)) { |
| | | String name = mo.getManagedObjectPath().getName(); |
| | | if (name == null) { |
| | | LocalizableMessage msg = ERR_CLIENT_REFINT_CANNOT_DISABLE_WITHOUT_NAME.get(managedObject |
| | | LocalizableMessage msg = |
| | | ERR_CLIENT_REFINT_CANNOT_DISABLE_WITHOUT_NAME.get(managedObject |
| | | .getManagedObjectDefinition().getUserFriendlyName(), getName(), mo |
| | | .getManagedObjectDefinition().getUserFriendlyName()); |
| | | unacceptableReasons.add(msg); |
| | | } else { |
| | | LocalizableMessage msg = ERR_CLIENT_REFINT_CANNOT_DISABLE_WITH_NAME.get(managedObject |
| | | .getManagedObjectDefinition().getUserFriendlyName(), getName(), mo |
| | | .getManagedObjectDefinition().getUserFriendlyName(), name); |
| | | LocalizableMessage msg = |
| | | ERR_CLIENT_REFINT_CANNOT_DISABLE_WITH_NAME.get( |
| | | managedObject.getManagedObjectDefinition().getUserFriendlyName(), getName(), |
| | | mo.getManagedObjectDefinition().getUserFriendlyName(), name); |
| | | unacceptableReasons.add(msg); |
| | | } |
| | | isAcceptable = false; |
| | |
| | | |
| | | // Find all managed objects which reference the named managed |
| | | // object using this property. |
| | | private <CC extends ConfigurationClient> List<ManagedObject<? extends CC>> findReferences( |
| | | ManagementContext context, AbstractManagedObjectDefinition<CC, ?> mod, String name) |
| | | private <C1 extends ConfigurationClient> List<ManagedObject<? extends C1>> findReferences( |
| | | ManagementContext context, AbstractManagedObjectDefinition<C1, ?> mod, String name) |
| | | throws ErrorResultException { |
| | | List<ManagedObject<? extends CC>> instances = findInstances(context, mod); |
| | | List<ManagedObject<? extends C1>> instances = findInstances(context, mod); |
| | | |
| | | Iterator<ManagedObject<? extends CC>> i = instances.iterator(); |
| | | Iterator<ManagedObject<? extends C1>> i = instances.iterator(); |
| | | while (i.hasNext()) { |
| | | ManagedObject<? extends CC> mo = i.next(); |
| | | ManagedObject<? extends C1> mo = i.next(); |
| | | boolean hasReference = false; |
| | | |
| | | for (String value : mo.getPropertyValues(AggregationPropertyDefinition.this)) { |
| | |
| | | |
| | | // Find all instances of a specific type of managed object. |
| | | @SuppressWarnings("unchecked") |
| | | private <CC extends ConfigurationClient> List<ManagedObject<? extends CC>> findInstances( |
| | | ManagementContext context, AbstractManagedObjectDefinition<CC, ?> mod) throws ErrorResultException { |
| | | List<ManagedObject<? extends CC>> instances = new LinkedList<ManagedObject<? extends CC>>(); |
| | | private <C1 extends ConfigurationClient> List<ManagedObject<? extends C1>> findInstances( |
| | | ManagementContext context, AbstractManagedObjectDefinition<C1, ?> mod) throws ErrorResultException { |
| | | List<ManagedObject<? extends C1>> instances = new LinkedList<ManagedObject<? extends C1>>(); |
| | | |
| | | if (mod == RootCfgDefn.getInstance()) { |
| | | instances.add((ManagedObject<? extends CC>) context.getRootConfigurationManagedObject()); |
| | | instances.add((ManagedObject<? extends C1>) context.getRootConfigurationManagedObject()); |
| | | } else { |
| | | for (RelationDefinition<? super CC, ?> rd : mod.getAllReverseRelationDefinitions()) { |
| | | for (RelationDefinition<? super C1, ?> rd : mod.getAllReverseRelationDefinitions()) { |
| | | for (ManagedObject<?> parent : findInstances(context, rd.getParentDefinition())) { |
| | | try { |
| | | if (rd instanceof SingletonRelationDefinition) { |
| | | SingletonRelationDefinition<? super CC, ?> srd = (SingletonRelationDefinition<? super CC, ?>) rd; |
| | | SingletonRelationDefinition<? super C1, ?> srd = |
| | | (SingletonRelationDefinition<? super C1, ?>) rd; |
| | | ManagedObject<?> mo = parent.getChild(srd); |
| | | if (mo.getManagedObjectDefinition().isChildOf(mod)) { |
| | | instances.add((ManagedObject<? extends CC>) mo); |
| | | instances.add((ManagedObject<? extends C1>) mo); |
| | | } |
| | | } else if (rd instanceof OptionalRelationDefinition) { |
| | | OptionalRelationDefinition<? super CC, ?> ord = (OptionalRelationDefinition<? super CC, ?>) rd; |
| | | OptionalRelationDefinition<? super C1, ?> ord = |
| | | (OptionalRelationDefinition<? super C1, ?>) rd; |
| | | ManagedObject<?> mo = parent.getChild(ord); |
| | | if (mo.getManagedObjectDefinition().isChildOf(mod)) { |
| | | instances.add((ManagedObject<? extends CC>) mo); |
| | | instances.add((ManagedObject<? extends C1>) mo); |
| | | } |
| | | } else if (rd instanceof InstantiableRelationDefinition) { |
| | | InstantiableRelationDefinition<? super CC, ?> ird = (InstantiableRelationDefinition<? super CC, ?>) rd; |
| | | InstantiableRelationDefinition<? super C1, ?> ird = |
| | | (InstantiableRelationDefinition<? super C1, ?>) rd; |
| | | |
| | | for (String name : parent.listChildren(ird)) { |
| | | ManagedObject<?> mo = parent.getChild(ird, name); |
| | | if (mo.getManagedObjectDefinition().isChildOf(mod)) { |
| | | instances.add((ManagedObject<? extends CC>) mo); |
| | | instances.add((ManagedObject<? extends C1>) mo); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | // The active server-side referential integrity change listeners |
| | | // associated with this property. |
| | | private final Map<DN, List<ReferentialIntegrityChangeListener>> changeListeners = new HashMap<DN, List<ReferentialIntegrityChangeListener>>(); |
| | | private final Map<DN, List<ReferentialIntegrityChangeListener>> changeListeners = |
| | | new HashMap<DN, List<ReferentialIntegrityChangeListener>>(); |
| | | |
| | | // The active server-side referential integrity delete listeners |
| | | // associated with this property. |
| | | private final Map<DN, List<ReferentialIntegrityDeleteListener>> deleteListeners = new HashMap<DN, List<ReferentialIntegrityDeleteListener>>(); |
| | | private final Map<DN, List<ReferentialIntegrityDeleteListener>> deleteListeners = |
| | | new HashMap<DN, List<ReferentialIntegrityDeleteListener>>(); |
| | | |
| | | // The name of the managed object which is the parent of the |
| | | // aggregated managed objects. |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public String decodeValue(String value) throws IllegalPropertyValueStringException { |
| | | public String decodeValue(String value) { |
| | | Reject.ifNull(value); |
| | | |
| | | try { |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public String normalizeValue(String value) throws IllegalPropertyValueException { |
| | | public String normalizeValue(String value) { |
| | | try { |
| | | Reference<C, S> reference = Reference.parseName(parentPath, relationDefinition, value); |
| | | return reference.getNormalizedName(); |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void validateValue(String value) throws IllegalPropertyValueException { |
| | | public void validateValue(String value) { |
| | | try { |
| | | Reference.parseName(parentPath, relationDefinition, value); |
| | | } catch (IllegalArgumentException e) { |
| | |
| | | * An interface for incrementally constructing attribute type property |
| | | * definitions. |
| | | */ |
| | | public static class Builder extends AbstractBuilder<AttributeType, AttributeTypePropertyDefinition> { |
| | | public static final class Builder extends AbstractBuilder<AttributeType, AttributeTypePropertyDefinition> { |
| | | |
| | | // Private constructor |
| | | private Builder(AbstractManagedObjectDefinition<?, ?> d, String propertyName) { |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public AttributeType decodeValue(String value) throws IllegalPropertyValueStringException { |
| | | public AttributeType decodeValue(String value) { |
| | | Reject.ifNull(value); |
| | | |
| | | String name = value.trim().toLowerCase(); |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public String encodeValue(AttributeType value) throws IllegalPropertyValueException { |
| | | public String encodeValue(AttributeType value) { |
| | | return value.getNameOrOID(); |
| | | } |
| | | |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void validateValue(AttributeType value) throws IllegalPropertyValueException { |
| | | public void validateValue(AttributeType value) { |
| | | Reject.ifNull(value); |
| | | |
| | | // No implementation required. |
| | |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.server.admin; |
| | | |
| | | import org.forgerock.util.Reject; |
| | |
| | | /** |
| | | * Boolean property definition. |
| | | */ |
| | | public final class BooleanPropertyDefinition extends |
| | | PropertyDefinition<Boolean> { |
| | | public final class BooleanPropertyDefinition extends PropertyDefinition<Boolean> { |
| | | |
| | | /** |
| | | * Mapping used for parsing boolean values. This mapping is more flexible than |
| | | * the standard boolean string parser and supports common true/false synonyms |
| | | * used in configuration. |
| | | * Mapping used for parsing boolean values. This mapping is more flexible |
| | | * than the standard boolean string parser and supports common true/false |
| | | * synonyms used in configuration. |
| | | */ |
| | | private static final Map<String, Boolean> VALUE_MAP; |
| | | static { |
| | |
| | | VALUE_MAP.put("true", Boolean.TRUE); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * An interface for incrementally constructing boolean property definitions. |
| | | */ |
| | | public static class Builder extends |
| | | AbstractBuilder<Boolean, BooleanPropertyDefinition> { |
| | | public static final class Builder extends AbstractBuilder<Boolean, BooleanPropertyDefinition> { |
| | | |
| | | // Private constructor |
| | | private Builder( |
| | | AbstractManagedObjectDefinition<?, ?> d, String propertyName) { |
| | | private Builder(AbstractManagedObjectDefinition<?, ?> d, String propertyName) { |
| | | super(d, propertyName); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | protected BooleanPropertyDefinition buildInstance( |
| | | AbstractManagedObjectDefinition<?, ?> d, String propertyName, |
| | | EnumSet<PropertyOption> options, |
| | | AdministratorAction adminAction, |
| | | protected BooleanPropertyDefinition buildInstance(AbstractManagedObjectDefinition<?, ?> d, |
| | | String propertyName, EnumSet<PropertyOption> options, AdministratorAction adminAction, |
| | | DefaultBehaviorProvider<Boolean> defaultBehavior) { |
| | | return new BooleanPropertyDefinition(d, propertyName, options, |
| | | adminAction, defaultBehavior); |
| | | return new BooleanPropertyDefinition(d, propertyName, options, adminAction, defaultBehavior); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Create a boolean property definition builder. |
| | | * |
| | | * @param d |
| | | * The managed object definition associated with this |
| | | * property definition. |
| | | * The managed object definition associated with this property |
| | | * definition. |
| | | * @param propertyName |
| | | * The property name. |
| | | * @return Returns the new boolean property definition builder. |
| | | */ |
| | | public static Builder createBuilder( |
| | | AbstractManagedObjectDefinition<?, ?> d, String propertyName) { |
| | | public static Builder createBuilder(AbstractManagedObjectDefinition<?, ?> d, String propertyName) { |
| | | return new Builder(d, propertyName); |
| | | } |
| | | |
| | | |
| | | |
| | | // Private constructor. |
| | | private BooleanPropertyDefinition( |
| | | AbstractManagedObjectDefinition<?, ?> d, String propertyName, |
| | | EnumSet<PropertyOption> options, |
| | | AdministratorAction adminAction, |
| | | private BooleanPropertyDefinition(AbstractManagedObjectDefinition<?, ?> d, String propertyName, |
| | | EnumSet<PropertyOption> options, AdministratorAction adminAction, |
| | | DefaultBehaviorProvider<Boolean> defaultBehavior) { |
| | | super(d, Boolean.class, propertyName, options, adminAction, |
| | | defaultBehavior); |
| | | super(d, Boolean.class, propertyName, options, adminAction, defaultBehavior); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void validateValue(Boolean value) |
| | | throws IllegalPropertyValueException { |
| | | public void validateValue(Boolean value) { |
| | | Reject.ifNull(value); |
| | | |
| | | // No additional validation required. |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public Boolean decodeValue(String value) |
| | | throws IllegalPropertyValueStringException { |
| | | public Boolean decodeValue(String value) { |
| | | Reject.ifNull(value); |
| | | |
| | | String nvalue = value.trim().toLowerCase(); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | |
| | | return v.visitBoolean(this, p); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | |
| | | return v.visitBoolean(this, value, p); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | |
| | | */ |
| | | public final class ClassLoaderProvider { |
| | | |
| | | private static final LocalizedLogger adminLogger = LocalizedLogger.getLocalizedLogger(AdminMessages.resourceName()); |
| | | private static final LocalizedLogger adminLogger = LocalizedLogger.getLocalizedLogger(AdminMessages |
| | | .resourceName()); |
| | | private static final Logger debugLogger = LoggerFactory.getLogger(ClassLoaderProvider.class); |
| | | |
| | | /** |
| | |
| | | * @throws SecurityException |
| | | * If a required system property value cannot be accessed. |
| | | */ |
| | | public void addJarFile(File jarFile) throws SecurityException, MalformedURLException { |
| | | public void addJarFile(File jarFile) throws MalformedURLException { |
| | | addURL(jarFile.toURI().toURL()); |
| | | } |
| | | |
| | |
| | | |
| | | // The attribute names for build information is name, version and revision |
| | | // number |
| | | private static final String[] BUILD_INFORMATION_ATTRIBUTE_NAMES = new String[] { |
| | | Attributes.Name.EXTENSION_NAME.toString(), Attributes.Name.IMPLEMENTATION_VERSION.toString(), |
| | | private static final String[] BUILD_INFORMATION_ATTRIBUTE_NAMES = |
| | | new String[] { Attributes.Name.EXTENSION_NAME.toString(), Attributes.Name.IMPLEMENTATION_VERSION.toString(), |
| | | REVISION_NUMBER }; |
| | | |
| | | /** |
| | |
| | | * If one of the extension names was not a single relative path |
| | | * name element or was an absolute path. |
| | | */ |
| | | public synchronized void addExtension(String... extensions) throws InitializationException, IllegalStateException, |
| | | IllegalArgumentException { |
| | | public synchronized void addExtension(String... extensions) throws InitializationException { |
| | | Reject.ifNull(extensions); |
| | | |
| | | if (loader == null) { |
| | |
| | | * @throws IllegalStateException |
| | | * If this class loader provider is already disabled. |
| | | */ |
| | | public synchronized void disable() throws IllegalStateException { |
| | | public synchronized void disable() { |
| | | if (loader == null) { |
| | | throw new IllegalStateException("Class loader provider already disabled."); |
| | | } |
| | |
| | | * @throws IllegalStateException |
| | | * If this class loader provider is already enabled. |
| | | */ |
| | | public synchronized void enable() throws InitializationException, IllegalStateException { |
| | | public synchronized void enable() throws InitializationException { |
| | | enable(RootCfgDefn.class.getClassLoader()); |
| | | } |
| | | |
| | |
| | | * @throws IllegalStateException |
| | | * If this class loader provider is already enabled. |
| | | */ |
| | | public synchronized void enable(ClassLoader parent) throws InitializationException, IllegalStateException { |
| | | public synchronized void enable(ClassLoader parent) throws InitializationException { |
| | | if (loader != null) { |
| | | throw new IllegalStateException("Class loader provider already enabled."); |
| | | } |
| | |
| | | loader.addJarFile(extension); |
| | | } catch (Exception e) { |
| | | debugLogger.trace("Unable to register the jar file with the class loader", e); |
| | | LocalizableMessage message = ERR_ADMIN_CANNOT_OPEN_JAR_FILE.get(extension.getName(), |
| | | extension.getParent(), stackTraceToSingleLineString(e, DynamicConstants.DEBUG_BUILD)); |
| | | LocalizableMessage message = |
| | | ERR_ADMIN_CANNOT_OPEN_JAR_FILE.get(extension.getName(), extension.getParent(), |
| | | stackTraceToSingleLineString(e, DynamicConstants.DEBUG_BUILD)); |
| | | throw new InitializationException(message); |
| | | } |
| | | jarFiles.add(extension); |
| | |
| | | * <code>null</code> if there is no information available. |
| | | */ |
| | | public String printExtensionInformation() { |
| | | File extensionsPath = new File(new StringBuilder(DirectoryServer.getServerRoot()).append(File.separator) |
| | | .append(LIB_DIR).append(File.separator).append(EXTENSIONS_DIR).toString()); |
| | | File extensionsPath = |
| | | new File(new StringBuilder(DirectoryServer.getServerRoot()).append(File.separator).append(LIB_DIR) |
| | | .append(File.separator).append(EXTENSIONS_DIR).toString()); |
| | | |
| | | if (!extensionsPath.exists() || !extensionsPath.isDirectory()) { |
| | | // no extensions' directory |
| | |
| | | if (!extensionsPath.isDirectory()) { |
| | | // The extensions directory is not a directory. This is more |
| | | // critical. |
| | | LocalizableMessage message = ERR_ADMIN_EXTENSIONS_DIR_NOT_DIRECTORY.get(String.valueOf(extensionsPath)); |
| | | LocalizableMessage message = |
| | | ERR_ADMIN_EXTENSIONS_DIR_NOT_DIRECTORY.get(String.valueOf(extensionsPath)); |
| | | throw new InitializationException(message); |
| | | } |
| | | |
| | |
| | | throw e; |
| | | } catch (Exception e) { |
| | | debugLogger.trace("Unable to initialize all extensions", e); |
| | | LocalizableMessage message = ERR_ADMIN_EXTENSIONS_CANNOT_LIST_FILES.get(String.valueOf(extensionsPath), |
| | | LocalizableMessage message = |
| | | ERR_ADMIN_EXTENSIONS_CANNOT_LIST_FILES.get(String.valueOf(extensionsPath), |
| | | stackTraceToSingleLineString(e, DynamicConstants.DEBUG_BUILD)); |
| | | throw new InitializationException(message, e); |
| | | } |
| | |
| | | loadDefinitionClasses(is); |
| | | } catch (InitializationException e) { |
| | | debugLogger.trace("Unable to initialize core components", e); |
| | | LocalizableMessage message = ERR_CLASS_LOADER_CANNOT_LOAD_CORE.get(CORE_MANIFEST, |
| | | LocalizableMessage message = |
| | | ERR_CLASS_LOADER_CANNOT_LOAD_CORE.get(CORE_MANIFEST, |
| | | stackTraceToSingleLineString(e, DynamicConstants.DEBUG_BUILD)); |
| | | throw new InitializationException(message); |
| | | } |
| | |
| | | is = jarFile.getInputStream(entry); |
| | | } catch (Exception e) { |
| | | debugLogger.trace("Unable to get input stream from jar", e); |
| | | LocalizableMessage message = ERR_ADMIN_CANNOT_READ_EXTENSION_MANIFEST.get(EXTENSION_MANIFEST, |
| | | jarFile.getName(), stackTraceToSingleLineString(e, DynamicConstants.DEBUG_BUILD)); |
| | | LocalizableMessage message = |
| | | ERR_ADMIN_CANNOT_READ_EXTENSION_MANIFEST.get(EXTENSION_MANIFEST, jarFile.getName(), |
| | | stackTraceToSingleLineString(e, DynamicConstants.DEBUG_BUILD)); |
| | | throw new InitializationException(message); |
| | | } |
| | | |
| | |
| | | loadDefinitionClasses(is); |
| | | } catch (InitializationException e) { |
| | | debugLogger.trace("Unable to load classes from input stream", e); |
| | | LocalizableMessage message = ERR_CLASS_LOADER_CANNOT_LOAD_EXTENSION.get(jarFile.getName(), |
| | | EXTENSION_MANIFEST, stackTraceToSingleLineString(e, DynamicConstants.DEBUG_BUILD)); |
| | | LocalizableMessage message = |
| | | ERR_CLASS_LOADER_CANNOT_LOAD_EXTENSION.get(jarFile.getName(), EXTENSION_MANIFEST, |
| | | stackTraceToSingleLineString(e, DynamicConstants.DEBUG_BUILD)); |
| | | throw new InitializationException(message); |
| | | } |
| | | try { |
| | | // Log build information of extensions in the error log |
| | | String[] information = getBuildInformation(jarFile); |
| | | LocalizableMessage message = NOTE_LOG_EXTENSION_INFORMATION.get(jarFile.getName(), information[1], |
| | | information[2]); |
| | | LocalizableMessage message = |
| | | NOTE_LOG_EXTENSION_INFORMATION.get(jarFile.getName(), information[1], information[2]); |
| | | LocalizedLogger.getLocalizedLogger(message.resourceName()).error(message); |
| | | } catch (Exception e) { |
| | | // Do not log information for that extension |
| | |
| | | */ |
| | | private void loadDefinitionClasses(InputStream is) throws InitializationException { |
| | | BufferedReader reader = new BufferedReader(new InputStreamReader(is)); |
| | | List<AbstractManagedObjectDefinition<?, ?>> definitions = new LinkedList<AbstractManagedObjectDefinition<?, ?>>(); |
| | | List<AbstractManagedObjectDefinition<?, ?>> definitions = |
| | | new LinkedList<AbstractManagedObjectDefinition<?, ?>>(); |
| | | while (true) { |
| | | String className; |
| | | try { |
| | | className = reader.readLine(); |
| | | } catch (IOException e) { |
| | | LocalizableMessage msg = ERR_CLASS_LOADER_CANNOT_READ_MANIFEST_FILE.get(String.valueOf(e.getMessage())); |
| | | LocalizableMessage msg = |
| | | ERR_CLASS_LOADER_CANNOT_READ_MANIFEST_FILE.get(String.valueOf(e.getMessage())); |
| | | throw new InitializationException(msg, e); |
| | | } |
| | | |
| | |
| | | try { |
| | | theClass = Class.forName(className, true, loader); |
| | | } catch (Exception e) { |
| | | LocalizableMessage msg = ERR_CLASS_LOADER_CANNOT_LOAD_CLASS.get(className, |
| | | String.valueOf(e.getMessage())); |
| | | LocalizableMessage msg = |
| | | ERR_CLASS_LOADER_CANNOT_LOAD_CLASS.get(className, String.valueOf(e.getMessage())); |
| | | throw new InitializationException(msg, e); |
| | | } |
| | | if (AbstractManagedObjectDefinition.class.isAssignableFrom(theClass)) { |
| | |
| | | try { |
| | | method = theClass.getMethod("getInstance"); |
| | | } catch (Exception e) { |
| | | LocalizableMessage msg = ERR_CLASS_LOADER_CANNOT_FIND_GET_INSTANCE_METHOD.get(className, |
| | | LocalizableMessage msg = |
| | | ERR_CLASS_LOADER_CANNOT_FIND_GET_INSTANCE_METHOD.get(className, |
| | | String.valueOf(e.getMessage())); |
| | | throw new InitializationException(msg, e); |
| | | } |
| | |
| | | try { |
| | | d = (AbstractManagedObjectDefinition<?, ?>) method.invoke(null); |
| | | } catch (Exception e) { |
| | | LocalizableMessage msg = ERR_CLASS_LOADER_CANNOT_INVOKE_GET_INSTANCE_METHOD.get(className, |
| | | LocalizableMessage msg = |
| | | ERR_CLASS_LOADER_CANNOT_INVOKE_GET_INSTANCE_METHOD.get(className, |
| | | String.valueOf(e.getMessage())); |
| | | throw new InitializationException(msg, e); |
| | | } |
| | |
| | | try { |
| | | d.initialize(); |
| | | } catch (Exception e) { |
| | | LocalizableMessage msg = ERR_CLASS_LOADER_CANNOT_INITIALIZE_DEFN.get(d.getName(), d.getClass() |
| | | .getName(), String.valueOf(e.getMessage())); |
| | | LocalizableMessage msg = |
| | | ERR_CLASS_LOADER_CANNOT_INITIALIZE_DEFN.get(d.getName(), d.getClass().getName(), |
| | | String.valueOf(e.getMessage())); |
| | | throw new InitializationException(msg, e); |
| | | } |
| | | } |
| | |
| | | } catch (Exception e) { |
| | | debugLogger.trace("Unable to load jar file: " + jar, e); |
| | | |
| | | LocalizableMessage message = ERR_ADMIN_CANNOT_OPEN_JAR_FILE.get(jar.getName(), jar.getParent(), |
| | | LocalizableMessage message = |
| | | ERR_ADMIN_CANNOT_OPEN_JAR_FILE.get(jar.getName(), jar.getParent(), |
| | | stackTraceToSingleLineString(e, DynamicConstants.DEBUG_BUILD)); |
| | | throw new InitializationException(message); |
| | | } |
| | |
| | | /** |
| | | * An interface for incrementally constructing class property definitions. |
| | | */ |
| | | public static class Builder extends AbstractBuilder<String, ClassPropertyDefinition> { |
| | | public static final class Builder extends AbstractBuilder<String, ClassPropertyDefinition> { |
| | | |
| | | // List of interfaces which property values must implement. |
| | | private List<String> instanceOfInterfaces; |
| | |
| | | } |
| | | |
| | | // Load a named class. |
| | | private static Class<?> loadClass(String className, boolean initialize) |
| | | throws ClassNotFoundException, LinkageError { |
| | | return Class.forName(className, initialize, ClassLoaderProvider.getInstance() |
| | | .getClassLoader()); |
| | | private static Class<?> loadClass(String className, boolean initialize) throws ClassNotFoundException { |
| | | return Class.forName(className, initialize, ClassLoaderProvider.getInstance().getClassLoader()); |
| | | } |
| | | |
| | | // List of interfaces which property values must implement. |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public String decodeValue(String value) throws IllegalPropertyValueStringException { |
| | | public String decodeValue(String value) { |
| | | Reject.ifNull(value); |
| | | |
| | | try { |
| | |
| | | * If the referenced class does not implement the requested |
| | | * type. |
| | | */ |
| | | public <T> Class<? extends T> loadClass(String className, Class<T> instanceOf) |
| | | throws IllegalPropertyValueException, ClassCastException { |
| | | public <T> Class<? extends T> loadClass(String className, Class<T> instanceOf) { |
| | | Reject.ifNull(className, instanceOf); |
| | | |
| | | // Make sure that the named class is valid. |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public String normalizeValue(String value) throws IllegalPropertyValueException { |
| | | public String normalizeValue(String value) { |
| | | Reject.ifNull(value); |
| | | |
| | | return value.trim(); |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void validateValue(String value) throws IllegalPropertyValueException { |
| | | public void validateValue(String value) { |
| | | Reject.ifNull(value); |
| | | |
| | | // Always make sure the name is a valid class name. |
| | |
| | | /* |
| | | * Do some basic checks to make sure the string representation is valid. |
| | | */ |
| | | private void validateClassName(String className) throws IllegalPropertyValueException { |
| | | private void validateClassName(String className) { |
| | | String nvalue = className.trim(); |
| | | if (!nvalue.matches(CLASS_RE)) { |
| | | throw new IllegalPropertyValueException(this, className); |
| | | } |
| | | } |
| | | |
| | | |
| | | /* |
| | | * Make sure that named class implements the interfaces named by this |
| | | * definition. |
| | | */ |
| | | private Class<?> validateClassInterfaces(String className, boolean initialize) |
| | | throws IllegalPropertyValueException { |
| | | private Class<?> validateClassInterfaces(String className, boolean initialize) { |
| | | Class<?> theClass = loadClassForValidation(className, className, initialize); |
| | | for (String i : instanceOfInterfaces) { |
| | | Class<?> instanceOfClass = loadClassForValidation(className, i, initialize); |
| | |
| | | return theClass; |
| | | } |
| | | |
| | | private Class<?> loadClassForValidation(String componentClassName, String classToBeLoaded, |
| | | boolean initialize) { |
| | | private Class<?> loadClassForValidation(String componentClassName, String classToBeLoaded, boolean initialize) { |
| | | try { |
| | | return loadClass(classToBeLoaded.trim(), initialize); |
| | | } catch (ClassNotFoundException e) { |
| | |
| | | import org.forgerock.opendj.ldap.DN; |
| | | |
| | | /** |
| | | * A common base interface for all server managed object |
| | | * configurations. |
| | | * A common base interface for all server managed object configurations. |
| | | */ |
| | | public interface Configuration { |
| | | |
| | |
| | | */ |
| | | DN dn(); |
| | | |
| | | |
| | | |
| | | /** |
| | | * Gets the configuration class associated with this configuration. |
| | | * |
| | |
| | | /** |
| | | * An interface for incrementally constructing DN property definitions. |
| | | */ |
| | | public static class Builder extends AbstractBuilder<DN, DNPropertyDefinition> { |
| | | public static final class Builder extends AbstractBuilder<DN, DNPropertyDefinition> { |
| | | |
| | | // Optional base DN which all valid values must be immediately |
| | | // subordinate to. |
| | |
| | | * If the provided string is not a valid DN string |
| | | * representation. |
| | | */ |
| | | public void setBaseDN(String baseDN) throws IllegalArgumentException { |
| | | public void setBaseDN(String baseDN) { |
| | | if (baseDN == null) { |
| | | setBaseDN((DN) null); |
| | | } else { |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void validateValue(DN value) throws IllegalPropertyValueException { |
| | | public void validateValue(DN value) { |
| | | Reject.ifNull(value); |
| | | |
| | | if (baseDN != null) { |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public DN decodeValue(String value) throws IllegalPropertyValueStringException { |
| | | public DN decodeValue(String value) { |
| | | Reject.ifNull(value); |
| | | |
| | | try { |
| | |
| | | */ |
| | | package org.opends.server.admin; |
| | | |
| | | |
| | | |
| | | /** |
| | | * An interface for determining the default behavior of a property. A |
| | | * property exhibits default behavior when it has no values defined. |
| | | * There are four different types of default behavior: |
| | | * An interface for determining the default behavior of a property. A property |
| | | * exhibits default behavior when it has no values defined. There are four |
| | | * different types of default behavior: |
| | | * <ol> |
| | | * <li>there is no default behavior - e.g. leaving a "description" |
| | | * unset has no side-effects. This default behavior is represented |
| | | * using the {@link UndefinedDefaultBehaviorProvider} implementation |
| | | * <li>the property defaults to one or more real values of the |
| | | * property. This default behavior is represented using the |
| | | * <li>there is no default behavior - e.g. leaving a "description" unset has no |
| | | * side-effects. This default behavior is represented using the |
| | | * {@link UndefinedDefaultBehaviorProvider} implementation |
| | | * <li>the property defaults to one or more real values of the property. This |
| | | * default behavior is represented using the |
| | | * {@link DefinedDefaultBehaviorProvider} implementation |
| | | * <li>the property defaults to some special behavior that cannot be |
| | | * represented using real property values. This default behavior is |
| | | * represented using the {@link AliasDefaultBehaviorProvider} |
| | | * implementation |
| | | * <li>the property inherits its values from property held in another |
| | | * managed object (e.g. the parent managed object). This default |
| | | * behavior is represented using the |
| | | * {@link AbsoluteInheritedDefaultBehaviorProvider} and |
| | | * <li>the property defaults to some special behavior that cannot be represented |
| | | * using real property values. This default behavior is represented using the |
| | | * {@link AliasDefaultBehaviorProvider} implementation |
| | | * <li>the property inherits its values from property held in another managed |
| | | * object (e.g. the parent managed object). This default behavior is represented |
| | | * using the {@link AbsoluteInheritedDefaultBehaviorProvider} and |
| | | * {@link RelativeInheritedDefaultBehaviorProvider} implementations. |
| | | * </ol> |
| | | * An application can perform actions based on the type of the default |
| | | * behavior by implementing the {@link DefaultBehaviorProviderVisitor} |
| | | * interface. |
| | | * An application can perform actions based on the type of the default behavior |
| | | * by implementing the {@link DefaultBehaviorProviderVisitor} interface. |
| | | * |
| | | * @param <T> |
| | | * The type of values represented by this provider. |
| | |
| | | // No implementation required. |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Apply a visitor to this default behavior provider. |
| | | * |
| | |
| | | * Optional additional visitor parameter. |
| | | * @return Returns a result as specified by the visitor. |
| | | */ |
| | | public abstract <R, P> |
| | | R accept(DefaultBehaviorProviderVisitor<T, R, P> v, P p); |
| | | |
| | | |
| | | public abstract <R, P> R accept(DefaultBehaviorProviderVisitor<T, R, P> v, P p); |
| | | |
| | | /** |
| | | * Performs any run-time initialization required by this default |
| | | * behavior provider. This may include resolving managed object |
| | | * paths and property names. |
| | | * Performs any run-time initialization required by this default behavior |
| | | * provider. This may include resolving managed object paths and property |
| | | * names. |
| | | * <p> |
| | | * The default implementation is to do nothing. |
| | | * |
| | | * @throws Exception |
| | | * If this default behavior provider could not be |
| | | * initialized. |
| | | * If this default behavior provider could not be initialized. |
| | | */ |
| | | protected void initialize() throws Exception { |
| | | // Default implementation is to do nothing. |
| | |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.server.admin; |
| | | |
| | | |
| | | |
| | | /** |
| | | * A visitor of default behavior providers, in the style of the visitor design |
| | | * pattern. Classes implementing this interface can query default behavior |
| | | * providers in a type-safe manner when the kind of default behavior provider |
| | | * is unknown at compile time. When a visitor is passed to a default behavior |
| | | * providers in a type-safe manner when the kind of default behavior provider is |
| | | * unknown at compile time. When a visitor is passed to a default behavior |
| | | * provider's accept method, the corresponding visit method most applicable to |
| | | * that default behavior provider is invoked. |
| | | * |
| | |
| | | * {@link java.lang.Void} for visitors that do not need to return |
| | | * results. |
| | | * @param <P> |
| | | * The type of the additional parameter to this visitor's methods. Use |
| | | * {@link java.lang.Void} for visitors that do not need an additional |
| | | * parameter. |
| | | * The type of the additional parameter to this visitor's methods. |
| | | * Use {@link java.lang.Void} for visitors that do not need an |
| | | * additional parameter. |
| | | */ |
| | | public interface DefaultBehaviorProviderVisitor<T, R, P> { |
| | | |
| | |
| | | */ |
| | | R visitAbsoluteInherited(AbsoluteInheritedDefaultBehaviorProvider<T> d, P p); |
| | | |
| | | |
| | | |
| | | /** |
| | | * Visit an alias default behavior provider. |
| | | * |
| | |
| | | */ |
| | | R visitAlias(AliasDefaultBehaviorProvider<T> d, P p); |
| | | |
| | | |
| | | |
| | | /** |
| | | * Visit an defined default behavior provider. |
| | | * |
| | |
| | | */ |
| | | R visitDefined(DefinedDefaultBehaviorProvider<T> d, P p); |
| | | |
| | | |
| | | |
| | | /** |
| | | * Visit a relative inherited default behavior provider. |
| | | * |
| | |
| | | */ |
| | | R visitRelativeInherited(RelativeInheritedDefaultBehaviorProvider<T> d, P p); |
| | | |
| | | |
| | | |
| | | /** |
| | | * Visit an undefined default behavior provider. |
| | | * |
| | |
| | | */ |
| | | package org.opends.server.admin; |
| | | |
| | | |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | |
| | | import java.util.SortedSet; |
| | | import java.util.TreeSet; |
| | | |
| | | |
| | | |
| | | /** |
| | | * A default managed object which should be created when a parent |
| | | * managed object is created. Default managed objects are associated |
| | | * with a {@link RelationDefinition}. |
| | | * A default managed object which should be created when a parent managed object |
| | | * is created. Default managed objects are associated with a |
| | | * {@link RelationDefinition}. |
| | | * |
| | | * @param <C> |
| | | * The type of client default managed object configuration. |
| | | * @param <S> |
| | | * The type of server default managed object configuration. |
| | | */ |
| | | public final class DefaultManagedObject |
| | | <C extends ConfigurationClient, S extends Configuration> |
| | | implements PropertyProvider { |
| | | public final class DefaultManagedObject<C extends ConfigurationClient, S extends Configuration> implements |
| | | PropertyProvider { |
| | | |
| | | /** |
| | | * An interface for incrementally constructing default managed |
| | | * objects. |
| | | * An interface for incrementally constructing default managed objects. |
| | | * |
| | | * @param <C> |
| | | * The type of client default managed object configuration. |
| | | * @param <S> |
| | | * The type of server default managed object configuration. |
| | | */ |
| | | public static final class Builder |
| | | <C extends ConfigurationClient, S extends Configuration> { |
| | | public static final class Builder<C extends ConfigurationClient, S extends Configuration> { |
| | | |
| | | // The default managed object's definition. |
| | | private final ManagedObjectDefinition<C, S> definition; |
| | | |
| | | // The string encoded default managed object's properties. |
| | | private final Map<String, List<String>> propertyStringValues = |
| | | new HashMap<String, List<String>>(); |
| | | |
| | | |
| | | private final Map<String, List<String>> propertyStringValues = new HashMap<String, List<String>>(); |
| | | |
| | | /** |
| | | * Creates a new default managed object builder. |
| | |
| | | this.definition = definition; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Construct a default managed object based on the properties of |
| | | * this builder. |
| | | * Construct a default managed object based on the properties of this |
| | | * builder. |
| | | * |
| | | * @return Returns the new default managed object. |
| | | */ |
| | |
| | | return new DefaultManagedObject<C, S>(definition, propertyStringValues); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Defines a property's values for the default managed object. |
| | | * |
| | | * @param name |
| | | * The name of the property. |
| | | * @param values |
| | | * One or more property values in the string |
| | | * representation. |
| | | * One or more property values in the string representation. |
| | | */ |
| | | public void setPropertyValues(String name, String... values) { |
| | | if (values == null || values.length == 0) { |
| | | throw new IllegalArgumentException( |
| | | "null or empty values specified for property " + name); |
| | | throw new IllegalArgumentException("null or empty values specified for property " + name); |
| | | } |
| | | |
| | | propertyStringValues.put(name, Arrays.asList(values)); |
| | |
| | | // The string encoded default managed object's properties. |
| | | private final Map<String, List<String>> propertyStringValues; |
| | | |
| | | |
| | | |
| | | // Private constructor. |
| | | private DefaultManagedObject(ManagedObjectDefinition<C, S> definition, |
| | | Map<String, List<String>> propertyStringValues) { |
| | |
| | | this.propertyStringValues = propertyStringValues; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Gets the managed object definition associated with this default |
| | | * managed object. |
| | | * Gets the managed object definition associated with this default managed |
| | | * object. |
| | | * |
| | | * @return Returns the managed object definition associated with |
| | | * this default managed object. |
| | | * @return Returns the managed object definition associated with this |
| | | * default managed object. |
| | | */ |
| | | public ManagedObjectDefinition<C, S> getManagedObjectDefinition() { |
| | | return definition; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Gets a mutable copy of the set of property values for the |
| | | * specified property. |
| | | * Gets a mutable copy of the set of property values for the specified |
| | | * property. |
| | | * |
| | | * @param <T> |
| | | * The type of the property to be retrieved. |
| | | * @param pd |
| | | * The property to be retrieved. |
| | | * @return Returns a newly allocated set containing a copy of the |
| | | * property's values. An empty set indicates that the |
| | | * property has no values defined and any default behavior |
| | | * is applicable. |
| | | * @return Returns a newly allocated set containing a copy of the property's |
| | | * values. An empty set indicates that the property has no values |
| | | * defined and any default behavior is applicable. |
| | | * @throws IllegalArgumentException |
| | | * If the property definition is not associated with this |
| | | * managed object's definition. |
| | | */ |
| | | public <T> SortedSet<T> getPropertyValues(PropertyDefinition<T> pd) |
| | | throws IllegalArgumentException { |
| | | public <T> SortedSet<T> getPropertyValues(PropertyDefinition<T> pd) { |
| | | // Validate the property definition. |
| | | definition.getPropertyDefinition(pd.getName()); |
| | | |
| | |
| | | return values; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Performs run-time initialization of properties. |
| | | * |
| | | * @throws Exception |
| | | * If this default managed object could not be |
| | | * initialized. |
| | | * If this default managed object could not be initialized. |
| | | */ |
| | | void initialize() throws Exception { |
| | | // FIXME: it would be nice if we could decode all property values |
| | |
| | | */ |
| | | package org.opends.server.admin; |
| | | |
| | | |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Collection; |
| | | |
| | | |
| | | |
| | | /** |
| | | * A default behavior provider which represents a well-defined set of default |
| | | * values. It should be used by properties which have default value(s) which are |
| | |
| | | * @param <T> |
| | | * The type of values represented by this provider. |
| | | */ |
| | | public final class DefinedDefaultBehaviorProvider<T> extends |
| | | DefaultBehaviorProvider<T> { |
| | | public final class DefinedDefaultBehaviorProvider<T> extends DefaultBehaviorProvider<T> { |
| | | |
| | | // The collection of default values. |
| | | private final Collection<String> values; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Create a new defined default behavior provider associated with the |
| | | * specified list of values. |
| | |
| | | * @throws IllegalArgumentException |
| | | * If the list of values was <code>null</code> or empty. |
| | | */ |
| | | public DefinedDefaultBehaviorProvider(String... values) |
| | | throws IllegalArgumentException { |
| | | public DefinedDefaultBehaviorProvider(String... values) { |
| | | if (values == null || values.length == 0) { |
| | | throw new IllegalArgumentException( |
| | | "Null or empty list of default values"); |
| | | throw new IllegalArgumentException("Null or empty list of default values"); |
| | | } |
| | | this.values = Arrays.asList(values); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | |
| | | return v.visitDefined(this, p); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Get a copy of the default values. |
| | | * |
| | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | /** |
| | | * The requested managed object was found but its type could not be |
| | | * determined. |
| | | * The requested managed object was found but its type could not be determined. |
| | | */ |
| | | public class DefinitionDecodingException extends DecodingException { |
| | | |
| | | /** |
| | | * An enumeration defining the reasons why the definition could not |
| | | * be resolved. |
| | | * An enumeration defining the reasons why the definition could not be |
| | | * resolved. |
| | | */ |
| | | public static enum Reason { |
| | | /** |
| | |
| | | NO_TYPE_INFORMATION(), |
| | | |
| | | /** |
| | | * The managed object could be found but did not contain the |
| | | * expected type information (eg incorrect object classes in |
| | | * LDAP). |
| | | * The managed object could be found but did not contain the expected |
| | | * type information (eg incorrect object classes in LDAP). |
| | | */ |
| | | WRONG_TYPE_INFORMATION(); |
| | | |
| | |
| | | */ |
| | | private static final long serialVersionUID = 3459033551415663416L; |
| | | |
| | | |
| | | |
| | | // Create the message. |
| | | private static LocalizableMessage createLocalizableMessage(AbstractManagedObjectDefinition<?, ?> d, |
| | | Reason reason) { |
| | | private static LocalizableMessage createLocalizableMessage(AbstractManagedObjectDefinition<?, ?> d, Reason reason) { |
| | | LocalizableMessage ufn = d.getUserFriendlyName(); |
| | | switch (reason) { |
| | | case NO_TYPE_INFORMATION: |
| | |
| | | // The reason why the definition could not be determined. |
| | | private final Reason reason; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Create a new definition decoding exception. |
| | | * |
| | |
| | | * @param reason |
| | | * The reason why the definition could not be determined. |
| | | */ |
| | | public DefinitionDecodingException(AbstractManagedObjectDefinition<?, ?> d, |
| | | Reason reason) { |
| | | public DefinitionDecodingException(AbstractManagedObjectDefinition<?, ?> d, Reason reason) { |
| | | super(createLocalizableMessage(d, reason)); |
| | | this.d = d; |
| | | this.reason = reason; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Gets the expected managed object definition. |
| | | * |
| | |
| | | return d; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Gets the reason why the definition could not be determined. |
| | | * |
| | | * @return Returns the reason why the definition could not be |
| | | * determined. |
| | | * @return Returns the reason why the definition could not be determined. |
| | | */ |
| | | public Reason getReason() { |
| | | return reason; |
| | |
| | | */ |
| | | package org.opends.server.admin; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This interface is used to determine the "best match" managed object |
| | | * definition in a definition hierarchy. |
| | | * <p> |
| | | * Managed object definitions, like Java classes, are arranged in an |
| | | * inheritance hierarchy. When managed objects are decoded (e.g. from |
| | | * LDAP entries), the driver implementation is provided with an |
| | | * "expected managed object definition". However, the actual decoded |
| | | * managed object is often an instance of a sub-type of this |
| | | * definition. For example, when decoding a connection handler managed |
| | | * object, the actual type can never be a connection handler because |
| | | * it is an abstract managed object type. Instead, the decoded managed |
| | | * object must be a "concrete" sub-type: an LDAP connection handler or |
| | | * JMX connection handler. |
| | | * Managed object definitions, like Java classes, are arranged in an inheritance |
| | | * hierarchy. When managed objects are decoded (e.g. from LDAP entries), the |
| | | * driver implementation is provided with an |
| | | * "expected managed object definition". However, the actual decoded managed |
| | | * object is often an instance of a sub-type of this definition. For example, |
| | | * when decoding a connection handler managed object, the actual type can never |
| | | * be a connection handler because it is an abstract managed object type. |
| | | * Instead, the decoded managed object must be a "concrete" sub-type: an LDAP |
| | | * connection handler or JMX connection handler. |
| | | * <p> |
| | | * This resolution process is coordinated by the |
| | | * <code>resolveManagedObjectDefinition</code> method in managed |
| | | * object definitions, where it is passed a |
| | | * <code>DefinitionResolver</code> implementation. The |
| | | * <code>resolveManagedObjectDefinition</code> method takes care of |
| | | * recursively descending through the definition hierarchy and invokes |
| | | * the {@link #matches(AbstractManagedObjectDefinition)} method |
| | | * against each potential sub-type. It is the job of the resolver to |
| | | * indicate whether the provided managed object definition is a |
| | | * candidate definition. For example, the LDAP driver provides a |
| | | * definition resolver which uses the decoded LDAP entry's object |
| | | * classes to determine the final appropriate managed object |
| | | * <code>resolveManagedObjectDefinition</code> method in managed object |
| | | * definitions, where it is passed a <code>DefinitionResolver</code> |
| | | * implementation. The <code>resolveManagedObjectDefinition</code> method takes |
| | | * care of recursively descending through the definition hierarchy and invokes |
| | | * the {@link #matches(AbstractManagedObjectDefinition)} method against each |
| | | * potential sub-type. It is the job of the resolver to indicate whether the |
| | | * provided managed object definition is a candidate definition. For example, |
| | | * the LDAP driver provides a definition resolver which uses the decoded LDAP |
| | | * entry's object classes to determine the final appropriate managed object |
| | | * definition. |
| | | */ |
| | | public interface DefinitionResolver { |
| | |
| | | * An interface for incrementally constructing duration property |
| | | * definitions. |
| | | */ |
| | | public static class Builder extends AbstractBuilder<Long, DurationPropertyDefinition> { |
| | | public static final class Builder extends AbstractBuilder<Long, DurationPropertyDefinition> { |
| | | |
| | | // The base unit for this property definition. |
| | | private DurationUnit baseUnit = DurationUnit.SECONDS; |
| | |
| | | * duration unit, or if the base unit is bigger than the |
| | | * maximum unit. |
| | | */ |
| | | public final void setBaseUnit(String unit) throws IllegalArgumentException { |
| | | public final void setBaseUnit(String unit) { |
| | | Reject.ifNull(unit); |
| | | |
| | | setBaseUnit(DurationUnit.getUnit(unit)); |
| | |
| | | * If the provided base unit is bigger than the maximum |
| | | * unit. |
| | | */ |
| | | public final void setBaseUnit(DurationUnit unit) throws IllegalArgumentException { |
| | | public final void setBaseUnit(DurationUnit unit) { |
| | | Reject.ifNull(unit); |
| | | |
| | | // Make sure that the base unit is not bigger than the maximum |
| | |
| | | * duration unit, or if the maximum unit is smaller than the |
| | | * base unit. |
| | | */ |
| | | public final void setMaximumUnit(String unit) throws IllegalArgumentException { |
| | | public final void setMaximumUnit(String unit) { |
| | | if (unit == null) { |
| | | setMaximumUnit((DurationUnit) null); |
| | | } else { |
| | |
| | | * If the provided maximum unit is smaller than the base |
| | | * unit. |
| | | */ |
| | | public final void setMaximumUnit(DurationUnit unit) throws IllegalArgumentException { |
| | | public final void setMaximumUnit(DurationUnit unit) { |
| | | if (unit != null) { |
| | | // Make sure that the maximum unit is not smaller than the |
| | | // base unit. |
| | |
| | | * If a negative lower limit was specified, or the lower |
| | | * limit is greater than the upper limit. |
| | | */ |
| | | public final void setLowerLimit(long lowerLimit) throws IllegalArgumentException { |
| | | public final void setLowerLimit(long lowerLimit) { |
| | | if (lowerLimit < 0) { |
| | | throw new IllegalArgumentException("Negative lower limit"); |
| | | } |
| | |
| | | * lower limit was specified, or the lower limit is greater |
| | | * than the upper limit. |
| | | */ |
| | | public final void setLowerLimit(String lowerLimit) throws IllegalArgumentException { |
| | | public final void setLowerLimit(String lowerLimit) { |
| | | setLowerLimit(DurationUnit.parseValue(lowerLimit, baseUnit)); |
| | | } |
| | | |
| | |
| | | * limit is greater than the upper limit or unlimited |
| | | * durations are permitted. |
| | | */ |
| | | public final void setUpperLimit(Long upperLimit) throws IllegalArgumentException { |
| | | public final void setUpperLimit(Long upperLimit) { |
| | | if (upperLimit != null) { |
| | | if (upperLimit < 0) { |
| | | throw new IllegalArgumentException("Negative upper limit"); |
| | |
| | | * If the upper limit could not be parsed, or if the lower |
| | | * limit is greater than the upper limit. |
| | | */ |
| | | public final void setUpperLimit(String upperLimit) throws IllegalArgumentException { |
| | | public final void setUpperLimit(String upperLimit) { |
| | | if (upperLimit == null) { |
| | | setUpperLimit((Long) null); |
| | | } else { |
| | |
| | | * If unlimited values are to be permitted but there is an |
| | | * upper limit specified. |
| | | */ |
| | | public final void setAllowUnlimited(boolean allowUnlimited) throws IllegalArgumentException { |
| | | public final void setAllowUnlimited(boolean allowUnlimited) { |
| | | if (allowUnlimited && upperLimit != null) { |
| | | throw new IllegalArgumentException("Upper limit specified when unlimited durations are permitted"); |
| | | } |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void validateValue(Long value) throws IllegalPropertyValueException { |
| | | public void validateValue(Long value) { |
| | | Reject.ifNull(value); |
| | | |
| | | long nvalue = baseUnit.toMilliSeconds(value); |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public String encodeValue(Long value) throws IllegalPropertyValueException { |
| | | public String encodeValue(Long value) { |
| | | Reject.ifNull(value); |
| | | |
| | | // Make sure that we correctly encode negative values as |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public Long decodeValue(String value) throws IllegalPropertyValueStringException { |
| | | public Long decodeValue(String value) { |
| | | Reject.ifNull(value); |
| | | |
| | | // First check for the special "unlimited" value when necessary. |
| | |
| | | */ |
| | | package org.opends.server.admin; |
| | | |
| | | |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This enumeration defines various duration units. |
| | | */ |
| | |
| | | WEEKS((long) 7 * 24 * 60 * 60 * 1000, "w", "weeks"); |
| | | |
| | | // A lookup table for resolving a unit from its name. |
| | | private static final Map<String, DurationUnit> nameToUnit; |
| | | private static final Map<String, DurationUnit> NAME_TO_UNIT; |
| | | static { |
| | | nameToUnit = new HashMap<String, DurationUnit>(); |
| | | NAME_TO_UNIT = new HashMap<String, DurationUnit>(); |
| | | |
| | | for (DurationUnit unit : DurationUnit.values()) { |
| | | nameToUnit.put(unit.shortName, unit); |
| | | nameToUnit.put(unit.longName, unit); |
| | | NAME_TO_UNIT.put(unit.shortName, unit); |
| | | NAME_TO_UNIT.put(unit.longName, unit); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Get the unit corresponding to the provided unit name. |
| | | * |
| | | * @param s |
| | | * The name of the unit. Can be the abbreviated or long |
| | | * name and can contain white space and mixed case |
| | | * characters. |
| | | * The name of the unit. Can be the abbreviated or long name and |
| | | * can contain white space and mixed case characters. |
| | | * @return Returns the unit corresponding to the provided unit name. |
| | | * @throws IllegalArgumentException |
| | | * If the provided name did not correspond to a known |
| | | * duration unit. |
| | | * If the provided name did not correspond to a known duration |
| | | * unit. |
| | | */ |
| | | public static DurationUnit getUnit(String s) throws IllegalArgumentException { |
| | | DurationUnit unit = nameToUnit.get(s.trim().toLowerCase()); |
| | | public static DurationUnit getUnit(String s) { |
| | | DurationUnit unit = NAME_TO_UNIT.get(s.trim().toLowerCase()); |
| | | if (unit == null) { |
| | | throw new IllegalArgumentException("Illegal duration unit \"" + s + "\""); |
| | | } |
| | | return unit; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Parse the provided duration string and return its equivalent |
| | | * duration in milliseconds. The duration string must specify the |
| | | * unit e.g. "10s". This method will parse duration string |
| | | * representations produced from the {@link #toString(long)} method. |
| | | * Therefore, a duration can comprise of multiple duration |
| | | * specifiers, for example <code>1d15m25s</code>. |
| | | * Parse the provided duration string and return its equivalent duration in |
| | | * milliseconds. The duration string must specify the unit e.g. "10s". This |
| | | * method will parse duration string representations produced from the |
| | | * {@link #toString(long)} method. Therefore, a duration can comprise of |
| | | * multiple duration specifiers, for example <code>1d15m25s</code>. |
| | | * |
| | | * @param s |
| | | * The duration string to be parsed. |
| | |
| | | * If the provided duration string could not be parsed. |
| | | * @see #toString(long) |
| | | */ |
| | | public static long parseValue(String s) throws NumberFormatException { |
| | | public static long parseValue(String s) { |
| | | return parseValue(s, null); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Parse the provided duration string and return its equivalent |
| | | * duration in milliseconds. This method will parse duration string |
| | | * representations produced from the {@link #toString(long)} method. |
| | | * Therefore, a duration can comprise of multiple duration |
| | | * specifiers, for example <code>1d15m25s</code>. |
| | | * Parse the provided duration string and return its equivalent duration in |
| | | * milliseconds. This method will parse duration string representations |
| | | * produced from the {@link #toString(long)} method. Therefore, a duration |
| | | * can comprise of multiple duration specifiers, for example |
| | | * <code>1d15m25s</code>. |
| | | * |
| | | * @param s |
| | | * The duration string to be parsed. |
| | | * @param defaultUnit |
| | | * The default unit to use if there is no unit specified in |
| | | * the duration string, or <code>null</code> if the |
| | | * string must always contain a unit. |
| | | * The default unit to use if there is no unit specified in the |
| | | * duration string, or <code>null</code> if the string must |
| | | * always contain a unit. |
| | | * @return Returns the parsed duration in milliseconds. |
| | | * @throws NumberFormatException |
| | | * If the provided duration string could not be parsed. |
| | | * @see #toString(long) |
| | | */ |
| | | public static long parseValue(String s, DurationUnit defaultUnit) |
| | | throws NumberFormatException { |
| | | public static long parseValue(String s, DurationUnit defaultUnit) { |
| | | String ns = s.trim(); |
| | | if (ns.length() == 0) { |
| | | throw new NumberFormatException("Empty duration value \"" + s + "\""); |
| | | } |
| | | |
| | | Pattern p1 = Pattern.compile("^\\s*((\\d+)\\s*w)?" + "\\s*((\\d+)\\s*d)?" |
| | | + "\\s*((\\d+)\\s*h)?" + "\\s*((\\d+)\\s*m)?" + "\\s*((\\d+)\\s*s)?" |
| | | + "\\s*((\\d+)\\s*ms)?\\s*$", Pattern.CASE_INSENSITIVE); |
| | | Pattern p1 = |
| | | Pattern.compile("^\\s*((\\d+)\\s*w)?" + "\\s*((\\d+)\\s*d)?" + "\\s*((\\d+)\\s*h)?" |
| | | + "\\s*((\\d+)\\s*m)?" + "\\s*((\\d+)\\s*s)?" + "\\s*((\\d+)\\s*ms)?\\s*$", Pattern.CASE_INSENSITIVE); |
| | | Matcher m1 = p1.matcher(ns); |
| | | if (m1.matches()) { |
| | | // Value must be of the form produced by toString(long). |
| | |
| | | DurationUnit unit; |
| | | if (unitString == null) { |
| | | if (defaultUnit == null) { |
| | | throw new NumberFormatException("Invalid duration value \"" + s |
| | | + "\""); |
| | | throw new NumberFormatException("Invalid duration value \"" + s + "\""); |
| | | } else { |
| | | unit = defaultUnit; |
| | | } |
| | |
| | | try { |
| | | unit = getUnit(unitString); |
| | | } catch (IllegalArgumentException e) { |
| | | throw new NumberFormatException("Invalid duration value \"" + s |
| | | + "\""); |
| | | throw new NumberFormatException("Invalid duration value \"" + s + "\""); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Returns a string representation of the provided duration. The |
| | | * string representation can be parsed using the |
| | | * {@link #parseValue(String)} method. The string representation is |
| | | * comprised of one or more of the number of weeks, days, hours, |
| | | * minutes, seconds, and milliseconds. Here are some examples: |
| | | * Returns a string representation of the provided duration. The string |
| | | * representation can be parsed using the {@link #parseValue(String)} |
| | | * method. The string representation is comprised of one or more of the |
| | | * number of weeks, days, hours, minutes, seconds, and milliseconds. Here |
| | | * are some examples: |
| | | * |
| | | * <pre> |
| | | * toString(0) // 0 ms |
| | |
| | | * @see #parseValue(String) |
| | | * @see #parseValue(String, DurationUnit) |
| | | */ |
| | | public static String toString(long duration) throws IllegalArgumentException { |
| | | public static String toString(long duration) { |
| | | if (duration < 0) { |
| | | throw new IllegalArgumentException("Negative duration " + duration); |
| | | } |
| | |
| | | return "0 ms"; |
| | | } |
| | | |
| | | DurationUnit[] units = new DurationUnit[] { WEEKS, DAYS, HOURS, MINUTES, |
| | | SECONDS, MILLI_SECONDS }; |
| | | DurationUnit[] units = new DurationUnit[] { WEEKS, DAYS, HOURS, MINUTES, SECONDS, MILLI_SECONDS }; |
| | | long remainder = duration; |
| | | StringBuilder builder = new StringBuilder(); |
| | | boolean isFirst = true; |
| | |
| | | // The size of the unit in milliseconds. |
| | | private final long sz; |
| | | |
| | | |
| | | |
| | | // Private constructor. |
| | | private DurationUnit(long sz, String shortName, String longName) { |
| | | this.sz = sz; |
| | |
| | | this.longName = longName; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Converts the specified duration in milliseconds to this unit. |
| | | * |
| | |
| | | return ((double) duration / sz); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Get the number of milliseconds that this unit represents. |
| | | * |
| | | * @return Returns the number of milliseconds that this unit |
| | | * represents. |
| | | * @return Returns the number of milliseconds that this unit represents. |
| | | */ |
| | | public long getDuration() { |
| | | return sz; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Get the long name of this unit. |
| | | * |
| | |
| | | return longName; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Get the abbreviated name of this unit. |
| | | * |
| | |
| | | return shortName; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Converts the specified duration in this unit to milliseconds. |
| | | * |
| | | * @param duration |
| | | * The duration as a quantity of this unit. |
| | | * @return Returns the number of milliseconds that the duration |
| | | * represents. |
| | | * @return Returns the number of milliseconds that the duration represents. |
| | | */ |
| | | public long toMilliSeconds(double duration) { |
| | | return (long) (sz * duration); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | * <p> |
| | | * This implementation returns the abbreviated name of this duration |
| | | * unit. |
| | | * This implementation returns the abbreviated name of this duration unit. |
| | | */ |
| | | @Override |
| | | public String toString() { |
| | |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.server.admin; |
| | | |
| | | import org.forgerock.util.Reject; |
| | |
| | | * The enumeration that should be used for values of this |
| | | * property definition. |
| | | */ |
| | | public static class Builder<E extends Enum<E>> extends AbstractBuilder<E, EnumPropertyDefinition<E>> { |
| | | public final static class Builder<E extends Enum<E>> extends AbstractBuilder<E, EnumPropertyDefinition<E>> { |
| | | |
| | | // The enumeration class. |
| | | private Class<E> enumClass; |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | protected EnumPropertyDefinition<E> buildInstance(AbstractManagedObjectDefinition<?, ?> d, String propertyName, |
| | | EnumSet<PropertyOption> options, AdministratorAction adminAction, |
| | | protected EnumPropertyDefinition<E> buildInstance(AbstractManagedObjectDefinition<?, ?> d, |
| | | String propertyName, EnumSet<PropertyOption> options, AdministratorAction adminAction, |
| | | DefaultBehaviorProvider<E> defaultBehavior) { |
| | | // Make sure that the enumeration class has been defined. |
| | | if (enumClass == null) { |
| | |
| | | |
| | | // Private constructor. |
| | | private EnumPropertyDefinition(AbstractManagedObjectDefinition<?, ?> d, String propertyName, |
| | | EnumSet<PropertyOption> options, AdministratorAction adminAction, |
| | | DefaultBehaviorProvider<E> defaultBehavior, Class<E> enumClass) { |
| | | EnumSet<PropertyOption> options, AdministratorAction adminAction, DefaultBehaviorProvider<E> defaultBehavior, |
| | | Class<E> enumClass) { |
| | | super(d, enumClass, propertyName, options, adminAction, defaultBehavior); |
| | | this.enumClass = enumClass; |
| | | |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public E decodeValue(String value) throws IllegalPropertyValueStringException { |
| | | public E decodeValue(String value) { |
| | | Reject.ifNull(value); |
| | | |
| | | String nvalue = value.trim().toLowerCase(); |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public String normalizeValue(E value) throws IllegalPropertyValueException { |
| | | public String normalizeValue(E value) { |
| | | Reject.ifNull(value); |
| | | |
| | | return value.toString().trim().toLowerCase(); |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void validateValue(E value) throws IllegalPropertyValueException { |
| | | public void validateValue(E value) { |
| | | Reject.ifNull(value); |
| | | |
| | | // No additional validation required. |
| | |
| | | /** |
| | | * The client-side constraint handler. |
| | | */ |
| | | private class ClientHandler extends ClientConstraintHandler { |
| | | private final class ClientHandler extends ClientConstraintHandler { |
| | | |
| | | // Private constructor. |
| | | private ClientHandler() { |
| | |
| | | /** |
| | | * The server-side constraint handler. |
| | | */ |
| | | private class ServerHandler extends ServerConstraintHandler { |
| | | private final class ServerHandler extends ServerConstraintHandler { |
| | | |
| | | // Private constructor. |
| | | private ServerHandler() { |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isUsable(ServerManagedObject<?> managedObject, Collection<LocalizableMessage> unacceptableReasons) |
| | | throws ConfigException { |
| | | public boolean isUsable(ServerManagedObject<?> managedObject, |
| | | Collection<LocalizableMessage> unacceptableReasons) throws ConfigException { |
| | | if (!condition.evaluate(managedObject)) { |
| | | unacceptableReasons.add(getSynopsis()); |
| | | return false; |
| | |
| | | * An interface for incrementally constructing IP address mask property |
| | | * definitions. |
| | | */ |
| | | public static class Builder extends AbstractBuilder<AddressMask, IPAddressMaskPropertyDefinition> { |
| | | public static final class Builder extends AbstractBuilder<AddressMask, IPAddressMaskPropertyDefinition> { |
| | | |
| | | // Private constructor |
| | | private Builder(AbstractManagedObjectDefinition<?, ?> d, String propertyName) { |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void validateValue(AddressMask value) throws IllegalPropertyValueException { |
| | | public void validateValue(AddressMask value) { |
| | | Reject.ifNull(value); |
| | | |
| | | // No additional validation required. |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public AddressMask decodeValue(String value) throws IllegalPropertyValueStringException { |
| | | public AddressMask decodeValue(String value) { |
| | | Reject.ifNull(value); |
| | | |
| | | try { |
| | |
| | | * An interface for incrementally constructing IP address property |
| | | * definitions. |
| | | */ |
| | | public static class Builder extends AbstractBuilder<InetAddress, IPAddressPropertyDefinition> { |
| | | public static final class Builder extends AbstractBuilder<InetAddress, IPAddressPropertyDefinition> { |
| | | |
| | | // Private constructor |
| | | private Builder(AbstractManagedObjectDefinition<?, ?> d, String propertyName) { |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void validateValue(InetAddress value) throws IllegalPropertyValueException { |
| | | public void validateValue(InetAddress value) { |
| | | Reject.ifNull(value); |
| | | |
| | | // No additional validation required. |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public InetAddress decodeValue(String value) throws IllegalPropertyValueStringException { |
| | | public InetAddress decodeValue(String value) { |
| | | Reject.ifNull(value); |
| | | |
| | | try { |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public String encodeValue(InetAddress value) throws IllegalPropertyValueException { |
| | | public String encodeValue(InetAddress value) { |
| | | // We should return the host name if it is available, or the IP |
| | | // address if not. |
| | | |
| | |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions copyright 2013 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.opends.server.admin; |
| | | |
| | | import static com.forgerock.opendj.ldap.AdminMessages.*; |
| | |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions copyright 2013 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.opends.server.admin; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | |
| | | |
| | | // The optional default managed objects associated with this |
| | | // instantiable relation definition. |
| | | private final Map<String, DefaultManagedObject<? extends C, ? extends S>> defaultManagedObjects = new HashMap<String, DefaultManagedObject<? extends C, ? extends S>>(); |
| | | private final Map<String, DefaultManagedObject<? extends C, ? extends S>> defaultManagedObjects = |
| | | new HashMap<String, DefaultManagedObject<? extends C, ? extends S>>(); |
| | | |
| | | /** |
| | | * Creates a new builder which can be used to incrementally build an |
| | |
| | | * If there is no default managed object associated with the |
| | | * provided name. |
| | | */ |
| | | public DefaultManagedObject<? extends C, ? extends S> getDefaultManagedObject(String name) |
| | | throws IllegalArgumentException { |
| | | public DefaultManagedObject<? extends C, ? extends S> getDefaultManagedObject(String name) { |
| | | if (!defaultManagedObjects.containsKey(name)) { |
| | | throw new IllegalArgumentException("unrecognized default managed object \"" + name + "\""); |
| | | } |
| | |
| | | /** |
| | | * An interface for incrementally constructing integer property definitions. |
| | | */ |
| | | public static class Builder extends AbstractBuilder<Integer, IntegerPropertyDefinition> { |
| | | public static final class Builder extends AbstractBuilder<Integer, IntegerPropertyDefinition> { |
| | | |
| | | // The lower limit of the property value. |
| | | private int lowerLimit = 0; |
| | |
| | | * If a negative lower limit was specified or the lower |
| | | * limit is greater than the upper limit. |
| | | */ |
| | | public final void setLowerLimit(int lowerLimit) throws IllegalArgumentException { |
| | | public final void setLowerLimit(int lowerLimit) { |
| | | if (lowerLimit < 0) { |
| | | throw new IllegalArgumentException("Negative lower limit"); |
| | | } |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | protected IntegerPropertyDefinition buildInstance(AbstractManagedObjectDefinition<?, ?> d, String propertyName, |
| | | EnumSet<PropertyOption> options, AdministratorAction adminAction, |
| | | protected IntegerPropertyDefinition buildInstance(AbstractManagedObjectDefinition<?, ?> d, |
| | | String propertyName, EnumSet<PropertyOption> options, AdministratorAction adminAction, |
| | | DefaultBehaviorProvider<Integer> defaultBehavior) { |
| | | return new IntegerPropertyDefinition(d, propertyName, options, adminAction, defaultBehavior, lowerLimit, |
| | | upperLimit, allowUnlimited); |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void validateValue(Integer value) throws IllegalPropertyValueException { |
| | | public void validateValue(Integer value) { |
| | | Reject.ifNull(value); |
| | | |
| | | if (!allowUnlimited && value < lowerLimit) { |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public String encodeValue(Integer value) throws IllegalPropertyValueException { |
| | | public String encodeValue(Integer value) { |
| | | Reject.ifNull(value); |
| | | |
| | | // Make sure that we correctly encode negative values as "unlimited". |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public Integer decodeValue(String value) throws IllegalPropertyValueStringException { |
| | | public Integer decodeValue(String value) { |
| | | Reject.ifNull(value); |
| | | |
| | | if (allowUnlimited) { |
| | |
| | | * If the LDAP profile properties file associated with the |
| | | * provided managed object definition could not be loaded. |
| | | */ |
| | | public String getAttributeName(AbstractManagedObjectDefinition<?, ?> d, PropertyDefinition<?> pd) |
| | | throws MissingResourceException { |
| | | public String getAttributeName(AbstractManagedObjectDefinition<?, ?> d, PropertyDefinition<?> pd) { |
| | | for (Wrapper profile : profiles) { |
| | | String attributeName = profile.getAttributeName(d, pd); |
| | | if (attributeName != null) { |
| | |
| | | * If the LDAP profile properties file associated with the |
| | | * provided managed object definition could not be loaded. |
| | | */ |
| | | public String getRelationChildRDNType(InstantiableRelationDefinition<?, ?> r) throws MissingResourceException { |
| | | public String getRelationChildRDNType(InstantiableRelationDefinition<?, ?> r) { |
| | | if (r.getNamingPropertyDefinition() != null) { |
| | | // Use the attribute associated with the naming property. |
| | | return getAttributeName(r.getChildDefinition(), r.getNamingPropertyDefinition()); |
| | |
| | | * If the LDAP profile properties file associated with the |
| | | * provided managed object definition could not be loaded. |
| | | */ |
| | | public String getRelationChildRDNType(SetRelationDefinition<?, ?> r) throws MissingResourceException { |
| | | public String getRelationChildRDNType(SetRelationDefinition<?, ?> r) { |
| | | for (Wrapper profile : profiles) { |
| | | String rdnType = profile.getRelationChildRDNType(r); |
| | | if (rdnType != null) { |
| | |
| | | * If the LDAP profile properties file associated with the |
| | | * provided managed object definition could not be loaded. |
| | | */ |
| | | public String getObjectClass(AbstractManagedObjectDefinition<?, ?> d) throws MissingResourceException { |
| | | public String getObjectClass(AbstractManagedObjectDefinition<?, ?> d) { |
| | | if (d.isTop()) { |
| | | return "top"; |
| | | } |
| | |
| | | * If the LDAP profile properties file associated with the |
| | | * provided managed object definition could not be loaded. |
| | | */ |
| | | public List<String> getObjectClasses(AbstractManagedObjectDefinition<?, ?> d) throws MissingResourceException { |
| | | public List<String> getObjectClasses(AbstractManagedObjectDefinition<?, ?> d) { |
| | | LinkedList<String> objectClasses = new LinkedList<String>(); |
| | | Set<String> s = new HashSet<String>(); |
| | | |
| | |
| | | * If the LDAP profile properties file associated with the |
| | | * provided managed object definition could not be loaded. |
| | | */ |
| | | public String getRelationRDNSequence(RelationDefinition<?, ?> r) throws MissingResourceException { |
| | | public String getRelationRDNSequence(RelationDefinition<?, ?> r) { |
| | | for (Wrapper profile : profiles) { |
| | | String rdnSequence = profile.getRelationRDNSequence(r); |
| | | if (rdnSequence != null) { |
| | |
| | | * @throws NoSuchElementException |
| | | * If there are no LDAP profile wrappers. |
| | | */ |
| | | public void popWrapper() throws NoSuchElementException { |
| | | public void popWrapper() { |
| | | profiles.removeFirst(); |
| | | } |
| | | |
| | |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.server.admin; |
| | | |
| | | import static com.forgerock.opendj.ldap.AdminMessages.*; |
| | |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.server.admin; |
| | | |
| | | |
| | | |
| | | import org.opends.server.admin.client.ManagedObject; |
| | | import org.opends.server.admin.server.ServerManagedObject; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Defines the structure of a managed object which can be |
| | | * instantiated. |
| | | * Defines the structure of a managed object which can be instantiated. |
| | | * |
| | | * @param <C> |
| | | * The type of client managed object configuration that this |
| | |
| | | * The type of server managed object configuration that this |
| | | * definition represents. |
| | | */ |
| | | public abstract class ManagedObjectDefinition |
| | | <C extends ConfigurationClient, S extends Configuration> |
| | | extends AbstractManagedObjectDefinition<C, S> { |
| | | public abstract class ManagedObjectDefinition<C extends ConfigurationClient, S extends Configuration> extends |
| | | AbstractManagedObjectDefinition<C, S> { |
| | | |
| | | /** |
| | | * Create a new managed object definition. |
| | |
| | | * @param name |
| | | * The name of the definition. |
| | | * @param parent |
| | | * The parent definition, or <code>null</code> if there |
| | | * is no parent. |
| | | * The parent definition, or <code>null</code> if there is no |
| | | * parent. |
| | | */ |
| | | protected ManagedObjectDefinition(String name, |
| | | AbstractManagedObjectDefinition<? super C, ? super S> parent) { |
| | | protected ManagedObjectDefinition(String name, AbstractManagedObjectDefinition<? super C, ? super S> parent) { |
| | | super(name, parent); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Creates a client configuration view of the provided managed |
| | | * object. Modifications made to the underlying managed object will |
| | | * be reflected in the client configuration view and vice versa. |
| | | * Creates a client configuration view of the provided managed object. |
| | | * Modifications made to the underlying managed object will be reflected in |
| | | * the client configuration view and vice versa. |
| | | * |
| | | * @param managedObject |
| | | * The managed object. |
| | | * @return Returns a client configuration view of the provided |
| | | * managed object. |
| | | * @return Returns a client configuration view of the provided managed |
| | | * object. |
| | | */ |
| | | public abstract C createClientConfiguration( |
| | | ManagedObject<? extends C> managedObject); |
| | | |
| | | |
| | | public abstract C createClientConfiguration(ManagedObject<? extends C> managedObject); |
| | | |
| | | /** |
| | | * Creates a server configuration view of the provided server |
| | | * managed object. |
| | | * Creates a server configuration view of the provided server managed |
| | | * object. |
| | | * |
| | | * @param managedObject |
| | | * The server managed object. |
| | | * @return Returns a server configuration view of the provided |
| | | * server managed object. |
| | | * @return Returns a server configuration view of the provided server |
| | | * managed object. |
| | | */ |
| | | public abstract S createServerConfiguration( |
| | | ServerManagedObject<? extends S> managedObject); |
| | | |
| | | |
| | | public abstract S createServerConfiguration(ServerManagedObject<? extends S> managedObject); |
| | | |
| | | /** |
| | | * Gets the server configuration class instance associated with this |
| | | * managed object definition. |
| | | * Gets the server configuration class instance associated with this managed |
| | | * object definition. |
| | | * |
| | | * @return Returns the server configuration class instance |
| | | * associated with this managed object definition. |
| | | * @return Returns the server configuration class instance associated with |
| | | * this managed object definition. |
| | | */ |
| | | public abstract Class<S> getServerConfigurationClass(); |
| | | } |
| | |
| | | * If the provided managed object definition was the |
| | | * {@link TopCfgDefn}. |
| | | */ |
| | | public LocalizableMessage getMessage(AbstractManagedObjectDefinition<?, ?> d, String key) |
| | | throws MissingResourceException, UnsupportedOperationException { |
| | | public LocalizableMessage getMessage(AbstractManagedObjectDefinition<?, ?> d, String key) { |
| | | return getMessage(d, key, Locale.getDefault(), (String[]) null); |
| | | } |
| | | |
| | |
| | | * If the provided managed object definition was the |
| | | * {@link TopCfgDefn}. |
| | | */ |
| | | public LocalizableMessage getMessage(AbstractManagedObjectDefinition<?, ?> d, String key, Locale locale) |
| | | throws MissingResourceException, UnsupportedOperationException { |
| | | public LocalizableMessage getMessage(AbstractManagedObjectDefinition<?, ?> d, String key, Locale locale) { |
| | | return getMessage(d, key, locale, (String[]) null); |
| | | } |
| | | |
| | |
| | | * {@link TopCfgDefn}. |
| | | */ |
| | | public LocalizableMessage getMessage(AbstractManagedObjectDefinition<?, ?> d, String key, Locale locale, |
| | | String... args) throws MissingResourceException, UnsupportedOperationException { |
| | | String... args) { |
| | | ResourceBundle resource = getResourceBundle(d, locale); |
| | | |
| | | // TODO: use message framework directly |
| | |
| | | * If the provided managed object definition was the |
| | | * {@link TopCfgDefn}. |
| | | */ |
| | | public LocalizableMessage getMessage(AbstractManagedObjectDefinition<?, ?> d, String key, String... args) |
| | | throws MissingResourceException, UnsupportedOperationException { |
| | | public LocalizableMessage getMessage(AbstractManagedObjectDefinition<?, ?> d, String key, String... args) { |
| | | return getMessage(d, key, Locale.getDefault(), args); |
| | | } |
| | | |
| | |
| | | |
| | | // Retrieve the resource bundle associated with a managed object and |
| | | // locale, lazily loading it if necessary. |
| | | private synchronized ResourceBundle getResourceBundle(AbstractManagedObjectDefinition<?, ?> d, Locale locale) |
| | | throws MissingResourceException, UnsupportedOperationException { |
| | | private synchronized ResourceBundle getResourceBundle(AbstractManagedObjectDefinition<?, ?> d, Locale locale) { |
| | | if (d.isTop()) { |
| | | throw new UnsupportedOperationException("I18n resources are not available for the " |
| | | + "Top configuration definition"); |
| | |
| | | ResourceBundle resourceBundle = map.get(locale); |
| | | if (resourceBundle == null) { |
| | | String baseName = prefix + "." + d.getClass().getName(); |
| | | resourceBundle = ResourceBundle.getBundle(baseName, locale, ClassLoaderProvider.getInstance() |
| | | .getClassLoader()); |
| | | resourceBundle = |
| | | ResourceBundle.getBundle(baseName, locale, ClassLoaderProvider.getInstance().getClassLoader()); |
| | | map.put(locale, resourceBundle); |
| | | } |
| | | |
| | |
| | | |
| | | package org.opends.server.admin; |
| | | |
| | | |
| | | |
| | | import java.io.BufferedInputStream; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | |
| | | import java.util.MissingResourceException; |
| | | import java.util.Properties; |
| | | |
| | | |
| | | |
| | | /** |
| | | * A class for retrieving non-internationalized resource properties |
| | | * associated with a managed object definition. |
| | | * A class for retrieving non-internationalized resource properties associated |
| | | * with a managed object definition. |
| | | * <p> |
| | | * Resource properties are not available for the {@link TopCfgDefn}. |
| | | */ |
| | | public final class ManagedObjectDefinitionResource { |
| | | |
| | | // Mapping from definition to property tables. |
| | | private final Map<AbstractManagedObjectDefinition<?, ?>, |
| | | Properties> properties; |
| | | private final Map<AbstractManagedObjectDefinition<?, ?>, Properties> properties; |
| | | |
| | | // The resource name prefix. |
| | | private final String prefix; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Creates a new resource instance for the named profile. |
| | | * |
| | |
| | | * The name of the profile. |
| | | * @return Returns the resource instance for the named profile. |
| | | */ |
| | | public static ManagedObjectDefinitionResource createForProfile( |
| | | String profile) { |
| | | return new ManagedObjectDefinitionResource("admin.profiles." |
| | | + profile); |
| | | public static ManagedObjectDefinitionResource createForProfile(String profile) { |
| | | return new ManagedObjectDefinitionResource("admin.profiles." + profile); |
| | | } |
| | | |
| | | |
| | | |
| | | // Private constructor. |
| | | private ManagedObjectDefinitionResource(String prefix) { |
| | | this.properties = |
| | | new HashMap<AbstractManagedObjectDefinition<?, ?>, Properties>(); |
| | | this.properties = new HashMap<AbstractManagedObjectDefinition<?, ?>, Properties>(); |
| | | this.prefix = prefix; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Get the resource value associated with the specified key. |
| | | * |
| | |
| | | * The managed object definition. |
| | | * @param key |
| | | * The resource key. |
| | | * @return Returns the resource value associated with the specified |
| | | * key. |
| | | * @return Returns the resource value associated with the specified key. |
| | | * @throws MissingResourceException |
| | | * If the key was not found. |
| | | * @throws UnsupportedOperationException |
| | | * If the provided managed object definition was the |
| | | * {@link TopCfgDefn}. |
| | | */ |
| | | public String getString(AbstractManagedObjectDefinition<?, ?> d, String key) |
| | | throws MissingResourceException, UnsupportedOperationException { |
| | | public String getString(AbstractManagedObjectDefinition<?, ?> d, String key) { |
| | | if (d.isTop()) { |
| | | throw new UnsupportedOperationException( |
| | | "Profile resources are not available for the " |
| | | throw new UnsupportedOperationException("Profile resources are not available for the " |
| | | + "Top configuration definition"); |
| | | } |
| | | |
| | |
| | | String baseName = prefix + "." + d.getClass().getName(); |
| | | String path = baseName.replace('.', '/') + ".properties"; |
| | | |
| | | throw new MissingResourceException("Can't find resource " |
| | | + path + ", key " + key, baseName, key); |
| | | throw new MissingResourceException("Can't find resource " + path + ", key " + key, baseName, key); |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | | |
| | | |
| | | // Retrieve the properties table associated with a managed object, |
| | | // lazily loading it if necessary. |
| | | private synchronized Properties getProperties( |
| | | AbstractManagedObjectDefinition<?, ?> d) |
| | | throws MissingResourceException { |
| | | private synchronized Properties getProperties(AbstractManagedObjectDefinition<?, ?> d) { |
| | | Properties p = properties.get(d); |
| | | |
| | | if (p == null) { |
| | | // Load the resource file. |
| | | String baseName = prefix + "." + d.getClass().getName(); |
| | | String path = baseName.replace('.', '/') + ".properties"; |
| | | InputStream stream = ClassLoaderProvider.getInstance() |
| | | .getClassLoader().getResourceAsStream(path); |
| | | InputStream stream = ClassLoaderProvider.getInstance().getClassLoader().getResourceAsStream(path); |
| | | |
| | | if (stream == null) { |
| | | throw new MissingResourceException("Can't find resource " |
| | | + path, baseName, ""); |
| | | throw new MissingResourceException("Can't find resource " + path, baseName, ""); |
| | | } |
| | | |
| | | p = new Properties(); |
| | | try { |
| | | p.load(new BufferedInputStream(stream)); |
| | | } catch (IOException e) { |
| | | throw new MissingResourceException("Can't load resource " |
| | | + path + " due to IO exception: " + e.getMessage(), |
| | | baseName, ""); |
| | | throw new MissingResourceException("Can't load resource " + path + " due to IO exception: " |
| | | + e.getMessage(), baseName, ""); |
| | | } |
| | | |
| | | // Cache the resource. |
| | |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.server.admin; |
| | | |
| | | import static com.forgerock.opendj.ldap.AdminMessages.*; |
| | |
| | | |
| | | package org.opends.server.admin; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This enumeration contains various options that can be associated |
| | | * with managed object definitions. |
| | | * This enumeration contains various options that can be associated with managed |
| | | * object definitions. |
| | | */ |
| | | public enum ManagedObjectOption { |
| | | /** |
| | | * Use this option to identify managed object types which should be |
| | | * considered as advanced and should not be exposed by default in |
| | | * client applications. |
| | | * considered as advanced and should not be exposed by default in client |
| | | * applications. |
| | | */ |
| | | ADVANCED, |
| | | |
| | | /** |
| | | * Use this option to identify managed object types which must not |
| | | * be directly exposed in client applications. |
| | | * Use this option to identify managed object types which must not be |
| | | * directly exposed in client applications. |
| | | */ |
| | | HIDDEN; |
| | | } |
| | |
| | | /** |
| | | * A path element representing an set managed object. |
| | | */ |
| | | private static final class SetElement<C extends ConfigurationClient, S extends Configuration> extends Element<C, S> { |
| | | private static final class SetElement<C extends ConfigurationClient, S extends Configuration> extends |
| | | Element<C, S> { |
| | | |
| | | // Factory method. |
| | | private static final <C extends ConfigurationClient, S extends Configuration> SetElement<C, S> create( |
| | |
| | | } |
| | | |
| | | // Single instance of a root path. |
| | | private static final ManagedObjectPath<RootCfgClient, RootCfg> EMPTY_PATH = new ManagedObjectPath<RootCfgClient, RootCfg>( |
| | | new LinkedList<Element<?, ?>>(), null, RootCfgDefn.getInstance()); |
| | | private static final ManagedObjectPath<RootCfgClient, RootCfg> EMPTY_PATH = |
| | | new ManagedObjectPath<RootCfgClient, RootCfg>(new LinkedList<Element<?, ?>>(), null, |
| | | RootCfgDefn.getInstance()); |
| | | |
| | | // A regular expression used to parse path elements. |
| | | private static final Pattern PE_REGEXP = Pattern.compile("^\\s*relation=\\s*([^+]+)\\s*" |
| | |
| | | * @throws IllegalArgumentException |
| | | * If the string could not be parsed. |
| | | */ |
| | | public static ManagedObjectPath<?, ?> valueOf(String s) throws IllegalArgumentException { |
| | | public static ManagedObjectPath<?, ?> valueOf(String s) { |
| | | String ns = s.trim(); |
| | | |
| | | // Check for root special case. |
| | |
| | | } |
| | | |
| | | // Decode an element. |
| | | // @Checkstyle:ignore |
| | | private static <C extends ConfigurationClient, S extends Configuration> Element<? extends C, ? extends S> createElement( |
| | | RelationDefinition<C, S> r, String path, String element, String type, String name) { |
| | | // First determine the managed object definition. |
| | |
| | | * path except that the final path element is associated with the specified |
| | | * managed object definition. |
| | | * |
| | | * @param <CC> |
| | | * @param <C1> |
| | | * The type of client managed object configuration that this path |
| | | * will reference. |
| | | * @param <SS> |
| | | * @param <S1> |
| | | * The type of server managed object configuration that this path |
| | | * will reference. |
| | | * @param nd |
| | |
| | | * this path except that the final path element is associated with |
| | | * the specified managed object definition. |
| | | */ |
| | | @SuppressWarnings("unchecked") |
| | | public <CC extends C, SS extends S> ManagedObjectPath<CC, SS> asSubType(AbstractManagedObjectDefinition<CC, SS> nd) { |
| | | // @Checkstyle:ignore |
| | | public <C1 extends C, S1 extends S> ManagedObjectPath<C1, S1> asSubType(AbstractManagedObjectDefinition<C1, S1> nd) { |
| | | if (r instanceof InstantiableRelationDefinition) { |
| | | InstantiableRelationDefinition<? super C, ? super S> ir = (InstantiableRelationDefinition<? super C, ? super S>) r; |
| | | InstantiableRelationDefinition<? super C, ? super S> ir = |
| | | (InstantiableRelationDefinition<? super C, ? super S>) r; |
| | | if (elements.size() == 0) { |
| | | return parent().child(ir, nd, "null"); |
| | | } else { |
| | |
| | | SetRelationDefinition<? super C, ? super S> sr = (SetRelationDefinition<? super C, ? super S>) r; |
| | | return parent().child(sr, nd); |
| | | } else if (r instanceof OptionalRelationDefinition) { |
| | | OptionalRelationDefinition<? super C, ? super S> or = (OptionalRelationDefinition<? super C, ? super S>) r; |
| | | OptionalRelationDefinition<? super C, ? super S> or = |
| | | (OptionalRelationDefinition<? super C, ? super S>) r; |
| | | return parent().child(or, nd); |
| | | } else { |
| | | SingletonRelationDefinition<? super C, ? super S> sr = (SingletonRelationDefinition<? super C, ? super S>) r; |
| | | SingletonRelationDefinition<? super C, ? super S> sr = |
| | | (SingletonRelationDefinition<? super C, ? super S>) r; |
| | | return parent().child(sr, nd); |
| | | } |
| | | } |
| | |
| | | * If the provided name is empty or blank. |
| | | */ |
| | | public <M extends ConfigurationClient, N extends Configuration> ManagedObjectPath<M, N> child( |
| | | InstantiableRelationDefinition<? super M, ? super N> r, AbstractManagedObjectDefinition<M, N> d, String name) |
| | | throws IllegalArgumentException { |
| | | InstantiableRelationDefinition<? super M, ? super N> r, AbstractManagedObjectDefinition<M, N> d, String name) { |
| | | if (name.trim().length() == 0) { |
| | | throw new IllegalArgumentException("Empty or blank managed object names are not allowed"); |
| | | } |
| | |
| | | * If the provided name is empty or blank. |
| | | */ |
| | | public <M extends ConfigurationClient, N extends Configuration> ManagedObjectPath<M, N> child( |
| | | InstantiableRelationDefinition<M, N> r, String name) throws IllegalArgumentException { |
| | | InstantiableRelationDefinition<M, N> r, String name) { |
| | | return child(r, r.getChildDefinition(), name); |
| | | } |
| | | |
| | |
| | | * If the provided name is empty or blank. |
| | | */ |
| | | public <M extends ConfigurationClient, N extends Configuration> ManagedObjectPath<M, N> child( |
| | | SetRelationDefinition<? super M, ? super N> r, AbstractManagedObjectDefinition<M, N> d) |
| | | throws IllegalArgumentException { |
| | | SetRelationDefinition<? super M, ? super N> r, AbstractManagedObjectDefinition<M, N> d) { |
| | | LinkedList<Element<?, ?>> celements = new LinkedList<Element<?, ?>>(elements); |
| | | celements.add(new SetElement<M, N>(r, d)); |
| | | return new ManagedObjectPath<M, N>(celements, r, d); |
| | |
| | | * child definition. |
| | | */ |
| | | public <M extends ConfigurationClient, N extends Configuration> ManagedObjectPath<? extends M, ? extends N> child( |
| | | SetRelationDefinition<M, N> r, String name) throws IllegalArgumentException { |
| | | SetRelationDefinition<M, N> r, String name) { |
| | | AbstractManagedObjectDefinition<M, N> d = r.getChildDefinition(); |
| | | return child(r, d.getChild(name)); |
| | | } |
| | |
| | | * If the provided name is empty or blank. |
| | | */ |
| | | public <M extends ConfigurationClient, N extends Configuration> ManagedObjectPath<M, N> child( |
| | | SetRelationDefinition<M, N> r) throws IllegalArgumentException { |
| | | SetRelationDefinition<M, N> r) { |
| | | return child(r, r.getChildDefinition()); |
| | | } |
| | | |
| | |
| | | * If this path does not have a parent (i.e. it is the empty |
| | | * path). |
| | | */ |
| | | public ManagedObjectPath<?, ?> parent() throws IllegalArgumentException { |
| | | public ManagedObjectPath<?, ?> parent() { |
| | | return parent(1); |
| | | } |
| | | |
| | |
| | | * If the offset is less than 0, or greater than the number of |
| | | * path elements in this path. |
| | | */ |
| | | public ManagedObjectPath<?, ?> parent(int offset) throws IllegalArgumentException { |
| | | public ManagedObjectPath<?, ?> parent(int offset) { |
| | | if (offset < 0) { |
| | | throw new IllegalArgumentException("Negative offset"); |
| | | } |
| | |
| | | return emptyPath(); |
| | | } |
| | | |
| | | LinkedList<Element<?, ?>> celements = new LinkedList<Element<?, ?>>(elements.subList(0, elements.size() |
| | | - offset)); |
| | | LinkedList<Element<?, ?>> celements = |
| | | new LinkedList<Element<?, ?>>(elements.subList(0, elements.size() - offset)); |
| | | return create(celements, celements.getLast()); |
| | | } |
| | | |
| | |
| | | * If this managed object path is empty or if its final path |
| | | * element does not comprise of an instantiable relation. |
| | | */ |
| | | @SuppressWarnings("unchecked") |
| | | public ManagedObjectPath<C, S> rename(String newName) throws IllegalStateException { |
| | | public ManagedObjectPath<C, S> rename(String newName) { |
| | | if (elements.size() == 0) { |
| | | throw new IllegalStateException("Cannot rename an empty path"); |
| | | } |
| | | |
| | | if (r instanceof InstantiableRelationDefinition) { |
| | | InstantiableRelationDefinition<? super C, ? super S> ir = (InstantiableRelationDefinition<? super C, ? super S>) r; |
| | | InstantiableRelationDefinition<? super C, ? super S> ir = |
| | | (InstantiableRelationDefinition<? super C, ? super S>) r; |
| | | return parent().child(ir, d, newName); |
| | | } else { |
| | | throw new IllegalStateException("Not an instantiable relation"); |
| | |
| | | */ |
| | | package org.opends.server.admin; |
| | | |
| | | |
| | | |
| | | /** |
| | | * A strategy for serializing managed object paths. |
| | | * <p> |
| | | * This interface provides a generic means for serializing managed |
| | | * object paths into application specific forms. For example, a JNDI |
| | | * client would use this interface to construct <code>LdapName</code> |
| | | * objects from a path. Similarly, on the server side, a serialization |
| | | * strategy is used to construct <code>DN</code> instances from a |
| | | * path. |
| | | * This interface provides a generic means for serializing managed object paths |
| | | * into application specific forms. For example, a JNDI client would use this |
| | | * interface to construct <code>LdapName</code> objects from a path. Similarly, |
| | | * on the server side, a serialization strategy is used to construct |
| | | * <code>DN</code> instances from a path. |
| | | * <p> |
| | | * During serialization the serializer is invoked for each element in |
| | | * the managed object path in big-endian order, starting from the root |
| | | * and proceeding down to the leaf element. |
| | | * During serialization the serializer is invoked for each element in the |
| | | * managed object path in big-endian order, starting from the root and |
| | | * proceeding down to the leaf element. |
| | | */ |
| | | public interface ManagedObjectPathSerializer { |
| | | |
| | | /** |
| | | * Append a managed object path element identified by an |
| | | * instantiable relation and an instance name. |
| | | * Append a managed object path element identified by an instantiable |
| | | * relation and an instance name. |
| | | * |
| | | * @param <C> |
| | | * The type of client managed object configuration that |
| | | * this path element references. |
| | | * The type of client managed object configuration that this path |
| | | * element references. |
| | | * @param <S> |
| | | * The type of server managed object configuration that |
| | | * this path element references. |
| | | * The type of server managed object configuration that this path |
| | | * element references. |
| | | * @param r |
| | | * The instantiable relation. |
| | | * @param d |
| | |
| | | * @param name |
| | | * The instance name. |
| | | */ |
| | | <C extends ConfigurationClient, S extends Configuration> |
| | | void appendManagedObjectPathElement( |
| | | InstantiableRelationDefinition<? super C, ? super S> r, |
| | | AbstractManagedObjectDefinition<C, S> d, String name); |
| | | |
| | | |
| | | <C extends ConfigurationClient, S extends Configuration> void appendManagedObjectPathElement( |
| | | InstantiableRelationDefinition<? super C, ? super S> r, AbstractManagedObjectDefinition<C, S> d, String name); |
| | | |
| | | /** |
| | | * Append a managed object path element identified by an optional |
| | | * relation. |
| | | * Append a managed object path element identified by an optional relation. |
| | | * |
| | | * @param <C> |
| | | * The type of client managed object configuration that |
| | | * this path element references. |
| | | * The type of client managed object configuration that this path |
| | | * element references. |
| | | * @param <S> |
| | | * The type of server managed object configuration that |
| | | * this path element references. |
| | | * The type of server managed object configuration that this path |
| | | * element references. |
| | | * @param r |
| | | * The optional relation. |
| | | * @param d |
| | | * The managed object definition. |
| | | */ |
| | | <C extends ConfigurationClient, S extends Configuration> |
| | | void appendManagedObjectPathElement( |
| | | OptionalRelationDefinition<? super C, ? super S> r, |
| | | AbstractManagedObjectDefinition<C, S> d); |
| | | |
| | | |
| | | <C extends ConfigurationClient, S extends Configuration> void appendManagedObjectPathElement( |
| | | OptionalRelationDefinition<? super C, ? super S> r, AbstractManagedObjectDefinition<C, S> d); |
| | | |
| | | /** |
| | | * Append a managed object path element identified by a singleton |
| | | * relation. |
| | | * Append a managed object path element identified by a singleton relation. |
| | | * |
| | | * @param <C> |
| | | * The type of client managed object configuration that |
| | | * this path element references. |
| | | * The type of client managed object configuration that this path |
| | | * element references. |
| | | * @param <S> |
| | | * The type of server managed object configuration that |
| | | * this path element references. |
| | | * The type of server managed object configuration that this path |
| | | * element references. |
| | | * @param r |
| | | * The singleton relation. |
| | | * @param d |
| | | * The managed object definition. |
| | | */ |
| | | <C extends ConfigurationClient, S extends Configuration> |
| | | void appendManagedObjectPathElement( |
| | | SingletonRelationDefinition<? super C, ? super S> r, |
| | | AbstractManagedObjectDefinition<C, S> d); |
| | | |
| | | |
| | | <C extends ConfigurationClient, S extends Configuration> void appendManagedObjectPathElement( |
| | | SingletonRelationDefinition<? super C, ? super S> r, AbstractManagedObjectDefinition<C, S> d); |
| | | |
| | | /** |
| | | * Append a managed object path element identified by a |
| | | * set relation. |
| | | * Append a managed object path element identified by a set relation. |
| | | * |
| | | * @param <C> |
| | | * The type of client managed object configuration that |
| | | * this path element references. |
| | | * The type of client managed object configuration that this path |
| | | * element references. |
| | | * @param <S> |
| | | * The type of server managed object configuration that |
| | | * this path element references. |
| | | * The type of server managed object configuration that this path |
| | | * element references. |
| | | * @param r |
| | | * The set relation. |
| | | * @param d |
| | | * The managed object definition. |
| | | */ |
| | | <C extends ConfigurationClient, S extends Configuration> |
| | | void appendManagedObjectPathElement( |
| | | SetRelationDefinition<? super C, ? super S> r, |
| | | AbstractManagedObjectDefinition<C, S> d); |
| | | <C extends ConfigurationClient, S extends Configuration> void appendManagedObjectPathElement( |
| | | SetRelationDefinition<? super C, ? super S> r, AbstractManagedObjectDefinition<C, S> d); |
| | | |
| | | } |
| | |
| | | |
| | | package org.opends.server.admin; |
| | | |
| | | |
| | | /** |
| | | * A managed object composite relationship definition which represents a |
| | | * composition of an optional single managed object (i.e. the referenced managed |
| | | * object may or may not be present). |
| | | * |
| | | * @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 final class OptionalRelationDefinition<C extends ConfigurationClient, S extends Configuration> extends |
| | | RelationDefinition<C, S> { |
| | | |
| | | /** |
| | | * A managed object composite relationship definition which represents |
| | | * a composition of an optional single managed object (i.e. the |
| | | * referenced managed object may or may not be present). |
| | | * An interface for incrementally constructing optional relation |
| | | * definitions. |
| | | * |
| | | * @param <C> |
| | | * The type of client managed object configuration that this |
| | |
| | | * The type of server managed object configuration that this |
| | | * relation definition refers to. |
| | | */ |
| | | public final class OptionalRelationDefinition |
| | | <C extends ConfigurationClient, S extends Configuration> |
| | | extends RelationDefinition<C, S> { |
| | | |
| | | /** |
| | | * An interface for incrementally constructing optional 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 final class Builder |
| | | <C extends ConfigurationClient, S extends Configuration> |
| | | extends AbstractBuilder<C, S, OptionalRelationDefinition<C, S>> { |
| | | public static final class Builder<C extends ConfigurationClient, S extends Configuration> extends |
| | | AbstractBuilder<C, S, OptionalRelationDefinition<C, S>> { |
| | | |
| | | // The optional default managed object associated with this |
| | | // optional relation. |
| | | private DefaultManagedObject<? extends C, ? extends S> |
| | | defaultManagedObject = null; |
| | | |
| | | |
| | | private DefaultManagedObject<? extends C, ? extends S> defaultManagedObject = null; |
| | | |
| | | /** |
| | | * Creates a new builder which can be used to incrementally build |
| | | * an optional relation definition. |
| | | * Creates a new builder which can be used to incrementally build an |
| | | * optional relation definition. |
| | | * |
| | | * @param pd |
| | | * The parent managed object definition. |
| | |
| | | * @param cd |
| | | * The child managed object definition. |
| | | */ |
| | | public Builder(AbstractManagedObjectDefinition<?, ?> pd, String name, |
| | | AbstractManagedObjectDefinition<C, S> cd) { |
| | | // @Checkstyle:ignore |
| | | public Builder(AbstractManagedObjectDefinition<?, ?> pd, String name, AbstractManagedObjectDefinition<C, S> cd) { |
| | | super(pd, name, cd); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Sets the optional default managed object associated with this |
| | | * optional relation definition. |
| | | * |
| | | * @param defaultManagedObject |
| | | * The default managed object or <code>null</code> if |
| | | * there is no default managed object defined for this |
| | | * relation definition. |
| | | * The default managed object or <code>null</code> if there |
| | | * is no default managed object defined for this relation |
| | | * definition. |
| | | */ |
| | | public void setDefaultManagedObject( |
| | | DefaultManagedObject<? extends C, ? extends S> defaultManagedObject) { |
| | | public void setDefaultManagedObject(DefaultManagedObject<? extends C, ? extends S> defaultManagedObject) { |
| | | this.defaultManagedObject = defaultManagedObject; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | protected OptionalRelationDefinition<C, S> buildInstance( |
| | | Common<C, S> common) { |
| | | protected OptionalRelationDefinition<C, S> buildInstance(Common<C, S> common) { |
| | | return new OptionalRelationDefinition<C, S>(common, defaultManagedObject); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | // The optional default managed object associated with this |
| | | // optional relation. |
| | | private final DefaultManagedObject<? extends C, ? extends S> |
| | | defaultManagedObject; |
| | | |
| | | |
| | | private final DefaultManagedObject<? extends C, ? extends S> defaultManagedObject; |
| | | |
| | | // Private constructor. |
| | | private OptionalRelationDefinition(Common<C, S> common, |
| | |
| | | this.defaultManagedObject = defaultManagedObject; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | |
| | | return v.visitOptional(this, p); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Gets the optional default managed object associated with this |
| | | * optional relation definition. |
| | | * |
| | | * @return Returns the default managed object or <code>null</code> |
| | | * if there is no default managed object defined for this |
| | | * Gets the optional default managed object associated with this optional |
| | | * relation definition. |
| | | * |
| | | * @return Returns the default managed object or <code>null</code> if there |
| | | * is no default managed object defined for this relation |
| | | * definition. |
| | | */ |
| | | public DefaultManagedObject<? extends C, ? extends S> |
| | | getDefaultManagedObject() { |
| | | public DefaultManagedObject<? extends C, ? extends S> getDefaultManagedObject() { |
| | | return defaultManagedObject; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | |
| | | builder.append(getChildDefinition().getName()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | |
| | | * @throws ClassCastException |
| | | * If the provided property value did not have the correct type. |
| | | */ |
| | | public final T castValue(Object object) throws ClassCastException { |
| | | public final T castValue(Object object) { |
| | | return theClass.cast(object); |
| | | } |
| | | |
| | |
| | | * @throws IllegalPropertyValueStringException |
| | | * If the property value string is invalid. |
| | | */ |
| | | public abstract T decodeValue(String value) throws IllegalPropertyValueStringException; |
| | | public abstract T decodeValue(String value); |
| | | |
| | | /** |
| | | * Encode the provided property value into its string representation. |
| | |
| | | * @throws IllegalPropertyValueException |
| | | * If the property value is invalid. |
| | | */ |
| | | public String encodeValue(T value) throws IllegalPropertyValueException { |
| | | public String encodeValue(T value) { |
| | | Reject.ifNull(value); |
| | | |
| | | return value.toString(); |
| | |
| | | * @throws IllegalPropertyValueException |
| | | * If the property value is invalid. |
| | | */ |
| | | public String normalizeValue(T value) throws IllegalPropertyValueException { |
| | | public String normalizeValue(T value) { |
| | | Reject.ifNull(value); |
| | | |
| | | return encodeValue(value); |
| | |
| | | * @throws IllegalPropertyValueException |
| | | * If the property value is invalid. |
| | | */ |
| | | public abstract void validateValue(T value) throws IllegalPropertyValueException; |
| | | public abstract void validateValue(T value); |
| | | |
| | | /** |
| | | * Performs any run-time initialization required by this property |
| | |
| | | /** |
| | | * Underlying implementation. |
| | | */ |
| | | private class MyPropertyDefinitionVisitor extends PropertyDefinitionVisitor<LocalizableMessage, Void> { |
| | | private final class MyPropertyDefinitionVisitor extends PropertyDefinitionVisitor<LocalizableMessage, Void> { |
| | | |
| | | // Flag indicating whether detailed syntax information will be |
| | | // generated. |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public <T> LocalizableMessage visitUnknown(PropertyDefinition<T> d, Void p) |
| | | throws UnknownPropertyDefinitionException { |
| | | public <T> LocalizableMessage visitUnknown(PropertyDefinition<T> d, Void p) { |
| | | return LocalizableMessage.raw("?"); |
| | | } |
| | | } |
| | |
| | | |
| | | package org.opends.server.admin; |
| | | |
| | | |
| | | |
| | | /** |
| | | * A visitor of property definitions, in the style of the visitor |
| | | * design pattern. Classes implementing this interface can query |
| | | * property definitions in a type-safe manner when the kind of |
| | | * property definition is unknown at compile time. When a visitor is |
| | | * passed to a property definition's accept method, the corresponding |
| | | * visit method most applicable to that property definition is |
| | | * invoked. |
| | | * A visitor of property definitions, in the style of the visitor design |
| | | * pattern. Classes implementing this interface can query property definitions |
| | | * in a type-safe manner when the kind of property definition is unknown at |
| | | * compile time. When a visitor is passed to a property definition's accept |
| | | * method, the corresponding visit method most applicable to that property |
| | | * definition is invoked. |
| | | * <p> |
| | | * Each <code>visitXXX</code> method is provided with a default |
| | | * implementation which calls |
| | | * {@link #visitUnknown(PropertyDefinition, Object)}. Sub-classes can |
| | | * override any or all of the methods to provide their own |
| | | * type-specific behavior. |
| | | * Each <code>visitXXX</code> method is provided with a default implementation |
| | | * which calls {@link #visitUnknown(PropertyDefinition, Object)}. Sub-classes |
| | | * can override any or all of the methods to provide their own type-specific |
| | | * behavior. |
| | | * |
| | | * @param <R> |
| | | * The return type of this visitor's methods. Use |
| | | * {@link java.lang.Void} for visitors that do not need to |
| | | * return results. |
| | | * {@link java.lang.Void} for visitors that do not need to return |
| | | * results. |
| | | * @param <P> |
| | | * The type of the additional parameter to this visitor's |
| | | * methods. Use {@link java.lang.Void} for visitors that do |
| | | * not need an additional parameter. |
| | | * The type of the additional parameter to this visitor's methods. |
| | | * Use {@link java.lang.Void} for visitors that do not need an |
| | | * additional parameter. |
| | | */ |
| | | public abstract class PropertyDefinitionVisitor<R, P> { |
| | | |
| | |
| | | // No implementation required. |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Visit a dseecompat Global ACI property definition. |
| | | * |
| | |
| | | return visitUnknown(pd, p); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Visit an aggregation property definition. |
| | | * |
| | | * @param <C> |
| | | * The type of client managed object configuration that |
| | | * this aggregation property definition refers to. |
| | | * The type of client managed object configuration that this |
| | | * aggregation property definition refers to. |
| | | * @param <S> |
| | | * The type of server managed object configuration that |
| | | * this aggregation property definition refers to. |
| | | * The type of server managed object configuration that this |
| | | * aggregation property definition refers to. |
| | | * @param pd |
| | | * The aggregation property definition to visit. |
| | | * @param p |
| | | * A visitor specified parameter. |
| | | * @return Returns a visitor specified result. |
| | | */ |
| | | public <C extends ConfigurationClient, S extends Configuration> |
| | | R visitAggregation(AggregationPropertyDefinition<C, S> pd, P p) { |
| | | public <C extends ConfigurationClient, S extends Configuration> R visitAggregation( |
| | | AggregationPropertyDefinition<C, S> pd, P p) { |
| | | return visitUnknown(pd, p); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Visit an attribute type property definition. |
| | | * |
| | |
| | | return visitUnknown(pd, p); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Visit a boolean property definition. |
| | | * |
| | |
| | | return visitUnknown(pd, p); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Visit a class property definition. |
| | | * |
| | |
| | | return visitUnknown(pd, p); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Visit a DN property definition. |
| | | * |
| | |
| | | return visitUnknown(pd, p); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Visit a duration property definition. |
| | | * |
| | |
| | | return visitUnknown(pd, p); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Visit an enumeration property definition. |
| | | * |
| | | * @param <E> |
| | | * The enumeration that should be used for values of the |
| | | * property definition. |
| | | * The enumeration that should be used for values of the property |
| | | * definition. |
| | | * @param pd |
| | | * The enumeration property definition to visit. |
| | | * @param p |
| | |
| | | return visitUnknown(pd, p); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Visit an integer property definition. |
| | | * |
| | |
| | | return visitUnknown(pd, p); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Visit a IP address property definition. |
| | | * |
| | |
| | | return visitUnknown(pd, p); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Visit a IP address mask property definition. |
| | | * |
| | |
| | | return visitUnknown(pd, p); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Visit a size property definition. |
| | | * |
| | |
| | | return visitUnknown(pd, p); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Visit a string property definition. |
| | | * |
| | |
| | | return visitUnknown(pd, p); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * Visit an unknown type of property definition. Implementations of |
| | | * this method can provide default behavior for unknown property |
| | | * definition types. |
| | | * Visit an unknown type of property definition. Implementations of this |
| | | * method can provide default behavior for unknown property definition |
| | | * types. |
| | | * <p> |
| | | * The default implementation of this method throws an |
| | | * {@link UnknownPropertyDefinitionException}. Sub-classes can |
| | | * override this method with their own default behavior. |
| | | * {@link UnknownPropertyDefinitionException}. Sub-classes can override this |
| | | * method with their own default behavior. |
| | | * |
| | | * @param <T> |
| | | * The type of the underlying property. |
| | |
| | | * A visitor specified parameter. |
| | | * @return Returns a visitor specified result. |
| | | * @throws UnknownPropertyDefinitionException |
| | | * Visitor implementations may optionally throw this |
| | | * exception. |
| | | * Visitor implementations may optionally throw this exception. |
| | | */ |
| | | public <T> R visitUnknown(PropertyDefinition<T> pd, P p) |
| | | throws UnknownPropertyDefinitionException { |
| | | public <T> R visitUnknown(PropertyDefinition<T> pd, P p) { |
| | | throw new UnknownPropertyDefinitionException(pd, p); |
| | | } |
| | | |
| | |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.server.admin; |
| | | |
| | | import static com.forgerock.opendj.ldap.AdminMessages.*; |
| | |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.server.admin; |
| | | |
| | | import static com.forgerock.opendj.ldap.AdminMessages.*; |
| | |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.server.admin; |
| | | |
| | | import static com.forgerock.opendj.ldap.AdminMessages.*; |
| | |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.server.admin; |
| | | |
| | | import static com.forgerock.opendj.ldap.AdminMessages.*; |
| | |
| | | |
| | | package org.opends.server.admin; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This enumeration contains various options that can be associated |
| | | * with property definitions. |
| | | * This enumeration contains various options that can be associated with |
| | | * property definitions. |
| | | */ |
| | | public enum PropertyOption { |
| | | /** |
| | | * Use this option to identify properties which should be considered |
| | | * as advanced and should not be exposed by default in client |
| | | * applications. |
| | | * Use this option to identify properties which should be considered as |
| | | * advanced and should not be exposed by default in client applications. |
| | | */ |
| | | ADVANCED, |
| | | |
| | | /** |
| | | * Use this option to identify properties which must not be directly |
| | | * exposed in client applications. |
| | | * Use this option to identify properties which must not be directly exposed |
| | | * in client applications. |
| | | */ |
| | | HIDDEN, |
| | | |
| | |
| | | MULTI_VALUED, |
| | | |
| | | /** |
| | | * Use this option to identify properties which can be initialized |
| | | * once only and are read-only thereafter. |
| | | * Use this option to identify properties which can be initialized once only |
| | | * and are read-only thereafter. |
| | | */ |
| | | READ_ONLY, |
| | | |
| | | /** |
| | | * Use this option to identify properties which are for monitoring |
| | | * purposes only and are generated automatically by the server.. |
| | | * Use this option to identify properties which are for monitoring purposes |
| | | * only and are generated automatically by the server.. |
| | | */ |
| | | MONITORING; |
| | | } |
| | |
| | | |
| | | package org.opends.server.admin; |
| | | |
| | | |
| | | |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | | |
| | | |
| | | |
| | | /** |
| | | * An interface which can be used to initialize the contents of a managed |
| | | * object. |
| | |
| | | public interface PropertyProvider { |
| | | |
| | | /** |
| | | * A property provider which always returns empty property values, indicating |
| | | * default behavior. |
| | | * A property provider which always returns empty property values, |
| | | * indicating default behavior. |
| | | */ |
| | | public static final PropertyProvider DEFAULT_PROVIDER = |
| | | new PropertyProvider() { |
| | | public static final PropertyProvider DEFAULT_PROVIDER = new PropertyProvider() { |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public <T> Collection<T> getPropertyValues(PropertyDefinition<T> d) |
| | | throws IllegalArgumentException { |
| | | public <T> Collection<T> getPropertyValues(PropertyDefinition<T> d) { |
| | | return Collections.<T> emptySet(); |
| | | } |
| | | |
| | | }; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Get the property values associated with the specified property definition. |
| | | * Get the property values associated with the specified property |
| | | * definition. |
| | | * <p> |
| | | * Implementations are not required to validate the values that they provide. |
| | | * Specifically: |
| | | * Implementations are not required to validate the values that they |
| | | * provide. Specifically: |
| | | * <ul> |
| | | * <li>they do not need to guarantee that the provided values are valid |
| | | * according to the property's syntax |
| | | * <li>they do not need to provide values for mandatory properties |
| | | * <li>they do not need to ensure that single-valued properties do contain at |
| | | * most one value. |
| | | * <li>they do not need to ensure that single-valued properties do contain |
| | | * at most one value. |
| | | * </ul> |
| | | * The returned set of values is allowed to contain duplicates. |
| | | * |
| | |
| | | * If this property provider does not recognise the requested |
| | | * property definition. |
| | | */ |
| | | <T> Collection<T> getPropertyValues(PropertyDefinition<T> d) |
| | | throws IllegalArgumentException; |
| | | <T> Collection<T> getPropertyValues(PropertyDefinition<T> d); |
| | | } |
| | |
| | | |
| | | package org.opends.server.admin; |
| | | |
| | | |
| | | |
| | | import java.net.InetAddress; |
| | | |
| | | import org.forgerock.opendj.ldap.DN; |
| | |
| | | import org.opends.server.authorization.dseecompat.Aci; |
| | | import org.opends.server.types.AddressMask; |
| | | |
| | | |
| | | /** |
| | | * A visitor of property values, in the style of the visitor design |
| | | * pattern. Classes implementing this interface can query a property a |
| | | * value and its associated property definition in a type-safe manner |
| | | * when the kind of property value is unknown at compile time. When a |
| | | * visitor is passed to a property definition's accept method, the |
| | | * corresponding visit method most applicable to that property |
| | | * definition is invoked. |
| | | * A visitor of property values, in the style of the visitor design pattern. |
| | | * Classes implementing this interface can query a property a value and its |
| | | * associated property definition in a type-safe manner when the kind of |
| | | * property value is unknown at compile time. When a visitor is passed to a |
| | | * property definition's accept method, the corresponding visit method most |
| | | * applicable to that property definition is invoked. |
| | | * <p> |
| | | * Each <code>visitXXX</code> method is provided with a default |
| | | * implementation which calls |
| | | * {@link #visitUnknown(PropertyDefinition, Object, Object)}. |
| | | * Sub-classes can override any or all of the methods to provide their |
| | | * own type-specific behavior. |
| | | * Each <code>visitXXX</code> method is provided with a default implementation |
| | | * which calls {@link #visitUnknown(PropertyDefinition, Object, Object)}. |
| | | * Sub-classes can override any or all of the methods to provide their own |
| | | * type-specific behavior. |
| | | * |
| | | * @param <R> |
| | | * The return type of this visitor's methods. Use |
| | | * {@link java.lang.Void} for visitors that do not need to |
| | | * return results. |
| | | * {@link java.lang.Void} for visitors that do not need to return |
| | | * results. |
| | | * @param <P> |
| | | * The type of the additional parameter to this visitor's |
| | | * methods. Use {@link java.lang.Void} for visitors that do |
| | | * not need an additional parameter. |
| | | * The type of the additional parameter to this visitor's methods. |
| | | * Use {@link java.lang.Void} for visitors that do not need an |
| | | * additional parameter. |
| | | */ |
| | | public abstract class PropertyValueVisitor<R, P> { |
| | | |
| | |
| | | // No implementation required. |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Visit a dseecompat ACI. |
| | | * |
| | |
| | | * A visitor specified parameter. |
| | | * @return Returns a visitor specified result. |
| | | */ |
| | | public R visitACI(ACIPropertyDefinition pd, Aci v, |
| | | P p) { |
| | | public R visitACI(ACIPropertyDefinition pd, Aci v, P p) { |
| | | return visitUnknown(pd, v, p); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Visit an aggregation property value. |
| | | * |
| | | * @param <C> |
| | | * The type of client managed object configuration that |
| | | * this aggregation property definition refers to. |
| | | * The type of client managed object configuration that this |
| | | * aggregation property definition refers to. |
| | | * @param <S> |
| | | * The type of server managed object configuration that |
| | | * this aggregation property definition refers to. |
| | | * The type of server managed object configuration that this |
| | | * aggregation property definition refers to. |
| | | * @param pd |
| | | * The aggregation property definition to visit. |
| | | * @param v |
| | |
| | | * A visitor specified parameter. |
| | | * @return Returns a visitor specified result. |
| | | */ |
| | | public <C extends ConfigurationClient, S extends Configuration> |
| | | R visitAggregation( |
| | | public <C extends ConfigurationClient, S extends Configuration> R visitAggregation( |
| | | AggregationPropertyDefinition<C, S> pd, String v, P p) { |
| | | return visitUnknown(pd, v, p); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Visit an attribute type. |
| | | * |
| | |
| | | * A visitor specified parameter. |
| | | * @return Returns a visitor specified result. |
| | | */ |
| | | public R visitAttributeType(AttributeTypePropertyDefinition pd, |
| | | AttributeType v, P p) { |
| | | public R visitAttributeType(AttributeTypePropertyDefinition pd, AttributeType v, P p) { |
| | | return visitUnknown(pd, v, p); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Visit a boolean. |
| | | * |
| | |
| | | return visitUnknown(pd, v, p); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Visit a class. |
| | | * |
| | |
| | | return visitUnknown(pd, v, p); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Visit a DN. |
| | | * |
| | |
| | | return visitUnknown(pd, v, p); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Visit a duration. |
| | | * |
| | |
| | | return visitUnknown(pd, v, p); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Visit an enumeration. |
| | | * |
| | | * @param <E> |
| | | * The enumeration that should be used for values of the |
| | | * property definition. |
| | | * The enumeration that should be used for values of the property |
| | | * definition. |
| | | * @param pd |
| | | * The enumeration property definition. |
| | | * @param v |
| | |
| | | * A visitor specified parameter. |
| | | * @return Returns a visitor specified result. |
| | | */ |
| | | public <E extends Enum<E>> |
| | | R visitEnum(EnumPropertyDefinition<E> pd, E v, P p) { |
| | | public <E extends Enum<E>> R visitEnum(EnumPropertyDefinition<E> pd, E v, P p) { |
| | | return visitUnknown(pd, v, p); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Visit an integer. |
| | | * |
| | |
| | | return visitUnknown(pd, v, p); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Visit a IP address. |
| | | * |
| | |
| | | return visitUnknown(pd, v, p); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Visit a IP address mask. |
| | | * |
| | |
| | | * A visitor specified parameter. |
| | | * @return Returns a visitor specified result. |
| | | */ |
| | | public R visitIPAddressMask(IPAddressMaskPropertyDefinition pd, AddressMask v, |
| | | P p) { |
| | | public R visitIPAddressMask(IPAddressMaskPropertyDefinition pd, AddressMask v, P p) { |
| | | return visitUnknown(pd, v, p); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Visit a size. |
| | | * |
| | |
| | | return visitUnknown(pd, v, p); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Visit a string. |
| | | * |
| | |
| | | return visitUnknown(pd, v, p); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Visit an unknown type of property value. Implementations of this |
| | | * method can provide default behavior for unknown types of |
| | | * property. |
| | | * Visit an unknown type of property value. Implementations of this method |
| | | * can provide default behavior for unknown types of property. |
| | | * <p> |
| | | * The default implementation of this method throws an |
| | | * {@link UnknownPropertyDefinitionException}. Sub-classes can |
| | | * override this method with their own default behavior. |
| | | * {@link UnknownPropertyDefinitionException}. Sub-classes can override this |
| | | * method with their own default behavior. |
| | | * |
| | | * @param <T> |
| | | * The type of property value to visit. |
| | |
| | | * A visitor specified parameter. |
| | | * @return Returns a visitor specified result. |
| | | * @throws UnknownPropertyDefinitionException |
| | | * Visitor implementations may optionally throw this |
| | | * exception. |
| | | * Visitor implementations may optionally throw this exception. |
| | | */ |
| | | public <T> R visitUnknown(PropertyDefinition<T> pd, T v, P p) |
| | | throws UnknownPropertyDefinitionException { |
| | | public <T> R visitUnknown(PropertyDefinition<T> pd, T v, P p) { |
| | | throw new UnknownPropertyDefinitionException(pd, p); |
| | | } |
| | | |
| | |
| | | * relation. |
| | | */ |
| | | public static <C extends ConfigurationClient, S extends Configuration> Reference<C, S> parseDN( |
| | | ManagedObjectPath<?, ?> path, InstantiableRelationDefinition<C, S> relationDef, String dnAsString) |
| | | throws IllegalArgumentException { |
| | | ManagedObjectPath<?, ?> path, InstantiableRelationDefinition<C, S> relationDef, String dnAsString) { |
| | | AbstractManagedObjectDefinition<?, ?> definition = path.getManagedObjectDefinition(); |
| | | RelationDefinition<?, ?> tmp = definition.getRelationDefinition(relationDef.getName()); |
| | | if (tmp != relationDef) { |
| | |
| | | * definition, or if the provided name is empty. |
| | | */ |
| | | public static <C extends ConfigurationClient, S extends Configuration> Reference<C, S> parseName( |
| | | ManagedObjectPath<?, ?> p, InstantiableRelationDefinition<C, S> rd, String s) |
| | | throws IllegalArgumentException { |
| | | ManagedObjectPath<?, ?> p, InstantiableRelationDefinition<C, S> rd, String s) { |
| | | // Sanity checks. |
| | | AbstractManagedObjectDefinition<?, ?> d = p.getManagedObjectDefinition(); |
| | | RelationDefinition<?, ?> tmp = d.getRelationDefinition(rd.getName()); |
| | |
| | | private final InstantiableRelationDefinition<C, S> relation; |
| | | |
| | | // Private constructor. |
| | | private Reference(ManagedObjectPath<?, ?> parent, InstantiableRelationDefinition<C, S> relation, String name) |
| | | throws IllegalArgumentException { |
| | | private Reference(ManagedObjectPath<?, ?> parent, InstantiableRelationDefinition<C, S> relation, String name) { |
| | | this.relation = relation; |
| | | this.name = name; |
| | | this.path = parent.child(relation, name); |
| | |
| | | * @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>> { |
| | | protected abstract static class AbstractBuilder<C extends ConfigurationClient, S extends Configuration, |
| | | D extends RelationDefinition<C, S>> { |
| | | |
| | | // Common fields. |
| | | private final Common<C, S> common; |
| | |
| | | private final AbstractManagedObjectDefinition<?, ?> pd; |
| | | |
| | | // Private constructor. |
| | | private Common(AbstractManagedObjectDefinition<?, ?> pd, String name, AbstractManagedObjectDefinition<C, S> cd) { |
| | | private Common(AbstractManagedObjectDefinition<?, ?> pd, String name, |
| | | AbstractManagedObjectDefinition<C, S> cd) { |
| | | this.name = name; |
| | | this.pd = pd; |
| | | this.cd = cd; |
| | |
| | | public final LocalizableMessage getDescription(Locale locale) { |
| | | try { |
| | | String property = "relation." + common.name + ".description"; |
| | | return ManagedObjectDefinitionI18NResource.getInstance() |
| | | .getMessage(getParentDefinition(), property, locale); |
| | | return ManagedObjectDefinitionI18NResource.getInstance().getMessage(getParentDefinition(), property, |
| | | locale); |
| | | } catch (MissingResourceException e) { |
| | | return null; |
| | | } |
| | |
| | | |
| | | package org.opends.server.admin; |
| | | |
| | | |
| | | |
| | | /** |
| | | * A visitor of relation definitions, in the style of the visitor |
| | | * design pattern. Classes implementing this interface can query |
| | | * relation definitions in a type-safe manner when the kind of |
| | | * relation definition is unknown at compile time. When a visitor is |
| | | * passed to a relation definition's accept method, the corresponding |
| | | * visit method most applicable to that relation definition is |
| | | * invoked. |
| | | * A visitor of relation definitions, in the style of the visitor design |
| | | * pattern. Classes implementing this interface can query relation definitions |
| | | * in a type-safe manner when the kind of relation definition is unknown at |
| | | * compile time. When a visitor is passed to a relation definition's accept |
| | | * method, the corresponding visit method most applicable to that relation |
| | | * definition is invoked. |
| | | * |
| | | * @param <R> |
| | | * The return type of this visitor's methods. Use |
| | | * {@link java.lang.Void} for visitors that do not need to |
| | | * return results. |
| | | * {@link java.lang.Void} for visitors that do not need to return |
| | | * results. |
| | | * @param <P> |
| | | * The type of the additional parameter to this visitor's |
| | | * methods. Use {@link java.lang.Void} for visitors that do |
| | | * not need an additional parameter. |
| | | * The type of the additional parameter to this visitor's methods. |
| | | * Use {@link java.lang.Void} for visitors that do not need an |
| | | * additional parameter. |
| | | */ |
| | | public interface RelationDefinitionVisitor<R, P> { |
| | | |
| | |
| | | <C extends ConfigurationClient, S extends Configuration> R visitInstantiable( |
| | | InstantiableRelationDefinition<C, S> rd, P p); |
| | | |
| | | |
| | | |
| | | /** |
| | | * Visit a set relation definition. |
| | | * |
| | |
| | | * A visitor specified parameter. |
| | | * @return Returns a visitor specified result. |
| | | */ |
| | | <C extends ConfigurationClient, S extends Configuration> R visitSet( |
| | | SetRelationDefinition<C, S> rd, P p); |
| | | |
| | | |
| | | <C extends ConfigurationClient, S extends Configuration> R visitSet(SetRelationDefinition<C, S> rd, P p); |
| | | |
| | | /** |
| | | * Visit an optional relation definition. |
| | |
| | | * A visitor specified parameter. |
| | | * @return Returns a visitor specified result. |
| | | */ |
| | | <C extends ConfigurationClient, S extends Configuration> R visitOptional( |
| | | OptionalRelationDefinition<C, S> rd, P p); |
| | | |
| | | |
| | | <C extends ConfigurationClient, S extends Configuration> R visitOptional(OptionalRelationDefinition<C, S> rd, P p); |
| | | |
| | | /** |
| | | * Visit a singleton relation definition. |
| | |
| | | * A visitor specified parameter. |
| | | * @return Returns a visitor specified result. |
| | | */ |
| | | <C extends ConfigurationClient, S extends Configuration> R visitSingleton( |
| | | SingletonRelationDefinition<C, S> rd, P p); |
| | | <C extends ConfigurationClient, S extends Configuration> R visitSingleton(SingletonRelationDefinition<C, S> rd, |
| | | P p); |
| | | |
| | | } |
| | |
| | | |
| | | package org.opends.server.admin; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This enumeration contains various options that can be associated |
| | | * with relation definitions. |
| | | * This enumeration contains various options that can be associated with |
| | | * relation definitions. |
| | | */ |
| | | public enum RelationOption { |
| | | /** |
| | | * Use this option to identify relations which should be considered |
| | | * as advanced and should not be exposed by default in client |
| | | * applications. |
| | | * Use this option to identify relations which should be considered as |
| | | * advanced and should not be exposed by default in client applications. |
| | | */ |
| | | ADVANCED, |
| | | |
| | | /** |
| | | * Use this option to identify relations which must not be directly |
| | | * exposed in client applications. |
| | | * Use this option to identify relations which must not be directly exposed |
| | | * in client applications. |
| | | */ |
| | | HIDDEN; |
| | | } |
| | |
| | | */ |
| | | package org.opends.server.admin; |
| | | |
| | | |
| | | |
| | | /** |
| | | * A default behavior provider which retrieves default values from a |
| | | * parent managed object. It should be used by properties which |
| | | * inherit their default value(s) from properties held in an other |
| | | * managed object. |
| | | * A default behavior provider which retrieves default values from a parent |
| | | * managed object. It should be used by properties which inherit their default |
| | | * value(s) from properties held in an other managed object. |
| | | * |
| | | * @param <T> |
| | | * The type of values represented by this provider. |
| | | */ |
| | | public final class RelativeInheritedDefaultBehaviorProvider<T> extends |
| | | DefaultBehaviorProvider<T> { |
| | | public final class RelativeInheritedDefaultBehaviorProvider<T> extends DefaultBehaviorProvider<T> { |
| | | |
| | | // The type of managed object expected at the relative offset. |
| | | private final AbstractManagedObjectDefinition<?, ?> d; |
| | |
| | | // The name of the property containing the inherited default values. |
| | | private final String propertyName; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Create a relative inherited default behavior provider associated |
| | | * with a parent managed object. |
| | | * Create a relative inherited default behavior provider associated with a |
| | | * parent managed object. |
| | | * |
| | | * @param d |
| | | * The type of parent managed object expected at the |
| | | * relative location. |
| | | * The type of parent managed object expected at the relative |
| | | * location. |
| | | * @param propertyName |
| | | * The name of the property containing the inherited |
| | | * default values. |
| | | * The name of the property containing the inherited default |
| | | * values. |
| | | * @param offset |
| | | * The relative location of the parent managed object |
| | | * (where 0 is the managed object itself, 1 is the parent, |
| | | * and 2 is the grand-parent). |
| | | * The relative location of the parent managed object (where 0 is |
| | | * the managed object itself, 1 is the parent, and 2 is the |
| | | * grand-parent). |
| | | * @throws IllegalArgumentException |
| | | * If the offset is less than 0. |
| | | */ |
| | | public RelativeInheritedDefaultBehaviorProvider( |
| | | AbstractManagedObjectDefinition<?, ?> d, String propertyName, int offset) |
| | | throws IllegalArgumentException { |
| | | public RelativeInheritedDefaultBehaviorProvider(AbstractManagedObjectDefinition<?, ?> d, String propertyName, |
| | | int offset) { |
| | | // We do not decode the property name now because the property |
| | | // might not have been constructed at this point (e.g. when the |
| | | // offset is 0). |
| | |
| | | this.offset = offset; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | |
| | | return v.visitRelativeInherited(this, p); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Get the definition of the parent managed object containing the |
| | | * inherited default values. |
| | | * Get the definition of the parent managed object containing the inherited |
| | | * default values. |
| | | * |
| | | * @return Returns the definition of the parent managed object |
| | | * containing the inherited default values. |
| | | * @return Returns the definition of the parent managed object containing |
| | | * the inherited default values. |
| | | */ |
| | | public AbstractManagedObjectDefinition<?, ?> getManagedObjectDefinition() { |
| | | return d; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Get the absolute path of the managed object containing the |
| | | * property which has the default values. |
| | | * Get the absolute path of the managed object containing the property which |
| | | * has the default values. |
| | | * |
| | | * @param path |
| | | * The path of the current managed object from which the |
| | | * relative path should be determined. |
| | | * @return Returns the absolute path of the managed object |
| | | * containing the property which has the default values. |
| | | * The path of the current managed object from which the relative |
| | | * path should be determined. |
| | | * @return Returns the absolute path of the managed object containing the |
| | | * property which has the default values. |
| | | */ |
| | | public ManagedObjectPath<?, ?> getManagedObjectPath( |
| | | ManagedObjectPath<?, ?> path) { |
| | | public ManagedObjectPath<?, ?> getManagedObjectPath(ManagedObjectPath<?, ?> path) { |
| | | return path.parent(offset); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Gets the name of the property containing the inherited default |
| | | * values. |
| | | * Gets the name of the property containing the inherited default values. |
| | | * |
| | | * @return Returns the name of the property containing the inherited |
| | | * default values. |
| | | * @return Returns the name of the property containing the inherited default |
| | | * values. |
| | | */ |
| | | public String getPropertyName() { |
| | | return propertyName; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Get the relative location of the parent managed object. |
| | | * |
| | | * @return Returns the relative location of the parent managed |
| | | * object (where 0 is the managed object itself, 1 is the |
| | | * parent, and 2 is the grand-parent). |
| | | * @return Returns the relative location of the parent managed object (where |
| | | * 0 is the managed object itself, 1 is the parent, and 2 is the |
| | | * grand-parent). |
| | | */ |
| | | public int getRelativeOffset() { |
| | | return offset; |
| | |
| | | |
| | | // The optional default managed objects associated with this |
| | | // set relation definition. |
| | | private final Map<String, DefaultManagedObject<? extends C, ? extends S>> defaultManagedObjects = new HashMap<String, DefaultManagedObject<? extends C, ? extends S>>(); |
| | | private final Map<String, DefaultManagedObject<? extends C, ? extends S>> defaultManagedObjects = |
| | | new HashMap<String, DefaultManagedObject<? extends C, ? extends S>>(); |
| | | |
| | | /** |
| | | * Creates a new builder which can be used to incrementally build a set |
| | |
| | | * If there is no default managed object associated with the |
| | | * provided name. |
| | | */ |
| | | public DefaultManagedObject<? extends C, ? extends S> getDefaultManagedObject(String name) |
| | | throws IllegalArgumentException { |
| | | public DefaultManagedObject<? extends C, ? extends S> getDefaultManagedObject(String name) { |
| | | if (!defaultManagedObjects.containsKey(name)) { |
| | | throw new IllegalArgumentException("unrecognized default managed object \"" + name + "\""); |
| | | } |
| | |
| | | |
| | | package org.opends.server.admin; |
| | | |
| | | |
| | | /** |
| | | * A managed object composite relationship definition which represents a |
| | | * composition of a single managed object (i.e. the managed object must be |
| | | * present). |
| | | * |
| | | * @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 final class SingletonRelationDefinition<C extends ConfigurationClient, S extends Configuration> extends |
| | | RelationDefinition<C, S> { |
| | | |
| | | /** |
| | | * A managed object composite relationship definition which represents |
| | | * a composition of a single managed object (i.e. the managed object |
| | | * must be present). |
| | | * An interface for incrementally constructing singleton relation |
| | | * definitions. |
| | | * |
| | | * @param <C> |
| | | * The type of client managed object configuration that this |
| | |
| | | * The type of server managed object configuration that this |
| | | * relation definition refers to. |
| | | */ |
| | | public final class SingletonRelationDefinition |
| | | <C extends ConfigurationClient, S extends Configuration> |
| | | extends RelationDefinition<C, S> { |
| | | |
| | | /** |
| | | * An interface for incrementally constructing singleton 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 final class Builder |
| | | <C extends ConfigurationClient, S extends Configuration> |
| | | extends AbstractBuilder<C, S, SingletonRelationDefinition<C, S>> { |
| | | public static final class Builder<C extends ConfigurationClient, S extends Configuration> extends |
| | | AbstractBuilder<C, S, SingletonRelationDefinition<C, S>> { |
| | | |
| | | // The optional default managed object associated with this |
| | | // singleton relation. |
| | | private DefaultManagedObject<? extends C, ? extends S> |
| | | defaultManagedObject = null; |
| | | |
| | | |
| | | private DefaultManagedObject<? extends C, ? extends S> defaultManagedObject = null; |
| | | |
| | | /** |
| | | * Creates a new builder which can be used to incrementally build |
| | | * an singleton relation definition. |
| | | * Creates a new builder which can be used to incrementally build an |
| | | * singleton relation definition. |
| | | * |
| | | * @param pd |
| | | * The parent managed object definition. |
| | |
| | | * @param cd |
| | | * The child managed object definition. |
| | | */ |
| | | public Builder(AbstractManagedObjectDefinition<?, ?> pd, String name, |
| | | AbstractManagedObjectDefinition<C, S> cd) { |
| | | // @Checkstyle:ignore |
| | | public Builder(AbstractManagedObjectDefinition<?, ?> pd, String name, AbstractManagedObjectDefinition<C, S> cd) { |
| | | super(pd, name, cd); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Sets the optional default managed object associated with this |
| | | * singleton relation definition. |
| | | * |
| | | * @param defaultManagedObject |
| | | * The default managed object or <code>null</code> if |
| | | * there is no default managed object defined for this |
| | | * relation definition. |
| | | * The default managed object or <code>null</code> if there |
| | | * is no default managed object defined for this relation |
| | | * definition. |
| | | */ |
| | | public void setDefaultManagedObject( |
| | | DefaultManagedObject<? extends C, ? extends S> defaultManagedObject) { |
| | | public void setDefaultManagedObject(DefaultManagedObject<? extends C, ? extends S> defaultManagedObject) { |
| | | this.defaultManagedObject = defaultManagedObject; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | protected SingletonRelationDefinition<C, S> buildInstance( |
| | | Common<C, S> common) { |
| | | return new SingletonRelationDefinition<C, S>(common, |
| | | defaultManagedObject); |
| | | protected SingletonRelationDefinition<C, S> buildInstance(Common<C, S> common) { |
| | | return new SingletonRelationDefinition<C, S>(common, defaultManagedObject); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | // The optional default managed object associated with this |
| | | // singleton relation. |
| | | private final DefaultManagedObject<? extends C, ? extends S> |
| | | defaultManagedObject; |
| | | |
| | | |
| | | private final DefaultManagedObject<? extends C, ? extends S> defaultManagedObject; |
| | | |
| | | // Private constructor. |
| | | private SingletonRelationDefinition(Common<C, S> common, |
| | |
| | | this.defaultManagedObject = defaultManagedObject; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | |
| | | return v.visitSingleton(this, p); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Gets the optional default managed object associated with this |
| | | * singleton relation definition. |
| | | * |
| | | * @return Returns the default managed object or <code>null</code> |
| | | * if there is no default managed object defined for this |
| | | * Gets the optional default managed object associated with this singleton |
| | | * relation definition. |
| | | * |
| | | * @return Returns the default managed object or <code>null</code> if there |
| | | * is no default managed object defined for this relation |
| | | * definition. |
| | | */ |
| | | public DefaultManagedObject<? extends C, ? extends S> |
| | | getDefaultManagedObject() { |
| | | public DefaultManagedObject<? extends C, ? extends S> getDefaultManagedObject() { |
| | | return defaultManagedObject; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | |
| | | builder.append(getChildDefinition().getName()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.server.admin; |
| | | |
| | | import org.forgerock.util.Reject; |
| | |
| | | * An interface for incrementally constructing memory size property |
| | | * definitions. |
| | | */ |
| | | public static class Builder extends AbstractBuilder<Long, SizePropertyDefinition> { |
| | | public static final class Builder extends AbstractBuilder<Long, SizePropertyDefinition> { |
| | | |
| | | // The lower limit of the property value in bytes. |
| | | private long lowerLimit = 0L; |
| | |
| | | * If a negative lower limit was specified, or if the lower |
| | | * limit is greater than the upper limit. |
| | | */ |
| | | public final void setLowerLimit(long lowerLimit) throws IllegalArgumentException { |
| | | public final void setLowerLimit(long lowerLimit) { |
| | | if (lowerLimit < 0) { |
| | | throw new IllegalArgumentException("Negative lower limit"); |
| | | } |
| | |
| | | * lower limit was specified, or the lower limit is greater |
| | | * than the upper limit. |
| | | */ |
| | | public final void setLowerLimit(String lowerLimit) throws IllegalArgumentException { |
| | | public final void setLowerLimit(String lowerLimit) { |
| | | setLowerLimit(SizeUnit.parseValue(lowerLimit, SizeUnit.BYTES)); |
| | | } |
| | | |
| | |
| | | * @throws IllegalArgumentException |
| | | * If the lower limit is greater than the upper limit. |
| | | */ |
| | | public final void setUpperLimit(Long upperLimit) throws IllegalArgumentException { |
| | | public final void setUpperLimit(Long upperLimit) { |
| | | if (upperLimit != null) { |
| | | if (upperLimit < 0) { |
| | | throw new IllegalArgumentException("Negative upper limit"); |
| | |
| | | * If the upper limit could not be parsed, or if the lower |
| | | * limit is greater than the upper limit. |
| | | */ |
| | | public final void setUpperLimit(String upperLimit) throws IllegalArgumentException { |
| | | public final void setUpperLimit(String upperLimit) { |
| | | if (upperLimit == null) { |
| | | setUpperLimit((Long) null); |
| | | } else { |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void validateValue(Long value) throws IllegalPropertyValueException { |
| | | public void validateValue(Long value) { |
| | | Reject.ifNull(value); |
| | | |
| | | if (!allowUnlimited && value < lowerLimit) { |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public String encodeValue(Long value) throws IllegalPropertyValueException { |
| | | public String encodeValue(Long value) { |
| | | Reject.ifNull(value); |
| | | |
| | | // Make sure that we correctly encode negative values as "unlimited". |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public Long decodeValue(String value) throws IllegalPropertyValueStringException { |
| | | public Long decodeValue(String value) { |
| | | Reject.ifNull(value); |
| | | |
| | | // First check for the special "unlimited" value when necessary. |
| | |
| | | */ |
| | | package org.opends.server.admin; |
| | | |
| | | |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This enumeration defines various memory size units. |
| | | */ |
| | |
| | | TERA_BYTES((long) 1000 * 1000 * 1000 * 1000, "tb", "terabytes"); |
| | | |
| | | // A lookup table for resolving a unit from its name. |
| | | private static final Map<String, SizeUnit> nameToUnit; |
| | | private static final Map<String, SizeUnit> NAME_TO_UNIT; |
| | | static { |
| | | nameToUnit = new HashMap<String, SizeUnit>(); |
| | | NAME_TO_UNIT = new HashMap<String, SizeUnit>(); |
| | | |
| | | for (SizeUnit unit : SizeUnit.values()) { |
| | | nameToUnit.put(unit.shortName, unit); |
| | | nameToUnit.put(unit.longName, unit); |
| | | NAME_TO_UNIT.put(unit.shortName, unit); |
| | | NAME_TO_UNIT.put(unit.longName, unit); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Gets the best-fit unit for the specified number of bytes. The |
| | | * returned unit will be able to represent the number of bytes using |
| | | * a decimal number comprising of an integer part which is greater |
| | | * than zero. Bigger units are chosen in preference to smaller units |
| | | * and binary units are only returned if they are an exact fit. If |
| | | * the number of bytes is zero then the {@link #BYTES} unit is |
| | | * always returned. For example: |
| | | * Gets the best-fit unit for the specified number of bytes. The returned |
| | | * unit will be able to represent the number of bytes using a decimal number |
| | | * comprising of an integer part which is greater than zero. Bigger units |
| | | * are chosen in preference to smaller units and binary units are only |
| | | * returned if they are an exact fit. If the number of bytes is zero then |
| | | * the {@link #BYTES} unit is always returned. For example: |
| | | * |
| | | * <pre> |
| | | * getBestFitUnit(0) // BYTES |
| | |
| | | * If <code>bytes</code> is negative. |
| | | * @see #getBestFitUnitExact(long) |
| | | */ |
| | | public static SizeUnit getBestFitUnit(long bytes) |
| | | throws IllegalArgumentException { |
| | | public static SizeUnit getBestFitUnit(long bytes) { |
| | | if (bytes < 0) { |
| | | throw new IllegalArgumentException("negative number of bytes: " + bytes); |
| | | } else if (bytes == 0) { |
| | |
| | | } else { |
| | | // Determine best fit: prefer non-binary units unless binary |
| | | // fits exactly. |
| | | SizeUnit[] nonBinary = new SizeUnit[] { TERA_BYTES, GIGA_BYTES, |
| | | MEGA_BYTES, KILO_BYTES }; |
| | | SizeUnit[] binary = new SizeUnit[] { TEBI_BYTES, GIBI_BYTES, MEBI_BYTES, |
| | | KIBI_BYTES }; |
| | | SizeUnit[] nonBinary = new SizeUnit[] { TERA_BYTES, GIGA_BYTES, MEGA_BYTES, KILO_BYTES }; |
| | | SizeUnit[] binary = new SizeUnit[] { TEBI_BYTES, GIBI_BYTES, MEBI_BYTES, KIBI_BYTES }; |
| | | |
| | | for (int i = 0; i < nonBinary.length; i++) { |
| | | if ((bytes % binary[i].getSize()) == 0) { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Gets the best-fit unit for the specified number of bytes which |
| | | * can represent the provided value using an integral value. Bigger |
| | | * units are chosen in preference to smaller units. If the number of |
| | | * bytes is zero then the {@link #BYTES} unit is always returned. |
| | | * For example: |
| | | * Gets the best-fit unit for the specified number of bytes which can |
| | | * represent the provided value using an integral value. Bigger units are |
| | | * chosen in preference to smaller units. If the number of bytes is zero |
| | | * then the {@link #BYTES} unit is always returned. For example: |
| | | * |
| | | * <pre> |
| | | * getBestFitUnitExact(0) // BYTES |
| | |
| | | * |
| | | * @param bytes |
| | | * The number of bytes. |
| | | * @return Returns the best fit unit can represent the provided |
| | | * value using an integral value. |
| | | * @return Returns the best fit unit can represent the provided value using |
| | | * an integral value. |
| | | * @throws IllegalArgumentException |
| | | * If <code>bytes</code> is negative. |
| | | * @see #getBestFitUnit(long) |
| | | */ |
| | | public static SizeUnit getBestFitUnitExact(long bytes) |
| | | throws IllegalArgumentException { |
| | | public static SizeUnit getBestFitUnitExact(long bytes) { |
| | | if (bytes < 0) { |
| | | throw new IllegalArgumentException("negative number of bytes: " + bytes); |
| | | } else if (bytes == 0) { |
| | |
| | | return BYTES; |
| | | } else { |
| | | // Determine best fit. |
| | | SizeUnit[] units = new SizeUnit[] { TEBI_BYTES, TERA_BYTES, GIBI_BYTES, |
| | | GIGA_BYTES, MEBI_BYTES, MEGA_BYTES, KIBI_BYTES, KILO_BYTES }; |
| | | SizeUnit[] units = |
| | | new SizeUnit[] { TEBI_BYTES, TERA_BYTES, GIBI_BYTES, GIGA_BYTES, MEBI_BYTES, MEGA_BYTES, KIBI_BYTES, |
| | | KILO_BYTES }; |
| | | |
| | | for (SizeUnit unit : units) { |
| | | if ((bytes % unit.getSize()) == 0) { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Get the unit corresponding to the provided unit name. |
| | | * |
| | | * @param s |
| | | * The name of the unit. Can be the abbreviated or long |
| | | * name and can contain white space and mixed case |
| | | * characters. |
| | | * The name of the unit. Can be the abbreviated or long name and |
| | | * can contain white space and mixed case characters. |
| | | * @return Returns the unit corresponding to the provided unit name. |
| | | * @throws IllegalArgumentException |
| | | * If the provided name did not correspond to a known |
| | | * memory size unit. |
| | | * If the provided name did not correspond to a known memory |
| | | * size unit. |
| | | */ |
| | | public static SizeUnit getUnit(String s) throws IllegalArgumentException { |
| | | SizeUnit unit = nameToUnit.get(s.trim().toLowerCase()); |
| | | public static SizeUnit getUnit(String s) { |
| | | SizeUnit unit = NAME_TO_UNIT.get(s.trim().toLowerCase()); |
| | | if (unit == null) { |
| | | throw new IllegalArgumentException("Illegal memory size unit \"" + s |
| | | + "\""); |
| | | throw new IllegalArgumentException("Illegal memory size unit \"" + s + "\""); |
| | | } |
| | | return unit; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Parse the provided size string and return its equivalent size in |
| | | * bytes. The size string must specify the unit e.g. "10kb". |
| | | * Parse the provided size string and return its equivalent size in bytes. |
| | | * The size string must specify the unit e.g. "10kb". |
| | | * |
| | | * @param s |
| | | * The size string to be parsed. |
| | |
| | | * @throws NumberFormatException |
| | | * If the provided size string could not be parsed. |
| | | */ |
| | | public static long parseValue(String s) throws NumberFormatException { |
| | | public static long parseValue(String s) { |
| | | return parseValue(s, null); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Parse the provided size string and return its equivalent size in |
| | | * bytes. |
| | | * Parse the provided size string and return its equivalent size in bytes. |
| | | * |
| | | * @param s |
| | | * The size string to be parsed. |
| | | * @param defaultUnit |
| | | * The default unit to use if there is no unit specified in |
| | | * the size string, or <code>null</code> if the string |
| | | * must always contain a unit. |
| | | * The default unit to use if there is no unit specified in the |
| | | * size string, or <code>null</code> if the string must always |
| | | * contain a unit. |
| | | * @return Returns the parsed size in bytes. |
| | | * @throws NumberFormatException |
| | | * If the provided size string could not be parsed. |
| | | */ |
| | | public static long parseValue(String s, SizeUnit defaultUnit) |
| | | throws NumberFormatException { |
| | | public static long parseValue(String s, SizeUnit defaultUnit) { |
| | | // Value must be a floating point number followed by a unit. |
| | | Pattern p = Pattern.compile("^\\s*(\\d+(\\.\\d+)?)\\s*(\\w+)?\\s*$"); |
| | | Matcher m = p.matcher(s); |
| | |
| | | // The size of the unit in bytes. |
| | | private final long sz; |
| | | |
| | | |
| | | |
| | | // Private constructor. |
| | | private SizeUnit(long sz, String shortName, String longName) { |
| | | this.sz = sz; |
| | |
| | | this.longName = longName; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Converts the specified size in bytes to this unit. |
| | | * |
| | |
| | | return ((double) amount / sz); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Get the long name of this unit. |
| | | * |
| | |
| | | return longName; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Get the abbreviated name of this unit. |
| | | * |
| | |
| | | return shortName; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Get the number of bytes that this unit represents. |
| | | * |
| | |
| | | return sz; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Converts the specified size in this unit to bytes. |
| | | * |
| | | * @param amount |
| | | * The size as a quantity of this unit. |
| | | * @return Returns the number of bytes that the size represents. |
| | | * |
| | | * @throws NumberFormatException |
| | | * If the provided size exceeded long.MAX_VALUE. |
| | | */ |
| | | public long toBytes(double amount) throws NumberFormatException { |
| | | public long toBytes(double amount) { |
| | | double value = sz * amount; |
| | | if (value > Long.MAX_VALUE) |
| | | { |
| | | throw new NumberFormatException |
| | | ("number too big (exceeded long.MAX_VALUE"); |
| | | if (value > Long.MAX_VALUE) { |
| | | throw new NumberFormatException("number too big (exceeded long.MAX_VALUE"); |
| | | } |
| | | return (long) (value); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | * <p> |
| | | * This implementation returns the abbreviated name of this size |
| | | * unit. |
| | | * This implementation returns the abbreviated name of this size unit. |
| | | */ |
| | | @Override |
| | | public String toString() { |
| | |
| | | /** |
| | | * An interface for incrementally constructing string property definitions. |
| | | */ |
| | | public static class Builder extends AbstractBuilder<String, StringPropertyDefinition> { |
| | | public static final class Builder extends AbstractBuilder<String, StringPropertyDefinition> { |
| | | |
| | | // Flag indicating whether values of this property are |
| | | // case-insensitive. |
| | |
| | | * If the provided regular expression pattern has an invalid |
| | | * syntax. |
| | | */ |
| | | public final void setPattern(String pattern, String patternUsage) throws PatternSyntaxException { |
| | | public final void setPattern(String pattern, String patternUsage) { |
| | | if (pattern == null) { |
| | | this.pattern = null; |
| | | this.patternUsage = null; |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | protected StringPropertyDefinition buildInstance(AbstractManagedObjectDefinition<?, ?> d, String propertyName, |
| | | EnumSet<PropertyOption> options, AdministratorAction adminAction, |
| | | protected StringPropertyDefinition buildInstance(AbstractManagedObjectDefinition<?, ?> d, |
| | | String propertyName, EnumSet<PropertyOption> options, AdministratorAction adminAction, |
| | | DefaultBehaviorProvider<String> defaultBehavior) { |
| | | return new StringPropertyDefinition(d, propertyName, options, adminAction, defaultBehavior, |
| | | isCaseInsensitive, pattern, patternUsage); |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public String decodeValue(String value) throws IllegalPropertyValueStringException { |
| | | public String decodeValue(String value) { |
| | | Reject.ifNull(value); |
| | | |
| | | try { |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public String normalizeValue(String value) throws IllegalPropertyValueException { |
| | | public String normalizeValue(String value) { |
| | | Reject.ifNull(value); |
| | | |
| | | if (isCaseInsensitive()) { |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void validateValue(String value) throws IllegalPropertyValueException { |
| | | public void validateValue(String value) { |
| | | Reject.ifNull(value); |
| | | |
| | | if (pattern != null) { |
| | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.admin.meta.RootCfgDefn; |
| | | |
| | | |
| | | /** |
| | | * An interface for querying the properties of a tag. |
| | | * <p> |
| | |
| | | */ |
| | | public final class Tag implements Comparable<Tag> { |
| | | |
| | | // All the tags. |
| | | private static final Map<String, Tag> tags = new HashMap<String, Tag>(); |
| | | /** All the tags. */ |
| | | private static final Map<String, Tag> TAGS = new HashMap<String, Tag>(); |
| | | |
| | | /** |
| | | * Defines a new tag with the specified name. |
| | |
| | | Tag tag = new Tag(name); |
| | | |
| | | // Register the tag. |
| | | tags.put(name, tag); |
| | | TAGS.put(name, tag); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @throws IllegalArgumentException |
| | | * If the tag name was not recognized. |
| | | */ |
| | | public static Tag valueOf(String name) throws IllegalArgumentException { |
| | | public static Tag valueOf(String name) { |
| | | Reject.ifNull(name); |
| | | |
| | | // Hack to force initialization of the tag definitions. |
| | | RootCfgDefn.getInstance(); |
| | | |
| | | Tag tag = tags.get(name.toLowerCase()); |
| | | Tag tag = TAGS.get(name.toLowerCase()); |
| | | |
| | | if (tag == null) { |
| | | throw new IllegalArgumentException("Unknown tag \"" + name + "\""); |
| | |
| | | // Hack to force initialization of the tag definitions. |
| | | RootCfgDefn.getInstance(); |
| | | |
| | | return Collections.unmodifiableCollection(tags.values()); |
| | | return Collections.unmodifiableCollection(TAGS.values()); |
| | | } |
| | | |
| | | // The name of the tag. |
| | | /** The name of the tag. */ |
| | | private final String name; |
| | | |
| | | // Private constructor. |
| | | /** Private constructor. */ |
| | | private Tag(String name) { |
| | | this.name = name; |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public final int compareTo(Tag o) { |
| | | return name.compareTo(o.name); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final boolean equals(Object obj) { |
| | | if (this == obj) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final int hashCode() { |
| | | return name.hashCode(); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final String toString() { |
| | | return name; |
| | |
| | | */ |
| | | package org.opends.server.admin; |
| | | |
| | | |
| | | |
| | | /** |
| | | * A default behavior provider which indicates undefined behavior. It should |
| | | * be used by properties which have no default values or behavior as such. For |
| | | * A default behavior provider which indicates undefined behavior. It should be |
| | | * used by properties which have no default values or behavior as such. For |
| | | * example, a description property, when left unset, has no default value and no |
| | | * side-effects. |
| | | * |
| | | * @param <T> |
| | | * The type of values represented by this provider. |
| | | */ |
| | | public final class UndefinedDefaultBehaviorProvider<T> extends |
| | | DefaultBehaviorProvider<T> { |
| | | public final class UndefinedDefaultBehaviorProvider<T> extends DefaultBehaviorProvider<T> { |
| | | |
| | | /** |
| | | * Create an undefined default behavior provider. |
| | |
| | | // No implementation required. |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.server.admin; |
| | | |
| | | import static com.forgerock.opendj.ldap.AdminMessages.*; |
| | |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.server.admin.client; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.server.admin.client; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.server.admin.client; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | |
| | | * A list of messages to which error messages should be added. |
| | | * @return Returns <code>true</code> if this constraint is satisfied, or |
| | | * <code>false</code> if it is not. |
| | | * @throws AuthorizationException |
| | | * If an authorization failure prevented this constraint from |
| | | * being evaluated. |
| | | * @throws CommunicationException |
| | | * If a communications problem prevented this constraint from |
| | | * being evaluated. |
| | | * @throws ErrorResultException |
| | | * If an error occurs. |
| | | */ |
| | | public boolean isAddAcceptable(ManagementContext context, ManagedObject<?> managedObject, |
| | | Collection<LocalizableMessage> unacceptableReasons) throws ErrorResultException { |
| | |
| | | * A list of messages to which error messages should be added. |
| | | * @return Returns <code>true</code> if this modify is satisfied, or |
| | | * <code>false</code> if it is not. |
| | | * @throws AuthorizationException |
| | | * If an authorization failure prevented this constraint from |
| | | * being evaluated. |
| | | * @throws CommunicationException |
| | | * If a communications problem prevented this constraint from |
| | | * being evaluated. |
| | | * @throws ErrorResultException |
| | | * If an error occurs. |
| | | */ |
| | | public boolean isModifyAcceptable(ManagementContext context, ManagedObject<?> managedObject, |
| | | Collection<LocalizableMessage> unacceptableReasons) throws ErrorResultException { |
| | |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.server.admin.client; |
| | | |
| | | |
| | | |
| | | import static com.forgerock.opendj.ldap.AdminMessages.*; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.server.admin.OperationsException; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This exception is thrown when a critical concurrent modification is |
| | | * detected by the client. This may be caused by another client |
| | | * application removing a managed object whilst it is being managed. |
| | | * This exception is thrown when a critical concurrent modification is detected |
| | | * by the client. This may be caused by another client application removing a |
| | | * managed object whilst it is being managed. |
| | | */ |
| | | public class ConcurrentModificationException extends OperationsException { |
| | | |
| | |
| | | */ |
| | | private static final long serialVersionUID = -1467024486347612820L; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Create a concurrent modification exception with a default |
| | | * message. |
| | | * Create a concurrent modification exception with a default message. |
| | | */ |
| | | public ConcurrentModificationException() { |
| | | super(ERR_CONCURRENT_MODIFICATION_EXCEPTION_DEFAULT.get()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Create a concurrent modification exception with a cause and a |
| | | * default message. |
| | | * Create a concurrent modification exception with a cause and a default |
| | | * message. |
| | | * |
| | | * @param cause |
| | | * The cause. |
| | |
| | | super(ERR_CONCURRENT_MODIFICATION_EXCEPTION_DEFAULT.get(), cause); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Create a concurrent modification exception with a message and |
| | | * cause. |
| | | * Create a concurrent modification exception with a message and cause. |
| | | * |
| | | * @param message |
| | | * The message. |
| | |
| | | super(message, cause); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Create a concurrent modification exception with a message. |
| | | * |
| | |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.server.admin.client; |
| | | |
| | | |
| | | |
| | | import static com.forgerock.opendj.ldap.AdminMessages.*; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | |
| | | import org.opends.server.admin.PropertyDefinition; |
| | | import org.opends.server.admin.PropertyDefinitionUsageBuilder; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Thrown when an attempt is made to create a new managed object with |
| | | * an illegal name. |
| | | * Thrown when an attempt is made to create a new managed object with an illegal |
| | | * name. |
| | | * <p> |
| | | * This exception can occur when a new managed object is given a name |
| | | * which is either an empty string, a string containing just |
| | | * white-spaces, or a string which is invalid according to the managed |
| | | * object's naming property (if it has one). |
| | | * This exception can occur when a new managed object is given a name which is |
| | | * either an empty string, a string containing just white-spaces, or a string |
| | | * which is invalid according to the managed object's naming property (if it has |
| | | * one). |
| | | */ |
| | | public class IllegalManagedObjectNameException extends OperationsException { |
| | | |
| | |
| | | */ |
| | | private static final long serialVersionUID = 7491748228684293291L; |
| | | |
| | | |
| | | |
| | | // Create the message |
| | | private static LocalizableMessage createMessage(String illegalName, |
| | | PropertyDefinition<?> namingPropertyDefinition) { |
| | | /** Create the message. */ |
| | | // @Checkstyle:ignore |
| | | private static LocalizableMessage createMessage(String illegalName, PropertyDefinition<?> namingPropertyDefinition) { |
| | | if (illegalName.length() == 0) { |
| | | return ERR_ILLEGAL_MANAGED_OBJECT_NAME_EXCEPTION_EMPTY.get(); |
| | | } else if (illegalName.trim().length() == 0) { |
| | |
| | | try { |
| | | namingPropertyDefinition.decodeValue(illegalName); |
| | | } catch (IllegalPropertyValueStringException e) { |
| | | PropertyDefinitionUsageBuilder builder = |
| | | new PropertyDefinitionUsageBuilder(true); |
| | | return ERR_ILLEGAL_MANAGED_OBJECT_NAME_EXCEPTION_SYNTAX.get( |
| | | illegalName, namingPropertyDefinition.getName(), builder |
| | | .getUsage(namingPropertyDefinition)); |
| | | PropertyDefinitionUsageBuilder builder = new PropertyDefinitionUsageBuilder(true); |
| | | return ERR_ILLEGAL_MANAGED_OBJECT_NAME_EXCEPTION_SYNTAX.get(illegalName, |
| | | namingPropertyDefinition.getName(), builder.getUsage(namingPropertyDefinition)); |
| | | } |
| | | } |
| | | |
| | | return ERR_ILLEGAL_MANAGED_OBJECT_NAME_EXCEPTION_OTHER.get(illegalName); |
| | | } |
| | | |
| | | // The illegal name. |
| | | /** The illegal name. */ |
| | | private final String illegalName; |
| | | |
| | | // The naming property definition if applicable. |
| | | /** The naming property definition if applicable. */ |
| | | private final PropertyDefinition<?> namingPropertyDefinition; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Create a new illegal name exception and no naming property |
| | | * definition. |
| | | * Create a new illegal name exception and no naming property definition. |
| | | * |
| | | * @param illegalName |
| | | * The illegal managed object name. |
| | |
| | | this(illegalName, null); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Create a new illegal name exception and a naming property |
| | | * definition. |
| | | * Create a new illegal name exception and a naming property definition. |
| | | * |
| | | * @param illegalName |
| | | * The illegal managed object name. |
| | | * @param namingPropertyDefinition |
| | | * The naming property definition. |
| | | */ |
| | | public IllegalManagedObjectNameException(String illegalName, |
| | | PropertyDefinition<?> namingPropertyDefinition) { |
| | | public IllegalManagedObjectNameException(String illegalName, PropertyDefinition<?> namingPropertyDefinition) { |
| | | super(createMessage(illegalName, namingPropertyDefinition)); |
| | | |
| | | this.illegalName = illegalName; |
| | | this.namingPropertyDefinition = namingPropertyDefinition; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Get the illegal managed object name. |
| | | * |
| | |
| | | return illegalName; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Get the naming property definition if applicable. |
| | | * |
| | | * @return Returns naming property definition, or <code>null</code> |
| | | * if none was specified. |
| | | * @return Returns naming property definition, or <code>null</code> if none |
| | | * was specified. |
| | | */ |
| | | public PropertyDefinition<?> getNamingPropertyDefinition() { |
| | | return namingPropertyDefinition; |
| | |
| | | import org.opends.server.admin.Configuration; |
| | | import org.opends.server.admin.DefaultBehaviorException; |
| | | import org.opends.server.admin.DefinitionDecodingException; |
| | | import org.opends.server.admin.IllegalPropertyValueException; |
| | | import org.opends.server.admin.InstantiableRelationDefinition; |
| | | import org.opends.server.admin.ManagedObjectAlreadyExistsException; |
| | | import org.opends.server.admin.ManagedObjectDefinition; |
| | |
| | | * @param <S> |
| | | * The expected type of the child managed object server |
| | | * configuration. |
| | | * @param <CC> |
| | | * @param <C1> |
| | | * The actual type of the added managed object configuration |
| | | * client. |
| | | * @param r |
| | |
| | | * If the relation definition is not associated with this |
| | | * managed object's definition. |
| | | */ |
| | | <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; |
| | | <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; |
| | | |
| | | /** |
| | | * Creates a new child managed object bound to the specified optional |
| | |
| | | * @param <S> |
| | | * The expected type of the child managed object server |
| | | * configuration. |
| | | * @param <CC> |
| | | * @param <C1> |
| | | * The actual type of the added managed object configuration |
| | | * client. |
| | | * @param r |
| | |
| | | * If the relation definition is not associated with this |
| | | * managed object's definition. |
| | | */ |
| | | <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; |
| | | <C extends ConfigurationClient, S extends Configuration, C1 extends C> ManagedObject<C1> createChild( |
| | | OptionalRelationDefinition<C, S> r, ManagedObjectDefinition<C1, ? extends S> d, |
| | | Collection<DefaultBehaviorException> exceptions); |
| | | |
| | | /** |
| | | * Creates a new child managed object bound to the specified set relation. |
| | |
| | | * @param <S> |
| | | * The expected type of the child managed object server |
| | | * configuration. |
| | | * @param <CC> |
| | | * @param <C1> |
| | | * The actual type of the added managed object configuration |
| | | * client. |
| | | * @param r |
| | |
| | | * If the relation definition is not associated with this |
| | | * managed object's definition. |
| | | */ |
| | | <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; |
| | | <C extends ConfigurationClient, S extends Configuration, C1 extends C> ManagedObject<C1> createChild( |
| | | SetRelationDefinition<C, S> r, ManagedObjectDefinition<C1, ? extends S> d, |
| | | Collection<DefaultBehaviorException> exceptions); |
| | | |
| | | /** |
| | | * Retrieves an instantiable child managed object. |
| | |
| | | * If any other error occurs. |
| | | */ |
| | | <C extends ConfigurationClient, S extends Configuration> ManagedObject<? extends C> getChild( |
| | | InstantiableRelationDefinition<C, S> r, String name) throws IllegalArgumentException, |
| | | InstantiableRelationDefinition<C, S> r, String name) throws |
| | | DefinitionDecodingException, ManagedObjectDecodingException, ManagedObjectNotFoundException, |
| | | ConcurrentModificationException, ErrorResultException; |
| | | |
| | |
| | | * If any other error occurs. |
| | | */ |
| | | <C extends ConfigurationClient, S extends Configuration> ManagedObject<? extends C> getChild( |
| | | OptionalRelationDefinition<C, S> r) throws IllegalArgumentException, DefinitionDecodingException, |
| | | OptionalRelationDefinition<C, S> r) throws DefinitionDecodingException, |
| | | ManagedObjectDecodingException, ManagedObjectNotFoundException, ConcurrentModificationException, |
| | | ErrorResultException; |
| | | |
| | |
| | | * If any other error occurs. |
| | | */ |
| | | <C extends ConfigurationClient, S extends Configuration> ManagedObject<? extends C> getChild( |
| | | SingletonRelationDefinition<C, S> r) throws IllegalArgumentException, DefinitionDecodingException, |
| | | SingletonRelationDefinition<C, S> r) throws DefinitionDecodingException, |
| | | ManagedObjectDecodingException, ManagedObjectNotFoundException, ConcurrentModificationException, |
| | | ErrorResultException; |
| | | |
| | |
| | | * If any other error occurs. |
| | | */ |
| | | <C extends ConfigurationClient, S extends Configuration> ManagedObject<? extends C> getChild( |
| | | SetRelationDefinition<C, S> r, String name) throws IllegalArgumentException, DefinitionDecodingException, |
| | | SetRelationDefinition<C, S> r, String name) throws DefinitionDecodingException, |
| | | ManagedObjectDecodingException, ManagedObjectNotFoundException, ConcurrentModificationException, |
| | | ErrorResultException; |
| | | |
| | |
| | | * Gets a mutable copy of the set of default values for the specified |
| | | * property. |
| | | * |
| | | * @param <PD> |
| | | * @param <P> |
| | | * The type of the property to be retrieved. |
| | | * @param pd |
| | | * The property to be retrieved. |
| | |
| | | * If the property definition is not associated with this |
| | | * managed object's definition. |
| | | */ |
| | | <PD> SortedSet<PD> getPropertyDefaultValues(PropertyDefinition<PD> pd) throws IllegalArgumentException; |
| | | <P> SortedSet<P> getPropertyDefaultValues(PropertyDefinition<P> pd); |
| | | |
| | | /** |
| | | * Gets the effective value of the specified property. |
| | |
| | | * See the class description for more information about how the effective |
| | | * property value is derived. |
| | | * |
| | | * @param <PD> |
| | | * @param <P> |
| | | * The type of the property to be retrieved. |
| | | * @param pd |
| | | * The property to be retrieved. |
| | |
| | | * If the property definition is not associated with this |
| | | * managed object's definition. |
| | | */ |
| | | <PD> PD getPropertyValue(PropertyDefinition<PD> pd) throws IllegalArgumentException; |
| | | <P> P getPropertyValue(PropertyDefinition<P> pd); |
| | | |
| | | /** |
| | | * Gets a mutable copy of the set of effective values for the specified |
| | |
| | | * See the class description for more information about how the effective |
| | | * property values are derived. |
| | | * |
| | | * @param <PD> |
| | | * @param <P> |
| | | * The type of the property to be retrieved. |
| | | * @param pd |
| | | * The property to be retrieved. |
| | |
| | | * If the property definition is not associated with this |
| | | * managed object's definition. |
| | | */ |
| | | <PD> SortedSet<PD> getPropertyValues(PropertyDefinition<PD> pd) throws IllegalArgumentException; |
| | | @Override |
| | | <P> SortedSet<P> getPropertyValues(PropertyDefinition<P> pd); |
| | | |
| | | /** |
| | | * Determines whether or not the specified property is set. If the property |
| | |
| | | * If the property definition is not associated with this |
| | | * managed object's definition. |
| | | */ |
| | | boolean isPropertyPresent(PropertyDefinition<?> pd) throws IllegalArgumentException; |
| | | boolean isPropertyPresent(PropertyDefinition<?> pd); |
| | | |
| | | /** |
| | | * Determines whether or not the optional managed object associated with the |
| | |
| | | * The optional relation definition. |
| | | * @return Returns <code>true</code> if the optional managed object exists, |
| | | * <code>false</code> otherwise. |
| | | * @throws IllegalArgumentException |
| | | * If the relation definition is not associated with this |
| | | * managed object's definition. |
| | | * @throws ConcurrentModificationException |
| | | * If this managed object has been removed from the server by |
| | | * another client. |
| | |
| | | * If there is any other error. |
| | | */ |
| | | <C extends ConfigurationClient, S extends Configuration> boolean hasChild(OptionalRelationDefinition<C, S> r) |
| | | throws IllegalArgumentException, ConcurrentModificationException, ErrorResultException; |
| | | throws ConcurrentModificationException, ErrorResultException; |
| | | |
| | | /** |
| | | * Lists the child managed objects associated with the specified |
| | |
| | | * If any other error occurs. |
| | | */ |
| | | <C extends ConfigurationClient, S extends Configuration> String[] listChildren( |
| | | InstantiableRelationDefinition<C, S> r) throws IllegalArgumentException, ConcurrentModificationException, |
| | | InstantiableRelationDefinition<C, S> r) throws ConcurrentModificationException, |
| | | ErrorResultException; |
| | | |
| | | /** |
| | |
| | | * The managed object definition. |
| | | * @return Returns the names of the child managed objects which are a |
| | | * sub-type of the specified managed object definition. |
| | | * @throws IllegalArgumentException |
| | | * If the relation definition is not associated with this |
| | | * managed object's definition. |
| | | * @throws ConcurrentModificationException |
| | | * If this managed object has been removed from the server by |
| | | * another client. |
| | |
| | | */ |
| | | <C extends ConfigurationClient, S extends Configuration> String[] listChildren( |
| | | InstantiableRelationDefinition<C, S> r, AbstractManagedObjectDefinition<? extends C, ? extends S> d) |
| | | throws IllegalArgumentException, ConcurrentModificationException, ErrorResultException; |
| | | throws ConcurrentModificationException, ErrorResultException; |
| | | |
| | | /** |
| | | * Lists the child managed objects associated with the specified set |
| | |
| | | * The set relation definition. |
| | | * @return Returns the names of the child managed objects which for set |
| | | * relations are the definition names of each managed object. |
| | | * @throws IllegalArgumentException |
| | | * If the relation definition is not associated with this |
| | | * managed object's definition. |
| | | * @throws ConcurrentModificationException |
| | | * If this managed object has been removed from the server by |
| | | * another client. |
| | |
| | | * If any other error occurs. |
| | | */ |
| | | <C extends ConfigurationClient, S extends Configuration> String[] listChildren(SetRelationDefinition<C, S> r) |
| | | throws IllegalArgumentException, ConcurrentModificationException, ErrorResultException; |
| | | throws ConcurrentModificationException, ErrorResultException; |
| | | |
| | | /** |
| | | * Lists the child managed objects associated with the specified set |
| | |
| | | * If any other error occurs. |
| | | */ |
| | | <C extends ConfigurationClient, S extends Configuration> String[] listChildren(SetRelationDefinition<C, S> r, |
| | | AbstractManagedObjectDefinition<? extends C, ? extends S> d) throws IllegalArgumentException, |
| | | AbstractManagedObjectDefinition<? extends C, ? extends S> d) throws |
| | | ConcurrentModificationException, ErrorResultException; |
| | | |
| | | /** |
| | |
| | | * If any other error occurs. |
| | | */ |
| | | <C extends ConfigurationClient, S extends Configuration> void removeChild(InstantiableRelationDefinition<C, S> r, |
| | | String name) throws IllegalArgumentException, ManagedObjectNotFoundException, OperationRejectedException, |
| | | String name) throws ManagedObjectNotFoundException, OperationRejectedException, |
| | | ConcurrentModificationException, ErrorResultException; |
| | | |
| | | /** |
| | |
| | | * relation definition refers to. |
| | | * @param r |
| | | * The optional relation definition. |
| | | * @throws IllegalArgumentException |
| | | * If the relation definition is not associated with this |
| | | * managed object's definition. |
| | | * @throws ManagedObjectNotFoundException |
| | | * If the managed object could not be removed because it could |
| | | * not found on the server. |
| | |
| | | * If any other error occurs. |
| | | */ |
| | | <C extends ConfigurationClient, S extends Configuration> void removeChild(OptionalRelationDefinition<C, S> r) |
| | | throws IllegalArgumentException, ManagedObjectNotFoundException, OperationRejectedException, |
| | | throws ManagedObjectNotFoundException, OperationRejectedException, |
| | | ConcurrentModificationException, ErrorResultException; |
| | | |
| | | /** |
| | |
| | | * The set relation definition. |
| | | * @param name |
| | | * The name of the child managed object to be removed. |
| | | * @throws IllegalArgumentException |
| | | * If the relation definition is not associated with this |
| | | * managed object's definition. |
| | | * @throws ManagedObjectNotFoundException |
| | | * If the managed object could not be removed because it could |
| | | * not found on the server. |
| | |
| | | * @throws ErrorResultException |
| | | * If any other error occurs. |
| | | */ |
| | | <C extends ConfigurationClient, S extends Configuration> void removeChild(SetRelationDefinition<C, S> r, String name) |
| | | throws IllegalArgumentException, ManagedObjectNotFoundException, OperationRejectedException, |
| | | <C extends ConfigurationClient, S extends Configuration> void removeChild(SetRelationDefinition<C, S> r, |
| | | String name) throws ManagedObjectNotFoundException, OperationRejectedException, |
| | | ConcurrentModificationException, ErrorResultException; |
| | | |
| | | /** |
| | |
| | | * <p> |
| | | * See the class description for more information regarding pending values. |
| | | * |
| | | * @param <PD> |
| | | * @param <P> |
| | | * The type of the property to be modified. |
| | | * @param pd |
| | | * The property to be modified. |
| | | * @param value |
| | | * The new pending value for the property, or <code>null</code> |
| | | * if the property should be reset to its default behavior. |
| | | * @throws IllegalPropertyValueException |
| | | * If the new pending value is deemed to be invalid according to |
| | | * the property definition. |
| | | * @throws PropertyIsReadOnlyException |
| | | * If this is not a new managed object and the property is |
| | | * read-only or for monitoring purposes. |
| | | * @throws PropertyIsMandatoryException |
| | | * If an attempt was made to remove a mandatory property. |
| | | * @throws IllegalArgumentException |
| | | * If the specified property definition is not associated with |
| | | * this managed object. |
| | | */ |
| | | <PD> void setPropertyValue(PropertyDefinition<PD> pd, PD value) throws IllegalPropertyValueException, |
| | | PropertyIsReadOnlyException, PropertyIsMandatoryException, IllegalArgumentException; |
| | | <P> void setPropertyValue(PropertyDefinition<P> pd, P value); |
| | | |
| | | /** |
| | | * Sets a new pending values for the specified property. |
| | | * <p> |
| | | * See the class description for more information regarding pending values. |
| | | * |
| | | * @param <PD> |
| | | * @param <P> |
| | | * The type of the property to be modified. |
| | | * @param pd |
| | | * The property to be modified. |
| | |
| | | * property (an empty set indicates that the property should be |
| | | * reset to its default behavior). The set will not be referenced |
| | | * by this managed object. |
| | | * @throws IllegalPropertyValueException |
| | | * If a new pending value is deemed to be invalid according to |
| | | * the property definition. |
| | | * @throws PropertyIsSingleValuedException |
| | | * If an attempt was made to add multiple pending values to a |
| | | * single-valued property. |
| | |
| | | * read-only or for monitoring purposes. |
| | | * @throws PropertyIsMandatoryException |
| | | * If an attempt was made to remove a mandatory property. |
| | | * @throws IllegalArgumentException |
| | | * If the specified property definition is not associated with |
| | | * this managed object. |
| | | */ |
| | | <PD> void setPropertyValues(PropertyDefinition<PD> pd, Collection<PD> values) throws IllegalPropertyValueException, |
| | | PropertyIsSingleValuedException, PropertyIsReadOnlyException, PropertyIsMandatoryException, |
| | | IllegalArgumentException; |
| | | <P> void setPropertyValues(PropertyDefinition<P> pd, Collection<P> values); |
| | | |
| | | } |
| | |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.server.admin.client; |
| | | |
| | | |
| | | |
| | | import static com.forgerock.opendj.ldap.AdminMessages.*; |
| | | |
| | | import java.util.Collection; |
| | |
| | | import org.opends.server.admin.ManagedObjectDefinition; |
| | | import org.opends.server.admin.PropertyException; |
| | | |
| | | |
| | | |
| | | /** |
| | | * The requested managed object was found but one or more of its |
| | | * properties could not be decoded successfully. |
| | | * The requested managed object was found but one or more of its properties |
| | | * could not be decoded successfully. |
| | | */ |
| | | public class ManagedObjectDecodingException extends DecodingException { |
| | | |
| | |
| | | */ |
| | | private static final long serialVersionUID = -4268510652395945357L; |
| | | |
| | | |
| | | |
| | | // Create the message. |
| | | private static LocalizableMessage createMessage(ManagedObject<?> partialManagedObject, |
| | | Collection<PropertyException> causes) { |
| | | Reject.ifNull(causes); |
| | | Reject.ifFalse(!causes.isEmpty(), "causes should not be empty"); |
| | | |
| | | ManagedObjectDefinition<?, ?> d = partialManagedObject |
| | | .getManagedObjectDefinition(); |
| | | ManagedObjectDefinition<?, ?> d = partialManagedObject.getManagedObjectDefinition(); |
| | | if (causes.size() == 1) { |
| | | return ERR_MANAGED_OBJECT_DECODING_EXCEPTION_SINGLE.get(d |
| | | .getUserFriendlyName(), causes.iterator().next().getLocalizableMessageObject()); |
| | | return ERR_MANAGED_OBJECT_DECODING_EXCEPTION_SINGLE.get(d.getUserFriendlyName(), causes.iterator().next() |
| | | .getLocalizableMessageObject()); |
| | | } else { |
| | | LocalizableMessageBuilder builder = new LocalizableMessageBuilder(); |
| | | |
| | |
| | | isFirst = false; |
| | | } |
| | | |
| | | return ERR_MANAGED_OBJECT_DECODING_EXCEPTION_PLURAL.get(d |
| | | .getUserFriendlyName(), builder.toMessage()); |
| | | return ERR_MANAGED_OBJECT_DECODING_EXCEPTION_PLURAL.get(d.getUserFriendlyName(), builder.toMessage()); |
| | | } |
| | | } |
| | | |
| | |
| | | // The partially created managed object. |
| | | private final ManagedObject<?> partialManagedObject; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Create a new property decoding exception. |
| | | * |
| | | * @param partialManagedObject |
| | | * The partially created managed object containing |
| | | * properties which were successfully decoded and empty |
| | | * properties for those which were not (this may include |
| | | * empty mandatory properties). |
| | | * The partially created managed object containing properties |
| | | * which were successfully decoded and empty properties for those |
| | | * which were not (this may include empty mandatory properties). |
| | | * @param causes |
| | | * The exception(s) that caused this decoding exception. |
| | | */ |
| | | public ManagedObjectDecodingException(ManagedObject<?> partialManagedObject, |
| | | Collection<PropertyException> causes) { |
| | | public ManagedObjectDecodingException(ManagedObject<?> partialManagedObject, Collection<PropertyException> causes) { |
| | | super(createMessage(partialManagedObject, causes)); |
| | | |
| | | this.partialManagedObject = partialManagedObject; |
| | | this.causes = Collections |
| | | .unmodifiableList(new LinkedList<PropertyException>(causes)); |
| | | this.causes = Collections.unmodifiableList(new LinkedList<PropertyException>(causes)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Get an unmodifiable collection view of the causes of this |
| | | * exception. |
| | | * Get an unmodifiable collection view of the causes of this exception. |
| | | * |
| | | * @return Returns an unmodifiable collection view of the causes of |
| | | * this exception. |
| | | * @return Returns an unmodifiable collection view of the causes of this |
| | | * exception. |
| | | */ |
| | | public Collection<PropertyException> getCauses() { |
| | | return causes; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Get the partially created managed object containing properties |
| | | * which were successfully decoded and empty properties for those |
| | | * which were not (this may include empty mandatory properties). |
| | | * Get the partially created managed object containing properties which were |
| | | * successfully decoded and empty properties for those which were not (this |
| | | * may include empty mandatory properties). |
| | | * |
| | | * @return Returns the partially created managed object containing |
| | | * properties which were successfully decoded and empty |
| | | * properties for those which were not (this may include |
| | | * empty mandatory properties). |
| | | * properties which were successfully decoded and empty properties |
| | | * for those which were not (this may include empty mandatory |
| | | * properties). |
| | | */ |
| | | public ManagedObject<?> getPartialManagedObject() { |
| | | return partialManagedObject; |
| | |
| | | */ |
| | | public final <C extends ConfigurationClient, S extends Configuration> boolean deleteManagedObject( |
| | | ManagedObjectPath<?, ?> parent, InstantiableRelationDefinition<C, S> rd, String name) |
| | | throws IllegalArgumentException, ManagedObjectNotFoundException, OperationRejectedException, |
| | | throws ManagedObjectNotFoundException, OperationRejectedException, |
| | | ErrorResultException { |
| | | return getDriver().deleteManagedObject(parent, rd, name); |
| | | } |
| | |
| | | * If any other error occurs. |
| | | */ |
| | | public final <C extends ConfigurationClient, S extends Configuration> boolean deleteManagedObject( |
| | | ManagedObjectPath<?, ?> parent, OptionalRelationDefinition<C, S> rd) throws IllegalArgumentException, |
| | | ManagedObjectPath<?, ?> parent, OptionalRelationDefinition<C, S> rd) throws |
| | | ManagedObjectNotFoundException, OperationRejectedException, ErrorResultException { |
| | | return getDriver().deleteManagedObject(parent, rd); |
| | | } |
| | |
| | | */ |
| | | public final <C extends ConfigurationClient, S extends Configuration> boolean deleteManagedObject( |
| | | ManagedObjectPath<?, ?> parent, SetRelationDefinition<C, S> rd, String name) |
| | | throws IllegalArgumentException, ManagedObjectNotFoundException, OperationRejectedException, |
| | | throws ManagedObjectNotFoundException, OperationRejectedException, |
| | | ErrorResultException { |
| | | return getDriver().deleteManagedObject(parent, rd, name); |
| | | } |
| | |
| | | /** |
| | | * Gets the effective value of a property in the named managed object. |
| | | * |
| | | * @param <PD> |
| | | * @param <P> |
| | | * The type of the property to be retrieved. |
| | | * @param path |
| | | * The path of the managed object containing the property. |
| | |
| | | * @throws ErrorResultException |
| | | * If any other error occurs. |
| | | */ |
| | | public final <PD> PD getPropertyValue(ManagedObjectPath<?, ?> path, PropertyDefinition<PD> pd) |
| | | throws IllegalArgumentException, DefinitionDecodingException, ErrorResultException, |
| | | ManagedObjectNotFoundException, PropertyException { |
| | | Set<PD> values = getPropertyValues(path, pd); |
| | | public final <P> P getPropertyValue(ManagedObjectPath<?, ?> path, PropertyDefinition<P> pd) |
| | | throws DefinitionDecodingException, ErrorResultException, ManagedObjectNotFoundException { |
| | | Set<P> values = getPropertyValues(path, pd); |
| | | if (values.isEmpty()) { |
| | | return null; |
| | | } else { |
| | |
| | | /** |
| | | * Gets the effective values of a property in the named managed object. |
| | | * |
| | | * @param <PD> |
| | | * @param <P> |
| | | * The type of the property to be retrieved. |
| | | * @param path |
| | | * The path of the managed object containing the property. |
| | |
| | | * @throws ErrorResultException |
| | | * If any other error occurs. |
| | | */ |
| | | public final <PD> SortedSet<PD> getPropertyValues(ManagedObjectPath<?, ?> path, PropertyDefinition<PD> pd) |
| | | throws IllegalArgumentException, DefinitionDecodingException, ErrorResultException, |
| | | ManagedObjectNotFoundException, PropertyException { |
| | | public final <P> SortedSet<P> getPropertyValues(ManagedObjectPath<?, ?> path, PropertyDefinition<P> pd) |
| | | throws DefinitionDecodingException, ErrorResultException, ManagedObjectNotFoundException { |
| | | return getDriver().getPropertyValues(path, pd); |
| | | } |
| | | |
| | |
| | | * If any other error occurs. |
| | | */ |
| | | public final <C extends ConfigurationClient, S extends Configuration> String[] listManagedObjects( |
| | | ManagedObjectPath<?, ?> parent, InstantiableRelationDefinition<C, S> rd) throws IllegalArgumentException, |
| | | ManagedObjectPath<?, ?> parent, InstantiableRelationDefinition<C, S> rd) throws |
| | | ManagedObjectNotFoundException, ErrorResultException { |
| | | return listManagedObjects(parent, rd, rd.getChildDefinition()); |
| | | } |
| | |
| | | */ |
| | | public final <C extends ConfigurationClient, S extends Configuration> String[] listManagedObjects( |
| | | ManagedObjectPath<?, ?> parent, InstantiableRelationDefinition<C, S> rd, |
| | | AbstractManagedObjectDefinition<? extends C, ? extends S> d) throws IllegalArgumentException, |
| | | AbstractManagedObjectDefinition<? extends C, ? extends S> d) throws |
| | | ManagedObjectNotFoundException, ErrorResultException { |
| | | return getDriver().listManagedObjects(parent, rd, d); |
| | | } |
| | |
| | | * If any other error occurs. |
| | | */ |
| | | public final <C extends ConfigurationClient, S extends Configuration> String[] listManagedObjects( |
| | | ManagedObjectPath<?, ?> parent, SetRelationDefinition<C, S> rd) throws IllegalArgumentException, |
| | | ManagedObjectPath<?, ?> parent, SetRelationDefinition<C, S> rd) throws |
| | | ManagedObjectNotFoundException, ErrorResultException { |
| | | return getDriver().listManagedObjects(parent, rd, rd.getChildDefinition()); |
| | | } |
| | |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.server.admin.client; |
| | | |
| | | |
| | | |
| | | import static com.forgerock.opendj.ldap.AdminMessages.*; |
| | | |
| | | import java.util.ArrayList; |
| | |
| | | import org.opends.server.admin.OperationsException; |
| | | import org.opends.server.admin.PropertyIsMandatoryException; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This exception is thrown when an attempt is made to add or modify a |
| | | * managed object when one or more of its mandatory properties are |
| | | * undefined. |
| | | * This exception is thrown when an attempt is made to add or modify a managed |
| | | * object when one or more of its mandatory properties are undefined. |
| | | */ |
| | | public class MissingMandatoryPropertiesException extends OperationsException { |
| | | |
| | |
| | | */ |
| | | private static final long serialVersionUID = 6342522125252055588L; |
| | | |
| | | |
| | | |
| | | // Create the message. |
| | | private static LocalizableMessage createMessage( |
| | | Collection<PropertyIsMandatoryException> causes) { |
| | | private static LocalizableMessage createMessage(Collection<PropertyIsMandatoryException> causes) { |
| | | Reject.ifNull(causes); |
| | | Reject.ifFalse(!causes.isEmpty(), "causes should not be empty"); |
| | | |
| | | if (causes.size() == 1) { |
| | | return ERR_MISSING_MANDATORY_PROPERTIES_EXCEPTION_SINGLE.get(causes |
| | | .iterator().next().getPropertyDefinition().getName()); |
| | | return ERR_MISSING_MANDATORY_PROPERTIES_EXCEPTION_SINGLE.get(causes.iterator().next() |
| | | .getPropertyDefinition().getName()); |
| | | } else { |
| | | LocalizableMessageBuilder builder = new LocalizableMessageBuilder(); |
| | | |
| | |
| | | isFirst = false; |
| | | } |
| | | |
| | | return ERR_MISSING_MANDATORY_PROPERTIES_EXCEPTION_PLURAL.get(builder |
| | | .toMessage()); |
| | | return ERR_MISSING_MANDATORY_PROPERTIES_EXCEPTION_PLURAL.get(builder.toMessage()); |
| | | } |
| | | } |
| | | |
| | |
| | | // exception. |
| | | private final LocalizableMessage ufn; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Creates a new missing mandatory properties exception with the |
| | | * provided causes. |
| | | * Creates a new missing mandatory properties exception with the provided |
| | | * causes. |
| | | * |
| | | * @param ufn |
| | | * The user friendly name of the component that caused this |
| | |
| | | * The causes of this exception (must be non-<code>null</code> |
| | | * and non-empty). |
| | | * @param isCreate |
| | | * Indicates whether the exception occurred during managed |
| | | * object creation. |
| | | * Indicates whether the exception occurred during managed object |
| | | * creation. |
| | | */ |
| | | public MissingMandatoryPropertiesException(LocalizableMessage ufn, |
| | | Collection<PropertyIsMandatoryException> causes, boolean isCreate) { |
| | |
| | | this.isCreate = isCreate; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Gets the first exception that caused this exception. |
| | | * |
| | |
| | | return causes.iterator().next(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Gets an unmodifiable collection view of the causes of this |
| | | * exception. |
| | | * Gets an unmodifiable collection view of the causes of this exception. |
| | | * |
| | | * @return Returns an unmodifiable collection view of the causes of |
| | | * this exception. |
| | | * @return Returns an unmodifiable collection view of the causes of this |
| | | * exception. |
| | | */ |
| | | public Collection<PropertyIsMandatoryException> getCauses() { |
| | | return Collections.unmodifiableCollection(causes); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Gets the user friendly name of the component that caused this |
| | | * exception. |
| | | * Gets the user friendly name of the component that caused this exception. |
| | | * |
| | | * @return Returns the user friendly name of the component that |
| | | * caused this exception. |
| | | * @return Returns the user friendly name of the component that caused this |
| | | * exception. |
| | | */ |
| | | public LocalizableMessage getUserFriendlyName() { |
| | | return ufn; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Indicates whether or not this exception was thrown during managed |
| | | * object creation or during modification. |
| | | * Indicates whether or not this exception was thrown during managed object |
| | | * creation or during modification. |
| | | * |
| | | * @return Returns <code>true</code> if this exception was thrown |
| | | * during managed object creation. |
| | | * @return Returns <code>true</code> if this exception was thrown during |
| | | * managed object creation. |
| | | */ |
| | | public boolean isCreate() { |
| | | return isCreate; |
| | |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.server.admin.client; |
| | | |
| | | import static com.forgerock.opendj.ldap.AdminMessages.*; |
| | |
| | | * The messages describing the constraint violations that |
| | | * occurred (must be non-<code>null</code> and non-empty). |
| | | */ |
| | | public OperationRejectedException(OperationType type, LocalizableMessage ufn, Collection<LocalizableMessage> messages) { |
| | | public OperationRejectedException(OperationType type, LocalizableMessage ufn, |
| | | Collection<LocalizableMessage> messages) { |
| | | super(getDefaultMessage(messages)); |
| | | |
| | | this.messages = new ArrayList<LocalizableMessage>(messages); |
| | |
| | | import org.opends.server.admin.Reference; |
| | | import org.opends.server.admin.RelationDefinition; |
| | | import org.opends.server.admin.SetRelationDefinition; |
| | | import org.opends.server.admin.UnknownPropertyDefinitionException; |
| | | import org.opends.server.admin.DefinitionDecodingException.Reason; |
| | | import org.opends.server.admin.client.ManagedObject; |
| | | import org.opends.server.admin.client.ManagedObjectDecodingException; |
| | |
| | | /** |
| | | * Decodes the provided property LDAP value. |
| | | * |
| | | * @param <PD> |
| | | * @param <P> |
| | | * The type of the property. |
| | | * @param pd |
| | | * The property definition. |
| | |
| | | * If the property value could not be decoded because it was |
| | | * invalid. |
| | | */ |
| | | public static <PD> PD decode(PropertyDefinition<PD> pd, Object value) |
| | | throws IllegalPropertyValueStringException { |
| | | public static <P> P decode(PropertyDefinition<P> pd, Object value) { |
| | | String s = String.valueOf(value); |
| | | return pd.castValue(pd.accept(new ValueDecoder(), s)); |
| | | } |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public <T> Object visitUnknown(PropertyDefinition<T> d, String p) throws UnknownPropertyDefinitionException { |
| | | public <T> Object visitUnknown(PropertyDefinition<T> d, String p) { |
| | | // By default the property definition's decoder will do. |
| | | return d.decodeValue(p); |
| | | } |
| | |
| | | */ |
| | | @SuppressWarnings("unchecked") |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration, PD> SortedSet<PD> getPropertyValues( |
| | | ManagedObjectPath<C, S> path, PropertyDefinition<PD> propertyDef) throws IllegalArgumentException, |
| | | DefinitionDecodingException, ManagedObjectNotFoundException, ErrorResultException, PropertyException { |
| | | public <C extends ConfigurationClient, S extends Configuration, P> SortedSet<P> getPropertyValues( |
| | | ManagedObjectPath<C, S> path, PropertyDefinition<P> propertyDef) throws DefinitionDecodingException, |
| | | ManagedObjectNotFoundException, ErrorResultException { |
| | | // Check that the requested property is from the definition |
| | | // associated with the path. |
| | | AbstractManagedObjectDefinition<C, S> d = path.getManagedObjectDefinition(); |
| | |
| | | // Make sure we use the correct property definition, the |
| | | // provided one might have been overridden in the resolved |
| | | // definition. |
| | | propertyDef = (PropertyDefinition<PD>) objectDef.getPropertyDefinition(propertyDef.getName()); |
| | | propertyDef = (PropertyDefinition<P>) objectDef.getPropertyDefinition(propertyDef.getName()); |
| | | |
| | | String attrID = profile.getAttributeName(objectDef, propertyDef); |
| | | SearchResultEntry resultEntry = connection.readEntry(dn, Collections.singleton(attrID)); |
| | | Attribute attribute = resultEntry.getAttribute(attrID); |
| | | |
| | | // Decode the values. |
| | | SortedSet<PD> values = new TreeSet<PD>(propertyDef); |
| | | SortedSet<P> values = new TreeSet<P>(propertyDef); |
| | | if (attribute != null) { |
| | | for (ByteString byteValue : attribute) { |
| | | PD value = ValueDecoder.decode(propertyDef, byteValue); |
| | | P value = ValueDecoder.decode(propertyDef, byteValue); |
| | | values.add(value); |
| | | } |
| | | } |
| | |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> String[] listManagedObjects( |
| | | ManagedObjectPath<?, ?> parent, InstantiableRelationDefinition<C, S> rd, |
| | | AbstractManagedObjectDefinition<? extends C, ? extends S> d) throws IllegalArgumentException, |
| | | ManagedObjectNotFoundException, ErrorResultException { |
| | | AbstractManagedObjectDefinition<? extends C, ? extends S> d) throws ManagedObjectNotFoundException, |
| | | ErrorResultException { |
| | | validateRelationDefinition(parent, rd); |
| | | |
| | | if (!managedObjectExists(parent)) { |
| | |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> String[] listManagedObjects( |
| | | ManagedObjectPath<?, ?> parent, SetRelationDefinition<C, S> rd, |
| | | AbstractManagedObjectDefinition<? extends C, ? extends S> d) throws IllegalArgumentException, |
| | | ManagedObjectNotFoundException, ErrorResultException { |
| | | AbstractManagedObjectDefinition<? extends C, ? extends S> d) throws ManagedObjectNotFoundException, |
| | | ErrorResultException { |
| | | validateRelationDefinition(parent, rd); |
| | | |
| | | if (!managedObjectExists(parent)) { |
| | |
| | | } |
| | | |
| | | // Create a property using the provided string values. |
| | | private <PD> void decodeProperty(PropertySet newProperties, ManagedObjectPath<?, ?> path, |
| | | PropertyDefinition<PD> propertyDef, Attribute attribute) throws PropertyException { |
| | | private <P> void decodeProperty(PropertySet newProperties, ManagedObjectPath<?, ?> path, |
| | | PropertyDefinition<P> propertyDef, Attribute attribute) { |
| | | PropertyException exception = null; |
| | | |
| | | // Get the property's active values. |
| | | SortedSet<PD> activeValues = new TreeSet<PD>(propertyDef); |
| | | SortedSet<P> activeValues = new TreeSet<P>(propertyDef); |
| | | if (attribute != null) { |
| | | for (ByteString byteValue : attribute) { |
| | | PD value = ValueDecoder.decode(propertyDef, byteValue); |
| | | P value = ValueDecoder.decode(propertyDef, byteValue); |
| | | activeValues.add(value); |
| | | } |
| | | } |
| | |
| | | if (activeValues.size() > 1 && !propertyDef.hasOption(PropertyOption.MULTI_VALUED)) { |
| | | // This exception takes precedence over previous exceptions. |
| | | exception = new PropertyIsSingleValuedException(propertyDef); |
| | | PD value = activeValues.first(); |
| | | P value = activeValues.first(); |
| | | activeValues.clear(); |
| | | activeValues.add(value); |
| | | } |
| | | |
| | | // Get the property's default values. |
| | | Collection<PD> defaultValues; |
| | | Collection<P> defaultValues; |
| | | try { |
| | | defaultValues = findDefaultValues(path, propertyDef, false); |
| | | } catch (DefaultBehaviorException e) { |
| | |
| | | |
| | | // Determine the type of managed object associated with the named |
| | | // entry. |
| | | private <C extends ConfigurationClient, S extends Configuration> ManagedObjectDefinition<? extends C, ? extends S> getEntryDefinition( |
| | | AbstractManagedObjectDefinition<C, S> d, DN dn) throws ErrorResultException, DefinitionDecodingException { |
| | | // @Checkstyle:off |
| | | private <C extends ConfigurationClient, S extends Configuration> ManagedObjectDefinition<? extends C, ? extends S> |
| | | getEntryDefinition(AbstractManagedObjectDefinition<C, S> d, DN dn) throws ErrorResultException, |
| | | DefinitionDecodingException { |
| | | // @Checkstyle:on |
| | | SearchResultEntry searchResultEntry = connection.readEntry(dn, Collections.singleton("objectclass")); |
| | | Attribute objectClassAttr = searchResultEntry.getAttribute("objectclass"); |
| | | |
| | |
| | | |
| | | // Resolve the appropriate sub-type based on the object classes. |
| | | DefinitionResolver resolver = new DefinitionResolver() { |
| | | @Override |
| | | public boolean matches(AbstractManagedObjectDefinition<?, ?> d) { |
| | | String objectClass = profile.getObjectClass(d); |
| | | return objectClasses.contains(objectClass); |
| | |
| | | import org.opends.server.admin.Reference; |
| | | import org.opends.server.admin.RelationDefinition; |
| | | import org.opends.server.admin.SetRelationDefinition; |
| | | import org.opends.server.admin.UnknownPropertyDefinitionException; |
| | | import org.opends.server.admin.client.ConcurrentModificationException; |
| | | import org.opends.server.admin.client.ManagedObject; |
| | | import org.opends.server.admin.client.OperationRejectedException; |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public <PD> Object visitUnknown(PropertyDefinition<PD> pd, PD v, Void p) |
| | | throws UnknownPropertyDefinitionException { |
| | | return pd.encodeValue(v); |
| | | public <P> Object visitUnknown(PropertyDefinition<P> propertyDef, P value, Void p) { |
| | | return propertyDef.encodeValue(value); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | // Encode a property into LDAP string values. |
| | | private <PD> void encodeProperty(Attribute attribute, PropertyDefinition<PD> propertyDef) { |
| | | private <P> void encodeProperty(Attribute attribute, PropertyDefinition<P> propertyDef) { |
| | | PropertyValueVisitor<Object, Void> visitor = new ValueEncoder(); |
| | | Property<PD> property = getProperty(propertyDef); |
| | | Property<P> property = getProperty(propertyDef); |
| | | if (propertyDef.hasOption(PropertyOption.MANDATORY)) { |
| | | // For mandatory properties we fall-back to the default values |
| | | // if defined which can sometimes be the case e.g when a |
| | | // mandatory property is overridden. |
| | | for (PD value : property.getEffectiveValues()) { |
| | | for (P value : property.getEffectiveValues()) { |
| | | attribute.add(propertyDef.accept(visitor, value, null)); |
| | | } |
| | | } else { |
| | | for (PD value : property.getPendingValues()) { |
| | | for (P value : property.getPendingValues()) { |
| | | attribute.add(propertyDef.accept(visitor, value, null)); |
| | | } |
| | | } |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | public <C extends ConfigurationClient, S extends Configuration> void appendManagedObjectPathElement( |
| | | InstantiableRelationDefinition<? super C, ? super S> r, AbstractManagedObjectDefinition<C, S> d, String name) { |
| | | InstantiableRelationDefinition<? super C, ? super S> r, AbstractManagedObjectDefinition<C, S> d, |
| | | String name) { |
| | | // Add the RDN sequence representing the relation. |
| | | appendManagedObjectPathElement(r); |
| | | |
| | |
| | | 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) { |
| | | for (String name : rd.getDefaultManagedObjectNames()) { |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> Void visitOptional( |
| | | OptionalRelationDefinition<C, S> rd, Void p) { |
| | | if (rd.getDefaultManagedObject() != null) { |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> Void visitSingleton( |
| | | SingletonRelationDefinition<C, S> rd, Void p) { |
| | | // Do nothing - not possible to create singletons |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> Void visitSet(SetRelationDefinition<C, S> rd, |
| | | Void p) { |
| | | for (String name : rd.getDefaultManagedObjectNames()) { |
| | |
| | | } |
| | | |
| | | // Set property values. |
| | | private <PD> void setPropertyValues(ManagedObject<?> mo, PropertyDefinition<PD> pd, |
| | | private <P> void setPropertyValues(ManagedObject<?> mo, PropertyDefinition<P> pd, |
| | | DefaultManagedObject<?, ?> dmo) { |
| | | mo.setPropertyValues(pd, dmo.getPropertyValues(pd)); |
| | | } |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public final void commit() throws ManagedObjectAlreadyExistsException, MissingMandatoryPropertiesException, |
| | | ConcurrentModificationException, OperationRejectedException, ErrorResultException { |
| | | // First make sure all mandatory properties are defined. |
| | |
| | | } |
| | | |
| | | 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, |
| | | SetRelationDefinition<C, S> r, String name) throws DefinitionDecodingException, |
| | | ManagedObjectDecodingException, ManagedObjectNotFoundException, ConcurrentModificationException, |
| | | ErrorResultException { |
| | | validateRelationDefinition(r); |
| | |
| | | /** |
| | | * {@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 { |
| | | 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 { |
| | | 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; |
| | |
| | | |
| | | // 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) { |
| | |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.server.admin.client.spi; |
| | | |
| | | import java.util.ArrayList; |
| | |
| | | * @param <T> |
| | | * The type of the property. |
| | | */ |
| | | private class DefaultValueFinder<T> implements DefaultBehaviorProviderVisitor<T, Collection<T>, Void> { |
| | | private final class DefaultValueFinder<T> implements DefaultBehaviorProviderVisitor<T, Collection<T>, Void> { |
| | | |
| | | // Any exception that occurred whilst retrieving inherited default |
| | | // values. |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public Collection<T> visitAbsoluteInherited(AbsoluteInheritedDefaultBehaviorProvider<T> d, Void p) { |
| | | try { |
| | | return getInheritedProperty(d.getManagedObjectPath(), d.getManagedObjectDefinition(), |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public Collection<T> visitAlias(AliasDefaultBehaviorProvider<T> d, Void p) { |
| | | return Collections.emptySet(); |
| | | } |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public Collection<T> visitDefined(DefinedDefaultBehaviorProvider<T> d, Void p) { |
| | | Collection<String> stringValues = d.getDefaultValues(); |
| | | List<T> values = new ArrayList<T>(stringValues.size()); |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public Collection<T> visitRelativeInherited(RelativeInheritedDefaultBehaviorProvider<T> d, Void p) { |
| | | try { |
| | | return getInheritedProperty(d.getManagedObjectPath(nextPath), d.getManagedObjectDefinition(), |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public Collection<T> visitUndefined(UndefinedDefaultBehaviorProvider<T> d, Void p) { |
| | | return Collections.emptySet(); |
| | | } |
| | | |
| | | // Find the default values for the next path/property. |
| | | private Collection<T> find(ManagedObjectPath<?, ?> p, PropertyDefinition<T> pd) throws DefaultBehaviorException { |
| | | private Collection<T> find(ManagedObjectPath<?, ?> p, PropertyDefinition<T> pd) { |
| | | this.nextPath = p; |
| | | this.nextProperty = pd; |
| | | |
| | |
| | | // Get an inherited property value. |
| | | @SuppressWarnings("unchecked") |
| | | private Collection<T> getInheritedProperty(ManagedObjectPath target, AbstractManagedObjectDefinition<?, ?> d, |
| | | String propertyName) throws DefaultBehaviorException { |
| | | String propertyName) { |
| | | // First check that the requested type of managed object |
| | | // corresponds to the path. |
| | | AbstractManagedObjectDefinition<?, ?> supr = target.getManagedObjectDefinition(); |
| | |
| | | */ |
| | | public final <C extends ConfigurationClient, S extends Configuration> boolean deleteManagedObject( |
| | | ManagedObjectPath<?, ?> parent, InstantiableRelationDefinition<C, S> rd, String name) |
| | | throws IllegalArgumentException, ManagedObjectNotFoundException, OperationRejectedException, |
| | | ErrorResultException { |
| | | throws ManagedObjectNotFoundException, OperationRejectedException, ErrorResultException { |
| | | validateRelationDefinition(parent, rd); |
| | | ManagedObjectPath<?, ?> child = parent.child(rd, name); |
| | | return doDeleteManagedObject(child); |
| | |
| | | * If any other error occurs. |
| | | */ |
| | | public final <C extends ConfigurationClient, S extends Configuration> boolean deleteManagedObject( |
| | | ManagedObjectPath<?, ?> parent, OptionalRelationDefinition<C, S> rd) throws IllegalArgumentException, |
| | | ManagedObjectNotFoundException, OperationRejectedException, ErrorResultException { |
| | | ManagedObjectPath<?, ?> parent, OptionalRelationDefinition<C, S> rd) throws ManagedObjectNotFoundException, |
| | | OperationRejectedException, ErrorResultException { |
| | | validateRelationDefinition(parent, rd); |
| | | ManagedObjectPath<?, ?> child = parent.child(rd); |
| | | return doDeleteManagedObject(child); |
| | |
| | | */ |
| | | public final <C extends ConfigurationClient, S extends Configuration> boolean deleteManagedObject( |
| | | ManagedObjectPath<?, ?> parent, SetRelationDefinition<C, S> rd, String name) |
| | | throws IllegalArgumentException, ManagedObjectNotFoundException, OperationRejectedException, |
| | | ErrorResultException { |
| | | throws ManagedObjectNotFoundException, OperationRejectedException, ErrorResultException { |
| | | validateRelationDefinition(parent, rd); |
| | | ManagedObjectPath<?, ?> child = parent.child(rd, name); |
| | | return doDeleteManagedObject(child); |
| | |
| | | * @throws ErrorResultException |
| | | * If any other error occurs. |
| | | */ |
| | | // @Checkstyle:ignore |
| | | public abstract <C extends ConfigurationClient, S extends Configuration> ManagedObject<? extends C> getManagedObject( |
| | | ManagedObjectPath<C, S> path) throws DefinitionDecodingException, ManagedObjectDecodingException, |
| | | ManagedObjectNotFoundException, ErrorResultException; |
| | |
| | | * @param <S> |
| | | * The type of server managed object configuration that the path |
| | | * definition refers to. |
| | | * @param <PD> |
| | | * @param <P> |
| | | * The type of the property to be retrieved. |
| | | * @param path |
| | | * The path of the managed object containing the property. |
| | |
| | | * @throws ErrorResultException |
| | | * If any other error occurs. |
| | | */ |
| | | public abstract <C extends ConfigurationClient, S extends Configuration, PD> SortedSet<PD> getPropertyValues( |
| | | ManagedObjectPath<C, S> path, PropertyDefinition<PD> pd) throws IllegalArgumentException, |
| | | DefinitionDecodingException, ManagedObjectNotFoundException, ErrorResultException, PropertyException; |
| | | public abstract <C extends ConfigurationClient, S extends Configuration, P> SortedSet<P> getPropertyValues( |
| | | ManagedObjectPath<C, S> path, PropertyDefinition<P> pd) throws DefinitionDecodingException, |
| | | ManagedObjectNotFoundException, ErrorResultException; |
| | | |
| | | /** |
| | | * Gets the root configuration managed object associated with this |
| | |
| | | */ |
| | | public abstract <C extends ConfigurationClient, S extends Configuration> String[] listManagedObjects( |
| | | ManagedObjectPath<?, ?> parent, InstantiableRelationDefinition<C, S> rd, |
| | | AbstractManagedObjectDefinition<? extends C, ? extends S> d) throws IllegalArgumentException, |
| | | ManagedObjectNotFoundException, ErrorResultException; |
| | | AbstractManagedObjectDefinition<? extends C, ? extends S> d) throws ManagedObjectNotFoundException, |
| | | ErrorResultException; |
| | | |
| | | /** |
| | | * Lists the child managed objects of the named parent managed object which |
| | |
| | | */ |
| | | public abstract <C extends ConfigurationClient, S extends Configuration> String[] listManagedObjects( |
| | | ManagedObjectPath<?, ?> parent, SetRelationDefinition<C, S> rd, |
| | | AbstractManagedObjectDefinition<? extends C, ? extends S> d) throws IllegalArgumentException, |
| | | ManagedObjectNotFoundException, ErrorResultException; |
| | | AbstractManagedObjectDefinition<? extends C, ? extends S> d) throws ManagedObjectNotFoundException, |
| | | ErrorResultException; |
| | | |
| | | /** |
| | | * Determines whether or not the named managed object exists. |
| | |
| | | /** |
| | | * Gets the default values for the specified property. |
| | | * |
| | | * @param <PD> |
| | | * @param <P> |
| | | * The type of the property. |
| | | * @param p |
| | | * The managed object path of the current managed object. |
| | |
| | | * If the default values could not be retrieved or decoded |
| | | * properly. |
| | | */ |
| | | protected final <PD> Collection<PD> findDefaultValues(ManagedObjectPath<?, ?> p, PropertyDefinition<PD> pd, |
| | | boolean isCreate) throws DefaultBehaviorException { |
| | | DefaultValueFinder<PD> v = new DefaultValueFinder<PD>(p, isCreate); |
| | | protected final <P> Collection<P> findDefaultValues(ManagedObjectPath<?, ?> p, PropertyDefinition<P> pd, |
| | | boolean isCreate) { |
| | | DefaultValueFinder<P> v = new DefaultValueFinder<P>(p, isCreate); |
| | | return v.find(p, pd); |
| | | } |
| | | |
| | |
| | | * If the relation definition does not belong to the managed |
| | | * object definition. |
| | | */ |
| | | protected final void validateRelationDefinition(ManagedObjectPath<?, ?> path, RelationDefinition<?, ?> rd) |
| | | throws IllegalArgumentException { |
| | | protected final void validateRelationDefinition(ManagedObjectPath<?, ?> path, RelationDefinition<?, ?> rd) { |
| | | AbstractManagedObjectDefinition<?, ?> d = path.getManagedObjectDefinition(); |
| | | RelationDefinition<?, ?> tmp = d.getRelationDefinition(rd.getName()); |
| | | if (tmp != rd) { |
| | |
| | | |
| | | package org.opends.server.admin.client.spi; |
| | | |
| | | |
| | | |
| | | import java.util.SortedSet; |
| | | |
| | | import org.opends.server.admin.PropertyDefinition; |
| | | |
| | | |
| | | |
| | | /** |
| | | * A managed object property comprising of the property's definition |
| | | * and its set of values. |
| | | * A managed object property comprising of the property's definition and its set |
| | | * of values. |
| | | * <p> |
| | | * The property stores the values in a sorted set in which values are |
| | | * compared using the comparator defined by the property definition. |
| | | * The property stores the values in a sorted set in which values are compared |
| | | * using the comparator defined by the property definition. |
| | | * <p> |
| | | * The property keeps track of whether or not its pending set of |
| | | * values differs from its active values. |
| | | * The property keeps track of whether or not its pending set of values differs |
| | | * from its active values. |
| | | * |
| | | * @param <T> |
| | | * The type of the property. |
| | |
| | | /** |
| | | * Get an immutable set view of this property's active values. |
| | | * |
| | | * @return Returns an immutable set view of this property's active |
| | | * values. An empty set indicates that there are no active |
| | | * values, and any default values are applicable. |
| | | * @return Returns an immutable set view of this property's active values. |
| | | * An empty set indicates that there are no active values, and any |
| | | * default values are applicable. |
| | | */ |
| | | SortedSet<T> getActiveValues(); |
| | | |
| | | |
| | | |
| | | /** |
| | | * Get an immutable set view of this property's default values. |
| | | * |
| | | * @return Returns an immutable set view of this property's default |
| | | * values. An empty set indicates that there are no default |
| | | * values. |
| | | * @return Returns an immutable set view of this property's default values. |
| | | * An empty set indicates that there are no default values. |
| | | */ |
| | | SortedSet<T> getDefaultValues(); |
| | | |
| | | |
| | | |
| | | /** |
| | | * Get an immutable set view of this property's effective values. |
| | | * |
| | | * @return Returns an immutable set view of this property's |
| | | * effective values. |
| | | * @return Returns an immutable set view of this property's effective |
| | | * values. |
| | | */ |
| | | SortedSet<T> getEffectiveValues(); |
| | | |
| | | |
| | | |
| | | /** |
| | | * Get an immutable set view of this property's pending values. |
| | | * <p> |
| | | * Immediately after construction, the pending values matches the |
| | | * active values. |
| | | * Immediately after construction, the pending values matches the active |
| | | * values. |
| | | * |
| | | * @return Returns an immutable set view of this property's pending |
| | | * values. An empty set indicates that there are no pending |
| | | * values, and any default values are applicable. |
| | | * @return Returns an immutable set view of this property's pending values. |
| | | * An empty set indicates that there are no pending values, and any |
| | | * default values are applicable. |
| | | */ |
| | | SortedSet<T> getPendingValues(); |
| | | |
| | | |
| | | |
| | | /** |
| | | * Get the property definition associated with this property. |
| | | * |
| | | * @return Returns the property definition associated with this |
| | | * property. |
| | | * @return Returns the property definition associated with this property. |
| | | */ |
| | | PropertyDefinition<T> getPropertyDefinition(); |
| | | |
| | | |
| | | |
| | | /** |
| | | * Determines whether or not this property contains any pending |
| | | * values. |
| | | * Determines whether or not this property contains any pending values. |
| | | * |
| | | * @return Returns <code>true</code> if this property does not |
| | | * contain any pending values. |
| | | * @return Returns <code>true</code> if this property does not contain any |
| | | * pending values. |
| | | */ |
| | | boolean isEmpty(); |
| | | |
| | | |
| | | |
| | | /** |
| | | * Determines whether or not this property has been modified since |
| | | * it was constructed. In other words, whether or not the set of |
| | | * pending values differs from the set of active values. |
| | | * Determines whether or not this property has been modified since it was |
| | | * constructed. In other words, whether or not the set of pending values |
| | | * differs from the set of active values. |
| | | * |
| | | * @return Returns <code>true</code> if this property has been |
| | | * modified since it was constructed. |
| | | * @return Returns <code>true</code> if this property has been modified |
| | | * since it was constructed. |
| | | */ |
| | | boolean isModified(); |
| | | |
| | | |
| | | |
| | | /** |
| | | * Determines whether or not this property contains any active |
| | | * values. |
| | | * Determines whether or not this property contains any active values. |
| | | * |
| | | * @return Returns <code>true</code> if this property does not |
| | | * contain any active values. |
| | | * @return Returns <code>true</code> if this property does not contain any |
| | | * active values. |
| | | */ |
| | | boolean wasEmpty(); |
| | | } |
| | |
| | | |
| | | package org.opends.server.admin.client.spi; |
| | | |
| | | |
| | | |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | | import java.util.HashMap; |
| | |
| | | import org.opends.server.admin.PropertyIsSingleValuedException; |
| | | import org.opends.server.admin.PropertyOption; |
| | | |
| | | |
| | | |
| | | /** |
| | | * A set of properties. Instances of this class can be used as the |
| | | * core of a managed object implementation. |
| | | * A set of properties. Instances of this class can be used as the core of a |
| | | * managed object implementation. |
| | | */ |
| | | public final class PropertySet { |
| | | |
| | |
| | | // The pending set of values. |
| | | private final SortedSet<T> pendingValues; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Create a property with the provided sets of pre-validated |
| | | * default and active values. |
| | | * Create a property with the provided sets of pre-validated default and |
| | | * active values. |
| | | * |
| | | * @param pd |
| | | * The property definition. |
| | |
| | | * @param activeValues |
| | | * The set of active values for the property. |
| | | */ |
| | | public MyProperty(PropertyDefinition<T> pd, Collection<T> defaultValues, |
| | | Collection<T> activeValues) { |
| | | public MyProperty(PropertyDefinition<T> pd, Collection<T> defaultValues, Collection<T> activeValues) { |
| | | this.d = pd; |
| | | |
| | | SortedSet<T> sortedDefaultValues = new TreeSet<T>(pd); |
| | | sortedDefaultValues.addAll(defaultValues); |
| | | this.defaultValues = Collections |
| | | .unmodifiableSortedSet(sortedDefaultValues); |
| | | this.defaultValues = Collections.unmodifiableSortedSet(sortedDefaultValues); |
| | | |
| | | this.activeValues = new TreeSet<T>(pd); |
| | | this.activeValues.addAll(activeValues); |
| | |
| | | this.pendingValues = new TreeSet<T>(this.activeValues); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Makes the pending values active. |
| | | */ |
| | |
| | | activeValues.addAll(pendingValues); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public SortedSet<T> getActiveValues() { |
| | | return Collections.unmodifiableSortedSet(activeValues); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public SortedSet<T> getDefaultValues() { |
| | | return defaultValues; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public SortedSet<T> getEffectiveValues() { |
| | | SortedSet<T> values = getPendingValues(); |
| | | |
| | |
| | | return values; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public SortedSet<T> getPendingValues() { |
| | | return Collections.unmodifiableSortedSet(pendingValues); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public PropertyDefinition<T> getPropertyDefinition() { |
| | | return d; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isEmpty() { |
| | | return pendingValues.isEmpty(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isModified() { |
| | | if (activeValues.size() == pendingValues.size() |
| | | && activeValues.containsAll(pendingValues)) { |
| | | if (activeValues.size() == pendingValues.size() && activeValues.containsAll(pendingValues)) { |
| | | return false; |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Replace all pending values of this property with the provided |
| | | * values. |
| | | * Replace all pending values of this property with the provided values. |
| | | * |
| | | * @param c |
| | | * The new set of pending property values. |
| | |
| | | pendingValues.addAll(c); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | |
| | | return getEffectiveValues().toString(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean wasEmpty() { |
| | | return activeValues.isEmpty(); |
| | | } |
| | |
| | | // The properties. |
| | | private final Map<PropertyDefinition<?>, MyProperty<?>> properties; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Creates a new empty property set. |
| | | */ |
| | |
| | | this.properties = new HashMap<PropertyDefinition<?>, MyProperty<?>>(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Creates a property with the provided sets of pre-validated |
| | | * default and active values. |
| | | * Creates a property with the provided sets of pre-validated default and |
| | | * active values. |
| | | * |
| | | * @param <T> |
| | | * The type of the property. |
| | |
| | | * @param activeValues |
| | | * The set of active values for the property. |
| | | */ |
| | | public <T> void addProperty(PropertyDefinition<T> pd, |
| | | Collection<T> defaultValues, Collection<T> activeValues) { |
| | | public <T> void addProperty(PropertyDefinition<T> pd, Collection<T> defaultValues, Collection<T> activeValues) { |
| | | MyProperty<T> p = new MyProperty<T>(pd, defaultValues, activeValues); |
| | | properties.put(pd, p); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Get the property associated with the specified property |
| | | * definition. |
| | | * Get the property associated with the specified property definition. |
| | | * |
| | | * @param <T> |
| | | * The underlying type of the property. |
| | | * @param d |
| | | * The Property definition. |
| | | * @return Returns the property associated with the specified |
| | | * property definition. |
| | | * @return Returns the property associated with the specified property |
| | | * definition. |
| | | * @throws IllegalArgumentException |
| | | * If this property provider does not recognise the |
| | | * requested property definition. |
| | | * If this property provider does not recognise the requested |
| | | * property definition. |
| | | */ |
| | | @SuppressWarnings("unchecked") |
| | | public <T> Property<T> getProperty(PropertyDefinition<T> d) |
| | | throws IllegalArgumentException { |
| | | public <T> Property<T> getProperty(PropertyDefinition<T> d) { |
| | | if (!properties.containsKey(d)) { |
| | | throw new IllegalArgumentException("Unknown property " + d.getName()); |
| | | } |
| | |
| | | return (Property<T>) properties.get(d); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | |
| | | public String toString() { |
| | | StringBuilder builder = new StringBuilder(); |
| | | builder.append('{'); |
| | | for (Map.Entry<PropertyDefinition<?>, MyProperty<?>> entry : properties |
| | | .entrySet()) { |
| | | for (Map.Entry<PropertyDefinition<?>, MyProperty<?>> entry : properties.entrySet()) { |
| | | builder.append(entry.getKey().getName()); |
| | | builder.append('='); |
| | | builder.append(entry.getValue().toString()); |
| | |
| | | return builder.toString(); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * Makes all pending values active. |
| | | */ |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Set a new pending values for the specified property. |
| | | * <p> |
| | | * See the class description for more information regarding pending |
| | | * values. |
| | | * See the class description for more information regarding pending values. |
| | | * |
| | | * @param <T> |
| | | * The type of the property to be modified. |
| | | * @param d |
| | | * The property to be modified. |
| | | * @param values |
| | | * A non-<code>null</code> set of new pending values for |
| | | * the property (an empty set indicates that the property |
| | | * should be reset to its default behavior). The set will |
| | | * not be referenced by this managed object. |
| | | * A non-<code>null</code> set of new pending values for the |
| | | * property (an empty set indicates that the property should be |
| | | * reset to its default behavior). The set will not be referenced |
| | | * by this managed object. |
| | | * @throws IllegalPropertyValueException |
| | | * If a new pending value is deemed to be invalid |
| | | * according to the property definition. |
| | | * If a new pending value is deemed to be invalid according to |
| | | * the property definition. |
| | | * @throws PropertyIsSingleValuedException |
| | | * If an attempt was made to add multiple pending values |
| | | * to a single-valued property. |
| | | * If an attempt was made to add multiple pending values to a |
| | | * single-valued property. |
| | | * @throws PropertyIsMandatoryException |
| | | * If an attempt was made to remove a mandatory property. |
| | | * @throws IllegalArgumentException |
| | | * If the specified property definition is not associated |
| | | * with this managed object. |
| | | * If the specified property definition is not associated with |
| | | * this managed object. |
| | | */ |
| | | <T> void setPropertyValues(PropertyDefinition<T> d, |
| | | Collection<T> values) throws IllegalPropertyValueException, |
| | | PropertyIsSingleValuedException, PropertyIsMandatoryException, |
| | | IllegalArgumentException { |
| | | <T> void setPropertyValues(PropertyDefinition<T> d, Collection<T> values) { |
| | | MyProperty<T> property = (MyProperty<T>) getProperty(d); |
| | | |
| | | if (values.size() > 1 && !d.hasOption(PropertyOption.MULTI_VALUED)) { |
| | |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | |
| | | |
| | | /** |
| | | * Client side driver implementation interfaces. |
| | | * <p> |
| | |
| | | import org.forgerock.opendj.ldap.ErrorResultException; |
| | | import org.forgerock.util.Reject; |
| | | import org.opends.server.admin.AbstractManagedObjectDefinition; |
| | | import org.opends.server.admin.IllegalPropertyValueStringException; |
| | | import org.opends.server.admin.PropertyDefinition; |
| | | import org.opends.server.admin.client.ManagedObject; |
| | | import org.opends.server.admin.client.ManagementContext; |
| | |
| | | final T value; |
| | | |
| | | // Private constructor. |
| | | private Impl(PropertyDefinition<T> pd, T value) throws IllegalPropertyValueStringException { |
| | | private Impl(PropertyDefinition<T> pd, T value) { |
| | | this.pd = pd; |
| | | this.value = value; |
| | | } |
| | |
| | | } |
| | | |
| | | // Creates the new private implementation. |
| | | private <T> void buildImpl(PropertyDefinition<T> pd) throws IllegalPropertyValueStringException { |
| | | private <T> void buildImpl(PropertyDefinition<T> pd) { |
| | | T value = pd.decodeValue(propertyStringValue); |
| | | this.impl = new Impl<T>(pd, value); |
| | | } |
| | |
| | | * It is based on the Admin Framework Introspection API |
| | | */ |
| | | @SuppressWarnings({ "unchecked", "rawtypes" }) |
| | | public class ConfigGuideGeneration { |
| | | public final class ConfigGuideGeneration { |
| | | |
| | | // Note : still to be done : |
| | | // I18n support. Today all the strings are hardcoded in this file |
| | | |
| | | private final static String ACI_SYNTAX_REL_URL = "/doc/admin-guide/#about-acis"; |
| | | private final static String DURATION_SYNTAX_REL_URL = "duration-syntax.html"; |
| | | private final String CSS_FILE = "opendj-config.css"; |
| | | private static final String CSS_FILE = "opendj-config.css"; |
| | | |
| | | private final String MAIN_FILE = "index.html"; |
| | | private final String INHERITANCE_TREE_FILE = "ManagedObjectInheritanceTree.html"; |
| | | private final String RELATION_TREE_FILE = "ManagedObjectRelationTree.html"; |
| | | private final String MO_LIST_FILE = "ManagedObjectList.html"; |
| | | private final String PROPERTIES_INDEX_FILE = "PropertiesIndex.html"; |
| | | private final String WELCOME_FILE = "welcome.html"; |
| | | private final String MAINTOP_FILE = "maintop.html"; |
| | | private final String INDEX_FILE = "index.html"; |
| | | private final String FAVICON = "http://forgerock.org/favicon.ico"; |
| | | private static final String MAIN_FILE = "index.html"; |
| | | private static final String INHERITANCE_TREE_FILE = "ManagedObjectInheritanceTree.html"; |
| | | private static final String RELATION_TREE_FILE = "ManagedObjectRelationTree.html"; |
| | | private static final String MO_LIST_FILE = "ManagedObjectList.html"; |
| | | private static final String PROPERTIES_INDEX_FILE = "PropertiesIndex.html"; |
| | | private static final String WELCOME_FILE = "welcome.html"; |
| | | private static final String MAINTOP_FILE = "maintop.html"; |
| | | private static final String INDEX_FILE = "index.html"; |
| | | private static final String FAVICON = "http://forgerock.org/favicon.ico"; |
| | | |
| | | private static final String CONFIG_GUIDE_DIR = "opendj_config_guide"; |
| | | private final String MAIN_FRAME = "mainFrame"; |
| | | private static final String MAIN_FRAME = "mainFrame"; |
| | | |
| | | private ConfigGuideGeneration() { |
| | | // no implementation required. |
| | | } |
| | | |
| | | /** |
| | | * Entry point for documentation generation. Properties: GenerationDir - The |
| | |
| | | ldapMapping = true; |
| | | } |
| | | |
| | | OpenDJWiki = properties.getProperty("OpenDJWiki"); |
| | | if (OpenDJWiki == null) { |
| | | openDJWiki = properties.getProperty("OpenDJWiki"); |
| | | if (openDJWiki == null) { |
| | | // Default is current wiki |
| | | OpenDJWiki = "http://wikis.forgerock.org/confluence/display/OPENDJ"; |
| | | openDJWiki = "http://wikis.forgerock.org/confluence/display/OPENDJ"; |
| | | } |
| | | |
| | | OpenDJHome = properties.getProperty("OpenDJHome"); |
| | | if (OpenDJHome == null) { |
| | | openDJHome = properties.getProperty("OpenDJHome"); |
| | | if (openDJHome == null) { |
| | | // Default is current OpenDJ project home |
| | | OpenDJHome = "http://opendj.forgerock.org"; |
| | | openDJHome = "http://opendj.forgerock.org"; |
| | | } |
| | | |
| | | aciSyntaxPage = OpenDJHome + ACI_SYNTAX_REL_URL; |
| | | aciSyntaxPage = openDJHome + ACI_SYNTAX_REL_URL; |
| | | durationSyntaxPage = DURATION_SYNTAX_REL_URL; |
| | | |
| | | ConfigGuideGeneration myGen = new ConfigGuideGeneration(); |
| | |
| | | if (rel.hasOption(RelationOption.HIDDEN)) { |
| | | continue; |
| | | } |
| | | String linkStr = getLink(childMo.getUserFriendlyName().toString(), childMo.getName() + ".html", |
| | | MAIN_FRAME); |
| | | String linkStr = |
| | | getLink(childMo.getUserFriendlyName().toString(), childMo.getName() + ".html", MAIN_FRAME); |
| | | String fromStr = ""; |
| | | if (!parentMo.getName().equals("")) { |
| | | fromStr = " (from " |
| | | fromStr = |
| | | " (from " |
| | | + getLink(parentMo.getUserFriendlyName().toString(), parentMo.getName() + ".html", MAIN_FRAME) |
| | | + ")"; |
| | | } |
| | |
| | | if (!aggregProps.isEmpty()) { |
| | | paragraph("The following components have a direct AGGREGATION relation FROM " |
| | | + mo.getUserFriendlyPluralName() + " :"); |
| | | TreeMap<String, AbstractManagedObjectDefinition> componentList = new TreeMap<String, AbstractManagedObjectDefinition>(); |
| | | TreeMap<String, AbstractManagedObjectDefinition> componentList = |
| | | new TreeMap<String, AbstractManagedObjectDefinition>(); |
| | | for (AggregationPropertyDefinition agg : aggregProps) { |
| | | RelationDefinition rel = agg.getRelationDefinition(); |
| | | AbstractManagedObjectDefinition childRel = rel.getChildDefinition(); |
| | |
| | | if (!isReverseAggregPropsEmpty) { |
| | | paragraph("The following components have a direct AGGREGATION relation TO " |
| | | + mo.getUserFriendlyPluralName() + " :"); |
| | | TreeMap<String, AbstractManagedObjectDefinition> componentList = new TreeMap<String, AbstractManagedObjectDefinition>(); |
| | | TreeMap<String, AbstractManagedObjectDefinition> componentList = |
| | | new TreeMap<String, AbstractManagedObjectDefinition>(); |
| | | for (AggregationPropertyDefinition agg : reverseAggregProps) { |
| | | AbstractManagedObjectDefinition fromMo = agg.getManagedObjectDefinition(); |
| | | componentList.put(fromMo.getName(), fromMo); |
| | |
| | | Type actionType = prop.getAdministratorAction().getType(); |
| | | String actionStr = ""; |
| | | if (actionType == Type.COMPONENT_RESTART) { |
| | | actionStr = "The " + mo.getUserFriendlyName() |
| | | actionStr = |
| | | "The " + mo.getUserFriendlyName() |
| | | + " must be disabled and re-enabled for changes to this setting " + "to take effect"; |
| | | } else if (actionType == Type.SERVER_RESTART) { |
| | | actionStr = "Restart the server"; |
| | |
| | | |
| | | String basicHtmlCell = ""; |
| | | if (basicPropName != null) { |
| | | basicHtmlCell = " <td>↓ <a href=\"#" + basicPropName + "\">" + basicPropName |
| | | + "</a></td>\n"; |
| | | basicHtmlCell = |
| | | " <td>↓ <a href=\"#" + basicPropName + "\">" + basicPropName + "</a></td>\n"; |
| | | } else if ((basicPropsArray.length == 0) && (ii == 0)) { |
| | | basicHtmlCell = " <td> None</td>\n"; |
| | | } else if (ii >= basicPropsArray.length) { |
| | |
| | | |
| | | String advancedHtmlCell = ""; |
| | | if (advancedPropName != null) { |
| | | advancedHtmlCell = " <td>↓ <a href=\"#" + advancedPropName + "\">" + advancedPropName |
| | | + "</a></td>\n"; |
| | | advancedHtmlCell = |
| | | " <td>↓ <a href=\"#" + advancedPropName + "\">" + advancedPropName + "</a></td>\n"; |
| | | } else if ((advancedPropsArray.length == 0) && (ii == 0)) { |
| | | advancedHtmlCell = " <td> None</td>\n"; |
| | | } |
| | |
| | | htmlHeader(DynamicConstants.PRODUCT_NAME + " Configuration Reference - Properties View"); |
| | | tabMenu(PROPERTIES_INDEX_FILE); |
| | | viewHelp("This view provides a list of all configuration properties, " |
| | | + "in alphabetical order, and indicates the configuration component to " |
| | | + "which each property applies."); |
| | | + "in alphabetical order, and indicates the configuration component to " + "which each property applies."); |
| | | |
| | | newline(); |
| | | paragraph(lettersPointers); |
| | |
| | | |
| | | private void genMainTopPage() { |
| | | htmlHeader(DynamicConstants.PRODUCT_NAME + " Configuration Reference - Main Top"); |
| | | htmlBuff.append("<div class=\"breadcrumb\"><span class=\"pageactions\">" + "<a href=\"" + OpenDJHome |
| | | + "\" target=\"_parent\">" + "<span style=\"font-size: 12px;\">« </span>" |
| | | + "Back to " + DynamicConstants.PRODUCT_NAME + " Home</a></span> </div>\n"); |
| | | htmlBuff.append("<div class=\"breadcrumb\"><span class=\"pageactions\">" + "<a href=\"" + openDJHome |
| | | + "\" target=\"_parent\">" + "<span style=\"font-size: 12px;\">« </span>" + "Back to " |
| | | + DynamicConstants.PRODUCT_NAME + " Home</a></span> </div>\n"); |
| | | htmlBuff.append("<table class=\"titletable\" cellspacing=\"0\" " + "width=\"100%\">\n"); |
| | | htmlBuff.append("<tbody><tr>\n"); |
| | | htmlBuff.append(" <td><h2>" + DynamicConstants.PRODUCT_NAME + " Configuration Reference</h2></td>\n"); |
| | | htmlBuff.append(" <td valign=\"bottom\" width=\"10%\">" + "<a href=\"" + OpenDJHome |
| | | htmlBuff.append(" <td valign=\"bottom\" width=\"10%\">" + "<a href=\"" + openDJHome |
| | | + "\" target=\"_parent\">" + "<img src=\"opendj_logo_sm.png\" alt=\"OpenDJ Logo\" align=\"bottom\" " |
| | | + "border=\"0\" height=\"33\" width=\"114\"></a></td>\n"); |
| | | htmlBuff.append("</tr>\n"); |
| | |
| | | + "frameborder=\"yes\" border=\"1\" bordercolor=\"#333333\">\n"); |
| | | htmlBuff.append(" <frame src=\"" + MAINTOP_FILE + "\" name=\"topFrame\" " |
| | | + "id=\"topFrame\" border=\"1\" title=\"topFrame\" scrolling=\"no\">\n"); |
| | | htmlBuff.append(" <frameset cols=\"375,*\" frameborder=\"yes\" " + "border=\"1\" " + "framespacing=\"1\">\n"); |
| | | htmlBuff |
| | | .append(" <frameset cols=\"375,*\" frameborder=\"yes\" " + "border=\"1\" " + "framespacing=\"1\">\n"); |
| | | htmlBuff.append(" <frame src=\"" + INHERITANCE_TREE_FILE + "\" " |
| | | + "name=\"leftFrame\" id=\"leftFrame\" title=\"leftFrame\" " + "scrolling=\"auto\">\n"); |
| | | htmlBuff.append(" <frame src=\"" + WELCOME_FILE + "\" name=\"mainFrame\" " |
| | |
| | | return "The DN of any " |
| | | + linkStr |
| | | + ". " |
| | | + ((prop.getSourceConstraintSynopsis() != null) ? prop.getSourceConstraintSynopsis() |
| | | .toString() : ""); |
| | | + ((prop.getSourceConstraintSynopsis() != null) ? prop.getSourceConstraintSynopsis().toString() |
| | | : ""); |
| | | } |
| | | |
| | | @Override |
| | |
| | | if (prop.getMaximumUnit() != null) { |
| | | durationStr += "Maximum unit is \"" + prop.getMaximumUnit().getLongName() + "\". "; |
| | | } |
| | | long lowerLimitStr = new Double(prop.getBaseUnit().fromMilliSeconds(prop.getLowerLimit())) |
| | | .longValue(); |
| | | long lowerLimitStr = |
| | | new Double(prop.getBaseUnit().fromMilliSeconds(prop.getLowerLimit())).longValue(); |
| | | durationStr += "Lower limit is " + lowerLimitStr + " " + prop.getBaseUnit().getLongName() + ". "; |
| | | if (prop.getUpperLimit() != null) { |
| | | long upperLimitStr = new Double(prop.getBaseUnit().fromMilliSeconds(prop.getUpperLimit())) |
| | | .longValue(); |
| | | long upperLimitStr = |
| | | new Double(prop.getBaseUnit().fromMilliSeconds(prop.getUpperLimit())).longValue(); |
| | | durationStr += "Upper limit is " + upperLimitStr + " " + prop.getBaseUnit().getLongName() + ". "; |
| | | } |
| | | |
| | |
| | | AliasDefaultBehaviorProvider aliasBehav = (AliasDefaultBehaviorProvider) defaultBehav; |
| | | defValueStr = aliasBehav.getSynopsis().toString(); |
| | | } else if (defaultBehav instanceof RelativeInheritedDefaultBehaviorProvider) { |
| | | RelativeInheritedDefaultBehaviorProvider relativBehav = (RelativeInheritedDefaultBehaviorProvider) defaultBehav; |
| | | defValueStr = getDefaultBehaviorString(relativBehav.getManagedObjectDefinition().getPropertyDefinition( |
| | | RelativeInheritedDefaultBehaviorProvider relativBehav = |
| | | (RelativeInheritedDefaultBehaviorProvider) defaultBehav; |
| | | defValueStr = |
| | | getDefaultBehaviorString(relativBehav.getManagedObjectDefinition().getPropertyDefinition( |
| | | relativBehav.getPropertyName())); |
| | | } else if (defaultBehav instanceof AbsoluteInheritedDefaultBehaviorProvider) { |
| | | AbsoluteInheritedDefaultBehaviorProvider absoluteBehav = (AbsoluteInheritedDefaultBehaviorProvider) defaultBehav; |
| | | defValueStr = getDefaultBehaviorString(absoluteBehav.getManagedObjectDefinition().getPropertyDefinition( |
| | | AbsoluteInheritedDefaultBehaviorProvider absoluteBehav = |
| | | (AbsoluteInheritedDefaultBehaviorProvider) defaultBehav; |
| | | defValueStr = |
| | | getDefaultBehaviorString(absoluteBehav.getManagedObjectDefinition().getPropertyDefinition( |
| | | absoluteBehav.getPropertyName())); |
| | | } |
| | | return defValueStr; |
| | |
| | | |
| | | } |
| | | |
| | | private final String Now = new Date().toString(); |
| | | private static final String NOW = new Date().toString(); |
| | | |
| | | private String getHtmlHeader(String pageTitle) { |
| | | return ("<html>\n" + "<head>\n" + "<meta http-equiv=\"content-type\"\n" |
| | | + "content=\"text/html; charset=ISO-8859-1\">\n" + "<title>" + pageTitle + "</title>\n" |
| | | + "<link rel=\"stylesheet\" type=\"text/css\"\n" + "href=\"" + CSS_FILE + "\">\n" |
| | | + "<link rel=\"shortcut icon\" href=\"" + FAVICON + "\">\n" |
| | | + "<meta name=\"date generated\" content=\"" + Now + "\">\n" + "</head>\n"); |
| | | + "<link rel=\"shortcut icon\" href=\"" + FAVICON + "\">\n" + "<meta name=\"date generated\" content=\"" |
| | | + NOW + "\">\n" + "</head>\n"); |
| | | } |
| | | |
| | | // Add a Tab Menu, the active tab is the one given as parameter |
| | | private void tabMenu(String activeTab) { |
| | | // @Checkstyle:off |
| | | htmlBuff.append("<div class=\"tabmenu\"> " + |
| | | |
| | | "<span><a " + (activeTab.equals(INHERITANCE_TREE_FILE) ? "class=\"activetab\" " : "") + "href=\"" |
| | |
| | | "<span><a " + (activeTab.equals(RELATION_TREE_FILE) ? "class=\"activetab\" " : "") + "href=\"" |
| | | + RELATION_TREE_FILE + "\"" + " title=\"Relational View of Components\">Structure</a></span> " + |
| | | |
| | | "<span><a " + (activeTab.equals(MO_LIST_FILE) ? "class=\"activetab\" " : "") + "href=\"" |
| | | + MO_LIST_FILE + "\"" + " title=\"Alphabetical Index of Components\">Components</a></span> " + |
| | | "<span><a " + (activeTab.equals(MO_LIST_FILE) ? "class=\"activetab\" " : "") + "href=\"" + MO_LIST_FILE |
| | | + "\"" + " title=\"Alphabetical Index of Components\">Components</a></span> " + |
| | | |
| | | "<span><a " + (activeTab.equals(PROPERTIES_INDEX_FILE) ? "class=\"activetab\" " : "") + "href=\"" |
| | | + PROPERTIES_INDEX_FILE + "\"" + " title=\"Alphabetical Index of Properties\" >Properties</a></span>" |
| | | + |
| | | + PROPERTIES_INDEX_FILE + "\"" + " title=\"Alphabetical Index of Properties\" >Properties</a></span>" + |
| | | |
| | | "</div>" + "\n"); |
| | | // @Checkstyle:on |
| | | } |
| | | |
| | | private String getLink(String str, String link) { |
| | |
| | | private void generateFile(String fileName) { |
| | | // Write the html buffer in a file |
| | | try { |
| | | PrintWriter file = new java.io.PrintWriter(new java.io.FileWriter(generationDir + File.separator |
| | | + fileName)); |
| | | PrintWriter file = |
| | | new java.io.PrintWriter(new java.io.FileWriter(generationDir + File.separator + fileName)); |
| | | file.write(htmlBuff.toString()); |
| | | file.close(); |
| | | } catch (Exception e) { |
| | |
| | | // Relation List from RootConfiguration |
| | | private final TreeMap<String, RelationDefinition> topRelList = new TreeMap<String, RelationDefinition>(); |
| | | private final TreeMap<String, RelationDefinition> relList = new TreeMap<String, RelationDefinition>(); |
| | | private final TreeMap<String, TreeMap<String, RelationDefinition>> catTopRelList = new TreeMap<String, TreeMap<String, RelationDefinition>>(); |
| | | private final TreeMap<String, TreeMap<String, RelationDefinition>> catTopRelList = |
| | | new TreeMap<String, TreeMap<String, RelationDefinition>>(); |
| | | // managed object list |
| | | private final TreeMap<String, AbstractManagedObjectDefinition> moList = new TreeMap<String, AbstractManagedObjectDefinition>(); |
| | | private final TreeMap<String, AbstractManagedObjectDefinition> topMoList = new TreeMap<String, AbstractManagedObjectDefinition>(); |
| | | private final TreeMap<String, TreeMap<String, AbstractManagedObjectDefinition>> catTopMoList = new TreeMap<String, TreeMap<String, AbstractManagedObjectDefinition>>(); |
| | | private final TreeMap<String, AbstractManagedObjectDefinition> moList = |
| | | new TreeMap<String, AbstractManagedObjectDefinition>(); |
| | | private final TreeMap<String, AbstractManagedObjectDefinition> topMoList = |
| | | new TreeMap<String, AbstractManagedObjectDefinition>(); |
| | | private final TreeMap<String, TreeMap<String, AbstractManagedObjectDefinition>> catTopMoList = |
| | | new TreeMap<String, TreeMap<String, AbstractManagedObjectDefinition>>(); |
| | | private final int ind = 0; |
| | | private StringBuffer htmlBuff = new StringBuffer(); |
| | | private static String generationDir; |
| | | private static boolean ldapMapping = false; |
| | | private static String OpenDJWiki; |
| | | private static String OpenDJHome; |
| | | private static String openDJWiki; |
| | | private static String openDJHome; |
| | | private static String aciSyntaxPage; |
| | | private static String durationSyntaxPage; |
| | | private boolean inList = false; |
| | |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | |
| | | |
| | | /** |
| | | * Common administration classes. |
| | | * <p> |
| | |
| | | /** The managed object path. */ |
| | | private final ManagedObjectPath<?, S> path; |
| | | |
| | | /** Repository of configuration entries */ |
| | | /** Repository of configuration entries. */ |
| | | private final ConfigurationRepository configRepository; |
| | | |
| | | private final ServerManagementContext serverContext; |
| | |
| | | * Copyright 2007-2008 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.admin.server; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | |
| | | |
| | | import java.util.List; |
| | | |
| | | import org.opends.server.admin.Configuration; |
| | | import org.opends.server.types.ConfigChangeResult; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This interface defines the methods that a Directory Server |
| | | * configurable component should implement if it wishes to be able to |
| | | * receive notifications when a new configuration is added. |
| | | * This interface defines the methods that a Directory Server configurable |
| | | * component should implement if it wishes to be able to receive notifications |
| | | * when a new configuration is added. |
| | | * |
| | | * @param <T> |
| | | * The type of configuration that this listener should be |
| | | * notified about. |
| | | * The type of configuration that this listener should be notified |
| | | * about. |
| | | */ |
| | | public interface ConfigurationAddListener<T extends Configuration> { |
| | | |
| | |
| | | * @param unacceptableReasons |
| | | * A list that can be used to hold messages about why the |
| | | * provided configuration is not acceptable. |
| | | * @return Returns <code>true</code> if the proposed addition is |
| | | * acceptable, or <code>false</code> if it is not. |
| | | * @return Returns <code>true</code> if the proposed addition is acceptable, |
| | | * or <code>false</code> if it is not. |
| | | */ |
| | | public boolean isConfigurationAddAcceptable(T configuration, |
| | | List<LocalizableMessage> unacceptableReasons); |
| | | |
| | | |
| | | public boolean isConfigurationAddAcceptable(T configuration, List<LocalizableMessage> unacceptableReasons); |
| | | |
| | | /** |
| | | * Adds a new configuration to this add listener. |
| | | * |
| | | * @param configuration |
| | | * The configuration that will be added. |
| | | * @return Returns information about the result of adding the |
| | | * configuration. |
| | | * @return Returns information about the result of adding the configuration. |
| | | */ |
| | | public ConfigChangeResult applyConfigurationAdd(T configuration); |
| | | } |
| | |
| | | * @param addListener |
| | | * The add listener to be added to the subordinate entry when it |
| | | * is added. |
| | | * @param configRepository TODO |
| | | * @param configRepository |
| | | * Repository of config entries. |
| | | */ |
| | | public DelayedConfigAddListener(DN child, ConfigAddListener addListener, ConfigurationRepository configRepository) { |
| | | this.parent = child.parent(); |
| | |
| | | * @param deleteListener |
| | | * The delete listener to be added to the subordinate entry when |
| | | * it is added. |
| | | * @param configRepository TODO |
| | | * @param configRepository |
| | | * Repository of config entries. |
| | | */ |
| | | public DelayedConfigAddListener(DN child, ConfigDeleteListener deleteListener, ConfigurationRepository configRepository) { |
| | | public DelayedConfigAddListener(DN child, ConfigDeleteListener deleteListener, |
| | | ConfigurationRepository configRepository) { |
| | | this.parent = child.parent(); |
| | | this.child = child; |
| | | this.delayedAddListener = null; |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationAdd(Entry configEntry) { |
| | | if (configEntry.getName().equals(child)) { |
| | | // The subordinate entry matched our criteria so register the |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean configAddIsAcceptable(Entry configEntry, LocalizableMessageBuilder unacceptableReason) { |
| | | // Always acceptable. |
| | | return true; |
| | |
| | | |
| | | private final ManagedObjectDefinition<?, S> definition; |
| | | |
| | | /** The managed object path identifying this managed object's location */ |
| | | /** The managed object path identifying this managed object's location. */ |
| | | private final ManagedObjectPath<?, S> path; |
| | | |
| | | private final Map<PropertyDefinition<?>, SortedSet<?>> properties; |
| | |
| | | * with this managed object's definition. |
| | | */ |
| | | public <M extends Configuration> void deregisterAddListener(InstantiableRelationDefinition<?, M> d, |
| | | ConfigurationAddListener<M> listener) throws IllegalArgumentException { |
| | | ConfigurationAddListener<M> listener) { |
| | | validateRelationDefinition(d); |
| | | DN baseDN = DNBuilder.create(path, d); |
| | | deregisterAddListener(baseDN, listener); |
| | |
| | | * with this managed object's definition. |
| | | */ |
| | | public <M extends Configuration> void deregisterAddListener(InstantiableRelationDefinition<?, M> d, |
| | | ServerManagedObjectAddListener<M> listener) throws IllegalArgumentException { |
| | | ServerManagedObjectAddListener<M> listener) { |
| | | validateRelationDefinition(d); |
| | | DN baseDN = DNBuilder.create(path, d); |
| | | deregisterAddListener(baseDN, listener); |
| | |
| | | * this managed object's definition. |
| | | */ |
| | | public <M extends Configuration> void deregisterAddListener(OptionalRelationDefinition<?, M> d, |
| | | ConfigurationAddListener<M> listener) throws IllegalArgumentException { |
| | | ConfigurationAddListener<M> listener) { |
| | | validateRelationDefinition(d); |
| | | DN baseDN = DNBuilder.create(path, d).parent(); |
| | | deregisterAddListener(baseDN, listener); |
| | |
| | | * this managed object's definition. |
| | | */ |
| | | public <M extends Configuration> void deregisterAddListener(OptionalRelationDefinition<?, M> d, |
| | | ServerManagedObjectAddListener<M> listener) throws IllegalArgumentException { |
| | | ServerManagedObjectAddListener<M> listener) { |
| | | validateRelationDefinition(d); |
| | | DN baseDN = DNBuilder.create(path, d).parent(); |
| | | deregisterAddListener(baseDN, listener); |
| | |
| | | * managed object's definition. |
| | | */ |
| | | public <M extends Configuration> void deregisterAddListener(SetRelationDefinition<?, M> d, |
| | | ConfigurationAddListener<M> listener) throws IllegalArgumentException { |
| | | ConfigurationAddListener<M> listener) { |
| | | validateRelationDefinition(d); |
| | | DN baseDN = DNBuilder.create(path, d); |
| | | deregisterAddListener(baseDN, listener); |
| | |
| | | * managed object's definition. |
| | | */ |
| | | public <M extends Configuration> void deregisterAddListener(SetRelationDefinition<?, M> d, |
| | | ServerManagedObjectAddListener<M> listener) throws IllegalArgumentException { |
| | | ServerManagedObjectAddListener<M> listener) { |
| | | validateRelationDefinition(d); |
| | | DN baseDN = DNBuilder.create(path, d); |
| | | deregisterAddListener(baseDN, listener); |
| | |
| | | ConfigChangeListenerAdaptor<?> adaptor = (ConfigChangeListenerAdaptor<?>) l; |
| | | ServerManagedObjectChangeListener<?> l2 = adaptor.getServerManagedObjectChangeListener(); |
| | | if (l2 instanceof ServerManagedObjectChangeListenerAdaptor<?>) { |
| | | ServerManagedObjectChangeListenerAdaptor<?> adaptor2 = (ServerManagedObjectChangeListenerAdaptor<?>) l2; |
| | | ServerManagedObjectChangeListenerAdaptor<?> adaptor2 = |
| | | (ServerManagedObjectChangeListenerAdaptor<?>) l2; |
| | | if (adaptor2.getConfigurationChangeListener() == listener) { |
| | | adaptor.finalizeChangeListener(); |
| | | configRepository.deregisterChangeListener(configDN, adaptor); |
| | |
| | | * with this managed object's definition. |
| | | */ |
| | | public <M extends Configuration> void deregisterDeleteListener(InstantiableRelationDefinition<?, M> d, |
| | | ConfigurationDeleteListener<M> listener) throws IllegalArgumentException { |
| | | ConfigurationDeleteListener<M> listener) { |
| | | validateRelationDefinition(d); |
| | | |
| | | DN baseDN = DNBuilder.create(path, d); |
| | |
| | | * with this managed object's definition. |
| | | */ |
| | | public <M extends Configuration> void deregisterDeleteListener(InstantiableRelationDefinition<?, M> d, |
| | | ServerManagedObjectDeleteListener<M> listener) throws IllegalArgumentException { |
| | | ServerManagedObjectDeleteListener<M> listener) { |
| | | validateRelationDefinition(d); |
| | | |
| | | DN baseDN = DNBuilder.create(path, d); |
| | |
| | | * this managed object's definition. |
| | | */ |
| | | public <M extends Configuration> void deregisterDeleteListener(OptionalRelationDefinition<?, M> d, |
| | | ConfigurationDeleteListener<M> listener) throws IllegalArgumentException { |
| | | ConfigurationDeleteListener<M> listener) { |
| | | validateRelationDefinition(d); |
| | | |
| | | DN baseDN = DNBuilder.create(path, d).parent(); |
| | |
| | | * this managed object's definition. |
| | | */ |
| | | public <M extends Configuration> void deregisterDeleteListener(OptionalRelationDefinition<?, M> d, |
| | | ServerManagedObjectDeleteListener<M> listener) throws IllegalArgumentException { |
| | | ServerManagedObjectDeleteListener<M> listener) { |
| | | validateRelationDefinition(d); |
| | | |
| | | DN baseDN = DNBuilder.create(path, d).parent(); |
| | |
| | | * managed object's definition. |
| | | */ |
| | | public <M extends Configuration> void deregisterDeleteListener(SetRelationDefinition<?, M> d, |
| | | ConfigurationDeleteListener<M> listener) throws IllegalArgumentException { |
| | | ConfigurationDeleteListener<M> listener) { |
| | | validateRelationDefinition(d); |
| | | |
| | | DN baseDN = DNBuilder.create(path, d); |
| | |
| | | * managed object's definition. |
| | | */ |
| | | public <M extends Configuration> void deregisterDeleteListener(SetRelationDefinition<?, M> d, |
| | | ServerManagedObjectDeleteListener<M> listener) throws IllegalArgumentException { |
| | | ServerManagedObjectDeleteListener<M> listener) { |
| | | validateRelationDefinition(d); |
| | | |
| | | DN baseDN = DNBuilder.create(path, d); |
| | |
| | | * not be decoded. |
| | | */ |
| | | public <M extends Configuration> ServerManagedObject<? extends M> getChild(InstantiableRelationDefinition<?, M> d, |
| | | String name) throws IllegalArgumentException, ConfigException { |
| | | String name) throws ConfigException { |
| | | validateRelationDefinition(d); |
| | | return serverContext.getManagedObject(path.child(d, name)); |
| | | } |
| | |
| | | * not be decoded. |
| | | */ |
| | | public <M extends Configuration> ServerManagedObject<? extends M> getChild(OptionalRelationDefinition<?, M> d) |
| | | throws IllegalArgumentException, ConfigException { |
| | | throws ConfigException { |
| | | validateRelationDefinition(d); |
| | | return serverContext.getManagedObject(path.child(d)); |
| | | } |
| | |
| | | * not be decoded. |
| | | */ |
| | | public <M extends Configuration> ServerManagedObject<? extends M> getChild(SetRelationDefinition<?, M> d, |
| | | String name) throws IllegalArgumentException, ConfigException { |
| | | String name) throws ConfigException { |
| | | validateRelationDefinition(d); |
| | | |
| | | return serverContext.getManagedObject(path.child(d, name)); |
| | |
| | | * not be decoded. |
| | | */ |
| | | public <M extends Configuration> ServerManagedObject<? extends M> getChild(SingletonRelationDefinition<?, M> d) |
| | | throws IllegalArgumentException, ConfigException { |
| | | throws ConfigException { |
| | | validateRelationDefinition(d); |
| | | return serverContext.getManagedObject(path.child(d)); |
| | | } |
| | |
| | | * If the property definition is not associated with this |
| | | * managed object's definition. |
| | | */ |
| | | public <T> T getPropertyValue(PropertyDefinition<T> d) throws IllegalArgumentException { |
| | | public <T> T getPropertyValue(PropertyDefinition<T> d) { |
| | | Set<T> values = getPropertyValues(d); |
| | | if (values.isEmpty()) { |
| | | return null; |
| | |
| | | * managed object's definition. |
| | | */ |
| | | @SuppressWarnings("unchecked") |
| | | public <T> SortedSet<T> getPropertyValues(PropertyDefinition<T> d) throws IllegalArgumentException { |
| | | public <T> SortedSet<T> getPropertyValues(PropertyDefinition<T> d) { |
| | | if (!properties.containsKey(d)) { |
| | | throw new IllegalArgumentException("Unknown property " + d.getName()); |
| | | } |
| | |
| | | * If the optional relation definition is not associated with |
| | | * this managed object's definition. |
| | | */ |
| | | public boolean hasChild(OptionalRelationDefinition<?, ?> d) throws IllegalArgumentException { |
| | | public boolean hasChild(OptionalRelationDefinition<?, ?> d) { |
| | | validateRelationDefinition(d); |
| | | return serverContext.managedObjectExists(path.child(d)); |
| | | } |
| | |
| | | * If the relation definition is not associated with this |
| | | * managed object's definition. |
| | | */ |
| | | public String[] listChildren(InstantiableRelationDefinition<?, ?> d) throws IllegalArgumentException { |
| | | public String[] listChildren(InstantiableRelationDefinition<?, ?> d) { |
| | | validateRelationDefinition(d); |
| | | return serverContext.listManagedObjects(path, d); |
| | | } |
| | |
| | | * If the relation definition is not associated with this |
| | | * managed object's definition. |
| | | */ |
| | | public String[] listChildren(SetRelationDefinition<?, ?> d) throws IllegalArgumentException { |
| | | public String[] listChildren(SetRelationDefinition<?, ?> d) { |
| | | validateRelationDefinition(d); |
| | | return serverContext.listManagedObjects(path, d); |
| | | } |
| | |
| | | * relation could not be retrieved. |
| | | */ |
| | | public <M extends Configuration> void registerAddListener(InstantiableRelationDefinition<?, M> d, |
| | | ConfigurationAddListener<M> listener) throws IllegalArgumentException, ConfigException { |
| | | ConfigurationAddListener<M> listener) throws ConfigException { |
| | | registerAddListener(d, new ServerManagedObjectAddListenerAdaptor<M>(listener)); |
| | | } |
| | | |
| | |
| | | * relation could not be retrieved. |
| | | */ |
| | | public <M extends Configuration> void registerAddListener(InstantiableRelationDefinition<?, M> d, |
| | | ServerManagedObjectAddListener<M> listener) throws IllegalArgumentException, ConfigException { |
| | | ServerManagedObjectAddListener<M> listener) throws ConfigException { |
| | | validateRelationDefinition(d); |
| | | DN baseDN = DNBuilder.create(path, d); |
| | | ConfigAddListener adaptor = new ConfigAddListenerAdaptor<M>(serverContext, path, d, listener); |
| | |
| | | * relation could not be retrieved. |
| | | */ |
| | | public <M extends Configuration> void registerAddListener(OptionalRelationDefinition<?, M> d, |
| | | ConfigurationAddListener<M> listener) throws IllegalArgumentException, ConfigException { |
| | | ConfigurationAddListener<M> listener) throws ConfigException { |
| | | registerAddListener(d, new ServerManagedObjectAddListenerAdaptor<M>(listener)); |
| | | } |
| | | |
| | |
| | | * relation could not be retrieved. |
| | | */ |
| | | public <M extends Configuration> void registerAddListener(OptionalRelationDefinition<?, M> d, |
| | | ServerManagedObjectAddListener<M> listener) throws IllegalArgumentException, ConfigException { |
| | | ServerManagedObjectAddListener<M> listener) throws ConfigException { |
| | | validateRelationDefinition(d); |
| | | DN baseDN = DNBuilder.create(path, d).parent(); |
| | | ConfigAddListener adaptor = new ConfigAddListenerAdaptor<M>(serverContext, path, d, listener); |
| | |
| | | * could not be retrieved. |
| | | */ |
| | | public <M extends Configuration> void registerAddListener(SetRelationDefinition<?, M> d, |
| | | ConfigurationAddListener<M> listener) throws IllegalArgumentException, ConfigException { |
| | | ConfigurationAddListener<M> listener) throws ConfigException { |
| | | registerAddListener(d, new ServerManagedObjectAddListenerAdaptor<M>(listener)); |
| | | } |
| | | |
| | |
| | | * could not be retrieved. |
| | | */ |
| | | public <M extends Configuration> void registerAddListener(SetRelationDefinition<?, M> d, |
| | | ServerManagedObjectAddListener<M> listener) throws IllegalArgumentException, ConfigException { |
| | | ServerManagedObjectAddListener<M> listener) throws ConfigException { |
| | | validateRelationDefinition(d); |
| | | DN baseDN = DNBuilder.create(path, d); |
| | | ConfigAddListener adaptor = new ConfigAddListenerAdaptor<M>(serverContext, path, d, listener); |
| | |
| | | * relation could not be retrieved. |
| | | */ |
| | | public <M extends Configuration> void registerDeleteListener(InstantiableRelationDefinition<?, M> d, |
| | | ConfigurationDeleteListener<M> listener) throws IllegalArgumentException, ConfigException { |
| | | ConfigurationDeleteListener<M> listener) throws ConfigException { |
| | | registerDeleteListener(d, new ServerManagedObjectDeleteListenerAdaptor<M>(listener)); |
| | | } |
| | | |
| | |
| | | * relation could not be retrieved. |
| | | */ |
| | | public <M extends Configuration> void registerDeleteListener(InstantiableRelationDefinition<?, M> d, |
| | | ServerManagedObjectDeleteListener<M> listener) throws IllegalArgumentException, ConfigException { |
| | | ServerManagedObjectDeleteListener<M> listener) throws ConfigException { |
| | | validateRelationDefinition(d); |
| | | DN baseDN = DNBuilder.create(path, d); |
| | | ConfigDeleteListener adaptor = new ConfigDeleteListenerAdaptor<M>(serverContext, path, d, listener); |
| | |
| | | * relation could not be retrieved. |
| | | */ |
| | | public <M extends Configuration> void registerDeleteListener(OptionalRelationDefinition<?, M> d, |
| | | ConfigurationDeleteListener<M> listener) throws IllegalArgumentException, ConfigException { |
| | | ConfigurationDeleteListener<M> listener) throws ConfigException { |
| | | registerDeleteListener(d, new ServerManagedObjectDeleteListenerAdaptor<M>(listener)); |
| | | } |
| | | |
| | |
| | | * relation could not be retrieved. |
| | | */ |
| | | public <M extends Configuration> void registerDeleteListener(OptionalRelationDefinition<?, M> d, |
| | | ServerManagedObjectDeleteListener<M> listener) throws IllegalArgumentException, ConfigException { |
| | | ServerManagedObjectDeleteListener<M> listener) throws ConfigException { |
| | | validateRelationDefinition(d); |
| | | DN baseDN = DNBuilder.create(path, d).parent(); |
| | | ConfigDeleteListener adaptor = new ConfigDeleteListenerAdaptor<M>(serverContext, path, d, listener); |
| | |
| | | * could not be retrieved. |
| | | */ |
| | | public <M extends Configuration> void registerDeleteListener(SetRelationDefinition<?, M> d, |
| | | ConfigurationDeleteListener<M> listener) throws IllegalArgumentException, ConfigException { |
| | | ConfigurationDeleteListener<M> listener) throws ConfigException { |
| | | registerDeleteListener(d, new ServerManagedObjectDeleteListenerAdaptor<M>(listener)); |
| | | } |
| | | |
| | |
| | | * could not be retrieved. |
| | | */ |
| | | public <M extends Configuration> void registerDeleteListener(SetRelationDefinition<?, M> d, |
| | | ServerManagedObjectDeleteListener<M> listener) throws IllegalArgumentException, ConfigException { |
| | | ServerManagedObjectDeleteListener<M> listener) throws ConfigException { |
| | | validateRelationDefinition(d); |
| | | DN baseDN = DNBuilder.create(path, d); |
| | | ConfigDeleteListener adaptor = new ConfigDeleteListenerAdaptor<M>(serverContext, path, d, listener); |
| | |
| | | ConfigAddListenerAdaptor<?> adaptor = (ConfigAddListenerAdaptor<?>) configListener; |
| | | ServerManagedObjectAddListener<?> smoListener = adaptor.getServerManagedObjectAddListener(); |
| | | if (smoListener instanceof ServerManagedObjectAddListenerAdaptor<?>) { |
| | | ServerManagedObjectAddListenerAdaptor<?> adaptor2 = (ServerManagedObjectAddListenerAdaptor<?>) smoListener; |
| | | ServerManagedObjectAddListenerAdaptor<?> adaptor2 = |
| | | (ServerManagedObjectAddListenerAdaptor<?>) smoListener; |
| | | if (adaptor2.getConfigurationAddListener() == listener) { |
| | | configRepository.deregisterAddListener(baseDN, adaptor); |
| | | } |
| | |
| | | } |
| | | |
| | | // Deregister an add listener. |
| | | private <M extends Configuration> void deregisterAddListener(DN baseDN, ServerManagedObjectAddListener<M> listener) { |
| | | private <M extends Configuration> void deregisterAddListener(DN baseDN, |
| | | ServerManagedObjectAddListener<M> listener) { |
| | | try { |
| | | if (configRepository.hasEntry(baseDN)) { |
| | | for (ConfigAddListener configListener : configRepository.getAddListeners(baseDN)) { |
| | |
| | | * @return a pair of (intermediate adaptor, intermediate listener) or |
| | | * {@code Pair.EMPTY} if listener can't be extracted |
| | | */ |
| | | // @Checkstyle:off |
| | | static <T extends Configuration> Pair<ConfigAddListenerAdaptor<T>, ConfigurationAddListener<T>> |
| | | extractInitialListener(ConfigAddListener configListener) { |
| | | // @Checkstyle:on |
| | | Pair<ConfigAddListenerAdaptor<T>, ServerManagedObjectAddListener<T>> pair = |
| | | extractIntermediateListener(configListener); |
| | | if (!pair.equals(Pair.EMPTY) && pair.getSecond() instanceof ServerManagedObjectAddListenerAdaptor) { |
| | |
| | | * {@code Pair.EMPTY} if listener can't be extracted |
| | | */ |
| | | @SuppressWarnings("unchecked") |
| | | // @Checkstyle:off |
| | | static <T extends Configuration> Pair<ConfigAddListenerAdaptor<T>, ServerManagedObjectAddListener<T>> |
| | | extractIntermediateListener(ConfigAddListener configListener) { |
| | | // @Checkstyle:on |
| | | if (configListener instanceof ConfigAddListenerAdaptor) { |
| | | ConfigAddListenerAdaptor<T> adaptor = ((ConfigAddListenerAdaptor<T>) configListener); |
| | | return Pair.of(adaptor, adaptor.getServerManagedObjectAddListener()); |
| | |
| | | } |
| | | |
| | | // Deregister a delete listener. |
| | | private <M extends Configuration> void deregisterDeleteListener(DN baseDN, ConfigurationDeleteListener<M> listener) { |
| | | private <M extends Configuration> void deregisterDeleteListener(DN baseDN, |
| | | ConfigurationDeleteListener<M> listener) { |
| | | try { |
| | | if (configRepository.hasEntry(baseDN)) { |
| | | for (ConfigDeleteListener l : configRepository.getDeleteListeners(baseDN)) { |
| | |
| | | ConfigDeleteListenerAdaptor<?> adaptor = (ConfigDeleteListenerAdaptor<?>) l; |
| | | ServerManagedObjectDeleteListener<?> l2 = adaptor.getServerManagedObjectDeleteListener(); |
| | | if (l2 instanceof ServerManagedObjectDeleteListenerAdaptor<?>) { |
| | | ServerManagedObjectDeleteListenerAdaptor<?> adaptor2 = (ServerManagedObjectDeleteListenerAdaptor<?>) l2; |
| | | ServerManagedObjectDeleteListenerAdaptor<?> adaptor2 = |
| | | (ServerManagedObjectDeleteListenerAdaptor<?>) l2; |
| | | if (adaptor2.getConfigurationDeleteListener() == listener) { |
| | | configRepository.deregisterDeleteListener(baseDN, adaptor); |
| | | } |
| | |
| | | } |
| | | |
| | | // Register an instantiable or optional relation add listener. |
| | | private void registerAddListener(DN baseDN, ConfigAddListener adaptor) throws IllegalArgumentException, |
| | | private void registerAddListener(DN baseDN, ConfigAddListener adaptor) throws |
| | | ConfigException { |
| | | if (configRepository.hasEntry(baseDN)) { |
| | | configRepository.registerAddListener(baseDN, adaptor); |
| | |
| | | |
| | | // Deregister a delayed listener with the nearest existing parent |
| | | // entry to the provided base DN. |
| | | private <M extends Configuration> void deregisterDelayedAddListener(DN baseDN, ConfigurationAddListener<M> listener) |
| | | throws ConfigException { |
| | | private <M extends Configuration> void deregisterDelayedAddListener(DN baseDN, |
| | | ConfigurationAddListener<M> listener) throws ConfigException { |
| | | DN parentDN = baseDN.parent(); |
| | | int delayWrappers = 0; |
| | | while (parentDN != null) { |
| | |
| | | ConfigAddListenerAdaptor<?> adaptor = (ConfigAddListenerAdaptor<?>) delayedListener; |
| | | ServerManagedObjectAddListener<?> l2 = adaptor.getServerManagedObjectAddListener(); |
| | | if (l2 instanceof ServerManagedObjectAddListenerAdaptor<?>) { |
| | | ServerManagedObjectAddListenerAdaptor<?> adaptor2 = (ServerManagedObjectAddListenerAdaptor<?>) l2; |
| | | ServerManagedObjectAddListenerAdaptor<?> adaptor2 = |
| | | (ServerManagedObjectAddListenerAdaptor<?>) l2; |
| | | if (adaptor2.getConfigurationAddListener() == listener) { |
| | | configRepository.deregisterAddListener(parentDN, configListener); |
| | | } |
| | |
| | | ConfigDeleteListenerAdaptor<?> adaptor = (ConfigDeleteListenerAdaptor<?>) delayedListener; |
| | | ServerManagedObjectDeleteListener<?> l2 = adaptor.getServerManagedObjectDeleteListener(); |
| | | if (l2 instanceof ServerManagedObjectDeleteListenerAdaptor<?>) { |
| | | ServerManagedObjectDeleteListenerAdaptor<?> adaptor2 = (ServerManagedObjectDeleteListenerAdaptor<?>) l2; |
| | | ServerManagedObjectDeleteListenerAdaptor<?> adaptor2 = |
| | | (ServerManagedObjectDeleteListenerAdaptor<?>) l2; |
| | | if (adaptor2.getConfigurationDeleteListener() == listener) { |
| | | configRepository.deregisterAddListener(parentDN, l); |
| | | } |
| | |
| | | |
| | | // Validate that a relation definition belongs to this managed |
| | | // object. |
| | | private void validateRelationDefinition(RelationDefinition<?, ?> rd) throws IllegalArgumentException { |
| | | private void validateRelationDefinition(RelationDefinition<?, ?> rd) { |
| | | RelationDefinition<?, ?> tmp = definition.getRelationDefinition(rd.getName()); |
| | | if (tmp != rd) { |
| | | throw new IllegalArgumentException("The relation " + rd.getName() + " is not associated with a " |
| | |
| | | * The type of server managed object that this listener should be |
| | | * notified about. |
| | | */ |
| | | final class ServerManagedObjectAddListenerAdaptor<T extends Configuration> implements ServerManagedObjectAddListener<T> { |
| | | final class ServerManagedObjectAddListenerAdaptor<T extends Configuration> implements |
| | | ServerManagedObjectAddListener<T> { |
| | | |
| | | // The underlying add listener. |
| | | private final ConfigurationAddListener<T> listener; |
| | |
| | | */ |
| | | package org.opends.server.admin.server; |
| | | |
| | | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | import java.util.List; |
| | |
| | | import org.opends.server.admin.Configuration; |
| | | import org.opends.server.types.ConfigChangeResult; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This interface defines the methods that a Directory Server |
| | | * configurable component should implement if it wishes to be able to |
| | | * receive notifications when a its associated server managed object |
| | | * is changed. |
| | | * This interface defines the methods that a Directory Server configurable |
| | | * component should implement if it wishes to be able to receive notifications |
| | | * when a its associated server managed object is changed. |
| | | * |
| | | * @param <T> |
| | | * The type of server managed object that this listener |
| | | * should be notified about. |
| | | * The type of server managed object that this listener should be |
| | | * notified about. |
| | | */ |
| | | public interface ServerManagedObjectChangeListener<T extends Configuration> { |
| | | |
| | | /** |
| | | * Indicates whether the proposed change to the server managed |
| | | * object is acceptable to this change listener. |
| | | * Indicates whether the proposed change to the server managed object is |
| | | * acceptable to this change listener. |
| | | * |
| | | * @param mo |
| | | * The new server managed object containing the changes. |
| | | * @param unacceptableReasons |
| | | * A list that can be used to hold messages about why the |
| | | * provided server managed object is not acceptable. |
| | | * @return Returns <code>true</code> if the proposed change is |
| | | * acceptable, or <code>false</code> if it is not. |
| | | * @return Returns <code>true</code> if the proposed change is acceptable, |
| | | * or <code>false</code> if it is not. |
| | | */ |
| | | public boolean isConfigurationChangeAcceptable( |
| | | ServerManagedObject<? extends T> mo, List<LocalizableMessage> unacceptableReasons); |
| | | |
| | | |
| | | public boolean isConfigurationChangeAcceptable(ServerManagedObject<? extends T> mo, |
| | | List<LocalizableMessage> unacceptableReasons); |
| | | |
| | | /** |
| | | * Applies the server managed object changes to this change |
| | | * listener. |
| | | * Applies the server managed object changes to this change listener. |
| | | * |
| | | * @param mo |
| | | * The new server managed object containing the changes. |
| | | * @return Returns information about the result of changing the |
| | | * server managed object. |
| | | * @return Returns information about the result of changing the server |
| | | * managed object. |
| | | */ |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | ServerManagedObject<? extends T> mo); |
| | | public ConfigChangeResult applyConfigurationChange(ServerManagedObject<? extends T> mo); |
| | | } |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationChange(ServerManagedObject<? extends T> mo) { |
| | | return listener.applyConfigurationChange(mo.getConfiguration()); |
| | | } |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isConfigurationChangeAcceptable(ServerManagedObject<? extends T> mo, |
| | | List<LocalizableMessage> unacceptableReasons) { |
| | | return listener.isConfigurationChangeAcceptable(mo.getConfiguration(), unacceptableReasons); |
| | |
| | | import org.opends.server.admin.RelationDefinition; |
| | | import org.opends.server.admin.RelativeInheritedDefaultBehaviorProvider; |
| | | import org.opends.server.admin.UndefinedDefaultBehaviorProvider; |
| | | import org.opends.server.admin.UnknownPropertyDefinitionException; |
| | | import org.opends.server.admin.DefinitionDecodingException.Reason; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.config.ConfigurationRepository; |
| | |
| | | * @param <T> |
| | | * The type of the property. |
| | | */ |
| | | private class DefaultValueFinder<T> implements DefaultBehaviorProviderVisitor<T, Collection<T>, Void> { |
| | | private final class DefaultValueFinder<T> implements DefaultBehaviorProviderVisitor<T, Collection<T>, Void> { |
| | | |
| | | // Any exception that occurred whilst retrieving inherited default |
| | | // values. |
| | |
| | | } |
| | | |
| | | // Find the default values for the next path/property. |
| | | private Collection<T> find(ManagedObjectPath<?, ?> path, PropertyDefinition<T> propertyDef) |
| | | throws DefaultBehaviorException { |
| | | private Collection<T> find(ManagedObjectPath<?, ?> path, PropertyDefinition<T> propertyDef) { |
| | | nextPath = path; |
| | | nextProperty = propertyDef; |
| | | |
| | |
| | | // Get an inherited property value. |
| | | @SuppressWarnings("unchecked") |
| | | private Collection<T> getInheritedProperty(ManagedObjectPath<?,?> target, |
| | | AbstractManagedObjectDefinition<?, ?> definition, String propertyName) |
| | | throws DefaultBehaviorException { |
| | | AbstractManagedObjectDefinition<?, ?> definition, String propertyName) { |
| | | // First check that the requested type of managed object |
| | | // corresponds to the path. |
| | | AbstractManagedObjectDefinition<?, ?> supr = target.getManagedObjectDefinition(); |
| | |
| | | * A definition resolver that determines the managed object definition from |
| | | * the object classes of a ConfigEntry. |
| | | */ |
| | | private class MyDefinitionResolver implements DefinitionResolver { |
| | | private final class MyDefinitionResolver implements DefinitionResolver { |
| | | |
| | | // The config entry. |
| | | private final Entry entry; |
| | |
| | | /** |
| | | * Decodes the provided property LDAP value. |
| | | * |
| | | * @param <PD> |
| | | * @param <P> |
| | | * The type of the property. |
| | | * @param propertyDef |
| | | * The property definition. |
| | |
| | | * If the property value could not be decoded because it was |
| | | * invalid. |
| | | */ |
| | | public static <PD> PD decode(PropertyDefinition<PD> propertyDef, String value) |
| | | throws IllegalPropertyValueStringException { |
| | | public static <P> P decode(PropertyDefinition<P> propertyDef, String value) { |
| | | return propertyDef.castValue(propertyDef.accept(new ValueDecoder(), value)); |
| | | } |
| | | |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public <T> Object visitUnknown(PropertyDefinition<T> d, String p) throws UnknownPropertyDefinitionException { |
| | | public <T> Object visitUnknown(PropertyDefinition<T> d, String p) { |
| | | // By default the property definition's decoder will do. |
| | | return d.decodeValue(p); |
| | | } |
| | |
| | | */ |
| | | private volatile ServerManagedObject<RootCfg> root; |
| | | |
| | | /** Repository of configuration entries */ |
| | | /** Repository of configuration entries. */ |
| | | private final ConfigurationRepository configRepository; |
| | | |
| | | /** |
| | |
| | | * @param <S> |
| | | * The type of server managed object configuration that the path |
| | | * definition refers to. |
| | | * @param <PD> |
| | | * @param <P> |
| | | * The type of the property to be retrieved. |
| | | * @param path |
| | | * The path of the managed object containing the property. |
| | |
| | | * If the named managed object could not be found or if it could |
| | | * not be decoded. |
| | | */ |
| | | public <C extends ConfigurationClient, S extends Configuration, PD> PD getPropertyValue( |
| | | ManagedObjectPath<C, S> path, PropertyDefinition<PD> pd) throws IllegalArgumentException, ConfigException, |
| | | PropertyException { |
| | | SortedSet<PD> values = getPropertyValues(path, pd); |
| | | public <C extends ConfigurationClient, S extends Configuration, P> P getPropertyValue( |
| | | ManagedObjectPath<C, S> path, PropertyDefinition<P> pd) throws ConfigException { |
| | | SortedSet<P> values = getPropertyValues(path, pd); |
| | | if (values.isEmpty()) { |
| | | return null; |
| | | } else { |
| | |
| | | * @param <S> |
| | | * The type of server managed object configuration that the path |
| | | * definition refers to. |
| | | * @param <PD> |
| | | * @param <P> |
| | | * The type of the property to be retrieved. |
| | | * @param path |
| | | * The path of the managed object containing the property. |
| | |
| | | * not be decoded. |
| | | */ |
| | | @SuppressWarnings("unchecked") |
| | | public <C extends ConfigurationClient, S extends Configuration, PD> SortedSet<PD> getPropertyValues( |
| | | ManagedObjectPath<C, S> path, PropertyDefinition<PD> propertyDef) throws IllegalArgumentException, ConfigException, |
| | | PropertyException { |
| | | public <C extends ConfigurationClient, S extends Configuration, P> SortedSet<P> getPropertyValues( |
| | | ManagedObjectPath<C, S> path, PropertyDefinition<P> propertyDef) throws ConfigException { |
| | | // Check that the requested property is from the definition |
| | | // associated with the path. |
| | | AbstractManagedObjectDefinition<C, S> definition = path.getManagedObjectDefinition(); |
| | |
| | | // Make sure we use the correct property definition, the |
| | | // provided one might have been overridden in the resolved |
| | | // definition. |
| | | propertyDef = (PropertyDefinition<PD>) managedObjDef.getPropertyDefinition(propertyDef.getName()); |
| | | propertyDef = (PropertyDefinition<P>) managedObjDef.getPropertyDefinition(propertyDef.getName()); |
| | | |
| | | List<String> attributeValues = getAttributeValues(managedObjDef, propertyDef, configEntry); |
| | | return decodeProperty(path.asSubType(managedObjDef), propertyDef, attributeValues, null); |
| | |
| | | * @return the root configuration server managed object |
| | | */ |
| | | public ServerManagedObject<RootCfg> getRootConfigurationManagedObject() { |
| | | // Use lazy initialisation because it needs a reference to this server context. |
| | | // Use lazy initialisation because it needs a reference to this server |
| | | // context. |
| | | ServerManagedObject<RootCfg> rootObject = root; |
| | | if (rootObject == null) { |
| | | synchronized(this) { |
| | | rootObject = root; |
| | | if (rootObject == null) { |
| | | root = rootObject = new ServerManagedObject<RootCfg>(ManagedObjectPath.emptyPath(), |
| | | RootCfgDefn.getInstance(), Collections.<PropertyDefinition<?>, SortedSet<?>> emptyMap(), |
| | | null, this); |
| | | root = rootObject = |
| | | new ServerManagedObject<RootCfg>(ManagedObjectPath.emptyPath(), |
| | | RootCfgDefn.getInstance(), Collections.<PropertyDefinition<?>, |
| | | SortedSet<?>> emptyMap(), null, this); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | /** Decode a property using the provided attribute values. */ |
| | | private <T> SortedSet<T> decodeProperty(ManagedObjectPath<?, ?> path, PropertyDefinition<T> propertyDef, |
| | | List<String> attributeValues, Entry newConfigEntry) throws PropertyException { |
| | | List<String> attributeValues, Entry newConfigEntry) { |
| | | PropertyException exception = null; |
| | | SortedSet<T> pvalues = new TreeSet<T>(propertyDef); |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | /** Gets the attribute values associated with a property from a ConfigEntry */ |
| | | /** Gets the attribute values associated with a property from a ConfigEntry. */ |
| | | private List<String> getAttributeValues(ManagedObjectDefinition<?, ?> d, PropertyDefinition<?> pd, |
| | | Entry configEntry) { |
| | | // TODO: we create a default attribute type if it is undefined. |
| | |
| | | |
| | | // Get the default values for the specified property. |
| | | private <T> Collection<T> getDefaultValues(ManagedObjectPath<?, ?> p, PropertyDefinition<T> pd, |
| | | Entry newConfigEntry) throws DefaultBehaviorException { |
| | | Entry newConfigEntry) { |
| | | DefaultValueFinder<T> v = new DefaultValueFinder<T>(newConfigEntry); |
| | | return v.find(p, pd); |
| | | } |
| | |
| | | } |
| | | |
| | | // Validate that a relation definition belongs to the path. |
| | | private void validateRelationDefinition(ManagedObjectPath<?, ?> path, RelationDefinition<?, ?> rd) |
| | | throws IllegalArgumentException { |
| | | private void validateRelationDefinition(ManagedObjectPath<?, ?> path, RelationDefinition<?, ?> rd) { |
| | | AbstractManagedObjectDefinition<?, ?> d = path.getManagedObjectDefinition(); |
| | | RelationDefinition<?, ?> tmp = d.getRelationDefinition(rd.getName()); |
| | | if (tmp != rd) { |
| 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 legal-notices/CDDLv1_0.txt |
| | | * or http://forgerock.org/license/CDDLv1.0.html. |
| | | * 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 legal-notices/CDDLv1_0.txt. |
| | | * 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 |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | /** |
| | | * Contains a number of API declarations for use throughout the |
| | | * Directory Server. Whenever possible, these APIs should be declared |
| | | * using abstract classes rather than interfaces so that they can be |
| | | * altered in future versions without impacting backward |
| | | * compatibility. |
| | | * <BR><BR> |
| | | * Note that the mere existence of a class or interface in this |
| | | * package does not in itself imply that it is intended for use by |
| | | * third party code. Please refer to the official product |
| | | * documentation to indicate which APIs may be safely used by anyone |
| | | * other than the core Directory Server developers. Failure to heed |
| | | * this warning may result in code that could have unintended side |
| | | * effects or that does not work properly across different Directory |
| | | * Server versions. |
| | | */ |
| | | package org.opends.server.api; |
| | | |
| | |
| | | throw new RuntimeException("This class is not implemented"); |
| | | } |
| | | |
| | | public static Aci decode(ByteString valueOf, DN rootDN) throws AciException { |
| | | /** |
| | | * Decode an ACI byte string. |
| | | * |
| | | * @param byteString |
| | | * The ByteString containing the ACI string. |
| | | * @param dn |
| | | * DN of the ACI entry. |
| | | * @return Returns a decoded ACI representing the string argument. |
| | | * @throws AciException |
| | | * If the parsing of the ACI string fails. |
| | | */ |
| | | public static Aci decode(ByteString byteString, DN dn) throws AciException { |
| | | throw new RuntimeException("This class is not implemented"); |
| | | } |
| | | } |
| | |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.authorization.dseecompat; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.server.types.IdentifiedException; |
| | | |
| | | |
| | | /** |
| | | * The AciException class defines an exception that may be thrown |
| | | * either during ACI syntax verification of an "aci" attribute type value |
| | | * or during evaluation of an LDAP operation using a set of applicable |
| | | * ACIs. |
| | | * The AciException class defines an exception that may be thrown either during |
| | | * ACI syntax verification of an "aci" attribute type value or during evaluation |
| | | * of an LDAP operation using a set of applicable ACIs. |
| | | */ |
| | | public class AciException extends IdentifiedException { |
| | | /** |
| | | * The serial version identifier required to satisfy the compiler because this |
| | | * class extends <CODE>java.lang.Exception</CODE>, which implements the |
| | | * The serial version identifier required to satisfy the compiler because |
| | | * this class extends <CODE>java.lang.Exception</CODE>, which implements the |
| | | * <CODE>java.io.Serializable</CODE> interface. This value was generated |
| | | * using the <CODE>serialver</CODE> command-line utility included with the |
| | | * Java SDK. |
| | |
| | | /** |
| | | * Creates a new ACI exception with the provided message. |
| | | * |
| | | * @param message The message to use for this ACI exception. |
| | | * @param message |
| | | * The message to use for this ACI exception. |
| | | */ |
| | | public AciException(LocalizableMessage message) { |
| | | super(message); |
| | | } |
| | | |
| | | /** |
| | | * Creates a new ACI exception with the provided message and root |
| | | * cause. |
| | | * Creates a new ACI exception with the provided message and root cause. |
| | | * |
| | | * @param message The message that explains the problem that occurred. |
| | | * @param cause The exception that was caught to trigger this |
| | | * exception. |
| | | * @param message |
| | | * The message that explains the problem that occurred. |
| | | * @param cause |
| | | * The exception that was caught to trigger this exception. |
| | | */ |
| | | public AciException(LocalizableMessage message, Throwable cause) { |
| | | super(message, cause); |
| 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 legal-notices/CDDLv1_0.txt |
| | | * or http://forgerock.org/license/CDDLv1.0.html. |
| | | * 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 legal-notices/CDDLv1_0.txt. |
| | | * 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 |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | */ |
| | | /** |
| | | * Contains the Directory Server Sun Java System Directory Server Enterprise |
| | | * Edition (dseecompat) compatability access control handler implementation. |
| | | */ |
| | | package org.opends.server.authorization.dseecompat; |
| | | |
| 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 legal-notices/CDDLv1_0.txt |
| | | * or http://forgerock.org/license/CDDLv1.0.html. |
| | | * 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 legal-notices/CDDLv1_0.txt. |
| | | * 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 |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | /** |
| | | * Contains code used to interact with the Directory Server configuration. This |
| | | * includes various kinds of configuration attributes for different data types, |
| | | * as well as the primary means of exposing configuration and operations over |
| | | * JMX. Further, it includes the code for the default configuration handler |
| | | * which stores information in an LDIF file. |
| | | * <BR><BR> |
| | | * Whenever a configuration entry is modified, assuming that the result of the |
| | | * modification is in conformance with the server schema, then any configurable |
| | | * components and configuration change listeners associated with that entry will |
| | | * be invoked and given an opportunity to reject that update if there is a |
| | | * problem with it, or dynamically react to it by applying the new |
| | | * configuration. If a new configuration entry is added, then any configuration |
| | | * add listeners associated with that entry's parent will be invoked. If an |
| | | * existing entry is removed, then any configuration delete listeners associated |
| | | * with that entry's parent will be invoked. |
| | | */ |
| | | package org.opends.server.config; |
| | | |
| | |
| | | * TODO : this is a stub, with some default implementations for some methods, |
| | | * and no implementation for others. |
| | | */ |
| | | public class DirectoryServer { |
| | | public final class DirectoryServer { |
| | | |
| | | private DirectoryServer() { |
| | | // no implementation yet |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the attribute type for the provided lowercase name or OID. It |
| | |
| | | return Schema.getDefaultSchema().getAttributeType(lowerName); |
| | | } |
| | | |
| | | /** |
| | | * Returns the directory of server instance. |
| | | * |
| | | * @return the instance root directory |
| | | */ |
| | | public static String getInstanceRoot() { |
| | | throw new RuntimeException("Not implemented"); |
| | | } |
| | | |
| | | /** |
| | | * Returns the root directory of server. |
| | | * |
| | | * @return the server root directory |
| | | */ |
| | | public static String getServerRoot() { |
| | | throw new RuntimeException("Not implemented"); |
| | | } |
| 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 legal-notices/CDDLv1_0.txt |
| | | * or http://forgerock.org/license/CDDLv1.0.html. |
| | | * 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 legal-notices/CDDLv1_0.txt. |
| | | * 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 |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | */ |
| | | /** |
| | | * Contains various classes that comprise the core of the Directory Server |
| | | * codebase. This includes: |
| | | * <BR> |
| | | * <UL> |
| | | * <LI> |
| | | * The code that is invoked to initialize the various components of the |
| | | * Directory Server when it is started. |
| | | * </LI> |
| | | * <LI> |
| | | * The code that is invoked whenever the Directory Server is in the process |
| | | * of shutting down. |
| | | * </LI> |
| | | * <LI> |
| | | * The various types of operations that may be processed within the |
| | | * Directory Server. |
| | | * </LI> |
| | | * <LI> |
| | | * Data structures for important elements of Directory Server data, |
| | | * including attributes, objectclasses, DNs, entries. |
| | | * </LI> |
| | | * <LI> |
| | | * The implementation of the work queue and worker threads responsible for |
| | | * processing operations requested by clients. |
| | | * </LI> |
| | | * </UL> |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | |
| | | return true; |
| | | } |
| | | for (int i = 0; i < s.length; i++) { |
| | | if (!hostName[i].equals("*")) // skip if wildcard |
| | | { |
| | | // skip if wildcard |
| | | if (!hostName[i].equals("*")) { |
| | | if (!s[i].equalsIgnoreCase(hostName[i])) { |
| | | return false; |
| | | } |
| | |
| | | * The rule string containing all wildcards. |
| | | */ |
| | | private void processAllWilds(final String rule) { |
| | | final String s[] = rule.split("\\.", -1); |
| | | final String []s = rule.split("\\.", -1); |
| | | if (s.length == IN4ADDRSZ) { |
| | | for (int i = 0; i < IN4ADDRSZ; i++) { |
| | | wildCard.set(i); |
| | |
| | | */ |
| | | private void processHost(final String rule) throws ConfigException { |
| | | // Note that '*' is valid in host rule |
| | | final String s[] = rule.split("^[0-9a-zA-z-.*]+"); |
| | | final String []s = rule.split("^[0-9a-zA-z-.*]+"); |
| | | if (s.length > 0) { |
| | | final LocalizableMessage message = ERR_ADDRESSMASK_FORMAT_DECODE_ERROR.get(); |
| | | throw new ConfigException(message); |
| | |
| | | */ |
| | | private void processHostPattern(final String rule) throws ConfigException { |
| | | // quick check for invalid chars like " " |
| | | final String s[] = rule.split("^[0-9a-zA-z-.]+"); |
| | | final String []s = rule.split("^[0-9a-zA-z-.]+"); |
| | | if (s.length > 0) { |
| | | final LocalizableMessage message = ERR_ADDRESSMASK_FORMAT_DECODE_ERROR.get(); |
| | | throw new ConfigException(message); |
| | |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | */ |
| | | |
| | | package org.opends.server.types; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | |
| | | /** |
| | | * This class defines a base exception for OpenDS exceptions. |
| | | */ |
| | | public abstract class OpenDsException |
| | | extends Exception |
| | | { |
| | | public abstract class OpenDsException extends Exception { |
| | | |
| | | /** |
| | | * Generated serialization ID. |
| | |
| | | /** |
| | | * Creates a new identified exception. |
| | | */ |
| | | protected OpenDsException() |
| | | { |
| | | protected OpenDsException() { |
| | | super(); |
| | | } |
| | | |
| | | /** |
| | | * Constructs a new instance from another |
| | | * <code>OpenDsException</code>. |
| | | * This constructor sets the message to be that of |
| | | * <code>cause</code>. |
| | | * Constructs a new instance from another <code>OpenDsException</code>. This |
| | | * constructor sets the message to be that of <code>cause</code>. |
| | | * |
| | | * @param cause exception whose message will be used for |
| | | * this exception's message. |
| | | * @param cause |
| | | * exception whose message will be used for this exception's |
| | | * message. |
| | | */ |
| | | protected OpenDsException(OpenDsException cause) { |
| | | this(null, cause); |
| | |
| | | /** |
| | | * Creates a new identified exception with the provided information. |
| | | * |
| | | * @param message The message that explains the problem that |
| | | * occurred. |
| | | * @param message |
| | | * The message that explains the problem that occurred. |
| | | */ |
| | | protected OpenDsException(LocalizableMessage message) |
| | | { |
| | | protected OpenDsException(LocalizableMessage message) { |
| | | this(message, null); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Creates a new identified exception with the provided information. |
| | | * |
| | | * @param cause The underlying cause that triggered this |
| | | * exception. |
| | | * @param cause |
| | | * The underlying cause that triggered this exception. |
| | | */ |
| | | protected OpenDsException(Throwable cause) |
| | | { |
| | | protected OpenDsException(Throwable cause) { |
| | | this(null, cause); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Creates a new identified exception with the provided information. |
| | | * |
| | | * @param message The message that explains the problem that |
| | | * occurred. |
| | | * @param cause The underlying cause that triggered this |
| | | * exception. |
| | | * @param message |
| | | * The message that explains the problem that occurred. |
| | | * @param cause |
| | | * The underlying cause that triggered this exception. |
| | | */ |
| | | protected OpenDsException(LocalizableMessage message, Throwable cause) |
| | | { |
| | | super(message != null ? message.toString() : |
| | | cause != null ? cause.getMessage() : null, cause); |
| | | protected OpenDsException(LocalizableMessage message, Throwable cause) { |
| | | super(message != null ? message.toString() : cause != null ? cause.getMessage() : null, cause); |
| | | if (message != null) { |
| | | this.message = message; |
| | | } else if (cause instanceof OpenDsException) { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Returns the message that explains the problem that occurred. |
| | | * |
| 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 legal-notices/CDDLv1_0.txt |
| | | * or http://forgerock.org/license/CDDLv1.0.html. |
| | | * 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 legal-notices/CDDLv1_0.txt. |
| | | * 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 |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | */ |
| | | /** |
| | | * Contains implementations for a number of Directory Server data |
| | | * types. Most, but not necessarily all, of these data types may be |
| | | * considered part of the public API for use when extending the |
| | | * Directory Server. Please refer to the official documentation for |
| | | * authoritative information on what classes are considered part of |
| | | * the public API. |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | |
| | | public static void initializeForClientUse() { |
| | | throw new RuntimeException("not implemented"); |
| | | } |
| | | |
| | | private EmbeddedUtils() { |
| | | // no implementation required. |
| | | } |
| | | |
| | | |
| | | } |
| 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 legal-notices/CDDLv1_0.txt |
| | | * or http://forgerock.org/license/CDDLv1.0.html. |
| | | * 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 legal-notices/CDDLv1_0.txt. |
| | | * 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 |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | */ |
| | | /** |
| | | * Contains implementations for various Directory Server utility classes and |
| | | * methods which may be used throughout the server but do not necessarily fit in |
| | | * elsewhere. Notable utility classes include: |
| | | * <BR> |
| | | * <UL> |
| | | * <LI> |
| | | * StaticUtils.java -- a set of static methods that may be called to perform |
| | | * all kinds of useful operations on data (e.g., get a stack trace from an |
| | | * exception, or convert the contents of a byte array to a readable form). |
| | | * </LI> |
| | | * <LI> |
| | | * Base64.java -- provides a mechanism for performing base64 encoding and |
| | | * decoding. |
| | | * </LI> |
| | | * <LI> |
| | | * DynamicConstants.java -- a set of constants that are actually generated |
| | | * automatically at build time and reflect information about the time and |
| | | * conditions under which the server was built. |
| | | * </LI> |
| | | * <LI> |
| | | * TimeThread.java -- provides a thread that will periodically retrieve |
| | | * the current time and format it in several common methods in an attempt to |
| | | * minimize the need to have multiple calls to |
| | | * <CODE>System.currentTimeMillis()</CODE> or <CODE>new Date()</CODE> |
| | | * whenever the time is needed. This thread updates internal variables |
| | | * several times each second, which should be sufficient for cases in which |
| | | * high-resolution timing is not required. |
| | | * </LI> |
| | | * </UL> |
| | | */ |
| | | package org.opends.server.util; |
| | | |
| | |
| | | */ |
| | | public final class ConfigurationMock { |
| | | |
| | | private static final ConfigAnswer configAnswer = new ConfigAnswer(); |
| | | private static final ConfigAnswer CONFIG_ANSWER = new ConfigAnswer(); |
| | | |
| | | /** |
| | | * Returns a mock for the provided configuration class. |
| | |
| | | * @return a mock |
| | | */ |
| | | public static <T extends Configuration> T mockCfg(Class<T> configClass) { |
| | | return mock(configClass, configAnswer); |
| | | return mock(configClass, CONFIG_ANSWER); |
| | | } |
| | | |
| | | /** |
| | |
| | | import static org.testng.Assert.*; |
| | | |
| | | import org.forgerock.opendj.config.ConfigTestCase; |
| | | import org.testng.annotations.*; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | @SuppressWarnings("javadoc") |
| | | public class DurationUnitTest extends ConfigTestCase { |
| | |
| | | */ |
| | | package org.opends.server.admin; |
| | | |
| | | |
| | | |
| | | /** |
| | | * A mock LDAP profile wrapper for testing purposes. |
| | | */ |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public String getAttributeName(AbstractManagedObjectDefinition<?, ?> d, |
| | | PropertyDefinition<?> pd) { |
| | | public String getAttributeName(AbstractManagedObjectDefinition<?, ?> d, PropertyDefinition<?> pd) { |
| | | |
| | | if (d == TestParentCfgDefn.getInstance()) { |
| | | TestParentCfgDefn td = TestParentCfgDefn.getInstance(); |
| | |
| | | return "ds-cfg-enabled"; |
| | | } else if (pd == (PropertyDefinition<?>)td.getMandatoryClassPropertyPropertyDefinition()) { |
| | | return "ds-cfg-java-class"; |
| | | } else if (pd == (PropertyDefinition<?>)td |
| | | .getMandatoryReadOnlyAttributeTypePropertyPropertyDefinition()) { |
| | | } else if (pd == (PropertyDefinition<?>) td.getMandatoryReadOnlyAttributeTypePropertyPropertyDefinition()) { |
| | | return "ds-cfg-attribute-type"; |
| | | } else if (pd == (PropertyDefinition<?>)td.getOptionalMultiValuedDNPropertyPropertyDefinition()) { |
| | | return "ds-cfg-base-dn"; |
| | | } else { |
| | | throw new RuntimeException("Unexpected test-parent property" |
| | | + pd.getName()); |
| | | throw new RuntimeException("Unexpected test-parent property" + pd.getName()); |
| | | } |
| | | } else if (d == TestChildCfgDefn.getInstance()) { |
| | | TestChildCfgDefn td = TestChildCfgDefn.getInstance(); |
| | |
| | | return "ds-cfg-enabled"; |
| | | } else if (pd == (PropertyDefinition<?>)td.getMandatoryClassPropertyPropertyDefinition()) { |
| | | return "ds-cfg-java-class"; |
| | | } else if (pd == (PropertyDefinition<?>)td |
| | | .getMandatoryReadOnlyAttributeTypePropertyPropertyDefinition()) { |
| | | } else if (pd == (PropertyDefinition<?>) td.getMandatoryReadOnlyAttributeTypePropertyPropertyDefinition()) { |
| | | return "ds-cfg-attribute-type"; |
| | | } else if (pd == (PropertyDefinition<?>)td.getOptionalMultiValuedDNProperty1PropertyDefinition()) { |
| | | return "ds-cfg-base-dn"; |
| | |
| | | } else if (pd.getName().equals("aggregation-property")) { |
| | | return "ds-cfg-rotation-policy"; |
| | | } else { |
| | | throw new RuntimeException("Unexpected test-child property" |
| | | + pd.getName()); |
| | | throw new RuntimeException("Unexpected test-child property" + pd.getName()); |
| | | } |
| | | } |
| | | |
| | |
| | | return null; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public String getRelationChildRDNType( |
| | | InstantiableRelationDefinition<?, ?> r) { |
| | | public String getRelationChildRDNType(InstantiableRelationDefinition<?, ?> r) { |
| | | if (r == TestCfg.getTestOneToManyParentRelationDefinition() |
| | | || r == TestParentCfgDefn.getInstance() |
| | | .getTestChildrenRelationDefinition()) { |
| | | || r == TestParentCfgDefn.getInstance().getTestChildrenRelationDefinition()) { |
| | | return "cn"; |
| | | } else { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | |
| | | return "cn=test parents,cn=config"; |
| | | } else if (r == TestCfg.getTestOneToZeroOrOneParentRelationDefinition()) { |
| | | return "cn=optional test parent,cn=config"; |
| | | } else if (r == TestParentCfgDefn.getInstance() |
| | | .getTestChildrenRelationDefinition()) { |
| | | } else if (r == TestParentCfgDefn.getInstance().getTestChildrenRelationDefinition()) { |
| | | return "cn=test children"; |
| | | } else if (r == TestParentCfgDefn.getInstance() |
| | | .getOptionalTestChildRelationDefinition()) { |
| | | } else if (r == TestParentCfgDefn.getInstance().getOptionalTestChildRelationDefinition()) { |
| | | return "cn=optional test child"; |
| | | } else { |
| | | return null; |
| | |
| | | * A one-to-zero-or-one relation between the root and a test-parent |
| | | * component. |
| | | */ |
| | | // @Checkstyle:off |
| | | private static final OptionalRelationDefinition<TestParentCfgClient, TestParentCfg> |
| | | RD_TEST_ONE_TO_ZERO_OR_ONE_PARENT; |
| | | // @Checkstyle:on |
| | | |
| | | // Create a one-to-many relation for test-parent components. |
| | | static { |
| | |
| | | * @return Returns the one-to-many relation between the root and test-parent |
| | | * components. |
| | | */ |
| | | // @Checkstyle:off |
| | | public static InstantiableRelationDefinition<TestParentCfgClient, TestParentCfg> |
| | | getTestOneToManyParentRelationDefinition() { |
| | | return RD_TEST_ONE_TO_MANY_PARENT; |
| | | } |
| | | // @Checkstyle:on |
| | | |
| | | /** |
| | | * Gets the one-to-zero-or-one relation between the root and a test-parent |
| | |
| | | * @return Returns the one-to-zero-or-one relation between the root and a |
| | | * test-parent component. |
| | | */ |
| | | // @Checkstyle:off |
| | | public static OptionalRelationDefinition<TestParentCfgClient, TestParentCfg> |
| | | getTestOneToZeroOrOneParentRelationDefinition() { |
| | | return RD_TEST_ONE_TO_ZERO_OR_ONE_PARENT; |
| | | } |
| | | // @Checkstyle:on |
| | | |
| | | /** |
| | | * Initializes a property definition and its default behavior. |
| | |
| | | private static final TestChildCfgDefn INSTANCE = new TestChildCfgDefn(); |
| | | |
| | | // The "aggregation-property" property definition. |
| | | // @Checkstyle:off |
| | | private static final AggregationPropertyDefinition<ConnectionHandlerCfgClient, ConnectionHandlerCfg> |
| | | PROPDEF_AGGREGATION_PROPERTY; |
| | | // @Checkstyle:on |
| | | |
| | | // The "mandatory-boolean-property" property definition. |
| | | private static final BooleanPropertyDefinition PROPDEF_MANDATORY_BOOLEAN_PROPERTY; |
| | |
| | | * |
| | | * @return Returns the "aggregation-property" property definition. |
| | | */ |
| | | // @Checkstyle:off |
| | | public AggregationPropertyDefinition<ConnectionHandlerCfgClient, ConnectionHandlerCfg> |
| | | getAggregationPropertyPropertyDefinition() { |
| | | return PROPDEF_AGGREGATION_PROPERTY; |
| | | } |
| | | // @Checkstyle:on |
| | | |
| | | /** |
| | | * Get the "mandatory-boolean-property" property definition. |
| | |
| | | private static final List<String> CLASS_OBJECT_CLASS_EXCEPTIONS = Arrays.asList(new String[] { |
| | | "org.opends.server.admin.std.meta.RootCfgDefn", "org.opends.server.admin.std.meta.GlobalCfgDefn", }); |
| | | |
| | | // TODO : does not work because can retrieve object class objects |
| | | // TODO : does not work because can't retrieve object class objects |
| | | @Test(enabled = false, dataProvider = "enumerateManageObjectDefns") |
| | | public void validateConfigObjectDefinitions(AbstractManagedObjectDefinition<?, ?> objectDef) { |
| | | String objName = objectDef.getName(); |
| | |
| | | + " instead of " + ldapObjectclassName).append(EOL + EOL); |
| | | } |
| | | } |
| | | ObjectClass configObjectClass = Schema.getDefaultSchema().asNonStrictSchema(). |
| | | getObjectClass(ldapObjectclassName.toLowerCase()); |
| | | ; |
| | | ObjectClass configObjectClass = |
| | | Schema.getDefaultSchema().asNonStrictSchema().getObjectClass(ldapObjectclassName.toLowerCase()); |
| | | |
| | | for (PropertyDefinition<?> propDef : allPropertyDefs) { |
| | | validatePropertyDefinition(objectDef, configObjectClass, propDef, errors); |
| | |
| | | if (expectedExceptionClass.equals(ErrorResultException.class)) { |
| | | assertThat(e).isInstanceOf(ErrorResultException.class); |
| | | assertThat(((ErrorResultException) e).getResult().getResultCode()).isEqualTo(expectedCode); |
| | | } |
| | | else { |
| | | } else { |
| | | assertThat(e).isInstanceOf(expectedExceptionClass); |
| | | } |
| | | } |
| | |
| | | if (expectedExceptionClass.equals(ErrorResultException.class)) { |
| | | assertThat(e).isInstanceOf(ErrorResultException.class); |
| | | assertThat(((ErrorResultException) e).getResult().getResultCode()).isEqualTo(expectedCode); |
| | | } |
| | | else { |
| | | } else { |
| | | assertThat(e).isInstanceOf(expectedExceptionClass); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public <C extends Control> C getControl(ControlDecoder<C> decoder, DecodeOptions options) throws DecodeException { |
| | | public <C extends Control> C getControl(ControlDecoder<C> decoder, DecodeOptions options) |
| | | throws DecodeException { |
| | | throw new RuntimeException("not implemented"); |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | // Construct a dummy path. |
| | | private synchronized static <C extends ConfigurationClient, S extends Configuration> ManagedObjectPath<C, S> getPath( |
| | | AbstractManagedObjectDefinition<C, S> d) { |
| | | /** Construct a dummy path. */ |
| | | // @Checkstyle:off |
| | | private synchronized static <C extends ConfigurationClient, S extends Configuration> ManagedObjectPath<C, S> |
| | | getPath(AbstractManagedObjectDefinition<C, S> d) { |
| | | // @Checkstyle:on |
| | | if (!isProfileRegistered) { |
| | | LDAPProfile.Wrapper profile = new LDAPProfile.Wrapper() { |
| | | |
| | | @Override |
| | | public String getRelationRDNSequence(RelationDefinition<?, ?> r) { |
| | | if (r.getName().equals(DUMMY_TEST_RELATION)) { |
| | |
| | | } |
| | | |
| | | }; |
| | | |
| | | LDAPProfile.getInstance().pushWrapper(profile); |
| | | isProfileRegistered = true; |
| | | } |
| | | |
| | | SingletonRelationDefinition.Builder<C, S> builder = new SingletonRelationDefinition.Builder<C, S>( |
| | | RootCfgDefn.getInstance(), DUMMY_TEST_RELATION, d); |
| | | SingletonRelationDefinition.Builder<C, S> builder = |
| | | new SingletonRelationDefinition.Builder<C, S>(RootCfgDefn.getInstance(), DUMMY_TEST_RELATION, d); |
| | | ManagedObjectPath<?, ?> root = ManagedObjectPath.emptyPath(); |
| | | return root.child(builder.getInstance()); |
| | | |
| | | } |
| | | } |
| | |
| | | "ds-cfg-enabled: true", |
| | | "ds-cfg-listen-address: 0.0.0.0", "ds-cfg-listen-port: 389"); |
| | | |
| | | // @Checkstyle:off |
| | | /** |
| | | * The default test child configuration "aggregation-property" property |
| | | * definition. |
| | |
| | | /** An aggregation where the target must be enabled. */ |
| | | private AggregationPropertyDefinition<ConnectionHandlerCfgClient, ConnectionHandlerCfg> |
| | | aggregationPropertyDefinitionTargetMustBeEnabled = null; |
| | | // @Checkstyle:on |
| | | |
| | | @BeforeClass |
| | | public void setUp() throws Exception { |
| | |
| | | TestParentCfg parentCfg = getParentCfg(entryName(TEST_PARENT_1), context); |
| | | parentCfg.addTestChildDeleteListener(deleteListener); |
| | | |
| | | ArgumentCaptor<ConfigDeleteListener> registeredListener = ArgumentCaptor.forClass(ConfigDeleteListener.class); |
| | | verify(configRepository).registerDeleteListener(eq(TEST_BASE_CHILD.getName()), registeredListener.capture()); |
| | | ArgumentCaptor<ConfigDeleteListener> registeredListener = |
| | | ArgumentCaptor.forClass(ConfigDeleteListener.class); |
| | | verify(configRepository).registerDeleteListener(eq(TEST_BASE_CHILD.getName()), |
| | | registeredListener.capture()); |
| | | |
| | | // Now simulate the delete ofthe referenced connection handler. |
| | | assertThat(registeredListener.getValue(). |
| | |
| | | TestChildCfg testChildCfg = parentCfg.getTestChild(entryName(TEST_CHILD_7)); |
| | | testChildCfg.addChangeListener(changeListener); |
| | | |
| | | ArgumentCaptor<ConfigChangeListener> registeredListener = ArgumentCaptor.forClass(ConfigChangeListener.class); |
| | | ArgumentCaptor<ConfigChangeListener> registeredListener = |
| | | ArgumentCaptor.forClass(ConfigChangeListener.class); |
| | | verify(configRepository).registerChangeListener(eq(TEST_CHILD_7.getName()), registeredListener.capture()); |
| | | |
| | | // Now simulate the disabling ofthe referenced connection handler. |
| | |
| | | public void createWithInstantiableRelationDefinition() throws Exception { |
| | | ManagedObjectPath<?,?> parentPath = ManagedObjectPath.emptyPath(). |
| | | child(TestCfg.getTestOneToManyParentRelationDefinition(), "test-parent-1"); |
| | | ManagedObjectPath<?,?> childPath = parentPath.child(TestParentCfgDefn.getInstance().getTestChildrenRelationDefinition(), "test-child-1"); |
| | | ManagedObjectPath<?, ?> childPath = parentPath.child(TestParentCfgDefn.getInstance(). |
| | | getTestChildrenRelationDefinition(), "test-child-1"); |
| | | |
| | | assertEquals( |
| | | DNBuilder.create(childPath), |