com.ibm.commerce.programadapter

Class HttpProgramAdapterImpl

  • java.lang.Object
    • com.ibm.commerce.adapter.AbstractHttpAdapter
      • com.ibm.commerce.programadapter.HttpProgramAdapterImpl
  • All Implemented Interfaces:
    com.ibm.commerce.adapter.DeviceFormatAdapter, com.ibm.commerce.adapter.HttpAdapter, com.ibm.commerce.adapter.HttpAdapterFactory


    public class HttpProgramAdapterImpl
    extends com.ibm.commerce.adapter.AbstractHttpAdapter
    implements com.ibm.commerce.adapter.HttpAdapter, com.ibm.commerce.adapter.HttpAdapterFactory
    The Program Adapter that handles HTTP requests.
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static java.lang.String _HTTP_CHARSET_CONSTANT
      The constant use to determine the encoding of the request.
      static java.lang.String _ICI_MESSAGE
      The parameter that will have the content of the message.
      static java.lang.String _ICI_NEWINBOUND_COMMAND_NAME
      This is the name of the command that can return a CommandProperty representation of the message.
      static java.lang.String _STR_CreateAdapter
      Constant representing the method name used for logging.
      static java.lang.String _STR_GetData
      Constant representing the method name used for logging.
      static java.lang.String _STR_InitFactory
      Constant representing the method name used for logging.
      static java.lang.String _STR_IsSupportedConfigParameter
      Constant representing the method name used for logging.
      static java.lang.String _STR_PostInvokeCommand
      Constant representing the method name used for logging.
      static java.lang.String _STR_PreInvokeCommand
      Constant representing the method name used for logging.
      static java.lang.String _STR_PreprocessRequest
      Constant representing the method name used for logging.
      static java.lang.String _STR_ProcessErrorResponse
      Constant representing the method name used for logging.
      static java.lang.String _STR_ProcessResponse
      Constant representing the method name used for logging.
      static java.lang.String _STR_SetCommandProperties
      Constant representing the method name used for logging.
      static java.lang.String _STR_ThisClass
      Constant representing the class name used for logging.
      static java.lang.String _STR_ValidateDeviceFormat
      Constant representing the method name used for logging.
      static java.lang.String COPYRIGHT
      IBM Copyright notice field.
      • Fields inherited from interface com.ibm.commerce.adapter.HttpAdapter

        DEVFMTID_BROWSER, DEVFMTNAME_BROWSER, DEVFMTNAME_IMODE, DEVFMTTYP_BROWSER, DEVFMTTYP_PVCDEVICE, DEVFMTTYP_XMLFMT, DEVFMTTYPID_BROWSER, DEVFMTTYPID_PVC, DEVFMTTYPID_XML
    • Constructor Summary

      Constructors 
      Constructor and Description
      HttpProgramAdapterImpl()
      Creates an instance of the Program Adapter to handle HTTP requests.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      boolean checkDeviceFormat(javax.servlet.http.HttpServletRequest req, TypedProperty prop)
      Return true if the input request can be processed by this adapter.
      com.ibm.commerce.adapter.HttpAdapter createAdapter(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, TypedProperty param)
      This method returns an instance of this adapter if the request has the format defined by this adapter.
      CommandProperty getCommandProperties()
      Returns the CommandProperty object of the request.
      java.lang.Integer getDefaultDeviceFormatId()
      Returns the default device format identifier for this adapter.
      java.lang.Integer getDeviceFormatTypeId()
      Gets the identifier of the device format type for this adapter.
      com.ibm.commerce.adapter.SessionContext getSessionContext()
      Gets the session context.
      com.ibm.commerce.server.HttpRequestWrapper getWrapperRequest()
      Gets the http request wrapper.
      boolean httpsRedirection()
      Returns true if Https redirection is required.
      void initFactory(org.w3c.dom.Element node)
      Initialize the adapter based on the information defined in the node.
      void postInvokeCommand(CommandContext commandContext)
      This method implements adapter specific function after the execution of a command.
      boolean preInvokeCommand(CommandContext commandContext)
      This method implements adapter specific function before the execution of a command.
      com.ibm.commerce.webcontroller.HttpControllerRequestObject preprocessRequest()
      This method preprocesses the request and returns a controller request object.
      boolean processErrorResponse(CommandContext commandContext, java.lang.Exception e)
      This method is called by the web controller when the execution of a request has failed.
      boolean processResponse(CommandContext commandContext, TypedProperty respProperty)
      This method is called by the web controller after it has successfully finished the execution of the request.
      void setCommandProperties(CommandProperty cmdProp)
      Sets the CommandProperties object.
      void setWrapperRequest(com.ibm.commerce.server.HttpRequestWrapper wrapper) 
      CommandProperty validateDeviceFormat(javax.servlet.http.HttpServletRequest req)
      Return a command property if there is a corresponding message mapper that can handle the request.
      • Methods inherited from class com.ibm.commerce.adapter.AbstractHttpAdapter

        displayGenericErrorView, getAdapterDesc, getContextPath, getDeviceFormatId, getDeviceFormatName, getDeviceFormatType, getDocumentPathName, getOrigReqName, getRequest, getRequestName, getRequestObject, getRequestProperties, getRequestURI, getResponse, getResponseObject, getUniqueIdentifier, httpRedirection, isDoubleClickHandlerEnabled, isEnabled, preInvokeAjaxCommand, preInvokeCommand, processRequest, processRequest, setAdapterDesc, setDefaultDeviceFormatId, setDeviceFormatClass, setDeviceFormatId, setDeviceFormatName, setDeviceFormatType, setDeviceFormatTypeId, setOrigReqName, setRequest, setRequestProperties, setResponse
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface com.ibm.commerce.adapter.HttpAdapter

        getAdapterDesc, getContextPath, getRequest, getRequestName, getRequestObject, getRequestProperties, getRequestURI, getResponse, getResponseObject, getUniqueIdentifier, isDoubleClickHandlerEnabled, preInvokeAjaxCommand, preInvokeCommand, processRequest, processRequest, setAdapterDesc, setRequest, setRequestProperties, setResponse
      • Methods inherited from interface com.ibm.commerce.adapter.HttpAdapterFactory

        getAdapterDesc, isEnabled
      • Methods inherited from interface com.ibm.commerce.adapter.DeviceFormatAdapter

        getDeviceFormatId, getDeviceFormatName, getDeviceFormatType, getDocumentPathName, setDefaultDeviceFormatId, setDeviceFormatId, setDeviceFormatName, setDeviceFormatType, setDeviceFormatTypeId
    • Field Detail

      • COPYRIGHT

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

        public static final java.lang.String _ICI_NEWINBOUND_COMMAND_NAME
        This is the name of the command that can return a CommandProperty representation of the message. This is called if the request does not have a corresponding message mapper.
        See Also:
        Constant Field Values
      • _ICI_MESSAGE

        public static final java.lang.String _ICI_MESSAGE
        The parameter that will have the content of the message.
        See Also:
        Constant Field Values
      • _HTTP_CHARSET_CONSTANT

        public static final java.lang.String _HTTP_CHARSET_CONSTANT
        The constant use to determine the encoding of the request.
        See Also:
        Constant Field Values
      • _STR_ThisClass

        public static final java.lang.String _STR_ThisClass
        Constant representing the class name used for logging.
        See Also:
        Constant Field Values
      • _STR_ValidateDeviceFormat

        public static final java.lang.String _STR_ValidateDeviceFormat
        Constant representing the method name used for logging.
        See Also:
        Constant Field Values
      • _STR_SetCommandProperties

        public static final java.lang.String _STR_SetCommandProperties
        Constant representing the method name used for logging.
        See Also:
        Constant Field Values
      • _STR_ProcessResponse

        public static final java.lang.String _STR_ProcessResponse
        Constant representing the method name used for logging.
        See Also:
        Constant Field Values
      • _STR_ProcessErrorResponse

        public static final java.lang.String _STR_ProcessErrorResponse
        Constant representing the method name used for logging.
        See Also:
        Constant Field Values
      • _STR_PreprocessRequest

        public static final java.lang.String _STR_PreprocessRequest
        Constant representing the method name used for logging.
        See Also:
        Constant Field Values
      • _STR_PreInvokeCommand

        public static final java.lang.String _STR_PreInvokeCommand
        Constant representing the method name used for logging.
        See Also:
        Constant Field Values
      • _STR_PostInvokeCommand

        public static final java.lang.String _STR_PostInvokeCommand
        Constant representing the method name used for logging.
        See Also:
        Constant Field Values
      • _STR_IsSupportedConfigParameter

        public static final java.lang.String _STR_IsSupportedConfigParameter
        Constant representing the method name used for logging.
        See Also:
        Constant Field Values
      • _STR_InitFactory

        public static final java.lang.String _STR_InitFactory
        Constant representing the method name used for logging.
        See Also:
        Constant Field Values
      • _STR_CreateAdapter

        public static final java.lang.String _STR_CreateAdapter
        Constant representing the method name used for logging.
        See Also:
        Constant Field Values
      • _STR_GetData

        public static final java.lang.String _STR_GetData
        Constant representing the method name used for logging.
        See Also:
        Constant Field Values
    • Constructor Detail

      • HttpProgramAdapterImpl

        public HttpProgramAdapterImpl()
        Creates an instance of the Program Adapter to handle HTTP requests.
    • Method Detail

      • checkDeviceFormat

        public boolean checkDeviceFormat(javax.servlet.http.HttpServletRequest req,
                                         TypedProperty prop)
        Return true if the input request can be processed by this adapter. This method will always return false because the method used to check the request is validateDeviceFormat().
        Specified by:
        checkDeviceFormat in interface com.ibm.commerce.adapter.HttpAdapterFactory
        Parameters:
        request - the HTTP request.
        properties - the request parameters.
        Returns:
        Always returns false.
      • createAdapter

        public com.ibm.commerce.adapter.HttpAdapter createAdapter(javax.servlet.http.HttpServletRequest request,
                                                                  javax.servlet.http.HttpServletResponse response,
                                                                  TypedProperty param)
        This method returns an instance of this adapter if the request has the format defined by this adapter. This method should first call the validateDeviceFormat() method. If it returns a CommandProperty object, then it will instantiate an instance of this adapter. The adapter instance returned will be initialized with request, response and request properties initialized.
        Specified by:
        createAdapter in interface com.ibm.commerce.adapter.HttpAdapterFactory
        Parameters:
        request - the HTTP request.
        response - the HTTP response.
        param - the request parameters
        Returns:
        This method returns an instance of this adapter if the request can be processed by this adapter. It returns null if this request cannot be processed by this adapter.
      • getCommandProperties

        public CommandProperty getCommandProperties()
        Returns the CommandProperty object of the request.
        Returns:
        The command properties of the request.
      • getDefaultDeviceFormatId

        public java.lang.Integer getDefaultDeviceFormatId()
        Returns the default device format identifier for this adapter.
        Specified by:
        getDefaultDeviceFormatId in interface com.ibm.commerce.adapter.DeviceFormatAdapter
        Overrides:
        getDefaultDeviceFormatId in class com.ibm.commerce.adapter.AbstractHttpAdapter
        Returns:
        The device format identifier.
      • getDeviceFormatTypeId

        public java.lang.Integer getDeviceFormatTypeId()
        Gets the identifier of the device format type for this adapter. This is the identifier of the message mapper added to the device format identifier of this adapter.
        Specified by:
        getDeviceFormatTypeId in interface com.ibm.commerce.adapter.DeviceFormatAdapter
        Overrides:
        getDeviceFormatTypeId in class com.ibm.commerce.adapter.AbstractHttpAdapter
        Returns:
        The identifier for the device format type.
      • getSessionContext

        public com.ibm.commerce.adapter.SessionContext getSessionContext()
                                                                  throws ECException
        Gets the session context.
        Specified by:
        getSessionContext in interface com.ibm.commerce.adapter.DeviceFormatAdapter
        Returns:
        The session context.
        Throws:
        ECException - if there is a problem obtaining the session context.
      • httpsRedirection

        public boolean httpsRedirection()
        Returns true if Https redirection is required. If a request comes in as Http but the command requires https, the request will be redirected.
        Specified by:
        httpsRedirection in interface com.ibm.commerce.adapter.HttpAdapter
        Returns:
        Always will return false.
      • initFactory

        public void initFactory(org.w3c.dom.Element node)
                         throws java.lang.Exception
        Initialize the adapter based on the information defined in the node. The initialization process is creating a descriptor for the adapter and passing the XML node to the descriptor for initialization.
        Specified by:
        initFactory in interface com.ibm.commerce.adapter.HttpAdapterFactory
        Overrides:
        initFactory in class com.ibm.commerce.adapter.AbstractHttpAdapter
        Parameters:
        node - the XML configuration for the adapter.
        Throws:
        java.lang.Exception - if there is a problem initializing.
      • postInvokeCommand

        public void postInvokeCommand(CommandContext commandContext)
                               throws ECException
        This method implements adapter specific function after the execution of a command.
        Specified by:
        postInvokeCommand in interface com.ibm.commerce.adapter.DeviceFormatAdapter
        Parameters:
        commandContext - CommandContext - the command context associated with the command.
        Throws:
        ECException
      • preInvokeCommand

        public boolean preInvokeCommand(CommandContext commandContext)
                                 throws ECException
        This method implements adapter specific function before the execution of a command.
        Specified by:
        preInvokeCommand in interface com.ibm.commerce.adapter.DeviceFormatAdapter
        Parameters:
        commandContext - the command context associated with the command.
        Returns:
        Always will return true.
        Throws:
        ECException - should never happen because the method only returns true.
      • preprocessRequest

        public com.ibm.commerce.webcontroller.HttpControllerRequestObject preprocessRequest()
        This method preprocesses the request and returns a controller request object.
        Specified by:
        preprocessRequest in interface com.ibm.commerce.adapter.HttpAdapter
        Overrides:
        preprocessRequest in class com.ibm.commerce.adapter.AbstractHttpAdapter
      • processErrorResponse

        public boolean processErrorResponse(CommandContext commandContext,
                                            java.lang.Exception e)
                                     throws ECException
        This method is called by the web controller when the execution of a request has failed. The web controller will execute the error view task associated with the exception if this method returns true.
        Specified by:
        processErrorResponse in interface com.ibm.commerce.adapter.DeviceFormatAdapter
        Overrides:
        processErrorResponse in class com.ibm.commerce.adapter.AbstractHttpAdapter
        Parameters:
        commandContext - commandContext for the request.
        exception - the exception caught when executing the request.
        Returns:
        Whether the error response is necessary. It is only needed if the view can be found.
        Throws:
        ECException - if there is a problem determining whether a response is necessary.
      • processResponse

        public boolean processResponse(CommandContext commandContext,
                                       TypedProperty respProperty)
                                throws ECException
        This method is called by the web controller after it has successfully finished the execution of the request. The web controller will execute the view task associated with the command if this method returns true.
        Specified by:
        processResponse in interface com.ibm.commerce.adapter.DeviceFormatAdapter
        Overrides:
        processResponse in class com.ibm.commerce.adapter.AbstractHttpAdapter
        Parameters:
        commandContext - the command context of the command.
        respProperties - the response properties returned by the command.
        Returns:
        Whether a response for the request is necessary.
        Throws:
        ECException - if there is a problem determining whether a response is necessary.
      • setCommandProperties

        public void setCommandProperties(CommandProperty cmdProp)
        Sets the CommandProperties object. This also gives the session context the opportunity to change the CommandProperty object if needed. This is because the session context provides the session and security handling of the adapter.
        Parameters:
        cmdProperties - the command properties which describes what command to execute.
      • validateDeviceFormat

        public CommandProperty validateDeviceFormat(javax.servlet.http.HttpServletRequest req)
        Return a command property if there is a corresponding message mapper that can handle the request. Before deciding to call a message mapper to decipher the message, the request's context type, method and encoding are checked. This is to ensure that this request is something that should be handled by this adapter.
        Parameters:
        request - the HTTP request.
        Returns:
        An instance of CommandProperty if this request can be processed by this adapter or null if this request cannot be processed by this adapter
      • getWrapperRequest

        public com.ibm.commerce.server.HttpRequestWrapper getWrapperRequest()
        Gets the http request wrapper.

        Returns:
      • setWrapperRequest

        public void setWrapperRequest(com.ibm.commerce.server.HttpRequestWrapper wrapper)
        Parameters:
        wrapper -