From 53646dabc6359e2635c48e201659b6f63a28de06 Mon Sep 17 00:00:00 2001 From: "Boslet, Cory" Date: Tue, 28 Apr 2020 15:23:02 -0400 Subject: Changed the text xml client to always set the Changed the text xml client to always set the accept type to text xml. Forgot to assign the accept type in rest client Issue-ID: SO-2838 Signed-off-by: Benjamin, Max (mb388a) Change-Id: Ia86e53327c6e126fcee6a15b5cd3e5f5c4ec9390 --- common/src/main/java/org/onap/so/client/HttpClient.java | 13 +++++++++---- .../src/main/java/org/onap/so/client/HttpClientFactory.java | 10 +++++----- common/src/main/java/org/onap/so/client/RestClient.java | 9 +++++++++ 3 files changed, 23 insertions(+), 9 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 63a4b1cd65..eaeb0ab6c6 100644 --- a/common/src/main/java/org/onap/so/client/HttpClient.java +++ b/common/src/main/java/org/onap/so/client/HttpClient.java @@ -24,22 +24,27 @@ import java.net.URL; import java.util.Map; import java.util.Optional; import static org.apache.commons.lang3.StringUtils.*; -import org.onap.logging.filter.base.ONAPComponents; +import org.onap.logging.filter.base.ONAPComponentsList; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class HttpClient extends RestClient { protected final Logger log = LoggerFactory.getLogger(HttpClient.class); - private ONAPComponents targetEntity; + private ONAPComponentsList targetEntity; - HttpClient(URL host, String contentType, ONAPComponents targetEntity) { + HttpClient(URL host, String contentType, ONAPComponentsList targetEntity) { super(host, contentType); this.targetEntity = targetEntity; } + HttpClient(URL host, String acceptType, String contentType, ONAPComponentsList targetEntity) { + super(host, acceptType, contentType); + this.targetEntity = targetEntity; + } + @Override - public ONAPComponents getTargetEntity() { + public ONAPComponentsList getTargetEntity() { return targetEntity; } 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 3a8a9ee1bd..84a8bb9fb1 100644 --- a/common/src/main/java/org/onap/so/client/HttpClientFactory.java +++ b/common/src/main/java/org/onap/so/client/HttpClientFactory.java @@ -21,19 +21,19 @@ package org.onap.so.client; import java.net.URL; import javax.ws.rs.core.MediaType; -import org.onap.logging.filter.base.ONAPComponents; +import org.onap.logging.filter.base.ONAPComponentsList; public class HttpClientFactory { - public HttpClient newJsonClient(URL host, ONAPComponents targetEntity) { + public HttpClient newJsonClient(URL host, ONAPComponentsList targetEntity) { return new HttpClient(host, MediaType.APPLICATION_JSON, targetEntity); } - public HttpClient newXmlClient(URL host, ONAPComponents targetEntity) { + public HttpClient newXmlClient(URL host, ONAPComponentsList targetEntity) { return new HttpClient(host, MediaType.APPLICATION_XML, targetEntity); } - public HttpClient newTextXmlClient(URL host, ONAPComponents targetEntity) { - return new HttpClient(host, MediaType.TEXT_XML, targetEntity); + public HttpClient newTextXmlClient(URL host, ONAPComponentsList targetEntity) { + return new HttpClient(host, MediaType.TEXT_XML, MediaType.TEXT_XML, targetEntity); } } diff --git a/common/src/main/java/org/onap/so/client/RestClient.java b/common/src/main/java/org/onap/so/client/RestClient.java index 30389de742..ece1333f83 100644 --- a/common/src/main/java/org/onap/so/client/RestClient.java +++ b/common/src/main/java/org/onap/so/client/RestClient.java @@ -104,6 +104,15 @@ public abstract class RestClient { this.props = new DefaultProperties(host); } + protected RestClient(URL host, String acceptType, String contentType) { + headerMap = new HashMap<>(); + this.path = Optional.empty(); + this.host = host; + this.accept = acceptType; + this.contentType = contentType; + this.props = new DefaultProperties(host); + } + /** * Override method to return false to disable logging. * -- cgit 1.2.3-korg