to sum up the opinions:

1. Sling API should always return a resource type, even if it's a fallback one

2. setting a sling:resourceType property is optional, if it's not set a 
fallback resource type is returned

3. the JCR resource provider always uses the JCR primrary type as fallback


-> open question from my side: should we change the Sling API implementation to 
always return a fixed fallback resource type, if the resource provider does not 
provide any value for the resource type? konrad recommended to use 
'sling/servlet/default' to use for this purpose.


stefan


>-----Original Message-----
>From: Stefan Seifert [mailto:sseif...@pro-vision.de]
>Sent: Thursday, January 9, 2020 2:00 PM
>To: Sling Developers
>Subject: Resource Type mandatory or optional?
>
>i've created a ticket concerning the Sling API that the method
>Resource.getResourceType should be marke das @Nullable, i always thought it
>was a bug and that the resource type is optional [1].
>
>carsten pointed out that the resource type is mandatory. the javadocs are
>not precise on this, i've also found no clear statement in the sling docs
>(I might not have found it).
>
>technically there is always a resource type when the JCR resource provider
>is used (fallback to JCR primary type if sling:resourceType is not set),
>but that's not implicitly the case for other resource providers or
>synthetic resources.
>
>if we think a resource type should be never null, we should return a
>default value for resources that do not have one, and update the
>documentation.
>
>WDYT?
>
>stefan
>
>[1] https://issues.apache.org/jira/browse/SLING-8975
>


Reply via email to