diff options
author | 2017-07-25 14:46:08 -0400 | |
---|---|---|
committer | 2017-07-25 14:46:59 -0400 | |
commit | d4241a5c945d04e44716851cfd2b7ef427accb48 (patch) | |
tree | 805b432231bca7732ea30af365d2b53f534c0ddd /src/main/java/org/openecomp/sparky/viewandinspect | |
parent | f8de1f25e7c71380a61b96d5251f224e3a4c821f (diff) |
Fixing the sync issues with AAI
Issue-ID: AAI-73
Change-Id: I5c7df7c24c59c347b112cdb003eea726e239a1ca
Signed-off-by: ARUL NAMBI <arul.nambi@amdocs.com>
Diffstat (limited to 'src/main/java/org/openecomp/sparky/viewandinspect')
3 files changed, 20 insertions, 12 deletions
diff --git a/src/main/java/org/openecomp/sparky/viewandinspect/entity/NodeProcessingTransaction.java b/src/main/java/org/openecomp/sparky/viewandinspect/entity/NodeProcessingTransaction.java index f881f06..178dc46 100644 --- a/src/main/java/org/openecomp/sparky/viewandinspect/entity/NodeProcessingTransaction.java +++ b/src/main/java/org/openecomp/sparky/viewandinspect/entity/NodeProcessingTransaction.java @@ -49,9 +49,16 @@ public class NodeProcessingTransaction { public void setRequestParameters(String requestParameters) { this.requestParameters = requestParameters; } - + + public String getSelfLink() { + if (processingNode == null) { + return null; + } + + return processingNode.getSelfLink(); + } + public String getSelfLinkWithModifiers() { - if (processingNode == null) { return null; } diff --git a/src/main/java/org/openecomp/sparky/viewandinspect/services/VisualizationContext.java b/src/main/java/org/openecomp/sparky/viewandinspect/services/VisualizationContext.java index c5adfd4..7c8714f 100644 --- a/src/main/java/org/openecomp/sparky/viewandinspect/services/VisualizationContext.java +++ b/src/main/java/org/openecomp/sparky/viewandinspect/services/VisualizationContext.java @@ -405,6 +405,7 @@ public class VisualizationContext { } else { selfLink = ((JsonNode) entityLinks.toArray()[0]).asText(); + selfLink = ActiveInventoryConfig.extractResourcePath(selfLink); newChildNode.setSelfLink(selfLink); newChildNode.setNodeId(NodeUtils.generateUniqueShaDigest(selfLink)); @@ -677,7 +678,7 @@ public class VisualizationContext { txn.setRequestParameters(depthModifier); aaiWorkOnHand.incrementAndGet(); supplyAsync( - new PerformNodeSelfLinkProcessingTask(txn, depthModifier, aaiProvider), + new PerformNodeSelfLinkProcessingTask(txn, depthModifier, aaiProvider, aaiConfig), aaiExecutorService).whenComplete((nodeTxn, error) -> { aaiWorkOnHand.decrementAndGet(); if (error != null) { @@ -1184,17 +1185,17 @@ public class VisualizationContext { Relationship[] relationshipArray = relationshipList.getRelationshipList(); OxmEntityDescriptor descriptor = null; - String repairedSelfLink = null; if (relationshipArray != null) { ActiveInventoryNode newNode = null; + String resourcePath = null; for (Relationship r : relationshipArray) { - repairedSelfLink = aaiConfig.repairSelfLink(r.getRelatedLink()); + resourcePath = ActiveInventoryConfig.extractResourcePath(r.getRelatedLink()); - String nodeId = NodeUtils.generateUniqueShaDigest(repairedSelfLink); + String nodeId = NodeUtils.generateUniqueShaDigest(resourcePath); if (nodeId == null) { @@ -1218,7 +1219,7 @@ public class VisualizationContext { newNode.setNodeId(nodeId); newNode.setEntityType(entityType); - newNode.setSelfLink(repairedSelfLink); + newNode.setSelfLink(resourcePath); processingNode.addOutboundNeighbor(nodeId); diff --git a/src/main/java/org/openecomp/sparky/viewandinspect/task/PerformNodeSelfLinkProcessingTask.java b/src/main/java/org/openecomp/sparky/viewandinspect/task/PerformNodeSelfLinkProcessingTask.java index b7fe3a5..1918e60 100644 --- a/src/main/java/org/openecomp/sparky/viewandinspect/task/PerformNodeSelfLinkProcessingTask.java +++ b/src/main/java/org/openecomp/sparky/viewandinspect/task/PerformNodeSelfLinkProcessingTask.java @@ -48,6 +48,7 @@ public class PerformNodeSelfLinkProcessingTask implements Supplier<NodeProcessin private NodeProcessingTransaction txn; private ActiveInventoryDataProvider aaiProvider; private Map<String, String> contextMap; + private ActiveInventoryConfig aaiConfig; /** * Instantiates a new perform node self link processing task. @@ -57,10 +58,11 @@ public class PerformNodeSelfLinkProcessingTask implements Supplier<NodeProcessin * @param aaiProvider the aai provider */ public PerformNodeSelfLinkProcessingTask(NodeProcessingTransaction txn, String requestParameters, - ActiveInventoryDataProvider aaiProvider) { + ActiveInventoryDataProvider aaiProvider, ActiveInventoryConfig aaiConfig) { this.aaiProvider = aaiProvider; this.txn = txn; this.contextMap = MDC.getCopyOfContextMap(); + this.aaiConfig = aaiConfig; } /* (non-Javadoc) @@ -69,10 +71,9 @@ public class PerformNodeSelfLinkProcessingTask implements Supplier<NodeProcessin @Override public NodeProcessingTransaction get() { MDC.setContextMap(contextMap); - String link = txn.getSelfLinkWithModifiers(); - + OperationResult opResult = new OperationResult(); + String link = txn.getSelfLink(); if (link == null) { - OperationResult opResult = new OperationResult(); opResult.setResult(500, "Aborting self-link processing because self link is null"); txn.setOpResult(opResult); return txn; @@ -82,7 +83,6 @@ public class PerformNodeSelfLinkProcessingTask implements Supplier<NodeProcessin logger.debug(AaiUiMsgs.DEBUG_GENERIC, "Collecting " + link); } - OperationResult opResult = null; try { opResult = aaiProvider.queryActiveInventoryWithRetries(link, "application/json", ActiveInventoryConfig.getConfig().getAaiRestConfig().getNumRequestRetries()); |