You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Bertrand Delacretaz <bd...@apache.org> on 2012/07/06 11:26:23 UTC

SLING-2530, does create assume the parent resource exists?

Hi,

Looking at the SLING-2530 Resources CRUD stuff - for the create
operation, https://cwiki.apache.org/confluence/display/SLING/Supporting+CRUD
says

> We add a new method create(String absolutePath, ValueMap properties) to the resource resolver, where the value map is optional.
> This will create the resource at the given path and add the provided properties.

I see two potential problems:

1) If the parent of the Resource to create does not exist yet, options
might be needed to specify how to create the intermediate path - the
node type to use for intermediate nodes in JCR, for example.
How can those options be specified?

2) If this requires the parent Resource to pre-exist, it would be
clearer to express that as a createChild method on the Resource object

Carsten, how do you see that in your design?

-Bertrand

Re: SLING-2530, does create assume the parent resource exists?

Posted by Bertrand Delacretaz <bd...@apache.org>.
On Fri, Jul 6, 2012 at 11:44 AM, Carsten Ziegeler <cz...@apache.org> wrote:
> Yepp, so I guess going with 2) is the better option, however this
> would require something like a add(Resource parent, String
> childNodeName, Map props) on the resource resolver.
>
> So maybe we go the same route as we did with getParent(), listChildren
> and add the functionality to the resource resolver but provide
> convenience methods on the resource which just delegate...

Sounds good to me, and it's consistent with what we already have.
-Bertrand

Re: SLING-2530, does create assume the parent resource exists?

Posted by Carsten Ziegeler <cz...@apache.org>.
Yepp, so I guess going with 2) is the better option, however this
would require something like a add(Resource parent, String
childNodeName, Map props) on the resource resolver.

So maybe we go the same route as we did with getParent(), listChildren
and add the functionality to the resource resolver but provide
convenience methods on the resource which just delegate

Carsten

2012/7/6 Bertrand Delacretaz <bd...@apache.org>:
> On Fri, Jul 6, 2012 at 11:32 AM, Carsten Ziegeler <cz...@apache.org> wrote:
>> ...I would prefer 1) although that raise some interesting questions,
>> especially as intermediate nodes might end up to be persisted in
>> different storages...
>
> Right, so IMO requiring the parent Resource to pre-exist makes things
> simpler for us, and less surprising to the user.
>
> -Bertrand



-- 
Carsten Ziegeler
cziegeler@apache.org

Re: SLING-2530, does create assume the parent resource exists?

Posted by Bertrand Delacretaz <bd...@apache.org>.
On Fri, Jul 6, 2012 at 11:32 AM, Carsten Ziegeler <cz...@apache.org> wrote:
> ...I would prefer 1) although that raise some interesting questions,
> especially as intermediate nodes might end up to be persisted in
> different storages...

Right, so IMO requiring the parent Resource to pre-exist makes things
simpler for us, and less surprising to the user.

-Bertrand

Re: SLING-2530, does create assume the parent resource exists?

Posted by Carsten Ziegeler <cz...@apache.org>.
Hi,

I haven't thought about this yet :)

But I would prefer 1) although that raise some interesting questions,
especially as intermediate nodes might end up to be persisted in
different storages

Carsten

2012/7/6 Bertrand Delacretaz <bd...@apache.org>:
> Hi,
>
> Looking at the SLING-2530 Resources CRUD stuff - for the create
> operation, https://cwiki.apache.org/confluence/display/SLING/Supporting+CRUD
> says
>
>> We add a new method create(String absolutePath, ValueMap properties) to the resource resolver, where the value map is optional.
>> This will create the resource at the given path and add the provided properties.
>
> I see two potential problems:
>
> 1) If the parent of the Resource to create does not exist yet, options
> might be needed to specify how to create the intermediate path - the
> node type to use for intermediate nodes in JCR, for example.
> How can those options be specified?
>
> 2) If this requires the parent Resource to pre-exist, it would be
> clearer to express that as a createChild method on the Resource object
>
> Carsten, how do you see that in your design?
>
> -Bertrand



-- 
Carsten Ziegeler
cziegeler@apache.org