1 package org.onap.so.bpmn.infrastructure.pnf.tasks;
3 import joptsimple.internal.Strings;
4 import org.onap.so.bpmn.common.BuildingBlockExecution;
5 import org.onap.so.client.exception.BBObjectNotFoundException;
6 import org.slf4j.Logger;
7 import org.slf4j.LoggerFactory;
8 import org.springframework.stereotype.Component;
9 import java.io.IOException;
10 import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.AAI_CONTAINS_INFO_ABOUT_PNF;
11 import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_CORRELATION_ID;
14 public class CheckAaiForPnfCorrelationId extends PnfBaseTasks {
15 private static final Logger logger = LoggerFactory.getLogger(CheckAaiForPnfCorrelationId.class);
18 public void execute(BuildingBlockExecution execution) {
20 String pnfCorrelationId = extractPnf(execution).getPnfName();
21 checkIfPnfCorrelationIdPresent(execution, pnfCorrelationId);
22 checkIfPnfExistsInAai(execution, pnfCorrelationId);
23 } catch (BBObjectNotFoundException e) {
24 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, e);
29 private void checkIfPnfCorrelationIdPresent(BuildingBlockExecution execution, String pnfCorrelationId) {
30 if (Strings.isNullOrEmpty(pnfCorrelationId)) {
31 exceptionUtil.buildAndThrowWorkflowException(execution, 500, PNF_CORRELATION_ID + " is not set");
35 private void checkIfPnfExistsInAai(BuildingBlockExecution execution, String pnfCorrelationId) {
37 boolean isEntry = pnfManagement.getEntryFor(pnfCorrelationId).isPresent();
38 logger.debug("AAI entry is found for pnf correlation id {}: {}", PNF_CORRELATION_ID, isEntry);
39 execution.setVariable(AAI_CONTAINS_INFO_ABOUT_PNF, isEntry);
40 } catch (IOException e) {
41 logger.error("Exception in check AAI for pnf_correlation_id execution", e);
42 exceptionUtil.buildAndThrowWorkflowException(execution, 9999, e);