Subversion Repositories SmartDukaan

Rev

Rev 413 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 413 Rev 419
Line 49... Line 49...
49
    @Result(name="success", type="redirectAction", 
49
    @Result(name="success", type="redirectAction", 
50
    		params = {"actionName" , "myaccount"})
50
    		params = {"actionName" , "myaccount"})
51
})
51
})
52
 
52
 
53
public class MyaccountController extends BaseController 
53
public class MyaccountController extends BaseController 
54
	implements ServletRequestAware, ParameterAware {
54
	implements ParameterAware {
55
 
55
 
56
	
56
	
57
	/**
57
	/**
58
	 * 
58
	 * 
59
	 */
59
	 */
Line 61... Line 61...
61
	
61
	
62
	private Map<String,String> htmlSnippets;
62
	private Map<String,String> htmlSnippets;
63
	/**
63
	/**
64
	 * 
64
	 * 
65
	 */
65
	 */
66
	private HttpServletRequest request;
-
 
-
 
66
	
67
	
67
	
68
	private Map<String, String[]> reqparams;
68
	private Map<String, String[]> reqparams;
69
	
69
	
70
	private String id;
70
	private String id;
71
	
71
	
Line 90... Line 90...
90
    	
90
    	
91
    	action = Integer.parseInt(this.reqparams.get("action")[0]);
91
    	action = Integer.parseInt(this.reqparams.get("action")[0]);
92
    	
92
    	
93
    	
93
    	
94
    	try {
94
    	try {
95
			if(addUpdateuserDetails(action)){   	
95
			if(addUpdateUserDetails(action)){   	
96
				return "success";
96
				return "success";
97
			}else{
97
			}else{
98
				return "failure";
98
				return "failure";
99
			}
99
			}
100
		} catch (Exception e) {
100
		} catch (Exception e) {
Line 105... Line 105...
105
    }
105
    }
106
 
106
 
107
    
107
    
108
    // GET /test
108
    // GET /test
109
    public HttpHeaders index() throws UnsupportedEncodingException {
109
    public HttpHeaders index() throws UnsupportedEncodingException {
110
    	log.info("this.request=" + this.request);
110
    	//log.info("this.request=" + this.request);
-
 
111
    	
-
 
112
    	
-
 
113
    	String userId = "";
-
 
114
    	
-
 
115
    	//if(this.session.getAttribute("loggedin").toString().equals("true")){
-
 
116
		//	userId = this.session.getAttribute("userid").toString();
-
 
117
    
-
 
118
    	if(this.userinfo.isLoggedIn()){
-
 
119
    		userId = (new Long(this.userinfo.getUserId())).toString();
111
	
120
 
-
 
121
			Map<PageContentKeys, String> params = new HashMap<PageContentKeys, String>();
-
 
122
			params.put(PageContentKeys.CUSTOMER_ID, userId);
-
 
123
			htmlSnippets = PageManager.getPageManager().getPageContents(PageEnum.MY_ACCOUNT_PAGE, params);
-
 
124
			
112
        return new DefaultHttpHeaders("index")
125
			return new DefaultHttpHeaders("index").disableCaching();
-
 
126
    	
-
 
127
    	}else{
113
            .disableCaching();
128
    		return new DefaultHttpHeaders("login").disableCaching();
-
 
129
    	}
-
 
130
    	
114
    }
131
    }
115
    
132
    
116
    public HttpHeaders show(){
133
    public HttpHeaders show(){
117
    	log.info("this.id=" + this.id);
134
    	log.info("this.id=" + this.id);
118
 
135
 
119
		Map<PageContentKeys, String> params = new HashMap<PageContentKeys, String>();
136
		Map<PageContentKeys, String> params = new HashMap<PageContentKeys, String>();
120
		params.put(PageContentKeys.CUSTOMER_ID, id);
137
		params.put(PageContentKeys.CUSTOMER_ID, id);
121
		htmlSnippets = PageManager.getPageManager().getPageContents(PageEnum.MY_ACCOUNT_PAGE, params);
138
		htmlSnippets = PageManager.getPageManager().getPageContents(PageEnum.MY_ACCOUNT_PAGE, params);
122
		
139
		
123
    	
140
    	
124
        return new DefaultHttpHeaders("index")
141
        return new DefaultHttpHeaders("index").disableCaching();
125
        .disableCaching();
-
 
126
    }
142
    }
127
    
143
    
128
    /**
144
    /**
129
     * 
145
     * 
130
     * @param id
146
     * @param id
131
     */
147
     */
132
    public void setId(String id) {
148
    public void setId(String id) {
133
        this.id = id;
149
        this.id = id;
134
    }
150
    }
135
 
151
 
-
 
152
    public boolean logoutUser(int userId) throws Exception{
-
 
153
		UserContextServiceClient userContextServiceClient = null;
-
 
154
		in.shop2020.model.v1.user.UserContextService.Client userClient = null;
-
 
155
 
-
 
156
		userContextServiceClient = new UserContextServiceClient();
-
 
157
		userClient = userContextServiceClient.getClient();
-
 
158
		
-
 
159
		userClient.setUserAsLoggedOut(userId, (new Date()).getTime());
-
 
160
		
-
 
161
    	return true;
-
 
162
    }
-
 
163
    
136
    public boolean addUpdateuserDetails(int action) throws Exception{
164
    public boolean addUpdateUserDetails(int action) throws Exception{
137
    	
165
    	
138
		UserContextServiceClient userContextServiceClient = null;
166
		UserContextServiceClient userContextServiceClient = null;
139
		in.shop2020.model.v1.user.UserContextService.Client userClient = null;
167
		in.shop2020.model.v1.user.UserContextService.Client userClient = null;
140
 
168
 
141
		userContextServiceClient = new UserContextServiceClient();
169
		userContextServiceClient = new UserContextServiceClient();
Line 163... Line 191...
163
//				context.getPrimaryInfo().setPassword(email);
191
//				context.getPrimaryInfo().setPassword(email);
164
//				context.getPrimaryInfo().setPassword(password);
192
//				context.getPrimaryInfo().setPassword(password);
165
//				context.getUserState().setIsLoggedIn(true);
193
//				context.getUserState().setIsLoggedIn(true);
166
				
194
				
167
				context = userClient.createContext(context, false);
195
				context = userClient.createContext(context, false);
-
 
196
				
-
 
197
				long userId = context.getId();
-
 
198
				
-
 
199
				userClient.setUserAsLoggedIn(userId, (new Date()).getTime());
-
 
200
				this.session.removeAttribute("useid");
-
 
201
				this.session.removeAttribute("loggedin");
-
 
202
				this.session.removeAttribute("issessionid");
-
 
203
				this.session.removeAttribute("email");
-
 
204
				
-
 
205
				this.session.setAttribute("userid", userId+"");
-
 
206
				this.session.setAttribute("loggedin", "true");
-
 
207
				this.session.setAttribute("issessionid", "false");
-
 
208
				this.session.setAttribute("email",email);
-
 
209
				
-
 
210
				
168
				return true;
211
				return true;
169
			}
212
			}
170
 
213
 
171
			//add address
214
			//add address
172
		case 2:
215
		case 2:
Line 210... Line 253...
210
 
253
 
211
    
254
    
212
    /**
255
    /**
213
     * 
256
     * 
214
     */
257
     */
215
    @Override
258
//    @Override
216
	public void setServletRequest(HttpServletRequest request) {
259
//	public void setServletRequest(HttpServletRequest request) {
217
		this.request = request;
260
//		this.request = request;
218
	}
261
//	}
219
 
262
 
220
    
263
    
221
	@Override
264
	@Override
222
	public void setParameters(Map<String, String[]> reqmap) {
265
	public void setParameters(Map<String, String[]> reqmap) {
223
		log.info("setParameters:" + reqmap);
266
		log.info("setParameters:" + reqmap);