Class MapEntries

  • All Implemented Interfaces:
    org.apache.sling.api.resource.observation.ExternalResourceChangeListener, org.apache.sling.api.resource.observation.ResourceChangeListener, MapEntriesHandler

    public class MapEntries
    extends Object
    implements MapEntriesHandler, org.apache.sling.api.resource.observation.ResourceChangeListener, org.apache.sling.api.resource.observation.ExternalResourceChangeListener
    • Method Detail

      • doInit

        protected boolean doInit()
        Actual initializer. Guards itself against concurrent use by using a ReentrantLock. Does nothing if the resource resolver has already been null-ed.
      • initializeVanityPaths

        protected void initializeVanityPaths()
                                      throws IOException
        Actual vanity paths initializer. Guards itself against concurrent use by using a ReentrantLock. Does nothing if the resource resolver has already been null-ed.
        Throws:
        IOException
      • dispose

        public void dispose()
        Cleans up this class.
      • getResolveMaps

        public List<MapEntry> getResolveMaps()
        Description copied from interface: MapEntriesHandler
        Creates a flat listing of all the map entries used for resolving URLs to resources

        This method returns information about all resolve rules, such as vanity paths, mapping entries, virtual URLs and URL mappings.

        This list is computed on-demand and therefore should not be used in performance-critical code.

        Specified by:
        getResolveMaps in interface MapEntriesHandler
        Returns:
        an unmodifiable, sorted, list of resolution map entries
      • getResolveMapsIterator

        public Iterator<MapEntry> getResolveMapsIterator​(String requestPath)
        Description copied from interface: MapEntriesHandler
        Creates an iterator over the possibly applicable mapping entries for resolving a resource

        This method uses the request path to filter out any unapplicable mapping entries and is therefore preferrable over MapEntriesHandler.getResolveMaps().

        The iterator will iterate over the mapping entries in the order of the pattern length.

        Specified by:
        getResolveMapsIterator in interface MapEntriesHandler
        Returns:
        the map entry iterator
      • getMapMaps

        public Collection<MapEntry> getMapMaps()
        Description copied from interface: MapEntriesHandler
        Return a flat listing of map entries used for mapping resources to URLs

        This method returns information about all mapping rules. Note that vanity paths are excluded.

        Specified by:
        getMapMaps in interface MapEntriesHandler
        Returns:
        an unmodifiable collection of map entries
      • getAliasMap

        public Map<String,​String> getAliasMap​(String parentPath)
        Description copied from interface: MapEntriesHandler
        Returns all alias entries that for children of the specified parentPath

        The returned map has resource names as keys and aliases as values.

        Specified by:
        getAliasMap in interface MapEntriesHandler
        Parameters:
        parentPath - the parent path
        Returns:
        a map of all child alias entries, possibly empty
      • getVanityPathMappings

        public Map<String,​List<String>> getVanityPathMappings()
        Description copied from interface: MapEntriesHandler
        Returns vanity paths mappings

        The keys in the map are resource paths and the values are the vanity mappings.

        Specified by:
        getVanityPathMappings in interface MapEntriesHandler
        Returns:
        an unmodifiable list of vanity path mappings
      • onChange

        public void onChange​(List<org.apache.sling.api.resource.observation.ResourceChange> changes)
        Handles the change to any of the node properties relevant for vanity URL mappings. The MapEntries(MapConfigurationProvider, BundleContext, EventAdmin, StringInterpolationProvider) constructor makes sure the event listener is registered to only get appropriate events.
        Specified by:
        onChange in interface org.apache.sling.api.resource.observation.ResourceChangeListener