Class MapEntries
- java.lang.Object
-
- org.apache.sling.resourceresolver.impl.mapping.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
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_DEFAULT_VANITY_PATH_REDIRECT_STATUSstatic StringDEFAULT_MAP_ROOTstatic StringPROP_REDIRECT_EXTERNALstatic StringPROP_REDIRECT_EXTERNAL_REDIRECT_STATUSstatic StringPROP_REDIRECT_EXTERNAL_STATUSstatic StringPROP_VANITY_ORDERstatic StringPROP_VANITY_PATH-
Fields inherited from interface org.apache.sling.resourceresolver.impl.mapping.MapEntriesHandler
EMPTY
-
-
Constructor Summary
Constructors Constructor Description MapEntries(MapConfigurationProvider factory, org.osgi.framework.BundleContext bundleContext, org.osgi.service.event.EventAdmin eventAdmin, StringInterpolationProvider stringInterpolationProvider, Optional<org.apache.sling.resourceresolver.impl.ResourceResolverMetrics> metrics)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddispose()Cleans up this class.protected booleandoInit()Actual initializer.Map<String,String>getAliasMap(String parentPath)Returns all alias entries that for children of the specifiedparentPathCollection<MapEntry>getMapMaps()Return a flat listing of map entries used for mapping resources to URLsList<MapEntry>getResolveMaps()Creates a flat listing of all the map entries used for resolving URLs to resourcesIterator<MapEntry>getResolveMapsIterator(String requestPath)Creates an iterator over the possibly applicable mapping entries for resolving a resourceMap<String,List<String>>getVanityPathMappings()Returns vanity paths mappingsprotected voidinitializeVanityPaths()Actual vanity paths initializer.booleanisOptimizeAliasResolutionEnabled()Whether alias resolution optimization is enabled.voidlogDisableAliasOptimization()Log an error if alias optimization should be used but is currently disabledvoidonChange(List<org.apache.sling.api.resource.observation.ResourceChange> changes)Handles the change to any of the node properties relevant for vanity URL mappings.
-
-
-
Field Detail
-
PROP_REDIRECT_EXTERNAL
public static final String PROP_REDIRECT_EXTERNAL
- See Also:
- Constant Field Values
-
PROP_REDIRECT_EXTERNAL_STATUS
public static final String PROP_REDIRECT_EXTERNAL_STATUS
- See Also:
- Constant Field Values
-
PROP_REDIRECT_EXTERNAL_REDIRECT_STATUS
public static final String PROP_REDIRECT_EXTERNAL_REDIRECT_STATUS
- See Also:
- Constant Field Values
-
PROP_VANITY_PATH
public static final String PROP_VANITY_PATH
- See Also:
- Constant Field Values
-
PROP_VANITY_ORDER
public static final String PROP_VANITY_ORDER
- See Also:
- Constant Field Values
-
DEFAULT_MAP_ROOT
public static final String DEFAULT_MAP_ROOT
- See Also:
- Constant Field Values
-
DEFAULT_DEFAULT_VANITY_PATH_REDIRECT_STATUS
public static final int DEFAULT_DEFAULT_VANITY_PATH_REDIRECT_STATUS
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MapEntries
public MapEntries(MapConfigurationProvider factory, org.osgi.framework.BundleContext bundleContext, org.osgi.service.event.EventAdmin eventAdmin, StringInterpolationProvider stringInterpolationProvider, Optional<org.apache.sling.resourceresolver.impl.ResourceResolverMetrics> metrics) throws org.apache.sling.api.resource.LoginException, IOException
- Throws:
org.apache.sling.api.resource.LoginExceptionIOException
-
-
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 IOExceptionActual 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:MapEntriesHandlerCreates a flat listing of all the map entries used for resolving URLs to resourcesThis 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:
getResolveMapsin interfaceMapEntriesHandler- Returns:
- an unmodifiable, sorted, list of resolution map entries
-
getResolveMapsIterator
public Iterator<MapEntry> getResolveMapsIterator(String requestPath)
Description copied from interface:MapEntriesHandlerCreates an iterator over the possibly applicable mapping entries for resolving a resourceThis 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:
getResolveMapsIteratorin interfaceMapEntriesHandler- Returns:
- the map entry iterator
-
getMapMaps
public Collection<MapEntry> getMapMaps()
Description copied from interface:MapEntriesHandlerReturn a flat listing of map entries used for mapping resources to URLsThis method returns information about all mapping rules. Note that vanity paths are excluded.
- Specified by:
getMapMapsin interfaceMapEntriesHandler- Returns:
- an unmodifiable collection of map entries
-
isOptimizeAliasResolutionEnabled
public boolean isOptimizeAliasResolutionEnabled()
Description copied from interface:MapEntriesHandlerWhether alias resolution optimization is enabled. If it is enabledMapEntriesHandler.getAliasMap(String)can be used.- Specified by:
isOptimizeAliasResolutionEnabledin interfaceMapEntriesHandler
-
getAliasMap
public Map<String,String> getAliasMap(String parentPath)
Description copied from interface:MapEntriesHandlerReturns all alias entries that for children of the specifiedparentPathThe returned map has resource names as keys and aliases as values.
- Specified by:
getAliasMapin interfaceMapEntriesHandler- 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:MapEntriesHandlerReturns vanity paths mappingsThe keys in the map are resource paths and the values are the vanity mappings.
- Specified by:
getVanityPathMappingsin interfaceMapEntriesHandler- 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:
onChangein interfaceorg.apache.sling.api.resource.observation.ResourceChangeListener
-
logDisableAliasOptimization
public void logDisableAliasOptimization()
Description copied from interface:MapEntriesHandlerLog an error if alias optimization should be used but is currently disabled- Specified by:
logDisableAliasOptimizationin interfaceMapEntriesHandler
-
-