Subversion Repositories SmartDukaan

Rev

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

Rev 1044 Rev 2145
Line 1... Line 1...
1
package in.shop2020.serving.controllers;
1
package in.shop2020.serving.controllers;
2
 
2
 
3
import in.shop2020.model.v1.user.Cart;
-
 
4
import in.shop2020.model.v1.user.ShoppingCartException;
-
 
5
import in.shop2020.model.v1.user.User;
-
 
6
import in.shop2020.model.v1.user.UserContextException;
-
 
7
import in.shop2020.model.v1.user.UserState;
-
 
8
import in.shop2020.model.v1.user.UserContextService.Client;
-
 
9
import in.shop2020.thrift.clients.UserContextServiceClient;
-
 
10
 
-
 
11
import java.util.*;
-
 
12
 
-
 
13
import javax.servlet.http.Cookie;
3
import javax.servlet.http.Cookie;
14
import javax.servlet.http.HttpServletRequest;
-
 
15
import javax.servlet.http.HttpServletResponse;
-
 
16
 
4
 
17
import org.apache.commons.lang.StringUtils;
-
 
18
import org.apache.log4j.Logger;
5
import org.apache.log4j.Logger;
19
import org.apache.struts2.convention.annotation.Action;
6
import org.apache.struts2.convention.annotation.Action;
20
import org.apache.struts2.convention.annotation.Result;
7
import org.apache.struts2.convention.annotation.Result;
21
import org.apache.struts2.convention.annotation.Results;
8
import org.apache.struts2.convention.annotation.Results;
22
import org.apache.struts2.interceptor.ParameterAware;
-
 
23
import org.apache.struts2.interceptor.ServletRequestAware;
-
 
24
import org.apache.struts2.interceptor.ServletResponseAware;
-
 
25
import org.apache.struts2.rest.DefaultHttpHeaders;
9
import org.apache.struts2.rest.DefaultHttpHeaders;
26
import org.apache.struts2.rest.HttpHeaders;
10
import org.apache.struts2.rest.HttpHeaders;
27
import org.apache.thrift.TException;
-
 
28
 
-
 
29
import com.opensymphony.xwork2.ValidationAwareSupport;
-
 
30
 
11
 
31
@Results({
12
@Results({
32
    @Result(name="success", type="redirectAction", 
13
    @Result(name="success", type="redirectAction", 
33
    		params = {"actionName" , "test"})
14
    		params = {"actionName" , "test"})
34
})
15
})
Line 55... Line 36...
55
        
36
        
56
        if(cookies != null){
37
        if(cookies != null){
57
	        for(int loopIndex = 0; loopIndex < cookies.length; loopIndex++) { 
38
	        for(int loopIndex = 0; loopIndex < cookies.length; loopIndex++) { 
58
	            Cookie cookie1 = cookies[loopIndex];
39
	            Cookie cookie1 = cookies[loopIndex];
59
	            if (cookie1.getName().equals("sessionId")) {
40
	            if (cookie1.getName().equals("sessionId")) {
60
	                System.out.println("Session Id is = " + cookie1.getValue());
-
 
61
	                sessionId = Long.parseLong(cookie1.getValue());
41
	                sessionId = Long.parseLong(cookie1.getValue());
-
 
42
	            	System.out.println("Session Id is = " + sessionId);
62
	                foundCookie = true;
43
	                foundCookie = true;
63
	            }
44
	            }
64
	        }
45
	        }
65
	       }
46
	       }
66
 
47
 
67
        
48
        
68
		UserContextServiceClient userContextServiceClient;
49
//		UserContextServiceClient userContextServiceClient;
69
		Client client;
50
//		Client client;
70
//		UserContext context;
51
//		UserContext context;
71
		try {
52
//		try {
72
			userContextServiceClient = new UserContextServiceClient();
53
//			userContextServiceClient = new UserContextServiceClient();
73
			//client = userContextServiceClient.getClient();
54
//			client = userContextServiceClient.getClient();
74
//TODO: Commented out since it's not super-critical to compile TestController			
55
//TODO: Commented out since it's not super-critical to compile TestController			
75
//			if (!foundCookie) {
56
//			if (!foundCookie) {
76
//	        	// create new session and set the cookies
57
//	        	// create new session and set the cookies
77
//	        	context = new UserContext();
58
//	        	context = new UserContext();
78
//	        	context = client.createContext(context, false);
59
//	        	context = client.createContext(context, false);
Line 90... Line 71...
90
//	        	if(context.getUserState().isIsLoggedIn()){
71
//	        	if(context.getUserState().isIsLoggedIn()){
91
//	        		System.out.println("User is logged in with user Id  " + context.getId());	
72
//	        		System.out.println("User is logged in with user Id  " + context.getId());	
92
//	        	}
73
//	        	}
93
//	        	
74
//	        	
94
//	        }
75
//	        }
95
	        
76
//	        
96
			
77
//			
97
		} catch (Exception e1) {
78
//		} catch (Exception e1) {
98
			// TODO Auto-generated catch block
79
//			// TODO Auto-generated catch block
99
			e1.printStackTrace();
80
//			e1.printStackTrace();
100
		}
81
//		}
101
		
82
		
102
 
83
 
103
        	
84
        	
104
        
85
        
105
        
86