Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
507 rajveer 1
/**
2
 * 
3
 */
4
package in.shop2020.serving.controllers;
5
 
6
import in.shop2020.model.v1.user.Address;
7
import in.shop2020.model.v1.user.AddressType;
555 chandransh 8
import in.shop2020.model.v1.user.User;
507 rajveer 9
import in.shop2020.model.v1.user.UserState;
10
import in.shop2020.serving.pages.PageContentKeys;
11
import in.shop2020.serving.pages.PageEnum;
12
import in.shop2020.serving.pages.PageManager;
13
import in.shop2020.serving.utils.Utils;
14
import in.shop2020.thrift.clients.UserContextServiceClient;
15
 
16
import java.io.UnsupportedEncodingException;
17
import java.util.Date;
18
import java.util.HashMap;
19
import java.util.Map;
20
 
21
import org.apache.juli.logging.Log;
22
import org.apache.juli.logging.LogFactory;
23
import org.apache.struts2.convention.annotation.Result;
24
import org.apache.struts2.convention.annotation.Results;
25
import org.apache.struts2.interceptor.ParameterAware;
26
import org.apache.struts2.rest.DefaultHttpHeaders;
27
import org.apache.struts2.rest.HttpHeaders;
28
 
29
/**
30
 * @author rajveer
31
 *
32
 */
33
 
517 rajveer 34
public class LoginDetailsController extends BaseController 
507 rajveer 35
	implements ParameterAware {
36
 
37
 
38
	/**
39
	 * 
40
	 */
517 rajveer 41
	private static Log log = LogFactory.getLog(LoginDetailsController.class);
507 rajveer 42
 
43
	private Map<String,String> htmlSnippets;
44
	/**
45
	 * 
46
	 */
47
 
48
 
49
	private Map<String, String[]> reqparams;
50
 
51
	private String id;
52
 
53
	private int action;
54
 
55
 
517 rajveer 56
	public LoginDetailsController() {
507 rajveer 57
		super();
58
	}
59
 
60
    // POST /logindetails
61
    public String create() {
62
    	log.info("LogindetailsController.create");
63
 
64
 
65
		String email = this.request.getParameter("txtLoginID");
66
		String oldPassword = this.request.getParameter("txtOldPassword");
67
		String newPassword = this.request.getParameter("txtNewPassword");
68
 
69
		if(this.userinfo.isLoggedIn()){
70
			if(Utils.ChangePassword(userinfo.getUserId(), email, oldPassword, newPassword))
71
			{
72
				return "success";
73
			}
74
    	}
75
		return "failure";
76
    }
77
 
78
 
79
    // GET /test
80
    public HttpHeaders index() throws UnsupportedEncodingException {
81
    	log.info("this.request=" + this.request);
82
 
83
    	String userId = "";
84
 
85
    	if(this.userinfo.isLoggedIn()){
86
			Map<PageContentKeys, String> params = new HashMap<PageContentKeys, String>();
555 chandransh 87
			params.put(PageContentKeys.CUSTOMER_ID, userinfo.getUserId() + "");
507 rajveer 88
			params.put(PageContentKeys.ITEM_COUNT, userinfo.getTotalItems()+"");
555 chandransh 89
			params.put(PageContentKeys.USER_NAME, userinfo.getNameOfUser());
90
			params.put(PageContentKeys.IS_LOGGED_IN, userinfo.isLoggedIn()+"");
507 rajveer 91
 
92
			htmlSnippets = PageManager.getPageManager().getPageContents(PageEnum.LOGIN_DETAILS_PAGE, params);
93
			return new DefaultHttpHeaders("index").disableCaching();
94
 
95
    	}else{
96
    		return new DefaultHttpHeaders("login").disableCaching();
97
    	}
98
 
99
    }
100
 
101
    public String getHeaderSnippet(){
102
		return htmlSnippets.get("HEADER");
103
	}
104
 
105
	public String getMainMenuSnippet(){
106
		return htmlSnippets.get("MAIN_MENU");
107
	}
108
 
109
	public String getSearchBarSnippet(){
110
		return htmlSnippets.get("SEARCH_BAR");
111
	}
112
 
113
 
114
	public String getCustomerServiceSnippet(){
115
		return htmlSnippets.get("CUSTOMER_SERVICE");
116
	}
117
 
118
	public String getMyaccountHeaderSnippet(){
119
		return htmlSnippets.get("MYACCOUNT_HEADER");
120
	}
121
 
122
	public String getLoginDetailsSnippet(){
123
		return htmlSnippets.get("LOGIN_DETAILS");
124
	}
125
 
126
	public String getMyResearchSnippet(){
127
		return htmlSnippets.get("MY_RESEARCH");
128
	}
129
 
130
	public String getFooterSnippet(){
131
		return htmlSnippets.get("FOOTER");
132
	}
133
 
134
	public String getJsFileSnippet(){
135
		return htmlSnippets.get("JS_FILES");
136
	}
137
 
138
	public String getCssFileSnippet(){
139
		return htmlSnippets.get("CSS_FILES");
140
	}
141
 
142
    /**
143
     * 
144
     * @param id
145
     */
146
    public void setId(String id) {
147
        this.id = id;
148
    }
149
 
150
 
151
    /**
152
     * 
153
     */
154
//    @Override
155
//	public void setServletRequest(HttpServletRequest request) {
156
//		this.request = request;
157
//	}
158
 
159
 
160
	@Override
161
	public void setParameters(Map<String, String[]> reqmap) {
162
		log.info("setParameters:" + reqmap);
163
 
164
		this.reqparams = reqmap;
165
	}
166
 
167
}