summaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-infrastructure-flows/src/main/groovy
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/so-bpmn-infrastructure-flows/src/main/groovy')
-rw-r--r--bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSDNCNetworkResource.groovy324
-rw-r--r--bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Create3rdONAPE2EServiceInstance.groovy232
-rw-r--r--bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy137
-rw-r--r--bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeActivateNetworkResource.groovy89
-rw-r--r--bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeActivateSDNCNetworkResource.groovy256
-rw-r--r--bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Delete3rdONAPE2EServiceInstance.groovy517
-rw-r--r--bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSDNCNetworkResource.groovy40
-rw-r--r--bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateResources.groovy1
-rw-r--r--bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy195
9 files changed, 1493 insertions, 298 deletions
diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSDNCNetworkResource.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSDNCNetworkResource.groovy
index ef99546214..6ebba419f2 100644
--- a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSDNCNetworkResource.groovy
+++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSDNCNetworkResource.groovy
@@ -20,6 +20,12 @@
package org.openecomp.mso.bpmn.infrastructure.scripts
+import org.apache.commons.lang3.StringUtils
+import org.camunda.bpm.engine.delegate.BpmnError
+import org.json.JSONObject
+import org.json.XML
+import org.onap.so.bpmn.common.recipe.ResourceInput
+import org.onap.so.bpmn.common.resource.ResourceRequestBuilder
import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
import org.camunda.bpm.engine.delegate.DelegateExecution
import org.onap.so.bpmn.core.json.JsonUtils
@@ -44,17 +50,335 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor {
public void preProcessRequest(DelegateExecution execution) {
msoLogger.trace("Started preProcessRequest ")
+
+ try {
+ //get bpmn inputs from resource request.
+ String requestId = execution.getVariable("mso-request-id")
+ String requestAction = execution.getVariable("requestAction")
+ msoLogger.info("The requestAction is: " + requestAction)
+ String recipeParamsFromRequest = execution.getVariable("recipeParams")
+ msoLogger.info("The recipeParams is: " + recipeParamsFromRequest)
+ String resourceInput = execution.getVariable("resourceInput")
+ msoLogger.info("The resourceInput is: " + resourceInput)
+ //Get ResourceInput Object
+ ResourceInput resourceInputObj = ResourceRequestBuilder.getJsonObject(resourceInput, ResourceInput.class)
+ execution.setVariable(Prefix + "resourceInput", resourceInputObj)
+
+ //Deal with recipeParams
+ String recipeParamsFromWf = execution.getVariable("recipeParamXsd")
+ String resourceName = resourceInputObj.getResourceInstanceName()
+ //For sdnc requestAction default is "createNetworkInstance"
+ String operationType = "Network"
+ if(!StringUtils.isBlank(recipeParamsFromRequest)){
+ //the operationType from worflow(first node) is second priority.
+ operationType = jsonUtil.getJsonValue(recipeParamsFromRequest, "operationType")
+ }
+ if(!StringUtils.isBlank(recipeParamsFromWf)){
+ //the operationType from worflow(first node) is highest priority.
+ operationType = jsonUtil.getJsonValue(recipeParamsFromWf, "operationType")
+ }
+
+ // TODO: based on the resource type decide action and operation type
+ String sdnc_svcAction = "activate"
+ operationType = "SOTNConnectivity"
+
+ String sdnc_requestAction = StringUtils.capitalize(sdnc_svcAction) + operationType +"Instance"
+ execution.setVariable(Prefix + "svcAction", sdnc_svcAction)
+ execution.setVariable(Prefix + "requestAction", sdnc_requestAction)
+ execution.setVariable(Prefix + "serviceInstanceId", resourceInputObj.getServiceInstanceId())
+ execution.setVariable("mso-request-id", requestId)
+ execution.setVariable("mso-service-instance-id", resourceInputObj.getServiceInstanceId())
+ } catch (BpmnError e) {
+ throw e;
+ } catch (Exception ex){
+ msg = "Exception in preProcessRequest " + ex.getMessage()
+ msoLogger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
}
public void prepareUpdateAfterActivateSDNCResource(DelegateExecution execution) {
msoLogger.trace("started prepareUpdateAfterActivateSDNCResource ")
+
+ ResourceInput resourceInputObj = execution.getVariable(Prefix + "resourceInput")
+ String operType = resourceInputObj.getOperationType()
+ String resourceCustomizationUuid = resourceInputObj.getResourceModelInfo().getModelCustomizationUuid()
+ String ServiceInstanceId = resourceInputObj.getServiceInstanceId()
+ String operationId = resourceInputObj.getOperationId()
+ String progress = "100"
+ String status = "finished"
+ String statusDescription = "SDCN resource creation completed"
+
+ execution.getVariable("operationId")
+
+ String body = """
+ <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
+ xmlns:ns="http://org.onap.so/requestsdb">
+ <soapenv:Header/>
+ <soapenv:Body>
+ <ns:updateResourceOperationStatus>
+ <operType>${MsoUtils.xmlEscape(operType)}</operType>
+ <operationId>${MsoUtils.xmlEscape(operationId)}</operationId>
+ <progress>${MsoUtils.xmlEscape(progress)}</progress>
+ <resourceTemplateUUID>${MsoUtils.xmlEscape(resourceCustomizationUuid)}</resourceTemplateUUID>
+ <serviceId>${MsoUtils.xmlEscape(ServiceInstanceId)}</serviceId>
+ <status>${MsoUtils.xmlEscape(status)}</status>
+ <statusDescription>${MsoUtils.xmlEscape(statusDescription)}</statusDescription>
+ </ns:updateResourceOperationStatus>
+ </soapenv:Body>
+ </soapenv:Envelope>""";
+
+ setProgressUpdateVariables(execution, body)
+ }
+
+ public void prepareSDNCRequest (DelegateExecution execution) {
+ msoLogger.trace("Started prepareSDNCRequest ")
+
+ try {
+ // get variables
+ String sdnc_svcAction = execution.getVariable(Prefix + "svcAction")
+ String sdnc_requestAction = execution.getVariable(Prefix + "requestAction")
+ String sdncCallback = execution.getVariable("URN_mso_workflow_sdncadapter_callback")
+ String createNetworkInput = execution.getVariable(Prefix + "networkRequest")
+
+ String hdrRequestId = execution.getVariable("mso-request-id")
+ String serviceInstanceId = execution.getVariable(Prefix + "serviceInstanceId")
+ String source = execution.getVariable("source")
+ String sdnc_service_id = execution.getVariable(Prefix + "sdncServiceId")
+ ResourceInput resourceInputObj = execution.getVariable(Prefix + "resourceInput")
+ String serviceType = resourceInputObj.getServiceType()
+ String serviceModelInvariantUuid = resourceInputObj.getServiceModelInfo().getModelInvariantUuid()
+ String serviceModelUuid = resourceInputObj.getServiceModelInfo().getModelUuid()
+ String serviceModelVersion = resourceInputObj.getServiceModelInfo().getModelVersion()
+ String serviceModelName = resourceInputObj.getServiceModelInfo().getModelName()
+ String globalCustomerId = resourceInputObj.getGlobalSubscriberId()
+ String modelInvariantUuid = resourceInputObj.getResourceModelInfo().getModelInvariantUuid();
+ String modelCustomizationUuid = resourceInputObj.getResourceModelInfo().getModelCustomizationUuid()
+ String modelUuid = resourceInputObj.getResourceModelInfo().getModelUuid()
+ String modelName = resourceInputObj.getResourceModelInfo().getModelName()
+ String modelVersion = resourceInputObj.getResourceModelInfo().getModelVersion()
+ String resourceInputPrameters = resourceInputObj.getResourceParameters()
+ String networkInputParametersJson = jsonUtil.getJsonValue(resourceInputPrameters, "requestInputs")
+ //here convert json string to xml string
+ String netowrkInputParameters = XML.toString(new JSONObject(customizeResourceParam(networkInputParametersJson)))
+ // 1. prepare assign topology via SDNC Adapter SUBFLOW call
+ String sdncTopologyActivateRequest = ""
+
+ switch (modelName) {
+ case ~/^Site$/:
+ sdncTopologyActivateRequest =
+ """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.onap/so/workflow/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>${MsoUtils.xmlEscape(hdrRequestId)}</sdncadapter:RequestId>
+ <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(serviceInstanceId)}</sdncadapter:SvcInstanceId>
+ <sdncadapter:SvcAction>${MsoUtils.xmlEscape(sdnc_svcAction)}</sdncadapter:SvcAction>
+ <sdncadapter:SvcOperation>network-topology-operation</sdncadapter:SvcOperation>
+ <sdncadapter:CallbackUrl>sdncCallback</sdncadapter:CallbackUrl>
+ <sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction>
+ </sdncadapter:RequestHeader>
+ <sdncadapterworkflow:SDNCRequestData>
+ <request-information>
+ <request-id>${MsoUtils.xmlEscape(hdrRequestId)}</request-id>
+ <request-action>${MsoUtils.xmlEscape(sdnc_requestAction)}</request-action>
+ <source>${MsoUtils.xmlEscape(source)}</source>
+ <notification-url></notification-url>
+ <order-number></order-number>
+ <order-version></order-version>
+ </request-information>
+ <service-information>
+ <service-id>${MsoUtils.xmlEscape(serviceInstanceId)}</service-id>
+ <subscription-service-type>${MsoUtils.xmlEscape(serviceType)}</subscription-service-type>
+ <onap-model-information>
+ <model-invariant-uuid>${MsoUtils.xmlEscape(serviceModelInvariantUuid)}</model-invariant-uuid>
+ <model-uuid>${MsoUtils.xmlEscape(serviceModelUuid)}</model-uuid>
+ <model-version>${MsoUtils.xmlEscape(serviceModelVersion)}</model-version>
+ <model-name>${MsoUtils.xmlEscape(serviceModelName)}</model-name>
+ </onap-model-information>
+ <service-instance-id>${MsoUtils.xmlEscape(serviceInstanceId)}</service-instance-id>
+ <global-customer-id>${MsoUtils.xmlEscape(globalCustomerId)}</global-customer-id>
+ </service-information>
+ <vnf-information>
+ <vnf-id></vnf-id>
+ <vnf-type></vnf-type>
+ <onap-model-information>
+ <model-invariant-uuid>${MsoUtils.xmlEscape(modelInvariantUuid)}</model-invariant-uuid>
+ <model-customization-uuid>${MsoUtils.xmlEscape(modelCustomizationUuid)}</model-customization-uuid>
+ <model-uuid>${MsoUtils.xmlEscape(modelUuid)}</model-uuid>
+ <model-version>${MsoUtils.xmlEscape(modelVersion)}</model-version>
+ <model-name>${MsoUtils.xmlEscape(modelName)}</model-name>
+ </onap-model-information>
+ </vnf-information>
+ <vnf-input-parameters>
+ <param>${MsoUtils.xmlEscape(netowrkInputParameters)}</param>
+ </vnf-input-parameters>
+ <vnf-request-input>
+ <request-version></request-version>
+ <vnf-name></vnf-name>
+ <neutron-id></neutron-id>
+ <contrail-network-fqdn></contrail-network-fqdn>
+ <subnets-data>
+ <subnet-data>
+ <element>
+ <ip-version></ip-version>
+ <subnet-id></subnet-id>
+ </subnet-data>
+ </subnets-data>
+ </vnf-request-input>
+ </sdncadapterworkflow:SDNCRequestData>
+ </aetgt:SDNCAdapterWorkflowRequest>""".trim()
+ break
+
+ case ~/^SOTNAttachment$/:
+ sdncTopologyActivateRequest =
+ """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.onap/so/workflow/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>${MsoUtils.xmlEscape(hdrRequestId)}</sdncadapter:RequestId>
+ <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(serviceInstanceId)}</sdncadapter:SvcInstanceId>
+ <sdncadapter:SvcAction>${MsoUtils.xmlEscape(sdnc_svcAction)}</sdncadapter:SvcAction>
+ <sdncadapter:SvcOperation>network-topology-operation</sdncadapter:SvcOperation>
+ <sdncadapter:CallbackUrl>sdncCallback</sdncadapter:CallbackUrl>
+ <sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction>
+ </sdncadapter:RequestHeader>
+ <sdncadapterworkflow:SDNCRequestData>
+ <request-information>
+ <request-id>${MsoUtils.xmlEscape(hdrRequestId)}</request-id>
+ <request-action>${MsoUtils.xmlEscape(sdnc_requestAction)}</request-action>
+ <source>${MsoUtils.xmlEscape(source)}</source>
+ <notification-url></notification-url>
+ <order-number></order-number>
+ <order-version></order-version>
+ </request-information>
+ <service-information>
+ <service-id>${MsoUtils.xmlEscape(serviceInstanceId)}</service-id>
+ <subscription-service-type>${MsoUtils.xmlEscape(serviceType)}</subscription-service-type>
+ <onap-model-information>
+ <model-invariant-uuid>${MsoUtils.xmlEscape(serviceModelInvariantUuid)}</model-invariant-uuid>
+ <model-uuid>${MsoUtils.xmlEscape(serviceModelUuid)}</model-uuid>
+ <model-version>${MsoUtils.xmlEscape(serviceModelVersion)}</model-version>
+ <model-name>${MsoUtils.xmlEscape(serviceModelName)}</model-name>
+ </onap-model-information>
+ <service-instance-id>${MsoUtils.xmlEscape(serviceInstanceId)}</service-instance-id>
+ <global-customer-id>${MsoUtils.xmlEscape(globalCustomerId)}</global-customer-id>
+ </service-information>
+ <allotted-resource-information>
+ <!-- TODO: to be filled as per the request input -->
+ <allotted-resource-input></allotted-resource-input>
+ <allotted-resource-type></allotted-resource-type>
+ <parent-service-instance-id><parent-service-instance-id>
+ <onap-model-information>
+ <model-invariant-uuid>${MsoUtils.xmlEscape(modelInvariantUuid)}</model-invariant-uuid>
+ <model-customization-uuid>${MsoUtils.xmlEscape(modelCustomizationUuid)}</model-customization-uuid>
+ <model-uuid>${MsoUtils.xmlEscape(modelUuid)}</model-uuid>
+ <model-version>${MsoUtils.xmlEscape(modelVersion)}</model-version>
+ <model-name>${MsoUtils.xmlEscape(modelName)}</model-name>
+ </onap-model-information>
+ </allotted-resource-information>
+ <connection-attachment-request-input>
+ <param>${MsoUtils.xmlEscape(netowrkInputParameters)}</param>
+ </connection-attachment-request-input>
+ </sdncadapterworkflow:SDNCRequestData>
+ </aetgt:SDNCAdapterWorkflowRequest>""".trim()
+ break
+
+ default:
+ sdncTopologyActivateRequest =
+ """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.onap/so/workflow/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>${MsoUtils.xmlEscape(hdrRequestId)}</sdncadapter:RequestId>
+ <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(serviceInstanceId)}</sdncadapter:SvcInstanceId>
+ <sdncadapter:SvcAction>${MsoUtils.xmlEscape(sdnc_svcAction)}</sdncadapter:SvcAction>
+ <sdncadapter:SvcOperation>network-topology-operation</sdncadapter:SvcOperation>
+ <sdncadapter:CallbackUrl>sdncCallback</sdncadapter:CallbackUrl>
+ <sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction>
+ </sdncadapter:RequestHeader>
+ <sdncadapterworkflow:SDNCRequestData>
+ <request-information>
+ <request-id>${MsoUtils.xmlEscape(hdrRequestId)}</request-id>
+ <request-action>${MsoUtils.xmlEscape(sdnc_requestAction)}</request-action>
+ <source>${MsoUtils.xmlEscape(source)}</source>
+ <notification-url></notification-url>
+ <order-number></order-number>
+ <order-version></order-version>
+ </request-information>
+ <service-information>
+ <service-id>${MsoUtils.xmlEscape(serviceInstanceId)}</service-id>
+ <subscription-service-type>${MsoUtils.xmlEscape(serviceType)}</subscription-service-type>
+ <onap-model-information>
+ <model-invariant-uuid>${MsoUtils.xmlEscape(serviceModelInvariantUuid)}</model-invariant-uuid>
+ <model-uuid>${MsoUtils.xmlEscape(serviceModelUuid)}</model-uuid>
+ <model-version>${MsoUtils.xmlEscape(serviceModelVersion)}</model-version>
+ <model-name>${MsoUtils.xmlEscape(serviceModelName)}</model-name>
+ </onap-model-information>
+ <service-instance-id>${MsoUtils.xmlEscape(serviceInstanceId)}</service-instance-id>
+ <global-customer-id>${MsoUtils.xmlEscape(globalCustomerId)}</global-customer-id>
+ </service-information>
+ <network-information>
+ <!-- TODO: to be filled by response from create -->
+ <network-id></network-id>
+ <onap-model-information>
+ <model-invariant-uuid>${MsoUtils.xmlEscape(modelInvariantUuid)}</model-invariant-uuid>
+ <model-customization-uuid>${MsoUtils.xmlEscape(modelCustomizationUuid)}</model-customization-uuid>
+ <model-uuid>${MsoUtils.xmlEscape(modelUuid)}</model-uuid>
+ <model-version>${MsoUtils.xmlEscape(modelVersion)}</model-version>
+ <model-name>${MsoUtils.xmlEscape(modelName)}</model-name>
+ </onap-model-information>
+ </network-information>
+ <network-request-input>
+ <network-input-parameters>${MsoUtils.xmlEscape(netowrkInputParameters)}</network-input-parameters>
+ </network-request-input>
+ </sdncadapterworkflow:SDNCRequestData>
+ </aetgt:SDNCAdapterWorkflowRequest>""".trim()
+
+ }
+
+ String sdncTopologyActivateRequesAsString = utils.formatXml(sdncTopologyActivateRequest)
+ msoLogger.debug(sdncTopologyActivateRequesAsString)
+ execution.setVariable("sdncAdapterWorkflowRequest", sdncTopologyActivateRequesAsString)
+ msoLogger.debug("sdncAdapterWorkflowRequest - " + "\n" + sdncTopologyActivateRequesAsString)
+
+ } catch (Exception ex) {
+ String exceptionMessage = " Bpmn error encountered in CreateSDNCCNetworkResource flow. prepareSDNCRequest() - " + ex.getMessage()
+ msoLogger.debug(exceptionMessage)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
+
+ }
+ msoLogger.trace("Exit prepareSDNCRequest ")
}
public void postCreateSDNCCall(DelegateExecution execution) {
msoLogger.trace("started postCreateSDNCCall ")
+
+ String responseCode = execution.getVariable(Prefix + "sdncCreateReturnCode")
+ String responseObj = execution.getVariable(Prefix + "SuccessIndicator")
+
+ msoLogger.info("response from sdnc, response code :" + responseCode + " response object :" + responseObj)
}
public void sendSyncResponse(DelegateExecution execution) {
msoLogger.trace("started sendSyncResponse ")
+
+ def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
+ utils.log("DEBUG", " *** sendSyncResponse *** ", isDebugEnabled)
+
+ try {
+ String operationStatus = "finished"
+ // RESTResponse for main flow
+ String resourceOperationResp = """{"operationStatus":"${operationStatus}"}""".trim()
+ utils.log("DEBUG", " sendSyncResponse to APIH:" + "\n" + resourceOperationResp, isDebugEnabled)
+ sendWorkflowResponse(execution, 202, resourceOperationResp)
+ execution.setVariable("sentSyncResponse", true)
+
+ } catch (Exception ex) {
+ String msg = "Exceptuion in sendSyncResponse:" + ex.getMessage()
+ utils.log("DEBUG", msg, isDebugEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ utils.log("DEBUG"," ***** Exit sendSyncResopnse *****", isDebugEnabled)
}
} \ No newline at end of file
diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Create3rdONAPE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Create3rdONAPE2EServiceInstance.groovy
index a2f4e35df1..fb21574fdd 100644
--- a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Create3rdONAPE2EServiceInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Create3rdONAPE2EServiceInstance.groovy
@@ -4,7 +4,7 @@
* ================================================================================
* Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved.
* ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
+ * 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
*
@@ -18,12 +18,12 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.so.bpmn.infrastructure.scripts;
+package org.onap.so.bpmn.infrastructure.scripts
import org.json.JSONObject
-import org.json.XML;
+import org.json.XML
-import static org.apache.commons.lang3.StringUtils.*;
+import static org.apache.commons.lang3.StringUtils.*
import groovy.xml.XmlUtil
import groovy.json.*
import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
@@ -31,7 +31,7 @@ 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.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
@@ -39,13 +39,14 @@ import org.onap.so.bpmn.infrastructure.workflow.serviceTask.client.builder.Abstr
import org.onap.so.rest.APIResponse
import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils
import org.onap.so.bpmn.infrastructure.workflow.service.ServicePluginFactory
-import java.util.UUID;
+import java.util.UUID
+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.apache.commons.codec.binary.Base64
import org.springframework.web.util.UriUtils
import org.onap.so.rest.RESTClient
import org.onap.so.rest.RESTConfig
@@ -56,24 +57,25 @@ import org.onap.so.rest.RESTConfig
*/
public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcessor {
- String Prefix="CRE3rdONAPESI_"
+ String Prefix = "CRE3rdONAPESI_"
ExceptionUtil exceptionUtil = new ExceptionUtil()
JsonUtils jsonUtil = new JsonUtils()
+
+ private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, Create3rdONAPE2EServiceInstance.class)
public void checkSPPartnerInfo (DelegateExecution execution) {
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- utils.log("INFO"," ***** Started checkSPPartnerInfo *****", isDebugEnabled)
+ msoLogger.info(" ***** Started checkSPPartnerInfo *****")
try {
//get bpmn inputs from resource request.
String requestId = execution.getVariable("mso-request-id")
String requestAction = execution.getVariable("requestAction")
- utils.log("INFO","The requestAction is: " + requestAction, isDebugEnabled)
+ msoLogger.info("The requestAction is: " + requestAction)
String recipeParamsFromRequest = execution.getVariable("recipeParams")
- utils.log("INFO","The recipeParams is: " + recipeParamsFromRequest, isDebugEnabled)
+ msoLogger.info("The recipeParams is: " + recipeParamsFromRequest)
String resourceInput = execution.getVariable("resourceInput")
- utils.log("INFO","The resourceInput is: " + resourceInput, isDebugEnabled)
+ msoLogger.info("The resourceInput is: " + resourceInput)
//Get ResourceInput Object
ResourceInput resourceInputObj = ResourceRequestBuilder.getJsonObject(resourceInput, ResourceInput.class)
String resourceInputPrameters = resourceInputObj.getResourceParameters()
@@ -81,7 +83,7 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
JSONObject inputParameters = new JSONObject(customizeResourceParam(inputParametersJson))
// set local resourceInput
- execution.setVariable(Prefix + "resourceInput", resourceInputObj)
+ execution.setVariable(Prefix + "ResourceInput", resourceInputObj)
boolean is3rdONAPExist = false
@@ -93,163 +95,161 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
{
String sppartnerUrl = inputParameters.get("url")
if(!isBlank(sppartnerUrl)) {
- execution.setVariable(Prefix + "sppartnerUrl", sppartnerUrl)
+ execution.setVariable(Prefix + "SppartnerUrl", sppartnerUrl)
is3rdONAPExist = true
}
else {
is3rdONAPExist = false
String msg = "sppartner Url is blank."
- utils.log("DEBUG", msg, isDebugEnabled)
+ msoLogger.debug(msg)
}
}
if(inputParameters.has("providingServiceInvarianteUuid"))
{
String sppartnerInvarianteUUID = inputParameters.get("providingServiceInvarianteUuid")
- execution.setVariable(Prefix + "sppartnerInvarianteUUID", sppartnerInvarianteUUID)
+ execution.setVariable(Prefix + "SppartnerInvarianteUUID", sppartnerInvarianteUUID)
is3rdONAPExist = true
}
else {
is3rdONAPExist = false
String msg = "sppartner providingServiceInvarianteUuid is blank."
- utils.log("DEBUG", msg, isDebugEnabled)
+ msoLogger.debug(msg)
}
if(inputParameters.has("providingServiceUuid"))
{
String sppartnerUUID = inputParameters.get("providingServiceUuid")
- execution.setVariable(Prefix + "sppartnerUUID", sppartnerUUID)
+ execution.setVariable(Prefix + "SppartnerUUID", sppartnerUUID)
is3rdONAPExist = true
}
else {
is3rdONAPExist = false
String msg = "sppartner providingServiceUuid is blank."
- utils.log("DEBUG", msg, isDebugEnabled)
+ msoLogger.debug(msg)
}
if(inputParameters.has("handoverMode"))
{
String handoverMode = inputParameters.get("handoverMode")
- execution.setVariable(Prefix + "handoverMode", handoverMode)
+ execution.setVariable(Prefix + "HandoverMode", handoverMode)
is3rdONAPExist = true
}
else {
is3rdONAPExist = false
String msg = "sppartner handoverMode is blank."
- utils.log("DEBUG", msg, isDebugEnabled)
+ msoLogger.debug(msg)
}
execution.setVariable("Is3rdONAPExist", is3rdONAPExist)
- execution.setVariable(Prefix + "serviceInstanceId", resourceInputObj.getServiceInstanceId())
+ execution.setVariable(Prefix + "ServiceInstanceId", resourceInputObj.getServiceInstanceId())
execution.setVariable("mso-request-id", requestId)
execution.setVariable("mso-service-instance-id", resourceInputObj.getServiceInstanceId())
} catch (BpmnError e) {
- throw e;
+ throw e
} catch (Exception ex){
String msg = "Exception in checkSPPartnerInfo " + ex.getMessage()
- utils.log("DEBUG", msg, isDebugEnabled)
+ msoLogger.debug(msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
}
}
public void checkLocallCall (DelegateExecution execution) {
def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- utils.log("INFO"," ***** Started checkLocallCall *****", isDebugEnabled)
+ 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()
String serviceParameters = jsonUtil.getJsonValue(incomingRequest, "service.parameters")
JSONObject inputParameters = new JSONObject(customizeResourceParam(serviceParameters))
- execution.setVariable(Prefix + "serviceParameters", inputParameters)
+ execution.setVariable(Prefix + "ServiceParameters", inputParameters)
- // CallSource is added only when ONAP SO calling 3rdONAP SO(Remote call)
+ // CallSource is added only when ONAP SO calling 3rdONAP(External API) SO(Remote call)
boolean isLocalCall = true
+ String callSource = "UUI"
if(inputParameters.has("CallSource"))
{
- String callSource = inputParameters.get("CallSource")
- if("3rdONAP".equalsIgnoreCase(callSource)) {
+ callSource = inputParameters.get("CallSource")
+ if("ExternalAPI".equalsIgnoreCase(callSource)) {
isLocalCall = false
- }
- execution.setVariable(Prefix + "CallSource", callSource)
- utils.log("DEBUG", "callSource is: " + callSource , isDebugEnabled)
- isLocalCall = true
+ }
}
+ execution.setVariable(Prefix + "CallSource", callSource)
+ msoLogger.debug("callSource is: " + callSource )
execution.setVariable("IsLocalCall", isLocalCall)
- } catch (BpmnError e) {
- throw e;
} catch (Exception ex){
String msg = "Exception in checkLocallCall " + ex.getMessage()
- utils.log("DEBUG", msg, isDebugEnabled)
+ msoLogger.debug(msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
}
}
public void preProcessRequest(DelegateExecution execution){
def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- utils.log("INFO"," ***** Started preProcessRequest *****", isDebugEnabled)
+ msoLogger.info(" ***** Started preProcessRequest *****")
try {
- ResourceInput resourceInputObj = execution.getVariable(Prefix + "resourceInput")
+ ResourceInput resourceInputObj = execution.getVariable(Prefix + "ResourceInput")
String msg = ""
String globalSubscriberId = resourceInputObj.getGlobalSubscriberId()
if (isBlank(globalSubscriberId)) {
msg = "Input globalSubscriberId is null"
- utils.log("INFO", msg, isDebugEnabled)
+ msoLogger.info(msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
}
//set local variable
- execution.setVariable("globalSubscriberId", globalSubscriberId);
- utils.log("INFO", "globalSubscriberId:" + globalSubscriberId, isDebugEnabled)
+ execution.setVariable("globalSubscriberId", globalSubscriberId)
+ msoLogger.info("globalSubscriberId:" + globalSubscriberId)
String serviceType = resourceInputObj.getServiceType()
if (isBlank(serviceType)) {
msg = "Input serviceType is null"
- utils.log("INFO", msg, isDebugEnabled)
+ msoLogger.info(msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
}
execution.setVariable("serviceType", serviceType)
- utils.log("INFO", "serviceType:" + serviceType, isDebugEnabled)
+ msoLogger.info("serviceType:" + serviceType)
- String resourceName = resourceInputObj.getResourceInstanceName();
+ String resourceName = resourceInputObj.getResourceInstanceName()
if (isBlank(resourceName)) {
msg = "Input resourceName is null"
- utils.log("INFO", msg, isDebugEnabled)
+ msoLogger.info(msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
}
execution.setVariable("resourceName", resourceName)
- utils.log("INFO", "resourceName:" + resourceName, isDebugEnabled)
+ msoLogger.info("resourceName:" + resourceName)
int beginIndex = resourceName.indexOf("_") + 1
String serviceInstanceName = resourceName.substring(beginIndex)
execution.setVariable("serviceInstanceName", serviceInstanceName)
- String serviceInstanceId = resourceInputObj.getServiceInstanceId();
+ String serviceInstanceId = resourceInputObj.getServiceInstanceId()
if (isBlank(serviceInstanceId)) {
msg = "Input serviceInstanceId is null"
- utils.log("INFO", msg, isDebugEnabled)
+ msoLogger.info(msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
}
execution.setVariable("serviceInstanceId", serviceInstanceId)
- utils.log("INFO", "serviceInstanceId:" + serviceInstanceId, isDebugEnabled)
+ msoLogger.info("serviceInstanceId:" + serviceInstanceId)
} catch (BpmnError e) {
- throw e;
+ throw e
} catch (Exception ex){
String msg = "Exception in preProcessRequest " + ex.getMessage()
- utils.log("DEBUG", msg, isDebugEnabled)
+ msoLogger.debug(msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
}
}
public void prepareUpdateProgress(DelegateExecution execution) {
def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- utils.log("INFO"," ***** Started prepareUpdateProgress *****", isDebugEnabled)
- ResourceInput resourceInputObj = execution.getVariable(Prefix + "resourceInput")
+ msoLogger.info(" ***** Started prepareUpdateProgress *****")
+ ResourceInput resourceInputObj = execution.getVariable(Prefix + "ResourceInput")
String operType = resourceInputObj.getOperationType()
String resourceCustomizationUuid = resourceInputObj.getResourceModelInfo().getModelCustomizationUuid()
String ServiceInstanceId = resourceInputObj.getServiceInstanceId()
@@ -274,18 +274,18 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
<statusDescription>${statusDescription}</statusDescription>
</ns:updateResourceOperationStatus>
</soapenv:Body>
- </soapenv:Envelope>""";
+ </soapenv:Envelope>"""
setProgressUpdateVariables(execution, body)
- utils.log("INFO"," ***** End prepareUpdateProgress *****", isDebugEnabled)
+ msoLogger.info(" ***** Exit prepareUpdateProgress *****")
}
public void allocateCrossONAPResource(DelegateExecution execution) {
def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- utils.log("INFO"," ***** Started allocateCrossONAPResource *****", isDebugEnabled)
+ msoLogger.info(" ***** Started allocateCrossONAPResource *****")
//get TP links from AAI for SOTN handoverMode only
- String handoverMode = execution.getVariable(Prefix + "handoverMode")
+ String handoverMode = execution.getVariable(Prefix + "HandoverMode")
if("SOTN".equalsIgnoreCase(handoverMode)) {
//to do get tp link in AAI
@@ -296,29 +296,29 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
String accessTopologyId = ""
String accessNodeId = ""
String accessLtpId = ""
- JSONObject inputParameters = execution.getVariable(Prefix + "serviceParameters")
+ JSONObject inputParameters = execution.getVariable(Prefix + "ServiceParameters")
inputParameters.put("access-provider-id", accessProviderId)
inputParameters.put("access-client-id", accessClientId)
inputParameters.put("access-topology-id", accessTopologyId)
inputParameters.put("access-node-id", accessNodeId)
inputParameters.put("access-ltp-id", accessLtpId)
- execution.setVariable(Prefix + "serviceParameters", inputParameters)
+ execution.setVariable(Prefix + "ServiceParameters", inputParameters)
}
- utils.log("INFO", "Exited " + allocateCrossONAPResource, isDebugEnabled)
+ msoLogger.info("Exit " + allocateCrossONAPResource)
}
public void prepare3rdONAPRequest(DelegateExecution execution) {
def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- utils.log("INFO"," ***** Started prepare3rdONAPRequest *****", isDebugEnabled)
+ msoLogger.info(" ***** Started prepare3rdONAPRequest *****")
- String sppartnerUrl = execution.getVariable(Prefix + "sppartnerUrl")
+ String sppartnerUrl = execution.getVariable(Prefix + "SppartnerUrl")
String extAPIPath = sppartnerUrl + 'serviceOrder'
execution.setVariable("ExternalAPIURL", extAPIPath)
// ExternalAPI message format
String externalId = execution.getVariable("resourceName")
- String category = "Network Service"
+ String category = "E2E Service"
String description = "Service Order from SPPartner"
String requestedStartDate = utils.generateCurrentTimeInUtc()
String requestedCompletionDate = utils.generateCurrentTimeInUtc()
@@ -352,17 +352,17 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
ExternalAPIUtil externalAPIUtil = new ExternalAPIUtil(this)
- // insert CallSource='3rdONAP' to uuiRequest
+ // insert CallSource='ExternalAPI' to uuiRequest
Map<String, String> callSourceMap = new HashMap<>()
callSourceMap.put("inputName", "CallSource")
- callSourceMap.put("inputValue", "3rdONAP")
+ callSourceMap.put("inputValue", "ExternalAPI")
String _requestInputs_ = externalAPIUtil.setTemplate(ExternalAPIUtil.RequestInputsTemplate, callSourceMap)
// Transfer all uuiRequest incomeParameters to ExternalAPI format
- JSONObject inputParameters = execution.getVariable(Prefix + "serviceParameters")
+ JSONObject inputParameters = execution.getVariable(Prefix + "ServiceParameters")
for(String key : inputParameters.keySet()) {
- String inputName = key;
- String inputValue = inputParameters.opt(key);
+ String inputName = key
+ String inputValue = inputParameters.opt(key)
Map<String, String> requestInputsMap = new HashMap<>()
requestInputsMap.put("inputName", '"' + inputName+ '"')
requestInputsMap.put("inputValue", '"' + inputValue + '"')
@@ -371,49 +371,49 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
valueMap.put("_requestInputs_", _requestInputs_)
String payload = externalAPIUtil.setTemplate(ExternalAPIUtil.PostServiceOrderRequestsTemplate, valueMap)
- execution.setVariable(Prefix + "payload", payload)
- utils.log("INFO", "Exited " + prepare3rdONAPRequest, isDebugEnabled)
+ execution.setVariable(Prefix + "Payload", payload)
+ msoLogger.info("Exit " + prepare3rdONAPRequest)
}
public void doCreateE2ESIin3rdONAP(DelegateExecution execution) {
def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- utils.log("INFO"," ***** Started doCreateE2ESIin3rdONAP *****", isDebugEnabled)
+ msoLogger.info(" ***** Started doCreateE2ESIin3rdONAP *****")
String extAPIPath = execution.getVariable("ExternalAPIURL")
- String payload = execution.getVariable(Prefix + "payload")
+ String payload = execution.getVariable(Prefix + "Payload")
ExternalAPIUtil externalAPIUtil = new ExternalAPIUtil(this)
APIResponse response = externalAPIUtil.executeExternalAPIPostCall(execution, extAPIPath, payload)
int responseCode = response.getStatusCode()
- execution.setVariable(Prefix + "postServiceOrderResponseCode", responseCode)
- utils.log("DEBUG", "Post ServiceOrder response code is: " + responseCode, isDebugEnabled)
+ execution.setVariable(Prefix + "PostServiceOrderResponseCode", responseCode)
+ msoLogger.debug("Post ServiceOrder response code is: " + responseCode)
String extApiResponse = response.getResponseBodyAsString()
JSONObject responseObj = new JSONObject(extApiResponse)
- execution.setVariable(Prefix + "postServiceOrderResponse", extApiResponse)
+ execution.setVariable(Prefix + "PostServiceOrderResponse", extApiResponse)
//Process Response
if(responseCode == 200 || responseCode == 201 || responseCode == 202 )
//200 OK 201 CREATED 202 ACCEPTED
{
- utils.log("DEBUG", "Post ServiceOrder Received a Good Response", isDebugEnabled)
+ msoLogger.debug("Post ServiceOrder Received a Good Response")
String serviceOrderId = responseObj.get("ServiceOrderId")
execution.setVariable(Prefix + "SuccessIndicator", true)
execution.setVariable("serviceOrderId", serviceOrderId)
}
else{
- utils.log("DEBUG", "Post ServiceOrder Received a Bad Response Code. Response Code is: " + responseCode, isDebugEnabled)
+ msoLogger.debug("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")
}
- utils.log("INFO", "Exited " + doCreateE2ESIin3rdONAP, isDebugEnabled)
+ msoLogger.info("Exit " + doCreateE2ESIin3rdONAP)
}
public void getE2ESIProgressin3rdONAP(DelegateExecution execution) {
def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- utils.log("INFO"," ***** Started getE2ESIProgressin3rdONAP *****", isDebugEnabled)
+ msoLogger.info(" ***** Started getE2ESIProgressin3rdONAP *****")
String extAPIPath = execution.getVariable("ExternalAPIURL")
extAPIPath += "/" + execution.getVariable("ServiceOrderId")
@@ -423,17 +423,17 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
APIResponse response = externalAPIUtil.executeExternalAPIGetCall(execution, extAPIPath)
int responseCode = response.getStatusCode()
- execution.setVariable(Prefix + "getServiceOrderResponseCode", responseCode)
- utils.log("DEBUG", "Get ServiceOrder response code is: " + responseCode, isDebugEnabled)
+ execution.setVariable(Prefix + "GetServiceOrderResponseCode", responseCode)
+ msoLogger.debug("Get ServiceOrder response code is: " + responseCode)
String extApiResponse = response.getResponseBodyAsString()
JSONObject responseObj = new JSONObject(extApiResponse)
- execution.setVariable(Prefix + "getServiceOrderResponse", extApiResponse)
+ execution.setVariable(Prefix + "GetServiceOrderResponse", extApiResponse)
//Process Response //200 OK 201 CREATED 202 ACCEPTED
if(responseCode == 200 || responseCode == 201 || responseCode == 202 )
{
- utils.log("DEBUG", "Get ServiceOrder Received a Good Response", isDebugEnabled)
+ msoLogger.debug("Get ServiceOrder Received a Good Response")
String serviceOrderState = responseObj.get("State")
execution.setVariable(Prefix + "SuccessIndicator", true)
execution.setVariable("serviceOrderState", serviceOrderState)
@@ -463,14 +463,14 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
execution.setVariable("statusDescription", "Create Service Order Status is " + serviceOrderState)
}
else{
- utils.log("DEBUG", "Get ServiceOrder Received a Bad Response Code. Response Code is: " + responseCode, isDebugEnabled)
+ 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 ServiceOrder Received a bad response")
exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Get ServiceOrder Received a bad response from 3rdONAP External API")
}
- utils.log("INFO", "Exited " + getE2ESIProgressin3rdONAP, isDebugEnabled)
+ msoLogger.info("Exit " + getE2ESIProgressin3rdONAP)
}
/**
@@ -479,18 +479,19 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
public void timeDelay(DelegateExecution execution) {
def isDebugEnabled= execution.getVariable("isDebugLogEnabled")
try {
- Thread.sleep(5000);
+ Thread.sleep(5000)
} catch(InterruptedException e) {
- utils.log("ERROR", "Time Delay exception" + e , isDebugEnabled)
+ utils.log("ERROR", "Time Delay exception" + e )
}
}
public void saveSPPartnerInAAI(DelegateExecution execution) {
def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- utils.log("INFO"," ***** Started postCreateE2ESIin3rdONAP *****", isDebugEnabled)
+ msoLogger.info(" ***** Started postCreateE2ESIin3rdONAP *****")
String sppartnerId = UUID.randomUUID().toString()
- String sppartnerUrl = execution.getVariable(Prefix + "sppartnerUrl")
+ String sppartnerUrl = execution.getVariable(Prefix + "SppartnerUrl")
+ String callSource = execution.getVariable(Prefix + "CallSource")
String serviceInstanceId = execution.getVariable("serviceInstanceId")
AaiUtil aaiUriUtil = new AaiUtil(this)
@@ -501,6 +502,7 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
"""<sp-partner xmlns=\"${namespace}\">
<id>${sppartnerId}</id>
<url>${sppartnerUrl}</url>
+ <callSource>${callSource}</callSource>
<service-instance>
<service-instance-id>${serviceInstanceId}</service-instance-id>
</service-instance>
@@ -512,28 +514,28 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
APIResponse response = aaiUriUtil.executeAAIPutCall(execution, serviceAaiPath, payload)
int responseCode = response.getStatusCode()
- execution.setVariable(Prefix + "putSppartnerResponseCode", responseCode)
- utils.log("DEBUG", " Put sppartner response code is: " + responseCode, isDebugEnabled)
+ execution.setVariable(Prefix + "PutSppartnerResponseCode", responseCode)
+ msoLogger.debug(" Put sppartner response code is: " + responseCode)
String aaiResponse = response.getResponseBodyAsString()
aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse)
- execution.setVariable(Prefix + "putSppartnerResponse", aaiResponse)
+ execution.setVariable(Prefix + "PutSppartnerResponse", aaiResponse)
//Process Response
if(responseCode == 200 || responseCode == 201 || responseCode == 202 )
//200 OK 201 CREATED 202 ACCEPTED
{
- utils.log("DEBUG", "PUT sppartner Received a Good Response", isDebugEnabled)
+ msoLogger.debug("PUT sppartner Received a Good Response")
execution.setVariable(Prefix + "SuccessIndicator", true)
}
else
{
- utils.log("DEBUG", "Put sppartner Received a Bad Response Code. Response Code is: " + responseCode, isDebugEnabled)
+ msoLogger.debug("Put sppartner Received a Bad Response Code. Response Code is: " + responseCode)
exceptionUtil.MapAAIExceptionToWorkflowExceptionGeneric(execution, aaiResponse, responseCode)
throw new BpmnError("MSOWorkflowException")
}
- utils.log("INFO", "Exited " + saveSPPartnerInAAI, isDebugEnabled)
+ msoLogger.info("Exit " + saveSPPartnerInAAI)
}
private void setProgressUpdateVariables(DelegateExecution execution, String body) {
@@ -544,48 +546,48 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso
public void postProcess(DelegateExecution execution){
def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- utils.log("INFO"," ***** Started postProcess *****", isDebugEnabled)
- String responseCode = execution.getVariable(Prefix + "putSppartnerResponseCode")
- String responseObj = execution.getVariable(Prefix + "putSppartnerResponse")
+ msoLogger.info(" ***** Started postProcess *****")
+ String responseCode = execution.getVariable(Prefix + "PutSppartnerResponseCode")
+ String responseObj = execution.getVariable(Prefix + "PutSppartnerResponse")
- utils.log("INFO","response from AAI for put sppartner, response code :" + responseCode + " response object :" + responseObj, isDebugEnabled)
- utils.log("INFO"," ***** Exit postProcess *****", isDebugEnabled)
+ msoLogger.info("response from AAI for put sppartner, response code :" + responseCode + " response object :" + responseObj)
+ msoLogger.info(" ***** Exit postProcess *****")
}
public void sendSyncResponse (DelegateExecution execution) {
def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- utils.log("DEBUG", " *** sendSyncResponse *** ", isDebugEnabled)
+ msoLogger.debug(" *** sendSyncResponse *** ")
try {
String operationStatus = "finished"
// RESTResponse for main flow
String resourceOperationResp = """{"operationStatus":"${operationStatus}"}""".trim()
- utils.log("DEBUG", " sendSyncResponse to APIH:" + "\n" + resourceOperationResp, isDebugEnabled)
+ msoLogger.debug(" sendSyncResponse to APIH:" + "\n" + resourceOperationResp)
sendWorkflowResponse(execution, 202, resourceOperationResp)
execution.setVariable("sentSyncResponse", true)
} catch (Exception ex) {
String msg = "Exceptuion in sendSyncResponse:" + ex.getMessage()
- utils.log("DEBUG", msg, isDebugEnabled)
+ msoLogger.debug(msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
}
- utils.log("DEBUG"," ***** Exit sendSyncResopnse *****", isDebugEnabled)
+ msoLogger.debug(" ***** Exit sendSyncResopnse *****")
}
String customizeResourceParam(String inputParametersJson) {
- List<Map<String, Object>> paramList = new ArrayList();
- JSONObject jsonObject = new JSONObject(inputParametersJson);
- Iterator iterator = jsonObject.keys();
+ List<Map<String, Object>> paramList = new ArrayList()
+ JSONObject jsonObject = new JSONObject(inputParametersJson)
+ Iterator iterator = jsonObject.keys()
while (iterator.hasNext()) {
- String key = iterator.next();
- HashMap<String, String> hashMap = new HashMap();
- hashMap.put("name", key);
+ String key = iterator.next()
+ HashMap<String, String> hashMap = new HashMap()
+ hashMap.put("name", key)
hashMap.put("value", jsonObject.get(key))
paramList.add(hashMap)
}
- Map<String, List<Map<String, Object>>> paramMap = new HashMap();
- paramMap.put("param", paramList);
+ Map<String, List<Map<String, Object>>> paramMap = new HashMap()
+ paramMap.put("param", paramList)
- return new JSONObject(paramMap).toString();
+ return new JSONObject(paramMap).toString()
}
}
diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy
index 1c0975f8c4..c819da4be4 100644
--- a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy
+++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy
@@ -109,9 +109,9 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor {
}
}
- String customizeResourceParam(String netowrkInputParametersJson) {
+ String customizeResourceParam(String networkInputParametersJson) {
List<Map<String, Object>> paramList = new ArrayList();
- JSONObject jsonObject = new JSONObject(netowrkInputParametersJson);
+ JSONObject jsonObject = new JSONObject(networkInputParametersJson);
Iterator iterator = jsonObject.keys();
while (iterator.hasNext()) {
String key = iterator.next();
@@ -159,12 +159,134 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor {
String modelName = resourceInputObj.getResourceModelInfo().getModelName()
String modelVersion = resourceInputObj.getResourceModelInfo().getModelVersion()
String resourceInputPrameters = resourceInputObj.getResourceParameters()
- String netowrkInputParametersJson = jsonUtil.getJsonValue(resourceInputPrameters, "requestInputs")
+ String networkInputParametersJson = jsonUtil.getJsonValue(resourceInputPrameters, "requestInputs")
//here convert json string to xml string
- String netowrkInputParameters = XML.toString(new JSONObject(customizeResourceParam(netowrkInputParametersJson)))
+ String netowrkInputParameters = XML.toString(new JSONObject(customizeResourceParam(networkInputParametersJson)))
// 1. prepare assign topology via SDNC Adapter SUBFLOW call
- String sndcTopologyCreateRequest =
- """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1"
+ String sdncTopologyCreateRequest = ""
+
+ switch (modelName) {
+ case ~/^Site$/:
+ sdncTopologyCreateRequest = """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.onap/so/workflow/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>${MsoUtils.xmlEscape(hdrRequestId)}</sdncadapter:RequestId>
+ <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(serviceInstanceId)}</sdncadapter:SvcInstanceId>
+ <sdncadapter:SvcAction>${MsoUtils.xmlEscape(sdnc_svcAction)}</sdncadapter:SvcAction>
+ <sdncadapter:SvcOperation>network-topology-operation</sdncadapter:SvcOperation>
+ <sdncadapter:CallbackUrl>sdncCallback</sdncadapter:CallbackUrl>
+ <sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction>
+ </sdncadapter:RequestHeader>
+ <sdncadapterworkflow:SDNCRequestData>
+ <request-information>
+ <request-id>${MsoUtils.xmlEscape(hdrRequestId)}</request-id>
+ <request-action>${MsoUtils.xmlEscape(sdnc_requestAction)}</request-action>
+ <source>${MsoUtils.xmlEscape(source)}</source>
+ <notification-url></notification-url>
+ <order-number></order-number>
+ <order-version></order-version>
+ </request-information>
+ <service-information>
+ <service-id>${MsoUtils.xmlEscape(serviceInstanceId)}</service-id>
+ <subscription-service-type>${MsoUtils.xmlEscape(serviceType)}</subscription-service-type>
+ <onap-model-information>
+ <model-invariant-uuid>${MsoUtils.xmlEscape(serviceModelInvariantUuid)}</model-invariant-uuid>
+ <model-uuid>${MsoUtils.xmlEscape(serviceModelUuid)}</model-uuid>
+ <model-version>${MsoUtils.xmlEscape(serviceModelVersion)}</model-version>
+ <model-name>${MsoUtils.xmlEscape(serviceModelName)}</model-name>
+ </onap-model-information>
+ <service-instance-id>${MsoUtils.xmlEscape(serviceInstanceId)}</service-instance-id>
+ <global-customer-id>${MsoUtils.xmlEscape(globalCustomerId)}</global-customer-id>
+ </service-information>
+ <subscriber-name>${MsoUtils.xmlEscape(globalCustomerId)}</subscriber-name>
+ <vnf-information>
+ <!-- TODO: to be filled as per the request input -->
+ <vnf-id></vnf-id>
+ <vnf-type></vnf-type>
+ <onap-model-information>
+ <model-invariant-uuid>${MsoUtils.xmlEscape(modelInvariantUuid)}</model-invariant-uuid>
+ <model-customization-uuid>${MsoUtils.xmlEscape(modelCustomizationUuid)}</model-customization-uuid>
+ <model-uuid>${MsoUtils.xmlEscape(modelUuid)}</model-uuid>
+ <model-version>${MsoUtils.xmlEscape(modelVersion)}</model-version>
+ <model-name>${MsoUtils.xmlEscape(modelName)}</model-name>
+ </onap-model-information>
+ </network-information>
+ <vnf-input-parameters>
+ <network-input-parameters>${MsoUtils.xmlEscape(netowrkInputParameters)}</network-input-parameters>
+ </vnf-input-parameters>
+ <vnf-request-input>
+ <request-version></request-version>
+ <vnf-name></vnf-name>
+ <neutron-id></neutron-id>
+ <contrail-network-fqdn></contrail-network-fqdn>
+ <subnets-data>
+ <subnet-data>
+ <element>
+ <ip-version></ip-version>
+ <subnet-id></subnet-id>
+ </subnet-data>
+ </subnets-data>
+ </vnf-request-input>
+ </sdncadapterworkflow:SDNCRequestData>
+ </aetgt:SDNCAdapterWorkflowRequest>""".trim()
+ break
+
+ case ~/^SOTNAttachment$/:
+ sdncTopologyCreateRequest = """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.onap/so/workflow/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>${MsoUtils.xmlEscape(hdrRequestId)}</sdncadapter:RequestId>
+ <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(serviceInstanceId)}</sdncadapter:SvcInstanceId>
+ <sdncadapter:SvcAction>${MsoUtils.xmlEscape(sdnc_svcAction)}</sdncadapter:SvcAction>
+ <sdncadapter:SvcOperation>network-topology-operation</sdncadapter:SvcOperation>
+ <sdncadapter:CallbackUrl>sdncCallback</sdncadapter:CallbackUrl>
+ <sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction>
+ </sdncadapter:RequestHeader>
+ <sdncadapterworkflow:SDNCRequestData>
+ <request-information>
+ <request-id>${MsoUtils.xmlEscape(hdrRequestId)}</request-id>
+ <request-action>${MsoUtils.xmlEscape(sdnc_requestAction)}</request-action>
+ <source>${MsoUtils.xmlEscape(source)}</source>
+ <notification-url></notification-url>
+ <order-number></order-number>
+ <order-version></order-version>
+ </request-information>
+ <service-information>
+ <service-id>${MsoUtils.xmlEscape(serviceInstanceId)}</service-id>
+ <subscription-service-type>${MsoUtils.xmlEscape(serviceType)}</subscription-service-type>
+ <onap-model-information>
+ <model-invariant-uuid>${MsoUtils.xmlEscape(serviceModelInvariantUuid)}</model-invariant-uuid>
+ <model-uuid>${MsoUtils.xmlEscape(serviceModelUuid)}</model-uuid>
+ <model-version>${MsoUtils.xmlEscape(serviceModelVersion)}</model-version>
+ <model-name>${MsoUtils.xmlEscape(serviceModelName)}</model-name>
+ </onap-model-information>
+ <service-instance-id>${MsoUtils.xmlEscape(serviceInstanceId)}</service-instance-id>
+ <global-customer-id>${MsoUtils.xmlEscape(globalCustomerId)}</global-customer-id>
+ </service-information>
+ <subscriber-name>${MsoUtils.xmlEscape(globalCustomerId)}</subscriber-name>
+ <allotted-resource-information>
+ <!-- TODO: to be filled as per the request input -->
+ <allotted-resource-type></allotted-resource-type>
+ <parent-service-instance-id><parent-service-instance-id>
+ <onap-model-information>
+ <model-invariant-uuid>${MsoUtils.xmlEscape(modelInvariantUuid)}</model-invariant-uuid>
+ <model-customization-uuid>${MsoUtils.xmlEscape(modelCustomizationUuid)}</model-customization-uuid>
+ <model-uuid>${MsoUtils.xmlEscape(modelUuid)}</model-uuid>
+ <model-version>${MsoUtils.xmlEscape(modelVersion)}</model-version>
+ <model-name>${MsoUtils.xmlEscape(modelName)}</model-name>
+ </onap-model-information>
+ </allotted-resource-information>
+ <connection-attachment-request-input>
+ <param>${MsoUtils.xmlEscape(netowrkInputParameters)}</param>
+ </connection-attachment-request-input>
+ </sdncadapterworkflow:SDNCRequestData>
+ </aetgt:SDNCAdapterWorkflowRequest>""".trim()
+ break
+
+ 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:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1">
<sdncadapter:RequestHeader>
@@ -210,8 +332,9 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor {
</network-request-input>
</sdncadapterworkflow:SDNCRequestData>
</aetgt:SDNCAdapterWorkflowRequest>""".trim()
+ }
- String sndcTopologyCreateRequesAsString = utils.formatXml(sndcTopologyCreateRequest)
+ String sndcTopologyCreateRequesAsString = utils.formatXml(sdncTopologyCreateRequest)
msoLogger.debug(sndcTopologyCreateRequesAsString)
execution.setVariable("sdncAdapterWorkflowRequest", sndcTopologyCreateRequesAsString)
msoLogger.debug("sdncAdapterWorkflowRequest - " + "\n" + sndcTopologyCreateRequesAsString)
diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeActivateNetworkResource.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeActivateNetworkResource.groovy
deleted file mode 100644
index 52249f0300..0000000000
--- a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeActivateNetworkResource.groovy
+++ /dev/null
@@ -1,89 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * OPENECOMP - SO
- * ================================================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.bpmn.infrastructure.scripts
-
-import org.apache.commons.lang3.StringUtils
-import org.camunda.bpm.engine.delegate.BpmnError
-import org.json.JSONObject
-import org.json.XML
-import org.openecomp.mso.bpmn.common.recipe.ResourceInput
-import org.openecomp.mso.bpmn.common.resource.ResourceRequestBuilder
-import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor
-import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.openecomp.mso.bpmn.core.json.JsonUtils
-import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
-import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils
-
-/**
- * This groovy class supports the <class>ActivateSDNCCNetworkResource.bpmn</class> process.
- * flow for SDNC Network Resource Activate
- */
-public class DeActivateSDNCNetworkResource extends AbstractServiceTaskProcessor {
-
- String Prefix = "ACTSDNCRES_"
-
- ExceptionUtil exceptionUtil = new ExceptionUtil()
-
- JsonUtils jsonUtil = new JsonUtils()
-
- SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
-
- public void preProcessRequest(DelegateExecution execution) {
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- utils.log("INFO"," ***** started preProcessRequest*****", isDebug)
- }
-
- public void prepareSDNCRequest(DelegateExecution execution) {
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- utils.log("INFO"," ***** started prepareSDNCRequest *****", isDebug)
- }
-
- public void prepareUpdateAfterDeActivateSDNCResource(DelegateExecution execution) {
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- utils.log("INFO"," ***** started prepareUpdateAfterDeActivateSDNCResource *****", isDebug)
- }
-
- public void postDeactivateSDNCCall(DelegateExecution execution) {
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- utils.log("INFO"," ***** started postDeactivateSDNCCall *****", isDebugEnabled)
- }
-
- public void sendSyncResponse(DelegateExecution execution) {
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- utils.log("INFO"," ***** started sendSyncResponse *****", isDebugEnabled)
-
- try {
- String operationStatus = "finished"
- // RESTResponse for main flow
- String resourceOperationResp = """{"operationStatus":"${operationStatus}"}""".trim()
- utils.log("DEBUG", " sendSyncResponse to APIH:" + "\n" + resourceOperationResp, isDebugEnabled)
- sendWorkflowResponse(execution, 202, resourceOperationResp)
- execution.setVariable("sentSyncResponse", true)
-
- } catch (Exception ex) {
- String msg = "Exceptuion in sendSyncResponse:" + ex.getMessage()
- utils.log("DEBUG", msg, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
- }
- utils.log("DEBUG"," ***** Exit sendSyncResopnse *****", isDebugEnabled)
- }
-
-} \ No newline at end of file
diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeActivateSDNCNetworkResource.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeActivateSDNCNetworkResource.groovy
new file mode 100644
index 0000000000..31bda63a49
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeActivateSDNCNetworkResource.groovy
@@ -0,0 +1,256 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - SO
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.bpmn.infrastructure.scripts
+
+import org.apache.commons.lang3.StringUtils
+import org.camunda.bpm.engine.delegate.BpmnError
+import org.json.JSONObject
+import org.json.XML
+import org.onap.so.logger.MsoLogger
+import org.openecomp.mso.bpmn.common.recipe.ResourceInput
+import org.openecomp.mso.bpmn.common.resource.ResourceRequestBuilder
+import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor
+import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.openecomp.mso.bpmn.core.json.JsonUtils
+import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
+import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils
+
+/**
+ * This groovy class supports the <class>ActivateSDNCCNetworkResource.bpmn</class> process.
+ * flow for SDNC Network Resource Activate
+ */
+public class DeActivateSDNCNetworkResource extends AbstractServiceTaskProcessor {
+ private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL,
+ CreateSDNCNetworkResource.class);
+ String Prefix = "DEACTSDNCRES_"
+
+ ExceptionUtil exceptionUtil = new ExceptionUtil()
+
+ JsonUtils jsonUtil = new JsonUtils()
+
+ SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
+
+ public void preProcessRequest(DelegateExecution execution) {
+ msoLogger.info(" ***** started preProcessRequest*****")
+
+ try {
+
+ //get bpmn inputs from resource request.
+ String requestId = execution.getVariable("mso-request-id")
+ String requestAction = execution.getVariable("requestAction")
+ msoLogger.info("The requestAction is: " + requestAction)
+ String recipeParamsFromRequest = execution.getVariable("recipeParams")
+ msoLogger.info("The recipeParams is: " + recipeParamsFromRequest)
+ String resourceInput = execution.getVariable("resourceInput")
+ msoLogger.info("The resourceInput is: " + resourceInput)
+ //Get ResourceInput Object
+ org.onap.so.bpmn.common.recipe.ResourceInput resourceInputObj = org.onap.so.bpmn.common.resource.ResourceRequestBuilder.getJsonObject(resourceInput, org.onap.so.bpmn.common.recipe.ResourceInput.class)
+ execution.setVariable(Prefix + "resourceInput", resourceInputObj)
+
+ //Deal with recipeParams
+ String recipeParamsFromWf = execution.getVariable("recipeParamXsd")
+ String resourceModelName = resourceInputObj.getResourceModelInfo().getModelName()
+ //For sdnc requestAction default is "NetworkInstance"
+ String operationType = "Network"
+ if(!StringUtils.isBlank(recipeParamsFromRequest) && "null" != recipeParamsFromRequest){
+ //the operationType from worflow(first node) is second priority.
+ operationType = jsonUtil.getJsonValue(recipeParamsFromRequest, "operationType")
+ }
+ if(!StringUtils.isBlank(recipeParamsFromWf)){
+ //the operationType from worflow(first node) is highest priority.
+ operationType = jsonUtil.getJsonValue(recipeParamsFromWf, "operationType")
+ }
+
+
+ // TODO: based on the resource type decide action and operation type
+ String sdnc_svcAction = "deactivate"
+ operationType = "SOTNConnectivity"
+
+ String sdnc_requestAction = StringUtils.capitalize(sdnc_svcAction) + operationType +"Instance"
+ execution.setVariable(Prefix + "svcAction", sdnc_svcAction)
+ execution.setVariable(Prefix + "requestAction", sdnc_requestAction)
+ execution.setVariable(Prefix + "serviceInstanceId", resourceInputObj.getServiceInstanceId())
+ execution.setVariable("mso-request-id", requestId)
+ execution.setVariable("mso-service-instance-id", resourceInputObj.getServiceInstanceId())
+ //TODO Here build networkrequest
+
+ } catch (BpmnError e) {
+ throw e;
+ } catch (Exception ex){
+ msg = "Exception in preProcessRequest " + ex.getMessage()
+ msoLogger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ }
+
+ public void prepareSDNCRequest(DelegateExecution execution) {
+ msoLogger.info(" ***** started prepareSDNCRequest *****")
+
+ try {
+ // get variables
+ String sdnc_svcAction = execution.getVariable(Prefix + "svcAction")
+ String sdnc_requestAction = execution.getVariable(Prefix + "requestAction")
+ String sdncCallback = execution.getVariable("URN_mso_workflow_sdncadapter_callback")
+ String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest")
+
+ String hdrRequestId = execution.getVariable("mso-request-id")
+ String serviceInstanceId = execution.getVariable(Prefix + "serviceInstanceId")
+ String source = execution.getVariable("source")
+ String sdnc_service_id = execution.getVariable(Prefix + "sdncServiceId")
+ org.onap.so.bpmn.common.recipe.ResourceInput resourceInputObj = execution.getVariable(Prefix + "resourceInput")
+ String serviceType = resourceInputObj.getServiceType()
+ String serviceModelInvariantUuid = resourceInputObj.getServiceModelInfo().getModelInvariantUuid()
+ String serviceModelUuid = resourceInputObj.getServiceModelInfo().getModelUuid()
+ String serviceModelVersion = resourceInputObj.getServiceModelInfo().getModelVersion()
+ String serviceModelName = resourceInputObj.getServiceModelInfo().getModelName()
+ String globalCustomerId = resourceInputObj.getGlobalSubscriberId()
+ String modelInvariantUuid = resourceInputObj.getResourceModelInfo().getModelInvariantUuid();
+ String modelCustomizationUuid = resourceInputObj.getResourceModelInfo().getModelCustomizationUuid()
+ String modelUuid = resourceInputObj.getResourceModelInfo().getModelUuid()
+ String modelName = resourceInputObj.getResourceModelInfo().getModelName()
+ String modelVersion = resourceInputObj.getResourceModelInfo().getModelVersion()
+ // 1. prepare assign topology via SDNC Adapter SUBFLOW call
+ String sndcTopologyDeleteRequest =
+ """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.onap/so/workflow/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>${MsoUtils.xmlEscape(hdrRequestId)}</sdncadapter:RequestId>
+ <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(serviceInstanceId)}</sdncadapter:SvcInstanceId>
+ <sdncadapter:SvcAction>${MsoUtils.xmlEscape(sdnc_svcAction)}</sdncadapter:SvcAction>
+ <sdncadapter:SvcOperation>network-topology-operation</sdncadapter:SvcOperation>
+ <sdncadapter:CallbackUrl>sdncCallback</sdncadapter:CallbackUrl>
+ <sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction>
+ </sdncadapter:RequestHeader>
+ <sdncadapterworkflow:SDNCRequestData>
+ <request-information>
+ <request-id>${MsoUtils.xmlEscape(hdrRequestId)}</request-id>
+ <request-action>${MsoUtils.xmlEscape(sdnc_requestAction)}</request-action>
+ <source>${MsoUtils.xmlEscape(source)}</source>
+ <notification-url></notification-url>
+ <order-number></order-number>
+ <order-version></order-version>
+ </request-information>
+ <service-information>
+ <service-id>${MsoUtils.xmlEscape(serviceInstanceId)}</service-id>
+ <subscription-service-type>${MsoUtils.xmlEscape(serviceType)}</subscription-service-type>
+ <onap-model-information>
+ <model-invariant-uuid>${MsoUtils.xmlEscape(serviceModelInvariantUuid)}</model-invariant-uuid>
+ <model-uuid>${MsoUtils.xmlEscape(serviceModelUuid)}</model-uuid>
+ <model-version>${MsoUtils.xmlEscape(serviceModelVersion)}</model-version>
+ <model-name>${MsoUtils.xmlEscape(serviceModelName)}</model-name>
+ </onap-model-information>
+ <service-instance-id>${MsoUtils.xmlEscape(serviceInstanceId)}</service-instance-id>
+ <global-customer-id>${MsoUtils.xmlEscape(globalCustomerId)}</global-customer-id>
+ </service-information>
+ <network-information>
+ <onap-model-information>
+ <model-invariant-uuid>${MsoUtils.xmlEscape(modelInvariantUuid)}</model-invariant-uuid>
+ <model-customization-uuid>${MsoUtils.xmlEscape(modelCustomizationUuid)}</model-customization-uuid>
+ <model-uuid>${MsoUtils.xmlEscape(modelUuid)}</model-uuid>
+ <model-version>${MsoUtils.xmlEscape(modelVersion)}</model-version>
+ <model-name>${MsoUtils.xmlEscape(modelName)}</model-name>
+ </onap-model-information>
+ </network-information>
+ <network-request-input>
+ <network-input-parameters></network-input-parameters>
+ </network-request-input>
+ </sdncadapterworkflow:SDNCRequestData>
+ </aetgt:SDNCAdapterWorkflowRequest>""".trim()
+
+ String sndcTopologyDeleteRequesAsString = utils.formatXml(sndcTopologyDeleteRequest)
+ utils.logAudit(sndcTopologyDeleteRequesAsString)
+ execution.setVariable("sdncAdapterWorkflowRequest", sndcTopologyDeleteRequesAsString)
+ msoLogger.info("sdncAdapterWorkflowRequest - " + "\n" + sndcTopologyDeleteRequesAsString)
+
+ } catch (Exception ex) {
+ String exceptionMessage = " Bpmn error encountered in DeleteSDNCCNetworkResource flow. prepareSDNCRequest() - " + ex.getMessage()
+ msoLogger.debug(exceptionMessage)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
+
+ }
+ msoLogger.info(" ***** Exit prepareSDNCRequest *****")
+ }
+
+ public void prepareUpdateAfterDeActivateSDNCResource(DelegateExecution execution) {
+ msoLogger.info("***** started prepareUpdateAfterDeActivateSDNCResource *****")
+
+ ResourceInput resourceInputObj = execution.getVariable(Prefix + "resourceInput")
+ String operType = resourceInputObj.getOperationType()
+ String resourceCustomizationUuid = resourceInputObj.getResourceModelInfo().getModelCustomizationUuid()
+ String serviceInstanceId = resourceInputObj.getServiceInstanceId()
+ String operationId = resourceInputObj.getOperationId()
+ String progress = "100"
+ String status = "finished"
+ String statusDescription = "SDCN resource delete completed"
+
+ //String operationId = execution.getVariable("operationId")
+
+ String body = """
+ <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
+ xmlns:ns="http://org.onap.so/requestsdb">
+ <soapenv:Header/>
+ <soapenv:Body>
+ <ns:updateResourceOperationStatus>
+ <operType>${MsoUtils.xmlEscape(operType)}</operType>
+ <operationId>${MsoUtils.xmlEscape(operationId)}</operationId>
+ <progress>${MsoUtils.xmlEscape(progress)}</progress>
+ <resourceTemplateUUID>${MsoUtils.xmlEscape(resourceCustomizationUuid)}</resourceTemplateUUID>
+ <serviceId>${MsoUtils.xmlEscape(serviceInstanceId)}</serviceId>
+ <status>${MsoUtils.xmlEscape(status)}</status>
+ <statusDescription>${MsoUtils.xmlEscape(statusDescription)}</statusDescription>
+ </ns:updateResourceOperationStatus>
+ </soapenv:Body>
+ </soapenv:Envelope>""";
+
+ setProgressUpdateVariables(execution, body)
+ }
+
+ public void postDeactivateSDNCCall(DelegateExecution execution) {
+ msoLogger.info(" ***** started postDeactivateSDNCCall *****")
+ String responseCode = execution.getVariable(Prefix + "sdncDeleteReturnCode")
+ String responseObj = execution.getVariable(Prefix + "SuccessIndicator")
+
+ msoLogger.info("response from sdnc, response code :" + responseCode + " response object :" + responseObj)
+ msoLogger.info(" ***** Exit prepareSDNCRequest *****")
+ }
+
+ public void sendSyncResponse(DelegateExecution execution) {
+ def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
+ msoLogger.info(" ***** started sendSyncResponse *****")
+
+ try {
+ String operationStatus = "finished"
+ // RESTResponse for main flow
+ String resourceOperationResp = """{"operationStatus":"${operationStatus}"}""".trim()
+ msoLogger.debug(" sendSyncResponse to APIH:" + "\n" + resourceOperationResp)
+ sendWorkflowResponse(execution, 202, resourceOperationResp)
+ execution.setVariable("sentSyncResponse", true)
+
+ } catch (Exception ex) {
+ String msg = "Exceptuion in sendSyncResponse:" + ex.getMessage()
+ msoLogger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ msoLogger.debug(" ***** Exit sendSyncResopnse *****")
+ }
+
+} \ No newline at end of file
diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Delete3rdONAPE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Delete3rdONAPE2EServiceInstance.groovy
new file mode 100644
index 0000000000..122fd50d61
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Delete3rdONAPE2EServiceInstance.groovy
@@ -0,0 +1,517 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * OPENECOMP - SO
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.infrastructure.scripts
+
+import org.json.JSONObject
+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.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.common.scripts.SDNCAdapterUtils
+import org.onap.so.bpmn.infrastructure.workflow.service.ServicePluginFactory
+import java.util.UUID
+
+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 E2EServiceInstance in 3rdONAP
+ */
+public class Delete3rdONAPE2EServiceInstance extends AbstractServiceTaskProcessor {
+
+ String Prefix="CRE3rdONAPESI_"
+
+ ExceptionUtil exceptionUtil = new ExceptionUtil()
+
+ JsonUtils jsonUtil = new JsonUtils()
+
+ public void checkSPPartnerInfoFromAAI (DelegateExecution execution) {
+ def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
+ utils.log("INFO"," ***** Started checkSPPartnerInfo *****", isDebugEnabled)
+ try {
+ //get bpmn inputs from resource request.
+ String requestId = execution.getVariable("mso-request-id")
+ String requestAction = execution.getVariable("requestAction")
+ utils.log("INFO","The requestAction is: " + requestAction, isDebugEnabled)
+ String recipeParamsFromRequest = execution.getVariable("recipeParams")
+ utils.log("INFO","The recipeParams is: " + recipeParamsFromRequest, isDebugEnabled)
+ String resourceInput = execution.getVariable("resourceInput")
+ utils.log("INFO","The resourceInput is: " + resourceInput, isDebugEnabled)
+ //Get ResourceInput Object
+ 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)
+ utils.log("INFO", "sppartnerId:" + sppartnerId, isDebugEnabled)
+
+ // Get Sppartner from AAI
+ AaiUtil aaiUriUtil = new AaiUtil(this)
+ 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)
+
+ getSPPartnerInAAI(execution)
+
+ String callSource = "UUI"
+ String sppartnerUrl = ""
+ String sppartnerVersion = ""
+ if(execution.getVariable(Prefix + "SuccessIndicator")) {
+ callSource = execution.getVariable(Prefix + "CallSource")
+ sppartnerId = execution.getVariable(Prefix + "SppartnerId")
+ sppartnerUrl = execution.getVariable(Prefix + "SppartnerUrl")
+ sppartnerVersion = execution.getVariable(Prefix + "SppartnerVersion")
+ }
+
+ boolean is3rdONAPExist = false
+ if(!isBlank(sppartnerUrl)) {
+ is3rdONAPExist = true
+ }
+
+ execution.setVariable("Is3rdONAPExist", is3rdONAPExist)
+ execution.setVariable(Prefix + "ServiceInstanceId", resourceInputObj.getServiceInstanceId())
+ execution.setVariable("mso-request-id", requestId)
+ execution.setVariable("mso-service-instance-id", resourceInputObj.getServiceInstanceId())
+
+ } catch (BpmnError e) {
+ throw e
+ } catch (Exception ex){
+ String msg = "Exception in checkSPPartnerInfoFromAAI " + ex.getMessage()
+ utils.log("DEBUG", msg, isDebugEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ }
+
+ public void checkLocallCall (DelegateExecution execution) {
+ def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
+ utils.log("INFO"," ***** Started checkLocallCall *****", isDebugEnabled)
+
+ boolean isLocalCall = true
+ String callSource = execution.getVariable(Prefix + "CallSource")
+ if("ExternalAPI".equalsIgnoreCase(callSource)) {
+ isLocalCall = false
+ }
+ execution.setVariable("IsLocalCall", isLocalCall)
+ }
+
+ public void preProcessRequest(DelegateExecution execution){
+ def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
+ utils.log("INFO"," ***** Started preProcessRequest *****", isDebugEnabled)
+ try {
+ ResourceInput resourceInputObj = execution.getVariable(Prefix + "resourceInput")
+ String msg = ""
+
+ String globalSubscriberId = resourceInputObj.getGlobalSubscriberId()
+ if (isBlank(globalSubscriberId)) {
+ msg = "Input globalSubscriberId is null"
+ utils.log("INFO", msg, isDebugEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ }
+ //set local variable
+ execution.setVariable("globalSubscriberId", globalSubscriberId)
+ utils.log("INFO", "globalSubscriberId:" + globalSubscriberId, isDebugEnabled)
+
+ String serviceType = resourceInputObj.getServiceType()
+ if (isBlank(serviceType)) {
+ msg = "Input serviceType is null"
+ utils.log("INFO", msg, isDebugEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ }
+ execution.setVariable("serviceType", serviceType)
+ utils.log("INFO", "serviceType:" + serviceType, isDebugEnabled)
+
+ String operationId = resourceInputObj.getOperationId()
+ if (isBlank(operationId)) {
+ msg = "Input operationId is null"
+ utils.log("INFO", msg, isDebugEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ }
+ execution.setVariable("operationId", operationId)
+ utils.log("INFO", "operationId:" + operationId, isDebugEnabled)
+
+ String resourceName = resourceInputObj.getResourceInstanceName()
+ if (isBlank(resourceName)) {
+ msg = "Input resourceName is null"
+ utils.log("INFO", msg, isDebugEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ }
+ execution.setVariable("resourceName", resourceName)
+ utils.log("INFO", "resourceInstanceId:" + resourceName, isDebugEnabled)
+
+ String resourceTemplateId = resourceInputObj.getResourceModelInfo().getModelCustomizationUuid()
+ if (isBlank(resourceTemplateId)) {
+ msg = "Input resourceTemplateId is null"
+ utils.log("INFO", msg, isDebugEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
+ }
+ execution.setVariable("resourceTemplateId", resourceTemplateId)
+ utils.log("INFO", "resourceTemplateId:" + resourceTemplateId, isDebugEnabled)
+
+ } catch (BpmnError e) {
+ throw e
+ } catch (Exception ex){
+ String msg = "Exception in preProcessRequest " + ex.getMessage()
+ utils.log("DEBUG", msg, isDebugEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ }
+
+ public void prepareUpdateProgress(DelegateExecution execution) {
+ def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
+ utils.log("INFO"," ***** Started prepareUpdateProgress *****", isDebugEnabled)
+ ResourceInput resourceInputObj = execution.getVariable(Prefix + "ResourceInput")
+ String operType = resourceInputObj.getOperationType()
+ String resourceCustomizationUuid = resourceInputObj.getResourceModelInfo().getModelCustomizationUuid()
+ String ServiceInstanceId = resourceInputObj.getServiceInstanceId()
+ String modelName = resourceInputObj.getResourceModelInfo().getModelName()
+ String operationId = resourceInputObj.getOperationId()
+ String progress = execution.getVariable("progress")
+ String status = execution.getVariable("status")
+ String statusDescription = execution.getVariable("statusDescription")
+
+ String body = """
+ <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
+ xmlns:ns="http://org.openecomp.mso/requestsdb">
+ <soapenv:Header/>
+ <soapenv:Body>
+ <ns:updateResourceOperationStatus>
+ <operType>${operType}</operType>
+ <operationId>${operationId}</operationId>
+ <progress>${progress}</progress>
+ <resourceTemplateUUID>${resourceCustomizationUuid}</resourceTemplateUUID>
+ <serviceId>${ServiceInstanceId}</serviceId>
+ <status>${status}</status>
+ <statusDescription>${statusDescription}</statusDescription>
+ </ns:updateResourceOperationStatus>
+ </soapenv:Body>
+ </soapenv:Envelope>"""
+
+ setProgressUpdateVariables(execution, body)
+ utils.log("INFO"," ***** End prepareUpdateProgress *****", isDebugEnabled)
+ }
+
+ public void prepare3rdONAPRequest(DelegateExecution execution) {
+ def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
+ utils.log("INFO"," ***** Started prepare3rdONAPRequest *****", isDebugEnabled)
+
+ 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"
+ String description = "Service Order from SPPartner"
+ String requestedStartDate = utils.generateCurrentTimeInUtc()
+ String requestedCompletionDate = utils.generateCurrentTimeInUtc()
+ String priority = "1" // 0-4 0:highest
+ String subscriberId = execution.getVariable("globalSubscriberId")
+ String customerRole = ""
+ String subscriberName = ""
+ String referredType = execution.getVariable("serviceType")
+ String orderItemId = "1"
+ String action = "delete" //for delete
+ String serviceState = "active"
+ String serviceName = ""
+ String serviceId = execution.getVariable(Prefix + "ServiceInstanceId")
+
+ Map<String, String> valueMap = new HashMap<>()
+ valueMap.put("externalId", '"' + externalId + '"')
+ valueMap.put("category", '"' + category + '"')
+ valueMap.put("description", '"' + description + '"')
+ valueMap.put("requestedStartDate", '"' + requestedStartDate + '"')
+ valueMap.put("requestedCompletionDate", '"' + requestedCompletionDate + '"')
+ valueMap.put("priority", '"'+ priority + '"')
+ valueMap.put("subscriberId", '"' + subscriberId + '"')
+ valueMap.put("customerRole", '"' + customerRole + '"')
+ valueMap.put("subscriberName", '"' + subscriberName + '"')
+ valueMap.put("referredType", '"' + referredType + '"')
+ valueMap.put("orderItemId", '"' + orderItemId + '"')
+ valueMap.put("action", '"' + action + '"')
+ valueMap.put("serviceState", '"' + serviceState + '"')
+ valueMap.put("serviceName", '"' + serviceName + '"')
+ valueMap.put("serviceId", '"' + serviceId + '"')
+
+ ExternalAPIUtil externalAPIUtil = new ExternalAPIUtil(this)
+
+ valueMap.put("_requestInputs_", "")
+
+ String payload = externalAPIUtil.setTemplate(ExternalAPIUtil.PostServiceOrderRequestsTemplate, valueMap)
+ execution.setVariable(Prefix + "Payload", payload)
+ utils.log("INFO", "Exit " + prepare3rdONAPRequest, isDebugEnabled)
+ }
+
+ public void doDeleteE2ESIin3rdONAP(DelegateExecution execution) {
+ def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
+ utils.log("INFO"," ***** Started doDeleteE2ESIin3rdONAP *****", isDebugEnabled)
+
+ String extAPIPath = execution.getVariable("ExternalAPIURL")
+ String payload = execution.getVariable(Prefix + "Payload")
+
+ ExternalAPIUtil externalAPIUtil = new ExternalAPIUtil(this)
+
+ APIResponse response = externalAPIUtil.executeExternalAPIPostCall(execution, extAPIPath, payload)
+
+ int responseCode = response.getStatusCode()
+ execution.setVariable(Prefix + "postServiceOrderResponseCode", responseCode)
+ utils.log("DEBUG", "Post ServiceOrder response code is: " + responseCode, isDebugEnabled)
+
+ String extApiResponse = response.getResponseBodyAsString()
+ JSONObject responseObj = new JSONObject(extApiResponse)
+ execution.setVariable(Prefix + "postServiceOrderResponse", extApiResponse)
+ //Process Response
+ if(responseCode == 200 || responseCode == 201 || responseCode == 202 )
+ //200 OK 201 CREATED 202 ACCEPTED
+ {
+ utils.log("DEBUG", "Post ServiceOrder Received a Good Response", isDebugEnabled)
+ String serviceOrderId = responseObj.get("ServiceOrderId")
+ execution.setVariable(Prefix + "SuccessIndicator", true)
+ execution.setVariable("serviceOrderId", serviceOrderId)
+ }
+ else{
+ utils.log("DEBUG", "Post ServiceOrder Received a Bad Response Code. Response Code is: " + responseCode, isDebugEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Post ServiceOrder Received a bad response from 3rdONAP External API")
+ }
+
+ utils.log("INFO", "Exit " + doDeleteE2ESIin3rdONAP, isDebugEnabled)
+ }
+
+
+ public void getE2ESIProgressin3rdONAP(DelegateExecution execution) {
+ def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
+ utils.log("INFO"," ***** Started getE2ESIProgressin3rdONAP *****", isDebugEnabled)
+
+ String extAPIPath = execution.getVariable("ExternalAPIURL")
+ extAPIPath += "/" + execution.getVariable("ServiceOrderId")
+
+ ExternalAPIUtil externalAPIUtil = new ExternalAPIUtil(this)
+
+ APIResponse response = externalAPIUtil.executeExternalAPIGetCall(execution, extAPIPath)
+
+ int responseCode = response.getStatusCode()
+ execution.setVariable(Prefix + "getServiceOrderResponseCode", responseCode)
+ utils.log("DEBUG", "Get ServiceOrder response code is: " + responseCode, isDebugEnabled)
+
+ String extApiResponse = response.getResponseBodyAsString()
+ JSONObject responseObj = new JSONObject(extApiResponse)
+ execution.setVariable(Prefix + "getServiceOrderResponse", extApiResponse)
+
+ //Process Response //200 OK 201 CREATED 202 ACCEPTED
+ if(responseCode == 200 || responseCode == 201 || responseCode == 202 )
+ {
+ utils.log("DEBUG", "Get ServiceOrder Received a Good Response", isDebugEnabled)
+ String serviceOrderState = responseObj.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)
+ execution.setVariable("status", "processing")
+ }
+ if("INPROGRESS".equalsIgnoreCase(serviceOrderState)) {
+ execution.setVariable("progress", 40)
+ execution.setVariable("status", "processing")
+ }
+ if("COMPLETED".equalsIgnoreCase(serviceOrderState)) {
+ execution.setVariable("progress", 100)
+ execution.setVariable("status", "finished")
+ }
+ if("FAILED".equalsIgnoreCase(serviceOrderState)) {
+ execution.setVariable("progress", 100)
+ execution.setVariable("status", "error")
+ }
+ else {
+ execution.setVariable("progress", 100)
+ execution.setVariable("status", "error")
+ execution.setVariable("statusDescription", "Delete Service Order Status is unknown")
+ }
+ execution.setVariable("statusDescription", "Delete Service Order Status is " + serviceOrderState)
+ }
+ else{
+ utils.log("DEBUG", "Get ServiceOrder Received a Bad Response Code. Response Code is: " + responseCode, isDebugEnabled)
+ execution.setVariable("progress", 100)
+ execution.setVariable("status", "error")
+ execution.setVariable("statusDescription", "Get ServiceOrder Received a bad response")
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Get ServiceOrder Received a bad response from 3rdONAP External API")
+ }
+
+ utils.log("INFO", "Exit " + getE2ESIProgressin3rdONAP, isDebugEnabled)
+ }
+
+ /**
+ * delay 5 sec
+ */
+ public void timeDelay(DelegateExecution execution) {
+ def isDebugEnabled= execution.getVariable("isDebugLogEnabled")
+ try {
+ Thread.sleep(5000)
+ } catch(InterruptedException e) {
+ utils.log("ERROR", "Time Delay exception" + e , isDebugEnabled)
+ }
+ }
+
+ private void getSPPartnerInAAI(DelegateExecution execution) {
+ def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
+ utils.log("INFO"," ***** Started postDeleteE2ESIin3rdONAP *****", isDebugEnabled)
+
+ AaiUtil aaiUriUtil = new AaiUtil(this)
+ String serviceAaiPath = execution.getVariable(Prefix + "serviceAaiPath")
+ APIResponse response = aaiUriUtil.executeAAIGetCall(execution, serviceAaiPath)
+ int responseCode = response.getStatusCode()
+ execution.setVariable(Prefix + "GetSppartnerResponseCode", responseCode)
+ utils.log("DEBUG", " Get sppartner response code is: " + responseCode, isDebugEnabled)
+
+ String aaiResponse = response.getResponseBodyAsString()
+ aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse)
+ aaiResponse = aaiResponse.replaceAll("&", "&amp;")
+ execution.setVariable(Prefix + "GetSppartnerResponse", aaiResponse)
+
+ //Process Response
+ if(responseCode == 200 || responseCode == 201 || responseCode == 202 )
+ //200 OK 201 CREATED 202 ACCEPTED
+ {
+ utils.log("DEBUG", "GET sppartner Received a Good Response", isDebugEnabled)
+ execution.setVariable(Prefix + "SuccessIndicator", true)
+ execution.setVariable(Prefix + "FoundIndicator", true)
+
+ String sppartnerId = utils.getNodeText1(aaiResponse, "sppartner-id")
+ execution.setVariable(Prefix + "SppartnerId", sppartnerId)
+ utils.log("DEBUG", " SppartnerId is: " + sppartnerId, isDebugEnabled)
+ String sppartnerUrl = utils.getNodeText1(aaiResponse, "sppartner-url")
+ execution.setVariable(Prefix + "SppartnerUrl", sppartnerUrl)
+ utils.log("DEBUG", " SppartnerUrl is: " + sppartnerUrl, isDebugEnabled)
+ String callSource = utils.getNodeText1(aaiResponse, "sppartner-callsource")
+ execution.setVariable(Prefix + "CallSource", callSource)
+ utils.log("DEBUG", " CallSource is: " + callSource, isDebugEnabled)
+ String sppartnerVersion = utils.getNodeText1(aaiResponse, "resource-version")
+ execution.setVariable(Prefix + "SppartnerVersion", sppartnerVersion)
+ utils.log("DEBUG", " Resource Version is: " + sppartnerVersion, isDebugEnabled)
+ }
+ else
+ {
+ utils.log("DEBUG", "Get sppartner Received a Bad Response Code. Response Code is: " + responseCode, isDebugEnabled)
+ exceptionUtil.MapAAIExceptionToWorkflowExceptionGeneric(execution, aaiResponse, responseCode)
+ throw new BpmnError("MSOWorkflowException")
+ }
+
+ utils.log("INFO", "Exit " + deleteSPPartnerInAAI, isDebugEnabled)
+ }
+
+ public void deleteSPPartnerInAAI(DelegateExecution execution) {
+ def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
+ utils.log("INFO"," ***** Started postDeleteE2ESIin3rdONAP *****", isDebugEnabled)
+
+ String sppartnerId = execution.getVariable(Prefix + "SppartnerId")
+ String sppartnerUrl = execution.getVariable(Prefix + "sppartnerUrl")
+ String sppartnerVersion = execution.getVariable(Prefix + "sppartnerVersion")
+
+ AaiUtil aaiUriUtil = new AaiUtil(this)
+ String serviceAaiPath = execution.getVariable(Prefix + "serviceAaiPath") + "/${sppartnerVersion}"
+ APIResponse response = aaiUriUtil.executeAAIDeleteCall(execution, serviceAaiPath)
+ int responseCode = response.getStatusCode()
+ execution.setVariable(Prefix + "DeleteSppartnerResponseCode", responseCode)
+ utils.log("DEBUG", " Get sppartner response code is: " + responseCode, isDebugEnabled)
+
+ String aaiResponse = response.getResponseBodyAsString()
+ aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse)
+ execution.setVariable(Prefix + "DeleteSppartnerResponse", aaiResponse)
+
+ //Process Response
+ if(responseCode == 200 || responseCode == 201 || responseCode == 202 )
+ //200 OK 201 CREATED 202 ACCEPTED
+ {
+ utils.log("DEBUG", "Delete sppartner Received a Good Response", isDebugEnabled)
+ execution.setVariable(Prefix + "SuccessIndicator", true)
+ }
+ else if(responseCode == 404){
+ utils.log("DEBUG", " Delete sppartner Received a Not Found (404) Response", isDebugEnabled)
+ execution.setVariable(Prefix + "FoundIndicator", false)
+ }
+ else
+ {
+ utils.log("DEBUG", "Delete sppartner Received a Bad Response Code. Response Code is: " + responseCode, isDebugEnabled)
+ exceptionUtil.MapAAIExceptionToWorkflowExceptionGeneric(execution, aaiResponse, responseCode)
+ throw new BpmnError("MSOWorkflowException")
+ }
+
+ utils.log("INFO", "Exit " + deleteSPPartnerInAAI, isDebugEnabled)
+ }
+
+ 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 postProcess(DelegateExecution execution){
+ def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
+ utils.log("INFO"," ***** Started postProcess *****", isDebugEnabled)
+ String responseCode = execution.getVariable(Prefix + "putSppartnerResponseCode")
+ String responseObj = execution.getVariable(Prefix + "putSppartnerResponse")
+
+ utils.log("INFO","response from AAI for put sppartner, response code :" + responseCode + " response object :" + responseObj, isDebugEnabled)
+ utils.log("INFO"," ***** Exit postProcess *****", isDebugEnabled)
+ }
+
+ public void sendSyncResponse (DelegateExecution execution) {
+ def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
+ utils.log("DEBUG", " *** sendSyncResponse *** ", isDebugEnabled)
+
+ try {
+ String operationStatus = "finished"
+ // RESTResponse for main flow
+ String resourceOperationResp = """{"operationStatus":"${operationStatus}"}""".trim()
+ utils.log("DEBUG", " sendSyncResponse to APIH:" + "\n" + resourceOperationResp, isDebugEnabled)
+ sendWorkflowResponse(execution, 202, resourceOperationResp)
+ execution.setVariable("sentSyncResponse", true)
+
+ } catch (Exception ex) {
+ String msg = "Exceptuion in sendSyncResponse:" + ex.getMessage()
+ utils.log("DEBUG", msg, isDebugEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ utils.log("DEBUG"," ***** Exit sendSyncResopnse *****", isDebugEnabled)
+ }
+}
diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSDNCNetworkResource.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSDNCNetworkResource.groovy
index ab5500602f..a18cee253e 100644
--- a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSDNCNetworkResource.groovy
+++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteSDNCNetworkResource.groovy
@@ -20,6 +20,8 @@
package org.onap.so.bpmn.infrastructure.scripts
+import org.onap.so.logger.MsoLogger
+
import static org.apache.commons.lang3.StringUtils.*;
import org.apache.commons.lang3.*
@@ -40,6 +42,8 @@ import groovy.json.*
* flow for SDNC Network Resource
*/
public class DeleteSDNCNetworkResource extends AbstractServiceTaskProcessor {
+ private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL,
+ CreateSDNCNetworkResource.class);
String Prefix="DELSDNCRES_"
@@ -50,18 +54,17 @@ public class DeleteSDNCNetworkResource extends AbstractServiceTaskProcessor {
SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
public void preProcessRequest(DelegateExecution execution){
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- utils.log("INFO"," ***** Started preProcessRequest *****", isDebugEnabled)
+ msoLogger.info("***** Started preProcessRequest *****")
try {
//get bpmn inputs from resource request.
String requestId = execution.getVariable("mso-request-id")
String requestAction = execution.getVariable("requestAction")
- utils.log("INFO","The requestAction is: " + requestAction, isDebugEnabled)
+ msoLogger.info("The requestAction is: " + requestAction)
String recipeParamsFromRequest = execution.getVariable("recipeParams")
- utils.log("INFO","The recipeParams is: " + recipeParamsFromRequest, isDebugEnabled)
+ msoLogger.info("The recipeParams is: " + recipeParamsFromRequest)
String resourceInput = execution.getVariable("resourceInput")
- utils.log("INFO","The resourceInput is: " + resourceInput, isDebugEnabled)
+ msoLogger.info("The resourceInput is: " + resourceInput)
//Get ResourceInput Object
ResourceInput resourceInputObj = ResourceRequestBuilder.getJsonObject(resourceInput, ResourceInput.class)
execution.setVariable(Prefix + "resourceInput", resourceInputObj)
@@ -104,7 +107,7 @@ public class DeleteSDNCNetworkResource extends AbstractServiceTaskProcessor {
throw e;
} catch (Exception ex){
msg = "Exception in preProcessRequest " + ex.getMessage()
- utils.log("DEBUG", msg, isDebugEnabled)
+ msoLogger.debug(msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
}
}
@@ -116,8 +119,7 @@ public class DeleteSDNCNetworkResource extends AbstractServiceTaskProcessor {
* generate the nsParameters
*/
public void prepareSDNCRequest (DelegateExecution execution) {
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- utils.log("INFO"," ***** Started prepareSDNCRequest *****", isDebugEnabled)
+ msoLogger.info("***** Started prepareSDNCRequest *****")
try {
// get variables
@@ -194,15 +196,15 @@ public class DeleteSDNCNetworkResource extends AbstractServiceTaskProcessor {
String sndcTopologyDeleteRequesAsString = utils.formatXml(sndcTopologyDeleteRequest)
utils.logAudit(sndcTopologyDeleteRequesAsString)
execution.setVariable("sdncAdapterWorkflowRequest", sndcTopologyDeleteRequesAsString)
- utils.log("INFO","sdncAdapterWorkflowRequest - " + "\n" + sndcTopologyDeleteRequesAsString, isDebugEnabled)
+ msoLogger.info("sdncAdapterWorkflowRequest - " + "\n" + sndcTopologyDeleteRequesAsString)
} catch (Exception ex) {
String exceptionMessage = " Bpmn error encountered in DeleteSDNCCNetworkResource flow. prepareSDNCRequest() - " + ex.getMessage()
- utils.log("DEBUG", exceptionMessage, isDebugEnabled)
+ msoLogger.debug(exceptionMessage)
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
}
- utils.log("INFO"," ***** Exit prepareSDNCRequest *****", isDebugEnabled)
+ msoLogger.info(" ***** Exit prepareSDNCRequest *****")
}
private void setProgressUpdateVariables(DelegateExecution execution, String body) {
@@ -277,18 +279,16 @@ public class DeleteSDNCNetworkResource extends AbstractServiceTaskProcessor {
}
public void postDeleteSDNCCall(DelegateExecution execution){
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- utils.log("INFO"," ***** Started prepareSDNCRequest *****", isDebugEnabled)
+ msoLogger.info(" ***** Started prepareSDNCRequest *****")
String responseCode = execution.getVariable(Prefix + "sdncDeleteReturnCode")
String responseObj = execution.getVariable(Prefix + "SuccessIndicator")
-
- utils.log("INFO","response from sdnc, response code :" + responseCode + " response object :" + responseObj, isDebugEnabled)
- utils.log("INFO"," ***** Exit prepareSDNCRequest *****", isDebugEnabled)
+
+ msoLogger.info("response from sdnc, response code :" + responseCode + " response object :" + responseObj)
+ msoLogger.info(" ***** Exit prepareSDNCRequest *****")
}
public void sendSyncResponse (DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- utils.log("DEBUG", " *** sendSyncResponse *** ", isDebugEnabled)
+ msoLogger.info(" *** sendSyncResponse *** ")
try {
String operationStatus = "finished"
@@ -300,9 +300,9 @@ public class DeleteSDNCNetworkResource extends AbstractServiceTaskProcessor {
} catch (Exception ex) {
String msg = "Exceptuion in sendSyncResponse:" + ex.getMessage()
- utils.log("DEBUG", msg, isDebugEnabled)
+ msoLogger.debug(msg)
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
}
- utils.log("DEBUG"," ***** Exit sendSyncResopnse *****", isDebugEnabled)
+ msoLogger.info(" ***** Exit sendSyncResopnse *****")
}
}
diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateResources.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateResources.groovy
index 9da8a90ca7..9591898ed0 100644
--- a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateResources.groovy
+++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateResources.groovy
@@ -226,6 +226,7 @@ public class DoCreateResources extends AbstractServiceTaskProcessor{
resourceInput.setResourceModelInfo(currentResource.getModelInfo());
ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
resourceInput.setServiceModelInfo(serviceDecomposition.getModelInfo());
+ def String resourceCustomizationUuid = currentResource.getModelInfo().getModelCustomizationUuid();
String incomingRequest = execution.getVariable("uuiRequest")
//set the requestInputs from tempalte To Be Done
diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy
index 54dfae3760..6d23ae7c65 100644
--- a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy
+++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy
@@ -192,76 +192,93 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor {
//Confirm there are no related service instances (vnf/network or volume)
if (utils.nodeExists(siData, "relationship-list")) {
utils.log("INFO", "SI Data relationship-list exists:", isDebugEnabled)
- //test(siData)
- NodeList nodeList = serviceXml.getElementsByTagName("relationship")
JSONArray jArray = new JSONArray()
- for (int x = 0; x < nodeList.getLength(); x++) {
- Node node = nodeList.item(x)
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- Element eElement = (Element) node
- def e = eElement.getElementsByTagName("related-to").item(0).getTextContent() //for ns
- if(e.equals("service-instance")){
- def relatedObject = eElement.getElementsByTagName("related-link").item(0).getTextContent()
- utils.log("INFO", "ServiceInstance Related NS :" + relatedObject, isDebugEnabled)
- NodeList dataList = node.getChildNodes()
- if(null != dataList) {
- JSONObject jObj = new JSONObject()
- for (int i = 0; i < dataList.getLength(); i++) {
- Node dNode = dataList.item(i)
- if(dNode.getNodeName() == "relationship-data") {
- Element rDataEle = (Element)dNode
- def eKey = rDataEle.getElementsByTagName("relationship-key").item(0).getTextContent()
- def eValue = rDataEle.getElementsByTagName("relationship-value").item(0).getTextContent()
- if(eKey.equals("service-instance.service-instance-id")){
- jObj.put("resourceInstanceId", eValue)
- }
-
- }
- else if(dNode.getNodeName() == "related-to-property"){
- Element rDataEle = (Element)dNode
- def eKey = rDataEle.getElementsByTagName("property-key").item(0).getTextContent()
- def eValue = rDataEle.getElementsByTagName("property-value").item(0).getTextContent()
- if(eKey.equals("service-instance.service-instance-name")){
- jObj.put("resourceType", eValue)
- }
- }
- }
- utils.log("INFO", "Relationship related to Resource:" + jObj.toString(), isDebugEnabled)
- jArray.put(jObj)
- }
- //for overlay/underlay
- }else if (e.equals("configuration")){
- def relatedObject = eElement.getElementsByTagName("related-link").item(0).getTextContent()
- utils.log("INFO", "ServiceInstance Related Configuration :" + relatedObject, isDebugEnabled)
- NodeList dataList = node.getChildNodes()
- if(null != dataList) {
- JSONObject jObj = new JSONObject()
- for (int i = 0; i < dataList.getLength(); i++) {
- Node dNode = dataList.item(i)
- if(dNode.getNodeName() == "relationship-data") {
- Element rDataEle = (Element)dNode
- def eKey = rDataEle.getElementsByTagName("relationship-key").item(0).getTextContent()
- def eValue = rDataEle.getElementsByTagName("relationship-value").item(0).getTextContent()
- if(eKey.equals("configuration.configuration-id")){
- jObj.put("resourceInstanceId", eValue)
- }
- }
- else if(dNode.getNodeName() == "related-to-property"){
- Element rDataEle = (Element)dNode
- def eKey = rDataEle.getElementsByTagName("property-key").item(0).getTextContent()
- def eValue = rDataEle.getElementsByTagName("property-value").item(0).getTextContent()
- if(eKey.equals("configuration.configuration-type")){
- jObj.put("resourceType", eValue)
- }
- }
- }
- utils.log("INFO", "Relationship related to Resource:" + jObj.toString(), isDebugEnabled)
- jArray.put(jObj)
- }
- }
- }
+
+ XmlParser xmlParser = new XmlParser()
+ Node root = xmlParser.parseText(siData)
+ def relation_list = utils.getChildNode(root, 'relationship-list')
+ def relationships = utils.getIdenticalChildren(relation_list, 'relationship')
+
+ for (def relation: relationships) {
+ def jObj = getRelationShipData(relation, isDebugEnabled)
+ jArray.put(jObj)
}
+
execution.setVariable("serviceRelationShip", jArray.toString())
+
+// //test(siData)
+// NodeList nodeList = serviceXml.getElementsByTagName("relationship")
+// JSONArray jArray = new JSONArray()
+// for (int x = 0; x < nodeList.getLength(); x++) {
+// Node node = nodeList.item(x)
+// if (node.getNodeType() == Node.ELEMENT_NODE) {
+// Element eElement = (Element) node
+// def e = eElement.getElementsByTagName("related-to").item(0).getTextContent() //for ns
+// if(e.equals("service-instance")){
+// def relatedObject = eElement.getElementsByTagName("related-link").item(0).getTextContent()
+// utils.log("INFO", "ServiceInstance Related NS :" + relatedObject, isDebugEnabled)
+// NodeList dataList = node.getChildNodes()
+// if(null != dataList) {
+// JSONObject jObj = new JSONObject()
+// for (int i = 0; i < dataList.getLength(); i++) {
+// Node dNode = dataList.item(i)
+// if(dNode.getNodeName() == "relationship-data") {
+// Element rDataEle = (Element)dNode
+// def eKey = rDataEle.getElementsByTagName("relationship-key").item(0).getTextContent()
+// def eValue = rDataEle.getElementsByTagName("relationship-value").item(0).getTextContent()
+// if(eKey.equals("service-instance.service-instance-id")){
+// jObj.put("resourceInstanceId", eValue)
+// }
+//
+// }
+// else if(dNode.getNodeName() == "related-to-property"){
+// Element rDataEle = (Element)dNode
+// def eKey = rDataEle.getElementsByTagName("property-key").item(0).getTextContent()
+// def eValue = rDataEle.getElementsByTagName("property-value").item(0).getTextContent()
+// if(eKey.equals("service-instance.service-instance-name")){
+// jObj.put("resourceType", eValue)
+// }
+// }
+// }
+// utils.log("INFO", "Relationship related to Resource:" + jObj.toString(), isDebugEnabled)
+// jArray.put(jObj)
+// }
+// //for overlay/underlay
+// }else if (e.equals("configuration")){
+// def relatedObject = eElement.getElementsByTagName("related-link").item(0).getTextContent()
+// utils.log("INFO", "ServiceInstance Related Configuration :" + relatedObject, isDebugEnabled)
+// NodeList dataList = node.getChildNodes()
+// if(null != dataList) {
+// JSONObject jObj = new JSONObject()
+// for (int i = 0; i < dataList.getLength(); i++) {
+// Node dNode = dataList.item(i)
+// if(dNode.getNodeName() == "relationship-data") {
+// Element rDataEle = (Element)dNode
+// def eKey = rDataEle.getElementsByTagName("relationship-key").item(0).getTextContent()
+// def eValue = rDataEle.getElementsByTagName("relationship-value").item(0).getTextContent()
+// if(eKey.equals("configuration.configuration-id")){
+// jObj.put("resourceInstanceId", eValue)
+// }
+// }
+// else if(dNode.getNodeName() == "related-to-property"){
+// Element rDataEle = (Element)dNode
+// def eKey = rDataEle.getElementsByTagName("property-key").item(0).getTextContent()
+// def eValue = rDataEle.getElementsByTagName("property-value").item(0).getTextContent()
+// if(eKey.equals("configuration.configuration-type")){
+// jObj.put("resourceType", eValue)
+// }
+// }
+// }
+// utils.log("INFO", "Relationship related to Resource:" + jObj.toString(), isDebugEnabled)
+// jArray.put(jObj)
+// }
+// // for SP-Partner
+// }else if (e.equals("sp-partner")){
+//
+// }
+// }
+// }
+// execution.setVariable("serviceRelationShip", jArray.toString())
}
}
}else{
@@ -292,6 +309,50 @@ 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.getNodeText1(relation, "related-to")
+
+ def rl = utils.getNodeText1(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")
+ def eValue = utils.getChildNodeText(rl_data, "relationship-value")
+
+ if ((rt == "service-instance" && eKey.equals("service-instance.service-instance-id"))
+ //for overlay/underlay
+ || (rt == "configuration" && eKey.equals("configuration.configuration-id")
+ )){
+ jObj.put("resourceInstanceId", eValue)
+ }
+ // for sp-partner
+ if(rt == "sp-partner" && eKey.equals("sp-partner.id")) {
+ jObj.put("resourceInstanceId", eValue)
+ String sppartnerName = "sp-partner" + eValue
+ jObj.put("resourceType", sppartnerName)
+ }
+ }
+
+ def rl_props = utils.getIdenticalChildren(node, "related-to-property")
+ for(def rl_prop : rl_props) {
+ def eKey = utils.getChildNodeText(rl_prop, "property-key")
+ def eValue = utils.getChildNodeText(rl_prop, "property-value")
+ if((rt == "service-instance" && eKey.equals("service-instance.service-instance-name"))
+ //for overlay/underlay
+ || (rt == "configuration" && eKey.equals("configuration.configuration-type"))){
+ jObj.put("resourceType", eValue)
+ }
+ }
+
+ utils.log("INFO", "Relationship related to Resource:" + jObj.toString(), isDebugEnabled)
+
+ return jObj
+ }
public void getCurrentNS(DelegateExecution execution){
def isDebugEnabled=execution.getVariable("isDebugLogEnabled")