RE: Need help in implementing Sling Context Aware Configuration

2016-11-21 Thread Stefan Seifert
please have also a look on the documentation [1] [2]

it should work the way you describe having a sling:configRef property on 
country node and on each language node.

stefan

[1] 
http://sling.apache.org/documentation/bundles/context-aware-configuration/context-aware-configuration.html
[2] 
http://sling.apache.org/documentation/bundles/context-aware-configuration/context-aware-configuration-default-implementation.html



>-Original Message-
>From: Nicolas Peltier [mailto:npelt...@adobe.com]
>Sent: Monday, November 21, 2016 1:54 PM
>To: users@sling.apache.org
>Cc: Gopal Agarwal
>Subject: Re: Need help in implementing Sling Context Aware Configuration
>
>Hi Guys,
>
>thanks for your help, it was indeed a deployment issue.
>
>now we’d need to know how to properly implement a “complex” but rather
>current case with country and language subnodes.
>
>Am i right to assume if we want to use default context path strategy we
>should add a sling:configRef property to each locale of the content (e.g.
>/content/mysite/country/language@sling:configRef), and then manage in the
>configuration the fallback mechanism?
>
>Nicolas
>
>
>
>
>> On Nov 21, 2016, at 7:23 AM, Bertrand Delacretaz 
>wrote:
>>
>> On Fri, Nov 18, 2016 at 8:36 AM, Gopal Agarwal 
>wrote:
>> ...
>>> ResourceResolver resourceResolver = request.getResourceResolver();
>>> Resource contentResource = (Resource)
>resourceResolver.getResource("/content/ubi/test");
>>> ValueMap props =
>contentResource.adaptTo(ConfigurationBuilder.class).asValueMap();...
>>
>> You should check whether contentResource is null before using it: as
>> per [1] getResource(..) returns null if the resource is not present or
>> cannot be read.
>>
>> -Bertrand
>>
>> [1]
>https://sling.apache.org/apidocs/sling7/org/apache/sling/api/resource/Resou
>rceResolver.html



Re: Need help in implementing Sling Context Aware Configuration

2016-11-21 Thread Nicolas Peltier
Hi Guys,

thanks for your help, it was indeed a deployment issue. 

now we’d need to know how to properly implement a “complex” but rather current 
case with country and language subnodes. 

Am i right to assume if we want to use default context path strategy we should 
add a sling:configRef property to each locale of the content (e.g. 
/content/mysite/country/language@sling:configRef), and then manage in the 
configuration the fallback mechanism?

Nicolas




> On Nov 21, 2016, at 7:23 AM, Bertrand Delacretaz  
> wrote:
> 
> On Fri, Nov 18, 2016 at 8:36 AM, Gopal Agarwal  wrote:
> ...
>> ResourceResolver resourceResolver = request.getResourceResolver();
>> Resource contentResource = (Resource) 
>> resourceResolver.getResource("/content/ubi/test");
>> ValueMap props = 
>> contentResource.adaptTo(ConfigurationBuilder.class).asValueMap();...
> 
> You should check whether contentResource is null before using it: as
> per [1] getResource(..) returns null if the resource is not present or
> cannot be read.
> 
> -Bertrand
> 
> [1] 
> https://sling.apache.org/apidocs/sling7/org/apache/sling/api/resource/ResourceResolver.html