diff options
Diffstat (limited to 'bpmn/so-bpmn-tasks/src')
8 files changed, 86 insertions, 53 deletions
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 173d5f7e73..a4ef28496e 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 @@ -21,7 +21,6 @@ package org.onap.so.bpmn.infrastructure.sdnc.tasks; import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.onap.so.bpmn.core.WorkflowException; import org.onap.so.client.exception.BadResponseException; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.client.exception.MapperException; @@ -31,6 +30,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import org.springframework.web.client.HttpClientErrorException; import com.jayway.jsonpath.JsonPath; import com.jayway.jsonpath.PathNotFoundException; @@ -64,15 +64,18 @@ public class SDNCRequestTasks { String finalMessageIndicator = JsonPath.read(response, "$.output.ack-final-indicator"); execution.setVariable("isSDNCCompleted", convertIndicatorToBoolean(finalMessageIndicator)); } catch(PathNotFoundException e) { - logger.error("Error Parsing SDNC Response", e); - exceptionBuilder.buildAndThrowWorkflowException(execution, 7000,"Error Parsing SDNC Response"); + logger.error("Error Parsing SDNC Response. Could not find read final ack indicator from JSON.", e); + exceptionBuilder.buildAndThrowWorkflowException(execution, 7000,"Recieved invalid response from SDNC, unable to read message content."); } catch (MapperException e) { - logger.error("Error Parsing SDNC Response", e); - exceptionBuilder.buildAndThrowWorkflowException(execution, 7000,"Error Parsing SDNC Response"); + logger.error("Failed to map SDNC object to JSON prior to POST.", e); + exceptionBuilder.buildAndThrowWorkflowException(execution, 7000,"Failed to map SDNC object to JSON prior to POST."); } catch (BadResponseException e) { - logger.error("Error Reading SDNC Response", e); - exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, "Error Reading SDNC Response"); - } + logger.error("Did not receive a successful response from SDNC.", e); + exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, e.getLocalizedMessage()); + } catch (HttpClientErrorException e){ + logger.error("HttpClientErrorException: 404 Not Found, Failed to contact SDNC", e); + exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, "SDNC cannot be contacted."); + } } public void processCallback (DelegateExecution execution) { diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java index 50f2091ae2..d18fd006f4 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java @@ -109,7 +109,9 @@ public class WorkflowAction { private static final String USERPARAMSERVICE = "service"; private static final String supportedTypes = "vnfs|vfModules|networks|networkCollections|volumeGroups|serviceInstances"; private static final String HOMINGSOLUTION = "Homing_Solution"; - private static final String FABRIC_CONFIGURATION = "FabricConfiguration"; + private static final String FABRIC_CONFIGURATION = "FabricConfiguration"; + private static final String G_SERVICE_TYPE = "serviceType"; + private static final String SERVICE_TYPE_TRANSPORT = "TRANSPORT"; private static final Logger logger = LoggerFactory.getLogger(WorkflowAction.class); @Autowired @@ -146,6 +148,8 @@ public class WorkflowAction { final String uri = (String) execution.getVariable(G_URI); final String vnfType = (String) execution.getVariable(VNF_TYPE); String serviceInstanceId = (String) execution.getVariable("serviceInstanceId"); + final String serviceType = Optional.ofNullable((String) execution.getVariable(G_SERVICE_TYPE)).orElse(""); + List<OrchestrationFlow> orchFlows = (List<OrchestrationFlow>) execution.getVariable(G_ORCHESTRATION_FLOW); List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>(); WorkflowResourceIds workflowResourceIds = populateResourceIdsFromApiHandler(execution); @@ -192,7 +196,7 @@ public class WorkflowAction { if (aLaCarte) { if (orchFlows == null || orchFlows.isEmpty()) { - orchFlows = queryNorthBoundRequestCatalogDb(execution, requestAction, resourceType, aLaCarte, cloudOwner); + orchFlows = queryNorthBoundRequestCatalogDb(execution, requestAction, resourceType, aLaCarte, cloudOwner, serviceType); } orchFlows = filterOrchFlows(orchFlows, resourceType, execution); String key = ""; @@ -277,7 +281,7 @@ public class WorkflowAction { logger.info("Found {}", foundObjects); if (orchFlows == null || orchFlows.isEmpty()) { - orchFlows = queryNorthBoundRequestCatalogDb(execution, requestAction, resourceType, aLaCarte, cloudOwner); + orchFlows = queryNorthBoundRequestCatalogDb(execution, requestAction, resourceType, aLaCarte, cloudOwner, serviceType); } flowsToExecute = buildExecuteBuildingBlockList(orchFlows, resourceCounter, requestId, apiVersion, resourceId, resourceType, requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails); @@ -1054,9 +1058,21 @@ public class WorkflowAction { protected List<OrchestrationFlow> queryNorthBoundRequestCatalogDb(DelegateExecution execution, String requestAction, WorkflowType resourceName, boolean aLaCarte, String cloudOwner) { + return this.queryNorthBoundRequestCatalogDb(execution, requestAction, resourceName, aLaCarte, cloudOwner, ""); + } + + protected List<OrchestrationFlow> queryNorthBoundRequestCatalogDb(DelegateExecution execution, String requestAction, + WorkflowType resourceName, boolean aLaCarte, String cloudOwner, String serviceType) { List<OrchestrationFlow> listToExecute = new ArrayList<>(); - NorthBoundRequest northBoundRequest = catalogDbClient - .getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(requestAction, resourceName.toString(), aLaCarte, cloudOwner); + NorthBoundRequest northBoundRequest = null; + if (serviceType.equalsIgnoreCase(SERVICE_TYPE_TRANSPORT)) { + northBoundRequest = catalogDbClient + .getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwnerAndServiceType(requestAction, + resourceName.toString(), aLaCarte, cloudOwner, serviceType); + } else { + northBoundRequest = catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner( + requestAction, resourceName.toString(), aLaCarte, cloudOwner); + } if(northBoundRequest == null){ if(aLaCarte){ buildAndThrowException(execution,"The request: ALaCarte " + resourceName + " " + requestAction + " is not supported by GR_API."); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailure.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailure.java index 4fb480892a..1812e50328 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailure.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailure.java @@ -25,6 +25,7 @@ import java.util.Optional; import org.camunda.bpm.engine.delegate.BpmnError; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.onap.so.bpmn.core.WorkflowException; +import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.client.RequestsDbClient; import org.slf4j.Logger; @@ -67,7 +68,7 @@ public class WorkflowActionBBFailure { String errorMsg = ""; Boolean rollbackCompletedSuccessfully = (Boolean) execution.getVariable("isRollbackComplete"); Boolean isRollbackFailure = (Boolean) execution.getVariable("isRollback"); - + ExecuteBuildingBlock ebb = (ExecuteBuildingBlock) execution.getVariable("buildingBlock"); if(rollbackCompletedSuccessfully==null) rollbackCompletedSuccessfully = false; @@ -97,6 +98,17 @@ public class WorkflowActionBBFailure { request.setStatusMessage(errorMsg); execution.setVariable("ErrorMessage", errorMsg); } + if(ebb!=null && ebb.getBuildingBlock()!=null){ + String flowStatus = ""; + if(rollbackCompletedSuccessfully){ + flowStatus = "All Rollback flows have completed successfully"; + }else{ + flowStatus = ebb.getBuildingBlock().getBpmnFlowName() + " has failed."; + } + request.setFlowStatus(flowStatus); + execution.setVariable("flowStatus", flowStatus); + } + request.setProgress(Long.valueOf(100)); request.setRequestStatus("FAILED"); request.setLastModifiedBy("CamundaBPMN"); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java index 917039b17b..78a84b1772 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java @@ -199,6 +199,7 @@ public class WorkflowActionBBTasks { execution.setVariable("finalStatusMessage", macroAction); Timestamp endTime = new Timestamp(System.currentTimeMillis()); request.setEndTime(endTime); + request.setFlowStatus("Successfully completed all Building Blocks"); request.setStatusMessage(macroAction); request.setProgress(Long.valueOf(100)); request.setRequestStatus("COMPLETE"); @@ -269,7 +270,7 @@ public class WorkflowActionBBTasks { int flowSize = rollbackFlows.size(); String handlingCode = (String) execution.getVariable("handlingCode"); if(handlingCode.equals("RollbackToAssigned")){ - for(int i = 0; i<flowSize -1; i++){ + for(int i = 0; i<flowSize; i++){ if(rollbackFlows.get(i).getBuildingBlock().getBpmnFlowName().contains("Unassign")){ rollbackFlows.remove(i); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java index 7d92a5304a..7ad2ef00b2 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java @@ -21,7 +21,6 @@ package org.onap.so.client.sdnc; import java.util.LinkedHashMap; -import java.util.Optional; import javax.ws.rs.core.UriBuilder; @@ -36,9 +35,6 @@ import org.springframework.core.ParameterizedTypeReference; import org.springframework.http.HttpHeaders; import org.springframework.stereotype.Component; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; - @Component public class SDNCClient { @@ -49,6 +45,7 @@ public class SDNCClient { private SDNCProperties properties; @Autowired private SdnCommonTasks sdnCommonTasks; + /** * * @param request @@ -59,13 +56,13 @@ public class SDNCClient { * @throws BadResponseException */ public String post(Object request, SDNCTopology topology) throws MapperException, BadResponseException { - String jsonRequest = sdnCommonTasks.buildJsonRequest(request); - String targetUrl = properties.getHost() + properties.getPath() + ":" + topology.toString() + "/"; - STOClient.setTargetUrl(targetUrl); - HttpHeaders httpHeader = sdnCommonTasks.getHttpHeaders(properties.getAuth()); - STOClient.setHttpHeader(httpHeader); - LinkedHashMap<String, Object> output = STOClient.post(jsonRequest, new ParameterizedTypeReference<LinkedHashMap<String, Object>>() {}); - return sdnCommonTasks.validateSDNResponse(output); + String jsonRequest = sdnCommonTasks.buildJsonRequest(request); + String targetUrl = properties.getHost() + properties.getPath() + ":" + topology.toString() + "/"; + STOClient.setTargetUrl(targetUrl); + HttpHeaders httpHeader = sdnCommonTasks.getHttpHeaders(properties.getAuth()); + STOClient.setHttpHeader(httpHeader); + LinkedHashMap<String, Object> output = STOClient.post(jsonRequest, new ParameterizedTypeReference<LinkedHashMap<String, Object>>() {}); + return sdnCommonTasks.validateSDNResponse(output); } @@ -76,9 +73,8 @@ public class SDNCClient { STOClient.setHttpHeader(httpHeader); LinkedHashMap<String, Object> output = STOClient.post(jsonRequest, new ParameterizedTypeReference<LinkedHashMap<String, Object>>() {}); return sdnCommonTasks.validateSDNResponse(output); -} + } - /** * * @param queryLink @@ -90,15 +86,14 @@ public class SDNCClient { * @throws BadResponseException */ public String get(String queryLink) throws MapperException, BadResponseException { - - String request = ""; - String jsonRequest = sdnCommonTasks.buildJsonRequest(request); - String targetUrl = UriBuilder.fromUri(properties.getHost()).path(queryLink).build().toString(); - STOClient.setTargetUrl(targetUrl); - HttpHeaders httpHeader = sdnCommonTasks.getHttpHeaders(properties.getAuth()); - STOClient.setHttpHeader(httpHeader); - LinkedHashMap<String, Object> output = STOClient.get(jsonRequest, new ParameterizedTypeReference<LinkedHashMap<String, Object>>() {}); - return sdnCommonTasks.validateSDNGetResponse(output); + String request = ""; + String jsonRequest = sdnCommonTasks.buildJsonRequest(request); + String targetUrl = UriBuilder.fromUri(properties.getHost()).path(queryLink).build().toString(); + STOClient.setTargetUrl(targetUrl); + HttpHeaders httpHeader = sdnCommonTasks.getHttpHeaders(properties.getAuth()); + STOClient.setHttpHeader(httpHeader); + LinkedHashMap<String, Object> output = STOClient.get(jsonRequest, new ParameterizedTypeReference<LinkedHashMap<String, Object>>() {}); + return sdnCommonTasks.validateSDNGetResponse(output); } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java index 5c1485979e..f3b094f645 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java @@ -21,9 +21,9 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks; import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.anyObject; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.isA; +import static org.mockito.ArgumentMatchers.anyObject; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.when; @@ -258,33 +258,28 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { List<ExecuteBuildingBlock> flowsToExecute = new ArrayList(); ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock(); BuildingBlock bb1 = new BuildingBlock(); - bb1.setBpmnFlowName("AssignServiceInstanceBB"); + bb1.setBpmnFlowName("AssignVfModuleBB"); ebb1.setBuildingBlock(bb1); flowsToExecute.add(ebb1); ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock(); BuildingBlock bb2 = new BuildingBlock(); - bb2.setBpmnFlowName("CreateNetworkCollectionBB"); + bb2.setBpmnFlowName("CreateVfModuleBB"); ebb2.setBuildingBlock(bb2); flowsToExecute.add(ebb2); ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock(); BuildingBlock bb3 = new BuildingBlock(); - bb3.setBpmnFlowName("AssignNetworkBB"); + bb3.setBpmnFlowName("ActivateVfModuleBB"); ebb3.setBuildingBlock(bb3); flowsToExecute.add(ebb3); - ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock(); - BuildingBlock bb4 = new BuildingBlock(); - bb4.setBpmnFlowName("CreateNetworkBB"); - ebb4.setBuildingBlock(bb4); - flowsToExecute.add(ebb4); execution.setVariable("flowsToExecute", flowsToExecute); - execution.setVariable("gCurrentSequence", 3); - doNothing().when(workflowActionBBFailure).updateRequestErrorStatusMessage(isA(DelegateExecution.class)); - + execution.setVariable("gCurrentSequence", 2); + workflowActionBBTasks.rollbackExecutionPath(execution); List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute"); - assertEquals(ebbs.get(0).getBuildingBlock().getBpmnFlowName(),"DeleteNetworkCollectionBB"); + assertEquals("DeleteVfModuleBB",ebbs.get(0).getBuildingBlock().getBpmnFlowName()); assertEquals(0,execution.getVariable("gCurrentSequence")); + assertEquals(1,ebbs.size()); } @Test diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java index 72f0ce4e6d..7b348c8cb3 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java @@ -982,6 +982,17 @@ public class WorkflowActionTest extends BaseTaskTest { assertEquals(flows.get(8).getFlowName(),"SDNOVnfHealthCheckBB"); assertEquals(flows.get(9).getFlowName(),"AAIUnsetVnfInMaintBB"); } + + @Test + public void queryNorthBoundRequestCatalogDbTransportTest() throws MalformedURLException { + NorthBoundRequest northBoundRequest = new NorthBoundRequest(); + List<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB"); + northBoundRequest.setOrchestrationFlowList(orchFlows); + when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwnerAndServiceType("createInstance","Service",true,"my-custom-cloud-owner","TRANSPORT")).thenReturn(northBoundRequest); + + List<OrchestrationFlow> flows = workflowAction.queryNorthBoundRequestCatalogDb(execution, "createInstance", WorkflowType.SERVICE, true,"my-custom-cloud-owner","TRANSPORT"); + assertEquals(flows.get(0).getFlowName(),"AssignServiceInstanceBB"); + } @Test public void extractResourceIdAndTypeFromUriTest(){ diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionUnitTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionUnitTest.java index 4008240203..297d75a104 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionUnitTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionUnitTest.java @@ -144,7 +144,7 @@ public class WorkflowActionUnitTest { flow.setFlowName("flow x"); List<OrchestrationFlow> flows = Arrays.asList(flow); - doReturn(Arrays.asList(flow)).when(workflowAction).queryNorthBoundRequestCatalogDb(any(), any(), any(), anyBoolean(), any()); + doReturn(Arrays.asList(flow)).when(workflowAction).queryNorthBoundRequestCatalogDb(any(), any(), any(), anyBoolean(), any(), any()); workflowAction.selectExecutionList(execution); verify(workflowAction, times(1)).filterOrchFlows(eq(flows), any(), any()); |