From 116667df3977935f02206b3ce16e8d117ffa7545 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Thu, 29 Aug 2019 10:49:50 -0400 Subject: Revert "Proposal to remove OSGi dependencies from the CCSDK project" This reverts commit b1dd81ede363508f83c86ed497b8c0815045f8e5. This commit contains a significant amount of new code with no jUnit testing, which drives our code coverage for this repo below mandatory 55% line coverage. Thus, this is not acceptable. Change-Id: I8a3196df31d0c86747bdb3facd963983276a66e2 Signed-off-by: Timoney, Dan (dt5972) --- saltstack-adapter/pom.xml | 1 - saltstack-adapter/saltstack-adapter-lighty/pom.xml | 53 ------- ...ltstackAdapterPropertiesProviderImplLighty.java | 175 --------------------- .../saltstack/lighty/SaltstackAdapterModule.java | 61 ------- 4 files changed, 290 deletions(-) delete mode 100755 saltstack-adapter/saltstack-adapter-lighty/pom.xml delete mode 100755 saltstack-adapter/saltstack-adapter-lighty/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/impl/SaltstackAdapterPropertiesProviderImplLighty.java delete mode 100644 saltstack-adapter/saltstack-adapter-lighty/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/lighty/SaltstackAdapterModule.java (limited to 'saltstack-adapter') diff --git a/saltstack-adapter/pom.xml b/saltstack-adapter/pom.xml index 5ae3ddde..57f86873 100644 --- a/saltstack-adapter/pom.xml +++ b/saltstack-adapter/pom.xml @@ -193,6 +193,5 @@ saltstack-adapter-provider saltstack-adapter-features saltstack-adapter-installer - saltstack-adapter-lighty diff --git a/saltstack-adapter/saltstack-adapter-lighty/pom.xml b/saltstack-adapter/saltstack-adapter-lighty/pom.xml deleted file mode 100755 index c82bf612..00000000 --- a/saltstack-adapter/saltstack-adapter-lighty/pom.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - 4.0.0 - - - org.onap.ccsdk.parent - binding-parent - 1.4.1-SNAPSHOT - - - - org.onap.ccsdk.sli.adaptors - saltstack-adapter-lighty - 0.6.1-SNAPSHOT - jar - - ccsdk-sli-adaptors :: netbox-client :: ${project.artifactId} - http://maven.apache.org - - - UTF-8 - - - - - - org.onap.ccsdk.sli.core - ccsdk-lighty-dependency-versions - ${project.version} - pom - import - - - - - - - io.lighty.core - lighty-controller - - - org.onap.ccsdk.sli.adaptors - saltstack-adapter-provider - ${project.version} - - - org.onap.ccsdk.sli.adaptors - saltstack-adapter-provider - ${project.version} - compile - - - diff --git a/saltstack-adapter/saltstack-adapter-lighty/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/impl/SaltstackAdapterPropertiesProviderImplLighty.java b/saltstack-adapter/saltstack-adapter-lighty/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/impl/SaltstackAdapterPropertiesProviderImplLighty.java deleted file mode 100755 index 0ea5a589..00000000 --- a/saltstack-adapter/saltstack-adapter-lighty/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/impl/SaltstackAdapterPropertiesProviderImplLighty.java +++ /dev/null @@ -1,175 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : CCSDK - * ================================================================================ - * Copyright (C) 2018 Samsung Electronics. 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========================================================= - */ - -package org.onap.ccsdk.sli.adaptors.saltstack.impl; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.Optional; -import java.util.Properties; -import java.util.Vector; -import org.onap.ccsdk.sli.adaptors.saltstack.SaltstackAdapterPropertiesProvider; -import org.onap.ccsdk.sli.core.sli.ConfigurationException; -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; - -/** - * THIS CLASS IS A COPY OF {@link SaltstackAdapterPropertiesProviderImpl} WITH REMOVED OSGi DEPENDENCIES - */ -public class SaltstackAdapterPropertiesProviderImplLighty implements SaltstackAdapterPropertiesProvider { - - private static final Logger LOG = LoggerFactory.getLogger(SaltstackAdapterPropertiesProviderImplLighty.class); - - /** - * The name of the properties file for database configuration - */ - private static final String SALTSTACKADAPTER_PROP_FILE_NAME = "saltstack-adapter.properties"; - - /** - * A prioritized list of strategies for resolving sql-resource properties files. - */ - private Vector saltstackAdapterPropertiesFileResolvers = new Vector<>(); - - /** - * The configuration properties for the db connection. - */ - private Properties properties; - - /** - * Set up the prioritized list of strategies for resolving dblib properties - * files. - */ - public SaltstackAdapterPropertiesProviderImplLighty() { - saltstackAdapterPropertiesFileResolvers - .add(new SdncConfigEnvVarFileResolver("Using property file (1) from environment variable")); - saltstackAdapterPropertiesFileResolvers.add(new CoreDefaultFileResolver("Using property file (2) from default directory")); - saltstackAdapterPropertiesFileResolvers.add(new KarafRootFileResolver("Using property file (4) from karaf root", this)); - - // determines properties file as according to the priority described in the - // class header comment - final File propertiesFile = determinePropertiesFile(this); - if (propertiesFile != null) { - try (FileInputStream fileInputStream = new FileInputStream(propertiesFile)) { - properties = new Properties(); - properties.load(fileInputStream); - } catch (final IOException e) { - LOG.error("Failed to load properties for file: {}", propertiesFile.toString(), - new ConfigurationException("Failed to load properties for file: " + propertiesFile.toString(), - e)); - } - } else { - // Try to read properties as resource - - InputStream propStr = getClass().getResourceAsStream("/" + SALTSTACKADAPTER_PROP_FILE_NAME); - if (propStr != null) { - properties = new Properties(); - try { - properties.load(propStr); - propStr.close(); - } catch (IOException e) { - properties = null; - } - } - - } - - if (properties == null) { - reportFailure("Missing configuration properties resource(3)", new ConfigurationException( - "Missing configuration properties resource(3): " + SALTSTACKADAPTER_PROP_FILE_NAME)); - - LOG.info("Defaulting org.onap.appc.adapter.saltstack.clientType to NONE"); - - properties = new Properties(); - properties.setProperty("org.onap.appc.adapter.saltstack.clientType", "NONE"); - } - } - - /** - * Reports the method chosen for properties resolution to the - * Logger. - * - * @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 fileOptional) { - if (fileOptional.isPresent()) { - final File file = fileOptional.get(); - LOG.info("{} {}", message, file.getPath()); - return file; - } - return null; - } - - /** - * Reports fatal errors. This is the case in which no properties file could be - * found. - * - * @param message An appropriate fatal error message - * @param configurationException An exception describing what went wrong during resolution - */ - private static void reportFailure(final String message, final ConfigurationException configurationException) { - - LOG.error("{}", message, configurationException); - } - - /** - * Extract svclogic config properties. - * - * @return the svclogic config properties - */ - public Properties getProperties() { - return properties; - } - - /** - * Determines the sql-resource properties file to use based on the following priority: - *
    - *
  1. A directory identified by the system environment variable - * SDNC_CONFIG_DIR
  2. - *
  3. The default directory DEFAULT_DBLIB_PROP_DIR
  4. - *
  5. A directory identified by the JRE argument - * sql-resource.properties
  6. - *
  7. A sql-resource.properties file located in the karaf root - * directory
  8. - *
- */ - File determinePropertiesFile(final SaltstackAdapterPropertiesProviderImplLighty resourceProvider) { - - for (final PropertiesFileResolver sliPropertiesFileResolver : saltstackAdapterPropertiesFileResolvers) { - final Optional fileOptional = sliPropertiesFileResolver.resolveFile(SALTSTACKADAPTER_PROP_FILE_NAME); - if (fileOptional.isPresent()) { - return reportSuccess(sliPropertiesFileResolver.getSuccessfulResolutionMessage(), fileOptional); - } - } - - return null; - } -} diff --git a/saltstack-adapter/saltstack-adapter-lighty/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/lighty/SaltstackAdapterModule.java b/saltstack-adapter/saltstack-adapter-lighty/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/lighty/SaltstackAdapterModule.java deleted file mode 100644 index 2f58d1f7..00000000 --- a/saltstack-adapter/saltstack-adapter-lighty/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/lighty/SaltstackAdapterModule.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * ============LICENSE_START========================================== - * Copyright (c) 2019 PANTHEON.tech s.r.o. - * =================================================================== - * 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.adaptors.saltstack.lighty; - -import io.lighty.core.controller.api.AbstractLightyModule; -import org.onap.ccsdk.sli.adaptors.saltstack.SaltstackAdapter; -import org.onap.ccsdk.sli.adaptors.saltstack.impl.SaltstackAdapterImpl; -import org.onap.ccsdk.sli.adaptors.saltstack.impl.SaltstackAdapterPropertiesProviderImplLighty; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * The implementation of the {@link io.lighty.core.controller.api.LightyModule} that manages and provides services from - * the saltstack-adapter-provider artifact. - */ -public class SaltstackAdapterModule extends AbstractLightyModule { - - private static final Logger LOG = LoggerFactory.getLogger(SaltstackAdapterModule.class); - - private SaltstackAdapterPropertiesProviderImplLighty salstackPropertiesProvider; - private SaltstackAdapterImpl saltstackAdapter; - - @Override - protected boolean initProcedure() { - this.salstackPropertiesProvider = new SaltstackAdapterPropertiesProviderImplLighty(); - try { - this.saltstackAdapter = new SaltstackAdapterImpl(salstackPropertiesProvider); - } catch (SvcLogicException e) { - LOG.error("Exception thrown while initializing {} in {}!", SaltstackAdapterImpl.class, this.getClass(), e); - } - return true; - } - - @Override - protected boolean stopProcedure() { - return true; - } - - public SaltstackAdapterPropertiesProviderImplLighty getSalstackPropertiesProvider() { - return this.salstackPropertiesProvider; - } - - public SaltstackAdapter getSaltstackAdapter() { - return saltstackAdapter; - } -} -- cgit 1.2.3-korg