diff options
Diffstat (limited to 'bpmn/MSOCommonBPMN')
3 files changed, 58 insertions, 55 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/recipe/ResourceInput.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/recipe/ResourceInput.java index 33c48fbe44..91049a8d0c 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/recipe/ResourceInput.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/recipe/ResourceInput.java @@ -21,6 +21,7 @@ */ package org.onap.so.bpmn.common.recipe; +import java.io.Serializable; import org.onap.so.bpmn.core.domain.ModelInfo; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; @@ -43,7 +44,7 @@ import org.slf4j.LoggerFactory; "operationId", "serviceModelInfo", "resourceModelInfo", "resourceInstancenUuid", "resourceParameters", "operationType"}) @JsonRootName("variables") -public class ResourceInput { +public class ResourceInput implements Serializable { private static Logger logger = LoggerFactory.getLogger(ResourceInput.class); diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java index dabfc81e1f..870b936f5c 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java @@ -153,65 +153,67 @@ public class ExceptionBuilder { } public void processAuditException(DelegateExecutionImpl execution, boolean flowShouldContinue) { - logger.info("Building a WorkflowException for Subflow"); + logger.debug("Processing Audit Results"); + String auditListString = (String) execution.getVariable("auditInventoryResult"); + if (auditListString != null) { + StringBuilder errorMessage = new StringBuilder(); + String processKey = getProcessKey(execution.getDelegateExecution()); + try { + ExtractPojosForBB extractPojosForBB = getExtractPojosForBB(); + VfModule module = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID); + String cloudRegionId = execution.getGeneralBuildingBlock().getCloudRegion().getLcpCloudRegionId(); + + GraphInventoryCommonObjectMapperProvider objectMapper = new GraphInventoryCommonObjectMapperProvider(); + AAIObjectAuditList auditList = + objectMapper.getMapper().readValue(auditListString, AAIObjectAuditList.class); + + errorMessage = errorMessage.append(auditList.getAuditType() + " VF-Module " + module.getVfModuleId() + + " failed due to incomplete AAI vserver inventory population after stack " + + auditList.getHeatStackName() + " was successfully " + auditList.getAuditType() + + "d in cloud region " + cloudRegionId + ". MSO Audit indicates that the following was not " + + auditList.getAuditType() + "d in AAI: "); + + Stream<AAIObjectAudit> vServerLInterfaceAuditStream = auditList.getAuditList().stream() + .filter(auditObject -> auditObject.getAaiObjectType().equals(AAIObjectType.VSERVER.typeName()) + || auditObject.getAaiObjectType().equals(AAIObjectType.L_INTERFACE.typeName())); + List<AAIObjectAudit> filteredAuditStream = + vServerLInterfaceAuditStream.filter(a -> !a.isDoesObjectExist()).collect(Collectors.toList()); + + for (AAIObjectAudit object : filteredAuditStream) { + if (object.getAaiObjectType().equals(AAIObjectType.L_INTERFACE.typeName())) { + LInterface li = objectMapper.getMapper().convertValue(object.getAaiObject(), LInterface.class); + errorMessage = errorMessage + .append(AAIObjectType.L_INTERFACE.typeName() + " " + li.getInterfaceId() + ", "); + } else { + Vserver vs = objectMapper.getMapper().convertValue(object.getAaiObject(), Vserver.class); + errorMessage = + errorMessage.append(AAIObjectType.VSERVER.typeName() + " " + vs.getVserverId() + ", "); + } + } - StringBuilder errorMessage = new StringBuilder(); - String processKey = getProcessKey(execution.getDelegateExecution()); - try { - ExtractPojosForBB extractPojosForBB = getExtractPojosForBB(); - VfModule module = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID); - String cloudRegionId = execution.getGeneralBuildingBlock().getCloudRegion().getLcpCloudRegionId(); - - GraphInventoryCommonObjectMapperProvider objectMapper = new GraphInventoryCommonObjectMapperProvider(); - String auditListString = (String) execution.getVariable("auditInventoryResult"); - AAIObjectAuditList auditList = - objectMapper.getMapper().readValue(auditListString, AAIObjectAuditList.class); - - errorMessage = errorMessage.append(auditList.getAuditType() + " VF-Module " + module.getVfModuleId() - + " failed due to incomplete A&AI vserver inventory population after stack " - + auditList.getHeatStackName() + " was successfully " + auditList.getAuditType() - + "d in cloud region " + cloudRegionId + ". MSO Audit indicates that AIC RO did not " - + auditList.getAuditType() + " "); - - Stream<AAIObjectAudit> vServerLInterfaceAuditStream = auditList.getAuditList().stream() - .filter(auditObject -> auditObject.getAaiObjectType().equals(AAIObjectType.VSERVER.typeName()) - || auditObject.getAaiObjectType().equals(AAIObjectType.L_INTERFACE.typeName())); - List<AAIObjectAudit> filteredAuditStream = - vServerLInterfaceAuditStream.filter(a -> !a.isDoesObjectExist()).collect(Collectors.toList()); - - for (AAIObjectAudit object : filteredAuditStream) { - if (object.getAaiObjectType().equals(AAIObjectType.L_INTERFACE.typeName())) { - LInterface li = objectMapper.getMapper().convertValue(object.getAaiObject(), LInterface.class); - errorMessage = errorMessage - .append(AAIObjectType.L_INTERFACE.typeName() + " " + li.getInterfaceId() + ", "); - } else { - Vserver vs = objectMapper.getMapper().convertValue(object.getAaiObject(), Vserver.class); - errorMessage = - errorMessage.append(AAIObjectType.VSERVER.typeName() + " " + vs.getVserverId() + ", "); + if (errorMessage.length() > 0) { + errorMessage.setLength(errorMessage.length() - 2); + errorMessage = errorMessage.append("."); } - } - if (errorMessage.length() > 0) { - errorMessage.setLength(errorMessage.length() - 2); - errorMessage = errorMessage.append(" in AAI. "); + } catch (IOException | BBObjectNotFoundException e) { + errorMessage = errorMessage.append("process objects in AAI. "); } - } catch (IOException | BBObjectNotFoundException e) { - errorMessage = errorMessage.append("process objects in AAI. "); - } - - errorMessage.append( - "Recommendation - Wait for nightly RO Audit to run and fix the data issue and resume vf-module creation in VID. If problem persists then report problem to AIC/RO Ops."); + if (flowShouldContinue) { + execution.setVariable("StatusMessage", errorMessage.toString()); + } else { + WorkflowException exception = new WorkflowException(processKey, 400, errorMessage.toString()); + execution.setVariable("WorkflowException", exception); + execution.setVariable("WorkflowExceptionErrorMessage", errorMessage.toString()); + logger.info("Outgoing WorkflowException is {}", exception); + logger.info("Throwing MSOWorkflowException"); + throw new BpmnError("AAIInventoryFailure"); + } - if (flowShouldContinue) { - execution.setVariable("StatusMessage", errorMessage.toString()); } else { - WorkflowException exception = new WorkflowException(processKey, 400, errorMessage.toString()); - execution.setVariable("WorkflowException", exception); - execution.setVariable("WorkflowExceptionErrorMessage", errorMessage.toString()); - logger.info("Outgoing WorkflowException is {}", exception); - logger.info("Throwing MSOWorkflowException"); - throw new BpmnError("AAIInventoryFailure"); + logger.debug("Unable to process audit results due to auditInventoryResult being null"); } } + } diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/exception/ExceptionBuilderTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/exception/ExceptionBuilderTest.java index 549f16b6f6..5f9aef67e6 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/exception/ExceptionBuilderTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/exception/ExceptionBuilderTest.java @@ -138,7 +138,7 @@ public class ExceptionBuilderTest extends BaseTest { WorkflowException we = execution.getVariable("WorkflowException"); assertNotNull(we); assertEquals( - "create VF-Module testVfModuleId1 failed due to incomplete A&AI vserver inventory population after stack testStackName was successfully created in cloud region testLcpCloudRegionId. MSO Audit indicates that AIC RO did not create vserver testVServerId in AAI. Recommendation - Wait for nightly RO Audit to run and fix the data issue and resume vf-module creation in VID. If problem persists then report problem to AIC/RO Ops.", + "create VF-Module testVfModuleId1 failed due to incomplete AAI vserver inventory population after stack testStackName was successfully created in cloud region testLcpCloudRegionId. MSO Audit indicates that the following was not created in AAI: vserver testVServerId.", we.getErrorMessage()); } } @@ -151,7 +151,7 @@ public class ExceptionBuilderTest extends BaseTest { String sm = execution.getVariable("StatusMessage"); assertNotNull(sm); assertEquals( - "create VF-Module testVfModuleId1 failed due to incomplete A&AI vserver inventory population after stack testStackName was successfully created in cloud region testLcpCloudRegionId. MSO Audit indicates that AIC RO did not create vserver testVServerId in AAI. Recommendation - Wait for nightly RO Audit to run and fix the data issue and resume vf-module creation in VID. If problem persists then report problem to AIC/RO Ops.", + "create VF-Module testVfModuleId1 failed due to incomplete AAI vserver inventory population after stack testStackName was successfully created in cloud region testLcpCloudRegionId. MSO Audit indicates that the following was not created in AAI: vserver testVServerId.", sm); } catch (BpmnError bpmnException) { fail(); |