Rev 15230 | Rev 15238 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
package in.shop2020.dtrapi.controllers;import java.util.List;import org.apache.log4j.Logger;import in.shop2020.dtrapi.services.UserMessagePojo;import in.shop2020.model.v1.dtr.DtrService.Client;import in.shop2020.thrift.clients.DtrClient;import com.google.gson.Gson;import com.mongodb.util.JSON;public class LivePricingController extends BaseController{private static Logger log = Logger.getLogger(Class.class);private static final long serialVersionUID = 1L;private String skuBundleId;private String source_id;private String id;private String url;private String fetchLive;public String index(){Gson gs = new Gson();DtrClient dc = null;try {dc = new DtrClient();List<in.shop2020.model.v1.dtr.LivePricing> pricingObj = dc.getClient().getLatestPricing(Long.valueOf(skuBundleId), Long.valueOf(source_id));setResultJson(JSON.parse(gs.toJson(pricingObj)).toString());} catch (Exception e) {log.info(e);}finally{dc.closeConnection();}return "index";}public String latestPriceById(){log.info("Inside lastestPriceById");log.info("Id is "+id);log.info("Source id "+source_id);log.info("Encoded Url is "+url);DtrClient dc = null;UserMessagePojo ump = new UserMessagePojo();ump.setMessage("");ump.setResult(false);try {dc = new DtrClient();if (Boolean.valueOf(fetchLive))dc.getClient().updateLatestPriceForItem(Long.valueOf(id));if (Long.valueOf(source_id) == 3){SnapdealProductPageParserController spp = new SnapdealProductPageParserController();spp.setUrl(url);setResultJson(spp.getColorMessage());}else{throw new Exception();}} catch (Exception e) {setResultJson(ump);}finally{dc.closeConnection();}return "index";}public String getSkuBundleId() {return skuBundleId;}public void setSkuBundleId(String skuBundleId) {this.skuBundleId = skuBundleId;}public String getSource_id() {return source_id;}public void setSource_id(String source_id) {this.source_id = source_id;}public void setId(String id) {this.id = id;}public String getId() {return id;}public String getUrl() {return url;}public void setUrl(String url) {this.url = url;}public void setFetchLive(String fetchLive) {this.fetchLive = fetchLive;}public String getFetchLive() {return fetchLive;}public static void main (String[] args){LivePricingController live = new LivePricingController();live.setId("84");live.setUrl("aHR0cDovL20uc25hcGRlYWwuY29tL3Byb2R1Y3Qvc3BpY2UtYm9zcy1lbnRlcnRhaW5lci0zLW01NDA2LzEwNTA2ODk2MjM/c3VwYz1TREw3MDA0MzYzMTUmdXRtX3NvdXJjZT1hZmZfcHJvZyZ1dG1fY2FtcGFpZ249YWZ0cyZvZmZlcl9pZD0xNyZhZmZfaWQ9MTc5MTUmYWZmX3N1Yj1TSEEzMTQzMTY3NzM0NQ==");live.setSource_id("3");live.setFetchLive("false");live.latestPriceById();System.out.println(live.getResultJson());}}