private boolean isInvalidRequiredProperty(PropertyDefinition propertyDefinition) { boolean isInvalidRequiredProperty = false; if ((propertyDefinition instanceof PropertyDefinitionSimple) && propertyDefinition.isRequired()) { PropertySimple propertySimple = this.propertyMap.getSimple(propertyDefinition.getName()); String errorMessage = propertySimple.getErrorMessage(); if ((null == propertySimple.getStringValue()) || "".equals(propertySimple.getStringValue()) || ((null != errorMessage) && (!"".equals(errorMessage.trim())))) { // Required properties with no value, or an invalid value (assumed if we see an error message) should never // be set to read-only, otherwise the user will have no way to give the property a value and thereby // get things to a valid state. isInvalidRequiredProperty = true; } } return isInvalidRequiredProperty; }
private static void validatePropertySimple(PropertyDefinition propertyDefinition, PropertySimple propertySimple, PropertySimple currentPropertySimple, List<String> errorMessages) { // make sure required properties have a value if (propertyDefinition.isRequired() && (propertySimple.getStringValue() == null)) { errorMessages.add("Required property '" + propertyDefinition.getName() + "' has a null value."); propertySimple.setStringValue(""); } // make sure readOnly properties are not being changed if (propertyDefinition.isReadOnly() && null != currentPropertySimple) { String currentValue = currentPropertySimple.getStringValue(); // if there is no current value allow an initial value to be set for the readOnly property. if (!(null == currentValue || currentValue.trim().isEmpty() || propertySimple.getStringValue().equals( currentValue))) { errorMessages.add("ReadOnly property '" + propertyDefinition.getName() + "' has a value [" + propertySimple.getStringValue() + "] different than the current value [" + currentValue + "]. It is not allowed to change."); } } }
public static void addPropertyDisplayName(UIComponent parent, PropertyDefinition propertyDefinition, Property property, boolean configReadOnly) { String displayName = (propertyDefinition != null) ? propertyDefinition.getDisplayName() : property.getName(); FacesComponentUtility.addOutputText(parent, null, displayName, CssStyleClasses.PROPERTY_DISPLAY_NAME_TEXT); if (!configReadOnly && propertyDefinition != null && propertyDefinition.isRequired() && (propertyDefinition instanceof PropertyDefinitionSimple || propertyDefinition instanceof PropertyDefinitionDynamic) ) { // Print a required marker next to required simples. // Ignore the required field for maps and lists, as it is has no significance for them. FacesComponentUtility.addOutputText(parent, null, " * ", CssStyleClasses.REQUIRED_MARKER_TEXT); } }
if (propertyDefinition.isRequired() && property ==null) { messages.add("Required property [" + name + "] not found"); return; if (!propertyDefinition.isRequired() && property==null) { return;
if (!operationResult.isSuccess()) { if (definitions.size()==1 && definitions.get(0).isRequired()==false) { return;
/** * checks if plugin configuration has set all required properties * @param plugin * @throws PluginConfigurationRequiredException if plugin is missing required configuration * @throws Exception in case of any other error */ private void checkForRequiredConfiguration(ServerPlugin plugin) throws Exception { ConfigurationDefinition configDef = getServerPluginConfigurationDefinition(new PluginKey(plugin)); Configuration configuration = plugin.getPluginConfiguration(); for (PropertyDefinition propDef : configDef.getPropertyDefinitions().values()) { if (propDef.isRequired() && propDef instanceof PropertyDefinitionSimple) { Property prop = configuration.get(propDef.getName()); PropertySimple simple = (PropertySimple) prop; if (simple == null || simple.getStringValue() == null || "".equals(simple.getStringValue())) { throw new PluginConfigurationRequiredException("Plugin [" + plugin.getDisplayName() + "] could not be enabled, because some required configuration fields are not set."); } } } }
if (defaultValue != null || propertyDefinition.isRequired()) { property = new PropertySimple(propertyDefinition.getName(), defaultValue); } else if (propertyDefinition.isRequired()) { if (propertyDefinition instanceof PropertyDefinitionMap) { property = new PropertyMap(propertyDefinition.getName()); PropertyDefinition listMemberPropertyDefinition = ((PropertyDefinitionList) propertyDefinition) .getMemberDefinition(); if (listMemberPropertyDefinition.isRequired()) { if (listMemberPropertyDefinition instanceof PropertyDefinitionMap) {
String value = null; if (normalizeRequiredDefaults || normalizeOptionalDefaults) { if (propertyDefinition.isRequired()) { if (normalizeRequiredDefaults) { value = ((PropertyDefinitionSimple) propertyDefinition).getDefaultValue();
if (propertyDef.isRequired()) { Property templateProperty = templateConfiguration.get(propertyDef.getName()); if (templateProperty == null) { if (propertyDef.isRequired()) {
existingProperty.setActivationPolicy(newProperty.getActivationPolicy()); existingProperty.setVersion(newProperty.getVersion()); existingProperty.setRequired(newProperty.isRequired()); existingProperty.setReadOnly(newProperty.isReadOnly()); existingProperty.setSummary(newProperty.isSummary());
if (propertyDefinition.isRequired()) { errorMessages.add("Required property '" + propertyDefinition.getName() + "' was not set in " + parentPropertyMap + ".");