@RequestMapping(value = "/select-suggested-address", method = RequestMethod.POST)
  public String doSelectSuggestedAddress(
      final AddressForm addressForm, final RedirectAttributes redirectModel) {
    final Set<String> resolveCountryRegions =
        org.springframework.util.StringUtils.commaDelimitedListToSet(
            Config.getParameter("resolve.country.regions"));

    final AddressData selectedAddress = new AddressData();
    selectedAddress.setId(addressForm.getAddressId());
    selectedAddress.setTitleCode(addressForm.getTitleCode());
    selectedAddress.setFirstName(addressForm.getFirstName());
    selectedAddress.setLastName(addressForm.getLastName());
    selectedAddress.setLine1(addressForm.getLine1());
    selectedAddress.setLine2(addressForm.getLine2());
    selectedAddress.setTown(addressForm.getTownCity());
    selectedAddress.setPostalCode(addressForm.getPostcode());
    selectedAddress.setBillingAddress(false);
    selectedAddress.setShippingAddress(true);
    selectedAddress.setVisibleInAddressBook(true);

    final CountryData countryData = i18NFacade.getCountryForIsocode(addressForm.getCountryIso());
    selectedAddress.setCountry(countryData);

    if (resolveCountryRegions.contains(countryData.getIsocode())) {
      if (addressForm.getRegionIso() != null && !StringUtils.isEmpty(addressForm.getRegionIso())) {
        final RegionData regionData =
            getI18NFacade().getRegion(addressForm.getCountryIso(), addressForm.getRegionIso());
        selectedAddress.setRegion(regionData);
      }
    }

    if (resolveCountryRegions.contains(countryData.getIsocode())) {
      if (addressForm.getRegionIso() != null && !StringUtils.isEmpty(addressForm.getRegionIso())) {
        final RegionData regionData =
            getI18NFacade().getRegion(addressForm.getCountryIso(), addressForm.getRegionIso());
        selectedAddress.setRegion(regionData);
      }
    }

    if (Boolean.TRUE.equals(addressForm.getEditAddress())) {
      selectedAddress.setDefaultAddress(
          Boolean.TRUE.equals(addressForm.getDefaultAddress())
              || userFacade.getAddressBook().size() <= 1);
      userFacade.editAddress(selectedAddress);
    } else {
      selectedAddress.setDefaultAddress(
          Boolean.TRUE.equals(addressForm.getDefaultAddress()) || userFacade.isAddressBookEmpty());
      userFacade.addAddress(selectedAddress);
    }

    GlobalMessages.addFlashMessage(
        redirectModel, GlobalMessages.CONF_MESSAGES_HOLDER, "account.confirmation.address.added");

    return REDIRECT_TO_ADDRESS_BOOK_PAGE;
  }
  @RequestMapping(
      value = "/edit-address/" + ADDRESS_CODE_PATH_VARIABLE_PATTERN,
      method = RequestMethod.POST)
  @RequireHardLogIn
  public String editAddress(
      final AddressForm addressForm,
      final BindingResult bindingResult,
      final Model model,
      final RedirectAttributes redirectModel)
      throws CMSItemNotFoundException {
    getAddressValidator().validate(addressForm, bindingResult);
    if (bindingResult.hasErrors()) {
      GlobalMessages.addErrorMessage(model, "form.global.error");
      storeCmsPageInModel(model, getContentPageForLabelOrId(ADD_EDIT_ADDRESS_CMS_PAGE));
      setUpMetaDataForContentPage(model, getContentPageForLabelOrId(ADD_EDIT_ADDRESS_CMS_PAGE));
      setUpAddressFormAfterError(addressForm, model);
      return ControllerConstants.Views.Pages.Account.AccountEditAddressPage;
    }

    model.addAttribute("metaRobots", "no-index,no-follow");

    final AddressData newAddress = new AddressData();
    newAddress.setId(addressForm.getAddressId());
    newAddress.setTitleCode(addressForm.getTitleCode());
    newAddress.setFirstName(addressForm.getFirstName());
    newAddress.setLastName(addressForm.getLastName());
    newAddress.setLine1(addressForm.getLine1());
    newAddress.setLine2(addressForm.getLine2());
    newAddress.setTown(addressForm.getTownCity());
    newAddress.setPostalCode(addressForm.getPostcode());
    newAddress.setBillingAddress(false);
    newAddress.setShippingAddress(true);
    newAddress.setVisibleInAddressBook(true);
    newAddress.setCountry(getI18NFacade().getCountryForIsocode(addressForm.getCountryIso()));

    if (addressForm.getRegionIso() != null && !StringUtils.isEmpty(addressForm.getRegionIso())) {
      newAddress.setRegion(
          getI18NFacade().getRegion(addressForm.getCountryIso(), addressForm.getRegionIso()));
    }

    if (Boolean.TRUE.equals(addressForm.getDefaultAddress())
        || userFacade.getAddressBook().size() <= 1) {
      newAddress.setDefaultAddress(true);
      newAddress.setVisibleInAddressBook(true);
    }

    final AddressVerificationResult<AddressVerificationDecision> verificationResult =
        getAddressVerificationFacade().verifyAddressData(newAddress);
    final boolean addressRequiresReview =
        getAddressVerificationResultHandler()
            .handleResult(
                verificationResult,
                newAddress,
                model,
                redirectModel,
                bindingResult,
                getAddressVerificationFacade().isCustomerAllowedToIgnoreAddressSuggestions(),
                "checkout.multi.address.updated");

    if (addressRequiresReview) {
      model.addAttribute(
          "regions", getI18NFacade().getRegionsForCountryIso(addressForm.getCountryIso()));
      model.addAttribute("country", addressForm.getCountryIso());
      model.addAttribute("edit", Boolean.TRUE);
      storeCmsPageInModel(model, getContentPageForLabelOrId(ADD_EDIT_ADDRESS_CMS_PAGE));
      setUpMetaDataForContentPage(model, getContentPageForLabelOrId(ADD_EDIT_ADDRESS_CMS_PAGE));
      return ControllerConstants.Views.Pages.Account.AccountEditAddressPage;
    }

    userFacade.editAddress(newAddress);

    return REDIRECT_TO_ADDRESS_BOOK_PAGE;
  }
  @RequestMapping(value = "/add-address", method = RequestMethod.POST)
  @RequireHardLogIn
  public String addAddress(
      final AddressForm addressForm,
      final BindingResult bindingResult,
      final Model model,
      final HttpServletRequest request,
      final RedirectAttributes redirectModel)
      throws CMSItemNotFoundException {
    getAddressValidator().validate(addressForm, bindingResult);
    if (bindingResult.hasErrors()) {
      GlobalMessages.addErrorMessage(model, "form.global.error");
      storeCmsPageInModel(model, getContentPageForLabelOrId(ADD_EDIT_ADDRESS_CMS_PAGE));
      setUpMetaDataForContentPage(model, getContentPageForLabelOrId(ADD_EDIT_ADDRESS_CMS_PAGE));
      setUpAddressFormAfterError(addressForm, model);
      return getViewForPage(model);
    }

    final AddressData newAddress = new AddressData();
    newAddress.setTitleCode(addressForm.getTitleCode());
    newAddress.setFirstName(addressForm.getFirstName());
    newAddress.setLastName(addressForm.getLastName());
    newAddress.setLine1(addressForm.getLine1());
    newAddress.setLine2(addressForm.getLine2());
    newAddress.setTown(addressForm.getTownCity());
    newAddress.setPostalCode(addressForm.getPostcode());
    newAddress.setBillingAddress(false);
    newAddress.setShippingAddress(true);
    newAddress.setVisibleInAddressBook(true);
    newAddress.setCountry(getI18NFacade().getCountryForIsocode(addressForm.getCountryIso()));

    if (addressForm.getRegionIso() != null && !StringUtils.isEmpty(addressForm.getRegionIso())) {
      newAddress.setRegion(
          getI18NFacade().getRegion(addressForm.getCountryIso(), addressForm.getRegionIso()));
    }

    if (userFacade.isAddressBookEmpty()) {
      newAddress.setDefaultAddress(true);
      newAddress.setVisibleInAddressBook(true);
    } else {
      newAddress.setDefaultAddress(
          addressForm.getDefaultAddress() != null
              && addressForm.getDefaultAddress().booleanValue());
    }

    final AddressVerificationResult<AddressVerificationDecision> verificationResult =
        getAddressVerificationFacade().verifyAddressData(newAddress);
    final boolean addressRequiresReview =
        getAddressVerificationResultHandler()
            .handleResult(
                verificationResult,
                newAddress,
                model,
                redirectModel,
                bindingResult,
                getAddressVerificationFacade().isCustomerAllowedToIgnoreAddressSuggestions(),
                "checkout.multi.address.added");

    if (addressRequiresReview) {
      model.addAttribute(
          "regions", getI18NFacade().getRegionsForCountryIso(addressForm.getCountryIso()));
      model.addAttribute("country", addressForm.getCountryIso());
      storeCmsPageInModel(model, getContentPageForLabelOrId(ADD_EDIT_ADDRESS_CMS_PAGE));
      setUpMetaDataForContentPage(model, getContentPageForLabelOrId(ADD_EDIT_ADDRESS_CMS_PAGE));
      return getViewForPage(model);
    }

    userFacade.addAddress(newAddress);

    return REDIRECT_TO_ADDRESS_BOOK_PAGE;
  }