Interface UrlProvider


  • @ProviderType
    public interface UrlProvider
    • Field Detail

      • URL_KEY_PARAM

        @Deprecated
        static final String URL_KEY_PARAM
        Deprecated.
        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
      • SKU_PARAM

        @Deprecated
        static final String SKU_PARAM
        Deprecated.
        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

        @Deprecated
        static final String VARIANT_SKU_PARAM
        Deprecated.
        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

        @Deprecated
        static final String VARIANT_URL_KEY_PARAM
        Deprecated.
        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

        @Deprecated
        static final String PAGE_PARAM
        Deprecated.
        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

        @Deprecated
        String toProductUrl​(@Nullable
                            org.apache.sling.api.SlingHttpServletRequest request,
                            @Nullable
                            com.day.cq.wcm.api.Page page,
                            Map<String,​String> params)
        Returns the product page URL. All required attributes to generate a valid category page URL must be provided via the params parameter.

        This method should be used if the component already loaded the URL attributes.

        Either request or page parameter can be null but not both. If both are null an IllegalArgumentException is thrown.

        Parameters:
        request - The current Sling HTTP request.
        page - This parameter can be null if the URL template does set a {{page}} parameter and a request is given.
        params - The parameters used in the URL template.
        Returns:
        The product URL.
      • toProductUrl

        String toProductUrl​(@Nullable
                            org.apache.sling.api.SlingHttpServletRequest request,
                            @Nullable
                            com.day.cq.wcm.api.Page page,
                            ProductUrlFormat.Params params)
        Returns the product page URL. All required attributes to generate a valid category page URL must be provided via the params parameter.

        This method should be used if the component already loaded the URL attributes.

        Either request or page parameter can be null but not both. If both are null an IllegalArgumentException is thrown.

        Parameters:
        request - The current Sling HTTP request.
        page - This parameter can be null if the URL template does set a {{page}} parameter and a request is given.
        params - The parameters used in the URL template.
        Returns:
        The product URL.
      • toProductUrl

        String toProductUrl​(@Nullable
                            org.apache.sling.api.SlingHttpServletRequest request,
                            @Nullable
                            com.day.cq.wcm.api.Page page,
                            String productIdentifier)
        Returns the product page URL. Only the product identifier must be provided, the implementation will query the needed URL attributes to generate a complete URL based on the configuration.

        This method should be used if the component only can provide the product identifier.

        Either request or page parameter can be null but not both. If both are null an IllegalArgumentException is thrown.

        Parameters:
        request - The current Sling HTTP request.
        page - This parameter can be null if the URL template does set a {{page}} parameter and a request is given.
        productIdentifier - The product identifier.
        Returns:
        The product URL.
      • toCategoryUrl

        @Deprecated
        String toCategoryUrl​(@Nullable
                             org.apache.sling.api.SlingHttpServletRequest request,
                             @Nullable
                             com.day.cq.wcm.api.Page page,
                             Map<String,​String> params)
        Returns the category page URL. All required attributes to generate a valid category page URL must be provided via the params parameter.

        This method should be used if the component already loaded the URL attributes.

        Either request or page parameter can be null but not both. If both are null an IllegalArgumentException is thrown.

        Parameters:
        request - The current Sling HTTP request.
        page - This parameter can be null if the URL template does set a {{page}} parameter and a request is given.
        params - The parameters used in the URL template.
        Returns:
        The category URL.
      • toCategoryUrl

        String toCategoryUrl​(@Nullable
                             org.apache.sling.api.SlingHttpServletRequest request,
                             @Nullable
                             com.day.cq.wcm.api.Page page,
                             CategoryUrlFormat.Params params)
        Returns the category page URL. All required attributes to generate a valid category page URL must be provided via the params parameter.

        This method should be used if the component already loaded the URL attributes.

        Either request or page parameter can be null but not both. If both are null an IllegalArgumentException is thrown.

        Parameters:
        request - The current Sling HTTP request.
        page - This parameter can be null if the URL template does set a {{page}} parameter and a request is given.
        params - The parameters used in the URL template.
        Returns:
        The category URL.
      • toCategoryUrl

        String toCategoryUrl​(@Nullable
                             org.apache.sling.api.SlingHttpServletRequest request,
                             @Nullable
                             com.day.cq.wcm.api.Page page,
                             String categoryIdentifier)
        Returns the category page URL. Only the category identifier must be provided, the implementation will query the needed URL attributes to generate a complete URL based on the configuration.

        This method should be used if the component only can provide the category identifier.

        Either request or page parameter can be null but not both. If both are null an IllegalArgumentException is thrown.

        Parameters:
        request - The current Sling HTTP request.
        page - This parameter can be null if the URL template does set a {{page}} parameter and a request is given.
        categoryIdentifier - The category identifier.
        Returns:
        The category URL.
      • getProductIdentifier

        String getProductIdentifier​(org.apache.sling.api.SlingHttpServletRequest request)
        Returns the product identifier (sku) used in the given Sling HTTP request. The product identifier can be used to load product data.
        Parameters:
        request - The current Sling HTTP request.
        Returns:
        The product sku identifier.
      • parseProductUrlFormatParameters

        ProductUrlFormat.Params parseProductUrlFormatParameters​(org.apache.sling.api.SlingHttpServletRequest request)
        Parses and returns the ProductUrlFormat.Params used in the given SlingHttpServletRequest based on the URLProvider configuration for product page URLs.
        Parameters:
        request - The current Sling HTTP request.
        Returns:
        the parsed ProductUrlFormat.Params
      • getCategoryIdentifier

        String getCategoryIdentifier​(org.apache.sling.api.SlingHttpServletRequest request)
        Returns the category identifier used in the given Sling HTTP request. The category identifier can be used to load category data.
        Parameters:
        request - The current Sling HTTP request.
        Returns:
        The category uid identifier.
      • parseCategoryUrlFormatParameters

        CategoryUrlFormat.Params parseCategoryUrlFormatParameters​(org.apache.sling.api.SlingHttpServletRequest request)
        Parses and returns the CategoryUrlFormat.Params used in the given Sling HTTP request based on the URLProvider configuration for category page URLs.
        Parameters:
        request - The current Sling HTTP request.
        Returns:
        parsed CategoryUrlFormat.Params