diff options
59 files changed, 1272 insertions, 328 deletions
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryGroups.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryGroups.java index facdd2f4ca..ed2526f400 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryGroups.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryGroups.java @@ -3,6 +3,8 @@ * ONAP - SO * ================================================================================ * Copyright (C) 2019 Huawei Intellectual Property. All rights reserved. + * + * Copyright (C) 2019 IBM. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +23,6 @@ package org.onap.so.adapters.catalogdb.catalogrest; import org.onap.so.db.catalog.beans.InstanceGroup; -import org.onap.so.db.catalog.beans.VFCInstanceGroup; import org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization; import javax.xml.bind.annotation.XmlRootElement; import java.util.ArrayList; diff --git a/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V6.2__Expand_Column_Size_Infra_Active_Requests_Request_Status.sql b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V6.2__Expand_Column_Size_Infra_Active_Requests_Request_Status.sql new file mode 100644 index 0000000000..427eb0bf07 --- /dev/null +++ b/adapters/mso-requests-db-adapter/src/main/resources/db/migration/V6.2__Expand_Column_Size_Infra_Active_Requests_Request_Status.sql @@ -0,0 +1,3 @@ +use requestdb; + +ALTER TABLE infra_active_requests MODIFY COLUMN REQUEST_STATUS varchar(25) NULL;
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExceptionUtil.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExceptionUtil.groovy index d95dbe2184..c23150384e 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExceptionUtil.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ExceptionUtil.groovy @@ -34,6 +34,7 @@ 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.logger.MessageEnum +import org.onap.so.utils.TargetEntities import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -283,6 +284,16 @@ class ExceptionUtil extends AbstractServiceTaskProcessor { execution.setVariable("WorkflowException", exception); logger.debug("Outgoing WorkflowException is " + exception) } + + public void buildWorkflowException(DelegateExecution execution, int errorCode, String errorMessage, TargetEntities extSystemErrorSource) { + MsoUtils utils = new MsoUtils() + String processKey = getProcessKey(execution); + logger.debug("Building a WorkflowException for " + processKey) + + WorkflowException exception = new WorkflowException(processKey, errorCode, errorMessage, extSystemErrorSource); + execution.setVariable("WorkflowException", exception); + logger.debug("Outgoing WorkflowException is " + exception) + } /** * This error handling method builds a WorkflowException Object and throws a diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy index a769eca3a1..866229f6b8 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy @@ -40,7 +40,6 @@ import java.util.UUID - class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { private static final Logger logger = LoggerFactory.getLogger( VnfAdapterRestV1.class); @@ -81,7 +80,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { String msg = getProcessKey(execution) + ': no messageId in ' + requestType logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg, TargetEntity.SO) } execution.setVariable('VNFAResponse_CORRELATOR', messageId) @@ -95,7 +94,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { String msg = getProcessKey(execution) + ': no notificationUrl in ' + requestType logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg, TargetEntity.SO) } execution.setVariable(prefix + 'notificationUrl', notificationUrl) @@ -109,7 +108,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { String msg = getProcessKey(execution) + ': mso:adapters:vnf:rest:endpoint URN mapping is not defined' logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg, TargetEntity.SO) } while (vnfAdapterEndpoint.endsWith('/')) { @@ -127,7 +126,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { String msg = getProcessKey(execution) + ': no vnfId in ' + requestType logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg, TargetEntity.SO) } vnfAdapterMethod = 'POST' @@ -140,7 +139,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { String msg = getProcessKey(execution) + ': no vnfId in ' + requestType logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg, TargetEntity.SO) } String vfModuleId = getChildText(root, 'vfModuleId') @@ -149,7 +148,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { String msg = getProcessKey(execution) + ': no vfModuleId in ' + requestType logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg, TargetEntity.SO) } vnfAdapterMethod = 'PUT' @@ -163,7 +162,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { String msg = getProcessKey(execution) + ': no vnfId in ' + requestType logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg, TargetEntity.SO) } String vfModuleId = getChildText(root, 'vfModuleId') @@ -172,7 +171,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { String msg = getProcessKey(execution) + ': no vfModuleId in ' + requestType logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg, TargetEntity.SO) } vnfAdapterMethod = 'DELETE' @@ -186,7 +185,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { String msg = getProcessKey(execution) + ': no vfModuleRollback in ' + requestType logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg, TargetEntity.SO) } String vnfId = getChildText(vfModuleRollbackNode, 'vnfId') @@ -195,7 +194,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { String msg = getProcessKey(execution) + ': no vnfId in ' + requestType logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg, TargetEntity.SO) } String vfModuleId = getChildText(vfModuleRollbackNode, 'vfModuleId') @@ -204,7 +203,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { String msg = getProcessKey(execution) + ': no vfModuleId in ' + requestType logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg, TargetEntity.SO) } vnfAdapterMethod = 'DELETE' @@ -225,7 +224,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { String msg = getProcessKey(execution) + ': no volumeGroupId in ' + requestType logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg, TargetEntity.SO) } vnfAdapterMethod = 'PUT' @@ -241,7 +240,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { String msg = getProcessKey(execution) + ': no volumeGroupId in ' + requestType logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg, TargetEntity.SO) } vnfAdapterMethod = 'DELETE' @@ -257,7 +256,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { String msg = getProcessKey(execution) + ': no volumeGroupId in ' + requestType logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg, TargetEntity.SO) } vnfAdapterMethod = 'DELETE' @@ -270,7 +269,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { String msg = getProcessKey(execution) + ': Unsupported request type: ' + requestType logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg, TargetEntity.SO) } execution.setVariable(prefix + 'vnfAdapterMethod', vnfAdapterMethod) @@ -307,7 +306,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg, TargetEntity.SO) } } @@ -358,7 +357,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { String msg = 'Unsupported HTTP method "' + vnfAdapterMethod + '" in ' + method + ": " + e logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg, TargetEntity.SO) } execution.setVariable(prefix + "vnfAdapterStatusCode", response.getStatus()) @@ -371,7 +370,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { String msg = 'Caught exception in ' + method + ": " + e logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", ErrorCode.UnknownError.getValue()); - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg, TargetEntity.SO) } } @@ -400,7 +399,7 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { } } catch (Exception e) { logger.debug("Error encountered within VnfAdapterRest ProcessCallback method: {}", e.getMessage(), e) - exceptionUtil.buildAndThrowWorkflowException(execution, 7020, "Error encountered within VnfAdapterRest ProcessCallback method") + exceptionUtil.buildAndThrowWorkflowException(execution, 7020, "Error encountered within VnfAdapterRest ProcessCallback method", TargetEntity.SO) } } @@ -419,10 +418,10 @@ class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { String rolledBack = getChildText(root, "rolledBack") rolledBack = rolledBack == null || rolledBack.isEmpty() ? "" : " rolledBack='" + rolledBack + "'" exceptionUtil.buildWorkflowException(execution, 7020, "Received " + root.name() + - " from VnfAdapter:" + category + message + rolledBack); + " from VnfAdapter:" + category + message + rolledBack, TargetEntity.OPENSTACK); } catch (Exception e) { response = response == null || String.valueOf(response).isEmpty() ? "NONE" : response - exceptionUtil.buildWorkflowException(execution, 7020, "Received error from VnfAdapter: " + response) + exceptionUtil.buildWorkflowException(execution, 7020, "Received error from VnfAdapter: " + response, TargetEntity.OPENSTACK) } } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java index 122e71851f..fd2054c3d0 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java @@ -30,10 +30,13 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; +import org.onap.so.constants.Status; import org.onap.so.db.catalog.beans.macro.RainyDayHandlerStatus; import org.onap.so.db.catalog.client.CatalogDbClient; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.client.RequestsDbClient; +import org.onap.so.utils.TargetEntities; +import org.onap.so.utils.TargetEntity; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -45,6 +48,7 @@ public class ExecuteBuildingBlockRainyDay { private static final Logger logger = LoggerFactory.getLogger(ExecuteBuildingBlockRainyDay.class); public static final String HANDLING_CODE = "handlingCode"; + public static final String ROLLBACK_TARGET_STATE = "rollbackTargetState"; @Autowired private CatalogDbClient catalogDbClient; @@ -165,6 +169,18 @@ public class ExecuteBuildingBlockRainyDay { if (handlingCode.equals("RollbackToAssigned") && !aLaCarte) { handlingCode = "Rollback"; } + if (handlingCode.startsWith("Rollback")) { + String targetState = ""; + if (handlingCode.equalsIgnoreCase("RollbackToAssigned")) { + targetState = Status.ROLLED_BACK_TO_ASSIGNED.toString(); + } else if (handlingCode.equalsIgnoreCase("RollbackToCreated")) { + targetState = Status.ROLLED_BACK_TO_CREATED.toString(); + } else { + targetState = Status.ROLLED_BACK.toString(); + } + execution.setVariable(ROLLBACK_TARGET_STATE, targetState); + logger.debug("Rollback target state is: {}", targetState); + } } logger.debug("RainyDayHandler Status Code is: {}", handlingCode); execution.setVariable(HANDLING_CODE, handlingCode); @@ -185,4 +201,44 @@ public class ExecuteBuildingBlockRainyDay { public void setHandlingStatusSuccess(DelegateExecution execution) { execution.setVariable(HANDLING_CODE, "Success"); } + + public void updateExtSystemErrorSource(DelegateExecution execution) { + try { + String requestId = (String) execution.getVariable("mso-request-id"); + WorkflowException exception = (WorkflowException) execution.getVariable("WorkflowException"); + TargetEntities extSystemErrorSource = exception.getExtSystemErrorSource(); + InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId); + Boolean isRollbackFailure = (Boolean) execution.getVariable("isRollback"); + if (isRollbackFailure == null) { + isRollbackFailure = false; + } + + if (extSystemErrorSource != null) { + String extSystemErrorSourceString = extSystemErrorSource.toString(); + if (isRollbackFailure) { + logger.debug("Updating extSystemErrorSource for isRollbackFailure to {} for request: {}", + extSystemErrorSourceString, requestId); + request.setRollbackExtSystemErrorSource(extSystemErrorSourceString); + } else { + logger.debug("Updating extSystemErrorSource to {} for request: {}", extSystemErrorSourceString, + requestId); + request.setExtSystemErrorSource(extSystemErrorSourceString); + } + } else if (isRollbackFailure) { + logger.debug( + "rollbackExtSystemErrorSource is null for isRollbackFailure. Setting rollbackExtSystemErrorSource to UNKNOWN"); + request.setRollbackExtSystemErrorSource(TargetEntity.UNKNOWN.toString()); + } else { + logger.debug("extSystemErrorSource is null. Setting extSystemErrorSource to UNKNOWN"); + request.setExtSystemErrorSource(TargetEntity.UNKNOWN.toString()); + } + + request.setLastModifiedBy("CamundaBPMN"); + requestDbclient.updateInfraActiveRequests(request); + } catch (Exception e) { + logger.error("Failed to update Request db with extSystemErrorSource or rollbackExtSystemErrorSource: " + + e.getMessage()); + } + } + } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java index d656314fd1..100887dbbc 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java @@ -43,6 +43,8 @@ import org.onap.so.client.graphinventory.GraphInventoryCommonObjectMapperProvide import org.onap.so.logger.MessageEnum; import org.onap.so.objects.audit.AAIObjectAudit; import org.onap.so.objects.audit.AAIObjectAuditList; +import org.onap.so.utils.TargetEntities; +import org.onap.so.utils.TargetEntity; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; @@ -89,6 +91,39 @@ public class ExceptionBuilder { buildAndThrowWorkflowException(execution, errorCode, msg); } + public void buildAndThrowWorkflowException(BuildingBlockExecution execution, int errorCode, Exception exception, + TargetEntities extSystemErrorSource) { + String msg = "Exception in %s.%s "; + try { + logger.error("Exception occurred", exception); + + String errorVariable = "Error%s%s"; + + StackTraceElement[] trace = Thread.currentThread().getStackTrace(); + for (StackTraceElement traceElement : trace) { + if (!traceElement.getClassName().equals(this.getClass().getName()) + && !traceElement.getClassName().equals(Thread.class.getName())) { + msg = String.format(msg, traceElement.getClassName(), traceElement.getMethodName()); + String shortClassName = + traceElement.getClassName().substring(traceElement.getClassName().lastIndexOf(".") + 1); + errorVariable = String.format(errorVariable, shortClassName, traceElement.getMethodName()); + break; + } + } + + logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + ErrorCode.UnknownError.getValue(), msg.toString()); + execution.setVariable(errorVariable, exception.getMessage()); + } catch (Exception ex) { + // log trace, allow process to complete gracefully + logger.error("Exception occurred", ex); + } + + if (exception.getMessage() != null) + msg = msg.concat(exception.getMessage()); + buildAndThrowWorkflowException(execution, errorCode, msg, extSystemErrorSource); + } + public void buildAndThrowWorkflowException(DelegateExecution execution, int errorCode, Exception exception) { String msg = "Exception in %s.%s "; try { @@ -120,6 +155,38 @@ public class ExceptionBuilder { buildAndThrowWorkflowException(execution, errorCode, msg); } + public void buildAndThrowWorkflowException(DelegateExecution execution, int errorCode, Exception exception, + TargetEntities extSystemErrorSource) { + String msg = "Exception in %s.%s "; + try { + logger.error("Exception occurred", exception); + + String errorVariable = "Error%s%s"; + + StackTraceElement[] trace = Thread.currentThread().getStackTrace(); + for (StackTraceElement traceElement : trace) { + if (!traceElement.getClassName().equals(this.getClass().getName()) + && !traceElement.getClassName().equals(Thread.class.getName())) { + msg = String.format(msg, traceElement.getClassName(), traceElement.getMethodName()); + String shortClassName = + traceElement.getClassName().substring(traceElement.getClassName().lastIndexOf(".") + 1); + errorVariable = String.format(errorVariable, shortClassName, traceElement.getMethodName()); + break; + } + } + logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", + ErrorCode.UnknownError.getValue(), msg.toString()); + execution.setVariable(errorVariable, exception.getMessage()); + } catch (Exception ex) { + // log trace, allow process to complete gracefully + logger.error("Exception occurred", ex); + } + + if (exception.getMessage() != null) + msg = msg.concat(exception.getMessage()); + buildAndThrowWorkflowException(execution, errorCode, msg, extSystemErrorSource); + } + public void buildAndThrowWorkflowException(BuildingBlockExecution execution, int errorCode, String errorMessage) { if (execution instanceof DelegateExecutionImpl) { buildAndThrowWorkflowException(((DelegateExecutionImpl) execution).getDelegateExecution(), errorCode, @@ -127,6 +194,14 @@ public class ExceptionBuilder { } } + public void buildAndThrowWorkflowException(BuildingBlockExecution execution, int errorCode, String errorMessage, + TargetEntities extSystemErrorSource) { + if (execution instanceof DelegateExecutionImpl) { + buildAndThrowWorkflowException(((DelegateExecutionImpl) execution).getDelegateExecution(), errorCode, + errorMessage, extSystemErrorSource); + } + } + public void buildAndThrowWorkflowException(DelegateExecution execution, int errorCode, String errorMessage) { String processKey = getProcessKey(execution); logger.info("Building a WorkflowException for Subflow"); @@ -139,6 +214,19 @@ public class ExceptionBuilder { throw new BpmnError("MSOWorkflowException"); } + public void buildAndThrowWorkflowException(DelegateExecution execution, int errorCode, String errorMessage, + TargetEntities extSystemErrorSource) { + String processKey = getProcessKey(execution); + logger.info("Building a WorkflowException for Subflow"); + + WorkflowException exception = new WorkflowException(processKey, errorCode, errorMessage, extSystemErrorSource); + execution.setVariable("WorkflowException", exception); + execution.setVariable("WorkflowExceptionErrorMessage", errorMessage); + logger.info("Outgoing WorkflowException is {}", exception); + logger.info("Throwing MSOWorkflowException"); + throw new BpmnError("MSOWorkflowException"); + } + public void buildAndThrowWorkflowException(DelegateExecution execution, String errorCode, String errorMessage) { execution.setVariable("WorkflowExceptionErrorMessage", errorMessage); throw new BpmnError(errorCode, errorMessage); @@ -204,7 +292,8 @@ public class ExceptionBuilder { if (flowShouldContinue) { execution.setVariable("StatusMessage", errorMessage.toString()); } else { - WorkflowException exception = new WorkflowException(processKey, 400, errorMessage.toString()); + WorkflowException exception = + new WorkflowException(processKey, 400, errorMessage.toString(), TargetEntity.SO); execution.setVariable("WorkflowException", exception); execution.setVariable("WorkflowExceptionErrorMessage", errorMessage.toString()); logger.info("Outgoing WorkflowException is {}", exception); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDayUnitTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDayUnitTest.java new file mode 100644 index 0000000000..6a48558d11 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDayUnitTest.java @@ -0,0 +1,129 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.tasks; + +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.verify; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; +import org.onap.so.bpmn.core.WorkflowException; +import org.onap.so.db.request.beans.InfraActiveRequests; +import org.onap.so.db.request.client.RequestsDbClient; +import org.onap.so.utils.TargetEntity; + +@RunWith(MockitoJUnitRunner.class) +public class ExecuteBuildingBlockRainyDayUnitTest { + + @Mock + private RequestsDbClient requestsDbClient; + + @InjectMocks + @Spy + private ExecuteBuildingBlockRainyDay executeBuildingBlockRainyDay; + + private DelegateExecution execution; + private DelegateExecution executionNullisRollback; + private String msoRequestId = "ef7c004b-829f-4773-a7d8-4de29feef5b1"; + private InfraActiveRequests request = new InfraActiveRequests(); + private WorkflowException exception; + private WorkflowException noExtSystemErrorSourceException; + + @Before + public void setup() { + exception = new WorkflowException("Test exception", 7000, "", "", TargetEntity.SDNC); + noExtSystemErrorSourceException = + new WorkflowException("Test exception without extsystemErrorSource", 7000, "", ""); + + execution = new DelegateExecutionFake(); + execution.setVariable("mso-request-id", "ef7c004b-829f-4773-a7d8-4de29feef5b1"); + + executionNullisRollback = new DelegateExecutionFake(); + executionNullisRollback.setVariable("mso-request-id", "ef7c004b-829f-4773-a7d8-4de29feef5b1"); + } + + @Test + public void updateExtSystemErrorSourceTest() { + doReturn(request).when(requestsDbClient).getInfraActiveRequestbyRequestId(msoRequestId); + doNothing().when(requestsDbClient).updateInfraActiveRequests(request); + execution.setVariable("isRollback", false); + execution.setVariable("WorkflowException", exception); + executeBuildingBlockRainyDay.updateExtSystemErrorSource(execution); + request.setExtSystemErrorSource(TargetEntity.SDNC.toString()); + + verify(requestsDbClient, Mockito.times(1)).updateInfraActiveRequests(request); + } + + @Test + public void updateExtSystemErrorSourceisRollbackTest() { + doReturn(request).when(requestsDbClient).getInfraActiveRequestbyRequestId(msoRequestId); + doNothing().when(requestsDbClient).updateInfraActiveRequests(request); + execution.setVariable("isRollback", true); + execution.setVariable("WorkflowException", exception); + executeBuildingBlockRainyDay.updateExtSystemErrorSource(execution); + request.setExtSystemErrorSource(TargetEntity.SDNC.toString()); + + verify(requestsDbClient, Mockito.times(1)).updateInfraActiveRequests(request); + } + + @Test + public void updateExtSystemErrorSourceisRollbackTargetEntityNullTest() { + doReturn(request).when(requestsDbClient).getInfraActiveRequestbyRequestId(msoRequestId); + doNothing().when(requestsDbClient).updateInfraActiveRequests(request); + execution.setVariable("isRollback", true); + execution.setVariable("WorkflowException", noExtSystemErrorSourceException); + executeBuildingBlockRainyDay.updateExtSystemErrorSource(execution); + request.setExtSystemErrorSource(TargetEntity.UNKNOWN.toString()); + + verify(requestsDbClient, Mockito.times(1)).updateInfraActiveRequests(request); + } + + @Test + public void updateExtSystemErrorSourceTargetEntityNullTest() { + doReturn(request).when(requestsDbClient).getInfraActiveRequestbyRequestId(msoRequestId); + doNothing().when(requestsDbClient).updateInfraActiveRequests(request); + execution.setVariable("isRollback", false); + execution.setVariable("WorkflowException", noExtSystemErrorSourceException); + executeBuildingBlockRainyDay.updateExtSystemErrorSource(execution); + request.setExtSystemErrorSource(TargetEntity.UNKNOWN.toString()); + + verify(requestsDbClient, Mockito.times(1)).updateInfraActiveRequests(request); + } + + @Test + public void updateExtSystemErrorSourceTargetEntityisRollbackNullTest() { + doReturn(request).when(requestsDbClient).getInfraActiveRequestbyRequestId(msoRequestId); + doNothing().when(requestsDbClient).updateInfraActiveRequests(request); + executionNullisRollback.setVariable("WorkflowException", exception); + executeBuildingBlockRainyDay.updateExtSystemErrorSource(executionNullisRollback); + request.setExtSystemErrorSource(TargetEntity.SDNC.toString()); + + verify(requestsDbClient, Mockito.times(1)).updateInfraActiveRequests(request); + } +} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java index c5da3cbd51..80373eb760 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java @@ -38,6 +38,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; +import org.onap.so.constants.Status; import org.onap.so.db.catalog.beans.macro.RainyDayHandlerStatus; import org.springframework.beans.factory.annotation.Autowired; @@ -207,6 +208,7 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution, true); assertEquals("Rollback", delegateExecution.getVariable("handlingCode")); + assertEquals(Status.ROLLED_BACK.toString(), delegateExecution.getVariable("rollbackTargetState")); } @Test @@ -232,9 +234,37 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution, true); assertEquals("RollbackToAssigned", delegateExecution.getVariable("handlingCode")); + assertEquals(Status.ROLLED_BACK_TO_ASSIGNED.toString(), delegateExecution.getVariable("rollbackTargetState")); } @Test + public void queryRainyDayTableRollbackToCreated() throws Exception { + customer.getServiceSubscription().getServiceInstances().add(serviceInstance); + serviceInstance.getModelInfoServiceInstance().setServiceType("st1"); + vnf.setVnfType("vnft1"); + delegateExecution.setVariable("aLaCarte", true); + delegateExecution.setVariable("suppressRollback", false); + delegateExecution.setVariable("WorkflowExceptionCode", "7000"); + RainyDayHandlerStatus rainyDayHandlerStatus = new RainyDayHandlerStatus(); + rainyDayHandlerStatus.setErrorCode("7000"); + rainyDayHandlerStatus.setFlowName("AssignServiceInstanceBB"); + rainyDayHandlerStatus.setServiceType("st1"); + rainyDayHandlerStatus.setVnfType("vnft1"); + rainyDayHandlerStatus.setPolicy("RollbackToCreated"); + rainyDayHandlerStatus.setWorkStep(ASTERISK); + rainyDayHandlerStatus.setSecondaryPolicy("Abort"); + + doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient).getRainyDayHandlerStatus("AssignServiceInstanceBB", + "st1", "vnft1", "7000", "*", "errorMessage"); + + executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution, true); + + assertEquals("RollbackToCreated", delegateExecution.getVariable("handlingCode")); + assertEquals(Status.ROLLED_BACK_TO_CREATED.toString(), delegateExecution.getVariable("rollbackTargetState")); + } + + + @Test public void suppressRollbackTest() throws Exception { delegateExecution.setVariable("suppressRollback", true); delegateExecution.setVariable("aLaCarte", true); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/exception/ExceptionBuilderTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/exception/ExceptionBuilderTest.java index 5f9aef67e6..aae62445de 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/exception/ExceptionBuilderTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/exception/ExceptionBuilderTest.java @@ -55,6 +55,7 @@ public class ExceptionBuilderTest extends BaseTest { @Mock protected ExtractPojosForBB extractPojosForBB; + @Spy @InjectMocks private ExceptionBuilder exceptionBuilder = new ExceptionBuilder(); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/exception/ExceptionBuilderUnitTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/exception/ExceptionBuilderUnitTest.java new file mode 100644 index 0000000000..b109ae258d --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/exception/ExceptionBuilderUnitTest.java @@ -0,0 +1,98 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.exception; + +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import org.camunda.bpm.engine.delegate.BpmnError; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.utils.TargetEntity; + +@RunWith(MockitoJUnitRunner.class) +public class ExceptionBuilderUnitTest { + @Mock + private BuildingBlockExecution buildingBlockExecution; + + @InjectMocks + @Spy + private ExceptionBuilder exceptionBuilder; + + @Rule + public ExpectedException thrown = ExpectedException.none(); + + private Exception e = new Exception("failure message"); + private DelegateExecution execution; + + @Before + public void setup() { + execution = new DelegateExecutionFake(); + } + + + @Test + public void buildAndThrowWorkflowExceptionTest() { + String expectedErrorMessage = + "Exception in org.onap.so.client.exception.ExceptionBuilder.buildAndThrowWorkflowException failure message"; + doNothing().when(exceptionBuilder).buildAndThrowWorkflowException(execution, 7000, expectedErrorMessage, + TargetEntity.SDNC); + + exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, e, TargetEntity.SDNC); + + verify(exceptionBuilder, times(1)).buildAndThrowWorkflowException(execution, 7000, expectedErrorMessage, + TargetEntity.SDNC); + } + + @Test + public void buildAndThrowWorkflowExceptionBuildingBlockExecutionTest() { + String expectedErrorMessage = + "Exception in org.onap.so.client.exception.ExceptionBuilder.buildAndThrowWorkflowException failure message"; + doNothing().when(exceptionBuilder).buildAndThrowWorkflowException(buildingBlockExecution, 7000, + expectedErrorMessage, TargetEntity.SDNC); + + exceptionBuilder.buildAndThrowWorkflowException(buildingBlockExecution, 7000, e, TargetEntity.SDNC); + + verify(exceptionBuilder, times(1)).buildAndThrowWorkflowException(buildingBlockExecution, 7000, + expectedErrorMessage, TargetEntity.SDNC); + } + + @Test + public void buildAndThrowWorkflowExceptionWithErrorMessageTest() { + doReturn("Process key").when(exceptionBuilder).getProcessKey(execution); + + thrown.expect(BpmnError.class); + exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, e.getMessage(), TargetEntity.SDNC); + } +} diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/WorkflowException.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/WorkflowException.java index 1692045d33..7d5bb0dcf1 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/WorkflowException.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/WorkflowException.java @@ -21,6 +21,7 @@ package org.onap.so.bpmn.core; import java.io.Serializable; +import org.onap.so.utils.TargetEntities; /** * An object that represents a workflow exception. @@ -32,6 +33,7 @@ public class WorkflowException implements Serializable { private final int errorCode; private final String errorMessage; private final String workStep; + private TargetEntities extSystemErrorSource; /** * Constructor @@ -47,6 +49,15 @@ public class WorkflowException implements Serializable { workStep = "*"; } + public WorkflowException(String processKey, int errorCode, String errorMessage, + TargetEntities extSystemErrorSource) { + this.processKey = processKey; + this.errorCode = errorCode; + this.errorMessage = errorMessage; + workStep = "*"; + this.extSystemErrorSource = extSystemErrorSource; + } + public WorkflowException(String processKey, int errorCode, String errorMessage, String workStep) { this.processKey = processKey; this.errorCode = errorCode; @@ -54,6 +65,15 @@ public class WorkflowException implements Serializable { this.workStep = workStep; } + public WorkflowException(String processKey, int errorCode, String errorMessage, String workStep, + TargetEntities extSystemErrorSource) { + this.processKey = processKey; + this.errorCode = errorCode; + this.errorMessage = errorMessage; + this.workStep = workStep; + this.extSystemErrorSource = extSystemErrorSource; + } + /** * Returns the process key. */ @@ -82,12 +102,17 @@ public class WorkflowException implements Serializable { return workStep; } + public TargetEntities getExtSystemErrorSource() { + return extSystemErrorSource; + } + /** * Returns a string representation of this object. */ @Override public String toString() { return getClass().getSimpleName() + "[processKey=" + getProcessKey() + ",errorCode=" + getErrorCode() - + ",errorMessage=" + getErrorMessage() + ",workStep=" + getWorkStep() + "]"; + + ",errorMessage=" + getErrorMessage() + ",workStep=" + getWorkStep() + ",extSystemErrorSource=" + + extSystemErrorSource + "]"; } } diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ExecuteBuildingBlock.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ExecuteBuildingBlock.bpmn index 0a6a7731ce..e64c44eb94 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ExecuteBuildingBlock.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ExecuteBuildingBlock.bpmn @@ -11,6 +11,7 @@ <camunda:in source="mso-request-id" target="mso-request-id" /> <camunda:out source="WorkflowExceptionErrorMessage" target="WorkflowExceptionErrorMessage" /> <camunda:out source="StatusMessage" target="StatusMessage" /> + <camunda:in source="isRollback" target="isRollback" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_19wuics</bpmn:incoming> <bpmn:outgoing>SequenceFlow_01h9qmz</bpmn:outgoing> @@ -37,13 +38,8 @@ </bpmn:exclusiveGateway> <bpmn:sequenceFlow id="SequenceFlow_0je0y25" sourceRef="StatusPolicy" targetRef="CheckOrchestrationStatusValidationResults" /> <bpmn:subProcess id="SubProcess_0tv8zda" name="Error Handling " triggeredByEvent="true"> - <bpmn:startEvent id="StartEvent_0tmcs9g"> - <bpmn:outgoing>SequenceFlow_09synl9</bpmn:outgoing> - <bpmn:errorEventDefinition camunda:errorCodeVariable="WorkflowExceptionCode" camunda:errorMessageVariable="WorkflowExceptionMessage" /> - </bpmn:startEvent> - <bpmn:sequenceFlow id="SequenceFlow_09synl9" sourceRef="StartEvent_0tmcs9g" targetRef="Task_QueryRainyDayTable" /> <bpmn:serviceTask id="Task_QueryRainyDayTable" name="QueryRainyDayTable" camunda:expression="${ExecuteBuildingBlockRainyDay.queryRainyDayTable(execution,true)}"> - <bpmn:incoming>SequenceFlow_09synl9</bpmn:incoming> + <bpmn:incoming>SequenceFlow_0vdeqxv</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0a62t4c</bpmn:outgoing> </bpmn:serviceTask> <bpmn:exclusiveGateway id="ExclusiveGateway_1aonzik" name="Check HandlingCode" default="SequenceFlow_0h8v45y"> @@ -93,6 +89,16 @@ <bpmn:incoming>SequenceFlow_0541bid</bpmn:incoming> <bpmn:outgoing>SequenceFlow_12ps9at</bpmn:outgoing> </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_0vdeqxv" sourceRef="Task_UpdateExtErrorSource" targetRef="Task_QueryRainyDayTable" /> + <bpmn:sequenceFlow id="SequenceFlow_09synl9" sourceRef="StartEvent_0tmcs9g" targetRef="Task_UpdateExtErrorSource" /> + <bpmn:startEvent id="StartEvent_0tmcs9g"> + <bpmn:outgoing>SequenceFlow_09synl9</bpmn:outgoing> + <bpmn:errorEventDefinition camunda:errorCodeVariable="WorkflowExceptionCode" camunda:errorMessageVariable="WorkflowExceptionMessage" /> + </bpmn:startEvent> + <bpmn:serviceTask id="Task_UpdateExtErrorSource" name="Update ExtErrorSource" camunda:expression="${ExecuteBuildingBlockRainyDay.updateExtSystemErrorSource(execution)}"> + <bpmn:incoming>SequenceFlow_09synl9</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0vdeqxv</bpmn:outgoing> + </bpmn:serviceTask> </bpmn:subProcess> <bpmn:sequenceFlow id="SequenceFlow_16lmcxp" sourceRef="Task_setHandlingCodeSuccess" targetRef="End_ExecuteBuildingBlock" /> <bpmn:sequenceFlow id="SequenceFlow_1j0vskt" name="Silent Success" sourceRef="CheckOrchestrationStatusValidationResults" targetRef="Task_setHandlingCodeSuccess"> @@ -163,63 +169,63 @@ </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ExclusiveGateway_0ey4zpt_di" bpmnElement="ExclusiveGateway_0ey4zpt" isMarkerVisible="true"> - <dc:Bounds x="721" y="385" width="50" height="50" /> + <dc:Bounds x="692" y="389" width="50" height="50" /> <bpmndi:BPMNLabel> - <dc:Bounds x="716" y="360" width="63" height="13" /> + <dc:Bounds x="686" y="364" width="65" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="IntermediateCatchEvent_0qjyidb_di" bpmnElement="IntermediateCatchEvent_RetryTimer"> - <dc:Bounds x="965" y="392" width="36" height="36" /> + <dc:Bounds x="936" y="396" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="956" y="367" width="55" height="13" /> + <dc:Bounds x="927" y="371" width="56" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ExclusiveGateway_1aonzik_di" bpmnElement="ExclusiveGateway_1aonzik" isMarkerVisible="true"> - <dc:Bounds x="568" y="385" width="50" height="50" /> + <dc:Bounds x="539" y="389" width="50" height="50" /> <bpmndi:BPMNLabel> - <dc:Bounds x="558" y="347" width="70" height="25" /> + <dc:Bounds x="528" y="351" width="72" height="24" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1wbevp0_di" bpmnElement="SequenceFlow_1wbevp0"> - <di:waypoint xsi:type="dc:Point" x="771" y="410" /> - <di:waypoint xsi:type="dc:Point" x="836" y="410" /> + <di:waypoint xsi:type="dc:Point" x="742" y="414" /> + <di:waypoint xsi:type="dc:Point" x="807" y="414" /> <bpmndi:BPMNLabel> - <dc:Bounds x="788" y="385" width="18" height="13" /> + <dc:Bounds x="759" y="389" width="19" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0fwsjva_di" bpmnElement="SequenceFlow_0fwsjva"> - <di:waypoint xsi:type="dc:Point" x="618" y="410" /> - <di:waypoint xsi:type="dc:Point" x="721" y="410" /> + <di:waypoint xsi:type="dc:Point" x="589" y="414" /> + <di:waypoint xsi:type="dc:Point" x="692" y="414" /> <bpmndi:BPMNLabel> - <dc:Bounds x="656" y="418" width="27" height="13" /> + <dc:Bounds x="627" y="422" width="28" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0h8v45y_di" bpmnElement="SequenceFlow_0h8v45y"> - <di:waypoint xsi:type="dc:Point" x="593" y="435" /> - <di:waypoint xsi:type="dc:Point" x="593" y="491" /> + <di:waypoint xsi:type="dc:Point" x="564" y="439" /> + <di:waypoint xsi:type="dc:Point" x="564" y="495" /> <bpmndi:BPMNLabel> - <dc:Bounds x="600" y="456" width="85" height="13" /> + <dc:Bounds x="570" y="460" width="88" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_1tifgqh_di" bpmnElement="Task_QueryRainyDayTable"> - <dc:Bounds x="425" y="370" width="100" height="80" /> + <dc:Bounds x="396" y="374" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0ndt8ft_di" bpmnElement="SequenceFlow_0ndt8ft"> - <di:waypoint xsi:type="dc:Point" x="936" y="410" /> - <di:waypoint xsi:type="dc:Point" x="965" y="410" /> + <di:waypoint xsi:type="dc:Point" x="907" y="414" /> + <di:waypoint xsi:type="dc:Point" x="936" y="414" /> <bpmndi:BPMNLabel> - <dc:Bounds x="906" y="389" width="90" height="12" /> + <dc:Bounds x="877" y="393" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_07a1ytc_di" bpmnElement="SequenceFlow_07a1ytc"> - <di:waypoint xsi:type="dc:Point" x="1001" y="410" /> - <di:waypoint xsi:type="dc:Point" x="1039" y="410" /> + <di:waypoint xsi:type="dc:Point" x="972" y="414" /> + <di:waypoint xsi:type="dc:Point" x="1010" y="414" /> <bpmndi:BPMNLabel> - <dc:Bounds x="975" y="389" width="90" height="12" /> + <dc:Bounds x="946" y="393" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_1obvxht_di" bpmnElement="Task_SetRetryTimer"> - <dc:Bounds x="836" y="370" width="100" height="80" /> + <dc:Bounds x="807" y="374" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0kdjsnx_di" bpmnElement="Continue"> <di:waypoint xsi:type="dc:Point" x="508" y="180" /> @@ -245,38 +251,25 @@ </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0a62t4c_di" bpmnElement="SequenceFlow_0a62t4c"> - <di:waypoint xsi:type="dc:Point" x="525" y="410" /> - <di:waypoint xsi:type="dc:Point" x="568" y="410" /> + <di:waypoint xsi:type="dc:Point" x="496" y="414" /> + <di:waypoint xsi:type="dc:Point" x="539" y="414" /> <bpmndi:BPMNLabel> - <dc:Bounds x="502" y="389" width="90" height="13" /> + <dc:Bounds x="473" y="393" width="90" height="13" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="SubProcess_0tv8zda_di" bpmnElement="SubProcess_0tv8zda" isExpanded="true"> - <dc:Bounds x="320" y="294" width="802" height="290" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="StartEvent_0tmcs9g_di" bpmnElement="StartEvent_0tmcs9g"> - <dc:Bounds x="340" y="392" width="36" height="36" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="223" y="428" width="90" height="12" /> - </bpmndi:BPMNLabel> + <dc:Bounds x="171" y="298" width="922" height="295" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_09synl9_di" bpmnElement="SequenceFlow_09synl9"> - <di:waypoint xsi:type="dc:Point" x="376" y="410" /> - <di:waypoint xsi:type="dc:Point" x="425" y="410" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="356" y="389" width="90" height="12" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="EndEvent_0mvmk3i_di" bpmnElement="EndEvent_0mvmk3i"> - <dc:Bounds x="575" y="491" width="36" height="36" /> + <dc:Bounds x="546" y="495" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="548" y="531" width="90" height="12" /> + <dc:Bounds x="519" y="535" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="EndEvent_1aww7yx_di" bpmnElement="EndEvent_1sez2lh"> - <dc:Bounds x="1039" y="392" width="36" height="36" /> + <dc:Bounds x="1010" y="396" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1049" y="432" width="19" height="13" /> + <dc:Bounds x="1020" y="436" width="20" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_16lmcxp_di" bpmnElement="SequenceFlow_16lmcxp"> @@ -319,27 +312,50 @@ <dc:Bounds x="906" y="140" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0541bid_di" bpmnElement="SequenceFlow_0541bid"> - <di:waypoint xsi:type="dc:Point" x="746" y="435" /> - <di:waypoint xsi:type="dc:Point" x="746" y="459" /> + <di:waypoint xsi:type="dc:Point" x="717" y="439" /> + <di:waypoint xsi:type="dc:Point" x="717" y="463" /> <bpmndi:BPMNLabel> - <dc:Bounds x="757" y="436" width="13" height="13" /> + <dc:Bounds x="728" y="440" width="13" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_12ps9at_di" bpmnElement="SequenceFlow_12ps9at"> - <di:waypoint xsi:type="dc:Point" x="796" y="499" /> - <di:waypoint xsi:type="dc:Point" x="868" y="499" /> + <di:waypoint xsi:type="dc:Point" x="767" y="503" /> + <di:waypoint xsi:type="dc:Point" x="839" y="503" /> <bpmndi:BPMNLabel> - <dc:Bounds x="787" y="478" width="90" height="12" /> + <dc:Bounds x="758" y="482" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="EndEvent_05vw85n_di" bpmnElement="EndEvent_0ex9298"> - <dc:Bounds x="868" y="481" width="36" height="36" /> + <dc:Bounds x="839" y="485" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="877" y="521" width="19" height="13" /> + <dc:Bounds x="848" y="525" width="20" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_11f2c91_di" bpmnElement="Task_QuerySecondaryPolicy"> - <dc:Bounds x="696" y="459" width="100" height="80" /> + <dc:Bounds x="667" y="463" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0vdeqxv_di" bpmnElement="SequenceFlow_0vdeqxv"> + <di:waypoint xsi:type="dc:Point" x="361" y="414" /> + <di:waypoint xsi:type="dc:Point" x="396" y="414" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="378.5" y="393" width="0" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="StartEvent_0tmcs9g_di" bpmnElement="StartEvent_0tmcs9g"> + <dc:Bounds x="196" y="396" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="79" y="432" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_09synl9_di" bpmnElement="SequenceFlow_09synl9"> + <di:waypoint xsi:type="dc:Point" x="232" y="414" /> + <di:waypoint xsi:type="dc:Point" x="261" y="414" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="201.5" y="393" width="90" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_10v49qn_di" bpmnElement="Task_UpdateExtErrorSource"> + <dc:Bounds x="261" y="374" width="100" height="80" /> </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/HomingBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/HomingBB.bpmn index b66ecfa329..11227ede4d 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/HomingBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/HomingBB.bpmn @@ -50,6 +50,7 @@ ex.processJavaException(execution)]]></bpmn2:script> <camunda:in source="asyncCorrelator" target="RCVWFMSG_correlator" /> <camunda:in source="asyncTimeout" target="RCVWFMSG_timeout" /> <camunda:out source="WorkflowResponse" target="asyncResponse" /> + <camunda:in source="mso-request-id" target="mso-request-id" /> </bpmn2:extensionElements> <bpmn2:incoming>SequenceFlow_0qrwjzu</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_03cy5y5</bpmn2:outgoing> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WorkflowActionBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WorkflowActionBB.bpmn index 35b77d9189..efdee8601e 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WorkflowActionBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/WorkflowActionBB.bpmn @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.7.2"> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="2.0.3"> <bpmn:process id="WorkflowActionBB" name="WorkflowActionBB" isExecutable="true"> <bpmn:startEvent id="Start_WorkflowActionBB" name="start"> <bpmn:outgoing>SequenceFlow_15s0okp</bpmn:outgoing> @@ -23,6 +23,9 @@ <camunda:out source="RetryDuration" target="RetryDuration" /> <camunda:in source="suppressRollback" target="suppressRollback" /> <camunda:out source="StatusMessage" target="StatusMessage" /> + <camunda:in source="isRollback" target="isRollback" /> + <camunda:in source="rollbackTargetState" target="rollbackTargetState" /> + <camunda:out source="rollbackTargetState" target="rollbackTargetState" /> </bpmn:extensionElements> <bpmn:incoming>SequenceFlow_0mew9im</bpmn:incoming> <bpmn:outgoing>SequenceFlow_1hsqed1</bpmn:outgoing> @@ -43,7 +46,7 @@ <bpmn:outgoing>SequenceFlow_0l7kaba</bpmn:outgoing> </bpmn:exclusiveGateway> <bpmn:sequenceFlow id="SequenceFlow_1m2eezj" name="Completed = true" sourceRef="ExclusiveGateway_Finished" targetRef="ExclusiveGateway_isTopLevelFlowC"> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("completed")==true&&execution.getVariable("isRollback")==false&&execution.getVariable("handlingCode")=="Success"}]]></bpmn:conditionExpression> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.getVariable("completed")==true&&execution.getVariable("isRollback")==false&&execution.getVariable("handlingCode")=="Success"}</bpmn:conditionExpression> </bpmn:sequenceFlow> <bpmn:serviceTask id="Task_RetrieveBBExectuionList" name="Retrieve BB Execution List" camunda:expression="${WorkflowAction.selectExecutionList(execution)}"> <bpmn:incoming>SequenceFlow_15s0okp</bpmn:incoming> @@ -80,7 +83,7 @@ </bpmn:exclusiveGateway> <bpmn:sequenceFlow id="SequenceFlow_024g0d1" name="no" sourceRef="ExclusiveGateway_10q79b6" targetRef="Task_UpdateDb" /> <bpmn:sequenceFlow id="SequenceFlow_0vi883o" name="yes" sourceRef="ExclusiveGateway_10q79b6" targetRef="Task_SendSyncAckError"> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("isTopLevelFlow")==true&&execution.getVariable("sentSyncResponse")==false}]]></bpmn:conditionExpression> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.getVariable("isTopLevelFlow")==true&&execution.getVariable("sentSyncResponse")==false}</bpmn:conditionExpression> </bpmn:sequenceFlow> <bpmn:sequenceFlow id="SequenceFlow_0eana0l" sourceRef="Task_SendSyncAckError" targetRef="Task_UpdateDb" /> <bpmn:serviceTask id="Task_SendSyncAckError" name="Send Sync Ack API Handler" camunda:asyncAfter="true" camunda:expression="${WorkflowActionBBTasks.sendSyncAck(execution)}"> @@ -89,10 +92,10 @@ </bpmn:serviceTask> </bpmn:subProcess> <bpmn:sequenceFlow id="SequenceFlow_0v588sm" name="Rollback = true" sourceRef="ExclusiveGateway_Finished" targetRef="Task_RollbackExecutionPath"> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("handlingCode")=="Rollback"||execution.getVariable("handlingCode")=="RollbackToAssigned"||execution.getVariable("handlingCode")=="RollbackToCreated"}]]></bpmn:conditionExpression> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.getVariable("handlingCode")=="Rollback"||execution.getVariable("handlingCode")=="RollbackToAssigned"||execution.getVariable("handlingCode")=="RollbackToCreated"}</bpmn:conditionExpression> </bpmn:sequenceFlow> <bpmn:sequenceFlow id="SequenceFlow_1atzsgn" sourceRef="Task_RollbackExecutionPath" targetRef="Task_SelectBB"> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("isRollbackNeeded")==true}]]></bpmn:conditionExpression> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.getVariable("isRollbackNeeded")==true}</bpmn:conditionExpression> </bpmn:sequenceFlow> <bpmn:serviceTask id="Task_RollbackExecutionPath" name="Rollback Execution Path" camunda:expression="${WorkflowActionBBTasks.rollbackExecutionPath(execution)}"> <bpmn:incoming>SequenceFlow_0v588sm</bpmn:incoming> @@ -101,7 +104,7 @@ </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_0vc9go9" sourceRef="Task_RetrieveBBExectuionList" targetRef="ExclusiveGateway_isTopLevelFlow" /> <bpmn:sequenceFlow id="SequenceFlow_11530ei" name="Abort = true" sourceRef="ExclusiveGateway_Finished" targetRef="ExclusiveGateway_isTopLevelFlowAbort"> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("handlingCode")=="Abort"}]]></bpmn:conditionExpression> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.getVariable("handlingCode")=="Abort"}</bpmn:conditionExpression> </bpmn:sequenceFlow> <bpmn:serviceTask id="Task_AbortAndCallErrorHandling" name="Update Request To Failed" camunda:expression="${WorkflowActionBBFailure.updateRequestStatusToFailed(execution)}"> <bpmn:incoming>SequenceFlow_02ksbt0</bpmn:incoming> @@ -125,7 +128,7 @@ </bpmn:exclusiveGateway> <bpmn:sequenceFlow id="SequenceFlow_0sckerv" name="yes" sourceRef="ExclusiveGateway_isTopLevelFlow" targetRef="Task_SendSync" /> <bpmn:sequenceFlow id="SequenceFlow_0unbew4" name="no" sourceRef="ExclusiveGateway_isTopLevelFlow" targetRef="Task_PreValidateWorkflow"> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("isTopLevelFlow")==false}]]></bpmn:conditionExpression> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.getVariable("isTopLevelFlow")==false}</bpmn:conditionExpression> </bpmn:sequenceFlow> <bpmn:exclusiveGateway id="ExclusiveGateway_isTopLevelFlowAbort" name="Is Top-Level Flow?" default="SequenceFlow_02ksbt0"> <bpmn:incoming>SequenceFlow_11530ei</bpmn:incoming> @@ -134,7 +137,7 @@ </bpmn:exclusiveGateway> <bpmn:sequenceFlow id="SequenceFlow_02ksbt0" name="yes" sourceRef="ExclusiveGateway_isTopLevelFlowAbort" targetRef="Task_AbortAndCallErrorHandling" /> <bpmn:sequenceFlow id="SequenceFlow_1r570x3" name="no" sourceRef="ExclusiveGateway_isTopLevelFlowAbort" targetRef="EndEvent_0lzz1ya"> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("isTopLevelFlow")==false}]]></bpmn:conditionExpression> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.getVariable("isTopLevelFlow")==false}</bpmn:conditionExpression> </bpmn:sequenceFlow> <bpmn:exclusiveGateway id="ExclusiveGateway_isTopLevelFlowC" name="Is Top-Level Flow?" default="SequenceFlow_0kf5sen"> <bpmn:incoming>SequenceFlow_1m2eezj</bpmn:incoming> @@ -142,13 +145,13 @@ <bpmn:outgoing>SequenceFlow_0kf5sen</bpmn:outgoing> </bpmn:exclusiveGateway> <bpmn:sequenceFlow id="SequenceFlow_0x4urgp" name="no" sourceRef="ExclusiveGateway_isTopLevelFlowC" targetRef="End_WorkflowActionBB"> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("isTopLevelFlow")==false}]]></bpmn:conditionExpression> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.getVariable("isTopLevelFlow")==false}</bpmn:conditionExpression> </bpmn:sequenceFlow> <bpmn:endEvent id="End_RollbackFailed" name="end"> <bpmn:incoming>SequenceFlow_1ui67mc</bpmn:incoming> </bpmn:endEvent> <bpmn:sequenceFlow id="SequenceFlow_11dlyzt" name="Rollback Not Needed" sourceRef="Task_RollbackExecutionPath" targetRef="Task_UpdateRequestToFailed"> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("isRollbackNeeded")==false}]]></bpmn:conditionExpression> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.getVariable("isRollbackNeeded")==false}</bpmn:conditionExpression> </bpmn:sequenceFlow> <bpmn:serviceTask id="Task_UpdateRequestToFailed" name="Update Request To Failed" camunda:expression="${WorkflowActionBBFailure.updateRequestStatusToFailedWithRollback(execution)}"> <bpmn:incoming>SequenceFlow_11dlyzt</bpmn:incoming> @@ -156,7 +159,7 @@ <bpmn:outgoing>SequenceFlow_1ui67mc</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_0l7kaba" name="Rollback Completed" sourceRef="ExclusiveGateway_Finished" targetRef="Task_UpdateRequestToFailed"> - <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("completed")==true&&execution.getVariable("isRollback")==true&&execution.getVariable("handlingCode")=="Success"}]]></bpmn:conditionExpression> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${execution.getVariable("completed")==true&&execution.getVariable("isRollback")==true&&execution.getVariable("handlingCode")=="Success"}</bpmn:conditionExpression> </bpmn:sequenceFlow> <bpmn:sequenceFlow id="SequenceFlow_1ui67mc" sourceRef="Task_UpdateRequestToFailed" targetRef="End_RollbackFailed" /> <bpmn:subProcess id="SubProcess_0fuugr9" name="Java Exception Handling Sub Process" triggeredByEvent="true"> @@ -210,8 +213,8 @@ </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_15s0okp_di" bpmnElement="SequenceFlow_15s0okp"> - <di:waypoint xsi:type="dc:Point" x="-398" y="120" /> - <di:waypoint xsi:type="dc:Point" x="-365" y="120" /> + <di:waypoint x="-398" y="120" /> + <di:waypoint x="-365" y="120" /> <bpmndi:BPMNLabel> <dc:Bounds x="-381" y="99" width="0" height="0" /> </bpmndi:BPMNLabel> @@ -220,8 +223,8 @@ <dc:Bounds x="560" y="80" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0mqrkxv_di" bpmnElement="SequenceFlow_0mqrkxv"> - <di:waypoint xsi:type="dc:Point" x="339" y="120" /> - <di:waypoint xsi:type="dc:Point" x="400" y="120" /> + <di:waypoint x="339" y="120" /> + <di:waypoint x="400" y="120" /> <bpmndi:BPMNLabel> <dc:Bounds x="324.5" y="105" width="90" height="0" /> </bpmndi:BPMNLabel> @@ -236,9 +239,9 @@ </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1m2eezj_di" bpmnElement="SequenceFlow_1m2eezj"> - <di:waypoint xsi:type="dc:Point" x="949" y="132" /> - <di:waypoint xsi:type="dc:Point" x="980" y="165" /> - <di:waypoint xsi:type="dc:Point" x="1060" y="165" /> + <di:waypoint x="949" y="132" /> + <di:waypoint x="980" y="165" /> + <di:waypoint x="1060" y="165" /> <bpmndi:BPMNLabel> <dc:Bounds x="968" y="168" width="83" height="12" /> </bpmndi:BPMNLabel> @@ -253,9 +256,9 @@ <dc:Bounds x="1161" y="206" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1pz6edz_di" bpmnElement="SequenceFlow_1pz6edz"> - <di:waypoint xsi:type="dc:Point" x="1261" y="246" /> - <di:waypoint xsi:type="dc:Point" x="1322" y="246" /> - <di:waypoint xsi:type="dc:Point" x="1322" y="183" /> + <di:waypoint x="1261" y="246" /> + <di:waypoint x="1322" y="246" /> + <di:waypoint x="1322" y="183" /> <bpmndi:BPMNLabel> <dc:Bounds x="1247" y="231" width="90" height="0" /> </bpmndi:BPMNLabel> @@ -276,16 +279,16 @@ </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0v588sm_di" bpmnElement="SequenceFlow_0v588sm"> - <di:waypoint xsi:type="dc:Point" x="936" y="145" /> - <di:waypoint xsi:type="dc:Point" x="936" y="262" /> - <di:waypoint xsi:type="dc:Point" x="339" y="262" /> + <di:waypoint x="936" y="145" /> + <di:waypoint x="936" y="262" /> + <di:waypoint x="339" y="262" /> <bpmndi:BPMNLabel> <dc:Bounds x="769.202380952381" y="272" width="73" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1atzsgn_di" bpmnElement="SequenceFlow_1atzsgn"> - <di:waypoint xsi:type="dc:Point" x="289" y="222" /> - <di:waypoint xsi:type="dc:Point" x="289" y="160" /> + <di:waypoint x="289" y="222" /> + <di:waypoint x="289" y="160" /> <bpmndi:BPMNLabel> <dc:Bounds x="259" y="191" width="90" height="0" /> </bpmndi:BPMNLabel> @@ -294,16 +297,16 @@ <dc:Bounds x="239" y="222" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0vc9go9_di" bpmnElement="SequenceFlow_0vc9go9"> - <di:waypoint xsi:type="dc:Point" x="-265" y="120" /> - <di:waypoint xsi:type="dc:Point" x="-228" y="120" /> + <di:waypoint x="-265" y="120" /> + <di:waypoint x="-228" y="120" /> <bpmndi:BPMNLabel> <dc:Bounds x="-246" y="105" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_11530ei_di" bpmnElement="SequenceFlow_11530ei"> - <di:waypoint xsi:type="dc:Point" x="946" y="105" /> - <di:waypoint xsi:type="dc:Point" x="983" y="44" /> - <di:waypoint xsi:type="dc:Point" x="1060" y="45" /> + <di:waypoint x="946" y="105" /> + <di:waypoint x="983" y="44" /> + <di:waypoint x="1060" y="45" /> <bpmndi:BPMNLabel> <dc:Bounds x="975" y="17" width="58" height="12" /> </bpmndi:BPMNLabel> @@ -318,28 +321,28 @@ </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1p8yxu6_di" bpmnElement="SequenceFlow_1p8yxu6"> - <di:waypoint xsi:type="dc:Point" x="1276" y="-36" /> - <di:waypoint xsi:type="dc:Point" x="1359" y="-36" /> - <di:waypoint xsi:type="dc:Point" x="1359" y="45" /> - <di:waypoint xsi:type="dc:Point" x="1386" y="45" /> + <di:waypoint x="1276" y="-36" /> + <di:waypoint x="1359" y="-36" /> + <di:waypoint x="1359" y="45" /> + <di:waypoint x="1386" y="45" /> <bpmndi:BPMNLabel> <dc:Bounds x="1329" y="5" width="90" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1wb59ic_di" bpmnElement="SequenceFlow_1wb59ic"> - <di:waypoint xsi:type="dc:Point" x="-32" y="34" /> - <di:waypoint xsi:type="dc:Point" x="32" y="34" /> - <di:waypoint xsi:type="dc:Point" x="32" y="120" /> - <di:waypoint xsi:type="dc:Point" x="80" y="120" /> + <di:waypoint x="-32" y="34" /> + <di:waypoint x="32" y="34" /> + <di:waypoint x="32" y="120" /> + <di:waypoint x="80" y="120" /> <bpmndi:BPMNLabel> <dc:Bounds x="47" y="77" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_01j184u_di" bpmnElement="SequenceFlow_01j184u"> - <di:waypoint xsi:type="dc:Point" x="936" y="95" /> - <di:waypoint xsi:type="dc:Point" x="936" y="55" /> - <di:waypoint xsi:type="dc:Point" x="936" y="55" /> - <di:waypoint xsi:type="dc:Point" x="936" y="4" /> + <di:waypoint x="936" y="95" /> + <di:waypoint x="936" y="55" /> + <di:waypoint x="936" y="55" /> + <di:waypoint x="936" y="4" /> <bpmndi:BPMNLabel> <dc:Bounds x="906" y="49" width="90" height="0" /> </bpmndi:BPMNLabel> @@ -354,16 +357,16 @@ </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0sckerv_di" bpmnElement="SequenceFlow_0sckerv"> - <di:waypoint xsi:type="dc:Point" x="-202" y="96" /> - <di:waypoint xsi:type="dc:Point" x="-202" y="34" /> - <di:waypoint xsi:type="dc:Point" x="-132" y="34" /> + <di:waypoint x="-202" y="96" /> + <di:waypoint x="-202" y="34" /> + <di:waypoint x="-132" y="34" /> <bpmndi:BPMNLabel> <dc:Bounds x="-195" y="55.55555555555556" width="18" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0unbew4_di" bpmnElement="SequenceFlow_0unbew4"> - <di:waypoint xsi:type="dc:Point" x="-178" y="120" /> - <di:waypoint xsi:type="dc:Point" x="80" y="120" /> + <di:waypoint x="-178" y="120" /> + <di:waypoint x="80" y="120" /> <bpmndi:BPMNLabel> <dc:Bounds x="-87" y="99.95468180757382" width="12" height="12" /> </bpmndi:BPMNLabel> @@ -375,16 +378,16 @@ </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_02ksbt0_di" bpmnElement="SequenceFlow_02ksbt0"> - <di:waypoint xsi:type="dc:Point" x="1085" y="20" /> - <di:waypoint xsi:type="dc:Point" x="1085" y="-37" /> - <di:waypoint xsi:type="dc:Point" x="1176" y="-37" /> + <di:waypoint x="1085" y="20" /> + <di:waypoint x="1085" y="-37" /> + <di:waypoint x="1176" y="-37" /> <bpmndi:BPMNLabel> <dc:Bounds x="1091" y="-8" width="19" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1r570x3_di" bpmnElement="SequenceFlow_1r570x3"> - <di:waypoint xsi:type="dc:Point" x="1110" y="45" /> - <di:waypoint xsi:type="dc:Point" x="1386" y="45" /> + <di:waypoint x="1110" y="45" /> + <di:waypoint x="1386" y="45" /> <bpmndi:BPMNLabel> <dc:Bounds x="1242" y="20" width="12" height="12" /> </bpmndi:BPMNLabel> @@ -396,10 +399,10 @@ </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0x4urgp_di" bpmnElement="SequenceFlow_0x4urgp"> - <di:waypoint xsi:type="dc:Point" x="1110" y="165" /> - <di:waypoint xsi:type="dc:Point" x="1220" y="165" /> - <di:waypoint xsi:type="dc:Point" x="1220" y="165" /> - <di:waypoint xsi:type="dc:Point" x="1304" y="165" /> + <di:waypoint x="1110" y="165" /> + <di:waypoint x="1220" y="165" /> + <di:waypoint x="1220" y="165" /> + <di:waypoint x="1304" y="165" /> <bpmndi:BPMNLabel> <dc:Bounds x="1256" y="140" width="12" height="12" /> </bpmndi:BPMNLabel> @@ -411,9 +414,9 @@ </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_11dlyzt_di" bpmnElement="SequenceFlow_11dlyzt"> - <di:waypoint xsi:type="dc:Point" x="289" y="302" /> - <di:waypoint xsi:type="dc:Point" x="289" y="368" /> - <di:waypoint xsi:type="dc:Point" x="960" y="368" /> + <di:waypoint x="289" y="302" /> + <di:waypoint x="289" y="368" /> + <di:waypoint x="960" y="368" /> <bpmndi:BPMNLabel> <dc:Bounds x="381.45685840707966" y="325" width="63" height="24" /> </bpmndi:BPMNLabel> @@ -425,33 +428,33 @@ <dc:Bounds x="960" y="325" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0l7kaba_di" bpmnElement="SequenceFlow_0l7kaba"> - <di:waypoint xsi:type="dc:Point" x="942" y="139" /> - <di:waypoint xsi:type="dc:Point" x="976" y="252" /> - <di:waypoint xsi:type="dc:Point" x="1016" y="252" /> - <di:waypoint xsi:type="dc:Point" x="1016" y="325" /> + <di:waypoint x="942" y="139" /> + <di:waypoint x="976" y="252" /> + <di:waypoint x="1016" y="252" /> + <di:waypoint x="1016" y="325" /> <bpmndi:BPMNLabel> <dc:Bounds x="959" y="255" width="52" height="24" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1edjl5x_di" bpmnElement="SequenceFlow_1edjl5x"> - <di:waypoint xsi:type="dc:Point" x="556" y="657" /> - <di:waypoint xsi:type="dc:Point" x="602" y="657" /> + <di:waypoint x="556" y="657" /> + <di:waypoint x="602" y="657" /> <bpmndi:BPMNLabel> <dc:Bounds x="534" y="636" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0wvzfgf_di" bpmnElement="SequenceFlow_0wvzfgf"> - <di:waypoint xsi:type="dc:Point" x="813" y="657" /> - <di:waypoint xsi:type="dc:Point" x="880" y="657" /> + <di:waypoint x="813" y="657" /> + <di:waypoint x="880" y="657" /> <bpmndi:BPMNLabel> <dc:Bounds x="801.5" y="636" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1ui67mc_di" bpmnElement="SequenceFlow_1ui67mc"> - <di:waypoint xsi:type="dc:Point" x="1060" y="365" /> - <di:waypoint xsi:type="dc:Point" x="1134" y="365" /> - <di:waypoint xsi:type="dc:Point" x="1134" y="365" /> - <di:waypoint xsi:type="dc:Point" x="1159" y="365" /> + <di:waypoint x="1060" y="365" /> + <di:waypoint x="1134" y="365" /> + <di:waypoint x="1134" y="365" /> + <di:waypoint x="1159" y="365" /> <bpmndi:BPMNLabel> <dc:Bounds x="1104" y="359" width="90" height="13" /> </bpmndi:BPMNLabel> @@ -463,25 +466,25 @@ </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_024g0d1_di" bpmnElement="SequenceFlow_024g0d1"> - <di:waypoint xsi:type="dc:Point" x="652" y="657" /> - <di:waypoint xsi:type="dc:Point" x="683" y="657" /> - <di:waypoint xsi:type="dc:Point" x="683" y="657" /> - <di:waypoint xsi:type="dc:Point" x="713" y="657" /> + <di:waypoint x="652" y="657" /> + <di:waypoint x="683" y="657" /> + <di:waypoint x="683" y="657" /> + <di:waypoint x="713" y="657" /> <bpmndi:BPMNLabel> <dc:Bounds x="677" y="634" width="12" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0vi883o_di" bpmnElement="SequenceFlow_0vi883o"> - <di:waypoint xsi:type="dc:Point" x="627" y="632" /> - <di:waypoint xsi:type="dc:Point" x="627" y="548" /> - <di:waypoint xsi:type="dc:Point" x="713" y="548" /> + <di:waypoint x="627" y="632" /> + <di:waypoint x="627" y="548" /> + <di:waypoint x="713" y="548" /> <bpmndi:BPMNLabel> <dc:Bounds x="633" y="584" width="18" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0eana0l_di" bpmnElement="SequenceFlow_0eana0l"> - <di:waypoint xsi:type="dc:Point" x="763" y="588" /> - <di:waypoint xsi:type="dc:Point" x="763" y="617" /> + <di:waypoint x="763" y="588" /> + <di:waypoint x="763" y="617" /> <bpmndi:BPMNLabel> <dc:Bounds x="778" y="596.5" width="0" height="12" /> </bpmndi:BPMNLabel> @@ -508,15 +511,15 @@ </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_11d126w_di" bpmnElement="SequenceFlow_11d126w"> - <di:waypoint xsi:type="dc:Point" x="606" y="875" /> - <di:waypoint xsi:type="dc:Point" x="690" y="875" /> + <di:waypoint x="606" y="875" /> + <di:waypoint x="690" y="875" /> <bpmndi:BPMNLabel> <dc:Bounds x="603" y="854" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0w4sx88_di" bpmnElement="SequenceFlow_0w4sx88"> - <di:waypoint xsi:type="dc:Point" x="790" y="875" /> - <di:waypoint xsi:type="dc:Point" x="856" y="875" /> + <di:waypoint x="790" y="875" /> + <di:waypoint x="856" y="875" /> <bpmndi:BPMNLabel> <dc:Bounds x="778" y="854" width="0" height="12" /> </bpmndi:BPMNLabel> @@ -525,25 +528,25 @@ <dc:Bounds x="400" y="80" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0mew9im_di" bpmnElement="SequenceFlow_0mew9im"> - <di:waypoint xsi:type="dc:Point" x="500" y="120" /> - <di:waypoint xsi:type="dc:Point" x="560" y="120" /> + <di:waypoint x="500" y="120" /> + <di:waypoint x="560" y="120" /> <bpmndi:BPMNLabel> <dc:Bounds x="530" y="99" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0kf5sen_di" bpmnElement="SequenceFlow_0kf5sen"> - <di:waypoint xsi:type="dc:Point" x="1085" y="190" /> - <di:waypoint xsi:type="dc:Point" x="1085" y="246" /> - <di:waypoint xsi:type="dc:Point" x="1161" y="246" /> + <di:waypoint x="1085" y="190" /> + <di:waypoint x="1085" y="246" /> + <di:waypoint x="1161" y="246" /> <bpmndi:BPMNLabel> <dc:Bounds x="1091" y="218" width="19" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1tfizxf_di" bpmnElement="SequenceFlow_1tfizxf"> - <di:waypoint xsi:type="dc:Point" x="180" y="120" /> - <di:waypoint xsi:type="dc:Point" x="211" y="120" /> - <di:waypoint xsi:type="dc:Point" x="211" y="120" /> - <di:waypoint xsi:type="dc:Point" x="239" y="120" /> + <di:waypoint x="180" y="120" /> + <di:waypoint x="211" y="120" /> + <di:waypoint x="211" y="120" /> + <di:waypoint x="239" y="120" /> <bpmndi:BPMNLabel> <dc:Bounds x="226" y="120" width="0" height="0" /> </bpmndi:BPMNLabel> @@ -555,23 +558,23 @@ <dc:Bounds x="735" y="80" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1hsqed1_di" bpmnElement="SequenceFlow_1hsqed1"> - <di:waypoint xsi:type="dc:Point" x="660" y="120" /> - <di:waypoint xsi:type="dc:Point" x="735" y="120" /> + <di:waypoint x="660" y="120" /> + <di:waypoint x="735" y="120" /> <bpmndi:BPMNLabel> <dc:Bounds x="697.5" y="99" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1fftixk_di" bpmnElement="SequenceFlow_1fftixk"> - <di:waypoint xsi:type="dc:Point" x="835" y="120" /> - <di:waypoint xsi:type="dc:Point" x="911" y="120" /> + <di:waypoint x="835" y="120" /> + <di:waypoint x="911" y="120" /> <bpmndi:BPMNLabel> <dc:Bounds x="873" y="99" width="0" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1pnkpim_di" bpmnElement="SequenceFlow_1pnkpim"> - <di:waypoint xsi:type="dc:Point" x="886" y="-36" /> - <di:waypoint xsi:type="dc:Point" x="289" y="-36" /> - <di:waypoint xsi:type="dc:Point" x="289" y="80" /> + <di:waypoint x="886" y="-36" /> + <di:waypoint x="289" y="-36" /> + <di:waypoint x="289" y="80" /> <bpmndi:BPMNLabel> <dc:Bounds x="587.5" y="-57" width="0" height="12" /> </bpmndi:BPMNLabel> diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/SniroHomingV2.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/SniroHomingV2.java index e5df3d3f35..f1fd23fe82 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/SniroHomingV2.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/SniroHomingV2.java @@ -65,6 +65,7 @@ import org.onap.so.client.sniro.beans.ServiceInfo; import org.onap.so.client.sniro.beans.SniroManagerRequest; import org.onap.so.client.sniro.beans.SubscriberInfo; import org.onap.so.db.catalog.beans.OrchestrationStatus; +import org.onap.so.utils.TargetEntity; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -160,14 +161,15 @@ public class SniroHomingV2 { logger.trace("Completed Sniro Homing Call Sniro"); } catch (BpmnError e) { logger.error(EXCEPTION_OCCURRED, e); - exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(e.getErrorCode()), e.getMessage()); + exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(e.getErrorCode()), e.getMessage(), + TargetEntity.SNIRO); } catch (BadResponseException e) { logger.error(EXCEPTION_OCCURRED, e); - exceptionUtil.buildAndThrowWorkflowException(execution, 400, e.getMessage()); + exceptionUtil.buildAndThrowWorkflowException(execution, 400, e.getMessage(), TargetEntity.SNIRO); } catch (Exception e) { logger.error(EXCEPTION_OCCURRED, e); exceptionUtil.buildAndThrowWorkflowException(execution, INTERNAL, - "Internal Error - occurred while preparing sniro request: " + e.getMessage()); + "Internal Error - occurred while preparing sniro request: " + e.getMessage(), TargetEntity.SO); } } @@ -211,14 +213,16 @@ public class SniroHomingV2 { logger.trace("Completed Sniro Homing Process Solution"); } catch (BpmnError e) { logger.error(EXCEPTION_OCCURRED, e); - exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(e.getErrorCode()), e.getMessage()); + exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(e.getErrorCode()), e.getMessage(), + TargetEntity.SNIRO); } catch (BadResponseException e) { logger.error(EXCEPTION_OCCURRED, e); - exceptionUtil.buildAndThrowWorkflowException(execution, 400, e.getMessage()); + exceptionUtil.buildAndThrowWorkflowException(execution, 400, e.getMessage(), TargetEntity.SNIRO); } catch (Exception e) { logger.error(EXCEPTION_OCCURRED, e); exceptionUtil.buildAndThrowWorkflowException(execution, INTERNAL, - "Internal Error - occurred while processing sniro asynchronous response: " + e.getMessage()); + "Internal Error - occurred while processing sniro asynchronous response: " + e.getMessage(), + TargetEntity.SO); } } 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 index 859db11037..e9d33f46ab 100644 --- 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 @@ -38,6 +38,7 @@ import org.onap.so.adapters.nwrest.UpdateNetworkRequest; import org.onap.so.adapters.nwrest.UpdateNetworkResponse; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.client.orchestration.NetworkAdapterResources; +import org.onap.so.utils.TargetEntity; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -93,7 +94,7 @@ public class NetworkAdapterRestV1 { throw new Exception("No Network Request was created. networkAdapterRequest was null."); } } catch (Exception ex) { - exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, ex); + exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, ex, TargetEntity.SO); } } @@ -138,7 +139,7 @@ public class NetworkAdapterRestV1 { } } catch (Exception e) { logger.error("Error in Openstack Adapter callback", e); - exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, e.getMessage()); + exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, e.getMessage(), TargetEntity.OPENSTACK); } } @@ -151,7 +152,7 @@ public class NetworkAdapterRestV1 { public void handleTimeOutException(DelegateExecution execution) { exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, - "Error timed out waiting on Openstack Async-Response"); + "Error timed out waiting on Openstack Async-Response", TargetEntity.SO); } public void handleSyncError(DelegateExecution execution) { @@ -159,6 +160,6 @@ public class NetworkAdapterRestV1 { 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); + exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, errorMessage, TargetEntity.OPENSTACK); } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCQueryTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCQueryTasks.java index fcc67d0ef7..9bbe94a077 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCQueryTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCQueryTasks.java @@ -29,8 +29,10 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; import org.onap.so.client.exception.BBObjectNotFoundException; +import org.onap.so.client.exception.BadResponseException; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.client.orchestration.SDNCVnfResources; +import org.onap.so.utils.TargetEntity; import org.onap.so.client.orchestration.SDNCVfModuleResources; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -39,7 +41,8 @@ import org.springframework.stereotype.Component; @Component public class SDNCQueryTasks { - + private static final Logger logger = LoggerFactory.getLogger(SDNCQueryTasks.class); + private static final String NO_RESPONSE_FROM_SDNC = "Error did not receive a response from SDNC."; public static final String SDNCQUERY_RESPONSE = "SDNCQueryResponse_"; @Autowired private SDNCVnfResources sdncVnfResources; @@ -63,8 +66,14 @@ public class SDNCQueryTasks { } String response = sdncVnfResources.queryVnf(genericVnf); execution.setVariable(SDNCQUERY_RESPONSE + genericVnf.getVnfId(), response); + } catch (BadResponseException ex) { + if (!ex.getMessage().equals(NO_RESPONSE_FROM_SDNC)) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex, TargetEntity.SDNC); + } else { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex, TargetEntity.SO); + } } catch (Exception ex) { - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex, TargetEntity.SO); } } @@ -88,6 +97,12 @@ public class SDNCQueryTasks { throw new Exception("Vf Module " + vfModule.getVfModuleId() + " exists in gBuildingBlock but does not have a selflink value"); } + } catch (BadResponseException ex) { + if (!ex.getMessage().equals(NO_RESPONSE_FROM_SDNC)) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex, TargetEntity.SDNC); + } else { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex, TargetEntity.SO); + } } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } @@ -109,10 +124,16 @@ public class SDNCQueryTasks { // If we see a bb object not found exception for something that is not a vf module id, then we should throw // the error as normal if (!ResourceKey.VF_MODULE_ID.equals(bbException.getResourceKey())) { - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, bbException); + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, bbException, TargetEntity.SO); + } + } catch (BadResponseException ex) { + if (!ex.getMessage().equals(NO_RESPONSE_FROM_SDNC)) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex, TargetEntity.SDNC); + } else { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex, TargetEntity.SO); } } catch (Exception ex) { - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex, TargetEntity.SO); } } } 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 cb761f4110..03714db943 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 @@ -37,6 +37,7 @@ import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.client.exception.MapperException; import org.onap.so.client.sdnc.SDNCClient; import org.onap.so.client.sdnc.beans.SDNCRequest; +import org.onap.so.utils.TargetEntity; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -79,17 +80,19 @@ public class SDNCRequestTasks { } catch (PathNotFoundException e) { 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."); + "Recieved invalid response from SDNC, unable to read message content.", TargetEntity.SO); } catch (MapperException e) { 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."); + "Failed to map SDNC object to JSON prior to POST.", TargetEntity.SO); } catch (BadResponseException e) { logger.error("Did not receive a successful response from SDNC.", e); - exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, e.getLocalizedMessage()); + exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, e.getLocalizedMessage(), + TargetEntity.SDNC); } catch (HttpClientErrorException e) { logger.error("HttpClientErrorException: 404 Not Found, Failed to contact SDNC", e); - exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, "SDNC cannot be contacted."); + exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, "SDNC cannot be contacted.", + TargetEntity.SO); } } @@ -120,16 +123,17 @@ public class SDNCRequestTasks { } } catch (SDNCErrorResponseException e) { logger.error("SDNC error response - " + e.getMessage()); - exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, e.getMessage()); + exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, e.getMessage(), TargetEntity.SDNC); } catch (Exception e) { - logger.error("Error procesing SDNC callback", e); - exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, "Error procesing SDNC callback"); + logger.error("Error processing SDNC callback", e); + exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, "Error processing SDNC callback", + TargetEntity.SO); } } public void handleTimeOutException(DelegateExecution execution) { exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, - "Error timed out waiting on SDNC Async-Response"); + "Error timed out waiting on SDNC Async-Response", TargetEntity.SO); } protected boolean convertIndicatorToBoolean(String finalMessageIndicator) { @@ -149,5 +153,4 @@ public class SDNCRequestTasks { } return result; } - } 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 4d2f9fd98c..2d3f5de616 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 @@ -26,6 +26,7 @@ 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.constants.Status; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.client.RequestsDbClient; import org.slf4j.Logger; @@ -37,6 +38,7 @@ import org.springframework.stereotype.Component; public class WorkflowActionBBFailure { private static final Logger logger = LoggerFactory.getLogger(WorkflowActionBBFailure.class); + public static final String ROLLBACK_TARGET_STATE = "rollbackTargetState"; @Autowired private RequestsDbClient requestDbclient; @Autowired @@ -53,7 +55,12 @@ public class WorkflowActionBBFailure { } else { errorMsg = "Failed to determine error message"; } - request.setStatusMessage(errorMsg); + Boolean isRollback = (Boolean) execution.getVariable("isRollback"); + if (!Boolean.TRUE.equals(isRollback)) { + request.setStatusMessage(errorMsg); + } else { + request.setRollbackStatusMessage(errorMsg); + } request.setProgress(Long.valueOf(100)); request.setLastModifiedBy("CamundaBPMN"); request.setEndTime(new Timestamp(System.currentTimeMillis())); @@ -84,6 +91,8 @@ public class WorkflowActionBBFailure { rollbackErrorMsg = "Rollback has been completed successfully."; request.setRollbackStatusMessage(rollbackErrorMsg); execution.setVariable("RollbackErrorMessage", rollbackErrorMsg); + String rollbackTargetState = (String) execution.getVariable(ROLLBACK_TARGET_STATE); + request.setRequestStatus(rollbackTargetState); } else if (isRollbackFailure) { Optional<String> rollbackErrorMsgOp = retrieveErrorMessage(execution); if (rollbackErrorMsgOp.isPresent()) { @@ -93,6 +102,7 @@ public class WorkflowActionBBFailure { } request.setRollbackStatusMessage(rollbackErrorMsg); execution.setVariable("RollbackErrorMessage", rollbackErrorMsg); + request.setRequestStatus(Status.FAILED.toString()); } else { Optional<String> errorMsgOp = retrieveErrorMessage(execution); if (errorMsgOp.isPresent()) { @@ -102,6 +112,12 @@ public class WorkflowActionBBFailure { } request.setStatusMessage(errorMsg); execution.setVariable("ErrorMessage", errorMsg); + String handlingCode = (String) execution.getVariable("handlingCode"); + if ("Abort".equalsIgnoreCase(handlingCode)) { + request.setRequestStatus(Status.ABORTED.toString()); + } else { + request.setRequestStatus(Status.FAILED.toString()); + } } if (ebb != null && ebb.getBuildingBlock() != null) { String flowStatus = ""; @@ -115,7 +131,6 @@ public class WorkflowActionBBFailure { } request.setProgress(Long.valueOf(100)); - request.setRequestStatus("FAILED"); request.setLastModifiedBy("CamundaBPMN"); request.setEndTime(new Timestamp(System.currentTimeMillis())); requestDbclient.updateInfraActiveRequests(request); 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 44152fcaf4..a17556f091 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 @@ -312,7 +312,6 @@ public class WorkflowActionBBTasks { } workflowActionBBFailure.updateRequestErrorStatusMessage(execution); - if (rollbackFlows.isEmpty()) execution.setVariable("isRollbackNeeded", false); else diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1Test.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1Test.java index d0cee42178..8aea2d2650 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1Test.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1Test.java @@ -39,12 +39,14 @@ import org.onap.so.bpmn.BaseTaskTest; import org.onap.so.client.exception.BadResponseException; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.client.exception.MapperException; +import org.onap.so.utils.TargetEntity; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.eq; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertThat; +import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -110,8 +112,9 @@ public class NetworkAdapterRestV1Test extends BaseTaskTest { delegateExecution.setVariable("networkAdapterRequest", updateNetworkRequest); delegateExecution.setVariable("NetworkAResponse_MESSAGE", updateNetworkResponse.toXmlString()); - doThrow(new BpmnError("MSOWorkflowException")).when(exceptionBuilder) - .buildAndThrowWorkflowException(any(DelegateExecution.class), anyInt(), any(String.class)); + doThrow(new BpmnError("MSOWorkflowException")).when(exceptionBuilder).buildAndThrowWorkflowException( + any(DelegateExecution.class), anyInt(), any(String.class), any(TargetEntity.class)); + try { networkAdapterRestV1Tasks.processCallback(delegateExecution); } catch (BpmnError be) { @@ -119,6 +122,6 @@ public class NetworkAdapterRestV1Test extends BaseTaskTest { } assertNull(delegateExecution.getVariable("updateNetworkResponse")); verify(exceptionBuilder, times(1)).buildAndThrowWorkflowException(any(DelegateExecution.class), eq(7000), - eq("test error message")); + eq("test error message"), eq(TargetEntity.OPENSTACK)); } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCQueryTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCQueryTasksTest.java index 3ea8474b24..0ba9237aaf 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCQueryTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCQueryTasksTest.java @@ -43,6 +43,9 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.client.exception.BBObjectNotFoundException; +import org.onap.so.client.exception.BadResponseException; +import org.onap.so.utils.TargetEntities; +import org.onap.so.utils.TargetEntity; public class SDNCQueryTasksTest extends BaseTaskTest { @InjectMocks @@ -61,8 +64,8 @@ public class SDNCQueryTasksTest extends BaseTaskTest { genericVnf = setGenericVnf(); vfModule = setVfModule(); - doThrow(new BpmnError("BPMN Error")).when(exceptionUtil) - .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class)); + doThrow(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException( + any(BuildingBlockExecution.class), eq(7000), any(Exception.class), any(TargetEntities.class)); when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID))) .thenReturn(serviceInstance); @@ -88,6 +91,28 @@ public class SDNCQueryTasksTest extends BaseTaskTest { } @Test + public void queryVfModuleBadResponseExceptionTest() throws Exception { + BadResponseException exception = new BadResponseException("Error received from SDNC"); + doThrow(exception).when(sdncVfModuleResources).queryVfModule(vfModule); + + expectedException.expect(BpmnError.class); + sdncQueryTasks.queryVfModule(execution); + + verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(execution, 700, exception, TargetEntity.SDNC); + } + + @Test + public void queryVfModuleResponseExceptionNoResponseTest() throws Exception { + BadResponseException exception = new BadResponseException("Error did not receive a response from SDNC."); + doThrow(exception).when(sdncVfModuleResources).queryVfModule(vfModule); + + expectedException.expect(BpmnError.class); + sdncQueryTasks.queryVfModule(execution); + + verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(execution, 700, exception, TargetEntity.SO); + } + + @Test public void queryVnfTest() throws Exception { String sdncQueryResponse = "response"; @@ -101,6 +126,28 @@ public class SDNCQueryTasksTest extends BaseTaskTest { } @Test + public void queryVnfBadResponseExceptionTest() throws Exception { + BadResponseException exception = new BadResponseException("Error received from SDNC"); + doThrow(exception).when(sdncVnfResources).queryVnf(genericVnf); + + expectedException.expect(BpmnError.class); + sdncQueryTasks.queryVnf(execution); + + verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(execution, 700, exception, TargetEntity.SDNC); + } + + @Test + public void queryVnfBadResponseExceptionNoResponseTest() throws Exception { + BadResponseException exception = new BadResponseException("Error did not receive a response from SDNC."); + doThrow(exception).when(sdncVnfResources).queryVnf(genericVnf); + + expectedException.expect(BpmnError.class); + sdncQueryTasks.queryVnf(execution); + + verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(execution, 700, exception, TargetEntity.SO); + } + + @Test public void queryVfModuleForVolumeGroupTest() throws Exception { String sdncQueryResponse = "response"; vfModule.setSelflink("vfModuleSelfLink"); @@ -115,6 +162,28 @@ public class SDNCQueryTasksTest extends BaseTaskTest { } @Test + public void queryVfModuleForVolumeGroupBadResponseExceptionTest() throws Exception { + BadResponseException exception = new BadResponseException("Error received from SDNC"); + doThrow(exception).when(sdncVfModuleResources).queryVfModule(vfModule); + + expectedException.expect(BpmnError.class); + sdncQueryTasks.queryVfModuleForVolumeGroup(execution); + + verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(execution, 700, exception, TargetEntity.SDNC); + } + + @Test + public void queryVfModuleForVolumeGroupBadResponseExceptionNoResponseTest() throws Exception { + BadResponseException exception = new BadResponseException("Error did not receive a response from SDNC."); + doThrow(exception).when(sdncVfModuleResources).queryVfModule(vfModule); + + expectedException.expect(BpmnError.class); + sdncQueryTasks.queryVfModuleForVolumeGroup(execution); + + verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(execution, 700, exception, TargetEntity.SO); + } + + @Test public void queryVfModuleForVolumeGroupNoSelfLinkExceptionTest() throws Exception { expectedException.expect(BpmnError.class); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasksTest.java index 6a94b357e0..0fc33fe5ce 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCRequestTasksTest.java @@ -21,6 +21,7 @@ package org.onap.so.bpmn.infrastructure.sdnc.tasks; import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doThrow; import java.io.IOException; @@ -48,6 +49,7 @@ import org.onap.so.client.exception.MapperException; import org.onap.so.client.sdnc.SDNCClient; import org.onap.so.client.sdnc.beans.SDNCRequest; import org.onap.so.client.sdnc.endpoint.SDNCTopology; +import org.onap.so.utils.TargetEntity; import org.w3c.dom.Document; import org.xml.sax.InputSource; import com.fasterxml.jackson.core.JsonParseException; @@ -66,7 +68,6 @@ public class SDNCRequestTasksTest extends SDNCRequestTasks { @Mock SDNCClient sdncClient; - @Spy private ExceptionBuilder exceptionBuilder; diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java index c683303a41..2d48d02774 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java @@ -41,6 +41,7 @@ import org.mockito.Spy; import org.onap.so.bpmn.BaseTaskTest; import org.onap.so.bpmn.core.WorkflowException; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; +import org.onap.so.constants.Status; import org.onap.so.db.request.beans.InfraActiveRequests; public class WorkflowActionBBFailureTest extends BaseTaskTest { @@ -102,6 +103,24 @@ public class WorkflowActionBBFailureTest extends BaseTaskTest { workflowActionBBFailure.updateRequestStatusToFailed(execution); String errorMsg = (String) execution.getVariable("ErrorMessage"); assertEquals("error in test case", errorMsg); + assertEquals(Status.FAILED.toString(), req.getRequestStatus()); + } + + @Test + public void updateRequestStatusToAborted() { + execution.setVariable("mso-request-id", "123"); + execution.setVariable("isRollbackComplete", false); + execution.setVariable("isRollback", false); + execution.setVariable("handlingCode", "Abort"); + InfraActiveRequests req = new InfraActiveRequests(); + WorkflowException wfe = new WorkflowException("processKey123", 1, "error in test case"); + execution.setVariable("WorkflowException", wfe); + doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId("123"); + doNothing().when(requestsDbClient).updateInfraActiveRequests(isA(InfraActiveRequests.class)); + workflowActionBBFailure.updateRequestStatusToFailed(execution); + String errorMsg = (String) execution.getVariable("ErrorMessage"); + assertEquals("error in test case", errorMsg); + assertEquals(Status.ABORTED.toString(), req.getRequestStatus()); } @Test @@ -117,19 +136,52 @@ public class WorkflowActionBBFailureTest extends BaseTaskTest { workflowActionBBFailure.updateRequestStatusToFailed(execution); String errorMsg = (String) execution.getVariable("RollbackErrorMessage"); assertEquals("error in rollback", errorMsg); + assertEquals(Status.FAILED.toString(), req.getRequestStatus()); + } + + @Test + public void updateRequestStatusToRolledback() { + execution.setVariable("mso-request-id", "123"); + execution.setVariable("isRollbackComplete", true); + execution.setVariable("isRollback", true); + execution.setVariable("rollbackTargetState", "ROLLED_BACK"); + InfraActiveRequests req = new InfraActiveRequests(); + doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId("123"); + doNothing().when(requestsDbClient).updateInfraActiveRequests(isA(InfraActiveRequests.class)); + workflowActionBBFailure.updateRequestStatusToFailed(execution); + String errorMsg = (String) execution.getVariable("RollbackErrorMessage"); + assertEquals("Rollback has been completed successfully.", errorMsg); + assertEquals(Status.ROLLED_BACK.toString(), req.getRequestStatus()); } @Test - public void updateRequestStatusToFailedRollbackCompleted() { + public void updateRequestStatusToRolledbackToAssigned() { execution.setVariable("mso-request-id", "123"); execution.setVariable("isRollbackComplete", true); execution.setVariable("isRollback", true); + execution.setVariable("rollbackTargetState", "ROLLED_BACK_TO_ASSIGNED"); InfraActiveRequests req = new InfraActiveRequests(); doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId("123"); doNothing().when(requestsDbClient).updateInfraActiveRequests(isA(InfraActiveRequests.class)); workflowActionBBFailure.updateRequestStatusToFailed(execution); String errorMsg = (String) execution.getVariable("RollbackErrorMessage"); assertEquals("Rollback has been completed successfully.", errorMsg); + assertEquals(Status.ROLLED_BACK_TO_ASSIGNED.toString(), req.getRequestStatus()); + } + + @Test + public void updateRequestStatusToRolledbackToCreated() { + execution.setVariable("mso-request-id", "123"); + execution.setVariable("isRollbackComplete", true); + execution.setVariable("isRollback", true); + execution.setVariable("rollbackTargetState", "ROLLED_BACK_TO_CREATED"); + InfraActiveRequests req = new InfraActiveRequests(); + doReturn(req).when(requestsDbClient).getInfraActiveRequestbyRequestId("123"); + doNothing().when(requestsDbClient).updateInfraActiveRequests(isA(InfraActiveRequests.class)); + workflowActionBBFailure.updateRequestStatusToFailed(execution); + String errorMsg = (String) execution.getVariable("RollbackErrorMessage"); + assertEquals("Rollback has been completed successfully.", errorMsg); + assertEquals(Status.ROLLED_BACK_TO_CREATED.toString(), req.getRequestStatus()); } @Test @@ -160,4 +212,38 @@ public class WorkflowActionBBFailureTest extends BaseTaskTest { Mockito.verify(reqMock, Mockito.times(1)).setLastModifiedBy("CamundaBPMN"); Mockito.verify(reqMock, Mockito.times(1)).setEndTime(any(Timestamp.class)); } + + @Test + public void updateRequestRollbackErrorStatusMessageTest() { + String reqId = "reqId123"; + execution.setVariable("mso-request-id", reqId); + WorkflowException we = new WorkflowException("WorkflowAction", 1231, "Error Case"); + execution.setVariable("WorkflowException", we); + execution.setVariable("isRollback", true); + + doReturn(reqMock).when(requestsDbClient).getInfraActiveRequestbyRequestId(reqId); + workflowActionBBFailure.updateRequestErrorStatusMessage(execution); + Mockito.verify(reqMock, Mockito.times(0)).setStatusMessage("Error Case"); + Mockito.verify(reqMock, Mockito.times(1)).setRollbackStatusMessage("Error Case"); + Mockito.verify(reqMock, Mockito.times(1)).setProgress(Long.valueOf(100)); + Mockito.verify(reqMock, Mockito.times(1)).setLastModifiedBy("CamundaBPMN"); + Mockito.verify(reqMock, Mockito.times(1)).setEndTime(any(Timestamp.class)); + } + + @Test + public void updateRequestNotRollbackErrorStatusMessageTest() { + String reqId = "reqId123"; + execution.setVariable("mso-request-id", reqId); + WorkflowException we = new WorkflowException("WorkflowAction", 1231, "Error Case"); + execution.setVariable("WorkflowException", we); + execution.setVariable("isRollback", false); + + doReturn(reqMock).when(requestsDbClient).getInfraActiveRequestbyRequestId(reqId); + workflowActionBBFailure.updateRequestErrorStatusMessage(execution); + Mockito.verify(reqMock, Mockito.times(1)).setStatusMessage("Error Case"); + Mockito.verify(reqMock, Mockito.times(0)).setRollbackStatusMessage("Error Case"); + Mockito.verify(reqMock, Mockito.times(1)).setProgress(Long.valueOf(100)); + Mockito.verify(reqMock, Mockito.times(1)).setLastModifiedBy("CamundaBPMN"); + Mockito.verify(reqMock, Mockito.times(1)).setEndTime(any(Timestamp.class)); + } } diff --git a/common/src/main/java/org/onap/so/constants/OrchestrationRequestFormat.java b/common/src/main/java/org/onap/so/constants/OrchestrationRequestFormat.java new file mode 100644 index 0000000000..ccfd2f4de6 --- /dev/null +++ b/common/src/main/java/org/onap/so/constants/OrchestrationRequestFormat.java @@ -0,0 +1,25 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.constants; + +public enum OrchestrationRequestFormat { + DETAIL, STATUSDETAIL +} diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/Status.java b/common/src/main/java/org/onap/so/constants/Status.java index b791bf147b..b460418f0f 100644 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/Status.java +++ b/common/src/main/java/org/onap/so/constants/Status.java @@ -18,12 +18,23 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.apihandlerinfra; +package org.onap.so.constants; /* * Enum for Status values returned by API Handler to Tail-F */ public enum Status { - PENDING, IN_PROGRESS, COMPLETE, COMPLETED, FAILED, TIMEOUT, UNLOCKED, PENDING_MANUAL_TASK + PENDING, + IN_PROGRESS, + COMPLETE, + COMPLETED, + FAILED, + TIMEOUT, + UNLOCKED, + PENDING_MANUAL_TASK, + ABORTED, + ROLLED_BACK, + ROLLED_BACK_TO_ASSIGNED, + ROLLED_BACK_TO_CREATED } diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/RequestStatus.java b/common/src/main/java/org/onap/so/serviceinstancebeans/RequestStatus.java index e236003631..3ada984b58 100644 --- a/common/src/main/java/org/onap/so/serviceinstancebeans/RequestStatus.java +++ b/common/src/main/java/org/onap/so/serviceinstancebeans/RequestStatus.java @@ -40,6 +40,36 @@ public class RequestStatus { protected String extSystemErrorSource; @JsonProperty("rollbackExtSystemErrorSource") protected String rollbackExtSystemErrorSource; + @JsonProperty("flowStatus") + protected String flowStatus; + @JsonProperty("retryStatusMessage") + protected String retryStatusMessage; + @JsonProperty("rollbackStatusMessage") + protected String rollbackStatusMessage; + + public String getFlowStatus() { + return flowStatus; + } + + public void setFlowStatus(String flowStatus) { + this.flowStatus = flowStatus; + } + + public String getRetryStatusMessage() { + return retryStatusMessage; + } + + public void setRetryStatusMessage(String retryStatusMessage) { + this.retryStatusMessage = retryStatusMessage; + } + + public String getRollbackStatusMessage() { + return rollbackStatusMessage; + } + + public void setRollbackStatusMessage(String rollbackStatusMessage) { + this.rollbackStatusMessage = rollbackStatusMessage; + } public String getExtSystemErrorSource() { return extSystemErrorSource; @@ -94,6 +124,8 @@ public class RequestStatus { return new ToStringBuilder(this).append("requestState", requestState).append("statusMessage", statusMessage) .append("percentProgress", percentProgress).append("timestamp", timeStamp) .append("extSystemErrorSource", extSystemErrorSource) - .append("rollbackExtSystemErrorSource", rollbackExtSystemErrorSource).toString(); + .append("rollbackExtSystemErrorSource", rollbackExtSystemErrorSource).append("flowStatus", flowStatus) + .append("retryStatusMessage", retryStatusMessage).append("rollbackStatusMessage", rollbackStatusMessage) + .toString(); } } diff --git a/common/src/main/java/org/onap/so/utils/TargetEntities.java b/common/src/main/java/org/onap/so/utils/TargetEntities.java new file mode 100644 index 0000000000..94385ec8ea --- /dev/null +++ b/common/src/main/java/org/onap/so/utils/TargetEntities.java @@ -0,0 +1,25 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.utils; + +public interface TargetEntities { + +} diff --git a/common/src/main/java/org/onap/so/utils/TargetEntity.java b/common/src/main/java/org/onap/so/utils/TargetEntity.java index 0f1fe51114..3a3ec91d2f 100644 --- a/common/src/main/java/org/onap/so/utils/TargetEntity.java +++ b/common/src/main/java/org/onap/so/utils/TargetEntity.java @@ -22,7 +22,7 @@ package org.onap.so.utils; import java.util.EnumSet; -public enum TargetEntity { +public enum TargetEntity implements TargetEntities { OPENSTACK_ADAPTER, BPMN, GRM, @@ -37,7 +37,11 @@ public enum TargetEntity { SDC, EXTERNAL, MULTICLOUD, - OOF; + OOF, + SDNC, + SO, + UNKNOWN, + OPENSTACK; private static final String PREFIX = "SO"; diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/filters/ResponseUpdateFilter.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/filters/ResponseUpdateFilter.java index eb52625bb6..119a0a560e 100644 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/filters/ResponseUpdateFilter.java +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/filters/ResponseUpdateFilter.java @@ -31,7 +31,7 @@ import javax.ws.rs.core.Response; import javax.ws.rs.ext.Provider; import javax.ws.rs.ext.Providers; import org.onap.logging.ref.slf4j.ONAPLogConstants; -import org.onap.so.apihandlerinfra.Status; +import org.onap.so.constants.Status; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.serviceinstancebeans.RequestError; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java index 835a24c4ce..fdc51ffe24 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java @@ -56,6 +56,7 @@ import org.onap.so.apihandlerinfra.e2eserviceinstancebeans.GetE2EServiceInstance import org.onap.so.apihandlerinfra.exceptions.ApiException; import org.onap.so.apihandlerinfra.exceptions.ValidateException; import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo; +import org.onap.so.constants.Status; import org.onap.so.db.catalog.beans.Service; import org.onap.so.db.catalog.beans.ServiceRecipe; import org.onap.so.db.catalog.client.CatalogDbClient; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/InstanceManagement.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/InstanceManagement.java index c582e429ff..d8a7cb3f5d 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/InstanceManagement.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/InstanceManagement.java @@ -33,6 +33,7 @@ import org.onap.so.apihandlerinfra.exceptions.RecipeNotFoundException; import org.onap.so.apihandlerinfra.exceptions.RequestDbFailureException; import org.onap.so.apihandlerinfra.exceptions.ValidateException; import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo; +import org.onap.so.constants.Status; import org.onap.so.db.catalog.beans.Workflow; import org.onap.so.db.catalog.client.CatalogDbClient; import org.onap.so.db.request.beans.InfraActiveRequests; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ManualTasks.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ManualTasks.java index 47f978a9e2..113baf96e6 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ManualTasks.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ManualTasks.java @@ -50,6 +50,7 @@ import org.onap.so.apihandlerinfra.tasksbeans.TaskRequestReference; import org.onap.so.apihandlerinfra.tasksbeans.TasksRequest; import org.onap.so.apihandlerinfra.tasksbeans.Value; import org.onap.so.apihandlerinfra.tasksbeans.Variables; +import org.onap.so.constants.Status; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.exceptions.ValidationException; import org.onap.so.logger.ErrorCode; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java index cbfe927adf..4bcc0d4111 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java @@ -63,6 +63,7 @@ import org.onap.so.apihandlerinfra.validation.ValidationRule; import org.onap.so.apihandlerinfra.vnfbeans.RequestStatusType; import org.onap.so.apihandlerinfra.vnfbeans.VnfInputs; import org.onap.so.apihandlerinfra.vnfbeans.VnfRequest; +import org.onap.so.constants.Status; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.exceptions.ValidationException; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java index b63e3916f3..ba69355d5e 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java @@ -48,6 +48,8 @@ import org.onap.so.apihandler.common.ResponseBuilder; import org.onap.so.apihandlerinfra.exceptions.ApiException; import org.onap.so.apihandlerinfra.exceptions.ValidateException; import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo; +import org.onap.so.constants.OrchestrationRequestFormat; +import org.onap.so.constants.Status; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.beans.RequestProcessingData; import org.onap.so.db.request.client.RequestsDbClient; @@ -72,6 +74,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; + @Path("onap/so/infra/orchestrationRequests") @Api(value = "onap/so/infra/orchestrationRequests", description = "API Requests for Orchestration requests") @Component @@ -95,7 +98,7 @@ public class OrchestrationRequests { @Transactional public Response getOrchestrationRequest(@PathParam("requestId") String requestId, @PathParam("version") String version, @QueryParam("includeCloudRequest") boolean includeCloudRequest, - @QueryParam("extSystemErrorSource") boolean extSystemErrorSource) throws ApiException { + @QueryParam(value = "format") String format) throws ApiException { String apiVersion = version.substring(1); GetOrchestrationResponse orchestrationResponse = new GetOrchestrationResponse(); @@ -142,7 +145,7 @@ public class OrchestrationRequests { throw validateException; } - Request request = mapInfraActiveRequestToRequest(infraActiveRequest, includeCloudRequest, extSystemErrorSource); + Request request = mapInfraActiveRequestToRequest(infraActiveRequest, includeCloudRequest, format); if (!requestProcessingData.isEmpty()) { request.setRequestProcessingData(mapRequestProcessingData(requestProcessingData)); @@ -159,8 +162,8 @@ public class OrchestrationRequests { @Produces(MediaType.APPLICATION_JSON) @Transactional public Response getOrchestrationRequest(@Context UriInfo ui, @PathParam("version") String version, - @QueryParam("includeCloudRequest") boolean includeCloudRequest, - @QueryParam("extSystemErrorSource") boolean extSystemErrorSource) throws ApiException { + @QueryParam("includeCloudRequest") boolean includeCloudRequest, @QueryParam(value = "format") String format) + throws ApiException { long startTime = System.currentTimeMillis(); @@ -197,7 +200,7 @@ public class OrchestrationRequests { List<RequestProcessingData> requestProcessingData = requestsDbClient.getRequestProcessingDataBySoRequestId(infraActive.getRequestId()); RequestList requestList = new RequestList(); - Request request = mapInfraActiveRequestToRequest(infraActive, includeCloudRequest, extSystemErrorSource); + Request request = mapInfraActiveRequestToRequest(infraActive, includeCloudRequest, format); if (!requestProcessingData.isEmpty()) { request.setRequestProcessingData(mapRequestProcessingData(requestProcessingData)); @@ -269,9 +272,10 @@ public class OrchestrationRequests { } else { String status = infraActiveRequest.getRequestStatus(); - if (status.equalsIgnoreCase("IN_PROGRESS") || status.equalsIgnoreCase("PENDING") - || status.equalsIgnoreCase("PENDING_MANUAL_TASK")) { - infraActiveRequest.setRequestStatus("UNLOCKED"); + if (Status.IN_PROGRESS.toString().equalsIgnoreCase(status) + || Status.PENDING.toString().equalsIgnoreCase(status) + || Status.PENDING_MANUAL_TASK.toString().equalsIgnoreCase(status)) { + infraActiveRequest.setRequestStatus(Status.UNLOCKED.toString()); infraActiveRequest.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER); infraActiveRequest.setRequestId(requestId); requestsDbClient.save(infraActiveRequest); @@ -294,7 +298,7 @@ public class OrchestrationRequests { } protected Request mapInfraActiveRequestToRequest(InfraActiveRequests iar, boolean includeCloudRequest, - boolean extSystemErrorSource) throws ApiException { + String format) throws ApiException { String requestBody = iar.getRequestBody(); Request request = new Request(); @@ -303,9 +307,6 @@ public class OrchestrationRequests { request.setRequestId(iar.getRequestId()); request.setRequestScope(iar.getRequestScope()); request.setRequestType(iar.getRequestAction()); - String rollbackStatusMessage = iar.getRollbackStatusMessage(); - String flowStatusMessage = iar.getFlowStatus(); - String retryStatusMessage = iar.getRetryStatusMessage(); String originalRequestId = iar.getOriginalRequestId(); if (originalRequestId != null) { @@ -376,43 +377,15 @@ public class OrchestrationRequests { String endTimeStamp = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(iar.getEndTime()) + " GMT"; request.setFinishTime(endTimeStamp); } - String statusMessages = null; + RequestStatus status = new RequestStatus(); - if (iar.getStatusMessage() != null) { - statusMessages = "STATUS: " + iar.getStatusMessage(); - } - if (flowStatusMessage != null) { - if (statusMessages != null) { - statusMessages = statusMessages + " " + "FLOW STATUS: " + flowStatusMessage; - } else { - statusMessages = "FLOW STATUS: " + flowStatusMessage; - } - } - if (retryStatusMessage != null) { - if (statusMessages != null) { - statusMessages = statusMessages + " " + "RETRY STATUS: " + retryStatusMessage; - } else { - statusMessages = "RETRY STATUS: " + retryStatusMessage; - } - } - if (rollbackStatusMessage != null) { - if (statusMessages != null) { - statusMessages = statusMessages + " " + "ROLLBACK STATUS: " + rollbackStatusMessage; - } else { - statusMessages = "ROLLBACK STATUS: " + rollbackStatusMessage; - } - } - if (statusMessages != null) { - status.setStatusMessage(statusMessages); - } + if (iar.getModifyTime() != null) { String timeStamp = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(iar.getModifyTime()) + " GMT"; status.setTimeStamp(timeStamp); } - if (iar.getRequestStatus() != null) { - status.setRequestState(iar.getRequestStatus()); - } + status.setRequestState(mapRequestStatusToRequest(iar, format)); if (iar.getProgress() != null) { status.setPercentProgress(iar.getProgress().intValue()); @@ -430,17 +403,80 @@ public class OrchestrationRequests { }); } - mapExtSystemErrorSourceToRequest(iar, status, extSystemErrorSource); + mapRequestStatusAndExtSysErrSrcToRequest(iar, status, format); request.setRequestStatus(status); return request; } - protected void mapExtSystemErrorSourceToRequest(InfraActiveRequests iar, RequestStatus status, - boolean extSystemErrorSource) { - if (extSystemErrorSource) { + protected String mapRequestStatusToRequest(InfraActiveRequests iar, String format) { + if (iar.getRequestStatus() != null) { + if (!StringUtils.isBlank(format) && OrchestrationRequestFormat.DETAIL.toString().equalsIgnoreCase(format)) { + return iar.getRequestStatus(); + } else { + if (Status.ABORTED.toString().equalsIgnoreCase(iar.getRequestStatus()) + || Status.ROLLED_BACK.toString().equalsIgnoreCase(iar.getRequestStatus()) + || Status.ROLLED_BACK_TO_ASSIGNED.toString().equalsIgnoreCase(iar.getRequestStatus()) + || Status.ROLLED_BACK_TO_CREATED.toString().equalsIgnoreCase(iar.getRequestStatus())) { + return Status.FAILED.toString(); + } else { + return iar.getRequestStatus(); + } + } + } + return null; + } + + protected void mapRequestStatusAndExtSysErrSrcToRequest(InfraActiveRequests iar, RequestStatus status, + String format) { + String rollbackStatusMessage = iar.getRollbackStatusMessage(); + String flowStatusMessage = iar.getFlowStatus(); + String retryStatusMessage = iar.getRetryStatusMessage(); + + String statusMessages = null; + if (iar.getStatusMessage() != null) { + statusMessages = "STATUS: " + iar.getStatusMessage(); + } + + if (OrchestrationRequestFormat.STATUSDETAIL.toString().equalsIgnoreCase(format)) { + if (flowStatusMessage != null) { + status.setFlowStatus(flowStatusMessage); + } + if (retryStatusMessage != null) { + status.setRetryStatusMessage(retryStatusMessage); + } + if (rollbackStatusMessage != null) { + status.setRollbackStatusMessage(rollbackStatusMessage); + } status.setExtSystemErrorSource(iar.getExtSystemErrorSource()); status.setRollbackExtSystemErrorSource(iar.getRollbackExtSystemErrorSource()); + } else { + + if (flowStatusMessage != null) { + if (statusMessages != null) { + statusMessages = statusMessages + " " + "FLOW STATUS: " + flowStatusMessage; + } else { + statusMessages = "FLOW STATUS: " + flowStatusMessage; + } + } + if (retryStatusMessage != null) { + if (statusMessages != null) { + statusMessages = statusMessages + " " + "RETRY STATUS: " + retryStatusMessage; + } else { + statusMessages = "RETRY STATUS: " + retryStatusMessage; + } + } + if (rollbackStatusMessage != null) { + if (statusMessages != null) { + statusMessages = statusMessages + " " + "ROLLBACK STATUS: " + rollbackStatusMessage; + } else { + statusMessages = "ROLLBACK STATUS: " + rollbackStatusMessage; + } + } + } + + if (statusMessages != null) { + status.setStatusMessage(statusMessages); } } 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 86e2f5ce93..c3f323459c 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 @@ -62,6 +62,7 @@ import org.onap.so.apihandlerinfra.exceptions.ValidateException; import org.onap.so.apihandlerinfra.exceptions.VfModuleNotFoundException; import org.onap.so.apihandlerinfra.infra.rest.handler.AbstractRestHandler; import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo; +import org.onap.so.constants.Status; import org.onap.so.db.catalog.beans.VfModule; import org.onap.so.db.catalog.client.CatalogDbClient; import org.onap.so.db.request.beans.InfraActiveRequests; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ResumeOrchestrationRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ResumeOrchestrationRequest.java index d82fd38e9f..ed300d95c2 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ResumeOrchestrationRequest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ResumeOrchestrationRequest.java @@ -40,6 +40,7 @@ import org.onap.so.apihandlerinfra.exceptions.ApiException; import org.onap.so.apihandlerinfra.exceptions.RequestDbFailureException; import org.onap.so.apihandlerinfra.exceptions.ValidateException; import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo; +import org.onap.so.constants.Status; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.logger.ErrorCode; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java index b290a796e2..5b827d9cf8 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java @@ -52,6 +52,7 @@ import org.onap.so.apihandlerinfra.exceptions.RequestDbFailureException; import org.onap.so.apihandlerinfra.exceptions.ValidateException; import org.onap.so.apihandlerinfra.infra.rest.handler.AbstractRestHandler; import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo; +import org.onap.so.constants.Status; import org.onap.so.db.catalog.beans.NetworkResource; import org.onap.so.db.catalog.beans.NetworkResourceCustomization; import org.onap.so.db.catalog.beans.Recipe; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/BpmnRequestBuilder.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/BpmnRequestBuilder.java index 5b51d85e41..bb5b4edfe4 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/BpmnRequestBuilder.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/BpmnRequestBuilder.java @@ -30,7 +30,6 @@ import org.onap.aai.domain.yang.ServiceInstance; import org.onap.aai.domain.yang.VfModule; import org.onap.aai.domain.yang.VolumeGroup; import org.onap.logging.ref.slf4j.ONAPLogConstants; -import org.onap.so.apihandlerinfra.Status; import org.onap.so.apihandlerinfra.infra.rest.exception.AAIEntityNotFound; import org.onap.so.apihandlerinfra.infra.rest.exception.CloudConfigurationNotFoundException; import org.onap.so.client.aai.AAIObjectType; @@ -38,6 +37,7 @@ import org.onap.so.client.aai.AAIResourcesClient; 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.constants.Status; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.serviceinstancebeans.CloudConfiguration; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/AbstractRestHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/AbstractRestHandler.java index 227506c60e..b5b548a266 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/AbstractRestHandler.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/AbstractRestHandler.java @@ -35,13 +35,13 @@ import org.onap.so.apihandlerinfra.Action; import org.onap.so.apihandlerinfra.Actions; import org.onap.so.apihandlerinfra.Constants; import org.onap.so.apihandlerinfra.MsoRequest; -import org.onap.so.apihandlerinfra.Status; import org.onap.so.apihandlerinfra.exceptions.ApiException; import org.onap.so.apihandlerinfra.exceptions.RequestDbFailureException; import org.onap.so.apihandlerinfra.exceptions.ValidateException; import org.onap.so.apihandlerinfra.infra.rest.exception.RequestConflictedException; import org.onap.so.apihandlerinfra.infra.rest.exception.WorkflowEngineConnectionException; import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo; +import org.onap.so.constants.Status; import org.onap.so.db.catalog.client.CatalogDbClient; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.client.RequestsDbClient; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/NetworkRestHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/NetworkRestHandler.java index ebb5d7e119..7b095fc9d0 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/NetworkRestHandler.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/NetworkRestHandler.java @@ -25,9 +25,9 @@ import java.util.HashMap; import org.onap.so.apihandler.common.RequestClientParameter; import org.onap.so.apihandlerinfra.Action; import org.onap.so.apihandlerinfra.Constants; -import org.onap.so.apihandlerinfra.Status; import org.onap.so.apihandlerinfra.infra.rest.exception.NoRecipeException; import org.onap.so.apihandlerinfra.infra.rest.exception.RequestConflictedException; +import org.onap.so.constants.Status; import org.onap.so.db.catalog.beans.NetworkRecipe; import org.onap.so.db.catalog.beans.Recipe; import org.onap.so.db.request.beans.InfraActiveRequests; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/ServiceInstanceRestHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/ServiceInstanceRestHandler.java index 7d3091e950..afadf36157 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/ServiceInstanceRestHandler.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/ServiceInstanceRestHandler.java @@ -26,9 +26,9 @@ import java.util.HashMap; import org.onap.so.apihandler.common.RequestClientParameter; import org.onap.so.apihandlerinfra.Action; import org.onap.so.apihandlerinfra.Constants; -import org.onap.so.apihandlerinfra.Status; import org.onap.so.apihandlerinfra.infra.rest.exception.NoRecipeException; import org.onap.so.apihandlerinfra.infra.rest.exception.RequestConflictedException; +import org.onap.so.constants.Status; import org.onap.so.db.catalog.beans.Recipe; import org.onap.so.db.catalog.beans.ServiceRecipe; import org.onap.so.db.request.beans.InfraActiveRequests; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/VFModuleRestHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/VFModuleRestHandler.java index efd8b12b9a..0762803488 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/VFModuleRestHandler.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/VFModuleRestHandler.java @@ -26,8 +26,8 @@ import java.util.HashMap; import org.onap.so.apihandler.common.RequestClientParameter; import org.onap.so.apihandlerinfra.Action; import org.onap.so.apihandlerinfra.Constants; -import org.onap.so.apihandlerinfra.Status; import org.onap.so.apihandlerinfra.infra.rest.exception.NoRecipeException; +import org.onap.so.constants.Status; import org.onap.so.db.catalog.beans.Recipe; import org.onap.so.db.catalog.beans.VnfComponentsRecipe; import org.onap.so.db.request.beans.InfraActiveRequests; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/VnfRestHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/VnfRestHandler.java index d98625fe50..e157d926f3 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/VnfRestHandler.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/VnfRestHandler.java @@ -26,8 +26,8 @@ import java.util.HashMap; import org.onap.so.apihandler.common.RequestClientParameter; import org.onap.so.apihandlerinfra.Action; import org.onap.so.apihandlerinfra.Constants; -import org.onap.so.apihandlerinfra.Status; import org.onap.so.apihandlerinfra.infra.rest.exception.NoRecipeException; +import org.onap.so.constants.Status; import org.onap.so.db.catalog.beans.Recipe; import org.onap.so.db.catalog.beans.VnfRecipe; import org.onap.so.db.request.beans.InfraActiveRequests; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/VolumeRestHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/VolumeRestHandler.java index 52f7ee9ac4..48a8aa2cd8 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/VolumeRestHandler.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/VolumeRestHandler.java @@ -26,7 +26,7 @@ import java.util.HashMap; import org.onap.so.apihandler.common.RequestClientParameter; import org.onap.so.apihandlerinfra.Action; import org.onap.so.apihandlerinfra.Constants; -import org.onap.so.apihandlerinfra.Status; +import org.onap.so.constants.Status; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.logger.LogConstants; import org.onap.so.serviceinstancebeans.ModelType; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestration.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestration.java index e8d00ed52b..d3fb7986ce 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestration.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestration.java @@ -42,7 +42,6 @@ import org.onap.so.logger.LoggingAnchor; import org.apache.http.HttpStatus; import org.onap.so.apihandler.common.ErrorNumbers; import org.onap.so.apihandlerinfra.Constants; -import org.onap.so.apihandlerinfra.Status; import org.onap.so.apihandlerinfra.exceptions.ApiException; import org.onap.so.apihandlerinfra.exceptions.DuplicateRequestException; import org.onap.so.apihandlerinfra.exceptions.ValidateException; @@ -51,6 +50,7 @@ import org.onap.so.apihandlerinfra.tenantisolationbeans.Action; import org.onap.so.apihandlerinfra.tenantisolationbeans.OperationalEnvironment; import org.onap.so.apihandlerinfra.tenantisolationbeans.RequestReferences; import org.onap.so.apihandlerinfra.tenantisolationbeans.TenantSyncResponse; +import org.onap.so.constants.Status; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.exceptions.ValidationException; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRequest.java index 007ea938a2..efdc52b837 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRequest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRequest.java @@ -30,7 +30,6 @@ import java.util.Map.Entry; import javax.ws.rs.core.MultivaluedMap; import org.apache.commons.lang3.StringUtils; import org.onap.so.apihandlerinfra.Constants; -import org.onap.so.apihandlerinfra.Status; import org.onap.so.apihandlerinfra.tenantisolationbeans.Action; import org.onap.so.apihandlerinfra.tenantisolationbeans.Manifest; import org.onap.so.apihandlerinfra.tenantisolationbeans.OperationalEnvironment; @@ -42,6 +41,7 @@ import org.onap.so.apihandlerinfra.tenantisolationbeans.RequestParameters; import org.onap.so.apihandlerinfra.tenantisolationbeans.ResourceType; import org.onap.so.apihandlerinfra.tenantisolationbeans.ServiceModelList; import org.onap.so.apihandlerinfra.vnfbeans.RequestStatusType; +import org.onap.so.constants.Status; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.exceptions.ValidationException; diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsUnitTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsUnitTest.java index 99ff4ffe9e..fc548a715e 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsUnitTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsUnitTest.java @@ -23,16 +23,10 @@ package org.onap.so.apihandlerinfra; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; import javax.ws.rs.core.Response; -import org.apache.http.HttpStatus; +import org.apache.commons.lang.StringUtils; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -40,11 +34,11 @@ import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; import org.onap.so.apihandler.common.ResponseBuilder; import org.onap.so.apihandlerinfra.exceptions.ApiException; +import org.onap.so.constants.OrchestrationRequestFormat; +import org.onap.so.constants.Status; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.serviceinstancebeans.InstanceReferences; @@ -64,7 +58,6 @@ public class OrchestrationRequestsUnitTest { @Rule public ExpectedException thrown = ExpectedException.none(); @InjectMocks - @Spy private OrchestrationRequests orchestrationRequests; private static final String REQUEST_ID = "7cb9aa56-dd31-41e5-828e-d93027d4ebba"; @@ -72,14 +65,13 @@ public class OrchestrationRequestsUnitTest { private static final String ORIGINAL_REQUEST_ID = "8f2d38a6-7c20-465a-bd7e-075645f1394b"; private static final String SERVICE = "service"; private static final String EXT_SYSTEM_ERROR_SOURCE = "external system error source"; - private static final String ROLLBACK_EXT_SYSTEM_ERROR_SOURCE = "SDNC"; + private static final String FLOW_STATUS = "FlowStatus"; + private static final String RETRY_STATUS_MESSAGE = "RetryStatusMessage"; + private static final String ROLLBACK_STATUS_MESSAGE = "RollbackStatusMessage"; private InfraActiveRequests iar; boolean includeCloudRequest = false; - boolean extSystemErrorSource = false; - - private static final String VERSION = "v7"; + private static final String ROLLBACK_EXT_SYSTEM_ERROR_SOURCE = "SDNC"; - List<org.onap.so.db.request.beans.RequestProcessingData> requestProcessingData = new ArrayList<>(); @Before public void setup() { @@ -87,12 +79,6 @@ public class OrchestrationRequestsUnitTest { iar.setRequestScope(SERVICE); iar.setRequestId(REQUEST_ID); iar.setServiceInstanceId(SERVICE_INSTANCE_ID); - when(requestDbClient.getInfraActiveRequestbyRequestId(Mockito.eq(REQUEST_ID))).thenReturn(iar); - when(requestDbClient.getRequestProcessingDataBySoRequestId(Mockito.eq(REQUEST_ID))) - .thenReturn(requestProcessingData); - - when(builder.buildResponse(Mockito.eq(HttpStatus.SC_OK), Mockito.eq(REQUEST_ID), any(Object.class), - any(String.class))).thenReturn(response); } @Test @@ -100,6 +86,7 @@ public class OrchestrationRequestsUnitTest { InstanceReferences instanceReferences = new InstanceReferences(); instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID); RequestStatus requestStatus = new RequestStatus(); + requestStatus.setRequestState(iar.getRequestStatus()); Request expected = new Request(); expected.setRequestId(REQUEST_ID); expected.setOriginalRequestId(ORIGINAL_REQUEST_ID); @@ -109,8 +96,8 @@ public class OrchestrationRequestsUnitTest { iar.setOriginalRequestId(ORIGINAL_REQUEST_ID); - Request result = - orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest, extSystemErrorSource); + Request result = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest, + OrchestrationRequestFormat.DETAIL.toString()); assertThat(result, sameBeanAs(expected)); } @@ -119,22 +106,24 @@ public class OrchestrationRequestsUnitTest { InstanceReferences instanceReferences = new InstanceReferences(); instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID); RequestStatus requestStatus = new RequestStatus(); + requestStatus.setRequestState(iar.getRequestStatus()); Request expected = new Request(); expected.setRequestId(REQUEST_ID); expected.setInstanceReferences(instanceReferences); expected.setRequestStatus(requestStatus); expected.setRequestScope(SERVICE); - Request result = - orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest, extSystemErrorSource); + Request result = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest, + OrchestrationRequestFormat.DETAIL.toString()); assertThat(result, sameBeanAs(expected)); } @Test - public void mapExtSystemErrorSourceToRequestFalseTest() throws ApiException { + public void mapRequestStatusAndExtSysErrSrcToRequestFalseTest() throws ApiException { InstanceReferences instanceReferences = new InstanceReferences(); instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID); RequestStatus requestStatus = new RequestStatus(); + requestStatus.setRequestState(iar.getRequestStatus()); Request expected = new Request(); expected.setRequestId(REQUEST_ID); @@ -142,21 +131,24 @@ public class OrchestrationRequestsUnitTest { expected.setRequestStatus(requestStatus); expected.setRequestScope(SERVICE); - extSystemErrorSource = false; includeCloudRequest = false; - Request actual = - orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest, extSystemErrorSource); + Request actual = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest, + OrchestrationRequestFormat.DETAIL.toString()); assertThat(actual, sameBeanAs(expected)); } @Test - public void mapExtSystemErrorSourceToRequestTrueTest() throws ApiException { + public void mapRequestStatusAndExtSysErrSrcToRequestStatusDetailTest() throws ApiException { InstanceReferences instanceReferences = new InstanceReferences(); instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID); RequestStatus requestStatus = new RequestStatus(); requestStatus.setExtSystemErrorSource(EXT_SYSTEM_ERROR_SOURCE); requestStatus.setRollbackExtSystemErrorSource(ROLLBACK_EXT_SYSTEM_ERROR_SOURCE); + requestStatus.setRequestState(iar.getRequestStatus()); + requestStatus.setFlowStatus(FLOW_STATUS); + requestStatus.setRollbackStatusMessage(ROLLBACK_STATUS_MESSAGE); + requestStatus.setRetryStatusMessage(RETRY_STATUS_MESSAGE); Request expected = new Request(); expected.setRequestId(REQUEST_ID); @@ -164,24 +156,44 @@ public class OrchestrationRequestsUnitTest { expected.setRequestStatus(requestStatus); expected.setRequestScope(SERVICE); - extSystemErrorSource = true; includeCloudRequest = false; iar.setExtSystemErrorSource(EXT_SYSTEM_ERROR_SOURCE); iar.setRollbackExtSystemErrorSource(ROLLBACK_EXT_SYSTEM_ERROR_SOURCE); + iar.setFlowStatus(FLOW_STATUS); + iar.setRollbackStatusMessage(ROLLBACK_STATUS_MESSAGE); + iar.setRetryStatusMessage(RETRY_STATUS_MESSAGE); - Request actual = - orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest, extSystemErrorSource); + Request actual = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest, + OrchestrationRequestFormat.STATUSDETAIL.toString()); assertThat(actual, sameBeanAs(expected)); } @Test - public void mapExtSystemErrorSourceToRequestMethodInvokedTest() throws ApiException, IOException { - extSystemErrorSource = true; + public void mapRequestStatusAndExtSysErrSrcToRequestDetailTest() throws ApiException { + InstanceReferences instanceReferences = new InstanceReferences(); + instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID); + RequestStatus requestStatus = new RequestStatus(); + requestStatus.setRequestState(iar.getRequestStatus()); + requestStatus.setStatusMessage(String.format("FLOW STATUS: %s RETRY STATUS: %s ROLLBACK STATUS: %s", + FLOW_STATUS, RETRY_STATUS_MESSAGE, ROLLBACK_STATUS_MESSAGE)); + + Request expected = new Request(); + expected.setRequestId(REQUEST_ID); + expected.setInstanceReferences(instanceReferences); + expected.setRequestStatus(requestStatus); + expected.setRequestScope(SERVICE); + includeCloudRequest = false; - orchestrationRequests.getOrchestrationRequest(REQUEST_ID, VERSION, includeCloudRequest, extSystemErrorSource); + iar.setExtSystemErrorSource(EXT_SYSTEM_ERROR_SOURCE); + iar.setRollbackExtSystemErrorSource(ROLLBACK_EXT_SYSTEM_ERROR_SOURCE); + iar.setFlowStatus(FLOW_STATUS); + iar.setRollbackStatusMessage(ROLLBACK_STATUS_MESSAGE); + iar.setRetryStatusMessage(RETRY_STATUS_MESSAGE); - verify(orchestrationRequests, times(1)).mapExtSystemErrorSourceToRequest(Mockito.eq(iar), Mockito.any(), - Mockito.eq(extSystemErrorSource)); + Request actual = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest, + OrchestrationRequestFormat.DETAIL.toString()); + + assertThat(actual, sameBeanAs(expected)); } @Test @@ -190,4 +202,22 @@ public class OrchestrationRequestsUnitTest { requestStatus.setExtSystemErrorSource(EXT_SYSTEM_ERROR_SOURCE); assertThat(requestStatus.getExtSystemErrorSource(), is(equalTo(EXT_SYSTEM_ERROR_SOURCE))); } + + @Test + public void mapRequestStatusToRequestForFormatDetailTest() throws ApiException { + iar.setRequestStatus(Status.ABORTED.toString()); + String result = + orchestrationRequests.mapRequestStatusToRequest(iar, OrchestrationRequestFormat.DETAIL.toString()); + + assertEquals(Status.ABORTED.toString(), result); + } + + + @Test + public void mapRequestStatusToRequestForFormatEmptyStringTest() throws ApiException { + iar.setRequestStatus(Status.ABORTED.toString()); + String result = orchestrationRequests.mapRequestStatusToRequest(iar, StringUtils.EMPTY); + + assertEquals(Status.FAILED.toString(), result); + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsUnitTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsUnitTest.java index 91ca756a51..d4b0c3aad1 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsUnitTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsUnitTest.java @@ -41,6 +41,7 @@ import org.mockito.junit.MockitoJUnitRunner; import org.onap.so.apihandlerinfra.exceptions.ApiException; import org.onap.so.apihandlerinfra.exceptions.ValidateException; import org.onap.so.apihandlerinfra.exceptions.VfModuleNotFoundException; +import org.onap.so.constants.Status; import org.onap.so.db.catalog.beans.VfModule; import org.onap.so.db.catalog.client.CatalogDbClient; import org.onap.so.db.request.beans.InfraActiveRequests; diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ResumeOrchestrationRequestTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ResumeOrchestrationRequestTest.java index 398966b0b3..1e755419be 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ResumeOrchestrationRequestTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ResumeOrchestrationRequestTest.java @@ -52,6 +52,7 @@ import org.onap.so.apihandlerinfra.exceptions.ApiException; import org.onap.so.apihandlerinfra.exceptions.DuplicateRequestException; import org.onap.so.apihandlerinfra.exceptions.RequestDbFailureException; import org.onap.so.apihandlerinfra.exceptions.ValidateException; +import org.onap.so.constants.Status; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.serviceinstancebeans.ModelInfo; diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/NetworkRestHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/NetworkRestHandlerTest.java index 8ff7517da8..59308215ac 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/NetworkRestHandlerTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/NetworkRestHandlerTest.java @@ -40,9 +40,9 @@ import org.mockito.junit.MockitoJUnitRunner; import org.onap.so.apihandler.common.RequestClientParameter; import org.onap.so.apihandlerinfra.Action; import org.onap.so.apihandlerinfra.Constants; -import org.onap.so.apihandlerinfra.Status; import org.onap.so.apihandlerinfra.infra.rest.exception.NoRecipeException; import org.onap.so.apihandlerinfra.infra.rest.handler.NetworkRestHandler; +import org.onap.so.constants.Status; import org.onap.so.db.catalog.client.CatalogDbClient; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.client.RequestsDbClient; diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/ServiceInstanceRestHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/ServiceInstanceRestHandlerTest.java index 56d57aa2d5..c1e6347943 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/ServiceInstanceRestHandlerTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/ServiceInstanceRestHandlerTest.java @@ -41,10 +41,10 @@ import org.mockito.junit.MockitoJUnitRunner; import org.onap.so.apihandler.common.RequestClientParameter; import org.onap.so.apihandlerinfra.Action; import org.onap.so.apihandlerinfra.Constants; -import org.onap.so.apihandlerinfra.Status; import org.onap.so.apihandlerinfra.infra.rest.exception.NoRecipeException; import org.onap.so.apihandlerinfra.infra.rest.exception.RequestConflictedException; import org.onap.so.apihandlerinfra.infra.rest.handler.ServiceInstanceRestHandler; +import org.onap.so.constants.Status; import org.onap.so.db.catalog.beans.Recipe; import org.onap.so.db.catalog.beans.ServiceRecipe; import org.onap.so.db.catalog.client.CatalogDbClient; diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/VfModuleRestHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/VfModuleRestHandlerTest.java index 280ae9c071..7d146791fe 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/VfModuleRestHandlerTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/VfModuleRestHandlerTest.java @@ -41,9 +41,9 @@ import org.mockito.junit.MockitoJUnitRunner; import org.onap.so.apihandler.common.RequestClientParameter; import org.onap.so.apihandlerinfra.Action; import org.onap.so.apihandlerinfra.Constants; -import org.onap.so.apihandlerinfra.Status; import org.onap.so.apihandlerinfra.infra.rest.exception.NoRecipeException; import org.onap.so.apihandlerinfra.infra.rest.handler.VFModuleRestHandler; +import org.onap.so.constants.Status; import org.onap.so.db.catalog.beans.Recipe; import org.onap.so.db.catalog.beans.VnfComponentsRecipe; import org.onap.so.db.catalog.client.CatalogDbClient; diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/VnfRestHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/VnfRestHandlerTest.java index 2ea537b6ad..03725ec85b 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/VnfRestHandlerTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/VnfRestHandlerTest.java @@ -40,9 +40,9 @@ import org.mockito.junit.MockitoJUnitRunner; import org.onap.so.apihandler.common.RequestClientParameter; import org.onap.so.apihandlerinfra.Action; import org.onap.so.apihandlerinfra.Constants; -import org.onap.so.apihandlerinfra.Status; import org.onap.so.apihandlerinfra.infra.rest.exception.NoRecipeException; import org.onap.so.apihandlerinfra.infra.rest.handler.VnfRestHandler; +import org.onap.so.constants.Status; import org.onap.so.db.catalog.beans.Recipe; import org.onap.so.db.catalog.beans.ServiceRecipe; import org.onap.so.db.catalog.client.CatalogDbClient; diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/VolumeRestHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/VolumeRestHandlerTest.java index 2721f8a14a..efa27743ef 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/VolumeRestHandlerTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/handler/VolumeRestHandlerTest.java @@ -40,9 +40,9 @@ import org.mockito.junit.MockitoJUnitRunner; import org.onap.so.apihandler.common.RequestClientParameter; import org.onap.so.apihandlerinfra.Action; import org.onap.so.apihandlerinfra.Constants; -import org.onap.so.apihandlerinfra.Status; import org.onap.so.apihandlerinfra.infra.rest.exception.NoRecipeException; import org.onap.so.apihandlerinfra.infra.rest.handler.VolumeRestHandler; +import org.onap.so.constants.Status; import org.onap.so.db.catalog.client.CatalogDbClient; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.client.RequestsDbClient; diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestrationTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestrationTest.java index 9ae1e5b232..a74c11c08b 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestrationTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestrationTest.java @@ -35,9 +35,9 @@ import org.junit.Before; import org.junit.Ignore; import org.junit.Test; import org.onap.so.apihandlerinfra.BaseTest; -import org.onap.so.apihandlerinfra.Status; import org.onap.so.apihandlerinfra.tenantisolationbeans.Action; import org.onap.so.apihandlerinfra.tenantisolationbeans.TenantIsolationRequest; +import org.onap.so.constants.Status; import org.onap.so.db.request.beans.InfraActiveRequests; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; @@ -210,7 +210,7 @@ </resource> </resources> <plugins> - <plugin> + <!-- <plugin> <groupId>org.sonatype.plugins</groupId> <artifactId>nexus-staging-maven-plugin</artifactId> <version>1.6.7</version> @@ -220,7 +220,7 @@ <stagingProfileId>176c31dfe190a</stagingProfileId> <serverId>ecomp-staging</serverId> </configuration> - </plugin> + </plugin> --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-deploy-plugin</artifactId> diff --git a/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/VnfmHelper.java b/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/VnfmHelper.java index 60b251c4d4..8f1e299fec 100644 --- a/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/VnfmHelper.java +++ b/vnfm-simulator/vnfm-service/src/main/java/org/onap/svnfm/simulator/services/VnfmHelper.java @@ -43,9 +43,13 @@ import org.springframework.stereotype.Component; @Component public class VnfmHelper { - @Autowired private ApplicationConfig applicationConfig; + @Autowired + public VnfmHelper(ApplicationConfig applicationConfig) { + this.applicationConfig = applicationConfig; + } + /** * * @param createVNFRequest diff --git a/vnfm-simulator/vnfm-service/src/test/java/org/onap/svnfm/simulator/services/VnfmHelperTest.java b/vnfm-simulator/vnfm-service/src/test/java/org/onap/svnfm/simulator/services/VnfmHelperTest.java new file mode 100644 index 0000000000..2b9598e54f --- /dev/null +++ b/vnfm-simulator/vnfm-service/src/test/java/org/onap/svnfm/simulator/services/VnfmHelperTest.java @@ -0,0 +1,104 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2019 Nokia. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.svnfm.simulator.services; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; +import org.junit.Before; +import org.junit.Test; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.CreateVnfRequest; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201.InstantiationStateEnum; +import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201LinksSelf; +import org.onap.svnfm.simulator.config.ApplicationConfig; +import org.onap.svnfm.simulator.constants.Constant; +import org.onap.svnfm.simulator.model.VnfInstance; + +public class VnfmHelperTest { + + private static final String VNF_INSTANCE_ID = "vnfInstanceTestId"; + private static final String VNFD_ID = "vnfdTestId"; + private static final String VNF_INSTANCE_NAME = "vnfInsNameTest"; + private static final String VNF_INSTANCE_DESCRIPTION = "vnfInstTestDescr"; + private static final String APPLICATION_CONFIG_BASE_URL = "appConfUrl"; + private VnfmHelper testedObject; + private ApplicationConfig applicationConfigMock; + + @Before + public void setup() { + applicationConfigMock = mock(ApplicationConfig.class); + testedObject = new VnfmHelper(applicationConfigMock); + } + + @Test + public void createVnfInstance() { + // when + VnfInstance result = testedObject.createVnfInstance(createVnfRequest(), VNF_INSTANCE_ID); + // then + assertThat(result.getId()).isEqualTo(VNF_INSTANCE_ID); + assertThat(result.getVnfdId()).isEqualTo(VNFD_ID); + assertThat(result.getVnfInstanceName()).isEqualTo(VNF_INSTANCE_NAME); + assertThat(result.getVnfInstanceDescription()).isEqualTo(VNF_INSTANCE_DESCRIPTION); + assertThat(result.getVnfProvider()).isEqualTo(Constant.VNF_PROVIDER); + assertThat(result.getVnfProductName()).isEqualTo(Constant.VNF_PROVIDER_NAME); + } + + @Test + public void getInlineResponse201() throws Exception { + // given + when(applicationConfigMock.getBaseUrl()).thenReturn(APPLICATION_CONFIG_BASE_URL); + // when + InlineResponse201 result = testedObject.getInlineResponse201(prepareVnfInstance()); + // then + assertThat(result.getVnfdVersion()).isEqualTo(Constant.VNFD_VERSION); + assertThat(result.getVnfSoftwareVersion()).isEqualTo(Constant.VNF_SOFTWARE_VERSION); + assertThat(result.getInstantiationState()).isEqualByComparingTo(InstantiationStateEnum.NOT_INSTANTIATED); + verifyAdditionalPropertyInlineResponse201(result); + } + + private CreateVnfRequest createVnfRequest() { + CreateVnfRequest createVnfRequest = new CreateVnfRequest(); + createVnfRequest.setVnfdId(VNFD_ID); + createVnfRequest.setVnfInstanceName(VNF_INSTANCE_NAME); + createVnfRequest.setVnfInstanceDescription(VNF_INSTANCE_DESCRIPTION); + return createVnfRequest; + } + + private VnfInstance prepareVnfInstance() { + VnfInstance vnfInstance = new VnfInstance(); + vnfInstance.setId(VNF_INSTANCE_ID); + return vnfInstance; + } + + private void verifyAdditionalPropertyInlineResponse201(InlineResponse201 result) { + InlineResponse201LinksSelf expectedVnfInstancesLinksSelf = new InlineResponse201LinksSelf(); + expectedVnfInstancesLinksSelf + .setHref(APPLICATION_CONFIG_BASE_URL + "/vnflcm/v1/vnf_instances/" + VNF_INSTANCE_ID); + assertThat(result.getLinks().getSelf()).isEqualTo(expectedVnfInstancesLinksSelf); + + InlineResponse201LinksSelf expectedVnfInstancesLinksSelfInstantiate = new InlineResponse201LinksSelf(); + expectedVnfInstancesLinksSelfInstantiate.setHref( + (APPLICATION_CONFIG_BASE_URL + "/vnflcm/v1/vnf_instances/" + VNF_INSTANCE_ID + "/instantiate")); + assertThat(result.getLinks().getInstantiate()).isEqualTo(expectedVnfInstancesLinksSelfInstantiate); + } + +} |