- httpClient = getHttpClient();
- HttpPost httpPost = new HttpPost(url);
- if (!header.isEmpty()) {
- for (Map.Entry<String, String> entry : header.entrySet()) {
- httpPost.addHeader(entry.getKey(), entry.getValue());
- }
+ CloseableHttpClient httpClient = getHttpClient();
+ HttpPost httpPost = getHttpPost(url, header, param, entity);
+ httpResponse = getHttpResponse(httpClient, httpPost);
+ } catch (Exception e) {
+ throw new CorrelationException("Failed to use post method query data from server");
+ }
+
+ return getResponseEntity(httpResponse);
+ }
+
+ public static String get(String url, Map<String, String> header) throws Exception {
+ HttpResponse httpResponse = null;
+ try {
+ CloseableHttpClient httpClient = getHttpClient();
+ HttpGet httpGet = getHttpGet(url, header);
+ httpResponse = getHttpResponse(httpClient, httpGet);
+ } catch (Exception e) {
+ throw new CorrelationException("Failed to use get method query data from server");
+ }
+ return getResponseEntity(httpResponse);
+ }
+
+ private static HttpPost getHttpPost(String url, Map<String, String> header,
+ Map<String, String> param, HttpEntity entity) {
+ HttpPost httpPost = new HttpPost(url);
+ if (!header.isEmpty()) {
+ for (Map.Entry<String, String> entry : header.entrySet()) {
+ httpPost.addHeader(entry.getKey(), entry.getValue());