aboutsummaryrefslogtreecommitdiffstats
path: root/aai-core/src/main
diff options
context:
space:
mode:
authorDavid Brilla <xbrilla@fi.muni.cz>2020-03-24 13:08:36 +0100
committerDavid Brilla <david.brilla@tieto.com>2020-04-21 11:29:53 +0200
commit6915f57d07f466a6dd54be693b2af2cec9b8e0c1 (patch)
tree7c1309f6575aee88434fca15b2001e72f81a46bc /aai-core/src/main
parent71d81fa49428fcd2080844482e4e1205a9481ae4 (diff)
AAI-common sonar fixes
Issue-ID: AAI-2786 Change-Id: Ia37e660886fce56c8ab5c53888fcbf265692a359 Signed-off-by: David Brilla <david.brilla@tieto.com>
Diffstat (limited to 'aai-core/src/main')
-rw-r--r--aai-core/src/main/java/org/onap/aai/audit/ListEndpoints.java16
-rw-r--r--aai-core/src/main/java/org/onap/aai/config/SpringContextAware.java3
-rw-r--r--aai-core/src/main/java/org/onap/aai/dbgen/GraphSONPartialIO.java3
-rw-r--r--aai-core/src/main/java/org/onap/aai/dbgen/GraphSONPartialReader.java60
-rw-r--r--aai-core/src/main/java/org/onap/aai/dbgen/SchemaGenerator.java30
-rw-r--r--aai-core/src/main/java/org/onap/aai/dbmap/AAIGraph.java22
-rw-r--r--aai-core/src/main/java/org/onap/aai/dbmap/AAIGraphConfig.java23
-rw-r--r--aai-core/src/main/java/org/onap/aai/dbmap/InMemoryGraph.java39
-rw-r--r--aai-core/src/main/java/org/onap/aai/dmaap/AAIDmaapEventJMSConsumer.java6
-rw-r--r--aai-core/src/main/java/org/onap/aai/domain/model/AAIResource.java131
-rw-r--r--aai-core/src/main/java/org/onap/aai/domain/model/AAIResourceKeys.java2
-rw-r--r--aai-core/src/main/java/org/onap/aai/domain/model/AAIResources.java19
-rw-r--r--aai-core/src/main/java/org/onap/aai/domain/translog/TransactionLogEntries.java10
13 files changed, 146 insertions, 218 deletions
diff --git a/aai-core/src/main/java/org/onap/aai/audit/ListEndpoints.java b/aai-core/src/main/java/org/onap/aai/audit/ListEndpoints.java
index fe2e1ff7..56321cf1 100644
--- a/aai-core/src/main/java/org/onap/aai/audit/ListEndpoints.java
+++ b/aai-core/src/main/java/org/onap/aai/audit/ListEndpoints.java
@@ -76,7 +76,6 @@ public class ListEndpoints {
if (schemaUriBasePath == null) {
String errorMsg = "Unable to find the property schema.uri.base.path,"
+ " please check if specified in system property or in schema-ingest.properties";
- System.err.println(errorMsg);
LOGGER.error(errorMsg);
}
@@ -96,11 +95,11 @@ public class ListEndpoints {
Loader loader = SpringContextAware.getBean(LoaderFactory.class).createLoaderForVersion(ModelType.MOXY, version);
try {
- final Introspector start = loader.introspectorFromName(this.START);
+ final Introspector start = loader.introspectorFromName(START);
Set<String> startMap = new HashSet<>();
beginAudit(start, basePath + "/" + version, startMap);
} catch (AAIUnknownObjectException e) {
- throw new RuntimeException("Failed to find object " + this.START + ", cannot run ListEndpoints audit");
+ throw new RuntimeException("Failed to find object " + START + ", cannot run ListEndpoints audit");
}
}
@@ -114,7 +113,7 @@ public class ListEndpoints {
String currentUri = "";
- if (!obj.getDbName().equals("inventory")) {
+ if (!obj.getDbName().equals(START)) {
currentUri = uri + obj.getGenericURI();
} else {
currentUri = uri;
@@ -126,8 +125,6 @@ public class ListEndpoints {
endpoints.add(currentUri);
}
- String dbName = obj.getDbName();
-
populateLogicalName(obj, uri, currentUri);
Set<String> properties = obj.getProperties();
@@ -196,7 +193,7 @@ public class ListEndpoints {
}
if (uri.endsWith("/relationship-list")) {
- uri = uri.substring(0, uri.lastIndexOf("/"));
+ uri = uri.substring(0, uri.lastIndexOf('/'));
}
String logicalName = "";
@@ -222,8 +219,8 @@ public class ListEndpoints {
if (endpointToLogicalName.containsKey(uri) && uri.endsWith("}")) {
logicalName = logicalName + "From" + endpointToLogicalName.get(uri);
- } else if (endpointToLogicalName.containsKey(uri.substring(0, uri.lastIndexOf("/")))) {
- logicalName = logicalName + "From" + endpointToLogicalName.get(uri.substring(0, uri.lastIndexOf("/")));
+ } else if (endpointToLogicalName.containsKey(uri.substring(0, uri.lastIndexOf('/')))) {
+ logicalName = logicalName + "From" + endpointToLogicalName.get(uri.substring(0, uri.lastIndexOf('/')));
}
endpointToLogicalName.put(currentUri, logicalName);
@@ -264,7 +261,6 @@ public class ListEndpoints {
Matcher m = null;
if (!filterOut.equals("")) {
p = Pattern.compile(filterOut);
- m = null;
}
for (String s : endpoints) {
if (p != null) {
diff --git a/aai-core/src/main/java/org/onap/aai/config/SpringContextAware.java b/aai-core/src/main/java/org/onap/aai/config/SpringContextAware.java
index b8694554..30f877c3 100644
--- a/aai-core/src/main/java/org/onap/aai/config/SpringContextAware.java
+++ b/aai-core/src/main/java/org/onap/aai/config/SpringContextAware.java
@@ -20,7 +20,6 @@
package org.onap.aai.config;
-import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
@@ -35,7 +34,7 @@ public class SpringContextAware implements ApplicationContextAware {
}
@Override
- public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+ public void setApplicationContext(ApplicationContext applicationContext) {
context = applicationContext;
}
diff --git a/aai-core/src/main/java/org/onap/aai/dbgen/GraphSONPartialIO.java b/aai-core/src/main/java/org/onap/aai/dbgen/GraphSONPartialIO.java
index 02dede24..6c2eee15 100644
--- a/aai-core/src/main/java/org/onap/aai/dbgen/GraphSONPartialIO.java
+++ b/aai-core/src/main/java/org/onap/aai/dbgen/GraphSONPartialIO.java
@@ -33,7 +33,6 @@ import org.apache.tinkerpop.gremlin.structure.io.Io;
import org.apache.tinkerpop.gremlin.structure.io.IoRegistry;
import org.apache.tinkerpop.gremlin.structure.io.Mapper;
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONMapper;
-import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONReader;
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONVersion;
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONWriter;
@@ -119,7 +118,7 @@ public final class GraphSONPartialIO
return new Builder(version);
}
- public final static class Builder implements Io.Builder<GraphSONPartialIO> {
+ public static final class Builder implements Io.Builder<GraphSONPartialIO> {
private IoRegistry registry = null;
private Graph graph;
diff --git a/aai-core/src/main/java/org/onap/aai/dbgen/GraphSONPartialReader.java b/aai-core/src/main/java/org/onap/aai/dbgen/GraphSONPartialReader.java
index d3dfd150..1b3a3287 100644
--- a/aai-core/src/main/java/org/onap/aai/dbgen/GraphSONPartialReader.java
+++ b/aai-core/src/main/java/org/onap/aai/dbgen/GraphSONPartialReader.java
@@ -49,7 +49,7 @@ import org.apache.tinkerpop.gremlin.structure.io.Mapper;
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONMapper;
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONReader;
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONTokens;
-import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONVersion;
+import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONWriter;
import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoWriter;
import org.apache.tinkerpop.gremlin.structure.util.Attachable;
import org.apache.tinkerpop.gremlin.structure.util.Host;
@@ -60,7 +60,6 @@ import org.apache.tinkerpop.shaded.jackson.core.type.TypeReference;
import org.apache.tinkerpop.shaded.jackson.databind.JsonNode;
import org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper;
import org.apache.tinkerpop.shaded.jackson.databind.node.JsonNodeType;
-import org.onap.aai.dbmap.InMemoryGraph;
/**
* This is a Wrapper around the GraphsonReader class
@@ -68,16 +67,15 @@ import org.onap.aai.dbmap.InMemoryGraph;
* GraphsonReader is a final class . hence the use of the Wrapper
* instead of inheriting-overwriting
*
- *
+ *
*/
public final class GraphSONPartialReader implements GraphReader {
private final ObjectMapper mapper;
private final long batchSize;
- private final GraphSONVersion version;
private boolean unwrapAdjacencyList = false;
private final GraphSONReader reader;
- private static final Logger LOGGER = LoggerFactory.getLogger(InMemoryGraph.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(GraphSONPartialReader.class);
final TypeReference<Map<String, Object>> mapTypeReference = new TypeReference<Map<String, Object>>() {};
@@ -85,7 +83,6 @@ public final class GraphSONPartialReader implements GraphReader {
mapper = builder.mapper.createMapper();
batchSize = builder.batchSize;
unwrapAdjacencyList = builder.unwrapAdjacencyList;
- version = ((GraphSONMapper) builder.mapper).getVersion();
reader = GraphSONReader.build().create();
}
@@ -119,7 +116,7 @@ public final class GraphSONPartialReader implements GraphReader {
if (supportsTx && counter.incrementAndGet() % batchSize == 0)
graphToWriteTo.tx().commit();
} catch (Exception ex) {
- LOGGER.info("Error in reading vertex from graphson" + vertex.toString());
+ LOGGER.info(String.format("Error in reading vertex from graphson%s", vertex.toString()));
}
});
@@ -138,13 +135,13 @@ public final class GraphSONPartialReader implements GraphReader {
: cachedOutV.addEdge(e.label(), cachedInV);
e.properties().forEachRemaining(p -> newEdge.property(p.key(), p.value()));
} else {
- LOGGER.debug("Ghost edges from " + cachedOutV + " to " + cachedInV);
+ LOGGER.debug(String.format("Ghost edges from %s to %s", cachedOutV, cachedInV));
}
if (supportsTx && counter.incrementAndGet() % batchSize == 0)
graphToWriteTo.tx().commit();
} catch (Exception ex) {
- LOGGER.info("Error in writing vertex into graph" + e.toString());
+ LOGGER.info(String.format("Error in writing vertex into graph%s", e.toString()));
}
}));
@@ -168,9 +165,6 @@ public final class GraphSONPartialReader implements GraphReader {
final Function<Attachable<Vertex>, Vertex> vertexAttachMethod,
final Function<Attachable<Edge>, Edge> edgeAttachMethod, final Direction attachEdgesOfThisDirection)
throws IOException {
- // return readVertexStrings(inputStream).<Vertex>map(FunctionUtils.wrapFunction(line -> readVertex(new
- // ByteArrayInputStream(line.getBytes()), vertexAttachMethod, edgeAttachMethod,
- // attachEdgesOfThisDirection))).iterator();
return reader.readVertices(inputStream, vertexAttachMethod, edgeAttachMethod, attachEdgesOfThisDirection);
}
@@ -219,23 +213,6 @@ public final class GraphSONPartialReader implements GraphReader {
@Override
public Edge readEdge(final InputStream inputStream, final Function<Attachable<Edge>, Edge> edgeAttachMethod)
throws IOException {
- /*
- * if (version == GraphSONVersion.v1_0) {
- * final Map<String, Object> edgeData = mapper.readValue(inputStream, mapTypeReference);
- *
- * final Map<String, Object> edgeProperties = edgeData.containsKey(GraphSONTokens.PROPERTIES) ?
- * (Map<String, Object>) edgeData.get(GraphSONTokens.PROPERTIES) : Collections.EMPTY_MAP;
- * final DetachedEdge edge = new DetachedEdge(edgeData.get(GraphSONTokens.ID),
- * edgeData.get(GraphSONTokens.LABEL).toString(),
- * edgeProperties,
- * Pair.with(edgeData.get(GraphSONTokens.OUT), edgeData.get(GraphSONTokens.OUT_LABEL).toString()),
- * Pair.with(edgeData.get(GraphSONTokens.IN), edgeData.get(GraphSONTokens.IN_LABEL).toString()));
- *
- * return edgeAttachMethod.apply(edge);
- * } else {
- * return edgeAttachMethod.apply((DetachedEdge) mapper.readValue(inputStream, Edge.class));
- * }
- */
return reader.readEdge(inputStream, edgeAttachMethod);
}
@@ -252,19 +229,6 @@ public final class GraphSONPartialReader implements GraphReader {
@Override
public VertexProperty readVertexProperty(final InputStream inputStream,
final Function<Attachable<VertexProperty>, VertexProperty> vertexPropertyAttachMethod) throws IOException {
- /*
- * if (version == GraphSONVersion.v1_0) {
- * final Map<String, Object> vpData = mapper.readValue(inputStream, mapTypeReference);
- * final Map<String, Object> metaProperties = (Map<String, Object>) vpData.get(GraphSONTokens.PROPERTIES);
- * final DetachedVertexProperty vp = new DetachedVertexProperty(vpData.get(GraphSONTokens.ID),
- * vpData.get(GraphSONTokens.LABEL).toString(),
- * vpData.get(GraphSONTokens.VALUE), metaProperties);
- * return vertexPropertyAttachMethod.apply(vp);
- * } else {
- * return vertexPropertyAttachMethod.apply((DetachedVertexProperty) mapper.readValue(inputStream,
- * VertexProperty.class));
- * }
- */
return reader.readVertexProperty(inputStream, vertexPropertyAttachMethod);
}
@@ -279,16 +243,6 @@ public final class GraphSONPartialReader implements GraphReader {
@Override
public Property readProperty(final InputStream inputStream,
final Function<Attachable<Property>, Property> propertyAttachMethod) throws IOException {
- /*
- * if (version == GraphSONVersion.v1_0) {
- * final Map<String, Object> propertyData = mapper.readValue(inputStream, mapTypeReference);
- * final DetachedProperty p = new DetachedProperty(propertyData.get(GraphSONTokens.KEY).toString(),
- * propertyData.get(GraphSONTokens.VALUE));
- * return propertyAttachMethod.apply(p);
- * } else {
- * return propertyAttachMethod.apply((DetachedProperty) mapper.readValue(inputStream, Property.class));
- * }
- */
return reader.readProperty(inputStream, propertyAttachMethod);
}
@@ -318,7 +272,7 @@ public final class GraphSONPartialReader implements GraphReader {
return new Builder();
}
- public final static class Builder implements ReaderBuilder<GraphSONPartialReader> {
+ public static final class Builder implements ReaderBuilder<GraphSONPartialReader> {
private long batchSize = 10000;
private Mapper<ObjectMapper> mapper = GraphSONMapper.build().create();
diff --git a/aai-core/src/main/java/org/onap/aai/dbgen/SchemaGenerator.java b/aai-core/src/main/java/org/onap/aai/dbgen/SchemaGenerator.java
index d253f876..e6b6fbaf 100644
--- a/aai-core/src/main/java/org/onap/aai/dbgen/SchemaGenerator.java
+++ b/aai-core/src/main/java/org/onap/aai/dbgen/SchemaGenerator.java
@@ -20,16 +20,7 @@
package org.onap.aai.dbgen;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.google.common.collect.Multimap;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Set;
-
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.janusgraph.core.Cardinality;
import org.janusgraph.core.JanusGraph;
@@ -37,36 +28,41 @@ import org.janusgraph.core.Multiplicity;
import org.janusgraph.core.PropertyKey;
import org.janusgraph.core.schema.JanusGraphManagement;
import org.onap.aai.config.SpringContextAware;
-import org.onap.aai.db.props.AAIProperties;
import org.onap.aai.edges.EdgeIngestor;
import org.onap.aai.edges.EdgeRule;
import org.onap.aai.edges.exceptions.EdgeRuleNotFoundException;
-import org.onap.aai.introspection.*;
+import org.onap.aai.introspection.Introspector;
+import org.onap.aai.introspection.Loader;
+import org.onap.aai.introspection.LoaderUtil;
import org.onap.aai.logging.LogFormatTools;
import org.onap.aai.schema.enums.PropertyMetadata;
-import org.onap.aai.setup.SchemaVersions;
import org.onap.aai.util.AAIConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.*;
public class SchemaGenerator {
private static final Logger LOGGER = LoggerFactory.getLogger(SchemaGenerator.class);
+ private SchemaGenerator() {
+
+ }
+
/**
* Load schema into JanusGraph.
*
- * @param graph
- * the graph
* @param graphMgmt
* the graph mgmt
*/
- public static void loadSchemaIntoJanusGraph(final JanusGraph graph, final JanusGraphManagement graphMgmt,
+ public static void loadSchemaIntoJanusGraph(final JanusGraphManagement graphMgmt,
String backend) {
try {
AAIConfig.init();
} catch (Exception ex) {
LOGGER.error(" ERROR - Could not run AAIConfig.init(). " + LogFormatTools.getStackTop(ex));
- // System.out.println(" ERROR - Could not run AAIConfig.init(). ");
System.exit(1);
}
@@ -177,7 +173,7 @@ public class SchemaGenerator {
String imsg = "-- About to call graphMgmt commit";
LOGGER.info(imsg);
if (backend != null) {
- LOGGER.info("Successfully loaded the schema to " + backend);
+ LOGGER.info(String.format("Successfully loaded the schema to %s", backend));
}
graphMgmt.commit();
diff --git a/aai-core/src/main/java/org/onap/aai/dbmap/AAIGraph.java b/aai-core/src/main/java/org/onap/aai/dbmap/AAIGraph.java
index 5bb4b656..13040d30 100644
--- a/aai-core/src/main/java/org/onap/aai/dbmap/AAIGraph.java
+++ b/aai-core/src/main/java/org/onap/aai/dbmap/AAIGraph.java
@@ -54,9 +54,12 @@ import java.util.Properties;
public class AAIGraph {
private static final Logger logger = LoggerFactory.getLogger(AAIGraph.class);
+ private static final String IN_MEMORY = "inmemory";
protected JanusGraph graph;
private static boolean isInit = false;
+
+
/**
* Instantiates a new AAI graph.
*/
@@ -107,7 +110,7 @@ public class AAIGraph {
propertiesConfiguration.getKeys()
.forEachRemaining(k -> graphProps.setProperty(k, propertiesConfiguration.getString(k)));
- if ("inmemory".equals(graphProps.get("storage.backend"))) {
+ if (IN_MEMORY.equals(graphProps.get("storage.backend"))) {
// Load the propertyKeys, indexes and edge-Labels into the DB
loadSchema(graph);
loadSnapShotToInMemoryGraph(graph, graphProps);
@@ -131,13 +134,12 @@ public class AAIGraph {
if ("true".equals(value)) {
try (Graph transaction = graph.newTransaction()) {
String location = System.getProperty("snapshot.location");
- logAndPrint("Loading snapshot to inmemory graph.");
+ logger.info("Loading snapshot to inmemory graph.");
transaction.io(IoCore.graphson()).readGraph(location);
transaction.tx().commit();
- logAndPrint("Snapshot loaded to inmemory graph.");
+ logger.info("Snapshot loaded to inmemory graph.");
} catch (Exception e) {
- logAndPrint("ERROR: Could not load datasnapshot to in memory graph. \n"
- + ExceptionUtils.getFullStackTrace(e));
+ logger.info(String.format("ERROR: Could not load datasnapshot to in memory graph. %n%s", ExceptionUtils.getFullStackTrace(e)));
throw new RuntimeException(e);
}
}
@@ -148,11 +150,11 @@ public class AAIGraph {
// Load the propertyKeys, indexes and edge-Labels into the DB
JanusGraphManagement graphMgt = graph.openManagement();
- System.out.println("-- loading schema into JanusGraph");
+ logger.info("-- loading schema into JanusGraph");
if ("true".equals(SpringContextAware.getApplicationContext().getEnvironment().getProperty("history.enabled", "false"))) {
- SchemaGenerator4Hist.loadSchemaIntoJanusGraph(graph, graphMgt, "inmemory");
+ SchemaGenerator4Hist.loadSchemaIntoJanusGraph(graph, graphMgt, IN_MEMORY);
} else {
- SchemaGenerator.loadSchemaIntoJanusGraph(graph, graphMgt, "inmemory");
+ SchemaGenerator.loadSchemaIntoJanusGraph(graphMgt, IN_MEMORY);
}
}
@@ -174,8 +176,4 @@ public class AAIGraph {
return graph;
}
- private void logAndPrint(String msg) {
- System.out.println(msg);
- logger.info(msg);
- }
}
diff --git a/aai-core/src/main/java/org/onap/aai/dbmap/AAIGraphConfig.java b/aai-core/src/main/java/org/onap/aai/dbmap/AAIGraphConfig.java
index ea939b32..6bf04246 100644
--- a/aai-core/src/main/java/org/onap/aai/dbmap/AAIGraphConfig.java
+++ b/aai-core/src/main/java/org/onap/aai/dbmap/AAIGraphConfig.java
@@ -20,36 +20,25 @@
package org.onap.aai.dbmap;
-import static org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration.*;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import com.google.common.base.Preconditions;
-import com.google.common.base.Predicate;
-import com.google.common.collect.Iterators;
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.PropertiesConfiguration;
+import org.apache.commons.lang.StringUtils;
+import org.janusgraph.diskstorage.configuration.ConfigElement;
import java.io.File;
import java.io.FileNotFoundException;
import java.lang.management.ManagementFactory;
-import java.util.Iterator;
import java.util.Objects;
-import java.util.regex.Pattern;
-
-import org.apache.commons.configuration.ConfigurationException;
-import org.apache.commons.configuration.PropertiesConfiguration;
-import org.apache.commons.lang.StringUtils;
-import org.janusgraph.diskstorage.configuration.ConfigElement;
-import org.janusgraph.diskstorage.configuration.backend.CommonsConfiguration;
/**
* For building a config that JanusGraphFactory.open can use with an identifiable graph.unique-instance-id
*/
public class AAIGraphConfig {
- private static final Logger logger = LoggerFactory.getLogger(AAIGraphConfig.class);
private AAIGraphConfig() {
- };
+
+ }
public PropertiesConfiguration getCc(String configPath, String graphType, String service)
throws ConfigurationException, FileNotFoundException {
diff --git a/aai-core/src/main/java/org/onap/aai/dbmap/InMemoryGraph.java b/aai-core/src/main/java/org/onap/aai/dbmap/InMemoryGraph.java
index d017b7e9..ac9407e3 100644
--- a/aai-core/src/main/java/org/onap/aai/dbmap/InMemoryGraph.java
+++ b/aai-core/src/main/java/org/onap/aai/dbmap/InMemoryGraph.java
@@ -28,7 +28,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
-import org.apache.commons.lang.exception.ExceptionUtils;
import org.apache.tinkerpop.gremlin.structure.io.IoCore;
import org.janusgraph.core.JanusGraph;
import org.janusgraph.core.JanusGraphFactory;
@@ -47,8 +46,7 @@ public class InMemoryGraph {
/*
* Create a In-memory graph
*/
- InputStream is = new FileInputStream(builder.propertyFile);
- try {
+ try(InputStream is = new FileInputStream(builder.propertyFile)){
graph = JanusGraphFactory.open(builder.propertyFile);
Properties graphProps = new Properties();
@@ -56,34 +54,31 @@ public class InMemoryGraph {
JanusGraphManagement graphMgt = graph.openManagement();
if (builder.isSchemaEnabled) {
LOGGER.info("Schema Enabled");
- SchemaGenerator.loadSchemaIntoJanusGraph(graph, graphMgt, graphProps.getProperty("storage.backend"));
+ SchemaGenerator.loadSchemaIntoJanusGraph(graphMgt, graphProps.getProperty("storage.backend"));
}
- JanusGraphTransaction transaction = graph.newTransaction();
- LOGGER.info("Loading snapshot");
- if (builder.isPartialGraph) {
- if ((builder.graphsonLocation != null) && (builder.graphsonLocation.length() > 0)) {
- transaction.io(GraphSONPartialIO.build()).readGraph(builder.graphsonLocation);
- } else {
- transaction.io(GraphSONPartialIO.build()).reader().create().readGraph(builder.seqInputStream,
+ try (JanusGraphTransaction transaction = graph.newTransaction()) {
+ LOGGER.info("Loading snapshot");
+ if (builder.isPartialGraph) {
+ if ((builder.graphsonLocation != null) && (builder.graphsonLocation.length() > 0)) {
+ transaction.io(GraphSONPartialIO.build()).readGraph(builder.graphsonLocation);
+ } else {
+ transaction.io(GraphSONPartialIO.build()).reader().create().readGraph(builder.seqInputStream,
graph);
- }
- } else {
- if ((builder.graphsonLocation != null) && (builder.graphsonLocation.length() > 0)) {
- transaction.io(IoCore.graphson()).readGraph(builder.graphsonLocation);
+ }
} else {
- transaction.io(IoCore.graphson()).reader().create().readGraph(builder.seqInputStream, graph);
+ if ((builder.graphsonLocation != null) && (builder.graphsonLocation.length() > 0)) {
+ transaction.io(IoCore.graphson()).readGraph(builder.graphsonLocation);
+ } else {
+ transaction.io(IoCore.graphson()).reader().create().readGraph(builder.seqInputStream, graph);
+ }
}
+ transaction.commit();
}
- transaction.commit();
} catch (Exception e) {
- // TODO : Changesysout to logger
- e.printStackTrace();
- LOGGER.error("ERROR: Could not load datasnapshot to in memory graph. \n" + LogFormatTools.getStackTop(e));
+ LOGGER.error(String.format("ERROR: Could not load datasnapshot to in memory graph. %n%s", LogFormatTools.getStackTop(e)));
throw new IllegalStateException("Could not load datasnapshot to in memory graph");
- } finally {
- is.close();
}
}
diff --git a/aai-core/src/main/java/org/onap/aai/dmaap/AAIDmaapEventJMSConsumer.java b/aai-core/src/main/java/org/onap/aai/dmaap/AAIDmaapEventJMSConsumer.java
index b3a8773e..3c030466 100644
--- a/aai-core/src/main/java/org/onap/aai/dmaap/AAIDmaapEventJMSConsumer.java
+++ b/aai-core/src/main/java/org/onap/aai/dmaap/AAIDmaapEventJMSConsumer.java
@@ -101,8 +101,8 @@ public class AAIDmaapEventJMSConsumer implements MessageListener {
} else {
return;
}
- if (jo.getString("event-topic") != null) {
- eventName = jo.getString("event-topic");
+ if (jo.getString(EVENT_TOPIC) != null) {
+ eventName = jo.getString(EVENT_TOPIC);
}
if (joPayload.has("event-header")) {
try {
@@ -129,7 +129,7 @@ public class AAIDmaapEventJMSConsumer implements MessageListener {
if ("AAI-EVENT".equals(eventName)) {
restTemplate.exchange(baseUrl + endpoint, HttpMethod.POST, httpEntity, String.class);
} else {
- LOGGER.error(eventName + "|Event Topic invalid.");
+ LOGGER.error(String.format("%s|Event Topic invalid.", eventName));
}
} catch (JMSException | JSONException e) {
aaiElsErrorCode = AaiElsErrorCode.DATA_ERROR;
diff --git a/aai-core/src/main/java/org/onap/aai/domain/model/AAIResource.java b/aai-core/src/main/java/org/onap/aai/domain/model/AAIResource.java
index ddeabf07..7e446fb6 100644
--- a/aai-core/src/main/java/org/onap/aai/domain/model/AAIResource.java
+++ b/aai-core/src/main/java/org/onap/aai/domain/model/AAIResource.java
@@ -23,6 +23,7 @@ package org.onap.aai.domain.model;
import com.google.common.collect.Multimap;
import java.util.ArrayList;
+import java.util.List;
import java.util.Map;
public class AAIResource {
@@ -42,29 +43,29 @@ public class AAIResource {
private String relationshipListClass;
private String relationshipUtils;
- private Map<String, String> PropertyDataTypeMap;
- private Multimap<String, String> NodeMapIndexedProps;
- private Multimap<String, String> NodeAltKey1Props;
- private Multimap<String, String> NodeDependencies;
- private Multimap<String, String> NodeKeyProps;
- private Multimap<String, String> NodeReqProps;
- private Multimap<String, String> NodeNameProps;
- private Multimap<String, String> NodeUniqueProps;
+ private Map<String, String> propertyDataTypeMap;
+ private Multimap<String, String> nodeMapIndexedProps;
+ private Multimap<String, String> nodeAltKey1Props;
+ private Multimap<String, String> nodeDependencies;
+ private Multimap<String, String> nodeKeyProps;
+ private Multimap<String, String> nodeReqProps;
+ private Multimap<String, String> nodeNameProps;
+ private Multimap<String, String> nodeUniqueProps;
// if new dataTypes are added - make sure to update getAllFields() method below
- private ArrayList<String> stringFields;
- private ArrayList<String> stringListFields;
- private ArrayList<String> longFields;
- private ArrayList<String> intFields;
- private ArrayList<String> shortFields;
- private ArrayList<String> booleanFields;
-
- private ArrayList<String> requiredFields;
- private ArrayList<String> orderedFields;
+ private List<String> stringFields;
+ private List<String> stringListFields;
+ private List<String> longFields;
+ private List<String> intFields;
+ private List<String> shortFields;
+ private List<String> booleanFields;
+
+ private List<String> requiredFields;
+ private List<String> orderedFields;
private AAIResource recurseToResource;
private boolean allowDirectWrite;
private boolean allowDirectRead;
- private ArrayList<String> autoGenUuidFields;
+ private List<String> autoGenUuidFields;
/**
* Gets the parent.
@@ -222,7 +223,7 @@ public class AAIResource {
* @return the property data type map
*/
public Map<String, String> getPropertyDataTypeMap() {
- return PropertyDataTypeMap;
+ return propertyDataTypeMap;
}
/**
@@ -231,7 +232,7 @@ public class AAIResource {
* @param propertyDataTypeMap the property data type map
*/
public void setPropertyDataTypeMap(Map<String, String> propertyDataTypeMap) {
- PropertyDataTypeMap = propertyDataTypeMap;
+ this.propertyDataTypeMap = propertyDataTypeMap;
}
/**
@@ -240,7 +241,7 @@ public class AAIResource {
* @return the node map indexed props
*/
public Multimap<String, String> getNodeMapIndexedProps() {
- return NodeMapIndexedProps;
+ return nodeMapIndexedProps;
}
/**
@@ -249,7 +250,7 @@ public class AAIResource {
* @param nodeMapIndexedProps the node map indexed props
*/
public void setNodeMapIndexedProps(Multimap<String, String> nodeMapIndexedProps) {
- NodeMapIndexedProps = nodeMapIndexedProps;
+ this.nodeMapIndexedProps = nodeMapIndexedProps;
}
/**
@@ -258,7 +259,7 @@ public class AAIResource {
* @return the node key props
*/
public Multimap<String, String> getNodeKeyProps() {
- return NodeKeyProps;
+ return nodeKeyProps;
}
/**
@@ -267,7 +268,7 @@ public class AAIResource {
* @param nodeKeyProps the node key props
*/
public void setNodeKeyProps(Multimap<String, String> nodeKeyProps) {
- this.NodeKeyProps = nodeKeyProps;
+ this.nodeKeyProps = nodeKeyProps;
}
/**
@@ -276,7 +277,7 @@ public class AAIResource {
* @return the node name props
*/
public Multimap<String, String> getNodeNameProps() {
- return NodeNameProps;
+ return nodeNameProps;
}
/**
@@ -286,7 +287,7 @@ public class AAIResource {
*/
public void setNodeNameProps(Multimap<String, String> nodeNameProps) {
- NodeNameProps = nodeNameProps;
+ this.nodeNameProps = nodeNameProps;
}
/**
@@ -295,7 +296,7 @@ public class AAIResource {
* @return the node unique props
*/
public Multimap<String, String> getNodeUniqueProps() {
- return NodeUniqueProps;
+ return nodeUniqueProps;
}
/**
@@ -304,7 +305,7 @@ public class AAIResource {
* @param nodeUniqueProps the node unique props
*/
public void setNodeUniqueProps(Multimap<String, String> nodeUniqueProps) {
- NodeUniqueProps = nodeUniqueProps;
+ this.nodeUniqueProps = nodeUniqueProps;
}
/**
@@ -313,7 +314,7 @@ public class AAIResource {
* @return the node req props
*/
public Multimap<String, String> getNodeReqProps() {
- return NodeReqProps;
+ return nodeReqProps;
}
/**
@@ -322,7 +323,7 @@ public class AAIResource {
* @param nodeReqProps the node req props
*/
public void setNodeReqProps(Multimap<String, String> nodeReqProps) {
- NodeReqProps = nodeReqProps;
+ this.nodeReqProps = nodeReqProps;
}
/**
@@ -384,9 +385,9 @@ public class AAIResource {
*
* @return the string fields
*/
- public ArrayList<String> getStringFields() {
+ public List<String> getStringFields() {
if (this.stringFields == null) {
- this.stringFields = new ArrayList<String>();
+ this.stringFields = new ArrayList<>();
}
return this.stringFields;
}
@@ -396,7 +397,7 @@ public class AAIResource {
*
* @param stringFields the new string fields
*/
- public void setStringFields(ArrayList<String> stringFields) {
+ public void setStringFields(List<String> stringFields) {
this.stringFields = stringFields;
}
@@ -405,9 +406,9 @@ public class AAIResource {
*
* @return the string list fields
*/
- public ArrayList<String> getStringListFields() {
+ public List<String> getStringListFields() {
if (this.stringListFields == null) {
- this.stringListFields = new ArrayList<String>();
+ this.stringListFields = new ArrayList<>();
}
return this.stringListFields;
}
@@ -417,7 +418,7 @@ public class AAIResource {
*
* @param stringListFields the new string list fields
*/
- public void setStringListFields(ArrayList<String> stringListFields) {
+ public void setStringListFields(List<String> stringListFields) {
this.stringListFields = stringListFields;
}
@@ -426,9 +427,9 @@ public class AAIResource {
*
* @return the long fields
*/
- public ArrayList<String> getLongFields() {
+ public List<String> getLongFields() {
if (this.longFields == null) {
- this.longFields = new ArrayList<String>();
+ this.longFields = new ArrayList<>();
}
return longFields;
}
@@ -438,7 +439,7 @@ public class AAIResource {
*
* @param longFields the new long fields
*/
- public void setLongFields(ArrayList<String> longFields) {
+ public void setLongFields(List<String> longFields) {
this.longFields = longFields;
}
@@ -447,9 +448,9 @@ public class AAIResource {
*
* @return the int fields
*/
- public ArrayList<String> getIntFields() {
+ public List<String> getIntFields() {
if (this.intFields == null) {
- this.intFields = new ArrayList<String>();
+ this.intFields = new ArrayList<>();
}
return intFields;
}
@@ -459,7 +460,7 @@ public class AAIResource {
*
* @param intFields the new int fields
*/
- public void setIntFields(ArrayList<String> intFields) {
+ public void setIntFields(List<String> intFields) {
this.intFields = intFields;
}
@@ -468,9 +469,9 @@ public class AAIResource {
*
* @return the short fields
*/
- public ArrayList<String> getShortFields() {
+ public List<String> getShortFields() {
if (this.shortFields == null) {
- this.shortFields = new ArrayList<String>();
+ this.shortFields = new ArrayList<>();
}
return shortFields;
}
@@ -480,7 +481,7 @@ public class AAIResource {
*
* @param shortFields the new short fields
*/
- public void setShortFields(ArrayList<String> shortFields) {
+ public void setShortFields(List<String> shortFields) {
this.shortFields = shortFields;
}
@@ -489,9 +490,9 @@ public class AAIResource {
*
* @return the boolean fields
*/
- public ArrayList<String> getBooleanFields() {
+ public List<String> getBooleanFields() {
if (this.booleanFields == null) {
- this.booleanFields = new ArrayList<String>();
+ this.booleanFields = new ArrayList<>();
}
return booleanFields;
}
@@ -501,7 +502,7 @@ public class AAIResource {
*
* @param booleanFields the new boolean fields
*/
- public void setBooleanFields(ArrayList<String> booleanFields) {
+ public void setBooleanFields(List<String> booleanFields) {
this.booleanFields = booleanFields;
}
@@ -510,9 +511,9 @@ public class AAIResource {
*
* @return the required fields
*/
- public ArrayList<String> getRequiredFields() {
+ public List<String> getRequiredFields() {
if (this.requiredFields == null) {
- this.requiredFields = new ArrayList<String>();
+ this.requiredFields = new ArrayList<>();
}
return requiredFields;
}
@@ -522,7 +523,7 @@ public class AAIResource {
*
* @param requiredFields the new required fields
*/
- public void setRequiredFields(ArrayList<String> requiredFields) {
+ public void setRequiredFields(List<String> requiredFields) {
this.requiredFields = requiredFields;
}
@@ -531,9 +532,9 @@ public class AAIResource {
*
* @return the ordered fields
*/
- public ArrayList<String> getOrderedFields() {
+ public List<String> getOrderedFields() {
if (this.orderedFields == null) {
- this.orderedFields = new ArrayList<String>();
+ this.orderedFields = new ArrayList<>();
}
return this.orderedFields;
}
@@ -543,9 +544,9 @@ public class AAIResource {
*
* @return the all fields
*/
- public ArrayList<String> getAllFields() {
+ public List<String> getAllFields() {
- ArrayList<String> allFields = new ArrayList<String>();
+ ArrayList<String> allFields = new ArrayList<>();
allFields.addAll(getBooleanFields());
allFields.addAll(getStringListFields());
allFields.addAll(getStringFields());
@@ -572,10 +573,10 @@ public class AAIResource {
/**
* Sets the node alt key 1 props.
*
- * @param _dbRulesNodeAltKey1Props the db rules node alt key 1 props
+ * @param dbRulesNodeAltKey1Props the db rules node alt key 1 props
*/
- public void setNodeAltKey1Props(Multimap<String, String> _dbRulesNodeAltKey1Props) {
- this.NodeAltKey1Props = _dbRulesNodeAltKey1Props;
+ public void setNodeAltKey1Props(Multimap<String, String> dbRulesNodeAltKey1Props) {
+ this.nodeAltKey1Props = dbRulesNodeAltKey1Props;
}
/**
@@ -584,16 +585,16 @@ public class AAIResource {
* @return the node alt key 1 props
*/
public Multimap<String, String> getNodeAltKey1Props() {
- return this.NodeAltKey1Props;
+ return this.nodeAltKey1Props;
}
/**
* Sets the node dependencies.
*
- * @param _dbRulesNodeDependencies the db rules node dependencies
+ * @param dbRulesNodeDependencies the db rules node dependencies
*/
- public void setNodeDependencies(Multimap<String, String> _dbRulesNodeDependencies) {
- this.NodeDependencies = _dbRulesNodeDependencies;
+ public void setNodeDependencies(Multimap<String, String> dbRulesNodeDependencies) {
+ this.nodeDependencies = dbRulesNodeDependencies;
}
/**
@@ -602,7 +603,7 @@ public class AAIResource {
* @return the node dependencies
*/
public Multimap<String, String> getNodeDependencies() {
- return this.NodeDependencies;
+ return this.nodeDependencies;
}
/**
@@ -665,9 +666,9 @@ public class AAIResource {
*
* @return the auto gen uuid fields
*/
- public ArrayList<String> getAutoGenUuidFields() {
+ public List<String> getAutoGenUuidFields() {
if (this.autoGenUuidFields == null) {
- this.autoGenUuidFields = new ArrayList<String>();
+ this.autoGenUuidFields = new ArrayList<>();
}
return this.autoGenUuidFields;
}
diff --git a/aai-core/src/main/java/org/onap/aai/domain/model/AAIResourceKeys.java b/aai-core/src/main/java/org/onap/aai/domain/model/AAIResourceKeys.java
index 64149513..1373c93d 100644
--- a/aai-core/src/main/java/org/onap/aai/domain/model/AAIResourceKeys.java
+++ b/aai-core/src/main/java/org/onap/aai/domain/model/AAIResourceKeys.java
@@ -33,7 +33,7 @@ public class AAIResourceKeys {
*/
public List<AAIResourceKey> getAaiResourceKey() {
if (aaiResourceKey == null) {
- aaiResourceKey = new ArrayList<AAIResourceKey>();
+ aaiResourceKey = new ArrayList<>();
}
return aaiResourceKey;
}
diff --git a/aai-core/src/main/java/org/onap/aai/domain/model/AAIResources.java b/aai-core/src/main/java/org/onap/aai/domain/model/AAIResources.java
index 413faf62..ac13ab07 100644
--- a/aai-core/src/main/java/org/onap/aai/domain/model/AAIResources.java
+++ b/aai-core/src/main/java/org/onap/aai/domain/model/AAIResources.java
@@ -23,24 +23,25 @@ package org.onap.aai.domain.model;
import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
import java.util.HashMap;
+import java.util.Map;
public class AAIResources {
private DynamicJAXBContext jaxbContext;
- private HashMap<String, AAIResource> aaiResources;
- private HashMap<String, AAIResource> resourceLookup;
+ private Map<String, AAIResource> resources;
+ private Map<String, AAIResource> resourceLookup;
/**
* Gets the aai resources.
*
* @return the aai resources
*/
- public HashMap<String, AAIResource> getAaiResources() {
- if (aaiResources == null) {
- aaiResources = new HashMap<String, AAIResource>();
+ public Map<String, AAIResource> getAaiResources() {
+ if (resources == null) {
+ resources = new HashMap<>();
}
- return aaiResources;
+ return resources;
}
/**
@@ -66,9 +67,9 @@ public class AAIResources {
*
* @return the resource lookup
*/
- public HashMap<String, AAIResource> getResourceLookup() {
+ public Map<String, AAIResource> getResourceLookup() {
if (resourceLookup == null) {
- resourceLookup = new HashMap<String, AAIResource>();
+ resourceLookup = new HashMap<>();
}
return resourceLookup;
}
@@ -78,7 +79,7 @@ public class AAIResources {
*
* @param resourceLookup the resource lookup
*/
- public void setResourceLookup(HashMap<String, AAIResource> resourceLookup) {
+ public void setResourceLookup(Map<String, AAIResource> resourceLookup) {
this.resourceLookup = resourceLookup;
}
diff --git a/aai-core/src/main/java/org/onap/aai/domain/translog/TransactionLogEntries.java b/aai-core/src/main/java/org/onap/aai/domain/translog/TransactionLogEntries.java
index e81b3e3c..cde4f4b9 100644
--- a/aai-core/src/main/java/org/onap/aai/domain/translog/TransactionLogEntries.java
+++ b/aai-core/src/main/java/org/onap/aai/domain/translog/TransactionLogEntries.java
@@ -105,11 +105,11 @@ import java.util.List;
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "", propOrder = {"transactionLogEntries"})
+@XmlType(name = "", propOrder = {"logEntries"})
@XmlRootElement(name = "transaction-log-entries", namespace = "http://org.onap.aai.inventory")
public class TransactionLogEntries {
- protected List<TransactionLogEntry> transactionLogEntries;
+ protected List<TransactionLogEntry> logEntries;
/**
* Gets the transaction log entries.
@@ -117,10 +117,10 @@ public class TransactionLogEntries {
* @return the transaction log entries
*/
public List<TransactionLogEntry> getTransactionLogEntries() {
- if (transactionLogEntries == null) {
- transactionLogEntries = new ArrayList<TransactionLogEntry>();
+ if (logEntries == null) {
+ logEntries = new ArrayList<>();
}
- return this.transactionLogEntries;
+ return this.logEntries;
}
}