jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r219511 - in /incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/version: InternalVersionHistoryImpl.java VersionManagerImpl.java
Date Mon, 18 Jul 2005 15:26:07 GMT
Author: tripod
Date: Mon Jul 18 08:25:49 2005
New Revision: 219511

URL: http://svn.apache.org/viewcvs?rev=219511&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/InternalVersionHistoryImpl.java
    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/InternalVersionHistoryImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/version/InternalVersionHistoryImpl.java?rev=219511&r1=219510&r2=219511&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/version/InternalVersionHistoryImpl.java
(original)
+++ incubator/jackrabbit/trunk/core/src/java/org/apache/jackrabbit/core/version/InternalVersionHistoryImpl.java
Mon Jul 18 08:25:49 2005
@@ -426,22 +426,26 @@
     static InternalVersionHistoryImpl create(VersionManagerImpl vMgr,
                                              NodeStateEx parent,
                                              String historyId, QName name,
-                                             NodeState nodeState)
+                                             NodeState nodeState,
+                                             List created)
             throws RepositoryException {
 
         // create history node
         NodeStateEx pNode = parent.addNode(name, NT_VERSIONHISTORY, historyId, true);
+        created.add(pNode.getUUID());
 
         // set the versionable uuid
         pNode.setPropertyValue(JCR_VERSIONABLEUUID, InternalValue.create(nodeState.getUUID()));
 
         // create label node
-        pNode.addNode(JCR_VERSIONLABELS, NT_VERSIONLABELS, null, false);
+        NodeStateEx lNode = pNode.addNode(JCR_VERSIONLABELS, NT_VERSIONLABELS, null, false);
+        created.add(lNode.getUUID());
 
         // create root version
         String versionId = UUID.randomUUID().toString();
 
         NodeStateEx vNode = pNode.addNode(JCR_ROOTVERSION, NT_VERSION, versionId, true);
+        created.add(vNode.getUUID());
 
         // initialize 'created' and 'predecessors'
         vNode.setPropertyValue(JCR_CREATED, InternalValue.create(Calendar.getInstance()));
@@ -450,7 +454,8 @@
 
         // add also an empty frozen node to the root version
         NodeStateEx node = vNode.addNode(JCR_FROZENNODE, NT_FROZENNODE, null, true);
-
+        created.add(node.getUUID());
+        
         // initialize the internal properties
         node.setPropertyValue(JCR_FROZENUUID, InternalValue.create(nodeState.getUUID()));
         node.setPropertyValue(JCR_FROZENPRIMARYTYPE,

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=219511&r1=219510&r2=219511&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
Mon Jul 18 08:25:49 2005
@@ -62,6 +62,7 @@
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
+import java.util.LinkedList;
 
 /**
  * This Class implements a VersionManager.
@@ -189,7 +190,8 @@
     public VersionHistory createVersionHistory(Session session, NodeState node)
             throws RepositoryException {
 
-        InternalVersionHistory history = createVersionHistory(node);
+        List created = new LinkedList();
+        InternalVersionHistory history = createVersionHistory(created, node);
         if (history == null) {
             throw new VersionException("History already exists for node " + node.getUUID());
         }
@@ -197,16 +199,13 @@
 
         // generate observation events
         List events = new ArrayList();
-        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);
+        Iterator iter = created.iterator();
+        while (iter.hasNext()) {
+            String uuid = (String) iter.next();
+            NodeImpl child = (NodeImpl) ((SessionImpl) session).getItemManager().getItem(new
NodeId(uuid));
+            generateAddedEvents(events, (NodeImpl) child.getParent(), child, false);
         }
         obsMgr.dispatch(events, (SessionImpl) session);
-
         return vh;
     }
 
@@ -226,11 +225,12 @@
     /**
      * Creates a new Version History.
      *
+     * @param created a list for adding the uuids of the newly created nodes
      * @param node the node for which the version history is to be initialized
      * @return the newly created version history.
      * @throws RepositoryException
      */
-    private InternalVersionHistory createVersionHistory(NodeState node)
+    private InternalVersionHistory createVersionHistory(List created, NodeState node)
             throws RepositoryException {
 
         try {
@@ -248,7 +248,8 @@
             for (int i = 0; i < 3; i++) {
                 QName name = new QName(NS_DEFAULT_URI, uuid.substring(i * 2, i * 2 + 2));
                 if (!root.hasNode(name)) {
-                    root.addNode(name, REP_VERSIONSTORAGE, null, false);
+                    NodeStateEx n = root.addNode(name, REP_VERSIONSTORAGE, null, false);
+                    created.add(n.getUUID());
                     root.store();
                 }
                 root = root.getNode(name, 1);
@@ -260,7 +261,7 @@
             }
 
             // create new history node in the persistent state
-            InternalVersionHistoryImpl hist = InternalVersionHistoryImpl.create(this, root,
UUID.randomUUID().toString(), historyNodeName, node);
+            InternalVersionHistoryImpl hist = InternalVersionHistoryImpl.create(this, root,
UUID.randomUUID().toString(), historyNodeName, node, created);
 
             // end update
             stateMgr.update();



Mime
View raw message