Subversion Repositories SmartDukaan

Rev

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

Rev 1044 Rev 1170
Line 1... Line 1...
1
package in.shop2020.serving.controllers;
1
package in.shop2020.serving.controllers;
2
 
2
 
-
 
3
import java.text.ParseException;
3
import java.util.ArrayList;
4
import java.util.ArrayList;
4
import java.util.List;
5
import java.util.List;
5
 
6
 
-
 
7
import in.shop2020.model.v1.user.UserContextException;
-
 
8
import in.shop2020.model.v1.user.UserContextService;
6
import in.shop2020.serving.controllers.BaseController;
9
import in.shop2020.serving.controllers.BaseController;
7
import in.shop2020.thrift.clients.HelperServiceClient;
10
import in.shop2020.thrift.clients.HelperServiceClient;
-
 
11
import in.shop2020.thrift.clients.UserContextServiceClient;
8
import in.shop2020.utils.Mail;
12
import in.shop2020.serving.utils.UserMessage;
9
 
13
 
10
import org.apache.log4j.Logger;
14
import org.apache.log4j.Logger;
11
import org.apache.struts2.rest.DefaultHttpHeaders;
15
import org.apache.struts2.rest.DefaultHttpHeaders;
12
import org.apache.struts2.rest.HttpHeaders;
16
import org.apache.struts2.rest.HttpHeaders;
13
 
17
 
14
public class ContactUsController extends BaseController{
18
public class ContactUsController extends BaseController{
15
	
19
	
16
	private static final long serialVersionUID = 1L;
20
	private static final long serialVersionUID = 1L;
17
	private static Logger log = Logger.getLogger(Class.class);
21
	private static Logger log = Logger.getLogger(Class.class);
18
	private static String customerCareMailId = "help@saholic.com";
22
/*	private static String customerCareMailId = "help@saholic.com";
19
	private String userMailId;
23
	private String userMailId;
20
	/*	
24
		
21
	static {
25
	static {
22
		try {
26
		try {
23
			customerCareMailId = ConfigClient.getClient().get("saholic_customer_care_mail");
27
			customerCareMailId = ConfigClient.getClient().get("saholic_customer_care_mail");
24
		} catch (ConfigException e) {
28
		} catch (ConfigException e) {
25
			customerCareMailId = "help@saholic.com";
29
			customerCareMailId = "help@saholic.com";
26
			e.printStackTrace();
30
			e.printStackTrace();
27
		}
31
		}
28
	}
32
	}
29
	*/
33
	*/
30
		public ContactUsController(){
34
	public ContactUsController(){
31
			super();	
35
		super();	
-
 
36
	}
-
 
37
		
-
 
38
	// GET /Show Form
-
 
39
	public HttpHeaders index() {
-
 
40
		return new DefaultHttpHeaders("index").disableCaching();
-
 
41
	}
-
 
42
 
-
 
43
	// POST /Save Communication
-
 
44
	public String create() {
-
 
45
		long communicationType = -1;
-
 
46
		long orderId = -1;
-
 
47
 
-
 
48
		try	{
-
 
49
			boolean u = userinfo.isLoggedIn();
-
 
50
			long userId = u ? userinfo.getUserId() : 0;
-
 
51
			String email = request.getParameter("email");
-
 
52
			communicationType = Integer.parseInt(request.getParameter("communication_type"));
-
 
53
			orderId = Integer.parseInt(request.getParameter("order_id"));
-
 
54
			String awb = request.getParameter("awb");
-
 
55
			String product = request.getParameter("product");
-
 
56
			String subject = request.getParameter("subject");
-
 
57
			String message = request.getParameter("message");
-
 
58
 
-
 
59
			UserContextService.Client userClient = (new UserContextServiceClient()).getClient();
-
 
60
 
-
 
61
 			if(userClient.saveUserCommunication(userId, email, communicationType, orderId, awb, product, subject, message))	{
-
 
62
				System.out.println("User Communication saved successfully!");
-
 
63
			}
-
 
64
		
-
 
65
		} catch(NumberFormatException e)	{
-
 
66
			e.printStackTrace();
-
 
67
		} catch (UserContextException e) {
-
 
68
			e.printStackTrace();
-
 
69
		} catch (Exception e) {
-
 
70
			e.printStackTrace();
-
 
71
		} finally	{
-
 
72
		
32
		}
73
		}
33
		
74
		
34
		 // GET /Send Mail
-
 
35
		 public HttpHeaders index() {		
-
 
36
			
-
 
37
	    	return new DefaultHttpHeaders("index").disableCaching();
-
 
38
		 }
-
 
39
 
-
 
40
		// POST /Send Mail
-
 
41
		public String create() {
-
 
42
	    	log.info("ContactUsController.create");
-
 
43
	    	Mail mail = new Mail();
75
/*	    	Mail mail = new Mail();
44
	    	List<String> mailTo = new ArrayList<String>();
76
	    	List<String> mailTo = new ArrayList<String>();
45
	    	
77
	    	
46
	    	this.userMailId = request.getParameter("mailFrom");
78
	    	this.userMailId = request.getParameter("mailFrom");
47
	    	String mailSubject = request.getParameter("mailSubject");
79
	    	String mailSubject = request.getParameter("mailSubject");
48
	    	String mailBody = request.getParameter("mailBody");
80
	    	String mailBody = request.getParameter("mailBody");
Line 58... Line 90...
58
				helperServiceClient = new HelperServiceClient();
90
				helperServiceClient = new HelperServiceClient();
59
				helperServiceClient.getClient().sendMail(mail);
91
				helperServiceClient.getClient().sendMail(mail);
60
			} catch (Exception e) {
92
			} catch (Exception e) {
61
				log.error("Helper service not working properly. Error while sending mail to user.");
93
				log.error("Helper service not working properly. Error while sending mail to user.");
62
				e.printStackTrace();
94
				e.printStackTrace();
63
			}
95
			}*/
64
	    	
96
	    	
65
	    	return "success";
97
	    	return "success";
66
	    }
98
	    }
67
 
99
 
68
		public String getCustomerCareMailId() {
-
 
69
			return customerCareMailId;
-
 
70
		}
-
 
71
 
-
 
72
		public String getUserMailId() {
100
		public String getSuccessMsg() {
73
			return userMailId;
101
			return UserMessage.USER_COMMUNICATION_SUCCESS;
74
		}
102
		}
75
 
-
 
76
}
103
}
77
104