jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Seypt <st...@web.de>
Subject rootVersion property bug?
Date Wed, 15 Nov 2006 19:02:22 GMT
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();
         }
     }
}

Mime
View raw message