Remove all references to artifactgenerator config 58/83458/2
authormark.j.leonard <mark.j.leonard@gmail.com>
Tue, 26 Mar 2019 13:38:40 +0000 (13:38 +0000)
committermark.j.leonard <mark.j.leonard@gmail.com>
Thu, 28 Mar 2019 13:19:09 +0000 (13:19 +0000)
Delete the artifact-generator.properties file. Remove all related
functionality from the code.

Change-Id: I652d99b6424bb60af5820f5afb97ef139e3f9511
Issue-ID: AAI-2284
Signed-off-by: mark.j.leonard <mark.j.leonard@gmail.com>
15 files changed:
appconfig-local/readme.txt
pom.xml
src/main/bin/start.sh
src/main/java/org/onap/aai/babel/parser/ArtifactGeneratorToscaParser.java
src/main/java/org/onap/aai/babel/xml/generator/api/AaiArtifactGenerator.java
src/main/java/org/onap/aai/babel/xml/generator/data/WidgetConfigurationUtil.java
src/test/java/org/onap/aai/babel/parser/TestArtifactGeneratorToscaParser.java
src/test/java/org/onap/aai/babel/service/TestCsarToXmlConverter.java
src/test/java/org/onap/aai/babel/util/ArtifactTestUtils.java
src/test/java/org/onap/aai/babel/util/Resources.java
src/test/java/org/onap/aai/babel/xml/generator/TestAaiArtifactGenerator.java
src/test/java/org/onap/aai/babel/xml/generator/model/TestModel.java
src/test/java/org/onap/aai/babel/xml/generator/model/TestVfModule.java
src/test/java/org/onap/aai/babel/xml/generator/model/TestWidget.java
src/test/resources/artifact-generator.properties [deleted file]

index 79cf29e..42b32f7 100644 (file)
@@ -1 +1,3 @@
-Relevant configuration files need to be copied here to successfully run this service locally.
\ No newline at end of file
+Relevant configuration files need to be copied here to successfully run this service locally.
+
+mvn -DKEY_STORE_PASSWORD=<obfuscated_password> spring-boot:run
diff --git a/pom.xml b/pom.xml
index fccfa93..5736290 100644 (file)
--- a/pom.xml
+++ b/pom.xml
                                        <jvmArguments>
                                                -DCONFIG_HOME=./appconfig-local
                                                -DAPP_HOME=.
-                                               -Dartifactgenerator.config=./appconfig-local/artifact-generator.properties
+                                                -Dtosca.mappings.config=./appconfig-local/tosca-mappings.json
                                                -DKEY_STORE_PASSWORD=${KEY_STORE_PASSWORD}
                                        </jvmArguments>
                                </configuration>
index f30a599..3121c8e 100644 (file)
@@ -3,8 +3,8 @@
 # ============LICENSE_START=======================================================
 # org.onap.aai
 # ================================================================================
-# Copyright © 2017-2019 AT&T Intellectual Property. All rights reserved.
-# Copyright © 2017-2019 European Software Marketing Ltd.
+# Copyright (c) 2017-2019 AT&T Intellectual Property. All rights reserved.
+# Copyright (c) 2017-2019 European Software Marketing Ltd.
 # ================================================================================
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 APP_HOME="${APP_HOME:-/opt/app/babel}"
 
 if [ -z "${CONFIG_HOME}" ]; then
-       echo "CONFIG_HOME must be set in order to start up process"
+       echo "CONFIG_HOME must be set in order to start the process"
        exit 1
 fi
 
 if [ -z "${KEY_STORE_PASSWORD}" ]; then
-       echo "KEY_STORE_PASSWORD must be set in order to start up process"
+       echo "KEY_STORE_PASSWORD must be set in order to start the process"
        exit 1
 fi
 
 PROPS="-DAPP_HOME=${APP_HOME}"
 PROPS="${PROPS} -DCONFIG_HOME=${CONFIG_HOME}"
-PROPS="${PROPS} -Dartifactgenerator.config=${CONFIG_HOME}/artifact-generator.properties"
 PROPS="${PROPS} -Dtosca.mappings.config=${CONFIG_HOME}/tosca-mappings.json"
 PROPS="${PROPS} -DKEY_STORE_PASSWORD=${KEY_STORE_PASSWORD}"
 JVM_MAX_HEAP=${MAX_HEAP:-1024}
index 9b66e58..c2d34c9 100644 (file)
@@ -25,7 +25,6 @@ import com.google.gson.Gson;
 import com.google.gson.JsonSyntaxException;
 import java.io.BufferedReader;
 import java.io.File;
-import java.io.FileInputStream;
 import java.io.FileReader;
 import java.io.IOException;
 import java.util.ArrayList;
@@ -33,7 +32,6 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Optional;
-import java.util.Properties;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 import org.onap.aai.babel.logging.LogHelper;
@@ -60,7 +58,6 @@ public class ArtifactGeneratorToscaParser {
 
     private static Logger log = LogHelper.INSTANCE;
 
-    public static final String PROPERTY_ARTIFACT_GENERATOR_CONFIG_FILE = "artifactgenerator.config";
     public static final String PROPERTY_TOSCA_MAPPING_FILE = "tosca.mappings.config";
 
     public static final String GENERATOR_AAI_CONFIGLOCATION_NOT_FOUND =
@@ -93,30 +90,6 @@ public class ArtifactGeneratorToscaParser {
         this.csarHelper = csarHelper;
     }
 
-    /**
-     * Initializes the Widget to UUID mapping configuration.
-     *
-     * @throws IOException
-     *             if an error occurs reading the configuration properties
-     */
-    public static void initWidgetConfiguration() throws IOException {
-        log.debug("Getting Widget Configuration");
-        String configLocation = System.getProperty(PROPERTY_ARTIFACT_GENERATOR_CONFIG_FILE);
-        if (configLocation != null) {
-            File file = new File(configLocation);
-            if (file.exists()) {
-                Properties properties = new Properties();
-                properties.load(new FileInputStream(file));
-                WidgetConfigurationUtil.setConfig(properties);
-            } else {
-                throw new IllegalArgumentException(String.format(GENERATOR_AAI_CONFIGFILE_NOT_FOUND, configLocation));
-            }
-        } else {
-            throw new IllegalArgumentException(
-                    String.format(GENERATOR_AAI_CONFIGLOCATION_NOT_FOUND, PROPERTY_ARTIFACT_GENERATOR_CONFIG_FILE));
-        }
-    }
-
     /**
      * Initializes the group filtering and TOSCA to Widget mapping configuration.
      *
index 2b8b128..11c1471 100644 (file)
@@ -82,7 +82,6 @@ public class AaiArtifactGenerator implements ArtifactGenerator {
         }
 
         try {
-            ArtifactGeneratorToscaParser.initWidgetConfiguration();
             ArtifactGeneratorToscaParser.initToscaMappingsConfiguration(configLocation);
         } catch (IOException e) {
             log.error(ApplicationMsgs.LOAD_PROPERTIES, e, configLocation);
index 620f792..8f774c9 100644 (file)
@@ -28,7 +28,6 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Optional;
-import java.util.Properties;
 import org.onap.aai.babel.xml.generator.XmlArtifactGenerationException;
 import org.onap.aai.babel.xml.generator.model.Resource;
 import org.onap.aai.babel.xml.generator.model.Widget;
@@ -40,7 +39,6 @@ public class WidgetConfigurationUtil {
     public static final String GENERATOR_AAI_CONFIGLPROP_NOT_FOUND =
             "Cannot generate artifacts. Widget configuration not found for %s";
 
-    private static Properties config;
     private static List<String> instanceGroups = Collections.emptyList();
     private static Map<String, Resource> typeToResource = new HashMap<>();
     private static Map<String, Widget> typeToWidget = new HashMap<>();
@@ -52,10 +50,6 @@ public class WidgetConfigurationUtil {
         throw new UnsupportedOperationException("This static class should not be instantiated!");
     }
 
-    public static void setConfig(Properties config) {
-        WidgetConfigurationUtil.config = config;
-    }
-
     public static void setSupportedInstanceGroups(List<String> supportedInstanceGroups) {
         instanceGroups = supportedInstanceGroups;
     }
@@ -94,15 +88,10 @@ public class WidgetConfigurationUtil {
     public static void setWidgetTypes(List<WidgetTypeConfig> types) {
         WidgetType.clearElements();
         for (WidgetTypeConfig type : types) {
-            if (type.type == null || type.name == null) {
+            if (type.type == null || type.name == null || type.modelInvariantId == null
+                    || type.modelVersionId == null) {
                 throw new IllegalArgumentException("Incomplete widget type specified: " + type);
             }
-            if (type.modelInvariantId == null) {
-                type.modelInvariantId = WidgetConfigurationUtil.getModelInvariantId(type.name);
-            }
-            if (type.modelVersionId == null) {
-                type.modelVersionId = WidgetConfigurationUtil.getModelVersionId(type.name);
-            }
             Widget widget = new Widget(new WidgetType(type.type), type.name, type.deleteFlag, //
                     type.modelInvariantId, type.modelVersionId);
             typeToWidget.put(type.type, widget);
@@ -123,21 +112,4 @@ public class WidgetConfigurationUtil {
         }
     }
 
-    public static String getModelInvariantId(String name) {
-        String id = config.getProperty(ArtifactType.AAI.name() + ".model-invariant-id." + name);
-        if (id == null) {
-            throw new IllegalArgumentException(String.format(GENERATOR_AAI_CONFIGLPROP_NOT_FOUND,
-                    ArtifactType.AAI.name() + ".model-invariant-id." + name));
-        }
-        return id;
-    }
-
-    public static String getModelVersionId(String name) {
-        String id = config.getProperty(ArtifactType.AAI.name() + ".model-version-id." + name);
-        if (id == null) {
-            throw new IllegalArgumentException(String.format(GENERATOR_AAI_CONFIGLPROP_NOT_FOUND,
-                    ArtifactType.AAI.name() + ".model-version-id." + name));
-        }
-        return id;
-    }
 }
index 7bc9fa8..50812c9 100644 (file)
@@ -56,18 +56,6 @@ public class TestArtifactGeneratorToscaParser {
 
     private static final String TEST_UUID = "1234";
 
-    /**
-     * Initialize the Generator with an invalid artifact generator properties file path.
-     *
-     * @throws IOException
-     *             if an error occurs reading the configuration properties
-     */
-    @Test(expected = IllegalArgumentException.class)
-    public void testMissingPropertiesFile() throws IOException {
-        System.setProperty(ArtifactGeneratorToscaParser.PROPERTY_ARTIFACT_GENERATOR_CONFIG_FILE, "non-existent.file");
-        ArtifactGeneratorToscaParser.initWidgetConfiguration();
-    }
-
     /**
      * Initialize the Generator with an invalid mappings file path.
      *
@@ -176,7 +164,6 @@ public class TestArtifactGeneratorToscaParser {
     public void testAddWidgetToService() throws IOException, XmlArtifactGenerationException {
         ArtifactTestUtils testUtils = new ArtifactTestUtils();
         testUtils.loadWidgetMappings();
-        testUtils.loadWidgetToUuidMappings();
 
         Model serviceModel = new Service();
         Resource resourceModel = new Resource(WidgetType.valueOf("VF"), false);
index 244eccd..184623c 100644 (file)
@@ -100,26 +100,6 @@ public class TestCsarToXmlConverter {
                 SERVICE_VERSION);
     }
 
-    /**
-     * Test that an Exception is thrown when the Artifact Generator properties are not present.
-     *
-     * @throws CsarConverterException
-     *             if there is an error either extracting the YAML files or generating XML artifacts
-     * @throws IOException
-     *             if an I/O exception occurs loading the test CSAR file
-     */
-    @Test
-    public void testArtifactGeneratorConfigMissing() throws CsarConverterException, IOException {
-        exception.expect(IllegalArgumentException.class);
-        exception.expectMessage("Cannot generate artifacts. System property "
-                + ArtifactGeneratorToscaParser.PROPERTY_ARTIFACT_GENERATOR_CONFIG_FILE + " not configured");
-
-        // Unset the required system property
-        System.clearProperty(ArtifactGeneratorToscaParser.PROPERTY_ARTIFACT_GENERATOR_CONFIG_FILE);
-        converter.generateXmlFromCsar(CsarTest.SD_WAN_CSAR_FILE.getContent(), CsarTest.SD_WAN_CSAR_FILE.getName(),
-                SERVICE_VERSION);
-    }
-
     /**
      * Test that an Exception is thrown when the Artifact Generator's TOSCA Mappings configuration file is not present.
      *
index 164c80b..066911e 100644 (file)
@@ -44,7 +44,6 @@ import org.apache.commons.io.IOUtils;
 import org.custommonkey.xmlunit.Diff;
 import org.onap.aai.babel.parser.ArtifactGeneratorToscaParser;
 import org.onap.aai.babel.xml.generator.data.Artifact;
-import org.onap.aai.babel.xml.generator.data.WidgetConfigurationUtil;
 import org.xml.sax.SAXException;
 
 /**
@@ -60,23 +59,10 @@ public class ArtifactTestUtils {
      * Initialize System Properties for test configuration files.
      */
     public void setGeneratorSystemProperties() {
-        System.setProperty(ArtifactGeneratorToscaParser.PROPERTY_ARTIFACT_GENERATOR_CONFIG_FILE,
-                getResourcePath(Resources.ARTIFACT_GENERATOR_CONFIG));
-
         System.setProperty(ArtifactGeneratorToscaParser.PROPERTY_TOSCA_MAPPING_FILE,
                 getResourcePath(Resources.TOSCA_MAPPING_CONFIG));
     }
 
-    /**
-     * Load the Widget to UUID mappings from the Artifact Generator Properties (resource).
-     *
-     * @throws IOException
-     *             if the properties file is not loaded
-     */
-    public void loadWidgetToUuidMappings() throws IOException {
-        WidgetConfigurationUtil.setConfig(getResourceAsProperties(Resources.ARTIFACT_GENERATOR_CONFIG));
-    }
-
     /**
      * Load the Widget type mappings (resource).
      *
index 72b0d1a..e089670 100644 (file)
@@ -26,7 +26,6 @@ package org.onap.aai.babel.util;
  */
 public class Resources {
 
-    public static final String ARTIFACT_GENERATOR_CONFIG = "artifact-generator.properties";
     public static final String TOSCA_MAPPING_CONFIG = "tosca-mappings.json";
     public static final String EMPTY_TOSCA_MAPPING_CONFIG = "empty-tosca-mappings.json";
     public static final String INVALID_TOSCA_MAPPING_CONFIG = "invalid-tosca-mappings.json";
index 2668e1e..b29d0d7 100644 (file)
@@ -88,7 +88,6 @@ public class TestAaiArtifactGenerator {
     public void testParserWithIncompleteMappings()
             throws SdcToscaParserException, IOException, XmlArtifactGenerationException {
         testUtils.loadWidgetMappings();
-        testUtils.loadWidgetToUuidMappings();
 
         AaiArtifactGenerator artifactGenerator = new AaiArtifactGenerator();
         WidgetType.clearElements(); // Remove all WidgetTypes so that the generator fails
index f1a579e..9fc5928 100644 (file)
@@ -37,16 +37,14 @@ import org.onap.aai.babel.util.ArtifactTestUtils;
 public class TestModel {
 
     /**
-     * Load the Widget Configuration, including the type mappings and the UUID mappings.
+     * Load the Widget mapping configuration.
      *
      * @throws IOException
      *             if the mappings configuration cannot be loaded
      */
     @BeforeClass
     public static void setup() throws IOException {
-        ArtifactTestUtils util = new ArtifactTestUtils();
-        util.loadWidgetToUuidMappings();
-        util.loadWidgetMappings();
+        new ArtifactTestUtils().loadWidgetMappings();
     }
 
     @Test
index 38931fb..88555ee 100644 (file)
@@ -41,16 +41,14 @@ import org.onap.aai.babel.xml.generator.XmlArtifactGenerationException;
 public class TestVfModule {
 
     /**
-     * Load the Widget Configuration, including the type mappings and the UUID mappings.
+     * Load the Widget mappings configuration.
      *
      * @throws IOException
      *             if the mappings configuration cannot be loaded
      */
     @BeforeClass
     public static void setup() throws IOException {
-        ArtifactTestUtils util = new ArtifactTestUtils();
-        util.loadWidgetToUuidMappings();
-        util.loadWidgetMappings();
+        new ArtifactTestUtils().loadWidgetMappings();
     }
 
     /**
index e5702ac..fec3479 100644 (file)
@@ -39,16 +39,14 @@ import org.onap.aai.babel.xml.generator.types.ModelType;
 public class TestWidget {
 
     /**
-     * Load the Widget Configuration, including the type mappings and the UUID mappings.
+     * Load the Widget mappings configuration.
      *
      * @throws IOException
      *             if the mappings configuration cannot be loaded
      */
     @BeforeClass
     public static void setup() throws IOException {
-        ArtifactTestUtils util = new ArtifactTestUtils();
-        util.loadWidgetToUuidMappings();
-        util.loadWidgetMappings();
+        new ArtifactTestUtils().loadWidgetMappings();
     }
 
     @Test
diff --git a/src/test/resources/artifact-generator.properties b/src/test/resources/artifact-generator.properties
deleted file mode 100644 (file)
index e69de29..0000000