Uploaded image for project: 'Sling'
  1. Sling
  2. SLING-9620

ResourceMapperImpl.getAllMappings does not respect multi-valued sling:alias

    XMLWordPrintableJSON

Details

    Description

      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:

      / 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
      

      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.

      Attachments

        1. SLING-9620-test.patch
          3 kB
          Angela Schreiber

        Issue Links

          Activity

            People

              rombert Robert Munteanu
              angela Angela Schreiber
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 3h 50m
                  3h 50m