You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Sunil Dhage <su...@coreobjects.com> on 2009/09/18 13:14:05 UTC
Versioning problem
Hi,
I have a structure of
Root-> dept ->emp->photo-> content-> some properties. One of the property holds photo of the employee.
I have a requirement of storing versions of employee photos.
I have added mix:versionable property to content node.
Its not adding to repository. On commenting of the version related stuff(beginning with * in below code), it works fine.
Is there any restriction like on primary node type for being versionable in nature.
node = node.addNode(empname);
node.setProperty("emp ", employee.getName());
node.setProperty("emp:empphoto", employee.getName());
InputStream in = employee.getPhoto().getInputStream();
Node attachments = node.addNode("photo",JcrConstants.NT_FILE);
log.info("Creating an attachments node.. "+attachments);
photo = attachments.addNode("content", JcrConstants.NT_RESOURCE);
*photo.addMixin("mix:versionable");
*photo.setProperty("versionId", 1L);
photo.setProperty(JcrConstants.JCR_MIMETYPE, "application/octet-stream");
photo.setProperty(JcrConstants.JCR_DATA, in);
Calendar lastModified = Calendar.getInstance();
lastModified.setTimeInMillis(System.currentTimeMillis());
photo.setProperty(JcrConstants.JCR_LASTMODIFIED, lastModified);
IOUtils.closeQuietly(in);
session.save();
*photo.checkin();
log.info("Saved node. node={} " + node);
Quick help is appreciated.
/Sunil
Re: Versioning problem
Posted by Alexander Klimetschek <ak...@day.com>.
On Fri, Sep 18, 2009 at 13:14, Sunil Dhage <su...@coreobjects.com> wrote:
> *photo.addMixin("mix:versionable");
You need to save the node after adding the mix:versionable mixin to
make the node versionable.
http://www.day.com/specs/jcr/1.0/8.2.4_Initializing_the_Version_History.html
Regards,
Alex
--
Alexander Klimetschek
alexander.klimetschek@day.com