From c45553d2e9bd80b842b46656fff86e357f959bf1 Mon Sep 17 00:00:00 2001 From: "Kalkere Ramesh, Sharan (sk720x)" Date: Fri, 7 Dec 2018 14:11:47 -0500 Subject: fixed headers for traceability Changed if condition and updated to get last element/instance in the list. Add block to handle when there is more than 1 process instance returned. Update headers for traceability in logging Change-Id: Ibb2cd0bf5ba7cd733371a204c0b61e418564df97 Issue-ID: SO-1301 Signed-off-by: Kalkere Ramesh, Sharan (sk720x) --- .../bpmn/common/scripts/SDNCAdapterRestV1.groovy | 5 +- .../so/bpmn/common/scripts/VnfAdapterRestV1.groovy | 7 +- .../main/resources/subprocess/FalloutHandler.bpmn | 1 + .../main/resources/subprocess/SDNCAdapterV1.bpmn | 175 ++++++++++----------- .../java/org/onap/so/bpmn/common/WorkflowTest.java | 22 ++- 5 files changed, 114 insertions(+), 96 deletions(-) (limited to 'bpmn') diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy index d7fc6ac995..0cefae526e 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy @@ -207,7 +207,10 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor { URL url = new URL(sdncAdapterUrl); - HttpClient httpClient = new HttpClient(url, "application/json", TargetEntity.SDNC_ADAPTER) + HttpClient httpClient = new HttpClient(url, "application/json", TargetEntity.SDNC_ADAPTER) + httpClient.addAdditionalHeader("X-ONAP-RequestID", execution.getVariable("mso-request-id")) + httpClient.addAdditionalHeader("X-ONAP-InvocationID", UUID.randomUUID().toString()) + httpClient.addAdditionalHeader("X-ONAP-PartnerName", "SO-SDNCAdapter") httpClient.addAdditionalHeader("mso-request-id", execution.getVariable("mso-request-id")) httpClient.addAdditionalHeader("mso-service-instance-id", execution.getVariable("mso-service-instance-id")) httpClient.addAdditionalHeader("Authorization", execution.getVariable(prefix + "basicAuthHeaderValue")) diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy index 13cc7f8d11..1452a9ad8d 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy @@ -29,6 +29,8 @@ import org.onap.so.client.HttpClient import org.onap.so.logger.MessageEnum import org.onap.so.logger.MsoLogger import org.onap.so.utils.TargetEntity +import java.util.UUID + @@ -311,7 +313,10 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { HttpClient httpClient = new HttpClient(url, "application/xml", TargetEntity.VNF_ADAPTER) httpClient.addAdditionalHeader("Authorization", execution.getVariable(prefix + "basicAuthHeaderValue")) - + + httpClient.addAdditionalHeader("X-ONAP-RequestID", execution.getVariable("mso-request-id")) + httpClient.addAdditionalHeader("X-ONAP-InvocationID", UUID.randomUUID().toString()) + httpClient.addAdditionalHeader("X-ONAP-PartnerName", "SO-VNFAdapter") Response response; if ("GET".equals(vnfAdapterMethod)) { diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/FalloutHandler.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/FalloutHandler.bpmn index 990863ec93..6914e7575f 100644 --- a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/FalloutHandler.bpmn +++ b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/FalloutHandler.bpmn @@ -70,6 +70,7 @@ falloutHandler.postProcessResponse(execution)]]> application/soap+xml #{BasicAuthHeaderValueDB} + #{FH_request_id} diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/SDNCAdapterV1.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/SDNCAdapterV1.bpmn index 2ae2ff7f8b..91c38241a2 100644 --- a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/SDNCAdapterV1.bpmn +++ b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/SDNCAdapterV1.bpmn @@ -1,5 +1,5 @@ - + SequenceFlow_15 @@ -8,28 +8,29 @@ - #{execution.getVariable("SDNCA_ResponseCode")=='200'} + badSynchronousResponse Exception - import org.onap.so.bpmn.common.scripts.* + +exceptionUtil.buildWorkflowException(execution, 7000, "Could not communicate with the SDNC Adapter" )]]> - ${execution.getVariable("mso.adapters.sdnc.endpoint")} + POST application/soap+xml #{BasicAuthHeaderValue} + #{mso-request-id} ${sdncAdapterRequest} @@ -65,20 +66,18 @@ exceptionUtil.buildWorkflowException(execution, 7000, "Could not communicate wit SequenceFlow_1 SequenceFlow_8 - import org.onap.so.bpmn.common.scripts.* + +sdnc.preProcessRequest(execution)]]> SequenceFlow_9 SequenceFlow_11ah5pw SequenceFlow_14 - import org.onap.so.bpmn.common.scripts.* + +sdnc.postProcessResponse(execution)]]> @@ -88,7 +87,7 @@ sdnc.postProcessResponse(execution) - #{execution.getVariable("asynchronousResponseTimeout")==true} + SequenceFlow_2 @@ -111,17 +110,17 @@ sdnc.postProcessResponse(execution) SequenceFlow_0mzs1ze SequenceFlow_11ah5pw - import org.onap.so.bpmn.common.scripts.* + +sdnc.setTimeout(execution)]]> goodSynchronousResponse SequenceFlow_26 SequenceFlow_2 - import org.onap.so.bpmn.common.scripts.* + +sdnc.resetCallbackRequest(execution)]]> @@ -131,14 +130,14 @@ sdnc.resetCallbackRequest(execution) - #{execution.getVariable("continueListening")==true} + SequenceFlow_1w1za5m SequenceFlow_17 - import org.onap.so.bpmn.common.scripts.* + +sdnc.toggleSuccessIndicator(execution)]]> @@ -168,9 +167,9 @@ sdnc.toggleSuccessIndicator(execution) SequenceFlow_22 SequenceFlow_27 - import org.onap.so.bpmn.common.scripts.* + +sdnc.assignError(execution)]]> @@ -183,7 +182,7 @@ sdnc.assignError(execution) SequenceFlow_23 - #{execution.getVariable("serviceConfigActivate")==true} + @@ -215,7 +214,7 @@ sdnc.assignError(execution) SequenceFlow_4 SequenceFlow_193cb6p - execution.setVariable("SDNCA_InterimNotify", true) + @@ -225,7 +224,7 @@ sdnc.assignError(execution) Done SequenceFlow_1w1za5m - execution.setVariable("SDNCA_InterimNotify", false) + @@ -264,23 +263,23 @@ sdnc.assignError(execution) - - - + + + - - + + - - + + @@ -292,24 +291,24 @@ sdnc.assignError(execution) - - + + - - + + - - - - + + + + @@ -330,8 +329,8 @@ sdnc.assignError(execution) - - + + @@ -340,8 +339,8 @@ sdnc.assignError(execution) - - + + @@ -350,8 +349,8 @@ sdnc.assignError(execution) - - + + @@ -363,16 +362,16 @@ sdnc.assignError(execution) - - + + - - - + + + @@ -384,8 +383,8 @@ sdnc.assignError(execution) - - + + @@ -394,17 +393,17 @@ sdnc.assignError(execution) - - - - + + + + - - + + @@ -416,8 +415,8 @@ sdnc.assignError(execution) - - + + @@ -429,8 +428,8 @@ sdnc.assignError(execution) - - + + @@ -442,17 +441,17 @@ sdnc.assignError(execution) - - - + + + - - - + + + @@ -461,8 +460,8 @@ sdnc.assignError(execution) - - + + @@ -486,22 +485,22 @@ sdnc.assignError(execution) - - + + - - + + - - + + @@ -519,17 +518,17 @@ sdnc.assignError(execution) - - - + + + - - - + + + @@ -547,8 +546,8 @@ sdnc.assignError(execution) - - + + @@ -560,8 +559,8 @@ sdnc.assignError(execution) - - + + @@ -570,8 +569,8 @@ sdnc.assignError(execution) - - + + diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowTest.java index 335f3468a7..4e45aafc9e 100644 --- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowTest.java +++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowTest.java @@ -56,6 +56,7 @@ import org.camunda.bpm.engine.RuntimeService; import org.camunda.bpm.engine.history.HistoricProcessInstance; import org.camunda.bpm.engine.history.HistoricVariableInstance; import org.camunda.bpm.engine.runtime.ProcessInstance; +import org.camunda.bpm.engine.runtime.ProcessInstanceQuery; import org.camunda.bpm.engine.test.ProcessEngineRule; import org.camunda.bpm.engine.variable.impl.VariableMapImpl; import org.custommonkey.xmlunit.DetailedDiff; @@ -884,11 +885,20 @@ public abstract class WorkflowTest { return null; } + ProcessInstanceQuery processInstanceQuery = null; if (processInstance == null) { - processInstance = runtimeService + processInstanceQuery = runtimeService .createProcessInstanceQuery() - .processDefinitionKey(processKey) - .singleResult(); + .processDefinitionKey(processKey); + } + + if(processInstanceQuery.count() <= 1){ + processInstance = processInstanceQuery.singleResult(); + }else{ + //TODO There shouldnt be more than one in the list but seems to be happening, need to figure out why happening and best way to get correct one from list + msoLogger.debug("Process Instance Query returned " + processInstanceQuery.count() + " instance. Getting the last instance in the list"); + List processList = processInstanceQuery.list(); + processInstance = processList.get((processList.size() - 1)); } if (processInstance != null) { @@ -927,7 +937,7 @@ public abstract class WorkflowTest { protected boolean injectSDNCRestCallback(String contentType, String content, long timeout) { String sdncRequestId = (String) getProcessVariable("SDNCAdapterRestV1", "SDNCAResponse_CORRELATOR", timeout); - + if (sdncRequestId == null) { sdncRequestId = (String) getProcessVariable("SDNCAdapterRestV2", "SDNCAResponse_CORRELATOR", timeout); @@ -1693,7 +1703,7 @@ public abstract class WorkflowTest { /** * Checks to see if the specified process is ended. - * + * * @param processInstanceId the process Instance Id * @return true if the process is ended */ @@ -1705,7 +1715,7 @@ public abstract class WorkflowTest { /** * Checks to see if the specified process is ended. - * + * * @author cb645j */ //TODO combine into 1 -- cgit 1.2.3-korg