Update of /var/cvs/src/org/mmbase/core/event
In directory james.mmbase.org:/tmp/cvs-serv20751
Modified Files:
Tag: MMBase-1_8
NodeEventHelper.java
Log Message:
fix for MMB-1553 was not good, because it tried to edit unmodifiable maps
See also: http://cvs.mmbase.org/viewcvs/src/org/mmbase/core/event
See also: http://www.mmbase.org/jira/browse/MMB-1553
Index: NodeEventHelper.java
===================================================================
RCS file: /var/cvs/src/org/mmbase/core/event/NodeEventHelper.java,v
retrieving revision 1.6.2.1
retrieving revision 1.6.2.2
diff -u -b -r1.6.2.1 -r1.6.2.2
--- NodeEventHelper.java 3 Feb 2008 16:58:11 -0000 1.6.2.1
+++ NodeEventHelper.java 7 Feb 2008 16:14:38 -0000 1.6.2.2
@@ -44,21 +44,22 @@
//fill the old and new values maps for the event
switch(eventType) {
case Event.TYPE_NEW:
- newEventValues = Collections.unmodifiableMap(node.getValues());
+ newEventValues = removeBinaryValues(node.getValues());
oldEventValues = Collections.EMPTY_MAP;
break;
case Event.TYPE_CHANGE:
- oldEventValues = Collections.unmodifiableMap(node.getOldValues());
+ oldEventValues = removeBinaryValues(node.getOldValues());
newEventValues = new HashMap();
Map values = node.getValues();
for(Iterator i = oldEventValues.keySet().iterator(); i.hasNext();
) {
Object key = i.next();
newEventValues.put(key, values.get(key));
}
+ newEventValues = removeBinaryValues(newEventValues);
break;
case Event.TYPE_DELETE:
newEventValues = Collections.EMPTY_MAP;
- oldEventValues = Collections.unmodifiableMap(node.getValues());
+ oldEventValues = removeBinaryValues(node.getValues());
break;
default: {
oldEventValues = Collections.EMPTY_MAP;
@@ -67,18 +68,27 @@
}
}
- removeBinaryValues(oldEventValues);
- removeBinaryValues(newEventValues);
-
return new NodeEvent(machineName, node.getBuilder().getTableName(),
node.getNumber(), oldEventValues, newEventValues, eventType);
}
- private static void removeBinaryValues(Map oldEventValues) {
+ private static Map removeBinaryValues(Map oldEventValues) {
+ Set toremove = null;
for (Iterator iterator = oldEventValues.entrySet().iterator();
iterator.hasNext();) {
Map.Entry entry = (Map.Entry) iterator.next();
if (entry.getValue() != null && (entry.getValue() instanceof
byte[])) {
- entry.setValue(null);
+ if (toremove == null) toremove = new HashSet();
+ toremove.add(entry.getKey());
+ }
}
+ if (toremove != null) {
+ Map newMap = new HashMap();
+ newMap.putAll(oldEventValues);
+ for (Iterator iterator = toremove.iterator(); iterator.hasNext();)
{
+ newMap.remove(iterator.next());
+ }
+ return Collections.unmodifiableMap(newMap);
+ } else {
+ return oldEventValues;
}
}
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs