com.ibm.commerce.content.commands

Class GetContentCmdImpl

  • All Implemented Interfaces:
    com.ibm.commerce.command.CacheableECCommand, ECCommand, ECTargetableCommand, TaskCommand, GetContentCmd, 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 GetContentCmdImpl
    extends TaskCommandImpl
    implements GetContentCmd, com.ibm.websphere.cache.Sizeable

    The GetContentCmdImpl class provides an implementation of the GetContentCmd task command that retrieves content from the specified content URL. The URL must be accessible from the WebSphere Commerce application server and the content must be text or HTML that can be included in the page that is returned to the browser.

    If the content includes embedded URLs, then the URLs must be:

    • fully qualified URLs
    • relative to the address of the page that includes the content
    • prefixed with a token that will be replaced by a configurable URL prefix

    This command can be configured by setting the following values in the STORECONF table:

    • wc.getContent.connectTimeout - The number of milliseconds allowed before the connection times out. This value is used when production content is retrieved. The default is 3000.
    • wc.getContent.previewConnectTimeout - The number of milliseconds allowed before the connection times out. This value is used when preview content is retrieved. If this value is not specified, then the value of wc.getContent.connectTimeout is used.
    • wc.getContent.readTimeout - The number of milliseconds allowed before the read times out. This value is used when production content is retrieved. The default is 3000.
    • wc.getContent.previewReadTimeout - The number of milliseconds allowed before the read times out. This value is used when preview content is retrieved. If this value is not specified, then the value of wc.getContent.readTimeout is used.
    • wc.getContent.cmsToken - A prefix token that will be found in the embedded URLs in production content. The token will be replaced by a configurable URL prefix. The replacement URL prefix is calculated by appending a configurable content path to a configurable content host. If this value is not specified, then embedded URLs will not be modified.
    • wc.getContent.cmsPreviewToken - A prefix token that will be found in the embedded URLs in preview content. The token will be replaced by a configurable URL prefix. The replacement URL prefix is calculated by appending a configurable content path to a configurable content host. If this value is not specified, the value of wc.getContent.cmsToken is used.
    • wc.getContent.cmsHost - The host name (including the scheme, host name, and port) of the location of production content. This value (along with the path) is used to replace the prefix token found in embedded URLs in the content.
    • wc.getContent.cmsPreviewHost - The host name (including the scheme, host name, and port) of the location of preview content. This value (along with the path) is used to replace the prefix token found in embedded URLs in the content.
    • wc.getContent.cmsPath - The path to the production location of content. This value (along with the host) is used to replace the prefix token found in embedded URLs in the content.
    • wc.getContent.cmsPreviewPath - The path to the preview location of content. This value (along with the path) is used to replace the prefix token found in embedded URLs in the content.
    • wc.getContent.useRelativeURLs - Indicates that relative URLs are used when replacing embedded content URLs found in the retrieved production content. Set this value to true if embedded content URLs are relative to the same host name as the pages that include them. This option can be overridden by setting the includeHostName property to true.
    • wc.getContent.characterEncoding - The character encoding of the content. The default is UTF-8.
    • wc.getContent.sendLTPAToken - Indicates that this command will send the LTPA token when retrieving content from the URL. Set this value to true to indicate that the LTPA token should be sent when retrieving content. Set to false to indicate that the LTPA token should not be sent. The default is false.
    • wc.getContent.sendPreviewLTPAToken - Indicates that this command will send the LTPA token when retrieving preview content from the URL. Set this value to true to indicate that the LTPA token should be sent when retrieving preview content. Set to false to indicate that the LTPA token should not be sent. If this value is not specified, then the value of wc.getContent.sendLTPAToken is used.
    • wc.getContent.ltpaTokenDomain - The domain for the LTPA token. If the host name of the content URL matches this domain, then the LTPA token is sent with the request. If this value is not specified, then the LTPA token is sent to all domains.
    • wc.getContent.previewLTPATokenDomain - The domain for the preview LTPA token. If the host name of the preview content URL matches this domain, then the LTPA token is sent with the request. If this value is not specified, then the value of wc.getContent.ltpaTokenDomain is used.
    • wc.getContent.ltpaTokenSecure - The secure connection setting for sending the LTPA token. If this value is set to true, then the LTPA token will only be sent to the content URL if it is a secure connection. The default value is false.
    • wc.getContent.previewLTPATokenSecure - The secure connection setting for sending the preview LTPA token. If this value is set to true, then the preview LTPA token will only be sent to the preview content URL if it is a secure connection. If this value is not specified, then the value of wc.getContent.ltpaTokenSecure is used.

    If the content cannot be retrieved, a warning is logged and the content property is set to null.

    This command is a cacheable command. The following cachespec entry will enable this command.

            <cache-entry>
                    <class>command</class>
                    <sharing-policy>not-shared</sharing-policy>
                    <name>com.ibm.commerce.content.commands.GetContentCmdImpl</name>
                    <cache-id>
                            <component type="method" id="getCacheId">
                                    <required>true</required>
                            </component>
                            <priority>1</priority>
                            <timeout>3600</timeout>
                            <inactivity>600</inactivity>
                    </cache-id>
    
                    <dependency-id>getContent</dependency-id>
            </cache-entry>
     
    See Also:
    Serialized Form
    • Constructor Detail

      • GetContentCmdImpl

        public GetContentCmdImpl()
    • Method Detail

      • getURL

        public java.lang.String getURL()
        Get the content URL.
        Returns:
        the content URL
      • getContent

        public java.lang.String getContent()
        Get the content. This value is available after the command is executed.
        Specified by:
        getContent in interface GetContentCmd
        Returns:
        the content
      • setPreview

        public void setPreview(boolean preview)
        Indicates that the content is preview content. Set to false for production content. The default is false.
        Specified by:
        setPreview in interface GetContentCmd
        Parameters:
        preview - preview option
      • getPreview

        public boolean getPreview()
        Get the preview option.
        Returns:
        preview option
      • setIncludeHostName

        public void setIncludeHostName(boolean includeHostName)
        Indicates that the URLs embedded in the content must be a fully qualified URLs that includes the scheme, host name and port. The command will use relative URLs if preview is set to false and the wc.getContent.useRelativeURLs configuration value is set to true. Set this property to true to force the embedded content URLs to be fully qualified with the configured host name. For example, if the content is intended for inclusion in an e-mail, then the embedded URLs must be fully qualified. The default is false.
        Specified by:
        setIncludeHostName in interface GetContentCmd
        Parameters:
        includeHostName - includeHostName option
      • getIncludeHostName

        public boolean getIncludeHostName()
        Get the includeHostName option.
        Returns:
        includeHostName
      • getObjectSize

        public long getObjectSize()
        Returns the estimated footprint size in bytes of this object and the objects it contains.
        Specified by:
        getObjectSize in interface com.ibm.websphere.cache.Sizeable
        Overrides:
        getObjectSize in class AbstractECTargetableCommand
        Returns:
        the estimated footprint size in bytes or -1 if a size cannot be determined.
      • setOutputProperties

        public void setOutputProperties(com.ibm.websphere.command.TargetableCommand cachedCommand)
        Copy the content from a cached version of this command.
        Specified by:
        setOutputProperties in interface com.ibm.websphere.command.TargetableCommand
        Overrides:
        setOutputProperties in class com.ibm.websphere.command.TargetableCommandImpl
        Parameters:
        cachedCommand - the cached version of this command
        See Also:
        TargetableCommandImpl.setOutputProperties(com.ibm.websphere.command.TargetableCommand)
      • getCacheId

        public java.lang.String getCacheId()
        Generate a cache ID for use with dynacache. This method will return null if the content is being retrieved for preview.
        Returns:
        cache ID