import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
+import static org.onap.so.bpmn.infrastructure.service.composition.ServiceCompositionConstants.CHILD_SVC_REQ_CORRELATION_ID;
+import static org.onap.so.bpmn.infrastructure.service.composition.ServiceCompositionConstants.CHILD_SVC_REQ_ERROR;
+import static org.onap.so.bpmn.infrastructure.service.composition.ServiceCompositionConstants.CHILD_SVC_REQ_MESSAGE_NAME;
+import static org.onap.so.bpmn.infrastructure.service.composition.ServiceCompositionConstants.CHILD_SVC_REQ_STATUS;
+import static org.onap.so.bpmn.infrastructure.service.composition.ServiceCompositionConstants.IS_CHILD_PROCESS;
+import static org.onap.so.bpmn.infrastructure.service.composition.ServiceCompositionConstants.PARENT_CORRELATION_ID;
@Component
public class WorkflowActionBBFailure {
private static final String DELETE_FABRIC_CONFIGURATION_FLOW = "DeleteFabricConfigurationBB";
private static final Logger logger = LoggerFactory.getLogger(WorkflowActionBBFailure.class);
public static final String ROLLBACK_TARGET_STATE = "rollbackTargetState";
+
@Autowired
private RequestsDbClient requestDbclient;
@Autowired
InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId);
String rollbackErrorMsg = "";
String errorMsg = "";
+ String childErrorMessage = "";
Boolean rollbackCompletedSuccessfully = (Boolean) execution.getVariable("isRollbackComplete");
Boolean isRollbackFailure = (Boolean) execution.getVariable("isRollback");
ExecuteBuildingBlock ebb = (ExecuteBuildingBlock) execution.getVariable("buildingBlock");
if (rollbackCompletedSuccessfully) {
rollbackErrorMsg = "Rollback has been completed successfully.";
+ childErrorMessage = rollbackErrorMsg;
request.setRollbackStatusMessage(rollbackErrorMsg);
execution.setVariable("RollbackErrorMessage", rollbackErrorMsg);
String rollbackTargetState = (String) execution.getVariable(ROLLBACK_TARGET_STATE);
} else {
rollbackErrorMsg = "Failed to determine rollback error message.";
}
+ childErrorMessage = rollbackErrorMsg;
request.setRollbackStatusMessage(rollbackErrorMsg);
execution.setVariable("RollbackErrorMessage", rollbackErrorMsg);
request.setRequestStatus(Status.FAILED.toString());
} else {
errorMsg = "Failed to determine error message";
}
+ childErrorMessage = errorMsg;
request.setStatusMessage(errorMsg);
execution.setVariable("ErrorMessage", errorMsg);
String handlingCode = (String) execution.getVariable("handlingCode");
execution.setVariable("flowStatus", flowStatus);
}
+ if (Boolean.TRUE.equals(execution.getVariable(IS_CHILD_PROCESS))) {
+ String parentCorrelationId = (String) execution.getVariable(PARENT_CORRELATION_ID);
+ logger.info("Child service creation failed. Sending message to parent with correlationId: "
+ + parentCorrelationId);
+ execution.getProcessEngineServices().getRuntimeService()
+ .createMessageCorrelation(CHILD_SVC_REQ_MESSAGE_NAME)
+ .setVariable(CHILD_SVC_REQ_STATUS, "FAILED").setVariable(CHILD_SVC_REQ_ERROR, childErrorMessage)
+ .processInstanceVariableEquals(CHILD_SVC_REQ_CORRELATION_ID, parentCorrelationId).correlate();
+ }
+
request.setProgress(Long.valueOf(100));
request.setLastModifiedBy("CamundaBPMN");
request.setEndTime(new Timestamp(System.currentTimeMillis()));