Author: rhauch
Date: 2009-04-17 10:21:31 -0400 (Fri, 17 Apr 2009)
New Revision: 838
Modified:
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrI18n.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/SessionCache.java
trunk/dna-jcr/src/main/resources/org/jboss/dna/jcr/JcrI18n.properties
Log:
DNA-359 Session.refresh and Node.refresh Methods Not Supported
Applied the patch that figures out whether any nodes that were removed from the branch
were not deleted (meaning they were moved to another branch). Note that this does handle
the case where a node was moved to another parent within the branch being refreshed.
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrI18n.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrI18n.java 2009-04-17 13:54:29 UTC
(rev 837)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrI18n.java 2009-04-17 14:21:31 UTC
(rev 838)
@@ -83,6 +83,7 @@
public static I18n unableToSaveNodeThatWasCreatedSincePreviousSave;
public static I18n unableToSetMultiValuedPropertyUsingSingleValue;
public static I18n unableToSetSingleValuedPropertyUsingMultipleValues;
+ public static I18n
unableToRefreshBranchSinceAtLeastOneNodeMovedToParentOutsideOfBranch;
public static I18n allPropertyValuesMustHaveSameType;
public static I18n unableToRemoveRootNode;
@@ -126,7 +127,7 @@
public static I18n cannotRedefineProperty;
public static I18n autocreatedPropertyNeedsDefault;
public static I18n singleValuedPropertyNeedsSingleValuedDefault;
-
+
static {
try {
I18n.initialize(JcrI18n.class);
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-17 13:54:29
UTC (rev 837)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/SessionCache.java 2009-04-17 14:21:31
UTC (rev 838)
@@ -268,12 +268,10 @@
*/
public void refresh( UUID nodeUuid,
boolean keepChanges ) throws RepositoryException {
- // Find the path of the given node ...
- Path path = getPathFor(nodeUuid);
-
// Build the set of affected node UUIDs
Set<UUID> nodesUnderBranch = new HashSet<UUID>();
Stack<UUID> nodesToVisit = new Stack<UUID>();
+ Set<UUID> nodesRemovedFromBranch = new HashSet<UUID>();
nodesToVisit.add(nodeUuid);
while (!nodesToVisit.isEmpty()) {
@@ -283,7 +281,9 @@
NodeInfo nodeInfo = null;
ChangedNodeInfo changedInfo = this.changedNodes.get(uuid);
if (changedInfo != null) {
- nodesToVisit.addAll(changedInfo.getUuidsForRemovedChildren());
+ Collection<UUID> removedNodes =
changedInfo.getUuidsForRemovedChildren();
+ nodesToVisit.addAll(removedNodes);
+ nodesRemovedFromBranch.addAll(removedNodes);
nodeInfo = changedInfo;
} else {
nodeInfo = this.cachedNodes.get(uuid);
@@ -295,6 +295,23 @@
}
}
+ if (!nodesRemovedFromBranch.isEmpty()) {
+ // Skip any nodes that were moved from one parent to another within this
branch ...
+ nodesRemovedFromBranch.removeAll(nodesUnderBranch);
+ // Skip any nodes that were actually deleted (not moved)...
+ nodesRemovedFromBranch.removeAll(this.deletedNodes.keySet());
+ if (!nodesRemovedFromBranch.isEmpty()) {
+ // There was at least one node that was moved from this branch to another
parent outside this branch
+ Path path = getPathFor(nodeUuid);
+ String msg =
JcrI18n.unableToRefreshBranchSinceAtLeastOneNodeMovedToParentOutsideOfBranch.text(path,
+
workspaceName());
+ throw new RepositoryException(msg);
+ }
+ }
+
+ // Find the path of the given node ...
+ Path path = getPathFor(nodeUuid);
+
if (keepChanges) {
// Keep the pending operations
for (UUID uuid : nodesUnderBranch) {
Modified: trunk/dna-jcr/src/main/resources/org/jboss/dna/jcr/JcrI18n.properties
===================================================================
--- trunk/dna-jcr/src/main/resources/org/jboss/dna/jcr/JcrI18n.properties 2009-04-17
13:54:29 UTC (rev 837)
+++ trunk/dna-jcr/src/main/resources/org/jboss/dna/jcr/JcrI18n.properties 2009-04-17
14:21:31 UTC (rev 838)
@@ -73,6 +73,7 @@
unableToSaveNodeThatWasCreatedSincePreviousSave = Unable to save node "{0}" in
workspace "{1}" because it was created since the last save
unableToSetMultiValuedPropertyUsingSingleValue = Unable to set existing multi-valued
property "{0}" on node "{1}" in workspace "{2}" using
single-value setter methods
unableToSetSingleValuedPropertyUsingMultipleValues = Unable to set existing single-valued
property "{0}" on node "{1}" in workspace "{2}" using
multi-value setter methods
+unableToRefreshBranchSinceAtLeastOneNodeMovedToParentOutsideOfBranch = Unable to refresh
"{0}" in workspace "{2}" because at least one of its decendants was
moved to another node outside of the branch that is not being refreshed
allPropertyValuesMustHaveSameType = All values of property "{0}" on node
"{3}" in workspace "{4}" must all be {2} values (values were: {1})
unableToRemoveRootNode = Unable to remove the root node in workspace "{1}"
Show replies by date