Class Utils

java.lang.Object
com.hybris.yprofile.common.Utils

public final class Utils extends Object
  • Method Details

    • formatDouble

      public static String formatDouble(Double d)
    • formatDate

      public static String formatDate(Date d)
    • remapSiteId

      public static String remapSiteId(String siteId)
    • getHeader

      public static Optional<String> getHeader(javax.servlet.http.HttpServletRequest request, String headerName)
    • getCookie

      public static Optional<javax.servlet.http.Cookie> getCookie(javax.servlet.http.HttpServletRequest request, String cookieName)
    • setCookie

      public static void setCookie(EnhancedCookieGenerator enhancedCookieGenerator, javax.servlet.http.HttpServletResponse response, String cookieName, String cookieValue, boolean isSessionCookie)
    • removeCookie

      public static void removeCookie(EnhancedCookieGenerator enhancedCookieGenerator, javax.servlet.http.HttpServletResponse response, String cookieName)
    • parseObjectToJson

      public static String parseObjectToJson(Object obj)
    • getActiveConsentModelFromEvent

      public static Optional<ConsentModel> getActiveConsentModelFromEvent(AbstractCommerceUserEvent event, CommerceConsentService commerceConsentService)
      Gets the active consent model for the base-site and customer pertaining to the event from the CommerceConsentService.
      Parameters:
      event - the event containing the user/customer model and the base site
      commerceConsentService - the service used to obtain the active consentModel
      Returns:
      an optional of the active consent model for this user and base site if present
    • getActiveConsentReferenceFromEvent

      public static String getActiveConsentReferenceFromEvent(AbstractCommerceUserEvent event, CommerceConsentService commerceConsentService)
      Gets the ConsentReference from the consent model for the base-site and customer of the event from CommerceConsentService.
      Parameters:
      event - the event containing the user/customer model and the base site
      commerceConsentService - the service used to obtain the active consentModel
      Returns:
      consent-reference as string if present, null otherwise
    • getActiveConsentReferenceForCustomerAndBaseSite

      public static String getActiveConsentReferenceForCustomerAndBaseSite(BaseSiteModel baseSiteModel, CustomerModel customerModel, CommerceConsentService commerceConsentService)
      Gets the ConsentReference from the consent model for the base-site and customer from CommerceConsentService.
      Parameters:
      baseSiteModel - the model containing the current baseSite
      customerModel - the model containing user info
      commerceConsentService - the service used to obtain the active consentModel
      Returns:
      consent-reference as string if present, null otherwise
    • getActiveConsentModelForCustomerAndBaseSite

      public static Optional<ConsentModel> getActiveConsentModelForCustomerAndBaseSite(BaseSiteModel baseSiteModel, CustomerModel customerModel, CommerceConsentService commerceConsentService)
      Gets the active consent model for the given baseSite and user from the CommerceConsentService.
      Parameters:
      baseSiteModel - the model containing the current baseSite
      customerModel - the model containing user info
      commerceConsentService - the service used to obtain the active consentModel
      Returns:
      an optional of the active consent model for this user and base site