From 32fb53c13342d5ad353c839b7ffd0ca85d14bd48 Mon Sep 17 00:00:00 2001 From: Jessica Wagantall Date: Tue, 1 Dec 2020 11:48:20 -0800 Subject: Migrate sli-core files Migrate sli-core repo files into new directory "core". Signed-off-by: Jessica Wagantall --- utils/installer/pom.xml | 129 --------------------- .../src/assembly/assemble_installer_zip.xml | 39 ------- .../src/assembly/assemble_mvnrepo_zip.xml | 29 ----- .../src/main/resources/scripts/install-feature.sh | 18 --- utils/pom.xml | 27 ----- utils/provider/pom.xml | 49 -------- .../ccsdk/sli/core/utils/DefaultFileResolver.java | 61 ---------- .../ccsdk/sli/core/utils/EnvVarFileResolver.java | 76 ------------ .../onap/ccsdk/sli/core/utils/JREFileResolver.java | 111 ------------------ .../sli/core/utils/KarafRootFileResolver.java | 63 ---------- .../onap/ccsdk/sli/core/utils/PathValidator.java | 17 --- .../sli/core/utils/PropertiesFileResolver.java | 45 ------- .../utils/common/BundleContextFileResolver.java | 82 ------------- .../core/utils/common/CoreDefaultFileResolver.java | 41 ------- .../utils/common/SdncConfigEnvVarFileResolver.java | 38 ------ .../core/utils/dblib/DblibDefaultFileResolver.java | 25 ---- .../core/utils/dblib/DblibEnvVarFileResolver.java | 23 ---- .../ccsdk/sli/core/utils/JREFileResolverTest.java | 14 --- .../sli/core/utils/KarafRootFileResolverTest.java | 13 --- .../utils/common/BundleContexFileResolverTest.java | 16 --- .../utils/common/CoreDefaultFileResolverTest.java | 25 ---- .../common/SdncConfigEnvVarFileResolverTest.java | 24 ---- .../utils/dblib/DblibDefaultFileResolverTest.java | 25 ---- .../utils/dblib/DblibEnvVarFileResolverTest.java | 24 ---- 24 files changed, 1014 deletions(-) delete mode 100755 utils/installer/pom.xml delete mode 100755 utils/installer/src/assembly/assemble_installer_zip.xml delete mode 100755 utils/installer/src/assembly/assemble_mvnrepo_zip.xml delete mode 100644 utils/installer/src/main/resources/scripts/install-feature.sh delete mode 100755 utils/pom.xml delete mode 100644 utils/provider/pom.xml delete mode 100644 utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/DefaultFileResolver.java delete mode 100755 utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/EnvVarFileResolver.java delete mode 100755 utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/JREFileResolver.java delete mode 100644 utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/KarafRootFileResolver.java delete mode 100644 utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/PathValidator.java delete mode 100644 utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/PropertiesFileResolver.java delete mode 100755 utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/common/BundleContextFileResolver.java delete mode 100755 utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/common/CoreDefaultFileResolver.java delete mode 100755 utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/common/SdncConfigEnvVarFileResolver.java delete mode 100755 utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/dblib/DblibDefaultFileResolver.java delete mode 100644 utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/dblib/DblibEnvVarFileResolver.java delete mode 100644 utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/JREFileResolverTest.java delete mode 100644 utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/KarafRootFileResolverTest.java delete mode 100644 utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/common/BundleContexFileResolverTest.java delete mode 100644 utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/common/CoreDefaultFileResolverTest.java delete mode 100644 utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/common/SdncConfigEnvVarFileResolverTest.java delete mode 100644 utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/dblib/DblibDefaultFileResolverTest.java delete mode 100644 utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/dblib/DblibEnvVarFileResolverTest.java (limited to 'utils') diff --git a/utils/installer/pom.xml b/utils/installer/pom.xml deleted file mode 100755 index 829a33051..000000000 --- a/utils/installer/pom.xml +++ /dev/null @@ -1,129 +0,0 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - odlparent-lite - 2.1.0-SNAPSHOT - - - - org.onap.ccsdk.sli.core - utils-installer - 1.1.1-SNAPSHOT - pom - - ccsdk-sli-core :: utils :: ${project.artifactId} - - - ccsdk-slicore-utils - ${application.name} - mvn:org.onap.ccsdk.sli.core/${features.boot}/${project.version}/xml/features - false - - - - - - org.onap.ccsdk.sli.core - utils-provider - ${project.version} - - - - - - - - - maven-assembly-plugin - - - maven-repo-zip - - single - - package - - true - stage/${application.name}-${project.version} - - src/assembly/assemble_mvnrepo_zip.xml - - true - - - - installer-zip - - single - - package - - true - ${application.name}-${project.version}-installer - - src/assembly/assemble_installer_zip.xml - - false - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - copy-dependencies - - copy-dependencies - - prepare-package - - false - ${project.build.directory}/assembly/system - false - true - true - true - false - false - org.onap.ccsdk.sli,org.apache.tomcat - sli-common,sli-provider - provided - - - - - - maven-resources-plugin - 2.6 - - - copy-version - - copy-resources - - validate - - ${basedir}/target/stage - - - src/main/resources/scripts - - install-feature.sh - - true - - - - - - - - - - - diff --git a/utils/installer/src/assembly/assemble_installer_zip.xml b/utils/installer/src/assembly/assemble_installer_zip.xml deleted file mode 100755 index a6a22a9ba..000000000 --- a/utils/installer/src/assembly/assemble_installer_zip.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - bin - - - zip - - - - false - - - - target/stage/ - ${application.name} - 755 - - *.sh - - - - target/stage/ - ${application.name} - 644 - - *.sh - - - - - - - diff --git a/utils/installer/src/assembly/assemble_mvnrepo_zip.xml b/utils/installer/src/assembly/assemble_mvnrepo_zip.xml deleted file mode 100755 index 86b07f1f3..000000000 --- a/utils/installer/src/assembly/assemble_mvnrepo_zip.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - repo - - - zip - - - - false - - - - target/assembly/ - . - - - - - - - - diff --git a/utils/installer/src/main/resources/scripts/install-feature.sh b/utils/installer/src/main/resources/scripts/install-feature.sh deleted file mode 100644 index e16e79a12..000000000 --- a/utils/installer/src/main/resources/scripts/install-feature.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -ODL_HOME=${ODL_HOME:-/opt/opendaylight/current} -ODL_KARAF_CLIENT=${ODL_KARAF_CLIENT:-${ODL_HOME}/bin/client} -INSTALLERDIR=$(dirname $0) - -REPOZIP=${INSTALLERDIR}/${features.boot}-${project.version}.zip - -if [ -f ${REPOZIP} ] -then - unzip -d ${ODL_HOME} ${REPOZIP} -else - echo "ERROR : repo zip ($REPOZIP) not found" - exit 1 -fi - -${ODL_KARAF_CLIENT} feature:repo-add ${features.repositories} -${ODL_KARAF_CLIENT} feature:install ${features.boot} diff --git a/utils/pom.xml b/utils/pom.xml deleted file mode 100755 index b8c196cff..000000000 --- a/utils/pom.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - odlparent-lite - 2.1.0-SNAPSHOT - - - - org.onap.ccsdk.sli.core - utils - 1.1.1-SNAPSHOT - pom - - ccsdk-sli-core :: utils - Utilities used across sli-core - - ONAP - - - - provider - installer - - diff --git a/utils/provider/pom.xml b/utils/provider/pom.xml deleted file mode 100644 index 3d4fd856d..000000000 --- a/utils/provider/pom.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - binding-parent - 2.1.0-SNAPSHOT - - - - org.onap.ccsdk.sli.core - utils-provider - 1.1.1-SNAPSHOT - bundle - - ccsdk-sli-core :: utils :: ${project.artifactId} - - The SLI Core Utilities Package provides common functionality for setting up SLI connectivity. - - - ONAP - - - - - com.google.guava - guava - - - org.osgi - org.osgi.core - provided - - - - - org.mockito - mockito-core - test - - - junit - junit - ${junit.version} - test - - - diff --git a/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/DefaultFileResolver.java b/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/DefaultFileResolver.java deleted file mode 100644 index 8938aa6e7..000000000 --- a/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/DefaultFileResolver.java +++ /dev/null @@ -1,61 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * onap - * ================================================================================ - * Copyright (C) 2016 - 2017 ONAP - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.ccsdk.sli.core.utils; - -import java.io.File; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Optional; - -/** - * Resolves dblib properties files relative to the default file path. In Unix, this is represented by: - * /opt/sdnc/data/properties - */ -public abstract class DefaultFileResolver implements PropertiesFileResolver { - - private final String successMessage; - - private final Path propertyPath; - - public DefaultFileResolver(final String successMessage, final Path propertyPath) { - this.successMessage = successMessage; - this.propertyPath = propertyPath; - } - - /** - * Parse a properties file location based on the default properties location - * - * @return an Optional File containing the location if it exists, or an empty Optional - */ - @Override - public Optional resolveFile(final String filename) { - final File fileFromDefaultDblibDir = propertyPath.resolve(filename).toFile(); - if (fileFromDefaultDblibDir.exists()) { - return Optional.of(fileFromDefaultDblibDir); - } - return Optional.empty(); - } - - @Override - public String getSuccessfulResolutionMessage() { - return this.successMessage; - } -} diff --git a/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/EnvVarFileResolver.java b/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/EnvVarFileResolver.java deleted file mode 100755 index 518fb30d3..000000000 --- a/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/EnvVarFileResolver.java +++ /dev/null @@ -1,76 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * onap - * ================================================================================ - * Copyright (C) 2016 - 2017 ONAP - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.ccsdk.sli.core.utils; - -import com.google.common.base.Strings; - -import java.io.File; -import java.nio.file.Paths; -import java.util.Optional; - -/** - * Resolves properties files relative to the directory identified by the SDNC_CONFIG_DIR - * environment variable. If a system property with the same name is set it is given precedence. - */ -public abstract class EnvVarFileResolver implements PropertiesFileResolver { - - /** - * Key for environment variable representing the configuration directory - */ - private final String propertyKey; - - private final String successMessage; - - public EnvVarFileResolver(final String successMessage, final String propertyKey) { - this.successMessage = successMessage; - this.propertyKey = propertyKey; - } - - /** - * Parse a properties file location based on System environment variable - * - * @return an Optional File containing the location if it exists, or an empty Optional - */ - @Override - public Optional resolveFile(final String filename) { - // attempt to read the system property first - String propDirectoryFromEnvVariable = System.getProperty(propertyKey); - - if(propDirectoryFromEnvVariable == null) { - // attempt to resolve the property directory from the corresponding environment variable - propDirectoryFromEnvVariable = System.getenv(propertyKey); - } - - final File fileFromEnvVariable; - if (!Strings.isNullOrEmpty(propDirectoryFromEnvVariable)) { - fileFromEnvVariable = Paths.get(propDirectoryFromEnvVariable).resolve(filename).toFile(); - if(PathValidator.isValidPropertiesPath(fileFromEnvVariable.getAbsolutePath()) && fileFromEnvVariable.exists()) { - return Optional.of(fileFromEnvVariable); - } - } - return Optional.empty(); - } - - @Override - public String getSuccessfulResolutionMessage() { - return this.successMessage; - } -} diff --git a/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/JREFileResolver.java b/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/JREFileResolver.java deleted file mode 100755 index c4a4fca47..000000000 --- a/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/JREFileResolver.java +++ /dev/null @@ -1,111 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * onap - * ================================================================================ - * Copyright (C) 2016 - 2017 ONAP - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.ccsdk.sli.core.utils; - -import java.io.File; -import java.io.InputStream; -import java.net.URL; -import java.nio.file.CopyOption; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.StandardCopyOption; -import java.util.Optional; - -import org.osgi.framework.Bundle; -import org.osgi.framework.FrameworkUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Resolves project properties files relative to the directory identified by the JRE property - * dblib.properties. - */ -public class JREFileResolver implements PropertiesFileResolver { - - /** - * Key for JRE argument representing the configuration directory - */ - - private static final Logger LOGGER = LoggerFactory.getLogger(JREFileResolver.class); - private final String successMessage; - private final Class clazz; - - public JREFileResolver(final String successMessage, final Class clazz) { - this.successMessage = successMessage; - this.clazz = clazz; - } - - /** - * Parse a properties file location based on JRE argument - * - * @return an Optional File containing the location if it exists, or an empty Optional - */ - @Override - public Optional resolveFile(final String filename) { - - try { - - final Bundle bundle = FrameworkUtil.getBundle(this.clazz); - if (bundle == null) { - return Optional.empty(); - } - - URL jreArgumentEntry = bundle.getEntry(filename); - if (jreArgumentEntry == null) { - return Optional.empty(); - } - - - final File dataFile = bundle.getDataFile(filename); - if(dataFile.exists()) { - dataFile.delete(); - } - - try (InputStream input = jreArgumentEntry.openStream()){ - Files.copy(input, dataFile.toPath()); - } catch(Exception exc) { - return Optional.empty(); - } - - return Optional.of(dataFile); - } catch (final NoClassDefFoundError e) { - LOGGER.info("Getting /{} embedded with {}", filename, clazz.getCanonicalName()); - try (InputStream input = clazz.getResourceAsStream("/"+filename)) { - File propFile = File.createTempFile("tmp", ".properties", null); - LOGGER.info("Copying /{} to {}", filename, propFile.getAbsolutePath()); - Files.copy(input, propFile.toPath(), StandardCopyOption.REPLACE_EXISTING); - return Optional.of(propFile); - } catch (Exception e1) { - LOGGER.info("Caught exception getting {} embedded in jar", filename, e1); - return Optional.empty(); - } - } - catch(final Exception e) { - return Optional.empty(); - } - - } - - @Override - public String getSuccessfulResolutionMessage() { - return this.successMessage; - } -} diff --git a/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/KarafRootFileResolver.java b/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/KarafRootFileResolver.java deleted file mode 100644 index 0cb754504..000000000 --- a/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/KarafRootFileResolver.java +++ /dev/null @@ -1,63 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * onap - * ================================================================================ - * Copyright (C) 2016 - 2017 ONAP - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.ccsdk.sli.core.utils; - -import java.io.File; -import java.net.URL; -import java.util.Optional; - -/** - * Resolves dblib properties files relative to the karaf root directory. - */ -public class KarafRootFileResolver implements PropertiesFileResolver { - - final Object provider; - - private final String successMessage; - - public KarafRootFileResolver(final String successMessage, final Object provider) { - this.successMessage = successMessage; - this.provider = provider; - } - - /** - * Parse a properties file location relative to the karaf root - * - * @return an Optional File containing the location if it exists, or an empty Optional - */ - @Override - public Optional resolveFile(final String filename) { - final URL fromKarafRoot = provider.getClass().getResource(filename); - if (fromKarafRoot != null) { - final File propertiesFile = new File(fromKarafRoot.getFile()); - if (propertiesFile.exists()) { - return Optional.of(propertiesFile); - } - return Optional.empty(); - } - return Optional.empty(); - } - - @Override - public String getSuccessfulResolutionMessage() { - return this.successMessage; - } -} diff --git a/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/PathValidator.java b/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/PathValidator.java deleted file mode 100644 index 08f0fc050..000000000 --- a/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/PathValidator.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.onap.ccsdk.sli.core.utils; -import java.util.regex.Pattern; - -public class PathValidator { - public static boolean isValidXmlPath(String path) { - Pattern allowList = Pattern.compile("[-.\\w/\\/]+\\.xml$"); - return (allowList.matcher(path).matches()); - } - public static boolean isValidPropertiesPath(String path) { - Pattern allowList = Pattern.compile("[-.\\w/\\/]+\\.properties$"); - return (allowList.matcher(path).matches()); - } - public static boolean isValidFilePath(String path) { - Pattern allowList = Pattern.compile("[-.\\w/\\/]+$"); - return (allowList.matcher(path).matches()); - } -} diff --git a/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/PropertiesFileResolver.java b/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/PropertiesFileResolver.java deleted file mode 100644 index bfb417dca..000000000 --- a/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/PropertiesFileResolver.java +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * onap - * ================================================================================ - * Copyright (C) 2016 - 2017 ONAP - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.ccsdk.sli.core.utils; - -import java.io.File; -import java.util.Optional; - -/** - * Strategy for resolving dblib properties. - */ -public interface PropertiesFileResolver { - - /** - * Resolve dblib properties file. - * - * @param filename the name of the file to look for at the specific location. - * @return An optional File or empty. - */ - Optional resolveFile(final String filename); - - /** - * A success message, used only for logging now. - * - * @return a success message, used only for logging now. - */ - String getSuccessfulResolutionMessage(); -} diff --git a/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/common/BundleContextFileResolver.java b/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/common/BundleContextFileResolver.java deleted file mode 100755 index 356009f3f..000000000 --- a/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/common/BundleContextFileResolver.java +++ /dev/null @@ -1,82 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * onap - * ================================================================================ - * Copyright (C) 2016 - 2017 ONAP - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.ccsdk.sli.core.utils.common; - -import java.io.File; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Optional; - -import org.onap.ccsdk.sli.core.utils.PropertiesFileResolver; -import org.osgi.framework.FrameworkUtil; -import org.slf4j.LoggerFactory; - -import com.google.common.base.Strings; - -/** - * Resolves properties files from runtime property value SDNC_CONFIG_DIR defined in the osgi properties. - */ -public class BundleContextFileResolver implements PropertiesFileResolver { - - /** - * Key for osgi variable representing the configuration directory - */ - private static final String SDNC_CONFIG_DIR_PROP_KEY = "SDNC_CONFIG_DIR"; - - private final String successMessage; - private final Class clazz; - - public BundleContextFileResolver(final String successMessage, final Class clazz) { - this.successMessage = successMessage; - this.clazz = clazz; - } - - /** - * Parse a properties file location based on JRE argument - * - * @return an Optional File containing the location if it exists, or an empty Optional - */ - @Override - public Optional resolveFile(final String filename) { - try { - if (FrameworkUtil.getBundle(clazz) == null) { - return Optional.empty(); - } else { - final String pathProperty = FrameworkUtil.getBundle(this.clazz).getBundleContext() - .getProperty(SDNC_CONFIG_DIR_PROP_KEY); - if (Strings.isNullOrEmpty(pathProperty)) { - return Optional.empty(); - } - final Path dblibPath = Paths.get(pathProperty); - return Optional.of(dblibPath.resolve(filename).toFile()); - - } - } catch (Exception|NoClassDefFoundError e) { - LoggerFactory.getLogger(this.getClass()).error("", e); - return Optional.empty(); - } - } - - @Override - public String getSuccessfulResolutionMessage() { - return this.successMessage; - } -} diff --git a/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/common/CoreDefaultFileResolver.java b/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/common/CoreDefaultFileResolver.java deleted file mode 100755 index 4d7e90261..000000000 --- a/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/common/CoreDefaultFileResolver.java +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * onap - * ================================================================================ - * Copyright (C) 2016 - 2017 ONAP - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.ccsdk.sli.core.utils.common; - -import java.nio.file.Path; -import java.nio.file.Paths; - -import org.onap.ccsdk.sli.core.utils.DefaultFileResolver; - -/** - * Resolve properties file location based on the default directory name. - */ -public class CoreDefaultFileResolver extends DefaultFileResolver { - - /** - * Default path to look for the configuration directory - */ - private static final Path DEFAULT_DBLIB_PROP_DIR = Paths.get("/opt", "sdnc", "data", "properties"); - - public CoreDefaultFileResolver(final String successMessage) { - super(successMessage, DEFAULT_DBLIB_PROP_DIR); - } -} diff --git a/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/common/SdncConfigEnvVarFileResolver.java b/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/common/SdncConfigEnvVarFileResolver.java deleted file mode 100755 index 51b6134f7..000000000 --- a/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/common/SdncConfigEnvVarFileResolver.java +++ /dev/null @@ -1,38 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * onap - * ================================================================================ - * Copyright (C) 2016 - 2017 ONAP - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.ccsdk.sli.core.utils.common; - -import org.onap.ccsdk.sli.core.utils.EnvVarFileResolver; - -/** - * Resolve properties file location based on the default directory name. - */ -public class SdncConfigEnvVarFileResolver extends EnvVarFileResolver { - - /** - * Key for environment variable representing the configuration directory - */ - private static final String SDNC_CONFIG_DIR_PROP_KEY = "SDNC_CONFIG_DIR"; - - public SdncConfigEnvVarFileResolver(final String successMessage) { - super(successMessage, SDNC_CONFIG_DIR_PROP_KEY); - } -} diff --git a/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/dblib/DblibDefaultFileResolver.java b/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/dblib/DblibDefaultFileResolver.java deleted file mode 100755 index 082bdf403..000000000 --- a/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/dblib/DblibDefaultFileResolver.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.onap.ccsdk.sli.core.utils.dblib; - -import java.nio.file.Path; -import java.nio.file.Paths; -import org.onap.ccsdk.sli.core.utils.DefaultFileResolver; - -/** - * Resolve properties file location based on the default directory name. - * - * @deprecated - * This class has been replaced by generic version of this class - * {@link #CoreDefaultFileResolver} in common package. - */ -@Deprecated -public class DblibDefaultFileResolver extends DefaultFileResolver { - - /** - * Default path to look for the configuration directory - */ - private static final Path DEFAULT_DBLIB_PROP_DIR = Paths.get("/opt", "sdnc", "data", "properties"); - - public DblibDefaultFileResolver(final String successMessage) { - super(successMessage, DEFAULT_DBLIB_PROP_DIR); - } -} diff --git a/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/dblib/DblibEnvVarFileResolver.java b/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/dblib/DblibEnvVarFileResolver.java deleted file mode 100644 index 959271cb7..000000000 --- a/utils/provider/src/main/java/org/onap/ccsdk/sli/core/utils/dblib/DblibEnvVarFileResolver.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.onap.ccsdk.sli.core.utils.dblib; - -import org.onap.ccsdk.sli.core.utils.EnvVarFileResolver; - -/** - * Resolve properties file location based on the default directory name. - * - * @deprecated - * This class has been replaced by generic version of this class - * {@link #SdncConfigEnvVarFileResolver} in common package. - */ -@Deprecated -public class DblibEnvVarFileResolver extends EnvVarFileResolver { - - /** - * Key for environment variable representing the configuration directory - */ - private static final String SDNC_CONFIG_DIR_PROP_KEY = "SDNC_CONFIG_DIR"; - - public DblibEnvVarFileResolver(final String successMessage) { - super(successMessage, SDNC_CONFIG_DIR_PROP_KEY); - } -} diff --git a/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/JREFileResolverTest.java b/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/JREFileResolverTest.java deleted file mode 100644 index 8a066f057..000000000 --- a/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/JREFileResolverTest.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.onap.ccsdk.sli.core.utils; - -import static org.junit.Assert.assertEquals; -import org.junit.Test; - -public class JREFileResolverTest { - - @Test - public void getSuccessfulResolutionMessage() throws Exception { - final PropertiesFileResolver resolver = new JREFileResolver("success", JREFileResolverTest.class); - assertEquals("success", resolver.getSuccessfulResolutionMessage()); - } - -} \ No newline at end of file diff --git a/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/KarafRootFileResolverTest.java b/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/KarafRootFileResolverTest.java deleted file mode 100644 index df16b41d0..000000000 --- a/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/KarafRootFileResolverTest.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.onap.ccsdk.sli.core.utils; - -import static org.junit.Assert.assertEquals; -import org.junit.Test; - -public class KarafRootFileResolverTest { - @Test - public void getSuccessfulResolutionMessage() throws Exception { - final PropertiesFileResolver resolver = new KarafRootFileResolver("success", null); - assertEquals("success", resolver.getSuccessfulResolutionMessage()); - } - -} \ No newline at end of file diff --git a/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/common/BundleContexFileResolverTest.java b/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/common/BundleContexFileResolverTest.java deleted file mode 100644 index 7ddf550b0..000000000 --- a/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/common/BundleContexFileResolverTest.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.onap.ccsdk.sli.core.utils.common; - -import static org.junit.Assert.assertEquals; -import org.junit.Test; -import org.onap.ccsdk.sli.core.utils.PropertiesFileResolver; - -public class BundleContexFileResolverTest { - - @Test - public void getSuccessfulResolutionMessage() throws Exception { - final PropertiesFileResolver resolver = - new BundleContextFileResolver("success", BundleContexFileResolverTest.class); - assertEquals("success", resolver.getSuccessfulResolutionMessage()); - } - -} \ No newline at end of file diff --git a/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/common/CoreDefaultFileResolverTest.java b/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/common/CoreDefaultFileResolverTest.java deleted file mode 100644 index f1f5f2244..000000000 --- a/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/common/CoreDefaultFileResolverTest.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.onap.ccsdk.sli.core.utils.common; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import java.io.File; -import java.util.Optional; -import org.junit.Test; -import org.onap.ccsdk.sli.core.utils.PropertiesFileResolver; - -public class CoreDefaultFileResolverTest { - - @Test - public void resolveFile() throws Exception { - final PropertiesFileResolver resolver = new CoreDefaultFileResolver("success"); - final Optional file = resolver.resolveFile("doesnotexist.cfg"); - assertFalse(file.isPresent()); - } - - @Test - public void getSuccessfulResolutionMessage() throws Exception { - final PropertiesFileResolver resolver = new CoreDefaultFileResolver("success"); - assertEquals("success", resolver.getSuccessfulResolutionMessage()); - } - -} \ No newline at end of file diff --git a/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/common/SdncConfigEnvVarFileResolverTest.java b/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/common/SdncConfigEnvVarFileResolverTest.java deleted file mode 100644 index 130dc0a1e..000000000 --- a/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/common/SdncConfigEnvVarFileResolverTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.onap.ccsdk.sli.core.utils.common; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import java.io.File; -import java.util.Optional; -import org.junit.Test; -import org.onap.ccsdk.sli.core.utils.PropertiesFileResolver; - -public class SdncConfigEnvVarFileResolverTest { - @Test - public void resolveFile() throws Exception { - final PropertiesFileResolver resolver = new SdncConfigEnvVarFileResolver("success"); - final Optional file = resolver.resolveFile("doesnotexist.cfg"); - assertFalse(file.isPresent()); - } - - @Test - public void getSuccessfulResolutionMessage() throws Exception { - final PropertiesFileResolver resolver = new SdncConfigEnvVarFileResolver("success"); - assertEquals("success", resolver.getSuccessfulResolutionMessage()); - } - -} \ No newline at end of file diff --git a/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/dblib/DblibDefaultFileResolverTest.java b/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/dblib/DblibDefaultFileResolverTest.java deleted file mode 100644 index 834a8c449..000000000 --- a/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/dblib/DblibDefaultFileResolverTest.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.onap.ccsdk.sli.core.utils.dblib; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import java.io.File; -import java.util.Optional; -import org.junit.Test; -import org.onap.ccsdk.sli.core.utils.PropertiesFileResolver; - -public class DblibDefaultFileResolverTest { - - @Test - public void resolveFile() throws Exception { - final PropertiesFileResolver resolver = new DblibDefaultFileResolver("success"); - final Optional file = resolver.resolveFile("doesnotexist.cfg"); - assertFalse(file.isPresent()); - } - - @Test - public void getSuccessfulResolutionMessage() throws Exception { - final PropertiesFileResolver resolver = new DblibDefaultFileResolver("success"); - assertEquals("success", resolver.getSuccessfulResolutionMessage()); - } - -} \ No newline at end of file diff --git a/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/dblib/DblibEnvVarFileResolverTest.java b/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/dblib/DblibEnvVarFileResolverTest.java deleted file mode 100644 index b5150ab67..000000000 --- a/utils/provider/src/test/java/org/onap/ccsdk/sli/core/utils/dblib/DblibEnvVarFileResolverTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.onap.ccsdk.sli.core.utils.dblib; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import java.io.File; -import java.util.Optional; -import org.junit.Test; -import org.onap.ccsdk.sli.core.utils.PropertiesFileResolver; - -public class DblibEnvVarFileResolverTest { - @Test - public void resolveFile() throws Exception { - final PropertiesFileResolver resolver = new DblibEnvVarFileResolver("success"); - final Optional file = resolver.resolveFile("doesnotexist.cfg"); - assertFalse(file.isPresent()); - } - - @Test - public void getSuccessfulResolutionMessage() throws Exception { - final PropertiesFileResolver resolver = new DblibEnvVarFileResolver("success"); - assertEquals("success", resolver.getSuccessfulResolutionMessage()); - } - -} \ No newline at end of file -- cgit 1.2.3-korg