Sling
  1. Sling
  2. SLING-1172

Allow uploading JSON files to create content structures

    Details

      Description

      Currently uploading a JSON file will just create the file node.

      On the other hand it would be useful if uploading to a node with a request extension of JSON, the JSON would be unpacked and handled as if it would be a modification request with the JSON data being the content to store.

      This would be similar to JSON upload supported by CouchDB.

        Activity

        Hide
        Eric Norman added a comment -

        fixed in r960134

        Show
        Eric Norman added a comment - fixed in r960134
        Hide
        Eric Norman added a comment -

        Fixed the import case where no name parameter is supplied.

        Show
        Eric Norman added a comment - Fixed the import case where no name parameter is supplied.
        Hide
        Eric Norman added a comment -

        Re-opening to reconsider the import case where no name is provided as discussed @ http://markmail.org/message/22qobb2e7y5yuu67

        Show
        Eric Norman added a comment - Re-opening to reconsider the import case where no name is provided as discussed @ http://markmail.org/message/22qobb2e7y5yuu67
        Hide
        Eric Norman added a comment -

        I also updated the documentation of the sling.post bundle in the wiki. Please review that as well.

        Show
        Eric Norman added a comment - I also updated the documentation of the sling.post bundle in the wiki. Please review that as well.
        Hide
        Eric Norman added a comment -

        Code committed in r958411. Please review to verify it works as you would expect.

        Show
        Eric Norman added a comment - Code committed in r958411. Please review to verify it works as you would expect.
        Hide
        Mike Moulton added a comment -

        Thank you Eric, I look forward to the commit.

        Show
        Mike Moulton added a comment - Thank you Eric, I look forward to the commit.
        Hide
        Eric Norman added a comment -

        Hi Mike,
        I (locally) have a mostly working prototype of a new "import" POST operation that re-uses the content loader functionality to import JSON (or XML) content supplied by a request parameter (or file upload). I just need to clean up the code a bit and make sure there is adequate test coverage and documentation before I check it in. I will try to get that wrapped up this week.

        Show
        Eric Norman added a comment - Hi Mike, I (locally) have a mostly working prototype of a new "import" POST operation that re-uses the content loader functionality to import JSON (or XML) content supplied by a request parameter (or file upload). I just need to clean up the code a bit and make sure there is adequate test coverage and documentation before I check it in. I will try to get that wrapped up this week.
        Hide
        Mike Moulton added a comment -

        What's the possibility to get this into Sling 6? I have run into the need for this several times on a current project.

        Show
        Mike Moulton added a comment - What's the possibility to get this into Sling 6? I have run into the need for this several times on a current project.
        Hide
        Andreas Schaefer added a comment -

        I started working on an implementation of an Operation to accomplish that based on the code from Simon. This version does not have much functionality beside being able to support JCR primary types. The code can be found here:

        git@github.com:schaefa/SlingTreeSave.git

        In the near future I want to add additional test cases (different JSon structures) and adjust the Operation to support them.

        -Andy

        Show
        Andreas Schaefer added a comment - I started working on an implementation of an Operation to accomplish that based on the code from Simon. This version does not have much functionality beside being able to support JCR primary types. The code can be found here: git@github.com:schaefa/SlingTreeSave.git In the near future I want to add additional test cases (different JSon structures) and adjust the Operation to support them. -Andy
        Hide
        Felix Meschberger added a comment -

        Sounds like a good idea.

        For JSON I am pretty sure round-tripping works alright.

        As for XML, things are probably different, because we have our own XML format for the loader, which is neither JCR document view nor JCR system view.

        Show
        Felix Meschberger added a comment - Sounds like a good idea. For JSON I am pretty sure round-tripping works alright. As for XML, things are probably different, because we have our own XML format for the loader, which is neither JCR document view nor JCR system view.
        Hide
        Vidar S. Ramdal added a comment -

        The content loader already has this functionality, right? Maybe we could re-use the code from there. As a bonus we would also get support for uploading content structures as XML.

        Show
        Vidar S. Ramdal added a comment - The content loader already has this functionality, right? Maybe we could re-use the code from there. As a bonus we would also get support for uploading content structures as XML.
        Hide
        Simon Gaeremynck added a comment -

        We had a similar use case.
        We handled it by creating a SlingPostOperation, code at [1]

        The user can do a POST request to the resource he wants to add/modify the tree.
        This has the benefit that the base resource gets resolved.
        The JSON is stored in a regular form parameter.

        [1] http://github.com/simong/open-experiments/blob/master/slingtests/osgikernel/bundles/batch/src/main/java/org/sakaiproject/kernel/batch/CreateTreeOperation.java

        Show
        Simon Gaeremynck added a comment - We had a similar use case. We handled it by creating a SlingPostOperation, code at [1] The user can do a POST request to the resource he wants to add/modify the tree. This has the benefit that the base resource gets resolved. The JSON is stored in a regular form parameter. [1] http://github.com/simong/open-experiments/blob/master/slingtests/osgikernel/bundles/batch/src/main/java/org/sakaiproject/kernel/batch/CreateTreeOperation.java
        Hide
        Alexander Klimetschek added a comment -

        I think it's actually about POSTing a JSON body in the request (and maybe via PUT), not necessarily a http form-based file upload of a json file. Therefore I'd suggest to rename this issue to "Allow JSON for requests to the SlingPostServlet".

        Show
        Alexander Klimetschek added a comment - I think it's actually about POSTing a JSON body in the request (and maybe via PUT), not necessarily a http form-based file upload of a json file. Therefore I'd suggest to rename this issue to "Allow JSON for requests to the SlingPostServlet".
        Hide
        Felix Meschberger added a comment -

        This is for the POST servlet of course...

        Show
        Felix Meschberger added a comment - This is for the POST servlet of course...

          People

          • Assignee:
            Eric Norman
            Reporter:
            Felix Meschberger
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development