@RequestMapping(value = "/add-address", method = RequestMethod.GET) @RequireHardLogIn public String addAddress(final Model model) throws CMSItemNotFoundException { model.addAttribute("countryData", checkoutFacade.getDeliveryCountries()); model.addAttribute("titleData", userFacade.getTitles()); final AddressForm addressForm = getPreparedAddressForm(); model.addAttribute("addressForm", addressForm); model.addAttribute("addressBookEmpty", Boolean.valueOf(userFacade.isAddressBookEmpty())); model.addAttribute("isDefaultAddress", Boolean.FALSE); storeCmsPageInModel(model, getContentPageForLabelOrId(ADD_EDIT_ADDRESS_CMS_PAGE)); setUpMetaDataForContentPage(model, getContentPageForLabelOrId(ADD_EDIT_ADDRESS_CMS_PAGE)); final List<Breadcrumb> breadcrumbs = accountBreadcrumbBuilder.getBreadcrumbs(null); breadcrumbs.add( new Breadcrumb( "/my-account/address-book", getMessageSource() .getMessage("text.account.addressBook", null, getI18nService().getCurrentLocale()), null)); breadcrumbs.add( new Breadcrumb( "#", getMessageSource() .getMessage( "text.account.addressBook.addEditAddress", null, getI18nService().getCurrentLocale()), null)); model.addAttribute("breadcrumbs", breadcrumbs); model.addAttribute("metaRobots", "no-index,no-follow"); return ControllerConstants.Views.Pages.Account.AccountEditAddressPage; }
@RequestMapping(method = RequestMethod.GET) @RequireHardLogIn public String account(final Model model) throws CMSItemNotFoundException { storeCmsPageInModel(model, getContentPageForLabelOrId(ACCOUNT_CMS_PAGE)); setUpMetaDataForContentPage(model, getContentPageForLabelOrId(ACCOUNT_CMS_PAGE)); model.addAttribute("breadcrumbs", accountBreadcrumbBuilder.getBreadcrumbs(null)); model.addAttribute("metaRobots", "no-index,no-follow"); return ControllerConstants.Views.Pages.Account.AccountHomePage; }
protected String errorUpdatingEmail(final Model model) throws CMSItemNotFoundException { final String returnAction; GlobalMessages.addErrorMessage(model, "form.global.error"); storeCmsPageInModel(model, getContentPageForLabelOrId(PROFILE_CMS_PAGE)); setUpMetaDataForContentPage(model, getContentPageForLabelOrId(PROFILE_CMS_PAGE)); model.addAttribute( "breadcrumbs", accountBreadcrumbBuilder.getBreadcrumbs("text.account.profile")); returnAction = ControllerConstants.Views.Pages.Account.AccountProfileEmailEditPage; return returnAction; }
@RequestMapping(value = "/payment-details", method = RequestMethod.GET) @RequireHardLogIn public String paymentDetails(final Model model) throws CMSItemNotFoundException { model.addAttribute("customerData", customerFacade.getCurrentCustomer()); model.addAttribute("paymentInfoData", userFacade.getCCPaymentInfos(true)); storeCmsPageInModel(model, getContentPageForLabelOrId(PAYMENT_DETAILS_CMS_PAGE)); setUpMetaDataForContentPage(model, getContentPageForLabelOrId(ADD_EDIT_ADDRESS_CMS_PAGE)); model.addAttribute( "breadcrumbs", accountBreadcrumbBuilder.getBreadcrumbs("text.account.paymentDetails")); model.addAttribute("metaRobots", "no-index,no-follow"); return ControllerConstants.Views.Pages.Account.AccountPaymentInfoPage; }
@RequestMapping(value = "/address-book", method = RequestMethod.GET) @RequireHardLogIn public String getAddressBook(final Model model) throws CMSItemNotFoundException { model.addAttribute("addressData", userFacade.getAddressBook()); storeCmsPageInModel(model, getContentPageForLabelOrId(ADDRESS_BOOK_CMS_PAGE)); setUpMetaDataForContentPage(model, getContentPageForLabelOrId(ADDRESS_BOOK_CMS_PAGE)); model.addAttribute( "breadcrumbs", accountBreadcrumbBuilder.getBreadcrumbs("text.account.addressBook")); model.addAttribute("metaRobots", "no-index,no-follow"); return ControllerConstants.Views.Pages.Account.AccountAddressBookPage; }
@RequestMapping(value = "/update-password", method = RequestMethod.POST) @RequireHardLogIn public String updatePassword( final UpdatePasswordForm updatePasswordForm, final BindingResult bindingResult, final Model model, final RedirectAttributes redirectAttributes) throws CMSItemNotFoundException { getPasswordValidator().validate(updatePasswordForm, bindingResult); if (!bindingResult.hasErrors()) { if (updatePasswordForm.getNewPassword().equals(updatePasswordForm.getCheckNewPassword())) { try { customerFacade.changePassword( updatePasswordForm.getCurrentPassword(), updatePasswordForm.getNewPassword()); } catch (final PasswordMismatchException localException) { bindingResult.rejectValue( "currentPassword", "profile.currentPassword.invalid", new Object[] {}, "profile.currentPassword.invalid"); } } else { bindingResult.rejectValue( "checkNewPassword", "validation.checkPwd.equals", new Object[] {}, "validation.checkPwd.equals"); } } if (bindingResult.hasErrors()) { GlobalMessages.addErrorMessage(model, "form.global.error"); storeCmsPageInModel(model, getContentPageForLabelOrId(PROFILE_CMS_PAGE)); setUpMetaDataForContentPage(model, getContentPageForLabelOrId(PROFILE_CMS_PAGE)); model.addAttribute( "breadcrumbs", accountBreadcrumbBuilder.getBreadcrumbs("text.account.profile.updatePasswordForm")); return ControllerConstants.Views.Pages.Account.AccountChangePasswordPage; } else { GlobalMessages.addFlashMessage( redirectAttributes, GlobalMessages.CONF_MESSAGES_HOLDER, "text.account.confirmation.password.updated", null); return REDIRECT_TO_PROFILE_PAGE; } }
@RequestMapping(value = "/update-password", method = RequestMethod.GET) @RequireHardLogIn public String updatePassword(final Model model) throws CMSItemNotFoundException { final UpdatePasswordForm updatePasswordForm = new UpdatePasswordForm(); model.addAttribute("updatePasswordForm", updatePasswordForm); storeCmsPageInModel(model, getContentPageForLabelOrId(PROFILE_CMS_PAGE)); setUpMetaDataForContentPage(model, getContentPageForLabelOrId(PROFILE_CMS_PAGE)); model.addAttribute( "breadcrumbs", accountBreadcrumbBuilder.getBreadcrumbs("text.account.profile.updatePasswordForm")); model.addAttribute("metaRobots", "no-index,no-follow"); return ControllerConstants.Views.Pages.Account.AccountChangePasswordPage; }
@RequestMapping(value = "/update-email", method = RequestMethod.GET) @RequireHardLogIn public String editEmail(final Model model) throws CMSItemNotFoundException { final CustomerData customerData = customerFacade.getCurrentCustomer(); final UpdateEmailForm updateEmailForm = new UpdateEmailForm(); updateEmailForm.setEmail(customerData.getDisplayUid()); model.addAttribute("updateEmailForm", updateEmailForm); storeCmsPageInModel(model, getContentPageForLabelOrId(PROFILE_CMS_PAGE)); setUpMetaDataForContentPage(model, getContentPageForLabelOrId(PROFILE_CMS_PAGE)); model.addAttribute( "breadcrumbs", accountBreadcrumbBuilder.getBreadcrumbs("text.account.profile")); model.addAttribute("metaRobots", "no-index,no-follow"); return ControllerConstants.Views.Pages.Account.AccountProfileEmailEditPage; }
@RequestMapping(value = "/update-profile", method = RequestMethod.POST) @RequireHardLogIn public String updateProfile( final UpdateProfileForm updateProfileForm, final BindingResult bindingResult, final Model model, final RedirectAttributes redirectAttributes) throws CMSItemNotFoundException { getProfileValidator().validate(updateProfileForm, bindingResult); String returnAction = ControllerConstants.Views.Pages.Account.AccountProfileEditPage; final CustomerData currentCustomerData = customerFacade.getCurrentCustomer(); final CustomerData customerData = new CustomerData(); customerData.setTitleCode(updateProfileForm.getTitleCode()); customerData.setFirstName(updateProfileForm.getFirstName()); customerData.setLastName(updateProfileForm.getLastName()); customerData.setUid(currentCustomerData.getUid()); customerData.setDisplayUid(currentCustomerData.getDisplayUid()); model.addAttribute("titleData", userFacade.getTitles()); if (bindingResult.hasErrors()) { GlobalMessages.addErrorMessage(model, "form.global.error"); } else { try { customerFacade.updateProfile(customerData); GlobalMessages.addFlashMessage( redirectAttributes, GlobalMessages.CONF_MESSAGES_HOLDER, "text.account.profile.confirmationUpdated", null); returnAction = REDIRECT_TO_PROFILE_PAGE; } catch (final DuplicateUidException e) { bindingResult.rejectValue("email", "registration.error.account.exists.title"); GlobalMessages.addErrorMessage(model, "form.global.error"); } } storeCmsPageInModel(model, getContentPageForLabelOrId(PROFILE_CMS_PAGE)); setUpMetaDataForContentPage(model, getContentPageForLabelOrId(PROFILE_CMS_PAGE)); model.addAttribute( "breadcrumbs", accountBreadcrumbBuilder.getBreadcrumbs("text.account.profile")); return returnAction; }
@RequestMapping(value = "/profile", method = RequestMethod.GET) @RequireHardLogIn public String profile(final Model model) throws CMSItemNotFoundException { final List<TitleData> titles = userFacade.getTitles(); final CustomerData customerData = customerFacade.getCurrentCustomer(); if (customerData.getTitleCode() != null) { model.addAttribute("title", findTitleForCode(titles, customerData.getTitleCode())); } model.addAttribute("customerData", customerData); storeCmsPageInModel(model, getContentPageForLabelOrId(PROFILE_CMS_PAGE)); setUpMetaDataForContentPage(model, getContentPageForLabelOrId(PROFILE_CMS_PAGE)); model.addAttribute( "breadcrumbs", accountBreadcrumbBuilder.getBreadcrumbs("text.account.profile")); model.addAttribute("metaRobots", "no-index,no-follow"); return ControllerConstants.Views.Pages.Account.AccountProfilePage; }
@RequestMapping(value = "/orders", method = RequestMethod.GET) @RequireHardLogIn public String orders( @RequestParam(value = "page", defaultValue = "0") final int page, @RequestParam(value = "show", defaultValue = "Page") final ShowMode showMode, @RequestParam(value = "sort", required = false) final String sortCode, final Model model) throws CMSItemNotFoundException { // Handle paged search results final PageableData pageableData = createPageableData(page, 5, sortCode, showMode); final SearchPageData<OrderHistoryData> searchPageData = orderFacade.getPagedOrderHistoryForStatuses(pageableData); populateModel(model, searchPageData, showMode); storeCmsPageInModel(model, getContentPageForLabelOrId(ORDER_HISTORY_CMS_PAGE)); setUpMetaDataForContentPage(model, getContentPageForLabelOrId(ORDER_HISTORY_CMS_PAGE)); model.addAttribute( "breadcrumbs", accountBreadcrumbBuilder.getBreadcrumbs("text.account.orderHistory")); model.addAttribute("metaRobots", "no-index,no-follow"); return ControllerConstants.Views.Pages.Account.AccountOrderHistoryPage; }
@RequestMapping(value = "/order/" + ORDER_CODE_PATH_VARIABLE_PATTERN, method = RequestMethod.GET) @RequireHardLogIn public String order(@PathVariable("orderCode") final String orderCode, final Model model) throws CMSItemNotFoundException { try { final OrderData orderDetails = orderFacade.getOrderDetailsForCode(orderCode); model.addAttribute("orderData", orderDetails); final List<Breadcrumb> breadcrumbs = accountBreadcrumbBuilder.getBreadcrumbs(null); breadcrumbs.add( new Breadcrumb( "/my-account/orders", getMessageSource() .getMessage( "text.account.orderHistory", null, getI18nService().getCurrentLocale()), null)); breadcrumbs.add( new Breadcrumb( "#", getMessageSource() .getMessage( "text.account.order.orderBreadcrumb", new Object[] {orderDetails.getCode()}, "Order {0}", getI18nService().getCurrentLocale()), null)); model.addAttribute("breadcrumbs", breadcrumbs); } catch (final UnknownIdentifierException e) { LOG.warn("Attempted to load a order that does not exist or is not visible", e); return REDIRECT_MY_ACCOUNT; } storeCmsPageInModel(model, getContentPageForLabelOrId(ORDER_DETAIL_CMS_PAGE)); model.addAttribute("metaRobots", "no-index,no-follow"); setUpMetaDataForContentPage(model, getContentPageForLabelOrId(ORDER_DETAIL_CMS_PAGE)); return ControllerConstants.Views.Pages.Account.AccountOrderPage; }
@RequestMapping( value = "/edit-address/" + ADDRESS_CODE_PATH_VARIABLE_PATTERN, method = RequestMethod.GET) @RequireHardLogIn public String editAddress( @PathVariable("addressCode") final String addressCode, final Model model) throws CMSItemNotFoundException { final AddressForm addressForm = new AddressForm(); model.addAttribute("countryData", checkoutFacade.getDeliveryCountries()); model.addAttribute("titleData", userFacade.getTitles()); model.addAttribute("addressForm", addressForm); model.addAttribute("addressBookEmpty", Boolean.valueOf(userFacade.isAddressBookEmpty())); for (final AddressData addressData : userFacade.getAddressBook()) { if (addressData.getId() != null && addressData.getId().equals(addressCode)) { model.addAttribute( "regions", getI18NFacade().getRegionsForCountryIso(addressData.getCountry().getIsocode())); model.addAttribute("country", addressData.getCountry().getIsocode()); model.addAttribute("addressData", addressData); addressForm.setAddressId(addressData.getId()); addressForm.setTitleCode(addressData.getTitleCode()); addressForm.setFirstName(addressData.getFirstName()); addressForm.setLastName(addressData.getLastName()); addressForm.setLine1(addressData.getLine1()); addressForm.setLine2(addressData.getLine2()); addressForm.setTownCity(addressData.getTown()); addressForm.setPostcode(addressData.getPostalCode()); addressForm.setCountryIso(addressData.getCountry().getIsocode()); if (addressData.getRegion() != null && !StringUtils.isEmpty(addressData.getRegion().getIsocode())) { addressForm.setRegionIso(addressData.getRegion().getIsocode()); } if (isDefaultAddress(addressData.getId())) { addressForm.setDefaultAddress(Boolean.TRUE); model.addAttribute("isDefaultAddress", Boolean.TRUE); } else { addressForm.setDefaultAddress(Boolean.FALSE); model.addAttribute("isDefaultAddress", Boolean.FALSE); } break; } } storeCmsPageInModel(model, getContentPageForLabelOrId(ADD_EDIT_ADDRESS_CMS_PAGE)); setUpMetaDataForContentPage(model, getContentPageForLabelOrId(ADD_EDIT_ADDRESS_CMS_PAGE)); final List<Breadcrumb> breadcrumbs = accountBreadcrumbBuilder.getBreadcrumbs(null); breadcrumbs.add( new Breadcrumb( "/my-account/address-book", getMessageSource() .getMessage("text.account.addressBook", null, getI18nService().getCurrentLocale()), null)); breadcrumbs.add( new Breadcrumb( "#", getMessageSource() .getMessage( "text.account.addressBook.addEditAddress", null, getI18nService().getCurrentLocale()), null)); model.addAttribute("breadcrumbs", breadcrumbs); model.addAttribute("metaRobots", "no-index,no-follow"); model.addAttribute("edit", Boolean.TRUE); return ControllerConstants.Views.Pages.Account.AccountEditAddressPage; }