From a29a743b000873c0b3a56c9a246158dfa45833af Mon Sep 17 00:00:00 2001 From: "raviteja.karumuri" Date: Wed, 3 Aug 2022 20:18:31 +0100 Subject: [SO] Enhance Delete AS Workflow(s) to launch SO CNFM for Delete AS Issue-ID: SO-3886 Signed-off-by: raviteja.karumuri Change-Id: I7776fee0ea812e17052553e03a015863004e9f5d Signed-off-by: raviteja.karumuri --- .../subprocess/BuildingBlock/CnfDeleteBB.bpmn | 46 ++++++++--- .../adapter/cnfm/tasks/CnfDeleteTask.java | 96 +++++++++++++++------- .../adapter/cnfm/tasks/CnfInstantiateTask.java | 16 ++-- .../cnfm/tasks/CnfmHttpServiceProvider.java | 5 ++ .../cnfm/tasks/CnfmHttpServiceProviderImpl.java | 52 +++++++++++- .../adapter/cnfm/tasks/CnfmUrlProvider.java | 9 ++ .../cnfm/tasks/MonitorCnfmCreateJobTask.java | 63 ++++++-------- 7 files changed, 203 insertions(+), 84 deletions(-) (limited to 'bpmn') diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CnfDeleteBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CnfDeleteBB.bpmn index 45d51d78a8..da3577ed61 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CnfDeleteBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CnfDeleteBB.bpmn @@ -7,31 +7,55 @@ Flow_1s7gtbc - - SequenceFlow_016sgof + + Flow_0td4p22 Flow_1s7gtbc - + + + Flow_19rm5pn + Flow_0td4p22 + + + + SequenceFlow_016sgof + Flow_19rm5pn + + + + + + - - + + - - + + + + + + - + - - + + + + + - + + + + diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/CnfDeleteTask.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/CnfDeleteTask.java index 6bbb391ca9..54b87ec2fe 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/CnfDeleteTask.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/CnfDeleteTask.java @@ -19,19 +19,23 @@ */ package org.onap.so.bpmn.infrastructure.adapter.cnfm.tasks; -import org.onap.logging.filter.base.ONAPComponents; +import static org.onap.so.bpmn.servicedecomposition.entities.ResourceKey.GENERIC_VNF_ID; + +import java.net.URI; +import java.util.HashMap; +import java.util.NoSuchElementException; +import java.util.Optional; +import org.camunda.bpm.engine.delegate.BpmnError; import org.onap.so.bpmn.common.BuildingBlockExecution; -import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; -import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; import org.onap.so.client.exception.ExceptionBuilder; -import org.onap.so.serviceinstancebeans.RequestDetails; +import org.onap.so.cnfm.lcm.model.TerminateAsRequest; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import static java.util.Objects.isNull; - /** * This class performs CNF Delete @@ -40,43 +44,79 @@ import static java.util.Objects.isNull; */ @Component public class CnfDeleteTask { - - private static final String AS_INSTANCE_ID = "asInstanceid"; - private static final Logger LOGGER = LoggerFactory.getLogger(CnfInstantiateTask.class); + private static final Logger LOGGER = LoggerFactory.getLogger(CnfDeleteTask.class); private final ExceptionBuilder exceptionUtil; private final CnfmHttpServiceProvider cnfmHttpServiceProvider; + private final ExtractPojosForBB extractPojosForBB; + private static final String CNFM_REQUEST_STATUS_CHECK_URL = "CnfmStatusCheckUrl"; + private static final String TERMINATE_AS_REQUEST_OBJECT = "TerminateAsRequest"; + private static final String MONITOR_JOB_NAME = "MonitorJobName"; @Autowired - public CnfDeleteTask(final CnfmHttpServiceProvider cnfmHttpServiceProvider, final ExceptionBuilder exceptionUtil) { + public CnfDeleteTask(final CnfmHttpServiceProvider cnfmHttpServiceProvider, final ExceptionBuilder exceptionUtil, + ExtractPojosForBB extractPojosForBB) { this.cnfmHttpServiceProvider = cnfmHttpServiceProvider; this.exceptionUtil = exceptionUtil; + this.extractPojosForBB = extractPojosForBB; } - public void invokeCnfmToDeleteAsInstnace(final BuildingBlockExecution execution) { + public void createTerminateAsRequest(final BuildingBlockExecution execution) { try { - LOGGER.debug("Executing DelteAsInstance task ..."); - final ExecuteBuildingBlock executeBuildingBlock = - (ExecuteBuildingBlock) execution.getVariable("buildingBlock"); - - final GeneralBuildingBlock generalBuildingBlock = execution.getGeneralBuildingBlock(); + LOGGER.debug("Executing createTerminateAsRequest task ..."); - final RequestDetails requestDetails = executeBuildingBlock.getRequestDetails(); - LOGGER.debug("RequestDetails of DeleteAsInstance: {}", requestDetails); + final TerminateAsRequest terminateAsRequest = new TerminateAsRequest(); + terminateAsRequest.setTerminationType(TerminateAsRequest.TerminationTypeEnum.GRACEFUL); + terminateAsRequest.setGracefulTerminationTimeout(0); + terminateAsRequest.setAdditionalParams(new HashMap<>()); - if (isNull(requestDetails) && isNull(requestDetails.getModelInfo()) - && isNull(requestDetails.getRequestInfo()) && isNull(requestDetails.getCloudConfiguration()) - && isNull(generalBuildingBlock)) { - LOGGER.error("Missing Mandatory attribute from RequestDetails: {} or GeneralBuildingBlock: {}", - requestDetails, generalBuildingBlock); - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, - "Missing Mandatory attribute from RequestDetails or GeneralBuildingBlock", ONAPComponents.SO); - } + LOGGER.debug("Adding TerminateAsRequest to execution {}", terminateAsRequest); - LOGGER.debug("Finished executing DeleteAsInstance task ..."); + execution.setVariable(TERMINATE_AS_REQUEST_OBJECT, terminateAsRequest); + LOGGER.debug("Finished executing terminateAsRequest task ..."); } catch (final Exception exception) { - LOGGER.error("Unable to invoke DeleteAsInstance", exception); + LOGGER.error("Unable to create TerminateAsRequest", exception); exceptionUtil.buildAndThrowWorkflowException(execution, 2001, exception); } } + + public void invokeCnfmToTerminateAsInstance(final BuildingBlockExecution execution) { + try { + LOGGER.debug("Executing TerminateAsInstance task ..."); + + final TerminateAsRequest terminateAsRequest = execution.getVariable(TERMINATE_AS_REQUEST_OBJECT); + final GenericVnf vnf = extractPojosForBB.extractByKey(execution, GENERIC_VNF_ID); + final String asInstanceId = vnf.getVnfId(); + + Optional terminateStatusCheck = + cnfmHttpServiceProvider.invokeTerminateAsRequest(asInstanceId, terminateAsRequest); + execution.setVariable(CNFM_REQUEST_STATUS_CHECK_URL, + terminateStatusCheck.orElseThrow(() -> new NoSuchElementException("Status check url Not found"))); + execution.setVariable(MONITOR_JOB_NAME, "Terminate"); + LOGGER.debug("Successfully invoked CNFM terminate AS request: {}", asInstanceId); + + } catch (final Exception exception) { + LOGGER.error("Unable to invoke CNFM TerminateAsRequest", exception); + exceptionUtil.buildAndThrowWorkflowException(execution, 2004, exception); + } + } + + public void invokeCnfmToDeleteAsInstance(final BuildingBlockExecution execution) { + try { + LOGGER.debug("Executing DelteAsInstance task ..."); + + final GenericVnf vnf = extractPojosForBB.extractByKey(execution, GENERIC_VNF_ID); + final String asInstanceId = vnf.getVnfId(); + + Optional response = cnfmHttpServiceProvider.invokeDeleteAsRequest(asInstanceId); + if (Boolean.TRUE.equals(response + .orElseThrow(() -> new BpmnError("Unable to complete DeleteAsRequest of ID: " + asInstanceId)))) { + LOGGER.debug("Successfully invoked CNFM delete AS request with ID: {}", asInstanceId); + } + + } catch (final Exception exception) { + LOGGER.error("Unable to invoke CNFM DeleteAsRequest", exception); + exceptionUtil.buildAndThrowWorkflowException(execution, 2004, exception); + } + } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/CnfInstantiateTask.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/CnfInstantiateTask.java index 0071e36ef9..e73c3f1703 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/CnfInstantiateTask.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/CnfInstantiateTask.java @@ -31,6 +31,7 @@ import java.net.URI; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.NoSuchElementException; import java.util.Optional; import org.apache.groovy.util.Maps; import org.onap.logging.filter.base.ONAPComponents; @@ -51,8 +52,6 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import camundajar.impl.scala.collection.immutable.HashMap; - /** * This class performs CNF Instantiation @@ -65,6 +64,7 @@ public class CnfInstantiateTask { private static final String CREATE_AS_REQUEST_OBJECT = "CreateAsRequestObject"; private static final String INSTANTIATE_AS_REQUEST_OBJECT = "InstantiateAsRequest"; private static final String CNFM_REQUEST_STATUS_CHECK_URL = "CnfmStatusCheckUrl"; + private static final String MONITOR_JOB_NAME = "MonitorJobName"; private static final String AS_INSTANCE_ID = "asInstanceid"; private static final Logger LOGGER = LoggerFactory.getLogger(CnfInstantiateTask.class); private final ExceptionBuilder exceptionUtil; @@ -133,7 +133,8 @@ public class CnfInstantiateTask { "Unable to invoke CNFM for CreateAsRequest", ONAPComponents.SO); } - final AsInstance asInstance = optional.get(); + final AsInstance asInstance = + optional.orElseThrow(() -> new NoSuchElementException("AsInstance object is empty")); execution.setVariable(AS_INSTANCE_ID, asInstance.getAsInstanceid()); LOGGER.debug("Successfully invoked CNFM response: {}", asInstance); @@ -153,8 +154,8 @@ public class CnfInstantiateTask { if (requestDetails != null && requestDetails.getRequestParameters() != null) { List> userParams = requestDetails.getRequestParameters().getUserParams(); if (userParams != null && !userParams.isEmpty()) { - List deploymentItems = new ArrayList(); - List deploymentItemsReq = new ArrayList(); + List deploymentItems = new ArrayList<>(); + List deploymentItemsReq = new ArrayList<>(); for (Map userParam : userParams) { if (userParam.containsKey("deploymentItems")) { deploymentItems = (ArrayList) userParam.get("deploymentItems"); @@ -186,9 +187,10 @@ public class CnfInstantiateTask { try { final InstantiateAsRequest instantiateAsRequest = execution.getVariable(INSTANTIATE_AS_REQUEST_OBJECT); final String asInstanceId = execution.getVariable(AS_INSTANCE_ID); - Optional cnf_status_check_url = + Optional cnfStatusCheckURL = cnfmHttpServiceProvider.invokeInstantiateAsRequest(instantiateAsRequest, asInstanceId); - execution.setVariable(CNFM_REQUEST_STATUS_CHECK_URL, cnf_status_check_url.get()); + execution.setVariable(CNFM_REQUEST_STATUS_CHECK_URL, cnfStatusCheckURL.orElseThrow()); + execution.setVariable(MONITOR_JOB_NAME, "Instantiate"); LOGGER.debug("Successfully invoked CNFM instantiate AS request: {}", asInstanceId); } catch (final Exception exception) { LOGGER.error("Unable to invoke CNFM InstantiateAsRequest", exception); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/CnfmHttpServiceProvider.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/CnfmHttpServiceProvider.java index 556d1a172b..06784a0564 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/CnfmHttpServiceProvider.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/CnfmHttpServiceProvider.java @@ -26,6 +26,7 @@ import org.onap.so.cnfm.lcm.model.AsInstance; import org.onap.so.cnfm.lcm.model.AsLcmOpOcc; import org.onap.so.cnfm.lcm.model.CreateAsRequest; import org.onap.so.cnfm.lcm.model.InstantiateAsRequest; +import org.onap.so.cnfm.lcm.model.TerminateAsRequest; /** * @author Sagar Shetty (sagar.shetty@est.tech) @@ -39,4 +40,8 @@ public interface CnfmHttpServiceProvider { Optional invokeInstantiateAsRequest(InstantiateAsRequest instantiateAsRequest, String asInstanceId); Optional getInstantiateOperationJobStatus(final String url); + + Optional invokeDeleteAsRequest(final String asInstanceId); + + Optional invokeTerminateAsRequest(String asInstanceId, TerminateAsRequest terminateAsRequest); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/CnfmHttpServiceProviderImpl.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/CnfmHttpServiceProviderImpl.java index 709c5c5758..ed0bc3937b 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/CnfmHttpServiceProviderImpl.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/CnfmHttpServiceProviderImpl.java @@ -23,11 +23,11 @@ import static org.onap.so.bpmn.infrastructure.adapter.cnfm.tasks.CnfmHttpService import java.net.URI; import java.util.Optional; - import org.onap.so.cnfm.lcm.model.AsInstance; import org.onap.so.cnfm.lcm.model.AsLcmOpOcc; import org.onap.so.cnfm.lcm.model.CreateAsRequest; import org.onap.so.cnfm.lcm.model.InstantiateAsRequest; +import org.onap.so.cnfm.lcm.model.TerminateAsRequest; import org.onap.so.rest.exceptions.HttpResouceNotFoundException; import org.onap.so.rest.exceptions.InvalidRestRequestException; import org.onap.so.rest.exceptions.RestProcessingException; @@ -136,4 +136,54 @@ public class CnfmHttpServiceProviderImpl implements CnfmHttpServiceProvider { } } + @Override + public Optional invokeDeleteAsRequest(String asInstanceId) { + try { + + final String url = cnfmUrlProvider.getDeleteAsRequestUrl(asInstanceId); + LOGGER.debug("Will send request to CNFM by uisng the url: {}", url); + + ResponseEntity response = httpServiceProvider.deleteHttpRequest(url, Void.class); + final HttpStatus httpStatus = response.getStatusCode(); + if (!(httpStatus.is2xxSuccessful())) { + LOGGER.error("Unable to invoke HTTP DELETE using URL: {}, Response Code: {}", url, httpStatus.value()); + return Optional.empty(); + } + return Optional.of(Boolean.TRUE); + } catch (final RestProcessingException | InvalidRestRequestException + | HttpResouceNotFoundException httpInvocationException) { + LOGGER.error("Unexpected error while processing delete request", httpInvocationException); + return Optional.empty(); + } + } + + @Override + public Optional invokeTerminateAsRequest(String asInstanceId, TerminateAsRequest terminateAsRequest) { + try { + + final String url = cnfmUrlProvider.getTerminateAsRequestUrl(asInstanceId); + LOGGER.debug("Will send request to CNFM to terminate by uisng the url: {}", url); + + ResponseEntity response = httpServiceProvider.postHttpRequest(terminateAsRequest, url, Void.class); + final HttpStatus httpStatus = response.getStatusCode(); + if (httpStatus.is2xxSuccessful()) { + URI statusUri = response.getHeaders().getLocation(); + if (statusUri == null) { + LOGGER.error("Received response without status URL while terminating of instance with ID: {}", + asInstanceId); + return Optional.empty(); + } + return Optional.of(statusUri); + } + LOGGER.error("Unable to invoke HTTP DELETE while terminating by using URL: {}, Response Code: {}", url, + httpStatus.value()); + return Optional.empty(); + + } catch (final RestProcessingException | InvalidRestRequestException + | HttpResouceNotFoundException httpInvocationException) { + LOGGER.error("Unexpected error while processing terminate request", httpInvocationException); + return Optional.empty(); + } + } + } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/CnfmUrlProvider.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/CnfmUrlProvider.java index 6cd5d1e262..a7dbf9322b 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/CnfmUrlProvider.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/CnfmUrlProvider.java @@ -49,4 +49,13 @@ public class CnfmUrlProvider { .pathSegment("instantiate").build().toString(); } + public String getDeleteAsRequestUrl(String asInstanceId) { + return UriComponentsBuilder.fromUri(baseUri).pathSegment("as_instances").pathSegment(asInstanceId).build() + .toString(); + } + + public String getTerminateAsRequestUrl(String asInstanceId) { + return UriComponentsBuilder.fromUri(baseUri).pathSegment("as_instances").pathSegment(asInstanceId) + .pathSegment("terminate").build().toString(); + } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/MonitorCnfmCreateJobTask.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/MonitorCnfmCreateJobTask.java index 323141365d..40a26cfaf9 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/MonitorCnfmCreateJobTask.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/MonitorCnfmCreateJobTask.java @@ -23,22 +23,18 @@ import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.CREAT import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.OPERATION_STATUS_PARAM_NAME; import java.net.URI; +import java.util.NoSuchElementException; import java.util.Optional; - -import org.onap.so.adapters.etsisol003adapter.lcm.v1.model.CreateVnfResponse; -import org.onap.so.adapters.etsisol003adapter.lcm.v1.model.QueryJobResponse; +import java.util.Set; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.client.exception.ExceptionBuilder; +import org.onap.so.cnfm.lcm.model.AsLcmOpOcc; +import org.onap.so.cnfm.lcm.model.AsLcmOpOcc.OperationStateEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import com.google.common.collect.ImmutableSet; - -import org.onap.so.cnfm.lcm.model.AsLcmOpOcc; -import org.onap.so.cnfm.lcm.model.AsLcmOpOcc.OperationStateEnum; - /** * @author sagar.shetty@est.tech @@ -48,8 +44,9 @@ import org.onap.so.cnfm.lcm.model.AsLcmOpOcc.OperationStateEnum; public class MonitorCnfmCreateJobTask { private static final String CNFM_REQUEST_STATUS_CHECK_URL = "CnfmStatusCheckUrl"; - public static final ImmutableSet OPERATION_FINISHED_STATES = - ImmutableSet.of(OperationStateEnum.COMPLETED, OperationStateEnum.FAILED, OperationStateEnum.ROLLED_BACK); + private static final String MONITOR_JOB_NAME = "MonitorJobName"; + public static final Set OPERATION_FINISHED_STATES = + Set.of(OperationStateEnum.COMPLETED, OperationStateEnum.FAILED, OperationStateEnum.ROLLED_BACK); private static final Logger LOGGER = LoggerFactory.getLogger(MonitorCnfmCreateJobTask.class); protected final ExceptionBuilder exceptionUtil; private final CnfmHttpServiceProvider cnfmHttpServiceProvider; @@ -69,10 +66,11 @@ public class MonitorCnfmCreateJobTask { public void getCurrentOperationStatus(final BuildingBlockExecution execution) { try { LOGGER.debug("Executing getCurrentOperationStatus ..."); - final URI operation_status_url = execution.getVariable(CNFM_REQUEST_STATUS_CHECK_URL); - LOGGER.debug("Executing getCurrentOperationStatus for CNF... :{}", operation_status_url.toString()); + final Optional operationStatusURL = Optional.of(execution.getVariable(CNFM_REQUEST_STATUS_CHECK_URL)); + LOGGER.debug("Executing getCurrentOperationStatus for CNF... :{}", operationStatusURL); final Optional instantiateOperationJobStatus = - cnfmHttpServiceProvider.getInstantiateOperationJobStatus(operation_status_url.toString()); + cnfmHttpServiceProvider.getInstantiateOperationJobStatus(String.valueOf(operationStatusURL + .orElseThrow(() -> new NoSuchElementException("Operational Status check url Not found")))); if (instantiateOperationJobStatus.isPresent()) { final AsLcmOpOcc asLcmOpOccResponse = instantiateOperationJobStatus.get(); if (asLcmOpOccResponse.getOperationState() != null) { @@ -81,17 +79,15 @@ public class MonitorCnfmCreateJobTask { operationStatus, asLcmOpOccResponse.getOperationState()); execution.setVariable(OPERATION_STATUS_PARAM_NAME, asLcmOpOccResponse.getOperationState()); } - LOGGER.debug("Operation {} without operationStatus and operation retrieval status :{}", asLcmOpOccResponse.getId(), asLcmOpOccResponse.getOperationState()); } - execution.setVariable(CREATE_CNF_STATUS_RESPONSE_PARAM_NAME, instantiateOperationJobStatus.get()); + execution.setVariable(CREATE_CNF_STATUS_RESPONSE_PARAM_NAME, + instantiateOperationJobStatus.isPresent() ? instantiateOperationJobStatus.get() : " "); LOGGER.debug("Finished executing getCurrentOperationStatus for CNF..."); } catch (final Exception exception) { - final String message = "Unable to invoke get current Operation status"; - LOGGER.error(message); - exceptionUtil.buildAndThrowWorkflowException(execution, 1209, message); - + LOGGER.error("Unable to invoke get current Operation status"); + exceptionUtil.buildAndThrowWorkflowException(execution, 1209, exception); } } @@ -100,10 +96,10 @@ public class MonitorCnfmCreateJobTask { * * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl} */ - public void timeOutLogFailue(final BuildingBlockExecution execution) { - final String message = "CNF Instantiation operation time out"; + public void timeOutLogFailure(final BuildingBlockExecution execution) { + String message = "CNF" + execution.getVariable(MONITOR_JOB_NAME) + "operation time out"; LOGGER.error(message); - exceptionUtil.buildAndThrowWorkflowException(execution, 1205, message); + exceptionUtil.buildAndThrowWorkflowException(execution, 1205, new Exception(message)); } /** @@ -115,22 +111,15 @@ public class MonitorCnfmCreateJobTask { LOGGER.debug("Executing CNF checkIfOperationWasSuccessful ..."); final OperationStateEnum operationStatusOption = execution.getVariable(OPERATION_STATUS_PARAM_NAME); final AsLcmOpOcc cnfInstantiateStautusResponse = execution.getVariable(CREATE_CNF_STATUS_RESPONSE_PARAM_NAME); - if (operationStatusOption == null) { - final String message = "Unable to instantiate CNF jobId: " - + (cnfInstantiateStautusResponse != null ? cnfInstantiateStautusResponse.getId() : "null") - + "Unable to retrieve OperationStatus"; + if ((operationStatusOption == OperationStateEnum.FAILED) + || (operationStatusOption == OperationStateEnum.FAILED_TEMP)) { + final String message = "Unable to" + execution.getVariable(MONITOR_JOB_NAME) + "CNF jobId: " + + (cnfInstantiateStautusResponse != null ? cnfInstantiateStautusResponse.getId() : "null"); LOGGER.error(message); - exceptionUtil.buildAndThrowWorkflowException(execution, 1206, message); - } else { - final OperationStateEnum operationStatus = operationStatusOption; - if (operationStatus != OperationStateEnum.COMPLETED) { - final String message = "Unable to instantiate jobId: " - + (cnfInstantiateStautusResponse != null ? cnfInstantiateStautusResponse.getId() : "null") - + " OperationStatus: " + operationStatus; - LOGGER.error(message); - exceptionUtil.buildAndThrowWorkflowException(execution, 1207, message); - } - LOGGER.debug("Successfully completed CNF instatiation of job status {}", cnfInstantiateStautusResponse); + exceptionUtil.buildAndThrowWorkflowException(execution, 1206, new Exception()); + } else if ((operationStatusOption == OperationStateEnum.COMPLETED)) { + String monitorJobName = execution.getVariable(MONITOR_JOB_NAME); + LOGGER.debug("Successfully completed CNF {} job", monitorJobName); } } -- cgit 1.2.3-korg