Rev 2949 | Rev 4630 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
/****/package in.shop2020.serving.controllers;import java.util.StringTokenizer;import in.shop2020.logistics.LogisticsService.Client;import in.shop2020.logistics.LogisticsServiceException;import in.shop2020.thrift.clients.LogisticsClient;import org.apache.log4j.Logger;import org.apache.struts2.rest.DefaultHttpHeaders;import org.apache.struts2.rest.HttpHeaders;import org.apache.thrift.TException;/*** @author rajveer**/public class EstimateController extends BaseController {private static final long serialVersionUID = 8023801600023970837L;private static Logger log = Logger.getLogger(Class.class);private String id;private long itemId;private String pincode;private long days = -1;public EstimateController() {super();}// GET /logoutpublic HttpHeaders show(){LogisticsClient logisticsServiceClient = null;try {logisticsServiceClient = new LogisticsClient();Client logisticsClient = logisticsServiceClient.getClient();days = logisticsClient.getLogisticsEstimation(itemId, pincode).getDeliveryTime();}catch (LogisticsServiceException e) {days = -1;log.error("Unable to get estimate for " + itemId, e);}catch(TException e){}catch (Exception e) {}return new DefaultHttpHeaders("index");}/**** @param id*/public void setId(String id) {this.id = id;StringTokenizer tokenizer = new StringTokenizer(this.id, "_");this.pincode = tokenizer.nextToken();this.itemId = Long.parseLong(tokenizer.nextToken());}public long getEstimatedTime() {return days;}}