Map<String, Property> existing = getExistingProperties();
deleteMissingProperties(existing, properties);
Map<String, String> data = new LinkedHashMap<String, String>();
for (Map<String, String> property : properties) {
Property existingProp = existing.get(property.get("name"));
String escapedName = getEscapedPropertyName(property.get("name"));
String value = property.get("value");
String description = property.get("description");
final String unescapedValue = value.replaceAll("\\\\", "");
// the prop name can not contain .
// need to remove the . test when http://java.net/jira/browse/GLASSFISH-15418 is fixed
boolean canSaveDesc = property.get("name").indexOf(".") == -1;
if ((existingProp == null) || !unescapedValue.equals(existingProp.getValue())) {
data.put(escapedName, property.get("value"));
if (canSaveDesc && (description != null)) {
data.put(escapedName + ".description", description);
}
}
//update the description only if not null/blank
if ((description != null) && (existingProp != null)) {
if (!"".equals(description) && (!description.equals(existingProp.getDescription()))) {
if (canSaveDesc) {
data.put(escapedName + ".description", description);
}
}
}