[
https://issues.apache.org/jira/browse/SLING-9620?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17167965#comment-17167965
]
Angela Schreiber commented on SLING-9620:
-----------------------------------------
attached _SLING-9620-test.patch_ aims to illustrate the reported issue, which i
originally found when working with Adobe AEM. i hope, it's suited for some
initial validation of a possible fix.
Note: a fix will likely need to be made for the 2 cases, when _Optimize Alias
Resolution_ is enabled and disabled. I have not further tested the behavior of
{{ResourceMapper.getAllMappings}} with enabled optimization (as it adds another
layer of complexity) but from a first glance it might be that fixing this, will
surfaces additional issues.
> ResourceMapperImpl.getAllMappings does not respect multi-valued sling:alias
> ---------------------------------------------------------------------------
>
> Key: SLING-9620
> URL: https://issues.apache.org/jira/browse/SLING-9620
> Project: Sling
> Issue Type: Bug
> Components: ResourceResolver
> Affects Versions: Resource Resolver 1.6.16
> Reporter: Angela Schreiber
> Priority: Major
> Attachments: SLING-9620-test.patch
>
>
> while investigating an issue involving {{sling:alias}}, i ended up manually
> adding the property using JCR API calls. this involved first adding the
> {{sling:ResourceAlias}} and i noticed that {{sling:alias}} can be both single
> or multi-valued according to the node type definition:
> {code}
> / Mixin node type to enable setting an alias on a resource
> [sling:ResourceAlias]
> mixin
>
> // alias name(s) for the node (single or multi-value)
> - sling:alias (string)
> - sling:alias (string) multiple
> {code}
> when setting multiple values for the {{sling:alias}} property, i found that
> {{ResourceMapper.getAllMappings}} only returns the first alias.
> looking at the implementation in
> {{ResourceMapperImpl.loadAliasIfApplicable}}, it seems that line 216
> ({{String alias = ResourceResolverControl.getProperty(current,
> ResourceResolverImpl.PROP_ALIAS);}}), is the culprit as call will in any case
> just return a single string (it calls {{getProperty(res, propName,
> String.class)}}).
> as a consequence consumers of the {{ResourceMapper.getAllMappings}} method
> will not get a complete list of all aliases available.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)