diff options
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/main/java')
12 files changed, 291 insertions, 70 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterCreateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterCreateTasks.java index bc3845d760..4c531d46f9 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterCreateTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterCreateTasks.java @@ -21,8 +21,8 @@ package org.onap.so.bpmn.infrastructure.adapter.network.tasks; import java.util.Map; -import java.util.Optional; +import org.onap.so.adapters.nwrest.CreateNetworkRequest; import org.onap.so.adapters.nwrest.CreateNetworkResponse; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; @@ -30,24 +30,23 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; +import org.onap.so.client.adapter.network.mapper.NetworkAdapterObjectMapper; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.client.orchestration.NetworkAdapterResources; -import org.onap.so.logger.MsoLogger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component public class NetworkAdapterCreateTasks { - private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, NetworkAdapterCreateTasks.class); @Autowired private ExtractPojosForBB extractPojosForBB; @Autowired - private NetworkAdapterResources networkAdapterResources; - @Autowired private ExceptionBuilder exceptionUtil; - - + @Autowired + private NetworkAdapterObjectMapper networkAdapterObjectMapper; + @Autowired + private NetworkAdapterResources networkAdapterResources; public void createNetwork(BuildingBlockExecution execution) { execution.setVariable("networkAdapterCreateRollback", false); @@ -59,18 +58,29 @@ public class NetworkAdapterCreateTasks { Map<String, String> userInput = gBBInput.getUserInput(); String cloudRegionPo = execution.getVariable("cloudRegionPo"); - Optional<CreateNetworkResponse> oCreateNetworkResponse = networkAdapterResources.createNetwork(gBBInput.getRequestContext(), gBBInput.getCloudRegion(), gBBInput.getOrchContext(), serviceInstance, l3Network, userInput, cloudRegionPo, gBBInput.getCustomer()); - if (oCreateNetworkResponse.isPresent()){ - CreateNetworkResponse createNetworkResponse = oCreateNetworkResponse.get(); + CreateNetworkRequest createNetworkRequest = networkAdapterObjectMapper.createNetworkRequestMapper(gBBInput.getRequestContext(), gBBInput.getCloudRegion(), gBBInput.getOrchContext(), serviceInstance, l3Network, userInput, cloudRegionPo, gBBInput.getCustomer()); + + execution.setVariable("networkAdapterRequest", createNetworkRequest); + } catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + } + + public void processResponseFromOpenstack(BuildingBlockExecution execution) { + try { + L3Network l3Network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID, execution.getLookupMap().get(ResourceKey.NETWORK_ID)); + + CreateNetworkResponse createNetworkResponse = execution.getVariable("createNetworkResponse"); + if(createNetworkResponse != null) { l3Network.setHeatStackId(createNetworkResponse.getNetworkStackId()); if (createNetworkResponse.getNetworkCreated()){ //setting rollback TRUE only if network was actually created (not a silent success OP) - execution.setVariable("createNetworkResponse", createNetworkResponse); execution.setVariable("networkAdapterCreateRollback", true); } + } else { + throw new Exception("No response was sent back from NetworkAdapterRestV1 subflow."); } - } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterDeleteTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterDeleteTasks.java index 1baa3f5dc9..41dabf9302 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterDeleteTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterDeleteTasks.java @@ -20,18 +20,15 @@ package org.onap.so.bpmn.infrastructure.adapter.network.tasks; -import java.util.Optional; - -import org.onap.so.adapters.nwrest.DeleteNetworkResponse; +import org.onap.so.adapters.nwrest.DeleteNetworkRequest; import org.onap.so.bpmn.common.BuildingBlockExecution; -import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; +import org.onap.so.client.adapter.network.mapper.NetworkAdapterObjectMapper; import org.onap.so.client.exception.ExceptionBuilder; -import org.onap.so.client.orchestration.NetworkAdapterResources; import org.onap.so.logger.MsoLogger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -42,7 +39,7 @@ public class NetworkAdapterDeleteTasks { @Autowired private ExtractPojosForBB extractPojosForBB; @Autowired - private NetworkAdapterResources networkAdapterResources; + private NetworkAdapterObjectMapper networkAdapterObjectMapper; @Autowired private ExceptionBuilder exceptionUtil; @@ -53,14 +50,9 @@ public class NetworkAdapterDeleteTasks { L3Network l3Network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID, execution.getLookupMap().get(ResourceKey.NETWORK_ID)); ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); - Optional<DeleteNetworkResponse> oDeleteNetworkResponse = networkAdapterResources.deleteNetwork(gBBInput.getRequestContext(), gBBInput.getCloudRegion(), serviceInstance, l3Network); + DeleteNetworkRequest deleteNetworkRequest = networkAdapterObjectMapper.deleteNetworkRequestMapper(gBBInput.getRequestContext(), gBBInput.getCloudRegion(), serviceInstance, l3Network); - if (oDeleteNetworkResponse.isPresent()){ - DeleteNetworkResponse deleteNetworkResponse = oDeleteNetworkResponse.get(); - if (deleteNetworkResponse.getNetworkDeleted()) { - execution.setVariable("deleteNetworkResponse", deleteNetworkResponse); - } - } + execution.setVariable("networkAdapterRequest", deleteNetworkRequest); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1.java new file mode 100644 index 0000000000..d821223507 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1.java @@ -0,0 +1,123 @@ +package org.onap.so.bpmn.infrastructure.adapter.network.tasks; + +import java.io.StringReader; +import java.util.Optional; + +import javax.ws.rs.core.Response; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Unmarshaller; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.onap.so.adapters.nwrest.CreateNetworkError; +import org.onap.so.adapters.nwrest.CreateNetworkRequest; +import org.onap.so.adapters.nwrest.CreateNetworkResponse; +import org.onap.so.adapters.nwrest.DeleteNetworkError; +import org.onap.so.adapters.nwrest.DeleteNetworkRequest; +import org.onap.so.adapters.nwrest.DeleteNetworkResponse; +import org.onap.so.client.exception.ExceptionBuilder; +import org.onap.so.client.orchestration.NetworkAdapterResources; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class NetworkAdapterRestV1 { + + private static final Logger logger = LoggerFactory.getLogger(NetworkAdapterRestV1.class); + + private static final String NETWORK_REQUEST = "networkAdapterRequest"; + private static final String NETWORK_MESSAGE = "NetworkAResponse_MESSAGE"; + private static final String NETWORK_SYNC_CODE = "NETWORKREST_networkAdapterStatusCode"; + private static final String NETWORK_SYNC_RESPONSE = "NETWORKREST_networkAdapterResponse"; + private static final String NETWORK_CORRELATOR = "NetworkAResponse_CORRELATOR"; + + @Autowired + private ExceptionBuilder exceptionBuilder; + + @Autowired + private NetworkAdapterResources networkAdapterResources; + + public void callNetworkAdapter (DelegateExecution execution) { + try { + Object networkAdapterRequest = execution.getVariable(NETWORK_REQUEST); + if (networkAdapterRequest != null) { + Optional<Response> response = Optional.empty(); + if (networkAdapterRequest instanceof CreateNetworkRequest) { + CreateNetworkRequest createNetworkRequest = (CreateNetworkRequest) networkAdapterRequest; + execution.setVariable(NETWORK_CORRELATOR, createNetworkRequest.getMessageId()); + response = networkAdapterResources.createNetworkAsync(createNetworkRequest); + } else if (networkAdapterRequest instanceof DeleteNetworkRequest) { + DeleteNetworkRequest deleteNetworkRequest = (DeleteNetworkRequest) networkAdapterRequest; + execution.setVariable(NETWORK_CORRELATOR, deleteNetworkRequest.getMessageId()); + response = networkAdapterResources.deleteNetworkAsync(deleteNetworkRequest); + } + if(response.isPresent()) { + String statusCode = Integer.toString(response.get().getStatus()); + String responseString = ""; + if(response.get().getEntity() != null) { + responseString = (String) response.get().getEntity(); + } + execution.setVariable(NETWORK_SYNC_CODE, statusCode); + execution.setVariable(NETWORK_SYNC_RESPONSE, responseString); + } else { + throw new Exception("No Ack response from Openstack Adapter"); + } + } else { + throw new Exception("No Network Request was created. networkAdapterRequest was null."); + } + } catch (Exception ex) { + exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, ex.getStackTrace().toString()); + } + } + + public void processCallback (DelegateExecution execution) { + try { + Object networkAdapterRequest = execution.getVariable(NETWORK_REQUEST); + String callback = (String) execution.getVariable(NETWORK_MESSAGE); + String logCallbackMessage = "Callback from OpenstackAdapter: " + callback; + logger.debug(logCallbackMessage); + if (networkAdapterRequest != null) { + if (networkAdapterRequest instanceof CreateNetworkRequest) { + if(callback.contains("createNetworkError")) { + CreateNetworkError createNetworkError = (CreateNetworkError) unmarshalXml(callback, CreateNetworkError.class); + throw new Exception(createNetworkError.getMessage()); + } else { + CreateNetworkResponse createNetworkResponse = (CreateNetworkResponse) unmarshalXml(callback, CreateNetworkResponse.class); + execution.setVariable("createNetworkResponse", createNetworkResponse); + } + } else if (networkAdapterRequest instanceof DeleteNetworkRequest) { + if(callback.contains("deleteNetworkError")) { + DeleteNetworkError deleteNetworkError = (DeleteNetworkError) unmarshalXml(callback, DeleteNetworkError.class); + throw new Exception(deleteNetworkError.getMessage()); + } else { + DeleteNetworkResponse deleteNetworkResponse = (DeleteNetworkResponse) unmarshalXml(callback, DeleteNetworkResponse.class); + execution.setVariable("deleteNetworkResponse", deleteNetworkResponse); + } + } + } + } catch (Exception e) { + logger.error("Error in Openstack Adapter callback", e); + exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, e.getMessage()); + } + } + + protected <T> Object unmarshalXml(String xmlString, Class<T> resultClass) throws JAXBException { + StringReader reader = new StringReader(xmlString); + JAXBContext context = JAXBContext.newInstance(resultClass); + Unmarshaller unmarshaller = context.createUnmarshaller(); + return unmarshaller.unmarshal(reader); + } + + public void handleTimeOutException (DelegateExecution execution) { + exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, "Error timed out waiting on Openstack Async-Response"); + } + + public void handleSyncError (DelegateExecution execution) { + String statusCode = (String) execution.getVariable(NETWORK_SYNC_CODE); + String responseString = (String) execution.getVariable(NETWORK_SYNC_RESPONSE); + String errorMessage = "Error with Openstack Adapter Sync Request: StatusCode = " + statusCode + " Response = " + responseString; + exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, errorMessage); + } +} 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/adapter/network/NetworkAdapterClient.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/NetworkAdapterClient.java index 45f28df756..cdb24401b3 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/NetworkAdapterClient.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/NetworkAdapterClient.java @@ -20,6 +20,8 @@ package org.onap.so.client.adapter.network; +import javax.ws.rs.core.Response; + import org.onap.so.adapters.nwrest.CreateNetworkRequest; import org.onap.so.adapters.nwrest.CreateNetworkResponse; import org.onap.so.adapters.nwrest.DeleteNetworkRequest; @@ -44,4 +46,10 @@ public interface NetworkAdapterClient { UpdateNetworkResponse updateNetwork(String aaiNetworkId, UpdateNetworkRequest req) throws NetworkAdapterClientException; + + Response createNetworkAsync(CreateNetworkRequest req) throws NetworkAdapterClientException; + + Response deleteNetworkAsync(String aaiNetworkId, DeleteNetworkRequest req) throws NetworkAdapterClientException; + + Response rollbackNetworkAsync(String aaiNetworkId, RollbackNetworkRequest req) throws NetworkAdapterClientException; } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/NetworkAdapterClientImpl.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/NetworkAdapterClientImpl.java index 9b052b4484..7092fe04c6 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/NetworkAdapterClientImpl.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/NetworkAdapterClientImpl.java @@ -22,6 +22,7 @@ package org.onap.so.client.adapter.network; import javax.ws.rs.InternalServerErrorException; import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; import javax.ws.rs.core.UriBuilder; import org.onap.so.adapters.nwrest.CreateNetworkRequest; @@ -54,6 +55,15 @@ public class NetworkAdapterClientImpl implements NetworkAdapterClient { throw new NetworkAdapterClientException(e.getMessage()); } } + + @Override + public Response createNetworkAsync(CreateNetworkRequest req) throws NetworkAdapterClientException{ + try { + return new AdapterRestClient(this.props, this.getUri("").build()).post(req); + } catch (InternalServerErrorException e) { + throw new NetworkAdapterClientException(e.getMessage()); + } + } @Override public DeleteNetworkResponse deleteNetwork(String aaiNetworkId, DeleteNetworkRequest req) throws NetworkAdapterClientException { @@ -64,6 +74,15 @@ public class NetworkAdapterClientImpl implements NetworkAdapterClient { throw new NetworkAdapterClientException(e.getMessage()); } } + + @Override + public Response deleteNetworkAsync(String aaiNetworkId, DeleteNetworkRequest req) throws NetworkAdapterClientException { + try { + return new AdapterRestClient(this.props, this.getUri("/" + aaiNetworkId).build()).delete(req); + } catch (InternalServerErrorException e) { + throw new NetworkAdapterClientException(e.getMessage()); + } + } @Override public RollbackNetworkResponse rollbackNetwork(String aaiNetworkId, RollbackNetworkRequest req) throws NetworkAdapterClientException { @@ -74,6 +93,15 @@ public class NetworkAdapterClientImpl implements NetworkAdapterClient { throw new NetworkAdapterClientException(e.getMessage()); } } + + @Override + public Response rollbackNetworkAsync(String aaiNetworkId, RollbackNetworkRequest req) throws NetworkAdapterClientException { + try { + return new AdapterRestClient(this.props, this.getUri("/" + aaiNetworkId).build()).delete(req); + } catch (InternalServerErrorException e) { + throw new NetworkAdapterClientException(e.getMessage()); + } + } @Override public QueryNetworkResponse queryNetwork(String aaiNetworkId, String cloudSiteId, String tenantId, diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java index 3081ab86d8..794314bf8c 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java @@ -27,6 +27,7 @@ import java.util.Map; import java.util.Optional; import java.util.UUID; +import org.apache.commons.lang3.StringUtils; import org.modelmapper.ModelMapper; import org.modelmapper.PropertyMap; import org.onap.so.adapters.nwrest.ContrailNetwork; @@ -106,8 +107,7 @@ public class NetworkAdapterObjectMapper { String messageId = getRandomUuid(); createNetworkRequest.setMessageId(messageId); - //TODO clarify callback URL build process - //createNetworkRequest.setNotificationUrl(createCallbackUrl("NetworkAResponse", messageId)); + createNetworkRequest.setNotificationUrl(createCallbackUrl("NetworkAResponse", messageId)); return createNetworkRequest; } @@ -137,11 +137,18 @@ public class NetworkAdapterObjectMapper { deleteNetworkRequest.setMsoRequest(createMsoRequest(requestContext, serviceInstance)); deleteNetworkRequest.setNetworkId(l3Network.getNetworkId()); - deleteNetworkRequest.setNetworkStackId(l3Network.getHeatStackId()); + if (!StringUtils.isEmpty(l3Network.getHeatStackId())){ + deleteNetworkRequest.setNetworkStackId(l3Network.getHeatStackId()); + } + else { + deleteNetworkRequest.setNetworkStackId(l3Network.getNetworkName()); + } deleteNetworkRequest.setNetworkType(l3Network.getNetworkType()); deleteNetworkRequest.setSkipAAI(true); deleteNetworkRequest.setTenantId(cloudRegion.getTenantId()); + deleteNetworkRequest.setNotificationUrl(createCallbackUrl("NetworkAResponse", messageId)); + return deleteNetworkRequest; } @@ -187,11 +194,10 @@ public class NetworkAdapterObjectMapper { return updateNetworkRequest; } - private RollbackNetworkRequest setCommonRollbackRequestFields(RollbackNetworkRequest request,RequestContext requestContext){ - //TODO confirm flag value + private RollbackNetworkRequest setCommonRollbackRequestFields(RollbackNetworkRequest request,RequestContext requestContext) throws UnsupportedEncodingException{ request.setSkipAAI(true); - request.setMessageId(requestContext.getMsoRequestId()); - //TODO clarify callback URL build process. This will also set SYNC flag + String messageId = requestContext.getMsoRequestId(); + request.setMessageId(messageId); //request.setNotificationUrl(createCallbackUrl("NetworkAResponse", messageId)); return request; } @@ -365,4 +371,4 @@ public class NetworkAdapterObjectMapper { updateNetworkRequest.setBackout(Boolean.TRUE.equals(orchestrationContext.getIsRollbackEnabled())); //NetworkTechnology(NetworkTechnology.NEUTRON); NOOP - default } -} +}
\ No newline at end of file diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/NetworkAdapterResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/NetworkAdapterResources.java index 64a86fc731..feb6ed4013 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/NetworkAdapterResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/NetworkAdapterResources.java @@ -24,6 +24,8 @@ import java.io.UnsupportedEncodingException; import java.util.Map; import java.util.Optional; +import javax.ws.rs.core.Response; + import org.onap.so.adapters.nwrest.CreateNetworkRequest; import org.onap.so.adapters.nwrest.CreateNetworkResponse; import org.onap.so.adapters.nwrest.DeleteNetworkRequest; @@ -79,4 +81,29 @@ public class NetworkAdapterResources { DeleteNetworkRequest deleteNetworkRequest = networkAdapterObjectMapper.deleteNetworkRequestMapper(requestContext, cloudRegion, serviceInstance, l3Network); return Optional.of(networkAdapterClient.deleteNetwork(l3Network.getNetworkId(), deleteNetworkRequest)); } + + public Optional<Response> createNetworkAsync(CreateNetworkRequest createNetworkRequest) throws UnsupportedEncodingException, NetworkAdapterClientException { + + return Optional.of(networkAdapterClient.createNetworkAsync(createNetworkRequest)); + } + + public Optional<Response> deleteNetworkAsync(DeleteNetworkRequest deleteNetworkRequest) throws UnsupportedEncodingException, NetworkAdapterClientException { + + return Optional.of(networkAdapterClient.deleteNetworkAsync(deleteNetworkRequest.getNetworkId(), deleteNetworkRequest)); + } + + public Optional<RollbackNetworkResponse> rollbackCreateNetwork(String networkId, RollbackNetworkRequest rollbackNetworkRequest) throws UnsupportedEncodingException, NetworkAdapterClientException { + + return Optional.of(networkAdapterClient.rollbackNetwork(networkId, rollbackNetworkRequest)); + } + + public Optional<UpdateNetworkResponse> updateNetwork(UpdateNetworkRequest updateNetworkRequest) throws UnsupportedEncodingException, NetworkAdapterClientException { + + return Optional.of(networkAdapterClient.updateNetwork(updateNetworkRequest.getNetworkId(), updateNetworkRequest)); + } + + public Optional<DeleteNetworkResponse> deleteNetwork(DeleteNetworkRequest deleteNetworkRequest) throws UnsupportedEncodingException, NetworkAdapterClientException { + + return Optional.of(networkAdapterClient.deleteNetwork(deleteNetworkRequest.getNetworkId(), deleteNetworkRequest)); + } } 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); } } |