com.ibm.commerce.foundation.client.facade.bod.servlet.config

Class URLtoBusinessObjectDocumentUtility

  • java.lang.Object
    • com.ibm.commerce.foundation.client.facade.bod.servlet.config.URLtoBusinessObjectDocumentUtility


  • public class URLtoBusinessObjectDocumentUtility
    extends java.lang.Object

    This utility class provides a system service to perform the transformation between URL and Business Object Document. This utility is created to be used by Web applications to load the configuration that defines how a URL request can be transformed to a business object document and perform that transformation. This utility class can be used in any Web application that would like to define the transformation of a URL to business object document through configuration instead of programatically.

    It is strongly recommend that the web application that is leveraging this utility to provide a mechanism that the base code that is using this utility can be overriden to use the map based methods of the client API.

    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      BusinessObjectDocumentType createBusinessObjectDocument(commonj.sdo.DataObject documentRoot, java.lang.String urlObject, java.lang.String verb, java.util.Map requestParameters)
      This method contstructs the Business Object Document for the specified URL client object.
      java.util.Map createResponseMap(commonj.sdo.DataObject businessObjectDocument, java.lang.String urlObject)
      This method creates the response map that represents the responding business object document.
      static URLtoBusinessObjectDocumentUtility getInstance(javax.servlet.http.HttpServletRequest servletRequest)
      This method returns a unique instance of the URL to Business Object Document utility that has been defined and configured in the application.
      static URLtoBusinessObjectDocumentUtility getInstance(javax.servlet.ServletContext servletContext)
      This method returns a unique instance of the URL to Business Object Document utility that has been defined and configured in the application.
      java.lang.String getLocalizedCommonException(java.lang.String errorCode, java.util.Locale locale)
      This method gets a localized common message for client errors that are treated as exceptions.
      java.lang.String getLocalizedCommonException(java.lang.String errorCode, java.lang.Object[] parameters, java.util.Locale locale)
      This method gets a localized common message for client errors that are treated as exceptions.
      java.lang.String[] getMediatedReasonCode(java.lang.String clientObject, java.lang.String property, java.lang.String reasonCode, java.util.Locale locale)
      This method returns the mediated message and client object property associated with the specified reason code.
      java.lang.String[] getMediatedReasonCode(java.lang.String clientObject, java.lang.String property, java.lang.String reasonCode, java.lang.Object[] parameters, java.util.Locale locale)
      This method returns the mediated message and client object property associated with the specified reason code.
      void load(java.io.InputStream inputStream)
      This method loads the configuration that defines the URL to Business Object Document mediation.
      static URLtoBusinessObjectDocumentUtility newInstance()
      This method returns a new instance of the URL to Business Object Document utility.
      void reset()
      This method resets the configuration of the URL to Business Object Document utility.
      void setApplicationErrorResourceBundle(java.lang.String bundle)
      This method sets the base resource bundle for common exceptions.
      void setExtensionApplicationErrorResourceBundle(java.lang.String bundle)
      This method sets the extension resource bundle for common exceptions.
      java.lang.String toString()
      This method returns the string representation of the object for debugging purposes.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Method Detail

      • getInstance

        public static URLtoBusinessObjectDocumentUtility getInstance(javax.servlet.ServletContext servletContext)
        This method returns a unique instance of the URL to Business Object Document utility that has been defined and configured in the application.
        Parameters:
        servletContext - The servlet context where the utility should be obtained from.
        Returns:
        The unique instance of the utility class for the application.
      • getInstance

        public static URLtoBusinessObjectDocumentUtility getInstance(javax.servlet.http.HttpServletRequest servletRequest)
        This method returns a unique instance of the URL to Business Object Document utility that has been defined and configured in the application.
        Parameters:
        servletRequest - The servlet request where the utility should be obtained from.
        Returns:
        The unique instance of the utility class for the application.
      • newInstance

        public static URLtoBusinessObjectDocumentUtility newInstance()
        This method returns a new instance of the URL to Business Object Document utility. It is up to the caller to store this object if it is required for later requests.
        Returns:
        The unique instance of the utility class.
      • toString

        public java.lang.String toString()
        This method returns the string representation of the object for debugging purposes.
        Overrides:
        toString in class java.lang.Object
        Returns:
        The String representation of the object.
      • reset

        public void reset()
        This method resets the configuration of the URL to Business Object Document utility.
      • load

        public void load(java.io.InputStream inputStream)
                  throws org.xml.sax.SAXException,
                         java.io.IOException,
                         javax.xml.parsers.ParserConfigurationException
        This method loads the configuration that defines the URL to Business Object Document mediation. This method merges the configuration found in the specified input stream with the existing configuration currently loaded.
        Parameters:
        inputStream - The configuration that defines the noun configuration.
        Throws:
        org.xml.sax.SAXException - A problem parsing the configuration.
        java.io.IOException - A problem reading the configuration.
        javax.xml.parsers.ParserConfigurationException - A problem parsing the configuration.
      • getMediatedReasonCode

        public java.lang.String[] getMediatedReasonCode(java.lang.String clientObject,
                                                        java.lang.String property,
                                                        java.lang.String reasonCode,
                                                        java.util.Locale locale)
        This method returns the mediated message and client object property associated with the specified reason code.
        Parameters:
        clientObject - The name of the client object.
        property - The known property of the client object to resolve.
        reasonCode - The reason code to mediate.
        locale - The locale of the message.
        Returns:
        A string array with only two elements. The first element is the mediated message and the other is the client property the reason code is associated with. If no message is found then the first element is null. If no client property is registered with a reason code, then null is returned in the second element.
      • getMediatedReasonCode

        public java.lang.String[] getMediatedReasonCode(java.lang.String clientObject,
                                                        java.lang.String property,
                                                        java.lang.String reasonCode,
                                                        java.lang.Object[] parameters,
                                                        java.util.Locale locale)
        This method returns the mediated message and client object property associated with the specified reason code.
        Parameters:
        clientObject - The name of the client object.
        property - The known property of the client object to resolve.
        reasonCode - The reason code to mediate.
        parameters - The reasons that is associated with the reason code.
        locale - The locale of the message.
        Returns:
        A string array with only two elements. The first element is the mediated message and the other is the client property the reason code is associated with. If no message is found then the first element is null. If no client property is registered with a reason code, then null is returned in the second element.
      • createBusinessObjectDocument

        public BusinessObjectDocumentType createBusinessObjectDocument(commonj.sdo.DataObject documentRoot,
                                                                       java.lang.String urlObject,
                                                                       java.lang.String verb,
                                                                       java.util.Map requestParameters)
                                                                throws java.lang.Exception
        This method contstructs the Business Object Document for the specified URL client object. Based on the URL parameter to noun element association and the verb specified, the right business object is created based on the information in the request parameters.
        Parameters:
        documentRoot - The parent container of the business object document. This parent allows the creation of the business object document.
        urlObject - The URL client object.
        verb - The verb of the business object document.
        requestParameters - The URL parameters specified in the URL request. This map will contain a String as the key and a String array as the value.
        Returns:
        The business object document that represents the specified request.
        Throws:
        java.lang.Exception - There is a problem building the business object document where parameters specified are invalid or other issues. These exceptions are typically application errors because of invalid input.
      • createResponseMap

        public java.util.Map createResponseMap(commonj.sdo.DataObject businessObjectDocument,
                                               java.lang.String urlObject)
                                        throws java.lang.Exception
        This method creates the response map that represents the responding business object document. The returning map is composed of those properties that have been flagged to be returned based on the specified response business object document.
        Parameters:
        businessObjectDocument - The response business object document.
        urlObject - The name of the URL client object.
        Returns:
        The map that represents the responding business object document.
        Throws:
        java.lang.Exception - There is a problem building the business object document where parameters specified are invalid or other issues. These exceptions are typically application errors because of invalid input.
      • setApplicationErrorResourceBundle

        public void setApplicationErrorResourceBundle(java.lang.String bundle)
        This method sets the base resource bundle for common exceptions.
        Parameters:
        bundle - The base resource bundle for common exceptions.
      • setExtensionApplicationErrorResourceBundle

        public void setExtensionApplicationErrorResourceBundle(java.lang.String bundle)
        This method sets the extension resource bundle for common exceptions.
        Parameters:
        bundle - The extension resource bundle for common extentions.
      • getLocalizedCommonException

        public java.lang.String getLocalizedCommonException(java.lang.String errorCode,
                                                            java.util.Locale locale)
        This method gets a localized common message for client errors that are treated as exceptions.
        Parameters:
        errorCode - The errorCode of the client error.
        locale - The locale for the message. If the locale is null the default locale is used.
        Returns:
        The localized common exception message, null if a localized common exception message does not exist.
      • getLocalizedCommonException

        public java.lang.String getLocalizedCommonException(java.lang.String errorCode,
                                                            java.lang.Object[] parameters,
                                                            java.util.Locale locale)
        This method gets a localized common message for client errors that are treated as exceptions.
        Parameters:
        errorCode - The errorCode of the client error.
        parameters - The message parameters that can be substituted in the message.
        locale - The locale for the message. If the locale is null the default locale is used.
        Returns:
        The localized common exception message, null if a localized common exception message does not exist.