Package org.hoteia.qalingo.core.domain

Examples of org.hoteia.qalingo.core.domain.Customer


 
  @RequestMapping(value = FoUrls.PERSONAL_EDIT_ADDRESS_URL, method = RequestMethod.GET)
  public ModelAndView displayCustomerEditAddress(final HttpServletRequest request, final Model model, @ModelAttribute("customerAddressForm") CustomerAddressForm customerAddressForm) throws Exception {
    ModelAndViewThemeDevice modelAndView = new ModelAndViewThemeDevice(getCurrentVelocityPath(request), FoUrls.PERSONAL_EDIT_ADDRESS.getVelocityPage());
    final RequestData requestData = requestUtil.getRequestData(request);
        final Customer currentCustomer = requestData.getCustomer();
   
    // WE RELOAD THE CUSTOMER FOR THE PERSISTANCE PROXY FILTER
    // IT AVOIDS LazyInitializationException: could not initialize proxy - no Session
    final Customer reloadedCustomer = customerService.getCustomerByLoginOrEmail(currentCustomer.getLogin());

    final CustomerAddressListViewBean customerAdressesViewBean = frontofficeViewBeanFactory.buildViewBeanCustomerAddressList(requestUtil.getRequestData(request), reloadedCustomer);
    model.addAttribute(ModelConstants.CUSTOMER_ADDRESSES_VIEW_BEAN, customerAdressesViewBean);
   
    String customerAddressId = request.getParameter(RequestConstants.REQUEST_PARAMETER_CUSTOMER_ADDRESS_GUID);
    if(StringUtils.isEmpty(customerAddressId)){
      customerAddressId = customerAddressForm.getIdOrGuid();
    }
   
    CustomerAddress customerAddress = null;
    try {
      customerAddress = reloadedCustomer.getAddress(new Long(customerAddressId));
     
    } catch (Exception e) {
      logger.error("Error with the address to edit, customerAddressId:" + customerAddressId, e);
      final String urlRedirect = urlService.generateUrl(FoUrls.PERSONAL_ADDRESS_LIST, requestUtil.getRequestData(request));
          return new ModelAndView(new RedirectView(urlRedirect));
View Full Code Here


 
  @RequestMapping(FoUrls.PERSONAL_ORDER_LIST_URL)
  public ModelAndView customerWishList(final HttpServletRequest request, final Model model) throws Exception {
    ModelAndViewThemeDevice modelAndView = new ModelAndViewThemeDevice(getCurrentVelocityPath(request), FoUrls.PERSONAL_ORDER_LIST.getVelocityPage());
    final RequestData requestData = requestUtil.getRequestData(request);
        final Customer currentCustomer = requestData.getCustomer();
   
    // WE RELOAD THE CUSTOMER FOR THE PERSISTANCE PROXY FILTER
    // IT AVOIDS LazyInitializationException: could not initialize proxy - no Session
    final Customer reloadedCustomer = customerService.getCustomerByLoginOrEmail(currentCustomer.getLogin());
   
    List<OrderCustomer> orderCustomers = orderCustomerService.findOrdersByCustomerId(reloadedCustomer.getId().toString());
    if(orderCustomers != null
        && orderCustomers.size() > 0){
      String url = requestUtil.getCurrentRequestUrl(request);
     
      String sessionKey = "PagedListHolder_Search_List_Product_" + request.getSession().getId();
View Full Code Here

    if(StringUtils.isNotEmpty(orderCustomerId)){
      final OrderCustomer orderCustomer = orderCustomerService.getOrderById(orderCustomerId);
      if(orderCustomer != null){
        // SANITY CHECK

            final Customer currentCustomer = requestData.getCustomer();
       
        // WE RELOAD THE CUSTOMER FOR THE PERSISTANCE PROXY FILTER
        // IT AVOIDS LazyInitializationException: could not initialize proxy - no Session
        final Customer reloadedCustomer = customerService.getCustomerByLoginOrEmail(currentCustomer.getLogin());
       
        List<OrderCustomer> orderCustomers = orderCustomerService.findOrdersByCustomerId(reloadedCustomer.getId().toString());
        if(orderCustomers.contains(orderCustomer)){
              return modelAndView;
        } else {
          logger.warn("Customer, " + reloadedCustomer.getId() + "/" + reloadedCustomer.getEmail() + ", try to acces to a customer order, " + orderCustomerId + ", which does not belong");
        }
      }
    }
    final String url = requestUtil.getLastRequestUrl(request);
    return new ModelAndView(new RedirectView(url));
View Full Code Here

    ModelAndViewThemeDevice modelAndView = new ModelAndViewThemeDevice(getCurrentVelocityPath(request), FoUrls.CUSTOMER_CREATE_ACCOUNT.getVelocityPage());
    final RequestData requestData = requestUtil.getRequestData(request);
        final Locale locale = requestData.getLocale();
       
    // SANITY CHECK: Customer logged
        final Customer currentCustomer = requestData.getCustomer();
    if(currentCustomer != null){
      final String url = urlService.generateUrl(FoUrls.PERSONAL_DETAILS, requestUtil.getRequestData(request));
      return new ModelAndView(new RedirectView(url));
    }
   
View Full Code Here

        final RequestData requestData = requestUtil.getRequestData(request);
        final Market currentMarket = requestData.getMarket();
        final MarketArea currentMarketArea = requestData.getMarketArea();

    // SANITY CHECK: Customer logged
        final Customer currentCustomer = requestData.getCustomer();
    if(currentCustomer != null){
      final String url = urlService.generateUrl(FoUrls.PERSONAL_DETAILS,requestUtil.getRequestData(request));
      return new ModelAndView(new RedirectView(url));
    }
   
    // "customer.create.account";
   
    if (result.hasErrors()) {
      return displayCustomerCreateAccount(request, model, createAccountForm);
    }
   
    final String email = createAccountForm.getEmail();
    final Customer customer = customerService.getCustomerByLoginOrEmail(email);
    if(customer != null){
      final String forgottenPasswordUrl = urlService.generateUrl(FoUrls.FORGOTTEN_PASSWORD, requestUtil.getRequestData(request));
      final Object[] objects = {forgottenPasswordUrl};
      result.rejectValue("email", "fo.customer.error_form_create_account_account_already_exist", objects,"This email customer account already exist! Go on this <a href=\"forgotten-password.html\" alt=\"\">page</a> to get a new password.");
      return displayCustomerCreateAccount(request, model, createAccountForm);
    }

    // Save the new customer
    final Customer newCustomer = webManagementService.buildAndSaveNewCustomer(requestData, currentMarket, currentMarketArea, createAccountForm);

    // Save the email confirmation
    webManagementService.buildAndSaveCustomerNewAccountMail(requestData, createAccountForm);

    // Login the new customer
View Full Code Here

    @RequestMapping(value = FoUrls.CART_CREATE_ACCOUNT_URL, method = RequestMethod.GET)
    public ModelAndView displayCheckoutCreateAccount(final HttpServletRequest request, final Model model, @ModelAttribute(ModelConstants.FRONTOFFICE_CREATE_ACCOUNT_FORM) CreateAccountForm createAccountForm) throws Exception {
        ModelAndViewThemeDevice modelAndView = new ModelAndViewThemeDevice(getCurrentVelocityPath(request), FoUrls.CUSTOMER_CREATE_ACCOUNT.getVelocityPage());
        final RequestData requestData = requestUtil.getRequestData(request);
        // SANITY CHECK: Customer logged
        final Customer currentCustomer = requestData.getCustomer();
        if(currentCustomer != null){
            final String url = urlService.generateUrl(FoUrls.CART_DELIVERY, requestUtil.getRequestData(request));
            return new ModelAndView(new RedirectView(url));
        }
       
View Full Code Here

        final RequestData requestData = requestUtil.getRequestData(request);
        final Market currentMarket = requestData.getMarket();
        final MarketArea currentMarketArea = requestData.getMarketArea();

        // SANITY CHECK: Customer logged
        final Customer currentCustomer = requestData.getCustomer();
        if(currentCustomer != null){
            final String url = urlService.generateUrl(FoUrls.CART_DELIVERY,requestUtil.getRequestData(request));
            return new ModelAndView(new RedirectView(url));
        }
       
        // "customer.create.account";
       
        if (result.hasErrors()) {
            return displayCustomerCreateAccount(request, model, createAccountForm);
        }
       
        final String email = createAccountForm.getEmail();
        final Customer customer = customerService.getCustomerByLoginOrEmail(email);
        if(customer != null){
            final String forgottenPasswordUrl = urlService.generateUrl(FoUrls.FORGOTTEN_PASSWORD, requestData);
            final Object[] objects = {forgottenPasswordUrl};
            result.rejectValue("email", "error.form.create.account.account.already.exist", objects,"This email customer account already exist! Go on this <a href=\"${0}\" alt=\"\">page</a> to get a new password.");
        }

        // Save the new customer
        final Customer newCustomer = webManagementService.buildAndSaveNewCustomer(requestData, currentMarket, currentMarketArea, createAccountForm);

        // Save the email confirmation
        webManagementService.buildAndSaveCustomerNewAccountMail(requestData, createAccountForm);

        // Login the new customer
View Full Code Here

      String errorMessage = getSpecificMessage(ScopeWebMessage.CUSTOMER, "error_form_new_account_validation_token_is_wrong", locale);
      addErrorMessage(request, errorMessage);
    }
   
    String email = request.getParameter(RequestConstants.REQUEST_PARAMETER_NEW_CUSTOMER_VALIDATION_EMAIL);
    final Customer customer = customerService.getCustomerByLoginOrEmail(email);
    if (customer == null) {
      // ADD ERROR MESSAGE
      String errorMessage = getSpecificMessage(ScopeWebMessage.CUSTOMER, "error_form_new_account_validation_email_or_login_are_wrong", locale);
      addErrorMessage(request, errorMessage);
    }
View Full Code Here

       
    if (result.hasErrors()) {
      return displayForgottenPassword(request, modelMap);
    }
   
    final Customer customer = customerService.getCustomerByLoginOrEmail(forgottenPasswordForm.getEmailOrLogin());
    if (customer == null) {
      addMessageError(result, null, "forgottenPasswordForm", "emailOrLogin", getSpecificMessage(ScopeWebMessage.AUTH, "error_form_reset_password_email_doesnt_exist", locale));
      return displayForgottenPassword(request, modelMap);
    }
   
    if (customer != null
        && customer.isAnonymous()) {
        addMessageError(result, null, "forgottenPasswordForm", "emailOrLogin",  getSpecificMessage(ScopeWebMessage.AUTH, "error_form_reset_password_customer_is_not_active", locale));
      return displayForgottenPassword(request, modelMap);
    }
   
    // FLAG THE CREDENTIAL WITH A TOKEN
View Full Code Here

      String errorMessage = getSpecificMessage(ScopeWebMessage.AUTH, "error_form_reset_password_token_is_wrong", locale);
      addErrorMessage(request, errorMessage);
    }
   
    String email = request.getParameter(RequestConstants.REQUEST_PARAMETER_PASSWORD_RESET_EMAIL);
    final Customer customer = customerService.getCustomerByLoginOrEmail(email);
    if (customer == null) {
      // ADD ERROR MESSAGE
      String errorMessage = getSpecificMessage(ScopeWebMessage.AUTH, "error_form_reset_password_email_or_login_are_wrong", locale);
      addErrorMessage(request, errorMessage);
    }
   
    if (!customer.getCurrentCredential().getResetToken().equals(token)) {
      // ADD ERROR MESSAGE
      String errorMessage = getSpecificMessage(ScopeWebMessage.AUTH, "error_form_reset_password_token_is_wrong", locale);
      addErrorMessage(request, errorMessage);
    }
   
View Full Code Here

TOP

Related Classes of org.hoteia.qalingo.core.domain.Customer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.