jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexander Klimetschek <aklim...@day.com>
Subject Re: Help on versioning
Date Thu, 17 Sep 2009 07:47:43 GMT
On Thu, Sep 17, 2009 at 04:04, freak182 <eman.nollase@gmail.com> wrote:
>
> Hello,
>
> given the scenario:
>
>  Node file = folder.addNode(name, "nt:file");
>  file.addMixin(JcrConstants.MIX_VERSIONABLE);
>
>  Node fileContent = file.addNode("jcr:content", "nt:resource");
>  fileContent.addMixin(JcrConstants.MIX_REFERENCEABLE);
>  fileContent.setProperty("jcr:mimeType", mimeType);
>  fileContent.setProperty("jcr:lastModified", Calendar.getInstance());
>  fileContent.setProperty("jcr:data", fileStream);
>  session.save();
>  file.checkin();
>
> ...in that line of code im saving the first version of my picture...but a
> bit later i modify a picture such i add some text inside the picture and now
> i want to save it as next version. Is saving would be same except for i will
> checking out the old node and checking the new fileStream?
>
>  String clildpath = path + name;
>  Node child = rootNode.getNode(clildpath);
>  fileContent.setProperty("jcr:data", fileStream); --> assuming this is new
> fileStream for previous image
>  session.save();
>  file.checkin();
>
> ...is this the correct way?

Yes, if you set the jcr:data property on the jcr:content subnode of
the nt:file node. The jcr:content child node definition of nt:file has
a OnParentVersion = COPY, which will check it in as well if you check
in the nt:file node. In your code I can see child, fileContent and
file nodes, seems a bit mixed up ;-)

Regards,
Alex

-- 
Alexander Klimetschek
alexander.klimetschek@day.com

Mime
View raw message