| | |
| | | ' The definition of the ', $ufn,' to be created.
', |
| | | '@param exceptions
', |
| | | ' An optional collection in which to place any ', |
| | | '{@link DefaultBehaviorException}s that occurred whilst ', |
| | | '{@link PropertyException}s that occurred whilst ', |
| | | 'attempting to determine the default values of the ', $ufn, |
| | | '. This argument can be <code>null<code>.
', |
| | | '@return Returns a new ', $ufn,' configuration instance.
')" /> |
| | | </xsl:call-template> |
| | | <xsl:value-of |
| | | select="concat(' <C extends ', $java-class-name,'CfgClient> C create', $java-relation-name, '(
', |
| | | ' ManagedObjectDefinition<C, ? extends ', $java-class-name,'Cfg> d, Collection<DefaultBehaviorException> exceptions);
')" /> |
| | | ' ManagedObjectDefinition<C, ? extends ', $java-class-name,'Cfg> d, Collection<PropertyException> exceptions);
')" /> |
| | | <xsl:text>
</xsl:text> |
| | | <xsl:text>
</xsl:text> |
| | | <xsl:text>
</xsl:text> |
| | |
| | | ' The name of the new ', $ufn,'.
', |
| | | '@param exceptions
', |
| | | ' An optional collection in which to place any ', |
| | | '{@link DefaultBehaviorException}s that occurred whilst ', |
| | | '{@link PropertyException}s that occurred whilst ', |
| | | 'attempting to determine the default values of the ', $ufn, |
| | | '. This argument can be <code>null<code>.
', |
| | | '@return Returns a new ', $ufn,' configuration instance.
', |
| | |
| | | </xsl:call-template> |
| | | <xsl:value-of |
| | | select="concat(' <C extends ', $java-class-name,'CfgClient> C create', $java-relation-name, '(
', |
| | | ' ManagedObjectDefinition<C, ? extends ', $java-class-name,'Cfg> d, String name, Collection<DefaultBehaviorException> exceptions) throws IllegalManagedObjectNameException;
')" /> |
| | | ' ManagedObjectDefinition<C, ? extends ', $java-class-name,'Cfg> d, String name, Collection<PropertyException> exceptions) throws IllegalManagedObjectNameException;
')" /> |
| | | </xsl:when> |
| | | <xsl:when test="string(adm:one-to-many/@unique) = 'true'"> |
| | | <xsl:call-template name="add-java-comment2"> |
| | |
| | | ' The definition of the ', $ufn,' to be created.
', |
| | | '@param exceptions
', |
| | | ' An optional collection in which to place any ', |
| | | '{@link DefaultBehaviorException}s that occurred whilst ', |
| | | '{@link PropertyException}s that occurred whilst ', |
| | | 'attempting to determine the default values of the ', $ufn, |
| | | '. This argument can be <code>null<code>.
', |
| | | '@return Returns a new ', $ufn,' configuration instance.
')" /> |
| | | </xsl:call-template> |
| | | <xsl:value-of |
| | | select="concat(' <C extends ', $java-class-name,'CfgClient> C create', $java-relation-name, '(
', |
| | | ' ManagedObjectDefinition<C, ? extends ', $java-class-name,'Cfg> d, Collection<DefaultBehaviorException> exceptions);
')" /> |
| | | ' ManagedObjectDefinition<C, ? extends ', $java-class-name,'Cfg> d, Collection<PropertyException> exceptions);
')" /> |
| | | </xsl:when> |
| | | </xsl:choose> |
| | | <xsl:text>
</xsl:text> |
| | |
| | | <xsl:if |
| | | test="$this-local-properties[not(@monitoring='true')]"> |
| | | <import> |
| | | org.opends.server.admin.IllegalPropertyValueException |
| | | org.opends.server.admin.PropertyException |
| | | </import> |
| | | </xsl:if> |
| | | <xsl:if test="$this-local-properties[@read-only='true']"> |
| | | <import> |
| | | org.opends.server.admin.PropertyIsReadOnlyException |
| | | org.opends.server.admin.PropertyException |
| | | </import> |
| | | </xsl:if> |
| | | <xsl:if test="$this-local-relations"> |
| | |
| | | test="$this-local-relations/adm:one-to-zero-or-one|$this-local-relations/adm:one-to-many"> |
| | | <import>java.util.Collection</import> |
| | | <import> |
| | | org.opends.server.admin.DefaultBehaviorException |
| | | org.opends.server.admin.PropertyException |
| | | </import> |
| | | <import> |
| | | org.opends.server.admin.client.OperationRejectedException |
| | |
| | | ' * {@inheritDoc}
', |
| | | ' */
', |
| | | ' public <M extends ', $java-class-name, 'CfgClient> M create', $java-relation-name, '(
', |
| | | ' ManagedObjectDefinition<M, ? extends ', $java-class-name,'Cfg> d, Collection<DefaultBehaviorException> exceptions) {
', |
| | | ' ManagedObjectDefinition<M, ? extends ', $java-class-name,'Cfg> d, Collection<PropertyException> exceptions) {
', |
| | | ' return impl.createChild(INSTANCE.get', $java-relation-name,'RelationDefinition(), d, exceptions).getConfiguration();
', |
| | | ' }
')" /> |
| | | <xsl:text>
</xsl:text> |
| | |
| | | ' * {@inheritDoc}
', |
| | | ' */
', |
| | | ' public <M extends ', $java-class-name, 'CfgClient> M create', $java-relation-name, '(
', |
| | | ' ManagedObjectDefinition<M, ? extends ', $java-class-name,'Cfg> d, String name, Collection<DefaultBehaviorException> exceptions) throws IllegalManagedObjectNameException {
', |
| | | ' ManagedObjectDefinition<M, ? extends ', $java-class-name,'Cfg> d, String name, Collection<PropertyException> exceptions) throws IllegalManagedObjectNameException {
', |
| | | ' return impl.createChild(INSTANCE.get', $java-relation-plural-name,'RelationDefinition(), d, name, exceptions).getConfiguration();
', |
| | | ' }
')" /> |
| | | </xsl:when> |
| | |
| | | ' * {@inheritDoc}
', |
| | | ' */
', |
| | | ' public <M extends ', $java-class-name, 'CfgClient> M create', $java-relation-name, '(
', |
| | | ' ManagedObjectDefinition<M, ? extends ', $java-class-name,'Cfg> d, Collection<DefaultBehaviorException> exceptions) {
', |
| | | ' ManagedObjectDefinition<M, ? extends ', $java-class-name,'Cfg> d, Collection<PropertyException> exceptions) {
', |
| | | ' return impl.createChild(INSTANCE.get', $java-relation-plural-name,'RelationDefinition(), d, exceptions).getConfiguration();
', |
| | | ' }
')" /> |
| | | </xsl:when> |
| | |
| | | </import> |
| | | </xsl:if> |
| | | <import> |
| | | org.opends.server.admin.DefaultBehaviorException |
| | | org.opends.server.admin.PropertyException |
| | | </import> |
| | | <import> |
| | | org.opends.server.admin.server.ConfigurationAddListener |
| | |
| | | <xsl:if test="$this-all-relations/adm:one-to-zero-or-one"> |
| | | <import>java.util.Collection</import> |
| | | <import> |
| | | org.opends.server.admin.DefaultBehaviorException |
| | | org.opends.server.admin.PropertyException |
| | | </import> |
| | | <import> |
| | | org.opends.server.admin.server.ConfigurationAddListener |
| | |
| | | </xsl:if> |
| | | <xsl:if test="$this-all-properties[@read-only='true']"> |
| | | <import> |
| | | org.opends.server.admin.PropertyIsReadOnlyException |
| | | org.opends.server.admin.PropertyException |
| | | </import> |
| | | </xsl:if> |
| | | </xsl:otherwise> |
| | |
| | | <xsl:value-of |
| | | select="concat(' *
', |
| | | ' * @param value The value of the "', $name, '" property.
', |
| | | ' * @throws IllegalPropertyValueException
', |
| | | ' * @throws PropertyException
', |
| | | ' * If the new value is invalid.
')" /> |
| | | <xsl:if test="@read-only='true'"> |
| | | <xsl:value-of |
| | | select="concat( |
| | | ' * @throws PropertyIsReadOnlyException
', |
| | | ' * @throws PropertyException
', |
| | | ' * If this ', $this-ufn, ' is not being initialized.
')" /> |
| | | </xsl:if> |
| | | <xsl:value-of |
| | |
| | | <xsl:value-of |
| | | select="concat(' *
', |
| | | ' * @param values The values of the "', $name, '" property.
', |
| | | ' * @throws IllegalPropertyValueException
', |
| | | ' * @throws PropertyException
', |
| | | ' * If one or more of the new values are invalid.
')" /> |
| | | <xsl:if test="@read-only='true'"> |
| | | <xsl:value-of |
| | | select="concat( |
| | | ' * @throws PropertyIsReadOnlyException
', |
| | | ' * @throws PropertyException
', |
| | | ' * If this ', $this-ufn, ' is not being initialized.
')" /> |
| | | </xsl:if> |
| | | <xsl:value-of |
| | |
| | | <xsl:value-of select="'> values'" /> |
| | | </xsl:otherwise> |
| | | </xsl:choose> |
| | | <xsl:value-of select="') throws IllegalPropertyValueException'" /> |
| | | <xsl:value-of select="') throws PropertyException'" /> |
| | | <xsl:if test="@read-only='true'"> |
| | | <xsl:value-of select="', PropertyIsReadOnlyException'" /> |
| | | <xsl:value-of select="', PropertyException'" /> |
| | | </xsl:if> |
| | | <xsl:value-of select="';
'" /> |
| | | </xsl:if> |
| | |
| | | <xsl:value-of select="' value)'" /> |
| | | <xsl:if test="@read-only='true'"> |
| | | <xsl:value-of |
| | | select="' throws PropertyIsReadOnlyException'" /> |
| | | select="' throws PropertyException'" /> |
| | | </xsl:if> |
| | | <xsl:value-of |
| | | select="concat(' {
' , |
| | |
| | | <xsl:value-of select="'> values)'" /> |
| | | <xsl:if test="@read-only='true'"> |
| | | <xsl:value-of |
| | | select="' throws PropertyIsReadOnlyException'" /> |
| | | select="' throws PropertyException'" /> |
| | | </xsl:if> |
| | | <xsl:value-of |
| | | select="concat(' {
' , |
| | |
| | | |
| | | import static org.opends.quicksetup.util.Utils.*; |
| | | |
| | | import org.opends.server.admin.DefaultBehaviorException; |
| | | import org.opends.server.admin.PropertyException; |
| | | import org.opends.server.admin.ManagedObjectNotFoundException; |
| | | import org.opends.server.admin.client.ManagementContext; |
| | | import org.opends.server.admin.client.ldap.LDAPManagementContext; |
| | |
| | | ReplicationSynchronizationProviderCfgDefn.getInstance(); |
| | | sync = root.createSynchronizationProvider(provider, |
| | | "Multimaster Synchronization", |
| | | new ArrayList<DefaultBehaviorException>()); |
| | | new ArrayList<PropertyException>()); |
| | | sync.setJavaClass( |
| | | org.opends.server.replication.plugin.MultimasterReplication.class. |
| | | getName()); |
| | |
| | | usedReplicationServerIds.add(id); |
| | | replicationServer = sync.createReplicationServer( |
| | | ReplicationServerCfgDefn.getInstance(), |
| | | new ArrayList<DefaultBehaviorException>()); |
| | | new ArrayList<PropertyException>()); |
| | | replicationServer.setReplicationServerId(id); |
| | | replicationServer.setReplicationPort(replicationPort); |
| | | replicationServerCreated = true; |
| | |
| | | domainName = getDomainName(domainNames, domainId, dn); |
| | | domain = sync.createReplicationDomain( |
| | | ReplicationDomainCfgDefn.getInstance(), domainName, |
| | | new ArrayList<DefaultBehaviorException>()); |
| | | new ArrayList<PropertyException>()); |
| | | domain.setServerId(domainId); |
| | | domain.setBaseDN(DN.valueOf(dn)); |
| | | isCreated = true; |
| | |
| | | */ |
| | | @Override |
| | | public void validateValue(Aci value) |
| | | throws IllegalPropertyValueException { |
| | | throws PropertyException { |
| | | ifNull(value); |
| | | |
| | | // No additional validation required. |
| | |
| | | */ |
| | | @Override |
| | | public Aci decodeValue(String value) |
| | | throws IllegalPropertyValueStringException { |
| | | throws PropertyException { |
| | | ifNull(value); |
| | | |
| | | try { |
| | | return Aci.decode(ByteString.valueOf(value), DN.NULL_DN); |
| | | } catch (AciException e) { |
| | | // TODO: it would be nice to throw the cause. |
| | | throw new IllegalPropertyValueStringException(this, value); |
| | | throw PropertyException.illegalPropertyValueException(this, value); |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public String decodeValue(String value) |
| | | throws IllegalPropertyValueStringException { |
| | | throws PropertyException { |
| | | ifNull(value); |
| | | |
| | | try { |
| | | validateValue(value); |
| | | return value; |
| | | } catch (IllegalPropertyValueException e) { |
| | | throw new IllegalPropertyValueStringException(this, value); |
| | | } catch (PropertyException e) { |
| | | throw PropertyException.illegalPropertyValueException(this, value); |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public String normalizeValue(String value) |
| | | throws IllegalPropertyValueException { |
| | | throws PropertyException { |
| | | try { |
| | | Reference<C, S> reference = Reference.parseName(parentPath, |
| | | relationDefinition, value); |
| | | return reference.getNormalizedName(); |
| | | } catch (IllegalArgumentException e) { |
| | | throw new IllegalPropertyValueException(this, value); |
| | | throw PropertyException.illegalPropertyValueException(this, value); |
| | | } |
| | | } |
| | | |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void validateValue(String value) throws IllegalPropertyValueException { |
| | | public void validateValue(String value) throws PropertyException { |
| | | try { |
| | | Reference.parseName(parentPath, relationDefinition, value); |
| | | } catch (IllegalArgumentException e) { |
| | | throw new IllegalPropertyValueException(this, value); |
| | | throw PropertyException.illegalPropertyValueException(this, value); |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public AttributeType decodeValue(String value) |
| | | throws IllegalPropertyValueStringException { |
| | | throws PropertyException { |
| | | ifNull(value); |
| | | |
| | | String name = value.trim().toLowerCase(); |
| | |
| | | !isCheckSchema); |
| | | |
| | | if (type == null) { |
| | | throw new IllegalPropertyValueStringException(this, value); |
| | | throw PropertyException.illegalPropertyValueException(this, value); |
| | | } else { |
| | | try { |
| | | validateValue(type); |
| | | return type; |
| | | } catch (IllegalPropertyValueException e) { |
| | | throw new IllegalPropertyValueStringException(this, value); |
| | | } catch (PropertyException e) { |
| | | throw PropertyException.illegalPropertyValueException(this, value); |
| | | } |
| | | } |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | public String encodeValue(AttributeType value) |
| | | throws IllegalPropertyValueException { |
| | | throws PropertyException { |
| | | return value.getNameOrOID(); |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public void validateValue(AttributeType value) |
| | | throws IllegalPropertyValueException { |
| | | throws PropertyException { |
| | | ifNull(value); |
| | | |
| | | // No implementation required. |
| | |
| | | */ |
| | | @Override |
| | | public void validateValue(Boolean value) |
| | | throws IllegalPropertyValueException { |
| | | throws PropertyException { |
| | | ifNull(value); |
| | | |
| | | // No additional validation required. |
| | |
| | | */ |
| | | @Override |
| | | public Boolean decodeValue(String value) |
| | | throws IllegalPropertyValueStringException { |
| | | throws PropertyException { |
| | | ifNull(value); |
| | | |
| | | String nvalue = value.trim().toLowerCase(); |
| | | Boolean b = VALUE_MAP.get(nvalue); |
| | | |
| | | if (b == null) { |
| | | throw new IllegalPropertyValueStringException(this, value); |
| | | throw PropertyException.illegalPropertyValueException(this, value); |
| | | } else { |
| | | return b; |
| | | } |
| | |
| | | |
| | | |
| | | import static org.forgerock.util.Reject.ifNull; |
| | | import static org.opends.server.admin.PropertyException.*; |
| | | |
| | | import java.util.Collections; |
| | | import java.util.EnumSet; |
| | |
| | | */ |
| | | @Override |
| | | public String decodeValue(String value) |
| | | throws IllegalPropertyValueStringException { |
| | | throws PropertyException { |
| | | ifNull(value); |
| | | |
| | | try { |
| | | validateValue(value); |
| | | } catch (IllegalPropertyValueException e) { |
| | | throw new IllegalPropertyValueStringException(this, value, e.getCause()); |
| | | } catch (PropertyException e) { |
| | | throw illegalPropertyValueException(this, value, e.getCause()); |
| | | } |
| | | |
| | | return value; |
| | |
| | | * The class representing the requested type. |
| | | * @return Returns the named class cast to a subclass of the |
| | | * specified class. |
| | | * @throws IllegalPropertyValueException |
| | | * @throws PropertyException |
| | | * If the named class was invalid, could not be loaded, or |
| | | * did not implement the required interfaces. |
| | | * @throws ClassCastException |
| | |
| | | * requested type. |
| | | */ |
| | | public <T> Class<? extends T> loadClass(String className, |
| | | Class<T> instanceOf) throws IllegalPropertyValueException, |
| | | Class<T> instanceOf) throws PropertyException, |
| | | ClassCastException { |
| | | ifNull(className, instanceOf); |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public String normalizeValue(String value) |
| | | throws IllegalPropertyValueException { |
| | | throws PropertyException { |
| | | ifNull(value); |
| | | |
| | | return value.trim(); |
| | |
| | | */ |
| | | @Override |
| | | public void validateValue(String value) |
| | | throws IllegalPropertyValueException { |
| | | throws PropertyException { |
| | | ifNull(value); |
| | | |
| | | // Always make sure the name is a valid class name. |
| | |
| | | * definition. |
| | | */ |
| | | private Class<?> validateClassInterfaces(String className, boolean initialize) |
| | | throws IllegalPropertyValueException { |
| | | throws PropertyException { |
| | | Class<?> theClass = loadClassForValidation(className, className, |
| | | initialize); |
| | | for (String i : instanceOfInterfaces) { |
| | | Class<?> instanceOfClass = loadClassForValidation(className, i, |
| | | initialize); |
| | | if (!instanceOfClass.isAssignableFrom(theClass)) { |
| | | throw new IllegalPropertyValueException(this, className); |
| | | throw PropertyException.illegalPropertyValueException(this, className); |
| | | } |
| | | } |
| | | return theClass; |
| | |
| | | return loadClass(classToBeLoaded.trim(), initialize); |
| | | } catch (ClassNotFoundException e) { |
| | | // If the class cannot be loaded then it is an invalid value. |
| | | throw new IllegalPropertyValueException(this, componentClassName, e); |
| | | throw illegalPropertyValueException(this, componentClassName, e); |
| | | } catch (LinkageError e) { |
| | | // If the class cannot be initialized then it is an invalid value. |
| | | throw new IllegalPropertyValueException(this, componentClassName, e); |
| | | throw illegalPropertyValueException(this, componentClassName, e); |
| | | } |
| | | } |
| | | |
| | |
| | | * Do some basic checks to make sure the string representation is valid. |
| | | */ |
| | | private void validateClassName(String className) |
| | | throws IllegalPropertyValueException { |
| | | throws PropertyException { |
| | | String nvalue = className.trim(); |
| | | if (!nvalue.matches(CLASS_RE)) { |
| | | throw new IllegalPropertyValueException(this, className); |
| | | throw PropertyException.illegalPropertyValueException(this, className); |
| | | } |
| | | } |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | public void validateValue(DN value) |
| | | throws IllegalPropertyValueException { |
| | | throws PropertyException { |
| | | ifNull(value); |
| | | |
| | | if (baseDN != null) { |
| | |
| | | } |
| | | |
| | | if (!parent.equals(baseDN)) { |
| | | throw new IllegalPropertyValueException(this, value); |
| | | throw PropertyException.illegalPropertyValueException(this, value); |
| | | } |
| | | } |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | public DN decodeValue(String value) |
| | | throws IllegalPropertyValueStringException { |
| | | throws PropertyException { |
| | | ifNull(value); |
| | | |
| | | try { |
| | |
| | | validateValue(dn); |
| | | return dn; |
| | | } catch (DirectoryException e) { |
| | | throw new IllegalPropertyValueStringException(this, value); |
| | | } catch (IllegalPropertyValueException e) { |
| | | throw new IllegalPropertyValueStringException(this, value); |
| | | throw PropertyException.illegalPropertyValueException(this, value); |
| | | } catch (PropertyException e) { |
| | | throw PropertyException.illegalPropertyValueException(this, value); |
| | | } |
| | | } |
| | | |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void validateValue(Long value) throws IllegalPropertyValueException { |
| | | public void validateValue(Long value) throws PropertyException { |
| | | ifNull(value); |
| | | |
| | | long nvalue = baseUnit.toMilliSeconds(value); |
| | | if (!allowUnlimited && nvalue < lowerLimit) { |
| | | throw new IllegalPropertyValueException(this, value); |
| | | throw PropertyException.illegalPropertyValueException(this, value); |
| | | |
| | | // unlimited allowed |
| | | } else if (nvalue >= 0 && nvalue < lowerLimit) { |
| | | throw new IllegalPropertyValueException(this, value); |
| | | throw PropertyException.illegalPropertyValueException(this, value); |
| | | } |
| | | |
| | | if ((upperLimit != null) && (nvalue > upperLimit)) { |
| | | throw new IllegalPropertyValueException(this, value); |
| | | throw PropertyException.illegalPropertyValueException(this, value); |
| | | } |
| | | } |
| | | |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public String encodeValue(Long value) throws IllegalPropertyValueException { |
| | | public String encodeValue(Long value) throws PropertyException { |
| | | ifNull(value); |
| | | |
| | | // Make sure that we correctly encode negative values as |
| | |
| | | */ |
| | | @Override |
| | | public Long decodeValue(String value) |
| | | throws IllegalPropertyValueStringException { |
| | | throws PropertyException { |
| | | ifNull(value); |
| | | |
| | | // First check for the special "unlimited" value when necessary. |
| | |
| | | try { |
| | | ms = DurationUnit.parseValue(value); |
| | | } catch (NumberFormatException e) { |
| | | throw new IllegalPropertyValueStringException(this, value); |
| | | throw PropertyException.illegalPropertyValueException(this, value); |
| | | } |
| | | |
| | | // Check the unit is in range - values must not be more granular |
| | | // than the base unit. |
| | | if ((ms % baseUnit.getDuration()) != 0) { |
| | | throw new IllegalPropertyValueStringException(this, value); |
| | | throw PropertyException.illegalPropertyValueException(this, value); |
| | | } |
| | | |
| | | // Convert the value a long in the property's required unit. |
| | | Long i = (long) baseUnit.fromMilliSeconds(ms); |
| | | try { |
| | | validateValue(i); |
| | | } catch (IllegalPropertyValueException e) { |
| | | throw new IllegalPropertyValueStringException(this, value); |
| | | } catch (PropertyException e) { |
| | | throw PropertyException.illegalPropertyValueException(this, value); |
| | | } |
| | | return i; |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | public E decodeValue(String value) |
| | | throws IllegalPropertyValueStringException { |
| | | throws PropertyException { |
| | | ifNull(value); |
| | | |
| | | String nvalue = value.trim().toLowerCase(); |
| | | E eValue = decodeMap.get(nvalue); |
| | | if (eValue == null) { |
| | | throw new IllegalPropertyValueStringException(this, value); |
| | | throw PropertyException.illegalPropertyValueException(this, value); |
| | | } else { |
| | | return eValue; |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | public String normalizeValue(E value) |
| | | throws IllegalPropertyValueException { |
| | | throws PropertyException { |
| | | ifNull(value); |
| | | |
| | | return value.toString().trim().toLowerCase(); |
| | |
| | | */ |
| | | @Override |
| | | public void validateValue(E value) |
| | | throws IllegalPropertyValueException { |
| | | throws PropertyException { |
| | | ifNull(value); |
| | | |
| | | // No additional validation required. |
| | |
| | | */ |
| | | @Override |
| | | public void validateValue(AddressMask value) |
| | | throws IllegalPropertyValueException { |
| | | throws PropertyException { |
| | | ifNull(value); |
| | | |
| | | // No additional validation required. |
| | |
| | | */ |
| | | @Override |
| | | public AddressMask decodeValue(String value) |
| | | throws IllegalPropertyValueStringException { |
| | | throws PropertyException { |
| | | ifNull(value); |
| | | |
| | | try { |
| | | return AddressMask.decode(value); |
| | | } catch (ConfigException e) { |
| | | // TODO: it would be nice to throw the cause. |
| | | throw new IllegalPropertyValueStringException(this, value); |
| | | throw PropertyException.illegalPropertyValueException(this, value); |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public void validateValue(InetAddress value) |
| | | throws IllegalPropertyValueException { |
| | | throws PropertyException { |
| | | ifNull(value); |
| | | |
| | | // No additional validation required. |
| | |
| | | */ |
| | | @Override |
| | | public InetAddress decodeValue(String value) |
| | | throws IllegalPropertyValueStringException { |
| | | throws PropertyException { |
| | | ifNull(value); |
| | | |
| | | try { |
| | | return InetAddress.getByName(value); |
| | | } catch (UnknownHostException e) { |
| | | // TODO: it would be nice to throw the cause. |
| | | throw new IllegalPropertyValueStringException(this, value); |
| | | throw PropertyException.illegalPropertyValueException(this, value); |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public String encodeValue(InetAddress value) |
| | | throws IllegalPropertyValueException { |
| | | throws PropertyException { |
| | | // We should return the host name if it is available, or the IP |
| | | // address if not. |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public void validateValue(Integer value) |
| | | throws IllegalPropertyValueException { |
| | | throws PropertyException { |
| | | ifNull(value); |
| | | |
| | | if (!allowUnlimited && value < lowerLimit) { |
| | | throw new IllegalPropertyValueException(this, value); |
| | | throw PropertyException.illegalPropertyValueException(this, value); |
| | | |
| | | // unlimited allowed |
| | | } else if (value >= 0 && value < lowerLimit) { |
| | | throw new IllegalPropertyValueException(this, value); |
| | | throw PropertyException.illegalPropertyValueException(this, value); |
| | | } |
| | | |
| | | if ((upperLimit != null) && (value > upperLimit)) { |
| | | throw new IllegalPropertyValueException(this, value); |
| | | throw PropertyException.illegalPropertyValueException(this, value); |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public String encodeValue(Integer value) |
| | | throws IllegalPropertyValueException { |
| | | throws PropertyException { |
| | | ifNull(value); |
| | | |
| | | // Make sure that we correctly encode negative values as "unlimited". |
| | |
| | | */ |
| | | @Override |
| | | public Integer decodeValue(String value) |
| | | throws IllegalPropertyValueStringException { |
| | | throws PropertyException { |
| | | ifNull(value); |
| | | |
| | | if (allowUnlimited) { |
| | |
| | | try { |
| | | i = Integer.valueOf(value); |
| | | } catch (NumberFormatException e) { |
| | | throw new IllegalPropertyValueStringException(this, value); |
| | | throw PropertyException.illegalPropertyValueException(this, value); |
| | | } |
| | | |
| | | try { |
| | | validateValue(i); |
| | | } catch (IllegalPropertyValueException e) { |
| | | throw new IllegalPropertyValueStringException(this, value); |
| | | } catch (PropertyException e) { |
| | | throw PropertyException.illegalPropertyValueException(this, value); |
| | | } |
| | | |
| | | return i; |
| | |
| | | * @param value |
| | | * The property string value (must not be <code>null</code>). |
| | | * @return Returns the decoded property value. |
| | | * @throws IllegalPropertyValueStringException |
| | | * @throws PropertyException |
| | | * If the property value string is invalid. |
| | | */ |
| | | public abstract T decodeValue(String value) |
| | | throws IllegalPropertyValueStringException; |
| | | throws PropertyException; |
| | | |
| | | |
| | | |
| | |
| | | * @param value |
| | | * The property value (must not be <code>null</code>). |
| | | * @return Returns the encoded property string value. |
| | | * @throws IllegalPropertyValueException |
| | | * @throws PropertyException |
| | | * If the property value is invalid. |
| | | */ |
| | | public String encodeValue(T value) throws IllegalPropertyValueException { |
| | | public String encodeValue(T value) throws PropertyException { |
| | | ifNull(value); |
| | | |
| | | return value.toString(); |
| | |
| | | * @param value |
| | | * The property value to be normalized. |
| | | * @return Returns the normalized property value. |
| | | * @throws IllegalPropertyValueException |
| | | * @throws PropertyException |
| | | * If the property value is invalid. |
| | | */ |
| | | public String normalizeValue(T value) throws IllegalPropertyValueException { |
| | | public String normalizeValue(T value) throws PropertyException { |
| | | ifNull(value); |
| | | |
| | | return encodeValue(value); |
| | |
| | | * |
| | | * @param value |
| | | * The property value (must not be <code>null</code>). |
| | | * @throws IllegalPropertyValueException |
| | | * @throws PropertyException |
| | | * If the property value is invalid. |
| | | */ |
| | | public abstract void validateValue(T value) |
| | | throws IllegalPropertyValueException; |
| | | throws PropertyException; |
| | | |
| | | |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public <T> Message visitUnknown(PropertyDefinition<T> d, Void p) |
| | | throws UnknownPropertyDefinitionException { |
| | | throws PropertyException { |
| | | return Message.raw("?"); |
| | | } |
| | | } |
| | |
| | | * definition types. |
| | | * <p> |
| | | * The default implementation of this method throws an |
| | | * {@link UnknownPropertyDefinitionException}. Sub-classes can |
| | | * {@link PropertyException}. Sub-classes can |
| | | * override this method with their own default behavior. |
| | | * |
| | | * @param <T> |
| | |
| | | * @param p |
| | | * A visitor specified parameter. |
| | | * @return Returns a visitor specified result. |
| | | * @throws UnknownPropertyDefinitionException |
| | | * @throws PropertyException |
| | | * Visitor implementations may optionally throw this |
| | | * exception. |
| | | */ |
| | | public <T> R visitUnknown(PropertyDefinition<T> pd, P p) |
| | | throws UnknownPropertyDefinitionException { |
| | | throw new UnknownPropertyDefinitionException(pd, p); |
| | | throws PropertyException { |
| | | throw PropertyException.unknownPropertyDefinitionException(pd, p); |
| | | } |
| | | |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions copyright 2014 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.opends.server.admin; |
| | | |
| | | |
| | | |
| | | import static org.opends.messages.AdminMessages.*; |
| | | |
| | | import org.opends.messages.Message; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Exceptions thrown as a result of errors that occurred when decoding |
| | | * and modifying property values. |
| | | * Exceptions thrown as a result of errors that occurred when decoding and |
| | | * modifying property values. |
| | | */ |
| | | public abstract class PropertyException extends AdminRuntimeException { |
| | | public final class PropertyException extends AdminRuntimeException |
| | | { |
| | | |
| | | /** |
| | | * Version ID required by serializable classes. |
| | | */ |
| | | private static final long serialVersionUID = -8465109598081914482L; |
| | | |
| | | // The property definition associated with the property that caused |
| | | // the exception. |
| | | private final PropertyDefinition<?> pd; |
| | | |
| | | |
| | | /** |
| | | * Creates a new default behavior exception with a cause. |
| | | * |
| | | * @param pd |
| | | * The property definition whose default values could not be |
| | | * determined. |
| | | * @param cause |
| | | * The exception that prevented the default values from being |
| | | * determined. |
| | | * @return A new default behavior exception with a cause. |
| | | */ |
| | | public static PropertyException defaultBehaviorException( |
| | | PropertyDefinition<?> pd, Throwable cause) |
| | | { |
| | | return new PropertyException(pd, |
| | | ERR_DEFAULT_BEHAVIOR_PROPERTY_EXCEPTION.get(pd.getName()), cause); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Creates property exception without a cause. |
| | | * Creates a new illegal property value exception. |
| | | * |
| | | * @param pd |
| | | * The property definition associated with the property |
| | | * that caused the exception. |
| | | * @param message |
| | | * The message. |
| | | * The property definition. |
| | | * @param value |
| | | * The illegal property value. |
| | | * @return A new illegal property value exception. |
| | | */ |
| | | protected PropertyException(PropertyDefinition<?> pd, Message message) { |
| | | public static PropertyException illegalPropertyValueException( |
| | | PropertyDefinition<?> pd, Object value) |
| | | { |
| | | return new PropertyException(pd, createMessage(pd, value)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Creates a new illegal property value exception. |
| | | * |
| | | * @param pd |
| | | * The property definition. |
| | | * @param value |
| | | * The illegal property value. |
| | | * @param cause |
| | | * The cause. |
| | | * @return A new illegal property value exception. |
| | | */ |
| | | public static PropertyException illegalPropertyValueException( |
| | | PropertyDefinition<?> pd, Object value, Throwable cause) |
| | | { |
| | | return new PropertyException(pd, createMessage(pd, value), cause); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Create a new property is mandatory exception. |
| | | * |
| | | * @param pd |
| | | * The property definition. |
| | | * @return A new property is mandatory exception. |
| | | */ |
| | | public static PropertyException propertyIsMandatoryException( |
| | | PropertyDefinition<?> pd) |
| | | { |
| | | return new PropertyException(pd, ERR_PROPERTY_IS_MANDATORY_EXCEPTION.get(pd |
| | | .getName())); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Create a new property is read-only exception. |
| | | * |
| | | * @param pd |
| | | * The property definition. |
| | | * @return A new property is read-only exception. |
| | | */ |
| | | public static PropertyException propertyIsReadOnlyException( |
| | | PropertyDefinition<?> pd) |
| | | { |
| | | return new PropertyException(pd, ERR_PROPERTY_IS_READ_ONLY_EXCEPTION.get(pd |
| | | .getName())); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Create a new property is single valued exception. |
| | | * |
| | | * @param pd |
| | | * The property definition. |
| | | * @return A new property is single valued exception. |
| | | */ |
| | | public static PropertyException propertyIsSingleValuedException( |
| | | PropertyDefinition<?> pd) |
| | | { |
| | | return new PropertyException(pd, |
| | | ERR_PROPERTY_IS_SINGLE_VALUED_EXCEPTION.get(pd.getName())); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Creates a new unknown property definition exception. |
| | | * |
| | | * @param pd |
| | | * The unknown property definition. |
| | | * @param p |
| | | * The visitor parameter if there was one. |
| | | * @return A new unknown property definition exception. |
| | | */ |
| | | public static PropertyException unknownPropertyDefinitionException( |
| | | PropertyDefinition<?> pd, Object p) |
| | | { |
| | | return new PropertyException(pd, |
| | | ERR_UNKNOWN_PROPERTY_DEFINITION_EXCEPTION.get(pd.getName(), pd |
| | | .getClass().getName())); |
| | | } |
| | | |
| | | |
| | | |
| | | // Create the message. |
| | | private static Message createMessage(PropertyDefinition<?> pd, Object value) |
| | | { |
| | | PropertyDefinitionUsageBuilder builder = new PropertyDefinitionUsageBuilder( |
| | | true); |
| | | return ERR_ILLEGAL_PROPERTY_VALUE_EXCEPTION.get(String.valueOf(value), |
| | | pd.getName(), builder.getUsage(pd)); |
| | | } |
| | | |
| | | |
| | | |
| | | /* |
| | | * The property definition associated with the property that caused the |
| | | * exception. |
| | | */ |
| | | private final PropertyDefinition<?> pd; |
| | | |
| | | |
| | | |
| | | private PropertyException(PropertyDefinition<?> pd, Message message) |
| | | { |
| | | super(message); |
| | | this.pd = pd; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Creates property exception with a cause. |
| | | * |
| | | * @param pd |
| | | * The property definition associated with the property |
| | | * that caused the exception. |
| | | * @param message |
| | | * The message. |
| | | * @param cause |
| | | * The cause. |
| | | */ |
| | | protected PropertyException(PropertyDefinition<?> pd, Message message, |
| | | Throwable cause) { |
| | | private PropertyException(PropertyDefinition<?> pd, Message message, |
| | | Throwable cause) |
| | | { |
| | | super(message, cause); |
| | | this.pd = pd; |
| | | } |
| | |
| | | |
| | | |
| | | /** |
| | | * Get the property definition associated with the property that |
| | | * caused the exception. |
| | | * Get the property definition associated with the property that caused the |
| | | * exception. |
| | | * |
| | | * @return Returns the property definition associated with the |
| | | * property that caused the exception. |
| | | * @return Returns the property definition associated with the property that |
| | | * caused the exception. |
| | | */ |
| | | public final PropertyDefinition<?> getPropertyDefinition() { |
| | | public final PropertyDefinition<?> getPropertyDefinition() |
| | | { |
| | | return pd; |
| | | } |
| | | |
| | |
| | | * property. |
| | | * <p> |
| | | * The default implementation of this method throws an |
| | | * {@link UnknownPropertyDefinitionException}. Sub-classes can |
| | | * {@link PropertyException}. Sub-classes can |
| | | * override this method with their own default behavior. |
| | | * |
| | | * @param <T> |
| | |
| | | * @param p |
| | | * A visitor specified parameter. |
| | | * @return Returns a visitor specified result. |
| | | * @throws UnknownPropertyDefinitionException |
| | | * @throws PropertyException |
| | | * Visitor implementations may optionally throw this |
| | | * exception. |
| | | */ |
| | | public <T> R visitUnknown(PropertyDefinition<T> pd, T v, P p) |
| | | throws UnknownPropertyDefinitionException { |
| | | throw new UnknownPropertyDefinitionException(pd, p); |
| | | throws PropertyException { |
| | | throw PropertyException.unknownPropertyDefinitionException(pd, p); |
| | | } |
| | | |
| | | } |
| | |
| | | try { |
| | | T tvalue = pd.decodeValue(name); |
| | | return pd.normalizeValue(tvalue); |
| | | } catch (IllegalPropertyValueStringException e) { |
| | | } catch (PropertyException e) { |
| | | // Fall through to default normalization. |
| | | } |
| | | } |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void validateValue(Long value) throws IllegalPropertyValueException { |
| | | public void validateValue(Long value) throws PropertyException { |
| | | ifNull(value); |
| | | |
| | | if (!allowUnlimited && value < lowerLimit) { |
| | | throw new IllegalPropertyValueException(this, value); |
| | | throw PropertyException.illegalPropertyValueException(this, value); |
| | | |
| | | // unlimited allowed |
| | | } else if (value >= 0 && value < lowerLimit) { |
| | | throw new IllegalPropertyValueException(this, value); |
| | | throw PropertyException.illegalPropertyValueException(this, value); |
| | | } |
| | | |
| | | if ((upperLimit != null) && (value > upperLimit)) { |
| | | throw new IllegalPropertyValueException(this, value); |
| | | throw PropertyException.illegalPropertyValueException(this, value); |
| | | } |
| | | } |
| | | |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public String encodeValue(Long value) throws IllegalPropertyValueException { |
| | | public String encodeValue(Long value) throws PropertyException { |
| | | ifNull(value); |
| | | |
| | | // Make sure that we correctly encode negative values as "unlimited". |
| | |
| | | */ |
| | | @Override |
| | | public Long decodeValue(String value) |
| | | throws IllegalPropertyValueStringException { |
| | | throws PropertyException { |
| | | ifNull(value); |
| | | |
| | | // First check for the special "unlimited" value when necessary. |
| | |
| | | try { |
| | | i = SizeUnit.parseValue(value, SizeUnit.BYTES); |
| | | } catch (NumberFormatException e) { |
| | | throw new IllegalPropertyValueStringException(this, value); |
| | | throw PropertyException.illegalPropertyValueException(this, value); |
| | | } |
| | | |
| | | try { |
| | | validateValue(i); |
| | | } catch (IllegalPropertyValueException e) { |
| | | throw new IllegalPropertyValueStringException(this, value); |
| | | } catch (PropertyException e) { |
| | | throw PropertyException.illegalPropertyValueException(this, value); |
| | | } |
| | | return i; |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | public String decodeValue(String value) |
| | | throws IllegalPropertyValueStringException { |
| | | throws PropertyException { |
| | | ifNull(value); |
| | | |
| | | try { |
| | | validateValue(value); |
| | | } catch (IllegalPropertyValueException e) { |
| | | throw new IllegalPropertyValueStringException(this, value); |
| | | } catch (PropertyException e) { |
| | | throw PropertyException.illegalPropertyValueException(this, value); |
| | | } |
| | | |
| | | return value; |
| | |
| | | */ |
| | | @Override |
| | | public String normalizeValue(String value) |
| | | throws IllegalPropertyValueException { |
| | | throws PropertyException { |
| | | ifNull(value); |
| | | |
| | | if (isCaseInsensitive()) { |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void validateValue(String value) throws IllegalPropertyValueException { |
| | | public void validateValue(String value) throws PropertyException { |
| | | ifNull(value); |
| | | |
| | | if (pattern != null) { |
| | | Matcher matcher = pattern.matcher(value); |
| | | if (!matcher.matches()) { |
| | | throw new IllegalPropertyValueException(this, value); |
| | | throw PropertyException.illegalPropertyValueException(this, value); |
| | | } |
| | | } |
| | | } |
| | |
| | | import static org.opends.messages.AdminMessages.*; |
| | | |
| | | import org.opends.messages.Message; |
| | | import org.opends.server.admin.IllegalPropertyValueStringException; |
| | | import org.opends.server.admin.PropertyException; |
| | | import org.opends.server.admin.OperationsException; |
| | | import org.opends.server.admin.PropertyDefinition; |
| | | import org.opends.server.admin.PropertyDefinitionUsageBuilder; |
| | |
| | | } else if (namingPropertyDefinition != null) { |
| | | try { |
| | | namingPropertyDefinition.decodeValue(illegalName); |
| | | } catch (IllegalPropertyValueStringException e) { |
| | | } catch (PropertyException e) { |
| | | PropertyDefinitionUsageBuilder builder = |
| | | new PropertyDefinitionUsageBuilder(true); |
| | | return ERR_ILLEGAL_MANAGED_OBJECT_NAME_EXCEPTION_SYNTAX.get( |
| | |
| | | |
| | | import org.opends.server.admin.AbstractManagedObjectDefinition; |
| | | import org.opends.server.admin.Configuration; |
| | | import org.opends.server.admin.DefaultBehaviorException; |
| | | import org.opends.server.admin.PropertyException; |
| | | import org.opends.server.admin.DefinitionDecodingException; |
| | | import org.opends.server.admin.IllegalPropertyValueException; |
| | | import org.opends.server.admin.InstantiableRelationDefinition; |
| | | import org.opends.server.admin.ManagedObjectAlreadyExistsException; |
| | | import org.opends.server.admin.ManagedObjectDefinition; |
| | |
| | | import org.opends.server.admin.ManagedObjectPath; |
| | | import org.opends.server.admin.OptionalRelationDefinition; |
| | | import org.opends.server.admin.PropertyDefinition; |
| | | import org.opends.server.admin.PropertyIsMandatoryException; |
| | | import org.opends.server.admin.PropertyIsReadOnlyException; |
| | | import org.opends.server.admin.PropertyIsSingleValuedException; |
| | | import org.opends.server.admin.PropertyProvider; |
| | | import org.opends.server.admin.SetRelationDefinition; |
| | | import org.opends.server.admin.SingletonRelationDefinition; |
| | |
| | | * The name of the child managed object. |
| | | * @param exceptions |
| | | * A collection in which to place any |
| | | * {@link DefaultBehaviorException}s that occurred whilst |
| | | * {@link PropertyException}s that occurred whilst |
| | | * attempting to determine the managed object's default |
| | | * values. |
| | | * @return Returns a new child managed object bound to the specified |
| | |
| | | <C extends ConfigurationClient, S extends Configuration, CC extends C> |
| | | ManagedObject<CC> createChild(InstantiableRelationDefinition<C, S> r, |
| | | ManagedObjectDefinition<CC, ? extends S> d, String name, |
| | | Collection<DefaultBehaviorException> exceptions) |
| | | Collection<PropertyException> exceptions) |
| | | throws IllegalManagedObjectNameException, IllegalArgumentException; |
| | | |
| | | |
| | |
| | | * The definition of the managed object to be created. |
| | | * @param exceptions |
| | | * A collection in which to place any |
| | | * {@link DefaultBehaviorException}s that occurred whilst |
| | | * {@link PropertyException}s that occurred whilst |
| | | * attempting to determine the managed object's default |
| | | * values. |
| | | * @return Returns a new child managed object bound to the specified |
| | |
| | | <C extends ConfigurationClient, S extends Configuration, CC extends C> |
| | | ManagedObject<CC> createChild(OptionalRelationDefinition<C, S> r, |
| | | ManagedObjectDefinition<CC, ? extends S> d, |
| | | Collection<DefaultBehaviorException> exceptions) |
| | | Collection<PropertyException> exceptions) |
| | | throws IllegalArgumentException; |
| | | |
| | | |
| | |
| | | * The definition of the managed object to be created. |
| | | * @param exceptions |
| | | * A collection in which to place any |
| | | * {@link DefaultBehaviorException}s that occurred whilst |
| | | * {@link PropertyException}s that occurred whilst |
| | | * attempting to determine the managed object's default |
| | | * values. |
| | | * @return Returns a new child managed object bound to the specified |
| | |
| | | <C extends ConfigurationClient, S extends Configuration, CC extends C> |
| | | ManagedObject<CC> createChild(SetRelationDefinition<C, S> r, |
| | | ManagedObjectDefinition<CC, ? extends S> d, |
| | | Collection<DefaultBehaviorException> exceptions) |
| | | Collection<PropertyException> exceptions) |
| | | throws IllegalArgumentException; |
| | | |
| | | |
| | |
| | | /** |
| | | * Sets a new pending value for the specified property. |
| | | * <p> |
| | | * See the class description for more information regarding pending |
| | | * values. |
| | | * See the class description for more information regarding pending values. |
| | | * |
| | | * @param <PD> |
| | | * The type of the property to be modified. |
| | | * @param pd |
| | | * The property to be modified. |
| | | * @param value |
| | | * The new pending value for the property, or |
| | | * <code>null</code> if the property should be reset to |
| | | * its default behavior. |
| | | * @throws IllegalPropertyValueException |
| | | * If the new pending value is deemed to be invalid |
| | | * according to the property definition. |
| | | * @throws PropertyIsReadOnlyException |
| | | * If this is not a new managed object and the property is |
| | | * read-only or for monitoring purposes. |
| | | * @throws PropertyIsMandatoryException |
| | | * If an attempt was made to remove a mandatory property. |
| | | * The new pending value for the property, or <code>null</code> if |
| | | * the property should be reset to its default behavior. |
| | | * @throws PropertyException |
| | | * If the new pending value is deemed to be invalid according to the |
| | | * property definition, or if this is not a new managed object and |
| | | * the property is read-only or for monitoring purposes, or if an |
| | | * attempt was made to remove a mandatory property. |
| | | * @throws IllegalArgumentException |
| | | * If the specified property definition is not associated |
| | | * with this managed object. |
| | | * If the specified property definition is not associated with this |
| | | * managed object. |
| | | */ |
| | | <PD> void setPropertyValue(PropertyDefinition<PD> pd, PD value) |
| | | throws IllegalPropertyValueException, PropertyIsReadOnlyException, |
| | | PropertyIsMandatoryException, IllegalArgumentException; |
| | | throws PropertyException, IllegalArgumentException; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Sets a new pending values for the specified property. |
| | | * <p> |
| | | * See the class description for more information regarding pending |
| | | * values. |
| | | * See the class description for more information regarding pending values. |
| | | * |
| | | * @param <PD> |
| | | * The type of the property to be modified. |
| | | * @param pd |
| | | * The property to be modified. |
| | | * @param values |
| | | * A non-<code>null</code> set of new pending values for |
| | | * the property (an empty set indicates that the property |
| | | * should be reset to its default behavior). The set will |
| | | * not be referenced by this managed object. |
| | | * @throws IllegalPropertyValueException |
| | | * If a new pending value is deemed to be invalid |
| | | * according to the property definition. |
| | | * @throws PropertyIsSingleValuedException |
| | | * If an attempt was made to add multiple pending values |
| | | * to a single-valued property. |
| | | * @throws PropertyIsReadOnlyException |
| | | * If this is not a new managed object and the property is |
| | | * read-only or for monitoring purposes. |
| | | * @throws PropertyIsMandatoryException |
| | | * If an attempt was made to remove a mandatory property. |
| | | * A non-<code>null</code> set of new pending values for the property |
| | | * (an empty set indicates that the property should be reset to its |
| | | * default behavior). The set will not be referenced by this managed |
| | | * object. |
| | | * @throws PropertyException |
| | | * If a new pending value is deemed to be invalid according to the |
| | | * property definition, or if an attempt was made to add multiple |
| | | * pending values to a single-valued property, or if this is not a |
| | | * new managed object and the property is read-only or for |
| | | * monitoring purposes, or if an attempt was made to remove a |
| | | * mandatory property. |
| | | * @throws IllegalArgumentException |
| | | * If the specified property definition is not associated |
| | | * with this managed object. |
| | | * If the specified property definition is not associated with this |
| | | * managed object. |
| | | */ |
| | | <PD> void setPropertyValues(PropertyDefinition<PD> pd, Collection<PD> values) |
| | | throws IllegalPropertyValueException, PropertyIsSingleValuedException, |
| | | PropertyIsReadOnlyException, PropertyIsMandatoryException, |
| | | IllegalArgumentException; |
| | | throws PropertyException, IllegalArgumentException; |
| | | |
| | | } |
| | |
| | | import org.opends.messages.Message; |
| | | import org.opends.messages.MessageBuilder; |
| | | import org.opends.server.admin.OperationsException; |
| | | import org.opends.server.admin.PropertyIsMandatoryException; |
| | | import org.opends.server.admin.PropertyException; |
| | | import org.forgerock.util.Reject; |
| | | |
| | | |
| | |
| | | |
| | | |
| | | // Create the message. |
| | | private static Message createMessage( |
| | | Collection<PropertyIsMandatoryException> causes) { |
| | | private static Message createMessage(Collection<PropertyException> causes) |
| | | { |
| | | Reject.ifNull(causes); |
| | | Reject.ifFalse(!causes.isEmpty()); |
| | | |
| | |
| | | MessageBuilder builder = new MessageBuilder(); |
| | | |
| | | boolean isFirst = true; |
| | | for (PropertyIsMandatoryException cause : causes) { |
| | | for (PropertyException cause : causes) { |
| | | if (!isFirst) { |
| | | builder.append(", "); |
| | | } |
| | |
| | | } |
| | | |
| | | // The causes of this exception. |
| | | private final Collection<PropertyIsMandatoryException> causes; |
| | | private final Collection<PropertyException> causes; |
| | | |
| | | // Indicates whether the exception occurred during managed object |
| | | // creation. |
| | |
| | | * object creation. |
| | | */ |
| | | public MissingMandatoryPropertiesException(Message ufn, |
| | | Collection<PropertyIsMandatoryException> causes, boolean isCreate) { |
| | | Collection<PropertyException> causes, boolean isCreate) { |
| | | super(createMessage(causes)); |
| | | |
| | | this.causes = new ArrayList<PropertyIsMandatoryException>(causes); |
| | | this.causes = new ArrayList<PropertyException>(causes); |
| | | this.ufn = ufn; |
| | | this.isCreate = isCreate; |
| | | } |
| | |
| | | * @return Returns the first exception that caused this exception. |
| | | */ |
| | | @Override |
| | | public PropertyIsMandatoryException getCause() { |
| | | public PropertyException getCause() { |
| | | return causes.iterator().next(); |
| | | } |
| | | |
| | |
| | | * @return Returns an unmodifiable collection view of the causes of |
| | | * this exception. |
| | | */ |
| | | public Collection<PropertyIsMandatoryException> getCauses() { |
| | | public Collection<PropertyException> getCauses() { |
| | | return Collections.unmodifiableCollection(causes); |
| | | } |
| | | |
| | |
| | | import org.opends.server.admin.AggregationPropertyDefinition; |
| | | import org.opends.server.admin.Configuration; |
| | | import org.opends.server.admin.ConfigurationClient; |
| | | import org.opends.server.admin.DefaultBehaviorException; |
| | | import org.opends.server.admin.PropertyException; |
| | | import org.opends.server.admin.DefinitionDecodingException; |
| | | import org.opends.server.admin.DefinitionResolver; |
| | | import org.opends.server.admin.IllegalPropertyValueStringException; |
| | | import org.opends.server.admin.InstantiableRelationDefinition; |
| | | import org.opends.server.admin.LDAPProfile; |
| | | import org.opends.server.admin.ManagedObjectDefinition; |
| | |
| | | import org.opends.server.admin.ManagedObjectPath; |
| | | import org.opends.server.admin.PropertyDefinition; |
| | | import org.opends.server.admin.PropertyDefinitionVisitor; |
| | | import org.opends.server.admin.PropertyException; |
| | | import org.opends.server.admin.PropertyIsMandatoryException; |
| | | import org.opends.server.admin.PropertyIsSingleValuedException; |
| | | import org.opends.server.admin.PropertyOption; |
| | | import org.opends.server.admin.Reference; |
| | | import org.opends.server.admin.RelationDefinition; |
| | | import org.opends.server.admin.SetRelationDefinition; |
| | | import org.opends.server.admin.UnknownPropertyDefinitionException; |
| | | import org.opends.server.admin.DefinitionDecodingException.Reason; |
| | | import org.opends.server.admin.client.AuthorizationException; |
| | | import org.opends.server.admin.client.CommunicationException; |
| | |
| | | * @param value |
| | | * The LDAP string representation. |
| | | * @return Returns the decoded LDAP value. |
| | | * @throws IllegalPropertyValueStringException |
| | | * @throws PropertyException |
| | | * If the property value could not be decoded because it |
| | | * was invalid. |
| | | */ |
| | | public static <PD> PD decode(PropertyDefinition<PD> pd, Object value) |
| | | throws IllegalPropertyValueStringException { |
| | | throws PropertyException { |
| | | String s = String.valueOf(value); |
| | | return pd.castValue(pd.accept(new ValueDecoder(), s)); |
| | | } |
| | |
| | | .getRelationDefinition(), p); |
| | | return reference.getName(); |
| | | } catch (IllegalArgumentException e) { |
| | | throw new IllegalPropertyValueStringException(d, p); |
| | | throw PropertyException.illegalPropertyValueException(d, p); |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public <T> Object visitUnknown(PropertyDefinition<T> d, String p) |
| | | throws UnknownPropertyDefinitionException { |
| | | throws PropertyException { |
| | | // By default the property definition's decoder will do. |
| | | return d.decodeValue(p); |
| | | } |
| | |
| | | |
| | | // Sanity check the returned values. |
| | | if (values.size() > 1 && !pd.hasOption(PropertyOption.MULTI_VALUED)) { |
| | | throw new PropertyIsSingleValuedException(pd); |
| | | throw PropertyException.propertyIsSingleValuedException(pd); |
| | | } |
| | | |
| | | if (values.isEmpty() && pd.hasOption(PropertyOption.MANDATORY)) { |
| | | throw new PropertyIsMandatoryException(pd); |
| | | throw PropertyException.propertyIsMandatoryException(pd); |
| | | } |
| | | |
| | | if (values.isEmpty()) { |
| | |
| | | |
| | | if (activeValues.size() > 1 && !pd.hasOption(PropertyOption.MULTI_VALUED)) { |
| | | // This exception takes precedence over previous exceptions. |
| | | exception = new PropertyIsSingleValuedException(pd); |
| | | exception = PropertyException.propertyIsSingleValuedException(pd); |
| | | PD value = activeValues.first(); |
| | | activeValues.clear(); |
| | | activeValues.add(value); |
| | |
| | | Collection<PD> defaultValues; |
| | | try { |
| | | defaultValues = findDefaultValues(p, pd, false); |
| | | } catch (DefaultBehaviorException e) { |
| | | } catch (PropertyException e) { |
| | | defaultValues = Collections.emptySet(); |
| | | exception = e; |
| | | } |
| | |
| | | // The active values maybe empty because of a previous |
| | | // exception. |
| | | if (exception == null) { |
| | | exception = new PropertyIsMandatoryException(pd); |
| | | exception = PropertyException.propertyIsMandatoryException(pd); |
| | | } |
| | | } |
| | | |
| | |
| | | import org.opends.server.admin.Reference; |
| | | import org.opends.server.admin.RelationDefinition; |
| | | import org.opends.server.admin.SetRelationDefinition; |
| | | import org.opends.server.admin.UnknownPropertyDefinitionException; |
| | | import org.opends.server.admin.PropertyException; |
| | | import org.opends.server.admin.client.AuthorizationException; |
| | | import org.opends.server.admin.client.CommunicationException; |
| | | import org.opends.server.admin.client.ConcurrentModificationException; |
| | |
| | | */ |
| | | @Override |
| | | public <PD> Object visitUnknown(PropertyDefinition<PD> pd, PD v, Void p) |
| | | throws UnknownPropertyDefinitionException { |
| | | throws PropertyException { |
| | | return pd.encodeValue(v); |
| | | } |
| | | } |
| | |
| | | import org.opends.server.admin.Configuration; |
| | | import org.opends.server.admin.ConfigurationClient; |
| | | import org.opends.server.admin.Constraint; |
| | | import org.opends.server.admin.DefaultBehaviorException; |
| | | import org.opends.server.admin.PropertyException; |
| | | import org.opends.server.admin.DefaultManagedObject; |
| | | import org.opends.server.admin.DefinitionDecodingException; |
| | | import org.opends.server.admin.IllegalPropertyValueException; |
| | | import org.opends.server.admin.IllegalPropertyValueStringException; |
| | | import org.opends.server.admin.InstantiableRelationDefinition; |
| | | import org.opends.server.admin.ManagedObjectAlreadyExistsException; |
| | | import org.opends.server.admin.ManagedObjectDefinition; |
| | |
| | | import org.opends.server.admin.ManagedObjectPath; |
| | | import org.opends.server.admin.OptionalRelationDefinition; |
| | | import org.opends.server.admin.PropertyDefinition; |
| | | import org.opends.server.admin.PropertyIsMandatoryException; |
| | | import org.opends.server.admin.PropertyIsReadOnlyException; |
| | | import org.opends.server.admin.PropertyIsSingleValuedException; |
| | | import org.opends.server.admin.PropertyOption; |
| | | import org.opends.server.admin.RelationDefinition; |
| | | import org.opends.server.admin.RelationDefinitionVisitor; |
| | |
| | | OperationRejectedException, AuthorizationException, |
| | | CommunicationException { |
| | | // First make sure all mandatory properties are defined. |
| | | List<PropertyIsMandatoryException> exceptions = |
| | | new LinkedList<PropertyIsMandatoryException>(); |
| | | List<PropertyException> exceptions = new LinkedList<PropertyException>(); |
| | | |
| | | for (PropertyDefinition<?> pd : definition.getAllPropertyDefinitions()) { |
| | | Property<?> p = getProperty(pd); |
| | | if (pd.hasOption(PropertyOption.MANDATORY) |
| | | && p.getEffectiveValues().isEmpty()) { |
| | | exceptions.add(new PropertyIsMandatoryException(pd)); |
| | | exceptions.add(PropertyException.propertyIsMandatoryException(pd)); |
| | | } |
| | | } |
| | | |
| | |
| | | ManagedObject<CC> createChild( |
| | | InstantiableRelationDefinition<C, S> r, |
| | | ManagedObjectDefinition<CC, ? extends S> d, String name, |
| | | Collection<DefaultBehaviorException> exceptions) |
| | | Collection<PropertyException> exceptions) |
| | | throws IllegalManagedObjectNameException, IllegalArgumentException { |
| | | validateRelationDefinition(r); |
| | | |
| | |
| | | if (pd != null) { |
| | | try { |
| | | pd.decodeValue(name); |
| | | } catch (IllegalPropertyValueStringException e) { |
| | | } catch (PropertyException e) { |
| | | throw new IllegalManagedObjectNameException(name, pd); |
| | | } |
| | | } |
| | |
| | | ManagedObject<CC> createChild( |
| | | OptionalRelationDefinition<C, S> r, |
| | | ManagedObjectDefinition<CC, ? extends S> d, |
| | | Collection<DefaultBehaviorException> exceptions) |
| | | Collection<PropertyException> exceptions) |
| | | throws IllegalArgumentException { |
| | | validateRelationDefinition(r); |
| | | ManagedObjectPath<CC, ? extends S> childPath = path.child(r, d); |
| | |
| | | ManagedObject<CC> createChild( |
| | | SetRelationDefinition<C, S> r, |
| | | ManagedObjectDefinition<CC, ? extends S> d, |
| | | Collection<DefaultBehaviorException> exceptions) |
| | | Collection<PropertyException> exceptions) |
| | | throws IllegalArgumentException { |
| | | validateRelationDefinition(r); |
| | | |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | public final <PD> void setPropertyValue(PropertyDefinition<PD> pd, PD value) |
| | | throws IllegalPropertyValueException, PropertyIsReadOnlyException, |
| | | PropertyIsMandatoryException, IllegalArgumentException { |
| | | throws PropertyException, PropertyException, |
| | | PropertyException, IllegalArgumentException { |
| | | if (value == null) { |
| | | setPropertyValues(pd, Collections.<PD> emptySet()); |
| | | } else { |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | public final <PD> void setPropertyValues(PropertyDefinition<PD> pd, |
| | | Collection<PD> values) throws IllegalPropertyValueException, |
| | | PropertyIsSingleValuedException, PropertyIsReadOnlyException, |
| | | PropertyIsMandatoryException, IllegalArgumentException { |
| | | Collection<PD> values) throws PropertyException, |
| | | PropertyException, PropertyException, |
| | | PropertyException, IllegalArgumentException { |
| | | if (pd.hasOption(PropertyOption.MONITORING)) { |
| | | throw new PropertyIsReadOnlyException(pd); |
| | | throw PropertyException.propertyIsReadOnlyException(pd); |
| | | } |
| | | |
| | | if (existsOnServer && pd.hasOption(PropertyOption.READ_ONLY)) { |
| | | throw new PropertyIsReadOnlyException(pd); |
| | | throw PropertyException.propertyIsReadOnlyException(pd); |
| | | } |
| | | |
| | | properties.setPropertyValues(pd, values); |
| | |
| | | createNewManagedObject( |
| | | ManagedObjectDefinition<M, ?> d, ManagedObjectPath<M, ?> p, |
| | | PropertyDefinition<PD> namingPropertyDefinition, String name, |
| | | Collection<DefaultBehaviorException> exceptions) { |
| | | Collection<PropertyException> exceptions) { |
| | | PropertySet childProperties = new PropertySet(); |
| | | for (PropertyDefinition<?> pd : d.getAllPropertyDefinitions()) { |
| | | try { |
| | | createProperty(childProperties, p, pd); |
| | | } catch (DefaultBehaviorException e) { |
| | | } catch (PropertyException e) { |
| | | // Add the exception if requested. |
| | | if (exceptions != null) { |
| | | exceptions.add(e); |
| | |
| | | // Create an empty property. |
| | | private <PD> void createProperty(PropertySet properties, |
| | | ManagedObjectPath<?, ?> p, PropertyDefinition<PD> pd) |
| | | throws DefaultBehaviorException { |
| | | throws PropertyException { |
| | | try { |
| | | Driver context = getDriver(); |
| | | Collection<PD> defaultValues = context.findDefaultValues(p, pd, true); |
| | | properties.addProperty(pd, defaultValues, Collections.<PD> emptySet()); |
| | | } catch (DefaultBehaviorException e) { |
| | | } catch (PropertyException e) { |
| | | // Make sure that we have still created the property. |
| | | properties.addProperty(pd, Collections.<PD> emptySet(), Collections |
| | | .<PD> emptySet()); |
| | |
| | | |
| | | |
| | | |
| | | import static org.opends.server.admin.PropertyException.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | |
| | | import org.opends.server.admin.Configuration; |
| | | import org.opends.server.admin.ConfigurationClient; |
| | | import org.opends.server.admin.Constraint; |
| | | import org.opends.server.admin.DefaultBehaviorException; |
| | | import org.opends.server.admin.PropertyException; |
| | | import org.opends.server.admin.DefaultBehaviorProviderVisitor; |
| | | import org.opends.server.admin.DefinedDefaultBehaviorProvider; |
| | | import org.opends.server.admin.DefinitionDecodingException; |
| | | import org.opends.server.admin.IllegalPropertyValueStringException; |
| | | import org.opends.server.admin.InstantiableRelationDefinition; |
| | | import org.opends.server.admin.ManagedObjectNotFoundException; |
| | | import org.opends.server.admin.ManagedObjectPath; |
| | | import org.opends.server.admin.OptionalRelationDefinition; |
| | | import org.opends.server.admin.PropertyDefinition; |
| | | import org.opends.server.admin.PropertyException; |
| | | import org.opends.server.admin.PropertyIsSingleValuedException; |
| | | import org.opends.server.admin.PropertyNotFoundException; |
| | | import org.opends.server.admin.PropertyOption; |
| | | import org.opends.server.admin.RelationDefinition; |
| | |
| | | |
| | | // Any exception that occurred whilst retrieving inherited default |
| | | // values. |
| | | private DefaultBehaviorException exception = null; |
| | | private PropertyException exception = null; |
| | | |
| | | // The path of the managed object containing the first property. |
| | | private final ManagedObjectPath<?, ?> firstPath; |
| | |
| | | try { |
| | | return getInheritedProperty(d.getManagedObjectPath(), d |
| | | .getManagedObjectDefinition(), d.getPropertyName()); |
| | | } catch (DefaultBehaviorException e) { |
| | | } catch (PropertyException e) { |
| | | exception = e; |
| | | return Collections.emptySet(); |
| | | } |
| | |
| | | for (String stringValue : stringValues) { |
| | | try { |
| | | values.add(nextProperty.decodeValue(stringValue)); |
| | | } catch (IllegalPropertyValueStringException e) { |
| | | exception = new DefaultBehaviorException(nextProperty, e); |
| | | } catch (PropertyException e) { |
| | | exception = defaultBehaviorException(nextProperty, e); |
| | | break; |
| | | } |
| | | } |
| | |
| | | try { |
| | | return getInheritedProperty(d.getManagedObjectPath(nextPath), d |
| | | .getManagedObjectDefinition(), d.getPropertyName()); |
| | | } catch (DefaultBehaviorException e) { |
| | | } catch (PropertyException e) { |
| | | exception = e; |
| | | return Collections.emptySet(); |
| | | } |
| | |
| | | |
| | | // Find the default values for the next path/property. |
| | | private Collection<T> find(ManagedObjectPath<?, ?> p, |
| | | PropertyDefinition<T> pd) throws DefaultBehaviorException { |
| | | PropertyDefinition<T> pd) throws PropertyException { |
| | | this.nextPath = p; |
| | | this.nextProperty = pd; |
| | | |
| | |
| | | } |
| | | |
| | | if (values.size() > 1 && !pd.hasOption(PropertyOption.MULTI_VALUED)) { |
| | | throw new DefaultBehaviorException(pd, |
| | | new PropertyIsSingleValuedException(pd)); |
| | | throw PropertyException.defaultBehaviorException(pd, |
| | | PropertyException.propertyIsSingleValuedException(pd)); |
| | | } |
| | | |
| | | return values; |
| | |
| | | @SuppressWarnings("unchecked") |
| | | private Collection<T> getInheritedProperty(ManagedObjectPath target, |
| | | AbstractManagedObjectDefinition<?, ?> d, String propertyName) |
| | | throws DefaultBehaviorException { |
| | | throws PropertyException { |
| | | // First check that the requested type of managed object |
| | | // corresponds to the path. |
| | | AbstractManagedObjectDefinition<?, ?> supr = target |
| | | .getManagedObjectDefinition(); |
| | | if (!supr.isParentOf(d)) { |
| | | throw new DefaultBehaviorException( |
| | | throw PropertyException.defaultBehaviorException( |
| | | nextProperty, new DefinitionDecodingException(supr, |
| | | Reason.WRONG_TYPE_INFORMATION)); |
| | | } |
| | |
| | | // inherits its defaults from the newly created managed object. |
| | | return getPropertyValues(target, pd2); |
| | | } |
| | | } catch (DefaultBehaviorException e) { |
| | | // Wrap any errors due to recursion. |
| | | throw new DefaultBehaviorException(pd1, e); |
| | | } catch (DefinitionDecodingException e) { |
| | | throw new DefaultBehaviorException(pd1, e); |
| | | } catch (PropertyNotFoundException e) { |
| | | throw new DefaultBehaviorException(pd1, e); |
| | | } catch (AuthorizationException e) { |
| | | throw new DefaultBehaviorException(pd1, e); |
| | | } catch (ManagedObjectNotFoundException e) { |
| | | throw new DefaultBehaviorException(pd1, e); |
| | | } catch (CommunicationException e) { |
| | | throw new DefaultBehaviorException(pd1, e); |
| | | } catch (PropertyException e) { |
| | | throw new DefaultBehaviorException(pd1, e); |
| | | // Wrap any errors due to recursion. |
| | | throw PropertyException.defaultBehaviorException(pd1, e); |
| | | } catch (DefinitionDecodingException e) { |
| | | throw PropertyException.defaultBehaviorException(pd1, e); |
| | | } catch (PropertyNotFoundException e) { |
| | | throw PropertyException.defaultBehaviorException(pd1, e); |
| | | } catch (AuthorizationException e) { |
| | | throw PropertyException.defaultBehaviorException(pd1, e); |
| | | } catch (ManagedObjectNotFoundException e) { |
| | | throw PropertyException.defaultBehaviorException(pd1, e); |
| | | } catch (CommunicationException e) { |
| | | throw PropertyException.defaultBehaviorException(pd1, e); |
| | | } |
| | | } |
| | | }; |
| | |
| | | * Indicates whether the managed object has been created |
| | | * yet. |
| | | * @return Returns the default values for the specified property. |
| | | * @throws DefaultBehaviorException |
| | | * @throws PropertyException |
| | | * If the default values could not be retrieved or decoded |
| | | * properly. |
| | | */ |
| | | protected final <PD> Collection<PD> findDefaultValues( |
| | | ManagedObjectPath<?, ?> p, PropertyDefinition<PD> pd, boolean isCreate) |
| | | throws DefaultBehaviorException { |
| | | throws PropertyException { |
| | | DefaultValueFinder<PD> v = new DefaultValueFinder<PD>(p, isCreate); |
| | | return v.find(p, pd); |
| | | } |
| | |
| | | import java.util.SortedSet; |
| | | import java.util.TreeSet; |
| | | |
| | | import org.opends.server.admin.IllegalPropertyValueException; |
| | | import org.opends.server.admin.PropertyException; |
| | | import org.opends.server.admin.PropertyDefinition; |
| | | import org.opends.server.admin.PropertyIsMandatoryException; |
| | | import org.opends.server.admin.PropertyIsSingleValuedException; |
| | | import org.opends.server.admin.PropertyOption; |
| | | |
| | | |
| | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * Makes all pending values active. |
| | | */ |
| | | void commit() { |
| | | for (MyProperty<?> p : properties.values()) { |
| | | void commit() |
| | | { |
| | | for (MyProperty<?> p : properties.values()) |
| | | { |
| | | p.commit(); |
| | | } |
| | | } |
| | |
| | | /** |
| | | * Set a new pending values for the specified property. |
| | | * <p> |
| | | * See the class description for more information regarding pending |
| | | * values. |
| | | * See the class description for more information regarding pending values. |
| | | * |
| | | * @param <T> |
| | | * The type of the property to be modified. |
| | | * @param d |
| | | * The property to be modified. |
| | | * @param values |
| | | * A non-<code>null</code> set of new pending values for |
| | | * the property (an empty set indicates that the property |
| | | * should be reset to its default behavior). The set will |
| | | * not be referenced by this managed object. |
| | | * @throws IllegalPropertyValueException |
| | | * If a new pending value is deemed to be invalid |
| | | * according to the property definition. |
| | | * @throws PropertyIsSingleValuedException |
| | | * If an attempt was made to add multiple pending values |
| | | * to a single-valued property. |
| | | * @throws PropertyIsMandatoryException |
| | | * If an attempt was made to remove a mandatory property. |
| | | * A non-<code>null</code> set of new pending values for the property |
| | | * (an empty set indicates that the property should be reset to its |
| | | * default behavior). The set will not be referenced by this managed |
| | | * object. |
| | | * @throws PropertyException |
| | | * If a new pending value is deemed to be invalid according to the |
| | | * property definition, or if an attempt was made to add multiple |
| | | * pending values to a single-valued property, or if an attempt was |
| | | * made to remove a mandatory property. |
| | | * @throws IllegalArgumentException |
| | | * If the specified property definition is not associated |
| | | * with this managed object. |
| | | * If the specified property definition is not associated with this |
| | | * managed object. |
| | | */ |
| | | <T> void setPropertyValues(PropertyDefinition<T> d, |
| | | Collection<T> values) throws IllegalPropertyValueException, |
| | | PropertyIsSingleValuedException, PropertyIsMandatoryException, |
| | | IllegalArgumentException { |
| | | <T> void setPropertyValues(PropertyDefinition<T> d, Collection<T> values) |
| | | throws PropertyException, IllegalArgumentException |
| | | { |
| | | MyProperty<T> property = (MyProperty<T>) getProperty(d); |
| | | |
| | | if (values.size() > 1 && !d.hasOption(PropertyOption.MULTI_VALUED)) { |
| | | throw new PropertyIsSingleValuedException(d); |
| | | throw PropertyException.propertyIsSingleValuedException(d); |
| | | } |
| | | |
| | | if (values.isEmpty() && d.hasOption(PropertyOption.MANDATORY)) { |
| | | // But only if there are no default values. |
| | | if (property.getDefaultValues().isEmpty()) { |
| | | throw new PropertyIsMandatoryException(d); |
| | | throw PropertyException.propertyIsMandatoryException(d); |
| | | } |
| | | } |
| | | |
| | |
| | | import java.util.SortedSet; |
| | | |
| | | import org.opends.server.admin.AbstractManagedObjectDefinition; |
| | | import org.opends.server.admin.IllegalPropertyValueStringException; |
| | | import org.opends.server.admin.PropertyException; |
| | | import org.opends.server.admin.PropertyDefinition; |
| | | import org.opends.server.admin.client.AuthorizationException; |
| | | import org.opends.server.admin.client.CommunicationException; |
| | |
| | | |
| | | // Private constructor. |
| | | private Impl(PropertyDefinition<T> pd, T value) |
| | | throws IllegalPropertyValueStringException { |
| | | throws PropertyException { |
| | | this.pd = pd; |
| | | this.value = value; |
| | | } |
| | |
| | | |
| | | // Creates the new private implementation. |
| | | private <T> void buildImpl(PropertyDefinition<T> pd) |
| | | throws IllegalPropertyValueStringException { |
| | | throws PropertyException { |
| | | T value = pd.decodeValue(propertyStringValue); |
| | | this.impl = new Impl<T>(pd, value); |
| | | } |
| | |
| | | |
| | | |
| | | import static org.opends.messages.AdminMessages.*; |
| | | import static org.opends.server.admin.PropertyException.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | |
| | | import org.opends.server.admin.AliasDefaultBehaviorProvider; |
| | | import org.opends.server.admin.Configuration; |
| | | import org.opends.server.admin.ConfigurationClient; |
| | | import org.opends.server.admin.DefaultBehaviorException; |
| | | import org.opends.server.admin.PropertyException; |
| | | import org.opends.server.admin.DefaultBehaviorProviderVisitor; |
| | | import org.opends.server.admin.DefinedDefaultBehaviorProvider; |
| | | import org.opends.server.admin.DefinitionDecodingException; |
| | | import org.opends.server.admin.DefinitionResolver; |
| | | import org.opends.server.admin.IllegalPropertyValueException; |
| | | import org.opends.server.admin.IllegalPropertyValueStringException; |
| | | import org.opends.server.admin.InstantiableRelationDefinition; |
| | | import org.opends.server.admin.LDAPProfile; |
| | | import org.opends.server.admin.ManagedObjectDefinition; |
| | | import org.opends.server.admin.ManagedObjectPath; |
| | | import org.opends.server.admin.PropertyDefinition; |
| | | import org.opends.server.admin.PropertyDefinitionVisitor; |
| | | import org.opends.server.admin.PropertyException; |
| | | import org.opends.server.admin.PropertyIsMandatoryException; |
| | | import org.opends.server.admin.PropertyIsSingleValuedException; |
| | | import org.opends.server.admin.PropertyNotFoundException; |
| | | import org.opends.server.admin.PropertyOption; |
| | | import org.opends.server.admin.Reference; |
| | |
| | | import org.opends.server.admin.RelativeInheritedDefaultBehaviorProvider; |
| | | import org.opends.server.admin.SetRelationDefinition; |
| | | import org.opends.server.admin.UndefinedDefaultBehaviorProvider; |
| | | import org.opends.server.admin.UnknownPropertyDefinitionException; |
| | | import org.opends.server.admin.DefinitionDecodingException.Reason; |
| | | import org.opends.server.admin.std.meta.RootCfgDefn; |
| | | import org.opends.server.admin.std.server.RootCfg; |
| | |
| | | |
| | | // Any exception that occurred whilst retrieving inherited default |
| | | // values. |
| | | private DefaultBehaviorException exception = null; |
| | | private PropertyException exception = null; |
| | | |
| | | // Optional new configuration entry which does not yet exist in |
| | | // the configuration back-end. |
| | |
| | | try { |
| | | return getInheritedProperty(d.getManagedObjectPath(), d |
| | | .getManagedObjectDefinition(), d.getPropertyName()); |
| | | } catch (DefaultBehaviorException e) { |
| | | } catch (PropertyException e) { |
| | | exception = e; |
| | | return Collections.emptySet(); |
| | | } |
| | |
| | | for (String stringValue : stringValues) { |
| | | try { |
| | | values.add(nextProperty.decodeValue(stringValue)); |
| | | } catch (IllegalPropertyValueStringException e) { |
| | | exception = new DefaultBehaviorException(nextProperty, e); |
| | | } catch (PropertyException e) { |
| | | exception = defaultBehaviorException(nextProperty, e); |
| | | break; |
| | | } |
| | | } |
| | |
| | | try { |
| | | return getInheritedProperty(d.getManagedObjectPath(nextPath), d |
| | | .getManagedObjectDefinition(), d.getPropertyName()); |
| | | } catch (DefaultBehaviorException e) { |
| | | } catch (PropertyException e) { |
| | | exception = e; |
| | | return Collections.emptySet(); |
| | | } |
| | |
| | | |
| | | // Find the default values for the next path/property. |
| | | private Collection<T> find(ManagedObjectPath<?, ?> p, |
| | | PropertyDefinition<T> pd) throws DefaultBehaviorException { |
| | | PropertyDefinition<T> pd) throws PropertyException { |
| | | nextPath = p; |
| | | nextProperty = pd; |
| | | |
| | |
| | | } |
| | | |
| | | if (values.size() > 1 && !pd.hasOption(PropertyOption.MULTI_VALUED)) { |
| | | throw new DefaultBehaviorException(pd, |
| | | new PropertyIsSingleValuedException(pd)); |
| | | throw PropertyException.defaultBehaviorException(pd, |
| | | PropertyException.propertyIsSingleValuedException(pd)); |
| | | } |
| | | |
| | | return values; |
| | |
| | | @SuppressWarnings("unchecked") |
| | | private Collection<T> getInheritedProperty(ManagedObjectPath target, |
| | | AbstractManagedObjectDefinition<?, ?> d, String propertyName) |
| | | throws DefaultBehaviorException { |
| | | throws PropertyException { |
| | | // First check that the requested type of managed object |
| | | // corresponds to the path. |
| | | AbstractManagedObjectDefinition<?, ?> supr = target |
| | | .getManagedObjectDefinition(); |
| | | if (!supr.isParentOf(d)) { |
| | | throw new DefaultBehaviorException( |
| | | throw PropertyException.defaultBehaviorException( |
| | | nextProperty, new DefinitionDecodingException(supr, |
| | | Reason.WRONG_TYPE_INFORMATION)); |
| | | } |
| | |
| | | return pvalues; |
| | | } |
| | | } catch (DefinitionDecodingException e) { |
| | | throw new DefaultBehaviorException(pd1, e); |
| | | throw PropertyException.defaultBehaviorException(pd1, e); |
| | | } catch (PropertyNotFoundException e) { |
| | | throw new DefaultBehaviorException(pd1, e); |
| | | } catch (IllegalPropertyValueException e) { |
| | | throw new DefaultBehaviorException(pd1, e); |
| | | } catch (IllegalPropertyValueStringException e) { |
| | | throw new DefaultBehaviorException(pd1, e); |
| | | throw PropertyException.defaultBehaviorException(pd1, e); |
| | | } catch (PropertyException e) { |
| | | throw PropertyException.defaultBehaviorException(pd1, e); |
| | | } catch (ConfigException e) { |
| | | throw new DefaultBehaviorException(pd1, e); |
| | | throw PropertyException.defaultBehaviorException(pd1, e); |
| | | } |
| | | } |
| | | } |
| | |
| | | * @param value |
| | | * The LDAP string representation. |
| | | * @return Returns the decoded LDAP value. |
| | | * @throws IllegalPropertyValueStringException |
| | | * @throws PropertyException |
| | | * If the property value could not be decoded because it |
| | | * was invalid. |
| | | */ |
| | | public static <PD> PD decode(PropertyDefinition<PD> pd, |
| | | AttributeValue value) throws IllegalPropertyValueStringException { |
| | | AttributeValue value) throws PropertyException { |
| | | String s = value.getValue().toString(); |
| | | return pd.castValue(pd.accept(new ValueDecoder(), s)); |
| | | } |
| | |
| | | .getRelationDefinition(), p); |
| | | return reference.getName(); |
| | | } catch (IllegalArgumentException e) { |
| | | throw new IllegalPropertyValueStringException(d, p); |
| | | throw PropertyException.illegalPropertyValueException(d, p); |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public <T> Object visitUnknown(PropertyDefinition<T> d, String p) |
| | | throws UnknownPropertyDefinitionException { |
| | | throws PropertyException { |
| | | // By default the property definition's decoder will do. |
| | | return d.decodeValue(p); |
| | | } |
| | |
| | | for (AttributeValue value : values) { |
| | | try { |
| | | pvalues.add(ValueDecoder.decode(pd, value)); |
| | | } catch (IllegalPropertyValueStringException e) { |
| | | } catch (PropertyException e) { |
| | | exception = e; |
| | | } |
| | | } |
| | |
| | | // No values defined so get the defaults. |
| | | try { |
| | | pvalues.addAll(getDefaultValues(path, pd, newConfigEntry)); |
| | | } catch (DefaultBehaviorException e) { |
| | | } catch (PropertyException e) { |
| | | exception = e; |
| | | } |
| | | } |
| | | |
| | | if (pvalues.size() > 1 && !pd.hasOption(PropertyOption.MULTI_VALUED)) { |
| | | // This exception takes precedence over previous exceptions. |
| | | exception = new PropertyIsSingleValuedException(pd); |
| | | exception = PropertyException.propertyIsSingleValuedException(pd); |
| | | T value = pvalues.first(); |
| | | pvalues.clear(); |
| | | pvalues.add(value); |
| | |
| | | if (pvalues.isEmpty() && pd.hasOption(PropertyOption.MANDATORY)) { |
| | | // The values maybe empty because of a previous exception. |
| | | if (exception == null) { |
| | | exception = new PropertyIsMandatoryException(pd); |
| | | exception = PropertyException.propertyIsMandatoryException(pd); |
| | | } |
| | | } |
| | | |
| | |
| | | // Get the default values for the specified property. |
| | | private <T> Collection<T> getDefaultValues(ManagedObjectPath<?, ?> p, |
| | | PropertyDefinition<T> pd, ConfigEntry newConfigEntry) |
| | | throws DefaultBehaviorException { |
| | | throws PropertyException { |
| | | DefaultValueFinder<T> v = new DefaultValueFinder<T>(newConfigEntry); |
| | | return v.find(p, pd); |
| | | } |
| | |
| | | |
| | | import org.opends.messages.Message; |
| | | import org.opends.server.admin.AbstractManagedObjectDefinition; |
| | | import org.opends.server.admin.DefaultBehaviorException; |
| | | import org.opends.server.admin.IllegalPropertyValueException; |
| | | import org.opends.server.admin.IllegalPropertyValueStringException; |
| | | import org.opends.server.admin.PropertyException; |
| | | import org.opends.server.admin.ManagedObjectDefinition; |
| | | import org.opends.server.admin.PropertyDefinition; |
| | | import org.opends.server.admin.PropertyDefinitionUsageBuilder; |
| | | import org.opends.server.admin.PropertyException; |
| | | import org.opends.server.admin.PropertyIsMandatoryException; |
| | | import org.opends.server.admin.PropertyIsReadOnlyException; |
| | | import org.opends.server.admin.PropertyIsSingleValuedException; |
| | | import org.opends.server.admin.RelationDefinition; |
| | | import org.opends.server.admin.client.IllegalManagedObjectNameException; |
| | | import org.opends.server.admin.client.ManagedObjectDecodingException; |
| | |
| | | } else if (pd != null) { |
| | | try { |
| | | pd.decodeValue(illegalName); |
| | | } catch (IllegalPropertyValueStringException e1) { |
| | | } catch (PropertyException e1) { |
| | | PropertyDefinitionUsageBuilder b = new PropertyDefinitionUsageBuilder( |
| | | true); |
| | | Message syntax = b.getUsage(pd); |
| | |
| | | */ |
| | | public static ArgumentException adaptPropertyException(PropertyException e, |
| | | AbstractManagedObjectDefinition<?, ?> d) { |
| | | if (e instanceof IllegalPropertyValueException) { |
| | | IllegalPropertyValueException pe = (IllegalPropertyValueException) e; |
| | | return adapt(d, pe); |
| | | } else if (e instanceof IllegalPropertyValueStringException) { |
| | | IllegalPropertyValueStringException pe = |
| | | (IllegalPropertyValueStringException) e; |
| | | return adapt(d, pe); |
| | | } else if (e instanceof PropertyIsMandatoryException) { |
| | | PropertyIsMandatoryException pe = (PropertyIsMandatoryException) e; |
| | | return adapt(d, pe); |
| | | } else if (e instanceof PropertyIsSingleValuedException) { |
| | | PropertyIsSingleValuedException pe = (PropertyIsSingleValuedException) e; |
| | | return adapt(d, pe); |
| | | } else if (e instanceof PropertyIsReadOnlyException) { |
| | | PropertyIsReadOnlyException pe = (PropertyIsReadOnlyException) e; |
| | | return adapt(d, pe); |
| | | } else if (e instanceof DefaultBehaviorException) { |
| | | DefaultBehaviorException pe = (DefaultBehaviorException) e; |
| | | return adapt(d, pe); |
| | | } else { |
| | | Message message = ERR_DSCFG_ERROR_PROPERTY_UNKNOWN_ERROR. |
| | | get(d.getUserFriendlyName(), e.getPropertyDefinition().getName(), |
| | | e.getMessage()); |
| | | return new ArgumentException(message); |
| | | } |
| | | return new ArgumentException(e.getMessageObject()); |
| | | } |
| | | |
| | | |
| | |
| | | builder.appendHeading(INFO_DSCFG_HEADING_PROPERTY_SYNTAX.get()); |
| | | |
| | | PropertyDefinitionUsageBuilder b = new PropertyDefinitionUsageBuilder(true); |
| | | for (PropertyIsMandatoryException pe : e.getCauses()) { |
| | | for (PropertyException pe : e.getCauses()) { |
| | | PropertyDefinition<?> pd = pe.getPropertyDefinition(); |
| | | builder.startRow(); |
| | | builder.appendCell(pd.getName()); |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * Creates an argument exception from a default behavior exception. |
| | | * |
| | | * @param d |
| | | * The managed object definition. |
| | | * @param e |
| | | * The default behavior exception. |
| | | * @return Returns an argument exception. |
| | | */ |
| | | private static ArgumentException adapt( |
| | | AbstractManagedObjectDefinition<?, ?> d, DefaultBehaviorException e) { |
| | | Message message = ERR_DSCFG_ERROR_PROPERTY_DEFAULT_BEHAVIOR. |
| | | get(d.getUserFriendlyName(), e.getPropertyDefinition().getName(), |
| | | e.getMessage()); |
| | | return new ArgumentException(message); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Creates an argument exception from an illegal property value |
| | | * exception. |
| | | * |
| | | * @param d |
| | | * The managed object definition. |
| | | * @param e |
| | | * The illegal property value exception. |
| | | * @return Returns an argument exception. |
| | | */ |
| | | private static ArgumentException adapt( |
| | | AbstractManagedObjectDefinition<?, ?> d, |
| | | IllegalPropertyValueException e) { |
| | | PropertyDefinitionUsageBuilder b = new PropertyDefinitionUsageBuilder(true); |
| | | Message syntax = b.getUsage(e.getPropertyDefinition()); |
| | | |
| | | if (syntax.length() > 20) { |
| | | // syntax = |
| | | // INFO_DSCFG_DESCRIPTION_PROPERTY_SYNTAX_HELP.get(); |
| | | } |
| | | |
| | | Message message = ERR_DSCFG_ERROR_PROPERTY_INVALID_VALUE. |
| | | get(String.valueOf(e.getIllegalValue()), d.getUserFriendlyName(), |
| | | e.getPropertyDefinition().getName(), syntax); |
| | | return new ArgumentException(message); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Creates an argument exception from an illegal property string |
| | | * value exception. |
| | | * |
| | | * @param d |
| | | * The managed object definition. |
| | | * @param e |
| | | * The illegal property string value exception. |
| | | * @return Returns an argument exception. |
| | | */ |
| | | private static ArgumentException adapt( |
| | | AbstractManagedObjectDefinition<?, ?> d, |
| | | IllegalPropertyValueStringException e) { |
| | | PropertyDefinitionUsageBuilder b = new PropertyDefinitionUsageBuilder(true); |
| | | Message syntax = b.getUsage(e.getPropertyDefinition()); |
| | | |
| | | if (syntax.length() > 20) { |
| | | // syntax = |
| | | // INFO_DSCFG_DESCRIPTION_PROPERTY_SYNTAX_HELP.get(); |
| | | } |
| | | |
| | | Message message = ERR_DSCFG_ERROR_PROPERTY_INVALID_VALUE. |
| | | get(String.valueOf(e.getIllegalValueString()), d.getUserFriendlyName(), |
| | | e.getPropertyDefinition().getName(), syntax); |
| | | return new ArgumentException(message); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Creates an argument exception from a property is mandatory |
| | | * exception. |
| | | * |
| | | * @param d |
| | | * The managed object definition. |
| | | * @param e |
| | | * The property is mandatory exception. |
| | | * @return Returns an argument exception. |
| | | */ |
| | | private static ArgumentException adapt( |
| | | AbstractManagedObjectDefinition<?, ?> d, |
| | | PropertyIsMandatoryException e) { |
| | | Message message = ERR_DSCFG_ERROR_PROPERTY_MANDATORY.get( |
| | | d.getUserFriendlyName(), e.getPropertyDefinition().getName()); |
| | | return new ArgumentException(message); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Creates an argument exception from a property is read-only |
| | | * exception. |
| | | * |
| | | * @param d |
| | | * The managed object definition. |
| | | * @param e |
| | | * The property is read-only exception. |
| | | * @return Returns an argument exception. |
| | | */ |
| | | private static ArgumentException adapt( |
| | | AbstractManagedObjectDefinition<?, ?> d, |
| | | PropertyIsReadOnlyException e) { |
| | | Message message = ERR_DSCFG_ERROR_PROPERTY_READ_ONLY.get( |
| | | d.getUserFriendlyName(), e.getPropertyDefinition().getName()); |
| | | return new ArgumentException(message); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Creates an argument exception from a property is single-valued |
| | | * exception. |
| | | * |
| | | * @param d |
| | | * The managed object definition. |
| | | * @param e |
| | | * The property is single-valued exception. |
| | | * @return Returns an argument exception. |
| | | */ |
| | | private static ArgumentException adapt( |
| | | AbstractManagedObjectDefinition<?, ?> d, |
| | | PropertyIsSingleValuedException e) { |
| | | Message message = ERR_DSCFG_ERROR_PROPERTY_SINGLE_VALUED.get( |
| | | d.getUserFriendlyName(), e.getPropertyDefinition().getName()); |
| | | return new ArgumentException(message); |
| | | } |
| | | |
| | | |
| | | |
| | | // Prevent instantiation. |
| | | private ArgumentExceptionFactory() { |
| | | // No implementation required. |
| | |
| | | |
| | | import static org.opends.messages.DSConfigMessages.*; |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static org.opends.server.admin.PropertyException.*; |
| | | import static org.opends.server.tools.dsconfig.ArgumentExceptionFactory.*; |
| | | |
| | | import java.util.Collection; |
| | |
| | | import org.opends.server.admin.AggregationPropertyDefinition; |
| | | import org.opends.server.admin.Configuration; |
| | | import org.opends.server.admin.ConfigurationClient; |
| | | import org.opends.server.admin.DefaultBehaviorException; |
| | | import org.opends.server.admin.PropertyException; |
| | | import org.opends.server.admin.DefinitionDecodingException; |
| | | import org.opends.server.admin.IllegalPropertyValueStringException; |
| | | import org.opends.server.admin.InstantiableRelationDefinition; |
| | | import org.opends.server.admin.ManagedObjectAlreadyExistsException; |
| | | import org.opends.server.admin.ManagedObjectDefinition; |
| | |
| | | import org.opends.server.admin.OptionalRelationDefinition; |
| | | import org.opends.server.admin.PropertyDefinition; |
| | | import org.opends.server.admin.PropertyDefinitionUsageBuilder; |
| | | import org.opends.server.admin.PropertyException; |
| | | import org.opends.server.admin.PropertyIsSingleValuedException; |
| | | import org.opends.server.admin.PropertyOption; |
| | | import org.opends.server.admin.PropertyProvider; |
| | | import org.opends.server.admin.RelationDefinition; |
| | |
| | | T value; |
| | | try { |
| | | value = pd.decodeValue(s); |
| | | } catch (IllegalPropertyValueStringException e) { |
| | | } catch (PropertyException e) { |
| | | throw ArgumentExceptionFactory.adaptPropertyException(e, d); |
| | | } |
| | | |
| | |
| | | values.add(value); |
| | | |
| | | if (values.size() > 1 && !pd.hasOption(PropertyOption.MULTI_VALUED)) { |
| | | PropertyException e = new PropertyIsSingleValuedException(pd); |
| | | PropertyException e = propertyIsSingleValuedException(pd); |
| | | throw ArgumentExceptionFactory.adaptPropertyException(e, d); |
| | | } |
| | | |
| | |
| | | |
| | | // Now create the component. |
| | | // FIXME: handle default value exceptions? |
| | | List<DefaultBehaviorException> exceptions = |
| | | new LinkedList<DefaultBehaviorException>(); |
| | | List<PropertyException> exceptions = |
| | | new LinkedList<PropertyException>(); |
| | | app.println(); |
| | | app.println(); |
| | | ManagedObject<? extends C> mo = |
| | |
| | | ConsoleApplication app, final ManagedObject<?> parent, |
| | | final InstantiableRelationDefinition<C, S> irelation, |
| | | final ManagedObjectDefinition<? extends C, ? extends S> d, |
| | | final List<DefaultBehaviorException> exceptions) throws CLIException { |
| | | final List<PropertyException> exceptions) throws CLIException { |
| | | ValidationCallback<ManagedObject<? extends C>> validator = |
| | | new ValidationCallback<ManagedObject<? extends C>>() { |
| | | |
| | |
| | | namingPropertyDefinition, propertyArgs); |
| | | |
| | | ManagedObject<? extends C> child; |
| | | List<DefaultBehaviorException> exceptions = |
| | | new LinkedList<DefaultBehaviorException>(); |
| | | List<PropertyException> exceptions = |
| | | new LinkedList<PropertyException>(); |
| | | boolean isNameProvidedInteractively = false; |
| | | String providedNamingArgName = null; |
| | | if (relation instanceof InstantiableRelationDefinition) { |
| | |
| | | import org.opends.server.admin.StringPropertyDefinition; |
| | | import org.opends.server.admin.Tag; |
| | | import org.opends.server.admin.UndefinedDefaultBehaviorProvider; |
| | | import org.opends.server.admin.UnknownPropertyDefinitionException; |
| | | import org.opends.server.admin.PropertyException; |
| | | import org.opends.server.tools.ClientException; |
| | | import org.opends.server.util.args.ArgumentException; |
| | | import org.opends.server.util.args.BooleanArgument; |
| | |
| | | */ |
| | | @Override |
| | | public <T> Void visitUnknown(PropertyDefinition<T> d, PrintStream p) |
| | | throws UnknownPropertyDefinitionException { |
| | | throws PropertyException { |
| | | PropertyDefinitionUsageBuilder usageBuilder = |
| | | new PropertyDefinitionUsageBuilder(true); |
| | | displayUsage(p, usageBuilder.getUsage(d)); |
| | |
| | | import org.opends.server.admin.DefinedDefaultBehaviorProvider; |
| | | import org.opends.server.admin.DefinitionDecodingException; |
| | | import org.opends.server.admin.EnumPropertyDefinition; |
| | | import org.opends.server.admin.IllegalPropertyValueException; |
| | | import org.opends.server.admin.IllegalPropertyValueStringException; |
| | | import org.opends.server.admin.PropertyException; |
| | | import org.opends.server.admin.InstantiableRelationDefinition; |
| | | import org.opends.server.admin.ManagedObjectDefinition; |
| | | import org.opends.server.admin.ManagedObjectNotFoundException; |
| | |
| | | import org.opends.server.admin.PropertyDefinition; |
| | | import org.opends.server.admin.PropertyDefinitionUsageBuilder; |
| | | import org.opends.server.admin.PropertyDefinitionVisitor; |
| | | import org.opends.server.admin.PropertyIsMandatoryException; |
| | | import org.opends.server.admin.PropertyIsReadOnlyException; |
| | | import org.opends.server.admin.PropertyIsSingleValuedException; |
| | | import org.opends.server.admin.PropertyOption; |
| | | import org.opends.server.admin.RelativeInheritedDefaultBehaviorProvider; |
| | | import org.opends.server.admin.UndefinedDefaultBehaviorProvider; |
| | | import org.opends.server.admin.UnknownPropertyDefinitionException; |
| | | import org.opends.server.admin.client.AuthorizationException; |
| | | import org.opends.server.admin.client.CommunicationException; |
| | | import org.opends.server.admin.client.ManagedObject; |
| | |
| | | */ |
| | | @Override |
| | | public <T> MenuResult<Void> visitUnknown(PropertyDefinition<T> d, |
| | | Void p) throws UnknownPropertyDefinitionException { |
| | | Void p) throws PropertyException { |
| | | app.println(); |
| | | displayPropertySyntax(app, d); |
| | | |
| | |
| | | |
| | | // Common menu processing. |
| | | private <T> MenuResult<Boolean> runMenu(final PropertyDefinition<T> d, |
| | | MenuBuilder<T> builder) throws IllegalPropertyValueException, |
| | | PropertyIsSingleValuedException, PropertyIsReadOnlyException, |
| | | PropertyIsMandatoryException, IllegalArgumentException { |
| | | MenuBuilder<T> builder) throws PropertyException, |
| | | PropertyException, PropertyException, |
| | | PropertyException, IllegalArgumentException { |
| | | builder.addHelpOption(new PropertyHelpCallback(mo |
| | | .getManagedObjectDefinition(), d)); |
| | | builder.addQuitOption(); |
| | |
| | | } |
| | | |
| | | break; |
| | | } catch (IllegalPropertyValueStringException e) { |
| | | } catch (PropertyException e) { |
| | | app.println(); |
| | | app.println(ArgumentExceptionFactory.adaptPropertyException(e, d) |
| | | .getMessageObject()); |
| | |
| | | } else { |
| | | values.add(value); |
| | | } |
| | | } catch (IllegalPropertyValueStringException e) { |
| | | } catch (PropertyException e) { |
| | | app.println(); |
| | | app.println(ArgumentExceptionFactory.adaptPropertyException(e, d) |
| | | .getMessageObject()); |
| | |
| | | import org.opends.messages.Message; |
| | | import org.opends.server.admin.AggregationPropertyDefinition; |
| | | import org.opends.server.admin.DefinitionDecodingException; |
| | | import org.opends.server.admin.IllegalPropertyValueStringException; |
| | | import org.opends.server.admin.PropertyException; |
| | | import org.opends.server.admin.InstantiableRelationDefinition; |
| | | import org.opends.server.admin.ManagedObjectAlreadyExistsException; |
| | | import org.opends.server.admin.ManagedObjectDefinition; |
| | |
| | | import org.opends.server.admin.ManagedObjectPath; |
| | | import org.opends.server.admin.OptionalRelationDefinition; |
| | | import org.opends.server.admin.PropertyDefinition; |
| | | import org.opends.server.admin.PropertyException; |
| | | import org.opends.server.admin.PropertyOption; |
| | | import org.opends.server.admin.RelationDefinition; |
| | | import org.opends.server.admin.SetRelationDefinition; |
| | |
| | | T value; |
| | | try { |
| | | value = pd.decodeValue(s); |
| | | } catch (IllegalPropertyValueStringException e) { |
| | | } catch (PropertyException e) { |
| | | throw ArgumentExceptionFactory.adaptPropertyException(e, mo |
| | | .getManagedObjectDefinition()); |
| | | } |
| | |
| | | ReplicationSynchronizationProviderCfgDefn.getInstance(); |
| | | sync = root.createSynchronizationProvider(provider, |
| | | "Multimaster Synchronization", |
| | | new ArrayList<DefaultBehaviorException>()); |
| | | new ArrayList<PropertyException>()); |
| | | sync.setJavaClass( |
| | | org.opends.server.replication.plugin.MultimasterReplication.class. |
| | | getName()); |
| | |
| | | usedReplicationServerIds.add(id); |
| | | replicationServer = sync.createReplicationServer( |
| | | ReplicationServerCfgDefn.getInstance(), |
| | | new ArrayList<DefaultBehaviorException>()); |
| | | new ArrayList<PropertyException>()); |
| | | replicationServer.setReplicationServerId(id); |
| | | replicationServer.setReplicationPort(replicationPort); |
| | | replicationServer.setReplicationServer(replicationServers); |
| | |
| | | InstallerHelper.getDomainName(domainNames, domainId, baseDN); |
| | | domain = sync.createReplicationDomain( |
| | | ReplicationDomainCfgDefn.getInstance(), domainName, |
| | | new ArrayList<DefaultBehaviorException>()); |
| | | new ArrayList<PropertyException>()); |
| | | domain.setServerId(domainId); |
| | | domain.setBaseDN(DN.valueOf(baseDN)); |
| | | domain.setReplicationServer(replicationServers); |
| | |
| | | * @param value |
| | | * to decode |
| | | */ |
| | | @Test(dataProvider = "testDecodeValueIllegalData", expectedExceptions = { IllegalPropertyValueStringException.class }) |
| | | @Test(dataProvider = "testDecodeValueIllegalData", expectedExceptions = { PropertyException.class }) |
| | | public void testDecodeValue2(String value) { |
| | | AttributeTypePropertyDefinition.setCheckSchema(true); |
| | | AttributeTypePropertyDefinition d = createPropertyDefinition(); |
| | |
| | | * @param value to decode |
| | | */ |
| | | @Test(dataProvider = "testDecodeValueData2", |
| | | expectedExceptions = {NullPointerException.class,IllegalPropertyValueStringException.class}) |
| | | expectedExceptions = {NullPointerException.class,PropertyException.class}) |
| | | public void testDecodeValue2(String value) { |
| | | BooleanPropertyDefinition d = createPropertyDefinition(); |
| | | d.decodeValue(value); |
| | |
| | | } |
| | | |
| | | @Test(dataProvider = "testLoadClassData2", |
| | | expectedExceptions = {IllegalPropertyValueException.class}) |
| | | expectedExceptions = {PropertyException.class}) |
| | | public <T> void testLoadClass2(String interfaceName, String loadClassName, |
| | | Class<T> instanceOfClass, Class expectedClass) { |
| | | ClassPropertyDefinition.Builder localBuilder = |
| | |
| | | * @throws DirectoryException |
| | | * If the DN could not be decoded. |
| | | */ |
| | | @Test(dataProvider = "testIllegalValues", expectedExceptions = IllegalPropertyValueException.class) |
| | | @Test(dataProvider = "testIllegalValues", expectedExceptions = PropertyException.class) |
| | | public void testValidateIllegalValues(String baseDN, String value) |
| | | throws DirectoryException { |
| | | DNPropertyDefinition.Builder localBuilder = DNPropertyDefinition |
| | |
| | | * @param value |
| | | * The value to be validated. |
| | | */ |
| | | @Test(dataProvider = "testIllegalValues", expectedExceptions = IllegalPropertyValueStringException.class) |
| | | @Test(dataProvider = "testIllegalValues", expectedExceptions = PropertyException.class) |
| | | public void testDecodeIllegalValues(String baseDN, String value) { |
| | | DNPropertyDefinition.Builder localBuilder = DNPropertyDefinition |
| | | .createBuilder(RootCfgDefn.getInstance(), "test-property"); |
| | |
| | | /** |
| | | * Tests the allowUnlimited property |
| | | */ |
| | | @Test(expectedExceptions = IllegalPropertyValueStringException.class) |
| | | @Test(expectedExceptions = PropertyException.class) |
| | | public void testIsAllowUnlimited2() { |
| | | DurationPropertyDefinition.Builder builder = createTestBuilder(); |
| | | builder.setAllowUnlimited(false); |
| | |
| | | /** |
| | | * Tests the allowUnlimited property |
| | | */ |
| | | @Test(expectedExceptions = IllegalPropertyValueException.class) |
| | | @Test(expectedExceptions = PropertyException.class) |
| | | public void testIsAllowUnlimited3() { |
| | | DurationPropertyDefinition.Builder builder = createTestBuilder(); |
| | | builder.setAllowUnlimited(false); |
| | |
| | | * @param value to validate |
| | | */ |
| | | @Test(dataProvider = "illegalValidateValueData", |
| | | expectedExceptions = {AssertionError.class,NullPointerException.class,IllegalPropertyValueException.class}) |
| | | expectedExceptions = {AssertionError.class,NullPointerException.class,PropertyException.class}) |
| | | public void testValidateValue2(Long low, Long high, boolean allowUnlimited, Long value) { |
| | | DurationPropertyDefinition.Builder builder = createTestBuilder(); |
| | | builder.setLowerLimit(low); |
| | |
| | | } |
| | | |
| | | public Boolean visitUnknown(PropertyDefinition d, Void o) |
| | | throws UnknownPropertyDefinitionException { |
| | | throws PropertyException { |
| | | return false; |
| | | } |
| | | |
| | |
| | | * @param value to decode |
| | | */ |
| | | @Test(dataProvider = "decodeValueData2", |
| | | expectedExceptions = {IllegalPropertyValueStringException.class}) |
| | | expectedExceptions = {PropertyException.class}) |
| | | public void testDecodeValue(String value) { |
| | | DurationPropertyDefinition.Builder builder = createTestBuilder(); |
| | | builder.setAllowUnlimited(false); |
| | |
| | | */ |
| | | @Test(dataProvider = "decodeValueData2", |
| | | expectedExceptions = {NullPointerException.class, |
| | | IllegalPropertyValueStringException.class} ) |
| | | PropertyException.class} ) |
| | | public void testDecodeValue2(String value) { |
| | | EnumPropertyDefinition epd = builder.getInstance(); |
| | | epd.decodeValue(value); |
| | |
| | | /** |
| | | * Tests the allowUnlimited property |
| | | */ |
| | | @Test(expectedExceptions = IllegalPropertyValueStringException.class) |
| | | @Test(expectedExceptions = PropertyException.class) |
| | | public void testIsAllowUnlimited2() { |
| | | IntegerPropertyDefinition.Builder builder = createTestBuilder(); |
| | | builder.setAllowUnlimited(false); |
| | |
| | | /** |
| | | * Tests the allowUnlimited property |
| | | */ |
| | | @Test(expectedExceptions = IllegalPropertyValueException.class) |
| | | @Test(expectedExceptions = PropertyException.class) |
| | | public void testIsAllowUnlimited3() { |
| | | IntegerPropertyDefinition.Builder builder = createTestBuilder(); |
| | | builder.setAllowUnlimited(false); |
| | |
| | | * @param allowUnlimited when true allows unlimited |
| | | */ |
| | | @Test(dataProvider = "illegalValidateValueData", |
| | | expectedExceptions = {AssertionError.class,NullPointerException.class,IllegalPropertyValueException.class}) |
| | | expectedExceptions = {AssertionError.class,NullPointerException.class,PropertyException.class}) |
| | | public void testValidateValue2(Integer low, Integer high, boolean allowUnlimited, Integer value) { |
| | | IntegerPropertyDefinition.Builder builder = createTestBuilder(); |
| | | builder.setLowerLimit(low); |
| | |
| | | } |
| | | |
| | | public Boolean visitUnknown(PropertyDefinition d, Void o) |
| | | throws UnknownPropertyDefinitionException { |
| | | throws PropertyException { |
| | | return false; |
| | | } |
| | | |
| | |
| | | /** |
| | | * Tests the allowUnlimited property |
| | | */ |
| | | @Test(expectedExceptions = IllegalPropertyValueStringException.class) |
| | | @Test(expectedExceptions = PropertyException.class) |
| | | public void testIsAllowUnlimited2() { |
| | | SizePropertyDefinition.Builder builder = createTestBuilder(); |
| | | builder.setAllowUnlimited(false); |
| | |
| | | /** |
| | | * Tests the allowUnlimited property |
| | | */ |
| | | @Test(expectedExceptions = IllegalPropertyValueException.class) |
| | | @Test(expectedExceptions = PropertyException.class) |
| | | public void testIsAllowUnlimited3() { |
| | | SizePropertyDefinition.Builder builder = createTestBuilder(); |
| | | builder.setAllowUnlimited(false); |
| | |
| | | * @param allowUnlimited when true allows unlimited |
| | | */ |
| | | @Test(dataProvider = "illegalValidateValueData", |
| | | expectedExceptions = {AssertionError.class,NullPointerException.class,IllegalPropertyValueException.class}) |
| | | expectedExceptions = {AssertionError.class,NullPointerException.class,PropertyException.class}) |
| | | public void testValidateValue2(Long low, Long high, boolean allowUnlimited, Long value) { |
| | | SizePropertyDefinition.Builder builder = createTestBuilder(); |
| | | builder.setLowerLimit(low); |
| | |
| | | } |
| | | |
| | | public Boolean visitUnknown(PropertyDefinition d, Void o) |
| | | throws UnknownPropertyDefinitionException { |
| | | throws PropertyException { |
| | | return false; |
| | | } |
| | | |
| | |
| | | /** |
| | | * Tests validateValue() with invalid data and a pattern. |
| | | */ |
| | | @Test(expectedExceptions = IllegalPropertyValueException.class) |
| | | @Test(expectedExceptions = PropertyException.class) |
| | | public void testValidateValue3() { |
| | | StringPropertyDefinition d = getDefinition(true, "^[a-z]+$"); |
| | | d.validateValue("abc123"); |
| | |
| | | /** |
| | | * Tests decodeValue() with invalid data and a pattern. |
| | | */ |
| | | @Test(expectedExceptions = IllegalPropertyValueStringException.class) |
| | | @Test(expectedExceptions = PropertyException.class) |
| | | public void testDecodeValue2() { |
| | | StringPropertyDefinition d = getDefinition(true, "^[a-z]+$"); |
| | | d.decodeValue("abc123"); |
| | |
| | | import java.util.Collection; |
| | | import java.util.SortedSet; |
| | | import org.opends.server.admin.ConfigurationClient; |
| | | import org.opends.server.admin.IllegalPropertyValueException; |
| | | import org.opends.server.admin.PropertyException; |
| | | import org.opends.server.admin.ManagedObjectDefinition; |
| | | import org.opends.server.admin.PropertyIsReadOnlyException; |
| | | import org.opends.server.admin.TestChildCfg; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.DN; |
| | |
| | | * An aggregation property which references connection handlers. |
| | | * |
| | | * @param values The values of the "aggregation-property" property. |
| | | * @throws IllegalPropertyValueException |
| | | * @throws PropertyException |
| | | * If one or more of the new values are invalid. |
| | | */ |
| | | void setAggregationProperty(Collection<String> values) throws IllegalPropertyValueException; |
| | | void setAggregationProperty(Collection<String> values) throws PropertyException; |
| | | |
| | | |
| | | |
| | |
| | | * A mandatory boolean property. |
| | | * |
| | | * @param value The value of the "mandatory-boolean-property" property. |
| | | * @throws IllegalPropertyValueException |
| | | * @throws PropertyException |
| | | * If the new value is invalid. |
| | | */ |
| | | void setMandatoryBooleanProperty(boolean value) throws IllegalPropertyValueException; |
| | | void setMandatoryBooleanProperty(boolean value) throws PropertyException; |
| | | |
| | | |
| | | |
| | |
| | | * A mandatory Java-class property requiring a component restart. |
| | | * |
| | | * @param value The value of the "mandatory-class-property" property. |
| | | * @throws IllegalPropertyValueException |
| | | * @throws PropertyException |
| | | * If the new value is invalid. |
| | | */ |
| | | void setMandatoryClassProperty(String value) throws IllegalPropertyValueException; |
| | | void setMandatoryClassProperty(String value) throws PropertyException; |
| | | |
| | | |
| | | |
| | |
| | | * creation of a Test Child. |
| | | * |
| | | * @param value The value of the "mandatory-read-only-attribute-type-property" property. |
| | | * @throws IllegalPropertyValueException |
| | | * @throws PropertyException |
| | | * If the new value is invalid. |
| | | * @throws PropertyIsReadOnlyException |
| | | * @throws PropertyException |
| | | * If this Test Child is not being initialized. |
| | | */ |
| | | void setMandatoryReadOnlyAttributeTypeProperty(AttributeType value) throws IllegalPropertyValueException, PropertyIsReadOnlyException; |
| | | void setMandatoryReadOnlyAttributeTypeProperty(AttributeType value) throws PropertyException, PropertyException; |
| | | |
| | | |
| | | |
| | |
| | | * from optional-multi-valued-dn-property in the parent. |
| | | * |
| | | * @param values The values of the "optional-multi-valued-dn-property1" property. |
| | | * @throws IllegalPropertyValueException |
| | | * @throws PropertyException |
| | | * If one or more of the new values are invalid. |
| | | */ |
| | | void setOptionalMultiValuedDNProperty1(Collection<DN> values) throws IllegalPropertyValueException; |
| | | void setOptionalMultiValuedDNProperty1(Collection<DN> values) throws PropertyException; |
| | | |
| | | |
| | | |
| | |
| | | * from optional-multi-valued-dn-property1. |
| | | * |
| | | * @param values The values of the "optional-multi-valued-dn-property2" property. |
| | | * @throws IllegalPropertyValueException |
| | | * @throws PropertyException |
| | | * If one or more of the new values are invalid. |
| | | */ |
| | | void setOptionalMultiValuedDNProperty2(Collection<DN> values) throws IllegalPropertyValueException; |
| | | void setOptionalMultiValuedDNProperty2(Collection<DN> values) throws PropertyException; |
| | | |
| | | } |
| | |
| | | import org.opends.server.admin.DefinedDefaultBehaviorProvider; |
| | | import org.opends.server.admin.ManagedObjectAlreadyExistsException; |
| | | import org.opends.server.admin.ManagedObjectDefinition; |
| | | import org.opends.server.admin.PropertyIsReadOnlyException; |
| | | import org.opends.server.admin.PropertyException; |
| | | import org.opends.server.admin.PropertyOption; |
| | | import org.opends.server.admin.PropertyProvider; |
| | | import org.opends.server.admin.RelativeInheritedDefaultBehaviorProvider; |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void setMandatoryReadOnlyAttributeTypeProperty(AttributeType value) throws PropertyIsReadOnlyException { |
| | | public void setMandatoryReadOnlyAttributeTypeProperty(AttributeType value) throws PropertyException { |
| | | impl.setPropertyValue(INSTANCE.getMandatoryReadOnlyAttributeTypePropertyPropertyDefinition(), value); |
| | | } |
| | | |
| | |
| | | import org.opends.server.admin.client.ManagedObjectDecodingException; |
| | | import org.opends.server.admin.client.OperationRejectedException; |
| | | import org.opends.server.admin.ConfigurationClient; |
| | | import org.opends.server.admin.DefaultBehaviorException; |
| | | import org.opends.server.admin.PropertyException; |
| | | import org.opends.server.admin.DefinitionDecodingException; |
| | | import org.opends.server.admin.IllegalPropertyValueException; |
| | | import org.opends.server.admin.ManagedObjectDefinition; |
| | | import org.opends.server.admin.ManagedObjectNotFoundException; |
| | | import org.opends.server.admin.PropertyIsReadOnlyException; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | |
| | |
| | | * A mandatory boolean property. |
| | | * |
| | | * @param value The value of the "mandatory-boolean-property" property. |
| | | * @throws IllegalPropertyValueException |
| | | * @throws PropertyException |
| | | * If the new value is invalid. |
| | | */ |
| | | void setMandatoryBooleanProperty(boolean value) throws IllegalPropertyValueException; |
| | | void setMandatoryBooleanProperty(boolean value) throws PropertyException; |
| | | |
| | | |
| | | |
| | |
| | | * A mandatory Java-class property requiring a component restart. |
| | | * |
| | | * @param value The value of the "mandatory-class-property" property. |
| | | * @throws IllegalPropertyValueException |
| | | * @throws PropertyException |
| | | * If the new value is invalid. |
| | | */ |
| | | void setMandatoryClassProperty(String value) throws IllegalPropertyValueException; |
| | | void setMandatoryClassProperty(String value) throws PropertyException; |
| | | |
| | | |
| | | |
| | |
| | | * creation of a Test Parent. |
| | | * |
| | | * @param value The value of the "mandatory-read-only-attribute-type-property" property. |
| | | * @throws IllegalPropertyValueException |
| | | * @throws PropertyException |
| | | * If the new value is invalid. |
| | | * @throws PropertyIsReadOnlyException |
| | | * @throws PropertyException |
| | | * If this Test Parent is not being initialized. |
| | | */ |
| | | void setMandatoryReadOnlyAttributeTypeProperty(AttributeType value) throws IllegalPropertyValueException, PropertyIsReadOnlyException; |
| | | void setMandatoryReadOnlyAttributeTypeProperty(AttributeType value) throws PropertyException, PropertyException; |
| | | |
| | | |
| | | |
| | |
| | | * behavior. |
| | | * |
| | | * @param values The values of the "optional-multi-valued-dn-property" property. |
| | | * @throws IllegalPropertyValueException |
| | | * @throws PropertyException |
| | | * If one or more of the new values are invalid. |
| | | */ |
| | | void setOptionalMultiValuedDNProperty(Collection<DN> values) throws IllegalPropertyValueException; |
| | | void setOptionalMultiValuedDNProperty(Collection<DN> values) throws PropertyException; |
| | | |
| | | |
| | | |
| | |
| | | * The name of the new Test Child. |
| | | * @param exceptions |
| | | * An optional collection in which to place any {@link |
| | | * DefaultBehaviorException}s that occurred whilst |
| | | * PropertyException}s that occurred whilst |
| | | * attempting to determine the default values of the |
| | | * Test Child. This argument can be <code>null<code>. |
| | | * @return Returns a new Test Child configuration instance. |
| | |
| | | * If the name is invalid. |
| | | */ |
| | | <C extends TestChildCfgClient> C createTestChild( |
| | | ManagedObjectDefinition<C, ? extends TestChildCfg> d, String name, Collection<DefaultBehaviorException> exceptions) throws IllegalManagedObjectNameException; |
| | | ManagedObjectDefinition<C, ? extends TestChildCfg> d, String name, Collection<PropertyException> exceptions) throws IllegalManagedObjectNameException; |
| | | |
| | | |
| | | |
| | |
| | | * The definition of the Optional Test Child to be created. |
| | | * @param exceptions |
| | | * An optional collection in which to place any {@link |
| | | * DefaultBehaviorException}s that occurred whilst |
| | | * PropertyException}s that occurred whilst |
| | | * attempting to determine the default values of the |
| | | * Optional Test Child. This argument can be <code>null<code>. |
| | | * @return Returns a new Optional Test Child configuration instance. |
| | | */ |
| | | <C extends TestChildCfgClient> C createOptionalTestChild( |
| | | ManagedObjectDefinition<C, ? extends TestChildCfg> d, Collection<DefaultBehaviorException> exceptions); |
| | | ManagedObjectDefinition<C, ? extends TestChildCfg> d, Collection<PropertyException> exceptions); |
| | | |
| | | |
| | | |
| | |
| | | import org.opends.server.admin.client.ManagedObjectDecodingException; |
| | | import org.opends.server.admin.client.MissingMandatoryPropertiesException; |
| | | import org.opends.server.admin.client.OperationRejectedException; |
| | | import org.opends.server.admin.DefaultBehaviorException; |
| | | import org.opends.server.admin.PropertyException; |
| | | import org.opends.server.admin.DefaultBehaviorProvider; |
| | | import org.opends.server.admin.DefinedDefaultBehaviorProvider; |
| | | import org.opends.server.admin.DefinitionDecodingException; |
| | |
| | | import org.opends.server.admin.ManagedObjectDefinition; |
| | | import org.opends.server.admin.ManagedObjectNotFoundException; |
| | | import org.opends.server.admin.OptionalRelationDefinition; |
| | | import org.opends.server.admin.PropertyIsReadOnlyException; |
| | | import org.opends.server.admin.PropertyOption; |
| | | import org.opends.server.admin.PropertyProvider; |
| | | import org.opends.server.admin.server.ConfigurationAddListener; |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public void setMandatoryReadOnlyAttributeTypeProperty(AttributeType value) throws PropertyIsReadOnlyException { |
| | | public void setMandatoryReadOnlyAttributeTypeProperty(AttributeType value) throws PropertyException { |
| | | impl.setPropertyValue(INSTANCE.getMandatoryReadOnlyAttributeTypePropertyPropertyDefinition(), value); |
| | | } |
| | | |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | public <M extends TestChildCfgClient> M createTestChild( |
| | | ManagedObjectDefinition<M, ? extends TestChildCfg> d, String name, Collection<DefaultBehaviorException> exceptions) throws IllegalManagedObjectNameException { |
| | | ManagedObjectDefinition<M, ? extends TestChildCfg> d, String name, Collection<PropertyException> exceptions) throws IllegalManagedObjectNameException { |
| | | return impl.createChild(INSTANCE.getTestChildrenRelationDefinition(), d, name, exceptions).getConfiguration(); |
| | | } |
| | | |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | public <M extends TestChildCfgClient> M createOptionalTestChild( |
| | | ManagedObjectDefinition<M, ? extends TestChildCfg> d, Collection<DefaultBehaviorException> exceptions) { |
| | | ManagedObjectDefinition<M, ? extends TestChildCfg> d, Collection<PropertyException> exceptions) { |
| | | return impl.createChild(INSTANCE.getOptionalTestChildRelationDefinition(), d, exceptions).getConfiguration(); |
| | | } |
| | | |
| | |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.admin.AdminTestCase; |
| | | import org.opends.server.admin.DefinitionDecodingException; |
| | | import org.opends.server.admin.IllegalPropertyValueStringException; |
| | | import org.opends.server.admin.ManagedObjectNotFoundException; |
| | | import org.opends.server.admin.PropertyException; |
| | | import org.opends.server.admin.ManagedObjectNotFoundException; |
| | | import org.opends.server.admin.TestCfg; |
| | | import org.opends.server.admin.TestChildCfgClient; |
| | | import org.opends.server.admin.TestChildCfgDefn; |
| | |
| | | Assert.assertEquals(causes.size(), 1); |
| | | |
| | | Throwable cause = causes.iterator().next(); |
| | | if (cause instanceof IllegalPropertyValueStringException) { |
| | | IllegalPropertyValueStringException pe = (IllegalPropertyValueStringException) cause; |
| | | if (cause instanceof PropertyException) { |
| | | PropertyException pe = (PropertyException) cause; |
| | | Assert.assertEquals(pe.getPropertyDefinition(), TestChildCfgDefn |
| | | .getInstance().getAggregationPropertyPropertyDefinition()); |
| | | Assert.assertEquals(pe.getIllegalValueString(), |
| | | "cn=LDAP Connection Handler, cn=bad rdn, cn=config"); |
| | | } else { |
| | | // Got an unexpected cause. |
| | | throw e; |
| | |
| | | Assert.assertEquals(causes.size(), 1); |
| | | |
| | | cause = causes.iterator().next(); |
| | | if (cause instanceof IllegalPropertyValueStringException) { |
| | | IllegalPropertyValueStringException pe = (IllegalPropertyValueStringException) cause; |
| | | if (cause instanceof PropertyException) { |
| | | PropertyException pe = (PropertyException) cause; |
| | | Assert.assertEquals(pe.getPropertyDefinition(), TestChildCfgDefn |
| | | .getInstance().getAggregationPropertyPropertyDefinition()); |
| | | Assert.assertEquals(pe.getIllegalValueString(), |
| | | "cn=LDAP Connection Handler, cn=bad rdn, cn=config"); |
| | | } else { |
| | | // Got an unexpected cause. |
| | | throw e; |