Rev 6382 | Blame | Last modification | View Log | RSS feed
package in.shop2020.serving.controllers;import in.shop2020.serving.cache.SnippetCacheWrapper;import in.shop2020.serving.cache.EhcacheWrapper.CacheKeys;import in.shop2020.thrift.clients.CatalogClient;import java.util.ArrayList;import java.util.List;import org.apache.log4j.Logger;import org.apache.struts2.convention.annotation.Action;import org.apache.struts2.convention.annotation.Actions;import org.apache.struts2.convention.annotation.Result;/*** @author Varun Gupta*/@SuppressWarnings("serial")@Result(name = "index", location = "clearance-sale-index.vm")public class ClearanceSaleController extends BaseController {private static Logger log = Logger.getLogger(ClearanceSaleController.class);private static List<Long> entityIds = new ArrayList<Long>();private static List<Long> sonyEntityIds = new ArrayList<Long>();private List<String> snippets = new ArrayList<String>();private List<String> sonySnippets = new ArrayList<String>();static {sonyEntityIds.add(1004874L);sonyEntityIds.add(1002111L);sonyEntityIds.add(1003428L);sonyEntityIds.add(1003376L);sonyEntityIds.add(1004882L);sonyEntityIds.add(1004204L);sonyEntityIds.add(1003426L);sonyEntityIds.add(1004838L);sonyEntityIds.add(1005156L);sonyEntityIds.add(1004429L);try {CatalogClient catalogClientService = new CatalogClient();in.shop2020.model.v1.catalog.CatalogService.Client client = catalogClientService.getClient();log.info("Getting clearance sale products snippets.");entityIds = client.getClearanceSaleCatalogIds();} catch (Exception e) {log.error("Unable to get clearance sale products from inventory service", e);}}@Actions({@Action("/clearance-sale"),@Action("/sony")})public String index() {return "index";}public void addEntityId(Long entityId, List<String> snippets) {String snippet = (String) SnippetCacheWrapper.getSnippet(CacheKeys.CATEGORY_SNIPPET_CACHE_KEY, entityId+"", sourceId);if (snippet != null) {snippets.add(snippet);}}public List<String> getSnippets() {if(request.getRequestURI().contains("sony")){for(long entityId: sonyEntityIds){addEntityId(entityId, sonySnippets);}return sonySnippets;}else{for(long entityId: entityIds){addEntityId(entityId, snippets);}return snippets;}}public String getPageTitle(){if(request.getRequestURI().contains("sony")){return "Sony Phones at Best Price";} else{return "Spice and Micromax Phones at Best Price | Clearance Sale";}}}