jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maikhorma <MHer...@NBME.org>
Subject Re: Versioning - How to cancel checkout
Date Fri, 09 Sep 2011 17:57:29 GMT

Stefan Hahn wrote:
> 
> How can I cancel checkout without creating a new version?
> 

This should work:
VersionManager vm = session.getWorkspace().getVersionManager();
vm.restore(vm.getBaseVersion(myNode.getPath()), true);

You may or may not need a session.save() first.

If you use rmi (like I do) that will throw a unsupported exception, the only
way around it that i've found is to use the old desupported way.  Seems to
work for me...
myNode.restore(myNode.getBaseVersion(), true);

Actually after a quick test it looks like this works which is slightly
better:
myNode.restore(vm.getBaseVersion((myNode.getPath())), true);

Side question that I've been wondering.  I think i understand why jcr2
changed from node.checkout(), but why are the versioning functions only by
path? It seems more natural to me that I could pass a node object, even if
all that does is node.getPath() (which is what JR's implementation does).  
Feels clunky that I keep converting the actual object to a string reference
that the other side is probably going to just get the object by the string. 
Of course there could be other implementations of the spec, but I'd bet most
do the same thing.  If anything I'd expect a string input would be a uid
rather than something that needs to be parsed.

--
View this message in context: http://jackrabbit.510166.n4.nabble.com/Versioning-How-to-cancel-checkout-tp3801494p3802387.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.

Mime
View raw message