Class ResourceMapperImpl
- All Implemented Interfaces:
ResourceMapper
-
Constructor Summary
ConstructorsConstructorDescriptionResourceMapperImpl(org.apache.sling.resourceresolver.impl.ResourceResolverImpl resolver, ResourceDecoratorTracker resourceDecorator, MapEntriesHandler mapEntries, Object namespaceMangler) -
Method Summary
Modifier and TypeMethodDescriptiongetAllMappings(String resourcePath) Returns all possible mappings for a givenresourcePathas paths.getAllMappings(String resourcePath, javax.servlet.http.HttpServletRequest request) Returns all possible mappings for a givenresourcePathas URLs.getMapping(String resourcePath) Returns a path mapped from the (resource) path applying the reverse mapping used by theResourceResolver.resolve(String)such that when the path is given to theResourceResolver.resolve(String)method the same resource is returned.getMapping(String resourcePath, javax.servlet.http.HttpServletRequest request) Returns an URL mapped from the (resource) path applying the reverse mapping used by theResourceResolver.resolve(HttpServletRequest, String)such that when the path is given to theResourceResolver.resolve(HttpServletRequest, String)method the same resource is returned.
-
Constructor Details
-
ResourceMapperImpl
public ResourceMapperImpl(org.apache.sling.resourceresolver.impl.ResourceResolverImpl resolver, ResourceDecoratorTracker resourceDecorator, MapEntriesHandler mapEntries, Object namespaceMangler)
-
-
Method Details
-
getMapping
Description copied from interface:ResourceMapperReturns a path mapped from the (resource) path applying the reverse mapping used by theResourceResolver.resolve(String)such that when the path is given to theResourceResolver.resolve(String)method the same resource is returned.Note, that technically the
resourcePathneed not refer to an existing resource. This method just applies the mappings and returns the resulting string. If theresourcePathdoes not address an existing resource roundtripping may of course not work and callingResourceResolver.resolve(String)with the path returned may returnnull.This method is intended as the reverse operation of the
ResourceResolver.resolve(String)method.- Specified by:
getMappingin interfaceResourceMapper- Parameters:
resourcePath- The path for which to return a mapped path.- Returns:
- The mapped path.
-
getMapping
Description copied from interface:ResourceMapperReturns an URL mapped from the (resource) path applying the reverse mapping used by theResourceResolver.resolve(HttpServletRequest, String)such that when the path is given to theResourceResolver.resolve(HttpServletRequest, String)method the same resource is returned.Note, that technically the
resourcePathneed not refer to an existing resource. This method just applies the mappings and returns the resulting string. If theresourcePathdoes not address an existing resource roundtripping may of course not work and callingResourceResolver.resolve(HttpServletRequest, String)with the path returned may returnnull.This method is intended as the reverse operation of the
ResourceResolver.resolve(HttpServletRequest, String)method. As such the URL returned is expected to be an absolute URL including scheme, host, any servlet context path and the actual path used to resolve the resource.- Specified by:
getMappingin interfaceResourceMapper- Parameters:
resourcePath- The path for which to return a mapped path.request- The http servlet request object which may be used to apply more mapping functionality.- Returns:
- The mapped URL.
-
getAllMappings
Description copied from interface:ResourceMapperReturns all possible mappings for a givenresourcePathas paths.This method differs from the
ResourceMapper.getMapping(String)variant by guaranteeing that all possible mappings are returned for a specified path.The mappings are not returned in any particular order.
- Specified by:
getAllMappingsin interfaceResourceMapper- Parameters:
resourcePath- The path for which to return a mapped path.- Returns:
- a collection of mapped URLs, in no particular order. May not be null or empty.
-
getAllMappings
public Collection<String> getAllMappings(String resourcePath, javax.servlet.http.HttpServletRequest request) Description copied from interface:ResourceMapperReturns all possible mappings for a givenresourcePathas URLs.This method differs from the
ResourceMapper.getMapping(String, HttpServletRequest)variant by guaranteeing that all possible mappings are returned for a specified path.The mappings are not returned in any particular order.
- Specified by:
getAllMappingsin interfaceResourceMapper- Parameters:
resourcePath- The path for which to return a mapped path.request- The http servlet request object which may be used to apply more mapping functionality.- Returns:
- a collection of mapped URLs, in no particular order. May not be null or empty.
-