jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r393000 - /jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/NodeStateEx.java
Date Mon, 10 Apr 2006 17:53:30 GMT
Author: tripod
Date: Mon Apr 10 10:53:26 2006
New Revision: 393000

URL: http://svn.apache.org/viewcvs?rev=393000&view=rev
Log:
[JCR-374] Missing 'node removed' event when removing a version

Modified:
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/NodeStateEx.java

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/NodeStateEx.java
URL: http://svn.apache.org/viewcvs/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/NodeStateEx.java?rev=393000&r1=392999&r2=393000&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/NodeStateEx.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/version/NodeStateEx.java
Mon Apr 10 10:53:26 2006
@@ -294,8 +294,6 @@
         }
     }
 
-
-
     /**
      * checks if the given child node exists.
      *
@@ -331,8 +329,7 @@
             if (entry == null) {
                 return false;
             } else {
-                ItemState state = stateMgr.getItemState(entry.getId());
-                stateMgr.destroy(state);
+                removeNode(entry.getId());
                 nodeState.removeChildNodeEntry(name, index);
                 nodeState.setStatus(ItemState.STATUS_EXISTING_MODIFIED);
                 return true;
@@ -340,6 +337,37 @@
         } catch (ItemStateException e) {
             throw new RepositoryException(e);
         }
+    }
+
+    /**
+     * removes recursively the node with the given id
+     *
+     * @param id
+     * @throws ItemStateException
+     */
+    private void removeNode(NodeId id) throws ItemStateException {
+        NodeState state = (NodeState) stateMgr.getItemState(id);
+
+        // remove properties
+        Iterator iter = state.getPropertyNames().iterator();
+        while (iter.hasNext()) {
+            QName name = (QName) iter.next();
+            PropertyId propId = new PropertyId(id, name);
+            PropertyState propState = (PropertyState) stateMgr.getItemState(propId);
+            stateMgr.destroy(propState);
+        }
+        state.removeAllPropertyNames();
+
+        // remove child nodes
+        iter = state.getChildNodeEntries().iterator();
+        while (iter.hasNext()) {
+            NodeState.ChildNodeEntry entry = (NodeState.ChildNodeEntry) iter.next();
+            removeNode(entry.getId());
+        }
+        state.removeAllChildNodeEntries();
+
+        // destroy the state itself
+        stateMgr.destroy(state);
     }
 
     /**



Mime
View raw message