diff options
Diffstat (limited to 'bpmn/MSOCommonBPMN/src/main/groovy')
9 files changed, 26 insertions, 14 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AaiUtil.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AaiUtil.groovy index 8cc232c2a4..8a8e41247c 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AaiUtil.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AaiUtil.groovy @@ -19,6 +19,9 @@ */ package org.onap.so.bpmn.common.scripts + +import org.onap.so.client.HttpClientFactory + import java.util.regex.Matcher import java.util.regex.Pattern @@ -88,7 +91,7 @@ class AaiUtil { String regionId = "" try{ URL Url = new URL(url) - HttpClient client = new HttpClient(Url, MediaType.APPLICATION_XML, TargetEntity.AAI) + HttpClient client = new HttpClientFactory().newXmlClient(Url, TargetEntity.AAI) client.addBasicAuthHeader(UrnPropertiesReader.getVariable("aai.auth", execution), UrnPropertiesReader.getVariable("mso.msoKey", execution)) client.addAdditionalHeader("X-FromAppId", "MSO") client.addAdditionalHeader("X-TransactionId", utils.getRequestID()) diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtils.groovy index 22b5de2e4b..df0dfaee60 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtils.groovy @@ -418,7 +418,7 @@ class CatalogDbUtils { String catalogDbEndpoint = UrnPropertiesReader.getVariable("mso.catalog.db.endpoint",execution) String queryEndpoint = catalogDbEndpoint + "/" + defaultDbAdapterVersion + endPoint def responseData = '' - HttpClient client = httpClientFactory.create(new URL(queryEndpoint), MediaType.APPLICATION_JSON, TargetEntity.CATALOG_DB) + HttpClient client = httpClientFactory.newJsonClient(new URL(queryEndpoint), TargetEntity.CATALOG_DB) client.addAdditionalHeader(ONAPLogConstants.Headers.REQUEST_ID, UUID.randomUUID().toString()) client.addAdditionalHeader('X-FromAppId', "BPMN") client.addAdditionalHeader('Accept', MediaType.APPLICATION_JSON) diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtil.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtil.groovy index 250cdda0a1..94c82f5a0c 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtil.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtil.groovy @@ -141,7 +141,7 @@ class ExternalAPIUtil { msoLogger.debug( "Generated uuid is: " + uuid) msoLogger.debug( "URL to be used is: " + url) - HttpClient client = httpClientFactory.create(new URL(url), MediaType.APPLICATION_JSON, TargetEntity.EXTERNAL) + HttpClient client = httpClientFactory.newJsonClient(new URL(url), TargetEntity.EXTERNAL) client.addBasicAuthHeader(execution.getVariable("URN_externalapi_auth"), execution.getVariable("URN_mso_msoKey")) client.addAdditionalHeader("X-FromAppId", "MSO") client.addAdditionalHeader(ONAPLogConstants.Headers.REQUEST_ID, uuid) @@ -177,7 +177,7 @@ class ExternalAPIUtil { msoLogger.debug( "Generated uuid is: " + uuid) msoLogger.debug( "URL to be used is: " + url) - HttpClient httpClient = httpClientFactory.create(new URL(url), MediaType.APPLICATION_JSON, TargetEntity.AAI) + HttpClient httpClient = httpClientFactory.newJsonClient(new URL(url), TargetEntity.AAI) httpClient.addBasicAuthHeader(execution.getVariable("URN_externalapi_auth"), execution.getVariable("URN_mso_msoKey")) httpClient.addAdditionalHeader("X-FromAppId", "MSO") httpClient.addAdditionalHeader("X-TransactionId", uuid) diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenerateVfModuleName.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenerateVfModuleName.groovy index c961dd06eb..1be24c4ce0 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenerateVfModuleName.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenerateVfModuleName.groovy @@ -21,6 +21,7 @@ package org.onap.so.bpmn.common.scripts import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.client.HttpClientFactory import java.io.Serializable; @@ -86,7 +87,8 @@ public class GenerateVfModuleName extends AbstractServiceTaskProcessor{ msoLogger.debug("AAI endPoint: " + endPoint) try { - HttpClient client = new HttpClient(new URL(endPoint), MediaType.APPLICATION_XML, TargetEntity.AAI) + HttpClient client = new HttpClientFactory().newXmlClient(new URL(endPoint), TargetEntity.AAI) + client.addAdditionalHeader('X-TransactionId', UUID.randomUUID().toString()) client.addAdditionalHeader('X-FromAppId', 'MSO') client.addAdditionalHeader('Content-Type', 'application/xml') diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy index ee93f3a445..5659c7affa 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy @@ -31,6 +31,7 @@ import org.onap.so.bpmn.core.domain.Subscriber import org.onap.so.bpmn.core.domain.VnfResource import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.client.HttpClient +import org.onap.so.client.HttpClientFactory import org.onap.so.logger.MsoLogger import org.onap.so.db.catalog.beans.CloudIdentity import org.onap.so.db.catalog.beans.CloudSite @@ -159,8 +160,8 @@ class OofHoming extends AbstractServiceTaskProcessor { URL url = new URL(urlString); - HttpClient httpClient = new HttpClient(url, "application/json", TargetEntity.SNIRO) - httpClient.addAdditionalHeader("Authorization", authHeader) + HttpClient httpClient = new HttpClientFactory().newJsonClient(url, TargetEntity.SNIRO) + httpClient.addAdditionalHeader("Authorization", authHeader) Response httpResponse = httpClient.post(oofRequest) int responseCode = httpResponse.getStatus() diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy index 46ecc7bbe6..c0da8881fb 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy @@ -34,6 +34,7 @@ import org.onap.so.bpmn.core.domain.Subscriber import org.onap.so.bpmn.core.domain.VnfResource import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.client.HttpClient +import org.onap.so.client.HttpClientFactory import org.onap.so.db.catalog.beans.CloudSite import org.onap.so.utils.TargetEntity import org.springframework.http.HttpEntity @@ -507,10 +508,10 @@ class OofUtils { String auth = UrnPropertiesReader.getVariable("mso.db.auth", execution) String uri = "/cloudSite" - URL url = new URL(endpoint + uri) - HttpClient client = new HttpClient(url, MediaType.APPLICATION_JSON, TargetEntity.EXTERNAL) - client.addAdditionalHeader(HttpHeaders.AUTHORIZATION, auth) - client.addAdditionalHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON) + URL url = new URL(endpoint + uri) + HttpClient client = new HttpClientFactory().newJsonClient(url, TargetEntity.EXTERNAL) + client.addAdditionalHeader(HttpHeaders.AUTHORIZATION, auth) + client.addAdditionalHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON) Response response = client.post(request.getBody().toString()) diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy index 0cefae526e..9f1570ee15 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy @@ -20,6 +20,8 @@ package org.onap.so.bpmn.common.scripts +import org.onap.so.client.HttpClientFactory + import java.text.SimpleDateFormat import javax.ws.rs.core.Response import java.net.URLEncoder @@ -207,7 +209,7 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor { URL url = new URL(sdncAdapterUrl); - HttpClient httpClient = new HttpClient(url, "application/json", TargetEntity.SDNC_ADAPTER) + HttpClient httpClient = new HttpClientFactory().newJsonClient(url, TargetEntity.SDNC_ADAPTER) httpClient.addAdditionalHeader("X-ONAP-RequestID", execution.getVariable("mso-request-id")) httpClient.addAdditionalHeader("X-ONAP-InvocationID", UUID.randomUUID().toString()) httpClient.addAdditionalHeader("X-ONAP-PartnerName", "SO-SDNCAdapter") diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SniroHomingV1.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SniroHomingV1.groovy index 401cac9820..9556ae7d6a 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SniroHomingV1.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SniroHomingV1.groovy @@ -34,6 +34,7 @@ import org.onap.so.bpmn.core.domain.Subscriber import org.onap.so.bpmn.core.domain.VnfResource import org.onap.so.bpmn.core.json.JsonUtils import org.onap.so.client.HttpClient +import org.onap.so.client.HttpClientFactory import org.onap.so.utils.TargetEntity import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor @@ -133,7 +134,7 @@ class SniroHomingV1 extends AbstractServiceTaskProcessor{ msoLogger.debug("Sniro Url is: " + urlString) URL url = new URL(urlString); - HttpClient httpClient = new HttpClient(url, "application/json", TargetEntity.SNIRO) + HttpClient httpClient = new HttpClientFactory().newJsonClient(url, TargetEntity.SNIRO) httpClient.addAdditionalHeader("Authorization", authHeader) Response httpResponse = httpClient.post(sniroRequest) diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy index 1452a9ad8d..8aff0f715d 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy @@ -20,6 +20,8 @@ package org.onap.so.bpmn.common.scripts +import org.onap.so.client.HttpClientFactory + import javax.ws.rs.core.Response import org.apache.commons.lang3.* import org.camunda.bpm.engine.delegate.BpmnError @@ -311,7 +313,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { URL url = new URL(vnfAdapterUrl); - HttpClient httpClient = new HttpClient(url, "application/xml", TargetEntity.VNF_ADAPTER) + HttpClient httpClient = new HttpClientFactory().newXmlClient(url, TargetEntity.VNF_ADAPTER) httpClient.addAdditionalHeader("Authorization", execution.getVariable(prefix + "basicAuthHeaderValue")) httpClient.addAdditionalHeader("X-ONAP-RequestID", execution.getVariable("mso-request-id")) |