8 Replies Latest reply on Mar 12, 2012 10:03 AM by rhauch

    Modeshape JSonRestClient: boolean useVersioning not used ?

    akrambenaissi

      Hi modeshapers again,

       

      I am trying to use the modeshaphe rest client to add node an set them versionable (mix:versionable property on each node).

       

      I am a bit disappointed to see that even when calling the following method:

      public Status publish( Workspace workspace, String path,      File file,    boolean useVersioning );

       

      with last argument to "true", the node is created but with the required type, that is to say, that it does not contain the following mixinTypes.

      jcr:mixinTypes": [ "mix:versionable" ]

       

      By having a look at the code, and mainly the FolderNode class, I can't see where this boolean is passed as property to the service.

       

      Can anyone (Randal ) help ?

       

      Greetings

      Akram


        • 1. Re: Modeshape JSonRestClient: boolean useVersioning not used ?
          akrambenaissi

          Hi all,

           

          replying to myself, it seems that the JSonRestClient is out of cause, since I traced it and everything comes fine to the server.

           

          However on the server side, I see a strange stuff in the ItemHandler class in the addNode(Node, String,JSONObject) method :

             for (Iterator<?> iter = properties.keys(); iter.hasNext();) {
                      String key = (String)iter.next();
          
                      if (PRIMARY_TYPE_PROPERTY.equals(key)) continue;
                      if (MIXIN_TYPES_PROPERTY.equals(key)) continue;
                      setPropertyOnNode(newNode, key, properties.get(key));
                  }
          

          The mixin properties are not set on the, which includes the mix:versionable value.

          Then the return value of the method is saved to session.

           

          So the mix:versionable is never saved when using the  rest client. Am I wrong ?

          • 2. Re: Modeshape JSonRestClient: boolean useVersioning not used ?
            rhauch

            The "jcr:mixinType" property is not set in that code block because it is set in the previous code block (see line 314), while the primary type is set when the new node is added to the parent (see line 307). Yes, the setPropertyOnNode(...) method does handle setting the 'jcr:mixinTypes' property, but that method is used in other places, and since the code you're talking about is always creating the node, it explicitly sets the mixin types (again, line 314) in a manner that is more efficient.

             

            Hope that helps!

            • 3. Re: Modeshape JSonRestClient: boolean useVersioning not used ?
              akrambenaissi

              This behaviour leads to only the jcr:content property to be set versionable.

              In the simple example: /A/B/c/jcr:content, only c/jcr:content has the mix:versionable property, where I would have expected "c" to have it also.

               

              Is it related to specification? or only an implementation choice?

              What is the impact of having the node itself versionable? I think that the JSR-283 will became my favorite lecture....

              • 4. Re: Modeshape JSonRestClient: boolean useVersioning not used ?
                rhauch

                This behaviour leads to only the jcr:content property to be set versionable.

                In the simple example: /A/B/c/jcr:content, only c/jcr:content has the mix:versionable property, where I would have expected "c" to have it also.

                That's very surprising. Do you know this from a result of using it, or by code inspection?

                 

                Let's trace through how an HTTP POST is handled to create a new 'nt:file' node. JAX-RS will invoke the JcrResources.postItem(...) method, which immediate forwards to the ItemHandler.postItem(...) method. That method calls the ItemHandler.addNode(...) method, which creates the child node (with a primary type of 'nt:file'), immediately adds the mixin types (defined in the 'jcr:mixinTypes' property) to the newly created node, sets all of the other properties on the node, and finally creates the child nodes if there are any defined by calling the same addNode(...) method.

                 

                If the behavior is as you report, then it is a bug (and I'll eat my words). But I just can't see how that's the case.

                Is it related to specification? or only an implementation choice?

                What is the impact of having the node itself versionable? I think that the JSR-283 will became my favorite lecture....

                So not only is the behavior you report surprising, it is certainly not dictated by the spec: any 'nt:file' node can surely be versionable. The 'jcr:content' child node can also be versionable, but people usually don't want to version the content differently from the file node. Instead, since the (default) OPV for the 'jcr:content' child node definition is COPY, the 'jcr:content' node will be included in the 'nt:file' node's version snapshot.

                • 5. Re: Modeshape JSonRestClient: boolean useVersioning not used ?
                  akrambenaissi

                  Hi,

                   

                  thank you for the explanation.

                  I have seen this from a result. To try to find out if it is correct, or maybe I've made something wrong, here is a small unit test that one can run (attachement).

                  It uses Apache commons httpclient and the modeshape 2.8 rest client API.

                   

                  Please let me know if you see the same behaviour.

                  1 of 1 people found this helpful
                  • 6. Re: Modeshape JSonRestClient: boolean useVersioning not used ?
                    rhauch

                    Ah, you're using the JsonRestClient.publish(...) method. Sorry about misunderstanding; I thought you were directly using the RESTful API. Yes, there's definitely a bug in the JsonRestClient, so I've logged a blocker issue (MODE-1417) for the next patch release (2.8.1.Final).

                     

                    Thanks again for reporting this, and I apologize again for not understanding.

                     

                    Best regards

                    • 7. Re: Modeshape JSonRestClient: boolean useVersioning not used ?
                      akrambenaissi

                      No problem, I will try to explain more clearly next time. Maybe providing the test case first would have been more efficient.

                       

                      Anyway, thank you for the great job and support done on modeshape. It's my first experience with a JCR product, and I really do appreciate modeshape and look really forward for the next release!

                       

                      That's cool, it's my first reported issue on modeshape, hope to gain enough knowledge on the product to submit patches/pull requests in the future .

                      • 8. Re: Modeshape JSonRestClient: boolean useVersioning not used ?
                        rhauch

                        The fix for this has been committed (to multiple branches) and MODE-1417 has been marked as resolved. It'll be in the next (and last) 2.x release (whether that's 2.8.1.Final or 2.9.0.Final).

                         

                        Thanks again.