| Line 77... |
Line 77... |
| 77 |
}
|
77 |
}
|
| 78 |
HttpGet request = new HttpGet(builder.build().encode().toUri());
|
78 |
HttpGet request = new HttpGet(builder.build().encode().toUri());
|
| 79 |
return this.execute(request);
|
79 |
return this.execute(request);
|
| 80 |
}
|
80 |
}
|
| 81 |
|
81 |
|
| - |
|
82 |
public HttpResponse getResponse(String url, Map<String, String> params, Map<String, String> headers)
|
| - |
|
83 |
throws ProfitMandiBusinessException, HttpHostConnectException {
|
| - |
|
84 |
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(url);
|
| - |
|
85 |
Set<String> keys = params.keySet();
|
| - |
|
86 |
for(String key : keys){
|
| - |
|
87 |
builder.queryParam(key, params.get(key));
|
| - |
|
88 |
}
|
| - |
|
89 |
HttpGet request = new HttpGet(builder.build().encode().toUri());
|
| - |
|
90 |
for(Map.Entry<String, String> entry : headers.entrySet()){
|
| - |
|
91 |
request.setHeader(entry.getKey(), entry.getValue());
|
| - |
|
92 |
}
|
| - |
|
93 |
try {
|
| - |
|
94 |
LOGGER.info("Request uri is {}", request.getURI().toString());
|
| - |
|
95 |
HttpResponse response = httpClient.execute(request);
|
| - |
|
96 |
LOGGER.info("Got response from server with responseCode {}", response.getStatusLine().getStatusCode());
|
| - |
|
97 |
if(response.getStatusLine().getStatusCode() == HttpStatus.OK.value()){
|
| - |
|
98 |
return response;
|
| - |
|
99 |
}else{
|
| - |
|
100 |
throw new ProfitMandiBusinessException("", "", "GE_1005");
|
| - |
|
101 |
}
|
| - |
|
102 |
} catch(HttpHostConnectException httpHostConnectException) {
|
| - |
|
103 |
LOGGER.error("Connection Timeout Exception", httpHostConnectException);
|
| - |
|
104 |
throw httpHostConnectException;
|
| - |
|
105 |
} catch (ClientProtocolException e) {
|
| - |
|
106 |
LOGGER.error("Client Error : ",e);
|
| - |
|
107 |
throw new RuntimeException(ResponseCodeHolder.getMessage("GE_1006"));
|
| - |
|
108 |
} catch (IOException e) {
|
| - |
|
109 |
LOGGER.error("IO Error : ", e);
|
| - |
|
110 |
throw new RuntimeException(ResponseCodeHolder.getMessage("GE_1006"));
|
| - |
|
111 |
}
|
| - |
|
112 |
}
|
| - |
|
113 |
|
| 82 |
public String execute(HttpUriRequest request)
|
114 |
public String execute(HttpUriRequest request)
|
| 83 |
throws ProfitMandiBusinessException, HttpHostConnectException{
|
115 |
throws ProfitMandiBusinessException, HttpHostConnectException{
|
| 84 |
LOGGER.info("Connecting to server at url {}",request.getURI());
|
116 |
LOGGER.info("Connecting to server at url {}",request.getURI());
|
| 85 |
try {
|
117 |
try {
|
| 86 |
HttpResponse response = httpClient.execute(request);
|
118 |
HttpResponse response = httpClient.execute(request);
|