Subversion Repositories SmartDukaan

Rev

Rev 762 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 762 Rev 786
Line 4... Line 4...
4
package in.shop2020.serving.controllers;
4
package in.shop2020.serving.controllers;
5
 
5
 
6
import java.util.StringTokenizer;
6
import java.util.StringTokenizer;
7
 
7
 
8
import in.shop2020.logistics.LogisticsService.Client;
8
import in.shop2020.logistics.LogisticsService.Client;
-
 
9
import in.shop2020.logistics.LogisticsServiceException;
9
import in.shop2020.thrift.clients.LogisticsServiceClient;
10
import in.shop2020.thrift.clients.LogisticsServiceClient;
10
 
11
 
11
import org.apache.juli.logging.Log;
12
import org.apache.juli.logging.Log;
12
import org.apache.juli.logging.LogFactory;
13
import org.apache.juli.logging.LogFactory;
13
import org.apache.struts2.rest.DefaultHttpHeaders;
14
import org.apache.struts2.rest.DefaultHttpHeaders;
14
import org.apache.struts2.rest.HttpHeaders;
15
import org.apache.struts2.rest.HttpHeaders;
-
 
16
import org.apache.thrift.TException;
15
 
17
 
16
/**
18
/**
17
 * @author rajveer
19
 * @author rajveer
18
 *
20
 *
19
 */
21
 */
Line 25... Line 27...
25
	private static Log log = LogFactory.getLog(EstimateController.class);
27
	private static Log log = LogFactory.getLog(EstimateController.class);
26
	
28
	
27
	private String id;
29
	private String id;
28
	private long itemId;
30
	private long itemId;
29
	private String pincode;
31
	private String pincode;
30
	private long days = 3;
32
	private long days = 0;
31
	public EstimateController() {
33
	public EstimateController() {
32
		super();
34
		super();
33
	}
35
	}
34
    
36
    
35
    // GET /logout
37
    // GET /logout
36
    public HttpHeaders show() throws Exception {
38
    public HttpHeaders show(){
37
    	LogisticsServiceClient logisticsServiceClient = null;
39
    	LogisticsServiceClient logisticsServiceClient = null;
38
    	try {
40
    	try {
39
			logisticsServiceClient = new LogisticsServiceClient();
41
			logisticsServiceClient = new LogisticsServiceClient();
40
			Client logisticsClient = logisticsServiceClient.getClient();
42
			Client logisticsClient = logisticsServiceClient.getClient();
41
			days = logisticsClient.getLogisticsEstimation(itemId, pincode).getDeliveryTime();
43
			days = logisticsClient.getLogisticsEstimation(itemId, pincode).getDeliveryTime();
42
			
44
			
43
		} catch (Exception e) {
45
    	}catch (LogisticsServiceException e) {
-
 
46
    		days = 0;
44
			// TODO Auto-generated catch block
47
    		log.error(e.getMessage());
45
			e.printStackTrace();
48
    		e.printStackTrace();
46
		} finally{
49
		}catch(TException e){
-
 
50
			
-
 
51
		}
47
			if( logisticsServiceClient != null ) {
52
    	catch (Exception e) {
48
				logisticsServiceClient.closeConnection();
-
 
49
			}
53
    		
50
		}
54
		}
51
    	return new DefaultHttpHeaders("index");
55
    	return new DefaultHttpHeaders("index");
52
    }
56
    }
53
        
57
        
54
    /**
58
    /**