diff options
28 files changed, 460 insertions, 231 deletions
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AbstractAuditService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AbstractAuditService.java index 0c05df959f..ddd9fb1b5e 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AbstractAuditService.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AbstractAuditService.java @@ -25,6 +25,7 @@ import java.util.Optional; import org.onap.so.objects.audit.AAIObjectAudit; import org.onap.so.objects.audit.AAIObjectAuditList; import org.onap.so.utils.ExternalTaskUtils; +import org.onap.so.utils.RetrySequenceLevel; import org.onap.logging.filter.base.ONAPComponents; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -47,6 +48,10 @@ public abstract class AbstractAuditService extends ExternalTaskUtils { @Autowired public Environment env; + public AbstractAuditService() { + super(RetrySequenceLevel.LONG); + } + /** * @param auditHeatStackFailed * @param auditList diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditCreateStackService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditCreateStackService.java index 43b362cbaf..8291fa9882 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditCreateStackService.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditCreateStackService.java @@ -32,6 +32,7 @@ import org.onap.so.audit.beans.AuditInventory; import org.onap.so.client.graphinventory.GraphInventoryCommonObjectMapperProvider; import org.onap.so.externaltasks.logging.AuditMDCSetup; import org.onap.so.objects.audit.AAIObjectAuditList; +import org.onap.so.utils.RetrySequenceLevel; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -48,6 +49,10 @@ public class AuditCreateStackService extends AbstractAuditService { @Autowired private AuditMDCSetup mdcSetup; + public AuditCreateStackService() { + super(); + } + protected void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) { mdcSetup.setupMDC(externalTask); AuditInventory auditInventory = externalTask.getVariable("auditInventory"); diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditDeleteStackService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditDeleteStackService.java index da5e8bb3a2..cf077915c9 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditDeleteStackService.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditDeleteStackService.java @@ -56,6 +56,10 @@ public class AuditDeleteStackService extends AbstractAuditService { @Autowired protected Environment env; + public AuditDeleteStackService() { + super(); + } + protected void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) { mdcSetup.setupMDC(externalTask); AuditInventory auditInventory = externalTask.getVariable("auditInventory"); diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditQueryStackService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditQueryStackService.java index 8699f8b953..1c69a3e5e7 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditQueryStackService.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditQueryStackService.java @@ -28,6 +28,10 @@ public class AuditQueryStackService extends AbstractAuditService { @Autowired protected AuditDataService auditDataService; + public AuditQueryStackService() { + super(); + } + protected void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) { mdcSetup.setupMDC(externalTask); AuditInventory auditInventory = externalTask.getVariable("auditInventory"); diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/create/CreateInventoryTask.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/create/CreateInventoryTask.java index 3d2d1d2aa3..e02258c619 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/create/CreateInventoryTask.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/create/CreateInventoryTask.java @@ -29,6 +29,7 @@ import org.onap.so.client.graphinventory.GraphInventoryCommonObjectMapperProvide import org.onap.so.externaltasks.logging.AuditMDCSetup; import org.onap.so.objects.audit.AAIObjectAuditList; import org.onap.so.utils.ExternalTaskUtils; +import org.onap.so.utils.RetrySequenceLevel; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -49,6 +50,10 @@ public class CreateInventoryTask extends ExternalTaskUtils { @Autowired private AuditMDCSetup mdcSetup; + public CreateInventoryTask() { + super(RetrySequenceLevel.SHORT); + } + protected void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) { mdcSetup.setupMDC(externalTask); boolean success = true; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/L3Network.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/L3Network.java index 6b3ad1d528..554e987fc8 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/L3Network.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/L3Network.java @@ -100,6 +100,10 @@ public class L3Network implements Serializable, ShallowCopy<L3Network> { private List<AggregateRoute> aggregateRoutes = new ArrayList<>(); @JsonProperty("vpn-binding") private List<VpnBinding> vpnBindings = new ArrayList<>(); + @JsonProperty("line-of-business") + private LineOfBusiness lineOfBusiness; + @JsonProperty("platform") + private Platform platform; public ModelInfoNetwork getModelInfoNetwork() { return modelInfoNetwork; @@ -313,6 +317,22 @@ public class L3Network implements Serializable, ShallowCopy<L3Network> { return vpnBindings; } + public LineOfBusiness getLineOfBusiness() { + return lineOfBusiness; + } + + public void setLineOfBusiness(LineOfBusiness lineOfBusiness) { + this.lineOfBusiness = lineOfBusiness; + } + + public Platform getPlatform() { + return platform; + } + + public void setPlatform(Platform platform) { + this.platform = platform; + } + @Override public boolean equals(final Object other) { if (!(other instanceof L3Network)) { diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java index a4793476e4..145d4c83a7 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java @@ -915,7 +915,7 @@ public class BBInputSetup implements JavaDelegate { if (network == null && (parameter.getBbName().equalsIgnoreCase(AssignFlows.NETWORK_A_LA_CARTE.toString()) || parameter.getBbName().equalsIgnoreCase(AssignFlows.NETWORK_MACRO.toString()))) { network = createNetwork(parameter.getLookupKeyMap(), parameter.getInstanceName(), parameter.getResourceId(), - parameter.getInstanceParams()); + parameter.getInstanceParams(), parameter); parameter.getServiceInstance().getNetworks().add(network); } if (network != null) { @@ -924,12 +924,20 @@ public class BBInputSetup implements JavaDelegate { } protected L3Network createNetwork(Map<ResourceKey, String> lookupKeyMap, String instanceName, String networkId, - List<Map<String, String>> instanceParams) { + List<Map<String, String>> instanceParams, BBInputSetupParameter parameter) { lookupKeyMap.put(ResourceKey.NETWORK_ID, networkId); L3Network network = new L3Network(); network.setNetworkId(networkId); network.setNetworkName(instanceName); network.setOrchestrationStatus(OrchestrationStatus.PRECREATED); + if (parameter != null) { + if (parameter.getLineOfBusiness() != null) { + network.setLineOfBusiness(this.mapperLayer.mapRequestLineOfBusiness(parameter.getLineOfBusiness())); + } + if (parameter.getLineOfBusiness() != null) { + network.setPlatform(this.mapperLayer.mapRequestPlatform(parameter.getPlatform())); + } + } if (instanceParams != null) { for (Map<String, String> params : instanceParams) { network.getCloudParams().putAll(params); @@ -1284,7 +1292,7 @@ public class BBInputSetup implements JavaDelegate { if (collectionNetworkResourceCust != null) { if ((bbName.equalsIgnoreCase(AssignFlows.NETWORK_A_LA_CARTE.toString()) || bbName.equalsIgnoreCase(AssignFlows.NETWORK_MACRO.toString()))) { - L3Network network = createNetwork(lookupKeyMap, null, networkId, null); + L3Network network = createNetwork(lookupKeyMap, null, networkId, null, null); serviceInstance.getNetworks().add(network); return network; } else { diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java index a45e803cf0..1acf4edb4a 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java @@ -1262,7 +1262,7 @@ public class BBInputSetupTest { verify(SPY_bbInputSetup, times(1)).mapCatalogNetwork(network, modelInfo, service); instanceName = "networkName2"; - L3Network network2 = SPY_bbInputSetup.createNetwork(lookupKeyMap, instanceName, resourceId, null); + L3Network network2 = SPY_bbInputSetup.createNetwork(lookupKeyMap, instanceName, resourceId, null, parameter); SPY_bbInputSetup.populateL3Network(parameter); verify(SPY_bbInputSetup, times(2)).mapCatalogNetwork(network2, modelInfo, service); } @@ -2832,17 +2832,32 @@ public class BBInputSetupTest { expected.setNetworkId(networkId); expected.setNetworkName(instanceName); expected.setCloudParams(cloudParams); + Platform platform = new Platform(); + platform.setPlatformName("platformName"); + expected.setPlatform(platform); + LineOfBusiness lineOfBusiness = new LineOfBusiness(); + lineOfBusiness.setLineOfBusinessName("lineOfBusiness"); + expected.setLineOfBusiness(lineOfBusiness); expected.setOrchestrationStatus(OrchestrationStatus.PRECREATED); Map<ResourceKey, String> lookupKeyMap = new HashMap<>(); List<Map<String, String>> instanceParams = new ArrayList<>(); instanceParams.add(cloudParams); - L3Network actual = SPY_bbInputSetup.createNetwork(lookupKeyMap, instanceName, networkId, instanceParams); + org.onap.so.serviceinstancebeans.Platform platformRequest = new org.onap.so.serviceinstancebeans.Platform(); + org.onap.so.serviceinstancebeans.LineOfBusiness lineOfBusinessRequest = + new org.onap.so.serviceinstancebeans.LineOfBusiness(); + lineOfBusinessRequest.setLineOfBusinessName("lineOfBusiness"); + platformRequest.setPlatformName("platformName"); + BBInputSetupParameter parameter = new BBInputSetupParameter.Builder().setRequestId(REQUEST_ID) + .setPlatform(platformRequest).setLineOfBusiness(lineOfBusinessRequest).build(); + L3Network actual = + SPY_bbInputSetup.createNetwork(lookupKeyMap, instanceName, networkId, instanceParams, parameter); assertThat(actual, sameBeanAs(expected)); assertEquals("LookupKeyMap is populated", networkId, lookupKeyMap.get(ResourceKey.NETWORK_ID)); expected.getCloudParams().clear(); - actual = SPY_bbInputSetup.createNetwork(lookupKeyMap, instanceName, networkId, null); + + actual = SPY_bbInputSetup.createNetwork(lookupKeyMap, instanceName, networkId, null, parameter); assertThat(actual, sameBeanAs(expected)); } diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowProcessor.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowProcessor.java index 70365b744c..25f7c4b93f 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowProcessor.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowProcessor.java @@ -75,9 +75,8 @@ public class WorkflowProcessor extends ProcessEngineAwareService { } } - // Note: the business key is used to identify the process in unit tests protected static String getBusinessKey(Map<String, Object> inputVariables) { - return getOrCreate(inputVariables, "mso-business-key"); + return getOrCreate(inputVariables, "mso-request-id"); } diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/CallActivityBusinessKeyParseListener.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/CallActivityBusinessKeyParseListener.java new file mode 100644 index 0000000000..80d86ad009 --- /dev/null +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/CallActivityBusinessKeyParseListener.java @@ -0,0 +1,30 @@ +package org.onap.so.bpmn.core.plugins; + +import org.camunda.bpm.engine.impl.bpmn.behavior.CallableElementActivityBehavior; +import org.camunda.bpm.engine.impl.bpmn.parser.AbstractBpmnParseListener; +import org.camunda.bpm.engine.impl.context.Context; +import org.camunda.bpm.engine.impl.core.model.CallableElement; +import org.camunda.bpm.engine.impl.el.ElValueProvider; +import org.camunda.bpm.engine.impl.el.Expression; +import org.camunda.bpm.engine.impl.el.ExpressionManager; +import org.camunda.bpm.engine.impl.pvm.process.ActivityImpl; +import org.camunda.bpm.engine.impl.pvm.process.ScopeImpl; +import org.camunda.bpm.engine.impl.util.xml.Element; +import org.springframework.stereotype.Component; + + +@Component +public class CallActivityBusinessKeyParseListener extends AbstractBpmnParseListener { + + @Override + public void parseCallActivity(Element callActivityElement, ScopeImpl scope, ActivityImpl activity) { + ExpressionManager expressionManager = Context.getProcessEngineConfiguration().getExpressionManager(); + Expression expression = expressionManager.createExpression("#{execution.processBusinessKey}"); + ElValueProvider p = new ElValueProvider(expression); + CallableElementActivityBehavior callableElementActivityBehavior = + (CallableElementActivityBehavior) activity.getActivityBehavior(); + CallableElement callableElement = (CallableElement) callableElementActivityBehavior.getCallableElement(); + callableElement.setBusinessKeyValueProvider(p); + callableElementActivityBehavior.setCallableElement(callableElement); + } +} diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/CallActivityBusinessKeyParseListenerPlugin.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/CallActivityBusinessKeyParseListenerPlugin.java new file mode 100644 index 0000000000..a2d897e367 --- /dev/null +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/CallActivityBusinessKeyParseListenerPlugin.java @@ -0,0 +1,24 @@ +package org.onap.so.bpmn.core.plugins; + +import java.util.ArrayList; +import java.util.List; +import org.camunda.bpm.engine.impl.bpmn.parser.BpmnParseListener; +import org.camunda.bpm.engine.impl.cfg.AbstractProcessEnginePlugin; +import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl; +import org.springframework.stereotype.Component; + + +@Component +public class CallActivityBusinessKeyParseListenerPlugin extends AbstractProcessEnginePlugin { + + @Override + public void preInit(ProcessEngineConfigurationImpl processEngineConfiguration) { + List<BpmnParseListener> preParseListeners = processEngineConfiguration.getCustomPreBPMNParseListeners(); + if (preParseListeners == null) { + preParseListeners = new ArrayList<>(); + processEngineConfiguration.setCustomPreBPMNParseListeners(preParseListeners); + } + preParseListeners.add(new CallActivityBusinessKeyParseListener()); + } + +} 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 93f98a34a6..0161422b64 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 @@ -1534,6 +1534,18 @@ public abstract class WorkflowTest { } } + protected Object getVariableFromHistoryByProcessInstanceId(String processInstanceId, String variableName) { + try { + HistoricVariableInstance v = historyService.createHistoricVariableInstanceQuery() + .processInstanceId(processInstanceId).variableName(variableName).singleResult(); + return v == null ? null : v.getValue(); + } catch (Exception e) { + logger.debug("Error retrieving variable {} from historical process with processInstanceId {}: ", + variableName, processInstanceId, e); + return null; + } + } + /** * Gets a variable value from a process instance based on businessKey and process name. Must be used when multiple * instances exist with the same business key such as when business key is passed to subflows or shared across diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignNetworkBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignNetworkBB.bpmn index 7c86e964ec..c48f8b4d10 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignNetworkBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignNetworkBB.bpmn @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_MagIIMOUEeW8asg-vCEgWQ" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.8.2" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"> +<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_MagIIMOUEeW8asg-vCEgWQ" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="3.1.2" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"> <bpmn2:process id="AssignNetworkBB" name="AssignNetworkBB" isExecutable="true"> <bpmn2:startEvent id="AssignNetworkBB_start"> <bpmn2:outgoing>SequenceFlow_11op1ih</bpmn2:outgoing> @@ -21,7 +21,7 @@ <bpmn2:outgoing>SequenceFlow_0988gld</bpmn2:outgoing> </bpmn2:serviceTask> <bpmn2:sequenceFlow id="SequenceFlow_017131q" name="Yes" sourceRef="networkFoundByName_ExclusiveGateway" targetRef="ExclusiveGateway_0vtj8n8"> - <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{AssignNetwork.networkFoundByName(execution.getVariable("gBuildingBlockExecution")) == true}]]></bpmn2:conditionExpression> + <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression">#{AssignNetwork.networkFoundByName(execution.getVariable("gBuildingBlockExecution")) == true}</bpmn2:conditionExpression> </bpmn2:sequenceFlow> <bpmn2:sequenceFlow id="SequenceFlow_0gkr871" name="No" sourceRef="networkFoundByName_ExclusiveGateway" targetRef="ServiceTask_put_network_in_AAI" /> <bpmn2:endEvent id="AssignNetworkBB_end"> @@ -36,11 +36,11 @@ <bpmn2:incoming>SequenceFlow_0e08b9t</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_0mxc4ri</bpmn2:outgoing> </bpmn2:serviceTask> - <bpmn2:sequenceFlow id="SequenceFlow_1ctpnpe" sourceRef="ServiceTask_put_network_in_AAI" targetRef="ServiceTask_connect_to_Tenant" /> + <bpmn2:sequenceFlow id="SequenceFlow_1ctpnpe" sourceRef="ServiceTask_put_network_in_AAI" targetRef="ExclusiveGateway_0g85lk7" /> <bpmn2:sequenceFlow id="SequenceFlow_0e08b9t" sourceRef="ServiceTask_connect_to_NCIG" targetRef="ServiceTask_connect_to_NCSI" /> <bpmn2:sequenceFlow id="SequenceFlow_0mxc4ri" sourceRef="ServiceTask_connect_to_NCSI" targetRef="ExclusiveGateway_0vtj8n8" /> <bpmn2:serviceTask id="ServiceTask_connect_to_Tenant" name=" AAI Connect (tenant) " camunda:expression="${AAICreateTasks.connectNetworkToTenant(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> - <bpmn2:incoming>SequenceFlow_1ctpnpe</bpmn2:incoming> + <bpmn2:incoming>SequenceFlow_0lj5jj1</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_0fwcvep</bpmn2:outgoing> </bpmn2:serviceTask> <bpmn2:serviceTask id="ServiceTask_connect_to_CloudRegion" name=" AAI Connect (cloud region) " camunda:expression="${AAICreateTasks.connectNetworkToCloudRegion(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> @@ -54,11 +54,6 @@ <bpmn2:outgoing>SequenceFlow_017131q</bpmn2:outgoing> <bpmn2:outgoing>SequenceFlow_0gkr871</bpmn2:outgoing> </bpmn2:inclusiveGateway> - <bpmn2:inclusiveGateway id="ExclusiveGateway_0vtj8n8"> - <bpmn2:incoming>SequenceFlow_017131q</bpmn2:incoming> - <bpmn2:incoming>SequenceFlow_0mxc4ri</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_0jm95hf</bpmn2:outgoing> - </bpmn2:inclusiveGateway> <bpmn2:sequenceFlow id="SequenceFlow_0jm95hf" sourceRef="ExclusiveGateway_0vtj8n8" targetRef="ServiceTask_get_cloud_region" /> <bpmn2:sequenceFlow id="SequenceFlow_16hhbw3" sourceRef="ServiceTask_get_cloud_region" targetRef="ServiceTask_assign_network_sdnc" /> <bpmn2:sequenceFlow id="SequenceFlow_0988gld" sourceRef="ServiceTask_assign_network_aai" targetRef="AssignNetworkBB_end" /> @@ -74,11 +69,36 @@ </bpmn2:callActivity> <bpmn2:sequenceFlow id="SequenceFlow_0rt36co" sourceRef="ServiceTask_assign_network_sdnc" targetRef="CallActivity_sdncHandlerCall" /> <bpmn2:sequenceFlow id="SequenceFlow_1mvf7b9" sourceRef="CallActivity_sdncHandlerCall" targetRef="ServiceTask_assign_network_aai" /> - <bpmn2:textAnnotation id="TextAnnotation_0dnksb2"> <bpmn2:text>sets Cloud Region on BB execution for SDNC assign</bpmn2:text> -</bpmn2:textAnnotation> + <bpmn2:serviceTask id="Task_0mu8391" name="Create Platform" camunda:expression="${AAICreateTasks.createPlatformForNetwork(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn2:incoming>SequenceFlow_1kslfgw</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_0j7rpm9</bpmn2:outgoing> + </bpmn2:serviceTask> + <bpmn2:serviceTask id="ServiceTask_0e2crgd" name="Create Lob" camunda:expression="${AAICreateTasks.createLineOfBusinessForNetwork(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn2:incoming>SequenceFlow_0j7rpm9</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_0ugp99e</bpmn2:outgoing> + </bpmn2:serviceTask> + <bpmn2:sequenceFlow id="SequenceFlow_0lj5jj1" sourceRef="ExclusiveGateway_0g85lk7" targetRef="ServiceTask_connect_to_Tenant" /> + <bpmn2:sequenceFlow id="SequenceFlow_1kslfgw" sourceRef="ExclusiveGateway_0g85lk7" targetRef="Task_0mu8391" /> + <bpmn2:sequenceFlow id="SequenceFlow_0j7rpm9" sourceRef="Task_0mu8391" targetRef="ServiceTask_0e2crgd" /> + <bpmn2:sequenceFlow id="SequenceFlow_0ugp99e" sourceRef="ServiceTask_0e2crgd" targetRef="ExclusiveGateway_0vtj8n8" /> + <bpmn2:parallelGateway id="ExclusiveGateway_0g85lk7"> + <bpmn2:incoming>SequenceFlow_1ctpnpe</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_0lj5jj1</bpmn2:outgoing> + <bpmn2:outgoing>SequenceFlow_1kslfgw</bpmn2:outgoing> + </bpmn2:parallelGateway> + <bpmn2:inclusiveGateway id="ExclusiveGateway_0vtj8n8"> + <bpmn2:incoming>SequenceFlow_017131q</bpmn2:incoming> + <bpmn2:incoming>SequenceFlow_0mxc4ri</bpmn2:incoming> + <bpmn2:incoming>SequenceFlow_0ugp99e</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_0jm95hf</bpmn2:outgoing> + </bpmn2:inclusiveGateway> + <bpmn2:textAnnotation id="TextAnnotation_0dnksb2"> + <bpmn2:text>sets Cloud Region on BB execution for SDNC assign</bpmn2:text> + </bpmn2:textAnnotation> <bpmn2:association id="Association_1rsqd3z" sourceRef="ServiceTask_get_cloud_region" targetRef="TextAnnotation_0dnksb2" /> - <bpmn2:textAnnotation id="TextAnnotation_17jb2vn"> <bpmn2:text>conditionally executed if Network Collection Instance Group exists</bpmn2:text> -</bpmn2:textAnnotation> + <bpmn2:textAnnotation id="TextAnnotation_17jb2vn"> + <bpmn2:text>conditionally executed if Network Collection Instance Group exists</bpmn2:text> + </bpmn2:textAnnotation> <bpmn2:association id="Association_15ppe1t" sourceRef="ServiceTask_connect_to_NCIG" targetRef="TextAnnotation_17jb2vn" /> </bpmn2:process> <bpmn2:error id="Error_2" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> @@ -86,165 +106,190 @@ <bpmndi:BPMNDiagram id="BPMNDiagram_1"> <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="AssignNetworkBB"> <bpmndi:BPMNShape id="_BPMNShape_StartEvent_47" bpmnElement="AssignNetworkBB_start"> - <dc:Bounds x="746" y="-105" width="36" height="36" /> + <dc:Bounds x="156" y="137" width="36" height="36" /> <bpmndi:BPMNLabel> <dc:Bounds x="739" y="-64" width="50" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_1wo7ke9_di" bpmnElement="ServiceTask_get_cloud_region"> - <dc:Bounds x="1632" y="-127" width="100" height="80" /> + <dc:Bounds x="1042" y="115" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_1ofnl0p_di" bpmnElement="ServiceTask_assign_network_sdnc"> - <dc:Bounds x="1769" y="-127" width="100" height="80" /> + <dc:Bounds x="1179" y="115" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="TextAnnotation_0dnksb2_di" bpmnElement="TextAnnotation_0dnksb2"> - <dc:Bounds x="1576" y="35" width="212" height="30" /> + <dc:Bounds x="986" y="242" width="212" height="30" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="Association_1rsqd3z_di" bpmnElement="Association_1rsqd3z"> - <di:waypoint xsi:type="dc:Point" x="1682" y="-47" /> - <di:waypoint xsi:type="dc:Point" x="1682" y="35" /> + <di:waypoint x="1092" y="195" /> + <di:waypoint x="1092" y="242" /> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_1dm3ngd_di" bpmnElement="ServiceTask_put_network_in_AAI"> - <dc:Bounds x="906" y="-49" width="100" height="80" /> + <dc:Bounds x="316" y="193" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_18yks1p_di" bpmnElement="ServiceTask_assign_network_aai"> - <dc:Bounds x="2106" y="-127" width="100" height="80" /> + <dc:Bounds x="1516" y="115" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_017131q_di" bpmnElement="SequenceFlow_017131q"> - <di:waypoint xsi:type="dc:Point" x="863" y="-112" /> - <di:waypoint xsi:type="dc:Point" x="863" y="-161" /> - <di:waypoint xsi:type="dc:Point" x="1562" y="-161" /> - <di:waypoint xsi:type="dc:Point" x="1562" y="-112" /> + <di:waypoint x="273" y="130" /> + <di:waypoint x="273" y="81" /> + <di:waypoint x="972" y="81" /> + <di:waypoint x="972" y="130" /> <bpmndi:BPMNLabel> - <dc:Bounds x="871.5" y="-151.96931534232883" width="19" height="12" /> + <dc:Bounds x="282" y="90" width="18" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0gkr871_di" bpmnElement="SequenceFlow_0gkr871"> - <di:waypoint xsi:type="dc:Point" x="863" y="-62" /> - <di:waypoint xsi:type="dc:Point" x="863" y="-9" /> - <di:waypoint xsi:type="dc:Point" x="906" y="-9" /> + <di:waypoint x="273" y="180" /> + <di:waypoint x="273" y="233" /> + <di:waypoint x="316" y="233" /> <bpmndi:BPMNLabel> - <dc:Bounds x="872.125" y="-36.06410256410257" width="14" height="12" /> + <dc:Bounds x="282" y="206" width="15" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="EndEvent_083u1a5_di" bpmnElement="AssignNetworkBB_end"> - <dc:Bounds x="2241" y="-105" width="36" height="36" /> + <dc:Bounds x="1651" y="137" width="36" height="36" /> <bpmndi:BPMNLabel> <dc:Bounds x="2214" y="-65" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_11op1ih_di" bpmnElement="SequenceFlow_11op1ih"> - <di:waypoint xsi:type="dc:Point" x="782" y="-87" /> - <di:waypoint xsi:type="dc:Point" x="838" y="-87" /> + <di:waypoint x="192" y="155" /> + <di:waypoint x="248" y="155" /> <bpmndi:BPMNLabel> <dc:Bounds x="765" y="-102" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_0a96yhg_di" bpmnElement="ServiceTask_connect_to_NCIG"> - <dc:Bounds x="1286" y="-49" width="100" height="80" /> + <dc:Bounds x="743" y="193" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_0mauyto_di" bpmnElement="ServiceTask_connect_to_NCSI"> - <dc:Bounds x="1422" y="-49" width="100" height="80" /> + <dc:Bounds x="867" y="193" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1ctpnpe_di" bpmnElement="SequenceFlow_1ctpnpe"> - <di:waypoint xsi:type="dc:Point" x="1006" y="-9" /> - <di:waypoint xsi:type="dc:Point" x="1036" y="-9" /> + <di:waypoint x="416" y="232" /> + <di:waypoint x="421" y="232" /> <bpmndi:BPMNLabel> <dc:Bounds x="976" y="-24" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0e08b9t_di" bpmnElement="SequenceFlow_0e08b9t"> - <di:waypoint xsi:type="dc:Point" x="1386" y="-9" /> - <di:waypoint xsi:type="dc:Point" x="1422" y="-9" /> + <di:waypoint x="843" y="233" /> + <di:waypoint x="867" y="233" /> <bpmndi:BPMNLabel> <dc:Bounds x="1359" y="-24" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0mxc4ri_di" bpmnElement="SequenceFlow_0mxc4ri"> - <di:waypoint xsi:type="dc:Point" x="1522" y="-9" /> - <di:waypoint xsi:type="dc:Point" x="1562" y="-9" /> - <di:waypoint xsi:type="dc:Point" x="1562" y="-62" /> + <di:waypoint x="917" y="193" /> + <di:waypoint x="956" y="164" /> <bpmndi:BPMNLabel> <dc:Bounds x="1497" y="-24" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_019bzpc_di" bpmnElement="ServiceTask_connect_to_Tenant"> - <dc:Bounds x="1036" y="-49" width="100" height="80" /> + <dc:Bounds x="515" y="193" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_1alvmym_di" bpmnElement="ServiceTask_connect_to_CloudRegion"> - <dc:Bounds x="1162" y="-49" width="100" height="80" /> + <dc:Bounds x="622" y="193" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0fwcvep_di" bpmnElement="SequenceFlow_0fwcvep"> - <di:waypoint xsi:type="dc:Point" x="1136" y="-9" /> - <di:waypoint xsi:type="dc:Point" x="1162" y="-9" /> + <di:waypoint x="565" y="193" /> + <di:waypoint x="565" y="173" /> + <di:waypoint x="672" y="173" /> + <di:waypoint x="672" y="193" /> <bpmndi:BPMNLabel> <dc:Bounds x="1104" y="-24" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_07z7hcu_di" bpmnElement="SequenceFlow_07z7hcu"> - <di:waypoint xsi:type="dc:Point" x="1262" y="-9" /> - <di:waypoint xsi:type="dc:Point" x="1286" y="-9" /> + <di:waypoint x="722" y="233" /> + <di:waypoint x="743" y="233" /> <bpmndi:BPMNLabel> <dc:Bounds x="1229" y="-24" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="TextAnnotation_17jb2vn_di" bpmnElement="TextAnnotation_17jb2vn"> - <dc:Bounds x="1232" y="86" width="158" height="54" /> + <dc:Bounds x="777" y="288" width="158" height="54" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="Association_15ppe1t_di" bpmnElement="Association_15ppe1t"> - <di:waypoint xsi:type="dc:Point" x="1306" y="31" /> - <di:waypoint xsi:type="dc:Point" x="1267" y="86" /> + <di:waypoint x="793" y="273" /> + <di:waypoint x="793" y="288" /> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="InclusiveGateway_0kiphfm_di" bpmnElement="networkFoundByName_ExclusiveGateway"> - <dc:Bounds x="838" y="-112" width="50" height="50" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="898" y="-104" width="73" height="24" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="InclusiveGateway_0pxktc3_di" bpmnElement="ExclusiveGateway_0vtj8n8"> - <dc:Bounds x="1537" y="-112" width="50" height="50" /> + <dc:Bounds x="248" y="130" width="50" height="50" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1562" y="-58" width="0" height="12" /> + <dc:Bounds x="308" y="138" width="73" height="27" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0jm95hf_di" bpmnElement="SequenceFlow_0jm95hf"> - <di:waypoint xsi:type="dc:Point" x="1587" y="-87" /> - <di:waypoint xsi:type="dc:Point" x="1632" y="-87" /> + <di:waypoint x="997" y="155" /> + <di:waypoint x="1042" y="155" /> <bpmndi:BPMNLabel> <dc:Bounds x="1609.5" y="-108" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_16hhbw3_di" bpmnElement="SequenceFlow_16hhbw3"> - <di:waypoint xsi:type="dc:Point" x="1732" y="-87" /> - <di:waypoint xsi:type="dc:Point" x="1769" y="-87" /> + <di:waypoint x="1142" y="155" /> + <di:waypoint x="1179" y="155" /> <bpmndi:BPMNLabel> <dc:Bounds x="1750.5" y="-108" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0988gld_di" bpmnElement="SequenceFlow_0988gld"> - <di:waypoint xsi:type="dc:Point" x="2206" y="-87" /> - <di:waypoint xsi:type="dc:Point" x="2241" y="-87" /> + <di:waypoint x="1616" y="155" /> + <di:waypoint x="1651" y="155" /> <bpmndi:BPMNLabel> <dc:Bounds x="2178.5" y="-108" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="CallActivity_0h7upeg_di" bpmnElement="CallActivity_sdncHandlerCall"> - <dc:Bounds x="1927" y="-127" width="100" height="80" /> + <dc:Bounds x="1337" y="115" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0rt36co_di" bpmnElement="SequenceFlow_0rt36co"> - <di:waypoint xsi:type="dc:Point" x="1869" y="-87" /> - <di:waypoint xsi:type="dc:Point" x="1927" y="-87" /> + <di:waypoint x="1279" y="155" /> + <di:waypoint x="1337" y="155" /> <bpmndi:BPMNLabel> <dc:Bounds x="1898" y="-108" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1mvf7b9_di" bpmnElement="SequenceFlow_1mvf7b9"> - <di:waypoint xsi:type="dc:Point" x="2027" y="-87" /> - <di:waypoint xsi:type="dc:Point" x="2106" y="-87" /> + <di:waypoint x="1437" y="155" /> + <di:waypoint x="1516" y="155" /> <bpmndi:BPMNLabel> <dc:Bounds x="2066.5" y="-108" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_0z9uk3m_di" bpmnElement="Task_0mu8391"> + <dc:Bounds x="471" y="305" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_0e2crgd_di" bpmnElement="ServiceTask_0e2crgd"> + <dc:Bounds x="631" y="305" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0lj5jj1_di" bpmnElement="SequenceFlow_0lj5jj1"> + <di:waypoint x="471" y="232" /> + <di:waypoint x="515" y="233" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1kslfgw_di" bpmnElement="SequenceFlow_1kslfgw"> + <di:waypoint x="446" y="257" /> + <di:waypoint x="446" y="345" /> + <di:waypoint x="471" y="345" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0j7rpm9_di" bpmnElement="SequenceFlow_0j7rpm9"> + <di:waypoint x="571" y="343" /> + <di:waypoint x="631" y="341" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0ugp99e_di" bpmnElement="SequenceFlow_0ugp99e"> + <di:waypoint x="731" y="345" /> + <di:waypoint x="972" y="345" /> + <di:waypoint x="972" y="180" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ParallelGateway_02lmom2_di" bpmnElement="ExclusiveGateway_0g85lk7"> + <dc:Bounds x="421" y="207" width="50" height="50" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="InclusiveGateway_1cof7a3_di" bpmnElement="ExclusiveGateway_0vtj8n8"> + <dc:Bounds x="947" y="130" width="50" height="50" /> + </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> </bpmn2:definitions> diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java index 22089dae1f..dab5102efd 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java @@ -31,8 +31,6 @@ import java.util.TreeSet; import java.util.UUID; import java.util.stream.Collectors; import java.util.stream.Stream; -import org.onap.so.client.orchestration.AAIPnfResources; -import org.onap.so.logger.LoggingAnchor; import org.camunda.bpm.engine.delegate.BpmnError; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; @@ -62,12 +60,14 @@ import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.client.orchestration.AAIConfigurationResources; import org.onap.so.client.orchestration.AAIInstanceGroupResources; import org.onap.so.client.orchestration.AAINetworkResources; +import org.onap.so.client.orchestration.AAIPnfResources; import org.onap.so.client.orchestration.AAIServiceInstanceResources; import org.onap.so.client.orchestration.AAIVfModuleResources; import org.onap.so.client.orchestration.AAIVnfResources; import org.onap.so.client.orchestration.AAIVolumeGroupResources; import org.onap.so.client.orchestration.AAIVpnBindingResources; import org.onap.so.logger.ErrorCode; +import org.onap.so.logger.LoggingAnchor; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -274,18 +274,28 @@ public class AAICreateTasks { * @param str * @throws @return */ + public void createPlatformForNetwork(BuildingBlockExecution execution) { + try { + L3Network network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID); + if (network != null) { + createPlatformNetwork(network); + } + } catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + } + + /** + * This method is used for separating (,) from the string. + * + * @param str + * @throws @return + */ public void createPlatform(BuildingBlockExecution execution) { try { GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); - Platform platform = vnf.getPlatform(); - if (platform != null) { - if (platform.getPlatformName() == null || "".equals(platform.getPlatformName())) { - logger.debug("PlatformName is null in input. Skipping create platform..."); - } else { - List<String> platforms = splitCDL(platform.getPlatformName()); - platforms.stream().forEach(platformName -> aaiVnfResources - .createPlatformandConnectVnf(new Platform(platformName), vnf)); - } + if (vnf != null) { + createPlatformVnf(vnf); } } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); @@ -293,6 +303,30 @@ public class AAICreateTasks { } + protected void createPlatformVnf(GenericVnf vnf) { + Platform platform = vnf.getPlatform(); + if (Strings.isNullOrEmpty(platform.getPlatformName())) { + logger.debug("PlatformName is null in input. Skipping create platform..."); + } else { + List<String> platforms = splitCDL(platform.getPlatformName()); + platforms.stream().forEach( + platformName -> aaiVnfResources.createPlatformandConnectVnf(new Platform(platformName), vnf)); + } + } + + protected void createPlatformNetwork(L3Network network) { + Platform platform = network.getPlatform(); + if (platform != null) { + if (Strings.isNullOrEmpty(platform.getPlatformName())) { + logger.debug("PlatformName is null in input. Skipping create platform..."); + } else { + List<String> platforms = splitCDL(platform.getPlatformName()); + platforms.stream().forEach( + platformName -> aaiNetworkResources.createPlatformAndConnectNetwork(platform, network)); + } + } + } + /** * This method is used for separating (,) from the string. * @@ -312,22 +346,51 @@ public class AAICreateTasks { public void createLineOfBusiness(BuildingBlockExecution execution) { try { GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); - LineOfBusiness lineOfBusiness = vnf.getLineOfBusiness(); - if (lineOfBusiness != null) { - if (lineOfBusiness.getLineOfBusinessName() == null - || "".equals(lineOfBusiness.getLineOfBusinessName())) { - logger.info("lineOfBusiness is null in input. Skipping create lineOfBusiness..."); - } else { - List<String> lineOfBussinesses = splitCDL(lineOfBusiness.getLineOfBusinessName()); - lineOfBussinesses.stream().forEach(lobName -> aaiVnfResources - .createLineOfBusinessandConnectVnf(new LineOfBusiness(lobName), vnf)); - } + if (vnf != null) { + createLineOfBusinessVnf(vnf); } } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } + public void createLineOfBusinessForNetwork(BuildingBlockExecution execution) { + try { + L3Network network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID); + if (network != null) { + createLineOfBusinessNetwork(network); + } + } catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + } + + protected void createLineOfBusinessVnf(GenericVnf vnf) { + LineOfBusiness lineOfBusiness = vnf.getLineOfBusiness(); + if (lineOfBusiness != null) { + if (Strings.isNullOrEmpty(lineOfBusiness.getLineOfBusinessName())) { + logger.info("lineOfBusiness is null in input. Skipping create lineOfBusiness..."); + } else { + List<String> lineOfBussinesses = splitCDL(lineOfBusiness.getLineOfBusinessName()); + lineOfBussinesses.stream().forEach( + lobName -> aaiVnfResources.createLineOfBusinessandConnectVnf(new LineOfBusiness(lobName), vnf)); + } + } + } + + protected void createLineOfBusinessNetwork(L3Network network) { + LineOfBusiness lineOfBusiness = network.getLineOfBusiness(); + if (lineOfBusiness != null) { + if (Strings.isNullOrEmpty(lineOfBusiness.getLineOfBusinessName())) { + logger.info("lineOfBusiness is null in input. Skipping create lineOfBusiness..."); + } else { + List<String> lineOfBussinesses = splitCDL(lineOfBusiness.getLineOfBusinessName()); + lineOfBussinesses.stream().forEach(lobName -> aaiNetworkResources + .createLineOfBusinessAndConnectNetwork(new LineOfBusiness(lobName), network)); + } + } + } + /** * This method is used for creating the volume group in A&AI. * diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java index bc702c9fb4..3af65815a6 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java @@ -30,6 +30,8 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection; import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; +import org.onap.so.bpmn.servicedecomposition.bbobjects.LineOfBusiness; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Platform; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet; import org.onap.so.client.aai.AAIObjectPlurals; @@ -38,8 +40,8 @@ import org.onap.so.client.aai.entities.AAIEdgeLabel; import org.onap.so.client.aai.entities.AAIResultWrapper; import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.onap.so.client.aai.entities.uri.AAIUriFactory; -import org.onap.so.client.graphinventory.entities.uri.Depth; import org.onap.so.client.aai.mapper.AAIObjectMapper; +import org.onap.so.client.graphinventory.entities.uri.Depth; import org.onap.so.db.catalog.beans.OrchestrationStatus; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -76,6 +78,22 @@ public class AAINetworkResources { serviceInstanceURI); } + public void createLineOfBusinessAndConnectNetwork(LineOfBusiness lineOfBusiness, L3Network network) { + AAIResourceUri lineOfBusinessURI = + AAIUriFactory.createResourceUri(AAIObjectType.LINE_OF_BUSINESS, lineOfBusiness.getLineOfBusinessName()); + AAIResourceUri networkURI = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, network.getNetworkId()); + injectionHelper.getAaiClient().createIfNotExists(lineOfBusinessURI, Optional.of(lineOfBusiness)) + .connect(networkURI, lineOfBusinessURI); + } + + public void createPlatformAndConnectNetwork(Platform platform, L3Network network) { + AAIResourceUri platformURI = + AAIUriFactory.createResourceUri(AAIObjectType.PLATFORM, platform.getPlatformName()); + AAIResourceUri networkURI = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, network.getNetworkId()); + injectionHelper.getAaiClient().createIfNotExists(platformURI, Optional.of(platform)).connect(networkURI, + platformURI); + } + public void deleteNetwork(L3Network network) { AAIResourceUri networkURI = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, network.getNetworkId()); injectionHelper.getAaiClient().delete(networkURI); diff --git a/common/src/main/java/org/onap/so/utils/ExternalTaskUtils.java b/common/src/main/java/org/onap/so/utils/ExternalTaskUtils.java index a2aed638fe..9488187003 100644 --- a/common/src/main/java/org/onap/so/utils/ExternalTaskUtils.java +++ b/common/src/main/java/org/onap/so/utils/ExternalTaskUtils.java @@ -1,10 +1,7 @@ package org.onap.so.utils; -import org.camunda.bpm.client.task.ExternalTask; -import org.onap.logging.ref.slf4j.ONAPLogConstants; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.slf4j.MDC; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; @@ -17,6 +14,16 @@ public abstract class ExternalTaskUtils { private static final Logger logger = LoggerFactory.getLogger(ExternalTaskUtils.class); + private final RetrySequenceLevel retrySequenceLevel; + + public ExternalTaskUtils() { + this.retrySequenceLevel = RetrySequenceLevel.MEDIUM; + } + + public ExternalTaskUtils(RetrySequenceLevel retrySequenceLevel) { + this.retrySequenceLevel = retrySequenceLevel; + } + public long calculateRetryDelay(int currentRetries) { int retrySequence = getRetrySequence().length - currentRetries; return Integer.parseInt(getRetrySequence()[retrySequence]) * getRetryMutiplier(); @@ -27,10 +34,30 @@ public abstract class ExternalTaskUtils { } protected String[] getRetrySequence() { - String[] seq = {"1", "1", "2", "3", "5", "8", "13", "20"}; - if (env.getProperty("mso.workflow.topics.retrySequence") != null) { - seq = env.getProperty("mso.workflow.topics.retrySequence", String[].class); + switch (retrySequenceLevel) { + case SHORT: + String[] seqShort = {"1", "1"}; + if (env.getProperty("mso.workflow.topics.retrySequence.short") != null) { + seqShort = env.getProperty("mso.workflow.topics.retrySequence.short", String[].class); + } + return seqShort; + case MEDIUM: + String[] seqInter = {"1", "1", "2", "3", "5"}; + if (env.getProperty("mso.workflow.topics.retrySequence.medium") != null) { + seqInter = env.getProperty("mso.workflow.topics.retrySequence.medium", String[].class); + } + return seqInter; + case LONG: + String[] seqLong = {"1", "1", "2", "3", "5", "8", "13", "20"}; + if (env.getProperty("mso.workflow.topics.retrySequence") != null) { + seqLong = env.getProperty("mso.workflow.topics.retrySequence", String[].class); + } + return seqLong; + default: + String[] seq = {"1"}; + return seq; } - return seq; + } + } diff --git a/common/src/main/java/org/onap/so/utils/RetrySequenceLevel.java b/common/src/main/java/org/onap/so/utils/RetrySequenceLevel.java new file mode 100644 index 0000000000..02964693d2 --- /dev/null +++ b/common/src/main/java/org/onap/so/utils/RetrySequenceLevel.java @@ -0,0 +1,6 @@ +package org.onap.so.utils; + +public enum RetrySequenceLevel { + SHORT, MEDIUM, LONG + +} diff --git a/common/src/test/java/org/onap/so/utils/ExternalTaskUtilsTest.java b/common/src/test/java/org/onap/so/utils/ExternalTaskUtilsTest.java index f918781b39..e27caa6458 100644 --- a/common/src/test/java/org/onap/so/utils/ExternalTaskUtilsTest.java +++ b/common/src/test/java/org/onap/so/utils/ExternalTaskUtilsTest.java @@ -16,7 +16,7 @@ public class ExternalTaskUtilsTest { private Environment mockenv; @InjectMocks - private ExternalTaskUtils externalTaskUtilsAnony = new ExternalTaskUtils() { + private ExternalTaskUtils externalTaskUtilsAnony = new ExternalTaskUtils(RetrySequenceLevel.LONG) { }; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/CamundaRequestHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/CamundaRequestHandler.java index e9f17c42d0..17377d881a 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/CamundaRequestHandler.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/CamundaRequestHandler.java @@ -2,10 +2,10 @@ package org.onap.so.apihandlerinfra; import java.security.GeneralSecurityException; import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; +import javax.ws.rs.core.UriBuilder; import javax.xml.bind.DatatypeConverter; import org.camunda.bpm.engine.impl.persistence.entity.HistoricActivityInstanceEntity; import org.camunda.bpm.engine.impl.persistence.entity.HistoricProcessInstanceEntity; @@ -42,10 +42,29 @@ public class CamundaRequestHandler { @Autowired private Environment env; + private String buildCamundaUrlString(boolean historyLookup, boolean sort, boolean active, String lookupId) { + UriBuilder uriBuilder = UriBuilder.fromUri(env.getProperty("mso.camundaURL")); + if (historyLookup) { + uriBuilder.path(env.getProperty("mso.camunda.rest.history.uri")); + uriBuilder.queryParam("processInstanceBusinessKey", lookupId); + if (active) { + uriBuilder.queryParam("active", true); + } + if (sort) { + uriBuilder.queryParam("sortBy", "startTime"); + uriBuilder.queryParam("sortOrder", "desc"); + } + } else { + uriBuilder.path(env.getProperty("mso.camunda.rest.activity.uri")); + uriBuilder.queryParam("processInstanceId", lookupId); + } + uriBuilder.queryParam("maxResults", 1); + return uriBuilder.build().toString(); + } + public ResponseEntity<List<HistoricProcessInstanceEntity>> getCamundaProcessInstanceHistory(String requestId, - boolean retry) { - String path = env.getProperty("mso.camunda.rest.history.uri") + requestId; - String targetUrl = env.getProperty("mso.camundaURL") + path; + boolean retry, boolean activeOnly, boolean sort) { + String targetUrl = buildCamundaUrlString(true, sort, activeOnly, requestId); HttpHeaders headers = setCamundaHeaders(env.getRequiredProperty("mso.camundaAuth"), env.getRequiredProperty("mso.msoKey")); @@ -77,8 +96,7 @@ public class CamundaRequestHandler { protected ResponseEntity<List<HistoricActivityInstanceEntity>> getCamundaActivityHistory(String processInstanceId) { RestTemplate restTemplate = getRestTemplate(false); - String path = env.getProperty("mso.camunda.rest.activity.uri") + processInstanceId; - String targetUrl = env.getProperty("mso.camundaURL") + path; + String targetUrl = buildCamundaUrlString(false, false, false, processInstanceId); HttpHeaders headers = setCamundaHeaders(env.getRequiredProperty("mso.camundaAuth"), env.getRequiredProperty("mso.msoKey")); HttpEntity<?> requestEntity = new HttpEntity<>(headers); @@ -92,7 +110,7 @@ public class CamundaRequestHandler { String taskInformation = null; try { - response = getCamundaProcessInstanceHistory(requestId, false); + response = getCamundaProcessInstanceHistory(requestId, false, false, true); } catch (RestClientException e) { logger.warn("Error querying Camunda for process-instance history for requestId: {}, exception: {}", requestId, e.getMessage()); @@ -112,7 +130,6 @@ public class CamundaRequestHandler { String taskInformation = null; if (historicProcessInstanceList != null && !historicProcessInstanceList.isEmpty()) { - Collections.reverse(historicProcessInstanceList); processInstanceId = historicProcessInstanceList.get(0).getId(); } else { logger.warn("No processInstances returned for requestId: {} to get TaskInformation", requestId); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java index 0c6ad0ba22..75b7e74d49 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java @@ -356,7 +356,7 @@ public class RequestHandlerUtils extends AbstractRestHandler { String requestId = duplicateRecord.getRequestId(); ResponseEntity<List<HistoricProcessInstanceEntity>> response = null; try { - response = camundaRequestHandler.getCamundaProcessInstanceHistory(requestId, true); + response = camundaRequestHandler.getCamundaProcessInstanceHistory(requestId, true, true, false); } catch (RestClientException e) { logger.error("Error querying Camunda for process-instance history for requestId: {}, exception: {}", requestId, e.getMessage()); @@ -370,13 +370,8 @@ public class RequestHandlerUtils extends AbstractRestHandler { if (response.getBody().isEmpty()) { updateStatus(duplicateRecord, Status.COMPLETE, "Request Completed"); - } - for (HistoricProcessInstance instance : response.getBody()) { - if (("ACTIVE").equals(instance.getState())) { - return true; - } else { - updateStatus(duplicateRecord, Status.COMPLETE, "Request Completed"); - } + } else { + return true; } return false; } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml b/mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml index babefd9478..baa7af77a5 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml +++ b/mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml @@ -25,9 +25,9 @@ mso: task: uri: /sobpmnengine/task history: - uri: /sobpmnengine/history/process-instance?variables=mso-request-id_eq_ + uri: /sobpmnengine/history/process-instance activity: - uri: /sobpmnengine/history/activity-instance?processInstanceId= + uri: /sobpmnengine/history/activity-instance camundaURL: http://localhost:8089 camundaAuth: E8E19DD16CC90D2E458E8FF9A884CC0452F8F3EB8E321F96038DE38D5C1B0B02DFAE00B88E2CF6E2A4101AB2C011FC161212EE diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/CamundaRequestHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/CamundaRequestHandlerTest.java index 4dc281b3fc..5f41257808 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/CamundaRequestHandlerTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/CamundaRequestHandlerTest.java @@ -44,12 +44,13 @@ public class CamundaRequestHandlerTest extends BaseTest { @Test public void timeoutTest() { wireMockServer.stubFor(get( - ("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_6718de35-b9a5-4670-b19f-a0f4ac22bfaf")) + ("/sobpmnengine/history/process-instance?processInstanceBusinessKey=6718de35-b9a5-4670-b19f-a0f4ac22bfaf&active=true&maxResults=1")) .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/HistoryCheckResponse.json") .withStatus(org.apache.http.HttpStatus.SC_OK).withFixedDelay(40000))); thrown.expect(ResourceAccessException.class); - camundaRequestHandler.getCamundaProcessInstanceHistory("6718de35-b9a5-4670-b19f-a0f4ac22bfaf", false); + camundaRequestHandler.getCamundaProcessInstanceHistory("6718de35-b9a5-4670-b19f-a0f4ac22bfaf", false, true, + false); } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/CamundaRequestHandlerUnitTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/CamundaRequestHandlerUnitTest.java index 261b64f2e6..53b9207337 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/CamundaRequestHandlerUnitTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/CamundaRequestHandlerUnitTest.java @@ -105,10 +105,8 @@ public class CamundaRequestHandlerUnitTest { activityInstanceResponse = new ResponseEntity<List<HistoricActivityInstanceEntity>>(activityInstanceList, HttpStatus.ACCEPTED); - doReturn("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_").when(env) - .getProperty("mso.camunda.rest.history.uri"); - doReturn("/sobpmnengine/history/activity-instance?processInstanceId=").when(env) - .getProperty("mso.camunda.rest.activity.uri"); + doReturn("/sobpmnengine/history/process-instance").when(env).getProperty("mso.camunda.rest.history.uri"); + doReturn("/sobpmnengine/history/activity-instance").when(env).getProperty("mso.camunda.rest.activity.uri"); doReturn("auth").when(env).getRequiredProperty("mso.camundaAuth"); doReturn("key").when(env).getRequiredProperty("mso.msoKey"); doReturn("http://localhost:8089").when(env).getProperty("mso.camundaURL"); @@ -208,9 +206,9 @@ public class CamundaRequestHandlerUnitTest { @Test public void getTaskName() throws IOException, ContactCamundaException { doReturn(processInstanceResponse).when(camundaRequestHandler).getCamundaProcessInstanceHistory(REQUEST_ID, - false); + false, false, true); doReturn(activityInstanceResponse).when(camundaRequestHandler) - .getCamundaActivityHistory("c4c6b647-a26e-11e9-b144-0242ac14000b"); + .getCamundaActivityHistory("c2fd4066-a26e-11e9-b144-0242ac14000b"); doReturn("Last task executed: BB to Execute").when(camundaRequestHandler).getActivityName(activityInstanceList); String expectedTaskName = "Last task executed: BB to Execute"; @@ -255,7 +253,7 @@ public class CamundaRequestHandlerUnitTest { @Test public void getTaskNameProcessInstanceLookupFailureTest() throws IOException, ContactCamundaException { doThrow(HttpClientErrorException.class).when(camundaRequestHandler).getCamundaProcessInstanceHistory(REQUEST_ID, - false); + false, false, true); String result = camundaRequestHandler.getTaskName(REQUEST_ID); assertNull(result); @@ -265,8 +263,8 @@ public class CamundaRequestHandlerUnitTest { public void getCamundaActivityHistoryTest() throws IOException, ContactCamundaException { HttpHeaders headers = setHeaders(); HttpEntity<?> requestEntity = new HttpEntity<>(headers); - String targetUrl = "http://localhost:8089/sobpmnengine/history/activity-instance?processInstanceId=" - + "c4c6b647-a26e-11e9-b144-0242ac14000b"; + String targetUrl = + "http://localhost:8089/sobpmnengine/history/activity-instance?processInstanceId=c4c6b647-a26e-11e9-b144-0242ac14000b&maxResults=1"; doReturn(activityInstanceResponse).when(restTemplate).exchange(targetUrl, HttpMethod.GET, requestEntity, new ParameterizedTypeReference<List<HistoricActivityInstanceEntity>>() {}); doReturn(headers).when(camundaRequestHandler).setCamundaHeaders("auth", "key"); @@ -279,8 +277,8 @@ public class CamundaRequestHandlerUnitTest { public void getCamundaActivityHistoryErrorTest() { HttpHeaders headers = setHeaders(); HttpEntity<?> requestEntity = new HttpEntity<>(headers); - String targetUrl = "http://localhost:8089/sobpmnengine/history/activity-instance?processInstanceId=" - + "c4c6b647-a26e-11e9-b144-0242ac14000b"; + String targetUrl = + "http://localhost:8089/sobpmnengine/history/activity-instance?processInstanceId=c4c6b647-a26e-11e9-b144-0242ac14000b&maxResults=1"; doThrow(new ResourceAccessException("IOException")).when(restTemplate).exchange(targetUrl, HttpMethod.GET, requestEntity, new ParameterizedTypeReference<List<HistoricActivityInstanceEntity>>() {}); doReturn(headers).when(camundaRequestHandler).setCamundaHeaders("auth", "key"); @@ -296,14 +294,14 @@ public class CamundaRequestHandlerUnitTest { public void getCamundaProccesInstanceHistoryTest() throws IOException, ContactCamundaException { HttpHeaders headers = setHeaders(); HttpEntity<?> requestEntity = new HttpEntity<>(headers); - String targetUrl = - "http://localhost:8089/sobpmnengine/history/process-instance?variables=mso-request-id_eq_" + REQUEST_ID; + String targetUrl = "http://localhost:8089/sobpmnengine/history/process-instance?processInstanceBusinessKey=" + + REQUEST_ID + "&active=true&maxResults=1"; doReturn(processInstanceResponse).when(restTemplate).exchange(targetUrl, HttpMethod.GET, requestEntity, new ParameterizedTypeReference<List<HistoricProcessInstanceEntity>>() {}); doReturn(headers).when(camundaRequestHandler).setCamundaHeaders("auth", "key"); ResponseEntity<List<HistoricProcessInstanceEntity>> actualResponse = - camundaRequestHandler.getCamundaProcessInstanceHistory(REQUEST_ID, false); + camundaRequestHandler.getCamundaProcessInstanceHistory(REQUEST_ID, false, true, false); assertEquals(processInstanceResponse, actualResponse); } @@ -311,14 +309,14 @@ public class CamundaRequestHandlerUnitTest { public void getCamundaProccesInstanceHistoryRetryTest() { HttpHeaders headers = setHeaders(); HttpEntity<?> requestEntity = new HttpEntity<>(headers); - String targetUrl = - "http://localhost:8089/sobpmnengine/history/process-instance?variables=mso-request-id_eq_" + REQUEST_ID; + String targetUrl = "http://localhost:8089/sobpmnengine/history/process-instance?processInstanceBusinessKey=" + + REQUEST_ID + "&active=true&maxResults=1"; doThrow(new ResourceAccessException("I/O error")).when(restTemplateRetry).exchange(targetUrl, HttpMethod.GET, requestEntity, new ParameterizedTypeReference<List<HistoricProcessInstanceEntity>>() {}); doReturn(headers).when(camundaRequestHandler).setCamundaHeaders("auth", "key"); thrown.expect(ResourceAccessException.class); - camundaRequestHandler.getCamundaProcessInstanceHistory(REQUEST_ID, true); + camundaRequestHandler.getCamundaProcessInstanceHistory(REQUEST_ID, true, true, false); verify(restTemplateRetry, times(2)).exchange(targetUrl, HttpMethod.GET, requestEntity, new ParameterizedTypeReference<List<HistoricProcessInstanceEntity>>() {}); @@ -328,14 +326,14 @@ public class CamundaRequestHandlerUnitTest { public void getCamundaProccesInstanceHistoryNoRetryTest() { HttpHeaders headers = setHeaders(); HttpEntity<?> requestEntity = new HttpEntity<>(headers); - String targetUrl = - "http://localhost:8089/sobpmnengine/history/process-instance?variables=mso-request-id_eq_" + REQUEST_ID; + String targetUrl = "http://localhost:8089/sobpmnengine/history/process-instance?processInstanceBusinessKey=" + + REQUEST_ID + "&sortBy=startTime&sortOrder=desc&maxResults=1"; doThrow(HttpClientErrorException.class).when(restTemplate).exchange(targetUrl, HttpMethod.GET, requestEntity, new ParameterizedTypeReference<List<HistoricProcessInstanceEntity>>() {}); doReturn(headers).when(camundaRequestHandler).setCamundaHeaders("auth", "key"); thrown.expect(HttpStatusCodeException.class); - camundaRequestHandler.getCamundaProcessInstanceHistory(REQUEST_ID, false); + camundaRequestHandler.getCamundaProcessInstanceHistory(REQUEST_ID, false, false, true); verify(restTemplate, times(1)).exchange(targetUrl, HttpMethod.GET, requestEntity, new ParameterizedTypeReference<List<HistoricProcessInstanceEntity>>() {}); @@ -345,15 +343,15 @@ public class CamundaRequestHandlerUnitTest { public void getCamundaProccesInstanceHistoryFailThenSuccessTest() throws IOException, ContactCamundaException { HttpHeaders headers = setHeaders(); HttpEntity<?> requestEntity = new HttpEntity<>(headers); - String targetUrl = - "http://localhost:8089/sobpmnengine/history/process-instance?variables=mso-request-id_eq_" + REQUEST_ID; + String targetUrl = "http://localhost:8089/sobpmnengine/history/process-instance?processInstanceBusinessKey=" + + REQUEST_ID + "&sortBy=startTime&sortOrder=desc&maxResults=1"; when(restTemplateRetry.exchange(targetUrl, HttpMethod.GET, requestEntity, new ParameterizedTypeReference<List<HistoricProcessInstanceEntity>>() {})) .thenThrow(new ResourceAccessException("I/O Exception")).thenReturn(processInstanceResponse); doReturn(headers).when(camundaRequestHandler).setCamundaHeaders("auth", "key"); ResponseEntity<List<HistoricProcessInstanceEntity>> actualResponse = - camundaRequestHandler.getCamundaProcessInstanceHistory(REQUEST_ID, true); + camundaRequestHandler.getCamundaProcessInstanceHistory(REQUEST_ID, true, false, true); assertEquals(processInstanceResponse, actualResponse); verify(restTemplateRetry, times(2)).exchange(targetUrl, HttpMethod.GET, requestEntity, diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java index aa6a3836c1..46fd2f9025 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java @@ -101,8 +101,8 @@ public class OrchestrationRequestsTest extends BaseTest { .withBody(new String(Files.readAllBytes( Paths.get("src/test/resources/OrchestrationRequest/ProcessInstanceHistoryResponse.json")))) .withStatus(org.apache.http.HttpStatus.SC_OK))); - wireMockServer.stubFor( - get(("/sobpmnengine/history/activity-instance?processInstanceId=c4c6b647-a26e-11e9-b144-0242ac14000b")) + wireMockServer.stubFor(get( + ("/sobpmnengine/history/activity-instance?processInstanceId=c2fd4066-a26e-11e9-b144-0242ac14000b&maxResults=1")) .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBody(new String(Files.readAllBytes(Paths.get( "src/test/resources/OrchestrationRequest/ActivityInstanceHistoryResponse.json")))) diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsTest.java index abdf38dfa6..7f9ff98b19 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsTest.java @@ -299,7 +299,7 @@ public class RequestHandlerUtilsTest extends BaseTest { @Test public void camundaHistoryCheckTest() throws ContactCamundaException, RequestDbFailureException { wireMockServer.stubFor(get( - ("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f")) + ("/sobpmnengine/history/process-instance?processInstanceBusinessKey=f0a35706-efc4-4e27-80ea-a995d7a2a40f&active=true&maxResults=1")) .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/HistoryCheckResponse.json") .withStatus(org.apache.http.HttpStatus.SC_OK))); @@ -314,7 +314,7 @@ public class RequestHandlerUtilsTest extends BaseTest { @Test public void camundaHistoryCheckNoneFoundTest() throws ContactCamundaException, RequestDbFailureException { wireMockServer.stubFor(get( - ("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f")) + ("/sobpmnengine/history/process-instance?processInstanceBusinessKey=f0a35706-efc4-4e27-80ea-a995d7a2a40f&active=true&maxResults=1")) .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBody("[]").withStatus(org.apache.http.HttpStatus.SC_OK))); @@ -326,21 +326,6 @@ public class RequestHandlerUtilsTest extends BaseTest { } @Test - public void camundaHistoryCheckNotInProgressTest() throws ContactCamundaException, RequestDbFailureException { - wireMockServer.stubFor(get( - ("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f")) - .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) - .withBodyFile("Camunda/HistoryCheckResponseCompleted.json") - .withStatus(org.apache.http.HttpStatus.SC_OK))); - - InfraActiveRequests duplicateRecord = new InfraActiveRequests(); - duplicateRecord.setRequestId("f0a35706-efc4-4e27-80ea-a995d7a2a40f"); - boolean inProgress = false; - inProgress = requestHandlerUtils.camundaHistoryCheck(duplicateRecord, null); - assertFalse(inProgress); - } - - @Test public void setCamundaHeadersTest() throws ContactCamundaException, RequestDbFailureException { String encryptedAuth = "015E7ACF706C6BBF85F2079378BDD2896E226E09D13DC2784BA309E27D59AB9FAD3A5E039DF0BB8408"; // user:password String key = "07a7159d3bf51a0e53be7a8f89699be7"; diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java index 006b82ac58..f566628ee3 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java @@ -2440,7 +2440,7 @@ public class ServiceInstancesTest extends BaseTest { .withBodyFile("InfraActiveRequests/createInfraActiveRequests.json") .withStatus(HttpStatus.SC_ACCEPTED))); wireMockServer.stubFor(get( - ("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f")) + ("/sobpmnengine/history/process-instance?processInstanceBusinessKey=f0a35706-efc4-4e27-80ea-a995d7a2a40f&active=true&maxResults=1")) .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/HistoryCheckResponse.json") .withStatus(org.apache.http.HttpStatus.SC_OK))); @@ -2463,7 +2463,7 @@ public class ServiceInstancesTest extends BaseTest { .withBodyFile("InfraActiveRequests/createInfraActiveRequests.json") .withStatus(HttpStatus.SC_ACCEPTED))); wireMockServer.stubFor(get( - ("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f")) + ("/sobpmnengine/history/process-instance?processInstanceBusinessKey=f0a35706-efc4-4e27-80ea-a995d7a2a40f&active=true&maxResults=1")) .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withStatus(org.apache.http.HttpStatus.SC_INTERNAL_SERVER_ERROR))); @@ -2897,7 +2897,7 @@ public class ServiceInstancesTest extends BaseTest { @Test public void camundaHistoryCheckTest() throws ContactCamundaException, RequestDbFailureException { wireMockServer.stubFor(get( - ("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f")) + ("/sobpmnengine/history/process-instance?processInstanceBusinessKey=f0a35706-efc4-4e27-80ea-a995d7a2a40f&active=true&maxResults=1")) .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBodyFile("Camunda/HistoryCheckResponse.json") .withStatus(org.apache.http.HttpStatus.SC_OK))); @@ -2912,7 +2912,7 @@ public class ServiceInstancesTest extends BaseTest { @Test public void camundaHistoryCheckNoneFoundTest() throws ContactCamundaException, RequestDbFailureException { wireMockServer.stubFor(get( - ("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f")) + ("/sobpmnengine/history/process-instance?processInstanceBusinessKey=f0a35706-efc4-4e27-80ea-a995d7a2a40f&active=true&maxResults=1")) .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBody("[]").withStatus(org.apache.http.HttpStatus.SC_OK))); @@ -2924,21 +2924,6 @@ public class ServiceInstancesTest extends BaseTest { } @Test - public void camundaHistoryCheckNotInProgressTest() throws ContactCamundaException, RequestDbFailureException { - wireMockServer.stubFor(get( - ("/sobpmnengine/history/process-instance?variables=mso-request-id_eq_f0a35706-efc4-4e27-80ea-a995d7a2a40f")) - .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) - .withBodyFile("Camunda/HistoryCheckResponseCompleted.json") - .withStatus(org.apache.http.HttpStatus.SC_OK))); - - InfraActiveRequests duplicateRecord = new InfraActiveRequests(); - duplicateRecord.setRequestId("f0a35706-efc4-4e27-80ea-a995d7a2a40f"); - boolean inProgress = false; - inProgress = requestHandlerUtils.camundaHistoryCheck(duplicateRecord, null); - assertFalse(inProgress); - } - - @Test public void handleReplaceInstance_Test() throws JsonParseException, JsonMappingException, IOException { String replaceVfModule = inputStream("/ReplaceVfModule.json"); ObjectMapper mapper = new ObjectMapper(); diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/ProcessInstanceHistoryResponse.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/ProcessInstanceHistoryResponse.json index faa283463b..4ff2663145 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/ProcessInstanceHistoryResponse.json +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/ProcessInstanceHistoryResponse.json @@ -19,26 +19,5 @@ "caseInstanceId":null, "tenantId":null, "state":"COMPLETED" - }, - { - "id":"c4c6b647-a26e-11e9-b144-0242ac14000b", - "businessKey":null, - "processDefinitionId":"ExecuteBuildingBlock:1:a46566de-a26b-11e9-b144-0242ac14000b", - "processDefinitionKey":"ExecuteBuildingBlock", - "processDefinitionName":"ExecuteBuildingBlock", - "processDefinitionVersion":1, - "startTime":"2019-07-09T17:27:04.298+0000", - "endTime":"2019-07-09T17:27:05.690+0000", - "removalTime":null, - "durationInMillis":1392, - "startUserId":null, - "startActivityId":"Start_ExecuteBuildingBlock", - "deleteReason":null, - "rootProcessInstanceId":"c2fd4066-a26e-11e9-b144-0242ac14000b", - "superProcessInstanceId":"c2fd4066-a26e-11e9-b144-0242ac14000b", - "superCaseInstanceId":null, - "caseInstanceId":null, - "tenantId":null, - "state":"COMPLETED" } ]
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/Camunda/HistoryCheckResponseCompleted.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/Camunda/HistoryCheckResponseCompleted.json deleted file mode 100644 index fdf0e9a286..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/Camunda/HistoryCheckResponseCompleted.json +++ /dev/null @@ -1,21 +0,0 @@ -[ - { - "id":"d1a0456e-1458-11e9-8afb-0242ac190006", - "businessKey":null, - "processDefinitionId":"86cfa113-141a-11e9-8afb-0242ac190006", - "processDefinitionKey":"UnassignServiceInstanceATTBB", - "processDefinitionName":"UnassignServiceInstanceATTBB", - "processDefinitionVersion":1, - "startTime":"2019-01-09T21:52:11.813+0000", - "endTime":"2019-01-09T21:52:12.353+0000", - "durationInMillis":540, - "startUserId":null, - "startActivityId":"Start_UnassignServiceInstanceBB", - "deleteReason":null, - "superProcessInstanceId":"d15f6c9e-1458-11e9-8afb-0242ac190006", - "superCaseInstanceId":null, - "caseInstanceId":null, - "tenantId":null, - "state":"COMPLETED" - } -]
\ No newline at end of file |