aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn')
-rw-r--r--bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/SDNCHandler.bpmn70
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/exceptions/SDNCErrorResponseException.java13
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasks.java33
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasksTest.java25
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/SDNC_Async_Request2.xml11
5 files changed, 115 insertions, 37 deletions
diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/SDNCHandler.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/SDNCHandler.bpmn
index 0be7c55596..7339b23802 100644
--- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/SDNCHandler.bpmn
+++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/SDNCHandler.bpmn
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.8.2">
+<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="2.0.3">
<bpmn:process id="SDNCHandler" name="SDNC" isExecutable="true">
<bpmn:startEvent id="SDNC_Start">
<bpmn:outgoing>SequenceFlow_1n0j3hz</bpmn:outgoing>
@@ -38,7 +38,7 @@
<bpmn:boundaryEvent id="BoundaryEvent_1quvxva" name="Timeout" attachedToRef="SubProcess_0y8yozw">
<bpmn:outgoing>SequenceFlow_1yifu46</bpmn:outgoing>
<bpmn:timerEventDefinition>
- <bpmn:timeDuration xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("sdncTimeout")}]]></bpmn:timeDuration>
+ <bpmn:timeDuration xsi:type="bpmn:tFormalExpression">${execution.getVariable("sdncTimeout")}</bpmn:timeDuration>
</bpmn:timerEventDefinition>
</bpmn:boundaryEvent>
<bpmn:sequenceFlow id="SequenceFlow_1ecej8g" sourceRef="SubProcess_0y8yozw" targetRef="ExclusiveGateway_09ehhaf" />
@@ -48,7 +48,7 @@
<bpmn:outgoing>SequenceFlow_0i4u8g4</bpmn:outgoing>
</bpmn:exclusiveGateway>
<bpmn:sequenceFlow id="SequenceFlow_0rh24pq" name="Final Ack = N" sourceRef="ExclusiveGateway_09ehhaf" targetRef="SubProcess_0y8yozw">
- <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("isCallbackCompleted")}]]></bpmn:conditionExpression>
+ <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.getVariable("isCallbackCompleted") == false}</bpmn:conditionExpression>
</bpmn:sequenceFlow>
<bpmn:sequenceFlow id="SequenceFlow_1yifu46" sourceRef="BoundaryEvent_1quvxva" targetRef="Task_1un0flc" />
<bpmn:sequenceFlow id="SequenceFlow_1n0j3hz" sourceRef="SDNC_Start" targetRef="SNDC_SetupCallback" />
@@ -62,7 +62,7 @@
<bpmn:sequenceFlow id="SequenceFlow_0flbj8a" sourceRef="SNDC_SetupCallback" targetRef="Call_SDNC" />
<bpmn:sequenceFlow id="SequenceFlow_0i4u8g4" name="Final Ack = Y" sourceRef="ExclusiveGateway_09ehhaf" targetRef="SDNC_End" />
<bpmn:sequenceFlow id="SequenceFlow_0puiqga" name="Final Ack = Y" sourceRef="isAsync_Gateway" targetRef="SDNC_End">
- <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("isSDNCCompleted")}]]></bpmn:conditionExpression>
+ <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.getVariable("isSDNCCompleted")}</bpmn:conditionExpression>
</bpmn:sequenceFlow>
<bpmn:serviceTask id="SNDC_SetupCallback" name="Setup Callback Variables" camunda:expression="${SDNCRequestTasks.createCorrelationVariables(execution)}">
<bpmn:incoming>SequenceFlow_1n0j3hz</bpmn:incoming>
@@ -72,7 +72,7 @@
<bpmn:incoming>SequenceFlow_1yifu46</bpmn:incoming>
</bpmn:serviceTask>
</bpmn:process>
- <bpmn:message id="Message_06oc4iz" name="SDNCCallbackMessage" />
+ <bpmn:message id="Message_06oc4iz" name="WorkflowMessage" />
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="SDNCHandler">
<bpmndi:BPMNShape id="StartEvent_0kxwniy_di" bpmnElement="SDNC_Start">
@@ -118,23 +118,23 @@
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_1qxm8ot_di" bpmnElement="SequenceFlow_1qxm8ot">
- <di:waypoint xsi:type="dc:Point" x="347" y="-72" />
- <di:waypoint xsi:type="dc:Point" x="376" y="-72" />
+ <di:waypoint x="347" y="-72" />
+ <di:waypoint x="376" y="-72" />
<bpmndi:BPMNLabel>
<dc:Bounds x="316.5" y="-93.5" width="90" height="13" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_05eggbt_di" bpmnElement="SequenceFlow_05eggbt">
- <di:waypoint xsi:type="dc:Point" x="412" y="-72" />
- <di:waypoint xsi:type="dc:Point" x="438" y="-72" />
+ <di:waypoint x="412" y="-72" />
+ <di:waypoint x="438" y="-72" />
<bpmndi:BPMNLabel>
<dc:Bounds x="380" y="-93.5" width="90" height="13" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_1ecej8g_di" bpmnElement="SequenceFlow_1ecej8g">
- <di:waypoint xsi:type="dc:Point" x="618" y="-67" />
- <di:waypoint xsi:type="dc:Point" x="798" y="-67" />
- <di:waypoint xsi:type="dc:Point" x="798" y="28" />
+ <di:waypoint x="618" y="-67" />
+ <di:waypoint x="798" y="-67" />
+ <di:waypoint x="798" y="28" />
<bpmndi:BPMNLabel>
<dc:Bounds x="663" y="-88.5" width="90" height="13" />
</bpmndi:BPMNLabel>
@@ -146,23 +146,23 @@
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_0rh24pq_di" bpmnElement="SequenceFlow_0rh24pq">
- <di:waypoint xsi:type="dc:Point" x="773" y="53" />
- <di:waypoint xsi:type="dc:Point" x="449" y="53" />
- <di:waypoint xsi:type="dc:Point" x="449" y="9" />
+ <di:waypoint x="773" y="53" />
+ <di:waypoint x="449" y="53" />
+ <di:waypoint x="449" y="9" />
<bpmndi:BPMNLabel>
<dc:Bounds x="579.9877300613497" y="32" width="66" height="13" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_1yifu46_di" bpmnElement="SequenceFlow_1yifu46">
- <di:waypoint xsi:type="dc:Point" x="636" y="-144" />
- <di:waypoint xsi:type="dc:Point" x="748" y="-145" />
+ <di:waypoint x="636" y="-144" />
+ <di:waypoint x="748" y="-145" />
<bpmndi:BPMNLabel>
<dc:Bounds x="647" y="-166" width="90" height="13" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_1n0j3hz_di" bpmnElement="SequenceFlow_1n0j3hz">
- <di:waypoint xsi:type="dc:Point" x="-231" y="152" />
- <di:waypoint xsi:type="dc:Point" x="-171" y="152" />
+ <di:waypoint x="-231" y="152" />
+ <di:waypoint x="-171" y="152" />
<bpmndi:BPMNLabel>
<dc:Bounds x="-201" y="130.5" width="0" height="13" />
</bpmndi:BPMNLabel>
@@ -174,47 +174,47 @@
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_0yve6l6_di" bpmnElement="SequenceFlow_0yve6l6">
- <di:waypoint xsi:type="dc:Point" x="253" y="127" />
- <di:waypoint xsi:type="dc:Point" x="253" y="92" />
- <di:waypoint xsi:type="dc:Point" x="253" y="92" />
- <di:waypoint xsi:type="dc:Point" x="253" y="-67" />
- <di:waypoint xsi:type="dc:Point" x="278" y="-67" />
+ <di:waypoint x="253" y="127" />
+ <di:waypoint x="253" y="92" />
+ <di:waypoint x="253" y="92" />
+ <di:waypoint x="253" y="-67" />
+ <di:waypoint x="278" y="-67" />
<bpmndi:BPMNLabel>
<dc:Bounds x="263" y="57" width="65" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_07vnhri_di" bpmnElement="SequenceFlow_07vnhri">
- <di:waypoint xsi:type="dc:Point" x="115" y="152" />
- <di:waypoint xsi:type="dc:Point" x="228" y="152" />
+ <di:waypoint x="115" y="152" />
+ <di:waypoint x="228" y="152" />
<bpmndi:BPMNLabel>
<dc:Bounds x="171.5" y="130" width="0" height="13" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_0flbj8a_di" bpmnElement="SequenceFlow_0flbj8a">
- <di:waypoint xsi:type="dc:Point" x="-71" y="152" />
- <di:waypoint xsi:type="dc:Point" x="15" y="152" />
+ <di:waypoint x="-71" y="152" />
+ <di:waypoint x="15" y="152" />
<bpmndi:BPMNLabel>
<dc:Bounds x="-28" y="130.5" width="0" height="13" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_0i4u8g4_di" bpmnElement="SequenceFlow_0i4u8g4">
- <di:waypoint xsi:type="dc:Point" x="798" y="78" />
- <di:waypoint xsi:type="dc:Point" x="798" y="174" />
+ <di:waypoint x="798" y="78" />
+ <di:waypoint x="798" y="174" />
<bpmndi:BPMNLabel>
<dc:Bounds x="809" y="119" width="66" height="13" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_0puiqga_di" bpmnElement="SequenceFlow_0puiqga">
- <di:waypoint xsi:type="dc:Point" x="253" y="177" />
- <di:waypoint xsi:type="dc:Point" x="253" y="192" />
- <di:waypoint xsi:type="dc:Point" x="780" y="192" />
+ <di:waypoint x="253" y="177" />
+ <di:waypoint x="253" y="192" />
+ <di:waypoint x="780" y="192" />
<bpmndi:BPMNLabel>
<dc:Bounds x="310" y="161" width="66" height="13" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_0oh3ye4_di" bpmnElement="SequenceFlow_0oh3ye4">
- <di:waypoint xsi:type="dc:Point" x="538" y="-72" />
- <di:waypoint xsi:type="dc:Point" x="562" y="-72" />
+ <di:waypoint x="538" y="-72" />
+ <di:waypoint x="562" y="-72" />
<bpmndi:BPMNLabel>
<dc:Bounds x="550" y="-93.5" width="0" height="13" />
</bpmndi:BPMNLabel>
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/exceptions/SDNCErrorResponseException.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/exceptions/SDNCErrorResponseException.java
new file mode 100644
index 0000000000..e0f88a20a5
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/exceptions/SDNCErrorResponseException.java
@@ -0,0 +1,13 @@
+package org.onap.so.bpmn.infrastructure.sdnc.exceptions;
+
+public class SDNCErrorResponseException extends Exception {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 7807799223298140702L;
+
+ public SDNCErrorResponseException(String message) {
+ super(message);
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasks.java
index a4ef28496e..24f642ae72 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasks.java
@@ -20,7 +20,15 @@
package org.onap.so.bpmn.infrastructure.sdnc.tasks;
+import java.io.StringReader;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathFactory;
+
import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.onap.so.bpmn.infrastructure.sdnc.exceptions.SDNCErrorResponseException;
import org.onap.so.client.exception.BadResponseException;
import org.onap.so.client.exception.ExceptionBuilder;
import org.onap.so.client.exception.MapperException;
@@ -31,6 +39,8 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.client.HttpClientErrorException;
+import org.w3c.dom.Document;
+import org.xml.sax.InputSource;
import com.jayway.jsonpath.JsonPath;
import com.jayway.jsonpath.PathNotFoundException;
@@ -44,6 +54,7 @@ public class SDNCRequestTasks {
private static final String MESSAGE = "_MESSAGE";
private static final String CORRELATOR = "_CORRELATOR";
protected static final String IS_CALLBACK_COMPLETED = "isCallbackCompleted";
+ protected static final String SDNC_SUCCESS = "200";
@Autowired
private ExceptionBuilder exceptionBuilder;
@@ -82,9 +93,24 @@ public class SDNCRequestTasks {
try {
SDNCRequest request = (SDNCRequest)execution.getVariable(SDNC_REQUEST);
String asyncRequest = (String) execution.getVariable(request.getCorrelationName()+MESSAGE);
- String finalMessageIndicator = JsonPath.read(asyncRequest, "$.input.ack-final-indicator");
+
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance ();
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ Document doc = db.parse(new InputSource(new StringReader(asyncRequest)));
+
+ String finalMessageIndicator = getXmlElement(doc, "/input/ack-final-indicator");
boolean isCallbackCompleted = convertIndicatorToBoolean(finalMessageIndicator);
execution.setVariable(IS_CALLBACK_COMPLETED, isCallbackCompleted);
+ if(isCallbackCompleted) {
+ String responseCode = getXmlElement(doc, "/input/response-code");
+ String responseMessage = getXmlElement(doc, "/input/response-message");
+ if(!SDNC_SUCCESS.equalsIgnoreCase(responseCode)) {
+ throw new SDNCErrorResponseException(responseMessage);
+ }
+ }
+ } catch (SDNCErrorResponseException e) {
+ logger.error("SDNC error response - " + e.getMessage());
+ exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, e.getMessage());
} catch (Exception e) {
logger.error("Error procesing SDNC callback", e);
exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, "Error procesing SDNC callback");
@@ -99,4 +125,9 @@ public class SDNCRequestTasks {
return "Y".equals(finalMessageIndicator);
}
+ protected String getXmlElement(Document doc, String exp) throws Exception {
+ XPath xPath = XPathFactory.newInstance().newXPath();
+ return xPath.evaluate(exp, doc);
+ }
+
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasksTest.java
index f1779cf119..043aad43b1 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasksTest.java
@@ -27,9 +27,13 @@ import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import java.io.IOException;
+import java.io.StringReader;
import java.nio.file.Files;
import java.nio.file.Paths;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
import org.camunda.bpm.engine.delegate.BpmnError;
import org.camunda.bpm.engine.delegate.DelegateExecution;
@@ -51,6 +55,8 @@ import org.onap.so.client.exception.MapperException;
import org.onap.so.client.sdnc.SDNCClient;
import org.onap.so.client.sdnc.beans.SDNCRequest;
import org.onap.so.client.sdnc.endpoint.SDNCTopology;
+import org.w3c.dom.Document;
+import org.xml.sax.InputSource;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
@@ -131,12 +137,29 @@ public class SDNCRequestTasksTest extends SDNCRequestTasks{
@Test
public void processCallBack_Final_Test() throws MapperException, BadResponseException, IOException{
- final String sdncResponse = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/SDNC_ASYNC_Request.json")));
+ final String sdncResponse = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/SDNC_Async_Request2.xml")));
delegateExecution.setVariable("correlationName_MESSAGE", sdncResponse);
sndcRequestTasks.processCallback(delegateExecution);
assertEquals(true,delegateExecution.getVariable(IS_CALLBACK_COMPLETED));
}
+ @Test
+ public void getXmlElementTest() throws Exception {
+ final String sdncResponse = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/SDNC_Async_Request2.xml")));
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance ();
+ DocumentBuilder db;
+ db = dbf.newDocumentBuilder ();
+ Document doc = db.parse (new InputSource(new StringReader(sdncResponse)));
+
+ String finalMessageIndicator = getXmlElement(doc, "/input/ack-final-indicator");
+ String responseCode = getXmlElement(doc, "/input/response-code");
+ String responseMessage = getXmlElement(doc, "/input/response-message");
+
+ assertEquals("Y", finalMessageIndicator);
+ assertEquals("200", responseCode);
+ assertEquals("Success", responseMessage);
+ }
+
public SDNCRequest createSDNCRequest(){
SDNCRequest request = new SDNCRequest();
request.setCorrelationName("correlationName");
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/SDNC_Async_Request2.xml b/bpmn/so-bpmn-tasks/src/test/resources/__files/SDNC_Async_Request2.xml
new file mode 100644
index 0000000000..aa69dba803
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/SDNC_Async_Request2.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<input>
+ <service-information>
+ <service-type>MY-SERVICE-TYPE</service-type>
+ <service-instance-id>b8308928-de76-4ce6-9e58-ec6033ff43b3</service-instance-id>
+ </service-information>
+ <svc-request-id>aa243891-4575-4040-bceb-25d5b7bc8c61</svc-request-id>
+ <response-code>200</response-code>
+ <response-message>Success</response-message>
+ <ack-final-indicator>Y</ack-final-indicator>
+</input>