From f175ecd3ba0a785ac1737ab3a4196d5141c05045 Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Fri, 10 May 2019 18:41:59 +0000 Subject: Remove DME2 plugin dme2 plugin was used to create dme2ingress proxy urls. This class is not generic enough to be useful to a wide audience. Change-Id: Iadc68d8f22393c3a9a5d21754137cae22b23fafe Issue-ID: CCSDK-1323 Signed-off-by: Smokowski, Kevin (ks6305) --- .../onap/ccsdk/sli/core/slipluginutils/DME2.java | 171 --------------------- .../ccsdk/sli/core/slipluginutils/Dme2Factory.java | 109 ------------- .../provider/src/main/resources/dme2.properties | 7 - .../blueprint/slipluginutils-blueprint.xml | 9 +- 4 files changed, 1 insertion(+), 295 deletions(-) delete mode 100644 sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/DME2.java delete mode 100644 sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2Factory.java delete mode 100644 sliPluginUtils/provider/src/main/resources/dme2.properties (limited to 'sliPluginUtils/provider/src/main') diff --git a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/DME2.java b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/DME2.java deleted file mode 100644 index 65b597e1..00000000 --- a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/DME2.java +++ /dev/null @@ -1,171 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : CCSDK - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights - * reserved. - * ================================================================================ - * Modifications Copyright (C) 2018 IBM. - * ================================================================================ - * 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.slipluginutils; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Properties; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * A SvcLogicJavaPlugin that generates DME2 proxy urls (for calling the DME2 ingress proxy) using - * parameters from context memory. - */ -public class DME2 implements SvcLogicJavaPlugin { - - private static final Logger LOG = LoggerFactory.getLogger(DME2.class); - // the key for proxyUrl, which represents a CSV list of urls - public static final String PROXY_URL_KEY = "proxyUrl"; - public static final String PROXY_URLS_VALUE_SEPARATOR = ","; - public static final String AAF_USERNAME_KEY = "aafUserName"; - public static final String AAF_PASSWORD_KEY = "aafPassword"; - public static final String ENV_CONTEXT_KEY = "envContext"; - public static final String ROUTE_OFFER_KEY = "routeOffer"; - public static final String COMMON_SERVICE_VERSION_KEY = "commonServiceVersion"; - public static final String PARTNER_KEY = "partner"; - public static final String VERSION_KEY = "version"; - public static final String SERVICE_KEY = "service"; - public static final String SUBCONTEXT_KEY = "subContext"; - public static final String ENDPOINT_READ_TIMEOUT_KEY = "endpointReadTimeout"; - public static final String OUTPUT_PATH_KEY = "outputPath"; - - final String aafUserName; - final String aafPassword; - final String envContext; - final String routeOffer; - final String[] proxyUrls; - final String commonServiceVersion; - final String partner; - final String endpointReadTimeout; - Integer index; - - public DME2(Properties properties) { - Iterator> it = properties.entrySet().iterator(); - while (it.hasNext()) { - Entry entry = it.next(); - if (entry.getValue() == null || entry.getValue().toString().length() < 1) { - it.remove(); - } - } - this.aafUserName = properties.getProperty(AAF_USERNAME_KEY, null); - this.aafPassword = properties.getProperty(AAF_PASSWORD_KEY, null); - this.envContext = properties.getProperty(ENV_CONTEXT_KEY, null); - this.routeOffer = properties.getProperty(ROUTE_OFFER_KEY, null); - this.commonServiceVersion = properties.getProperty(COMMON_SERVICE_VERSION_KEY, null); - this.partner = properties.getProperty(PARTNER_KEY, null); - this.endpointReadTimeout = properties.getProperty(ENDPOINT_READ_TIMEOUT_KEY, null); - String proxyUrlString = properties.getProperty(PROXY_URL_KEY, null); - if (proxyUrlString != null && proxyUrlString.length() > 0) { - this.proxyUrls = proxyUrlString.split(PROXY_URLS_VALUE_SEPARATOR); - } else { - String[] local = {"http://localhost:5000"}; - this.proxyUrls = local; - } - this.index = 0; - } - - // constructs a URL to contact the proxy which contacts a DME2 service - public String constructUrl(Map parameters) { - StringBuilder sb = new StringBuilder(); - - // The hostname is assigned in a round robin fashion - sb.append(acquireHostName()); - sb.append("/service=" + parameters.get(SERVICE_KEY)); - - // If the directedGraph passes an explicit version use that, if not use the commonServiceVersion - // found in the properties file - String version = parameters.get(VERSION_KEY); - if (version != null && version.length() > 0) { - sb.append("/version=" + version); - }else { - sb.append("/version=" + this.commonServiceVersion); - } - String envContext = parameters.getOrDefault(ENV_CONTEXT_KEY, this.envContext); - sb.append("/envContext=" + envContext); - - String routeOffer = parameters.getOrDefault(ROUTE_OFFER_KEY, this.routeOffer); - if (routeOffer != null && routeOffer.length() > 0) { - sb.append("/routeOffer=" + routeOffer); - } - - String subContext = parameters.get(SUBCONTEXT_KEY); - if (subContext != null && subContext.length() > 0) { - sb.append("/subContext=" + subContext); - } - sb.append("?dme2.password=" + this.aafPassword); - sb.append("&dme2.username=" + this.aafUserName); - if (this.partner != null) { - sb.append("&partner=" + this.partner); - } - sb.append("&dme2.allowhttpcode=true"); - String endpointReadTimeout = parameters.getOrDefault(ENDPOINT_READ_TIMEOUT_KEY, this.endpointReadTimeout); - if (endpointReadTimeout != null) { - sb.append("&dme2.endpointReadTimeout=" + endpointReadTimeout); - } - String incompleteUrl = sb.toString(); - - // Support optional parameters in a flexible way - for (Entry param : parameters.entrySet()) { - if (!incompleteUrl.contains(param.getKey() + "=") && param.getValue() != null - && param.getValue().length() > 0 && !OUTPUT_PATH_KEY.equals(param.getKey()) && !PARTNER_KEY.equals(param.getKey())) { - sb.append("&" + param.getKey() + "=" + param.getValue()); - } - } - return sb.toString(); - } - - public synchronized String acquireHostName() { - String retVal = proxyUrls[index]; - index++; - if (index == this.proxyUrls.length) { - index = 0; - } - return retVal; - } - - // Node entry point - public void constructUrl(Map parameters, SvcLogicContext ctx) throws SvcLogicException { - SliPluginUtils.checkParameters(parameters, new String[] {SERVICE_KEY, OUTPUT_PATH_KEY}, LOG); - String completeProxyUrl = constructUrl(parameters); - ctx.setAttribute(parameters.get(OUTPUT_PATH_KEY), completeProxyUrl); - } - - // Support legacy direct java call - public String constructUrl(String service, String version, String subContext) { - Map parameters = new HashMap<>(); - parameters.put(SERVICE_KEY, service); - if (version != null) { - parameters.put(VERSION_KEY, version); - } - parameters.put(SUBCONTEXT_KEY, subContext); - return constructUrl(parameters); - } - -} diff --git a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2Factory.java b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2Factory.java deleted file mode 100644 index 7013a9c5..00000000 --- a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/Dme2Factory.java +++ /dev/null @@ -1,109 +0,0 @@ -/*- - * ============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========================================================= - */ - -package org.onap.ccsdk.sli.core.slipluginutils; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; -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 Properties instead of an OSGi ManagedService, it was decided to - * make these properties immutable. - */ -public final class Dme2Factory { - - private static final Logger LOG = LoggerFactory.getLogger(Dme2Factory.class); - private static final String DME2_PROPERTIES_FILE_NAME = "dme2.properties"; - - static Properties properties; - private Vector dme2PropertiesFileResolvers = new Vector<>(); - - public Dme2Factory() { - 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", Dme2Factory.class)); - dme2PropertiesFileResolvers.add(new KarafRootFileResolver("Using property file (4) from karaf root", this)); - File dme2File = getDme2File(DME2_PROPERTIES_FILE_NAME); - init(dme2File); - } - - private void init(final File dme2propertiesFile) { - try { - properties = getProperties(dme2propertiesFile); - } catch (final FileNotFoundException e) { - LOG.error("dme2.properties file could not be found at path: {}", dme2propertiesFile, e); - } catch (final IOException e) { - LOG.error("fatal error reading dme2.properties at path: {}", dme2propertiesFile, e); - } - } - - /** - * 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; - } - - private File getDme2File(final String dme2Filename) { - for (final PropertiesFileResolver dblibPropertiesFileResolver : dme2PropertiesFileResolvers) { - final Optional 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; - } - - public DME2 createDme2() { - return new DME2(properties); - } - -} diff --git a/sliPluginUtils/provider/src/main/resources/dme2.properties b/sliPluginUtils/provider/src/main/resources/dme2.properties deleted file mode 100644 index 37344844..00000000 --- a/sliPluginUtils/provider/src/main/resources/dme2.properties +++ /dev/null @@ -1,7 +0,0 @@ -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 diff --git a/sliPluginUtils/provider/src/main/resources/org/opendaylight/blueprint/slipluginutils-blueprint.xml b/sliPluginUtils/provider/src/main/resources/org/opendaylight/blueprint/slipluginutils-blueprint.xml index 283dbbaa..534b92c9 100644 --- a/sliPluginUtils/provider/src/main/resources/org/opendaylight/blueprint/slipluginutils-blueprint.xml +++ b/sliPluginUtils/provider/src/main/resources/org/opendaylight/blueprint/slipluginutils-blueprint.xml @@ -10,11 +10,4 @@ - - - - - - - \ No newline at end of file + -- cgit 1.2.3-korg