jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r561000 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core: ItemImpl.java NodeImpl.java
Date Mon, 30 Jul 2007 14:51:48 GMT
Author: stefan
Date: Mon Jul 30 07:51:47 2007
New Revision: 561000

URL: http://svn.apache.org/viewvc?view=rev&rev=561000
Log:
JCR-1034: Unable to save session after saving a renamed node

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java?view=diff&rev=561000&r1=560999&r2=561000
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ItemImpl.java
Mon Jul 30 07:51:47 2007
@@ -1114,8 +1114,9 @@
                     NodeState nodeState = (NodeState) transientState;
                     Set dependentIDs = new HashSet();
                     if (nodeState.hasOverlayedState()) {
-                        NodeId oldParentId =
-                                nodeState.getOverlayedState().getParentId();
+                        NodeState overlayedState =
+                                (NodeState) nodeState.getOverlayedState();
+                        NodeId oldParentId = overlayedState.getParentId();
                         NodeId newParentId = nodeState.getParentId();
                         if (oldParentId != null) {
                             if (newParentId == null) {
@@ -1124,14 +1125,31 @@
                                 dependentIDs.add(oldParentId);
                             } else {
                                 if (!oldParentId.equals(newParentId)) {
-                                    // node has been moved, add old and new parent
-                                    // to dependencies
+                                    // node has been moved to a new location,
+                                    // add old and new parent to dependencies
                                     dependentIDs.add(oldParentId);
                                     dependentIDs.add(newParentId);
+                                } else {
+                                    // edge case: check whether definition id
+                                    // has changed (indicating that the node
+                                    // had been renamed, subsequently acquiring
+                                    // a new definition) (JCR-1034)
+                                    if (!nodeState.getDefinitionId().equals(
+                                            overlayedState.getDefinitionId())) {
+                                        // node has been renamed and as result
+                                        // got redefined, add parent to dependencies
+                                        dependentIDs.add(newParentId);
+                                    }
                                 }
                             }
                         }
                     }
+
+                    // note that there's no need to check removed/added
+                    // child node entries since those, being descendants, 
+                    // will automatically be included in the hierarchical
+                    // scope of this save operation.
+/*
                     // removed child node entries
                     for (Iterator cneIt =
                             nodeState.getRemovedChildNodeEntries().iterator();
@@ -1148,7 +1166,7 @@
                                 (NodeState.ChildNodeEntry) cneIt.next();
                         dependentIDs.add(cne.getId());
                     }
-
+  */
                     // now walk through dependencies and check whether they
                     // are within the scope of this save operation
                     Iterator depIt = dependentIDs.iterator();

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java?view=diff&rev=561000&r1=560999&r2=561000
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/NodeImpl.java
Mon Jul 30 07:51:47 2007
@@ -635,6 +635,10 @@
     }
 
     protected void onRedefine(NodeDefId defId) throws RepositoryException {
+        if (defId.equals(((NodeState) state).getDefinitionId())) {
+            // no change, ignore silently...
+            return;
+        }
         NodeDefinitionImpl newDef =
                 session.getNodeTypeManager().getNodeDefinition(defId);
         // modify the state of 'this', i.e. the target node



Mime
View raw message