From cc805b184620525115c88c1a52ddfde55c73e15b Mon Sep 17 00:00:00 2001 From: "Gamboa, Gilbert" Date: Fri, 5 Jul 2019 10:30:58 -0400 Subject: mso will support new requeststate values Support new request status - ROLLED_BACK, ROLLED_BACK_TO_ASSIGNED, ROLLED_BACK_TO_CREATED, and ABORTED. Support new request status - ROLLED_BACK, ROLLED_BACK_TO_ASSIGNED, ROLLED_BACK_TO_CREATED, and ABORTED. Added default FAILED request status in case rollback is not needed. Variable rollbackTargetState needs to be returned to WorkflowAction flow Variable rollbackTargetState needs to in to ExecuteBuildingBlock as well. Add new RequestDb migration file to expand infra_active_requests column request_status to 25 bytes to fit new request states. Change-Id: I0da2f8013001a28dcc20f64eb9455e4cfd3dd197 Issue-ID: SO-2093 Signed-off-by: Benjamin, Max (mb388a) --- .../workflow/tasks/WorkflowActionBBFailure.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'bpmn/so-bpmn-tasks/src/main') 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 67dc9fec26..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 @@ -89,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 rollbackErrorMsgOp = retrieveErrorMessage(execution); if (rollbackErrorMsgOp.isPresent()) { @@ -98,6 +102,7 @@ public class WorkflowActionBBFailure { } request.setRollbackStatusMessage(rollbackErrorMsg); execution.setVariable("RollbackErrorMessage", rollbackErrorMsg); + request.setRequestStatus(Status.FAILED.toString()); } else { Optional errorMsgOp = retrieveErrorMessage(execution); if (errorMsgOp.isPresent()) { @@ -107,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 = ""; @@ -120,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); -- cgit 1.2.3-korg