| Line 221... |
Line 221... |
| 221 |
LOGGER.error("IO Error : ", e);
|
221 |
LOGGER.error("IO Error : ", e);
|
| 222 |
throw new RuntimeException(ResponseCodeHolder.getMessage("GE_1006"));
|
222 |
throw new RuntimeException(ResponseCodeHolder.getMessage("GE_1006"));
|
| 223 |
}
|
223 |
}
|
| 224 |
}
|
224 |
}
|
| 225 |
|
225 |
|
| - |
|
226 |
public HttpResponse postResponse(String url, Map<String, String> params, Map<String, String> headers)
|
| - |
|
227 |
throws ProfitMandiBusinessException, HttpHostConnectException {
|
| - |
|
228 |
List<NameValuePair> bodyParameters = new ArrayList<>();
|
| - |
|
229 |
if (params != null) {
|
| - |
|
230 |
for (Map.Entry<String, String> entry : params.entrySet()) {
|
| - |
|
231 |
bodyParameters.add(new BasicNameValuePair(entry.getKey(), entry.getValue()));
|
| - |
|
232 |
}
|
| - |
|
233 |
}
|
| - |
|
234 |
HttpPost request = new HttpPost(url);
|
| - |
|
235 |
if (headers != null) {
|
| - |
|
236 |
for (Map.Entry<String, String> entry : headers.entrySet()) {
|
| - |
|
237 |
request.setHeader(entry.getKey(), entry.getValue());
|
| - |
|
238 |
}
|
| - |
|
239 |
}
|
| - |
|
240 |
try {
|
| - |
|
241 |
request.setEntity(new UrlEncodedFormEntity(bodyParameters));
|
| - |
|
242 |
LOGGER.info("Request uri is {}", request.getURI().toString());
|
| - |
|
243 |
HttpResponse response = httpClient.execute(request);
|
| - |
|
244 |
LOGGER.info("Got response from server with responseCode {}", response.getStatusLine().getStatusCode());
|
| - |
|
245 |
if (response.getStatusLine().getStatusCode() == HttpStatus.OK.value()) {
|
| - |
|
246 |
return response;
|
| - |
|
247 |
} else {
|
| - |
|
248 |
throw new ProfitMandiBusinessException("", "", "GE_1005");
|
| - |
|
249 |
}
|
| - |
|
250 |
} catch (HttpHostConnectException httpHostConnectException) {
|
| - |
|
251 |
LOGGER.error("Connection Timeout Exception", httpHostConnectException);
|
| - |
|
252 |
throw httpHostConnectException;
|
| - |
|
253 |
} catch (ClientProtocolException e) {
|
| - |
|
254 |
LOGGER.error("Client Error : ", e);
|
| - |
|
255 |
throw new RuntimeException(ResponseCodeHolder.getMessage("GE_1006"));
|
| - |
|
256 |
} catch (IOException e) {
|
| - |
|
257 |
LOGGER.error("IO Error : ", e);
|
| - |
|
258 |
throw new RuntimeException(ResponseCodeHolder.getMessage("GE_1006"));
|
| - |
|
259 |
}
|
| - |
|
260 |
}
|
| - |
|
261 |
|
| 226 |
public String post(SchemeType scheme, String hostName, int port, String uri, Map<String, String> params,
|
262 |
public String post(SchemeType scheme, String hostName, int port, String uri, Map<String, String> params,
|
| 227 |
Map<String, String> headers) throws ProfitMandiBusinessException, HttpHostConnectException {
|
263 |
Map<String, String> headers) throws ProfitMandiBusinessException, HttpHostConnectException {
|
| 228 |
String url = scheme.getValue() == null ? SchemeType.HTTP.toString()
|
264 |
String url = scheme.getValue() == null ? SchemeType.HTTP.toString()
|
| 229 |
: scheme.getValue() + hostName + ":" + port + "/" + uri;
|
265 |
: scheme.getValue() + hostName + ":" + port + "/" + uri;
|
| 230 |
return this.post(url, params, headers);
|
266 |
return this.post(url, params, headers);
|