Fix sonar issues : 38/124638/1
authorSamuel Liard <samuel.liard@gmail.com>
Fri, 1 Oct 2021 08:09:17 +0000 (10:09 +0200)
committerSamuel Liard <samuel.liard@gmail.com>
Fri, 1 Oct 2021 08:17:43 +0000 (10:17 +0200)
Remove all printStackTrace
Change split regex
Remove all string comparison with !=

Issue-ID: AAI-3362
Signed-off-by: sliard <samuel.liard@gmail.com>
Change-Id: Ia473d0e2d0af5a6cde333e593c42bddd89709167

31 files changed:
src/main/java/org/onap/aai/audit/AuditGraphson2Sql.java
src/main/java/org/onap/aai/datagrooming/DataGrooming.java
src/main/java/org/onap/aai/datasnapshot/DataSnapshot.java
src/main/java/org/onap/aai/datasnapshot/DataSnapshot4HistInit.java
src/main/java/org/onap/aai/datasnapshot/PartialVertexLoader.java
src/main/java/org/onap/aai/dbgen/DupeTool.java
src/main/java/org/onap/aai/dbgen/UpdatePropertyTool.java
src/main/java/org/onap/aai/historytruncate/HistoryTruncate.java
src/main/java/org/onap/aai/migration/MigrationController.java
src/main/java/org/onap/aai/migration/Migrator.java
src/main/java/org/onap/aai/migration/v12/ALTSLicenseEntitlementMigration.java
src/main/java/org/onap/aai/migration/v12/MigrateHUBEvcInventory.java
src/main/java/org/onap/aai/migration/v12/MigrateINVEvcInventory.java
src/main/java/org/onap/aai/migration/v12/MigrateINVPhysicalInventory.java
src/main/java/org/onap/aai/migration/v12/MigratePATHEvcInventory.java
src/main/java/org/onap/aai/migration/v12/MigrateSAREvcInventory.java
src/main/java/org/onap/aai/migration/v12/SDWANSpeedChangeMigration.java
src/main/java/org/onap/aai/migration/v12/UpdateAaiUriIndexMigration.java
src/main/java/org/onap/aai/migration/v12/UriMigration.java
src/main/java/org/onap/aai/migration/v13/MigrateBadWidgetModelsPartOne.java
src/main/java/org/onap/aai/migration/v13/MigrateBadWidgetModelsPartTwo.java
src/main/java/org/onap/aai/migration/v13/MigrateForwarderEvcCircuitId.java
src/main/java/org/onap/aai/migration/v14/MigrateSameSourcedRCTROPserverData.java
src/main/java/org/onap/aai/migration/v14/MigrateSdnaIvlanData.java
src/main/java/org/onap/aai/migration/v15/MigrateCloudRegionUpgradeCycle.java
src/main/java/org/onap/aai/migration/v15/MigrateRadcomChanges.java
src/main/java/org/onap/aai/migration/v20/MigrateVlanTag.java
src/main/java/org/onap/aai/util/SendDeleteMigrationNotificationsMain.java
src/main/java/org/onap/aai/util/SendMigrationNotificationsMain.java
src/test/java/org/onap/aai/migration/v12/MigrateINVPhysicalInventoryMethodTest.java
src/test/java/org/onap/aai/util/SendDeleteMigrationNotificationsTest.java

index ff29157..73c07b8 100644 (file)
@@ -22,39 +22,38 @@ package org.onap.aai.audit;
 
 import com.google.gson.JsonObject;
 import com.google.gson.JsonParser;
-import org.apache.tinkerpop.gremlin.structure.Direction;
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
 import org.javatuples.Triplet;
-import org.onap.aai.restclient.PropertyPasswordConfiguration;
 import org.onap.aai.edges.EdgeIngestor;
 import org.onap.aai.edges.EdgeRule;
 import org.onap.aai.edges.exceptions.EdgeRuleNotFoundException;
-import org.onap.aai.exceptions.AAIException;
 import org.onap.aai.introspection.Loader;
 import org.onap.aai.introspection.LoaderFactory;
 import org.onap.aai.introspection.ModelType;
-import org.onap.aai.logging.ErrorLogHelper;
 import org.onap.aai.rest.client.ApertureService;
 import org.onap.aai.setup.SchemaVersions;
-import org.onap.aai.util.AAIConfig;
-import org.onap.aai.util.AAIConstants;
-import org.onap.aai.util.ExceptionTranslator;
 import org.onap.aai.util.FormatDate;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.slf4j.MDC;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.AnnotationConfigApplicationContext;
-
-import java.io.*;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.*;
-import java.util.stream.Collectors;
-
-import com.att.eelf.configuration.Configuration;
 import org.springframework.stereotype.Component;
 
 @Component
@@ -515,7 +514,6 @@ public class AuditGraphson2Sql {
                    String msg = "DEBUG --  Error while processing nodes ------";
                 LOGGER.debug(msg);
                    System.out.println(msg);
-                e.printStackTrace();
             }
         }// End of looping over all files
         
index 3884a01..0718dff 100644 (file)
@@ -19,6 +19,9 @@
  */
 package org.onap.aai.datagrooming;
 
+import com.att.eelf.configuration.Configuration;
+import com.beust.jcommander.JCommander;
+import com.beust.jcommander.Parameter;
 import java.io.BufferedReader;
 import java.io.BufferedWriter;
 import java.io.File;
@@ -36,7 +39,6 @@ import java.util.Map.Entry;
 import java.util.Properties;
 import java.util.Set;
 import java.util.UUID;
-
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
@@ -46,11 +48,10 @@ import org.apache.tinkerpop.gremlin.structure.Graph;
 import org.apache.tinkerpop.gremlin.structure.Property;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
 import org.apache.tinkerpop.gremlin.structure.VertexProperty;
-import org.onap.aai.GraphAdminApp;
-import org.onap.aai.restclient.PropertyPasswordConfiguration;
-import org.onap.aai.util.GraphAdminConstants;
-import org.onap.logging.ref.slf4j.ONAPLogConstants;
+import org.janusgraph.core.JanusGraph;
 import org.onap.aai.dbmap.AAIGraph;
+import org.onap.aai.edges.enums.AAIDirection;
+import org.onap.aai.edges.enums.EdgeProperty;
 import org.onap.aai.exceptions.AAIException;
 import org.onap.aai.introspection.Introspector;
 import org.onap.aai.introspection.Loader;
@@ -59,19 +60,16 @@ import org.onap.aai.introspection.ModelType;
 import org.onap.aai.introspection.exceptions.AAIUnknownObjectException;
 import org.onap.aai.logging.ErrorLogHelper;
 import org.onap.aai.logging.LogFormatTools;
-import org.onap.aai.edges.enums.AAIDirection;
-import org.onap.aai.edges.enums.EdgeProperty;
+import org.onap.aai.restclient.PropertyPasswordConfiguration;
 import org.onap.aai.setup.SchemaVersions;
-import org.onap.aai.setup.SchemaVersion;
-import org.onap.aai.util.*;
-
-import com.att.eelf.configuration.Configuration;
+import org.onap.aai.util.AAIConfig;
+import org.onap.aai.util.AAIConstants;
+import org.onap.aai.util.AAISystemExitUtil;
+import org.onap.aai.util.ExceptionTranslator;
+import org.onap.aai.util.FormatDate;
+import org.onap.aai.util.GraphAdminConstants;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import com.beust.jcommander.JCommander;
-import com.beust.jcommander.Parameter;
-
-import org.janusgraph.core.JanusGraph;
 import org.springframework.context.annotation.AnnotationConfigApplicationContext;
 
 
@@ -2159,32 +2157,31 @@ public class DataGrooming {
                                // uniqueness, and we
                                // found more than one node using its key -- record the found
                                // vertices as duplicates.
-                               String dupesStr = "";
-                               for (int i = 0; i < checkVertList.size(); i++) {
-                                       dupesStr = dupesStr
-                                                       + ((checkVertList.get(i))).id()
-                                                                       .toString() + "|";
+                               StringBuilder dupesStr = new StringBuilder();
+                               for (Vertex vertex : checkVertList) {
+                                       dupesStr.append(vertex.id()
+                                                       .toString()).append("|");
                                }
-                               if (dupesStr != "") {
+                               if (dupesStr.length() > 0) {
                                        Vertex prefV = getPreferredDupe(transId, fromAppId,
                                                        source, checkVertList, version, loader);
                                        if (prefV == null) {
                                                // We could not determine which duplicate to keep
-                                               dupesStr = dupesStr + "KeepVid=UNDETERMINED";
-                                               returnList.add(dupesStr);
+                                               dupesStr.append("KeepVid=UNDETERMINED");
+                                               returnList.add(dupesStr.toString());
                                        } else {
-                                               dupesStr = dupesStr + "KeepVid=" + prefV.id();
+                                               dupesStr.append("KeepVid=").append(prefV.id());
                                                Boolean didRemove = false;
                                                if (dupeFixOn) {
                                                        didRemove = deleteNonKeepersIfAppropriate(g,
-                                                                       dupesStr, prefV.id().toString(),
+                                                                       dupesStr.toString(), prefV.id().toString(),
                                                                        deleteCandidateList);
                                                }
                                                if (didRemove) {
                                                        dupeGrpsDeleted++;
                                                } else {
                                                        // keep them on our list
-                                                       returnList.add(dupesStr);
+                                                       returnList.add(dupesStr.toString());
                                                }
                                        }
                                }
@@ -2206,13 +2203,11 @@ public class DataGrooming {
                                        if (thisParentsVertList.size() > 1) {
                                                // More than one vertex found with the same key info
                                                // hanging off the same parent/dependent node
-                                               String dupesStr = "";
-                                               for (int i = 0; i < thisParentsVertList.size(); i++) {
-                                                       dupesStr = dupesStr
-                                                                       + ((thisParentsVertList
-                                                                                       .get(i))).id() + "|";
+                                               StringBuilder dupesStr = new StringBuilder();
+                                               for (Vertex vertex : thisParentsVertList) {
+                                                       dupesStr.append(vertex.id()).append("|");
                                                }
-                                               if (dupesStr != "") {
+                                               if (dupesStr.length() > 0) {
                                                        Vertex prefV = getPreferredDupe(transId,
                                                                        fromAppId, source, thisParentsVertList,
                                                                        version, loader);
@@ -2220,15 +2215,14 @@ public class DataGrooming {
                                                        if (prefV == null) {
                                                                // We could not determine which duplicate to
                                                                // keep
-                                                               dupesStr = dupesStr + "KeepVid=UNDETERMINED";
-                                                               returnList.add(dupesStr);
+                                                               dupesStr.append("KeepVid=UNDETERMINED");
+                                                               returnList.add(dupesStr.toString());
                                                        } else {
                                                                Boolean didRemove = false;
-                                                               dupesStr = dupesStr + "KeepVid="
-                                                                               + prefV.id().toString();
+                                                               dupesStr.append("KeepVid=").append(prefV.id().toString());
                                                                if (dupeFixOn) {
                                                                        didRemove = deleteNonKeepersIfAppropriate(
-                                                                                       g, dupesStr, prefV.id()
+                                                                                       g, dupesStr.toString(), prefV.id()
                                                                                                        .toString(),
                                                                                        deleteCandidateList );
                                                                }
@@ -2236,7 +2230,7 @@ public class DataGrooming {
                                                                        dupeGrpsDeleted++;
                                                                } else {
                                                                        // keep them on our list
-                                                                       returnList.add(dupesStr);
+                                                                       returnList.add(dupesStr.toString());
                                                                }
                                                        }
                                                }
index 946489b..a9312b2 100644 (file)
@@ -564,7 +564,7 @@ public class DataSnapshot {
                                //
                                LOGGER.debug(" Command = " + command );
                                
-                               if (cArgs.oldFileDir != null && cArgs.oldFileDir != ""){
+                               if (cArgs.oldFileDir != null && !cArgs.oldFileDir.isEmpty()){
                                        targetDir = cArgs.oldFileDir;
                                }
                                ArrayList <File> snapFilesArr = getFilesToProcess(targetDir, oldSnapshotFileName, false);
index 9aba8cf..35448e4 100644 (file)
@@ -582,7 +582,7 @@ public class DataSnapshot4HistInit {
                                //
                                LOGGER.debug(" Command = " + command );
                                
-                               if (cArgs.oldFileDir != null && cArgs.oldFileDir != ""){
+                               if (cArgs.oldFileDir != null && !cArgs.oldFileDir.isEmpty()){
                                        targetDir = cArgs.oldFileDir;
                                }
                                ArrayList <File> snapFilesArr = getFilesToProcess(targetDir, oldSnapshotFileName, false);
index 22ca0a2..8ed8087 100644 (file)
  */
 package org.onap.aai.datasnapshot;
 
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
 import java.io.BufferedReader;
 import java.io.FileReader;
 import java.util.HashMap;
 import java.util.concurrent.Callable;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONReader;
 import org.janusgraph.core.JanusGraph;
 import org.onap.aai.exceptions.AAIException;
 import org.onap.aai.logging.ErrorLogHelper;
 import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
 
 
 
@@ -96,7 +94,6 @@ public class PartialVertexLoader implements Callable<HashMap<String,String>>{
                                        Thread.sleep(failurePauseMs); // Slow down if things are failing
                                        LOGGER.debug(" >> addVertex FAILED for vtxId = " + oldVtxIdStr + ", label = [" 
                                                        + vtxLabelStr + "].  ErrorMsg = [" + e.getMessage() + "]" );
-                               //e.printStackTrace();
                                failedAttemptHash.put(oldVtxIdStr, vtxLabelStr);
                                if( failureCount > maxAllowedErrors ) {
                                        LOGGER.debug(" >>> Abandoning PartialVertexLoader() because " +
@@ -116,7 +113,6 @@ public class PartialVertexLoader implements Callable<HashMap<String,String>>{
                                Thread.sleep(failurePauseMs); // Slow down if things are failing
                                LOGGER.debug(" -- COMMIT FAILED for Vtx ADD for vtxId = " + oldVtxIdStr + ", label = [" 
                                                + vtxLabelStr + "].  ErrorMsg = [" +e.getMessage() + "]" );
-                               //e.printStackTrace();                                          
                                failedAttemptHash.put(oldVtxIdStr, vtxLabelStr);
                                if( failureCount > maxAllowedErrors ) {
                                        LOGGER.debug(">>> Abandoning PartialVertexLoader() because " +
index 0532e2e..43b1e8e 100644 (file)
@@ -558,24 +558,23 @@ public class DupeTool {
             try {
                 if (!vidList.isEmpty() && vidList.size() > 1) {
                     // There are more than one vertex id's using the same key info
-                    String dupesStr = "";
+                    StringBuilder dupesStr = new StringBuilder();
                     ArrayList<Vertex> vertList = new ArrayList<>();
-                    for (int i = 0; i < vidList.size(); i++) {
-                        String tmpVid = vidList.get(i);
-                        dupesStr = dupesStr + tmpVid + "|";
+                    for (String tmpVid : vidList) {
+                        dupesStr.append(tmpVid).append("|");
                         vertList.add(vtxHash.get(tmpVid));
                     }
 
-                    if (dupesStr != "") {
+                    if (dupesStr.length() > 0) {
                         Vertex prefV = getPreferredDupe(transId, fromAppId,
                                 g, vertList, version, specialTenantRule, loader, logger);
                         if (prefV == null) {
                             // We could not determine which duplicate to keep
-                            dupesStr = dupesStr + "KeepVid=UNDETERMINED";
-                            returnList.add(dupesStr);
+                            dupesStr.append("KeepVid=UNDETERMINED");
+                            returnList.add(dupesStr.toString());
                         } else {
-                            dupesStr = dupesStr + "KeepVid=" + prefV.id();
-                            returnList.add(dupesStr);
+                            dupesStr.append("KeepVid=").append(prefV.id());
+                            returnList.add(dupesStr.toString());
                         }
                     }
                 }
@@ -689,25 +688,22 @@ public class DupeTool {
                     if (thisParentsVertList.size() > 1) {
                         // More than one vertex found with the same key info
                         // hanging off the same parent/dependent node
-                        String dupesStr = "";
-                        for (int i = 0; i < thisParentsVertList.size(); i++) {
-                            dupesStr = dupesStr
-                                    + ((thisParentsVertList
-                                    .get(i))).id() + "|";
+                        StringBuilder dupesStr = new StringBuilder();
+                        for (Vertex vertex : thisParentsVertList) {
+                            dupesStr.append(vertex.id()).append("|");
                         }
-                        if (dupesStr != "") {
+                        if (dupesStr.toString().length() > 0) {
                             Vertex prefV = getPreferredDupe(transId,
                                     fromAppId, g, thisParentsVertList,
                                     version, specialTenantRule, loader, logger);
 
                             if (prefV == null) {
                                 // We could not determine which duplicate to keep
-                                dupesStr = dupesStr + "KeepVid=UNDETERMINED";
-                                returnList.add(dupesStr);
+                                dupesStr.append("KeepVid=UNDETERMINED");
+                                returnList.add(dupesStr.toString());
                             } else {
-                                dupesStr = dupesStr + "KeepVid="
-                                        + prefV.id().toString();
-                                returnList.add(dupesStr);
+                                dupesStr.append("KeepVid=").append(prefV.id().toString());
+                                returnList.add(dupesStr.toString());
                             }
                         }
                     }
@@ -1422,10 +1418,8 @@ public class DupeTool {
         // ie. "3456|9880|keepVid=3456"
 
         boolean didADelFlag = false;
-        for (int n = 0; n < dupeInfoList.size(); n++) {
-            String dupeInfoString = dupeInfoList.get(n);
-            boolean tmpFlag = deleteNonKeeperForOneSet(g, dupeInfoString, logger);
-            didADelFlag = tmpFlag | didADelFlag;
+        for (String dupeInfoString : dupeInfoList) {
+            didADelFlag |= deleteNonKeeperForOneSet(g, dupeInfoString, logger);
         }
 
         return didADelFlag;
index 032fc9e..9a6094b 100644 (file)
@@ -68,7 +68,7 @@ public class UpdatePropertyTool {
         try {
             EXIT_VM_STATUS_CODE = updatePropertyToolInternal.run(graph, args) ? EXIT_VM_STATUS_CODE_SUCCESS : EXIT_VM_STATUS_CODE_FAILURE;
         } catch (Exception e) {
-            e.printStackTrace();
+            System.out.println("Exception : " + e.getMessage());
             EXIT_VM_STATUS_CODE = EXIT_VM_STATUS_CODE_FAILURE;
         } finally {
             updatePropertyToolInternal.closeGraph(graph);
index e0adec0..8d7114e 100644 (file)
@@ -203,12 +203,10 @@ public class HistoryTruncate {
                } catch (AAIException e) {
                        ErrorLogHelper.logError("AAI_6128", e.getMessage());
                        LOGGER.error("Encountered an exception during the historyTruncate: ", e);
-                       e.printStackTrace();
                        successStatus = false;
                } catch (Exception ex) {
                        ErrorLogHelper.logError("AAI_6128", ex.getMessage());
                        LOGGER.error("Encountered an exception during the historyTruncate: ", ex);
-                       ex.printStackTrace();
                        successStatus = false;
                } finally {
                        if (jgraph != null ) {
index 5e969bf..8cecad4 100644 (file)
  */
 package org.onap.aai.migration;
 
-import org.onap.aai.restclient.PropertyPasswordConfiguration;
 import org.onap.aai.dbmap.AAIGraph;
 import org.onap.aai.edges.EdgeIngestor;
 import org.onap.aai.exceptions.AAIException;
 import org.onap.aai.introspection.LoaderFactory;
 import org.onap.aai.logging.ErrorLogHelper;
+import org.onap.aai.restclient.PropertyPasswordConfiguration;
 import org.onap.aai.serialization.db.EdgeSerializer;
 import org.onap.aai.setup.SchemaVersions;
-import org.onap.aai.util.AAIConstants;
 import org.onap.aai.util.ExceptionTranslator;
 import org.springframework.context.annotation.AnnotationConfigApplicationContext;
 
-import java.util.UUID;
-
 /**
  * Wrapper class to allow {@link org.onap.aai.migration.MigrationControllerInternal MigrationControllerInternal}
  * to be run from a shell script
@@ -72,7 +69,7 @@ public class MigrationController {
                try {
                        internal.run(args);
                } catch (Exception e) {
-                       e.printStackTrace();
+                       System.out.println("Exception : " + e.getMessage());
                }
                AAIGraph.getInstance().graphShutdown();
                System.exit(0);
index 9498cd1..57291e0 100644 (file)
@@ -29,7 +29,6 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Optional;
 import java.util.UUID;
-
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
 import org.apache.tinkerpop.gremlin.structure.Direction;
 import org.apache.tinkerpop.gremlin.structure.Edge;
@@ -154,47 +153,52 @@ public abstract class Migrator implements Runnable {
 
        /**
         * Create files containing data for dmaap delete Event Generation
-        * @param dmaapVertexList
+        * @param dmaapDeleteIntrospectorList
         */
-       public void createDmaapFilesForDelete(List<Introspector> dmaapDeleteIntrospectorList) {try {
-               System.out.println("dmaapDeleteIntrospectorList :: " + dmaapDeleteIntrospectorList.size());
-               String fileName = "DELETE-"+ getMigrationName() + "-" + UUID.randomUUID();
-               String logDirectory = System.getProperty("AJSC_HOME") + "/logs/data/dmaapEvents/";
-               File f = new File(logDirectory);
-               f.mkdirs();
-               
-               try{
-                       Files.createFile(Paths.get(logDirectory + "/" + fileName));
-               }catch(Exception e) {
-                       e.printStackTrace();
-               }
-               
-               if (dmaapDeleteIntrospectorList.size() > 0) {                           
-                       dmaapDeleteIntrospectorList.stream().forEach(svIntr-> {
-                               try {
-                                       String str = svIntr.marshal(false);
-                                       String finalStr="";
+       public void createDmaapFilesForDelete(List<Introspector> dmaapDeleteIntrospectorList) {
+               try {
+                       System.out.println("dmaapDeleteIntrospectorList :: " + dmaapDeleteIntrospectorList.size());
+                       String fileName = "DELETE-" + getMigrationName() + "-" + UUID.randomUUID();
+                       String logDirectory = System.getProperty("AJSC_HOME") + "/logs/data/dmaapEvents/";
+                       File f = new File(logDirectory);
+                       f.mkdirs();
+
+                       try {
+                               Files.createFile(Paths.get(logDirectory + "/" + fileName));
+                       } catch (Exception e) {
+                               logger.error("Unable to create file", e);
+                       }
+
+                       if (dmaapDeleteIntrospectorList.size() > 0) {
+                               dmaapDeleteIntrospectorList.stream().forEach(svIntr -> {
                                        try {
-                                               finalStr=svIntr.getName() + "#@#" + svIntr.getURI() + "#@#" + str+"\n";
-                                               Files.write(Paths.get(logDirectory + "/" + fileName),finalStr.getBytes(),StandardOpenOption.APPEND);
-                                       } catch (IOException e) {
-                                               System.out.println("Unable to generate file with dmaap msgs for " + getMigrationName() + 
-                                                               " Exception is: " + e.getMessage());
-                                               logger.error("Unable to generate file with dmaap msgs for "+getMigrationName(), e);
-                                       }
+                                               String str = svIntr.marshal(false);
+                                               String finalStr = "";
+                                               try {
+                                                       finalStr =
+                                                                       svIntr.getName() + "#@#" + svIntr.getURI() + "#@#" + str + "\n";
+                                                       Files.write(Paths.get(logDirectory + "/" + fileName),
+                                                                       finalStr.getBytes(), StandardOpenOption.APPEND);
+                                               } catch (IOException e) {
+                                                       System.out.println("Unable to generate file with dmaap msgs for " +
+                                                                       getMigrationName() +
+                                                                       " Exception is: " + e.getMessage());
+                                                       logger.error("Unable to generate file with dmaap msgs for " +
+                                                                       getMigrationName(), e);
+                                               }
 
-                               }catch (Exception e) {
+                                       } catch (Exception e) {
                                                // TODO Auto-generated catch block
-                                               e.printStackTrace();
+                                               System.out.println("Exception : " + e.getMessage());
                                        }
                                });
-                               
+
                                //Files.write(Paths.get(logDirectory+"/"+fileName), (Iterable<Vertex>)dmaapVertexList.stream()::iterator);
-                       } 
-               }catch (Exception e) {
-                       e.printStackTrace();
-                       logger.error("Unable to generate file with dmaap msgs for "+getMigrationName(), e);
-               }}
+                       }
+               } catch (Exception e) {
+                       logger.error("Unable to generate file with dmaap msgs for " + getMigrationName(), e);
+               }
+       }
 
        /**
         * As string.
index ef45209..135685c 100644 (file)
@@ -82,15 +82,15 @@ public class ALTSLicenseEntitlementMigration extends Migrator{
                 logger.info("\n");
                 if (!vnfLine.isEmpty()) {
                     if (fileLineCounter != 0) {
-                        String[] fields = vnfLine.split("\\s*,\\s*", -1);
+                        String[] fields = vnfLine.split(",", -1);
                         if (fields.length != this.headerLength) {
                             logger.info("ERROR: Vnf line should contain " + this.headerLength + " columns, contains " + fields.length + " instead.");
                             success = false;
                             continue;
                         }
-                        String newResourceUuid = fields[0];
-                        String groupUuid = fields[1];
-                        String vnfId = fields[19];
+                        String newResourceUuid = fields[0].trim();
+                        String groupUuid = fields[1].trim();
+                        String vnfId = fields[19].trim();
                         logger.info("---------- Processing Line " + vnfLine + "----------");
                         logger.info("newResourceUuid = " + newResourceUuid + " vnfId = " + vnfId + " group uuid = " + groupUuid);
                         if (history.containsKey(vnfId)){
@@ -104,7 +104,7 @@ public class ALTSLicenseEntitlementMigration extends Migrator{
                             }
                         }
                         else {
-                            Set newSet = new HashSet();
+                            Set<String> newSet = new HashSet<>();
                             newSet.add(groupUuid);
                             history.put(vnfId, newSet);
                         }
@@ -120,7 +120,7 @@ public class ALTSLicenseEntitlementMigration extends Migrator{
                         this.ChangeResourceUuid(licenses, newResourceUuid, "license", vnfId, groupUuid);
 
                     } else {
-                        this.headerLength = vnfLine.split("\\s*,\\s*", -1).length;
+                        this.headerLength = vnfLine.split(",", -1).length;
                         logger.info("headerLength: " + headerLength);
                         if (this.headerLength < 22){
                             logger.info("ERROR: Input file should have 22 columns");
@@ -139,7 +139,6 @@ public class ALTSLicenseEntitlementMigration extends Migrator{
             success = false;
         } catch (Exception e) {
             logger.info("encountered exception", e);
-            e.printStackTrace();
             success = false;
         }
     }
index 0b3103b..97936d7 100644 (file)
@@ -120,16 +120,16 @@ public class MigrateHUBEvcInventory extends Migrator {
                 logger.info("\n");
                 if (!line.isEmpty()) {
                     if (fileLineCounter != 0) {
-                        String[] colList = line.split("\\s*,\\s*", -1);
+                        String[] colList = line.split(",", -1);
 //                        if (colList.length != headerLength) {
 //                            logger.info("ERROR: HUB line entry should contain " + headerLength + " columns, contains " + colList.length + " instead.");
 //                            success = false;
 //                            continue;
 //                        }
                         Map<String, String> hubColValues = new HashMap<String, String>();
-                        hubColValues.put("ivlan", colList[1]);
-                        hubColValues.put("nniSvlan", colList[3]);
-                        hubColValues.put("evcName", colList[4]);
+                        hubColValues.put("ivlan", colList[1].trim());
+                        hubColValues.put("nniSvlan", colList[3].trim());
+                        hubColValues.put("evcName", colList[4].trim());
                        
                        String evcName = hubColValues.get("evcName");
                        String ivlan = hubColValues.get("ivlan");
@@ -169,7 +169,7 @@ public class MigrateHUBEvcInventory extends Migrator {
                             }
                         }
                     } else {
-                        this.headerLength = line.split("\\s*,\\s*", -1).length;
+                        this.headerLength = line.split(",", -1).length;
                         logger.info("headerLength: " + headerLength);
                         if (this.headerLength < 5){
                             logger.info("ERROR: Input file should have 5 columns");
index a9fce6a..de97408 100644 (file)
@@ -112,14 +112,14 @@ public class MigrateINVEvcInventory extends Migrator {
                 logger.info("\n");
                 if (!line.isEmpty()) {
                     if (fileLineCounter != 0) {
-                        String[] colList = line.split("\\s*,\\s*", -1);
+                        String[] colList = line.split(",", -1);
                         if (colList.length != headerLength) {
                             logger.info("ERROR: INV line should contain " + headerLength + " columns, contains " + colList.length + " instead.");
                             continue;
                         }
                         Map<String, String> invColValues = new HashMap<String, String>();
-                        invColValues.put("evcName", colList[22]);
-                        invColValues.put("collectorInterconnectType", colList[17]);
+                        invColValues.put("evcName", colList[22].trim());
+                        invColValues.put("collectorInterconnectType", colList[17].trim());
                        
                        String evcName = invColValues.get("evcName");
                        String interconnectType = invColValues.get("collectorInterconnectType");
@@ -152,7 +152,7 @@ public class MigrateINVEvcInventory extends Migrator {
                                continue;
                         }
                     } else {
-                        this.headerLength = line.split("\\s*,\\s*", -1).length;
+                        this.headerLength = line.split(",", -1).length;
                         logger.info("headerLength: " + headerLength);
                         if (this.headerLength < 23){
                             logger.info("ERROR: Input file should have 23 columns");
@@ -183,7 +183,6 @@ public class MigrateINVEvcInventory extends Migrator {
             success = false;
         } catch (Exception e) {
             logger.info("encountered exception", e);
-            e.printStackTrace();
             success = false;
         }
     }
index 0c85481..ade7ec3 100644 (file)
@@ -39,6 +39,7 @@ package org.onap.aai.migration.v12;
  */
 
 
+import java.util.stream.Collectors;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
 import org.javatuples.Pair;
@@ -125,7 +126,6 @@ public class MigrateINVPhysicalInventory extends Migrator {
             success = false;
         } catch (Exception e) {
             logger.info("encountered exception", e);
-            e.printStackTrace();
             success = false;
         }
     }
@@ -231,7 +231,7 @@ public class MigrateINVPhysicalInventory extends Migrator {
                
                lines.stream()
                        .filter(line -> !line.isEmpty())
-                       .map(line -> Arrays.asList(line.split("\\s*,\\s*", -1)))
+                       .map(line -> Arrays.stream(line.split(",", -1)).map(String::trim).collect(Collectors.toList()))
 //                     .filter(this::verifyLine)
                        .map(this::processLine)
                        .filter(Optional::isPresent)
@@ -316,7 +316,7 @@ public class MigrateINVPhysicalInventory extends Migrator {
                        firstLine = lines.get(0);
                }
 
-               this.headerLength = firstLine.split("\\s*,\\s*", -1).length;
+               this.headerLength = firstLine.split(",", -1).length;
                logger.info("headerLength: " + headerLength);
                if (this.headerLength < 21){
                        String msg = "ERROR: Input file should have 21 columns";
index b0bacde..28b5b7b 100644 (file)
@@ -136,25 +136,25 @@ public class MigratePATHEvcInventory extends Migrator {
                 logger.info("\n");
                 if (!line.isEmpty()) {
                     if (fileLineCounter != 0) {
-                        String[] colList = line.split("\\s*,\\s*", -1);
+                        String[] colList = line.split(",", -1);
                         if (colList.length != headerLength) {
                             logger.info("ERROR: PATH line should contain " + headerLength + " columns, contains " + colList.length + " instead.");
 //                            success = false;
                             continue;
                         }
                         Map<String, String> pathColValues = new HashMap<String, String>();
-                        pathColValues.put("evcName", colList[1]);
-                        pathColValues.put("bearerFacingCircuit", colList[4]);
-                        pathColValues.put("bearerCvlan", colList[6]);
-                       pathColValues.put("bearerSvlan", colList[7]);
-                       pathColValues.put("bearerPtniiName", colList[8]);
-                       String bearerPortAid = colList[12].replaceAll("^\"|\"$", "").replaceAll("\\s+","");
+                        pathColValues.put("evcName", colList[1].trim());
+                        pathColValues.put("bearerFacingCircuit", colList[4].trim());
+                        pathColValues.put("bearerCvlan", colList[6].trim());
+                       pathColValues.put("bearerSvlan", colList[7].trim());
+                       pathColValues.put("bearerPtniiName", colList[8].trim());
+                       String bearerPortAid = colList[12].trim().replaceAll("^\"|\"$", "").replaceAll("\\s+","");
                        pathColValues.put("bearerPortAid", bearerPortAid);
-                       pathColValues.put("collectorFacingCircuit", colList[14]);
-                       pathColValues.put("collectorCvlan", colList[16]);
-                       pathColValues.put("collectorSvlan", colList[17]);
-                       pathColValues.put("collectorPtniiName", colList[18]);
-                       String collectorPortAid = colList[22].replaceAll("^\"|\"$", "").replaceAll("\\s+","");
+                       pathColValues.put("collectorFacingCircuit", colList[14].trim());
+                       pathColValues.put("collectorCvlan", colList[16].trim());
+                       pathColValues.put("collectorSvlan", colList[17].trim());
+                       pathColValues.put("collectorPtniiName", colList[18].trim());
+                       String collectorPortAid = colList[22].trim().replaceAll("^\"|\"$", "").replaceAll("\\s+","");
                        pathColValues.put("collectorPortAid", collectorPortAid);
                        
                        
@@ -202,7 +202,7 @@ public class MigratePATHEvcInventory extends Migrator {
                             }
                         }
                     } else {
-                        this.headerLength = line.split("\\s*,\\s*", -1).length;
+                        this.headerLength = line.split(",", -1).length;
                         logger.info("headerLength: " + headerLength);
                         if (this.headerLength < 24){
                             logger.info("ERROR: Input file should have 24 columns");
@@ -232,7 +232,6 @@ public class MigratePATHEvcInventory extends Migrator {
             success = false;
         } catch (Exception e) {
             logger.info("encountered exception", e);
-            e.printStackTrace();
             success = false;
         }
     }
index a24d21a..2894883 100644 (file)
@@ -131,36 +131,36 @@ public class MigrateSAREvcInventory extends Migrator {
                 logger.info("\n");
                 if (!line.isEmpty()) {
                     if (fileLineCounter != 0) {
-                        String[] colList = line.split("\\s*,\\s*", -1);
+                        String[] colList = line.split(",", -1);
 //                        if (colList.length != headerLength) {
 //                            logger.info("ERROR: SAR line should contain " + headerLength + " columns, contains " + colList.length + " instead.");
 //                            success = false;
 //                            continue;
 //                        }
                         Map<String, String> sarColValues = new HashMap<String, String>();
-                        sarColValues.put("evcName", colList[0]);
-                        sarColValues.put("subscriberName", colList[1]);
-                        sarColValues.put("espName", colList[2]);
-                        sarColValues.put("bearerCircuitId", colList[3]);
-                       sarColValues.put("bearerTagMode", colList[4]);
-                       sarColValues.put("bearerCvlan", colList[5]);
-                       sarColValues.put("bearerSvlan", colList[6]);
-                       sarColValues.put("bearerPtniiName", colList[7]);
-                       sarColValues.put("bearerSlotName", colList[8]);
-                       String bearerPortAid = colList[9].replaceAll("^\"|\"$", "").replaceAll("\\s+","");
+                        sarColValues.put("evcName", colList[0].trim());
+                        sarColValues.put("subscriberName", colList[1].trim());
+                        sarColValues.put("espName", colList[2].trim());
+                        sarColValues.put("bearerCircuitId", colList[3].trim());
+                       sarColValues.put("bearerTagMode", colList[4].trim());
+                       sarColValues.put("bearerCvlan", colList[5].trim());
+                       sarColValues.put("bearerSvlan", colList[6].trim());
+                       sarColValues.put("bearerPtniiName", colList[7].trim());
+                       sarColValues.put("bearerSlotName", colList[8].trim());
+                       String bearerPortAid = colList[9].trim().replaceAll("^\"|\"$", "").replaceAll("\\s+","");
                        sarColValues.put("bearerPortAid", bearerPortAid);
-                       sarColValues.put("bearerPortType", colList[10]);
-                       sarColValues.put("collectorCircuitId", colList[11]);
-                       sarColValues.put("collectorTagMode", colList[12]);
-                       sarColValues.put("collectorCvlan", colList[13]);
-                       sarColValues.put("collectorSvlan", colList[14]);
-                       sarColValues.put("collectorPtniiName", colList[15]);
-                       sarColValues.put("collectorSlotName", colList[16]);
-                       String collectorPortAid = colList[17].replaceAll("^\"|\"$", "").replaceAll("\\s+","");
+                       sarColValues.put("bearerPortType", colList[10].trim());
+                       sarColValues.put("collectorCircuitId", colList[11].trim());
+                       sarColValues.put("collectorTagMode", colList[12].trim());
+                       sarColValues.put("collectorCvlan", colList[13].trim());
+                       sarColValues.put("collectorSvlan", colList[14].trim());
+                       sarColValues.put("collectorPtniiName", colList[15].trim());
+                       sarColValues.put("collectorSlotName", colList[16].trim());
+                       String collectorPortAid = colList[17].trim().replaceAll("^\"|\"$", "").replaceAll("\\s+","");
                        sarColValues.put("collectorPortAid", collectorPortAid);
-                       sarColValues.put("collectorPortType", colList[18]);
-                       sarColValues.put("espEvcCircuitId", colList[19]);
-                       sarColValues.put("evcAccessCIR", colList[20]);
+                       sarColValues.put("collectorPortType", colList[18].trim());
+                       sarColValues.put("espEvcCircuitId", colList[19].trim());
+                       sarColValues.put("evcAccessCIR", colList[20].trim());
                        
                        String evcName = sarColValues.get("evcName");
                         if (!AAIConfig.isEmpty(evcName)) {
@@ -181,7 +181,7 @@ public class MigrateSAREvcInventory extends Migrator {
                                
                         }
                     } else {
-                        this.headerLength = line.split("\\s*,\\s*", -1).length;
+                        this.headerLength = line.split(",", -1).length;
                         logger.info("headerLength: " + headerLength);
                         if (this.headerLength < 21){
                             logger.info("ERROR: Input file should have 21 columns");
@@ -211,7 +211,6 @@ public class MigrateSAREvcInventory extends Migrator {
             success = false;
         } catch (Exception e) {
             logger.info("encountered exception", e);
-            e.printStackTrace();
             success = false;
         }
     }
index b420c57..d102f99 100644 (file)
@@ -111,7 +111,6 @@ public class SDWANSpeedChangeMigration extends Migrator {
 
             }
         } catch (AAIException e) {
-            e.printStackTrace();
             success = false;
         }
 
index 6273f84..dbb892d 100644 (file)
@@ -192,7 +192,7 @@ public class UpdateAaiUriIndexMigration extends Migrator {
                                                        .status(SchemaStatus.DISABLED)
                                                        .call();
                                } catch (Exception e) {
-                                       e.printStackTrace();
+                                       logger.info("AwaitGraphIndexStatus error: " + e.getMessage());
                                }
                        }
 
@@ -260,7 +260,7 @@ public class UpdateAaiUriIndexMigration extends Migrator {
                                                .status(SchemaStatus.REGISTERED)
                                                .call();
                        } catch (Exception e) {
-                               e.printStackTrace();
+                               logger.info("AwaitGraphIndexStatus error: " + e.getMessage());
                        }
                }
 
@@ -279,7 +279,7 @@ public class UpdateAaiUriIndexMigration extends Migrator {
                                                .status(SchemaStatus.ENABLED)
                                                .call();
                        } catch (Exception e) {
-                               e.printStackTrace();
+                               logger.info("AwaitGraphIndexStatus error: " + e.getMessage());
                        }
                }
 
index ed3b84d..4a55f71 100644 (file)
  */
 package org.onap.aai.migration.v12;
 
+import java.io.UnsupportedEncodingException;
 import java.nio.charset.UnsupportedCharsetException;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.UUID;
+import java.util.stream.Collectors;
+import javax.ws.rs.core.UriBuilder;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
 import org.onap.aai.db.props.AAIProperties;
 import org.onap.aai.edges.EdgeIngestor;
+import org.onap.aai.edges.enums.AAIDirection;
 import org.onap.aai.edges.enums.EdgeProperty;
 import org.onap.aai.exceptions.AAIException;
 import org.onap.aai.introspection.LoaderFactory;
 import org.onap.aai.introspection.ModelType;
-import org.onap.aai.serialization.db.EdgeSerializer;
-import org.onap.aai.introspection.exceptions.AAIUnknownObjectException;
-import org.onap.aai.migration.*;
-import org.onap.aai.edges.enums.AAIDirection;
+import org.onap.aai.migration.MigrationDangerRating;
+import org.onap.aai.migration.MigrationPriority;
+import org.onap.aai.migration.Migrator;
+import org.onap.aai.migration.Status;
 import org.onap.aai.serialization.db.DBSerializer;
+import org.onap.aai.serialization.db.EdgeSerializer;
 import org.onap.aai.serialization.engines.TransactionalGraphEngine;
 import org.onap.aai.setup.SchemaVersion;
 import org.onap.aai.setup.SchemaVersions;
 import org.springframework.web.util.UriUtils;
 
-import javax.ws.rs.core.UriBuilder;
-import java.io.UnsupportedEncodingException;
-import java.util.*;
-import java.util.stream.Collectors;
-
 //@Enabled
 
 @MigrationPriority(1000)
@@ -99,12 +104,8 @@ public class UriMigration extends Migrator {
                        logger.info(topLevelNodeType + " : " + parentSet.size());
                        try {
                                this.verifyOrAddUri("", parentSet);
-                       } catch (AAIUnknownObjectException e) {
-                               e.printStackTrace();
-                       } catch (AAIException e) {
-                               e.printStackTrace();
-                       } catch (UnsupportedEncodingException e) {
-                               e.printStackTrace();
+                       } catch (UnsupportedEncodingException | AAIException e) {
+                               logger.info("VerifyOrAddUri error: " + e.getMessage());
                        }
                });
                logger.info("RUNTIME: " + (System.currentTimeMillis() - start));
index 1d5843e..15649e1 100644 (file)
@@ -254,7 +254,6 @@ public class MigrateBadWidgetModelsPartOne extends EdgeSwingMigrator {
                        success = false;
                } catch (Exception e) {
                        logger.error("encountered exception", e);
-                       e.printStackTrace();
                        success = false;
                }
                return fileLines;
index 7363d3c..d127c9e 100644 (file)
@@ -25,13 +25,9 @@ import java.io.FileReader;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Map;
 import java.util.Optional;
-import java.util.Set;
-
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
 import org.apache.tinkerpop.gremlin.structure.Direction;
@@ -41,7 +37,10 @@ import org.javatuples.Pair;
 import org.onap.aai.db.props.AAIProperties;
 import org.onap.aai.edges.EdgeIngestor;
 import org.onap.aai.introspection.LoaderFactory;
-import org.onap.aai.migration.*;
+import org.onap.aai.migration.EdgeSwingMigrator;
+import org.onap.aai.migration.MigrationDangerRating;
+import org.onap.aai.migration.MigrationPriority;
+import org.onap.aai.migration.Status;
 import org.onap.aai.serialization.db.EdgeSerializer;
 import org.onap.aai.serialization.engines.TransactionalGraphEngine;
 import org.onap.aai.setup.SchemaVersions;
@@ -420,7 +419,6 @@ public class MigrateBadWidgetModelsPartTwo extends EdgeSwingMigrator {
                        success = false;
                } catch (Exception e) {
                        logger.error("encountered exception", e);
-                       e.printStackTrace();
                        success = false;
                }
                return fileLines;
index 0edff80..6c2b795 100644 (file)
@@ -47,14 +47,12 @@ import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Optional;
-
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
 import org.onap.aai.db.props.AAIProperties;
 import org.onap.aai.edges.EdgeIngestor;
 import org.onap.aai.introspection.LoaderFactory;
-import org.onap.aai.migration.Enabled;
 import org.onap.aai.migration.MigrationDangerRating;
 import org.onap.aai.migration.MigrationPriority;
 import org.onap.aai.migration.Migrator;
@@ -156,20 +154,20 @@ public class MigrateForwarderEvcCircuitId extends Migrator {
                 String line = lineItr.next().replace("\n", "").replace("\r", "");
                 if (!line.isEmpty()) {
                     if (fileLineCounter != 0) {
-                        String[] colList = line.split("\\s*,\\s*", -1);
+                        String[] colList = line.split(",", -1);
                         CircuitIdFileData lineData = new CircuitIdFileData();
-                        lineData.setPnfName(colList[0].replaceAll("^\"|\"$", "")
+                        lineData.setPnfName(colList[0].trim().replaceAll("^\"|\"$", "")
                                        .replaceAll("[\t\n\r]+", "").trim());
-                        lineData.setInterfaceName(colList[1].replaceAll("^\"|\"$", "")
+                        lineData.setInterfaceName(colList[1].trim().replaceAll("^\"|\"$", "")
                                        .replaceAll("[\t\n\r]+", "").trim());
-                        lineData.setOldCircuitId(colList[2].replaceAll("^\"|\"$", "")
+                        lineData.setOldCircuitId(colList[2].trim().replaceAll("^\"|\"$", "")
                                        .replaceAll("[\t\n\r]+", "").trim());
-                        lineData.setNewCircuitId(colList[4].replaceAll("^\"|\"$", "")
+                        lineData.setNewCircuitId(colList[4].trim().replaceAll("^\"|\"$", "")
                                        .replaceAll("[\t\n\r]+", "").trim());
                         circuitIdList.add(lineData);
                        
                     } else {
-                        this.headerLength = line.split("\\s*,\\s*", -1).length;
+                        this.headerLength = line.split(",", -1).length;
                         logger.info("headerLength: " + headerLength + "\n");
                         if (this.headerLength != 6){
                             logger.info(this.MIGRATION_ERROR + "ERROR: Input file should have 6 columns");
@@ -195,7 +193,6 @@ public class MigrateForwarderEvcCircuitId extends Migrator {
             success = false;
         } catch (Exception e) {
             logger.info(this.MIGRATION_ERROR + "encountered exception", e);
-            e.printStackTrace();
             success = false;
         }
     }
@@ -209,7 +206,7 @@ public class MigrateForwarderEvcCircuitId extends Migrator {
                                        .has(this.PROPERTY_FORWARDER_ROLE, this.VALUE_INGRESS).has(this.PROPERTY_SEQUENCE, this.VALUE_EXPECTED_SEQUENCE)
                                        .out("org.onap.relationships.inventory.Uses").in("org.onap.relationships.inventory.BelongsTo");
                                if(!nodeList.hasNext()) {
-                                       logger.info(this.MIGRATION_ERROR + "ERROR: Failure to update Circuit Id " + circuitIdList.get(i).getOldCircuitId() + 
+                                       logger.info(this.MIGRATION_ERROR + "ERROR: Failure to update Circuit Id " + circuitIdList.get(i).getOldCircuitId() +
                                                        " to " + circuitIdList.get(i).getNewCircuitId() + " Graph Traversal failed \n");
                                        migrationFailure++;
                                }
@@ -218,30 +215,30 @@ public class MigrateForwarderEvcCircuitId extends Migrator {
                                        boolean updateSuccess = false;
                                        if (forwarderEvcVtx != null) {
                                                logger.info("forwarder-evc-id is " + forwarderEvcVtx.value("forwarder-evc-id"));
-                                               if(forwarderEvcVtx.property(PROPERTY_CIRCUIT_ID).isPresent() && 
+                                               if(forwarderEvcVtx.property(PROPERTY_CIRCUIT_ID).isPresent() &&
                                                   forwarderEvcVtx.value(PROPERTY_CIRCUIT_ID).equals(circuitIdList.get(i).getNewCircuitId())) {
-                                                       logger.info("Skipping Record: Old Collector CircuitId " + forwarderEvcVtx.value(PROPERTY_CIRCUIT_ID) + 
+                                                       logger.info("Skipping Record: Old Collector CircuitId " + forwarderEvcVtx.value(PROPERTY_CIRCUIT_ID) +
                                                                        " is the same as New Collector CircuitId " + circuitIdList.get(i).getNewCircuitId() + "\n");
                                                        migrationFailure++;
                                                }
                                                else if(!circuitIdList.get(i).getNewCircuitId().isEmpty() &&
-                                                       forwarderEvcVtx.property(PROPERTY_CIRCUIT_ID).isPresent() && 
+                                                       forwarderEvcVtx.property(PROPERTY_CIRCUIT_ID).isPresent() &&
                                                        circuitIdList.get(i).getOldCircuitId().equals(forwarderEvcVtx.value(PROPERTY_CIRCUIT_ID)))
                                                {
                                                        try {
                                                                forwarderEvcVtx.property(PROPERTY_CIRCUIT_ID, circuitIdList.get(i).getNewCircuitId());
                                                                this.touchVertexProperties(forwarderEvcVtx, false);
                                                                updateSuccess = true;
-                                                               
+
                                                        } catch (Exception e) {
                                                                logger.info(e.toString());
-                                                               logger.info(this.MIGRATION_ERROR + "ERROR: Failure to update Circuit Id " + circuitIdList.get(i).getOldCircuitId() + 
+                                                               logger.info(this.MIGRATION_ERROR + "ERROR: Failure to update Circuit Id " + circuitIdList.get(i).getOldCircuitId() +
                                                                                " to " + circuitIdList.get(i).getNewCircuitId() + "\n");
                                                                migrationFailure++;
-                                                               
+
                                                        }
                                                        if(updateSuccess) {
-                                                               String dmaapMsg = System.nanoTime() + "_" + forwarderEvcVtx.id().toString() + "_"       + 
+                                                               String dmaapMsg = System.nanoTime() + "_" + forwarderEvcVtx.id().toString() + "_"       +
                                                                                forwarderEvcVtx.value("resource-version").toString();
                                                                dmaapMsgList.add(dmaapMsg);
                                                                logger.info("Update of Circuit Id " + circuitIdList.get(i).getOldCircuitId() + " to " +
@@ -249,14 +246,14 @@ public class MigrateForwarderEvcCircuitId extends Migrator {
                                                                migrationSuccess++;
                                                        }
                                                }
-                                               else if(!forwarderEvcVtx.property(PROPERTY_CIRCUIT_ID).isPresent())     
+                                               else if(!forwarderEvcVtx.property(PROPERTY_CIRCUIT_ID).isPresent())
                                                {
-                                                       logger.info(this.MIGRATION_ERROR + "ERROR: Old Collector Circuit Id not found " + circuitIdList.get(i).getOldCircuitId() + 
+                                                       logger.info(this.MIGRATION_ERROR + "ERROR: Old Collector Circuit Id not found " + circuitIdList.get(i).getOldCircuitId() +
                                                                        " was not updated to " + circuitIdList.get(i).getNewCircuitId() + "\n");
                                                        migrationFailure++;
                                                }
                                                else {
-                                                       logger.info(this.MIGRATION_ERROR + "ERROR: Failure to update Circuit Id " + circuitIdList.get(i).getOldCircuitId() + 
+                                                       logger.info(this.MIGRATION_ERROR + "ERROR: Failure to update Circuit Id " + circuitIdList.get(i).getOldCircuitId() +
                                                                        " to " + circuitIdList.get(i).getNewCircuitId() + "\n");
                                                        migrationFailure++;
                                                }
index a3085c9..ffe7266 100644 (file)
@@ -145,24 +145,20 @@ public class MigrateSameSourcedRCTROPserverData extends EdgeSwingMigrator {
         try {
                logger.info("RCT pserver count: "+rctCount);
             updateToLatestRCT(pserverTraversalRCT);
-        } catch (UnsupportedEncodingException e) {
-            e.printStackTrace();
-        } catch (AAIException e) {
-            e.printStackTrace();
+        } catch (UnsupportedEncodingException | AAIException e) {
+          logger.info("UpdateToLatestRCT error: " + e.getMessage());
         }
 
-        List<Vertex>  pserverTraversalRO = graphTraversalSource().V().has("aai-node-type", "pserver").has("source-of-truth", P.within("RO", "AAI-EXTENSIONS")).toList();
+      List<Vertex>  pserverTraversalRO = graphTraversalSource().V().has("aai-node-type", "pserver").has("source-of-truth", P.within("RO", "AAI-EXTENSIONS")).toList();
         int roCount = pserverTraversalRO.size();
         try {
                logger.info("RO pserver count: "+roCount);
             updateToLatestRO(pserverTraversalRO);
-        } catch (UnsupportedEncodingException e) {
-            e.printStackTrace();
-        } catch (AAIException e) {
-            e.printStackTrace();
+        } catch (UnsupportedEncodingException | AAIException e) {
+          logger.info("UpdateToLatestRO error: " + e.getMessage());
         }
 
-        logger.info ("\n \n ******* Migration Summary Counts for RCT and RO sourced pservers in A&AI ********* \n");
+      logger.info ("\n \n ******* Migration Summary Counts for RCT and RO sourced pservers in A&AI ********* \n");
         logger.info(this.MIGRATION_SUMMARY_COUNT + "Total number of RCT pservers: " +rctCount);
         logger.info(this.MIGRATION_SUMMARY_COUNT + "Duplicate RCT pserver count: "+ dupRctCount);
         logger.info(this.MIGRATION_SUMMARY_COUNT + "Number of RCT updated: "+ rctPserversUpdatedCount);
index 3c10ab6..a8c2f72 100644 (file)
@@ -30,7 +30,6 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Optional;
-
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
@@ -38,7 +37,6 @@ import org.apache.tinkerpop.gremlin.structure.Vertex;
 import org.onap.aai.db.props.AAIProperties;
 import org.onap.aai.edges.EdgeIngestor;
 import org.onap.aai.introspection.LoaderFactory;
-import org.onap.aai.migration.Enabled;
 import org.onap.aai.migration.MigrationDangerRating;
 import org.onap.aai.migration.MigrationPriority;
 import org.onap.aai.migration.Migrator;
@@ -212,7 +210,6 @@ public class MigrateSdnaIvlanData extends Migrator {
             success = false;
         } catch (Exception e) {
             logger.info(this.MIGRATION_ERROR + "encountered exception", e);
-            e.printStackTrace();
             success = false;
         }        
 
index 6104d9d..fd8bf5b 100644 (file)
@@ -32,6 +32,7 @@ import java.util.Optional;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.atomic.AtomicInteger;
 
+import java.util.stream.Collectors;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
 import org.javatuples.Pair;
@@ -174,7 +175,6 @@ public class MigrateCloudRegionUpgradeCycle extends Migrator {
                        success = false;
                } catch (Exception e) {
                        logger.info("encountered exception", e);
-                       e.printStackTrace();
                        success = false;
                }
        }
@@ -208,7 +208,7 @@ public class MigrateCloudRegionUpgradeCycle extends Migrator {
 
                logger.info("Total rows count excluding header: " + lines.size());
 
-               lines.stream().filter(line -> !line.isEmpty()).map(line -> Arrays.asList(line.split("\\s*,\\s*", -1)))
+               lines.stream().filter(line -> !line.isEmpty()).map(line -> Arrays.stream(line.split(",", -1)).map(String::trim).collect(Collectors.toList()))
                                .map(this::processRegionUpgradeCycle).filter(Optional::isPresent).map(Optional::get).forEach(p -> {
                                        processedRowsCount.getAndIncrement();
                                        String pnfName = p.getValue0();
@@ -219,7 +219,7 @@ public class MigrateCloudRegionUpgradeCycle extends Migrator {
 
                fileContent.add(regionMap);
 
-               lines.stream().filter(line -> !line.isEmpty()).map(line -> Arrays.asList(line.split("\\s*,\\s*", -1)))
+               lines.stream().filter(line -> !line.isEmpty()).map(line -> Arrays.stream(line.split(",", -1)).map(String::trim).collect(Collectors.toList()))
                                .map(this::processRegionAlias).filter(Optional::isPresent).map(Optional::get).forEach(p -> {
                                        processedRowsCount.getAndIncrement();
                                        String pnfName = p.getValue0();
@@ -319,7 +319,7 @@ public class MigrateCloudRegionUpgradeCycle extends Migrator {
                        firstLine = lines.get(0);
                }
 
-               this.headerLength = firstLine.split("\\s*,\\s*", -1).length;
+               this.headerLength = firstLine.split(",", -1).length;
                logger.info("headerLength: " + headerLength);
                if (this.headerLength < 4) {
                        String msg = "ERROR: Input file should have 4 columns";
index 3ae17bd..db523cd 100644 (file)
@@ -183,15 +183,15 @@ public class MigrateRadcomChanges extends EdgeSwingMigrator {
                String line = lineItr.next().replace("\n", "").replace("\r", "");
                if (!line.isEmpty()) {
                     if (typeFileLineCounter != 0) {
-                        String[] colList = line.split("\\s*,\\s*", -1);
-                        if(!colList[0].equalsIgnoreCase(SERVICE_MODEL_TYPE) && !colList[0].equalsIgnoreCase(RESOURCE_MODEL_TYPE)) {
-                                               vfModuleFileLineList.add(new VfModuleFileData(colList[0], colList[5], colList[6]));
+                        String[] colList = line.split(",", -1);
+                        if(!colList[0].trim().equalsIgnoreCase(SERVICE_MODEL_TYPE) && !colList[0].trim().equalsIgnoreCase(RESOURCE_MODEL_TYPE)) {
+                                               vfModuleFileLineList.add(new VfModuleFileData(colList[0].trim(), colList[5].trim(), colList[6].trim()));
                                        }
-                        if(!colList[1].isEmpty() && !fileTypeList.contains(colList[1])) {
-                               fileTypeList.add(colList[1]);
+                        if(!colList[1].trim().isEmpty() && !fileTypeList.contains(colList[1].trim())) {
+                               fileTypeList.add(colList[1].trim());
                         }
                     } else {
-                        this.headerLength = line.split("\\s*,\\s*", -1).length;
+                        this.headerLength = line.split(",", -1).length;
                         logger.info("headerLength: " + headerLength + "\n");
                         if (this.headerLength != 7 ){
                             logger.info(MIGRATION_ERROR + "ERROR: Input file should have 7 columns");
@@ -211,7 +211,6 @@ public class MigrateRadcomChanges extends EdgeSwingMigrator {
             success = false;
         } catch (Exception e) {
             logger.info(MIGRATION_ERROR + "encountered exception", e);
-            e.printStackTrace();
             success = false;
         }
         
@@ -238,15 +237,15 @@ public class MigrateRadcomChanges extends EdgeSwingMigrator {
                                String line = lineItr.next().replace("\n", "").replace("\r", "");
                                if (!line.isEmpty()) {
                                        if (modelFileLineCounter != 0) {
-                                               String[] colList = line.split("\\s*,\\s*", -1);
-                                               if(colList[1].equals(fileTypeList.get(i)) && colList[0].equalsIgnoreCase(SERVICE_MODEL_TYPE)) {
-                                                       newServiceModelInvariantId = colList[2];
-                                                       newServiceModelVersionId = colList[3];
+                                               String[] colList = line.split(",", -1);
+                                               if(colList[1].trim().equals(fileTypeList.get(i)) && colList[0].trim().equalsIgnoreCase(SERVICE_MODEL_TYPE)) {
+                                                       newServiceModelInvariantId = colList[2].trim();
+                                                       newServiceModelVersionId = colList[3].trim();
                                                }
-                                               else if(colList[1].equals(fileTypeList.get(i)) && colList[0].equalsIgnoreCase(RESOURCE_MODEL_TYPE)) {
-                                                       newResourceModelInvariantId = colList[2];
-                                                       newResourceModelVersionId = colList[3];
-                                                       newResourceModelCustomizationId = colList[4];
+                                               else if(colList[1].trim().equals(fileTypeList.get(i)) && colList[0].trim().equalsIgnoreCase(RESOURCE_MODEL_TYPE)) {
+                                                       newResourceModelInvariantId = colList[2].trim();
+                                                       newResourceModelVersionId = colList[3].trim();
+                                                       newResourceModelCustomizationId = colList[4].trim();
                                                }
                                        }
                                }
@@ -261,12 +260,12 @@ public class MigrateRadcomChanges extends EdgeSwingMigrator {
                                String line = lineItr.next().replace("\n", "").replace("\r", "");
                                if (!line.isEmpty()) {
                                        if (genericVnfFileLineCounter != 0) {
-                                               String[] colList = line.split("\\s*,\\s*", -1);
-                                               if(colList[1].equals(fileTypeList.get(i))) {
-                                                       genericVnfList.add(colList[0]);
+                                               String[] colList = line.split(",", -1);
+                                               if(colList[1].trim().equals(fileTypeList.get(i))) {
+                                                       genericVnfList.add(colList[0].trim());
                                                }
                                        } else {
-                                               this.headerLength = line.split("\\s*,\\s*", -1).length;
+                                               this.headerLength = line.split(",", -1).length;
                                                logger.info("headerLength: " + headerLength + "\n");
                                                if (this.headerLength != 2){
                                                        logger.info(MIGRATION_ERROR + "ERROR: Input file should have 2 columns");
@@ -288,7 +287,6 @@ public class MigrateRadcomChanges extends EdgeSwingMigrator {
                 success = false;
             } catch (Exception e) {
                 logger.info(MIGRATION_ERROR + "encountered exception", e);
-                e.printStackTrace();
                 success = false;
             }
         }
index 0519cad..7452e2b 100644 (file)
@@ -191,7 +191,6 @@ public class MigrateVlanTag extends EdgeSwingMigrator {
                } catch (Exception e) {
                        logger.info("encountered exception", e.getMessage());
                        logger.error("encountered exception", e);
-                       e.printStackTrace();
                        success = false;
                }
        }
index 4297886..d846a50 100644 (file)
@@ -70,7 +70,7 @@ public class SendDeleteMigrationNotificationsMain {
                try {
                        internal.process(basePath);
                } catch (Exception e) {
-                       e.printStackTrace();
+                       // TODO Catch exception
                }
                AAIGraph.getInstance().graphShutdown();
                System.exit(0);
index 0eeaecd..e608284 100644 (file)
@@ -71,7 +71,7 @@ public class SendMigrationNotificationsMain {
                try {
                        internal.process(basePath);
                } catch (Exception e) {
-                       e.printStackTrace();
+                       System.out.println("SendMigrationNotifications process error : " + e.getMessage());
                }
                AAIGraph.getInstance().graphShutdown();
                System.exit(0);
index 25d7bc7..2b2a61d 100644 (file)
  */
 package org.onap.aai.migration.v12;
 
-import org.janusgraph.core.JanusGraphFactory;
-import org.janusgraph.core.JanusGraph;
-import org.janusgraph.core.JanusGraphTransaction;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategy;
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.JanusGraphFactory;
+import org.janusgraph.core.JanusGraphTransaction;
 import org.javatuples.Pair;
-import org.junit.*;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
 import org.onap.aai.AAISetup;
-import org.onap.aai.dbmap.DBConnectionType;
 import org.onap.aai.introspection.Loader;
 import org.onap.aai.introspection.ModelType;
-import org.onap.aai.setup.SchemaVersions;
-import org.onap.aai.setup.SchemaVersion;
-import org.onap.aai.serialization.engines.QueryStyle;
 import org.onap.aai.serialization.engines.JanusGraphDBEngine;
+import org.onap.aai.serialization.engines.QueryStyle;
 import org.onap.aai.serialization.engines.TransactionalGraphEngine;
 
-import java.util.*;
-
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
-
 public class MigrateINVPhysicalInventoryMethodTest extends AAISetup {
 
        private final static ModelType introspectorFactoryType = ModelType.MOXY;
@@ -110,12 +117,12 @@ public class MigrateINVPhysicalInventoryMethodTest extends AAISetup {
        public void readLineTest() throws Exception {
                MigrateINVPhysicalInventory m = new MigrateINVPhysicalInventory(spy, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
                String line = "pnf-name-collector-1,06000D.121,5150,AED,,2001:1890:fcfe:7000:7021:0:1:2,64,,,,,\"1.7    \",SFP_1GE/Ethernet_10/100/1000M,ACCESS,N,N,M0651881_ST,SHARED,DOUBLE,SFP-1GE-LX,1000Mbps,,evc-name-1\n";
-               Pair<String, String> pair = m.processLine(Arrays.asList(line.split("\\s*,\\s*", -1))).get();
+               Pair<String, String> pair = m.processLine(Arrays.asList(line.split(",", -1))).get();
                assertEquals("Test 1","pnf-name-collector-1", pair.getValue0());
                assertEquals("Test 1","1.7", pair.getValue1());
 
                line = "pnf-name-1,06000D.121,5150,AED,,2001:1890:fcfe:7000:7021:0:1:2,64,,,,,1.2,SFP_1GE/Ethernet_10/100/1000M,ACCESS,N,N,M0651882_ST,SHARED,DOUBLE,SFP-1GE-LX,1000Mbps,,evc-name-3";
-               pair = m.processLine(Arrays.asList(line.split("\\s*,\\s*", -1))).get();
+               pair = m.processLine(Arrays.asList(line.split(",", -1))).get();
                assertEquals("Test 1","pnf-name-1", pair.getValue0());
                assertEquals("Test 1","1.2", pair.getValue1());
 
index f89f87d..fc7e55f 100644 (file)
@@ -101,7 +101,7 @@ public class SendDeleteMigrationNotificationsTest extends AAISetup {
                        try{
                                Files.createFile(Paths.get(FILE));
                        }catch(Exception e) {
-                               e.printStackTrace();
+                               System.out.println("Create File error : " + e.getMessage());
                        }
                        String finalStr = "";
                        finalStr = "pserver" + "#@#" + "/cloud-infrastructure/pservers/pserver/"+SendDeleteMigrationNotifications.class.getSimpleName()+"-pserver-1" + "#@#" + "{\"hostname\":\""+ SendDeleteMigrationNotifications.class.getSimpleName()+"-pserver-1\",\"resource-version\":\"333\"}" + "\n";