Interface UrlProvider

  • All Known Implementing Classes:
    UrlProviderImpl

    public interface UrlProvider
    • Field Detail

      • URL_KEY_PARAM

        static final String URL_KEY_PARAM
        The url_key parameter of the product or category. In the case of a ConfigurableProduct, this must hold the url_key of the configurable product and the variant url_key must be set with the variant_url_key parameter.
        See Also:
        Constant Field Values
      • URL_PATH_PARAM

        static final String URL_PATH_PARAM
        The url_path parameter of the product or category.
        See Also:
        Constant Field Values
      • SKU_PARAM

        static final String SKU_PARAM
        The sku parameter of the product. In the case of a ConfigurableProduct, this must hold the sku of the configurable product and the variant sku must be set with the variant_sku parameter.
        See Also:
        Constant Field Values
      • VARIANT_SKU_PARAM

        static final String VARIANT_SKU_PARAM
        In the case of a ConfigurableProduct, the variant_sku parameter must be set to the sku of the currently selected/chosen variant.
        See Also:
        Constant Field Values
      • VARIANT_URL_KEY_PARAM

        static final String VARIANT_URL_KEY_PARAM
        In the case of a ConfigurableProduct, the variant_url_key parameter must be set to the url_key of the currently selected/chosen variant.
        See Also:
        Constant Field Values
      • PAGE_PARAM

        static final String PAGE_PARAM
        Use this parameter name to set the page part of the URL. This ensures that implementations of the UrlProvider can easily "find out" if the page part of the URL is being statically set.
        See Also:
        Constant Field Values
    • Method Detail

      • toProductUrl

        String toProductUrl​(org.apache.sling.api.SlingHttpServletRequest request,
                            @Nullable
                            com.day.cq.wcm.api.Page page,
                            Map<String,​String> params)
        Returns the product page URL.
        Parameters:
        request - The current Sling HTTP request.
        page - The target page, if any. This parameter can be null if the URL template does not use the ${page} parameter.
        params - The parameters used in the URL template.
        Returns:
        The product URL.
      • toCategoryUrl

        String toCategoryUrl​(org.apache.sling.api.SlingHttpServletRequest request,
                             com.day.cq.wcm.api.Page page,
                             Map<String,​String> params)
        Returns the category page URL.
        Parameters:
        request - The current Sling HTTP request.
        page - The target page, if any. This parameter can be null if the URL template does not use the ${page} parameter.
        params - The parameters used in the URL template.
        Returns:
        The category URL.
      • getProductIdentifier

        org.apache.commons.lang3.tuple.Pair<UrlProvider.ProductIdentifierType,​String> getProductIdentifier​(org.apache.sling.api.SlingHttpServletRequest request)
        Returns the type and value of the product identifier used in the given Sling HTTP request.
        Parameters:
        request - The current Sling HTTP request.
        Returns:
        The type and value of the product identifier.
      • getCategoryIdentifier

        org.apache.commons.lang3.tuple.Pair<UrlProvider.CategoryIdentifierType,​String> getCategoryIdentifier​(org.apache.sling.api.SlingHttpServletRequest request)
        Returns the type and value of the category identifier used in the given Sling HTTP request.
        Parameters:
        request - The current Sling HTTP request.
        Returns:
        The type and value of the category identifier.