summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorseshukm <seshu.kumar.m@huawei.com>2017-10-26 13:13:20 +0530
committerseshukm <seshu.kumar.m@huawei.com>2017-10-26 13:13:20 +0530
commit5e83d43305c69c41d9d455a844e435501f6d3a6e (patch)
treeae499210d3101d933e00a3b4c47368d3db184a87
parent0bc351ed4e238cd0656e73d9d72f17b280c5a705 (diff)
fix update operation Status
fixing update of operation status for del e2e svc IssueId: SO-263 Change-Id: I797f36c54d4fd90f697b22d576666197b311713f Signed-off-by: seshukm <seshu.kumar.m@huawei.com>
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteCustomE2EServiceInstance.groovy96
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstance.groovy79
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/resources/process/DeleteCustomE2EServiceInstance.bpmn84
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCustomDeleteE2EServiceInstance.bpmn97
-rw-r--r--mso-api-handlers/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstances.java831
5 files changed, 1029 insertions, 158 deletions
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteCustomE2EServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteCustomE2EServiceInstance.groovy
index 7ab651c9b0..206e614630 100644
--- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteCustomE2EServiceInstance.groovy
+++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteCustomE2EServiceInstance.groovy
@@ -81,8 +81,7 @@ public class DeleteCustomE2EServiceInstance extends AbstractServiceTaskProcessor
msg = "Input serviceInstanceId' is null"
exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
}
-
-
+
String serviceType = execution.getVariable("serviceType")
if (isBlank(serviceType)) {
msg = "Input serviceType' is null"
@@ -90,6 +89,7 @@ public class DeleteCustomE2EServiceInstance extends AbstractServiceTaskProcessor
} else {
execution.setVariable("serviceType", serviceType)
}
+
//subscriberInfo
String globalSubscriberId = jsonUtil.getJsonValue(siRequest, "globalSubscriberId")
if (isBlank(globalSubscriberId)) {
@@ -98,7 +98,16 @@ public class DeleteCustomE2EServiceInstance extends AbstractServiceTaskProcessor
} else {
execution.setVariable("globalSubscriberId", globalSubscriberId)
}
- execution.setVariable("URN_mso_adapters_openecomp_db_endpoint","http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter")
+
+ //operationId
+ String operationId = jsonUtil.getJsonValue(siRequest, "operationId")
+ if (isBlank(operationId)) {
+ operationId = UUID.randomUUID().toString()
+ }
+ execution.setVariable("operationId", operationId)
+
+ execution.setVariable("URN_mso_adapters_openecomp_db_endpoint","http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter")
+
} catch (BpmnError e) {
throw e;
} catch (Exception ex){
@@ -116,7 +125,7 @@ public class DeleteCustomE2EServiceInstance extends AbstractServiceTaskProcessor
try {
String operationId = execution.getVariable("operationId")
- // RESTResponse (for API Handler (APIH) Reply Task)
+ // RESTResponse (for API Handler (APIH) Reply Task) : :
String syncResponse = """{"operationId":"${operationId}"}""".trim()
utils.log("DEBUG", " sendSynchResponse: xmlSyncResponse - " + "\n" + syncResponse, isDebugEnabled)
sendWorkflowResponse(execution, 202, syncResponse)
@@ -156,85 +165,6 @@ public class DeleteCustomE2EServiceInstance extends AbstractServiceTaskProcessor
}
- public void preInitResourcesOperStatus(Execution execution){
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
-
- utils.log("DEBUG", " ======== STARTED preInitResourcesOperStatus Process ======== ", isDebugEnabled)
- try{
- String serviceId = execution.getVariable("serviceInstanceId")
- String operationId = UUID.randomUUID().toString()
- String operationType = "DELETE"
- String resourceTemplateUUIDs = ""
- String result = "processing"
- String progress = "0"
- String reason = ""
- String operationContent = "Prepare service creation"
- utils.log("DEBUG", "Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId + " operationType:" + oprationType, isDebugEnabled)
- serviceId = UriUtils.encode(serviceId,"UTF-8")
- execution.setVariable("serviceInstanceId", serviceId)
- execution.setVariable("operationId", operationId)
- execution.setVariable("operationType", operationType)
- // we use resource instance ids for delete flow as resourceTemplateUUIDs
- /*[
- {
- "resourceInstanceId":"1111",
- "resourceType":"vIMS"
- },
- {
- "resourceInstanceId":"222",
- "resourceType":"vEPC"
- },
- {
- "resourceInstanceId":"3333",
- "resourceType":"overlay"
- },
- {
- "resourceInstanceId":"4444",
- "resourceType":"underlay"
- }
- ]*/
- String serviceRelationShip = execution.getVariable("serviceRelationShip")
-
- def jsonSlurper = new JsonSlurper()
- def jsonOutput = new JsonOutput()
- List relationShipList = jsonSlurper.parseText(serviceRelationShip)
-
- if (relationShipList != null) {
- relationShipList.each {
- resourceTemplateUUIDs = resourceTemplateUUIDs + it.resourceInstanceId + ":"
- }
- }
-
- def dbAdapterEndpoint = execution.getVariable("URN_mso_adapters_openecomp_db_endpoint")
- execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint)
- utils.log("DEBUG", "DB Adapter Endpoint is: " + dbAdapterEndpoint, isDebugEnabled)
-
- String payload =
- """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
- xmlns:ns="http://org.openecomp.mso/requestsdb">
- <soapenv:Header/>
- <soapenv:Body>
- <ns:initResourceOperationStatus xmlns:ns="http://org.openecomp.mso/requestsdb">
- <serviceId>${serviceId}</serviceId>
- <operationId>${operationId}</operationId>
- <operationType>${operationType}</operationType>
- <resourceTemplateUUIDs>${resourceTemplateUUIDs}</resourceTemplateUUIDs>
- </ns:initResourceOperationStatus>
- </soapenv:Body>
- </soapenv:Envelope>"""
-
- payload = utils.formatXml(payload)
- execution.setVariable("CVFMI_initResOperStatusRequest", payload)
- utils.log("DEBUG", "Outgoing initResourceOperationStatus: \n" + payload, isDebugEnabled)
- utils.logAudit("CreateVfModuleInfra Outgoing initResourceOperationStatus Request: " + payload)
-
- }catch(Exception e){
- utils.log("ERROR", "Exception Occured Processing preInitResourcesOperStatus. Exception is:\n" + e, isDebugEnabled)
- execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during preInitResourcesOperStatus Method:\n" + e.getMessage())
- }
- utils.log("DEBUG", "======== COMPLETED preInitResourcesOperStatus Process ======== ", isDebugEnabled)
- }
-
public void prepareCompletionRequest (Execution execution) {
def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
utils.log("DEBUG", " *** prepareCompletion *** ", isDebugEnabled)
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstance.groovy
index f141bbdeb0..cd0fe818bc 100644
--- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstance.groovy
+++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstance.groovy
@@ -472,6 +472,85 @@ public class DoCustomDeleteE2EServiceInstance extends AbstractServiceTaskProcess
utils.log("DEBUG"," *** Exit postProcessAAIDEL *** ", isDebugEnabled)
}
+ public void preInitResourcesOperStatus(Execution execution){
+ def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
+
+ utils.log("DEBUG", " ======== STARTED preInitResourcesOperStatus Process ======== ", isDebugEnabled)
+ try{
+ String serviceId = execution.getVariable("serviceInstanceId")
+ String operationId = execution.getVariable("operationId")
+ String operationType = execution.getVariable("operationType")
+ String resourceTemplateUUIDs = ""
+ String result = "processing"
+ String progress = "0"
+ String reason = ""
+ String operationContent = "Prepare service creation"
+ utils.log("DEBUG", "Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId + " operationType:" + oprationType, isDebugEnabled)
+ serviceId = UriUtils.encode(serviceId,"UTF-8")
+ execution.setVariable("serviceInstanceId", serviceId)
+ execution.setVariable("operationId", operationId)
+ execution.setVariable("operationType", operationType)
+ // we use resource instance ids for delete flow as resourceTemplateUUIDs
+ /*[
+ {
+ "resourceInstanceId":"1111",
+ "resourceType":"vIMS"
+ },
+ {
+ "resourceInstanceId":"222",
+ "resourceType":"vEPC"
+ },
+ {
+ "resourceInstanceId":"3333",
+ "resourceType":"overlay"
+ },
+ {
+ "resourceInstanceId":"4444",
+ "resourceType":"underlay"
+ }
+ ]*/
+ String serviceRelationShip = execution.getVariable("serviceRelationShip")
+
+ def jsonSlurper = new JsonSlurper()
+ def jsonOutput = new JsonOutput()
+ List relationShipList = jsonSlurper.parseText(serviceRelationShip)
+
+ if (relationShipList != null) {
+ relationShipList.each {
+ resourceTemplateUUIDs = resourceTemplateUUIDs + it.resourceInstanceId + ":"
+ }
+ }
+
+ def dbAdapterEndpoint = execution.getVariable("URN_mso_openecomp_adapters_db_endpoint")
+ execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint)
+ utils.log("DEBUG", "DB Adapter Endpoint is: " + dbAdapterEndpoint, isDebugEnabled)
+
+ String payload =
+ """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
+ xmlns:ns="http://org.openecomp.mso/requestsdb">
+ <soapenv:Header/>
+ <soapenv:Body>
+ <ns:initResourceOperationStatus xmlns:ns="http://org.openecomp.mso/requestsdb">
+ <serviceId>${serviceId}</serviceId>
+ <operationId>${operationId}</operationId>
+ <operationType>${operationType}</operationType>
+ <resourceTemplateUUIDs>${resourceTemplateUUIDs}</resourceTemplateUUIDs>
+ </ns:initResourceOperationStatus>
+ </soapenv:Body>
+ </soapenv:Envelope>"""
+
+ payload = utils.formatXml(payload)
+ execution.setVariable("CVFMI_initResOperStatusRequest", payload)
+ utils.log("DEBUG", "Outgoing initResourceOperationStatus: \n" + payload, isDebugEnabled)
+ utils.logAudit("CreateVfModuleInfra Outgoing initResourceOperationStatus Request: " + payload)
+
+ }catch(Exception e){
+ utils.log("ERROR", "Exception Occured Processing preInitResourcesOperStatus. Exception is:\n" + e, isDebugEnabled)
+ execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during preInitResourcesOperStatus Method:\n" + e.getMessage())
+ }
+ utils.log("DEBUG", "======== COMPLETED preInitResourcesOperStatus Process ======== ", isDebugEnabled)
+ }
+
/**
* prepare delete parameters
*/
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DeleteCustomE2EServiceInstance.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DeleteCustomE2EServiceInstance.bpmn
index 0273983104..c6a6d02e4c 100644
--- a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DeleteCustomE2EServiceInstance.bpmn
+++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DeleteCustomE2EServiceInstance.bpmn
@@ -109,7 +109,7 @@ csi.sendSyncError(execution)]]></bpmn:script>
<bpmn:sequenceFlow id="SequenceFlow_1py6yqz" sourceRef="ScriptTask_0so3xj0" targetRef="CallActivity_1qhekgt" />
</bpmn:subProcess>
<bpmn:scriptTask id="ScriptTask_1mao77y" name="Send Sync Ack Response" scriptFormat="groovy">
- <bpmn:incoming>SequenceFlow_1x62wqv</bpmn:incoming>
+ <bpmn:incoming>SequenceFlow_0yowshs</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_0zf2qyk</bpmn:outgoing>
<bpmn:script><![CDATA[import org.openecomp.mso.bpmn.infrastructure.scripts.*
def csi = new DeleteCustomE2EServiceInstance()
@@ -128,20 +128,12 @@ csi.sendSyncResponse(execution)]]></bpmn:script>
<bpmn:sequenceFlow id="SequenceFlow_0zf2qyk" sourceRef="ScriptTask_1mao77y" targetRef="CallActivity_1vyx9hu" />
<bpmn:sequenceFlow id="SequenceFlow_07hrbs0" sourceRef="CallActivity_1vyx9hu" targetRef="ExclusiveGateway_0vu8gx6" />
<bpmn:sequenceFlow id="SequenceFlow_1ab5l2q" sourceRef="CallActivity_1wx4ihe" targetRef="EndEvent_0db8bs6" />
- <bpmn:sequenceFlow id="SequenceFlow_0yowshs" sourceRef="ScriptTask_0a63hms" targetRef="ScriptTask_1fhsuor" />
+ <bpmn:sequenceFlow id="SequenceFlow_0yowshs" sourceRef="ScriptTask_0a63hms" targetRef="ScriptTask_1mao77y" />
<bpmn:sequenceFlow id="SequenceFlow_04urx2e" name="yes" sourceRef="ExclusiveGateway_0vu8gx6" targetRef="ScriptTask_1fzpbop">
<bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[#{execution.getVariable("WorkflowException") == null}]]></bpmn:conditionExpression>
</bpmn:sequenceFlow>
<bpmn:sequenceFlow id="SequenceFlow_1ii935p" sourceRef="ScriptTask_1fzpbop" targetRef="CallActivity_1wx4ihe" />
<bpmn:sequenceFlow id="SequenceFlow_1t6ekab" name="no" sourceRef="ExclusiveGateway_0vu8gx6" targetRef="EndEvent_1i1g9s6" />
- <bpmn:scriptTask id="ScriptTask_1fhsuor" name="Prepare Resource Oper Status">
- <bpmn:incoming>SequenceFlow_0yowshs</bpmn:incoming>
- <bpmn:outgoing>SequenceFlow_1x62wqv</bpmn:outgoing>
- <bpmn:script><![CDATA[import org.openecomp.mso.bpmn.infrastructure.scripts.*
-def ddsi = new DeleteCustomE2EServiceInstance()
-ddsi.preInitResourcesOperStatus(execution)]]></bpmn:script>
- </bpmn:scriptTask>
- <bpmn:sequenceFlow id="SequenceFlow_1x62wqv" sourceRef="ScriptTask_1fhsuor" targetRef="ScriptTask_1mao77y" />
</bpmn:process>
<bpmn:error id="Error_1erlsmy" name="MSO Workflow Exception" errorCode="MSOWorkflowException" />
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
@@ -156,39 +148,39 @@ ddsi.preInitResourcesOperStatus(execution)]]></bpmn:script>
<dc:Bounds x="834" y="660" width="394" height="188" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="CallActivity_1vyx9hu_di" bpmnElement="CallActivity_1vyx9hu">
- <dc:Bounds x="1385" y="187" width="100" height="80" />
+ <dc:Bounds x="1159" y="187" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="EndEvent_0db8bs6_di" bpmnElement="EndEvent_0db8bs6">
- <dc:Bounds x="1910" y="304" width="36" height="36" />
+ <dc:Bounds x="1686" y="304" width="36" height="36" />
<bpmndi:BPMNLabel>
- <dc:Bounds x="1921" y="340" width="19" height="12" />
+ <dc:Bounds x="1696" y="340" width="22" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="ScriptTask_0a63hms_di" bpmnElement="ScriptTask_0a63hms">
<dc:Bounds x="724" y="187" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="ScriptTask_1fzpbop_di" bpmnElement="ScriptTask_1fzpbop">
- <dc:Bounds x="1717" y="187" width="100" height="80" />
+ <dc:Bounds x="1493" y="187" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="CallActivity_1wx4ihe_di" bpmnElement="CallActivity_1wx4ihe">
- <dc:Bounds x="1878" y="187" width="100" height="80" />
+ <dc:Bounds x="1654" y="187" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="SubProcess_1vbcima_di" bpmnElement="SubProcess_1vbcima" isExpanded="true">
<dc:Bounds x="736" y="374" width="679" height="194" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="ScriptTask_1mao77y_di" bpmnElement="ScriptTask_1mao77y">
- <dc:Bounds x="1221" y="187" width="100" height="80" />
+ <dc:Bounds x="936" y="187" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="ExclusiveGateway_0vu8gx6_di" bpmnElement="ExclusiveGateway_0vu8gx6" isMarkerVisible="true">
- <dc:Bounds x="1582" y="202" width="50" height="50" />
+ <dc:Bounds x="1358" y="202" width="50" height="50" />
<bpmndi:BPMNLabel>
- <dc:Bounds x="1582" y="174" width="49" height="12" />
+ <dc:Bounds x="1358" y="174" width="50" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="EndEvent_1i1g9s6_di" bpmnElement="EndEvent_1i1g9s6">
- <dc:Bounds x="1589" y="304" width="36" height="36" />
+ <dc:Bounds x="1365" y="304" width="36" height="36" />
<bpmndi:BPMNLabel>
- <dc:Bounds x="1517" y="340" width="90" height="12" />
+ <dc:Bounds x="1293" y="340" width="90" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_1wxumid_di" bpmnElement="SequenceFlow_1wxumid">
@@ -199,54 +191,52 @@ ddsi.preInitResourcesOperStatus(execution)]]></bpmn:script>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_0zf2qyk_di" bpmnElement="SequenceFlow_0zf2qyk">
- <di:waypoint xsi:type="dc:Point" x="1321" y="227" />
- <di:waypoint xsi:type="dc:Point" x="1385" y="227" />
+ <di:waypoint xsi:type="dc:Point" x="1036" y="227" />
+ <di:waypoint xsi:type="dc:Point" x="1159" y="227" />
<bpmndi:BPMNLabel>
- <dc:Bounds x="1308" y="206" width="90" height="12" />
+ <dc:Bounds x="1052.5" y="206" width="90" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_07hrbs0_di" bpmnElement="SequenceFlow_07hrbs0">
- <di:waypoint xsi:type="dc:Point" x="1485" y="227" />
- <di:waypoint xsi:type="dc:Point" x="1582" y="227" />
+ <di:waypoint xsi:type="dc:Point" x="1259" y="227" />
+ <di:waypoint xsi:type="dc:Point" x="1358" y="227" />
<bpmndi:BPMNLabel>
- <dc:Bounds x="1488.5" y="206" width="90" height="12" />
+ <dc:Bounds x="1263.5" y="206" width="90" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_1ab5l2q_di" bpmnElement="SequenceFlow_1ab5l2q">
- <di:waypoint xsi:type="dc:Point" x="1928" y="267" />
- <di:waypoint xsi:type="dc:Point" x="1928" y="304" />
+ <di:waypoint xsi:type="dc:Point" x="1704" y="267" />
+ <di:waypoint xsi:type="dc:Point" x="1704" y="304" />
<bpmndi:BPMNLabel>
- <dc:Bounds x="1898" y="280" width="90" height="12" />
+ <dc:Bounds x="1674" y="280" width="90" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_0yowshs_di" bpmnElement="SequenceFlow_0yowshs">
<di:waypoint xsi:type="dc:Point" x="824" y="227" />
- <di:waypoint xsi:type="dc:Point" x="892" y="227" />
+ <di:waypoint xsi:type="dc:Point" x="936" y="227" />
<bpmndi:BPMNLabel>
- <dc:Bounds x="813" y="206" width="90" height="12" />
+ <dc:Bounds x="835" y="206" width="90" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_04urx2e_di" bpmnElement="SequenceFlow_04urx2e">
- <di:waypoint xsi:type="dc:Point" x="1632" y="227" />
- <di:waypoint xsi:type="dc:Point" x="1717" y="227" />
+ <di:waypoint xsi:type="dc:Point" x="1408" y="227" />
+ <di:waypoint xsi:type="dc:Point" x="1493" y="227" />
<bpmndi:BPMNLabel>
- <dc:Bounds x="1634" y="203" width="19" height="12" />
+ <dc:Bounds x="1410" y="203" width="20" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_1ii935p_di" bpmnElement="SequenceFlow_1ii935p">
- <di:waypoint xsi:type="dc:Point" x="1817" y="227" />
- <di:waypoint xsi:type="dc:Point" x="1878" y="227" />
+ <di:waypoint xsi:type="dc:Point" x="1593" y="227" />
+ <di:waypoint xsi:type="dc:Point" x="1654" y="227" />
<bpmndi:BPMNLabel>
- <dc:Bounds x="1759" y="212" width="90" height="12" />
+ <dc:Bounds x="1535" y="212" width="90" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_1t6ekab_di" bpmnElement="SequenceFlow_1t6ekab">
- <di:waypoint xsi:type="dc:Point" x="1607" y="252" />
- <di:waypoint xsi:type="dc:Point" x="1607" y="277" />
- <di:waypoint xsi:type="dc:Point" x="1607" y="277" />
- <di:waypoint xsi:type="dc:Point" x="1607" y="304" />
+ <di:waypoint xsi:type="dc:Point" x="1383" y="252" />
+ <di:waypoint xsi:type="dc:Point" x="1383" y="304" />
<bpmndi:BPMNLabel>
- <dc:Bounds x="1616" y="277" width="12" height="12" />
+ <dc:Bounds x="1391" y="277" width="15" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="ScriptTask_1c6ogpt_di" bpmnElement="ScriptTask_1c6ogpt">
@@ -331,16 +321,6 @@ ddsi.preInitResourcesOperStatus(execution)]]></bpmn:script>
<dc:Bounds x="1060" y="463" width="90" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
- <bpmndi:BPMNShape id="ScriptTask_1fhsuor_di" bpmnElement="ScriptTask_1fhsuor">
- <dc:Bounds x="892" y="187" width="100" height="80" />
- </bpmndi:BPMNShape>
- <bpmndi:BPMNEdge id="SequenceFlow_1x62wqv_di" bpmnElement="SequenceFlow_1x62wqv">
- <di:waypoint xsi:type="dc:Point" x="992" y="227" />
- <di:waypoint xsi:type="dc:Point" x="1221" y="227" />
- <bpmndi:BPMNLabel>
- <dc:Bounds x="1061.5" y="206" width="90" height="12" />
- </bpmndi:BPMNLabel>
- </bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCustomDeleteE2EServiceInstance.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCustomDeleteE2EServiceInstance.bpmn
index ea7056d1b4..22246316d2 100644
--- a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCustomDeleteE2EServiceInstance.bpmn
+++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCustomDeleteE2EServiceInstance.bpmn
@@ -112,7 +112,7 @@ ex.processJavaException(execution)]]></bpmn:script>
<bpmn:incoming>SequenceFlow_1wmjau1</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_0qquvgc</bpmn:outgoing>
</bpmn:callActivity>
- <bpmn:sequenceFlow id="SequenceFlow_1av166w" sourceRef="ExclusiveGateway_0veiutm" targetRef="ScriptTask_0z30dax" />
+ <bpmn:sequenceFlow id="SequenceFlow_1av166w" sourceRef="ExclusiveGateway_0veiutm" targetRef="ScriptTask_146jt8v" />
<bpmn:sequenceFlow id="SequenceFlow_0qquvgc" sourceRef="CallActivity_Del_VFC" targetRef="ScriptTask_0mdub03" />
<bpmn:scriptTask id="ScriptTask_0vcz9mj" name="Prepare Resource Delele For vEPC" scriptFormat="groovy">
<bpmn:incoming>SequenceFlow_1931m8u</bpmn:incoming>
@@ -142,7 +142,7 @@ def ddsi = new DoCustomDeleteE2EServiceInstance()
ddsi.postProcessSDNCDelete(execution, response, "delete")]]></bpmn:script>
</bpmn:scriptTask>
<bpmn:scriptTask id="ScriptTask_0z30dax" name="Prepare Resource Delele For Overlay" scriptFormat="groovy">
- <bpmn:incoming>SequenceFlow_1av166w</bpmn:incoming>
+ <bpmn:incoming>SequenceFlow_0l4w9nr</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_1dza4q4</bpmn:outgoing>
<bpmn:script><![CDATA[import org.openecomp.mso.bpmn.infrastructure.scripts.*
String resourceName = "overlay"
@@ -203,6 +203,37 @@ ddsi.preResourceDelete(execution, resourceName )]]></bpmn:script>
<bpmn:incoming>SequenceFlow_1g4djgh</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_0uc2beq</bpmn:outgoing>
</bpmn:serviceTask>
+ <bpmn:scriptTask id="ScriptTask_146jt8v" name="Prepare Resource Oper Status">
+ <bpmn:incoming>SequenceFlow_1av166w</bpmn:incoming>
+ <bpmn:outgoing>SequenceFlow_1ym9otf</bpmn:outgoing>
+ <bpmn:script><![CDATA[import org.openecomp.mso.bpmn.infrastructure.scripts.*
+def ddsi = new DoCustomDeleteE2EServiceInstance()
+ddsi.preInitResourcesOperStatus(execution)]]></bpmn:script>
+ </bpmn:scriptTask>
+ <bpmn:serviceTask id="ServiceTask_00tg69u" name="Init Resource Oper Status">
+ <bpmn:extensionElements>
+ <camunda:connector>
+ <camunda:inputOutput>
+ <camunda:inputParameter name="url">${URN_mso_openecomp_adapters_db_endpoint}</camunda:inputParameter>
+ <camunda:inputParameter name="headers">
+ <camunda:map>
+ <camunda:entry key="content-type">application/soap+xml</camunda:entry>
+ <camunda:entry key="Authorization">#{BasicAuthHeaderValueDB}</camunda:entry>
+ </camunda:map>
+ </camunda:inputParameter>
+ <camunda:inputParameter name="payload">${CVFMI_initResOperStatusRequest}</camunda:inputParameter>
+ <camunda:inputParameter name="method">POST</camunda:inputParameter>
+ <camunda:outputParameter name="CVFMI_dbResponseCode">${statusCode}</camunda:outputParameter>
+ <camunda:outputParameter name="CVFMI_dbResponse">${response}</camunda:outputParameter>
+ </camunda:inputOutput>
+ <camunda:connectorId>http-connector</camunda:connectorId>
+ </camunda:connector>
+ </bpmn:extensionElements>
+ <bpmn:incoming>SequenceFlow_1ym9otf</bpmn:incoming>
+ <bpmn:outgoing>SequenceFlow_0l4w9nr</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:sequenceFlow id="SequenceFlow_1ym9otf" sourceRef="ScriptTask_146jt8v" targetRef="ServiceTask_00tg69u" />
+ <bpmn:sequenceFlow id="SequenceFlow_0l4w9nr" sourceRef="ServiceTask_00tg69u" targetRef="ScriptTask_0z30dax" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DoCustomDeleteE2EServiceInstance">
@@ -344,9 +375,9 @@ ddsi.preResourceDelete(execution, resourceName )]]></bpmn:script>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_1av166w_di" bpmnElement="SequenceFlow_1av166w">
<di:waypoint xsi:type="dc:Point" x="42" y="-17" />
- <di:waypoint xsi:type="dc:Point" x="167" y="-17" />
+ <di:waypoint xsi:type="dc:Point" x="83" y="-17" />
<bpmndi:BPMNLabel>
- <dc:Bounds x="59.5" y="-38" width="90" height="12" />
+ <dc:Bounds x="17.5" y="-38" width="90" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_0qquvgc_di" bpmnElement="SequenceFlow_0qquvgc">
@@ -373,20 +404,20 @@ ddsi.preResourceDelete(execution, resourceName )]]></bpmn:script>
<dc:Bounds x="1188" y="-57" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="ScriptTask_0z30dax_di" bpmnElement="ScriptTask_0z30dax">
- <dc:Bounds x="167" y="-57" width="100" height="80" />
+ <dc:Bounds x="356" y="-57" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_1dza4q4_di" bpmnElement="SequenceFlow_1dza4q4">
- <di:waypoint xsi:type="dc:Point" x="267" y="-17" />
- <di:waypoint xsi:type="dc:Point" x="360" y="-17" />
+ <di:waypoint xsi:type="dc:Point" x="456" y="-17" />
+ <di:waypoint xsi:type="dc:Point" x="524" y="-17" />
<bpmndi:BPMNLabel>
- <dc:Bounds x="268.5" y="-38" width="90" height="12" />
+ <dc:Bounds x="445" y="-38" width="90" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_0rpu756_di" bpmnElement="SequenceFlow_0rpu756">
- <di:waypoint xsi:type="dc:Point" x="460" y="-17" />
- <di:waypoint xsi:type="dc:Point" x="564" y="-17" />
+ <di:waypoint xsi:type="dc:Point" x="624" y="-17" />
+ <di:waypoint xsi:type="dc:Point" x="692" y="-17" />
<bpmndi:BPMNLabel>
- <dc:Bounds x="467" y="-38" width="90" height="12" />
+ <dc:Bounds x="613" y="-38" width="90" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_0uhpfcl_di" bpmnElement="SequenceFlow_0uhpfcl">
@@ -432,38 +463,58 @@ ddsi.preResourceDelete(execution, resourceName )]]></bpmn:script>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="ServiceTask_0v9q75y_di" bpmnElement="CallActivity_Del_SDNC_cust">
- <dc:Bounds x="360" y="-57" width="100" height="80" />
+ <dc:Bounds x="524" y="-57" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_0d9lmlv_di" bpmnElement="SequenceFlow_0d9lmlv">
- <di:waypoint xsi:type="dc:Point" x="664" y="-17" />
- <di:waypoint xsi:type="dc:Point" x="769" y="-17" />
+ <di:waypoint xsi:type="dc:Point" x="792" y="-17" />
+ <di:waypoint xsi:type="dc:Point" x="855" y="-17" />
<bpmndi:BPMNLabel>
- <dc:Bounds x="671.5" y="-38" width="90" height="12" />
+ <dc:Bounds x="778.5" y="-38" width="90" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_1g4djgh_di" bpmnElement="SequenceFlow_1g4djgh">
- <di:waypoint xsi:type="dc:Point" x="869" y="-17" />
- <di:waypoint xsi:type="dc:Point" x="971" y="-17" />
+ <di:waypoint xsi:type="dc:Point" x="955" y="-17" />
+ <di:waypoint xsi:type="dc:Point" x="1021" y="-17" />
<bpmndi:BPMNLabel>
- <dc:Bounds x="875" y="-38" width="90" height="12" />
+ <dc:Bounds x="943" y="-38" width="90" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_0uc2beq_di" bpmnElement="SequenceFlow_0uc2beq">
- <di:waypoint xsi:type="dc:Point" x="1071" y="-17" />
+ <di:waypoint xsi:type="dc:Point" x="1121" y="-17" />
<di:waypoint xsi:type="dc:Point" x="1188" y="-17" />
<bpmndi:BPMNLabel>
- <dc:Bounds x="1084.5" y="-38" width="90" height="12" />
+ <dc:Bounds x="1109.5" y="-38" width="90" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="ScriptTask_1e5z0wu_di" bpmnElement="Task_14erap6">
- <dc:Bounds x="564" y="-57" width="100" height="80" />
+ <dc:Bounds x="692" y="-57" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="ServiceTask_0f0965f_di" bpmnElement="Task_1j1u666">
- <dc:Bounds x="769" y="-57" width="100" height="80" />
+ <dc:Bounds x="855" y="-57" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="ServiceTask_0p4b7e1_di" bpmnElement="Task_0edkv0m">
- <dc:Bounds x="971" y="-57" width="100" height="80" />
+ <dc:Bounds x="1021" y="-57" width="100" height="80" />
</bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="ScriptTask_146jt8v_di" bpmnElement="ScriptTask_146jt8v">
+ <dc:Bounds x="83" y="-57" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="ServiceTask_00tg69u_di" bpmnElement="ServiceTask_00tg69u">
+ <dc:Bounds x="208" y="-57" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge id="SequenceFlow_1ym9otf_di" bpmnElement="SequenceFlow_1ym9otf">
+ <di:waypoint xsi:type="dc:Point" x="183" y="-17" />
+ <di:waypoint xsi:type="dc:Point" x="208" y="-17" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="151.5" y="-38" width="0" height="12" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="SequenceFlow_0l4w9nr_di" bpmnElement="SequenceFlow_0l4w9nr">
+ <di:waypoint xsi:type="dc:Point" x="308" y="-17" />
+ <di:waypoint xsi:type="dc:Point" x="356" y="-17" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="332" y="-38" width="0" height="12" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
diff --git a/mso-api-handlers/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstances.java b/mso-api-handlers/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstances.java
new file mode 100644
index 0000000000..ecd0e4d4cc
--- /dev/null
+++ b/mso-api-handlers/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstances.java
@@ -0,0 +1,831 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 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.apihandlerinfra;
+
+import java.io.IOException;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpStatus;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.hibernate.Session;
+import org.json.JSONObject;
+import org.openecomp.mso.apihandler.common.ErrorNumbers;
+import org.openecomp.mso.apihandler.common.RequestClient;
+import org.openecomp.mso.apihandler.common.RequestClientFactory;
+import org.openecomp.mso.apihandler.common.ResponseHandler;
+import org.openecomp.mso.apihandlerinfra.Messages;
+import org.openecomp.mso.apihandlerinfra.MsoException;
+import org.openecomp.mso.apihandlerinfra.MsoRequest;
+import org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans.DelE2ESvcResp;
+import org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans.E2EServiceInstanceDeleteRequest;
+import org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans.E2EServiceInstanceRequest;
+import org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans.E2EUserParam;
+import org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans.GetE2EServiceInstanceResponse;
+import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.ModelInfo;
+import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.RequestDetails;
+import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.RequestInfo;
+import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.RequestParameters;
+import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.ServiceInstancesRequest;
+import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.SubscriberInfo;
+import org.openecomp.mso.db.AbstractSessionFactoryManager;
+import org.openecomp.mso.db.catalog.CatalogDatabase;
+import org.openecomp.mso.db.catalog.beans.Service;
+import org.openecomp.mso.db.catalog.beans.ServiceRecipe;
+import org.openecomp.mso.logger.MessageEnum;
+import org.openecomp.mso.logger.MsoAlarmLogger;
+import org.openecomp.mso.logger.MsoLogger;
+import org.openecomp.mso.requestsdb.InfraActiveRequests;
+import org.openecomp.mso.requestsdb.OperationStatus;
+import org.openecomp.mso.requestsdb.RequestsDatabase;
+import org.openecomp.mso.requestsdb.RequestsDbSessionFactoryManager;
+import org.openecomp.mso.utils.UUIDChecker;
+
+import com.wordnik.swagger.annotations.Api;
+import com.wordnik.swagger.annotations.ApiOperation;
+
+@Path("/e2eServiceInstances")
+@Api(value = "/e2eServiceInstances", description = "API Requests for E2E Service Instances")
+public class E2EServiceInstances {
+
+ private HashMap<String, String> instanceIdMap = new HashMap<>();
+ private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH);
+ private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger();
+ public static final String MSO_PROP_APIHANDLER_INFRA = "MSO_PROP_APIHANDLER_INFRA";
+ private ServiceInstancesRequest sir = null;
+
+ public static final String END_OF_THE_TRANSACTION = "End of the transaction, the final response is: ";
+ public static final String EXCEPTION_CREATING_DB_RECORD = "Exception while creating record in DB";
+ public static final String EXCEPTION_COMMUNICATE_BPMN_ENGINE = "Exception while communicate with BPMN engine";
+
+ /**
+ * POST Requests for E2E Service create Instance on a version provided
+ */
+
+ @POST
+ @Path("/{version:[vV][3-5]}")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value = "Create a E2E Service Instance on a version provided", response = Response.class)
+ public Response createE2EServiceInstance(String request, @PathParam("version") String version) {
+
+ return processE2EserviceInstances(request, Action.createInstance, null, version);
+ }
+
+ /**
+ * DELETE Requests for E2E Service delete Instance on a specified version
+ * and serviceId
+ */
+
+ @DELETE
+ @Path("/{version:[vV][3-5]}/{serviceId}")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value = "Delete E2E Service Instance on a specified version and serviceId", response = Response.class)
+ public Response deleteE2EServiceInstance(String request, @PathParam("version") String version,
+ @PathParam("serviceId") String serviceId) {
+
+ instanceIdMap.put("serviceId", serviceId);
+
+ return deleteE2EserviceInstances(request, Action.deleteInstance, instanceIdMap, version);
+ }
+
+ @GET
+ @Path("/{version:[vV][3-5]}/{serviceId}/operations/{operationId}")
+ @ApiOperation(value = "Find e2eServiceInstances Requests for a given serviceId and operationId", response = Response.class)
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response getE2EServiceInstances(@PathParam("serviceId") String serviceId,
+ @PathParam("version") String version, @PathParam("operationId") String operationId) {
+ RequestsDatabase requestsDB = RequestsDatabase.getInstance();
+
+ GetE2EServiceInstanceResponse e2eServiceResponse = new GetE2EServiceInstanceResponse();
+
+ MsoRequest msoRequest = new MsoRequest(serviceId);
+
+ long startTime = System.currentTimeMillis();
+
+ OperationStatus operationStatus = null;
+
+ try {
+ operationStatus = requestsDB.getOperationStatus(serviceId, operationId);
+
+ } catch (Exception e) {
+ msoLogger.error(MessageEnum.APIH_DB_ACCESS_EXC, MSO_PROP_APIHANDLER_INFRA, "", "",
+ MsoLogger.ErrorCode.AvailabilityError,
+ "Exception while communciate with Request DB - Infra Request Lookup", e);
+ msoRequest.setStatus(org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
+ Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND,
+ MsoException.ServiceException, e.getMessage(), ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB, null);
+ alarmLogger.sendAlarm("MsoDatabaseAccessError", MsoAlarmLogger.CRITICAL,
+ Messages.errors.get(ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB));
+ msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError,
+ "Exception while communciate with Request DB");
+ msoLogger.debug("End of the transaction, the final response is: " + (String) response.getEntity());
+ return response;
+
+ }
+
+ if (operationStatus == null) {
+ Response resp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NO_CONTENT,
+ MsoException.ServiceException, "E2E serviceId " + serviceId + " is not found in DB",
+ ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, null);
+ msoLogger.error(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "",
+ MsoLogger.ErrorCode.BusinessProcesssError,
+ "Null response from RequestDB when searching by serviceId");
+ msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound,
+ "Null response from RequestDB when searching by serviceId");
+ msoLogger.debug("End of the transaction, the final response is: " + (String) resp.getEntity());
+ return resp;
+
+ }
+
+ e2eServiceResponse.setE2eRequest(operationStatus);
+
+ return Response.status(200).entity(e2eServiceResponse).build();
+ }
+
+ private Response deleteE2EserviceInstances(String requestJSON, Action action,
+ HashMap<String, String> instanceIdMap, String version) {
+ //TODO should be a new one or the same service instance Id
+ String requestId = instanceIdMap.get("serviceId");
+ long startTime = System.currentTimeMillis();
+ msoLogger.debug("requestId is: " + requestId);
+ E2EServiceInstanceDeleteRequest e2eDelReq = null;
+
+ MsoRequest msoRequest = new MsoRequest(requestId);
+
+ ObjectMapper mapper = new ObjectMapper();
+ try {
+ e2eDelReq = mapper.readValue(requestJSON, E2EServiceInstanceDeleteRequest.class);
+
+ } catch (Exception e) {
+
+ msoLogger.debug("Mapping of request to JSON object failed : ", e);
+ Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST,
+ MsoException.ServiceException, "Mapping of request to JSON object failed. " + e.getMessage(),
+ ErrorNumbers.SVC_BAD_PARAMETER, null);
+ msoLogger.error(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "",
+ MsoLogger.ErrorCode.SchemaError, requestJSON, e);
+ msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError,
+ "Mapping of request to JSON object failed");
+ msoLogger.debug("End of the transaction, the final response is: " + (String) response.getEntity());
+ createOperationStatusRecordForError(action, requestId);
+ return response;
+ }
+
+ CatalogDatabase db = null;
+ RecipeLookupResult recipeLookupResult = null;
+ try {
+ db = CatalogDatabase.getInstance();
+ recipeLookupResult = getServiceInstanceOrchestrationURI(db, action);
+ } catch (Exception e) {
+ msoLogger.error(MessageEnum.APIH_DB_ACCESS_EXC, MSO_PROP_APIHANDLER_INFRA, "", "",
+ MsoLogger.ErrorCode.AvailabilityError, "Exception while communciate with Catalog DB", e);
+ msoRequest.setStatus(org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
+ Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND,
+ MsoException.ServiceException, "No communication to catalog DB " + e.getMessage(),
+ ErrorNumbers.SVC_NO_SERVER_RESOURCES, null);
+ alarmLogger.sendAlarm("MsoDatabaseAccessError", MsoAlarmLogger.CRITICAL,
+ Messages.errors.get(ErrorNumbers.NO_COMMUNICATION_TO_CATALOG_DB));
+ msoRequest.createRequestRecord(Status.FAILED, action);
+ msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError,
+ "Exception while communciate with DB");
+ msoLogger.debug(END_OF_THE_TRANSACTION + (String) response.getEntity());
+ return response;
+ } finally {
+ closeCatalogDB(db);
+ }
+ if (recipeLookupResult == null) {
+ msoLogger.error(MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, MSO_PROP_APIHANDLER_INFRA, "", "",
+ MsoLogger.ErrorCode.DataError, "No recipe found in DB");
+ msoRequest.setStatus(org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
+ Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND,
+ MsoException.ServiceException, "Recipe does not exist in catalog DB",
+ ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null);
+ msoRequest.createRequestRecord(Status.FAILED, action);
+ msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound,
+ "No recipe found in DB");
+ msoLogger.debug(END_OF_THE_TRANSACTION + (String) response.getEntity());
+ createOperationStatusRecordForError(action, requestId);
+ return response;
+ }
+
+
+ RequestClient requestClient = null;
+ HttpResponse response = null;
+
+ long subStartTime = System.currentTimeMillis();
+ //String sirRequestJson = mapReqJsonToSvcInstReq(e2eSir, requestJSON);
+
+ try {
+ requestClient = RequestClientFactory.getRequestClient(recipeLookupResult.getOrchestrationURI(),
+ MsoPropertiesUtils.loadMsoProperties());
+
+ JSONObject jjo = new JSONObject(requestJSON);
+ jjo.put("operationId", UUIDChecker.generateUUID(msoLogger));
+
+ String bpmnRequest = jjo.toString();
+
+ // Capture audit event
+ msoLogger.debug("MSO API Handler Posting call to BPEL engine for url: " + requestClient.getUrl());
+ String serviceId = instanceIdMap.get("serviceId");
+ String serviceInstanceType = e2eDelReq.getServiceType();
+ response = requestClient.post(requestId, false, recipeLookupResult.getRecipeTimeout(), action.name(),
+ serviceId, null, null, null, null, serviceInstanceType, null, null, null, bpmnRequest);
+
+ msoLogger.recordMetricEvent(subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
+ "Successfully received response from BPMN engine", "BPMN", recipeLookupResult.getOrchestrationURI(),
+ null);
+ } catch (Exception e) {
+ msoLogger.recordMetricEvent(subStartTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with BPMN engine", "BPMN",
+ recipeLookupResult.getOrchestrationURI(), null);
+ Response resp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY,
+ MsoException.ServiceException, "Failed calling bpmn " + e.getMessage(),
+ ErrorNumbers.SVC_NO_SERVER_RESOURCES, null);
+ alarmLogger.sendAlarm("MsoConfigurationError", MsoAlarmLogger.CRITICAL,
+ Messages.errors.get(ErrorNumbers.NO_COMMUNICATION_TO_BPEL));
+ msoLogger.error(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "",
+ MsoLogger.ErrorCode.AvailabilityError, "Exception while communicate with BPMN engine");
+ msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError,
+ "Exception while communicate with BPMN engine");
+ msoLogger.debug("End of the transaction, the final response is: " + (String) resp.getEntity());
+ createOperationStatusRecordForError(action, requestId);
+ return resp;
+ }
+
+ if (response == null) {
+ Response resp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY,
+ MsoException.ServiceException, "bpelResponse is null", ErrorNumbers.SVC_NO_SERVER_RESOURCES, null);
+ msoLogger.error(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "",
+ MsoLogger.ErrorCode.BusinessProcesssError, "Null response from BPEL");
+ msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError,
+ "Null response from BPMN");
+ msoLogger.debug(END_OF_THE_TRANSACTION + (String) resp.getEntity());
+ createOperationStatusRecordForError(action, requestId);
+ return resp;
+ }
+
+ ResponseHandler respHandler = new ResponseHandler(response, requestClient.getType());
+ int bpelStatus = respHandler.getStatus();
+
+ return beplStatusUpdate(requestId, startTime, msoRequest, requestClient, respHandler, bpelStatus, action);
+ }
+
+ private Response processE2EserviceInstances(String requestJSON, Action action,
+ HashMap<String, String> instanceIdMap, String version) {
+
+ String requestId = UUIDChecker.generateUUID(msoLogger);
+ long startTime = System.currentTimeMillis();
+ msoLogger.debug("requestId is: " + requestId);
+ E2EServiceInstanceRequest e2eSir = null;
+
+ MsoRequest msoRequest = new MsoRequest(requestId);
+ ObjectMapper mapper = new ObjectMapper();
+ try {
+ e2eSir = mapper.readValue(requestJSON, E2EServiceInstanceRequest.class);
+
+ } catch (Exception e) {
+ //TODO update the service name
+ this.createOperationStatusRecordForError(action, requestId);
+
+ msoLogger.debug("Mapping of request to JSON object failed : ", e);
+ Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST,
+ MsoException.ServiceException, "Mapping of request to JSON object failed. " + e.getMessage(),
+ ErrorNumbers.SVC_BAD_PARAMETER, null);
+ msoLogger.error(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "",
+ MsoLogger.ErrorCode.SchemaError, requestJSON, e);
+ msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError,
+ "Mapping of request to JSON object failed");
+ msoLogger.debug("End of the transaction, the final response is: " + (String) response.getEntity());
+ return response;
+ }
+
+ mapReqJsonToSvcInstReq(e2eSir, requestJSON);
+ sir.getRequestDetails().getRequestParameters().setaLaCarte(true);
+ try {
+ msoRequest.parse(sir, instanceIdMap, action, version);
+ } catch (Exception e) {
+ msoLogger.debug("Validation failed: ", e);
+ Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST,
+ MsoException.ServiceException, "Error parsing request. " + e.getMessage(),
+ ErrorNumbers.SVC_BAD_PARAMETER, null);
+ if (msoRequest.getRequestId() != null) {
+ msoLogger.debug("Logging failed message to the database");
+ //TODO update the service name
+ this.createOperationStatusRecordForError(action, requestId);
+ }
+ msoLogger.error(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "",
+ MsoLogger.ErrorCode.SchemaError, requestJSON, e);
+ msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError,
+ "Validation of the input request failed");
+ msoLogger.debug("End of the transaction, the final response is: " + (String) response.getEntity());
+ return response;
+ }
+
+ InfraActiveRequests dup = null;
+// String instanceName = sir.getService().getName();
+// String requestScope = sir.getService().getParameters().getNodeType();
+ String instanceName = sir.getRequestDetails().getRequestInfo().getInstanceName();
+ String requestScope = sir.getRequestDetails().getModelInfo().getModelType().name();
+ try {
+ if (!(instanceName == null && "service".equals(requestScope)
+ && (action == Action.createInstance || action == Action.activateInstance))) {
+ //TODO : Need to check for the duplicate record from the operation status,
+ //TODO : commenting this check for unblocking current testing for now... induces dead code...
+// dup = (RequestsDatabase.getInstance()).checkInstanceNameDuplicate(instanceIdMap, instanceName,
+// requestScope);
+ }
+ } catch (Exception e) {
+ msoLogger.error(MessageEnum.APIH_DUPLICATE_CHECK_EXC, MSO_PROP_APIHANDLER_INFRA, "", "",
+ MsoLogger.ErrorCode.DataError, "Error during duplicate check ", e);
+
+ Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR,
+ MsoException.ServiceException, e.getMessage(), ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, null);
+
+ msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError,
+ "Error during duplicate check");
+ msoLogger.debug("End of the transaction, the final response is: " + (String) response.getEntity());
+ return response;
+ }
+
+ if (dup != null) {
+ // Found the duplicate record. Return the appropriate error.
+ String instance = null;
+ if (instanceName != null) {
+ instance = instanceName;
+ } else {
+ instance = instanceIdMap.get(requestScope + "InstanceId");
+ }
+ String dupMessage = "Error: Locked instance - This " + requestScope + " (" + instance + ") "
+ + "already has a request being worked with a status of " + dup.getRequestStatus() + " (RequestId - "
+ + dup.getRequestId() + "). The existing request must finish or be cleaned up before proceeding.";
+
+ Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_CONFLICT,
+ MsoException.ServiceException, dupMessage, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, null);
+
+ msoLogger.warn(MessageEnum.APIH_DUPLICATE_FOUND, dupMessage, "", "", MsoLogger.ErrorCode.SchemaError,
+ "Duplicate request - Subscriber already has a request for this service");
+
+
+ msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict,
+ dupMessage);
+ msoLogger.debug("End of the transaction, the final response is: " + (String) response.getEntity());
+ createOperationStatusRecordForError(action, requestId);
+ return response;
+ }
+
+ CatalogDatabase db = null;
+ RecipeLookupResult recipeLookupResult = null;
+ try {
+ db = CatalogDatabase.getInstance();
+ recipeLookupResult = getServiceInstanceOrchestrationURI(db, action);
+ } catch (Exception e) {
+ msoLogger.error(MessageEnum.APIH_DB_ACCESS_EXC, MSO_PROP_APIHANDLER_INFRA, "", "",
+ MsoLogger.ErrorCode.AvailabilityError, "Exception while communciate with Catalog DB", e);
+ msoRequest.setStatus(org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
+ Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND,
+ MsoException.ServiceException, "No communication to catalog DB " + e.getMessage(),
+ ErrorNumbers.SVC_NO_SERVER_RESOURCES, null);
+ alarmLogger.sendAlarm("MsoDatabaseAccessError", MsoAlarmLogger.CRITICAL,
+ Messages.errors.get(ErrorNumbers.NO_COMMUNICATION_TO_CATALOG_DB));
+
+ msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError,
+ "Exception while communciate with DB");
+ msoLogger.debug(END_OF_THE_TRANSACTION + (String) response.getEntity());
+ createOperationStatusRecordForError(action, requestId);
+ return response;
+ } finally {
+ closeCatalogDB(db);
+ }
+
+ if (recipeLookupResult == null) {
+ msoLogger.error(MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, MSO_PROP_APIHANDLER_INFRA, "", "",
+ MsoLogger.ErrorCode.DataError, "No recipe found in DB");
+ msoRequest.setStatus(org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
+ Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND,
+ MsoException.ServiceException, "Recipe does not exist in catalog DB",
+ ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null);
+
+ msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound,
+ "No recipe found in DB");
+ msoLogger.debug(END_OF_THE_TRANSACTION + (String) response.getEntity());
+ createOperationStatusRecordForError(action, requestId);
+ return response;
+ }
+
+// try {
+// msoRequest.createRequestRecord(Status.PENDING, action);
+// //createOperationStatusRecord(action, requestId);
+// } catch (Exception e) {
+// msoLogger.error(MessageEnum.APIH_DB_ACCESS_EXC_REASON, "Exception while creating record in DB", "", "",
+// MsoLogger.ErrorCode.SchemaError, "Exception while creating record in DB", e);
+// msoRequest.setStatus(org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
+// Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR,
+// MsoException.ServiceException, "Exception while creating record in DB " + e.getMessage(),
+// ErrorNumbers.SVC_BAD_PARAMETER, null);
+// msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError,
+// "Exception while creating record in DB");
+// msoLogger.debug("End of the transaction, the final response is: " + (String) response.getEntity());
+// return response;
+// }
+
+ String serviceInstanceType = e2eSir.getService().getParameters().getServiceType();
+
+ String serviceId = "";
+ RequestClient requestClient = null;
+ HttpResponse response = null;
+
+ long subStartTime = System.currentTimeMillis();
+ String sirRequestJson = mapReqJsonToSvcInstReq(e2eSir, requestJSON);
+
+ try {
+ requestClient = RequestClientFactory.getRequestClient(recipeLookupResult.getOrchestrationURI(),
+ MsoPropertiesUtils.loadMsoProperties());
+
+ // Capture audit event
+ msoLogger.debug("MSO API Handler Posting call to BPEL engine for url: " + requestClient.getUrl());
+
+ response = requestClient.post(requestId, false, recipeLookupResult.getRecipeTimeout(), action.name(),
+ serviceId, null, null, null, null, serviceInstanceType, null, null, null, sirRequestJson);
+
+ msoLogger.recordMetricEvent(subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
+ "Successfully received response from BPMN engine", "BPMN", recipeLookupResult.getOrchestrationURI(),
+ null);
+ } catch (Exception e) {
+ msoLogger.recordMetricEvent(subStartTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with BPMN engine", "BPMN",
+ recipeLookupResult.getOrchestrationURI(), null);
+ Response resp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY,
+ MsoException.ServiceException, "Failed calling bpmn " + e.getMessage(),
+ ErrorNumbers.SVC_NO_SERVER_RESOURCES, null);
+ alarmLogger.sendAlarm("MsoConfigurationError", MsoAlarmLogger.CRITICAL,
+ Messages.errors.get(ErrorNumbers.NO_COMMUNICATION_TO_BPEL));
+ msoLogger.error(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "",
+ MsoLogger.ErrorCode.AvailabilityError, "Exception while communicate with BPMN engine");
+ msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError,
+ "Exception while communicate with BPMN engine");
+ msoLogger.debug("End of the transaction, the final response is: " + (String) resp.getEntity());
+ createOperationStatusRecordForError(action, requestId);
+ return resp;
+ }
+
+ if (response == null) {
+ Response resp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY,
+ MsoException.ServiceException, "bpelResponse is null", ErrorNumbers.SVC_NO_SERVER_RESOURCES, null);
+ msoLogger.error(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "",
+ MsoLogger.ErrorCode.BusinessProcesssError, "Null response from BPEL");
+ msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError,
+ "Null response from BPMN");
+ msoLogger.debug(END_OF_THE_TRANSACTION + (String) resp.getEntity());
+ return resp;
+ }
+
+ ResponseHandler respHandler = new ResponseHandler(response, requestClient.getType());
+ int bpelStatus = respHandler.getStatus();
+
+ return beplStatusUpdate(requestId, startTime, msoRequest, requestClient, respHandler, bpelStatus, action);
+ }
+
+ private void closeCatalogDB(CatalogDatabase db) {
+ if (db != null) {
+ db.close();
+ }
+ }
+
+ private InfraActiveRequests checkForDuplicateRecord(Action action, HashMap<String, String> instanceIdMap,
+ String instanceName, String requestScope) {
+ InfraActiveRequests dupValue = null;
+ if (!(instanceName == null && "service".equals(requestScope)
+ && (action == Action.createInstance || action == Action.activateInstance))) {
+ dupValue = (RequestsDatabase.getInstance()).checkInstanceNameDuplicate(instanceIdMap, instanceName,
+ requestScope);
+ }
+ return dupValue;
+ }
+
+ private Response duplicateRecordFound(Action action, HashMap<String, String> instanceIdMap, long startTime,
+ MsoRequest msoRequest, InfraActiveRequests dup, String instanceName, String requestScope) {
+ String instance = null;
+ if (instanceName != null) {
+ instance = instanceName;
+ } else {
+ instance = instanceIdMap.get(requestScope + "InstanceId");
+ }
+ String dupMessage = "Error: Locked instance - This " + requestScope + " (" + instance + ") "
+ + "already has a request being worked with a status of " + dup.getRequestStatus() + " (RequestId - "
+ + dup.getRequestId() + "). The existing request must finish or be cleaned up before proceeding.";
+
+ Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_CONFLICT, MsoException.ServiceException,
+ dupMessage, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, null);
+
+ msoLogger.warn(MessageEnum.APIH_DUPLICATE_FOUND, dupMessage, "", "", MsoLogger.ErrorCode.SchemaError,
+ "Duplicate request - Subscriber already has a request for this service");
+ msoRequest.createRequestRecord(Status.FAILED, action);
+ msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, dupMessage);
+ msoLogger.debug(END_OF_THE_TRANSACTION + (String) response.getEntity());
+ return response;
+ }
+
+ private Response beplStatusUpdate(String requestId, long startTime, MsoRequest msoRequest,
+ RequestClient requestClient, ResponseHandler respHandler, int bpelStatus, Action action) {
+ // BPMN accepted the request, the request is in progress
+ if (bpelStatus == HttpStatus.SC_ACCEPTED) {
+ String camundaJSONResponseBody = respHandler.getResponseBody();
+ msoLogger.debug("Received from Camunda: " + camundaJSONResponseBody);
+
+ // currently only for delete case we update the status here
+ if(action == Action.deleteInstance){
+ ObjectMapper mapper = new ObjectMapper();
+ try{
+ DelE2ESvcResp jo = mapper.readValue(camundaJSONResponseBody, DelE2ESvcResp.class);
+ String operationId = jo.getOperationId();
+
+ this.createOperationStatusRecord("DELETE", requestId, operationId);
+ }
+ catch(Exception ex)
+ {
+ msoLogger.error(MessageEnum.APIH_BPEL_RESPONSE_ERROR, requestClient.getUrl(), "", "",
+ MsoLogger.ErrorCode.BusinessProcesssError,
+ "Response from BPEL engine is failed with HTTP Status=" + bpelStatus);
+ }
+ }
+ msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
+ "BPMN accepted the request, the request is in progress");
+ msoLogger.debug(END_OF_THE_TRANSACTION + camundaJSONResponseBody);
+ return Response.status(HttpStatus.SC_ACCEPTED).entity(camundaJSONResponseBody).build();
+ } else {
+ List<String> variables = new ArrayList<>();
+ variables.add(bpelStatus + "");
+ String camundaJSONResponseBody = respHandler.getResponseBody();
+ if (camundaJSONResponseBody != null && !camundaJSONResponseBody.isEmpty()) {
+ Response resp = msoRequest.buildServiceErrorResponse(bpelStatus, MsoException.ServiceException,
+ "Request Failed due to BPEL error with HTTP Status= %1 " + '\n' + camundaJSONResponseBody,
+ ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, variables);
+ msoLogger.error(MessageEnum.APIH_BPEL_RESPONSE_ERROR, requestClient.getUrl(), "", "",
+ MsoLogger.ErrorCode.BusinessProcesssError,
+ "Response from BPEL engine is failed with HTTP Status=" + bpelStatus);
+ msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError,
+ "Response from BPMN engine is failed");
+ msoLogger.debug(END_OF_THE_TRANSACTION + (String) resp.getEntity());
+ return resp;
+ } else {
+ Response resp = msoRequest.buildServiceErrorResponse(bpelStatus, MsoException.ServiceException,
+ "Request Failed due to BPEL error with HTTP Status= %1",
+ ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, variables);
+ msoLogger.error(MessageEnum.APIH_BPEL_RESPONSE_ERROR, requestClient.getUrl(), "", "",
+ MsoLogger.ErrorCode.BusinessProcesssError, "Response from BPEL engine is empty");
+ msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError,
+ "Response from BPEL engine is empty");
+ msoLogger.debug(END_OF_THE_TRANSACTION + (String) resp.getEntity());
+ return resp;
+ }
+ }
+ }
+
+ /**
+ * Getting recipes from catalogDb
+ *
+ * @param db
+ * @param action
+ * @return
+ */
+ private RecipeLookupResult getServiceInstanceOrchestrationURI(CatalogDatabase db, Action action) {
+
+ RecipeLookupResult recipeLookupResult = getServiceURI(db, action);
+
+ if (recipeLookupResult != null) {
+ msoLogger.debug("Orchestration URI is: " + recipeLookupResult.getOrchestrationURI()
+ + ", recipe Timeout is: " + Integer.toString(recipeLookupResult.getRecipeTimeout()));
+ } else {
+ msoLogger.debug("No matching recipe record found");
+ }
+ return recipeLookupResult;
+ }
+
+ /**
+ * Getting recipes from catalogDb
+ *
+ * @param db
+ * @param action
+ * @return
+ */
+ private RecipeLookupResult getServiceURI(CatalogDatabase db, Action action) {
+
+ String defaultServiceModelName = "UUI_DEFAULT";
+
+ Service serviceRecord = db.getServiceByModelName(defaultServiceModelName);
+ ServiceRecipe recipe = db.getServiceRecipeByModelUUID(serviceRecord.getModelUUID(), action.name());
+
+ if (recipe == null) {
+ return null;
+ }
+ return new RecipeLookupResult(recipe.getOrchestrationUri(), recipe.getRecipeTimeout());
+
+ }
+
+ /**
+ * Converting E2EServiceInstanceRequest to ServiceInstanceRequest and
+ * passing it to camunda engine.
+ *
+ * @param e2eSir
+ * @return
+ */
+ private String mapReqJsonToSvcInstReq(E2EServiceInstanceRequest e2eSir, String requestJSON) {
+
+ sir = new ServiceInstancesRequest();
+
+ String returnString = null;
+ RequestDetails requestDetails = new RequestDetails();
+ ModelInfo modelInfo = new ModelInfo();
+
+ // ModelInvariantId
+ modelInfo.setModelInvariantId(e2eSir.getService().getServiceDefId());
+
+ // modelNameVersionId
+ modelInfo.setModelNameVersionId(e2eSir.getService().getTemplateId());
+
+// String modelInfoValue = e2eSir.getService().getParameters().getNodeTemplateName();
+// String[] arrayOfInfo = modelInfoValue.split(":");
+// String modelName = arrayOfInfo[0];
+// String modelVersion = arrayOfInfo[1];
+
+// TODO: To ensure, if we dont get the values from the UUI
+ String modelName = "voLTE";
+ String modelVersion = "1.0";
+ // modelName
+ modelInfo.setModelName(modelName);
+
+ // modelVersion
+ modelInfo.setModelVersion(modelVersion);
+
+ // modelType
+ modelInfo.setModelType(ModelType.service);
+
+ // setting modelInfo to requestDetails
+ requestDetails.setModelInfo(modelInfo);
+
+ SubscriberInfo subscriberInfo = new SubscriberInfo();
+
+ // globalsubscriberId
+ subscriberInfo.setGlobalSubscriberId(e2eSir.getService().getParameters().getGlobalSubscriberId());
+
+ // subscriberName
+ subscriberInfo.setSubscriberName(e2eSir.getService().getParameters().getSubscriberName());
+
+ // setting subscriberInfo to requestDetails
+ requestDetails.setSubscriberInfo(subscriberInfo);
+
+ RequestInfo requestInfo = new RequestInfo();
+
+ // instanceName
+ requestInfo.setInstanceName(e2eSir.getService().getName());
+
+ // source
+ requestInfo.setSource("UUI");
+
+ // suppressRollback
+ requestInfo.setSuppressRollback(true);
+
+ // setting requestInfo to requestDetails
+ requestDetails.setRequestInfo(requestInfo);
+
+ RequestParameters requestParameters = new RequestParameters();
+
+ // subscriptionServiceType
+ requestParameters.setSubscriptionServiceType("MOG");
+
+ // Userparams
+ List<E2EUserParam> userParams;
+ //userParams = e2eSir.getService().getParameters().getRequestParameters().getUserParams();
+ List<Map<String, String>> userParamList = new ArrayList<>();
+ Map<String, String> userParamMap = new HashMap<>();
+ //complete json request updated in the camunda
+ userParamMap.put("UUIRequest", requestJSON);
+ userParamMap.put("ServiceInstanceName", e2eSir.getService().getName());
+
+// Map<String, String> userParamMap3 = null;
+// for (E2EUserParam userp : userParams) {
+// userParamMap.put(userp.getName(), userp.getValue());
+//
+// }
+ userParamList.add(userParamMap);
+ requestParameters.setUserParams(userParamList);
+
+ // setting requestParameters to requestDetails
+ requestDetails.setRequestParameters(requestParameters);
+
+ sir.setRequestDetails(requestDetails);
+
+ // converting to string
+ ObjectMapper mapper = new ObjectMapper();
+ try {
+ returnString = mapper.writeValueAsString(sir);
+ } catch (IOException e) {
+ msoLogger.debug("Exception while converting ServiceInstancesRequest object to string", e);
+ }
+
+ return returnString;
+ }
+
+
+ private void createOperationStatusRecordForError(Action action, String requestId) {
+
+ AbstractSessionFactoryManager requestsDbSessionFactoryManager = new RequestsDbSessionFactoryManager();
+
+ Session session = null;
+ try {
+
+ session = requestsDbSessionFactoryManager.getSessionFactory().openSession();
+ session.beginTransaction();
+
+ OperationStatus os = new OperationStatus();
+ os.setOperation(action.name());
+ os.setOperationContent("");
+ os.setOperationId("");
+ os.setProgress("100");
+ os.setReason("");
+ os.setResult("error");
+ os.setServiceId(requestId);
+ os.setUserId("");
+ os.setFinishedAt(new Timestamp(System.currentTimeMillis()));
+ os.setOperateAt(new Timestamp(System.currentTimeMillis()));
+
+ session.save(os);
+ session.getTransaction().commit();
+
+ } catch (Exception e) {
+ msoLogger.error (MessageEnum.APIH_DB_INSERT_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception when creation record request in Operation", e);
+ } finally {
+ if (null != session) {
+ session.close();
+ }
+ }
+ }
+ private void createOperationStatusRecord(String actionNm, String serviceId, String operationId) {
+
+ AbstractSessionFactoryManager requestsDbSessionFactoryManager = new RequestsDbSessionFactoryManager();
+
+ Session session = null;
+ try {
+
+ session = requestsDbSessionFactoryManager.getSessionFactory().openSession();
+ session.beginTransaction();
+
+ OperationStatus os = new OperationStatus();
+ os.setOperation(actionNm);
+ os.setOperationContent("");
+ os.setOperationId(operationId);
+ os.setProgress("0");
+ os.setReason("");
+ os.setResult("processing");
+ os.setServiceId(serviceId);
+ //TODO : to be updated...
+ os.setUserId("");
+ os.setFinishedAt(new Timestamp(System.currentTimeMillis()));
+ os.setOperateAt(new Timestamp(System.currentTimeMillis()));
+
+ session.save(os);
+ session.getTransaction().commit();
+
+ } catch (Exception e) {
+ msoLogger.error (MessageEnum.APIH_DB_INSERT_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception when creation record request in Operation", e);
+ } finally {
+ if (null != session) {
+ session.close();
+ }
+ }
+ }
+} \ No newline at end of file