jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r950579 - /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java
Date Wed, 02 Jun 2010 14:37:28 GMT
Author: jukka
Date: Wed Jun  2 14:37:28 2010
New Revision: 950579

URL: http://svn.apache.org/viewvc?rev=950579&view=rev
Log:
JCR-2617: ItemStateMap warnings during node type changes

Need to discard the entire /jcr:system/jcr:nodeTypes subtree instead of just the root when
the node types change. Otherwise we'll see cache collisions when new items are being created
to override the previous ones.

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java?rev=950579&r1=950578&r2=950579&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java
Wed Jun  2 14:37:28 2010
@@ -26,10 +26,13 @@ import javax.jcr.RepositoryException;
 import javax.jcr.version.OnParentVersionAction;
 
 import org.apache.jackrabbit.core.id.NodeId;
+import org.apache.jackrabbit.core.id.PropertyId;
 import org.apache.jackrabbit.core.nodetype.NodeTypeRegistry;
 import org.apache.jackrabbit.core.state.ChangeLog;
+import org.apache.jackrabbit.core.state.ChildNodeEntry;
 import org.apache.jackrabbit.core.state.ItemStateException;
 import org.apache.jackrabbit.core.state.NoSuchItemStateException;
+import org.apache.jackrabbit.core.state.NodeState;
 import org.apache.jackrabbit.core.value.InternalValue;
 import org.apache.jackrabbit.core.virtual.AbstractVISProvider;
 import org.apache.jackrabbit.core.virtual.VirtualNodeState;
@@ -123,7 +126,7 @@ public class VirtualNodeTypeStateProvide
     public void onNodeTypeModified(Name ntName) throws RepositoryException {
         // todo: do more efficient reloading
         try {
-            getRootState().discard();
+            discardTree(getRootState());
         } catch (ItemStateException e) {
             throw new RepositoryException(e);
         }
@@ -136,13 +139,31 @@ public class VirtualNodeTypeStateProvide
             throws RepositoryException {
         // todo: do more efficient reloading
         try {
-            getRootState().discard();
+            discardTree(getRootState());
         } catch (ItemStateException e) {
             throw new RepositoryException(e);
         }
     }
 
     /**
+     * Recursively discards all the properties and nodes in the subtree
+     * rooted at the given node state.
+     *
+     * @see <a href="https://issues.apache.org/jira/browse/JCR-2617">JCR-2617</a>
+     * @param state root of the subtree to be discarded
+     * @throws ItemStateException if items in the subtree can not be accessed
+     */
+    private void discardTree(NodeState state) throws ItemStateException {
+        for (Name name : state.getPropertyNames()) {
+            getItemState(new PropertyId(state.getNodeId(), name)).discard();
+        }
+        for (ChildNodeEntry entry : state.getChildNodeEntries()) {
+            discardTree((NodeState) getItemState(entry.getId()));
+        }
+        state.discard();
+    }
+
+    /**
      * Creates a node type state
      *
      * @param parent



Mime
View raw message