/**
  * Using a language String finds the afferent locale.
  *
  * @param localeString
  * @return
  */
 private Locale getLocaleByLanguageStr(final String localeString) {
   Store store = requestHelper.getStoreConfig().getStore();
   for (Locale locale : store.getSupportedLocales()) {
     if (locale.toString().equals(localeString)) {
       return locale;
     }
   }
   return store.getDefaultLocale();
 }
 /**
  * Apply a merged cart page redirection URL.
  *
  * @param request the request
  * @return the merged cart landing page for a merged cart scenario, otherwise the original
  *     targetUrl is returned
  */
 protected boolean mergedCartRedirect(final HttpServletRequest request) {
   final CustomerSession customerSession = requestHelper.getCustomerSession(request);
   if (customerSession != null) {
     final ShoppingCart shoppingCart = customerSession.getShoppingCart();
     if (shoppingCart.isMergedNotification()) {
       return true;
     }
   }
   return false;
 }
 /**
  * Perform a check to see if the language should be changed.
  *
  * @param aRequest - request
  * @param aResponse - response
  */
 protected void processPossibleLocaleChange(
     final HttpServletRequest aRequest, final HttpServletResponse aResponse) {
   String localeFromRequest = (String) aRequest.getAttribute(WebConstants.URL_REQUEST_LOCALE);
   if (localeFromRequest != null && localeFromRequest.length() > 0) {
     CustomerSession customerSession = requestHelper.getCustomerSession(aRequest);
     Locale newLocale = getLocaleByLanguageStr(localeFromRequest);
     if (!newLocale.equals(customerSession.getLocale())) {
       customerSession.setLocale(newLocale);
       customerSessionService.update(customerSession);
       aRequest.setAttribute(WebConstants.LOCALE_PARAMETER_NAME, newLocale);
     }
   }
 }