- httpClient = getHttpClient();
- HttpGet httpGet = new HttpGet(url);
- if (!header.isEmpty()) {
- for (Map.Entry<String, String> entry : header.entrySet()) {
- httpGet.addHeader(entry.getKey(), entry.getValue());
- }
+ CloseableHttpClient httpClient = getHttpClient(timeout);
+ addHeaders(header, httpGet);
+ response = executeRequest(httpClient, httpGet);
+ } catch (Exception e) {
+ throw new CorrelationException("Failed to query data from server through GET method!");
+ }
+ return response;
+ }
+
+ public static HttpResponse delete(String url, Map<String, String> header) throws CorrelationException {
+ return delete(url, header, DEFUALT_TIMEOUT);
+ }
+
+ public static HttpResponse delete(String url, Map<String, String> header, int timeout) throws CorrelationException {
+ HttpResponse response;
+ HttpDelete httpDelete = new HttpDelete(url);
+ try {
+ CloseableHttpClient httpClient = getHttpClient(timeout);
+ addHeaders(header, httpDelete);
+ response = executeRequest(httpClient, httpDelete);
+ } catch (Exception e) {
+ throw new CorrelationException("Failed to query data from server through DELETE method!");
+ }
+ return response;
+ }
+
+ private static void addParams(Map<String, String> param, HttpEntityEnclosingRequestBase requestBase) {
+ if (!param.isEmpty()) {
+ List<NameValuePair> formparams = new ArrayList<>();
+ for (Map.Entry<String, String> entry : param.entrySet()) {
+ formparams.add(new BasicNameValuePair(entry.getKey(), entry.getValue()));