You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Sridhar Raman <sr...@gmail.com> on 2007/12/08 14:24:17 UTC

Doubt in Versioning

This is what I have figured out from reading the documentation, and testing:
The following code,
Node A = root.addNode("NODEA", "ATYPE");

A.checkout();
A.setProperty("PROP1", "some value");

A.save();
A.checkin();

creates a version for the node A, and currently the node is in a read-only
status.

Now if I were to execute the following code,
Node A = root.getNode("NODEA");

A.checkout();
A.setProperty("PROP1", "some other different value");

A.save();
// NOT DOING ANY CHECK-IN

I expected no new version to be created for node A.  And yes, this happens
as expected.
But say, I execute this code now,
Node A = root.getNode("NODEA");

A.checkout();
System.out.println(A.getProperty("PROP1").getString());

I expected the value "some value" to be printed.  This was because, I
thought the checkout that I do would mean that I get node A's latest
version.  But what is printed is "some other different value".

I somehow found this a bit counter-intuitive.  Can someone please clarify my
doubt?

Thanks,
Sridhar

Re: Doubt in Versioning

Posted by Tobias Bocanegra <to...@day.com>.
> This means that in case, I do a save() operation, and the system crashes
> before the checkin() happens, the next time I bring up the server, I would
> get the non checked-in version (unless of course I do a restore())?
no.

> Also, if on bringing up the server, without doing a server, and then making
> changes, I save and checkin successfully, the version that I wanted to
> checkin (but couldn't because of the crash) will be lost right?
no.

> I am just curious.  Would this mean that in my CMS, every time I bring up
> the server, do I see to it that all the versionable nodes are restored to
> their base versions, if the versioned data is very important to me?  I want
> to make sure this is recommended, so that I can proceed with this
> implementation.  Or is there any other solution?
>
> Also, just a small thought.  Wouldn't it be more convenient if, for
> versionable nodes, a save() operation ALSO did the checkin as well?  Or are
> there some issues with this?

The versioning does not work that way. whenever you save() the state
of an item it is persisted to the underlying datastructure independent
if the node is versionable or not. so if your server crashes after you
saved the item, it won't be lost.

you only need versioning if you want to be able to archive and restore
former versions of content.
usually node are not versioned every time there is a modification, but
at the end of more highlevel step, i.e. after you're done making all
modifications to several nodes and properties of a CMS page, before
publishing, etc.

regards, toby
-- 
-----------------------------------------< 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: Doubt in Versioning

Posted by Sridhar Raman <sr...@gmail.com>.
This means that in case, I do a save() operation, and the system crashes
before the checkin() happens, the next time I bring up the server, I would
get the non checked-in version (unless of course I do a restore())?

Also, if on bringing up the server, without doing a server, and then making
changes, I save and checkin successfully, the version that I wanted to
checkin (but couldn't because of the crash) will be lost right?

I am just curious.  Would this mean that in my CMS, every time I bring up
the server, do I see to it that all the versionable nodes are restored to
their base versions, if the versioned data is very important to me?  I want
to make sure this is recommended, so that I can proceed with this
implementation.  Or is there any other solution?

Also, just a small thought.  Wouldn't it be more convenient if, for
versionable nodes, a save() operation ALSO did the checkin as well?  Or are
there some issues with this?

Thanks,
Sridhar

On Dec 8, 2007 9:25 PM, Tobias Bocanegra <to...@day.com> wrote:

> hi,
> what you want is 'Node.restore()'.  checkout just makes as checked-in
> node modifiable.
> in your example the 2nd checkout has no effect since the node is
> already checked out.
>
> regards, toby
>
> On 12/8/07, Sridhar Raman <sr...@gmail.com> wrote:
> > This is what I have figured out from reading the documentation, and
> testing:
> > The following code,
> > Node A = root.addNode("NODEA", "ATYPE");
> >
> > A.checkout();
> > A.setProperty("PROP1", "some value");
> >
> > A.save();
> > A.checkin();
> >
> > creates a version for the node A, and currently the node is in a
> read-only
> > status.
> >
> > Now if I were to execute the following code,
> > Node A = root.getNode("NODEA");
> >
> > A.checkout();
> > A.setProperty("PROP1", "some other different value");
> >
> > A.save();
> > // NOT DOING ANY CHECK-IN
> >
> > I expected no new version to be created for node A.  And yes, this
> happens
> > as expected.
> > But say, I execute this code now,
> > Node A = root.getNode("NODEA");
> >
> > A.checkout();
> > System.out.println(A.getProperty("PROP1").getString());
> >
> > I expected the value "some value" to be printed.  This was because, I
> > thought the checkout that I do would mean that I get node A's latest
> > version.  But what is printed is "some other different value".
> >
> > I somehow found this a bit counter-intuitive.  Can someone please
> clarify my
> > doubt?
> >
> > Thanks,
> > Sridhar
> >
>
>
> --
> -----------------------------------------< 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: Doubt in Versioning

Posted by Tobias Bocanegra <to...@day.com>.
hi,
what you want is 'Node.restore()'.  checkout just makes as checked-in
node modifiable.
in your example the 2nd checkout has no effect since the node is
already checked out.

regards, toby

On 12/8/07, Sridhar Raman <sr...@gmail.com> wrote:
> This is what I have figured out from reading the documentation, and testing:
> The following code,
> Node A = root.addNode("NODEA", "ATYPE");
>
> A.checkout();
> A.setProperty("PROP1", "some value");
>
> A.save();
> A.checkin();
>
> creates a version for the node A, and currently the node is in a read-only
> status.
>
> Now if I were to execute the following code,
> Node A = root.getNode("NODEA");
>
> A.checkout();
> A.setProperty("PROP1", "some other different value");
>
> A.save();
> // NOT DOING ANY CHECK-IN
>
> I expected no new version to be created for node A.  And yes, this happens
> as expected.
> But say, I execute this code now,
> Node A = root.getNode("NODEA");
>
> A.checkout();
> System.out.println(A.getProperty("PROP1").getString());
>
> I expected the value "some value" to be printed.  This was because, I
> thought the checkout that I do would mean that I get node A's latest
> version.  But what is printed is "some other different value".
>
> I somehow found this a bit counter-intuitive.  Can someone please clarify my
> doubt?
>
> Thanks,
> Sridhar
>


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