summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/onap/aai/dataexport/DataExportTasks.java5
-rw-r--r--src/main/java/org/onap/aai/datagrooming/DataGroomingTasks.java2
-rw-r--r--src/main/java/org/onap/aai/datasnapshot/PrintVertexDetails.java9
-rw-r--r--src/main/java/org/onap/aai/db/schema/AuditOXM.java2
-rw-r--r--src/main/java/org/onap/aai/dbgen/UpdatePropertyToolInternal.java5
-rw-r--r--src/main/java/org/onap/aai/migration/v12/DeletePInterface.java2
-rw-r--r--src/main/java/org/onap/aai/migration/v12/MigrateDataFromASDCToConfiguration.java2
-rw-r--r--src/main/java/org/onap/aai/migration/v12/MigrateSAREvcInventory.java4
-rw-r--r--src/main/java/org/onap/aai/migration/v13/MigrateModelVer.java4
-rw-r--r--src/main/java/org/onap/aai/migration/v13/MigratePserverAndPnfEquipType.java4
-rw-r--r--src/main/java/org/onap/aai/migration/v14/PserverDedupWithDifferentSourcesOfTruth.java2
-rw-r--r--src/main/java/org/onap/aai/rest/search/GenericQueryProcessor.java4
-rw-r--r--src/main/java/org/onap/aai/util/UniquePropertyCheck.java5
13 files changed, 22 insertions, 28 deletions
diff --git a/src/main/java/org/onap/aai/dataexport/DataExportTasks.java b/src/main/java/org/onap/aai/dataexport/DataExportTasks.java
index 028c729..143312b 100644
--- a/src/main/java/org/onap/aai/dataexport/DataExportTasks.java
+++ b/src/main/java/org/onap/aai/dataexport/DataExportTasks.java
@@ -76,7 +76,8 @@ import org.apache.commons.io.filefilter.RegexFileFilter;
public class DataExportTasks {
private static final Logger LOGGER;
- private static final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
+
+ private final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
static {
System.setProperty("aai.service.name", DataExportTasks.class.getSimpleName());
@@ -160,7 +161,7 @@ public class DataExportTasks {
if ( "false".equalsIgnoreCase(enableMultipleSnapshots)){
// find the second to latest data snapshot
snapshot = findSnapshot();
- snapshotFilePath = snapshot.getAbsolutePath();
+ snapshotFilePath = snapshot != null ?snapshot.getAbsolutePath() : null;
if ( "true".equalsIgnoreCase (enablePartialGraph) ) {
String[] command = new String[2];
command[0] = AAIConstants.AAI_HOME + AAIConstants.AAI_FILESEP + "bin" + AAIConstants.AAI_FILESEP + "dynamicPayloadPartial.sh";
diff --git a/src/main/java/org/onap/aai/datagrooming/DataGroomingTasks.java b/src/main/java/org/onap/aai/datagrooming/DataGroomingTasks.java
index 4309ece..21f3172 100644
--- a/src/main/java/org/onap/aai/datagrooming/DataGroomingTasks.java
+++ b/src/main/java/org/onap/aai/datagrooming/DataGroomingTasks.java
@@ -51,7 +51,7 @@ public class DataGroomingTasks {
private AaiScheduledTaskAuditLog auditLog;
private static final Logger LOGGER = LoggerFactory.getLogger(DataGroomingTasks.class);
- private static final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
+ private final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
@Autowired
private LoaderFactory loaderFactory;
diff --git a/src/main/java/org/onap/aai/datasnapshot/PrintVertexDetails.java b/src/main/java/org/onap/aai/datasnapshot/PrintVertexDetails.java
index 12b3099..ff6835b 100644
--- a/src/main/java/org/onap/aai/datasnapshot/PrintVertexDetails.java
+++ b/src/main/java/org/onap/aai/datasnapshot/PrintVertexDetails.java
@@ -74,11 +74,10 @@ public class PrintVertexDetails implements Runnable{
if (debugOn) {
// This is much slower, but sometimes we need to find out which single line is
// causing a failure
- try {
+ try(FileOutputStream subFileStr = new FileOutputStream(fname)) {
int okCount = 0;
int failCount = 0;
Long debugDelayMsL = new Long(debugDelayMs);
- FileOutputStream subFileStr = new FileOutputStream(fname);
GraphWriter graphWriter = null;
if ("gryo".equalsIgnoreCase(snapshotType)) {
@@ -117,12 +116,10 @@ public class PrintVertexDetails implements Runnable{
+ "], aai-uri = [" + aaiUri + "]. ";
System.out.println(fmsg);
LOGGER.debug(" PrintVertexDetails " + fmsg);
- // e.printStackTrace();
}
}
System.out.println(" -- Printed " + okCount + " vertexes out to " + fname + ", with " + failCount
+ " failed.");
- subFileStr.close();
} catch (Exception e) {
AAIException ae = new AAIException("AAI_6128", e , "Error running PrintVertexDetails in debugon");
ErrorLogHelper.logException(ae);
@@ -136,16 +133,14 @@ public class PrintVertexDetails implements Runnable{
vtxList.add(gt.next());
}
- try {
+ try(FileOutputStream subFileStr = new FileOutputStream(fname)) {
int count = vtxList.size();
Iterator<Vertex> vSubItr = vtxList.iterator();
- FileOutputStream subFileStr = new FileOutputStream(fname);
if ("gryo".equalsIgnoreCase(snapshotType)) {
jg.io(IoCore.gryo()).writer().create().writeVertices(subFileStr, vSubItr, Direction.BOTH);
} else {
jg.io(IoCore.graphson()).writer().create().writeVertices(subFileStr, vSubItr, Direction.BOTH);
}
- subFileStr.close();
String pmsg = " -- Printed " + count + " vertexes out to " + fname;
System.out.println(pmsg);
LOGGER.debug(" PrintVertexDetails " + pmsg);
diff --git a/src/main/java/org/onap/aai/db/schema/AuditOXM.java b/src/main/java/org/onap/aai/db/schema/AuditOXM.java
index e976bed..9c5ef4d 100644
--- a/src/main/java/org/onap/aai/db/schema/AuditOXM.java
+++ b/src/main/java/org/onap/aai/db/schema/AuditOXM.java
@@ -153,7 +153,7 @@ public class AuditOXM extends Auditor {
if (namespace == null) {
namespace = "";
}
- boolean isTopLevel = namespace != "";
+ boolean isTopLevel = !namespace.isEmpty();
List<String> unique = Arrays.asList(uniqueProps.split(","));
Set<String> indexed = temp.getIndexedProperties();
Set<String> keys = temp.getKeys();
diff --git a/src/main/java/org/onap/aai/dbgen/UpdatePropertyToolInternal.java b/src/main/java/org/onap/aai/dbgen/UpdatePropertyToolInternal.java
index 79b988d..91f62f9 100644
--- a/src/main/java/org/onap/aai/dbgen/UpdatePropertyToolInternal.java
+++ b/src/main/java/org/onap/aai/dbgen/UpdatePropertyToolInternal.java
@@ -243,9 +243,9 @@ public class UpdatePropertyToolInternal {
if (filePath != null && !filePath.isEmpty()) {
// Add vertex Ids listed from the given file name
- try {
+ try(BufferedReader br = new BufferedReader(new FileReader(filePath))) {
logAndPrint("Loading file at: " + filePath);
- BufferedReader br = new BufferedReader(new FileReader(filePath));
+
StringBuilder sb = new StringBuilder();
String nextLine = br.readLine();
@@ -261,7 +261,6 @@ public class UpdatePropertyToolInternal {
}
String allVertexIdsString = sb.toString();
logAndPrint("All vertex IDs from file " + filePath + ":\n" + allVertexIdsString);
- br.close();
} catch (IOException ioe) {
logErrorAndPrint("ERROR reading in text file failed.", ioe);
}
diff --git a/src/main/java/org/onap/aai/migration/v12/DeletePInterface.java b/src/main/java/org/onap/aai/migration/v12/DeletePInterface.java
index 1089b2f..8d306c4 100644
--- a/src/main/java/org/onap/aai/migration/v12/DeletePInterface.java
+++ b/src/main/java/org/onap/aai/migration/v12/DeletePInterface.java
@@ -70,7 +70,7 @@ public class DeletePInterface extends Migrator {
if (cousins == null || cousins.isEmpty()) {
if (children == null || children.isEmpty()) {
logger.info("Delete p-interface: " + getVertexURI(pInterfV));
- pInterfV.remove();
+ if(pInterfV != null) pInterfV.remove();
count++;
} else {
skipCount++;
diff --git a/src/main/java/org/onap/aai/migration/v12/MigrateDataFromASDCToConfiguration.java b/src/main/java/org/onap/aai/migration/v12/MigrateDataFromASDCToConfiguration.java
index 819c7d4..39224ad 100644
--- a/src/main/java/org/onap/aai/migration/v12/MigrateDataFromASDCToConfiguration.java
+++ b/src/main/java/org/onap/aai/migration/v12/MigrateDataFromASDCToConfiguration.java
@@ -92,7 +92,7 @@ public class MigrateDataFromASDCToConfiguration extends Migrator {
logger.error("Found Exception" , a);
} finally {
try {
- br.close();
+ if(br !=null) br.close();
} catch (IOException e) {
success = false;
logger.error("Found Exception" , e);
diff --git a/src/main/java/org/onap/aai/migration/v12/MigrateSAREvcInventory.java b/src/main/java/org/onap/aai/migration/v12/MigrateSAREvcInventory.java
index e05999d..a24d21a 100644
--- a/src/main/java/org/onap/aai/migration/v12/MigrateSAREvcInventory.java
+++ b/src/main/java/org/onap/aai/migration/v12/MigrateSAREvcInventory.java
@@ -430,7 +430,7 @@ public class MigrateSAREvcInventory extends Migrator {
private Vertex createNewConfigurationFromSARData(Map<String, String> sarColValues, Vertex forwardingPathVtx, int lineNumber) {
Vertex configurationVtx = null;
- String forwardingPathId = forwardingPathVtx.value(this.FOWARDING_PATH_ID);
+ String forwardingPathId = forwardingPathVtx !=null ? forwardingPathVtx.value(this.FOWARDING_PATH_ID) : "";
try {
List<Vertex> configList = g.V(forwardingPathVtx).out("org.onap.relationships.inventory.Uses").has("aai-node-type","configuration")
@@ -470,7 +470,7 @@ public class MigrateSAREvcInventory extends Migrator {
try {
Introspector evc = loader.introspectorFromName(EVC_NODE_TYPE);
evcVtx = serializer.createNewVertex(evc);
- evcId = configurationVtx.value(this.PROPERTY_CONFIGURATION_ID);
+ evcId = configurationVtx != null ? configurationVtx.value(this.PROPERTY_CONFIGURATION_ID) : "";
String cir = sarColValues.get("evcAccessCIR");
int length = cir.length();
diff --git a/src/main/java/org/onap/aai/migration/v13/MigrateModelVer.java b/src/main/java/org/onap/aai/migration/v13/MigrateModelVer.java
index 7bc9a7d..1e0ef5e 100644
--- a/src/main/java/org/onap/aai/migration/v13/MigrateModelVer.java
+++ b/src/main/java/org/onap/aai/migration/v13/MigrateModelVer.java
@@ -142,8 +142,8 @@ public class MigrateModelVer extends Migrator{
String uri = String.format("/service-design-and-creation/models/model/%s/model-vers/model-ver/%s", currrentValueModelInvariantID, currentValueModelVersionID);
String propertyKey = NODETYPEKEYMAP.get(nodeTypeString);
- String propertyValue = vertex.value(propertyKey).toString();
- logger.info("Processing "+nodeTypeString+ " vertex with key "+vertex.value(propertyKey).toString());
+ String propertyValue = vertex != null ? vertex.value(propertyKey).toString() : "";
+ logger.info("Processing "+nodeTypeString+ " vertex with key "+ propertyValue);
Vertex modelVerVertex = null;
if (modelVerUriVtxIdMap.containsKey(uri)){
diff --git a/src/main/java/org/onap/aai/migration/v13/MigratePserverAndPnfEquipType.java b/src/main/java/org/onap/aai/migration/v13/MigratePserverAndPnfEquipType.java
index 61c488c..94b85b1 100644
--- a/src/main/java/org/onap/aai/migration/v13/MigratePserverAndPnfEquipType.java
+++ b/src/main/java/org/onap/aai/migration/v13/MigratePserverAndPnfEquipType.java
@@ -70,7 +70,7 @@ public class MigratePserverAndPnfEquipType extends Migrator{
currentValueOfEquipType = getEquipTypeNodeValue(vertex);
hostName = getHostNameNodeValue(vertex);
if("Server".equals(currentValueOfEquipType) ||"server".equals(currentValueOfEquipType) ){
- vertex.property(EQUIP_TYPE_PROPERTY, "SERVER");
+ if(vertex != null) vertex.property(EQUIP_TYPE_PROPERTY, "SERVER");
this.touchVertexProperties(vertex, false);
logger.info("changed Pserver equip-type from " + currentValueOfEquipType + " to SERVER having hostname : " + hostName);
pserverCount++;
@@ -89,7 +89,7 @@ public class MigratePserverAndPnfEquipType extends Migrator{
currentValueOfEquipType = getEquipTypeNodeValue(vertex);
pnfName = getPnfNameNodeValue(vertex);
if("Switch".equals(currentValueOfEquipType)||"switch".equals(currentValueOfEquipType)){
- vertex.property(EQUIP_TYPE_PROPERTY, "SWITCH");
+ if(vertex != null) vertex.property(EQUIP_TYPE_PROPERTY, "SWITCH");
this.touchVertexProperties(vertex, false);
logger.info("changed Pnf equip-type from "+ currentValueOfEquipType +" to SWITCH having pnf-name :" + pnfName);
pnfCount++;
diff --git a/src/main/java/org/onap/aai/migration/v14/PserverDedupWithDifferentSourcesOfTruth.java b/src/main/java/org/onap/aai/migration/v14/PserverDedupWithDifferentSourcesOfTruth.java
index 54ed12c..11f7bd5 100644
--- a/src/main/java/org/onap/aai/migration/v14/PserverDedupWithDifferentSourcesOfTruth.java
+++ b/src/main/java/org/onap/aai/migration/v14/PserverDedupWithDifferentSourcesOfTruth.java
@@ -119,7 +119,7 @@ public class PserverDedupWithDifferentSourcesOfTruth extends EdgeSwingMigrator {
@Override
public Optional<String[]> getAffectedNodeTypes() {
- return null;
+ return Optional.empty();
}
@Override
diff --git a/src/main/java/org/onap/aai/rest/search/GenericQueryProcessor.java b/src/main/java/org/onap/aai/rest/search/GenericQueryProcessor.java
index 9bcd843..85573fc 100644
--- a/src/main/java/org/onap/aai/rest/search/GenericQueryProcessor.java
+++ b/src/main/java/org/onap/aai/rest/search/GenericQueryProcessor.java
@@ -115,10 +115,10 @@ public abstract class GenericQueryProcessor {
Map<String, Object> params = new HashMap<>();
String query = "";
if (this.isGremlin) {
- query = gremlin.get();
+ query = gremlin.isPresent() ? gremlin.get() : "";
}else if (this.isDsl) {
- String dslUserQuery = dsl.get();
+ String dslUserQuery = dsl.isPresent() ? dsl.get() : "";
if(dslQueryProcessorOptional.isPresent()){
String dslQuery = dslQueryProcessorOptional.get().parseAaiQuery(dslUserQuery);
query = groovyQueryBuilder.executeTraversal(dbEngine, dslQuery, params);
diff --git a/src/main/java/org/onap/aai/util/UniquePropertyCheck.java b/src/main/java/org/onap/aai/util/UniquePropertyCheck.java
index 8ef5139..20432e6 100644
--- a/src/main/java/org/onap/aai/util/UniquePropertyCheck.java
+++ b/src/main/java/org/onap/aai/util/UniquePropertyCheck.java
@@ -73,11 +73,10 @@ public class UniquePropertyCheck {
String propertyName = args[0];
Graph graph = null;
- try {
+ try(JanusGraph tGraph = JanusGraphFactory.open(new AAIGraphConfig.Builder(AAIConstants.REALTIME_DB_CONFIG).forService(UniquePropertyCheck.class.getSimpleName()).withGraphType("realtime").buildConfiguration())) {
AAIConfig.init();
System.out.println(" ---- NOTE --- about to open graph (takes a little while)--------\n");
- JanusGraph tGraph = JanusGraphFactory.open(new AAIGraphConfig.Builder(AAIConstants.REALTIME_DB_CONFIG).forService(UniquePropertyCheck.class.getSimpleName()).withGraphType("realtime").buildConfiguration());
-
+
if( tGraph == null ) {
logAndPrint(logger, " Error: Could not get JanusGraph ");
System.exit(1);