From b35d55e3f57630551f0b773674bd1f5c44585ede Mon Sep 17 00:00:00 2001 From: "Singal, Kapil (ks220y)" Date: Thu, 9 Aug 2018 20:47:29 +0000 Subject: Controller Blueprints MS Creating the base directory structure for Controller Blueprints MicroService Change-Id: I1ccf7fc76446048af3b2822f9155bb634657aee3 Issue-ID: CCSDK-410 Signed-off-by: Singal, Kapil (ks220y) --- .../src/test/resources/application.properties | 65 ++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 ms/controllerblueprints/application/src/test/resources/application.properties (limited to 'ms/controllerblueprints/application/src/test/resources') diff --git a/ms/controllerblueprints/application/src/test/resources/application.properties b/ms/controllerblueprints/application/src/test/resources/application.properties new file mode 100644 index 000000000..c6057e563 --- /dev/null +++ b/ms/controllerblueprints/application/src/test/resources/application.properties @@ -0,0 +1,65 @@ +# +# Copyright © 2017-2018 AT&T Intellectual Property. +# +# 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. +# + +info.build.artifact=@project.artifactId@ +info.build.name=@project.name@ +info.build.description=@project.description@ +info.build.version=@project.version@ +info.build.groupId=@project.groupId@ +logging.level.root=info + +server.contextPath=/ +server.servlet-path=/ +spring.jersey.application-path=/api/controller-blueprints/v1 +server.routingPath=/api + +mots.application.acronym=MOTS_ID +platform.identifier=AJSC7_JERSEY +#spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration + +#logging.pattern.console=%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p) %clr($ threadId: {PID:- }){magenta} %clr(---){faint} %clr([ hostname: %X{hostname} serviceName: %X{serviceName} version: %X{version} transactionId: %X{transactionId} requestTimeStamp: %X{requestTimestamp} responseTimeStamp: %X{responseTimestamp} duration: %X{duration}]){yellow} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n%wex + +#The max number of active threads in this pool +server.tomcat.max-threads=200 +#The minimum number of threads always kept alive +server.tomcat.min-Spare-Threads=25 +#The number of milliseconds before an idle thread shutsdown, unless the number of active threads are less or equal to minSpareThreads +server.tomcat.max-idle-time=60000 + +#for changing the tomcat port... +#server.port=8081 + +#Servlet context parameters +server.context_parameters.p-name=value #context parameter with p-name as key and value as value. + +# make this true for AAF authentication and place cadi.properties into etc folder +aaf.enabled=false + +# set to true to enable version proxy +#ivp.enabled=false + +logging.level.org.springframework.web=INFO +logging.level.org.hibernate.SQL=warn +logging.level.org.hibernate.type.descriptor.sql=debug + +spring.jpa.properties.hibernate.show_sql=true +spring.jpa.properties.hibernate.use_sql_comments=true +spring.jpa.properties.hibernate.format_sql=true + +#Load Blueprints +# blueprints.load.initial-data may be overridden by ENV variables +blueprints.load.initial-data=true +blueprints.load.path=load \ No newline at end of file -- cgit 1.2.3-korg From a3c9519d6aa7eb8e1f450a7d041047f2c0a5cc07 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Fri, 17 Aug 2018 19:45:00 +0000 Subject: Controller Blueprints Microservice Restcontroller Swagger Implementation with Embeded jar for Controller Bluprints MS Change-Id: I0c0a33f0e29dad0d4aa703e3e381068b510e57d4 Issue-ID: CCSDK-468 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- ms/controllerblueprints/.gitignore | 1 + .../application/etc/logback.xml | 36 ++++ .../opt/app/onap/config/application.properties | 35 ---- .../application/opt/app/onap/config/logback.xml | 36 ---- ms/controllerblueprints/application/pom.xml | 5 - .../application/src/assembly/distribution.xml | 8 - .../ControllerBluprintsApplication.java | 8 +- .../ControllerBluprintsFilterConfiguration.java | 37 ---- .../apps/controllerblueprints/CorsConfig.java | 22 +- .../controllerblueprints/JerseyConfiguration.java | 102 --------- .../apps/controllerblueprints/SwaggerConfig.java | 70 +++++++ .../ccsdk/apps/controllerblueprints/WebConfig.java | 37 ++++ .../controllerblueprints/WebMvcConfiguration.java | 37 ---- .../ControllerBluprintsApplicationTest.java | 3 +- .../src/test/resources/application.properties | 45 ---- .../application/src/test/resources/logback.xml | 36 ++++ ms/controllerblueprints/modules/core/pom.xml | 58 ------ .../modules/resource-dict/pom.xml | 7 - ms/controllerblueprints/modules/service/pom.xml | 24 +-- .../service/common/ServiceExceptionMapper.java | 42 ---- .../service/common/SwaggerGenerator.java | 24 +-- .../service/rs/ConfigModelRest.java | 232 ++++++++------------- .../service/rs/ConfigModelRestImpl.java | 116 ----------- .../service/rs/ModelTypeRest.java | 147 +++++-------- .../service/rs/ModelTypeRestImpl.java | 87 -------- .../service/rs/ResourceDictionaryRest.java | 152 ++++++-------- .../service/rs/ResourceDictionaryRestImpl.java | 91 -------- .../service/rs/ServiceTemplateRest.java | 160 ++++++-------- .../service/rs/ServiceTemplateRestImpl.java | 94 --------- .../controllerblueprints/JerseyConfiguration.java | 69 ------ .../controllerblueprints/TestConfiguration.java | 36 ---- .../service/rs/ConfigModelRestTest.java | 4 +- .../service/rs/ModelTypeRestTest.java | 3 +- .../service/rs/ResourceDictionaryRestTest.java | 3 +- .../service/rs/ServiceTemplateRestTest.java | 3 +- ms/controllerblueprints/parent/pom.xml | 122 ++++++++--- 36 files changed, 580 insertions(+), 1412 deletions(-) create mode 100644 ms/controllerblueprints/application/etc/logback.xml delete mode 100644 ms/controllerblueprints/application/opt/app/onap/config/logback.xml delete mode 100644 ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsFilterConfiguration.java delete mode 100644 ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/JerseyConfiguration.java create mode 100644 ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/SwaggerConfig.java create mode 100644 ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/WebConfig.java delete mode 100644 ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/WebMvcConfiguration.java create mode 100644 ms/controllerblueprints/application/src/test/resources/logback.xml delete mode 100644 ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ServiceExceptionMapper.java delete mode 100644 ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRestImpl.java delete mode 100644 ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestImpl.java delete mode 100644 ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestImpl.java delete mode 100644 ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestImpl.java delete mode 100644 ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/JerseyConfiguration.java delete mode 100644 ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/TestConfiguration.java (limited to 'ms/controllerblueprints/application/src/test/resources') diff --git a/ms/controllerblueprints/.gitignore b/ms/controllerblueprints/.gitignore index b808e8430..644e3b492 100644 --- a/ms/controllerblueprints/.gitignore +++ b/ms/controllerblueprints/.gitignore @@ -7,6 +7,7 @@ **/target-ide/* **/target/* **/logs/* +**/debug-logs/* **/tokens/* # Added for Intellij IDEA IDE diff --git a/ms/controllerblueprints/application/etc/logback.xml b/ms/controllerblueprints/application/etc/logback.xml new file mode 100644 index 000000000..44e9a8a11 --- /dev/null +++ b/ms/controllerblueprints/application/etc/logback.xml @@ -0,0 +1,36 @@ + + + + + + + %d{HH:mm:ss.SSS} %-5level %logger{100} - %msg%n + + + + + + + + + + + + + + diff --git a/ms/controllerblueprints/application/opt/app/onap/config/application.properties b/ms/controllerblueprints/application/opt/app/onap/config/application.properties index 202017de7..9fa8e04cf 100644 --- a/ms/controllerblueprints/application/opt/app/onap/config/application.properties +++ b/ms/controllerblueprints/application/opt/app/onap/config/application.properties @@ -14,43 +14,8 @@ # limitations under the License. # -info.build.artifact=@project.artifactId@ -info.build.name=@project.name@ -info.build.description=@project.description@ -info.build.version=@project.version@ -info.build.groupId=@project.groupId@ -logging.level.root=info - -server.contextPath=/ -server.servlet-path=/ -spring.jersey.application-path=/api/controller-blueprints/v1 -server.routingPath=/api - -mots.application.acronym=MOTS_ID -platform.identifier=AJSC7_JERSEY -#spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration - #logging.pattern.console=%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p) %clr($ threadId: {PID:- }){magenta} %clr(---){faint} %clr([ hostname: %X{hostname} serviceName: %X{serviceName} version: %X{version} transactionId: %X{transactionId} requestTimeStamp: %X{requestTimestamp} responseTimeStamp: %X{responseTimestamp} duration: %X{duration}]){yellow} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n%wex -#The max number of active threads in this pool -server.tomcat.max-threads=200 -#The minimum number of threads always kept alive -server.tomcat.min-Spare-Threads=25 -#The number of milliseconds before an idle thread shutsdown, unless the number of active threads are less or equal to minSpareThreads -server.tomcat.max-idle-time=60000 - -#for changing the tomcat port... -#server.port=8081 - -#Servlet context parameters -server.context_parameters.p-name=value #context parameter with p-name as key and value as value. - -# make this true for AAF authentication and place cadi.properties into etc folder -aaf.enabled=false - -# set to true to enable version proxy -#ivp.enabled=false - logging.level.org.springframework.web=INFO logging.level.org.hibernate.SQL=warn logging.level.org.hibernate.type.descriptor.sql=debug diff --git a/ms/controllerblueprints/application/opt/app/onap/config/logback.xml b/ms/controllerblueprints/application/opt/app/onap/config/logback.xml deleted file mode 100644 index cdd20c8b1..000000000 --- a/ms/controllerblueprints/application/opt/app/onap/config/logback.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - %d{HH:mm:ss.SSS} %-5level %logger{100} - %msg%n - - - - - - - - - - - - - - diff --git a/ms/controllerblueprints/application/pom.xml b/ms/controllerblueprints/application/pom.xml index 18d9a9037..19fd9c72d 100644 --- a/ms/controllerblueprints/application/pom.xml +++ b/ms/controllerblueprints/application/pom.xml @@ -69,11 +69,6 @@ spring-boot-devtools true - - com.h2database - h2 - runtime - org.springframework.boot spring-boot-starter-test diff --git a/ms/controllerblueprints/application/src/assembly/distribution.xml b/ms/controllerblueprints/application/src/assembly/distribution.xml index adfb52d10..c58c20d78 100644 --- a/ms/controllerblueprints/application/src/assembly/distribution.xml +++ b/ms/controllerblueprints/application/src/assembly/distribution.xml @@ -27,14 +27,6 @@ /opt/app/onap/lib - org.slf4j:slf4j-log4j12 - javax.servlet:servlet-api - javax.servlet:javax.servlet-api - j2ee:j2ee - log4j:log4j - com.sun:j2ee - log4j:apache-log4j-extras - org.slf4j:slf4j-simple diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsApplication.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsApplication.java index 96d82e7e4..447e1966d 100644 --- a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsApplication.java +++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsApplication.java @@ -16,22 +16,26 @@ package org.onap.ccsdk.apps.controllerblueprints; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.ComponentScan; +import org.springframework.web.reactive.config.EnableWebFlux; /** - * - * * @author Brinda Santh */ @SpringBootApplication +@EnableWebFlux @ComponentScan(basePackages = {"org.onap.ccsdk.apps.controllerblueprints"}) @EnableAutoConfiguration public class ControllerBluprintsApplication { + private static EELFLogger log = EELFManager.getInstance().getLogger(ControllerBluprintsApplication.class); public static void main(String[] args) { + log.info("****** Starting Controller Bluprints Application **************"); SpringApplication.run(ControllerBluprintsApplication.class, args); } diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsFilterConfiguration.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsFilterConfiguration.java deleted file mode 100644 index 6f4bfc988..000000000 --- a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsFilterConfiguration.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * 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. - */ - -package org.onap.ccsdk.apps.controllerblueprints; - - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Configuration; -/** - * - * - * @author Brinda Santh - */ -@Configuration -public class ControllerBluprintsFilterConfiguration { - private static Logger log = LoggerFactory.getLogger(JerseyConfiguration.class); - - @Value("${server.routingPath:#{null}}") - private String routingPath; - - -} diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/CorsConfig.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/CorsConfig.java index 0d9ab1623..5d682ed50 100644 --- a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/CorsConfig.java +++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/CorsConfig.java @@ -1,17 +1,17 @@ /* - * Copyright © 2017-2018 AT&T Intellectual Property. + * Copyright © 2017-2018 AT&T Intellectual Property. * - * 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 + * 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 + * 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. + * 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. */ package org.onap.ccsdk.apps.controllerblueprints; @@ -29,7 +29,7 @@ import org.springframework.web.filter.CorsFilter; * @author Brinda Santh * @version 1.0 */ -@Configuration +//@Configuration public class CorsConfig { /** * This is a CORS Implementation for different Orgin GUI to access. diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/JerseyConfiguration.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/JerseyConfiguration.java deleted file mode 100644 index a3b0faf0c..000000000 --- a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/JerseyConfiguration.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * 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. - */ - -package org.onap.ccsdk.apps.controllerblueprints; - - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.MapperFeature; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; -import io.swagger.jaxrs.config.BeanConfig; -import io.swagger.jaxrs.listing.ApiListingResource; -import io.swagger.jaxrs.listing.SwaggerSerializers; -import org.glassfish.jersey.server.ResourceConfig; -import org.glassfish.jersey.servlet.ServletProperties; -import org.onap.ccsdk.apps.controllerblueprints.service.common.ServiceExceptionMapper; -import org.onap.ccsdk.apps.controllerblueprints.service.rs.ConfigModelRestImpl; -import org.onap.ccsdk.apps.controllerblueprints.service.rs.ModelTypeRestImpl; -import org.onap.ccsdk.apps.controllerblueprints.service.rs.ResourceDictionaryRestImpl; -import org.onap.ccsdk.apps.controllerblueprints.service.rs.ServiceTemplateRestImpl; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Primary; -import org.springframework.stereotype.Component; - -import javax.ws.rs.core.MediaType; - -/** - * - * - * @author Brinda Santh - */ -@Component -public class JerseyConfiguration extends ResourceConfig { - private static Logger log = LoggerFactory.getLogger(JerseyConfiguration.class); - /** - * - */ - @Autowired - public JerseyConfiguration() { - register(ConfigModelRestImpl.class); - register(ModelTypeRestImpl.class); - register(ResourceDictionaryRestImpl.class); - register(ServiceTemplateRestImpl.class); - register(ServiceExceptionMapper.class); - property(ServletProperties.FILTER_FORWARD_ON_404, true); - configureSwagger(); - } - - /** - * - * @return ObjectMapper - */ - @Bean - @Primary - public ObjectMapper objectMapper() { - ObjectMapper objectMapper = new ObjectMapper(); - objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); - objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); - objectMapper.enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES); - objectMapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING); - objectMapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING); - return objectMapper; - } - - /** - * - */ - private void configureSwagger() { - register(ApiListingResource.class); - register(SwaggerSerializers.class); - BeanConfig beanConfig = new BeanConfig(); - beanConfig.setVersion("1.0.0"); - beanConfig.setSchemes(new String[]{"http", "https"}); - beanConfig.setBasePath("/api/controller-blueprints/v1"); - beanConfig.setTitle("Controller Blueprints API"); - beanConfig.setDescription("Controller BluePrints API"); - beanConfig.getSwagger().addConsumes(MediaType.APPLICATION_JSON); - beanConfig.getSwagger().addProduces(MediaType.APPLICATION_JSON); - beanConfig.setResourcePackage("org.onap.ccsdk.apps.controllerblueprints"); - beanConfig.setPrettyPrint(true); - beanConfig.setScan(true); - } - - -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/SwaggerConfig.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/SwaggerConfig.java new file mode 100644 index 000000000..5970bafde --- /dev/null +++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/SwaggerConfig.java @@ -0,0 +1,70 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * 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. + */ + +package org.onap.ccsdk.apps.controllerblueprints; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Contact; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + +/** + * SwaggerConfig + * + * @author Brinda Santh 8/13/2018 + */ +@Configuration +@EnableSwagger2 +public class SwaggerConfig { + private static final Set DEFAULT_PRODUCES_AND_CONSUMES = + new HashSet(Arrays.asList("application/json", + "application/xml")); + private static Logger log = LoggerFactory.getLogger(SwaggerConfig.class); + + @Bean + public Docket api() { + return new Docket(DocumentationType.SWAGGER_2) + .select() + .apis(RequestHandlerSelectors.any()) + .paths(PathSelectors.any()) + .build() + .apiInfo(apiInfo()); + } + + private ApiInfo apiInfo() { + return new ApiInfo( + "Controller Blueprints API", + "Controller blueprints API for VNF Self Service.", + "1.0.0", + "Terms of service", + new Contact("Brinda Santh", "www.onap.com", "brindasanth@onap.com"), + "Apache 2.0", "http://www.apache.org/licenses/LICENSE-2.0", Collections.emptyList()); + } + + +} diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/WebConfig.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/WebConfig.java new file mode 100644 index 000000000..1eba97cdc --- /dev/null +++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/WebConfig.java @@ -0,0 +1,37 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * 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. + */ + +package org.onap.ccsdk.apps.controllerblueprints; + +import org.springframework.context.annotation.Configuration; +import org.springframework.web.reactive.config.ResourceHandlerRegistry; +import org.springframework.web.reactive.config.WebFluxConfigurationSupport; + +/** + * WebConfig + * + * @author Brinda Santh 8/13/2018 + */ +@Configuration +public class WebConfig extends WebFluxConfigurationSupport { + public void addResourceHandlers(ResourceHandlerRegistry registry) { + registry.addResourceHandler("swagger-ui.html") + .addResourceLocations("classpath:/META-INF/resources/"); + + registry.addResourceHandler("/webjars/**") + .addResourceLocations("classpath:/META-INF/resources/webjars/"); + } +} diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/WebMvcConfiguration.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/WebMvcConfiguration.java deleted file mode 100644 index a690c056c..000000000 --- a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/WebMvcConfiguration.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * 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. - */ - -package org.onap.ccsdk.apps.controllerblueprints; - -import org.springframework.context.annotation.Configuration; -import org.springframework.web.servlet.config.annotation.EnableWebMvc; -import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; - -/** - * - * WebMvcConfiguration WebMvcConfiguration - * @author Brinda Santh - */ -@Configuration -@EnableWebMvc -public class WebMvcConfiguration extends WebMvcConfigurerAdapter { - @Override - public void addResourceHandlers(ResourceHandlerRegistry registry) { - registry.addResourceHandler("/swagger-ui/**").addResourceLocations("classpath:/swagger-ui/dist/"); - } - -} diff --git a/ms/controllerblueprints/application/src/test/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsApplicationTest.java b/ms/controllerblueprints/application/src/test/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsApplicationTest.java index 4bdbde008..95639bd32 100644 --- a/ms/controllerblueprints/application/src/test/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsApplicationTest.java +++ b/ms/controllerblueprints/application/src/test/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsApplicationTest.java @@ -46,9 +46,8 @@ public class ControllerBluprintsApplicationTest { @Test public void testConfigModel() { - ResponseEntity entity = this.restTemplate - .getForEntity("/api/controller-blueprints/v1/service/configmodel/1", String.class); + .getForEntity("/api/v1/config-model/1", String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); } } diff --git a/ms/controllerblueprints/application/src/test/resources/application.properties b/ms/controllerblueprints/application/src/test/resources/application.properties index c6057e563..55ffeaf16 100644 --- a/ms/controllerblueprints/application/src/test/resources/application.properties +++ b/ms/controllerblueprints/application/src/test/resources/application.properties @@ -14,51 +14,6 @@ # limitations under the License. # -info.build.artifact=@project.artifactId@ -info.build.name=@project.name@ -info.build.description=@project.description@ -info.build.version=@project.version@ -info.build.groupId=@project.groupId@ -logging.level.root=info - -server.contextPath=/ -server.servlet-path=/ -spring.jersey.application-path=/api/controller-blueprints/v1 -server.routingPath=/api - -mots.application.acronym=MOTS_ID -platform.identifier=AJSC7_JERSEY -#spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration - -#logging.pattern.console=%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p) %clr($ threadId: {PID:- }){magenta} %clr(---){faint} %clr([ hostname: %X{hostname} serviceName: %X{serviceName} version: %X{version} transactionId: %X{transactionId} requestTimeStamp: %X{requestTimestamp} responseTimeStamp: %X{responseTimestamp} duration: %X{duration}]){yellow} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n%wex - -#The max number of active threads in this pool -server.tomcat.max-threads=200 -#The minimum number of threads always kept alive -server.tomcat.min-Spare-Threads=25 -#The number of milliseconds before an idle thread shutsdown, unless the number of active threads are less or equal to minSpareThreads -server.tomcat.max-idle-time=60000 - -#for changing the tomcat port... -#server.port=8081 - -#Servlet context parameters -server.context_parameters.p-name=value #context parameter with p-name as key and value as value. - -# make this true for AAF authentication and place cadi.properties into etc folder -aaf.enabled=false - -# set to true to enable version proxy -#ivp.enabled=false - -logging.level.org.springframework.web=INFO -logging.level.org.hibernate.SQL=warn -logging.level.org.hibernate.type.descriptor.sql=debug - -spring.jpa.properties.hibernate.show_sql=true -spring.jpa.properties.hibernate.use_sql_comments=true -spring.jpa.properties.hibernate.format_sql=true - #Load Blueprints # blueprints.load.initial-data may be overridden by ENV variables blueprints.load.initial-data=true diff --git a/ms/controllerblueprints/application/src/test/resources/logback.xml b/ms/controllerblueprints/application/src/test/resources/logback.xml new file mode 100644 index 000000000..b9b97dc89 --- /dev/null +++ b/ms/controllerblueprints/application/src/test/resources/logback.xml @@ -0,0 +1,36 @@ + + + + + + + %d{HH:mm:ss.SSS} %-5level %logger{100} - %msg%n + + + + + + + + + + + + + + diff --git a/ms/controllerblueprints/modules/core/pom.xml b/ms/controllerblueprints/modules/core/pom.xml index 0e88dd293..fc7581c8c 100644 --- a/ms/controllerblueprints/modules/core/pom.xml +++ b/ms/controllerblueprints/modules/core/pom.xml @@ -29,30 +29,6 @@ Controller Blueprints Core - - org.jetbrains.kotlin - kotlin-stdlib - - - org.jetbrains.kotlin - kotlin-reflect - - - com.fasterxml.jackson.module - jackson-module-kotlin - - - com.fasterxml.jackson.core - jackson-databind - - - com.fasterxml.jackson.core - jackson-annotations - - - com.fasterxml.jackson.core - jackson-core - com.fasterxml.jackson.dataformat jackson-dataformat-xml @@ -65,44 +41,10 @@ com.fasterxml.jackson.module jackson-module-jsonSchema - - org.apache.commons - commons-lang3 - - - commons-collections - commons-collections - - - commons-io - commons-io - - - com.google.guava - guava - org.yaml snakeyaml - - com.jayway.jsonpath - json-path - - - junit - junit - test - - - org.jetbrains.kotlin - kotlin-test - test - - diff --git a/ms/controllerblueprints/modules/resource-dict/pom.xml b/ms/controllerblueprints/modules/resource-dict/pom.xml index a0d1be611..337f5512f 100644 --- a/ms/controllerblueprints/modules/resource-dict/pom.xml +++ b/ms/controllerblueprints/modules/resource-dict/pom.xml @@ -33,13 +33,6 @@ org.onap.ccsdk.apps controllerblueprints-core - - junit - junit - test - - - diff --git a/ms/controllerblueprints/modules/service/pom.xml b/ms/controllerblueprints/modules/service/pom.xml index 17738bf4b..b4b798e6e 100644 --- a/ms/controllerblueprints/modules/service/pom.xml +++ b/ms/controllerblueprints/modules/service/pom.xml @@ -36,37 +36,17 @@ org.onap.ccsdk.apps controllerblueprints-resource-dict - - org.apache.commons - commons-lang3 - - - commons-collections - commons-collections - - - commons-io - commons-io - org.apache.velocity velocity - - io.swagger - swagger-jersey2-jaxrs - - - org.json - json - org.springframework.boot - spring-boot-starter-web + spring-boot-starter-webflux org.springframework.boot - spring-boot-starter-jersey + spring-boot-starter-web org.springframework.boot diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ServiceExceptionMapper.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ServiceExceptionMapper.java deleted file mode 100644 index f223dccb2..000000000 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ServiceExceptionMapper.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * 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. - */ - -package org.onap.ccsdk.apps.controllerblueprints.service.common; - -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException; - -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.ext.ExceptionMapper; -import javax.ws.rs.ext.Provider; -import java.io.PrintWriter; -import java.io.StringWriter; - -@Provider -public class ServiceExceptionMapper implements ExceptionMapper { - - @Override - public Response toResponse(BluePrintException ex) { - ErrorMessage errorMessage = new ErrorMessage(); - errorMessage.setCode(ex.getCode()); - errorMessage.setMessage(ex.getMessage()); - StringWriter errorStackTrace = new StringWriter(); - ex.printStackTrace(new PrintWriter(errorStackTrace)); - errorMessage.setDeveloperMessage(ex.toString()); - return Response.status(500).entity(errorMessage).type(MediaType.APPLICATION_JSON).build(); - } - -} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/SwaggerGenerator.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/SwaggerGenerator.java index e90807633..81f7d7018 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/SwaggerGenerator.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/SwaggerGenerator.java @@ -1,17 +1,17 @@ /* - * Copyright © 2017-2018 AT&T Intellectual Property. + * Copyright © 2017-2018 AT&T Intellectual Property. * - * 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 + * 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 + * 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. + * 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. */ package org.onap.ccsdk.apps.controllerblueprints.service.common; @@ -20,7 +20,6 @@ import io.swagger.models.*; import io.swagger.models.parameters.BodyParameter; import io.swagger.models.parameters.Parameter; import io.swagger.models.properties.*; -import io.swagger.util.Json; import org.apache.commons.collections.MapUtils; import org.apache.commons.lang3.BooleanUtils; import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants; @@ -63,8 +62,7 @@ public class SwaggerGenerator { swagger.setDefinitions(getDefinition()); - swaggerContent = Json.pretty(swagger); - return swaggerContent; + return swagger.toString(); } private Info getInfo() { diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRest.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRest.java index 86c89bf90..94324a808 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRest.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRest.java @@ -16,164 +16,112 @@ package org.onap.ccsdk.apps.controllerblueprints.service.rs; -import io.swagger.annotations.*; import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException; -import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate; +import org.onap.ccsdk.apps.controllerblueprints.service.ConfigModelService; import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; +import org.springframework.web.bind.annotation.*; -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; import java.util.List; /** - * ConfigModelRest.java Purpose: Rest service controller for ConfigModelRest Management - * - * @author Brinda Santh - * @version 1.0 + * {@inheritDoc} */ -@Api -@Path("/service") -@Produces({MediaType.APPLICATION_JSON}) -public interface ConfigModelRest { +@RestController +@RequestMapping("/api/v1/config-model") +public class ConfigModelRest { - /** - * This is a getConfigModel rest service - * - * @param id - * @return ConfigModel - * @throws BluePrintException - */ - @GET - @Path("/configmodel/{id}") - @Consumes({MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_JSON}) - @ApiOperation(value = "Provides Rest service to Search Service Template", response = ConfigModel.class) - @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"), - @ApiResponse(code = 500, message = "Unexpected Runtime error")}) - @RequestMapping(value = "/configmodel/{id}", method = RequestMethod.GET) - @ResponseBody ConfigModel getConfigModel(@ApiParam(required = true) @PathParam("id") Long id) - throws BluePrintException; - + private ConfigModelService configModelService; /** - * This is a saveConfigModel rest service - * - * @param configModel - * @return ConfigModel - * @throws BluePrintException + * This is a ConfigModelRest constructor. + * + * @param configModelService Config Model Service */ - @POST - @Path("/configmodel") - @Consumes({MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_JSON}) - @ApiOperation(value = "Provides Rest service to get Model Type by Tags", response = ServiceTemplate.class) - @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"), - @ApiResponse(code = 500, message = "Unexpected Runtime error")}) - ConfigModel saveConfigModel(@ApiParam(required = true) ConfigModel configModel) - throws BluePrintException; + public ConfigModelRest(ConfigModelService configModelService) { + this.configModelService = configModelService; - /** - * This is a deleteConfigModel rest service - * - * @param id - * @throws BluePrintException - */ - @DELETE - @Path("/configmodel/{id}") - @Consumes({MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_JSON}) - @ApiOperation(value = "Provides Rest service to delete ConfigModel.") - @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"), - @ApiResponse(code = 500, message = "Unexpected Runtime error")}) - void deleteConfigModel(@ApiParam(required = true) @PathParam("id") Long id) throws BluePrintException; + } - /** - * This is a getInitialConfigModel rest service - * - * @param name - * @return ConfigModel - * @throws BluePrintException - */ - @GET - @Path("/configmodelinitial/{name}") - @Consumes({MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_JSON}) - @ApiOperation(value = "Provides Rest service to create default Service Template", response = ConfigModel.class) - @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"), - @ApiResponse(code = 500, message = "Unexpected Runtime error")}) - ConfigModel getInitialConfigModel(@ApiParam(required = true) @PathParam("name") String name) - throws BluePrintException; + @GetMapping(path = "/initial/{name}") + public @ResponseBody + ConfigModel getInitialConfigModel(@PathVariable(value = "name") String name) throws BluePrintException { + try { + return this.configModelService.getInitialConfigModel(name); + } catch (Exception e) { + throw new BluePrintException(2000, e.getMessage(), e); + } + } - /** - * This is a getCloneConfigModel rest service - * - * @param id - * @return ConfigModel - * @throws BluePrintException - */ - @GET - @Path("/configmodelclone/{id}") - @Consumes({MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_JSON}) - @ApiOperation(value = "Provides Rest service to create default Service Template", response = ConfigModel.class) - @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"), - @ApiResponse(code = 500, message = "Unexpected Runtime error")}) - ConfigModel getCloneConfigModel(@ApiParam(required = true) @PathParam("id") Long id) - throws BluePrintException; + @PostMapping(path = "/") + public @ResponseBody + ConfigModel saveConfigModel(@RequestBody ConfigModel configModel) throws BluePrintException { + try { + return this.configModelService.saveConfigModel(configModel); + } catch (Exception e) { + throw new BluePrintException(2200, e.getMessage(), e); + } + } - /** - * This is a publishConfigModel rest service - * - * @param id - * @return ServiceTemplate - * @throws BluePrintException - */ - @GET - @Path("/configmodelpublish/{id}") - @Consumes({MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_JSON}) - @ApiOperation(value = "Provides Rest service to get Model Type by Tags", response = ConfigModel.class) - @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"), - @ApiResponse(code = 500, message = "Unexpected Runtime error")}) - ConfigModel publishConfigModel(@ApiParam(required = true) @PathParam("id") Long id) - throws BluePrintException; + @DeleteMapping(path = "/{id}") + public void deleteConfigModel(@PathVariable(value = "id") Long id) throws BluePrintException { + try { + this.configModelService.deleteConfigModel(id); + } catch (Exception e) { + throw new BluePrintException(4000, e.getMessage(), e); + } + } - /** - * This is a getConfigModelByNameAndVersion rest service - * - * @param name - * @param version - * @return ConfigModel - * @throws BluePrintException - */ - @GET - @Path("/configmodelbyname/{name}/version/{version}") - @Consumes({MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_JSON}) - @ApiOperation(value = "Provides Rest service to Search Service Template", response = ConfigModel.class) - @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"), - @ApiResponse(code = 500, message = "Unexpected Runtime error")}) - ConfigModel getConfigModelByNameAndVersion(@ApiParam(required = true) @PathParam("name") String name, - @ApiParam(required = true) @PathParam("version") String version) throws BluePrintException; + @GetMapping(path = "/publish/{id}") + public @ResponseBody + ConfigModel publishConfigModel(@PathVariable(value = "id") Long id) throws BluePrintException { + try { + return this.configModelService.publishConfigModel(id); + } catch (Exception e) { + throw new BluePrintException(2500, e.getMessage(), e); + } + } - /** - * This is a searchServiceModels rest service - * - * @param tags - * @return List - * @throws BluePrintException - */ - @GET - @Path("/configmodelsearch/{tags}") - @Consumes({MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_JSON}) - @ApiOperation(value = "Provides Rest service to Search Service Template", response = ConfigModel.class) - @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"), - @ApiResponse(code = 500, message = "Unexpected Runtime error")}) - List searchConfigModels(@ApiParam(required = true) @PathParam("tags") String tags) - throws BluePrintException; + @GetMapping(path = "/{id}") + public @ResponseBody + ConfigModel getConfigModel(@PathVariable(value = "id") Long id) throws BluePrintException { + try { + return this.configModelService.getConfigModel(id); + } catch (Exception e) { + throw new BluePrintException(2001, e.getMessage(), e); + } + } + + @GetMapping(path = "/by-name/{name}/version/{version}") + public @ResponseBody + ConfigModel getConfigModelByNameAndVersion(@PathVariable(value = "name") String name, + @PathVariable(value = "version") String version) throws BluePrintException { + try { + return this.configModelService.getConfigModelByNameAndVersion(name, version); + } catch (Exception e) { + throw new BluePrintException(2002, e.getMessage(), e); + } + } + + @GetMapping(path = "/search/{tags}") + public @ResponseBody + List searchConfigModels(@PathVariable(value = "tags") String tags) throws BluePrintException { + try { + return this.configModelService.searchConfigModels(tags); + } catch (Exception e) { + throw new BluePrintException(2003, e.getMessage(), e); + } + } + + @GetMapping(path = "/clone/{id}") + public @ResponseBody + ConfigModel getCloneConfigModel(@PathVariable(value = "id") Long id) throws BluePrintException { + try { + return this.configModelService.getCloneConfigModel(id); + } catch (Exception e) { + throw new BluePrintException(2004, e.getMessage(), e); + } + } } diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRestImpl.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRestImpl.java deleted file mode 100644 index a9abcd5ff..000000000 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRestImpl.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * 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. - */ - -package org.onap.ccsdk.apps.controllerblueprints.service.rs; - -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException; -import org.onap.ccsdk.apps.controllerblueprints.service.ConfigModelService; -import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel; -import org.springframework.stereotype.Service; - -import java.util.List; - -/** - * {@inheritDoc} - */ -@Service -public class ConfigModelRestImpl implements ConfigModelRest { - - private ConfigModelService configModelService; - - /** - * This is a ConfigModelRestImpl constructor. - * - * @param configModelService Config Model Service - */ - public ConfigModelRestImpl(ConfigModelService configModelService) { - this.configModelService = configModelService; - - } - - @Override - public ConfigModel getInitialConfigModel(String name) throws BluePrintException { - try { - return this.configModelService.getInitialConfigModel(name); - } catch (Exception e) { - throw new BluePrintException(2000, e.getMessage(), e); - } - } - - @Override - public ConfigModel saveConfigModel(ConfigModel configModel) throws BluePrintException { - try { - return this.configModelService.saveConfigModel(configModel); - } catch (Exception e) { - throw new BluePrintException(2200, e.getMessage(), e); - } - } - - @Override - public void deleteConfigModel(Long id) throws BluePrintException { - try { - this.configModelService.deleteConfigModel(id); - } catch (Exception e) { - throw new BluePrintException(4000, e.getMessage(), e); - } - } - - @Override - public ConfigModel publishConfigModel(Long id) throws BluePrintException { - try { - return this.configModelService.publishConfigModel(id); - } catch (Exception e) { - throw new BluePrintException(2500, e.getMessage(), e); - } - } - - @Override - public ConfigModel getConfigModel(Long id) throws BluePrintException { - try { - return this.configModelService.getConfigModel(id); - } catch (Exception e) { - throw new BluePrintException(2001, e.getMessage(), e); - } - } - - @Override - public ConfigModel getConfigModelByNameAndVersion(String name, String version) throws BluePrintException { - try { - return this.configModelService.getConfigModelByNameAndVersion(name, version); - } catch (Exception e) { - throw new BluePrintException(2002, e.getMessage(), e); - } - } - - @Override - public List searchConfigModels(String tags) throws BluePrintException { - try { - return this.configModelService.searchConfigModels(tags); - } catch (Exception e) { - throw new BluePrintException(2003, e.getMessage(), e); - } - } - - @Override - public ConfigModel getCloneConfigModel(Long id) throws BluePrintException { - try { - return this.configModelService.getCloneConfigModel(id); - } catch (Exception e) { - throw new BluePrintException(2004, e.getMessage(), e); - } - } - -} diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java index 59b730309..2fa64316f 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java @@ -16,110 +16,77 @@ package org.onap.ccsdk.apps.controllerblueprints.service.rs; -import io.swagger.annotations.*; import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException; +import org.onap.ccsdk.apps.controllerblueprints.service.ModelTypeService; import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType; +import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; +import org.springframework.web.bind.annotation.*; -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; import java.util.List; /** - * ModelTypeRest.java Purpose: Rest service controller for Artifact Handling - * - * @author Brinda Santh - * @version 1.0 + * {@inheritDoc} */ -@Api -@Path("/service") -@Produces({MediaType.APPLICATION_JSON}) -public interface ModelTypeRest { +@RestController +@RequestMapping("/api/v1/model-type") +public class ModelTypeRest { - /** - * This is a getModelTypeByName rest service - * - * @param name - * @return ModelType - * @throws BluePrintException - */ - @GET - @Path("/modeltype/{name}") - @Consumes({MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_JSON}) - @ApiOperation(value = "Provides Rest service to get Model Type by id", response = ModelType.class) - @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"), - @ApiResponse(code = 500, message = "Unexpected Runtime error")}) - ModelType getModelTypeByName(@ApiParam(required = true) @PathParam("name") String name) - throws BluePrintException; + private ModelTypeService modelTypeService; /** - * This is a saveModelType rest service - * - * @param modelType - * @return ModelType - * @throws BluePrintException + * This is a ModelTypeResourceImpl, used to save and get the model types stored in database + * + * @param modelTypeService Model Type Service */ + public ModelTypeRest(ModelTypeService modelTypeService) { + this.modelTypeService = modelTypeService; + } - @POST - @Path("/modeltype") - @Consumes({MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_JSON}) - @ApiOperation(value = "Provides Rest service to Save Model Type", response = ModelType.class) - @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"), - @ApiResponse(code = 500, message = "Unexpected Runtime error")}) - ModelType saveModelType(@ApiParam(required = true) ModelType modelType) throws BluePrintException; + @GetMapping(path = "/{name}") + public ModelType getModelTypeByName(@PathVariable(value = "name") String name) throws BluePrintException { + try { + return modelTypeService.getModelTypeByName(name); + } catch (Exception e) { + throw new BluePrintException(1000, e.getMessage(), e); + } + } - /** - * This is a deleteModelType rest service - * - * @param name - * @throws BluePrintException - */ - @DELETE - @Path("/modeltype/{name}") - @Consumes({MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_JSON}) - @ApiOperation(value = "Provides Rest service to delete Model Type") - @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"), - @ApiResponse(code = 500, message = "Unexpected Runtime error")}) - void deleteModelTypeByName(@ApiParam(required = true) @PathParam("name") String name) - throws BluePrintException; + @GetMapping(path = "/search/{tags}") + public List searchModelTypes(@PathVariable(value = "tags") String tags) throws BluePrintException { + try { + return modelTypeService.searchModelTypes(tags); + } catch (Exception e) { + throw new BluePrintException(1001, e.getMessage(), e); + } + } - /** - * This is a searchModelType rest service - * - * @param tags - * @return List - * @throws BluePrintException - */ - @GET - @Path("/modeltypesearch/{tags}") - @Consumes({MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_JSON}) - @ApiOperation(value = "Provides Rest service to get Model Type by tags", response = ModelType.class, - responseContainer = "List") - @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"), - @ApiResponse(code = 500, message = "Unexpected Runtime error")}) - List searchModelTypes(@ApiParam(required = true) @PathParam("tags") String tags) - throws BluePrintException; + @GetMapping(path = "/by-definition/{definitionType}") + public @ResponseBody + List getModelTypeByDefinitionType(@PathVariable(value = "definitionType") String definitionType) throws BluePrintException { + try { + return modelTypeService.getModelTypeByDefinitionType(definitionType); + } catch (Exception e) { + throw new BluePrintException(1002, e.getMessage(), e); + } + } - /** - * This is a getModelTypeByDefinitionType rest service - * - * @param definitionType - * @return List - * @throws BluePrintException - */ - @GET - @Path("/modeltypebydefinition/{definitionType}") - @Consumes({MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_JSON}) - @ApiOperation(value = "Provides Rest service to get Model Type by tags", response = ModelType.class, - responseContainer = "List") - @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"), - @ApiResponse(code = 500, message = "Unexpected Runtime error")}) - List getModelTypeByDefinitionType( - @ApiParam(required = true) @PathParam("definitionType") String definitionType) - throws BluePrintException; + @PostMapping(path = "/") + public @ResponseBody + ModelType saveModelType(@RequestBody ModelType modelType) throws BluePrintException { + try { + return modelTypeService.saveModel(modelType); + } catch (Exception e) { + throw new BluePrintException(1100, e.getMessage(), e); + } + } + @DeleteMapping(path = "/{name}") + public void deleteModelTypeByName(@PathVariable(value = "name") String name) throws BluePrintException { + try { + modelTypeService.deleteByModelName(name); + } catch (Exception e) { + throw new BluePrintException(1400, e.getMessage(), e); + } + } } diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestImpl.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestImpl.java deleted file mode 100644 index 6fbc69699..000000000 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestImpl.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * 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. - */ - -package org.onap.ccsdk.apps.controllerblueprints.service.rs; - -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException; -import org.onap.ccsdk.apps.controllerblueprints.service.ModelTypeService; -import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType; -import org.springframework.stereotype.Service; - -import java.util.List; - -/** - * {@inheritDoc} - */ -@Service -public class ModelTypeRestImpl implements ModelTypeRest { - - private ModelTypeService modelTypeService; - - /** - * This is a ModelTypeResourceImpl, used to save and get the model types stored in database - * - * @param modelTypeService Model Type Service - */ - public ModelTypeRestImpl(ModelTypeService modelTypeService) { - this.modelTypeService = modelTypeService; - } - - @Override - public ModelType getModelTypeByName(String modelName) throws BluePrintException { - try { - return modelTypeService.getModelTypeByName(modelName); - } catch (Exception e) { - throw new BluePrintException(1000, e.getMessage(), e); - } - } - - @Override - public List searchModelTypes(String tags) throws BluePrintException { - try { - return modelTypeService.searchModelTypes(tags); - } catch (Exception e) { - throw new BluePrintException(1001, e.getMessage(), e); - } - } - - @Override - public List getModelTypeByDefinitionType(String definitionType) throws BluePrintException { - try { - return modelTypeService.getModelTypeByDefinitionType(definitionType); - } catch (Exception e) { - throw new BluePrintException(1002, e.getMessage(), e); - } - } - - @Override - public ModelType saveModelType(ModelType modelType) throws BluePrintException { - try { - return modelTypeService.saveModel(modelType); - } catch (Exception e) { - throw new BluePrintException(1100, e.getMessage(), e); - } - } - - @Override - public void deleteModelTypeByName(String name) throws BluePrintException { - try { - modelTypeService.deleteByModelName(name); - } catch (Exception e) { - throw new BluePrintException(1400, e.getMessage(), e); - } - } -} diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java index 5bc983363..dfb06bba5 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java @@ -16,111 +16,83 @@ package org.onap.ccsdk.apps.controllerblueprints.service.rs; -import io.swagger.annotations.*; import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException; +import org.onap.ccsdk.apps.controllerblueprints.service.ResourceDictionaryService; import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary; +import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; +import org.springframework.web.bind.annotation.*; -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; import java.util.List; /** - * ResourceDictionaryRest.java Purpose: Rest service controller for Artifact Handling - * - * @author Brinda Santh - * @version 1.0 + * {@inheritDoc} */ -@Api -@Path("/service") -@Produces({MediaType.APPLICATION_JSON}) +@RestController +@RequestMapping(value = "/api/v1/dictionary") +public class ResourceDictionaryRest { -public interface ResourceDictionaryRest { - /** - * This is a getDataDictionaryByPath rest service - * - * @param name - * @return ResourceDictionary - * @throws BluePrintException - */ - @GET - @Path("/dictionary/{name}") - @Consumes({MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_JSON}) - @ApiOperation(value = "Provides Rest service to get Resource dictionary", response = ResourceDictionary.class) - @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"), - @ApiResponse(code = 500, message = "Unexpected Runtime error")}) - ResourceDictionary getResourceDictionaryByName(@ApiParam(required = true) @PathParam("name") String name) - throws BluePrintException; + private ResourceDictionaryService resourceDictionaryService; /** - * This is a saveDataDictionary rest service - * - * @param resourceMapping - * @return ResourceDictionary - * @throws BluePrintException + * This is a DataDictionaryRestImpl, used to save and get the Resource Mapping stored in database + * + * @param dataDictionaryService Data Dictionary Service */ + public ResourceDictionaryRest(ResourceDictionaryService dataDictionaryService) { + this.resourceDictionaryService = dataDictionaryService; + } - @POST - @Path("/dictionary") - @Consumes({MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_JSON}) - @ApiOperation(value = "Provides Rest service to Save Resource dictionary Type", response = ResourceDictionary.class) - @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"), - @ApiResponse(code = 500, message = "Unexpected Runtime error")}) - ResourceDictionary saveResourceDictionary(@ApiParam(required = true) ResourceDictionary resourceMapping) - throws BluePrintException; + @PostMapping(path = "/") + public @ResponseBody + ResourceDictionary saveResourceDictionary(@RequestBody ResourceDictionary dataDictionary) + throws BluePrintException { + try { + return resourceDictionaryService.saveResourceDictionary(dataDictionary); + } catch (Exception e) { + throw new BluePrintException(4100, e.getMessage(), e); + } + } - /** - * This is a deleteDataDictionaryByName rest service - * - * @param name - * @throws BluePrintException - */ - @DELETE - @Path("/dictionary/{name}") - @Consumes({MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_JSON}) - @ApiOperation(value = "Provides Rest service to delete ResourceDictionary Type") - @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"), - @ApiResponse(code = 500, message = "Unexpected Runtime error")}) - void deleteResourceDictionaryByName(@ApiParam(required = true) @PathParam("name") String name) - throws BluePrintException; + @DeleteMapping(path = "/{name}") + public void deleteResourceDictionaryByName(@PathVariable(value = "name") String name) throws BluePrintException { + try { + resourceDictionaryService.deleteResourceDictionary(name); + } catch (Exception e) { + throw new BluePrintException(4400, e.getMessage(), e); + } + } - /** - * This is a searchResourceDictionaryByTags rest service - * - * @param tags - * @return ResourceDictionary - * @throws BluePrintException - */ - @GET - @Path("/dictionarysearch/{tags}") - @Consumes({MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_JSON}) - @ApiOperation(value = "Provides Rest service to search Resource dictionary by tags", - response = ResourceDictionary.class, responseContainer = "List") - @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"), - @ApiResponse(code = 500, message = "Unexpected Runtime error")}) - List searchResourceDictionaryByTags( - @ApiParam(required = true) @PathParam("tags") String tags) throws BluePrintException; + @GetMapping(path = "/{name}") + public @ResponseBody + ResourceDictionary getResourceDictionaryByName(@PathVariable(value = "name") String name) throws BluePrintException { + try { + return resourceDictionaryService.getResourceDictionaryByName(name); + } catch (Exception e) { + throw new BluePrintException(4001, e.getMessage(), e); + } + } - /** - * This is a searchResourceDictionaryByNames rest service - * - * @param names - * @return List - * @throws BluePrintException - */ - @POST - @Path("/dictionarybynames") - @Consumes({MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_JSON}) - @ApiOperation(value = "Provides Rest service to get ResourceDictionary Type by names", - response = ResourceDictionary.class, responseContainer = "List") - @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"), - @ApiResponse(code = 500, message = "Unexpected Runtime error")}) - List searchResourceDictionaryByNames(@ApiParam(required = true) List names) - throws BluePrintException; + @PostMapping(path = "/by-names") + public @ResponseBody + List searchResourceDictionaryByNames(@RequestBody List names) + throws BluePrintException { + try { + return resourceDictionaryService.searchResourceDictionaryByNames(names); + } catch (Exception e) { + throw new BluePrintException(4002, e.getMessage(), e); + } + } + + @GetMapping(path = "/search/{tags}") + public @ResponseBody + List searchResourceDictionaryByTags(@PathVariable(value = "tags") String tags) throws BluePrintException { + try { + return resourceDictionaryService.searchResourceDictionaryByTags(tags); + } catch (Exception e) { + throw new BluePrintException(4003, e.getMessage(), e); + } + } } diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestImpl.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestImpl.java deleted file mode 100644 index e3448424d..000000000 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestImpl.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * 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. - */ - -package org.onap.ccsdk.apps.controllerblueprints.service.rs; - -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException; -import org.onap.ccsdk.apps.controllerblueprints.service.ResourceDictionaryService; -import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary; -import org.springframework.stereotype.Service; - -import java.util.List; - -/** - * {@inheritDoc} - */ -@Service -public class ResourceDictionaryRestImpl implements ResourceDictionaryRest { - - - private ResourceDictionaryService resourceDictionaryService; - - /** - * This is a DataDictionaryRestImpl, used to save and get the Resource Mapping stored in database - * - * @param dataDictionaryService Data Dictionary Service - */ - public ResourceDictionaryRestImpl(ResourceDictionaryService dataDictionaryService) { - this.resourceDictionaryService = dataDictionaryService; - } - - @Override - public ResourceDictionary saveResourceDictionary(ResourceDictionary dataDictionary) - throws BluePrintException { - try { - return resourceDictionaryService.saveResourceDictionary(dataDictionary); - } catch (Exception e) { - throw new BluePrintException(4100, e.getMessage(), e); - } - } - - @Override - public void deleteResourceDictionaryByName(String name) throws BluePrintException { - try { - resourceDictionaryService.deleteResourceDictionary(name); - } catch (Exception e) { - throw new BluePrintException(4400, e.getMessage(), e); - } - } - - @Override - public ResourceDictionary getResourceDictionaryByName(String resourcePath) throws BluePrintException { - try { - return resourceDictionaryService.getResourceDictionaryByName(resourcePath); - } catch (Exception e) { - throw new BluePrintException(4001, e.getMessage(), e); - } - } - - @Override - public List searchResourceDictionaryByNames(List names) - throws BluePrintException { - try { - return resourceDictionaryService.searchResourceDictionaryByNames(names); - } catch (Exception e) { - throw new BluePrintException(4002, e.getMessage(), e); - } - } - - @Override - public List searchResourceDictionaryByTags(String tags) throws BluePrintException { - try { - return resourceDictionaryService.searchResourceDictionaryByTags(tags); - } catch (Exception e) { - throw new BluePrintException(4003, e.getMessage(), e); - } - } - -} diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRest.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRest.java index fcb8f3119..d8ea1941b 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRest.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRest.java @@ -16,119 +16,87 @@ package org.onap.ccsdk.apps.controllerblueprints.service.rs; -import io.swagger.annotations.*; + import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException; import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate; import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment; +import org.onap.ccsdk.apps.controllerblueprints.service.ServiceTemplateService; import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModelContent; import org.onap.ccsdk.apps.controllerblueprints.service.model.AutoMapResponse; +import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; +import org.springframework.web.bind.annotation.*; -import javax.ws.rs.Consumes; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; import java.util.List; - /** - * ServiceTemplateRest.java Purpose: ServiceTemplateRest interface - * - * @author Brinda Santh - * @version 1.0 + * {@inheritDoc} */ +@RestController +@RequestMapping(value = "/api/v1/service-template") +public class ServiceTemplateRest { -@Api -@Path("/service") -@Produces({MediaType.APPLICATION_JSON}) -public interface ServiceTemplateRest { + private ServiceTemplateService serviceTemplateService; /** - * This is a enrichServiceTemplate rest service - * - * @param serviceTemplate - * @return ServiceTemplate - * @throws BluePrintException + * This is a ServiceTemplateRest constructor + * + * @param serviceTemplateService Service Template Service */ - @POST - @Path("/servicetemplate/enrich") - @Consumes({MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_JSON}) - @ApiOperation(value = "Provides Rest service to enrich service template", response = ServiceTemplate.class) - @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"), - @ApiResponse(code = 500, message = "Unexpected Runtime error")}) - ServiceTemplate enrichServiceTemplate(@ApiParam(required = true) ServiceTemplate serviceTemplate) - throws BluePrintException; + public ServiceTemplateRest(ServiceTemplateService serviceTemplateService) { + this.serviceTemplateService = serviceTemplateService; + } - /** - * This is a validateServiceTemplate rest service - * - * @param serviceTemplate - * @return ServiceTemplate - * @throws BluePrintException - */ - @POST - @Path("/servicetemplate/validate") - @Consumes({MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_JSON}) - @ApiOperation(value = "Provides Rest service to validate service template", response = ServiceTemplate.class) - @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"), - @ApiResponse(code = 500, message = "Unexpected Runtime error")}) - ServiceTemplate validateServiceTemplate(@ApiParam(required = true) ServiceTemplate serviceTemplate) - throws BluePrintException; + @PostMapping(path = "/enrich") + public @ResponseBody + ServiceTemplate enrichServiceTemplate(@RequestBody ServiceTemplate serviceTemplate) throws BluePrintException { + try { + return serviceTemplateService.enrichServiceTemplate(serviceTemplate); + } catch (Exception e) { + throw new BluePrintException(3500, e.getMessage(), e); + } + } - /** - * This is a generateResourceAssignments rest service - * - * @param templateContent - * @return List - * @throws BluePrintException - */ - @POST - @Path("/resourceassignment/generate") - @Consumes({MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_JSON}) - @ApiOperation(value = "Provides Rest service to auto map for the Resource Mapping", - response = ResourceAssignment.class, responseContainer = "List") - @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"), - @ApiResponse(code = 500, message = "Unexpected Runtime error")}) - List generateResourceAssignments( - @ApiParam(required = true) ConfigModelContent templateContent) throws BluePrintException; + @PostMapping(path = "/validate") + public @ResponseBody + ServiceTemplate validateServiceTemplate(@RequestBody ServiceTemplate serviceTemplate) throws BluePrintException { + try { + return serviceTemplateService.validateServiceTemplate(serviceTemplate); + } catch (Exception e) { + throw new BluePrintException(3501, e.getMessage(), e); + } + } - /** - * This is a autoMap rest service - * - * @param resourceAssignments - * @return AutoMapResponse - * @throws BluePrintException - */ - @POST - @Path("/resourceassignment/automap") - @Consumes({MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_JSON}) - @ApiOperation(value = "Provides Rest service to auto map for the Resource assignments", - response = AutoMapResponse.class) - @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"), - @ApiResponse(code = 500, message = "Unexpected Runtime error")}) - AutoMapResponse autoMap(@ApiParam(required = true) List resourceAssignments) - throws BluePrintException; + @PostMapping(path = "/resource-assignment/auto-map") + public @ResponseBody + AutoMapResponse autoMap(@RequestBody List resourceAssignments) throws BluePrintException { + try { + return serviceTemplateService.autoMap(resourceAssignments); + } catch (Exception e) { + throw new BluePrintException(3502, e.getMessage(), e); + } + } - /** - * This is a validateResourceAssignments rest service - * - * @param resourceAssignments - * @return List - * @throws BluePrintException - */ - @POST - @Path("/resourceassignment/validate") - @Consumes({MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_JSON}) - @ApiOperation(value = "Provides Rest service to validate Resource assignments", response = ResourceAssignment.class, - responseContainer = "List") - @ApiResponses(value = {@ApiResponse(code = 404, message = "Service not available"), - @ApiResponse(code = 500, message = "Unexpected Runtime error")}) - List validateResourceAssignments( - @ApiParam(required = true) List resourceAssignments) throws BluePrintException; + @PostMapping(path = "/resource-assignment/validate") + public @ResponseBody + List validateResourceAssignments(@RequestBody List resourceAssignments) + throws BluePrintException { + try { + return serviceTemplateService.validateResourceAssignments(resourceAssignments); + } catch (Exception e) { + throw new BluePrintException(3503, e.getMessage(), e); + } + } + + @PostMapping(path = "/resource-assignment/generate") + public @ResponseBody + List generateResourceAssignments(@RequestBody ConfigModelContent templateContent) + throws BluePrintException { + try { + return serviceTemplateService.generateResourceAssignments(templateContent); + } catch (Exception e) { + throw new BluePrintException(3504, e.getMessage(), e); + } + } } diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestImpl.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestImpl.java deleted file mode 100644 index 6c49d5c65..000000000 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestImpl.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * 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. - */ - -package org.onap.ccsdk.apps.controllerblueprints.service.rs; - - -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException; -import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate; -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment; -import org.onap.ccsdk.apps.controllerblueprints.service.ServiceTemplateService; -import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModelContent; -import org.onap.ccsdk.apps.controllerblueprints.service.model.AutoMapResponse; -import org.springframework.stereotype.Service; - -import java.util.List; - -/** - * {@inheritDoc} - */ -@Service -public class ServiceTemplateRestImpl implements ServiceTemplateRest { - - private ServiceTemplateService serviceTemplateService; - - /** - * This is a ServiceTemplateRestImpl constructor - * - * @param serviceTemplateService Service Template Service - */ - public ServiceTemplateRestImpl(ServiceTemplateService serviceTemplateService) { - this.serviceTemplateService = serviceTemplateService; - } - - @Override - public ServiceTemplate enrichServiceTemplate(ServiceTemplate serviceTemplate) throws BluePrintException { - try { - return serviceTemplateService.enrichServiceTemplate(serviceTemplate); - } catch (Exception e) { - throw new BluePrintException(3500, e.getMessage(), e); - } - } - - @Override - public ServiceTemplate validateServiceTemplate(ServiceTemplate serviceTemplate) throws BluePrintException { - try { - return serviceTemplateService.validateServiceTemplate(serviceTemplate); - } catch (Exception e) { - throw new BluePrintException(3501, e.getMessage(), e); - } - } - - @Override - public AutoMapResponse autoMap(List resourceAssignments) throws BluePrintException { - try { - return serviceTemplateService.autoMap(resourceAssignments); - } catch (Exception e) { - throw new BluePrintException(3502, e.getMessage(), e); - } - } - - @Override - public List validateResourceAssignments(List resourceAssignments) - throws BluePrintException { - try { - return serviceTemplateService.validateResourceAssignments(resourceAssignments); - } catch (Exception e) { - throw new BluePrintException(3503, e.getMessage(), e); - } - } - - @Override - public List generateResourceAssignments(ConfigModelContent templateContent) - throws BluePrintException { - try { - return serviceTemplateService.generateResourceAssignments(templateContent); - } catch (Exception e) { - throw new BluePrintException(3504, e.getMessage(), e); - } - } - -} diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/JerseyConfiguration.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/JerseyConfiguration.java deleted file mode 100644 index f5535eb12..000000000 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/JerseyConfiguration.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * 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. - */ - -package org.onap.ccsdk.apps.controllerblueprints; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.MapperFeature; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; -import org.glassfish.jersey.logging.LoggingFeature; -import org.glassfish.jersey.server.ResourceConfig; -import org.glassfish.jersey.servlet.ServletProperties; -import org.onap.ccsdk.apps.controllerblueprints.service.common.ServiceExceptionMapper; -import org.onap.ccsdk.apps.controllerblueprints.service.rs.ConfigModelRestImpl; -import org.onap.ccsdk.apps.controllerblueprints.service.rs.ModelTypeRestImpl; -import org.onap.ccsdk.apps.controllerblueprints.service.rs.ResourceDictionaryRestImpl; -import org.onap.ccsdk.apps.controllerblueprints.service.rs.ServiceTemplateRestImpl; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Primary; -import org.springframework.stereotype.Component; - -import java.util.logging.Logger; - - -@Component -public class JerseyConfiguration extends ResourceConfig { - private static final Logger log = Logger.getLogger(JerseyConfiguration.class.getName()); - - @Bean - @Primary - public ObjectMapper objectMapper() { - ObjectMapper objectMapper = new ObjectMapper(); - objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); - objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); - objectMapper.enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES); - objectMapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING); - objectMapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING); - return objectMapper; - } - - @Autowired - public JerseyConfiguration() { - register(ConfigModelRestImpl.class); - register(ModelTypeRestImpl.class); - register(ResourceDictionaryRestImpl.class); - register(ServiceTemplateRestImpl.class); - // Exception Mapping - register(ServiceExceptionMapper.class); - property(ServletProperties.FILTER_FORWARD_ON_404, true); - register(new LoggingFeature(log)); - } - - -} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/TestConfiguration.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/TestConfiguration.java deleted file mode 100644 index ea259c9c9..000000000 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/TestConfiguration.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * 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. - */ - -package org.onap.ccsdk.apps.controllerblueprints; - -import org.springframework.context.annotation.Bean; - -import java.util.ArrayList; - -//@Configuration -public class TestConfiguration { - - @Bean("jaxrsProviders") - public ArrayList provider() { - return new ArrayList(); - } - - @Bean("jaxrsServices") - public ArrayList service() { - return new ArrayList(); - } - -} diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRestTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRestTest.java index 5b10a7e86..a4a787b08 100644 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRestTest.java +++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRestTest.java @@ -20,7 +20,6 @@ import org.junit.*; import org.junit.runner.RunWith; import org.junit.runners.MethodSorters; import org.onap.ccsdk.apps.controllerblueprints.TestApplication; -import org.onap.ccsdk.apps.controllerblueprints.TestConfiguration; import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel; import org.onap.ccsdk.apps.controllerblueprints.service.utils.ConfigModelUtils; import org.slf4j.Logger; @@ -35,7 +34,7 @@ import java.util.List; @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -@ContextConfiguration(classes = {TestApplication.class, TestConfiguration.class}) +@ContextConfiguration(classes = {TestApplication.class}) @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class ConfigModelRestTest { @@ -68,7 +67,6 @@ public class ConfigModelRestTest { ConfigModel configModel = configModelRest.getInitialConfigModel(name); Assert.assertNotNull("Failed to get Initial Config Model , Return object is Null", configModel); Assert.assertNotNull("Failed to get Service Template Content ", configModel.getConfigModelContents()); - } diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestTest.java index d33349c53..d328b3eac 100644 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestTest.java +++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestTest.java @@ -21,7 +21,6 @@ import org.junit.*; import org.junit.runner.RunWith; import org.junit.runners.MethodSorters; import org.onap.ccsdk.apps.controllerblueprints.TestApplication; -import org.onap.ccsdk.apps.controllerblueprints.TestConfiguration; import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants; import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType; import org.slf4j.Logger; @@ -38,7 +37,7 @@ import java.util.List; @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -@ContextConfiguration(classes = {TestApplication.class, TestConfiguration.class}) +@ContextConfiguration(classes = {TestApplication.class}) @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class ModelTypeRestTest { private static Logger log = LoggerFactory.getLogger(ModelTypeRestTest.class); diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java index 71dff338b..afe9b426f 100644 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java +++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java @@ -24,7 +24,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.MethodSorters; import org.onap.ccsdk.apps.controllerblueprints.TestApplication; -import org.onap.ccsdk.apps.controllerblueprints.TestConfiguration; import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -41,7 +40,7 @@ import java.util.List; @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -@ContextConfiguration(classes = {TestApplication.class, TestConfiguration.class}) +@ContextConfiguration(classes = {TestApplication.class}) @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class ResourceDictionaryRestTest { diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java index f81dd4165..fdc68e4e5 100644 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java +++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java @@ -24,7 +24,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.MethodSorters; import org.onap.ccsdk.apps.controllerblueprints.TestApplication; -import org.onap.ccsdk.apps.controllerblueprints.TestConfiguration; import org.onap.ccsdk.apps.controllerblueprints.core.ConfigModelConstant; import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate; import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils; @@ -46,7 +45,7 @@ import java.util.List; @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -@ContextConfiguration(classes = {TestApplication.class, TestConfiguration.class}) +@ContextConfiguration(classes = {TestApplication.class}) @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class ServiceTemplateRestTest { diff --git a/ms/controllerblueprints/parent/pom.xml b/ms/controllerblueprints/parent/pom.xml index 0b19186d5..f8977d1f3 100644 --- a/ms/controllerblueprints/parent/pom.xml +++ b/ms/controllerblueprints/parent/pom.xml @@ -27,17 +27,19 @@ pom UTF-8 + UTF-8 1.8 1.8 - 1.2.51 - 200.4.2-RELEASE - 2.4.2-RELEASE - 1.4.2 - 1.5.7.RELEASE - 20.0.1-SNAPSHOT + 1.8 + 2.0.4.RELEASE + 1.2.60 + 1.0.0 + 2.9.2 + 1.4.197 + org.springframework.boot spring-boot-dependencies @@ -46,6 +48,24 @@ import + + com.att.eelf + eelf-core + ${eelf.version} + + + + + io.springfox + springfox-swagger2 + ${springfox.swagger2.version} + + + io.springfox + springfox-swagger-ui + ${springfox.swagger2.version} + + org.apache.commons commons-lang3 @@ -66,33 +86,12 @@ velocity 1.7 - - org.json - json - 20180130 - com.google.guava guava 25.1-jre - - io.swagger - swagger-jersey2-jaxrs - 1.5.20 - - - org.glassfish.jersey.containers - * - - - org.glassfish.jersey.core - * - - - - org.jetbrains.kotlin @@ -105,9 +104,17 @@ ${kotlin.version} - com.fasterxml.jackson.module - jackson-module-kotlin - 2.9.6 + org.jetbrains.kotlin + kotlin-stdlib-jdk8 + ${kotlin.version} + + + + + + com.h2database + h2 + ${h2database.version} org.jetbrains.kotlin @@ -134,10 +141,65 @@ + + com.att.eelf + eelf-core + + + org.apache.commons + commons-lang3 + 3.2.1 + + + commons-collections + commons-collections + 3.2.2 + + + commons-io + commons-io + 2.6 + + + com.jayway.jsonpath + json-path + + + io.springfox + springfox-swagger2 + + + io.springfox + springfox-swagger-ui + org.jetbrains.kotlin kotlin-stdlib + + org.jetbrains.kotlin + kotlin-stdlib-jdk8 + + + com.fasterxml.jackson.module + jackson-module-kotlin + + + + junit + junit + test + + + org.jetbrains.kotlin + kotlin-test + test + + + io.projectreactor + reactor-test + test + -- cgit 1.2.3-korg From 5285007a4e66bc18c69cef96aa32326a139d7642 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Tue, 21 Aug 2018 04:11:57 +0000 Subject: Controller Blueprints Microservice Define Controllerblueprint API DataType and Error definitions for Config model, Service Template, Model Type and Resource Dictionary Services Change-Id: I12d8d87292ec101601b0cfb7ba9670730973e318 Issue-ID: CCSDK-469 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- ms/controllerblueprints/README.md | 9 +++ .../artifact_type/artifact-bpmn-camunda.json | 8 +++ .../artifact_type/artifact-directed-graph.json | 9 +++ .../opt/app/onap/config/application.properties | 3 + .../ApplicationExceptionHandler.java | 42 +++++++++++++ .../apps/controllerblueprints/CorsConfig.java | 27 +++++---- .../ControllerBluprintsApplicationTest.java | 22 +++++-- .../src/test/resources/application.properties | 2 +- .../application/src/test/resources/logback.xml | 3 +- .../artifact_type/artifact-bpmn-camunda.json | 8 +++ .../artifact_type/artifact-directed-graph.json | 9 +++ .../core/ConfigModelConstant.kt | 5 -- .../core/data/BluePrintModel.kt | 9 ++- .../core/utils/JacksonUtils.kt | 7 +++ .../load/resource_dictionary/db-source.json | 31 ++++++++++ .../load/resource_dictionary/default-source.json | 14 +++++ .../load/resource_dictionary/input-source.json | 17 ++++++ .../load/resource_dictionary/mdsal-source.json | 36 +++++++++++ .../resource/dict/ResourceAssignment.java | 6 +- .../resource/dict/ResourceDictionaryConstants.java | 24 ++++++++ .../resource/dict/data/DictionaryDefinition.java | 11 ++-- .../resource/dict/data/ResourceSource.java | 22 +++++++ .../resource/dict/data/SourceDb.java | 2 +- .../resource/dict/data/SourceDefault.java | 2 +- .../resource/dict/data/SourceDeserializer.java | 67 +++++++++++++++++++++ .../resource/dict/data/SourceInput.java | 3 +- .../resource/dict/data/SourceMdsal.java | 3 +- .../dict/utils/ResourceDictionaryUtils.java | 10 ++-- .../dict/util/DictionaryDefinitionTest.java | 70 ++++++++++++++++++++++ .../dict/util/ResourceDictionaryUtilsTest.java | 27 ++++----- .../load/resource_dictionary/action-name.json | 17 ------ .../load/resource_dictionary/bundle-id.json | 32 ---------- .../load/resource_dictionary/db-source.json | 31 ++++++++++ .../load/resource_dictionary/input-source.json | 17 ++++++ .../load/resource_dictionary/v4-ip-type.json | 4 +- .../service/ApplicationRegistrationService.java | 39 ++++++++++++ .../service/common/ErrorMessage.java | 32 ++++++---- .../service/domain/ConfigModel.java | 8 ++- .../service/domain/ConfigModelContent.java | 6 +- .../service/domain/ModelType.java | 12 +++- .../service/domain/ResourceDictionary.java | 11 ++++ .../service/rs/ConfigModelRest.java | 21 ++++--- .../service/rs/ModelTypeRest.java | 11 ++-- .../service/rs/ResourceDictionaryRest.java | 11 ++-- .../service/rs/ServiceTemplateRest.java | 13 ++-- .../service/rs/ResourceDictionaryRestTest.java | 6 +- 46 files changed, 625 insertions(+), 154 deletions(-) create mode 100644 ms/controllerblueprints/application/load/model_type/artifact_type/artifact-bpmn-camunda.json create mode 100644 ms/controllerblueprints/application/load/model_type/artifact_type/artifact-directed-graph.json create mode 100644 ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ApplicationExceptionHandler.java create mode 100644 ms/controllerblueprints/modules/core/load/model_type/artifact_type/artifact-bpmn-camunda.json create mode 100644 ms/controllerblueprints/modules/core/load/model_type/artifact_type/artifact-directed-graph.json create mode 100644 ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/db-source.json create mode 100644 ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/default-source.json create mode 100644 ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/input-source.json create mode 100644 ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/mdsal-source.json create mode 100644 ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.java create mode 100644 ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/ResourceSource.java create mode 100644 ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDeserializer.java create mode 100644 ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/util/DictionaryDefinitionTest.java delete mode 100644 ms/controllerblueprints/modules/service/load/resource_dictionary/action-name.json delete mode 100644 ms/controllerblueprints/modules/service/load/resource_dictionary/bundle-id.json create mode 100644 ms/controllerblueprints/modules/service/load/resource_dictionary/db-source.json create mode 100644 ms/controllerblueprints/modules/service/load/resource_dictionary/input-source.json create mode 100644 ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ApplicationRegistrationService.java (limited to 'ms/controllerblueprints/application/src/test/resources') diff --git a/ms/controllerblueprints/README.md b/ms/controllerblueprints/README.md index e69de29bb..070a54169 100755 --- a/ms/controllerblueprints/README.md +++ b/ms/controllerblueprints/README.md @@ -0,0 +1,9 @@ +Application VM Arguments : + +-Dlogging.config=etc/logback.xml +-Dspring.config.location=opt/app/onap/config/ +-Dspring.datasource.url=jdbc:mysql://127.0.0.1:3306/sdnctl +-Dspring.datasource.username=sdnctl +-Dspring.datasource.password=sdnctl +-Dblueprints.load.initial-data=true + diff --git a/ms/controllerblueprints/application/load/model_type/artifact_type/artifact-bpmn-camunda.json b/ms/controllerblueprints/application/load/model_type/artifact_type/artifact-bpmn-camunda.json new file mode 100644 index 000000000..ac76b4f4f --- /dev/null +++ b/ms/controllerblueprints/application/load/model_type/artifact_type/artifact-bpmn-camunda.json @@ -0,0 +1,8 @@ +{ + "description": " Camunda BPM File", + "version": "1.0.0", + "file_ext": [ + "bpmn" + ], + "derived_from": "tosca.artifacts.Implementation" +} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/model_type/artifact_type/artifact-directed-graph.json b/ms/controllerblueprints/application/load/model_type/artifact_type/artifact-directed-graph.json new file mode 100644 index 000000000..7ab3a5434 --- /dev/null +++ b/ms/controllerblueprints/application/load/model_type/artifact_type/artifact-directed-graph.json @@ -0,0 +1,9 @@ +{ + "description": "Directed Graph File", + "version": "1.0.0", + "file_ext": [ + "json", + "xml" + ], + "derived_from": "tosca.artifacts.Implementation" +} \ No newline at end of file diff --git a/ms/controllerblueprints/application/opt/app/onap/config/application.properties b/ms/controllerblueprints/application/opt/app/onap/config/application.properties index 9fa8e04cf..f075b578e 100644 --- a/ms/controllerblueprints/application/opt/app/onap/config/application.properties +++ b/ms/controllerblueprints/application/opt/app/onap/config/application.properties @@ -20,6 +20,9 @@ logging.level.org.springframework.web=INFO logging.level.org.hibernate.SQL=warn logging.level.org.hibernate.type.descriptor.sql=debug +#To Remove Null in JSON API Response +spring.jackson.default-property-inclusion=non_null + spring.jpa.properties.hibernate.show_sql=true spring.jpa.properties.hibernate.use_sql_comments=true spring.jpa.properties.hibernate.format_sql=true diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ApplicationExceptionHandler.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ApplicationExceptionHandler.java new file mode 100644 index 000000000..d02be5c26 --- /dev/null +++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ApplicationExceptionHandler.java @@ -0,0 +1,42 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * 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. + */ + +package org.onap.ccsdk.apps.controllerblueprints; + +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException; +import org.onap.ccsdk.apps.controllerblueprints.service.common.ErrorMessage; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.context.request.WebRequest; + +@ControllerAdvice +@RestController +public class ApplicationExceptionHandler { + @ExceptionHandler(Exception.class) + public final ResponseEntity handleAllExceptions(Exception ex, WebRequest request) { + ErrorMessage exceptionResponse = new ErrorMessage( ex.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR.value(), ex.getLocalizedMessage()); + return new ResponseEntity<>(exceptionResponse, HttpStatus.INTERNAL_SERVER_ERROR); + } + + @ExceptionHandler(BluePrintException.class) + public final ResponseEntity handleBlueprintException(BluePrintException ex, WebRequest request) { + ErrorMessage exceptionResponse = new ErrorMessage( ex.getMessage(), ex.getCode(), ex.getLocalizedMessage()); + return new ResponseEntity<>(exceptionResponse, HttpStatus.INTERNAL_SERVER_ERROR); + } +} diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/CorsConfig.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/CorsConfig.java index 5d682ed50..d00d2c845 100644 --- a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/CorsConfig.java +++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/CorsConfig.java @@ -20,8 +20,9 @@ package org.onap.ccsdk.apps.controllerblueprints; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.cors.CorsConfiguration; -import org.springframework.web.cors.UrlBasedCorsConfigurationSource; -import org.springframework.web.filter.CorsFilter; +import org.springframework.web.cors.reactive.CorsWebFilter; +import org.springframework.web.cors.reactive.UrlBasedCorsConfigurationSource; +import java.util.Arrays; /** * CorsConfig.java Purpose: Provide Configuration Generator CorsConfig Information @@ -29,7 +30,7 @@ import org.springframework.web.filter.CorsFilter; * @author Brinda Santh * @version 1.0 */ -//@Configuration +@Configuration public class CorsConfig { /** * This is a CORS Implementation for different Orgin GUI to access. @@ -37,15 +38,17 @@ public class CorsConfig { * @return CorsFilter */ @Bean - public CorsFilter corsFilter() { - UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); - CorsConfiguration config = new CorsConfiguration(); - config.setAllowCredentials(true); - config.addAllowedOrigin("*"); - config.addAllowedHeader("*"); - config.addAllowedMethod("*"); - source.registerCorsConfiguration("/**", config); - return new CorsFilter(source); + CorsWebFilter corsWebFilter() { + CorsConfiguration corsConfig = new CorsConfiguration(); + corsConfig.setAllowedOrigins(Arrays.asList("*")); + corsConfig.setMaxAge(8000L); + corsConfig.addAllowedMethod("*"); + + UrlBasedCorsConfigurationSource source = + new UrlBasedCorsConfigurationSource(); + source.registerCorsConfiguration("/**", corsConfig); + + return new CorsWebFilter(source); } diff --git a/ms/controllerblueprints/application/src/test/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsApplicationTest.java b/ms/controllerblueprints/application/src/test/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsApplicationTest.java index 95639bd32..26b943b61 100644 --- a/ms/controllerblueprints/application/src/test/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsApplicationTest.java +++ b/ms/controllerblueprints/application/src/test/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsApplicationTest.java @@ -16,17 +16,18 @@ package org.onap.ccsdk.apps.controllerblueprints; +import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.web.client.TestRestTemplate; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; +import org.springframework.http.*; import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.Assertions.assertThat; @@ -46,8 +47,21 @@ public class ControllerBluprintsApplicationTest { @Test public void testConfigModel() { - ResponseEntity entity = this.restTemplate - .getForEntity("/api/v1/config-model/1", String.class); + HttpHeaders headers = new HttpHeaders(); + headers.set("Accept", MediaType.APPLICATION_JSON_VALUE); + ResponseEntity entity = this.restTemplate + .exchange("/api/v1/config-model/1", HttpMethod.GET, new HttpEntity<>(headers),ConfigModel.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); + Assert.assertNotNull("failed to get response Config model",entity.getBody()); + } + + @Test + public void testConfigModelFailure() { + HttpHeaders headers = new HttpHeaders(); + headers.set("Accept", MediaType.APPLICATION_JSON_VALUE); + ResponseEntity entity = this.restTemplate + .exchange("/api/v1/config-model-not-found/1", HttpMethod.GET, new HttpEntity<>(headers),ConfigModel.class); + assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND); + Assert.assertNotNull("failed to get response Config model",entity.getBody()); } } diff --git a/ms/controllerblueprints/application/src/test/resources/application.properties b/ms/controllerblueprints/application/src/test/resources/application.properties index 55ffeaf16..a147034f8 100644 --- a/ms/controllerblueprints/application/src/test/resources/application.properties +++ b/ms/controllerblueprints/application/src/test/resources/application.properties @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # - +spring.jackson.default-property-inclusion=non_null #Load Blueprints # blueprints.load.initial-data may be overridden by ENV variables blueprints.load.initial-data=true diff --git a/ms/controllerblueprints/application/src/test/resources/logback.xml b/ms/controllerblueprints/application/src/test/resources/logback.xml index b9b97dc89..53388bc9e 100644 --- a/ms/controllerblueprints/application/src/test/resources/logback.xml +++ b/ms/controllerblueprints/application/src/test/resources/logback.xml @@ -24,8 +24,7 @@ - - + diff --git a/ms/controllerblueprints/modules/core/load/model_type/artifact_type/artifact-bpmn-camunda.json b/ms/controllerblueprints/modules/core/load/model_type/artifact_type/artifact-bpmn-camunda.json new file mode 100644 index 000000000..ac76b4f4f --- /dev/null +++ b/ms/controllerblueprints/modules/core/load/model_type/artifact_type/artifact-bpmn-camunda.json @@ -0,0 +1,8 @@ +{ + "description": " Camunda BPM File", + "version": "1.0.0", + "file_ext": [ + "bpmn" + ], + "derived_from": "tosca.artifacts.Implementation" +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/core/load/model_type/artifact_type/artifact-directed-graph.json b/ms/controllerblueprints/modules/core/load/model_type/artifact_type/artifact-directed-graph.json new file mode 100644 index 000000000..7ab3a5434 --- /dev/null +++ b/ms/controllerblueprints/modules/core/load/model_type/artifact_type/artifact-directed-graph.json @@ -0,0 +1,9 @@ +{ + "description": "Directed Graph File", + "version": "1.0.0", + "file_ext": [ + "json", + "xml" + ], + "derived_from": "tosca.artifacts.Implementation" +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/ConfigModelConstant.kt b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/ConfigModelConstant.kt index bb5a78fd9..978269125 100644 --- a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/ConfigModelConstant.kt +++ b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/ConfigModelConstant.kt @@ -42,11 +42,6 @@ object ConfigModelConstant { const val CAPABILITY_PROPERTY_MAPPING = "mapping" - const val SOURCE_INPUT = "input" - const val SOURCE_DEFAULT = "default" - const val SOURCE_MDSAL = "mdsal" - const val SOURCE_DB = "db" - const val PROPERTY_RECIPE_NAMES = "action-names" } diff --git a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt index 6d677ffae..a10f6d30c 100644 --- a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt +++ b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt @@ -155,7 +155,7 @@ class PropertyDefinition { var id: String? = null var description: String? = null var required: Boolean? = null - var type: String? = null + lateinit var type: String @get:JsonProperty("default") var defaultValue: Any? = null var status: String? = null @@ -202,7 +202,7 @@ class OperationDefinition { } class Implementation { - var primary: String? = null + lateinit var primary: String var dependencies: MutableList? = null } @@ -240,6 +240,11 @@ class TriggerDefinition { var description: String? = null @get:JsonProperty("event_type") lateinit var eventType: String + @get:JsonProperty("target_filter") + var targetFilter: EventFilterDefinition? = null + var condition: ConditionClause? = null + var constraint: ConditionClause? = null + var method: String? = null lateinit var action: String } diff --git a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt index 95b2af7b7..9621382c3 100644 --- a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt +++ b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt @@ -49,6 +49,13 @@ object JacksonUtils { return jacksonObjectMapper().readValue(content, valueType) } + @JvmStatic + fun readValueFromFile(fileName: String, valueType: Class): T? { + val content: String = FileUtils.readFileToString(File(fileName), Charset.defaultCharset()) + ?: throw BluePrintException(format("Failed to read json file : {}", fileName)) + return readValue(content, valueType) + } + @JvmStatic fun jsonNodeFromObject(from: kotlin.Any): JsonNode = jacksonObjectMapper().convertValue(from, JsonNode::class.java) diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/db-source.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/db-source.json new file mode 100644 index 000000000..8b97cdeb7 --- /dev/null +++ b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/db-source.json @@ -0,0 +1,31 @@ +{ + "name": "bundle-id", + "description": "name of the ", + "resource-type": "ONAP", + "resource-path": "vnf/bundle-id", + "updated-by": "brindasanth@onap.com", + "data-type": "String", + "tags": "bundle-id, brindasanth@onap.com", + "source": { + "db": { + "query": "SELECT db-country, db-state FROM DEVICE_PROFILE WHERE profile_name = :profile_name", + "input-key-mapping": { + "profile_name": "profile_name" + }, + "output-key-mapping": { + "db-country": "country", + "db-state": "state" + } + } + }, + "decryption-rules": [ + { + "sources": [ + "input" + ], + "path": "/.", + "rule": "LOCAL-Decrypt", + "decrypt-type": "AES128" + } + ] +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/default-source.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/default-source.json new file mode 100644 index 000000000..ac23292ed --- /dev/null +++ b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/default-source.json @@ -0,0 +1,14 @@ +{ + "tags": "v4-ip-type, tosca.datatypes.Root, data_type, brindasanth@onap.com", + "name": "v4-ip-type", + "description": "To be provided", + "updated-by": "brindasanth@onap.com", + "resource-type": "ONAP", + "resource-path": "vnf/v4-ip-type", + "data-type": "string", + "source": { + "default": { + + } + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/input-source.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/input-source.json new file mode 100644 index 000000000..35736b663 --- /dev/null +++ b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/input-source.json @@ -0,0 +1,17 @@ +{ + "name": "action-name", + "resource-path": "action-name", + "resource-type": "ONAP", + "description": "To be provided", + "valid-values": null, + "sample-value": null, + "updated-by": "brindasanth@onap.com", + "tags": null, + "default": null, + "data-type": "string", + "source": { + "input": { + "key": "action-name" + } + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/mdsal-source.json b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/mdsal-source.json new file mode 100644 index 000000000..c103f94dc --- /dev/null +++ b/ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/mdsal-source.json @@ -0,0 +1,36 @@ +{ + "tags": "oam-local-ipv4-address, tosca.datatypes.Root, data_type, st1848@att.com", + "name": "oam-local-ipv4-address", + "description": "based on service-instance-id,network-role,v4-ip-type and vm-type get the ipv4-gateway-prefix from the SDN-GC mdsal", + "updated-by": "st1848@att.com", + "resource-type": "ATT", + "resource-path": "vnf/oam-local-ipv4-address", + "data-type": "string", + "source": { + "mdsal": { + "base": "sdnc-gc", + "type": "JSON", + "url-path": "config/L3VNF-API:services/service-list/$service-instance-id/service-data/vnf-topology-information/vnf-assignments/vnf-vms/$vm-type/vm-networks/$network-role/v4-assigned-ip-list/$v4-ip-type", + "path": "/v4-assigned-ip-list/0/v4-ip-prefix", + "input-key-mapping": { + "service-instance-id": "service-instance-id", + "network-role": "network-role", + "v4-ip-type": "v4-ip-type", + "vm-type": "vm-type" + }, + "output-key-mapping": { + "oam-local-ipv4-address": "v4-ip-prefix" + } + } + }, + "candidate-dependency": { + "mdsal": { + "names": [ + "service-instance-id", + "network-role", + "v4-ip-type", + "vm-type" + ] + } + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceAssignment.java b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceAssignment.java index 15576b906..f85e5ebcd 100644 --- a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceAssignment.java +++ b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceAssignment.java @@ -30,10 +30,10 @@ import java.util.List; * @version 1.0 */ public class ResourceAssignment { - + @JsonProperty(value = "name", required = true) private String name; - @JsonProperty("property") + @JsonProperty(value = "property", required = true) private PropertyDefinition property; @JsonProperty("input-param") @@ -58,7 +58,7 @@ public class ResourceAssignment { private String message; @JsonProperty("updated-date") - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy hh:mm:ss") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") private Date updatedDate; @JsonProperty("updated-by") diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.java b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.java new file mode 100644 index 000000000..1af42c590 --- /dev/null +++ b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.java @@ -0,0 +1,24 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * 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. + */ + +package org.onap.ccsdk.apps.controllerblueprints.resource.dict; + +public class ResourceDictionaryConstants { + public static final String SOURCE_INPUT= "input"; + public static final String SOURCE_DEFAULT = "default"; + public static final String SOURCE_DB = "db"; + public static final String SOURCE_MDSAL = "mdsal"; +} diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/DictionaryDefinition.java b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/DictionaryDefinition.java index 4dc9c89a1..7c2d926f0 100644 --- a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/DictionaryDefinition.java +++ b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/DictionaryDefinition.java @@ -17,7 +17,7 @@ package org.onap.ccsdk.apps.controllerblueprints.resource.dict.data; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import java.util.List; import java.util.Map; @@ -29,6 +29,7 @@ import java.util.Map; public class DictionaryDefinition { @JsonProperty(value = "name", required = true) private String name; + @JsonProperty(value = "description") private String description; @@ -39,6 +40,7 @@ public class DictionaryDefinition { private String sampleValue; private String tags; + @JsonProperty(value = "updated-by") private String updatedBy; @@ -58,7 +60,8 @@ public class DictionaryDefinition { private Object defaultValue; @JsonProperty(value = "source", required = true) - private Map source; + @JsonDeserialize(using = SourceDeserializer.class, keyAs = String.class, contentAs = ResourceSource.class) + private Map source; @JsonProperty("candidate-dependency") private Map dependency; @@ -154,11 +157,11 @@ public class DictionaryDefinition { this.defaultValue = defaultValue; } - public Map getSource() { + public Map getSource() { return source; } - public void setSource(Map source) { + public void setSource(Map source) { this.source = source; } diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/ResourceSource.java b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/ResourceSource.java new file mode 100644 index 000000000..735832cb1 --- /dev/null +++ b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/ResourceSource.java @@ -0,0 +1,22 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * 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. + */ + +package org.onap.ccsdk.apps.controllerblueprints.resource.dict.data; + +import java.io.Serializable; + +public interface ResourceSource extends Serializable { +} diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDb.java b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDb.java index 23d404605..724d0224e 100644 --- a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDb.java +++ b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDb.java @@ -24,7 +24,7 @@ import java.util.Map; * SourceDb * @author Brinda Santh */ -public class SourceDb { +public class SourceDb implements ResourceSource{ @JsonProperty(value = "base", required = true) private String base; @JsonProperty(value = "type", required = true) diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDefault.java b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDefault.java index 0a4351cca..d165192e9 100644 --- a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDefault.java +++ b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDefault.java @@ -20,7 +20,7 @@ package org.onap.ccsdk.apps.controllerblueprints.resource.dict.data; * SourceDefault * @author Brinda Santh */ -public class SourceDefault { +public class SourceDefault implements ResourceSource { private String key; diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDeserializer.java b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDeserializer.java new file mode 100644 index 000000000..86476e1c2 --- /dev/null +++ b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceDeserializer.java @@ -0,0 +1,67 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * 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. + */ + +package org.onap.ccsdk.apps.controllerblueprints.resource.dict.data; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.*; +import com.fasterxml.jackson.databind.node.ObjectNode; +import com.google.common.base.Preconditions; +import org.apache.commons.lang3.StringUtils; +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +public class SourceDeserializer extends JsonDeserializer> { + + private static final Logger log = LoggerFactory.getLogger(SourceDeserializer.class); + + private Class keyAs; + + private Class contentAs; + + private static Map> registry = new HashMap>(); + + public static void registerSource(String uniqueAttribute, Class sourceClass) { + registry.put(uniqueAttribute, sourceClass); + } + + @Override + public Map deserialize(JsonParser p, DeserializationContext ctxt) + throws IOException, JsonProcessingException { + + ObjectMapper mapper = (ObjectMapper) p.getCodec(); + ObjectNode root = (ObjectNode) mapper.readTree(p); + Map sources = new HashMap(); + root.fields().forEachRemaining((node) -> { + String key = node.getKey(); + JsonNode valueNode = node.getValue(); + Preconditions.checkArgument(StringUtils.isNotBlank(key), "missing source key"); + Preconditions.checkArgument(registry.containsKey(key), key +" source not registered"); + if (StringUtils.isNotBlank(key) && registry.containsKey(key)) { + Class sourceClass = registry.get(key); + ResourceSource resourceSource = JacksonUtils.readValue(valueNode.toString(), sourceClass); + sources.put(key, resourceSource); + } + }); + return sources; + } +} diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceInput.java b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceInput.java index 82cb769da..87184f223 100644 --- a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceInput.java +++ b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceInput.java @@ -20,7 +20,7 @@ package org.onap.ccsdk.apps.controllerblueprints.resource.dict.data; * SourceInput * @author Brinda Santh */ -public class SourceInput { +public class SourceInput implements ResourceSource { private String key; @@ -33,5 +33,4 @@ public class SourceInput { } - } diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceMdsal.java b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceMdsal.java index 9eb233e76..8a066e91a 100644 --- a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceMdsal.java +++ b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/data/SourceMdsal.java @@ -24,7 +24,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import java.util.Map; -public class SourceMdsal { +public class SourceMdsal implements ResourceSource { @JsonProperty(value = "base", required = true) private String base; @@ -93,5 +93,4 @@ public class SourceMdsal { } - } diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.java b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.java index 9d51d8213..4f9467f05 100644 --- a/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.java +++ b/ms/controllerblueprints/modules/resource-dict/src/main/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.java @@ -16,15 +16,15 @@ package org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils; -import com.fasterxml.jackson.databind.JsonNode; import org.apache.commons.collections.MapUtils; import org.apache.commons.lang3.StringUtils; -import org.onap.ccsdk.apps.controllerblueprints.core.ConfigModelConstant; import org.onap.ccsdk.apps.controllerblueprints.core.data.EntrySchema; import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition; import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment; +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants; import org.onap.ccsdk.apps.controllerblueprints.resource.dict.data.DictionaryDefinition; import org.onap.ccsdk.apps.controllerblueprints.resource.dict.data.DictionaryDependency; +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.data.ResourceSource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -63,7 +63,7 @@ public class ResourceDictionaryUtils { // Overwrite the Property Definitions from Dictionary setProperty(resourceAssignment, dictionaryDefinition); - Map dictionarySource = dictionaryDefinition.getSource(); + Map dictionarySource = dictionaryDefinition.getSource(); Map dictionaryDependencyMap = dictionaryDefinition.getDependency(); if (MapUtils.isNotEmpty(dictionarySource)) { @@ -82,7 +82,7 @@ public class ResourceDictionaryUtils { } } } else { - resourceAssignment.setDictionarySource(ConfigModelConstant.SOURCE_INPUT); + resourceAssignment.setDictionarySource(ResourceDictionaryConstants.SOURCE_INPUT); } log.info("auto map resourceAssignment : {}", resourceAssignment); } @@ -98,7 +98,7 @@ public class ResourceDictionaryUtils { } } - private static String findFirstSource(Map dictionarySource) { + private static String findFirstSource(Map dictionarySource) { String source = null; if (MapUtils.isNotEmpty(dictionarySource)) { source = dictionarySource.keySet().stream().findFirst().get(); diff --git a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/util/DictionaryDefinitionTest.java b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/util/DictionaryDefinitionTest.java new file mode 100644 index 000000000..851ba1256 --- /dev/null +++ b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/util/DictionaryDefinitionTest.java @@ -0,0 +1,70 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * 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. + */ + +package org.onap.ccsdk.apps.controllerblueprints.resource.dict.util; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils; +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants; +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.data.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class DictionaryDefinitionTest { + private Logger log = LoggerFactory.getLogger(DictionaryDefinitionTest.class); + String basePath = "load/resource_dictionary"; + + @Before + public void setup(){ + SourceDeserializer.registerSource(ResourceDictionaryConstants.SOURCE_DB, SourceDb.class); + SourceDeserializer.registerSource(ResourceDictionaryConstants.SOURCE_INPUT, SourceInput.class); + SourceDeserializer.registerSource(ResourceDictionaryConstants.SOURCE_MDSAL, SourceMdsal.class); + SourceDeserializer.registerSource(ResourceDictionaryConstants.SOURCE_DEFAULT,SourceDefault.class); + } + + @Test + public void testDictionaryDefinitionInputSource(){ + + String fileName = basePath + "/input-source.json"; + DictionaryDefinition dictionaryDefinition = JacksonUtils.readValueFromFile(fileName, DictionaryDefinition.class); + Assert.assertNotNull("Failed to populate dictionaryDefinition for input type", dictionaryDefinition); + } + + @Test + public void testDictionaryDefinitionDefaultSource(){ + + String fileName = basePath + "/default-source.json"; + DictionaryDefinition dictionaryDefinition = JacksonUtils.readValueFromFile(fileName, DictionaryDefinition.class); + Assert.assertNotNull("Failed to populate dictionaryDefinition for default type", dictionaryDefinition); + } + + @Test + public void testDictionaryDefinitionDBSource(){ + + String fileName = basePath + "/db-source.json"; + DictionaryDefinition dictionaryDefinition = JacksonUtils.readValueFromFile(fileName, DictionaryDefinition.class); + Assert.assertNotNull("Failed to populate dictionaryDefinition for db type", dictionaryDefinition); + } + + @Test + public void testDictionaryDefinitionMDSALSource(){ + String fileName = basePath + "/mdsal-source.json"; + DictionaryDefinition dictionaryDefinition = JacksonUtils.readValueFromFile(fileName, DictionaryDefinition.class); + Assert.assertNotNull("Failed to populate dictionaryDefinition for mdsal type", dictionaryDefinition); + } +} diff --git a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/util/ResourceDictionaryUtilsTest.java b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/util/ResourceDictionaryUtilsTest.java index 22b01c4a8..0c9a1c5d8 100644 --- a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/util/ResourceDictionaryUtilsTest.java +++ b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/util/ResourceDictionaryUtilsTest.java @@ -17,13 +17,11 @@ package org.onap.ccsdk.apps.controllerblueprints.resource.dict.util; -import com.fasterxml.jackson.databind.JsonNode; import org.junit.Assert; import org.junit.Test; import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants; -import org.onap.ccsdk.apps.controllerblueprints.core.ConfigModelConstant; -import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils; import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment; +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants; import org.onap.ccsdk.apps.controllerblueprints.resource.dict.data.*; import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.ResourceDictionaryUtils; import org.slf4j.Logger; @@ -45,9 +43,9 @@ public class ResourceDictionaryUtilsTest { DictionaryDefinition dictionaryDefinition = new DictionaryDefinition(); dictionaryDefinition.setDataType(BluePrintConstants.DATA_TYPE_STRING); - Map source = new HashMap<>(); + Map source = new HashMap<>(); SourceInput sourceInput = new SourceInput(); - source.put(ConfigModelConstant.SOURCE_INPUT, JacksonUtils.jsonNodeFromObject(sourceInput)); + source.put(ResourceDictionaryConstants.SOURCE_INPUT, sourceInput); dictionaryDefinition.setSource(source); ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, dictionaryDefinition); @@ -72,15 +70,16 @@ public class ResourceDictionaryUtilsTest { DictionaryDefinition dictionaryDefinition = new DictionaryDefinition(); dictionaryDefinition.setDataType(BluePrintConstants.DATA_TYPE_STRING); - Map source = new HashMap<>(); + Map source = new HashMap<>(); SourceDb sourceDb = new SourceDb(); - source.put(ConfigModelConstant.SOURCE_DB, JacksonUtils.jsonNodeFromObject(sourceDb)); + sourceDb.setBase("sdnc_connection"); + source.put(ResourceDictionaryConstants.SOURCE_DB, sourceDb); dictionaryDefinition.setSource(source); Map dependency = new HashMap<>(); DictionaryDependency dependencyDb = new DictionaryDependency(); dependencyDb.setNames(Arrays.asList("vnf-id", "vnf-name")); - dependency.put(ConfigModelConstant.SOURCE_DB, dependencyDb); + dependency.put(ResourceDictionaryConstants.SOURCE_DB, dependencyDb); dictionaryDefinition.setDependency(dependency); DecryptionRule decryptionRule = new DecryptionRule(); @@ -115,15 +114,15 @@ public class ResourceDictionaryUtilsTest { DictionaryDefinition dictionaryDefinition = new DictionaryDefinition(); dictionaryDefinition.setDataType(BluePrintConstants.DATA_TYPE_STRING); - Map source = new HashMap<>(); + Map source = new HashMap<>(); SourceDefault sourceDefault = new SourceDefault(); - source.put(ConfigModelConstant.SOURCE_DEFAULT, JacksonUtils.jsonNodeFromObject(sourceDefault)); + source.put(ResourceDictionaryConstants.SOURCE_DEFAULT, sourceDefault); dictionaryDefinition.setSource(source); Map dependency = new HashMap<>(); DictionaryDependency dependencyDefault = new DictionaryDependency(); dependencyDefault.setNames(Arrays.asList(new String[]{"vnf-id", "vnf-name"})); - dependency.put(ConfigModelConstant.SOURCE_DEFAULT, dependencyDefault); + dependency.put(ResourceDictionaryConstants.SOURCE_DEFAULT, dependencyDefault); dictionaryDefinition.setDependency(dependency); ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, dictionaryDefinition); @@ -143,15 +142,15 @@ public class ResourceDictionaryUtilsTest { DictionaryDefinition dictionaryDefinition = new DictionaryDefinition(); dictionaryDefinition.setDataType(BluePrintConstants.DATA_TYPE_STRING); - Map source = new HashMap<>(); + Map source = new HashMap<>(); SourceMdsal sourceMdsal = new SourceMdsal(); - source.put(ConfigModelConstant.SOURCE_MDSAL, JacksonUtils.jsonNodeFromObject(sourceMdsal)); + source.put(ResourceDictionaryConstants.SOURCE_MDSAL,sourceMdsal); dictionaryDefinition.setSource(source); Map dependency = new HashMap<>(); DictionaryDependency dependencyMdsal = new DictionaryDependency(); dependencyMdsal.setNames(Arrays.asList(new String[]{"vnf-id", "vnf-name"})); - dependency.put(ConfigModelConstant.SOURCE_MDSAL, dependencyMdsal); + dependency.put(ResourceDictionaryConstants.SOURCE_MDSAL, dependencyMdsal); dictionaryDefinition.setDependency(dependency); ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, dictionaryDefinition); diff --git a/ms/controllerblueprints/modules/service/load/resource_dictionary/action-name.json b/ms/controllerblueprints/modules/service/load/resource_dictionary/action-name.json deleted file mode 100644 index 92b64e629..000000000 --- a/ms/controllerblueprints/modules/service/load/resource_dictionary/action-name.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "action-name", - "resource-path": "action-name", - "resource-type": "ONAP", - "description": "To be provided", - "valid-values": null, - "sample-value": null, - "updated-by": "ym9479@onap.com", - "tags": null, - "default": null, - "data-type": "string", - "source": { - "input": { - "key": "action-name" - } - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/load/resource_dictionary/bundle-id.json b/ms/controllerblueprints/modules/service/load/resource_dictionary/bundle-id.json deleted file mode 100644 index f9678f5ff..000000000 --- a/ms/controllerblueprints/modules/service/load/resource_dictionary/bundle-id.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "name": "bundle-id", - "description": "name of the ", - "resource-type": "ONAP", - "resource-path": "vnf/bundle-id", - "updated-by": "ym9479@onap.com", - "data-type": "String", - "tags": "bundle-id, ym9479@onap.com", - "source": { - "db": { - "path": "$key-value", - "input-key-mapping": { - "key-value": "$resource-group-key" - }, - "output-key-mapping": { - "bundle-id": "bundle-id" - } - }, - "input": { - } - }, - "decryption-rules": [ - { - "sources": [ - "input" - ], - "path": "/.", - "rule": "LOCAL-Decrypt", - "decrypt-type": "AES128" - } - ] -} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/load/resource_dictionary/db-source.json b/ms/controllerblueprints/modules/service/load/resource_dictionary/db-source.json new file mode 100644 index 000000000..862523544 --- /dev/null +++ b/ms/controllerblueprints/modules/service/load/resource_dictionary/db-source.json @@ -0,0 +1,31 @@ +{ + "name": "bundle-id", + "description": "name of the ", + "resource-type": "ONAP", + "resource-path": "vnf/bundle-id", + "updated-by": "brindasanth@onap.com", + "data-type": "String", + "tags": "bundle-id, brindasanth@onap.com", + "source": { + "db": { + "query": "SELECT bundle-id FROM DEVICE_PROFILE WHERE profile_name = :profile_name", + "input-key-mapping": { + "profile_name": "profile_name" + }, + "output-key-mapping": { + "db-country": "country", + "db-state": "state" + } + } + }, + "decryption-rules": [ + { + "sources": [ + "input" + ], + "path": "/.", + "rule": "LOCAL-Decrypt", + "decrypt-type": "AES128" + } + ] +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/load/resource_dictionary/input-source.json b/ms/controllerblueprints/modules/service/load/resource_dictionary/input-source.json new file mode 100644 index 000000000..35736b663 --- /dev/null +++ b/ms/controllerblueprints/modules/service/load/resource_dictionary/input-source.json @@ -0,0 +1,17 @@ +{ + "name": "action-name", + "resource-path": "action-name", + "resource-type": "ONAP", + "description": "To be provided", + "valid-values": null, + "sample-value": null, + "updated-by": "brindasanth@onap.com", + "tags": null, + "default": null, + "data-type": "string", + "source": { + "input": { + "key": "action-name" + } + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/load/resource_dictionary/v4-ip-type.json b/ms/controllerblueprints/modules/service/load/resource_dictionary/v4-ip-type.json index 03254b78a..c6c0f9851 100644 --- a/ms/controllerblueprints/modules/service/load/resource_dictionary/v4-ip-type.json +++ b/ms/controllerblueprints/modules/service/load/resource_dictionary/v4-ip-type.json @@ -1,8 +1,8 @@ { - "tags": "v4-ip-type, tosca.datatypes.Root, data_type, ym9479@onap.com", + "tags": "v4-ip-type, tosca.datatypes.Root, data_type, brindasanth@onap.com", "name": "v4-ip-type", "description": "To be provided", - "updated-by": "ym9479@onap.com", + "updated-by": "brindasanth@onap.com", "resource-type": "ONAP", "resource-path": "vnf/v4-ip-type", "data-type": "string", diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ApplicationRegistrationService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ApplicationRegistrationService.java new file mode 100644 index 000000000..074f18d05 --- /dev/null +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ApplicationRegistrationService.java @@ -0,0 +1,39 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * 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. + */ + +package org.onap.ccsdk.apps.controllerblueprints.service; + +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants; +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.data.*; +import org.springframework.stereotype.Component; + +import javax.annotation.PostConstruct; + +@Component +public class ApplicationRegistrationService { + + @PostConstruct + public void register(){ + registerDictionarySources(); + } + + public void registerDictionarySources(){ + SourceDeserializer.registerSource(ResourceDictionaryConstants.SOURCE_DB, SourceDb.class); + SourceDeserializer.registerSource(ResourceDictionaryConstants.SOURCE_INPUT, SourceInput.class); + SourceDeserializer.registerSource(ResourceDictionaryConstants.SOURCE_MDSAL, SourceMdsal.class); + SourceDeserializer.registerSource(ResourceDictionaryConstants.SOURCE_DEFAULT,SourceDefault.class); + } +} diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ErrorMessage.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ErrorMessage.java index f7a802e46..431641265 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ErrorMessage.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ErrorMessage.java @@ -16,24 +16,25 @@ package org.onap.ccsdk.apps.controllerblueprints.service.common; +import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; import java.io.Serializable; +import java.util.Date; @JsonInclude(Include.NON_NULL) public class ErrorMessage implements Serializable { - private Integer httpStatus; private String message; private Integer code; - private String developerMessage; + private String debugMessage; + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") + private Date timestamp = new Date(); - public Integer getHttpStatus() { - return httpStatus; - } - - public void setHttpStatus(Integer httpStatus) { - this.httpStatus = httpStatus; + public ErrorMessage(String message, Integer code, String debugMessage){ + this.message = message; + this.code = code; + this.debugMessage = debugMessage; } public String getMessage() { @@ -52,12 +53,19 @@ public class ErrorMessage implements Serializable { this.code = code; } - public String getDeveloperMessage() { - return developerMessage; + public String getDebugMessage() { + return debugMessage; } - public void setDeveloperMessage(String developerMessage) { - this.developerMessage = developerMessage; + public void setDebugMessage(String developerMessage) { + this.debugMessage = developerMessage; } + public Date getTimestamp() { + return timestamp; + } + + public void setTimestamp(Date timestamp) { + this.timestamp = timestamp; + } } \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModel.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModel.java index 224960fa5..45382815c 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModel.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModel.java @@ -18,6 +18,7 @@ package org.onap.ccsdk.apps.controllerblueprints.service.domain; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonManagedReference; +import io.swagger.annotations.ApiModelProperty; import org.hibernate.annotations.Proxy; import org.springframework.data.annotation.LastModifiedDate; import org.springframework.data.jpa.domain.support.AuditingEntityListener; @@ -82,6 +83,7 @@ public class ConfigModel implements Serializable { @NotNull @Column(name = "artifact_version") + @ApiModelProperty(required=true) private String artifactVersion; @Lob @@ -91,7 +93,7 @@ public class ConfigModel implements Serializable { @Column(name = "internal_version") private Integer internalVersion; - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MM/dd/yyyy KK:mm:ss a Z") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") @LastModifiedDate @Temporal(TemporalType.TIMESTAMP) @Column(name = "creation_date") @@ -99,19 +101,23 @@ public class ConfigModel implements Serializable { @NotNull @Column(name = "artifact_name") + @ApiModelProperty(required=true) private String artifactName; @NotNull @Column(name = "published") + @ApiModelProperty(required=true) private String published; @NotNull @Column(name = "updated_by") + @ApiModelProperty(required=true) private String updatedBy; @NotNull @Lob @Column(name = "tags") + @ApiModelProperty(required=true) private String tags; diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModelContent.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModelContent.java index f7bd554df..0c05ef959 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModelContent.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModelContent.java @@ -18,6 +18,7 @@ package org.onap.ccsdk.apps.controllerblueprints.service.domain; import com.fasterxml.jackson.annotation.JsonBackReference; import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; import org.springframework.data.annotation.LastModifiedDate; import org.springframework.data.jpa.domain.support.AuditingEntityListener; @@ -46,10 +47,12 @@ public class ConfigModelContent { @NotNull @Column(name = "name") + @ApiModelProperty(required=true) private String name; @NotNull @Column(name = "content_type") + @ApiModelProperty(required=true) private String contentType; @@ -65,10 +68,11 @@ public class ConfigModelContent { @NotNull @Lob @Column(name = "content") + @ApiModelProperty(required=true) private String content; - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MM/dd/yyyy KK:mm:ss a Z") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") @LastModifiedDate @Temporal(TemporalType.TIMESTAMP) @Column(name = "updated_date") diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ModelType.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ModelType.java index ed6340a65..61e4d1189 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ModelType.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ModelType.java @@ -16,6 +16,8 @@ package org.onap.ccsdk.apps.controllerblueprints.service.domain; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; import org.springframework.data.annotation.LastModifiedDate; import org.springframework.data.jpa.domain.support.AuditingEntityListener; @@ -40,36 +42,43 @@ public class ModelType implements Serializable { @Id @NotNull @Column(name = "model_name", nullable = false) + @ApiModelProperty(required=true) private String modelName; @NotNull @Column(name = "derived_from") + @ApiModelProperty(required=true) private String derivedFrom; @NotNull @Column(name = "definition_type") + @ApiModelProperty(required=true) private String definitionType; @NotNull @Lob @Column(name = "definition") + @ApiModelProperty(required=true) private String definition; @NotNull @Lob @Column(name = "description") + @ApiModelProperty(required=true) private String description; @NotNull @Column(name = "version") + @ApiModelProperty(required=true) private String version; @NotNull @Lob @Column(name = "tags") + @ApiModelProperty(required=true) private String tags; - // @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MM/dd/yyyy KK:mm:ss a Z") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") @LastModifiedDate @Temporal(TemporalType.TIMESTAMP) @Column(name = "creation_date") @@ -77,6 +86,7 @@ public class ModelType implements Serializable { @NotNull @Column(name = "updated_by") + @ApiModelProperty(required=true) private String updatedBy; @Override diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ResourceDictionary.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ResourceDictionary.java index adb018841..0d5879db8 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ResourceDictionary.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ResourceDictionary.java @@ -16,6 +16,8 @@ package org.onap.ccsdk.apps.controllerblueprints.service.domain; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; import org.springframework.data.annotation.LastModifiedDate; import org.springframework.data.jpa.domain.support.AuditingEntityListener; @@ -39,18 +41,22 @@ public class ResourceDictionary implements Serializable { @Id @NotNull @Column(name = "name") + @ApiModelProperty(required=true) private String name; @NotNull @Column(name = "resource_path") + @ApiModelProperty(required=true) private String resourcePath; @NotNull @Column(name = "resource_type") + @ApiModelProperty(required=true) private String resourceType; @NotNull @Column(name = "data_type") + @ApiModelProperty(required=true) private String dataType; @Column(name = "entry_schema") @@ -67,18 +73,22 @@ public class ResourceDictionary implements Serializable { @NotNull @Lob @Column(name = "definition") + @ApiModelProperty(required=true) private String definition; @NotNull @Lob @Column(name = "description") + @ApiModelProperty(required=true) private String description; @NotNull @Lob @Column(name = "tags") + @ApiModelProperty(required=true) private String tags; + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") @LastModifiedDate @Temporal(TemporalType.TIMESTAMP) @Column(name = "creation_date") @@ -86,6 +96,7 @@ public class ResourceDictionary implements Serializable { @NotNull @Column(name = "updated_by") + @ApiModelProperty(required=true) private String updatedBy; @Override diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRest.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRest.java index 94324a808..62b683032 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRest.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRest.java @@ -19,8 +19,7 @@ package org.onap.ccsdk.apps.controllerblueprints.service.rs; import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException; import org.onap.ccsdk.apps.controllerblueprints.service.ConfigModelService; import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel; -import org.springframework.stereotype.Component; -import org.springframework.stereotype.Service; +import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.*; import java.util.List; @@ -29,7 +28,7 @@ import java.util.List; * {@inheritDoc} */ @RestController -@RequestMapping("/api/v1/config-model") +@RequestMapping(value = "/api/v1/config-model") public class ConfigModelRest { private ConfigModelService configModelService; @@ -44,7 +43,7 @@ public class ConfigModelRest { } - @GetMapping(path = "/initial/{name}") + @GetMapping(path = "/initial/{name}", produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody ConfigModel getInitialConfigModel(@PathVariable(value = "name") String name) throws BluePrintException { try { @@ -54,7 +53,7 @@ public class ConfigModelRest { } } - @PostMapping(path = "/") + @PostMapping(path = "/", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody ConfigModel saveConfigModel(@RequestBody ConfigModel configModel) throws BluePrintException { try { @@ -69,11 +68,11 @@ public class ConfigModelRest { try { this.configModelService.deleteConfigModel(id); } catch (Exception e) { - throw new BluePrintException(4000, e.getMessage(), e); + throw new BluePrintException(2400, e.getMessage(), e); } } - @GetMapping(path = "/publish/{id}") + @GetMapping(path = "/publish/{id}", produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody ConfigModel publishConfigModel(@PathVariable(value = "id") Long id) throws BluePrintException { try { @@ -83,7 +82,7 @@ public class ConfigModelRest { } } - @GetMapping(path = "/{id}") + @GetMapping(path = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody ConfigModel getConfigModel(@PathVariable(value = "id") Long id) throws BluePrintException { try { @@ -93,7 +92,7 @@ public class ConfigModelRest { } } - @GetMapping(path = "/by-name/{name}/version/{version}") + @GetMapping(path = "/by-name/{name}/version/{version}", produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody ConfigModel getConfigModelByNameAndVersion(@PathVariable(value = "name") String name, @PathVariable(value = "version") String version) throws BluePrintException { @@ -104,7 +103,7 @@ public class ConfigModelRest { } } - @GetMapping(path = "/search/{tags}") + @GetMapping(path = "/search/{tags}", produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody List searchConfigModels(@PathVariable(value = "tags") String tags) throws BluePrintException { try { @@ -114,7 +113,7 @@ public class ConfigModelRest { } } - @GetMapping(path = "/clone/{id}") + @GetMapping(path = "/clone/{id}", produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody ConfigModel getCloneConfigModel(@PathVariable(value = "id") Long id) throws BluePrintException { try { diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java index 2fa64316f..f6e5c274f 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java @@ -19,6 +19,7 @@ package org.onap.ccsdk.apps.controllerblueprints.service.rs; import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException; import org.onap.ccsdk.apps.controllerblueprints.service.ModelTypeService; import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType; +import org.springframework.http.MediaType; import org.springframework.stereotype.Component; import org.springframework.stereotype.Service; import org.springframework.web.bind.annotation.*; @@ -29,7 +30,7 @@ import java.util.List; * {@inheritDoc} */ @RestController -@RequestMapping("/api/v1/model-type") +@RequestMapping(value = "/api/v1/model-type") public class ModelTypeRest { private ModelTypeService modelTypeService; @@ -43,7 +44,7 @@ public class ModelTypeRest { this.modelTypeService = modelTypeService; } - @GetMapping(path = "/{name}") + @GetMapping(path = "/{name}", produces = MediaType.APPLICATION_JSON_VALUE) public ModelType getModelTypeByName(@PathVariable(value = "name") String name) throws BluePrintException { try { return modelTypeService.getModelTypeByName(name); @@ -52,7 +53,7 @@ public class ModelTypeRest { } } - @GetMapping(path = "/search/{tags}") + @GetMapping(path = "/search/{tags}", produces = MediaType.APPLICATION_JSON_VALUE) public List searchModelTypes(@PathVariable(value = "tags") String tags) throws BluePrintException { try { return modelTypeService.searchModelTypes(tags); @@ -61,7 +62,7 @@ public class ModelTypeRest { } } - @GetMapping(path = "/by-definition/{definitionType}") + @GetMapping(path = "/by-definition/{definitionType}", produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody List getModelTypeByDefinitionType(@PathVariable(value = "definitionType") String definitionType) throws BluePrintException { try { @@ -71,7 +72,7 @@ public class ModelTypeRest { } } - @PostMapping(path = "/") + @PostMapping(path = "/", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody ModelType saveModelType(@RequestBody ModelType modelType) throws BluePrintException { try { diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java index dfb06bba5..795738cb1 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java @@ -19,8 +19,7 @@ package org.onap.ccsdk.apps.controllerblueprints.service.rs; import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException; import org.onap.ccsdk.apps.controllerblueprints.service.ResourceDictionaryService; import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary; -import org.springframework.stereotype.Component; -import org.springframework.stereotype.Service; +import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.*; import java.util.List; @@ -44,7 +43,7 @@ public class ResourceDictionaryRest { this.resourceDictionaryService = dataDictionaryService; } - @PostMapping(path = "/") + @PostMapping(path = "/", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody ResourceDictionary saveResourceDictionary(@RequestBody ResourceDictionary dataDictionary) throws BluePrintException { @@ -64,7 +63,7 @@ public class ResourceDictionaryRest { } } - @GetMapping(path = "/{name}") + @GetMapping(path = "/{name}", produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody ResourceDictionary getResourceDictionaryByName(@PathVariable(value = "name") String name) throws BluePrintException { try { @@ -74,7 +73,7 @@ public class ResourceDictionaryRest { } } - @PostMapping(path = "/by-names") + @PostMapping(path = "/by-names", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody List searchResourceDictionaryByNames(@RequestBody List names) throws BluePrintException { @@ -85,7 +84,7 @@ public class ResourceDictionaryRest { } } - @GetMapping(path = "/search/{tags}") + @GetMapping(path = "/search/{tags}", produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody List searchResourceDictionaryByTags(@PathVariable(value = "tags") String tags) throws BluePrintException { try { diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRest.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRest.java index d8ea1941b..a22285b88 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRest.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRest.java @@ -23,8 +23,7 @@ import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment import org.onap.ccsdk.apps.controllerblueprints.service.ServiceTemplateService; import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModelContent; import org.onap.ccsdk.apps.controllerblueprints.service.model.AutoMapResponse; -import org.springframework.stereotype.Component; -import org.springframework.stereotype.Service; +import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.*; import java.util.List; @@ -47,7 +46,7 @@ public class ServiceTemplateRest { this.serviceTemplateService = serviceTemplateService; } - @PostMapping(path = "/enrich") + @PostMapping(path = "/enrich", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody ServiceTemplate enrichServiceTemplate(@RequestBody ServiceTemplate serviceTemplate) throws BluePrintException { try { @@ -57,7 +56,7 @@ public class ServiceTemplateRest { } } - @PostMapping(path = "/validate") + @PostMapping(path = "/validate", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody ServiceTemplate validateServiceTemplate(@RequestBody ServiceTemplate serviceTemplate) throws BluePrintException { try { @@ -67,7 +66,7 @@ public class ServiceTemplateRest { } } - @PostMapping(path = "/resource-assignment/auto-map") + @PostMapping(path = "/resource-assignment/auto-map", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody AutoMapResponse autoMap(@RequestBody List resourceAssignments) throws BluePrintException { try { @@ -77,7 +76,7 @@ public class ServiceTemplateRest { } } - @PostMapping(path = "/resource-assignment/validate") + @PostMapping(path = "/resource-assignment/validate", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody List validateResourceAssignments(@RequestBody List resourceAssignments) throws BluePrintException { @@ -88,7 +87,7 @@ public class ServiceTemplateRest { } } - @PostMapping(path = "/resource-assignment/generate") + @PostMapping(path = "/resource-assignment/generate", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody List generateResourceAssignments(@RequestBody ConfigModelContent templateContent) throws BluePrintException { diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java index afe9b426f..73d6eca99 100644 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java +++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java @@ -24,6 +24,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.MethodSorters; import org.onap.ccsdk.apps.controllerblueprints.TestApplication; +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.data.*; import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -51,7 +52,10 @@ public class ResourceDictionaryRestTest { @Before public void setUp() { - + SourceDeserializer.registerSource("db", SourceDb.class); + SourceDeserializer.registerSource("input", SourceInput.class); + SourceDeserializer.registerSource("mdsal", SourceMdsal.class); + SourceDeserializer.registerSource("default", SourceDefault.class); } @Test -- cgit 1.2.3-korg From 713a0958b1796d06ca19ad9be396e92999e851d6 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Mon, 3 Sep 2018 00:50:25 +0000 Subject: Controller Blueprints Microservice Add Logger MDC using ONAP LoggerAdaptor and change swagger configuration to return the transactions information, version, etc Change-Id: Ie1dccecce0c08e7ae02c0e55c1cc5be75d5fc686 Issue-ID: CCSDK-510 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- ms/controllerblueprints/README.md | 3 + .../application/etc/logback.xml | 9 +- ms/controllerblueprints/application/etc/run.source | 2 +- .../opt/app/onap/config/application.properties | 8 ++ .../ApplicationExceptionHandler.java | 16 ++- .../ControllerBluprintsApplication.java | 2 +- .../apps/controllerblueprints/CorsConfig.java | 55 ----------- .../apps/controllerblueprints/SwaggerConfig.java | 97 ++++++++++++++++++- .../ccsdk/apps/controllerblueprints/WebConfig.java | 1 + .../filters/ApplicationLoggingFilter.java | 81 ++++++++++++++++ .../controllerblueprints/filters/CorsFilter.java | 61 ++++++++++++ .../controllerblueprints/VersionSplitTest.java | 36 +++++++ .../src/test/resources/application.properties | 11 +++ .../distribution/src/main/dc/docker-compose.yaml | 5 +- .../core/BluePrintConstants.kt | 7 +- .../service/ConfigModelService.java | 107 ++++++++++++--------- .../service/rs/ConfigModelRest.java | 50 ++-------- .../service/rs/ModelTypeRest.java | 2 +- .../service/rs/ResourceDictionaryRest.java | 2 +- ms/controllerblueprints/parent/pom.xml | 10 ++ 20 files changed, 409 insertions(+), 156 deletions(-) delete mode 100644 ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/CorsConfig.java create mode 100644 ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/filters/ApplicationLoggingFilter.java create mode 100644 ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/filters/CorsFilter.java create mode 100644 ms/controllerblueprints/application/src/test/java/org/onap/ccsdk/apps/controllerblueprints/VersionSplitTest.java (limited to 'ms/controllerblueprints/application/src/test/resources') diff --git a/ms/controllerblueprints/README.md b/ms/controllerblueprints/README.md index 070a54169..4079daf60 100755 --- a/ms/controllerblueprints/README.md +++ b/ms/controllerblueprints/README.md @@ -1,5 +1,8 @@ Application VM Arguments : +-DappName=ControllerBluePrints +-Dms_name=org.onap.ccsdk.apps.controllerblueprints +-DappVersion=1.0.0 -Dlogging.config=etc/logback.xml -Dspring.config.location=opt/app/onap/config/ -Dspring.datasource.url=jdbc:mysql://127.0.0.1:3306/sdnctl diff --git a/ms/controllerblueprints/application/etc/logback.xml b/ms/controllerblueprints/application/etc/logback.xml index 44e9a8a11..0a75e60f5 100644 --- a/ms/controllerblueprints/application/etc/logback.xml +++ b/ms/controllerblueprints/application/etc/logback.xml @@ -15,11 +15,18 @@ --> + + + + + + + - %d{HH:mm:ss.SSS} %-5level %logger{100} - %msg%n + ${defaultPattern} diff --git a/ms/controllerblueprints/application/etc/run.source b/ms/controllerblueprints/application/etc/run.source index cba5e1dd2..fc1b4e554 100644 --- a/ms/controllerblueprints/application/etc/run.source +++ b/ms/controllerblueprints/application/etc/run.source @@ -4,7 +4,7 @@ java -classpath "/etc:${APP_HOME}/lib/*:/lib/*:/src:/schema:/generated-sources:$ -DVERSION_ROUTEOFFER_ENVCONTEXT=${BUNDLEVERSION}/${STICKYSELECTORKEY}/${ENVCONTEXT} \ -DSecurityFilePath=/etc \ -DREST_NAME_NORMALIZER_PATTERN_FILE=/etc/PatternInputs.txt \ --Dms_name=org.onap.ccsdk.apps.controllerblueprints.ControllerBlueprints \ +-Dms_name=org.onap.ccsdk.apps.controllerblueprints \ -Dlogging.config=${APP_CONFIG_HOME}/logback.xml \ -Djava.security.egd=file:/dev/./urandom \ -DAPPNAME=${APP_NAME} -DAPPENV=${APP_ENV} -DAPPVERSION=${APP_VERSION} -DNAMESPACE=${NAMESPACE} \ diff --git a/ms/controllerblueprints/application/opt/app/onap/config/application.properties b/ms/controllerblueprints/application/opt/app/onap/config/application.properties index f075b578e..3b6033e7f 100644 --- a/ms/controllerblueprints/application/opt/app/onap/config/application.properties +++ b/ms/controllerblueprints/application/opt/app/onap/config/application.properties @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +appName=ControllerBluePrints +ms_name=org.onap.ccsdk.apps.controllerblueprints +appVersion=1.0.0 #logging.pattern.console=%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p) %clr($ threadId: {PID:- }){magenta} %clr(---){faint} %clr([ hostname: %X{hostname} serviceName: %X{serviceName} version: %X{version} transactionId: %X{transactionId} requestTimeStamp: %X{requestTimestamp} responseTimeStamp: %X{responseTimestamp} duration: %X{duration}]){yellow} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n%wex @@ -23,6 +26,11 @@ logging.level.org.hibernate.type.descriptor.sql=debug #To Remove Null in JSON API Response spring.jackson.default-property-inclusion=non_null +#Swagger Configuration +swagger.contact.name=Brinda Santh Muthuramalingam +swagger.contact.url=www.onap.com +swagger.contact.email=brindasanth@onap.com + spring.jpa.properties.hibernate.show_sql=true spring.jpa.properties.hibernate.use_sql_comments=true spring.jpa.properties.hibernate.format_sql=true diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ApplicationExceptionHandler.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ApplicationExceptionHandler.java index 0a403b8c9..6e9dcd7f9 100644 --- a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ApplicationExceptionHandler.java +++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ApplicationExceptionHandler.java @@ -22,6 +22,9 @@ import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException; import org.onap.ccsdk.apps.controllerblueprints.service.common.ErrorMessage; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; +import org.springframework.http.converter.HttpMessageNotReadableException; +import org.springframework.web.HttpRequestMethodNotSupportedException; +import org.springframework.web.bind.MethodArgumentNotValidException; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RestController; @@ -32,17 +35,26 @@ import org.springframework.web.context.request.WebRequest; @SuppressWarnings("unused") public class ApplicationExceptionHandler { private static EELFLogger log = EELFManager.getInstance().getLogger(ApplicationExceptionHandler.class); + @ExceptionHandler(Exception.class) public final ResponseEntity handleAllExceptions(Exception ex, WebRequest request) { log.error("Application Exception", ex); - ErrorMessage exceptionResponse = new ErrorMessage( ex.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR.value(), ex.getLocalizedMessage()); + ErrorMessage exceptionResponse = new ErrorMessage(ex.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR.value(), ex.getLocalizedMessage()); return new ResponseEntity<>(exceptionResponse, HttpStatus.INTERNAL_SERVER_ERROR); } + @ExceptionHandler({HttpMessageNotReadableException.class, MethodArgumentNotValidException.class, + HttpRequestMethodNotSupportedException.class}) + public final ResponseEntity handleBadRequest(Exception ex, WebRequest request) { + log.error("Bad Request Exception", ex); + ErrorMessage exceptionResponse = new ErrorMessage(ex.getMessage(), HttpStatus.BAD_REQUEST.value(), ex.getLocalizedMessage()); + return new ResponseEntity<>(exceptionResponse, HttpStatus.BAD_REQUEST); + } + @ExceptionHandler(BluePrintException.class) public final ResponseEntity handleBlueprintException(BluePrintException ex, WebRequest request) { log.error("Application Blueprint Exception", ex); - ErrorMessage exceptionResponse = new ErrorMessage( ex.getMessage(), ex.getCode(), ex.getLocalizedMessage()); + ErrorMessage exceptionResponse = new ErrorMessage(ex.getMessage(), ex.getCode(), ex.getLocalizedMessage()); return new ResponseEntity<>(exceptionResponse, HttpStatus.INTERNAL_SERVER_ERROR); } } diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsApplication.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsApplication.java index 447e1966d..6b0efd87b 100644 --- a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsApplication.java +++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsApplication.java @@ -35,7 +35,7 @@ public class ControllerBluprintsApplication { private static EELFLogger log = EELFManager.getInstance().getLogger(ControllerBluprintsApplication.class); public static void main(String[] args) { - log.info("****** Starting Controller Bluprints Application **************"); + log.info("****** Starting Controlled Blueprints Application ******"); SpringApplication.run(ControllerBluprintsApplication.class, args); } diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/CorsConfig.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/CorsConfig.java deleted file mode 100644 index d00d2c845..000000000 --- a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/CorsConfig.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * 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. - */ - -package org.onap.ccsdk.apps.controllerblueprints; - - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.cors.CorsConfiguration; -import org.springframework.web.cors.reactive.CorsWebFilter; -import org.springframework.web.cors.reactive.UrlBasedCorsConfigurationSource; -import java.util.Arrays; - -/** - * CorsConfig.java Purpose: Provide Configuration Generator CorsConfig Information - * - * @author Brinda Santh - * @version 1.0 - */ -@Configuration -public class CorsConfig { - /** - * This is a CORS Implementation for different Orgin GUI to access. - * - * @return CorsFilter - */ - @Bean - CorsWebFilter corsWebFilter() { - CorsConfiguration corsConfig = new CorsConfiguration(); - corsConfig.setAllowedOrigins(Arrays.asList("*")); - corsConfig.setMaxAge(8000L); - corsConfig.addAllowedMethod("*"); - - UrlBasedCorsConfigurationSource source = - new UrlBasedCorsConfigurationSource(); - source.registerCorsConfiguration("/**", corsConfig); - - return new CorsWebFilter(source); - } - - -} diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/SwaggerConfig.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/SwaggerConfig.java index 67e3e5d00..cfcccf338 100644 --- a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/SwaggerConfig.java +++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/SwaggerConfig.java @@ -16,16 +16,30 @@ package org.onap.ccsdk.apps.controllerblueprints; +import com.google.common.collect.Lists; +import org.jetbrains.annotations.NotNull; +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants; +import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.RequestMethod; import springfox.documentation.builders.PathSelectors; import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.builders.ResponseMessageBuilder; +import springfox.documentation.schema.ModelRef; import springfox.documentation.service.ApiInfo; import springfox.documentation.service.Contact; +import springfox.documentation.service.Header; +import springfox.documentation.service.ResponseMessage; import springfox.documentation.spi.DocumentationType; import springfox.documentation.spring.web.plugins.Docket; import springfox.documentation.swagger2.annotations.EnableSwagger2; + import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; /** * SwaggerConfig @@ -36,10 +50,23 @@ import java.util.Collections; @EnableSwagger2 @SuppressWarnings("unused") public class SwaggerConfig { + @Value("${appVersion}") + private String appVersion; + @Value("${swagger.contact.name}") + private String contactName; + @Value("${swagger.contact.url}") + private String contactUrl; + @Value("${swagger.contact.email}") + private String contactEmail; + @Bean @SuppressWarnings("unused") public Docket api() { return new Docket(DocumentationType.SWAGGER_2) + .globalResponseMessage(RequestMethod.GET, getDefaultGetResponseMessages()) + .globalResponseMessage(RequestMethod.POST, getDefaultPostResponseMessages()) + .globalResponseMessage(RequestMethod.PUT, getDefaultPutResponseMessages()) + .globalResponseMessage(RequestMethod.DELETE, getDefaultDeleteResponseMessages()) .select() .apis(RequestHandlerSelectors.any()) .paths(PathSelectors.any()) @@ -51,11 +78,77 @@ public class SwaggerConfig { return new ApiInfo( "Controller Blueprints API", "Controller blueprints API for VNF Self Service.", - "1.0.0", + appVersion, "Terms of service", - new Contact("Brinda Santh", "www.onap.com", "brindasanth@onap.com"), + new Contact(contactName, contactUrl, contactEmail), "Apache 2.0", "http://www.apache.org/licenses/LICENSE-2.0", Collections.emptyList()); } + private List getDefaultGetResponseMessages() { + List defaultResponseMessages = Lists.newArrayList(); + Map defaultHeaders = getDefaultResponseHeaders(); + defaultResponseMessages.add(getResponseBuilder(HttpStatus.OK, defaultHeaders)); + defaultResponseMessages.add(getResponseBuilder(HttpStatus.BAD_REQUEST, defaultHeaders)); + defaultResponseMessages.add(getResponseBuilder(HttpStatus.UNAUTHORIZED, defaultHeaders)); + defaultResponseMessages.add(getResponseBuilder(HttpStatus.FORBIDDEN, defaultHeaders)); + defaultResponseMessages.add(getResponseBuilder(HttpStatus.NOT_FOUND, defaultHeaders)); + defaultResponseMessages.add(getResponseBuilder(HttpStatus.INTERNAL_SERVER_ERROR, defaultHeaders)); + return defaultResponseMessages; + } + + private List getDefaultPostResponseMessages() { + List defaultResponseMessages = Lists.newArrayList(); + Map defaultHeaders = getDefaultResponseHeaders(); + defaultResponseMessages.add(getResponseBuilder(HttpStatus.OK, defaultHeaders)); + defaultResponseMessages.add(getResponseBuilder(HttpStatus.CREATED, defaultHeaders)); + defaultResponseMessages.add(getResponseBuilder(HttpStatus.BAD_REQUEST, defaultHeaders)); + defaultResponseMessages.add(getResponseBuilder(HttpStatus.UNAUTHORIZED, defaultHeaders)); + defaultResponseMessages.add(getResponseBuilder(HttpStatus.FORBIDDEN, defaultHeaders)); + defaultResponseMessages.add(getResponseBuilder(HttpStatus.INTERNAL_SERVER_ERROR, defaultHeaders)); + return defaultResponseMessages; + } + + private List getDefaultPutResponseMessages() { + List defaultResponseMessages = Lists.newArrayList(); + Map defaultHeaders = getDefaultResponseHeaders(); + defaultResponseMessages.add(getResponseBuilder(HttpStatus.OK, defaultHeaders)); + defaultResponseMessages.add(getResponseBuilder(HttpStatus.BAD_REQUEST, defaultHeaders)); + defaultResponseMessages.add(getResponseBuilder(HttpStatus.UNAUTHORIZED, defaultHeaders)); + defaultResponseMessages.add(getResponseBuilder(HttpStatus.FORBIDDEN, defaultHeaders)); + defaultResponseMessages.add(getResponseBuilder(HttpStatus.INTERNAL_SERVER_ERROR, defaultHeaders)); + return defaultResponseMessages; + } + + private List getDefaultDeleteResponseMessages() { + List defaultResponseMessages = Lists.newArrayList(); + Map defaultHeaders = getDefaultResponseHeaders(); + defaultResponseMessages.add(getResponseBuilder(HttpStatus.OK, defaultHeaders)); + defaultResponseMessages.add(getResponseBuilder(HttpStatus.BAD_REQUEST, defaultHeaders)); + defaultResponseMessages.add(getResponseBuilder(HttpStatus.UNAUTHORIZED, defaultHeaders)); + defaultResponseMessages.add(getResponseBuilder(HttpStatus.FORBIDDEN, defaultHeaders)); + defaultResponseMessages.add(getResponseBuilder(HttpStatus.INTERNAL_SERVER_ERROR, defaultHeaders)); + return defaultResponseMessages; + } + private ResponseMessage getResponseBuilder(@NotNull HttpStatus httpStatus, Map defaultHeaders) { + ResponseMessageBuilder responseMessageBuilder = new ResponseMessageBuilder(); + responseMessageBuilder.code(httpStatus.value()) + .message(httpStatus.getReasonPhrase()) + .headersWithDescription(defaultHeaders) + .build(); + return responseMessageBuilder.build(); + } + + private Map getDefaultResponseHeaders() { + Map defaultHeaders = new HashMap<>(); + defaultHeaders.put(BluePrintConstants.RESPONSE_HEADER_TRANSACTION_ID, + new Header(BluePrintConstants.RESPONSE_HEADER_TRANSACTION_ID, "Transaction Id", new ModelRef("string"))); + defaultHeaders.put(BluePrintConstants.RESPONSE_HEADER_LATEST_VERSION, + new Header(BluePrintConstants.RESPONSE_HEADER_LATEST_VERSION, "API Latest Version", new ModelRef("string"))); + defaultHeaders.put(BluePrintConstants.RESPONSE_HEADER_MINOR_VERSION, + new Header(BluePrintConstants.RESPONSE_HEADER_MINOR_VERSION, "API Minor Version", new ModelRef("string"))); + defaultHeaders.put(BluePrintConstants.RESPONSE_HEADER_PATCH_VERSION, + new Header(BluePrintConstants.RESPONSE_HEADER_PATCH_VERSION, "API Patch Version", new ModelRef("string"))); + return defaultHeaders; + } } diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/WebConfig.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/WebConfig.java index 1eba97cdc..c5cdee625 100644 --- a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/WebConfig.java +++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/WebConfig.java @@ -26,6 +26,7 @@ import org.springframework.web.reactive.config.WebFluxConfigurationSupport; * @author Brinda Santh 8/13/2018 */ @Configuration +@SuppressWarnings("unused") public class WebConfig extends WebFluxConfigurationSupport { public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("swagger-ui.html") diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/filters/ApplicationLoggingFilter.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/filters/ApplicationLoggingFilter.java new file mode 100644 index 000000000..9a556e717 --- /dev/null +++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/filters/ApplicationLoggingFilter.java @@ -0,0 +1,81 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * 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. + */ + +package org.onap.ccsdk.apps.controllerblueprints.filters; + +import com.google.common.base.Preconditions; +import org.apache.commons.lang3.StringUtils; +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants; +import org.onap.logging.ref.slf4j.ONAPLogAdapter; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.MDC; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import javax.servlet.*; +import javax.servlet.annotation.WebFilter; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +/** + * ApplicationLoggingFilter + * + * @author Brinda Santh 8/14/2018 + */ +@Component +@WebFilter(asyncSupported = true, urlPatterns = {"/*"}) +@SuppressWarnings("unused") +public class ApplicationLoggingFilter implements Filter { + private static Logger log = LoggerFactory.getLogger(ApplicationLoggingFilter.class); + + @SuppressWarnings("unused") + @Value("${appVersion}") + private String appVersion; + + public void doFilter(ServletRequest request, + ServletResponse response, + FilterChain chain) throws IOException, ServletException { + + HttpServletRequest req = (HttpServletRequest) request; + HttpServletResponse res = (HttpServletResponse) response; + + ONAPLogAdapter onapLogAdapter = new ONAPLogAdapter(log); + onapLogAdapter.entering(req); + + String[] tokens = StringUtils.split(appVersion, '.'); + Preconditions.checkNotNull(tokens, "failed to split application versions"); + Preconditions.checkArgument(tokens.length == 3, "failed to tokenize application versions"); + res.addHeader(BluePrintConstants.RESPONSE_HEADER_TRANSACTION_ID, MDC.get("RequestID")); + res.addHeader(BluePrintConstants.RESPONSE_HEADER_MINOR_VERSION, tokens[1]); + res.addHeader(BluePrintConstants.RESPONSE_HEADER_PATCH_VERSION, tokens[2]); + res.addHeader(BluePrintConstants.RESPONSE_HEADER_LATEST_VERSION, appVersion); + chain.doFilter(request, response); + // Clean the MDC info + onapLogAdapter.exiting(); + } + + @Override + public void init(FilterConfig filterConfig) { + + } + + @Override + public void destroy() { + + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/filters/CorsFilter.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/filters/CorsFilter.java new file mode 100644 index 000000000..91cc731d0 --- /dev/null +++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/filters/CorsFilter.java @@ -0,0 +1,61 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * 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. + */ + +package org.onap.ccsdk.apps.controllerblueprints.filters; + +import org.springframework.http.HttpMethod; +import org.springframework.stereotype.Component; +import javax.servlet.*; +import javax.servlet.annotation.WebFilter; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +/** + * CorsFilter.java Purpose: Provide Configuration Generator CorsFilter Information + * + * @author Brinda Santh + */ +@Component +@WebFilter(asyncSupported = true, urlPatterns = {"/*"}) +@SuppressWarnings("unused") +public class CorsFilter implements Filter { + + public void destroy() { + } + + public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain) + throws IOException, ServletException { + + HttpServletRequest request = (HttpServletRequest) servletRequest; + HttpServletResponse response = (HttpServletResponse) servletResponse; + + response.addHeader("Access-Control-Allow-Origin", "*"); + response.addHeader("Access-Control-Allow-Methods", "*"); + response.addHeader("Access-Control-Allow-Headers", + "DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range"); + + if (request.getMethod().equals(HttpMethod.OPTIONS.toString())) { + response.addHeader("Access-Control-Max-Age", "1728000"); + response.setStatus(HttpServletResponse.SC_ACCEPTED); + return; + } + chain.doFilter(request, servletResponse); + } + + public void init(FilterConfig fConfig) throws ServletException { + } + +} \ No newline at end of file diff --git a/ms/controllerblueprints/application/src/test/java/org/onap/ccsdk/apps/controllerblueprints/VersionSplitTest.java b/ms/controllerblueprints/application/src/test/java/org/onap/ccsdk/apps/controllerblueprints/VersionSplitTest.java new file mode 100644 index 000000000..9445e1d36 --- /dev/null +++ b/ms/controllerblueprints/application/src/test/java/org/onap/ccsdk/apps/controllerblueprints/VersionSplitTest.java @@ -0,0 +1,36 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * 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. + */ + +package org.onap.ccsdk.apps.controllerblueprints; + +import org.apache.commons.lang3.StringUtils; +import org.junit.Assert; +import org.junit.Test; +/** + * VersionSplitTest + * + * @author Brinda Santh + */ +public class VersionSplitTest { + + @Test + public void testVersionSplit() { + String version = "1.03.04"; + String[] tokens = StringUtils.split(version, '.'); + Assert.assertNotNull("failed to tokenize", tokens); + Assert.assertEquals("failed to three token ", 3, tokens.length ); + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/application/src/test/resources/application.properties b/ms/controllerblueprints/application/src/test/resources/application.properties index a147034f8..a63ed5b71 100644 --- a/ms/controllerblueprints/application/src/test/resources/application.properties +++ b/ms/controllerblueprints/application/src/test/resources/application.properties @@ -13,7 +13,18 @@ # See the License for the specific language governing permissions and # limitations under the License. # +appName=ControllerBluePrints +ms_name=org.onap.ccsdk.apps.controllerblueprints +appVersion=1.0.0 + +#To Remove Null in JSON API Response spring.jackson.default-property-inclusion=non_null + +#Swagger Configuration +swagger.contact.name=Brinda Santh Muthuramalingam +swagger.contact.url=www.onap.com +swagger.contact.email=brindasanth@onap.com + #Load Blueprints # blueprints.load.initial-data may be overridden by ENV variables blueprints.load.initial-data=true diff --git a/ms/controllerblueprints/distribution/src/main/dc/docker-compose.yaml b/ms/controllerblueprints/distribution/src/main/dc/docker-compose.yaml index 9450f3065..493d43813 100644 --- a/ms/controllerblueprints/distribution/src/main/dc/docker-compose.yaml +++ b/ms/controllerblueprints/distribution/src/main/dc/docker-compose.yaml @@ -26,11 +26,12 @@ services: - ~/share/vm_ms/controllerblueprints/config:/opt/app/onap/config - ~/share/vm_ms/controllerblueprints/logs:/logs environment: + APPLICATIONNAME : ControllerBluePrints + BUNDLEVERSION: 1.0.0 + APP_CONFIG_HOME: /opt/app/onap/config DB_URL: jdbc:mysql://db:3306/sdnctl DB_USER: sdnctl DB_PASSWORD: sdnctl INIT_DATA_LOAD: "true" - APP_CONFIG_HOME: /opt/app/onap/config - BUNDLEVERSION: 1.0.0 STICKYSELECTORKEY: ENVCONTEXT: DEV \ No newline at end of file diff --git a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt index 2e3edb65e..4ae1f4d5d 100644 --- a/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt +++ b/ms/controllerblueprints/modules/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt @@ -17,12 +17,17 @@ package org.onap.ccsdk.apps.controllerblueprints.core /** - * + * BluePrintConstants * * @author Brinda Santh */ object BluePrintConstants { + const val RESPONSE_HEADER_TRANSACTION_ID: String = "X-ONAP-RequestID" + const val RESPONSE_HEADER_MINOR_VERSION: String = "X-MinorVersion" + const val RESPONSE_HEADER_PATCH_VERSION: String = "X-PatchVersion" + const val RESPONSE_HEADER_LATEST_VERSION: String = "X-LatestVersion" + const val TYPE_DEFAULT: String = "default" const val DATA_TYPE_STRING: String = "string" diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelService.java index 534394a3e..a2f653c67 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelService.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelService.java @@ -19,6 +19,7 @@ package org.onap.ccsdk.apps.controllerblueprints.service; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; +import org.jetbrains.annotations.NotNull; import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants; import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException; import org.onap.ccsdk.apps.controllerblueprints.core.ConfigModelConstant; @@ -68,6 +69,7 @@ public class ConfigModelService { this.configModelRepository = configModelRepository; this.configModelContentRepository = configModelContentRepository; this.configModelCreateService = configModelCreateService; + log.info("Config Model Service Initiated..."); } /** @@ -143,8 +145,8 @@ public class ConfigModelService { * @param version version * @return ConfigModel */ - public ConfigModel getConfigModelByNameAndVersion(String name, String version) { - ConfigModel configModel = null; + public ConfigModel getConfigModelByNameAndVersion(@NotNull String name, String version) throws BluePrintException { + ConfigModel configModel; Optional dbConfigModel; if (StringUtils.isNotBlank(version)) { dbConfigModel = configModelRepository.findByArtifactNameAndArtifactVersion(name, version); @@ -153,6 +155,8 @@ public class ConfigModelService { } if (dbConfigModel.isPresent()) { configModel = dbConfigModel.get(); + } else { + throw new BluePrintException(String.format("failed to get config model name(%s), version(%s) from repo", name, version)); } return configModel; } @@ -162,15 +166,17 @@ public class ConfigModelService { * * @param id id * @return ConfigModel + * @throws BluePrintException BluePrintException */ - public ConfigModel getConfigModel(Long id) { - ConfigModel configModel = null; - if (id != null) { - Optional dbConfigModel = configModelRepository.findById(id); - if (dbConfigModel.isPresent()) { - configModel = dbConfigModel.get(); - } + public ConfigModel getConfigModel(@NotNull Long id) throws BluePrintException { + ConfigModel configModel; + Optional dbConfigModel = configModelRepository.findById(id); + if (dbConfigModel.isPresent()) { + configModel = dbConfigModel.get(); + } else { + throw new BluePrintException(String.format("failed to get config model id(%d) from repo", id)); } + return configModel; } @@ -179,54 +185,56 @@ public class ConfigModelService { * * @param id id * @return ConfigModel + * @throws BluePrintException BluePrintException */ - public ConfigModel getCloneConfigModel(Long id) { + public ConfigModel getCloneConfigModel(@NotNull Long id) throws BluePrintException { ConfigModel configModel; - ConfigModel cloneConfigModel = null; - if (id != null) { - Optional dbConfigModel = configModelRepository.findById(id); - if (dbConfigModel.isPresent()) { - configModel = dbConfigModel.get(); - cloneConfigModel = configModel; - cloneConfigModel.setUpdatedBy("xxxxx@xxx.com"); - cloneConfigModel.setArtifactName("XXXX"); - cloneConfigModel.setPublished("XXXX"); - cloneConfigModel.setPublished("XXXX"); - cloneConfigModel.setUpdatedBy("XXXX"); - cloneConfigModel.setId(null); - cloneConfigModel.setTags(null); - cloneConfigModel.setCreatedDate(new Date()); - List configModelContents = cloneConfigModel.getConfigModelContents(); - - if (CollectionUtils.isNotEmpty(configModelContents)) { - for (ConfigModelContent configModelContent : configModelContents) { - if (configModelContent != null && StringUtils.isNotBlank(configModelContent.getContentType())) { - configModelContent.setId(null); - configModelContent.setCreationDate(new Date()); - - if (ConfigModelConstant.MODEL_CONTENT_TYPE_TOSCA_JSON - .equalsIgnoreCase(configModelContent.getContentType())) { - ServiceTemplate serviceTemplate = JacksonUtils - .readValue(configModelContent.getContent(), ServiceTemplate.class); - if (serviceTemplate != null && serviceTemplate.getMetadata() != null) { - serviceTemplate.getMetadata() - .put(BluePrintConstants.METADATA_TEMPLATE_AUTHOR, "XXXX"); - serviceTemplate.getMetadata() - .put(BluePrintConstants.METADATA_TEMPLATE_VERSION, "1.0.0"); - serviceTemplate.getMetadata() - .put(BluePrintConstants.METADATA_TEMPLATE_NAME, "XXXXXX"); - - configModelContent.setContent(JacksonUtils.getJson(serviceTemplate)); - } + ConfigModel cloneConfigModel; + Optional dbConfigModel = configModelRepository.findById(id); + if (dbConfigModel.isPresent()) { + configModel = dbConfigModel.get(); + cloneConfigModel = configModel; + cloneConfigModel.setUpdatedBy("xxxxx@xxx.com"); + cloneConfigModel.setArtifactName("XXXX"); + cloneConfigModel.setPublished("XXXX"); + cloneConfigModel.setPublished("XXXX"); + cloneConfigModel.setUpdatedBy("XXXX"); + cloneConfigModel.setId(null); + cloneConfigModel.setTags(null); + cloneConfigModel.setCreatedDate(new Date()); + List configModelContents = cloneConfigModel.getConfigModelContents(); + + if (CollectionUtils.isNotEmpty(configModelContents)) { + for (ConfigModelContent configModelContent : configModelContents) { + if (configModelContent != null && StringUtils.isNotBlank(configModelContent.getContentType())) { + configModelContent.setId(null); + configModelContent.setCreationDate(new Date()); + + if (ConfigModelConstant.MODEL_CONTENT_TYPE_TOSCA_JSON + .equalsIgnoreCase(configModelContent.getContentType())) { + ServiceTemplate serviceTemplate = JacksonUtils + .readValue(configModelContent.getContent(), ServiceTemplate.class); + if (serviceTemplate != null && serviceTemplate.getMetadata() != null) { + serviceTemplate.getMetadata() + .put(BluePrintConstants.METADATA_TEMPLATE_AUTHOR, "XXXX"); + serviceTemplate.getMetadata() + .put(BluePrintConstants.METADATA_TEMPLATE_VERSION, "1.0.0"); + serviceTemplate.getMetadata() + .put(BluePrintConstants.METADATA_TEMPLATE_NAME, "XXXXXX"); + + configModelContent.setContent(JacksonUtils.getJson(serviceTemplate)); } } - } + } } + } else { + throw new BluePrintException(String.format("failed to get config model id(%d) from repo", id)); } + return cloneConfigModel; } @@ -234,14 +242,17 @@ public class ConfigModelService { * This is a deleteConfigModel method * * @param id id + * @throws BluePrintException BluePrintException */ @Transactional - public void deleteConfigModel(Long id) { + public void deleteConfigModel(@NotNull Long id) throws BluePrintException { Optional dbConfigModel = configModelRepository.findById(id); if (dbConfigModel.isPresent()) { configModelContentRepository.deleteByConfigModel(dbConfigModel.get()); configModelRepository.delete(dbConfigModel.get()); + } else { + throw new BluePrintException(String.format("failed to get config model id(%d) from repo", id)); } } diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRest.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRest.java index 62b683032..fc2956bea 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRest.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRest.java @@ -46,81 +46,49 @@ public class ConfigModelRest { @GetMapping(path = "/initial/{name}", produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody ConfigModel getInitialConfigModel(@PathVariable(value = "name") String name) throws BluePrintException { - try { - return this.configModelService.getInitialConfigModel(name); - } catch (Exception e) { - throw new BluePrintException(2000, e.getMessage(), e); - } + return this.configModelService.getInitialConfigModel(name); } - @PostMapping(path = "/", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) + @PostMapping(path = "", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody ConfigModel saveConfigModel(@RequestBody ConfigModel configModel) throws BluePrintException { - try { - return this.configModelService.saveConfigModel(configModel); - } catch (Exception e) { - throw new BluePrintException(2200, e.getMessage(), e); - } + return this.configModelService.saveConfigModel(configModel); } @DeleteMapping(path = "/{id}") public void deleteConfigModel(@PathVariable(value = "id") Long id) throws BluePrintException { - try { - this.configModelService.deleteConfigModel(id); - } catch (Exception e) { - throw new BluePrintException(2400, e.getMessage(), e); - } + this.configModelService.deleteConfigModel(id); } @GetMapping(path = "/publish/{id}", produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody ConfigModel publishConfigModel(@PathVariable(value = "id") Long id) throws BluePrintException { - try { - return this.configModelService.publishConfigModel(id); - } catch (Exception e) { - throw new BluePrintException(2500, e.getMessage(), e); - } + return this.configModelService.publishConfigModel(id); } @GetMapping(path = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody ConfigModel getConfigModel(@PathVariable(value = "id") Long id) throws BluePrintException { - try { - return this.configModelService.getConfigModel(id); - } catch (Exception e) { - throw new BluePrintException(2001, e.getMessage(), e); - } + return this.configModelService.getConfigModel(id); } @GetMapping(path = "/by-name/{name}/version/{version}", produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody ConfigModel getConfigModelByNameAndVersion(@PathVariable(value = "name") String name, @PathVariable(value = "version") String version) throws BluePrintException { - try { - return this.configModelService.getConfigModelByNameAndVersion(name, version); - } catch (Exception e) { - throw new BluePrintException(2002, e.getMessage(), e); - } + return this.configModelService.getConfigModelByNameAndVersion(name, version); } @GetMapping(path = "/search/{tags}", produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody List searchConfigModels(@PathVariable(value = "tags") String tags) throws BluePrintException { - try { - return this.configModelService.searchConfigModels(tags); - } catch (Exception e) { - throw new BluePrintException(2003, e.getMessage(), e); - } + return this.configModelService.searchConfigModels(tags); } @GetMapping(path = "/clone/{id}", produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody ConfigModel getCloneConfigModel(@PathVariable(value = "id") Long id) throws BluePrintException { - try { - return this.configModelService.getCloneConfigModel(id); - } catch (Exception e) { - throw new BluePrintException(2004, e.getMessage(), e); - } + return this.configModelService.getCloneConfigModel(id); } } diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java index 6bcbae963..082b15078 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java @@ -70,7 +70,7 @@ public class ModelTypeRest { } } - @PostMapping(path = "/", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) + @PostMapping(path = "", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody ModelType saveModelType(@RequestBody ModelType modelType) throws BluePrintException { try { diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java index 795738cb1..a4aced60c 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java @@ -43,7 +43,7 @@ public class ResourceDictionaryRest { this.resourceDictionaryService = dataDictionaryService; } - @PostMapping(path = "/", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) + @PostMapping(path = "", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody ResourceDictionary saveResourceDictionary(@RequestBody ResourceDictionary dataDictionary) throws BluePrintException { diff --git a/ms/controllerblueprints/parent/pom.xml b/ms/controllerblueprints/parent/pom.xml index 19e55fe0b..8af57c7d3 100644 --- a/ms/controllerblueprints/parent/pom.xml +++ b/ms/controllerblueprints/parent/pom.xml @@ -38,6 +38,7 @@ 1.0.0 2.9.2 1.4.197 + 1.2.2-SNAPSHOT @@ -55,6 +56,11 @@ eelf-core ${eelf.version} + + org.onap.logging-analytics + logging-slf4j + ${onap.logger.slf4j} + @@ -163,6 +169,10 @@ com.att.eelf eelf-core + + org.onap.logging-analytics + logging-slf4j + org.apache.commons commons-lang3 -- cgit 1.2.3-korg From 2c91cf47dcfc3014dd669627e214b2e8ec34ce4a Mon Sep 17 00:00:00 2001 From: Brinda Santh Date: Wed, 5 Sep 2018 23:18:19 -0400 Subject: Controller Blueprints Microservice Add configuration property to load model types and Remove duplicate model type test case files Change-Id: I6a34539cae7377bd133727fde77ff8fefaadf023 Issue-ID: CCSDK-484 Signed-off-by: Brinda Santh --- .../node_type/component-netconf-executor.json | 4 +- .../opt/app/onap/config/application.properties | 9 +- .../src/test/resources/application.properties | 9 +- .../artifact_type/artifact-mapping-resource.json | 8 -- .../artifact_type/artifact-script-python.json | 8 -- .../artifact_type/artifact-template-velocity.json | 8 -- .../model_type/data_type/datatype-property.json | 27 ------ .../data_type/datatype-resource-assignment.json | 46 ----------- .../load/model_type/data_type/dt-license-key.json | 11 --- .../load/model_type/data_type/dt-v4-aggregate.json | 15 ---- .../node_type/artifact-config-template.json | 37 --------- .../node_type/component-config-generator.json | 72 ---------------- .../node_type/component-netconf-edit.json | 95 ---------------------- .../node_type/component-netconf-executor.json | 79 ------------------ .../node_type/component-netconf-get.json | 61 -------------- .../node_type/component-resource-assignment.json | 68 ---------------- .../node_type/component-transaction-netconf.json | 93 --------------------- .../model_type/node_type/dg-activate-netconf.json | 66 --------------- .../model_type/node_type/dg-config-generator.json | 65 --------------- .../node_type/dg-resource-assign-activate.json | 70 ---------------- .../node_type/dg-resource-assignment.json | 65 --------------- .../load/model_type/node_type/source-db.json | 44 ---------- .../load/model_type/node_type/source-default.json | 18 ---- .../load/model_type/node_type/source-input.json | 18 ---- .../load/model_type/node_type/source-rest.json | 61 -------------- .../node_type/tosca.nodes.ResourceSource.json | 5 -- .../model_type/node_type/vnf-netconf-device.json | 42 ---------- .../service/DataBaseInitService.java | 14 ++-- .../ResourceDictionaryReactRepository.kt | 5 ++ .../ResourceDictionaryReactRepositoryTest.java | 27 ++++++ .../service/rs/ModelTypeRestTest.java | 15 ++-- .../service/rs/ServiceTemplateRestTest.java | 5 +- .../src/test/resources/application.properties | 9 +- .../model_type/data_type/datatype-property.json | 27 ++++++ 34 files changed, 98 insertions(+), 1108 deletions(-) delete mode 100644 ms/controllerblueprints/modules/service/load/model_type/artifact_type/artifact-mapping-resource.json delete mode 100644 ms/controllerblueprints/modules/service/load/model_type/artifact_type/artifact-script-python.json delete mode 100644 ms/controllerblueprints/modules/service/load/model_type/artifact_type/artifact-template-velocity.json delete mode 100644 ms/controllerblueprints/modules/service/load/model_type/data_type/datatype-property.json delete mode 100644 ms/controllerblueprints/modules/service/load/model_type/data_type/datatype-resource-assignment.json delete mode 100644 ms/controllerblueprints/modules/service/load/model_type/data_type/dt-license-key.json delete mode 100644 ms/controllerblueprints/modules/service/load/model_type/data_type/dt-v4-aggregate.json delete mode 100644 ms/controllerblueprints/modules/service/load/model_type/node_type/artifact-config-template.json delete mode 100644 ms/controllerblueprints/modules/service/load/model_type/node_type/component-config-generator.json delete mode 100644 ms/controllerblueprints/modules/service/load/model_type/node_type/component-netconf-edit.json delete mode 100644 ms/controllerblueprints/modules/service/load/model_type/node_type/component-netconf-executor.json delete mode 100644 ms/controllerblueprints/modules/service/load/model_type/node_type/component-netconf-get.json delete mode 100644 ms/controllerblueprints/modules/service/load/model_type/node_type/component-resource-assignment.json delete mode 100644 ms/controllerblueprints/modules/service/load/model_type/node_type/component-transaction-netconf.json delete mode 100644 ms/controllerblueprints/modules/service/load/model_type/node_type/dg-activate-netconf.json delete mode 100644 ms/controllerblueprints/modules/service/load/model_type/node_type/dg-config-generator.json delete mode 100644 ms/controllerblueprints/modules/service/load/model_type/node_type/dg-resource-assign-activate.json delete mode 100644 ms/controllerblueprints/modules/service/load/model_type/node_type/dg-resource-assignment.json delete mode 100644 ms/controllerblueprints/modules/service/load/model_type/node_type/source-db.json delete mode 100644 ms/controllerblueprints/modules/service/load/model_type/node_type/source-default.json delete mode 100644 ms/controllerblueprints/modules/service/load/model_type/node_type/source-input.json delete mode 100644 ms/controllerblueprints/modules/service/load/model_type/node_type/source-rest.json delete mode 100644 ms/controllerblueprints/modules/service/load/model_type/node_type/tosca.nodes.ResourceSource.json delete mode 100644 ms/controllerblueprints/modules/service/load/model_type/node_type/vnf-netconf-device.json create mode 100644 ms/controllerblueprints/modules/service/src/test/resources/model_type/data_type/datatype-property.json (limited to 'ms/controllerblueprints/application/src/test/resources') diff --git a/ms/controllerblueprints/application/load/model_type/node_type/component-netconf-executor.json b/ms/controllerblueprints/application/load/model_type/node_type/component-netconf-executor.json index aed667aaf..240caf3fc 100644 --- a/ms/controllerblueprints/application/load/model_type/node_type/component-netconf-executor.json +++ b/ms/controllerblueprints/application/load/model_type/node_type/component-netconf-executor.json @@ -23,12 +23,12 @@ "required": true, "type": "string" }, - "service-template-name": { + "template-name": { "description": "Service Template Name", "required": true, "type": "string" }, - "service-template-version": { + "template-version": { "description": "Service Template Version", "required": true, "type": "string" diff --git a/ms/controllerblueprints/application/opt/app/onap/config/application.properties b/ms/controllerblueprints/application/opt/app/onap/config/application.properties index 3b6033e7f..2d355d653 100644 --- a/ms/controllerblueprints/application/opt/app/onap/config/application.properties +++ b/ms/controllerblueprints/application/opt/app/onap/config/application.properties @@ -1,5 +1,6 @@ # -# Copyright © 2017-2018 AT&T Intellectual Property. +# Copyright © 2017-2018 AT&T Intellectual Property. +# Modifications Copyright © 2018 IBM. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -48,4 +49,8 @@ spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect #Load Blueprints # blueprints.load.initial-data may be overridden by ENV variables blueprints.load.initial-data=true -blueprints.load.path=load \ No newline at end of file +load.dataTypePath=load/model_type/data_type +load.nodeTypePath=load/model_type/node_type +load.artifactTypePath=load/model_type/artifact_type +load.resourceDictionaryPath=load/resource_dictionary +load.blueprintsPath=load/blueprints \ No newline at end of file diff --git a/ms/controllerblueprints/application/src/test/resources/application.properties b/ms/controllerblueprints/application/src/test/resources/application.properties index a63ed5b71..3bcbbd9c9 100644 --- a/ms/controllerblueprints/application/src/test/resources/application.properties +++ b/ms/controllerblueprints/application/src/test/resources/application.properties @@ -1,5 +1,6 @@ # -# Copyright © 2017-2018 AT&T Intellectual Property. +# Copyright © 2017-2018 AT&T Intellectual Property. +# Modifications Copyright © 2018 IBM. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -28,4 +29,8 @@ swagger.contact.email=brindasanth@onap.com #Load Blueprints # blueprints.load.initial-data may be overridden by ENV variables blueprints.load.initial-data=true -blueprints.load.path=load \ No newline at end of file +load.dataTypePath=load/model_type/data_type +load.nodeTypePath=load/model_type/node_type +load.artifactTypePath=load/model_type/artifact_type +load.resourceDictionaryPath=load/resource_dictionary +load.blueprintsPath=load/blueprints \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/load/model_type/artifact_type/artifact-mapping-resource.json b/ms/controllerblueprints/modules/service/load/model_type/artifact_type/artifact-mapping-resource.json deleted file mode 100644 index 0a3261b09..000000000 --- a/ms/controllerblueprints/modules/service/load/model_type/artifact_type/artifact-mapping-resource.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "description": " Velocity Template Resource Mapping File used along with Configuration template", - "version": "1.0.0", - "file_ext": [ - "json" - ], - "derived_from": "tosca.artifacts.Implementation" -} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/load/model_type/artifact_type/artifact-script-python.json b/ms/controllerblueprints/modules/service/load/model_type/artifact_type/artifact-script-python.json deleted file mode 100644 index b48d2b628..000000000 --- a/ms/controllerblueprints/modules/service/load/model_type/artifact_type/artifact-script-python.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "description": " Kotlin Script Template used for Configuration", - "version": "1.0.0", - "file_ext": [ - "py" - ], - "derived_from": "tosca.artifacts.Implementation" -} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/load/model_type/artifact_type/artifact-template-velocity.json b/ms/controllerblueprints/modules/service/load/model_type/artifact_type/artifact-template-velocity.json deleted file mode 100644 index 9395d3970..000000000 --- a/ms/controllerblueprints/modules/service/load/model_type/artifact_type/artifact-template-velocity.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "description": " Velocity Template used for Configuration", - "version": "1.0.0", - "file_ext": [ - "vtl" - ], - "derived_from": "tosca.artifacts.Implementation" -} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/load/model_type/data_type/datatype-property.json b/ms/controllerblueprints/modules/service/load/model_type/data_type/datatype-property.json deleted file mode 100644 index 5584b10ea..000000000 --- a/ms/controllerblueprints/modules/service/load/model_type/data_type/datatype-property.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "version": "1.0.0", - "description": "This is Entry point Input Data Type, which is dynamic datatype, The parameter names will be populated during the Design time for each inputs", - "properties": { - "type": { - "required": true, - "type": "string" - }, - "description": { - "required": false, - "type": "string" - }, - "required": { - "required": false, - "type": "boolean" - }, - "default": { - "required": false, - "type": "string" - }, - "entry_schema": { - "required": false, - "type": "string" - } - }, - "derived_from": "tosca.datatypes.Root" -} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/load/model_type/data_type/datatype-resource-assignment.json b/ms/controllerblueprints/modules/service/load/model_type/data_type/datatype-resource-assignment.json deleted file mode 100644 index cc9816ebb..000000000 --- a/ms/controllerblueprints/modules/service/load/model_type/data_type/datatype-resource-assignment.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "version": "1.0.0", - "description": "This is Resource Assignment Data Type", - "properties": { - "property": { - "required": true, - "type": "datatype-property" - }, - "input-param": { - "required": true, - "type": "boolean" - }, - "dictionary-name": { - "required": false, - "type": "string" - }, - "dictionary-source": { - "required": false, - "type": "string" - }, - "dependencies": { - "required": true, - "type": "list", - "entry_schema": { - "type": "string" - } - }, - "status": { - "required": false, - "type": "string" - }, - "message": { - "required": false, - "type": "string" - }, - "updated-date": { - "required": false, - "type": "string" - }, - "updated-by": { - "required": false, - "type": "string" - } - }, - "derived_from": "tosca.datatypes.Root" -} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/load/model_type/data_type/dt-license-key.json b/ms/controllerblueprints/modules/service/load/model_type/data_type/dt-license-key.json deleted file mode 100644 index e9c312b79..000000000 --- a/ms/controllerblueprints/modules/service/load/model_type/data_type/dt-license-key.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "version": "1.0.0", - "description": "This is dt-plicense-key Data Type", - "properties": { - "license-key": { - "required": true, - "type": "string" - } - }, - "derived_from": "tosca.datatypes.Root" -} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/load/model_type/data_type/dt-v4-aggregate.json b/ms/controllerblueprints/modules/service/load/model_type/data_type/dt-v4-aggregate.json deleted file mode 100644 index 842a7f805..000000000 --- a/ms/controllerblueprints/modules/service/load/model_type/data_type/dt-v4-aggregate.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "version": "1.0.0", - "description": "This is dt-v4-aggregate Data Type", - "properties": { - "ipv4-address": { - "required": true, - "type": "string" - }, - "ipv4-plen": { - "required": false, - "type": "integer" - } - }, - "derived_from": "tosca.datatypes.Root" -} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/load/model_type/node_type/artifact-config-template.json b/ms/controllerblueprints/modules/service/load/model_type/node_type/artifact-config-template.json deleted file mode 100644 index be9bbfc0e..000000000 --- a/ms/controllerblueprints/modules/service/load/model_type/node_type/artifact-config-template.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "description": "This is Configuration Velocity Template", - "version": "1.0.0", - "properties": { - "action-names": { - "required": true, - "type": "list", - "entry_schema": { - "type": "string" - } - } - }, - "capabilities": { - "content": { - "type": "tosca.capability.Content", - "properties": { - "content": { - "required": true, - "type": "string" - } - } - }, - "mapping": { - "type": "tosca.capability.Mapping", - "properties": { - "mapping": { - "required": false, - "type": "list", - "entry_schema": { - "type": "datatype-resource-assignment" - } - } - } - } - }, - "derived_from": "tosca.nodes.Artifact" -} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/load/model_type/node_type/component-config-generator.json b/ms/controllerblueprints/modules/service/load/model_type/node_type/component-config-generator.json deleted file mode 100644 index 764f9e890..000000000 --- a/ms/controllerblueprints/modules/service/load/model_type/node_type/component-config-generator.json +++ /dev/null @@ -1,72 +0,0 @@ -{ - "description": "This is Generate Configuration Component API", - "version": "1.0.0", - "capabilities": { - "component-node": { - "type": "tosca.capabilities.Node" - } - }, - "interfaces": { - "org-openecomp-sdnc-config-generator-service-ConfigGeneratorNode": { - "operations": { - "process": { - "inputs": { - "template-data": { - "description": "Conditional : JSON string which is used to mash with template. Either template-data or ( resource-id and resource-type ) should be present", - "required": false, - "type": "string" - }, - "template-content": { - "description": "Conditional : Dynamic Template used to generate Configuration.", - "required": false, - "type": "string" - }, - "resource-type": { - "description": "Conditional : resource-type used to pull the data content from the data base. Either template-data or ( resource-id and resource-type ) should be present", - "required": false, - "type": "string" - }, - "request-id": { - "description": "Request Id used to store the generated configuration, in the database along with the template-name", - "required": true, - "type": "string" - }, - "resource-id": { - "description": "Conditional : Id used to pull the data content from the data base. Either template-data or ( resource-id and resource-type ) should be present", - "required": false, - "type": "string" - }, - "action-name": { - "description": "Conditional : Action Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority", - "required": false, - "type": "string" - }, - "template-name": { - "description": "Conditional : Name of the Artifact Node Template, to get the template Content. If template-content is present, then content wont be reterived from the Artifact Node Template.", - "required": true, - "type": "string" - } - }, - "outputs": { - "generated-config": { - "description": "Generated Configuration for the Template adn Resource Data", - "required": true, - "type": "string" - }, - "mask-info": { - "description": "If template contains mask encription keys, then this mask-info field will be generated, This JSON Content alligns to the bean org.onap.ccsdk.apps.controllerblueprints.core.data.custom.MaskInfo ", - "required": false, - "type": "string" - }, - "status": { - "description": "Status of the Component Execution ( success or failure )", - "required": true, - "type": "string" - } - } - } - } - } - }, - "derived_from": "tosca.nodes.Component" -} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/load/model_type/node_type/component-netconf-edit.json b/ms/controllerblueprints/modules/service/load/model_type/node_type/component-netconf-edit.json deleted file mode 100644 index 144e1dded..000000000 --- a/ms/controllerblueprints/modules/service/load/model_type/node_type/component-netconf-edit.json +++ /dev/null @@ -1,95 +0,0 @@ -{ - "description": "This is Netconf Edit Configuration Component API", - "version": "1.0.0", - "capabilities": { - "component-node": { - "type": "tosca.capabilities.Node" - } - }, - "interfaces": { - "org-openecomp-sdnc-netconf-adaptor-service-SimpleNetconfEditConfigNode": { - "operations": { - "process": { - "inputs": { - "template-name": { - "description": "Template name used by the Components during processing", - "required": false, - "type": "string" - }, - "rpc-message": { - "description": "If the message is Neconf RPC message,It should be true or false.", - "required": false, - "type": "boolean", - "default": false - }, - "wait": { - "description": "Delay time in sec before performing edit-config action.", - "required": false, - "type": "integer", - "default": 0 - }, - "unlock": { - "description": "If unLock command has to send before Edit Configuration.", - "required": false, - "type": "boolean", - "default": false - }, - "config-target": { - "required": false, - "type": "string" - }, - "commit": { - "description": "Issue commit command to the device after performing edit-config action.", - "required": false, - "type": "boolean", - "default": false - }, - "edit-default-operation": { - "required": false, - "type": "string" - }, - "content": { - "description": "Static messgae content, If this is not set, need to have Requirement relationship to Artifact contents.", - "required": false, - "type": "string" - }, - "lock": { - "description": "Issue lock command to the device before performing edit-config action.", - "required": false, - "type": "boolean", - "default": false - }, - "post-restart-wait": { - "description": "If Restart command should be issued before the Edit Operation, Provide the time to wait after restart. 0 meanno restart required or wait time in sec ex : 3000 for 5 ", - "required": false, - "type": "integer", - "default": 0 - }, - "pre-restart-wait": { - "description": "If Restart command should be issued after the Edit Operation, Provide the time to wait after restart. 0 meanno restart required or wait time in sec ex : 3000 for 5 ", - "required": false, - "type": "integer", - "default": 0 - }, - "message-time-out": { - "required": false, - "type": "integer", - "default": 30 - } - }, - "outputs": { - "rpc-response-message": { - "type": "string" - }, - "status": { - "description": "Status of the Component Execution ( success or failure )", - "required": true, - "type": "string" - } - } - } - } - } - }, - "derived_from": "tosca.nodes.Component" -} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/load/model_type/node_type/component-netconf-executor.json b/ms/controllerblueprints/modules/service/load/model_type/node_type/component-netconf-executor.json deleted file mode 100644 index 240caf3fc..000000000 --- a/ms/controllerblueprints/modules/service/load/model_type/node_type/component-netconf-executor.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "description": "This is Netconf Transaction Configuration Component API", - "version": "1.0.0", - "capabilities": { - "component-node": { - "type": "tosca.capabilities.Node" - } - }, - "requirements": { - "netconf-connection": { - "capability": "netconf", - "node": "vnf-netconf-device", - "relationship": "tosca.relationships.ConnectsTo" - } - }, - "interfaces": { - "org-openecomp-sdnc-netconf-adaptor-service-NetconfExecutorNode": { - "operations": { - "process": { - "inputs": { - "request-id": { - "description": "Request Id used to store the generated configuration, in the database along with the template-name", - "required": true, - "type": "string" - }, - "template-name": { - "description": "Service Template Name", - "required": true, - "type": "string" - }, - "template-version": { - "description": "Service Template Version", - "required": true, - "type": "string" - }, - "action-name": { - "description": "Action Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority", - "required": false, - "type": "string" - }, - "resource-type": { - "description": "Resource Type to get from Database, Either (message & mask-info ) or( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority", - "required": false, - "type": "string" - }, - "resource-id": { - "description": "Resource Id to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority", - "required": false, - "type": "string" - }, - "reservation-id": { - "description": "Reservation Id used to send to NPM", - "required": false, - "type": "string" - }, - "execution-script": { - "description": "Python Script to Execute for this Component action, It should refer any one of Prython Artifact Definition for this Node Template.", - "required": true, - "type": "string" - } - }, - "outputs": { - "response-data": { - "description": "Execution Response Data in JSON format.", - "required": false, - "type": "string" - }, - "status": { - "description": "Status of the Component Execution ( success or failure )", - "required": true, - "type": "string" - } - } - } - } - } - }, - "derived_from": "tosca.nodes.Component" -} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/load/model_type/node_type/component-netconf-get.json b/ms/controllerblueprints/modules/service/load/model_type/node_type/component-netconf-get.json deleted file mode 100644 index 1659bf419..000000000 --- a/ms/controllerblueprints/modules/service/load/model_type/node_type/component-netconf-get.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "description": "This is Netconf Get Running Configuration Component API", - "version": "1.0.0", - "capabilities": { - "component-node": { - "type": "tosca.capabilities.Node" - } - }, - "interfaces": { - "org-openecomp-sdnc-netconf-adaptor-service-SimpleNetconfGetConfigNode": { - "operations": { - "process": { - "inputs": { - "template-name": { - "description": "Template name used by the Components during processing", - "required": false, - "type": "string" - }, - "rpc-message": { - "description": "It should be true, If the message is Neconf RPC message, It should be false If it is plain Config message.", - "required": false, - "type": "boolean", - "default": false - }, - "wait": { - "required": false, - "type": "integer", - "default": 0 - }, - "lock": { - "required": false, - "type": "boolean", - "default": false - }, - "content": { - "description": "Static messgae content, If this is not set, need to have Requirement relationship to Artifact contents.", - "required": false, - "type": "string" - }, - "message-time-out": { - "required": false, - "type": "integer", - "default": 30 - } - }, - "outputs": { - "config-message": { - "type": "string" - }, - "status": { - "description": "Status of the Component Execution ( success or failure )", - "required": true, - "type": "string" - } - } - } - } - } - }, - "derived_from": "tosca.nodes.Component" -} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/load/model_type/node_type/component-resource-assignment.json b/ms/controllerblueprints/modules/service/load/model_type/node_type/component-resource-assignment.json deleted file mode 100644 index 34c028482..000000000 --- a/ms/controllerblueprints/modules/service/load/model_type/node_type/component-resource-assignment.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "description": "This is Resource Assignment Component API", - "version": "1.0.0", - "capabilities": { - "component-node": { - "type": "tosca.capabilities.Node" - } - }, - "interfaces": { - "org-openecomp-sdnc-config-assignment-service-ConfigAssignmentNode": { - "operations": { - "process": { - "inputs": { - "service-template-name": { - "description": "Service Template Name.", - "required": true, - "type": "string" - }, - "service-template-version": { - "description": "Service Template Version.", - "required": true, - "type": "string" - }, - "resource-type": { - "description": "Request type.", - "required": true, - "type": "string" - }, - "template-names": { - "description": "Name of the artifact Node Templates, to get the template Content.", - "required": true, - "type": "list", - "entry_schema": { - "type": "string" - } - }, - "request-id": { - "description": "Request Id, Unique Id for the request.", - "required": true, - "type": "string" - }, - "resource-id": { - "description": "Resource Id.", - "required": true, - "type": "string" - }, - "action-name": { - "description": "Action Name of the process", - "required": true, - "type": "string" - } - }, - "outputs": { - "resource-assignment-params": { - "required": true, - "type": "string" - }, - "status": { - "required": true, - "type": "string" - } - } - } - } - } - }, - "derived_from": "tosca.nodes.Component" -} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/load/model_type/node_type/component-transaction-netconf.json b/ms/controllerblueprints/modules/service/load/model_type/node_type/component-transaction-netconf.json deleted file mode 100644 index 7c3745848..000000000 --- a/ms/controllerblueprints/modules/service/load/model_type/node_type/component-transaction-netconf.json +++ /dev/null @@ -1,93 +0,0 @@ -{ - "description": "This is Netconf Transaction Configuration Component API", - "version": "1.0.0", - "capabilities": { - "component-node": { - "type": "tosca.capabilities.Node" - } - }, - "requirements": { - "netconf-connection": { - "capability": "netconf", - "node": "vnf-netconf-device", - "relationship": "tosca.relationships.ConnectsTo" - } - }, - "interfaces": { - "org-openecomp-sdnc-netconf-adaptor-service-NetconfTransactionNode": { - "operations": { - "process": { - "inputs": { - "rollback": { - "required": false, - "type": "boolean" - }, - "assignment-action-name": { - "description": "Assignment Action Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority", - "required": true, - "type": "string" - }, - "transaction-components": { - "description": "Components used to used for the atomic transaction, Default Handlers are org.openecomp.sdnc.netconf.adaptor.service.SimpleNetconfEditConfigNode and org.openecomp.sdnc.netconf.adaptor.service.SimpleNetconfGetConfigNode", - "required": true, - "type": "list", - "entry_schema": { - "type": "string" - } - }, - "resource-type": { - "description": "Resource Type to get from Database, Either (message & mask-info ) or( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority", - "required": false, - "type": "string" - }, - "initialise-sftp": { - "required": false, - "type": "boolean" - }, - "request-id": { - "description": "Request Id used to store the generated configuration, in the database along with the template-name", - "required": true, - "type": "string" - }, - "initialise-ssh": { - "required": false, - "type": "boolean" - }, - "lock": { - "required": false, - "type": "boolean", - "default": false - }, - "unlock": { - "description": "If unLock command has to send before Edit Configuration.", - "required": false, - "type": "boolean", - "default": false - }, - "resource-id": { - "description": "Resource Id to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority", - "required": false, - "type": "string" - }, - "action-name": { - "description": "Action Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority", - "required": false, - "type": "string" - } - }, - "outputs": { - "rpc-response-message": { - "type": "string" - }, - "status": { - "description": "Status of the Component Execution ( success or failure )", - "required": true, - "type": "string" - } - } - } - } - } - }, - "derived_from": "tosca.nodes.Component" -} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/load/model_type/node_type/dg-activate-netconf.json b/ms/controllerblueprints/modules/service/load/model_type/node_type/dg-activate-netconf.json deleted file mode 100644 index a9d16eddc..000000000 --- a/ms/controllerblueprints/modules/service/load/model_type/node_type/dg-activate-netconf.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "description": "This is Download Netconf Directed Graph", - "version": "1.0.0", - "properties": { - "mode": { - "required": false, - "type": "string", - "default": "sync" - }, - "version": { - "required": false, - "type": "string", - "default": "LATEST" - }, - "is-start-flow": { - "required": false, - "type": "boolean", - "default": false - } - }, - "capabilities": { - "dg-node": { - "type": "tosca.capabilities.Node" - }, - "content": { - "type": "tosca.capability.Content", - "properties": { - "type": { - "required": false, - "type": "string", - "default": "json" - }, - "content": { - "required": true, - "type": "string" - } - } - } - }, - "requirements": { - "component-dependency": { - "capability": "component-node", - "node": "component-netconf-executor", - "relationship": "tosca.relationships.DependsOn" - } - }, - "interfaces": { - "CONFIG": { - "operations": { - "ActivateNetconf": { - "inputs": { - "params": { - "required": false, - "type": "list", - "entry_schema": { - "type": "datatype-property" - } - } - } - } - } - } - }, - - "derived_from": "tosca.nodes.DG" -} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/load/model_type/node_type/dg-config-generator.json b/ms/controllerblueprints/modules/service/load/model_type/node_type/dg-config-generator.json deleted file mode 100644 index 6794b3c89..000000000 --- a/ms/controllerblueprints/modules/service/load/model_type/node_type/dg-config-generator.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "description": "This is Activate DG for Config Generator Directed Graph", - "version": "1.0.0", - "properties": { - "mode": { - "required": false, - "type": "string", - "default": "sync" - }, - "version": { - "required": false, - "type": "string", - "default": "LATEST" - }, - "is-start-flow": { - "required": false, - "type": "boolean", - "default": false - } - }, - "capabilities": { - "dg-node": { - "type": "tosca.capabilities.Node" - }, - "content": { - "type": "tosca.capability.Content", - "properties": { - "type": { - "required": false, - "type": "string", - "default": "json" - }, - "content": { - "required": true, - "type": "string" - } - } - } - }, - "requirements": { - "component-dependency": { - "capability": "component-node", - "node": "component-config-generator", - "relationship": "tosca.relationships.DependsOn" - } - }, - "interfaces": { - "CONFIG": { - "operations": { - "GenerateConfiguration": { - "inputs": { - "params": { - "required": false, - "type": "list", - "entry_schema": { - "type": "datatype-property" - } - } - } - } - } - } - }, - "derived_from": "tosca.nodes.DG" -} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/load/model_type/node_type/dg-resource-assign-activate.json b/ms/controllerblueprints/modules/service/load/model_type/node_type/dg-resource-assign-activate.json deleted file mode 100644 index 22a4d813c..000000000 --- a/ms/controllerblueprints/modules/service/load/model_type/node_type/dg-resource-assign-activate.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "description": "This is Resource Assign and Activate Netconf Directed Graph", - "version": "1.0.0", - "properties": { - "mode": { - "required": false, - "type": "string", - "default": "sync" - }, - "version": { - "required": false, - "type": "string", - "default": "LATEST" - }, - "is-start-flow": { - "required": false, - "type": "boolean", - "default": false - } - }, - "capabilities": { - "dg-node": { - "type": "tosca.capabilities.Node" - }, - "content": { - "type": "tosca.capability.Content", - "properties": { - "type": { - "required": false, - "type": "string", - "default": "json" - }, - "content": { - "required": false, - "type": "string" - } - } - } - }, - "requirements": { - "ra-component": { - "capability": "component-node", - "node": "component-resource-assignment", - "relationship": "tosca.relationships.DependsOn" - }, - "netconf-component": { - "capability": "component-node", - "node": "component-netconf-executor", - "relationship": "tosca.relationships.DependsOn" - } - }, - "interfaces": { - "CONFIG": { - "operations": { - "ResourceAssignAndActivate": { - "inputs": { - "params": { - "required": false, - "type": "list", - "entry_schema": { - "type": "datatype-property" - } - } - } - } - } - } - }, - "derived_from": "tosca.nodes.DG" -} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/load/model_type/node_type/dg-resource-assignment.json b/ms/controllerblueprints/modules/service/load/model_type/node_type/dg-resource-assignment.json deleted file mode 100644 index 7c01faa13..000000000 --- a/ms/controllerblueprints/modules/service/load/model_type/node_type/dg-resource-assignment.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "description": "This is Resource Assignment Directed Graph", - "version": "1.0.0", - "properties": { - "mode": { - "required": false, - "type": "string", - "default": "sync" - }, - "version": { - "required": false, - "type": "string", - "default": "LATEST" - }, - "is-start-flow": { - "required": false, - "type": "boolean", - "default": false - } - }, - "capabilities": { - "dg-node": { - "type": "tosca.capabilities.Node" - }, - "content": { - "type": "tosca.capability.Content", - "properties": { - "type": { - "required": false, - "type": "string", - "default": "json" - }, - "content": { - "required": false, - "type": "string" - } - } - } - }, - "requirements": { - "component-dependency": { - "capability": "component-node", - "node": "component-resource-assignment", - "relationship": "tosca.relationships.DependsOn" - } - }, - "interfaces": { - "CONFIG": { - "operations": { - "ResourceAssignment": { - "inputs": { - "params": { - "required": false, - "type": "list", - "entry_schema": { - "type": "datatype-property" - } - } - } - } - } - } - }, - "derived_from": "tosca.nodes.DG" -} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/load/model_type/node_type/source-db.json b/ms/controllerblueprints/modules/service/load/model_type/node_type/source-db.json deleted file mode 100644 index 661a9503b..000000000 --- a/ms/controllerblueprints/modules/service/load/model_type/node_type/source-db.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "description": "This is Database Resource Source Node Type", - "version": "1.0.0", - "properties": { - "type": { - "required": true, - "type": "string", - "constraints": [ - { - "valid_values": [ - "SQL", - "PLSQL" - ] - } - ] - }, - "query": { - "required": true, - "type": "string" - }, - "input-key-mapping": { - "required": false, - "type": "map", - "entry_schema": { - "type": "string" - } - }, - "output-key-mapping": { - "required": false, - "type": "map", - "entry_schema": { - "type": "string" - } - }, - "key-dependencies": { - "required": true, - "type": "list", - "entry_schema": { - "type": "string" - } - } - }, - "derived_from": "tosca.nodes.ResourceSource" -} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/load/model_type/node_type/source-default.json b/ms/controllerblueprints/modules/service/load/model_type/node_type/source-default.json deleted file mode 100644 index 13e234e1b..000000000 --- a/ms/controllerblueprints/modules/service/load/model_type/node_type/source-default.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "description": "This is Default Resource Source Node Type", - "version": "1.0.0", - "properties": { - "key": { - "required": false, - "type": "string" - }, - "key-dependencies": { - "required": true, - "type": "list", - "entry_schema": { - "type": "string" - } - } - }, - "derived_from": "tosca.nodes.ResourceSource" -} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/load/model_type/node_type/source-input.json b/ms/controllerblueprints/modules/service/load/model_type/node_type/source-input.json deleted file mode 100644 index 126ea30bd..000000000 --- a/ms/controllerblueprints/modules/service/load/model_type/node_type/source-input.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "description": "This is Input Resource Source Node Type", - "version": "1.0.0", - "properties": { - "key": { - "required": false, - "type": "string" - }, - "key-dependencies": { - "required": true, - "type": "list", - "entry_schema": { - "type": "string" - } - } - }, - "derived_from": "tosca.nodes.ResourceSource" -} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/load/model_type/node_type/source-rest.json b/ms/controllerblueprints/modules/service/load/model_type/node_type/source-rest.json deleted file mode 100644 index f8dd8b6fc..000000000 --- a/ms/controllerblueprints/modules/service/load/model_type/node_type/source-rest.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "description": "This is Rest Resource Source Node Type", - "version": "1.0.0", - "properties": { - "type": { - "required": false, - "type": "string", - "default": "JSON", - "constraints": [ - { - "valid_values": [ - "JSON" - ] - } - ] - }, - "url-path": { - "required": true, - "type": "string" - }, - "path": { - "required": true, - "type": "string" - }, - "expression-type": { - "required": false, - "type": "string", - "default": "JSON_PATH", - "constraints": [ - { - "valid_values": [ - "JSON_PATH", - "JSON_POINTER" - ] - } - ] - }, - "input-key-mapping": { - "required": false, - "type": "map", - "entry_schema": { - "type": "string" - } - }, - "output-key-mapping": { - "required": false, - "type": "map", - "entry_schema": { - "type": "string" - } - }, - "key-dependencies": { - "required": true, - "type": "list", - "entry_schema": { - "type": "string" - } - } - }, - "derived_from": "tosca.nodes.ResourceSource" -} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/load/model_type/node_type/tosca.nodes.ResourceSource.json b/ms/controllerblueprints/modules/service/load/model_type/node_type/tosca.nodes.ResourceSource.json deleted file mode 100644 index 2ef553e24..000000000 --- a/ms/controllerblueprints/modules/service/load/model_type/node_type/tosca.nodes.ResourceSource.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "description": "TOSCA base type for Resource Sources", - "version": "1.0.0", - "derived_from": "tosca.nodes.Root" -} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/load/model_type/node_type/vnf-netconf-device.json b/ms/controllerblueprints/modules/service/load/model_type/node_type/vnf-netconf-device.json deleted file mode 100644 index 54573bade..000000000 --- a/ms/controllerblueprints/modules/service/load/model_type/node_type/vnf-netconf-device.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "description": "This is VNF Device with Netconf Capability", - "version": "1.0.0", - "capabilities": { - "netconf": { - "type": "tosca.capability.Netconf", - "properties": { - "login-key": { - "required": true, - "type": "string", - "default": "sdnc" - }, - "login-account": { - "required": true, - "type": "string", - "default": "sdnc-tacacs" - }, - "source": { - "required": true, - "type": "string", - "default": "npm" - }, - "target-ip-address": { - "required": true, - "type": "string" - }, - "port-number": { - "required": true, - "type": "integer", - "default": 830 - }, - "connection-time-out": { - "required": false, - "type": "integer", - "default": 30 - } - } - } - }, - "derived_from": "tosca.nodes.Vnf" - -} diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/DataBaseInitService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/DataBaseInitService.java index 886809297..c6d80cfb6 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/DataBaseInitService.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/DataBaseInitService.java @@ -60,16 +60,19 @@ import java.util.List; public class DataBaseInitService { private static EELFLogger log = EELFManager.getInstance().getLogger(DataBaseInitService.class); - @Value("${blueprints.load.path}") - private String modelLoadPath; private ModelTypeService modelTypeService; private ResourceDictionaryService resourceDictionaryService; private ConfigModelService configModelService; + @Value("${load.dataTypePath}") private String dataTypePath; + @Value("${load.nodeTypePath}") private String nodeTypePath; + @Value("${load.artifactTypePath}") private String artifactTypePath; + @Value("${load.resourceDictionaryPath}") private String resourceDictionaryPath; + @Value("${load.blueprintsPath}") private String bluePrintsPath; @Autowired @@ -94,13 +97,6 @@ public class DataBaseInitService { @PostConstruct @SuppressWarnings("unused") private void initDatabase() { - log.info("loading Blueprints from DIR : {}", modelLoadPath); - dataTypePath = modelLoadPath + "/model_type/data_type"; - nodeTypePath = modelLoadPath + "/model_type/node_type"; - artifactTypePath = modelLoadPath + "/model_type/artifact_type"; - resourceDictionaryPath = modelLoadPath + "/resource_dictionary"; - bluePrintsPath = modelLoadPath + "/blueprints"; - log.info("loading dataTypePath from DIR : {}", dataTypePath); log.info("loading nodeTypePath from DIR : {}", nodeTypePath); log.info("loading artifactTypePath from DIR : {}", artifactTypePath); diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryReactRepository.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryReactRepository.kt index 92172a2e4..064b5c382 100644 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryReactRepository.kt +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryReactRepository.kt @@ -22,6 +22,7 @@ import org.springframework.stereotype.Service import reactor.core.publisher.Flux import reactor.core.publisher.Mono import reactor.core.scheduler.Schedulers + /** * ResourceDictionaryReactRepository. * @@ -30,6 +31,10 @@ import reactor.core.scheduler.Schedulers @Service open class ResourceDictionaryReactRepository(private val resourceDictionaryRepository: ResourceDictionaryRepository) { + fun save(resourceDictionary: ResourceDictionary): Mono { + return Mono.justOrEmpty(resourceDictionaryRepository.save(resourceDictionary)) + } + fun findByName(name: String): Mono { return Mono.justOrEmpty(resourceDictionaryRepository.findByName(name)) } diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryReactRepositoryTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryReactRepositoryTest.java index db111885a..1e740ec33 100644 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryReactRepositoryTest.java +++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryReactRepositoryTest.java @@ -17,11 +17,14 @@ package org.onap.ccsdk.apps.controllerblueprints.service.repository; import org.junit.Assert; +import org.junit.Before; import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.MethodSorters; import org.onap.ccsdk.apps.controllerblueprints.TestApplication; +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils; +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition; import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; @@ -30,6 +33,7 @@ import org.springframework.test.context.junit4.SpringRunner; import java.util.Arrays; import java.util.List; + /** * ResourceDictionaryReactRepositoryTest. * @@ -45,6 +49,16 @@ public class ResourceDictionaryReactRepositoryTest { @Autowired protected ResourceDictionaryReactRepository resourceDictionaryReactRepository; + @Before + public void init() { + ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile("load/resource_dictionary/db-source" + + ".json", ResourceDefinition.class); + + ResourceDictionary resourceDictionary = transformResourceDictionary(resourceDefinition); + ResourceDictionary dbResourceDictionary = resourceDictionaryReactRepository.save(resourceDictionary).block(); + Assert.assertNotNull("Failed to query React Resource Dictionary by Name", dbResourceDictionary); + } + @Test public void test01FindByNameReact() throws Exception { ResourceDictionary dbResourceDictionary = resourceDictionaryReactRepository.findByName("db-source").block(); @@ -64,4 +78,17 @@ public class ResourceDictionaryReactRepositoryTest { resourceDictionaryReactRepository.findByTagsContainingIgnoreCase("db-source").collectList().block(); Assert.assertNotNull("Failed to query React Resource Dictionary by Tags", dbTagsResourceDictionaries); } + + private ResourceDictionary transformResourceDictionary(ResourceDefinition resourceDefinition) { + ResourceDictionary resourceDictionary = new ResourceDictionary(); + resourceDictionary.setName(resourceDefinition.getName()); + resourceDictionary.setDataType(resourceDefinition.getProperty().getType()); + resourceDictionary.setDescription(resourceDefinition.getProperty().getDescription()); + resourceDictionary.setResourcePath(resourceDefinition.getResourcePath()); + resourceDictionary.setResourceType(resourceDefinition.getResourceType()); + resourceDictionary.setTags(resourceDefinition.getTags()); + resourceDictionary.setUpdatedBy(resourceDefinition.getUpdatedBy()); + resourceDictionary.setDefinition(resourceDefinition); + return resourceDictionary; + } } diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestTest.java index c28abe2d3..c7147490d 100644 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestTest.java +++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRestTest.java @@ -1,5 +1,6 @@ /* * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,13 +55,14 @@ public class ModelTypeRestTest { @After - public void tearDown() {} + public void tearDown() { + } @Test public void test01SaveModelType() throws Exception { - log.info( "**************** test01SaveModelType ********************"); + log.info("**************** test01SaveModelType ********************"); - String content = FileUtils.readFileToString(new File("load/model_type/data_type/datatype-property.json"), Charset.defaultCharset()); + String content = JacksonUtils.getClassPathFileContent("model_type/data_type/datatype-property.json"); ModelType modelType = new ModelType(); modelType.setDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE); modelType.setDerivedFrom(BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT); @@ -72,7 +74,7 @@ public class ModelTypeRestTest { + BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE); modelType.setUpdatedBy("xxxxxx@xxx.com"); modelType = modelTypeRest.saveModelType(modelType); - log.info( "Saved Mode {}", modelType.toString()); + log.info("Saved Mode {}", modelType.toString()); Assert.assertNotNull("Failed to get Saved ModelType", modelType); Assert.assertNotNull("Failed to get Saved ModelType, Id", modelType.getModelName()); @@ -90,7 +92,7 @@ public class ModelTypeRestTest { @Test public void test02SearchModelTypes() throws Exception { - log.info( "*********************** test02SearchModelTypes ***************************"); + log.info("*********************** test02SearchModelTypes ***************************"); String tags = "test-datatype"; @@ -102,7 +104,7 @@ public class ModelTypeRestTest { @Test public void test03GetModelType() throws Exception { - log.info( "************************* test03GetModelType *********************************"); + log.info("************************* test03GetModelType *********************************"); ModelType dbModelType = modelTypeRest.getModelTypeByName(modelName); Assert.assertNotNull("Failed to get response for api call getModelByName ", dbModelType); Assert.assertNotNull("Failed to get Id for api call getModelByName ", dbModelType.getModelName()); @@ -125,5 +127,4 @@ public class ModelTypeRestTest { } - } diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java index 217eb8f06..faa10825f 100644 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java +++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java @@ -1,5 +1,6 @@ /* * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -127,10 +128,10 @@ public class ServiceTemplateRestTest { public void test05AutoMap() throws Exception { log.info("*********** test05AutoMap *******************************************"); - String resourceassignmentContent = FileUtils.readFileToString( + String resourceAssignmentContent = FileUtils.readFileToString( new File("src/test/resources/resourcedictionary/automap.json"), Charset.defaultCharset()); List batchResourceAssignment = - JacksonUtils.getListFromJson(resourceassignmentContent, ResourceAssignment.class); + JacksonUtils.getListFromJson(resourceAssignmentContent, ResourceAssignment.class); AutoMapResponse autoMapResponse = serviceTemplateRest.autoMap(batchResourceAssignment); Assert.assertNotNull("Failed to get ResourceAssignments, Return object is Null", diff --git a/ms/controllerblueprints/modules/service/src/test/resources/application.properties b/ms/controllerblueprints/modules/service/src/test/resources/application.properties index a13e16841..b17663e9a 100644 --- a/ms/controllerblueprints/modules/service/src/test/resources/application.properties +++ b/ms/controllerblueprints/modules/service/src/test/resources/application.properties @@ -1,5 +1,6 @@ # -# Copyright © 2017-2018 AT&T Intellectual Property. +# Copyright © 2017-2018 AT&T Intellectual Property. +# Modifications Copyright © 2018 IBM. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -64,4 +65,8 @@ logging.level.org.hibernate.type.descriptor.sql=debug blueprints.load.initial-data=true -blueprints.load.path=load \ No newline at end of file +load.dataTypePath=./../../application/load/model_type/data_type +load.nodeTypePath=./../../application/load/model_type/node_type +load.artifactTypePath=./../../application/load/model_type/artifact_type +load.resourceDictionaryPath=load/resource_dictionary +load.blueprintsPath=./../../application/load/blueprints \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/test/resources/model_type/data_type/datatype-property.json b/ms/controllerblueprints/modules/service/src/test/resources/model_type/data_type/datatype-property.json new file mode 100644 index 000000000..5584b10ea --- /dev/null +++ b/ms/controllerblueprints/modules/service/src/test/resources/model_type/data_type/datatype-property.json @@ -0,0 +1,27 @@ +{ + "version": "1.0.0", + "description": "This is Entry point Input Data Type, which is dynamic datatype, The parameter names will be populated during the Design time for each inputs", + "properties": { + "type": { + "required": true, + "type": "string" + }, + "description": { + "required": false, + "type": "string" + }, + "required": { + "required": false, + "type": "boolean" + }, + "default": { + "required": false, + "type": "string" + }, + "entry_schema": { + "required": false, + "type": "string" + } + }, + "derived_from": "tosca.datatypes.Root" +} \ No newline at end of file -- cgit 1.2.3-korg From 30bdb24f421db1d3703cfea707a8a6865adedb88 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Wed, 12 Sep 2018 16:26:31 +0000 Subject: Controller Blueprints Microservice Add dynamic resource source mapping rest service. Change-Id: I59274a4c0162bc6718c4248788c0e7f36830a129 Issue-ID: CCSDK-556 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../load/resource_dictionary/default-source.json | 16 ++++ .../opt/app/onap/config/application.properties | 5 +- .../src/test/resources/application.properties | 5 +- .../service/ApplicationRegistrationService.java | 26 ++++++- .../service/ResourceDictionaryService.java | 13 +++- .../service/rs/ResourceDictionaryRest.java | 7 ++ .../enhancer/ResourceAssignmentEnhancerService.kt | 88 ++++++++++++++++++++++ .../ResourceAssignmentEnhancerServiceTest.java | 50 ++++++++++++ .../service/rs/ResourceDictionaryRestTest.java | 8 ++ .../src/test/resources/application.properties | 5 +- .../src/test/resources/enhance/simple-enrich.json | 37 +++++++++ 11 files changed, 252 insertions(+), 8 deletions(-) create mode 100644 ms/controllerblueprints/application/load/resource_dictionary/default-source.json create mode 100644 ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerService.kt create mode 100644 ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerServiceTest.java create mode 100644 ms/controllerblueprints/modules/service/src/test/resources/enhance/simple-enrich.json (limited to 'ms/controllerblueprints/application/src/test/resources') diff --git a/ms/controllerblueprints/application/load/resource_dictionary/default-source.json b/ms/controllerblueprints/application/load/resource_dictionary/default-source.json new file mode 100644 index 000000000..64bfa0ccd --- /dev/null +++ b/ms/controllerblueprints/application/load/resource_dictionary/default-source.json @@ -0,0 +1,16 @@ +{ + "tags": "v4-ip-type, tosca.datatypes.Root, data_type, brindasanth@onap.com", + "name": "default-source", + "property" :{ + "description": "name of the ", + "type": "string" + }, + "updated-by": "brindasanth@onap.com", + "sources": { + "default": { + "type": "source-default", + "properties": { + } + } + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/application/opt/app/onap/config/application.properties b/ms/controllerblueprints/application/opt/app/onap/config/application.properties index b65d5bfe5..d28148275 100644 --- a/ms/controllerblueprints/application/opt/app/onap/config/application.properties +++ b/ms/controllerblueprints/application/opt/app/onap/config/application.properties @@ -53,4 +53,7 @@ load.dataTypePath=load/model_type/data_type load.nodeTypePath=load/model_type/node_type load.artifactTypePath=load/model_type/artifact_type load.resourceDictionaryPath=load/resource_dictionary -load.blueprintsPath=load/blueprints \ No newline at end of file +load.blueprintsPath=load/blueprints + +# Load Resource Source Mappings +resourceSourceMappings=db=source-db,input=source-input,default=source-default,mdsal=source-rest \ No newline at end of file diff --git a/ms/controllerblueprints/application/src/test/resources/application.properties b/ms/controllerblueprints/application/src/test/resources/application.properties index 3bcbbd9c9..e2d040c26 100644 --- a/ms/controllerblueprints/application/src/test/resources/application.properties +++ b/ms/controllerblueprints/application/src/test/resources/application.properties @@ -33,4 +33,7 @@ load.dataTypePath=load/model_type/data_type load.nodeTypePath=load/model_type/node_type load.artifactTypePath=load/model_type/artifact_type load.resourceDictionaryPath=load/resource_dictionary -load.blueprintsPath=load/blueprints \ No newline at end of file +load.blueprintsPath=load/blueprints + +# Load Resource Source Mappings +resourceSourceMappings=db=source-db,input=source-input,default=source-default,mdsal=source-rest \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ApplicationRegistrationService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ApplicationRegistrationService.java index 5a4a2877e..fc7410f96 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ApplicationRegistrationService.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ApplicationRegistrationService.java @@ -17,20 +17,40 @@ package org.onap.ccsdk.apps.controllerblueprints.service; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import org.apache.commons.collections.CollectionUtils; +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.factory.ResourceSourceMappingFactory; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import javax.annotation.PostConstruct; +import java.util.List; @Component @SuppressWarnings("unused") public class ApplicationRegistrationService { + private static EELFLogger log = EELFManager.getInstance().getLogger(ApplicationRegistrationService.class); + + @Value("#{'${resourceSourceMappings}'.split(',')}") + private List resourceSourceMappings; @PostConstruct - public void register(){ + public void register() { registerDictionarySources(); } - public void registerDictionarySources(){ - + public void registerDictionarySources() { + log.info("Registering Dictionary Sources : {}", resourceSourceMappings); + if (CollectionUtils.isNotEmpty(resourceSourceMappings)) { + resourceSourceMappings.forEach(resourceSourceMapping -> { + String[] mappingKeyValue = resourceSourceMapping.split("="); + if (mappingKeyValue != null && mappingKeyValue.length == 2) { + ResourceSourceMappingFactory.INSTANCE.registerSourceMapping(mappingKeyValue[0].trim(), mappingKeyValue[1].trim()); + } else { + log.warn("failed to get resource source mapping {}", resourceSourceMapping); + } + }); + } } } diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryService.java index 62aa0e29c..fd73db3b6 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryService.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryService.java @@ -22,8 +22,9 @@ import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException; import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition; -import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils; import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition; +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceSourceMapping; +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.factory.ResourceSourceMappingFactory; import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary; import org.onap.ccsdk.apps.controllerblueprints.service.repository.ResourceDictionaryRepository; import org.onap.ccsdk.apps.controllerblueprints.service.validator.ResourceDictionaryValidator; @@ -105,7 +106,7 @@ public class ResourceDictionaryService { */ public ResourceDictionary saveResourceDictionary(ResourceDictionary resourceDictionary) { Preconditions.checkNotNull(resourceDictionary, "Resource Dictionary information is missing"); - Preconditions.checkNotNull(resourceDictionary.getDefinition(),"Resource Dictionary definition information is missing"); + Preconditions.checkNotNull(resourceDictionary.getDefinition(), "Resource Dictionary definition information is missing"); ResourceDefinition resourceDefinition = resourceDictionary.getDefinition(); Preconditions.checkNotNull(resourceDefinition, "failed to get resource definition from content"); @@ -153,4 +154,12 @@ public class ResourceDictionaryService { Preconditions.checkArgument(StringUtils.isNotBlank(name), "Resource dictionary Name Information is missing."); resourceDictionaryRepository.deleteByName(name); } + + /** + * This is a getResourceSourceMapping service + * + */ + public ResourceSourceMapping getResourceSourceMapping() { + return ResourceSourceMappingFactory.INSTANCE.getRegisterSourceMapping(); + } } diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java index e0cf6c69b..287d413cc 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java @@ -18,6 +18,7 @@ package org.onap.ccsdk.apps.controllerblueprints.service.rs; import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException; +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceSourceMapping; import org.onap.ccsdk.apps.controllerblueprints.service.ResourceDictionaryService; import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary; import org.springframework.http.MediaType; @@ -76,4 +77,10 @@ public class ResourceDictionaryRest { } + @GetMapping(path = "/source-mapping", produces = MediaType.APPLICATION_JSON_VALUE) + public @ResponseBody + ResourceSourceMapping getResourceSourceMapping() { + return resourceDictionaryService.getResourceSourceMapping(); + } + } diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerService.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerService.kt new file mode 100644 index 000000000..0d08985a1 --- /dev/null +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerService.kt @@ -0,0 +1,88 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * 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. + */ + +package org.onap.ccsdk.apps.controllerblueprints.service.enhancer + +import com.att.eelf.configuration.EELFLogger +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintEnhancerDefaultService +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintEnhancerService +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition +import com.att.eelf.configuration.EELFManager +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceAssignmentValidationDefaultService +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionRepoService + +/** + * ResourceAssignmentEnhancerService. + * + * @author Brinda Santh + */ +interface ResourceAssignmentEnhancerService { + + @Throws(BluePrintException::class) + fun enhanceBluePrint(bluePrintEnhancerService: BluePrintEnhancerService, + resourceAssignments: List) + + @Throws(BluePrintException::class) + fun enhanceBluePrint(resourceAssignments: List): ServiceTemplate +} + +/** + * ResourceAssignmentEnhancerDefaultService. + * + * @author Brinda Santh + */ +open class ResourceAssignmentEnhancerDefaultService(private val resourceDefinitionRepoService: ResourceDefinitionRepoService) + : ResourceAssignmentEnhancerService { + private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceAssignmentValidationDefaultService::class.java) + + /** + * Get the defined source instance from the ResourceAssignment, + * then get the NodeType of the Sources assigned + */ + override fun enhanceBluePrint(bluePrintEnhancerService: BluePrintEnhancerService, + resourceAssignments: List) { + + // Iterate the Resource Assignment and + resourceAssignments.map { resourceAssignment -> + val dictionaryName = resourceAssignment.dictionaryName!! + val dictionarySource = resourceAssignment.dictionarySource!! + log.info("Enriching Assignment name({}), dictionary name({}), source({})", resourceAssignment.name, + dictionaryName, dictionarySource) + // Get the Resource Definition from Repo + val resourceDefinition: ResourceDefinition = getResourceDefinition(dictionaryName) + + val sourceNodeTemplate = resourceDefinition.sources.get(dictionarySource) + + // Enrich as NodeTemplate + bluePrintEnhancerService.enrichNodeTemplate(dictionarySource, sourceNodeTemplate!!) + } + } + + override fun enhanceBluePrint(resourceAssignments: List): ServiceTemplate { + val bluePrintEnhancerService = BluePrintEnhancerDefaultService(resourceDefinitionRepoService) + bluePrintEnhancerService.serviceTemplate = ServiceTemplate() + bluePrintEnhancerService.initialCleanUp() + enhanceBluePrint(bluePrintEnhancerService, resourceAssignments) + return bluePrintEnhancerService.serviceTemplate + } + + private fun getResourceDefinition(name: String): ResourceDefinition { + return resourceDefinitionRepoService.getResourceDefinition(name).block()!! + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerServiceTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerServiceTest.java new file mode 100644 index 000000000..7d16f50fa --- /dev/null +++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerServiceTest.java @@ -0,0 +1,50 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * 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. + */ + +package org.onap.ccsdk.apps.controllerblueprints.service.enhancer; + +import org.junit.Assert; +import org.junit.Test; +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException; +import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate; +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonReactorUtils; +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment; +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionFileRepoService; +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionRepoService; + +import java.util.List; + +/** + * ResourceAssignmentEnhancerService. + * + * @author Brinda Santh + */ +public class ResourceAssignmentEnhancerServiceTest { + + @Test + public void testEnhanceBluePrint() throws BluePrintException { + + List resourceAssignments = JacksonReactorUtils + .getListFromClassPathFile("enhance/simple-enrich.json", ResourceAssignment.class).block(); + Assert.assertNotNull("Failed to get Resource Assignment", resourceAssignments); + ResourceDefinitionRepoService resourceDefinitionRepoService = new ResourceDefinitionFileRepoService("./../../application/load"); + ResourceAssignmentEnhancerService resourceAssignmentEnhancerService = + new ResourceAssignmentEnhancerDefaultService(resourceDefinitionRepoService); + ServiceTemplate serviceTemplate = resourceAssignmentEnhancerService.enhanceBluePrint(resourceAssignments); + Assert.assertNotNull("Failed to get Enriched service Template", serviceTemplate); + } +} + diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java index 5955ae191..ac786d0e9 100644 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java +++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java @@ -26,6 +26,7 @@ import org.junit.runners.MethodSorters; import org.onap.ccsdk.apps.controllerblueprints.TestApplication; import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils; import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition; +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceSourceMapping; import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; @@ -103,4 +104,11 @@ public class ResourceDictionaryRestTest { } + @Test + public void test03GetResourceSourceMapping() { + ResourceSourceMapping resourceSourceMapping = resourceDictionaryRest.getResourceSourceMapping(); + org.springframework.util.Assert.notNull(resourceSourceMapping, "Failed to get resource source mapping"); + org.springframework.util.Assert.notNull(resourceSourceMapping.getResourceSourceMappings(), "Failed to get resource source mappings"); + } + } diff --git a/ms/controllerblueprints/modules/service/src/test/resources/application.properties b/ms/controllerblueprints/modules/service/src/test/resources/application.properties index 429588b31..3a913b701 100644 --- a/ms/controllerblueprints/modules/service/src/test/resources/application.properties +++ b/ms/controllerblueprints/modules/service/src/test/resources/application.properties @@ -28,4 +28,7 @@ load.dataTypePath=./../../application/load/model_type/data_type load.nodeTypePath=./../../application/load/model_type/node_type load.artifactTypePath=./../../application/load/model_type/artifact_type load.resourceDictionaryPath=./../../application/load/resource_dictionary -load.blueprintsPath=./../../application/load/blueprints \ No newline at end of file +load.blueprintsPath=./../../application/load/blueprints + +# Load Resource Source Mappings +resourceSourceMappings=db=source-db,input=source-input,default=source-default,mdsal=source-rest \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/test/resources/enhance/simple-enrich.json b/ms/controllerblueprints/modules/service/src/test/resources/enhance/simple-enrich.json new file mode 100644 index 000000000..641da80a2 --- /dev/null +++ b/ms/controllerblueprints/modules/service/src/test/resources/enhance/simple-enrich.json @@ -0,0 +1,37 @@ +[ + { + "name": "rs-db-source", + "input-param": true, + "property": { + "type": "string", + "required": true + }, + "dictionary-name": "db-source", + "dictionary-source": "db", + "dependencies": [ + "input-source" + ] + }, + { + "name": "ra-default-source", + "input-param": true, + "property": { + "type": "string", + "required": true + }, + "dictionary-name": "default-source", + "dictionary-source": "default", + "dependencies": [] + }, + { + "name": "ra-input-source", + "input-param": true, + "property": { + "type": "string", + "required": true + }, + "dictionary-name": "input-source", + "dictionary-source": "input", + "dependencies": [] + } +] -- cgit 1.2.3-korg From 99f4a1e766cf27d35fb7b68b4904d1e49e7fa787 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Thu, 13 Sep 2018 00:20:34 +0000 Subject: Controller Blueprints Microservice Add resource assignment enhancement and validation to blueprint validation and enhancement. Change-Id: I547760012e7014cfbb7a1e3a1d8ffb77edc9b6a2 Issue-ID: CCSDK-562 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../load/resource_dictionary/db-source.json | 24 -- .../load/resource_dictionary/default-source.json | 16 -- .../load/resource_dictionary/input-source.json | 17 -- .../load/resource_dictionary/sample-db-source.json | 24 ++ .../resource_dictionary/sample-default-source.json | 16 ++ .../resource_dictionary/sample-input-source.json | 17 ++ .../load/resource_dictionary/sample-licenses.json | 29 ++ .../resource_dictionary/sample-mdsal-source.json | 25 ++ .../resource_dictionary/sample-v4-ip-type.json | 17 ++ .../load/resource_dictionary/v4-ip-type.json | 17 -- .../src/test/resources/application.properties | 2 + .../service/BluePrintEnhancerService.java | 23 +- .../service/BluePrintRepoDBService.java | 97 ------- .../service/ResourceDefinitionRepoDBService.java | 115 ++++++++ .../service/enhancer/BluePrintEnhancerService.kt | 272 ++++++++++++++++++ .../enhancer/ResourceAssignmentEnhancerService.kt | 50 +++- .../ResourceAssignmentEnhancerServiceTest.java | 17 +- .../ResourceDictionaryReactRepositoryTest.java | 6 +- .../service/rs/ResourceDictionaryRestTest.java | 2 +- .../service/rs/ServiceTemplateRestTest.java | 4 +- .../validator/ServiceTemplateValidationTest.java | 10 + .../src/test/resources/application.properties | 4 +- .../enhance/enhance-resource-assignment.json | 62 ++++ .../test/resources/enhance/enhance-template.json | 10 +- .../test/resources/enhance/enhanced-template.json | 312 ++++++++++++++------- .../src/test/resources/enhance/simple-enrich.json | 37 --- .../modules/service/src/test/resources/logback.xml | 5 +- .../test/resources/resourcedictionary/automap.json | 9 +- 28 files changed, 895 insertions(+), 344 deletions(-) delete mode 100644 ms/controllerblueprints/application/load/resource_dictionary/db-source.json delete mode 100644 ms/controllerblueprints/application/load/resource_dictionary/default-source.json delete mode 100644 ms/controllerblueprints/application/load/resource_dictionary/input-source.json create mode 100644 ms/controllerblueprints/application/load/resource_dictionary/sample-db-source.json create mode 100644 ms/controllerblueprints/application/load/resource_dictionary/sample-default-source.json create mode 100644 ms/controllerblueprints/application/load/resource_dictionary/sample-input-source.json create mode 100644 ms/controllerblueprints/application/load/resource_dictionary/sample-licenses.json create mode 100644 ms/controllerblueprints/application/load/resource_dictionary/sample-mdsal-source.json create mode 100644 ms/controllerblueprints/application/load/resource_dictionary/sample-v4-ip-type.json delete mode 100644 ms/controllerblueprints/application/load/resource_dictionary/v4-ip-type.json delete mode 100644 ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoDBService.java create mode 100644 ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDefinitionRepoDBService.java create mode 100644 ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerService.kt create mode 100644 ms/controllerblueprints/modules/service/src/test/resources/enhance/enhance-resource-assignment.json delete mode 100644 ms/controllerblueprints/modules/service/src/test/resources/enhance/simple-enrich.json (limited to 'ms/controllerblueprints/application/src/test/resources') diff --git a/ms/controllerblueprints/application/load/resource_dictionary/db-source.json b/ms/controllerblueprints/application/load/resource_dictionary/db-source.json deleted file mode 100644 index a0c78af06..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/db-source.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "name": "db-source", - "property" :{ - "description": "name of the ", - "type": "string" - }, - "updated-by": "brindasanth@onap.com", - "tags": "db-source, brindasanth@onap.com", - "sources": { - "db": { - "type": "source-db", - "properties": { - "query": "SELECT db-country, db-state FROM DEVICE_PROFILE WHERE profile_name = :profile_name", - "input-key-mapping": { - "profile_name": "profile_name" - }, - "output-key-mapping": { - "db-country": "country", - "db-state": "state" - } - } - } - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/resource_dictionary/default-source.json b/ms/controllerblueprints/application/load/resource_dictionary/default-source.json deleted file mode 100644 index 64bfa0ccd..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/default-source.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "tags": "v4-ip-type, tosca.datatypes.Root, data_type, brindasanth@onap.com", - "name": "default-source", - "property" :{ - "description": "name of the ", - "type": "string" - }, - "updated-by": "brindasanth@onap.com", - "sources": { - "default": { - "type": "source-default", - "properties": { - } - } - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/resource_dictionary/input-source.json b/ms/controllerblueprints/application/load/resource_dictionary/input-source.json deleted file mode 100644 index acfad16bb..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/input-source.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "input-source", - "property" :{ - "description": "name of the ", - "type": "string" - }, - "updated-by": "brindasanth@onap.com", - "tags": "action-name, brindasanth", - "sources": { - "input": { - "type": "source-input", - "properties": { - "key": "action-name" - } - } - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/resource_dictionary/sample-db-source.json b/ms/controllerblueprints/application/load/resource_dictionary/sample-db-source.json new file mode 100644 index 000000000..90775aee0 --- /dev/null +++ b/ms/controllerblueprints/application/load/resource_dictionary/sample-db-source.json @@ -0,0 +1,24 @@ +{ + "name": "sample-db-source", + "property" :{ + "description": "name of the ", + "type": "string" + }, + "updated-by": "brindasanth@onap.com", + "tags": "db-source, brindasanth@onap.com", + "sources": { + "db": { + "type": "source-db", + "properties": { + "query": "SELECT db-country, db-state FROM DEVICE_PROFILE WHERE profile_name = :profile_name", + "input-key-mapping": { + "profile_name": "profile_name" + }, + "output-key-mapping": { + "db-country": "country", + "db-state": "state" + } + } + } + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/resource_dictionary/sample-default-source.json b/ms/controllerblueprints/application/load/resource_dictionary/sample-default-source.json new file mode 100644 index 000000000..395b0ddd1 --- /dev/null +++ b/ms/controllerblueprints/application/load/resource_dictionary/sample-default-source.json @@ -0,0 +1,16 @@ +{ + "tags": "sample-default-source", + "name": "sample-default-source", + "property" :{ + "description": "name of the ", + "type": "string" + }, + "updated-by": "brindasanth@onap.com", + "sources": { + "default": { + "type": "source-default", + "properties": { + } + } + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/resource_dictionary/sample-input-source.json b/ms/controllerblueprints/application/load/resource_dictionary/sample-input-source.json new file mode 100644 index 000000000..73c0d4089 --- /dev/null +++ b/ms/controllerblueprints/application/load/resource_dictionary/sample-input-source.json @@ -0,0 +1,17 @@ +{ + "name": "sample-input-source", + "property" :{ + "description": "name of the ", + "type": "string" + }, + "updated-by": "brindasanth@onap.com", + "tags": "sample-input-source", + "sources": { + "input": { + "type": "source-input", + "properties": { + "key": "input-source" + } + } + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/resource_dictionary/sample-licenses.json b/ms/controllerblueprints/application/load/resource_dictionary/sample-licenses.json new file mode 100644 index 000000000..5834dd49b --- /dev/null +++ b/ms/controllerblueprints/application/load/resource_dictionary/sample-licenses.json @@ -0,0 +1,29 @@ +{ + "tags": "sample-licenses", + "name": "sample-licenses", + "property": { + "description" : " Sample Data for licences", + "required": true, + "type": "list", + "entry_schema": { + "type": "dt-license-key" + } + }, + "updated-by": "brindasanth@onap.com", + "sources": { + "mdsal": { + "type": "source-rest", + "properties": { + "type": "JSON", + "url-path": "config/L3VNF-API:services/service-list/", + "path": "/licenses", + "input-key-mapping": { + }, + "output-key-mapping": { + "licenses": "licenses" + }, + "key-dependencies": [] + } + } + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/resource_dictionary/sample-mdsal-source.json b/ms/controllerblueprints/application/load/resource_dictionary/sample-mdsal-source.json new file mode 100644 index 000000000..25464d3fe --- /dev/null +++ b/ms/controllerblueprints/application/load/resource_dictionary/sample-mdsal-source.json @@ -0,0 +1,25 @@ +{ + "tags": "sample-mdsal-source", + "name": "sample-mdsal-source", + "property": { + "description": "Sample sample-mdsal-source", + "type": "string" + }, + "updated-by": "brindasanth@onap.com", + "sources": { + "mdsal": { + "type": "source-rest", + "properties": { + "type": "JSON", + "url-path": "config/L3VNF-API:services/service-list/$service-instance-id/service-data/vnf-topology-information/vnf-assignments/vnf-vms/$vm-type/vm-networks/$network-role/v4-assigned-ip-list/$v4-ip-type", + "path": "/v4-assigned-ip-list/0/v4-ip-prefix", + "input-key-mapping": { + }, + "output-key-mapping": { + "mdsal-source": "v4-ip-prefix" + }, + "key-dependencies": [] + } + } + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/resource_dictionary/sample-v4-ip-type.json b/ms/controllerblueprints/application/load/resource_dictionary/sample-v4-ip-type.json new file mode 100644 index 000000000..055279c1e --- /dev/null +++ b/ms/controllerblueprints/application/load/resource_dictionary/sample-v4-ip-type.json @@ -0,0 +1,17 @@ +{ + "name": "sample-v4-ip-type", + "property": { + "description": "sample-v4-ip-type", + "type": "string" + }, + "updated-by": "brindasanth@onap.com", + "tags": "sample-v4-ip-type", + "sources": { + "input": { + "type": "source-input", + "properties": { + "key": "sample-v4-ip-type" + } + } + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/resource_dictionary/v4-ip-type.json b/ms/controllerblueprints/application/load/resource_dictionary/v4-ip-type.json deleted file mode 100644 index 1b4432d53..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/v4-ip-type.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "v4-ip-type", - "property": { - "description": "name of the ", - "type": "string" - }, - "updated-by": "brindasanth@onap.com", - "tags": "v4-ip-type, source-input, brindasanth", - "sources": { - "input": { - "type": "source-input", - "properties": { - "key": "v4-ip-type" - } - } - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/src/test/resources/application.properties b/ms/controllerblueprints/application/src/test/resources/application.properties index e2d040c26..5c6acf93d 100644 --- a/ms/controllerblueprints/application/src/test/resources/application.properties +++ b/ms/controllerblueprints/application/src/test/resources/application.properties @@ -14,6 +14,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +spring.main.banner-mode=off + appName=ControllerBluePrints ms_name=org.onap.ccsdk.apps.controllerblueprints appVersion=1.0.0 diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java index 8e98f9477..ef3b4a48f 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java @@ -25,12 +25,13 @@ import org.jetbrains.annotations.NotNull; import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException; import org.onap.ccsdk.apps.controllerblueprints.core.ConfigModelConstant; import org.onap.ccsdk.apps.controllerblueprints.core.data.*; -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintEnhancerDefaultService; -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoService; +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionRepoService; +import org.onap.ccsdk.apps.controllerblueprints.service.enhancer.BluePrintEnhancerDefaultService; import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils; import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; +import org.onap.ccsdk.apps.controllerblueprints.service.enhancer.ResourceAssignmentEnhancerService; import org.springframework.stereotype.Service; import java.util.HashMap; @@ -48,14 +49,18 @@ public class BluePrintEnhancerService extends BluePrintEnhancerDefaultService { private static EELFLogger log = EELFManager.getInstance().getLogger(BluePrintEnhancerService.class); + private ResourceAssignmentEnhancerService resourceAssignmentEnhancerService; + private Map recipeDataTypes = new HashMap<>(); - public BluePrintEnhancerService(BluePrintRepoService bluePrintEnhancerRepoDBService) { - super(bluePrintEnhancerRepoDBService); + public BluePrintEnhancerService(ResourceDefinitionRepoService resourceDefinitionRepoService, + ResourceAssignmentEnhancerService resourceAssignmentEnhancerService) { + super(resourceDefinitionRepoService); + this.resourceAssignmentEnhancerService = resourceAssignmentEnhancerService; } @Override - public void enrichTopologyTemplate(@NotNull ServiceTemplate serviceTemplate) throws BluePrintException{ + public void enrichTopologyTemplate(@NotNull ServiceTemplate serviceTemplate) throws BluePrintException { super.enrichTopologyTemplate(serviceTemplate); // Update the Recipe Inputs and DataTypes @@ -101,7 +106,7 @@ public class BluePrintEnhancerService extends BluePrintEnhancerDefaultService { // Modified for ONAP converted Object to JsonNode JsonNode recipeNames = nodeTemplate.getProperties().get(ConfigModelConstant.PROPERTY_RECIPE_NAMES); - log.info("Processing Receipe Names : {} ", recipeNames); + log.info("Processing Recipe Names : {} ", recipeNames); if (recipeNames != null && recipeNames.isArray() && recipeNames.size() > 0) { @@ -159,6 +164,9 @@ public class BluePrintEnhancerService extends BluePrintEnhancerDefaultService { JacksonUtils.getListFromJson(resourceAssignmentContent, ResourceAssignment.class); Preconditions.checkNotNull(resourceAssignments, "Failed to Processing Resource Mapping " + resourceAssignmentContent); + // Enhance Resource Assignment + resourceAssignmentEnhancerService.enhanceBluePrint(this, resourceAssignments); + dataTypeProperties = new HashMap<>(); for (ResourceAssignment resourceAssignment : resourceAssignments) { @@ -167,9 +175,6 @@ public class BluePrintEnhancerService extends BluePrintEnhancerDefaultService { && resourceAssignment.getProperty() != null && StringUtils.isNotBlank(resourceAssignment.getName())) { - // Enrich the Property Definition - super.enrichPropertyDefinition(resourceAssignment.getName(), resourceAssignment.getProperty()); - dataTypeProperties.put(resourceAssignment.getName(), resourceAssignment.getProperty()); } diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoDBService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoDBService.java deleted file mode 100644 index 5510e480c..000000000 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoDBService.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 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. - */ - -package org.onap.ccsdk.apps.controllerblueprints.service; - -import com.fasterxml.jackson.databind.JsonNode; -import com.google.common.base.Preconditions; -import org.apache.commons.lang3.StringUtils; -import org.jetbrains.annotations.NotNull; -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException; -import org.onap.ccsdk.apps.controllerblueprints.core.data.*; -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoService; -import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils; -import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType; -import org.onap.ccsdk.apps.controllerblueprints.service.repository.ModelTypeRepository; -import org.springframework.stereotype.Service; -import reactor.core.publisher.Mono; - -import java.util.Optional; - -/** - * BluePrintRepoDBService - * - * @author Brinda Santh - */ -@Service -@SuppressWarnings("unused") -public class BluePrintRepoDBService implements BluePrintRepoService { - - private ModelTypeRepository modelTypeRepository; - @SuppressWarnings("unused") - public BluePrintRepoDBService(ModelTypeRepository modelTypeRepository) { - this.modelTypeRepository = modelTypeRepository; - } - - @Override - public Mono getNodeType(@NotNull String nodeTypeName) throws BluePrintException { - return getModelType(nodeTypeName, NodeType.class); - } - - @Override - public Mono getDataType(@NotNull String dataTypeName) throws BluePrintException { - return getModelType(dataTypeName, DataType.class); - } - - @Override - public Mono getArtifactType(@NotNull String artifactTypeName) throws BluePrintException { - return getModelType(artifactTypeName, ArtifactType.class); - } - - @Override - public Mono getRelationshipType(@NotNull String relationshipTypeName) throws BluePrintException { - return getModelType(relationshipTypeName, RelationshipType.class); - } - - @Override - public Mono getCapabilityDefinition(@NotNull String capabilityDefinitionName) throws BluePrintException { - return getModelType(capabilityDefinitionName, CapabilityDefinition.class); - } - - private Mono getModelType(String modelName, Class valueClass) throws BluePrintException { - Preconditions.checkArgument(StringUtils.isNotBlank(modelName), - "Failed to get model from repo, model name is missing"); - - return getModelDefinition(modelName).map(modelDefinition -> { - Preconditions.checkNotNull(modelDefinition, - String.format("Failed to get model content for model name (%s)", modelName)); - return JacksonUtils.readValue(modelDefinition, valueClass); - } - ); - } - - private Mono getModelDefinition(String modelName) throws BluePrintException { - JsonNode modelDefinition; - Optional modelTypeDb = modelTypeRepository.findByModelName(modelName); - if (modelTypeDb.isPresent()) { - modelDefinition = modelTypeDb.get().getDefinition(); - } else { - throw new BluePrintException(String.format("failed to get model definition (%s) from repo", modelName)); - } - return Mono.just(modelDefinition); - } -} diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDefinitionRepoDBService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDefinitionRepoDBService.java new file mode 100644 index 000000000..16cc8415c --- /dev/null +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDefinitionRepoDBService.java @@ -0,0 +1,115 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 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. + */ + +package org.onap.ccsdk.apps.controllerblueprints.service; + +import com.fasterxml.jackson.databind.JsonNode; +import com.google.common.base.Preconditions; +import org.apache.commons.lang3.StringUtils; +import org.jetbrains.annotations.NotNull; +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException; +import org.onap.ccsdk.apps.controllerblueprints.core.data.*; +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils; +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition; +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionRepoService; +import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType; +import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary; +import org.onap.ccsdk.apps.controllerblueprints.service.repository.ModelTypeRepository; +import org.onap.ccsdk.apps.controllerblueprints.service.repository.ResourceDictionaryRepository; +import org.springframework.stereotype.Service; +import reactor.core.publisher.Mono; + +import java.util.Optional; + +/** + * ResourceDefinitionRepoDBService + * + * @author Brinda Santh + */ +@Service +@SuppressWarnings("unused") +public class ResourceDefinitionRepoDBService implements ResourceDefinitionRepoService { + + private ModelTypeRepository modelTypeRepository; + private ResourceDictionaryRepository resourceDictionaryRepository; + + @SuppressWarnings("unused") + public ResourceDefinitionRepoDBService(ModelTypeRepository modelTypeRepository, + ResourceDictionaryRepository resourceDictionaryRepository) { + this.modelTypeRepository = modelTypeRepository; + this.resourceDictionaryRepository = resourceDictionaryRepository; + } + + @Override + public Mono getNodeType(@NotNull String nodeTypeName) throws BluePrintException { + return getModelType(nodeTypeName, NodeType.class); + } + + @Override + public Mono getDataType(@NotNull String dataTypeName) throws BluePrintException { + return getModelType(dataTypeName, DataType.class); + } + + @Override + public Mono getArtifactType(@NotNull String artifactTypeName) throws BluePrintException { + return getModelType(artifactTypeName, ArtifactType.class); + } + + @Override + public Mono getRelationshipType(@NotNull String relationshipTypeName) throws BluePrintException { + return getModelType(relationshipTypeName, RelationshipType.class); + } + + @Override + public Mono getCapabilityDefinition(@NotNull String capabilityDefinitionName) throws BluePrintException { + return getModelType(capabilityDefinitionName, CapabilityDefinition.class); + } + + @NotNull + @Override + public Mono getResourceDefinition(@NotNull String resourceDefinitionName) throws BluePrintException{ + Optional dbResourceDictionary = resourceDictionaryRepository.findByName(resourceDefinitionName); + if(dbResourceDictionary.isPresent()){ + return Mono.just(dbResourceDictionary.get().getDefinition()); + }else{ + throw new BluePrintException(String.format("failed to get resource dictionary (%s) from repo", resourceDefinitionName)); + } + } + + private Mono getModelType(String modelName, Class valueClass) throws BluePrintException { + Preconditions.checkArgument(StringUtils.isNotBlank(modelName), + "Failed to get model from repo, model name is missing"); + + return getModelDefinition(modelName).map(modelDefinition -> { + Preconditions.checkNotNull(modelDefinition, + String.format("Failed to get model content for model name (%s)", modelName)); + return JacksonUtils.readValue(modelDefinition, valueClass); + } + ); + } + + private Mono getModelDefinition(String modelName) throws BluePrintException { + JsonNode modelDefinition; + Optional modelTypeDb = modelTypeRepository.findByModelName(modelName); + if (modelTypeDb.isPresent()) { + modelDefinition = modelTypeDb.get().getDefinition(); + } else { + throw new BluePrintException(String.format("failed to get model definition (%s) from repo", modelName)); + } + return Mono.just(modelDefinition); + } +} diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerService.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerService.kt new file mode 100644 index 000000000..cf9e96e77 --- /dev/null +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerService.kt @@ -0,0 +1,272 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 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. + */ + +package org.onap.ccsdk.apps.controllerblueprints.service.enhancer + +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes +import org.onap.ccsdk.apps.controllerblueprints.core.data.* +import org.onap.ccsdk.apps.controllerblueprints.core.format +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoService +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonReactorUtils +import java.io.Serializable + +/** + * BluePrintEnhancerService + * @author Brinda Santh + * + */ +interface BluePrintEnhancerService : Serializable { + + @Throws(BluePrintException::class) + fun enhance(content: String): ServiceTemplate + + /** + * Read Blueprint from CSAR structure Directory + */ + @Throws(BluePrintException::class) + fun enhance(fileName: String, basePath: String): ServiceTemplate + + @Throws(BluePrintException::class) + fun enhance(serviceTemplate: ServiceTemplate): ServiceTemplate + + @Throws(BluePrintException::class) + fun enrichNodeTemplate(nodeTemplateName: String, nodeTemplate: NodeTemplate) + + @Throws(BluePrintException::class) + fun enrichNodeType(nodeTypeName: String, nodeType: NodeType) + + @Throws(BluePrintException::class) + fun enrichPropertyDefinition(propertyName: String, propertyDefinition: PropertyDefinition) +} + +open class BluePrintEnhancerDefaultService(val bluePrintRepoService: BluePrintRepoService) : BluePrintEnhancerService { + + private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintEnhancerDefaultService::class.toString()) + + lateinit var serviceTemplate: ServiceTemplate + + @Throws(BluePrintException::class) + override fun enhance(content: String): ServiceTemplate { + return JacksonReactorUtils.readValueFromFile(content, ServiceTemplate::class.java).map { serviceTemplate -> + enhance(serviceTemplate!!) + }.block()!! + } + + @Throws(BluePrintException::class) + override fun enhance(fileName: String, basePath: String): ServiceTemplate { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + @Throws(BluePrintException::class) + override fun enhance(serviceTemplate: ServiceTemplate): ServiceTemplate { + this.serviceTemplate = serviceTemplate + initialCleanUp() + enrichTopologyTemplate(serviceTemplate) + + // log.info("Enriched Blueprint :\n {}", JacksonUtils.getJson(serviceTemplate, true)) + return this.serviceTemplate + } + + open fun initialCleanUp() { + serviceTemplate.artifactTypes?.clear() + serviceTemplate.nodeTypes?.clear() + serviceTemplate.dataTypes?.clear() + + serviceTemplate.artifactTypes = HashMap() + serviceTemplate.nodeTypes = HashMap() + serviceTemplate.dataTypes = HashMap() + + } + + @Throws(BluePrintException::class) + open fun enrichTopologyTemplate(serviceTemplate: ServiceTemplate) { + serviceTemplate.topologyTemplate?.let { topologyTemplate -> + enrichTopologyTemplateInputs(topologyTemplate) + enrichTopologyTemplateNodeTemplates(topologyTemplate) + } + } + + @Throws(BluePrintException::class) + open fun enrichTopologyTemplateInputs(topologyTemplate: TopologyTemplate) { + topologyTemplate.inputs?.let { inputs -> + enrichPropertyDefinitions(inputs) + } + } + + open fun enrichTopologyTemplateNodeTemplates(topologyTemplate: TopologyTemplate) { + topologyTemplate.nodeTemplates?.forEach { nodeTemplateName, nodeTemplate -> + enrichNodeTemplate(nodeTemplateName, nodeTemplate) + } + } + + @Throws(BluePrintException::class) + override fun enrichNodeTemplate(nodeTemplateName: String, nodeTemplate: NodeTemplate) { + val nodeTypeName = nodeTemplate.type + // Get NodeType from Repo and Update Service Template + val nodeType = populateNodeType(nodeTypeName) + + // Enrich NodeType + enrichNodeType(nodeTypeName, nodeType) + + //Enrich Node Template Artifacts + enrichNodeTemplateArtifactDefinition(nodeTemplateName, nodeTemplate) + } + + @Throws(BluePrintException::class) + override fun enrichNodeType(nodeTypeName: String, nodeType: NodeType) { + log.debug("Enriching NodeType({})", nodeTypeName) + val derivedFrom = nodeType.derivedFrom + + if (!BluePrintTypes.rootNodeTypes().contains(derivedFrom)) { + val derivedFromNodeType = populateNodeType(nodeTypeName) + // Enrich NodeType + enrichNodeType(derivedFrom, derivedFromNodeType) + } + + // NodeType Property Definitions + enrichNodeTypeProperties(nodeTypeName, nodeType) + + //NodeType Requirement + enrichNodeTypeRequirements(nodeTypeName, nodeType) + + //NodeType Capability + enrichNodeTypeCapabilityProperties(nodeTypeName, nodeType) + + //NodeType Interface + enrichNodeTypeInterfaces(nodeTypeName, nodeType) + } + + open fun enrichNodeTypeProperties(nodeTypeName: String, nodeType: NodeType) { + nodeType.properties?.let { enrichPropertyDefinitions(nodeType.properties!!) } + } + + open fun enrichNodeTypeRequirements(nodeTypeName: String, nodeType: NodeType) { + + nodeType.requirements?.forEach { _, requirementDefinition -> + // Populate Requirement Node + requirementDefinition.node?.let { requirementNodeTypeName -> + // Get Requirement NodeType from Repo and Update Service Template + val requirementNodeType = populateNodeType(requirementNodeTypeName) + + enrichNodeType(requirementNodeTypeName, requirementNodeType) + } + } + } + + open fun enrichNodeTypeCapabilityProperties(nodeTypeName: String, nodeType: NodeType) { + nodeType.capabilities?.forEach { capabilityDefinitionName, capabilityDefinition -> + capabilityDefinition.properties?.let { properties -> + enrichPropertyDefinitions(properties) + } + } + } + + open fun enrichNodeTypeInterfaces(nodeTypeName: String, nodeType: NodeType) { + nodeType.interfaces?.forEach { interfaceName, interfaceObj -> + // Populate Node type Interface Operation + log.debug("Enriching NodeType({}) Interface({})", nodeTypeName, interfaceName) + populateNodeTypeInterfaceOperation(nodeTypeName, interfaceName, interfaceObj) + + } + } + + open fun populateNodeTypeInterfaceOperation(nodeTypeName: String, interfaceName: String, interfaceObj: InterfaceDefinition) { + + interfaceObj.operations?.forEach { operationName, operation -> + enrichNodeTypeInterfaceOperationInputs(nodeTypeName, operationName, operation) + enrichNodeTypeInterfaceOperationOputputs(nodeTypeName, operationName, operation) + } + } + + open fun enrichNodeTypeInterfaceOperationInputs(nodeTypeName: String, operationName: String, operation: OperationDefinition) { + operation.inputs?.let { inputs -> + enrichPropertyDefinitions(inputs) + } + } + + open fun enrichNodeTypeInterfaceOperationOputputs(nodeTypeName: String, operationName: String, operation: OperationDefinition) { + operation.outputs?.let { inputs -> + enrichPropertyDefinitions(inputs) + } + } + + open fun enrichPropertyDefinitions(properties: MutableMap) { + + properties.forEach { propertyName, propertyDefinition -> + enrichPropertyDefinition(propertyName, propertyDefinition) + } + } + + @Throws(BluePrintException::class) + override fun enrichPropertyDefinition(propertyName: String, propertyDefinition: PropertyDefinition) { + val propertyType = propertyDefinition.type + if (BluePrintTypes.validPrimitiveTypes().contains(propertyType)) { + + } else if (BluePrintTypes.validCollectionTypes().contains(propertyType)) { + val entrySchema = propertyDefinition.entrySchema + ?: throw BluePrintException(format("Entry Schema is missing for collection property : {}", propertyName)) + + if (!BluePrintTypes.validPrimitiveTypes().contains(entrySchema.type)) { + populateDataTypes(entrySchema.type) + } + } else { + populateDataTypes(propertyType) + } + + } + + open fun enrichNodeTemplateArtifactDefinition(nodeTemplateName: String, nodeTemplate: NodeTemplate) { + + nodeTemplate.artifacts?.forEach { artifactDefinitionName, artifactDefinition -> + val artifactTypeName = artifactDefinition.type + ?: throw BluePrintException(format("Artifact type is missing for NodeTemplate({}) artifact({})", nodeTemplateName, artifactDefinitionName)) + + // Populate Artifact Type + populateArtifactType(artifactTypeName) + } + } + + open fun populateNodeType(nodeTypeName: String): NodeType { + + val nodeType = serviceTemplate.nodeTypes?.get(nodeTypeName) + ?: bluePrintRepoService.getNodeType(nodeTypeName)?.block() + ?: throw BluePrintException(format("Couldn't get NodeType({}) from repo.", nodeTypeName)) + serviceTemplate.nodeTypes?.put(nodeTypeName, nodeType) + return nodeType + } + + open fun populateArtifactType(artifactTypeName: String): ArtifactType { + val artifactType = serviceTemplate.artifactTypes?.get(artifactTypeName) + ?: bluePrintRepoService.getArtifactType(artifactTypeName)?.block() + ?: throw BluePrintException(format("Couldn't get ArtifactType({}) from repo.", artifactTypeName)) + serviceTemplate.artifactTypes?.put(artifactTypeName, artifactType) + return artifactType + } + + open fun populateDataTypes(dataTypeName: String): DataType { + val dataType = serviceTemplate.dataTypes?.get(dataTypeName) + ?: bluePrintRepoService.getDataType(dataTypeName)?.block() + ?: throw BluePrintException(format("Couldn't get DataType({}) from repo.", dataTypeName)) + serviceTemplate.dataTypes?.put(dataTypeName, dataType) + return dataType + } + +} + diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerService.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerService.kt index 0d08985a1..de6f82ffe 100644 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerService.kt +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerService.kt @@ -19,13 +19,16 @@ package org.onap.ccsdk.apps.controllerblueprints.service.enhancer import com.att.eelf.configuration.EELFLogger import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintEnhancerDefaultService -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintEnhancerService import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition import com.att.eelf.configuration.EELFManager +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes +import org.onap.ccsdk.apps.controllerblueprints.core.format +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.factory.ResourceSourceMappingFactory import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceAssignmentValidationDefaultService import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionRepoService +import org.springframework.stereotype.Service /** * ResourceAssignmentEnhancerService. @@ -47,6 +50,7 @@ interface ResourceAssignmentEnhancerService { * * @author Brinda Santh */ +@Service open class ResourceAssignmentEnhancerDefaultService(private val resourceDefinitionRepoService: ResourceDefinitionRepoService) : ResourceAssignmentEnhancerService { private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceAssignmentValidationDefaultService::class.java) @@ -58,20 +62,41 @@ open class ResourceAssignmentEnhancerDefaultService(private val resourceDefiniti override fun enhanceBluePrint(bluePrintEnhancerService: BluePrintEnhancerService, resourceAssignments: List) { + val uniqueSourceNodeTypeNames = hashSetOf() + // Iterate the Resource Assignment and resourceAssignments.map { resourceAssignment -> val dictionaryName = resourceAssignment.dictionaryName!! val dictionarySource = resourceAssignment.dictionarySource!! - log.info("Enriching Assignment name({}), dictionary name({}), source({})", resourceAssignment.name, + log.debug("Enriching Assignment name({}), dictionary name({}), source({})", resourceAssignment.name, dictionaryName, dictionarySource) - // Get the Resource Definition from Repo - val resourceDefinition: ResourceDefinition = getResourceDefinition(dictionaryName) + val sourceNodeTypeName = ResourceSourceMappingFactory.getRegisterSourceMapping(dictionarySource) + + // Add Unique Node Types + uniqueSourceNodeTypeNames.add(sourceNodeTypeName) + + // TODO("Candidate for Optimisation") + if (checkResourceDefinitionNeeded(resourceAssignment)) { + + bluePrintEnhancerService.enrichPropertyDefinition(resourceAssignment.name, resourceAssignment.property!!); + + // Get the Resource Definition from Repo + val resourceDefinition: ResourceDefinition = getResourceDefinition(dictionaryName) - val sourceNodeTemplate = resourceDefinition.sources.get(dictionarySource) + val sourceNodeTemplate = resourceDefinition.sources.get(dictionarySource) + ?: throw BluePrintException(format("failed to get assigned dictionarySource({}) from resourceDefinition({})", dictionarySource, dictionaryName)) - // Enrich as NodeTemplate - bluePrintEnhancerService.enrichNodeTemplate(dictionarySource, sourceNodeTemplate!!) + // Enrich as NodeTemplate + bluePrintEnhancerService.enrichNodeTemplate(dictionarySource, sourceNodeTemplate) + } } + // Enrich the ResourceSource NodeTypes + uniqueSourceNodeTypeNames.map { nodeTypeName -> + resourceDefinitionRepoService.getNodeType(nodeTypeName).subscribe { nodeType -> + bluePrintEnhancerService.enrichNodeType(nodeTypeName, nodeType) + } + } + } override fun enhanceBluePrint(resourceAssignments: List): ServiceTemplate { @@ -82,7 +107,14 @@ open class ResourceAssignmentEnhancerDefaultService(private val resourceDefiniti return bluePrintEnhancerService.serviceTemplate } + private fun checkResourceDefinitionNeeded(resourceAssignment: ResourceAssignment): Boolean { + return !((resourceAssignment.dictionarySource.equals(ResourceDictionaryConstants.SOURCE_INPUT) + || resourceAssignment.dictionarySource.equals(ResourceDictionaryConstants.SOURCE_DEFAULT)) + && BluePrintTypes.validPrimitiveOrCollectionPrimitive(resourceAssignment.property!!)) + } + private fun getResourceDefinition(name: String): ResourceDefinition { - return resourceDefinitionRepoService.getResourceDefinition(name).block()!! + return resourceDefinitionRepoService.getResourceDefinition(name).block() + ?: throw BluePrintException(format("failed to get dictionary definition({})", name)) } } \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerServiceTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerServiceTest.java index 7d16f50fa..e279ec9c0 100644 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerServiceTest.java +++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerServiceTest.java @@ -16,12 +16,17 @@ package org.onap.ccsdk.apps.controllerblueprints.service.enhancer; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; import org.junit.Assert; +import org.junit.Before; import org.junit.Test; import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException; import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate; import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonReactorUtils; +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils; import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment; +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.factory.ResourceSourceMappingFactory; import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionFileRepoService; import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionRepoService; @@ -33,18 +38,28 @@ import java.util.List; * @author Brinda Santh */ public class ResourceAssignmentEnhancerServiceTest { + private static EELFLogger log = EELFManager.getInstance().getLogger(ResourceAssignmentEnhancerServiceTest.class); + + @Before + public void setUp(){ + ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("db", "source-db"); + ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("input", "source-input"); + ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("default", "source-default"); + ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("mdsal", "source-rest"); + } @Test public void testEnhanceBluePrint() throws BluePrintException { List resourceAssignments = JacksonReactorUtils - .getListFromClassPathFile("enhance/simple-enrich.json", ResourceAssignment.class).block(); + .getListFromClassPathFile("enhance/enhance-resource-assignment.json", ResourceAssignment.class).block(); Assert.assertNotNull("Failed to get Resource Assignment", resourceAssignments); ResourceDefinitionRepoService resourceDefinitionRepoService = new ResourceDefinitionFileRepoService("./../../application/load"); ResourceAssignmentEnhancerService resourceAssignmentEnhancerService = new ResourceAssignmentEnhancerDefaultService(resourceDefinitionRepoService); ServiceTemplate serviceTemplate = resourceAssignmentEnhancerService.enhanceBluePrint(resourceAssignments); Assert.assertNotNull("Failed to get Enriched service Template", serviceTemplate); + log.trace("Enhanced Service Template : {}", JacksonUtils.getJson(serviceTemplate, true)); } } diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryReactRepositoryTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryReactRepositoryTest.java index ab939ffa1..b2e290186 100644 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryReactRepositoryTest.java +++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ResourceDictionaryReactRepositoryTest.java @@ -1,5 +1,6 @@ /* * Copyright © 2018 IBM. + * Modifications Copyright © 2017-2018 AT&T Intellectual Property. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +18,6 @@ package org.onap.ccsdk.apps.controllerblueprints.service.repository; import org.junit.Assert; -import org.junit.Before; import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runner.RunWith; @@ -55,7 +55,7 @@ public class ResourceDictionaryReactRepositoryTest { @Test @Commit public void test01Save() { - ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile("./../../application/load/resource_dictionary/db-source" + + ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile("./../../application/load/resource_dictionary/sample-db-source" + ".json", ResourceDefinition.class); Assert.assertNotNull("Failed to get resourceDefinition from content", resourceDefinition); resourceDefinition.setName(sourceName); @@ -88,7 +88,7 @@ public class ResourceDictionaryReactRepositoryTest { @Test @Commit public void test05Delete() { - resourceDictionaryReactRepository.deleteByName("db-source").block(); + resourceDictionaryReactRepository.deleteByName(sourceName).block(); } private ResourceDictionary transformResourceDictionary(ResourceDefinition resourceDefinition) { diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java index ac786d0e9..272cdd08f 100644 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java +++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java @@ -42,7 +42,7 @@ import java.util.List; @RunWith(SpringRunner.class) -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = {"blueprints.load.initial-data=true"}) @ContextConfiguration(classes = {TestApplication.class}) @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class ResourceDictionaryRestTest { diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java index faa10825f..37cc61d1c 100644 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java +++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java @@ -45,7 +45,7 @@ import java.util.List; @RunWith(SpringRunner.class) -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = {"blueprints.load.initial-data=true"}) @ContextConfiguration(classes = {TestApplication.class}) @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class ServiceTemplateRestTest { @@ -143,7 +143,7 @@ public class ServiceTemplateRestTest { List autoMappedResourceAssignment = autoMapResponse.getResourceAssignments(); autoMappedResourceAssignment.forEach(resourceAssignment -> { - if ("bundle-id".equals(resourceAssignment.getName())) { + if ("sample-db-source".equals(resourceAssignment.getName())) { Assert.assertEquals("Failed to assign default first source", "db", resourceAssignment.getDictionarySource()); } diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidationTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidationTest.java index 46b725f87..5f34b5510 100644 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidationTest.java +++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidationTest.java @@ -19,9 +19,11 @@ package org.onap.ccsdk.apps.controllerblueprints.service.validator; import org.apache.commons.io.FileUtils; import org.junit.Assert; +import org.junit.Before; import org.junit.Test; import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate; import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils; +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.factory.ResourceSourceMappingFactory; import org.onap.ccsdk.apps.controllerblueprints.service.utils.ConfigModelUtils; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; @@ -33,6 +35,14 @@ import java.util.List; public class ServiceTemplateValidationTest { private static EELFLogger log = EELFManager.getInstance().getLogger(ServiceTemplateValidationTest.class); + @Before + public void setUp(){ + ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("db", "source-db"); + ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("input", "source-input"); + ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("default", "source-default"); + ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("mdsal", "source-rest"); + } + @Test public void testBluePrintDirs() { List dirs = ConfigModelUtils.getBlueprintNames("load/blueprints"); diff --git a/ms/controllerblueprints/modules/service/src/test/resources/application.properties b/ms/controllerblueprints/modules/service/src/test/resources/application.properties index 3a913b701..397f3b138 100644 --- a/ms/controllerblueprints/modules/service/src/test/resources/application.properties +++ b/ms/controllerblueprints/modules/service/src/test/resources/application.properties @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # - +spring.main.banner-mode=off spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS = false @@ -23,7 +23,7 @@ logging.level.org.hibernate.SQL=warn logging.level.org.hibernate.type.descriptor.sql=debug -blueprints.load.initial-data=true +blueprints.load.initial-data=false load.dataTypePath=./../../application/load/model_type/data_type load.nodeTypePath=./../../application/load/model_type/node_type load.artifactTypePath=./../../application/load/model_type/artifact_type diff --git a/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhance-resource-assignment.json b/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhance-resource-assignment.json new file mode 100644 index 000000000..3715becad --- /dev/null +++ b/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhance-resource-assignment.json @@ -0,0 +1,62 @@ +[ + { + "name": "rs-db-source", + "input-param": true, + "property": { + "type": "string", + "required": true + }, + "dictionary-name": "sample-db-source", + "dictionary-source": "db", + "dependencies": [ + "input-source" + ] + }, + { + "name": "ra-default-source", + "input-param": true, + "property": { + "type": "string", + "required": true + }, + "dictionary-name": "sample-default-source", + "dictionary-source": "default", + "dependencies": [] + }, + { + "name": "ra-input-source", + "input-param": true, + "property": { + "type": "string", + "required": true + }, + "dictionary-name": "sample-input-source", + "dictionary-source": "input", + "dependencies": [] + }, + { + "name": "ra-list-input-source", + "input-param": true, + "property": { + "type": "list", + "required": true, + "entry_schema": { + "type": "string" + } + }, + "dictionary-name": "ra-list-input-source", + "dictionary-source": "input", + "dependencies": [] + }, + { + "name": "ra-complex-input-source", + "input-param": true, + "property": { + "type": "dt-v4-aggregate", + "required": true + }, + "dictionary-name": "sample-mdsal-source", + "dictionary-source": "mdsal", + "dependencies": [] + } +] diff --git a/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhance-template.json b/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhance-template.json index 70d03e0a8..782ed505c 100644 --- a/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhance-template.json +++ b/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhance-template.json @@ -218,13 +218,13 @@ "properties": { "mapping": [ { - "name": "bundle-mac", + "name": "rs-db-source", "property": { "required": true, "type": "string" }, "input-param": false, - "dictionary-name": "bundle-mac", + "dictionary-name": "sample-db-source", "dictionary-source": "db", "dependencies": [ "hostname" @@ -232,7 +232,7 @@ "version": 0 }, { - "name": "wan-aggregate-ipv4-addresses", + "name": "mdsal-source", "property": { "description": "", "required": true, @@ -242,7 +242,7 @@ } }, "input-param": false, - "dictionary-name": "wan-aggregate-ipv4-addresses", + "dictionary-name": "sample-mdsal-source", "dictionary-source": "mdsal", "dependencies": [ "service-instance-id" @@ -313,7 +313,7 @@ } }, "input-param": false, - "dictionary-name": "licenses", + "dictionary-name": "sample-licenses", "dictionary-source": "mdsal", "dependencies": [ "service-instance-id" diff --git a/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhanced-template.json b/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhanced-template.json index bf3deffb5..531d756be 100644 --- a/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhanced-template.json +++ b/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhanced-template.json @@ -114,10 +114,6 @@ "description" : "This is Dynamic Data type definition generated from resource mapping for the config template name base-config-template.", "version" : "1.0.0", "properties" : { - "bundle-mac" : { - "required" : true, - "type" : "string" - }, "hostname" : { "required" : true, "type" : "string" @@ -129,13 +125,9 @@ "type" : "dt-license-key" } }, - "wan-aggregate-ipv4-addresses" : { - "description" : "", + "rs-db-source" : { "required" : true, - "type" : "list", - "entry_schema" : { - "type" : "dt-v4-aggregate" - } + "type" : "string" }, "service" : { "required" : true, @@ -144,6 +136,14 @@ "service-instance-id" : { "required" : true, "type" : "string" + }, + "mdsal-source" : { + "description" : "", + "required" : true, + "type" : "list", + "entry_schema" : { + "type" : "dt-v4-aggregate" + } } }, "derived_from" : "tosca.datatypes.Dynamic" @@ -206,6 +206,127 @@ "version" : "1.0.0", "derived_from" : "tosca.nodes.Root" }, + "artifact-config-template" : { + "description" : "This is Configuration Velocity Template", + "version" : "1.0.0", + "properties" : { + "action-names" : { + "required" : true, + "type" : "list", + "entry_schema" : { + "type" : "string" + } + } + }, + "capabilities" : { + "content" : { + "type" : "tosca.capabilities.Content", + "properties" : { + "content" : { + "required" : true, + "type" : "string" + } + } + }, + "mapping" : { + "type" : "tosca.capabilities.Mapping", + "properties" : { + "mapping" : { + "required" : false, + "type" : "list", + "entry_schema" : { + "type" : "datatype-resource-assignment" + } + } + } + } + }, + "derived_from" : "tosca.nodes.Artifact" + }, + "tosca.nodes.Vnf" : { + "description" : "This is VNF Node Type", + "version" : "1.0.0", + "derived_from" : "tosca.nodes.Root" + }, + "tosca.nodes.Artifact" : { + "description" : "This is Deprecated Artifact Node Type.", + "version" : "1.0.0", + "derived_from" : "tosca.nodes.Root" + }, + "dg-activate-netconf" : { + "description" : "This is Download Netconf Directed Graph", + "version" : "1.0.0", + "properties" : { + "mode" : { + "required" : false, + "type" : "string", + "default" : "sync" + }, + "version" : { + "required" : false, + "type" : "string", + "default" : "LATEST" + }, + "is-start-flow" : { + "required" : false, + "type" : "boolean", + "default" : false + } + }, + "capabilities" : { + "dg-node" : { + "type" : "tosca.capabilities.Node" + } + }, + "requirements" : { + "component-dependency" : { + "capability" : "component-node", + "node" : "component-netconf-executor", + "relationship" : "tosca.relationships.DependsOn" + } + }, + "interfaces" : { + "CONFIG" : { + "operations" : { + "ActivateNetconf" : { + "inputs" : { + "params" : { + "required" : false, + "type" : "list", + "entry_schema" : { + "type" : "datatype-property" + } + } + } + } + } + } + }, + "derived_from" : "tosca.nodes.DG" + }, + "source-input" : { + "description" : "This is Input Resource Source Node Type", + "version" : "1.0.0", + "properties" : { + "key" : { + "required" : false, + "type" : "string" + }, + "key-dependencies" : { + "required" : true, + "type" : "list", + "entry_schema" : { + "type" : "string" + } + } + }, + "derived_from" : "tosca.nodes.ResourceSource" + }, + "tosca.nodes.ResourceSource" : { + "description" : "TOSCA base type for Resource Sources", + "version" : "1.0.0", + "derived_from" : "tosca.nodes.Root" + }, "component-resource-assignment" : { "description" : "This is Resource Assignment Component API", "version" : "1.0.0", @@ -279,42 +400,44 @@ "version" : "1.0.0", "derived_from" : "tosca.nodes.Root" }, - "artifact-config-template" : { - "description" : "This is Configuration Velocity Template", + "source-db" : { + "description" : "This is Database Resource Source Node Type", "version" : "1.0.0", "properties" : { - "action-names" : { + "type" : { "required" : true, - "type" : "list", + "type" : "string", + "constraints" : [ { + "valid_values" : [ "SQL", "PLSQL" ] + } ] + }, + "query" : { + "required" : true, + "type" : "string" + }, + "input-key-mapping" : { + "required" : false, + "type" : "map", "entry_schema" : { "type" : "string" } - } - }, - "capabilities" : { - "content" : { - "type" : "tosca.capabilities.Content", - "properties" : { - "content" : { - "required" : true, - "type" : "string" - } + }, + "output-key-mapping" : { + "required" : false, + "type" : "map", + "entry_schema" : { + "type" : "string" } }, - "mapping" : { - "type" : "tosca.capabilities.Mapping", - "properties" : { - "mapping" : { - "required" : false, - "type" : "list", - "entry_schema" : { - "type" : "datatype-resource-assignment" - } - } + "key-dependencies" : { + "required" : true, + "type" : "list", + "entry_schema" : { + "type" : "string" } } }, - "derived_from" : "tosca.nodes.Artifact" + "derived_from" : "tosca.nodes.ResourceSource" }, "vnf-netconf-device" : { "description" : "This is VNF Device with Netconf Capability", @@ -357,10 +480,57 @@ }, "derived_from" : "tosca.nodes.Vnf" }, - "tosca.nodes.Vnf" : { - "description" : "This is VNF Node Type", + "source-rest" : { + "description" : "This is Rest Resource Source Node Type", "version" : "1.0.0", - "derived_from" : "tosca.nodes.Root" + "properties" : { + "type" : { + "required" : false, + "type" : "string", + "constraints" : [ { + "valid_values" : [ "JSON" ] + } ], + "default" : "JSON" + }, + "url-path" : { + "required" : true, + "type" : "string" + }, + "path" : { + "required" : true, + "type" : "string" + }, + "expression-type" : { + "required" : false, + "type" : "string", + "constraints" : [ { + "valid_values" : [ "JSON_PATH", "JSON_POINTER" ] + } ], + "default" : "JSON_PATH" + }, + "input-key-mapping" : { + "required" : false, + "type" : "map", + "entry_schema" : { + "type" : "string" + } + }, + "output-key-mapping" : { + "required" : false, + "type" : "map", + "entry_schema" : { + "type" : "string" + } + }, + "key-dependencies" : { + "required" : true, + "type" : "list", + "entry_schema" : { + "type" : "string" + } + } + }, + "derived_from" : "tosca.nodes.ResourceSource" }, "component-netconf-executor" : { "description" : "This is Netconf Transaction Configuration Component API", @@ -440,62 +610,6 @@ } }, "derived_from" : "tosca.nodes.Component" - }, - "tosca.nodes.Artifact" : { - "description" : "This is Deprecated Artifact Node Type.", - "version" : "1.0.0", - "derived_from" : "tosca.nodes.Root" - }, - "dg-activate-netconf" : { - "description" : "This is Download Netconf Directed Graph", - "version" : "1.0.0", - "properties" : { - "mode" : { - "required" : false, - "type" : "string", - "default" : "sync" - }, - "version" : { - "required" : false, - "type" : "string", - "default" : "LATEST" - }, - "is-start-flow" : { - "required" : false, - "type" : "boolean", - "default" : false - } - }, - "capabilities" : { - "dg-node" : { - "type" : "tosca.capabilities.Node" - } - }, - "requirements" : { - "component-dependency" : { - "capability" : "component-node", - "node" : "component-netconf-executor", - "relationship" : "tosca.relationships.DependsOn" - } - }, - "interfaces" : { - "CONFIG" : { - "operations" : { - "ActivateNetconf" : { - "inputs" : { - "params" : { - "required" : false, - "type" : "list", - "entry_schema" : { - "type" : "datatype-property" - } - } - } - } - } - } - }, - "derived_from" : "tosca.nodes.DG" } }, "topology_template" : { @@ -704,18 +818,18 @@ "mapping" : { "properties" : { "mapping" : [ { - "name" : "bundle-mac", + "name" : "rs-db-source", "property" : { "required" : true, "type" : "string" }, "input-param" : false, - "dictionary-name" : "bundle-mac", + "dictionary-name" : "sample-db-source", "dictionary-source" : "db", "dependencies" : [ "hostname" ], "version" : 0 }, { - "name" : "wan-aggregate-ipv4-addresses", + "name" : "mdsal-source", "property" : { "description" : "", "required" : true, @@ -725,7 +839,7 @@ } }, "input-param" : false, - "dictionary-name" : "wan-aggregate-ipv4-addresses", + "dictionary-name" : "sample-mdsal-source", "dictionary-source" : "mdsal", "dependencies" : [ "service-instance-id" ], "version" : 0 @@ -787,7 +901,7 @@ } }, "input-param" : false, - "dictionary-name" : "licenses", + "dictionary-name" : "sample-licenses", "dictionary-source" : "mdsal", "dependencies" : [ "service-instance-id" ], "version" : 0 diff --git a/ms/controllerblueprints/modules/service/src/test/resources/enhance/simple-enrich.json b/ms/controllerblueprints/modules/service/src/test/resources/enhance/simple-enrich.json deleted file mode 100644 index 641da80a2..000000000 --- a/ms/controllerblueprints/modules/service/src/test/resources/enhance/simple-enrich.json +++ /dev/null @@ -1,37 +0,0 @@ -[ - { - "name": "rs-db-source", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "db-source", - "dictionary-source": "db", - "dependencies": [ - "input-source" - ] - }, - { - "name": "ra-default-source", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "default-source", - "dictionary-source": "default", - "dependencies": [] - }, - { - "name": "ra-input-source", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "input-source", - "dictionary-source": "input", - "dependencies": [] - } -] diff --git a/ms/controllerblueprints/modules/service/src/test/resources/logback.xml b/ms/controllerblueprints/modules/service/src/test/resources/logback.xml index 4a04cfdca..7b7ef7565 100644 --- a/ms/controllerblueprints/modules/service/src/test/resources/logback.xml +++ b/ms/controllerblueprints/modules/service/src/test/resources/logback.xml @@ -1,5 +1,6 @@ @@ -102,6 +105,11 @@ kotlin-stdlib ${kotlin.version} + + org.jetbrains.kotlin + kotlinx-couroutines-core + ${kotlin.couroutines.version} + org.jetbrains.kotlin kotlin-reflect @@ -112,6 +120,12 @@ kotlin-stdlib-jdk8 ${kotlin.version} + + org.jetbrains.kotlin + kotlin-stdlib-jdk7 + ${kotlin.version} + + @@ -148,12 +162,12 @@ org.powermock powermock-api-mockito2 - 1.7.4 + ${powermock.version} test org.jetbrains.kotlin - kotlin-test + kotlin-test-junit ${kotlin.version} test -- cgit 1.2.3-korg From c872d95d0c4f7b5227c0d05def39986e3eebe5b3 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Sat, 1 Dec 2018 19:54:07 -0500 Subject: Enable Webflux Service. Change-Id: I99bacee9b63aa788bb368dec60981bf19ea759c4 Issue-ID: CCSDK-781 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../application/etc/logback.xml | 2 +- .../opt/app/onap/config/application-dev.properties | 2 +- .../opt/app/onap/config/application.properties | 2 +- ms/controllerblueprints/application/pom.xml | 53 ++++++++++++- .../ApplicationExceptionHandler.java | 74 ------------------ .../apps/controllerblueprints/SwaggerConfig.java | 7 +- .../ccsdk/apps/controllerblueprints/WebConfig.java | 11 +++ .../filters/ApplicationLoggingFilter.java | 91 ++++++++++++---------- .../controllerblueprints/filters/CorsFilter.java | 64 --------------- .../ApplicationBasicAuthenticationEntryPoint.java | 43 ---------- .../ApplicationSecurityConfigurerAdapter.java | 74 ++++++++---------- .../src/test/resources/application.properties | 2 +- ms/controllerblueprints/modules/service/pom.xml | 4 - .../service/DataBaseInitService.java | 2 +- .../service/SchemaGeneratorService.java | 2 +- .../service/domain/ConfigModelContent.java | 1 + .../repository/ConfigModelContentRepository.java | 1 + .../service/rs/ConfigModelRest.java | 1 + .../service/rs/ModelTypeRest.java | 1 + .../service/rs/ResourceDictionaryRest.java | 1 + .../service/rs/ServiceTemplateRest.java | 1 + .../service/utils/ConfigModelUtils.java | 1 + ms/controllerblueprints/parent/pom.xml | 10 ++- 23 files changed, 169 insertions(+), 281 deletions(-) delete mode 100644 ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ApplicationExceptionHandler.java delete mode 100644 ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/filters/CorsFilter.java delete mode 100644 ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/security/ApplicationBasicAuthenticationEntryPoint.java (limited to 'ms/controllerblueprints/application/src/test/resources') diff --git a/ms/controllerblueprints/application/etc/logback.xml b/ms/controllerblueprints/application/etc/logback.xml index 6639705e2..01ae4f6c9 100644 --- a/ms/controllerblueprints/application/etc/logback.xml +++ b/ms/controllerblueprints/application/etc/logback.xml @@ -16,7 +16,7 @@ - + diff --git a/ms/controllerblueprints/application/opt/app/onap/config/application-dev.properties b/ms/controllerblueprints/application/opt/app/onap/config/application-dev.properties index e09208703..8741fab21 100644 --- a/ms/controllerblueprints/application/opt/app/onap/config/application-dev.properties +++ b/ms/controllerblueprints/application/opt/app/onap/config/application-dev.properties @@ -19,7 +19,7 @@ appVersion=1.0.0 # Basic Authentication basic-auth.user-name=ccsdkapps -basic-auth.hashed-pwd=$2a$10$MJxhNiOAffxbyrV9.rrOUewP9Q/ASg5Nit2cmP.yBaXGsVXo8BW3y +basic-auth.hashed-pwd={bcrypt}$2a$10$MJxhNiOAffxbyrV9.rrOUewP9Q/ASg5Nit2cmP.yBaXGsVXo8BW3y #logging.pattern.console=%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p) %clr($ threadId: {PID:- }){magenta} %clr(---){faint} %clr([ hostname: %X{hostname} serviceName: %X{serviceName} version: %X{version} transactionId: %X{transactionId} requestTimeStamp: %X{requestTimestamp} responseTimeStamp: %X{responseTimestamp} duration: %X{duration}]){yellow} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n%wex diff --git a/ms/controllerblueprints/application/opt/app/onap/config/application.properties b/ms/controllerblueprints/application/opt/app/onap/config/application.properties index 0160ee5fb..aae37011e 100644 --- a/ms/controllerblueprints/application/opt/app/onap/config/application.properties +++ b/ms/controllerblueprints/application/opt/app/onap/config/application.properties @@ -20,7 +20,7 @@ appVersion=1.0.0 # Basic Authentication basic-auth.user-name=ccsdkapps -basic-auth.hashed-pwd=$2a$10$MJxhNiOAffxbyrV9.rrOUewP9Q/ASg5Nit2cmP.yBaXGsVXo8BW3y +basic-auth.hashed-pwd={bcrypt}$2a$10$MJxhNiOAffxbyrV9.rrOUewP9Q/ASg5Nit2cmP.yBaXGsVXo8BW3y #logging.pattern.console=%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p) %clr($ threadId: {PID:- }){magenta} %clr(---){faint} %clr([ hostname: %X{hostname} serviceName: %X{serviceName} version: %X{version} transactionId: %X{transactionId} requestTimeStamp: %X{requestTimestamp} responseTimeStamp: %X{responseTimestamp} duration: %X{duration}]){yellow} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n%wex diff --git a/ms/controllerblueprints/application/pom.xml b/ms/controllerblueprints/application/pom.xml index bf1c75259..bb0f7686d 100644 --- a/ms/controllerblueprints/application/pom.xml +++ b/ms/controllerblueprints/application/pom.xml @@ -31,7 +31,7 @@ application Controller Blueprints Application - ${basedir}/src/main/resources/swagger-ui/dist + ${basedir}/target/src/main/resources/swagger-ui 1.8 org.onap.ccsdk.apps controllerblueprints @@ -205,9 +205,56 @@ 1.8 + + com.github.kongchen + swagger-maven-plugin + 3.1.7 + + + + true + org.onap.ccsdk.apps.controllerblueprints.service.rs + + + http + https + + /api/v1 + + Controller Blueprints + ${project.version} + + Controller blueprints API for VNF Self Service. + + + Terms of service + + + brindasanth@gmail.com + Brinda Santh + http://onap.com + + + http://www.apache.org/licenses/LICENSE-2.0.html + Apache 2.0 + + + ${swagger.directory} + + + + + + compile + + generate + + + + - - + + diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ApplicationExceptionHandler.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ApplicationExceptionHandler.java deleted file mode 100644 index 78706d570..000000000 --- a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ApplicationExceptionHandler.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * 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. - */ - -package org.onap.ccsdk.apps.controllerblueprints; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException; -import org.onap.ccsdk.apps.controllerblueprints.service.common.ErrorMessage; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.http.converter.HttpMessageNotReadableException; -import org.springframework.security.authentication.BadCredentialsException; -import org.springframework.security.web.csrf.InvalidCsrfTokenException; -import org.springframework.web.HttpRequestMethodNotSupportedException; -import org.springframework.web.bind.MethodArgumentNotValidException; -import org.springframework.web.bind.annotation.ControllerAdvice; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.context.request.WebRequest; - -import javax.naming.AuthenticationException; -import java.nio.file.AccessDeniedException; - -@ControllerAdvice -@RestController -@SuppressWarnings("unused") -public class ApplicationExceptionHandler { - private static EELFLogger log = EELFManager.getInstance().getLogger(ApplicationExceptionHandler.class); - - @ExceptionHandler(Exception.class) - public final ResponseEntity handleAllExceptions(Exception ex, WebRequest request) { - log.error("Application Exception", ex); - ErrorMessage exceptionResponse = new ErrorMessage(ex.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR.value(), ex.getLocalizedMessage()); - return new ResponseEntity<>(exceptionResponse, HttpStatus.INTERNAL_SERVER_ERROR); - } - - @ExceptionHandler({InvalidCsrfTokenException.class, AuthenticationException.class, BadCredentialsException.class, AccessDeniedException.class}) - @ResponseStatus(value = HttpStatus.UNAUTHORIZED) - public final ResponseEntity handleAuthenticationRequest(Exception ex, WebRequest request) { - log.error("Authentication Exception", ex); - ErrorMessage exceptionResponse = new ErrorMessage(ex.getMessage(), HttpStatus.UNAUTHORIZED.value(), ex.getLocalizedMessage()); - return new ResponseEntity<>(exceptionResponse, HttpStatus.UNAUTHORIZED); - } - - @ExceptionHandler({HttpMessageNotReadableException.class, MethodArgumentNotValidException.class, - HttpRequestMethodNotSupportedException.class}) - public final ResponseEntity handleBadRequest(Exception ex, WebRequest request) { - log.error("Bad Request Exception", ex); - ErrorMessage exceptionResponse = new ErrorMessage(ex.getMessage(), HttpStatus.BAD_REQUEST.value(), ex.getLocalizedMessage()); - return new ResponseEntity<>(exceptionResponse, HttpStatus.BAD_REQUEST); - } - - @ExceptionHandler(BluePrintException.class) - public final ResponseEntity handleBlueprintException(BluePrintException ex, WebRequest request) { - log.error("Application Blueprint Exception", ex); - ErrorMessage exceptionResponse = new ErrorMessage(ex.getMessage(), ex.getCode(), ex.getLocalizedMessage()); - return new ResponseEntity<>(exceptionResponse, HttpStatus.INTERNAL_SERVER_ERROR); - } -} diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/SwaggerConfig.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/SwaggerConfig.java index 8b96f04a4..b9c0bd19b 100644 --- a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/SwaggerConfig.java +++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/SwaggerConfig.java @@ -21,7 +21,6 @@ import org.jetbrains.annotations.NotNull; import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.RequestMethod; import springfox.documentation.builders.PathSelectors; @@ -34,7 +33,6 @@ import springfox.documentation.service.Header; import springfox.documentation.service.ResponseMessage; import springfox.documentation.spi.DocumentationType; import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; import java.util.Collections; import java.util.HashMap; @@ -46,8 +44,9 @@ import java.util.Map; * * @author Brinda Santh 8/13/2018 */ -@Configuration -@EnableSwagger2 +@Deprecated +//@Configuration +//@EnableSwagger2 @SuppressWarnings("unused") public class SwaggerConfig { @Value("${appVersion}") diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/WebConfig.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/WebConfig.java index 83f5f19ee..45faa1b57 100644 --- a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/WebConfig.java +++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/WebConfig.java @@ -17,6 +17,7 @@ package org.onap.ccsdk.apps.controllerblueprints; import org.springframework.context.annotation.Configuration; +import org.springframework.web.reactive.config.CorsRegistry; import org.springframework.web.reactive.config.ResourceHandlerRegistry; import org.springframework.web.reactive.config.WebFluxConfigurationSupport; @@ -35,5 +36,15 @@ public class WebConfig extends WebFluxConfigurationSupport { registry.addResourceHandler("/webjars/**") .addResourceLocations("classpath:/META-INF/resources/webjars/"); + + } + + @Override + public void addCorsMappings(CorsRegistry corsRegistry) { + corsRegistry.addMapping("/**") + .allowedOrigins("*") + .allowedMethods("*") + .allowedHeaders("DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range") + .maxAge(3600); } } diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/filters/ApplicationLoggingFilter.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/filters/ApplicationLoggingFilter.java index 44761177b..367ea7d91 100644 --- a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/filters/ApplicationLoggingFilter.java +++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/filters/ApplicationLoggingFilter.java @@ -20,66 +20,79 @@ package org.onap.ccsdk.apps.controllerblueprints.filters; import com.google.common.base.Preconditions; import org.apache.commons.lang3.StringUtils; import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants; -import org.onap.logging.ref.slf4j.ONAPLogAdapter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.slf4j.MDC; import org.springframework.beans.factory.annotation.Value; -import org.springframework.core.Ordered; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.HttpHeaders; +import org.springframework.http.server.reactive.ServerHttpRequest; +import org.springframework.http.server.reactive.ServerHttpResponse; +import org.springframework.web.server.ServerWebExchange; +import org.springframework.web.server.WebFilter; +import org.springframework.web.server.WebFilterChain; +import reactor.core.publisher.Mono; -import javax.servlet.*; -import javax.servlet.annotation.WebFilter; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; +import java.time.ZoneOffset; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.util.UUID; /** * ApplicationLoggingFilter * * @author Brinda Santh 8/14/2018 */ -@Component -@WebFilter(asyncSupported = true, urlPatterns = {"/*"}) -@Order(Ordered.HIGHEST_PRECEDENCE) +@Configuration @SuppressWarnings("unused") -public class ApplicationLoggingFilter implements Filter { +public class ApplicationLoggingFilter implements WebFilter { private static Logger log = LoggerFactory.getLogger(ApplicationLoggingFilter.class); @SuppressWarnings("unused") @Value("${appVersion}") private String appVersion; - public void doFilter(ServletRequest request, - ServletResponse response, - FilterChain chain) throws IOException, ServletException { - - HttpServletRequest req = (HttpServletRequest) request; - HttpServletResponse res = (HttpServletResponse) response; - - ONAPLogAdapter onapLogAdapter = new ONAPLogAdapter(log); - onapLogAdapter.entering(req); - - String[] tokens = StringUtils.split(appVersion, '.'); - Preconditions.checkNotNull(tokens, "failed to split application versions"); - Preconditions.checkArgument(tokens.length == 3, "failed to tokenize application versions"); - res.addHeader(BluePrintConstants.RESPONSE_HEADER_TRANSACTION_ID, MDC.get("RequestID")); - res.addHeader(BluePrintConstants.RESPONSE_HEADER_MINOR_VERSION, tokens[1]); - res.addHeader(BluePrintConstants.RESPONSE_HEADER_PATCH_VERSION, tokens[2]); - res.addHeader(BluePrintConstants.RESPONSE_HEADER_LATEST_VERSION, appVersion); - chain.doFilter(request, response); - // Clean the MDC info - onapLogAdapter.exiting(); + @Override + public Mono filter(ServerWebExchange serverWebExchange, WebFilterChain webFilterChain) { + try { + + ServerHttpRequest request = serverWebExchange.getRequest(); + ServerHttpResponse response = serverWebExchange.getResponse(); + + String[] tokens = StringUtils.split(appVersion, '.'); + Preconditions.checkNotNull(tokens, "failed to split application versions"); + Preconditions.checkArgument(tokens.length == 3, "failed to tokenize application versions"); + HttpHeaders header = response.getHeaders(); + + String requestID = defaultToUUID(request.getHeaders().getFirst("X-ONAP-RequestID")); + String invocationID = defaultToUUID(request.getHeaders().getFirst("X-ONAP-InvocationID")); + String partnerName = defaultToEmpty(request.getHeaders().getFirst("X-ONAP-PartnerName")); + MDC.put("InvokeTimestamp", ZonedDateTime.now(ZoneOffset.UTC).format(DateTimeFormatter.ISO_INSTANT)); + MDC.put("RequestID", requestID); + MDC.put("InvocationID", invocationID); + MDC.put("PartnerName", partnerName); + MDC.put("ClientIPAddress", defaultToEmpty(request.getRemoteAddress().getAddress())); + MDC.put("ServerFQDN", defaultToEmpty(request.getRemoteAddress().getHostString())); + + header.add(BluePrintConstants.RESPONSE_HEADER_TRANSACTION_ID, requestID); + header.add(BluePrintConstants.RESPONSE_HEADER_MINOR_VERSION, tokens[1]); + header.add(BluePrintConstants.RESPONSE_HEADER_PATCH_VERSION, tokens[2]); + header.add(BluePrintConstants.RESPONSE_HEADER_LATEST_VERSION, appVersion); + } catch (Exception e) { + e.printStackTrace(); + } + + return webFilterChain.filter(serverWebExchange); + } - @Override - public void init(FilterConfig filterConfig) { - //method does nothing + private static String defaultToUUID(String in) { + return in == null ? UUID.randomUUID().toString() : in; } - @Override - public void destroy() { - //method does nothing + private static String defaultToEmpty(Object in) { + return in == null ? "" : in.toString(); } + + } \ No newline at end of file diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/filters/CorsFilter.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/filters/CorsFilter.java deleted file mode 100644 index b97fa1788..000000000 --- a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/filters/CorsFilter.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 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. - */ - -package org.onap.ccsdk.apps.controllerblueprints.filters; - -import org.springframework.http.HttpMethod; -import org.springframework.stereotype.Component; -import javax.servlet.*; -import javax.servlet.annotation.WebFilter; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -/** - * CorsFilter.java Purpose: Provide Configuration Generator CorsFilter Information - * - * @author Brinda Santh - */ -@Component -@WebFilter(asyncSupported = true, urlPatterns = {"/*"}) -@SuppressWarnings("unused") -public class CorsFilter implements Filter { - - public void destroy() { - //method does nothing - } - - public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain) - throws IOException, ServletException { - - HttpServletRequest request = (HttpServletRequest) servletRequest; - HttpServletResponse response = (HttpServletResponse) servletResponse; - - response.addHeader("Access-Control-Allow-Origin", "*"); - response.addHeader("Access-Control-Allow-Methods", "*"); - response.addHeader("Access-Control-Allow-Headers", - "DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range"); - - if (request.getMethod().equals(HttpMethod.OPTIONS.toString())) { - response.addHeader("Access-Control-Max-Age", "1728000"); - response.setStatus(HttpServletResponse.SC_ACCEPTED); - return; - } - chain.doFilter(request, servletResponse); - } - - public void init(FilterConfig fConfig) throws ServletException { - //method does nothing - } - -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/security/ApplicationBasicAuthenticationEntryPoint.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/security/ApplicationBasicAuthenticationEntryPoint.java deleted file mode 100644 index e3df3a621..000000000 --- a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/security/ApplicationBasicAuthenticationEntryPoint.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * 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. - */ - -package org.onap.ccsdk.apps.controllerblueprints.security; - -import org.springframework.security.core.AuthenticationException; -import org.springframework.security.web.authentication.www.BasicAuthenticationEntryPoint; -import org.springframework.stereotype.Component; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; - -@Component -public class ApplicationBasicAuthenticationEntryPoint extends BasicAuthenticationEntryPoint { - - @Override - public void commence(final HttpServletRequest request, final HttpServletResponse response, final AuthenticationException authException) - throws IOException { - response.addHeader("WWW-Authenticate", "Basic realm=\"" + getRealmName() + "\""); - response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); - response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized"); - } - - @Override - public void afterPropertiesSet() throws Exception { - setRealmName("CCSDK-APPS"); - super.afterPropertiesSet(); - } - -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/security/ApplicationSecurityConfigurerAdapter.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/security/ApplicationSecurityConfigurerAdapter.java index 3a39d7821..334574f79 100644 --- a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/security/ApplicationSecurityConfigurerAdapter.java +++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/security/ApplicationSecurityConfigurerAdapter.java @@ -1,38 +1,35 @@ /* - * Copyright © 2017-2018 AT&T Intellectual Property. + * Copyright © 2017-2018 AT&T Intellectual Property. * - * 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 + * 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 + * 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. + * 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. */ package org.onap.ccsdk.apps.controllerblueprints.security; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; -import org.springframework.security.crypto.password.PasswordEncoder; +import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity; +import org.springframework.security.config.web.server.ServerHttpSecurity; +import org.springframework.security.core.userdetails.MapReactiveUserDetailsService; +import org.springframework.security.core.userdetails.User; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.security.web.server.SecurityWebFilterChain; @SuppressWarnings("unused") -@Configuration -@EnableWebSecurity -public class ApplicationSecurityConfigurerAdapter extends WebSecurityConfigurerAdapter { +@EnableWebFluxSecurity +public class ApplicationSecurityConfigurerAdapter { @Value("${basic-auth.user-name}") private String userName; @@ -42,31 +39,24 @@ public class ApplicationSecurityConfigurerAdapter extends WebSecurityConfigurerA private static EELFLogger log = EELFManager.getInstance().getLogger(ApplicationSecurityConfigurerAdapter.class); - @Autowired - private ApplicationBasicAuthenticationEntryPoint authenticationEntryPoint; - - @Autowired - public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { - log.info("User Id {} and hashed pwd : {}", userName, userHashedPassword); - auth.inMemoryAuthentication() - .withUser(userName).password(userHashedPassword) - .authorities("ROLE_USER"); - } - - @Override - protected void configure(HttpSecurity http) throws Exception { - http.authorizeRequests() - .antMatchers("/actuator/health").permitAll() - .antMatchers("/**").authenticated() - .and() - .httpBasic() - .authenticationEntryPoint(authenticationEntryPoint); + @Bean + public SecurityWebFilterChain springWebFilterChain(ServerHttpSecurity http) throws Exception { http.csrf().disable(); + http.authorizeExchange() + .pathMatchers("/webjars/**", "/actuator/**").permitAll() + .anyExchange().authenticated() + .and().httpBasic(); + + return http.build(); } @Bean - public PasswordEncoder passwordEncoder() { - return new BCryptPasswordEncoder(); + public MapReactiveUserDetailsService userDetailsService() { + User.UserBuilder userBuilder = User.builder(); + UserDetails defaultUser = userBuilder + .username(userName) + .password(userHashedPassword).roles("USER").build(); + return new MapReactiveUserDetailsService(defaultUser); } } \ No newline at end of file diff --git a/ms/controllerblueprints/application/src/test/resources/application.properties b/ms/controllerblueprints/application/src/test/resources/application.properties index 62ef2a74a..0e8789767 100644 --- a/ms/controllerblueprints/application/src/test/resources/application.properties +++ b/ms/controllerblueprints/application/src/test/resources/application.properties @@ -22,7 +22,7 @@ appVersion=1.0.0 # Basic Authentication basic-auth.user-name=ccsdkapps -basic-auth.hashed-pwd=$2a$10$MJxhNiOAffxbyrV9.rrOUewP9Q/ASg5Nit2cmP.yBaXGsVXo8BW3y +basic-auth.hashed-pwd={bcrypt}$2a$10$MJxhNiOAffxbyrV9.rrOUewP9Q/ASg5Nit2cmP.yBaXGsVXo8BW3y #To Remove Null in JSON API Response spring.jackson.default-property-inclusion=non_null diff --git a/ms/controllerblueprints/modules/service/pom.xml b/ms/controllerblueprints/modules/service/pom.xml index cd95abf94..017cfde48 100644 --- a/ms/controllerblueprints/modules/service/pom.xml +++ b/ms/controllerblueprints/modules/service/pom.xml @@ -46,10 +46,6 @@ org.springframework.boot spring-boot-starter-webflux - - org.springframework.boot - spring-boot-starter-web - org.springframework.boot spring-boot-starter-data-jpa diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/DataBaseInitService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/DataBaseInitService.java index 74faa4df1..a4b874eef 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/DataBaseInitService.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/DataBaseInitService.java @@ -54,7 +54,7 @@ import java.util.List; * @author Brinda Santh * @version 1.0 */ - +@Deprecated @Component @ConditionalOnProperty(name = "blueprints.load.initial-data", havingValue = "true") public class DataBaseInitService { diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/SchemaGeneratorService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/SchemaGeneratorService.java index 04a95fd12..ff8b07a9d 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/SchemaGeneratorService.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/SchemaGeneratorService.java @@ -37,7 +37,7 @@ import java.util.Map; * @author Brinda Santh * @version 1.0 */ - +@Deprecated public class SchemaGeneratorService { private static EELFLogger log = EELFManager.getInstance().getLogger(SchemaGeneratorService.class); diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModelContent.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModelContent.java index 71904fb30..561354713 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModelContent.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModelContent.java @@ -62,6 +62,7 @@ public class ConfigModelContent { @Column(name = "description") private String description; + @Deprecated @Lob @Column(name = "content", nullable = false) @ApiModelProperty(required=true) diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ConfigModelContentRepository.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ConfigModelContentRepository.java index 733cbbdb3..81c26373b 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ConfigModelContentRepository.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ConfigModelContentRepository.java @@ -31,6 +31,7 @@ import java.util.Optional; * @author Brinda Santh * @version 1.0 */ +@Deprecated @Repository public interface ConfigModelContentRepository extends JpaRepository { diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRest.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRest.java index 95e551b14..b025b2ffa 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRest.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRest.java @@ -27,6 +27,7 @@ import java.util.List; /** * {@inheritDoc} */ +@Deprecated @RestController @RequestMapping(value = "/api/v1/config-model") public class ConfigModelRest { diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java index 0f485a081..69c209258 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java @@ -28,6 +28,7 @@ import java.util.List; /** * {@inheritDoc} */ +@Deprecated @RestController @RequestMapping(value = "/api/v1/model-type") public class ModelTypeRest { diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java index 9b2209e8b..932cdfac8 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java @@ -29,6 +29,7 @@ import java.util.List; /** * {@inheritDoc} */ +@Deprecated @RestController @RequestMapping(value = "/api/v1/dictionary") public class ResourceDictionaryRest { diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRest.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRest.java index caa6bba4f..3798ee6d4 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRest.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRest.java @@ -32,6 +32,7 @@ import java.util.List; /** * {@inheritDoc} */ +@Deprecated @RestController @RequestMapping(value = "/api/v1/service-template") public class ServiceTemplateRest { diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/utils/ConfigModelUtils.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/utils/ConfigModelUtils.java index e9ee1bc0a..3c6b14baf 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/utils/ConfigModelUtils.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/utils/ConfigModelUtils.java @@ -37,6 +37,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +@Deprecated public class ConfigModelUtils { private ConfigModelUtils() { diff --git a/ms/controllerblueprints/parent/pom.xml b/ms/controllerblueprints/parent/pom.xml index 4f6a316b9..309b2283e 100644 --- a/ms/controllerblueprints/parent/pom.xml +++ b/ms/controllerblueprints/parent/pom.xml @@ -28,8 +28,8 @@ Controller Blueprints Parent pom - 2.0.6.RELEASE - 5.0.10.RELEASE + 2.1.1.RELEASE + 5.1.3.RELEASE 1.3.10 1.3.10 1.0.1 @@ -170,6 +170,12 @@ ${kotlin.version} test + + io.grpc + grpc-testing + ${grpc.version} + test + -- cgit 1.2.3-korg From 8899e7a0f1ba7481cbcbe7ff581c285a9d0e98b6 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Fri, 14 Dec 2018 20:38:44 -0500 Subject: Add multiple path load service. Change-Id: Ib2e5f60663991d097b7446106bb883a45db1bdb8 Issue-ID: CCSDK-746 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- ms/controllerblueprints/README.md | 2 +- .../opt/app/onap/config/application-dev.properties | 32 +- .../opt/app/onap/config/application.properties | 25 +- .../src/test/resources/application.properties | 24 +- .../service/DataBaseInitService.java | 325 --------------------- .../service/BluePrintCoreConfiguration.kt | 60 ++++ .../service/load/BluePrintCatalogLoad.kt | 28 -- .../service/load/BluePrintCatalogLoadService.kt | 68 +++++ .../service/load/BluePrintCatalogServiceImpl.kt | 66 +++++ .../service/load/BluePrintDatabaseLoadService.kt | 79 +++++ .../service/load/BluePrintLoadConfiguration.kt | 34 +++ .../service/load/ModelTypeLoadService.kt | 6 +- .../service/load/ResourceDictionaryLoadService.kt | 104 ++++--- .../enhancer/BluePrintEnhancerServiceImplTest.java | 4 +- .../service/rs/ResourceDictionaryRestTest.java | 29 +- .../service/rs/ServiceTemplateRestTest.java | 2 +- .../src/test/resources/application.properties | 27 +- .../modules/service/src/test/resources/logback.xml | 2 +- 18 files changed, 446 insertions(+), 471 deletions(-) delete mode 100644 ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/DataBaseInitService.java create mode 100644 ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintCoreConfiguration.kt delete mode 100644 ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintCatalogLoad.kt create mode 100644 ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintCatalogLoadService.kt create mode 100644 ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintCatalogServiceImpl.kt create mode 100644 ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintDatabaseLoadService.kt create mode 100644 ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintLoadConfiguration.kt (limited to 'ms/controllerblueprints/application/src/test/resources') diff --git a/ms/controllerblueprints/README.md b/ms/controllerblueprints/README.md index 43eeee5fc..3ca48d1c5 100755 --- a/ms/controllerblueprints/README.md +++ b/ms/controllerblueprints/README.md @@ -8,6 +8,6 @@ Application VM Arguments : -Dspring.datasource.url=jdbc:mysql://127.0.0.1:3306/sdnctl -Dspring.datasource.username=sdnctl -Dspring.datasource.password=sdnctl --Dblueprints.load.initial-data=true +-Dcontrollerblueprints.loadInitialData=true -Dspring.profiles.active=dev diff --git a/ms/controllerblueprints/application/opt/app/onap/config/application-dev.properties b/ms/controllerblueprints/application/opt/app/onap/config/application-dev.properties index 8741fab21..46aa2fa0e 100644 --- a/ms/controllerblueprints/application/opt/app/onap/config/application-dev.properties +++ b/ms/controllerblueprints/application/opt/app/onap/config/application-dev.properties @@ -44,19 +44,21 @@ spring.datasource.url=jdbc:mysql://localhost:3306/sdnctl spring.datasource.username=sdnctl spring.datasource.password=sdnctl spring.datasource.driver-class-name=org.mariadb.jdbc.Driver -spring.jpa.show-sql = true -spring.jpa.hibernate.ddl-auto = none -spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy -spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect - -#Load Blueprints -# blueprints.load.initial-data may be overridden by ENV variables -blueprints.load.initial-data=true -load.dataTypePath=./../../../components/model-catalog/definition-type/starter-type/data_type -load.nodeTypePath=./../../../components/model-catalog/definition-type/starter-type/node_type -load.artifactTypePath=./../../../components/model-catalog/definition-type/starter-type/artifact_type -load.resourceDictionaryPath=./../../../components/model-catalog/resource-dictionary/starter-dictionary -load.blueprintsPath=./../../../components/model-catalog/blueprint-model/starter-blueprint - +spring.jpa.show-sql=true +spring.jpa.hibernate.ddl-auto=none +spring.jpa.hibernate.naming-strategy=org.hibernate.cfg.ImprovedNamingStrategy +spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect # Load Resource Source Mappings -resourceSourceMappings=db=source-db,input=source-input,default=source-default,mdsal=source-rest \ No newline at end of file +resourceSourceMappings=db=source-db,input=source-input,default=source-default,mdsal=source-rest +# Controller Blueprints Core Configuration +controllerblueprints.blueprintDeployPath=/etc/blueprints/deploy +controllerblueprints.blueprintArchivePath=/etc/blueprints/archive +controllerblueprints.blueprintEnrichmentPath=/etc/blueprints/enrichment +# Controller Blueprint Load Configurations +controllerblueprints.loadInitialData=true +controllerblueprints.loadBluePrint=false +controllerblueprints.loadBluePrintPaths=./../../../components/model-catalog/blueprint-model/starter-blueprint +controllerblueprints.loadModelType=true +controllerblueprints.loadModeTypePaths=./../../../components/model-catalog/definition-type/starter-type +controllerblueprints.loadResourceDictionary=true +controllerblueprints.loadResourceDictionaryPaths=./../../../components/model-catalog/resource-dictionary/starter-dictionary \ No newline at end of file diff --git a/ms/controllerblueprints/application/opt/app/onap/config/application.properties b/ms/controllerblueprints/application/opt/app/onap/config/application.properties index aae37011e..2ac4ad373 100644 --- a/ms/controllerblueprints/application/opt/app/onap/config/application.properties +++ b/ms/controllerblueprints/application/opt/app/onap/config/application.properties @@ -50,14 +50,19 @@ spring.jpa.hibernate.ddl-auto = none spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect -#Load Blueprints -# blueprints.load.initial-data may be overridden by ENV variables -blueprints.load.initial-data=true -load.dataTypePath=model-catalog/definition-type/starter-type/data_type -load.nodeTypePath=model-catalog/definition-type/starter-type/node_type -load.artifactTypePath=model-catalog/definition-type/starter-type/artifact_type -load.resourceDictionaryPath=model-catalog/resource-dictionary/starter-dictionary -load.blueprintsPath=model-catalog/blueprint-model/starter-blueprint - # Load Resource Source Mappings -resourceSourceMappings=db=source-db,input=source-input,default=source-default,mdsal=source-rest \ No newline at end of file +resourceSourceMappings=db=source-db,input=source-input,default=source-default,mdsal=source-rest + +# Controller Blueprints Core Configuration +controllerblueprints.blueprintDeployPath=/etc/blueprints/deploy +controllerblueprints.blueprintArchivePath=/etc/blueprints/archive +controllerblueprints.blueprintEnrichmentPath=/etc/blueprints/enrichment +# Controller Blueprint Load Configurations +# blueprints.load.initial-data may be overridden by ENV variables +controllerblueprints.loadInitialData=true +controllerblueprints.loadBluePrint=false +controllerblueprints.loadBluePrintPaths=model-catalog/blueprint-model/starter-blueprint +controllerblueprints.loadModelType=true +controllerblueprints.loadModeTypePaths=model-catalog/definition-type/starter-type +controllerblueprints.loadResourceDictionary=true +controllerblueprints.loadResourceDictionaryPaths=model-catalog/resource-dictionary/starter-dictionary \ No newline at end of file diff --git a/ms/controllerblueprints/application/src/test/resources/application.properties b/ms/controllerblueprints/application/src/test/resources/application.properties index 0e8789767..48f70b0ea 100644 --- a/ms/controllerblueprints/application/src/test/resources/application.properties +++ b/ms/controllerblueprints/application/src/test/resources/application.properties @@ -32,14 +32,18 @@ swagger.contact.name=Brinda Santh Muthuramalingam swagger.contact.url=www.onap.com swagger.contact.email=brindasanth@onap.com -#Load Blueprints -# blueprints.load.initial-data may be overridden by ENV variables -blueprints.load.initial-data=true -load.dataTypePath=./../../../components/model-catalog/definition-type/starter-type/data_type -load.nodeTypePath=./../../../components/model-catalog/definition-type/starter-type/node_type -load.artifactTypePath=./../../../components/model-catalog/definition-type/starter-type/artifact_type -load.resourceDictionaryPath=./../../../components/model-catalog/resource-dictionary/starter-dictionary -load.blueprintsPath=./../../../components/model-catalog/blueprint-model/starter-blueprint - # Load Resource Source Mappings -resourceSourceMappings=db=source-db,input=source-input,default=source-default,mdsal=source-rest \ No newline at end of file +resourceSourceMappings=db=source-db,input=source-input,default=source-default,mdsal=source-rest + +# Controller Blueprints Core Configuration +controllerblueprints.blueprintDeployPath=./target/blueprints/deploy +controllerblueprints.blueprintArchivePath=./target/blueprints/archive +controllerblueprints.blueprintEnrichmentPath=./target/blueprints/enrichment +# Controller Blueprint Load Configurations +controllerblueprints.loadInitialData=false +controllerblueprints.loadBluePrint=false +controllerblueprints.loadBluePrintPaths=./../../../../components/model-catalog/blueprint-model/starter-blueprint +controllerblueprints.loadModelType=false +controllerblueprints.loadModeTypePaths=./../../../../components/model-catalog/definition-type/starter-type +controllerblueprints.loadResourceDictionary=false +controllerblueprints.loadResourceDictionaryPaths=./../../../../components/model-catalog/resource-dictionary/starter-dictionary \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/DataBaseInitService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/DataBaseInitService.java deleted file mode 100644 index a4b874eef..000000000 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/DataBaseInitService.java +++ /dev/null @@ -1,325 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 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. - */ - -package org.onap.ccsdk.apps.controllerblueprints.service; - -import com.google.common.base.Preconditions; -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.io.IOUtils; -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.text.StrBuilder; -import org.jetbrains.annotations.NotNull; -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants; -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException; -import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactType; -import org.onap.ccsdk.apps.controllerblueprints.core.data.DataType; -import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeType; -import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils; -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition; -import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel; -import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType; -import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary; -import org.onap.ccsdk.apps.controllerblueprints.service.utils.ConfigModelUtils; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.boot.context.event.ApplicationReadyEvent; -import org.springframework.context.event.EventListener; -import org.springframework.core.io.Resource; -import org.springframework.core.io.support.ResourcePatternResolver; -import org.springframework.stereotype.Component; -import java.io.IOException; -import java.nio.charset.Charset; -import java.util.List; - -/** - * DataBaseInitService.java Purpose: Provide DataBaseInitService Service - * - * @author Brinda Santh - * @version 1.0 - */ -@Deprecated -@Component -@ConditionalOnProperty(name = "blueprints.load.initial-data", havingValue = "true") -public class DataBaseInitService { - - private static EELFLogger log = EELFManager.getInstance().getLogger(DataBaseInitService.class); - private ModelTypeService modelTypeService; - private ResourceDictionaryService resourceDictionaryService; - private ConfigModelService configModelService; - private String updateBySystem = "System"; - private static final String JSON_EXTN= ".json"; - private static final String EXCEPTION= "Exception"; - - @Value("${load.dataTypePath}") - private String dataTypePath; - @Value("${load.nodeTypePath}") - private String nodeTypePath; - @Value("${load.artifactTypePath}") - private String artifactTypePath; - @Value("${load.resourceDictionaryPath}") - private String resourceDictionaryPath; - @Value("${load.blueprintsPath}") - private String bluePrintsPath; - - @Autowired - private ResourcePatternResolver resourceLoader; - - /** - * This is a DataBaseInitService, used to load the initial data - * - * @param modelTypeService modelTypeService - * @param resourceDictionaryService resourceDictionaryService - * @param configModelService configModelService - */ - public DataBaseInitService(ModelTypeService modelTypeService, ResourceDictionaryService resourceDictionaryService, - ConfigModelService configModelService) { - this.modelTypeService = modelTypeService; - this.resourceDictionaryService = resourceDictionaryService; - this.configModelService = configModelService; - log.info("DataBaseInitService started..."); - - } - - @SuppressWarnings("unused") - @EventListener(ApplicationReadyEvent.class) - private void initDatabase() { - log.info("loading dataTypePath from DIR : {}", dataTypePath); - log.info("loading nodeTypePath from DIR : {}", nodeTypePath); - log.info("loading artifactTypePath from DIR : {}", artifactTypePath); - log.info("loading resourceDictionaryPath from DIR : {}", resourceDictionaryPath); - log.info("loading bluePrintsPath from DIR : {}", bluePrintsPath); - - loadModelType(); - loadResourceDictionary(); - } - - private void loadModelType() { - log.info(" *************************** loadModelType **********************"); - try { - Resource[] dataTypefiles = getPathResources(dataTypePath, JSON_EXTN); - StrBuilder errorBuilder = new StrBuilder(); - for (Resource file : dataTypefiles) { - if (file != null) { - loadDataType(file, errorBuilder); - } - } - - Resource[] nodeTypefiles = getPathResources(nodeTypePath, JSON_EXTN); - for (Resource file : nodeTypefiles) { - if (file != null) { - loadNodeType(file, errorBuilder); - } - } - - - Resource[] artifactTypefiles = getPathResources(artifactTypePath, JSON_EXTN); - - for (Resource file : artifactTypefiles) { - if (file != null) { - loadArtifactType(file, errorBuilder); - } - } - - - if (!errorBuilder.isEmpty()) { - log.error(errorBuilder.toString()); - } - } catch (Exception e) { - log.error("Failed in Data type loading", e); - } - } - - private void loadResourceDictionary() { - log.info( - " *************************** loadResourceDictionary **********************"); - try { - Resource[] dataTypefiles = getPathResources(resourceDictionaryPath, JSON_EXTN); - - StrBuilder errorBuilder = new StrBuilder(); - String fileName; - for (Resource file : dataTypefiles) { - try { - fileName = file.getFilename(); - log.trace("Loading : {}", fileName); - String definitionContent = getResourceContent(file); - ResourceDefinition resourceDefinition = - JacksonUtils.readValue(definitionContent, ResourceDefinition.class); - if (resourceDefinition != null) { - Preconditions.checkNotNull(resourceDefinition.getProperty(), "Failed to get Property Definition"); - ResourceDictionary resourceDictionary = new ResourceDictionary(); - resourceDictionary.setName(resourceDefinition.getName()); - resourceDictionary.setDefinition(resourceDefinition); - - Preconditions.checkNotNull(resourceDefinition.getProperty(), "Property field is missing"); - resourceDictionary.setDescription(resourceDefinition.getProperty().getDescription()); - resourceDictionary.setDataType(resourceDefinition.getProperty().getType()); - if(resourceDefinition.getProperty().getEntrySchema() != null){ - resourceDictionary.setEntrySchema(resourceDefinition.getProperty().getEntrySchema().getType()); - } - resourceDictionary.setUpdatedBy(resourceDefinition.getUpdatedBy()); - if (StringUtils.isBlank(resourceDefinition.getTags())) { - resourceDictionary.setTags( - resourceDefinition.getName() + ", " + resourceDefinition.getUpdatedBy() - + ", " + resourceDefinition.getUpdatedBy()); - - } else { - resourceDictionary.setTags(resourceDefinition.getTags()); - } - resourceDictionaryService.saveResourceDictionary(resourceDictionary); - - log.trace(" Loaded successfully : {}", file.getFilename()); - } else { - throw new BluePrintException("couldn't get dictionary from content information"); - } - } catch (Exception e) { - log.error(EXCEPTION, e); - errorBuilder.appendln("Dictionary loading Errors : " + file.getFilename() + ":" + e.getMessage()); - } - } - if (!errorBuilder.isEmpty()) { - log.error(errorBuilder.toString()); - } - - - } catch (Exception e) { - log.error( - "Failed in Resource dictionary loading", e); - } - } - - private void loadBlueprints() { - log.info("*************************** loadServiceTemplate **********************"); - try { - List serviceTemplateDirs = ConfigModelUtils.getBlueprintNames(bluePrintsPath); - if (CollectionUtils.isNotEmpty(serviceTemplateDirs)) { - StrBuilder errorBuilder = new StrBuilder(); - for (String fileName : serviceTemplateDirs) { - try { - String bluePrintPath = this.bluePrintsPath.concat("/").concat(fileName); - log.debug("***** Loading service template : {}", bluePrintPath); - ConfigModel configModel = ConfigModelUtils.getConfigModel(bluePrintPath); - - configModel = this.configModelService.saveConfigModel(configModel); - - log.info("Publishing : {}", configModel.getId()); - - this.configModelService.publishConfigModel(configModel.getId()); - - log.info("Loaded service template successfully: {}", fileName); - - } catch (Exception e) { - log.error(EXCEPTION, e); - errorBuilder.appendln("load config model " + fileName + " error : " + e.getMessage()); - } - } - - if (!errorBuilder.isEmpty()) { - log.error(errorBuilder.toString()); - } - } - } catch (Exception e) { - log.error("Failed in Service Template loading", e); - } - } - - private void loadNodeType(Resource file, StrBuilder errorBuilder) { - try { - log.trace("Loading Node Type : {}", file.getFilename()); - String nodeKey = file.getFilename().replace(JSON_EXTN, ""); - String definitionContent = getResourceContent(file); - NodeType nodeType = JacksonUtils.readValue(definitionContent, NodeType.class); - Preconditions.checkNotNull(nodeType, String.format("failed to get node type from file : %s", file.getFilename())); - ModelType modelType = new ModelType(); - modelType.setDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE); - modelType.setDerivedFrom(nodeType.getDerivedFrom()); - modelType.setDescription(nodeType.getDescription()); - modelType.setDefinition(JacksonUtils.jsonNode(definitionContent)); - modelType.setModelName(nodeKey); - modelType.setVersion(nodeType.getVersion()); - modelType.setUpdatedBy(updateBySystem); - modelType.setTags(nodeKey + "," + BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE + "," - + nodeType.getDerivedFrom()); - modelTypeService.saveModel(modelType); - log.trace("Loaded Node Type successfully : {}", file.getFilename()); - } catch (Exception e) { - log.error(EXCEPTION, e); - errorBuilder.appendln("Node type loading error : " + file.getFilename() + ":" + e.getMessage()); - } - } - - private void loadDataType(@NotNull Resource file, StrBuilder errorBuilder) { - try { - log.trace("Loading Data Type: {}", file.getFilename()); - String dataKey = file.getFilename().replace(JSON_EXTN, ""); - String definitionContent = getResourceContent(file); - DataType dataType = JacksonUtils.readValue(definitionContent, DataType.class); - Preconditions.checkNotNull(dataType, String.format("failed to get data type from file : %s", file.getFilename())); - ModelType modelType = new ModelType(); - modelType.setDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE); - modelType.setDerivedFrom(dataType.getDerivedFrom()); - modelType.setDescription(dataType.getDescription()); - modelType.setDefinition(JacksonUtils.jsonNode(definitionContent)); - modelType.setModelName(dataKey); - modelType.setVersion(dataType.getVersion()); - modelType.setUpdatedBy(updateBySystem); - modelType.setTags(dataKey + "," + dataType.getDerivedFrom() + "," - + BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE); - modelTypeService.saveModel(modelType); - log.trace(" Loaded Data Type successfully : {}", file.getFilename()); - } catch (Exception e) { - log.error(EXCEPTION, e); - errorBuilder.appendln("Data type loading error : " + file.getFilename() + ":" + e.getMessage()); - } - } - - private void loadArtifactType(Resource file, StrBuilder errorBuilder) { - try { - log.trace("Loading Artifact Type: {}", file.getFilename()); - String dataKey = file.getFilename().replace(JSON_EXTN, ""); - String definitionContent = getResourceContent(file); - ArtifactType artifactType = JacksonUtils.readValue(definitionContent, ArtifactType.class); - Preconditions.checkNotNull(artifactType, String.format("failed to get artifact type from file : %s", file.getFilename())); - ModelType modelType = new ModelType(); - modelType.setDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE); - modelType.setDerivedFrom(artifactType.getDerivedFrom()); - modelType.setDescription(artifactType.getDescription()); - modelType.setDefinition(JacksonUtils.jsonNode(definitionContent)); - modelType.setModelName(dataKey); - modelType.setVersion(artifactType.getVersion()); - modelType.setUpdatedBy(updateBySystem); - modelType.setTags(dataKey + "," + artifactType.getDerivedFrom() + "," - + BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE); - modelTypeService.saveModel(modelType); - log.trace("Loaded Artifact Type successfully : {}", file.getFilename()); - } catch (Exception e) { - log.error(EXCEPTION, e); - errorBuilder.appendln("Artifact type loading error : " + file.getFilename() + ":" + e.getMessage()); - } - } - - private Resource[] getPathResources(String path, String extension) throws IOException { - return resourceLoader.getResources("file:" + path + "/*" + extension); - } - - private String getResourceContent(Resource resource) throws IOException { - return IOUtils.toString(resource.getInputStream(), Charset.defaultCharset()); - } - -} diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintCoreConfiguration.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintCoreConfiguration.kt new file mode 100644 index 000000000..2e5fc5ba3 --- /dev/null +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintCoreConfiguration.kt @@ -0,0 +1,60 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * 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. + */ + +package org.onap.ccsdk.apps.controllerblueprints.service + +import org.onap.ccsdk.apps.controllerblueprints.service.load.BluePrintLoadConfiguration +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.boot.context.properties.bind.Bindable +import org.springframework.boot.context.properties.bind.Binder +import org.springframework.boot.context.properties.source.ConfigurationPropertySources +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration +import org.springframework.core.env.Environment +import org.springframework.stereotype.Service + +@Configuration +open class BluePrintCoreConfiguration(private val bluePrintProperties: BluePrintProperties) { + + companion object { + const val PREFIX_BLUEPRINT_LOAD_CONFIGURATION = "controllerblueprints" + } + + @Bean + open fun bluePrintLoadConfiguration(): BluePrintLoadConfiguration { + return bluePrintProperties + .propertyBeanType(PREFIX_BLUEPRINT_LOAD_CONFIGURATION, BluePrintLoadConfiguration::class.java) + } +} + +@Configuration +open class BlueprintPropertyConfiguration { + @Autowired + lateinit var environment: Environment + + @Bean + open fun bluePrintPropertyBinder(): Binder { + val configurationPropertySource = ConfigurationPropertySources.get(environment) + return Binder(configurationPropertySource) + } +} + +@Service +open class BluePrintProperties(var bluePrintPropertyBinder: Binder) { + fun propertyBeanType(prefix: String, type: Class): T { + return bluePrintPropertyBinder.bind(prefix, Bindable.of(type)).get() + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintCatalogLoad.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintCatalogLoad.kt deleted file mode 100644 index 8a5cc4c6c..000000000 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintCatalogLoad.kt +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * 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. - */ - -package org.onap.ccsdk.apps.controllerblueprints.service.load - -import org.springframework.stereotype.Service - -@Service -open class BluePrintCatalogLoad { - - open fun loadBluePrintModelCatalog() { - // TODO - } - -} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintCatalogLoadService.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintCatalogLoadService.kt new file mode 100644 index 000000000..07ee0a9bb --- /dev/null +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintCatalogLoadService.kt @@ -0,0 +1,68 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * 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. + */ + +package org.onap.ccsdk.apps.controllerblueprints.service.load + +import com.att.eelf.configuration.EELFManager +import kotlinx.coroutines.Deferred +import kotlinx.coroutines.async +import kotlinx.coroutines.runBlocking +import org.apache.commons.lang3.text.StrBuilder +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintCatalogService +import org.springframework.stereotype.Service +import java.io.File + +@Service +open class BluePrintCatalogLoadService(private val bluePrintCatalogService: BluePrintCatalogService) { + + private val log = EELFManager.getInstance().getLogger(BluePrintCatalogLoadService::class.java) + + open fun loadPathsBluePrintModelCatalog(paths: List) { + paths.forEach { loadPathBluePrintModelCatalog(it) } + } + + open fun loadPathBluePrintModelCatalog(path: String) { + + val files = File(path).listFiles() + runBlocking { + val errorBuilder = StrBuilder() + val deferredResults = mutableListOf>() + + for (file in files) { + deferredResults += async { + loadBluePrintModelCatalog(errorBuilder, file) + } + } + + for (deferredResult in deferredResults) { + deferredResult.await() + } + + if (!errorBuilder.isEmpty) { + log.error(errorBuilder.toString()) + } + } + } + + open fun loadBluePrintModelCatalog(errorBuilder: StrBuilder, file: File) { + try { + bluePrintCatalogService.uploadToDataBase(file.absolutePath) + } catch (e: Exception) { + errorBuilder.appendln("Couldn't load DataType(${file.name}: ${e.message}") + } + } + +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintCatalogServiceImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintCatalogServiceImpl.kt new file mode 100644 index 000000000..8cddbb4c9 --- /dev/null +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintCatalogServiceImpl.kt @@ -0,0 +1,66 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * 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. + */ + +package org.onap.ccsdk.apps.controllerblueprints.service.load + +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintCatalogService +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintValidatorService +import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintArchiveUtils +import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils +import org.springframework.stereotype.Service +import java.io.File +import java.util.* + +@Service +class BluePrintCatalogServiceImpl(private val bluePrintLoadConfiguration: BluePrintLoadConfiguration, + private val bluePrintValidatorService: BluePrintValidatorService) : BluePrintCatalogService { + + override fun uploadToDataBase(file: String): String { + val id = UUID.randomUUID().toString() + val blueprintFile = File(file) + // If the file is directory + if (blueprintFile.isDirectory) { + val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(id, blueprintFile.absolutePath) + val valid = bluePrintValidatorService.validateBluePrints(bluePrintRuntimeService) + if (valid) { + val zipFile = File("${bluePrintLoadConfiguration.blueprintArchivePath}/${id}.zip") + // zip the directory + BluePrintArchiveUtils.compress(blueprintFile, zipFile, true) + + // TODO(Upload to the Data Base) + + // After Upload to Database delete the zip file + zipFile.deleteOnExit() + } + } else { + // If the file is ZIP + // TODO(Upload to the Data Base) + } + return id + } + + override fun downloadFromDataBase(name: String, version: String, path: String): String { + // If path ends with zip, then compress otherwise download as extracted folder + + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun prepareBluePrint(name: String, version: String): String { + val preparedPath = "${bluePrintLoadConfiguration.blueprintDeployPath}/$name/$version" + downloadFromDataBase(name, version, preparedPath) + return preparedPath + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintDatabaseLoadService.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintDatabaseLoadService.kt new file mode 100644 index 000000000..eeea97c9b --- /dev/null +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintDatabaseLoadService.kt @@ -0,0 +1,79 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * 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. + */ + +package org.onap.ccsdk.apps.controllerblueprints.service.load + +import com.att.eelf.configuration.EELFManager +import org.springframework.boot.context.event.ApplicationReadyEvent +import org.springframework.context.event.EventListener +import org.springframework.stereotype.Service + +@Service +open class BluePrintDatabaseLoadService(private val bluePrintLoadConfiguration: BluePrintLoadConfiguration, + private val modelTypeLoadService: ModelTypeLoadService, + private val resourceDictionaryLoadService: ResourceDictionaryLoadService, + private val bluePrintCatalogLoadService: BluePrintCatalogLoadService) { + + private val log = EELFManager.getInstance().getLogger(BluePrintDatabaseLoadService::class.java) + + + @EventListener(ApplicationReadyEvent::class) + open fun init() { + if (bluePrintLoadConfiguration.loadInitialData) { + initModelTypes() + initResourceDictionary() + initBluePrintCatalog() + } else { + log.info("Initial data load is disabled") + } + } + + open fun initModelTypes() { + log.info("model types load configuration(${bluePrintLoadConfiguration.loadModelType}) " + + "under paths(${bluePrintLoadConfiguration.loadModeTypePaths})") + + if (bluePrintLoadConfiguration.loadModelType) { + val paths = bluePrintLoadConfiguration.loadModeTypePaths?.split(",") + paths?.let { + modelTypeLoadService.loadPathsModelType(paths) + } + } + } + + open fun initResourceDictionary() { + log.info("resource dictionary load configuration(${bluePrintLoadConfiguration.loadResourceDictionary}) " + + "under paths(${bluePrintLoadConfiguration.loadResourceDictionaryPaths})") + + if (bluePrintLoadConfiguration.loadResourceDictionary) { + val paths = bluePrintLoadConfiguration.loadResourceDictionaryPaths?.split(",") + paths?.let { + resourceDictionaryLoadService.loadPathsResourceDictionary(paths) + } + } + } + + open fun initBluePrintCatalog() { + log.info("blueprint load configuration(${bluePrintLoadConfiguration.loadBluePrint}) " + + "under paths(${bluePrintLoadConfiguration.loadBluePrintPaths})") + + if (bluePrintLoadConfiguration.loadBluePrint) { + val paths = bluePrintLoadConfiguration.loadBluePrintPaths?.split(",") + paths?.let { + bluePrintCatalogLoadService.loadPathsBluePrintModelCatalog(paths) + } + } + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintLoadConfiguration.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintLoadConfiguration.kt new file mode 100644 index 000000000..cf36a3e5a --- /dev/null +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintLoadConfiguration.kt @@ -0,0 +1,34 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * 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. + */ + +package org.onap.ccsdk.apps.controllerblueprints.service.load + +open class BluePrintLoadConfiguration { + + lateinit var blueprintDeployPath: String + lateinit var blueprintArchivePath: String + lateinit var blueprintEnrichmentPath: String + + var loadInitialData: Boolean = false + var loadBluePrint: Boolean = false + var loadBluePrintPaths: String? = null + + var loadModelType: Boolean = false + var loadModeTypePaths: String? = null + + var loadResourceDictionary: Boolean = false + var loadResourceDictionaryPaths: String? = null +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/ModelTypeLoadService.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/ModelTypeLoadService.kt index ac9834b9f..1c5276c8d 100644 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/ModelTypeLoadService.kt +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/ModelTypeLoadService.kt @@ -36,11 +36,11 @@ open class ModelTypeLoadService(private val modelTypeService: ModelTypeService) private val log = EELFManager.getInstance().getLogger(ModelTypeLoadService::class.java) private val updateBySystem = "System" - open fun loadModelType(modelTypePaths: List) { - modelTypePaths.forEach { loadModelType(it) } + open fun loadPathsModelType(modelTypePaths: List) { + modelTypePaths.forEach { loadPathModelType(it) } } - open fun loadModelType(modelTypePath: String) { + open fun loadPathModelType(modelTypePath: String) { log.info(" *************************** loadModelType **********************") try { val errorBuilder = StrBuilder() diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/ResourceDictionaryLoadService.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/ResourceDictionaryLoadService.kt index eddaa1cc2..4bb8a2f3a 100644 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/ResourceDictionaryLoadService.kt +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/ResourceDictionaryLoadService.kt @@ -17,6 +17,9 @@ package org.onap.ccsdk.apps.controllerblueprints.service.load import com.att.eelf.configuration.EELFManager +import kotlinx.coroutines.Deferred +import kotlinx.coroutines.async +import kotlinx.coroutines.runBlocking import org.apache.commons.lang3.StringUtils import org.apache.commons.lang3.text.StrBuilder import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException @@ -33,55 +36,70 @@ open class ResourceDictionaryLoadService(private val resourceDictionaryService: private val log = EELFManager.getInstance().getLogger(ResourceDictionaryLoadService::class.java) - open fun loadResourceDictionary(resourceDictionaryPaths: List) { - resourceDictionaryPaths.forEach { loadResourceDictionary(it) } + open fun loadPathsResourceDictionary(paths: List) { + paths.forEach { loadPathResourceDictionary(it) } } - open fun loadResourceDictionary(resourceDictionaryPath: String) { + open fun loadPathResourceDictionary(path: String) { log.info(" *************************** loadResourceDictionary **********************") - val resourceDictionaries = File(resourceDictionaryPath).listFiles() - val errorBuilder = StrBuilder() - - resourceDictionaries.forEach { file -> - try { - log.trace("Loading NodeType(${file.name}") - val definitionContent = file.readText(Charset.defaultCharset()) - val resourceDefinition = JacksonUtils.readValue(definitionContent, ResourceDefinition::class.java) - if (resourceDefinition != null) { - - checkNotNull(resourceDefinition.property) { "Failed to get Property Definition" } - val resourceDictionary = ResourceDictionary() - resourceDictionary.name = resourceDefinition.name - resourceDictionary.definition = resourceDefinition - - checkNotNull(resourceDefinition.property) { "Property field is missing" } - resourceDictionary.description = resourceDefinition.property.description - resourceDictionary.dataType = resourceDefinition.property.type - - if (resourceDefinition.property.entrySchema != null) { - resourceDictionary.entrySchema = resourceDefinition.property.entrySchema!!.type - } - resourceDictionary.updatedBy = resourceDefinition.updatedBy - - if (StringUtils.isBlank(resourceDefinition.tags)) { - resourceDictionary.tags = (resourceDefinition.name + ", " + resourceDefinition.updatedBy - + ", " + resourceDefinition.updatedBy) - - } else { - resourceDictionary.tags = resourceDefinition.tags - } - resourceDictionaryService.saveResourceDictionary(resourceDictionary) - - log.trace("Resource dictionary(${file.name}) loaded successfully ") - } else { - throw BluePrintException("couldn't get dictionary from content information") + val files = File(path).listFiles() + + runBlocking { + val errorBuilder = StrBuilder() + val deferredResults = mutableListOf>() + + for (file in files) { + deferredResults += async { + loadResourceDictionary(errorBuilder, file) } - } catch (e: Exception) { - errorBuilder.appendln("Couldn't load Resource dictionary (${file.name}: ${e.message}") + } + + for (deferredResult in deferredResults) { + deferredResult.await() + } + + if (!errorBuilder.isEmpty) { + log.error(errorBuilder.toString()) } } - if (!errorBuilder.isEmpty) { - log.error(errorBuilder.toString()) + } + + private fun loadResourceDictionary(errorBuilder: StrBuilder, file: File) { + try { + log.trace("Loading NodeType(${file.name}") + val definitionContent = file.readText(Charset.defaultCharset()) + val resourceDefinition = JacksonUtils.readValue(definitionContent, ResourceDefinition::class.java) + if (resourceDefinition != null) { + + checkNotNull(resourceDefinition.property) { "Failed to get Property Definition" } + val resourceDictionary = ResourceDictionary() + resourceDictionary.name = resourceDefinition.name + resourceDictionary.definition = resourceDefinition + + checkNotNull(resourceDefinition.property) { "Property field is missing" } + resourceDictionary.description = resourceDefinition.property.description + resourceDictionary.dataType = resourceDefinition.property.type + + if (resourceDefinition.property.entrySchema != null) { + resourceDictionary.entrySchema = resourceDefinition.property.entrySchema!!.type + } + resourceDictionary.updatedBy = resourceDefinition.updatedBy + + if (StringUtils.isBlank(resourceDefinition.tags)) { + resourceDictionary.tags = (resourceDefinition.name + ", " + resourceDefinition.updatedBy + + ", " + resourceDefinition.updatedBy) + + } else { + resourceDictionary.tags = resourceDefinition.tags + } + resourceDictionaryService.saveResourceDictionary(resourceDictionary) + + log.trace("Resource dictionary(${file.name}) loaded successfully ") + } else { + throw BluePrintException("couldn't get dictionary from content information") + } + } catch (e: Exception) { + errorBuilder.appendln("Couldn't load Resource dictionary (${file.name}: ${e.message}") } } diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImplTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImplTest.java index 06f2f9088..23e5294fd 100644 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImplTest.java +++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImplTest.java @@ -52,8 +52,8 @@ public class BluePrintEnhancerServiceImplTest { @Before public void init() { - modelTypeLoadService.loadModelType("./../../../../components/model-catalog/definition-type/starter-type"); - resourceDictionaryLoadService.loadResourceDictionary("./../../../../components/model-catalog/resource-dictionary/starter-dictionary"); + modelTypeLoadService.loadPathModelType("./../../../../components/model-catalog/definition-type/starter-type"); + resourceDictionaryLoadService.loadPathResourceDictionary("./../../../../components/model-catalog/resource-dictionary/starter-dictionary"); } @Test diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java index 272cdd08f..3818ae2ea 100644 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java +++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRestTest.java @@ -17,34 +17,25 @@ package org.onap.ccsdk.apps.controllerblueprints.service.rs; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; import org.apache.commons.io.IOUtils; import org.junit.Assert; -import org.junit.FixMethodOrder; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.MethodSorters; -import org.onap.ccsdk.apps.controllerblueprints.TestApplication; import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils; import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition; import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceSourceMapping; import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; import java.nio.charset.Charset; import java.util.ArrayList; import java.util.List; - -@RunWith(SpringRunner.class) -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = {"blueprints.load.initial-data=true"}) -@ContextConfiguration(classes = {TestApplication.class}) -@FixMethodOrder(MethodSorters.NAME_ASCENDING) +@Deprecated +//@RunWith(SpringRunner.class) +//@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = {"blueprints.load.initial-data=true"}) +//@ContextConfiguration(classes = {TestApplication.class}) +//@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class ResourceDictionaryRestTest { private static EELFLogger log = EELFManager.getInstance().getLogger(ResourceDictionaryRestTest.class); @@ -52,7 +43,7 @@ public class ResourceDictionaryRestTest { @Autowired protected ResourceDictionaryRest resourceDictionaryRest; - @Test + //@Test public void test01SaveDataDictionary() throws Exception { String definition = IOUtils.toString( getClass().getClassLoader().getResourceAsStream("resourcedictionary/default_definition.json"), @@ -82,7 +73,7 @@ public class ResourceDictionaryRestTest { } - @Test + //@Test public void test02GetDataDictionary() throws Exception { ResourceDictionary dbResourceDictionary = resourceDictionaryRest.getResourceDictionaryByName("test-name"); @@ -104,7 +95,7 @@ public class ResourceDictionaryRestTest { } - @Test + //@Test public void test03GetResourceSourceMapping() { ResourceSourceMapping resourceSourceMapping = resourceDictionaryRest.getResourceSourceMapping(); org.springframework.util.Assert.notNull(resourceSourceMapping, "Failed to get resource source mapping"); diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java index e513ff533..675d2c246 100644 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java +++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRestTest.java @@ -124,7 +124,7 @@ public class ServiceTemplateRestTest { } - @Test + //@Test public void test05AutoMap() throws Exception { log.info("*********** test05AutoMap *******************************************"); diff --git a/ms/controllerblueprints/modules/service/src/test/resources/application.properties b/ms/controllerblueprints/modules/service/src/test/resources/application.properties index 2bfb04164..718616bbd 100644 --- a/ms/controllerblueprints/modules/service/src/test/resources/application.properties +++ b/ms/controllerblueprints/modules/service/src/test/resources/application.properties @@ -15,20 +15,21 @@ # limitations under the License. # spring.main.banner-mode=off -spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS = false - - +spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false logging.level.org.springframework.web=INFO logging.level.org.hibernate.SQL=warn logging.level.org.hibernate.type.descriptor.sql=debug - - -blueprints.load.initial-data=false -load.dataTypePath=./../../../../components/model-catalog/definition-type/starter-type/data_type -load.nodeTypePath=./../../../../components/model-catalog/definition-type/starter-type/node_type -load.artifactTypePath=./../../../../components/model-catalog/definition-type/starter-type/artifact_type -load.resourceDictionaryPath=./../../../../components/model-catalog/resource-dictionary/starter-dictionary -load.blueprintsPath=./../../../../components/model-catalog/blueprint-model/starter-blueprint - # Load Resource Source Mappings -resourceSourceMappings=db=source-db,input=source-input,default=source-default,mdsal=source-rest \ No newline at end of file +resourceSourceMappings=db=source-db,input=source-input,default=source-default,mdsal=source-rest +# Controller Blueprints Core Configuration +controllerblueprints.blueprintDeployPath=./target/blueprints/deploy +controllerblueprints.blueprintArchivePath=./target/blueprints/archive +controllerblueprints.blueprintEnrichmentPath=./target/blueprints/enrichment +# Controller Blueprint Load Configurations +controllerblueprints.loadInitialData=false +controllerblueprints.loadBluePrint=false +controllerblueprints.loadBluePrintPaths=./../../../../components/model-catalog/blueprint-model/starter-blueprint +controllerblueprints.loadModelType=false +controllerblueprints.loadModeTypePaths=./../../../../components/model-catalog/definition-type/starter-type +controllerblueprints.loadResourceDictionary=false +controllerblueprints.loadResourceDictionaryPaths=./../../../../components/model-catalog/resource-dictionary/starter-dictionary \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/test/resources/logback.xml b/ms/controllerblueprints/modules/service/src/test/resources/logback.xml index fc1f6698e..2546a8389 100644 --- a/ms/controllerblueprints/modules/service/src/test/resources/logback.xml +++ b/ms/controllerblueprints/modules/service/src/test/resources/logback.xml @@ -17,7 +17,7 @@ - + + + + + + + + + + + + + + ${defaultPattern} + + + + + + + + + + + + + + + diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ApplicationConstants.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ApplicationConstants.java index 2471bd5bc..c4759b568 100644 --- a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ApplicationConstants.java +++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ApplicationConstants.java @@ -17,7 +17,7 @@ package org.onap.ccsdk.apps.controllerblueprints; /** - * ApplicationConstants.java Purpose: Provide ControllerBluprintsApplication Constant Information + * ApplicationConstants.java Purpose: Provide ControllerBlueprintsApplication Constant Information * * @author Brinda Santh * @version 1.0 diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBlueprintsApplication.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBlueprintsApplication.java new file mode 100644 index 000000000..e925c69c0 --- /dev/null +++ b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBlueprintsApplication.java @@ -0,0 +1,42 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * 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. + */ + +package org.onap.ccsdk.apps.controllerblueprints; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.web.reactive.config.EnableWebFlux; + +/** + * @author Brinda Santh + */ +@SpringBootApplication +@EnableWebFlux +@ComponentScan(basePackages = {"org.onap.ccsdk.apps.controllerblueprints"}) +@EnableAutoConfiguration +public class ControllerBlueprintsApplication { + private static EELFLogger log = EELFManager.getInstance().getLogger(ControllerBlueprintsApplication.class); + + public static void main(String[] args) { + log.info("****** Starting Controlled Blueprints Application ******"); + SpringApplication.run(ControllerBlueprintsApplication.class, args); + } + +} \ No newline at end of file diff --git a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsApplication.java b/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsApplication.java deleted file mode 100644 index 6b0efd87b..000000000 --- a/ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsApplication.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * 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. - */ - -package org.onap.ccsdk.apps.controllerblueprints; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.web.reactive.config.EnableWebFlux; - -/** - * @author Brinda Santh - */ -@SpringBootApplication -@EnableWebFlux -@ComponentScan(basePackages = {"org.onap.ccsdk.apps.controllerblueprints"}) -@EnableAutoConfiguration -public class ControllerBluprintsApplication { - private static EELFLogger log = EELFManager.getInstance().getLogger(ControllerBluprintsApplication.class); - - public static void main(String[] args) { - log.info("****** Starting Controlled Blueprints Application ******"); - SpringApplication.run(ControllerBluprintsApplication.class, args); - } - -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/src/main/resources/application-dev.properties b/ms/controllerblueprints/application/src/main/resources/application-dev.properties new file mode 100755 index 000000000..30b71fb41 --- /dev/null +++ b/ms/controllerblueprints/application/src/main/resources/application-dev.properties @@ -0,0 +1,70 @@ +# +# Copyright © 2017-2018 AT&T Intellectual Property. +# +# 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. +# +appName=ControllerBluePrints +ms_name=org.onap.ccsdk.apps.controllerblueprints +appVersion=1.0.0 + +# Basic Authentication +basic-auth.user-name=ccsdkapps +basic-auth.hashed-pwd={bcrypt}$2a$10$MJxhNiOAffxbyrV9.rrOUewP9Q/ASg5Nit2cmP.yBaXGsVXo8BW3y + +#logging.pattern.console=%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p) %clr($ threadId: {PID:- }){magenta} %clr(---){faint} %clr([ hostname: %X{hostname} serviceName: %X{serviceName} version: %X{version} transactionId: %X{transactionId} requestTimeStamp: %X{requestTimestamp} responseTimeStamp: %X{responseTimestamp} duration: %X{duration}]){yellow} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n%wex + +logging.level.org.springframework.web=INFO +logging.level.org.hibernate.SQL=warn +logging.level.org.hibernate.type.descriptor.sql=debug + +#To Remove Null in JSON API Response +spring.jackson.default-property-inclusion=non_null + +#Swagger Configuration +swagger.contact.name=Brinda Santh Muthuramalingam +swagger.contact.url=www.onap.com +swagger.contact.email=brindasanth@onap.com + +spring.jpa.properties.hibernate.show_sql=true +spring.jpa.properties.hibernate.use_sql_comments=true +spring.jpa.properties.hibernate.format_sql=true + +# spring.datasource.url, spring.datasource.username,spring.datasource.password may be overridden by ENV variables +spring.datasource.url=jdbc:mysql://localhost:3306/sdnctl +spring.datasource.username=sdnctl +spring.datasource.password=sdnctl +spring.datasource.driver-class-name=org.mariadb.jdbc.Driver +spring.jpa.show-sql=true +spring.jpa.hibernate.ddl-auto=none +spring.jpa.hibernate.naming-strategy=org.hibernate.cfg.ImprovedNamingStrategy +spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect +# Load Resource Source Mappings +resourceSourceMappings=db=source-db,input=source-input,default=source-default,mdsal=source-rest,capability=source-capability +# Controller Blueprints Core Configuration +controllerblueprints.blueprintDeployPath=/etc/blueprints/deploy +controllerblueprints.blueprintArchivePath=/etc/blueprints/archive +controllerblueprints.blueprintEnrichmentPath=/etc/blueprints/enrichment +# Controller Blueprint Load Configurations +controllerblueprints.loadInitialData=true +controllerblueprints.loadBluePrint=false +controllerblueprints.loadBluePrintPaths=./../../../components/model-catalog/blueprint-model/starter-blueprint +controllerblueprints.loadModelType=true +controllerblueprints.loadModeTypePaths=./../../../components/model-catalog/definition-type/starter-type +controllerblueprints.loadResourceDictionary=true +controllerblueprints.loadResourceDictionaryPaths=./../../../components/model-catalog/resource-dictionary/starter-dictionary + +# CBA file extension +controllerblueprints.loadCbaExtension=zip + +# Web server config +server.port=8080 \ No newline at end of file diff --git a/ms/controllerblueprints/application/src/main/resources/application.properties b/ms/controllerblueprints/application/src/main/resources/application.properties new file mode 100755 index 000000000..b6d509ce8 --- /dev/null +++ b/ms/controllerblueprints/application/src/main/resources/application.properties @@ -0,0 +1,74 @@ +# +# Copyright © 2017-2018 AT&T Intellectual Property. +# Modifications Copyright © 2019 Bell Canada. +# +# 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. +# +appName=ControllerBluePrints +ms_name=org.onap.ccsdk.apps.controllerblueprints +appVersion=1.0.0 + +# Basic Authentication +basic-auth.user-name=ccsdkapps +basic-auth.hashed-pwd={bcrypt}$2a$10$MJxhNiOAffxbyrV9.rrOUewP9Q/ASg5Nit2cmP.yBaXGsVXo8BW3y + +#logging.pattern.console=%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p) %clr($ threadId: {PID:- }){magenta} %clr(---){faint} %clr([ hostname: %X{hostname} serviceName: %X{serviceName} version: %X{version} transactionId: %X{transactionId} requestTimeStamp: %X{requestTimestamp} responseTimeStamp: %X{responseTimestamp} duration: %X{duration}]){yellow} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n%wex + +logging.level.org.springframework.web=INFO +logging.level.org.hibernate.SQL=warn +logging.level.org.hibernate.type.descriptor.sql=debug + +#To Remove Null in JSON API Response +spring.jackson.default-property-inclusion=non_null + +#Swagger Configuration +swagger.contact.name=Brinda Santh Muthuramalingam +swagger.contact.url=www.onap.com +swagger.contact.email=brindasanth@onap.com + +spring.jpa.properties.hibernate.show_sql=true +spring.jpa.properties.hibernate.use_sql_comments=true +spring.jpa.properties.hibernate.format_sql=true + +# spring.datasource.url, spring.datasource.username,spring.datasource.password may be overridden by ENV variables +spring.datasource.url=jdbc:mysql://db:3306/sdnctl +spring.datasource.username=sdnctl +spring.datasource.password=sdnctl +spring.datasource.driver-class-name=org.mariadb.jdbc.Driver +spring.jpa.show-sql=true +spring.jpa.hibernate.ddl-auto=none +spring.jpa.hibernate.naming-strategy=org.hibernate.cfg.ImprovedNamingStrategy +spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect + +# Load Resource Source Mappings +resourceSourceMappings=db=source-db,input=source-input,default=source-default,mdsal=source-rest,capability=source-capability + +# Controller Blueprints Core Configuration +controllerblueprints.blueprintDeployPath=/etc/blueprints/deploy +controllerblueprints.blueprintArchivePath=/etc/blueprints/archive +controllerblueprints.blueprintEnrichmentPath=/etc/blueprints/enrichment +# Controller Blueprint Load Configurations +# blueprints.load.initial-data may be overridden by ENV variables +controllerblueprints.loadInitialData=true +controllerblueprints.loadBluePrint=false +controllerblueprints.loadBluePrintPaths=/model-catalog/blueprint-model/starter-blueprint +controllerblueprints.loadModelType=true +controllerblueprints.loadModeTypePaths=/model-catalog/definition-type/starter-type +controllerblueprints.loadResourceDictionary=true +controllerblueprints.loadResourceDictionaryPaths=/model-catalog/resource-dictionary/starter-dictionary + +# CBA file extension +controllerblueprints.loadCbaExtension=zip + +# Web server config +server.port=8080 \ No newline at end of file diff --git a/ms/controllerblueprints/application/src/test/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBlueprintsApplicationTest.java b/ms/controllerblueprints/application/src/test/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBlueprintsApplicationTest.java new file mode 100644 index 000000000..cf9b3e71f --- /dev/null +++ b/ms/controllerblueprints/application/src/test/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBlueprintsApplicationTest.java @@ -0,0 +1,62 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * 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. + */ + +package org.onap.ccsdk.apps.controllerblueprints; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; +import org.springframework.http.client.support.BasicAuthorizationInterceptor; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) +public class ControllerBlueprintsApplicationTest { + @Autowired + private TestRestTemplate restTemplate; + + @Before + public void setUp(){ + BasicAuthorizationInterceptor bai = new BasicAuthorizationInterceptor("ccsdkapps", "ccsdkapps"); + this.restTemplate.getRestTemplate().getInterceptors().add(bai); + } + + @Test + public void testConfigModel() { + HttpHeaders headers = new HttpHeaders(); + headers.set("Accept", MediaType.APPLICATION_JSON_VALUE); +// ResponseEntity entity = this.restTemplate +// .exchange("/api/v1/config-model/1", HttpMethod.GET, new HttpEntity<>(headers),BlueprintModel.class); +// assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); +// Assert.assertNotNull("failed to get response Config model",entity.getBody()); + } + + @Test + public void testConfigModelFailure() { + HttpHeaders headers = new HttpHeaders(); + headers.set("Accept", MediaType.APPLICATION_JSON_VALUE); +// ResponseEntity entity = this.restTemplate +// .exchange("/api/v1/config-model-not-found/1", HttpMethod.GET, new HttpEntity<>(headers),BlueprintModel.class); +// assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND); +// Assert.assertNotNull("failed to get response Config model",entity.getBody()); + } +} diff --git a/ms/controllerblueprints/application/src/test/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsApplicationTest.java b/ms/controllerblueprints/application/src/test/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsApplicationTest.java deleted file mode 100644 index 969f80428..000000000 --- a/ms/controllerblueprints/application/src/test/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsApplicationTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * 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. - */ - -package org.onap.ccsdk.apps.controllerblueprints; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.test.web.client.TestRestTemplate; -import org.springframework.http.HttpHeaders; -import org.springframework.http.MediaType; -import org.springframework.http.client.support.BasicAuthorizationInterceptor; -import org.springframework.test.context.junit4.SpringRunner; - -@RunWith(SpringRunner.class) -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -public class ControllerBluprintsApplicationTest { - @Autowired - private TestRestTemplate restTemplate; - - @Before - public void setUp(){ - BasicAuthorizationInterceptor bai = new BasicAuthorizationInterceptor("ccsdkapps", "ccsdkapps"); - this.restTemplate.getRestTemplate().getInterceptors().add(bai); - } - - @Test - public void testConfigModel() { - HttpHeaders headers = new HttpHeaders(); - headers.set("Accept", MediaType.APPLICATION_JSON_VALUE); -// ResponseEntity entity = this.restTemplate -// .exchange("/api/v1/config-model/1", HttpMethod.GET, new HttpEntity<>(headers),BlueprintModel.class); -// assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); -// Assert.assertNotNull("failed to get response Config model",entity.getBody()); - } - - @Test - public void testConfigModelFailure() { - HttpHeaders headers = new HttpHeaders(); - headers.set("Accept", MediaType.APPLICATION_JSON_VALUE); -// ResponseEntity entity = this.restTemplate -// .exchange("/api/v1/config-model-not-found/1", HttpMethod.GET, new HttpEntity<>(headers),BlueprintModel.class); -// assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND); -// Assert.assertNotNull("failed to get response Config model",entity.getBody()); - } -} diff --git a/ms/controllerblueprints/application/src/test/resources/application.properties b/ms/controllerblueprints/application/src/test/resources/application.properties index 13b2aa754..9aebd7936 100755 --- a/ms/controllerblueprints/application/src/test/resources/application.properties +++ b/ms/controllerblueprints/application/src/test/resources/application.properties @@ -52,4 +52,7 @@ controllerblueprints.loadResourceDictionaryPaths=./../../../../components/model- controllerblueprints.loadCbaExtension=zip # CBA examples for tests cases -controllerblueprints.loadBlueprintsExamplesPath=./../../../../components/model-catalog/blueprint-model/test-blueprints \ No newline at end of file +controllerblueprints.loadBlueprintsExamplesPath=./../../../../components/model-catalog/blueprint-model/test-blueprints + +# Web server config +server.port=8080 \ No newline at end of file diff --git a/ms/controllerblueprints/distribution/pom.xml b/ms/controllerblueprints/distribution/pom.xml old mode 100644 new mode 100755 index 305712936..91d4bbca0 --- a/ms/controllerblueprints/distribution/pom.xml +++ b/ms/controllerblueprints/distribution/pom.xml @@ -1,6 +1,7 @@ controllerblueprints onap/ccsdk-controllerblueprints - ${https_proxy} - deploy - true - + ${https_proxy} + deploy + true + @@ -120,20 +121,20 @@ - println project.properties['ccsdk.project.version']; - def versionArray; + println project.properties['ccsdk.project.version'] + def versionArray if (project.properties['ccsdk.project.version'] != null ) { - versionArray = project.properties['ccsdk.project.version'].split('\\.'); + versionArray = project.properties['ccsdk.project.version'].split('\\.') } if (project.properties['ccsdk.project.version'].endsWith("-SNAPSHOT")) { - project.properties['project.docker.latesttag.version']=versionArray[0] + '.' + versionArray[1] + "-STAGING-latest"; + project.properties['project.docker.latesttag.version']=versionArray[0] + '.' + versionArray[1] + "-STAGING-latest" } else { - project.properties['project.docker.latesttag.version']=versionArray[0]+'.' + versionArray[1]+"-STAGING-latest"; + project.properties['project.docker.latesttag.version']=versionArray[0]+'.' + versionArray[1]+"-STAGING-latest" } - println 'New Tag for docker:' + project.properties['project.docker.latesttag.version']; + println 'New Tag for docker:' + project.properties['project.docker.latesttag.version'] @@ -143,34 +144,34 @@ - - - docker - - - - io.fabric8 - docker-maven-plugin - 0.26.1 - false - - - - ${image.name} - - try - ${basedir}/target/docker-stage - - ${project.version} - ${project.version}-STAGING-${maven.build.timestamp} - ${project.docker.latesttag.version} - - - - - true - - + + + docker + + + + io.fabric8 + docker-maven-plugin + 0.26.1 + false + + + + ${image.name} + + try + ${basedir}/target/docker-stage + + ${project.version} + ${project.version}-STAGING-${maven.build.timestamp} + ${project.docker.latesttag.version} + + + + + true + + generate-images package @@ -186,11 +187,11 @@ push - - - - - + + + + + - + diff --git a/ms/controllerblueprints/distribution/src/main/dc/docker-compose.yaml b/ms/controllerblueprints/distribution/src/main/dc/docker-compose.yaml old mode 100644 new mode 100755 index eae24703b..232bfc016 --- a/ms/controllerblueprints/distribution/src/main/dc/docker-compose.yaml +++ b/ms/controllerblueprints/distribution/src/main/dc/docker-compose.yaml @@ -1,37 +1,33 @@ -version: '3.3' - -services: - db: - image: mariadb:latest - container_name: cb-mariadb - ports: - - "3306:3306" - volumes: - - ~/vm_mysql:/var/lib/mysql - restart: always - environment: - MYSQL_ROOT_PASSWORD: sdnctl - MYSQL_DATABASE: sdnctl - MYSQL_USER: sdnctl - MYSQL_PASSWORD: sdnctl - controller-blueprints: - depends_on: - - db - image: onap/ccsdk-controllerblueprints:latest - container_name: cb-rest - ports: - - "8080:8080" - restart: always - volumes: - - ~/share/vm_ms/controllerblueprints/config:/opt/app/onap/config - - ~/share/vm_ms/controllerblueprints/logs:/logs - environment: - APPLICATIONNAME : ControllerBluePrints - BUNDLEVERSION: 1.0.0 - APP_CONFIG_HOME: /opt/app/onap/config - DB_URL: jdbc:mysql://db:3306/sdnctl - DB_USER: sdnctl - DB_PASSWORD: sdnctl - INIT_DATA_LOAD: "true" - STICKYSELECTORKEY: - ENVCONTEXT: DEV \ No newline at end of file +version: '3.3' + +services: + db: + image: mariadb:latest + container_name: ccsdk-mariadb + ports: + - "3306:3306" + volumes: + - ~/vm_mysql:/var/lib/mysql + restart: always + environment: + MYSQL_ROOT_PASSWORD: sdnctl + MYSQL_DATABASE: sdnctl + MYSQL_USER: sdnctl + MYSQL_PASSWORD: sdnctl + controller-blueprints: + depends_on: + - db + image: onap/ccsdk-controllerblueprints:latest + container_name: cb-rest + ports: + - "8080:8080" + restart: always + volumes: + - ~/share/vm_ms/controllerblueprints/config:/opt/app/onap/config + - ~/share/vm_ms/controllerblueprints/logs:/logs + environment: + APPLICATIONNAME: ControllerBluePrints + BUNDLEVERSION: 1.0.0 + APP_CONFIG_HOME: /opt/app/onap/config + STICKYSELECTORKEY: + ENVCONTEXT: dev \ No newline at end of file diff --git a/ms/controllerblueprints/distribution/src/main/docker/Dockerfile b/ms/controllerblueprints/distribution/src/main/docker/Dockerfile old mode 100644 new mode 100755 index 6de589dac..88577f5af --- a/ms/controllerblueprints/distribution/src/main/docker/Dockerfile +++ b/ms/controllerblueprints/distribution/src/main/docker/Dockerfile @@ -15,6 +15,7 @@ RUN (mkdir -p /source /opt/app/onap) && (tar -xzf /source.tar.gz -C /source) \ && (cp -rf /source/app/opt/app/onap/lib /opt/app/onap/) \ && (cp -rf /source/app/etc /) \ && (cp -rf /source/app/model-catalog /) \ +&& (cp -rf /source/app/config /) \ && (rm -rf /source) -ENTRYPOINT /startService.sh +ENTRYPOINT /startService.sh \ No newline at end of file diff --git a/ms/controllerblueprints/distribution/src/main/docker/distribution.xml b/ms/controllerblueprints/distribution/src/main/docker/distribution.xml old mode 100644 new mode 100755 index c929f98ef..1555b43e7 --- a/ms/controllerblueprints/distribution/src/main/docker/distribution.xml +++ b/ms/controllerblueprints/distribution/src/main/docker/distribution.xml @@ -1,6 +1,7 @@