jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r219336 - /incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
Date Sat, 16 Jul 2005 16:07:23 GMT
Author: tripod
Date: Sat Jul 16 09:07:18 2005
New Revision: 219336

URL: http://svn.apache.org/viewcvs?rev=219336&view=rev
Log:
[#JCR-168] Observation events are not triggered for intermediate nodes in version storage

Modified:
    incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java

Modified: incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java?rev=219336&r1=219335&r2=219336&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
(original)
+++ incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/version/VersionManagerImpl.java
Sat Jul 16 09:07:18 2005
@@ -197,7 +197,14 @@
 
         // generate observation events
         List events = new ArrayList();
-        recursiveAdd(events, (NodeImpl) vh.getParent(), vh);
+        NodeImpl parent = (NodeImpl) vh.getParent();
+        generateAddedEvents(events, parent, vh, true);
+        // in case the history was created 'deep' also add events for its ancestors
+        while (!parent.internalGetUUID().equals(historyRoot.getUUID())) {
+            NodeImpl child = parent;
+            parent = (NodeImpl) parent.getParent();
+            generateAddedEvents(events, parent, child, false);
+        }
         obsMgr.dispatch(events, (SessionImpl) session);
 
         return vh;
@@ -420,7 +427,7 @@
 
         // generate observation events
         List events = new ArrayList();
-        recursiveAdd(events, (NodeImpl) v.getParent(), v);
+        generateAddedEvents(events, (NodeImpl) v.getParent(), v, true);
         obsMgr.dispatch(events, session);
 
         return v;
@@ -526,7 +533,7 @@
         SessionImpl session = (SessionImpl) history.getSession();
         VersionImpl version = (VersionImpl) ((VersionHistoryImpl) history).getNode(name);
         List events = new ArrayList();
-        recursiveRemove(events, (NodeImpl) history, version);
+        generateRemovedEvents(events, (NodeImpl) history, version, true);
 
         InternalVersionHistoryImpl vh = (InternalVersionHistoryImpl)
                 ((VersionHistoryImpl) history).getInternalVersionHistory();
@@ -633,7 +640,8 @@
      * @param node
      * @throws RepositoryException
      */
-    private void recursiveAdd(List events, NodeImpl parent, NodeImpl node)
+    private void generateAddedEvents(List events, NodeImpl parent, NodeImpl node,
+                                     boolean recursive)
             throws RepositoryException {
 
         events.add(EventState.childNodeAdded(
@@ -656,10 +664,12 @@
                     node.getSession()
             ));
         }
-        NodeIterator niter = node.getNodes();
-        while (niter.hasNext()) {
-            NodeImpl n = (NodeImpl) niter.nextNode();
-            recursiveAdd(events, node, n);
+        if (recursive) {
+            NodeIterator niter = node.getNodes();
+            while (niter.hasNext()) {
+                NodeImpl n = (NodeImpl) niter.nextNode();
+                generateAddedEvents(events, node, n, true);
+            }
         }
     }
 
@@ -671,7 +681,8 @@
      * @param node
      * @throws RepositoryException
      */
-    private void recursiveRemove(List events, NodeImpl parent, NodeImpl node)
+    private void generateRemovedEvents(List events, NodeImpl parent,
+                                       NodeImpl node, boolean recursive)
             throws RepositoryException {
 
         events.add(EventState.childNodeRemoved(
@@ -682,10 +693,12 @@
                 (NodeTypeImpl) parent.getPrimaryNodeType(),
                 node.getSession()
         ));
-        NodeIterator niter = node.getNodes();
-        while (niter.hasNext()) {
-            NodeImpl n = (NodeImpl) niter.nextNode();
-            recursiveRemove(events, node, n);
+        if (recursive) {
+            NodeIterator niter = node.getNodes();
+            while (niter.hasNext()) {
+                NodeImpl n = (NodeImpl) niter.nextNode();
+                generateRemovedEvents(events, node, n, true);
+            }
         }
     }
 



Mime
View raw message