You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Justin Edelson <ju...@gmail.com> on 2010/02/10 01:03:50 UTC

Re: [jira] Commented: (SLING-1172) Allow uploading JSON files to create content structures

Ian-
How do you currently deal with partial node updates? For example, if you had
/some/path/node
/some/path/node/child1
/some/path/node/child2

and submitted to /some/path/node:

{
 'jcr:title': 'some title',
 'jcr:description': 'some description'
}

Would child1 and child2 be deleted?

Justin

On Tue, Feb 9, 2010 at 6:46 PM, Ian Boston <ie...@tfd.co.uk> 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 <sc...@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)" <ji...@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.
>>>>
>>>>
>>

Re: [jira] Commented: (SLING-1172) Allow uploading JSON files to create content structures

Posted by Simon Gaeremynck <ga...@gmail.com>.
No, it wouldn't delete them.

Whenever possible it tries to get the node. If the parent node doesn't have the requested name it will add it.
Properties will be overwritten..
Example at [1] which I hope clarifies it a bit.

I haven't looked at the ContentLoader yet, but I agree it would make sense to re-use it.

Simon

[1]
ex:
Existing node structure
/some/path/node
       + "my:title" : "random"
/some/path/node/child1
       + "my:title" : "random"
       + "my:foo" : "bar"


Posted JSON to /some/path/node
{
  "my:title" : "parent",
  "child1" : {
     "my:title" : "Child 1",
     "my:description" : "Description of child 1"
  },
  "child2" : {
    "my:title" : "Child 2",
     "my:description" : "Description of child 2"
  }
}


Would result in:
/some/path/node
       + "my:title" : "random"
/some/path/node/child1
       + "my:title" : "Child 1"
       + "my:description" : "Description of child 1"
       + "my:foo" : "bar" 
/some/path/node/child2
       + "my:title" : "Child 2"
       + "my:description" : "Description of child 2"


On 10 Feb 2010, at 00:03, Justin Edelson wrote:

> Ian-
> How do you currently deal with partial node updates? For example, if you had
> /some/path/node
> /some/path/node/child1
> /some/path/node/child2
> 
> and submitted to /some/path/node:
> 
> {
> 'jcr:title': 'some title',
> 'jcr:description': 'some description'
> }
> 
> Would child1 and child2 be deleted?
> 
> Justin
> 
> On Tue, Feb 9, 2010 at 6:46 PM, Ian Boston <ie...@tfd.co.uk> 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 <sc...@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)" <ji...@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.
>>>>> 
>>>>> 
>>>