diff options
Diffstat (limited to 'controlloop/common/actors/actor.so')
-rw-r--r-- | controlloop/common/actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SOActorServiceProvider.java | 66 |
1 files changed, 19 insertions, 47 deletions
diff --git a/controlloop/common/actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SOActorServiceProvider.java b/controlloop/common/actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SOActorServiceProvider.java index 8c1b23af9..b31906334 100644 --- a/controlloop/common/actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SOActorServiceProvider.java +++ b/controlloop/common/actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SOActorServiceProvider.java @@ -27,9 +27,9 @@ import java.util.Map; import java.util.UUID; import org.drools.core.WorkingMemory; +import org.onap.policy.aai.AAIManager; import org.onap.policy.aai.AAINQInstanceFilters; import org.onap.policy.aai.AAINQInventoryResponseItem; -import org.onap.policy.aai.AAIManager; import org.onap.policy.aai.AAINQNamedQuery; import org.onap.policy.aai.AAINQQueryParameters; import org.onap.policy.aai.AAINQRequest; @@ -202,12 +202,17 @@ public class SOActorServiceProvider implements Actor { // insert aainqResponseWrapper to memory -- Is this needed? // insert(aainqResponseWrapper); - // + if (logger.isDebugEnabled()) { + logger.debug("AAI Named Query Response: "); + logger.debug(Serialization.gsonPretty.toJson(aainqResponseWrapper.aainqresponse)); + } + extractSOFieldsFromNamedQuery(aainqResponseWrapper, onset); return aainqResponseWrapper; } } + /** * Extract the required fields from the named query response * @param namedQueryResponseWrapper @@ -236,22 +241,19 @@ public class SOActorServiceProvider implements Actor { // Find the index for base vf module and non-base vf module int baseIndex = -1; - int nonBaseIndex = -1; List<AAINQInventoryResponseItem> inventoryItems = namedQueryResponseWrapper.aainqresponse.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems; for (AAINQInventoryResponseItem m : inventoryItems) { if (m.vfModule != null && m.vfModule.isBaseVfModule) { baseIndex = inventoryItems.indexOf(m); - } else if (m.vfModule != null && m.vfModule.orchestrationStatus == null) { - nonBaseIndex = inventoryItems.indexOf(m); - } + } // - if (baseIndex != -1 && nonBaseIndex != -1) { + if (baseIndex != -1) { break; } } // Report the error if either base vf module or non-base vf module is not found - if (baseIndex == -1 || nonBaseIndex == -1) { + if (baseIndex == -1) { logger.error("Either base or non-base vf module is not found from AAI response."); return; } @@ -261,49 +263,19 @@ public class SOActorServiceProvider implements Actor { setVfModuleItemVfModuleName(vfModuleItemVfModuleName.replace("Vfmodule", "vDNS")); // vfModuleItem - NOT the base module - setVfModuleItemModelInvariantId(namedQueryResponseWrapper.aainqresponse.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(nonBaseIndex).vfModule.modelInvariantId); - setVfModuleItemModelVersionId(namedQueryResponseWrapper.aainqresponse.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(nonBaseIndex).vfModule.modelVersionId); - setVfModuleItemModelName(namedQueryResponseWrapper.aainqresponse.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(nonBaseIndex).extraProperties.extraProperty.get(0).propertyValue); - setVfModuleItemModelNameVersionId(namedQueryResponseWrapper.aainqresponse.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(nonBaseIndex).extraProperties.extraProperty.get(4).propertyValue); + setVfModuleItemModelInvariantId(namedQueryResponseWrapper.aainqresponse.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(baseIndex).vfModule.modelInvariantId); + setVfModuleItemModelVersionId(namedQueryResponseWrapper.aainqresponse.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(baseIndex).vfModule.modelVersionId); + setVfModuleItemModelName(namedQueryResponseWrapper.aainqresponse.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(baseIndex).extraProperties.extraProperty.get(0).propertyValue); + setVfModuleItemModelNameVersionId(namedQueryResponseWrapper.aainqresponse.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(baseIndex).extraProperties.extraProperty.get(4).propertyValue); // tenantItem setTenantItemTenantId(namedQueryResponseWrapper.aainqresponse.inventoryResponseItems.get(0).items.inventoryResponseItems.get(1).tenant.tenantId); // cloudRegionItem setCloudRegionItemCloudRegionId(namedQueryResponseWrapper.aainqresponse.inventoryResponseItems.get(0).items.inventoryResponseItems.get(1).items.inventoryResponseItems.get(0).cloudRegion.cloudRegionId); - + } catch (Exception e) { - logger.error(e.getMessage(), e); - VirtualControlLoopNotification notification = new VirtualControlLoopNotification(onset); - notification.notification = ControlLoopNotificationType.REJECTED; - notification.message = "Exception occurred " + e.getMessage(); - notification.policyName = onset.policyName; - notification.policyScope = onset.policyScope; - notification.policyVersion = onset.policyVersion; - // - try { - logger.debug(Serialization.gsonPretty.toJson(notification)); - } catch (Exception e1) { - logger.error("Can't deliver notification: " + notification); - logger.error(e1.getMessage(), e1); - } - // - notification.notification = ControlLoopNotificationType.FINAL_FAILURE; - notification.message = "Invalid named-query response from AAI"; - // - try { - logger.debug(Serialization.gsonPretty.toJson(notification)); - } catch (Exception e1) { - logger.error("Can't deliver notification: " + notification); - logger.error(e1.getMessage(), e1); - } - // Retract everything - return; - } - - // Extracted fields should not be null - if (!checkExtractedFields()) { - System.err.println("some fields are missing from AAI response."); + logger.warn("Problem extracting SO data from AAI query response because of {}", e.getMessage(), e); return; } } @@ -327,7 +299,7 @@ public class SOActorServiceProvider implements Actor { } return true; } - + /** * Construct SO Request * @@ -335,6 +307,7 @@ public class SOActorServiceProvider implements Actor { * @param operation * @param policy * @return SORequest + * @throws IllegalAccessException */ public SORequest constructRequest(VirtualControlLoopEvent onset, ControlLoopOperation operation, Policy policy) { @@ -349,8 +322,7 @@ public class SOActorServiceProvider implements Actor { // check if the fields extracted from named query response are // not null so we can proceed with SO request if (!checkExtractedFields()) { - - System.err.println("AAI response is missing some required fields. Cannot proceed with SO Request construction."); + logger.warn("AAI response is missing some required fields. Cannot proceed with SO Request construction."); return null; } else { |