private boolean isReadOnly(PropertyDefinition propertyDefinition) { // A fully editable config overrides any other means of setting read only. return (!this.config.isFullyEditable() && (this.config.isReadOnly() || (propertyDefinition.isReadOnly() && !isInvalidRequiredProperty(propertyDefinition)))); }
/** * Simple map property parsing. * * @param property raw map property * @param propertyDefinition property definition * @return parsed map, can be empty if no members were set. */ protected Map<String, Object> prepareSimplePropertyMap(PropertyMap property, PropertyDefinitionMap propertyDefinition) { Map<String, PropertyDefinition> memberDefinitions = propertyDefinition.getMap(); Map<String, Object> results = new HashMap<String, Object>(); for (String name : memberDefinitions.keySet()) { PropertyDefinition memberDefinition = memberDefinitions.get(name); if (memberDefinition.isReadOnly()) continue; if (memberDefinition instanceof PropertyDefinitionSimple) { PropertyDefinitionSimple pds = (PropertyDefinitionSimple) memberDefinition; PropertySimple ps = (PropertySimple) property.get(name); if ((ps == null || ps.getStringValue() == null) && !pds.isRequired()) continue; if (ps != null) results.put(name, ps.getStringValue()); } else { log.error(" *** not yet supported *** : " + memberDefinition.getName()); } } return results; }
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."); } } }
if (propDef.isReadOnly()) return;
existingProperty.setVersion(newProperty.getVersion()); existingProperty.setRequired(newProperty.isRequired()); existingProperty.setReadOnly(newProperty.isReadOnly()); existingProperty.setSummary(newProperty.isSummary()); existingProperty.setPropertyGroupDefinition(newProperty.getPropertyGroupDefinition());