| Line 153... |
Line 153... |
| 153 |
}
|
153 |
}
|
| 154 |
}
|
154 |
}
|
| 155 |
|
155 |
|
| 156 |
public String execute(HttpUriRequest request) throws ProfitMandiBusinessException, HttpHostConnectException {
|
156 |
public String execute(HttpUriRequest request) throws ProfitMandiBusinessException, HttpHostConnectException {
|
| 157 |
LOGGER.info("Connecting to server at url {}", request.getURI());
|
157 |
LOGGER.info("Connecting to server at url {}", request.getURI());
|
| - |
|
158 |
HttpResponse response = null;
|
| 158 |
try {
|
159 |
try {
|
| 159 |
HttpResponse response = httpClient.execute(request);
|
160 |
response = httpClient.execute(request);
|
| 160 |
String responseString = this.toString(response.getEntity().getContent());
|
161 |
String responseString = this.toString(response.getEntity().getContent());
|
| 161 |
LOGGER.info("Got response from server with responseCode {}", response.getStatusLine().getStatusCode());
|
162 |
LOGGER.info("Got response from server with responseCode {}", response.getStatusLine().getStatusCode());
|
| 162 |
LOGGER.info("Response String {}", responseString);
|
163 |
LOGGER.info("Response String {}", responseString);
|
| 163 |
if (response.getStatusLine().getStatusCode() == HttpStatus.OK.value() || response.getStatusLine().getStatusCode() == HttpStatus.CREATED.value() || response.getStatusLine().getStatusCode() == HttpStatus.ACCEPTED.value()) {
|
164 |
if (response.getStatusLine().getStatusCode() == HttpStatus.OK.value() || response.getStatusLine().getStatusCode() == HttpStatus.CREATED.value() || response.getStatusLine().getStatusCode() == HttpStatus.ACCEPTED.value()) {
|
| 164 |
return responseString;
|
165 |
return responseString;
|
| Line 173... |
Line 174... |
| 173 |
LOGGER.error("Client Error : ", e);
|
174 |
LOGGER.error("Client Error : ", e);
|
| 174 |
throw new RuntimeException(ResponseCodeHolder.getMessage("GE_1006"));
|
175 |
throw new RuntimeException(ResponseCodeHolder.getMessage("GE_1006"));
|
| 175 |
} catch (IOException e) {
|
176 |
} catch (IOException e) {
|
| 176 |
LOGGER.error("IO Error : ", e);
|
177 |
LOGGER.error("IO Error : ", e);
|
| 177 |
throw new RuntimeException(ResponseCodeHolder.getMessage("GE_1006"));
|
178 |
throw new RuntimeException(ResponseCodeHolder.getMessage("GE_1006"));
|
| - |
|
179 |
} finally {
|
| - |
|
180 |
if (response != null) EntityUtils.consumeQuietly(response.getEntity());
|
| 178 |
}
|
181 |
}
|
| 179 |
}
|
182 |
}
|
| 180 |
|
183 |
|
| 181 |
public MandiiResponse executeMandii(HttpUriRequest request)
|
184 |
public MandiiResponse executeMandii(HttpUriRequest request)
|
| 182 |
throws ProfitMandiBusinessException, HttpHostConnectException {
|
185 |
throws ProfitMandiBusinessException, HttpHostConnectException {
|
| 183 |
LOGGER.info("Connecting to server at url {}", request.getURI());
|
186 |
LOGGER.info("Connecting to server at url {}", request.getURI());
|
| - |
|
187 |
HttpResponse response = null;
|
| 184 |
try {
|
188 |
try {
|
| 185 |
HttpResponse response = httpClient.execute(request);
|
189 |
response = httpClient.execute(request);
|
| 186 |
String responseString = this.toString(response.getEntity().getContent());
|
190 |
String responseString = this.toString(response.getEntity().getContent());
|
| 187 |
LOGGER.info("Got response from server with responseCode {}", response.getStatusLine().getStatusCode());
|
191 |
LOGGER.info("Got response from server with responseCode {}", response.getStatusLine().getStatusCode());
|
| 188 |
|
192 |
|
| 189 |
MandiiResponse mandiiResponse = new MandiiResponse();
|
193 |
MandiiResponse mandiiResponse = new MandiiResponse();
|
| 190 |
mandiiResponse.setResponseString(responseString);
|
194 |
mandiiResponse.setResponseString(responseString);
|
| Line 198... |
Line 202... |
| 198 |
LOGGER.error("Client Error : ", e);
|
202 |
LOGGER.error("Client Error : ", e);
|
| 199 |
throw new RuntimeException(ResponseCodeHolder.getMessage("GE_1006"));
|
203 |
throw new RuntimeException(ResponseCodeHolder.getMessage("GE_1006"));
|
| 200 |
} catch (IOException e) {
|
204 |
} catch (IOException e) {
|
| 201 |
LOGGER.error("IO Error : ", e);
|
205 |
LOGGER.error("IO Error : ", e);
|
| 202 |
throw new RuntimeException(ResponseCodeHolder.getMessage("GE_1006"));
|
206 |
throw new RuntimeException(ResponseCodeHolder.getMessage("GE_1006"));
|
| - |
|
207 |
} finally {
|
| - |
|
208 |
if (response != null) EntityUtils.consumeQuietly(response.getEntity());
|
| 203 |
}
|
209 |
}
|
| 204 |
}
|
210 |
}
|
| 205 |
|
211 |
|
| 206 |
public String executeJson(HttpUriRequest request) throws ProfitMandiBusinessException, HttpHostConnectException {
|
212 |
public String executeJson(HttpUriRequest request) throws ProfitMandiBusinessException, HttpHostConnectException {
|
| 207 |
LOGGER.info("Connecting to server at url {}", request.getURI());
|
213 |
LOGGER.info("Connecting to server at url {}", request.getURI());
|
| - |
|
214 |
HttpResponse response = null;
|
| 208 |
try {
|
215 |
try {
|
| 209 |
HttpResponse response = httpClient.execute(request);
|
216 |
response = httpClient.execute(request);
|
| 210 |
String responseString = this.toString(response.getEntity().getContent());
|
217 |
String responseString = this.toString(response.getEntity().getContent());
|
| 211 |
LOGGER.info("Got response from server with responseCode {}", response.getStatusLine().getStatusCode());
|
218 |
LOGGER.info("Got response from server with responseCode {}", response.getStatusLine().getStatusCode());
|
| 212 |
LOGGER.info("Response String {}", responseString);
|
219 |
LOGGER.info("Response String {}", responseString);
|
| 213 |
return responseString;
|
220 |
return responseString;
|
| 214 |
} catch (HttpHostConnectException httpHostConnectException) {
|
221 |
} catch (HttpHostConnectException httpHostConnectException) {
|
| Line 218... |
Line 225... |
| 218 |
LOGGER.error("Client Error : ", e);
|
225 |
LOGGER.error("Client Error : ", e);
|
| 219 |
throw new RuntimeException(ResponseCodeHolder.getMessage("GE_1006"));
|
226 |
throw new RuntimeException(ResponseCodeHolder.getMessage("GE_1006"));
|
| 220 |
} catch (IOException e) {
|
227 |
} catch (IOException e) {
|
| 221 |
LOGGER.error("IO Error : ", e);
|
228 |
LOGGER.error("IO Error : ", e);
|
| 222 |
throw new RuntimeException(ResponseCodeHolder.getMessage("GE_1006"));
|
229 |
throw new RuntimeException(ResponseCodeHolder.getMessage("GE_1006"));
|
| - |
|
230 |
} finally {
|
| - |
|
231 |
if (response != null) EntityUtils.consumeQuietly(response.getEntity());
|
| 223 |
}
|
232 |
}
|
| 224 |
}
|
233 |
}
|
| 225 |
|
234 |
|
| 226 |
public HttpResponse postResponse(String url, Map<String, String> params, Map<String, String> headers)
|
235 |
public HttpResponse postResponse(String url, Map<String, String> params, Map<String, String> headers)
|
| 227 |
throws ProfitMandiBusinessException, HttpHostConnectException {
|
236 |
throws ProfitMandiBusinessException, HttpHostConnectException {
|