jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sch...@apache.org
Subject svn commit: r1327439 - in /jackrabbit/branches/2.4: ./ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/ jackrabbit-core/src/test/java/org/apache/jackrabbit/core/
Date Wed, 18 Apr 2012 10:08:45 GMT
Author: schans
Date: Wed Apr 18 10:08:45 2012
New Revision: 1327439

URL: http://svn.apache.org/viewvc?rev=1327439&view=rev
Log:
JCR-3290: Mix data inconsistency by correctly merging transient state with persistent overlayed
state (merge from trunk)

Added:
    jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/AddMoveTest.java
      - copied unchanged from r1324713, jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/AddMoveTest.java
Modified:
    jackrabbit/branches/2.4/   (props changed)
    jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeStateMerger.java
    jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java

Propchange: jackrabbit/branches/2.4/
------------------------------------------------------------------------------
  Merged /jackrabbit/trunk:r1324713

Modified: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeStateMerger.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeStateMerger.java?rev=1327439&r1=1327438&r2=1327439&view=diff
==============================================================================
--- jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeStateMerger.java
(original)
+++ jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/NodeStateMerger.java
Wed Apr 18 10:08:45 2012
@@ -44,6 +44,7 @@ class NodeStateMerger {
      * in order to avoid an <code>InvalidItemStateException</code>.
      * <p/>
      * See http://issues.apache.org/jira/browse/JCR-584.
+     * See also http://issues.apache.org/jira/browse/JCR-3290.
      *
      * @param state node state whose modified overlayed state should be
      *        merged
@@ -109,8 +110,8 @@ class NodeStateMerger {
                     ArrayList<ChildNodeEntry> removed = new ArrayList<ChildNodeEntry>();
 
                     for (ChildNodeEntry cne : state.getAddedChildNodeEntries()) {
-                        // locally added?
-                        if (context.isAdded(cne.getId()) || context.isModified(cne.getId()))
{
+                        // locally added or moved?
+                        if (context.isAdded(cne.getId()) || (context.isModified(cne.getId())
&& isParent(state, cne, context))) {
                             // a new child node entry has been added to this state;
                             // check for name collisions with other state
                             if (overlayedState.hasChildNodeEntry(cne.getName())) {
@@ -339,6 +340,14 @@ class NodeStateMerger {
         return false;
     }
 
+    private static boolean isParent(NodeState state, ChildNodeEntry entry, MergeContext context)
{
+        try {
+            return state.getId().equals(context.getNodeState(entry.getId()).getParentId());
+        } catch (ItemStateException e) {
+            return false;
+        }
+    }
+
     private static boolean isAutoCreated(ChildNodeEntry cne, EffectiveNodeType ent) {
         for (QNodeDefinition def : ent.getAutoCreateNodeDefs()) {
             if (def.getName().equals(cne.getName())) {
@@ -368,5 +377,6 @@ class NodeStateMerger {
         boolean isModified(ItemId id);
         boolean allowsSameNameSiblings(NodeId id);
         EffectiveNodeType getEffectiveNodeType(Name ntName) throws NoSuchNodeTypeException;
+        NodeState getNodeState(NodeId id) throws ItemStateException;
     }
 }

Modified: jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java?rev=1327439&r1=1327438&r2=1327439&view=diff
==============================================================================
--- jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
(original)
+++ jackrabbit/branches/2.4/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/SharedItemStateManager.java
Wed Apr 18 10:08:45 2012
@@ -650,7 +650,7 @@ public class SharedItemStateManager
                                             return ntReg.getEffectiveNodeType(ntName);
                                         }
 
-                                        protected NodeState getNodeState(NodeId id)
+                                        public NodeState getNodeState(NodeId id)
                                                 throws ItemStateException {
                                             if (local.has(id)) {
                                                 return (NodeState) local.get(id);
@@ -1312,7 +1312,7 @@ public class SharedItemStateManager
                 }
 
                 if (!(parentId == null && oldParentId == null)
-                        && !parentId.equals(oldParentId)) {
+                        && (parentId != null && !parentId.equals(oldParentId)))
{
                     // This node (not the root) has been moved; check
                     // whether the parent has been modified as well
                     if (changeLog.has(parentId)) {
@@ -1397,7 +1397,7 @@ public class SharedItemStateManager
             if (sharedSet.contains(expectedParent)) {
                 return;
             }
-            String message = "Child node has another parent id " + parentId + ", expected
" + expectedParent;
+            String message = "Child node " + childState.getId() + " has another parent id
" + parentId + ", expected " + expectedParent;
             log.error(message);
             throw new ItemStateException(message);
         }



Mime
View raw message