import java.util.Map;
import org.camunda.bpm.engine.delegate.BpmnError;
import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.onap.logging.filter.base.ONAPComponents;
import org.onap.logging.filter.base.ONAPComponentsList;
import org.onap.so.bpmn.core.WorkflowException;
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.client.exception.ExceptionBuilder;
import org.onap.so.constants.Status;
import org.onap.so.db.catalog.beans.macro.RainyDayHandlerStatus;
import org.onap.so.db.catalog.client.CatalogDbClient;
public static final String RAINY_DAY_VNF_TYPE = "rainyDayVnfType";
public static final String RAINY_DAY_VNF_NAME = "rainyDayVnfName";
+ @Autowired
+ private ExceptionBuilder exceptionBuilder;
@Autowired
private CatalogDbClient catalogDbClient;
@Autowired
try {
String requestId = (String) execution.getVariable("mso-request-id");
WorkflowException exception = (WorkflowException) execution.getVariable("WorkflowException");
+ if (exception == null) {
+ String errorMessage = (String) execution.getVariable("WorkflowExceptionMessage");
+ exception =
+ exceptionBuilder.buildWorkflowException(execution, 500, errorMessage, ONAPComponents.EXTERNAL);
+ }
ONAPComponentsList extSystemErrorSource = exception.getExtSystemErrorSource();
InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId);
Boolean isRollbackFailure = (Boolean) execution.getVariable("isRollback");
+
if (isRollbackFailure == null) {
isRollbackFailure = false;
}
throw new BpmnError("MSOWorkflowException");
}
+ public WorkflowException buildWorkflowException(DelegateExecution execution, int errorCode, String errorMessage,
+ ONAPComponentsList 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);
+ return exception;
+ }
+
public void buildAndThrowWorkflowException(DelegateExecution execution, String errorCode, String errorMessage) {
execution.setVariable("WorkflowExceptionErrorMessage", errorMessage);
throw new BpmnError(errorCode, errorMessage);