Hi, I just tried a GET, feed it to the operation and it works pretty well. However, as it is now it will ignore all properties which names start with 'jcr:'. It's probably better to take the same approach as in the JsonReader and have a set of ignored names instead of ignoring everything. (uuid, primaryType, created, ...)
For the naming part: We could also do something like this :operation=tree and then depending wether you're sending XML, json, .. :json=.. or :xml=.. This way we can keep it all in 1 operation. For the above 2 reasons, re-using the code from contentloader would be a big bonus (imho). Simon On 10 Feb 2010, at 14:46, Felix Meschberger wrote: > Hi, > > On 10.02.2010 15:36, Simon Gaeremynck wrote: >> I'm not really sure what you mean by roundtripping to the JsonGetServlet? > > By round tripping I mean that I can feed the result of a GET to > /some/node.json to the :tree operation and (given a clean state) get the > same content structure. > > And vice versa: POST:tree to /some/node.json and then GET > /some/node.json returns an equivalent JSON. > > >> >> Initial patch at [1]. > > Patch looks good, with one remark: Since this is json only (right now) > how about using that as the name: > > operation=json > :json=...json-data... > > WDYT ? > > Regards > Felix > >> >> Basicly what this does is: >> - A SlingPostOperation with the operation :tree. >> - Grab a string from the request parameter ':tree' >> - Try to convert it to a JSONObject >> - Walk over the JSONObject and create the nodes/properties in JCR as it goes >> along. >> - Save the session. >> >> >> This doesn't use the ContentLoader service (yet) because AFAICT that is all >> internal and >> seems to be aimed primarily for loading bundle resources. (Haven't had a >> close look though) >> However, it would be good if this operation would use the JsonReader >> provided by the contentloader >> as that would remove code duplication and the JsonReader already has proper >> test coverage. >> >> Simon >> >> [1] http://codereview.appspot.com/207057/show >> >> >> On 10 Feb 2010, at 11:54, Felix Meschberger wrote: >> >>> Hi, >>> >>> Sounds great and the class looks good. I assume this provides >>> round-tripping to the JsonGetServlet. >>> >>> So, if Simon would be contributing this, it would be nice. >>> >>> Regards >>> Felix >>> >>> On 10.02.2010 00:46, Ian Boston wrote: >>>> >>>> Simon who works with me wrote this, but it takes a post of json in the >>>> parameter tree as a modification to a sub tree. >>>> >>>> Our ui developers love it. They can convert many post operations into >>>> one post. >>>> >>>> If of use, I'll ask Simon to submit as a patch on the jira. >>>> Ian >>>> >>>> http://github.com/ieb/open-experiments/blob/master/slingtests/osgikernel/bundles/batch/src/main/java/org/sakaiproject/nakamura/batch/CreateTreeOperation.java >>>> >>>> >>>> Sent from my iPhone >>>> >>>> On 9 Feb 2010, at 23:28, Andreas Schaefer <schaef...@me.com> wrote: >>>> >>>>> I am currently working on a project where we might use Sling. In order >>>>> to evaluate this I created my own Sling servlet in order to take JSon >>>>> and create / merge (hibernate lingo) data. >>>>> >>>>> Therefore I would love to have a way to upload JSon and would be >>>>> willing to lend a hand getting this off the ground. >>>>> >>>>> Cheers - Andy >>>>> >>>>> On Feb 9, 2010, at 3:02 PM, Ian Boston wrote: >>>>> >>>>>> We have implented something like this already, happy to share if of >>>>>> interest. >>>>>> >>>>>> Ian >>>>>> >>>>>> Sent from my iPhone >>>>>> >>>>>> On 9 Feb 2010, at 18:45, "Felix Meschberger (JIRA)" <j...@apache.org> >>>>>> wrote: >>>>>> >>>>>>> >>>>>>> [ >>>>>>> https://issues.apache.org/jira/browse/SLING-1172?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12831583#action_12831583 >>>>>>> ] >>>>>>> >>>>>>> >>>>>>> Felix Meschberger commented on SLING-1172: >>>>>>> ------------------------------------------ >>>>>>> >>>>>>> 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. >>>>>>> >>>>>>>> Allow uploading JSON files to create content structures >>>>>>>> ------------------------------------------------------- >>>>>>>> >>>>>>>> Key: SLING-1172 >>>>>>>> URL: https://issues.apache.org/jira/browse/SLING-1172 >>>>>>>> Project: Sling >>>>>>>> Issue Type: New Feature >>>>>>>> Components: Servlets >>>>>>>> Affects Versions: Servlets Post 2.0.4 >>>>>>>> Reporter: Felix Meschberger >>>>>>>> Fix For: Servlets Post 2.0.6 >>>>>>>> >>>>>>>> >>>>>>>> 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. >>>>>>> >>>>>>> -- >>>>>>> This message is automatically generated by JIRA. >>>>>>> - >>>>>>> You can reply to this email to add a comment to the issue online. >>>>>>> >>>>> >>>> >> >>