| 1614 |
rajveer |
1 |
package in.shop2020.serving.interceptors;
|
|
|
2 |
import in.shop2020.serving.services.UserSessionInfo;
|
|
|
3 |
|
|
|
4 |
import javax.servlet.http.HttpServletRequest;
|
|
|
5 |
import javax.servlet.http.HttpSession;
|
|
|
6 |
|
|
|
7 |
import org.apache.log4j.Logger;
|
|
|
8 |
import org.apache.struts2.ServletActionContext;
|
|
|
9 |
|
|
|
10 |
import com.opensymphony.xwork2.ActionInvocation;
|
|
|
11 |
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
|
|
|
12 |
|
|
|
13 |
public class CreateUserInterceptor extends AbstractInterceptor {
|
|
|
14 |
|
|
|
15 |
|
|
|
16 |
private static final long serialVersionUID = -4125815700236506235L;
|
|
|
17 |
private static Logger log = Logger.getLogger(CreateUserInterceptor.class);
|
|
|
18 |
|
|
|
19 |
|
|
|
20 |
|
|
|
21 |
@Override
|
|
|
22 |
public String intercept(ActionInvocation invocation) throws Exception {
|
|
|
23 |
log.info("inside create user interceprot");
|
|
|
24 |
HttpServletRequest request = ServletActionContext.getRequest();
|
|
|
25 |
HttpSession session = request.getSession(); // Get the existing session or create a new one
|
|
|
26 |
|
|
|
27 |
UserSessionInfo userInfo = (UserSessionInfo) session.getAttribute(UserInterceptor.USER_INFO);
|
|
|
28 |
if(userInfo.getUserId() == -1){
|
|
|
29 |
userInfo = new UserSessionInfo(session.getId());
|
|
|
30 |
session.setAttribute(UserInterceptor.USER_INFO, userInfo);
|
|
|
31 |
}
|
|
|
32 |
return invocation.invoke();
|
|
|
33 |
}
|
|
|
34 |
|
|
|
35 |
|
|
|
36 |
}
|