aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks/src/main/java
diff options
context:
space:
mode:
authorraviteja.karumuri <raviteja.karumuri@est.tech>2022-08-03 20:18:31 +0100
committerraviteja.karumuri <raviteja.karumuri@est.tech>2022-08-10 12:10:29 +0100
commita29a743b000873c0b3a56c9a246158dfa45833af (patch)
tree5329046ea4634f0485d8965259b9c34670899486 /bpmn/so-bpmn-tasks/src/main/java
parente7bbcbba4e6106c1eef3f7a252cc4ed9b3067fd7 (diff)
[SO] Enhance Delete AS Workflow(s) to launch SO CNFM for Delete AS
Issue-ID: SO-3886 Signed-off-by: raviteja.karumuri <raviteja.karumuri@est.tech> Change-Id: I7776fee0ea812e17052553e03a015863004e9f5d Signed-off-by: raviteja.karumuri <raviteja.karumuri@est.tech>
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/main/java')
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/CnfDeleteTask.java96
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/CnfInstantiateTask.java16
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/CnfmHttpServiceProvider.java5
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/CnfmHttpServiceProviderImpl.java52
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/CnfmUrlProvider.java9
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/MonitorCnfmCreateJobTask.java63
6 files changed, 168 insertions, 73 deletions
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<URI> 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<Boolean> 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<Map<String, Object>> userParams = requestDetails.getRequestParameters().getUserParams();
if (userParams != null && !userParams.isEmpty()) {
- List deploymentItems = new ArrayList<Object>();
- List deploymentItemsReq = new ArrayList<AsInfoModificationRequestDeploymentItems>();
+ List<Object> deploymentItems = new ArrayList<>();
+ List<AsInfoModificationRequestDeploymentItems> deploymentItemsReq = new ArrayList<>();
for (Map<String, Object> userParam : userParams) {
if (userParam.containsKey("deploymentItems")) {
deploymentItems = (ArrayList<Object>) 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<URI> cnf_status_check_url =
+ Optional<URI> 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<URI> invokeInstantiateAsRequest(InstantiateAsRequest instantiateAsRequest, String asInstanceId);
Optional<AsLcmOpOcc> getInstantiateOperationJobStatus(final String url);
+
+ Optional<Boolean> invokeDeleteAsRequest(final String asInstanceId);
+
+ Optional<URI> 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<Boolean> invokeDeleteAsRequest(String asInstanceId) {
+ try {
+
+ final String url = cnfmUrlProvider.getDeleteAsRequestUrl(asInstanceId);
+ LOGGER.debug("Will send request to CNFM by uisng the url: {}", url);
+
+ ResponseEntity<Void> 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<URI> 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<Void> 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<OperationStateEnum> OPERATION_FINISHED_STATES =
- ImmutableSet.of(OperationStateEnum.COMPLETED, OperationStateEnum.FAILED, OperationStateEnum.ROLLED_BACK);
+ private static final String MONITOR_JOB_NAME = "MonitorJobName";
+ public static final Set<OperationStateEnum> 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<URI> operationStatusURL = Optional.of(execution.getVariable(CNFM_REQUEST_STATUS_CHECK_URL));
+ LOGGER.debug("Executing getCurrentOperationStatus for CNF... :{}", operationStatusURL);
final Optional<AsLcmOpOcc> 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);
}
}