summaryrefslogtreecommitdiffstats
path: root/adapters/mso-adapter-utils/src/main/java/org
diff options
context:
space:
mode:
authorMichal Kabaj <michal.kabaj@nokia.com>2018-12-17 17:10:24 +0100
committerLukasz Muszkieta <lukasz.muszkieta@nokia.com>2019-01-04 12:02:36 +0000
commit61b78a7d5f1eb8f1c5955d6d1439ce9225a39b46 (patch)
tree4f6ab37c32786ad489f6d8f2130d1b03105f8c32 /adapters/mso-adapter-utils/src/main/java/org
parent85a47c701c3b34c58d2b121ba466d41ffb4fb7b0 (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 'adapters/mso-adapter-utils/src/main/java/org')
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java16
1 files changed, 6 insertions, 10 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java
index 829f6c1445..c9b70610d1 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java
@@ -21,16 +21,17 @@
package org.onap.so.openstack.utils;
import java.net.MalformedURLException;
+import java.net.URL;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
-import javax.ws.rs.core.UriBuilder;
import javax.ws.rs.core.UriBuilderException;
import javax.ws.rs.core.Response;
+import org.onap.so.client.HttpClientFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.onap.so.adapters.vdu.CloudInfo;
@@ -48,7 +49,6 @@ import org.onap.so.openstack.beans.StackInfo;
import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound;
import org.onap.so.openstack.exceptions.MsoException;
import org.onap.so.openstack.exceptions.MsoOpenstackException;
-import org.onap.so.client.HttpClient;
import org.onap.so.client.RestClient;
import org.onap.so.db.catalog.beans.CloudSite;
import org.onap.so.logger.MessageEnum;
@@ -56,13 +56,8 @@ import org.onap.so.logger.MsoLogger;
import org.onap.so.utils.TargetEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.woorea.openstack.heat.model.CreateStackParam;
@@ -80,11 +75,11 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
private static final Logger logger = LoggerFactory.getLogger(MsoMulticloudUtils.class);
private static final ObjectMapper JSON_MAPPER = new ObjectMapper();
+ private final HttpClientFactory httpClientFactory = new HttpClientFactory();
@Autowired
private Environment environment;
-
/******************************************************************************
*
* Methods (and associated utilities) to implement the VduPlugin interface
@@ -603,8 +598,9 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
private RestClient getMulticloudClient(String endpoint) {
RestClient client = null;
try {
- client = new HttpClient(UriBuilder.fromUri(endpoint).build().toURL(),
- MediaType.APPLICATION_JSON.toString(), TargetEntity.MULTICLOUD);
+ client = httpClientFactory.newJsonClient(
+ new URL(endpoint),
+ TargetEntity.MULTICLOUD);
} catch (MalformedURLException e) {
logger.debug(String.format("Encountered malformed URL error getting multicloud rest client %s", e.getMessage()));
} catch (IllegalArgumentException e) {