summaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-infrastructure-flows
diff options
context:
space:
mode:
authorSeshu Kumar M <seshu.kumar.m@huawei.com>2018-08-07 07:37:49 +0000
committerGerrit Code Review <gerrit@onap.org>2018-08-07 07:37:49 +0000
commita592af99f9434747758012462a8b0425a2a624fd (patch)
tree3d3ec8c334336475e5a3915fbd2f319adae39c1e /bpmn/so-bpmn-infrastructure-flows
parentb4b11aab90ea69704b95d1a5c9658f05e238b78b (diff)
parent3091f88155228e1648b690994c21e8be6dfba701 (diff)
Merge "Provide implementation for activate methods"
Diffstat (limited to 'bpmn/so-bpmn-infrastructure-flows')
-rw-r--r--bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSDNCNetworkResource.groovy196
-rw-r--r--bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy8
-rw-r--r--bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/ActivateSDNCNetworkResource.bpmn33
3 files changed, 224 insertions, 13 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..e034393151 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,207 @@ 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")
+ }
+
+ 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 sndcTopologyCreateRequest =
+ """<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>${MsoUtils.xmlEscape(netowrkInputParameters)}</network-input-parameters>
+ </network-request-input>
+ </sdncadapterworkflow:SDNCRequestData>
+ </aetgt:SDNCAdapterWorkflowRequest>""".trim()
+
+ String sndcTopologyCreateRequesAsString = utils.formatXml(sndcTopologyCreateRequest)
+ msoLogger.debug(sndcTopologyCreateRequesAsString)
+ execution.setVariable("sdncAdapterWorkflowRequest", sndcTopologyCreateRequesAsString)
+ msoLogger.debug("sdncAdapterWorkflowRequest - " + "\n" + sndcTopologyCreateRequesAsString)
+
+ } 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/CreateSDNCNetworkResource.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy
index 1c0975f8c4..cc0f9bb5f4 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,9 +159,9 @@ 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"
diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/ActivateSDNCNetworkResource.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/ActivateSDNCNetworkResource.bpmn
index e44804a822..6b3641b235 100644
--- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/ActivateSDNCNetworkResource.bpmn
+++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/ActivateSDNCNetworkResource.bpmn
@@ -18,7 +18,7 @@
<camunda:out source="WorkflowException" target="WorkflowException" />
<camunda:in source="sdncAdapterWorkflowRequest" target="sdncAdapterWorkflowRequest" />
</bpmn:extensionElements>
- <bpmn:incoming>SequenceFlow_18l3crb</bpmn:incoming>
+ <bpmn:incoming>SequenceFlow_0sjrnv5</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_1xk5xed</bpmn:outgoing>
</bpmn:callActivity>
<bpmn:sequenceFlow id="SequenceFlow_1xk5xed" sourceRef="CallActivity_1600xlj" targetRef="Task_0uwlr22" />
@@ -30,7 +30,7 @@
def dcsi = new ActivateSDNCNetworkResource()
dcsi.postCreateSDNCCall(execution)</bpmn:script>
</bpmn:scriptTask>
- <bpmn:sequenceFlow id="SequenceFlow_18l3crb" sourceRef="Task_13sx2bp" targetRef="CallActivity_1600xlj" />
+ <bpmn:sequenceFlow id="SequenceFlow_18l3crb" sourceRef="Task_13sx2bp" targetRef="ScriptTask_1gih50a" />
<bpmn:scriptTask id="Task_13sx2bp" name="Pre Process Request" scriptFormat="groovy">
<bpmn:incoming>SequenceFlow_1c92ks3</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_18l3crb</bpmn:outgoing>
@@ -78,13 +78,21 @@ csi.sendSyncResponse(execution)</bpmn:script>
</bpmn:scriptTask>
<bpmn:sequenceFlow id="SequenceFlow_17md60u" sourceRef="ScriptTask_1g5zyi6" targetRef="EndEvent_1x6k78c" />
<bpmn:sequenceFlow id="SequenceFlow_1c92ks3" sourceRef="createNS_StartEvent" targetRef="Task_13sx2bp" />
+ <bpmn:scriptTask id="ScriptTask_1gih50a" name="Prepare SDNC Actiate request" scriptFormat="groovy">
+ <bpmn:incoming>SequenceFlow_18l3crb</bpmn:incoming>
+ <bpmn:outgoing>SequenceFlow_0sjrnv5</bpmn:outgoing>
+ <bpmn:script>import org.openecomp.mso.bpmn.infrastructure.scripts.*
+def dcsi = new ActivateSDNCNetworkResource()
+dcsi.prepareSDNCRequest(execution)</bpmn:script>
+ </bpmn:scriptTask>
+ <bpmn:sequenceFlow id="SequenceFlow_0sjrnv5" sourceRef="ScriptTask_1gih50a" targetRef="CallActivity_1600xlj" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="ActivateSDNCNetworkResource">
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="createNS_StartEvent">
- <dc:Bounds x="-203" y="306" width="36" height="36" />
+ <dc:Bounds x="-275" y="306" width="36" height="36" />
<bpmndi:BPMNLabel>
- <dc:Bounds x="-230" y="352" width="89" height="27" />
+ <dc:Bounds x="-302" y="352" width="89" height="27" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="EndEvent_15pcuuc_di" bpmnElement="EndEvent_1x6k78c">
@@ -114,14 +122,14 @@ csi.sendSyncResponse(execution)</bpmn:script>
<dc:Bounds x="594" y="284" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_18l3crb_di" bpmnElement="SequenceFlow_18l3crb">
- <di:waypoint x="12" y="324" />
- <di:waypoint x="77" y="324" />
+ <di:waypoint x="-105" y="324" />
+ <di:waypoint x="-63" y="324" />
<bpmndi:BPMNLabel>
<dc:Bounds x="235.5" y="108" width="90" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="ScriptTask_14l9mlv_di" bpmnElement="Task_13sx2bp">
- <dc:Bounds x="-88" y="284" width="100" height="80" />
+ <dc:Bounds x="-205" y="284" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="ScriptTask_0hu4lhm_di" bpmnElement="Task_0uwlr22">
<dc:Bounds x="247" y="284" width="100" height="80" />
@@ -154,8 +162,15 @@ csi.sendSyncResponse(execution)</bpmn:script>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_1c92ks3_di" bpmnElement="SequenceFlow_1c92ks3">
- <di:waypoint x="-167" y="324" />
- <di:waypoint x="-88" y="324" />
+ <di:waypoint x="-239" y="324" />
+ <di:waypoint x="-205" y="324" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNShape id="ScriptTask_1gih50a_di" bpmnElement="ScriptTask_1gih50a">
+ <dc:Bounds x="-63" y="284" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge id="SequenceFlow_0sjrnv5_di" bpmnElement="SequenceFlow_0sjrnv5">
+ <di:waypoint x="37" y="324" />
+ <di:waypoint x="77" y="324" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>