Author: bcarothers
Date: 2009-05-27 19:10:00 -0400 (Wed, 27 May 2009)
New Revision: 939
Modified:
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrWorkspace.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/SessionCache.java
Log:
DNA-437 TCK Tests Fail on Workspace.copy
Applied a patch that adds a check that the final segment in the destination path does not
have a SNS index on it and also attempts to check that SNS constraints on the parent node
of the destination are met. The SNS check will not function properly if multiple workspace
operations are performed without a refresh, but it's an incremental improvement over
the current state.
This fixes 3 test cases in the nightly TCK test, but doesn't allow us to uncomment any
additional tests in the CI TCK test yet.
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrWorkspace.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrWorkspace.java 2009-05-22 18:34:30
UTC (rev 938)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrWorkspace.java 2009-05-27 23:10:00
UTC (rev 939)
@@ -60,6 +60,7 @@
import org.jboss.dna.jcr.JcrContentHandler.EnclosingSAXException;
import org.jboss.dna.jcr.JcrContentHandler.SaveMode;
import org.jboss.dna.jcr.JcrRepository.Option;
+import org.jboss.dna.jcr.cache.NodeInfo;
import org.xml.sax.ContentHandler;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
@@ -284,8 +285,25 @@
throw new RepositoryException(JcrI18n.invalidPathParameter.text(destAbsPath,
"destAbsPath"), e);
}
+ // Doing a literal test here because the path factory will canonicalize
"/node[1]" to "/node"
+ if (destAbsPath.endsWith("]")) {
+ throw new RepositoryException();
+ }
+
+ /*
+ * Make sure that the node has a definition at the new location
+ */
+ SessionCache cache = this.session.cache();
+ NodeInfo nodeInfo = cache.findNodeInfo(null, srcPath);
+ NodeInfo parent = cache.findNodeInfo(null, destPath.getParent());
+
+ // This throws a ConstraintViolationException if there is no matching definition
+ // In practice, this won't always work until we figure out how to refresh the
destination parent's cache entry
+ cache.findBestNodeDefinition(parent.getUuid(),
destPath.getLastSegment().getName(), nodeInfo.getPrimaryTypeName());
+
// Perform the copy operation, but use the "to" form (not the
"into", which takes the parent) ...
graph.copy(srcPath).to(destPath);
+
}
/**
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-05-22 18:34:30
UTC (rev 938)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/SessionCache.java 2009-05-27 23:10:00
UTC (rev 939)
@@ -514,7 +514,8 @@
List<Name> mixinTypeNames = node.getMixinTypeNames();
Children children = nodeInfo.getChildren();
- int snsCount = children.getCountOfSameNameSiblingsWithName(newNodeName);
+ // Need to add one to speculate that this node will be added
+ int snsCount = children.getCountOfSameNameSiblingsWithName(newNodeName) + 1;
JcrNodeDefinition definition =
nodeTypes().findChildNodeDefinition(primaryTypeName,
mixinTypeNames,
newNodeName,
Show replies by date