Update of /var/cvs/applications/richtext/src/org/mmbase/richtext/processors/xml
In directory james.mmbase.org:/tmp/cvs-serv4849

Modified Files:
        Wiki.java 
Log Message:
made it work beter in transactions


See also: 
http://cvs.mmbase.org/viewcvs/applications/richtext/src/org/mmbase/richtext/processors/xml


Index: Wiki.java
===================================================================
RCS file: 
/var/cvs/applications/richtext/src/org/mmbase/richtext/processors/xml/Wiki.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- Wiki.java   10 Jun 2008 11:35:19 -0000      1.13
+++ Wiki.java   15 Jul 2008 10:00:59 -0000      1.14
@@ -29,7 +29,7 @@
  * id of the node).
  *
  * @author Michiel Meeuwissen
- * @version $Id: Wiki.java,v 1.13 2008/06/10 11:35:19 michiel Exp $
+ * @version $Id: Wiki.java,v 1.14 2008/07/15 10:00:59 michiel Exp $
  * @todo something goes wrong if same node relation multiple times.
  */
 
@@ -153,6 +153,7 @@
      *
      */
     Document parse(Node editedNode, Field field, Document source) {
+        Cloud cloud = editedNode.getCloud();
 
         String fieldName = field.getName();
         Set<String> usedIds = new HashSet<String>();
@@ -162,10 +163,18 @@
             log.debug("Resolving " + editedNode + " " + 
XMLWriter.write(source, true));
         }
 
-        Cloud cloud = editedNode.getCloud();
+
+        // In a transaction, the query will not return our new nodes.
+        // Administrate related idrels ourselves.
+        NodeList createdLinks = (NodeList) cloud.getProperty("createdlinks");
+        if (createdLinks == null) {
+            createdLinks = cloud.createNodeList();
         NodeManager objects = cloud.getNodeManager("object");
         NodeQuery q = Queries.createRelationNodesQuery(editedNode, objects, 
"idrel", "destination");
         NodeList links = cloud.getNodeManager("idrel").getList(q);
+            createdLinks.addAll(links);
+            cloud.setProperty("createdlinks", createdLinks);
+        }
 
         // search all anchors
         org.w3c.dom.NodeList as = source.getElementsByTagName("*");
@@ -179,7 +188,7 @@
             a.removeAttribute("class");
             String id = a.getAttribute("id");
             if ("".equals(id)) continue;
-            Node link = findById(a, links, fieldName, usedIds);
+            Node link = findById(a, createdLinks, fieldName, usedIds);
             if (link == null) {
 
                 log.service("No relation found with id '" + id + "'. 
Implicitely creating one now.");
@@ -191,6 +200,7 @@
                         newRel.setStringValue("id", decoratedId);
                         newRel.setStringValue("class", className);
                         newRel.commit();
+                        createdLinks.add(newRel);
                         a.setAttribute("id", decoratedId);
                         usedIds.add(decoratedId);
                     } catch (Exception e) {
_______________________________________________
Cvs mailing list
Cvs@lists.mmbase.org
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to