| Line 16... |
Line 16... |
| 16 |
import org.springframework.web.bind.annotation.RequestParam;
|
16 |
import org.springframework.web.bind.annotation.RequestParam;
|
| 17 |
|
17 |
|
| 18 |
import com.spice.profitmandi.common.ResponseCodeHolder;
|
18 |
import com.spice.profitmandi.common.ResponseCodeHolder;
|
| 19 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
19 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 20 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
20 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| - |
|
21 |
import com.spice.profitmandi.common.util.JWTUtil;
|
| 21 |
import com.spice.profitmandi.dao.entity.User;
|
22 |
import com.spice.profitmandi.dao.entity.User;
|
| 22 |
import com.spice.profitmandi.dao.repository.UserRepository;
|
23 |
import com.spice.profitmandi.dao.repository.UserRepository;
|
| 23 |
import com.spice.profitmandi.web.model.ProfitMandiResponse;
|
24 |
import com.spice.profitmandi.web.model.ProfitMandiResponse;
|
| 24 |
import com.spice.profitmandi.web.model.Response;
|
25 |
import com.spice.profitmandi.web.model.Response;
|
| 25 |
import com.spice.profitmandi.web.model.ResponseStatus;
|
26 |
import com.spice.profitmandi.web.model.ResponseStatus;
|
| Line 60... |
Line 61... |
| 60 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
61 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
| 61 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
62 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
| 62 |
}
|
63 |
}
|
| 63 |
}
|
64 |
}
|
| 64 |
|
65 |
|
| - |
|
66 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_TOKEN_IS_EXPIRED, method=RequestMethod.GET)
|
| - |
|
67 |
public ResponseEntity<?> tokenIsExpired(HttpServletRequest request, @RequestParam(name = "token") String token){
|
| - |
|
68 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
| - |
|
69 |
try {
|
| - |
|
70 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, JWTUtil.isExpired(token));
|
| - |
|
71 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
| - |
|
72 |
}catch (ProfitMandiBusinessException pmbe) {
|
| - |
|
73 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
| - |
|
74 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
| - |
|
75 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
| - |
|
76 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.BAD_REQUEST);
|
| - |
|
77 |
}catch (Exception e) {
|
| - |
|
78 |
LOGGER.error("Internal Server Error: ", e);
|
| - |
|
79 |
final Response response=new Response("","","", e.getMessage());
|
| - |
|
80 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
| - |
|
81 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
| - |
|
82 |
}
|
| - |
|
83 |
}
|
| - |
|
84 |
|
| - |
|
85 |
@RequestMapping(value = ProfitMandiConstants.URL_USER_TOKEN_DETAIL, method=RequestMethod.GET)
|
| - |
|
86 |
public ResponseEntity<?> tokenDetail(HttpServletRequest request, @RequestParam(name = "token") String token){
|
| - |
|
87 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
| - |
|
88 |
try {
|
| - |
|
89 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, userRepository.selectById(JWTUtil.getUserId(token)));
|
| - |
|
90 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.OK);
|
| - |
|
91 |
}catch (ProfitMandiBusinessException pmbe) {
|
| - |
|
92 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
| - |
|
93 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
| - |
|
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);
|
| - |
|
96 |
}catch (Exception e) {
|
| - |
|
97 |
LOGGER.error("Internal Server Error: ", e);
|
| - |
|
98 |
final Response response=new Response("","","", e.getMessage());
|
| - |
|
99 |
final ProfitMandiResponse<Response> profitMandiResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.INTERNAL_SERVER_ERROR.toString(), HttpStatus.INTERNAL_SERVER_ERROR, ResponseStatus.FAILURE, response);
|
| - |
|
100 |
return new ResponseEntity<>(profitMandiResponse,HttpStatus.INTERNAL_SERVER_ERROR);
|
| - |
|
101 |
}
|
| - |
|
102 |
}
|
| - |
|
103 |
|
| 65 |
@RequestMapping(value = ProfitMandiConstants.URL_USER, method=RequestMethod.POST)
|
104 |
@RequestMapping(value = ProfitMandiConstants.URL_USER, method=RequestMethod.POST)
|
| 66 |
public ResponseEntity<?> createUser(HttpServletRequest request){
|
105 |
public ResponseEntity<?> createUser(HttpServletRequest request){
|
| 67 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
106 |
LOGGER.info("requested url : "+request.getRequestURL().toString());
|
| 68 |
final User user = (User)request.getAttribute(ProfitMandiConstants.USER);
|
107 |
final User user = (User)request.getAttribute(ProfitMandiConstants.USER);
|
| 69 |
request.removeAttribute(ProfitMandiConstants.USER);
|
108 |
request.removeAttribute(ProfitMandiConstants.USER);
|
| 70 |
try {
|
109 |
try {
|
| 71 |
user.setCreateTimestamp(LocalDateTime.now());
|
110 |
user.setCreateTimestamp(LocalDateTime.now());
|
| 72 |
user.setUpdateTimestamp(LocalDateTime.now());
|
111 |
user.setUpdateTimestamp(LocalDateTime.now());
|
| 73 |
userRepository.persist(user);
|
112 |
userRepository.persist(user);
|
| 74 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("API_OK_1000"));
|
113 |
final ProfitMandiResponse<?> profitMandiResponse=new ProfitMandiResponse<>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.OK.toString(), HttpStatus.OK, ResponseStatus.SUCCESS, ResponseCodeHolder.getMessage("USR_OK_1000"));
|
| 75 |
return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
|
114 |
return new ResponseEntity<>(profitMandiResponse, HttpStatus.OK);
|
| 76 |
}catch (ProfitMandiBusinessException pmbe) {
|
115 |
}catch (ProfitMandiBusinessException pmbe) {
|
| 77 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
116 |
LOGGER.error("ProfitMandi error: ", pmbe);
|
| 78 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
117 |
final Response response=new Response(pmbe.getRejectedType(), pmbe.getRejectedValue(),pmbe.getCode(), pmbe.getMessage());
|
| 79 |
final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|
118 |
final ProfitMandiResponse<Response> chatOnResponse=new ProfitMandiResponse<Response>(LocalDateTime.now(), request.getRequestURL().toString(), HttpStatus.BAD_REQUEST.toString(), HttpStatus.BAD_REQUEST, ResponseStatus.FAILURE, response);
|