aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2021-10-29 14:40:13 -0400
committerDan Timoney <dtimoney@att.com>2021-10-29 15:31:05 -0400
commitfcc85dc1e3c199c72a173dee04c216a17b7e86a7 (patch)
tree0ae58f20a19ef662c2bd8be8ab8990463693a2ff
parent012d5a145fa2b04554f53079731062f6c46f2d90 (diff)
Sync local changes to support GRA microservice
Sync changes made downstream to support GRA microservice Issue-ID: CCSDK-3504 Change-Id: I5fd99b978edb9598c5fe38f188635b365ad4e24c Signed-off-by: Dan Timoney <dtimoney@att.com>
-rw-r--r--ms/neng/pom.xml1
-rw-r--r--ms/pom.xml1
-rwxr-xr-xms/sliboot/src/main/dc/docker-compose.yaml6
-rw-r--r--ms/sliboot/src/main/java/org/onap/ccsdk/apps/ms/sliboot/FilterConfiguration.java66
-rw-r--r--ms/sliboot/src/main/java/org/onap/ccsdk/apps/ms/sliboot/SlibootApp.java6
-rw-r--r--services/src/main/java/org/onap/ccsdk/apps/filters/AuditLogFilter.java3
-rw-r--r--services/src/main/java/org/onap/ccsdk/apps/filters/ContentTypeFilter.java2
-rw-r--r--services/src/main/java/org/onap/ccsdk/apps/filters/PayloadLoggingFilter.java3
-rw-r--r--services/src/main/java/org/onap/ccsdk/apps/services/SvcLogicFactory.java247
9 files changed, 205 insertions, 130 deletions
diff --git a/ms/neng/pom.xml b/ms/neng/pom.xml
index ed283067..4a40ad17 100644
--- a/ms/neng/pom.xml
+++ b/ms/neng/pom.xml
@@ -18,6 +18,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
-->
+
<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>
diff --git a/ms/pom.xml b/ms/pom.xml
index 5eefe802..7912d7c0 100644
--- a/ms/pom.xml
+++ b/ms/pom.xml
@@ -18,6 +18,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
-->
+
<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>
diff --git a/ms/sliboot/src/main/dc/docker-compose.yaml b/ms/sliboot/src/main/dc/docker-compose.yaml
index 7b85745a..a6bd9b5a 100755
--- a/ms/sliboot/src/main/dc/docker-compose.yaml
+++ b/ms/sliboot/src/main/dc/docker-compose.yaml
@@ -30,11 +30,13 @@ services:
links:
- db:dbhost
environment:
- - MYSQL_HOST=dbhost
+ - MYSQL_DB_HOST=dbhost
+ - MYSQL_DB_USER=${MYSQL_USER}
+ - MYSQL_DB_PASSWD=${MYSQL_PASSWORD}
+ - MYSQL_DB_DATABASE=${MYSQL_DATABASE}
- MYSQL_USER=${MYSQL_USER}
- MYSQL_PASSWORD=${MYSQL_PASSWORD}
- MYSQL_DATABASE=${MYSQL_DATABASE}
- - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
- SDNC_CONFIG_DIR=/opt/onap/ccsdk/config
logging:
driver: "json-file"
diff --git a/ms/sliboot/src/main/java/org/onap/ccsdk/apps/ms/sliboot/FilterConfiguration.java b/ms/sliboot/src/main/java/org/onap/ccsdk/apps/ms/sliboot/FilterConfiguration.java
new file mode 100644
index 00000000..295953a4
--- /dev/null
+++ b/ms/sliboot/src/main/java/org/onap/ccsdk/apps/ms/sliboot/FilterConfiguration.java
@@ -0,0 +1,66 @@
+package org.onap.ccsdk.apps.ms.sliboot;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.Properties;
+
+import org.onap.aaf.cadi.filter.CadiFilter;
+import org.onap.ccsdk.sli.core.utils.common.EnvProperties;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.boot.web.servlet.FilterRegistrationBean;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.annotation.Order;
+
+@Configuration
+@ConditionalOnProperty("cadi.properties.path")
+public class FilterConfiguration {
+ private static final Logger log = LoggerFactory.getLogger(FilterConfiguration.class);
+
+ @Value( "${cadi.properties.path:none}" )
+ private String cadiPropFile;
+
+ @Bean
+ @Order(1)
+ public FilterRegistrationBean<CadiFilter> cadiFilter() {
+ CadiFilter filter = new CadiFilter();
+
+ FilterRegistrationBean<CadiFilter> registrationBean = new FilterRegistrationBean<>();
+ registrationBean.setFilter(filter);
+ if ("none".equals(cadiPropFile)) {
+ log.info("cadi.properties.path undefined, AAF CADI disabled");
+ registrationBean.setEnabled(false);
+ registrationBean.addUrlPatterns("/xxxx/*");
+ } else {
+ // Note: assume that cadi.properties.path specifies full path to properties file
+ File cadiFile = new File(cadiPropFile);
+ if (!cadiFile.exists()) {
+ log.info("cadi properties file {} not found, AAF CADI disabled", cadiPropFile);
+ registrationBean.setEnabled(false);
+ registrationBean.addUrlPatterns("/xxxx/*");
+ } else {
+ Properties cadiProperties = new EnvProperties();
+ try {
+ cadiProperties.load(new FileReader(cadiFile));
+ cadiProperties.forEach((k, v) -> {
+ registrationBean.addInitParameter((String) k, cadiProperties.getProperty((String) k));
+ });
+ registrationBean.addUrlPatterns("/*");
+ log.info("Installed and configured CADI filter");
+ } catch (IOException e) {
+ log.info("Caught exception loading cadi properties file {}, AAF CADI disabled", cadiPropFile, e);
+ registrationBean.setEnabled(false);
+ registrationBean.addUrlPatterns("/xxxx/*");
+ }
+ }
+
+ }
+
+ return registrationBean;
+ }
+
+}
diff --git a/ms/sliboot/src/main/java/org/onap/ccsdk/apps/ms/sliboot/SlibootApp.java b/ms/sliboot/src/main/java/org/onap/ccsdk/apps/ms/sliboot/SlibootApp.java
index 2bca1dbc..0fd23a9e 100644
--- a/ms/sliboot/src/main/java/org/onap/ccsdk/apps/ms/sliboot/SlibootApp.java
+++ b/ms/sliboot/src/main/java/org/onap/ccsdk/apps/ms/sliboot/SlibootApp.java
@@ -7,9 +7,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.
@@ -67,6 +67,6 @@ public class SlibootApp {
}
return registrationBean;
- }
+ }
}
diff --git a/services/src/main/java/org/onap/ccsdk/apps/filters/AuditLogFilter.java b/services/src/main/java/org/onap/ccsdk/apps/filters/AuditLogFilter.java
index b6d52c52..45ce55f4 100644
--- a/services/src/main/java/org/onap/ccsdk/apps/filters/AuditLogFilter.java
+++ b/services/src/main/java/org/onap/ccsdk/apps/filters/AuditLogFilter.java
@@ -7,7 +7,6 @@ import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.slf4j.MDC;
import org.springframework.stereotype.Component;
-@Component
public class AuditLogFilter extends AuditLogServletFilter {
private static final String MDC_HTTP_METHOD_KEY = "HttpMethod";
@@ -40,4 +39,4 @@ public class AuditLogFilter extends AuditLogServletFilter {
return null;
}
-} \ No newline at end of file
+}
diff --git a/services/src/main/java/org/onap/ccsdk/apps/filters/ContentTypeFilter.java b/services/src/main/java/org/onap/ccsdk/apps/filters/ContentTypeFilter.java
index 20f9ec47..f2f638f6 100644
--- a/services/src/main/java/org/onap/ccsdk/apps/filters/ContentTypeFilter.java
+++ b/services/src/main/java/org/onap/ccsdk/apps/filters/ContentTypeFilter.java
@@ -62,7 +62,7 @@ public class ContentTypeFilter implements Filter {
contentType = "application/json";
} else if ("application/yang-data+xml".equalsIgnoreCase(contentType)) {
contentType = "application/xml";
- } else if (contentType.startsWith("text/plain")) {
+ } else if (contentType.startsWith("text/plain") || contentType.startsWith("*/*")) {
// Use Accept header, if present, to determine content type.
boolean acceptsXml = false;
boolean acceptsJson = false;
diff --git a/services/src/main/java/org/onap/ccsdk/apps/filters/PayloadLoggingFilter.java b/services/src/main/java/org/onap/ccsdk/apps/filters/PayloadLoggingFilter.java
index e53c50a7..dd591fb7 100644
--- a/services/src/main/java/org/onap/ccsdk/apps/filters/PayloadLoggingFilter.java
+++ b/services/src/main/java/org/onap/ccsdk/apps/filters/PayloadLoggingFilter.java
@@ -36,7 +36,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
-@Component
public class PayloadLoggingFilter extends AbstractServletFilter implements Filter {
private static final Logger log = LoggerFactory.getLogger(PayloadLoggingFilter.class);
@@ -319,4 +318,4 @@ public class PayloadLoggingFilter extends AbstractServletFilter implements Filte
}
}
}
-} \ No newline at end of file
+}
diff --git a/services/src/main/java/org/onap/ccsdk/apps/services/SvcLogicFactory.java b/services/src/main/java/org/onap/ccsdk/apps/services/SvcLogicFactory.java
index 9ab5656c..54d612f6 100644
--- a/services/src/main/java/org/onap/ccsdk/apps/services/SvcLogicFactory.java
+++ b/services/src/main/java/org/onap/ccsdk/apps/services/SvcLogicFactory.java
@@ -20,8 +20,11 @@
package org.onap.ccsdk.apps.services;
+import java.io.File;
import java.io.FileInputStream;
+import java.io.FileReader;
import java.io.IOException;
+import java.io.InputStream;
import java.util.List;
import java.util.Properties;
@@ -41,6 +44,8 @@ import org.onap.ccsdk.sli.core.dblib.DBLIBResourceProvider;
import org.onap.ccsdk.sli.core.dblib.DBResourceManager;
import org.onap.ccsdk.sli.core.dblib.DbLibService;
import org.onap.ccsdk.sli.core.sli.ConfigurationException;
+import org.onap.ccsdk.sli.core.sli.SvcLogicAdaptor;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
import org.onap.ccsdk.sli.core.sli.SvcLogicLoader;
import org.onap.ccsdk.sli.core.sli.SvcLogicRecorder;
@@ -67,147 +72,149 @@ import org.springframework.stereotype.Service;
@Configuration
@Service
public class SvcLogicFactory {
- private static final Logger log = LoggerFactory.getLogger(SvcLogicFactory.class);
-
- @Autowired
- List<SvcLogicRecorder> recorders;
-
- @Autowired
- List<SvcLogicJavaPlugin> plugins;
-
- @Autowired
- List<SvcLogicResource> svcLogicResources;
+ private static final Logger log = LoggerFactory.getLogger(SvcLogicFactory.class);
+ private static final String SDNC_CONFIG_DIR = "SDNC_CONFIG_DIR";
+ private static final String CONTRAIL_PROPERTIES = "contrail-adaptor.properties";
+
+ @Autowired
+ List<SvcLogicRecorder> recorders;
+
+ @Autowired
+ List<SvcLogicJavaPlugin> plugins;
+
+ @Autowired
+ List<SvcLogicResource> svcLogicResources;
+
+
+ @Bean
+ public SvcLogicStore getStore() throws Exception {
+ SvcLogicPropertiesProvider propProvider = new SvcLogicPropertiesProvider() {
+
+ @Override
+ public Properties getProperties() {
+ Properties props = new Properties();
+
+ String propPath = System.getProperty("serviceLogicProperties", "");
+
+ if ("".equals(propPath)) {
+ propPath = System.getenv("SVCLOGIC_PROPERTIES");
+ }
+
+ if ((propPath == null) || propPath.length() == 0) {
+ propPath = "src/main/resources/svclogic.properties";
+ }
+ System.out.println(propPath);
+ try (FileInputStream fileInputStream = new FileInputStream(propPath)) {
+ props = new EnvProperties();
+ props.load(fileInputStream);
+ } catch (final IOException e) {
+ log.error("Failed to load properties for file: {}", propPath,
+ new ConfigurationException("Failed to load properties for file: " + propPath, e));
+ }
+ return props;
+ }
+ };
+ SvcLogicStore store = SvcLogicStoreFactory.getSvcLogicStore(propProvider.getProperties());
+ return store;
+ }
- @Bean
- public SvcLogicStore getStore() throws Exception {
- SvcLogicPropertiesProvider propProvider = new SvcLogicPropertiesProvider() {
+ @Bean
+ public SvcLogicLoader createLoader() throws Exception {
+ String serviceLogicDirectory = System.getProperty("serviceLogicDirectory");
+ if (serviceLogicDirectory == null) {
+ serviceLogicDirectory = "src/main/resources";
+ }
- @Override
- public Properties getProperties() {
- Properties props = new Properties();
+ System.out.println("serviceLogicDirectory is " + serviceLogicDirectory);
+ SvcLogicLoader loader = new SvcLogicLoader(serviceLogicDirectory, getStore());
+ try {
+ loader.loadAndActivate();
+ } catch (IOException e) {
+ log.error("Cannot load directed graphs", e);
+ }
+ return loader;
+ }
- String propPath = System.getProperty("serviceLogicProperties", "");
+ @Bean
+ public SvcLogicServiceBase createService() throws Exception {
+ HashMapResolver resolver = new HashMapResolver();
+ for (SvcLogicRecorder recorder : recorders) {
+ log.info("Registering SvcLogicRecorder {}", recorder.getClass().getName());
+ resolver.addSvcLogicRecorder(recorder.getClass().getName(), recorder);
- if ("".equals(propPath)) {
- propPath = System.getenv("SVCLOGIC_PROPERTIES");
}
+ for (SvcLogicJavaPlugin plugin : plugins) {
+ log.info("Registering SvcLogicJavaPlugin {}", plugin.getClass().getName());
+ resolver.addSvcLogicSvcLogicJavaPlugin(plugin.getClass().getName(), plugin);
- if ((propPath == null) || propPath.length() == 0) {
- propPath = "src/main/resources/svclogic.properties";
}
- System.out.println(propPath);
- try (FileInputStream fileInputStream = new FileInputStream(propPath)) {
- props = new EnvProperties();
- props.load(fileInputStream);
- } catch (final IOException e) {
- log.error("Failed to load properties for file: {}", propPath,
- new ConfigurationException("Failed to load properties for file: " + propPath, e));
+ for (SvcLogicResource svcLogicResource : svcLogicResources) {
+ log.info("Registering SvcLogicResource {}", svcLogicResource.getClass().getName());
+ resolver.addSvcLogicResource(svcLogicResource.getClass().getName(), svcLogicResource);
}
- return props;
- }
- };
- SvcLogicStore store = SvcLogicStoreFactory.getSvcLogicStore(propProvider.getProperties());
- return store;
- }
-
- @Bean
- public SvcLogicLoader createLoader() throws Exception {
- String serviceLogicDirectory = System.getProperty("serviceLogicDirectory");
- if (serviceLogicDirectory == null) {
- serviceLogicDirectory = "src/main/resources";
+
+ return new SvcLogicServiceImplBase(getStore(), resolver);
}
- System.out.println("serviceLogicDirectory is " + serviceLogicDirectory);
- SvcLogicLoader loader = new SvcLogicLoader(serviceLogicDirectory, getStore());
+ @Bean
+ public Slf4jRecorder slf4jRecorderNode() {
+ return new Slf4jRecorder();
+ }
- try {
- loader.loadAndActivate();
- } catch (IOException e) {
- log.error("Cannot load directed graphs", e);
+ // Beans from sli/core
+
+ @Bean
+ public SliPluginUtils sliPluginUtil() {
+ return new SliPluginUtils();
}
- return loader;
- }
- @Bean
- public SvcLogicServiceBase createService() throws Exception {
- HashMapResolver resolver = new HashMapResolver();
- for (SvcLogicRecorder recorder : recorders) {
- resolver.addSvcLogicRecorder(recorder.getClass().getName(), recorder);
+ @Bean
+ public SliStringUtils sliStringUtils() {
+ return new SliStringUtils();
+ }
+ // Beans from sli/adaptors
+
+ @Bean
+ AAIService aaiService() {
+ return new AAIService(new AAIServiceProvider());
+ }
+
+ @Bean
+ public ConfigResource configResource() {
+ return new ConfigResource(new MdsalResourcePropertiesProviderImpl());
+ }
+
+ @Bean
+ public OperationalResource operationalResource() {
+ return new OperationalResource(new MdsalResourcePropertiesProviderImpl());
}
- for (SvcLogicJavaPlugin plugin : plugins) {
- resolver.addSvcLogicSvcLogicJavaPlugin(plugin.getClass().getName(), plugin);
+ @Bean
+ public PublisherApi publisherApi() {
+ return new PublisherApiImpl();
}
- for (SvcLogicResource svcLogicResource : svcLogicResources) {
- resolver.addSvcLogicResource(svcLogicResource.getClass().getName(), svcLogicResource);
+
+ @Bean
+ public NetboxClient netboxClient() {
+ return new NetboxClientImpl();
}
- return new SvcLogicServiceImplBase(getStore(), resolver);
- }
-
- @Bean
- public Slf4jRecorder slf4jRecorderNode() {
- return new Slf4jRecorder();
- }
-
- // Beans from sli/core
-
- @Bean
- public SliPluginUtils sliPluginUtil() {
- return new SliPluginUtils();
- }
-
- @Bean
- public SliStringUtils sliStringUtils() {
- return new SliStringUtils();
- }
-
- // Beans from sli/adaptors
-
- @Bean AAIService aaiService() {
- return new AAIService(new AAIServiceProvider());
- }
-
- @Bean
- public ConfigResource configResource() {
- return new ConfigResource(new MdsalResourcePropertiesProviderImpl());
- }
-
- @Bean
- public OperationalResource operationalResource() {
- return new OperationalResource(new MdsalResourcePropertiesProviderImpl());
- }
-
- @Bean
- public PublisherApi publisherApi() {
- return new PublisherApiImpl();
- }
-
-
- @Bean
- public NetboxClient netboxClient() {
- return new NetboxClientImpl();
- }
-
-
- @Bean
- public SqlResource sqlResource() {
- return new SqlResource();
- }
-
-
- @Bean
- public RestapiCallNode restapiCallNode() {
- return new RestapiCallNode();
- }
-
- @Bean
- public PropertiesNode propertiesNode() {
- return new PropertiesNode();
- }
+ @Bean
+ public SqlResource sqlResource() {
+ return new SqlResource();
+ }
+ @Bean
+ public RestapiCallNode restapiCallNode() {
+ return new RestapiCallNode();
+ }
+
+ @Bean
+ public PropertiesNode propertiesNode() {
+ return new PropertiesNode();
+ }
}