jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Lubos and Alena Pochman" <pochm...@gmail.com>
Subject Cannot update previous version of nt:file node
Date Thu, 15 Mar 2007 02:52:24 GMT
I create nt:file node like:

        Node root = session.getRootNode();
        document = root.addNode(instanceName, "nt:file");
        document.addMixin("mix:versionable");  // Make document referencable
and versionable
        Node content = document.addNode("jcr:content", "nt:resource");
        content.setProperty("jcr:mimeType", "application/zip");
        content.setProperty("jcr:data", new
ByteArrayInputStream(zipContents));
        content.setProperty("jcr:lastModified", Calendar.getInstance());
        this.session.save();

Then I create a new version like:

        document.checkout();
        Node content = (Node)document.getPrimaryItem();
        content.setProperty("jcr:data", new
ByteArrayInputStream(zipContents));
        content.setProperty("jcr:lastModified", Calendar.getInstance());
        this.session.save();
        document.checkin();

Then I try to retrieve current version data (that works OK):

        node = this.session.getNodeByUUID(id);
        Property prop = node.getProperty("jcr:content/jcr:data");
        InputStream is = prop.getStream();

But then I try to retrieve previous version of the node, it fails with
"PathNotFoundException: jcr:frozenNode/jcr:content/jcr:data" exception when
calling getProperty("jcr:frozenNode/jcr:content/jcr:data"):

            Node document = this.session.getNodeByUUID(id);
            Version base = document.getBaseVersion();
            Version[] predecessors = base.getPredecessors();
             for (int i = 0; i < predecessors.length; i++) {
                       System.out.println(predecessors[i].getCreated() + ":
"
                               +
predecessors[i].getProperty("jcr:frozenNode/jcr:content/jcr:data").getLength());

How do I access and read properties of previous versions of a node?

Thanks, Lubos

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message