Subversion Repositories SmartDukaan

Rev

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

Rev 5529 Rev 5945
Line 1... Line 1...
1
package in.shop2020.serving.controllers;
1
package in.shop2020.serving.controllers;
2
 
2
 
3
import in.shop2020.model.v1.catalog.InventoryServiceException;
3
import in.shop2020.model.v1.catalog.CatalogServiceException;
4
import in.shop2020.serving.cache.EhcacheWrapper;
4
import in.shop2020.serving.cache.EhcacheWrapper;
5
import in.shop2020.serving.services.ContentServingService;
5
import in.shop2020.serving.services.ContentServingService;
6
import in.shop2020.serving.utils.SnippetType;
6
import in.shop2020.serving.utils.SnippetType;
7
import in.shop2020.thrift.clients.CatalogClient;
7
import in.shop2020.thrift.clients.CatalogClient;
8
 
8
 
Line 68... Line 68...
68
    	List<Long> latestArrivalCategories = new ArrayList<Long>();
68
    	List<Long> latestArrivalCategories = new ArrayList<Long>();
69
    	//Right now if we have brand name, we can just send back for all categories
69
    	//Right now if we have brand name, we can just send back for all categories
70
    	if(brandName==null){
70
    	if(brandName==null){
71
    	    latestArrivalCategories.add(categoryId);
71
    	    latestArrivalCategories.add(categoryId);
72
    	}
72
    	}
73
    	in.shop2020.model.v1.catalog.InventoryService.Client client = catalogClientService.getClient();
73
    	in.shop2020.model.v1.catalog.CatalogService.Client client = catalogClientService.getClient();
74
    	
74
    	
75
        this.items = client.getLatestArrivalsCatalogIds(beginIndex, windowSize, brandName, latestArrivalCategories);
75
        this.items = client.getLatestArrivalsCatalogIds(beginIndex, windowSize, brandName, latestArrivalCategories);
76
        setSnippets();
76
        setSnippets();
77
    	return new DefaultHttpHeaders("index");
77
    	return new DefaultHttpHeaders("index");
78
    }
78
    }
Line 94... Line 94...
94
        		log.info("Using Cache.");
94
        		log.info("Using Cache.");
95
        		return new DefaultHttpHeaders("show");
95
        		return new DefaultHttpHeaders("show");
96
        	}
96
        	}
97
        }
97
        }
98
        log.info("Getting latest arrivals from snippets.");
98
        log.info("Getting latest arrivals from snippets.");
99
    	in.shop2020.model.v1.catalog.InventoryService.Client client = catalogClientService.getClient();
99
    	in.shop2020.model.v1.catalog.CatalogService.Client client = catalogClientService.getClient();
100
    	try {
100
    	try {
101
    		long count = client.getLatestArrivalsCount();
101
    		long count = client.getLatestArrivalsCount();
102
			this.setTotalItems(count > 20 ? 20 : count);
102
			this.setTotalItems(count > 20 ? 20 : count);
103
			if(sourceId == -1){
103
			if(sourceId == -1){
104
				showcasePageSnippetsCache.put(SHOWCASE_LATEST_ARRIVALS_COUNT_CACHE_KEY, this.totalItems);
104
				showcasePageSnippetsCache.put(SHOWCASE_LATEST_ARRIVALS_COUNT_CACHE_KEY, this.totalItems);
Line 106... Line 106...
106
			this.items = client.getLatestArrivalsCatalogIds(beginIndex, windowSize, null, Arrays.asList(new Long[]{10002L, 10003L, 10010L, 10050L}));
106
			this.items = client.getLatestArrivalsCatalogIds(beginIndex, windowSize, null, Arrays.asList(new Long[]{10002L, 10003L, 10010L, 10050L}));
107
			setSnippets();
107
			setSnippets();
108
			if(sourceId == -1){
108
			if(sourceId == -1){
109
				showcasePageSnippetsCache.put(SHOWCASE_LATEST_ARRIVALS_CACHE_KEY + beginIndex, this.snippets);
109
				showcasePageSnippetsCache.put(SHOWCASE_LATEST_ARRIVALS_CACHE_KEY + beginIndex, this.snippets);
110
			}
110
			}
111
		} catch (InventoryServiceException e) {
111
		} catch (CatalogServiceException e) {
112
			log.error("Unable to get latest arrivals from inventory service.", e);
112
			log.error("Unable to get latest arrivals from inventory service.", e);
113
		} catch (TException e) {
113
		} catch (TException e) {
114
			log.error("Unable to get latest arrivals from inventory service.", e);
114
			log.error("Unable to get latest arrivals from inventory service.", e);
115
		}
115
		}
116
    	return new DefaultHttpHeaders("show");
116
    	return new DefaultHttpHeaders("show");