private String showCatalog(ModelMap model, HttpServletRequest request, CatalogSort catalogSort) {
    addCategoryToModel(request, model);
    boolean productFound = addProductsToModel(request, model, catalogSort);

    String view = defaultCategoryView;
    if (productFound) {
      // TODO: Nice to have: product logic similar to category below
      view = defaultProductView;
    } else {
      Category currentCategory = (Category) model.get("currentCategory");
      if (currentCategory.getUrl() != null && !"".equals(currentCategory.getUrl())) {
        return "redirect:" + currentCategory.getUrl();
      } else if (currentCategory.getDisplayTemplate() != null
          && !"".equals(currentCategory.getUrl())) {
        view = categoryTemplatePrefix + currentCategory.getDisplayTemplate();
      } else {
        if ("true".equals(request.getParameter("ajax"))) {
          view = "catalog/categoryView/mainContentFragment";
        } else {
          view = defaultCategoryView;
        }
      }
    }

    if (catalogSort == null) {
      model.addAttribute("catalogSort", new CatalogSort());
    }

    List<Order> wishlists =
        cartService.findOrdersForCustomer(customerState.getCustomer(request), OrderStatus.NAMED);
    model.addAttribute("wishlists", wishlists);

    return view;
  }
 public String viewUpdateAccount(HttpServletRequest request, Model model, UpdateAccountForm form) {
   Customer customer = CustomerState.getCustomer();
   form.setEmailAddress(customer.getEmailAddress());
   form.setFirstName(customer.getFirstName());
   form.setLastName(customer.getLastName());
   return getUpdateAccountView();
 }
  protected Order retrieveCartOrder(HttpServletRequest request, ModelMap model) {
    Customer currentCustomer = customerState.getCustomer(request);
    Order currentCartOrder = null;
    if (currentCustomer != null) {
      currentCartOrder = cartService.findCartForCustomer(currentCustomer);
      if (currentCartOrder == null) {
        currentCartOrder = cartService.createNewCartForCustomer(currentCustomer);
      }
    }

    model.addAttribute("currentCartOrder", currentCartOrder);
    return currentCartOrder;
  }
 public String processUpdateAccount(
     HttpServletRequest request,
     Model model,
     UpdateAccountForm form,
     BindingResult result,
     RedirectAttributes redirectAttributes)
     throws ServiceException {
   updateAccountValidator.validate(form, result);
   if (result.hasErrors()) {
     return getUpdateAccountView();
   }
   Customer customer = CustomerState.getCustomer();
   customer.setEmailAddress(form.getEmailAddress());
   customer.setFirstName(form.getFirstName());
   customer.setLastName(form.getLastName());
   customerService.saveCustomer(customer);
   redirectAttributes.addFlashAttribute("successMessage", getAccountUpdatedMessage());
   return getAccountRedirectView();
 }
 public String viewOrderHistory(HttpServletRequest request, Model model) {
   List<Order> orders =
       orderService.findOrdersForCustomer(CustomerState.getCustomer(), OrderStatus.SUBMITTED);
   model.addAttribute("orders", orders);
   return getOrderHistoryView();
 }