Shared nodes and Versioning
bwallis42 Feb 28, 2012 12:34 AMI seem to have found a problem when using shared nodes in a tree with mix:versionable on the root node. The CND i'm using is:
{code}
[A] > mix:versionable
- name (string) copy
+ b (B) multiple copy
+ c (C) multiple copy
[B]
- name (string) copy
+ c (C) multiple copy
[C] > mix:shareable
- name (string) copy
{code}
When I run the following bit of code (I'll include the full code as an attachment) with an existing simple tree of nodes that is /a/b/c I get a ConstraintViolationException.
{code}
71: versionManager.checkout(a.getPath());
72: workspace.clone(workspace.getName(), c.getPath(), "/a/c", false);
73: versionManager.checkin(a.getPath());
{code}
The code is trying to clone the node at /a/b/c to /a/c which should create a shared node that is at both /a/b/c and at /a/c. The clone operation works fine but I get the exception at the line that does the checkin.
The error is:
{code}
javax.jcr.nodetype.ConstraintViolationException: Cannot find a definition for the child node named 'c' on the node at '/a' with primary type 'A' and mixin types: []
at org.modeshape.jcr.SessionCache.save(SessionCache.java:509)
at org.modeshape.jcr.AbstractJcrNode.save(AbstractJcrNode.java:2256)
at org.modeshape.jcr.JcrVersionManager.checkin(JcrVersionManager.java:384)
at org.modeshape.jcr.JcrVersionManager.checkin(JcrVersionManager.java:1738)
at au.com.infomedix.documentstore.cnd.TestSharedVersioned.main(TestSharedVersioned.java:73)
Caused by: org.modeshape.graph.session.ValidationException: Cannot find a definition for the child node named 'c' on the node at '/a' with primary type 'A' and mixin types: []
at org.modeshape.jcr.SessionCache$JcrNodeOperations.preSave(SessionCache.java:2930)
at org.modeshape.graph.session.GraphSession$4.finishParentAfterLoading(GraphSession.java:1115)
at org.modeshape.graph.session.GraphSession$LoadAllChildrenVisitor.finish(GraphSession.java:3449)
at org.modeshape.graph.session.GraphSession$Node.onChangedNodes(GraphSession.java:3182)
at org.modeshape.graph.session.GraphSession.save(GraphSession.java:1112)
at org.modeshape.jcr.SessionCache.save(SessionCache.java:507)
... 4 more
{code}
If I change the type of the child node c in node A to "nt:base" then the error goes away and it works as expected.
ie:
{code}
[A] > mix:versionable
- name (string) copy
+ b (B) multiple copy
+ c (nt:base) multiple copy
{code}
-
simple-shared.cnd.zip 239 bytes
-
TestSharedVersioned.java.zip 1.2 KB