3 Replies Latest reply on Jun 16, 2010 1:08 PM by Manuel Gentile

    SessionCache createChild

    Manuel Gentile Newbie

      At the beginning of the createChild method of SessionCache.java we have the following code

      public JcrNode createChild( Name name,UUID desiredUuid,Name primaryTypeName )
       throws InvalidItemStateException, ConstraintViolationException, AccessDeniedException, RepositoryException {
        if (desiredUuid == null) desiredUuid = UUID.randomUUID();


      When a node is created modeshape adds a jcr:uuid property even if the node is not mix:referenceable.



      As result, when we create a non mix:referenceable node using jcrom we got an exception because jcrom wants to setUuid.


      Looking at the jcrom code, I see that jcrom checks for the presence of the property jcr:uuid  instead to control the node type!!!



      Where is the mistake? Personally, I think  both libraries make something wrong :-)

        • 1. Re: SessionCache createChild
          Randall Hauch Master

          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.

          • 2. Re: SessionCache createChild
            Randall Hauch Master

            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.

            • 3. Re: SessionCache createChild
              Manuel Gentile Newbie

              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") )