/** * Processes the requested add address from the multiship process. * This method will create a CustomerAddress based on the requested Address * and associate it with the current Customer in session. * * @param request * @param response * @param model * @param addressForm * @return the return path to the multiship page * @throws ServiceException */ public String saveMultishipAddAddress(HttpServletRequest request, HttpServletResponse response, Model model, ShippingInfoForm addressForm, BindingResult result) throws ServiceException { addressService.populateAddressISOCountrySub(addressForm.getAddress()); multishipAddAddressFormValidator.validate(addressForm, result); if (result.hasErrors()) { return showMultishipAddAddress(request, response, model); } removeUnusedPhones(addressForm); CustomerAddress customerAddress = customerAddressService.create(); customerAddress.setAddressName(addressForm.getAddressName()); customerAddress.setAddress(addressForm.getAddress()); customerAddress.setCustomer(CustomerState.getCustomer()); customerAddressService.saveCustomerAddress(customerAddress); //append current time to redirect to fix a problem with ajax caching in IE return getMultishipAddAddressSuccessView() + "?_=" + System.currentTimeMillis(); }
public String addCustomerAddress(HttpServletRequest request, Model model, CustomerAddressForm form, BindingResult result, RedirectAttributes redirectAttributes) throws ServiceException { addressService.populateAddressISOCountrySub(form.getAddress()); customerAddressValidator.validate(form, result); if (result.hasErrors()) { return getCustomerAddressesView(); } removeUnusedPhones(form); Address address = addressService.saveAddress(form.getAddress()); CustomerAddress customerAddress = customerAddressService.create(); customerAddress.setAddress(address); customerAddress.setAddressName(form.getAddressName()); customerAddress.setCustomer(CustomerState.getCustomer()); customerAddress = customerAddressService.saveCustomerAddress(customerAddress); if (form.getAddress().isDefault()) { customerAddressService.makeCustomerAddressDefault(customerAddress.getId(), customerAddress.getCustomer().getId()); } form.setCustomerAddressId(customerAddress.getId()); if (!isAjaxRequest(request)) { List<CustomerAddress> addresses = customerAddressService.readActiveCustomerAddressesByCustomerId(CustomerState.getCustomer().getId()); model.addAttribute("addresses", addresses); } redirectAttributes.addFlashAttribute("successMessage", getAddressAddedMessage()); return getCustomerAddressesRedirect(); }
if (!customer.isAnonymous() && shippingForm.isSaveAsDefault()) { Address address = addressService.saveAddress(shippingForm.getAddress()); CustomerAddress customerAddress = customerAddressService.create(); customerAddress.setAddress(address); customerAddress.setAddressName(shippingForm.getAddressName());
.map(stream -> stream .map(entry -> { CustomerAddress customerAddress = customerAddressService.create(); customerAddress.setAddressName(entry.getKey()); customerAddress.setAddress(addressConverter.createEntity(entry.getValue()));