aboutsummaryrefslogtreecommitdiffstats
path: root/sliPluginUtils
diff options
context:
space:
mode:
Diffstat (limited to 'sliPluginUtils')
-rw-r--r--sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml65
-rw-r--r--sliPluginUtils/features/features-sliPluginUtils/pom.xml29
-rwxr-xr-xsliPluginUtils/features/pom.xml130
-rw-r--r--sliPluginUtils/features/src/main/resources/features.xml38
-rwxr-xr-xsliPluginUtils/installer/pom.xml23
-rwxr-xr-xsliPluginUtils/pom.xml38
-rwxr-xr-xsliPluginUtils/provider/pom.xml47
-rw-r--r--sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2PropertiesProvider.java421
-rw-r--r--sliPluginUtils/provider/src/main/resources/dme2.properties7
9 files changed, 388 insertions, 410 deletions
diff --git a/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml
new file mode 100644
index 00000000..8ea5ca86
--- /dev/null
+++ b/sliPluginUtils/features/ccsdk-sliPluginUtils/pom.xml
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onap.ccsdk.parent</groupId>
+ <artifactId>single-feature-parent</artifactId>
+ <version>1.0.1-SNAPSHOT</version>
+ <relativePath/>
+ </parent>
+
+ <groupId>org.onap.ccsdk.sli.core</groupId>
+ <artifactId>ccsdk-sliPluginUtils</artifactId>
+ <version>0.2.1-SNAPSHOT</version>
+ <packaging>feature</packaging>
+
+ <name>ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId}</name>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.mdsal.model</groupId>
+ <artifactId>mdsal-model-artifacts</artifactId>
+ <version>0.11.1</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>mdsal-artifacts</artifactId>
+ <version>1.6.1</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>odl-mdsal-broker</artifactId>
+ <type>xml</type>
+ <classifier>features</classifier>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>ccsdk-sli</artifactId>
+ <version>${project.version}</version>
+ <type>xml</type>
+ <classifier>features</classifier>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>sliPluginUtils-provider</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>equinoxSDK381</groupId>
+ <artifactId>org.eclipse.osgi</artifactId>
+ <version>${equinox.osgi.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/sliPluginUtils/features/features-sliPluginUtils/pom.xml b/sliPluginUtils/features/features-sliPluginUtils/pom.xml
new file mode 100644
index 00000000..004277dd
--- /dev/null
+++ b/sliPluginUtils/features/features-sliPluginUtils/pom.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onap.ccsdk.parent</groupId>
+ <artifactId>feature-repo-parent</artifactId>
+ <version>1.0.1-SNAPSHOT</version>
+ <relativePath/>
+ </parent>
+
+ <groupId>org.onap.ccsdk.sli.core</groupId>
+ <artifactId>features-sliPluginUtils</artifactId>
+ <version>0.2.1-SNAPSHOT</version>
+ <packaging>feature</packaging>
+
+ <name>ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId}</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>ccsdk-sliPluginUtils</artifactId>
+ <version>${project.version}</version>
+ <type>xml</type>
+ <classifier>features</classifier>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/sliPluginUtils/features/pom.xml b/sliPluginUtils/features/pom.xml
index 19d32f7a..4a1f8994 100755
--- a/sliPluginUtils/features/pom.xml
+++ b/sliPluginUtils/features/pom.xml
@@ -1,127 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <artifactId>sliPluginUtils-features</artifactId>
- <packaging>jar</packaging>
<modelVersion>4.0.0</modelVersion>
<parent>
- <artifactId>sliPluginUtils</artifactId>
- <groupId>org.onap.ccsdk.sli.core</groupId>
- <version>0.2.0-SNAPSHOT</version>
+ <groupId>org.onap.ccsdk.parent</groupId>
+ <artifactId>odlparent-lite</artifactId>
+ <version>1.0.1-SNAPSHOT</version>
+ <relativePath/>
</parent>
- <name>SliPluginUtils Plugin - Features</name>
-
- <dependencies>
- <dependency>
- <groupId>org.onap.ccsdk.sli.core</groupId>
- <artifactId>sliPluginUtils-provider</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- <version>${commons.lang.version}</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>features-mdsal</artifactId>
- <version>${odl.mdsal.features.version}</version>
- <classifier>features</classifier>
- <type>xml</type>
- <scope>runtime</scope>
- </dependency>
- <!-- dependency for opendaylight-karaf-empty for use by testing -->
- <dependency>
- <groupId>org.opendaylight.odlparent</groupId>
- <artifactId>opendaylight-karaf-empty</artifactId>
- <version>${odl.karaf.empty.distro.version}</version>
- <type>zip</type>
- </dependency>
- <dependency>
- <!-- Required for launching the feature tests -->
- <groupId>org.opendaylight.odlparent</groupId>
- <artifactId>features-test</artifactId>
- <version>${odl.commons.opendaylight.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>features-yangtools</artifactId>
- <version>${odl.yangtools.version}</version>
- <classifier>features</classifier>
- <type>xml</type>
- <scope>runtime</scope>
- </dependency>
- </dependencies>
-
- <build>
- <resources>
- <resource>
- <filtering>true</filtering>
- <directory>src/main/resources</directory>
- </resource>
- </resources>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-resources-plugin</artifactId>
- <executions>
- <execution>
- <id>filter</id>
- <goals>
- <goal>resources</goal>
- </goals>
- <phase>generate-resources</phase>
- </execution>
- </executions>
- </plugin>
+ <groupId>org.onap.ccsdk.sli.core</groupId>
+ <artifactId>sliPluginUtils-features</artifactId>
+ <version>0.2.1-SNAPSHOT</version>
+ <packaging>pom</packaging>
- <!-- launches the feature test, which validates that your karaf feature
- can be installed inside of a karaf container. It doesn't validate that your
- functionality works correctly, just that you have all of the dependent bundles
- defined correctly.
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <version>2.16</version>
- <configuration>
- <systemPropertyVariables>
- <karaf.distro.groupId>org.opendaylight.odlparent</karaf.distro.groupId>
- <karaf.distro.artifactId>opendaylight-karaf-empty</karaf.distro.artifactId>
- <karaf.distro.version>${odl.karaf.empty.distro.version}</karaf.distro.version>
- </systemPropertyVariables>
- <dependenciesToScan>
- <dependency>org.opendaylight.yangtools:features-test</dependency>
- </dependenciesToScan>
- </configuration>
- </plugin>
- -->
+ <name>ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId}</name>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>build-helper-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>attach-artifacts</id>
- <goals>
- <goal>attach-artifact</goal>
- </goals>
- <phase>package</phase>
- <configuration>
- <artifacts>
- <artifact>
- <file>${project.build.directory}/classes/${features.file}</file>
- <type>xml</type>
- <classifier>features</classifier>
- </artifact>
- </artifacts>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
+ <modules>
+ <module>features-sliPluginUtils</module>
+ <module>ccsdk-sliPluginUtils</module>
+ </modules>
</project>
diff --git a/sliPluginUtils/features/src/main/resources/features.xml b/sliPluginUtils/features/src/main/resources/features.xml
deleted file mode 100644
index f59cea42..00000000
--- a/sliPluginUtils/features/src/main/resources/features.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ============LICENSE_START=======================================================
- ONAP : CCSDK
- ================================================================================
- Copyright (C) 2017 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=========================================================
- -->
-
-
-<features name="sdnc-sliPluginUtils-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.2.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
-
- <repository>mvn:org.opendaylight.mdsal/features-mdsal/${odl.mdsal.features.version}/xml/features</repository>
-
-
- <feature name='sdnc-sliPluginUtils' description="sdnc-sliPluginUtils" version='${project.version}'>
- <!-- Most applications will have a dependency on the ODL MD-SAL Broker -->
- <feature version="${odl.mdsal.version}">odl-mdsal-broker</feature>
- <feature>sdnc-sli</feature>
- <bundle>mvn:org.onap.ccsdk.sli.core/sliPluginUtils-provider/${project.version}</bundle>
- </feature>
-
-</features>
diff --git a/sliPluginUtils/installer/pom.xml b/sliPluginUtils/installer/pom.xml
index 736d2220..1c0704af 100755
--- a/sliPluginUtils/installer/pom.xml
+++ b/sliPluginUtils/installer/pom.xml
@@ -1,18 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
+
<parent>
- <artifactId>sliPluginUtils</artifactId>
- <groupId>org.onap.ccsdk.sli.core</groupId>
- <version>0.2.0-SNAPSHOT</version>
+ <groupId>org.onap.ccsdk.parent</groupId>
+ <artifactId>odlparent-lite</artifactId>
+ <version>1.0.1-SNAPSHOT</version>
+ <relativePath/>
</parent>
+
+ <groupId>org.onap.ccsdl.sli.core</groupId>
<artifactId>sliPluginUtils-installer</artifactId>
- <name>SLI Plugin Utilities - Karaf Installer</name>
+ <version>0.2.1-SNAPSHOT</version>
<packaging>pom</packaging>
+ <name>ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId}</name>
+
<properties>
- <application.name>sdnc-sliPluginUtils</application.name>
- <features.boot>sdnc-sliPluginUtils</features.boot>
+ <application.name>ccsdk-sliPluginUtils</application.name>
+ <features.boot>${application.name}</features.boot>
<features.repositories>mvn:org.onap.ccsdk.sli.core/sliPluginUtils-features/${project.version}/xml/features</features.repositories>
<include.transitive.dependencies>false</include.transitive.dependencies>
</properties>
@@ -21,10 +27,10 @@
<dependency>
<groupId>org.onap.ccsdk.sli.core</groupId>
- <artifactId>sliPluginUtils-features</artifactId>
+ <artifactId>${application.name}</artifactId>
<version>${project.version}</version>
- <classifier>features</classifier>
<type>xml</type>
+ <classifier>features</classifier>
<exclusions>
<exclusion>
<groupId>*</groupId>
@@ -134,5 +140,4 @@
</plugins>
</build>
-
</project>
diff --git a/sliPluginUtils/pom.xml b/sliPluginUtils/pom.xml
index 21efb170..45be684f 100755
--- a/sliPluginUtils/pom.xml
+++ b/sliPluginUtils/pom.xml
@@ -1,38 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onap.ccsdk.parent</groupId>
+ <artifactId>odlparent-lite</artifactId>
+ <version>1.0.1-SNAPSHOT</version>
+ <relativePath/>
+ </parent>
<groupId>org.onap.ccsdk.sli.core</groupId>
<artifactId>sliPluginUtils</artifactId>
- <version>0.2.0-SNAPSHOT</version>
+ <version>0.2.1-SNAPSHOT</version>
<packaging>pom</packaging>
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.onap.ccsdk.sli.core</groupId>
- <artifactId>ccsdk-sli-core</artifactId>
- <version>0.2.0-SNAPSHOT</version>
- </parent>
- <name>Service Logic Interface Plugin Utilities</name>
+ <name>ccsdk-sli-core :: sliPluginUtils</name>
<description>A package of static utility functions to be used when developing SLI plugins</description>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.onap.ccsdk.sli.core</groupId>
- <artifactId>SliPluginUtils-features</artifactId>
- <classifier>features</classifier>
- <type>xml</type>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onap.ccsdk.sli.core</groupId>
- <artifactId>SliPluginUtils-provider</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
<modules>
<module>provider</module>
<module>features</module>
diff --git a/sliPluginUtils/provider/pom.xml b/sliPluginUtils/provider/pom.xml
index 61b5e958..0a274edd 100755
--- a/sliPluginUtils/provider/pom.xml
+++ b/sliPluginUtils/provider/pom.xml
@@ -1,17 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <artifactId>sliPluginUtils-provider</artifactId>
- <packaging>bundle</packaging>
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.onap.ccsdk.sli.core</groupId>
- <artifactId>sliPluginUtils</artifactId>
- <version>0.2.0-SNAPSHOT</version>
+ <groupId>org.onap.ccsdk.parent</groupId>
+ <artifactId>binding-parent</artifactId>
+ <version>1.0.1-SNAPSHOT</version>
+ <relativePath/>
</parent>
- <name>SliPluginUtils Plugin - Provider</name>
+ <groupId>org.onap.ccsdk.sli.core</groupId>
+ <artifactId>sliPluginUtils-provider</artifactId>
+ <version>0.2.1-SNAPSHOT</version>
+ <packaging>bundle</packaging>
+
+ <name>ccsdk-sli-core :: sliPluginUtils :: ${project.artifactId}</name>
<url>http://maven.apache.org</url>
<properties>
@@ -22,11 +25,10 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.onap.ccsdk.sli.core</groupId>
+ <groupId>${project.groupId}</groupId>
<artifactId>sli-common</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
@@ -34,22 +36,18 @@
<dependency>
<groupId>equinoxSDK381</groupId>
<artifactId>org.eclipse.osgi</artifactId>
- <version>${equinox.osgi.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
- <version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
- <version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
- <version>3.1</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
@@ -68,27 +66,4 @@
<version>1.1</version>
</dependency>
</dependencies>
-
- <build>
- <plugins>
-
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <version>${bundle.plugin.version}</version>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Bundle-SymbolicName>org.onap.ccsdk.sli.core.slipluginutils</Bundle-SymbolicName>
- <Export-Package>org.onap.ccsdk.sli.core.slipluginutils</Export-Package>
- <Import-Package>org.onap.ccsdk.sli.core.*,org.osgi.framework.*,org.slf4j.*,java.net.*</Import-Package>
- <Embed-Dependency>*;scope=compile|runtime;artifactId=!sli-common|org.eclipse.osgi|mariadb-java-client|slf4j-api|jcl-over-slf4j</Embed-Dependency>
- <Embed-Transitive>true</Embed-Transitive>
- </instructions>
- </configuration>
- </plugin>
-
- </plugins>
-
- </build>
</project>
diff --git a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2PropertiesProvider.java b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2PropertiesProvider.java
index 07c84c66..6802c9a8 100644
--- a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2PropertiesProvider.java
+++ b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2PropertiesProvider.java
@@ -8,9 +8,9 @@
* 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.
@@ -31,193 +31,248 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Optional;
import java.util.Properties;
+import java.util.Vector;
+import org.onap.ccsdk.sli.core.utils.JREFileResolver;
+import org.onap.ccsdk.sli.core.utils.KarafRootFileResolver;
+import org.onap.ccsdk.sli.core.utils.PropertiesFileResolver;
+import org.onap.ccsdk.sli.core.utils.common.CoreDefaultFileResolver;
+import org.onap.ccsdk.sli.core.utils.common.SdncConfigEnvVarFileResolver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * Immutable properties container for dme2 properties. Since the initial design decision was made to
- * utilize <code>Properties</code> instead of an OSGi <code>ManagedService</code>, it was decided
- * to make these properties immutable.
+ * Immutable properties container for dme2 properties. Since the initial design
+ * decision was made to utilize <code>Properties</code> instead of an OSGi
+ * <code>ManagedService</code>, it was decided to make these properties
+ * immutable.
*/
public final class Dme2PropertiesProvider {
- private static final Logger LOG = LoggerFactory.getLogger(Dme2PropertiesProvider.class);
-
- /**
- * The name of the environment variable to specify the configuration directory.
- */
- private static final String SDNC_ROOT_DIR_ENV_VAR_KEY = "SDNC_CONFIG_DIR";
-
- /**
- * the dme2 properties file name.
- */
- private static final String DME2_PROPERTIES_FILE_NAME = "dme2.properties";
-
- /**
- * the key for <code>proxyUrl</code>, which represents a CSV list of urls
- */
- static final String PROXY_URL_KEY = "proxyUrl";
-
- /**
- * indicates that proxy urls are separated by commas
- */
- private static final String PROXY_URLS_VALUE_SEPARATOR = ",";
-
- /**
- * the key for <code>aafUserName</code>
- */
- static final String AAF_USERNAME_KEY = "aafUserName";
-
- /**
- * the key for <code>aafPassword</code>
- */
- static final String AAF_PASSWORD_KEY = "aafPassword";
-
- /**
- * the key for <code>envContext</code>
- */
- static final String ENV_CONTEXT_KEY = "envContext";
-
- /**
- * the key for <code>routeOffer</code>
- */
- static final String ROUTE_OFFER_KEY = "routeOffer";
-
- /**
- * the key for <code>commonServiceVersion</code>
- */
- static final String COMMON_SERVICE_VERSION_KEY = "commonServiceVersion";
-
- /**
- * the key for <code>partner</code>
- */
- static final String PARTNER_KEY = "partner";
-
- private Optional<String []> proxyUrls = Optional.empty();
-
- private Optional<String> aafUsername = Optional.empty();
-
- private Optional<String> aafPassword = Optional.empty();
-
- private Optional<String> envContext = Optional.empty();
-
- private Optional<String> routeOffer = Optional.empty();
-
- private Optional<String> commonServiceVersion = Optional.empty();
-
- private Optional<String> partner = Optional.empty();
-
-
- /**
- * Instantiates the properties provider, which involves loading the appropriate properties for dme2.
- */
- public Dme2PropertiesProvider() {
- this(getDme2Path(SDNC_ROOT_DIR_ENV_VAR_KEY, DME2_PROPERTIES_FILE_NAME).toString());
- }
-
- /**
- * Instantiates the properties provider, which involves loading the appropriate properties for dme2.
- *
- * @param dme2Path location of the dme2.properties file
- */
- @VisibleForTesting
- Dme2PropertiesProvider(final String dme2Path) {
- final Properties properties;
- try {
- properties = getProperties(dme2Path);
- this.proxyUrls = getProxyUrls(properties);
- this.aafUsername = getAafUsername(properties);
- this.aafPassword = getAafPassword(properties);
- this.envContext = getEnvContext(properties);
- this.routeOffer = getRouteOffer(properties);
- this.commonServiceVersion = getCommonServiceVersion(properties);
- this.partner = getPartner(properties);
- } catch (final FileNotFoundException e) {
- LOG.error("dme2.properties file could not be found at path: {}", dme2Path, e);
- } catch (final IOException e) {
- LOG.error("fatal error reading dme2.properties at path: {}", dme2Path, e);
- }
- }
-
- private static Path getDme2Path(final String sdncRootDirectory, final String dme2Filename) {
- return Paths.get(sdncRootDirectory, dme2Filename);
- }
-
- private static Properties getProperties(final String dme2Path) throws IOException {
- final File dme2File = new File(dme2Path);
- final Properties properties = new Properties();
- properties.load(new FileReader(dme2File));
- return properties;
- }
-
- private String getProxyUrl(final Properties properties) {
- return properties.getProperty(PROXY_URL_KEY);
- }
-
- private Optional<String []> getProxyUrls(final Properties properties) {
- final String proxyUrlsValue = getProxyUrl(properties);
- if (!Strings.isNullOrEmpty(proxyUrlsValue)) {
- return Optional.ofNullable(proxyUrlsValue.split(PROXY_URLS_VALUE_SEPARATOR));
- }
- return Optional.empty();
- }
-
- public Optional<String []> getProxyUrls() {
- return this.proxyUrls;
- }
-
- private Optional<String> getAafUsername(final Properties properties) {
- final String aafUsernameValue = properties.getProperty(AAF_USERNAME_KEY);
- return Optional.ofNullable(aafUsernameValue);
- }
-
- Optional<String> getAafUsername() {
- return this.aafUsername;
- }
-
- private Optional<String> getAafPassword(final Properties properties) {
- final String aafPassword = properties.getProperty(AAF_PASSWORD_KEY);
- return Optional.ofNullable(aafPassword);
- }
-
- Optional<String> getAafPassword() {
- return this.aafPassword;
- }
-
- private Optional<String> getEnvContext(final Properties properties) {
- final String envContext = properties.getProperty(ENV_CONTEXT_KEY);
- return Optional.ofNullable(envContext);
- }
-
- Optional<String> getEnvContext() {
- return this.envContext;
- }
-
- private Optional<String> getRouteOffer(final Properties properties) {
- final String routeOffer = properties.getProperty(ROUTE_OFFER_KEY);
- return Optional.ofNullable(routeOffer);
- }
-
- Optional<String> getRouteOffer() {
- return this.routeOffer;
- }
-
- private Optional<String> getCommonServiceVersion(final Properties properties) {
- final String commonServiceVersion = properties.getProperty(COMMON_SERVICE_VERSION_KEY);
- return Optional.ofNullable(commonServiceVersion);
- }
-
- Optional<String> getCommonServiceVersion() {
- return this.commonServiceVersion;
- }
-
- private Optional<String> getPartner(final Properties properties) {
- final String partner = properties.getProperty(PARTNER_KEY);
- return Optional.ofNullable(partner);
- }
-
- Optional<String> getPartner() {
- return this.partner;
- }
+ private static final Logger LOG = LoggerFactory.getLogger(Dme2PropertiesProvider.class);
+
+ /**
+ * The name of the environment variable to specify the configuration directory.
+ */
+ private static final String SDNC_ROOT_DIR_ENV_VAR_KEY = "SDNC_CONFIG_DIR";
+
+ /**
+ * the dme2 properties file name.
+ */
+ private static final String DME2_PROPERTIES_FILE_NAME = "dme2.properties";
+
+ /**
+ * the key for <code>proxyUrl</code>, which represents a CSV list of urls
+ */
+ static final String PROXY_URL_KEY = "proxyUrl";
+
+ /**
+ * indicates that proxy urls are separated by commas
+ */
+ private static final String PROXY_URLS_VALUE_SEPARATOR = ",";
+
+ /**
+ * the key for <code>aafUserName</code>
+ */
+ static final String AAF_USERNAME_KEY = "aafUserName";
+
+ /**
+ * the key for <code>aafPassword</code>
+ */
+ static final String AAF_PASSWORD_KEY = "aafPassword";
+
+ /**
+ * the key for <code>envContext</code>
+ */
+ static final String ENV_CONTEXT_KEY = "envContext";
+
+ /**
+ * the key for <code>routeOffer</code>
+ */
+ static final String ROUTE_OFFER_KEY = "routeOffer";
+
+ /**
+ * the key for <code>commonServiceVersion</code>
+ */
+ static final String COMMON_SERVICE_VERSION_KEY = "commonServiceVersion";
+
+ /**
+ * the key for <code>partner</code>
+ */
+ static final String PARTNER_KEY = "partner";
+
+ private Optional<String[]> proxyUrls = Optional.empty();
+
+ private Optional<String> aafUsername = Optional.empty();
+
+ private Optional<String> aafPassword = Optional.empty();
+
+ private Optional<String> envContext = Optional.empty();
+
+ private Optional<String> routeOffer = Optional.empty();
+
+ private Optional<String> commonServiceVersion = Optional.empty();
+
+ private Optional<String> partner = Optional.empty();
+
+ /**
+ * A prioritized list of strategies for resolving dme2 properties files.
+ */
+ private Vector<PropertiesFileResolver> dme2PropertiesFileResolvers = new Vector<>();
+
+ /**
+ * Instantiates the properties provider, which involves loading the appropriate
+ * properties for dme2.
+ */
+ public Dme2PropertiesProvider() {
+ this(DME2_PROPERTIES_FILE_NAME);
+ }
+
+ /**
+ * Instantiates the properties provider, which involves loading the appropriate
+ * properties for dme2.
+ *
+ * @param dme2Path
+ * location of the dme2.properties file
+ */
+ @VisibleForTesting
+ Dme2PropertiesProvider(final String dme2FileName) {
+ dme2PropertiesFileResolvers
+ .add(new SdncConfigEnvVarFileResolver("Using property file (1) from environment variable"));
+ dme2PropertiesFileResolvers.add(new CoreDefaultFileResolver("Using property file (2) from default directory"));
+
+ dme2PropertiesFileResolvers
+ .add(new JREFileResolver("Using property file (3) from JRE argument", Dme2PropertiesProvider.class));
+ dme2PropertiesFileResolvers.add(new KarafRootFileResolver("Using property file (4) from karaf root", this));
+
+ File dme2File = getDme2File(dme2FileName);
+
+ init(dme2File);
+ }
+
+ private void init(final File dme2Path) {
+ final Properties properties;
+ try {
+ properties = getProperties(dme2Path);
+ this.proxyUrls = getProxyUrls(properties);
+ this.aafUsername = getAafUsername(properties);
+ this.aafPassword = getAafPassword(properties);
+ this.envContext = getEnvContext(properties);
+ this.routeOffer = getRouteOffer(properties);
+ this.commonServiceVersion = getCommonServiceVersion(properties);
+ this.partner = getPartner(properties);
+ } catch (final FileNotFoundException e) {
+
+ LOG.error("dme2.properties file could not be found at path: {}", dme2Path, e);
+ } catch (final IOException e) {
+ LOG.error("fatal error reading dme2.properties at path: {}", dme2Path, e);
+ }
+ }
+
+ /**
+ * Reports the method chosen for properties resolution to the
+ * <code>Logger</code>.
+ *
+ * @param message
+ * Some user friendly message
+ * @param fileOptional
+ * The file location of the chosen properties file
+ * @return the file location of the chosen properties file
+ */
+ private static File reportSuccess(final String message, final Optional<File> fileOptional) {
+ if (fileOptional.isPresent()) {
+ final File file = fileOptional.get();
+ LOG.info("{} {}", message, file.getPath());
+ return file;
+ }
+ return null;
+ }
+
+ private File getDme2File(final String dme2Filename) {
+
+ for (final PropertiesFileResolver dblibPropertiesFileResolver : dme2PropertiesFileResolvers) {
+ final Optional<File> fileOptional = dblibPropertiesFileResolver.resolveFile(dme2Filename);
+ if (fileOptional.isPresent()) {
+ return reportSuccess(dblibPropertiesFileResolver.getSuccessfulResolutionMessage(), fileOptional);
+ }
+ }
+ return (new File(dme2Filename));
+ }
+
+ private static Properties getProperties(final File dme2File) throws IOException {
+
+ final Properties properties = new Properties();
+ properties.load(new FileReader(dme2File));
+ return properties;
+ }
+
+ private String getProxyUrl(final Properties properties) {
+ return properties.getProperty(PROXY_URL_KEY);
+ }
+
+ private Optional<String[]> getProxyUrls(final Properties properties) {
+ final String proxyUrlsValue = getProxyUrl(properties);
+ if (!Strings.isNullOrEmpty(proxyUrlsValue)) {
+ return Optional.ofNullable(proxyUrlsValue.split(PROXY_URLS_VALUE_SEPARATOR));
+ }
+ return Optional.empty();
+ }
+
+ public Optional<String[]> getProxyUrls() {
+ return this.proxyUrls;
+ }
+
+ private Optional<String> getAafUsername(final Properties properties) {
+ final String aafUsernameValue = properties.getProperty(AAF_USERNAME_KEY);
+ return Optional.ofNullable(aafUsernameValue);
+ }
+
+ Optional<String> getAafUsername() {
+ return this.aafUsername;
+ }
+
+ private Optional<String> getAafPassword(final Properties properties) {
+ final String aafPassword = properties.getProperty(AAF_PASSWORD_KEY);
+ return Optional.ofNullable(aafPassword);
+ }
+
+ Optional<String> getAafPassword() {
+ return this.aafPassword;
+ }
+
+ private Optional<String> getEnvContext(final Properties properties) {
+ final String envContext = properties.getProperty(ENV_CONTEXT_KEY);
+ return Optional.ofNullable(envContext);
+ }
+
+ Optional<String> getEnvContext() {
+ return this.envContext;
+ }
+
+ private Optional<String> getRouteOffer(final Properties properties) {
+ final String routeOffer = properties.getProperty(ROUTE_OFFER_KEY);
+ return Optional.ofNullable(routeOffer);
+ }
+
+ Optional<String> getRouteOffer() {
+ return this.routeOffer;
+ }
+
+ private Optional<String> getCommonServiceVersion(final Properties properties) {
+ final String commonServiceVersion = properties.getProperty(COMMON_SERVICE_VERSION_KEY);
+ return Optional.ofNullable(commonServiceVersion);
+ }
+
+ Optional<String> getCommonServiceVersion() {
+ return this.commonServiceVersion;
+ }
+
+ private Optional<String> getPartner(final Properties properties) {
+ final String partner = properties.getProperty(PARTNER_KEY);
+ return Optional.ofNullable(partner);
+ }
+
+ Optional<String> getPartner() {
+ return this.partner;
+ }
}
diff --git a/sliPluginUtils/provider/src/main/resources/dme2.properties b/sliPluginUtils/provider/src/main/resources/dme2.properties
new file mode 100644
index 00000000..37344844
--- /dev/null
+++ b/sliPluginUtils/provider/src/main/resources/dme2.properties
@@ -0,0 +1,7 @@
+aafUserName=user@sample.com
+aafPassword=fake
+envContext=UAT
+routeOffer=UAT
+proxyUrl=http://sample.com:25055,http://sample.com:25055
+commonServiceVersion=1702.0
+partner= \ No newline at end of file