You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-dev@jackrabbit.apache.org by Francesco Mari <ma...@gmail.com> on 2015/03/26 14:10:16 UTC

Autocreated properties with the ContentRepository API

Hi all,

when using the ContentRepository API with the JCR plugins (as
installed by the Jcr builder), autocreated properties are not
generated.

IIUC, this happens because
org.apache.jackrabbit.oak.util.TreeUtil#autoCreateItems is only called
when using a org.apache.jackrabbit.oak.jcr.delegate.NodeDelegate,
instead of being part of the logic executed by
org.apache.jackrabbit.oak.plugins.nodetype.TypeEditor.

I think that TypeEditor, instead of NodeDelegate, should take care of
autocreated items. What do you think?

Re: Autocreated properties with the ContentRepository API

Posted by Michael Dürig <md...@apache.org>.
Hi,

IMO this is a requirement for which we didn't come up with a clean 
solution yet. While I agree that it is probably not possible to just fit 
this into the "commit hook" framework, this should still be a single 
concern in one place instead of spreading it all over.

Please report an improvement issue so it doesn't drop of the agenda.

Michael

On 26.3.15 2:53 , Francesco Mari wrote:
> I was not aware of this design decision, thanks for clarifying.
>
> Anyway, the remote API is currently implemented on top of the
> ContentRepository API. This means that I have to take care of
> providing values for autocreated properties. Is there anything that
> can be done do prevent this?
>
> I was thinking that maybe, when the "JCR plugins" are installed, a
> wrapper of Tree may be installed as well. This wrapper could take care
> of the generation of autocreated properties in the transient space.
> This is kind of a big change, because the ContentRepository API is not
> meant to be extended this way.
>
>
> 2015-03-26 14:26 GMT+01:00 Angela Schreiber <an...@adobe.com>:
>> hi francesco
>>
>> well... so far we claimed that it's the responsibility of the
>> Oak API caller to make sure that items defined to be autocreated
>> from a JCR point of view must be created. as the Oak API itself
>> doesn't know about autocreated items.
>>
>> afaik delegating this to the TypeEditor will not work, because
>> JCR mandates for various autocreated items that they are already
>> present in the transient state (before being saved).
>>
>> as you can see it's not only the NodeDelegate that autocreates
>> items but e.g. also the user management implementation, the versioning
>> etc.
>>
>> kind regards
>> angela
>>
>> On 26/03/15 14:10, "Francesco Mari" <ma...@gmail.com> wrote:
>>
>>> Hi all,
>>>
>>> when using the ContentRepository API with the JCR plugins (as
>>> installed by the Jcr builder), autocreated properties are not
>>> generated.
>>>
>>> IIUC, this happens because
>>> org.apache.jackrabbit.oak.util.TreeUtil#autoCreateItems is only called
>>> when using a org.apache.jackrabbit.oak.jcr.delegate.NodeDelegate,
>>> instead of being part of the logic executed by
>>> org.apache.jackrabbit.oak.plugins.nodetype.TypeEditor.
>>>
>>> I think that TypeEditor, instead of NodeDelegate, should take care of
>>> autocreated items. What do you think?
>>

Re: Autocreated properties with the ContentRepository API

Posted by Angela Schreiber <an...@adobe.com>.
Hi Francesco

Sure, that might be worth an evaluation. Currently you would
need to use the TreeUtil method in order to make sure
the auto-created items are property setup as you already
mentioned below.

Kind regards
Angela

On 26/03/15 14:53, "Francesco Mari" <ma...@gmail.com> wrote:

>I was not aware of this design decision, thanks for clarifying.
>
>Anyway, the remote API is currently implemented on top of the
>ContentRepository API. This means that I have to take care of
>providing values for autocreated properties. Is there anything that
>can be done do prevent this?
>
>I was thinking that maybe, when the "JCR plugins" are installed, a
>wrapper of Tree may be installed as well. This wrapper could take care
>of the generation of autocreated properties in the transient space.
>This is kind of a big change, because the ContentRepository API is not
>meant to be extended this way.
>
>
>2015-03-26 14:26 GMT+01:00 Angela Schreiber <an...@adobe.com>:
>> hi francesco
>>
>> well... so far we claimed that it's the responsibility of the
>> Oak API caller to make sure that items defined to be autocreated
>> from a JCR point of view must be created. as the Oak API itself
>> doesn't know about autocreated items.
>>
>> afaik delegating this to the TypeEditor will not work, because
>> JCR mandates for various autocreated items that they are already
>> present in the transient state (before being saved).
>>
>> as you can see it's not only the NodeDelegate that autocreates
>> items but e.g. also the user management implementation, the versioning
>> etc.
>>
>> kind regards
>> angela
>>
>> On 26/03/15 14:10, "Francesco Mari" <ma...@gmail.com> wrote:
>>
>>>Hi all,
>>>
>>>when using the ContentRepository API with the JCR plugins (as
>>>installed by the Jcr builder), autocreated properties are not
>>>generated.
>>>
>>>IIUC, this happens because
>>>org.apache.jackrabbit.oak.util.TreeUtil#autoCreateItems is only called
>>>when using a org.apache.jackrabbit.oak.jcr.delegate.NodeDelegate,
>>>instead of being part of the logic executed by
>>>org.apache.jackrabbit.oak.plugins.nodetype.TypeEditor.
>>>
>>>I think that TypeEditor, instead of NodeDelegate, should take care of
>>>autocreated items. What do you think?
>>


Re: Autocreated properties with the ContentRepository API

Posted by Francesco Mari <ma...@gmail.com>.
I was not aware of this design decision, thanks for clarifying.

Anyway, the remote API is currently implemented on top of the
ContentRepository API. This means that I have to take care of
providing values for autocreated properties. Is there anything that
can be done do prevent this?

I was thinking that maybe, when the "JCR plugins" are installed, a
wrapper of Tree may be installed as well. This wrapper could take care
of the generation of autocreated properties in the transient space.
This is kind of a big change, because the ContentRepository API is not
meant to be extended this way.


2015-03-26 14:26 GMT+01:00 Angela Schreiber <an...@adobe.com>:
> hi francesco
>
> well... so far we claimed that it's the responsibility of the
> Oak API caller to make sure that items defined to be autocreated
> from a JCR point of view must be created. as the Oak API itself
> doesn't know about autocreated items.
>
> afaik delegating this to the TypeEditor will not work, because
> JCR mandates for various autocreated items that they are already
> present in the transient state (before being saved).
>
> as you can see it's not only the NodeDelegate that autocreates
> items but e.g. also the user management implementation, the versioning
> etc.
>
> kind regards
> angela
>
> On 26/03/15 14:10, "Francesco Mari" <ma...@gmail.com> wrote:
>
>>Hi all,
>>
>>when using the ContentRepository API with the JCR plugins (as
>>installed by the Jcr builder), autocreated properties are not
>>generated.
>>
>>IIUC, this happens because
>>org.apache.jackrabbit.oak.util.TreeUtil#autoCreateItems is only called
>>when using a org.apache.jackrabbit.oak.jcr.delegate.NodeDelegate,
>>instead of being part of the logic executed by
>>org.apache.jackrabbit.oak.plugins.nodetype.TypeEditor.
>>
>>I think that TypeEditor, instead of NodeDelegate, should take care of
>>autocreated items. What do you think?
>

Re: Autocreated properties with the ContentRepository API

Posted by Angela Schreiber <an...@adobe.com>.
hi francesco

well... so far we claimed that it's the responsibility of the
Oak API caller to make sure that items defined to be autocreated
from a JCR point of view must be created. as the Oak API itself
doesn't know about autocreated items.

afaik delegating this to the TypeEditor will not work, because
JCR mandates for various autocreated items that they are already
present in the transient state (before being saved).

as you can see it's not only the NodeDelegate that autocreates
items but e.g. also the user management implementation, the versioning
etc.

kind regards
angela

On 26/03/15 14:10, "Francesco Mari" <ma...@gmail.com> wrote:

>Hi all,
>
>when using the ContentRepository API with the JCR plugins (as
>installed by the Jcr builder), autocreated properties are not
>generated.
>
>IIUC, this happens because
>org.apache.jackrabbit.oak.util.TreeUtil#autoCreateItems is only called
>when using a org.apache.jackrabbit.oak.jcr.delegate.NodeDelegate,
>instead of being part of the logic executed by
>org.apache.jackrabbit.oak.plugins.nodetype.TypeEditor.
>
>I think that TypeEditor, instead of NodeDelegate, should take care of
>autocreated items. What do you think?