Author: rhauch
Date: 2009-04-17 09:54:29 -0400 (Fri, 17 Apr 2009)
New Revision: 837
Modified:
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/SessionCache.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/ChangedNodeInfo.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrTckTest.java
Log:
DNA-359 Session.refresh and Node.refresh Methods Not Supported
Applied the second patch, which corrects how the nodes under the refreshed node are
computed (to also take into account nodes that were removed from the subgraph).
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/SessionCache.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/SessionCache.java 2009-04-16 17:50:46
UTC (rev 836)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/SessionCache.java 2009-04-17 13:54:29
UTC (rev 837)
@@ -280,10 +280,14 @@
UUID uuid = nodesToVisit.pop();
nodesUnderBranch.add(uuid);
- NodeInfo nodeInfo = cachedNodes.get(uuid);
- // Newly added nodes will be changedNodes but not cachedNodes
- if (nodeInfo == null) nodeInfo = changedNodes.get(uuid);
-
+ NodeInfo nodeInfo = null;
+ ChangedNodeInfo changedInfo = this.changedNodes.get(uuid);
+ if (changedInfo != null) {
+ nodesToVisit.addAll(changedInfo.getUuidsForRemovedChildren());
+ nodeInfo = changedInfo;
+ } else {
+ nodeInfo = this.cachedNodes.get(uuid);
+ }
if (nodeInfo != null) {
for (ChildNode childNode : nodeInfo.getChildren()) {
nodesToVisit.add(childNode.getUuid());
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/ChangedNodeInfo.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/ChangedNodeInfo.java 2009-04-16
17:50:46 UTC (rev 836)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/cache/ChangedNodeInfo.java 2009-04-17
13:54:29 UTC (rev 837)
@@ -23,6 +23,8 @@
*/
package org.jboss.dna.jcr.cache;
+import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
@@ -95,6 +97,15 @@
}
/**
+ * Return the original node information. May be null if this is a new node.
+ *
+ * @return the original node information
+ */
+ public NodeInfo getOriginal() {
+ return original;
+ }
+
+ /**
* {@inheritDoc}
*
* @see org.jboss.dna.jcr.cache.NodeInfo#getOriginalLocation()
@@ -195,6 +206,23 @@
}
/**
+ * Get the UUIDs for the children for this node that have been removed since the node
was last persisted.
+ *
+ * @return a collection of the UUIDs of the removed children; never null but possibly
empty
+ */
+ public Collection<UUID> getUuidsForRemovedChildren() {
+ if (original == null) return Collections.emptySet();
+
+ Set<UUID> removedChildren = new HashSet<UUID>();
+ for (ChildNode originalChildNode : original.getChildren()) {
+ if
(!this.changedChildren.childrenByUuid.containsKey(originalChildNode.getUuid())) {
+ removedChildren.add(originalChildNode.getUuid());
+ }
+ }
+ return removedChildren;
+ }
+
+ /**
* Add a child to the children. This method does nothing if the child is already in
the children.
*
* @param childName the name of the child that is to be added; may not be null
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrTckTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrTckTest.java 2009-04-16 17:50:46 UTC
(rev 836)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrTckTest.java 2009-04-17 13:54:29 UTC
(rev 837)
@@ -43,7 +43,11 @@
import org.apache.jackrabbit.test.api.NamespaceRegistryTest;
import org.apache.jackrabbit.test.api.NodeAddMixinTest;
import org.apache.jackrabbit.test.api.NodeCanAddMixinTest;
+import org.apache.jackrabbit.test.api.NodeItemIsModifiedTest;
+import org.apache.jackrabbit.test.api.NodeItemIsNewTest;
import org.apache.jackrabbit.test.api.NodeRemoveMixinTest;
+import org.apache.jackrabbit.test.api.PropertyItemIsModifiedTest;
+import org.apache.jackrabbit.test.api.PropertyItemIsNewTest;
import org.apache.jackrabbit.test.api.PropertyTest;
import org.apache.jackrabbit.test.api.RepositoryLoginTest;
import org.apache.jackrabbit.test.api.SessionUUIDTest;
@@ -213,12 +217,12 @@
addTestSuite(SetPropertyValueTest.class);
addTestSuite(SetPropertyConstraintViolationExceptionTest.class);
// addTestSuite(SetPropertyAssumeTypeTest.class);
- //
- // addTestSuite(NodeItemIsModifiedTest.class);
- // addTestSuite(NodeItemIsNewTest.class);
- // addTestSuite(PropertyItemIsModifiedTest.class);
- // addTestSuite(PropertyItemIsNewTest.class);
+ addTestSuite(NodeItemIsModifiedTest.class);
+ addTestSuite(NodeItemIsNewTest.class);
+ addTestSuite(PropertyItemIsModifiedTest.class);
+ addTestSuite(PropertyItemIsNewTest.class);
+
addTestSuite(NodeAddMixinTest.class);
addTestSuite(NodeCanAddMixinTest.class);
addTestSuite(NodeRemoveMixinTest.class);
Show replies by date