Package io.wcm.handler.url
Interface UrlHandler
-
@ProviderType public interface UrlHandlerRewrites and builds URLs for links to content pages and resources.The interface is implemented by a Sling Model. You can adapt from
SlingHttpServletRequestorResourceto get a context-specific handler instance.
-
-
Field Summary
Fields Modifier and Type Field Description static @NotNull StringSELECTOR_SUFFIXSelector that is always added if a Sling-URL contains a suffix (to avoid files and directories with same name in dispatcher cache)
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description @NotNull UrlBuilderget(@NotNull com.day.cq.wcm.api.Page page)Builds and optionally externalizes an URL using a builder pattern.@NotNull UrlBuilderget(@NotNull String path)Builds and optionally externalizes an URL using a builder pattern.@NotNull UrlBuilderget(@NotNull org.apache.sling.api.resource.Resource resource)Builds and optionally externalizes an URL using a builder pattern.@Nullable StringrewritePathToContext(@NotNull org.apache.sling.api.resource.Resource resource)Rewrites given path to current site or context.@Nullable StringrewritePathToContext(@NotNull org.apache.sling.api.resource.Resource resource, @NotNull org.apache.sling.api.resource.Resource contextResource)Rewrites given path to given site or context.
-
-
-
Field Detail
-
SELECTOR_SUFFIX
@NotNull static final @NotNull String SELECTOR_SUFFIX
Selector that is always added if a Sling-URL contains a suffix (to avoid files and directories with same name in dispatcher cache)- See Also:
- Constant Field Values
-
-
Method Detail
-
get
@NotNull @NotNull UrlBuilder get(@NotNull @NotNull String path)
Builds and optionally externalizes an URL using a builder pattern.- Parameters:
path- Path to start URL building with- Returns:
- URL builder which allows to chain further optional parameters before building the URL string.
-
get
@NotNull @NotNull UrlBuilder get(@NotNull @NotNull org.apache.sling.api.resource.Resource resource)
Builds and optionally externalizes an URL using a builder pattern.- Parameters:
resource- Resource, URL building is started with its path- Returns:
- URL builder which allows to chain further optional parameters before building the URL string.
-
get
@NotNull @NotNull UrlBuilder get(@NotNull @NotNull com.day.cq.wcm.api.Page page)
Builds and optionally externalizes an URL using a builder pattern.- Parameters:
page- Page Page, URL building is started with its path- Returns:
- URL builder which allows to chain further optional parameters before building the URL string.
-
rewritePathToContext
@Nullable @Nullable String rewritePathToContext(@NotNull @NotNull org.apache.sling.api.resource.Resource resource)
Rewrites given path to current site or context. The site root path is replaced with the one from current site This is useful if a link to an internal page points to a page outside the site (e.g. because the page containing the link was copied from the other site or inherited). When the AEM built-in rewrite logic was not applied the link would be invalid. This methods rewrites the link path to the current site to try to resolve it there.- Parameters:
resource- Resource to rewrite path from- Returns:
- Rewritten path or null if resource invalid
-
rewritePathToContext
@Nullable @Nullable String rewritePathToContext(@NotNull @NotNull org.apache.sling.api.resource.Resource resource, @NotNull @NotNull org.apache.sling.api.resource.Resource contextResource)
Rewrites given path to given site or context. The site root path is replaced with the one from current site. This is useful if a link to an internal page points to a page outside the site (e.g. because the page containing the link was copied from the other site or inherited). When the AEM built-in rewrite logic was not applied the link would be invalid. This methods rewrites the link path to the current site to try to resolve it there.- Parameters:
resource- Resource to rewrite path fromcontextResource- Context resource to which the path should be rewritten to- Returns:
- Rewritten path or null if resource or context resource is invalid
-
-