Merge "Removed problems triggering Sonar errors"
authorWilliam Reehil <william.reehil@att.com>
Mon, 13 Jul 2020 17:31:57 +0000 (17:31 +0000)
committerGerrit Code Review <gerrit@onap.org>
Mon, 13 Jul 2020 17:31:57 +0000 (17:31 +0000)
INFO.yaml
aai-core/src/main/java/org/onap/aai/dbgen/SchemaGenerator4Hist.java
aai-core/src/main/java/org/onap/aai/dbmap/AAIGraph.java
aai-core/src/main/java/org/onap/aai/introspection/exceptions/AAIUnmarshallingException.java
aai-core/src/main/java/org/onap/aai/serialization/queryformats/Aggregate.java
aai-core/src/main/java/org/onap/aai/util/HttpsAuthClient.java
aai-core/src/test/java/org/onap/aai/audit/ListEndpointsTest.java
docs/platform/architecture.rst
docs/platform/images/aai_components.png [new file with mode: 0644]

index c575705..f1b7883 100644 (file)
--- a/INFO.yaml
+++ b/INFO.yaml
@@ -4,11 +4,11 @@ project_creation_date: '2017-05-03'
 project_category: ''
 lifecycle_state: 'Incubation'
 project_lead: &onap_aai_ptl
-    name: 'James Forsyth'
-    email: 'jf2512@att.com'
-    id: 'jimmydot'
+    name: 'William Reehil'
+    email: 'william.reehil@att.com'
     company: 'ATT'
-    timezone: 'America/Detroit'
+    id: 'wreehil'
+    timezone: 'America/New_York'
 primary_contact: *onap_aai_ptl
 issue_tracking:
     type: 'jira'
@@ -46,6 +46,11 @@ committers:
       company: 'ATT'
       id: 'vk250x'
       timezone: 'America/New_York'
+    - name: 'James Forsyth'
+      email: 'jf2512@att.com'
+      id: 'jimmydot'
+      company: 'ATT'
+      timezone: 'America/Detroit'
 tsc:
     approval: 'https://lists.onap.org/g/onap-tsc'
     changes:
@@ -55,3 +60,6 @@ tsc:
         - type: 'removal'
           name: 'Tian Lee'
           link: 'https://lists.onap.org/g/onap-tsc/message/6227'
+        - type: 'Addition'
+          name: 'William Reehil'
+          link: 'https://lists.onap.org/g/onap-tsc/message/6506'
index 0f88de2..a35625f 100644 (file)
 
 package org.onap.aai.dbgen;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import com.google.common.collect.Multimap;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
 import org.janusgraph.core.Cardinality;
-import org.janusgraph.core.JanusGraph;
 import org.janusgraph.core.Multiplicity;
 import org.janusgraph.core.PropertyKey;
 import org.janusgraph.core.schema.JanusGraphManagement;
@@ -39,8 +36,14 @@ import org.onap.aai.introspection.LoaderUtil;
 import org.onap.aai.logging.LogFormatTools;
 import org.onap.aai.schema.enums.PropertyMetadata;
 import org.onap.aai.util.AAIConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
-import java.util.*;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
 
 import static org.onap.aai.db.props.AAIProperties.*;
 
@@ -48,22 +51,21 @@ public class SchemaGenerator4Hist {
 
     private static final Logger LOGGER = LoggerFactory.getLogger(SchemaGenerator4Hist.class);
 
+    private SchemaGenerator4Hist(){
+
+    }
     /**
      * Load schema into JanusGraph.
      *
-     * @param graph
-     *        the graph
      * @param graphMgmt
      *        the graph mgmt
      */
-    public static void loadSchemaIntoJanusGraph(final JanusGraph graph, final JanusGraphManagement graphMgmt,
-            String backend) {
+    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(). ");
+            LOGGER.error(" ERROR - Could not run AAIConfig.init(). {}", LogFormatTools.getStackTop(ex));
             System.exit(1);
         }
 
@@ -97,11 +99,9 @@ public class SchemaGenerator4Hist {
 
         for (String label : labels) {
             if (graphMgmt.containsRelationType(label)) {
-                String dmsg = " EdgeLabel  [" + label + "] already existed. ";
-                LOGGER.debug(dmsg);
+                LOGGER.debug(" EdgeLabel  [{}] already existed. ", label);
             } else {
-                String dmsg = "Making EdgeLabel: [" + label + "]";
-                LOGGER.debug(dmsg);
+                LOGGER.debug("Making EdgeLabel: [{}]", label);
                 graphMgmt.makeEdgeLabel(label).multiplicity(Multiplicity.valueOf("MULTI")).make();
             }
         }
@@ -119,8 +119,7 @@ public class SchemaGenerator4Hist {
                     dbPropName = alias.get();
                 }
                 if (graphMgmt.containsRelationType(dbPropName)) {
-                    String dmsg = " PropertyKey  [" + dbPropName + "] already existed in the DB. ";
-                    LOGGER.debug(dmsg);
+                    LOGGER.debug(" PropertyKey  [{}] already existed in the DB. ", dbPropName);
                 } else {
                     Class<?> type = obj.getClass(propName);
                     Cardinality cardinality = Cardinality.LIST;
@@ -132,7 +131,6 @@ public class SchemaGenerator4Hist {
                        // above) will be stored in our db as a single String.  And that
                        // single string will have Cardinality = LIST so we can track its
                        // history.
-                        //cardinality = Cardinality.SET;
                         type = obj.getGenericTypeClass(propName);
                         process = true;
                     } else if (obj.isSimpleType(propName)) {
@@ -141,9 +139,8 @@ public class SchemaGenerator4Hist {
 
                     if (process) {
 
-                        String imsg = " Creating PropertyKey: [" + dbPropName + "], [" + type.getSimpleName() + "], ["
-                                + cardinality + "]";
-                        LOGGER.info(imsg);
+                        LOGGER.info(" Creating PropertyKey: [{}], [{}], [{}]",
+                                dbPropName, type.getSimpleName(), cardinality);
                         PropertyKey propK;
                         if (!seenProps.containsKey(dbPropName)) {
                             propK = graphMgmt.makePropertyKey(dbPropName).dataType(type).cardinality(cardinality)
@@ -153,17 +150,14 @@ public class SchemaGenerator4Hist {
                             propK = seenProps.get(dbPropName);
                         }
                         if (graphMgmt.containsGraphIndex(dbPropName)) {
-                            String dmsg = " Index  [" + dbPropName + "] already existed in the DB. ";
-                            LOGGER.debug(dmsg);
+                            LOGGER.debug(" Index  [{}] already existed in the DB. ", dbPropName);
                         } else {
                             if (obj.getIndexedProperties().contains(propName)) {
                                // NOTE - for History we never add a unique index - just a regular index
-                                imsg = "Add index for PropertyKey: [" + dbPropName + "]";
-                                LOGGER.info(imsg);
+                                LOGGER.info("Add index for PropertyKey: [{}]", dbPropName);
                                 graphMgmt.buildIndex(dbPropName, Vertex.class).addKey(propK).buildCompositeIndex();
                             } else {
-                                imsg = "No index needed/added for PropertyKey: [" + dbPropName + "]";
-                                LOGGER.info(imsg);
+                                LOGGER.info("No index needed/added for PropertyKey: [{}]", dbPropName);
                             }
                         }
                     }
@@ -176,63 +170,33 @@ public class SchemaGenerator4Hist {
         //  only have one of them.  That is, a Property can show up many times in a
         //  node, but each instance of that property will only have a single start-ts,
         //  end-ts, end-source-of-truth.  Same goes for a node or edge itself.
-        if (graphMgmt.containsRelationType(END_SOT)) {
-            String dmsg = "PropertyKey [" + END_SOT + "] already existed in the DB. ";
-            LOGGER.debug(dmsg);
-        } else if (!seenProps.containsKey(END_SOT)  ) {
-               String imsg = " Creating PropertyKey: [" + END_SOT + "], [String], [SINGLE]";
-               LOGGER.info(imsg);
-               graphMgmt.makePropertyKey(END_SOT).dataType(String.class)
-                       .cardinality(Cardinality.SINGLE).make();
-        }
-
-        if (graphMgmt.containsRelationType(START_TS)) {
-            String dmsg = " PropertyKey [" + START_TS + "] already existed in the DB. ";
-            LOGGER.debug(dmsg);
-        } else if (!seenProps.containsKey(START_TS)  ) {
-               String imsg = " Creating PropertyKey: [" + START_TS + "], [Long], [SINGLE]";
-               LOGGER.info(imsg);
-               graphMgmt.makePropertyKey(START_TS).dataType(Long.class)
-                       .cardinality(Cardinality.SINGLE).make();
-        }
-
-        if (graphMgmt.containsRelationType(END_TS)) {
-            String dmsg = "PropertyKey [" + END_TS + "] already existed in the DB. ";
-            LOGGER.debug(dmsg);
-        } else if (!seenProps.containsKey(END_TS)  ) {
-               String imsg = " Creating PropertyKey: [" + END_TS + "], [Long], [SINGLE]";
-               LOGGER.info(imsg);
-               graphMgmt.makePropertyKey(END_TS).dataType(Long.class)
-                       .cardinality(Cardinality.SINGLE).make();
-        }
-
-        if (graphMgmt.containsRelationType(START_TX_ID)) {
-            String dmsg = "PropertyKey [" + START_TX_ID + "] already existed in the DB. ";
-            LOGGER.debug(dmsg);
-        } else if (!seenProps.containsKey(START_TX_ID)  ) {
-            String imsg = " Creating PropertyKey: [" + START_TX_ID + "], [String], [SINGLE]";
-            LOGGER.info(imsg);
-            graphMgmt.makePropertyKey(START_TX_ID).dataType(String.class)
-                .cardinality(Cardinality.SINGLE).make();
-        }
+        makeNewProperty(graphMgmt, seenProps, String.class, END_SOT);
+        makeNewProperty(graphMgmt, seenProps, Long.class, START_TS);
+        makeNewProperty(graphMgmt, seenProps, Long.class, END_TS);
+        makeNewProperty(graphMgmt, seenProps, String.class, START_TX_ID);
+        makeNewProperty(graphMgmt, seenProps, String.class, END_TX_ID);
 
-        if (graphMgmt.containsRelationType(END_TX_ID)) {
-            String dmsg = "PropertyKey [" + END_TX_ID + "] already existed in the DB. ";
-            LOGGER.debug(dmsg);
-        } else if (!seenProps.containsKey(END_TX_ID)  ) {
-            String imsg = " Creating PropertyKey: [" + END_TX_ID + "], [String], [SINGLE]";
-            LOGGER.info(imsg);
-            graphMgmt.makePropertyKey(END_TX_ID).dataType(String.class)
-                .cardinality(Cardinality.SINGLE).make();
-        }
 
         String imsg = "-- About to call graphMgmt commit";
         LOGGER.info(imsg);
         graphMgmt.commit();
         if (backend != null) {
-            LOGGER.info("Successfully loaded the schema to " + backend);
+            LOGGER.info("Successfully loaded the schema to {}", backend);
         }
 
     }
 
+    private static <T> void makeNewProperty(JanusGraphManagement graphMgmt,
+                                            Map<String, PropertyKey> seenProps,
+                                            Class<T> type,
+                                            String propertyName) {
+        if (graphMgmt.containsRelationType(propertyName)) {
+            LOGGER.debug("PropertyKey [{}] already existed in the DB.", propertyName);
+        } else if (!seenProps.containsKey(propertyName)) {
+            LOGGER.info("Creating PropertyKey: [{}], [{}], [{}]",
+                    propertyName, type.getSimpleName(), Cardinality.SINGLE);
+            graphMgmt.makePropertyKey(propertyName).dataType(type).cardinality(Cardinality.SINGLE)
+                    .make();
+        }
+    }
 }
index 13040d3..f2f2433 100644 (file)
@@ -152,7 +152,7 @@ public class AAIGraph {
 
         logger.info("-- loading schema into JanusGraph");
         if ("true".equals(SpringContextAware.getApplicationContext().getEnvironment().getProperty("history.enabled", "false"))) {
-            SchemaGenerator4Hist.loadSchemaIntoJanusGraph(graph, graphMgt, IN_MEMORY);
+            SchemaGenerator4Hist.loadSchemaIntoJanusGraph(graphMgt, IN_MEMORY);
         } else {
             SchemaGenerator.loadSchemaIntoJanusGraph(graphMgt, IN_MEMORY);
         }
index 5dfc5d3..6ce42e4 100644 (file)
@@ -26,18 +26,19 @@ public class AAIUnmarshallingException extends AAIException {
 
     private static final long serialVersionUID = -5615651557821878103L;
 
+    private static final String AAI_MSG="AAI_3000";
     public AAIUnmarshallingException() {
     }
 
     public AAIUnmarshallingException(String message) {
-        super("AAI_3000", message);
+        super(AAI_MSG, message);
     }
 
     public AAIUnmarshallingException(Throwable cause) {
-        super("AAI_3000", cause);
+        super(AAI_MSG, cause);
     }
 
     public AAIUnmarshallingException(String message, Throwable cause) {
-        super("AAI_3000", cause, message);
+        super(AAI_MSG, cause, message);
     }
 }
index b762726..9ce343f 100644 (file)
@@ -129,7 +129,7 @@ public class Aggregate extends MultiFormatMapper {
                         json.addProperty(prop.key(), gson.toJson(prop.value()));
                     } else {
                         // throw exception?
-                        return null;
+                        return Optional.empty();
                     }
                 }
             } else {
@@ -214,7 +214,7 @@ public class Aggregate extends MultiFormatMapper {
                 json.add(inner);
             } else {
                 Optional<JsonObject> obj = this.getJsonFromVertex((Vertex)l, properties);
-                json.add(obj.get());
+                if(obj.isPresent()) json.add(obj.get());
             }
         }
         return Optional.of(json);
index c2bfabf..84935cd 100644 (file)
@@ -93,9 +93,9 @@ public class HttpsAuthClient {
 
             ctx = SSLContext.getInstance("TLSv1.2");
             KeyManagerFactory kmf = null;
-            try {
+
+            try(FileInputStream fin = new FileInputStream(keystorePath)) {
                 kmf = KeyManagerFactory.getInstance("SunX509");
-                FileInputStream fin = new FileInputStream(keystorePath);
                 KeyStore ks = KeyStore.getInstance("PKCS12");
                 char[] pwd = keystorePassword.toCharArray();
                 ks.load(fin, pwd);
index 5c82524..5d60673 100644 (file)
@@ -25,11 +25,13 @@ import org.junit.Before;
 import org.junit.Test;
 import org.onap.aai.AAISetup;
 import org.onap.aai.setup.SchemaVersion;
+import org.springframework.test.annotation.DirtiesContext;
 
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 
+@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
 public class ListEndpointsTest extends AAISetup {
 
     private Properties properties;
index f370daa..9ca5ed3 100644 (file)
@@ -21,3 +21,87 @@ AAI is where the data converges, where the pictures come together, and where the
 With the high volume and variety of data, AAI must be prepared to answer many types of queries; real-time search to quickly retrieve specific items from an ocean of data, relationships to determine impacts and consequences, aggregations and counts to explore availability and consumption, validation and integrity to establish whether systems are acting on good information, history and provenance to reconstruct the current view and its context, and enrichment out to legacy systems to examine the low-level details of the network and virtual assets.
 
 .. image:: images/aai_in_onap.png
+
+AAI Components
+^^^^^^^^^^^^^^
+
+.. image:: images/aai_components.png
+
+ESR
+"""
+Applications for management of external systems.
+
+==================  ===
+**aai/esr-gui**     External system management ui. UI for esr-server.
+**aai/esr-server**  ESR backend, mainly include the function of external system reachable check and data pretreatment.
+==================  ===
+
+Input abstraction
+"""""""""""""""""
+Applications that serve as entry points to A&AI.
+
+====================  ===
+**aai/model-loader**  Obtains SDC artifacts and loads them into the A&AI Resources service for storage.
+**aai/sparky-be**     AAI user interface back end.
+**aai/sparky-fe**     AAI user interface front end.
+====================  ===
+
+Query abstraction
+"""""""""""""""""
+Query abstraction point for clients that routes AAI queries and event data.
+
+===================  ===
+**aai/data-router**  AAI Microservice used to route AAI queries and event data to correct storage engine. Serves as a query abstraction point for clients, as well as a gateway.
+===================  ===
+
+Data management
+"""""""""""""""
+Microservices that facilitate data management of AAI objects.
+
+============================  ===
+**aai/babel**                 AAI Microservice to generate AAI model XML from SDC TOSCA CSAR artifacts.
+**aai/cacher**                Cacher is a generic service that can be used to snapshot json responses, force sync them, sync them periodically, or update them by consuming dmaap events.
+**aai/chameleon**             (deprecated) Abstraction service for historical database.
+**aai/champ**                 Abstraction from underlying graph storage systems that A&AI would interface with.
+**aai/gizmo**                 (deprecated) CRUD Rest API endpoint for resources and relationships, delivering atomic interactions with the graph for improved scalability.
+**aai/resources**             AAI Resources Micro Service providing CRUD REST APIs for inventory resources. This microservice provides the main path for updating and searching the graph - java-types defined in the OXM file for each version of the API define the REST endpoints - for example, the java-type "CloudRegion" in aai-common/aai-schema/src/main/resources/oxm/aai_oxm_v11.xml maps to /aai/v11/cloud-infrastructure/cloud-regions/cloud-region.
+**aai/search-data-service**   Abstraction layer for searchengine, supporting queries and updates. Currently supports Elasticsearch, but has also been design with Solr support in mind.
+**aai/spike**                 (deprecated) Microservice used to generate events describing changes to the graph data.
+**aai/tabular-data-service**  (deprecated) Microservice which serves as an abstraction layer to a tabular data store.
+**aai/validation**            Microservice used to invoke validation mechanism .
+============================  ===
+
+Graph services
+""""""""""""""
+Set of components, which store, provide or display schemas.
+
+======================  ===
+**aai/graphadmin**      Microservice with various functions for graph management.
+**aai/graphgraph**      Microservice used to provide view of AAI model, schema and edge rules.
+**aai/schema-service**  Application holds and provides specified schema versions.
+**aai/traversal**       AAI Traversal Micro Service providing REST APIs for traversal/search of inventory resources. Custom queries (gremin-style traversals) model based queries (which use a model either manually created or loaded from SDC models) and named-queries (traversals which ignore edge labels and direction and just link together objects of given node types from a starting node).
+======================  ===
+
+Libraries
+"""""""""
+Libraries don't run as standalone applications. They contain general functionality, which may be imported and used in other modules.
+
+=======================  ===
+**aai/aai-common**       This holds the model, annotations and common modules used across the Resources and Traversal micro services. aai/aai-common creates artifacts like aai-core, aai-schema and aai-annotations, which are used by the rest of the microservices and libraries.
+**aai/event-client**     Event bus client library.
+**aai/logging-service**  AAI common logging library.
+**aai/rest-client**      Library for making REST calls.
+**aai/router-core**      Library containing the core camel components for the data router.
+=======================  ===
+
+Configuration repositories
+""""""""""""""""""""""""""
+Contain several repositories that include various configuration.
+
+===================  ===
+**aai/aai-data**     (deprecated) AAI Chef environment files.
+**aai/aai-config**   (deprecated) AAI Chef cookbooks.
+**aai/aai-service**  (deprecated) AAI REST based services.
+**aai/oom**
+**aai/test-config**  Repository containing test configuration for use in continuous integration.
+===================  ===
diff --git a/docs/platform/images/aai_components.png b/docs/platform/images/aai_components.png
new file mode 100644 (file)
index 0000000..217225f
Binary files /dev/null and b/docs/platform/images/aai_components.png differ