@RequestMapping(value = "/billingaddressform", method = RequestMethod.GET)
  public String getCountryAddressForm(
      @RequestParam("countryIsoCode") final String countryIsoCode,
      @RequestParam("useDeliveryAddress") final boolean useDeliveryAddress,
      final Model model) {
    model.addAttribute("supportedCountries", getCountries());
    model.addAttribute("regions", getI18NFacade().getRegionsForCountryIso(countryIsoCode));
    model.addAttribute("country", countryIsoCode);

    final SopPaymentDetailsForm sopPaymentDetailsForm = new SopPaymentDetailsForm();
    model.addAttribute("sopPaymentDetailsForm", sopPaymentDetailsForm);
    if (useDeliveryAddress) {
      final AddressData deliveryAddress =
          getCheckoutFacade().getCheckoutCart().getDeliveryAddress();

      if (deliveryAddress.getRegion() != null
          && !StringUtils.isEmpty(deliveryAddress.getRegion().getIsocode())) {
        sopPaymentDetailsForm.setBillTo_state(deliveryAddress.getRegion().getIsocodeShort());
      }

      sopPaymentDetailsForm.setBillTo_titleCode(deliveryAddress.getTitleCode());
      sopPaymentDetailsForm.setBillTo_firstName(deliveryAddress.getFirstName());
      sopPaymentDetailsForm.setBillTo_lastName(deliveryAddress.getLastName());
      sopPaymentDetailsForm.setBillTo_street1(deliveryAddress.getLine1());
      sopPaymentDetailsForm.setBillTo_street2(deliveryAddress.getLine2());
      sopPaymentDetailsForm.setBillTo_city(deliveryAddress.getTown());
      sopPaymentDetailsForm.setBillTo_postalCode(deliveryAddress.getPostalCode());
      sopPaymentDetailsForm.setBillTo_country(deliveryAddress.getCountry().getIsocode());
      sopPaymentDetailsForm.setBillTo_phoneNumber(deliveryAddress.getPhone());
    }
    return ControllerConstants.Views.Fragments.Checkout.BillingAddressForm;
  }
  @RequestMapping(value = "/addressform", method = RequestMethod.GET)
  public String getCountryAddressForm(
      @RequestParam("addressCode") final String addressCode,
      @RequestParam("countryIsoCode") final String countryIsoCode,
      final Model model) {
    model.addAttribute("supportedCountries", getCountries());
    model.addAttribute("regions", getI18NFacade().getRegionsForCountryIso(countryIsoCode));
    model.addAttribute("country", countryIsoCode);

    final AddressForm addressForm = new AddressForm();
    model.addAttribute("addressForm", addressForm);
    for (final AddressData addressData : userFacade.getAddressBook()) {
      if (addressData.getId() != null
          && addressData.getId().equals(addressCode)
          && countryIsoCode.equals(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());
        }

        break;
      }
    }
    return ControllerConstants.Views.Fragments.Account.CountryAddressForm;
  }
 /**
  * Gets the customer bill to data.
  *
  * @param addressData the address data
  * @return the customer bill to data
  */
 private CustomerBillToData getCustomerBillToData(final AddressData addressData) {
   final CustomerBillToData billToData = new CustomerBillToData();
   billToData.setBillToCity(addressData.getTown());
   billToData.setBillToFirstName(addressData.getFirstName());
   billToData.setBillToLastName(addressData.getLastName());
   billToData.setBillToStreet1(addressData.getLine1());
   billToData.setBillToStreet2(addressData.getLine2());
   final RegionData regionData = addressData.getRegion();
   String regionIsoCode = "MH";
   if (regionData != null) {
     regionIsoCode = regionData.getIsocode();
   }
   billToData.setBillToState(regionIsoCode);
   billToData.setBillToCountry(addressData.getCountry().getIsocode());
   billToData.setBillToPostalCode(addressData.getPostalCode());
   return billToData;
 }
  @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;
  }