jackrabbit-commits mailing list archives

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

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

Make the "discard everyting" mechanism more generic to improve performance and to avoid duplicate
code.

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/virtual/AbstractVISProvider.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=950598&r1=950597&r2=950598&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 15:28:51 2010
@@ -26,13 +26,10 @@ 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;
@@ -102,65 +99,16 @@ public class VirtualNodeTypeStateProvide
         return null;
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    public void onNodeTypeAdded(Name ntName) throws RepositoryException {
-        try {
-            VirtualNodeState root = (VirtualNodeState) getRootState();
-            QNodeTypeDefinition ntDef = ntReg.getNodeTypeDef(ntName);
-            VirtualNodeState ntState = createNodeTypeState(root, ntDef);
-            root.addChildNodeEntry(ntName, ntState.getNodeId());
-
-            // add as hard reference
-            root.addStateReference(ntState);
-            root.notifyStateUpdated();
-        } catch (ItemStateException e) {
-            throw new RepositoryException(e);
-        }
+    public void onNodeTypeAdded(Name ntName) {
+        discardAll(); // TODO: More efficient reloading
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    public void onNodeTypeModified(Name ntName) throws RepositoryException {
-        // todo: do more efficient reloading
-        try {
-            discardTree(getRootState());
-        } catch (ItemStateException e) {
-            throw new RepositoryException(e);
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void onNodeTypesRemoved(Collection<Name> names)
-            throws RepositoryException {
-        // todo: do more efficient reloading
-        try {
-            discardTree(getRootState());
-        } catch (ItemStateException e) {
-            throw new RepositoryException(e);
-        }
+    public void onNodeTypeModified(Name ntName) {
+        discardAll(); // TODO: More efficient reloading
     }
 
-    /**
-     * 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();
+    public void onNodeTypesRemoved(Collection<Name> names) {
+        discardAll(); // TODO: More efficient reloading
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/virtual/AbstractVISProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/virtual/AbstractVISProvider.java?rev=950598&r1=950597&r2=950598&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/virtual/AbstractVISProvider.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/virtual/AbstractVISProvider.java
Wed Jun  2 15:28:51 2010
@@ -192,6 +192,43 @@ public abstract class AbstractVISProvide
     }
 
     /**
+     * Discards all virtual item states and prepares for the root state
+     * to be recreated when next accessed.
+     *
+     * @see <a href="https://issues.apache.org/jira/browse/JCR-2617">JCR-2617</a>
+     */
+    protected synchronized void discardAll() {
+        if (root != null) {
+            discardTree(root);
+            root = null;
+        }
+    }
+
+    /**
+     * Recursively discards all the properties and nodes in the subtree
+     * rooted at the given node state.
+     *
+     * @param state root of the subtree to be discarded
+     */
+    private void discardTree(NodeState state) {
+        for (Name name : state.getPropertyNames()) {
+            try {
+                getItemState(new PropertyId(state.getNodeId(), name)).discard();
+            } catch (ItemStateException e) {
+                log.warn("Unable to discard virtual property " + name, e);
+            }
+        }
+        for (ChildNodeEntry entry : state.getChildNodeEntries()) {
+            try {
+                discardTree((NodeState) getItemState(entry.getId()));
+            } catch (ItemStateException e) {
+                log.warn("Unable to discard virtual node " + entry.getId(), e);
+            }
+        }
+        state.discard();
+    }
+
+    /**
      * Checks if this provide has the node state of the given node id
      *
      * @param id



Mime
View raw message