Correct handling of nulls and empty strings for PropertyBackedBeans (actually save empty strings)

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@14354 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Dave Ward
2009-05-18 16:57:54 +00:00
parent 4634d889c8
commit e31d630fde

View File

@@ -342,10 +342,6 @@ public class ChildApplicationContextFactory extends AbstractPropertyBackedBean i
{ {
updateCompositeProperty(name, value, type); updateCompositeProperty(name, value, type);
} }
else if (value == null)
{
this.properties.remove(name);
}
else else
{ {
this.properties.setProperty(name, value); this.properties.setProperty(name, value);
@@ -370,18 +366,12 @@ public class ChildApplicationContextFactory extends AbstractPropertyBackedBean i
Map<String, CompositeDataBean> propertyValues = this.compositeProperties.get(name); Map<String, CompositeDataBean> propertyValues = this.compositeProperties.get(name);
if (propertyValues == null) if (propertyValues == null)
{ {
if (value == null)
{
return;
}
propertyValues = Collections.emptyMap(); propertyValues = Collections.emptyMap();
} }
try try
{ {
Map<String, CompositeDataBean> newPropertyValues = new LinkedHashMap<String, CompositeDataBean>(11); Map<String, CompositeDataBean> newPropertyValues = new LinkedHashMap<String, CompositeDataBean>(11);
if (value != null)
{
StringTokenizer tkn = new StringTokenizer(value, ", \t\n\r\f"); StringTokenizer tkn = new StringTokenizer(value, ", \t\n\r\f");
while (tkn.hasMoreTokens()) while (tkn.hasMoreTokens())
{ {
@@ -403,7 +393,6 @@ public class ChildApplicationContextFactory extends AbstractPropertyBackedBean i
} }
newPropertyValues.put(id, child); newPropertyValues.put(id, child);
} }
}
// Destroy any children that have been removed // Destroy any children that have been removed
Set<String> idsToRemove = new TreeSet<String>(propertyValues.keySet()); Set<String> idsToRemove = new TreeSet<String>(propertyValues.keySet());