The JCR 1.0.1 specification (section 4.9) is pretty clear when it comes to the "jcr:uuid" property on "mix:referenceable" nodes, stating that "jcr:uuid" is protected, auto-created, and mandatory. That means that this property on referenceable nodes is created and administered by the system and can only be read (but not changed or deleted) by the client.
Unfortunately, the spec does not specifically address whether the "jcr:uuid" property can be used on non-referenceable nodes. It does say in Section 4.5, however, that the "jcr" namespace prefix is reserved for items defined within built-in node types. My interpretation is thus that the "jcr:uuid" property should not be used on non-referenceable nodes. WDYT?
ModeShape does define an internal UUID property on all nodes, even if they're not "mix:referenceable". ModeShape only exposes this property if the node is "mix:referenceable", but as you state it probably doesn't like clients attempting to set this property. While I think ModeShape is acting per the spec, we may want to better handle this situation to make ModeShape easier to use with projects like JCROM. Would you mind logging an enhancement request in JIRA?
BTW, JCR 2.0 fixes this whole issue with the introduction of a node identifier, which is always there. Sure, JCROM would need to change to make use of it, but the potential is there. BTW, the spec does not dictate the format of this identifier, but ModeShape (and other JCR impls) use UUIDs internally.
I should add that IMO the best way to add a "jcr:uuid" property on a node is to simply make the node referenceable by adding the "mix:referenceable" mixin type. Anything else (like explicitly adding a "jcr:uuid" property value on a non-referenceable node) seems to imply different identifier semantics, and thus a different property name should be used.
Then again, I may be interpreting the spec more strictly than others.
Thanks a lot for the explanation!
IMO modeshape should not add jcr:uuid on non referenceable node, even if the spec does not specify this aspect.
BTW, also JCROM has to change and force setuuid only for referenceable node
if (fileNode.isNodeType("mix:referenceable"))instead of
if ( fileNode.hasProperty("jcr:uuid") )