com.ibm.commerce.seo.url.helpers

Interface SEOURLMapper

  • All Known Implementing Classes:
    SEOURLMapperImpl


    public interface SEOURLMapper
    The interface defines the functionality provided by the SEO URL mapper implementation. The functionalities supported are:
    • Construction of SEO friendly URLs for use in the store. This functionality is used by the wcf:url tag library.
    • Deconstruction of incoming URLs to their dynamic struts equivalent.
    • Construction of partial SEO friendly URLs for catalog entries, categories and static pages, which are used for display purpose in CMC.
    • Build a map of Token Name and URL keyword for the pattern specified.
    The default implementation of this interface is SEOURLMapperImpl
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static java.lang.String COPYRIGHT
      IBM copyright field.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method and Description
      java.lang.String constructDynamicURLByPatternName(java.lang.String patternName, TypedProperty requestProperties, javax.servlet.jsp.PageContext pageContext)
      This method constructs the dynamic url using the patternName and set of request properties.
      java.lang.String constructSEOURLByPatternName(java.lang.String patternName, TypedProperty requestProperties, javax.servlet.jsp.PageContext pageContext, java.lang.String mappingName, java.util.Map params)
      This method constructs the SEO URL using the URL pattern name and request properties specified.
      java.util.List<java.lang.String> constructSEOUrlPrefixByUsageAndDevice(java.lang.String usage, java.lang.String device, TypedProperty urlProperties)
      This method constructs all the valid URL prefixes for the usage and device specified.The method looks up all the URL pattern configurations for the store specified based on the usage to find all the applicable URL patterns.
      javax.servlet.http.HttpServletRequest deconstructHttpRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.Integer storeId)
      This method deconstructs the incoming SEO URL to its dynamic equivalent.
      java.lang.Integer getStoreIdFromSEOURL(java.lang.String seoURL)
      This method parses the input seoUrl and returns storeId.
      boolean isSEOURLPatternFeatureEnabled(java.lang.Integer storeId)
      Check if SEO URL pattern based feature is enabled for the given store or not.
      java.util.List processRequestURL(javax.servlet.http.HttpServletRequest request)
      This method checks if the incoming URL in the request is actually an SEO URL or not.
    • Field Detail

      • COPYRIGHT

        static final java.lang.String COPYRIGHT
        IBM copyright field.
        See Also:
        Constant Field Values
    • Method Detail

      • constructSEOUrlPrefixByUsageAndDevice

        java.util.List<java.lang.String> constructSEOUrlPrefixByUsageAndDevice(java.lang.String usage,
                                                                               java.lang.String device,
                                                                               TypedProperty urlProperties)
                                                                        throws AbstractApplicationException
        This method constructs all the valid URL prefixes for the usage and device specified.The method looks up all the URL pattern configurations for the store specified based on the usage to find all the applicable URL patterns. Using the identified patterns and the input parameters specified, it identifies the URL prefixes that can be constructed.

        The storeId and langId are expected to be passed in the request properties.

        The URL prefix would have the location of the primary token for the usage, tagged with a special marker. All the other tokens in the URL pattern would be fully resolved. The marker used to identify the primary token location in the URL is $SEO:PRIMARYTOKEN$.

                Assuming there is an URL pattern /StoreToken/LangToken/ProductToken for usage PRODUCT and device mobile,
         the method would construct the following URL prefix if the storeId, langId are specified in the properties.
         
         http://localhost/shop/Madisons/en/$SEO:PRIMARYTOKEN$
         
         Where, 
         localhost is the host name for the web server, 
         //shop is the context root simplification defined for the site
         Madisons/en/$SEO:PRIMARYTOKEN$ is the URL prefix.
         
         
        Parameters:
        usage - The usage of the URL prefixes being constructed. For example, ITEM, PRODUCT etc.
        device - The device for which the URL is being constructed. Values supported are: SEOConstants#DEVICE_TYPE_MOBILE or SEOConstants#DEVICE_TYPE_STANDARD_BROWSER
        urlProperties - The input properties to construct the URL prefix.
        Returns:
        A list of valid URL prefixes if found. An empty list otherwise.
        Throws:
        AbstractApplicationException - When an error occurs while building the URL. Possible errors are:
        • The input properties does not have all the required values to find the keywords
        • A URL keyword has not been defined for the token in the pattern.
        • The value specified for a token in the request properties is invalid.
      • deconstructHttpRequest

        javax.servlet.http.HttpServletRequest deconstructHttpRequest(javax.servlet.http.HttpServletRequest request,
                                                                     javax.servlet.http.HttpServletResponse response,
                                                                     java.lang.Integer storeId)
                                                              throws AbstractApplicationException
        This method deconstructs the incoming SEO URL to its dynamic equivalent. The method parses the incoming URL to match a specific URL pattern defined for a specific store. If a valid match is found, the method builds the dynamic properties and sets it as the request properties for the struts view defined in the pattern.
        Parameters:
        request - The incoming servlet request.
        response - The incoming servlet response object.
        storeId - - Store Id for which the url needs to be deconstructed
        Returns:
        The converted servlet request containing the struts view and the deconstructed request properties.
        Throws:
        AbstractApplicationException - When the deconstruction fails.
      • constructSEOURLByPatternName

        java.lang.String constructSEOURLByPatternName(java.lang.String patternName,
                                                      TypedProperty requestProperties,
                                                      javax.servlet.jsp.PageContext pageContext,
                                                      java.lang.String mappingName,
                                                      java.util.Map params)
                                               throws AbstractApplicationException
        This method constructs the SEO URL using the URL pattern name and request properties specified. The storeId and langId are expected to be part of the request properties. If SEO URL based on pattern feature is needed, then patternName parameter is mandatory and should be non-null while mappingName will be ignored and null can be passed for mappingName If SEO URL based on mapper file feature is needed, then mappingName parameter is mandatory and should be non-null, while patternName will be ignored and null can be passed for patternName.
        Parameters:
        patternName - The URL pattern name to be used for constructing the SEO URL based on pattern feature.
        requestProperties - The input request properties for constructing the URL.
        pageContext - The page context of the page on which the URL is being constructed.
        mappingName - The mapping name used in old SEO implementation.
        params - Map of parameters passed to be used while constructing SEO URL based on mapping name. Will be ignored when construction is done based on patternName
        Returns:
        The SEO URL
        Throws:
        AbstractApplicationException - When an error occurs while building the URL. Possible errors are:
        • The input properties does not have all the required values to find the keywords
        • A URL keyword has not been defined for the token in the pattern.
        • The value specified for a token in the request properties is invalid.
      • constructDynamicURLByPatternName

        java.lang.String constructDynamicURLByPatternName(java.lang.String patternName,
                                                          TypedProperty requestProperties,
                                                          javax.servlet.jsp.PageContext pageContext)
                                                   throws AbstractApplicationException
        This method constructs the dynamic url using the patternName and set of request properties. PageContext is used to retrieve the storeId and patternName is used to retrieve the viewName from the pattern. All the key/value pair in requestProperties are set as query parameters in the resulting URL.
        Parameters:
        patternName - - Name of the pattern. ViewName will be retrieved based on this pattern name.
        requestProperties - - Request properties which goes in as query parameters in the resulting URL.
        pageContext - - JSP page context object.
        Returns:
        String - Dynamic URL
        Throws:
        AbstractApplicationException
      • isSEOURLPatternFeatureEnabled

        boolean isSEOURLPatternFeatureEnabled(java.lang.Integer storeId)
        Check if SEO URL pattern based feature is enabled for the given store or not.
        Parameters:
        storeId - - StoreId for which this check needs to be done
        Returns:
        true - if SEO based on URL pattern is enabled. false, otherwise.
        See Also:
        SEOURLPatternConfigurationRegistry#isSEOURLPatternFeatureEnabled(Integer)
      • getStoreIdFromSEOURL

        java.lang.Integer getStoreIdFromSEOURL(java.lang.String seoURL)
        This method parses the input seoUrl and returns storeId. Input string is parsed and each token in the string is matched against the available tokens whose usageType is set to 'Store' SEOConfigurationRegistry#getAllStaticSEOTokenUsageTypesForStore(Integer). Token value of the matched token will be returned as storeId.
        Parameters:
        seoURL - - Input string which will be tokenized and parsed.
        Returns:
        - storeId computed from input string
      • processRequestURL

        java.util.List processRequestURL(javax.servlet.http.HttpServletRequest request)
        This method checks if the incoming URL in the request is actually an SEO URL or not. The string after the last / in the request path of the request object is used to do this check. The incoming URL is considered as SEO URL only if it satisfies all of the below conditions:
        • It doesn't match any entry in the old SEO URL mapper XML
        • It doesn't match any action entry defined in the struts XML for the stores web app
        • The path doesn't contain dot(.) Ex: index.jsp, furniture.jpeg are all non-SEO URL's
        • storeId is present in the request object or it can be deduced by parsing the incoming URL.
        • SEO Pattern feature is enabled for the current store.
        This method also modifies the request object in following scenario's:
        • If the request path is found to be dynamic, then it modifies the request path in the request object by replacing the request path with the computed relative path (subString after the last / in the request path)
        • If the storeId is not present in request object and if it can be computed by parsing the request path then the storeId will be added to the request object.
        Parameters:
        request - - HttpServletRequest object. Note that this object might be modified in certain scenario's.
        Returns:
        - List -- Returns an ArrayList with 3 elements
        • Element 0 -- Contains Boolean.TRUE if the incoming URL is SEO URL based on pattern feature. Otherwise, Boolean FALSE
        • Element 1 -- The modified HTTPServletRequest object
        • Element 3 -- An Integer object specifying the URL Type, with following convention: value 0 indicates unknown url type. value 1 indicates old SEO URL. value 2 indicates dynamic view/action. value 3 indicates new SEO URL based on pattern feature.