I would suggest that you don't make your "fileNode" versionable.  Where you
define your "fileContent" nodetype, add the mix:versionable there.  Then the
metadata of your fileNode can change all you want, but your resource has its
own independent versioning.

-----Original Message-----
From: Lee F [mailto:[email protected]] 
Sent: Monday, January 23, 2012 3:42 PM
To: [email protected]
Subject: How to add unversioned metadata to a versioned node?

Hello,
I have an app that allows users to upload binary files to a Jackrabbit
repository.  There are also a few pieces of metadata that I am tracking
withing each file.  For example, description, document id, user, etc. The
other requirement is that the files be versioned and have access to
historical versions.  This is all working beautifully except for one small
problem...

Whenever the user changes something like the description, the version number
for the file goes up one.  I really only want a new version to occur when the
actual file is replaced with a new one.
Can someone tell me how I can store unversioned metadata with my versioned
node?  Would be much appreciated.  Thanks!


Here is some sample code to illustrate how I am doing it now....


When the session starts, I register a custom property type....
-----------------------------------------------------------------------------
--------------------
NodeTypeManager nodeTypeManager = (NodeTypeManager)
session.getWorkspace().getNodeTypeManager();
NodeTypeTemplate nodeType = nodeTypeManager.createNodeTypeTemplate();
nodeType.setDeclaredSuperTypeNames(new String[] {"nt:resource"});
nodeType.setName("fileContent");

PropertyDefinitionTemplate property =
nodeTypeManager.createPropertyDefinitionTemplate();
property.setName("description");
property.setMultiple(false);
property.setRequiredType(type);
template.getPropertyDefinitionTemplates().add(property);
nodeTypeManager.registerNodeType(nodeType, true);
-----------------------------------------------------------------------------
--------------------



To change property value....
-----------------------------------------------------------------------------
--------------------

VersionManager vman = session.getWorkspace().getVersionManager();
Node fileNode = session.getNodeByIdentifier(id); Node resNode =
fileNode.getNode("jcr:content"); vman.checkout(fileNode.getPath());
resNode.setProperty("description", description); session.save();
vman.checkin(fileNode.getPath());
-----------------------------------------------------------------------------
--------------------

Reply via email to