From 370f5fe6f8c90bb35a9529f19d862e63a2cf8b9d Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Tue, 27 Oct 2020 16:47:24 -0400 Subject: Import SLI-API controller Import sliboot controller to implement SLI-API interface. Change-Id: Iea85a9cb128366fa0f580852d9f2fa71405a4bad Issue-ID: SDNC-1400 Signed-off-by: Dan Timoney --- ms/generic-resource-api/pom.xml | 30 ++++++-- .../sdnc/apps/ms/gra/GenericResourceMsApp.java | 87 ++++++++++++++++++++++ .../apps/ms/gra/core/GenericResourceMsApp.java | 78 ------------------- .../org/onap/sdnc/apps/ms/gra/core/WebConfig.java | 54 -------------- .../src/main/resources/schema-derby.sql | 4 +- .../ConfigApiPreloadControllerTest.java | 2 +- .../ConfigApiServicesControllerTest.java | 2 +- .../gra/controllers/GenericResourceMsAppTest.java | 2 +- .../controllers/OperationsApiControllerTest.java | 4 +- .../src/test/resources/application.properties | 5 +- .../src/test/resources/dblib.properties | 8 +- .../src/test/resources/svclogic.properties | 6 +- 12 files changed, 129 insertions(+), 153 deletions(-) create mode 100644 ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/GenericResourceMsApp.java delete mode 100644 ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/core/GenericResourceMsApp.java delete mode 100644 ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/core/WebConfig.java (limited to 'ms/generic-resource-api') diff --git a/ms/generic-resource-api/pom.xml b/ms/generic-resource-api/pom.xml index 8fc19cd..e4cecac 100644 --- a/ms/generic-resource-api/pom.xml +++ b/ms/generic-resource-api/pom.xml @@ -18,13 +18,13 @@ http://wiki.onap.org - org.onap.sdnc.apps.ms.gra.core.GenericResourceMsApp + org.onap.sdnc.apps.ms.gra.GenericResourceMsApp 1.5.0 2.1.13 - 1.0.0 - 1.0-STAGING-latest - 2.0.1 - 2.0.1 + 1.1.0-SNAPSHOT + 1.1-STAGING-latest + 2.1.0-SNAPSHOT + 2.1.0-SNAPSHOT onap/ccsdk-alpine-j11-image onap/sdnc-gra-image @@ -94,6 +94,11 @@ services ${ccsdk.apps.version} + + org.onap.ccsdk.apps + sliboot + ${ccsdk.apps.version} + org.onap.ccsdk.sli.core sli-common @@ -118,6 +123,21 @@ sliPluginUtils-provider ${ccsdk.sli.core.version} + + org.onap.ccsdk.sli.adaptors + mdsal-resource-provider + ${ccsdk.sli.adaptors.version} + + + org.onap.ccsdk.sli.adaptors.messagerouter + publisher.provider + ${ccsdk.sli.adaptors.version} + + + org.onap.ccsdk.sli.adaptors + netbox-client-provider + ${ccsdk.sli.adaptors.version} + org.onap.ccsdk.sli.adaptors sql-resource-provider diff --git a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/GenericResourceMsApp.java b/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/GenericResourceMsApp.java new file mode 100644 index 0000000..9501f99 --- /dev/null +++ b/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/GenericResourceMsApp.java @@ -0,0 +1,87 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SDNC + * ================================================================================ + * Copyright (C) 2020 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.sdnc.apps.ms.gra; + +import org.apache.shiro.realm.Realm; +import org.apache.shiro.realm.text.PropertiesRealm; +import org.apache.shiro.spring.web.config.DefaultShiroFilterChainDefinition; +import org.apache.shiro.spring.web.config.ShiroFilterChainDefinition; +import org.onap.aaf.cadi.shiro.AAFRealm; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.domain.EntityScan; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Import; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; +import org.springframework.transaction.annotation.EnableTransactionManagement; +import org.onap.ccsdk.apps.ms.sliboot.controllers.RestconfApiController; + +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +@SpringBootApplication(scanBasePackages={ "org.onap.sdnc.apps.ms.gra", "org.onap.ccsdk.apps.services"}) +@EnableJpaRepositories(basePackages={"org.onap.sdnc.apps.ms.gra", "org.onap.ccsdk.apps.ms.sliboot"}) +@EntityScan(basePackages={"org.onap.sdnc.apps.ms.gra", "org.onap.ccsdk.apps.ms.sliboot"}) +@EnableTransactionManagement +@Import(RestconfApiController.class) +@EnableSwagger2 + +public class GenericResourceMsApp { + + private static final Logger log = LoggerFactory.getLogger(GenericResourceMsApp.class); + + public static void main(String[] args) throws Exception { + SpringApplication.run(GenericResourceMsApp.class, args); + } + + @Bean + public Realm realm() { + + // If cadi prop files is not defined use local properties realm + // src/main/resources/shiro-users.properties + if ("none".equals(System.getProperty("cadi_prop_files", "none"))) { + log.info("cadi_prop_files undefined, AAF Realm will not be set"); + PropertiesRealm realm = new PropertiesRealm(); + return realm; + } else { + AAFRealm realm = new AAFRealm(); + return realm; + } + + } + + @Bean + public ShiroFilterChainDefinition shiroFilterChainDefinition() { + DefaultShiroFilterChainDefinition chainDefinition = new DefaultShiroFilterChainDefinition(); + + // if cadi prop files is not set disable authentication + if ("none".equals(System.getProperty("cadi_prop_files", "none"))) { + chainDefinition.addPathDefinition("/**", "anon"); + } else { + log.info("Loaded property cadi_prop_files, AAF REALM set"); + chainDefinition.addPathDefinition("/**", "authcBasic, rest[org.onap.sdnc.odl:odl-api]"); + } + + return chainDefinition; + } + +} diff --git a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/core/GenericResourceMsApp.java b/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/core/GenericResourceMsApp.java deleted file mode 100644 index e3a2bd7..0000000 --- a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/core/GenericResourceMsApp.java +++ /dev/null @@ -1,78 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SDNC - * ================================================================================ - * Copyright (C) 2020 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.sdnc.apps.ms.gra.core; - -import org.apache.shiro.realm.Realm; -import org.apache.shiro.realm.text.PropertiesRealm; -import org.apache.shiro.spring.web.config.DefaultShiroFilterChainDefinition; -import org.apache.shiro.spring.web.config.ShiroFilterChainDefinition; -import org.onap.aaf.cadi.shiro.AAFRealm; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Import; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -@SpringBootApplication(scanBasePackages= { "org.onap.sdnc.apps.ms.gra.*", "org.onap.ccsdk.apps.services"}) -@EnableSwagger2 -public class GenericResourceMsApp { - - private static final Logger log = LoggerFactory.getLogger(GenericResourceMsApp.class); - - public static void main(String[] args) throws Exception { - SpringApplication.run(GenericResourceMsApp.class, args); - } - - @Bean - public Realm realm() { - - // If cadi prop files is not defined use local properties realm - // src/main/resources/shiro-users.properties - if ("none".equals(System.getProperty("cadi_prop_files", "none"))) { - log.info("cadi_prop_files undefined, AAF Realm will not be set"); - PropertiesRealm realm = new PropertiesRealm(); - return realm; - } else { - AAFRealm realm = new AAFRealm(); - return realm; - } - - } - - @Bean - public ShiroFilterChainDefinition shiroFilterChainDefinition() { - DefaultShiroFilterChainDefinition chainDefinition = new DefaultShiroFilterChainDefinition(); - - // if cadi prop files is not set disable authentication - if ("none".equals(System.getProperty("cadi_prop_files", "none"))) { - chainDefinition.addPathDefinition("/**", "anon"); - } else { - log.info("Loaded property cadi_prop_files, AAF REALM set"); - chainDefinition.addPathDefinition("/**", "authcBasic, rest[org.onap.sdnc.odl:odl-api]"); - } - - return chainDefinition; - } - -} diff --git a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/core/WebConfig.java b/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/core/WebConfig.java deleted file mode 100644 index 5c1a923..0000000 --- a/ms/generic-resource-api/src/main/java/org/onap/sdnc/apps/ms/gra/core/WebConfig.java +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SDNC - * ================================================================================ - * Copyright (C) 2020 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.sdnc.apps.ms.gra.core; - -import org.onap.logging.filter.spring.LoggingInterceptor; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.autoconfigure.domain.EntityScan; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.jpa.repository.config.EnableJpaRepositories; -import org.springframework.jdbc.datasource.DriverManagerDataSource; -import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; -import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; -import org.springframework.orm.jpa.JpaTransactionManager; -import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; -import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; -import org.springframework.transaction.PlatformTransactionManager; -import org.springframework.transaction.annotation.EnableTransactionManagement; -import org.springframework.web.servlet.config.annotation.EnableWebMvc; -import org.springframework.web.servlet.config.annotation.InterceptorRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; - -import javax.persistence.EntityManagerFactory; -import javax.sql.DataSource; - -@Configuration -@EnableJpaRepositories("org.onap.sdnc.apps.ms.gra.*") -@ComponentScan(basePackages={"org.onap.sdnc.apps.ms.gra.*", "org.onap.ccsdk.apps.services"}) -@EntityScan("org.onap.sdnc.apps.ms.gra.*") -@EnableTransactionManagement -public class WebConfig implements WebMvcConfigurer { - - -} diff --git a/ms/generic-resource-api/src/main/resources/schema-derby.sql b/ms/generic-resource-api/src/main/resources/schema-derby.sql index 52afd71..8d691cc 100644 --- a/ms/generic-resource-api/src/main/resources/schema-derby.sql +++ b/ms/generic-resource-api/src/main/resources/schema-derby.sql @@ -1,7 +1,7 @@ -CREATE SCHEMA sdnctl; +CREATE SCHEMA gra; -SET SCHEMA sdnctl; +SET SCHEMA gra; -- -- Table structure for table ACCESS_LOG diff --git a/ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/ConfigApiPreloadControllerTest.java b/ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/ConfigApiPreloadControllerTest.java index 49f3ae7..5b0a8e6 100644 --- a/ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/ConfigApiPreloadControllerTest.java +++ b/ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/ConfigApiPreloadControllerTest.java @@ -3,7 +3,7 @@ package org.onap.sdnc.apps.ms.gra.controllers; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; -import org.onap.sdnc.apps.ms.gra.core.GenericResourceMsApp; +import org.onap.sdnc.apps.ms.gra.GenericResourceMsApp; import org.onap.sdnc.apps.ms.gra.data.ConfigPreloadData; import org.onap.sdnc.apps.ms.gra.data.ConfigPreloadDataRepository; import org.onap.sdnc.apps.ms.gra.data.ConfigServicesRepository; diff --git a/ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/ConfigApiServicesControllerTest.java b/ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/ConfigApiServicesControllerTest.java index 6329500..e9a5c8b 100644 --- a/ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/ConfigApiServicesControllerTest.java +++ b/ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/ConfigApiServicesControllerTest.java @@ -4,7 +4,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; -import org.onap.sdnc.apps.ms.gra.core.GenericResourceMsApp; +import org.onap.sdnc.apps.ms.gra.GenericResourceMsApp; import org.onap.sdnc.apps.ms.gra.data.ConfigPreloadData; import org.onap.sdnc.apps.ms.gra.data.ConfigPreloadDataRepository; import org.onap.sdnc.apps.ms.gra.data.ConfigServices; diff --git a/ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/GenericResourceMsAppTest.java b/ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/GenericResourceMsAppTest.java index 260d66b..166278a 100644 --- a/ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/GenericResourceMsAppTest.java +++ b/ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/GenericResourceMsAppTest.java @@ -6,7 +6,7 @@ import org.apache.shiro.spring.web.config.ShiroFilterChainDefinition; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; -import org.onap.sdnc.apps.ms.gra.core.GenericResourceMsApp; +import org.onap.sdnc.apps.ms.gra.GenericResourceMsApp; import java.util.Map; diff --git a/ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/OperationsApiControllerTest.java b/ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/OperationsApiControllerTest.java index f0f29d3..b285d9e 100644 --- a/ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/OperationsApiControllerTest.java +++ b/ms/generic-resource-api/src/test/java/org/onap/sdnc/apps/ms/gra/controllers/OperationsApiControllerTest.java @@ -3,7 +3,7 @@ package org.onap.sdnc.apps.ms.gra.controllers; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; -import org.onap.sdnc.apps.ms.gra.core.GenericResourceMsApp; +import org.onap.sdnc.apps.ms.gra.GenericResourceMsApp; import org.onap.sdnc.apps.ms.gra.data.ConfigPreloadDataRepository; import org.onap.sdnc.apps.ms.gra.data.ConfigServices; import org.onap.sdnc.apps.ms.gra.data.ConfigServicesRepository; @@ -126,7 +126,7 @@ public class OperationsApiControllerTest { .andReturn(); assertEquals(200, mvcResult.getResponse().getStatus()); assertEquals(1, configServicesRepository.count()); - assertEquals(1, operationalServicesRepository.count()); + assertEquals(0, operationalServicesRepository.count()); } diff --git a/ms/generic-resource-api/src/test/resources/application.properties b/ms/generic-resource-api/src/test/resources/application.properties index 807719e..a3a99b8 100644 --- a/ms/generic-resource-api/src/test/resources/application.properties +++ b/ms/generic-resource-api/src/test/resources/application.properties @@ -5,13 +5,14 @@ spring.jackson.date-format=org.onap.sdnc.apps.ms.gra.swagger.RFC3339DateFormat spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false logging.level.com.att=TRACE logging.level.org.onap=TRACE -spring.datasource.url=jdbc:derby:memory:sdnctl;create=true +spring.datasource.url=jdbc:derby:memory:gra;create=true spring.datasource.platform=derby -spring.datasource.username=sdnctl +spring.datasource.username=sdnc spring.datasource.password=abc123 spring.datasource.driver-class-name=org.apache.derby.jdbc.EmbeddedDriver spring.datasource.testWhileIdle=true spring.datasource.validationQuery=SELECT 1 +spring.datasource.continue-on-error=true spring.jpa.show-sql=true spring.jpa.hibernate.ddl-auto=update spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyHbmImpl diff --git a/ms/generic-resource-api/src/test/resources/dblib.properties b/ms/generic-resource-api/src/test/resources/dblib.properties index 198a00c..27923aa 100644 --- a/ms/generic-resource-api/src/test/resources/dblib.properties +++ b/ms/generic-resource-api/src/test/resources/dblib.properties @@ -23,12 +23,12 @@ org.onap.ccsdk.sli.dbtype=jdbc org.onap.ccsdk.sli.jdbc.hosts=localhost -org.onap.ccsdk.sli.jdbc.url=jdbc:derby:memory:sdnctl;create=true +org.onap.ccsdk.sli.jdbc.url=jdbc:derby:memory:gra;create=true org.onap.ccsdk.sli.jdbc.driver=org.apache.derby.jdbc.EmbeddedDriver -org.onap.ccsdk.sli.jdbc.database = sdnctl -org.onap.ccsdk.sli.jdbc.user = sdnctl +org.onap.ccsdk.sli.jdbc.database = gra +org.onap.ccsdk.sli.jdbc.user = sdnc org.onap.ccsdk.sli.jdbc.password = abc123 -org.onap.ccsdk.sli.jdbc.connection.name=sdnctldb01 +org.onap.ccsdk.sli.jdbc.connection.name=gradb01 org.onap.ccsdk.sli.jdbc.connection.timeout=50 org.onap.ccsdk.sli.jdbc.request.timeout=100 org.onap.ccsdk.sli.jdbc.limit.init=10 diff --git a/ms/generic-resource-api/src/test/resources/svclogic.properties b/ms/generic-resource-api/src/test/resources/svclogic.properties index 8f5243e..acbf8d0 100644 --- a/ms/generic-resource-api/src/test/resources/svclogic.properties +++ b/ms/generic-resource-api/src/test/resources/svclogic.properties @@ -20,10 +20,10 @@ ### org.onap.ccsdk.sli.dbtype = jdbc -org.onap.ccsdk.sli.jdbc.url=jdbc:derby:memory:sdnctl;create=true +org.onap.ccsdk.sli.jdbc.url=jdbc:derby:memory:gra;create=true org.onap.ccsdk.sli.jdbc.driver=org.apache.derby.jdbc.EmbeddedDriver -org.onap.ccsdk.sli.jdbc.database = sdnctl -org.onap.ccsdk.sli.jdbc.user = sdnctl +org.onap.ccsdk.sli.jdbc.database = gra +org.onap.ccsdk.sli.jdbc.user = sdnc org.onap.ccsdk.sli.jdbc.password = abc123 serviceLogicDirectory=target/docker-stage/opt/onap/sdnc/svclogic/graphs/generic-resource-api -- cgit 1.2.3-korg