This content has been marked as final.
Show 1 reply
-
1. Re: ConstraintViolationException when restoring a nt:file node
hchiorean Jul 15, 2015 5:19 AM (in response to jkraushaar)I don't understand what you're trying to do: you're getting the base version of a file, then removing that file, creating a new version of the owning folder (checkout/checkin) and then attempting to restore the base version of the file, even though you haven't created a version of that file in the first place. This makes no sense to me.
However, some things you should keep in mind:
- the base version of a new versionable node is initially the root version, *which is always an empty version* (as per the JCR spec 3.13.5.2). Never attempt to restore the root version of a node which has mandatory properties/child nodes (like your case)
- if you have a (parent -> child) relationship and both nodes have mix:versionable and OPV VERSION (which is the default) calling checkin(parent) will behave differently in terms of the child graph than when OPV is COPY. You should look at JSR 283 #3.13.9 Versionable State
You're getting this exception because you're attempting to restore an invalid version of a file which hasn't been properly versioned in the first place. Because of this the [jcr:content] mandatory child node of [nt:file] is not present anywhere in the versions graph. You'll find more information on how full versioning works in section 3.13 of the JCR 2.0 spec.