You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by "Niu, Xuetao" <Xu...@fiserv.com> on 2010/02/05 17:42:18 UTC

How to get the versionable node from its fronzen node?

Hello,

 

I am looking through the version history of a versionable node, and I
don't have a reference to the versionable node. How can I find the
versionable node from the frozen nodes in its versioning history?

 

Thanks!

Xuetao


Re: How to get the versionable node from its fronzen node?

Posted by Robert Campbell <rr...@gmail.com>.
I'd like to open this thread back up because we're performing the
exact operation Sébastien outlined, but we're getting the
ItemNotFoundException from JCR-134 in Jackrabbit 2.1.1.

In our case the versionable node was not removed, but rather just
added for the first time. We have registered listeners with the for
NODE_ADDED events on the "/jcr:system/jcr:versionStorage" path.
Basically we're listening for new versions being added. When a new
_versionable_ node is added, the onEvent in the listeners is correctly
invoked based on a new _version_ (frozen) node being added for that
head/versionable node. When we run Sébastien's code to retrieve the
headNode from the frozenNode, we get an ItemNotFoundException.
Curiously, adding a Thread.sleep() actually solves the problem, so
there must be some transient/race condition occurring. Here is the
code:

            final Node frozenNode = getNodeBy(forzenNodePath, session);
            final String headNodeIdentifier =
frozenNode.getProperty(Property.JCR_FROZEN_UUID)
                    .getString();
            Thread.sleep(20000);
            session.refresh(true);
            return session.getNodeByIdentifier(headNodeIdentifier).getPath();

Is this a bug? Or are we simply doing something incorrectly?

- Rob Campbell


On Fri, Feb 5, 2010 at 8:24 PM, Sébastien Launay
<se...@gmail.com> wrote:
> Hi,
>
> 2010/2/5 Niu, Xuetao <Xu...@fiserv.com>:
>> Hello,
>>
>> I am looking through the version history of a versionable node, and I
>> don't have a reference to the versionable node. How can I find the
>> versionable node from the frozen nodes in its versioning history
>
> You can retrieve the versionable node from the frozenNode with the
> following code:
> Node headNode =
> session.getNodeByIdentifier(frozenNode.getProperty("jcr:frozenUuid"));
> // use session.getNodeByUUID with JCR 1.0
>
> This code might throw an ItemNotFoundException if the "head" node has
> been removed but still has versions in the history, see [1] for more information
> about this.
>
> [1] http://issues.apache.org/jira/browse/JCR-134
>
> --
> Sébastien Launay
>

Re: How to get the versionable node from its fronzen node?

Posted by Sébastien Launay <se...@gmail.com>.
Hi,

2010/2/5 Niu, Xuetao <Xu...@fiserv.com>:
> Hello,
>
> I am looking through the version history of a versionable node, and I
> don't have a reference to the versionable node. How can I find the
> versionable node from the frozen nodes in its versioning history

You can retrieve the versionable node from the frozenNode with the
following code:
Node headNode =
session.getNodeByIdentifier(frozenNode.getProperty("jcr:frozenUuid"));
// use session.getNodeByUUID with JCR 1.0

This code might throw an ItemNotFoundException if the "head" node has
been removed but still has versions in the history, see [1] for more information
about this.

[1] http://issues.apache.org/jira/browse/JCR-134

-- 
Sébastien Launay