opendj-config: added @Override + Autorefactor'ed comments
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.config; |
| | | |
| | | import java.util.EnumSet; |
| | |
| | | |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * ACI property definition. |
| | | */ |
| | | /** ACI property definition. */ |
| | | public final class ACIPropertyDefinition extends PropertyDefinition<String> { |
| | | |
| | | /** |
| | | * An interface for incrementally constructing ACI property definitions. |
| | | */ |
| | | /** An interface for incrementally constructing ACI property definitions. */ |
| | | public static final class Builder extends AbstractBuilder<String, ACIPropertyDefinition> { |
| | | |
| | | /** Private constructor. */ |
| | |
| | | super(d, propertyName); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected ACIPropertyDefinition buildInstance(AbstractManagedObjectDefinition<?, ?> d, |
| | | String propertyName, EnumSet<PropertyOption> options, |
| | |
| | | super(d, String.class, propertyName, options, adminAction, defaultBehavior); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void validateValue(String value) { |
| | | Reject.ifNull(value); |
| | |
| | | // No additional validation required. |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String decodeValue(String value) { |
| | | Reject.ifNull(value); |
| | |
| | | throw PropertyException.illegalPropertyValueException(this, value); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(PropertyDefinitionVisitor<R, P> v, P p) { |
| | | return v.visitACI(this, p); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(PropertyValueVisitor<R, P> v, String value, P p) { |
| | | return v.visitACI(this, value, p); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int compare(String o1, String o2) { |
| | | return o1.compareTo(o2); |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config; |
| | | |
| | |
| | | this.propertyName = propertyName; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(DefaultBehaviorProviderVisitor<T, R, P> v, P p) { |
| | | return v.visitAbsoluteInherited(this, p); |
| | | } |
| | |
| | | return propertyName; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected void initialize() throws Exception { |
| | | // Decode the path. |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2007-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | * Portions Copyright 2015-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config; |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final String toString() { |
| | | StringBuilder builder = new StringBuilder(); |
| | |
| | | apd.getRelationDefinition().getChildDefinition().reverseAggregationPropertyDefinitions.add(apd); |
| | | } |
| | | |
| | | /** |
| | | * Recursively descend definition hierarchy to find the best match |
| | | * definition. |
| | | */ |
| | | /** Recursively descend definition hierarchy to find the best match definition. */ |
| | | private AbstractManagedObjectDefinition<? extends C, ? extends S> resolveManagedObjectDefinitionAux( |
| | | AbstractManagedObjectDefinition<? extends C, ? extends S> d, DefinitionResolver r) { |
| | | if (!r.matches(d)) { |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.config; |
| | | |
| | | import org.forgerock.i18n.LocalizableException; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | /** |
| | | * Exceptions thrown when interacting with administration framework. |
| | | */ |
| | | /** Exceptions thrown when interacting with administration framework. */ |
| | | public abstract class AdminException extends Exception implements LocalizableException { |
| | | private final LocalizableMessage message; |
| | | |
| | | /** |
| | | * Fake serialization ID. |
| | | */ |
| | | /** Fake serialization ID. */ |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config; |
| | | |
| | |
| | | this.name = name; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | return name; |
| | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * The managed object definition associated with this administrator |
| | | * action. |
| | | */ |
| | | /** The managed object definition associated with this administrator action. */ |
| | | private final AbstractManagedObjectDefinition<?, ?> definition; |
| | | |
| | | /** |
| | | * The name of the property definition associated with this |
| | | * administrator action. |
| | | */ |
| | | /** The name of the property definition associated with this administrator action. */ |
| | | private final String propertyName; |
| | | |
| | | /** The type of administration action. */ |
| | |
| | | */ |
| | | private String rdName; |
| | | |
| | | /** |
| | | * The condition which is used to determine if a referenced |
| | | * managed object is enabled. |
| | | */ |
| | | /** The condition which is used to determine if a referenced managed object is enabled. */ |
| | | private Condition targetIsEnabledCondition = Conditions.TRUE; |
| | | |
| | | /** |
| | |
| | | this.targetNeedsEnablingCondition = condition; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected AggregationPropertyDefinition<C, S> buildInstance(AbstractManagedObjectDefinition<?, ?> d, |
| | | String propertyName, EnumSet<PropertyOption> options, AdministratorAction adminAction, |
| | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * A change listener which prevents the named component from being disabled. |
| | | */ |
| | | /** A change listener which prevents the named component from being disabled. */ |
| | | private final class ReferentialIntegrityChangeListener implements ServerManagedObjectChangeListener<S> { |
| | | |
| | | /** |
| | |
| | | this.message = message; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationChange(ServerManagedObject<? extends S> mo) { |
| | | try { |
| | | if (targetIsEnabledCondition.evaluate(mo)) { |
| | |
| | | + relationDefinition.getChildDefinition().getUserFriendlyName()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isConfigurationChangeAcceptable(ServerManagedObject<? extends S> mo, |
| | | List<LocalizableMessage> unacceptableReasons) { |
| | | // Always prevent the referenced component from being |
| | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * A delete listener which prevents the named component from being deleted. |
| | | */ |
| | | /** A delete listener which prevents the named component from being deleted. */ |
| | | private final class ReferentialIntegrityDeleteListener implements ConfigurationDeleteListener<S> { |
| | | |
| | | /** The DN of the referenced configuration entry. */ |
| | |
| | | this.message = message; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationDelete(S configuration) { |
| | | // This should not happen - the |
| | | // isConfigurationDeleteAcceptable() call-back should have |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isConfigurationDeleteAcceptable(S configuration, List<LocalizableMessage> unacceptableReasons) { |
| | | if (configuration.dn().equals(dn)) { |
| | | // Always prevent deletion of the referenced component. |
| | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * The server-side constraint handler implementation. |
| | | */ |
| | | /** The server-side constraint handler implementation. */ |
| | | private class ServerHandler extends ServerConstraintHandler { |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isUsable(ServerManagedObject<?> managedObject, |
| | | Collection<LocalizableMessage> unacceptableReasons) throws ConfigException { |
| | |
| | | return isUsable; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void performPostAdd(ServerManagedObject<?> managedObject) throws ConfigException { |
| | | // First make sure existing listeners associated with this |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void performPostDelete(ServerManagedObject<?> managedObject) throws ConfigException { |
| | | // Remove any registered delete and change listeners. |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void performPostModify(ServerManagedObject<?> managedObject) throws ConfigException { |
| | | // Remove all the constraints associated with this managed |
| | |
| | | */ |
| | | private class SourceClientHandler extends ClientConstraintHandler { |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isAddAcceptable(ManagementContext context, ManagedObject<?> managedObject, |
| | | Collection<LocalizableMessage> unacceptableReasons) throws LdapException { |
| | |
| | | return isAcceptable; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isModifyAcceptable(ManagementContext context, ManagedObject<?> managedObject, |
| | | Collection<LocalizableMessage> unacceptableReasons) throws LdapException { |
| | |
| | | */ |
| | | private class TargetClientHandler extends ClientConstraintHandler { |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isDeleteAcceptable(ManagementContext context, ManagedObjectPath<?, ?> path, |
| | | Collection<LocalizableMessage> unacceptableReasons) throws LdapException { |
| | |
| | | return isAcceptable; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isModifyAcceptable(ManagementContext context, ManagedObject<?> managedObject, |
| | | Collection<LocalizableMessage> unacceptableReasons) throws LdapException { |
| | |
| | | return isAcceptable; |
| | | } |
| | | |
| | | /** |
| | | * Find all managed objects which reference the named managed |
| | | * object using this property. |
| | | */ |
| | | /** Find all managed objects which reference the named managed object using this property. */ |
| | | private <C1 extends ConfigurationClient> List<ManagedObject<? extends C1>> findReferences( |
| | | ManagementContext context, AbstractManagedObjectDefinition<C1, ?> mod, String name) |
| | | throws LdapException { |
| | |
| | | |
| | | private static final Logger debugLogger = LoggerFactory.getLogger(AggregationPropertyDefinition.class); |
| | | |
| | | /** |
| | | * The active server-side referential integrity change listeners |
| | | * associated with this property. |
| | | */ |
| | | /** The active server-side referential integrity change listeners associated with this property. */ |
| | | private final Map<DN, List<ReferentialIntegrityChangeListener>> changeListeners = new HashMap<>(); |
| | | |
| | | /** |
| | | * The active server-side referential integrity delete listeners |
| | | * associated with this property. |
| | | */ |
| | | /** The active server-side referential integrity delete listeners associated with this property. */ |
| | | private final Map<DN, List<ReferentialIntegrityDeleteListener>> deleteListeners = new HashMap<>(); |
| | | |
| | | /** |
| | | * The name of the managed object which is the parent of the |
| | | * aggregated managed objects. |
| | | */ |
| | | /** The name of the managed object which is the parent of the aggregated managed objects. */ |
| | | private ManagedObjectPath<?, ?> parentPath; |
| | | |
| | | /** |
| | |
| | | */ |
| | | private final String rdName; |
| | | |
| | | /** |
| | | * The relation in the parent managed object which contains the |
| | | * aggregated managed objects. |
| | | */ |
| | | /** The relation in the parent managed object which contains the aggregated managed objects. */ |
| | | private InstantiableRelationDefinition<C, S> relationDefinition; |
| | | |
| | | /** The source constraint. */ |
| | | private final Constraint sourceConstraint; |
| | | |
| | | /** |
| | | * The condition which is used to determine if a referenced managed |
| | | * object is enabled. |
| | | */ |
| | | /** The condition which is used to determine if a referenced managed object is enabled. */ |
| | | private final Condition targetIsEnabledCondition; |
| | | |
| | | /** |
| | |
| | | this.targetIsEnabledCondition = targetIsEnabledCondition; |
| | | this.sourceConstraint = new Constraint() { |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Collection<ClientConstraintHandler> getClientConstraintHandlers() { |
| | | ClientConstraintHandler handler = new SourceClientHandler(); |
| | | return Collections.singleton(handler); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Collection<ServerConstraintHandler> getServerConstraintHandlers() { |
| | | ServerConstraintHandler handler = new ServerHandler(); |
| | | return Collections.singleton(handler); |
| | |
| | | }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(PropertyDefinitionVisitor<R, P> v, P p) { |
| | | return v.visitAggregation(this, p); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(PropertyValueVisitor<R, P> v, String value, P p) { |
| | | return v.visitAggregation(this, value, p); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String decodeValue(String value) { |
| | | Reject.ifNull(value); |
| | |
| | | return targetNeedsEnablingCondition; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String normalizeValue(String value) { |
| | | try { |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void toString(StringBuilder builder) { |
| | | super.toString(builder); |
| | |
| | | builder.append(targetIsEnabledCondition); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void validateValue(String value) { |
| | | try { |
| | |
| | | // for actions performed against referenced managed objects. |
| | | Constraint constraint = new Constraint() { |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Collection<ClientConstraintHandler> getClientConstraintHandlers() { |
| | | ClientConstraintHandler handler = new TargetClientHandler(); |
| | | return Collections.singleton(handler); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Collection<ServerConstraintHandler> getServerConstraintHandlers() { |
| | | return Collections.emptyList(); |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config; |
| | | |
| | |
| | | */ |
| | | public final class AliasDefaultBehaviorProvider<T> extends DefaultBehaviorProvider<T> { |
| | | |
| | | /** |
| | | * The managed object definition associated with this default |
| | | * behavior. |
| | | */ |
| | | /** The managed object definition associated with this default behavior. */ |
| | | private final AbstractManagedObjectDefinition<?, ?> definition; |
| | | |
| | | /** |
| | | * The name of the property definition associated with this default |
| | | * behavior. |
| | | */ |
| | | /** The name of the property definition associated with this default behavior. */ |
| | | private final String propertyName; |
| | | |
| | | /** |
| | |
| | | this.propertyName = propertyName; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(DefaultBehaviorProviderVisitor<T, R, P> v, P p) { |
| | | return v.visitAlias(this, p); |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.config; |
| | | |
| | | import org.forgerock.util.Reject; |
| | |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | |
| | | /** |
| | | * Attribute type property definition. |
| | | */ |
| | | /** Attribute type property definition. */ |
| | | public final class AttributeTypePropertyDefinition extends PropertyDefinition<AttributeType> { |
| | | |
| | | /** |
| | | * An interface for incrementally constructing attribute type property |
| | | * definitions. |
| | | */ |
| | | /** An interface for incrementally constructing attribute type property definitions. */ |
| | | public static final class Builder extends AbstractBuilder<AttributeType, AttributeTypePropertyDefinition> { |
| | | |
| | | /** Private constructor. */ |
| | |
| | | super(d, propertyName); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected AttributeTypePropertyDefinition buildInstance(AbstractManagedObjectDefinition<?, ?> d, |
| | | String propertyName, EnumSet<PropertyOption> options, AdministratorAction adminAction, |
| | |
| | | super(d, AttributeType.class, propertyName, options, adminAction, defaultBehavior); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(PropertyDefinitionVisitor<R, P> v, P p) { |
| | | return v.visitAttributeType(this, p); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(PropertyValueVisitor<R, P> v, AttributeType value, P p) { |
| | | return v.visitAttributeType(this, value, p); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int compare(AttributeType o1, AttributeType o2) { |
| | | return o1.getNameOrOID().compareToIgnoreCase(o2.getNameOrOID()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public AttributeType decodeValue(String value) { |
| | | Reject.ifNull(value); |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String encodeValue(AttributeType value) { |
| | | return value.getNameOrOID(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void validateValue(AttributeType value) { |
| | | Reject.ifNull(value); |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | * Portions Copyright 2015-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config; |
| | | |
| | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * Boolean property definition. |
| | | */ |
| | | /** Boolean property definition. */ |
| | | public final class BooleanPropertyDefinition extends PropertyDefinition<Boolean> { |
| | | |
| | | /** |
| | |
| | | VALUE_MAP.put("true", Boolean.TRUE); |
| | | } |
| | | |
| | | /** |
| | | * An interface for incrementally constructing boolean property definitions. |
| | | */ |
| | | /** An interface for incrementally constructing boolean property definitions. */ |
| | | public static final class Builder extends AbstractBuilder<Boolean, BooleanPropertyDefinition> { |
| | | |
| | | /** Private constructor. */ |
| | |
| | | super(d, propertyName); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected BooleanPropertyDefinition buildInstance(AbstractManagedObjectDefinition<?, ?> d, |
| | | String propertyName, EnumSet<PropertyOption> options, AdministratorAction adminAction, |
| | |
| | | super(d, Boolean.class, propertyName, options, adminAction, defaultBehavior); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void validateValue(Boolean value) { |
| | | Reject.ifNull(value); |
| | |
| | | // No additional validation required. |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Boolean decodeValue(String value) { |
| | | Reject.ifNull(value); |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(PropertyDefinitionVisitor<R, P> v, P p) { |
| | | return v.visitBoolean(this, p); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(PropertyValueVisitor<R, P> v, Boolean value, P p) { |
| | | return v.visitBoolean(this, value, p); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int compare(Boolean o1, Boolean o2) { |
| | | return o1.compareTo(o2); |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions copyright 2013-2015 ForgeRock AS. |
| | | * Portions copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.config; |
| | |
| | | public final void addInstanceOf(String className) { |
| | | Reject.ifNull(className); |
| | | |
| | | /* |
| | | * Do some basic checks to make sure the string representation is |
| | | * valid. |
| | | */ |
| | | /* Do some basic checks to make sure the string representation is valid. */ |
| | | String value = className.trim(); |
| | | if (!value.matches(CLASS_RE)) { |
| | | throw new IllegalArgumentException("\"" + value + "\" is not a valid Java class name"); |
| | |
| | | instanceOfInterfaces.add(value); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected ClassPropertyDefinition buildInstance(AbstractManagedObjectDefinition<?, ?> d, String propertyName, |
| | | EnumSet<PropertyOption> options, AdministratorAction adminAction, |
| | |
| | | this.instanceOfInterfaces = Collections.unmodifiableList(new LinkedList<String>(instanceOfInterfaces)); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(PropertyDefinitionVisitor<R, P> v, P p) { |
| | | return v.visitClass(this, p); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(PropertyValueVisitor<R, P> v, String value, P p) { |
| | | return v.visitClass(this, value, p); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String decodeValue(String value) { |
| | | Reject.ifNull(value); |
| | |
| | | return theClass.asSubclass(instanceOf); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String normalizeValue(String value) { |
| | | Reject.ifNull(value); |
| | |
| | | return value.trim(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void validateValue(String value) { |
| | | Reject.ifNull(value); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Do some basic checks to make sure the string representation is valid. |
| | | */ |
| | | /** Do some basic checks to make sure the string representation is valid. */ |
| | | private void validateClassName(String className) { |
| | | String nvalue = className.trim(); |
| | | if (!nvalue.matches(CLASS_RE)) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Make sure that named class implements the interfaces named by this |
| | | * definition. |
| | | */ |
| | | /** Make sure that named class implements the interfaces named by this definition. */ |
| | | private Class<?> validateClassInterfaces(String className, boolean initialize) { |
| | | Class<?> theClass = loadClassForValidation(className, className, initialize); |
| | | for (String i : instanceOfInterfaces) { |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2007-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.config; |
| | | |
| | | 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 { |
| | | |
| | | /** |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS. |
| | | * Portions Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.config; |
| | |
| | | import org.forgerock.opendj.config.client.OperationRejectedException; |
| | | import org.forgerock.opendj.ldap.LdapException; |
| | | |
| | | /** |
| | | * A common base interface for all managed object configuration clients. |
| | | */ |
| | | /** A common base interface for all managed object configuration clients. */ |
| | | public interface ConfigurationClient { |
| | | |
| | | /** |
| | |
| | | */ |
| | | private static final class MyURLClassLoader extends URLClassLoader { |
| | | |
| | | /** |
| | | * Create a class loader with the default parent class loader. |
| | | */ |
| | | /** Create a class loader with the default parent class loader. */ |
| | | public MyURLClassLoader() { |
| | | super(new URL[0]); |
| | | } |
| | |
| | | /** Attribute name in jar's MANIFEST corresponding to the revision number. */ |
| | | private static final String REVISION_NUMBER = "Revision-Number"; |
| | | |
| | | /** |
| | | * The attribute names for build information is name, version and revision number. |
| | | */ |
| | | /** 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(), REVISION_NUMBER }; |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config; |
| | | |
| | |
| | | */ |
| | | public abstract class Constraint { |
| | | |
| | | /** |
| | | * Creates a new constraint. |
| | | */ |
| | | /** Creates a new constraint. */ |
| | | protected Constraint() { |
| | | // No implementation required. |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.config; |
| | |
| | | |
| | | import org.forgerock.opendj.ldap.DN; |
| | | |
| | | /** |
| | | * DN property definition. |
| | | */ |
| | | /** DN property definition. */ |
| | | public final class DNPropertyDefinition extends PropertyDefinition<DN> { |
| | | |
| | | /** |
| | | * Optional base DN which all valid values must be immediately |
| | | * subordinate to. |
| | | */ |
| | | /** Optional base DN which all valid values must be immediately subordinate to. */ |
| | | private final DN baseDN; |
| | | |
| | | /** An interface for incrementally constructing DN property definitions. */ |
| | | public static final class Builder extends AbstractBuilder<DN, DNPropertyDefinition> { |
| | | |
| | | /** |
| | | * Optional base DN which all valid values must be immediately |
| | | * subordinate to. |
| | | */ |
| | | /** Optional base DN which all valid values must be immediately subordinate to. */ |
| | | private DN baseDN; |
| | | |
| | | /** Private constructor. */ |
| | |
| | | this.baseDN = baseDN; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected DNPropertyDefinition buildInstance(AbstractManagedObjectDefinition<?, ?> d, String propertyName, |
| | | EnumSet<PropertyOption> options, AdministratorAction adminAction, |
| | |
| | | return baseDN; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void validateValue(DN value) { |
| | | Reject.ifNull(value); |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public DN decodeValue(String value) { |
| | | Reject.ifNull(value); |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(PropertyDefinitionVisitor<R, P> v, P p) { |
| | | return v.visitDN(this, p); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(PropertyValueVisitor<R, P> v, DN value, P p) { |
| | | return v.visitDN(this, value, p); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int compare(DN o1, DN o2) { |
| | | return o1.compareTo(o2); |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.config; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | /** |
| | | * The requested managed object was found but it could not be decoded. |
| | | */ |
| | | /** The requested managed object was found but it could not be decoded. */ |
| | | public abstract class DecodingException extends OperationsException { |
| | | |
| | | /** |
| | | * Fake serialization ID. |
| | | */ |
| | | /** Fake serialization ID. */ |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config; |
| | | |
| | |
| | | */ |
| | | public abstract class DefaultBehaviorProvider<T> { |
| | | |
| | | /** |
| | | * Creates a new default behavior provider. |
| | | */ |
| | | /** Creates a new default behavior provider. */ |
| | | protected DefaultBehaviorProvider() { |
| | | // No implementation required. |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | * Portions Copyright 2015-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config; |
| | | |
| | |
| | | * If the property definition is not associated with this |
| | | * managed object's definition. |
| | | */ |
| | | @Override |
| | | public <T> SortedSet<T> getPropertyValues(PropertyDefinition<T> pd) { |
| | | // Validate the property definition. |
| | | definition.getPropertyDefinition(pd.getName()); |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | * Portions Copyright 2015-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config; |
| | | |
| | |
| | | this.values = Arrays.asList(values); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(DefaultBehaviorProviderVisitor<T, R, P> v, P p) { |
| | | return v.visitDefined(this, p); |
| | | } |
| | |
| | | |
| | | 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 { |
| | | /** |
| | | * The managed object could be found but its type resolved to an |
| | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * Version ID required by serializable classes. |
| | | */ |
| | | /** Version ID required by serializable classes. */ |
| | | private static final long serialVersionUID = 3459033551415663416L; |
| | | |
| | | /** Create the message. */ |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.config; |
| | |
| | | */ |
| | | private final boolean allowUnlimited; |
| | | |
| | | /** |
| | | * An interface for incrementally constructing duration property |
| | | * definitions. |
| | | */ |
| | | /** An interface for incrementally constructing duration property definitions. */ |
| | | public static final class Builder extends AbstractBuilder<Long, DurationPropertyDefinition> { |
| | | |
| | | /** The base unit for this property definition. */ |
| | |
| | | this.allowUnlimited = allowUnlimited; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected DurationPropertyDefinition buildInstance(AbstractManagedObjectDefinition<?, ?> d, |
| | | String propertyName, EnumSet<PropertyOption> options, AdministratorAction adminAction, |
| | |
| | | return allowUnlimited; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void validateValue(Long value) { |
| | | Reject.ifNull(value); |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String encodeValue(Long value) { |
| | | Reject.ifNull(value); |
| | |
| | | return builder.toString(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Long decodeValue(String value) { |
| | | Reject.ifNull(value); |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(PropertyDefinitionVisitor<R, P> v, P p) { |
| | | return v.visitDuration(this, p); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(PropertyValueVisitor<R, P> v, Long value, P p) { |
| | | return v.visitDuration(this, value, p); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void toString(StringBuilder builder) { |
| | | super.toString(builder); |
| | |
| | | builder.append(allowUnlimited); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int compare(Long o1, Long o2) { |
| | | return o1.compareTo(o2); |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | * Portions Copyright 2015-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config; |
| | | |
| | |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | |
| | | /** |
| | | * This enumeration defines various duration units. |
| | | */ |
| | | /** This enumeration defines various duration units. */ |
| | | public enum DurationUnit { |
| | | |
| | | /** A day unit. */ |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | * Portions Copyright 2015-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config; |
| | | |
| | |
| | | this.enumClass = enumClass; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected EnumPropertyDefinition<E> buildInstance(AbstractManagedObjectDefinition<?, ?> d, |
| | | String propertyName, EnumSet<PropertyOption> options, AdministratorAction adminAction, |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(PropertyDefinitionVisitor<R, P> v, P p) { |
| | | return v.visitEnum(this, p); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(PropertyValueVisitor<R, P> v, E value, P p) { |
| | | return v.visitEnum(this, value, p); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public E decodeValue(String value) { |
| | | Reject.ifNull(value); |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String normalizeValue(E value) { |
| | | Reject.ifNull(value); |
| | |
| | | return value.toString().trim().toLowerCase(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void validateValue(E value) { |
| | | Reject.ifNull(value); |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS. |
| | | * Portions Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config; |
| | | |
| | |
| | | */ |
| | | public class GenericConstraint extends Constraint { |
| | | |
| | | /** |
| | | * The client-side constraint handler. |
| | | */ |
| | | /** The client-side constraint handler. */ |
| | | private final class ClientHandler extends ClientConstraintHandler { |
| | | |
| | | /** Private constructor. */ |
| | |
| | | // No implementation required. |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isAddAcceptable(ManagementContext context, ManagedObject<?> managedObject, |
| | | Collection<LocalizableMessage> unacceptableReasons) throws LdapException { |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isModifyAcceptable(ManagementContext context, ManagedObject<?> managedObject, |
| | | Collection<LocalizableMessage> unacceptableReasons) throws LdapException { |
| | |
| | | // No implementation required. |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isUsable(ServerManagedObject<?> managedObject, |
| | | Collection<LocalizableMessage> unacceptableReasons) throws ConfigException { |
| | |
| | | this.condition = condition; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Collection<ClientConstraintHandler> getClientConstraintHandlers() { |
| | | return Collections.singleton(clientHandler); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Collection<ServerConstraintHandler> getServerConstraintHandlers() { |
| | | return Collections.singleton(serverHandler); |
| | | } |
| | |
| | | return resource.getMessage(definition, property, locale); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected void initialize() throws Exception { |
| | | condition.initialize(definition); |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions copyright 2014 ForgeRock AS. |
| | | * Portions copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.config; |
| | |
| | | |
| | | import java.util.EnumSet; |
| | | |
| | | /** |
| | | * IP address mask property definition. |
| | | */ |
| | | /** IP address mask property definition. */ |
| | | public final class IPAddressMaskPropertyDefinition extends PropertyDefinition<AddressMask> { |
| | | |
| | | /** |
| | | * An interface for incrementally constructing IP address mask property |
| | | * definitions. |
| | | */ |
| | | /** An interface for incrementally constructing IP address mask property definitions. */ |
| | | public static final class Builder extends AbstractBuilder<AddressMask, IPAddressMaskPropertyDefinition> { |
| | | |
| | | /** Private constructor. */ |
| | |
| | | super(d, propertyName); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected IPAddressMaskPropertyDefinition buildInstance(AbstractManagedObjectDefinition<?, ?> d, |
| | | String propertyName, EnumSet<PropertyOption> options, AdministratorAction adminAction, |
| | |
| | | super(d, AddressMask.class, propertyName, options, adminAction, defaultBehavior); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void validateValue(AddressMask value) { |
| | | Reject.ifNull(value); |
| | |
| | | // No additional validation required. |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public AddressMask decodeValue(String value) { |
| | | Reject.ifNull(value); |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(PropertyDefinitionVisitor<R, P> v, P p) { |
| | | return v.visitIPAddressMask(this, p); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(PropertyValueVisitor<R, P> v, AddressMask value, P p) { |
| | | return v.visitIPAddressMask(this, value, p); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int compare(AddressMask o1, AddressMask o2) { |
| | | return o1.toString().compareTo(o2.toString()); |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.config; |
| | |
| | | import java.net.UnknownHostException; |
| | | import java.util.EnumSet; |
| | | |
| | | /** |
| | | * IP address property definition. |
| | | */ |
| | | /** IP address property definition. */ |
| | | public final class IPAddressPropertyDefinition extends PropertyDefinition<InetAddress> { |
| | | |
| | | /** |
| | | * An interface for incrementally constructing IP address property |
| | | * definitions. |
| | | */ |
| | | /** An interface for incrementally constructing IP address property definitions. */ |
| | | public static final class Builder extends AbstractBuilder<InetAddress, IPAddressPropertyDefinition> { |
| | | |
| | | /** Private constructor. */ |
| | |
| | | super(d, propertyName); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected IPAddressPropertyDefinition buildInstance(AbstractManagedObjectDefinition<?, ?> d, |
| | | String propertyName, EnumSet<PropertyOption> options, AdministratorAction adminAction, |
| | |
| | | super(d, InetAddress.class, propertyName, options, adminAction, defaultBehavior); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void validateValue(InetAddress value) { |
| | | Reject.ifNull(value); |
| | |
| | | // No additional validation required. |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public InetAddress decodeValue(String value) { |
| | | Reject.ifNull(value); |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String encodeValue(InetAddress value) { |
| | | // We should return the host name if it is available, or the IP |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(PropertyDefinitionVisitor<R, P> v, P p) { |
| | | return v.visitIPAddress(this, p); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(PropertyValueVisitor<R, P> v, InetAddress value, P p) { |
| | | return v.visitIPAddress(this, value, p); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int compare(InetAddress o1, InetAddress o2) { |
| | | return o1.getHostAddress().compareTo(o2.getHostAddress()); |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | * Portions Copyright 2015-2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.config; |
| | |
| | | /** The plural name of the relation. */ |
| | | private final String pluralName; |
| | | |
| | | /** |
| | | * The optional default managed objects associated with this |
| | | * instantiable relation definition. |
| | | */ |
| | | /** The optional default managed objects associated with this instantiable relation definition. */ |
| | | private final Map<String, DefaultManagedObject<? extends C, ? extends S>> defaultManagedObjects = |
| | | new HashMap<>(); |
| | | |
| | |
| | | this.namingPropertyDefinition = namingPropertyDefinition; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected InstantiableRelationDefinition<C, S> buildInstance(Common<C, S> common) { |
| | | return new InstantiableRelationDefinition<>(common, pluralName, namingPropertyDefinition, |
| | |
| | | /** The plural name of the relation. */ |
| | | private final String pluralName; |
| | | |
| | | /** |
| | | * The optional default managed objects associated with this |
| | | * instantiable relation definition. |
| | | */ |
| | | /** The optional default managed objects associated with this instantiable relation definition. */ |
| | | private final Map<String, DefaultManagedObject<? extends C, ? extends S>> defaultManagedObjects; |
| | | |
| | | /** Private constructor. */ |
| | |
| | | this.defaultManagedObjects = defaultManagedObjects; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(RelationDefinitionVisitor<R, P> v, P p) { |
| | | return v.visitInstantiable(this, p); |
| | |
| | | return ManagedObjectDefinitionI18NResource.getInstance().getMessage(getParentDefinition(), property, locale); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void toString(StringBuilder builder) { |
| | | builder.append("name="); |
| | |
| | | builder.append(getChildDefinition().getName()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected void initialize() throws Exception { |
| | | for (DefaultManagedObject<?, ?> dmo : defaultManagedObjects.values()) { |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.config; |
| | |
| | | */ |
| | | private final boolean allowUnlimited; |
| | | |
| | | /** |
| | | * An interface for incrementally constructing integer property definitions. |
| | | */ |
| | | /** An interface for incrementally constructing integer property definitions. */ |
| | | public static final class Builder extends AbstractBuilder<Integer, IntegerPropertyDefinition> { |
| | | |
| | | /** The lower limit of the property value. */ |
| | |
| | | this.allowUnlimited = allowUnlimited; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected IntegerPropertyDefinition buildInstance(AbstractManagedObjectDefinition<?, ?> d, |
| | | String propertyName, EnumSet<PropertyOption> options, AdministratorAction adminAction, |
| | |
| | | return allowUnlimited; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void validateValue(Integer value) { |
| | | Reject.ifNull(value); |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String encodeValue(Integer value) { |
| | | Reject.ifNull(value); |
| | |
| | | return value.toString(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Integer decodeValue(String value) { |
| | | Reject.ifNull(value); |
| | |
| | | return i; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(PropertyDefinitionVisitor<R, P> v, P p) { |
| | | return v.visitInteger(this, p); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(PropertyValueVisitor<R, P> v, Integer value, P p) { |
| | | return v.visitInteger(this, value, p); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void toString(StringBuilder builder) { |
| | | super.toString(builder); |
| | |
| | | builder.append(allowUnlimited); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int compare(Integer o1, Integer o2) { |
| | | return o1.compareTo(o2); |
| | |
| | | */ |
| | | public final class ManagedObjectAlreadyExistsException extends OperationsException { |
| | | |
| | | /** |
| | | * Version ID required by serializable classes. |
| | | */ |
| | | /** Version ID required by serializable classes. */ |
| | | private static final long serialVersionUID = -2344653674171609366L; |
| | | |
| | | /** |
| | | * Create a managed object already exists exception. |
| | | */ |
| | | /** Create a managed object already exists exception. */ |
| | | public ManagedObjectAlreadyExistsException() { |
| | | super(ERR_MANAGED_OBJECT_ALREADY_EXISTS_EXCEPTION.get()); |
| | | } |
| | |
| | | |
| | | import static com.forgerock.opendj.ldap.config.ConfigMessages.*; |
| | | |
| | | /** |
| | | * The requested managed object could not be located. |
| | | */ |
| | | /** The requested managed object could not be located. */ |
| | | public class ManagedObjectNotFoundException extends OperationsException { |
| | | |
| | | /** |
| | | * Version ID required by serializable classes. |
| | | */ |
| | | /** Version ID required by serializable classes. */ |
| | | private static final long serialVersionUID = -477551786551892978L; |
| | | |
| | | /** |
| | | * Create a managed object not found exception. |
| | | */ |
| | | /** Create a managed object not found exception. */ |
| | | public ManagedObjectNotFoundException() { |
| | | super(ERR_MANAGED_OBJECT_NOT_FOUND_EXCEPTION.get()); |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS. |
| | | * Portions Copyright 2011-2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.config; |
| | |
| | | */ |
| | | public final class ManagedObjectPath<C extends ConfigurationClient, S extends Configuration> { |
| | | |
| | | /** |
| | | * A serialize which is used to generate the toDN representation. |
| | | */ |
| | | /** A serialize which is used to generate the toDN representation. */ |
| | | private static final class DNSerializer implements ManagedObjectPathSerializer { |
| | | |
| | | /** The current DN. */ |
| | |
| | | this.profile = LDAPProfile.getInstance(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> void appendManagedObjectPathElement( |
| | | InstantiableRelationDefinition<? super C, ? super S> r, AbstractManagedObjectDefinition<C, S> d, |
| | | String name) { |
| | |
| | | dn = dn.child(new RDN(attrType, name)); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> void appendManagedObjectPathElement( |
| | | SetRelationDefinition<? super C, ? super S> r, AbstractManagedObjectDefinition<C, S> d) { |
| | | // Add the RDN sequence representing the relation. |
| | |
| | | dn = dn.child(new RDN(attrType, d.getName())); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> void appendManagedObjectPathElement( |
| | | OptionalRelationDefinition<? super C, ? super S> r, AbstractManagedObjectDefinition<C, S> d) { |
| | | // Add the RDN sequence representing the relation. |
| | | appendManagedObjectPathElement(r); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> void appendManagedObjectPathElement( |
| | | SingletonRelationDefinition<? super C, ? super S> r, AbstractManagedObjectDefinition<C, S> d) { |
| | | // Add the RDN sequence representing the relation. |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Abstract path element. |
| | | */ |
| | | /** Abstract path element. */ |
| | | private static abstract class Element<C extends ConfigurationClient, S extends Configuration> { |
| | | |
| | | /** The type of managed object referenced by this element. */ |
| | |
| | | public abstract void serialize(ManagedObjectPathSerializer serializer); |
| | | } |
| | | |
| | | /** |
| | | * A path element representing an instantiable managed object. |
| | | */ |
| | | /** A path element representing an instantiable managed object. */ |
| | | private static final class InstantiableElement<C extends ConfigurationClient, S extends Configuration> extends |
| | | Element<C, S> { |
| | | |
| | |
| | | this.name = name; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getName() { |
| | | return name; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public InstantiableRelationDefinition<? super C, ? super S> getRelationDefinition() { |
| | | return r; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void serialize(ManagedObjectPathSerializer serializer) { |
| | | serializer.appendManagedObjectPathElement(r, getManagedObjectDefinition(), name); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * A path element representing an optional managed object. |
| | | */ |
| | | /** A path element representing an optional managed object. */ |
| | | private static final class OptionalElement<C extends ConfigurationClient, S extends Configuration> extends |
| | | Element<C, S> { |
| | | |
| | |
| | | this.r = r; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public OptionalRelationDefinition<? super C, ? super S> getRelationDefinition() { |
| | | return r; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void serialize(ManagedObjectPathSerializer serializer) { |
| | | serializer.appendManagedObjectPathElement(r, getManagedObjectDefinition()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * A path element representing an set managed object. |
| | | */ |
| | | /** A path element representing an set managed object. */ |
| | | private static final class SetElement<C extends ConfigurationClient, S extends Configuration> extends |
| | | Element<C, S> { |
| | | |
| | |
| | | this.r = r; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public SetRelationDefinition<? super C, ? super S> getRelationDefinition() { |
| | | return r; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void serialize(ManagedObjectPathSerializer serializer) { |
| | | serializer.appendManagedObjectPathElement(r, getManagedObjectDefinition()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * A path element representing a singleton managed object. |
| | | */ |
| | | /** A path element representing a singleton managed object. */ |
| | | private static final class SingletonElement<C extends ConfigurationClient, S extends Configuration> extends |
| | | Element<C, S> { |
| | | |
| | |
| | | this.r = r; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public SingletonRelationDefinition<? super C, ? super S> getRelationDefinition() { |
| | | return r; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void serialize(ManagedObjectPathSerializer serializer) { |
| | | serializer.appendManagedObjectPathElement(r, getManagedObjectDefinition()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * A serialize which is used to generate the toString representation. |
| | | */ |
| | | /** A serialize which is used to generate the toString representation. */ |
| | | private static final class StringSerializer implements ManagedObjectPathSerializer { |
| | | |
| | | /** Serialize to this string builder. */ |
| | |
| | | this.builder = builder; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <M extends ConfigurationClient, N extends Configuration> void appendManagedObjectPathElement( |
| | | InstantiableRelationDefinition<? super M, ? super N> r, AbstractManagedObjectDefinition<M, N> d, |
| | | String name) { |
| | |
| | | builder.append(name.replace("/", "//")); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <M extends ConfigurationClient, N extends Configuration> void appendManagedObjectPathElement( |
| | | OptionalRelationDefinition<? super M, ? super N> r, AbstractManagedObjectDefinition<M, N> d) { |
| | | serializeElement(r, d); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <M extends ConfigurationClient, N extends Configuration> void appendManagedObjectPathElement( |
| | | SingletonRelationDefinition<? super M, ? super N> r, AbstractManagedObjectDefinition<M, N> d) { |
| | | serializeElement(r, d); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <M extends ConfigurationClient, N extends Configuration> void appendManagedObjectPathElement( |
| | | SetRelationDefinition<? super M, ? super N> r, AbstractManagedObjectDefinition<M, N> d) { |
| | | serializeElement(r, d); |
| | |
| | | return create(elements, lastElement); |
| | | } |
| | | |
| | | /** |
| | | * Factory method required in order to allow generic wild-card |
| | | * construction of new paths. |
| | | */ |
| | | /** Factory method required in order to allow generic wild-card construction of new paths. */ |
| | | private static <C extends ConfigurationClient, S extends Configuration> ManagedObjectPath<C, S> create( |
| | | LinkedList<Element<?, ?>> elements, Element<C, S> lastElement) { |
| | | return new ManagedObjectPath<>(elements, lastElement.getRelationDefinition(), |
| | |
| | | return child(r, r.getChildDefinition()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean equals(Object obj) { |
| | | if (obj == this) { |
| | |
| | | return r; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int hashCode() { |
| | | return toString().hashCode(); |
| | |
| | | return serializer.toDN(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | StringBuilder builder = new StringBuilder(); |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.config; |
| | |
| | | */ |
| | | public abstract class OperationsException extends AdminException { |
| | | |
| | | /** |
| | | * Serialization ID. |
| | | */ |
| | | /** Serialization ID. */ |
| | | private static final long serialVersionUID = 6329910102360262187L; |
| | | |
| | | /** |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | * Portions Copyright 2015-2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.config; |
| | |
| | | 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. |
| | | */ |
| | | /** The optional default managed object associated with this optional relation. */ |
| | | private DefaultManagedObject<? extends C, ? extends S> defaultManagedObject; |
| | | |
| | | /** |
| | |
| | | this.defaultManagedObject = defaultManagedObject; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected OptionalRelationDefinition<C, S> buildInstance(Common<C, S> common) { |
| | | return new OptionalRelationDefinition<>(common, defaultManagedObject); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * The optional default managed object associated with this |
| | | * optional relation. |
| | | */ |
| | | /** The optional default managed object associated with this optional relation. */ |
| | | private final DefaultManagedObject<? extends C, ? extends S> defaultManagedObject; |
| | | |
| | | /** Private constructor. */ |
| | |
| | | this.defaultManagedObject = defaultManagedObject; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(RelationDefinitionVisitor<R, P> v, P p) { |
| | | return v.visitOptional(this, p); |
| | |
| | | return defaultManagedObject; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void toString(StringBuilder builder) { |
| | | builder.append("name="); |
| | |
| | | builder.append(getChildDefinition().getName()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected void initialize() throws Exception { |
| | | if (defaultManagedObject != null) { |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | * Portions Copyright 2015-2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.config; |
| | |
| | | * @return a negative integer, zero, or a positive integer as the first |
| | | * argument is less than, equal to, or greater than the second. |
| | | */ |
| | | @Override |
| | | public int compare(T o1, T o2) { |
| | | Reject.ifNull(o1); |
| | | Reject.ifNull(o2); |
| | |
| | | * property definition is less than, equal to, or greater than the |
| | | * specified property definition. |
| | | */ |
| | | @Override |
| | | public final int compareTo(PropertyDefinition<?> o) { |
| | | int rc = propertyName.compareTo(o.propertyName); |
| | | if (rc == 0) { |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2014-2015 ForgeRock AS. |
| | | * Portions copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config; |
| | | |
| | |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.util.Utils; |
| | | |
| | | /** |
| | | * A property definition visitor which can be used to generate syntax usage |
| | | * information. |
| | | */ |
| | | /** A property definition visitor which can be used to generate syntax usage information. */ |
| | | public final class PropertyDefinitionUsageBuilder { |
| | | |
| | | /** |
| | | * Underlying implementation. |
| | | */ |
| | | /** Underlying implementation. */ |
| | | private static final class MyPropertyDefinitionVisitor extends |
| | | PropertyDefinitionVisitor<LocalizableMessage, Void> { |
| | | /** |
| | | * Flag indicating whether detailed syntax information will be |
| | | * generated. |
| | | */ |
| | | /** Flag indicating whether detailed syntax information will be generated. */ |
| | | private final boolean isDetailed; |
| | | |
| | | /** The formatter to use for numeric values. */ |
| | |
| | | this.numberFormat.setMaximumFractionDigits(2); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> LocalizableMessage visitAggregation( |
| | | AggregationPropertyDefinition<C, S> d, Void p) { |
| | | return LocalizableMessage.raw("NAME"); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LocalizableMessage visitAttributeType(AttributeTypePropertyDefinition d, Void p) { |
| | | return LocalizableMessage.raw("OID"); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LocalizableMessage visitACI(ACIPropertyDefinition d, Void p) { |
| | | return LocalizableMessage.raw("ACI"); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LocalizableMessage visitBoolean(BooleanPropertyDefinition d, Void p) { |
| | | if (isDetailed) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LocalizableMessage visitClass(ClassPropertyDefinition d, Void p) { |
| | | if (isDetailed && !d.getInstanceOfInterface().isEmpty()) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LocalizableMessage visitDN(DNPropertyDefinition d, Void p) { |
| | | if (isDetailed && d.getBaseDN() != null) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LocalizableMessage visitDuration(DurationPropertyDefinition d, Void p) { |
| | | LocalizableMessageBuilder builder = new LocalizableMessageBuilder(); |
| | |
| | | return builder.toMessage(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <E extends Enum<E>> LocalizableMessage visitEnum(EnumPropertyDefinition<E> d, Void p) { |
| | | if (!isDetailed) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LocalizableMessage visitInteger(IntegerPropertyDefinition d, Void p) { |
| | | LocalizableMessageBuilder builder = new LocalizableMessageBuilder(); |
| | |
| | | return builder.toMessage(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LocalizableMessage visitIPAddress(IPAddressPropertyDefinition d, Void p) { |
| | | return LocalizableMessage.raw("HOST_NAME"); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LocalizableMessage visitIPAddressMask(IPAddressMaskPropertyDefinition d, Void p) { |
| | | return LocalizableMessage.raw("IP_ADDRESS_MASK"); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LocalizableMessage visitSize(SizePropertyDefinition d, Void p) { |
| | | LocalizableMessageBuilder builder = new LocalizableMessageBuilder(); |
| | |
| | | return builder.toMessage(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LocalizableMessage visitString(StringPropertyDefinition d, Void p) { |
| | | if (d.getPattern() != null) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <T> LocalizableMessage visitUnknown(PropertyDefinition<T> d, Void p) { |
| | | return LocalizableMessage.raw("?"); |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.config; |
| | |
| | | */ |
| | | public abstract class PropertyDefinitionVisitor<R, P> { |
| | | |
| | | /** |
| | | * Default constructor. |
| | | */ |
| | | /** Default constructor. */ |
| | | protected PropertyDefinitionVisitor() { |
| | | // No implementation required. |
| | | } |
| | |
| | | */ |
| | | public final class PropertyException extends RuntimeException implements LocalizableException { |
| | | |
| | | /** |
| | | * Version ID required by serializable classes. |
| | | */ |
| | | /** Version ID required by serializable classes. */ |
| | | private static final long serialVersionUID = -8465109598081914482L; |
| | | |
| | | /** |
| | |
| | | /** LocalizableMessage that explains the problem. */ |
| | | private final LocalizableMessage message; |
| | | |
| | | /** |
| | | * The property definition associated with the property that caused |
| | | * the exception. |
| | | */ |
| | | /** The property definition associated with the property that caused the exception. */ |
| | | private final PropertyDefinition<?> pd; |
| | | |
| | | private PropertyException(final PropertyDefinition<?> pd, final LocalizableMessage message) { |
| | |
| | | this.pd = pd; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LocalizableMessage getMessageObject() { |
| | | return message; |
| | | } |
| | |
| | | */ |
| | | public class PropertyNotFoundException extends OperationsException { |
| | | |
| | | /** |
| | | * Serialization ID. |
| | | */ |
| | | /** Serialization ID. */ |
| | | private static final long serialVersionUID = -895548482881819610L; |
| | | |
| | | /** The name of the property that could not be found. */ |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.config; |
| | | |
| | | /** |
| | | * 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 |
| | |
| | | */ |
| | | HIDDEN, |
| | | |
| | | /** |
| | | * Use this option to identify properties which must have a value. |
| | | */ |
| | | /** Use this option to identify properties which must have a value. */ |
| | | MANDATORY, |
| | | |
| | | /** |
| | | * Use this option to identify properties which are multi-valued. |
| | | */ |
| | | /** Use this option to identify properties which are multi-valued. */ |
| | | MULTI_VALUED, |
| | | |
| | | /** |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.config; |
| | |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | | |
| | | /** |
| | | * An interface which can be used to initialize the contents of a managed |
| | | * object. |
| | | */ |
| | | /** 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. */ |
| | | PropertyProvider DEFAULT_PROVIDER = new PropertyProvider() { |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <T> Collection<T> getPropertyValues(PropertyDefinition<T> d) { |
| | | return Collections.<T> emptySet(); |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.config; |
| | |
| | | */ |
| | | public abstract class PropertyValueVisitor<R, P> { |
| | | |
| | | /** |
| | | * Default constructor. |
| | | */ |
| | | /** Default constructor. */ |
| | | protected PropertyValueVisitor() { |
| | | // No implementation required. |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | * Portions Copyright 2015-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config; |
| | | |
| | |
| | | /** The path of the referenced managed object. */ |
| | | private final ManagedObjectPath<C, S> path; |
| | | |
| | | /** |
| | | * The instantiable relation in the parent which contains the |
| | | * referenced managed object. |
| | | */ |
| | | /** The instantiable relation in the parent which contains the referenced managed object. */ |
| | | private final InstantiableRelationDefinition<C, S> relation; |
| | | |
| | | /** Private constructor. */ |
| | |
| | | return path.toDN(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | return name; |
| | | } |
| | | |
| | | /** |
| | | * Normalize a value using the specified naming property definition |
| | | * if defined. |
| | | */ |
| | | /** Normalize a value using the specified naming property definition if defined. */ |
| | | private <T> String normalizeName(PropertyDefinition<T> pd) { |
| | | if (pd != null) { |
| | | try { |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | * Portions Copyright 2015-2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.config; |
| | |
| | | return common.options.contains(option); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final String toString() { |
| | | StringBuilder builder = new StringBuilder(); |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.config; |
| | | |
| | | /** |
| | | * 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 |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config; |
| | | |
| | |
| | | this.offset = offset; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(DefaultBehaviorProviderVisitor<T, R, P> v, P p) { |
| | | return v.visitRelativeInherited(this, p); |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | * Portions Copyright 2015-2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.config; |
| | |
| | | /** The plural name of the relation. */ |
| | | private final String pluralName; |
| | | |
| | | /** |
| | | * The optional default managed objects associated with this |
| | | * set relation definition. |
| | | */ |
| | | /** The optional default managed objects associated with this set relation definition. */ |
| | | private final Map<String, DefaultManagedObject<? extends C, ? extends S>> defaultManagedObjects = |
| | | new HashMap<>(); |
| | | |
| | |
| | | defaultManagedObject); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected SetRelationDefinition<C, S> buildInstance(Common<C, S> common) { |
| | | return new SetRelationDefinition<>(common, pluralName, defaultManagedObjects); |
| | |
| | | /** The plural name of the relation. */ |
| | | private final String pluralName; |
| | | |
| | | /** |
| | | * The optional default managed objects associated with this |
| | | * set relation definition. |
| | | */ |
| | | /** The optional default managed objects associated with this set relation definition. */ |
| | | private final Map<String, DefaultManagedObject<? extends C, ? extends S>> defaultManagedObjects; |
| | | |
| | | /** Private constructor. */ |
| | |
| | | this.defaultManagedObjects = defaultManagedObjects; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(RelationDefinitionVisitor<R, P> v, P p) { |
| | | return v.visitSet(this, p); |
| | |
| | | return ManagedObjectDefinitionI18NResource.getInstance().getMessage(getParentDefinition(), property, locale); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void toString(StringBuilder builder) { |
| | | builder.append("name="); |
| | |
| | | builder.append(getChildDefinition().getName()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected void initialize() throws Exception { |
| | | for (DefaultManagedObject<?, ?> dmo : defaultManagedObjects.values()) { |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | * Portions Copyright 2015-2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.config; |
| | |
| | | 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. |
| | | */ |
| | | /** The optional default managed object associated with this singleton relation. */ |
| | | private DefaultManagedObject<? extends C, ? extends S> defaultManagedObject; |
| | | |
| | | /** |
| | |
| | | this.defaultManagedObject = defaultManagedObject; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected SingletonRelationDefinition<C, S> buildInstance(Common<C, S> common) { |
| | | return new SingletonRelationDefinition<>(common, defaultManagedObject); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * The optional default managed object associated with this |
| | | * singleton relation. |
| | | */ |
| | | /** The optional default managed object associated with this singleton relation. */ |
| | | private final DefaultManagedObject<? extends C, ? extends S> defaultManagedObject; |
| | | |
| | | /** Private constructor. */ |
| | |
| | | this.defaultManagedObject = defaultManagedObject; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(RelationDefinitionVisitor<R, P> v, P p) { |
| | | return v.visitSingleton(this, p); |
| | |
| | | return defaultManagedObject; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void toString(StringBuilder builder) { |
| | | builder.append("name="); |
| | |
| | | builder.append(getChildDefinition().getName()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected void initialize() throws Exception { |
| | | if (defaultManagedObject != null) { |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config; |
| | | |
| | |
| | | */ |
| | | private final boolean allowUnlimited; |
| | | |
| | | /** |
| | | * An interface for incrementally constructing memory size property |
| | | * definitions. |
| | | */ |
| | | /** An interface for incrementally constructing memory size property definitions. */ |
| | | public static final class Builder extends AbstractBuilder<Long, SizePropertyDefinition> { |
| | | |
| | | /** The lower limit of the property value in bytes. */ |
| | |
| | | this.allowUnlimited = allowUnlimited; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected SizePropertyDefinition buildInstance(AbstractManagedObjectDefinition<?, ?> d, String propertyName, |
| | | EnumSet<PropertyOption> options, AdministratorAction adminAction, |
| | |
| | | return allowUnlimited; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void validateValue(Long value) { |
| | | Reject.ifNull(value); |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String encodeValue(Long value) { |
| | | Reject.ifNull(value); |
| | |
| | | return builder.toString(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Long decodeValue(String value) { |
| | | Reject.ifNull(value); |
| | |
| | | return i; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(PropertyDefinitionVisitor<R, P> v, P p) { |
| | | return v.visitSize(this, p); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(PropertyValueVisitor<R, P> v, Long value, P p) { |
| | | return v.visitSize(this, value, p); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void toString(StringBuilder builder) { |
| | | super.toString(builder); |
| | |
| | | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int compare(Long o1, Long o2) { |
| | | return o1.compareTo(o2); |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | * Portions Copyright 2015-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config; |
| | | |
| | |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | |
| | | /** |
| | | * This enumeration defines various memory size units. |
| | | */ |
| | | /** This enumeration defines various memory size units. */ |
| | | public enum SizeUnit { |
| | | |
| | | /** A byte unit. */ |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.config; |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | /** |
| | | * String property definition. |
| | | */ |
| | | /** String property definition. */ |
| | | public final class StringPropertyDefinition extends PropertyDefinition<String> { |
| | | |
| | | /** |
| | | * An interface for incrementally constructing string property definitions. |
| | | */ |
| | | /** An interface for incrementally constructing string property definitions. */ |
| | | public static final class Builder extends AbstractBuilder<String, StringPropertyDefinition> { |
| | | |
| | | /** |
| | | * Flag indicating whether values of this property are |
| | | * case-insensitive. |
| | | */ |
| | | /** Flag indicating whether values of this property are case-insensitive. */ |
| | | private boolean isCaseInsensitive = true; |
| | | |
| | | /** Optional pattern which values of this property must match. */ |
| | | private Pattern pattern; |
| | | |
| | | /** |
| | | * Pattern usage which provides a user-friendly summary of the |
| | | * pattern if present. |
| | | */ |
| | | /** Pattern usage which provides a user-friendly summary of the pattern if present. */ |
| | | private String patternUsage; |
| | | |
| | | /** Private constructor. */ |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected StringPropertyDefinition buildInstance(AbstractManagedObjectDefinition<?, ?> d, |
| | | String propertyName, EnumSet<PropertyOption> options, AdministratorAction adminAction, |
| | |
| | | return new Builder(d, propertyName); |
| | | } |
| | | |
| | | /** |
| | | * Flag indicating whether values of this property are |
| | | * case-insensitive. |
| | | */ |
| | | /** Flag indicating whether values of this property are case-insensitive. */ |
| | | private final boolean isCaseInsensitive; |
| | | |
| | | /** Optional pattern which values of this property must match. */ |
| | | private final Pattern pattern; |
| | | |
| | | /** |
| | | * Pattern usage which provides a user-friendly summary of the |
| | | * pattern if present. |
| | | */ |
| | | /** Pattern usage which provides a user-friendly summary of the pattern if present. */ |
| | | private final String patternUsage; |
| | | |
| | | /** Private constructor. */ |
| | |
| | | this.patternUsage = patternUsage; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(PropertyDefinitionVisitor<R, P> v, P p) { |
| | | return v.visitString(this, p); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(PropertyValueVisitor<R, P> v, String value, P p) { |
| | | return v.visitString(this, value, p); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String decodeValue(String value) { |
| | | Reject.ifNull(value); |
| | |
| | | return isCaseInsensitive; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String normalizeValue(String value) { |
| | | Reject.ifNull(value); |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void validateValue(String value) { |
| | | Reject.ifNull(value); |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | * Portions Copyright 2015-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config; |
| | | |
| | |
| | | this.name = name; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final int compareTo(Tag o) { |
| | | return name.compareTo(o.name); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final boolean equals(Object obj) { |
| | | if (this == obj) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final int hashCode() { |
| | | return name.hashCode(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final String toString() { |
| | | return name; |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config; |
| | | |
| | |
| | | return INSTANCE; |
| | | } |
| | | |
| | | /** |
| | | * Private constructor. |
| | | */ |
| | | /** Private constructor. */ |
| | | private TopCfgDefn() { |
| | | super("top", null); |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config; |
| | | |
| | |
| | | */ |
| | | public final class UndefinedDefaultBehaviorProvider<T> extends DefaultBehaviorProvider<T> { |
| | | |
| | | /** |
| | | * Create an undefined default behavior provider. |
| | | */ |
| | | /** Create an undefined default behavior provider. */ |
| | | public UndefinedDefaultBehaviorProvider() { |
| | | // No implementation required. |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <R, P> R accept(DefaultBehaviorProviderVisitor<T, R, P> v, P p) { |
| | | return v.visitUndefined(this, p); |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config.client; |
| | | |
| | |
| | | */ |
| | | public abstract class AdminClientException extends AdminException { |
| | | |
| | | /** |
| | | * Serialization ID. |
| | | */ |
| | | /** Serialization ID. */ |
| | | private static final long serialVersionUID = 4044747533980824456L; |
| | | |
| | | /** |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.config.client; |
| | |
| | | */ |
| | | public abstract class AdminSecurityException extends AdminClientException { |
| | | |
| | | /** |
| | | * Fake serialization ID. |
| | | */ |
| | | /** Fake serialization ID. */ |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | |
| | | */ |
| | | public class AuthenticationException extends AdminSecurityException { |
| | | |
| | | /** |
| | | * Serialization ID. |
| | | */ |
| | | /** Serialization ID. */ |
| | | private static final long serialVersionUID = 3544797197747686958L; |
| | | |
| | | /** |
| | | * Creates an authentication exception with a default message. |
| | | */ |
| | | /** Creates an authentication exception with a default message. */ |
| | | public AuthenticationException() { |
| | | super(ERR_AUTHENTICATION_EXCEPTION_DEFAULT.get()); |
| | | } |
| | |
| | | */ |
| | | public class AuthenticationNotSupportedException extends AdminSecurityException { |
| | | |
| | | /** |
| | | * Serialization ID. |
| | | */ |
| | | /** Serialization ID. */ |
| | | private static final long serialVersionUID = 7387834052676291793L; |
| | | |
| | | /** |
| | | * Creates an authentication not supported exception with a default message. |
| | | */ |
| | | /** Creates an authentication not supported exception with a default message. */ |
| | | public AuthenticationNotSupportedException() { |
| | | super(ERR_AUTHENTICATION_NOT_SUPPORTED_EXCEPTION_DEFAULT.get()); |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS. |
| | | * Portions Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config.client; |
| | | |
| | |
| | | */ |
| | | public abstract class ClientConstraintHandler { |
| | | |
| | | /** |
| | | * Creates a new client constraint handler. |
| | | */ |
| | | /** Creates a new client constraint handler. */ |
| | | protected ClientConstraintHandler() { |
| | | // No implementation required. |
| | | } |
| | |
| | | */ |
| | | public class ConcurrentModificationException extends OperationsException { |
| | | |
| | | /** |
| | | * Serialization ID. |
| | | */ |
| | | /** Serialization ID. */ |
| | | 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()); |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS. |
| | | * Portions Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config.client; |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.LdapException; |
| | | import org.forgerock.opendj.server.config.client.RootCfgClient; |
| | | |
| | | /** |
| | | * Driver based client management connection context. |
| | | */ |
| | | /** Driver based client management connection context. */ |
| | | public abstract class DriverBasedManagementContext implements ManagementContext { |
| | | |
| | | /** |
| | | * Creates a new management context. |
| | | */ |
| | | /** Creates a new management context. */ |
| | | protected DriverBasedManagementContext() { |
| | | // No implementation required. |
| | | } |
| | |
| | | */ |
| | | public class IllegalManagedObjectNameException extends OperationsException { |
| | | |
| | | /** |
| | | * Serialization ID. |
| | | */ |
| | | /** Serialization ID. */ |
| | | private static final long serialVersionUID = 7491748228684293291L; |
| | | |
| | | /** Create the message. */ |
| | |
| | | */ |
| | | public class ManagedObjectDecodingException extends DecodingException { |
| | | |
| | | /** |
| | | * Version ID required by serializable classes. |
| | | */ |
| | | /** Version ID required by serializable classes. */ |
| | | private static final long serialVersionUID = -4268510652395945357L; |
| | | |
| | | /** Create the message. */ |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS. |
| | | * Portions Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config.client; |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.LdapException; |
| | | import org.forgerock.opendj.server.config.client.RootCfgClient; |
| | | |
| | | /** |
| | | * Client management connection context. |
| | | */ |
| | | /** Client management connection context. */ |
| | | public interface ManagementContext extends Closeable { |
| | | |
| | | /** |
| | |
| | | */ |
| | | public class MissingMandatoryPropertiesException extends OperationsException { |
| | | |
| | | /** |
| | | * Serialization ID. |
| | | */ |
| | | /** Serialization ID. */ |
| | | private static final long serialVersionUID = 6342522125252055588L; |
| | | |
| | | /** Create the message. */ |
| | |
| | | */ |
| | | public class OperationRejectedException extends AdminClientException { |
| | | |
| | | /** |
| | | * The type of operation that caused this exception. |
| | | */ |
| | | /** The type of operation that caused this exception. */ |
| | | public enum OperationType { |
| | | /** |
| | | * A managed object could not be created. |
| | | */ |
| | | /** A managed object could not be created. */ |
| | | CREATE, |
| | | |
| | | /** |
| | | * A managed object could not be deleted. |
| | | */ |
| | | /** A managed object could not be deleted. */ |
| | | DELETE, |
| | | |
| | | /** |
| | | * A managed object could not be modified. |
| | | */ |
| | | /** A managed object could not be modified. */ |
| | | MODIFY; |
| | | } |
| | | |
| | | /** |
| | | * Serialization ID. |
| | | */ |
| | | /** Serialization ID. */ |
| | | private static final long serialVersionUID = 8547688890613079044L; |
| | | |
| | | /** Gets the default message. */ |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2014-2015 ForgeRock AS. |
| | | * Portions copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.config.client.ldap; |
| | |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.RDN; |
| | | |
| | | /** |
| | | * A strategy for creating <code>DN</code>s from managed object paths. |
| | | */ |
| | | /** A strategy for creating <code>DN</code>s from managed object paths. */ |
| | | final class DNBuilder implements ManagedObjectPathSerializer { |
| | | |
| | | /** |
| | |
| | | this.profile = profile; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> void appendManagedObjectPathElement( |
| | | InstantiableRelationDefinition<? super C, ? super S> r, |
| | | AbstractManagedObjectDefinition<C, S> d, String name) { |
| | |
| | | return rdnsOfDn; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> void appendManagedObjectPathElement( |
| | | OptionalRelationDefinition<? super C, ? super S> r, |
| | | AbstractManagedObjectDefinition<C, S> d) { |
| | |
| | | appendManagedObjectPathElement(r); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> void appendManagedObjectPathElement( |
| | | SingletonRelationDefinition<? super C, ? super S> r, |
| | | AbstractManagedObjectDefinition<C, S> d) { |
| | |
| | | appendManagedObjectPathElement(r); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> void appendManagedObjectPathElement( |
| | | SetRelationDefinition<? super C, ? super S> r, AbstractManagedObjectDefinition<C, S> d) { |
| | | // Add the RDN sequence representing the relation. |
| | |
| | | import org.forgerock.opendj.ldap.responses.SearchResultEntry; |
| | | import org.forgerock.opendj.ldif.ConnectionEntryReader; |
| | | |
| | | /** |
| | | * The LDAP management context driver implementation. |
| | | */ |
| | | /** The LDAP management context driver implementation. */ |
| | | final class LDAPDriver extends Driver { |
| | | |
| | | /** |
| | | * A visitor which is used to decode property LDAP values. |
| | | */ |
| | | /** A visitor which is used to decode property LDAP values. */ |
| | | private static final class ValueDecoder extends PropertyDefinitionVisitor<Object, String> { |
| | | /** |
| | | * Decodes the provided property LDAP value. |
| | |
| | | // Do nothing. |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> Object visitAggregation( |
| | | AggregationPropertyDefinition<C, S> d, String p) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <T> Object visitUnknown(PropertyDefinition<T> d, String p) { |
| | | // By default the property definition's decoder will do. |
| | |
| | | |
| | | private final Connection connection; |
| | | |
| | | /** |
| | | * The LDAP profile which should be used to construct LDAP |
| | | * requests and decode LDAP responses. |
| | | */ |
| | | /** The LDAP profile which should be used to construct LDAP requests and decode LDAP responses. */ |
| | | private final LDAPProfile profile; |
| | | |
| | | /** |
| | |
| | | this.context = context; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void close() { |
| | | connection.close(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> ManagedObject<? extends C> getManagedObject( |
| | | ManagedObjectPath<C, S> path) throws DefinitionDecodingException, ManagedObjectDecodingException, |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ManagedObject<RootCfgClient> getRootConfigurationManagedObject() { |
| | | return new LDAPManagedObject<>(this, RootCfgDefn.getInstance(), ManagedObjectPath.emptyPath(), |
| | | new PropertySet(), true, null); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> String[] listManagedObjects( |
| | | ManagedObjectPath<?, ?> parent, InstantiableRelationDefinition<C, S> rd, |
| | |
| | | return children.toArray(new String[children.size()]); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> String[] listManagedObjects( |
| | | ManagedObjectPath<?, ?> parent, SetRelationDefinition<C, S> rd, |
| | |
| | | return children.toArray(new String[children.size()]); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean managedObjectExists(ManagedObjectPath<?, ?> path) throws ManagedObjectNotFoundException, |
| | | LdapException { |
| | |
| | | return entryExists(dn); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected <C extends ConfigurationClient, S extends Configuration> void deleteManagedObject( |
| | | ManagedObjectPath<C, S> path) throws OperationRejectedException, LdapException { |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected LDAPManagementContext getManagementContext() { |
| | | return context; |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2007-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS. |
| | | * Portions Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.config.client.ldap; |
| | |
| | | */ |
| | | final class LDAPManagedObject<T extends ConfigurationClient> extends AbstractManagedObject<T> { |
| | | |
| | | /** |
| | | * A visitor which is used to encode property LDAP values. |
| | | */ |
| | | /** A visitor which is used to encode property LDAP values. */ |
| | | private static final class ValueEncoder extends PropertyValueVisitor<Object, Void> { |
| | | |
| | | /** Prevent instantiation. */ |
| | |
| | | // No implementation required. |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> Object visitAggregation( |
| | | AggregationPropertyDefinition<C, S> pd, String v, Void p) { |
| | |
| | | return reference.toDN().toString(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <P> Object visitUnknown(PropertyDefinition<P> propertyDef, P value, Void p) { |
| | | return propertyDef.encodeValue(value); |
| | |
| | | this.driver = driver; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected void addNewManagedObject() throws LdapException, OperationRejectedException, |
| | | ConcurrentModificationException, ManagedObjectAlreadyExistsException { |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected Driver getDriver() { |
| | | return driver; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected void modifyExistingManagedObject() throws ConcurrentModificationException, OperationRejectedException, |
| | | LdapException { |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected <M extends ConfigurationClient> ManagedObject<M> newInstance(ManagedObjectDefinition<M, ?> d, |
| | | ManagedObjectPath<M, ?> path, PropertySet properties, boolean existsOnServer, |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isModified() { |
| | | ManagedObjectDefinition<?, ?> d = getManagedObjectDefinition(); |
| | | for (PropertyDefinition<?> pd : d.getAllPropertyDefinitions()) { |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions copyright 2014-2015 ForgeRock AS. |
| | | * Portions copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.config.client.ldap; |
| | |
| | | import org.forgerock.opendj.server.config.client.RootCfgClient; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | /** |
| | | * An LDAP management connection context. |
| | | */ |
| | | /** An LDAP management connection context. */ |
| | | public final class LDAPManagementContext extends DriverBasedManagementContext { |
| | | |
| | | private static final class ManagementContextWrapper implements ManagementContext { |
| | |
| | | this.driver = driver; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected Driver getDriver() { |
| | | return driver; |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS. |
| | | * Portions Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config.client.spi; |
| | | |
| | |
| | | */ |
| | | public abstract class AbstractManagedObject<T extends ConfigurationClient> implements ManagedObject<T> { |
| | | |
| | | /** |
| | | * Creates any default managed objects associated with a relation |
| | | * definition. |
| | | */ |
| | | /** Creates any default managed objects associated with a relation definition. */ |
| | | private final class DefaultManagedObjectFactory implements RelationDefinitionVisitor<Void, Void> { |
| | | |
| | | /** Possible exceptions. */ |
| | |
| | | private OperationRejectedException ore; |
| | | private LdapException ere; |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> Void visitInstantiable( |
| | | InstantiableRelationDefinition<C, S> rd, Void p) { |
| | |
| | | return null; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> Void visitOptional( |
| | | OptionalRelationDefinition<C, S> rd, Void p) { |
| | |
| | | return null; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> Void visitSingleton( |
| | | SingletonRelationDefinition<C, S> rd, Void p) { |
| | |
| | | return null; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> Void visitSet(SetRelationDefinition<C, S> rd, |
| | | Void p) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * The managed object definition associated with this managed |
| | | * object. |
| | | */ |
| | | /** The managed object definition associated with this managed object. */ |
| | | private final ManagedObjectDefinition<T, ? extends Configuration> definition; |
| | | |
| | | /** |
| | |
| | | this.namingPropertyDefinition = namingPropertyDefinition; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final void commit() throws ManagedObjectAlreadyExistsException, MissingMandatoryPropertiesException, |
| | | ConcurrentModificationException, OperationRejectedException, LdapException { |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @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, |
| | |
| | | return createNewManagedObject(d, childPath, pd, name, exceptions); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final <C extends ConfigurationClient, S extends Configuration, C1 extends C> ManagedObject<C1> createChild( |
| | | OptionalRelationDefinition<C, S> r, ManagedObjectDefinition<C1, ? extends S> d, |
| | |
| | | return createNewManagedObject(d, childPath, null, null, exceptions); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final <C extends ConfigurationClient, S extends Configuration, C1 extends C> ManagedObject<C1> createChild( |
| | | SetRelationDefinition<C, S> r, ManagedObjectDefinition<C1, ? extends S> 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 DefinitionDecodingException, |
| | |
| | | return ctx.getManagedObject(path.child(r, name)); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final <C extends ConfigurationClient, S extends Configuration> ManagedObject<? extends C> getChild( |
| | | OptionalRelationDefinition<C, S> r) throws DefinitionDecodingException, ManagedObjectDecodingException, |
| | |
| | | return ctx.getManagedObject(path.child(r)); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final <C extends ConfigurationClient, S extends Configuration> ManagedObject<? extends C> getChild( |
| | | SingletonRelationDefinition<C, S> r) throws DefinitionDecodingException, ManagedObjectDecodingException, |
| | |
| | | return ctx.getManagedObject(path.child(r)); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final <C extends ConfigurationClient, S extends Configuration> ManagedObject<? extends C> getChild( |
| | | SetRelationDefinition<C, S> r, String name) throws DefinitionDecodingException, |
| | |
| | | return ctx.getManagedObject(path.child(r, cd)); |
| | | } |
| | | |
| | | /** {@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} */ |
| | | @Override |
| | | public final <P> SortedSet<P> getPropertyDefaultValues(PropertyDefinition<P> pd) { |
| | | return new TreeSet<>(getProperty(pd).getDefaultValues()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final <P> P getPropertyValue(PropertyDefinition<P> pd) { |
| | | Set<P> values = getProperty(pd).getEffectiveValues(); |
| | |
| | | return null; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final <P> SortedSet<P> getPropertyValues(PropertyDefinition<P> pd) { |
| | | return new TreeSet<>(getProperty(pd).getEffectiveValues()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final <C extends ConfigurationClient, S extends Configuration> boolean hasChild( |
| | | OptionalRelationDefinition<C, S> r) throws ConcurrentModificationException, LdapException { |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @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 ConcurrentModificationException, LdapException { |
| | | 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) |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final <C extends ConfigurationClient, S extends Configuration> String[] listChildren( |
| | | SetRelationDefinition<C, S> r) throws ConcurrentModificationException, LdapException { |
| | | 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) |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final <C extends ConfigurationClient, S extends Configuration> void removeChild( |
| | | InstantiableRelationDefinition<C, S> r, String name) throws ManagedObjectNotFoundException, |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final <C extends ConfigurationClient, S extends Configuration> void removeChild( |
| | | OptionalRelationDefinition<C, S> r) throws ManagedObjectNotFoundException, OperationRejectedException, |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final <C extends ConfigurationClient, S extends Configuration> void removeChild( |
| | | SetRelationDefinition<C, S> r, String name) throws ManagedObjectNotFoundException, |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final <P> void setPropertyValue(PropertyDefinition<P> pd, P value) { |
| | | if (value != null) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final <P> void setPropertyValues(PropertyDefinition<P> pd, Collection<P> values) { |
| | | if (pd.hasOption(PropertyOption.MONITORING)) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | StringBuilder builder = new StringBuilder(); |
| | |
| | | ManagedObjectPath<M, ?> path, PropertySet properties, boolean existsOnServer, |
| | | PropertyDefinition<?> namingPropertyDefinition); |
| | | |
| | | /** |
| | | * Creates a new managed object with no active values, just default |
| | | * values. |
| | | */ |
| | | /** Creates a new managed object with no active values, just default values. */ |
| | | private <M extends ConfigurationClient, P> ManagedObject<M> createNewManagedObject( |
| | | ManagedObjectDefinition<M, ?> d, ManagedObjectPath<M, ?> p, PropertyDefinition<P> namingPropertyDefinition, |
| | | String name, Collection<PropertyException> exceptions) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Validate that a relation definition belongs to this managed |
| | | * object. |
| | | */ |
| | | /** Validate that a relation definition belongs to this managed object. */ |
| | | private void validateRelationDefinition(RelationDefinition<?, ?> rd) { |
| | | ManagedObjectDefinition<T, ?> d = getManagedObjectDefinition(); |
| | | RelationDefinition<?, ?> tmp = d.getRelationDefinition(rd.getName()); |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS. |
| | | * Portions Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config.client.spi; |
| | | |
| | |
| | | */ |
| | | private final class DefaultValueFinder<T> implements DefaultBehaviorProviderVisitor<T, Collection<T>, Void> { |
| | | |
| | | /** |
| | | * Any exception that occurred whilst retrieving inherited default |
| | | * values. |
| | | */ |
| | | /** Any exception that occurred whilst retrieving inherited default values. */ |
| | | private PropertyException exception; |
| | | |
| | | /** The path of the managed object containing the first property. */ |
| | |
| | | this.isCreate = isCreate; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Collection<T> visitAbsoluteInherited(AbsoluteInheritedDefaultBehaviorProvider<T> d, Void p) { |
| | | try { |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@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(); |
| | |
| | | return values; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Collection<T> visitRelativeInherited(RelativeInheritedDefaultBehaviorProvider<T> d, Void p) { |
| | | try { |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Collection<T> visitUndefined(UndefinedDefaultBehaviorProvider<T> d, Void p) { |
| | | return Collections.emptySet(); |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | * Portions Copyright 2015-2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.config.client.spi; |
| | |
| | | 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() { |
| | | return activeValues.size() != pendingValues.size() |
| | |
| | | pendingValues.addAll(c); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | return getEffectiveValues().toString(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean wasEmpty() { |
| | | return activeValues.isEmpty(); |
| | |
| | | return (Property<T>) properties.get(d); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | StringBuilder builder = new StringBuilder(); |
| | |
| | | return builder.toString(); |
| | | } |
| | | |
| | | /** |
| | | * Makes all pending values active. |
| | | */ |
| | | /** Makes all pending values active. */ |
| | | void commit() { |
| | | for (MyProperty<?> p : properties.values()) { |
| | | p.commit(); |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS. |
| | | * Portions Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config.conditions; |
| | | |
| | |
| | | this.conditions = Arrays.asList(conditions); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean evaluate(ManagementContext context, ManagedObject<?> managedObject) throws LdapException { |
| | | for (Condition condition : conditions) { |
| | | if (!condition.evaluate(context, managedObject)) { |
| | |
| | | return true; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean evaluate(ServerManagedObject<?> managedObject) throws ConfigException { |
| | | for (Condition condition : conditions) { |
| | | if (!condition.evaluate(managedObject)) { |
| | |
| | | return true; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void initialize(AbstractManagedObjectDefinition<?, ?> d) throws Exception { |
| | | for (Condition condition : conditions) { |
| | | condition.initialize(d); |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS. |
| | | * Portions Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config.conditions; |
| | | |
| | |
| | | import org.forgerock.opendj.config.server.ServerManagedObject; |
| | | import org.forgerock.opendj.ldap.LdapException; |
| | | |
| | | /** |
| | | * An interface for evaluating conditions. |
| | | */ |
| | | /** An interface for evaluating conditions. */ |
| | | public interface Condition { |
| | | |
| | | /** |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS. |
| | | * Portions Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config.conditions; |
| | | |
| | |
| | | import org.forgerock.opendj.config.server.ServerManagedObject; |
| | | import org.forgerock.opendj.ldap.LdapException; |
| | | |
| | | /** |
| | | * This class consists exclusively of static methods that operate on or return |
| | | * conditions. |
| | | */ |
| | | /** This class consists exclusively of static methods that operate on or return conditions. */ |
| | | public final class Conditions { |
| | | |
| | | /** |
| | | * A condition which always evaluates to <code>false</code>. |
| | | */ |
| | | /** A condition which always evaluates to <code>false</code>. */ |
| | | public static final Condition FALSE = new Condition() { |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean evaluate(ManagementContext context, ManagedObject<?> managedObject) throws LdapException { |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean evaluate(ServerManagedObject<?> managedObject) throws ConfigException { |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void initialize(AbstractManagedObjectDefinition<?, ?> d) throws Exception { |
| | | // No implementation required. |
| | | } |
| | | |
| | | }; |
| | | |
| | | /** |
| | | * A condition which always evaluates to <code>true</code>. |
| | | */ |
| | | /** A condition which always evaluates to <code>true</code>. */ |
| | | public static final Condition TRUE = new Condition() { |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean evaluate(ManagementContext context, ManagedObject<?> managedObject) throws LdapException { |
| | | return true; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean evaluate(ServerManagedObject<?> managedObject) throws ConfigException { |
| | | return true; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void initialize(AbstractManagedObjectDefinition<?, ?> d) throws Exception { |
| | | // No implementation required. |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS. |
| | | * Portions Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config.conditions; |
| | | |
| | |
| | | this.value = value; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean evaluate(ManagementContext context, ManagedObject<?> managedObject) throws LdapException { |
| | | SortedSet<T> values = managedObject.getPropertyValues(pd); |
| | | return values.contains(value); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean evaluate(ServerManagedObject<?> managedObject) throws ConfigException { |
| | | SortedSet<T> values = managedObject.getPropertyValues(pd); |
| | | return values.contains(value); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void initialize(AbstractManagedObjectDefinition<?, ?> d) throws Exception { |
| | | // Not used. |
| | | } |
| | |
| | | this.propertyStringValue = stringValue; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean evaluate(ManagementContext context, ManagedObject<?> managedObject) throws LdapException { |
| | | return impl.evaluate(context, managedObject); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean evaluate(ServerManagedObject<?> managedObject) throws ConfigException { |
| | | return impl.evaluate(managedObject); |
| | | } |
| | |
| | | impl.setPropertyValue(managedObject); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void initialize(AbstractManagedObjectDefinition<?, ?> d) throws Exception { |
| | | // Decode the property. |
| | | buildImpl(d.getPropertyDefinition(propertyName)); |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS. |
| | | * Portions Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config.conditions; |
| | | |
| | |
| | | this.propertyName = propertyName; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean evaluate(ManagementContext context, ManagedObject<?> managedObject) throws LdapException { |
| | | SortedSet<?> values = managedObject.getPropertyValues(pd); |
| | | return !values.isEmpty(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean evaluate(ServerManagedObject<?> managedObject) throws ConfigException { |
| | | SortedSet<?> values = managedObject.getPropertyValues(pd); |
| | | return !values.isEmpty(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void initialize(AbstractManagedObjectDefinition<?, ?> d) throws Exception { |
| | | // Decode the property. |
| | | this.pd = d.getPropertyDefinition(propertyName); |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS. |
| | | * Portions Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config.conditions; |
| | | |
| | |
| | | this.condition = condition; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean evaluate(ManagementContext context, ManagedObject<?> managedObject) throws LdapException { |
| | | return !condition.evaluate(context, managedObject); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean evaluate(ServerManagedObject<?> managedObject) throws ConfigException { |
| | | return !condition.evaluate(managedObject); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void initialize(AbstractManagedObjectDefinition<?, ?> d) throws Exception { |
| | | condition.initialize(d); |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS. |
| | | * Portions Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config.conditions; |
| | | |
| | |
| | | this.conditions = Arrays.asList(conditions); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean evaluate(ManagementContext context, ManagedObject<?> managedObject) throws LdapException { |
| | | for (Condition condition : conditions) { |
| | | if (condition.evaluate(context, managedObject)) { |
| | |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean evaluate(ServerManagedObject<?> managedObject) throws ConfigException { |
| | | for (Condition condition : conditions) { |
| | | if (condition.evaluate(managedObject)) { |
| | |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void initialize(AbstractManagedObjectDefinition<?, ?> d) throws Exception { |
| | | for (Condition condition : conditions) { |
| | | condition.initialize(d); |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS. |
| | | * Portions Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config.dsconfig; |
| | | |
| | |
| | | import com.forgerock.opendj.cli.TableBuilder; |
| | | import com.forgerock.opendj.cli.TextTablePrinter; |
| | | |
| | | /** |
| | | * A utility class for converting various admin exception types into argument exceptions. |
| | | */ |
| | | /** A utility class for converting various admin exception types into argument exceptions. */ |
| | | public final class ArgumentExceptionFactory { |
| | | |
| | | /** |
| | |
| | | return point; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean equals(final Object obj) { |
| | | if (this == obj) { |
| | | return true; |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int compareTo(final BuildVersion version) { |
| | | if (major == version.major) { |
| | | if (minor == version.minor) { |
| | |
| | | return rev; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public int hashCode() { |
| | | return Arrays.hashCode(new int[] { major, minor, point, rev.hashCode() }); |
| | | } |
| | |
| | | * |
| | | * @return The string representation of the version. |
| | | */ |
| | | @Override |
| | | public String toString() { |
| | | return Utils.joinAsString(".", major, minor, point, rev); |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS. |
| | | * Portions Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.config.dsconfig; |
| | |
| | | import org.forgerock.opendj.config.RelationDefinition; |
| | | import org.forgerock.opendj.config.SetRelationDefinition; |
| | | |
| | | /** |
| | | * This class is used to access CLI profile annotations. |
| | | */ |
| | | /** This class is used to access CLI profile annotations. */ |
| | | final class CLIProfile { |
| | | |
| | | /** The singleton instance. */ |
| | |
| | | return properties.keySet(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @SuppressWarnings("unchecked") |
| | | public <T> Collection<T> getPropertyValues(PropertyDefinition<T> d) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * A help call-back which displays help about available component types. |
| | | */ |
| | | /** A help call-back which displays help about available component types. */ |
| | | private static final class TypeHelpCallback<C extends ConfigurationClient, S extends Configuration> implements |
| | | HelpCallback { |
| | | |
| | |
| | | this.d = d; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void display(ConsoleApplication app) { |
| | | app.println(INFO_DSCFG_CREATE_TYPE_HELP_HEADING.get(d.getUserFriendlyPluralName())); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Check that any referenced components are enabled if required. |
| | | */ |
| | | /** Check that any referenced components are enabled if required. */ |
| | | private static MenuResult<Void> checkReferences(ConsoleApplication app, ManagementContext context, |
| | | ManagedObject<?> mo, SubCommandHandler handler) throws ClientException { |
| | | ManagedObjectDefinition<?, ?> d = mo.getManagedObjectDefinition(); |
| | |
| | | return relation; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public SubCommand getSubCommand() { |
| | | return subCommand; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public MenuResult<Integer> run(ConsoleApplication app, LDAPManagementContextFactory factory) |
| | | throws ArgumentException, ClientException { |
| | |
| | | */ |
| | | final class DeleteSubCommandHandler extends SubCommandHandler { |
| | | |
| | | /** |
| | | * The value for the long option force. |
| | | */ |
| | | /** The value for the long option force. */ |
| | | private static final String OPTION_DSCFG_LONG_FORCE = "force"; |
| | | |
| | | /** |
| | | * The value for the short option force. |
| | | */ |
| | | /** The value for the short option force. */ |
| | | private static final char OPTION_DSCFG_SHORT_FORCE = 'f'; |
| | | |
| | | /** |
| | |
| | | /** The path of the managed object. */ |
| | | private final ManagedObjectPath<?, ?> path; |
| | | |
| | | /** |
| | | * The relation which references the managed object to be deleted. |
| | | */ |
| | | /** The relation which references the managed object to be deleted. */ |
| | | private final RelationDefinition<?, ?> relation; |
| | | |
| | | /** The sub-command associated with this handler. */ |
| | |
| | | return relation; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public SubCommand getSubCommand() { |
| | | return subCommand; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public MenuResult<Integer> run(ConsoleApplication app, LDAPManagementContextFactory factory) |
| | | throws ArgumentException, ClientException { |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS. |
| | | * Portions Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config.dsconfig; |
| | | |
| | |
| | | return path.getRelationDefinition(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public SubCommand getSubCommand() { |
| | | return subCommand; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public MenuResult<Integer> run(ConsoleApplication app, LDAPManagementContextFactory factory) |
| | | throws ArgumentException, ClientException { |
| | |
| | | DefaultBehaviorProviderVisitor<T, LocalizableMessage, Void> visitor |
| | | = new DefaultBehaviorProviderVisitor<T, LocalizableMessage, Void>() { |
| | | |
| | | @Override |
| | | public LocalizableMessage visitAbsoluteInherited(AbsoluteInheritedDefaultBehaviorProvider<T> d, |
| | | Void p) { |
| | | // Should not happen - inherited default values are |
| | |
| | | throw new IllegalStateException(); |
| | | } |
| | | |
| | | @Override |
| | | public LocalizableMessage visitAlias(AliasDefaultBehaviorProvider<T> d, Void p) { |
| | | if (app.isVerbose()) { |
| | | return d.getSynopsis(); |
| | |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public LocalizableMessage visitDefined(DefinedDefaultBehaviorProvider<T> d, Void p) { |
| | | // Should not happen - real default values are displayed as |
| | | // normal values. |
| | | throw new IllegalStateException(); |
| | | } |
| | | |
| | | @Override |
| | | public LocalizableMessage visitRelativeInherited(RelativeInheritedDefaultBehaviorProvider<T> d, |
| | | Void p) { |
| | | // Should not happen - inherited default values are |
| | |
| | | throw new IllegalStateException(); |
| | | } |
| | | |
| | | @Override |
| | | public LocalizableMessage visitUndefined(UndefinedDefaultBehaviorProvider<T> d, Void p) { |
| | | return null; |
| | | } |
| | |
| | | private static class DefaultVisitor<T> implements |
| | | DefaultBehaviorProviderVisitor<T, LocalizableMessage, PropertyDefinition<T>> { |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LocalizableMessage visitAbsoluteInherited(AbsoluteInheritedDefaultBehaviorProvider<T> d, |
| | | PropertyDefinition<T> p) { |
| | | return INFO_DSCFG_HELP_FIELD_INHERITED_ABS.get(d.getPropertyName(), d.getManagedObjectPath() |
| | | .getRelationDefinition().getUserFriendlyName()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LocalizableMessage visitAlias(AliasDefaultBehaviorProvider<T> d, PropertyDefinition<T> p) { |
| | | return d.getSynopsis(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LocalizableMessage visitDefined(DefinedDefaultBehaviorProvider<T> d, PropertyDefinition<T> p) { |
| | | LocalizableMessageBuilder builder = new LocalizableMessageBuilder(); |
| | | PropertyValuePrinter printer = new PropertyValuePrinter(null, null, false); |
| | |
| | | return builder.toMessage(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LocalizableMessage visitRelativeInherited(RelativeInheritedDefaultBehaviorProvider<T> d, |
| | | PropertyDefinition<T> p) { |
| | | if (d.getRelativeOffset() == 0) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LocalizableMessage visitUndefined(UndefinedDefaultBehaviorProvider<T> d, PropertyDefinition<T> p) { |
| | | return INFO_DSCFG_HELP_FIELD_UNDEFINED.get(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Create a new default behavior printer. |
| | | */ |
| | | /** Create a new default behavior printer. */ |
| | | public DefaultBehaviorPrinter() { |
| | | // No implementation required. |
| | | } |
| | |
| | | // No implementation required. |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <E extends Enum<E>> Void visitEnum(EnumPropertyDefinition<E> d, PrintStream p) { |
| | | displayUsage(p, INFO_DSCFG_HELP_FIELD_ENUM.get()); |
| | |
| | | return null; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Void visitString(StringPropertyDefinition d, PrintStream p) { |
| | | PropertyDefinitionUsageBuilder usageBuilder = new PropertyDefinitionUsageBuilder(false); |
| | |
| | | return null; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <T> Void visitUnknown(PropertyDefinition<T> d, PrintStream p) { |
| | | PropertyDefinitionUsageBuilder usageBuilder = new PropertyDefinitionUsageBuilder(true); |
| | |
| | | |
| | | /** Strings used in property help. */ |
| | | private static final String HEADING_SEPARATOR = " : "; |
| | | |
| | | /** Width of biggest heading (need to be careful of I18N). */ |
| | | private static final int HEADING_WIDTH; |
| | | |
| | | /** |
| | | * The value for the long option category. |
| | | */ |
| | | /** The value for the long option category. */ |
| | | private static final String OPTION_DSCFG_LONG_CATEGORY = "category"; |
| | | |
| | | /** |
| | | * The value for the long option inherited. |
| | | */ |
| | | /** The value for the long option inherited. */ |
| | | private static final String OPTION_DSCFG_LONG_INHERITED = "inherited"; |
| | | |
| | | /** |
| | | * The value for the long option type. |
| | | */ |
| | | /** The value for the long option type. */ |
| | | private static final String OPTION_DSCFG_LONG_TYPE = "type"; |
| | | |
| | | /** |
| | | * The value for the short option category. |
| | | */ |
| | | /** The value for the short option category. */ |
| | | private static final Character OPTION_DSCFG_SHORT_CATEGORY = 'c'; |
| | | |
| | | /** |
| | | * The value for the short option inherited. |
| | | */ |
| | | /** The value for the short option inherited. */ |
| | | private static final Character OPTION_DSCFG_SHORT_INHERITED = null; |
| | | |
| | | /** |
| | | * The value for the short option type. |
| | | */ |
| | | /** The value for the short option type. */ |
| | | private static final Character OPTION_DSCFG_SHORT_TYPE = 't'; |
| | | |
| | | static { |
| | |
| | | return b.toString(); |
| | | } |
| | | |
| | | /** |
| | | * The argument which should be used to specify the category of managed object to be retrieved. |
| | | */ |
| | | /** The argument which should be used to specify the category of managed object to be retrieved. */ |
| | | private final StringArgument categoryArgument; |
| | | |
| | | /** |
| | | * A table listing all the available types of managed object indexed on their parent type. |
| | | */ |
| | | /** A table listing all the available types of managed object indexed on their parent type. */ |
| | | private final Map<String, Map<String, AbstractManagedObjectDefinition<?, ?>>> categoryMap = new TreeMap<>(); |
| | | |
| | | /** The argument which should be used to display inherited properties. */ |
| | |
| | | /** The sub-command associated with this handler. */ |
| | | private final SubCommand subCommand; |
| | | |
| | | /** |
| | | * A table listing all the available types of managed object indexed on their tag(s). |
| | | */ |
| | | /** A table listing all the available types of managed object indexed on their tag(s). */ |
| | | private final Map<Tag, Map<String, AbstractManagedObjectDefinition<?, ?>>> tagMap = new HashMap<>(); |
| | | |
| | | /** |
| | | * The argument which should be used to specify the sub-type of managed object to be retrieved. |
| | | */ |
| | | /** The argument which should be used to specify the sub-type of managed object to be retrieved. */ |
| | | private final StringArgument typeArgument; |
| | | |
| | | /** Private constructor. */ |
| | |
| | | setCommandBuilderUseful(false); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public SubCommand getSubCommand() { |
| | | return subCommand; |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public MenuResult<Integer> run(ConsoleApplication app, LDAPManagementContextFactory factory) |
| | | throws ArgumentException, ClientException { |
| | |
| | | import com.forgerock.opendj.cli.ConsoleApplication; |
| | | import com.forgerock.opendj.cli.ReturnCode; |
| | | |
| | | /** |
| | | * An LDAP management context factory for the DSConfig tool. |
| | | */ |
| | | /** An LDAP management context factory for the DSConfig tool. */ |
| | | public final class LDAPManagementContextFactory { |
| | | |
| | | /** The management context. */ |
| | |
| | | factory = cfp.getAuthenticatedConnectionFactory(); |
| | | } |
| | | |
| | | /** |
| | | * Closes this management context. |
| | | */ |
| | | /** Closes this management context. */ |
| | | public void close() { |
| | | closeSilently(context); |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2015 ForgeRock AS. |
| | | * Portions Copyright 2012-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config.dsconfig; |
| | | |
| | |
| | | return relation; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public SubCommand getSubCommand() { |
| | | return subCommand; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public MenuResult<Integer> run(ConsoleApplication app, LDAPManagementContextFactory factory) |
| | | throws ArgumentException, ClientException { |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS. |
| | | * Portions Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config.dsconfig; |
| | | |
| | |
| | | * The type of the underlying property associated with the modification. |
| | | */ |
| | | final class PropertyEditorModification<T> { |
| | | /** |
| | | * The enumeration that describes the different types of modifications that we can have. |
| | | */ |
| | | /** The enumeration that describes the different types of modifications that we can have. */ |
| | | enum Type { |
| | | /** The user chose to set values. */ |
| | | SET, |
| | |
| | | return originalValues; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | return "Property name: " + getPropertyDefinition() + "\nMod type: " + getType() + "\nMod values: " |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS. |
| | | * Portions Copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config.dsconfig; |
| | | |
| | |
| | | |
| | | import static org.forgerock.opendj.config.dsconfig.DSConfig.*; |
| | | |
| | | /** |
| | | * Common methods used for interactively editing properties. |
| | | */ |
| | | /** Common methods used for interactively editing properties. */ |
| | | final class PropertyValueEditor { |
| | | |
| | | /** |
| | |
| | | /** The aggregation property definition. */ |
| | | private final AggregationPropertyDefinition<C, S> pd; |
| | | |
| | | /** |
| | | * Creates a new component create call-back for the provided aggregation property definition. |
| | | */ |
| | | /** Creates a new component create call-back for the provided aggregation property definition. */ |
| | | private CreateComponentCallback(AggregationPropertyDefinition<C, S> pd) { |
| | | this.pd = pd; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public MenuResult<String> invoke(ConsoleApplication app) throws ClientException { |
| | | try { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * A help call-back which displays a description and summary of a component and its properties. |
| | | */ |
| | | /** A help call-back which displays a description and summary of a component and its properties. */ |
| | | private static final class ComponentHelpCallback implements HelpCallback { |
| | | |
| | | /** The managed object being edited. */ |
| | |
| | | this.properties = c; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void display(ConsoleApplication app) { |
| | | app.println(); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * A simple interface for querying and retrieving common default behavior properties. |
| | | */ |
| | | /** A simple interface for querying and retrieving common default behavior properties. */ |
| | | private static final class DefaultBehaviorQuery<T> { |
| | | |
| | | /** |
| | | * The type of default behavior. |
| | | */ |
| | | /** The type of default behavior. */ |
| | | private enum Type { |
| | | /** |
| | | * Alias default behavior. |
| | | */ |
| | | /** Alias default behavior. */ |
| | | ALIAS, |
| | | |
| | | /** |
| | | * Defined default behavior. |
| | | */ |
| | | /** Defined default behavior. */ |
| | | DEFINED, |
| | | |
| | | /** |
| | | * Inherited default behavior. |
| | | */ |
| | | /** Inherited default behavior. */ |
| | | INHERITED, |
| | | |
| | | /** |
| | | * Undefined default behavior. |
| | | */ |
| | | /** Undefined default behavior. */ |
| | | UNDEFINED; |
| | | } |
| | | |
| | |
| | | DefaultBehaviorProviderVisitor<T, DefaultBehaviorQuery<T>, PropertyDefinition<T>> visitor |
| | | = new DefaultBehaviorProviderVisitor<T, DefaultBehaviorQuery<T>, PropertyDefinition<T>>() { |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public DefaultBehaviorQuery<T> visitAbsoluteInherited(AbsoluteInheritedDefaultBehaviorProvider<T> d, |
| | | PropertyDefinition<T> p) { |
| | |
| | | return new DefaultBehaviorQuery<>(Type.INHERITED, query.getAliasDescription()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public DefaultBehaviorQuery<T> visitAlias(AliasDefaultBehaviorProvider<T> d, |
| | | PropertyDefinition<T> p) { |
| | | return new DefaultBehaviorQuery<>(Type.ALIAS, d.getSynopsis()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public DefaultBehaviorQuery<T> visitDefined(DefinedDefaultBehaviorProvider<T> d, |
| | | PropertyDefinition<T> p) { |
| | | return new DefaultBehaviorQuery<>(Type.DEFINED, null); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public DefaultBehaviorQuery<T> visitRelativeInherited(RelativeInheritedDefaultBehaviorProvider<T> d, |
| | | PropertyDefinition<T> p) { |
| | |
| | | return new DefaultBehaviorQuery<>(Type.INHERITED, query.getAliasDescription()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public DefaultBehaviorQuery<T> visitUndefined(UndefinedDefaultBehaviorProvider<T> d, |
| | | PropertyDefinition<T> p) { |
| | |
| | | return pd.getDefaultBehaviorProvider().accept(visitor, pd); |
| | | } |
| | | |
| | | /** |
| | | * The description of the behavior if it is an alias default behavior. |
| | | */ |
| | | /** The description of the behavior if it is an alias default behavior. */ |
| | | private final LocalizableMessage aliasDescription; |
| | | |
| | | /** The type of behavior. */ |
| | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * A property definition visitor which initializes mandatory properties. |
| | | */ |
| | | /** A property definition visitor which initializes mandatory properties. */ |
| | | private final class MandatoryPropertyInitializer extends PropertyDefinitionVisitor<MenuResult<Void>, Void> |
| | | implements MenuCallback<Void> { |
| | | |
| | |
| | | this.pd = pd; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public MenuResult<Void> invoke(ConsoleApplication app) throws ClientException { |
| | | displayPropertyHeader(app, pd); |
| | |
| | | return result; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> MenuResult<Void> visitAggregation( |
| | | AggregationPropertyDefinition<C, S> d, Void p) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public MenuResult<Void> visitBoolean(BooleanPropertyDefinition d, Void p) { |
| | | MenuBuilder<Boolean> builder = new MenuBuilder<>(app); |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <E extends Enum<E>> MenuResult<Void> visitEnum(EnumPropertyDefinition<E> d, Void x) { |
| | | MenuBuilder<E> builder = new MenuBuilder<>(app); |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <T> MenuResult<Void> visitUnknown(PropertyDefinition<T> d, Void p) { |
| | | app.println(); |
| | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * A menu call-back for editing a modifiable multi-valued property. |
| | | */ |
| | | /** A menu call-back for editing a modifiable multi-valued property. */ |
| | | private final class MultiValuedPropertyEditor extends PropertyDefinitionVisitor<MenuResult<Boolean>, Void> |
| | | implements MenuCallback<Boolean> { |
| | | |
| | |
| | | this.pd = pd; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public MenuResult<Boolean> invoke(ConsoleApplication app) throws ClientException { |
| | | displayPropertyHeader(app, pd); |
| | |
| | | return result; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> MenuResult<Boolean> visitAggregation( |
| | | final AggregationPropertyDefinition<C, S> d, Void p) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <T extends Enum<T>> MenuResult<Boolean> visitEnum(final EnumPropertyDefinition<T> d, Void p) { |
| | | final SortedSet<T> defaultValues = mo.getPropertyDefaultValues(d); |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <T> MenuResult<Boolean> visitUnknown(final PropertyDefinition<T> d, Void p) { |
| | | app.println(); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * A help call-back which displays a description and summary of a single property. |
| | | */ |
| | | /** A help call-back which displays a description and summary of a single property. */ |
| | | private static final class PropertyHelpCallback implements HelpCallback { |
| | | |
| | | /** The managed object definition. */ |
| | |
| | | this.pd = pd; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void display(ConsoleApplication app) { |
| | | app.println(); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * A menu call-back for viewing a read-only properties. |
| | | */ |
| | | /** A menu call-back for viewing a read-only properties. */ |
| | | private final class ReadOnlyPropertyViewer extends PropertyDefinitionVisitor<MenuResult<Boolean>, Void> implements |
| | | MenuCallback<Boolean> { |
| | | |
| | |
| | | this.pd = pd; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public MenuResult<Boolean> invoke(ConsoleApplication app) throws ClientException { |
| | | MenuResult<Boolean> result = pd.accept(this, null); |
| | |
| | | return result; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <T> MenuResult<Boolean> visitUnknown(PropertyDefinition<T> pd, Void p) { |
| | | SortedSet<T> values = mo.getPropertyValues(pd); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * A menu call-back for editing a modifiable single-valued property. |
| | | */ |
| | | /** A menu call-back for editing a modifiable single-valued property. */ |
| | | private final class SingleValuedPropertyEditor extends PropertyDefinitionVisitor<MenuResult<Boolean>, Void> |
| | | implements MenuCallback<Boolean> { |
| | | |
| | |
| | | this.pd = pd; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public MenuResult<Boolean> invoke(ConsoleApplication app) throws ClientException { |
| | | displayPropertyHeader(app, pd); |
| | |
| | | return result; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> MenuResult<Boolean> visitAggregation( |
| | | AggregationPropertyDefinition<C, S> d, Void p) { |
| | |
| | | return runMenu(d, builder); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public MenuResult<Boolean> visitBoolean(BooleanPropertyDefinition d, Void p) { |
| | | // Construct a menu of actions. |
| | |
| | | return runMenu(d, builder); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <E extends Enum<E>> MenuResult<Boolean> visitEnum(EnumPropertyDefinition<E> d, Void p) { |
| | | // Construct a menu of actions. |
| | |
| | | return runMenu(d, builder); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <T> MenuResult<Boolean> visitUnknown(final PropertyDefinition<T> d, Void p) { |
| | | app.println(); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * The threshold above which choice menus should be displayed in multiple columns. |
| | | */ |
| | | /** The threshold above which choice menus should be displayed in multiple columns. */ |
| | | private static final int MULTI_COLUMN_THRESHOLD = 8; |
| | | |
| | | /** The application console. */ |
| | |
| | | return mods; |
| | | } |
| | | |
| | | /** |
| | | * Clears the list of modifications. |
| | | */ |
| | | /** Clears the list of modifications. */ |
| | | public void resetModifications() { |
| | | mods.clear(); |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS. |
| | | * Portions Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config.dsconfig; |
| | | |
| | |
| | | */ |
| | | final class PropertyValuePrinter { |
| | | |
| | | /** |
| | | * Perform property type specific print formatting. |
| | | */ |
| | | /** Perform property type specific print formatting. */ |
| | | private static final class MyPropertyValueVisitor extends PropertyValueVisitor<LocalizableMessage, Void> { |
| | | |
| | | /** |
| | | * The requested size unit (null if the property's unit should be used). |
| | | */ |
| | | /** The requested size unit (null if the property's unit should be used). */ |
| | | private final SizeUnit sizeUnit; |
| | | |
| | | /** |
| | | * The requested time unit (null if the property's unit should be used). |
| | | */ |
| | | /** The requested time unit (null if the property's unit should be used). */ |
| | | private final DurationUnit timeUnit; |
| | | |
| | | /** |
| | | * Whether or not values should be displayed in a script-friendly manner. |
| | | */ |
| | | /** Whether or not values should be displayed in a script-friendly manner. */ |
| | | private final boolean isScriptFriendly; |
| | | |
| | | /** The formatter to use for numeric values. */ |
| | | private final NumberFormat numberFormat; |
| | | |
| | |
| | | numberFormat.setMaximumFractionDigits(2); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LocalizableMessage visitBoolean(BooleanPropertyDefinition pd, Boolean v, Void p) { |
| | | return v ? INFO_VALUE_TRUE.get() : INFO_VALUE_FALSE.get(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LocalizableMessage visitDuration(DurationPropertyDefinition pd, Long v, Void p) { |
| | | if (pd.getUpperLimit() == null && (v < 0 || v == Long.MAX_VALUE)) { |
| | |
| | | return builder.toMessage(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public LocalizableMessage visitSize(SizePropertyDefinition pd, Long v, Void p) { |
| | | if (pd.isAllowUnlimited() && v < 0) { |
| | |
| | | return builder.toMessage(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <T> LocalizableMessage visitUnknown(PropertyDefinition<T> pd, T v, Void p) { |
| | | // For all other property definition types the default encoding |
| | |
| | | */ |
| | | final class SetPropSubCommandHandler extends SubCommandHandler { |
| | | |
| | | /** |
| | | * Type of modification being performed. |
| | | */ |
| | | /** Type of modification being performed. */ |
| | | private static enum ModificationType { |
| | | /** |
| | | * Append a single value to the property. |
| | | */ |
| | | /** Append a single value to the property. */ |
| | | ADD, |
| | | |
| | | /** |
| | | * Remove a single value from the property. |
| | | */ |
| | | /** Remove a single value from the property. */ |
| | | REMOVE, |
| | | |
| | | /** |
| | | * Append a single value to the property (first invocation removes existing values). |
| | | */ |
| | | /** Append a single value to the property (first invocation removes existing values). */ |
| | | SET; |
| | | } |
| | | |
| | | /** |
| | | * The value for the long option add. |
| | | */ |
| | | /** The value for the long option add. */ |
| | | private static final String OPTION_DSCFG_LONG_ADD = "add"; |
| | | |
| | | /** |
| | | * The value for the long option remove. |
| | | */ |
| | | /** The value for the long option remove. */ |
| | | private static final String OPTION_DSCFG_LONG_REMOVE = "remove"; |
| | | |
| | | /** |
| | | * The value for the long option reset. |
| | | */ |
| | | /** The value for the long option reset. */ |
| | | private static final String OPTION_DSCFG_LONG_RESET = "reset"; |
| | | |
| | | /** |
| | | * The value for the long option set. |
| | | */ |
| | | /** The value for the long option set. */ |
| | | private static final String OPTION_DSCFG_LONG_SET = "set"; |
| | | |
| | | /** |
| | | * The value for the short option add. |
| | | */ |
| | | /** The value for the short option add. */ |
| | | private static final Character OPTION_DSCFG_SHORT_ADD = null; |
| | | |
| | | /** |
| | | * The value for the short option remove. |
| | | */ |
| | | /** The value for the short option remove. */ |
| | | private static final Character OPTION_DSCFG_SHORT_REMOVE = null; |
| | | |
| | | /** |
| | | * The value for the short option reset. |
| | | */ |
| | | /** The value for the short option reset. */ |
| | | private static final Character OPTION_DSCFG_SHORT_RESET = null; |
| | | |
| | | /** |
| | | * The value for the short option set. |
| | | */ |
| | | /** The value for the short option set. */ |
| | | private static final Character OPTION_DSCFG_SHORT_SET = null; |
| | | |
| | | /** |
| | |
| | | || (!app.isAdvancedMode() && pd.hasOption(PropertyOption.ADVANCED)); |
| | | } |
| | | |
| | | /** |
| | | * Check that any referenced components are enabled if required. |
| | | */ |
| | | /** Check that any referenced components are enabled if required. */ |
| | | private static MenuResult<Void> checkReferences(ConsoleApplication app, ManagementContext context, |
| | | ManagedObject<?> mo, SubCommandHandler handler) throws ClientException { |
| | | ManagedObjectDefinition<?, ?> d = mo.getManagedObjectDefinition(); |
| | |
| | | /** The path of the managed object. */ |
| | | private final ManagedObjectPath<?, ?> path; |
| | | |
| | | /** |
| | | * The argument which should be used to specify zero or more property value adds. |
| | | */ |
| | | /** The argument which should be used to specify zero or more property value adds. */ |
| | | private final StringArgument propertyAddArgument; |
| | | |
| | | /** |
| | | * The argument which should be used to specify zero or more property value removes. |
| | | */ |
| | | /** The argument which should be used to specify zero or more property value removes. */ |
| | | private final StringArgument propertyRemoveArgument; |
| | | |
| | | /** |
| | | * The argument which should be used to specify zero or more property value resets. |
| | | */ |
| | | /** The argument which should be used to specify zero or more property value resets. */ |
| | | private final StringArgument propertyResetArgument; |
| | | |
| | | /** |
| | | * The argument which should be used to specify zero or more property value assignments. |
| | | */ |
| | | /** The argument which should be used to specify zero or more property value assignments. */ |
| | | private final StringArgument propertySetArgument; |
| | | |
| | | /** The sub-command associated with this handler. */ |
| | | private final SubCommand subCommand; |
| | | |
| | |
| | | return path.getRelationDefinition(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public SubCommand getSubCommand() { |
| | | return subCommand; |
| | |
| | | /** The current result. */ |
| | | private MenuResult<ManagedObject<?>> result; |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> void appendManagedObjectPathElement( |
| | | InstantiableRelationDefinition<? super C, ? super S> r, AbstractManagedObjectDefinition<C, S> d, |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> void appendManagedObjectPathElement( |
| | | OptionalRelationDefinition<? super C, ? super S> r, AbstractManagedObjectDefinition<C, S> d) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> void appendManagedObjectPathElement( |
| | | SetRelationDefinition<? super C, ? super S> r, AbstractManagedObjectDefinition<C, S> d) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> void appendManagedObjectPathElement( |
| | | SingletonRelationDefinition<? super C, ? super S> r, AbstractManagedObjectDefinition<C, S> d) { |
| | |
| | | this.isCreate = isCreate; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> void appendManagedObjectPathElement( |
| | | InstantiableRelationDefinition<? super C, ? super S> r, AbstractManagedObjectDefinition<C, S> d, |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> void appendManagedObjectPathElement( |
| | | OptionalRelationDefinition<? super C, ? super S> r, AbstractManagedObjectDefinition<C, S> d) { |
| | | sz--; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> void appendManagedObjectPathElement( |
| | | SetRelationDefinition<? super C, ? super S> r, AbstractManagedObjectDefinition<C, S> d) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> void appendManagedObjectPathElement( |
| | | SingletonRelationDefinition<? super C, ? super S> r, AbstractManagedObjectDefinition<C, S> d) { |
| | |
| | | // No implementation required. |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final int compareTo(SubCommandHandler o) { |
| | | String s1 = getSubCommand().getName(); |
| | |
| | | return s1.compareTo(s2); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final boolean equals(Object obj) { |
| | | if (this == obj) { |
| | |
| | | return tags; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public final int hashCode() { |
| | | return getSubCommand().getName().hashCode(); |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS. |
| | | * Portions Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config.dsconfig; |
| | | |
| | |
| | | */ |
| | | private final class Visitor implements RelationDefinitionVisitor<Void, ManagedObjectPath<?, ?>> { |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> Void visitInstantiable( |
| | | InstantiableRelationDefinition<C, S> rd, ManagedObjectPath<?, ?> p) { |
| | | try { |
| | |
| | | return null; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> Void visitOptional( |
| | | OptionalRelationDefinition<C, S> rd, ManagedObjectPath<?, ?> p) { |
| | | try { |
| | |
| | | return null; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> Void visitSet(SetRelationDefinition<C, S> rd, |
| | | ManagedObjectPath<?, ?> p) { |
| | | try { |
| | |
| | | return null; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> Void visitSingleton( |
| | | SingletonRelationDefinition<C, S> rd, ManagedObjectPath<?, ?> p) { |
| | | try { |
| | |
| | | * Header, with the fields enclosed by brackets [] replaced by your own identifying |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2014 ForgeRock AS. |
| | | * Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | |
| | | /** |
| | | * This package contains the DS config. |
| | | */ |
| | | /** This package contains the DS config. */ |
| | | package org.forgerock.opendj.config.dsconfig; |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config.server; |
| | | |
| | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | |
| | | /** |
| | | * Common features of config listener adaptors. |
| | | */ |
| | | /** Common features of config listener adaptors. */ |
| | | abstract class AbstractConfigListenerAdaptor { |
| | | |
| | | /** |
| | | * Create a new config listener adaptor. |
| | | */ |
| | | /** Create a new config listener adaptor. */ |
| | | protected AbstractConfigListenerAdaptor() { |
| | | // No implementation required. |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2007-2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2015 ForgeRock AS. |
| | | * Portions copyright 2015-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config.server; |
| | | |
| | |
| | | this.cachedManagedObject = null; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationAdd(Entry configEntry) { |
| | | if (optionalRelation != null) { |
| | | // Optional managed objects are located directly beneath the |
| | |
| | | return result; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean configAddIsAcceptable(Entry configEntry, LocalizableMessageBuilder unacceptableReason) { |
| | | DN dn = configEntry.getName(); |
| | | String name = dn.rdn().getFirstAVA().getAttributeValue().toString().trim(); |
| | |
| | | */ |
| | | private boolean adminActionRequired; |
| | | |
| | | /** |
| | | * The result code to return to the client from this configuration change. |
| | | */ |
| | | /** The result code to return to the client from this configuration change. */ |
| | | private ResultCode resultCode = ResultCode.SUCCESS; |
| | | |
| | | /** |
| | | * Creates a new config change result object with the provided information. |
| | | */ |
| | | /** Creates a new config change result object with the provided information. */ |
| | | public ConfigChangeResult() { |
| | | // nothing more to do |
| | | } |
| | |
| | | this.cachedManagedObject = null; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationDelete(Entry configEntry) { |
| | | if (optionalRelation != null) { |
| | |
| | | return result; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean configDeleteIsAcceptable(Entry configEntry, LocalizableMessageBuilder unacceptableReason) { |
| | | DN dn = configEntry.getName(); |
| | | String name = dn.rdn().getFirstAVA().getAttributeValue().toString().trim(); |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config.server; |
| | | |
| | | import org.forgerock.i18n.LocalizableException; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | /** |
| | | * Thrown during the course of interactions with the Directory Server |
| | | * configuration. |
| | | */ |
| | | /** Thrown during the course of interactions with the Directory Server configuration. */ |
| | | public final class ConfigException extends Exception implements LocalizableException { |
| | | private static final long serialVersionUID = -540463620272921157L; |
| | | private final LocalizableMessage message; |
| | |
| | | * |
| | | * @return LocalizableMessage of the problem |
| | | */ |
| | | @Override |
| | | public LocalizableMessage getMessageObject() { |
| | | return message; |
| | | } |
| | |
| | | import org.forgerock.opendj.config.DefinitionDecodingException; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | |
| | | /** |
| | | * A utility class for converting admin exceptions to config exceptions. |
| | | */ |
| | | /** A utility class for converting admin exceptions to config exceptions. */ |
| | | final class ConfigExceptionFactory { |
| | | |
| | | /** The singleton instance. */ |
| | |
| | | */ |
| | | public class ConstraintViolationException extends DecodingException { |
| | | |
| | | /** |
| | | * Serialization ID. |
| | | */ |
| | | /** Serialization ID. */ |
| | | private static final long serialVersionUID = -4902443848460011875L; |
| | | |
| | | /** The server managed object. */ |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.config.server; |
| | |
| | | import org.forgerock.opendj.config.RelationDefinition; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | |
| | | /** |
| | | * A factory class for creating <code>DN</code>s from managed object paths. |
| | | */ |
| | | /** A factory class for creating <code>DN</code>s from managed object paths. */ |
| | | final class DNBuilder { |
| | | |
| | | /** |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions copyright 2015 ForgeRock AS. |
| | | * Portions copyright 2015-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config.server; |
| | | |
| | |
| | | this.delayedDeleteListener = deleteListener; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationAdd(Entry configEntry) { |
| | | if (configEntry.getName().equals(child)) { |
| | |
| | | return new ConfigChangeResult(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean configAddIsAcceptable(Entry configEntry, LocalizableMessageBuilder unacceptableReason) { |
| | | // Always acceptable. |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config.server; |
| | | |
| | |
| | | */ |
| | | public abstract class ServerConstraintHandler { |
| | | |
| | | /** |
| | | * Creates a new server constraint handler. |
| | | */ |
| | | /** Creates a new server constraint handler. */ |
| | | protected ServerConstraintHandler() { |
| | | // No implementation required. |
| | | } |
| | |
| | | registerDeleteListener(baseDN, adaptor); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | StringBuilder builder = new StringBuilder(); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Register a delayed listener with the nearest existing parent |
| | | * entry to the provided base DN. |
| | | */ |
| | | /** Register a delayed listener with the nearest existing parent entry to the provided base DN. */ |
| | | private void registerDelayedListener(DN baseDN, ConfigAddListener delayedListener) throws ConfigException { |
| | | DN currentDN = baseDN.parent(); |
| | | DN previousDN = currentDN; |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config.server; |
| | | |
| | |
| | | this.listener = listener; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationAdd(ServerManagedObject<? extends T> mo) { |
| | | return listener.applyConfigurationAdd(mo.getConfiguration()); |
| | | } |
| | |
| | | return listener; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isConfigurationAddAcceptable(ServerManagedObject<? extends T> mo, |
| | | List<LocalizableMessage> unacceptableReasons) { |
| | | return listener.isConfigurationAddAcceptable(mo.getConfiguration(), unacceptableReasons); |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config.server; |
| | | |
| | |
| | | this.listener = listener; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationChange(ServerManagedObject<? extends T> mo) { |
| | | return listener.applyConfigurationChange(mo.getConfiguration()); |
| | |
| | | return listener; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isConfigurationChangeAcceptable(ServerManagedObject<? extends T> mo, |
| | | List<LocalizableMessage> unacceptableReasons) { |
| | |
| | | */ |
| | | public class ServerManagedObjectDecodingException extends DecodingException { |
| | | |
| | | /** |
| | | * Version ID required by serializable classes. |
| | | */ |
| | | /** Version ID required by serializable classes. */ |
| | | private static final long serialVersionUID = 1598401431084729853L; |
| | | |
| | | /** Create the message. */ |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config.server; |
| | | |
| | |
| | | this.listener = listener; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationDelete(ServerManagedObject<? extends T> mo) { |
| | | return listener.applyConfigurationDelete(mo.getConfiguration()); |
| | | } |
| | |
| | | return listener; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isConfigurationDeleteAcceptable(ServerManagedObject<? extends T> mo, |
| | | List<LocalizableMessage> unacceptableReasons) { |
| | | return listener.isConfigurationDeleteAcceptable(mo.getConfiguration(), unacceptableReasons); |
| | |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | |
| | | /** |
| | | * Server management connection context. |
| | | */ |
| | | /** Server management connection context. */ |
| | | public final class ServerManagementContext { |
| | | |
| | | /** |
| | |
| | | /** Any exception that occurred whilst retrieving inherited default values. */ |
| | | private PropertyException exception; |
| | | |
| | | /** |
| | | * Optional new configuration entry which does not yet exist in |
| | | * the configuration back-end. |
| | | */ |
| | | /** Optional new configuration entry which does not yet exist in the configuration back-end. */ |
| | | private final Entry newConfigEntry; |
| | | |
| | | /** The path of the managed object containing the next property. */ |
| | |
| | | this.newConfigEntry = newConfigEntry; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Collection<T> visitAbsoluteInherited(AbsoluteInheritedDefaultBehaviorProvider<T> d, Void p) { |
| | | try { |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@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(); |
| | |
| | | return values; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Collection<T> visitRelativeInherited(RelativeInheritedDefaultBehaviorProvider<T> d, Void p) { |
| | | try { |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Collection<T> visitUndefined(UndefinedDefaultBehaviorProvider<T> d, Void p) { |
| | | return Collections.emptySet(); |
| | |
| | | this.entry = entry; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean matches(AbstractManagedObjectDefinition<?, ?> d) { |
| | | String oc = LDAPProfile.getInstance().getObjectClass(d); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * A visitor which is used to decode property LDAP values. |
| | | */ |
| | | /** A visitor which is used to decode property LDAP values. */ |
| | | private static final class ValueDecoder extends PropertyDefinitionVisitor<Object, String> { |
| | | |
| | | /** |
| | |
| | | // Do nothing. |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <C extends ConfigurationClient, S extends Configuration> Object visitAggregation( |
| | | AggregationPropertyDefinition<C, S> d, String p) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <T> Object visitUnknown(PropertyDefinition<T> d, String p) { |
| | | // By default the property definition's decoder will do. |
| | |
| | | |
| | | private static final Logger debugLogger = LoggerFactory.getLogger(ServerManagementContext.class); |
| | | |
| | | /** |
| | | * The root server managed object, lazily initialized. |
| | | */ |
| | | /** The root server managed object, lazily initialized. */ |
| | | private volatile ServerManagedObject<RootCfg> root; |
| | | |
| | | /** Repository of configuration entries. */ |
| | |
| | | return configRepository; |
| | | } |
| | | |
| | | /** |
| | | * Gets a config entry required for a managed object and throws a |
| | | * config exception on failure. |
| | | */ |
| | | /** Gets a config entry required for a managed object and throws a config exception on failure. */ |
| | | private Entry getManagedObjectConfigEntry(DN dn) throws ConfigException { |
| | | Entry configEntry; |
| | | try { |
| | |
| | | * Header, with the fields enclosed by brackets [] replaced by your own identifying |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2013 ForgeRock AS. |
| | | * Copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config.server.spi; |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.Entry; |
| | | |
| | | /** |
| | | * Provides configuration entries and listener registration on the entries. |
| | | */ |
| | | /** Provides configuration entries and listener registration on the entries. */ |
| | | public interface ConfigurationRepository { |
| | | |
| | | /** |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config; |
| | | |
| | |
| | | import org.forgerock.opendj.server.config.server.RootCfg; |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | | * An abstract class that all admin unit tests should extend. |
| | | */ |
| | | /** An abstract class that all admin unit tests should extend. */ |
| | | @SuppressWarnings("javadoc") |
| | | @Test(groups = { "precommit", "admin" }, singleThreaded = true) |
| | | public abstract class AdminTestCase extends ConfigTestCase { |
| | | |
| | | /** |
| | | * Create a mock of ConfigurationRepository with provided entries registered. |
| | | */ |
| | | /** Create a mock of ConfigurationRepository with provided entries registered. */ |
| | | protected final ConfigurationRepository createConfigRepositoryWithEntries(final Entry...entries) throws Exception { |
| | | ConfigurationRepository configRepository = mock(ConfigurationRepository.class); |
| | | for (Entry entry : entries) { |
| | |
| | | * Header, with the fields enclosed by brackets [] replaced by your own identifying |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2013 ForgeRock AS. |
| | | * Copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config; |
| | | |
| | | import org.forgerock.testng.ForgeRockTestCase; |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | | * An abstract class that all unit tests should extend. |
| | | */ |
| | | /** An abstract class that all unit tests should extend. */ |
| | | @Test(groups = { "precommit", "config" }) |
| | | public abstract class ConfigTestCase extends ForgeRockTestCase { |
| | | // no implementation |
| | |
| | | * Header, with the fields enclosed by brackets [] replaced by your own identifying |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2013-2015 ForgeRock AS. |
| | | * Copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config; |
| | | |
| | |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Object answer(InvocationOnMock invocation) { |
| | | try { |
| | |
| | | return definitionClass.getMethod(invokedMethodName.replaceAll("^is", "get") + "PropertyDefinition"); |
| | | } |
| | | |
| | | /** |
| | | * Returns the type of values returned by the property. |
| | | */ |
| | | /** Returns the type of values returned by the property. */ |
| | | private Class<?> getPropertyReturnType(Method getPropertyDefMethod) { |
| | | Class<?> returnClass = getPropertyDefMethod.getReturnType(); |
| | | return ((ParameterizedType) returnClass.getGenericSuperclass()) |
| | |
| | | this.propertyDef = propertyDef; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Collection<T> visitAbsoluteInherited(AbsoluteInheritedDefaultBehaviorProvider<T> provider, Void p) { |
| | | // not handled |
| | | return null; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Collection<T> visitAlias(AliasDefaultBehaviorProvider<T> provider, Void p) { |
| | | // not handled |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * Returns the default value for the property as a collection. |
| | | */ |
| | | /** Returns the default value for the property as a collection. */ |
| | | @Override |
| | | public Collection<T> visitDefined(DefinedDefaultBehaviorProvider<T> provider, Void p) { |
| | | SortedSet<T> values = new TreeSet<>(); |
| | |
| | | return values; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Collection<T> visitRelativeInherited(RelativeInheritedDefaultBehaviorProvider<T> d, Void p) { |
| | | // not handled |
| | | return null; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Collection<T> visitUndefined(UndefinedDefaultBehaviorProvider<T> d, Void p) { |
| | | // not handled |
| | |
| | | * Header, with the fields enclosed by brackets [] replaced by your own identifying |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2013 ForgeRock AS. |
| | | * Copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config; |
| | | |
| | |
| | | import org.forgerock.opendj.server.config.server.LDAPConnectionHandlerCfg; |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | | * Test case to ensure that ConfigurationMock class is correct. |
| | | */ |
| | | /** Test case to ensure that ConfigurationMock class is correct. */ |
| | | @SuppressWarnings("javadoc") |
| | | public class ConfigurationMockTest extends ConfigTestCase { |
| | | |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.config; |
| | |
| | | builder.setAllowUnlimited(true); |
| | | DurationPropertyDefinition def = buildTestDefinition(builder); |
| | | PropertyDefinitionVisitor<Boolean, Void> v = new PropertyDefinitionVisitor<Boolean, Void>() { |
| | | @Override |
| | | public Boolean visitDuration(DurationPropertyDefinition d, Void o) { |
| | | return true; |
| | | } |
| | |
| | | DurationPropertyDefinition.Builder builder = createTestBuilder(); |
| | | builder.setAllowUnlimited(true); |
| | | builder.setDefaultBehaviorProvider(new DefaultBehaviorProvider<Long>() { |
| | | @Override |
| | | public <R, P> R accept(DefaultBehaviorProviderVisitor<Long, R, P> v, P p) { |
| | | return null; |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.config; |
| | |
| | | assertNotNull(builder); |
| | | } |
| | | |
| | | /** |
| | | * Tests that exception thrown when no enum class specified by builder. |
| | | */ |
| | | /** Tests that exception thrown when no enum class specified by builder. */ |
| | | @Test |
| | | public void testBuildInstance() { |
| | | EnumPropertyDefinition<?> def = builder.getInstance(); |
| | | assertEquals(def.getEnumClass(), TestEnum.class); |
| | | } |
| | | |
| | | /** |
| | | * Tests that exception thrown when no enum class specified by builder. |
| | | */ |
| | | /** Tests that exception thrown when no enum class specified by builder. */ |
| | | @Test(expectedExceptions = { IllegalStateException.class }) |
| | | public void testBuildInstanceWithoutEnumClassSpecified() { |
| | | EnumPropertyDefinition.Builder<TestEnum> localBuilder = EnumPropertyDefinition.createBuilder( |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config; |
| | | |
| | |
| | | builder.setAllowUnlimited(true); |
| | | IntegerPropertyDefinition propertyDef = buildTestDefinition(builder); |
| | | PropertyDefinitionVisitor<Boolean, Void> v = new PropertyDefinitionVisitor<Boolean, Void>() { |
| | | @Override |
| | | public Boolean visitInteger(IntegerPropertyDefinition d, Void o) { |
| | | return true; |
| | | } |
| | |
| | | IntegerPropertyDefinition.Builder builder = createTestBuilder(); |
| | | builder.setAllowUnlimited(true); |
| | | builder.setDefaultBehaviorProvider(new DefaultBehaviorProvider<Integer>() { |
| | | @Override |
| | | public <R, P> R accept(DefaultBehaviorProviderVisitor<Integer, R, P> v, P p) { |
| | | return null; |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config; |
| | | |
| | | |
| | | /** |
| | | * A mock LDAP profile wrapper for testing purposes. |
| | | */ |
| | | /** A mock LDAP profile wrapper for testing purposes. */ |
| | | public final class MockLDAPProfile extends LDAPProfile.Wrapper { |
| | | |
| | | /** |
| | | * Creates a new mock LDAP profile. |
| | | */ |
| | | /** Creates a new mock LDAP profile. */ |
| | | public MockLDAPProfile() { |
| | | // No implementation required. |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getAttributeName(AbstractManagedObjectDefinition<?, ?> d, PropertyDefinition<?> pd) { |
| | | |
| | |
| | | return null; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getRelationChildRDNType(InstantiableRelationDefinition<?, ?> r) { |
| | | if (r == TestCfg.getTestOneToManyParentRelationDefinition() |
| | |
| | | return null; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getObjectClass(AbstractManagedObjectDefinition<?, ?> d) { |
| | | if (d == TestParentCfgDefn.getInstance()) { |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getRelationRDNSequence(RelationDefinition<?, ?> r) { |
| | | if (r == TestCfg.getTestOneToManyParentRelationDefinition()) { |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | * Portions Copyright 2015-2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.forgerock.opendj.config; |
| | |
| | | public void testAccept() { |
| | | defaultBehaviorProvider.accept(new DefaultBehaviorProviderVisitor<Boolean, Object, Object>() { |
| | | |
| | | @Override |
| | | public Object visitAbsoluteInherited(AbsoluteInheritedDefaultBehaviorProvider d, Object o) { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public Object visitAlias(AliasDefaultBehaviorProvider d, Object o) { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public Object visitDefined(DefinedDefaultBehaviorProvider d, Object o) { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public Object visitRelativeInherited(RelativeInheritedDefaultBehaviorProvider d, Object o) { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public Object visitUndefined(UndefinedDefaultBehaviorProvider d, Object o) { |
| | | return null; |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config; |
| | | |
| | |
| | | builder.setAllowUnlimited(true); |
| | | SizePropertyDefinition propertyDef = buildTestDefinition(builder); |
| | | PropertyDefinitionVisitor<Boolean, Void> v = new PropertyDefinitionVisitor<Boolean, Void>() { |
| | | @Override |
| | | public Boolean visitSize(SizePropertyDefinition d, Void o) { |
| | | return true; |
| | | } |
| | |
| | | SizePropertyDefinition.Builder builder = createTestBuilder(); |
| | | builder.setAllowUnlimited(true); |
| | | builder.setDefaultBehaviorProvider(new DefaultBehaviorProvider<Long>() { |
| | | @Override |
| | | public <R, P> R accept(DefaultBehaviorProviderVisitor<Long, R, P> v, P p) { |
| | | return null; |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | * Portions Copyright 2015-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config; |
| | | |
| | |
| | | |
| | | import org.forgerock.opendj.server.config.meta.RootCfgDefn; |
| | | |
| | | /** |
| | | * Common methods for hooking in the test components. |
| | | */ |
| | | /** Common methods for hooking in the test components. */ |
| | | public final class TestCfg { |
| | | |
| | | /** |
| | | * A one-to-many relation between the root and test-parent components. |
| | | */ |
| | | /** A one-to-many relation between the root and test-parent components. */ |
| | | private static final InstantiableRelationDefinition<TestParentCfgClient, TestParentCfg> RD_TEST_ONE_TO_MANY_PARENT; |
| | | |
| | | /** |
| | | * A one-to-zero-or-one relation between the root and a test-parent |
| | | * component. |
| | | */ |
| | | /** 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; |
| | |
| | | ManagedObjectDefinitionI18NResource.getInstance().setResourceBundle(definition, resourceBundle); |
| | | } |
| | | |
| | | /** |
| | | * Deregisters the test configurations from the administration framework. |
| | | */ |
| | | /** Deregisters the test configurations from the administration framework. */ |
| | | public static synchronized void cleanup() { |
| | | LDAPProfile.getInstance().popWrapper(); |
| | | |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2007-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config; |
| | | |
| | |
| | | * |
| | | * @return Returns the configuration class associated with this Test Child. |
| | | */ |
| | | @Override |
| | | Class<? extends TestChildCfg> configurationClass(); |
| | | |
| | | /** |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config; |
| | | |
| | |
| | | * @return Returns the configuration definition associated with this Test |
| | | * Child. |
| | | */ |
| | | @Override |
| | | ManagedObjectDefinition<? extends TestChildCfgClient, ? extends TestChildCfg> definition(); |
| | | |
| | | /** |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2007-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS. |
| | | * Portions Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config; |
| | | |
| | |
| | | INSTANCE.registerPropertyDefinition(PROPDEF_MANDATORY_CLASS_PROPERTY); |
| | | } |
| | | |
| | | /** |
| | | * Build the "mandatory-read-only-attribute-type-property" property |
| | | * definition. |
| | | */ |
| | | /** Build the "mandatory-read-only-attribute-type-property" property definition. */ |
| | | static { |
| | | AttributeTypePropertyDefinition.Builder builder = AttributeTypePropertyDefinition.createBuilder(INSTANCE, |
| | | "mandatory-read-only-attribute-type-property"); |
| | |
| | | return INSTANCE; |
| | | } |
| | | |
| | | /** |
| | | * Private constructor. |
| | | */ |
| | | /** Private constructor. */ |
| | | private TestChildCfgDefn() { |
| | | super("test-child", null); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public TestChildCfgClient createClientConfiguration(ManagedObject<? extends TestChildCfgClient> impl) { |
| | | return new TestChildCfgClientImpl(impl); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public TestChildCfg createServerConfiguration(ServerManagedObject<? extends TestChildCfg> impl) { |
| | | return new TestChildCfgServerImpl(impl); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Class<TestChildCfg> getServerConfigurationClass() { |
| | | return TestChildCfg.class; |
| | | } |
| | |
| | | return PROPDEF_OPTIONAL_MULTI_VALUED_DN_PROPERTY2; |
| | | } |
| | | |
| | | /** |
| | | * Managed object client implementation. |
| | | */ |
| | | /** Managed object client implementation. */ |
| | | private static class TestChildCfgClientImpl implements TestChildCfgClient { |
| | | |
| | | /** Private implementation. */ |
| | |
| | | this.impl = impl; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public SortedSet<String> getAggregationProperty() { |
| | | return impl.getPropertyValues(INSTANCE.getAggregationPropertyPropertyDefinition()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void setAggregationProperty(Collection<String> values) { |
| | | impl.setPropertyValues(INSTANCE.getAggregationPropertyPropertyDefinition(), values); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Boolean isMandatoryBooleanProperty() { |
| | | return impl.getPropertyValue(INSTANCE.getMandatoryBooleanPropertyPropertyDefinition()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void setMandatoryBooleanProperty(boolean value) { |
| | | impl.setPropertyValue(INSTANCE.getMandatoryBooleanPropertyPropertyDefinition(), value); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getMandatoryClassProperty() { |
| | | return impl.getPropertyValue(INSTANCE.getMandatoryClassPropertyPropertyDefinition()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void setMandatoryClassProperty(String value) { |
| | | impl.setPropertyValue(INSTANCE.getMandatoryClassPropertyPropertyDefinition(), value); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public AttributeType getMandatoryReadOnlyAttributeTypeProperty() { |
| | | return impl.getPropertyValue(INSTANCE.getMandatoryReadOnlyAttributeTypePropertyPropertyDefinition()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void setMandatoryReadOnlyAttributeTypeProperty(AttributeType value) throws PropertyException { |
| | | impl.setPropertyValue(INSTANCE.getMandatoryReadOnlyAttributeTypePropertyPropertyDefinition(), value); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public SortedSet<DN> getOptionalMultiValuedDNProperty1() { |
| | | return impl.getPropertyValues(INSTANCE.getOptionalMultiValuedDNProperty1PropertyDefinition()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void setOptionalMultiValuedDNProperty1(Collection<DN> values) { |
| | | impl.setPropertyValues(INSTANCE.getOptionalMultiValuedDNProperty1PropertyDefinition(), values); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public SortedSet<DN> getOptionalMultiValuedDNProperty2() { |
| | | return impl.getPropertyValues(INSTANCE.getOptionalMultiValuedDNProperty2PropertyDefinition()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void setOptionalMultiValuedDNProperty2(Collection<DN> values) { |
| | | impl.setPropertyValues(INSTANCE.getOptionalMultiValuedDNProperty2PropertyDefinition(), values); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ManagedObjectDefinition<? extends TestChildCfgClient, ? extends TestChildCfg> definition() { |
| | | return INSTANCE; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public PropertyProvider properties() { |
| | | return impl; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void commit() throws ManagedObjectAlreadyExistsException, MissingMandatoryPropertiesException, |
| | | ConcurrentModificationException, OperationRejectedException, LdapException { |
| | | impl.commit(); |
| | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * Managed object server implementation. |
| | | */ |
| | | /** Managed object server implementation. */ |
| | | private static class TestChildCfgServerImpl implements TestChildCfg { |
| | | |
| | | /** Private implementation. */ |
| | |
| | | this.impl = impl; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void addChangeListener(ConfigurationChangeListener<TestChildCfg> listener) { |
| | | impl.registerChangeListener(listener); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void removeChangeListener(ConfigurationChangeListener<TestChildCfg> listener) { |
| | | impl.deregisterChangeListener(listener); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public SortedSet<String> getAggregationProperty() { |
| | | return impl.getPropertyValues(INSTANCE.getAggregationPropertyPropertyDefinition()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isMandatoryBooleanProperty() { |
| | | return impl.getPropertyValue(INSTANCE.getMandatoryBooleanPropertyPropertyDefinition()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getMandatoryClassProperty() { |
| | | return impl.getPropertyValue(INSTANCE.getMandatoryClassPropertyPropertyDefinition()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public AttributeType getMandatoryReadOnlyAttributeTypeProperty() { |
| | | return impl.getPropertyValue(INSTANCE.getMandatoryReadOnlyAttributeTypePropertyPropertyDefinition()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public SortedSet<DN> getOptionalMultiValuedDNProperty1() { |
| | | return impl.getPropertyValues(INSTANCE.getOptionalMultiValuedDNProperty1PropertyDefinition()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public SortedSet<DN> getOptionalMultiValuedDNProperty2() { |
| | | return impl.getPropertyValues(INSTANCE.getOptionalMultiValuedDNProperty2PropertyDefinition()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Class<? extends TestChildCfg> configurationClass() { |
| | | return TestChildCfg.class; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public DN dn() { |
| | | return impl.getDN(); |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2007-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config; |
| | | |
| | |
| | | * |
| | | * @return Returns the configuration class associated with this Test Parent. |
| | | */ |
| | | @Override |
| | | Class<? extends TestParentCfg> configurationClass(); |
| | | |
| | | /** |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS. |
| | | * Portions Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config; |
| | | |
| | |
| | | * @return Returns the configuration definition associated with this Test |
| | | * Parent. |
| | | */ |
| | | @Override |
| | | ManagedObjectDefinition<? extends TestParentCfgClient, ? extends TestParentCfg> definition(); |
| | | |
| | | /** |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2007-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS. |
| | | * Portions Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config; |
| | | |
| | |
| | | INSTANCE.registerPropertyDefinition(PD_MANDATORY_CLASS_PROPERTY); |
| | | } |
| | | |
| | | /** |
| | | * Build the "mandatory-read-only-attribute-type-property" property |
| | | * definition. |
| | | */ |
| | | /** Build the "mandatory-read-only-attribute-type-property" property definition. */ |
| | | static { |
| | | AttributeTypePropertyDefinition.Builder builder = AttributeTypePropertyDefinition.createBuilder(INSTANCE, |
| | | "mandatory-read-only-attribute-type-property"); |
| | |
| | | return INSTANCE; |
| | | } |
| | | |
| | | /** |
| | | * Private constructor. |
| | | */ |
| | | /** Private constructor. */ |
| | | private TestParentCfgDefn() { |
| | | super("test-parent", null); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public TestParentCfgClient createClientConfiguration(ManagedObject<? extends TestParentCfgClient> impl) { |
| | | return new TestParentCfgClientImpl(impl); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public TestParentCfg createServerConfiguration(ServerManagedObject<? extends TestParentCfg> impl) { |
| | | return new TestParentCfgServerImpl(impl); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Class<TestParentCfg> getServerConfigurationClass() { |
| | | return TestParentCfg.class; |
| | | } |
| | |
| | | return RD_OPTIONAL_TEST_CHILD; |
| | | } |
| | | |
| | | /** |
| | | * Managed object client implementation. |
| | | */ |
| | | /** Managed object client implementation. */ |
| | | private static class TestParentCfgClientImpl implements TestParentCfgClient { |
| | | |
| | | /** Private implementation. */ |
| | |
| | | this.impl = impl; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Boolean isMandatoryBooleanProperty() { |
| | | return impl.getPropertyValue(INSTANCE.getMandatoryBooleanPropertyPropertyDefinition()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void setMandatoryBooleanProperty(boolean value) { |
| | | impl.setPropertyValue(INSTANCE.getMandatoryBooleanPropertyPropertyDefinition(), value); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getMandatoryClassProperty() { |
| | | return impl.getPropertyValue(INSTANCE.getMandatoryClassPropertyPropertyDefinition()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void setMandatoryClassProperty(String value) { |
| | | impl.setPropertyValue(INSTANCE.getMandatoryClassPropertyPropertyDefinition(), value); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public AttributeType getMandatoryReadOnlyAttributeTypeProperty() { |
| | | return impl.getPropertyValue(INSTANCE.getMandatoryReadOnlyAttributeTypePropertyPropertyDefinition()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void setMandatoryReadOnlyAttributeTypeProperty(AttributeType value) throws PropertyException { |
| | | impl.setPropertyValue(INSTANCE.getMandatoryReadOnlyAttributeTypePropertyPropertyDefinition(), value); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public SortedSet<DN> getOptionalMultiValuedDNProperty() { |
| | | return impl.getPropertyValues(INSTANCE.getOptionalMultiValuedDNPropertyPropertyDefinition()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void setOptionalMultiValuedDNProperty(Collection<DN> values) { |
| | | impl.setPropertyValues(INSTANCE.getOptionalMultiValuedDNPropertyPropertyDefinition(), values); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String[] listTestChildren() throws ConcurrentModificationException, LdapException { |
| | | return impl.listChildren(INSTANCE.getTestChildrenRelationDefinition()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public TestChildCfgClient getTestChild(String name) throws DefinitionDecodingException, |
| | | ManagedObjectDecodingException, ManagedObjectNotFoundException, ConcurrentModificationException, |
| | | LdapException { |
| | | return impl.getChild(INSTANCE.getTestChildrenRelationDefinition(), name).getConfiguration(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <M extends TestChildCfgClient> M createTestChild(ManagedObjectDefinition<M, ? extends TestChildCfg> d, |
| | | String name, Collection<PropertyException> exceptions) throws IllegalManagedObjectNameException { |
| | | return impl.createChild(INSTANCE.getTestChildrenRelationDefinition(), d, name, exceptions) |
| | | .getConfiguration(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void removeTestChild(String name) throws ManagedObjectNotFoundException, |
| | | ConcurrentModificationException, OperationRejectedException, LdapException { |
| | | impl.removeChild(INSTANCE.getTestChildrenRelationDefinition(), name); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean hasOptionalTestChild() throws ConcurrentModificationException, LdapException { |
| | | return impl.hasChild(INSTANCE.getOptionalTestChildRelationDefinition()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public TestChildCfgClient getOptionalChild() throws DefinitionDecodingException, |
| | | ManagedObjectDecodingException, ManagedObjectNotFoundException, ConcurrentModificationException, |
| | | LdapException { |
| | | return impl.getChild(INSTANCE.getOptionalTestChildRelationDefinition()).getConfiguration(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public <M extends TestChildCfgClient> M createOptionalTestChild( |
| | | ManagedObjectDefinition<M, ? extends TestChildCfg> d, Collection<PropertyException> exceptions) { |
| | | return impl.createChild(INSTANCE.getOptionalTestChildRelationDefinition(), d, exceptions) |
| | | .getConfiguration(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void removeOptionalTestChild() throws ManagedObjectNotFoundException, ConcurrentModificationException, |
| | | OperationRejectedException, LdapException { |
| | | impl.removeChild(INSTANCE.getOptionalTestChildRelationDefinition()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ManagedObjectDefinition<? extends TestParentCfgClient, ? extends TestParentCfg> definition() { |
| | | return INSTANCE; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public PropertyProvider properties() { |
| | | return impl; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void commit() throws ManagedObjectAlreadyExistsException, MissingMandatoryPropertiesException, |
| | | ConcurrentModificationException, OperationRejectedException, LdapException { |
| | | impl.commit(); |
| | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * Managed object server implementation. |
| | | */ |
| | | /** Managed object server implementation. */ |
| | | private static class TestParentCfgServerImpl implements TestParentCfg { |
| | | |
| | | /** Private implementation. */ |
| | |
| | | this.impl = impl; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void addChangeListener(ConfigurationChangeListener<TestParentCfg> listener) { |
| | | impl.registerChangeListener(listener); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void removeChangeListener(ConfigurationChangeListener<TestParentCfg> listener) { |
| | | impl.deregisterChangeListener(listener); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isMandatoryBooleanProperty() { |
| | | return impl.getPropertyValue(INSTANCE.getMandatoryBooleanPropertyPropertyDefinition()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getMandatoryClassProperty() { |
| | | return impl.getPropertyValue(INSTANCE.getMandatoryClassPropertyPropertyDefinition()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public AttributeType getMandatoryReadOnlyAttributeTypeProperty() { |
| | | return impl.getPropertyValue(INSTANCE.getMandatoryReadOnlyAttributeTypePropertyPropertyDefinition()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public SortedSet<DN> getOptionalMultiValuedDNProperty() { |
| | | return impl.getPropertyValues(INSTANCE.getOptionalMultiValuedDNPropertyPropertyDefinition()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String[] listTestChildren() { |
| | | return impl.listChildren(INSTANCE.getTestChildrenRelationDefinition()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public TestChildCfg getTestChild(String name) throws ConfigException { |
| | | return impl.getChild(INSTANCE.getTestChildrenRelationDefinition(), name).getConfiguration(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void addTestChildAddListener(ConfigurationAddListener<TestChildCfg> listener) throws ConfigException { |
| | | impl.registerAddListener(INSTANCE.getTestChildrenRelationDefinition(), listener); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void removeTestChildAddListener(ConfigurationAddListener<TestChildCfg> listener) { |
| | | impl.deregisterAddListener(INSTANCE.getTestChildrenRelationDefinition(), listener); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void addTestChildDeleteListener(ConfigurationDeleteListener<TestChildCfg> listener) |
| | | throws ConfigException { |
| | | impl.registerDeleteListener(INSTANCE.getTestChildrenRelationDefinition(), listener); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void removeTestChildDeleteListener(ConfigurationDeleteListener<TestChildCfg> listener) { |
| | | impl.deregisterDeleteListener(INSTANCE.getTestChildrenRelationDefinition(), listener); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean hasOptionalTestChild() { |
| | | return impl.hasChild(INSTANCE.getOptionalTestChildRelationDefinition()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public TestChildCfg getOptionalTestChild() throws ConfigException { |
| | | return impl.getChild(INSTANCE.getOptionalTestChildRelationDefinition()).getConfiguration(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void addOptionalTestChildAddListener(ConfigurationAddListener<TestChildCfg> listener) |
| | | throws ConfigException { |
| | | impl.registerAddListener(INSTANCE.getOptionalTestChildRelationDefinition(), listener); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void removeOptionalTestChildAddListener(ConfigurationAddListener<TestChildCfg> listener) { |
| | | impl.deregisterAddListener(INSTANCE.getOptionalTestChildRelationDefinition(), listener); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void addOptionalChildTestDeleteListener(ConfigurationDeleteListener<TestChildCfg> listener) |
| | | throws ConfigException { |
| | | impl.registerDeleteListener(INSTANCE.getOptionalTestChildRelationDefinition(), listener); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void removeOptionalTestChildDeleteListener(ConfigurationDeleteListener<TestChildCfg> listener) { |
| | | impl.deregisterDeleteListener(INSTANCE.getOptionalTestChildRelationDefinition(), listener); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Class<? extends TestParentCfg> configurationClass() { |
| | | return TestParentCfg.class; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public DN dn() { |
| | | return impl.getDN(); |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions copyright 2011-2015 ForgeRock AS. |
| | | * Portions copyright 2011-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config; |
| | | |
| | |
| | | private static final List<String> CLASS_OBJECT_CLASS_EXCEPTIONS = Arrays.asList(new String[] { |
| | | "org.forgerock.opendj.config.std.meta.RootCfgDefn", "org.forgerock.opendj.config.std.meta.GlobalCfgDefn", }); |
| | | |
| | | // TODO : does not work because can't 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(); |
| | |
| | | // e.g. "prop-name-ending-with-enabled" |
| | | }); |
| | | |
| | | /** |
| | | * Exceptions to properties not starting with the name of their config |
| | | * object. |
| | | */ |
| | | /** Exceptions to properties not starting with the name of their config object. */ |
| | | private static final List<String> OBJECT_PREFIX_PROPERTY_EXCEPTIONS = Arrays.asList(new String[] { "backend-id", |
| | | "plugin-type", "replication-server-id", "network-group-id", "workflow-id", "workflow-element-id", |
| | | "workflow-element" |
| | |
| | | TestCfg.setUp(); |
| | | } |
| | | |
| | | /** |
| | | * Tears down test environment. |
| | | */ |
| | | /** Tears down test environment. */ |
| | | @AfterClass |
| | | public void tearDown() { |
| | | TestCfg.cleanup(); |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS. |
| | | * Portions Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config.client.ldap; |
| | | |
| | |
| | | import org.forgerock.opendj.config.server.ServerConstraintHandler; |
| | | import org.forgerock.opendj.ldap.LdapException; |
| | | |
| | | /** |
| | | * A mock constraint which can be configured to refuse various types of |
| | | * operation. |
| | | */ |
| | | /** A mock constraint which can be configured to refuse various types of operation. */ |
| | | public final class MockConstraint extends Constraint { |
| | | |
| | | /** |
| | | * Mock client constraint handler. |
| | | */ |
| | | /** Mock client constraint handler. */ |
| | | private class Handler extends ClientConstraintHandler { |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isAddAcceptable(ManagementContext context, ManagedObject<?> managedObject, |
| | | Collection<LocalizableMessage> unacceptableReasons) throws LdapException { |
| | |
| | | return allowAdds; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isDeleteAcceptable(ManagementContext context, ManagedObjectPath<?, ?> path, |
| | | Collection<LocalizableMessage> unacceptableReasons) throws LdapException { |
| | |
| | | return allowDeletes; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isModifyAcceptable(ManagementContext context, ManagedObject<?> managedObject, |
| | | Collection<LocalizableMessage> unacceptableReasons) throws LdapException { |
| | |
| | | this.allowDeletes = allowDeletes; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Collection<ClientConstraintHandler> getClientConstraintHandlers() { |
| | | return Collections.<ClientConstraintHandler> singleton(new Handler()); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Collection<ServerConstraintHandler> getServerConstraintHandlers() { |
| | | return Collections.emptySet(); |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2007-2008 Sun Microsystems, Inc. |
| | | * Portions copyright 2013-2015 ForgeRock AS. |
| | | * Portions copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config.server; |
| | | |
| | |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | | * Test cases for aggregations on the server-side. |
| | | */ |
| | | /** Test cases for aggregations on the server-side. */ |
| | | @Test(singleThreaded = true) |
| | | @SuppressWarnings("javadoc") |
| | | public final class AggregationServerTest extends AdminTestCase { |
| | | |
| | | /** |
| | | * Dummy change listener for triggering change constraint call-backs. |
| | | */ |
| | | /** Dummy change listener for triggering change constraint call-backs. */ |
| | | private static final class DummyChangeListener implements ConfigurationChangeListener<TestChildCfg> { |
| | | |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationChange(TestChildCfg configuration) { |
| | | return new ConfigChangeResult(); |
| | | } |
| | | |
| | | @Override |
| | | public boolean isConfigurationChangeAcceptable(TestChildCfg configuration, |
| | | List<LocalizableMessage> unacceptableReasons) { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Dummy delete listener for triggering delete constraint call-backs. |
| | | */ |
| | | /** Dummy delete listener for triggering delete constraint call-backs. */ |
| | | private static final class DummyDeleteListener implements ConfigurationDeleteListener<TestChildCfg> { |
| | | |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationDelete(TestChildCfg configuration) { |
| | | return new ConfigChangeResult(); |
| | | } |
| | | |
| | | @Override |
| | | public boolean isConfigurationDeleteAcceptable(TestChildCfg configuration, |
| | | List<LocalizableMessage> unacceptableReasons) { |
| | | return true; |
| | |
| | | // @Checkstyle:on |
| | | |
| | | // @Checkstyle:off |
| | | /** |
| | | * The default test child configuration "aggregation-property" property |
| | | * definition. |
| | | */ |
| | | /** The default test child configuration "aggregation-property" property definition. */ |
| | | private AggregationPropertyDefinition<ConnectionHandlerCfgClient, ConnectionHandlerCfg> |
| | | aggregationPropertyDefinitionDefault; |
| | | |
| | | /** |
| | | * An aggregation where the target must be enabled if the source is enabled. |
| | | */ |
| | | /** An aggregation where the target must be enabled if the source is enabled. */ |
| | | private AggregationPropertyDefinition<ConnectionHandlerCfgClient, ConnectionHandlerCfg> |
| | | aggregationPropertyDefinitionTargetAndSourceMustBeEnabled; |
| | | |
| | |
| | | TestCfg.addConstraint(aggregationPropertyDefinitionTargetAndSourceMustBeEnabled.getSourceConstraint()); |
| | | } |
| | | |
| | | /** |
| | | * Put back the default aggregation definition. |
| | | */ |
| | | /** Put back the default aggregation definition. */ |
| | | private void putBackDefaultAggregationDefinitionFromTargetAndSourceEnabled() { |
| | | TestCfg.removeConstraint(aggregationPropertyDefinitionTargetAndSourceMustBeEnabled.getSourceConstraint()); |
| | | TestCfg.addPropertyDefinition(aggregationPropertyDefinitionDefault); |
| | |
| | | TestCfg.addConstraint(aggregationPropertyDefinitionTargetMustBeEnabled.getSourceConstraint()); |
| | | } |
| | | |
| | | /** |
| | | * Put back the default aggregation definition. |
| | | */ |
| | | /** Put back the default aggregation definition. */ |
| | | private void putBackDefaultAggregationDefinitionFromTargetEnabled() { |
| | | TestCfg.removeConstraint(aggregationPropertyDefinitionTargetMustBeEnabled.getSourceConstraint()); |
| | | TestCfg.addPropertyDefinition(aggregationPropertyDefinitionDefault); |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions copyright 2015 ForgeRock AS. |
| | | * Portions copyright 2015-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config.server; |
| | | |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | | * Test cases for constraints on the server-side. |
| | | */ |
| | | /** Test cases for constraints on the server-side. */ |
| | | @SuppressWarnings("javadoc") |
| | | public final class ConstraintTest extends AdminTestCase { |
| | | |
| | | private static class AddListener implements ConfigurationAddListener<TestChildCfg> { |
| | | |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationAdd(TestChildCfg configuration) { |
| | | return new ConfigChangeResult(); |
| | | } |
| | | |
| | | @Override |
| | | public boolean isConfigurationAddAcceptable(TestChildCfg configuration, |
| | | List<LocalizableMessage> unacceptableReasons) { |
| | | return true; |
| | |
| | | |
| | | private static class DeleteListener implements ConfigurationDeleteListener<TestChildCfg> { |
| | | |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationDelete(TestChildCfg configuration) { |
| | | return new ConfigChangeResult(); |
| | | } |
| | | |
| | | @Override |
| | | public boolean isConfigurationDeleteAcceptable(TestChildCfg configuration, |
| | | List<LocalizableMessage> unacceptableReasons) { |
| | | return true; |
| | |
| | | |
| | | private static class ChangeListener implements ConfigurationChangeListener<TestChildCfg> { |
| | | |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationChange(TestChildCfg configuration) { |
| | | return new ConfigChangeResult(); |
| | | } |
| | | |
| | | @Override |
| | | public boolean isConfigurationChangeAcceptable(TestChildCfg configuration, |
| | | List<LocalizableMessage> unacceptableReasons) { |
| | | return true; |
| | |
| | | "objectclass: ds-cfg-branch", |
| | | "cn: test children"); |
| | | |
| | | /** |
| | | * Parent 1 - uses default values for |
| | | * optional-multi-valued-dn-property. |
| | | */ |
| | | /** Parent 1 - uses default values for optional-multi-valued-dn-property. */ |
| | | private static final Entry TEST_PARENT_1 = LDIF.makeEntry( |
| | | "dn: cn=test parent 1,cn=test parents,cn=config", |
| | | "objectclass: top", |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | * Portions Copyright 2015-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config.server; |
| | | |
| | |
| | | final SingletonRelationDefinition<TestChildCfgClient, TestChildCfg> relationDef = builder.getInstance(); |
| | | |
| | | LDAPProfile.Wrapper wrapper = new LDAPProfile.Wrapper() { |
| | | @Override |
| | | public String getRelationRDNSequence(RelationDefinition<?, ?> r) { |
| | | return (r == relationDef) ? "cn=singleton-test-child" : null; |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions copyright 2015 ForgeRock AS. |
| | | * Portions copyright 2015-2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config.server; |
| | | |
| | |
| | | import org.testng.annotations.Test; |
| | | |
| | | @SuppressWarnings("javadoc") |
| | | /** |
| | | * Test default behavior on the server side, by checking values of configuration objects. |
| | | */ |
| | | /** Test default behavior on the server side, by checking values of configuration objects. */ |
| | | public final class DefaultBehaviorTest extends AdminTestCase { |
| | | |
| | | private static class TestConfigurationAddListener implements ConfigurationAddListener<TestChildCfg> { |
| | | |
| | | private TestChildCfg childCfg; |
| | | |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationAdd(TestChildCfg configuration) { |
| | | return new ConfigChangeResult(); |
| | | } |
| | |
| | | return childCfg; |
| | | } |
| | | |
| | | @Override |
| | | public boolean isConfigurationAddAcceptable(TestChildCfg configuration, |
| | | List<LocalizableMessage> unacceptableReasons) { |
| | | childCfg = configuration; |
| | |
| | | |
| | | private TestChildCfg childCfg; |
| | | |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationChange(TestChildCfg configuration) { |
| | | return new ConfigChangeResult(); |
| | | } |
| | |
| | | return childCfg; |
| | | } |
| | | |
| | | @Override |
| | | public boolean isConfigurationChangeAcceptable(TestChildCfg configuration, |
| | | List<LocalizableMessage> unacceptableReasons) { |
| | | childCfg = configuration; |
| | |
| | | Arrays.asList("dc=default value p2v1,dc=com", "dc=default value p2v2,dc=com") } }; |
| | | } |
| | | |
| | | /** |
| | | * Test that a child config have correct values when accessed from its |
| | | * parent config. |
| | | */ |
| | | /** Test that a child config have correct values when accessed from its parent config. */ |
| | | @Test(dataProvider = "childConfigurationsValues") |
| | | public void testChildValues(Entry testParent, Entry testBaseChild, Entry testChild, |
| | | List<String> valuesForOptionalDNProperty1, List<String> valuesForOptionalDNProperty2) throws Exception { |
| | |
| | | valuesForOptionalDNProperty2); |
| | | } |
| | | |
| | | /** |
| | | * Test that a child config have correct values when accessed through an add |
| | | * listener. |
| | | */ |
| | | /** Test that a child config have correct values when accessed through an add listener. */ |
| | | @Test(dataProvider = "childConfigurationsValues") |
| | | public void testAddListenerChildValues(Entry testParent, Entry testBaseChild, Entry testChild, |
| | | List<String> valuesForOptionalDNProperty1, List<String> valuesForOptionalDNProperty2) throws Exception { |
| | |
| | | { TEST_PARENT_2, Arrays.asList("dc=default value p2v1,dc=com", "dc=default value p2v2,dc=com") } }; |
| | | } |
| | | |
| | | /** |
| | | * Tests that parent configuration has correct values. |
| | | */ |
| | | /** Tests that parent configuration has correct values. */ |
| | | @Test(dataProvider = "parentConfigurationsValues") |
| | | public void testParentValues(Entry parentEntry, List<String> valuesForOptionalDNProperty) throws Exception { |
| | | ConfigurationRepository configRepository = createConfigRepositoryWithEntries(parentEntry); |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2007-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config.server; |
| | | |
| | |
| | | "cn: test parents"); |
| | | } |
| | | |
| | | /** |
| | | * Create a mock of ConfigurationRepository with provided DNs registered. |
| | | */ |
| | | /** Create a mock of ConfigurationRepository with provided DNs registered. */ |
| | | private ConfigurationRepository createConfigRepositoryWithDNs(DN... dns) throws ConfigException { |
| | | ConfigurationRepository configRepository = mock(ConfigurationRepository.class); |
| | | for (DN dn : dns) { |
| | |
| | | return configRepository; |
| | | } |
| | | |
| | | /** |
| | | * Register a listener for test parent entry and return the actual |
| | | * registered listener. |
| | | */ |
| | | /** Register a listener for test parent entry and return the actual registered listener. */ |
| | | private ConfigAddListener registerAddListenerForTestParent(ConfigurationRepository configRepository, |
| | | ServerManagedObject<RootCfg> root, ConfigurationAddListener<TestParentCfg> parentListener) throws Exception { |
| | | root.registerAddListener(TestCfg.getTestOneToManyParentRelationDefinition(), parentListener); |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | package org.forgerock.opendj.config.server; |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.testng.Assert; |
| | | |
| | | /** |
| | | * A mock constraint which can be configured to refuse various types of |
| | | * operation. |
| | | */ |
| | | /** A mock constraint which can be configured to refuse various types of operation. */ |
| | | public final class MockConstraint extends Constraint { |
| | | |
| | | /** |
| | | * Mock server constraint handler. |
| | | */ |
| | | /** Mock server constraint handler. */ |
| | | private class MockConstraintHandler extends ServerConstraintHandler { |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isDeleteAllowed(ServerManagedObject<?> managedObject, |
| | | Collection<LocalizableMessage> unacceptableReasons) throws ConfigException { |
| | |
| | | return isDeleteAllowed; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isUsable(ServerManagedObject<?> managedObject, |
| | | Collection<LocalizableMessage> unacceptableReasons) throws ConfigException { |
| | |
| | | return isUsable; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void performPostAdd(ServerManagedObject<?> managedObject) throws ConfigException { |
| | | // Make sure that the associated config entry exists. |
| | |
| | | Assert.assertTrue(configRepository.hasEntry(targetDN)); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void performPostDelete(ServerManagedObject<?> managedObject) throws ConfigException { |
| | | // Make sure that the associated config entry does not exist. |
| | |
| | | Assert.assertTrue(configRepository.hasEntry(targetDN)); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void performPostModify(ServerManagedObject<?> managedObject) throws ConfigException { |
| | | // Make sure that the associated config entry exists. |
| | |
| | | this.configRepository = configRepository; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Collection<ClientConstraintHandler> getClientConstraintHandlers() { |
| | | return Collections.emptySet(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public Collection<ServerConstraintHandler> getServerConstraintHandlers() { |
| | | return Collections.<ServerConstraintHandler> singleton(new MockConstraintHandler()); |
| | | } |