move all hard install config to environment vars 80/79380/4
authorJorge Hernandez <jorge.hernandez-herrero@att.com>
Thu, 28 Feb 2019 16:10:49 +0000 (10:10 -0600)
committerJorge Hernandez <jorge.hernandez-herrero@att.com>
Fri, 1 Mar 2019 15:56:11 +0000 (09:56 -0600)
+ support multiple system properties files with variable interpolation
  loaded at initialization
+ support of configurable JVM options (-X, etc ..).
+ rearrange aaf configuration to avoid {{}} installation variables
  and use dynamic enviroment variables.
+ miscellaneous clean up in areas touched and checkstyle.

Change-Id: I71ad839778e17eb57c098a2c5cc2bf96e468669a
Issue-ID: POLICY-1524
Signed-off-by: Jorge Hernandez <jorge.hernandez-herrero@att.com>
27 files changed:
docker_build.sh
docker_merge.sh
docker_verify.sh
feature-eelf/src/main/java/org/onap/policy/drools/eelf/EelfFeature.java
feature-eelf/src/test/java/org/onap/policy/drools/eelf/test/EElfTest.java
feature-pooling-dmaap/src/main/feature/config/feature-pooling-dmaap.properties
packages/docker/src/main/docker/Dockerfile
packages/docker/src/main/docker/do-start.sh
packages/install/src/files/base.conf
policy-management/src/main/java/org/onap/policy/drools/persistence/FileSystemPersistence.java
policy-management/src/main/java/org/onap/policy/drools/persistence/SystemPersistence.java
policy-management/src/main/java/org/onap/policy/drools/system/Main.java
policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngine.java
policy-management/src/main/server-gen/bin/policy-management-controller
policy-management/src/main/server/config/aaf-credentials.properties [deleted file]
policy-management/src/main/server/config/aaf-location.properties [deleted file]
policy-management/src/main/server/config/aaf-system.properties [new file with mode: 0644]
policy-management/src/main/server/config/aaf.properties [deleted file]
policy-management/src/main/server/config/engine-system.properties [new file with mode: 0644]
policy-management/src/main/server/config/engine.properties [moved from policy-management/src/main/server/config/policy-engine.properties with 63% similarity]
policy-management/src/main/server/config/system.properties
policy-management/src/test/java/org/onap/policy/drools/persistence/SystemPersistenceTest.java [moved from policy-management/src/test/java/org/onap/policy/drools/persistence/test/SystemPersistenceTest.java with 61% similarity]
policy-management/src/test/java/org/onap/policy/drools/system/PolicyEngineManagerTest.java
policy-management/src/test/java/org/onap/policy/drools/system/PolicyEngineTest.java
policy-utils/src/main/java/org/onap/policy/drools/utils/PropertyUtil.java
policy-utils/src/main/java/org/onap/policy/drools/utils/logging/LoggerUtil.java
policy-utils/src/test/java/org/onap/policy/drools/utils/PropertyUtilTest.java

index 6f68058..64abc90 100644 (file)
@@ -1,5 +1,5 @@
 #!/bin/bash
-# Copyright 2018 AT&T Intellectual Property. All rights reserved
+# Copyright 2018-2019 AT&T Intellectual Property. All rights reserved
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -22,14 +22,6 @@ TIMESTAMP=$(date -u +%Y%m%dT%H%M%S)
 BUILD_ARGS="--build-arg BUILD_VERSION=${MVN_VERSION}"
 IMAGE=policy-drools
 
-if [ $HTTP_PROXY ]; then
-    BUILD_ARGS+=" --build-arg HTTP_PROXY=${HTTP_PROXY}"
-fi
-
-if [ $HTTPS_PROXY ]; then
-    BUILD_ARGS+=" --build-arg HTTPS_PROXY=${HTTPS_PROXY}"
-fi
-
 echo $DOCKER_REPOSITORY
 echo $MVN_VERSION
 echo $MVN_MAJMIN_VERSION
index 20fa184..3cbef59 100644 (file)
@@ -1,5 +1,5 @@
 #!/bin/bash
-# Copyright 2018 AT&T Intellectual Property. All rights reserved
+# Copyright 2018-2019 AT&T Intellectual Property. All rights reserved
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -22,13 +22,6 @@ TIMESTAMP=$(date -u +%Y%m%dT%H%M%S)
 BUILD_ARGS="--build-arg BUILD_VERSION=${MVN_VERSION}"
 IMAGE=policy-drools
 
-if [ $HTTP_PROXY ]; then
-    BUILD_ARGS+=" --build-arg HTTP_PROXY=${HTTP_PROXY}"
-fi
-if [ $HTTPS_PROXY ]; then
-    BUILD_ARGS+=" --build-arg HTTPS_PROXY=${HTTPS_PROXY}"
-fi
-
 echo $DOCKER_REPOSITORY
 echo $MVN_VERSION
 echo $MVN_MAJMIN_VERSION
index 6a4d024..e2fbe27 100644 (file)
@@ -1,5 +1,5 @@
 #!/bin/bash
-# Copyright 2018 AT&T Intellectual Property. All rights reserved
+# Copyright 2018-2019 AT&T Intellectual Property. All rights reserved
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -25,13 +25,6 @@ TIMESTAMP=$(date -u +%Y%m%dT%H%M%S)
 BUILD_ARGS="--build-arg BUILD_VERSION=${MVN_VERSION}"
 IMAGE=policy-drools
 
-if [ $HTTP_PROXY ]; then
-    BUILD_ARGS+=" --build-arg HTTP_PROXY=${HTTP_PROXY}"
-fi
-if [ $HTTPS_PROXY ]; then
-    BUILD_ARGS+=" --build-arg HTTPS_PROXY=${HTTPS_PROXY}"
-fi
-
 echo $DOCKER_REPOSITORY
 echo $MVN_VERSION
 echo $MVN_MAJMIN_VERSION
index bf0f000..5f99d3b 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * feature-eelf
  * ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,8 +27,8 @@ import org.onap.policy.common.logging.eelf.Configuration;
 import org.onap.policy.common.logging.flexlogger.FlexLogger;
 import org.onap.policy.common.logging.flexlogger.Logger;
 import org.onap.policy.drools.features.PolicyEngineFeatureAPI;
-import org.onap.policy.drools.system.Main;
 import org.onap.policy.drools.system.PolicyEngine;
+import org.onap.policy.drools.utils.logging.LoggerUtil;
 
 /**
  * Feature EELF : Enables EELF Logging Libraries .
@@ -38,8 +38,8 @@ public class EelfFeature implements PolicyEngineFeatureAPI {
     @Override
     public final boolean beforeBoot(PolicyEngine engine, String[] cliArgs) {
 
-        String logback = System.getProperty(Main.LOGBACK_CONFIGURATION_FILE_SYSTEM_PROPERTY, 
-                Main.LOGBACK_CONFIGURATION_FILE_DEFAULT);
+        String logback = System.getProperty(LoggerUtil.LOGBACK_CONFIGURATION_FILE_SYSTEM_PROPERTY,
+                LoggerUtil.LOGBACK_CONFIGURATION_FILE_DEFAULT);
         Path logbackPath = Paths.get(logback);
 
         if (System.getProperty(Configuration.PROPERTY_LOGGING_FILE_PATH) == null) {
@@ -55,7 +55,7 @@ public class EelfFeature implements PolicyEngineFeatureAPI {
         Logger logger = FlexLogger.getLogger(this.getClass(), true);
 
         if (logger.isInfoEnabled()) {
-            logProperty(logger, Main.LOGBACK_CONFIGURATION_FILE_SYSTEM_PROPERTY);
+            logProperty(logger, LoggerUtil.LOGBACK_CONFIGURATION_FILE_SYSTEM_PROPERTY);
             logProperty(logger, Configuration.PROPERTY_LOGGING_FILE_PATH);
             logProperty(logger, Configuration.PROPERTY_LOGGING_FILE_NAME);
         }
index 7f9e81c..5a1645a 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * feature-eelf
  * ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -36,8 +36,8 @@ import java.util.List;
 import org.junit.Test;
 import org.onap.policy.common.logging.flexlogger.FlexLogger;
 import org.onap.policy.drools.eelf.EelfFeature;
-import org.onap.policy.drools.system.Main;
 import org.onap.policy.drools.system.PolicyEngine;
+import org.onap.policy.drools.utils.logging.LoggerUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -102,7 +102,7 @@ public class EElfTest {
 
         /* set logback configuration */
 
-        System.setProperty(Main.LOGBACK_CONFIGURATION_FILE_SYSTEM_PROPERTY, 
+        System.setProperty(LoggerUtil.LOGBACK_CONFIGURATION_FILE_SYSTEM_PROPERTY,
                 LOGBACK_CONFIGURATION_FILE_DEFAULT);
 
         /* set up eelf throuth common loggings library */
index 1d54985..2786a61 100644 (file)
@@ -84,13 +84,15 @@ pooling.beijing.topic=${env:POOLING_TOPIC}
 
 
 # the list of sources and sinks should be identical
-ueb.source.topics=${env:POOLING_TOPIC}
-ueb.sink.topics=${env:POOLING_TOPIC}
-
-ueb.source.topics.${{POOLING_TOPIC}}.servers=${env:DMAAP_SERVERS}
-ueb.source.topics.${{POOLING_TOPIC}}.apiKey=
-ueb.source.topics.${{POOLING_TOPIC}}.apiSecret=
-
-ueb.sink.topics.${{POOLING_TOPIC}}.servers=${env:DMAAP_SERVERS}
-ueb.sink.topics.${{POOLING_TOPIC}}.apiKey=
-ueb.sink.topics.${{POOLING_TOPIC}}.apiSecret=
+ueb.source.topics=POOLING_TOPIC
+ueb.sink.topics=POOLING_TOPIC
+
+ueb.source.topics.POOLING_TOPIC.servers=${env:DMAAP_SERVERS}
+ueb.source.topics.POOLING_TOPIC.effectiveTopic=${env:POOLING_TOPIC}
+ueb.source.topics.POOLING_TOPIC.apiKey=
+ueb.source.topics.POOLING_TOPIC.apiSecret=
+
+ueb.sink.topics.POOLING_TOPIC.servers=${env:DMAAP_SERVERS}
+ueb.sink.topics.POOLING_TOPIC.effectiveTopic=${env:POOLING_TOPIC}
+ueb.sink.topics.POOLING_TOPIC.apiKey=
+ueb.sink.topics.POOLING_TOPIC.apiSecret=
index 087dcb4..829bb6b 100644 (file)
@@ -1,14 +1,10 @@
 FROM ubuntu:14.04
 
-ARG HTTP_PROXY=${HTTP_PROXY}
-ARG HTTPS_PROXY=${HTTPS_PROXY}
 ARG BUILD_VERSION=${BUILD_VERSION}
 ARG POLICY_HOME=/opt/app/policy
 ARG POLICY_LOGS=/var/log/onap/policy/pdpd
 ARG POLICY_INSTALL=/tmp/policy-install
 
-ENV http_proxy $HTTP_PROXY
-ENV https_proxy $HTTPS_PROXY
 ENV BUILD_VERSION ${BUILD_VERSION}
 ENV POLICY_INSTALL ${POLICY_INSTALL}
 ENV POLICY_HOME ${POLICY_HOME}
index 91402e6..4687e42 100644 (file)
@@ -1,9 +1,9 @@
 #!/bin/bash
 ###
 # ============LICENSE_START=======================================================
-# 
+# ONAP
 # ================================================================================
-# Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+# Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
 # ================================================================================
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # ============LICENSE_END=========================================================
 ###
 
-# skip installation if build.info file is present (restarting an existing container)
-if [[ -f ${POLICY_HOME}/etc/build.info ]]; then
-       echo "Found existing installation, will not reinstall"
-       . ${POLICY_HOME}/etc/profile.d/env.sh
-else 
-       echo "installing .."
-
-       # replace conf files from installer with environment-specific files
-       # mounted from the hosting VM
-       if [[ -d config ]]; then
-               cp config/*.conf .
-       fi
-
-       if [[ -f config/drools-preinstall.sh ]] ; then
-               echo "found preinstallation script"
-               bash config/drools-preinstall.sh
-       fi
-
-       # remove broken symbolic links if any in data directory
-       if [[ -d ${POLICY_HOME}/config ]]; then
-               echo "removing dangling symbolic links"
-               find -L ${POLICY_HOME}/config -type l -exec rm -- {} +
-       fi
-
-       apps=$(ls config/apps*.zip 2> /dev/null)
-       for app in $apps
-       do
-           echo "Application found: ${app}"
-           unzip -o ${app}
-       done
-
-    feats=$(ls config/feature*.zip 2> /dev/null)
-    for feat in $feats
-    do
-        echo "Feature found: ${feat}"
-        cp ${feat} .
-    done
-
-       echo "docker install at ${PWD}"
-
-       ./docker-install.sh
-
-       . ${POLICY_HOME}/etc/profile.d/env.sh
-
-       # allow user to override the key or/and the trust stores
-
-       if [[ -f config/policy-keystore ]]; then
-           cp -f config/policy-keystore ${POLICY_HOME}/etc/ssl
-       fi
-
-       if [[ -f config/policy-truststore ]]; then
-           cp -f config/policy-truststore ${POLICY_HOME}/etc/ssl
-       fi
-
-       # allow user to override all or some aaf configuration
-
-       if [[ -f config/aaf.properties ]]; then
-           cp -f config/aaf.properties ${POLICY_HOME}/config/aaf.properties
-       fi
-
-       if [[ -f config/aaf-location.properties ]]; then
-           cp -f config/aaf-location.properties ${POLICY_HOME}/config/aaf-location.properties
-       fi
-
-       if [[ -f config/aaf-credentials.properties ]]; then
-           cp -f config/aaf-credentials.properties ${POLICY_HOME}/config/aaf-credentials.properties
-       fi
-
-       if [[ -f config/aaf-cadi.keyfile ]]; then
-           cp -f config/aaf-cadi.keyfile ${POLICY_HOME}/config/aaf-cadi.keyfile
-       fi
-
-       if [[ -f config/drools-tweaks.sh ]] ; then
-               echo "Executing tweaks"
-               # file may not be executable; running it as an
-               # argument to bash avoids needing execute perms.
-               bash config/drools-tweaks.sh
-       fi
+echo "installing .."
+
+# replace conf files from installer with environment-specific files
+# mounted from the hosting VM
+
+if [[ -d config ]]; then
+    cp config/*.conf .
+fi
+
+if [[ -f config/drools-preinstall.sh ]] ; then
+    echo "found preinstallation script"
+    bash config/drools-preinstall.sh
+fi
+
+# remove broken symbolic links if any in data directory
+if [[ -d ${POLICY_HOME}/config ]]; then
+    echo "removing dangling symbolic links"
+    find -L ${POLICY_HOME}/config -type l -exec rm -- {} +
+fi
+
+apps=$(ls config/apps*.zip 2> /dev/null)
+for app in $apps
+do
+    echo "Application found: ${app}"
+    unzip -o ${app}
+done
+
+feats=$(ls config/feature*.zip 2> /dev/null)
+for feat in $feats
+do
+    echo "Feature found: ${feat}"
+    cp ${feat} .
+done
+
+echo "docker install at ${PWD}"
+
+./docker-install.sh
+
+source ${POLICY_HOME}/etc/profile.d/env.sh
+
+# allow user to override the key or/and the trust stores
+
+if [[ -f config/policy-keystore ]]; then
+    cp -f config/policy-keystore ${POLICY_HOME}/etc/ssl
+fi
+
+if [[ -f config/policy-truststore ]]; then
+    cp -f config/policy-truststore ${POLICY_HOME}/etc/ssl
+fi
+
+# allow user to override all or some aaf configuration
+
+if [[ -f config/aaf.properties ]]; then
+    cp -f config/aaf.properties ${POLICY_HOME}/config/aaf.properties
+fi
+
+if [[ -f config/aaf-cadi.keyfile ]]; then
+    cp -f config/aaf-cadi.keyfile ${POLICY_HOME}/config/aaf-cadi.keyfile
+fi
+
+if [[ -f config/drools-tweaks.sh ]] ; then
+    echo "Executing tweaks"
+    # file may not be executable; running it as an
+    # argument to bash avoids needing execute perms.
+    bash config/drools-tweaks.sh
 fi
 
 echo "Starting processes"
index 4d38301..70b165f 100644 (file)
 # ============LICENSE_END=========================================================
 ###
 
+# JVM options
+
+JVM_OPTIONS=-server -Xms512m -Xmx1024m
+
 # SYSTEM software configuration 
 
 POLICY_HOME=/opt/app/policy
@@ -38,6 +42,7 @@ TELEMETRY_PASSWORD=
 SNAPSHOT_REPOSITORY_ID=
 SNAPSHOT_REPOSITORY_URL=
 RELEASE_REPOSITORY_ID=
+RELEASE_REPOSITORY_URL=
 REPOSITORY_USERNAME=
 REPOSITORY_PASSWORD=
 
@@ -56,7 +61,6 @@ AAF_HOST=aaf-onap-test.osaaf.org
 # PDP-D DMaaP configuration channel
 
 PDPD_CONFIGURATION_TOPIC=PDPD-CONFIGURATION
-PDPD_CONFIGURATION_SERVERS=
 PDPD_CONFIGURATION_API_KEY=
 PDPD_CONFIGURATION_API_SECRET=
 PDPD_CONFIGURATION_CONSUMER_GROUP=
index 2fcb07d..b5c6fe9 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * ============LICENSE_START=======================================================
- * policy-management
+ * ONAP
  * ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -32,6 +32,7 @@ import java.util.Arrays;
 import java.util.List;
 import java.util.Properties;
 
+import java.util.function.BiPredicate;
 import org.onap.policy.drools.properties.DroolsProperties;
 import org.onap.policy.drools.utils.PropertyUtil;
 import org.slf4j.Logger;
@@ -41,45 +42,60 @@ import org.slf4j.LoggerFactory;
  * Properties based Persistence.
  */
 public class FileSystemPersistence implements SystemPersistence {
-    
+
+    /**
+     * Properties file extension.
+     */
+    public static final String PROPERTIES_FILE_EXTENSION = ".properties";
+
     /**
-     * policy controllers suffix.
+     * Policy controllers suffix.
      */
     public static final String CONTROLLER_SUFFIX_IDENTIFIER = "-controller";
 
     /**
-     * policy controller properties file suffix.
+     * Policy controller properties file suffix.
      */
     public static final String PROPERTIES_FILE_CONTROLLER_SUFFIX =
-            CONTROLLER_SUFFIX_IDENTIFIER + ".properties";
+            CONTROLLER_SUFFIX_IDENTIFIER + PROPERTIES_FILE_EXTENSION;
 
     /**
-     * policy controller properties file suffix.
+     * Policy controller properties file suffix.
      */
     public static final String PROPERTIES_FILE_CONTROLLER_BACKUP_SUFFIX =
-            CONTROLLER_SUFFIX_IDENTIFIER + ".properties.bak";
+            CONTROLLER_SUFFIX_IDENTIFIER + PROPERTIES_FILE_EXTENSION + ".bak";
 
     /**
-     * policy engine properties file name.
+     * Policy engine properties file name.
      */
-    public static final String PROPERTIES_FILE_ENGINE = "policy-engine.properties";
+    public static final String PROPERTIES_FILE_ENGINE = "engine" + PROPERTIES_FILE_EXTENSION;
 
     /**
      * Installation environment suffix for files.
      */
-    public static final String ENV_SUFFIX = ".environment";
+    public static final String ENV_FILE_SUFFIX = ".environment";
 
     /**
-     * configuration directory.
+     * Environment properties extension.
+     */
+    public static final String ENV_FILE_EXTENSION = ENV_FILE_SUFFIX;
+
+    /**
+     * Installation environment suffix for files.
+     */
+    public static final String SYSTEM_PROPERTIES_SUFFIX = "-system";
+    public static final String SYSTEM_PROPERTIES_FILE_SUFFIX = SYSTEM_PROPERTIES_SUFFIX + PROPERTIES_FILE_EXTENSION;
+
+    /**
+     * Configuration directory.
      */
     protected Path configurationDirectory = Paths.get(DEFAULT_CONFIGURATION_DIR);
 
     /**
-     * logger.
+     * Logger.
      */
     private static final Logger logger = LoggerFactory.getLogger(FileSystemPersistence.class);
 
-
     @Override
     public void setConfigurationDir(String configDir) {
         String tempConfigDir = configDir;
@@ -93,6 +109,11 @@ public class FileSystemPersistence implements SystemPersistence {
             this.configurationDirectory = Paths.get(tempConfigDir);
         }
 
+        setConfigurationDir();
+    }
+
+    @Override
+    public void setConfigurationDir() {
         if (Files.notExists(this.configurationDirectory)) {
             try {
                 Files.createDirectories(this.configurationDirectory);
@@ -103,7 +124,7 @@ public class FileSystemPersistence implements SystemPersistence {
 
         if (!Files.isDirectory(this.configurationDirectory)) {
             throw new IllegalStateException(
-                    "config directory: " + this.configurationDirectory + " is not a directory");
+                "config directory: " + this.configurationDirectory + " is not a directory");
         }
     }
 
@@ -112,21 +133,116 @@ public class FileSystemPersistence implements SystemPersistence {
         return this.configurationDirectory;
     }
 
+    protected Properties getProperties(Path propertiesPath) {
+        if (!Files.exists(propertiesPath)) {
+            throw new IllegalArgumentException("properties for " + propertiesPath.toString() + " are not persisted.");
+        }
+
+        try {
+            return PropertyUtil.getProperties(propertiesPath.toFile());
+        } catch (final Exception e) {
+            throw new IllegalArgumentException("can't read properties for " + propertiesPath.toString(), e);
+        }
+    }
+
     @Override
-    public Properties getEngineProperties() {
-        final Path policyEnginePath =
-                Paths.get(this.configurationDirectory.toString(), PROPERTIES_FILE_ENGINE);
+    public Properties getProperties(String name) {
+        if (name == null || name.isEmpty()) {
+            throw new IllegalArgumentException("properties name must be provided");
+        }
+
+        Path propertiesPath = Paths.get(this.configurationDirectory.toString());
+        if (name.endsWith(PROPERTIES_FILE_EXTENSION) || name.endsWith(ENV_FILE_EXTENSION)) {
+            propertiesPath = propertiesPath.resolve(name);
+        } else {
+            propertiesPath = propertiesPath.resolve(name + PROPERTIES_FILE_EXTENSION);
+        }
+
+        return getProperties(propertiesPath);
+    }
+
+    protected List<Properties> getPropertiesList(String suffix) {
+        return getPropertiesList(suffix, (name, props) ->  true);
+    }
+
+    protected List<Properties> getPropertiesList(String suffix, BiPredicate<String, Properties> preCondition) {
+        List<Properties> properties = new ArrayList<>();
+        File[] files = this.sortedListFiles();
+        for (File file : files) {
+            if (file.getName().endsWith(suffix)) {
+                addToPropertiesList(file, properties, preCondition);
+            }
+        }
+        return properties;
+    }
+
+    private void addToPropertiesList(File file, List<Properties> properties,
+                                     BiPredicate<String, Properties> preCondition) {
         try {
-            if (Files.exists(policyEnginePath)) {
-                return PropertyUtil.getProperties(policyEnginePath.toFile());
+            Properties proposedProps = getProperties(file.getName());
+            if (preCondition.test(file.getName(), proposedProps)) {
+                properties.add(proposedProps);
             }
         } catch (final Exception e) {
-            logger.warn("{}: could not find {}", this, policyEnginePath, e);
+            logger.error("{}: cannot get properties {} because of {}", this, file.getName(),
+                e.getMessage(), e);
         }
+    }
 
-        return null;
+    @Override
+    public Properties getEnvironmentProperties(String name) {
+        if (name == null || name.isEmpty()) {
+            throw new IllegalArgumentException("environment name must be provided");
+        }
+
+        return this.getProperties(Paths.get(this.configurationDirectory.toString(), name + ENV_FILE_SUFFIX));
     }
 
+    @Override
+    public List<Properties> getEnvironmentProperties() {
+        return getPropertiesList(ENV_FILE_SUFFIX);
+    }
+
+    @Override
+    public Properties getSystemProperties(String name) {
+        return this.getProperties(name + SYSTEM_PROPERTIES_SUFFIX);
+    }
+
+    @Override
+    public List<Properties> getSystemProperties() {
+        return getPropertiesList(SYSTEM_PROPERTIES_FILE_SUFFIX);
+    }
+
+    @Override
+    public Properties getEngineProperties() {
+        return this.getProperties(PROPERTIES_FILE_ENGINE);
+    }
+
+    @Override
+    public Properties getControllerProperties(String controllerName) {
+        return this.getProperties(controllerName + CONTROLLER_SUFFIX_IDENTIFIER);
+    }
+
+    @Override
+    public List<Properties> getControllerProperties() {
+        return getPropertiesList(PROPERTIES_FILE_CONTROLLER_SUFFIX, this::testControllerName);
+    }
+
+    private boolean testControllerName(String controllerFilename, Properties controllerProperties) {
+        String controllerName = controllerFilename
+                .substring(0, controllerFilename.length() - PROPERTIES_FILE_CONTROLLER_SUFFIX.length());
+        String controllerPropName = controllerProperties.getProperty(DroolsProperties.PROPERTY_CONTROLLER_NAME);
+        if (controllerPropName == null) {
+            controllerProperties.setProperty(DroolsProperties.PROPERTY_CONTROLLER_NAME, controllerName);
+        } else if (!controllerPropName.equals(controllerName)) {
+            logger.error("{}: mismatch controller named {} against {} in file {}",
+                         this, controllerPropName, controllerName, controllerFilename);
+            return false;
+        }
+        return true;
+    }
+
+
     @Override
     public boolean backupController(String controllerName) {
         final Path controllerPropertiesPath = Paths.get(this.configurationDirectory.toString(),
@@ -209,97 +325,6 @@ public class FileSystemPersistence implements SystemPersistence {
         return true;
     }
 
-    @Override
-    public Properties getControllerProperties(String controllerName) {
-        return this.getProperties(controllerName + CONTROLLER_SUFFIX_IDENTIFIER);
-    }
-
-    @Override
-    public List<Properties> getControllerProperties() {
-        final List<Properties> controllers = new ArrayList<>();
-        final File[] controllerFiles = this.sortedListFiles();
-        for (final File controllerFile : controllerFiles) {
-            if (controllerFile.getName().endsWith(PROPERTIES_FILE_CONTROLLER_SUFFIX)) {
-                final int idxSuffix = controllerFile.getName().indexOf(PROPERTIES_FILE_CONTROLLER_SUFFIX);
-                final int lastIdxSuffix =
-                        controllerFile.getName().lastIndexOf(PROPERTIES_FILE_CONTROLLER_SUFFIX);
-                if (idxSuffix != lastIdxSuffix) {
-                    throw new IllegalArgumentException(
-                            "Improper naming of controller properties file: " + "Expected <controller-name>"
-                                    + FileSystemPersistence.PROPERTIES_FILE_CONTROLLER_SUFFIX);
-                }
-
-                final String name = controllerFile.getName().substring(0, lastIdxSuffix);
-                try {
-                    final Properties controllerProperties = this.getControllerProperties(name);
-                    final String controllerName =
-                            controllerProperties.getProperty(DroolsProperties.PROPERTY_CONTROLLER_NAME);
-                    if (controllerName == null) {
-                        controllerProperties.setProperty(DroolsProperties.PROPERTY_CONTROLLER_NAME, name);
-                    } else if (!controllerName.equals(name)) {
-                        logger.error("{}: mismatch controller named {} with file name {}", this, controllerName,
-                                controllerFile.getName());
-                        continue;
-                    }
-                    controllers.add(this.getControllerProperties(name));
-                } catch (final Exception e) {
-                    logger.error("{}: cannot obtain properties for controller {} because of {}", name,
-                            e.getMessage(), e);
-                }
-            }
-        }
-        return controllers;
-    }
-
-    @Override
-    public Properties getProperties(String name) {
-        final Path propertiesPath =
-                Paths.get(this.configurationDirectory.toString(), name + ".properties");
-
-        if (!Files.exists(propertiesPath)) {
-            throw new IllegalArgumentException("properties for " + name + " are not persisted.");
-        }
-
-        try {
-            return PropertyUtil.getProperties(propertiesPath.toFile());
-        } catch (final Exception e) {
-            logger.warn("{}: can't read properties @ {}", name, propertiesPath);
-            throw new IllegalArgumentException(
-                    "can't read properties for " + name + " @ " + propertiesPath, e);
-        }
-    }
-
-    @Override
-    public List<Properties> getEnvironmentProperties() {
-        final List<Properties> envs = new ArrayList<>();
-        final File[] envFiles = this.sortedListFiles();
-        for (final File envFile : envFiles) {
-            if (envFile.getName().endsWith(ENV_SUFFIX)) {
-                final String name = envFile.getName().substring(0, envFile.getName().indexOf(ENV_SUFFIX));
-                try {
-                    envs.add(this.getEnvironmentProperties(name));
-                } catch (final Exception e) {
-                    logger.error("{}: cannot get environment {} because of {}", name, e.getMessage(), e);
-                }
-            }
-        }
-        return envs;
-    }
-
-    @Override
-    public Properties getEnvironmentProperties(String name) {
-        final Path envPath = Paths.get(this.configurationDirectory.toString(), name + ENV_SUFFIX);
-        if (!Files.exists(envPath)) {
-            throw new IllegalArgumentException("{} environment" + name + " cannot be retrieved");
-        }
-
-        try {
-            return PropertyUtil.getProperties(envPath.toFile());
-        } catch (final Exception e) {
-            throw new IllegalArgumentException("cannot read environment " + name, e);
-        }
-    }
-
     /**
      * provides a list of files sorted by name in ascending order in the configuration directory.
      */
index 34b27c2..3285222 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * policy-management
  * ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -31,27 +31,32 @@ public interface SystemPersistence {
     /**
      * configuration directory.
      */
-    public static final String DEFAULT_CONFIGURATION_DIR = "config";
+    String DEFAULT_CONFIGURATION_DIR = "config";
 
     /**
      * Persistence Manager. For now it is a file-based properties management, In the future, it will
      * probably be DB based, so manager implementation will change.
      */
-    public static final SystemPersistence manager = new FileSystemPersistence();
+    SystemPersistence manager = new FileSystemPersistence();
 
     /**
      * sets a configuration directory and ensures it exists.
      *
      * @param configDir configuration directory or null to use the default one
      */
-    public void setConfigurationDir(String configDir);
+    void setConfigurationDir(String configDir);
+
+    /**
+     * sets the default configuration directory and ensures it exists.
+     */
+    void setConfigurationDir();
 
     /**
      * get configuration directory path.
      *
      * @return configuration directory path
      */
-    public Path getConfigurationPath();
+    Path getConfigurationPath();
 
     /**
      * backs up a controller configuration.
@@ -59,7 +64,7 @@ public interface SystemPersistence {
      * @param controllerName the controller name
      * @return true if the configuration is backed up
      */
-    public boolean backupController(String controllerName);
+    boolean backupController(String controllerName);
 
     /**
      * persists controller configuration.
@@ -71,7 +76,7 @@ public interface SystemPersistence {
      * @throws IllegalArgumentException if the configuration cannot be handled by the persistence
      *         manager
      */
-    public boolean storeController(String controllerName, Object configuration);
+    boolean storeController(String controllerName, Object configuration);
 
     /**
      * delete controller configuration.
@@ -79,7 +84,7 @@ public interface SystemPersistence {
      * @param controllerName the controller name
      * @return true if storage is succesful, false otherwise
      */
-    public boolean deleteController(String controllerName);
+    boolean deleteController(String controllerName);
 
     /**
      * get controller properties.
@@ -90,34 +95,34 @@ public interface SystemPersistence {
      * @throws IllegalArgumentException if the controller name does not lead to a properties
      *         configuration
      */
-    public Properties getControllerProperties(String controllerName);
+    Properties getControllerProperties(String controllerName);
 
     /**
      * get controllers configuration.
      *
      * @return list of controllers properties
      */
-    public List<Properties> getControllerProperties();
+    List<Properties> getControllerProperties();
 
     /**
      * get environments.
      *
      */
-    public List<Properties> getEnvironmentProperties();
+    List<Properties> getEnvironmentProperties();
 
     /**
      * get environment properties.
      *
      * @param environmentName name
      */
-    public Properties getEnvironmentProperties(String environmentName);
+    Properties getEnvironmentProperties(String environmentName);
 
     /**
      * get the engine properties.
      *
      * @return the engine properties
      */
-    public Properties getEngineProperties();
+    Properties getEngineProperties();
 
     /**
      * get properties by name.
@@ -127,5 +132,20 @@ public interface SystemPersistence {
      *
      * @throws IllegalArgumentException if the name does not lead to a properties configuration
      */
-    public Properties getProperties(String name);
+    Properties getProperties(String name);
+
+    /**
+     * get system properties configuration.
+     *
+     * @param name name
+     * @return properties
+     */
+    Properties getSystemProperties(String name);
+
+    /**
+     * get system properties configuration list.
+     *
+     * @return list of system properties
+     */
+    List<Properties> getSystemProperties();
 }
index 79268b2..5ebd049 100644 (file)
@@ -1,8 +1,8 @@
 /*-
  * ============LICENSE_START=======================================================
- * policy-management
+ * ONAP
  * ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 
 package org.onap.policy.drools.system;
 
-import java.nio.file.Files;
-import java.nio.file.Paths;
 import java.util.Properties;
-
 import org.onap.policy.drools.persistence.SystemPersistence;
 import org.onap.policy.drools.properties.DroolsProperties;
+import org.onap.policy.drools.utils.PropertyUtil;
 import org.onap.policy.drools.utils.logging.LoggerUtil;
 import org.onap.policy.drools.utils.logging.MDCTransaction;
 import org.slf4j.Logger;
@@ -36,13 +34,6 @@ import org.slf4j.LoggerFactory;
  */
 public class Main {
 
-    /** logback configuration file system property. */
-    public static final String LOGBACK_CONFIGURATION_FILE_SYSTEM_PROPERTY =
-            "logback.configurationFile";
-
-    /** logback configuration file system property. */
-    public static final String LOGBACK_CONFIGURATION_FILE_DEFAULT = "config/logback.xml";
-
     /** constructor (hides public default one). */
     private Main() {}
 
@@ -53,44 +44,27 @@ public class Main {
      */
     public static void main(String[] args) {
 
-        /* logging defaults */
-
-        if (System.getProperty(LOGBACK_CONFIGURATION_FILE_SYSTEM_PROPERTY) == null) {
-            if (Files.exists(Paths.get(LOGBACK_CONFIGURATION_FILE_DEFAULT))) {
-                System.setProperty(
-                        LOGBACK_CONFIGURATION_FILE_SYSTEM_PROPERTY, LOGBACK_CONFIGURATION_FILE_DEFAULT);
-            } else {
-                LoggerUtil.setLevel(LoggerUtil.ROOT_LOGGER, ch.qos.logback.classic.Level.INFO.toString());
-            }
-        }
-
-        /* make sure the default configuration directory is properly set up */
+        /* start logger */
 
-        SystemPersistence.manager.setConfigurationDir(null);
+        Logger logger = LoggerFactory.getLogger(Main.class);
 
-        /* logging defaults */
+        /* system properties */
 
-        if (System.getProperty(LOGBACK_CONFIGURATION_FILE_SYSTEM_PROPERTY) == null) {
-            if (Files.exists(Paths.get(LOGBACK_CONFIGURATION_FILE_DEFAULT))) {
-                System.setProperty(
-                        LOGBACK_CONFIGURATION_FILE_SYSTEM_PROPERTY, LOGBACK_CONFIGURATION_FILE_DEFAULT);
-            } else {
-                LoggerUtil.setLevel(LoggerUtil.ROOT_LOGGER, ch.qos.logback.classic.Level.INFO.toString());
-            }
+        for (Properties systemProperties : SystemPersistence.manager.getSystemProperties()) {
+            PropertyUtil.setSystemProperties(systemProperties);
         }
 
         /* 0. boot */
 
         PolicyEngine.manager.boot(args);
 
-        /* start logger */
+        /* 1.a. Configure Engine */
 
-        final Logger logger = LoggerFactory.getLogger(Main.class);
-
-        /* 1.a. Configure the Engine */
-
-        Properties engineProperties = SystemPersistence.manager.getEngineProperties();
-        if (engineProperties == null) {
+        Properties engineProperties;
+        try {
+            engineProperties = SystemPersistence.manager.getEngineProperties();
+        } catch (IllegalArgumentException iae) {
+            logger.warn("Main: engine properties not found.  Using default configuration.", iae);
             engineProperties = PolicyEngine.manager.defaultTelemetryConfig();
         }
 
@@ -98,7 +72,7 @@ public class Main {
 
         /* 1.b. Load Installation Environment(s) */
 
-        for (final Properties env : SystemPersistence.manager.getEnvironmentProperties()) {
+        for (Properties env : SystemPersistence.manager.getEnvironmentProperties()) {
             PolicyEngine.manager.setEnvironment(env);
         }
 
index 959114a..bedd8d4 100644 (file)
@@ -54,6 +54,7 @@ import org.onap.policy.drools.protocol.configuration.ControllerConfiguration;
 import org.onap.policy.drools.protocol.configuration.PdpdConfiguration;
 import org.onap.policy.drools.server.restful.RestManager;
 import org.onap.policy.drools.server.restful.aaf.AafTelemetryAuthFilter;
+import org.onap.policy.drools.utils.PropertyUtil;
 import org.onap.policy.drools.utils.logging.LoggerUtil;
 import org.onap.policy.drools.utils.logging.MDCTransaction;
 import org.slf4j.Logger;
@@ -429,7 +430,7 @@ class PolicyEngineManager implements PolicyEngine {
 
     @Override
     public synchronized void setEnvironment(Properties properties) {
-        this.environment.putAll(properties);
+        this.environment.putAll(PropertyUtil.getInterpolatedProperties(properties));
     }
 
     @JsonIgnore
@@ -443,7 +444,10 @@ class PolicyEngineManager implements PolicyEngine {
     public synchronized String getEnvironmentProperty(String envKey) {
         String value = this.environment.getProperty(envKey);
         if (value == null) {
-            value = System.getenv(envKey);
+            value = System.getProperty(envKey);
+            if (value == null) {
+                value = System.getenv(envKey);
+            }
         }
         return value;
     }
index 589c4c3..79fab58 100644 (file)
@@ -53,8 +53,9 @@ function um_start() {
     source ${POLICY_HOME}/etc/profile.d/env.sh
 
     ${POLICY_HOME}/bin/configure-maven
+    JVM_OPTS=(${JVM_OPTIONS})
 
-    # If 'system.properties' exists, convert it into JVM arguments.
+    # If 'system.properties' exists, convert it into "-D" JVM arguments.
     # Note that the following also handles property values with spaces.
     IFS=$'\n'
     systemProperties=($(
@@ -71,7 +72,7 @@ function um_start() {
            # to subprocesses
            exec {cfg}>&-
        fi
-       nohup $JAVA_HOME/bin/java -cp $_DIR/config:$_DIR/lib:$CP "${systemProperties[@]}" "$@" $CLASS > >( while read line; do echo "$(date): ${line}"; done > $_LOGS/$PNAME.out) 2> >( while read line; do echo "$(date): ${line}"; done > $_LOGS/$PNAME.err) &
+       nohup $JAVA_HOME/bin/java "${JVM_OPTS[@]}" -cp $_DIR/config:$_DIR/lib:$CP "${systemProperties[@]}" "$@" $CLASS > >( while read line; do echo "$(date): ${line}"; done > $_LOGS/$PNAME.out) 2> >( while read line; do echo "$(date): ${line}"; done > $_LOGS/$PNAME.err) &
 
        _PID=$!
        echo $_PID > $_PIDFILE
diff --git a/policy-management/src/main/server/config/aaf-credentials.properties b/policy-management/src/main/server/config/aaf-credentials.properties
deleted file mode 100644 (file)
index aaa5f16..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-cm_url=https://AAF_LOCATE_URL/AAF_NS.cm:2.1
-cadi_x509_issuers=CN=intermediateCA_1, OU=OSAAF, O=ONAP, C=US:CN=intermediateCA_7, OU=OSAAF, O=ONAP, C=US
-cadi_keyfile=${{POLICY_HOME}}/config/aaf-cadi.keyfile
-cadi_keystore=${{POLICY_HOME}}/etc/ssl/policy-keystore
-cadi_keystore_password=${{KEYSTORE_PASSWD}}
-cadi_key_password=${{KEYSTORE_PASSWD}}
-cadi_alias=policy@policy.onap.org
-cadi_truststore=${{POLICY_HOME}}/etc/ssl/policy-truststore
-cadi_truststore_password=${{TRUSTSTORE_PASSWD}}
\ No newline at end of file
diff --git a/policy-management/src/main/server/config/aaf-location.properties b/policy-management/src/main/server/config/aaf-location.properties
deleted file mode 100644 (file)
index dc828e7..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-cadi_latitude=38.000
-cadi_longitude=-72.000
diff --git a/policy-management/src/main/server/config/aaf-system.properties b/policy-management/src/main/server/config/aaf-system.properties
new file mode 100644 (file)
index 0000000..05716cc
--- /dev/null
@@ -0,0 +1,43 @@
+#
+# ============LICENSE_START=======================================================
+# ONAP
+# ================================================================================
+# Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+# ================================================================================
+# 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=========================================================
+#
+
+# AAF related system properties
+
+aaf_locate_url=https://${env:AAF_HOST}:8095
+aaf_oauth2_introspect_url=https://AAF_LOCATE_URL/AAF_NS.introspect:2.1/introspect
+aaf_oauth2_token_url=https://AAF_LOCATE_URL/AAF_NS.token:2.1/token
+aaf_url=https://AAF_LOCATE_URL/AAF_NS.service:2.1
+aaf_env=DEV
+
+cadi_protocols=TLSv1.1,TLSv1.2
+cadi_latitude=38.000
+cadi_longitude=-72.000
+cadi_loglevel=DEBUG
+
+cadi_x509_issuers=CN=intermediateCA_1, OU=OSAAF, O=ONAP, C=US:CN=intermediateCA_7, OU=OSAAF, O=ONAP, C=US
+cadi_keyfile=${env:POLICY_HOME}/config/aaf-cadi.keyfile
+cadi_keystore=${env:POLICY_HOME}/etc/ssl/policy-keystore
+cadi_keystore_password=${env:KEYSTORE_PASSWD}
+cadi_key_password=${env:KEYSTORE_PASSWD}
+cadi_alias=policy@policy.onap.org
+cadi_truststore=${env:POLICY_HOME}/etc/ssl/policy-truststore
+cadi_truststore_password=${env:TRUSTSTORE_PASSWD}
+
+cm_url=https://AAF_LOCATE_URL/AAF_NS.cm:2.1
diff --git a/policy-management/src/main/server/config/aaf.properties b/policy-management/src/main/server/config/aaf.properties
deleted file mode 100644 (file)
index 8084be9..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-cadi_prop_files=${{POLICY_HOME}}/config/aaf-credentials.properties:${{POLICY_HOME}}/config/aaf-location.properties
-cadi_loglevel=DEBUG
-aaf_env=DEV
-aaf_locate_url=https://${{AAF_HOST}}:8095
-aaf_oauth2_introspect_url=https://AAF_LOCATE_URL/AAF_NS.introspect:2.1/introspect
-aaf_oauth2_token_url=https://AAF_LOCATE_URL/AAF_NS.token:2.1/token
-aaf_url=https://AAF_LOCATE_URL/AAF_NS.service:2.1
-cadi_protocols=TLSv1.1,TLSv1.2
-cm_url=https://AAF_LOCATE_URL/AAF_NS.cm:2.1
-fs_url=https://AAF_LOCATE_URL/AAF_NS.fs.2.1
-gui_url=https://AAF_LOCATE_URL/AAF_NS.gui.2.1
diff --git a/policy-management/src/main/server/config/engine-system.properties b/policy-management/src/main/server/config/engine-system.properties
new file mode 100644 (file)
index 0000000..c1f21b8
--- /dev/null
@@ -0,0 +1,37 @@
+#
+# ============LICENSE_START=======================================================
+# ONAP
+# ================================================================================
+# Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+# ================================================================================
+# 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=========================================================
+#
+
+# system properties set within the application
+
+java.net.preferIPv4Stack=true
+
+# jmx
+
+com.sun.management.jmxremote.port=9991
+com.sun.management.jmxremote.authenticate=false
+com.sun.management.jmxremote.ssl=false
+
+# certs
+
+javax.net.ssl.trustStore=${env:POLICY_HOME}/etc/ssl/policy-truststore
+javax.net.ssl.trustStorePassword=${env:TRUSTSTORE_PASSWD}
+
+javax.net.ssl.keyStore=${env:POLICY_HOME}/etc/ssl/policy-keystore
+javax.net.ssl.keyStorePassword=${env:KEYSTORE_PASSWD}
@@ -1,15 +1,15 @@
 ###
 # ============LICENSE_START=======================================================
-# policy-management
+# ONAP
 # ================================================================================
-# Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+# Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
 # ================================================================================
 # 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.
 # ============LICENSE_END=========================================================
 ###
 
-# Policy Engine Configuration
+# Policy Engine Configuration Channels
 
-# Configuration Channel Settings: PDPD-CONFIGURATION
+dmaap.source.topics=PDPD-CONFIGURATION,POLICY-PDP-PAP
 
-dmaap.source.topics=${env:PDPD_CONFIGURATION_TOPIC},POLICY-PDP-PAP
-dmaap.source.topics.${{PDPD_CONFIGURATION_TOPIC}}.servers=${env:PDPD_CONFIGURATION_SERVERS}
-dmaap.source.topics.${{PDPD_CONFIGURATION_TOPIC}}.apiKey=${env:PDPD_CONFIGURATION_API_KEY}
-dmaap.source.topics.${{PDPD_CONFIGURATION_TOPIC}}.apiSecret=${env:PDPD_CONFIGURATION_API_SECRET}
-dmaap.source.topics.${{PDPD_CONFIGURATION_TOPIC}}.consumerGroup=${env:PDPD_CONFIGURATION_CONSUMER_GROUP}
-dmaap.source.topics.${{PDPD_CONFIGURATION_TOPIC}}.consumerInstance=${env:PDPD_CONFIGURATION_CONSUMER_INSTANCE}
-dmaap.source.topics.${{PDPD_CONFIGURATION_TOPIC}}.managed=false
-dmaap.source.topics.${{PDPD_CONFIGURATION_TOPIC}}.https=true
+dmaap.sink.topics=PDPD-CONFIGURATION,POLICY-PDP-PAP
 
-dmaap.sink.topics=${env:PDPD_CONFIGURATION_TOPIC},POLICY-PDP-PAP
-dmaap.sink.topics.${{PDPD_CONFIGURATION_TOPIC}}.servers=${env:PDPD_CONFIGURATION_SERVERS}
-dmaap.sink.topics.${{PDPD_CONFIGURATION_TOPIC}}.apiKey=${env:PDPD_CONFIGURATION_API_KEY}
-dmaap.sink.topics.${{PDPD_CONFIGURATION_TOPIC}}.apiSecret=${env:PDPD_CONFIGURATION_API_SECRET}
-dmaap.sink.topics.${{PDPD_CONFIGURATION_TOPIC}}.partitionKey=${env:PDPD_CONFIGURATION_PARTITION_KEY}
-dmaap.sink.topics.${{PDPD_CONFIGURATION_TOPIC}}.managed=false
-dmaap.sink.topics.${{PDPD_CONFIGURATION_TOPIC}}.https=true
+dmaap.source.topics.PDPD-CONFIGURATION.servers=${env:DMAAP_SERVERS}
+dmaap.source.topics.PDPD-CONFIGURATION.effectiveTopic=${env:PDPD_CONFIGURATION_TOPIC}
+dmaap.source.topics.PDPD-CONFIGURATION.apiKey=${env:PDPD_CONFIGURATION_API_KEY}
+dmaap.source.topics.PDPD-CONFIGURATION.apiSecret=${env:PDPD_CONFIGURATION_API_SECRET}
+dmaap.source.topics.PDPD-CONFIGURATION.consumerGroup=${env:PDPD_CONFIGURATION_CONSUMER_GROUP}
+dmaap.source.topics.PDPD-CONFIGURATION.consumerInstance=${env:PDPD_CONFIGURATION_CONSUMER_INSTANCE}
+dmaap.source.topics.PDPD-CONFIGURATION.managed=false
+dmaap.source.topics.PDPD-CONFIGURATION.https=true
+
+dmaap.sink.topics.PDPD-CONFIGURATION.servers=${env:DMAAP_SERVERS}
+dmaap.sink.topics.PDPD-CONFIGURATION.effectiveTopic=${env:PDPD_CONFIGURATION_TOPIC}
+dmaap.sink.topics.PDPD-CONFIGURATION.apiKey=${env:PDPD_CONFIGURATION_API_KEY}
+dmaap.sink.topics.PDPD-CONFIGURATION.apiSecret=${env:PDPD_CONFIGURATION_API_SECRET}
+dmaap.sink.topics.PDPD-CONFIGURATION.partitionKey=${env:PDPD_CONFIGURATION_PARTITION_KEY}
+dmaap.sink.topics.PDPD-CONFIGURATION.managed=false
+dmaap.sink.topics.PDPD-CONFIGURATION.https=true
 
 # Configuration Channel Settings: POLICY-PDP-PAP
 
-dmaap.source.topics.POLICY-PDP-PAP.effectiveTopic=${env:POLICY_PDP_PAP_TOPIC}
 dmaap.source.topics.POLICY-PDP-PAP.servers=${env:DMAAP_SERVERS}
+dmaap.source.topics.POLICY-PDP-PAP.effectiveTopic=${env:POLICY_PDP_PAP_TOPIC}
 dmaap.source.topics.POLICY-PDP-PAP.apiKey=${env:POLICY_PDP_PAP_API_KEY}
 dmaap.source.topics.POLICY-PDP-PAP.apiSecret=${env:POLICY_PDP_PAP_API_SECRET}
 dmaap.source.topics.POLICY-PDP-PAP.managed=false
 dmaap.source.topics.POLICY-PDP-PAP.https=true
 
-dmaap.sink.topics.POLICY-PDP-PAP.effectiveTopic=${env:POLICY_PDP_PAP_TOPIC}
 dmaap.sink.topics.POLICY-PDP-PAP.servers=${env:DMAAP_SERVERS}
+dmaap.sink.topics.POLICY-PDP-PAP.effectiveTopic=${env:POLICY_PDP_PAP_TOPIC}
 dmaap.sink.topics.POLICY-PDP-PAP.apiKey=${env:POLICY_PDP_PAP_API_KEY}
 dmaap.sink.topics.POLICY-PDP-PAP.apiSecret=${env:POLICY_PDP_PAP_API_SECRET}
 dmaap.sink.topics.POLICY-PDP-PAP.managed=false
index 6bac0ea..9b6be6b 100644 (file)
@@ -2,7 +2,7 @@
 # ============LICENSE_START=======================================================
 # ONAP
 # ================================================================================
-# Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+# Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
 # ================================================================================
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # ============LICENSE_END=========================================================
 ###
 
-# system properties passed to controller
+# system properties passed as "-D" arguments to the JVM process.
 
-# jmx
+# logging
 
-com.sun.management.jmxremote.port=9991
-com.sun.management.jmxremote.authenticate=false
-com.sun.management.jmxremote.ssl=false
-
-# certs
-
-javax.net.ssl.trustStore=${{POLICY_HOME}}/etc/ssl/policy-truststore
-javax.net.ssl.trustStorePassword=${{TRUSTSTORE_PASSWD}}
-
-javax.net.ssl.keyStore=${{POLICY_HOME}}/etc/ssl/policy-keystore
-javax.net.ssl.keyStorePassword=${{KEYSTORE_PASSWD}}
-
-# aaf
-
-cadi_prop_files=config/aaf.properties
-
-# standard logging
-
-logback.configurationFile=config/logback.xml
+logback.configurationFile=config/logback.xml
\ No newline at end of file
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP
  * ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.drools.persistence.test;
+package org.onap.policy.drools.persistence;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
 import java.io.FileOutputStream;
@@ -30,56 +30,51 @@ import java.io.OutputStream;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
+import java.util.List;
 import java.util.Properties;
-
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.FixMethodOrder;
 import org.junit.Test;
 import org.junit.runners.MethodSorters;
-import org.onap.policy.drools.persistence.FileSystemPersistence;
-import org.onap.policy.drools.persistence.SystemPersistence;
 import org.onap.policy.drools.properties.DroolsProperties;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
  * (File) System Persistence Tests.
  */
 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
 public class SystemPersistenceTest {
-
-    /**
-     * logger.
-     */
-    private static final Logger logger = LoggerFactory.getLogger(SystemPersistenceTest.class);
-
     /**
      * sample configuration dir.
      */
-    public static final String OTHER_CONFIG_DIR = "tmp";
+    private static final String OTHER_CONFIG_DIR = "tmp";
 
     /**
      * Test JUnit Controller Name.
      */
-    public static final String TEST_CONTROLLER_NAME = "foo";
+    private static final String TEST_CONTROLLER_NAME = "foo";
 
     /**
      * Test JUnit Controller Name.
      */
-    public static final String TEST_CONTROLLER_FILE = TEST_CONTROLLER_NAME + "-controller.properties";
+    private static final String TEST_CONTROLLER_FILE = TEST_CONTROLLER_NAME + "-controller.properties";
 
     /**
      * Test JUnit Controller Name Backup.
      */
-    public static final String TEST_CONTROLLER_FILE_BAK = TEST_CONTROLLER_FILE + ".bak";
+    private static final String TEST_CONTROLLER_FILE_BAK = TEST_CONTROLLER_FILE + ".bak";
 
     /**
      * Test JUnit Environment/Engine properties.
      */
-    private static final String ENV_PROPS = "envProps";
+    private static final String ENV_PROPS = TEST_CONTROLLER_NAME;
     private static final String ENV_PROPS_FILE = ENV_PROPS + ".environment";
-    private static final String POLICY_ENGINE_PROPERTIES_FILE = "policy-engine.properties";
+
+    /**
+     * Test JUnit system properties.
+     */
+    private static final String SYSTEM_PROPS = TEST_CONTROLLER_NAME;
+    private static final String SYSTEM_PROPS_FILE =  SYSTEM_PROPS + "-system.properties";
 
     @BeforeClass
     public static void setUp() throws IOException {
@@ -92,22 +87,21 @@ public class SystemPersistenceTest {
     }
 
     @Test
-    public void test1NonDefaultConfigDir() throws IOException {
-        logger.info("enter");
-
+    public void test1NonDefaultConfigDir() {
         SystemPersistence.manager.setConfigurationDir(OTHER_CONFIG_DIR);
-        assertTrue(
-                SystemPersistence.manager.getConfigurationPath().toString().equals(OTHER_CONFIG_DIR));
+        assertEquals(OTHER_CONFIG_DIR, SystemPersistence.manager.getConfigurationPath().toString());
 
         SystemPersistence.manager.setConfigurationDir(null);
-        assertTrue(SystemPersistence.manager.getConfigurationPath().toString()
-                .equals(SystemPersistence.DEFAULT_CONFIGURATION_DIR));
+        assertEquals(SystemPersistence.DEFAULT_CONFIGURATION_DIR,
+                SystemPersistence.manager.getConfigurationPath().toString());
+
+        SystemPersistence.manager.setConfigurationDir();
+        assertEquals(SystemPersistence.DEFAULT_CONFIGURATION_DIR,
+                SystemPersistence.manager.getConfigurationPath().toString());
     }
 
     @Test
-    public void test2Engine() throws IOException {
-        logger.info("enter");
-
+    public void test2Engine_Environment_System() throws IOException {
         SystemPersistence.manager.setConfigurationDir(OTHER_CONFIG_DIR);
 
         final Path policyEnginePropsPath =
@@ -123,21 +117,33 @@ public class SystemPersistenceTest {
             }
         }
 
-        assertEquals(SystemPersistence.manager.getEngineProperties(), engineProps);
+        assertEquals(engineProps, SystemPersistence.manager.getEngineProperties());
 
         final Path environmentPropertiesPath =
                 Paths.get(SystemPersistence.manager.getConfigurationPath().toString(), ENV_PROPS_FILE);
         if (Files.notExists(environmentPropertiesPath)) {
             Files.createFile(environmentPropertiesPath);
         }
+        assertNotNull(SystemPersistence.manager.getEnvironmentProperties(ENV_PROPS));
         assertTrue(SystemPersistence.manager.getEnvironmentProperties(ENV_PROPS).isEmpty());
-        assertTrue(SystemPersistence.manager.getEnvironmentProperties().size() == 1);
+        assertEquals(1, SystemPersistence.manager.getEnvironmentProperties().size());
+        assertEquals(SystemPersistence.manager.getEnvironmentProperties(ENV_PROPS),
+                     SystemPersistence.manager.getEnvironmentProperties().get(0));
+
+        Path systemPropertiesPath =
+            Paths.get(SystemPersistence.manager.getConfigurationPath().toString(), SYSTEM_PROPS_FILE);
+        if (Files.notExists(systemPropertiesPath)) {
+            Files.createFile(systemPropertiesPath);
+        }
+        assertNotNull(SystemPersistence.manager.getSystemProperties(SYSTEM_PROPS));
+        assertTrue(SystemPersistence.manager.getSystemProperties(SYSTEM_PROPS).isEmpty());
+        assertEquals(1, SystemPersistence.manager.getSystemProperties().size());
+        assertEquals(SystemPersistence.manager.getSystemProperties(SYSTEM_PROPS),
+                     SystemPersistence.manager.getSystemProperties().get(0));
     }
 
     @Test
-    public void test3PersistConfiguration() {
-        logger.info("enter");
-
+    public void test3Controller() {
         SystemPersistence.manager.setConfigurationDir(null);
 
         final Path controllerPath = Paths
@@ -150,19 +156,21 @@ public class SystemPersistenceTest {
         assertTrue(Files.notExists(controllerBakPath));
 
         Properties properties = new Properties();
-        properties.put(DroolsProperties.PROPERTY_CONTROLLER_NAME, TEST_CONTROLLER_NAME);
         SystemPersistence.manager.storeController(TEST_CONTROLLER_NAME, properties);
 
         assertTrue(Files.exists(controllerPath));
 
         properties = SystemPersistence.manager.getControllerProperties(TEST_CONTROLLER_NAME);
-        assertTrue(properties != null);
+        assertNotNull(properties);
+
+        List<Properties> controllerPropsList = SystemPersistence.manager.getControllerProperties();
+        assertEquals(1,  controllerPropsList.size());
+        assertEquals(TEST_CONTROLLER_NAME, controllerPropsList
+                     .get(0).getProperty(DroolsProperties.PROPERTY_CONTROLLER_NAME));
 
         SystemPersistence.manager.backupController(TEST_CONTROLLER_NAME);
         assertTrue(Files.exists(controllerBakPath));
 
-        assertFalse(SystemPersistence.manager.getControllerProperties().isEmpty());
-
         SystemPersistence.manager.deleteController(TEST_CONTROLLER_NAME);
         assertTrue(Files.notExists(controllerPath));
     }
@@ -172,22 +180,25 @@ public class SystemPersistenceTest {
      * 
      * @throws IOException throws IO exception
      */
-    public static void cleanUpWorkingDirs() throws IOException {
-
+    private static void cleanUpWorkingDirs() throws IOException {
         SystemPersistence.manager.setConfigurationDir(null);
 
-        final Path testControllerPath = Paths
-                .get(SystemPersistence.manager.getConfigurationPath().toString(), TEST_CONTROLLER_FILE);
+        for (Properties properties : SystemPersistence.manager.getControllerProperties()) {
+            SystemPersistence.manager.deleteController(properties
+                        .getProperty(DroolsProperties.PROPERTY_CONTROLLER_NAME));
+        }
+
         final Path testControllerBakPath = Paths
                 .get(SystemPersistence.manager.getConfigurationPath().toString(), TEST_CONTROLLER_FILE_BAK);
 
-        final Path policyEnginePath = Paths.get(OTHER_CONFIG_DIR, POLICY_ENGINE_PROPERTIES_FILE);
+        final Path policyEnginePath = Paths.get(OTHER_CONFIG_DIR, FileSystemPersistence.PROPERTIES_FILE_ENGINE);
         final Path environmentPath = Paths.get(OTHER_CONFIG_DIR, ENV_PROPS_FILE);
+        final Path systemPath = Paths.get(OTHER_CONFIG_DIR, SYSTEM_PROPS_FILE);
 
-        Files.deleteIfExists(testControllerPath);
         Files.deleteIfExists(testControllerBakPath);
         Files.deleteIfExists(policyEnginePath);
         Files.deleteIfExists(environmentPath);
+        Files.deleteIfExists(systemPath);
     }
 
 }
index 4b8357a..8050b26 100644 (file)
@@ -368,6 +368,16 @@ public class PolicyEngineManagerTest {
 
         assertNotNull(mgr.getEnvironmentProperty("PATH"));
         assertNull(mgr.getEnvironmentProperty("unknown-env-property"));
+
+        System.setProperty("propS-a", "valueS-a");
+        assertEquals("valueS-a", mgr.getEnvironmentProperty("propS-a"));
+
+        Properties props3 = new Properties();
+        props3.put("prop3-a", "${env:HOME}");
+        mgr.setEnvironment(props3);
+        assertEquals(System.getenv("HOME"), mgr.getEnvironmentProperty("prop3-a"));
+        assertEquals("valueS-a", mgr.getEnvironmentProperty("propS-a"));
+        assertEquals(newValue, mgr.getEnvironmentProperty(propKey));
     }
 
     @Test
index a00d6db..64af6d4 100644 (file)
@@ -163,7 +163,7 @@ public class PolicyEngineTest {
         PolicyEngine.manager.configure(engineProps);
         assertFalse(PolicyEngine.manager.isAlive());
 
-        logger.info("policy-engine {} has configuration {}", PolicyEngine.manager, engineProps);
+        logger.info("engine {} has configuration {}", PolicyEngine.manager, engineProps);
 
         gson.compareGson(PolicyEngine.manager, new File(PolicyEngineTest.class.getSimpleName() + "Config.json"));
     }
index 3891c85..8594995 100644 (file)
@@ -32,6 +32,7 @@ import java.util.Timer;
 import java.util.TimerTask;
 
 import org.apache.commons.configuration2.ConfigurationConverter;
+import org.apache.commons.configuration2.SystemConfiguration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -77,12 +78,12 @@ public class PropertyUtil {
          * builders since they use the commons-beanutils (optional) library that has been
          * flagged as insecured.
          */
-        return ConfigurationConverter.getProperties(ConfigurationConverter.getConfiguration(rval));
+        return getInterpolatedProperties(rval);
     }
 
     /**
      * Read in a properties file.
-     * 
+     *
      * @param fileName the properties file
      * @return a Properties object, containing the associated properties
      * @throws IOException - subclass 'FileNotFoundException' if the file
@@ -93,6 +94,88 @@ public class PropertyUtil {
         return getProperties(new File(fileName));
     }
 
+    /**
+     * Read in a properties file, and register for update notifications.
+     * NOTE: it is possible that the first callback will occur while this
+     * method is still in progress. To avoid this problem, use 'synchronized'
+     * blocks around this invocation and in the callback -- that will ensure
+     * that the processing of the initial properties complete before any
+     * updates are processed.
+     *
+     * @param file the properties file
+     * @param listener notify if not null, this is a callback interface that is used for
+     *     notifications of changes
+     * @return a Properties object, containing the associated properties
+     * @throws IOException - subclass 'FileNotFoundException' if the file
+     *     does not exist or can't be opened, and 'IOException' if there is
+     *     a problem loading the properties file.
+     */
+    public static Properties getProperties(File file, Listener listener)
+        throws IOException {
+        File propFile = file;
+        if (listener == null) {
+            // no listener specified -- just fetch the properties
+            return getProperties(propFile);
+        }
+
+        // Convert the file to a canonical form in order to avoid the situation
+        // where different names refer to the same file.
+        propFile = propFile.getCanonicalFile();
+
+        // See if there is an existing registration. The 'synchronized' block
+        // is needed to handle the case where a new listener is added at about
+        // the same time that another one is being removed.
+        synchronized (registrations) {
+            ListenerRegistration reg = registrations.get(propFile);
+            if (reg == null) {
+                // a new registration is needed
+                reg = new ListenerRegistration(propFile);
+            }
+            return reg.addListener(listener);
+        }
+    }
+
+    /**
+     * Read in a properties file, and register for update notifications.
+     * NOTE: it is possible that the first callback will occur while this
+     * method is still in progress. To avoid this problem, use 'synchronized'
+     * blocks around this invocation and in the callback -- that will ensure
+     * that the processing of the initial properties complete before any
+     * updates are processed.
+     *
+     * @param fileName the properties file
+     * @param listener notify if not null, this is a callback interface that is used for
+     *     notifications of changes
+     * @return a Properties object, containing the associated properties
+     * @throws IOException - subclass 'FileNotFoundException' if the file
+     *     does not exist or can't be opened, and 'IOException' if there is
+     *     a problem loading the properties file.
+     */
+    public static Properties getProperties(String fileName, Listener listener)
+        throws IOException {
+        return getProperties(new File(fileName), listener);
+    }
+
+    /**
+     * gets interpolated properties from a properties object.
+     *
+     * @param properties object
+     * @return properties
+     */
+    public static Properties getInterpolatedProperties(Properties properties) {
+        return ConfigurationConverter.getProperties(ConfigurationConverter.getConfiguration(properties));
+    }
+
+    /**
+     * sets system properties from a properties file.
+     *
+     * @param properties properties file
+     */
+    public static void setSystemProperties(Properties properties) {
+        Properties interpolatedProps = getInterpolatedProperties(properties);
+        SystemConfiguration.setSystemProperties(ConfigurationConverter.getConfiguration(interpolatedProps));
+    }
+
     /* ============================================================ */
 
     /**
@@ -276,68 +359,6 @@ public class PropertyUtil {
         }
     }
 
-    /**
-     * Read in a properties file, and register for update notifications.
-     * NOTE: it is possible that the first callback will occur while this
-     * method is still in progress. To avoid this problem, use 'synchronized'
-     * blocks around this invocation and in the callback -- that will ensure
-     * that the processing of the initial properties complete before any
-     * updates are processed.
-     *
-     * @param file the properties file
-     * @param listener notify if not null, this is a callback interface that is used for
-     *     notifications of changes
-     * @return a Properties object, containing the associated properties
-     * @throws IOException - subclass 'FileNotFoundException' if the file
-     *     does not exist or can't be opened, and 'IOException' if there is
-     *     a problem loading the properties file.
-     */
-    public static Properties getProperties(File file, Listener listener)
-            throws IOException {
-        File propFile = file;
-        if (listener == null) {
-            // no listener specified -- just fetch the properties
-            return getProperties(propFile);
-        }
-
-        // Convert the file to a canonical form in order to avoid the situation
-        // where different names refer to the same file.
-        propFile = propFile.getCanonicalFile();
-
-        // See if there is an existing registration. The 'synchronized' block
-        // is needed to handle the case where a new listener is added at about
-        // the same time that another one is being removed.
-        synchronized (registrations) {
-            ListenerRegistration reg = registrations.get(propFile);
-            if (reg == null) {
-                // a new registration is needed
-                reg = new ListenerRegistration(propFile);
-            }
-            return reg.addListener(listener);
-        }
-    }
-
-    /**
-     * Read in a properties file, and register for update notifications.
-     * NOTE: it is possible that the first callback will occur while this
-     * method is still in progress. To avoid this problem, use 'synchronized'
-     * blocks around this invocation and in the callback -- that will ensure
-     * that the processing of the initial properties complete before any
-     * updates are processed.
-     *
-     * @param fileName the properties file
-     * @param listener notify if not null, this is a callback interface that is used for
-     *     notifications of changes
-     * @return a Properties object, containing the associated properties
-     * @throws IOException - subclass 'FileNotFoundException' if the file
-     *     does not exist or can't be opened, and 'IOException' if there is
-     *     a problem loading the properties file.
-     */
-    public static Properties getProperties(String fileName, Listener listener)
-            throws IOException {
-        return getProperties(new File(fileName), listener);
-    }
-
     /**
      * Stop listenening for updates.
      * 
index 0fe848c..1697f69 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP
  * ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,6 +30,16 @@ import org.slf4j.MarkerFactory;
  */
 public class LoggerUtil {
 
+    /**
+     * Logback configuration file system property.
+     */
+    public static final String LOGBACK_CONFIGURATION_FILE_SYSTEM_PROPERTY = "logback.configurationFile";
+
+    /**
+     * Logback default configuration file location.
+     */
+    public static final String LOGBACK_CONFIGURATION_FILE_DEFAULT = "config/logback.xml";
+
     /**
      * Root logger.
      */
@@ -55,7 +65,6 @@ public class LoggerUtil {
      */
     public static final Marker TRANSACTION_LOG_MARKER = MarkerFactory.getMarker(TRANSACTION_LOG_MARKER_NAME);
 
-
     private LoggerUtil() {
         // Empty constructor
     }
index 2d5d356..f05974c 100644 (file)
@@ -79,7 +79,7 @@ public class PropertyUtilTest {
      * Utility method to write a properties file.
      *
      * @param name the file name, relative to the temporary directory
-     * @param the properties to store in the file
+     * @param properties to store in the file
      * @return a File instance associated with the newly-created file
      * @throws IOException if the file can't be created for some reason
      */
@@ -137,10 +137,24 @@ public class PropertyUtilTest {
         assertEquals(prop1, prop2);
 
         Properties prop3 = PropertyUtil.getProperties(INTERPOLATION_PROPERTIES);
+
         assertEquals("no", prop3.getProperty(INTERPOLATION_NO));
         assertEquals(System.getenv("HOME"), prop3.getProperty(INTERPOLATION_ENV));
         assertEquals(LoggerUtil.ROOT_LOGGER, prop3.getProperty(INTERPOLATION_CONST));
         assertEquals(System.getProperty("user.home"), prop3.getProperty(INTERPOLATION_SYS));
+
+        Properties prop4 = new Properties();
+        prop4.put(INTERPOLATION_NO, "no");
+        prop4.put(INTERPOLATION_ENV, "${env:HOME}");
+        prop4.put(INTERPOLATION_CONST, "${const:org.onap.policy.drools.utils.logging.LoggerUtil.ROOT_LOGGER}");
+        prop4.put(INTERPOLATION_SYS, "${sys:user.home}");
+
+        PropertyUtil.setSystemProperties(prop4);
+
+        assertEquals("no", System.getProperty(INTERPOLATION_NO));
+        assertEquals(System.getenv("HOME"), System.getProperty(INTERPOLATION_ENV));
+        assertEquals(LoggerUtil.ROOT_LOGGER, System.getProperty(INTERPOLATION_CONST));
+        assertEquals(System.getProperty("user.home"), System.getProperty(INTERPOLATION_SYS));
     }
 
     /**