You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Jeff Yemin <je...@gmail.com> on 2009/04/17 02:50:21 UTC

questions about clone and restore

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".

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.


Thanks,
Jeff


-- 
View this message in context: http://www.nabble.com/questions-about-clone-and-restore-tp23088566p23088566.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


Re: questions about clone and restore

Posted by Tobias Bocanegra <tr...@day.com>.
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