aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/MSOCommonBPMN/src/main
diff options
context:
space:
mode:
authorBoslet, Cory <cory.boslet@att.com>2019-05-31 11:46:57 -0400
committerBenjamin, Max (mb388a) <mb388a@us.att.com>2019-05-31 11:47:10 -0400
commite74e48d9e7eec31c468db238f7f2edd9e6961923 (patch)
tree0434f30ecb8737cd9d3eab3eb2e0abf46697da35 /bpmn/MSOCommonBPMN/src/main
parentec71f01963e4c5c70d11f41842c7cd9cfd38316d (diff)
Added NPE check for audit
Added NPE check so that flow continues when no audit results present Change-Id: I614dbaff7eaaca86a503da2734d7c5f7a197bb1b Issue-ID: SO-1959 Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'bpmn/MSOCommonBPMN/src/main')
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java106
1 files changed, 54 insertions, 52 deletions
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");
}
}
+
}