Subversion Repositories SmartDukaan

Rev

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

Rev 23204 Rev 23532
Line 4... Line 4...
4
import java.time.LocalDateTime;
4
import java.time.LocalDateTime;
5
import java.util.HashMap;
5
import java.util.HashMap;
6
import java.util.Iterator;
6
import java.util.Iterator;
7
import java.util.List;
7
import java.util.List;
8
import java.util.Map;
8
import java.util.Map;
-
 
9
import java.util.logging.Logger;
9
 
10
 
-
 
11
import org.apache.http.conn.HttpHostConnectException;
10
import org.springframework.beans.factory.annotation.Autowired;
12
import org.springframework.beans.factory.annotation.Autowired;
11
import org.springframework.http.HttpHeaders;
13
import org.springframework.http.HttpHeaders;
12
import org.springframework.http.MediaType;
14
import org.springframework.http.MediaType;
13
import org.springframework.stereotype.Component;
15
import org.springframework.stereotype.Component;
14
 
16
 
Line 49... Line 51...
49
	
51
	
50
	@Autowired
52
	@Autowired
51
	private UserRoleRepository userRoleRepository;
53
	private UserRoleRepository userRoleRepository;
52
	
54
	
53
	public Map<String, Object> process(GoogleLoginRequest googleLoginRequest) throws ProfitMandiBusinessException{
55
	public Map<String, Object> process(GoogleLoginRequest googleLoginRequest) throws ProfitMandiBusinessException{
54
		RestClient restClient = new RestClient(SchemeType.HTTPS, V1_HOST_NAME, PORT_NUMBER);
56
		RestClient restClient = new RestClient();
55
		Map<String, String> params = new HashMap<>();
57
		Map<String, String> params = new HashMap<>();
56
		params.put(ProfitMandiConstants.ACCESS_TOKEN, googleLoginRequest.getToken());
58
		params.put(ProfitMandiConstants.ACCESS_TOKEN, googleLoginRequest.getToken());
57
		Map<String, String> headers = new HashMap<>(1);
59
		Map<String, String> headers = new HashMap<>(1);
58
		headers.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
60
		headers.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
-
 
61
		String responseString; 
-
 
62
		try {
59
		String responseString = restClient.get(V1_URI, params, headers);
63
			responseString = restClient.get(SchemeType.HTTPS, V1_HOST_NAME, PORT_NUMBER, V1_URI, params, headers);
-
 
64
		} catch (HttpHostConnectException e) {
-
 
65
			throw new ProfitMandiBusinessException("", "", "Could not connect to remote host");
-
 
66
		}
60
		try {
67
		try {
61
			JsonNode rootNode = objectMapper.readTree(responseString);
68
			JsonNode rootNode = objectMapper.readTree(responseString);
62
			SocialUser socialUser = new SocialUser();
69
			SocialUser socialUser = new SocialUser();
63
			if(rootNode.has("emails")){
70
			if(rootNode.has("emails")){
64
				JsonNode emails = rootNode.get("emails");
71
				JsonNode emails = rootNode.get("emails");
Line 132... Line 139...
132
			throw new ProfitMandiBusinessException("", "", "VE_1001");
139
			throw new ProfitMandiBusinessException("", "", "VE_1001");
133
		}
140
		}
134
	}
141
	}
135
	
142
	
136
	public Map<String, Object> getFofoDetail(String token) throws ProfitMandiBusinessException{
143
	public Map<String, Object> getFofoDetail(String token) throws ProfitMandiBusinessException{
137
		RestClient restClient = new RestClient(SchemeType.HTTPS, V3_HOST_NAME, PORT_NUMBER);
144
		RestClient restClient = new RestClient();
138
		Map<String, String> params = new HashMap<>();
145
		Map<String, String> params = new HashMap<>();
139
		params.put(ProfitMandiConstants.ID_TOKEN, token);
146
		params.put(ProfitMandiConstants.ID_TOKEN, token);
140
		Map<String, String> headers = new HashMap<>(1);
147
		Map<String, String> headers = new HashMap<>(1);
141
		headers.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
148
		headers.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
-
 
149
		String responseString;
-
 
150
		try {
142
		String responseString = restClient.get(V3_URI, params, headers);
151
			responseString = restClient.get(SchemeType.HTTPS, V3_HOST_NAME, PORT_NUMBER, V3_URI, params, headers);
-
 
152
		} catch(HttpHostConnectException e) {
-
 
153
			throw new ProfitMandiBusinessException("", "", "Could not connect to host");
-
 
154
		}
-
 
155
		
143
		try {
156
		try {
144
			JsonNode rootNode = objectMapper.readTree(responseString);
157
			JsonNode rootNode = objectMapper.readTree(responseString);
145
			User user = null;
158
			User user = null;
146
			try{
159
			try{
147
				user = userRepository.selectByEmailId(rootNode.get("email").asText());
160
				user = userRepository.selectByEmailId(rootNode.get("email").asText());