summaryrefslogtreecommitdiffstats
path: root/bpmn/MSOCommonBPMN/src/main/groovy/org/onap
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/MSOCommonBPMN/src/main/groovy/org/onap')
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AaiUtil.groovy397
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtils.groovy52
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExternalAPIUtil.groovy85
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenerateVfModuleName.groovy67
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/NetworkUtils.groovy169
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy34
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy25
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModule.groovy82
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy36
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV2.groovy23
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SniroHomingV1.groovy28
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy40
12 files changed, 293 insertions, 745 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 8a262251b1..8cc232c2a4 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
@@ -22,20 +22,21 @@ package org.onap.so.bpmn.common.scripts
import java.util.regex.Matcher
import java.util.regex.Pattern
+import javax.ws.rs.core.MediaType
+import javax.ws.rs.core.Response
import javax.ws.rs.core.UriBuilder
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
import org.onap.aai.domain.yang.GenericVnf
import org.onap.so.bpmn.core.UrnPropertiesReader;
+import org.onap.so.client.HttpClient
import org.onap.so.client.aai.AAIVersion
import org.onap.so.client.aai.entities.uri.AAIUri
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
import org.onap.so.openpojo.rules.HasToStringRule
-import org.onap.so.rest.APIResponse;
-import org.onap.so.rest.RESTClient
-import org.onap.so.rest.RESTConfig
+import org.onap.so.utils.TargetEntity
@Deprecated
class AaiUtil {
@@ -54,37 +55,6 @@ class AaiUtil {
this.taskProcessor = taskProcessor
}
- public String getBusinessSPPartnerUri(DelegateExecution execution) {
- def uri = getUri(execution, 'sp-partner')
- msoLogger.debug('AaiUtil.getBusinessSPPartnerUri() - AAI URI: ' + uri)
- return uri
- }
-
- public String getVersion(DelegateExecution execution, resourceName, processKey) {
- def versionWithResourceKey = "mso.workflow.default.aai.${resourceName}.version"
- def versionWithProcessKey = "mso.workflow.custom.${processKey}.aai.version"
-
- def version = UrnPropertiesReader.getVariable(versionWithProcessKey, execution)
- if (version) {
- msoLogger.debug("AaiUtil.getVersion() - using flow specific ${versionWithProcessKey}=${version}")
- return version
- }
-
- version = UrnPropertiesReader.getVariable(versionWithResourceKey, execution)
- if (version) {
- msoLogger.debug("AaiUtil.getVersion() - using resource specific ${versionWithResourceKey}=${version}")
- return version
- }
-
- version = UrnPropertiesReader.getVariable(DEFAULT_VERSION_KEY, execution)
- if (version) {
- msoLogger.debug("AaiUtil.getVersion() - using default version ${DEFAULT_VERSION_KEY}=${version}")
- return version
- }
-
- (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, "Internal Error: One of the following should be defined in MSO URN properties file: ${versionWithResourceKey}, ${versionWithProcessKey}, ${DEFAULT_VERSION_KEY}")
- }
-
public String createAaiUri(AAIUri uri) {
return createAaiUri(AAIVersion.valueOf('V' + UrnPropertiesReader.getVariable(DEFAULT_VERSION_KEY)), uri)
}
@@ -94,14 +64,6 @@ class AaiUtil {
return UriBuilder.fromUri(result + uri.build().toString()).build().toString()
}
- public String setNamespace(DelegateExecution execution) {
- def key = AAI_NAMESPACE_STRING_KEY
- aaiNamespace = UrnPropertiesReader.getVariable(key, execution)
- if (aaiNamespace == null ) {
- (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, 'Internal Error: AAI URI entry for ' + key + ' not defined in the MSO URN properties file')
- }
- }
-
public String getNamespace() {
return getNamespace(AAIVersion.valueOf('V' + UrnPropertiesReader.getVariable(DEFAULT_VERSION_KEY)))
}
@@ -114,330 +76,6 @@ class AaiUtil {
return namespace + version
}
- /**
- * This method can be used for getting the building namespace out of uri.
- * NOTE: A getUri() method needs to be invoked first.
- * Alternative method is the getNamespaceFromUri(DelegateExecution execution, String uri)
- * return namespace (plus version from uri)
- *
- * @param url
- *
- * @return namespace
- */
- public String getNamespaceFromUri(String uri) {
- String namespace = UrnPropertiesReader.getVariable(AAI_NAMESPACE_STRING_KEY)
- if (namespace == null) {
- throw new Exception('Internal Error: AAI Namespace has not been set yet. A getUri() method needs to be invoked first.')
- }
- if(uri!=null){
- String version = getVersionFromUri(uri)
- return namespace + "v"+version
- }else{
- return namespace
- }
- }
-
- /**
- * This method can be used for building namespace with aai version out of uri.
- * NOTE: 2 arguments: DelegateExecution execution & String uri
- * @param execution
- * @param url
- *
- * @return namespace
- */
- public String getNamespaceFromUri(DelegateExecution execution, String uri) {
- String namespace = UrnPropertiesReader.getVariable(AAI_NAMESPACE_STRING_KEY, execution)
- if (namespace == null ) {
- (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, 'Internal Error: AAI URI entry for ' + AAI_NAMESPACE_STRING_KEY + ' not defined in the MSO URN properties file')
- }
- if(uri!=null){
- String version = getVersionFromUri(uri)
- return namespace + "v"+version
- }else{
- return namespace
- }
- }
-
- /**
- * This is used to extract the version from uri.
- *
- * @param uri
- *
- * @return version
- */
- private String getVersionFromUri(String uri) {
-
- Matcher versionRegEx = Pattern.compile("/v(\\d+)").matcher(uri)
- if (versionRegEx.find()) {
- return versionRegEx.group(1);
- }
-
- return "";
- }
-
-
- /**
- * This reusable method can be used for making AAI Get Calls. The url should
- * be passed as a parameter along with the execution. The method will
- * return an APIResponse.
- *
- * @param execution
- * @param url
- *
- * @return APIResponse
- *
- */
- public APIResponse executeAAIGetCall(DelegateExecution execution, String url){
- msoLogger.trace("STARTED Execute AAI Get Process ")
- APIResponse apiResponse = null
- try{
- String uuid = utils.getRequestID()
- msoLogger.debug("Generated uuid is: " + uuid)
- msoLogger.debug("URL to be used is: " + url)
-
- String basicAuthCred = utils.getBasicAuth(UrnPropertiesReader.getVariable("aai.auth", execution),UrnPropertiesReader.getVariable("mso.msoKey", execution))
-
- RESTConfig config = new RESTConfig(url);
- RESTClient client = new RESTClient(config).addHeader("X-FromAppId", "MSO").addHeader("X-TransactionId", uuid).addHeader("Accept","application/xml");
-
- if (basicAuthCred != null && !"".equals(basicAuthCred)) {
- client.addAuthorizationHeader(basicAuthCred)
- }
- apiResponse = client.httpGet()
-
- msoLogger.trace("COMPLETED Execute AAI Get Process ")
- }catch(Exception e){
- msoLogger.debug("Exception occured while executing AAI Get Call. Exception is: \n" + e)
- (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, e.getMessage())
- }
- return apiResponse
- }
-
-
- /**
- * This reusable method can be used for making AAI httpPut Calls. The url should
- * be passed as a parameter along with the execution and payload. The method will
- * return an APIResponse.
- *
- * @param execution
- * @param url
- * @param payload
- *
- * @return APIResponse
- *
- */
- public APIResponse executeAAIPutCall(DelegateExecution execution, String url, String payload){
- msoLogger.trace("Started Execute AAI Put Process ")
- APIResponse apiResponse = null
- try{
- String uuid = utils.getRequestID()
- msoLogger.debug("Generated uuid is: " + uuid)
- msoLogger.debug("URL to be used is: " + url)
-
- String basicAuthCred = utils.getBasicAuth(UrnPropertiesReader.getVariable("aai.auth", execution),UrnPropertiesReader.getVariable("mso.msoKey", execution))
-
- RESTConfig config = new RESTConfig(url);
- RESTClient client = new RESTClient(config).addHeader("X-FromAppId", "MSO").addHeader("X-TransactionId", uuid).addHeader("Content-Type", "application/xml").addHeader("Accept","application/xml");
- if (basicAuthCred != null && !"".equals(basicAuthCred)) {
- client.addAuthorizationHeader(basicAuthCred)
- }
- apiResponse = client.httpPut(payload)
-
- msoLogger.trace("Completed Execute AAI Put Process ")
- }catch(Exception e){
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception occured while executing AAI Put Call.", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e);
- (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, e.getMessage())
- }
- return apiResponse
- }
-
- /**
- * This reusable method can be used for making AAI httpPatch Calls. The url should
- * be passed as a parameter along with the execution and payload. The method will
- * return an APIResponse.
- *
- * @param execution
- * @param url
- * @param payload
- *
- * @return APIResponse
- *
- */
- public APIResponse executeAAIPatchCall(DelegateExecution execution, String url, String payload){
- msoLogger.trace("Started Execute AAI Patch Process ")
- APIResponse apiResponse = null
- try{
- String uuid = utils.getRequestID()
- msoLogger.debug("Generated uuid is: " + uuid)
-
- msoLogger.debug("URL to be used is: " + url)
-
- String basicAuthCred = utils.getBasicAuth(UrnPropertiesReader.getVariable("aai.auth", execution),UrnPropertiesReader.getVariable("mso.msoKey", execution))
-
- RESTConfig config = new RESTConfig(url);
- RESTClient client = new RESTClient(config).addHeader("X-FromAppId", "MSO").addHeader("X-TransactionId", uuid).addHeader("Content-Type", "application/merge-patch+json").addHeader("Accept","application/json");
- if (basicAuthCred != null && !"".equals(basicAuthCred)) {
- client.addAuthorizationHeader(basicAuthCred)
- }
- apiResponse = client.httpPatch(payload)
-
- msoLogger.trace("Completed Execute AAI Patch Process ")
- }catch(Exception e){
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception occured while executing AAI Patch Call.", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e);
- (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, e.getMessage())
- }
- return apiResponse
- }
-
-
- /**
- * This reusable method can be used for making AAI Delete Calls. The url should
- * be passed as a parameter along with the execution. The method will
- * return an APIResponse.
- *
- * @param execution
- * @param url
- *
- * @return APIResponse
- *
- */
- public APIResponse executeAAIDeleteCall(DelegateExecution execution, String url){
- msoLogger.trace("Started Execute AAI Delete Process ")
- APIResponse apiResponse = null
- try{
- String uuid = utils.getRequestID()
- msoLogger.debug("Generated uuid is: " + uuid)
- msoLogger.debug("URL to be used is: " + url)
-
- String basicAuthCred = utils.getBasicAuth(UrnPropertiesReader.getVariable("aai.auth", execution),UrnPropertiesReader.getVariable("mso.msoKey", execution))
-
- RESTConfig config = new RESTConfig(url);
- RESTClient client = new RESTClient(config).addHeader("X-FromAppId", "MSO").addHeader("X-TransactionId", uuid).addHeader("Accept","application/xml");
- if (basicAuthCred != null && !"".equals(basicAuthCred)) {
- client.addAuthorizationHeader(basicAuthCred)
- }
- apiResponse = client.delete()
-
- msoLogger.trace("Completed Execute AAI Delete Process ")
- }catch(Exception e){
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception occured while executing AAI Delete Call.", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e);
- (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, e.getMessage())
- }
- return apiResponse
- }
-
- /**
- * This reusable method can be used for making AAI Delete Calls. The url should
- * be passed as a parameter along with the execution. The method will
- * return an APIResponse.
- *
- * @param execution
- * @param url
- * @param payload
- *
- * @return APIResponse
- *
- */
- public APIResponse executeAAIDeleteCall(DelegateExecution execution, String url, String payload, String authHeader){
- msoLogger.trace("Started Execute AAI Delete Process ")
- APIResponse apiResponse = null
- try{
- String uuid = utils.getRequestID()
- msoLogger.debug("Generated uuid is: " + uuid)
-
- msoLogger.debug("URL to be used is: " + url)
-
- String basicAuthCred = utils.getBasicAuth(UrnPropertiesReader.getVariable("aai.auth", execution),UrnPropertiesReader.getVariable("mso.msoKey", execution))
- RESTConfig config = new RESTConfig(url);
- RESTClient client = new RESTClient(config).addHeader("X-FromAppId", "MSO").addHeader("X-TransactionId", uuid).addHeader("Accept","application/xml").addAuthorizationHeader(authHeader);
- if (basicAuthCred != null && !"".equals(basicAuthCred)) {
- client.addAuthorizationHeader(basicAuthCred)
- }
- apiResponse = client.httpDelete(payload)
-
- msoLogger.trace("Completed Execute AAI Delete Process ")
- }catch(Exception e){
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception occured while executing AAI Delete Call.", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e);
- (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, e.getMessage())
- }
- return apiResponse
- }
-
- /**
- * This reusable method can be used for making AAI Post Calls. The url
- * and payload should be passed as a parameters along with the execution.
- * The method will return an APIResponse.
- *
- * @param execution
- * @param url
- * @param payload
- *
- * @return APIResponse
- *
- */
- public APIResponse executeAAIPostCall(DelegateExecution execution, String url, String payload){
- msoLogger.trace("Started Execute AAI Post Process ")
- APIResponse apiResponse = null
- try{
- String uuid = utils.getRequestID()
- msoLogger.debug("Generated uuid is: " + uuid)
- msoLogger.debug("URL to be used is: " + url)
-
- String basicAuthCred = utils.getBasicAuth(UrnPropertiesReader.getVariable("aai.auth", execution),UrnPropertiesReader.getVariable("mso.msoKey", execution))
- RESTConfig config = new RESTConfig(url);
- RESTClient client = new RESTClient(config).addHeader("X-FromAppId", "MSO").addHeader("X-TransactionId", uuid).addHeader("Accept","application/xml");
-
- if (basicAuthCred != null && !"".equals(basicAuthCred)) {
- client.addAuthorizationHeader(basicAuthCred)
- }
- apiResponse = client.httpPost(payload)
-
- msoLogger.trace("Completed Execute AAI Post Process ")
- }catch(Exception e){
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception occured while executing AAI Post Call.", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e);
- (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, e.getMessage())
- }
- return apiResponse
- }
-
- /**
- * This reusable method can be used for making AAI Post Calls. The url
- * and payload should be passed as a parameters along with the execution.
- * The method will return an APIResponse.
- *
- * @param execution
- * @param url
- * @param payload
- * @param authenticationHeader - addAuthenticationHeader value
- * @param headerName - name of header you want to add, i.e. addHeader(headerName, headerValue)
- * @param headerValue - the header's value, i.e. addHeader(headerName, headerValue)
- *
- * @return APIResponse
- *
- */
- public APIResponse executeAAIPostCall(DelegateExecution execution, String url, String payload, String authenticationHeaderValue, String headerName, String headerValue){
- msoLogger.trace("Started Execute AAI Post Process ")
- APIResponse apiResponse = null
- try{
- msoLogger.debug("URL to be used is: " + url)
-
- String basicAuthCred = utils.getBasicAuth(UrnPropertiesReader.getVariable("aai.auth", execution),UrnPropertiesReader.getVariable("mso.msoKey", execution))
-
- RESTConfig config = new RESTConfig(url);
- RESTClient client = new RESTClient(config).addAuthorizationHeader(authenticationHeaderValue).addHeader(headerName, headerValue)
- if (basicAuthCred != null && !"".equals(basicAuthCred)) {
- client.addAuthorizationHeader(basicAuthCred)
- }
- apiResponse = client.httpPost(payload)
-
- msoLogger.trace("Completed Execute AAI Post Process ")
- }catch(Exception e){
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception occured while executing AAI Post Call.", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e);
- (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, e.getMessage())
- }
- return apiResponse
- }
-
/* Utility to get the Cloud Region from AAI
* Returns String cloud region id, (ie, cloud-region-id)
@@ -449,9 +87,17 @@ class AaiUtil {
public String getAAICloudReqion(DelegateExecution execution, String url, String backend, inputCloudRegion){
String regionId = ""
try{
- APIResponse apiResponse = executeAAIGetCall(execution, url)
- String returnCode = apiResponse.getStatusCode()
- String aaiResponseAsString = apiResponse.getResponseBodyAsString()
+ URL Url = new URL(url)
+ HttpClient client = new HttpClient(Url, MediaType.APPLICATION_XML, 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())
+ client.addAdditionalHeader("Accept", MediaType.APPLICATION_XML)
+
+ Response apiResponse = client.get()
+
+ String returnCode = apiResponse.getStatus()
+ String aaiResponseAsString = apiResponse.readEntity(String.class)
msoLogger.debug("Call AAI Cloud Region Return code: " + returnCode)
execution.setVariable(execution.getVariable("prefix")+"queryCloudRegionReturnCode", returnCode)
@@ -491,19 +137,6 @@ class AaiUtil {
return regionId
}
- /* returns xml Node with service-type of searchValue */
- def searchServiceType(xmlInput, searchValue){
- def fxml= new XmlSlurper().parseText(xmlInput)
- def ret = fxml.'**'.find {it.'service-type' == searchValue}
- return ret
- }
-
- /* returns xml Node with service-instance-id of searchValue */
- def searchServiceInstanceId(xmlInput, searchValue){
- def ret = xmlInput.'**'.find {it.'service-instance-id' == searchValue}
- return ret
- }
-
/**
* Get the lowest unused VF Module index from AAI response for a given module type. The criteria for
* determining module type is specified by "key" parameter (for example, "persona-model-id"),
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 9ce29dedb8..d5183ff5bb 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
@@ -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.
@@ -23,23 +23,23 @@ package org.onap.so.bpmn.common.scripts
import org.json.JSONObject;
import org.json.JSONArray;
import org.json.XML
+import org.onap.logging.ref.slf4j.ONAPLogConstants
import org.onap.so.bpmn.core.UrnPropertiesReader;
import org.springframework.web.util.UriUtils;
import org.onap.so.bpmn.core.json.JsonUtils
-
-
+import org.onap.so.client.HttpClient
import groovy.json.JsonBuilder
import groovy.json.JsonSlurper
import groovy.util.slurpersupport.GPathResult
import groovy.xml.QName;
+import javax.ws.rs.core.MediaType
+import javax.ws.rs.core.Response
import org.camunda.bpm.engine.delegate.DelegateExecution
import org.onap.so.logger.MsoLogger;
-import org.onap.so.rest.APIResponse;
-import org.onap.so.rest.RESTClient
-import org.onap.so.rest.RESTConfig
+import org.onap.so.utils.TargetEntity
import org.onap.so.logger.MessageEnum
@@ -731,12 +731,12 @@ class CatalogDbUtils {
String endPoint = "/serviceResources?serviceModelUuid=" + UriUtils.encode(serviceModelUuid, "UTF-8")
try {
String catalogDbResponse = getResponseFromCatalogDb(execution, endPoint)
-
+
if (catalogDbResponse != null) {
-
+
resources = parseServiceResourcesJson(catalogDbResponse, "v1")
}
-
+
}
catch (Exception e) {
utils.log("ERROR", "Exception in Querying Catalog DB: " + e.message)
@@ -1230,32 +1230,32 @@ class CatalogDbUtils {
String catalogDbEndpoint = UrnPropertiesReader.getVariable("mso.catalog.db.endpoint",execution)
String queryEndpoint = catalogDbEndpoint + "/" + defaultDbAdapterVersion + endPoint
- RESTConfig config = new RESTConfig(queryEndpoint);
def responseData = ''
def bpmnRequestId = UUID.randomUUID().toString()
- RESTClient client = new RESTClient(config).
- addHeader('X-TransactionId', bpmnRequestId).
- addHeader('X-FromAppId', 'BPMN').
- addHeader('Content-Type', 'application/json').
- addHeader('Accept','application/json');
+ URL url = new URL(queryEndpoint)
+ HttpClient client = new HttpClient(url, MediaType.APPLICATION_JSON, TargetEntity.CATALOG_DB)
+ client.addAdditionalHeader(ONAPLogConstants.Headers.REQUEST_ID, bpmnRequestId)
+ client.addAdditionalHeader('X-FromAppId', "BPMN")
+ client.addAdditionalHeader('Accept', MediaType.APPLICATION_JSON)
String basicAuthCred = execution.getVariable("BasicAuthHeaderValueDB")
if (basicAuthCred != null && !"".equals(basicAuthCred)) {
- client.addAuthorizationHeader(basicAuthCred)
+ client.addAdditionalHeader("Authorization", basicAuthCred)
}else {
- client.addAuthorizationHeader(getBasicDBAuthHeader(execution))
+ client.addAdditionalHeader("Authorization", getBasicDBAuthHeader(execution))
}
+
msoLogger.debug('sending GET to Catalog DB endpoint: ' + endPoint)
- APIResponse response = client.httpGet()
+ Response response = client.get()
- responseData = response.getResponseBodyAsString()
+ responseData = response.readEntity(String.class)
if (responseData != null) {
msoLogger.debug("Received data from Catalog DB: " + responseData)
}
- msoLogger.debug('Response code:' + response.getStatusCode())
+ msoLogger.debug('Response code:' + response.getStatus())
msoLogger.debug('Response:' + System.lineSeparator() + responseData)
- if (response.getStatusCode() == 200) {
+ if (response.getStatus() == 200) {
// parse response as needed
return responseData
}
@@ -1291,14 +1291,14 @@ class CatalogDbUtils {
return responseJson
}
-
+
private String getBasicDBAuthHeader(DelegateExecution execution) {
-
+
String encodedString = null
try {
String basicAuthValueDB = UrnPropertiesReader.getVariable("mso.adapters.db.auth", execution)
utils.log("DEBUG", " Obtained BasicAuth userid password for Catalog DB adapter: " + basicAuthValueDB)
-
+
encodedString = utils.getBasicAuth(basicAuthValueDB, UrnPropertiesReader.getVariable("mso.msoKey", execution))
execution.setVariable("BasicAuthHeaderValueDB",encodedString)
} catch (IOException ex) {
@@ -1307,5 +1307,5 @@ class CatalogDbUtils {
}
return encodedString
}
-
+
} \ No newline at end of file
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 3096bedda6..5c935e9081 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
@@ -22,14 +22,16 @@ package org.onap.so.bpmn.common.scripts
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor;
+import org.onap.so.client.HttpClient
import org.onap.so.logger.MsoLogger
-import org.onap.so.rest.APIResponse
-import org.onap.so.rest.RESTClient
-import org.onap.so.rest.RESTConfig
import org.apache.commons.lang3.StringEscapeUtils
import java.util.regex.Matcher
import java.util.regex.Pattern
+import javax.ws.rs.core.MediaType
+import javax.ws.rs.core.Response
+import org.onap.so.utils.TargetEntity
+
class ExternalAPIUtil {
String Prefix="EXTAPI_"
@@ -127,23 +129,22 @@ class ExternalAPIUtil {
* @return APIResponse
*
*/
- public APIResponse executeExternalAPIGetCall(DelegateExecution execution, String url){
+ public Response executeExternalAPIGetCall(DelegateExecution execution, String url){
msoLogger.debug(" ======== STARTED Execute ExternalAPI Get Process ======== ")
- APIResponse apiResponse = null
+ Response apiResponse = null
try{
String uuid = utils.getRequestID()
msoLogger.debug( "Generated uuid is: " + uuid)
msoLogger.debug( "URL to be used is: " + url)
- String basicAuthCred = utils.getBasicAuth(execution.getVariable("URN_externalapi_auth"),execution.getVariable("URN_mso_msoKey"))
-
- RESTConfig config = new RESTConfig(url);
- RESTClient client = new RESTClient(config).addHeader("X-FromAppId", "MSO").addHeader("X-TransactionId", uuid).addHeader("Accept","application/json");
+ URL Url = new URL(url)
+ HttpClient client = new HttpClient(Url, MediaType.APPLICATION_JSON, 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)
+ client.addAdditionalHeader("Accept", MediaType.APPLICATION_JSON)
- if (basicAuthCred != null && !"".equals(basicAuthCred)) {
- client.addAuthorizationHeader(basicAuthCred)
- }
- apiResponse = client.httpGet()
+ apiResponse = client.get()
msoLogger.debug( "======== COMPLETED Execute ExternalAPI Get Process ======== ")
}catch(Exception e){
@@ -162,25 +163,25 @@ class ExternalAPIUtil {
* @param url
* @param payload
*
- * @return APIResponse
+ * @return Response
*
*/
- public APIResponse executeExternalAPIPostCall(DelegateExecution execution, String url, String payload){
+ public Response executeExternalAPIPostCall(DelegateExecution execution, String urlString, String payload){
msoLogger.debug( " ======== Started Execute ExternalAPI Post Process ======== ")
- APIResponse apiResponse = null
+ Response apiResponse = null
try{
String uuid = utils.getRequestID()
msoLogger.debug( "Generated uuid is: " + uuid)
- msoLogger.debug( "URL to be used is: " + url)
+ msoLogger.debug( "URL to be used is: " + urlString)
- String basicAuthCred = utils.getBasicAuth(execution.getVariable("URN_externalapi_auth"),execution.getVariable("URN_mso_msoKey"))
- RESTConfig config = new RESTConfig(url);
- RESTClient client = new RESTClient(config).addHeader("X-FromAppId", "MSO").addHeader("X-TransactionId", uuid).addHeader("Content-Type", "application/json").addHeader("Accept","application/json");
+ URL url = new URL(urlString);
- if (basicAuthCred != null && !"".equals(basicAuthCred)) {
- client.addAuthorizationHeader(basicAuthCred)
- }
- apiResponse = client.httpPost(payload)
+ HttpClient httpClient = new HttpClient(url, "application/json", TargetEntity.AAI)
+ httpClient.addBasicAuthHeader(execution.getVariable("URN_externalapi_auth"), execution.getVariable("URN_mso_msoKey"))
+ httpClient.addAdditionalHeader("X-FromAppId", "MSO")
+ httpClient.addAdditionalHeader("X-TransactionId", uuid)
+
+ apiResponse = httpClient.post(payload)
msoLogger.debug( "======== Completed Execute ExternalAPI Post Process ======== ")
}catch(Exception e){
@@ -190,42 +191,6 @@ class ExternalAPIUtil {
return apiResponse
}
- /**
- * This reusable method can be used for making ExternalAPI Post Calls. The url
- * and payload should be passed as a parameters along with the execution.
- * The method will return an APIResponse.
- *
- * @param execution
- * @param url
- * @param payload
- * @param authenticationHeader - addAuthenticationHeader value
- * @param headerName - name of header you want to add, i.e. addHeader(headerName, headerValue)
- * @param headerValue - the header's value, i.e. addHeader(headerName, headerValue)
- *
- * @return APIResponse
- *
- */
- public APIResponse executeExternalAPIPostCall(DelegateExecution execution, String url, String payload, String authenticationHeaderValue, String headerName, String headerValue){
- msoLogger.debug( " ======== Started Execute ExternalAPI Post Process ======== ")
- APIResponse apiResponse = null
- try{
- msoLogger.debug( "URL to be used is: " + url)
-
- String basicAuthCred = utils.getBasicAuth(execution.getVariable("URN_externalapi_auth"),execution.getVariable("URN_mso_msoKey"))
-
- RESTConfig config = new RESTConfig(url);
- RESTClient client = new RESTClient(config).addAuthorizationHeader(authenticationHeaderValue).addHeader(headerName, headerValue)
- if (basicAuthCred != null && !"".equals(basicAuthCred)) {
- client.addAuthorizationHeader(basicAuthCred)
- }
- apiResponse = client.httpPost(payload)
- msoLogger.debug( "======== Completed Execute ExternalAPI Post Process ======== ")
- }catch(Exception e){
- msoLogger.error("Exception occured while executing ExternalAPI Post Call. Exception is: \n" + e)
- exceptionUtil.buildAndThrowWorkflowException(execution, 9999, e.getMessage())
- }
- return apiResponse
- }
} \ No newline at end of file
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 78d147e819..c961dd06eb 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
@@ -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.
@@ -24,19 +24,20 @@ import org.onap.so.bpmn.core.UrnPropertiesReader
import java.io.Serializable;
+import javax.ws.rs.core.MediaType
+import javax.ws.rs.core.Response
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
import org.springframework.web.util.UriUtils
import org.onap.so.bpmn.core.json.JsonUtils
import org.onap.so.bpmn.core.WorkflowException
+import org.onap.so.client.HttpClient
import org.onap.so.client.aai.AAIObjectType
import org.onap.so.client.aai.entities.uri.AAIResourceUri
import org.onap.so.client.aai.entities.uri.AAIUriFactory
import org.onap.so.client.graphinventory.entities.uri.Depth
-import org.onap.so.rest.APIResponse;
-import org.onap.so.rest.RESTClient
-import org.onap.so.rest.RESTConfig
+import org.onap.so.utils.TargetEntity
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
@@ -46,8 +47,8 @@ public class GenerateVfModuleName extends AbstractServiceTaskProcessor{
def Prefix="GVFMN_"
ExceptionUtil exceptionUtil = new ExceptionUtil()
-
-
+
+
public void preProcessRequest(DelegateExecution execution) {
try {
def vnfId = execution.getVariable("vnfId")
@@ -76,7 +77,7 @@ public class GenerateVfModuleName extends AbstractServiceTaskProcessor{
try {
def vnfId = execution.getVariable('vnfId')
def personaModelId = execution.getVariable('personaModelId')
-
+
AaiUtil aaiUtil = new AaiUtil(this)
AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)
uri.depth(Depth.ONE)
@@ -85,34 +86,34 @@ public class GenerateVfModuleName extends AbstractServiceTaskProcessor{
msoLogger.debug("AAI endPoint: " + endPoint)
try {
- RESTConfig config = new RESTConfig(endPoint);
+ HttpClient client = new HttpClient(new URL(endPoint), MediaType.APPLICATION_XML, TargetEntity.AAI)
+ client.addAdditionalHeader('X-TransactionId', UUID.randomUUID().toString())
+ client.addAdditionalHeader('X-FromAppId', 'MSO')
+ client.addAdditionalHeader('Content-Type', 'application/xml')
+ client.addAdditionalHeader('Accept','application/xml')
+
def responseData = ''
- def aaiRequestId = UUID.randomUUID().toString()
- RESTClient client = new RESTClient(config).
- addHeader('X-TransactionId', aaiRequestId).
- addHeader('X-FromAppId', 'MSO').
- addHeader('Content-Type', 'application/xml').
- addHeader('Accept','application/xml');
+
msoLogger.debug('sending GET to AAI endpoint \'' + endPoint + '\'')
- APIResponse response = client.httpGet()
+ Response response = client.get()
msoLogger.debug("GenerateVfModuleName - invoking httpGet() to AAI")
- responseData = response.getResponseBodyAsString()
+ responseData = response.readEntity(String.class)
if (responseData != null) {
msoLogger.debug("Received generic VNF data: " + responseData)
}
msoLogger.debug("GenerateVfModuleName - queryAAIVfModule Response: " + responseData)
- msoLogger.debug("GenerateVfModuleName - queryAAIVfModule ResponseCode: " + response.getStatusCode())
+ msoLogger.debug("GenerateVfModuleName - queryAAIVfModule ResponseCode: " + response.getStatus())
- execution.setVariable('GVFMN_queryAAIVfModuleResponseCode', response.getStatusCode())
+ execution.setVariable('GVFMN_queryAAIVfModuleResponseCode', response.getStatus())
execution.setVariable('GVFMN_queryAAIVfModuleResponse', responseData)
- msoLogger.debug('Response code:' + response.getStatusCode())
+ msoLogger.debug('Response code:' + response.getStatus())
msoLogger.debug('Response:' + System.lineSeparator() + responseData)
- if (response.getStatusCode() == 200) {
- // Set the VfModuleXML
- if (responseData != null) {
+ if (response.getStatus() == 200) {
+ // Set the VfModuleXML
+ if (responseData != null) {
String vfModulesText = utils.getNodeXml(responseData, "vf-modules")
if (vfModulesText == null || vfModulesText.isEmpty()) {
msoLogger.debug("There are no VF modules in this VNF yet")
@@ -131,18 +132,18 @@ public class GenerateVfModuleName extends AbstractServiceTaskProcessor{
def personaModelIdFromAAI = utils.getNodeText(vfModuleXml, "model-invariant-id")
if (!personaModelIdFromAAI) {
// check old attribute name
- personaModelIdFromAAI = utils.getNodeText(vfModuleXml, "persona-model-id")
+ personaModelIdFromAAI = utils.getNodeText(vfModuleXml, "persona-model-id")
}
if (personaModelIdFromAAI != null && personaModelIdFromAAI.equals(personaModelId)) {
matchingVfModules = matchingVfModules + utils.removeXmlPreamble(vfModuleXml)
- }
+ }
}
matchingVfModules = matchingVfModules + "</vfModules>"
- msoLogger.debug("Matching VF Modules: " + matchingVfModules)
+ msoLogger.debug("Matching VF Modules: " + matchingVfModules)
execution.setVariable("GVFMN_vfModuleXml", matchingVfModules)
}
}
- }
+ }
} catch (Exception ex) {
ex.printStackTrace()
msoLogger.debug('Exception occurred while executing AAI GET:' + ex.getMessage())
@@ -155,18 +156,18 @@ public class GenerateVfModuleName extends AbstractServiceTaskProcessor{
msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAI(): ' + e.getMessage())
}
-
+
}
-
+
public void generateName (DelegateExecution execution) {
def method = getClass().getSimpleName() + '.generateName() ' +
'execution=' + execution.getId() +
')'
msoLogger.trace('Entered ' + method)
-
- String vfModuleXml = execution.getVariable("GVFMN_vfModuleXml")
-
- String moduleIndex = utils.getLowestUnusedIndex(vfModuleXml)
+
+ String vfModuleXml = execution.getVariable("GVFMN_vfModuleXml")
+
+ String moduleIndex = utils.getLowestUnusedIndex(vfModuleXml)
msoLogger.debug("moduleIndex is: " + moduleIndex)
def vnfName = execution.getVariable("vnfName")
def vfModuleLabel = execution.getVariable("vfModuleLabel")
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/NetworkUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/NetworkUtils.groovy
index a1e63dc150..27d067dfc1 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/NetworkUtils.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/NetworkUtils.groovy
@@ -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.
@@ -22,6 +22,9 @@ package org.onap.so.bpmn.common.scripts
import groovy.xml.XmlUtil
import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.onap.aai.domain.yang.L3Network
+import org.onap.aai.domain.yang.Subnet
+import org.onap.aai.domain.yang.Subnets
import org.onap.so.bpmn.core.UrnPropertiesReader
import org.onap.so.logger.MsoLogger
import org.w3c.dom.Document
@@ -64,7 +67,7 @@ class NetworkUtils {
* @param cloudRegionId the cloud-region-region
* @return String request
*/
- def CreateNetworkRequestV2(execution, requestId, messageId, requestInput, queryIdResponse, routeCollection, policyFqdns, tableCollection, cloudRegionId, backoutOnFailure, source) {
+ def CreateNetworkRequestV2(execution, requestId, messageId, requestInput,L3Network queryIdResponse, routeCollection, policyFqdns, tableCollection, cloudRegionId, backoutOnFailure, source) {
String createNetworkRequest = null
if(requestInput!=null && queryIdResponse!=null) {
String serviceInstanceId = ""
@@ -72,8 +75,8 @@ class NetworkUtils {
String externalValue = ""
if (source == "VID") {
- sharedValue = utils.getNodeText(queryIdResponse, "is-shared-network") != null ? utils.getNodeText(queryIdResponse, "is-shared-network") : "false"
- externalValue = utils.getNodeText(queryIdResponse, "is-external-network") != null ? utils.getNodeText(queryIdResponse, "is-external-network") : "false"
+ sharedValue = queryIdResponse.isIsSharedNetwork() != null ? queryIdResponse.isIsSharedNetwork() : "false"
+ externalValue = queryIdResponse.isIsExternalNetwork() != null ? queryIdResponse.isIsExternalNetwork() : "false"
serviceInstanceId = utils.getNodeText(requestInput, "service-instance-id")
} else { // source = 'PORTAL'
@@ -100,14 +103,14 @@ class NetworkUtils {
networkType = utils.getNodeText(networkModelInfo, "modelName")
modelCustomizationUuid = utils.getNodeText(networkModelInfo, "modelCustomizationUuid")
} else {
- networkType = utils.getNodeText(queryIdResponse, "network-type")
+ networkType = queryIdResponse.getNetworkType()
modelCustomizationUuid = utils.getNodeText(requestInput, "modelCustomizationId")
}
// queryIdResponse
- String networkName = utils.getNodeText(queryIdResponse, "network-name")
- String networkId = utils.getNodeText(queryIdResponse, "network-id")
- String networkTechnology = utils.getNodeText(queryIdResponse, "network-technology")
+ String networkName = queryIdResponse.getNetworkName()
+ String networkId = queryIdResponse.getNetworkId()
+ String networkTechnology = queryIdResponse.getNetworkTechnology()
// contrailNetwork - networkTechnology = 'Contrail' vs. 'AIC_SR_IOV')
String contrailNetwork = ""
@@ -124,13 +127,12 @@ class NetworkUtils {
// rebuild subnets
String subnets = ""
- if (utils.nodeExists(queryIdResponse, "subnets")) {
- def subnetsGroup = utils.getNodeXml(queryIdResponse, "subnets", false)
- subnets = buildSubnets(subnetsGroup)
+ if (queryIdResponse.getSubnets() != null) {
+ subnets = buildSubnets(queryIdResponse)
}
String physicalNetworkName = ""
- physicalNetworkName = utils.getNodeText(queryIdResponse, "physical-network-name")
+ physicalNetworkName = queryIdResponse.getPhysicalNetworkName()
String vlansCollection = buildVlans(queryIdResponse)
@@ -181,7 +183,7 @@ class NetworkUtils {
* @param cloudRegionId the cloud-region-region
* @return String request
*/
- def UpdateNetworkRequestV2(execution, requestId, messageId, requestInput, queryIdResponse, routeCollection, policyFqdns, tableCollection, cloudRegionId, backoutOnFailure, source) {
+ def UpdateNetworkRequestV2(execution, requestId, messageId, requestInput, L3Network queryIdResponse, routeCollection, policyFqdns, tableCollection, cloudRegionId, backoutOnFailure, source) {
String updateNetworkRequest = null
if(requestInput!=null && queryIdResponse!=null) {
String serviceInstanceId = ""
@@ -189,8 +191,8 @@ class NetworkUtils {
String externalValue = ""
if (source == "VID") {
- sharedValue = utils.getNodeText(queryIdResponse, "is-shared-network") != null ? utils.getNodeText(queryIdResponse, "is-shared-network") : "false"
- externalValue = utils.getNodeText(queryIdResponse, "is-external-network") != null ? utils.getNodeText(queryIdResponse, "is-external-network") : "false"
+ sharedValue = queryIdResponse.isIsSharedNetwork() != null ? queryIdResponse.isIsSharedNetwork() : "false"
+ externalValue = queryIdResponse.isIsExternalNetwork() != null ? queryIdResponse.isIsExternalNetwork() : "false"
serviceInstanceId = utils.getNodeText(requestInput, "service-instance-id")
} else { // source = 'PORTAL'
@@ -205,9 +207,9 @@ class NetworkUtils {
String tenantId = utils.getNodeText(requestInput, "tenant-id")
// queryIdResponse
- String networkName = utils.getNodeText(queryIdResponse, "network-name")
- String networkId = utils.getNodeText(queryIdResponse, "network-id")
-
+ String networkName = queryIdResponse.getNetworkName()
+ String networkId = queryIdResponse.getNetworkId()
+
String networkType = ""
String modelCustomizationUuid = ""
if (utils.nodeExists(requestInput, "networkModelInfo")) {
@@ -215,15 +217,14 @@ class NetworkUtils {
networkType = utils.getNodeText(networkModelInfo, "modelName")
modelCustomizationUuid = utils.getNodeText(networkModelInfo, "modelCustomizationUuid")
} else {
- networkType = utils.getNodeText(queryIdResponse, "network-type")
+ networkType = queryIdResponse.getNetworkType()
modelCustomizationUuid = utils.getNodeText(requestInput, "modelCustomizationId")
}
// rebuild subnets
String subnets = ""
- if (utils.nodeExists(queryIdResponse, "subnets")) {
- def subnetsGroup = utils.getNodeXml(queryIdResponse, "subnets", false)
- subnets = buildSubnets(subnetsGroup)
+ if (queryIdResponse.getSubnets() != null) {
+ subnets = buildSubnets(queryIdResponse)
}
String networkParams = ""
@@ -232,12 +233,12 @@ class NetworkUtils {
networkParams = buildParams(netParams)
}
- String networkStackId = utils.getNodeText(queryIdResponse, "heat-stack-id")
+ String networkStackId = queryIdResponse.getHeatStackId()
if (networkStackId == 'null' || networkStackId == "" || networkStackId == null) {
networkStackId = "force_update"
}
- String physicalNetworkName = utils.getNodeText(queryIdResponse, "physical-network-name")
+ String physicalNetworkName = queryIdResponse.getPhysicalNetworkName()
String vlansCollection = buildVlans(queryIdResponse)
updateNetworkRequest =
@@ -418,7 +419,7 @@ class NetworkUtils {
rebuildSegmentationAssignments = buildXMLElements(requeryIdAAIResponse, "segmentation-assignments", "segmentation-assignment", elementList)
} else {
rebuildSegmentationAssignments = buildXMLElements(requeryIdAAIResponse, "", "segmentation-assignments", elementList)
- }
+ }
}
// rebuild 'ctag-assignments' / rebuildCtagAssignments
@@ -736,7 +737,7 @@ class NetworkUtils {
return rtn
}
-
+
def isInstanceValueMatch(linkResource, globalSubscriberId, serviceType) {
Boolean rtn = false
try {
@@ -809,7 +810,7 @@ class NetworkUtils {
} else { //pending-update or PendingUpdate
xmlNetwork += "<"+element+">"+"Active"+"</"+element+">"
}
- }
+ }
if (element=="heat-stack-id") {
if (replaceNetworkId != "") {
xmlNetwork += "<"+element+">"+replaceNetworkId+"</"+element+">"
@@ -834,11 +835,11 @@ class NetworkUtils {
} else { //pending-update or PendingUpdate
xmlNetwork += "<"+element+">"+"Active"+"</"+element+">"
}
- }
+ }
} else {
xmlNetwork += "<"+element+">"+var.toString()+"</"+element+">"
}
- }
+ }
}
}
return xmlNetwork
@@ -863,7 +864,7 @@ class NetworkUtils {
} else {
def subnetList = ["subnet-id", "neutron-subnet-id", "gateway-address", "network-start-address", "cidr-mask", "ip-version", "orchestration-status", "dhcp-enabled", "dhcp-start", "dhcp-end", "subnet-role", "resource-version", "subnet-name", "ip-assignment-direction", "host-routes"]
rebuildingSubnets += buildSubNetworkElements(subnetXml, createNetworkResponse, subnetList, "subnet")
- }
+ }
}
if (utils.nodeExists(subnetsData, 'relationship')) {
rebuildingSubnets = rebuildRelationship(requeryIdAAIResponse)
@@ -878,29 +879,24 @@ class NetworkUtils {
return rebuildingSubnets
}
- def buildSubnets(queryIdResponse) {
+ def buildSubnets(L3Network network) {
def rebuildingSubnets = ""
- def subnetsData = new XmlSlurper().parseText(queryIdResponse)
- //rebuildingSubnets += "<subnets>"
- try {
- def subnets = subnetsData.'**'.findAll {it.name() == "subnet"}
- def subnetsSize = subnets.size()
- for (i in 0..subnetsSize-1) {
- def subnet = subnets[i]
- def subnetXml = XmlUtil.serialize(subnet)
- def orchestrationStatus = utils.getNodeText(subnetXml, "orchestration-status")
- if (orchestrationStatus == "pending-delete" || orchestrationStatus == "PendingDelete") {
- // skip, do not include in processing, remove!!!
- } else {
- def subnetList = ["dhcp-start", "dhcp-end", "network-start-address", "cidr-mask", "dhcp-enabled", "gateway-address", "ip-version", "subnet-id", "subnet-name", "ip-assignment-direction", "host-routes"]
- rebuildingSubnets += buildSubNetworkElements(subnetXml, subnetList, "subnets")
- //rebuildingSubnets += buildSubNetworkElements(subnetXml, subnetList, "")
- }
+ Subnets subnets = network.getSubnets()
+ try{
+ for(Subnet s : subnets.getSubnet()){
+ def orchestrationStatus = s.getOrchestrationStatus()
+ if (orchestrationStatus == "pending-delete" || orchestrationStatus == "PendingDelete") {
+ // skip, do not include in processing, remove!!!
+ } else {
+ def subnetList = ["dhcp-start", "dhcp-end", "network-start-address", "cidr-mask", "dhcp-enabled", "gateway-address", "ip-version", "subnet-id", "subnet-name", "ip-assignment-direction", "host-routes"]
+ rebuildingSubnets += buildSubNetworkElements(s, subnetList, "subnets")
+ //rebuildingSubnets += buildSubNetworkElements(subnetXml, subnetList, "")
+ }
}
} catch (Exception ex) {
- //
+ //
} finally {
- //rebuildingSubnets += "</subnets>"
+ //rebuildingSubnets += "</subnets>"
}
return rebuildingSubnets
}
@@ -919,7 +915,7 @@ class NetworkUtils {
var = xml.'**'.find {it.name() == element}
if (var != null) {
if (element=="orchestration-status") {
- if(var.toString() == 'pending-create' || var.toString() == 'PendingCreate') {
+ if(var.toString() == 'pending-create' || var.toString() == 'PendingCreate') {
xmlBuild += "<"+element+">"+"Created"+"</"+element+">"
} else { // pending-update or PendingUpdate'
xmlBuild += "<"+element+">"+"Active"+"</"+element+">"
@@ -940,9 +936,9 @@ class NetworkUtils {
List elementRoute = ["host-route-id", "route-prefix", "next-hop", "next-hop-type", "resource-version"]
xmlBuild += buildXMLElements(subnetXml, "host-routes", "host-route", elementRoute)
}
- } else {
+ } else {
xmlBuild += "<"+element+">"+var.toString()+"</"+element+">"
- }
+ }
}
}
}
@@ -957,68 +953,69 @@ class NetworkUtils {
}
// build subnet sub-network single elements
- def buildSubNetworkElements(subnetXml, elementList, parentName) {
+ def buildSubNetworkElements(Subnet subnet, elementList, parentName) {
+
def var = ""
def xmlBuild = ""
if (parentName != "") {
xmlBuild += "<"+parentName+">"
}
- if (subnetXml != null) {
+ if (subnet != null) {
def networkStartAddress = ""
for (element in elementList) {
- def xml= new XmlSlurper().parseText(subnetXml)
- var = xml.'**'.find {it.name() == element}
if (element == "dhcp-start") {
+ var = subnet.getDhcpStart()
xmlBuild += "<allocationPools>"
- if (var.toString() == 'null') {
+ if (var == null) {
xmlBuild += "<start>"+""+"</start>"
} else {
- xmlBuild += "<start>"+var.toString()+"</start>"
+ xmlBuild += "<start>"+var+"</start>"
}
}
if (element == "dhcp-end") {
- if (var.toString() == 'null') {
+ var = subnet.getDhcpEnd()
+ if (var == null) {
xmlBuild += "<end>"+""+"</end>"
} else {
- xmlBuild += "<end>"+var.toString()+"</end>"
+ xmlBuild += "<end>"+var+"</end>"
}
xmlBuild += "</allocationPools>"
}
if (element == "network-start-address" || element == "cidr-mask") {
if (element == "network-start-address") {
- networkStartAddress = var.toString()
+ networkStartAddress = subnet.getNetworkStartAddress()
}
if (element == "cidr-mask") {
- xmlBuild += "<cidr>"+networkStartAddress+"/"+var.toString()+"</cidr>"
+ xmlBuild += "<cidr>"+networkStartAddress+"/"+var+"</cidr>"
}
}
if (element == "dhcp-enabled") {
- xmlBuild += "<enableDHCP>"+var.toString()+"</enableDHCP>"
+ xmlBuild += "<enableDHCP>"+subnet.isDhcpEnabled()+"</enableDHCP>"
}
if (element == "gateway-address") {
- xmlBuild += "<gatewayIp>"+var.toString()+"</gatewayIp>"
+ xmlBuild += "<gatewayIp>"+subnet.getGatewayAddress()+"</gatewayIp>"
}
if (element == "ip-version") {
- String ipVersion = getIpvVersion(var.toString())
+ String ipVersion = getIpvVersion(subnet.getIpVersion())
xmlBuild += "<ipVersion>"+ipVersion+"</ipVersion>"
}
if (element == "subnet-id") {
- xmlBuild += "<subnetId>"+var.toString()+"</subnetId>"
+ xmlBuild += "<subnetId>"+subnet.getSubnetId()+"</subnetId>"
}
- if ((element == "subnet-name") && (var != null)) {
- xmlBuild += "<subnetName>"+var.toString()+"</subnetName>"
+ if ((element == "subnet-name") && (subnet.getSubnetName() != null)) {
+ xmlBuild += "<subnetName>"+subnet.getSubnetName()+"</subnetName>"
}
- if ((element == "ip-assignment-direction") && (var != null)) {
- xmlBuild += "<addrFromStart>"+var.toString()+"</addrFromStart>"
+ if ((element == "ip-assignment-direction") && (subnet.getIpAssignmentDirection() != null)) {
+ xmlBuild += "<addrFromStart>"+subnet.getIpAssignmentDirection()+"</addrFromStart>"
}
if (element == "host-routes") {
def routes = ""
- if (subnetXml.contains("host-routes")) {
- routes = buildHostRoutes(subnetXml)
+ if (subnet.getHostRoutes() != null) {
+ routes = buildHostRoutes(subnet)
}
- xmlBuild += routes
- }
-
+ xmlBuild += routes
+ }
+
}
}
if (parentName != "") {
@@ -1053,12 +1050,12 @@ class NetworkUtils {
}
}
buildHostRoutes += "</hostRoutes>"
- }
- }
- return buildHostRoutes
-
+ }
+ }
+ return buildHostRoutes
+
}
-
+
// rebuild ctag-assignments
def rebuildCtagAssignments(xmlInput) {
def rebuildingCtagAssignments = ""
@@ -1396,17 +1393,17 @@ class NetworkUtils {
}
return rollbackEnabled
}
-
-
+
+
/**
* This method extracts the version for the the given ip-version.
*
* @param String ipvVersion - IP protocols version (ex: ipv4 or ipv6 or 4 or 6)
* @return String version - digit version (ex: 4 or 6)
*/
-
+
public String getIpvVersion (String ipvVersion) {
-
+
String version = ""
try {
if (ipvVersion.isNumber()) {
@@ -1418,7 +1415,7 @@ class NetworkUtils {
}
}
} catch (Exception ex) {
- version = ipvVersion
+ version = ipvVersion
}
return version
}
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 533df72285..2e937ed134 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
@@ -32,12 +32,13 @@ import org.onap.so.bpmn.core.domain.ServiceDecomposition
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.logger.MsoLogger
import org.onap.so.db.catalog.beans.CloudIdentity
import org.onap.so.db.catalog.beans.CloudSite
-import org.onap.so.rest.APIResponse
-import org.onap.so.rest.RESTClient
-import org.onap.so.rest.RESTConfig
+
import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
+import org.onap.so.utils.TargetEntity
import org.json.JSONArray
import org.json.JSONObject
@@ -45,6 +46,8 @@ import org.springframework.web.util.UriUtils
import static org.onap.so.bpmn.common.scripts.GenericUtils.*
+import javax.ws.rs.core.Response
+
/**
* This class contains the scripts used
* by the OOF Homing Subflow building block. The
@@ -135,7 +138,7 @@ class OofHoming extends AbstractServiceTaskProcessor {
//Prepare Callback
String timeout = execution.getVariable("timeout")
- if (isBlank(timeout)) {
+ if (isBlank(timeout)) {
timeout = UrnPropertiesReader.getVariable("mso.oof.timeout", execution);
if (isBlank(timeout)) {
timeout = "PT30M"
@@ -153,25 +156,18 @@ class OofHoming extends AbstractServiceTaskProcessor {
execution.setVariable("oofRequest", oofRequest)
utils.log("DEBUG", "OOF Request is: " + oofRequest, isDebugEnabled)
- String url = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution)
- utils.log("DEBUG", "Posting to OOF Url: " + url, isDebugEnabled)
+ String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution)
+ utils.log("DEBUG", "Posting to OOF Url: " + urlString, isDebugEnabled)
- logDebug("URL to be used is: " + url, isDebugEnabled)
- RESTConfig config = new RESTConfig(url)
- RESTClient client = new RESTClient(config).addAuthorizationHeader(authHeader).
- addHeader("Content-Type", "application/json")
- APIResponse response = client.httpPost(oofRequest)
+ URL url = new URL(urlString);
+ HttpClient httpClient = new HttpClient(url, "application/json", TargetEntity.SNIRO)
+ httpClient.addAdditionalHeader("Authorization", authHeader)
+ Response httpResponse = httpClient.post(oofRequest)
- int responseCode = response.getStatusCode()
- logDebug("OOF sync response code is: " + responseCode, isDebugEnabled)
- String syncResponse = response.getResponseBodyAsString()
- execution.setVariable("syncResponse", syncResponse)
- logDebug("OOF sync response is: " + syncResponse, isDebugEnabled)
+ int responseCode = httpResponse.getStatus()
+ logDebug("OOF sync response code is: " + responseCode, isDebugEnabled)
- if(responseCode != 202){
- exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from OOF.")
- }
utils.log("DEBUG", "*** Completed Homing Call OOF ***", isDebugEnabled)
}
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 197589efa1..b9bc1c7c00 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
@@ -33,10 +33,9 @@ import org.onap.so.bpmn.core.domain.ServiceInstance
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.db.catalog.beans.CloudSite
-import org.onap.so.rest.APIResponse
-import org.onap.so.rest.RESTClient
-import org.onap.so.rest.RESTConfig
+import org.onap.so.utils.TargetEntity
import org.springframework.http.HttpEntity
import org.springframework.http.HttpHeaders
import org.springframework.http.HttpMethod
@@ -504,22 +503,16 @@ class OofUtils {
String auth = UrnPropertiesReader.getVariable("mso.db.auth", execution)
String uri = "/cloudSite"
- HttpHeaders headers = new HttpHeaders()
+ 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)
- headers.set(HttpHeaders.AUTHORIZATION, auth)
- headers.set(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON)
- headers.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ Response response = client.post(request.getBody().toString())
- UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(endpoint + uri)
- HttpEntity<CloudSite> request = new HttpEntity<CloudSite>(cloudSite, headers)
- RESTConfig config = new RESTConfig(endpoint + uri)
- RESTClient client = new RESTClient(config).addAuthorizationHeader(auth).
- addHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON).addHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
- APIResponse response = client.httpPost(request.getBody().toString())
-
- int responseCode = response.getStatusCode()
+ int responseCode = response.getStatus()
logDebug("CatalogDB response code is: " + responseCode, isDebugEnabled)
- String syncResponse = response.getResponseBodyAsString()
+ String syncResponse = response.readEntity(String.class)
logDebug("CatalogDB response is: " + syncResponse, isDebugEnabled)
if(responseCode != 202){
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModule.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModule.groovy
index 1a55bf2a0e..8f0e481c9a 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModule.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModule.groovy
@@ -34,9 +34,6 @@ import org.onap.so.client.aai.entities.AAIResultWrapper
import org.onap.so.client.aai.entities.uri.AAIResourceUri
import org.onap.so.client.aai.entities.uri.AAIUriFactory
import org.onap.so.client.graphinventory.entities.uri.Depth
-import org.onap.so.rest.APIResponse
-import org.onap.so.rest.RESTClient
-import org.onap.so.rest.RESTConfig
import org.springframework.web.util.UriUtils
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
@@ -214,74 +211,31 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase {
msoLogger.trace('Entered ' + method)
try {
- // Construct payload
- org.onap.aai.domain.yang.VfModule vfModule = execution.getVariable('PUAAIVfMod_vfModule')
-
- def orchestrationStatus = execution.getVariable('PUAAIVfMod_orchestrationStatus')
-
- vfModule.setOrchestrationStatus(orchestrationStatus)
-
- //def payload = utils.nodeToString(newVfModuleNode)
-
- // Construct endpoint
def vnfId = execution.getVariable('PUAAIVfMod_vnfId')
def vfModuleId = execution.getVariable('PUAAIVfMod_vfModuleId')
+ def orchestrationStatus = execution.getVariable('PUAAIVfMod_orchestrationStatus')
- def payload = """{
- "vf-module-id": "${vfModuleId}",
- "orchestration-status": "${orchestrationStatus}"
- }"""
+ org.onap.aai.domain.yang.VfModule vfModule = execution.getVariable('PUAAIVfMod_vfModule')
- msoLogger.debug("VfModule payload : " + payload)
+ vfModule.setVfModuleId(vfModuleId)
+ vfModule.setOrchestrationStatus(orchestrationStatus)
- AaiUtil aaiUtil = new AaiUtil(this)
+ AAIResourcesClient client = new AAIResourcesClient()
AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId)
- uri.depth(Depth.ONE)
- String endPoint = aaiUtil.createAaiUri(uri)
+ client.update(uri, vfModule)
+
+ // Set the output for this flow. The updated VfModule is an output, the generic VNF name, and for
+ // backward compatibilty, the heat-stack-id is an output
+ execution.setVariable('PUAAIVfMod_outVfModule', vfModule)
+ def vnfName = execution.getVariable('PUAAIVfMod_vnfName')
+ msoLogger.debug('Output PUAAIVfMod_vnfName set to ' + vnfName)
+ // TODO: Should deprecate use of processKey+Response variable for the response. Will use "WorkflowResponse" instead
+ execution.setVariable('WorkflowResponse', vfModule)
+
+ def heatStackId = vfModule.getHeatStackId()
+ execution.setVariable('PUAAIVfMod_heatStackId', heatStackId)
+ msoLogger.debug('Output PUAAIVfMod_heatStackId set to \'' + heatStackId + '\'')
- msoLogger.debug("PrepareUpdateAAIVfModule: AAI endPoint : " + endPoint)
- String basicAuthCred = utils.getBasicAuth(UrnPropertiesReader.getVariable("aai.auth", execution),UrnPropertiesReader.getVariable("mso.msoKey", execution))
- try {
- RESTConfig config = new RESTConfig(endPoint);
- def responseData = ''
- def aaiRequestId = utils.getRequestID()
- RESTClient client = new RESTClient(config).
- addHeader('X-TransactionId', aaiRequestId).
- addHeader('X-FromAppId', 'MSO').
- addHeader('Content-Type', 'application/merge-patch+json').
- addHeader('Accept','application/json');
- if (basicAuthCred != null && !"".equals(basicAuthCred)) {
- client.addAuthorizationHeader(basicAuthCred)
- }
- msoLogger.debug('sending PATCH to AAI endpoint \'' + endPoint + '\'' + 'with payload \n' + payload)
- APIResponse response = client.httpPatch(payload)
- msoLogger.debug("PrepareUpdateAAIVfModule: - invoking httpPatch to AAI")
-
- responseData = response.getResponseBodyAsString()
- execution.setVariable('PUAAIVfMod_updateVfModuleResponseCode', response.getStatusCode())
- execution.setVariable('PUAAIVfMod_updateVfModuleResponse', responseData)
- msoLogger.debug('Response code:' + response.getStatusCode())
- msoLogger.debug('Response:' + System.lineSeparator() + responseData)
- msoLogger.debug("PrepareUpdateAAIVfModule: AAI Response : " + responseData)
- msoLogger.debug("PrepareUpdateAAIVfModule: AAI ResponseCode : " + response.getStatusCode())
-
- // Set the output for this flow. The updated VfModule is an output, the generic VNF name, and for
- // backward compatibilty, the heat-stack-id is an output
- execution.setVariable('PUAAIVfMod_outVfModule', vfModule)
- def vnfName = execution.getVariable('PUAAIVfMod_vnfName')
- msoLogger.debug('Output PUAAIVfMod_vnfName set to ' + vnfName)
- // TODO: Should deprecate use of processKey+Response variable for the response. Will use "WorkflowResponse" instead
- execution.setVariable('WorkflowResponse', vfModule)
-
- def heatStackId = vfModule.getHeatStackId()
- execution.setVariable('PUAAIVfMod_heatStackId', heatStackId)
- msoLogger.debug('Output PUAAIVfMod_heatStackId set to \'' + heatStackId + '\'')
- } catch (Exception ex) {
- ex.printStackTrace()
- msoLogger.debug('Exception occurred while executing AAI PUT:' + ex.getMessage())
- execution.setVariable('PUAAIVfMod_updateVfModuleResponseCode', 500)
- execution.setVariable('PUAAIVfMod_updateVfModuleResponse', 'AAI PATCH Failed:' + ex.getMessage())
- }
msoLogger.trace('Exited ' + method)
} catch (BpmnError e) {
throw e;
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 f610ea4782..d7fc6ac995 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
@@ -21,6 +21,7 @@
package org.onap.so.bpmn.common.scripts
import java.text.SimpleDateFormat
+import javax.ws.rs.core.Response
import java.net.URLEncoder
import org.apache.commons.codec.binary.Base64
@@ -36,11 +37,10 @@ import org.onap.so.bpmn.core.UrnPropertiesReader
import org.onap.so.bpmn.core.WorkflowException
import org.onap.so.bpmn.core.domain.RollbackData
import org.onap.so.bpmn.core.json.JsonUtils
-import org.onap.so.rest.APIResponse
-import org.onap.so.rest.RESTClient
-import org.onap.so.rest.RESTConfig
+import org.onap.so.client.HttpClient
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
+import org.onap.so.utils.TargetEntity
@@ -205,23 +205,23 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor {
String sdncAdapterRequest = execution.getVariable(prefix + 'sdncAdapterRequest')
msoLogger.debug("SDNC Rest Request is: " + sdncAdapterRequest)
- RESTConfig config = new RESTConfig(sdncAdapterUrl)
- RESTClient client = new RESTClient(config).
- addHeader("Content-Type", "application/json")
- .addHeader("mso-request-id",execution.getVariable("mso-request-id"))
- .addHeader("mso-service-instance-id",execution.getVariable("mso-service-instance-id"))
- .addAuthorizationHeader(execution.getVariable(prefix + "basicAuthHeaderValue"))
+ URL url = new URL(sdncAdapterUrl);
- APIResponse response
+ HttpClient httpClient = new HttpClient(url, "application/json", TargetEntity.SDNC_ADAPTER)
+ httpClient.addAdditionalHeader("mso-request-id", execution.getVariable("mso-request-id"))
+ httpClient.addAdditionalHeader("mso-service-instance-id", execution.getVariable("mso-service-instance-id"))
+ httpClient.addAdditionalHeader("Authorization", execution.getVariable(prefix + "basicAuthHeaderValue"))
+
+ Response response
if ("GET".equals(sdncAdapterMethod)) {
- response = client.httpGet()
+ response = httpClient.get()
} else if ("PUT".equals(sdncAdapterMethod)) {
- response = client.httpPut(sdncAdapterRequest)
+ response = httpClient.put(sdncAdapterRequest)
} else if ("POST".equals(sdncAdapterMethod)) {
- response = client.httpPost(sdncAdapterRequest)
+ response = httpClient.post(sdncAdapterRequest)
} else if ("DELETE".equals(sdncAdapterMethod)) {
- response = client.httpDelete(sdncAdapterRequest)
+ response = httpClient.delete(sdncAdapterRequest)
} else {
String msg = 'Unsupported HTTP method "' + sdncAdapterMethod + '" in ' + method + ": " + e
msoLogger.debug(msg)
@@ -229,13 +229,15 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor {
exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
}
- execution.setVariable(prefix + "sdncAdapterStatusCode", response.getStatusCode())
- execution.setVariable(prefix + "sdncAdapterResponse", response.getResponseBodyAsString())
+ execution.setVariable(prefix + "sdncAdapterStatusCode", response.getStatus())
+ if(response.hasEntity()){
+ execution.setVariable(prefix + "sdncAdapterResponse", response.readEntity(String.class))
+ }
} catch (BpmnError e) {
throw e
} catch (Exception e) {
String msg = 'Caught exception in ' + method + ": " + e
- msoLogger.debug(msg)
+ msoLogger.debug(msg, e)
msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV2.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV2.groovy
index 967b9fa93f..1a20497bbc 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV2.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV2.groovy
@@ -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.
@@ -34,9 +34,6 @@ import org.json.JSONObject
import org.onap.so.bpmn.core.WorkflowException
import org.onap.so.bpmn.core.json.JsonUtils
-import org.onap.so.rest.APIResponse
-import org.onap.so.rest.RESTClient
-import org.onap.so.rest.RESTConfig
import org.onap.so.bpmn.core.UrnPropertiesReader
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
@@ -224,7 +221,7 @@ class SDNCAdapterRestV2 extends SDNCAdapterRestV1 {
if (responseType.endsWith('Error')) {
sdncAdapterBuildWorkflowException(execution, callback)
}
-
+
// Check for possible interim notification
execution.setVariable(prefix + "interimNotification", null)
execution.setVariable(prefix + "doInterimNotification", false)
@@ -235,7 +232,7 @@ class SDNCAdapterRestV2 extends SDNCAdapterRestV1 {
execution.setVariable(prefix + "doInterimNotification", true)
}
}
-
+
} catch (Exception e) {
callback = callback == null || String.valueOf(callback).isEmpty() ? "NONE" : callback
String msg = "Received error from SDNCAdapter: " + callback
@@ -243,7 +240,7 @@ class SDNCAdapterRestV2 extends SDNCAdapterRestV1 {
exceptionUtil.buildWorkflowException(execution, 5300, msg)
}
}
-
+
/**
* Prepare to send an interim notification by extracting the variable/value definitions
* in the interimNotification JSON object and placing them in the execution. These
@@ -254,21 +251,21 @@ class SDNCAdapterRestV2 extends SDNCAdapterRestV1 {
'execution=' + execution.getId() +
')'
msoLogger.trace('Entered ' + method)
-
+
String prefix = execution.getVariable('prefix')
msoLogger.debug("Preparing Interim Notification")
try {
def interimNotification = execution.getVariable(prefix + "interimNotification")
msoLogger.debug("Preparing Interim Notification:\n" + JsonUtils.prettyJson(interimNotification))
-
+
for (int i = 0; ; i++) {
def variable = JsonUtils.getJsonParamValue(interimNotification, 'variableList', 'variable', i)
-
+
if (variable == null) {
break
}
-
+
def String variableName = JsonUtils.getJsonValue(variable, "name")
if ((variableName != null) && !variableName.isEmpty()) {
def variableValue = JsonUtils.getJsonValue(variable, "value")
@@ -276,7 +273,7 @@ class SDNCAdapterRestV2 extends SDNCAdapterRestV1 {
msoLogger.debug("Setting "+ variableName + "=" + variableValue)
}
}
-
+
} catch (Exception e) {
String msg = "Error preparing interim notification"
msoLogger.debug(getProcessKey(execution) + ': ' + msg)
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 8d14ead6e0..401cac9820 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
@@ -33,15 +33,18 @@ import org.onap.so.bpmn.core.domain.ServiceDecomposition
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.rest.APIResponse
-import org.onap.so.rest.RESTClient
-import org.onap.so.rest.RESTConfig
+import org.onap.so.client.HttpClient
+import org.onap.so.utils.TargetEntity
import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
import org.json.JSONArray
import org.json.JSONObject
import static org.onap.so.bpmn.common.scripts.GenericUtils.*;
+
+import java.net.URL
+
+import javax.ws.rs.core.Response
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
@@ -126,20 +129,25 @@ class SniroHomingV1 extends AbstractServiceTaskProcessor{
String endpoint = UrnPropertiesReader.getVariable("sniro.manager.uri.v1", execution)
String host = UrnPropertiesReader.getVariable("sniro.manager.host", execution)
- String url = host + endpoint
- msoLogger.debug("Sniro Url is: " + url)
+ String urlString = host + endpoint
+ msoLogger.debug("Sniro Url is: " + urlString)
+
+ URL url = new URL(urlString);
+ HttpClient httpClient = new HttpClient(url, "application/json", TargetEntity.SNIRO)
+ httpClient.addAdditionalHeader("Authorization", authHeader)
+ Response httpResponse = httpClient.post(sniroRequest)
- RESTConfig config = new RESTConfig(url);
- RESTClient client = new RESTClient(config).addAuthorizationHeader(authHeader).addHeader("Content-Type", "application/json")
- APIResponse response = client.httpPost(sniroRequest)
+ int responseCode = httpResponse.getStatus()
- int responseCode = response.getStatusCode()
msoLogger.debug("Sniro sync response code is: " + responseCode)
- msoLogger.debug("Sniro sync response is: " + response.getResponseBodyAsString())
+ if(httpResponse.hasEntity()){
+ msoLogger.debug("Sniro sync response is: " + httpResponse.readEntity(String.class))
+ }
if(responseCode != 202){
exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from Sniro.")
}
+
msoLogger.trace("Completed Sniro Homing Call Sniro")
}
}catch(BpmnError b){
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 52f45c205c..13cc7f8d11 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
@@ -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.
@@ -20,15 +20,15 @@
package org.onap.so.bpmn.common.scripts
+import javax.ws.rs.core.Response
import org.apache.commons.lang3.*
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
import org.onap.so.bpmn.core.UrnPropertiesReader
-import org.onap.so.rest.APIResponse
-import org.onap.so.rest.RESTClient
-import org.onap.so.rest.RESTConfig
+import org.onap.so.client.HttpClient
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
+import org.onap.so.utils.TargetEntity
@@ -67,7 +67,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor {
if ('rollbackVolumeGroupRequest'.equals(requestType)) {
messageId = getMessageIdForVolumeGroupRollback(root)
}
-
+
if (messageId == null || messageId.isEmpty()) {
String msg = getProcessKey(execution) + ': no messageId in ' + requestType
msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
@@ -281,7 +281,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor {
exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
}
}
-
+
public String getVolumeGroupIdFromRollbackRequest(Node root) {
return root.'volumeGroupRollback'.'volumeGroupId'.text()
}
@@ -289,7 +289,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor {
public String getMessageIdForVolumeGroupRollback(Node root) {
return root.'volumeGroupRollback'.'messageId'.text()
}
-
+
/**
* This method is used instead of an HTTP Connector task because the
* connector does not allow DELETE with a body.
@@ -307,29 +307,31 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor {
String vnfAdapterUrl = execution.getVariable(prefix + 'vnfAdapterUrl')
String vnfAdapterRequest = execution.getVariable(prefix + 'vnfAdapterRequest')
- RESTConfig config = new RESTConfig(vnfAdapterUrl)
- RESTClient client = new RESTClient(config).
- addHeader("Content-Type", "application/xml").
- addAuthorizationHeader(execution.getVariable(prefix + "basicAuthHeaderValue"));
+ URL url = new URL(vnfAdapterUrl);
- APIResponse response;
+ HttpClient httpClient = new HttpClient(url, "application/xml", TargetEntity.VNF_ADAPTER)
+ httpClient.addAdditionalHeader("Authorization", execution.getVariable(prefix + "basicAuthHeaderValue"))
+
+ Response response;
if ("GET".equals(vnfAdapterMethod)) {
- response = client.httpGet()
+ response = httpClient.get()
} else if ("PUT".equals(vnfAdapterMethod)) {
- response = client.httpPut(vnfAdapterRequest)
+ response = httpClient.put(vnfAdapterRequest)
} else if ("POST".equals(vnfAdapterMethod)) {
- response = client.httpPost(vnfAdapterRequest)
+ response = httpClient.post(vnfAdapterRequest)
} else if ("DELETE".equals(vnfAdapterMethod)) {
- response = client.httpDelete(vnfAdapterRequest)
+ response = httpClient.delete(vnfAdapterRequest)
} else {
String msg = 'Unsupported HTTP method "' + vnfAdapterMethod + '" in ' + method + ": " + e
msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
}
- execution.setVariable(prefix + "vnfAdapterStatusCode", response.getStatusCode())
- execution.setVariable(prefix + "vnfAdapterResponse", response.getResponseBodyAsString())
+ execution.setVariable(prefix + "vnfAdapterStatusCode", response.getStatus())
+ if(response.hasEntity()){
+ execution.setVariable(prefix + "vnfAdapterResponse", response.readEntity(String.class))
+ }
} catch (BpmnError e) {
throw e
} catch (Exception e) {