You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Konrad Windszus <kw...@apache.org> on 2025/09/23 09:56:10 UTC
Resource type from JCR Resource provider containing colon
Hi,
According to https://sling.apache.org/documentation/the-sling-engine/resources.html#resource-types the JCR resource provider determines the resource type as
"The value of the sling:resourceType property or the primary node type if the property is not set (a namespace separator colon is replaced by a slash, e.g. the nt:file primary node type is mapped to the nt/file resource type”
However, I couldn’t find any code related to converting the colon to a slash in https://github.com/apache/sling-org-apache-sling-jcr-resource/blob/a1f5532981a118470c74afdba217fa480c1e0cec/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrItemResource.java#L120.
Also it seems that in reality the resource type via Resource.getResourceType() is exposed still having the colon from the underlying “jcr:primaryType” value.
I know that the servlet resolver somehow treats the resource type as having “/“ instead of “:” but I am wondering if that logic is specific to the servlet resolver.
Am I misunderstanding something or is there a bug?
Thanks,
Konrad
Re: Resource type from JCR Resource provider containing colon
Posted by Konrad Windszus <kw...@apache.org>.
Carsten found it. Thanks for that.
The conversion happens in https://github.com/apache/sling-org-apache-sling-api/blob/9285f1baca058fc3ae7c68be09cd2a70ef918d5d/src/main/java/org/apache/sling/api/resource/ResourceUtil.java#L482 called from
https://github.com/apache/sling-org-apache-sling-servlets-resolver/blob/0c268c985b55bbae2a4583b830c0ecfa5699c937/src/main/java/org/apache/sling/servlets/resolver/internal/helper/LocationCollector.java#L135.
So the logic described in https://sling.apache.org/documentation/the-sling-engine/resources.html#resource-types with converting “:" to “/“ is
- only used within the servlet resolver
- is resource provider agnostic
I will try come up with a fix to the documentation.
Konrad
> On 25. Sep 2025, at 12:10, Konrad Windszus <kw...@apache.org> wrote:
>
> Ping, anyone has any pointers?
> Thanks,
> Konrad
>
>> On 23. Sep 2025, at 11:56, Konrad Windszus <kw...@apache.org> wrote:
>>
>> Hi,
>> According to https://sling.apache.org/documentation/the-sling-engine/resources.html#resource-types the JCR resource provider determines the resource type as
>>
>> "The value of the sling:resourceType property or the primary node type if the property is not set (a namespace separator colon is replaced by a slash, e.g. the nt:file primary node type is mapped to the nt/file resource type”
>>
>> However, I couldn’t find any code related to converting the colon to a slash in https://github.com/apache/sling-org-apache-sling-jcr-resource/blob/a1f5532981a118470c74afdba217fa480c1e0cec/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrItemResource.java#L120.
>>
>> Also it seems that in reality the resource type via Resource.getResourceType() is exposed still having the colon from the underlying “jcr:primaryType” value.
>> I know that the servlet resolver somehow treats the resource type as having “/“ instead of “:” but I am wondering if that logic is specific to the servlet resolver.
>> Am I misunderstanding something or is there a bug?
>>
>> Thanks,
>> Konrad
>
>
Re: Resource type from JCR Resource provider containing colon
Posted by Konrad Windszus <kw...@apache.org>.
Ping, anyone has any pointers?
Thanks,
Konrad
> On 23. Sep 2025, at 11:56, Konrad Windszus <kw...@apache.org> wrote:
>
> Hi,
> According to https://sling.apache.org/documentation/the-sling-engine/resources.html#resource-types the JCR resource provider determines the resource type as
>
> "The value of the sling:resourceType property or the primary node type if the property is not set (a namespace separator colon is replaced by a slash, e.g. the nt:file primary node type is mapped to the nt/file resource type”
>
> However, I couldn’t find any code related to converting the colon to a slash in https://github.com/apache/sling-org-apache-sling-jcr-resource/blob/a1f5532981a118470c74afdba217fa480c1e0cec/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrItemResource.java#L120.
>
> Also it seems that in reality the resource type via Resource.getResourceType() is exposed still having the colon from the underlying “jcr:primaryType” value.
> I know that the servlet resolver somehow treats the resource type as having “/“ instead of “:” but I am wondering if that logic is specific to the servlet resolver.
> Am I misunderstanding something or is there a bug?
>
> Thanks,
> Konrad