Subversion Repositories SmartDukaan

Rev

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

Rev 2944 Rev 3126
Line 6... Line 6...
6
import java.util.Date;
6
import java.util.Date;
7
import java.util.List;
7
import java.util.List;
8
 
8
 
9
import in.shop2020.model.v1.order.LineItem;
9
import in.shop2020.model.v1.order.LineItem;
10
import in.shop2020.model.v1.order.Order;
10
import in.shop2020.model.v1.order.Order;
11
import in.shop2020.model.v1.user.UserContextException;
11
import in.shop2020.model.v1.user.UserCommunicationException;
12
import in.shop2020.model.v1.user.UserContextService;
12
import in.shop2020.model.v1.user.UserContextService;
13
import in.shop2020.model.v1.user.UserCommunicationType;
13
import in.shop2020.model.v1.user.UserCommunicationType;
14
import in.shop2020.serving.controllers.BaseController;
14
import in.shop2020.serving.controllers.BaseController;
15
import in.shop2020.thrift.clients.TransactionServiceClient;
15
import in.shop2020.thrift.clients.TransactionClient;
16
import in.shop2020.thrift.clients.UserContextServiceClient;
16
import in.shop2020.thrift.clients.UserClient;
17
import in.shop2020.serving.utils.UserMessage;
17
import in.shop2020.serving.utils.UserMessage;
18
 
18
 
19
import org.apache.log4j.Logger;
19
import org.apache.log4j.Logger;
-
 
20
import org.apache.thrift.TException;
-
 
21
import org.apache.thrift.transport.TTransportException;
20
 
22
 
21
/**
23
/**
22
 * @author Varun Gupta
24
 * @author Varun Gupta
23
 */
25
 */
24
 
26
 
Line 40... Line 42...
40
    }
42
    }
41
 
43
 
42
    // GET /Show Form
44
    // GET /Show Form
43
    public String index() {
45
    public String index() {
44
        try {
46
        try {
45
            TransactionServiceClient transactionServiceClient = new TransactionServiceClient();
47
            TransactionClient transactionServiceClient = new TransactionClient();
46
            in.shop2020.model.v1.order.TransactionService.Client orderClient = transactionServiceClient.getClient();
48
            in.shop2020.model.v1.order.TransactionService.Client orderClient = transactionServiceClient.getClient();
47
            orders = orderClient.getOrdersForCustomer(userinfo.getUserId(), 0, (new Date()).getTime(), null);
49
            orders = orderClient.getOrdersForCustomer(userinfo.getUserId(), 0, (new Date()).getTime(), null);
48
        } catch (Exception e) {
50
        } catch (Exception e) {
49
            log.error("Unable to get the orders for the user becauase of: ", e);
51
            log.error("Unable to get the orders for the user becauase of: ", e);
50
        }
52
        }
Line 64... Line 66...
64
        return "index";
66
        return "index";
65
    }
67
    }
66
 
68
 
67
    public String show() throws SecurityException, IOException {
69
    public String show() throws SecurityException, IOException {
68
        try {
70
        try {
69
            TransactionServiceClient transactionServiceClient = new TransactionServiceClient();
71
            TransactionClient transactionServiceClient = new TransactionClient();
70
            in.shop2020.model.v1.order.TransactionService.Client orderClient = transactionServiceClient.getClient();
72
            in.shop2020.model.v1.order.TransactionService.Client orderClient = transactionServiceClient.getClient();
71
 
73
 
72
            if (id.equals("to_return")) {
74
            if (id.equals("to_return")) {
73
                order_ids = orderClient.getReturnableOrdersForCustomer(userinfo.getUserId(), 0);
75
                order_ids = orderClient.getReturnableOrdersForCustomer(userinfo.getUserId(), 0);
74
            } else if (id.equals("to_cancel")) {
76
            } else if (id.equals("to_cancel")) {
Line 104... Line 106...
104
            String awb = request.getParameter("awb");
106
            String awb = request.getParameter("awb");
105
            String product = request.getParameter("product");
107
            String product = request.getParameter("product");
106
            String subject = request.getParameter("subject");
108
            String subject = request.getParameter("subject");
107
            String message = request.getParameter("message");
109
            String message = request.getParameter("message");
108
 
110
 
109
            UserContextService.Client userClient = (new UserContextServiceClient()).getClient();
111
            UserContextService.Client userClient = (new UserClient()).getClient();
110
 
112
 
111
            if (userClient.saveUserCommunication(userId, email, communicationType, orderId, awb, product, subject,
113
            if (userClient.saveUserCommunication(userId, email, communicationType, orderId, awb, product, subject,
112
                    message)) {
114
                    message)) {
113
                log.info("User Communication saved successfully!");
115
                log.info("User Communication saved successfully!");
114
            }
116
            }
115
 
117
 
116
        } catch (NumberFormatException e) {
118
        } catch (NumberFormatException e) {
117
            log.error("Unable to get communication type or order id: ", e);
119
            log.error("Unable to get communication type or order id: ", e);
118
        } catch (UserContextException e) {
120
        } catch (TTransportException e) {
119
            log.error("Unable to save user communication: ", e);
121
        	log.error("Unable to initialize client: ", e);
120
        } catch (Exception e) {
122
		} catch (UserCommunicationException e) {
121
            log.error("Unable to save user communication: ", e);
123
            log.error("Unable to get communication type or order id: ", e);
122
        } finally {
124
		} catch (TException e) {
-
 
125
			log.error("Thrift exception: ", e);
123
 
126
		}
124
        }
-
 
125
        return "success";
127
        return "success";
126
    }
128
    }
127
 
129
 
128
    public String getId() {
130
    public String getId() {
129
        return this.id;
131
        return this.id;