Subversion Repositories SmartDukaan

Rev

Rev 21432 | Rev 21448 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 21432 Rev 21440
Line 72... Line 72...
72
		final Map<String, Object> googleLoginMap = (Map<String, Object>)request.getAttribute(ProfitMandiConstants.GOOGLE_LOGIN_MAP);
72
		final Map<String, Object> googleLoginMap = (Map<String, Object>)request.getAttribute(ProfitMandiConstants.GOOGLE_LOGIN_MAP);
73
		request.removeAttribute(ProfitMandiConstants.GOOGLE_LOGIN_MAP);
73
		request.removeAttribute(ProfitMandiConstants.GOOGLE_LOGIN_MAP);
74
		try {
74
		try {
75
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, googleLoginProcessor.process(googleLoginMap));
75
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, googleLoginProcessor.process(googleLoginMap));
76
			return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
76
			return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
77
		}catch (ProfitMandiBusinessException pmbe) {
77
		}catch (ProfitMandiBusinessException profitMandiBusinessException) {
78
			LOGGER.error("ProfitMandi error: ", pmbe);
78
			LOGGER.error("ProfitMandi error: ",  profitMandiBusinessException);
79
			final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
79
			final Response response=new Response(profitMandiBusinessException.getRejectedType(), profitMandiBusinessException.getRejectedValue(),profitMandiBusinessException.getCode(), profitMandiBusinessException.getMessage());
80
			final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
80
			final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
81
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.BAD_REQUEST);
81
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.BAD_REQUEST);
82
		}
82
		}
83
	}
83
	}
84
	
84
	
Line 86... Line 86...
86
	public ResponseEntity<?> tokenIsExpired(HttpServletRequest request, @RequestParam(name = "token") String token){
86
	public ResponseEntity<?> tokenIsExpired(HttpServletRequest request, @RequestParam(name = "token") String token){
87
		LOGGER.info("requested url : "+request.getRequestURL().toString());
87
		LOGGER.info("requested url : "+request.getRequestURL().toString());
88
		try {
88
		try {
89
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, JWTUtil.isExpired(token));
89
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, JWTUtil.isExpired(token));
90
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
90
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
91
		}catch (ProfitMandiBusinessException pmbe) {
91
		}catch (ProfitMandiBusinessException profitMandiBusinessException) {
92
			LOGGER.error("ProfitMandi error: ", pmbe);
92
			LOGGER.error("ProfitMandi error: ",  profitMandiBusinessException);
93
			final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
93
			final Response response=new Response(profitMandiBusinessException.getRejectedType(), profitMandiBusinessException.getRejectedValue(),profitMandiBusinessException.getCode(), profitMandiBusinessException.getMessage());
94
			final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
94
			final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
95
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.BAD_REQUEST);
95
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.BAD_REQUEST);
96
		}
96
		}
97
	}
97
	}
98
	
98
	
Line 118... Line 118...
118
			user.setCreateTimestamp(LocalDateTime.now());
118
			user.setCreateTimestamp(LocalDateTime.now());
119
			user.setUpdateTimestamp(LocalDateTime.now());
119
			user.setUpdateTimestamp(LocalDateTime.now());
120
			userRepository.persist(user);
120
			userRepository.persist(user);
121
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("USR_OK_1000"));
121
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("USR_OK_1000"));
122
			return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
122
			return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
123
		}catch (ProfitMandiBusinessException pmbe) {
123
		}catch (ProfitMandiBusinessException profitMandiBusinessException) {
124
			LOGGER.error("ProfitMandi error: ", pmbe);
124
			LOGGER.error("ProfitMandi error: ",  profitMandiBusinessException);
125
			final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
125
			final Response response=new Response(profitMandiBusinessException.getRejectedType(), profitMandiBusinessException.getRejectedValue(),profitMandiBusinessException.getCode(), profitMandiBusinessException.getMessage());
126
			final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
126
			final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
127
			return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
127
			return new ResponseEntity<>(chatOnResponse,HttpStatus.BAD_REQUEST);
128
		}
128
		}
129
	}
129
	}
130
	
130
	
Line 139... Line 139...
139
	public ResponseEntity<?> getById(HttpServletRequest request, @RequestParam(name = "id") int id){
139
	public ResponseEntity<?> getById(HttpServletRequest request, @RequestParam(name = "id") int id){
140
		LOGGER.info("requested url : "+request.getRequestURL().toString());
140
		LOGGER.info("requested url : "+request.getRequestURL().toString());
141
		try {
141
		try {
142
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, userRepository.selectById(id));
142
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, userRepository.selectById(id));
143
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
143
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
144
		}catch (ProfitMandiBusinessException pmbe) {
144
		}catch (ProfitMandiBusinessException profitMandiBusinessException) {
145
			LOGGER.error("ProfitMandi error: ", pmbe);
145
			LOGGER.error("ProfitMandi error: ",  profitMandiBusinessException);
146
			final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
146
			final Response response=new Response(profitMandiBusinessException.getRejectedType(), profitMandiBusinessException.getRejectedValue(),profitMandiBusinessException.getCode(), profitMandiBusinessException.getMessage());
147
			final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
147
			final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
148
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.BAD_REQUEST);
148
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.BAD_REQUEST);
149
		}
149
		}
150
	}
150
	}
151
	
151
	
Line 153... Line 153...
153
	public ResponseEntity<?> getByMobileNumber(HttpServletRequest request, @RequestParam(name = "mobileNumber") String mobileNumber){
153
	public ResponseEntity<?> getByMobileNumber(HttpServletRequest request, @RequestParam(name = "mobileNumber") String mobileNumber){
154
		LOGGER.info("requested url : "+request.getRequestURL().toString());
154
		LOGGER.info("requested url : "+request.getRequestURL().toString());
155
		try {
155
		try {
156
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, userRepository.selectByMobileNumber(mobileNumber));
156
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, userRepository.selectByMobileNumber(mobileNumber));
157
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
157
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
158
		}catch (ProfitMandiBusinessException pmbe) {
158
		}catch (ProfitMandiBusinessException profitMandiBusinessException) {
159
			LOGGER.error("ProfitMandi error: ", pmbe);
159
			LOGGER.error("ProfitMandi error: ",  profitMandiBusinessException);
160
			final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
160
			final Response response=new Response(profitMandiBusinessException.getRejectedType(), profitMandiBusinessException.getRejectedValue(),profitMandiBusinessException.getCode(), profitMandiBusinessException.getMessage());
161
			final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
161
			final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
162
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.BAD_REQUEST);
162
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.BAD_REQUEST);
163
		}
163
		}
164
	}
164
	}
165
	
165
	
Line 175... Line 175...
175
	public ResponseEntity<?> getByEmailId(HttpServletRequest request, @RequestParam(name = "emailId") String emailId){
175
	public ResponseEntity<?> getByEmailId(HttpServletRequest request, @RequestParam(name = "emailId") String emailId){
176
		LOGGER.info("requested url : "+request.getRequestURL().toString());
176
		LOGGER.info("requested url : "+request.getRequestURL().toString());
177
		try {
177
		try {
178
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, userRepository.selectByEmailId(emailId));
178
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, userRepository.selectByEmailId(emailId));
179
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
179
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
180
		}catch (ProfitMandiBusinessException pmbe) {
180
		}catch (ProfitMandiBusinessException profitMandiBusinessException) {
181
			LOGGER.error("ProfitMandi error: ", pmbe);
181
			LOGGER.error("ProfitMandi error: ",  profitMandiBusinessException);
182
			final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
182
			final Response response=new Response(profitMandiBusinessException.getRejectedType(), profitMandiBusinessException.getRejectedValue(),profitMandiBusinessException.getCode(), profitMandiBusinessException.getMessage());
183
			final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
183
			final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
184
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.BAD_REQUEST);
184
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.BAD_REQUEST);
185
		}
185
		}
186
	}
186
	}
187
	
187
	
Line 209... Line 209...
209
			userRole.setUserId(user.getId());
209
			userRole.setUserId(user.getId());
210
			userRoleRepository.persist(userRole);
210
			userRoleRepository.persist(userRole);
211
			//role.setPermissionType(userAddRoleRequest.getRole().getPermissionType());
211
			//role.setPermissionType(userAddRoleRequest.getRole().getPermissionType());
212
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, "");
212
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, "");
213
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
213
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
214
		}catch (ProfitMandiBusinessException pmbe) {
214
		}catch (ProfitMandiBusinessException profitMandiBusinessException) {
215
			LOGGER.error("ProfitMandi error: ", pmbe);
215
			LOGGER.error("ProfitMandi error: ",  profitMandiBusinessException);
216
			final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
216
			final Response response=new Response(profitMandiBusinessException.getRejectedType(), profitMandiBusinessException.getRejectedValue(),profitMandiBusinessException.getCode(), profitMandiBusinessException.getMessage());
217
			final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
217
			final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
218
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.BAD_REQUEST);
218
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.BAD_REQUEST);
219
		}
219
		}
220
	}
220
	}
221
	
221
	
Line 227... Line 227...
227
			userRepository.selectById(userId);
227
			userRepository.selectById(userId);
228
			userRoleRepository.deleteByUserAndRoleId(userId, roleId);
228
			userRoleRepository.deleteByUserAndRoleId(userId, roleId);
229
			permissionRepository.deleteByRoleId(roleId);
229
			permissionRepository.deleteByRoleId(roleId);
230
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, "");
230
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, "");
231
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
231
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
232
		}catch (ProfitMandiBusinessException pmbe) {
232
		}catch (ProfitMandiBusinessException profitMandiBusinessException) {
233
			LOGGER.error("ProfitMandi error: ", pmbe);
233
			LOGGER.error("ProfitMandi error: ",  profitMandiBusinessException);
234
			final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
234
			final Response response=new Response(profitMandiBusinessException.getRejectedType(), profitMandiBusinessException.getRejectedValue(),profitMandiBusinessException.getCode(), profitMandiBusinessException.getMessage());
235
			final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
235
			final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
236
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.BAD_REQUEST);
236
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.BAD_REQUEST);
237
		}
237
		}
238
	}
238
	}
239
	
239
	
Line 263... Line 263...
263
			for(Role role : roles){
263
			for(Role role : roles){
264
				roleTypes[index++] = role.getType().toString();
264
				roleTypes[index++] = role.getType().toString();
265
			}
265
			}
266
			responseMap.put(ProfitMandiConstants.TOKEN, JWTUtil.create(user.getId(), roleTypes));
266
			responseMap.put(ProfitMandiConstants.TOKEN, JWTUtil.create(user.getId(), roleTypes));
267
			responseMap.put(ProfitMandiConstants.REGISTERED, true);
267
			responseMap.put(ProfitMandiConstants.REGISTERED, true);
268
		}catch (ProfitMandiBusinessException pmbe) {
268
		}catch (ProfitMandiBusinessException profitMandiBusinessException) {
269
			responseMap.put(ProfitMandiConstants.TOKEN, JWTUtil.create());
269
			responseMap.put(ProfitMandiConstants.TOKEN, JWTUtil.create());
270
			responseMap.put(ProfitMandiConstants.REGISTERED, false);
270
			responseMap.put(ProfitMandiConstants.REGISTERED, false);
271
		}
271
		}
272
		final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, responseMap);
272
		final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, responseMap);
273
		return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
273
		return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);