@RequestMapping(value = BoUrls.DELIVERY_METHOD_DETAILS_URL, method = RequestMethod.GET)
  public ModelAndView deliveryMethodDetails(final HttpServletRequest request, final Model model)
      throws Exception {
    ModelAndViewThemeDevice modelAndView =
        new ModelAndViewThemeDevice(
            getCurrentVelocityPath(request), BoUrls.DELIVERY_METHOD_DETAILS.getVelocityPage());
    final RequestData requestData = requestUtil.getRequestData(request);

    final String deliveryMethodCode =
        request.getParameter(RequestConstants.REQUEST_PARAMETER_DELIVERY_METHOD_CODE);

    // SANITY CHECK
    if (StringUtils.isEmpty(deliveryMethodCode)) {
      final String urlRedirect =
          backofficeUrlService.generateUrl(BoUrls.DELIVERY_METHOD_LIST, requestData);
      return new ModelAndView(new RedirectView(urlRedirect));
    }

    final DeliveryMethod deliveryMethod =
        deliveryMethodService.getDeliveryMethodByCode(deliveryMethodCode);

    // SANITY CHECK
    if (deliveryMethod != null) {
      modelAndView.addObject(
          ModelConstants.DELIVERY_METHOD_VIEW_BEAN,
          backofficeViewBeanFactory.buildViewBeanDeliveryMethod(requestData, deliveryMethod));
    } else {
      final String url = requestUtil.getLastRequestUrl(request);
      return new ModelAndView(new RedirectView(url));
    }

    final List<WarehouseViewBean> warehouseViewBeans = new ArrayList<WarehouseViewBean>();
    final List<Warehouse> warehouses =
        warehouseService.findWarehousesByDeliveryMethodId(deliveryMethod.getId());
    for (Iterator<Warehouse> iterator = warehouses.iterator(); iterator.hasNext(); ) {
      Warehouse warehouse = (Warehouse) iterator.next();
      warehouseViewBeans.add(
          backofficeViewBeanFactory.buildViewBeanWarehouse(
              requestUtil.getRequestData(request), warehouse));
    }
    request.setAttribute(ModelConstants.WAREHOUSES_VIEW_BEAN, warehouseViewBeans);

    model.addAttribute(
        ModelConstants.URL_BACK,
        backofficeUrlService.generateUrl(BoUrls.DELIVERY_METHOD_LIST, requestData));

    Object[] params = {deliveryMethod.getName() + " (" + deliveryMethod.getCode() + ")"};
    initPageTitleAndMainContentTitle(
        request, modelAndView, BoUrls.DELIVERY_METHOD_DETAILS.getKey(), params);

    return modelAndView;
  }
  @RequestMapping(value = BoUrls.DELIVERY_METHOD_EDIT_URL, method = RequestMethod.GET)
  public ModelAndView deliveryMethodEdit(
      final HttpServletRequest request,
      final Model model,
      @ModelAttribute(ModelConstants.DELIVERY_METHOD_FORM) DeliveryMethodForm deliveryMethodForm)
      throws Exception {
    ModelAndViewThemeDevice modelAndView =
        new ModelAndViewThemeDevice(
            getCurrentVelocityPath(request), BoUrls.DELIVERY_METHOD_EDIT.getVelocityPage());
    final RequestData requestData = requestUtil.getRequestData(request);

    final String deliveryMethodCode =
        request.getParameter(RequestConstants.REQUEST_PARAMETER_DELIVERY_METHOD_CODE);
    if (StringUtils.isNotEmpty(deliveryMethodCode)) {
      // EDIT MODE
      final DeliveryMethod deliveryMethod =
          deliveryMethodService.getDeliveryMethodByCode(
              deliveryMethodCode, FetchPlanGraphDeliveryMethod.fullDeliveryMethodFetchPlan());

      DeliveryMethodViewBean deliveryMethodViewBean =
          backofficeViewBeanFactory.buildViewBeanDeliveryMethod(requestData, deliveryMethod);
      request.setAttribute(ModelConstants.DELIVERY_METHOD_VIEW_BEAN, deliveryMethodViewBean);

      Object[] params = {deliveryMethod.getName() + " (" + deliveryMethod.getCode() + ")"};
      initPageTitleAndMainContentTitle(
          request, modelAndView, BoUrls.DELIVERY_METHOD_EDIT.getKey(), params);

      model.addAttribute(
          ModelConstants.URL_BACK,
          backofficeUrlService.generateUrl(
              BoUrls.DELIVERY_METHOD_DETAILS, requestData, deliveryMethod));
    } else {
      // ADD MODE

      initPageTitleAndMainContentTitle(
          request, modelAndView, BoUrls.DELIVERY_METHOD_ADD.getKey(), null);

      model.addAttribute(
          ModelConstants.URL_BACK,
          backofficeUrlService.generateUrl(BoUrls.DELIVERY_METHOD_LIST, requestData));
    }

    return modelAndView;
  }