views:

163

answers:

1

Hello.
I am using Jackrabbit and I have the following question:
I have a parent node P and a child node C. Both P and C are versionable. At some point in my code I need to get data from a previous version V of P, so I use getVersionHistory().getVersion(V).getNode("jcr:frozennode") in order to get the version I need. In this version however, the child of node P is no longer node C but a reference to C's version history, therefore I don't know the exact state C was in while P's version was V. So the question is, is there a way to determine which versions of C correspond to the version of P I have retrieved (by "correspond" I mean were active at the same time). I understand that since both P and C are versionable and therefore can be checked-out/checked-in independently there might not be a single version of C corresponding to a version of P, so I would expect to get a sub-set of C's version history which contains the versions C went through while P was in version V.
Thank you,
Christina

A: 

You could use timestamps added to all nodes to determine which versions where assosciated at a given time.

EDIT: The "proper" way is probably to checkout a complete subtree by version. Check also these links:

http://www.day.com/specs/jcr/2.0/3_Repository_Model.html#VersionableState

Or this tutorial: http://jtoee.com/jsr-170/the_jcr_primer/5/

CND docs: http://jackrabbit.apache.org/node-type-notation.html

stacker
Thanks for the suggestion, but I was actually looking if there was a way to get this information "properly" through jcr methods, without having to do such a workaround.
Christina
So what you are saying is that in the above scenario I should not checkout node C independently but always checkout node P even if I don't want to modify any of its other children? This effectively means that I'm going to always checkout the root of each versionable tree even for a modification in a single node way down the tree; it doesn't sound very efficient...When I revert P to a previous version V, C also gets reverted to a version relative to V, so I guess that the functionality I'm looking for is there. The question is if it is available to jackrabbit users or just jackrabbit itself.
Christina