aboutsummaryrefslogtreecommitdiffstats
path: root/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/HttpRequest.java
diff options
context:
space:
mode:
Diffstat (limited to 'common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/HttpRequest.java')
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/HttpRequest.java69
1 files changed, 31 insertions, 38 deletions
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/HttpRequest.java b/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/HttpRequest.java
index b418ce744e..57e5cb2bed 100644
--- a/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/HttpRequest.java
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/http/client/api/HttpRequest.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -28,34 +28,27 @@ import java.util.Properties;
//TODO- remove all static and use instance methods for better testing
public abstract class HttpRequest {
- private static final Properties DEFAULT_HEADERS = null;
- private static final HttpClientConfig DEFAULT_CONFIG = new HttpClientConfig();
+ static final Properties defaultHeaders = null;
+ static final HttpClientConfig defaultConfig = new HttpClientConfig();
- private HttpRequest() {
- }
-
- public static Properties getDefaultHeaders() {
- return DEFAULT_HEADERS;
- }
- public static HttpClientConfig getDefaultConfig() {
- return DEFAULT_CONFIG;
+ private HttpRequest() {
}
/*
* GET response as string
*/
public static HttpResponse<String> get(String url) throws HttpExecuteException {
- return get(url, DEFAULT_HEADERS, DEFAULT_CONFIG);
+ return get(url, defaultHeaders, defaultConfig);
}
public static HttpResponse<String> get(String url, Properties headers) throws HttpExecuteException {
- return get(url, headers, DEFAULT_CONFIG);
+ return get(url, headers, defaultConfig);
}
-
+
public static HttpResponse<String> get(String url, HttpClientConfig config) throws HttpExecuteException {
- return get(url, DEFAULT_HEADERS, config);
+ return get(url, defaultHeaders, config);
}
public static HttpResponse<String> get(String url, Properties headers, HttpClientConfig config) throws HttpExecuteException {
@@ -66,15 +59,15 @@ public abstract class HttpRequest {
* GET response as byte array
*/
public static HttpResponse<byte[]> getAsByteArray(String url) throws HttpExecuteException {
- return getAsByteArray(url, DEFAULT_HEADERS, DEFAULT_CONFIG);
+ return getAsByteArray(url, defaultHeaders, defaultConfig);
}
public static HttpResponse<byte[]> getAsByteArray(String url, Properties headers) throws HttpExecuteException {
- return getAsByteArray(url, headers, DEFAULT_CONFIG);
+ return getAsByteArray(url, headers, defaultConfig);
}
public static HttpResponse<byte[]> getAsByteArray(String url, HttpClientConfig config) throws HttpExecuteException {
- return getAsByteArray(url, DEFAULT_HEADERS, config);
+ return getAsByteArray(url, defaultHeaders, config);
}
public static HttpResponse<byte[]> getAsByteArray(String url, Properties headers, HttpClientConfig config) throws HttpExecuteException {
@@ -85,15 +78,15 @@ public abstract class HttpRequest {
* PUT
*/
public static HttpResponse<String> put(String url, HttpEntity entity) throws HttpExecuteException {
- return put(url, DEFAULT_HEADERS, entity, DEFAULT_CONFIG);
+ return put(url, defaultHeaders, entity, defaultConfig);
}
public static HttpResponse<String> put(String url, Properties headers, HttpEntity entity) throws HttpExecuteException {
- return put(url, headers, entity, DEFAULT_CONFIG);
+ return put(url, headers, entity, defaultConfig);
}
-
+
public static HttpResponse<String> put(String url, HttpEntity entity, HttpClientConfig config) throws HttpExecuteException {
- return put(url, DEFAULT_HEADERS, entity, config);
+ return put(url, defaultHeaders, entity, config);
}
public static HttpResponse<String> put(String url, Properties headers, HttpEntity entity, HttpClientConfig config) throws HttpExecuteException {
@@ -104,59 +97,59 @@ public abstract class HttpRequest {
* POST
*/
public static HttpResponse<String> post(String url, HttpEntity entity) throws HttpExecuteException {
- return post(url, DEFAULT_HEADERS, entity, DEFAULT_CONFIG);
+ return post(url, defaultHeaders, entity, defaultConfig);
}
public static HttpResponse<String> post(String url, Properties headers, HttpEntity entity) throws HttpExecuteException {
- return post(url, headers, entity, DEFAULT_CONFIG);
+ return post(url, headers, entity, defaultConfig);
}
-
+
public static HttpResponse<String> post(String url, HttpEntity entity, HttpClientConfig config) throws HttpExecuteException {
- return post(url, DEFAULT_HEADERS, entity, config);
+ return post(url, defaultHeaders, entity, config);
}
public static HttpResponse<String> post(String url, Properties headers, HttpEntity entity, HttpClientConfig config) throws HttpExecuteException {
return HttpRequestHandler.get().post(url, headers, entity, config);
}
-
+
/*
* PATCH
*/
public static HttpResponse<String> patch(String url, HttpEntity entity) throws HttpExecuteException {
- return patch(url, DEFAULT_HEADERS, entity, DEFAULT_CONFIG);
+ return patch(url, defaultHeaders, entity, defaultConfig);
}
public static HttpResponse<String> patch(String url, Properties headers, HttpEntity entity) throws HttpExecuteException {
- return patch(url, headers, entity, DEFAULT_CONFIG);
+ return patch(url, headers, entity, defaultConfig);
}
-
+
public static HttpResponse<String> patch(String url, HttpEntity entity, HttpClientConfig config) throws HttpExecuteException {
- return patch(url, DEFAULT_HEADERS, entity, config);
+ return patch(url, defaultHeaders, entity, config);
}
public static HttpResponse<String> patch(String url, Properties headers, HttpEntity entity, HttpClientConfig config) throws HttpExecuteException {
return HttpRequestHandler.get().patch(url, headers, entity, config);
}
-
+
/*
* DELETE
*/
public static HttpResponse<String> delete(String url) throws HttpExecuteException {
- return delete(url, DEFAULT_HEADERS, DEFAULT_CONFIG);
+ return delete(url, defaultHeaders, defaultConfig);
}
public static HttpResponse<String> delete(String url, Properties headers) throws HttpExecuteException {
- return delete(url, headers, DEFAULT_CONFIG);
+ return delete(url, headers, defaultConfig);
}
-
+
public static HttpResponse<String> delete(String url, HttpClientConfig config) throws HttpExecuteException {
- return delete(url, DEFAULT_HEADERS, config);
+ return delete(url, defaultHeaders, config);
}
public static HttpResponse<String> delete(String url, Properties headers, HttpClientConfig config) throws HttpExecuteException {
return HttpRequestHandler.get().delete(url, headers, config);
}
-
+
public static void destroy() {
HttpRequestHandler.get().destroy();
}