Subversion Repositories SmartDukaan

Rev

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

Rev 21248 Rev 21277
Line 1... Line 1...
1
package com.spice.profitmandi.web.controller;
1
package com.spice.profitmandi.web.controller;
2
 
2
 
3
import java.time.LocalDateTime;
3
import java.time.LocalDateTime;
-
 
4
import java.util.Map;
4
 
5
 
5
import javax.servlet.http.HttpServletRequest;
6
import javax.servlet.http.HttpServletRequest;
6
 
7
 
7
import org.slf4j.Logger;
8
import org.slf4j.Logger;
8
import org.slf4j.LoggerFactory;
9
import org.slf4j.LoggerFactory;
Line 19... Line 20...
19
import com.spice.profitmandi.dao.repository.UserRepository;
20
import com.spice.profitmandi.dao.repository.UserRepository;
20
import com.spice.profitmandi.dao.repository.UserRepositoryImpl;
21
import com.spice.profitmandi.dao.repository.UserRepositoryImpl;
21
import com.spice.profitmandi.web.model.ProfitMandiResponse;
22
import com.spice.profitmandi.web.model.ProfitMandiResponse;
22
import com.spice.profitmandi.web.model.Response;
23
import com.spice.profitmandi.web.model.Response;
23
import com.spice.profitmandi.web.model.ResponseStatus;
24
import com.spice.profitmandi.web.model.ResponseStatus;
-
 
25
import com.spice.profitmandi.web.processor.GoogleLoginProcessor;
24
 
26
 
25
/**
27
/**
26
 * @author ashikali
28
 * @author ashikali
27
 *
29
 *
28
 */
30
 */
Line 31... Line 33...
31
	
33
	
32
	private static final Logger LOGGER=LoggerFactory.getLogger(UserController.class);
34
	private static final Logger LOGGER=LoggerFactory.getLogger(UserController.class);
33
	
35
	
34
	private UserRepository userRepository = UserRepositoryImpl.getInstance();
36
	private UserRepository userRepository = UserRepositoryImpl.getInstance();
35
	
37
	
-
 
38
	@SuppressWarnings("unchecked")
-
 
39
	@RequestMapping(value = ProfitMandiConstants.URL_USER_GOOGLE_LOGIN,method=RequestMethod.POST)
-
 
40
	public ResponseEntity<?> googleLogin(HttpServletRequest request){
-
 
41
		LOGGER.info("requested url : "+request.getRequestURL().toString());
-
 
42
		final Map<String, Object> googleLoginMap = (Map<String, Object>)request.getAttribute(ProfitMandiConstants.GOOGLE_LOGIN_MAP);
-
 
43
		request.removeAttribute(ProfitMandiConstants.GOOGLE_LOGIN_MAP);
-
 
44
		GoogleLoginProcessor googleLoginProcessor = GoogleLoginProcessor.getInstance();
-
 
45
		try {
-
 
46
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, googleLoginProcessor.process(googleLoginMap));
-
 
47
			return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
-
 
48
		}catch (ProfitMandiBusinessException pmbe) {
-
 
49
			LOGGER.error("ProfitMandi error: ", pmbe);
-
 
50
			final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
-
 
51
			final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
-
 
52
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.BAD_REQUEST);
-
 
53
		}catch (Exception e) {
-
 
54
			LOGGER.error("Internal Server Error : ",e);
-
 
55
			final Response response=new Response("","","", e.getMessage());
-
 
56
			final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
-
 
57
			return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
-
 
58
		}
-
 
59
	}
-
 
60
	
36
	@RequestMapping(value = ProfitMandiConstants.URL_USER_ALL,method=RequestMethod.GET)
61
	@RequestMapping(value = ProfitMandiConstants.URL_USER_ALL,method=RequestMethod.GET)
37
	public ResponseEntity<?> getAll(HttpServletRequest request){
62
	public ResponseEntity<?> getAll(HttpServletRequest request){
38
		LOGGER.info("requested url : "+request.getRequestURL().toString());
63
		LOGGER.info("requested url : "+request.getRequestURL().toString());
39
		try {
64
		try {
40
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, userRepository.selectAll());
65
			final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, userRepository.selectAll());