com.ibm.commerce.foundation.rest.resourcehandler

Class AbstractResourceHandler

    • Field Detail

      • COPYRIGHT

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

      • AbstractResourceHandler

        public AbstractResourceHandler()
    • Method Detail

      • getMapFromRequest

        public java.util.Map<java.lang.String,java.lang.Object> getMapFromRequest(javax.servlet.http.HttpServletRequest request,
                                                                                  java.lang.String responseFormat)
                                                                           throws java.lang.Exception
        This method gets Map from HttpServletRequest based on JSON or XML input format.
        Parameters:
        request - the request
        responseFormat - the response format
        Returns:
        the map from request
        Throws:
        java.lang.Exception - the exception
      • prepareAndValidate

        public javax.ws.rs.core.Response prepareAndValidate(java.lang.String storeId,
                                                            java.lang.String resourceName,
                                                            java.lang.String httpMethod,
                                                            javax.servlet.http.HttpServletRequest request,
                                                            java.lang.String responseFormat)
        This method is reserved to do initialization as needed. If initialization fails, it will generate an error response. Currently it does nothing and always returns null.
        Parameters:
        storeId - the store id
        resourceName - the resource name
        httpMethod - the http method
        request - the request
        responseFormat - the response format shortcut. Response format is used to resolve the media type for the REST response. If response format is not provided, then Accept header is used to resolve the media type for the REST response. Refer to MediaTypeHelper.getResponseMediaType(String, Request) for more details on the response media type resolution.
        Returns:
        Returns null.
      • generateResponseForEntireDataObject

        @Deprecated
        public javax.ws.rs.core.Response generateResponseForEntireDataObject(java.lang.String responseFormat,
                                                                                         commonj.sdo.DataObject dataArea)
        Deprecated. This method shouldn't be used.
        This method provides a convenient way to return the entire DataObject in JSON or XML format. Note that this will return all the data fields in the same structure as specified in DataObject.
        Parameters:
        responseFormat - the response format shortcut.
        dataArea - the data area
        Returns:
        the response
      • createMapForProvider

        @Deprecated
        public java.util.Map<java.lang.String,java.lang.Object> createMapForProvider(commonj.sdo.DataObject dataArea,
                                                                                                 java.lang.String resourceName,
                                                                                                 java.lang.String urlParamGrpName,
                                                                                                 boolean flattenNoun)
        Deprecated. Replaced by the method signature createMapForProvider(DataObject, String, String) which doesn't include the flattenNoun option. The option to flatten the root noun is now stored in the BOD mapping configuration file.
        This method will create a Map for entity providers using a DataObject. Each resource handler should call one of the createMapForProvider methods.
        Parameters:
        dataArea - DataObject returned from OAGIS service
        resourceName - resource name
        urlParamGrpName - URLParmeterGroup name in BOD mapping file
        flattenNoun - True indicates that if there is a list with only one noun then the data in the noun will be put as top-level elements (the list level will be removed). False indicates that a single noun in a list will remain that way. Use false for URIs that are specified with a unique ID.
        Returns:
        A map to be passed to entity providers.
      • createMapForProvider

        public java.util.Map<java.lang.String,java.lang.Object> createMapForProvider(commonj.sdo.DataObject dataArea,
                                                                                     java.lang.String resourceName,
                                                                                     java.lang.String urlParamGrpName)
        This method will create a Map for entity providers using a DataObject. Each resource handler should call one of the createMapForProvider methods.
        Parameters:
        dataArea - DataObject returned from OAGIS service
        resourceName - resource name
        urlParamGrpName - URLParmeterGroup name in BOD mapping file
        Returns:
        A map to be passed to entity providers.
      • mergeMapsForProvider

        public java.util.Map<java.lang.String,java.lang.Object> mergeMapsForProvider(java.util.Map<java.lang.String,java.lang.Object> map1,
                                                                                     java.util.Map<java.lang.String,java.lang.Object> map2)
        Merge map1 and map2 for providers.
        Parameters:
        map1 - first map
        map2 - second map
        Returns:
        merged map of map1 and map2.
      • getUserId

        public java.lang.Long getUserId()
        Get the current request user ID
        Returns:
        the current user ID. Using the generic user ID if no user ID Could be found.
      • getStoreId

        public java.lang.String getStoreId()
        Extract the current store ID from the business context.
        Returns:
        the store ID if one could be found. Store ID zero '0' is returned if no store ID was defined.