use of org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock in project so by onap.
the class ControllerExecution method setControllerActorScopeAction.
/**
* Setting Controller Actor, Scope and Action Variables in BuildingBlockExecution object
*
* @param execution - BuildingBlockExecution object
*/
public void setControllerActorScopeAction(BuildingBlockExecution execution) {
ExecuteBuildingBlock executeBuildingBlock = execution.getVariable(BUILDING_BLOCK);
BuildingBlock buildingBlock = executeBuildingBlock.getBuildingBlock();
String scope = Optional.ofNullable(buildingBlock.getBpmnScope()).orElseThrow(() -> new NullPointerException("BPMN Scope is NULL in the orchestration_flow_reference table "));
String action = Optional.ofNullable(buildingBlock.getBpmnAction()).orElseThrow(() -> new NullPointerException("BPMN Action is NULL in the orchestration_flow_reference table "));
String controllerActor;
try {
if (String.valueOf(scope).equals("pnf")) {
Pnf pnf = getPnf(execution);
String pnfModelUUID = pnf.getModelInfoPnf().getModelCustomizationUuid();
PnfResourceCustomization pnfResourceCustomization = catalogDbClient.getPnfResourceCustomizationByModelCustomizationUUID(pnfModelUUID);
controllerActor = Optional.ofNullable(pnfResourceCustomization.getControllerActor()).orElse("APPC");
execution.setVariable(MSO_REQUEST_ID, execution.getGeneralBuildingBlock().getRequestContext().getMsoRequestId());
execution.setVariable(PRC_BLUEPRINT_VERSION, pnfResourceCustomization.getBlueprintVersion());
execution.setVariable(PRC_BLUEPRINT_NAME, pnfResourceCustomization.getBlueprintName());
} else if ("service".equalsIgnoreCase(scope)) {
GeneralBuildingBlock gbb = execution.getGeneralBuildingBlock();
ModelInfoServiceInstance modelInfoServiceInstance = gbb.getServiceInstance().getModelInfoServiceInstance();
controllerActor = Optional.ofNullable(modelInfoServiceInstance.getControllerActor()).orElse("CDS");
} else {
GenericVnf genericVnf = getGenericVnf(execution);
String modelUuid = genericVnf.getModelInfoGenericVnf().getModelCustomizationUuid();
VnfResourceCustomization vnfResourceCustomization = catalogDbClient.getVnfResourceCustomizationByModelCustomizationUUID(modelUuid);
controllerActor = Optional.ofNullable(vnfResourceCustomization.getControllerActor()).orElse("APPC");
}
execution.setVariable(SCOPE, scope);
execution.setVariable(ACTION, action);
execution.setVariable(CONTROLLER_ACTOR, controllerActor);
logger.debug("Executing Controller Execution for ControllerActor: {}, Scope: {} , Action: {}", controllerActor, scope, action);
} catch (Exception ex) {
logger.error("An exception occurred while fetching Controller Actor,Scope and Action ", ex);
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
}
}
Aggregations