com.ibm.commerce.context.audit

Class AuditContextUtility

  • java.lang.Object
    • com.ibm.commerce.context.audit.AuditContextUtility


  • public class AuditContextUtility
    extends java.lang.Object
    This class contains utility methods that can be used by components that interact with the audit context or need to setup some data based on the audit context.
    • Field Detail

      • TRANSPORT_IDENTIFIER_WEB

        public static final java.lang.String TRANSPORT_IDENTIFIER_WEB
        This is the constant identifier that will represent the web transport. The identifier is the class name (including the package) of the ServletRequest object.
      • TRANSPORT_IDENTIFIER_SALES_CENTER

        public static final java.lang.String TRANSPORT_IDENTIFIER_SALES_CENTER
        This is the constant identifier that will represent any request that is from the sales center. The constant is com.ibm.commerce.SalesCenterRequest.
        See Also:
        Constant Field Values
      • TRANSPORT_REMOTE_AGENT_SALES_CENTER

        public static final java.lang.String TRANSPORT_REMOTE_AGENT_SALES_CENTER
        This is the remote agent that will be associated with sales center requests. The remote agent will always be com.ibm.commerce.SalesCenterClient.
        See Also:
        Constant Field Values
      • TRANSPORT_IDENTIFIER_WEBSERVICES

        public static final java.lang.String TRANSPORT_IDENTIFIER_WEBSERVICES
        This is the constant identifier that will represent any request that is from web services. The constant is com.ibm.commerce.WebServiceRequest.
        See Also:
        Constant Field Values
      • TRANSPORT_REMOTE_AGENT_WEBSERVICES

        public static final java.lang.String TRANSPORT_REMOTE_AGENT_WEBSERVICES
        This is the remote agent that will be associated with web service requests. The remote agent will always be com.ibm.commerce.WebServiceClient.
        See Also:
        Constant Field Values
      • TRANSPORT_IDENTIFIER_SCHEDULER

        public static final java.lang.String TRANSPORT_IDENTIFIER_SCHEDULER
        This is the constant identifier that will represent any request that is from the scheduler. The constant is com.ibm.commerce.SchedulerRequest.
        See Also:
        Constant Field Values
      • TRANSPORT_REMOTE_AGENT_SCHEDULER

        public static final java.lang.String TRANSPORT_REMOTE_AGENT_SCHEDULER
        This is the remote agent that will be associated with scheduled jobs. The remote agent will always be com.ibm.commerce.ScheduledProcess.
        See Also:
        Constant Field Values
    • Method Detail

      • addTransportDataToActivityForWeb

        public static void addTransportDataToActivityForWeb(ActivityToken activityToken,
                                                            javax.servlet.http.HttpServletRequest request)
        This method adds the transport information from the HTTP request to the session data.
        Parameters:
        activityToken - This is the activity token used to start the business request.
        request - This is the HTTP request used to extract the transport information.
      • addTransportDataToActivityTokenForSalesCenter

        public static void addTransportDataToActivityTokenForSalesCenter(ActivityToken activityToken)
        This method sets the transport data that will be associated with a sales center request. This implementation sets the transport identifier and the remote agent of the request.
        Parameters:
        activityToken - This is the activity token used to start the business request.
      • addTransportDataToActivityTokenForWebServices

        public static void addTransportDataToActivityTokenForWebServices(ActivityToken activityToken)
        This method sets the transport data that will be associated with a web service request. This implementation sets the transport identifier and the remote agent of the request.
        Parameters:
        activityToken - This is the activity token used to start the business request.
      • addTransportDataToActivityTokenForForScheduler

        public static void addTransportDataToActivityTokenForForScheduler(ActivityToken activityToken)
        This method sets the transport data that will be associated with a scheduled process. This implementation sets the transport identifier and the remote agent of the request.
        Parameters:
        activityToken - This is the activity token used to start the business request.
      • getUserIds

        public static java.util.ArrayList getUserIds(java.lang.String personalizationId)
                                              throws BusinessContextException
        Get the list of user IDs associated with a specific personalization ID.
        Parameters:
        personalizationId - the personalization id for the search
        Returns:
        the ArrayList of String user IDs
        Throws:
        BusinessContextException - on any error encountered
      • getRegisteredUserId

        public static java.lang.Long getRegisteredUserId(java.lang.String personalizationId)
                                                  throws BusinessContextException
        Get the register user ID associated with a specific personalization ID. Returns null if no register user ID has been associated with this personalization ID.
        Parameters:
        personalizationId - the personalization id for the search
        Returns:
        the register user ID. Null if no register user ID associated with this personalization ID.
        Throws:
        BusinessContextException - on any error encountered
      • getPersonalizationId

        public static java.lang.String getPersonalizationId(java.lang.Long userId)
                                                     throws BusinessContextException
        Get the personalization ID for a specific guest or register user. If the user is a generic user, it will return null. If no personalization ID has been assigned to the guest or register user, it will generate a new one for the user.
        Parameters:
        userId - the user id for the search
        Returns:
        the personalization id for this user
        Throws:
        BusinessContextException - on any other error encountered
      • getPersonalizationId

        public static java.lang.String getPersonalizationId(java.lang.Long userId,
                                                            java.lang.String personalizationId)
                                                     throws BusinessContextException
        Get the personalization ID for a specific guest or register user. If the user is a generic user, it will return null. If no personalization ID has been assigned to the guest or register user, it will assign with the input personalization ID for the user if the input personalization ID is not null, or will generate a new personalization ID otherwise.
        Parameters:
        userId - the user id for the search
        personalizationId - the new personalization id assigned
        Returns:
        the personalization id for this user
        Throws:
        BusinessContextException - on any other error encountered
      • generatePersonalizationId

        public static java.lang.String generatePersonalizationId()
        Reserved for IBM internal use.

        Method to genetare UUID for personalization id purpose.

        Returns:
        the personalization id for this user
      • adjustPersonalizationIdForRegisterUser

        public static void adjustPersonalizationIdForRegisterUser(java.lang.Long userId)
                                                           throws BusinessContextException
        Reserved for IBM internal use.

        Adjust the personalization ID for a specific register user. This method will check to see if the input register user personalization ID has been used by another register user. If yes, then it will reassign (regenerate and store in DB) a new personalization ID for the input register user. This is necessary in the scenario that when a guest user did not register and was using another register user personalization ID to add something to shopping cart. The guest user is allowed to use the same personalization ID as the other register user. However, when the user register to be a new user, since the user will still use the guest user ID, but the type of the user is now register, he should not use the same personalization ID and should be assign a new one. If the input register user personalization ID is not used by any other register user, the method will just do nothing. If the input user ID is not a register user, the method will just do nothing. It is the responsibility of the caller to adjust the audit context personalization ID if the input user is the current run-as user.

        Parameters:
        userId - user ID for personalization ID adjustment
        Throws:
        BusinessContextException - on any other error encountered
      • adjustPersonalizationIdForRegisterUser

        public static void adjustPersonalizationIdForRegisterUser(java.lang.Integer storeId,
                                                                  java.lang.Long userId)
                                                           throws BusinessContextException
        Reserved for IBM internal use.

        Adjust the personalization ID for a specific register user. This method will check to see if the input register user personalization ID has been used by another register user. If yes, then it will reassign (regenerate and store in DB) a new personalization ID for the input register user. This is necessary in the scenario that when a guest user did not register and was using another register user personalization ID to add something to shopping cart. The guest user is allowed to use the same personalization ID as the other register user. However, when the user register to be a new user, since the user will still use the guest user ID, but the type of the user is now register, he should not use the same personalization ID and should be assign a new one. If the input register user personalization ID is not used by any other register user, the method will just do nothing. If the input user ID is not a register user, the method will just do nothing. It is the responsibility of the caller to adjust the audit context personalization ID if the input user is the current run-as user.

        Parameters:
        storeId - store ID for personalization ID adjustment
        userId - user ID for personalization ID adjustment
        Throws:
        BusinessContextException - on any other error encountered