Setting sling:resourceType on a node as part of repo initialization?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Setting sling:resourceType on a node as part of repo initialization?

John Logan
Hi,


I'm creating a node at repository initialization time using a "create path" statement in my repoinit block, and wondering what the best practice would be for also setting the sling:resourceType on that node.  It looks like the repoinit language only allows setting of jcr:primaryType and mixins.  Am I missing something, or is there another way I should be doing this?


Thank you!


John Logan

Reply | Threaded
Open this post in threaded view
|

Re: Setting sling:resourceType on a node as part of repo initialization?

Bertrand Delacretaz
Hi John,

On Fri, Dec 15, 2017 at 1:44 AM, John Logan <[hidden email]> wrote:
>... I'm creating a node at repository initialization time using a "create path" statement in my repoinit
> block, and wondering what the best practice would be for also setting the sling:resourceType on
> that node....

You're right that this is not supported by the repoinit language so far.

As a workaround you might register a SlingRepositoryInitializer [1]
that does what you need.

But I agree that it would make sense to support this in repoint. As
resource types are in the same "family" than node types I think best
is to expand the bracketed node type statements to something like

  (nt:unstructured mixin nt:versionable resourceType foo/bar)

WDYT?

I won't have time to do this myself in the next few days, though, but
we might at least create a ticket as I think it makes sense. Feel free
to that if you want.

-Bertrand

[1] https://sling.apache.org/documentation/bundles/repository-initialization.html
Reply | Threaded
Open this post in threaded view
|

Re: Setting sling:resourceType on a node as part of repo initialization?

John Logan
Hi Bertrand,


For my case, need to get this node set up as the base folder of a particular data store.  It's a Sling model but has no other properties are required for adaptTo() to work successfully, so what you describe would work for me.


It wouldn't work if I had any other required properties that needed to be mapped from the node.  For that, the repoinit language would need to support general property initialization, and I'm not sure whether that falls within the intended scope.


For now the repository initializer should work just fine; somehow I looked right past that when scanning the repoinit stuff.


Thanks, as always, for your help!


John

________________________________
From: Bertrand Delacretaz <[hidden email]>
Sent: Friday, December 15, 2017 3:09:44 AM
To: users
Subject: Re: Setting sling:resourceType on a node as part of repo initialization?

Hi John,

On Fri, Dec 15, 2017 at 1:44 AM, John Logan <[hidden email]> wrote:
>... I'm creating a node at repository initialization time using a "create path" statement in my repoinit
> block, and wondering what the best practice would be for also setting the sling:resourceType on
> that node....

You're right that this is not supported by the repoinit language so far.

As a workaround you might register a SlingRepositoryInitializer [1]
that does what you need.

But I agree that it would make sense to support this in repoint. As
resource types are in the same "family" than node types I think best
is to expand the bracketed node type statements to something like

  (nt:unstructured mixin nt:versionable resourceType foo/bar)

WDYT?

I won't have time to do this myself in the next few days, though, but
we might at least create a ticket as I think it makes sense. Feel free
to that if you want.

-Bertrand

[1] https://sling.apache.org/documentation/bundles/repository-initialization.html
Reply | Threaded
Open this post in threaded view
|

Re: Setting sling:resourceType on a node as part of repo initialization?

Bertrand Delacretaz
Hi John,

On Fri, Dec 15, 2017 at 8:00 PM, John Logan <[hidden email]> wrote:
> It wouldn't work if I had any other required properties that needed to be mapped from the node...
> For that, the repoinit language would need to support general property initialization, and I'm not
> sure whether that falls within the intended scope...

Indeed, I would prefer avoiding that if possible, hence going via a
resourceType option in the nodetypes parameters sounds cleaner to me.

-Bertrand