Merge "Fix potential null pointer places"
authorSteven Blimkie <Steven.Blimkie@amdocs.com>
Wed, 25 Jul 2018 14:51:11 +0000 (14:51 +0000)
committerGerrit Code Review <gerrit@onap.org>
Wed, 25 Jul 2018 14:51:11 +0000 (14:51 +0000)
1  2 
sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/services/BaseVisualizationContext.java

@@@ -538,38 -538,15 +538,15 @@@ public class BaseVisualizationContext i
  
          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);
            }
  
          }
  
    }
  
+   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.
     *
    /**
     * Process current node states.
     *
-    * @param rootNodeDiscovered the root node discovered
     */
    private void processCurrentNodeStates(QueryParams queryParams) {
      /*
          Thread.sleep(10);
        } catch (InterruptedException exc) {
          LOG.error(AaiUiMsgs.PROCESSING_LOOP_INTERUPTED, exc.getMessage());
 +        Thread.currentThread().interrupt();
          return;
        }