if (valueResource != null) {
valueResource = valueResource.trim();
}
// create new CmsProperty object to store
CmsProperty newProperty = new CmsProperty();
newProperty.setName(curPropDef.getName());
newProperty.setStructureValue(valueStructure);
newProperty.setResourceValue(valueResource);
// get the old property values
CmsProperty oldProperty = activeProperties.get(curPropDef.getName());
if (oldProperty == null) {
// property was not set, create new empty property object
oldProperty = new CmsProperty();
oldProperty.setName(curPropDef.getName());
}
boolean writeStructureValue = false;
boolean writeResourceValue = false;
String oldValue = oldProperty.getStructureValue();
String newValue = newProperty.getStructureValue();
// write the structure value if the existing structure value is not null and we want to delete the structure value
writeStructureValue = (oldValue != null && newProperty.isDeleteStructureValue());
// or if we want to write a value which is neither the delete value or an empty value
writeStructureValue |= !newValue.equals(oldValue)
&& !"".equalsIgnoreCase(newValue)
&& !CmsProperty.DELETE_VALUE.equalsIgnoreCase(newValue);
// set the structure value explicitly to null to leave it as is in the database
if (!writeStructureValue) {
newProperty.setStructureValue(null);
}
oldValue = oldProperty.getResourceValue();
newValue = newProperty.getResourceValue();
// write the resource value if the existing resource value is not null and we want to delete the resource value
writeResourceValue = (oldValue != null && newProperty.isDeleteResourceValue());
// or if we want to write a value which is neither the delete value or an empty value