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;
8
import in.shop2020.model.v1.user.UserContext;
9
import in.shop2020.model.v1.user.UserPrimaryInfo;
10
import in.shop2020.model.v1.user.UserState;
11
import in.shop2020.serving.pages.PageContentKeys;
12
import in.shop2020.serving.pages.PageEnum;
13
import in.shop2020.serving.pages.PageManager;
14
import in.shop2020.serving.utils.Utils;
15
import in.shop2020.thrift.clients.UserContextServiceClient;
16
 
17
import java.io.UnsupportedEncodingException;
18
import java.util.Date;
19
import java.util.HashMap;
20
import java.util.Map;
21
 
22
import org.apache.juli.logging.Log;
23
import org.apache.juli.logging.LogFactory;
24
import org.apache.struts2.convention.annotation.Result;
25
import org.apache.struts2.convention.annotation.Results;
26
import org.apache.struts2.interceptor.ParameterAware;
27
import org.apache.struts2.rest.DefaultHttpHeaders;
28
import org.apache.struts2.rest.HttpHeaders;
29
 
30
/**
31
 * @author rajveer
32
 *
33
 */
34
 
517 rajveer 35
public class LoginDetailsController extends BaseController 
507 rajveer 36
	implements ParameterAware {
37
 
38
 
39
	/**
40
	 * 
41
	 */
517 rajveer 42
	private static Log log = LogFactory.getLog(LoginDetailsController.class);
507 rajveer 43
 
44
	private Map<String,String> htmlSnippets;
45
	/**
46
	 * 
47
	 */
48
 
49
 
50
	private Map<String, String[]> reqparams;
51
 
52
	private String id;
53
 
54
	private int action;
55
 
56
 
517 rajveer 57
	public LoginDetailsController() {
507 rajveer 58
		super();
59
	}
60
 
61
    // POST /logindetails
62
    public String create() {
63
    	log.info("LogindetailsController.create");
64
 
65
 
66
		String email = this.request.getParameter("txtLoginID");
67
		String oldPassword = this.request.getParameter("txtOldPassword");
68
		String newPassword = this.request.getParameter("txtNewPassword");
69
 
70
		if(this.userinfo.isLoggedIn()){
71
			if(Utils.ChangePassword(userinfo.getUserId(), email, oldPassword, newPassword))
72
			{
73
				return "success";
74
			}
75
    	}
76
		return "failure";
77
    }
78
 
79
 
80
    // GET /test
81
    public HttpHeaders index() throws UnsupportedEncodingException {
82
    	log.info("this.request=" + this.request);
83
 
84
    	String userId = "";
85
 
86
    	if(this.userinfo.isLoggedIn()){
87
    		userId = (new Long(this.userinfo.getUserId())).toString();
88
			Map<PageContentKeys, String> params = new HashMap<PageContentKeys, String>();
89
			params.put(PageContentKeys.CUSTOMER_ID, userId);
90
			params.put(PageContentKeys.ITEM_COUNT, userinfo.getTotalItems()+"");
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
}