You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Bruno Dusausoy <br...@yp5.be> on 2011/04/26 15:22:09 UTC

JCR 2.0 Versioning

Hi,

I have a node of primary type "jcr:content" which is versionable 
("mix:simpleVersionable").

When I update it, I create a new version with the sequence :
1) checkout
2) modification
3) save
4) checkin

Everything is ok at this point, a new version is indeed created.
But when I look at the version history, like this :


Workspace workspace = session.getWorkspace();
VersionManager manager = workspace.getVersionManager();
VersionHistory history = 
manager.getVersionHistory("/1/instruction/jcr:content");

VersionIterator iter = history.getAllLinearVersions();
System.out.println(frozen.getProperty("jcr:data").getString());
while (iter.hasNext()) {
     Version v = iter.nextVersion();
     NodeIterator ni = v.getNodes();
     while (ni.hasNext()) {
         Node node = ni.nextNode();
         System.out.println(node.getName());
         for (PropertyIterator pi = node.getProperties(); pi.hasNext();){
             Property prop = pi.nextProperty();
             System.out.println("Property : " + prop.getName());
         }

     }
}

I get the result :

jcr:frozenNode
Property : jcr:frozenUuid
Property : jcr:uuid
Property : jcr:frozenPrimaryType
Property : jcr:frozenMixinTypes
Property : jcr:primaryType
jcr:frozenNode
Property : jcr:frozenUuid
Property : jcr:lastModifiedBy
Property : jcr:uuid
Property : jcr:data
Property : jcr:frozenPrimaryType
Property : jcr:lastModified
Property : jcr:frozenMixinTypes
Property : jcr:primaryType

What I'm interested in here is the jcr:data property, of course.
But as you can see in the output, there is no such property for the 
first one.

Here's the code snippet for the creation of this node :

content = instruction.addNode("jcr:content", "nt:resource");
content.addMixin("mix:simpleVersionable");
content.setProperty("jcr:data", new BinaryImpl(input));
session.save();

I've also tried with these lines after the session.save(); line :
VersionManager versionManager = workspace.getVersionManager();
versionManager.checkin(absPath);

(where absPath points to the right node, of course) but it doesn't work 
either.

Can someone tell me what I've missed ?

Regards.
-- 
Bruno Dusausoy
YP5 Software
--
Pensez environnement : limitez l'impression de ce mail.
Please don't print this e-mail unless you really need to.

Re: JCR 2.0 Versioning

Posted by Jukka Zitting <jz...@adobe.com>.
Hi,

On 26.04.2011 15:22, Bruno Dusausoy wrote:
> What I'm interested in here is the jcr:data property, of course. But
> as you can see in the output, there is no such property for the first
> one.

The first version is the "root version" that's essentially just an empty
node that gets created when you make the node versionable and its
version history is initialized. Then, when you call checkin() for the
first time, the first real version is created with content copied from
the versionable node.

-- 
Jukka Zitting