com.ibm.commerce.marketing.commands.elements

Class DisplayLocationBasedContentActionTaskCmdImpl

  • All Implemented Interfaces:
    DisplayLocationBasedContentActionTaskCmd, MarketingCampaignElementTaskCmd, com.ibm.websphere.cache.Sizeable, com.ibm.websphere.command.CacheableCommand, com.ibm.websphere.command.Command, com.ibm.websphere.command.CommandCaller, com.ibm.websphere.command.TargetableCommand, java.io.Serializable


    public class DisplayLocationBasedContentActionTaskCmdImpl
    extends MarketingCampaignElementTaskCmdImpl
    implements DisplayLocationBasedContentActionTaskCmd
    This command returns location based content to display in an e-Marketing Spot. The command first finds the customer's current location based on the location type specified. The current location is first looked for in the trigger parameters in a parameter with the same name as the location type. For example, the current location can be passed as parameters in the Get MarketingSpotData call in the e-Marketing Spot JSP snippet.
     <wcf:param name="pointOfInterest" value="12345" />               
     <wcf:param name="region" value="Toronto" /> 
     
    If the parameter is not found in the trigger parameters, then the location is looked for in the customer's user behavior record under an element name the same as the location type. The CheckInStoreEvent event is configured to record the customer's latest point of interest and region location information. Once the current location is identified, the location is used to form a URL identifying the content to display in the e-Marketing Spot. The naming convention of the content is:
    • Point of Interest: prefix + pointOfInterest + suffix
    • Region: prefix + region + suffix
    The prefix and suffix can be specified in any of the following ways:
    1. Passed in as parameters in the Get MarketingSpotData call
       <wcf:param name="DM_locationContentUrlPrefix" value="http://localhost/wcsstore/Madisons/images/eFlyer/" />
       <wcf:param name="DM_locationContentUrlSuffix" value=".png" />
       
      This will override any setting in the "Display Location-based Content" action definition.
    2. Specified in the "Display Location-based Content" action definition in the optional URL prefix and URL suffix fields.
    3. As a customization by extending this class and implementing the composeContentURL method.
    This command will validate that the content specified by the URL exists. There are two ways to validate the content. The method to use is specified in the DM_locationContentValidation parameter. Valid values are url, file, and none. If this parameter is not specified, then the default is url.
    1. As a URL. A full URI must be passed in.
       <c:set var="rootPath" value="${request.scheme}://${request.serverName}${request.contextPath}/servlet"/>
       <c:set var="relativePath" value="${jspStoreDir}images/eFlyer/"/>
       
       <wcf:param name="DM_locationContentValidation" value="url" />
       <wcf:param name="DM_locationContentUrlPrefix" value="${rootPath}${relativePath}" />
       <wcf:param name="DM_locationContentUrlSuffix" value=".png" />
       
    2. As a file on the file system. This command will prepend the value of the wcsstore alias to the prefix.
       <c:set var="relativeStoreJspUrl" value="${jspStoreDir}images/eFlyer/"/>
       
       <wcf:param name="DM_locationContentValidation" value="file" />
       <wcf:param name="DM_locationContentUrlPrefix" value="${relativeStoreJspUrl}" />
       <wcf:param name="DM_locationContentUrlSuffix" value=".jsp" />
       
    Handling different content for different languages (and fallback behavior) will require configuration and/or customization. For example, you may want to include ${locale} as part of the path.

    In some situations, you may not want this command to validate that the content specified by the URL exists. To disable that check, you can either:

    • Pass in a parameter in the Get MarketingSpotData call
       <wcf:param name="DM_locationContentValidation" value="none" />
       
    • As a customization by extending this class and implementing the validURL method to return true.
    See Also:
    Serialized Form
    • Field Detail

      • COPYRIGHT

        public static final java.lang.String COPYRIGHT
        IBM copyright notice field.
        See Also:
        Constant Field Values
      • CLASSNAME

        public static final java.lang.String CLASSNAME
        The name of this class.
        See Also:
        Constant Field Values
      • DISPLAY_TYPE_URL_CONTENT

        public static final java.lang.String DISPLAY_TYPE_URL_CONTENT
        A constant representing Location-based Content to be displayed in an e-Marketing Spot.
        See Also:
        Constant Field Values
    • Constructor Detail

      • DisplayLocationBasedContentActionTaskCmdImpl

        public DisplayLocationBasedContentActionTaskCmdImpl()
        This method is the default constructor. It currently performs no actions.
    • Method Detail

      • performExecute

        public void performExecute()
        This method finds content associated with the customer's current location. If a current location is not found, or has expired, nothing is done. A timeout value can be specified to indicate for how long the user data point of interest and region information remains valid. Once the data has expired, the customer is no longer considered to be in that location. By default, the timeout will be set to one hour. This can be changed by configuring the setting in the wc-admin-component.xml file.
        <_config:property name="traceElementTimeoutConfig" value="pointOfInterest,3600,region,3600"/>
        Specified by:
        performExecute in interface com.ibm.websphere.command.TargetableCommand
        Overrides:
        performExecute in class MarketingCampaignElementTaskCmdImpl
      • locateContent

        public void locateContent(java.lang.String urlPrefix,
                                  java.lang.String currentLocation,
                                  java.lang.String urlSuffix,
                                  java.lang.String validation)
        This method calls composeContentURL to get the URL for the content. If validation has not been disabled, then validURL is called to check if the content exists. If the content is found, it creates an EMarketingSpotDataBean of the type UrlContent and the URL is the unique ID.
        Parameters:
        urlPrefix - The prefix used to create the content URL.
        currentLocation - The customer's current location.
        urlSuffix - The suffix used to create the content URL.
        validation - The type of validation to be done. Valid values are url, file, or none.
      • composeContentURL

        public java.lang.String composeContentURL(java.lang.String urlPrefix,
                                                  java.lang.String currentLocation,
                                                  java.lang.String urlSuffix)
        This method appends the URL prefix, current location, and URL suffix to create a URL that identifies the content to be displayed in the e-Marketing Spot.
        Parameters:
        urlPrefix - The prefix used to create the content URL.
        currentLocation - The customer's current location.
        urlSuffix - The suffix used to create the content URL.
        Returns:
        This method returns the full URL for the content to be displayed.
      • validFile

        public boolean validFile(java.lang.String contentURL)
        This method checks that the file exists.
        Parameters:
        contentURL - The content URL.
        Returns:
        This method returns true if the JSP file exists.
      • validURL

        public boolean validURL(java.lang.String contentURL)
        This method checks that the content JSP file exists.
        Parameters:
        contentURL - The content URL.
        Returns:
        This method returns true if the URL exists.
      • validateParameters

        public java.util.List validateParameters(java.util.Map elementParameters)
        This method validates that all the required name value pairs have been set for the campaign element. It checks for locationType.
        Specified by:
        validateParameters in interface MarketingCampaignElementTaskCmd
        Overrides:
        validateParameters in class MarketingCampaignElementTaskCmdImpl
        Parameters:
        elementParameters - The name value pairs for this element.
        Returns:
        This method returns a list of ApplicationError exceptions that contains any validation errors. The list may be empty or be null.