@RequestMapping(value = BoUrls.PRODUCT_MARKETING_EDIT_URL, method = RequestMethod.GET) public ModelAndView productMarketingEdit( final HttpServletRequest request, final HttpServletResponse response, ModelMap modelMap) throws Exception { ModelAndViewThemeDevice modelAndView = new ModelAndViewThemeDevice( getCurrentVelocityPath(request), BoUrls.PRODUCT_MARKETING_EDIT.getVelocityPage()); final MarketArea currentMarketArea = requestUtil.getCurrentMarketArea(request); final Retailer currentRetailer = requestUtil.getCurrentRetailer(request); final String productMarketingCode = request.getParameter(RequestConstants.REQUEST_PARAMETER_PRODUCT_MARKETING_CODE); final ProductMarketing productMarketing = productMarketingService.getProductMarketingByCode( currentMarketArea.getId(), currentRetailer.getId(), productMarketingCode); // "business.product.marketing.edit"; initProductMarketingModelAndView(request, modelAndView, productMarketing); modelAndView.addObject( "productMarketingForm", formFactory.buildProductMarketingForm(request, productMarketing)); initSpecificSeo(request, modelAndView, "", productMarketing.getBusinessName()); // modelAndView.addObject("productMarketingDetails", // viewBeanFactory.buildUserEditViewBean(request, currentLocalization, user)); return modelAndView; }
@RequestMapping(value = BoUrls.PRODUCT_MARKETING_DETAILS_URL, method = RequestMethod.GET) public ModelAndView productMarketingDetails( final HttpServletRequest request, final HttpServletResponse response) throws Exception { ModelAndViewThemeDevice modelAndView = new ModelAndViewThemeDevice( getCurrentVelocityPath(request), BoUrls.PRODUCT_MARKETING_DETAILS.getVelocityPage()); final MarketArea currentMarketArea = requestUtil.getCurrentMarketArea(request); final Retailer currentRetailer = requestUtil.getCurrentRetailer(request); final String productMarketingCode = request.getParameter(RequestConstants.REQUEST_PARAMETER_PRODUCT_MARKETING_CODE); final ProductMarketing productMarketing = productMarketingService.getProductMarketingByCode( currentMarketArea.getId(), currentRetailer.getId(), productMarketingCode); // "business.product.marketing.details"; initProductMarketingModelAndView(request, modelAndView, productMarketing); initSpecificSeo(request, modelAndView, "", productMarketing.getBusinessName()); return modelAndView; }
@SuppressWarnings("unchecked") public String generateUrl( final String urlWithoutWildcard, final boolean isSEO, final RequestData requestData, Object... params) { String urlStr = null; Map<String, String> getParams = new HashMap<String, String>(); Map<String, String> urlParams = new HashMap<String, String>(); try { if (params != null) { for (Object param : params) { if (param == null) continue; if (param instanceof Retailer) { Retailer retailer = (Retailer) param; urlParams.put( RequestConstants.URL_PATTERN_RETAILER_CODE, handleParamValue(retailer.getCode())); urlStr = addFullPrefixUrl(requestData, urlStr) + handleString(retailer.getName()) + "/"; } else if (param instanceof ProductSku) { ProductSku productSku = (ProductSku) param; urlParams.put( RequestConstants.URL_PATTERN_PRODUCT_SKU_CODE, handleParamValue(productSku.getCode())); urlStr = addFullPrefixUrl(requestData, urlStr); } else if (param instanceof ProductMarketing) { ProductMarketing productMarketing = (ProductMarketing) param; urlParams.put( RequestConstants.URL_PATTERN_PRODUCT_MARKETING_CODE, handleParamValue(productMarketing.getCode())); urlStr = addFullPrefixUrl(requestData, urlStr) + handleString(productMarketing.getBusinessName()) + "/"; } else if (param instanceof CatalogCategoryVirtual) { CatalogCategoryVirtual category = (CatalogCategoryVirtual) param; urlParams.put( RequestConstants.URL_PATTERN_CATEGORY_CODE, handleParamValue(category.getCode())); urlStr = addFullPrefixUrl(requestData, urlStr) + handleString(category.getBusinessName()) + "/"; } else if (param instanceof CatalogCategoryMaster) { CatalogCategoryMaster category = (CatalogCategoryMaster) param; urlParams.put( RequestConstants.URL_PATTERN_CATEGORY_CODE, handleParamValue(category.getCode())); urlStr = addFullPrefixUrl(requestData, urlStr) + handleString(category.getBusinessName()) + "/"; } else if (param instanceof ProductBrand) { ProductBrand productBrand = (ProductBrand) param; urlParams.put( RequestConstants.URL_PATTERN_BRAND_CODE, handleParamValue(productBrand.getCode())); urlStr = addFullPrefixUrl(requestData, urlStr) + handleString(productBrand.getName()) + "/"; } else if (param instanceof CartItem) { CartItem cartItem = (CartItem) param; urlParams.put( RequestConstants.URL_PATTERN_CART_ITEM_CODE, handleParamValue(cartItem.getId().toString())); } else if (param instanceof Map) { getParams = (Map<String, String>) param; } else { logger.warn("Unknowned url parameter : [{}]", param); } } } if (StringUtils.isEmpty(urlStr)) { // AD THE DEFAULT PREFIX - DEFAULT PATH IS urlStr = buildDefaultPrefix(requestData); if (isSEO) { urlStr = getFullPrefixUrl(requestData); } } // REMOVE THE / AT EH END BEFORE ADDING THE /**.html segment if (urlStr.endsWith("/")) { urlStr = urlStr.substring(0, urlStr.length() - 1); } urlStr = urlStr + urlWithoutWildcard; } catch (Exception e) { logger.error("Can't build Url!", e); } return handleUrlParameters(urlStr, urlParams, getParams); }