Subversion Repositories SmartDukaan

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4544 varun.gupt 1
package in.shop2020.serving.controllers;
2
 
3
import java.util.List;
4
import java.util.ArrayList;
5
 
6
import org.apache.struts2.interceptor.ServletRequestAware;
7
import org.apache.struts2.interceptor.ServletResponseAware;
8
import org.apache.thrift.TException;
9
import org.apache.thrift.transport.TTransportException;
10
 
11
import in.shop2020.thrift.clients.HelperClient;
12
import in.shop2020.utils.HelperService;
13
import in.shop2020.utils.HelperServiceException;
14
 
15
/**
16
 * @author Varun Gupta
17
 *
18
 */
19
public class ShareProducts extends BaseController implements ServletRequestAware, ServletResponseAware {
20
 
21
	public ShareProducts()	{
22
		super();
23
	}
24
 
25
	public String index()	{
26
		return "success";
27
	}
28
 
29
	public String create()	{
30
		String emailAddress = request.getParameter("email");
31
		String[] productIds = request.getParameterValues("e");
32
		List<Long> entityIds = new ArrayList<Long>();
33
 
34
		for (String entityId: productIds)	{
35
 
36
			try	{
37
				entityIds.add(Long.parseLong(entityId));
38
 
39
			} catch (NumberFormatException e) {
40
				// TODO: handle exception
41
			}
42
		}
43
 
44
		HelperClient helperServiceClient;
45
 
46
		try {
47
			helperServiceClient = new HelperClient();
48
			HelperService.Client helperClient = helperServiceClient.getClient();
49
			helperClient.shareEntities(entityIds, emailAddress);
50
 
51
		} catch (TTransportException e) {
52
			e.printStackTrace();
53
 
54
		} catch (HelperServiceException e) {
55
			e.printStackTrace();
56
 
57
		} catch (TException e) {
58
			e.printStackTrace();
59
		}
60
		return "success";
61
	}
62
}