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

        Felix Meschberger created issue -
        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...
        Felix Meschberger made changes -
        Field Original Value New Value
        Fix Version/s Servlets Post 2.0.6 [ 12314180 ]
        Fix Version/s Servlets Get 2.0.8 [ 12314257 ]
        Affects Version/s Servlets Post 2.0.4 [ 12313275 ]
        Affects Version/s Servlets Get 2.0.6 [ 12313969 ]
        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
        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
        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
        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
        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
        Eric Norman made changes -
        Assignee Eric Norman [ edn ]
        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
        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 -

        Thank you Eric, I look forward to the commit.

        Show
        Mike Moulton added a comment - Thank you Eric, I look forward to the commit.
        Eric Norman committed 958411 (32 files)
        Reviews: none

        SLING-1172 Allow uploading JSON files to create content structures

        sling trunk
        Eric Norman made changes -
        Status Open [ 1 ] In Progress [ 3 ]
        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.
        Eric Norman made changes -
        Status In Progress [ 3 ] Resolved [ 5 ]
        Fix Version/s JCR ContentLoader 2.0.8 [ 12314472 ]
        Resolution Fixed [ 1 ]
        Eric Norman committed 958417 (1 file)
        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 -

        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
        Eric Norman made changes -
        Resolution Fixed [ 1 ]
        Status Resolved [ 5 ] Reopened [ 4 ]
        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.
        Eric Norman made changes -
        Status Reopened [ 4 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Hide
        Eric Norman added a comment -

        fixed in r960134

        Show
        Eric Norman added a comment - fixed in r960134
        Justin Edelson made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Gavin made changes -
        Workflow no-reopen-closed,doc-test-required [ 12481437 ] Copy of no-reopen-closed,doc-test-required [ 12764930 ]
        Gavin made changes -
        Workflow Copy of no-reopen-closed,doc-test-required [ 12764930 ] no-reopen-closed,doc-test-required [ 12766348 ]
        Gavin made changes -
        Workflow no-reopen-closed,doc-test-required [ 12766348 ] re-open possible,doc-test-required [ 12788390 ]
        Gavin made changes -
        Workflow re-open possible,doc-test-required [ 12788390 ] no-reopen-closed,doc-test-required [ 12791117 ]

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development