public String getOptionValue(ProvisioningOption option, String defaultValue) throws ProvisioningException { final String value = layout.getOptionValue(option.getName()); if(value == null) { if(defaultValue != null) { return defaultValue; } defaultValue = option.getDefaultValue(); if(defaultValue != null) { return defaultValue; } if(option.isRequired()) { throw new ProvisioningException("Required plugin option " + option.getName() + " has not been provided"); } return null; } if(!option.getValueSet().isEmpty() && !option.getValueSet().contains(value)) { final StringBuilder buf = new StringBuilder(); buf.append("Plugin option ").append(option.getName()).append(" is set to ").append(value).append(" but expects one of "); StringUtils.append(buf, option.getValueSet()); throw new ProvisioningException(buf.toString()); } return value; }
public String getOptionValue(ProvisioningOption option) throws ProvisioningException { final String setValue = options.get(option.getName()); if(setValue == null) { if(option.isRequired() && (!options.containsKey(option.getName()) && option.getDefaultValue() == null)) { throw new ProvisioningException(Errors.pluginOptionRequired(option.getName())); } return option.getDefaultValue(); } if(!option.getValueSet().isEmpty() && !option.getValueSet().contains(setValue)) { throw new ProvisioningException(Errors.pluginOptionIllegalValue(option.getName(), setValue, option.getValueSet())); } return setValue; }
break; default: throw new ProvisioningDescriptionException(Errors.pluginOptionIllegalValue(ProvisioningOption.OPTIONAL_PACKAGES.getName(), optionalPackages, ProvisioningOption.OPTIONAL_PACKAGES.getValueSet()));