diff options
Diffstat (limited to 'src/main')
50 files changed, 1066 insertions, 869 deletions
diff --git a/src/main/bin/start.sh b/src/main/bin/start.sh index f7b20c4..038f4df 100644 --- a/src/main/bin/start.sh +++ b/src/main/bin/start.sh @@ -4,7 +4,7 @@ # org.onap.aai # =================================================================== # Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. -# Copyright © 2017-2018 Amdocs +# Copyright © 2017-2018 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. @@ -20,27 +20,37 @@ # ============LICENSE_END============================================ #******************************************************************************* -BASEDIR="/opt/app/model-loader/" -AJSC_HOME="$BASEDIR" +# AJSC_HOME is required for EELF logging. +# This path is referenced in the file logback.xml. +AJSC_HOME="${AJSC_HOME-/opt/app/model-loader}" if [ -z "$CONFIG_HOME" ]; then - echo "CONFIG_HOME must be set in order to start up process" - exit 1 + echo "CONFIG_HOME must be set in order to start up the process" + echo "The expected value is a folder containing the model-loader.properties file" + exit 1 fi -CLASSPATH="$AJSC_HOME/lib/*" -CLASSPATH="$CLASSPATH:$AJSC_HOME/extJars/" -CLASSPATH="$CLASSPATH:$AJSC_HOME/etc/" +JARFILE="$AJSC_HOME/model-loader.jar" + +# Some properties are repeated here for debugging purposes. PROPS="-DAJSC_HOME=$AJSC_HOME" -PROPS="$PROPS -DAJSC_CONF_HOME=$BASEDIR/bundleconfig/" -PROPS="$PROPS -Dlogback.configurationFile=$BASEDIR/bundleconfig/etc/logback.xml" -PROPS="$PROPS -DAJSC_SHARED_CONFIG=$AJSC_CONF_HOME" -PROPS="$PROPS -DAJSC_SERVICE_NAMESPACE=model-loader" -PROPS="$PROPS -DAJSC_SERVICE_VERSION=v1" -PROPS="$PROPS -Dserver.port=9500" PROPS="$PROPS -DCONFIG_HOME=$CONFIG_HOME" +PROPS="$PROPS -Dcom.att.eelf.logging.path=$AJSC_HOME" +PROPS="$PROPS -Dcom.att.eelf.logging.file=logback.xml" +PROPS="$PROPS -Dlogback.configurationFile=$AJSC_HOME/logback.xml" +PROPS="$PROPS -Dserver.port=9500" JVM_MAX_HEAP=${MAX_HEAP:-1024} -echo $CLASSPATH +if [ -z "${java_runtime_arguments}" ]; then + java_runtime_arguments="-Xms75m -Xmx${JVM_MAX_HEAP}m \ + -Dcom.sun.management.jmxremote \ + -Dcom.sun.management.jmxremote.authenticate=false \ + -Dcom.sun.management.jmxremote.ssl=false \ + -Dcom.sun.management.jmxremote.local.only=false \ + -Dcom.sun.management.jmxremote.port=1099 \ + -Dcom.sun.management.jmxremote.rmi.port=1099 \ + -Djava.rmi.server.hostname=127.0.0.1" +fi -exec java -Xmx${JVM_MAX_HEAP}m $PROPS -classpath $CLASSPATH com.att.ajsc.runner.Runner context=// port=9500 +echo "java $java_runtime_arguments $PROPS -jar $JARFILE" +java $java_runtime_arguments $PROPS -jar $JARFILE diff --git a/src/main/docker/Dockerfile b/src/main/docker/Dockerfile index 9aafdda..db67dd9 100644 --- a/src/main/docker/Dockerfile +++ b/src/main/docker/Dockerfile @@ -2,20 +2,22 @@ FROM ubuntu:14.04 ARG MICRO_HOME=/opt/app/model-loader ARG BIN_HOME=$MICRO_HOME/bin +ARG JAR_FILE=model-loader.jar RUN apt-get update # Install and setup java8 RUN apt-get update && apt-get install -y software-properties-common -## sudo -E is required to preserve the environment. If you remove that line, it will most like freeze at this step +## sudo -E is required to preserve the environment. If you remove that line, it will most likely freeze at this step RUN sudo -E add-apt-repository ppa:openjdk-r/ppa && apt-get update && apt-get install -y openjdk-8-jdk -## Setup JAVA_HOME, this is useful for docker commandline +## Set up JAVA_HOME for docker command-line ENV JAVA_HOME usr/lib/jvm/java-8-openjdk-amd64 RUN export JAVA_HOME # Build up the deployment folder structure RUN mkdir -p $MICRO_HOME -ADD swm/package/nix/dist_files/appl/model-loader/* $MICRO_HOME/ +COPY ${JAR_FILE} $MICRO_HOME/ +COPY classes/logback.xml $MICRO_HOME/ RUN mkdir -p $BIN_HOME COPY *.sh $BIN_HOME RUN chmod 755 $BIN_HOME/* diff --git a/src/main/java/org/onap/aai/modelloader/config/ModelLoaderConfig.java b/src/main/java/org/onap/aai/modelloader/config/ModelLoaderConfig.java index 692f412..3f03bb5 100644 --- a/src/main/java/org/onap/aai/modelloader/config/ModelLoaderConfig.java +++ b/src/main/java/org/onap/aai/modelloader/config/ModelLoaderConfig.java @@ -1,22 +1,22 @@ /** - * ============LICENSE_START========================================== + * ============LICENSE_START======================================================= * org.onap.aai - * =================================================================== + * ================================================================================ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * =================================================================== + * Copyright © 2017-2018 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. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ============LICENSE_END============================================ + * ============LICENSE_END========================================================= */ package org.onap.aai.modelloader.config; @@ -25,7 +25,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Properties; import org.eclipse.jetty.util.security.Password; -import org.openecomp.sdc.api.consumer.IConfiguration; +import org.onap.sdc.api.consumer.IConfiguration; /** * Properties for the Model Loader @@ -33,267 +33,286 @@ import org.openecomp.sdc.api.consumer.IConfiguration; */ public class ModelLoaderConfig implements IConfiguration { - // Configuration file structure - public static final String PREFIX_MODEL_LOADER_CONFIG = "ml"; - public static final String PREFIX_DISTRIBUTION_CLIENT = PREFIX_MODEL_LOADER_CONFIG + ".distribution."; - public static final String PREFIX_AAI = PREFIX_MODEL_LOADER_CONFIG + ".aai."; - public static final String PREFIX_BABEL = PREFIX_MODEL_LOADER_CONFIG + ".babel."; - public static final String PREFIX_DEBUG = PREFIX_MODEL_LOADER_CONFIG + ".debug."; - - private static final String SUFFIX_KEYSTORE_FILE = "KEYSTORE_FILE"; - private static final String SUFFIX_KEYSTORE_PASS = "KEYSTORE_PASSWORD"; - - // Configuration file properties - protected static final String PROP_ML_DISTRIBUTION_ACTIVE_SERVER_TLS_AUTH = - PREFIX_DISTRIBUTION_CLIENT + "ACTIVE_SERVER_TLS_AUTH"; - protected static final String PROP_ML_DISTRIBUTION_ASDC_CONNECTION_DISABLED = PREFIX_DISTRIBUTION_CLIENT + "ASDC_CONNECTION_DISABLE"; - protected static final String PROP_ML_DISTRIBUTION_ASDC_ADDRESS = PREFIX_DISTRIBUTION_CLIENT + "ASDC_ADDRESS"; - protected static final String PROP_ML_DISTRIBUTION_CONSUMER_GROUP = PREFIX_DISTRIBUTION_CLIENT + "CONSUMER_GROUP"; - protected static final String PROP_ML_DISTRIBUTION_CONSUMER_ID = PREFIX_DISTRIBUTION_CLIENT + "CONSUMER_ID"; - protected static final String PROP_ML_DISTRIBUTION_ENVIRONMENT_NAME = - PREFIX_DISTRIBUTION_CLIENT + "ENVIRONMENT_NAME"; - protected static final String PROP_ML_DISTRIBUTION_KEYSTORE_PASSWORD = - PREFIX_DISTRIBUTION_CLIENT + SUFFIX_KEYSTORE_PASS; - protected static final String PROP_ML_DISTRIBUTION_KEYSTORE_FILE = - PREFIX_DISTRIBUTION_CLIENT + SUFFIX_KEYSTORE_FILE; - protected static final String PROP_ML_DISTRIBUTION_PASSWORD = PREFIX_DISTRIBUTION_CLIENT + "PASSWORD"; - protected static final String PROP_ML_DISTRIBUTION_POLLING_INTERVAL = - PREFIX_DISTRIBUTION_CLIENT + "POLLING_INTERVAL"; - protected static final String PROP_ML_DISTRIBUTION_POLLING_TIMEOUT = PREFIX_DISTRIBUTION_CLIENT + "POLLING_TIMEOUT"; - protected static final String PROP_ML_DISTRIBUTION_USER = PREFIX_DISTRIBUTION_CLIENT + "USER"; - protected static final String PROP_ML_DISTRIBUTION_ARTIFACT_TYPES = PREFIX_DISTRIBUTION_CLIENT + "ARTIFACT_TYPES"; - protected static final String PROP_ML_DISTRIBUTION_MSG_BUS_ADDRESSES = PREFIX_DISTRIBUTION_CLIENT + "MSG_BUS_ADDRESSES"; - protected static final String PROP_ML_DISTRIBUTION_HTTPS_WITH_DMAAP = - PREFIX_DISTRIBUTION_CLIENT + "USE_HTTPS_WITH_DMAAP"; - - protected static final String PROP_AAI_BASE_URL = PREFIX_AAI + "BASE_URL"; - protected static final String PROP_AAI_KEYSTORE_FILE = PREFIX_AAI + SUFFIX_KEYSTORE_FILE; - protected static final String PROP_AAI_KEYSTORE_PASSWORD = PREFIX_AAI + SUFFIX_KEYSTORE_PASS; - protected static final String PROP_AAI_MODEL_RESOURCE_URL = PREFIX_AAI + "MODEL_URL"; - protected static final String PROP_AAI_NAMED_QUERY_RESOURCE_URL = PREFIX_AAI + "NAMED_QUERY_URL"; - protected static final String PROP_AAI_VNF_IMAGE_RESOURCE_URL = PREFIX_AAI + "VNF_IMAGE_URL"; - protected static final String PROP_AAI_AUTHENTICATION_USER = PREFIX_AAI + "AUTH_USER"; - protected static final String PROP_AAI_AUTHENTICATION_PASSWORD = PREFIX_AAI + "AUTH_PASSWORD"; - - protected static final String PROP_BABEL_BASE_URL = PREFIX_BABEL + "BASE_URL"; - protected static final String PROP_BABEL_KEYSTORE_FILE = PREFIX_BABEL + SUFFIX_KEYSTORE_FILE; - protected static final String PROP_BABEL_KEYSTORE_PASSWORD = PREFIX_BABEL + SUFFIX_KEYSTORE_PASS; - protected static final String PROP_BABEL_GENERATE_RESOURCE_URL = PREFIX_BABEL + "GENERATE_ARTIFACTS_URL"; - - protected static final String PROP_DEBUG_INGEST_SIMULATOR = PREFIX_DEBUG + "INGEST_SIMULATOR"; - - private Properties modelLoaderProperties = null; - - private String certLocation = "."; - - private List<String> artifactTypes = null; - - private List<String> msgBusAddrs = null; - - private String modelVersion = null; - - - /** - * This is the class constructor. - * - * @param modelLoaderProperties properties needed to be configured for the model loader - * @param certLocation location of the certificate - */ - public ModelLoaderConfig(Properties modelLoaderProperties, String certLocation) { - this.modelLoaderProperties = modelLoaderProperties; - this.certLocation = certLocation; - - // Get list of artifacts - artifactTypes = new ArrayList<>(); - if (modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_ARTIFACT_TYPES) != null) { - String[] artTypeList = modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_ARTIFACT_TYPES).split(","); - for (String artType : artTypeList) { - artifactTypes.add(artType); - } - } - - // Get list of message bus addresses - msgBusAddrs = new ArrayList<>(); - if (modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_MSG_BUS_ADDRESSES) != null) { - String[] msgBusList = modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_MSG_BUS_ADDRESSES).split(","); - for (String addr : msgBusList) { - msgBusAddrs.add(addr); - } - } - } - - @Override - public boolean activateServerTLSAuth() { - String value = modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_ACTIVE_SERVER_TLS_AUTH); - return value == null ? false : Boolean.parseBoolean(value); - } - - @Override - public String getAsdcAddress() { - return modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_ASDC_ADDRESS); - } - - @Override - public String getConsumerGroup() { - return modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_CONSUMER_GROUP); - } - - @Override - public String getConsumerID() { - return modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_CONSUMER_ID); - } - - @Override - public String getEnvironmentName() { - return modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_ENVIRONMENT_NAME); - } - - @Override - public String getKeyStorePassword() { - return Password.deobfuscate(modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_KEYSTORE_PASSWORD)); - } - - @Override - public String getKeyStorePath() { - return certLocation + modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_KEYSTORE_FILE); - } - - @Override - public String getPassword() { - return Password.deobfuscate(modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_PASSWORD)); - } - - @Override - public int getPollingInterval() { - return Integer.parseInt(modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_POLLING_INTERVAL)); - } - - @Override - public int getPollingTimeout() { - return Integer.parseInt(modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_POLLING_TIMEOUT)); - } - - @Override - public List<String> getRelevantArtifactTypes() { - return artifactTypes; - } - - @Override - public String getUser() { - return modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_USER); - } - - @Override - public boolean isFilterInEmptyResources() { - return false; - } - - @Override - public Boolean isUseHttpsWithDmaap() { - String useHTTPS = modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_HTTPS_WITH_DMAAP); - return useHTTPS == null ? false : Boolean.valueOf(useHTTPS); - } - - @Override - public List<String> getMsgBusAddress() { - return msgBusAddrs; - } - - public String getAaiKeyStorePath() { - return certLocation + File.separator + modelLoaderProperties.getProperty(PROP_AAI_KEYSTORE_FILE); - } - - public String getBabelKeyStorePath() { - return certLocation + File.separator + modelLoaderProperties.getProperty(PROP_BABEL_KEYSTORE_FILE); - } - - public String getAaiKeyStorePassword() { - return Password.deobfuscate(modelLoaderProperties.getProperty(PROP_AAI_KEYSTORE_PASSWORD)); - } - - public String getBabelKeyStorePassword() { - return Password.deobfuscate(modelLoaderProperties.getProperty(PROP_BABEL_KEYSTORE_PASSWORD)); - } - - public String getAaiBaseUrl() { - return modelLoaderProperties.getProperty(PROP_AAI_BASE_URL); - } - - public String getBabelBaseUrl() { - return modelLoaderProperties.getProperty(PROP_BABEL_BASE_URL); - } - - public String getBabelGenerateArtifactsUrl() { - return modelLoaderProperties.getProperty(PROP_BABEL_GENERATE_RESOURCE_URL); - } - - public String getAaiModelUrl(String version) { - setModelVersion(version); - return updatePropertyOXMVersion(modelLoaderProperties, PROP_AAI_MODEL_RESOURCE_URL, version); - } - - public String getAaiNamedQueryUrl(String version) { - return updatePropertyOXMVersion(modelLoaderProperties, PROP_AAI_NAMED_QUERY_RESOURCE_URL, version); - } - - public String getAaiVnfImageUrl() { - return updatePropertyOXMVersion(modelLoaderProperties, PROP_AAI_VNF_IMAGE_RESOURCE_URL, getModelVersion()); - } - - public String getAaiAuthenticationUser() { - return modelLoaderProperties.getProperty(PROP_AAI_AUTHENTICATION_USER); - } - - public String getModelVersion() { - return modelVersion; - } - - public void setModelVersion(String modelVersion) { - this.modelVersion = modelVersion; - } - - /** - * @return password for AAI authentication that has been reverse-engineered from its obfuscated form. - */ - public String getAaiAuthenticationPassword() { - String password = Password.deobfuscate(modelLoaderProperties.getProperty(PROP_AAI_AUTHENTICATION_PASSWORD)); - - if (password != null && password.isEmpty()) { - password = null; - } - - return password; - } - - /** - * @return a boolean value indicating whether the simulator is enabled. - */ - public boolean getIngestSimulatorEnabled() { - String propValue = modelLoaderProperties.getProperty(PROP_DEBUG_INGEST_SIMULATOR); - return propValue != null && "enabled".equalsIgnoreCase(propValue); - } - - /** - * @return a String value of the defined property with the oxm version - */ - private String updatePropertyOXMVersion(Properties modelLoaderProperties, String propertyName, String version) { - if (version != null) - return modelLoaderProperties.getProperty(propertyName).replace("v*", version); - else - return modelLoaderProperties.getProperty(propertyName); - } - - - - - /** - * @return a boolean value indicating whether model loader is connected to ASDC. - */ - public boolean getASDCConnectionDisabled(){ - String propValue = modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_ASDC_CONNECTION_DISABLED); - return propValue != null && "true".equalsIgnoreCase(propValue); - - } + // Configuration file structure + public static final String PREFIX_MODEL_LOADER_CONFIG = "ml"; + public static final String PREFIX_DISTRIBUTION_CLIENT = PREFIX_MODEL_LOADER_CONFIG + ".distribution."; + public static final String PREFIX_AAI = PREFIX_MODEL_LOADER_CONFIG + ".aai."; + public static final String PREFIX_BABEL = PREFIX_MODEL_LOADER_CONFIG + ".babel."; + public static final String PREFIX_DEBUG = PREFIX_MODEL_LOADER_CONFIG + ".debug."; + + private static final String SUFFIX_KEYSTORE_FILE = "KEYSTORE_FILE"; + private static final String SUFFIX_KEYSTORE_PASS = "KEYSTORE_PASSWORD"; + + // Configuration file properties + protected static final String PROP_ML_DISTRIBUTION_ACTIVE_SERVER_TLS_AUTH = + PREFIX_DISTRIBUTION_CLIENT + "ACTIVE_SERVER_TLS_AUTH"; + protected static final String PROP_ML_DISTRIBUTION_ASDC_CONNECTION_DISABLED = + PREFIX_DISTRIBUTION_CLIENT + "ASDC_CONNECTION_DISABLE"; + protected static final String PROP_ML_DISTRIBUTION_ASDC_ADDRESS = PREFIX_DISTRIBUTION_CLIENT + "ASDC_ADDRESS"; + protected static final String PROP_ML_DISTRIBUTION_CONSUMER_GROUP = PREFIX_DISTRIBUTION_CLIENT + "CONSUMER_GROUP"; + protected static final String PROP_ML_DISTRIBUTION_CONSUMER_ID = PREFIX_DISTRIBUTION_CLIENT + "CONSUMER_ID"; + protected static final String PROP_ML_DISTRIBUTION_ENVIRONMENT_NAME = + PREFIX_DISTRIBUTION_CLIENT + "ENVIRONMENT_NAME"; + protected static final String PROP_ML_DISTRIBUTION_KEYSTORE_PASSWORD = + PREFIX_DISTRIBUTION_CLIENT + SUFFIX_KEYSTORE_PASS; + protected static final String PROP_ML_DISTRIBUTION_KEYSTORE_FILE = + PREFIX_DISTRIBUTION_CLIENT + SUFFIX_KEYSTORE_FILE; + protected static final String PROP_ML_DISTRIBUTION_PASSWORD = PREFIX_DISTRIBUTION_CLIENT + "PASSWORD"; + protected static final String PROP_ML_DISTRIBUTION_POLLING_INTERVAL = + PREFIX_DISTRIBUTION_CLIENT + "POLLING_INTERVAL"; + protected static final String PROP_ML_DISTRIBUTION_POLLING_TIMEOUT = PREFIX_DISTRIBUTION_CLIENT + "POLLING_TIMEOUT"; + protected static final String PROP_ML_DISTRIBUTION_USER = PREFIX_DISTRIBUTION_CLIENT + "USER"; + protected static final String PROP_ML_DISTRIBUTION_ARTIFACT_TYPES = PREFIX_DISTRIBUTION_CLIENT + "ARTIFACT_TYPES"; + protected static final String PROP_ML_DISTRIBUTION_MSG_BUS_ADDRESSES = + PREFIX_DISTRIBUTION_CLIENT + "MSG_BUS_ADDRESSES"; + protected static final String PROP_ML_DISTRIBUTION_HTTPS_WITH_DMAAP = + PREFIX_DISTRIBUTION_CLIENT + "USE_HTTPS_WITH_DMAAP"; + + protected static final String PROP_AAI_BASE_URL = PREFIX_AAI + "BASE_URL"; + protected static final String PROP_AAI_KEYSTORE_FILE = PREFIX_AAI + SUFFIX_KEYSTORE_FILE; + protected static final String PROP_AAI_KEYSTORE_PASSWORD = PREFIX_AAI + SUFFIX_KEYSTORE_PASS; + protected static final String PROP_AAI_MODEL_RESOURCE_URL = PREFIX_AAI + "MODEL_URL"; + protected static final String PROP_AAI_NAMED_QUERY_RESOURCE_URL = PREFIX_AAI + "NAMED_QUERY_URL"; + protected static final String PROP_AAI_VNF_IMAGE_RESOURCE_URL = PREFIX_AAI + "VNF_IMAGE_URL"; + protected static final String PROP_AAI_AUTHENTICATION_USER = PREFIX_AAI + "AUTH_USER"; + protected static final String PROP_AAI_AUTHENTICATION_PASSWORD = PREFIX_AAI + "AUTH_PASSWORD"; + + protected static final String PROP_BABEL_BASE_URL = PREFIX_BABEL + "BASE_URL"; + protected static final String PROP_BABEL_KEYSTORE_FILE = PREFIX_BABEL + SUFFIX_KEYSTORE_FILE; + protected static final String PROP_BABEL_KEYSTORE_PASSWORD = PREFIX_BABEL + SUFFIX_KEYSTORE_PASS; + protected static final String PROP_BABEL_GENERATE_RESOURCE_URL = PREFIX_BABEL + "GENERATE_ARTIFACTS_URL"; + + protected static final String PROP_DEBUG_INGEST_SIMULATOR = PREFIX_DEBUG + "INGEST_SIMULATOR"; + private static String configHome; + + private Properties modelLoaderProperties = null; + + private String certLocation = "."; + + private List<String> artifactTypes = null; + + private List<String> msgBusAddrs = null; + + private String modelVersion = null; + + protected static final String FILESEP = + (System.getProperty("file.separator") == null) ? "/" : System.getProperty("file.separator"); + + public static void setConfigHome(String configHome) { + ModelLoaderConfig.configHome = configHome; + } + + public static String propertiesFile() { + return configHome + FILESEP + "model-loader.properties"; + } + + public ModelLoaderConfig(Properties configProperties) { + this(configProperties, ModelLoaderConfig.configHome + FILESEP + "auth" + FILESEP); + } + + /** + * Original constructor + * + * @param modelLoaderProperties properties needed to be configured for the model loader + * @param certLocation location of the certificate + */ + public ModelLoaderConfig(Properties modelLoaderProperties, String certLocation) { + this.modelLoaderProperties = modelLoaderProperties; + this.certLocation = certLocation; + + // Get list of artifacts + artifactTypes = new ArrayList<>(); + if (modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_ARTIFACT_TYPES) != null) { + String[] artTypeList = modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_ARTIFACT_TYPES).split(","); + for (String artType : artTypeList) { + artifactTypes.add(artType); + } + } + + // Get list of message bus addresses + msgBusAddrs = new ArrayList<>(); + if (modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_MSG_BUS_ADDRESSES) != null) { + String[] msgBusList = modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_MSG_BUS_ADDRESSES).split(","); + for (String addr : msgBusList) { + msgBusAddrs.add(addr); + } + } + } + + + @Override + public boolean activateServerTLSAuth() { + String value = modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_ACTIVE_SERVER_TLS_AUTH); + return value == null ? false : Boolean.parseBoolean(value); + } + + @Override + public String getAsdcAddress() { + return modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_ASDC_ADDRESS); + } + + @Override + public String getConsumerGroup() { + return modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_CONSUMER_GROUP); + } + + @Override + public String getConsumerID() { + return modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_CONSUMER_ID); + } + + @Override + public String getEnvironmentName() { + return modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_ENVIRONMENT_NAME); + } + + @Override + public String getKeyStorePassword() { + return Password.deobfuscate(modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_KEYSTORE_PASSWORD)); + } + + @Override + public String getKeyStorePath() { + return certLocation + modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_KEYSTORE_FILE); + } + + @Override + public String getPassword() { + return Password.deobfuscate(modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_PASSWORD)); + } + + @Override + public int getPollingInterval() { + return Integer.parseInt(modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_POLLING_INTERVAL)); + } + + @Override + public int getPollingTimeout() { + return Integer.parseInt(modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_POLLING_TIMEOUT)); + } + + @Override + public List<String> getRelevantArtifactTypes() { + return artifactTypes; + } + + @Override + public String getUser() { + return modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_USER); + } + + @Override + public boolean isFilterInEmptyResources() { + return false; + } + + @Override + public Boolean isUseHttpsWithDmaap() { + String useHTTPS = modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_HTTPS_WITH_DMAAP); + return useHTTPS == null ? false : Boolean.valueOf(useHTTPS); + } + + @Override + public List<String> getMsgBusAddress() { + return msgBusAddrs; + } + + public String getAaiKeyStorePath() { + return certLocation + File.separator + modelLoaderProperties.getProperty(PROP_AAI_KEYSTORE_FILE); + } + + public String getBabelKeyStorePath() { + String filename = modelLoaderProperties.getProperty(PROP_BABEL_KEYSTORE_FILE); + if (filename == null) { + return null; + } else { + return certLocation + File.separator + filename; + } + } + + public String getAaiKeyStorePassword() { + return Password.deobfuscate(modelLoaderProperties.getProperty(PROP_AAI_KEYSTORE_PASSWORD)); + } + + public String getBabelKeyStorePassword() { + return Password.deobfuscate(modelLoaderProperties.getProperty(PROP_BABEL_KEYSTORE_PASSWORD)); + } + + public String getAaiBaseUrl() { + return modelLoaderProperties.getProperty(PROP_AAI_BASE_URL); + } + + public String getBabelBaseUrl() { + return modelLoaderProperties.getProperty(PROP_BABEL_BASE_URL); + } + + public String getBabelGenerateArtifactsUrl() { + return modelLoaderProperties.getProperty(PROP_BABEL_GENERATE_RESOURCE_URL); + } + + public String getAaiModelUrl(String version) { + setModelVersion(version); + return updatePropertyOXMVersion(modelLoaderProperties, PROP_AAI_MODEL_RESOURCE_URL, version); + } + + public String getAaiNamedQueryUrl(String version) { + return updatePropertyOXMVersion(modelLoaderProperties, PROP_AAI_NAMED_QUERY_RESOURCE_URL, version); + } + public String getAaiVnfImageUrl() { + return updatePropertyOXMVersion(modelLoaderProperties, PROP_AAI_VNF_IMAGE_RESOURCE_URL, getModelVersion()); + } + + public String getAaiAuthenticationUser() { + return modelLoaderProperties.getProperty(PROP_AAI_AUTHENTICATION_USER); + } + + public String getModelVersion() { + return modelVersion; + } + + public void setModelVersion(String modelVersion) { + this.modelVersion = modelVersion; + } + + /** + * @return password for AAI authentication that has been reverse-engineered from its obfuscated form. + */ + public String getAaiAuthenticationPassword() { + String password = Password.deobfuscate(modelLoaderProperties.getProperty(PROP_AAI_AUTHENTICATION_PASSWORD)); + + if (password != null && password.isEmpty()) { + password = null; + } + + return password; + } + + /** + * @return a boolean value indicating whether the simulator is enabled. + */ + public boolean getIngestSimulatorEnabled() { + String propValue = modelLoaderProperties.getProperty(PROP_DEBUG_INGEST_SIMULATOR); + return propValue != null && "enabled".equalsIgnoreCase(propValue); + } + + /** + * @return a String value of the defined property with the oxm version + */ + private String updatePropertyOXMVersion(Properties modelLoaderProperties, String propertyName, String version) { + if (version != null) + return modelLoaderProperties.getProperty(propertyName).replace("v*", version); + else + return modelLoaderProperties.getProperty(propertyName); + } + + /** + * @return a boolean value indicating whether model loader is connected to ASDC. + */ + public boolean getASDCConnectionDisabled() { + String propValue = modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_ASDC_CONNECTION_DISABLED); + return propValue != null && "true".equalsIgnoreCase(propValue); + + } } diff --git a/src/main/java/org/onap/aai/modelloader/entity/Artifact.java b/src/main/java/org/onap/aai/modelloader/entity/Artifact.java index 4c0e0f1..f576e24 100644 --- a/src/main/java/org/onap/aai/modelloader/entity/Artifact.java +++ b/src/main/java/org/onap/aai/modelloader/entity/Artifact.java @@ -1,22 +1,22 @@ /** - * ============LICENSE_START========================================== + * ============LICENSE_START======================================================= * org.onap.aai - * =================================================================== + * ================================================================================ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * =================================================================== + * Copyright © 2017-2018 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. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ============LICENSE_END============================================ + * ============LICENSE_END========================================================= */ package org.onap.aai.modelloader.entity; diff --git a/src/main/java/org/onap/aai/modelloader/entity/ArtifactHandler.java b/src/main/java/org/onap/aai/modelloader/entity/ArtifactHandler.java index 9e80e05..b1fed03 100644 --- a/src/main/java/org/onap/aai/modelloader/entity/ArtifactHandler.java +++ b/src/main/java/org/onap/aai/modelloader/entity/ArtifactHandler.java @@ -1,27 +1,26 @@ /**
- * ============LICENSE_START==========================================
+ * ============LICENSE_START=======================================================
* org.onap.aai
- * ===================================================================
+ * ================================================================================
* Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ===================================================================
+ * Copyright © 2017-2018 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.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- * ============LICENSE_END============================================
+ * ============LICENSE_END=========================================================
*/
package org.onap.aai.modelloader.entity;
import java.util.List;
-
import org.onap.aai.modelloader.config.ModelLoaderConfig;
import org.onap.aai.modelloader.restclient.AaiRestClient;
@@ -33,9 +32,8 @@ public abstract class ArtifactHandler { this.config = config;
}
- public abstract boolean pushArtifacts(List<Artifact> artifacts, String distributionId, List<Artifact> completedArtifacts,
- AaiRestClient restClient);
+ public abstract boolean pushArtifacts(List<Artifact> artifacts, String distributionId,
+ List<Artifact> completedArtifacts, AaiRestClient restClient);
- public abstract void rollback(List<Artifact> completedArtifacts, String distributionId,
- AaiRestClient aaiClient);
+ public abstract void rollback(List<Artifact> completedArtifacts, String distributionId, AaiRestClient aaiClient);
}
diff --git a/src/main/java/org/onap/aai/modelloader/entity/ArtifactType.java b/src/main/java/org/onap/aai/modelloader/entity/ArtifactType.java index 6959936..a58c874 100644 --- a/src/main/java/org/onap/aai/modelloader/entity/ArtifactType.java +++ b/src/main/java/org/onap/aai/modelloader/entity/ArtifactType.java @@ -1,22 +1,22 @@ /** - * ============LICENSE_START========================================== + * ============LICENSE_START======================================================= * org.onap.aai - * =================================================================== + * ================================================================================ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * =================================================================== + * Copyright © 2017-2018 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. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ============LICENSE_END============================================ + * ============LICENSE_END========================================================= */ package org.onap.aai.modelloader.entity; diff --git a/src/main/java/org/onap/aai/modelloader/entity/catalog/VnfCatalogArtifact.java b/src/main/java/org/onap/aai/modelloader/entity/catalog/VnfCatalogArtifact.java index 3219625..a8f4e60 100644 --- a/src/main/java/org/onap/aai/modelloader/entity/catalog/VnfCatalogArtifact.java +++ b/src/main/java/org/onap/aai/modelloader/entity/catalog/VnfCatalogArtifact.java @@ -1,22 +1,22 @@ /** - * ============LICENSE_START========================================== + * ============LICENSE_START======================================================= * org.onap.aai - * =================================================================== + * ================================================================================ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * =================================================================== + * Copyright © 2017-2018 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. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ============LICENSE_END============================================ + * ============LICENSE_END========================================================= */ package org.onap.aai.modelloader.entity.catalog; diff --git a/src/main/java/org/onap/aai/modelloader/entity/catalog/VnfCatalogArtifactHandler.java b/src/main/java/org/onap/aai/modelloader/entity/catalog/VnfCatalogArtifactHandler.java index b224407..85be50b 100644 --- a/src/main/java/org/onap/aai/modelloader/entity/catalog/VnfCatalogArtifactHandler.java +++ b/src/main/java/org/onap/aai/modelloader/entity/catalog/VnfCatalogArtifactHandler.java @@ -1,22 +1,22 @@ /**
- * ============LICENSE_START==========================================
+ * ============LICENSE_START=======================================================
* org.onap.aai
- * ===================================================================
+ * ================================================================================
* Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ===================================================================
+ * Copyright © 2017-2018 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.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- * ============LICENSE_END============================================
+ * ============LICENSE_END=========================================================
*/
package org.onap.aai.modelloader.entity.catalog;
diff --git a/src/main/java/org/onap/aai/modelloader/entity/catalog/VnfImageException.java b/src/main/java/org/onap/aai/modelloader/entity/catalog/VnfImageException.java index 9459c49..c116abe 100644 --- a/src/main/java/org/onap/aai/modelloader/entity/catalog/VnfImageException.java +++ b/src/main/java/org/onap/aai/modelloader/entity/catalog/VnfImageException.java @@ -1,22 +1,22 @@ /** - * ============LICENSE_START========================================== + * ============LICENSE_START======================================================= * org.onap.aai - * =================================================================== + * ================================================================================ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * =================================================================== + * Copyright © 2017-2018 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. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ============LICENSE_END============================================ + * ============LICENSE_END========================================================= */ package org.onap.aai.modelloader.entity.catalog; @@ -55,4 +55,4 @@ class VnfImageException extends Exception { return resultCode; } -}
\ No newline at end of file +} diff --git a/src/main/java/org/onap/aai/modelloader/entity/model/AbstractModelArtifact.java b/src/main/java/org/onap/aai/modelloader/entity/model/AbstractModelArtifact.java index 3c1152f..35c672a 100644 --- a/src/main/java/org/onap/aai/modelloader/entity/model/AbstractModelArtifact.java +++ b/src/main/java/org/onap/aai/modelloader/entity/model/AbstractModelArtifact.java @@ -1,29 +1,28 @@ /** - * ============LICENSE_START========================================== + * ============LICENSE_START======================================================= * org.onap.aai - * =================================================================== + * ================================================================================ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * =================================================================== + * Copyright © 2017-2018 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. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ============LICENSE_END============================================ + * ============LICENSE_END========================================================= */ package org.onap.aai.modelloader.entity.model; import java.util.HashSet; import java.util.List; import java.util.Set; - import org.onap.aai.modelloader.config.ModelLoaderConfig; import org.onap.aai.modelloader.entity.Artifact; import org.onap.aai.modelloader.entity.ArtifactType; diff --git a/src/main/java/org/onap/aai/modelloader/entity/model/AbstractModelArtifactParser.java b/src/main/java/org/onap/aai/modelloader/entity/model/AbstractModelArtifactParser.java index fd6af31..35405e6 100644 --- a/src/main/java/org/onap/aai/modelloader/entity/model/AbstractModelArtifactParser.java +++ b/src/main/java/org/onap/aai/modelloader/entity/model/AbstractModelArtifactParser.java @@ -1,24 +1,23 @@ /** - * ============LICENSE_START========================================== + * ============LICENSE_START======================================================= * org.onap.aai - * =================================================================== + * ================================================================================ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * =================================================================== + * Copyright © 2017-2018 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. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ============LICENSE_END============================================ + * ============LICENSE_END========================================================= */ - package org.onap.aai.modelloader.entity.model; import java.io.StringReader; @@ -30,12 +29,10 @@ import java.util.stream.Collector; import java.util.stream.IntStream; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; - import org.onap.aai.cl.api.Logger; import org.onap.aai.cl.eelf.LoggerFactory; import org.onap.aai.modelloader.entity.Artifact; import org.onap.aai.modelloader.service.ModelLoaderMsgs; - import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; diff --git a/src/main/java/org/onap/aai/modelloader/entity/model/BabelArtifactParsingException.java b/src/main/java/org/onap/aai/modelloader/entity/model/BabelArtifactParsingException.java index 1426e82..a3f14ba 100644 --- a/src/main/java/org/onap/aai/modelloader/entity/model/BabelArtifactParsingException.java +++ b/src/main/java/org/onap/aai/modelloader/entity/model/BabelArtifactParsingException.java @@ -1,24 +1,23 @@ /** - * ============LICENSE_START========================================== + * ============LICENSE_START======================================================= * org.onap.aai - * =================================================================== + * ================================================================================ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * =================================================================== + * Copyright © 2017-2018 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. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ============LICENSE_END============================================ + * ============LICENSE_END========================================================= */ - package org.onap.aai.modelloader.entity.model; /** diff --git a/src/main/java/org/onap/aai/modelloader/entity/model/IModelArtifact.java b/src/main/java/org/onap/aai/modelloader/entity/model/IModelArtifact.java index 5978b99..a3b0737 100644 --- a/src/main/java/org/onap/aai/modelloader/entity/model/IModelArtifact.java +++ b/src/main/java/org/onap/aai/modelloader/entity/model/IModelArtifact.java @@ -1,24 +1,23 @@ /** - * ============LICENSE_START========================================== + * ============LICENSE_START======================================================= * org.onap.aai - * =================================================================== + * ================================================================================ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * =================================================================== + * Copyright © 2017-2018 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. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ============LICENSE_END============================================ + * ============LICENSE_END========================================================= */ - package org.onap.aai.modelloader.entity.model; /** diff --git a/src/main/java/org/onap/aai/modelloader/entity/model/IModelId.java b/src/main/java/org/onap/aai/modelloader/entity/model/IModelId.java index 9b635bf..41ac94b 100644 --- a/src/main/java/org/onap/aai/modelloader/entity/model/IModelId.java +++ b/src/main/java/org/onap/aai/modelloader/entity/model/IModelId.java @@ -1,35 +1,34 @@ /** - * ============LICENSE_START========================================== + * ============LICENSE_START======================================================= * org.onap.aai - * =================================================================== + * ================================================================================ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * =================================================================== + * Copyright © 2017-2018 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. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ============LICENSE_END============================================ + * ============LICENSE_END========================================================= */ - package org.onap.aai.modelloader.entity.model; /** - * Defines methods for c + * Defines methods for Model Id */ public interface IModelId { /** * This method is responsible for using the values in the supplied Pair to set the id of the model. * - * The definition of what the relationship will be is defined by the implementation. Some model ids would have + * The definition of what the relationship will be is defined by the implementation. Some model ids would have * single key/value pairs, others would have a composite key. * * Where the id of the model is a composite key multiple calls to this method will be required to successfully set diff --git a/src/main/java/org/onap/aai/modelloader/entity/model/IModelParser.java b/src/main/java/org/onap/aai/modelloader/entity/model/IModelParser.java index 758a882..7287142 100644 --- a/src/main/java/org/onap/aai/modelloader/entity/model/IModelParser.java +++ b/src/main/java/org/onap/aai/modelloader/entity/model/IModelParser.java @@ -1,27 +1,26 @@ /** - * ============LICENSE_START========================================== + * ============LICENSE_START======================================================= * org.onap.aai - * =================================================================== + * ================================================================================ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * =================================================================== + * Copyright © 2017-2018 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. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ============LICENSE_END============================================ + * ============LICENSE_END========================================================= */ package org.onap.aai.modelloader.entity.model; import java.util.List; - import org.onap.aai.modelloader.entity.Artifact; @FunctionalInterface diff --git a/src/main/java/org/onap/aai/modelloader/entity/model/ModelArtifact.java b/src/main/java/org/onap/aai/modelloader/entity/model/ModelArtifact.java index 896167a..154cda1 100644 --- a/src/main/java/org/onap/aai/modelloader/entity/model/ModelArtifact.java +++ b/src/main/java/org/onap/aai/modelloader/entity/model/ModelArtifact.java @@ -1,22 +1,22 @@ /** - * ============LICENSE_START========================================== + * ============LICENSE_START======================================================= * org.onap.aai - * =================================================================== + * ================================================================================ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * =================================================================== + * Copyright © 2017-2018 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. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ============LICENSE_END============================================ + * ============LICENSE_END========================================================= */ package org.onap.aai.modelloader.entity.model; @@ -31,16 +31,14 @@ import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; - +import org.onap.aai.cl.api.Logger; +import org.onap.aai.cl.eelf.LoggerFactory; import org.onap.aai.modelloader.config.ModelLoaderConfig; +import org.onap.aai.modelloader.entity.Artifact; import org.onap.aai.modelloader.entity.ArtifactType; import org.onap.aai.modelloader.restclient.AaiRestClient; import org.onap.aai.modelloader.service.ModelLoaderMsgs; -import org.onap.aai.cl.api.Logger; -import org.onap.aai.cl.eelf.LoggerFactory; -import org.onap.aai.modelloader.entity.Artifact; import org.onap.aai.restclient.client.OperationResult; - import org.w3c.dom.Node; public class ModelArtifact extends AbstractModelArtifact { diff --git a/src/main/java/org/onap/aai/modelloader/entity/model/ModelArtifactHandler.java b/src/main/java/org/onap/aai/modelloader/entity/model/ModelArtifactHandler.java index 157ac8d..626ca49 100644 --- a/src/main/java/org/onap/aai/modelloader/entity/model/ModelArtifactHandler.java +++ b/src/main/java/org/onap/aai/modelloader/entity/model/ModelArtifactHandler.java @@ -1,34 +1,33 @@ /** - * ============LICENSE_START========================================== + * ============LICENSE_START======================================================= * org.onap.aai - * =================================================================== + * ================================================================================ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * =================================================================== + * Copyright © 2017-2018 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. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ============LICENSE_END============================================ + * ============LICENSE_END========================================================= */ package org.onap.aai.modelloader.entity.model; import java.util.List; - +import org.onap.aai.cl.api.Logger; +import org.onap.aai.cl.eelf.LoggerFactory; import org.onap.aai.modelloader.config.ModelLoaderConfig; import org.onap.aai.modelloader.entity.Artifact; import org.onap.aai.modelloader.entity.ArtifactHandler; import org.onap.aai.modelloader.restclient.AaiRestClient; import org.onap.aai.modelloader.service.ModelLoaderMsgs; -import org.onap.aai.cl.api.Logger; -import org.onap.aai.cl.eelf.LoggerFactory; public class ModelArtifactHandler extends ArtifactHandler { @@ -45,7 +44,7 @@ public class ModelArtifactHandler extends ArtifactHandler { List<Artifact> sortedModelArtifacts; try { sortedModelArtifacts = modelSorter.sort(artifacts); - } catch (RuntimeException ex) { + } catch (BabelArtifactParsingException ex) { logger.error(ModelLoaderMsgs.DISTRIBUTION_EVENT_ERROR, "Unable to resolve models: " + ex.getMessage()); return false; } diff --git a/src/main/java/org/onap/aai/modelloader/entity/model/ModelArtifactParser.java b/src/main/java/org/onap/aai/modelloader/entity/model/ModelArtifactParser.java index 17bdd87..e687be0 100644 --- a/src/main/java/org/onap/aai/modelloader/entity/model/ModelArtifactParser.java +++ b/src/main/java/org/onap/aai/modelloader/entity/model/ModelArtifactParser.java @@ -1,22 +1,22 @@ /** - * ============LICENSE_START========================================== + * ============LICENSE_START======================================================= * org.onap.aai - * =================================================================== + * ================================================================================ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * =================================================================== + * Copyright © 2017-2018 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. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ============LICENSE_END============================================ + * ============LICENSE_END========================================================= */ package org.onap.aai.modelloader.entity.model; @@ -25,12 +25,10 @@ import java.util.Objects; import java.util.stream.Collector; import java.util.stream.IntStream; import javax.xml.XMLConstants; - -import org.onap.aai.modelloader.entity.Artifact; -import org.onap.aai.modelloader.service.ModelLoaderMsgs; import org.onap.aai.cl.api.Logger; import org.onap.aai.cl.eelf.LoggerFactory; - +import org.onap.aai.modelloader.entity.Artifact; +import org.onap.aai.modelloader.service.ModelLoaderMsgs; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; diff --git a/src/main/java/org/onap/aai/modelloader/entity/model/ModelSorter.java b/src/main/java/org/onap/aai/modelloader/entity/model/ModelSorter.java index e8fcf3f..4c39975 100644 --- a/src/main/java/org/onap/aai/modelloader/entity/model/ModelSorter.java +++ b/src/main/java/org/onap/aai/modelloader/entity/model/ModelSorter.java @@ -1,22 +1,22 @@ /** - * ============LICENSE_START========================================== + * ============LICENSE_START======================================================= * org.onap.aai - * =================================================================== + * ================================================================================ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * =================================================================== + * Copyright © 2017-2018 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. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ============LICENSE_END============================================ + * ============LICENSE_END========================================================= */ package org.onap.aai.modelloader.entity.model; @@ -30,7 +30,6 @@ import java.util.Map; import java.util.Objects; import java.util.Set; import jline.internal.Log; - import org.onap.aai.modelloader.entity.Artifact; /** @@ -115,15 +114,14 @@ public class ModelSorter { * * @param originalList the list that needs to be sorted * @return a list of sorted models + * @throws BabelArtifactParsingException */ - public List<Artifact> sort(List<Artifact> originalList) { - - if (originalList.size() <= 1) { + public List<Artifact> sort(List<Artifact> originalList) throws BabelArtifactParsingException { + if (originalList == null || originalList.size() <= 1) { return originalList; } - Collection<Node> nodes = createNodes(originalList); - Collection<Node> sortedNodes = sortNodes(nodes); + Collection<Node> sortedNodes = sortNodes(createNodes(originalList)); List<Artifact> sortedModelsList = new ArrayList<>(sortedNodes.size()); for (Node node : sortedNodes) { @@ -188,8 +186,9 @@ public class ModelSorter { * * @param unsortedNodes the collection of nodes to be sorted * @return a sorted collection of the given nodes + * @throws BabelArtifactParsingException */ - private Collection<Node> sortNodes(Collection<Node> unsortedNodes) { + private Collection<Node> sortNodes(Collection<Node> unsortedNodes) throws BabelArtifactParsingException { // L <- Empty list that will contain the sorted elements List<Node> nodeList = new ArrayList<>(); @@ -233,7 +232,8 @@ public class ModelSorter { } } if (cycle) { - throw new RuntimeException("Circular dependency present between models, topological sort not possible"); + throw new BabelArtifactParsingException( + "Circular dependency present between models, topological sort not possible"); } return nodeList; diff --git a/src/main/java/org/onap/aai/modelloader/entity/model/NamedQueryArtifact.java b/src/main/java/org/onap/aai/modelloader/entity/model/NamedQueryArtifact.java index 668a751..4df9879 100644 --- a/src/main/java/org/onap/aai/modelloader/entity/model/NamedQueryArtifact.java +++ b/src/main/java/org/onap/aai/modelloader/entity/model/NamedQueryArtifact.java @@ -1,37 +1,35 @@ /** - * ============LICENSE_START========================================== + * ============LICENSE_START======================================================= * org.onap.aai - * =================================================================== + * ================================================================================ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * =================================================================== + * Copyright © 2017-2018 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. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ============LICENSE_END============================================ + * ============LICENSE_END========================================================= */ package org.onap.aai.modelloader.entity.model; import java.util.List; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; - +import org.onap.aai.cl.api.Logger; +import org.onap.aai.cl.eelf.LoggerFactory; import org.onap.aai.modelloader.config.ModelLoaderConfig; +import org.onap.aai.modelloader.entity.Artifact; import org.onap.aai.modelloader.entity.ArtifactType; import org.onap.aai.modelloader.restclient.AaiRestClient; import org.onap.aai.modelloader.service.ModelLoaderMsgs; -import org.onap.aai.cl.api.Logger; -import org.onap.aai.cl.eelf.LoggerFactory; - -import org.onap.aai.modelloader.entity.Artifact; import org.onap.aai.restclient.client.OperationResult; public class NamedQueryArtifact extends AbstractModelArtifact { @@ -58,7 +56,8 @@ public class NamedQueryArtifact extends AbstractModelArtifact { } @Override - public boolean push(AaiRestClient aaiClient, ModelLoaderConfig config, String distId, List<Artifact> completedArtifacts) { + public boolean push(AaiRestClient aaiClient, ModelLoaderConfig config, String distId, + List<Artifact> completedArtifacts) { OperationResult getResponse = aaiClient.getResource(getNamedQueryUrl(config), distId, MediaType.APPLICATION_XML_TYPE); if ((getResponse == null) || (getResponse.getResultCode() != Response.Status.OK.getStatusCode())) { diff --git a/src/main/java/org/onap/aai/modelloader/entity/model/NamedQueryArtifactParser.java b/src/main/java/org/onap/aai/modelloader/entity/model/NamedQueryArtifactParser.java index 5b9488e..3a0eada 100644 --- a/src/main/java/org/onap/aai/modelloader/entity/model/NamedQueryArtifactParser.java +++ b/src/main/java/org/onap/aai/modelloader/entity/model/NamedQueryArtifactParser.java @@ -1,32 +1,30 @@ /** - * ============LICENSE_START========================================== + * ============LICENSE_START======================================================= * org.onap.aai - * =================================================================== + * ================================================================================ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * =================================================================== + * Copyright © 2017-2018 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. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ============LICENSE_END============================================ + * ============LICENSE_END========================================================= */ package org.onap.aai.modelloader.entity.model; import java.util.List; - -import org.onap.aai.modelloader.entity.Artifact; -import org.onap.aai.modelloader.service.ModelLoaderMsgs; import org.onap.aai.cl.api.Logger; import org.onap.aai.cl.eelf.LoggerFactory; - +import org.onap.aai.modelloader.entity.Artifact; +import org.onap.aai.modelloader.service.ModelLoaderMsgs; import org.w3c.dom.Node; public class NamedQueryArtifactParser extends AbstractModelArtifactParser { @@ -44,15 +42,13 @@ public class NamedQueryArtifactParser extends AbstractModelArtifactParser { boolean valid = false; if (model != null) { - logger.info(ModelLoaderMsgs.DISTRIBUTION_EVENT, - "Named-Query parsed =====>>>> " + "Named-Query-UUID: " + ((NamedQueryArtifact) model) - .getNamedQueryUuid()); + logger.info(ModelLoaderMsgs.DISTRIBUTION_EVENT, "Named-Query parsed =====>>>> " + "Named-Query-UUID: " + + ((NamedQueryArtifact) model).getNamedQueryUuid()); modelList.add((NamedQueryArtifact) model); valid = true; } else { - logger.error(ModelLoaderMsgs.ARTIFACT_PARSE_ERROR, - "Unable to parse named-query artifact " + artifactName); + logger.error(ModelLoaderMsgs.ARTIFACT_PARSE_ERROR, "Unable to parse named-query artifact " + artifactName); } return valid; diff --git a/src/main/java/org/onap/aai/modelloader/entity/model/Pair.java b/src/main/java/org/onap/aai/modelloader/entity/model/Pair.java index ede60eb..e6382b1 100644 --- a/src/main/java/org/onap/aai/modelloader/entity/model/Pair.java +++ b/src/main/java/org/onap/aai/modelloader/entity/model/Pair.java @@ -1,24 +1,23 @@ /** - * ============LICENSE_START========================================== + * ============LICENSE_START======================================================= * org.onap.aai - * =================================================================== + * ================================================================================ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * =================================================================== + * Copyright © 2017-2018 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. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ============LICENSE_END============================================ + * ============LICENSE_END========================================================= */ - package org.onap.aai.modelloader.entity.model; /** diff --git a/src/main/java/org/onap/aai/modelloader/extraction/ArtifactInfoExtractor.java b/src/main/java/org/onap/aai/modelloader/extraction/ArtifactInfoExtractor.java index 7dbc34f..0fde55c 100644 --- a/src/main/java/org/onap/aai/modelloader/extraction/ArtifactInfoExtractor.java +++ b/src/main/java/org/onap/aai/modelloader/extraction/ArtifactInfoExtractor.java @@ -1,30 +1,30 @@ /** - * ============LICENSE_START========================================== + * ============LICENSE_START======================================================= * org.onap.aai - * =================================================================== + * ================================================================================ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * =================================================================== + * Copyright © 2017-2018 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. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ============LICENSE_END============================================ + * ============LICENSE_END========================================================= */ package org.onap.aai.modelloader.extraction; import java.util.ArrayList; import java.util.List; -import org.openecomp.sdc.api.notification.IArtifactInfo; -import org.openecomp.sdc.api.notification.INotificationData; -import org.openecomp.sdc.api.notification.IResourceInstance; +import org.onap.sdc.api.notification.IArtifactInfo; +import org.onap.sdc.api.notification.INotificationData; +import org.onap.sdc.api.notification.IResourceInstance; /** * This class is responsible for extracting implementations of IArtifactInto from an implementation of diff --git a/src/main/java/org/onap/aai/modelloader/extraction/InvalidArchiveException.java b/src/main/java/org/onap/aai/modelloader/extraction/InvalidArchiveException.java index 5e6353f..36581df 100644 --- a/src/main/java/org/onap/aai/modelloader/extraction/InvalidArchiveException.java +++ b/src/main/java/org/onap/aai/modelloader/extraction/InvalidArchiveException.java @@ -1,22 +1,22 @@ /** - * ============LICENSE_START========================================== + * ============LICENSE_START======================================================= * org.onap.aai - * =================================================================== + * ================================================================================ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * =================================================================== + * Copyright © 2017-2018 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. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ============LICENSE_END============================================ + * ============LICENSE_END========================================================= */ package org.onap.aai.modelloader.extraction; diff --git a/src/main/java/org/onap/aai/modelloader/notification/ArtifactDeploymentManager.java b/src/main/java/org/onap/aai/modelloader/notification/ArtifactDeploymentManager.java index 6d75306..ca17261 100644 --- a/src/main/java/org/onap/aai/modelloader/notification/ArtifactDeploymentManager.java +++ b/src/main/java/org/onap/aai/modelloader/notification/ArtifactDeploymentManager.java @@ -1,22 +1,22 @@ /** - * ============LICENSE_START========================================== + * ============LICENSE_START======================================================= * org.onap.aai - * =================================================================== + * ================================================================================ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * =================================================================== + * Copyright © 2017-2018 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. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ============LICENSE_END============================================ + * ============LICENSE_END========================================================= */ package org.onap.aai.modelloader.notification; @@ -27,9 +27,9 @@ import org.onap.aai.modelloader.entity.Artifact; import org.onap.aai.modelloader.entity.catalog.VnfCatalogArtifactHandler; import org.onap.aai.modelloader.entity.model.ModelArtifactHandler; import org.onap.aai.modelloader.restclient.AaiRestClient; -import org.openecomp.sdc.api.IDistributionClient; -import org.openecomp.sdc.api.notification.IArtifactInfo; -import org.openecomp.sdc.api.notification.INotificationData; +import org.onap.sdc.api.IDistributionClient; +import org.onap.sdc.api.notification.IArtifactInfo; +import org.onap.sdc.api.notification.INotificationData; /** * This class is responsible for deploying model and catalog artifacts. diff --git a/src/main/java/org/onap/aai/modelloader/notification/ArtifactDownloadManager.java b/src/main/java/org/onap/aai/modelloader/notification/ArtifactDownloadManager.java index 3fa0b40..9dbe397 100644 --- a/src/main/java/org/onap/aai/modelloader/notification/ArtifactDownloadManager.java +++ b/src/main/java/org/onap/aai/modelloader/notification/ArtifactDownloadManager.java @@ -1,22 +1,22 @@ /** - * ============LICENSE_START========================================== + * ============LICENSE_START======================================================= * org.onap.aai - * =================================================================== + * ================================================================================ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * =================================================================== + * Copyright © 2017-2018 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. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ============LICENSE_END============================================ + * ============LICENSE_END========================================================= */ package org.onap.aai.modelloader.notification; @@ -41,12 +41,12 @@ import org.onap.aai.modelloader.extraction.InvalidArchiveException; import org.onap.aai.modelloader.restclient.BabelServiceClient; import org.onap.aai.modelloader.restclient.BabelServiceClientFactory; import org.onap.aai.modelloader.service.ModelLoaderMsgs; -import org.openecomp.sdc.api.IDistributionClient; -import org.openecomp.sdc.api.notification.IArtifactInfo; -import org.openecomp.sdc.api.notification.INotificationData; -import org.openecomp.sdc.api.results.IDistributionClientDownloadResult; -import org.openecomp.sdc.utils.ArtifactTypeEnum; -import org.openecomp.sdc.utils.DistributionActionResultEnum; +import org.onap.sdc.api.IDistributionClient; +import org.onap.sdc.api.notification.IArtifactInfo; +import org.onap.sdc.api.notification.INotificationData; +import org.onap.sdc.api.results.IDistributionClientDownloadResult; +import org.onap.sdc.utils.ArtifactTypeEnum; +import org.onap.sdc.utils.DistributionActionResultEnum; /** * This class is responsible for downloading the artifacts from the ASDC. diff --git a/src/main/java/org/onap/aai/modelloader/notification/BabelArtifactConverter.java b/src/main/java/org/onap/aai/modelloader/notification/BabelArtifactConverter.java index 7eb562a..ad4eb7d 100644 --- a/src/main/java/org/onap/aai/modelloader/notification/BabelArtifactConverter.java +++ b/src/main/java/org/onap/aai/modelloader/notification/BabelArtifactConverter.java @@ -1,22 +1,22 @@ /** - * ============LICENSE_START========================================== + * ============LICENSE_START======================================================= * org.onap.aai - * =================================================================== + * ================================================================================ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * =================================================================== + * Copyright © 2017-2018 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. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ============LICENSE_END============================================ + * ============LICENSE_END========================================================= */ package org.onap.aai.modelloader.notification; diff --git a/src/main/java/org/onap/aai/modelloader/notification/BasicStatusMsg.java b/src/main/java/org/onap/aai/modelloader/notification/BasicStatusMsg.java new file mode 100644 index 0000000..03f521e --- /dev/null +++ b/src/main/java/org/onap/aai/modelloader/notification/BasicStatusMsg.java @@ -0,0 +1,57 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright © 2017-2018 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.aai.modelloader.notification; + +import org.onap.sdc.api.consumer.IDistributionStatusMessageBasic; +import org.onap.sdc.utils.DistributionStatusEnum; + +public class BasicStatusMsg implements IDistributionStatusMessageBasic { + + private static final String COMPONENT_NAME = "AAI"; + protected DistributionStatusEnum status; + protected String distributionId; + protected String consumerId; + + @Override + public long getTimestamp() { + return System.currentTimeMillis(); + } + + @Override + public DistributionStatusEnum getStatus() { + return status; + } + + @Override + public String getDistributionID() { + return distributionId; + } + + @Override + public String getConsumerID() { + return consumerId; + } + + public String getComponentName() { + return COMPONENT_NAME; + } + +} diff --git a/src/main/java/org/onap/aai/modelloader/notification/CompDoneStatusMessageBuilder.java b/src/main/java/org/onap/aai/modelloader/notification/CompDoneStatusMessageBuilder.java index 5660ad0..c389945 100644 --- a/src/main/java/org/onap/aai/modelloader/notification/CompDoneStatusMessageBuilder.java +++ b/src/main/java/org/onap/aai/modelloader/notification/CompDoneStatusMessageBuilder.java @@ -1,29 +1,29 @@ /** - * ============LICENSE_START========================================== + * ============LICENSE_START======================================================= * org.onap.aai - * =================================================================== + * ================================================================================ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * =================================================================== + * Copyright © 2017-2018 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. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ============LICENSE_END============================================ + * ============LICENSE_END========================================================= */ package org.onap.aai.modelloader.notification; -import org.openecomp.sdc.api.IDistributionClient; -import org.openecomp.sdc.api.consumer.IComponentDoneStatusMessage; -import org.openecomp.sdc.api.notification.INotificationData; -import org.openecomp.sdc.utils.DistributionStatusEnum; +import org.onap.sdc.api.IDistributionClient; +import org.onap.sdc.api.consumer.IComponentDoneStatusMessage; +import org.onap.sdc.api.notification.INotificationData; +import org.onap.sdc.utils.DistributionStatusEnum; /** * This class is responsible for building an instance of {@link DistributionStatusMsg}. @@ -33,15 +33,16 @@ public class CompDoneStatusMessageBuilder { private CompDoneStatusMessageBuilder() {} /** - * Builds an instance of {@link CompDoneStatusMsg} from the given parameters about the status of the - * distribution of the given artifact. + * Builds an instance of {@link CompDoneStatusMsg} from the given parameters about the status of the distribution of + * the given artifact. * * @param client the distribution client this message pertains to * @param data data about the notification that resulted in this message being created * @param status the status of the distribution of the artifact to be reported * @return IComponentDoneStatusMessage implementation of IComponentDoneStatusMessage from the given parameters */ - public static IComponentDoneStatusMessage build(IDistributionClient client, INotificationData data, DistributionStatusEnum status) { + public static IComponentDoneStatusMessage build(IDistributionClient client, INotificationData data, + DistributionStatusEnum status) { return new CompDoneStatusMsg(status, data.getDistributionID(), client.getConfiguration().getConsumerID()); } } diff --git a/src/main/java/org/onap/aai/modelloader/notification/CompDoneStatusMsg.java b/src/main/java/org/onap/aai/modelloader/notification/CompDoneStatusMsg.java index db358f3..422052a 100644 --- a/src/main/java/org/onap/aai/modelloader/notification/CompDoneStatusMsg.java +++ b/src/main/java/org/onap/aai/modelloader/notification/CompDoneStatusMsg.java @@ -1,36 +1,32 @@ /** - * ============LICENSE_START========================================== + * ============LICENSE_START======================================================= * org.onap.aai - * =================================================================== + * ================================================================================ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * =================================================================== + * Copyright © 2017-2018 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. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ============LICENSE_END============================================ + * ============LICENSE_END========================================================= */ package org.onap.aai.modelloader.notification; -import org.openecomp.sdc.api.consumer.IComponentDoneStatusMessage; -import org.openecomp.sdc.utils.DistributionStatusEnum; +import org.onap.sdc.api.consumer.IComponentDoneStatusMessage; +import org.onap.sdc.utils.DistributionStatusEnum; -public class CompDoneStatusMsg implements IComponentDoneStatusMessage { - - private DistributionStatusEnum status; - private String distributionId; - private String consumerId; +public class CompDoneStatusMsg extends BasicStatusMsg implements IComponentDoneStatusMessage { /** - * Creates a new DistributionStatusMsg instance. + * Creates a new Component Done Status Message instance. * * @param status - The distribution status to be reported. * @param distributionId - The identifier of the distribution who's status is being rported on. @@ -41,29 +37,4 @@ public class CompDoneStatusMsg implements IComponentDoneStatusMessage { this.distributionId = distributionId; this.consumerId = consumerId; } - - @Override - public long getTimestamp() { - return System.currentTimeMillis(); - } - - @Override - public DistributionStatusEnum getStatus() { - return status; - } - - @Override - public String getDistributionID() { - return distributionId; - } - - @Override - public String getConsumerID() { - return consumerId; - } - - @Override - public String getComponentName() { - return "AAI"; - } } diff --git a/src/main/java/org/onap/aai/modelloader/notification/DistributionStatusMessageBuilder.java b/src/main/java/org/onap/aai/modelloader/notification/DistributionStatusMessageBuilder.java index fcfd81c..91cd3de 100644 --- a/src/main/java/org/onap/aai/modelloader/notification/DistributionStatusMessageBuilder.java +++ b/src/main/java/org/onap/aai/modelloader/notification/DistributionStatusMessageBuilder.java @@ -1,30 +1,30 @@ /** - * ============LICENSE_START========================================== + * ============LICENSE_START======================================================= * org.onap.aai - * =================================================================== + * ================================================================================ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * =================================================================== + * Copyright © 2017-2018 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. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ============LICENSE_END============================================ + * ============LICENSE_END========================================================= */ package org.onap.aai.modelloader.notification; -import org.openecomp.sdc.api.IDistributionClient; -import org.openecomp.sdc.api.consumer.IDistributionStatusMessage; -import org.openecomp.sdc.api.notification.IArtifactInfo; -import org.openecomp.sdc.api.notification.INotificationData; -import org.openecomp.sdc.utils.DistributionStatusEnum; +import org.onap.sdc.api.IDistributionClient; +import org.onap.sdc.api.consumer.IDistributionStatusMessage; +import org.onap.sdc.api.notification.IArtifactInfo; +import org.onap.sdc.api.notification.INotificationData; +import org.onap.sdc.utils.DistributionStatusEnum; /** * This class is responsible for building an instance of {@link DistributionStatusMsg}. @@ -58,9 +58,9 @@ public class DistributionStatusMessageBuilder { * @param status the status of the distribution of the artifact to be reported * @return IDistributionStatusMessage implementation of IDistributionStatusMsg from the given parameters */ - public static IDistributionStatusMessage build(IDistributionClient client, - INotificationData data, DistributionStatusEnum status) { - return new DistributionStatusMsg(status, data.getDistributionID(), - client.getConfiguration().getConsumerID(), ""); + public static IDistributionStatusMessage build(IDistributionClient client, INotificationData data, + DistributionStatusEnum status) { + return new DistributionStatusMsg(status, data.getDistributionID(), client.getConfiguration().getConsumerID(), + ""); } } diff --git a/src/main/java/org/onap/aai/modelloader/notification/DistributionStatusMsg.java b/src/main/java/org/onap/aai/modelloader/notification/DistributionStatusMsg.java index cc9fb0b..0a2d6a9 100644 --- a/src/main/java/org/onap/aai/modelloader/notification/DistributionStatusMsg.java +++ b/src/main/java/org/onap/aai/modelloader/notification/DistributionStatusMsg.java @@ -1,73 +1,50 @@ -/**
- * ============LICENSE_START==========================================
- * org.onap.aai
- * ===================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ===================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- */
-package org.onap.aai.modelloader.notification;
-
-import org.openecomp.sdc.api.consumer.IDistributionStatusMessage;
-import org.openecomp.sdc.utils.DistributionStatusEnum;
-
-public class DistributionStatusMsg implements IDistributionStatusMessage {
-
- private DistributionStatusEnum status;
- private String distributionId;
- private String consumerId;
- private String artifactUrl;
-
- /**
- * Creates a new DistributionStatusMsg instance.
- *
- * @param status - The distribution status to be reported.
- * @param distributionId - The identifier of the distribution who's status is being rported on.
- * @param consumerId - Identifier of the consumer associated with the distribution.
- * @param artifactUrl - Resource identifier for the artifact.
- */
- public DistributionStatusMsg(DistributionStatusEnum status, String distributionId, String consumerId,
- String artifactUrl) {
- this.status = status;
- this.distributionId = distributionId;
- this.consumerId = consumerId;
- this.artifactUrl = artifactUrl;
- }
-
- @Override
- public long getTimestamp() {
- return System.currentTimeMillis();
- }
-
- @Override
- public DistributionStatusEnum getStatus() {
- return status;
- }
-
- @Override
- public String getDistributionID() {
- return distributionId;
- }
-
- @Override
- public String getConsumerID() {
- return consumerId;
- }
-
- @Override
- public String getArtifactURL() {
- return artifactUrl;
- }
-}
+/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright © 2017-2018 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.aai.modelloader.notification; + +import org.onap.sdc.api.consumer.IDistributionStatusMessage; +import org.onap.sdc.utils.DistributionStatusEnum; + +public class DistributionStatusMsg extends BasicStatusMsg implements IDistributionStatusMessage { + + private String artifactUrl; + + /** + * Creates a new Distribution Status Message instance. + * + * @param status - The distribution status to be reported. + * @param distributionId - The identifier of the distribution who's status is being rported on. + * @param consumerId - Identifier of the consumer associated with the distribution. + * @param artifactUrl - Resource identifier for the artifact. + */ + public DistributionStatusMsg(DistributionStatusEnum status, String distributionId, String consumerId, + String artifactUrl) { + this.status = status; + this.distributionId = distributionId; + this.consumerId = consumerId; + this.artifactUrl = artifactUrl; + } + + @Override + public String getArtifactURL() { + return artifactUrl; + } +} diff --git a/src/main/java/org/onap/aai/modelloader/notification/DownloadFailureException.java b/src/main/java/org/onap/aai/modelloader/notification/DownloadFailureException.java index 73a191a..d39330f 100644 --- a/src/main/java/org/onap/aai/modelloader/notification/DownloadFailureException.java +++ b/src/main/java/org/onap/aai/modelloader/notification/DownloadFailureException.java @@ -1,22 +1,22 @@ /** - * ============LICENSE_START========================================== + * ============LICENSE_START======================================================= * org.onap.aai - * =================================================================== + * ================================================================================ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * =================================================================== + * Copyright © 2017-2018 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. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ============LICENSE_END============================================ + * ============LICENSE_END========================================================= */ package org.onap.aai.modelloader.notification; diff --git a/src/main/java/org/onap/aai/modelloader/notification/EventCallback.java b/src/main/java/org/onap/aai/modelloader/notification/EventCallback.java index fe6bf7b..2baa217 100644 --- a/src/main/java/org/onap/aai/modelloader/notification/EventCallback.java +++ b/src/main/java/org/onap/aai/modelloader/notification/EventCallback.java @@ -1,22 +1,22 @@ /** - * ============LICENSE_START========================================== + * ============LICENSE_START======================================================= * org.onap.aai - * =================================================================== + * ================================================================================ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * =================================================================== + * Copyright © 2017-2018 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. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ============LICENSE_END============================================ + * ============LICENSE_END========================================================= */ package org.onap.aai.modelloader.notification; @@ -30,10 +30,10 @@ import org.onap.aai.modelloader.entity.Artifact; import org.onap.aai.modelloader.extraction.ArtifactInfoExtractor; import org.onap.aai.modelloader.restclient.BabelServiceClientFactory; import org.onap.aai.modelloader.service.ModelLoaderMsgs; -import org.openecomp.sdc.api.IDistributionClient; -import org.openecomp.sdc.api.consumer.INotificationCallback; -import org.openecomp.sdc.api.notification.IArtifactInfo; -import org.openecomp.sdc.api.notification.INotificationData; +import org.onap.sdc.api.IDistributionClient; +import org.onap.sdc.api.consumer.INotificationCallback; +import org.onap.sdc.api.notification.IArtifactInfo; +import org.onap.sdc.api.notification.INotificationData; import org.slf4j.MDC; public class EventCallback implements INotificationCallback { @@ -76,6 +76,7 @@ public class EventCallback implements INotificationCallback { if (artifactDeploymentManager == null) { artifactDeploymentManager = new ArtifactDeploymentManager(client, config); } + return artifactDeploymentManager; } diff --git a/src/main/java/org/onap/aai/modelloader/notification/NotificationPublisher.java b/src/main/java/org/onap/aai/modelloader/notification/NotificationPublisher.java index 447e817..967a290 100644 --- a/src/main/java/org/onap/aai/modelloader/notification/NotificationPublisher.java +++ b/src/main/java/org/onap/aai/modelloader/notification/NotificationPublisher.java @@ -1,22 +1,22 @@ /** - * ============LICENSE_START========================================== + * ============LICENSE_START======================================================= * org.onap.aai - * =================================================================== + * ================================================================================ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * =================================================================== + * Copyright © 2017-2018 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. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ============LICENSE_END============================================ + * ============LICENSE_END========================================================= */ package org.onap.aai.modelloader.notification; @@ -31,12 +31,12 @@ import org.onap.aai.cl.mdc.MdcContext; import org.onap.aai.cl.mdc.MdcOverride; import org.onap.aai.modelloader.config.ModelLoaderConfig; import org.onap.aai.modelloader.service.ModelLoaderMsgs; -import org.openecomp.sdc.api.IDistributionClient; -import org.openecomp.sdc.api.notification.IArtifactInfo; -import org.openecomp.sdc.api.notification.INotificationData; -import org.openecomp.sdc.api.results.IDistributionClientResult; -import org.openecomp.sdc.utils.DistributionActionResultEnum; -import org.openecomp.sdc.utils.DistributionStatusEnum; +import org.onap.sdc.api.IDistributionClient; +import org.onap.sdc.api.notification.IArtifactInfo; +import org.onap.sdc.api.notification.INotificationData; +import org.onap.sdc.api.results.IDistributionClientResult; +import org.onap.sdc.utils.DistributionActionResultEnum; +import org.onap.sdc.utils.DistributionStatusEnum; /** * This class is responsible for publishing the status of actions performed working with artifacts. @@ -46,24 +46,18 @@ class NotificationPublisher { private static Logger logger = LoggerFactory.getInstance().getLogger(NotificationPublisher.class); private static Logger metricsLogger = LoggerFactory.getInstance().getMetricsLogger(NotificationPublisher.class); - protected static final String FILESEP = - (System.getProperty("file.separator") == null) ? "/" : System.getProperty("file.separator"); - protected static final String CONFIG_DIR = System.getProperty("CONFIG_HOME") + FILESEP; - protected static final String CONFIG_AUTH_LOCATION = CONFIG_DIR + "auth" + FILESEP; - protected static final String CONFIG_FILE = CONFIG_DIR + "model-loader.properties"; - private boolean publishingEnabled; public NotificationPublisher() { Properties configProperties = new Properties(); try { - configProperties.load(new FileInputStream(CONFIG_FILE)); + configProperties.load(new FileInputStream(ModelLoaderConfig.propertiesFile())); } catch (IOException e) { String errorMsg = "Failed to load configuration: " + e.getMessage(); logger.error(ModelLoaderMsgs.DISTRIBUTION_EVENT_ERROR, e, errorMsg); } - ModelLoaderConfig config = new ModelLoaderConfig(configProperties, CONFIG_AUTH_LOCATION); + ModelLoaderConfig config = new ModelLoaderConfig(configProperties); publishingEnabled = !config.getASDCConnectionDisabled(); } diff --git a/src/main/java/org/onap/aai/modelloader/notification/ProcessToscaArtifactsException.java b/src/main/java/org/onap/aai/modelloader/notification/ProcessToscaArtifactsException.java index 6678af6..0d082c1 100644 --- a/src/main/java/org/onap/aai/modelloader/notification/ProcessToscaArtifactsException.java +++ b/src/main/java/org/onap/aai/modelloader/notification/ProcessToscaArtifactsException.java @@ -1,22 +1,22 @@ /** - * ============LICENSE_START========================================== + * ============LICENSE_START======================================================= * org.onap.aai - * =================================================================== + * ================================================================================ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * =================================================================== + * Copyright © 2017-2018 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. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ============LICENSE_END============================================ + * ============LICENSE_END========================================================= */ package org.onap.aai.modelloader.notification; diff --git a/src/main/java/org/onap/aai/modelloader/restclient/AaiRestClient.java b/src/main/java/org/onap/aai/modelloader/restclient/AaiRestClient.java index 28cd671..5576ea9 100644 --- a/src/main/java/org/onap/aai/modelloader/restclient/AaiRestClient.java +++ b/src/main/java/org/onap/aai/modelloader/restclient/AaiRestClient.java @@ -1,22 +1,22 @@ /** - * ============LICENSE_START========================================== + * ============LICENSE_START======================================================= * org.onap.aai - * =================================================================== + * ================================================================================ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * =================================================================== + * Copyright © 2017-2018 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. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ============LICENSE_END============================================ + * ============LICENSE_END========================================================= */ package org.onap.aai.modelloader.restclient; diff --git a/src/main/java/org/onap/aai/modelloader/restclient/BabelServiceClient.java b/src/main/java/org/onap/aai/modelloader/restclient/BabelServiceClient.java index a861580..fa677a9 100644 --- a/src/main/java/org/onap/aai/modelloader/restclient/BabelServiceClient.java +++ b/src/main/java/org/onap/aai/modelloader/restclient/BabelServiceClient.java @@ -1,22 +1,22 @@ /** - * ============LICENSE_START========================================== + * ============LICENSE_START======================================================= * org.onap.aai - * =================================================================== + * ================================================================================ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * =================================================================== + * Copyright © 2017-2018 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. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ============LICENSE_END============================================ + * ============LICENSE_END========================================================= */ package org.onap.aai.modelloader.restclient; @@ -173,7 +173,8 @@ public class BabelServiceClient { .post(ClientResponse.class, obj.toString()); String sanitizedJson = JsonSanitizer.sanitize(response.getEntity(String.class)); - logger.debug(ModelLoaderMsgs.DISTRIBUTION_EVENT, "Babel response " + response.getStatus() + " " + sanitizedJson); + logger.debug(ModelLoaderMsgs.DISTRIBUTION_EVENT, + "Babel response " + response.getStatus() + " " + sanitizedJson); if (response.getStatus() != Response.Status.OK.getStatusCode()) { throw new BabelServiceException(sanitizedJson); diff --git a/src/main/java/org/onap/aai/modelloader/restclient/BabelServiceClientFactory.java b/src/main/java/org/onap/aai/modelloader/restclient/BabelServiceClientFactory.java index 6ce4a60..4354710 100644 --- a/src/main/java/org/onap/aai/modelloader/restclient/BabelServiceClientFactory.java +++ b/src/main/java/org/onap/aai/modelloader/restclient/BabelServiceClientFactory.java @@ -1,22 +1,22 @@ /** - * ============LICENSE_START========================================== + * ============LICENSE_START======================================================= * org.onap.aai - * =================================================================== + * ================================================================================ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * =================================================================== + * Copyright © 2017-2018 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. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ============LICENSE_END============================================ + * ============LICENSE_END========================================================= */ package org.onap.aai.modelloader.restclient; diff --git a/src/main/java/org/onap/aai/modelloader/service/ArtifactInfoImpl.java b/src/main/java/org/onap/aai/modelloader/service/ArtifactInfoImpl.java index e32d92c..9af92be 100644 --- a/src/main/java/org/onap/aai/modelloader/service/ArtifactInfoImpl.java +++ b/src/main/java/org/onap/aai/modelloader/service/ArtifactInfoImpl.java @@ -1,37 +1,38 @@ /** - * ============LICENSE_START========================================== + * ============LICENSE_START======================================================= * org.onap.aai - * =================================================================== + * ================================================================================ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * =================================================================== + * Copyright © 2017-2018 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. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ============LICENSE_END============================================ + * ============LICENSE_END========================================================= */ package org.onap.aai.modelloader.service; import java.util.Collections; -import org.openecomp.sdc.api.notification.IArtifactInfo; +import java.util.List; +import org.onap.sdc.api.notification.IArtifactInfo; /** * This class is an implementation of IArtifactInfo for test purposes. */ public class ArtifactInfoImpl implements IArtifactInfo { - private java.lang.String artifactName; - private java.lang.String artifactType; - private java.lang.String artifactDescription; - private java.lang.String artifactVersion; + private String artifactName; + private String artifactType; + private String artifactDescription; + private String artifactVersion; @Override public String getArtifactName() { @@ -95,7 +96,7 @@ public class ArtifactInfoImpl implements IArtifactInfo { } @Override - public java.util.List<org.openecomp.sdc.api.notification.IArtifactInfo> getRelatedArtifacts() { + public List<IArtifactInfo> getRelatedArtifacts() { return Collections.emptyList(); } diff --git a/src/main/java/org/onap/aai/modelloader/service/ModelLoaderApplication.java b/src/main/java/org/onap/aai/modelloader/service/ModelLoaderApplication.java new file mode 100644 index 0000000..c0eb5f2 --- /dev/null +++ b/src/main/java/org/onap/aai/modelloader/service/ModelLoaderApplication.java @@ -0,0 +1,37 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright © 2017-2018 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.aai.modelloader.service; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * Model Loader Spring Boot Application. + */ + +@SpringBootApplication +public class ModelLoaderApplication { + + public static void main(String[] args) { + SpringApplication.run(ModelLoaderApplication.class, args); + } + +} diff --git a/src/main/java/org/onap/aai/modelloader/service/ModelLoaderInterface.java b/src/main/java/org/onap/aai/modelloader/service/ModelLoaderInterface.java index 1b466c8..6796090 100644 --- a/src/main/java/org/onap/aai/modelloader/service/ModelLoaderInterface.java +++ b/src/main/java/org/onap/aai/modelloader/service/ModelLoaderInterface.java @@ -1,49 +1,45 @@ -/**
- * ============LICENSE_START==========================================
- * org.onap.aai
- * ===================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ===================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- */
-package org.onap.aai.modelloader.service;
-
-import java.io.IOException;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.Response;
-
-public interface ModelLoaderInterface {
-
- @GET
- @Path("/loadModel/{modelid}")
- public Response loadModel(@PathParam("modelid") String modelid);
-
- @PUT
- @Path("/saveModel/{modelid}/{modelname}")
- public Response saveModel(@PathParam("modelid") String modelid, @PathParam("modelname") String modelname);
-
- @POST
- @Consumes("text/plain")
- @Produces("application/xml")
- @Path("/ingestModel/{modelName}/{modelVersion}")
- public Response ingestModel(@PathParam("modelName") String modelid, @PathParam("modelVersion") String modelVersion,
- String payload) throws IOException;
-}
+/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright © 2017-2018 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.aai.modelloader.service; + +import java.io.IOException; +import javax.ws.rs.core.Response; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; + +public interface ModelLoaderInterface { + + @RequestMapping(value = "/loadModel/{modelid}", // + method = RequestMethod.GET, produces = "application/json") + @ResponseBody + public Response loadModel(String modelid); + + @RequestMapping(value = "/saveModel/{modelid}/{modelname}", // + method = RequestMethod.PUT, produces = "application/json") + @ResponseBody + public Response saveModel(String modelid, String modelname); + + @RequestMapping(value = "/ingestModel/{modelName}/{modelVersion}", // + method = RequestMethod.POST, produces = "application/json") + @ResponseBody + public Response ingestModel(String modelid, String modelVersion, String payload) throws IOException; +} diff --git a/src/main/java/org/onap/aai/modelloader/service/ModelLoaderMsgs.java b/src/main/java/org/onap/aai/modelloader/service/ModelLoaderMsgs.java index c5f00c0..fd39a9a 100644 --- a/src/main/java/org/onap/aai/modelloader/service/ModelLoaderMsgs.java +++ b/src/main/java/org/onap/aai/modelloader/service/ModelLoaderMsgs.java @@ -1,22 +1,22 @@ /**
- * ============LICENSE_START==========================================
+ * ============LICENSE_START=======================================================
* org.onap.aai
- * ===================================================================
+ * ================================================================================
* Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ===================================================================
+ * Copyright © 2017-2018 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.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- * ============LICENSE_END============================================
+ * ============LICENSE_END=========================================================
*/
package org.onap.aai.modelloader.service;
@@ -74,7 +74,7 @@ public enum ModelLoaderMsgs implements LogMessageEnum { * Arguments: {0} = request type. {1} = endpoint. {2} = error message.
*/
BABEL_REST_REQUEST_ERROR,
-
+
/**
* Arguments: {0} = info request payload.
**/
diff --git a/src/main/java/org/onap/aai/modelloader/service/ModelLoaderService.java b/src/main/java/org/onap/aai/modelloader/service/ModelLoaderService.java index a4cc5d1..06d6e30 100644 --- a/src/main/java/org/onap/aai/modelloader/service/ModelLoaderService.java +++ b/src/main/java/org/onap/aai/modelloader/service/ModelLoaderService.java @@ -1,22 +1,22 @@ /** - * ============LICENSE_START========================================== + * ============LICENSE_START======================================================= * org.onap.aai - * =================================================================== + * ================================================================================ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * =================================================================== + * Copyright © 2017-2018 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. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ============LICENSE_END============================================ + * ============LICENSE_END========================================================= */ package org.onap.aai.modelloader.service; @@ -29,9 +29,8 @@ import java.util.List; import java.util.Properties; import java.util.Timer; import java.util.TimerTask; - +import javax.annotation.PostConstruct; import javax.ws.rs.core.Response; - import org.onap.aai.cl.api.Logger; import org.onap.aai.cl.eelf.LoggerFactory; import org.onap.aai.modelloader.config.ModelLoaderConfig; @@ -40,53 +39,54 @@ import org.onap.aai.modelloader.notification.ArtifactDeploymentManager; import org.onap.aai.modelloader.notification.ArtifactDownloadManager; import org.onap.aai.modelloader.notification.EventCallback; import org.onap.aai.modelloader.restclient.BabelServiceClientFactory; -import org.openecomp.sdc.api.IDistributionClient; -import org.openecomp.sdc.api.notification.IArtifactInfo; -import org.openecomp.sdc.api.notification.INotificationData; -import org.openecomp.sdc.api.results.IDistributionClientResult; -import org.openecomp.sdc.impl.DistributionClientFactory; -import org.openecomp.sdc.utils.DistributionActionResultEnum; +import org.onap.sdc.api.IDistributionClient; +import org.onap.sdc.api.notification.IArtifactInfo; +import org.onap.sdc.api.notification.INotificationData; +import org.onap.sdc.api.results.IDistributionClientResult; +import org.onap.sdc.impl.DistributionClientFactory; +import org.onap.sdc.utils.DistributionActionResultEnum; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; /** * Service class in charge of managing the negotiating model loading capabilities between AAI and an ASDC. */ +@RestController +@RequestMapping("/services/model-loader/v1/model-service") public class ModelLoaderService implements ModelLoaderInterface { + static Logger logger = LoggerFactory.getInstance().getLogger(ModelLoaderService.class.getName()); + protected static final String FILESEP = (System.getProperty("file.separator") == null) ? "/" : System.getProperty("file.separator"); - protected static final String CONFIG_DIR = System.getProperty("CONFIG_HOME") + FILESEP; - protected static final String CONFIG_AUTH_LOCATION = CONFIG_DIR + "auth" + FILESEP; - protected static final String CONFIG_FILE = CONFIG_DIR + "model-loader.properties"; - + @Value("${CONFIG_HOME}") + private String configDir; private IDistributionClient client; private ModelLoaderConfig config; - static Logger logger = LoggerFactory.getInstance().getLogger(ModelLoaderService.class.getName()); - /** * Responsible for loading configuration files and calling initialization. */ - public ModelLoaderService() { - start(); - } - + @PostConstruct protected void start() { // Load model loader system configuration logger.info(ModelLoaderMsgs.LOADING_CONFIGURATION); + ModelLoaderConfig.setConfigHome(configDir); Properties configProperties = new Properties(); try { - configProperties.load(new FileInputStream(CONFIG_FILE)); + configProperties.load(new FileInputStream(configDir + FILESEP + "model-loader.properties")); + config = new ModelLoaderConfig(configProperties); + if (!config.getASDCConnectionDisabled()) { + initSdcClient(); + } } catch (IOException e) { String errorMsg = "Failed to load configuration: " + e.getMessage(); logger.error(ModelLoaderMsgs.ASDC_CONNECTION_ERROR, errorMsg); - shutdown(); } - - config = new ModelLoaderConfig(configProperties, CONFIG_AUTH_LOCATION); - init(); - - Runtime.getRuntime().addShutdownHook(new Thread(this::preShutdownOperations)); } /** @@ -102,18 +102,28 @@ public class ModelLoaderService implements ModelLoaderInterface { /** * Responsible for loading configuration files, initializing model distribution clients, and starting them. */ - protected void init() { - if (!config.getASDCConnectionDisabled()) { - // Initialize distribution client - logger.debug(ModelLoaderMsgs.INITIALIZING, "Initializing distribution client..."); - client = DistributionClientFactory.createDistributionClient(); - EventCallback callback = new EventCallback(client, config); - - IDistributionClientResult initResult = client.init(config, callback); - - if (initResult.getDistributionActionResult() != DistributionActionResultEnum.SUCCESS) { - String errorMsg = - "Failed to initialize distribution client: " + initResult.getDistributionMessageResult(); + protected void initSdcClient() { + // Initialize distribution client + logger.debug(ModelLoaderMsgs.INITIALIZING, "Initializing distribution client..."); + client = DistributionClientFactory.createDistributionClient(); + EventCallback callback = new EventCallback(client, config); + + IDistributionClientResult initResult = client.init(config, callback); + + if (initResult.getDistributionActionResult() != DistributionActionResultEnum.SUCCESS) { + String errorMsg = "Failed to initialize distribution client: " + initResult.getDistributionMessageResult(); + logger.error(ModelLoaderMsgs.ASDC_CONNECTION_ERROR, errorMsg); + + // Kick off a timer to retry the SDC connection + Timer timer = new Timer(); + TimerTask task = new SdcConnectionJob(client, config, callback, timer); + timer.schedule(task, new Date(), 60000); + } else { + // Start distribution client + logger.debug(ModelLoaderMsgs.INITIALIZING, "Starting distribution client..."); + IDistributionClientResult startResult = client.start(); + if (startResult.getDistributionActionResult() != DistributionActionResultEnum.SUCCESS) { + String errorMsg = "Failed to start distribution client: " + startResult.getDistributionMessageResult(); logger.error(ModelLoaderMsgs.ASDC_CONNECTION_ERROR, errorMsg); // Kick off a timer to retry the SDC connection @@ -121,41 +131,10 @@ public class ModelLoaderService implements ModelLoaderInterface { TimerTask task = new SdcConnectionJob(client, config, callback, timer); timer.schedule(task, new Date(), 60000); } else { - // Start distribution client - logger.debug(ModelLoaderMsgs.INITIALIZING, "Starting distribution client..."); - IDistributionClientResult startResult = client.start(); - if (startResult.getDistributionActionResult() != DistributionActionResultEnum.SUCCESS) { - String errorMsg = - "Failed to start distribution client: " + startResult.getDistributionMessageResult(); - logger.error(ModelLoaderMsgs.ASDC_CONNECTION_ERROR, errorMsg); - - // Kick off a timer to retry the SDC connection - Timer timer = new Timer(); - TimerTask task = new SdcConnectionJob(client, config, callback, timer); - timer.schedule(task, new Date(), 60000); - } else { - logger.info(ModelLoaderMsgs.INITIALIZING, "Connection to SDC established"); - } + logger.info(ModelLoaderMsgs.INITIALIZING, "Connection to SDC established"); } } - } - - /** - * Shut down the process. - */ - private void shutdown() { - preShutdownOperations(); - - // TODO: Find a better way to shut down the model loader. - try { - // Give logs time to write to file - Thread.sleep(2000); - } catch (InterruptedException e) { // NOSONAR - // Nothing we can do at this point - logger.debug(e.getMessage()); - } - - Runtime.getRuntime().halt(1); + Runtime.getRuntime().addShutdownHook(new Thread(this::preShutdownOperations)); } /** @@ -164,7 +143,7 @@ public class ModelLoaderService implements ModelLoaderInterface { * @see org.onap.aai.modelloader.service.ModelLoaderInterface#loadModel(java.lang.String) */ @Override - public Response loadModel(String modelid) { + public Response loadModel(@PathVariable String modelid) { return Response.ok("{\"model_loaded\":\"" + modelid + "\"}").build(); } @@ -174,12 +153,13 @@ public class ModelLoaderService implements ModelLoaderInterface { * @see org.onap.aai.modelloader.service.ModelLoaderInterface#saveModel(java.lang.String, java.lang.String) */ @Override - public Response saveModel(String modelid, String modelname) { + public Response saveModel(@PathVariable String modelid, @PathVariable String modelname) { return Response.ok("{\"model_saved\":\"" + modelid + "-" + modelname + "\"}").build(); } @Override - public Response ingestModel(String modelName, String modelVersion, String payload) throws IOException { + public Response ingestModel(@PathVariable String modelName, @PathVariable String modelVersion, + @RequestBody String payload) throws IOException { boolean success; if (config.getIngestSimulatorEnabled()) { diff --git a/src/main/java/org/onap/aai/modelloader/service/NotificationDataImpl.java b/src/main/java/org/onap/aai/modelloader/service/NotificationDataImpl.java index 28611ff..536aa4a 100644 --- a/src/main/java/org/onap/aai/modelloader/service/NotificationDataImpl.java +++ b/src/main/java/org/onap/aai/modelloader/service/NotificationDataImpl.java @@ -1,30 +1,30 @@ /** - * ============LICENSE_START========================================== + * ============LICENSE_START======================================================= * org.onap.aai - * =================================================================== + * ================================================================================ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * =================================================================== + * Copyright © 2017-2018 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. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ============LICENSE_END============================================ + * ============LICENSE_END========================================================= */ package org.onap.aai.modelloader.service; import java.util.Collections; import java.util.List; -import org.openecomp.sdc.api.notification.IArtifactInfo; -import org.openecomp.sdc.api.notification.INotificationData; -import org.openecomp.sdc.api.notification.IResourceInstance; +import org.onap.sdc.api.notification.IArtifactInfo; +import org.onap.sdc.api.notification.INotificationData; +import org.onap.sdc.api.notification.IResourceInstance; public class NotificationDataImpl implements INotificationData { diff --git a/src/main/java/org/onap/aai/modelloader/service/SdcConnectionJob.java b/src/main/java/org/onap/aai/modelloader/service/SdcConnectionJob.java index d30e6dd..82e0bc6 100644 --- a/src/main/java/org/onap/aai/modelloader/service/SdcConnectionJob.java +++ b/src/main/java/org/onap/aai/modelloader/service/SdcConnectionJob.java @@ -1,22 +1,22 @@ /** - * ============LICENSE_START========================================== + * ============LICENSE_START======================================================= * org.onap.aai - * =================================================================== + * ================================================================================ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * =================================================================== + * Copyright © 2017-2018 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. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ============LICENSE_END============================================ + * ============LICENSE_END========================================================= */ package org.onap.aai.modelloader.service; @@ -26,9 +26,9 @@ import org.onap.aai.cl.api.Logger; import org.onap.aai.cl.eelf.LoggerFactory; import org.onap.aai.modelloader.config.ModelLoaderConfig; import org.onap.aai.modelloader.notification.EventCallback; -import org.openecomp.sdc.api.IDistributionClient; -import org.openecomp.sdc.api.results.IDistributionClientResult; -import org.openecomp.sdc.utils.DistributionActionResultEnum; +import org.onap.sdc.api.IDistributionClient; +import org.onap.sdc.api.results.IDistributionClientResult; +import org.onap.sdc.utils.DistributionActionResultEnum; public class SdcConnectionJob extends TimerTask { static Logger logger = LoggerFactory.getInstance().getLogger(SdcConnectionJob.class.getName()); diff --git a/src/main/java/org/onap/aai/modelloader/util/JsonXmlConverter.java b/src/main/java/org/onap/aai/modelloader/util/JsonXmlConverter.java index a5a7bc5..48a33b5 100644 --- a/src/main/java/org/onap/aai/modelloader/util/JsonXmlConverter.java +++ b/src/main/java/org/onap/aai/modelloader/util/JsonXmlConverter.java @@ -1,22 +1,22 @@ /**
- * ============LICENSE_START==========================================
+ * ============LICENSE_START=======================================================
* org.onap.aai
- * ===================================================================
+ * ================================================================================
* Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ===================================================================
+ * Copyright © 2017-2018 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.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- * ============LICENSE_END============================================
+ * ============LICENSE_END=========================================================
*/
package org.onap.aai.modelloader.util;
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties new file mode 100644 index 0000000..4ea6f0a --- /dev/null +++ b/src/main/resources/application.properties @@ -0,0 +1,20 @@ +# Note that the start.sh script sets the following System Properties +# We provide default values here for testing purposes +AJSC_HOME=. +CONFIG_HOME=appconfig-local +com.att.eelf.logging.path=src/main/resources +com.att.eelf.logging.file=logback.xml +logback.configurationFile=${com.att.eelf.logging.path}/${com.att.eelf.logging.file} + +server.port=9500 +#server.ssl.key-store= +#server.ssl.key-store-password= +#server.ssl.keyStoreType= +#server.ssl.keyAlias= + +server.tomcat.max-threads=200 +# The minimum number of threads always kept alive +server.tomcat.min-spare-threads=25 + +# Spring Boot logging +logging.config=${logback.configurationFile} diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml new file mode 100644 index 0000000..6b7c2c1 --- /dev/null +++ b/src/main/resources/logback.xml @@ -0,0 +1,151 @@ +<configuration scan="true" scanPeriod="3 seconds" debug="false"> + <property name="logDir" value="${AJSC_HOME}/logs" /> + <property name="componentName" value="AAI-ML"></property> + + <!-- default eelf log file names --> + <property name="generalLogName" value="error" /> + <property name="metricsLogName" value="metrics" /> + <property name="auditLogName" value="audit" /> + <property name="debugLogName" value="debug" /> + + <property name="errorLogPattern" + value="%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%mdc{RequestId}|%thread|ModelLoader|%mdc{PartnerName}|%logger||%.-5level|%msg%n" /> + <property name="auditMetricPattern" value="%m%n" /> + + <property name="logDirectory" value="${logDir}/${componentName}" /> + + <!-- Example evaluator filter applied against console appender --> + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <encoder> + <pattern>${defaultPattern}</pattern> + </encoder> + </appender> + + <!-- ============================================================================ --> + <!-- EELF Appenders --> + <!-- ============================================================================ --> + + <!-- The EELFAppender is used to record events to the general application + log --> + + <appender name="EELF" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <file>${logDirectory}/${generalLogName}.log</file> + <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> + <fileNamePattern>${logDirectory}/${generalLogName}.%d{yyyy-MM-dd}.log.zip</fileNamePattern> + <maxHistory>60</maxHistory> + </rollingPolicy> + <encoder> + <pattern>${errorLogPattern}</pattern> + </encoder> + </appender> + <appender name="asyncEELF" class="ch.qos.logback.classic.AsyncAppender"> + <!-- deny all events with a level below INFO, that is TRACE and DEBUG --> + <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> + <level>INFO</level> + </filter> + <queueSize>256</queueSize> + <appender-ref ref="EELF" /> + </appender> + + <appender name="EELFAudit" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <file>${logDirectory}/${auditLogName}.log</file> + <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> + <fileNamePattern>${logDirectory}/${auditLogName}.%d{yyyy-MM-dd}.log.zip</fileNamePattern> + <maxHistory>60</maxHistory> + </rollingPolicy> + <encoder> + <pattern>${auditMetricPattern}</pattern> + </encoder> + </appender> + <appender name="asyncEELFAudit" class="ch.qos.logback.classic.AsyncAppender"> + <queueSize>256</queueSize> + <appender-ref ref="EELFAudit" /> + </appender> + + <appender name="EELFMetrics" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <file>${logDirectory}/${metricsLogName}.log</file> + <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> + <fileNamePattern>${logDirectory}/${metricsLogName}.%d{yyyy-MM-dd}.log.zip</fileNamePattern> + <maxHistory>60</maxHistory> + </rollingPolicy> + <encoder> + <pattern>${auditMetricPattern}</pattern> + </encoder> + </appender> + <appender name="asyncEELFMetrics" class="ch.qos.logback.classic.AsyncAppender"> + <queueSize>256</queueSize> + <appender-ref ref="EELFMetrics" /> + </appender> + + <appender name="EELFDebug" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <file>${logDirectory}/${debugLogName}.log</file> + <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> + <fileNamePattern>${logDirectory}/${debugLogName}.%d{yyyy-MM-dd}.log.zip</fileNamePattern> + <maxHistory>60</maxHistory> + </rollingPolicy> + <encoder> + <pattern>${errorLogPattern}</pattern> + </encoder> + </appender> + <appender name="asyncEELFDebug" class="ch.qos.logback.classic.AsyncAppender"> + <queueSize>256</queueSize> + <appender-ref ref="EELFDebug" /> + <includeCallerData>true</includeCallerData> + </appender> + + <!-- ============================================================================ --> + <!-- EELF loggers --> + <!-- ============================================================================ --> + <logger name="com.att.eelf" level="info" additivity="false"> + <appender-ref ref="asyncEELF" /> + <appender-ref ref="asyncEELFDebug" /> + </logger> + <logger name="com.att.eelf.audit" level="info" additivity="false"> + <appender-ref ref="asyncEELFAudit" /> + </logger> + <logger name="com.att.eelf.metrics" level="info" additivity="false"> + <appender-ref ref="asyncEELFMetrics" /> + </logger> + + <!-- Spring related loggers --> + <logger name="org.springframework" level="WARN" /> + <logger name="org.springframework.beans" level="WARN" /> + <logger name="org.springframework.web" level="WARN" /> + <logger name="com.blog.spring.jms" level="WARN" /> + + <logger name="com.att" level="INFO" /> + + <!-- Model Loader loggers --> + <logger name="org.openecomp.modelloader" level="INFO" /> + + <!-- Other Loggers that may help troubleshoot --> + <logger name="net.sf" level="WARN" /> + <logger name="org.apache.commons.httpclient" level="WARN" /> + <logger name="org.apache.commons" level="WARN" /> + <logger name="org.apache.coyote" level="WARN" /> + <logger name="org.apache.jasper" level="WARN" /> + + <!-- Camel Related Loggers (including restlet/servlet/jaxrs/cxf logging. + May aid in troubleshooting) --> + <logger name="org.apache.camel" level="WARN" /> + <logger name="org.apache.cxf" level="WARN" /> + <logger name="org.apache.camel.processor.interceptor" level="WARN" /> + <logger name="org.apache.cxf.jaxrs.interceptor" level="WARN" /> + <logger name="org.apache.cxf.service" level="WARN" /> + <logger name="org.restlet" level="WARN" /> + <logger name="org.apache.camel.component.restlet" level="WARN" /> + + <!-- logback internals logging --> + <logger name="ch.qos.logback.classic" level="WARN" /> + <logger name="ch.qos.logback.core" level="WARN" /> + + <root> + <appender-ref ref="asyncEELF" /> + <!-- <appender-ref ref="asyncEELFDebug" /> --> + </root> + +</configuration> diff --git a/src/main/resources/org/onap/aai/modelloader/service/ModelLoaderMsgs.properties b/src/main/resources/org/onap/aai/modelloader/service/ModelLoaderMsgs.properties index 112b48c..1e5658c 100644 --- a/src/main/resources/org/onap/aai/modelloader/service/ModelLoaderMsgs.properties +++ b/src/main/resources/org/onap/aai/modelloader/service/ModelLoaderMsgs.properties @@ -3,7 +3,7 @@ # org.onap.aai
# ===================================================================
# Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
-# Copyright © 2017-2018 Amdocs
+# Copyright © 2017-2018 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.
|