ServerProperty serverProperty = ADSContext
.getServerPropFromName(propertyName);
if (serverProperty == null)
{
Message message = ERR_CLI_ERROR_PROPERTY_UNRECOGNIZED.get(propertyName);
throw new ArgumentException(message);
}
// Check that propName is not hidden.
if (serverProperties.get(serverProperty).isHidden())
{
Message message = ERR_CLI_ERROR_PROPERTY_UNRECOGNIZED.get(propertyName);
throw new ArgumentException(message);
}
// Check the property Syntax.
MessageBuilder invalidReason = new MessageBuilder();
Argument arg = serverProperties.get(serverProperty) ;
if ( ! arg.valueIsAcceptable(value, invalidReason))
{
Message message =
ERR_CLI_ERROR_INVALID_PROPERTY_VALUE.get(propertyName, value);
throw new ArgumentException(message);
}
serverProperties.get(serverProperty).addValue(value);
// add to the map.
map.put(serverProperty, value);
}
// Check that all mandatory props are set.
for (ServerProperty s : ServerProperty.values())
{
Argument arg = serverProperties.get(s);
if (arg.isHidden())
{
continue;
}
if (map.containsKey(s))
{
continue ;
}
if ( ! arg.isRequired())
{
continue ;
}
// If we are here, it means that the argument is required
// but not yet is the map. Check if we have a default value.
if (arg.getDefaultValue() == null)
{
Message message =
ERR_CLI_ERROR_MISSING_PROPERTY.get(s.getAttributeName());
throw new ArgumentException(message);
}
else
{
map.put(s, arg.getDefaultValue());
}