You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by Oliver Wehrens <we...@aei.mpg.de> on 2006/04/03 12:02:28 UTC

Restore a version of a node property

Hi,

Apologies if this is not a real Jackrabbit Developer question.

I have a node with properties and a couple of versions of it. Now I want to
extract from a particular version a specific property. Do I see that right,
that the only way of getting the versioned property is to restore the node
(in a different location to not to overwrite the current version and not to
force a new version). Is there any way to avoid that ? I just need the
content of the property I do not want to restore the whole node.

Does anybody know a real JCR 170 Mailinglist ? Or jackrabbit-users ?

Thanks, Oliver

-- 
Oliver Wehrens
+49 170 785 1323
http://wehrens.net/oliver







Re: Restore a version of a node property

Posted by Oliver Wehrens <we...@aei.mpg.de>.
Thanks a lot.

Oliver


On 05.04.2006 12:07 Uhr, "Tobias Bocanegra" <to...@day.com>
wrote:

> you need to checkin first:
> 
> node = session.getRootNode().addNode("entry");
> node.addMixin("mix:versionable");
> node.setProperty("content", "1");
> node.getSession.save();
> node.checkin()   <---------------------
> 
> node.checkout();
> node.setProperty("content", "2");
> node.save();
> node.checkin();
> 
> 
> On 4/4/06, Oliver Wehrens <we...@aei.mpg.de> wrote:
>> Hi,
>> 
>> I did read it (but obviously not careful enough) ;-).
>> 
>> If I create a node with a property like:
>> 
>> node = session.getRootNode().addNode("entry");
>> node.addMixin("mix:versionable");
>> node.setProperty("content", "1");
>> node.getSession.save();
>> 
>> node.checkout();
>> node.setProperty("content", "2");
>> node.save();
>> node.checkin();
>> 
>> 
>> Now Version 1.0 of this node contains the property content with the value
>> "2".  How do I get to "1" ? What I did as workaround, I created an empty
>> node and check it out and change the property and check in it again. Now I
>> can access the very first version.
>> 
>> Oliver
>> 
>> On 04.04.2006 12:57 Uhr, "Tobias Bocanegra" <to...@day.com>
>> wrote:
>> 
>>>> This described method works fine for me, however how do I get a property of
>>>> the rootNode of the history? As far as I can see it starts with the first
>>>> revision but not with the original node I saved in the very beginning...
>>> when a new versionable node is created, it also creates the respective
>>> version-history node in the version storage. i also creates a
>>> root-version, which is empty. the root-version simply acts as
>>> 'sentinel' for the 'jcr:predecessors' and 'jcr:baseVersion'
>>> references. when you
>>> checkin the node, it's content get copied into the 1.0 version in the
>>> version storage (according to the OnParentVersion) properties.
>>> 
>>> read the versioning chapter of jsr170 for a more detailed explanation.
>>> regards, toby
>>> 
>>> 
>>>> 
>>>> Anybody got an idea?
>>>> 
>>>> Thanks, Oliver
>>>> 
>>>> 
>>>> 
>>>> On 03.04.2006 21:33 Uhr, "David Gillen" <da...@pnl.gov> wrote:
>>>> 
>>>>> Tobias Bocanegra <tobias.bocanegra <at> day.com> writes:
>>>>>> 
>>>>>> hi oliver,
>>>>>> you can access the content of the version directly in the
>>>>>> jcr:versionStorage.
>>>>>> either by searching for your version, or by using the version history:
>>>>>> 
>>>>>> node.getVersionHistory().getVersion(xyz).getNode
>>>>> ("jcr:frozenNode").getProperty("yourprop");
>>>>>> 
>>>>> 
>>>>> 
>>>>> Hello,
>>>>> 
>>>>> I have the same issue as the original poster, and I'm having trouble
>>>>> making
>>>>> the suggestion above work
>>>>> for me.  I keep getting:
>>>>> 
>>>>> javax.jcr.PathNotFoundException: myprop
>>>>> at org.apache.jackrabbit.core.NodeImpl.getProperty(NodeImpl.java:2423)
>>>>> 
>>>>> where myprop is the name of the property I'm trying to retrieve.  When I
>>>>> run
>>>>> through a debugger, and look at the propertyNames HashMap within the
>>>>> NodeState
>>>>> belonging to the node of the older version, I don't see any property names
>>>>> listed that I created, only property names that look internal to
>>>>> Jackrabbit.
>>>>> 
>>>>> I can provide source code that demonstrates this problem.  Any ideas?
>>>>> 
>>>>>> regards, toby
>>>>> 
>>>>> -Dave
>>>>> 
>>>>> 
>>>> 
>>>> --
>>>> Oliver Wehrens
>>>> +49 170 785 1323
>>>> http://wehrens.net/oliver
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>> 
>>> 
>>> --
>>> -----------------------------------------< tobias.bocanegra@day.com >---
>>> Tobias Bocanegra, Day Management AG, Barfuesserplatz 6, CH - 4001 Basel
>>> T +41 61 226 98 98, F +41 61 226 98 97
>>> -----------------------------------------------< http://www.day.com >---
>>> 
>> 
>> --
>> Oliver Wehrens
>> +49 170 785 1323
>> http://wehrens.net/oliver
>> 
>> 
>> 
>> 
>> 
>> 
>> 
> 
> 
> --
> -----------------------------------------< tobias.bocanegra@day.com >---
> Tobias Bocanegra, Day Management AG, Barfuesserplatz 6, CH - 4001 Basel
> T +41 61 226 98 98, F +41 61 226 98 97
> -----------------------------------------------< http://www.day.com >---
> 

-- 
Oliver Wehrens
+49 170 785 1323
http://wehrens.net/oliver







Re: Restore a version of a node property

Posted by Tobias Bocanegra <to...@day.com>.
you need to checkin first:

node = session.getRootNode().addNode("entry");
node.addMixin("mix:versionable");
node.setProperty("content", "1");
node.getSession.save();
node.checkin()   <---------------------

node.checkout();
node.setProperty("content", "2");
node.save();
node.checkin();


On 4/4/06, Oliver Wehrens <we...@aei.mpg.de> wrote:
> Hi,
>
> I did read it (but obviously not careful enough) ;-).
>
> If I create a node with a property like:
>
> node = session.getRootNode().addNode("entry");
> node.addMixin("mix:versionable");
> node.setProperty("content", "1");
> node.getSession.save();
>
> node.checkout();
> node.setProperty("content", "2");
> node.save();
> node.checkin();
>
>
> Now Version 1.0 of this node contains the property content with the value
> "2".  How do I get to "1" ? What I did as workaround, I created an empty
> node and check it out and change the property and check in it again. Now I
> can access the very first version.
>
> Oliver
>
> On 04.04.2006 12:57 Uhr, "Tobias Bocanegra" <to...@day.com>
> wrote:
>
> >> This described method works fine for me, however how do I get a property of
> >> the rootNode of the history? As far as I can see it starts with the first
> >> revision but not with the original node I saved in the very beginning...
> > when a new versionable node is created, it also creates the respective
> > version-history node in the version storage. i also creates a
> > root-version, which is empty. the root-version simply acts as
> > 'sentinel' for the 'jcr:predecessors' and 'jcr:baseVersion'
> > references. when you
> > checkin the node, it's content get copied into the 1.0 version in the
> > version storage (according to the OnParentVersion) properties.
> >
> > read the versioning chapter of jsr170 for a more detailed explanation.
> > regards, toby
> >
> >
> >>
> >> Anybody got an idea?
> >>
> >> Thanks, Oliver
> >>
> >>
> >>
> >> On 03.04.2006 21:33 Uhr, "David Gillen" <da...@pnl.gov> wrote:
> >>
> >>> Tobias Bocanegra <tobias.bocanegra <at> day.com> writes:
> >>>>
> >>>> hi oliver,
> >>>> you can access the content of the version directly in the
> >>>> jcr:versionStorage.
> >>>> either by searching for your version, or by using the version history:
> >>>>
> >>>> node.getVersionHistory().getVersion(xyz).getNode
> >>> ("jcr:frozenNode").getProperty("yourprop");
> >>>>
> >>>
> >>>
> >>> Hello,
> >>>
> >>> I have the same issue as the original poster, and I'm having trouble making
> >>> the suggestion above work
> >>> for me.  I keep getting:
> >>>
> >>> javax.jcr.PathNotFoundException: myprop
> >>> at org.apache.jackrabbit.core.NodeImpl.getProperty(NodeImpl.java:2423)
> >>>
> >>> where myprop is the name of the property I'm trying to retrieve.  When I run
> >>> through a debugger, and look at the propertyNames HashMap within the
> >>> NodeState
> >>> belonging to the node of the older version, I don't see any property names
> >>> listed that I created, only property names that look internal to Jackrabbit.
> >>>
> >>> I can provide source code that demonstrates this problem.  Any ideas?
> >>>
> >>>> regards, toby
> >>>
> >>> -Dave
> >>>
> >>>
> >>
> >> --
> >> Oliver Wehrens
> >> +49 170 785 1323
> >> http://wehrens.net/oliver
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >
> >
> > --
> > -----------------------------------------< tobias.bocanegra@day.com >---
> > Tobias Bocanegra, Day Management AG, Barfuesserplatz 6, CH - 4001 Basel
> > T +41 61 226 98 98, F +41 61 226 98 97
> > -----------------------------------------------< http://www.day.com >---
> >
>
> --
> Oliver Wehrens
> +49 170 785 1323
> http://wehrens.net/oliver
>
>
>
>
>
>
>


--
-----------------------------------------< tobias.bocanegra@day.com >---
Tobias Bocanegra, Day Management AG, Barfuesserplatz 6, CH - 4001 Basel
T +41 61 226 98 98, F +41 61 226 98 97
-----------------------------------------------< http://www.day.com >---

Re: Restore a version of a node property

Posted by Oliver Wehrens <we...@aei.mpg.de>.
Hi,

I did read it (but obviously not careful enough) ;-).

If I create a node with a property like:

node = session.getRootNode().addNode("entry");
node.addMixin("mix:versionable");
node.setProperty("content", "1");
node.getSession.save();

node.checkout();
node.setProperty("content", "2");
node.save();
node.checkin();


Now Version 1.0 of this node contains the property content with the value
"2".  How do I get to "1" ? What I did as workaround, I created an empty
node and check it out and change the property and check in it again. Now I
can access the very first version.

Oliver

On 04.04.2006 12:57 Uhr, "Tobias Bocanegra" <to...@day.com>
wrote:

>> This described method works fine for me, however how do I get a property of
>> the rootNode of the history? As far as I can see it starts with the first
>> revision but not with the original node I saved in the very beginning...
> when a new versionable node is created, it also creates the respective
> version-history node in the version storage. i also creates a
> root-version, which is empty. the root-version simply acts as
> 'sentinel' for the 'jcr:predecessors' and 'jcr:baseVersion'
> references. when you
> checkin the node, it's content get copied into the 1.0 version in the
> version storage (according to the OnParentVersion) properties.
> 
> read the versioning chapter of jsr170 for a more detailed explanation.
> regards, toby
> 
> 
>> 
>> Anybody got an idea?
>> 
>> Thanks, Oliver
>> 
>> 
>> 
>> On 03.04.2006 21:33 Uhr, "David Gillen" <da...@pnl.gov> wrote:
>> 
>>> Tobias Bocanegra <tobias.bocanegra <at> day.com> writes:
>>>> 
>>>> hi oliver,
>>>> you can access the content of the version directly in the
>>>> jcr:versionStorage.
>>>> either by searching for your version, or by using the version history:
>>>> 
>>>> node.getVersionHistory().getVersion(xyz).getNode
>>> ("jcr:frozenNode").getProperty("yourprop");
>>>> 
>>> 
>>> 
>>> Hello,
>>> 
>>> I have the same issue as the original poster, and I'm having trouble making
>>> the suggestion above work
>>> for me.  I keep getting:
>>> 
>>> javax.jcr.PathNotFoundException: myprop
>>> at org.apache.jackrabbit.core.NodeImpl.getProperty(NodeImpl.java:2423)
>>> 
>>> where myprop is the name of the property I'm trying to retrieve.  When I run
>>> through a debugger, and look at the propertyNames HashMap within the
>>> NodeState
>>> belonging to the node of the older version, I don't see any property names
>>> listed that I created, only property names that look internal to Jackrabbit.
>>> 
>>> I can provide source code that demonstrates this problem.  Any ideas?
>>> 
>>>> regards, toby
>>> 
>>> -Dave
>>> 
>>> 
>> 
>> --
>> Oliver Wehrens
>> +49 170 785 1323
>> http://wehrens.net/oliver
>> 
>> 
>> 
>> 
>> 
>> 
>> 
> 
> 
> --
> -----------------------------------------< tobias.bocanegra@day.com >---
> Tobias Bocanegra, Day Management AG, Barfuesserplatz 6, CH - 4001 Basel
> T +41 61 226 98 98, F +41 61 226 98 97
> -----------------------------------------------< http://www.day.com >---
> 

-- 
Oliver Wehrens
+49 170 785 1323
http://wehrens.net/oliver







Re: Restore a version of a node property

Posted by Tobias Bocanegra <to...@day.com>.
> This described method works fine for me, however how do I get a property of
> the rootNode of the history? As far as I can see it starts with the first
> revision but not with the original node I saved in the very beginning...
when a new versionable node is created, it also creates the respective
version-history node in the version storage. i also creates a
root-version, which is empty. the root-version simply acts as
'sentinel' for the 'jcr:predecessors' and 'jcr:baseVersion'
references. when you
checkin the node, it's content get copied into the 1.0 version in the
version storage (according to the OnParentVersion) properties.

read the versioning chapter of jsr170 for a more detailed explanation.
regards, toby


>
> Anybody got an idea?
>
> Thanks, Oliver
>
>
>
> On 03.04.2006 21:33 Uhr, "David Gillen" <da...@pnl.gov> wrote:
>
> > Tobias Bocanegra <tobias.bocanegra <at> day.com> writes:
> >>
> >> hi oliver,
> >> you can access the content of the version directly in the jcr:versionStorage.
> >> either by searching for your version, or by using the version history:
> >>
> >> node.getVersionHistory().getVersion(xyz).getNode
> > ("jcr:frozenNode").getProperty("yourprop");
> >>
> >
> >
> > Hello,
> >
> > I have the same issue as the original poster, and I'm having trouble making
> > the suggestion above work
> > for me.  I keep getting:
> >
> > javax.jcr.PathNotFoundException: myprop
> > at org.apache.jackrabbit.core.NodeImpl.getProperty(NodeImpl.java:2423)
> >
> > where myprop is the name of the property I'm trying to retrieve.  When I run
> > through a debugger, and look at the propertyNames HashMap within the NodeState
> > belonging to the node of the older version, I don't see any property names
> > listed that I created, only property names that look internal to Jackrabbit.
> >
> > I can provide source code that demonstrates this problem.  Any ideas?
> >
> >> regards, toby
> >
> > -Dave
> >
> >
>
> --
> Oliver Wehrens
> +49 170 785 1323
> http://wehrens.net/oliver
>
>
>
>
>
>
>


--
-----------------------------------------< tobias.bocanegra@day.com >---
Tobias Bocanegra, Day Management AG, Barfuesserplatz 6, CH - 4001 Basel
T +41 61 226 98 98, F +41 61 226 98 97
-----------------------------------------------< http://www.day.com >---

Re: Restore a version of a node property

Posted by Tobias Bocanegra <to...@day.com>.
whats the 'on parent version' value of the respective property definition?
can you send a test-case?

thanks.
regards, toby

On 5/31/06, Markus Krüger <kr...@ion.ag> wrote:
> Hello, I have the same issue as David.
>
> I get the PathNotFoundException on any of my properties (in my case it is a
> proptery for an author named jcr:author). Are there any solutions to this
> problem, yet?
>
> Best regards,
>
> Markus Krüger
>
>


-- 
-----------------------------------------< tobias.bocanegra@day.com >---
Tobias Bocanegra, Day Management AG, Barfuesserplatz 6, CH - 4001 Basel
T +41 61 226 98 98, F +41 61 226 98 97
-----------------------------------------------< http://www.day.com >---

Re: Restore a version of a node property

Posted by Markus Krüger <kr...@ion.ag>.
Hello, I have the same issue as David.

I get the PathNotFoundException on any of my properties (in my case it is a
proptery for an author named jcr:author). Are there any solutions to this
problem, yet?

Best regards,

Markus Krüger


Re: Restore a version of a node property

Posted by Oliver Wehrens <we...@aei.mpg.de>.
Hi,

This described method works fine for me, however how do I get a property of
the rootNode of the history? As far as I can see it starts with the first
revision but not with the original node I saved in the very beginning...

Anybody got an idea?

Thanks, Oliver



On 03.04.2006 21:33 Uhr, "David Gillen" <da...@pnl.gov> wrote:

> Tobias Bocanegra <tobias.bocanegra <at> day.com> writes:
>> 
>> hi oliver,
>> you can access the content of the version directly in the jcr:versionStorage.
>> either by searching for your version, or by using the version history:
>> 
>> node.getVersionHistory().getVersion(xyz).getNode
> ("jcr:frozenNode").getProperty("yourprop");
>> 
> 
> 
> Hello,
> 
> I have the same issue as the original poster, and I'm having trouble making
> the suggestion above work
> for me.  I keep getting:
> 
> javax.jcr.PathNotFoundException: myprop
> at org.apache.jackrabbit.core.NodeImpl.getProperty(NodeImpl.java:2423)
> 
> where myprop is the name of the property I'm trying to retrieve.  When I run
> through a debugger, and look at the propertyNames HashMap within the NodeState
> belonging to the node of the older version, I don't see any property names
> listed that I created, only property names that look internal to Jackrabbit.
> 
> I can provide source code that demonstrates this problem.  Any ideas?
> 
>> regards, toby
> 
> -Dave
> 
> 

-- 
Oliver Wehrens
+49 170 785 1323
http://wehrens.net/oliver







Re: Restore a version of a node property

Posted by David Gillen <da...@pnl.gov>.
Tobias Bocanegra <tobias.bocanegra <at> day.com> writes:
> 
> hi oliver,
> you can access the content of the version directly in the jcr:versionStorage.
> either by searching for your version, or by using the version history:
> 
> node.getVersionHistory().getVersion(xyz).getNode
("jcr:frozenNode").getProperty("yourprop");
> 


Hello,

I have the same issue as the original poster, and I'm having trouble making 
the suggestion above work 
for me.  I keep getting:

javax.jcr.PathNotFoundException: myprop
	at org.apache.jackrabbit.core.NodeImpl.getProperty(NodeImpl.java:2423)

where myprop is the name of the property I'm trying to retrieve.  When I run 
through a debugger, and look at the propertyNames HashMap within the NodeState 
belonging to the node of the older version, I don't see any property names 
listed that I created, only property names that look internal to Jackrabbit.

I can provide source code that demonstrates this problem.  Any ideas?

> regards, toby

-Dave



Re: Restore a version of a node property

Posted by Tobias Bocanegra <to...@day.com>.
hi oliver,
you can access the content of the version directly in the jcr:versionStorage.
either by searching for your version, or by using the version history:

node.getVersionHistory().getVersion(xyz).getNode("jcr:frozenNode").getProperty("yourprop");

regards, toby

btw: see http://jackrabbit.apache.org/mail-lists.html for a list of
available mailing lists.


On 4/3/06, Oliver Wehrens <we...@aei.mpg.de> wrote:
> Hi,
>
> Apologies if this is not a real Jackrabbit Developer question.
>
> I have a node with properties and a couple of versions of it. Now I want to
> extract from a particular version a specific property. Do I see that right,
> that the only way of getting the versioned property is to restore the node
> (in a different location to not to overwrite the current version and not to
> force a new version). Is there any way to avoid that ? I just need the
> content of the property I do not want to restore the whole node.
>
> Does anybody know a real JCR 170 Mailinglist ? Or jackrabbit-users ?
>
> Thanks, Oliver
>
> --
> Oliver Wehrens
> +49 170 785 1323
> http://wehrens.net/oliver
>
>
>
>
>
>
>


--
-----------------------------------------< tobias.bocanegra@day.com >---
Tobias Bocanegra, Day Management AG, Barfuesserplatz 6, CH - 4001 Basel
T +41 61 226 98 98, F +41 61 226 98 97
-----------------------------------------------< http://www.day.com >---