Subversion Repositories SmartDukaan

Rev

Rev 6912 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
458 rajveer 1
package in.shop2020.serving.controllers;
2
 
2263 vikas 3
import in.shop2020.datalogger.EventType;
2911 rajveer 4
import in.shop2020.serving.services.UserSessionInfo;
3126 rajveer 5
import in.shop2020.thrift.clients.UserClient;
2511 vikas 6
import in.shop2020.utils.DataLogger;
458 rajveer 7
 
8
import java.util.Date;
2419 vikas 9
 
6912 anupam.sin 10
import org.apache.log4j.Logger;
458 rajveer 11
import org.apache.struts2.convention.annotation.Result;
12
import org.apache.struts2.convention.annotation.Results;
13
 
14
/**
15
 * @author rajveer
16
 *
17
 */
18
@Results({
19
    @Result(name="success", type="redirectAction", 
823 vikas 20
    		params = {"actionName" , "home"})
458 rajveer 21
})
22
 
23
public class LogoutController extends BaseController {
24
 
25
 
26
	/**
27
	 * 
28
	 */
6912 anupam.sin 29
    private static Logger log = Logger.getLogger(Class.class);
650 rajveer 30
	private static final long serialVersionUID = 1L;
31
	/**
32
	 * 
33
	 */
458 rajveer 34
 
35
	public LogoutController() {
36
		super();
37
 
38
	}
39
 
40
    // GET /logout
41
    public String index() throws Exception {
42
		if(this.userinfo.isLoggedIn()){
43
			logoutUser(this.userinfo.getUserId());
2911 rajveer 44
			//Clean the old userinfo
45
			userinfo = new UserSessionInfo();
2907 rajveer 46
			clearUserCookies();
6912 anupam.sin 47
		}
48
		try {
12616 anikendra 49
//		    DataLogger.logData(EventType.LOGOUT, getSessionId(), userinfo.getUserId(), userinfo.getEmail());
6912 anupam.sin 50
		} catch(Exception e) {
51
		    log.error("Unable to logDate on AppEngine", e);
52
		}
458 rajveer 53
		return "success";
54
 
55
    }
56
 
57
 
58
    public boolean logoutUser(long userId) throws Exception{
3126 rajveer 59
		UserClient userContextServiceClient =new UserClient();
555 chandransh 60
		in.shop2020.model.v1.user.UserContextService.Client userClient = userContextServiceClient.getClient();
458 rajveer 61
 
62
		userClient.setUserAsLoggedOut(userId, (new Date()).getTime());
63
    	return true;
64
    }
65
 
66
}