@RequestMapping(value = "/products", method=RequestMethod.GET)
	@ResponseBody
	public ReadableProductList getFiltered(
			@RequestParam(value = "lang", required=false) String lang, 
			@RequestParam(value = "category", required=false) Long category, 
			@RequestParam(value = "manufacturer", required=false) Long manufacturer,
			@RequestParam(value = "status", required=false) String status,
			@RequestParam(value = "owner", required=false) Long owner,
			@RequestParam(value = "start", required=false) Integer start,
			@RequestParam(value = "count", required=false) Integer count,
			HttpServletRequest request, HttpServletResponse response) throws Exception {
		ProductCriteria criteria = new ProductCriteria();
		if(!StringUtils.isBlank(lang)) {
			criteria.setLanguage(lang);
		}
		if(!StringUtils.isBlank(status)) {
			criteria.setStatus(status);
		}
		if(category != null) {
			List<Long> categoryIds = new ArrayList<Long>();
			categoryIds.add(category);
			criteria.setCategoryIds(categoryIds);
		}
		if(manufacturer != null) {
			criteria.setManufacturerId(manufacturer);
		}
		if(owner != null) {
			criteria.setOwnerId(owner);
		}
		if(start != null) {
			criteria.setStartIndex(start);
		}
		if(count != null) {
			criteria.setMaxCount(count);
		}
		//TODO
		//RENTAL add filter by owner
		//REPOSITORY to use the new filters
		try {
			MerchantStore merchantStore = storeFacade.getByCode(com.salesmanager.core.business.constants.Constants.DEFAULT_STORE);
			Language language = languageUtils.getRESTLanguage(request, merchantStore);	
			ReadableProductList productList = productFacade.getProductListsByCriterias(merchantStore, language, criteria);
			return productList;
		} catch(Exception e) {
			LOGGER.error("Error while filtering products product",e);
			try {
				response.sendError(503, "Error while filtering products " + e.getMessage());
			} catch (Exception ignore) {
			}
			return null;
		}
	}
@RequestMapping(value = "/products", method=RequestMethod.GET)
	@ResponseBody
	public ReadableProductList getFiltered(
			@RequestParam(value = "lang", required=false) String lang, 
			@RequestParam(value = "category", required=false) Long category, 
			@RequestParam(value = "manufacturer", required=false) Long manufacturer,
			@RequestParam(value = "status", required=false) String status,
			@RequestParam(value = "owner", required=false) Long owner,
			@RequestParam(value = "start", required=false) Integer start,
			@RequestParam(value = "count", required=false) Integer count,
			HttpServletRequest request, HttpServletResponse response) throws Exception {
		ProductCriteria criteria = new ProductCriteria();
		if(!StringUtils.isBlank(lang)) {
			criteria.setLanguage(lang);
		}
		if(!StringUtils.isBlank(status)) {
			criteria.setStatus(status);
		}
		if(category != null) {
			List<Long> categoryIds = new ArrayList<Long>();
			categoryIds.add(category);
			criteria.setCategoryIds(categoryIds);
		}
		if(manufacturer != null) {
			criteria.setManufacturerId(manufacturer);
		}
		if(owner != null) {
			criteria.setOwnerId(owner);
		}
		if(start != null) {
			criteria.setStartIndex(start);
		}
		if(count != null) {
			criteria.setMaxCount(count);
		}
	
	
	
		try {
			MerchantStore merchantStore = storeFacade.getByCode(com.salesmanager.core.business.constants.Constants.DEFAULT_STORE);
			Language language = languageUtils.getRESTLanguage(request, merchantStore);	
			ReadableProductList productList = productFacade.getProductListsByCriterias(merchantStore, language, criteria);
			return productList;
		} catch(Exception e) {
			LOGGER.error("Error while filtering products product",e);
			try {
				response.sendError(503, "Error while filtering products " + e.getMessage());
			} catch (Exception ignore) {
			}
			return null;
		}
	}
@requestmapping(value = "/products", method=requestmethod.get) @responsebody public readableproductlist getfiltered( @requestparam(value = "lang", required=false) string lang, @requestparam(value = "category", required=false) long category, @requestparam(value = "manufacturer", required=false) long manufacturer, @requestparam(value = "status", required=false) string status, @requestparam(value = "owner", required=false) long owner, @requestparam(value = "start", required=false) integer start, @requestparam(value = "count", required=false) integer count, httpservletrequest request, httpservletresponse response) throws exception { productcriteria criteria = new productcriteria(); if(!stringutils.isblank(lang)) { criteria.setlanguage(lang); } if(!stringutils.isblank(status)) { criteria.setstatus(status); } if(category != null) { list<long> categoryids = new arraylist<long>(); categoryids.add(category); criteria.setcategoryids(categoryids); } if(manufacturer != null) { criteria.setmanufacturerid(manufacturer); } if(owner != null) { criteria.setownerid(owner); } if(start != null) { criteria.setstartindex(start); } if(count != null) { criteria.setmaxcount(count); } try { merchantstore merchantstore = storefacade.getbycode(com.salesmanager.core.business.constants.constants.default_store); language language = languageutils.getrestlanguage(request, merchantstore); readableproductlist productlist = productfacade.getproductlistsbycriterias(merchantstore, language, criteria); return productlist; } catch(exception e) { logger.error("error while filtering products product",e); try { response.senderror(503, "error while filtering products " + e.getmessage()); } catch (exception ignore) { } return null; } }