diff options
author | Michal Kabaj <michal.kabaj@nokia.com> | 2018-12-17 17:10:24 +0100 |
---|---|---|
committer | Lukasz Muszkieta <lukasz.muszkieta@nokia.com> | 2019-01-04 12:02:36 +0000 |
commit | 61b78a7d5f1eb8f1c5955d6d1439ce9225a39b46 (patch) | |
tree | 4f6ab37c32786ad489f6d8f2130d1b03105f8c32 /common/src/main | |
parent | 85a47c701c3b34c58d2b121ba466d41ffb4fb7b0 (diff) |
HttpClientFactory to create HttpClient instances
-Replace constructor calls with existing factory
-Add create methods to factory for each required Media Type
Change-Id: Ibd03c10230c87a0413c0ec529e0ea9ac800444f9
Issue-ID: SO-1344
Signed-off-by: Michal Kabaj <michal.kabaj@nokia.com>
Diffstat (limited to 'common/src/main')
-rw-r--r-- | common/src/main/java/org/onap/so/client/HttpClient.java | 4 | ||||
-rw-r--r-- | common/src/main/java/org/onap/so/client/HttpClientFactory.java | 13 |
2 files changed, 13 insertions, 4 deletions
diff --git a/common/src/main/java/org/onap/so/client/HttpClient.java b/common/src/main/java/org/onap/so/client/HttpClient.java index 66e970a154..6f13a86237 100644 --- a/common/src/main/java/org/onap/so/client/HttpClient.java +++ b/common/src/main/java/org/onap/so/client/HttpClient.java @@ -34,10 +34,10 @@ public class HttpClient extends RestClient { protected final Logger log = LoggerFactory.getLogger(HttpClient.class); private TargetEntity targetEntity; - public HttpClient(URL host, String contentType, TargetEntity targetEntity) { + + HttpClient(URL host, String contentType, TargetEntity targetEntity) { super(host, contentType); this.targetEntity = targetEntity; - } @Override diff --git a/common/src/main/java/org/onap/so/client/HttpClientFactory.java b/common/src/main/java/org/onap/so/client/HttpClientFactory.java index 9705d7d0c4..d02c18ff56 100644 --- a/common/src/main/java/org/onap/so/client/HttpClientFactory.java +++ b/common/src/main/java/org/onap/so/client/HttpClientFactory.java @@ -20,11 +20,20 @@ package org.onap.so.client; import java.net.URL; +import javax.ws.rs.core.MediaType; import org.onap.so.utils.TargetEntity; public class HttpClientFactory { - public HttpClient create(URL host, String contentType, TargetEntity targetEntity) { - return new HttpClient(host, contentType, targetEntity); + public HttpClient newJsonClient(URL host, TargetEntity targetEntity) { + return new HttpClient(host, MediaType.APPLICATION_JSON, targetEntity); + } + + public HttpClient newXmlClient(URL host, TargetEntity targetEntity) { + return new HttpClient(host, MediaType.APPLICATION_XML, targetEntity); + } + + public HttpClient newTextXmlClient(URL host, TargetEntity targetEntity) { + return new HttpClient(host, MediaType.TEXT_XML, targetEntity); } } |