Subversion Repositories SmartDukaan

Rev

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

Rev 6902 Rev 8578
Line 38... Line 38...
38
	private static final String LATEST_ARRIVALS_CACHE_KEY = "home_latest_arrivals_snippet";
38
	private static final String LATEST_ARRIVALS_CACHE_KEY = "home_latest_arrivals_snippet";
39
	
39
	
40
	private List<String> bestDealSnippets = null;
40
	private List<String> bestDealSnippets = null;
41
	private List<String> bestSellerSnippets = null;
41
	private List<String> bestSellerSnippets = null;
42
	private List<String> latestArrivalSnippets = null;
42
	private List<String> latestArrivalSnippets = null;
43
	private static List<Banner> activeBanners = null;
-
 
44
	private static Map<String, List<BannerMap>> allBannersMap = null;
-
 
45
	
43
	
46
	public HomeController(){
44
	public HomeController(){
47
		super();
45
		super();
48
	}
46
	}
49
 
47
 
Line 77... Line 75...
77
	public String destroy() throws SecurityException, IOException{
75
	public String destroy() throws SecurityException, IOException{
78
        logger.info("Reloading best deals, best sellers and latest arrivals");
76
        logger.info("Reloading best deals, best sellers and latest arrivals");
79
        EhcacheWrapper<String, List<String>> homeSnippetCache = new EhcacheWrapper<String, List<String>>(
77
        EhcacheWrapper<String, List<String>> homeSnippetCache = new EhcacheWrapper<String, List<String>>(
80
                EhcacheWrapper.HOME_PAGE_SNIPPET_CACHE_NAME, CacheManager.create());
78
                EhcacheWrapper.HOME_PAGE_SNIPPET_CACHE_NAME, CacheManager.create());
81
        homeSnippetCache.removeAll();
79
        homeSnippetCache.removeAll();
82
        activeBanners = null;
-
 
83
    	allBannersMap = null;
-
 
84
	    setSnippets();
80
	    setSnippets();
85
	    return "index";
81
	    return "index";
86
	}
82
	}
87
	
83
	
88
	public List<String> getBestDealSnippets(){
84
	public List<String> getBestDealSnippets(){
Line 102... Line 98...
102
	 * into memory.
98
	 * into memory.
103
	 */
99
	 */
104
    private void setSnippets() {
100
    private void setSnippets() {
105
        EhcacheWrapper<String, List<String>> homeSnippetCache = new EhcacheWrapper<String, List<String>>(
101
        EhcacheWrapper<String, List<String>> homeSnippetCache = new EhcacheWrapper<String, List<String>>(
106
                EhcacheWrapper.HOME_PAGE_SNIPPET_CACHE_NAME, CacheManager.create());
102
                EhcacheWrapper.HOME_PAGE_SNIPPET_CACHE_NAME, CacheManager.create());
-
 
103
        logger.info("Source id "+sourceId);
107
        if(sourceId == -1){
104
        if(sourceId == -1){
108
        	bestDealSnippets = homeSnippetCache.get(BEST_DEALS_CACHE_KEY);
105
        	bestDealSnippets = homeSnippetCache.get(BEST_DEALS_CACHE_KEY);
109
        	bestSellerSnippets = homeSnippetCache.get(BEST_SELLERS_CACHE_KEY);
106
        	bestSellerSnippets = homeSnippetCache.get(BEST_SELLERS_CACHE_KEY);
110
        	latestArrivalSnippets = homeSnippetCache.get(LATEST_ARRIVALS_CACHE_KEY);
107
        	latestArrivalSnippets = homeSnippetCache.get(LATEST_ARRIVALS_CACHE_KEY);
111
        
108
        
Line 120... Line 117...
120
        
117
        
121
        int bestSellerCount = 4;
118
        int bestSellerCount = 4;
122
        int latestArrivalCount = 4;
119
        int latestArrivalCount = 4;
123
        
120
        
124
        try {
121
        try {
-
 
122
        	activeBanners=null;
-
 
123
    	    allBannersMap=null;
-
 
124
    	    setBanners();
125
            CatalogClient catalogServiceClient = new CatalogClient();
125
            CatalogClient catalogServiceClient = new CatalogClient();
126
            Client client = catalogServiceClient.getClient();
126
            Client client = catalogServiceClient.getClient();
127
        
-
 
128
            activeBanners = client.getActiveBanners();
-
 
129
            if(activeBanners != null){
-
 
130
            	allBannersMap = new HashMap<String, List<BannerMap>>();
-
 
131
            	for(Banner banner: activeBanners){
-
 
132
            		allBannersMap.put(banner.getBannerName(), client.getBannerMapDetails(banner.getBannerName()));
-
 
133
            	}
-
 
134
            }
-
 
135
 
-
 
136
        	
-
 
137
            //Get top 4 best deals 
127
            //Get top 4 best deals 
138
            bestDealCatalogIds = client.getBestDealsCatalogIds(0, 4, null, -1);
128
            bestDealCatalogIds = client.getBestDealsCatalogIds(0, 4, null, -1);
139
            
129
            
140
            //Get top 8 best sellers b'coz 4 of them may overlap with best deals.
130
            //Get top 8 best sellers b'coz 4 of them may overlap with best deals.
141
            bestSellerCatalogIds = client.getBestSellersCatalogIds(0, 8, null, -1);
131
            bestSellerCatalogIds = client.getBestSellersCatalogIds(0, 8, null, -1);
Line 188... Line 178...
188
        	snippets.add(ContentServingService.getSnippet(SnippetType.HOME_SNIPPET, item+"", sourceId));
178
        	snippets.add(ContentServingService.getSnippet(SnippetType.HOME_SNIPPET, item+"", sourceId));
189
        }
179
        }
190
        return snippets;
180
        return snippets;
191
    }
181
    }
192
    
182
    
193
    public List<Banner> getActiveBanners() {
-
 
194
    	return activeBanners;
-
 
195
    }
-
 
196
    
-
 
197
    public List<BannerMap> getbannermapdetails(String bannerName) {
-
 
198
    	return allBannersMap.get(bannerName);
-
 
199
    }
-
 
200
    
183
    
201
    public int activeBannerCount() {
-
 
202
    	return activeBanners.size();
-
 
203
    }
-
 
204
    
184
    
205
    @Override
185
    @Override
206
	public String getHeaderSnippet() {
186
	public String getHeaderSnippet() {
207
		String url = request.getQueryString();
187
		String url = request.getQueryString();
208
		if (url == null) {
188
		if (url == null) {