- public static HttpResponse put(String url, Map<String, String> header, Map<String, String> param,
- HttpEntity entity, int timeout) throws CorrelationException {
- HttpResponse response;
- HttpPut httpPut = new HttpPut(url);
- try {
- CloseableHttpClient httpClient = getHttpClient(timeout);
- addHeaders(header, httpPut);
- addParams(param, httpPut);
- if (entity != null) {
- httpPut.setEntity(entity);
- }
- response = executeRequest(httpClient, httpPut);
- } catch (Exception e) {
- throw new CorrelationException("Failed to query data from server through PUT method!");
- }
- return response;
- }
-
- public static HttpResponse get(String url, Map<String, String> header) throws CorrelationException {
- return get(url, header, DEFUALT_TIMEOUT);
- }
-
- public static HttpResponse get(String url, Map<String, String> header, int timeout) throws CorrelationException {
- HttpResponse response;
- HttpGet httpGet = new HttpGet(url);
- try {
- 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;