X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fonap%2Faai%2Fbabel%2Fparser%2FArtifactGeneratorToscaParser.java;h=c769e9a57e0367e48fa34cac657f612160be3386;hb=dc94e09008ba0eb9dce7541d2c898ddc5c500814;hp=3bccebe0e9accf9ee08f94173039822740190f66;hpb=66b3afa06776e9944ad515206d281d67747c9770;p=aai%2Fbabel.git diff --git a/src/main/java/org/onap/aai/babel/parser/ArtifactGeneratorToscaParser.java b/src/main/java/org/onap/aai/babel/parser/ArtifactGeneratorToscaParser.java index 3bccebe..c769e9a 100644 --- a/src/main/java/org/onap/aai/babel/parser/ArtifactGeneratorToscaParser.java +++ b/src/main/java/org/onap/aai/babel/parser/ArtifactGeneratorToscaParser.java @@ -1,5 +1,5 @@ /** - * ============LICENSE_START======================================================= + * ============LICENSE_START======================================================= * org.onap.aai * ================================================================================ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. @@ -18,12 +18,8 @@ * limitations under the License. * ============LICENSE_END========================================================= */ -package org.onap.aai.babel.parser; -import static org.onap.aai.babel.xml.generator.data.GeneratorConstants.GENERATOR_AAI_CONFIGFILE_NOT_FOUND; -import static org.onap.aai.babel.xml.generator.data.GeneratorConstants.GENERATOR_AAI_CONFIGLOCATION_NOT_FOUND; -import static org.onap.aai.babel.xml.generator.data.GeneratorConstants.GENERATOR_AAI_PROVIDING_SERVICE_METADATA_MISSING; -import static org.onap.aai.babel.xml.generator.data.GeneratorConstants.GENERATOR_AAI_PROVIDING_SERVICE_MISSING; +package org.onap.aai.babel.parser; import java.io.File; import java.io.FileInputStream; @@ -34,7 +30,6 @@ import java.util.Map; import java.util.Properties; import java.util.stream.Collectors; import org.onap.aai.babel.logging.LogHelper; -import org.onap.aai.babel.xml.generator.data.GeneratorConstants; import org.onap.aai.babel.xml.generator.data.WidgetConfigurationUtil; import org.onap.aai.babel.xml.generator.model.AllotedResource; import org.onap.aai.babel.xml.generator.model.L3NetworkWidget; @@ -54,17 +49,32 @@ import org.onap.sdc.toscaparser.api.Property; public class ArtifactGeneratorToscaParser { - public static final String GENERATOR_AAI_ERROR_INVALID_ID = - "Invalid value for mandatory attribute <%s> in Artifact: <%s>"; + private static Logger log = LogHelper.INSTANCE; + + public static final String PROPERTY_ARTIFACT_GENERATOR_CONFIG_FILE = "artifactgenerator.config"; + + private static final String GENERATOR_AAI_CONFIGFILE_NOT_FOUND = + "Cannot generate artifacts. Artifact Generator Configuration file not found at %s"; + private static final String GENERATOR_AAI_CONFIGLOCATION_NOT_FOUND = + "Cannot generate artifacts. artifactgenerator.config system property not configured"; + private static final String GENERATOR_AAI_PROVIDING_SERVICE_METADATA_MISSING = + "Cannot generate artifacts. Providing Service Metadata is missing for allotted resource %s"; + private static final String GENERATOR_AAI_PROVIDING_SERVICE_MISSING = + "Cannot generate artifacts. Providing Service is missing for allotted resource %s"; + + // Metadata properties + private static final String CATEGORY = "category"; private static final String ALLOTTED_RESOURCE = "Allotted Resource"; + private static final String SUBCATEGORY = "subcategory"; private static final String TUNNEL_XCONNECT = "Tunnel XConnect"; - private static Logger log = LogHelper.INSTANCE; + + private static final String VERSION = "version"; private ISdcCsarHelper csarHelper; /** * Constructs using csarHelper - * + * * @param csarHelper The csar helper */ public ArtifactGeneratorToscaParser(ISdcCsarHelper csarHelper) { @@ -73,7 +83,7 @@ public class ArtifactGeneratorToscaParser { /** * Returns the artifact description - * + * * @param model the artifact model * @return the artifact model's description */ @@ -89,12 +99,12 @@ public class ArtifactGeneratorToscaParser { /** * Initialises the widget configuration. - * + * * @throws IOException */ public static void initWidgetConfiguration() throws IOException { log.debug("Getting Widget Configuration"); - String configLocation = System.getProperty(GeneratorConstants.PROPERTY_ARTIFACT_GENERATOR_CONFIG_FILE); + String configLocation = System.getProperty(PROPERTY_ARTIFACT_GENERATOR_CONFIG_FILE); if (configLocation != null) { File file = new File(configLocation); if (file.exists()) { @@ -110,8 +120,8 @@ public class ArtifactGeneratorToscaParser { } /** - * Generates a Resource List using input Service Node Templates - * + * Generates a Resource List using input Service Node Templates. + * * @param serviceNodes input Service Node Templates * @param idTypeStore ID->Type mapping * @return the processed resource models @@ -213,11 +223,11 @@ public class ArtifactGeneratorToscaParser { /** * Process the service tosca - * + * * @param service model of the service artifact * @param idTypeStore ID->Type mapping * @param nodeTemplates a list of service nodes - * + * */ public void processServiceTosca(Service service, Map idTypeStore, List nodeTemplates) { @@ -253,16 +263,16 @@ public class ArtifactGeneratorToscaParser { } private boolean hasAllottedResource(Map metadata) { - return ALLOTTED_RESOURCE.equals(metadata.get(GeneratorConstants.CATEGORY)); + return ALLOTTED_RESOURCE.equals(metadata.get(CATEGORY)); } private boolean hasSubCategoryTunnelXConnect(Map metadata) { - return TUNNEL_XCONNECT.equals(metadata.get(GeneratorConstants.SUBCATEGORY)); + return TUNNEL_XCONNECT.equals(metadata.get(SUBCATEGORY)); } /** * Create a Map of property name against String property value from the input Map - * + * * @param inputMap The input Map * @return Map of property name against String property value */ @@ -285,7 +295,7 @@ public class ArtifactGeneratorToscaParser { String.format(GENERATOR_AAI_PROVIDING_SERVICE_METADATA_MISSING, model.getModelId())); } Map properties = populateStringProperties(nodeProperties); - properties.put(GeneratorConstants.VERSION, "1.0"); + properties.put(VERSION, "1.0"); resourceNode.populateModelIdentificationInformation(properties); model.addResource((Resource) resourceNode); } else if (resourceNode instanceof Resource && !(resourceNode.getWidgetType().equals(Widget.Type.L3_NET))) {