| Line 94... |
Line 94... |
| 94 |
socialUser.setUpdateTimestamp(LocalDateTime.now());
|
94 |
socialUser.setUpdateTimestamp(LocalDateTime.now());
|
| 95 |
socialUserRepository.persist(socialUser);
|
95 |
socialUserRepository.persist(socialUser);
|
| 96 |
}
|
96 |
}
|
| 97 |
|
97 |
|
| 98 |
Map<String, Object> responseMap = new HashMap<>(2);
|
98 |
Map<String, Object> responseMap = new HashMap<>(2);
|
| - |
|
99 |
User user = null;
|
| 99 |
try{
|
100 |
try{
|
| - |
|
101 |
user = userRepository.selectByEmailId(socialUser.getEmailId());
|
| - |
|
102 |
}catch(ProfitMandiBusinessException profitMandiBusinessException){
|
| - |
|
103 |
|
| - |
|
104 |
}
|
| - |
|
105 |
if(user == null){
|
| - |
|
106 |
try{
|
| 100 |
User user = userRepository.selectByEmailId(socialUser.getEmailId());
|
107 |
user = userRepository.selectByEmailId(socialUser.getEmailId());
|
| - |
|
108 |
}catch (ProfitMandiBusinessException profitMandiBusinessException) {
|
| - |
|
109 |
responseMap.put(ProfitMandiConstants.TOKEN, JWTUtil.create(socialUser.getEmailId()));
|
| - |
|
110 |
responseMap.put(ProfitMandiConstants.REGISTERED, false);
|
| - |
|
111 |
}
|
| - |
|
112 |
}
|
| - |
|
113 |
if(user != null){
|
| 101 |
//Set<Role> roles = user.getRoles();
|
114 |
//Set<Role> roles = user.getRoles();
|
| 102 |
List<UserRole> userRoles = userRoleRepository.selectByUserId(user.getId());
|
115 |
List<UserRole> userRoles = userRoleRepository.selectByUserId(user.getId());
|
| 103 |
//Set<Role> roles = new HashSet<>();
|
116 |
//Set<Role> roles = new HashSet<>();
|
| 104 |
String[] roleTypes = new String[userRoles.size()];
|
117 |
String[] roleTypes = new String[userRoles.size()];
|
| 105 |
int index = 0;
|
118 |
int index = 0;
|
| 106 |
for (UserRole userRole : userRoles) {
|
119 |
for (UserRole userRole : userRoles) {
|
| 107 |
roleTypes[index++] = userRole.getRoleType().toString();
|
120 |
roleTypes[index++] = userRole.getRoleType().toString();
|
| 108 |
}
|
121 |
}
|
| 109 |
responseMap.put(ProfitMandiConstants.TOKEN, JWTUtil.create(user.getId(), roleTypes));
|
122 |
responseMap.put(ProfitMandiConstants.TOKEN, JWTUtil.create(user.getId(), roleTypes));
|
| 110 |
responseMap.put(ProfitMandiConstants.REGISTERED, true);
|
123 |
responseMap.put(ProfitMandiConstants.REGISTERED, true);
|
| 111 |
}catch (ProfitMandiBusinessException profitMandiBusinessException) {
|
- |
|
| 112 |
responseMap.put(ProfitMandiConstants.TOKEN, JWTUtil.create(socialUser.getEmailId()));
|
- |
|
| 113 |
responseMap.put(ProfitMandiConstants.REGISTERED, false);
|
- |
|
| 114 |
}
|
124 |
}
|
| - |
|
125 |
|
| 115 |
return responseMap;
|
126 |
return responseMap;
|
| 116 |
}catch (JsonProcessingException jsonProcessingException) {
|
127 |
}catch (JsonProcessingException jsonProcessingException) {
|
| 117 |
//LOGGER.error("Json parse exception of "+json,jsonProcessingException);
|
128 |
//LOGGER.error("Json parse exception of "+json,jsonProcessingException);
|
| 118 |
throw new ProfitMandiBusinessException("", "", "VE_1001");
|
129 |
throw new ProfitMandiBusinessException("", "", "VE_1001");
|
| 119 |
}catch (IOException ioException) {
|
130 |
}catch (IOException ioException) {
|
| Line 129... |
Line 140... |
| 129 |
Map<String, String> headers = new HashMap<>(1);
|
140 |
Map<String, String> headers = new HashMap<>(1);
|
| 130 |
headers.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
|
141 |
headers.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
|
| 131 |
String responseString = restClient.get(V3_URI, params, headers);
|
142 |
String responseString = restClient.get(V3_URI, params, headers);
|
| 132 |
try {
|
143 |
try {
|
| 133 |
JsonNode rootNode = objectMapper.readTree(responseString);
|
144 |
JsonNode rootNode = objectMapper.readTree(responseString);
|
| - |
|
145 |
User user = null;
|
| 134 |
try{
|
146 |
try{
|
| 135 |
User user = userRepository.selectByEmailId(rootNode.get("email").asText());
|
147 |
user = userRepository.selectByEmailId(rootNode.get("email").asText());
|
| - |
|
148 |
}catch(ProfitMandiBusinessException profitMandiBusinessException){
|
| - |
|
149 |
|
| - |
|
150 |
}
|
| - |
|
151 |
if(user == null){
|
| - |
|
152 |
user = userRepository.selectBySecondryEmailId(rootNode.get("email").asText());
|
| - |
|
153 |
}
|
| - |
|
154 |
if(user != null){
|
| 136 |
Map<String, Object> responseMap = new HashMap<>(2);
|
155 |
Map<String, Object> responseMap = new HashMap<>(2);
|
| 137 |
responseMap.put(ProfitMandiConstants.FOFO_ID, user.getId());
|
156 |
responseMap.put(ProfitMandiConstants.FOFO_ID, user.getId());
|
| 138 |
responseMap.put(ProfitMandiConstants.EMAIL_ID, user.getEmailId());
|
157 |
responseMap.put(ProfitMandiConstants.EMAIL_ID, user.getEmailId());
|
| 139 |
return responseMap;
|
158 |
return responseMap;
|
| 140 |
}catch (ProfitMandiBusinessException profitMandiBusinessException) {
|
- |
|
| 141 |
throw new ProfitMandiBusinessException(profitMandiBusinessException.getRejectedType(), profitMandiBusinessException.getRejectedValue(), "");
|
- |
|
| 142 |
}
|
159 |
}
|
| 143 |
|
160 |
|
| 144 |
}catch (JsonProcessingException jsonProcessingException) {
|
161 |
}catch (JsonProcessingException jsonProcessingException) {
|
| 145 |
throw new ProfitMandiBusinessException("", "", "VE_1001");
|
162 |
throw new ProfitMandiBusinessException("", "", "VE_1001");
|
| 146 |
}catch (IOException ioException) {
|
163 |
}catch (IOException ioException) {
|
| 147 |
throw new ProfitMandiBusinessException("", "", "VE_1001");
|
164 |
throw new ProfitMandiBusinessException("", "", "VE_1001");
|
| 148 |
}
|
165 |
}
|
| - |
|
166 |
return null;
|
| 149 |
}
|
167 |
}
|
| 150 |
}
|
168 |
}
|