Subversion Repositories SmartDukaan

Rev

Rev 1923 | Rev 2943 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1923 Rev 2453
Line 38... Line 38...
38
	
38
	
39
	List<Long> items = null;
39
	List<Long> items = null;
40
	
40
	
41
	CatalogServiceClient catalogClientService = null;
41
	CatalogServiceClient catalogClientService = null;
42
	
42
	
43
	
-
 
44
	
-
 
45
	public BestSellersController() {
43
	public BestSellersController() {
46
		super();
44
		super();
47
		try {
45
		try {
48
			catalogClientService = new CatalogServiceClient();
46
			catalogClientService = new CatalogServiceClient();
49
		} catch (Exception e) {
47
		} catch (Exception e) {
50
			log.error("Unable to get catalog service client.");
48
			log.error("Unable to get catalog service client.", e);
51
			e.printStackTrace();
-
 
52
		}
49
		}
53
	}
50
	}
54
    
51
    
55
    // GET /index
52
    // GET /index
56
    public HttpHeaders index() throws Exception {
53
    public HttpHeaders index() throws Exception {
Line 70... Line 67...
70
    	in.shop2020.model.v1.catalog.InventoryService.Client client = catalogClientService.getClient();
67
    	in.shop2020.model.v1.catalog.InventoryService.Client client = catalogClientService.getClient();
71
    	try {
68
    	try {
72
			this.setTotalItems(client.getBestSellersCount());
69
			this.setTotalItems(client.getBestSellersCount());
73
			this.items = client.getBestSellersCatalogIds(beginIndex, windowSize, null, -1);
70
			this.items = client.getBestSellersCatalogIds(beginIndex, windowSize, null, -1);
74
		} catch (InventoryServiceException e) {
71
		} catch (InventoryServiceException e) {
75
			log.error("Unable to get best sellers from inventory service.");
72
			log.error("Unable to get best sellers from inventory service.", e);
76
			log.error("Exception id is:"  + e.getId() + " Exception message is:" + e.getMessage());
-
 
77
			e.printStackTrace();
-
 
78
		} catch (TException e) {
73
		} catch (TException e) {
79
			log.error("Unable to get best sellers from inventory service.");
74
			log.error("Unable to get best sellers from inventory service.", e);
80
			log.error(" Exception message is:" + e.getMessage());
-
 
81
			e.printStackTrace();
-
 
82
		}
75
		}
83
    	return new DefaultHttpHeaders("show");
76
    	return new DefaultHttpHeaders("show");
84
    }
77
    }
85
    
78
    
86
    public List<String> getItems() {
79
    public List<String> getItems() {
87
    	ArrayList<String> snippets = new ArrayList<String>();
80
    	ArrayList<String> snippets = new ArrayList<String>();
88
    	if(items != null){
81
    	if(items != null){
89
    		for(long item: items){
82
    		for(long item: items){
90
				try {
83
				try {
91
					snippets.add(FileUtils.read( Utils.EXPORT_ENTITIES_PATH + item + File.separator +"CategorySnippet.html"));
84
					snippets.add(FileUtils.read(Utils.EXPORT_ENTITIES_PATH + item + File.separator +"CategorySnippet.html"));
92
				} catch (IOException ioex) {
85
				} catch (IOException ioex) {
93
					ioex.printStackTrace();
86
					log.error("Error while getting the snippet for: " + item, ioex);
94
    				log.error(ioex);
-
 
95
				}
87
				}
96
			}
88
			}
97
    	}
89
    	}
98
		
90
		
99
    	return snippets;
91
    	return snippets;