Subversion Repositories SmartDukaan

Rev

Rev 4544 | Details | Compare with Previous | 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
 */
4882 rajveer 19
@SuppressWarnings("serial")
4544 varun.gupt 20
public class ShareProducts extends BaseController implements ServletRequestAware, ServletResponseAware {
21
 
22
	public ShareProducts()	{
23
		super();
24
	}
25
 
26
	public String index()	{
27
		return "success";
28
	}
29
 
30
	public String create()	{
31
		String emailAddress = request.getParameter("email");
32
		String[] productIds = request.getParameterValues("e");
33
		List<Long> entityIds = new ArrayList<Long>();
34
 
35
		for (String entityId: productIds)	{
36
 
37
			try	{
38
				entityIds.add(Long.parseLong(entityId));
39
 
40
			} catch (NumberFormatException e) {
41
				// TODO: handle exception
42
			}
43
		}
44
 
45
		HelperClient helperServiceClient;
46
 
47
		try {
48
			helperServiceClient = new HelperClient();
49
			HelperService.Client helperClient = helperServiceClient.getClient();
50
			helperClient.shareEntities(entityIds, emailAddress);
51
 
52
		} catch (TTransportException e) {
53
			e.printStackTrace();
54
 
55
		} catch (HelperServiceException e) {
56
			e.printStackTrace();
57
 
58
		} catch (TException e) {
59
			e.printStackTrace();
60
		}
61
		return "success";
62
	}
63
}