Merge "Fix Blocker/Critical sonar issues"
authorTian Lee <TianL@amdocs.com>
Thu, 21 Sep 2017 11:33:58 +0000 (11:33 +0000)
committerGerrit Code Review <gerrit@onap.org>
Thu, 21 Sep 2017 11:33:58 +0000 (11:33 +0000)
src/main/java/org/openecomp/sparky/synchronizer/AggregationSynchronizer.java
src/main/java/org/openecomp/sparky/synchronizer/CrossEntityReferenceSynchronizer.java
src/main/java/org/openecomp/sparky/synchronizer/ElasticSearchIndexCleaner.java
src/main/java/org/openecomp/sparky/synchronizer/GeoSynchronizer.java
src/main/java/org/openecomp/sparky/viewandinspect/entity/ActiveInventoryNode.java

index 2d7429c..2fd67c3 100644 (file)
@@ -632,6 +632,7 @@ public class AggregationSynchronizer extends AbstractEntitySynchronizer
             "Could not deserialize JSON (representing operation result) as node tree. " +
             "Operation result = " + jsonResult + ". " + exc.getLocalizedMessage();
         LOG.error(AaiUiMsgs.JSON_PROCESSING_ERROR, message);
+        return;
       }
 
       JsonNode resultData = rootNode.get("result-data");
index c825040..1e3e85c 100644 (file)
@@ -338,7 +338,10 @@ public class CrossEntityReferenceSynchronizer extends AbstractEntitySynchronizer
       try {
         rootNode = mapper.readTree(jsonResult);
       } catch (IOException exc) {
-        // TODO // TODO -> LOG, waht should be logged here?
+        String message = "Could not deserialize JSON (representing operation result) as node tree. "
+                + "Operation result = " + jsonResult + ". " + exc.getLocalizedMessage();
+        LOG.error(AaiUiMsgs.JSON_PROCESSING_ERROR, message);
+        return;
       }
 
       JsonNode resultData = rootNode.get("result-data");
@@ -576,7 +579,7 @@ public class CrossEntityReferenceSynchronizer extends AbstractEntitySynchronizer
                         }
                         
                       } else {
-                        String message = "Entity sync failed because AAI query failed with error " + aaiQueryResult.getResult(); 
+                        String message = "Entity sync failed because AAI query failed with error ";
                         LOG.error(AaiUiMsgs.ENTITY_SYNC_FAILED_QUERY_ERROR, message);
                       }
                       
index b23764c..9ef4fe6 100644 (file)
@@ -521,11 +521,6 @@ public class ElasticSearchIndexCleaner implements IndexCleaner {
     }
 
     JsonNode rootNode = parseElasticSearchResult(opResult.getResult());
-    boolean timedOut = Boolean.parseBoolean(getFieldValue(rootNode, "timed_out"));
-    final String tookStr = getFieldValue(rootNode, "took");
-    int tookInMs = (tookStr == null) ? 0 : Integer.parseInt(tookStr);
-
-    JsonNode hitsNode = rootNode.get("hits");
 
     /*
      * Check the result for success / failure, and enumerate all the index ids that resulted in
@@ -533,6 +528,11 @@ public class ElasticSearchIndexCleaner implements IndexCleaner {
      */
 
     if (rootNode != null) {
+      boolean timedOut = Boolean.parseBoolean(getFieldValue(rootNode, "timed_out"));
+      final String tookStr = getFieldValue(rootNode, "took");
+      int tookInMs = (tookStr == null) ? 0 : Integer.parseInt(tookStr);
+
+      JsonNode hitsNode = rootNode.get("hits");
 
       if (timedOut) {
         LOG.info(AaiUiMsgs.COLLECT_TIME_WITH_ERROR, "Scroll Context", String.valueOf(tookInMs));
@@ -576,6 +576,9 @@ public class ElasticSearchIndexCleaner implements IndexCleaner {
         }
 
       }
+    } else {
+      // scroll context get failed, nothing else to do
+      LOG.error(AaiUiMsgs.ERROR_GENERIC, opResult.toString());
     }
 
     return OperationState.OK;
index c8d3b95..493f3c9 100644 (file)
@@ -250,6 +250,7 @@ public class GeoSynchronizer extends AbstractEntitySynchronizer implements Index
         rootNode = mapper.readTree(jsonResult);
       } catch (IOException exc) {
         LOG.error(AaiUiMsgs.ERROR_GENERIC, exc);
+        return;
       }
 
       JsonNode resultData = rootNode.get("result-data");
index aef710d..fc0f074 100644 (file)
@@ -166,7 +166,7 @@ public class ActiveInventoryNode {
   
   public void addQueryParams(Collection<String> params) {
 
-    if (params != null & params.size() > 0) {
+    if (params != null && !params.isEmpty()) {
 
       for (String param : params) {
         addQueryParam(param);