| Line 3... |
Line 3... |
| 3 |
*/
|
3 |
*/
|
| 4 |
package in.shop2020.serving.controllers;
|
4 |
package in.shop2020.serving.controllers;
|
| 5 |
|
5 |
|
| 6 |
|
6 |
|
| 7 |
import in.shop2020.datalogger.EventType;
|
7 |
import in.shop2020.datalogger.EventType;
|
| - |
|
8 |
import in.shop2020.model.v1.user.Cart;
|
| 8 |
import in.shop2020.model.v1.user.Sex;
|
9 |
import in.shop2020.model.v1.user.Sex;
|
| 9 |
import in.shop2020.model.v1.user.TrackLogType;
|
10 |
import in.shop2020.model.v1.user.TrackLogType;
|
| 10 |
import in.shop2020.model.v1.user.User;
|
11 |
import in.shop2020.model.v1.user.User;
|
| 11 |
import in.shop2020.serving.interceptors.TrackingInterceptor;
|
12 |
import in.shop2020.serving.interceptors.TrackingInterceptor;
|
| 12 |
import in.shop2020.serving.utils.DesEncrypter;
|
13 |
import in.shop2020.serving.utils.DesEncrypter;
|
| Line 63... |
Line 64... |
| 63 |
else
|
64 |
else
|
| 64 |
return "failure";
|
65 |
return "failure";
|
| 65 |
}
|
66 |
}
|
| 66 |
|
67 |
|
| 67 |
public boolean registerUser() throws Exception{
|
68 |
public boolean registerUser() throws Exception{
|
| 68 |
String email, password, userName, mobileNumber, communicationEmail, sex, dateOfBirth;
|
69 |
String email, password, userName;
|
| 69 |
boolean isValid = true;
|
70 |
boolean isValid = true;
|
| 70 |
userName = this.request.getParameter("nameOfUser");
|
71 |
userName = this.request.getParameter("nameOfUser");
|
| 71 |
email = this.request.getParameter("email");
|
72 |
email = this.request.getParameter("email");
|
| 72 |
password = this.request.getParameter("txtPassword");
|
73 |
password = this.request.getParameter("txtPassword");
|
| 73 |
|
74 |
|
| 74 |
mobileNumber = this.request.getParameter("mobileNumber");
|
- |
|
| 75 |
communicationEmail = this.request.getParameter("communicationEmail");
|
- |
|
| 76 |
|
- |
|
| 77 |
dateOfBirth = this.request.getParameter("dateOfBirth");
|
- |
|
| 78 |
sex = this.request.getParameter("sex");
|
- |
|
| 79 |
|
- |
|
| 80 |
if(userName == null ){
|
75 |
if(userName == null ){
|
| 81 |
addActionError("Please enter name of user.");
|
76 |
addActionError("Please enter name of user.");
|
| 82 |
isValid = false;
|
77 |
isValid = false;
|
| 83 |
}
|
78 |
}
|
| 84 |
if(email == null ){
|
79 |
if(email == null ){
|
| Line 87... |
Line 82... |
| 87 |
}
|
82 |
}
|
| 88 |
if(password == null ){
|
83 |
if(password == null ){
|
| 89 |
addActionError("Please enter password.");
|
84 |
addActionError("Please enter password.");
|
| 90 |
isValid = false;
|
85 |
isValid = false;
|
| 91 |
}
|
86 |
}
|
| 92 |
if(communicationEmail == null ){
|
- |
|
| 93 |
addActionError("Please enter Communication email.");
|
- |
|
| 94 |
isValid = false;
|
- |
|
| 95 |
}
|
- |
|
| 96 |
|
87 |
|
| 97 |
if(!isValid){
|
88 |
if(!isValid){
|
| 98 |
DataLogger.logData(EventType.REGISTER_DATA_INCOMPLETE, getSessionId(), userinfo.getUserId(), email, userName, communicationEmail);
|
89 |
DataLogger.logData(EventType.REGISTER_DATA_INCOMPLETE, getSessionId(), userinfo.getUserId(), email, userName, email);
|
| 99 |
return isValid;
|
90 |
return isValid;
|
| 100 |
}
|
91 |
}
|
| 101 |
|
92 |
|
| 102 |
UserClient userContextServiceClient = new UserClient();
|
93 |
UserClient userContextServiceClient = new UserClient();
|
| 103 |
in.shop2020.model.v1.user.UserContextService.Client userClient = userContextServiceClient.getClient();
|
94 |
in.shop2020.model.v1.user.UserContextService.Client userClient = userContextServiceClient.getClient();
|
| 104 |
|
95 |
|
| 105 |
if(userClient.userExists(email)){
|
96 |
if(userClient.userExists(email)){
|
| 106 |
addActionError("User already exists with this email id.");
|
97 |
addActionError("User already exists with this email id.");
|
| 107 |
DataLogger.logData(EventType.REGISTER_FAILED_USER_EXISTS, getSessionId(), userinfo.getUserId(), email, userName, communicationEmail);
|
98 |
DataLogger.logData(EventType.REGISTER_FAILED_USER_EXISTS, getSessionId(), userinfo.getUserId(), email, userName, email);
|
| 108 |
return false;
|
99 |
return false;
|
| 109 |
}
|
100 |
}
|
| 110 |
|
101 |
|
| 111 |
User user = new User();
|
102 |
User user = new User();
|
| 112 |
user.setName(userName);
|
103 |
user.setName(userName);
|
| 113 |
user.setEmail(email);
|
104 |
user.setEmail(email);
|
| 114 |
String encryptedPassword = desEncrypter.encrypt(password);
|
105 |
String encryptedPassword = desEncrypter.encrypt(password);
|
| 115 |
user.setPassword(encryptedPassword);
|
106 |
user.setPassword(encryptedPassword);
|
| 116 |
user.setCommunicationEmail(communicationEmail);
|
107 |
user.setCommunicationEmail(email);
|
| 117 |
user.setMobileNumber(mobileNumber);
|
- |
|
| 118 |
user.setDateOfBirth(dateOfBirth);
|
- |
|
| 119 |
Cookie sourceCookie = (Cookie) cookiesMap.get(TrackingInterceptor.SRC_COOKIE);
|
108 |
Cookie sourceCookie = (Cookie) cookiesMap.get(TrackingInterceptor.SRC_COOKIE);
|
| 120 |
if (sourceCookie != null) {
|
109 |
if (sourceCookie != null) {
|
| 121 |
DesEncrypter des = new DesEncrypter(TrackingInterceptor.ENCRIPTION_STRING);
|
110 |
DesEncrypter des = new DesEncrypter(TrackingInterceptor.ENCRIPTION_STRING);
|
| 122 |
String sourceCookieVal = des.decrypt(sourceCookie.getValue());
|
111 |
String sourceCookieVal = des.decrypt(sourceCookie.getValue());
|
| 123 |
user.setSource(sourceCookieVal);
|
112 |
user.setSource(sourceCookieVal);
|
| Line 134... |
Line 123... |
| 134 |
}
|
123 |
}
|
| 135 |
user.setSourceStartTime(sourceTime);
|
124 |
user.setSourceStartTime(sourceTime);
|
| 136 |
}
|
125 |
}
|
| 137 |
|
126 |
|
| 138 |
user.setSex(Sex.WONT_SAY);
|
127 |
user.setSex(Sex.WONT_SAY);
|
| 139 |
if (sex != null) {
|
- |
|
| 140 |
try {
|
- |
|
| 141 |
user.setSex(Sex.findByValue(Integer.parseInt(sex)));
|
- |
|
| 142 |
} catch (NumberFormatException nfe) {
|
- |
|
| 143 |
log.error("Unusual value for sex. Leaving it marked as won't say.");
|
- |
|
| 144 |
}
|
- |
|
| 145 |
}
|
128 |
|
| 146 |
|
- |
|
| 147 |
|
129 |
|
| 148 |
user = userClient.createUser(user);
|
130 |
user = userClient.createUser(user);
|
| 149 |
long userId = user.getUserId();
|
131 |
long userId = user.getUserId();
|
| 150 |
userClient.setUserAsLoggedIn(userId, (new Date()).getTime());
|
132 |
userClient.setUserAsLoggedIn(userId, (new Date()).getTime());
|
| 151 |
String pincode = userClient.getDefaultPincode(user.getUserId());
|
133 |
String pincode = userClient.getDefaultPincode(user.getUserId());
|
| Line 177... |
Line 159... |
| 177 |
userinfo.setNameOfUser(userName);
|
159 |
userinfo.setNameOfUser(userName);
|
| 178 |
userinfo.setEmail(email);
|
160 |
userinfo.setEmail(email);
|
| 179 |
userinfo.setLoggedIn(true);
|
161 |
userinfo.setLoggedIn(true);
|
| 180 |
userinfo.setPincode(pincode);
|
162 |
userinfo.setPincode(pincode);
|
| 181 |
userinfo.setCartId(user.getActiveCartId());
|
163 |
userinfo.setCartId(user.getActiveCartId());
|
| 182 |
int totalItems = userClient.getCart(userinfo.getCartId()).getLinesSize();
|
164 |
Cart cart = userClient.getCart(userinfo.getCartId());
|
| 183 |
userinfo.setTotalItems(totalItems);
|
165 |
userinfo.setTotalItems(cart.getLinesSize());
|
| - |
|
166 |
userinfo.setTotalAmount(cart.getTotalPrice());
|
| - |
|
167 |
|
| 184 |
if (cookiesMap.containsKey(TrackingInterceptor.AFF_COOKIE)) {
|
168 |
if (cookiesMap.containsKey(TrackingInterceptor.AFF_COOKIE)) {
|
| 185 |
long affId = Long.parseLong(cookiesMap.get(TrackingInterceptor.AFF_COOKIE).getValue());
|
169 |
long affId = Long.parseLong(cookiesMap.get(TrackingInterceptor.AFF_COOKIE).getValue());
|
| 186 |
userClient.addTrackLog(affId, userId, TrackLogType.NEW_REGISTRATION, "",email, (new Date()).getTime());
|
170 |
userClient.addTrackLog(affId, userId, TrackLogType.NEW_REGISTRATION, "",email, (new Date()).getTime());
|
| 187 |
}
|
171 |
}
|
| 188 |
DataLogger.logData(EventType.REGISTER_SUCCESS, getSessionId(), userinfo.getUserId(), email, userName, communicationEmail);
|
172 |
DataLogger.logData(EventType.REGISTER_SUCCESS, getSessionId(), userinfo.getUserId(), email, userName, email);
|
| 189 |
|
173 |
|
| 190 |
return true;
|
174 |
return true;
|
| 191 |
}
|
175 |
}
|
| 192 |
|
176 |
|
| 193 |
public String getRegistrationHeaderSnippet(){
|
177 |
public String getRegistrationHeaderSnippet(){
|