jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tobias Bocanegra <tri...@day.com>
Subject Re: questions about clone and restore
Date Fri, 17 Apr 2009 12:59:19 GMT
hi Jeff,

> If I create a versionable node in one workspace and that node is subsequently
> modified multiple times in that workspace, is there any way to clone an
> earlier version of that node into another workspace?  My understanding of
> the Workspace.clone method is that it always clones the latest version of
> the node from the source workspace.  I'd like to be able to clone an earlier
> version in order to implement staged publishing.  In a "staging" workspace I
> want to be able to check in multiple versions of a node before it's every
> published to a "live" workspace, but then choose one of the earlier versions
> of that node to publish to "live".

cloning always pulls the same node to the workspace. cloning directly
an old version to the new workspace is not possible in one step. you
need to clone it first, and then restore it. for example:

Node srcNode = ....;
dstWsp.clone("staging", srcNode.getPath(), srcNode.getPath(), true);
Node dstNode = dstSession.getNodeByUUID(srcNode.getUUID());
dstNode.restoreByLabel("go-live");

> I'm also a bit confused by the Node.restoreByLabel method.  The name seems
> to imply that the node will be restored to an earlier version, but I am able
> to use it to "restore" to a later version as well.  Is this correct
> behavior?  The JSR-170 spec, so far as I can see, doesn't say one way or the
> other, though 15.7 of JSR-283 explicitly states that it's for restoring to a
> previous state.  As above, I'd like to use this method to publish a version
> of a node to the "live" workspace that is a successor to the current version
> in "live", but not necessarily the latest version.
in order to be able to use the restoreByLabel() you first need to
'tag' a version with one.
for example, in your code where you define the 'good' version to be published:

Node srcNode = ...
Version goodVersion = srcNode.checkin();
srcNode.getVersionHistory.addVersionLabel(goodVersion.getName(),
"go-live", true);

alternatively you can restore by version object or by version name.

regards, toby

Mime
View raw message