jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tobias Bocanegra" <tobias.bocane...@day.com>
Subject Re: rootVersion property bug?
Date Thu, 16 Nov 2006 10:39:02 GMT
the rootVersion never has content and is rather a sentinel for the
version history. it is created when a new mix:versionable node is
created or when a node gets a mix:versionable mixin.

if you want to restore the contents, you first need to do a checkin.
regards, toby

On 11/15/06, Steve Seypt <st6v6@web.de> wrote:
> I want to get the original contend of a node property.
> I wonder why the rootVersion doesn't has the requested property.
>
> What am i doing wrong?
>
> Here is my code:
>
> import java.io.IOException;
> import javax.jcr.*;
> import javax.jcr.version.*;
> import org.apache.jackrabbit.core.TransientRepository;
>
> /*
>   * output:
>   * -------
>   * testnode: old
>   * version "jcr:rootVersion": -
>   * version "1.0": new
>   *
>   */
>
> public class Property {
>      public static void main(String[] args) {
>          Session session = null;
>          try {
>              // login
>              Repository repository = new TransientRepository();
>              session = repository.login(
>                      new SimpleCredentials("username",
> "password".toCharArray()));
>              // create testnode
>              Node root = session.getRootNode();
>              Node test = root.addNode("test");
>              test.addMixin("mix:versionable");
>              test.setProperty("edit", "old");
>              session.save();
>              System.out.println ("testnode: " +
> test.getProperty("edit").getString());
>              // change testnode
>              test.checkout();
>              test.setProperty("edit", "new");
>              session.save();
>              test.checkin();
>              // print out testnode
>              VersionHistory history = test.getVersionHistory();
>              VersionIterator vi = history.getAllVersions();
>              Version v = null;
>              Node n = null;
>              while (vi.hasNext()) {
>                 v = vi.nextVersion();
>                 n = v.getNode("jcr:frozenNode");
>                 System.out.print ("version \"" + v.getName() + "\": ");
>                 if (n.hasProperty("edit")) {
>                     System.out.print (n.getProperty("edit").getString());
>                 } else {
>                     System.out.print("-");
>                 }
>                 System.out.println("");
>              }
>              // delete testnode
>              test.remove();
>              session.save();
>          } catch (IOException e) {
>              e.printStackTrace();
>          } catch (RepositoryException e) {
>              e.printStackTrace();
>          } finally {
>              //logout
>              session.logout();
>          }
>      }
> }
>


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

Mime
View raw message