summaryrefslogtreecommitdiffstats
path: root/sparkybe-onap-service/src/main/java
diff options
context:
space:
mode:
authorSteven Blimkie <Steven.Blimkie@amdocs.com>2018-07-25 14:51:11 +0000
committerGerrit Code Review <gerrit@onap.org>2018-07-25 14:51:11 +0000
commitadb1e19bc2103f0a444e6dd82795a7b79225a802 (patch)
treef49b5f2484f82a457310f233bd1064ec704b3726 /sparkybe-onap-service/src/main/java
parentb637d94ab44de34647be275756bace1bbc993ed1 (diff)
parent010ec08bb7207a2956217e13d3e39b68f5609bd3 (diff)
Merge "Fix potential null pointer places"
Diffstat (limited to 'sparkybe-onap-service/src/main/java')
-rw-r--r--sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregatevnf/search/AggregateVnfSearchProvider.java54
-rw-r--r--sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregation/sync/AggregationSynchronizer.java60
-rw-r--r--sparkybe-onap-service/src/main/java/org/onap/aai/sparky/autosuggestion/sync/AutosuggestionSynchronizer.java58
-rw-r--r--sparkybe-onap-service/src/main/java/org/onap/aai/sparky/crossentityreference/sync/CrossEntityReferenceSynchronizer.java55
-rw-r--r--sparkybe-onap-service/src/main/java/org/onap/aai/sparky/security/EcompSso.java2
-rw-r--r--sparkybe-onap-service/src/main/java/org/onap/aai/sparky/sync/task/StoreDocumentTask.java4
-rw-r--r--sparkybe-onap-service/src/main/java/org/onap/aai/sparky/topology/sync/GeoSynchronizer.java44
-rw-r--r--sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/entity/ActiveInventoryNode.java52
-rw-r--r--sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/search/ViewInspectSearchProvider.java3
-rw-r--r--sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/services/BaseVisualizationContext.java53
-rw-r--r--sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/services/BaseVisualizationService.java55
-rw-r--r--sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewinspect/sync/ViewInspectEntitySynchronizer.java56
12 files changed, 225 insertions, 271 deletions
diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregatevnf/search/AggregateVnfSearchProvider.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregatevnf/search/AggregateVnfSearchProvider.java
index 5fd0dc9..91121c6 100644
--- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregatevnf/search/AggregateVnfSearchProvider.java
+++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregatevnf/search/AggregateVnfSearchProvider.java
@@ -106,11 +106,10 @@ public class AggregateVnfSearchProvider implements SearchProvider {
}
ObjectMapper mapper = new ObjectMapper();
- JsonNode rootNode = null;
List<SearchSuggestion> suggestionEntityList = new ArrayList<SearchSuggestion>();
try {
- rootNode = mapper.readTree(operationResult);
+ JsonNode rootNode = mapper.readTree(operationResult);
JsonNode hitsNode = rootNode.get(KEY_SEARCH_RESULT);
// Check if there are hits that are coming back
if (hitsNode.has(KEY_HITS)) {
@@ -120,30 +119,14 @@ public class AggregateVnfSearchProvider implements SearchProvider {
* next we iterate over the values in the hit array elements
*/
Iterator<JsonNode> nodeIterator = hitsArray.elements();
- JsonNode entityNode = null;
- CommonSearchSuggestion responseSuggestion = null;
- JsonNode sourceNode = null;
-
while (nodeIterator.hasNext()) {
- entityNode = nodeIterator.next();
- String responseText = getValueFromNode(entityNode, KEY_TEXT);
- // do the point transformation as we build the response?
- responseSuggestion = new CommonSearchSuggestion();
- responseSuggestion.setRoute(vnfSearchSuggestionRoute);
- responseSuggestion.setText(responseText);
- responseSuggestion.setHashId(NodeUtils.generateUniqueShaDigest(responseText));
-
- sourceNode = entityNode.get(KEY_DOCUMENT).get(KEY_CONTENT);
- if (sourceNode.has(KEY_FILTER_LIST)) {
- ArrayNode filtersArray = (ArrayNode) sourceNode.get(KEY_FILTER_LIST);
- for (int i = 0; i < filtersArray.size(); i++) {
- String filterValueString = filtersArray.get(i).toString();
- UiFilterValueEntity filterValue =
- mapper.readValue(filterValueString, UiFilterValueEntity.class);
- responseSuggestion.getFilterValues().add(filterValue);
- }
+ JsonNode entityNode = nodeIterator.next();
+ if(entityNode != null) {
+ String responseText = getValueFromNode(entityNode, KEY_TEXT);
+
+ CommonSearchSuggestion responseSuggestion = createCommonSearchSuggestion(mapper, entityNode, responseText);
+ suggestionEntityList.add(responseSuggestion);
}
- suggestionEntityList.add(responseSuggestion);
}
}
} catch (IOException exc) {
@@ -153,9 +136,30 @@ public class AggregateVnfSearchProvider implements SearchProvider {
}
+ private CommonSearchSuggestion createCommonSearchSuggestion(ObjectMapper mapper, JsonNode entityNode, String responseText) throws IOException {
+ // do the point transformation as we build the response?
+ CommonSearchSuggestion responseSuggestion = new CommonSearchSuggestion();
+ responseSuggestion.setRoute(vnfSearchSuggestionRoute);
+ responseSuggestion.setText(responseText);
+ responseSuggestion.setHashId(NodeUtils.generateUniqueShaDigest(responseText));
+
+ JsonNode keyDocument = entityNode.get(KEY_DOCUMENT);
+ JsonNode sourceNode = keyDocument.get(KEY_CONTENT);
+ if (sourceNode.has(KEY_FILTER_LIST)) {
+ ArrayNode filtersArray = (ArrayNode) sourceNode.get(KEY_FILTER_LIST);
+ for (int i = 0; i < filtersArray.size(); i++) {
+ String filterValueString = filtersArray.get(i).toString();
+ UiFilterValueEntity filterValue =
+ mapper.readValue(filterValueString, UiFilterValueEntity.class);
+ responseSuggestion.getFilterValues().add(filterValue);
+ }
+ }
+ return responseSuggestion;
+ }
+
private String getValueFromNode(JsonNode node, String fieldName) {
- if (node == null || fieldName == null) {
+ if (fieldName == null) {
return null;
}
diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregation/sync/AggregationSynchronizer.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregation/sync/AggregationSynchronizer.java
index e0b6955..b4c254a 100644
--- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregation/sync/AggregationSynchronizer.java
+++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregation/sync/AggregationSynchronizer.java
@@ -118,7 +118,6 @@ public class AggregationSynchronizer extends AbstractEntitySynchronizer
/**
* Instantiates a new entity aggregation synchronizer.
*
- * @param indexName the index name
* @throws Exception the exception
*/
public AggregationSynchronizer(String entityType, ElasticSearchSchemaConfig schemaConfig,
@@ -613,7 +612,7 @@ public class AggregationSynchronizer extends AbstractEntitySynchronizer
Map<String, Object> map = mapper.convertValue(entityNode, Map.class);
doc.copyAttributeKeyValuePair(map);
}
-
+
/**
* Process entity type self links.
*
@@ -621,10 +620,8 @@ public class AggregationSynchronizer extends AbstractEntitySynchronizer
*/
private void processEntityTypeSelfLinks(OperationResult operationResult) {
- JsonNode rootNode = null;
-
- if ( operationResult == null ) {
- return;
+ if (operationResult == null) {
+ return;
}
final String jsonResult = operationResult.getResult();
@@ -632,46 +629,41 @@ public class AggregationSynchronizer extends AbstractEntitySynchronizer
if (jsonResult != null && jsonResult.length() > 0 && operationResult.wasSuccessful()) {
try {
- rootNode = mapper.readTree(jsonResult);
- } catch (IOException exc) {
- String message =
- "Could not deserialize JSON (representing operation result) as node tree. " +
- "Operation result = " + jsonResult + ". " + exc.getLocalizedMessage();
- LOG.error(AaiUiMsgs.JSON_PROCESSING_ERROR, message);
- }
+ JsonNode rootNode = mapper.readTree(jsonResult);
- JsonNode resultData = rootNode.get("result-data");
- ArrayNode resultDataArrayNode = null;
+ JsonNode resultData = rootNode.get("result-data");
- if (resultData.isArray()) {
- resultDataArrayNode = (ArrayNode) resultData;
+ if (resultData.isArray()) {
+ ArrayNode resultDataArrayNode = (ArrayNode) resultData;
- Iterator<JsonNode> elementIterator = resultDataArrayNode.elements();
- JsonNode element = null;
+ Iterator<JsonNode> elementIterator = resultDataArrayNode.elements();
- while (elementIterator.hasNext()) {
- element = elementIterator.next();
+ while (elementIterator.hasNext()) {
+ JsonNode element = elementIterator.next();
- final String resourceType = NodeUtils.getNodeFieldAsText(element, "resource-type");
- final String resourceLink = NodeUtils.getNodeFieldAsText(element, "resource-link");
+ final String resourceType = NodeUtils.getNodeFieldAsText(element, "resource-type");
+ final String resourceLink = NodeUtils.getNodeFieldAsText(element, "resource-link");
- OxmEntityDescriptor descriptor = null;
+ if (resourceType != null && resourceLink != null) {
- if (resourceType != null && resourceLink != null) {
+ OxmEntityDescriptor descriptor = oxmEntityLookup.getEntityDescriptors().get(resourceType);
- descriptor = oxmEntityLookup.getEntityDescriptors().get(resourceType);
-
- if (descriptor == null) {
- LOG.error(AaiUiMsgs.MISSING_ENTITY_DESCRIPTOR, resourceType);
- // go to next element in iterator
- continue;
- }
+ if (descriptor == null) {
+ LOG.error(AaiUiMsgs.MISSING_ENTITY_DESCRIPTOR, resourceType);
+ // go to next element in iterator
+ continue;
+ }
- selflinks.add(new SelfLinkDescriptor(resourceLink, SynchronizerConstants.NODES_ONLY_MODIFIER, resourceType));
-
+ selflinks.add(new SelfLinkDescriptor(resourceLink, SynchronizerConstants.NODES_ONLY_MODIFIER, resourceType));
+ }
}
}
+ } catch (IOException exc) {
+ String message =
+ "Could not deserialize JSON (representing operation result) as node tree. " +
+ "Operation result = " + jsonResult + ". " + exc.getLocalizedMessage();
+ LOG.error(AaiUiMsgs.JSON_PROCESSING_ERROR, message);
}
}
diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/autosuggestion/sync/AutosuggestionSynchronizer.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/autosuggestion/sync/AutosuggestionSynchronizer.java
index ab1c7af..6f8299c 100644
--- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/autosuggestion/sync/AutosuggestionSynchronizer.java
+++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/autosuggestion/sync/AutosuggestionSynchronizer.java
@@ -120,7 +120,6 @@ public class AutosuggestionSynchronizer extends AbstractEntitySynchronizer
/**
* Instantiates a new historical entity summarizer.
*
- * @param indexName the index name
* @throws Exception the exception
*/
public AutosuggestionSynchronizer(ElasticSearchSchemaConfig schemaConfig, int internalSyncWorkers,
@@ -260,10 +259,8 @@ public class AutosuggestionSynchronizer extends AbstractEntitySynchronizer
*/
private void processEntityTypeSelfLinks(OperationResult operationResult) {
- JsonNode rootNode = null;
-
- if ( operationResult == null ) {
- return;
+ if (operationResult == null) {
+ return;
}
final String jsonResult = operationResult.getResult();
@@ -271,45 +268,38 @@ public class AutosuggestionSynchronizer extends AbstractEntitySynchronizer
if (jsonResult != null && jsonResult.length() > 0 && operationResult.wasSuccessful()) {
try {
- rootNode = mapper.readTree(jsonResult);
- } catch (IOException exc) {
- String message = "Could not deserialize JSON (representing operation result) as node tree. "
- + "Operation result = " + jsonResult + ". " + exc.getLocalizedMessage();
- LOG.error(AaiUiMsgs.JSON_PROCESSING_ERROR, message);
- }
-
- JsonNode resultData = rootNode.get("result-data");
- ArrayNode resultDataArrayNode = null;
+ JsonNode rootNode = mapper.readTree(jsonResult);
+ JsonNode resultData = rootNode.get("result-data");
- if (resultData.isArray()) {
- resultDataArrayNode = (ArrayNode) resultData;
+ if (resultData.isArray()) {
+ ArrayNode resultDataArrayNode = (ArrayNode) resultData;
- Iterator<JsonNode> elementIterator = resultDataArrayNode.elements();
- JsonNode element = null;
+ Iterator<JsonNode> elementIterator = resultDataArrayNode.elements();
- while (elementIterator.hasNext()) {
- element = elementIterator.next();
+ while (elementIterator.hasNext()) {
+ JsonNode element = elementIterator.next();
- final String resourceType = NodeUtils.getNodeFieldAsText(element, "resource-type");
- final String resourceLink = NodeUtils.getNodeFieldAsText(element, "resource-link");
+ final String resourceType = NodeUtils.getNodeFieldAsText(element, "resource-type");
+ final String resourceLink = NodeUtils.getNodeFieldAsText(element, "resource-link");
- OxmEntityDescriptor descriptor = null;
+ if (resourceType != null && resourceLink != null) {
- if (resourceType != null && resourceLink != null) {
+ OxmEntityDescriptor descriptor = oxmEntityLookup.getEntityDescriptors().get(resourceType);
- descriptor = oxmEntityLookup.getEntityDescriptors().get(resourceType);
-
- if (descriptor == null) {
- LOG.error(AaiUiMsgs.MISSING_ENTITY_DESCRIPTOR, resourceType);
- // go to next element in iterator
- continue;
+ if (descriptor == null) {
+ LOG.error(AaiUiMsgs.MISSING_ENTITY_DESCRIPTOR, resourceType);
+ // go to next element in iterator
+ continue;
+ }
+ selflinks.add(new SelfLinkDescriptor(resourceLink,
+ SynchronizerConstants.NODES_ONLY_MODIFIER, resourceType));
}
- selflinks.add(new SelfLinkDescriptor(resourceLink,
- SynchronizerConstants.NODES_ONLY_MODIFIER, resourceType));
-
-
}
}
+ } catch (IOException exc) {
+ String message = "Could not deserialize JSON (representing operation result) as node tree. "
+ + "Operation result = " + jsonResult + ". " + exc.getLocalizedMessage();
+ LOG.error(AaiUiMsgs.JSON_PROCESSING_ERROR, message);
}
}
}
diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/crossentityreference/sync/CrossEntityReferenceSynchronizer.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/crossentityreference/sync/CrossEntityReferenceSynchronizer.java
index d95e507..a817eb9 100644
--- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/crossentityreference/sync/CrossEntityReferenceSynchronizer.java
+++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/crossentityreference/sync/CrossEntityReferenceSynchronizer.java
@@ -123,7 +123,6 @@ public class CrossEntityReferenceSynchronizer extends AbstractEntitySynchronizer
/**
* Instantiates a new cross entity reference synchronizer.
*
- * @param indexName the index name
* @throws Exception the exception
*/
public CrossEntityReferenceSynchronizer(ElasticSearchSchemaConfig schemaConfig,
@@ -349,49 +348,42 @@ public class CrossEntityReferenceSynchronizer extends AbstractEntitySynchronizer
*/
private void processEntityTypeSelfLinks(OperationResult operationResult) {
- JsonNode rootNode = null;
-
final String jsonResult = operationResult.getResult();
if (jsonResult != null && jsonResult.length() > 0) {
try {
- rootNode = mapper.readTree(jsonResult);
- } catch (IOException exc) {
- // TODO // TODO -> LOG, waht should be logged here?
- }
-
- JsonNode resultData = rootNode.get("result-data");
- ArrayNode resultDataArrayNode = null;
-
- if (resultData.isArray()) {
- resultDataArrayNode = (ArrayNode) resultData;
+ JsonNode rootNode = mapper.readTree(jsonResult);
+ JsonNode resultData = rootNode.get("result-data");
- Iterator<JsonNode> elementIterator = resultDataArrayNode.elements();
- JsonNode element = null;
+ if (resultData.isArray()) {
+ ArrayNode resultDataArrayNode = (ArrayNode) resultData;
- while (elementIterator.hasNext()) {
- element = elementIterator.next();
+ Iterator<JsonNode> elementIterator = resultDataArrayNode.elements();
- final String resourceType = NodeUtils.getNodeFieldAsText(element, "resource-type");
- final String resourceLink = NodeUtils.getNodeFieldAsText(element, "resource-link");
+ while (elementIterator.hasNext()) {
+ JsonNode element = elementIterator.next();
- CrossEntityReferenceDescriptor descriptor = null;
+ final String resourceType = NodeUtils.getNodeFieldAsText(element, "resource-type");
+ final String resourceLink = NodeUtils.getNodeFieldAsText(element, "resource-link");
- if (resourceType != null && resourceLink != null) {
- descriptor = crossEntityReferenceLookup.getCrossReferenceEntityDescriptors().get(resourceType);
+ if (resourceType != null && resourceLink != null) {
+ CrossEntityReferenceDescriptor descriptor = crossEntityReferenceLookup.getCrossReferenceEntityDescriptors().get(resourceType);
- if (descriptor == null) {
- LOG.error(AaiUiMsgs.MISSING_ENTITY_DESCRIPTOR, resourceType);
- // go to next element in iterator
- continue;
- }
- if (descriptor.hasCrossEntityReferences()) {
- selflinks.add(new SelfLinkDescriptor(
- resourceLink,SynchronizerConstants.DEPTH_ALL_MODIFIER, resourceType));
+ if (descriptor == null) {
+ LOG.error(AaiUiMsgs.MISSING_ENTITY_DESCRIPTOR, resourceType);
+ // go to next element in iterator
+ continue;
+ }
+ if (descriptor.hasCrossEntityReferences()) {
+ selflinks.add(new SelfLinkDescriptor(
+ resourceLink, SynchronizerConstants.DEPTH_ALL_MODIFIER, resourceType));
+ }
}
}
}
+ } catch (IOException exc) {
+ // TODO // TODO -> LOG, waht should be logged here?
}
}
}
@@ -625,7 +617,8 @@ public class CrossEntityReferenceSynchronizer extends AbstractEntitySynchronizer
}
} else {
- String message = "Entity sync failed because AAI query failed with error " + aaiQueryResult.getResult();
+ String result = aaiQueryResult != null ? aaiQueryResult.getResult() : "unknown";
+ String message = "Entity sync failed because AAI query failed with error " + result;
LOG.error(AaiUiMsgs.ENTITY_SYNC_FAILED_QUERY_ERROR, message);
}
diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/security/EcompSso.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/security/EcompSso.java
index d248df9..fd64f97 100644
--- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/security/EcompSso.java
+++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/security/EcompSso.java
@@ -109,7 +109,7 @@ public class EcompSso {
String[] cspFields = getCspData(request);
if (cspFields != null && cspFields.length > 5)
uid = cspFields[5];
- } catch (Throwable t) {
+ } catch (Exception t) {
LOG.info(AaiUiMsgs.LOGIN_FILTER_INFO,
"getLoginIdFromCookie failed " + t.getLocalizedMessage());
}
diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/sync/task/StoreDocumentTask.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/sync/task/StoreDocumentTask.java
index 983a2ad..301e65d 100644
--- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/sync/task/StoreDocumentTask.java
+++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/sync/task/StoreDocumentTask.java
@@ -48,7 +48,7 @@ public class StoreDocumentTask implements Supplier<NetworkTransaction> {
*
* @param doc the doc
* @param txn the txn
- * @param esDataProvider the es data provider
+ * @param esAdapter the es adapter
*/
public StoreDocumentTask(IndexDocument doc, NetworkTransaction txn,
ElasticSearchAdapter esAdapter) {
@@ -67,7 +67,7 @@ public class StoreDocumentTask implements Supplier<NetworkTransaction> {
long startTimeInMs = System.currentTimeMillis();
MDC.setContextMap(contextMap);
- OperationResult operationResult = null;
+ OperationResult operationResult = new OperationResult();
try {
diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/topology/sync/GeoSynchronizer.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/topology/sync/GeoSynchronizer.java
index a91ebc4..809c21a 100644
--- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/topology/sync/GeoSynchronizer.java
+++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/topology/sync/GeoSynchronizer.java
@@ -78,7 +78,6 @@ public class GeoSynchronizer extends AbstractEntitySynchronizer implements Index
/**
* Instantiates a new geo synchronizer.
*
- * @param indexName the index name
* @throws Exception the exception
*/
public GeoSynchronizer(ElasticSearchSchemaConfig schemaConfig, int internalSyncWorkers,
@@ -245,45 +244,40 @@ public class GeoSynchronizer extends AbstractEntitySynchronizer implements Index
*/
private void processEntityTypeSelfLinks(OperationResult operationResult) {
- JsonNode rootNode = null;
-
final String jsonResult = operationResult.getResult();
if (jsonResult != null && jsonResult.length() > 0 && operationResult.wasSuccessful()) {
try {
- rootNode = mapper.readTree(jsonResult);
- } catch (IOException exc) {
- LOG.error(AaiUiMsgs.ERROR_GENERIC, exc);
- }
+ JsonNode rootNode = mapper.readTree(jsonResult);
+ JsonNode resultData = rootNode.get("result-data");
- JsonNode resultData = rootNode.get("result-data");
- ArrayNode resultDataArrayNode = null;
+ if (resultData.isArray()) {
+ ArrayNode resultDataArrayNode = (ArrayNode) resultData;
- if (resultData.isArray()) {
- resultDataArrayNode = (ArrayNode) resultData;
+ Iterator<JsonNode> elementIterator = resultDataArrayNode.elements();
- Iterator<JsonNode> elementIterator = resultDataArrayNode.elements();
- JsonNode element = null;
+ while (elementIterator.hasNext()) {
+ JsonNode element = elementIterator.next();
- while (elementIterator.hasNext()) {
- element = elementIterator.next();
+ final String resourceType = NodeUtils.getNodeFieldAsText(element, "resource-type");
+ final String resourceLink = NodeUtils.getNodeFieldAsText(element, "resource-link");
- final String resourceType = NodeUtils.getNodeFieldAsText(element, "resource-type");
- final String resourceLink = NodeUtils.getNodeFieldAsText(element, "resource-link");
+ if (resourceType != null && resourceLink != null) {
- if (resourceType != null && resourceLink != null) {
+ if (geoDescriptorMap.containsKey(resourceType)) {
+ selflinks.add(new SelfLinkDescriptor(resourceLink + "?nodes-only", resourceType));
+ } else {
+ LOG.error(AaiUiMsgs.MISSING_ENTITY_DESCRIPTOR, resourceType);
+ // go to next element in iterator
+ continue;
+ }
- if (geoDescriptorMap.containsKey(resourceType)) {
- selflinks.add(new SelfLinkDescriptor(resourceLink + "?nodes-only", resourceType));
- } else {
- LOG.error(AaiUiMsgs.MISSING_ENTITY_DESCRIPTOR, resourceType);
- // go to next element in iterator
- continue;
}
-
}
}
+ } catch (IOException exc) {
+ LOG.error(AaiUiMsgs.ERROR_GENERIC, exc);
}
}
diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/entity/ActiveInventoryNode.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/entity/ActiveInventoryNode.java
index a13ffdb..4d83509 100644
--- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/entity/ActiveInventoryNode.java
+++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/entity/ActiveInventoryNode.java
@@ -667,28 +667,19 @@ public class ActiveInventoryNode {
} else {
JsonNode nodeValue = field.getValue();
- if (nodeValue != null && nodeValue.isValueNode()) {
+ if (nodeValue != null) {
+ if (nodeValue.isValueNode()) {
- /*
- * before we blindly add the fieldName and value to our property set, let's do one more
- * check to see if the field name is an entity type. If it is, then our complex
- * attribute processing code will pick it up and process it instead, but this is
- * probably more likely just for array node types, but we'll see.
- */
-
- if (oxmEntityLookup.getEntityDescriptors().get(fieldName) == null) {
/*
- * this is no an entity type as far as we can tell, so we can add it to our property
- * set.
+ * before we blindly add the fieldName and value to our property set, let's do one more
+ * check to see if the field name is an entity type. If it is, then our complex
+ * attribute processing code will pick it up and process it instead, but this is
+ * probably more likely just for array node types, but we'll see.
*/
- addProperty(fieldName, nodeValue.asText());
-
- }
-
- } else {
+ handleNodeValue(fieldName, nodeValue.asText());
- if (nodeValue.isArray()) {
+ } else if (nodeValue.isArray()) {
/*
* make sure array entity-type collection is not an entityType before adding it to the
@@ -696,26 +687,13 @@ public class ActiveInventoryNode {
* complex group or relationship.
*/
- if (oxmEntityLookup.getEntityDescriptors().get(field.getKey()) == null) {
- /*
- * this is no an entity type as far as we can tell, so we can add it to our property
- * set.
- */
-
- addProperty(field.getKey(), nodeValue.toString());
-
- }
-
+ handleNodeValue(field.getKey(), nodeValue.toString());
} else {
-
complexGroups.add(nodeValue);
-
}
}
-
}
-
}
} catch (IOException exc) {
@@ -727,6 +705,18 @@ public class ActiveInventoryNode {
}
+ private void handleNodeValue(String fieldName, String fieldValue) {
+ if (oxmEntityLookup.getEntityDescriptors().get(fieldName) == null) {
+ /*
+ * this is no an entity type as far as we can tell, so we can add it to our property
+ * set.
+ */
+
+ addProperty(fieldName, fieldValue);
+
+ }
+ }
+
public void setSelfLink(String selfLink) {
this.selfLink = selfLink;
}
diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/search/ViewInspectSearchProvider.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/search/ViewInspectSearchProvider.java
index 610aec6..8bf8610 100644
--- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/search/ViewInspectSearchProvider.java
+++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/search/ViewInspectSearchProvider.java
@@ -194,7 +194,8 @@ public class ViewInspectSearchProvider implements SearchProvider {
suggestionEntity
.setText(annotateSearchTags(searchTags, searchTagIds, entityType, queryStr));
} catch (Exception exc) {
- LOG.error(AaiUiMsgs.SEARCH_TAG_ANNOTATION_ERROR, searchTags.toString(),
+ String searchTagsAsText = searchTags != null ? searchTags.toString() : "n/a";
+ LOG.error(AaiUiMsgs.SEARCH_TAG_ANNOTATION_ERROR, searchTagsAsText,
exc.getLocalizedMessage());
// at least send back the un-annotated search tags
suggestionEntity.setText(searchTags);
diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/services/BaseVisualizationContext.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/services/BaseVisualizationContext.java
index aa4508c..0cbd52e 100644
--- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/services/BaseVisualizationContext.java
+++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/services/BaseVisualizationContext.java
@@ -538,38 +538,15 @@ public class BaseVisualizationContext implements VisualizationContext {
JsonNode nodeValue = field.getValue();
- if (nodeValue != null && nodeValue.isValueNode()) {
-
- if (oxmEntityLookup.getEntityDescriptors().get(fieldName) == null) {
-
- /*
- * entity property name is not an entity, thus we can add this property name and value
- * to our property set
- */
-
- ain.addProperty(fieldName, nodeValue.asText());
-
- }
-
- } else {
-
- if (nodeValue.isArray()) {
-
- if (oxmEntityLookup.getEntityDescriptors().get(fieldName) == null) {
-
- /*
- * entity property name is not an entity, thus we can add this property name and value
- * to our property set
- */
-
- ain.addProperty(field.getKey(), nodeValue.toString());
-
- }
-
+ if(nodeValue!=null) {
+ if (nodeValue.isValueNode()) {
+ String key = fieldName;
+ handleNodeValue(ain, fieldName, key, nodeValue.asText());
+ } else if (nodeValue.isArray()) {
+ String key = field.getKey();
+ handleNodeValue(ain, fieldName, key, nodeValue.toString());
} else {
-
- ain.addComplexGroup(nodeValue);
-
+ ain.addComplexGroup(nodeValue);
}
}
@@ -628,6 +605,19 @@ public class BaseVisualizationContext implements VisualizationContext {
}
+ private void handleNodeValue(ActiveInventoryNode ain, String fieldName, String key, String value) {
+ if (oxmEntityLookup.getEntityDescriptors().get(fieldName) == null) {
+
+ /*
+ * entity property name is not an entity, thus we can add this property name and value
+ * to our property set
+ */
+
+ ain.addProperty(key, value);
+
+ }
+ }
+
/**
* Perform self link resolve.
*
@@ -826,7 +816,6 @@ public class BaseVisualizationContext implements VisualizationContext {
/**
* Process current node states.
*
- * @param rootNodeDiscovered the root node discovered
*/
private void processCurrentNodeStates(QueryParams queryParams) {
/*
diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/services/BaseVisualizationService.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/services/BaseVisualizationService.java
index dffcbdf..afb0363 100644
--- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/services/BaseVisualizationService.java
+++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/services/BaseVisualizationService.java
@@ -193,7 +193,7 @@ public class BaseVisualizationService implements VisualizationService {
public OperationResult buildVisualizationUsingGenericQuery(QueryRequest queryRequest) {
OperationResult returnValue = new OperationResult();
- OperationResult dataCollectionResult = null;
+ OperationResult dataCollectionResult = new OperationResult();
QueryParams queryParams = null;
SearchableEntity sourceEntity = null;
@@ -294,8 +294,6 @@ public class BaseVisualizationService implements VisualizationService {
throw new ServletException(e1);
}
- String jsonResponse = null;
-
long startTimeInMs = System.currentTimeMillis();
visContext.processSelfLinks(searchtargetEntity, queryParams);
@@ -338,28 +336,24 @@ public class BaseVisualizationService implements VisualizationService {
GraphMeta graphMeta = new GraphMeta();
- D3VisualizationOutput output = null;
- try {
- output = transformer
- .generateVisualizationOutput((System.currentTimeMillis() - opStartTimeInMs), graphMeta);
- } catch (JsonProcessingException exc) {
- throw new ServletException("Caught an exception while generation visualization output", exc);
- } catch (IOException exc) {
- LOG.error(AaiUiMsgs.FAILURE_TO_PROCESS_REQUEST, exc.getLocalizedMessage());
- }
+ D3VisualizationOutput output = getD3VisualizationOutput(opStartTimeInMs, transformer, graphMeta);
- output.setInlineMessage(visContext.getInlineMessage());
- output.getGraphMeta().setNumLinkResolveFailed(visContext.getNumFailedLinkResolve());
- output.getGraphMeta().setNumLinksResolvedSuccessfullyFromCache(
- visContext.getNumSuccessfulLinkResolveFromCache());
- output.getGraphMeta().setNumLinksResolvedSuccessfullyFromServer(
- visContext.getNumSuccessfulLinkResolveFromFromServer());
+ String jsonResponse = null;
- try {
- jsonResponse = transformer.convertVisualizationOutputToJson(output);
- } catch (JsonProcessingException jpe) {
- throw new ServletException(
- "Caught an exception while converting visualization output to json", jpe);
+ if (output != null) {
+ output.setInlineMessage(visContext.getInlineMessage());
+ output.getGraphMeta().setNumLinkResolveFailed(visContext.getNumFailedLinkResolve());
+ output.getGraphMeta().setNumLinksResolvedSuccessfullyFromCache(
+ visContext.getNumSuccessfulLinkResolveFromCache());
+ output.getGraphMeta().setNumLinksResolvedSuccessfullyFromServer(
+ visContext.getNumSuccessfulLinkResolveFromFromServer());
+
+ try {
+ jsonResponse = transformer.convertVisualizationOutputToJson(output);
+ } catch (JsonProcessingException jpe) {
+ throw new ServletException(
+ "Caught an exception while converting visualization output to json", jpe);
+ }
}
logOptime("[build flat node array, add relationship data, search target,"
@@ -370,7 +364,20 @@ public class BaseVisualizationService implements VisualizationService {
return jsonResponse;
}
-
+
+ private D3VisualizationOutput getD3VisualizationOutput(long opStartTimeInMs, VisualizationTransformer transformer, GraphMeta graphMeta) throws ServletException {
+ D3VisualizationOutput output = null;
+ try {
+ output = transformer
+ .generateVisualizationOutput((System.currentTimeMillis() - opStartTimeInMs), graphMeta);
+ } catch (JsonProcessingException exc) {
+ throw new ServletException("Caught an exception while generation visualization output", exc);
+ } catch (IOException exc) {
+ LOG.error(AaiUiMsgs.FAILURE_TO_PROCESS_REQUEST, exc.getLocalizedMessage());
+ }
+ return output;
+ }
+
public void shutdown() {
aaiExecutorService.shutdown();
}
diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewinspect/sync/ViewInspectEntitySynchronizer.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewinspect/sync/ViewInspectEntitySynchronizer.java
index ecf4e56..285a76b 100644
--- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewinspect/sync/ViewInspectEntitySynchronizer.java
+++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewinspect/sync/ViewInspectEntitySynchronizer.java
@@ -115,7 +115,6 @@ public class ViewInspectEntitySynchronizer extends AbstractEntitySynchronizer
/**
* Instantiates a new searchable entity synchronizer.
*
- * @param indexName the index name
* @throws Exception the exception
*/
public ViewInspectEntitySynchronizer(ElasticSearchSchemaConfig schemaConfig,
@@ -255,54 +254,49 @@ public class ViewInspectEntitySynchronizer extends AbstractEntitySynchronizer
*/
private void processEntityTypeSelfLinks(OperationResult operationResult) {
- JsonNode rootNode = null;
-
final String jsonResult = operationResult.getResult();
if (jsonResult != null && jsonResult.length() > 0 && operationResult.wasSuccessful()) {
try {
- rootNode = mapper.readTree(jsonResult);
- } catch (IOException exc) {
- String message =
- "Could not deserialize JSON (representing operation result) as node tree. " +
- "Operation result = " + jsonResult + ". " + exc.getLocalizedMessage();
- LOG.error(AaiUiMsgs.JSON_PROCESSING_ERROR, message);
- }
+ JsonNode rootNode = mapper.readTree(jsonResult);
+ JsonNode resultData = rootNode.get("result-data");
- JsonNode resultData = rootNode.get("result-data");
- ArrayNode resultDataArrayNode = null;
+ if (resultData.isArray()) {
+ ArrayNode resultDataArrayNode = (ArrayNode) resultData;
- if (resultData.isArray()) {
- resultDataArrayNode = (ArrayNode) resultData;
+ Iterator<JsonNode> elementIterator = resultDataArrayNode.elements();
- Iterator<JsonNode> elementIterator = resultDataArrayNode.elements();
- JsonNode element = null;
+ while (elementIterator.hasNext()) {
+ JsonNode element = elementIterator.next();
- while (elementIterator.hasNext()) {
- element = elementIterator.next();
+ final String resourceType = NodeUtils.getNodeFieldAsText(element, "resource-type");
+ final String resourceLink = NodeUtils.getNodeFieldAsText(element, "resource-link");
- final String resourceType = NodeUtils.getNodeFieldAsText(element, "resource-type");
- final String resourceLink = NodeUtils.getNodeFieldAsText(element, "resource-link");
+ SearchableOxmEntityDescriptor descriptor = null;
- SearchableOxmEntityDescriptor descriptor = null;
+ if (resourceType != null && resourceLink != null) {
- if (resourceType != null && resourceLink != null) {
+ descriptor = searchableEntityLookup.getSearchableEntityDescriptors().get(resourceType);
- descriptor = searchableEntityLookup.getSearchableEntityDescriptors().get(resourceType);
+ if (descriptor == null) {
+ LOG.error(AaiUiMsgs.MISSING_ENTITY_DESCRIPTOR, resourceType);
+ // go to next element in iterator
+ continue;
+ }
- if (descriptor == null) {
- LOG.error(AaiUiMsgs.MISSING_ENTITY_DESCRIPTOR, resourceType);
- // go to next element in iterator
- continue;
- }
+ if (descriptor.hasSearchableAttributes()) {
+ selflinks.add(new SelfLinkDescriptor(resourceLink, SynchronizerConstants.NODES_ONLY_MODIFIER, resourceType));
+ }
- if (descriptor.hasSearchableAttributes()) {
- selflinks.add(new SelfLinkDescriptor(resourceLink, SynchronizerConstants.NODES_ONLY_MODIFIER, resourceType));
}
-
}
}
+ } catch (IOException exc) {
+ String message =
+ "Could not deserialize JSON (representing operation result) as node tree. " +
+ "Operation result = " + jsonResult + ". " + exc.getLocalizedMessage();
+ LOG.error(AaiUiMsgs.JSON_PROCESSING_ERROR, message);
}
}