@RequestMapping("/getCatalog.html") public String getCatalog(Map<String, Object> model) { if (logger.isDebugEnabled()) { logger.debug(""); } ClientConfig config = new DefaultClientConfig(); Client client = Client.create(config); WebResource service = client.resource(getBaseURI()); String xml = service .path("rest") .path("product") .path("findall") .accept(MediaType.TEXT_XML) .get(String.class); ConvertXMLToObject convertXMLToObject = new ConvertXMLToObject(xml); XmlProductMsg productMsg = convertXMLToObject.xmlProductMsgToObjects(); List<XmlProduct> lOfProducts = productMsg.getLOfProducts(); CatalogForm catalogForm = new CatalogForm(); catalogForm.setmOfProducts(lOfProducts); catalogForm.setShowLinks(false); catalogForm.setHeader("Full Catalogue"); catalogForm.setCurrentPage("fullCatalogue"); model.put("catalogForm", catalogForm); return "catalog"; }
@RequestMapping("/myCatalog.html") public Object myCatalog(Map<String, Object> model) { if (logger.isDebugEnabled()) { logger.debug(""); } XmlLogin login = (XmlLogin) model.get("loggedin"); if (login == null || login.getUserId() == null) { return new ModelAndView("redirect:homepage.html"); } ClientConfig config = new DefaultClientConfig(); Client client = Client.create(config); WebResource service = client.resource(getBaseURI()); String xml = service .path("rest") .path("userproduct") .path("finduserproducts") .path(login.getUserId()) .accept(MediaType.TEXT_XML) .get(String.class); ConvertXMLToObject convertXMLToObject = new ConvertXMLToObject(xml); XmlProductMsg productMsg = convertXMLToObject.xmlProductMsgToObjects(); List<XmlProduct> lOfProducts = productMsg.getLOfProducts(); CatalogForm catalogForm = new CatalogForm(); catalogForm.setmOfProducts(lOfProducts); catalogForm.setShowLinks(true); catalogForm.setHeader("My Catalogue"); catalogForm.setOrigin(""); catalogForm.setCurrentPage("myCatalogue"); model.put("catalogForm", catalogForm); return "catalog"; }