| | |
| | | * @throws ConfigException If this attribute does not have exactly one |
| | | * active value. |
| | | */ |
| | | public String activeValue() |
| | | throws ConfigException |
| | | public String activeValue() throws ConfigException |
| | | { |
| | | if ((activeValues == null) || activeValues.isEmpty()) |
| | | if (activeValues == null || activeValues.isEmpty()) |
| | | { |
| | | LocalizableMessage message = ERR_CONFIG_ATTR_NO_STRING_VALUE.get(getName()); |
| | | throw new ConfigException(message); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_NO_STRING_VALUE.get(getName())); |
| | | } |
| | | |
| | | if (activeValues.size() > 1) |
| | | { |
| | | LocalizableMessage message = ERR_CONFIG_ATTR_MULTIPLE_STRING_VALUES.get(getName()); |
| | | throw new ConfigException(message); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_MULTIPLE_STRING_VALUES.get(getName())); |
| | | } |
| | | |
| | | return activeValues.get(0); |
| | |
| | | return activeValue(); |
| | | } |
| | | |
| | | if ((pendingValues == null) || pendingValues.isEmpty()) |
| | | if (pendingValues == null || pendingValues.isEmpty()) |
| | | { |
| | | LocalizableMessage message = ERR_CONFIG_ATTR_NO_STRING_VALUE.get(getName()); |
| | | throw new ConfigException(message); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_NO_STRING_VALUE.get(getName())); |
| | | } |
| | | |
| | | if (pendingValues.size() > 1) |
| | | { |
| | | LocalizableMessage message = ERR_CONFIG_ATTR_MULTIPLE_STRING_VALUES.get(getName()); |
| | | throw new ConfigException(message); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_MULTIPLE_STRING_VALUES.get(getName())); |
| | | } |
| | | |
| | | return pendingValues.get(0); |
| | |
| | | public void setValue(String value) |
| | | throws ConfigException |
| | | { |
| | | if ((value == null) || (value.length() == 0)) |
| | | if (value == null || value.length() == 0) |
| | | { |
| | | LocalizableMessage message = ERR_CONFIG_ATTR_EMPTY_STRING_VALUE.get(getName()); |
| | | throw new ConfigException(message); |
| | |
| | | |
| | | // Next check if the set contains multiple values and if that is allowed. |
| | | int numValues = values.size(); |
| | | if ((! isMultiValued()) && (numValues > 1)) |
| | | if (!isMultiValued() && numValues > 1) |
| | | { |
| | | throw new ConfigException(ERR_CONFIG_ATTR_SET_VALUES_IS_SINGLE_VALUED.get(getName())); |
| | | } |
| | |
| | | { |
| | | // Make sure that the value is non-empty. |
| | | String stringValue; |
| | | if (value == null || ((stringValue = value.toString()).length() == 0)) |
| | | if (value == null || (stringValue = value.toString()).length() == 0) |
| | | { |
| | | rejectReason.append(ERR_CONFIG_ATTR_EMPTY_STRING_VALUE.get(getName())); |
| | | return false; |
| | |
| | | // Make sure that the value is in the allowed value set. |
| | | if (! allowedValues.contains(stringValue.toLowerCase())) |
| | | { |
| | | rejectReason.append(ERR_CONFIG_ATTR_VALUE_NOT_ALLOWED.get( |
| | | stringValue, getName())); |
| | | rejectReason.append(ERR_CONFIG_ATTR_VALUE_NOT_ALLOWED.get(stringValue, getName())); |
| | | return false; |
| | | } |
| | | |
| | |
| | | else |
| | | { |
| | | int numValues = a.size(); |
| | | if ((numValues > 1) && (! isMultiValued())) |
| | | if (numValues > 1 && !isMultiValued()) |
| | | { |
| | | // This is illegal -- the attribute is single-valued. |
| | | LocalizableMessage message = |
| | |
| | | if (! allowedValues.contains(lowerValue)) |
| | | { |
| | | // This is illegal -- the value is not allowed. |
| | | throw new ConfigException(ERR_CONFIG_ATTR_VALUE_NOT_ALLOWED.get( |
| | | v, a.getName())); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_VALUE_NOT_ALLOWED.get(v, a.getName())); |
| | | } |
| | | |
| | | pendingValues.add(v.toString()); |
| | |
| | | else |
| | | { |
| | | int numValues = a.size(); |
| | | if ((numValues > 1) && (! isMultiValued())) |
| | | if (numValues > 1 && ! isMultiValued()) |
| | | { |
| | | // This is illegal -- the attribute is single-valued. |
| | | LocalizableMessage message = |
| | |
| | | if (! allowedValues.contains(lowerValue)) |
| | | { |
| | | // This is illegal -- the value is not allowed. |
| | | throw new ConfigException(ERR_CONFIG_ATTR_VALUE_NOT_ALLOWED.get( |
| | | v, a.getName())); |
| | | throw new ConfigException(ERR_CONFIG_ATTR_VALUE_NOT_ALLOWED.get(v, a.getName())); |
| | | } |
| | | |
| | | activeValues.add(v.toString()); |
| | |
| | | } |
| | | |
| | | |
| | | if (requiresAdminAction() && (pendingValues != null) && |
| | | (pendingValues != activeValues)) |
| | | if (requiresAdminAction() && pendingValues != null && pendingValues != activeValues) |
| | | { |
| | | String name = getName() + ";" + OPTION_PENDING_VALUES; |
| | | |
| | |
| | | } |
| | | else if (! pendingValues.isEmpty()) |
| | | { |
| | | attributeList.add(new javax.management.Attribute(name, |
| | | pendingValues.get(0))); |
| | | attributeList.add(new javax.management.Attribute(name, pendingValues.get(0))); |
| | | } |
| | | } |
| | | } |