I am trying to create an auto-generated GUID property on all cq:PageContent nodes. This will be similar to the jcr:uuid property, but will be persisted with content promotion/replication/package installs (whereas the jcr:uuid for a content item changes between different environments).
I am trying to determine how AEM/JCR generates the jcr:uuid property on node creation. The CND defining the property is:
[mix:referenceable]
mixin
- jcr:uuid (string) mandatory autocreated protected initialize
I've tried defining my GUID property in a similar manor, specifying the autocreated
and initialize
attributes, but this did not result in auto-generation of the property.
Could anybody point me to the source of the jcr:uuid's generation?
As an aside, I asked a related question on the Adobe Community Forum: http://help-forums.adobe.com/content/adobeforums/en/experience-manager-forum/adobe-experience-manager.topic.5_ciot.html/forum__bnxr-i_am_tryingtocreat.html
You don't mention which version of AEM (so whether you're dealing with Jackrabbit or Oak), but the mechanism turns out to be basically the same.
When assigning a default value, there are a few hard-coded system property names that get special treatment (jcr:uuid being one of them). If the name of the property being assigned a default value doesn't match any of the special cases, it falls back the static list of default values from the property definition (e.g. listed in the CND file).
In summary, it looks like you cannot piggy-back on this mechanism to assign your own dynamic default value for an arbitrary property. You would need to implement your own event listener or something.
Jackrabbit: See the implementation of setDefaultValues and computeSystemGeneratedPropertyValues
Oak: See the implementation of TreeUtil autoCreateProperty