From 6915f57d07f466a6dd54be693b2af2cec9b8e0c1 Mon Sep 17 00:00:00 2001 From: David Brilla Date: Tue, 24 Mar 2020 13:08:36 +0100 Subject: AAI-common sonar fixes Issue-ID: AAI-2786 Change-Id: Ia37e660886fce56c8ab5c53888fcbf265692a359 Signed-off-by: David Brilla --- .../java/org/onap/aai/audit/ListEndpoints.java | 16 +-- .../org/onap/aai/config/SpringContextAware.java | 3 +- .../java/org/onap/aai/dbgen/GraphSONPartialIO.java | 3 +- .../org/onap/aai/dbgen/GraphSONPartialReader.java | 60 ++-------- .../java/org/onap/aai/dbgen/SchemaGenerator.java | 30 ++--- .../src/main/java/org/onap/aai/dbmap/AAIGraph.java | 22 ++-- .../java/org/onap/aai/dbmap/AAIGraphConfig.java | 23 +--- .../java/org/onap/aai/dbmap/InMemoryGraph.java | 39 +++--- .../onap/aai/dmaap/AAIDmaapEventJMSConsumer.java | 6 +- .../org/onap/aai/domain/model/AAIResource.java | 131 +++++++++++---------- .../org/onap/aai/domain/model/AAIResourceKeys.java | 2 +- .../org/onap/aai/domain/model/AAIResources.java | 19 +-- .../aai/domain/translog/TransactionLogEntries.java | 10 +- 13 files changed, 146 insertions(+), 218 deletions(-) (limited to 'aai-core/src/main') 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 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 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 { + public static final class Builder implements Io.Builder { 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> mapTypeReference = new TypeReference>() {}; @@ -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, Vertex> vertexAttachMethod, final Function, Edge> edgeAttachMethod, final Direction attachEdgesOfThisDirection) throws IOException { - // return readVertexStrings(inputStream).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, Edge> edgeAttachMethod) throws IOException { - /* - * if (version == GraphSONVersion.v1_0) { - * final Map edgeData = mapper.readValue(inputStream, mapTypeReference); - * - * final Map edgeProperties = edgeData.containsKey(GraphSONTokens.PROPERTIES) ? - * (Map) 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, VertexProperty> vertexPropertyAttachMethod) throws IOException { - /* - * if (version == GraphSONVersion.v1_0) { - * final Map vpData = mapper.readValue(inputStream, mapTypeReference); - * final Map metaProperties = (Map) 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, Property> propertyAttachMethod) throws IOException { - /* - * if (version == GraphSONVersion.v1_0) { - * final Map 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 { + public static final class Builder implements ReaderBuilder { private long batchSize = 10000; private Mapper 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 PropertyDataTypeMap; - private Multimap NodeMapIndexedProps; - private Multimap NodeAltKey1Props; - private Multimap NodeDependencies; - private Multimap NodeKeyProps; - private Multimap NodeReqProps; - private Multimap NodeNameProps; - private Multimap NodeUniqueProps; + private Map propertyDataTypeMap; + private Multimap nodeMapIndexedProps; + private Multimap nodeAltKey1Props; + private Multimap nodeDependencies; + private Multimap nodeKeyProps; + private Multimap nodeReqProps; + private Multimap nodeNameProps; + private Multimap nodeUniqueProps; // if new dataTypes are added - make sure to update getAllFields() method below - private ArrayList stringFields; - private ArrayList stringListFields; - private ArrayList longFields; - private ArrayList intFields; - private ArrayList shortFields; - private ArrayList booleanFields; - - private ArrayList requiredFields; - private ArrayList orderedFields; + private List stringFields; + private List stringListFields; + private List longFields; + private List intFields; + private List shortFields; + private List booleanFields; + + private List requiredFields; + private List orderedFields; private AAIResource recurseToResource; private boolean allowDirectWrite; private boolean allowDirectRead; - private ArrayList autoGenUuidFields; + private List autoGenUuidFields; /** * Gets the parent. @@ -222,7 +223,7 @@ public class AAIResource { * @return the property data type map */ public Map getPropertyDataTypeMap() { - return PropertyDataTypeMap; + return propertyDataTypeMap; } /** @@ -231,7 +232,7 @@ public class AAIResource { * @param propertyDataTypeMap the property data type map */ public void setPropertyDataTypeMap(Map propertyDataTypeMap) { - PropertyDataTypeMap = propertyDataTypeMap; + this.propertyDataTypeMap = propertyDataTypeMap; } /** @@ -240,7 +241,7 @@ public class AAIResource { * @return the node map indexed props */ public Multimap getNodeMapIndexedProps() { - return NodeMapIndexedProps; + return nodeMapIndexedProps; } /** @@ -249,7 +250,7 @@ public class AAIResource { * @param nodeMapIndexedProps the node map indexed props */ public void setNodeMapIndexedProps(Multimap nodeMapIndexedProps) { - NodeMapIndexedProps = nodeMapIndexedProps; + this.nodeMapIndexedProps = nodeMapIndexedProps; } /** @@ -258,7 +259,7 @@ public class AAIResource { * @return the node key props */ public Multimap getNodeKeyProps() { - return NodeKeyProps; + return nodeKeyProps; } /** @@ -267,7 +268,7 @@ public class AAIResource { * @param nodeKeyProps the node key props */ public void setNodeKeyProps(Multimap nodeKeyProps) { - this.NodeKeyProps = nodeKeyProps; + this.nodeKeyProps = nodeKeyProps; } /** @@ -276,7 +277,7 @@ public class AAIResource { * @return the node name props */ public Multimap getNodeNameProps() { - return NodeNameProps; + return nodeNameProps; } /** @@ -286,7 +287,7 @@ public class AAIResource { */ public void setNodeNameProps(Multimap nodeNameProps) { - NodeNameProps = nodeNameProps; + this.nodeNameProps = nodeNameProps; } /** @@ -295,7 +296,7 @@ public class AAIResource { * @return the node unique props */ public Multimap getNodeUniqueProps() { - return NodeUniqueProps; + return nodeUniqueProps; } /** @@ -304,7 +305,7 @@ public class AAIResource { * @param nodeUniqueProps the node unique props */ public void setNodeUniqueProps(Multimap nodeUniqueProps) { - NodeUniqueProps = nodeUniqueProps; + this.nodeUniqueProps = nodeUniqueProps; } /** @@ -313,7 +314,7 @@ public class AAIResource { * @return the node req props */ public Multimap getNodeReqProps() { - return NodeReqProps; + return nodeReqProps; } /** @@ -322,7 +323,7 @@ public class AAIResource { * @param nodeReqProps the node req props */ public void setNodeReqProps(Multimap nodeReqProps) { - NodeReqProps = nodeReqProps; + this.nodeReqProps = nodeReqProps; } /** @@ -384,9 +385,9 @@ public class AAIResource { * * @return the string fields */ - public ArrayList getStringFields() { + public List getStringFields() { if (this.stringFields == null) { - this.stringFields = new ArrayList(); + this.stringFields = new ArrayList<>(); } return this.stringFields; } @@ -396,7 +397,7 @@ public class AAIResource { * * @param stringFields the new string fields */ - public void setStringFields(ArrayList stringFields) { + public void setStringFields(List stringFields) { this.stringFields = stringFields; } @@ -405,9 +406,9 @@ public class AAIResource { * * @return the string list fields */ - public ArrayList getStringListFields() { + public List getStringListFields() { if (this.stringListFields == null) { - this.stringListFields = new ArrayList(); + 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 stringListFields) { + public void setStringListFields(List stringListFields) { this.stringListFields = stringListFields; } @@ -426,9 +427,9 @@ public class AAIResource { * * @return the long fields */ - public ArrayList getLongFields() { + public List getLongFields() { if (this.longFields == null) { - this.longFields = new ArrayList(); + this.longFields = new ArrayList<>(); } return longFields; } @@ -438,7 +439,7 @@ public class AAIResource { * * @param longFields the new long fields */ - public void setLongFields(ArrayList longFields) { + public void setLongFields(List longFields) { this.longFields = longFields; } @@ -447,9 +448,9 @@ public class AAIResource { * * @return the int fields */ - public ArrayList getIntFields() { + public List getIntFields() { if (this.intFields == null) { - this.intFields = new ArrayList(); + this.intFields = new ArrayList<>(); } return intFields; } @@ -459,7 +460,7 @@ public class AAIResource { * * @param intFields the new int fields */ - public void setIntFields(ArrayList intFields) { + public void setIntFields(List intFields) { this.intFields = intFields; } @@ -468,9 +469,9 @@ public class AAIResource { * * @return the short fields */ - public ArrayList getShortFields() { + public List getShortFields() { if (this.shortFields == null) { - this.shortFields = new ArrayList(); + this.shortFields = new ArrayList<>(); } return shortFields; } @@ -480,7 +481,7 @@ public class AAIResource { * * @param shortFields the new short fields */ - public void setShortFields(ArrayList shortFields) { + public void setShortFields(List shortFields) { this.shortFields = shortFields; } @@ -489,9 +490,9 @@ public class AAIResource { * * @return the boolean fields */ - public ArrayList getBooleanFields() { + public List getBooleanFields() { if (this.booleanFields == null) { - this.booleanFields = new ArrayList(); + this.booleanFields = new ArrayList<>(); } return booleanFields; } @@ -501,7 +502,7 @@ public class AAIResource { * * @param booleanFields the new boolean fields */ - public void setBooleanFields(ArrayList booleanFields) { + public void setBooleanFields(List booleanFields) { this.booleanFields = booleanFields; } @@ -510,9 +511,9 @@ public class AAIResource { * * @return the required fields */ - public ArrayList getRequiredFields() { + public List getRequiredFields() { if (this.requiredFields == null) { - this.requiredFields = new ArrayList(); + this.requiredFields = new ArrayList<>(); } return requiredFields; } @@ -522,7 +523,7 @@ public class AAIResource { * * @param requiredFields the new required fields */ - public void setRequiredFields(ArrayList requiredFields) { + public void setRequiredFields(List requiredFields) { this.requiredFields = requiredFields; } @@ -531,9 +532,9 @@ public class AAIResource { * * @return the ordered fields */ - public ArrayList getOrderedFields() { + public List getOrderedFields() { if (this.orderedFields == null) { - this.orderedFields = new ArrayList(); + this.orderedFields = new ArrayList<>(); } return this.orderedFields; } @@ -543,9 +544,9 @@ public class AAIResource { * * @return the all fields */ - public ArrayList getAllFields() { + public List getAllFields() { - ArrayList allFields = new ArrayList(); + ArrayList 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 _dbRulesNodeAltKey1Props) { - this.NodeAltKey1Props = _dbRulesNodeAltKey1Props; + public void setNodeAltKey1Props(Multimap dbRulesNodeAltKey1Props) { + this.nodeAltKey1Props = dbRulesNodeAltKey1Props; } /** @@ -584,16 +585,16 @@ public class AAIResource { * @return the node alt key 1 props */ public Multimap 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 _dbRulesNodeDependencies) { - this.NodeDependencies = _dbRulesNodeDependencies; + public void setNodeDependencies(Multimap dbRulesNodeDependencies) { + this.nodeDependencies = dbRulesNodeDependencies; } /** @@ -602,7 +603,7 @@ public class AAIResource { * @return the node dependencies */ public Multimap getNodeDependencies() { - return this.NodeDependencies; + return this.nodeDependencies; } /** @@ -665,9 +666,9 @@ public class AAIResource { * * @return the auto gen uuid fields */ - public ArrayList getAutoGenUuidFields() { + public List getAutoGenUuidFields() { if (this.autoGenUuidFields == null) { - this.autoGenUuidFields = new ArrayList(); + 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 getAaiResourceKey() { if (aaiResourceKey == null) { - aaiResourceKey = new ArrayList(); + 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 aaiResources; - private HashMap resourceLookup; + private Map resources; + private Map resourceLookup; /** * Gets the aai resources. * * @return the aai resources */ - public HashMap getAaiResources() { - if (aaiResources == null) { - aaiResources = new HashMap(); + public Map getAaiResources() { + if (resources == null) { + resources = new HashMap<>(); } - return aaiResources; + return resources; } /** @@ -66,9 +67,9 @@ public class AAIResources { * * @return the resource lookup */ - public HashMap getResourceLookup() { + public Map getResourceLookup() { if (resourceLookup == null) { - resourceLookup = new HashMap(); + resourceLookup = new HashMap<>(); } return resourceLookup; } @@ -78,7 +79,7 @@ public class AAIResources { * * @param resourceLookup the resource lookup */ - public void setResourceLookup(HashMap resourceLookup) { + public void setResourceLookup(Map 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 transactionLogEntries; + protected List logEntries; /** * Gets the transaction log entries. @@ -117,10 +117,10 @@ public class TransactionLogEntries { * @return the transaction log entries */ public List getTransactionLogEntries() { - if (transactionLogEntries == null) { - transactionLogEntries = new ArrayList(); + if (logEntries == null) { + logEntries = new ArrayList<>(); } - return this.transactionLogEntries; + return this.logEntries; } } -- cgit 1.2.3-korg