summaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap')
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Create3rdONAPE2EServiceInstance.groovy179
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateDeviceResource.groovy56
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy36
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVFCNSResource.groovy63
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Delete3rdONAPE2EServiceInstance.groovy249
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteDeviceResource.groovy37
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy1
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareModelVersions.groovy69
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy6
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstanceRollback.groovy3
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy662
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstanceRollback.groovy117
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy10
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstanceRollback.groovy21
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy66
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy59
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy92
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceV2.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy64
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy27
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceRollback.groovy76
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstance.groovy102
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy21
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleVFCNetworkServiceInstance.groovy42
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy574
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceRollback.groovy10
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy181
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/RollbackVnf.groovy44
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollback.groovy34
31 files changed, 1231 insertions, 1676 deletions
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Create3rdONAPE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Create3rdONAPE2EServiceInstance.groovy
index cd583f77ef..a0f0e279f6 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Create3rdONAPE2EServiceInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Create3rdONAPE2EServiceInstance.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.
@@ -31,16 +31,21 @@ import org.onap.so.bpmn.common.scripts.ExceptionUtil
import org.onap.so.bpmn.common.scripts.ExternalAPIUtil
import org.onap.so.bpmn.common.scripts.AaiUtil
import org.onap.so.bpmn.common.scripts.MsoUtils
+import org.onap.aai.domain.yang.SpPartner
import org.onap.so.bpmn.common.recipe.ResourceInput
import org.onap.so.bpmn.common.resource.ResourceRequestBuilder
import org.onap.so.bpmn.core.WorkflowException
import org.onap.so.bpmn.core.json.JsonUtils
import org.onap.so.bpmn.infrastructure.workflow.serviceTask.client.builder.AbstractBuilder
-import org.onap.so.rest.APIResponse
+import org.onap.so.client.aai.AAIObjectType
+import org.onap.so.client.aai.AAIResourcesClient
+import org.onap.so.client.aai.entities.uri.AAIResourceUri
+import org.onap.so.client.aai.entities.uri.AAIUriFactory
import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils
import org.onap.so.bpmn.infrastructure.workflow.service.ServicePluginFactory
import java.util.Map
import java.util.UUID
+import javax.ws.rs.core.Response
import org.onap.so.logger.MsoLogger
import org.camunda.bpm.engine.runtime.Execution
@@ -49,12 +54,10 @@ import org.camunda.bpm.engine.delegate.DelegateExecution
import org.apache.commons.lang3.*
import org.apache.commons.codec.binary.Base64
import org.springframework.web.util.UriUtils
-import org.onap.so.rest.RESTClient
-import org.onap.so.rest.RESTConfig
/**
* This groovy class supports the <class>Create3rdONAPE2EServiceInstance.bpmn</class> process.
- * flow for Create E2EServiceInstance in 3rdONAP
+ * flow for Create E2EServiceInstance in 3rdONAP
*/
public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcessor {
@@ -82,10 +85,10 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
String resourceInputPrameters = resourceInputObj.getResourceParameters()
String inputParametersJson = JsonUtils.getJsonValue(resourceInputPrameters, "requestInputs")
JSONObject inputParameters = new JSONObject(inputParametersJson)
-
+
// set local resourceInput
execution.setVariable(Prefix + "ResourceInput", resourceInputObj)
-
+
boolean is3rdONAPExist = false
if(inputParameters.has("sppartner_url"))
@@ -123,7 +126,7 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
String msg = "sppartner providingServiceInvarianteUuid is blank."
msoLogger.debug(msg)
}
-
+
if(inputParameters.has("sppartner_handoverMode"))
{
String handoverMode = inputParameters.get("sppartner_handoverMode")
@@ -153,9 +156,9 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
public void checkLocallCall (DelegateExecution execution) {
msoLogger.info(" ***** Started checkLocallCall *****")
try {
-
+
//Get ResourceInput Object
- ResourceInput resourceInputObj = execution.getVariable(Prefix + "ResourceInput")
+ ResourceInput resourceInputObj = execution.getVariable(Prefix + "ResourceInput")
//uuiRequest
String incomingRequest = resourceInputObj.getRequestsInputs()
@@ -163,7 +166,7 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
String requestInputs = JsonUtils.getJsonValue(serviceParameters, "requestInputs")
JSONObject inputParameters = new JSONObject(requestInputs)
execution.setVariable(Prefix + "ServiceParameters", inputParameters)
-
+
// CallSource is added only when ONAP SO calling 3rdONAP(External API) SO(Remote call)
boolean isLocalCall = true
String callSource = "UUI"
@@ -174,11 +177,11 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
String sppartnerId = inputParameters.get("SppartnerServiceId")
execution.setVariable(Prefix + "SppartnerServiceId", sppartnerId)
isLocalCall = false
- }
+ }
}
execution.setVariable(Prefix + "CallSource", callSource)
msoLogger.debug("callSource is: " + callSource )
-
+
execution.setVariable("IsLocalCall", isLocalCall)
} catch (Exception ex){
@@ -211,7 +214,7 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
}
execution.setVariable("serviceType", serviceType)
msoLogger.info("serviceType:" + serviceType)
-
+
String resourceName = resourceInputObj.getResourceInstanceName()
if (isBlank(resourceName)) {
msg = "Input resourceName is null"
@@ -219,11 +222,11 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
}
execution.setVariable("resourceName", resourceName)
msoLogger.info("resourceName:" + resourceName)
-
+
int beginIndex = resourceName.indexOf("_") + 1
String serviceInstanceName = resourceName.substring(beginIndex)
execution.setVariable("serviceInstanceName", serviceInstanceName)
-
+
String serviceInstanceId = resourceInputObj.getServiceInstanceId()
if (isBlank(serviceInstanceId)) {
msg = "Input serviceInstanceId is null"
@@ -239,7 +242,7 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
}
execution.setVariable(Prefix + "ResourceModelInvariantUuid", resourceModelInvariantUuid)
msoLogger.info("resourceModelInvariantUuid:" + resourceModelInvariantUuid)
-
+
String resourceModelUuid = resourceInputObj.getResourceModelInfo().getModelUuid()
if (isBlank(resourceModelUuid)) {
msg = "Input resourceModelUuid is null"
@@ -247,7 +250,7 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
}
execution.setVariable(Prefix + "ResourceModelUuid", resourceModelUuid)
msoLogger.info("resourceModelUuid:" + resourceModelUuid)
-
+
String resourceModelCustomizationUuid = resourceInputObj.getResourceModelInfo().getModelCustomizationUuid()
if (isBlank(resourceModelCustomizationUuid)) {
msg = "Input resourceModelCustomizationUuid is null"
@@ -300,7 +303,7 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
public void allocateCrossONAPResource(DelegateExecution execution) {
msoLogger.info(" ***** Started allocateCrossONAPResource *****")
-
+
//get TP links from AAI for SOTN handoverMode only
String handoverMode = execution.getVariable(Prefix + "HandoverMode")
if("SOTN".equalsIgnoreCase(handoverMode)) {
@@ -318,7 +321,7 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
crossTPs.put("remote-access-topology-id", inputParameters.get("local-access-topology-id"));
crossTPs.put("remote-access-node-id", inputParameters.get("local-access-node-id"));
crossTPs.put("remote-access-ltp-id", inputParameters.get("local-access-ltp-id"));
-
+
inputParameters.put("local-access-provider-id", crossTPs.get("local-access-provider-id"));
inputParameters.put("local-access-client-id", crossTPs.get("local-access-client-id"));
inputParameters.put("local-access-topology-id", crossTPs.get("local-access-topology-id"));
@@ -336,17 +339,17 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
msoLogger.error("No allocated CrossONAPResource found in ServiceParameters")
}
}
-
+
msoLogger.info("Exit " + allocateCrossONAPResource)
}
public void prepare3rdONAPRequest(DelegateExecution execution) {
msoLogger.info(" ***** Started prepare3rdONAPRequest *****")
-
+
String sppartnerUrl = execution.getVariable(Prefix + "SppartnerUrl")
String extAPIPath = sppartnerUrl + '/serviceOrder'
execution.setVariable("ExternalAPIURL", extAPIPath)
-
+
// ExternalAPI message format
String externalId = execution.getVariable("resourceName")
String category = "E2E Service"
@@ -363,7 +366,7 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
String serviceState = "active"
String serviceName = execution.getVariable("serviceInstanceName")
String serviceUuId = execution.getVariable(Prefix + "SppartnerUUID")
-
+
Map<String, String> valueMap = new HashMap<>()
valueMap.put("externalId", '"' + externalId + '"')
valueMap.put("category", '"' + category + '"')
@@ -381,30 +384,30 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
valueMap.put("serviceId", "null") //null for add
valueMap.put("serviceName", '"' + serviceName + '"')
valueMap.put("serviceUuId", '"' + serviceUuId + '"')
-
+
ExternalAPIUtil externalAPIUtil = new ExternalAPIUtil()
-
- // insert CallSource='ExternalAPI' to uuiRequest
+
+ // insert CallSource='ExternalAPI' to uuiRequest
Map<String, String> requestInputsMap = new HashMap<>()
requestInputsMap.put("inputName", '"CallSource"')
requestInputsMap.put("inputValue", '"ExternalAPI"')
String _requestInputs_ = externalAPIUtil.setTemplate(ExternalAPIUtil.RequestInputsTemplate, requestInputsMap)
-
+
requestInputsMap.clear()
String serviceInstanceId = execution.getVariable(Prefix + "ServiceInstanceId")
requestInputsMap.put("inputName", '"SppartnerServiceId"')
requestInputsMap.put("inputValue", '"' + serviceInstanceId + '"')
_requestInputs_ += ",\n" + externalAPIUtil.setTemplate(ExternalAPIUtil.RequestInputsTemplate, requestInputsMap)
-
+
requestInputsMap.clear()
String serviceType = execution.getVariable("serviceType")
requestInputsMap.put("inputName", '"serviceType"')
requestInputsMap.put("inputValue", '"' + serviceType + '"')
_requestInputs_ += ",\n" + externalAPIUtil.setTemplate(ExternalAPIUtil.RequestInputsTemplate, requestInputsMap)
-
+
// Transfer all uuiRequest incomeParameters to ExternalAPI format
JSONObject inputParameters = execution.getVariable(Prefix + "ServiceParameters")
- for(String key : inputParameters.keySet()) {
+ for(String key : inputParameters.keySet()) {
String inputName = key
String inputValue = inputParameters.opt(key)
requestInputsMap.clear()
@@ -413,7 +416,7 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
_requestInputs_ += ",\n" + externalAPIUtil.setTemplate(ExternalAPIUtil.RequestInputsTemplate, requestInputsMap)
}
valueMap.put("_requestInputs_", _requestInputs_)
-
+
String payload = externalAPIUtil.setTemplate(ExternalAPIUtil.PostServiceOrderRequestsTemplate, valueMap)
execution.setVariable(Prefix + "Payload", payload)
msoLogger.info("Exit " + prepare3rdONAPRequest)
@@ -421,26 +424,26 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
public void doCreateE2ESIin3rdONAP(DelegateExecution execution) {
msoLogger.info(" ***** Started doCreateE2ESIin3rdONAP *****")
-
+
String extAPIPath = execution.getVariable("ExternalAPIURL")
String payload = execution.getVariable(Prefix + "Payload")
msoLogger.debug("doCreateE2ESIin3rdONAP externalAPIURL is: " + extAPIPath)
msoLogger.debug("doCreateE2ESIin3rdONAP payload is: " + payload)
-
+
ExternalAPIUtil externalAPIUtil = new ExternalAPIUtil()
- APIResponse response = externalAPIUtil.executeExternalAPIPostCall(execution, extAPIPath, payload)
+ Response response = externalAPIUtil.executeExternalAPIPostCall(execution, extAPIPath, payload)
- int responseCode = response.getStatusCode()
+ int responseCode = response.getStatus()
execution.setVariable(Prefix + "PostServiceOrderResponseCode", responseCode)
msoLogger.debug("Post ServiceOrder response code is: " + responseCode)
- String extApiResponse = response.getResponseBodyAsString()
+ String extApiResponse = response.readEntity(String.class)
JSONObject responseObj = new JSONObject(extApiResponse)
execution.setVariable(Prefix + "PostServiceOrderResponse", extApiResponse)
-
+
msoLogger.debug("doCreateE2ESIin3rdONAP response body is: " + extApiResponse)
-
+
//Process Response
if(responseCode == 200 || responseCode == 201 || responseCode == 202 )
//200 OK 201 CREATED 202 ACCEPTED
@@ -455,32 +458,32 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
msoLogger.error("Post ServiceOrder Received a Bad Response Code. Response Code is: " + responseCode)
// exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Post ServiceOrder Received a bad response from 3rdONAP External API")
}
-
+
msoLogger.info("Exit " + doCreateE2ESIin3rdONAP)
}
-
+
public void getE2ESIProgressin3rdONAP(DelegateExecution execution) {
msoLogger.info(" ***** Started getE2ESIProgressin3rdONAP *****")
-
+
String extAPIPath = execution.getVariable("ExternalAPIURL")
extAPIPath += "/" + execution.getVariable("ServiceOrderId")
utils.log("DEBUG", "getE2ESIProgressin3rdONAP create externalAPIURL is: " + extAPIPath, isDebugEnabled)
-
+
ExternalAPIUtil externalAPIUtil = new ExternalAPIUtil()
- APIResponse response = externalAPIUtil.executeExternalAPIGetCall(execution, extAPIPath)
+ Response response = externalAPIUtil.executeExternalAPIGetCall(execution, extAPIPath)
- int responseCode = response.getStatusCode()
+ int responseCode = response.getStatus()
execution.setVariable(Prefix + "GetServiceOrderResponseCode", responseCode)
msoLogger.debug("Get ServiceOrder response code is: " + responseCode)
- String extApiResponse = response.getResponseBodyAsString()
+ String extApiResponse = response.readEntity(String.class)
JSONObject responseObj = new JSONObject(extApiResponse)
execution.setVariable(Prefix + "GetServiceOrderResponse", extApiResponse)
-
+
msoLogger.debug("getE2ESIProgressin3rdONAP create response body is: " + extApiResponse)
-
+
//Process Response //200 OK 201 CREATED 202 ACCEPTED
if(responseCode == 200 || responseCode == 201 || responseCode == 202 )
{
@@ -511,7 +514,7 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
String serviceOrderState = item.get("state")
execution.setVariable(Prefix + "SuccessIndicator", true)
execution.setVariable("ServiceOrderState", serviceOrderState)
-
+
// Get serviceOrder State and process progress
if("ACKNOWLEDGED".equalsIgnoreCase(serviceOrderState)) {
execution.setVariable("progress", 15)
@@ -539,17 +542,17 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
execution.setVariable("statusDescription", "Create Service Order Status is unknown")
}
}
- else{
+ else{
msoLogger.debug("Get ServiceOrder Received a Bad Response Code. Response Code is: " + responseCode)
execution.setVariable("progress", 100)
execution.setVariable("status", "error")
execution.setVariable("statusDescription", "Get Create ServiceOrder Received a bad response")
exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Get Create ServiceOrder Received a bad response from 3rdONAP External API")
- }
-
+ }
+
msoLogger.info("Exit " + getE2ESIProgressin3rdONAP)
}
-
+
/**
* delay 5 sec
*/
@@ -562,8 +565,8 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
}
public void saveSPPartnerInAAI(DelegateExecution execution) {
- msoLogger.info(" ***** Started saveSPPartnerInAAI *****")
-
+ msoLogger.info(" ***** Started saveSPPartnerInAAI *****")
+
String sppartnerId = execution.getVariable(Prefix + "SppartnerServiceId")
String sppartnerUrl = execution.getVariable(Prefix + "SppartnerUrl")
String callSource = execution.getVariable(Prefix + "CallSource")
@@ -574,57 +577,21 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
String resourceModelUuid = execution.getVariable(Prefix + "ResourceModelUuid")
String resourceModelCustomizationUuid = execution.getVariable(Prefix + "ResourceModelCustomizationUuid")
- AaiUtil aaiUriUtil = new AaiUtil()
- String aai_uri = aaiUriUtil.getBusinessSPPartnerUri(execution)
- String namespace = aaiUriUtil.getNamespaceFromUri(aai_uri)
-
- String payload =
- """<sp-partner xmlns=\"${namespace}\">
- <id>${sppartnerId}</id>
- <url>${sppartnerUrl}</url>
- <callsource>${callSource}</callsource>
- <model-invariant-id>${resourceModelInvariantUuid}</model-invariant-id>
- <model-version-id>${resourceModelUuid}</model-version-id>
- <model-customization-id>${resourceModelCustomizationUuid}</model-customization-id>
- <relationship-list>
- <relationship>
- <related-to>service-instance</related-to>
- <related-link>/aai/v14/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${serviceType}/service-instances/service-instance/${serviceInstanceId}</related-link>
- <relationship-data>
- <relationship-key>service-instance.service-instance-id</relationship-key>
- <relationship-value>${serviceInstanceId}</relationship-value>
- </relationship-data>
- </relationship>
- </relationship-list>
- </sp-partner>""".trim()
- utils.logAudit(payload)
-
- String aai_endpoint = execution.getVariable("URN_aai_endpoint")
- String serviceAaiPath = "${aai_endpoint}${aai_uri}/" + UriUtils.encode(sppartnerId,"UTF-8")
-
- APIResponse response = aaiUriUtil.executeAAIPutCall(execution, serviceAaiPath, payload)
- int responseCode = response.getStatusCode()
- execution.setVariable(Prefix + "PutSppartnerResponseCode", responseCode)
- msoLogger.debug("Put sppartner response code is: " + responseCode)
+ SpPartner partner = new SpPartner()
+ partner.setSpPartnerId(sppartnerId)
+ partner.setUrl(sppartnerUrl)
+ partner.setCallsource(callSource)
+ partner.setModelInvariantId(resourceModelInvariantUuid)
+ partner.setModelVersionId(resourceModelUuid)
+ partner.setModelCustomizationId(resourceModelCustomizationUuid)
- String aaiResponse = response.getResponseBodyAsString()
- aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse)
- execution.setVariable(Prefix + "PutSppartnerResponse", aaiResponse)
+ AAIResourcesClient client = new AAIResourcesClient()
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SP_PARTNER, sppartnerId)
+ client.create(uri, partner)
+
+ AAIResourceUri siUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId, serviceType, serviceInstanceId)
+ client.connect(uri, siUri)
- //Process Response
- if(responseCode == 200 || responseCode == 201 || responseCode == 202 )
- //200 OK 201 CREATED 202 ACCEPTED
- {
- msoLogger.debug("PUT sppartner Received a Good Response")
- execution.setVariable(Prefix + "SuccessIndicator", true)
- }
- else
- {
- msoLogger.debug("Put sppartner Received a Bad Response Code. Response Code is: " + responseCode)
- exceptionUtil.MapAAIExceptionToWorkflowExceptionGeneric(execution, aaiResponse, responseCode)
- throw new BpmnError("MSOWorkflowException")
- }
-
msoLogger.info("Exit " + saveSPPartnerInAAI)
}
@@ -632,7 +599,7 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
def dbAdapterEndpoint = execution.getVariable("URN_mso_adapters_openecomp_db_endpoint")
execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint)
execution.setVariable("CVFMI_updateResOperStatusRequest", body)
- }
+ }
public void postProcess(DelegateExecution execution){
msoLogger.info(" ***** Started postProcess *****")
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateDeviceResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateDeviceResource.groovy
index 89a6239be7..8fc9ce0883 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateDeviceResource.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateDeviceResource.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.
@@ -26,27 +26,23 @@ import org.json.XML;
import static org.apache.commons.lang3.StringUtils.*;
import groovy.xml.XmlUtil
import groovy.json.*
-import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
+import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
import org.onap.so.bpmn.common.scripts.ExceptionUtil
import org.onap.so.bpmn.common.recipe.ResourceInput;
-import org.onap.so.bpmn.common.resource.ResourceRequestBuilder
-import org.onap.so.bpmn.core.WorkflowException
+import org.onap.so.bpmn.common.resource.ResourceRequestBuilder
+import org.onap.so.bpmn.core.WorkflowException
import org.onap.so.bpmn.core.json.JsonUtils
import org.onap.so.bpmn.infrastructure.workflow.serviceTask.client.builder.AbstractBuilder
import org.onap.so.logger.MsoLogger
-import org.onap.so.rest.APIResponse
import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils
import java.util.UUID;
-import org.camunda.bpm.engine.delegate.BpmnError
+import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
import org.apache.commons.lang3.*
import org.apache.commons.codec.binary.Base64;
-import org.springframework.web.util.UriUtils
-import org.onap.so.rest.RESTClient
-import org.onap.so.rest.RESTConfig
-import org.onap.so.rest.APIResponse;
+import org.springframework.web.util.UriUtils
import org.onap.so.bpmn.common.scripts.AaiUtil
/**
@@ -56,18 +52,18 @@ import org.onap.so.bpmn.common.scripts.AaiUtil
public class CreateDeviceResource extends AbstractServiceTaskProcessor {
String Prefix="CREDEVRES_"
-
+
ExceptionUtil exceptionUtil = new ExceptionUtil()
JsonUtils jsonUtil = new JsonUtils()
-
+
private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, CreateDeviceResource.class)
public void preProcessRequest(DelegateExecution execution){
msoLogger.info(" ***** Started preProcessRequest *****")
String msg = ""
- try {
-
+ try {
+
//get bpmn inputs from resource request.
String requestId = execution.getVariable("mso-request-id")
String requestAction = execution.getVariable("requestAction")
@@ -90,10 +86,10 @@ public class CreateDeviceResource extends AbstractServiceTaskProcessor {
// String requestInputs = JsonUtils.getJsonValue(serviceParameters, "requestInputs")
// JSONObject serviceInputParameters = new JSONObject(requestInputs)
// execution.setVariable(Prefix + "ServiceParameters", serviceInputParameters)
-
+
//Deal with recipeParams
String recipeParamsFromWf = execution.getVariable("recipeParamXsd")
- String resourceName = resourceInputObj.getResourceInstanceName()
+ String resourceName = resourceInputObj.getResourceInstanceName()
if (isBlank(resourceName)) {
msg = "Input resourceName is null"
msoLogger.error(msg)
@@ -108,7 +104,7 @@ public class CreateDeviceResource extends AbstractServiceTaskProcessor {
}
execution.setVariable(Prefix + "ResourceModelInvariantUuid", resourceModelInvariantUuid)
msoLogger.info("resourceModelInvariantUuid:" + resourceModelInvariantUuid)
-
+
String resourceModelUuid = resourceInputObj.getResourceModelInfo().getModelUuid()
if (isBlank(resourceModelUuid)) {
msg = "Input resourceModelUuid is null"
@@ -116,7 +112,7 @@ public class CreateDeviceResource extends AbstractServiceTaskProcessor {
}
execution.setVariable(Prefix + "ResourceModelUuid", resourceModelUuid)
msoLogger.info("resourceModelUuid:" + resourceModelUuid)
-
+
String resourceModelCustomizationUuid = resourceInputObj.getResourceModelInfo().getModelCustomizationUuid()
if (isBlank(resourceModelCustomizationUuid)) {
msg = "Input resourceModelCustomizationUuid is null"
@@ -127,7 +123,7 @@ public class CreateDeviceResource extends AbstractServiceTaskProcessor {
execution.setVariable(Prefix + "serviceInstanceId", resourceInputObj.getServiceInstanceId())
execution.setVariable("mso-request-id", requestId)
-
+
} catch (BpmnError e) {
throw e;
} catch (Exception ex){
@@ -136,22 +132,22 @@ public class CreateDeviceResource extends AbstractServiceTaskProcessor {
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
}
}
-
+
public void checkDevType(DelegateExecution execution){
msoLogger.info(" ***** Started checkDevType *****")
try {
JSONObject resourceInputParameters = execution.getVariable(Prefix + "ResourceRequestInputs")
String devType = resourceInputParameters.get("device_class")
-
+
if(StringUtils.isBlank(devType)) {
devType = "OTHER"
}
- // support VNF as PNF, to modify
+ // support VNF as PNF, to modify
else if(StringUtils.equalsIgnoreCase(devType, "VNF")) {
devType = "PNF"
- }
-
+ }
+
execution.setVariable("device_class", devType)
} catch (Exception ex){
@@ -160,13 +156,13 @@ public class CreateDeviceResource extends AbstractServiceTaskProcessor {
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
}
}
-
+
private void setProgressUpdateVariables(DelegateExecution execution, String body) {
def dbAdapterEndpoint = execution.getVariable("URN_mso_adapters_openecomp_db_endpoint")
execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint)
execution.setVariable("CVFMI_updateResOperStatusRequest", body)
}
-
+
public void prepareUpdateProgress(DelegateExecution execution) {
msoLogger.info(" ***** Started prepareUpdateProgress *****")
ResourceInput resourceInputObj = execution.getVariable(Prefix + "ResourceInput")
@@ -199,7 +195,7 @@ public class CreateDeviceResource extends AbstractServiceTaskProcessor {
setProgressUpdateVariables(execution, body)
msoLogger.info(" ***** Exit prepareUpdateProgress *****")
}
-
+
public void getVNFTemplatefromSDC(DelegateExecution execution){
msoLogger.info(" ***** Started getVNFTemplatefromSDC *****")
try {
@@ -212,7 +208,7 @@ public class CreateDeviceResource extends AbstractServiceTaskProcessor {
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
}
}
-
+
public void postVNFInfoProcess(DelegateExecution execution){
msoLogger.info(" ***** Started postVNFInfoProcess *****")
try {
@@ -225,7 +221,7 @@ public class CreateDeviceResource extends AbstractServiceTaskProcessor {
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
}
}
-
+
public void sendSyncResponse (DelegateExecution execution) {
msoLogger.debug(" *** sendSyncResponse *** ")
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy
index 47b3cc351f..4b5737c776 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.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.
@@ -25,14 +25,19 @@ import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
import org.json.JSONObject
import org.json.XML
+import org.onap.aai.domain.yang.ServiceInstance
+import org.onap.aai.domain.yang.ServiceInstances
import org.onap.so.bpmn.common.recipe.ResourceInput
import org.onap.so.bpmn.common.resource.ResourceRequestBuilder
import org.onap.so.bpmn.common.scripts.AaiUtil
import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
import org.onap.so.bpmn.common.scripts.ExceptionUtil
import org.onap.so.bpmn.core.json.JsonUtils
+import org.onap.so.client.aai.AAIObjectPlurals
+import org.onap.so.client.aai.AAIResourcesClient
+import org.onap.so.client.aai.entities.uri.AAIResourceUri
+import org.onap.so.client.aai.entities.uri.AAIUriFactory
import org.onap.so.logger.MsoLogger
-import org.onap.so.rest.APIResponse
import static org.apache.commons.lang3.StringUtils.*
@@ -50,7 +55,7 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor {
JsonUtils jsonUtil = new JsonUtils()
public void preProcessRequest(DelegateExecution execution){
-
+
msoLogger.info(" ***** Started preProcessRequest *****")
try {
@@ -208,27 +213,20 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor {
def vpnName = StringUtils.containsIgnoreCase(modelName, "sotnvpnattachment") ? "sotnvpnattachmentvf_sotncondition_sotnVpnName" : "sdwanvpnattachmentvf_sdwancondition_sdwanVpnName"
String parentServiceName = jsonUtil.getJsonValueForKey(resourceInputObj.getRequestsInputs(), vpnName)
- AaiUtil aaiUtil = new AaiUtil(this)
- String aai_endpoint = execution.getVariable("URN_aai_endpoint")
- String customerUri = aaiUtil.getBusinessCustomerUri(execution) + "/" + customer
- String aai_service_query_url = aai_endpoint + customerUri + "/service-subscriptions/service-subscription/" + serviceType + "/service-instances?service-instance-name=" + parentServiceName
+ AAIResourcesClient client = new AAIResourcesClient()
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.SERVICE_INSTANCE, customer, serviceType).queryParam("service-instance-name", parentServiceName)
+ ServiceInstances sis = client.get(uri).asBean(ServiceInstances.class).get()
+ ServiceInstance si = sis.getServiceInstance().get(0)
- APIResponse aaiResponse = aaiUtil.executeAAIGetCall(execution, aai_service_query_url)
- def parentServiceInstanceId = getParentServiceInstnaceId(aaiResponse)
- execution.setVariable("parentServiceInstanceId", parentServiceInstanceId)
- break
+ def parentServiceInstanceId = si.getServiceInstanceId()
+ execution.setVariable("parentServiceInstanceId", parentServiceInstanceId)
+ break
default:
break
}
}
- private String getParentServiceInstnaceId(APIResponse aaiResponse) {
- String response = aaiResponse.getResponseBodyAsString()
- def xmlResp = new XmlParser().parseText(response)
- return "${xmlResp?."service-instance"[0]?."service-instance-id"[0]?.text()}"
- }
-
/**
* Pre Process the BPMN Flow Request
* Includes:
@@ -388,7 +386,7 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor {
// for SDWANConnectivity and SOTNConnectivity:
default:
sdncTopologyCreateRequest = """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1"
- xmlns:sdncadapter="http://org.onap.so/workflow/sdnc/adapter/schema/v1"
+ xmlns:sdncadapter="http://org.onap.so/workflow/sdnc/adapter/schema/v1"
xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1">
<sdncadapter:RequestHeader>
<sdncadapter:RequestId>${hdrRequestId}</sdncadapter:RequestId>
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVFCNSResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVFCNSResource.groovy
index 409b8dfd1c..e3702f1014 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVFCNSResource.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVFCNSResource.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.
@@ -25,17 +25,16 @@ import org.onap.so.client.aai.entities.uri.AAIResourceUri
import org.onap.so.client.aai.entities.uri.AAIUriFactory;
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.bpmn.common.scripts.ExceptionUtil
+import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
+import org.onap.so.bpmn.common.scripts.ExceptionUtil
import org.onap.so.bpmn.core.json.JsonUtils
import org.onap.so.client.HttpClient
import org.onap.so.logger.MessageEnum
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 groovy.json.*
+import javax.ws.rs.core.Response
+import org.onap.so.utils.TargetEntity
/**
* This groovy class supports the <class>DoCreateVFCNetworkServiceInstance.bpmn</class> process.
@@ -46,9 +45,9 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor {
String vfcUrl = "/vfc/rest/v1/vfcadapter"
-
+
String host = "http://mso.mso.testlab.openecomp.org:8080"
-
+
ExceptionUtil exceptionUtil = new ExceptionUtil()
JsonUtils jsonUtil = new JsonUtils()
@@ -116,7 +115,7 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor {
execution.setVariable("nsOperationKey", nsOperationKey);
execution.setVariable("nsParameters", nsParameters)
execution.setVariable("nsServiceModelUUID", nsServiceModelUUID);
-
+
} catch (BpmnError e) {
throw e;
@@ -150,9 +149,9 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor {
"additionalParamForNs":${requestInputs}
}
}"""
- APIResponse apiResponse = postRequest(execution, host + vfcUrl + "/ns", reqBody)
- String returnCode = apiResponse.getStatusCode()
- String aaiResponseAsString = apiResponse.getResponseBodyAsString()
+ Response apiResponse = postRequest(execution, host + vfcUrl + "/ns", reqBody)
+ String returnCode = apiResponse.getStatus()
+ String aaiResponseAsString = apiResponse.readEntity(String.class)
String nsInstanceId = "";
if(returnCode== "200" || returnCode == "201"){
nsInstanceId = jsonUtil.getJsonValue(aaiResponseAsString, "nsInstanceId")
@@ -178,9 +177,9 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor {
}"""
String nsInstanceId = execution.getVariable("nsInstanceId")
String url = host + vfcUrl + "/ns/" +nsInstanceId + "/instantiate"
- APIResponse apiResponse = postRequest(execution, url, reqBody)
- String returnCode = apiResponse.getStatusCode()
- String aaiResponseAsString = apiResponse.getResponseBodyAsString()
+ Response apiResponse = postRequest(execution, url, reqBody)
+ String returnCode = apiResponse.getStatus()
+ String aaiResponseAsString = apiResponse.readEntity(String.class)
String jobId = "";
if(returnCode== "200"|| returnCode == "201"){
jobId = jsonUtil.getJsonValue(aaiResponseAsString, "jobId")
@@ -197,9 +196,9 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor {
String jobId = execution.getVariable("jobId")
String nsOperationKey = execution.getVariable("nsOperationKey");
String url = host + vfcUrl + "/jobs/" + jobId
- APIResponse apiResponse = postRequest(execution, url, nsOperationKey)
- String returnCode = apiResponse.getStatusCode()
- String aaiResponseAsString = apiResponse.getResponseBodyAsString()
+ Response apiResponse = postRequest(execution, url, nsOperationKey)
+ String returnCode = apiResponse.getStatus()
+ String aaiResponseAsString = apiResponse.readEntity(String.class)
String operationStatus = "error"
if(returnCode== "200"|| returnCode == "201"){
operationStatus = jsonUtil.getJsonValue(aaiResponseAsString, "responseDescriptor.status")
@@ -209,12 +208,12 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor {
}
/**
- * delay 5 sec
+ * delay 5 sec
*/
public void timeDelay(DelegateExecution execution) {
try {
Thread.sleep(5000);
- } catch(InterruptedException e) {
+ } catch(InterruptedException e) {
msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Time Delay exception" + e , "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
}
}
@@ -250,23 +249,29 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor {
* url: the url of the request
* requestBody: the body of the request
*/
- private APIResponse postRequest(DelegateExecution execution, String url, String requestBody){
+ private Response postRequest(DelegateExecution execution, String urlString, String requestBody){
msoLogger.trace("Started Execute VFC adapter Post Process ")
msoLogger.info("url:"+url +"\nrequestBody:"+ requestBody)
- APIResponse apiResponse = null
+ Response apiResponse = null
try{
- RESTConfig config = new RESTConfig(url);
- RESTClient client = new RESTClient(config).addHeader("Content-Type", "application/json").addHeader("Accept","application/json").addHeader("Authorization","Basic QlBFTENsaWVudDpwYXNzd29yZDEk");
- apiResponse = client.httpPost(requestBody)
- msoLogger.info("response code:"+ apiResponse.getStatusCode() +"\nresponse body:"+ apiResponse.getResponseBodyAsString())
+
+ URL url = new URL(urlString);
+
+ HttpClient httpClient = new HttpClient(url, "application/json", TargetEntity.VNF_ADAPTER)
+ httpClient.addAdditionalHeader("Accept", "application/json")
+ httpClient.addAdditionalHeader("Authorization", "Basic QlBFTENsaWVudDpwYXNzd29yZDEk")
+
+ apiResponse = httpClient.post(requestBody)
+
+ msoLogger.info("response code:"+ apiResponse.getStatus() +"\nresponse body:"+ apiResponse.readEntity(String.class))
msoLogger.trace("Completed Execute VF-C adapter 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);
throw new BpmnError("MSOWorkflowException")
- }
+ }
return apiResponse
}
-
+
public void sendSyncResponse (DelegateExecution execution) {
def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
utils.log("DEBUG", " *** sendSyncResponse *** ", isDebugEnabled)
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Delete3rdONAPE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Delete3rdONAPE2EServiceInstance.groovy
index 56e5be04a5..46c0c4bfa0 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Delete3rdONAPE2EServiceInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Delete3rdONAPE2EServiceInstance.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,39 +20,31 @@
package org.onap.so.bpmn.infrastructure.scripts
+import javax.ws.rs.NotFoundException
+import javax.ws.rs.core.Response
+
+import org.apache.commons.lang3.StringUtils
+import org.camunda.bpm.engine.delegate.BpmnError
+import org.camunda.bpm.engine.delegate.DelegateExecution
import org.json.JSONArray
import org.json.JSONObject
-import org.json.XML
-
-import static org.apache.commons.lang3.StringUtils.*
-import groovy.xml.XmlUtil
+import org.onap.aai.domain.yang.SpPartner
+import org.onap.so.bpmn.common.recipe.ResourceInput
+import org.onap.so.bpmn.common.resource.ResourceRequestBuilder
+import org.onap.so.bpmn.common.scripts.AaiUtil
import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
import org.onap.so.bpmn.common.scripts.ExceptionUtil
import org.onap.so.bpmn.common.scripts.ExternalAPIUtil
-import org.onap.so.bpmn.common.scripts.AaiUtil
-import org.onap.so.bpmn.common.scripts.MsoUtils
-import org.onap.so.bpmn.common.recipe.ResourceInput
-import org.onap.so.bpmn.common.resource.ResourceRequestBuilder
-import org.onap.so.bpmn.core.WorkflowException
import org.onap.so.bpmn.core.json.JsonUtils
-import org.onap.so.bpmn.infrastructure.workflow.serviceTask.client.builder.AbstractBuilder
-import org.onap.so.rest.APIResponse
-import org.onap.so.bpmn.infrastructure.workflow.service.ServicePluginFactory
-import java.util.UUID
+import org.onap.so.client.aai.AAIObjectType
+import org.onap.so.client.aai.AAIResourcesClient
+import org.onap.so.client.aai.entities.uri.AAIResourceUri
+import org.onap.so.client.aai.entities.uri.AAIUriFactory
import org.onap.so.logger.MsoLogger
-import org.camunda.bpm.engine.runtime.Execution
-import org.camunda.bpm.engine.delegate.BpmnError
-import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.apache.commons.lang3.*
-import org.apache.commons.codec.binary.Base64
-import org.springframework.web.util.UriUtils
-import org.onap.so.rest.RESTClient
-import org.onap.so.rest.RESTConfig
-
/**
* This groovy class supports the <class>Delete3rdONAPE2EServiceInstance.bpmn</class> process.
- * flow for Delete 3rdONAPE2EServiceInstance in 3rdONAP
+ * flow for Delete 3rdONAPE2EServiceInstance in 3rdONAP
*/
public class Delete3rdONAPE2EServiceInstance extends AbstractServiceTaskProcessor {
@@ -79,33 +71,31 @@ public class Delete3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
ResourceInput resourceInputObj = ResourceRequestBuilder.getJsonObject(resourceInput, ResourceInput.class)
// set local resourceInput
execution.setVariable(Prefix + "ResourceInput", resourceInputObj)
-
+
String resourceInstanceId = resourceInputObj.getResourceInstancenUuid()
String sppartnerId = resourceInstanceId
execution.setVariable(Prefix + "SppartnerId", sppartnerId)
-
+
// Get Sppartner from AAI
- AaiUtil aaiUriUtil = new AaiUtil()
- String aai_uri = aaiUriUtil.getBusinessSPPartnerUri(execution)
- String namespace = aaiUriUtil.getNamespaceFromUri(aai_uri)
- String aai_endpoint = execution.getVariable("URN_aai_endpoint")
- String serviceAaiPath = "${aai_endpoint}${aai_uri}/" + UriUtils.encode(sppartnerId,"UTF-8")
- execution.setVariable(Prefix + "ServiceAaiPath", serviceAaiPath)
-
+ AaiUtil aaiUriUtil = new AaiUtil(this)
+ AAIResourceUri spPartner = AAIUriFactory.createResourceUri(AAIObjectType.SP_PARTNER, sppartnerId)
+ String spPartnerUri = aaiUriUtil.createAaiUri(spPartner)
+ execution.setVariable(Prefix + "ServiceAaiPath", spPartnerUri)
+
getSPPartnerInAAI(execution)
-
+
String callSource = "UUI"
String sppartnerUrl = ""
if(execution.hasVariable(Prefix + "CallSource")) {
callSource = execution.getVariable(Prefix + "CallSource")
sppartnerUrl = execution.getVariable(Prefix + "SppartnerUrl")
}
-
- boolean is3rdONAPExist = false
- if(!isBlank(sppartnerUrl)) {
+
+ boolean is3rdONAPExist = false
+ if(!isBlank(sppartnerUrl)) {
is3rdONAPExist = true
}
-
+
execution.setVariable("Is3rdONAPExist", is3rdONAPExist)
execution.setVariable(Prefix + "ServiceInstanceId", resourceInputObj.getServiceInstanceId())
execution.setVariable("mso-request-id", requestId)
@@ -122,7 +112,7 @@ public class Delete3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
public void checkLocallCall (DelegateExecution execution) {
msoLogger.info(" ***** Started checkLocallCall *****")
-
+
boolean isLocalCall = true
String callSource = execution.getVariable(Prefix + "CallSource")
if("ExternalAPI".equalsIgnoreCase(callSource)) {
@@ -136,7 +126,7 @@ public class Delete3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
String msg = ""
try {
- ResourceInput resourceInputObj = execution.getVariable(Prefix + "ResourceInput")
+ ResourceInput resourceInputObj = execution.getVariable(Prefix + "ResourceInput")
String globalSubscriberId = resourceInputObj.getGlobalSubscriberId()
if (isBlank(globalSubscriberId)) {
@@ -154,15 +144,15 @@ public class Delete3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
}
execution.setVariable("serviceType", serviceType)
msoLogger.info( "serviceType:" + serviceType)
-
- String operationId = resourceInputObj.getOperationId()
+
+ String operationId = resourceInputObj.getOperationId()
if (isBlank(operationId)) {
msg = "Input operationId is null"
msoLogger.error( msg)
}
execution.setVariable("operationId", operationId)
msoLogger.info( "operationId:" + operationId)
-
+
String resourceName = resourceInputObj.getResourceInstanceName()
if (isBlank(resourceName)) {
msg = "Input resourceName is null"
@@ -170,7 +160,7 @@ public class Delete3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
}
execution.setVariable("resourceName", resourceName)
msoLogger.info("resourceName:" + resourceName)
-
+
String resourceTemplateId = resourceInputObj.getResourceModelInfo().getModelCustomizationUuid()
if (isBlank(resourceTemplateId)) {
msg = "Input resourceTemplateId is null"
@@ -223,11 +213,11 @@ public class Delete3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
public void prepare3rdONAPRequest(DelegateExecution execution) {
msoLogger.info(" ***** Started prepare3rdONAPRequest *****")
-
+
String sppartnerUrl = execution.getVariable(Prefix + "SppartnerUrl")
String extAPIPath = sppartnerUrl + '/serviceOrder'
execution.setVariable("ExternalAPIURL", extAPIPath)
-
+
// ExternalAPI message format
String externalId = execution.getVariable("resourceName")
String category = "E2E Service"
@@ -245,10 +235,10 @@ public class Delete3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
String serviceName = ""
String serviceType = execution.getVariable("serviceType")
String serviceId = execution.getVariable(Prefix + "SppartnerId")
-
+
queryServicefrom3rdONAP(execution)
- String serviceSpecificationId = execution.getVariable(Prefix + "ServiceSpecificationId")
-
+ String serviceSpecificationId = execution.getVariable(Prefix + "ServiceSpecificationId")
+
Map<String, String> valueMap = new HashMap<>()
valueMap.put("externalId", '"' + externalId + '"')
valueMap.put("category", '"' + category + '"')
@@ -266,20 +256,20 @@ public class Delete3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
valueMap.put("serviceId", '"' + serviceId + '"')
valueMap.put("serviceName", "null")
valueMap.put("serviceUuId", '"' + serviceSpecificationId + '"')
-
+
ExternalAPIUtil externalAPIUtil = new ExternalAPIUtil()
-
+
valueMap.put("_requestInputs_", "")
-
+
String payload = externalAPIUtil.setTemplate(ExternalAPIUtil.PostServiceOrderRequestsTemplate, valueMap)
execution.setVariable(Prefix + "Payload", payload)
msoLogger.info( "Exit " + prepare3rdONAPRequest)
}
-
+
private void queryServicefrom3rdONAP(DelegateExecution execution)
{
msoLogger.info(" ***** Started queryServicefrom3rdONAP *****")
-
+
String globalSubscriberId = execution.getVariable("globalSubscriberId")
String SppartnerServiceId = execution.getVariable(Prefix + "SppartnerId")
@@ -290,17 +280,17 @@ public class Delete3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
ExternalAPIUtil externalAPIUtil = new ExternalAPIUtil()
- APIResponse response = externalAPIUtil.executeExternalAPIGetCall(execution, extAPIPath)
+ Response response = externalAPIUtil.executeExternalAPIGetCall(execution, extAPIPath)
- int responseCode = response.getStatusCode()
+ int responseCode = response.getStatus()
execution.setVariable(Prefix + "GetServiceResponseCode", responseCode)
msoLogger.debug("Get Service response code is: " + responseCode)
- String extApiResponse = response.getResponseBodyAsString()
+ String extApiResponse = response.readEntity(String.class)
- execution.setVariable(Prefix + "GetServiceResponse", extApiResponse)
+ execution.setVariable(Prefix + "GetServiceResponse", extApiResponse)
msoLogger.debug("queryServicefrom3rdONAP response body is: " + extApiResponse)
-
+
//Process Response //200 OK 201 CREATED 202 ACCEPTED
if(responseCode == 200 || responseCode == 201 || responseCode == 202 )
{
@@ -320,27 +310,27 @@ public class Delete3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
msoLogger.error("Get Service Received a Bad Response Code. Response Code is: " + responseCode)
// exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Get Service Received a bad response from 3rdONAP External API")
}
-
+
msoLogger.info( "Exit " + queryServicefrom3rdONAP)
}
public void doDeleteE2ESIin3rdONAP(DelegateExecution execution) {
msoLogger.info(" ***** Started doDeleteE2ESIin3rdONAP *****")
-
+
String extAPIPath = execution.getVariable("ExternalAPIURL")
String payload = execution.getVariable(Prefix + "Payload")
msoLogger.debug("doDeleteE2ESIin3rdONAP externalAPIURL is: " + extAPIPath)
msoLogger.debug("doDeleteE2ESIin3rdONAP payload is: " + payload)
-
+
ExternalAPIUtil externalAPIUtil = new ExternalAPIUtil()
- APIResponse response = externalAPIUtil.executeExternalAPIPostCall(execution, extAPIPath, payload)
+ Response response = externalAPIUtil.executeExternalAPIPostCall(execution, extAPIPath, payload)
- int responseCode = response.getStatusCode()
+ int responseCode = response.getStatus()
execution.setVariable(Prefix + "PostServiceOrderResponseCode", responseCode)
msoLogger.debug("Post ServiceOrder response code is: " + responseCode)
- String extApiResponse = response.getResponseBodyAsString()
+ String extApiResponse = response.readEntity(String.class)
JSONObject responseObj = new JSONObject(extApiResponse)
execution.setVariable(Prefix + "PostServiceOrderResponse", extApiResponse)
@@ -360,31 +350,31 @@ public class Delete3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
msoLogger.error("Post ServiceOrder Received a Bad Response Code. Response Code is: " + responseCode)
exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Post ServiceOrder Received a bad response from 3rdONAP External API")
}
-
+
msoLogger.info( "Exit " + doDeleteE2ESIin3rdONAP)
}
-
+
public void getE2ESIProgressin3rdONAP(DelegateExecution execution) {
msoLogger.info(" ***** Started getE2ESIProgressin3rdONAP *****")
-
+
String extAPIPath = execution.getVariable("ExternalAPIURL")
extAPIPath += "/" + execution.getVariable("ServiceOrderId")
msoLogger.debug("getE2ESIProgressin3rdONAP delete externalAPIURL is: " + extAPIPath)
-
+
ExternalAPIUtil externalAPIUtil = new ExternalAPIUtil()
- APIResponse response = externalAPIUtil.executeExternalAPIGetCall(execution, extAPIPath)
+ Response response = externalAPIUtil.executeExternalAPIGetCall(execution, extAPIPath)
- int responseCode = response.getStatusCode()
+ int responseCode = response.getStatus()
execution.setVariable(Prefix + "GetServiceOrderResponseCode", responseCode)
msoLogger.debug("Get ServiceOrder response code is: " + responseCode)
- String extApiResponse = response.getResponseBodyAsString()
+ String extApiResponse = response.readEntity(String.class)
JSONObject responseObj = new JSONObject(extApiResponse)
execution.setVariable(Prefix + "GetServiceOrderResponse", extApiResponse)
-
- utils.log("DEBUG", "getE2ESIProgressin3rdONAP delete response body is: " + extApiResponse, isDebugEnabled)
+
+ utils.log("DEBUG", "getE2ESIProgressin3rdONAP delete response body is: " + extApiResponse)
//Process Response //200 OK 201 CREATED 202 ACCEPTED
if(responseCode == 200 || responseCode == 201 || responseCode == 202 )
@@ -443,17 +433,17 @@ public class Delete3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
execution.setVariable("statusDescription", "Delete Service Order Status is unknown")
}
}
- else{
+ else{
msoLogger.debug("Get ServiceOrder Received a Bad Response Code. Response Code is: " + responseCode)
execution.setVariable("progress", 100)
execution.setVariable("status", "error")
execution.setVariable("statusDescription", "Get Delete ServiceOrder Received a bad response")
exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Get Delete ServiceOrder Received a bad response from 3rdONAP External API")
- }
-
+ }
+
msoLogger.info( "Exit " + getE2ESIProgressin3rdONAP)
}
-
+
/**
* delay 5 sec
*/
@@ -466,86 +456,53 @@ public class Delete3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
}
private void getSPPartnerInAAI(DelegateExecution execution) {
- msoLogger.info(" ***** Started getSPPartnerInAAI *****")
-
- AaiUtil aaiUriUtil = new AaiUtil()
- String serviceAaiPath = execution.getVariable(Prefix + "ServiceAaiPath")
- APIResponse response = aaiUriUtil.executeAAIGetCall(execution, serviceAaiPath)
- int responseCode = response.getStatusCode()
- execution.setVariable(Prefix + "GetSppartnerResponseCode", responseCode)
- msoLogger.debug(" Get sppartner response code is: " + responseCode)
-
- String aaiResponse = response.getResponseBodyAsString()
- aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse)
- aaiResponse = aaiResponse.replaceAll("&", "&amp;")
- execution.setVariable(Prefix + "GetSppartnerResponse", aaiResponse)
+ msoLogger.info(" ***** Started getSPPartnerInAAI *****")
+ String id = execution.getVariable(Prefix + "SppartnerId")
+
+ AAIResourcesClient client = new AAIResourcesClient()
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SP_PARTNER, id)
+ SpPartner sp = client.get(uri).asBean(SpPartner.class).get()
+
+ msoLogger.debug("GET sppartner Received a Good Response")
+ execution.setVariable(Prefix + "SuccessIndicator", true)
+ execution.setVariable(Prefix + "FoundIndicator", true)
+
+ String sppartnerId = sp.getSpPartnerId()
+ execution.setVariable(Prefix + "SppartnerId", sppartnerId)
+ msoLogger.debug(" SppartnerId is: " + sppartnerId)
+ String sppartnerUrl = sp.getUrl()
+ execution.setVariable(Prefix + "SppartnerUrl", sppartnerUrl)
+ msoLogger.debug(" SppartnerUrl is: " + sppartnerUrl)
+ String callSource = sp.getCallsource()
+ execution.setVariable(Prefix + "CallSource", callSource)
+ msoLogger.debug(" CallSource is: " + callSource)
+ String sppartnerVersion = sp.getResourceVersion()
+ execution.setVariable(Prefix + "SppartnerVersion", sppartnerVersion)
+ msoLogger.debug(" Resource Version is: " + sppartnerVersion)
+
- //Process Response
- if(responseCode == 200 || responseCode == 201 || responseCode == 202 )
- //200 OK 201 CREATED 202 ACCEPTED
- {
- msoLogger.debug("GET sppartner Received a Good Response")
- execution.setVariable(Prefix + "SuccessIndicator", true)
- execution.setVariable(Prefix + "FoundIndicator", true)
-
- String sppartnerId = utils.getNodeText1(aaiResponse, "sp-partner-id")
- execution.setVariable(Prefix + "SppartnerId", sppartnerId)
- msoLogger.debug(" SppartnerId is: " + sppartnerId)
- String sppartnerUrl = utils.getNodeText1(aaiResponse, "url")
- execution.setVariable(Prefix + "SppartnerUrl", sppartnerUrl)
- msoLogger.debug(" SppartnerUrl is: " + sppartnerUrl)
- String callSource = utils.getNodeText1(aaiResponse, "callsource")
- execution.setVariable(Prefix + "CallSource", callSource)
- msoLogger.debug(" CallSource is: " + callSource)
- String sppartnerVersion = utils.getNodeText1(aaiResponse, "resource-version")
- execution.setVariable(Prefix + "SppartnerVersion", sppartnerVersion)
- msoLogger.debug(" Resource Version is: " + sppartnerVersion)
- }
- else
- {
- msoLogger.debug("Get sppartner Received a Bad Response Code. Response Code is: " + responseCode)
-// exceptionUtil.MapAAIExceptionToWorkflowExceptionGeneric(execution, aaiResponse, responseCode)
-// throw new BpmnError("MSOWorkflowException")
- }
-
msoLogger.info( "Exit " + getSPPartnerInAAI)
}
-
+
public void deleteSPPartnerInAAI(DelegateExecution execution) {
msoLogger.info(" ***** Started deleteSPPartnerInAAI *****")
-
+
String sppartnerId = execution.getVariable(Prefix + "SppartnerId")
String sppartnerUrl = execution.getVariable(Prefix + "SppartnerUrl")
String sppartnerVersion = execution.getVariable(Prefix + "SppartnerVersion")
-
- AaiUtil aaiUriUtil = new AaiUtil()
- String serviceAaiPath = execution.getVariable(Prefix + "ServiceAaiPath") + "?resource-version=${sppartnerVersion}"
- APIResponse response = aaiUriUtil.executeAAIDeleteCall(execution, serviceAaiPath)
- int responseCode = response.getStatusCode()
- execution.setVariable(Prefix + "DeleteSppartnerResponseCode", responseCode)
- msoLogger.debug(" Get sppartner response code is: " + responseCode)
-
- String aaiResponse = response.getResponseBodyAsString()
- aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse)
- execution.setVariable(Prefix + "DeleteSppartnerResponse", aaiResponse)
- //Process Response
- if(responseCode == 200 || responseCode == 204 )
- {
+ AAIResourcesClient client = new AAIResourcesClient()
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SP_PARTNER, sppartnerId)
+ try {
+ client.delete(uri)
msoLogger.debug("Delete sppartner Received a Good Response")
execution.setVariable(Prefix + "SuccessIndicator", true)
- }
- else if(responseCode == 404){
+ } catch (NotFoundException e) {
msoLogger.debug(" Delete sppartner Received a Not Found (404) Response")
execution.setVariable(Prefix + "FoundIndicator", false)
}
- else
- {
- msoLogger.debug("Delete sppartner Received a Bad Response Code. Response Code is: " + responseCode)
-// exceptionUtil.MapAAIExceptionToWorkflowExceptionGeneric(execution, aaiResponse, responseCode)
-// throw new BpmnError("MSOWorkflowException")
- }
-
+ msoLogger.debug("Delete sppartner Received a Good Response")
+
msoLogger.info( "Exit " + deleteSPPartnerInAAI)
}
@@ -553,7 +510,7 @@ public class Delete3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
def dbAdapterEndpoint = execution.getVariable("URN_mso_adapters_openecomp_db_endpoint")
execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint)
execution.setVariable("CVFMI_updateResOperStatusRequest", body)
- }
+ }
public void postProcess(DelegateExecution execution){
msoLogger.info(" ***** Started postProcess *****")
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteDeviceResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteDeviceResource.groovy
index 71ce28d7d3..82be3e6a0c 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteDeviceResource.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteDeviceResource.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.
@@ -29,23 +29,23 @@ import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
import org.onap.so.bpmn.common.scripts.ExceptionUtil
import org.onap.so.bpmn.common.recipe.ResourceInput;
import org.onap.so.bpmn.common.resource.ResourceRequestBuilder
+import org.onap.so.bpmn.core.UrnPropertiesReader
import org.onap.so.bpmn.core.WorkflowException
import org.onap.so.bpmn.core.json.JsonUtils
import org.onap.so.bpmn.infrastructure.workflow.serviceTask.client.builder.AbstractBuilder
+import org.onap.so.client.HttpClient
import org.onap.so.logger.MsoLogger
-import org.onap.so.rest.APIResponse
import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils
import java.util.UUID;
-
+import javax.ws.rs.core.Response
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
import org.apache.commons.lang3.*
+import javax.ws.rs.core.MediaType
import org.apache.commons.codec.binary.Base64;
import org.springframework.web.util.UriUtils
-import org.onap.so.rest.RESTClient
-import org.onap.so.rest.RESTConfig
-import org.onap.so.rest.APIResponse;
+import org.onap.so.utils.TargetEntity
import org.onap.so.bpmn.common.scripts.AaiUtil
/**
@@ -106,20 +106,29 @@ public class DeleteDeviceResource extends AbstractServiceTaskProcessor {
private void getDeviceInAAI(DelegateExecution execution) {
msoLogger.info(" ***** Started getDeviceInAAI *****")
-
+
String deviceId = execution.getVariable(Prefix + "DeviceId")
AaiUtil aaiUriUtil = new AaiUtil()
String aai_uri = aaiUriUtil.getNetworkDeviceUri(execution)
String aai_endpoint = execution.getVariable("URN_aai_endpoint")
String serviceAaiPath = "${aai_endpoint}${aai_uri}/" + UriUtils.encode(deviceId,"UTF-8")
execution.setVariable(Prefix + "ServiceAaiPath", serviceAaiPath)
-
- APIResponse response = aaiUriUtil.executeAAIGetCall(execution, serviceAaiPath)
- int responseCode = response.getStatusCode()
+
+ URL url = new URL(serviceAaiPath)
+ 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 response = client.get()
+
+
+
+ int responseCode = response.getStatus()
execution.setVariable(Prefix + "GetDeviceResponseCode", responseCode)
msoLogger.debug(" Get device response code is: " + responseCode)
- String aaiResponse = response.getResponseBodyAsString()
+ String aaiResponse = response.readEntity(String.class)
aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse)
aaiResponse = aaiResponse.replaceAll("&", "&amp;")
execution.setVariable(Prefix + "GetDeviceResponse", aaiResponse)
@@ -131,8 +140,8 @@ public class DeleteDeviceResource extends AbstractServiceTaskProcessor {
msoLogger.debug("GET Device Received a Good Response")
execution.setVariable(Prefix + "SuccessIndicator", true)
execution.setVariable(Prefix + "FoundIndicator", true)
-
- String devClass = utils.getNodeText1(aaiResponse, "device_class")
+
+ String devClass = utils.getNodeText(aaiResponse, "device_class")
execution.setVariable(Prefix + "DeviceClass", devClass)
msoLogger.debug(" DeviceClass is: " + devClass)
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy
index 7cbbac5fbf..8c9ab3fe45 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy
@@ -39,7 +39,6 @@ import org.onap.so.client.aai.entities.uri.AAIUriFactory
import org.onap.so.constants.Defaults
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
-import org.onap.so.rest.APIResponse
import org.springframework.web.util.UriUtils
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareModelVersions.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareModelVersions.groovy
index 98605fea8b..9c9ed933e0 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareModelVersions.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCompareModelVersions.groovy
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* ONAP - SO
* ================================================================================
- * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved.
* ================================================================================
* 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.
@@ -40,9 +40,6 @@ import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils
import org.onap.so.bpmn.common.scripts.CatalogDbUtils;
import org.onap.so.bpmn.core.RollbackData
import org.onap.so.bpmn.core.WorkflowException
-import org.onap.so.rest.APIResponse;
-import org.onap.so.rest.RESTClient
-import org.onap.so.rest.RESTConfig
import java.util.List;
import java.util.UUID;
@@ -88,48 +85,48 @@ public class DoCompareModelVersions extends AbstractServiceTaskProcessor {
try {
execution.setVariable("prefix", Prefix)
-
+
//Inputs
String modelInvariantUuid_target = execution.getVariable("model-invariant-id-target")
if (isBlank(modelInvariantUuid_target)) {
msg = "Input model-invariant-id-target is null"
utils.log("INFO", msg, isDebugEnabled)
exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
- }
-
+ }
+
String modelUuid_target = execution.getVariable("model-version-id-target")
if (isBlank(modelUuid_target)) {
msg = "Input model-version-id-target is null"
utils.log("INFO", msg, isDebugEnabled)
exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
}
-
+
String modelInvariantUuid_original = execution.getVariable("model-invariant-id-original")
if (isBlank(modelInvariantUuid_original)) {
msg = "Input model-invariant-id-original is null"
utils.log("INFO", msg, isDebugEnabled)
exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
}
-
+
String modelUuid_original = execution.getVariable("model-version-id-original")
if (isBlank(modelUuid_original)) {
msg = "Input model-version-id-original is null"
utils.log("INFO", msg, isDebugEnabled)
exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
- }
-
+ }
+
// Target and original modelInvariantUuid must to be the same
if(modelInvariantUuid_target != modelInvariantUuid_original){
msg = "Input model-invariant-id-target and model-invariant-id-original must to be the same"
utils.log("INFO", msg, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
}
-
+
// Target and original modelUuid must not to be the same
if(modelUuid_target == modelUuid_original){
msg = "Input model-version-id-target and model-version-id-original must not to be the same"
utils.log("INFO", msg, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
}
} catch (Exception ex){
@@ -139,7 +136,7 @@ public class DoCompareModelVersions extends AbstractServiceTaskProcessor {
}
utils.log("INFO"," ***** Exit preProcessRequest *****", isDebugEnabled)
}
-
+
public void prepareDecomposeService_Target(DelegateExecution execution) {
def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
@@ -153,7 +150,7 @@ public class DoCompareModelVersions extends AbstractServiceTaskProcessor {
"modelUuid":"${modelUuid}",
"modelVersion":""
}"""
-
+
execution.setVariable("serviceModelInfo_Target", serviceModelInfo)
utils.log("DEBUG", " ***** Completed prepareDecomposeService_Target of update generic e2e service ***** ", isDebugEnabled)
@@ -166,8 +163,8 @@ public class DoCompareModelVersions extends AbstractServiceTaskProcessor {
public void processDecomposition_Target(DelegateExecution execution) {
def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
-
- utils.log("DEBUG", " ***** Inside processDecomposition_Target() of update generic e2e service flow ***** ", isDebugEnabled)
+
+ utils.log("DEBUG", " ***** Inside processDecomposition_Target() of update generic e2e service flow ***** ", isDebugEnabled)
try {
ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
execution.setVariable("serviceDecomposition_Target", serviceDecomposition)
@@ -177,7 +174,7 @@ public class DoCompareModelVersions extends AbstractServiceTaskProcessor {
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
}
}
-
+
public void prepareDecomposeService_Original(DelegateExecution execution) {
def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
@@ -191,7 +188,7 @@ public class DoCompareModelVersions extends AbstractServiceTaskProcessor {
"modelUuid":"${modelUuid}",
"modelVersion":""
}"""
-
+
execution.setVariable("serviceModelInfo_Original", serviceModelInfo)
utils.log("DEBUG", " ***** Completed prepareDecomposeService_Original of update generic e2e service ***** ", isDebugEnabled)
@@ -204,8 +201,8 @@ public class DoCompareModelVersions extends AbstractServiceTaskProcessor {
public void processDecomposition_Original(DelegateExecution execution) {
def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
-
- utils.log("DEBUG", " ***** Inside processDecomposition_Original() of update generic e2e service flow ***** ", isDebugEnabled)
+
+ utils.log("DEBUG", " ***** Inside processDecomposition_Original() of update generic e2e service flow ***** ", isDebugEnabled)
try {
ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
execution.setVariable("serviceDecomposition_Original", serviceDecomposition)
@@ -214,45 +211,45 @@ public class DoCompareModelVersions extends AbstractServiceTaskProcessor {
utils.log("DEBUG", exceptionMessage, isDebugEnabled)
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
}
- }
+ }
public void doCompareModelVersions(DelegateExecution execution){
def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- utils.log("INFO", "======== Start doCompareModelVersions Process ======== ", isDebugEnabled)
+ utils.log("INFO", "======== Start doCompareModelVersions Process ======== ", isDebugEnabled)
ServiceDecomposition serviceDecomposition_Target = execution.getVariable("serviceDecomposition_Target")
ServiceDecomposition serviceDecomposition_Original = execution.getVariable("serviceDecomposition_Original")
-
+
List<Resource> allSR_target = serviceDecomposition_Target.getServiceResources();
List<Resource> allSR_original = serviceDecomposition_Original.getServiceResources();
-
+
List<Resource> addResourceList = new ArrayList<String>()
List<Resource> delResourceList = new ArrayList<String>()
-
+
addResourceList.addAll(allSR_target)
delResourceList.addAll(allSR_original)
-
+
//Compare
for (Resource rc_t : allSR_target){
String muuid = rc_t.getModelInfo().getModelUuid()
String mIuuid = rc_t.getModelInfo().getModelInvariantUuid()
String mCuuid = rc_t.getModelInfo().getModelCustomizationUuid()
for (Resource rc_o : allSR_original){
- if(rc_o.getModelInfo().getModelUuid() == muuid
- && rc_o.getModelInfo().getModelInvariantUuid() == mIuuid
+ if(rc_o.getModelInfo().getModelUuid() == muuid
+ && rc_o.getModelInfo().getModelInvariantUuid() == mIuuid
&& rc_o.getModelInfo().getModelCustomizationUuid() == mCuuid) {
addResourceList.remove(rc_t);
delResourceList.remove(rc_o);
}
- }
+ }
}
execution.setVariable("addResourceList", addResourceList)
execution.setVariable("delResourceList", delResourceList)
- utils.log("INFO", "addResourceList: " + addResourceList, isDebugEnabled)
+ utils.log("INFO", "addResourceList: " + addResourceList, isDebugEnabled)
utils.log("INFO", "delResourceList: " + delResourceList, isDebugEnabled)
-
- utils.log("INFO", "======== COMPLETED doCompareModelVersions Process ======== ", isDebugEnabled)
+
+ utils.log("INFO", "======== COMPLETED doCompareModelVersions Process ======== ", isDebugEnabled)
}
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy
index d43a19624e..5b7d38dfb6 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy
@@ -46,7 +46,7 @@ import org.onap.so.bpmn.infrastructure.workflow.service.ServicePluginFactory
import org.onap.so.client.aai.entities.uri.AAIUriFactory
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
-import org.onap.so.rest.APIResponse
+
import org.springframework.web.util.UriUtils
import org.onap.so.bpmn.core.UrnPropertiesReader
@@ -461,10 +461,10 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor {
uuiRequest = ServicePluginFactory.getInstance().doProcessSiteLocation(serviceDecomposition, uuiRequest);
execution.setVariable("uuiRequest", uuiRequest)
execution.setVariable("serviceDecomposition", serviceDecomposition)
-
+
msoLogger.trace("======== COMPLETED doProcessSiteLocation Process ======== ")
}
-
+
// Allocate cross link TPs(terminal points) for sotn network only
public void doTPResourcesAllocation(DelegateExecution execution){
msoLogger.trace("======== Start doTPResourcesAllocation Process ======== ")
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstanceRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstanceRollback.groovy
index 82355beed2..4f00a64ecb 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstanceRollback.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstanceRollback.groovy
@@ -32,9 +32,6 @@ import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils
import org.onap.so.bpmn.core.RollbackData
import org.onap.so.bpmn.core.WorkflowException
-import org.onap.so.rest.APIResponse;
-import org.onap.so.rest.RESTClient
-import org.onap.so.rest.RESTConfig
import org.onap.so.logger.MsoLogger
import org.onap.so.logger.MessageEnum
import org.onap.so.bpmn.common.scripts.ExceptionUtil;
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy
index 51574f63f8..c9497165c4 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy
@@ -21,7 +21,8 @@
package org.onap.so.bpmn.infrastructure.scripts;
import javax.ws.rs.core.UriBuilder
-
+import javax.xml.parsers.DocumentBuilder
+import javax.xml.parsers.DocumentBuilderFactory
import org.apache.commons.lang3.*
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
@@ -41,14 +42,24 @@ import org.onap.so.client.aai.AAIResourcesClient
import org.onap.so.client.aai.entities.uri.AAIResourceUri
import org.onap.so.client.aai.entities.uri.AAIUriFactory
import org.onap.so.client.aai.entities.AAIResultWrapper
+import org.onap.so.client.aai.entities.Relationships
import org.onap.so.client.graphinventory.entities.uri.Depth
import org.onap.so.constants.Defaults
import org.onap.so.logger.MsoLogger
-import org.onap.so.rest.APIResponse;
import org.springframework.web.util.UriUtils
+import org.w3c.dom.Document
+import org.w3c.dom.Element
+import org.w3c.dom.NamedNodeMap
+import org.w3c.dom.Node
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource
import org.onap.aai.domain.yang.VpnBinding
+import org.onap.aai.domain.yang.L3Network
+import org.onap.aai.domain.yang.L3Networks
+import org.onap.aai.domain.yang.NetworkPolicy
+import org.onap.aai.domain.yang.RouteTableReference
import org.onap.aai.domain.yang.RouteTarget
-
+import org.onap.aai.domain.yang.Subnet
import com.fasterxml.jackson.jaxrs.util.EndpointAsBeanProperty
import javax.ws.rs.NotFoundException
@@ -359,66 +370,26 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor {
msoLogger.debug(" ***** Inside callRESTQueryAAINetworkName() of DoCreateNetworkInstance ***** " )
- // get variables
- String networkInputs = execution.getVariable(Prefix + "networkInputs")
- String networkName = utils.getNodeText(networkInputs, "network-name")
- networkName = UriUtils.encode(networkName,"UTF-8")
-
- // Prepare AA&I url with network-name
- String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution)
- AaiUtil aaiUriUtil = new AaiUtil(this)
-
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.L3_NETWORK)
- uri.queryParam("network-name", networkName)
- String queryAAINameRequest = aaiUriUtil.createAaiUri(uri)
-
- execution.setVariable(Prefix + "queryNameAAIRequest", queryAAINameRequest)
- msoLogger.debug(Prefix + "queryNameAAIRequest - " + "\n" + queryAAINameRequest)
-
- try {
- APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryAAINameRequest)
- String returnCode = response.getStatusCode()
- execution.setVariable(Prefix + "aaiNameReturnCode", returnCode)
- msoLogger.debug(" ***** AAI Query Name Response Code : " + returnCode)
-
- String aaiResponseAsString = response.getResponseBodyAsString()
- msoLogger.debug(" ***** AAI Query Name Response : " +'\n'+ aaiResponseAsString)
-
- if (returnCode=='200') {
- execution.setVariable(Prefix + "queryNameAAIResponse", aaiResponseAsString)
- execution.setVariable(Prefix + "isAAIqueryNameGood", true)
- String orchestrationStatus = ""
- try {
- // response is NOT empty
- orchestrationStatus = utils.getNodeText(aaiResponseAsString, "orchestration-status")
- execution.setVariable(Prefix + "orchestrationStatus", orchestrationStatus.toUpperCase())
- msoLogger.debug(Prefix + "orchestrationStatus - " + orchestrationStatus.toUpperCase())
- execution.setVariable("orchestrationStatus", orchestrationStatus)
-
- } catch (Exception ex) {
- // response is empty
- execution.setVariable(Prefix + "orchestrationStatus", orchestrationStatus)
- msoLogger.debug(Prefix + "orchestrationStatus - " + orchestrationStatus)
- }
-
- } else {
- if (returnCode=='404') {
- msoLogger.debug(" QueryAAINetworkName return code = '404' (Not Found). Proceed with the Create !!! ")
-
- } else {
- // aai all errors
- String dataErrorMessage = "Unexpected Error Response from QueryAAINetworkName - " + returnCode
- msoLogger.debug(dataErrorMessage)
- exceptionUtil.buildWorkflowException(execution, 2500, dataErrorMessage)
+ try{
+ // get variables
+ String networkInputs = execution.getVariable(Prefix + "networkInputs")
+ String networkName = utils.getNodeText(networkInputs, "network-name")
- }
+ AAIResourcesClient client = new AAIResourcesClient()
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.L3_NETWORK).queryParam("network-name", networkName)
+ L3Networks networks = client.get(uri, NotFoundException.class).asBean(L3Networks.class).get()
+ L3Network network = networks.getL3Network().get(0)
- }
+ execution.setVariable(Prefix + "isAAIqueryNameGood", true)
+ String orchestrationStatus = network.getOrchestrationStatus()
+ execution.setVariable(Prefix + "orchestrationStatus", orchestrationStatus.toUpperCase())
+ msoLogger.debug(Prefix + "orchestrationStatus - " + orchestrationStatus.toUpperCase())
+ execution.setVariable("orchestrationStatus", orchestrationStatus)
msoLogger.debug(Prefix + "isAAIqueryNameGood? : " + execution.getVariable(Prefix + "isAAIqueryNameGood"))
- } catch (BpmnError e) {
- throw e;
+ } catch (NotFoundException e) {
+ msoLogger.debug(" QueryAAINetworkName return code = '404' (Not Found). Proceed with the Create !!! ")
} catch (Exception ex) {
// try error
@@ -515,57 +486,21 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor {
String networkName = utils.getNodeText(assignSDNCResponse, "network-name")
execution.setVariable(Prefix + "networkName", networkName)
- networkId = UriUtils.encode(networkId,"UTF-8")
-
- AaiUtil aaiUriUtil = new AaiUtil(this)
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId)
- uri.depth(Depth.ALL)
- String queryIdAAIRequest = aaiUriUtil.createAaiUri(uri)
-
- execution.setVariable(Prefix + "queryIdAAIRequest", queryIdAAIRequest)
- msoLogger.debug(Prefix + "queryIdAAIRequest - " + "\n" + queryIdAAIRequest)
-
- APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryIdAAIRequest)
- String returnCode = response.getStatusCode()
- execution.setVariable(Prefix + "aaiIdReturnCode", returnCode)
-
- msoLogger.debug(" ***** AAI Response Code : " + returnCode)
+ AAIResourcesClient client = new AAIResourcesClient()
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId).depth(Depth.ONE)
+ L3Network network = client.get(uri, NotFoundException.class).asBean(L3Network.class).get()
- String aaiResponseAsString = response.getResponseBodyAsString()
+ execution.setVariable(Prefix + "queryIdAAIResponse", network)
- if (returnCode=='200') {
- execution.setVariable(Prefix + "queryIdAAIResponse", aaiResponseAsString)
- msoLogger.debug(" QueryAAINetworkId Success REST Response - " + "\n" + aaiResponseAsString)
-
- String netId = utils.getNodeText(aaiResponseAsString, "network-id")
- execution.setVariable(Prefix + "networkId", netId)
- String netName = utils.getNodeText(aaiResponseAsString, "network-name")
- execution.setVariable(Prefix + "networkName", netName)
-
- } else {
- if (returnCode=='404') {
- String dataErrorMessage = "Response Error from QueryAAINetworkId is 404 (Not Found)."
- msoLogger.debug(" AAI Query Failed. " + dataErrorMessage)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
-
- } else {
- if (aaiResponseAsString.contains("RESTFault")) {
- WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
- execution.setVariable("WorkflowException", exceptionObject)
- throw new BpmnError("MSOWorkflowException")
-
- } else {
- // aai all errors
- String dataErrorMessage = "Unexpected Response from QueryAAINetworkId - " + returnCode
- msoLogger.debug("Unexpected Response from QueryAAINetworkId - " + dataErrorMessage)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
-
- }
- }
- }
+ String netId = network.getNetworkId()
+ execution.setVariable(Prefix + "networkId", netId)
+ String netName = network.getNetworkName()
+ execution.setVariable(Prefix + "networkName", netName)
- } catch (BpmnError e) {
- throw e;
+ } catch (NotFoundException e) {
+ String dataErrorMessage = "Response Error from QueryAAINetworkId is 404 (Not Found)."
+ msoLogger.debug(" AAI Query Failed. " + dataErrorMessage)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
} catch (Exception ex) {
String exceptionMessage = "Bpmn error encountered in DoCreateNetworkInstance flow. callRESTQueryAAINetworkId() - " + ex.getMessage()
@@ -586,61 +521,27 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor {
// get variables
String networkId = execution.getVariable(Prefix + "networkId")
String netId = networkId
- networkId = UriUtils.encode(networkId,"UTF-8")
-
- // Prepare AA&I url
- AaiUtil aaiUriUtil = new AaiUtil(this)
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId)
- uri.depth(Depth.ALL)
- String requeryIdAAIRequest = aaiUriUtil.createAaiUri(uri)
-
- execution.setVariable(Prefix + "requeryIdAAIRequest", requeryIdAAIRequest)
- msoLogger.debug(Prefix + "requeryIdAAIRequest - " + "\n" + requeryIdAAIRequest)
-
- APIResponse response = aaiUriUtil.executeAAIGetCall(execution, requeryIdAAIRequest)
- String returnCode = response.getStatusCode()
- execution.setVariable(Prefix + "aaiRequeryIdReturnCode", returnCode)
- msoLogger.debug(" ***** AAI ReQuery Response Code : " + returnCode)
- String aaiResponseAsString = response.getResponseBodyAsString()
+ AAIResourcesClient client = new AAIResourcesClient()
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId).depth(Depth.ONE)
+ L3Network network = client.get(uri, NotFoundException.class).asBean(L3Network.class).get()
- if (returnCode=='200') {
- execution.setVariable(Prefix + "requeryIdAAIResponse", aaiResponseAsString)
- msoLogger.debug(" ReQueryAAINetworkId Success REST Response - " + "\n" + aaiResponseAsString)
+ execution.setVariable(Prefix + "aaiRequeryIdReturnCode", "200")
- String netName = utils.getNodeText(aaiResponseAsString, "network-name")
- String networkOutputs =
- """<network-outputs>
+ String netName = network.getNetworkName()
+ String networkOutputs =
+ """<network-outputs>
<network-id>${MsoUtils.xmlEscape(netId)}</network-id>
<network-name>${MsoUtils.xmlEscape(netName)}</network-name>
</network-outputs>"""
- execution.setVariable(Prefix + "networkOutputs", networkOutputs)
- msoLogger.debug(" networkOutputs - " + '\n' + networkOutputs)
-
- } else {
- if (returnCode=='404') {
- String dataErrorMessage = "Response Error from ReQueryAAINetworkId is 404 (Not Found)."
- msoLogger.debug(" AAI ReQuery Failed. - " + dataErrorMessage)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
-
- } else {
- if (aaiResponseAsString.contains("RESTFault")) {
- WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
- execution.setVariable("WorkflowException", exceptionObject)
- throw new BpmnError("MSOWorkflowException")
-
- } else {
- // aai all errors
- String dataErrorMessage = "Unexpected Response from ReQueryAAINetworkId - " + returnCode
- msoLogger.debug(dataErrorMessage)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
+ execution.setVariable(Prefix + "networkOutputs", networkOutputs)
+ msoLogger.debug(" networkOutputs - " + '\n' + networkOutputs)
- }
- }
- }
- } catch (BpmnError e) {
- throw e;
+ } catch (NotFoundException e) {
+ String dataErrorMessage = "Response Error from ReQueryAAINetworkId is 404 (Not Found)."
+ msoLogger.debug(" AAI ReQuery Failed. - " + dataErrorMessage)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
} catch (Exception ex) {
String exceptionMessage = "Bpmn error encountered in DoCreateNetworkInstance flow. callRESTReQueryAAINetworkId() - " + ex.getMessage()
@@ -659,72 +560,57 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor {
try {
- // get variables
- String queryIdAAIResponse = execution.getVariable(Prefix + "queryIdAAIResponse").replace('<?xml version="1.0" encoding="UTF-8"?>', "")
- String relationship = networkUtils.getFirstNodeXml(queryIdAAIResponse, "relationship-list").trim().replace("tag0:","").replace(":tag0","")
- msoLogger.debug(" relationship - " + relationship)
-
- // Check if Vnf Binding is present, then build a List of vnfBinding
- List vpnBindingUri = networkUtils.getVnfBindingObject(relationship)
- int vpnCount = vpnBindingUri.size()
- execution.setVariable(Prefix + "vpnCount", vpnCount)
- msoLogger.debug(Prefix + "vpnCount - " + vpnCount)
-
- if (vpnCount > 0) {
- execution.setVariable(Prefix + "vpnBindings", vpnBindingUri)
- msoLogger.debug(" vpnBindingUri List - " + vpnBindingUri)
-
- String routeTargets = ""
- // AII loop call using list vpnBindings
- for(i in 0..vpnBindingUri.size()-1) {
- int counting = i+1
-
- String vpnBindingId = vpnBindingUri[i].substring(vpnBindingUri[i].indexOf("/vpn-binding/")+13, vpnBindingUri[i].length())
- if (vpnBindingId.charAt(vpnBindingId.length()-1) == '/') {
- vpnBindingId = vpnBindingId.substring(0, vpnBindingId.length()-1)
- }
-
- AAIResourcesClient resourceClient = new AAIResourcesClient()
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VPN_BINDING, vpnBindingId)
- AAIResultWrapper wrapper = resourceClient.get(uri.depth(Depth.TWO), NotFoundException.class)
-
- Optional<VpnBinding> binding = wrapper.asBean(VpnBinding.class)
-
- String routeTarget = ""
- String routeRole = ""
- if(binding.get().getRouteTargets() != null) {
- List<RouteTarget> targets = binding.get().getRouteTargets().getRouteTarget()
- for(RouteTarget target : targets) {
- routeTarget = target.getGlobalRouteTarget()
- routeRole = target.getRouteTargetRole()
- routeTargets += "<routeTargets>" + '\n' +
- " <routeTarget>" + routeTarget + "</routeTarget>" + '\n' +
- " <routeTargetRole>" + routeRole + "</routeTargetRole>" + '\n' +
- "</routeTargets>" + '\n'
+ AAIResourcesClient client = new AAIResourcesClient()
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, execution.getVariable(Prefix + "networkId"))
+ Optional<Relationships> relationships = client.get(uri, NotFoundException.class).getRelationships()
+ if(relationships.isPresent()){
+ List<AAIResourceUri> uris = relationships.get().getRelatedAAIUris(AAIObjectType.VPN_BINDING)
+
+ msoLogger.debug(Prefix + "vpnCount - " + uris.size())
+
+ if (uris.size() > 0) {
+ String routeTargets = ""
+ for(AAIResourceUri u : uris) {
+
+ AAIResultWrapper wrapper = client.get(u.depth(Depth.TWO), NotFoundException.class)
+ Optional<VpnBinding> binding = wrapper.asBean(VpnBinding.class)
+
+ String routeTarget = ""
+ String routeRole = ""
+ if(binding.get().getRouteTargets() != null) {
+ List<RouteTarget> targets = binding.get().getRouteTargets().getRouteTarget()
+ for(RouteTarget target : targets) {
+ routeTarget = target.getGlobalRouteTarget()
+ routeRole = target.getRouteTargetRole()
+ routeTargets += "<routeTargets>" + '\n' +
+ " <routeTarget>" + routeTarget + "</routeTarget>" + '\n' +
+ " <routeTargetRole>" + routeRole + "</routeTargetRole>" + '\n' +
+ "</routeTargets>" + '\n'
+ }
}
- }
- } // end loop
+ } // end loop
- execution.setVariable(Prefix + "routeCollection", routeTargets)
- msoLogger.debug(Prefix + "routeCollection - " + '\n' + routeTargets)
+ execution.setVariable(Prefix + "routeCollection", routeTargets)
+ msoLogger.debug(Prefix + "routeCollection - " + '\n' + routeTargets)
- } else {
- // reset return code to success
- execution.setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", "200")
- AaiUtil aaiUriUtil = new AaiUtil(this)
- String schemaVersion = aaiUriUtil.getNamespace()
- String aaiStubResponse =
- """ <rest:payload contentType="text/xml" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd">
+ } else {
+ // reset return code to success
+ execution.setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", "200")
+ AaiUtil aaiUriUtil = new AaiUtil(this)
+ String schemaVersion = aaiUriUtil.getNamespace()
+ String aaiStubResponse =
+ """ <rest:payload contentType="text/xml" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd">
<vpn-binding xmlns="${schemaVersion}">
<global-route-target/>
</vpn-binding>
</rest:payload>"""
- String aaiStubResponseAsXml = utils.formatXml(aaiStubResponse)
- execution.setVariable(Prefix + "queryVpnBindingAAIResponse", aaiStubResponseAsXml)
- execution.setVariable(Prefix + "routeCollection", "<routeTargets/>")
- msoLogger.debug(" No vpnBinding, using this stub as response - " + '\n' + aaiStubResponseAsXml)
+ String aaiStubResponseAsXml = utils.formatXml(aaiStubResponse)
+ execution.setVariable(Prefix + "queryVpnBindingAAIResponse", aaiStubResponseAsXml)
+ execution.setVariable(Prefix + "routeCollection", "<routeTargets/>")
+ msoLogger.debug(" No vpnBinding, using this stub as response - " + '\n' + aaiStubResponseAsXml)
+ }
}
} catch (NotFoundException e) {
@@ -746,111 +632,62 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor {
msoLogger.debug(" ***** Inside callRESTQueryAAINetworkPolicy() of DoCreateNetworkInstance ***** " )
try {
- // get variables
- String queryIdAAIResponse = execution.getVariable(Prefix + "queryIdAAIResponse").replace('<?xml version="1.0" encoding="UTF-8"?>', "")
- String relationship = networkUtils.getFirstNodeXml(queryIdAAIResponse, "relationship-list").trim().replace("tag0:","").replace(":tag0","")
- msoLogger.debug(" relationship - " + relationship)
-
- // Check if Network Policy is present, then build a List of network policy
- List networkPolicyUriList = networkUtils.getNetworkPolicyObject(relationship)
- int networkPolicyCount = networkPolicyUriList.size()
- execution.setVariable(Prefix + "networkPolicyCount", networkPolicyCount)
- msoLogger.debug(Prefix + "networkPolicyCount - " + networkPolicyCount)
+ AAIResourcesClient client = new AAIResourcesClient()
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, execution.getVariable(Prefix + "networkId"))
+ Optional<Relationships> relationships = client.get(uri, NotFoundException.class).getRelationships()
+ if(relationships.isPresent()){
+ List<AAIResourceUri> uris = relationships.get().getRelatedAAIUris(AAIObjectType.NETWORK_POLICY)
- AaiUtil aaiUriUtil = new AaiUtil(this)
+ execution.setVariable(Prefix + "networkPolicyCount", uris.size())
+ msoLogger.debug(Prefix + "networkPolicyCount - " + uris.size())
- if (networkPolicyCount > 0) {
- execution.setVariable(Prefix + "networkPolicyUriList", networkPolicyUriList)
- msoLogger.debug(" networkPolicyUri List - " + networkPolicyUriList)
+ if (uris.size() > 0) {
- String networkPolicies = ""
- // AII loop call using list vpnBindings
- for (i in 0..networkPolicyUriList.size()-1) {
+ String networkPolicies = ""
+ // AII loop call using list vpnBindings
+ for(AAIResourceUri u : uris) {
- int counting = i+1
+ NetworkPolicy p = client.get(u, NotFoundException.class).asBean(NetworkPolicy.class).get()
- // Note: By default, the network policy url is found in 'related-link' of the response,
- // so, the default in URN mappings for this is set to "" (ie, space), unless forced to use the URN mapping.
+ execution.setVariable(Prefix + "aaiQqueryNetworkPolicyReturnCode", "200")
- URI uri = UriBuilder.fromUri(networkPolicyUriList[i]).build()
+ String networkPolicy = p.getNetworkPolicyFqdn()
+ networkPolicies += "<policyFqdns>" + networkPolicy + "</policyFqdns>" + '\n'
- AAIResourceUri aaiUri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.NETWORK_POLICY, uri)
- aaiUri.depth(Depth.ALL)
- String queryNetworkPolicyAAIRequest = aaiUriUtil.createAaiUri(aaiUri)
+ } // end loop
- execution.setVariable(Prefix + "queryNetworkPolicyAAIRequest", queryNetworkPolicyAAIRequest)
- msoLogger.debug(Prefix + "queryNetworkPolicyAAIRequest, , NetworkPolicy #" + counting + " : " + "\n" + queryNetworkPolicyAAIRequest)
+ execution.setVariable(Prefix + "networkCollection", networkPolicies)
+ msoLogger.debug(Prefix + "networkCollection - " + '\n' + networkPolicies)
- APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryNetworkPolicyAAIRequest)
- String returnCode = response.getStatusCode()
- execution.setVariable(Prefix + "aaiQqueryNetworkPolicyReturnCode", returnCode)
- msoLogger.debug(" ***** AAI query network policy Response Code, NetworkPolicy #" + counting + " : " + returnCode)
-
- String aaiResponseAsString = response.getResponseBodyAsString()
-
- if (returnCode=='200') {
- execution.setVariable(Prefix + "queryNetworkPolicyAAIResponse", aaiResponseAsString)
- msoLogger.debug(" QueryAAINetworkPolicy Success REST Response, , NetworkPolicy #" + counting + " : " + "\n" + aaiResponseAsString)
-
- String networkPolicy = ""
- if (utils.nodeExists(aaiResponseAsString, "network-policy-fqdn")) {
- networkPolicy = utils.getNodeText(aaiResponseAsString, "network-policy-fqdn")
- networkPolicies += "<policyFqdns>" + networkPolicy + "</policyFqdns>" + '\n'
- }
-
- } else {
- if (returnCode=='404') {
- String dataErrorMessage = "Response Error from QueryAAINetworkPolicy is 404 (Not Found)."
- msoLogger.debug(dataErrorMessage)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
-
- } else {
- if (aaiResponseAsString.contains("RESTFault")) {
- WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
- execution.setVariable("WorkflowException", exceptionObject)
- throw new BpmnError("MSOWorkflowException")
-
- } else {
- // aai all errors
- String dataErrorMessage = "Unexpected Response from QueryAAINetworkPolicy - " + returnCode
- msoLogger.debug(dataErrorMessage)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
-
- }
- }
- }
-
- } // end loop
-
- execution.setVariable(Prefix + "networkCollection", networkPolicies)
- msoLogger.debug(Prefix + "networkCollection - " + '\n' + networkPolicies)
-
- } else {
- // reset return code to success
- execution.setVariable(Prefix + "aaiQqueryNetworkPolicyReturnCode", "200")
- String schemaVersion = aaiUriUtil.getNamespace()
- String aaiStubResponse =
- """ <rest:payload contentType="text/xml" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd">
+ } else {
+ // reset return code to success
+ execution.setVariable(Prefix + "aaiQqueryNetworkPolicyReturnCode", "200")
+ AaiUtil aaiUriUtil = new AaiUtil(this)
+ String schemaVersion = aaiUriUtil.getNamespace()
+ String aaiStubResponse =
+ """ <rest:payload contentType="text/xml" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd">
<network-policy xmlns="${schemaVersion}">
<network-policy-fqdn/>
</network-policy>
</rest:payload>"""
- String aaiStubResponseAsXml = utils.formatXml(aaiStubResponse)
- execution.setVariable(Prefix + "queryNetworkPolicyAAIResponse", aaiStubResponseAsXml)
- execution.setVariable(Prefix + "networkCollection", "<policyFqdns/>")
- msoLogger.debug(" No net policies, using this stub as response - " + '\n' + aaiStubResponseAsXml)
+ String aaiStubResponseAsXml = utils.formatXml(aaiStubResponse)
+ execution.setVariable(Prefix + "queryNetworkPolicyAAIResponse", aaiStubResponseAsXml)
+ execution.setVariable(Prefix + "networkCollection", "<policyFqdns/>")
+ msoLogger.debug(" No net policies, using this stub as response - " + '\n' + aaiStubResponseAsXml)
+ }
}
+ } catch (NotFoundException e) {
+ String dataErrorMessage = "Response Error from QueryAAINetworkPolicy is 404 (Not Found)."
+ msoLogger.debug(dataErrorMessage)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
- } catch (BpmnError e) {
- throw e;
-
- } catch (Exception ex) {
- String exceptionMessage = "Bpmn error encountered in DoCreateNetworkInstance flow. callRESTQueryAAINetworkPolicy() - " + ex.getMessage()
- msoLogger.debug(exceptionMessage)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
+ } catch (Exception ex) {
+ String exceptionMessage = "Bpmn error encountered in DoCreateNetworkInstance flow. callRESTQueryAAINetworkPolicy() - " + ex.getMessage()
+ msoLogger.debug(exceptionMessage)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
- }
+ }
}
@@ -861,103 +698,57 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor {
msoLogger.debug(" ***** Inside callRESTQueryAAINetworkTableRef() of DoCreateNetworkInstance ***** " )
try {
- // get variables
- String queryIdAAIResponse = execution.getVariable(Prefix + "queryIdAAIResponse").replace('<?xml version="1.0" encoding="UTF-8"?>', "")
- String relationship = networkUtils.getFirstNodeXml(queryIdAAIResponse, "relationship-list").trim().replace("tag0:","").replace(":tag0","")
- msoLogger.debug(" relationship - " + relationship)
-
- // Check if Network TableREf is present, then build a List of network policy
- List networkTableRefUriList = networkUtils.getNetworkTableRefObject(relationship)
- int networkTableRefCount = networkTableRefUriList.size()
- execution.setVariable(Prefix + "networkTableRefCount", networkTableRefCount)
- msoLogger.debug(Prefix + "networkTableRefCount - " + networkTableRefCount)
- String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution)
- AaiUtil aaiUriUtil = new AaiUtil(this)
+ AAIResourcesClient client = new AAIResourcesClient()
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, execution.getVariable(Prefix + "networkId"))
+ Optional<Relationships> relationships = client.get(uri, NotFoundException.class).getRelationships()
+ if(relationships.isPresent()){
+ List<AAIResourceUri> uris = relationships.get().getRelatedAAIUris(AAIObjectType.ROUTE_TABLE_REFERENCE)
- if (networkTableRefCount > 0) {
- execution.setVariable(Prefix + "networkTableRefUriList", networkTableRefUriList)
- msoLogger.debug(" networkTableRefUri List - " + networkTableRefUriList)
+ execution.setVariable(Prefix + "networkTableRefCount", uris.size())
+ msoLogger.debug(Prefix + "networkTableRefCount - " + uris.size())
- // AII loop call using list vpnBindings
- String networkTableRefs = ""
- for (i in 0..networkTableRefUriList.size()-1) {
- int counting = i+1
+ if (uris.size() > 0) {
- // prepare url using tableRef
- URI uri = UriBuilder.fromUri(networkTableRefUriList[i]).build()
+ // AII loop call using list vpnBindings
+ String networkTableRefs = ""
+ for(AAIResourceUri u : uris) {
- AAIResourceUri aaiUri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.ROUTE_TABLE_REFERENCE, uri)
- aaiUri.depth(Depth.ALL)
- String queryNetworkTableRefAAIRequest = aaiUriUtil.createAaiUri(aaiUri)
+ RouteTableReference rt = client.get(u, NotFoundException.class).asBean(RouteTableReference.class).get()
- execution.setVariable(Prefix + "queryNetworkTableRefAAIRequest", queryNetworkTableRefAAIRequest)
- msoLogger.debug(Prefix + "queryNetworkTableRefAAIRequest, , NetworkTableRef #" + counting + " : " + "\n" + queryNetworkTableRefAAIRequest)
+ String networkTableRef = rt.getRouteTableReferenceFqdn()
+ networkTableRefs += "<routeTableFqdns>" + networkTableRef + "</routeTableFqdns>" + '\n'
- APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryNetworkTableRefAAIRequest)
- String returnCode = response.getStatusCode()
- execution.setVariable(Prefix + "aaiQqueryNetworkTableRefReturnCode", returnCode)
- msoLogger.debug(" ***** AAI query network Table Reference Response Code, NetworkTableRef #" + counting + " : " + returnCode)
-
- String aaiResponseAsString = response.getResponseBodyAsString()
-
- if (returnCode=='200') {
- execution.setVariable(Prefix + "queryNetworkTableRefAAIResponse", aaiResponseAsString)
- msoLogger.debug(" QueryAAINetworkTableRef Success REST Response, , NetworkTableRef #" + counting + " : " + "\n" + aaiResponseAsString)
-
- String networkTableRef = ""
- if (utils.nodeExists(aaiResponseAsString, "route-table-reference-fqdn")) {
- networkTableRef = utils.getNodeText(aaiResponseAsString, "route-table-reference-fqdn")
- networkTableRefs += "<routeTableFqdns>" + networkTableRef + "</routeTableFqdns>" + '\n'
- }
-
- } else {
- if (returnCode=='404') {
- String dataErrorMessage = "Response Error from QueryAAINetworkTableRef is 404 (Not Found)."
- msoLogger.debug(dataErrorMessage)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
-
- } else {
- if (aaiResponseAsString.contains("RESTFault")) {
- WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
- execution.setVariable("WorkflowException", exceptionObject)
- throw new BpmnError("MSOWorkflowException")
-
- } else {
- // aai all errors
- String dataErrorMessage = "Unexpected Response from QueryAAINetworkTableRef - " + returnCode
- msoLogger.debug(dataErrorMessage)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
-
- }
- }
- }
- } // end loop
+ } // end loop
- execution.setVariable(Prefix + "tableRefCollection", networkTableRefs)
- msoLogger.debug(Prefix + "tableRefCollection - " + '\n' + networkTableRefs)
+ execution.setVariable(Prefix + "tableRefCollection", networkTableRefs)
+ msoLogger.debug(Prefix + "tableRefCollection - " + '\n' + networkTableRefs)
- } else {
- // reset return code to success
- execution.setVariable(Prefix + "aaiQqueryNetworkTableRefReturnCode", "200")
- String schemaVersion = aaiUriUtil.getNamespace()
- String aaiStubResponse =
- """ <rest:payload contentType="text/xml" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd">
+ } else {
+ // reset return code to success
+ execution.setVariable(Prefix + "aaiQqueryNetworkTableRefReturnCode", "200")
+ AaiUtil aaiUriUtil = new AaiUtil(this)
+ String schemaVersion = aaiUriUtil.getNamespace()
+ String aaiStubResponse =
+ """ <rest:payload contentType="text/xml" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd">
<route-table-references xmlns="${schemaVersion}">
<route-table-reference-fqdn/>
</route-table-references>
</rest:payload>"""
- String aaiStubResponseAsXml = utils.formatXml(aaiStubResponse)
- execution.setVariable(Prefix + "queryNetworkTableRefAAIResponse", aaiStubResponseAsXml)
- execution.setVariable(Prefix + "tableRefCollection", "<routeTableFqdns/>")
- msoLogger.debug(" No net table references, using this stub as response - " + '\n' + aaiStubResponseAsXml)
+ String aaiStubResponseAsXml = utils.formatXml(aaiStubResponse)
+ execution.setVariable(Prefix + "queryNetworkTableRefAAIResponse", aaiStubResponseAsXml)
+ execution.setVariable(Prefix + "tableRefCollection", "<routeTableFqdns/>")
+ msoLogger.debug(" No net table references, using this stub as response - " + '\n' + aaiStubResponseAsXml)
+ }
}
- } catch (BpmnError e) {
- throw e;
+ } catch (NotFoundException e) {
+ String dataErrorMessage = "Response Error from QueryAAINetworkTableRef is 404 (Not Found)."
+ msoLogger.debug(dataErrorMessage)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
} catch (Exception ex) {
String exceptionMessage = "Bpmn error encountered in DoCreateNetworkInstance flow. callRESTQueryAAINetworkTableRef() - " + ex.getMessage()
@@ -978,75 +769,86 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor {
try {
// get variables
String networkId = execution.getVariable(Prefix + "networkId")
- networkId = UriUtils.encode(networkId,"UTF-8")
String requeryIdAAIResponse = execution.getVariable(Prefix + "requeryIdAAIResponse")
String createNetworkResponse = execution.getVariable(Prefix + "createNetworkResponse")
- // Prepare url
- AaiUtil aaiUriUtil = new AaiUtil(this)
-
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId)
- uri.depth(Depth.ALL)
- String updateContrailAAIUrlRequest = aaiUriUtil.createAaiUri(uri)
-
- execution.setVariable(Prefix + "updateContrailAAIUrlRequest", updateContrailAAIUrlRequest)
- msoLogger.debug(Prefix + "updateContrailAAIUrlRequest - " + "\n" + updateContrailAAIUrlRequest)
-
- //Prepare payload (PUT)
- String schemaVersion = aaiUriUtil.getNamespaceFromUri(updateContrailAAIUrlRequest)
- String payload = networkUtils.ContrailNetworkCreatedUpdate(requeryIdAAIResponse, createNetworkResponse, schemaVersion)
- String payloadXml = utils.formatXml(payload)
- execution.setVariable(Prefix + "updateContrailAAIPayloadRequest", payloadXml)
- msoLogger.debug(" 'payload' to Update Contrail - " + "\n" + payloadXml)
-
- APIResponse response = aaiUriUtil.executeAAIPutCall(execution, updateContrailAAIUrlRequest, payloadXml)
-
- String returnCode = response.getStatusCode()
- execution.setVariable(Prefix + "aaiUpdateContrailReturnCode", returnCode)
- msoLogger.debug(" ***** AAI Update Contrail Response Code : " + returnCode)
- String aaiUpdateContrailResponseAsString = response.getResponseBodyAsString()
- if (returnCode=='200') {
- execution.setVariable(Prefix + "updateContrailAAIResponse", aaiUpdateContrailResponseAsString)
- msoLogger.debug(" AAI Update Contrail Success REST Response - " + "\n" + aaiUpdateContrailResponseAsString)
- // Point-of-no-return is set to false, rollback not needed.
- String rollbackEnabled = execution.getVariable(Prefix + "rollbackEnabled")
- if (rollbackEnabled == "true") {
- execution.setVariable(Prefix + "isPONR", false)
- } else {
- execution.setVariable(Prefix + "isPONR", true)
+ L3Network l3Network = new L3Network()
+ if (utils.nodeExists(requeryIdAAIResponse, 'heat-stack-id')) {
+ } else {
+ if (utils.nodeExists(createNetworkResponse, 'networkStackId')) {
+ l3Network.setHeatStackId(utils.getNodeText(createNetworkResponse, 'networkStackId'))
}
- msoLogger.debug(Prefix + "isPONR" + ": " + execution.getVariable(Prefix + "isPONR"))
+ }
+ if (utils.nodeExists(requeryIdAAIResponse, 'neutron-network-id')) {
} else {
- if (returnCode=='404') {
- String dataErrorMessage = " Response Error from UpdateContrailAAINetwork is 404 (Not Found)."
- msoLogger.debug(dataErrorMessage)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
+ if (utils.nodeExists(createNetworkResponse, 'neutronNetworkId')) {
+ l3Network.setNeutronNetworkId(utils.getNodeText(createNetworkResponse, 'neutronNetworkId'))
+ }
+ }
+ if (utils.nodeExists(requeryIdAAIResponse, 'contrail-network-fqdn')) {
+ } else {
+ if (utils.nodeExists(createNetworkResponse, 'networkFqdn')) {
+ l3Network.setContrailNetworkFqdn(utils.getNodeText(createNetworkResponse, 'networkFqdn'))
+ }
+ }
- } else {
- if (aaiUpdateContrailResponseAsString.contains("RESTFault")) {
- WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiUpdateContrailResponseAsString, execution)
- execution.setVariable("WorkflowException", exceptionObject)
- throw new BpmnError("MSOWorkflowException")
-
- } else {
- // aai all errors
- String errorMessage = "Unexpected Response from UpdateContrailAAINetwork - " + returnCode
- msoLogger.debug(errorMessage)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage)
- }
+ String status = utils.getNodeText(createNetworkResponse, 'orchestration-status')
+ if(status.equals("pending-create") || status.equals("PendingCreate")){
+ l3Network.setOperationalStatus("Created")
+ }else{
+ l3Network.setOperationalStatus("Active")
+ }
+
+ AAIResourcesClient client = new AAIResourcesClient()
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId)
+ client.update(uri, l3Network)
+
+ String subnetsXml = utils.getNodeXml(requeryIdAAIResponse, "subnets")
+ InputSource source = new InputSource(new StringReader(subnetsXml));
+ DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
+ docFactory.setNamespaceAware(true)
+ DocumentBuilder docBuilder = docFactory.newDocumentBuilder()
+ Document xml = docBuilder.parse(source)
+ NodeList nodeList = xml.getElementsByTagNameNS("*", "subnet")
+ for (int x = 0; x < nodeList.getLength(); x++) {
+ Node node = nodeList.item(x)
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ Element eElement = (Element) node
+ String subnetOrchStatus = eElement.getElementsByTagNameNS("*", "orchestration-status").item(0).getTextContent()
+ String subnetId = eElement.getElementsByTagNameNS("*", "subnet-id").item(0).getTextContent()
+ Subnet subnet = new Subnet()
+ String neutronSubnetId = networkUtils.extractNeutSubId(createNetworkResponse, subnetId)
+ subnet.setNeutronSubnetId(neutronSubnetId)
+ if(subnetOrchStatus.equals("pending-create") || subnetOrchStatus.equals("PendingCreate") ){
+ subnet.setOrchestrationStatus("Created")
+ }else{
+ subnet.setOrchestrationStatus("Active")
+ }
+
+ AAIResourceUri subUri = AAIUriFactory.createResourceUri(AAIObjectType.SUBNET, networkId, subnetId)
+ client.update(subUri, subnet)
}
}
+ String rollbackEnabled = execution.getVariable(Prefix + "rollbackEnabled")
+ if (rollbackEnabled == "true") {
+ execution.setVariable(Prefix + "isPONR", false)
+ } else {
+ execution.setVariable(Prefix + "isPONR", true)
+ }
+ msoLogger.debug(Prefix + "isPONR" + ": " + execution.getVariable(Prefix + "isPONR"))
+
} catch (BpmnError e) {
throw e;
-
+ } catch (NotFoundException e) {
+ String dataErrorMessage = " Response Error from UpdateContrailAAINetwork is 404 (Not Found)."
+ msoLogger.debug(dataErrorMessage)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
} catch (Exception ex) {
String exceptionMessage = "Bpmn error encountered in DoCreateNetworkInstance flow. callRESTUpdateContrailAAINetwork() - " + ex.getMessage()
msoLogger.debug(exceptionMessage)
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
-
}
-
}
public void prepareCreateNetworkRequest (DelegateExecution execution) {
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstanceRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstanceRollback.groovy
index 7e00f05b90..1d75d399ee 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstanceRollback.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstanceRollback.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.
@@ -25,6 +25,7 @@ import groovy.xml.XmlUtil
import groovy.json.*
import org.onap.so.bpmn.core.UrnPropertiesReader
import org.onap.so.bpmn.core.json.JsonUtils
+import org.onap.so.client.HttpClient
import org.onap.so.logger.MsoLogger
import org.onap.so.logger.MessageEnum
@@ -34,12 +35,10 @@ import org.onap.so.bpmn.common.scripts.NetworkUtils
import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils
import org.onap.so.bpmn.common.scripts.VidUtils
import org.onap.so.bpmn.core.WorkflowException
-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 java.util.UUID;
-
+import javax.ws.rs.core.Response
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
import org.apache.commons.lang3.*
@@ -61,7 +60,7 @@ public class DoCreateNetworkInstanceRollback extends AbstractServiceTaskProcesso
SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
def className = getClass().getSimpleName()
-
+
/**
* This method is executed during the preProcessRequest task of the <class>DoCreateNetworkInstanceRollback.bpmn</class> process.
* @param execution
@@ -73,7 +72,7 @@ public class DoCreateNetworkInstanceRollback extends AbstractServiceTaskProcesso
execution.setVariable(Prefix + "rollbackSDNCRequest", null)
execution.setVariable(Prefix + "rollbackActivateSDNCRequest", null)
execution.setVariable(Prefix + "WorkflowException", null)
-
+
execution.setVariable(Prefix + "rollbackNetworkRequest", "")
execution.setVariable(Prefix + "rollbackNetworkResponse", "")
execution.setVariable(Prefix + "rollbackNetworkReturnCode", "")
@@ -81,7 +80,7 @@ public class DoCreateNetworkInstanceRollback extends AbstractServiceTaskProcesso
execution.setVariable(Prefix + "rollbackSDNCRequest", "")
execution.setVariable(Prefix + "rollbackSDNCResponse", "")
execution.setVariable(Prefix + "rollbackSDNCReturnCode", "")
-
+
execution.setVariable(Prefix + "rollbackActivateSDNCRequest", "")
execution.setVariable(Prefix + "rollbackActivateSDNCResponse", "")
execution.setVariable(Prefix + "rollbackActivateSDNCReturnCode", "")
@@ -103,18 +102,18 @@ public class DoCreateNetworkInstanceRollback extends AbstractServiceTaskProcesso
public void preProcessRequest (DelegateExecution execution) {
def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
execution.setVariable("prefix",Prefix)
-
+
msoLogger.trace("Inside preProcessRequest() of " + className + ".groovy")
try {
// initialize flow variables
InitializeProcessVariables(execution)
-
+
// GET Incoming request/variables
String rollbackNetworkRequest = null
String rollbackSDNCRequest = null
String rollbackActivateSDNCRequest = null
-
+
// Partial Rollback
Map<String, String> rollbackData = execution.getVariable("rollbackData")
if (rollbackData != null && rollbackData instanceof Map) {
@@ -122,7 +121,7 @@ public class DoCreateNetworkInstanceRollback extends AbstractServiceTaskProcesso
if(rollbackData.containsKey("rollbackSDNCRequest")) {
rollbackSDNCRequest = rollbackData["rollbackSDNCRequest"]
}
-
+
if(rollbackData.containsKey("rollbackNetworkRequest")) {
rollbackNetworkRequest = rollbackData["rollbackNetworkRequest"]
}
@@ -130,14 +129,14 @@ public class DoCreateNetworkInstanceRollback extends AbstractServiceTaskProcesso
if(rollbackData.containsKey("rollbackActivateSDNCRequest")) {
rollbackActivateSDNCRequest = rollbackData["rollbackActivateSDNCRequest"]
}
-
+
}
-
+
execution.setVariable(Prefix + "rollbackNetworkRequest", rollbackNetworkRequest)
execution.setVariable(Prefix + "rollbackSDNCRequest", rollbackSDNCRequest)
execution.setVariable(Prefix + "rollbackActivateSDNCRequest", rollbackActivateSDNCRequest)
msoLogger.debug("'rollbackData': " + '\n' + execution.getVariable("rollbackData"))
-
+
String sdncVersion = execution.getVariable("sdncVersion")
msoLogger.debug("sdncVersion? : " + sdncVersion)
@@ -147,7 +146,7 @@ public class DoCreateNetworkInstanceRollback extends AbstractServiceTaskProcesso
def encodedString = utils.getBasicAuth(basicAuthValuePO, UrnPropertiesReader.getVariable("mso.msoKey", execution))
execution.setVariable("BasicAuthHeaderValuePO",encodedString)
execution.setVariable("BasicAuthHeaderValueSDNC", encodedString)
-
+
} catch (IOException ex) {
String exceptionMessage = "Exception Encountered in DoCreateNetworkInstance, PreProcessRequest() - "
String dataErrorMessage = exceptionMessage + " Unable to encode PO/SDNC user/password string - " + ex.getMessage()
@@ -168,88 +167,80 @@ public class DoCreateNetworkInstanceRollback extends AbstractServiceTaskProcesso
} else {
// called by: Macro - Full Rollback, WorkflowException = null
execution.setVariable(Prefix + "fullRollback", true)
-
+
}
msoLogger.debug("*** fullRollback? : " + execution.getVariable(Prefix + "fullRollback"))
-
-
+
+
} catch (BpmnError e) {
throw e;
-
+
} catch (Exception ex) {
// caught exception
String exceptionMessage = "Exception Encountered in PreProcessRequest() of " + className + ".groovy ***** : " + ex.getMessage()
msoLogger.debug(exceptionMessage)
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
-
+
}
}
-
+
public void callPONetworkAdapter (DelegateExecution execution) {
def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
execution.setVariable("prefix",Prefix)
msoLogger.trace("Inside callPONetworkAdapter() of " + className + "")
-
+
try {
String poUrl = UrnPropertiesReader.getVariable("mso.adapters.network.rest.endpoint",execution)
String rollbackSDNCRequest = execution.getVariable(Prefix + "rollbackSDNCRequest")
String networkId = utils.getNodeText(rollbackSDNCRequest, "network-id")
-
+
String rollbackNetworkRequest = execution.getVariable(Prefix + "rollbackNetworkRequest")
String urlRollbackPoNetwork = poUrl+ "/" + networkId + "/rollback"
msoLogger.debug("'urlRollbackPoNetwork': " + urlRollbackPoNetwork)
execution.setVariable(Prefix + "urlRollbackPoNetwork", urlRollbackPoNetwork)
- RESTConfig config = new RESTConfig(urlRollbackPoNetwork)
- RESTClient client = new RESTClient(config).
- addHeader("Content-Type", "application/xml").
- addAuthorizationHeader(execution.getVariable("BasicAuthHeaderValuePO"));
-
- APIResponse response = client.httpDelete(rollbackNetworkRequest)
- String responseCode = response.getStatusCode()
- String responseBody = response.getResponseBodyAsString()
-
- execution.setVariable(Prefix + "rollbackNetworkReturnCode", responseCode)
- execution.setVariable(Prefix + "rollbackNetworkResponse", responseBody)
-
- msoLogger.debug(" Network Adapter rollback responseCode: " + responseCode)
- msoLogger.debug(" Network Adapter rollback responseBody: " + responseBody)
-
-
+ URL url = new URL(urlRollbackPoNetwork)
+ HttpClient httpClient = new HttpClient(url, "application/xml", TargetEntity.OPENSTACK_ADAPTER)
+ httpClient.addAdditionalHeader("Authorization", execution.getVariable("BasicAuthHeaderValuePO"))
+ Response response = httpClient.delete(rollbackNetworkRequest)
+
+ execution.setVariable(Prefix + "rollbackNetworkReturnCode", response.getStatus())
+
+ msoLogger.debug(" Network Adapter rollback responseCode: " + response.getStatus())
+
+
} catch (Exception ex) {
String exceptionMessage = "Exception Encountered in callPONetworkAdapter() of DoCreateNetworkInstanceRollback flow - " + ex.getMessage()
msoLogger.debug(exceptionMessage)
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
}
-
+
}
-
-
+
+
public void validateRollbackResponses (DelegateExecution execution) {
def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
execution.setVariable("prefix",Prefix)
msoLogger.trace("Inside validateRollbackResponses() of DoCreateNetworkInstanceRollback")
-
+
try {
// validate PO network rollback response
String rollbackNetworkErrorMessages = ""
String rollbackNetworkReturnCode = "200"
if (execution.getVariable(Prefix + "rollbackNetworkRequest") != null) {
rollbackNetworkReturnCode = execution.getVariable(Prefix + "rollbackNetworkReturnCode")
- String rollbackNetworkResponse = execution.getVariable(Prefix + "rollbackNetworkResponse")
msoLogger.debug(" NetworkRollback Code - " + rollbackNetworkReturnCode)
- msoLogger.debug(" NetworkRollback Response - " + rollbackNetworkResponse)
if (rollbackNetworkReturnCode != "200") {
rollbackNetworkErrorMessages = " + PO Network rollback failed. "
} else {
rollbackNetworkErrorMessages = " + PO Network rollback completed."
}
}
-
+
// validate SDNC rollback response
String rollbackSdncErrorMessages = ""
String rollbackSDNCReturnCode = "200"
@@ -270,13 +261,13 @@ public class DoCreateNetworkInstanceRollback extends AbstractServiceTaskProcesso
}
} else {
rollbackSdncErrorMessages = " + SNDC assign rollback completed."
- }
+ }
} else {
rollbackSdncErrorMessages = " + SDNC assign rollback failed. "
}
msoLogger.debug(" SDNC assign rollback Code - " + rollbackSDNCReturnCode)
msoLogger.debug(" SDNC assign rollback Response - " + rollbackSDNCResponse)
- }
+ }
// validate SDNC activate rollback response
String rollbackActivateSdncErrorMessages = ""
@@ -303,15 +294,15 @@ public class DoCreateNetworkInstanceRollback extends AbstractServiceTaskProcesso
}
msoLogger.debug(" SDNC activate rollback Code - " + rollbackActivateSDNCReturnCode)
msoLogger.debug(" SDNC activate rollback Response - " + rollbackActivateSDNCResponse)
- }
+ }
String statusMessage = ""
int errorCode = 7000
msoLogger.debug("*** fullRollback? : " + execution.getVariable(Prefix + "fullRollback"))
- if (execution.getVariable(Prefix + "fullRollback") == false) {
- // original WorkflowException,
- WorkflowException wfe = execution.getVariable(Prefix + "WorkflowException")
+ if (execution.getVariable(Prefix + "fullRollback") == false) {
+ // original WorkflowException,
+ WorkflowException wfe = execution.getVariable(Prefix + "WorkflowException")
if (wfe != null) {
// rollback due to failure in DoCreate - Partial rollback
statusMessage = wfe.getErrorMessage()
@@ -325,7 +316,7 @@ public class DoCreateNetworkInstanceRollback extends AbstractServiceTaskProcesso
if (rollbackNetworkReturnCode == "200" && rollbackSDNCReturnCode == "200" && rollbackActivateSDNCReturnCode == "200") {
execution.setVariable("rolledBack", true)
execution.setVariable("wasDeleted", true)
-
+
} else {
execution.setVariable("rolledBack", false)
execution.setVariable("wasDeleted", true)
@@ -336,8 +327,8 @@ public class DoCreateNetworkInstanceRollback extends AbstractServiceTaskProcesso
String processKey = getProcessKey(execution);
WorkflowException exception = new WorkflowException(processKey, errorCode, statusMessage);
execution.setVariable("workflowException", exception);
-
- } else {
+
+ } else {
// rollback due to failures in Main flow (Macro) - Full rollback
// WorkflowException = null
if (rollbackNetworkReturnCode == "200" && rollbackSDNCReturnCode == "200" && rollbackActivateSDNCReturnCode == "200") {
@@ -351,9 +342,9 @@ public class DoCreateNetworkInstanceRollback extends AbstractServiceTaskProcesso
exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage)
throw new BpmnError("MSOWorkflowException")
}
-
- }
-
+
+ }
+
} catch (Exception ex) {
String errorMessage = "See Previous Camunda flows for cause of Error: Undetermined Exception."
@@ -370,18 +361,18 @@ public class DoCreateNetworkInstanceRollback extends AbstractServiceTaskProcesso
// *******************************
-
+
public void processJavaException(DelegateExecution execution){
def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
execution.setVariable("prefix",Prefix)
-
+
try{
msoLogger.debug("Caught a Java Exception in " + Prefix)
msoLogger.debug("Started processJavaException Method")
msoLogger.debug("Variables List: " + execution.getVariables())
execution.setVariable("UnexpectedError", "Caught a Java Lang Exception - " + Prefix) // Adding this line temporarily until this flows error handling gets updated
exceptionUtil.buildWorkflowException(execution, 500, "Caught a Java Lang Exception")
-
+
}catch(Exception e){
msoLogger.debug("Caught Exception during processJavaException Method: " + e)
execution.setVariable("UnexpectedError", "Exception in processJavaException method - " + Prefix) // Adding this line temporarily until this flows error handling gets updated
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy
index 08dc38cd2a..4bda803da0 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy
@@ -48,7 +48,7 @@ import org.onap.so.client.aai.entities.uri.AAIUri
import org.onap.so.client.aai.entities.uri.AAIUriFactory
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
-import org.onap.so.rest.APIResponse
+
import groovy.json.*
@@ -278,7 +278,7 @@ public class DoCreateServiceInstance extends AbstractServiceTaskProcessor {
if (siParamsXml == null)
siParamsXml = ""
execution.setVariable("siParamsXml", siParamsXml)
-
+
} catch (BpmnError e) {
throw e;
} catch (Exception ex){
@@ -323,7 +323,7 @@ public class DoCreateServiceInstance extends AbstractServiceTaskProcessor {
{
oStatus = "Created"
}
-
+
//QUERY CATALOG DB AND GET WORKLOAD / ENVIRONMENT CONTEXT
String environmentContext = ""
String workloadContext =""
@@ -345,7 +345,7 @@ public class DoCreateServiceInstance extends AbstractServiceTaskProcessor {
msoLogger.debug(msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
}
-
+
org.onap.aai.domain.yang.ServiceInstance si = new org.onap.aai.domain.yang.ServiceInstance()
si.setServiceInstanceName(execution.getVariable("serviceInstanceName"))
si.setServiceType(serviceType)
@@ -354,7 +354,7 @@ public class DoCreateServiceInstance extends AbstractServiceTaskProcessor {
si.setModelInvariantId(modelInvariantUuid)
si.setModelVersionId(execution.getVariable("modelUuid"))
si.setEnvironmentContext(environmentContext)
- si.setWorkloadContext(workloadContext)
+ si.setWorkloadContext(workloadContext)
AAIResourcesClient client = new AAIResourcesClient()
AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), serviceInstanceId)
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstanceRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstanceRollback.groovy
index dd56b8f2cc..e80941e212 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstanceRollback.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstanceRollback.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.
@@ -30,9 +30,6 @@ import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils
import org.onap.so.bpmn.core.RollbackData
import org.onap.so.bpmn.core.WorkflowException
-import org.onap.so.rest.APIResponse;
-import org.onap.so.rest.RESTClient
-import org.onap.so.rest.RESTConfig
import org.onap.so.logger.MsoLogger
import org.onap.so.logger.MessageEnum
@@ -57,7 +54,7 @@ import org.springframework.web.util.UriUtils;
* rollbackAAI
* rollbackSDNC
* sdncRollbackRequest
- *
+ *
*
* Outputs:
* @param - rollbackError
@@ -66,7 +63,7 @@ import org.springframework.web.util.UriUtils;
*/
public class DoCreateServiceInstanceRollback extends AbstractServiceTaskProcessor{
private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoCreateServiceInstanceRollback.class);
-
+
String Prefix="DCRESIRB_"
@@ -141,7 +138,7 @@ public class DoCreateServiceInstanceRollback extends AbstractServiceTaskProcesso
}
public void validateSDNCResponse(DelegateExecution execution, String response, String method) {
-
+
msoLogger.trace("validateSDNCResponse")
String msg = ""
try {
@@ -149,7 +146,7 @@ public class DoCreateServiceInstanceRollback extends AbstractServiceTaskProcesso
boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
msoLogger.debug("SDNCResponse: " + response)
msoLogger.debug("workflowException: " + workflowException)
-
+
SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
@@ -174,7 +171,7 @@ public class DoCreateServiceInstanceRollback extends AbstractServiceTaskProcesso
}
public void postProcessRequest(DelegateExecution execution) {
-
+
msoLogger.trace("postProcessRequest")
String msg = ""
try {
@@ -208,7 +205,7 @@ public class DoCreateServiceInstanceRollback extends AbstractServiceTaskProcesso
}
public void processRollbackException(DelegateExecution execution){
-
+
msoLogger.trace("processRollbackException")
try{
msoLogger.debug("Caught an Exception in DoCreateServiceInstanceRollback")
@@ -226,7 +223,7 @@ public class DoCreateServiceInstanceRollback extends AbstractServiceTaskProcesso
}
public void processRollbackJavaException(DelegateExecution execution){
-
+
msoLogger.trace("processRollbackJavaException")
try{
execution.setVariable("rollbackData", null)
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy
index 2663ba7aa7..a3c30dcb50 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.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,19 +23,19 @@ package org.onap.so.bpmn.infrastructure.scripts
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.camunda.bpm.engine.delegate.BpmnError
+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.bpmn.common.scripts.AbstractServiceTaskProcessor
import org.onap.so.bpmn.common.scripts.ExceptionUtil
-import org.onap.so.bpmn.core.json.JsonUtils
+import org.onap.so.bpmn.core.json.JsonUtils
import org.onap.so.client.HttpClient
import org.onap.so.logger.MessageEnum
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 groovy.json.*
+import javax.ws.rs.core.Response
/**
* This groovy class supports the <class>DoCreateVFCNetworkServiceInstance.bpmn</class> process.
@@ -45,9 +45,9 @@ public class DoCreateVFCNetworkServiceInstance extends AbstractServiceTaskProces
private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoCreateVFCNetworkServiceInstance.class);
String vfcUrl = "/vfc/rest/v1/vfcadapter"
-
+
String host = "http://mso.mso.testlab.openecomp.org:8080"
-
+
ExceptionUtil exceptionUtil = new ExceptionUtil()
JsonUtils jsonUtil = new JsonUtils()
@@ -99,7 +99,7 @@ public class DoCreateVFCNetworkServiceInstance extends AbstractServiceTaskProces
}"""
execution.setVariable("nsOperationKey", nsOperationKey);
execution.setVariable("nsParameters", nsParameters)
-
+
} catch (BpmnError e) {
throw e;
@@ -126,9 +126,9 @@ public class DoCreateVFCNetworkServiceInstance extends AbstractServiceTaskProces
"nsOperationKey":${nsOperationKey},
"nsParameters":${nsParameters}
}"""
- APIResponse apiResponse = postRequest(execution, host + vfcUrl + "/ns", reqBody)
- String returnCode = apiResponse.getStatusCode()
- String aaiResponseAsString = apiResponse.getResponseBodyAsString()
+ Response apiResponse = postRequest(execution, host + vfcUrl + "/ns", reqBody)
+ String returnCode = apiResponse.getStatus()
+ String aaiResponseAsString = apiResponse.readEntity(String.class)
String nsInstanceId = "";
if(returnCode== "200" || returnCode == "201"){
nsInstanceId = jsonUtil.getJsonValue(aaiResponseAsString, "nsInstanceId")
@@ -154,9 +154,9 @@ public class DoCreateVFCNetworkServiceInstance extends AbstractServiceTaskProces
}"""
String nsInstanceId = execution.getVariable("nsInstanceId")
String url = host + vfcUrl + "/ns/" +nsInstanceId + "/instantiate"
- APIResponse apiResponse = postRequest(execution, url, reqBody)
- String returnCode = apiResponse.getStatusCode()
- String aaiResponseAsString = apiResponse.getResponseBodyAsString()
+ Response apiResponse = postRequest(execution, url, reqBody)
+ String returnCode = apiResponse.getStatus()
+ String aaiResponseAsString = apiResponse.readEntity(String.class)
String jobId = "";
if(returnCode== "200"|| returnCode == "201"){
jobId = jsonUtil.getJsonValue(aaiResponseAsString, "jobId")
@@ -173,9 +173,9 @@ public class DoCreateVFCNetworkServiceInstance extends AbstractServiceTaskProces
String jobId = execution.getVariable("jobId")
String nsOperationKey = execution.getVariable("nsOperationKey");
String url = host + vfcUrl + "/jobs/" + jobId
- APIResponse apiResponse = postRequest(execution, url, nsOperationKey)
- String returnCode = apiResponse.getStatusCode()
- String aaiResponseAsString = apiResponse.getResponseBodyAsString()
+ Response apiResponse = postRequest(execution, url, nsOperationKey)
+ String returnCode = apiResponse.getStatus()
+ String aaiResponseAsString = apiResponse.readEntity(String.class)
String operationStatus = "error"
if(returnCode== "200"|| returnCode == "201"){
operationStatus = jsonUtil.getJsonValue(aaiResponseAsString, "responseDescriptor.status")
@@ -185,12 +185,12 @@ public class DoCreateVFCNetworkServiceInstance extends AbstractServiceTaskProces
}
/**
- * delay 5 sec
+ * delay 5 sec
*/
public void timeDelay(DelegateExecution execution) {
try {
Thread.sleep(5000);
- } catch(InterruptedException e) {
+ } catch(InterruptedException e) {
msoLogger.debug("Time Delay exception" + e )
}
}
@@ -226,20 +226,26 @@ public class DoCreateVFCNetworkServiceInstance extends AbstractServiceTaskProces
* url: the url of the request
* requestBody: the body of the request
*/
- private APIResponse postRequest(DelegateExecution execution, String url, String requestBody){
+ private Response postRequest(DelegateExecution execution, String urlString, String requestBody){
msoLogger.trace("Started Execute VFC adapter Post Process")
- msoLogger.debug("url:"+url +"\nrequestBody:"+ requestBody)
- APIResponse apiResponse = null
+ msoLogger.debug("url:"+urlString +"\nrequestBody:"+ requestBody)
+ Response apiResponse = null
try{
- RESTConfig config = new RESTConfig(url);
- RESTClient client = new RESTClient(config).addHeader("Content-Type", "application/json").addHeader("Accept","application/json").addHeader("Authorization","Basic QlBFTENsaWVudDpwYXNzd29yZDEk");
- apiResponse = client.httpPost(requestBody)
- msoLogger.debug("response code:"+ apiResponse.getStatusCode() +"\nresponse body:"+ apiResponse.getResponseBodyAsString())
+
+ URL url = new URL(urlString);
+
+ HttpClient httpClient = new HttpClient(url, "application/json", TargetEntity.VNF_ADAPTER)
+ httpClient.addAdditionalHeader("Accept", "application/json")
+ httpClient.addAdditionalHeader("Authorization", "Basic QlBFTENsaWVudDpwYXNzd29yZDEk")
+
+ apiResponse = httpClient.post(requestBody)
+
+ msoLogger.debug("response code:"+ apiResponse.getStatus() +"\nresponse body:"+ apiResponse.readEntity(String.class))
msoLogger.trace("Completed Execute VF-C adapter 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, "Exception is:\n" + e);
throw new BpmnError("MSOWorkflowException")
- }
+ }
return apiResponse
}
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy
index 6917a97887..50fe75e3df 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy
@@ -20,6 +20,8 @@
package org.onap.so.bpmn.infrastructure.scripts
+import javax.ws.rs.core.MediaType
+import javax.ws.rs.core.Response
import javax.xml.parsers.DocumentBuilder
import javax.xml.parsers.DocumentBuilderFactory
@@ -42,6 +44,8 @@ import org.onap.so.bpmn.core.WorkflowException
import org.onap.so.bpmn.core.domain.VnfResource
import org.onap.so.bpmn.core.json.DecomposeJsonUtil
import org.onap.so.bpmn.core.json.JsonUtils
+import org.onap.so.client.graphinventory.entities.uri.Depth
+import org.onap.so.client.HttpClient
import org.onap.so.client.aai.AAIObjectPlurals
import org.onap.so.client.aai.AAIObjectType;
import org.onap.so.client.aai.AAIResourcesClient
@@ -53,9 +57,9 @@ import org.onap.so.client.graphinventory.entities.uri.Depth
import org.onap.so.constants.Defaults
import org.onap.so.logger.MessageEnum
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.springframework.web.util.UriUtils
import org.w3c.dom.Document
import org.w3c.dom.Element
import org.w3c.dom.NamedNodeMap
@@ -638,28 +642,26 @@ public class DoCreateVfModule extends VfModuleBase {
String endPoint = aaiUriUtil.createAaiUri(uri)
try {
- RESTConfig config = new RESTConfig(endPoint);
- 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');
+ 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', MediaType.APPLICATION_XML)
+ client.addAdditionalHeader('Accept', MediaType.APPLICATION_XML)
+
msoLogger.debug('sending GET to AAI endpoint \'' + endPoint + '\'')
- APIResponse response = client.httpGet()
+ Response response = client.get()
- responseData = response.getResponseBodyAsString()
+ String responseData = response.readEntity(String.class)
if (responseData != null) {
msoLogger.debug("Received generic VNF data: " + responseData)
}
- execution.setVariable('DCVFM_queryAAIVfModuleResponseCode', response.getStatusCode())
+ execution.setVariable('DCVFM_queryAAIVfModuleResponseCode', response.getStatus())
execution.setVariable('DCVFM_queryAAIVfModuleResponse', 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 the VNF record from A&AI to find base module info
msoLogger.debug('Parsing the VNF data to find base module info')
if (responseData != null) {
@@ -722,31 +724,31 @@ public class DoCreateVfModule extends VfModuleBase {
AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VF_MODULE, vnfId).queryParam("vf-module-name",vfModuleName)
String endPoint = aaiUriUtil.createAaiUri(uri)
+ 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', MediaType.APPLICATION_XML)
+ client.addAdditionalHeader('Accept', MediaType.APPLICATION_XML)
+
try {
- RESTConfig config = new RESTConfig(endPoint);
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("createVfModule - invoking httpGet() to AAI")
- responseData = response.getResponseBodyAsString()
+ responseData = response.readEntity(String.class)
if (responseData != null) {
msoLogger.debug("Received generic VNF data: " + responseData)
}
- execution.setVariable('DCVFM_queryAAIVfModuleForStatusResponseCode', response.getStatusCode())
+ execution.setVariable('DCVFM_queryAAIVfModuleForStatusResponseCode', response.getStatus())
execution.setVariable('DCVFM_queryAAIVfModuleForStatusResponse', responseData)
- msoLogger.debug('Response code:' + response.getStatusCode())
+ msoLogger.debug('Response code:' + response.getStatus())
msoLogger.debug('Response:' + System.lineSeparator() + responseData)
// Retrieve VF Module info and its orchestration status; if not found, do nothing
- if (response.getStatusCode() == 200) {
+ if (response.getStatus() == 200) {
// Parse the VNF record from A&AI to find base module info
msoLogger.debug('Parsing the VNF data to find orchestration status')
if (responseData != null) {
@@ -1883,7 +1885,6 @@ public class DoCreateVfModule extends VfModuleBase {
} catch (BpmnError e) {
throw e;
-
} catch (Exception ex) {
String exceptionMessage = "Bpmn error encountered in DoCreateVfModule flow. createNetworkPoliciesInAAI() - " + ex.getMessage()
msoLogger.debug(exceptionMessage)
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy
index 38858d20f7..55a84575f4 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.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.
@@ -36,7 +36,7 @@ import org.onap.so.client.aai.entities.uri.AAIResourceUri
import org.onap.so.client.aai.entities.uri.AAIUriFactory
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
-import org.onap.so.rest.APIResponse
+
import org.springframework.web.util.UriUtils
import javax.ws.rs.NotFoundException
@@ -44,7 +44,7 @@ import javax.ws.rs.NotFoundException
public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{
private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoCreateVfModuleRollback.class);
-
+
def Prefix="DCVFMR_"
ExceptionUtil exceptionUtil = new ExceptionUtil()
@@ -55,7 +55,7 @@ public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{
// parse the incoming DELETE_VF_MODULE request for the Generic Vnf and Vf Module Ids
// and formulate the outgoing request for PrepareUpdateAAIVfModuleRequest
public void preProcessRequest(DelegateExecution execution) {
-
+
initProcessVariables(execution)
@@ -63,10 +63,10 @@ public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{
execution.setVariable("rolledBack", null)
execution.setVariable("rollbackError", null)
-
+
def rollbackData = execution.getVariable("rollbackData")
msoLogger.debug("RollbackData:" + rollbackData)
-
+
if (rollbackData != null) {
String vnfId = rollbackData.get("VFMODULE", "vnfid")
execution.setVariable("DCVFMR_vnfId", vnfId)
@@ -106,9 +106,9 @@ public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{
createdNetworkPolicyFqdnList.add(fqdn)
msoLogger.debug("got fqdn # " + i + ": " + fqdn)
i = i + 1
-
+
}
-
+
execution.setVariable("DCVFMR_createdNetworkPolicyFqdnList", createdNetworkPolicyFqdnList)
String oamManagementV4Address = rollbackData.get("VFMODULE", "oamManagementV4Address")
execution.setVariable("DCVFMR_oamManagementV4Address", oamManagementV4Address)
@@ -124,7 +124,7 @@ public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{
execution.setVariable("DCVFMR_rollbackCreateAAIVfModule", rollbackData.get("VFMODULE", "rollbackCreateAAIVfModule"))
execution.setVariable("DCVFMR_rollbackCreateNetworkPoliciesAAI", rollbackData.get("VFMODULE", "rollbackCreateNetworkPoliciesAAI"))
execution.setVariable("DCVFMR_rollbackUpdateVnfAAI", rollbackData.get("VFMODULE", "rollbackUpdateVnfAAI"))
-
+
// formulate the request for PrepareUpdateAAIVfModule
String request = """<PrepareUpdateAAIVfModuleRequest>
<vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id>
@@ -136,11 +136,11 @@ public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{
} else {
execution.setVariable("skipRollback", true)
}
-
+
if (execution.getVariable("disableRollback").equals("true" )) {
execution.setVariable("skipRollback", true)
}
-
+
} catch (BpmnError e) {
throw e;
} catch (Exception ex){
@@ -153,14 +153,14 @@ public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{
// build a SDNC vnf-topology-operation request for the specified action
// (note: the action passed is expected to be 'changedelete' or 'delete')
public void prepSDNCAdapterRequest(DelegateExecution execution) {
-
+
String srvInstId = execution.getVariable("DCVFMR_serviceInstanceId")
String uuid = execution.getVariable('testReqId') // for junits
if(uuid==null){
uuid = execution.getVariable("DCVFMR_requestId") + "-" + System.currentTimeMillis()
}
-
+
def callbackUrl = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution)
String source = execution.getVariable("DCVFMR_source")
@@ -243,21 +243,21 @@ public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{
}
public void preProcessSDNCDeactivateRequest(DelegateExecution execution){
-
+
execution.setVariable("prefix", Prefix)
msoLogger.trace("STARTED preProcessSDNCDeactivateRequest")
-
+
def serviceInstanceId = execution.getVariable("DCVFMR_serviceInstanceId")
-
+
try{
//Build SDNC Request
-
+
String deactivateSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "deactivate")
-
+
deactivateSDNCRequest = utils.formatXml(deactivateSDNCRequest)
execution.setVariable("DCVFMR_deactivateSDNCRequest", deactivateSDNCRequest)
msoLogger.debug("Outgoing DeactivateSDNCRequest is: \n" + deactivateSDNCRequest)
-
+
}catch(Exception e){
msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing preProcessSDNCDeactivateRequest.", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessSDNCDeactivateRequest Method:\n" + e.getMessage())
@@ -275,12 +275,12 @@ public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{
msoLogger.trace("STARTED preProcessSDNCUnassignRequest Process")
try{
String serviceInstanceId = execution.getVariable("DCVFMR_serviceInstanceId")
-
+
String unassignSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "unassign")
-
+
execution.setVariable("DCVFMR_unassignSDNCRequest", unassignSDNCRequest)
msoLogger.debug("Outgoing UnassignSDNCRequest is: \n" + unassignSDNCRequest)
-
+
}catch(Exception e){
msoLogger.debug("Exception Occured Processing preProcessSDNCUnassignRequest. Exception is:\n" + e)
exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessSDNCUnassignRequest Method:\n" + e.getMessage())
@@ -289,7 +289,7 @@ public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{
}
public String buildSDNCRequest(DelegateExecution execution, String svcInstId, String action){
-
+
String uuid = execution.getVariable('testReqId') // for junits
if(uuid==null){
uuid = execution.getVariable("DCVFMR_requestId") + "-" + System.currentTimeMillis()
@@ -301,9 +301,9 @@ public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{
def vfModuleId = execution.getVariable("DCVFMR_vfModuleId")
def source = execution.getVariable("DCVFMR_source")
def vnfId = execution.getVariable("DCVFMR_vnfId")
-
+
def sdncVersion = execution.getVariable("sdncVersion")
-
+
String sdncRequest =
"""<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.onap/so/request/types/v1"
xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
@@ -327,29 +327,29 @@ public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{
</request-information>
<service-information>
<service-id/>
- <subscription-service-type/>
+ <subscription-service-type/>
<service-instance-id>${MsoUtils.xmlEscape(serviceInstanceId)}</service-instance-id>
<global-customer-id/>
</service-information>
<vnf-information>
<vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id>
- <vnf-type/>
+ <vnf-type/>
</vnf-information>
<vf-module-information>
<vf-module-id>${MsoUtils.xmlEscape(vfModuleId)}</vf-module-id>
</vf-module-information>
- <vf-module-request-input/>
+ <vf-module-request-input/>
</sdncadapterworkflow:SDNCRequestData>
</sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
-
+
msoLogger.debug("sdncRequest: " + sdncRequest)
return sdncRequest
}
-
+
// parse the incoming DELETE_VF_MODULE request
// and formulate the outgoing VnfAdapterDeleteV1 request
public void prepVNFAdapterRequest(DelegateExecution execution) {
-
+
String requestId = UUID.randomUUID().toString()
String origRequestId = execution.getVariable("DCVFMR_requestId")
String srvInstId = execution.getVariable("DCVFMR_serviceInstanceId")
@@ -390,7 +390,7 @@ public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{
// parse the incoming DELETE_VF_MODULE request
// and formulate the outgoing UpdateAAIVfModuleRequest request
public void prepUpdateAAIVfModule(DelegateExecution execution) {
-
+
String vnfId = execution.getVariable("DCVFMR_vnfId")
String vfModuleId = execution.getVariable("DCVFMR_vfModuleId")
// formulate the request for UpdateAAIVfModule
@@ -403,11 +403,11 @@ public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{
msoLogger.debug("UpdateAAIVfModuleRequest :" + request)
execution.setVariable("UpdateAAIVfModuleRequest", request)
}
-
+
// parse the incoming DELETE_VF_MODULE request
// and formulate the outgoing UpdateAAIVfModuleRequest request
public void prepUpdateAAIVfModuleToAssigned(DelegateExecution execution) {
-
+
String vnfId = execution.getVariable("DCVFMR_vnfId")
String vfModuleId = execution.getVariable("DCVFMR_vfModuleId")
// formulate the request for UpdateAAIVfModule
@@ -424,7 +424,7 @@ public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{
// parse the incoming DELETE_VF_MODULE request
// and formulate the outgoing DeleteAAIVfModuleRequest request
public void prepDeleteAAIVfModule(DelegateExecution execution) {
-
+
String vnfId = execution.getVariable("DCVFMR_vnfId")
String vfModuleId = execution.getVariable("DCVFMR_vfModuleId")
// formulate the request for UpdateAAIVfModule
@@ -439,7 +439,7 @@ public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{
// generates a WorkflowException if
// -
public void handleDoDeleteVfModuleFailure(DelegateExecution execution) {
-
+
msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "AAI error occurred deleting the Generic Vnf"+ execution.getVariable("DoDVfMod_deleteGenericVnfResponse"), "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError);
String processKey = getProcessKey(execution);
exceptionUtil.buildWorkflowException(execution, 5000, "Failure in DoDeleteVfModule")
@@ -447,7 +447,7 @@ public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{
}
public void sdncValidateResponse(DelegateExecution execution, String response){
-
+
execution.setVariable("prefix",Prefix)
WorkflowException workflowException = execution.getVariable("WorkflowException")
@@ -603,35 +603,35 @@ public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{
exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preProcessUpdateAAIGenericVnf((): ' + e.getMessage())
}
}
-
+
public void setSuccessfulRollbackStatus (DelegateExecution execution){
-
+
execution.setVariable("prefix", Prefix)
msoLogger.trace("STARTED setSuccessfulRollbackStatus")
-
+
try{
// Set rolledBack to true, rollbackError to null
execution.setVariable("rolledBack", true)
execution.setVariable("rollbackError", null)
-
+
}catch(Exception e){
msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing setSuccessfulRollbackStatus.", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during setSuccessfulRollbackStatus Method:\n" + e.getMessage())
}
msoLogger.trace("COMPLETED setSuccessfulRollbackStatus")
}
-
+
public void setFailedRollbackStatus (DelegateExecution execution){
-
+
execution.setVariable("prefix", Prefix)
msoLogger.trace("STARTED setFailedRollbackStatus")
-
+
try{
// Set rolledBack to false, rollbackError to actual value, rollbackData to null
execution.setVariable("rolledBack", false)
execution.setVariable("rollbackError", 'Caught exception in DoCreateVfModuleRollback')
execution.setVariable("rollbackData", null)
-
+
}catch(Exception e){
msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing setFailedRollbackStatus.", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during setFailedRollbackStatus Method:\n" + e.getMessage())
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceV2.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceV2.groovy
index 7e9b4f47ab..eab6fe05e7 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceV2.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceV2.groovy
@@ -37,7 +37,7 @@ import org.onap.so.bpmn.common.scripts.MsoUtils
import org.onap.so.bpmn.core.json.JsonUtils
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
-import org.onap.so.rest.APIResponse;
+
import org.springframework.web.util.UriUtils;
import org.onap.so.client.aai.AAIResourcesClient
import org.onap.so.client.aai.AAIObjectType
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy
index 66bd1ece90..3630df00f4 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy
@@ -21,6 +21,7 @@ package org.onap.so.bpmn.infrastructure.scripts
import static org.apache.commons.lang3.StringUtils.*;
+import javax.ws.rs.core.Response
import javax.xml.parsers.DocumentBuilder
import javax.xml.parsers.DocumentBuilderFactory
@@ -36,8 +37,10 @@ import org.onap.so.bpmn.common.scripts.MsoUtils
import org.onap.so.bpmn.core.WorkflowException
import org.onap.so.bpmn.core.domain.Resource
import org.onap.so.bpmn.core.domain.ServiceDecomposition
-import org.onap.so.rest.APIResponse
+
+import org.onap.so.utils.TargetEntity
import org.onap.so.bpmn.core.json.JsonUtils
+import org.onap.so.client.HttpClient
import org.springframework.web.util.UriUtils;
import org.w3c.dom.Document
import org.w3c.dom.Element
@@ -207,7 +210,7 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor {
}
execution.setVariable("serviceRelationShip", jArray.toString())
-
+
// //test(siData)
// NodeList nodeList = serviceXml.getElementsByTagName("relationship")
// JSONArray jArray = new JSONArray()
@@ -276,8 +279,8 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor {
// }
// // for SP-Partner
// }else if (e.equals("sp-partner")){
-//
-// }
+//
+// }
// }
// }
// execution.setVariable("serviceRelationShip", jArray.toString())
@@ -311,16 +314,16 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor {
}
utils.log("INFO"," *** Exit postProcessAAIGET *** ", isDebugEnabled)
}
-
+
private JSONObject getRelationShipData(node, isDebugEnabled){
JSONObject jObj = new JSONObject()
-
+
def relation = utils.nodeToString(node)
def rt = utils.getNodeText(relation, "related-to")
-
+
def rl = utils.getNodeText(relation, "related-link")
utils.log("INFO", "ServiceInstance Related NS/Configuration :" + rl, isDebugEnabled)
-
+
def rl_datas = utils.getIdenticalChildren(node, "relationship-data")
for(def rl_data : rl_datas) {
def eKey = utils.getChildNodeText(rl_data, "relationship-key")
@@ -398,7 +401,7 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor {
}
private void generateRelatedResourceInfo(String response, JSONObject jObj){
-
+
def xml = new XmlSlurper().parseText(response)
def rtn = xml.childNodes()
while (rtn.hasNext()) {
@@ -408,26 +411,29 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor {
jObj.put(key, value)
}
}
-
+
private JSONObject getRelatedResourceInAAI (DelegateExecution execution, JSONObject jObj)
{
def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- utils.log("INFO"," ***** Started getRelatedResourceInAAI *****", isDebugEnabled)
-
+ utils.log("INFO"," ***** Started getRelatedResourceInAAI *****", isDebugEnabled)
+
AaiUtil aaiUriUtil = new AaiUtil()
String aai_endpoint = execution.getVariable("URN_aai_endpoint")
String urlLink = jObj.get("resourceLinkUrl")
String serviceAaiPath = "${aai_endpoint}${urlLink}"
- APIResponse response = aaiUriUtil.executeAAIGetCall(execution, serviceAaiPath)
- int responseCode = response.getStatusCode()
+
+ URL url = new URL(serviceAaiPath)
+ HttpClient client = new HttpClient(url, "application/xml", TargetEntity.AAI)
+
+
+ Response response = client.get()
+ int responseCode = response.getStatus()
execution.setVariable(Prefix + "GeRelatedResourceResponseCode", responseCode)
utils.log("DEBUG", " Get RelatedResource code is: " + responseCode, isDebugEnabled)
- String aaiResponse = response.getResponseBodyAsString()
- aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse)
- aaiResponse = aaiResponse.replaceAll("&", "&amp;")
+ String aaiResponse = response.readEntity(String.class)
execution.setVariable(Prefix + "GetRelatedResourceResponse", aaiResponse)
-
+
//Process Response
if(responseCode == 200 || responseCode == 201 || responseCode == 202 )
//200 OK 201 CREATED 202 ACCEPTED
@@ -435,9 +441,9 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor {
utils.log("DEBUG", "GET RelatedResource Received a Good Response", isDebugEnabled)
execution.setVariable(Prefix + "SuccessIndicator", true)
execution.setVariable(Prefix + "FoundIndicator", true)
-
+
generateRelatedResourceInfo(aaiResponse, jObj)
-
+
//get model-invariant-uuid and model-uuid
String modelInvariantId = ""
String modelUuid = ""
@@ -447,19 +453,19 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor {
modelUuid = jObj.get("model-version-id")
modelCustomizationId = jObj.get("model-customization-id")
}
-
- jObj.put("modelInvariantId", modelInvariantId)
- jObj.put("modelVersionId", modelUuid)
+
+ jObj.put("modelInvariantId", modelInvariantId)
+ jObj.put("modelVersionId", modelUuid)
jObj.put("modelCustomizationId", modelCustomizationId)
}
else
{
- utils.log("ERROR", "Get RelatedResource Received a Bad Response Code. Response Code is: " + responseCode, isDebugEnabled)
+ utils.log("ERROR", "Get RelatedResource Received a Bad Response Code. Response Code is: " + responseCode, isDebugEnabled)
}
-
+
utils.log("INFO", " ***** Exit getRelatedResourceInAAI *****", isDebugEnabled)
- return jObj;
-
+ return jObj;
+
}
public void postDecomposeService(DelegateExecution execution) {
@@ -491,7 +497,7 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor {
relationShipList.each {
JSONObject obj = getRelatedResourceInAAI(execution, (JSONObject)it)
-
+
for (Resource resource : deleteResourceList) {
String modelName = resource.getModelInfo().getModelName()
@@ -508,7 +514,7 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor {
}
}
}
- }
+ }
// only delete real existing resources
execution.setVariable("deleteResourceList", deleteRealResourceList)
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy
index 1333c1f4c4..ca4643dea0 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy
@@ -33,6 +33,7 @@ import org.onap.so.bpmn.common.scripts.VidUtils
import org.onap.so.bpmn.core.UrnPropertiesReader
import org.onap.so.bpmn.core.WorkflowException
import org.onap.so.bpmn.core.json.JsonUtils
+import org.onap.so.client.HttpClient
import org.onap.so.client.aai.AAIObjectType
import org.onap.so.client.aai.entities.AAIResultWrapper
import org.onap.so.client.aai.entities.Relationships
@@ -42,12 +43,12 @@ import org.onap.so.client.graphinventory.entities.uri.Depth
import org.onap.so.constants.Defaults
import org.onap.so.logger.MessageEnum
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.springframework.web.util.UriUtils
+import org.onap.so.utils.TargetEntity
import groovy.json.JsonOutput
+import javax.ws.rs.core.Response
public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor {
private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoDeleteNetworkInstance.class);
@@ -447,17 +448,13 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor {
String vnfAdapterUrl = UrnPropertiesReader.getVariable("mso.adapters.network.rest.endpoint",execution)
String vnfAdapterRequest = execution.getVariable(Prefix + "deleteNetworkRequest")
- RESTConfig config = new RESTConfig(vnfAdapterUrl)
- RESTClient client = new RESTClient(config).
- addHeader("Content-Type", "application/xml").
- addAuthorizationHeader(execution.getVariable("BasicAuthHeaderValuePO"));
-
- APIResponse response;
+ URL url = new URL(vnfAdapterUrl)
+ HttpClient httpClient = new HttpClient(url, "application/xml", TargetEntity.OPENSTACK_ADAPTER)
+ httpClient.addAdditionalHeader("Authorization", execution.getVariable("BasicAuthHeaderValuePO"))
+ Response response = httpClient.delete(vnfAdapterRequest)
- response = client.httpDelete(vnfAdapterRequest)
- execution.setVariable(Prefix + "networkReturnCode", response.getStatusCode())
- execution.setVariable(Prefix + "deleteNetworkResponse", response.getResponseBodyAsString())
+ execution.setVariable(Prefix + "networkReturnCode", response.getStatus())
} catch (Exception ex) {
// caught exception
@@ -499,7 +496,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor {
execution.setVariable(Prefix + "requestId", requestId)
msoLogger.debug(Prefix + "requestId " + requestId)
L3Network queryAAIResponse = execution.getVariable(Prefix + "queryAAIResponse")
-
+
SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc")
// 1. prepare delete topology via SDNC Adapter SUBFLOW call
@@ -972,9 +969,9 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor {
requestId = execution.getVariable("mso-request-id")
}
execution.setVariable(Prefix + "requestId", requestId)
-
+
L3Network queryAAIResponse = execution.getVariable(Prefix + "queryAAIResponse")
-
+
SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc")
// 1. prepare delete topology via SDNC Adapter SUBFLOW call
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceRollback.groovy
index ca6e21eedc..1db7475cba 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceRollback.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceRollback.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.
@@ -30,9 +30,7 @@ import org.onap.so.bpmn.common.scripts.NetworkUtils
import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils
import org.onap.so.bpmn.common.scripts.VidUtils
import org.onap.so.bpmn.core.WorkflowException
-import org.onap.so.rest.APIResponse;
-import org.onap.so.rest.RESTClient
-import org.onap.so.rest.RESTConfig
+
import java.util.UUID;
@@ -51,7 +49,7 @@ import org.onap.so.logger.MsoLogger
*/
public class DoDeleteNetworkInstanceRollback extends AbstractServiceTaskProcessor {
private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoDeleteNetworkInstanceRollback.class);
-
+
String Prefix="DELNWKIR_"
ExceptionUtil exceptionUtil = new ExceptionUtil()
JsonUtils jsonUtil = new JsonUtils()
@@ -60,16 +58,16 @@ public class DoDeleteNetworkInstanceRollback extends AbstractServiceTaskProcesso
SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
def className = getClass().getSimpleName()
-
+
/**
* This method is executed during the preProcessRequest task of the <class>DoDeleteNetworkInstanceRollback.bpmn</class> process.
* @param execution
*/
public InitializeProcessVariables(DelegateExecution execution){
/* Initialize all the process variables in this block */
-
+
execution.setVariable(Prefix + "WorkflowException", null)
-
+
execution.setVariable(Prefix + "rollbackDeactivateSDNCRequest", null)
execution.setVariable(Prefix + "rollbackDeactivateSDNCResponse", "")
execution.setVariable(Prefix + "rollbackDeactivateSDNCReturnCode", "")
@@ -77,11 +75,11 @@ public class DoDeleteNetworkInstanceRollback extends AbstractServiceTaskProcesso
execution.setVariable(Prefix + "rollbackSDNCRequest", "")
execution.setVariable(Prefix + "rollbackSDNCResponse", "")
execution.setVariable(Prefix + "rollbackSDNCReturnCode", "")
-
+
execution.setVariable(Prefix + "rollbackNetworkRequest", null)
execution.setVariable(Prefix + "rollbackNetworkResponse", "")
execution.setVariable(Prefix + "rollbackNetworkReturnCode", "")
-
+
execution.setVariable(Prefix + "Success", false)
execution.setVariable(Prefix + "fullRollback", false)
@@ -97,13 +95,13 @@ public class DoDeleteNetworkInstanceRollback extends AbstractServiceTaskProcesso
public void preProcessRequest (DelegateExecution execution) {
execution.setVariable("prefix",Prefix)
-
+
msoLogger.trace("Inside preProcessRequest() of " + className + ".groovy ")
try {
// initialize flow variables
InitializeProcessVariables(execution)
-
+
// GET Incoming request/variables
String rollbackDeactivateSDNCRequest = null
String rollbackSDNCRequest = null
@@ -111,20 +109,20 @@ public class DoDeleteNetworkInstanceRollback extends AbstractServiceTaskProcesso
Map<String, String> rollbackData = execution.getVariable("rollbackData")
if (rollbackData != null && rollbackData instanceof Map) {
-
+
if(rollbackData.containsKey("rollbackDeactivateSDNCRequest")) {
rollbackDeactivateSDNCRequest = rollbackData["rollbackDeactivateSDNCRequest"]
}
-
+
if(rollbackData.containsKey("rollbackSDNCRequest")) {
rollbackSDNCRequest = rollbackData["rollbackSDNCRequest"]
}
-
+
if(rollbackData.containsKey("rollbackNetworkRequest")) {
rollbackNetworkRequest = rollbackData["rollbackNetworkRequest"]
}
}
-
+
execution.setVariable(Prefix + "rollbackNetworkRequest", rollbackNetworkRequest)
execution.setVariable(Prefix + "rollbackSDNCRequest", rollbackSDNCRequest)
execution.setVariable(Prefix + "rollbackDeactivateSDNCRequest", rollbackDeactivateSDNCRequest)
@@ -132,14 +130,14 @@ public class DoDeleteNetworkInstanceRollback extends AbstractServiceTaskProcesso
String sdncVersion = execution.getVariable("sdncVersion")
msoLogger.debug("sdncVersion? : " + sdncVersion)
-
+
// PO Authorization Info / headers Authorization=
String basicAuthValuePO = UrnPropertiesReader.getVariable("mso.adapters.po.auth",execution)
try {
def encodedString = utils.getBasicAuth(basicAuthValuePO, UrnPropertiesReader.getVariable("mso.msoKey", execution))
execution.setVariable("BasicAuthHeaderValuePO",encodedString)
execution.setVariable("BasicAuthHeaderValueSDNC", encodedString)
-
+
} catch (IOException ex) {
String exceptionMessage = "Exception Encountered in DoCreateNetworkInstance, PreProcessRequest() - "
String dataErrorMessage = exceptionMessage + " Unable to encode PO/SDNC user/password string - " + ex.getMessage()
@@ -160,31 +158,31 @@ public class DoDeleteNetworkInstanceRollback extends AbstractServiceTaskProcesso
} else {
// called by: Macro - Full Rollback, WorkflowException = null
execution.setVariable(Prefix + "fullRollback", true)
-
+
}
-
+
msoLogger.debug("*** fullRollback? : " + execution.getVariable(Prefix + "fullRollback"))
-
+
} catch (BpmnError e) {
throw e;
-
+
} catch (Exception ex) {
sendSyncError(execution)
// caught exception
String exceptionMessage = "Exception Encountered in PreProcessRequest() of " + className + ".groovy ***** : " + ex.getMessage()
msoLogger.debug(exceptionMessage)
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
-
+
}
}
-
+
public void validateRollbackResponses (DelegateExecution execution) {
execution.setVariable("prefix",Prefix)
msoLogger.trace("Inside validateRollbackResponses() of DoDeleteNetworkInstanceRollback ")
-
+
try {
// validate SDNC activate response
@@ -212,7 +210,7 @@ public class DoDeleteNetworkInstanceRollback extends AbstractServiceTaskProcesso
msoLogger.debug(" SDNC deactivate rollback Code - " + rollbackDeactivateSDNCReturnCode)
msoLogger.debug(" SDNC deactivate rollback Response - " + rollbackDeactivateSDNCResponse)
}
-
+
// validate SDNC rollback response
String rollbackSdncErrorMessages = ""
String rollbackSDNCReturnCode = "200"
@@ -239,7 +237,7 @@ public class DoDeleteNetworkInstanceRollback extends AbstractServiceTaskProcesso
msoLogger.debug(" SDNC assign rollback Code - " + rollbackSDNCReturnCode)
msoLogger.debug(" SDNC assign rollback Response - " + rollbackSDNCResponse)
}
-
+
// validate PO network rollback response
String rollbackNetworkErrorMessages = ""
String rollbackNetworkReturnCode = "200"
@@ -251,11 +249,11 @@ public class DoDeleteNetworkInstanceRollback extends AbstractServiceTaskProcesso
} else {
rollbackNetworkErrorMessages = " + PO Network rollback completed."
}
-
+
msoLogger.debug(" NetworkRollback Code - " + rollbackNetworkReturnCode)
msoLogger.debug(" NetworkRollback Response - " + rollbackNetworkResponse)
}
-
+
String statusMessage = ""
int errorCode = 7000
msoLogger.debug("*** fullRollback? : " + execution.getVariable(Prefix + "fullRollback"))
@@ -273,7 +271,7 @@ public class DoDeleteNetworkInstanceRollback extends AbstractServiceTaskProcesso
if (rollbackDeactivateSDNCReturnCode == "200" && rollbackNetworkReturnCode == "200" && rollbackSDNCReturnCode == "200") {
execution.setVariable("rolledBack", true)
execution.setVariable("wasDeleted", true)
-
+
} else {
execution.setVariable("rolledBack", false)
execution.setVariable("wasDeleted", true)
@@ -284,12 +282,12 @@ public class DoDeleteNetworkInstanceRollback extends AbstractServiceTaskProcesso
String processKey = getProcessKey(execution);
WorkflowException exception = new WorkflowException(processKey, errorCode, statusMessage);
execution.setVariable("workflowException", exception);
-
+
} else {
// rollback due to failures in Main flow (Macro or a-ala-carte) - Full rollback
if (rollbackDeactivateSDNCReturnCode == "200" && rollbackNetworkReturnCode == "200" && rollbackSDNCReturnCode == "200") {
execution.setVariable("rollbackSuccessful", true)
- execution.setVariable("rollbackError", false)
+ execution.setVariable("rollbackError", false)
} else {
String exceptionMessage = "Network Delete Rollback was not Successful. "
msoLogger.debug(exceptionMessage)
@@ -297,9 +295,9 @@ public class DoDeleteNetworkInstanceRollback extends AbstractServiceTaskProcesso
execution.setVariable("rollbackError", true)
exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage)
throw new BpmnError("MSOWorkflowException")
- }
- }
-
+ }
+ }
+
} catch (Exception ex) {
String errorMessage = "See Previous Camunda flows for cause of Error: Undetermined Exception."
String exceptionMessage = " Bpmn error encountered in DoDeleteNetworkInstanceRollback flow. validateRollbackResponses() - " + errorMessage + ": " + ex.getMessage()
@@ -315,18 +313,18 @@ public class DoDeleteNetworkInstanceRollback extends AbstractServiceTaskProcesso
// *******************************
-
+
public void processJavaException(DelegateExecution execution){
execution.setVariable("prefix",Prefix)
-
+
try{
msoLogger.debug("Caught a Java Exception in " + Prefix)
msoLogger.debug("Started processJavaException Method")
msoLogger.debug("Variables List: " + execution.getVariables())
execution.setVariable("UnexpectedError", "Caught a Java Lang Exception - " + Prefix) // Adding this line temporarily until this flows error handling gets updated
exceptionUtil.buildWorkflowException(execution, 500, "Caught a Java Lang Exception")
-
+
}catch(Exception e){
msoLogger.debug("Caught Exception during processJavaException Method: " + e)
execution.setVariable("UnexpectedError", "Exception in processJavaException method - " + Prefix) // Adding this line temporarily until this flows error handling gets updated
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstance.groovy
index da2d14f060..d855479694 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstance.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.
@@ -25,15 +25,15 @@ import org.camunda.bpm.engine.delegate.DelegateExecution
import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
import org.onap.so.bpmn.common.scripts.ExceptionUtil
import org.onap.so.bpmn.core.json.JsonUtils
+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.logger.MessageEnum
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 javax.ws.rs.core.Response
/**
* This groovy class supports the <class>DoDeleteVFCNetworkServiceInstance.bpmn</class> process.
* flow for E2E ServiceInstance Delete
@@ -41,11 +41,11 @@ import org.onap.so.rest.RESTConfig
public class DoDeleteVFCNetworkServiceInstance extends AbstractServiceTaskProcessor {
private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoDeleteVFCNetworkServiceInstance.class);
-
+
String vfcUrl = "/vfc/rest/v1/vfcadapter"
-
+
String host = "http://mso.mso.testlab.openecomp.org:8080"
-
+
ExceptionUtil exceptionUtil = new ExceptionUtil()
JsonUtils jsonUtil = new JsonUtils()
@@ -124,16 +124,15 @@ public class DoDeleteVFCNetworkServiceInstance extends AbstractServiceTaskProces
msoLogger.trace("deleteNetworkService start ")
String nsOperationKey = execution.getVariable("nsOperationKey");
- String url = host + vfcUrl + "/ns/" + execution.getVariable("nsInstanceId")
- APIResponse apiResponse = deleteRequest(execution, url, nsOperationKey)
- String returnCode = apiResponse.getStatusCode()
- String apiResponseAsString = apiResponse.getResponseBodyAsString()
+ String url = host + vfcUrl + "/ns/" + execution.getVariable("nsInstanceId")
+ Response apiResponse = deleteRequest(execution, url, nsOperationKey)
+ String returnCode = apiResponse.getStatus()
String operationStatus = "error";
if(returnCode== "200" || returnCode== "202"){
operationStatus = "finished"
}
execution.setVariable("operationStatus", operationStatus)
-
+
msoLogger.trace("deleteNetworkService end ")
}
@@ -143,16 +142,16 @@ public class DoDeleteVFCNetworkServiceInstance extends AbstractServiceTaskProces
public void terminateNetworkService(DelegateExecution execution) {
msoLogger.trace("terminateNetworkService start ")
- String nsOperationKey = execution.getVariable("nsOperationKey")
+ String nsOperationKey = execution.getVariable("nsOperationKey")
String url = host + vfcUrl + "/ns/" + execution.getVariable("nsInstanceId") + "/terminate"
- APIResponse apiResponse = postRequest(execution, url, nsOperationKey)
- String returnCode = apiResponse.getStatusCode()
- String aaiResponseAsString = apiResponse.getResponseBodyAsString()
+ Response apiResponse = postRequest(execution, url, nsOperationKey)
+ String returnCode = apiResponse.getStatus()
+ String aaiResponseAsString = apiResponse.readEntity(String.class)
String jobId = "";
if(returnCode== "200" || returnCode== "202"){
jobId = jsonUtil.getJsonValue(aaiResponseAsString, "jobId")
}
- execution.setVariable("jobId", jobId)
+ execution.setVariable("jobId", jobId)
msoLogger.trace("terminateNetworkService end ")
}
@@ -164,10 +163,10 @@ public class DoDeleteVFCNetworkServiceInstance extends AbstractServiceTaskProces
msoLogger.trace("queryNSProgress start ")
String jobId = execution.getVariable("jobId")
String nsOperationKey = execution.getVariable("nsOperationKey");
- String url = host + vfcUrl + "/jobs/" + execution.getVariable("jobId")
- APIResponse apiResponse = postRequest(execution, url, nsOperationKey)
- String returnCode = apiResponse.getStatusCode()
- String apiResponseAsString = apiResponse.getResponseBodyAsString()
+ String url = host + vfcUrl + "/jobs/" + execution.getVariable("jobId")
+ Response apiResponse = postRequest(execution, url, nsOperationKey)
+ String returnCode = apiResponse.getStatus()
+ String apiResponseAsString = apiResponse.readEntity(String.class)
String operationProgress = "100"
if(returnCode== "200"){
operationProgress = jsonUtil.getJsonValue(apiResponseAsString, "responseDescriptor.progress")
@@ -177,12 +176,12 @@ public class DoDeleteVFCNetworkServiceInstance extends AbstractServiceTaskProces
}
/**
- * delay 5 sec
+ * delay 5 sec
*/
public void timeDelay(DelegateExecution execution) {
try {
Thread.sleep(5000);
- } catch(InterruptedException e) {
+ } catch(InterruptedException e) {
msoLogger.info("Time Delay exception" + e)
}
}
@@ -199,21 +198,27 @@ public class DoDeleteVFCNetworkServiceInstance extends AbstractServiceTaskProces
* url: the url of the request
* requestBody: the body of the request
*/
- private APIResponse postRequest(DelegateExecution execution, String url, String requestBody){
+ private Response postRequest(DelegateExecution execution, String urlString, String requestBody){
- msoLogger.trace("Started Execute VFC adapter Post Process ")
- msoLogger.info("url:"+url +"\nrequestBody:"+ requestBody)
- APIResponse apiResponse = null
- try{
- RESTConfig config = new RESTConfig(url);
- RESTClient client = new RESTClient(config).addHeader("Content-Type", "application/json").addHeader("Accept","application/json").addHeader("Authorization","Basic QlBFTENsaWVudDpwYXNzd29yZDEk");;
- apiResponse = client.httpPost(requestBody)
- msoLogger.info("response code:"+ apiResponse.getStatusCode() +"\nresponse body:"+ apiResponse.getResponseBodyAsString())
- msoLogger.trace("Completed Execute VF-C adapter Post Process ")
- }catch(Exception e){
+ msoLogger.trace("Started Execute VFC adapter Post Process ")
+ msoLogger.info("url:"+urlString +"\nrequestBody:"+ requestBody)
+ Response apiResponse = null
+ try{
+ URL url = new URL(urlString);
+
+ HttpClient httpClient = new HttpClient(url, "application/json", TargetEntity.VNF_ADAPTER)
+ httpClient.addAdditionalHeader("Accept", "application/json")
+ httpClient.addAdditionalHeader("Authorization", "Basic QlBFTENsaWVudDpwYXNzd29yZDEk")
+
+ apiResponse = httpClient.post(requestBody)
+
+ msoLogger.debug("response code:"+ apiResponse.getStatus() +"\nresponse body:"+ apiResponse.readEntity(String.class))
+
+ msoLogger.trace("Completed Execute VF-C adapter Post Process ")
+ }catch(Exception e){
msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception occured while executing VF-C Post Call. Exception is: \n" + e, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
throw new BpmnError("MSOWorkflowException")
- }
+ }
return apiResponse
}
/**
@@ -221,21 +226,24 @@ public class DoDeleteVFCNetworkServiceInstance extends AbstractServiceTaskProces
* url: the url of the request
* requestBody: the body of the request
*/
- private APIResponse deleteRequest(DelegateExecution execution, String url, String requestBody){
+ private Response deleteRequest(DelegateExecution execution, String url, String requestBody){
- msoLogger.trace("Started Execute VFC adapter Delete Process ")
+ msoLogger.trace("Started Execute VFC adapter Delete Process ")
msoLogger.info("url:"+url +"\nrequestBody:"+ requestBody)
- APIResponse apiResponse = null
+ Response r
try{
- RESTConfig config = new RESTConfig(url);
- RESTClient client = new RESTClient(config).addHeader("Content-Type", "application/json").addHeader("Accept","application/json").addHeader("Authorization","Basic QlBFTENsaWVudDpwYXNzd29yZDEk");
- apiResponse = client.httpDelete(requestBody)
- msoLogger.info("response code:"+ apiResponse.getStatusCode() +"\nresponse body:"+ apiResponse.getResponseBodyAsString())
- msoLogger.trace("Completed Execute VF-C adapter Delete Process ")
+
+ URL Url = new URL(url)
+ HttpClient httpClient = new HttpClient(Url, "application/json", TargetEntity.VNF_ADAPTER)
+ httpClient.addAdditionalHeader("Accept", "application/json")
+ httpClient.addAdditionalHeader("Authorization", "Basic QlBFTENsaWVudDpwYXNzd29yZDEk")
+ r = httpClient.delete(requestBody)
+
+ msoLogger.trace("Completed Execute VF-C adapter Delete Process ")
}catch(Exception e){
- msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception occured while executing VF-C Post Call. Exception is: \n" + e, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
+ msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception occured while executing VF-C Post Call. Exception is: \n" + e, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
throw new BpmnError("MSOWorkflowException")
- }
- return apiResponse
+ }
+ return r
}
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy
index d6ca08d816..3bc481ab01 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModule.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.
@@ -43,9 +43,6 @@ import org.onap.so.client.aai.entities.uri.AAIResourceUri
import org.onap.so.client.aai.entities.uri.AAIUriFactory
import org.onap.so.logger.MessageEnum
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.springframework.web.util.UriUtils
import org.w3c.dom.Document
import org.w3c.dom.Element
@@ -66,7 +63,7 @@ import org.xml.sax.InputSource
* @param - vfModuleModelInfo
* @param - cloudConfiguration*
* @param - sdncVersion ("1610")
-* @param - retainResources
+* @param - retainResources
* @param - aLaCarte
*
* Outputs:
@@ -133,11 +130,11 @@ public class DoDeleteVfModule extends AbstractServiceTaskProcessor{
def vfModuleModelName = jsonUtil.getJsonValue(vfModuleModelInfo, "modelName")
execution.setVariable("vfModuleModelName", vfModuleModelName)
// retainResources
- def retainResources = execution.getVariable("retainResources")
+ def retainResources = execution.getVariable("retainResources")
if (retainResources == null) {
retainResources = false
}
- execution.setVariable("retainResources", retainResources)
+ execution.setVariable("retainResources", retainResources)
}
else {
@@ -206,7 +203,7 @@ public class DoDeleteVfModule extends AbstractServiceTaskProcessor{
if(uuid==null){
uuid = execution.getVariable("requestId") + "-" + System.currentTimeMillis()
}
-
+
def srvInstId = execution.getVariable("srvInstId")
def callbackUrl = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution)
String requestId = execution.getVariable("requestId")
@@ -229,7 +226,7 @@ public class DoDeleteVfModule extends AbstractServiceTaskProcessor{
boolean retainResources = execution.getVariable("retainResources")
String requestSubActionString = ""
if (retainResources) {
- requestSubActionString = "<request-sub-action>RetainResource</request-sub-action>"
+ requestSubActionString = "<request-sub-action>RetainResource</request-sub-action>"
}
String request = """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.onap/so/request/types/v1"
xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
@@ -578,7 +575,7 @@ public class DoDeleteVfModule extends AbstractServiceTaskProcessor{
exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIGenericVnf(): ' + e.getMessage())
}
}
-
+
/**
* Using the vnfId and vfModuleId provided in the inputs,
* query AAI to get the corresponding VF Module info.
@@ -593,7 +590,7 @@ public class DoDeleteVfModule extends AbstractServiceTaskProcessor{
'execution=' + execution.getId() +
')'
msoLogger.trace('Entered ' + method)
-
+
execution.setVariable(Prefix + 'orchestrationStatus', '')
try {
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleVFCNetworkServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleVFCNetworkServiceInstance.groovy
index e06e5238c6..a99f6e993e 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleVFCNetworkServiceInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleVFCNetworkServiceInstance.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.
@@ -31,12 +31,10 @@ import org.onap.so.bpmn.core.json.JsonUtils
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.runtime.Execution
import com.fasterxml.jackson.databind.ObjectMapper
-
-import org.onap.so.rest.RESTClient
-import org.onap.so.rest.RESTConfig
-import org.onap.so.rest.APIResponse;
+import javax.ws.rs.core.Response
import org.onap.so.bpmn.infrastructure.vfcmodel.ScaleResource
+import org.onap.so.client.HttpClient
import org.onap.so.bpmn.infrastructure.vfcmodel.ScaleNsByStepsData
import org.onap.so.bpmn.infrastructure.vfcmodel.ScaleNsData
@@ -47,6 +45,7 @@ import org.onap.so.bpmn.infrastructure.vfcmodel.NsParameters
import org.onap.so.bpmn.infrastructure.vfcmodel.LocationConstraint
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
+import org.onap.so.utils.TargetEntity
@@ -114,10 +113,10 @@ public class DoScaleVFCNetworkServiceInstance extends AbstractServiceTaskProcess
String url = host + scaleUrl.replaceAll("\\{nsInstanceId\\}", nsInstanceId)
- APIResponse apiResponse = postRequest(execution, url, reqBody)
+ Response apiResponse = postRequest(execution, url, reqBody)
- String returnCode = apiResponse.getStatusCode()
- String aaiResponseAsString = apiResponse.getResponseBodyAsString()
+ String returnCode = apiResponse.getStatus()
+ String aaiResponseAsString = apiResponse.readEntity(String.class)
String jobId = ""
if (returnCode == "200" || returnCode == "202") {
jobId = jsonUtil.getJsonValue(aaiResponseAsString, "jobId")
@@ -156,10 +155,10 @@ public class DoScaleVFCNetworkServiceInstance extends AbstractServiceTaskProcess
nsOperationKey.setOperationId(execution.getVariable("operationId"))
String queryReqBody = objectToJsonStr(nsOperationKey)
- APIResponse apiResponse = postRequest(execution,url, queryReqBody)
+ Response apiResponse = postRequest(execution,url, queryReqBody)
- String returnCode = apiResponse.getStatusCode()
- String aaiResponseAsString = apiResponse.getResponseBodyAsString()
+ String returnCode = apiResponse.getStatus()
+ String aaiResponseAsString = apiResponse.readEntity(String.class)
String operationStatus = "error"
@@ -195,16 +194,19 @@ public class DoScaleVFCNetworkServiceInstance extends AbstractServiceTaskProcess
* url: the url of the request
* requestBody: the body of the request
*/
- private APIResponse postRequest(DelegateExecution execution, String url, String requestBody){
+ private Response postRequest(DelegateExecution execution, String urlString, String requestBody){
msoLogger.trace("Started Execute VFC adapter Post Process ")
- msoLogger.info("url:"+url +"\nrequestBody:"+ requestBody)
- APIResponse apiResponse = null
+ msoLogger.info("url:"+urlString +"\nrequestBody:"+ requestBody)
+ Response apiResponse = null
try{
- RESTConfig config = new RESTConfig(url)
- RESTClient client = new RESTClient(config).addHeader("Content-Type", "application/json").addHeader("Authorization","Basic QlBFTENsaWVudDpwYXNzd29yZDEk")
-// RESTClient client = new RESTClient(config).addHeader("Content-Type", "application/json").addHeader("Accept","application/json").addHeader("Authorization","Basic QlBFTENsaWVudDpwYXNzd29yZDEk")
- apiResponse = client.httpPost(requestBody)
- msoLogger.info("response code:"+ apiResponse.getStatusCode() +"\nresponse body:"+ apiResponse.getResponseBodyAsString())
+ URL url = new URL(urlString);
+
+ HttpClient httpClient = new HttpClient(url, "application/json", TargetEntity.VNF_ADAPTER)
+ httpClient.addAdditionalHeader("Authorization", "Basic QlBFTENsaWVudDpwYXNzd29yZDEk")
+
+ apiResponse = httpClient.post(requestBody)
+
+ msoLogger.info("response code:"+ apiResponse.getStatus() +"\nresponse body:"+ apiResponse.readEntity(String.class))
msoLogger.trace("Completed Execute VF-C adapter Post Process ")
}catch(Exception e){
msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception occured while executing VFC Post Call.", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e);
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy
index dbacd48809..cc301db4cd 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy
@@ -21,7 +21,8 @@
package org.onap.so.bpmn.infrastructure.scripts;
import javax.ws.rs.core.UriBuilder
-
+import javax.xml.parsers.DocumentBuilder
+import javax.xml.parsers.DocumentBuilderFactory
import org.apache.commons.lang3.*
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
@@ -43,10 +44,20 @@ import org.onap.so.client.aai.entities.AAIResultWrapper
import org.onap.so.client.graphinventory.entities.uri.Depth
import org.onap.so.constants.Defaults
import org.onap.so.logger.MsoLogger
-import org.onap.so.rest.APIResponse
+
import org.springframework.web.util.UriUtils
+import org.w3c.dom.Document
+import org.w3c.dom.Element
+import org.w3c.dom.NamedNodeMap
+import org.w3c.dom.Node
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource
import org.onap.aai.domain.yang.VpnBinding
+import org.onap.aai.domain.yang.L3Network
+import org.onap.aai.domain.yang.NetworkPolicy
+import org.onap.aai.domain.yang.RouteTableReference
import org.onap.aai.domain.yang.RouteTarget
+import org.onap.aai.domain.yang.Subnet
import javax.ws.rs.NotFoundException
import groovy.json.*
@@ -405,56 +416,21 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor {
// get variables
String networkRequest = execution.getVariable(Prefix + "networkRequest")
String networkId = utils.getNodeText(networkRequest, "network-id")
- networkId = UriUtils.encode(networkId,"UTF-8")
execution.setVariable(Prefix + "networkId", networkId)
- // Prepare AA&I url
- AaiUtil aaiUriUtil = new AaiUtil(this)
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId)
- uri.depth(Depth.ALL)
- String queryIdAAIRequest = aaiUriUtil.createAaiUri(uri)
-
- msoLogger.debug(queryIdAAIRequest)
- execution.setVariable(Prefix + "queryIdAAIRequest", queryIdAAIRequest)
- msoLogger.debug(Prefix + "queryIdAAIRequest - " + "\n" + queryIdAAIRequest)
-
- APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryIdAAIRequest)
- String returnCode = response.getStatusCode()
- execution.setVariable(Prefix + "aaiIdReturnCode", returnCode)
- msoLogger.debug(" ***** AAI Response Code : " + returnCode)
-
- String aaiResponseAsString = response.getResponseBodyAsString()
+ AAIResourcesClient client = new AAIResourcesClient()
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId).depth(Depth.ONE)
+ AAIResultWrapper network = client.get(uri, NotFoundException.class)
- if (returnCode=='200') {
- msoLogger.debug(aaiResponseAsString)
- execution.setVariable(Prefix + "queryIdAAIResponse", aaiResponseAsString)
- msoLogger.debug(" QueryAAINetworkId Success REST Response - " + "\n" + aaiResponseAsString)
+ execution.setVariable(Prefix + "aaiIdReturnCode", "200")
- } else {
- if (returnCode=='404') {
- String dataErrorMessage = "Response Error from QueryAAINetworkId is 404 (Not Found)."
- msoLogger.debug(" AAI Query Failed. " + dataErrorMessage)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
+ execution.setVariable(Prefix + "queryIdAAIResponse", network)
- } else {
- if (aaiResponseAsString.contains("RESTFault")) {
- WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
- execution.setVariable("WorkflowException", exceptionObject)
- throw new BpmnError("MSOWorkflowException")
-
- } else {
- // aai all errors
- String dataErrorMessage = "Unexpected Response from QueryAAINetworkId - " + returnCode
- msoLogger.debug("Unexpected Response from QueryAAINetworkId - " + dataErrorMessage)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
-
- }
- }
- }
-
- } catch (BpmnError e) {
- throw e;
+ } catch (NotFoundException e) {
+ String dataErrorMessage = "Response Error from QueryAAINetworkId is 404 (Not Found)."
+ msoLogger.debug(" AAI Query Failed. " + dataErrorMessage)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
} catch (Exception ex) {
String exceptionMessage = "Bpmn error encountered in DoUpdateNetworkInstance flow. callRESTQueryAAINetworkId() - " + ex.getMessage()
msoLogger.debug(exceptionMessage)
@@ -474,65 +450,29 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor {
// get variables
String networkRequest = execution.getVariable(Prefix + "networkRequest")
String networkId = utils.getNodeText(networkRequest, "network-id")
- networkId = UriUtils.encode(networkId,"UTF-8")
-
- // Prepare AA&I url
- AaiUtil aaiUriUtil = new AaiUtil(this)
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId)
- uri.depth(Depth.ALL)
- String requeryIdAAIRequest = aaiUriUtil.createAaiUri(uri)
-
- msoLogger.debug(requeryIdAAIRequest)
- execution.setVariable(Prefix + "requeryIdAAIRequest", requeryIdAAIRequest)
- msoLogger.debug(" UPDNETI_requeryIdAAIRequest - " + "\n" + requeryIdAAIRequest)
-
- APIResponse response = aaiUriUtil.executeAAIGetCall(execution, requeryIdAAIRequest)
- String returnCode = response.getStatusCode()
- execution.setVariable(Prefix + "aaiRequeryIdReturnCode", returnCode)
- msoLogger.debug(" ***** AAI ReQuery Response Code : " + returnCode)
- String aaiResponseAsString = response.getResponseBodyAsString()
+ AAIResourcesClient client = new AAIResourcesClient()
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId).depth(Depth.ONE)
+ AAIResultWrapper network = client.get(uri, NotFoundException.class)
- if (returnCode=='200') {
- msoLogger.debug(aaiResponseAsString)
- execution.setVariable(Prefix + "requeryIdAAIResponse", aaiResponseAsString)
- msoLogger.debug(" ReQueryAAINetworkId Success REST Response - " + "\n" + aaiResponseAsString)
+ execution.setVariable(Prefix + "aaiRequeryIdReturnCode", "200")
+ execution.setVariable(Prefix + "requeryIdAAIResponse", network)
- String netId = utils.getNodeText(aaiResponseAsString, "network-id")
- String netName = utils.getNodeText(aaiResponseAsString, "network-name")
- String networkOutputs =
- """<network-outputs>
+ L3Network net = network.asBean(L3Network.class).get()
+ String netId = net.getNetworkId()
+ String netName = net.getNetworkName()
+ String networkOutputs =
+ """<network-outputs>
<network-id>${MsoUtils.xmlEscape(netId)}</network-id>
<network-name>${MsoUtils.xmlEscape(netName)}</network-name>
</network-outputs>"""
- execution.setVariable(Prefix + "networkOutputs", networkOutputs)
- msoLogger.debug(" networkOutputs - " + '\n' + networkOutputs)
-
- } else {
- if (returnCode=='404') {
- String dataErrorMessage = "Response Error from ReQueryAAINetworkId is 404 (Not Found)."
- msoLogger.debug(" AAI ReQuery Failed. - " + dataErrorMessage)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
-
- } else {
- if (aaiResponseAsString.contains("RESTFault")) {
- WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
- execution.setVariable("WorkflowException", exceptionObject)
- throw new BpmnError("MSOWorkflowException")
-
- } else {
- // aai all errors
- String dataErrorMessage = "Unexpected Response from ReQueryAAINetworkId - " + returnCode
- msoLogger.debug(dataErrorMessage)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
-
- }
- }
- }
-
- } catch (BpmnError e) {
- throw e;
+ execution.setVariable(Prefix + "networkOutputs", networkOutputs)
+ msoLogger.debug(" networkOutputs - " + '\n' + networkOutputs)
+ } catch (NotFoundException e) {
+ String dataErrorMessage = "Response Error from ReQueryAAINetworkId is 404 (Not Found)."
+ msoLogger.debug(" AAI ReQuery Failed. - " + dataErrorMessage)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
} catch (Exception ex) {
String exceptionMessage = "Bpmn error encountered in DoUpdateNetworkInstance flow. callRESTReQueryAAINetworkId() - " + ex.getMessage()
msoLogger.debug(exceptionMessage)
@@ -551,71 +491,56 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor {
try {
// get variables
- String queryIdAAIResponse = execution.getVariable(Prefix + "requeryIdAAIResponse").replace('<?xml version="1.0" encoding="UTF-8"?>', "")
- String relationship = networkUtils.getFirstNodeXml(queryIdAAIResponse, "relationship-list").trim().replace("tag0:","").replace(":tag0","")
- msoLogger.debug(" relationship - " + relationship)
-
- // Check if Vnf Binding is present, then build a List of vnfBinding
- List vpnBindingUri = networkUtils.getVnfBindingObject(relationship)
- int vpnCount = vpnBindingUri.size()
- execution.setVariable(Prefix + "vpnCount", vpnCount)
- msoLogger.debug(" UPDNETI_vpnCount - " + vpnCount)
-
- if (vpnCount > 0) {
- execution.setVariable(Prefix + "vpnBindings", vpnBindingUri)
- msoLogger.debug(" vpnBindingUri List - " + vpnBindingUri)
-
- String routeTargets = ""
- // AII loop call using list vpnBindings
- for(i in 0..vpnBindingUri.size()-1) {
- int counting = i+1
-
- String vpnBindingId = vpnBindingUri[i].substring(vpnBindingUri[i].indexOf("/vpn-binding/")+13, vpnBindingUri[i].length())
- if (vpnBindingId.charAt(vpnBindingId.length()-1) == '/') {
- vpnBindingId = vpnBindingId.substring(0, vpnBindingId.length()-1)
- }
-
- AAIResourcesClient resourceClient = new AAIResourcesClient()
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VPN_BINDING, vpnBindingId)
- AAIResultWrapper wrapper = resourceClient.get(uri.depth(Depth.TWO), NotFoundException.class)
-
- Optional<VpnBinding> binding = wrapper.asBean(VpnBinding.class)
-
- String routeTarget = ""
- String routeRole = ""
- if(binding.get().getRouteTargets() != null) {
- List<RouteTarget> targets = binding.get().getRouteTargets().getRouteTarget()
- for(RouteTarget target : targets) {
- routeTarget = target.getGlobalRouteTarget()
- routeRole = target.getRouteTargetRole()
- routeTargets += "<routeTargets>" + '\n' +
- " <routeTarget>" + routeTarget + "</routeTarget>" + '\n' +
- " <routeTargetRole>" + routeRole + "</routeTargetRole>" + '\n' +
- "</routeTargets>" + '\n'
+ AAIResultWrapper queryIdAAIResponse = execution.getVariable(Prefix + "requeryIdAAIResponse")
+ if(queryIdAAIResponse.getRelationships().isPresent()){
+ List<AAIResourceUri> uris = queryIdAAIResponse.getRelationships().get().getRelatedAAIUris(AAIObjectType.VPN_BINDING)
+
+ msoLogger.debug(Prefix + "vpnCount - " + uris.size())
+
+ if (uris.size() > 0) {
+ String routeTargets = ""
+ for(AAIResourceUri u : uris) {
+
+ AAIResourcesClient client = new AAIResourcesClient()
+ AAIResultWrapper wrapper = client.get(u.depth(Depth.TWO), NotFoundException.class)
+ Optional<VpnBinding> binding = wrapper.asBean(VpnBinding.class)
+
+ String routeTarget = ""
+ String routeRole = ""
+ if(binding.get().getRouteTargets() != null) {
+ List<RouteTarget> targets = binding.get().getRouteTargets().getRouteTarget()
+ for(RouteTarget target : targets) {
+ routeTarget = target.getGlobalRouteTarget()
+ routeRole = target.getRouteTargetRole()
+ routeTargets += "<routeTargets>" + '\n' +
+ " <routeTarget>" + routeTarget + "</routeTarget>" + '\n' +
+ " <routeTargetRole>" + routeRole + "</routeTargetRole>" + '\n' +
+ "</routeTargets>" + '\n'
+ }
}
- }
- } // end loop
+ } // end loop
- execution.setVariable(Prefix + "routeCollection", routeTargets)
- msoLogger.debug(" UPDNETI_routeCollection - " + '\n' + routeTargets)
+ execution.setVariable(Prefix + "routeCollection", routeTargets)
+ msoLogger.debug(" UPDNETI_routeCollection - " + '\n' + routeTargets)
- } else {
- // reset return code to success
- execution.setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", "200")
- AaiUtil aaiUriUtil = new AaiUtil(this)
- String schemaVersion = aaiUriUtil.getNamespace()
- String aaiStubResponse =
- """ <rest:payload contentType="text/xml" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd">
+ } else {
+ // reset return code to success
+ execution.setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", "200")
+ AaiUtil aaiUriUtil = new AaiUtil(this)
+ String schemaVersion = aaiUriUtil.getNamespace()
+ String aaiStubResponse =
+ """ <rest:payload contentType="text/xml" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd">
<vpn-binding xmlns="${schemaVersion}">
<global-route-target/>
</vpn-binding>
</rest:payload>"""
- String aaiStubResponseAsXml = utils.formatXml(aaiStubResponse)
- execution.setVariable(Prefix + "queryVpnBindingAAIResponse", aaiStubResponseAsXml)
- execution.setVariable(Prefix + "routeCollection", "<routeTargets/>")
- msoLogger.debug(" No vpnBinding, using this stub as response - " + '\n' + aaiStubResponseAsXml)
+ String aaiStubResponseAsXml = utils.formatXml(aaiStubResponse)
+ execution.setVariable(Prefix + "queryVpnBindingAAIResponse", aaiStubResponseAsXml)
+ execution.setVariable(Prefix + "routeCollection", "<routeTargets/>")
+ msoLogger.debug(" No vpnBinding, using this stub as response - " + '\n' + aaiStubResponseAsXml)
+ }
}
} catch (NotFoundException e) {
@@ -638,103 +563,55 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor {
try {
// get variables
- String queryIdAAIResponse = execution.getVariable(Prefix + "requeryIdAAIResponse").replace('<?xml version="1.0" encoding="UTF-8"?>', "")
- String relationship = networkUtils.getFirstNodeXml(queryIdAAIResponse, "relationship-list").trim().replace("tag0:","").replace(":tag0","")
- msoLogger.debug(" relationship - " + relationship)
-
- // Check if Network Policy is present, then build a List of network policy
- List networkPolicyUriList = networkUtils.getNetworkPolicyObject(relationship)
- int networkPolicyCount = networkPolicyUriList.size()
- execution.setVariable(Prefix + "networkPolicyCount", networkPolicyCount)
- msoLogger.debug(" UPDNETI_networkPolicyCount - " + networkPolicyCount)
-
- AaiUtil aaiUriUtil = new AaiUtil(this)
+ AAIResultWrapper queryIdAAIResponse = execution.getVariable(Prefix + "requeryIdAAIResponse")
+ if(queryIdAAIResponse.getRelationships().isPresent()){
+ List<AAIResourceUri> uris = queryIdAAIResponse.getRelationships().get().getRelatedAAIUris(AAIObjectType.NETWORK_POLICY)
- if (networkPolicyCount > 0) {
- execution.setVariable(Prefix + "networkPolicyUriList", networkPolicyUriList)
- msoLogger.debug(" networkPolicyUri List - " + networkPolicyUriList)
+ execution.setVariable(Prefix + "networkPolicyCount", uris.size())
+ msoLogger.debug(Prefix + "networkPolicyCount - " + uris.size())
- String networkPolicies = ""
- // AII loop call using list vpnBindings
- for (i in 0..networkPolicyUriList.size()-1) {
+ if (uris.size() > 0) {
- int counting = i+1
+ String networkPolicies = ""
+ // AII loop call using list vpnBindings
+ for(AAIResourceUri u : uris) {
- URI uri = UriBuilder.fromUri(networkPolicyUriList[i]).build()
+ AAIResourcesClient client = new AAIResourcesClient()
+ NetworkPolicy p = client.get(u, NotFoundException.class).asBean(NetworkPolicy.class).get()
- AAIResourceUri aaiUri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.NETWORK_POLICY, uri)
- aaiUri.depth(Depth.ALL)
- String queryNetworkPolicyAAIRequest = aaiUriUtil.createAaiUri(aaiUri)
+ execution.setVariable(Prefix + "aaiQqueryNetworkPolicyReturnCode", "200")
- msoLogger.debug(queryNetworkPolicyAAIRequest)
- execution.setVariable(Prefix + "queryNetworkPolicyAAIRequest", queryNetworkPolicyAAIRequest)
- msoLogger.debug(" UPDNETI_queryNetworkPolicyAAIRequest, , NetworkPolicy #" + counting + " : " + "\n" + queryNetworkPolicyAAIRequest)
+ String networkPolicy = p.getNetworkPolicyFqdn()
+ networkPolicies += "<policyFqdns>" + networkPolicy + "</policyFqdns>" + '\n'
- APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryNetworkPolicyAAIRequest)
- String returnCode = response.getStatusCode()
- execution.setVariable(Prefix + "aaiQqueryNetworkPolicyReturnCode", returnCode)
- msoLogger.debug(" ***** AAI query network policy Response Code, NetworkPolicy #" + counting + " : " + returnCode)
+ } // end loop
- String aaiResponseAsString = response.getResponseBodyAsString()
-
- if (returnCode=='200') {
- msoLogger.debug(aaiResponseAsString)
- execution.setVariable(Prefix + "queryNetworkPolicyAAIResponse", aaiResponseAsString)
- msoLogger.debug(" QueryAAINetworkPolicy Success REST Response, , NetworkPolicy #" + counting + " : " + "\n" + aaiResponseAsString)
-
- String networkPolicy = ""
- if (utils.nodeExists(aaiResponseAsString, "network-policy-fqdn")) {
- networkPolicy = utils.getNodeText(aaiResponseAsString, "network-policy-fqdn")
- networkPolicies += "<policyFqdns>" + networkPolicy + "</policyFqdns>" + '\n'
- }
+ execution.setVariable(Prefix + "networkCollection", networkPolicies)
+ msoLogger.debug(" UPDNETI_networkCollection - " + '\n' + networkPolicies)
- } else {
- if (returnCode=='404') {
- String dataErrorMessage = "Response Error from QueryAAINetworkPolicy is 404 (Not Found)."
- msoLogger.debug(dataErrorMessage)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
-
- } else {
- if (aaiResponseAsString.contains("RESTFault")) {
- WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
- execution.setVariable("WorkflowException", exceptionObject)
- throw new BpmnError("MSOWorkflowException")
-
- } else {
- // aai all errors
- String dataErrorMessage = "Unexpected Response from QueryAAINetworkPolicy - " + returnCode
- msoLogger.debug(dataErrorMessage)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
-
- }
- }
- }
-
- } // end loop
-
- execution.setVariable(Prefix + "networkCollection", networkPolicies)
- msoLogger.debug(" UPDNETI_networkCollection - " + '\n' + networkPolicies)
-
- } else {
- // reset return code to success
- execution.setVariable(Prefix + "aaiQqueryNetworkPolicyReturnCode", "200")
- String schemaVersion = aaiUriUtil.getNamespace()
- String aaiStubResponse =
- """ <rest:payload contentType="text/xml" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd">
+ } else {
+ // reset return code to success
+ execution.setVariable(Prefix + "aaiQqueryNetworkPolicyReturnCode", "200")
+ AaiUtil aaiUriUtil = new AaiUtil(this)
+ String schemaVersion = aaiUriUtil.getNamespace()
+ String aaiStubResponse =
+ """ <rest:payload contentType="text/xml" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd">
<network-policy xmlns="${schemaVersion}">
<network-policy-fqdn/>
</network-policy>
</rest:payload>"""
- String aaiStubResponseAsXml = utils.formatXml(aaiStubResponse)
- execution.setVariable(Prefix + "queryNetworkPolicyAAIResponse", aaiStubResponseAsXml)
- execution.setVariable(Prefix + "networkCollection", "<policyFqdns/>")
- msoLogger.debug(" No net policies, using this stub as response - " + '\n' + aaiStubResponseAsXml)
+ String aaiStubResponseAsXml = utils.formatXml(aaiStubResponse)
+ execution.setVariable(Prefix + "queryNetworkPolicyAAIResponse", aaiStubResponseAsXml)
+ execution.setVariable(Prefix + "networkCollection", "<policyFqdns/>")
+ msoLogger.debug(" No net policies, using this stub as response - " + '\n' + aaiStubResponseAsXml)
+ }
}
- } catch (BpmnError e) {
- throw e;
-
+ } catch (NotFoundException e) {
+ String dataErrorMessage = "Response Error from QueryAAINetworkPolicy is 404 (Not Found)."
+ msoLogger.debug(dataErrorMessage)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
} catch (Exception ex) {
String exceptionMessage = "Bpmn error encountered in DoUpdateNetworkInstance flow. callRESTQueryAAINetworkPolicy() - " + ex.getMessage()
msoLogger.debug(exceptionMessage)
@@ -751,105 +628,56 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor {
msoLogger.debug(" ***** Inside callRESTQueryAAINetworkTableRef of DoUpdateNetworkInstance ***** " )
try {
- // get variables
- String queryIdAAIResponse = execution.getVariable(Prefix + "requeryIdAAIResponse").replace('<?xml version="1.0" encoding="UTF-8"?>', "")
- String relationship = networkUtils.getFirstNodeXml(queryIdAAIResponse, "relationship-list").trim().replace("tag0:","").replace(":tag0","")
- msoLogger.debug(" relationship - " + relationship)
+ AAIResultWrapper queryIdAAIResponse = execution.getVariable(Prefix + "requeryIdAAIResponse")
+ if(queryIdAAIResponse.getRelationships().isPresent()){
+ List<AAIResourceUri> uris = queryIdAAIResponse.getRelationships().get().getRelatedAAIUris(AAIObjectType.ROUTE_TABLE_REFERENCE)
- // Check if Network TableREf is present, then build a List of network policy
- List networkTableRefUriList = networkUtils.getNetworkTableRefObject(relationship)
- int networkTableRefCount = networkTableRefUriList.size()
- execution.setVariable(Prefix + "networkTableRefCount", networkTableRefCount)
- msoLogger.debug(" UPDNETI_networkTableRefCount - " + networkTableRefCount)
+ execution.setVariable(Prefix + "networkTableRefCount", uris.size())
+ msoLogger.debug(Prefix + "networkTableRefCount - " + uris.size())
- String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution)
- AaiUtil aaiUriUtil = new AaiUtil(this)
-
- if (networkTableRefCount > 0) {
- execution.setVariable(Prefix + "networkTableRefUriList", networkTableRefUriList)
- msoLogger.debug(" networkTableRefUri List - " + networkTableRefUriList)
-
- // AII loop call using list vpnBindings
- String networkTableRefs = ""
- for (i in 0..networkTableRefUriList.size()-1) {
-
- int counting = i+1
+ msoLogger.debug(" UPDNETI_networkTableRefCount - " + uris.size())
+ if (uris.size() > 0) {
- // prepare url using tableRef
- URI uri = UriBuilder.fromUri(networkTableRefUriList[i]).build()
+ execution.setVariable(Prefix + "aaiQqueryNetworkTableRefReturnCode", "200")
- AAIResourceUri aaiUri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.ROUTE_TABLE_REFERENCE, uri)
- aaiUri.depth(Depth.ALL)
- String queryNetworkTableRefAAIRequest = aaiUriUtil.createAaiUri(aaiUri)
+ // AII loop call using list vpnBindings
+ String networkTableRefs = ""
+ for(AAIResourceUri u : uris) {
- msoLogger.debug(queryNetworkTableRefAAIRequest)
- execution.setVariable(Prefix + "queryNetworkTableRefAAIRequest", queryNetworkTableRefAAIRequest)
- msoLogger.debug(" UPDNETI_queryNetworkTableRefAAIRequest, , NetworkTableRef #" + counting + " : " + "\n" + queryNetworkTableRefAAIRequest)
+ AAIResourcesClient client = new AAIResourcesClient()
+ RouteTableReference rt = client.get(u, NotFoundException.class).asBean(RouteTableReference.class).get()
- APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryNetworkTableRefAAIRequest)
- String returnCode = response.getStatusCode()
- execution.setVariable(Prefix + "aaiQqueryNetworkTableRefReturnCode", returnCode)
- msoLogger.debug(" ***** AAI query network Table Reference Response Code, NetworkTableRef #" + counting + " : " + returnCode)
+ String networkTableRef = rt.getRouteTableReferenceFqdn()
+ networkTableRefs += "<routeTableFqdns>" + networkTableRef + "</routeTableFqdns>" + '\n'
- String aaiResponseAsString = response.getResponseBodyAsString()
+ } // end loop
- if (returnCode=='200') {
- msoLogger.debug(aaiResponseAsString)
- execution.setVariable(Prefix + "queryNetworkTableRefAAIResponse", aaiResponseAsString)
- msoLogger.debug(" QueryAAINetworkTableRef Success REST Response, , NetworkTableRef #" + counting + " : " + "\n" + aaiResponseAsString)
+ execution.setVariable(Prefix + "tableRefCollection", networkTableRefs)
+ msoLogger.debug(" UPDNETI_tableRefCollection - " + '\n' + networkTableRefs)
- String networkTableRef = ""
- if (utils.nodeExists(aaiResponseAsString, "route-table-reference-fqdn")) {
- networkTableRef = utils.getNodeText(aaiResponseAsString, "route-table-reference-fqdn")
- networkTableRefs += "<routeTableFqdns>" + networkTableRef + "</routeTableFqdns>" + '\n'
- }
-
- } else {
- if (returnCode=='404') {
- String dataErrorMessage = "Response Error from QueryAAINetworkTableRef is 404 (Not Found)."
- msoLogger.debug(dataErrorMessage)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
-
- } else {
- if (aaiResponseAsString.contains("RESTFault")) {
- WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
- execution.setVariable("WorkflowException", exceptionObject)
- throw new BpmnError("MSOWorkflowException")
-
- } else {
- // aai all errors
- String dataErrorMessage = "Unexpected Response from QueryAAINetworkTableRef - " + returnCode
- msoLogger.debug(dataErrorMessage)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
-
- }
- }
- }
-
- } // end loop
-
- execution.setVariable(Prefix + "tableRefCollection", networkTableRefs)
- msoLogger.debug(" UPDNETI_tableRefCollection - " + '\n' + networkTableRefs)
-
- } else {
- // reset return code to success
- execution.setVariable(Prefix + "aaiQqueryNetworkTableRefReturnCode", "200")
- String schemaVersion = aaiUriUtil.getNamespace()
- String aaiStubResponse =
- """ <rest:payload contentType="text/xml" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd">
+ } else {
+ // reset return code to success
+ execution.setVariable(Prefix + "aaiQqueryNetworkTableRefReturnCode", "200")
+ AaiUtil aaiUriUtil = new AaiUtil(this)
+ String schemaVersion = aaiUriUtil.getNamespace()
+ String aaiStubResponse =
+ """ <rest:payload contentType="text/xml" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd">
<route-table-references xmlns="${schemaVersion}">
<route-table-reference-fqdn/>
</route-table-references>
</rest:payload>"""
- String aaiStubResponseAsXml = utils.formatXml(aaiStubResponse)
- execution.setVariable(Prefix + "queryNetworkTableRefAAIResponse", aaiStubResponseAsXml)
- execution.setVariable(Prefix + "tableRefCollection", "<routeTableFqdns/>")
- msoLogger.debug(" No net table references, using this stub as response - " + '\n' + aaiStubResponseAsXml)
+ String aaiStubResponseAsXml = utils.formatXml(aaiStubResponse)
+ execution.setVariable(Prefix + "queryNetworkTableRefAAIResponse", aaiStubResponseAsXml)
+ execution.setVariable(Prefix + "tableRefCollection", "<routeTableFqdns/>")
+ msoLogger.debug(" No net table references, using this stub as response - " + '\n' + aaiStubResponseAsXml)
+ }
}
- } catch (BpmnError e) {
- throw e;
+ } catch (NotFoundException e) {
+ String dataErrorMessage = "Response Error from QueryAAINetworkTableRef is 404 (Not Found)."
+ msoLogger.debug(dataErrorMessage)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
} catch (Exception ex) {
String exceptionMessage = "Bpmn error encountered in DoUpdateNetworkInstance flow. callRESTQueryAAINetworkTableRef() - " + ex.getMessage()
@@ -861,76 +689,73 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor {
}
public void callRESTUpdateContrailAAINetwork(DelegateExecution execution) {
-
execution.setVariable("prefix", Prefix)
-
msoLogger.debug(" ***** Inside callRESTUpdateContrailAAINetwork of DoUpdateNetworkInstance ***** " )
-
try {
// get variables
String networkRequest = execution.getVariable(Prefix + "networkRequest")
String networkId = utils.getNodeText(networkRequest, "network-id")
- networkId = UriUtils.encode(networkId,"UTF-8")
- String requeryIdAAIResponse = execution.getVariable(Prefix + "requeryIdAAIResponse")
+ AAIResultWrapper requeryIdAAIResponse = execution.getVariable(Prefix + "requeryIdAAIResponse")
String updateNetworkResponse = execution.getVariable(Prefix + "updateNetworkResponse")
- // Prepare url
- AaiUtil aaiUriUtil = new AaiUtil(this)
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId)
- uri.depth(Depth.ALL)
- String updateContrailAAIUrlRequest = aaiUriUtil.createAaiUri(uri)
-
- msoLogger.debug(updateContrailAAIUrlRequest)
- execution.setVariable(Prefix + "updateContrailAAIUrlRequest", updateContrailAAIUrlRequest)
- msoLogger.debug(" UPDNETI_updateContrailAAIUrlRequest - " + "\n" + updateContrailAAIUrlRequest)
-
- //Prepare payload (PUT)
- String schemaVersion = aaiUriUtil.getNamespaceFromUri(updateContrailAAIUrlRequest)
- String payload = networkUtils.ContrailNetworkCreatedUpdate(requeryIdAAIResponse, updateNetworkResponse, schemaVersion)
- String payloadXml = utils.formatXml(payload)
- msoLogger.debug(payloadXml)
- execution.setVariable(Prefix + "updateContrailAAIPayloadRequest", payloadXml)
- msoLogger.debug(" 'payload' to Update Contrail - " + "\n" + payloadXml)
-
- APIResponse response = aaiUriUtil.executeAAIPutCall(execution, updateContrailAAIUrlRequest, payload)
- String returnCode = response.getStatusCode()
- String aaiUpdateContrailResponseAsString = response.getResponseBodyAsString()
-
- execution.setVariable(Prefix + "aaiUpdateContrailReturnCode", returnCode)
- msoLogger.debug(" ***** AAI Update Contrail Response Code : " + returnCode)
-
-
- if (returnCode=='200') {
- msoLogger.debug(aaiUpdateContrailResponseAsString)
- execution.setVariable(Prefix + "updateContrailAAIResponse", aaiUpdateContrailResponseAsString)
- msoLogger.debug(" AAI Update Contrail Success REST Response - " + "\n" + aaiUpdateContrailResponseAsString)
- // Point-of-no-return is set to false, rollback not needed.
- execution.setVariable(Prefix + "isPONR", true)
-
+ L3Network oldL3Network = requeryIdAAIResponse.asBean(L3Network.class).get()
+ L3Network l3Network = new L3Network()
+ if (oldL3Network.getHeatStackId() != null) {
} else {
- if (returnCode=='404') {
- String dataErrorMessage = " Response Error from UpdateContrailAAINetwork is 404 (Not Found)."
- msoLogger.debug(dataErrorMessage)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
+ if (utils.nodeExists(updateNetworkResponse, 'networkStackId')) {
+ l3Network.setHeatStackId(utils.getNodeText(updateNetworkResponse, 'networkStackId'))
+ }
+ }
+ if (oldL3Network.getNeutronNetworkId() != null) {
+ } else {
+ if (utils.nodeExists(updateNetworkResponse, 'neutronNetworkId')) {
+ l3Network.setNeutronNetworkId(utils.getNodeText(updateNetworkResponse, 'neutronNetworkId'))
+ }
+ }
+ if (oldL3Network.getContrailNetworkFqdn() != null) {
+ } else {
+ if (utils.nodeExists(updateNetworkResponse, 'networkFqdn')) {
+ l3Network.setContrailNetworkFqdn(utils.getNodeText(updateNetworkResponse, 'networkFqdn'))
+ }
+ }
- } else {
- if (aaiUpdateContrailResponseAsString.contains("RESTFault")) {
- WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiUpdateContrailResponseAsString, execution)
- execution.setVariable("WorkflowException", exceptionObject)
- throw new BpmnError("MSOWorkflowException")
-
- } else {
- // aai all errors
- String errorMessage = "Unexpected Response from UpdateContrailAAINetwork - " + returnCode
- msoLogger.debug(errorMessage)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage)
- }
+ String status = utils.getNodeText(updateNetworkResponse, 'orchestration-status')
+ if(status.equals("pending-create") || status.equals("PendingCreate")){
+ l3Network.setOperationalStatus("Created")
+ }else{
+ l3Network.setOperationalStatus("Active")
+ }
+
+ AAIResourcesClient client = new AAIResourcesClient()
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId)
+ client.update(uri, l3Network)
+
+ List<Subnet> subnets = oldL3Network.getSubnets().getSubnet()
+ for(Subnet s:subnets){
+ String subnetOrchStatus = s.getOrchestrationStatus()
+ String subnetId = s.getSubnetId()
+
+ Subnet subnet = new Subnet()
+ String neutronSubnetId = networkUtils.extractNeutSubId(updateNetworkResponse, subnetId)
+ subnet.setNeutronSubnetId(neutronSubnetId)
+ if(subnetOrchStatus.equals("pending-create") || subnetOrchStatus.equals("PendingCreate") ){
+ subnet.setOrchestrationStatus("Created")
+ }else{
+ subnet.setOrchestrationStatus("Active")
}
+
+ AAIResourceUri subUri = AAIUriFactory.createResourceUri(AAIObjectType.SUBNET, networkId, subnetId)
+ client.update(subUri, subnet)
}
+ execution.setVariable(Prefix + "isPONR", true)
+
} catch (BpmnError e) {
throw e;
-
+ } catch (NotFoundException e) {
+ String dataErrorMessage = " Response Error from UpdateContrailAAINetwork is 404 (Not Found)."
+ msoLogger.debug(dataErrorMessage)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
} catch (Exception ex) {
String exceptionMessage = "Bpmn error encountered in DoUpdateNetworkInstance flow. callRESTUpdateContrailAAINetwork() - " + ex.getMessage()
msoLogger.debug(exceptionMessage)
@@ -1000,7 +825,8 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor {
String serviceInstanceId = utils.getNodeText(updateNetworkInput, "service-instance-id")
- String queryAAIResponse = execution.getVariable(Prefix + "queryIdAAIResponse")
+ AAIResultWrapper wrapper = execution.getVariable(Prefix + "queryIdAAIResponse")
+ L3Network queryAAIResponse = wrapper.asBean(L3Network.class).get()
// 1. prepare assign topology via SDNC Adapter SUBFLOW call
String sndcTopologyCreateRequest = sdncAdapterUtils.sdncTopologyRequestV2(execution, updateNetworkInput, serviceInstanceId, sdncCallback, "changeassign", "NetworkActivateRequest", cloudRegionId, networkId, queryAAIResponse, null)
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceRollback.groovy
index 8a13b3c392..eaba51ac6f 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceRollback.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceRollback.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.
@@ -32,7 +32,7 @@ import org.onap.so.bpmn.common.scripts.VidUtils
import org.onap.so.bpmn.core.WorkflowException
import org.onap.so.bpmn.core.UrnPropertiesReader
import org.onap.so.bpmn.core.json.JsonUtils
-import org.onap.so.rest.APIResponse
+
import java.util.UUID;
@@ -51,7 +51,7 @@ import org.onap.so.logger.MsoLogger
*/
public class DoUpdateNetworkInstanceRollback extends AbstractServiceTaskProcessor {
private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoUpdateNetworkInstanceRollback.class);
-
+
String Prefix="UPDNETIR_"
ExceptionUtil exceptionUtil = new ExceptionUtil()
JsonUtils jsonUtil = new JsonUtils()
@@ -128,7 +128,7 @@ public class DoUpdateNetworkInstanceRollback extends AbstractServiceTaskProcesso
// PO Authorization Info / headers Authorization=
String basicAuthValuePO = UrnPropertiesReader.getVariable("mso.adapters.po.auth",execution)
-
+
try {
def encodedString = utils.getBasicAuth(basicAuthValuePO, UrnPropertiesReader.getVariable("mso.msoKey", execution))
execution.setVariable("BasicAuthHeaderValuePO",encodedString)
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy
index c4711411d3..f6a8a1558c 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy
@@ -45,7 +45,7 @@ import org.onap.so.client.aai.entities.uri.AAIResourceUri
import org.onap.so.constants.Defaults
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
-import org.onap.so.rest.APIResponse
+
import org.springframework.web.util.UriUtils
public class DoUpdateVfModule extends VfModuleBase {
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy
index afe01b9243..7fdbb5cb89 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.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,8 @@ package org.onap.so.bpmn.infrastructure.scripts
import static org.apache.commons.lang3.StringUtils.*;
+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.onap.so.bpmn.common.scripts.AaiUtil
@@ -34,15 +36,14 @@ import org.onap.so.bpmn.core.domain.ModuleResource
import org.onap.so.bpmn.core.domain.VnfResource
import org.onap.so.bpmn.core.json.JsonUtils
import org.onap.so.client.graphinventory.entities.uri.Depth
+import org.onap.so.client.HttpClient
import org.onap.so.client.aai.AAIObjectType;
import org.onap.so.client.aai.AAIResourcesClient
import org.onap.so.client.aai.entities.uri.AAIResourceUri
import org.onap.so.client.aai.entities.uri.AAIUriFactory;
import org.onap.so.logger.MessageEnum
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.springframework.web.util.UriUtils;
/**
@@ -54,14 +55,14 @@ class DoUpdateVnfAndModules extends AbstractServiceTaskProcessor {
String Prefix="DUVAM_"
ExceptionUtil exceptionUtil = new ExceptionUtil()
- JsonUtils jsonUtil = new JsonUtils()
+ JsonUtils jsonUtil = new JsonUtils()
/**
* This method gets and validates the incoming
* request.
*
* @param - execution
- *
+ *
*/
public void preProcessRequest(DelegateExecution execution) {
@@ -69,66 +70,66 @@ class DoUpdateVnfAndModules extends AbstractServiceTaskProcessor {
msoLogger.trace("STARTED DoUpdateVnfAndModules PreProcessRequest Process")
try{
- // Get Variables
-
+ // Get Variables
+
String requestId = execution.getVariable("msoRequestId")
- execution.setVariable("requestId", requestId)
+ execution.setVariable("requestId", requestId)
execution.setVariable("mso-request-id", requestId)
msoLogger.debug("Incoming Request Id is: " + requestId)
- String serviceInstanceId = execution.getVariable("serviceInstanceId")
+ String serviceInstanceId = execution.getVariable("serviceInstanceId")
msoLogger.debug("Incoming Service Instance Id is: " + serviceInstanceId)
- String vnfId = execution.getVariable("vnfId")
- msoLogger.debug("Incoming Vnf Id is: " + vnfId)
-
+ String vnfId = execution.getVariable("vnfId")
+ msoLogger.debug("Incoming Vnf Id is: " + vnfId)
+
String source = "VID"
execution.setVariable("DUVAM_source", source)
msoLogger.debug("Incoming Source is: " + source)
-
+
String sdncVersion = execution.getVariable("sdncVersion")
if (sdncVersion == null) {
sdncVersion = "1702"
}
execution.setVariable("DUVAM_sdncVersion", sdncVersion)
msoLogger.debug("Incoming Sdnc Version is: " + sdncVersion)
-
- VnfResource vnfResource = (VnfResource) execution.getVariable("vnfResourceDecomposition")
-
+
+ VnfResource vnfResource = (VnfResource) execution.getVariable("vnfResourceDecomposition")
+
String vnfModelInfo = execution.getVariable("vnfModelInfo")
String serviceModelInfo = execution.getVariable("serviceModelInfo")
-
+
String serviceId = execution.getVariable("productFamilyId")
execution.setVariable("DUVAM_serviceId", serviceId)
- msoLogger.debug("Incoming Service Id is: " + serviceId)
-
- String modelUuid = jsonUtil.getJsonValue(vnfModelInfo, "modelUuid")
+ msoLogger.debug("Incoming Service Id is: " + serviceId)
+
+ String modelUuid = jsonUtil.getJsonValue(vnfModelInfo, "modelUuid")
execution.setVariable("DUVAM_modelUuid", modelUuid)
- msoLogger.debug("Incoming modelUuid is: " + modelUuid)
-
- String modelCustomizationUuid = jsonUtil.getJsonValue(vnfModelInfo, "modelCustomizationUuid")
+ msoLogger.debug("Incoming modelUuid is: " + modelUuid)
+
+ String modelCustomizationUuid = jsonUtil.getJsonValue(vnfModelInfo, "modelCustomizationUuid")
execution.setVariable("DUVAM_modelCustomizationUuid", modelCustomizationUuid)
msoLogger.debug("Incoming Model Customization Uuid is: " + modelCustomizationUuid)
-
+
String cloudSiteId = execution.getVariable("lcpCloudRegionId")
execution.setVariable("DUVAM_cloudSiteId", cloudSiteId)
msoLogger.debug("Incoming Cloud Site Id is: " + cloudSiteId)
-
+
String tenantId = execution.getVariable("tenantId")
execution.setVariable("DUVAM_tenantId", tenantId)
msoLogger.debug("Incoming Tenant Id is: " + tenantId)
-
+
String globalSubscriberId = execution.getVariable("globalSubscriberId")
if (globalSubscriberId == null) {
globalSubscriberId = ""
}
execution.setVariable("DUVAM_globalSubscriberId", globalSubscriberId)
msoLogger.debug("Incoming Global Subscriber Id is: " + globalSubscriberId)
-
+
execution.setVariable("DUVAM_moduleCount", 0)
execution.setVariable("DUVAM_nextModule", 0)
-
-
+
+
}catch(BpmnError b){
msoLogger.debug("Rethrowing MSOWorkflowException")
throw b
@@ -138,8 +139,8 @@ class DoUpdateVnfAndModules extends AbstractServiceTaskProcessor {
}
msoLogger.trace("COMPLETED DoUpdateVnfAndModules PreProcessRequest Process ")
- }
-
+ }
+
/**
* Using the received vnfId and vfModuleId, query AAI to get the corresponding VNF info.
* A 200 response is expected with the VNF info in the response body. Will find out the base module info.
@@ -155,43 +156,43 @@ class DoUpdateVnfAndModules extends AbstractServiceTaskProcessor {
try {
def vnfId = execution.getVariable('vnfId')
-
+
AaiUtil aaiUriUtil = new AaiUtil(this)
AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId).depth(Depth.ONE)
String endPoint = aaiUriUtil.createAaiUri(uri)
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("createVfModule - invoking httpGet() to AAI")
- responseData = response.getResponseBodyAsString()
+ responseData = response.readEntity(String.class)
if (responseData != null) {
msoLogger.debug("Received generic VNF data: " + responseData)
}
msoLogger.debug("createVfModule - queryAAIVfModule Response: " + responseData)
- msoLogger.debug("createVfModule - queryAAIVfModule ResponseCode: " + response.getStatusCode())
+ msoLogger.debug("createVfModule - queryAAIVfModule ResponseCode: " + response.getStatus())
- execution.setVariable('DUVAM_queryAAIVfModuleResponseCode', response.getStatusCode())
+ execution.setVariable('DUVAM_queryAAIVfModuleResponseCode', response.getStatus())
execution.setVariable('DUVAM_queryAAIVfModuleResponse', responseData)
- msoLogger.debug('Response code:' + response.getStatusCode())
+ msoLogger.debug('Response code:' + response.getStatus())
msoLogger.debug('Response:' + System.lineSeparator() + responseData)
//Map<String, String>[] vfModules = new HashMap<String,String>[]
def vfModulesList = new ArrayList<Map<String,String>>()
def vfModules = null
def vfModuleBaseEntry = null
- if (response.getStatusCode() == 200) {
+ if (response.getStatus() == 200) {
// Parse the VNF record from A&AI to find base module info
msoLogger.debug('Parsing the VNF data to find base module info')
if (responseData != null) {
@@ -204,7 +205,7 @@ class DoUpdateVnfAndModules extends AbstractServiceTaskProcessor {
int vfModulesSize = 0
for (i in 0..vfModules.size()-1) {
def vfModuleXml = groovy.xml.XmlUtil.serialize(vfModules[i])
-
+
Map<String, String> vfModuleEntry = new HashMap<String, String>()
def vfModuleId = utils.getNodeText(vfModuleXml, "vf-module-id")
vfModuleEntry.put("vfModuleId", vfModuleId)
@@ -216,20 +217,20 @@ class DoUpdateVnfAndModules extends AbstractServiceTaskProcessor {
vfModuleEntry.put("modelUuid", modelUuid)
def modelCustomizationUuid = utils.getNodeText(vfModuleXml, "model-customization-id")
vfModuleEntry.put("modelCustomizationUuid", modelCustomizationUuid)
-
+
def isBaseVfModule = utils.getNodeText(vfModuleXml, "is-base-vf-module")
vfModuleEntry.put("isBaseVfModule", isBaseVfModule)
-
+
String volumeGroupId = ''
-
+
msoLogger.debug("Next module!")
def vfModuleRelationships = vfModules[i].'**'.findAll {it.name() == 'relationship-data'}
if (vfModuleRelationships.size() > 0) {
- for (j in 0..vfModuleRelationships.size()-1) {
+ for (j in 0..vfModuleRelationships.size()-1) {
if (vfModuleRelationships[j] != null) {
-
- def relationshipKey = vfModuleRelationships[j].'**'.findAll {it.name() == 'relationship-key'}
-
+
+ def relationshipKey = vfModuleRelationships[j].'**'.findAll {it.name() == 'relationship-key'}
+
if (relationshipKey[0] == 'volume-group.volume-group-id') {
def relationshipValue = vfModuleRelationships[j].'**'.findAll {it.name() == 'relationship-value'}
volumeGroupId = relationshipValue[0]
@@ -238,25 +239,25 @@ class DoUpdateVnfAndModules extends AbstractServiceTaskProcessor {
}
}
}
-
+
vfModuleEntry.put("volumeGroupId", volumeGroupId)
msoLogger.debug("volumeGroupId is: " + volumeGroupId)
// Save base vf module to add it to the start of the list later
- if (isBaseVfModule == "true") {
+ if (isBaseVfModule == "true") {
vfModuleBaseEntry = vfModuleEntry
}
- else {
+ else {
vfModulesList.add(vfModuleEntry)
}
}
// Start the list with the base module if any
if (vfModuleBaseEntry != null) {
vfModulesList.add(0, vfModuleBaseEntry)
- }
+ }
}
-
- }
+
+ }
}
else {
msoLogger.debug('Response code from AAI GET is: ' + response.getStatusCode())
@@ -276,44 +277,44 @@ class DoUpdateVnfAndModules extends AbstractServiceTaskProcessor {
exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIVfModule(): ' + e.getMessage())
}
}
-
+
public void prepareNextModuleToUpdate(DelegateExecution execution){
execution.setVariable("prefix", Prefix)
msoLogger.trace("STARTED prepareNextModuleToUpdate ")
-
+
try {
int i = execution.getVariable("DUVAM_nextModule")
def vfModules = execution.getVariable("DUVAM_vfModules")
def vfModule = vfModules[i]
-
+
def vfModuleId = vfModule.get("vfModuleId")
execution.setVariable("DUVAM_vfModuleId", vfModuleId)
-
+
def vfModuleName = vfModule.get("vfModuleName")
execution.setVariable("DUVAM_vfModuleName", vfModuleName)
-
+
def isBaseVfModule = vfModule.get("isBaseVfModule")
execution.setVariable("DUVAM_isBaseVfModule", isBaseVfModule)
-
+
String modelInvariantUuid = vfModule.get("modelInvariantUuid")
- msoLogger.debug("ModelInvariantUuid: " + modelInvariantUuid)
-
+ msoLogger.debug("ModelInvariantUuid: " + modelInvariantUuid)
+
def volumeGroupId = vfModule.get("volumeGroupId")
execution.setVariable("DUVAM_volumeGroupId", volumeGroupId)
execution.setVariable("DUVAM_volumeGroupName", "")
-
+
VnfResource vnfResource = (VnfResource) execution.getVariable("vnfResourceDecomposition")
List<ModuleResource> moduleResources = vnfResource.getVfModules()
-
+
if (moduleResources != null && !moduleResources.isEmpty()) {
-
- for (j in 0..moduleResources.size()-1) {
+
+ for (j in 0..moduleResources.size()-1) {
ModelInfo modelInfo = moduleResources[j].getModelInfo()
String modelInvariantUuidFromDecomposition = modelInfo.getModelInvariantUuid()
msoLogger.debug("modelInvariantUuidFromDecomposition: " + modelInvariantUuidFromDecomposition)
-
+
if (modelInvariantUuid.equals(modelInvariantUuidFromDecomposition)) {
String vfModuleModelInfo = modelInfo.toJsonString()
String vfModuleModelInfoValue = jsonUtil.getJsonValue(vfModuleModelInfo, "modelInfo")
@@ -321,18 +322,18 @@ class DoUpdateVnfAndModules extends AbstractServiceTaskProcessor {
msoLogger.debug("vfModuleModelInfo: " + vfModuleModelInfoValue)
break
}
-
+
}
- }
-
+ }
+
}catch(Exception e){
msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing preProcessAddOnModule. Exception is:\n" + e, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during prepareNextModuleToUpdate Method:\n" + e.getMessage())
}
msoLogger.trace("COMPLETED prepareNextModuleToUpdate ")
}
-
-
+
+
/**
* Prepare a Request for invoking the UpdateAAIGenericVnf subflow.
*
@@ -344,25 +345,25 @@ class DoUpdateVnfAndModules extends AbstractServiceTaskProcessor {
')'
msoLogger.trace('Entered ' + method)
-
- try {
+
+ try {
def vnfId = execution.getVariable('vnfId')
VnfResource vnfResource = (VnfResource) execution.getVariable("vnfResourceDecomposition")
ModelInfo vnfDecompModelInfo = vnfResource.getModelInfo()
String vnfModelInfo = execution.getVariable("vnfModelInfo")
String modelUuid = execution.getVariable("DUVAM_modelUuid")
if (modelUuid == null || modelUuid.isEmpty()) {
- modelUuid = vnfDecompModelInfo.getModelUuid()
+ modelUuid = vnfDecompModelInfo.getModelUuid()
}
String modelCustomizationUuid = execution.getVariable("DUVAM_modelCustomizationUuid")
if (modelCustomizationUuid == null || modelCustomizationUuid.isEmpty()) {
modelCustomizationUuid = vnfDecompModelInfo.getModelCustomizationUuid()
- }
+ }
String nfType = vnfResource.getNfType()
String nfTypeString = ''
if (nfType != null && !nfType.isEmpty()) {
nfTypeString = "<nf-type>" + nfType + "</nf-type>"
- }
+ }
String nfRole = vnfResource.getNfRole()
String nfRoleString = ''
if (nfRole != null && !nfRole.isEmpty()) {
@@ -377,8 +378,8 @@ class DoUpdateVnfAndModules extends AbstractServiceTaskProcessor {
String nfNamingCodeString = ''
if (nfNamingCode != null && !nfNamingCode.isEmpty()) {
nfNamingCodeString = "<nf-naming-code>" + nfNamingCode + "</nf-naming-code>"
- }
-
+ }
+
String updateAAIGenericVnfRequest = """
<UpdateAAIGenericVnfRequest>
<vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id>
@@ -394,8 +395,8 @@ class DoUpdateVnfAndModules extends AbstractServiceTaskProcessor {
execution.setVariable('DUVAM_updateAAIGenericVnfRequest', updateAAIGenericVnfRequest)
msoLogger.debug("updateAAIGenericVnfRequest : " + updateAAIGenericVnfRequest)
msoLogger.debug('Request for UpdateAAIGenericVnf:\n' + updateAAIGenericVnfRequest)
-
-
+
+
msoLogger.trace('Exited ' + method)
} catch (BpmnError e) {
throw e;
@@ -404,7 +405,7 @@ class DoUpdateVnfAndModules extends AbstractServiceTaskProcessor {
exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIGenericVnf(): ' + e.getMessage())
}
}
-
+
/**
* APP-C Call - placeholder.
*
@@ -415,6 +416,6 @@ class DoUpdateVnfAndModules extends AbstractServiceTaskProcessor {
'execution=' + execution.getId() +
')'
- msoLogger.trace('Entered ' + method)
+ msoLogger.trace('Entered ' + method)
}
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/RollbackVnf.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/RollbackVnf.groovy
index d729c770ca..22b44c9ead 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/RollbackVnf.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/RollbackVnf.groovy
@@ -8,7 +8,7 @@
* 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.
@@ -32,9 +32,7 @@ import org.onap.so.bpmn.common.scripts.ExceptionUtil
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.impl.cmd.AbstractSetVariableCmd
import org.camunda.bpm.engine.delegate.DelegateExecution
-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.bpmn.common.scripts.VidUtils;
import org.onap.so.bpmn.core.RollbackData
@@ -61,7 +59,7 @@ public class RollbackVnf extends VnfCmBase {
private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, RollbackVnf.class);
ExceptionUtil exceptionUtil = new ExceptionUtil()
- JsonUtils jsonUtils = new JsonUtils()
+ JsonUtils jsonUtils = new JsonUtils()
def prefix = "VnfIPU_"
/**
@@ -71,16 +69,16 @@ public class RollbackVnf extends VnfCmBase {
*/
public void initProcessVariables(DelegateExecution execution) {
execution.setVariable('prefix', 'RVnf_')
-
- execution.setVariable('rollbackSuccessful', false)
+
+ execution.setVariable('rollbackSuccessful', false)
execution.setVariable('currentActivity', 'RVnf')
execution.setVariable('workStep', null)
execution.setVariable('failedActivity', null)
- execution.setVariable('errorCode', "0")
- execution.setVariable('actionUnlock', Action.Unlock)
+ execution.setVariable('errorCode', "0")
+ execution.setVariable('actionUnlock', Action.Unlock)
execution.setVariable('actionStart', Action.Start)
execution.setVariable('actionResumeTraffic', Action.ResumeTraffic)
-
+
}
/**
@@ -97,16 +95,16 @@ public class RollbackVnf extends VnfCmBase {
msoLogger.trace('Entered ' + method)
initProcessVariables(execution)
-
+
try {
-
+
execution.setVariable("rollbackErrorCode", "0")
-
+
if (execution.getVariable("rollbackSetClosedLoopDisabledFlag") == true) {
msoLogger.debug("Will call setClosedLoopDisabledFlag")
- }
+ }
+
-
msoLogger.trace('Exited ' + method)
}
@@ -115,9 +113,9 @@ public class RollbackVnf extends VnfCmBase {
msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, " Exception Encountered - " + "\n" + restFaultMessage, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
execution.setVariable("rollbackErrorCode", "1")
exceptionUtil.buildAndThrowWorkflowException(execution, 5000, restFaultMessage)
- }
+ }
}
-
+
/**
* Determine success of rollback execution.
*
@@ -130,7 +128,7 @@ public class RollbackVnf extends VnfCmBase {
initProcessVariables(execution)
msoLogger.trace('Entered ' + method)
-
+
def rollbackErrorCode = execution.getVariable('rollbackErrorCode')
if (rollbackErrorCode == "0") {
execution.setVariable('rollbackSuccessful', true)
@@ -140,9 +138,9 @@ public class RollbackVnf extends VnfCmBase {
execution.setVariable('rollbackSuccessful', false)
msoLogger.debug("rollback unsuccessful")
}
-
- msoLogger.trace('Exited ' + method)
-
- }
-
+
+ msoLogger.trace('Exited ' + method)
+
+ }
+
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy
index 8a3dcbab5d..7a6fd72a7d 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy
@@ -32,7 +32,7 @@ import org.onap.so.bpmn.core.WorkflowException
import org.onap.so.bpmn.core.json.JsonUtils
import org.onap.so.logger.MessageEnum
import org.onap.so.logger.MsoLogger
-import org.onap.so.rest.APIResponse
+
import org.onap.so.client.aai.AAIResourcesClient
import org.onap.so.client.aai.AAIObjectType
import org.onap.so.client.aai.entities.AAIResultWrapper
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollback.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollback.groovy
index aa88c2ac68..06d557532b 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollback.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollback.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.
@@ -28,7 +28,7 @@ import org.onap.so.bpmn.common.scripts.ExceptionUtil
import org.onap.so.bpmn.common.scripts.MsoUtils
import org.onap.so.bpmn.common.scripts.AaiUtil
import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils
-import org.onap.so.rest.APIResponse
+
import java.util.UUID;
import org.camunda.bpm.engine.delegate.BpmnError
@@ -44,15 +44,15 @@ import org.onap.so.logger.MsoLogger
* This groovy class supports the <class>CreateAllottedResourceTXCRollback.bpmn</class> process.
*
* @author
- *
+ *
* Inputs:
* @param - msoRequestId
* @param - isDebugLogEnabled
- * @param - disableRollback - O
+ * @param - disableRollback - O
* @param - rollbackData
*
* Outputs:
- * @param - rollbackError
+ * @param - rollbackError
* @param - rolledBack (no localRB->null, localRB F->false, localRB S->true)
*
*/
@@ -63,31 +63,31 @@ public class DoCreateAllottedResourceTXCRollback extends AbstractServiceTaskProc
ExceptionUtil exceptionUtil = new ExceptionUtil()
public void preProcessRequest (DelegateExecution execution) {
-
+
String msg = ""
msoLogger.trace("start preProcessRequest")
execution.setVariable("prefix", Prefix)
String rbType = "DCARTXC_"
try {
-
+
def rollbackData = execution.getVariable("rollbackData")
msoLogger.debug("RollbackData:" + rollbackData)
if (rollbackData != null) {
if (rollbackData.hasType(rbType)) {
-
+
execution.setVariable("serviceInstanceId", rollbackData.get(rbType, "serviceInstanceId"))
execution.setVariable("parentServiceInstanceId", rollbackData.get(rbType, "parentServiceInstanceId"))
execution.setVariable("allottedResourceId", rollbackData.get("SERVICEINSTANCE", "allottedResourceId"))
-
-
+
+
def rollbackAAI = rollbackData.get(rbType, "rollbackAAI")
if ("true".equals(rollbackAAI))
{
execution.setVariable("rollbackAAI",true)
execution.setVariable("aaiARPath", rollbackData.get(rbType, "aaiARPath"))
-
+
}
def rollbackSDNC = rollbackData.get(rbType, "rollbackSDNCassign")
if ("true".equals(rollbackSDNC))
@@ -96,11 +96,11 @@ public class DoCreateAllottedResourceTXCRollback extends AbstractServiceTaskProc
execution.setVariable("deactivateSdnc", rollbackData.get(rbType, "rollbackSDNCactivate"))
execution.setVariable("deleteSdnc", rollbackData.get(rbType, "rollbackSDNCcreate"))
execution.setVariable("unassignSdnc", rollbackData.get(rbType, "rollbackSDNCassign"))
-
+
msoLogger.debug("sdncDeactivate:\n" + execution.getVariable("deactivateSdnc") )
msoLogger.debug("sdncDelete:\n" + execution.getVariable("deleteSdnc"))
msoLogger.debug("sdncUnassign:\n" + execution.getVariable("unassignSdnc"))
-
+
execution.setVariable("sdncDeactivateRequest", rollbackData.get(rbType, "sdncActivateRollbackReq"))
execution.setVariable("sdncDeleteRequest", rollbackData.get(rbType, "sdncCreateRollbackReq"))
execution.setVariable("sdncUnassignRequest", rollbackData.get(rbType, "sdncAssignRollbackReq"))
@@ -122,7 +122,7 @@ public class DoCreateAllottedResourceTXCRollback extends AbstractServiceTaskProc
{
execution.setVariable("skipRollback", true)
}
-
+
}catch(BpmnError b){
msoLogger.debug("Rethrowing MSOWorkflowException")
throw b
@@ -213,7 +213,7 @@ public class DoCreateAllottedResourceTXCRollback extends AbstractServiceTaskProc
}
msoLogger.trace("end deleteAaiAR")
}
-
+
public void postProcessRequest(DelegateExecution execution) {
msoLogger.trace("start postProcessRequest")
@@ -236,7 +236,7 @@ public class DoCreateAllottedResourceTXCRollback extends AbstractServiceTaskProc
}
}
-
+
public void processRollbackException(DelegateExecution execution){
msoLogger.trace("start processRollbackException")