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) --- ms/controllerblueprints/parent/pom.xml | 228 +++++++++++++++++++++++++++++++++ 1 file changed, 228 insertions(+) create mode 100644 ms/controllerblueprints/parent/pom.xml (limited to 'ms/controllerblueprints/parent') diff --git a/ms/controllerblueprints/parent/pom.xml b/ms/controllerblueprints/parent/pom.xml new file mode 100644 index 000000000..0b19186d5 --- /dev/null +++ b/ms/controllerblueprints/parent/pom.xml @@ -0,0 +1,228 @@ + + + + + 4.0.0 + org.onap.ccsdk.apps + controllerblueprints-parent + Controller Blueprints Parent + 0.3.0-SNAPSHOT + pom + + 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 + + + + + org.springframework.boot + spring-boot-dependencies + ${spring.boot.version} + pom + import + + + + org.apache.commons + commons-lang3 + 3.2.1 + + + commons-collections + commons-collections + 3.2.2 + + + commons-io + commons-io + 2.6 + + + org.apache.velocity + 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 + kotlin-stdlib + ${kotlin.version} + + + org.jetbrains.kotlin + kotlin-reflect + ${kotlin.version} + + + com.fasterxml.jackson.module + jackson-module-kotlin + 2.9.6 + + + org.jetbrains.kotlin + kotlin-test + ${kotlin.version} + test + + + org.onap.ccsdk.apps + controllerblueprints-core + ${project.version} + + + org.onap.ccsdk.apps + controllerblueprints-service + ${project.version} + + + org.onap.ccsdk.apps + controllerblueprints-resource-dict + ${project.version} + + + + + + + org.jetbrains.kotlin + kotlin-stdlib + + + + + + + + org.apache.maven.plugins + maven-source-plugin + 3.0.1 + + + attach-sources + + jar + + + + + + + kotlin-maven-plugin + org.jetbrains.kotlin + ${kotlin.version} + + + compile + + compile + + + + ${project.basedir}/src/main/kotlin + ${project.basedir}/src/main/java + + + + + test-compile + + test-compile + + + + ${project.basedir}/src/test/kotlin + ${project.basedir}/src/test/java + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.5.1 + + ${maven.compiler.source} + ${maven.compiler.target} + + + + + default-compile + none + + + + default-testCompile + none + + + java-compile + compile + + compile + + + + java-test-compile + test-compile + + testCompile + + + + + + + -- 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/parent') 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 380b7afc7c81a13c3025de0efed050ddbd1d929b Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Thu, 23 Aug 2018 15:54:30 +0000 Subject: Controller Blueprints Microservice Add Docker Build and Deploy Maven Implementations for Controller Blueprint MS and their dependencies Change-Id: I9eee9fff535bcc9ca0b855150892ce53af126d1c Issue-ID: CCSDK-483 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- ms/controllerblueprints/application/pom.xml | 75 ++++----- .../application/src/assembly/distribution.xml | 72 -------- .../application/src/main/dc/docker-compose.yaml | 36 ---- .../application/src/main/docker/Dockerfile | 17 -- .../application/src/main/docker/startService.sh | 8 - ms/controllerblueprints/distribution/pom.xml | 187 +++++++++++++++++++++ .../distribution/src/main/dc/docker-compose.yaml | 36 ++++ .../distribution/src/main/docker/Dockerfile | 20 +++ .../distribution/src/main/docker/distribution.xml | 72 ++++++++ .../distribution/src/main/docker/startService.sh | 8 + ms/controllerblueprints/modules/core/pom.xml | 6 +- ms/controllerblueprints/modules/pom.xml | 6 +- .../modules/resource-dict/pom.xml | 10 +- ms/controllerblueprints/modules/service/pom.xml | 10 +- ms/controllerblueprints/parent/pom.xml | 40 +++-- ms/controllerblueprints/pom.xml | 8 + 16 files changed, 400 insertions(+), 211 deletions(-) delete mode 100644 ms/controllerblueprints/application/src/assembly/distribution.xml delete mode 100644 ms/controllerblueprints/application/src/main/dc/docker-compose.yaml delete mode 100644 ms/controllerblueprints/application/src/main/docker/Dockerfile delete mode 100644 ms/controllerblueprints/application/src/main/docker/startService.sh create mode 100644 ms/controllerblueprints/distribution/pom.xml create mode 100644 ms/controllerblueprints/distribution/src/main/dc/docker-compose.yaml create mode 100644 ms/controllerblueprints/distribution/src/main/docker/Dockerfile create mode 100644 ms/controllerblueprints/distribution/src/main/docker/distribution.xml create mode 100644 ms/controllerblueprints/distribution/src/main/docker/startService.sh (limited to 'ms/controllerblueprints/parent') diff --git a/ms/controllerblueprints/application/pom.xml b/ms/controllerblueprints/application/pom.xml index 19fd9c72d..4e781ad1b 100644 --- a/ms/controllerblueprints/application/pom.xml +++ b/ms/controllerblueprints/application/pom.xml @@ -21,24 +21,18 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 4.0.0 - org.onap.ccsdk.apps - controllerblueprints-parent + org.onap.ccsdk.apps.controllerblueprints + parent 0.3.0-SNAPSHOT ../parent - controllerblueprints-application + application Controller Blueprints Application ${basedir}/src/main/resources/swagger-ui/dist 1.8 - xxxxxxxxx:5100 - distribution - local org.onap.ccsdk.apps - org.onap.ccsdk.apps - 200.0.49 controllerblueprints - jacoco reuseReports @@ -50,15 +44,12 @@ ${basedir}/target/jacoco-it.exec java 2.0.7 - - - - org.onap.ccsdk.apps - controllerblueprints-service + org.onap.ccsdk.apps.controllerblueprints + service org.springframework.boot @@ -102,16 +93,34 @@ true - - src/main/docker - ${basedir}/target - - **/* - - true - + + maven-resources-plugin + 2.6 + + + copy-dockerfile + + copy-resources + + validate + + ${basedir}/target/docker-stage + + + src/main/docker + + * + + true + + + + + + + org.jacoco jacoco-maven-plugin @@ -166,28 +175,6 @@ - - - maven-assembly-plugin - 3.0.0 - - - target - - src/assembly/distribution.xml - - posix - - - - ${assembly.id} - package - - single - - - - maven-compiler-plugin 3.1 diff --git a/ms/controllerblueprints/application/src/assembly/distribution.xml b/ms/controllerblueprints/application/src/assembly/distribution.xml deleted file mode 100644 index c58c20d78..000000000 --- a/ms/controllerblueprints/application/src/assembly/distribution.xml +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - ${assembly.id} - - tar.gz - - - - /opt/app/onap/lib - - - - - - - ${project.basedir}/src/main/resources - - application.properties - - / - true - - - ${project.basedir}/src/main/docker - - Dockerfile - startService.sh - - / - true - - - ${project.basedir}/src/main/groovy - src/main/groovy - true - - - ${project.basedir}/src/main/resources - src/main/resources - true - - - ${project.basedir}/etc - /etc - true - - - ${project.basedir}/load - load - true - - - diff --git a/ms/controllerblueprints/application/src/main/dc/docker-compose.yaml b/ms/controllerblueprints/application/src/main/dc/docker-compose.yaml deleted file mode 100644 index 5696d02b3..000000000 --- a/ms/controllerblueprints/application/src/main/dc/docker-compose.yaml +++ /dev/null @@ -1,36 +0,0 @@ -version: '3.3' - -services: - db: - image: mysql:5.7.22 - container_name: cb-mysql - ports: - - "3307: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/controllerblueprints:1.0.0 - 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: - 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/application/src/main/docker/Dockerfile b/ms/controllerblueprints/application/src/main/docker/Dockerfile deleted file mode 100644 index 06304e1db..000000000 --- a/ms/controllerblueprints/application/src/main/docker/Dockerfile +++ /dev/null @@ -1,17 +0,0 @@ -FROM anapsix/alpine-java:8_jdk - -RUN apk add --no-cache curl - -COPY startService.sh /startService.sh -RUN chmod 777 /startService.sh && dos2unix /startService.sh - -COPY @project.build.finalName@-@assembly.id@.tar.gz /source.tar.gz - -RUN (mkdir -p /source /opt/app/onap) && (tar -xzf /source.tar.gz -C /source) \ -&& (mv /source/@project.build.finalName@ /source/app) \ -&& (cp -rf /source/app/opt/app/onap/lib /opt/app/onap/) \ -&& (cp -rf /source/app/etc /) \ -&& (cp -rf /source/app/load /) \ -&& (rm -rf /source) - -ENTRYPOINT /startService.sh diff --git a/ms/controllerblueprints/application/src/main/docker/startService.sh b/ms/controllerblueprints/application/src/main/docker/startService.sh deleted file mode 100644 index 7077c2246..000000000 --- a/ms/controllerblueprints/application/src/main/docker/startService.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -nodeName=ControllerBlueprints_1.0.0_$(cat /proc/self/cgroup | grep docker | sed s/\\//\\n/g | tail -1) - -echo "APP Config HOME : ${APP_CONFIG_HOME}" -export APP_HOME=/opt/app/onap - -source /etc/run.source diff --git a/ms/controllerblueprints/distribution/pom.xml b/ms/controllerblueprints/distribution/pom.xml new file mode 100644 index 000000000..37c0b8448 --- /dev/null +++ b/ms/controllerblueprints/distribution/pom.xml @@ -0,0 +1,187 @@ + + + + + 4.0.0 + + org.onap.ccsdk.apps.controllerblueprints + parent + 0.3.0-SNAPSHOT + ../parent + + distribution + pom + Controller Blueprints Distribution + + maven + org.onap.ccsdk.apps + controllerblueprints + onap/ccsdk-controllerblueprints + + + + + org.onap.ccsdk.apps.controllerblueprints + application + + + + + + maven-resources-plugin + 2.6 + + + copy-dockerfile + + copy-resources + + validate + + ${basedir}/target/docker-stage + + + src/main/docker + + * + + true + + + + + + + + org.apache.maven.plugins + maven-antrun-plugin + + + ant-test + package + + + + + + + run + + + + + + + maven-assembly-plugin + 3.0.0 + + + ${basedir}/target/docker-stage + + src/main/docker/distribution.xml + + posix + + + + ${assembly.id} + package + + single + + + + + + org.codehaus.groovy.maven + gmaven-plugin + 1.0 + + + validate + + execute + + + + println project.properties['ccsdk.project.version']; + def versionArray; + if (project.properties['ccsdk.project.version'] != null ) { + 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"; + } else { + project.properties['project.docker.latesttag.version']=versionArray[0]+'.' + versionArray[1]+"-STAGING-latest"; + } + + println 'New Tag for docker:' + project.properties['project.docker.latesttag.version']; + + + + + + + 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 + + + + + + + + + + + push-images + deploy + + build + push + + + + + + + + diff --git a/ms/controllerblueprints/distribution/src/main/dc/docker-compose.yaml b/ms/controllerblueprints/distribution/src/main/dc/docker-compose.yaml new file mode 100644 index 000000000..9450f3065 --- /dev/null +++ b/ms/controllerblueprints/distribution/src/main/dc/docker-compose.yaml @@ -0,0 +1,36 @@ +version: '3.3' + +services: + db: + image: mysql:5.7.22 + container_name: cb-mysql + ports: + - "3307: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: + 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/distribution/src/main/docker/Dockerfile b/ms/controllerblueprints/distribution/src/main/docker/Dockerfile new file mode 100644 index 000000000..a2f453f24 --- /dev/null +++ b/ms/controllerblueprints/distribution/src/main/docker/Dockerfile @@ -0,0 +1,20 @@ +FROM anapsix/alpine-java:8_jdk + +ENV HTTP_PROXY ${HTTP_PROXY} +ENV HTTPS_PROXY ${HTTPS_PROXY} + +RUN apk add --no-cache curl + +COPY startService.sh /startService.sh +RUN chmod 777 /startService.sh && dos2unix /startService.sh + +COPY @project.build.finalName@-@assembly.id@.tar.gz /source.tar.gz + +RUN (mkdir -p /source /opt/app/onap) && (tar -xzf /source.tar.gz -C /source) \ +&& (mv /source/@project.build.finalName@ /source/app) \ +&& (cp -rf /source/app/opt/app/onap/lib /opt/app/onap/) \ +&& (cp -rf /source/app/etc /) \ +&& (cp -rf /source/app/load /) \ +&& (rm -rf /source) + +ENTRYPOINT /startService.sh diff --git a/ms/controllerblueprints/distribution/src/main/docker/distribution.xml b/ms/controllerblueprints/distribution/src/main/docker/distribution.xml new file mode 100644 index 000000000..f2f3cb0be --- /dev/null +++ b/ms/controllerblueprints/distribution/src/main/docker/distribution.xml @@ -0,0 +1,72 @@ + + + + + + ${assembly.id} + + tar.gz + + + + /opt/app/onap/lib + + + + + + + ${project.basedir}/../application/src/main/resources + + application.properties + + ./ + true + + + ${project.basedir}/src/main/docker + + Dockerfile + startService.sh + + ./ + true + + + ${project.basedir}/../application/src/main/groovy + src/main/groovy + true + + + ${project.basedir}/../application/src/main/resources + src/main/resources + true + + + ${project.basedir}/../application/etc + ./etc + true + + + ${project.basedir}/../application/load + load + true + + + diff --git a/ms/controllerblueprints/distribution/src/main/docker/startService.sh b/ms/controllerblueprints/distribution/src/main/docker/startService.sh new file mode 100644 index 000000000..7077c2246 --- /dev/null +++ b/ms/controllerblueprints/distribution/src/main/docker/startService.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +nodeName=ControllerBlueprints_1.0.0_$(cat /proc/self/cgroup | grep docker | sed s/\\//\\n/g | tail -1) + +echo "APP Config HOME : ${APP_CONFIG_HOME}" +export APP_HOME=/opt/app/onap + +source /etc/run.source diff --git a/ms/controllerblueprints/modules/core/pom.xml b/ms/controllerblueprints/modules/core/pom.xml index fc7581c8c..5782c60fc 100644 --- a/ms/controllerblueprints/modules/core/pom.xml +++ b/ms/controllerblueprints/modules/core/pom.xml @@ -21,11 +21,11 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 4.0.0 - org.onap.ccsdk.apps - controllerblueprints-modules + org.onap.ccsdk.apps.controllerblueprints + modules 0.3.0-SNAPSHOT - controllerblueprints-core + core Controller Blueprints Core diff --git a/ms/controllerblueprints/modules/pom.xml b/ms/controllerblueprints/modules/pom.xml index 9e7215ba8..5ab4e4477 100644 --- a/ms/controllerblueprints/modules/pom.xml +++ b/ms/controllerblueprints/modules/pom.xml @@ -21,12 +21,12 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 4.0.0 - org.onap.ccsdk.apps - controllerblueprints-parent + org.onap.ccsdk.apps.controllerblueprints + parent 0.3.0-SNAPSHOT ../parent - controllerblueprints-modules + modules Controller Blueprints Modules pom diff --git a/ms/controllerblueprints/modules/resource-dict/pom.xml b/ms/controllerblueprints/modules/resource-dict/pom.xml index 337f5512f..4f2261853 100644 --- a/ms/controllerblueprints/modules/resource-dict/pom.xml +++ b/ms/controllerblueprints/modules/resource-dict/pom.xml @@ -21,17 +21,17 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 4.0.0 - org.onap.ccsdk.apps - controllerblueprints-modules + org.onap.ccsdk.apps.controllerblueprints + modules 0.3.0-SNAPSHOT - controllerblueprints-resource-dict + resource-dict Controller Blueprints Resource Dictionary - org.onap.ccsdk.apps - controllerblueprints-core + org.onap.ccsdk.apps.controllerblueprints + core diff --git a/ms/controllerblueprints/modules/service/pom.xml b/ms/controllerblueprints/modules/service/pom.xml index b4b798e6e..6a40a4a71 100644 --- a/ms/controllerblueprints/modules/service/pom.xml +++ b/ms/controllerblueprints/modules/service/pom.xml @@ -21,11 +21,11 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 4.0.0 - org.onap.ccsdk.apps - controllerblueprints-modules + org.onap.ccsdk.apps.controllerblueprints + modules 0.3.0-SNAPSHOT - controllerblueprints-service + service Controller Blueprints Service @@ -33,8 +33,8 @@ - org.onap.ccsdk.apps - controllerblueprints-resource-dict + org.onap.ccsdk.apps.controllerblueprints + resource-dict org.apache.velocity diff --git a/ms/controllerblueprints/parent/pom.xml b/ms/controllerblueprints/parent/pom.xml index f8977d1f3..e48c11342 100644 --- a/ms/controllerblueprints/parent/pom.xml +++ b/ms/controllerblueprints/parent/pom.xml @@ -20,18 +20,18 @@ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 4.0.0 - org.onap.ccsdk.apps - controllerblueprints-parent + + org.onap.ccsdk.apps + controllerblueprints + 0.3.0-SNAPSHOT + + org.onap.ccsdk.apps.controllerblueprints + parent Controller Blueprints Parent - 0.3.0-SNAPSHOT pom - UTF-8 - UTF-8 - 1.8 - 1.8 - 1.8 2.0.4.RELEASE + 5.0.8.RELEASE 1.2.60 1.0.0 2.9.2 @@ -122,19 +122,26 @@ ${kotlin.version} test + + - org.onap.ccsdk.apps - controllerblueprints-core + org.onap.ccsdk.apps.controllerblueprints + core ${project.version} - org.onap.ccsdk.apps - controllerblueprints-service + org.onap.ccsdk.apps.controllerblueprints + service ${project.version} - org.onap.ccsdk.apps - controllerblueprints-resource-dict + org.onap.ccsdk.apps.controllerblueprints + application + ${project.version} + + + org.onap.ccsdk.apps.controllerblueprints + resource-dict ${project.version} @@ -148,17 +155,14 @@ org.apache.commons commons-lang3 - 3.2.1 - + commons-collections commons-collections - 3.2.2 commons-io commons-io - 2.6 com.jayway.jsonpath diff --git a/ms/controllerblueprints/pom.xml b/ms/controllerblueprints/pom.xml index d76f4c8cb..798bdae4a 100644 --- a/ms/controllerblueprints/pom.xml +++ b/ms/controllerblueprints/pom.xml @@ -30,12 +30,20 @@ ControllerBlueprints UTF-8 + UTF-8 + yyyyMMdd'T'HHmmss'Z' + ${maven.build.timestamp} + 1.8 + 1.8 + 1.8 + ${project.version} pom parent modules application + distribution -- cgit 1.2.3-korg From bddb076486a7c3def39687f6f9aaa0fc060d85e6 Mon Sep 17 00:00:00 2001 From: Brinda Santh Date: Thu, 23 Aug 2018 23:34:05 -0400 Subject: Controller Blueprints Microservice Add Powermock compatable version in OpenJDK Ubuntu Machine for Spring boot 2 Junit testcase and clean maven dependencies Change-Id: Icac038b0d68fdd0edbb1aac9bc2bccb77d627289 Issue-ID: CCSDK-483 Signed-off-by: Brinda Santh --- ms/controllerblueprints/application/pom.xml | 18 ++++++++-- ms/controllerblueprints/modules/core/pom.xml | 11 ++++++ .../modules/resource-dict/pom.xml | 7 ++++ ms/controllerblueprints/modules/service/pom.xml | 17 +++++++++ ms/controllerblueprints/parent/pom.xml | 40 +++++++++------------- 5 files changed, 67 insertions(+), 26 deletions(-) (limited to 'ms/controllerblueprints/parent') diff --git a/ms/controllerblueprints/application/pom.xml b/ms/controllerblueprints/application/pom.xml index 4e781ad1b..38f81c169 100644 --- a/ms/controllerblueprints/application/pom.xml +++ b/ms/controllerblueprints/application/pom.xml @@ -2,6 +2,8 @@ + + org.powermock + powermock-api-mockito2 + test + org.springframework.boot spring-boot-starter-test test + + org.jetbrains.kotlin + kotlin-test + test + + + io.projectreactor + reactor-test + test + diff --git a/ms/controllerblueprints/parent/pom.xml b/ms/controllerblueprints/parent/pom.xml index e48c11342..19e55fe0b 100644 --- a/ms/controllerblueprints/parent/pom.xml +++ b/ms/controllerblueprints/parent/pom.xml @@ -2,6 +2,8 @@ @@ -144,6 +141,20 @@ resource-dict ${project.version} + + + + org.powermock + powermock-api-mockito2 + 1.7.4 + test + + + org.jetbrains.kotlin + kotlin-test + ${kotlin.version} + test + @@ -188,25 +199,8 @@ 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 cdadbb3ccb2d40ab9e6b5a00dca8e62d3f423f24 Mon Sep 17 00:00:00 2001 From: Gary Wu Date: Fri, 24 Aug 2018 15:16:48 -0700 Subject: Use managed guava version Use centrally managed guava version specified in oparent. Includes upgrade to oparent 1.2.0. This change was submitted by script and may include additional whitespace or formatting changes. Change-Id: I6b131c9311f70a46b67b81119ef201b93c28ffa5 Issue-ID: INT-619 Signed-off-by: Gary Wu --- ms/controllerblueprints/parent/pom.xml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'ms/controllerblueprints/parent') diff --git a/ms/controllerblueprints/parent/pom.xml b/ms/controllerblueprints/parent/pom.xml index e48c11342..1e8b8f2dc 100644 --- a/ms/controllerblueprints/parent/pom.xml +++ b/ms/controllerblueprints/parent/pom.xml @@ -14,11 +14,7 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License. --> - - + 4.0.0 org.onap.ccsdk.apps @@ -89,7 +85,7 @@ com.google.guava guava - 25.1-jre + -- 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/parent') 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 41c2f1da66124c013f1fe644e2220b078fbf2563 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Fri, 14 Sep 2018 20:07:46 +0000 Subject: Controller Blueprints Microservice Change database to mariadb in docker compose and spring boot version upgrade Change-Id: Icd73b8110aea2a1b90ab29217b9c5e30817e6c06 Issue-ID: CCSDK-574 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- ms/controllerblueprints/distribution/src/main/dc/docker-compose.yaml | 4 ++-- ms/controllerblueprints/parent/pom.xml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'ms/controllerblueprints/parent') diff --git a/ms/controllerblueprints/distribution/src/main/dc/docker-compose.yaml b/ms/controllerblueprints/distribution/src/main/dc/docker-compose.yaml index 493d43813..3c1464699 100644 --- a/ms/controllerblueprints/distribution/src/main/dc/docker-compose.yaml +++ b/ms/controllerblueprints/distribution/src/main/dc/docker-compose.yaml @@ -2,8 +2,8 @@ version: '3.3' services: db: - image: mysql:5.7.22 - container_name: cb-mysql + image: mariadb:latest + container_name: cb-mariadb ports: - "3307:3306" volumes: diff --git a/ms/controllerblueprints/parent/pom.xml b/ms/controllerblueprints/parent/pom.xml index 8b719f577..aabb4b259 100644 --- a/ms/controllerblueprints/parent/pom.xml +++ b/ms/controllerblueprints/parent/pom.xml @@ -28,9 +28,9 @@ Controller Blueprints Parent pom - 2.0.4.RELEASE + 2.0.5.RELEASE 5.0.8.RELEASE - 1.2.60 + 1.2.70 1.0.0 2.9.2 1.4.197 -- cgit 1.2.3-korg From 1b4788a4d81ca646b97497661f7dfb5a996ef52d Mon Sep 17 00:00:00 2001 From: Sandeep J Date: Fri, 21 Sep 2018 15:44:52 +0530 Subject: added version no to google guava plugin dependency to increase code coverage Issue-ID: CCSDK-591 Change-Id: I0599d001c5433ac1c63c160099090eab09bdaffa Signed-off-by: Sandeep J --- ms/controllerblueprints/parent/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ms/controllerblueprints/parent') diff --git a/ms/controllerblueprints/parent/pom.xml b/ms/controllerblueprints/parent/pom.xml index aabb4b259..86dfdf69c 100644 --- a/ms/controllerblueprints/parent/pom.xml +++ b/ms/controllerblueprints/parent/pom.xml @@ -90,10 +90,10 @@ velocity 1.7 - + com.google.guava guava - + 26.0-jre -- cgit 1.2.3-korg From c4200f66c92b7cc9331dc5d01773aeda1c4ba989 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Thu, 27 Sep 2018 16:26:45 -0400 Subject: Roll to next snapshot version Roll to next snapshot version Change-Id: Ifbbe4c890c47001d60117f09a67daa278d57dcd4 Issue-ID: CCSDK-597 Signed-off-by: Timoney, Dan (dt5972) --- ms/controllerblueprints/application/pom.xml | 2 +- ms/controllerblueprints/distribution/pom.xml | 2 +- ms/controllerblueprints/modules/pom.xml | 2 +- ms/controllerblueprints/modules/service/pom.xml | 2 +- ms/controllerblueprints/parent/pom.xml | 2 +- ms/controllerblueprints/pom.xml | 4 ++-- 6 files changed, 7 insertions(+), 7 deletions(-) (limited to 'ms/controllerblueprints/parent') diff --git a/ms/controllerblueprints/application/pom.xml b/ms/controllerblueprints/application/pom.xml index 9834924e0..ecb882175 100644 --- a/ms/controllerblueprints/application/pom.xml +++ b/ms/controllerblueprints/application/pom.xml @@ -25,7 +25,7 @@ org.onap.ccsdk.apps.controllerblueprints parent - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT ../parent application diff --git a/ms/controllerblueprints/distribution/pom.xml b/ms/controllerblueprints/distribution/pom.xml index 7a2c67920..b2c5b33c4 100644 --- a/ms/controllerblueprints/distribution/pom.xml +++ b/ms/controllerblueprints/distribution/pom.xml @@ -23,7 +23,7 @@ org.onap.ccsdk.apps.controllerblueprints parent - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT ../parent distribution diff --git a/ms/controllerblueprints/modules/pom.xml b/ms/controllerblueprints/modules/pom.xml index 887d02331..b38b6e6aa 100644 --- a/ms/controllerblueprints/modules/pom.xml +++ b/ms/controllerblueprints/modules/pom.xml @@ -23,7 +23,7 @@ org.onap.ccsdk.apps.controllerblueprints parent - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT ../parent modules diff --git a/ms/controllerblueprints/modules/service/pom.xml b/ms/controllerblueprints/modules/service/pom.xml index e95c1f739..add4ad15a 100644 --- a/ms/controllerblueprints/modules/service/pom.xml +++ b/ms/controllerblueprints/modules/service/pom.xml @@ -25,7 +25,7 @@ org.onap.ccsdk.apps.controllerblueprints modules - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT service Controller Blueprints Service diff --git a/ms/controllerblueprints/parent/pom.xml b/ms/controllerblueprints/parent/pom.xml index 86dfdf69c..659839c5e 100644 --- a/ms/controllerblueprints/parent/pom.xml +++ b/ms/controllerblueprints/parent/pom.xml @@ -21,7 +21,7 @@ org.onap.ccsdk.apps controllerblueprints - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT org.onap.ccsdk.apps.controllerblueprints parent diff --git a/ms/controllerblueprints/pom.xml b/ms/controllerblueprints/pom.xml index 5c190db5d..d8acbf20f 100644 --- a/ms/controllerblueprints/pom.xml +++ b/ms/controllerblueprints/pom.xml @@ -20,13 +20,13 @@ org.onap.ccsdk.apps ccsdk-apps-ms - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT 4.0.0 org.onap.ccsdk.apps controllerblueprints Controller Blueprints Root - 0.3.0-SNAPSHOT + 0.3.1-SNAPSHOT ControllerBlueprints UTF-8 -- cgit 1.2.3-korg From 85b0edf34bac8732fe03ca2ca4e7df35bea6736b Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Thu, 25 Oct 2018 10:34:51 -0400 Subject: Roll to initial Dublin version Roll to initial Dublin release version Change-Id: I9f56f6643bf5850a9958d46f137fa929b1c05e5d Issue-ID: CCSDK-617 Signed-off-by: Timoney, Dan (dt5972) --- ms/controllerblueprints/application/pom.xml | 2 +- ms/controllerblueprints/distribution/pom.xml | 2 +- ms/controllerblueprints/modules/pom.xml | 2 +- ms/controllerblueprints/modules/service/pom.xml | 2 +- ms/controllerblueprints/parent/pom.xml | 4 ++-- ms/controllerblueprints/pom.xml | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-) (limited to 'ms/controllerblueprints/parent') diff --git a/ms/controllerblueprints/application/pom.xml b/ms/controllerblueprints/application/pom.xml index ecb882175..44fda2dd6 100644 --- a/ms/controllerblueprints/application/pom.xml +++ b/ms/controllerblueprints/application/pom.xml @@ -25,7 +25,7 @@ org.onap.ccsdk.apps.controllerblueprints parent - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT ../parent application diff --git a/ms/controllerblueprints/distribution/pom.xml b/ms/controllerblueprints/distribution/pom.xml index b2c5b33c4..498442a25 100644 --- a/ms/controllerblueprints/distribution/pom.xml +++ b/ms/controllerblueprints/distribution/pom.xml @@ -23,7 +23,7 @@ org.onap.ccsdk.apps.controllerblueprints parent - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT ../parent distribution diff --git a/ms/controllerblueprints/modules/pom.xml b/ms/controllerblueprints/modules/pom.xml index b38b6e6aa..eff2429ab 100644 --- a/ms/controllerblueprints/modules/pom.xml +++ b/ms/controllerblueprints/modules/pom.xml @@ -23,7 +23,7 @@ org.onap.ccsdk.apps.controllerblueprints parent - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT ../parent modules diff --git a/ms/controllerblueprints/modules/service/pom.xml b/ms/controllerblueprints/modules/service/pom.xml index add4ad15a..e766f51cf 100644 --- a/ms/controllerblueprints/modules/service/pom.xml +++ b/ms/controllerblueprints/modules/service/pom.xml @@ -25,7 +25,7 @@ org.onap.ccsdk.apps.controllerblueprints modules - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT service Controller Blueprints Service diff --git a/ms/controllerblueprints/parent/pom.xml b/ms/controllerblueprints/parent/pom.xml index 659839c5e..a9e7cfa52 100644 --- a/ms/controllerblueprints/parent/pom.xml +++ b/ms/controllerblueprints/parent/pom.xml @@ -21,7 +21,7 @@ org.onap.ccsdk.apps controllerblueprints - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT org.onap.ccsdk.apps.controllerblueprints parent @@ -34,7 +34,7 @@ 1.0.0 2.9.2 1.4.197 - 1.2.2-SNAPSHOT + 1.2.2 diff --git a/ms/controllerblueprints/pom.xml b/ms/controllerblueprints/pom.xml index d8acbf20f..4517f3f3e 100644 --- a/ms/controllerblueprints/pom.xml +++ b/ms/controllerblueprints/pom.xml @@ -20,13 +20,13 @@ org.onap.ccsdk.apps ccsdk-apps-ms - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT 4.0.0 org.onap.ccsdk.apps controllerblueprints Controller Blueprints Root - 0.3.1-SNAPSHOT + 0.4.0-SNAPSHOT ControllerBlueprints UTF-8 -- cgit 1.2.3-korg From 6488fc3cdaf0ea48687f98acc14f689c42f64427 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Sat, 10 Nov 2018 11:54:05 -0500 Subject: Controller Design Studio Upgrade Spring Boot and Kotlin versions. Change-Id: If0d7d0f476d8cfd23916013ff1ab554b26bc6b7a Issue-ID: CCSDK-658 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- ms/controllerblueprints/.gitignore | 5 +- .../Definitions/activation-blueprint.json | 388 --- .../Mappings/baseconfig-mapping.json | 3 - .../baseconfiguration/Plans/ActivateProcess.bpmn | 66 - .../Scripts/SamplePythonComponentNode.py | 8 - .../baseconfiguration/Scripts/__init__.py | 0 .../baseconfiguration/TOSCA-Metadata/TOSCA.meta | 8 - .../Templates/baseconfig-template.vtl | 1 - .../load/blueprints/baseconfiguration/__init__.py | 0 .../blueprints/vFW/Definitions/vFW_spinup.json | 3613 -------------------- .../load/blueprints/vFW/TOSCA-Metadata/TOSCA.meta | 6 - .../blueprints/vFW/Templates/base_template.vtl | 56 - .../blueprints/vFW/Templates/vFW_vNF_Artifact.vtl | 203 -- .../load/blueprints/vFW/Templates/vfw.vtl | 315 -- .../load/blueprints/vFW/Templates/vpg.vtl | 315 -- .../load/blueprints/vFW/Templates/vsn.vtl | 311 -- .../artifact_type/artifact-bpmn-camunda.json | 8 - .../artifact_type/artifact-directed-graph.json | 9 - .../artifact_type/artifact-mapping-resource.json | 8 - .../artifact_type/artifact-script-python.json | 8 - .../artifact_type/artifact-template-velocity.json | 8 - .../tosca.artifacts.Implementation.json | 5 - .../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 - .../data_type/tosca.datatypes.Credential.json | 31 - .../node_type/artifact-config-template.json | 37 - .../node_type/component-config-generator.json | 72 - .../node_type/component-netconf-executor.json | 79 - .../node_type/component-resource-assignment.json | 68 - .../model_type/node_type/dg-activate-netconf.json | 52 - .../model_type/node_type/dg-config-generator.json | 51 - .../node_type/dg-resource-assign-activate.json | 56 - .../node_type/dg-resource-assignment.json | 51 - .../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 - .../model_type/node_type/tosca.nodes.Artifact.json | 5 - .../node_type/tosca.nodes.Component.json | 5 - .../load/model_type/node_type/tosca.nodes.DG.json | 5 - .../node_type/tosca.nodes.ResourceSource.json | 5 - .../load/model_type/node_type/tosca.nodes.Vnf.json | 5 - .../node_type/tosca.nodes.component.Python.json | 5 - .../model_type/node_type/vnf-netconf-device.json | 42 - .../load/resource_dictionary/address.json | 14 - .../load/resource_dictionary/aic-cloud-region.json | 15 - .../load/resource_dictionary/aic_clli.json | 15 - .../resource_dictionary/availability_zone_0.json | 15 - .../load/resource_dictionary/db-source.json | 24 - .../load/resource_dictionary/default-source.json | 16 - .../load/resource_dictionary/image_name.json | 33 - .../load/resource_dictionary/input-source.json | 16 - .../load/resource_dictionary/key_name.json | 33 - .../load/resource_dictionary/mdsal-source.json | 34 - .../load/resource_dictionary/name_0.json | 15 - .../resource_dictionary/nexus_artifact_repo.json | 16 - .../load/resource_dictionary/nf-role.json | 25 - .../load/resource_dictionary/nfc-naming-code.json | 25 - .../resource_dictionary/onap_private_net_cidr.json | 21 - .../resource_dictionary/onap_private_net_id.json | 33 - .../onap_private_subnet_id.json | 33 - .../resource_dictionary/private-prefix-id.json | 21 - .../resource_dictionary/protected-prefix-id.json | 21 - .../protected_private_net_cidr.json | 21 - .../protected_private_subnet_id.json | 16 - .../load/resource_dictionary/pub_key.json | 34 - .../load/resource_dictionary/public_net_id.json | 14 - .../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/sec_group.json | 16 - .../resource_dictionary/service-instance-id.json | 15 - .../load/resource_dictionary/status.json | 16 - .../resource_dictionary/unprotected-prefix-id.json | 21 - .../unprotected_private_net_cidr.json | 21 - .../unprotected_private_subnet_id.json | 16 - .../load/resource_dictionary/vf-module-id.json | 15 - .../load/resource_dictionary/vf-module-label.json | 25 - .../vf-module-model-customization-uuid.json | 15 - .../load/resource_dictionary/vf-module-type.json | 25 - .../load/resource_dictionary/vf-naming-policy.json | 25 - .../load/resource_dictionary/vf-nf-code.json | 25 - .../load/resource_dictionary/vf_module_name.json | 15 - .../resource_dictionary/vfccustomizationuuid.json | 25 - .../load/resource_dictionary/vfw_name_0.json | 15 - .../load/resource_dictionary/vfw_private_ip_0.json | 33 - .../load/resource_dictionary/vfw_private_ip_1.json | 33 - .../load/resource_dictionary/vfw_private_ip_2.json | 14 - .../load/resource_dictionary/vm-type.json | 25 - .../load/resource_dictionary/vnf-id.json | 15 - .../vnf-model-customization-uuid.json | 15 - .../load/resource_dictionary/vnf-name.json | 28 - .../load/resource_dictionary/vnf_name.json | 27 - .../vnfc-model-invariant-uuid.json | 25 - .../resource_dictionary/vnfc-model-version.json | 25 - .../load/resource_dictionary/volume-name.json | 15 - .../resource_dictionary/volume_group_name.json | 16 - .../load/resource_dictionary/vpg_name_0.json | 15 - .../load/resource_dictionary/vpg_private_ip_0.json | 33 - .../load/resource_dictionary/vpg_private_ip_1.json | 16 - .../load/resource_dictionary/vsn_name_0.json | 15 - .../load/resource_dictionary/vsn_private_ip_0.json | 33 - .../load/resource_dictionary/vsn_private_ip_1.json | 14 - .../opt/app/onap/config/application.properties | 2 +- ms/controllerblueprints/application/pom.xml | 2 +- .../src/test/resources/application.properties | 10 +- ms/controllerblueprints/modules/service/pom.xml | 2 +- .../service/utils/ConfigModelUtils.java | 2 +- .../ResourceAssignmentEnhancerServiceTest.java | 5 +- .../ResourceDictionaryReactRepositoryTest.java | 3 +- .../validator/ServiceTemplateValidationTest.java | 4 +- .../src/test/resources/application.properties | 10 +- ms/controllerblueprints/parent/pom.xml | 26 +- 118 files changed, 43 insertions(+), 7501 deletions(-) delete mode 100644 ms/controllerblueprints/application/load/blueprints/baseconfiguration/Definitions/activation-blueprint.json delete mode 100644 ms/controllerblueprints/application/load/blueprints/baseconfiguration/Mappings/baseconfig-mapping.json delete mode 100644 ms/controllerblueprints/application/load/blueprints/baseconfiguration/Plans/ActivateProcess.bpmn delete mode 100644 ms/controllerblueprints/application/load/blueprints/baseconfiguration/Scripts/SamplePythonComponentNode.py delete mode 100644 ms/controllerblueprints/application/load/blueprints/baseconfiguration/Scripts/__init__.py delete mode 100644 ms/controllerblueprints/application/load/blueprints/baseconfiguration/TOSCA-Metadata/TOSCA.meta delete mode 100644 ms/controllerblueprints/application/load/blueprints/baseconfiguration/Templates/baseconfig-template.vtl delete mode 100644 ms/controllerblueprints/application/load/blueprints/baseconfiguration/__init__.py delete mode 100644 ms/controllerblueprints/application/load/blueprints/vFW/Definitions/vFW_spinup.json delete mode 100644 ms/controllerblueprints/application/load/blueprints/vFW/TOSCA-Metadata/TOSCA.meta delete mode 100644 ms/controllerblueprints/application/load/blueprints/vFW/Templates/base_template.vtl delete mode 100644 ms/controllerblueprints/application/load/blueprints/vFW/Templates/vFW_vNF_Artifact.vtl delete mode 100644 ms/controllerblueprints/application/load/blueprints/vFW/Templates/vfw.vtl delete mode 100644 ms/controllerblueprints/application/load/blueprints/vFW/Templates/vpg.vtl delete mode 100644 ms/controllerblueprints/application/load/blueprints/vFW/Templates/vsn.vtl delete mode 100644 ms/controllerblueprints/application/load/model_type/artifact_type/artifact-bpmn-camunda.json delete mode 100644 ms/controllerblueprints/application/load/model_type/artifact_type/artifact-directed-graph.json delete mode 100644 ms/controllerblueprints/application/load/model_type/artifact_type/artifact-mapping-resource.json delete mode 100644 ms/controllerblueprints/application/load/model_type/artifact_type/artifact-script-python.json delete mode 100644 ms/controllerblueprints/application/load/model_type/artifact_type/artifact-template-velocity.json delete mode 100644 ms/controllerblueprints/application/load/model_type/artifact_type/tosca.artifacts.Implementation.json delete mode 100644 ms/controllerblueprints/application/load/model_type/data_type/datatype-property.json delete mode 100644 ms/controllerblueprints/application/load/model_type/data_type/datatype-resource-assignment.json delete mode 100644 ms/controllerblueprints/application/load/model_type/data_type/dt-license-key.json delete mode 100644 ms/controllerblueprints/application/load/model_type/data_type/dt-v4-aggregate.json delete mode 100644 ms/controllerblueprints/application/load/model_type/data_type/tosca.datatypes.Credential.json delete mode 100644 ms/controllerblueprints/application/load/model_type/node_type/artifact-config-template.json delete mode 100644 ms/controllerblueprints/application/load/model_type/node_type/component-config-generator.json delete mode 100644 ms/controllerblueprints/application/load/model_type/node_type/component-netconf-executor.json delete mode 100644 ms/controllerblueprints/application/load/model_type/node_type/component-resource-assignment.json delete mode 100644 ms/controllerblueprints/application/load/model_type/node_type/dg-activate-netconf.json delete mode 100644 ms/controllerblueprints/application/load/model_type/node_type/dg-config-generator.json delete mode 100644 ms/controllerblueprints/application/load/model_type/node_type/dg-resource-assign-activate.json delete mode 100644 ms/controllerblueprints/application/load/model_type/node_type/dg-resource-assignment.json delete mode 100644 ms/controllerblueprints/application/load/model_type/node_type/source-db.json delete mode 100644 ms/controllerblueprints/application/load/model_type/node_type/source-default.json delete mode 100644 ms/controllerblueprints/application/load/model_type/node_type/source-input.json delete mode 100644 ms/controllerblueprints/application/load/model_type/node_type/source-rest.json delete mode 100644 ms/controllerblueprints/application/load/model_type/node_type/tosca.nodes.Artifact.json delete mode 100644 ms/controllerblueprints/application/load/model_type/node_type/tosca.nodes.Component.json delete mode 100644 ms/controllerblueprints/application/load/model_type/node_type/tosca.nodes.DG.json delete mode 100644 ms/controllerblueprints/application/load/model_type/node_type/tosca.nodes.ResourceSource.json delete mode 100644 ms/controllerblueprints/application/load/model_type/node_type/tosca.nodes.Vnf.json delete mode 100644 ms/controllerblueprints/application/load/model_type/node_type/tosca.nodes.component.Python.json delete mode 100644 ms/controllerblueprints/application/load/model_type/node_type/vnf-netconf-device.json delete mode 100755 ms/controllerblueprints/application/load/resource_dictionary/address.json delete mode 100755 ms/controllerblueprints/application/load/resource_dictionary/aic-cloud-region.json delete mode 100755 ms/controllerblueprints/application/load/resource_dictionary/aic_clli.json delete mode 100755 ms/controllerblueprints/application/load/resource_dictionary/availability_zone_0.json delete mode 100755 ms/controllerblueprints/application/load/resource_dictionary/db-source.json delete mode 100755 ms/controllerblueprints/application/load/resource_dictionary/default-source.json delete mode 100755 ms/controllerblueprints/application/load/resource_dictionary/image_name.json delete mode 100755 ms/controllerblueprints/application/load/resource_dictionary/input-source.json delete mode 100755 ms/controllerblueprints/application/load/resource_dictionary/key_name.json delete mode 100755 ms/controllerblueprints/application/load/resource_dictionary/mdsal-source.json delete mode 100755 ms/controllerblueprints/application/load/resource_dictionary/name_0.json delete mode 100755 ms/controllerblueprints/application/load/resource_dictionary/nexus_artifact_repo.json delete mode 100755 ms/controllerblueprints/application/load/resource_dictionary/nf-role.json delete mode 100755 ms/controllerblueprints/application/load/resource_dictionary/nfc-naming-code.json delete mode 100755 ms/controllerblueprints/application/load/resource_dictionary/onap_private_net_cidr.json delete mode 100755 ms/controllerblueprints/application/load/resource_dictionary/onap_private_net_id.json delete mode 100755 ms/controllerblueprints/application/load/resource_dictionary/onap_private_subnet_id.json delete mode 100755 ms/controllerblueprints/application/load/resource_dictionary/private-prefix-id.json delete mode 100755 ms/controllerblueprints/application/load/resource_dictionary/protected-prefix-id.json delete mode 100755 ms/controllerblueprints/application/load/resource_dictionary/protected_private_net_cidr.json delete mode 100755 ms/controllerblueprints/application/load/resource_dictionary/protected_private_subnet_id.json delete mode 100755 ms/controllerblueprints/application/load/resource_dictionary/pub_key.json delete mode 100755 ms/controllerblueprints/application/load/resource_dictionary/public_net_id.json delete mode 100644 ms/controllerblueprints/application/load/resource_dictionary/sample-db-source.json delete mode 100644 ms/controllerblueprints/application/load/resource_dictionary/sample-default-source.json delete mode 100644 ms/controllerblueprints/application/load/resource_dictionary/sample-input-source.json delete mode 100644 ms/controllerblueprints/application/load/resource_dictionary/sample-licenses.json delete mode 100644 ms/controllerblueprints/application/load/resource_dictionary/sample-mdsal-source.json delete mode 100644 ms/controllerblueprints/application/load/resource_dictionary/sample-v4-ip-type.json delete mode 100755 ms/controllerblueprints/application/load/resource_dictionary/sec_group.json delete mode 100755 ms/controllerblueprints/application/load/resource_dictionary/service-instance-id.json delete mode 100755 ms/controllerblueprints/application/load/resource_dictionary/status.json delete mode 100755 ms/controllerblueprints/application/load/resource_dictionary/unprotected-prefix-id.json delete mode 100755 ms/controllerblueprints/application/load/resource_dictionary/unprotected_private_net_cidr.json delete mode 100755 ms/controllerblueprints/application/load/resource_dictionary/unprotected_private_subnet_id.json delete mode 100755 ms/controllerblueprints/application/load/resource_dictionary/vf-module-id.json delete mode 100755 ms/controllerblueprints/application/load/resource_dictionary/vf-module-label.json delete mode 100755 ms/controllerblueprints/application/load/resource_dictionary/vf-module-model-customization-uuid.json delete mode 100755 ms/controllerblueprints/application/load/resource_dictionary/vf-module-type.json delete mode 100755 ms/controllerblueprints/application/load/resource_dictionary/vf-naming-policy.json delete mode 100755 ms/controllerblueprints/application/load/resource_dictionary/vf-nf-code.json delete mode 100755 ms/controllerblueprints/application/load/resource_dictionary/vf_module_name.json delete mode 100755 ms/controllerblueprints/application/load/resource_dictionary/vfccustomizationuuid.json delete mode 100755 ms/controllerblueprints/application/load/resource_dictionary/vfw_name_0.json delete mode 100755 ms/controllerblueprints/application/load/resource_dictionary/vfw_private_ip_0.json delete mode 100755 ms/controllerblueprints/application/load/resource_dictionary/vfw_private_ip_1.json delete mode 100755 ms/controllerblueprints/application/load/resource_dictionary/vfw_private_ip_2.json delete mode 100755 ms/controllerblueprints/application/load/resource_dictionary/vm-type.json delete mode 100755 ms/controllerblueprints/application/load/resource_dictionary/vnf-id.json delete mode 100755 ms/controllerblueprints/application/load/resource_dictionary/vnf-model-customization-uuid.json delete mode 100755 ms/controllerblueprints/application/load/resource_dictionary/vnf-name.json delete mode 100755 ms/controllerblueprints/application/load/resource_dictionary/vnf_name.json delete mode 100755 ms/controllerblueprints/application/load/resource_dictionary/vnfc-model-invariant-uuid.json delete mode 100755 ms/controllerblueprints/application/load/resource_dictionary/vnfc-model-version.json delete mode 100755 ms/controllerblueprints/application/load/resource_dictionary/volume-name.json delete mode 100755 ms/controllerblueprints/application/load/resource_dictionary/volume_group_name.json delete mode 100755 ms/controllerblueprints/application/load/resource_dictionary/vpg_name_0.json delete mode 100755 ms/controllerblueprints/application/load/resource_dictionary/vpg_private_ip_0.json delete mode 100755 ms/controllerblueprints/application/load/resource_dictionary/vpg_private_ip_1.json delete mode 100755 ms/controllerblueprints/application/load/resource_dictionary/vsn_name_0.json delete mode 100755 ms/controllerblueprints/application/load/resource_dictionary/vsn_private_ip_0.json delete mode 100755 ms/controllerblueprints/application/load/resource_dictionary/vsn_private_ip_1.json (limited to 'ms/controllerblueprints/parent') diff --git a/ms/controllerblueprints/.gitignore b/ms/controllerblueprints/.gitignore index 8cda363d8..4b5c1c0a4 100644 --- a/ms/controllerblueprints/.gitignore +++ b/ms/controllerblueprints/.gitignore @@ -16,9 +16,10 @@ **/*.iml **/*.project **/.springBeans +**/.directory **/*versionsBackup **/blackDuckHub* -**/*.jsonld -/target-ide/ +**/*.jsonld +/target-ide/ diff --git a/ms/controllerblueprints/application/load/blueprints/baseconfiguration/Definitions/activation-blueprint.json b/ms/controllerblueprints/application/load/blueprints/baseconfiguration/Definitions/activation-blueprint.json deleted file mode 100644 index 4c1ca4a52..000000000 --- a/ms/controllerblueprints/application/load/blueprints/baseconfiguration/Definitions/activation-blueprint.json +++ /dev/null @@ -1,388 +0,0 @@ -{ - "metadata": { - "template_author": "Brinda Santh Muthuramalingam", - "author-email": "brindasanth@gmail.com", - "user-groups": "ADMIN, OPERATION", - "template_name": "baseconfiguration", - "template_version": "1.0.0", - "template_tags": "brinda, tosca" - }, - "topology_template": { - "inputs": { - "request-id": { - "required": true, - "type": "string" - }, - "action-name": { - "required": true, - "type": "string" - }, - "scope-type": { - "required": true, - "type": "string" - }, - "hostname": { - "required": true, - "type": "string" - } - }, - "node_templates": { - "activate-process": { - "type": "bpmn-activate", - "properties": { - "process-name": { - "get_input": "action-name" - }, - "version": { - "get_property": [ - "SELF", - "process-name" - ] - }, - "content": { - "get_artifact": [ - "SELF", - "activate-process" - ] - } - }, - "artifacts": { - "activate-process": { - "type": "artifact-bpmn-camunda", - "file": "Plans/ActivateProcess.bpmn" - } - } - }, - "resource-assignment": { - "type": "component-resource-assignment", - "properties": { - "request-id": "1234" - }, - "interfaces": { - "DefaultComponentNode": { - "operations": { - "process": { - "inputs": { - "action-name": { - "get_input": "action-name" - }, - "resource-type": "vnf-type", - "request-id": { - "get_input": "request-id" - }, - "resource-id": { - "get_input": "hostname" - }, - "template-content": { - "get_artifact": [ - "SELF", - "baseconfig-template" - ] - }, - "mapping-content": { - "get_artifact": [ - "SELF", - "baseconfig-mapping" - ] - } - }, - "outputs": { - "resource-assignment-params": "", - "status": "" - } - } - } - } - }, - "artifacts": { - "baseconfig-template": { - "type": "artifact-template-velocity", - "file": "Templates/baseconfig-template.vtl" - }, - "baseconfig-mapping": { - "type": "artifact-mapping-resource", - "file": "Mappings/baseconfig-mapping.json" - } - } - }, - "resource-assignment-py": { - "type": "component-resource-assignment", - "properties": { - "request-id": "1234" - }, - "interfaces": { - "DefaultComponentNode": { - "operations": { - "process": { - "implementation": { - "primary": "component-script" - }, - "inputs": { - "action-name": { - "get_input": "action-name" - } - }, - "outputs": { - "resource-assignment-params": "", - "status": "" - } - } - } - } - }, - "artifacts": { - "component-script": { - "type": "artifact-script-python", - "file": "Scripts/baseconfig-template.vtl" - } - } - } - }, - "workflows": { - "activate-process": { - "steps": { - "call-resource-assignment": { - "description": "Invoke Resource Assignment Component", - "target": "resource-assignment", - "activities": [ - { - "call_operation": "ResourceAssignmentNode.process" - } - ], - "on_success": [ - "download-baseconfig" - ] - }, - "download-baseconfig": { - "description": "Call Download Base Config Component", - "target": "activate-netconf", - "activities": [ - { - "call_operation": "NetconfTransactionNode.process" - } - ], - "on_success": [ - "download-licence" - ] - }, - "download-licence": { - "description": "Call Download Licence Component", - "target": "activate-netconf", - "activities": [ - { - "call_operation": "NetconfTransactionNode.process" - } - ] - } - } - } - } - }, - "artifact_types": { - "artifact-template-velocity": { - "description": " Velocity Template used for Configuration", - "version": "1.0.0", - "file_ext": [ - "vtl" - ], - "derived_from": "tosca.artifacts.Implementation" - }, - "artifact-mapping-resource": { - "description": " Velocity Template Resource Mapping File used along with Configuration template", - "version": "1.0.0", - "file_ext": [ - "json" - ], - "derived_from": "tosca.artifacts.Implementation" - }, - "artifact-script-kotlin": { - "description": " Kotlin Script Template used for Configuration", - "version": "1.0.0", - "file_ext": [ - "kt" - ], - "derived_from": "tosca.artifacts.Implementation" - }, - "artifact-script-python": { - "description": " Kotlin Script Template used for Configuration", - "version": "1.0.0", - "file_ext": [ - "py" - ], - "derived_from": "tosca.artifacts.Implementation" - }, - "artifact-bpmn-camunda": { - "description": " Camunda BPM File", - "version": "1.0.0", - "file_ext": [ - "bpmn" - ], - "derived_from": "tosca.artifacts.Implementation" - }, - "artifact-component-jar": { - "description": "Component Jar", - "version": "1.0.0", - "file_ext": [ - "jar" - ], - "derived_from": "tosca.artifacts.Implementation" - } - }, - "node_types": { - "bpmn-activate": { - "description": "This is BPMN Activate node type", - "version": "1.0.0", - "properties": { - "content": { - "required": false, - "type": "string" - }, - "process-name": { - "required": false, - "type": "string" - }, - "version": { - "required": false, - "type": "string", - "default": "LATEST" - } - }, - "derived_from": "tosca.nodes.DG" - }, - "tosca.nodes.Component": { - "description": "This is Resource Assignment Component API", - "version": "1.0.0", - "derived_from": "tosca.nodes.Root" - }, - "tosca.nodes.DG": { - "description": "This is Directed Graph Node Type", - "version": "1.0.0", - "derived_from": "tosca.nodes.Root" - }, - "tosca.nodes.component.Python": { - "description": "This is Resource Assignment Python Component API", - "version": "1.0.0", - "derived_from": "tosca.nodes.Root" - }, - "component-resource-assignment": { - "description": "This is Resource Assignment Component API", - "version": "1.0.0", - "properties": { - "request-id": { - "description": "Request Id used to store the generated configuration, in the database along with the template-name", - "required": true, - "type": "string" - } - }, - "interfaces": { - "DefaultComponentNode": { - "operations": { - "process": { - "inputs": { - "action-name": { - "description": "Recipe 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": { - "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": "Id used to pull the data content from the data base. Either template-data or resource-id should be present", - "required": true, - "type": "string" - }, - "template-content": { - "description": "Id used to pull the data content from the data base. Either template-data or resource-id should be present", - "required": true, - "type": "string" - }, - "mapping-content": { - "description": "Id used to pull the data content from the data base. Either template-data or resource-id should be present", - "required": true, - "type": "string" - } - }, - "outputs": { - "resource-assignment-params": { - "required": true, - "type": "string" - }, - "status": { - "required": true, - "type": "string" - } - } - } - } - } - }, - "derived_from": "tosca.nodes.Component" - }, - "component-resource-assignment-python": { - "description": "This is Resource Assignment Component API", - "version": "1.0.0", - "properties": { - "request-id": { - "description": "Request Id used to store the generated configuration, in the database along with the template-name", - "required": true, - "type": "string" - } - }, - "interfaces": { - "DefaultComponentNode": { - "operations": { - "process": { - "inputs": { - "action-name": { - "description": "Recipe 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": { - "resource-assignment-params": { - "required": true, - "type": "string" - }, - "status": { - "required": true, - "type": "string" - } - } - } - } - } - }, - "derived_from": "tosca.nodes.component.Python" - } - }, - "data_types": { - "sample-property": { - "description": "This is sample data type", - "version": "1.0.0", - "properties": { - "content": { - "required": false, - "type": "string" - }, - "process-name": { - "required": false, - "type": "string" - }, - "version": { - "required": false, - "type": "string", - "default": "LATEST" - } - }, - "derived_from": "tosca.datatypes.Root" - } - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/blueprints/baseconfiguration/Mappings/baseconfig-mapping.json b/ms/controllerblueprints/application/load/blueprints/baseconfiguration/Mappings/baseconfig-mapping.json deleted file mode 100644 index caee773bb..000000000 --- a/ms/controllerblueprints/application/load/blueprints/baseconfiguration/Mappings/baseconfig-mapping.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "assignments": "Sample Assignments" -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/blueprints/baseconfiguration/Plans/ActivateProcess.bpmn b/ms/controllerblueprints/application/load/blueprints/baseconfiguration/Plans/ActivateProcess.bpmn deleted file mode 100644 index 89ae342f8..000000000 --- a/ms/controllerblueprints/application/load/blueprints/baseconfiguration/Plans/ActivateProcess.bpmn +++ /dev/null @@ -1,66 +0,0 @@ - - - - - SequenceFlow_0l0dq58 - - - SequenceFlow_1ay0k6p - - - - - - - - - - SequenceFlow_0l0dq58 - SequenceFlow_1ay0k6p - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ms/controllerblueprints/application/load/blueprints/baseconfiguration/Scripts/SamplePythonComponentNode.py b/ms/controllerblueprints/application/load/blueprints/baseconfiguration/Scripts/SamplePythonComponentNode.py deleted file mode 100644 index fc5151338..000000000 --- a/ms/controllerblueprints/application/load/blueprints/baseconfiguration/Scripts/SamplePythonComponentNode.py +++ /dev/null @@ -1,8 +0,0 @@ -from com.brvith.orchestrator.core.interfaces import ComponentNode - -class SamplePythonComponentNode(ComponentNode): - def prepare(self, context, componentContext): - return None - - def prepare(self, context, componentContext): - return None \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/blueprints/baseconfiguration/Scripts/__init__.py b/ms/controllerblueprints/application/load/blueprints/baseconfiguration/Scripts/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/ms/controllerblueprints/application/load/blueprints/baseconfiguration/TOSCA-Metadata/TOSCA.meta b/ms/controllerblueprints/application/load/blueprints/baseconfiguration/TOSCA-Metadata/TOSCA.meta deleted file mode 100644 index 9066e4845..000000000 --- a/ms/controllerblueprints/application/load/blueprints/baseconfiguration/TOSCA-Metadata/TOSCA.meta +++ /dev/null @@ -1,8 +0,0 @@ -TOSCA-Meta-File-Version: 1.0.0 -CSAR-Version: 1.0 -Created-By: Brinda Santh M -Entry-Definitions: Definitions/activation-blueprint.json -Template-Tags: Brinda Santh, activation-blueprint - -Name: Plans/ActivateProcess.bpmn -Content-Type: application/vnd.oasis.bpmn diff --git a/ms/controllerblueprints/application/load/blueprints/baseconfiguration/Templates/baseconfig-template.vtl b/ms/controllerblueprints/application/load/blueprints/baseconfiguration/Templates/baseconfig-template.vtl deleted file mode 100644 index 026c59176..000000000 --- a/ms/controllerblueprints/application/load/blueprints/baseconfiguration/Templates/baseconfig-template.vtl +++ /dev/null @@ -1 +0,0 @@ -This is Sample Velocity Template \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/blueprints/baseconfiguration/__init__.py b/ms/controllerblueprints/application/load/blueprints/baseconfiguration/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/ms/controllerblueprints/application/load/blueprints/vFW/Definitions/vFW_spinup.json b/ms/controllerblueprints/application/load/blueprints/vFW/Definitions/vFW_spinup.json deleted file mode 100644 index d5416c0ea..000000000 --- a/ms/controllerblueprints/application/load/blueprints/vFW/Definitions/vFW_spinup.json +++ /dev/null @@ -1,3613 +0,0 @@ -{ - "metadata": { - "template_author": "aa0419", - "template_name": "vFW_spinup", - "template_version": "1.0.0", - "service-type": "vFW", - "template_tags": "vFW, ONAP", - "release": "1810", - "vnf-type": "VFW" - }, - "topology_template": { - "inputs": { - "request-id": { - "required": true, - "type": "string" - }, - "service-instance-id": { - "required": true, - "type": "string" - }, - "scope-type": { - "required": true, - "type": "string" - }, - "action-name": { - "required": true, - "type": "string" - }, - "hostname": { - "required": true, - "type": "string" - }, - "resource-assignment-request": { - "description": "This is Dynamic Data type for the receipe resource-assignment-action.", - "required": false, - "type": "dt-resource-assignment-request" - } - }, - "node_templates": { - "resource-assignment-ra-component": { - "type": "component-resource-assignment", - "interfaces": { - "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode": { - "operations": { - "process": { - "inputs": { - "action-name": "{ \"get_input\" : \"action-name\" }", - "service-template-name": "{ \"get_attribute\" : \"service-template-name\" }", - "template-names": [ - "vFW_vNF_Artifact", - "base_template", - "vfw", - "vsn", - "vpg" - ], - "service-template-version": "{ \"get_attribute\" : \"service-template-version\" }", - "resource-type": "vnf-type", - "request-id": "{ \"get_input\" : \"request-id\" }", - "resource-id": "{ \"get_input\" : \"hostname\" }" - }, - "outputs": { - "resource-assignment-params": "Success", - "status": "status" - } - } - } - } - }, - "capabilities": { - "component-node": { - - } - } - }, - "resource-assignment-action": { - "type": "dg-resource-assignment", - "properties": { - "mode": "sync", - "version": "LATEST", - "is-start-flow": false - }, - "interfaces": { - "CONFIG": { - "operations": { - "ResourceAssignment": { - "inputs": { - "params": [ - - ] - } - } - } - } - }, - "capabilities": { - "dg-node": { - - }, - "content": { - "properties": { - "type": "json" - } - } - }, - "requirements": { - "component-dependency": { - "capability": "component-node", - "node": "resource-assignment-ra-component", - "relationship": "tosca.relationships.DependsOn" - } - } - }, - "vFW_vNF_Artifact": { - "type": "artifact-config-template", - "properties": { - "action-names": [ - "resource-assignment-action" - ] - }, - "capabilities": { - "content": { - "properties": { - "content": "vFW_vNF_Artifact" - } - }, - "mapping": { - "properties": { - "mapping": [ - { - "name": "service-instance-id", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "service-instance-id", - "dictionary-source": "input", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "vnf-id", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vnf-id", - "dictionary-source": "input", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "vnf-model-customization-uuid", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vnf-model-customization-uuid", - "dictionary-source": "input", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "aic-cloud-region", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "aic-cloud-region", - "dictionary-source": "input", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "onap_private_net_id", - "property": { - "description": "", - "required": false, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "onap_private_net_id", - "dictionary-source": "input", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "onap_private_subnet_id", - "property": { - "description": "", - "required": false, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "onap_private_subnet_id", - "dictionary-source": "input", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "key_name", - "property": { - "description": "", - "required": false, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "key_name", - "dictionary-source": "input", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "image_name", - "property": { - "description": "", - "required": false, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - }, - "default": "Ubuntu 14.04 LTS Generic" - }, - "input-param": false, - "dictionary-name": "image_name", - "dictionary-source": "input", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "pub_key", - "property": { - "description": "", - "required": false, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - }, - "default": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDKXDgoo3+WOqcUG8/5uUbk81+yczgwC4Y8ywTmuQqbNxlY1oQ0YxdMUqUnhitSXs5S/yRuAVOYHwGg2mCs20oAINrP+mxBI544AMIb9itPjCtgqtE2EWo6MmnFGbHB4Sx3XioE7F4VPsh7japsIwzOjbrQe+Mua1TGQ5d4nfEOQaaglXLLPFfuc7WbhbJbK6Q7rHqZfRcOwAMXgDoBqlyqKeiKwnumddo2RyNT8ljYmvB6buz7KnMinzo7qB0uktVT05FH9Rg0CTWH5norlG5qXgP2aukL0gk1ph8iAt7uYLf1ktp+LJI2gaF6L0/qli9EmVCSLr1uJ38Q8CBflhkh" - }, - "input-param": false, - "dictionary-name": "pub_key", - "dictionary-source": "input", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "vnf_name", - "property": { - "description": "", - "required": false, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vnf_name", - "dictionary-source": "input", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "vf-naming-policy", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - }, - "default": "SDNC_Policy.Config_MS_ONAP_VFW_NAMING_TIMESTAMP" - }, - "input-param": false, - "dictionary-name": "vf-naming-policy", - "dictionary-source": "default", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "nf-role", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "nf-role", - "dictionary-source": "db", - "dependencies": [ - "vnf-model-customization-uuid" - ], - "version": 0 - }, - { - "name": "vfw_private_ip_1", - "property": { - "description": "", - "required": false, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vfw_private_ip_1", - "dictionary-source": "input", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "vfw_private_ip_0", - "property": { - "description": "", - "required": false, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vfw_private_ip_0", - "dictionary-source": "input", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "vpg_private_ip_0", - "property": { - "description": "", - "required": false, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vpg_private_ip_0", - "dictionary-source": "input", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "vsn_private_ip_0", - "property": { - "description": "", - "required": false, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vsn_private_ip_0", - "dictionary-source": "input", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "protected-prefix-id", - "property": { - "description": "", - "required": false, - "type": "integer", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "protected-prefix-id", - "dictionary-source": "db", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "unprotected-prefix-id", - "property": { - "description": "", - "required": false, - "type": "integer", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "unprotected-prefix-id", - "dictionary-source": "db", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "vf-nf-code", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vf-nf-code", - "dictionary-source": "db", - "dependencies": [ - "vnf-model-customization-uuid" - ], - "version": 0 - } - ] - } - } - } - }, - "vfw": { - "type": "artifact-config-template", - "capabilities": { - "content": { - "properties": { - "content": "vfw" - } - }, - "mapping": { - "properties": { - "mapping": [ - { - "name": "service-instance-id", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "service-instance-id", - "dictionary-source": "input", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "vnf-id", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vnf-id", - "dictionary-source": "input", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "vnf-name", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vnf-name", - "dictionary-source": "mdsal", - "dependencies": [ - "service-instance-id", - "vnf-id" - ], - "version": 0 - }, - { - "name": "vnf-model-customization-uuid", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vnf-model-customization-uuid", - "dictionary-source": "input", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "vf-module-id", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vf-module-id", - "dictionary-source": "input", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "vf-module-type", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vf-module-type", - "dictionary-source": "db", - "dependencies": [ - "vf-module-model-customization-uuid" - ], - "version": 0 - }, - { - "name": "vf-module-model-customization-uuid", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vf-module-model-customization-uuid", - "dictionary-source": "input", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "vfccustomizationuuid", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vfccustomizationuuid", - "dictionary-source": "db", - "dependencies": [ - "vf-module-model-customization-uuid" - ], - "version": 0 - }, - { - "name": "aic-cloud-region", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "aic-cloud-region", - "dictionary-source": "input", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "vm-type", - "property": { - "description": "", - "required": false, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vm-type", - "dictionary-source": "db", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "vnfc-model-invariant-uuid", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vnfc-model-invariant-uuid", - "dictionary-source": "db", - "dependencies": [ - "vfccustomizationuuid" - ], - "version": 0 - }, - { - "name": "vnfc-model-version", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vnfc-model-version", - "dictionary-source": "db", - "dependencies": [ - "vfccustomizationuuid" - ], - "version": 0 - }, - { - "name": "nf-role", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - }, - "default": "vFW" - }, - "input-param": false, - "dictionary-name": "nf-role", - "dictionary-source": "default", - "dependencies": [ - "vnf-model-customization-uuid" - ], - "version": 0 - }, - { - "name": "nfc-naming-code", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "nfc-naming-code", - "dictionary-source": "db", - "dependencies": [ - "vfccustomizationuuid" - ], - "version": 0 - }, - { - "name": "public_net_id", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - }, - "default": "public_net_id" - }, - "input-param": false, - "dictionary-name": "public_net_id", - "dictionary-source": "default", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "image_name", - "property": { - "description": "", - "required": false, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "image_name", - "dictionary-source": "mdsal", - "dependencies": [ - "service-instance-id", - "vnf-id" - ], - "version": 0 - }, - { - "name": "key_name", - "property": { - "description": "", - "required": false, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "key_name", - "dictionary-source": "mdsal", - "dependencies": [ - "service-instance-id", - "vnf-id" - ], - "version": 0 - }, - { - "name": "pub_key", - "property": { - "description": "", - "required": false, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "pub_key", - "dictionary-source": "mdsal", - "dependencies": [ - "service-instance-id", - "vnf-id" - ], - "version": 0 - }, - { - "name": "onap_private_net_id", - "property": { - "description": "", - "required": false, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "onap_private_net_id", - "dictionary-source": "mdsal", - "dependencies": [ - "service-instance-id", - "vnf-id" - ], - "version": 0 - }, - { - "name": "onap_private_subnet_id", - "property": { - "description": "", - "required": false, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "onap_private_subnet_id", - "dictionary-source": "mdsal", - "dependencies": [ - "service-instance-id", - "vnf-id" - ], - "version": 0 - }, - { - "name": "unprotected_private_net_cidr", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "unprotected_private_net_cidr", - "dictionary-source": "db", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "protected_private_net_cidr", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "protected_private_net_cidr", - "dictionary-source": "db", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "nexus_artifact_repo", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - }, - "default": "nexus_artifact_repo" - }, - "input-param": false, - "dictionary-name": "nexus_artifact_repo", - "dictionary-source": "default", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "sec_group", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - }, - "default": "onap_sg_PUhf" - }, - "input-param": false, - "dictionary-name": "sec_group", - "dictionary-source": "default", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "onap_private_net_cidr", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "onap_private_net_cidr", - "dictionary-source": "db", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "vfw_name_0", - "property": { - "description": "", - "required": false, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vfw_name_0", - "dictionary-source": "input", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "vf-naming-policy", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - }, - "default": "SDNC_Policy.Config_MS_ONAP_VFW_NAMING_TIMESTAMP" - }, - "input-param": false, - "dictionary-name": "vf-naming-policy", - "dictionary-source": "default", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "vf_module_name", - "property": { - "description": "", - "required": false, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vf_module_name", - "dictionary-source": "input", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "vf-module-label", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vf-module-label", - "dictionary-source": "db", - "dependencies": [ - "vf-module-model-customization-uuid" - ], - "version": 0 - }, - { - "name": "private-prefix-id", - "property": { - "description": "", - "required": false, - "type": "integer", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "private-prefix-id", - "dictionary-source": "db", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "vfw_private_ip_2", - "property": { - "description": "", - "required": false, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vfw_private_ip_2", - "dictionary-source": "input", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "vnf_name", - "property": { - "description": "", - "required": false, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vnf_name", - "dictionary-source": "input", - "dependencies": [ - - ], - "version": 0 - } - ] - } - } - } - }, - "vpg": { - "type": "artifact-config-template", - "capabilities": { - "content": { - "properties": { - "content": "vpg" - } - }, - "mapping": { - "properties": { - "mapping": [ - { - "name": "service-instance-id", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "service-instance-id", - "dictionary-source": "input", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "vnf-id", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vnf-id", - "dictionary-source": "input", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "vnf-name", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vnf-name", - "dictionary-source": "mdsal", - "dependencies": [ - "service-instance-id", - "vnf-id" - ], - "version": 0 - }, - { - "name": "vnf-model-customization-uuid", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vnf-model-customization-uuid", - "dictionary-source": "input", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "vf-module-id", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vf-module-id", - "dictionary-source": "input", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "vf-module-type", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vf-module-type", - "dictionary-source": "db", - "dependencies": [ - "vf-module-model-customization-uuid" - ], - "version": 0 - }, - { - "name": "vf-module-model-customization-uuid", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vf-module-model-customization-uuid", - "dictionary-source": "input", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "vfccustomizationuuid", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vfccustomizationuuid", - "dictionary-source": "db", - "dependencies": [ - "vf-module-model-customization-uuid" - ], - "version": 0 - }, - { - "name": "aic-cloud-region", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "aic-cloud-region", - "dictionary-source": "input", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "vm-type", - "property": { - "description": "", - "required": false, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vm-type", - "dictionary-source": "db", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "vnfc-model-invariant-uuid", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vnfc-model-invariant-uuid", - "dictionary-source": "db", - "dependencies": [ - "vfccustomizationuuid" - ], - "version": 0 - }, - { - "name": "vnfc-model-version", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vnfc-model-version", - "dictionary-source": "db", - "dependencies": [ - "vfccustomizationuuid" - ], - "version": 0 - }, - { - "name": "nf-role", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - }, - "default": "vPG" - }, - "input-param": false, - "dictionary-name": "nf-role", - "dictionary-source": "default", - "dependencies": [ - "vnf-model-customization-uuid" - ], - "version": 0 - }, - { - "name": "nfc-naming-code", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "nfc-naming-code", - "dictionary-source": "db", - "dependencies": [ - "vfccustomizationuuid" - ], - "version": 0 - }, - { - "name": "public_net_id", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - }, - "default": "public_net_id" - }, - "input-param": false, - "dictionary-name": "public_net_id", - "dictionary-source": "default", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "image_name", - "property": { - "description": "", - "required": false, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "image_name", - "dictionary-source": "mdsal", - "dependencies": [ - "service-instance-id", - "vnf-id" - ], - "version": 0 - }, - { - "name": "key_name", - "property": { - "description": "", - "required": false, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "key_name", - "dictionary-source": "mdsal", - "dependencies": [ - "service-instance-id", - "vnf-id" - ], - "version": 0 - }, - { - "name": "pub_key", - "property": { - "description": "", - "required": false, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "pub_key", - "dictionary-source": "mdsal", - "dependencies": [ - "service-instance-id", - "vnf-id" - ], - "version": 0 - }, - { - "name": "onap_private_net_id", - "property": { - "description": "", - "required": false, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "onap_private_net_id", - "dictionary-source": "mdsal", - "dependencies": [ - "service-instance-id", - "vnf-id" - ], - "version": 0 - }, - { - "name": "onap_private_subnet_id", - "property": { - "description": "", - "required": false, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "onap_private_subnet_id", - "dictionary-source": "mdsal", - "dependencies": [ - "service-instance-id", - "vnf-id" - ], - "version": 0 - }, - { - "name": "unprotected_private_net_cidr", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "unprotected_private_net_cidr", - "dictionary-source": "db", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "onap_private_net_cidr", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "onap_private_net_cidr", - "dictionary-source": "db", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "vfw_private_ip_0", - "property": { - "description": "", - "required": false, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vfw_private_ip_0", - "dictionary-source": "mdsal", - "dependencies": [ - "service-instance-id", - "vnf-id" - ], - "version": 0 - }, - { - "name": "vsn_private_ip_0", - "property": { - "description": "", - "required": false, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vsn_private_ip_0", - "dictionary-source": "mdsal", - "dependencies": [ - "service-instance-id", - "vnf-id" - ], - "version": 0 - }, - { - "name": "nexus_artifact_repo", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - }, - "default": "nexus_artifact_repo" - }, - "input-param": false, - "dictionary-name": "nexus_artifact_repo", - "dictionary-source": "default", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "sec_group", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - }, - "default": "onap_sg_PUhf" - }, - "input-param": false, - "dictionary-name": "sec_group", - "dictionary-source": "default", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "vpg_private_ip_0", - "property": { - "description": "", - "required": false, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vpg_private_ip_0", - "dictionary-source": "mdsal", - "dependencies": [ - "service-instance-id", - "vnf-id" - ], - "version": 0 - }, - { - "name": "vpg_name_0", - "property": { - "description": "", - "required": false, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vpg_name_0", - "dictionary-source": "input", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "vf-naming-policy", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - }, - "default": "SDNC_Policy.Config_MS_ONAP_VPG_NAMING_TIMESTAMP" - }, - "input-param": false, - "dictionary-name": "vf-naming-policy", - "dictionary-source": "default", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "vf_module_name", - "property": { - "description": "", - "required": false, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vf_module_name", - "dictionary-source": "input", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "vf-module-label", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vf-module-label", - "dictionary-source": "db", - "dependencies": [ - "vf-module-model-customization-uuid" - ], - "version": 0 - }, - { - "name": "private-prefix-id", - "property": { - "description": "", - "required": false, - "type": "integer", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "private-prefix-id", - "dictionary-source": "db", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "vpg_private_ip_1", - "property": { - "description": "", - "required": false, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vpg_private_ip_1", - "dictionary-source": "input", - "dependencies": [ - - ], - "version": 0 - } - ] - } - } - } - }, - "vsn": { - "type": "artifact-config-template", - "capabilities": { - "content": { - "properties": { - "content": "vsn" - } - }, - "mapping": { - "properties": { - "mapping": [ - { - "name": "service-instance-id", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "service-instance-id", - "dictionary-source": "input", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "vnf-id", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vnf-id", - "dictionary-source": "input", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "vnf-name", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vnf-name", - "dictionary-source": "mdsal", - "dependencies": [ - "service-instance-id", - "vnf-id" - ], - "version": 0 - }, - { - "name": "vnf-model-customization-uuid", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vnf-model-customization-uuid", - "dictionary-source": "input", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "vf-module-id", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vf-module-id", - "dictionary-source": "input", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "vf-module-type", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vf-module-type", - "dictionary-source": "db", - "dependencies": [ - "vf-module-model-customization-uuid" - ], - "version": 0 - }, - { - "name": "vf-module-model-customization-uuid", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vf-module-model-customization-uuid", - "dictionary-source": "input", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "vfccustomizationuuid", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vfccustomizationuuid", - "dictionary-source": "db", - "dependencies": [ - "vf-module-model-customization-uuid" - ], - "version": 0 - }, - { - "name": "aic-cloud-region", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "aic-cloud-region", - "dictionary-source": "input", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "vm-type", - "property": { - "description": "", - "required": false, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vm-type", - "dictionary-source": "db", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "vnfc-model-invariant-uuid", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vnfc-model-invariant-uuid", - "dictionary-source": "db", - "dependencies": [ - "vfccustomizationuuid" - ], - "version": 0 - }, - { - "name": "vnfc-model-version", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vnfc-model-version", - "dictionary-source": "db", - "dependencies": [ - "vfccustomizationuuid" - ], - "version": 0 - }, - { - "name": "nf-role", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - }, - "default": "vSN" - }, - "input-param": false, - "dictionary-name": "nf-role", - "dictionary-source": "default", - "dependencies": [ - "vnf-model-customization-uuid" - ], - "version": 0 - }, - { - "name": "nfc-naming-code", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "nfc-naming-code", - "dictionary-source": "db", - "dependencies": [ - "vfccustomizationuuid" - ], - "version": 0 - }, - { - "name": "image_name", - "property": { - "description": "", - "required": false, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "image_name", - "dictionary-source": "mdsal", - "dependencies": [ - "service-instance-id", - "vnf-id" - ], - "version": 0 - }, - { - "name": "public_net_id", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - }, - "value": "public_net_id", - "default": "public_net_id" - }, - "input-param": false, - "dictionary-name": "public_net_id", - "dictionary-source": "default", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "key_name", - "property": { - "description": "", - "required": false, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "key_name", - "dictionary-source": "mdsal", - "dependencies": [ - "service-instance-id", - "vnf-id" - ], - "version": 0 - }, - { - "name": "pub_key", - "property": { - "description": "", - "required": false, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "pub_key", - "dictionary-source": "mdsal", - "dependencies": [ - "service-instance-id", - "vnf-id" - ], - "version": 0 - }, - { - "name": "onap_private_net_id", - "property": { - "description": "", - "required": false, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "onap_private_net_id", - "dictionary-source": "mdsal", - "dependencies": [ - "service-instance-id", - "vnf-id" - ], - "version": 0 - }, - { - "name": "onap_private_subnet_id", - "property": { - "description": "", - "required": false, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "onap_private_subnet_id", - "dictionary-source": "mdsal", - "dependencies": [ - "service-instance-id", - "vnf-id" - ], - "version": 0 - }, - { - "name": "unprotected_private_net_cidr", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "unprotected_private_net_cidr", - "dictionary-source": "db", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "protected_private_net_cidr", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "protected_private_net_cidr", - "dictionary-source": "db", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "onap_private_net_cidr", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "onap_private_net_cidr", - "dictionary-source": "db", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "nexus_artifact_repo", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - }, - "value": "nexus_artifact_repo", - "default": "nexus_artifact_repo" - }, - "input-param": false, - "dictionary-name": "nexus_artifact_repo", - "dictionary-source": "default", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "sec_group", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - }, - "default": "onap_sg_PUhf" - }, - "input-param": false, - "dictionary-name": "sec_group", - "dictionary-source": "default", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "vfw_private_ip_1", - "property": { - "description": "", - "required": false, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vfw_private_ip_1", - "dictionary-source": "mdsal", - "dependencies": [ - "service-instance-id", - "vnf-id" - ], - "version": 0 - }, - { - "name": "vsn_name_0", - "property": { - "description": "", - "required": false, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vsn_name_0", - "dictionary-source": "input", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "vf-naming-policy", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - }, - "default": "SDNC_Policy.Config_MS_ONAP_VSN_NAMING_TIMESTAMP" - }, - "input-param": false, - "dictionary-name": "vf-naming-policy", - "dictionary-source": "default", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "vf_module_name", - "property": { - "description": "", - "required": false, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vf_module_name", - "dictionary-source": "input", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "vf-module-label", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vf-module-label", - "dictionary-source": "db", - "dependencies": [ - "vf-module-model-customization-uuid" - ], - "version": 0 - }, - { - "name": "private-prefix-id", - "property": { - "description": "", - "required": false, - "type": "integer", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "private-prefix-id", - "dictionary-source": "db", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "vsn_private_ip_1", - "property": { - "description": "", - "required": false, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vsn_private_ip_1", - "dictionary-source": "input", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "protected-prefix-id", - "property": { - "description": "", - "required": false, - "type": "integer", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "protected-prefix-id", - "dictionary-source": "db", - "dependencies": [ - - ], - "version": 0 - } - ] - } - } - } - }, - "base_template": { - "type": "artifact-config-template", - "capabilities": { - "content": { - "properties": { - "content": "base_template" - } - }, - "mapping": { - "properties": { - "mapping": [ - { - "name": "service-instance-id", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "service-instance-id", - "dictionary-source": "input", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "vf-module-type", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vf-module-type", - "dictionary-source": "db", - "dependencies": [ - "vf-module-model-customization-uuid" - ], - "version": 0 - }, - { - "name": "vf-module-model-customization-uuid", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vf-module-model-customization-uuid", - "dictionary-source": "input", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "vnf-id", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vnf-id", - "dictionary-source": "input", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "vf-module-id", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vf-module-id", - "dictionary-source": "input", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "vnf-model-customization-uuid", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vnf-model-customization-uuid", - "dictionary-source": "input", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "aic-cloud-region", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "aic-cloud-region", - "dictionary-source": "input", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "nf-role", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "nf-role", - "dictionary-source": "db", - "dependencies": [ - "vnf-model-customization-uuid" - ], - "version": 0 - }, - { - "name": "vnf-name", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "vnf-name", - "dictionary-source": "mdsal", - "dependencies": [ - "service-instance-id", - "vnf-id" - ], - "version": 0 - }, - { - "name": "unprotected_private_net_cidr", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "unprotected_private_net_cidr", - "dictionary-source": "db", - "dependencies": [ - - ], - "version": 0 - }, - { - "name": "protected_private_net_cidr", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "protected_private_net_cidr", - "dictionary-source": "db", - "dependencies": [ - - ], - "version": 0 - } - ] - } - } - } - } - } - }, - "node_types": { - "tosca.nodes.Component": { - "description": "This is default Component Node", - "version": "1.0.0", - "derived_from": "tosca.nodes.Root" - }, - "tosca.nodes.DG": { - "description": "This is Directed Graph 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" - }, - "component-resource-assignment": { - "description": "This is Resource Assignment Component API", - "version": "1.0.0", - "capabilities": { - "component-node": { - "type": "tosca.capabilities.Node" - } - }, - "interfaces": { - "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode": { - "operations": { - "process": { - "inputs": { - "action-name": { - "description": "Action Name of the process", - "required": true, - "type": "string" - }, - "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" - } - }, - "outputs": { - "resource-assignment-params": { - "required": true, - "type": "string" - }, - "status": { - "required": true, - "type": "string" - } - } - } - } - } - }, - "derived_from": "tosca.nodes.Component" - }, - "dg-resource-assignment": { - "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.capabilities.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" - }, - "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" - } - }, - "data_types": { - "datatype-property": { - "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" - }, - "datatype-resource-assignment": { - "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" - }, - "dt-resource-assignment-request": { - "version": "1.0.0", - "description": "This is Dynamic Data type definition generated from resource mapping for the config template name activate-template.", - "properties": { - "password-user-ftap-nsm": { - "required": true, - "type": "string", - "default": "password-user-ftap" - }, - "reservation-id": { - "required": true, - "type": "string", - "value": "123" - }, - "security-manager-resource-key": { - "required": true, - "type": "string", - "value": "sdnc" - }, - "password-user-ftap": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "entry_schema": { - "type": "" - } - } - }, - "derived_from": "tosca.datatypes.Dynamic" - } - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/blueprints/vFW/TOSCA-Metadata/TOSCA.meta b/ms/controllerblueprints/application/load/blueprints/vFW/TOSCA-Metadata/TOSCA.meta deleted file mode 100644 index 7918c1159..000000000 --- a/ms/controllerblueprints/application/load/blueprints/vFW/TOSCA-Metadata/TOSCA.meta +++ /dev/null @@ -1,6 +0,0 @@ -TOSCA-Meta-File-Version: 1.0.0 -CSAR-Version: 1.0 -Created-By: ONAP -Entry-Definitions: Definitions/vFW_spinup.json -Template-Tags: ONAP, vFW -Content-Type: application/vnd.oasis.bpmn diff --git a/ms/controllerblueprints/application/load/blueprints/vFW/Templates/base_template.vtl b/ms/controllerblueprints/application/load/blueprints/vFW/Templates/base_template.vtl deleted file mode 100644 index 1f8298c5f..000000000 --- a/ms/controllerblueprints/application/load/blueprints/vFW/Templates/base_template.vtl +++ /dev/null @@ -1,56 +0,0 @@ -{ - "resource-accumulator-resolved-data": [ - { - "param-name": "service-instance-id", - "param-value": "${service-instance-id}" - }, - { - "param-name": "vnf_id", - "param-value": "${vnf-id}" - }, - { - "param-name": "vnf_name", - "param-value": "${vnf-name}" - }, - { - "param-name": "vnf_model_customization_uuid", - "param-value": "${vnf-model-customization-uuid}" - }, - { - "param-name": "vf_module_id", - "param-value": "${vf-module-id}" - }, - { - "param-name": "vf_module_type", - "param-value": "${vf-module-type}" - }, - { - "param-name": "unprotected_private_net_id", - "param-value": "${vnf-name}_unprotected" - }, - { - "param-name": "unprotected_private_subnet_id", - "param-value": "${vnf-name}_unprotected_sub" - }, - { - "param-name": "unprotected_private_net_cidr", - "param-value": "${unprotected_private_net_cidr}" - }, - { - "param-name": "protected_private_net_id", - "param-value": "${vnf-name}_protected" - }, - { - "param-name": "protected_private_subnet_id", - "param-value": "${vnf-name}_protected_sub" - }, - { - "param-name": "protected_private_net_cidr", - "param-value": "${protected_private_net_cidr}" - }, - { - "param-name": "vf_module_name", - "param-value": "${vnf-name}_base" - } - ] -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/blueprints/vFW/Templates/vFW_vNF_Artifact.vtl b/ms/controllerblueprints/application/load/blueprints/vFW/Templates/vFW_vNF_Artifact.vtl deleted file mode 100644 index ca09046aa..000000000 --- a/ms/controllerblueprints/application/load/blueprints/vFW/Templates/vFW_vNF_Artifact.vtl +++ /dev/null @@ -1,203 +0,0 @@ -{ - "resource-accumulator-resolved-data": [ - { - "param-name": "service-instance-id", - "param-value": "${service-instance-id}" - }, - { - "param-name": "vnf_id", - "param-value": "${vnf-id}" - }, - { - "param-name": "vnf-model-customization-uuid", - "param-value": "${vnf-model-customization-uuid}" - }, - { - "param-name": "aic-cloud-region", - "param-value": "${aic-cloud-region}" - }, - { - "param-name": "onap_private_net_id", - "param-value": "${onap_private_net_id}" - }, - { - "param-name": "pub_key", - "param-value": "${pub_key}" - }, - { - "param-name": "image_name", - "param-value": "${image_name}" - }, - { - "param-name": "onap_private_subnet_id", - "param-value": "${onap_private_net_id}_sub" - } - ], - "capability-data": [ - { - "capability-name": "generate-name", - "key-mapping": [ - { - "payload": [ - { - "param-name": "resource-name", - "param-value": "vnf_name" - }, - { - "param-name": "resource-value", - "param-value": "${vnf_name}" - }, - { - "param-name": "external-key", - "param-value": "${vnf-id}_vnf_name" - }, - { - "param-name": "policy-instance-name", - "param-value": "${vf-naming-policy}" - }, - { - "param-name": "nf-role", - "param-value": "${nf-role}" - }, - { - "param-name": "naming-type", - "param-value": "VNF" - }, - { - "param-name": "AIC_CLOUD_REGION", - "param-value": "${aic-cloud-region}" - } - ], - "output-key-mapping": [ - { - "resource-name": "vnf_name", - "resource-value": "${vnf_name}" - } - ] - } - ] - }, - { - "capability-name": "netbox-ip-assign", - "key-mapping": [ - { - "payload": [ - { - "param-name": "service-instance-id", - "param-value": "${service-instance-id}" - }, - { - "param-name": "prefix-id", - "param-value": "${protected-prefix-id}" - }, - { - "param-name": "vnf-id", - "param-value": "${vnf-id}" - }, - { - "param-name": "external_key", - "param-value": "${vnf-id}-vfw_private_ip_1" - } - ], - "output-key-mapping": [ - { - "resource-name": "vfw_private_ip_1", - "resource-value": "${vfw_private_ip_1}" - } - ] - }, - { - "payload": [ - { - "param-name": "service-instance-id", - "param-value": "${service-instance-id}" - }, - { - "param-name": "prefix-id", - "param-value": "${unprotected-prefix-id}" - }, - { - "param-name": "vnf-id", - "param-value": "${vnf-id}" - }, - { - "param-name": "external_key", - "param-value": "${vnf-id}-vfw_private_ip_0" - } - ], - "output-key-mapping": [ - { - "resource-name": "vfw_private_ip_0", - "resource-value": "${vfw_private_ip_0}" - } - ] - }, - { - "payload": [ - { - "param-name": "service-instance-id", - "param-value": "${service-instance-id}" - }, - { - "param-name": "prefix-id", - "param-value": "${unprotected-prefix-id}" - }, - { - "param-name": "vnf-id", - "param-value": "${vnf-id}" - }, - { - "param-name": "external_key", - "param-value": "${vnf-id}-vpg_private_ip_0" - } - ], - "output-key-mapping": [ - { - "resource-name": "vpg_private_ip_0", - "resource-value": "${vpg_private_ip_0}" - } - ] - }, - { - "payload": [ - { - "param-name": "service-instance-id", - "param-value": "${service-instance-id}" - }, - { - "param-name": "prefix-id", - "param-value": "${protected-prefix-id}" - }, - { - "param-name": "vnf-id", - "param-value": "${vnf-id}" - }, - { - "param-name": "external_key", - "param-value": "${vnf-id}-vsn_private_ip_0" - } - ], - "output-key-mapping": [ - { - "resource-name": "vsn_private_ip_0", - "resource-value": "${vsn_private_ip_0}" - } - ] - } - ] - }, - { - "capability-name": "unresolved-composite-data", - "key-mapping": [ - { - "output-key-mapping": [ - { - "resource-name": "key_name", - "resource-value": "${vnf_name}_key" - } - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/blueprints/vFW/Templates/vfw.vtl b/ms/controllerblueprints/application/load/blueprints/vFW/Templates/vfw.vtl deleted file mode 100644 index 06a91d3a1..000000000 --- a/ms/controllerblueprints/application/load/blueprints/vFW/Templates/vfw.vtl +++ /dev/null @@ -1,315 +0,0 @@ -{ - "resource-accumulator-resolved-data": [ - { - "param-name": "service-instance-id", - "param-value": "${service-instance-id}" - }, - { - "param-name": "vnf_id", - "param-value": "${vnf-id}" - }, - { - "param-name": "vnf_name", - "param-value": "${vnf-name}" - }, - { - "param-name": "vnf_model_customization_uuid", - "param-value": "${vnf-model-customization-uuid}" - }, - { - "param-name": "vf_module_id", - "param-value": "${vnf-id}" - }, - { - "param-name": "vf_module_type", - "param-value": "${vf-module-type}" - }, - { - "param-name": "vf_module_customization_uuid", - "param-value": "${vf-module-model-customization-uuid}" - }, - { - "param-name": "vfc_customization_uuid", - "param-value": "${vfccustomizationuuid}" - }, - { - "param-name": "aic-cloud-region", - "param-value": "${aic-cloud-region}" - }, - { - "param-name": "vm-type", - "param-value": "${vm-type}" - }, - { - "param-name": "vnfc-model-customization-uuid", - "param-value": "${vfccustomizationuuid}" - }, - { - "param-name": "vnfc-model-invariant-uuid", - "param-value": "${vnfc-model-invariant-uuid}" - }, - { - "param-name": "vnfc-model-version", - "param-value": "${vnfc-model-version}" - }, - { - "param-name": "nfc-function", - "param-value": "${nf-role}" - }, - { - "param-name": "nfc-naming-code", - "param-value": "${nfc-naming-code}" - }, - { - "param-name": "cloud_env", - "param-value": "openstack" - }, - { - "param-name": "repo_url_artifacts", - "param-value": "https://nexus.onap.org/content/groups/staging" - }, - { - "param-name": "repo_url_blob", - "param-value": "https://nexus.onap.org/content/repositories/raw" - }, - { - "param-name": "dcae_collector_port", - "param-value": "8080" - }, - { - "param-name": "image_name", - "param-value": "${image_name}" - }, - { - "param-name": "flavor_name", - "param-value": "m1.medium" - }, - { - "param-name": "install_script_version", - "param-value": "1.2.1-SNAPSHOT" - }, - { - "param-name": "demo_artifacts_version", - "param-value": "1.2.1-SNAPSHOT" - }, - { - "param-name": "dcae_collector_ip", - "param-value": "10.0.4.1" - }, - { - "param-name": "key_name", - "param-value": "${key_name}" - }, - { - "param-name": "pub_key", - "param-value": "${pub_key}" - }, - { - "param-name": "public_net_id", - "param-value": "${public_net_id}" - }, - { - "param-name": "unprotected_private_net_id", - "param-value": "${vnf-name}_unprotected" - }, - { - "param-name": "protected_private_net_id", - "param-value": "${vnf-name}_protected" - }, - { - "param-name": "onap_private_net_id", - "param-value": "${onap_private_net_id}" - }, - { - "param-name": "onap_private_subnet_id", - "param-value": "${onap_private_subnet_id}" - }, - { - "param-name": "unprotected_private_net_cidr", - "param-value": "${unprotected_private_net_cidr}" - }, - { - "param-name": "protected_private_net_cidr", - "param-value": "${protected_private_net_cidr}" - }, - { - "param-name": "unprotected_private_subnet_id", - "param-value": "${vnf-name}_unprotected_sub" - }, - { - "param-name": "unprotected_private_net_cidr", - "param-value": "${unprotected_private_net_cidr}" - }, - { - "param-name": "protected_private_subnet_id", - "param-value": "${vnf-name}_protected_sub" - }, - { - "param-name": "nexus_artifact_repo", - "param-value": "${nexus_artifact_repo}" - }, - { - "param-name": "sec_group", - "param-value": "${sec_group}" - }, - { - "param-name": "onap_private_net_cidr", - "param-value": "${onap_private_net_cidr}" - } - ], - "capability-data": [ - { - "capability-name": "generate-name", - "key-mapping": [ - { - "payload": [ - { - "param-name": "resource-name", - "param-value": "vfw_name_0" - }, - { - "param-name": "resource-value", - "param-value": "${vfw_name_0}" - }, - { - "param-name": "external-key", - "param-value": "${vf-module-id}_vfw_name_0" - }, - { - "param-name": "policy-instance-name", - "param-value": "${vf-naming-policy}" - }, - { - "param-name": "nf-role", - "param-value": "${nf-role}" - }, - { - "param-name": "naming-type", - "param-value": "VNFC" - }, - { - "param-name": "VNF_NAME", - "param-value": "${vnf-name}" - }, - { - "param-name": "NFC_NAMING_CODE", - "param-value": "${nfc-naming-code}" - } - ], - "output-key-mapping": [ - { - "resource-name": "vfw_name_0", - "resource-value": "${vfw_name_0}" - } - ] - }, - { - "payload": [ - { - "param-name": "resource-name", - "param-value": "vf_module_name" - }, - { - "param-name": "resource-value", - "param-value": "${vf_module_name}" - }, - { - "param-name": "external-key", - "param-value": "${vf-module-id}_vf_module_name" - }, - { - "param-name": "policy-instance-name", - "param-value": "${vf-naming-policy}" - }, - { - "param-name": "nf-role", - "param-value": "${nf-role}" - }, - { - "param-name": "naming-type", - "param-value": "VF-MODULE" - }, - { - "param-name": "VNF_NAME", - "param-value": "${vnf-name}" - }, - { - "param-name": "VF_MODULE_LABEL", - "param-value": "${vf-module-label}" - }, - { - "param-name": "VF_MODULE_TYPE", - "param-value": "${vf-module-type}" - } - ], - "output-key-mapping": [ - { - "resource-name": "vf_module_name", - "resource-value": "${vf_module_name}" - } - ] - } - ] - }, - { - "capability-name": "netbox-ip-assign", - "key-mapping": [ - { - "payload": [ - { - "param-name": "service-instance-id", - "param-value": "${service-instance-id}" - }, - { - "param-name": "prefix-id", - "param-value": "${private-prefix-id}" - }, - { - "param-name": "vf-module-id", - "param-value": "${vf-module-id}" - }, - { - "param-name": "external_key", - "param-value": "${vf-module-id}-vfw_private_ip_2" - } - ], - "output-key-mapping": [ - { - "resource-name": "vfw_private_ip_2", - "resource-value": "${vfw_private_ip_2}" - } - ] - } - ] - }, - { - "capability-name": "unresolved-composite-data", - "key-mapping": [ - { - "output-key-mapping": [ - { - "resource-name": "KEY", - "resource-value": "${vnf_name}" - }, - { - "resource-name": "vf-module-name", - "resource-value": "${vf_module_name}" - }, - { - "resource-name": "vnfc-name", - "resource-value": "${vfw_name_0}" - }, - { - "resource-name": "ipv4-oam-address", - "resource-value": "${vfw_private_ip_2}" - }, - { - "resource-name": "ipv4-oam-address-prefix", - "resource-value": "${onap_private_net_cidr}" - } - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/blueprints/vFW/Templates/vpg.vtl b/ms/controllerblueprints/application/load/blueprints/vFW/Templates/vpg.vtl deleted file mode 100644 index f7e3780a3..000000000 --- a/ms/controllerblueprints/application/load/blueprints/vFW/Templates/vpg.vtl +++ /dev/null @@ -1,315 +0,0 @@ -{ - "resource-accumulator-resolved-data": [ - { - "param-name": "service-instance-id", - "param-value": "${service-instance-id}" - }, - { - "param-name": "vnf_id", - "param-value": "${vnf-id}" - }, - { - "param-name": "vnf_name", - "param-value": "${vnf-name}" - }, - { - "param-name": "vnf_model_customization_uuid", - "param-value": "${vnf-model-customization-uuid}" - }, - { - "param-name": "vf_module_id", - "param-value": "${vf-module-id}" - }, - { - "param-name": "vf_module_type", - "param-value": "${vf-module-type}" - }, - { - "param-name": "vf_module_customization_uuid", - "param-value": "${vf-module-model-customization-uuid}" - }, - { - "param-name": "vfc_customization_uuid", - "param-value": "${vfccustomizationuuid}" - }, - { - "param-name": "aic-cloud-region", - "param-value": "${aic-cloud-region}" - }, - { - "param-name": "vm-type", - "param-value": "${vm-type}" - }, - { - "param-name": "vnfc-model-customization-uuid", - "param-value": "${vfccustomizationuuid}" - }, - { - "param-name": "vnfc-model-invariant-uuid", - "param-value": "${vnfc-model-invariant-uuid}" - }, - { - "param-name": "vnfc-model-version", - "param-value": "${vnfc-model-version}" - }, - { - "param-name": "nfc-function", - "param-value": "${nf-role}" - }, - { - "param-name": "nfc-naming-code", - "param-value": "${nfc-naming-code}" - }, - { - "param-name": "cloud_env", - "param-value": "openstack" - }, - { - "param-name": "repo_url_artifacts", - "param-value": "https://nexus.onap.org/content/groups/staging" - }, - { - "param-name": "repo_url_blob", - "param-value": "https://nexus.onap.org/content/repositories/raw" - }, - { - "param-name": "dcae_collector_port", - "param-value": "8080" - }, - { - "param-name": "image_name", - "param-value": "${image_name}" - }, - { - "param-name": "flavor_name", - "param-value": "m1.medium" - }, - { - "param-name": "key_name", - "param-value": "${key_name}" - }, - { - "param-name": "pub_key", - "param-value": "${pub_key}" - }, - { - "param-name": "install_script_version", - "param-value": "1.2.1-SNAPSHOT" - }, - { - "param-name": "demo_artifacts_version", - "param-value": "1.2.1-SNAPSHOT" - }, - { - "param-name": "dcae_collector_ip", - "param-value": "10.0.4.1" - }, - { - "param-name": "public_net_id", - "param-value": "${public_net_id}" - }, - { - "param-name": "protected_private_net_id", - "param-value": "zdfw1fwl01_protected" - }, - { - "param-name": "onap_private_net_id", - "param-value": "${onap_private_net_id}" - }, - { - "param-name": "onap_private_subnet_id", - "param-value": "${onap_private_subnet_id}" - }, - { - "param-name": "unprotected_private_net_id", - "param-value": "${vnf-name}_unprotected" - }, - { - "param-name": "unprotected_private_subnet_id", - "param-value": "${vnf-name}_unprotected_sub" - }, - { - "param-name": "unprotected_private_net_cidr", - "param-value": "${unprotected_private_net_cidr}" - }, - { - "param-name": "protected_private_subnet_id", - "param-value": "${vnf-name}_protected_sub" - }, - { - "param-name": "protected_private_net_id", - "param-value": "${vnf-name}_protected" - }, - { - "param-name": "onap_private_net_cidr", - "param-value": "${onap_private_net_cidr}" - }, - { - "param-name": "vfw_private_ip_0", - "param-value": "${vfw_private_ip_0}" - }, - { - "param-name": "vsn_private_ip_0", - "param-value": "${vsn_private_ip_0}" - }, - { - "param-name": "nexus_artifact_repo", - "param-value": "${nexus_artifact_repo}" - }, - { - "param-name": "sec_group", - "param-value": "${sec_group}" - }, - { - "param-name": "vpg_private_ip_0", - "param-value": "${vpg_private_ip_0}" - } - ], - "capability-data": [ - { - "capability-name": "generate-name", - "key-mapping": [ - { - "payload": [ - { - "param-name": "resource-name", - "param-value": "vpg_name_0" - }, - { - "param-name": "resource-value", - "param-value": "${vpg_name_0}" - }, - { - "param-name": "external-key", - "param-value": "${vf-module-id}_vpg_name_0" - }, - { - "param-name": "policy-instance-name", - "param-value": "${vf-naming-policy}" - }, - { - "param-name": "nf-role", - "param-value": "${nf-role}" - }, - { - "param-name": "naming-type", - "param-value": "VNFC" - }, - { - "param-name": "VNF_NAME", - "param-value": "${vnf-name}" - }, - { - "param-name": "NFC_NAMING_CODE", - "param-value": "${nfc-naming-code}" - } - ], - "output-key-mapping": [ - { - "resource-name": "vpg_name_0", - "resource-value": "${vpg_name_0}" - } - ] - }, - { - "payload": [ - { - "param-name": "resource-name", - "param-value": "vf_module_name" - }, - { - "param-name": "resource-value", - "param-value": "${vf_module_name}" - }, - { - "param-name": "external-key", - "param-value": "${vf-module-id}_vf_module_name" - }, - { - "param-name": "policy-instance-name", - "param-value": "${vf-naming-policy}" - }, - { - "param-name": "nf-role", - "param-value": "${nf-role}" - }, - { - "param-name": "naming-type", - "param-value": "VF-MODULE" - }, - { - "param-name": "VNF_NAME", - "param-value": "${vnf-name}" - }, - { - "param-name": "VF_MODULE_LABEL", - "param-value": "${vf-module-label}" - }, - { - "param-name": "VF_MODULE_TYPE", - "param-value": "${vf-module-type}" - } - ], - "output-key-mapping": [ - { - "resource-name": "vf_module_name", - "resource-value": "${vf_module_name}" - } - ] - } - ] - }, - { - "capability-name": "netbox-ip-assign", - "key-mapping": [ - { - "payload": [ - { - "param-name": "service-instance-id", - "param-value": "${service-instance-id}" - }, - { - "param-name": "prefix-id", - "param-value": "${private-prefix-id}" - }, - { - "param-name": "vf-module-id", - "param-value": "${vf-module-id}" - }, - { - "param-name": "external_key", - "param-value": "${vf-module-id}-vpg_private_ip_1" - } - ], - "output-key-mapping": [ - { - "resource-name": "vpg_private_ip_1", - "resource-value": "${vpg_private_ip_1}" - } - ] - } - ] - }, - { - "capability-name": "unresolved-composite-data", - "key-mapping": [ - { - "output-key-mapping": [ - { - "resource-name": "vf-module-name", - "resource-value": "${vf_module_name}" - }, - { - "resource-name": "vnfc-name", - "resource-value": "${vpg_name_0}" - }, - { - "resource-name": "ipv4-oam-address-prefix", - "resource-value": "${onap_private_net_cidr}" - } - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/blueprints/vFW/Templates/vsn.vtl b/ms/controllerblueprints/application/load/blueprints/vFW/Templates/vsn.vtl deleted file mode 100644 index 727427a63..000000000 --- a/ms/controllerblueprints/application/load/blueprints/vFW/Templates/vsn.vtl +++ /dev/null @@ -1,311 +0,0 @@ -{ - "resource-accumulator-resolved-data": [ - { - "param-name": "service-instance-id", - "param-value": "${service-instance-id}" - }, - { - "param-name": "vnf_id", - "param-value": "${vnf-id}" - }, - { - "param-name": "vnf_name", - "param-value": "${vnf-name}" - }, - { - "param-name": "vnf_model_customization_uuid", - "param-value": "${vnf-model-customization-uuid}" - }, - { - "param-name": "vf_module_id", - "param-value": "${vf-module-id}" - }, - { - "param-name": "vf_module_type", - "param-value": "${vf-module-type}" - }, - { - "param-name": "vf_module_customization_uuid", - "param-value": "${vf-module-model-customization-uuid}" - }, - { - "param-name": "vfc_customization_uuid", - "param-value": "${vfccustomizationuuid}" - }, - { - "param-name": "aic-cloud-region", - "param-value": "${aic-cloud-region}" - }, - { - "param-name": "vm-type", - "param-value": "${vm-type}" - }, - { - "param-name": "vnfc-model-customization-uuid", - "param-value": "${vfccustomizationuuid}" - }, - { - "param-name": "vnfc-model-invariant-uuid", - "param-value": "${vnfc-model-invariant-uuid}" - }, - { - "param-name": "vnfc-model-version", - "param-value": "${vnfc-model-version}" - }, - { - "param-name": "nfc-function", - "param-value": "${nf-role}" - }, - { - "param-name": "nfc-naming-code", - "param-value": "${nfc-naming-code}" - }, - { - "param-name": "cloud_env", - "param-value": "openstack" - }, - { - "param-name": "repo_url_artifacts", - "param-value": "https://nexus.onap.org/content/groups/staging" - }, - { - "param-name": "repo_url_blob", - "param-value": "https://nexus.onap.org/content/repositories/raw" - }, - { - "param-name": "dcae_collector_port", - "param-value": "8080" - }, - { - "param-name": "image_name", - "param-value": "${image_name}" - }, - { - "param-name": "flavor_name", - "param-value": "m1.medium" - }, - { - "param-name": "install_script_version", - "param-value": "1.2.1-SNAPSHOT" - }, - { - "param-name": "key_name", - "param-value": "${key_name}" - }, - { - "param-name": "pub_key", - "param-value": "${pub_key}" - }, - { - "param-name": "demo_artifacts_version", - "param-value": "1.2.1-SNAPSHOT" - }, - { - "param-name": "dcae_collector_ip", - "param-value": "10.0.4.1" - }, - { - "param-name": "public_net_id", - "param-value": "${public_net_id}" - }, - { - "param-name": "unprotected_private_net_id", - "param-value": "${vnf-name}_unprotected" - }, - { - "param-name": "protected_private_subnet_id", - "param-value": "${vnf-name}_protected_sub" - }, - { - "param-name": "protected_private_net_id", - "param-value": "${vnf-name}_protected" - }, - { - "param-name": "onap_private_net_id", - "param-value": "${onap_private_net_id}" - }, - { - "param-name": "onap_private_subnet_id", - "param-value": "${onap_private_subnet_id}" - }, - { - "param-name": "unprotected_private_net_cidr", - "param-value": "${unprotected_private_net_cidr}" - }, - { - "param-name": "protected_private_net_cidr", - "param-value": "${protected_private_net_cidr}" - }, - { - "param-name": "onap_private_net_cidr", - "param-value": "${onap_private_net_cidr}" - }, - { - "param-name": "nexus_artifact_repo", - "param-value": "${nexus_artifact_repo}" - }, - { - "param-name": "sec_group", - "param-value": "${sec_group}" - }, - { - "param-name": "vfw_private_ip_1", - "param-value": "${vfw_private_ip_1}" - } - ], - "capability-data": [ - { - "capability-name": "generate-name", - "key-mapping": [ - { - "payload": [ - { - "param-name": "resource-name", - "param-value": "vsn_name_0" - }, - { - "param-name": "resource-value", - "param-value": "${vsn_name_0}" - }, - { - "param-name": "external-key", - "param-value": "${vf-module-id}_vsn_name_0" - }, - { - "param-name": "policy-instance-name", - "param-value": "${vf-naming-policy}" - }, - { - "param-name": "nf-role", - "param-value": "${nf-role}" - }, - { - "param-name": "naming-type", - "param-value": "VNFC" - }, - { - "param-name": "VNF_NAME", - "param-value": "${vnf-name}" - }, - { - "param-name": "NFC_NAMING_CODE", - "param-value": "${nfc-naming-code}" - } - ], - "output-key-mapping": [ - { - "resource-name": "vsn_name_0", - "resource-value": "${vsn_name_0}" - } - ] - }, - { - "payload": [ - { - "param-name": "resource-name", - "param-value": "vf_module_name" - }, - { - "param-name": "resource-value", - "param-value": "${vf_module_name}" - }, - { - "param-name": "external-key", - "param-value": "${vf-module-id}_vf_module_name" - }, - { - "param-name": "policy-instance-name", - "param-value": "${vf-naming-policy}" - }, - { - "param-name": "nf-role", - "param-value": "${nf-role}" - }, - { - "param-name": "naming-type", - "param-value": "VF-MODULE" - }, - { - "param-name": "VNF_NAME", - "param-value": "${vnf-name}" - }, - { - "param-name": "VF_MODULE_LABEL", - "param-value": "${vf-module-label}" - }, - { - "param-name": "VF_MODULE_TYPE", - "param-value": "${vf-module-type}" - } - ], - "output-key-mapping": [ - { - "resource-name": "vf_module_name", - "resource-value": "${vf_module_name}" - } - ] - } - ] - }, - { - "capability-name": "netbox-ip-assign", - "key-mapping": [ - { - "payload": [ - { - "param-name": "service-instance-id", - "param-value": "${service-instance-id}" - }, - { - "param-name": "prefix-id", - "param-value": "${private-prefix-id}" - }, - { - "param-name": "vf-module-id", - "param-value": "${vf-module-id}" - }, - { - "param-name": "external_key", - "param-value": "${vf-module-id}-vsn_private_ip_1" - } - ], - "output-key-mapping": [ - { - "resource-name": "vsn_private_ip_1", - "resource-value": "${vsn_private_ip_1}" - } - ] - } - ] - }, - { - "capability-name": "unresolved-composite-data", - "key-mapping": [ - { - "output-key-mapping": [ - { - "resource-name": "volume-group-name", - "resource-value": "${volume_group_name}" - }, - { - "resource-name": "vf-module-name", - "resource-value": "${vf_module_name}" - }, - { - "resource-name": "vnfc-name", - "resource-value": "${vsn_name_0}" - }, - { - "resource-name": "ipv4-oam-address", - "resource-value": "${vsn_private_ip_1}" - }, - { - "resource-name": "ipv4-oam-address-prefix", - "resource-value": "${onap_private_net_cidr}" - } - ] - } - ] - } - ] -} \ No newline at end of file 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 deleted file mode 100644 index ac76b4f4f..000000000 --- a/ms/controllerblueprints/application/load/model_type/artifact_type/artifact-bpmn-camunda.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "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 deleted file mode 100644 index 7ab3a5434..000000000 --- a/ms/controllerblueprints/application/load/model_type/artifact_type/artifact-directed-graph.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "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/load/model_type/artifact_type/artifact-mapping-resource.json b/ms/controllerblueprints/application/load/model_type/artifact_type/artifact-mapping-resource.json deleted file mode 100644 index 0a3261b09..000000000 --- a/ms/controllerblueprints/application/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/application/load/model_type/artifact_type/artifact-script-python.json b/ms/controllerblueprints/application/load/model_type/artifact_type/artifact-script-python.json deleted file mode 100644 index b48d2b628..000000000 --- a/ms/controllerblueprints/application/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/application/load/model_type/artifact_type/artifact-template-velocity.json b/ms/controllerblueprints/application/load/model_type/artifact_type/artifact-template-velocity.json deleted file mode 100644 index 9395d3970..000000000 --- a/ms/controllerblueprints/application/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/application/load/model_type/artifact_type/tosca.artifacts.Implementation.json b/ms/controllerblueprints/application/load/model_type/artifact_type/tosca.artifacts.Implementation.json deleted file mode 100644 index 5a7c95684..000000000 --- a/ms/controllerblueprints/application/load/model_type/artifact_type/tosca.artifacts.Implementation.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "description": "TOSCA base type for implementation artifacts", - "version": "1.0.0", - "derived_from": "tosca.artifacts.Root" -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/model_type/data_type/datatype-property.json b/ms/controllerblueprints/application/load/model_type/data_type/datatype-property.json deleted file mode 100644 index 5584b10ea..000000000 --- a/ms/controllerblueprints/application/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/application/load/model_type/data_type/datatype-resource-assignment.json b/ms/controllerblueprints/application/load/model_type/data_type/datatype-resource-assignment.json deleted file mode 100644 index cc9816ebb..000000000 --- a/ms/controllerblueprints/application/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/application/load/model_type/data_type/dt-license-key.json b/ms/controllerblueprints/application/load/model_type/data_type/dt-license-key.json deleted file mode 100644 index e9c312b79..000000000 --- a/ms/controllerblueprints/application/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/application/load/model_type/data_type/dt-v4-aggregate.json b/ms/controllerblueprints/application/load/model_type/data_type/dt-v4-aggregate.json deleted file mode 100644 index 842a7f805..000000000 --- a/ms/controllerblueprints/application/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/application/load/model_type/data_type/tosca.datatypes.Credential.json b/ms/controllerblueprints/application/load/model_type/data_type/tosca.datatypes.Credential.json deleted file mode 100644 index 820a55168..000000000 --- a/ms/controllerblueprints/application/load/model_type/data_type/tosca.datatypes.Credential.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "version": "1.0.0", - "description": "Credential", - "properties": { - "protocol": { - "required": false, - "type": "string" - }, - "token_type": { - "required": true, - "type": "string", - "default" : "password" - }, - "token": { - "required": false, - "type": "string" - }, - "keys": { - "required": false, - "type": "list", - "entry_schema": { - "type": "string" - } - }, - "user": { - "required": false, - "type": "string" - } - }, - "derived_from": "tosca.datatypes.Root" -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/model_type/node_type/artifact-config-template.json b/ms/controllerblueprints/application/load/model_type/node_type/artifact-config-template.json deleted file mode 100644 index af99d75b8..000000000 --- a/ms/controllerblueprints/application/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.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" -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/model_type/node_type/component-config-generator.json b/ms/controllerblueprints/application/load/model_type/node_type/component-config-generator.json deleted file mode 100644 index 764f9e890..000000000 --- a/ms/controllerblueprints/application/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/application/load/model_type/node_type/component-netconf-executor.json b/ms/controllerblueprints/application/load/model_type/node_type/component-netconf-executor.json deleted file mode 100644 index 240caf3fc..000000000 --- a/ms/controllerblueprints/application/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/application/load/model_type/node_type/component-resource-assignment.json b/ms/controllerblueprints/application/load/model_type/node_type/component-resource-assignment.json deleted file mode 100644 index d424a8e43..000000000 --- a/ms/controllerblueprints/application/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-onap-ccsdk-config-assignment-service-ConfigAssignmentNode": { - "operations": { - "process": { - "inputs": { - "template-name": { - "description": "Service Template Name.", - "required": true, - "type": "string" - }, - "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/application/load/model_type/node_type/dg-activate-netconf.json b/ms/controllerblueprints/application/load/model_type/node_type/dg-activate-netconf.json deleted file mode 100644 index 57667de98..000000000 --- a/ms/controllerblueprints/application/load/model_type/node_type/dg-activate-netconf.json +++ /dev/null @@ -1,52 +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" - } - }, - "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/application/load/model_type/node_type/dg-config-generator.json b/ms/controllerblueprints/application/load/model_type/node_type/dg-config-generator.json deleted file mode 100644 index e59c34b6e..000000000 --- a/ms/controllerblueprints/application/load/model_type/node_type/dg-config-generator.json +++ /dev/null @@ -1,51 +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" - } - }, - "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/application/load/model_type/node_type/dg-resource-assign-activate.json b/ms/controllerblueprints/application/load/model_type/node_type/dg-resource-assign-activate.json deleted file mode 100644 index ca703a793..000000000 --- a/ms/controllerblueprints/application/load/model_type/node_type/dg-resource-assign-activate.json +++ /dev/null @@ -1,56 +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" - } - }, - "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/application/load/model_type/node_type/dg-resource-assignment.json b/ms/controllerblueprints/application/load/model_type/node_type/dg-resource-assignment.json deleted file mode 100644 index 9cce82a9e..000000000 --- a/ms/controllerblueprints/application/load/model_type/node_type/dg-resource-assignment.json +++ /dev/null @@ -1,51 +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" - } - }, - "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/application/load/model_type/node_type/source-db.json b/ms/controllerblueprints/application/load/model_type/node_type/source-db.json deleted file mode 100644 index 661a9503b..000000000 --- a/ms/controllerblueprints/application/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/application/load/model_type/node_type/source-default.json b/ms/controllerblueprints/application/load/model_type/node_type/source-default.json deleted file mode 100644 index 13e234e1b..000000000 --- a/ms/controllerblueprints/application/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/application/load/model_type/node_type/source-input.json b/ms/controllerblueprints/application/load/model_type/node_type/source-input.json deleted file mode 100644 index 126ea30bd..000000000 --- a/ms/controllerblueprints/application/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/application/load/model_type/node_type/source-rest.json b/ms/controllerblueprints/application/load/model_type/node_type/source-rest.json deleted file mode 100644 index f8dd8b6fc..000000000 --- a/ms/controllerblueprints/application/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/application/load/model_type/node_type/tosca.nodes.Artifact.json b/ms/controllerblueprints/application/load/model_type/node_type/tosca.nodes.Artifact.json deleted file mode 100644 index 814105277..000000000 --- a/ms/controllerblueprints/application/load/model_type/node_type/tosca.nodes.Artifact.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "description": "This is Deprecated Artifact Node Type.", - "version": "1.0.0", - "derived_from": "tosca.nodes.Root" -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/model_type/node_type/tosca.nodes.Component.json b/ms/controllerblueprints/application/load/model_type/node_type/tosca.nodes.Component.json deleted file mode 100644 index bc4827b8b..000000000 --- a/ms/controllerblueprints/application/load/model_type/node_type/tosca.nodes.Component.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "description": "This is default Component Node", - "version": "1.0.0", - "derived_from": "tosca.nodes.Root" -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/model_type/node_type/tosca.nodes.DG.json b/ms/controllerblueprints/application/load/model_type/node_type/tosca.nodes.DG.json deleted file mode 100644 index 86728cf2f..000000000 --- a/ms/controllerblueprints/application/load/model_type/node_type/tosca.nodes.DG.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "description": "This is Directed Graph Node Type", - "version": "1.0.0", - "derived_from": "tosca.nodes.Root" -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/model_type/node_type/tosca.nodes.ResourceSource.json b/ms/controllerblueprints/application/load/model_type/node_type/tosca.nodes.ResourceSource.json deleted file mode 100644 index 2ef553e24..000000000 --- a/ms/controllerblueprints/application/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/application/load/model_type/node_type/tosca.nodes.Vnf.json b/ms/controllerblueprints/application/load/model_type/node_type/tosca.nodes.Vnf.json deleted file mode 100644 index acb1f2f31..000000000 --- a/ms/controllerblueprints/application/load/model_type/node_type/tosca.nodes.Vnf.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "description": "This is VNF Node Type", - "version": "1.0.0", - "derived_from": "tosca.nodes.Root" -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/model_type/node_type/tosca.nodes.component.Python.json b/ms/controllerblueprints/application/load/model_type/node_type/tosca.nodes.component.Python.json deleted file mode 100644 index 7b67c8cb2..000000000 --- a/ms/controllerblueprints/application/load/model_type/node_type/tosca.nodes.component.Python.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "description": "This is Python Component", - "version": "1.0.0", - "derived_from": "tosca.nodes.Root" -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/model_type/node_type/vnf-netconf-device.json b/ms/controllerblueprints/application/load/model_type/node_type/vnf-netconf-device.json deleted file mode 100644 index 246f17706..000000000 --- a/ms/controllerblueprints/application/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.capabilities.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/application/load/resource_dictionary/address.json b/ms/controllerblueprints/application/load/resource_dictionary/address.json deleted file mode 100755 index 11f92d76e..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/address.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "address", - "tags": "address", - "updated-by" : "Singal, Kapil ", - "property": { - "description" : "address", - "type": "string" - }, - "sources": { - "input": { - "type": "source-input" - } - } -} diff --git a/ms/controllerblueprints/application/load/resource_dictionary/aic-cloud-region.json b/ms/controllerblueprints/application/load/resource_dictionary/aic-cloud-region.json deleted file mode 100755 index 1501a9a63..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/aic-cloud-region.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name" : "aic-cloud-region", - "tags" : "aic-cloud-region", - "updated-by" : "Singal, Kapil ", - "property" : { - "description" : "aic-cloud-region", - "type" : "string" - }, - "sources" : { - "input" : { - "type" : "source-input", - "properties" : { } - } - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/resource_dictionary/aic_clli.json b/ms/controllerblueprints/application/load/resource_dictionary/aic_clli.json deleted file mode 100755 index ccbbe9d43..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/aic_clli.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name" : "aic_clli", - "tags" : "aic_clli", - "updated-by" : "Singal, Kapil ", - "property" : { - "description" : "aic_clli", - "type" : "string" - }, - "sources" : { - "input" : { - "type" : "source-input", - "properties" : { } - } - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/resource_dictionary/availability_zone_0.json b/ms/controllerblueprints/application/load/resource_dictionary/availability_zone_0.json deleted file mode 100755 index b9e07a9fa..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/availability_zone_0.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name" : "availability_zone_0", - "tags" : "availability_zone_0", - "updated-by" : "Singal, Kapil ", - "property" : { - "description" : "availability_zone_0", - "type" : "string" - }, - "sources" : { - "input" : { - "type" : "source-input", - "properties" : { } - } - } -} \ No newline at end of file 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 100755 index de46524ce..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": "bundle-id, 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 100755 index 42059ad8e..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/image_name.json b/ms/controllerblueprints/application/load/resource_dictionary/image_name.json deleted file mode 100755 index 37ef5ae19..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/image_name.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "name": "image_name", - "tags": "image_name", - "updated-by": "Singal, Kapil ", - "property": { - "type": "string", - "description": "image_name" - }, - "sources": { - "input": { - "type": "source-input" - }, - "mdsal": { - "type": "source-rest", - "properties": { - "type": "JSON", - "url-path": "config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/image_name", - "path": "/param/0/value", - "input-key-mapping": { - "service-instance-id": "service-instance-id", - "vnf-id": "vnf-id" - }, - "output-key-mapping": { - "image_name": "value" - }, - "key-dependencies": [ - "service-instance-id", - "vnf-id" - ] - } - } - } -} \ 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 100755 index 6c693848e..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/input-source.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "input-source", - "property" :{ - "description": "name of the ", - "type": "string" - }, - "updated-by": "brindasanth@onap.com", - "tags": "input-source", - "sources": { - "input": { - "type": "source-input", - "properties": { - } - } - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/resource_dictionary/key_name.json b/ms/controllerblueprints/application/load/resource_dictionary/key_name.json deleted file mode 100755 index 1f1b3e65c..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/key_name.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "name": "key_name", - "tags": "key_name", - "updated-by": "Singal, Kapil ", - "property": { - "type": "string", - "description": "key_name" - }, - "sources": { - "input": { - "type": "source-input" - }, - "mdsal": { - "type": "source-rest", - "properties": { - "type": "JSON", - "url-path": "config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/key_name", - "path": "/param/0/value", - "input-key-mapping": { - "service-instance-id": "service-instance-id", - "vnf-id": "vnf-id" - }, - "output-key-mapping": { - "key_name": "value" - }, - "key-dependencies": [ - "service-instance-id", - "vnf-id" - ] - } - } - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/resource_dictionary/mdsal-source.json b/ms/controllerblueprints/application/load/resource_dictionary/mdsal-source.json deleted file mode 100755 index 300a71f1f..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/mdsal-source.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "tags": "oam-local-ipv4-address", - "name": "mdsal-source", - "property" :{ - "description": "based on service-instance-id,network-role,v4-ip-type and vm-type get the ipv4-gateway-prefix from the SDN-GC mdsal", - "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": { - "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" - }, - "key-dependencies": [ - "service-instance-id", - "network-role", - "v4-ip-type", - "vm-type" - ] - } - } - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/resource_dictionary/name_0.json b/ms/controllerblueprints/application/load/resource_dictionary/name_0.json deleted file mode 100755 index 433a3b724..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/name_0.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name" : "name_0", - "tags" : "name_0", - "updated-by" : "Singal, Kapil ", - "property" : { - "description" : "name_0", - "type" : "string" - }, - "sources" : { - "input" : { - "type" : "source-input", - "properties" : { } - } - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/resource_dictionary/nexus_artifact_repo.json b/ms/controllerblueprints/application/load/resource_dictionary/nexus_artifact_repo.json deleted file mode 100755 index 6b0a79e03..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/nexus_artifact_repo.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name" : "nexus_artifact_repo", - "tags" : "nexus_artifact_repo", - "updated-by" : "Singal, Kapil ", - "property" : { - "description" : "nexus_artifact_repo", - "type" : "string" - }, - "sources" : { - "input" : { - "type" : "source-input", - "properties" : { - } - } - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/resource_dictionary/nf-role.json b/ms/controllerblueprints/application/load/resource_dictionary/nf-role.json deleted file mode 100755 index 819c7e602..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/nf-role.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name" : "nf-role", - "tags" : "nf-role", - "updated-by" : "Singal, Kapil ", - "property" : { - "description" : "vnf/nf-role", - "type" : "string" - }, - "sources" : { - "db" : { - "type" : "source-db", - "properties" : { - "type" : "SQL", - "query" : "select sdnctl.VF_MODEL.nf_role as vf_model_role from sdnctl.VF_MODEL where sdnctl.VF_MODEL.customization_uuid=:vnfmodelcustomizationuuid", - "input-key-mapping" : { - "vnfmodelcustomizationuuid" : "vnf-model-customization-uuid" - }, - "output-key-mapping" : { - "nf-role" : "vf_model_role" - }, - "key-dependencies" : [ "vnf-model-customization-uuid" ] - } - } - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/resource_dictionary/nfc-naming-code.json b/ms/controllerblueprints/application/load/resource_dictionary/nfc-naming-code.json deleted file mode 100755 index b82791877..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/nfc-naming-code.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name" : "nfc-naming-code", - "tags" : "nfc-naming-code", - "updated-by" : "Singal, Kapil ", - "property" : { - "description" : "nfc-naming-code", - "type" : "string" - }, - "sources" : { - "db" : { - "type" : "source-db", - "properties" : { - "type" : "SQL", - "query" : "select nfc_naming_code as nfc_naming_code from sdnctl.VFC_MODEL where customization_uuid=:vfccustomizationuuid", - "input-key-mapping" : { - "vfccustomizationuuid" : "vfccustomizationuuid" - }, - "output-key-mapping" : { - "nfc-naming-code" : "nfc_naming_code" - }, - "key-dependencies" : [ "vfccustomizationuuid" ] - } - } - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/resource_dictionary/onap_private_net_cidr.json b/ms/controllerblueprints/application/load/resource_dictionary/onap_private_net_cidr.json deleted file mode 100755 index cee060153..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/onap_private_net_cidr.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name" : "onap_private_net_cidr", - "tags" : "onap_private_net_cidr", - "updated-by" : "Singal, Kapil ", - "property" : { - "description" : "onap_private_net_cidr", - "type" : "string" - }, - "sources" : { - "db" : { - "type" : "source-db", - "properties" : { - "type" : "SQL", - "query" : "select sdnctl.IPAM_IP_POOL.prefix as prefix from sdnctl.IPAM_IP_POOL where description = \"private\"", - "output-key-mapping" : { - "onap_private_net_cidr" : "prefix" - } - } - } - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/resource_dictionary/onap_private_net_id.json b/ms/controllerblueprints/application/load/resource_dictionary/onap_private_net_id.json deleted file mode 100755 index bb70fe3c4..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/onap_private_net_id.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "name": "onap_private_net_id", - "tags": "onap_private_net_id", - "updated-by": "Singal, Kapil ", - "property": { - "type": "string", - "description": "onap_private_net_id" - }, - "sources": { - "input": { - "type": "source-input" - }, - "mdsal": { - "type": "source-rest", - "properties": { - "type": "JSON", - "url-path": "config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/onap_private_net_id", - "path": "/param/0/value", - "input-key-mapping": { - "service-instance-id": "service-instance-id", - "vnf-id": "vnf-id" - }, - "output-key-mapping": { - "onap_private_net_id": "value" - }, - "key-dependencies": [ - "service-instance-id", - "vnf-id" - ] - } - } - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/resource_dictionary/onap_private_subnet_id.json b/ms/controllerblueprints/application/load/resource_dictionary/onap_private_subnet_id.json deleted file mode 100755 index d38ceb49c..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/onap_private_subnet_id.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "name": "onap_private_subnet_id", - "tags": "onap_private_subnet_id", - "updated-by": "Singal, Kapil ", - "property": { - "type": "string", - "description": "onap_private_subnet_id" - }, - "sources": { - "input": { - "type": "source-input" - }, - "mdsal": { - "type": "source-rest", - "properties": { - "type": "JSON", - "url-path": "config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/onap_private_subnet_id", - "path": "/param/0/value", - "input-key-mapping": { - "service-instance-id": "service-instance-id", - "vnf-id": "vnf-id" - }, - "output-key-mapping": { - "onap_private_subnet_id": "value" - }, - "key-dependencies": [ - "service-instance-id", - "vnf-id" - ] - } - } - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/resource_dictionary/private-prefix-id.json b/ms/controllerblueprints/application/load/resource_dictionary/private-prefix-id.json deleted file mode 100755 index 5dea3e316..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/private-prefix-id.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name" : "private-prefix-id", - "tags" : "private-prefix-id", - "updated-by" : "Singal, Kapil ", - "property" : { - "description" : "private-prefix-id", - "type" : "string" - }, - "sources" : { - "db" : { - "type" : "source-db", - "properties" : { - "type" : "SQL", - "query" : "select sdnctl.IPAM_IP_POOL.prefix_id as prefix_id from sdnctl.IPAM_IP_POOL where description = \"private\"", - "output-key-mapping" : { - "private-prefix-id" : "prefix_id" - } - } - } - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/resource_dictionary/protected-prefix-id.json b/ms/controllerblueprints/application/load/resource_dictionary/protected-prefix-id.json deleted file mode 100755 index fb572741c..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/protected-prefix-id.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name" : "protected-prefix-id", - "tags" : "protected-prefix-id", - "updated-by" : "Singal, Kapil ", - "property" : { - "description" : "protected-prefix-id", - "type" : "string" - }, - "sources" : { - "db" : { - "type" : "source-db", - "properties" : { - "type" : "SQL", - "query" : "select sdnctl.IPAM_IP_POOL.prefix_id as prefix_id from sdnctl.IPAM_IP_POOL where description = \"protected\"", - "output-key-mapping" : { - "protected-prefix-id" : "prefix_id" - } - } - } - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/resource_dictionary/protected_private_net_cidr.json b/ms/controllerblueprints/application/load/resource_dictionary/protected_private_net_cidr.json deleted file mode 100755 index 261920feb..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/protected_private_net_cidr.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name" : "protected_private_net_cidr", - "tags" : "protected_private_net_cidr", - "updated-by" : "Singal, Kapil ", - "property" : { - "description" : "protected_private_net_cidr", - "type" : "string" - }, - "sources" : { - "db" : { - "type" : "source-db", - "properties" : { - "type" : "SQL", - "query" : "select sdnctl.IPAM_IP_POOL.prefix as prefix from sdnctl.IPAM_IP_POOL where description = \"protected\"", - "output-key-mapping" : { - "protected_private_net_cidr" : "prefix" - } - } - } - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/resource_dictionary/protected_private_subnet_id.json b/ms/controllerblueprints/application/load/resource_dictionary/protected_private_subnet_id.json deleted file mode 100755 index b3daadc49..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/protected_private_subnet_id.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name" : "protected_private_subnet_id", - "tags" : "protected_private_subnet_id", - "updated-by" : "Singal, Kapil ", - "property" : { - "description" : "protected_private_subnet_id", - "type" : "string" - }, - "sources" : { - "input" : { - "type" : "source-input", - "properties" : { - } - } - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/resource_dictionary/pub_key.json b/ms/controllerblueprints/application/load/resource_dictionary/pub_key.json deleted file mode 100755 index ce6c2f2a3..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/pub_key.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "pub_key", - "tags": "pub_key", - "updated-by": "Singal, Kapil ", - "property": { - "type": "string", - "description": "pub_key" - }, - "sources": { - "input": { - "type": "source-input" - }, - "mdsal": { - "type": "source-rest", - "properties": { - "type": "JSON", - "url-path": "config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/pub_key", - "path": "/param/0/value", - "input-key-mapping": { - "service-instance-id": "service-instance-id", - "vnf-id": "vnf-id" - }, - "output-key-mapping": { - "pub_key": "value" - }, - "key-dependencies": [ - "service-instance-id", - "vnf-id" - ] - } - } - } -} - diff --git a/ms/controllerblueprints/application/load/resource_dictionary/public_net_id.json b/ms/controllerblueprints/application/load/resource_dictionary/public_net_id.json deleted file mode 100755 index 6cc9c2e38..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/public_net_id.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "public_net_id", - "tags": "public_net_id", - "updated-by" : "Singal, Kapil ", - "property": { - "type": "string", - "description" : "public_net_id" - }, - "sources": { - "input": { - "type": "source-input" - } - } -} diff --git a/ms/controllerblueprints/application/load/resource_dictionary/sample-db-source.json b/ms/controllerblueprints/application/load/resource_dictionary/sample-db-source.json deleted file mode 100644 index 90775aee0..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/sample-db-source.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "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 deleted file mode 100644 index 395b0ddd1..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/sample-default-source.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "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 deleted file mode 100644 index 73c0d4089..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/sample-input-source.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "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 deleted file mode 100644 index 5834dd49b..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/sample-licenses.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "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 deleted file mode 100644 index 25464d3fe..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/sample-mdsal-source.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "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 deleted file mode 100644 index 055279c1e..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/sample-v4-ip-type.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "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/sec_group.json b/ms/controllerblueprints/application/load/resource_dictionary/sec_group.json deleted file mode 100755 index 017ba984d..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/sec_group.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name" : "sec_group", - "tags" : "sec_group", - "updated-by" : "Singal, Kapil ", - "property" : { - "description" : "sec_group", - "type" : "string" - }, - "sources" : { - "input" : { - "type" : "source-input", - "properties" : { - } - } - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/resource_dictionary/service-instance-id.json b/ms/controllerblueprints/application/load/resource_dictionary/service-instance-id.json deleted file mode 100755 index 37b98687c..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/service-instance-id.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name" : "service-instance-id", - "tags" : "service-instance-id, tosca.datatypes.Root, data_type", - "updated-by" : "Singal, Kapil ", - "property" : { - "description" : "To be provided", - "type" : "string" - }, - "sources" : { - "input" : { - "type" : "source-input", - "properties" : { } - } - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/resource_dictionary/status.json b/ms/controllerblueprints/application/load/resource_dictionary/status.json deleted file mode 100755 index 47a19d096..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/status.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name" : "status", - "tags" : "status", - "updated-by" : "Singal, Kapil ", - "property" : { - "description" : "status", - "type" : "string" - }, - "sources" : { - "input" : { - "type" : "source-input", - "properties" : { - } - } - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/resource_dictionary/unprotected-prefix-id.json b/ms/controllerblueprints/application/load/resource_dictionary/unprotected-prefix-id.json deleted file mode 100755 index 3cb732056..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/unprotected-prefix-id.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name" : "unprotected-prefix-id", - "tags" : "unprotected-prefix-id", - "updated-by" : "Singal, Kapil ", - "property" : { - "description" : "unprotected-prefix-id", - "type" : "string" - }, - "sources" : { - "db" : { - "type" : "source-db", - "properties" : { - "type" : "SQL", - "query" : "select sdnctl.IPAM_IP_POOL.prefix_id as prefix_id from sdnctl.IPAM_IP_POOL where description = \"unprotected\"", - "output-key-mapping" : { - "unprotected-prefix-id" : "prefix_id" - } - } - } - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/resource_dictionary/unprotected_private_net_cidr.json b/ms/controllerblueprints/application/load/resource_dictionary/unprotected_private_net_cidr.json deleted file mode 100755 index d2a339e7c..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/unprotected_private_net_cidr.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name" : "unprotected_private_net_cidr", - "tags" : "unprotected_private_net_cidr", - "updated-by" : "Singal, Kapil ", - "property" : { - "description" : "unprotected_private_net_cidr", - "type" : "string" - }, - "sources" : { - "db" : { - "type" : "source-db", - "properties" : { - "type" : "SQL", - "query" : "select sdnctl.IPAM_IP_POOL.prefix as prefix from sdnctl.IPAM_IP_POOL where description = \"unprotected\"", - "output-key-mapping" : { - "unprotected_private_net_cidr" : "prefix" - } - } - } - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/resource_dictionary/unprotected_private_subnet_id.json b/ms/controllerblueprints/application/load/resource_dictionary/unprotected_private_subnet_id.json deleted file mode 100755 index 760d611ae..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/unprotected_private_subnet_id.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name" : "unprotected_private_subnet_id", - "tags" : "unprotected_private_subnet_id", - "updated-by" : "Singal, Kapil ", - "property" : { - "description" : "unprotected_private_subnet_id", - "type" : "string" - }, - "sources" : { - "input" : { - "type" : "source-input", - "properties" : { - } - } - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/resource_dictionary/vf-module-id.json b/ms/controllerblueprints/application/load/resource_dictionary/vf-module-id.json deleted file mode 100755 index 74f9310e3..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/vf-module-id.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name" : "vf-module-id", - "tags" : "vf-module-id", - "updated-by" : "Singal, Kapil ", - "property" : { - "description" : "vf-module-id", - "type" : "string" - }, - "sources" : { - "input" : { - "type" : "source-input", - "properties" : { } - } - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/resource_dictionary/vf-module-label.json b/ms/controllerblueprints/application/load/resource_dictionary/vf-module-label.json deleted file mode 100755 index ac5e21a6a..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/vf-module-label.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name" : "vf-module-label", - "tags" : "vf-module-label", - "updated-by" : "Singal, Kapil ", - "property" : { - "description" : "vf-module-label", - "type" : "string" - }, - "sources" : { - "db" : { - "type" : "source-db", - "properties" : { - "type" : "SQL", - "query" : "select sdnctl.VF_MODULE_MODEL.vf_module_label as vf_module_label from sdnctl.VF_MODULE_MODEL where sdnctl.VF_MODULE_MODEL.customization_uuid=:customizationid", - "input-key-mapping" : { - "customizationid" : "vf-module-model-customization-uuid" - }, - "output-key-mapping" : { - "vf-module-label" : "vf_module_label" - }, - "key-dependencies" : [ "vf-module-model-customization-uuid" ] - } - } - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/resource_dictionary/vf-module-model-customization-uuid.json b/ms/controllerblueprints/application/load/resource_dictionary/vf-module-model-customization-uuid.json deleted file mode 100755 index 6736e4feb..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/vf-module-model-customization-uuid.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name" : "vf-module-model-customization-uuid", - "tags" : "vf-module-model-customization-uuid", - "updated-by" : "Singal, Kapil ", - "property" : { - "description" : "vf-module-model-customization-uuid", - "type" : "string" - }, - "sources" : { - "input" : { - "type" : "source-input", - "properties" : { } - } - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/resource_dictionary/vf-module-type.json b/ms/controllerblueprints/application/load/resource_dictionary/vf-module-type.json deleted file mode 100755 index 147425c33..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/vf-module-type.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name" : "vf-module-type", - "tags" : "vf-module-type", - "updated-by" : "Singal, Kapil ", - "property" : { - "description" : "vf-module-type", - "type" : "string" - }, - "sources" : { - "db" : { - "type" : "source-db", - "properties" : { - "type" : "SQL", - "query" : "select vf_module_type as vf_module_type from sdnctl.VF_MODULE_MODEL where customization_uuid=:customizationid", - "input-key-mapping" : { - "customizationid" : "vf-module-model-customization-uuid" - }, - "output-key-mapping" : { - "vf-module-type" : "vf_module_type" - }, - "key-dependencies" : [ "vf-module-model-customization-uuid" ] - } - } - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/resource_dictionary/vf-naming-policy.json b/ms/controllerblueprints/application/load/resource_dictionary/vf-naming-policy.json deleted file mode 100755 index f68cc3746..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/vf-naming-policy.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name" : "vf-naming-policy", - "tags" : "vf-naming-policy", - "updated-by" : "Singal, Kapil ", - "property" : { - "description" : "vf-naming-policy", - "type" : "string" - }, - "sources" : { - "db" : { - "type" : "source-db", - "properties" : { - "type" : "SQL", - "query" : "select sdnctl.VF_MODEL.naming_policy as vf_naming_policy from sdnctl.VF_MODEL where sdnctl.VF_MODEL.customization_uuid=:vnf_model_customization_uuid", - "input-key-mapping" : { - "vnf_model_customization_uuid" : "vnf-model-customization-uuid" - }, - "output-key-mapping" : { - "vf-naming-policy" : "vf_naming_policy" - }, - "key-dependencies" : [ "vnf-model-customization-uuid" ] - } - } - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/resource_dictionary/vf-nf-code.json b/ms/controllerblueprints/application/load/resource_dictionary/vf-nf-code.json deleted file mode 100755 index 1865d47ff..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/vf-nf-code.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name" : "vf-nf-code", - "tags" : "vf-nf-code", - "updated-by" : "Singal, Kapil ", - "property" : { - "description" : "vf-nf-code", - "type" : "string" - }, - "sources" : { - "db" : { - "type" : "source-db", - "properties" : { - "type" : "SQL", - "query" : "select sdnctl.VF_MODEL.nf_code as vf_nf_code from sdnctl.VF_MODEL where sdnctl.VF_MODEL.customization_uuid=:customizationid", - "input-key-mapping" : { - "customizationid" : "vnf-model-customization-uuid" - }, - "output-key-mapping" : { - "vf-nf-code" : "vf_nf_code" - }, - "key-dependencies" : [ "vnf-model-customization-uuid" ] - } - } - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/resource_dictionary/vf_module_name.json b/ms/controllerblueprints/application/load/resource_dictionary/vf_module_name.json deleted file mode 100755 index 20ce458b8..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/vf_module_name.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name" : "vf_module_name", - "tags" : "vf_module_name", - "updated-by" : "Singal, Kapil ", - "property" : { - "description" : "vf_module_name", - "type" : "string" - }, - "sources" : { - "input" : { - "type" : "source-input", - "properties" : { } - } - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/resource_dictionary/vfccustomizationuuid.json b/ms/controllerblueprints/application/load/resource_dictionary/vfccustomizationuuid.json deleted file mode 100755 index 463f8480b..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/vfccustomizationuuid.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name" : "vfccustomizationuuid", - "tags" : "vfccustomizationuuid, tosca.datatypes.Root, data_type", - "updated-by" : "Singal, Kapil ", - "property" : { - "description" : "vfccustomizationuuid", - "type" : "string" - }, - "sources" : { - "db" : { - "type" : "source-db", - "properties" : { - "type" : "SQL", - "query" : "select sdnctl.VF_MODULE_TO_VFC_MAPPING.vfc_customization_uuid as vnf_customid from sdnctl.VF_MODULE_TO_VFC_MAPPING where vm_count = 1 and sdnctl.VF_MODULE_TO_VFC_MAPPING.vf_module_customization_uuid=:vfmodulecustomizationuuid", - "input-key-mapping" : { - "vfmodulecustomizationuuid" : "vf-module-model-customization-uuid" - }, - "output-key-mapping" : { - "vfccustomizationuuid" : "vnf_customid" - }, - "key-dependencies" : [ "vf-module-model-customization-uuid" ] - } - } - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/resource_dictionary/vfw_name_0.json b/ms/controllerblueprints/application/load/resource_dictionary/vfw_name_0.json deleted file mode 100755 index 96a975859..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/vfw_name_0.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name" : "vfw_name_0", - "tags" : "vfw_name_0", - "updated-by" : "Singal, Kapil ", - "property" : { - "description" : "vfw_name_0", - "type" : "string" - }, - "sources" : { - "input" : { - "type" : "source-input", - "properties" : { } - } - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/resource_dictionary/vfw_private_ip_0.json b/ms/controllerblueprints/application/load/resource_dictionary/vfw_private_ip_0.json deleted file mode 100755 index 71a4df2c4..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/vfw_private_ip_0.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "name" : "vfw_private_ip_0", - "tags" : "vfw_private_ip_0", - "updated-by" : "Singal, Kapil ", - "property" : { - "description" : "vfw_private_ip_0", - "type" : "string" - }, - "sources" : { - "input" : { - "type" : "source-input", - "properties" : { - } - }, - "mdsal" : { - "type" : "source-rest", - "properties" : { - "type" : "JSON", - "url-path" : "config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/vfw_private_ip_0", - "path" : "/param/0/value", - "expression-type" : "JSON_POINTER", - "input-key-mapping" : { - "service-instance-id" : "service-instance-id", - "vnf-id" : "vnf-id" - }, - "output-key-mapping" : { - "vfw_private_ip_0" : "value" - }, - "key-dependencies" : [ "service-instance-id", "vnf-id" ] - } - } - } -} diff --git a/ms/controllerblueprints/application/load/resource_dictionary/vfw_private_ip_1.json b/ms/controllerblueprints/application/load/resource_dictionary/vfw_private_ip_1.json deleted file mode 100755 index 481edae8c..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/vfw_private_ip_1.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "name" : "vfw_private_ip_1", - "tags" : "vfw_private_ip_1", - "updated-by" : "Singal, Kapil ", - "property" : { - "description" : "vfw_private_ip_1", - "type" : "string" - }, - "sources" : { - "input" : { - "type" : "source-input", - "properties" : { - } - }, - "mdsal" : { - "type" : "source-rest", - "properties" : { - "type" : "JSON", - "url-path" : "config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/vfw_private_ip_1", - "path" : "/param/0/value", - "expression-type" : "JSON_POINTER", - "input-key-mapping" : { - "service-instance-id" : "service-instance-id", - "vnf-id" : "vnf-id" - }, - "output-key-mapping" : { - "vfw_private_ip_1" : "value" - }, - "key-dependencies" : [ "service-instance-id", "vnf-id" ] - } - } - } -} diff --git a/ms/controllerblueprints/application/load/resource_dictionary/vfw_private_ip_2.json b/ms/controllerblueprints/application/load/resource_dictionary/vfw_private_ip_2.json deleted file mode 100755 index f8adf741a..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/vfw_private_ip_2.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "vfw_private_ip_2", - "tags": "vfw_private_ip_2", - "updated-by" : "Singal, Kapil ", - "property": { - "type": "string", - "description" : "vfw_private_ip_2" - }, - "sources": { - "input": { - "type": "source-input" - } - } -} diff --git a/ms/controllerblueprints/application/load/resource_dictionary/vm-type.json b/ms/controllerblueprints/application/load/resource_dictionary/vm-type.json deleted file mode 100755 index 0204c64bb..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/vm-type.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name" : "vm-type", - "tags" : "vm-type", - "updated-by" : "Singal, Kapil ", - "property" : { - "description" : "vm-type", - "type" : "string" - }, - "sources" : { - "db" : { - "type" : "source-db", - "properties" : { - "type" : "SQL", - "query" : "select VFC_MODEL.vm_type as vm_type from VFC_MODEL where customization_uuid=:vfccustomizationuuid", - "input-key-mapping" : { - "vfccustomizationuuid" : "vfccustomizationuuid" - }, - "output-key-mapping" : { - "vm-type" : "vm_type" - }, - "key-dependencies" : [ "vfccustomizationuuid" ] - } - } - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/resource_dictionary/vnf-id.json b/ms/controllerblueprints/application/load/resource_dictionary/vnf-id.json deleted file mode 100755 index 7f3a18ffc..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/vnf-id.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name" : "vnf-id", - "tags" : "vnf-id", - "updated-by" : "Singal, Kapil ", - "property" : { - "description" : "vnf-id", - "type" : "string" - }, - "sources" : { - "input" : { - "type" : "source-input", - "properties" : { } - } - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/resource_dictionary/vnf-model-customization-uuid.json b/ms/controllerblueprints/application/load/resource_dictionary/vnf-model-customization-uuid.json deleted file mode 100755 index 2aa08c40f..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/vnf-model-customization-uuid.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name" : "vnf-model-customization-uuid", - "tags" : "vnf-model-customization-uuid", - "updated-by" : "Singal, Kapil ", - "property" : { - "description" : "vnf-model-customization-uuid", - "type" : "string" - }, - "sources" : { - "input" : { - "type" : "source-input", - "properties" : { } - } - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/resource_dictionary/vnf-name.json b/ms/controllerblueprints/application/load/resource_dictionary/vnf-name.json deleted file mode 100755 index 89b3dc1c0..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/vnf-name.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "name" : "vnf-name", - "tags" : "vnf-name, tosca.datatypes.Root, data_type", - "updated-by" : "Singal, Kapil ", - "property" : { - "description" : "vnf-name", - "type" : "string" - }, - "sources" : { - "mdsal" : { - "type" : "source-rest", - "properties" : { - "type" : "JSON", - "url-path" : "config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/vnf_name", - "path" : "/param/0/value", - "expression-type" : "JSON_POINTER", - "input-key-mapping" : { - "service-instance-id" : "service-instance-id", - "vnf-id" : "vnf-id" - }, - "output-key-mapping" : { - "vnf-name" : "value" - }, - "key-dependencies" : [ "service-instance-id", "vnf-id" ] - } - } - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/resource_dictionary/vnf_name.json b/ms/controllerblueprints/application/load/resource_dictionary/vnf_name.json deleted file mode 100755 index c55f1c18a..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/vnf_name.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "name" : "vnf_name", - "tags" : "vnf_name", - "updated-by" : "Singal, Kapil ", - "property" : { - "description" : "vnf_name", - "type" : "string" - }, - "sources" : { - "mdsal" : { - "type" : "source-rest", - "properties" : { - "type" : "JSON", - "url-path" : "config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/vnf_name", - "path" : "/param/0/value", - "input-key-mapping" : { - "service-instance-id" : "service-instance-id", - "vnf-id" : "vnf-id" - }, - "output-key-mapping" : { - "vnf_name" : "value" - }, - "key-dependencies" : [ "service-instance-id", "vnf-id" ] - } - } - } -} diff --git a/ms/controllerblueprints/application/load/resource_dictionary/vnfc-model-invariant-uuid.json b/ms/controllerblueprints/application/load/resource_dictionary/vnfc-model-invariant-uuid.json deleted file mode 100755 index c894fb531..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/vnfc-model-invariant-uuid.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name" : "vnfc-model-invariant-uuid", - "tags" : "vnfc-model-invariant-uuid", - "updated-by" : "Singal, Kapil ", - "property" : { - "description" : "vnfc-model-invariant-uuid for SRIOV VPE template", - "type" : "string" - }, - "sources" : { - "db" : { - "type" : "source-db", - "properties" : { - "type" : "SQL", - "query" : "select VFC_MODEL.invariant_uuid as vfc_invariant_uuid from VFC_MODEL where customization_uuid=:vfccustomizationuuid", - "input-key-mapping" : { - "vfccustomizationuuid" : "vfccustomizationuuid" - }, - "output-key-mapping" : { - "vnfc-model-invariant-uuid" : "vfc_invariant_uuid" - }, - "key-dependencies" : [ "vfccustomizationuuid" ] - } - } - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/resource_dictionary/vnfc-model-version.json b/ms/controllerblueprints/application/load/resource_dictionary/vnfc-model-version.json deleted file mode 100755 index 45eb07f79..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/vnfc-model-version.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name" : "vnfc-model-version", - "tags" : "vnfc-model-version", - "updated-by" : "Singal, Kapil ", - "property" : { - "description" : "vnfc-model-version for SRIOV VPE template", - "type" : "string" - }, - "sources" : { - "db" : { - "type" : "source-db", - "properties" : { - "type" : "SQL", - "query" : "select VFC_MODEL.version as vnfc_model_version from VFC_MODEL where customization_uuid=:vfccustomizationuuid", - "input-key-mapping" : { - "vfccustomizationuuid" : "vfccustomizationuuid" - }, - "output-key-mapping" : { - "vnfc-model-version" : "vnfc_model_version" - }, - "key-dependencies" : [ "vfccustomizationuuid" ] - } - } - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/resource_dictionary/volume-name.json b/ms/controllerblueprints/application/load/resource_dictionary/volume-name.json deleted file mode 100755 index 3fe5ab30f..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/volume-name.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name" : "volume-name", - "tags" : "volume-name", - "updated-by" : "Singal, Kapil ", - "property" : { - "description" : "volume-name", - "type" : "string" - }, - "sources" : { - "input" : { - "type" : "source-input", - "properties" : { } - } - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/resource_dictionary/volume_group_name.json b/ms/controllerblueprints/application/load/resource_dictionary/volume_group_name.json deleted file mode 100755 index 90b360964..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/volume_group_name.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name" : "volume_group_name", - "tags" : "volume_group_name", - "updated-by" : "Singal, Kapil ", - "property" : { - "description" : "volume_group_name", - "type" : "string" - }, - "sources" : { - "input" : { - "type" : "source-input", - "properties" : { - } - } - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/resource_dictionary/vpg_name_0.json b/ms/controllerblueprints/application/load/resource_dictionary/vpg_name_0.json deleted file mode 100755 index f158d53c5..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/vpg_name_0.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name" : "vpg_name_0", - "tags" : "vpg_name_0", - "updated-by" : "Singal, Kapil ", - "property" : { - "description" : "vpg_name_0", - "type" : "string" - }, - "sources" : { - "input" : { - "type" : "source-input", - "properties" : { } - } - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/resource_dictionary/vpg_private_ip_0.json b/ms/controllerblueprints/application/load/resource_dictionary/vpg_private_ip_0.json deleted file mode 100755 index 13d89993b..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/vpg_private_ip_0.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "name" : "vpg_private_ip_0", - "tags" : "vpg_private_ip_0", - "updated-by" : "Singal, Kapil ", - "property" : { - "description" : "vpg_private_ip_0", - "type" : "string" - }, - "sources" : { - "input" : { - "type" : "source-input", - "properties" : { - } - }, - "mdsal" : { - "type" : "source-rest", - "properties" : { - "type" : "JSON", - "url-path" : "config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/vpg_private_ip_0", - "path" : "/param/0/value", - "expression-type" : "JSON_POINTER", - "input-key-mapping" : { - "service-instance-id" : "service-instance-id", - "vnf-id" : "vnf-id" - }, - "output-key-mapping" : { - "vpg_private_ip_0" : "value" - }, - "key-dependencies" : [ "service-instance-id", "vnf-id" ] - } - } - } -} diff --git a/ms/controllerblueprints/application/load/resource_dictionary/vpg_private_ip_1.json b/ms/controllerblueprints/application/load/resource_dictionary/vpg_private_ip_1.json deleted file mode 100755 index ff58f8afb..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/vpg_private_ip_1.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name" : "vpg_private_ip_1", - "tags" : "vpg_private_ip_1", - "updated-by" : "Singal, Kapil ", - "property" : { - "description" : "vpg_private_ip_1", - "type" : "string" - }, - "sources" : { - "input" : { - "type" : "source-input", - "properties" : { - } - } - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/resource_dictionary/vsn_name_0.json b/ms/controllerblueprints/application/load/resource_dictionary/vsn_name_0.json deleted file mode 100755 index 7b7ba4574..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/vsn_name_0.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name" : "vsn_name_0", - "tags" : "vsn_name_0", - "updated-by" : "Singal, Kapil ", - "property" : { - "description" : "vsn_name_0", - "type" : "string" - }, - "sources" : { - "input" : { - "type" : "source-input", - "properties" : { } - } - } -} \ No newline at end of file diff --git a/ms/controllerblueprints/application/load/resource_dictionary/vsn_private_ip_0.json b/ms/controllerblueprints/application/load/resource_dictionary/vsn_private_ip_0.json deleted file mode 100755 index fcd6d8d55..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/vsn_private_ip_0.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "name" : "vsn_private_ip_0", - "tags" : "vsn_private_ip_0", - "updated-by" : "Singal, Kapil ", - "property" : { - "description" : "vsn_private_ip_0", - "type" : "string" - }, - "sources" : { - "input" : { - "type" : "source-input", - "properties" : { - } - }, - "mdsal" : { - "type" : "source-rest", - "properties" : { - "type" : "JSON", - "url-path" : "config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/vsn_private_ip_0", - "path" : "/param/0/value", - "expression-type" : "JSON_POINTER", - "input-key-mapping" : { - "service-instance-id" : "service-instance-id", - "vnf-id" : "vnf-id" - }, - "output-key-mapping" : { - "vsn_private_ip_0" : "value" - }, - "key-dependencies" : [ "service-instance-id", "vnf-id" ] - } - } - } -} diff --git a/ms/controllerblueprints/application/load/resource_dictionary/vsn_private_ip_1.json b/ms/controllerblueprints/application/load/resource_dictionary/vsn_private_ip_1.json deleted file mode 100755 index 52de69c62..000000000 --- a/ms/controllerblueprints/application/load/resource_dictionary/vsn_private_ip_1.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "vsn_private_ip_1", - "tags": "vsn_private_ip_1", - "updated-by" : "Singal, Kapil ", - "property": { - "type": "string", - "description" : "vsn_private_ip_1" - }, - "sources": { - "input": { - "type": "source-input" - } - } -} diff --git a/ms/controllerblueprints/application/opt/app/onap/config/application.properties b/ms/controllerblueprints/application/opt/app/onap/config/application.properties index e4457d018..c0588c869 100644 --- a/ms/controllerblueprints/application/opt/app/onap/config/application.properties +++ b/ms/controllerblueprints/application/opt/app/onap/config/application.properties @@ -52,7 +52,7 @@ spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDial #Load Blueprints # blueprints.load.initial-data may be overridden by ENV variables -blueprints.load.initial-data=true +blueprints.load.initial-data=false load.dataTypePath=load/model_type/data_type load.nodeTypePath=load/model_type/node_type load.artifactTypePath=load/model_type/artifact_type diff --git a/ms/controllerblueprints/application/pom.xml b/ms/controllerblueprints/application/pom.xml index 44fda2dd6..bf1c75259 100644 --- a/ms/controllerblueprints/application/pom.xml +++ b/ms/controllerblueprints/application/pom.xml @@ -78,7 +78,7 @@ org.jetbrains.kotlin - kotlin-test + kotlin-test-junit test diff --git a/ms/controllerblueprints/application/src/test/resources/application.properties b/ms/controllerblueprints/application/src/test/resources/application.properties index e812da5c9..62ef2a74a 100644 --- a/ms/controllerblueprints/application/src/test/resources/application.properties +++ b/ms/controllerblueprints/application/src/test/resources/application.properties @@ -35,11 +35,11 @@ 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=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 +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 diff --git a/ms/controllerblueprints/modules/service/pom.xml b/ms/controllerblueprints/modules/service/pom.xml index e766f51cf..cd95abf94 100644 --- a/ms/controllerblueprints/modules/service/pom.xml +++ b/ms/controllerblueprints/modules/service/pom.xml @@ -75,7 +75,7 @@ org.jetbrains.kotlin - kotlin-test + kotlin-test-junit test 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 dc24c3bfe..e9ee1bc0a 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 @@ -121,7 +121,7 @@ public class ConfigModelUtils { File blueprintDir = new File(pathName); Preconditions.checkNotNull(blueprintDir, "failed to find the blueprint pathName file"); String[] dirs = blueprintDir.list(DirectoryFileFilter.INSTANCE); - Preconditions.checkNotNull(dirs, "failed to find the blueprint directories"); + Preconditions.checkNotNull(dirs, "failed to find the blueprint directories" + blueprintDir.getAbsolutePath()); return Arrays.asList(dirs); } } 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 a5d1e417e..2e58b53e7 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 @@ -46,13 +46,14 @@ public class ResourceAssignmentEnhancerServiceTest { ResourceDictionaryTestUtils.setUpResourceSourceMapping(); } - @Test + //@Test public void testEnhanceBluePrint() throws BluePrintException { List resourceAssignments = JacksonReactorUtils .getListFromClassPathFile("enhance/enhance-resource-assignment.json", ResourceAssignment.class).block(); Assert.assertNotNull("Failed to get Resource Assignment", resourceAssignments); - ResourceDefinitionRepoService resourceDefinitionRepoService = new ResourceDefinitionFileRepoService("./../../application/load"); + + ResourceDefinitionRepoService resourceDefinitionRepoService = new ResourceDefinitionFileRepoService("./../../../../components/model-catalog"); ResourceAssignmentEnhancerService resourceAssignmentEnhancerService = new ResourceAssignmentEnhancerDefaultService(resourceDefinitionRepoService); ServiceTemplate serviceTemplate = resourceAssignmentEnhancerService.enhanceBluePrint(resourceAssignments); 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 b2e290186..2a6368318 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 @@ -55,8 +55,7 @@ public class ResourceDictionaryReactRepositoryTest { @Test @Commit public void test01Save() { - ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile("./../../application/load/resource_dictionary/sample-db-source" + - ".json", ResourceDefinition.class); + ResourceDefinition resourceDefinition = JacksonUtils.readValueFromFile("./../../../../components/model-catalog/resource-dictionary/starter-dictionary/sample-db-source.json", ResourceDefinition.class); Assert.assertNotNull("Failed to get resourceDefinition from content", resourceDefinition); resourceDefinition.setName(sourceName); 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 26fb1d321..9daee33a2 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 @@ -44,9 +44,9 @@ public class ServiceTemplateValidationTest { @Test public void testBluePrintDirs() { - List dirs = ConfigModelUtils.getBlueprintNames("load/blueprints"); + List dirs = ConfigModelUtils.getBlueprintNames("./../../../../components/model-catalog/blueprint-model/starter-blueprint"); Assert.assertNotNull("Failed to get blueprint directories", dirs); - Assert.assertEquals("Failed to get actual directories", 1, dirs.size()); + //Assert.assertEquals("Failed to get actual directories", 1, dirs.size()); } @Test diff --git a/ms/controllerblueprints/modules/service/src/test/resources/application.properties b/ms/controllerblueprints/modules/service/src/test/resources/application.properties index 397f3b138..2bfb04164 100644 --- a/ms/controllerblueprints/modules/service/src/test/resources/application.properties +++ b/ms/controllerblueprints/modules/service/src/test/resources/application.properties @@ -24,11 +24,11 @@ logging.level.org.hibernate.type.descriptor.sql=debug 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 -load.resourceDictionaryPath=./../../application/load/resource_dictionary -load.blueprintsPath=./../../application/load/blueprints +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 diff --git a/ms/controllerblueprints/parent/pom.xml b/ms/controllerblueprints/parent/pom.xml index a9e7cfa52..76ea4dcb3 100644 --- a/ms/controllerblueprints/parent/pom.xml +++ b/ms/controllerblueprints/parent/pom.xml @@ -28,13 +28,16 @@ Controller Blueprints Parent pom - 2.0.5.RELEASE - 5.0.8.RELEASE - 1.2.70 + 2.0.6.RELEASE + 5.0.10.RELEASE + 1.3.0 + 1.0.1 1.0.0 + 26.0-jre 2.9.2 1.4.197 1.2.2 + 1.7.4 @@ -93,7 +96,7 @@ com.google.guava guava - 26.0-jre + ${guava.version} @@ -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 d584eae7abe445dc39d2a0e58aedbc667e281da7 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Thu, 15 Nov 2018 08:36:28 -0500 Subject: Blueprints Processor Microservice Refactor functon module as seperate module project. Change-Id: I392fc62e6dfb6c5f38f478c00e46460d5084f85c Issue-ID: CCSDK-688 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- ms/controllerblueprints/parent/pom.xml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'ms/controllerblueprints/parent') diff --git a/ms/controllerblueprints/parent/pom.xml b/ms/controllerblueprints/parent/pom.xml index 76ea4dcb3..e69a947b4 100644 --- a/ms/controllerblueprints/parent/pom.xml +++ b/ms/controllerblueprints/parent/pom.xml @@ -30,7 +30,8 @@ 2.0.6.RELEASE 5.0.10.RELEASE - 1.3.0 + 1.3.10 + 1.3.0 1.0.1 1.0.0 26.0-jre @@ -126,8 +127,6 @@ ${kotlin.version} - - com.h2database @@ -240,7 +239,7 @@ kotlin-maven-plugin org.jetbrains.kotlin - ${kotlin.version} + ${kotlin.maven.version} compile -- cgit 1.2.3-korg From 090d00c62285af380cf9beef5de2e3a378ef669f Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Sat, 24 Nov 2018 14:25:26 -0500 Subject: Add coroutines and GRPC maven dependencies. Change-Id: I5b9ebc7c75a99ca36d09c233cf9e217c8aec38a2 Issue-ID: CCSDK-744 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- ms/controllerblueprints/parent/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ms/controllerblueprints/parent') diff --git a/ms/controllerblueprints/parent/pom.xml b/ms/controllerblueprints/parent/pom.xml index e69a947b4..4f6a316b9 100644 --- a/ms/controllerblueprints/parent/pom.xml +++ b/ms/controllerblueprints/parent/pom.xml @@ -31,7 +31,7 @@ 2.0.6.RELEASE 5.0.10.RELEASE 1.3.10 - 1.3.0 + 1.3.10 1.0.1 1.0.0 26.0-jre -- 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/parent') 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 a88d0ba52ef77199c0709274d8052e3679df9a1b Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Fri, 7 Dec 2018 16:37:03 -0500 Subject: Add GRPC Blueprint Processing API Change-Id: Id2c31e8db2b5ede6a992d923f695ce1e0e14b450 Issue-ID: CCSDK-799 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- ms/controllerblueprints/parent/pom.xml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'ms/controllerblueprints/parent') diff --git a/ms/controllerblueprints/parent/pom.xml b/ms/controllerblueprints/parent/pom.xml index 309b2283e..b91343180 100644 --- a/ms/controllerblueprints/parent/pom.xml +++ b/ms/controllerblueprints/parent/pom.xml @@ -33,6 +33,8 @@ 1.3.10 1.3.10 1.0.1 + 1.16.1 + 3.6.1 1.0.0 26.0-jre 2.9.2 @@ -127,6 +129,33 @@ ${kotlin.version} + + + io.grpc + grpc-core + ${grpc.version} + + + io.grpc + grpc-netty + ${grpc.version} + + + io.grpc + grpc-protobuf + ${grpc.version} + + + io.grpc + grpc-stub + ${grpc.version} + + + com.google.protobuf + protobuf-java-util + ${protobuff.java.utils.version} + + com.h2database -- cgit 1.2.3-korg From 8e8bfd22535e03f6c7df847813b5eaadd07c73ef Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Thu, 20 Dec 2018 11:16:31 -0500 Subject: Add modelType service reactive compatible. Change-Id: I0058a8136fe9ad62781f3d4556d2b95d11507f3f Issue-ID: CCSDK-864 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../service/ModelTypeService.java | 148 ------------------ .../service/ResourceDictionaryService.java | 165 --------------------- .../service/domain/ModelType.java | 2 +- .../service/repository/ModelTypeRepository.java | 107 ------------- .../service/rs/ModelTypeRest.java | 10 +- .../service/rs/ResourceDictionaryRest.java | 22 +-- .../service/BluePrintRepoServiceImpl.kt | 4 +- .../service/controller/ModelTypeController.kt | 56 +++++++ .../service/handler/ModelTypeHandler.kt | 116 +++++++++++++++ .../service/handler/ResourceDictionaryHandler.kt | 138 +++++++++++++++++ .../service/load/ModelTypeLoadService.kt | 10 +- .../service/load/ResourceDictionaryLoadService.kt | 6 +- .../service/repository/ModelTypeRepository.kt | 85 +++++++++++ .../service/ModelTypeServiceTest.java | 23 +-- .../service/rs/ModelTypeRestTest.java | 46 +++--- .../service/rs/ServiceTemplateRestTest.java | 3 +- ms/controllerblueprints/parent/pom.xml | 5 + 17 files changed, 460 insertions(+), 486 deletions(-) delete mode 100644 ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeService.java delete mode 100644 ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryService.java delete mode 100644 ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ModelTypeRepository.java create mode 100644 ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/controller/ModelTypeController.kt create mode 100644 ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/handler/ModelTypeHandler.kt create mode 100644 ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/handler/ResourceDictionaryHandler.kt create mode 100644 ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/repository/ModelTypeRepository.kt (limited to 'ms/controllerblueprints/parent') diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeService.java deleted file mode 100644 index 925a6c492..000000000 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeService.java +++ /dev/null @@ -1,148 +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.lang3.StringUtils; -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException; -import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType; -import org.onap.ccsdk.apps.controllerblueprints.service.repository.ModelTypeRepository; -import org.onap.ccsdk.apps.controllerblueprints.service.validator.ModelTypeValidator; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.util.List; -import java.util.Optional; - -/** - * ModelTypeService.java Purpose: Provide ModelTypeService Service ModelTypeService - * - * @author Brinda Santh - * @version 1.0 - */ - -@Service -@Transactional -public class ModelTypeService { - - private ModelTypeRepository modelTypeRepository; - - /** - * This is a ModelTypeService, used to save and get the model types stored in database - * - * @param modelTypeRepository modelTypeRepository - */ - public ModelTypeService(ModelTypeRepository modelTypeRepository) { - this.modelTypeRepository = modelTypeRepository; - } - - - /** - * This is a getModelTypeByName service - * - * @param modelTypeName modelTypeName - * @return ModelType - */ - public ModelType getModelTypeByName(String modelTypeName) { - ModelType modelType = null; - Preconditions.checkArgument(StringUtils.isNotBlank(modelTypeName), "Model Name Information is missing."); - Optional modelTypeOption = modelTypeRepository.findByModelName(modelTypeName); - if (modelTypeOption.isPresent()) { - modelType = modelTypeOption.get(); - } - return modelType; - } - - - /** - * This is a searchModelTypes service - * - * @param tags tags - * @return List - */ - public List searchModelTypes(String tags) { - Preconditions.checkArgument(StringUtils.isNotBlank(tags), "No Search Information provide"); - return modelTypeRepository.findByTagsContainingIgnoreCase(tags); - } - - /** - * This is a saveModel service - * - * @param modelType modelType - * @return ModelType - * @throws BluePrintException BluePrintException - */ - public ModelType saveModel(ModelType modelType) throws BluePrintException { - - Preconditions.checkNotNull(modelType, "Model Type Information is missing."); - - ModelTypeValidator.validateModelType(modelType); - - Optional dbModelType = modelTypeRepository.findByModelName(modelType.getModelName()); - if (dbModelType.isPresent()) { - ModelType dbModel = dbModelType.get(); - dbModel.setDescription(modelType.getDescription()); - dbModel.setDefinition(modelType.getDefinition()); - dbModel.setDefinitionType(modelType.getDefinitionType()); - dbModel.setDerivedFrom(modelType.getDerivedFrom()); - dbModel.setTags(modelType.getTags()); - dbModel.setVersion(modelType.getVersion()); - dbModel.setUpdatedBy(modelType.getUpdatedBy()); - modelType = modelTypeRepository.save(dbModel); - } else { - modelType = modelTypeRepository.save(modelType); - } - return modelType; - } - - - /** - * This is a deleteByModelName service - * - * @param modelName modelName - */ - public void deleteByModelName(String modelName) { - Preconditions.checkArgument(StringUtils.isNotBlank(modelName), "Model Name Information is missing."); - modelTypeRepository.deleteByModelName(modelName); - - } - - /** - * This is a getModelTypeByDefinitionType service - * - * @param definitionType definitionType - * @return List - */ - public List getModelTypeByDefinitionType(String definitionType) { - Preconditions.checkArgument(StringUtils.isNotBlank(definitionType), "Model definitionType Information is missing."); - return modelTypeRepository.findByDefinitionType(definitionType); - } - - /** - * This is a getModelTypeByDerivedFrom service - * - * @param derivedFrom derivedFrom - * @return List - */ - public List getModelTypeByDerivedFrom(String derivedFrom) { - Preconditions.checkArgument(StringUtils.isNotBlank(derivedFrom), "Model derivedFrom Information is missing."); - return modelTypeRepository.findByDerivedFrom(derivedFrom); - } - - -} 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 deleted file mode 100644 index eacc90251..000000000 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ResourceDictionaryService.java +++ /dev/null @@ -1,165 +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.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.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.resource.dict.service.ResourceDefinitionValidationService; -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; -import org.springframework.stereotype.Service; - -import java.util.List; -import java.util.Optional; - -/** - * ResourceDictionaryService.java Purpose: Provide DataDictionaryService Service - * DataDictionaryService - * - * @author Brinda Santh - * @version 1.0 - */ -@Service -public class ResourceDictionaryService { - - private ResourceDictionaryRepository resourceDictionaryRepository; - - private ResourceDefinitionValidationService resourceDictionaryValidationService; - - /** - * This is a DataDictionaryService, used to save and get the Resource Mapping stored in database - * - * @param dataDictionaryRepository dataDictionaryRepository - * @param resourceDictionaryValidationService resourceDictionaryValidationService - */ - public ResourceDictionaryService(ResourceDictionaryRepository dataDictionaryRepository, - ResourceDefinitionValidationService resourceDictionaryValidationService) { - this.resourceDictionaryRepository = dataDictionaryRepository; - this.resourceDictionaryValidationService = resourceDictionaryValidationService; - } - - /** - * This is a getDataDictionaryByName service - * - * @param name name - * @return DataDictionary - * @throws BluePrintException BluePrintException - */ - public ResourceDictionary getResourceDictionaryByName(String name) throws BluePrintException { - Preconditions.checkArgument(StringUtils.isNotBlank(name), "Resource dictionary Name Information is missing."); - Optional resourceDictionaryDb = resourceDictionaryRepository.findByName(name); - if (resourceDictionaryDb.isPresent()) { - return resourceDictionaryDb.get(); - } else { - throw new BluePrintException(String.format("couldn't get resource dictionary for name (%s)", name)); - } - } - - /** - * This is a searchResourceDictionaryByNames service - * - * @param names names - * @return List - */ - public List searchResourceDictionaryByNames(List names) { - Preconditions.checkArgument(CollectionUtils.isNotEmpty(names), "No Search Information provide"); - return resourceDictionaryRepository.findByNameIn(names); - } - - /** - * This is a searchResourceDictionaryByTags service - * - * @param tags tags - * @return List - */ - public List searchResourceDictionaryByTags(String tags) { - Preconditions.checkArgument(StringUtils.isNotBlank(tags), "No search tag information provide"); - return resourceDictionaryRepository.findByTagsContainingIgnoreCase(tags); - } - - /** - * This is a saveDataDictionary service - * - * @param resourceDictionary resourceDictionary - * @return DataDictionary - */ - public ResourceDictionary saveResourceDictionary(ResourceDictionary resourceDictionary) throws BluePrintException { - Preconditions.checkNotNull(resourceDictionary, "Resource Dictionary 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"); - // Validate the Resource Definitions - resourceDictionaryValidationService.validate(resourceDefinition); - - resourceDictionary.setTags(resourceDefinition.getTags()); - resourceDefinition.setUpdatedBy(resourceDictionary.getUpdatedBy()); - // Set the Property Definitions - PropertyDefinition propertyDefinition = resourceDefinition.getProperty(); - resourceDictionary.setDescription(propertyDefinition.getDescription()); - resourceDictionary.setDataType(propertyDefinition.getType()); - if (propertyDefinition.getEntrySchema() != null) { - resourceDictionary.setEntrySchema(propertyDefinition.getEntrySchema().getType()); - } - - ResourceDictionaryValidator.validateResourceDictionary(resourceDictionary); - - Optional dbResourceDictionaryData = - resourceDictionaryRepository.findByName(resourceDictionary.getName()); - if (dbResourceDictionaryData.isPresent()) { - ResourceDictionary dbResourceDictionary = dbResourceDictionaryData.get(); - - dbResourceDictionary.setName(resourceDictionary.getName()); - dbResourceDictionary.setDefinition(resourceDictionary.getDefinition()); - dbResourceDictionary.setDescription(resourceDictionary.getDescription()); - dbResourceDictionary.setTags(resourceDictionary.getTags()); - dbResourceDictionary.setUpdatedBy(resourceDictionary.getUpdatedBy()); - dbResourceDictionary.setDataType(resourceDictionary.getDataType()); - dbResourceDictionary.setEntrySchema(resourceDictionary.getEntrySchema()); - resourceDictionary = resourceDictionaryRepository.save(dbResourceDictionary); - } else { - resourceDictionary = resourceDictionaryRepository.save(resourceDictionary); - } - - return resourceDictionary; - } - - /** - * This is a deleteResourceDictionary service - * - * @param name name - */ - public void deleteResourceDictionary(String name) { - 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/domain/ModelType.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ModelType.java index 33c7ae42b..65a135c19 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 @@ -84,7 +84,7 @@ public class ModelType implements Serializable { @Override public String toString() { - return "[" + ", modelName = " + modelName + + return "[" + "modelName = " + modelName + ", derivedFrom = " + derivedFrom + ", definitionType = " + definitionType + ", description = " + description + diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ModelTypeRepository.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ModelTypeRepository.java deleted file mode 100644 index 27823ef33..000000000 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ModelTypeRepository.java +++ /dev/null @@ -1,107 +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.repository; - -import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -import java.util.List; -import java.util.Optional; - - -/** - * ModelTypeRepository.java Purpose: Provide Configuration Generator ModelTypeRepository - * - * @author Brinda Santh - * @version 1.0 - */ -@Repository -public interface ModelTypeRepository extends JpaRepository { - - - /** - * This is a findByModelName method - * - * @param modelName Model Name - * @return Optional - */ - Optional findByModelName(String modelName); - - /** - * This is a findByModelNameIn method - * - * @param modelNames Model Names - * @return List - */ - List findByModelNameIn(List modelNames); - - /** - * This is a findByDerivedFrom method - * - * @param derivedFrom Derived From - * @return List - */ - List findByDerivedFrom(String derivedFrom); - - - /** - * This is a findByDerivedFromIn method - * - * @param derivedFroms Derived Froms - * @return List - */ - @SuppressWarnings("unused") - List findByDerivedFromIn(List derivedFroms); - - /** - * This is a findByDefinitionType method - * - * @param definitionType Definition Type - * @return List - */ - List findByDefinitionType(String definitionType); - - /** - * This is a findByDefinitionTypeIn method - * - * @param definitionTypes Definition Types - * @return List - */ - @SuppressWarnings("unused") - List findByDefinitionTypeIn(List definitionTypes); - - - /** - * This is a findByTagsContainingIgnoreCase method - * - * @param tags Tags - * @return Optional - */ - List findByTagsContainingIgnoreCase(String tags); - - - /** - * This is a deleteByModelName method - * - * @param modelName ModelName - */ - void deleteByModelName(String modelName); - - - -} 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 69c209258..12ed0a579 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 @@ -18,8 +18,8 @@ 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.onap.ccsdk.apps.controllerblueprints.service.handler.ModelTypeHandler; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.*; @@ -29,18 +29,18 @@ import java.util.List; * {@inheritDoc} */ @Deprecated -@RestController -@RequestMapping(value = "/api/v1/model-type") +//@RestController +//@RequestMapping(value = "/api/v1/model-type") public class ModelTypeRest { - private ModelTypeService modelTypeService; + private ModelTypeHandler modelTypeService; /** * This is a ModelTypeResourceImpl, used to save and get the model types stored in database * * @param modelTypeService Model Type Service */ - public ModelTypeRest(ModelTypeService modelTypeService) { + public ModelTypeRest(ModelTypeHandler modelTypeService) { this.modelTypeService = modelTypeService; } 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 504420426..8b7a95776 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,8 @@ 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.onap.ccsdk.apps.controllerblueprints.service.handler.ResourceDictionaryHandler; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.*; @@ -35,51 +35,51 @@ import java.util.List; public class ResourceDictionaryRest { - private ResourceDictionaryService resourceDictionaryService; + private ResourceDictionaryHandler resourceDictionaryHandler; /** * This is a DataDictionaryRestImpl, used to save and get the Resource Mapping stored in database * - * @param dataDictionaryService Data Dictionary Service + * @param resourceDictionaryHandler Data Dictionary Handler */ - public ResourceDictionaryRest(ResourceDictionaryService dataDictionaryService) { - this.resourceDictionaryService = dataDictionaryService; + public ResourceDictionaryRest(ResourceDictionaryHandler resourceDictionaryHandler) { + this.resourceDictionaryHandler = resourceDictionaryHandler; } @PostMapping(path = "", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody ResourceDictionary saveResourceDictionary(@RequestBody ResourceDictionary dataDictionary) throws BluePrintException { - return resourceDictionaryService.saveResourceDictionary(dataDictionary); + return resourceDictionaryHandler.saveResourceDictionary(dataDictionary); } @DeleteMapping(path = "/{name}") public void deleteResourceDictionaryByName(@PathVariable(value = "name") String name) { - resourceDictionaryService.deleteResourceDictionary(name); + resourceDictionaryHandler.deleteResourceDictionary(name); } @GetMapping(path = "/{name}", produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody ResourceDictionary getResourceDictionaryByName(@PathVariable(value = "name") String name) throws BluePrintException { - return resourceDictionaryService.getResourceDictionaryByName(name); + return resourceDictionaryHandler.getResourceDictionaryByName(name); } @PostMapping(path = "/by-names", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody List searchResourceDictionaryByNames(@RequestBody List names) { - return resourceDictionaryService.searchResourceDictionaryByNames(names); + return resourceDictionaryHandler.searchResourceDictionaryByNames(names); } @GetMapping(path = "/search/{tags}", produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody List searchResourceDictionaryByTags(@PathVariable(value = "tags") String tags) { - return resourceDictionaryService.searchResourceDictionaryByTags(tags); + return resourceDictionaryHandler.searchResourceDictionaryByTags(tags); } @GetMapping(path = "/source-mapping", produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody ResourceSourceMapping getResourceSourceMapping() { - return resourceDictionaryService.getResourceSourceMapping(); + return resourceDictionaryHandler.getResourceSourceMapping(); } } diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoServiceImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoServiceImpl.kt index 50e19b2fe..c818410f7 100644 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoServiceImpl.kt +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoServiceImpl.kt @@ -94,8 +94,8 @@ open class BluePrintRepoFileService(private val modelTypeRepository: ModelTypeRe private fun getModelDefinition(modelName: String): JsonNode { val modelDefinition: JsonNode val modelTypeDb = modelTypeRepository.findByModelName(modelName) - if (modelTypeDb.isPresent) { - modelDefinition = modelTypeDb.get().definition + if (modelTypeDb != null) { + modelDefinition = modelTypeDb.definition } else { throw BluePrintException(String.format("failed to get model definition (%s) from repo", modelName)) } diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/controller/ModelTypeController.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/controller/ModelTypeController.kt new file mode 100644 index 000000000..db82849e8 --- /dev/null +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/controller/ModelTypeController.kt @@ -0,0 +1,56 @@ +/* + * 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.controller + +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType +import org.onap.ccsdk.apps.controllerblueprints.service.handler.ModelTypeHandler +import org.springframework.http.MediaType +import org.springframework.web.bind.annotation.* + +@RestController +@RequestMapping(value = arrayOf("/api/v1/model-type")) +open class ModelTypeController(private val modelTypeHandler: ModelTypeHandler) { + + @GetMapping(path = arrayOf("/{name}"), produces = arrayOf(MediaType.APPLICATION_JSON_VALUE)) + fun getModelTypeByName(@PathVariable(value = "name") name: String): ModelType? { + return modelTypeHandler.getModelTypeByName(name) + } + + @GetMapping(path = arrayOf("/search/{tags}"), produces = arrayOf(MediaType.APPLICATION_JSON_VALUE)) + fun searchModelTypes(@PathVariable(value = "tags") tags: String): List { + return modelTypeHandler.searchModelTypes(tags) + } + + @GetMapping(path = arrayOf("/by-definition/{definitionType}"), produces = arrayOf(MediaType.APPLICATION_JSON_VALUE)) + @ResponseBody + fun getModelTypeByDefinitionType(@PathVariable(value = "definitionType") definitionType: String): List { + return modelTypeHandler.getModelTypeByDefinitionType(definitionType) + } + + @PostMapping(path = arrayOf(""), produces = arrayOf(MediaType.APPLICATION_JSON_VALUE), consumes = arrayOf(MediaType.APPLICATION_JSON_VALUE)) + @ResponseBody + @Throws(BluePrintException::class) + fun saveModelType(@RequestBody modelType: ModelType): ModelType { + return modelTypeHandler.saveModel(modelType) + } + + @DeleteMapping(path = arrayOf("/{name}")) + fun deleteModelTypeByName(@PathVariable(value = "name") name: String) { + modelTypeHandler.deleteByModelName(name) + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/handler/ModelTypeHandler.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/handler/ModelTypeHandler.kt new file mode 100644 index 000000000..8099d07ff --- /dev/null +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/handler/ModelTypeHandler.kt @@ -0,0 +1,116 @@ +/* + * 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.handler + +import com.att.eelf.configuration.EELFManager +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType +import org.onap.ccsdk.apps.controllerblueprints.service.repository.ModelTypeRepository +import org.onap.ccsdk.apps.controllerblueprints.service.validator.ModelTypeValidator +import org.springframework.stereotype.Service + +@Service +open class ModelTypeHandler(private val modelTypeRepository: ModelTypeRepository) { + + private val log = EELFManager.getInstance().getLogger(ModelTypeHandler::class.java)!! + + /** + * This is a getModelTypeByName service + * + * @param modelTypeName modelTypeName + * @return ModelType + */ + fun getModelTypeByName(modelTypeName: String): ModelType? { + log.info("Searching : $modelTypeName") + check(modelTypeName.isNotBlank()) { "Model Name Information is missing." } + return modelTypeRepository.findByModelName(modelTypeName) + } + + + /** + * This is a searchModelTypes service + * + * @param tags tags + * @return List + */ + fun searchModelTypes(tags: String): List { + check(tags.isNotBlank()) { "No Search Information provide" } + return modelTypeRepository.findByTagsContainingIgnoreCase(tags) + } + + /** + * This is a saveModel service + * + * @param modelType modelType + * @return ModelType + * @throws BluePrintException BluePrintException + */ + @Throws(BluePrintException::class) + open fun saveModel(modelType: ModelType): ModelType { + lateinit var dbModel: ModelType + ModelTypeValidator.validateModelType(modelType) + val dbModelType: ModelType? = modelTypeRepository.findByModelName(modelType.modelName) + if (dbModelType != null) { + dbModel = dbModelType + dbModel.description = modelType.description + dbModel.definition = modelType.definition + dbModel.definitionType = modelType.definitionType + dbModel.derivedFrom = modelType.derivedFrom + dbModel.tags = modelType.tags + dbModel.version = modelType.version + dbModel.updatedBy = modelType.updatedBy + dbModel = modelTypeRepository.save(dbModel) + } else { + dbModel = modelTypeRepository.save(modelType) + } + return dbModel + } + + + /** + * This is a deleteByModelName service + * + * @param modelName modelName + */ + open fun deleteByModelName(modelName: String) { + check(modelName.isNotBlank()) { "Model Name Information is missing." } + modelTypeRepository.deleteByModelName(modelName) + + } + + /** + * This is a getModelTypeByDefinitionType service + * + * @param definitionType definitionType + * @return List + */ + fun getModelTypeByDefinitionType(definitionType: String): List { + check(definitionType.isNotBlank()) { "Model definitionType Information is missing." } + return modelTypeRepository.findByDefinitionType(definitionType) + } + + /** + * This is a getModelTypeByDerivedFrom service + * + * @param derivedFrom derivedFrom + * @return List + */ + fun getModelTypeByDerivedFrom(derivedFrom: String): List { + check(derivedFrom.isNotBlank()) { "Model derivedFrom Information is missing." } + return modelTypeRepository.findByDerivedFrom(derivedFrom) + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/handler/ResourceDictionaryHandler.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/handler/ResourceDictionaryHandler.kt new file mode 100644 index 000000000..c24931484 --- /dev/null +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/handler/ResourceDictionaryHandler.kt @@ -0,0 +1,138 @@ +/* + * 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.handler + +import com.google.common.base.Preconditions +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.resource.dict.ResourceSourceMapping +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.factory.ResourceSourceMappingFactory +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionValidationService +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 +import org.springframework.stereotype.Service + +@Service +class ResourceDictionaryHandler(private val resourceDictionaryRepository: ResourceDictionaryRepository, + private val resourceDictionaryValidationService: ResourceDefinitionValidationService) { + + + /** + * This is a getDataDictionaryByName service + * + * @param name name + * @return DataDictionary + * @throws BluePrintException BluePrintException + */ + @Throws(BluePrintException::class) + fun getResourceDictionaryByName(name: String): ResourceDictionary { + Preconditions.checkArgument(StringUtils.isNotBlank(name), "Resource dictionary Name Information is missing.") + val resourceDictionaryDb = resourceDictionaryRepository.findByName(name) + return if (resourceDictionaryDb.isPresent) { + resourceDictionaryDb.get() + } else { + throw BluePrintException(String.format("couldn't get resource dictionary for name (%s)", name)) + } + } + + /** + * This is a searchResourceDictionaryByNames service + * + * @param names names + * @return List + */ + fun searchResourceDictionaryByNames(names: List): List { + Preconditions.checkArgument(CollectionUtils.isNotEmpty(names), "No Search Information provide") + return resourceDictionaryRepository.findByNameIn(names) + } + + /** + * This is a searchResourceDictionaryByTags service + * + * @param tags tags + * @return List + */ + fun searchResourceDictionaryByTags(tags: String): List { + Preconditions.checkArgument(StringUtils.isNotBlank(tags), "No search tag information provide") + return resourceDictionaryRepository.findByTagsContainingIgnoreCase(tags) + } + + /** + * This is a saveDataDictionary service + * + * @param resourceDictionary resourceDictionary + * @return DataDictionary + */ + @Throws(BluePrintException::class) + fun saveResourceDictionary(resourceDictionary: ResourceDictionary): ResourceDictionary { + var resourceDictionary = resourceDictionary + + val resourceDefinition = resourceDictionary.definition + Preconditions.checkNotNull(resourceDefinition, "failed to get resource definition from content") + // Validate the Resource Definitions + resourceDictionaryValidationService.validate(resourceDefinition) + + resourceDictionary.tags = resourceDefinition.tags + resourceDefinition.updatedBy = resourceDictionary.updatedBy + // Set the Property Definitions + val propertyDefinition = resourceDefinition.property + resourceDictionary.description = propertyDefinition.description + resourceDictionary.dataType = propertyDefinition.type + if (propertyDefinition.entrySchema != null) { + resourceDictionary.entrySchema = propertyDefinition.entrySchema!!.type + } + + ResourceDictionaryValidator.validateResourceDictionary(resourceDictionary) + + val dbResourceDictionaryData = resourceDictionaryRepository.findByName(resourceDictionary.name) + if (dbResourceDictionaryData.isPresent) { + val dbResourceDictionary = dbResourceDictionaryData.get() + + dbResourceDictionary.name = resourceDictionary.name + dbResourceDictionary.definition = resourceDictionary.definition + dbResourceDictionary.description = resourceDictionary.description + dbResourceDictionary.tags = resourceDictionary.tags + dbResourceDictionary.updatedBy = resourceDictionary.updatedBy + dbResourceDictionary.dataType = resourceDictionary.dataType + dbResourceDictionary.entrySchema = resourceDictionary.entrySchema + resourceDictionary = resourceDictionaryRepository.save(dbResourceDictionary) + } else { + resourceDictionary = resourceDictionaryRepository.save(resourceDictionary) + } + + return resourceDictionary + } + + /** + * This is a deleteResourceDictionary service + * + * @param name name + */ + fun deleteResourceDictionary(name: String) { + check(name.isNotBlank()) { "Resource dictionary name is missing." } + resourceDictionaryRepository.deleteByName(name) + } + + /** + * This is a getResourceSourceMapping service + */ + fun getResourceSourceMapping(): ResourceSourceMapping { + return ResourceSourceMappingFactory.getRegisterSourceMapping() + } +} \ 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 31b1a16bd..51bbca7d2 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 @@ -25,14 +25,14 @@ 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.service.ModelTypeService import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType +import org.onap.ccsdk.apps.controllerblueprints.service.handler.ModelTypeHandler import org.springframework.stereotype.Service import java.io.File import java.nio.charset.Charset @Service -open class ModelTypeLoadService(private val modelTypeService: ModelTypeService) { +open class ModelTypeLoadService(private val modelTypeHandler: ModelTypeHandler) { private val log = EELFManager.getInstance().getLogger(ModelTypeLoadService::class.java) private val updateBySystem = "System" @@ -100,7 +100,7 @@ open class ModelTypeLoadService(private val modelTypeService: ModelTypeService) modelType.version = dataType.version modelType.updatedBy = updateBySystem modelType.tags = (dataKey + "," + dataType.derivedFrom + "," + BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE) - modelTypeService.saveModel(modelType) + modelTypeHandler.saveModel(modelType) log.trace("DataType(${file.name}) loaded successfully ") } catch (e: Exception) { errorBuilder.appendln("Couldn't load DataType(${file.name}: ${e.message}") @@ -124,7 +124,7 @@ open class ModelTypeLoadService(private val modelTypeService: ModelTypeService) modelType.version = artifactType.version modelType.updatedBy = updateBySystem modelType.tags = (dataKey + "," + artifactType.derivedFrom + "," + BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE) - modelTypeService.saveModel(modelType) + modelTypeHandler.saveModel(modelType) log.trace("ArtifactType(${file.name}) loaded successfully ") } catch (e: Exception) { errorBuilder.appendln("Couldn't load ArtifactType(${file.name}: ${e.message}") @@ -148,7 +148,7 @@ open class ModelTypeLoadService(private val modelTypeService: ModelTypeService) modelType.version = nodeType.version modelType.updatedBy = updateBySystem modelType.tags = (nodeKey + "," + BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE + "," + nodeType.derivedFrom) - modelTypeService.saveModel(modelType) + modelTypeHandler.saveModel(modelType) log.trace("NodeType(${file.name}) loaded successfully ") } catch (e: Exception) { errorBuilder.appendln("Couldn't load NodeType(${file.name}: ${e.message}") 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 4bb8a2f3a..8100cac39 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 @@ -25,14 +25,14 @@ import org.apache.commons.lang3.text.StrBuilder import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException 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.ResourceDictionaryService import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary +import org.onap.ccsdk.apps.controllerblueprints.service.handler.ResourceDictionaryHandler import org.springframework.stereotype.Service import java.io.File import java.nio.charset.Charset @Service -open class ResourceDictionaryLoadService(private val resourceDictionaryService: ResourceDictionaryService) { +open class ResourceDictionaryLoadService(private val resourceDictionaryHandler: ResourceDictionaryHandler) { private val log = EELFManager.getInstance().getLogger(ResourceDictionaryLoadService::class.java) @@ -92,7 +92,7 @@ open class ResourceDictionaryLoadService(private val resourceDictionaryService: } else { resourceDictionary.tags = resourceDefinition.tags } - resourceDictionaryService.saveResourceDictionary(resourceDictionary) + resourceDictionaryHandler.saveResourceDictionary(resourceDictionary) log.trace("Resource dictionary(${file.name}) loaded successfully ") } else { diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/repository/ModelTypeRepository.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/repository/ModelTypeRepository.kt new file mode 100644 index 000000000..990cc6518 --- /dev/null +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/repository/ModelTypeRepository.kt @@ -0,0 +1,85 @@ +/* + * 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.repository + +import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType +import org.springframework.data.jpa.repository.JpaRepository +import org.springframework.stereotype.Repository +import javax.transaction.Transactional + +@Repository +interface ModelTypeRepository : JpaRepository { + /** + * This is a findByModelName method + * + * @param modelName Model Name + * @return Optional + */ + fun findByModelName(modelName: String): ModelType? + /** + * This is a findByModelNameIn method + * + * @param modelNames Model Names + * @return List + */ + fun findByModelNameIn(modelNames: List): List + /** + * This is a findByDerivedFrom method + * + * @param derivedFrom Derived From + * @return List + */ + fun findByDerivedFrom(derivedFrom: String): List + /** + * This is a findByDerivedFromIn method + * + * @param derivedFroms Derived Froms + * @return List + */ + fun findByDerivedFromIn(derivedFroms: List): List + + /** + * This is a findByDefinitionType method + * + * @param definitionType Definition Type + * @return List + */ + fun findByDefinitionType(definitionType: String): List + /** + * This is a findByDefinitionTypeIn method + * + * @param definitionTypes Definition Types + * @return List + */ + fun findByDefinitionTypeIn(definitionTypes: List): List + + /** + * This is a findByTagsContainingIgnoreCase method + * + * @param tags Tags + * @return Optional + */ + fun findByTagsContainingIgnoreCase(tags: String): List + + /** + * This is a deleteByModelName method + * + * @param modelName ModelName + */ + @Transactional + fun deleteByModelName(modelName: String) +} diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeServiceTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeServiceTest.java index 8e258ab6d..e2bb4c5fa 100644 --- a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeServiceTest.java +++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/ModelTypeServiceTest.java @@ -25,9 +25,11 @@ import org.onap.ccsdk.apps.controllerblueprints.TestApplication; import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants; 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.handler.ModelTypeHandler; import org.onap.ccsdk.apps.controllerblueprints.service.rs.ModelTypeRestTest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; +import org.springframework.test.annotation.Commit; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.transaction.annotation.Propagation; @@ -43,11 +45,12 @@ import java.util.List; public class ModelTypeServiceTest { private static EELFLogger log = EELFManager.getInstance().getLogger(ModelTypeRestTest.class); @Autowired - ModelTypeService modelTypeService; + private ModelTypeHandler modelTypeHandler; String modelName = "test-datatype"; @Test + @Commit public void test01SaveModelType() throws Exception { log.info("**************** test01SaveModelType ********************"); @@ -62,18 +65,18 @@ public class ModelTypeServiceTest { modelType.setTags("test-datatype ," + BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT + "," + BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE); modelType.setUpdatedBy("xxxxxx@xxx.com"); - modelType = modelTypeService.saveModel(modelType); + modelType = modelTypeHandler.saveModel(modelType); log.info("Saved Mode {}", modelType.toString()); Assert.assertNotNull("Failed to get Saved ModelType", modelType); Assert.assertNotNull("Failed to get Saved ModelType, Id", modelType.getModelName()); - ModelType dbModelType = modelTypeService.getModelTypeByName(modelType.getModelName()); + ModelType dbModelType = modelTypeHandler.getModelTypeByName(modelType.getModelName()); Assert.assertNotNull("Failed to query ResourceMapping for ID (" + dbModelType.getModelName() + ")", dbModelType); // Model Update modelType.setUpdatedBy("bs2796@xxx.com"); - modelType = modelTypeService.saveModel(modelType); + modelType = modelTypeHandler.saveModel(modelType); Assert.assertNotNull("Failed to get Saved ModelType", modelType); Assert.assertEquals("Failed to get Saved getUpdatedBy ", "bs2796@xxx.com", modelType.getUpdatedBy()); @@ -85,7 +88,7 @@ public class ModelTypeServiceTest { String tags = "test-datatype"; - List dbModelTypes = modelTypeService.searchModelTypes(tags); + List dbModelTypes = modelTypeHandler.searchModelTypes(tags); Assert.assertNotNull("Failed to search ResourceMapping by tags", dbModelTypes); Assert.assertTrue("Failed to search ResourceMapping by tags count", dbModelTypes.size() > 0); @@ -94,17 +97,17 @@ public class ModelTypeServiceTest { @Test public void test03GetModelType() throws Exception { log.info("************************* test03GetModelType *********************************"); - ModelType dbModelType = modelTypeService.getModelTypeByName(modelName); + ModelType dbModelType = modelTypeHandler.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()); List dbDatatypeModelTypes = - modelTypeService.getModelTypeByDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE); + modelTypeHandler.getModelTypeByDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE); Assert.assertNotNull("Failed to find getModelTypeByDefinitionType by tags", dbDatatypeModelTypes); Assert.assertTrue("Failed to find getModelTypeByDefinitionType by count", dbDatatypeModelTypes.size() > 0); List dbModelTypeByDerivedFroms = - modelTypeService.getModelTypeByDerivedFrom(BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT); + modelTypeHandler.getModelTypeByDerivedFrom(BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT); Assert.assertNotNull("Failed to find getModelTypeByDerivedFrom by tags", dbModelTypeByDerivedFroms); Assert.assertTrue("Failed to find getModelTypeByDerivedFrom by count", dbModelTypeByDerivedFroms.size() > 0); @@ -114,10 +117,10 @@ public class ModelTypeServiceTest { public void test04DeleteModelType() throws Exception { log.info( "************************ test03DeleteModelType ***********************"); - ModelType dbResourceMapping = modelTypeService.getModelTypeByName(modelName); + ModelType dbResourceMapping = modelTypeHandler.getModelTypeByName(modelName); Assert.assertNotNull("Failed to get response for api call getModelByName ", dbResourceMapping); Assert.assertNotNull("Failed to get Id for api call getModelByName ", dbResourceMapping.getModelName()); - modelTypeService.deleteByModelName(dbResourceMapping.getModelName()); + modelTypeHandler.deleteByModelName(dbResourceMapping.getModelName()); } } \ No newline at end of file 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 c7147490d..d283377b3 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 @@ -17,48 +17,37 @@ package org.onap.ccsdk.apps.controllerblueprints.service.rs; -import org.apache.commons.io.FileUtils; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; 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.core.BluePrintConstants; import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils; +import org.onap.ccsdk.apps.controllerblueprints.service.controller.ModelTypeController; import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType; -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.boot.test.autoconfigure.orm.jpa.DataJpaTest; +import org.springframework.test.annotation.Commit; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; -import java.io.File; -import java.nio.charset.Charset; import java.util.List; @RunWith(SpringRunner.class) -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) +@DataJpaTest @ContextConfiguration(classes = {TestApplication.class}) @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class ModelTypeRestTest { private static EELFLogger log = EELFManager.getInstance().getLogger(ModelTypeRestTest.class); @Autowired - ModelTypeRest modelTypeRest; + ModelTypeController modelTypeController; String modelName = "test-datatype"; - @Before - public void setUp() { - - } - - - @After - public void tearDown() { - } - @Test + @Commit public void test01SaveModelType() throws Exception { log.info("**************** test01SaveModelType ********************"); @@ -73,18 +62,18 @@ public class ModelTypeRestTest { modelType.setTags("test-datatype ," + BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT + "," + BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE); modelType.setUpdatedBy("xxxxxx@xxx.com"); - modelType = modelTypeRest.saveModelType(modelType); + modelType = modelTypeController.saveModelType(modelType); log.info("Saved Mode {}", modelType.toString()); Assert.assertNotNull("Failed to get Saved ModelType", modelType); Assert.assertNotNull("Failed to get Saved ModelType, Id", modelType.getModelName()); - ModelType dbModelType = modelTypeRest.getModelTypeByName(modelType.getModelName()); + ModelType dbModelType = modelTypeController.getModelTypeByName(modelType.getModelName()); Assert.assertNotNull("Failed to query ResourceMapping for ID (" + dbModelType.getModelName() + ")", dbModelType); // Model Update modelType.setUpdatedBy("bs2796@xxx.com"); - modelType = modelTypeRest.saveModelType(modelType); + modelType = modelTypeController.saveModelType(modelType); Assert.assertNotNull("Failed to get Saved ModelType", modelType); Assert.assertEquals("Failed to get Saved getUpdatedBy ", "bs2796@xxx.com", modelType.getUpdatedBy()); @@ -96,7 +85,7 @@ public class ModelTypeRestTest { String tags = "test-datatype"; - List dbModelTypes = modelTypeRest.searchModelTypes(tags); + List dbModelTypes = modelTypeController.searchModelTypes(tags); Assert.assertNotNull("Failed to search ResourceMapping by tags", dbModelTypes); Assert.assertTrue("Failed to search ResourceMapping by tags count", dbModelTypes.size() > 0); @@ -105,25 +94,26 @@ public class ModelTypeRestTest { @Test public void test03GetModelType() throws Exception { log.info("************************* test03GetModelType *********************************"); - ModelType dbModelType = modelTypeRest.getModelTypeByName(modelName); - Assert.assertNotNull("Failed to get response for api call getModelByName ", dbModelType); + ModelType dbModelType = modelTypeController.getModelTypeByName(modelName); + Assert.assertNotNull("Failed to get response for api call getModelByName " + modelName, dbModelType); Assert.assertNotNull("Failed to get Id for api call getModelByName ", dbModelType.getModelName()); List dbDatatypeModelTypes = - modelTypeRest.getModelTypeByDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE); + modelTypeController.getModelTypeByDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE); Assert.assertNotNull("Failed to find getModelTypeByDefinitionType by tags", dbDatatypeModelTypes); Assert.assertTrue("Failed to find getModelTypeByDefinitionType by count", dbDatatypeModelTypes.size() > 0); } @Test + @Commit public void test04DeleteModelType() throws Exception { log.info( "************************ test03DeleteModelType ***********************"); - ModelType dbResourceMapping = modelTypeRest.getModelTypeByName(modelName); + ModelType dbResourceMapping = modelTypeController.getModelTypeByName(modelName); Assert.assertNotNull("Failed to get response for api call getModelByName ", dbResourceMapping); Assert.assertNotNull("Failed to get Id for api call getModelByName ", dbResourceMapping.getModelName()); - modelTypeRest.deleteModelTypeByName(dbResourceMapping.getModelName()); + modelTypeController.deleteModelTypeByName(dbResourceMapping.getModelName()); } 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 675d2c246..9c02d4cfe 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 @@ -29,6 +29,7 @@ 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; import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment; +import org.onap.ccsdk.apps.controllerblueprints.service.controller.ModelTypeController; import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModelContent; import org.onap.ccsdk.apps.controllerblueprints.service.model.AutoMapResponse; import com.att.eelf.configuration.EELFLogger; @@ -52,7 +53,7 @@ public class ServiceTemplateRestTest { private static EELFLogger log = EELFManager.getInstance().getLogger(ServiceTemplateRestTest.class); @Autowired - ModelTypeRest modelTypeRest; + ModelTypeController modelTypeRest; @Autowired private ServiceTemplateRest serviceTemplateRest; diff --git a/ms/controllerblueprints/parent/pom.xml b/ms/controllerblueprints/parent/pom.xml index b91343180..38a879ab8 100644 --- a/ms/controllerblueprints/parent/pom.xml +++ b/ms/controllerblueprints/parent/pom.xml @@ -113,6 +113,11 @@ kotlinx-couroutines-core ${kotlin.couroutines.version} + + org.jetbrains.kotlinx + kotlinx-coroutines-reactor + ${kotlin.couroutines.version} + org.jetbrains.kotlin kotlin-reflect -- cgit 1.2.3-korg From 7f6c527bac8c0c60a2988e59ff7251178f904cdd Mon Sep 17 00:00:00 2001 From: Alexis de Talhouët Date: Mon, 7 Jan 2019 16:33:02 -0500 Subject: Add support for blueprintprocessor runtime DB MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - created db-resources module to store controller blueprint related controller blueprint repository and entities. Also create an abstract BlueprintCatalogServiceImpl so it can be used both by controllerblueprint and blueprintprocessor - created blueprint-validation to store the implementation of the validation interface. - change controllerblueprint service to levrage db-resources - implement CatalogService for blueprintprocessor db-lib by using db-resources. Change-Id: I0539e414e4ff3b7a6edf0f6304d6cbc5e6eac404 Issue-ID: CCSDK-664 Signed-off-by: Alexis de Talhouët --- .../modules/blueprint-validation/pom.xml | 52 ++++++ .../BluePrintTypeValidatorServiceImpl.kt | 66 ++++++++ .../validation/BluePrintValidatorDefaultService.kt | 100 ++++++++++++ .../modules/db-resources/pom.xml | 47 ++++++ .../db/resources/BlueprintCatalogServiceImpl.kt | 82 ++++++++++ .../resources/repository/ModelContentRepository.kt | 93 +++++++++++ .../db/resources/repository/ModelRepository.kt | 88 ++++++++++ ms/controllerblueprints/modules/pom.xml | 8 +- ms/controllerblueprints/modules/service/pom.xml | 180 +++++++++++---------- .../service/BlueprintModelService.java | 32 ++-- .../service/common/ApplicationConstants.java | 34 ---- .../BlueprintModelContentRepository.java | 102 ------------ .../repository/BlueprintModelRepository.java | 96 ----------- .../repository/BlueprintModelSearchRepository.java | 69 -------- .../ControllerBlueprintModelSearchRepository.java | 69 ++++++++ .../service/BluePrintCoreConfiguration.kt | 60 ------- .../service/BluePrintRepoServiceImpl.kt | 11 ++ .../ControllerBluePrintCoreConfiguration.kt | 60 +++++++ .../service/load/BluePrintCatalogServiceImpl.kt | 135 ---------------- .../service/load/BluePrintDatabaseLoadService.kt | 1 + .../service/load/BluePrintLoadConfiguration.kt | 34 ---- .../load/ControllerBlueprintCatalogServiceImpl.kt | 86 ++++++++++ .../ControllerBlueprintModelContentRepository.kt | 22 +++ .../ControllerBlueprintModelRepository.kt | 21 +++ .../validator/BluePrintTypeValidatorServiceImpl.kt | 66 -------- .../validator/BluePrintValidatorDefaultService.kt | 103 ------------ ms/controllerblueprints/parent/pom.xml | 10 ++ 27 files changed, 926 insertions(+), 801 deletions(-) create mode 100644 ms/controllerblueprints/modules/blueprint-validation/pom.xml create mode 100644 ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/blueprint/validation/BluePrintTypeValidatorServiceImpl.kt create mode 100644 ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/blueprint/validation/BluePrintValidatorDefaultService.kt create mode 100644 ms/controllerblueprints/modules/db-resources/pom.xml create mode 100644 ms/controllerblueprints/modules/db-resources/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/db/resources/BlueprintCatalogServiceImpl.kt create mode 100644 ms/controllerblueprints/modules/db-resources/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/db/resources/repository/ModelContentRepository.kt create mode 100644 ms/controllerblueprints/modules/db-resources/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/db/resources/repository/ModelRepository.kt delete mode 100644 ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ApplicationConstants.java delete mode 100644 ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/BlueprintModelContentRepository.java delete mode 100644 ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/BlueprintModelRepository.java delete mode 100644 ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/BlueprintModelSearchRepository.java create mode 100644 ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ControllerBlueprintModelSearchRepository.java delete mode 100644 ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintCoreConfiguration.kt create mode 100644 ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/ControllerBluePrintCoreConfiguration.kt delete mode 100755 ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintCatalogServiceImpl.kt delete mode 100644 ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintLoadConfiguration.kt create mode 100755 ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/ControllerBlueprintCatalogServiceImpl.kt create mode 100644 ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/repository/ControllerBlueprintModelContentRepository.kt create mode 100644 ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/repository/ControllerBlueprintModelRepository.kt delete mode 100644 ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/BluePrintTypeValidatorServiceImpl.kt delete mode 100644 ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/BluePrintValidatorDefaultService.kt (limited to 'ms/controllerblueprints/parent') diff --git a/ms/controllerblueprints/modules/blueprint-validation/pom.xml b/ms/controllerblueprints/modules/blueprint-validation/pom.xml new file mode 100644 index 000000000..0cafc9a65 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-validation/pom.xml @@ -0,0 +1,52 @@ + + + + + 4.0.0 + + org.onap.ccsdk.apps.controllerblueprints + modules + 0.4.0-SNAPSHOT + + blueprint-validation + Controller Blueprints Validation Service + + + + org.springframework + spring-core + + + org.springframework + spring-context + + + org.onap.ccsdk.apps.controllerblueprints + core + + + org.onap.ccsdk.apps.controllerblueprints + resource-dict + + + + diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/blueprint/validation/BluePrintTypeValidatorServiceImpl.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/blueprint/validation/BluePrintTypeValidatorServiceImpl.kt new file mode 100644 index 000000000..76dfa73e3 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/blueprint/validation/BluePrintTypeValidatorServiceImpl.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.blueprint.validation + +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.* +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.context.ApplicationContext +import org.springframework.stereotype.Service + +@Service +class BluePrintTypeValidatorServiceImpl : BluePrintTypeValidatorService { + + @Autowired + private lateinit var context: ApplicationContext + + override fun getServiceTemplateValidators(): List { + return context.getBeansOfType(BluePrintServiceTemplateValidator::class.java).mapNotNull { it.value } + } + + override fun getDataTypeValidators(): List { + return context.getBeansOfType(BluePrintDataTypeValidator::class.java).mapNotNull { it.value } + } + + override fun getArtifactTypeValidators(): List { + return context.getBeansOfType(BluePrintArtifactTypeValidator::class.java).mapNotNull { it.value } + } + + override fun getNodeTypeValidators(): List { + return context.getBeansOfType(BluePrintNodeTypeValidator::class.java).mapNotNull { it.value } + } + + override fun getTopologyTemplateValidators(): List { + return context.getBeansOfType(BluePrintTopologyTemplateValidator::class.java).mapNotNull { it.value } + } + + override fun getNodeTemplateValidators(): List { + return context.getBeansOfType(BluePrintNodeTemplateValidator::class.java).mapNotNull { it.value } + } + + override fun getWorkflowValidators(): List { + return context.getBeansOfType(BluePrintWorkflowValidator::class.java).mapNotNull { it.value } + } + + override fun getPropertyDefinitionValidators(): List { + return context.getBeansOfType(BluePrintPropertyDefinitionValidator::class.java).mapNotNull { it.value } + } + + override fun getAttributeDefinitionValidators(): List { + return context.getBeansOfType(BluePrintAttributeDefinitionValidator::class.java).mapNotNull { it.value } + } +} + diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/blueprint/validation/BluePrintValidatorDefaultService.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/blueprint/validation/BluePrintValidatorDefaultService.kt new file mode 100644 index 000000000..2993b3d35 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/blueprint/validation/BluePrintValidatorDefaultService.kt @@ -0,0 +1,100 @@ +/* + * 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.blueprint.validation + +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.core.interfaces.BluePrintTypeValidatorService +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintValidatorService +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService +import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils +import org.onap.ccsdk.apps.controllerblueprints.core.validation.BluePrintArtifactTypeValidatorImpl +import org.onap.ccsdk.apps.controllerblueprints.core.validation.BluePrintAttributeDefinitionValidatorImpl +import org.onap.ccsdk.apps.controllerblueprints.core.validation.BluePrintDataTypeValidatorImpl +import org.onap.ccsdk.apps.controllerblueprints.core.validation.BluePrintNodeTemplateValidatorImpl +import org.onap.ccsdk.apps.controllerblueprints.core.validation.BluePrintNodeTypeValidatorImpl +import org.onap.ccsdk.apps.controllerblueprints.core.validation.BluePrintPropertyDefinitionValidatorImpl +import org.onap.ccsdk.apps.controllerblueprints.core.validation.BluePrintServiceTemplateValidatorImpl +import org.onap.ccsdk.apps.controllerblueprints.core.validation.BluePrintTopologyTemplateValidatorImpl +import org.onap.ccsdk.apps.controllerblueprints.core.validation.BluePrintValidatorServiceImpl +import org.onap.ccsdk.apps.controllerblueprints.core.validation.BluePrintWorkflowValidatorImpl +import org.springframework.stereotype.Service +import java.util.* + +@Service +class BluePrintTypeValidatorDefaultService(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) + : BluePrintValidatorService { + + private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintValidatorServiceImpl::class.toString()) + + override fun validateBluePrints(basePath: String): Boolean { + + log.info("validating blueprint($basePath)") + val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(UUID.randomUUID().toString(), basePath) + return validateBluePrints(bluePrintRuntimeService) + } + + override fun validateBluePrints(bluePrintRuntimeService: BluePrintRuntimeService<*>): Boolean { + + bluePrintTypeValidatorService.validateServiceTemplate(bluePrintRuntimeService, "service_template", + bluePrintRuntimeService.bluePrintContext().serviceTemplate) + + if (bluePrintRuntimeService.getBluePrintError().errors.size > 0) { + throw BluePrintException("failed in blueprint validation : ${bluePrintRuntimeService.getBluePrintError().errors.joinToString("\n")}") + } + return true + } +} + +// Core Validator Services + +@Service +class DefaultBluePrintServiceTemplateValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService) + : BluePrintServiceTemplateValidatorImpl(bluePrintTypeValidatorService) + +@Service +class DefaultBluePrintDataTypeValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService) + : BluePrintDataTypeValidatorImpl(bluePrintTypeValidatorService) + +@Service +class DefaultBluePrintArtifactTypeValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService) + : BluePrintArtifactTypeValidatorImpl(bluePrintTypeValidatorService) + +@Service +class DefaultBluePrintNodeTypeValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService) + : BluePrintNodeTypeValidatorImpl(bluePrintTypeValidatorService) + +@Service +class DefaultBluePrintTopologyTemplateValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService) + : BluePrintTopologyTemplateValidatorImpl(bluePrintTypeValidatorService) + +@Service +class DefaulBluePrintNodeTemplateValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService) + : BluePrintNodeTemplateValidatorImpl(bluePrintTypeValidatorService) + +@Service +class DefaultBluePrintWorkflowValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService) + : BluePrintWorkflowValidatorImpl(bluePrintTypeValidatorService) + +@Service +class DefaulBluePrintPropertyDefinitionValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService) + : BluePrintPropertyDefinitionValidatorImpl(bluePrintTypeValidatorService) + +@Service +class DefaultBluePrintAttributeDefinitionValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService) + : BluePrintAttributeDefinitionValidatorImpl(bluePrintTypeValidatorService) \ No newline at end of file diff --git a/ms/controllerblueprints/modules/db-resources/pom.xml b/ms/controllerblueprints/modules/db-resources/pom.xml new file mode 100644 index 000000000..69e322e40 --- /dev/null +++ b/ms/controllerblueprints/modules/db-resources/pom.xml @@ -0,0 +1,47 @@ + + + + + 4.0.0 + + org.onap.ccsdk.apps.controllerblueprints + modules + 0.4.0-SNAPSHOT + + db-resources + Controller Blueprints DB Resources + + + + + + + org.onap.ccsdk.apps.controllerblueprints + core + + + org.springframework.boot + spring-boot-starter-data-jpa + + + + diff --git a/ms/controllerblueprints/modules/db-resources/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/db/resources/BlueprintCatalogServiceImpl.kt b/ms/controllerblueprints/modules/db-resources/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/db/resources/BlueprintCatalogServiceImpl.kt new file mode 100644 index 000000000..881e3bc40 --- /dev/null +++ b/ms/controllerblueprints/modules/db-resources/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/db/resources/BlueprintCatalogServiceImpl.kt @@ -0,0 +1,82 @@ +/* + * 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. + */ + +package org.onap.ccsdk.apps.controllerblueprints.db.resources + +import org.onap.ccsdk.apps.controllerblueprints.core.config.BluePrintLoadConfiguration +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintCatalogService +import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintArchiveUtils +import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintFileUtils +import java.io.File +import javax.persistence.MappedSuperclass + +@MappedSuperclass +abstract class BlueprintCatalogServiceImpl(private val bluePrintLoadConfiguration: BluePrintLoadConfiguration) : BluePrintCatalogService { + + override fun uploadToDataBase(file: String, validate: Boolean): String { + // The file name provided here is unique as we transform to UUID before storing + val blueprintFile = File(file) + val fileName = blueprintFile.name + val id = BluePrintFileUtils.stripFileExtension(fileName) + // If the file is directory + if (blueprintFile.isDirectory) { + + val zipFile = File("${bluePrintLoadConfiguration.blueprintArchivePath}/$fileName") + // zip the directory + BluePrintArchiveUtils.compress(blueprintFile, zipFile, true) + + // Upload to the Data Base + saveToDataBase(blueprintFile, id, zipFile) + + // After Upload to Database delete the zip file + zipFile.delete() + + } else { + // If the file is ZIP + // unzip the CBA file to validate before store in database + val targetDir = "${bluePrintLoadConfiguration.blueprintDeployPath}/$id/" + val extractedDirectory = BluePrintArchiveUtils.deCompress(blueprintFile, targetDir) + + // Upload to the Data Base + saveToDataBase(extractedDirectory, id, blueprintFile) + + // After Upload to Database delete the zip file + blueprintFile.delete() + extractedDirectory.delete() + } + + 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 downloadFromDataBase(uuid: String, path: String): String { + 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 + } + + abstract fun saveToDataBase(extractedDirectory: File, id: String, archiveFile: File, checkValidity: Boolean? = false) +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/db-resources/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/db/resources/repository/ModelContentRepository.kt b/ms/controllerblueprints/modules/db-resources/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/db/resources/repository/ModelContentRepository.kt new file mode 100644 index 000000000..4965677ef --- /dev/null +++ b/ms/controllerblueprints/modules/db-resources/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/db/resources/repository/ModelContentRepository.kt @@ -0,0 +1,93 @@ +/* + * 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. + */ + +package org.onap.ccsdk.apps.controllerblueprints.db.resources.repository + +import org.jetbrains.annotations.NotNull +import java.util.Optional +import org.springframework.data.jpa.repository.JpaRepository +import org.springframework.data.repository.NoRepositoryBean + +/** + * @param Model + * @param ModelContent + */ +@NoRepositoryBean +interface ModelContentRepository : JpaRepository { + + /** + * This is a findById method + * + * @param id id + * @return Optional + */ + @NotNull + override fun findById(@NotNull id: String): Optional + + /** + * This is a findTopByBlueprintModelAndContentType method + * + * @param blueprintModel blueprintModel + * @param contentType contentType + * @return Optional + */ + fun findTopByBlueprintModelAndContentType(blueprintModel: T, + contentType: String): Optional + + /** + * This is a findByBlueprintModelAndContentType method + * + * @param blueprintModel blueprintModel + * @param contentType contentType + * @return Optional + */ + fun findByBlueprintModelAndContentType(blueprintModel: T, contentType: String): List + + /** + * This is a findByBlueprintModel method + * + * @param blueprintModel B + * @return Optional + */ + fun findByBlueprintModel(blueprintModel: T): List + + /** + * This is a findByBlueprintModelAndContentTypeAndName method + * + * @param blueprintModel blueprintModel + * @param contentType contentType + * @param name name + * @return Optional + */ + fun findByBlueprintModelAndContentTypeAndName(blueprintModel: T, + contentType: String, name: String): Optional + + /** + * This is a deleteByMdeleteByBlueprintModelodelName method + * + * @param blueprintModel B + */ + fun deleteByBlueprintModel(blueprintModel: T) + + /** + * This is a deleteById method + * + * @param id id + */ + override fun deleteById(@NotNull id: String) + +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/db-resources/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/db/resources/repository/ModelRepository.kt b/ms/controllerblueprints/modules/db-resources/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/db/resources/repository/ModelRepository.kt new file mode 100644 index 000000000..c31f009a6 --- /dev/null +++ b/ms/controllerblueprints/modules/db-resources/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/db/resources/repository/ModelRepository.kt @@ -0,0 +1,88 @@ +/* + * 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. + */ + +package org.onap.ccsdk.apps.controllerblueprints.db.resources.repository + +import org.jetbrains.annotations.NotNull +import java.util.Optional +import org.springframework.data.jpa.repository.JpaRepository +import org.springframework.data.repository.NoRepositoryBean + +/** + * @param Model + */ +@NoRepositoryBean +interface ModelRepository : JpaRepository { + + /** + * This is a findById method + * + * @param id id + * @return Optional + */ + @NotNull + override fun findById(@NotNull id: String): Optional + + /** + * This is a findByArtifactNameAndArtifactVersion method + * + * @param artifactName artifactName + * @param artifactVersion artifactVersion + * @return Optional + */ + fun findByArtifactNameAndArtifactVersion(artifactName: String, artifactVersion: String): Optional + + /** + * This is a findTopByArtifactNameOrderByArtifactIdDesc method + * + * @param artifactName artifactName + * @return Optional + */ + fun findTopByArtifactNameOrderByArtifactVersionDesc(artifactName: String): Optional + + /** + * This is a findTopByArtifactName method + * + * @param artifactName artifactName + * @return Optional + */ + fun findTopByArtifactName(artifactName: String): List + + /** + * This is a findByTagsContainingIgnoreCase method + * + * @param tags tags + * @return Optional + */ + fun findByTagsContainingIgnoreCase(tags: String): List + + /** + * This is a deleteByArtifactNameAndArtifactVersion method + * + * @param artifactName artifactName + * @param artifactVersion artifactVersion + */ + fun deleteByArtifactNameAndArtifactVersion(artifactName: String, artifactVersion: String) + + /** + * This is a deleteById method + * + * @param id id + */ + override fun deleteById(@NotNull id: String) + +} diff --git a/ms/controllerblueprints/modules/pom.xml b/ms/controllerblueprints/modules/pom.xml index eff2429ab..9a53eebf3 100644 --- a/ms/controllerblueprints/modules/pom.xml +++ b/ms/controllerblueprints/modules/pom.xml @@ -16,9 +16,9 @@ --> + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" + xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 4.0.0 org.onap.ccsdk.apps.controllerblueprints @@ -32,6 +32,8 @@ service + blueprint-validation + db-resources diff --git a/ms/controllerblueprints/modules/service/pom.xml b/ms/controllerblueprints/modules/service/pom.xml index 017cfde48..91a9eab14 100644 --- a/ms/controllerblueprints/modules/service/pom.xml +++ b/ms/controllerblueprints/modules/service/pom.xml @@ -1,84 +1,96 @@ - - - - - 4.0.0 - - org.onap.ccsdk.apps.controllerblueprints - modules - 0.4.0-SNAPSHOT - - service - Controller Blueprints Service - - - - - - - org.onap.ccsdk.apps.controllerblueprints - resource-dict - - - org.apache.velocity - velocity - - - org.springframework.boot - spring-boot-starter-webflux - - - org.springframework.boot - spring-boot-starter-data-jpa - - - com.h2database - h2 - runtime - - - org.mariadb.jdbc - mariadb-java-client - - - org.powermock - powermock-api-mockito2 - test - - - org.springframework.boot - spring-boot-starter-test - test - - - org.jetbrains.kotlin - kotlin-test-junit - test - - - io.projectreactor - reactor-test - test - - - - + + + + + 4.0.0 + + org.onap.ccsdk.apps.controllerblueprints + modules + 0.4.0-SNAPSHOT + + service + Controller Blueprints Service + + + + + + + org.onap.ccsdk.apps.controllerblueprints + core + + + org.onap.ccsdk.apps.controllerblueprints + db-resources + + + org.onap.ccsdk.apps.controllerblueprints + blueprint-validation + + + org.onap.ccsdk.apps.controllerblueprints + resource-dict + + + org.apache.velocity + velocity + + + org.springframework.boot + spring-boot-starter-webflux + + + org.springframework.boot + spring-boot-starter-data-jpa + + + com.h2database + h2 + runtime + + + org.mariadb.jdbc + mariadb-java-client + + + org.powermock + powermock-api-mockito2 + test + + + org.springframework.boot + spring-boot-starter-test + test + + + org.jetbrains.kotlin + kotlin-test-junit + test + + + io.projectreactor + reactor-test + test + + + + diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BlueprintModelService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BlueprintModelService.java index ba27742af..ca0e24393 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BlueprintModelService.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BlueprintModelService.java @@ -21,14 +21,14 @@ import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import org.jetbrains.annotations.NotNull; import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException; +import org.onap.ccsdk.apps.controllerblueprints.core.config.BluePrintLoadConfiguration; import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintCatalogService; import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintFileUtils; import org.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModel; import org.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModelSearch; -import org.onap.ccsdk.apps.controllerblueprints.service.load.BluePrintLoadConfiguration; -import org.onap.ccsdk.apps.controllerblueprints.service.repository.BlueprintModelContentRepository; -import org.onap.ccsdk.apps.controllerblueprints.service.repository.BlueprintModelRepository; -import org.onap.ccsdk.apps.controllerblueprints.service.repository.BlueprintModelSearchRepository; +import org.onap.ccsdk.apps.controllerblueprints.service.repository.ControllerBlueprintModelContentRepository; +import org.onap.ccsdk.apps.controllerblueprints.service.repository.ControllerBlueprintModelRepository; +import org.onap.ccsdk.apps.controllerblueprints.service.repository.ControllerBlueprintModelSearchRepository; import org.onap.ccsdk.apps.controllerblueprints.service.utils.BluePrintEnhancerUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.io.ByteArrayResource; @@ -65,17 +65,17 @@ public class BlueprintModelService { private BluePrintCatalogService bluePrintCatalogService; @Autowired - private BlueprintModelSearchRepository blueprintModelSearchRepository; + private ControllerBlueprintModelSearchRepository blueprintModelSearchRepository; @Autowired - private BlueprintModelRepository blueprintModelRepository; + private ControllerBlueprintModelRepository blueprintModelRepository; @Autowired - private BlueprintModelContentRepository blueprintModelContentRepository; + private ControllerBlueprintModelContentRepository blueprintModelContentRepository; private static final String BLUEPRINT_MODEL_ID_FAILURE_MSG = "failed to get blueprint model id(%d) from repo"; private static final String BLUEPRINT_MODEL_NAME_VERSION_FAILURE_MSG = "failed to get blueprint model by name(%d)" + - " and version(%d) from repo"; + " and version(%d) from repo"; /** * This is a saveBlueprintModel method @@ -86,10 +86,12 @@ public class BlueprintModelService { */ public Mono saveBlueprintModel(FilePart filePart) throws BluePrintException { try { - Path cbaLocation = BluePrintFileUtils.Companion.getCbaStorageDirectory(bluePrintLoadConfiguration.blueprintArchivePath); + Path cbaLocation = BluePrintFileUtils.Companion + .getCbaStorageDirectory(bluePrintLoadConfiguration.blueprintArchivePath); return BluePrintEnhancerUtils.Companion.saveCBAFile(filePart, cbaLocation).map(fileName -> { - String blueprintId = bluePrintCatalogService.uploadToDataBase(cbaLocation.resolve(fileName).toString(), false); - return blueprintModelSearchRepository.findById(blueprintId).get(); + String blueprintId = bluePrintCatalogService + .uploadToDataBase(cbaLocation.resolve(fileName).toString(), false); + return blueprintModelSearchRepository.findById(blueprintId).get(); }); } catch (IOException | BluePrintException e) { @@ -122,14 +124,15 @@ public class BlueprintModelService { /** * This is a getBlueprintModelByNameAndVersion method * - * @param name name + * @param name name * @param version version * @return BlueprintModelSearch */ - public BlueprintModelSearch getBlueprintModelByNameAndVersion(@NotNull String name, @NotNull String version) throws BluePrintException { + public BlueprintModelSearch getBlueprintModelByNameAndVersion(@NotNull String name, @NotNull String version) + throws BluePrintException { BlueprintModelSearch blueprintModelSearch; Optional dbBlueprintModel = blueprintModelSearchRepository - .findByArtifactNameAndArtifactVersion(name, version); + .findByArtifactNameAndArtifactVersion(name, version); if (dbBlueprintModel.isPresent()) { blueprintModelSearch = dbBlueprintModel.get(); } else { @@ -142,7 +145,6 @@ public class BlueprintModelService { /** * This is a downloadBlueprintModelFile method to find the target file to download and return a file resource using MONO * - * @param (id) * @return ResponseEntity */ public ResponseEntity downloadBlueprintModelFile(@NotNull String id) throws BluePrintException { diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ApplicationConstants.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ApplicationConstants.java deleted file mode 100644 index d16f1b135..000000000 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ApplicationConstants.java +++ /dev/null @@ -1,34 +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; - -/** - * ApplicationConstants.java Purpose: Provide ControllerBluprintsApplication Constant Information - * - * @author Brinda Santh - * @version 1.0 - */ -public final class ApplicationConstants { - public static final String ACTIVE_Y = "Y"; - public static final String ACTIVE_N = "N"; - public static final String ASDC_ARTIFACT_TYPE_SDNC_MODEL = "SDNC_MODEL"; - - private ApplicationConstants() { - - } - -} diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/BlueprintModelContentRepository.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/BlueprintModelContentRepository.java deleted file mode 100644 index 7940c9447..000000000 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/BlueprintModelContentRepository.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * 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. - */ - -package org.onap.ccsdk.apps.controllerblueprints.service.repository; - -import org.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModel; -import org.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModelContent; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -import javax.validation.constraints.NotNull; -import java.util.List; -import java.util.Optional; - -/** - * BlueprintModelContentRepository.java Purpose: Provide BlueprintModelContentRepository of Repository - * - * @author Brinda Santh - * @version 1.0 - */ -@Repository -public interface BlueprintModelContentRepository extends JpaRepository { - - /** - * This is a findById method - * - * @param id id - * @return Optional - */ - @NotNull - Optional findById(@NotNull String id); - - /** - * This is a findTopByBlueprintModelAndContentType method - * - * @param blueprintModel blueprintModel - * @param contentType contentType - * @return Optional - */ - @SuppressWarnings("unused") - Optional findTopByBlueprintModelAndContentType(BlueprintModel blueprintModel, String contentType); - - /** - * This is a findByBlueprintModelAndContentType method - * - * @param blueprintModel blueprintModel - * @param contentType contentType - * @return Optional - */ - @SuppressWarnings("unused") - List findByBlueprintModelAndContentType(BlueprintModel blueprintModel, String contentType); - - /** - * This is a findByBlueprintModel method - * - * @param blueprintModel blueprintModel - * @return Optional - */ - @SuppressWarnings("unused") - List findByBlueprintModel(BlueprintModel blueprintModel); - - /** - * This is a findByBlueprintModelAndContentTypeAndName method - * - * @param blueprintModel blueprintModel - * @param contentType contentType - * @param name name - * @return Optional - */ - @SuppressWarnings("unused") - Optional findByBlueprintModelAndContentTypeAndName(BlueprintModel blueprintModel, - String contentType, String name); - - /** - * This is a deleteByMdeleteByBlueprintModelodelName method - * - * @param blueprintModel blueprintModel - */ - void deleteByBlueprintModel(BlueprintModel blueprintModel); - - /** - * This is a deleteById method - * - * @param id id - */ - void deleteById(@NotNull String id); - -} diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/BlueprintModelRepository.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/BlueprintModelRepository.java deleted file mode 100644 index 413160498..000000000 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/BlueprintModelRepository.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * 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. - */ - -package org.onap.ccsdk.apps.controllerblueprints.service.repository; - -import org.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModel; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -import javax.validation.constraints.NotNull; -import java.util.List; -import java.util.Optional; - -/** - * AsdcArtifactsRepository.java Purpose: Provide Configuration Generator AsdcArtifactsRepository - * - * @author Brinda Santh - * @version 1.0 - */ -@Repository -public interface BlueprintModelRepository extends JpaRepository { - /** - * This is a findById method - * - * @param id id - * @return Optional - */ - @NotNull - Optional findById(@NotNull String id); - - /** - * This is a findByArtifactNameAndArtifactVersion method - * - * @param artifactName artifactName - * @param artifactVersion artifactVersion - * @return Optional - */ - Optional findByArtifactNameAndArtifactVersion(String artifactName, String artifactVersion); - - /** - * This is a findTopByArtifactNameOrderByArtifactIdDesc method - * - * @param artifactName artifactName - * @return Optional - */ - Optional findTopByArtifactNameOrderByArtifactVersionDesc(String artifactName); - - /** - * This is a findTopByArtifactName method - * - * @param artifactName artifactName - * @return Optional - */ - @SuppressWarnings("unused") - List findTopByArtifactName(String artifactName); - - /** - * This is a findByTagsContainingIgnoreCase method - * - * @param tags tags - * @return Optional - */ - List findByTagsContainingIgnoreCase(String tags); - - /** - * This is a deleteByArtifactNameAndArtifactVersion method - * - * @param artifactName artifactName - * @param artifactVersion artifactVersion - */ - @SuppressWarnings("unused") - void deleteByArtifactNameAndArtifactVersion(String artifactName, String artifactVersion); - - /** - * This is a deleteById method - * - * @param id id - */ - @SuppressWarnings("unused") - void deleteById(@NotNull String id); - -} diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/BlueprintModelSearchRepository.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/BlueprintModelSearchRepository.java deleted file mode 100644 index ed863563a..000000000 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/BlueprintModelSearchRepository.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * 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. - */ - -package org.onap.ccsdk.apps.controllerblueprints.service.repository; - -import org.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModelSearch; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -import javax.validation.constraints.NotNull; -import java.util.List; -import java.util.Optional; - -/** - * BlueprintModelSearchRepository.java Purpose: Provide Configuration Generator AsdcArtifactsRepository - * - * @author Brinda Santh - * @version 1.0 - */ -@Repository -public interface BlueprintModelSearchRepository extends JpaRepository { - - /** - * This is a findById method - * - * @param id id - * @return Optional - */ - @NotNull - Optional findById(@NotNull String id); - - /** - * This is a findAll method - * @return List - */ - @Override - List findAll(); - - /** - * This is a findByArtifactNameAndArtifactVersion method - * - * @param artifactName artifactName - * @param artifactVersion artifactVersion - * @return Optional - */ - Optional findByArtifactNameAndArtifactVersion(String artifactName, String artifactVersion); - - /** - * This is a findByTagsContainingIgnoreCase method - * - * @param tags - * @return Optional - */ - List findByTagsContainingIgnoreCase(String tags); -} diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ControllerBlueprintModelSearchRepository.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ControllerBlueprintModelSearchRepository.java new file mode 100644 index 000000000..343f8c67b --- /dev/null +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ControllerBlueprintModelSearchRepository.java @@ -0,0 +1,69 @@ +/* + * 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. + */ + +package org.onap.ccsdk.apps.controllerblueprints.service.repository; + +import org.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModelSearch; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import javax.validation.constraints.NotNull; +import java.util.List; +import java.util.Optional; + +/** + * ControllerBlueprintModelSearchRepository.java Purpose: Provide Configuration Generator AsdcArtifactsRepository + * + * @author Brinda Santh + * @version 1.0 + */ +@Repository +public interface ControllerBlueprintModelSearchRepository extends JpaRepository { + + /** + * This is a findById method + * + * @param id id + * @return Optional + */ + @NotNull + Optional findById(@NotNull String id); + + /** + * This is a findAll method + * @return List + */ + @Override + List findAll(); + + /** + * This is a findByArtifactNameAndArtifactVersion method + * + * @param artifactName artifactName + * @param artifactVersion artifactVersion + * @return Optional + */ + Optional findByArtifactNameAndArtifactVersion(String artifactName, String artifactVersion); + + /** + * This is a findByTagsContainingIgnoreCase method + * + * @param tags + * @return Optional + */ + List findByTagsContainingIgnoreCase(String tags); +} 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 deleted file mode 100644 index 2e5fc5ba3..000000000 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintCoreConfiguration.kt +++ /dev/null @@ -1,60 +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 - -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/BluePrintRepoServiceImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoServiceImpl.kt index c818410f7..f856b9efe 100644 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoServiceImpl.kt +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoServiceImpl.kt @@ -24,10 +24,21 @@ import org.onap.ccsdk.apps.controllerblueprints.core.data.* import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintRepoService 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.ResourceAssignmentValidationServiceImpl +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionValidationServiceImpl import org.onap.ccsdk.apps.controllerblueprints.service.repository.ModelTypeRepository import org.onap.ccsdk.apps.controllerblueprints.service.repository.ResourceDictionaryRepository import org.springframework.stereotype.Service +// Resource Dictionary Validation Services + +@Service +class DefaultResourceAssignmentValidationService : ResourceAssignmentValidationServiceImpl() + +@Service +class DefalutResourceDefinitionValidationService(bluePrintRepoService: BluePrintRepoService) + : ResourceDefinitionValidationServiceImpl(bluePrintRepoService) + interface ResourceDefinitionRepoService : BluePrintRepoService { @Throws(BluePrintException::class) diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/ControllerBluePrintCoreConfiguration.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/ControllerBluePrintCoreConfiguration.kt new file mode 100644 index 000000000..2c4ee746a --- /dev/null +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/ControllerBluePrintCoreConfiguration.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.core.config.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 ControllerBluePrintCoreConfiguration(private val bluePrintProperties: ControllerBlueprintProperties) { + + companion object { + const val PREFIX_BLUEPRINT_LOAD_CONFIGURATION = "controllerblueprints" + } + + @Bean + open fun controlelrBlueprintLoadConfiguration(): BluePrintLoadConfiguration { + return bluePrintProperties + .propertyBeanType(PREFIX_BLUEPRINT_LOAD_CONFIGURATION, BluePrintLoadConfiguration::class.java) + } +} + +@Configuration +open class ControllerBlueprintPropertyConfiguration { + @Autowired + lateinit var environment: Environment + + @Bean + open fun controllerBluePrintPropertyBinder(): Binder { + val configurationPropertySource = ConfigurationPropertySources.get(environment) + return Binder(configurationPropertySource) + } +} + +@Service +open class ControllerBlueprintProperties(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/BluePrintCatalogServiceImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintCatalogServiceImpl.kt deleted file mode 100755 index 761dd25a3..000000000 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintCatalogServiceImpl.kt +++ /dev/null @@ -1,135 +0,0 @@ -/* - * 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. - */ - -package org.onap.ccsdk.apps.controllerblueprints.service.load - -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants -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.BluePrintFileUtils -import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils -import org.onap.ccsdk.apps.controllerblueprints.service.common.ApplicationConstants -import org.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModel -import org.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModelContent -import org.onap.ccsdk.apps.controllerblueprints.service.repository.BlueprintModelContentRepository -import org.onap.ccsdk.apps.controllerblueprints.service.repository.BlueprintModelRepository -import org.springframework.stereotype.Service -import java.io.File -import java.nio.file.Files - -@Service -class BluePrintCatalogServiceImpl(private val bluePrintLoadConfiguration: BluePrintLoadConfiguration, - private val bluePrintValidatorService: BluePrintValidatorService, - private val blueprintModelContentRepository: BlueprintModelContentRepository, - private val blueprintModelRepository: BlueprintModelRepository) : BluePrintCatalogService { - - override fun uploadToDataBase(file: String, validate: Boolean): String { - // The file name provided here is unique as we transform to UUID before storing - val blueprintFile = File(file) - val fileName = blueprintFile.name - val id = BluePrintFileUtils.stripFileExtension(fileName) - // If the file is directory - if (blueprintFile.isDirectory) { - - val zipFile = File("${bluePrintLoadConfiguration.blueprintArchivePath}/$fileName") - // zip the directory - BluePrintArchiveUtils.compress(blueprintFile, zipFile, true) - - // Upload to the Data Base - saveToDataBase(blueprintFile, id, zipFile) - - // After Upload to Database delete the zip file - zipFile.delete() - - } else { - // If the file is ZIP - // unzip the CBA file to validate before store in database - val targetDir = "${bluePrintLoadConfiguration.blueprintDeployPath}/$id/" - val extractedDirectory = BluePrintArchiveUtils.deCompress(blueprintFile, targetDir) - - // Upload to the Data Base - saveToDataBase(extractedDirectory, id, blueprintFile) - - // After Upload to Database delete the zip file - blueprintFile.delete() - extractedDirectory.delete() - } - - 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 downloadFromDataBase(uuid: String, path: String): String { - 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 - } - - private fun saveToDataBase(extractedDirectory: File, id: String, archiveFile: File, checkValidity: Boolean? = false) { - // Upload to the Data Base - //val id = "save-$uuid" - var valid = false - val firstItem = BluePrintArchiveUtils.getFirstItemInDirectory(extractedDirectory) - val blueprintBaseDirectory = extractedDirectory.absolutePath + "/" + firstItem - // Validate Blueprint - val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(id, blueprintBaseDirectory) - - // Check Validity of blueprint - if (checkValidity!!) { - valid = bluePrintValidatorService.validateBluePrints(bluePrintRuntimeService) - } - - if ((valid && checkValidity!!) || (!valid && !checkValidity!!)) { - val metaData = bluePrintRuntimeService.bluePrintContext().metadata!! - // FIXME("Check Duplicate for Artifact Name and Artifact Version") - val blueprintModel = BlueprintModel() - blueprintModel.id = id - blueprintModel.artifactType = ApplicationConstants.ASDC_ARTIFACT_TYPE_SDNC_MODEL - blueprintModel.published = ApplicationConstants.ACTIVE_N - blueprintModel.artifactName = metaData[BluePrintConstants.METADATA_TEMPLATE_NAME] - blueprintModel.artifactVersion = metaData[BluePrintConstants.METADATA_TEMPLATE_VERSION] - blueprintModel.updatedBy = metaData[BluePrintConstants.METADATA_TEMPLATE_AUTHOR] - blueprintModel.tags = metaData[BluePrintConstants.METADATA_TEMPLATE_TAGS] - blueprintModel.artifactDescription = "Controller Blueprint for ${blueprintModel.artifactName}:${blueprintModel.artifactVersion}" - - val blueprintModelContent = BlueprintModelContent() - blueprintModelContent.id = id // For quick access both id's are same.always have one to one mapping. - blueprintModelContent.contentType = "CBA_ZIP" - blueprintModelContent.name = "${blueprintModel.artifactName}:${blueprintModel.artifactVersion}" - blueprintModelContent.description = "(${blueprintModel.artifactName}:${blueprintModel.artifactVersion} CBA Zip Content" - blueprintModelContent.content = Files.readAllBytes(archiveFile.toPath()) - - // Set the Blueprint Model into blueprintModelContent - blueprintModelContent.blueprintModel = blueprintModel - - // Set the Blueprint Model Content into blueprintModel - blueprintModel.blueprintModelContent = blueprintModelContent - - blueprintModelRepository.saveAndFlush(blueprintModel) - } - } -} \ 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 index eeea97c9b..8b6e54af9 100644 --- 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 @@ -17,6 +17,7 @@ package org.onap.ccsdk.apps.controllerblueprints.service.load import com.att.eelf.configuration.EELFManager +import org.onap.ccsdk.apps.controllerblueprints.core.config.BluePrintLoadConfiguration import org.springframework.boot.context.event.ApplicationReadyEvent import org.springframework.context.event.EventListener import org.springframework.stereotype.Service 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 deleted file mode 100644 index cf36a3e5a..000000000 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/BluePrintLoadConfiguration.kt +++ /dev/null @@ -1,34 +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 - -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/ControllerBlueprintCatalogServiceImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/ControllerBlueprintCatalogServiceImpl.kt new file mode 100755 index 000000000..ac81f8fa6 --- /dev/null +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/load/ControllerBlueprintCatalogServiceImpl.kt @@ -0,0 +1,86 @@ +/* + * 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. + */ + +package org.onap.ccsdk.apps.controllerblueprints.service.load + +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.apps.controllerblueprints.core.common.ApplicationConstants +import org.onap.ccsdk.apps.controllerblueprints.core.config.BluePrintLoadConfiguration +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.onap.ccsdk.apps.controllerblueprints.db.resources.BlueprintCatalogServiceImpl +import org.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModel +import org.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModelContent +import org.onap.ccsdk.apps.controllerblueprints.service.repository.ControllerBlueprintModelContentRepository +import org.onap.ccsdk.apps.controllerblueprints.service.repository.ControllerBlueprintModelRepository +import org.springframework.stereotype.Service +import java.io.File +import java.nio.file.Files + +/** +Similar implementation in [org.onap.ccsdk.apps.blueprintsprocessor.db.BlueprintProcessorCatalogServiceImpl] + */ +@Service +class ControllerBlueprintCatalogServiceImpl(bluePrintLoadConfiguration: BluePrintLoadConfiguration, + private val bluePrintValidatorService: BluePrintValidatorService, + private val blueprintModelContentRepository: ControllerBlueprintModelContentRepository, + private val blueprintModelRepository: ControllerBlueprintModelRepository) + : BlueprintCatalogServiceImpl(bluePrintLoadConfiguration) { + + override fun saveToDataBase(extractedDirectory: File, id: String, archiveFile: File, checkValidity: Boolean?) { + var valid = false + val firstItem = BluePrintArchiveUtils.getFirstItemInDirectory(extractedDirectory) + val blueprintBaseDirectory = extractedDirectory.absolutePath + "/" + firstItem + // Validate Blueprint + val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(id, blueprintBaseDirectory) + + // Check Validity of blueprint + if (checkValidity!!) { + valid = bluePrintValidatorService.validateBluePrints(bluePrintRuntimeService) + } + + if ((valid && checkValidity!!) || (!valid && !checkValidity!!)) { + val metaData = bluePrintRuntimeService.bluePrintContext().metadata!! + // FIXME("Check Duplicate for Artifact Name and Artifact Version") + val blueprintModel = BlueprintModel() + blueprintModel.id = id + blueprintModel.artifactType = ApplicationConstants.ASDC_ARTIFACT_TYPE_SDNC_MODEL + blueprintModel.published = ApplicationConstants.ACTIVE_N + blueprintModel.artifactName = metaData[BluePrintConstants.METADATA_TEMPLATE_NAME] + blueprintModel.artifactVersion = metaData[BluePrintConstants.METADATA_TEMPLATE_VERSION] + blueprintModel.updatedBy = metaData[BluePrintConstants.METADATA_TEMPLATE_AUTHOR] + blueprintModel.tags = metaData[BluePrintConstants.METADATA_TEMPLATE_TAGS] + blueprintModel.artifactDescription = "Controller Blueprint for ${blueprintModel.artifactName}:${blueprintModel.artifactVersion}" + + val blueprintModelContent = BlueprintModelContent() + blueprintModelContent.id = id // For quick access both id's are same.always have one to one mapping. + blueprintModelContent.contentType = "CBA_ZIP" + blueprintModelContent.name = "${blueprintModel.artifactName}:${blueprintModel.artifactVersion}" + blueprintModelContent.description = "(${blueprintModel.artifactName}:${blueprintModel.artifactVersion} CBA Zip Content" + blueprintModelContent.content = Files.readAllBytes(archiveFile.toPath()) + + // Set the Blueprint Model into blueprintModelContent + blueprintModelContent.blueprintModel = blueprintModel + + // Set the Blueprint Model Content into blueprintModel + blueprintModel.blueprintModelContent = blueprintModelContent + + blueprintModelRepository.saveAndFlush(blueprintModel) + } + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/repository/ControllerBlueprintModelContentRepository.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/repository/ControllerBlueprintModelContentRepository.kt new file mode 100644 index 000000000..7cda72763 --- /dev/null +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/repository/ControllerBlueprintModelContentRepository.kt @@ -0,0 +1,22 @@ +/* + * Copyright (C) 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. + */ +package org.onap.ccsdk.apps.controllerblueprints.service.repository + +import org.onap.ccsdk.apps.controllerblueprints.db.resources.repository.ModelContentRepository +import org.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModel +import org.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModelContent + +interface ControllerBlueprintModelContentRepository : ModelContentRepository diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/repository/ControllerBlueprintModelRepository.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/repository/ControllerBlueprintModelRepository.kt new file mode 100644 index 000000000..ec1175072 --- /dev/null +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/repository/ControllerBlueprintModelRepository.kt @@ -0,0 +1,21 @@ +/* + * Copyright (C) 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. + */ +package org.onap.ccsdk.apps.controllerblueprints.service.repository + +import org.onap.ccsdk.apps.controllerblueprints.db.resources.repository.ModelRepository +import org.onap.ccsdk.apps.controllerblueprints.service.domain.BlueprintModel + +interface ControllerBlueprintModelRepository : ModelRepository diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/BluePrintTypeValidatorServiceImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/BluePrintTypeValidatorServiceImpl.kt deleted file mode 100644 index 9d4797ff9..000000000 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/BluePrintTypeValidatorServiceImpl.kt +++ /dev/null @@ -1,66 +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.validator - -import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.* -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.context.ApplicationContext -import org.springframework.stereotype.Service - -@Service -class BluePrintTypeValidatorServiceImpl : BluePrintTypeValidatorService { - - @Autowired - private lateinit var context: ApplicationContext - - override fun getServiceTemplateValidators(): List { - return context.getBeansOfType(BluePrintServiceTemplateValidator::class.java).mapNotNull { it.value } - } - - override fun getDataTypeValidators(): List { - return context.getBeansOfType(BluePrintDataTypeValidator::class.java).mapNotNull { it.value } - } - - override fun getArtifactTypeValidators(): List { - return context.getBeansOfType(BluePrintArtifactTypeValidator::class.java).mapNotNull { it.value } - } - - override fun getNodeTypeValidators(): List { - return context.getBeansOfType(BluePrintNodeTypeValidator::class.java).mapNotNull { it.value } - } - - override fun getTopologyTemplateValidators(): List { - return context.getBeansOfType(BluePrintTopologyTemplateValidator::class.java).mapNotNull { it.value } - } - - override fun getNodeTemplateValidators(): List { - return context.getBeansOfType(BluePrintNodeTemplateValidator::class.java).mapNotNull { it.value } - } - - override fun getWorkflowValidators(): List { - return context.getBeansOfType(BluePrintWorkflowValidator::class.java).mapNotNull { it.value } - } - - override fun getPropertyDefinitionValidators(): List { - return context.getBeansOfType(BluePrintPropertyDefinitionValidator::class.java).mapNotNull { it.value } - } - - override fun getAttributeDefinitionValidators(): List { - return context.getBeansOfType(BluePrintAttributeDefinitionValidator::class.java).mapNotNull { it.value } - } -} - diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/BluePrintValidatorDefaultService.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/BluePrintValidatorDefaultService.kt deleted file mode 100644 index 89f4d9e38..000000000 --- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/BluePrintValidatorDefaultService.kt +++ /dev/null @@ -1,103 +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.validator - -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.core.interfaces.BluePrintRepoService -import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService -import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintValidatorService -import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService -import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils -import org.onap.ccsdk.apps.controllerblueprints.core.validation.* -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceAssignmentValidationServiceImpl -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionValidationServiceImpl -import org.springframework.stereotype.Service -import java.util.* - -@Service -class BluePrintTypeValidatorDefaultService(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) - : BluePrintValidatorService { - - private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintValidatorServiceImpl::class.toString()) - - override fun validateBluePrints(basePath: String): Boolean { - - log.info("validating blueprint($basePath)") - val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(UUID.randomUUID().toString(), basePath) - return validateBluePrints(bluePrintRuntimeService) - } - - override fun validateBluePrints(bluePrintRuntimeService: BluePrintRuntimeService<*>): Boolean { - - bluePrintTypeValidatorService.validateServiceTemplate(bluePrintRuntimeService, "service_template", - bluePrintRuntimeService.bluePrintContext().serviceTemplate) - - if (bluePrintRuntimeService.getBluePrintError().errors.size > 0) { - throw BluePrintException("failed in blueprint validation : ${bluePrintRuntimeService.getBluePrintError().errors.joinToString("\n")}") - } - return true - } -} - -// Core Validator Services - -@Service -class DefaultBluePrintServiceTemplateValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService) - : BluePrintServiceTemplateValidatorImpl(bluePrintTypeValidatorService) - -@Service -class DefaultBluePrintDataTypeValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService) - : BluePrintDataTypeValidatorImpl(bluePrintTypeValidatorService) - -@Service -class DefaultBluePrintArtifactTypeValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService) - : BluePrintArtifactTypeValidatorImpl(bluePrintTypeValidatorService) - -@Service -class DefaultBluePrintNodeTypeValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService) - : BluePrintNodeTypeValidatorImpl(bluePrintTypeValidatorService) - -@Service -class DefaultBluePrintTopologyTemplateValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService) - : BluePrintTopologyTemplateValidatorImpl(bluePrintTypeValidatorService) - -@Service -class DefaulBluePrintNodeTemplateValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService) - : BluePrintNodeTemplateValidatorImpl(bluePrintTypeValidatorService) - -@Service -class DefaultBluePrintWorkflowValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService) - : BluePrintWorkflowValidatorImpl(bluePrintTypeValidatorService) - -@Service -class DefaulBluePrintPropertyDefinitionValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService) - : BluePrintPropertyDefinitionValidatorImpl(bluePrintTypeValidatorService) - -@Service -class DefaultBluePrintAttributeDefinitionValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService) - : BluePrintAttributeDefinitionValidatorImpl(bluePrintTypeValidatorService) - -// Resource Dictionary Validation Services - -@Service -class DefaultResourceAssignmentValidationService : ResourceAssignmentValidationServiceImpl() - -@Service -class DefalutResourceDefinitionValidationService(bluePrintRepoService: BluePrintRepoService) - : ResourceDefinitionValidationServiceImpl(bluePrintRepoService) \ No newline at end of file diff --git a/ms/controllerblueprints/parent/pom.xml b/ms/controllerblueprints/parent/pom.xml index 38a879ab8..ec6f25239 100644 --- a/ms/controllerblueprints/parent/pom.xml +++ b/ms/controllerblueprints/parent/pom.xml @@ -190,6 +190,16 @@ resource-dict ${project.version} + + org.onap.ccsdk.apps.controllerblueprints + db-resources + ${project.version} + + + org.onap.ccsdk.apps.controllerblueprints + blueprint-validation + ${project.version} + -- cgit 1.2.3-korg From 13f58213dff9f0297b95a79f38991a57a12f2e1e Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Fri, 4 Jan 2019 10:43:33 -0500 Subject: Update to use correct parent pom Updated neng microservice to use springboot v1 parent as opposed to odlparent. Without that change, javadoc was failing when compiled with Fluorine version of odlparent-lite parent pom. Change-Id: I677278d90869f493c281c7c5432b271dd43e7513 Issue-ID: CCSDK-870 Signed-off-by: Timoney, Dan (dt5972) --- ms/controllerblueprints/application/pom.xml | 2 +- ms/controllerblueprints/distribution/pom.xml | 2 +- .../modules/blueprint-validation/pom.xml | 9 +- .../modules/db-resources/pom.xml | 9 +- ms/controllerblueprints/modules/pom.xml | 103 ++++++++++----------- ms/controllerblueprints/modules/service/pom.xml | 9 +- ms/controllerblueprints/parent/pom.xml | 2 +- ms/controllerblueprints/pom.xml | 4 +- 8 files changed, 60 insertions(+), 80 deletions(-) (limited to 'ms/controllerblueprints/parent') diff --git a/ms/controllerblueprints/application/pom.xml b/ms/controllerblueprints/application/pom.xml index bd244e0db..a01a61347 100644 --- a/ms/controllerblueprints/application/pom.xml +++ b/ms/controllerblueprints/application/pom.xml @@ -21,7 +21,7 @@ org.onap.ccsdk.apps.controllerblueprints parent - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT ../parent application diff --git a/ms/controllerblueprints/distribution/pom.xml b/ms/controllerblueprints/distribution/pom.xml index afbc6617a..305712936 100644 --- a/ms/controllerblueprints/distribution/pom.xml +++ b/ms/controllerblueprints/distribution/pom.xml @@ -19,7 +19,7 @@ org.onap.ccsdk.apps.controllerblueprints parent - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT ../parent distribution diff --git a/ms/controllerblueprints/modules/blueprint-validation/pom.xml b/ms/controllerblueprints/modules/blueprint-validation/pom.xml index 0cafc9a65..d175eecf2 100644 --- a/ms/controllerblueprints/modules/blueprint-validation/pom.xml +++ b/ms/controllerblueprints/modules/blueprint-validation/pom.xml @@ -16,16 +16,12 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License. --> - - + 4.0.0 org.onap.ccsdk.apps.controllerblueprints modules - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT blueprint-validation Controller Blueprints Validation Service @@ -49,4 +45,3 @@ - diff --git a/ms/controllerblueprints/modules/db-resources/pom.xml b/ms/controllerblueprints/modules/db-resources/pom.xml index 69e322e40..c09d96c10 100644 --- a/ms/controllerblueprints/modules/db-resources/pom.xml +++ b/ms/controllerblueprints/modules/db-resources/pom.xml @@ -16,16 +16,12 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License. --> - - + 4.0.0 org.onap.ccsdk.apps.controllerblueprints modules - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT db-resources Controller Blueprints DB Resources @@ -44,4 +40,3 @@ - diff --git a/ms/controllerblueprints/modules/pom.xml b/ms/controllerblueprints/modules/pom.xml index 9a53eebf3..3857ef5db 100644 --- a/ms/controllerblueprints/modules/pom.xml +++ b/ms/controllerblueprints/modules/pom.xml @@ -1,54 +1,49 @@ - - - - - 4.0.0 - - org.onap.ccsdk.apps.controllerblueprints - parent - 0.4.0-SNAPSHOT - ../parent - - modules - Controller Blueprints Modules - pom - - - service - blueprint-validation - db-resources - - - - - - maven-compiler-plugin - 3.1 - - - 1.8 - 1.8 - - - - - - - + + + + 4.0.0 + + org.onap.ccsdk.apps.controllerblueprints + parent + 0.4.1-SNAPSHOT + ../parent + + modules + Controller Blueprints Modules + pom + + + service + blueprint-validation + db-resources + + + + + + maven-compiler-plugin + 3.1 + + + 1.8 + 1.8 + + + + + + diff --git a/ms/controllerblueprints/modules/service/pom.xml b/ms/controllerblueprints/modules/service/pom.xml index 91a9eab14..9868b17be 100644 --- a/ms/controllerblueprints/modules/service/pom.xml +++ b/ms/controllerblueprints/modules/service/pom.xml @@ -16,16 +16,12 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License. --> - - + 4.0.0 org.onap.ccsdk.apps.controllerblueprints modules - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT service Controller Blueprints Service @@ -93,4 +89,3 @@ - diff --git a/ms/controllerblueprints/parent/pom.xml b/ms/controllerblueprints/parent/pom.xml index ec6f25239..ea93bb21f 100644 --- a/ms/controllerblueprints/parent/pom.xml +++ b/ms/controllerblueprints/parent/pom.xml @@ -21,7 +21,7 @@ org.onap.ccsdk.apps controllerblueprints - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT org.onap.ccsdk.apps.controllerblueprints parent diff --git a/ms/controllerblueprints/pom.xml b/ms/controllerblueprints/pom.xml index d88956f0d..6d6dae6ba 100644 --- a/ms/controllerblueprints/pom.xml +++ b/ms/controllerblueprints/pom.xml @@ -18,12 +18,12 @@ org.onap.ccsdk.apps ccsdk-apps-ms - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT 4.0.0 controllerblueprints Controller Blueprints Root - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT ControllerBlueprints UTF-8 -- cgit 1.2.3-korg From 72b279d28159c81a9411332034a9e60b8605baa7 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh" Date: Fri, 11 Jan 2019 11:30:40 -0500 Subject: Add blueprint Kotlin script support. Change-Id: I92b8e9850ea07c7f671e7aada9770713854534c3 Issue-ID: CCSDK-941 Signed-off-by: Muthuramalingam, Brinda Santh --- ms/controllerblueprints/parent/pom.xml | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'ms/controllerblueprints/parent') diff --git a/ms/controllerblueprints/parent/pom.xml b/ms/controllerblueprints/parent/pom.xml index ea93bb21f..9042318dc 100644 --- a/ms/controllerblueprints/parent/pom.xml +++ b/ms/controllerblueprints/parent/pom.xml @@ -30,13 +30,13 @@ 2.1.1.RELEASE 5.1.3.RELEASE - 1.3.10 - 1.3.10 - 1.0.1 - 1.16.1 + 1.3.11 + 1.3.11 + 1.1.0 + 1.17.1 3.6.1 1.0.0 - 26.0-jre + 27.0.1-jre 2.9.2 1.4.197 1.2.2 @@ -108,6 +108,27 @@ kotlin-stdlib ${kotlin.version} + + org.jetbrains.kotlin + kotlin-scripting-jvm-host + ${kotlin.version} + + + org.jetbrains.kotlin + kotlin-compiler-embeddable + ${kotlin.version} + runtime + + + org.jetbrains.kotlin + kotlin-script-util + ${kotlin.version} + + + org.jetbrains.kotlin + kotlin-script-runtime + ${kotlin.version} + org.jetbrains.kotlin kotlinx-couroutines-core -- cgit 1.2.3-korg From 6a0e531e402ecb21311cdc803e46f148f837d694 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh" Date: Wed, 23 Jan 2019 11:42:13 -0500 Subject: GRPC 1.18.0 Upgrade. Change-Id: I1f7f75e14d284641d86c5ef91723b00aaab9bed7 Issue-ID: CCSDK-998 Signed-off-by: Muthuramalingam, Brinda Santh --- ms/controllerblueprints/parent/pom.xml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'ms/controllerblueprints/parent') diff --git a/ms/controllerblueprints/parent/pom.xml b/ms/controllerblueprints/parent/pom.xml index 9042318dc..578a0c7ef 100644 --- a/ms/controllerblueprints/parent/pom.xml +++ b/ms/controllerblueprints/parent/pom.xml @@ -33,7 +33,7 @@ 1.3.11 1.3.11 1.1.0 - 1.17.1 + 1.18.0 3.6.1 1.0.0 27.0.1-jre @@ -108,6 +108,11 @@ kotlin-stdlib ${kotlin.version} + + org.jetbrains.kotlin + kotlin-stdlib-common + ${kotlin.version} + org.jetbrains.kotlin kotlin-scripting-jvm-host -- cgit 1.2.3-korg From 6d6ebfa4b1b2c2c3ecf54d4476118c4a7b658625 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh" Date: Fri, 25 Jan 2019 20:17:35 -0500 Subject: blueprint scripting module Change-Id: Ibe7602bdb6708d9adbe1aecd26eb14e24872f75d Issue-ID: CCSDK-941 Signed-off-by: Muthuramalingam, Brinda Santh --- .../src/main/resources/application.properties | 2 +- .../modules/blueprint-scripts/pom.xml | 59 ++++++++ .../scripts/BluePrintCompiledScript.kt | 56 ++++++++ .../scripts/BluePrintCompilerProxy.kt | 150 +++++++++++++++++++++ .../scripts/BluePrintScriptConfiguration.kt | 61 +++++++++ .../scripts/BlueprintScriptingHost.kt | 92 +++++++++++++ .../scripts/BlueprintScriptingHostTest.kt | 88 ++++++++++++ .../src/test/resources/scripts1/simple.cba.kts | 55 ++++++++ .../src/test/resources/scripts2/simple.cba.kts | 55 ++++++++ ms/controllerblueprints/modules/pom.xml | 1 + ms/controllerblueprints/modules/service/pom.xml | 6 +- ms/controllerblueprints/parent/pom.xml | 38 ++++-- 12 files changed, 646 insertions(+), 17 deletions(-) create mode 100644 ms/controllerblueprints/modules/blueprint-scripts/pom.xml create mode 100644 ms/controllerblueprints/modules/blueprint-scripts/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/scripts/BluePrintCompiledScript.kt create mode 100644 ms/controllerblueprints/modules/blueprint-scripts/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/scripts/BluePrintCompilerProxy.kt create mode 100644 ms/controllerblueprints/modules/blueprint-scripts/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/scripts/BluePrintScriptConfiguration.kt create mode 100644 ms/controllerblueprints/modules/blueprint-scripts/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/scripts/BlueprintScriptingHost.kt create mode 100644 ms/controllerblueprints/modules/blueprint-scripts/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/scripts/BlueprintScriptingHostTest.kt create mode 100644 ms/controllerblueprints/modules/blueprint-scripts/src/test/resources/scripts1/simple.cba.kts create mode 100644 ms/controllerblueprints/modules/blueprint-scripts/src/test/resources/scripts2/simple.cba.kts (limited to 'ms/controllerblueprints/parent') diff --git a/ms/controllerblueprints/application/src/main/resources/application.properties b/ms/controllerblueprints/application/src/main/resources/application.properties index b6d509ce8..ec61be48b 100755 --- a/ms/controllerblueprints/application/src/main/resources/application.properties +++ b/ms/controllerblueprints/application/src/main/resources/application.properties @@ -41,7 +41,7 @@ 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.url=jdbc:mysql://localhost:3306/sdnctl spring.datasource.username=sdnctl spring.datasource.password=sdnctl spring.datasource.driver-class-name=org.mariadb.jdbc.Driver diff --git a/ms/controllerblueprints/modules/blueprint-scripts/pom.xml b/ms/controllerblueprints/modules/blueprint-scripts/pom.xml new file mode 100644 index 000000000..46c88b4cc --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-scripts/pom.xml @@ -0,0 +1,59 @@ + + + + + + modules + org.onap.ccsdk.apps.controllerblueprints + 0.4.1-SNAPSHOT + + 4.0.0 + blueprint-scripts + Controller Blueprints Scripts + + + + org.onap.ccsdk.apps.controllerblueprints + resource-dict + + + org.jetbrains.kotlin + kotlin-compiler-embeddable + + + org.jetbrains.kotlin + kotlin-scripting-jvm-host + + + org.jetbrains.kotlin + kotlin-compiler + + + + + org.jetbrains.kotlin + kotlin-script-util + + + org.jetbrains.kotlin + kotlin-script-runtime + + + + \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-scripts/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/scripts/BluePrintCompiledScript.kt b/ms/controllerblueprints/modules/blueprint-scripts/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/scripts/BluePrintCompiledScript.kt new file mode 100644 index 000000000..8ac915bd4 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-scripts/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/scripts/BluePrintCompiledScript.kt @@ -0,0 +1,56 @@ +/* + * 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.scripts + +import java.io.File +import java.io.Serializable +import java.net.URL +import java.net.URLClassLoader +import kotlin.reflect.KClass +import kotlin.script.experimental.api.* + +open class BluePrintCompiledScript( + private val scriptCompilationConfiguration: ScriptCompilationConfiguration, + private val compiledJar: File) : + CompiledScript, Serializable { + + lateinit var scriptClassFQName: String + + override val compilationConfiguration: ScriptCompilationConfiguration + get() = scriptCompilationConfiguration + + override suspend fun getClass(scriptEvaluationConfiguration: ScriptEvaluationConfiguration?): ResultWithDiagnostics> = try { + + val baseClassLoader = Thread.currentThread().contextClassLoader + + val urls = arrayListOf() + urls.add(compiledJar.toURI().toURL()) + val classLoaderWithDependencies = URLClassLoader(urls.toTypedArray(), baseClassLoader) + + val clazz = classLoaderWithDependencies.loadClass(scriptClassFQName).kotlin + clazz.asSuccess() + } catch (e: Throwable) { + ResultWithDiagnostics.Failure( + ScriptDiagnostic( + "Unable to instantiate class $scriptClassFQName", + exception = e + ) + ) + } + +} + diff --git a/ms/controllerblueprints/modules/blueprint-scripts/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/scripts/BluePrintCompilerProxy.kt b/ms/controllerblueprints/modules/blueprint-scripts/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/scripts/BluePrintCompilerProxy.kt new file mode 100644 index 000000000..7e9e86882 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-scripts/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/scripts/BluePrintCompilerProxy.kt @@ -0,0 +1,150 @@ +/* + * 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.scripts + +import org.jetbrains.kotlin.com.intellij.openapi.util.Disposer +import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys +import org.jetbrains.kotlin.cli.common.config.addKotlinSourceRoots +import org.jetbrains.kotlin.cli.common.environment.setIdeaIoUseFallback +import org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport +import org.jetbrains.kotlin.cli.common.messages.CompilerMessageLocation +import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity +import org.jetbrains.kotlin.cli.common.messages.MessageCollector +import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles +import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment +import org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler +import org.jetbrains.kotlin.cli.jvm.config.JvmClasspathRoot +import org.jetbrains.kotlin.config.* +import org.slf4j.LoggerFactory +import java.io.File +import kotlin.script.experimental.api.* +import kotlin.script.experimental.host.ScriptingHostConfiguration +import kotlin.script.experimental.jvm.util.classpathFromClasspathProperty +import kotlin.script.experimental.jvmhost.KJvmCompilerProxy + +open class BluePrintsCompilerProxy(private val hostConfiguration: ScriptingHostConfiguration) : KJvmCompilerProxy { + + private val log = LoggerFactory.getLogger(BluePrintsCompilerProxy::class.java)!! + + override fun compile(script: SourceCode, scriptCompilationConfiguration: ScriptCompilationConfiguration) + : ResultWithDiagnostics> { + + val messageCollector = ScriptDiagnosticsMessageCollector() + + fun failure(vararg diagnostics: ScriptDiagnostic): ResultWithDiagnostics.Failure = + ResultWithDiagnostics.Failure(*messageCollector.diagnostics.toTypedArray(), *diagnostics) + + // Compile the Code + try { + + log.trace("Scripting Host Configuration : $hostConfiguration") + + setIdeaIoUseFallback() + + val blueprintSourceCode = script as BluePrintSourceCode + + val compiledJarFile = blueprintSourceCode.targetJarFile + + if (!compiledJarFile.exists() || blueprintSourceCode.regenerate) { + + var environment: KotlinCoreEnvironment? = null + + val rootDisposable = Disposer.newDisposable() + + val compilerConfiguration = CompilerConfiguration().apply { + + put(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, messageCollector) + put(CommonConfigurationKeys.MODULE_NAME, blueprintSourceCode.moduleName) + put(JVMConfigurationKeys.OUTPUT_JAR, compiledJarFile) + put(JVMConfigurationKeys.RETAIN_OUTPUT_IN_MEMORY, false) + + // Load Current Class loader to Compilation Class loader + val currentClassLoader = classpathFromClasspathProperty() + currentClassLoader?.forEach { + add(CLIConfigurationKeys.CONTENT_ROOTS, JvmClasspathRoot(it)) + } + + // Add all Kotlin Sources + addKotlinSourceRoots(blueprintSourceCode.blueprintKotlinSources) + + languageVersionSettings = LanguageVersionSettingsImpl( + LanguageVersion.LATEST_STABLE, ApiVersion.LATEST_STABLE, mapOf(AnalysisFlags.skipMetadataVersionCheck to true) + ) + } + + //log.info("Executing with compiler configuration : $compilerConfiguration") + + environment = KotlinCoreEnvironment.createForProduction(rootDisposable, compilerConfiguration, + EnvironmentConfigFiles.JVM_CONFIG_FILES) + + // Compile Kotlin Sources + val compiled = KotlinToJVMBytecodeCompiler.compileBunchOfSources(environment) + + log.info("Generated jar(${compiledJarFile.absolutePath}) status : $compiled}") + + val analyzerWithCompilerReport = AnalyzerWithCompilerReport(messageCollector, + environment.configuration.languageVersionSettings) + + if (analyzerWithCompilerReport.hasErrors()) { + return failure() + } + } + + val res = BluePrintCompiledScript(scriptCompilationConfiguration, compiledJarFile) + + return ResultWithDiagnostics.Success(res, messageCollector.diagnostics) + + } catch (ex: Throwable) { + return failure(ex.asDiagnostics()) + } + } +} + +class ScriptDiagnosticsMessageCollector : MessageCollector { + + private val _diagnostics = arrayListOf() + + val diagnostics: List get() = _diagnostics + + override fun clear() { + _diagnostics.clear() + } + + override fun hasErrors(): Boolean = + _diagnostics.any { it.severity == ScriptDiagnostic.Severity.ERROR } + + + override fun report(severity: CompilerMessageSeverity, message: String, location: CompilerMessageLocation?) { + val mappedSeverity = when (severity) { + CompilerMessageSeverity.EXCEPTION, + CompilerMessageSeverity.ERROR -> ScriptDiagnostic.Severity.ERROR + CompilerMessageSeverity.STRONG_WARNING, + CompilerMessageSeverity.WARNING -> ScriptDiagnostic.Severity.WARNING + CompilerMessageSeverity.INFO -> ScriptDiagnostic.Severity.INFO + CompilerMessageSeverity.LOGGING -> ScriptDiagnostic.Severity.DEBUG + else -> null + } + if (mappedSeverity != null) { + val mappedLocation = location?.let { + if (it.line < 0 && it.column < 0) null // special location created by CompilerMessageLocation.create + else SourceCode.Location(SourceCode.Position(it.line, it.column)) + } + _diagnostics.add(ScriptDiagnostic(message, mappedSeverity, location?.path, mappedLocation)) + } + } +} + diff --git a/ms/controllerblueprints/modules/blueprint-scripts/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/scripts/BluePrintScriptConfiguration.kt b/ms/controllerblueprints/modules/blueprint-scripts/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/scripts/BluePrintScriptConfiguration.kt new file mode 100644 index 000000000..3b3a59079 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-scripts/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/scripts/BluePrintScriptConfiguration.kt @@ -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.scripts + +import java.io.File +import kotlin.script.experimental.annotations.KotlinScript +import kotlin.script.experimental.api.ScriptCompilationConfiguration +import kotlin.script.experimental.api.SourceCode +import kotlin.script.experimental.api.defaultImports +import kotlin.script.experimental.jvm.jvm +import kotlin.script.experimental.jvm.util.classpathFromClassloader + +@KotlinScript( + fileExtension = "cba.kts", + compilationConfiguration = BluePrintScripCompilationConfiguration::class, + displayName = "Controller Blueprint Archive Kotlin Scripts" +) +abstract class BluePrintKotlinScript + +object BluePrintScripCompilationConfiguration : ScriptCompilationConfiguration( + { + defaultImports( + "org.onap.ccsdk.apps.controllerblueprints.core.*", + "org.onap.ccsdk.apps.controllerblueprints.core.data.*", + "org.onap.ccsdk.apps.controllerblueprints.core.interfaces.*", + "org.onap.ccsdk.apps.controllerblueprints.core.services.*", + "org.onap.ccsdk.apps.controllerblueprints.core.utils.*") + jvm { + classpathFromClassloader(BluePrintScripCompilationConfiguration::class.java.classLoader) + } + } +) + +open class BluePrintSourceCode : SourceCode { + lateinit var blueprintKotlinSources: MutableList + lateinit var moduleName: String + lateinit var targetJarFile: File + var regenerate: Boolean = false + + override val text: String + get() = "" + + override val locationId: String? = null + + override val name: String? + get() = moduleName +} diff --git a/ms/controllerblueprints/modules/blueprint-scripts/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/scripts/BlueprintScriptingHost.kt b/ms/controllerblueprints/modules/blueprint-scripts/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/scripts/BlueprintScriptingHost.kt new file mode 100644 index 000000000..59ce4abb5 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-scripts/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/scripts/BlueprintScriptingHost.kt @@ -0,0 +1,92 @@ +/* + * 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.scripts + +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException +import org.slf4j.LoggerFactory +import java.util.* +import kotlin.script.experimental.api.* +import kotlin.script.experimental.host.BasicScriptingHost +import kotlin.script.experimental.jvm.defaultJvmScriptingHostConfiguration +import kotlin.script.experimental.jvmhost.JvmScriptCompiler +import kotlin.script.experimental.jvmhost.impl.withDefaults + +val blueprintScriptCompiler = JvmScriptCompiler(defaultJvmScriptingHostConfiguration, + BluePrintsCompilerProxy(defaultJvmScriptingHostConfiguration.withDefaults())) + +open class BlueprintScriptingHost(evaluator: ScriptEvaluator) : BasicScriptingHost(blueprintScriptCompiler, evaluator) { + + override fun eval( + script: SourceCode, + scriptCompilationConfiguration: ScriptCompilationConfiguration, + configuration: ScriptEvaluationConfiguration? + ): ResultWithDiagnostics = + + runInCoroutineContext { + + compiler(script, scriptCompilationConfiguration) + .onSuccess { + evaluator(it, configuration) + } + } +} + + +open class BluePrintScriptEvaluator(private val scriptClassName: String) : ScriptEvaluator { + + private val log = LoggerFactory.getLogger(BluePrintScriptEvaluator::class.java)!! + + override suspend operator fun invoke( + compiledScript: CompiledScript<*>, + scriptEvaluationConfiguration: ScriptEvaluationConfiguration? + ): ResultWithDiagnostics = + try { + log.info("Getting class name($scriptClassName) of type() from the compiled sources ") + val bluePrintCompiledScript = compiledScript as BluePrintCompiledScript + bluePrintCompiledScript.scriptClassFQName = scriptClassName + + val res = compiledScript.getClass(scriptEvaluationConfiguration) + when (res) { + is ResultWithDiagnostics.Failure -> res + is ResultWithDiagnostics.Success -> { + + val scriptClass = res.value + val args = ArrayList() + scriptEvaluationConfiguration?.get(ScriptEvaluationConfiguration.providedProperties)?.forEach { + args.add(it.value) + } + scriptEvaluationConfiguration?.get(ScriptEvaluationConfiguration.implicitReceivers)?.let { + args.addAll(it) + } + scriptEvaluationConfiguration?.get(ScriptEvaluationConfiguration.constructorArgs)?.let { + args.addAll(it) + } + + val instance = scriptClass.java.newInstance() as? T + ?: throw BluePrintProcessorException("failed to create instance from the script") + + log.info("Created script instance successfully....") + + ResultWithDiagnostics.Success(EvaluationResult(ResultValue.Value(scriptClass.qualifiedName!!, + instance, "", instance), + scriptEvaluationConfiguration)) + } + } + } catch (e: Throwable) { + ResultWithDiagnostics.Failure(e.asDiagnostics("Error evaluating script")) + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-scripts/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/scripts/BlueprintScriptingHostTest.kt b/ms/controllerblueprints/modules/blueprint-scripts/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/scripts/BlueprintScriptingHostTest.kt new file mode 100644 index 000000000..4b6f2a47d --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-scripts/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/scripts/BlueprintScriptingHostTest.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.scripts + + +import org.apache.commons.io.FileUtils +import org.junit.Ignore +import org.junit.Test +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BlueprintFunctionNode +import java.io.File +import kotlin.script.experimental.jvm.util.classpathFromClass +import kotlin.script.experimental.jvm.util.classpathFromClassloader +import kotlin.script.experimental.jvm.util.classpathFromClasspathProperty +import kotlin.script.experimental.jvmhost.createJvmCompilationConfigurationFromTemplate + +class BlueprintScriptingHostTest { + + @Test + @Ignore + fun `test classpaths`() { + + println(" *********** classpathFromClass *********** ") + classpathFromClass(BlueprintScriptingHostTest::class.java.classLoader, + BlueprintScriptingHostTest::class)!! + .forEach(::println) + + println(" *********** classpathFromClassloader *********** ") + classpathFromClassloader(BlueprintScriptingHostTest::class.java.classLoader)!! + .forEach(::println) + + println(" *********** classpathFromClasspathProperty *********** ") + classpathFromClasspathProperty()!! + .forEach(::println) + } + + @Test + fun `test same script two folders`() { + + FileUtils.forceMkdir(File("target/scripts1/")) + FileUtils.forceMkdir(File("target/scripts2/")) + + val scriptSource1 = BluePrintSourceCode() + scriptSource1.moduleName = "blueprint-test-script" + + scriptSource1.targetJarFile = File("target/scripts1/blueprint-script-generated.jar") + val sources1: MutableList = arrayListOf() + sources1.add("src/test/resources/scripts1") + scriptSource1.blueprintKotlinSources = sources1 + + val scriptClassName = "Simple_cba\$SampleComponentFunction" + + val compilationConfiguration = createJvmCompilationConfigurationFromTemplate() + + val scriptEvaluator = BluePrintScriptEvaluator>(scriptClassName) + + val scriptSource2 = BluePrintSourceCode() + scriptSource2.moduleName = "blueprint-test-script" + + scriptSource2.targetJarFile = File("target/scripts2/blueprint-script-generated.jar") + val sources2: MutableList = arrayListOf() + sources2.add("src/test/resources/scripts2") + scriptSource2.blueprintKotlinSources = sources2 + + for (i in 1..2) { + val evalResponse = BlueprintScriptingHost(scriptEvaluator).eval(scriptSource1, compilationConfiguration, + null) + } + + for (i in 1..2) { + val evalResponse = BlueprintScriptingHost(scriptEvaluator).eval(scriptSource2, compilationConfiguration, + null) + } + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-scripts/src/test/resources/scripts1/simple.cba.kts b/ms/controllerblueprints/modules/blueprint-scripts/src/test/resources/scripts1/simple.cba.kts new file mode 100644 index 000000000..9f61c649f --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-scripts/src/test/resources/scripts1/simple.cba.kts @@ -0,0 +1,55 @@ +/* + * 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. + */ + +import org.onap.ccsdk.apps.controllerblueprints.core.asJsonPrimitive +import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BlueprintFunctionNode +import org.springframework.stereotype.Service + +@Service +open class SampleComponentFunction : BlueprintFunctionNode { + + override fun getName(): String { + println("Printing Name....." + "sample".asJsonPrimitive()) + return "my Name" + } + + override fun prepareRequest(executionRequest: String): String { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun process(executionRequest: String) { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun recover(runtimeException: RuntimeException, executionRequest: String) { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun prepareResponse(): String { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun apply(t: String): String { + return "Script 1 response - $t" + } +} + +val blueprintFunction = SampleComponentFunction() + +val serviceTemplate = ServiceTemplate() + +println("Simple script printing....") diff --git a/ms/controllerblueprints/modules/blueprint-scripts/src/test/resources/scripts2/simple.cba.kts b/ms/controllerblueprints/modules/blueprint-scripts/src/test/resources/scripts2/simple.cba.kts new file mode 100644 index 000000000..845172548 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-scripts/src/test/resources/scripts2/simple.cba.kts @@ -0,0 +1,55 @@ +/* + * 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. + */ + +import org.onap.ccsdk.apps.controllerblueprints.core.asJsonPrimitive +import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BlueprintFunctionNode +import org.springframework.stereotype.Service + +@Service +open class SampleComponentFunction : BlueprintFunctionNode { + + override fun getName(): String { + println("Printing Name....." + "sample".asJsonPrimitive()) + return "my Name" + } + + override fun prepareRequest(executionRequest: String): String { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun process(executionRequest: String) { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun recover(runtimeException: RuntimeException, executionRequest: String) { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun prepareResponse(): String { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun apply(t: String): String { + return "Script 2 response - $t" + } +} + +val blueprintFunction = SampleComponentFunction() + +val serviceTemplate = ServiceTemplate() + +println("Simple script printing....") diff --git a/ms/controllerblueprints/modules/pom.xml b/ms/controllerblueprints/modules/pom.xml index 3857ef5db..834db24eb 100644 --- a/ms/controllerblueprints/modules/pom.xml +++ b/ms/controllerblueprints/modules/pom.xml @@ -30,6 +30,7 @@ service blueprint-validation db-resources + blueprint-scripts diff --git a/ms/controllerblueprints/modules/service/pom.xml b/ms/controllerblueprints/modules/service/pom.xml index 9868b17be..73fe0739b 100644 --- a/ms/controllerblueprints/modules/service/pom.xml +++ b/ms/controllerblueprints/modules/service/pom.xml @@ -30,10 +30,6 @@ - - org.onap.ccsdk.apps.controllerblueprints - core - org.onap.ccsdk.apps.controllerblueprints db-resources @@ -44,7 +40,7 @@ org.onap.ccsdk.apps.controllerblueprints - resource-dict + blueprint-scripts org.apache.velocity diff --git a/ms/controllerblueprints/parent/pom.xml b/ms/controllerblueprints/parent/pom.xml index 578a0c7ef..8cbc98e03 100644 --- a/ms/controllerblueprints/parent/pom.xml +++ b/ms/controllerblueprints/parent/pom.xml @@ -28,11 +28,11 @@ Controller Blueprints Parent pom - 2.1.1.RELEASE - 5.1.3.RELEASE - 1.3.11 - 1.3.11 - 1.1.0 + 2.1.2.RELEASE + 5.1.4.RELEASE + 1.3.20 + 1.3.20 + 1.1.1 1.18.0 3.6.1 1.0.0 @@ -113,16 +113,23 @@ kotlin-stdlib-common ${kotlin.version} + + org.jetbrains.kotlin kotlin-scripting-jvm-host ${kotlin.version} + + + org.jetbrains.kotlin + kotlin-compile + + org.jetbrains.kotlin kotlin-compiler-embeddable ${kotlin.version} - runtime org.jetbrains.kotlin @@ -203,27 +210,32 @@ org.onap.ccsdk.apps.controllerblueprints - service + resource-dict ${project.version} org.onap.ccsdk.apps.controllerblueprints - application + db-resources ${project.version} org.onap.ccsdk.apps.controllerblueprints - resource-dict + blueprint-validation ${project.version} org.onap.ccsdk.apps.controllerblueprints - db-resources + blueprint-scripts ${project.version} org.onap.ccsdk.apps.controllerblueprints - blueprint-validation + service + ${project.version} + + + org.onap.ccsdk.apps.controllerblueprints + application ${project.version} @@ -274,6 +286,10 @@ com.jayway.jsonpath json-path + + com.google.guava + guava + io.springfox springfox-swagger2 -- cgit 1.2.3-korg From 03fde837e1eb307cc0a17dda5161f1215c6159ad Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh" Date: Thu, 7 Feb 2019 14:51:50 -0500 Subject: Refactor components core and resource dict modules Change-Id: I04e9e723d68a38ecefe48206e67fddbe43c55854 Issue-ID: CCSDK-1047 Signed-off-by: Muthuramalingam, Brinda Santh --- .../artifact_type/artifact-bpmn-camunda.json | 8 + .../artifact_type/artifact-directed-graph.json | 9 + .../artifact_type/artifact-mapping-resource.json | 8 + .../artifact_type/artifact-script-python.json | 8 + .../artifact_type/artifact-template-velocity.json | 8 + .../tosca.artifacts.Implementation.json | 5 + .../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 + .../data_type/tosca.datatypes.Credential.json | 31 + .../node_type/artifact-config-template.json | 37 ++ .../node_type/component-config-generator.json | 72 +++ .../node_type/component-netconf-executor.json | 79 +++ .../node_type/component-resource-assignment.json | 68 +++ .../model_type/node_type/dg-activate-netconf.json | 52 ++ .../model_type/node_type/dg-config-generator.json | 51 ++ .../node_type/dg-resource-assign-activate.json | 56 ++ .../node_type/dg-resource-assignment.json | 51 ++ .../model_type/node_type/tosca.nodes.Artifact.json | 5 + .../node_type/tosca.nodes.Component.json | 5 + .../load/model_type/node_type/tosca.nodes.DG.json | 5 + .../load/model_type/node_type/tosca.nodes.Vnf.json | 5 + .../node_type/tosca.nodes.component.Python.json | 5 + .../model_type/node_type/vnf-netconf-device.json | 42 ++ .../modules/blueprint-core/pom.xml | 76 +++ .../core/BluePrintConstants.kt | 176 ++++++ .../controllerblueprints/core/BluePrintError.kt | 29 + .../core/BluePrintException.kt | 49 ++ .../core/BluePrintProcessorException.kt | 50 ++ .../controllerblueprints/core/BluePrintTypes.kt | 164 ++++++ .../core/ConfigModelConstant.kt | 30 + .../controllerblueprints/core/CustomFunctions.kt | 151 +++++ .../core/common/ApplicationConstants.kt | 23 + .../core/config/BluePrintLoadConfiguration.kt | 34 ++ .../core/data/BluePrintExpressionData.kt | 70 +++ .../core/data/BluePrintModel.kt | 622 +++++++++++++++++++++ .../core/data/BlueprintErrorCode.kt | 97 ++++ .../core/factory/BluePrintValidatorFactory.kt | 45 ++ .../core/interfaces/BluePrintCatalogService.kt | 59 ++ .../core/interfaces/BluePrintEnhancer.kt | 141 +++++ .../core/interfaces/BluePrintRepoService.kt | 47 ++ .../core/interfaces/BluePrintScriptsService.kt | 25 + .../core/interfaces/BlueprintFunctionNode.kt | 39 ++ .../core/interfaces/BlueprintValidator.kt | 132 +++++ .../core/service/BluePrintChainedService.kt | 117 ++++ .../core/service/BluePrintContext.kt | 254 +++++++++ .../core/service/BluePrintExpressionService.kt | 173 ++++++ .../core/service/BluePrintImportService.kt | 96 ++++ .../core/service/BluePrintParserService.kt | 62 ++ .../core/service/BluePrintRepoFileService.kt | 71 +++ .../core/service/BluePrintRuntimeService.kt | 501 +++++++++++++++++ .../core/service/BluePrintTemplateService.kt | 94 ++++ .../core/service/BluePrintValidatorService.kt | 607 ++++++++++++++++++++ .../core/service/PropertyAssignmentService.kt | 210 +++++++ .../core/utils/BluePrintArchiveUtils.kt | 147 +++++ .../core/utils/BluePrintFileUtils.kt | 253 +++++++++ .../core/utils/BluePrintMetadataUtils.kt | 144 +++++ .../core/utils/BluePrintRuntimeUtils.kt | 61 ++ .../core/utils/JacksonReactorUtils.kt | 109 ++++ .../core/utils/JacksonUtils.kt | 287 ++++++++++ .../core/utils/ResourceResolverUtils.kt | 62 ++ .../core/utils/ServiceTemplateUtils.kt | 110 ++++ .../core/utils/TopologicalSortingUtils.kt | 131 +++++ .../BluePrintArtifactTypeValidatorImpl.kt | 33 ++ .../BluePrintAttributeDefinitionValidatorImpl.kt | 29 + .../validation/BluePrintDataTypeValidatorImpl.kt | 37 ++ .../BluePrintNodeTemplateValidatorImpl.kt | 298 ++++++++++ .../validation/BluePrintNodeTypeValidatorImpl.kt | 155 +++++ .../BluePrintPropertyDefinitionValidatorImpl.kt | 83 +++ .../BluePrintServiceTemplateValidatorImpl.kt | 107 ++++ .../BluePrintTopologyTemplateValidatorImpl.kt | 72 +++ .../validation/BluePrintValidatorServiceImpl.kt | 48 ++ .../validation/BluePrintWorkflowValidatorImpl.kt | 76 +++ .../services/javax.script.ScriptEngineFactory | 17 + .../core/CustomFunctionsTest.kt | 35 ++ .../core/mock/MockBluePrintTypeValidatorService.kt | 59 ++ .../core/service/BluePrintContextTest.kt | 54 ++ .../core/service/BluePrintExpressionServiceTest.kt | 117 ++++ .../core/service/BluePrintRepoFileServiceTest.kt | 57 ++ .../core/service/BluePrintRuntimeServiceTest.kt | 144 +++++ .../core/service/BluePrintTemplateServiceTest.kt | 35 ++ .../BluePrintValidatorDefaultServiceTest.kt | 50 ++ .../core/utils/BluePrintFileUtilsTest.kt | 60 ++ .../core/utils/BluePrintMetadataUtilsTest.kt | 41 ++ .../core/utils/JacksonUtilsTest.kt | 78 +++ .../core/utils/TopologicalSortingUtilsTest.kt | 36 ++ .../BluePrintValidatorServiceImplTest.kt | 100 ++++ .../src/test/resources/componentnode/default.json | 100 ++++ .../src/test/resources/data/alltype-data.json | 10 + .../src/test/resources/data/default-context.json | 7 + .../resources/dictionary/dictionary_schema.json | 261 +++++++++ .../src/test/resources/properties/convert.json | 36 ++ .../src/test/resources/properties/default.json | 16 + .../scripts/SampleBlueprintFunctionNode.kts | 44 ++ .../test/resources/templates/base-config-data.json | 36 ++ .../resources/templates/base-config-template.vtl | 61 ++ .../modules/blueprint-validation/pom.xml | 2 +- .../modules/db-resources/pom.xml | 2 +- ms/controllerblueprints/modules/pom.xml | 7 +- .../node_type/source-component-java.json | 31 + .../load/model_type/node_type/source-default.json | 18 + .../load/model_type/node_type/source-input.json | 18 + .../model_type/node_type/source-primary-db.json | 44 ++ .../load/model_type/node_type/source-rest.json | 61 ++ .../node_type/tosca.nodes.ResourceSource.json | 5 + .../load/resource_dictionary/address.json | 17 + .../load/resource_dictionary/aic-cloud-region.json | 17 + .../load/resource_dictionary/aic_clli.json | 17 + .../resource_dictionary/availability_zone_0.json | 17 + .../load/resource_dictionary/default-source.json | 16 + .../load/resource_dictionary/input-source.json | 17 + .../load/resource_dictionary/mdsal-source.json | 34 ++ .../load/resource_dictionary/name_0.json | 17 + .../load/resource_dictionary/nf-role.json | 25 + .../load/resource_dictionary/nfc-naming-code.json | 25 + .../resource_dictionary/onap_private_net_cidr.json | 21 + .../resource_dictionary/onap_private_net_id.json | 17 + .../resource_dictionary/primary-db-source.json | 24 + .../resource_dictionary/private-prefix-id.json | 21 + .../resource_dictionary/protected-prefix-id.json | 21 + .../protected_private_net_cidr.json | 21 + .../load/resource_dictionary/public_net_id.json | 17 + .../resource_dictionary/service-instance-id.json | 17 + .../resource_dictionary/unprotected-prefix-id.json | 21 + .../unprotected_private_net_cidr.json | 21 + .../load/resource_dictionary/vf-module-id.json | 17 + .../load/resource_dictionary/vf-module-label.json | 25 + .../vf-module-model-customization-uuid.json | 17 + .../load/resource_dictionary/vf-module-type.json | 25 + .../load/resource_dictionary/vf-naming-policy.json | 25 + .../load/resource_dictionary/vf-nf-code.json | 25 + .../load/resource_dictionary/vf_module_name.json | 17 + .../resource_dictionary/vfccustomizationuuid.json | 25 + .../load/resource_dictionary/vfw_private_ip_0.json | 35 ++ .../load/resource_dictionary/vfw_private_ip_1.json | 35 ++ .../load/resource_dictionary/vfw_private_ip_2.json | 17 + .../load/resource_dictionary/vm-type.json | 25 + .../load/resource_dictionary/vnf-id.json | 17 + .../vnf-model-customization-uuid.json | 17 + .../load/resource_dictionary/vnf-name.json | 28 + .../load/resource_dictionary/vnf_name.json | 28 + .../vnfc-model-invariant-uuid.json | 25 + .../resource_dictionary/vnfc-model-version.json | 25 + .../load/resource_dictionary/vpg_private_ip_0.json | 35 ++ .../load/resource_dictionary/vpg_private_ip_1.json | 17 + .../load/resource_dictionary/vsn_private_ip_0.json | 35 ++ .../load/resource_dictionary/vsn_private_ip_1.json | 17 + .../modules/resource-dict/pom.xml | 42 ++ .../resource/dict/ResourceDefinition.kt | 100 ++++ .../resource/dict/ResourceDictionaryConstants.kt | 38 ++ .../dict/factory/ResourceSourceMappingFactory.kt | 47 ++ .../service/ResourceAssignmentValidationService.kt | 163 ++++++ .../service/ResourceDefinitionValidationService.kt | 113 ++++ .../dict/utils/BulkResourceSequencingUtils.kt | 109 ++++ .../resource/dict/utils/ResourceDictionaryUtils.kt | 94 ++++ .../resource/dict/ResourceDefinitionTest.java | 60 ++ .../factory/ResourceSourceMappingFactoryTest.java | 42 ++ .../ResourceAssignmentValidationServiceTest.kt | 66 +++ .../ResourceDefinitionValidationServiceTest.java | 56 ++ .../utils/BulkResourceSequencingUtilsTest.java | 37 ++ .../dict/utils/ResourceDictionaryUtilsTest.java | 99 ++++ .../dict/utils/ResourceDictionaryTestUtils.kt | 30 + .../resources/data/resource-assignment-input.json | 10 + .../src/test/resources/validation/cyclic.json | 111 ++++ .../src/test/resources/validation/duplicate.json | 110 ++++ .../src/test/resources/validation/success.json | 110 ++++ ms/controllerblueprints/parent/pom.xml | 64 ++- 168 files changed, 11263 insertions(+), 10 deletions(-) create mode 100644 ms/controllerblueprints/modules/blueprint-core/load/model_type/artifact_type/artifact-bpmn-camunda.json create mode 100644 ms/controllerblueprints/modules/blueprint-core/load/model_type/artifact_type/artifact-directed-graph.json create mode 100644 ms/controllerblueprints/modules/blueprint-core/load/model_type/artifact_type/artifact-mapping-resource.json create mode 100644 ms/controllerblueprints/modules/blueprint-core/load/model_type/artifact_type/artifact-script-python.json create mode 100644 ms/controllerblueprints/modules/blueprint-core/load/model_type/artifact_type/artifact-template-velocity.json create mode 100644 ms/controllerblueprints/modules/blueprint-core/load/model_type/artifact_type/tosca.artifacts.Implementation.json create mode 100644 ms/controllerblueprints/modules/blueprint-core/load/model_type/data_type/datatype-property.json create mode 100644 ms/controllerblueprints/modules/blueprint-core/load/model_type/data_type/datatype-resource-assignment.json create mode 100644 ms/controllerblueprints/modules/blueprint-core/load/model_type/data_type/dt-license-key.json create mode 100644 ms/controllerblueprints/modules/blueprint-core/load/model_type/data_type/dt-v4-aggregate.json create mode 100644 ms/controllerblueprints/modules/blueprint-core/load/model_type/data_type/tosca.datatypes.Credential.json create mode 100644 ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/artifact-config-template.json create mode 100644 ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/component-config-generator.json create mode 100644 ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/component-netconf-executor.json create mode 100644 ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/component-resource-assignment.json create mode 100644 ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/dg-activate-netconf.json create mode 100644 ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/dg-config-generator.json create mode 100644 ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/dg-resource-assign-activate.json create mode 100644 ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/dg-resource-assignment.json create mode 100644 ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/tosca.nodes.Artifact.json create mode 100644 ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/tosca.nodes.Component.json create mode 100644 ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/tosca.nodes.DG.json create mode 100644 ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/tosca.nodes.Vnf.json create mode 100644 ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/tosca.nodes.component.Python.json create mode 100644 ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/vnf-netconf-device.json create mode 100644 ms/controllerblueprints/modules/blueprint-core/pom.xml create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintError.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintException.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintProcessorException.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/ConfigModelConstant.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctions.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/common/ApplicationConstants.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/config/BluePrintLoadConfiguration.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintExpressionData.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BlueprintErrorCode.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/factory/BluePrintValidatorFactory.kt create mode 100755 ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintCatalogService.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintEnhancer.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintRepoService.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintScriptsService.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintFunctionNode.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintValidator.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintChainedService.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionService.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintImportService.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintParserService.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileService.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintTemplateService.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt create mode 100755 ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintArchiveUtils.kt create mode 100755 ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintRuntimeUtils.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtils.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/ResourceResolverUtils.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/ServiceTemplateUtils.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/TopologicalSortingUtils.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintArtifactTypeValidatorImpl.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintAttributeDefinitionValidatorImpl.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintDataTypeValidatorImpl.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTemplateValidatorImpl.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTypeValidatorImpl.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintPropertyDefinitionValidatorImpl.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintServiceTemplateValidatorImpl.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintTopologyTemplateValidatorImpl.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImpl.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintWorkflowValidatorImpl.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/main/resources/META-INF/services/javax.script.ScriptEngineFactory create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctionsTest.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/mock/MockBluePrintTypeValidatorService.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContextTest.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionServiceTest.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintTemplateServiceTest.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorDefaultServiceTest.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtilsTest.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtilsTest.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/TopologicalSortingUtilsTest.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImplTest.kt create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/test/resources/componentnode/default.json create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/test/resources/data/alltype-data.json create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/test/resources/data/default-context.json create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/test/resources/dictionary/dictionary_schema.json create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/test/resources/properties/convert.json create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/test/resources/properties/default.json create mode 100644 ms/controllerblueprints/modules/blueprint-core/src/test/resources/scripts/SampleBlueprintFunctionNode.kts create mode 100755 ms/controllerblueprints/modules/blueprint-core/src/test/resources/templates/base-config-data.json create mode 100755 ms/controllerblueprints/modules/blueprint-core/src/test/resources/templates/base-config-template.vtl create mode 100644 ms/controllerblueprints/modules/resource-dict/load/model_type/node_type/source-component-java.json create mode 100644 ms/controllerblueprints/modules/resource-dict/load/model_type/node_type/source-default.json create mode 100644 ms/controllerblueprints/modules/resource-dict/load/model_type/node_type/source-input.json create mode 100644 ms/controllerblueprints/modules/resource-dict/load/model_type/node_type/source-primary-db.json create mode 100644 ms/controllerblueprints/modules/resource-dict/load/model_type/node_type/source-rest.json create mode 100644 ms/controllerblueprints/modules/resource-dict/load/model_type/node_type/tosca.nodes.ResourceSource.json create mode 100644 ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/address.json create mode 100644 ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/aic-cloud-region.json create mode 100644 ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/aic_clli.json create mode 100644 ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/availability_zone_0.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/load/resource_dictionary/name_0.json create mode 100644 ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/nf-role.json create mode 100644 ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/nfc-naming-code.json create mode 100644 ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/onap_private_net_cidr.json create mode 100644 ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/onap_private_net_id.json create mode 100644 ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/primary-db-source.json create mode 100644 ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/private-prefix-id.json create mode 100644 ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/protected-prefix-id.json create mode 100644 ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/protected_private_net_cidr.json create mode 100644 ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/public_net_id.json create mode 100644 ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/service-instance-id.json create mode 100644 ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/unprotected-prefix-id.json create mode 100644 ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/unprotected_private_net_cidr.json create mode 100644 ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vf-module-id.json create mode 100644 ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vf-module-label.json create mode 100644 ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vf-module-model-customization-uuid.json create mode 100644 ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vf-module-type.json create mode 100644 ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vf-naming-policy.json create mode 100644 ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vf-nf-code.json create mode 100644 ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vf_module_name.json create mode 100644 ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vfccustomizationuuid.json create mode 100644 ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vfw_private_ip_0.json create mode 100644 ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vfw_private_ip_1.json create mode 100644 ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vfw_private_ip_2.json create mode 100644 ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vm-type.json create mode 100644 ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vnf-id.json create mode 100644 ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vnf-model-customization-uuid.json create mode 100644 ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vnf-name.json create mode 100644 ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vnf_name.json create mode 100644 ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vnfc-model-invariant-uuid.json create mode 100644 ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vnfc-model-version.json create mode 100644 ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vpg_private_ip_0.json create mode 100644 ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vpg_private_ip_1.json create mode 100644 ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vsn_private_ip_0.json create mode 100644 ms/controllerblueprints/modules/resource-dict/load/resource_dictionary/vsn_private_ip_1.json create mode 100644 ms/controllerblueprints/modules/resource-dict/pom.xml create mode 100644 ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinition.kt create mode 100644 ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt create mode 100644 ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactory.kt create mode 100644 ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt create mode 100644 ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt create mode 100644 ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtils.kt create mode 100644 ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt create mode 100644 ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java create mode 100644 ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactoryTest.java create mode 100644 ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt create mode 100644 ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationServiceTest.java create mode 100644 ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtilsTest.java create mode 100644 ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java create mode 100644 ms/controllerblueprints/modules/resource-dict/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryTestUtils.kt create mode 100644 ms/controllerblueprints/modules/resource-dict/src/test/resources/data/resource-assignment-input.json create mode 100644 ms/controllerblueprints/modules/resource-dict/src/test/resources/validation/cyclic.json create mode 100644 ms/controllerblueprints/modules/resource-dict/src/test/resources/validation/duplicate.json create mode 100644 ms/controllerblueprints/modules/resource-dict/src/test/resources/validation/success.json (limited to 'ms/controllerblueprints/parent') diff --git a/ms/controllerblueprints/modules/blueprint-core/load/model_type/artifact_type/artifact-bpmn-camunda.json b/ms/controllerblueprints/modules/blueprint-core/load/model_type/artifact_type/artifact-bpmn-camunda.json new file mode 100644 index 000000000..cae06c18f --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-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/blueprint-core/load/model_type/artifact_type/artifact-directed-graph.json b/ms/controllerblueprints/modules/blueprint-core/load/model_type/artifact_type/artifact-directed-graph.json new file mode 100644 index 000000000..10bf7d2c4 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-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/blueprint-core/load/model_type/artifact_type/artifact-mapping-resource.json b/ms/controllerblueprints/modules/blueprint-core/load/model_type/artifact_type/artifact-mapping-resource.json new file mode 100644 index 000000000..9123efd1d --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/load/model_type/artifact_type/artifact-mapping-resource.json @@ -0,0 +1,8 @@ +{ + "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/blueprint-core/load/model_type/artifact_type/artifact-script-python.json b/ms/controllerblueprints/modules/blueprint-core/load/model_type/artifact_type/artifact-script-python.json new file mode 100644 index 000000000..22af3b0a9 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/load/model_type/artifact_type/artifact-script-python.json @@ -0,0 +1,8 @@ +{ + "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/blueprint-core/load/model_type/artifact_type/artifact-template-velocity.json b/ms/controllerblueprints/modules/blueprint-core/load/model_type/artifact_type/artifact-template-velocity.json new file mode 100644 index 000000000..20f94c946 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/load/model_type/artifact_type/artifact-template-velocity.json @@ -0,0 +1,8 @@ +{ + "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/blueprint-core/load/model_type/artifact_type/tosca.artifacts.Implementation.json b/ms/controllerblueprints/modules/blueprint-core/load/model_type/artifact_type/tosca.artifacts.Implementation.json new file mode 100644 index 000000000..d75f33760 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/load/model_type/artifact_type/tosca.artifacts.Implementation.json @@ -0,0 +1,5 @@ +{ + "description": "TOSCA base type for implementation artifacts", + "version": "1.0.0", + "derived_from": "tosca.artifacts.Root" +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/load/model_type/data_type/datatype-property.json b/ms/controllerblueprints/modules/blueprint-core/load/model_type/data_type/datatype-property.json new file mode 100644 index 000000000..d3ecffd17 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/load/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 diff --git a/ms/controllerblueprints/modules/blueprint-core/load/model_type/data_type/datatype-resource-assignment.json b/ms/controllerblueprints/modules/blueprint-core/load/model_type/data_type/datatype-resource-assignment.json new file mode 100644 index 000000000..8fa595a15 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/load/model_type/data_type/datatype-resource-assignment.json @@ -0,0 +1,46 @@ +{ + "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/blueprint-core/load/model_type/data_type/dt-license-key.json b/ms/controllerblueprints/modules/blueprint-core/load/model_type/data_type/dt-license-key.json new file mode 100644 index 000000000..27e25fe17 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/load/model_type/data_type/dt-license-key.json @@ -0,0 +1,11 @@ +{ + "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/blueprint-core/load/model_type/data_type/dt-v4-aggregate.json b/ms/controllerblueprints/modules/blueprint-core/load/model_type/data_type/dt-v4-aggregate.json new file mode 100644 index 000000000..4f7be2dba --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/load/model_type/data_type/dt-v4-aggregate.json @@ -0,0 +1,15 @@ +{ + "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/blueprint-core/load/model_type/data_type/tosca.datatypes.Credential.json b/ms/controllerblueprints/modules/blueprint-core/load/model_type/data_type/tosca.datatypes.Credential.json new file mode 100644 index 000000000..68d91652f --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/load/model_type/data_type/tosca.datatypes.Credential.json @@ -0,0 +1,31 @@ +{ + "version": "1.0.0", + "description": "Credential", + "properties": { + "protocol": { + "required": false, + "type": "string" + }, + "token_type": { + "required": true, + "type": "string", + "default" : "password" + }, + "token": { + "required": false, + "type": "string" + }, + "keys": { + "required": false, + "type": "list", + "entry_schema": { + "type": "string" + } + }, + "user": { + "required": false, + "type": "string" + } + }, + "derived_from": "tosca.datatypes.Root" +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/artifact-config-template.json b/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/artifact-config-template.json new file mode 100644 index 000000000..057038fd2 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/artifact-config-template.json @@ -0,0 +1,37 @@ +{ + "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" +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/component-config-generator.json b/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/component-config-generator.json new file mode 100644 index 000000000..05bf7fe24 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/component-config-generator.json @@ -0,0 +1,72 @@ +{ + "description": "This is Generate Configuration Component API", + "version": "1.0.0", + "capabilities": { + "component-node": { + "type": "tosca.capabilities.Node" + } + }, + "interfaces": { + "org-onap-ccsdk-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/blueprint-core/load/model_type/node_type/component-netconf-executor.json b/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/component-netconf-executor.json new file mode 100644 index 000000000..22f5c9b3c --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/component-netconf-executor.json @@ -0,0 +1,79 @@ +{ + "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-onap-ccsdk-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" + }, + "service-template-name": { + "description": "Service Template Name", + "required": true, + "type": "string" + }, + "service-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/blueprint-core/load/model_type/node_type/component-resource-assignment.json b/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/component-resource-assignment.json new file mode 100644 index 000000000..e009f8583 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/component-resource-assignment.json @@ -0,0 +1,68 @@ +{ + "description": "This is Resource Assignment Component API", + "version": "1.0.0", + "capabilities": { + "component-node": { + "type": "tosca.capabilities.Node" + } + }, + "interfaces": { + "ResourceAssignmentComponent": { + "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/blueprint-core/load/model_type/node_type/dg-activate-netconf.json b/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/dg-activate-netconf.json new file mode 100644 index 000000000..57667de98 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/dg-activate-netconf.json @@ -0,0 +1,52 @@ +{ + "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" +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/dg-config-generator.json b/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/dg-config-generator.json new file mode 100644 index 000000000..679c4641c --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/dg-config-generator.json @@ -0,0 +1,51 @@ +{ + "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" + } + }, + "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/blueprint-core/load/model_type/node_type/dg-resource-assign-activate.json b/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/dg-resource-assign-activate.json new file mode 100644 index 000000000..87b052b61 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/dg-resource-assign-activate.json @@ -0,0 +1,56 @@ +{ + "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" + } + }, + "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/blueprint-core/load/model_type/node_type/dg-resource-assignment.json b/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/dg-resource-assignment.json new file mode 100644 index 000000000..9de599b01 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/dg-resource-assignment.json @@ -0,0 +1,51 @@ +{ + "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" + } + }, + "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/blueprint-core/load/model_type/node_type/tosca.nodes.Artifact.json b/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/tosca.nodes.Artifact.json new file mode 100644 index 000000000..4db3f73c8 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/tosca.nodes.Artifact.json @@ -0,0 +1,5 @@ +{ + "description": "This is Deprecated Artifact Node Type.", + "version": "1.0.0", + "derived_from": "tosca.nodes.Root" +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/tosca.nodes.Component.json b/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/tosca.nodes.Component.json new file mode 100644 index 000000000..d559216af --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/tosca.nodes.Component.json @@ -0,0 +1,5 @@ +{ + "description": "This is default Component Node", + "version": "1.0.0", + "derived_from": "tosca.nodes.Root" +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/tosca.nodes.DG.json b/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/tosca.nodes.DG.json new file mode 100644 index 000000000..eb8cac0ae --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/tosca.nodes.DG.json @@ -0,0 +1,5 @@ +{ + "description": "This is Directed Graph Node Type", + "version": "1.0.0", + "derived_from": "tosca.nodes.Root" +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/tosca.nodes.Vnf.json b/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/tosca.nodes.Vnf.json new file mode 100644 index 000000000..c2f5b8687 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/tosca.nodes.Vnf.json @@ -0,0 +1,5 @@ +{ + "description": "This is VNF Node Type", + "version": "1.0.0", + "derived_from": "tosca.nodes.Root" +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/tosca.nodes.component.Python.json b/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/tosca.nodes.component.Python.json new file mode 100644 index 000000000..908e5682e --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/tosca.nodes.component.Python.json @@ -0,0 +1,5 @@ +{ + "description": "This is Python Component", + "version": "1.0.0", + "derived_from": "tosca.nodes.Root" +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/vnf-netconf-device.json b/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/vnf-netconf-device.json new file mode 100644 index 000000000..b226a0cf8 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/load/model_type/node_type/vnf-netconf-device.json @@ -0,0 +1,42 @@ +{ + "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/blueprint-core/pom.xml b/ms/controllerblueprints/modules/blueprint-core/pom.xml new file mode 100644 index 000000000..9461b2ca5 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/pom.xml @@ -0,0 +1,76 @@ + + + + + 4.0.0 + + org.onap.ccsdk.apps.controllerblueprints + modules + 0.4.1-SNAPSHOT + + blueprint-core + Controller Blueprints Core + + + + com.fasterxml.jackson.dataformat + jackson-dataformat-xml + + + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml + + + com.fasterxml.jackson.module + jackson-module-jsonSchema + + + io.projectreactor + reactor-core + + + org.yaml + snakeyaml + + + org.apache.velocity + velocity + + + + org.jetbrains.kotlin + kotlin-test-junit + test + + + io.mockk + mockk + test + + + org.jetbrains.kotlinx + kotlinx-coroutines-test + test + + + + + diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt new file mode 100644 index 000000000..c50218bfb --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt @@ -0,0 +1,176 @@ +/* + * 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.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 STATUS_SUCCESS: String = "success" + const val STATUS_PROCESSING: String = "processing" + const val STATUS_FAILURE: String = "failure" + + const val TYPE_DEFAULT: String = "default" + + const val DATA_TYPE_STRING: String = "string" + const val DATA_TYPE_INTEGER: String = "integer" + const val DATA_TYPE_FLOAT: String = "float" + const val DATA_TYPE_DOUBLE: String = "double" + const val DATA_TYPE_BOOLEAN: String = "boolean" + const val DATA_TYPE_TIMESTAMP: String = "timestamp" + const val DATA_TYPE_NULL: String = "null" + const val DATA_TYPE_LIST: String = "list" + const val DATA_TYPE_MAP: String = "map" + + const val USER_SYSTEM: String = "System" + + const val PATH_DIVIDER: String = "/" + const val PATH_SERVICE_TEMPLATE: String = "service_template" + const val PATH_TOPOLOGY_TEMPLATE: String = "topology_template" + const val PATH_METADATA: String = "metadata" + const val PATH_NODE_TYPES: String = "node_types" + const val PATH_POLICY_TYPES: String = "policy_types" + const val PATH_RELATIONSHIP_TYPES: String = "relationship_types" + const val PATH_ARTIFACT_TYPES: String = "artifact_types" + const val PATH_DATA_TYPES: String = "data_types" + const val PATH_INPUTS: String = "inputs" + const val PATH_NODE_WORKFLOWS: String = "workflows" + const val PATH_NODE_TEMPLATES: String = "node_templates" + const val PATH_CAPABILITIES: String = "capabilities" + const val PATH_REQUIREMENTS: String = "requirements" + const val PATH_INTERFACES: String = "interfaces" + const val PATH_OPERATIONS: String = "operations" + const val PATH_OUTPUTS: String = "outputs" + const val PATH_PROPERTIES: String = "properties" + const val PATH_ATTRIBUTES: String = "attributes" + const val PATH_ARTIFACTS: String = "artifacts" + + const val MODEL_DIR_MODEL_TYPE: String = "definition-type" + + const val MODEL_DEFINITION_TYPE_NODE_TYPE: String = "node_type" + const val MODEL_DEFINITION_TYPE_ARTIFACT_TYPE: String = "artifact_type" + const val MODEL_DEFINITION_TYPE_CAPABILITY_TYPE: String = "capability_type" + const val MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE: String = "relationship_type" + const val MODEL_DEFINITION_TYPE_DATA_TYPE: String = "data_type" + + const val MODEL_TYPE_DATATYPES_ROOT: String = "tosca.datatypes.Root" + const val MODEL_TYPE_NODES_ROOT: String = "tosca.nodes.Root" + const val MODEL_TYPE_GROUPS_ROOT: String = "tosca.groups.Root" + const val MODEL_TYPE_RELATIONSHIPS_ROOT: String = "tosca.relationships.Root" + const val MODEL_TYPE_ARTIFACTS_ROOT: String = "tosca.artifacts.Root" + const val MODEL_TYPE_CAPABILITIES_ROOT: String = "tosca.capabilities.Root" + const val MODEL_TYPE_INTERFACES_ROOT: String = "tosca.interfaces.Root" + + const val MODEL_TYPE_RELATIONSHIPS_DEPENDS_ON = "tosca.relationships.DependsOn" + const val MODEL_TYPE_RELATIONSHIPS_HOSTED_ON = "tosca.relationships.HostedOn" + const val MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO = "tosca.relationships.ConnectsTo" + const val MODEL_TYPE_RELATIONSHIPS_ATTACH_TO = "tosca.relationships.AttachesTo" + const val MODEL_TYPE_RELATIONSHIPS_ROUTES_TO = "tosca.relationships.RoutesTo" + + const val MODEL_TYPE_NODE_DG = "tosca.nodes.DG" + const val MODEL_TYPE_NODE_COMPONENT = "tosca.nodes.Component" + const val MODEL_TYPE_NODE_VNF = "tosca.nodes.Vnf" + @Deprecated("Artifacts will be attached to Node Template") + const val MODEL_TYPE_NODE_ARTIFACT = "tosca.nodes.Artifact" + const val MODEL_TYPE_NODE_RESOURCE_SOURCE = "tosca.nodes.ResourceSource" + + const val MODEL_TYPE_NODES_COMPONENT_JAVA: String = "tosca.nodes.component.Java" + const val MODEL_TYPE_NODES_COMPONENT_BUNDLE: String = "tosca.nodes.component.Bundle" + const val MODEL_TYPE_NODES_COMPONENT_SCRIPT: String = "tosca.nodes.component.Script" + const val MODEL_TYPE_NODES_COMPONENT_PYTHON: String = "tosca.nodes.component.Python" + const val MODEL_TYPE_NODES_COMPONENT_JYTHON: String = "tosca.nodes.component.Jython" + const val MODEL_TYPE_NODES_COMPONENT_KOTLIN: String = "tosca.nodes.component.Kotlin" + const val MODEL_TYPE_NODES_COMPONENT_JAVA_SCRIPT: String = "tosca.nodes.component.JavaScript" + + const val MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION = "tosca.artifacts.Implementation" + + const val MODEL_TYPE_DATA_TYPE_DYNAMIC = "tosca.datatypes.Dynamic" + + const val MODEL_TYPE_CAPABILITY_TYPE_NODE = "tosca.capabilities.Node" + const val MODEL_TYPE_CAPABILITY_TYPE_COMPUTE = "tosca.capabilities.Compute" + const val MODEL_TYPE_CAPABILITY_TYPE_NETWORK = "tosca.capabilities.Network" + const val MODEL_TYPE_CAPABILITY_TYPE_STORAGE = "tosca.capabilities.Storage" + const val MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT = "tosca.capabilities.Endpoint" + const val MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_PUBLIC = "tosca.capabilities.Endpoint.Public" + const val MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_ADMIN = "tosca.capabilities.Endpoint.Admin" + const val MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_DATABASE = "tosca.capabilities.Endpoint.Database" + const val MODEL_TYPE_CAPABILITY_TYPE_ATTACHMENT = "tosca.capabilities.Attachment" + const val MODEL_TYPE_CAPABILITY_TYPE_OPERATION_SYSTEM = "tosca.capabilities.OperatingSystem" + const val MODEL_TYPE_CAPABILITY_TYPE_BINDABLE = "tosca.capabilities.network.Bindable" + // Custom capabilities + const val MODEL_TYPE_CAPABILITY_TYPE_CONTENT = "tosca.capabilities.Content" + const val MODEL_TYPE_CAPABILITY_TYPE_MAPPING = "tosca.capabilities.Mapping" + const val MODEL_TYPE_CAPABILITY_TYPE_NETCONF = "tosca.capabilities.Netconf" + const val MODEL_TYPE_CAPABILITY_TYPE_SSH = "tosca.capabilities.Ssh" + const val MODEL_TYPE_CAPABILITY_TYPE_SFTP = "tosca.capabilities.Sftp" + + const val EXPRESSION_GET_INPUT: String = "get_input" + const val EXPRESSION_GET_ATTRIBUTE: String = "get_attribute" + const val EXPRESSION_GET_ARTIFACT: String = "get_artifact" + const val EXPRESSION_GET_PROPERTY: String = "get_property" + const val EXPRESSION_GET_OPERATION_OUTPUT: String = "get_operation_output" + const val EXPRESSION_GET_NODE_OF_TYPE: String = "get_nodes_of_type" + + const val PROPERTY_BLUEPRINT_PROCESS_ID: String = "blueprint-process-id" + const val PROPERTY_BLUEPRINT_BASE_PATH: String = "blueprint-basePath" + const val PROPERTY_BLUEPRINT_RUNTIME: String = "blueprint-runtime" + const val PROPERTY_BLUEPRINT_INPUTS_DATA: String = "blueprint-inputs-data" + const val PROPERTY_BLUEPRINT_CONTEXT: String = "blueprint-context" + const val PROPERTY_BLUEPRINT_NAME: String = "template_name" + const val PROPERTY_BLUEPRINT_VERSION: String = "template_version" + + const val TOSCA_METADATA_DIR: String = "TOSCA-Metadata" + const val TOSCA_METADATA_ENTRY_DEFINITION_FILE: String = "TOSCA-Metadata/TOSCA.meta" + const val TOSCA_DEFINITIONS_DIR: String = "Definitions" + const val TOSCA_PLANS_DIR: String = "Plans" + const val TOSCA_SCRIPTS_DIR: String = "Scripts" + const val TOSCA_MAPPINGS_DIR: String = "Mappings" + const val TOSCA_TEMPLATES_DIR: String = "Templates" + const val TOSCA_SCRIPTS_KOTLIN_DIR: String = "$TOSCA_SCRIPTS_DIR/kotlin" + + const val METADATA_USER_GROUPS = "user-groups" + const val METADATA_TEMPLATE_NAME = "template_name" + const val METADATA_TEMPLATE_VERSION = "template_version" + const val METADATA_TEMPLATE_AUTHOR = "template_author" + const val METADATA_TEMPLATE_TAGS = "template_tags" + const val METADATA_WORKFLOW_NAME = "workflow_name" + + const val PAYLOAD_DATA = "payload-data" + const val PROPERTY_CURRENT_STEP = "current-step" + const val PROPERTY_CURRENT_NODE_TEMPLATE = "current-node-template" + const val PROPERTY_CURRENT_INTERFACE = "current-interface" + const val PROPERTY_CURRENT_OPERATION = "current-operation" + const val PROPERTY_CURRENT_IMPLEMENTATION = "current-implementation" + const val PROPERTY_EXECUTION_REQUEST = "execution-request" + + const val OPERATION_PROCESS = "process" + const val OPERATION_PREPARE = "prepare" + + const val BLUEPRINT_RETRIEVE_TYPE_DB = "db" + const val BLUEPRINT_RETRIEVE_TYPE_FILE = "file" + const val BLUEPRINT_RETRIEVE_TYPE_REPO = "repo" + +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintError.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintError.kt new file mode 100644 index 000000000..ea5bda42e --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintError.kt @@ -0,0 +1,29 @@ +/* + * 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.core + +class BluePrintError { + var errors: MutableList = arrayListOf() + + fun addError(type: String, name: String, error: String) { + this.errors.add("$type : $name : $error") + } + + fun addError(error: String) { + this.errors.add(error) + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintException.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintException.kt new file mode 100644 index 000000000..5acdf8e43 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintException.kt @@ -0,0 +1,49 @@ +/* + * 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.core +/** + * + * + * @author Brinda Santh + */ +class BluePrintException : Exception { + + var code: Int = 100 + + constructor(cause: Throwable) : super(cause) + constructor(message: String) : super(message) + constructor(message: String, cause: Throwable) : super(message, cause) + constructor(cause: Throwable, message: String, vararg args: Any?) : super(String.format(message, *args), cause) + + constructor(code: Int, cause: Throwable) : super(cause) { + this.code = code + } + + constructor(code: Int, message: String) : super(message) { + this.code = code + } + + constructor(code: Int, message: String, cause: Throwable) : super(message, cause) { + this.code = code + } + + constructor(code: Int, cause: Throwable, message: String, vararg args: Any?) + : super(String.format(message, *args), cause) { + this.code = code + } +} + diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintProcessorException.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintProcessorException.kt new file mode 100644 index 000000000..6ebabb7a9 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintProcessorException.kt @@ -0,0 +1,50 @@ +/* + * 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.core + +/** + * + * + * @author Brinda Santh + */ +class BluePrintProcessorException : RuntimeException { + var code: Int = 100 + + constructor(message: String, cause: Throwable) : super(message, cause) + constructor(message: String) : super(message) + constructor(cause: Throwable) : super(cause) + constructor(cause: Throwable, message: String, vararg args: Any?) : super(format(message, *args), cause) + + constructor(code: Int, cause: Throwable) : super(cause) { + this.code = code + } + + constructor(code: Int, message: String) : super(message) { + this.code = code + } + + constructor(code: Int, message: String, cause: Throwable) : super(message, cause) { + this.code = code + } + + constructor(code: Int, cause: Throwable, message: String, vararg args: Any?) + : super(String.format(message, *args), cause) { + this.code = code + } +} + diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt new file mode 100644 index 000000000..4509cccf3 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt @@ -0,0 +1,164 @@ +/* + * 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.core + +import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition + +/** + * + * + * @author Brinda Santh + */ +object BluePrintTypes { + + @JvmStatic + val validNodeTypeDerivedFroms: MutableList = arrayListOf( + BluePrintConstants.MODEL_TYPE_NODES_ROOT, + BluePrintConstants.MODEL_TYPE_NODE_DG, + BluePrintConstants.MODEL_TYPE_NODE_COMPONENT, + BluePrintConstants.MODEL_TYPE_NODE_VNF, + BluePrintConstants.MODEL_TYPE_NODE_ARTIFACT, + BluePrintConstants.MODEL_TYPE_NODE_RESOURCE_SOURCE, + BluePrintConstants.MODEL_TYPE_NODES_COMPONENT_JAVA, + BluePrintConstants.MODEL_TYPE_NODES_COMPONENT_BUNDLE, + BluePrintConstants.MODEL_TYPE_NODES_COMPONENT_SCRIPT, + BluePrintConstants.MODEL_TYPE_NODES_COMPONENT_PYTHON, + BluePrintConstants.MODEL_TYPE_NODES_COMPONENT_JYTHON, + BluePrintConstants.MODEL_TYPE_NODES_COMPONENT_JAVA_SCRIPT + ) + + @JvmStatic + val validArtifactTypeDerivedFroms: MutableList = arrayListOf( + BluePrintConstants.MODEL_TYPE_ARTIFACTS_ROOT, + BluePrintConstants.MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION + ) + + @JvmStatic + val validDataTypeDerivedFroms: MutableList = arrayListOf( + BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT, + BluePrintConstants.MODEL_TYPE_DATA_TYPE_DYNAMIC + ) + + @Deprecated("This has to move to Relationship Types Model Drive") + @JvmStatic + val validRelationShipDerivedFroms: MutableList = arrayListOf( + BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_ROOT, + BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_DEPENDS_ON, + BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_HOSTED_ON, + BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO, + BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_ATTACH_TO, + BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_ROUTES_TO + ) + + @Deprecated("This has to move to Capability Types Model Drive") + @JvmStatic + val validCapabilityTypes: MutableList = arrayListOf( + BluePrintConstants.MODEL_TYPE_CAPABILITIES_ROOT, + BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_NODE, + BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_COMPUTE, + BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_NETWORK, + BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_STORAGE, + BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT, + BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_PUBLIC, + BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_ADMIN, + BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_DATABASE, + BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_ATTACHMENT, + BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_OPERATION_SYSTEM, + BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_BINDABLE, + BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_CONTENT, + BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_MAPPING, + BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_NETCONF, + BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_SSH, + BluePrintConstants.MODEL_TYPE_CAPABILITY_TYPE_SFTP + ) + + @JvmStatic + fun validModelTypes(): List { + val validTypes: MutableList = arrayListOf() + validTypes.add(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE) + validTypes.add(BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE) + validTypes.add(BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE) + validTypes.add(BluePrintConstants.MODEL_DEFINITION_TYPE_CAPABILITY_TYPE) + validTypes.add(BluePrintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE) + return validTypes + } + + @JvmStatic + fun validPropertyTypes(): List { + val validTypes: MutableList = arrayListOf() + validTypes.add(BluePrintConstants.DATA_TYPE_STRING) + validTypes.add(BluePrintConstants.DATA_TYPE_INTEGER) + validTypes.add(BluePrintConstants.DATA_TYPE_FLOAT) + validTypes.add(BluePrintConstants.DATA_TYPE_DOUBLE) + validTypes.add(BluePrintConstants.DATA_TYPE_BOOLEAN) + validTypes.add(BluePrintConstants.DATA_TYPE_TIMESTAMP) + validTypes.add(BluePrintConstants.DATA_TYPE_NULL) + validTypes.add(BluePrintConstants.DATA_TYPE_LIST) + validTypes.add(BluePrintConstants.DATA_TYPE_MAP) + return validTypes + } + + @JvmStatic + fun validPrimitiveTypes(): List { + val validTypes: MutableList = arrayListOf() + validTypes.add(BluePrintConstants.DATA_TYPE_STRING) + validTypes.add(BluePrintConstants.DATA_TYPE_INTEGER) + validTypes.add(BluePrintConstants.DATA_TYPE_FLOAT) + validTypes.add(BluePrintConstants.DATA_TYPE_DOUBLE) + validTypes.add(BluePrintConstants.DATA_TYPE_BOOLEAN) + validTypes.add(BluePrintConstants.DATA_TYPE_TIMESTAMP) + validTypes.add(BluePrintConstants.DATA_TYPE_NULL) + return validTypes + } + + @JvmStatic + fun validCollectionTypes(): List { + val validTypes: MutableList = arrayListOf() + validTypes.add(BluePrintConstants.DATA_TYPE_LIST) + validTypes.add(BluePrintConstants.DATA_TYPE_MAP) + return validTypes + } + + @JvmStatic + fun validPrimitiveOrCollectionPrimitive(propertyDefinition: PropertyDefinition): Boolean { + val entrySchema = propertyDefinition.entrySchema?.type ?: BluePrintConstants.DATA_TYPE_NULL + return BluePrintTypes.validPropertyTypes().contains(propertyDefinition.type) + && BluePrintTypes.validPrimitiveTypes().contains(entrySchema) + } + + @JvmStatic + fun validCommands(): List { + return listOf(BluePrintConstants.EXPRESSION_GET_INPUT, + BluePrintConstants.EXPRESSION_GET_ATTRIBUTE, + BluePrintConstants.EXPRESSION_GET_PROPERTY, + BluePrintConstants.EXPRESSION_GET_ARTIFACT, + BluePrintConstants.EXPRESSION_GET_OPERATION_OUTPUT, + BluePrintConstants.EXPRESSION_GET_NODE_OF_TYPE) + } + + @JvmStatic + fun rootNodeTypes(): List { + return listOf(BluePrintConstants.MODEL_TYPE_NODES_ROOT) + } + + @JvmStatic + fun rootDataTypes(): List { + return listOf(BluePrintConstants.MODEL_TYPE_DATATYPES_ROOT) + } + + +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/ConfigModelConstant.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/ConfigModelConstant.kt new file mode 100644 index 000000000..68858dc58 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/ConfigModelConstant.kt @@ -0,0 +1,30 @@ +/* + * 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.core + +/** + * + * + * @author Brinda Santh + */ +object ConfigModelConstant { + + const val MODEL_CONTENT_TYPE_TOSCA_JSON = "TOSCA_JSON" + const val MODEL_CONTENT_TYPE_TEMPLATE = "TEMPLATE" + const val CAPABILITY_PROPERTY_MAPPING = "mapping" +} diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctions.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctions.kt new file mode 100644 index 000000000..0b9c142b8 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctions.kt @@ -0,0 +1,151 @@ +/* + * 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.core + +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.node.BooleanNode +import com.fasterxml.jackson.databind.node.DoubleNode +import com.fasterxml.jackson.databind.node.IntNode +import com.fasterxml.jackson.databind.node.TextNode +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils +import org.slf4j.helpers.MessageFormatter +import java.io.File +import java.io.InputStream +import kotlin.reflect.KClass + +/** + * + * + * @author Brinda Santh + */ + +fun String.asJsonPrimitive(): TextNode { + return TextNode(this) +} + +fun Boolean.asJsonPrimitive(): BooleanNode { + return BooleanNode.valueOf(this) +} + +fun Int.asJsonPrimitive(): IntNode { + return IntNode.valueOf(this) +} + +fun Double.asJsonPrimitive(): DoubleNode { + return DoubleNode.valueOf(this) +} + +fun MutableMap.asJsonNode(): JsonNode { + return JacksonUtils.jsonNodeFromObject(this) +} + +fun format(message: String, vararg args: Any?): String { + if (args != null && args.isNotEmpty()) { + return MessageFormatter.arrayFormat(message, args).message + } + return message +} + +fun MutableMap.castOptionalValue(key: String, valueType: KClass): T? { + if (containsKey(key)) { + return get(key) as? T + } else { + return null + } +} + +fun MutableMap.castValue(key: String, valueType: KClass): T { + if (containsKey(key)) { + return get(key) as T + } else { + throw BluePrintException("couldn't find the key $key") + } +} + +fun MutableMap.putJsonElement(key: String, value: Any) { + when (value) { + is JsonNode -> + this[key] = value + is String -> + this[key] = TextNode(value) + is Boolean -> + this[key] = BooleanNode.valueOf(value) + is Int -> + this[key] = IntNode.valueOf(value.toInt()) + is Double -> + this[key] = DoubleNode.valueOf(value.toDouble()) + else -> + this[key] = JacksonUtils.jsonNodeFromObject(value) + } +} + +fun MutableMap.getAsString(key: String): String { + return this[key]?.asText() ?: throw BluePrintException("couldn't find value for key($key)") +} + +fun MutableMap.getAsBoolean(key: String): Boolean { + return this[key]?.asBoolean() ?: throw BluePrintException("couldn't find value for key($key)") +} + +fun MutableMap.getAsInt(key: String): Int { + return this[key]?.asInt() ?: throw BluePrintException("couldn't find value for key($key)") +} + +fun MutableMap.getAsDouble(key: String): Double { + return this[key]?.asDouble() ?: throw BluePrintException("couldn't find value for key($key)") +} + +// Checks + +fun checkNotEmpty(value: String?): Boolean { + return value != null && value.isNotBlank() +} + +fun checkNotEmptyOrThrow(value: String?, message: String? = value.plus(" is null/empty ")): Boolean { + val notEmpty = checkNotEmpty(value) + if (!notEmpty) { + throw BluePrintException(message!!) + } + return notEmpty +} + +fun checkEqualsOrThrow(value1: String?, value2: String?, lazyMessage: () -> Any): Boolean { + if (value1.equals(value2, ignoreCase = true)) { + return true + } else { + throw BluePrintException(lazyMessage().toString()) + } +} + +fun nullToEmpty(value: String?): String { + return if (checkNotEmpty(value)) value!! else "" +} + +fun returnNotEmptyOrThrow(value: String?, lazyMessage: () -> Any): String { + if (checkNotEmpty(value)) { + return value!! + } else { + throw IllegalStateException(lazyMessage().toString()) + } +} + +fun InputStream.toFile(path: String): File { + val file = File(path) + file.outputStream().use { this.copyTo(it) } + return file +} + diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/common/ApplicationConstants.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/common/ApplicationConstants.kt new file mode 100644 index 000000000..994ea5b7b --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/common/ApplicationConstants.kt @@ -0,0 +1,23 @@ +/* + * 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. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.common + +object ApplicationConstants { + const val ACTIVE_Y = "Y" + const val ACTIVE_N = "N" + const val ASDC_ARTIFACT_TYPE_SDNC_MODEL = "SDNC_MODEL" +} diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/config/BluePrintLoadConfiguration.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/config/BluePrintLoadConfiguration.kt new file mode 100644 index 000000000..235cfd56b --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/config/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.core.config + +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/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintExpressionData.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintExpressionData.kt new file mode 100644 index 000000000..96f549db8 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintExpressionData.kt @@ -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.core.data + +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.node.ObjectNode +/** + * + * + * @author Brinda Santh + */ +data class ExpressionData( + var isExpression: Boolean = false, + var valueNode: JsonNode, + var expressionNode: ObjectNode? = null, + var inputExpression: InputExpression? = null, + var propertyExpression: PropertyExpression? = null, + var attributeExpression: AttributeExpression? = null, + var artifactExpression: ArtifactExpression? = null, + var operationOutputExpression: OperationOutputExpression? = null, + var command: String? = null +) + +data class InputExpression( + var propertyName: String +) + +data class PropertyExpression( + var modelableEntityName: String = "SELF", + var reqOrCapEntityName: String? = null, + var propertyName: String, + var subPropertyName: String? = null +) + +data class AttributeExpression( + var modelableEntityName: String = "SELF", + var reqOrCapEntityName: String? = null, + var attributeName: String, + var subAttributeName: String? = null +) + +data class ArtifactExpression( + val modelableEntityName: String = "SELF", + val artifactName: String, + val location: String? = "LOCAL_FILE", + val remove: Boolean? = false +) + +data class OperationOutputExpression( + val modelableEntityName: String = "SELF", + val interfaceName: String, + val operationName: String, + val propertyName: String +) + + diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt new file mode 100644 index 000000000..c4376d5e4 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt @@ -0,0 +1,622 @@ +/* + * 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.core.data + +import com.fasterxml.jackson.annotation.JsonIgnore +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonPropertyOrder +import com.fasterxml.jackson.databind.JsonNode +import io.swagger.annotations.ApiModelProperty + +/** + * + * + * @author Brinda Santh + */ +open class EntityType { + @get:JsonIgnore + var id: String? = null + var description: String? = null + var version: String = "1.0.0" + var metadata: MutableMap? = null + @get:JsonProperty("derived_from") + lateinit var derivedFrom: String + var attributes: MutableMap? = null + var properties: MutableMap? = null +} + +/* + 5.3.2 tosca.datatypes.Credential + The Credential type is a complex TOSCA data Type used when describing + authorization credentials used to access network accessible resources. + */ +class Credential { + @get:JsonIgnore + var id: String? = null + var protocol: String? = null + @get:JsonProperty("token_type") + lateinit var tokenType: String + lateinit var token: String + var keys: MutableMap? = null + lateinit var user: String +} + +/* +3.5.2 Constraint clause +A constraint clause defines an operation along with one or more compatible values that can be used to define a constraint on a property or parameter’s allowed values when it is defined in a TOSCA Service Template or one of its entities. + */ +class ConstraintClause { + @get:JsonProperty("equal") + var equal: JsonNode? = null + @get:JsonProperty("greater_than") + var greaterThan: Any? = null + @get:JsonProperty("greater_or_equal") + var greaterOrEqual: Any? = null + @get:JsonProperty("less_than") + var lessThan: Any? = null + @get:JsonProperty("less_or_equal") + var lessOrEqual: Any? = null + @get:JsonProperty("in_range") + var inRange: Any? = null + @get:JsonProperty("valid_values") + var validValues: MutableList? = null + @get:JsonProperty("length") + var length: Any? = null + @get:JsonProperty("min_length") + var minLength: Any? = null + @get:JsonProperty("max_length") + var maxLength: Any? = null + var pattern: String? = null + var schema: String? = null +} + +/* +3.5.4 Node Filter definition +A node filter definition defines criteria for selection of a TOSCA Node Template based upon the template’s property values, capabilities and capability properties. + */ + +class NodeFilterDefinition { + var properties: MutableMap? = null + var capabilities: MutableList? = null +} + +/* +3.5.5 Repository definition + A repository definition defines a named external repository which contains deployment + and implementation artifacts that are referenced within the TOSCA Service Template. +*/ +class RepositoryDefinition { + @get:JsonIgnore + var id: String? = null + var description: String? = null + lateinit var url: String + var credential: Credential? = null +} + + +/* +3.5.6 Artifact definition +An artifact definition defines a named, typed file that can be associated with Node Type +or Node Template and used by orchestration engine to facilitate deployment and implementation of interface operations. + */ +class ArtifactDefinition { + @get:JsonIgnore + var id: String? = null + var type: String? = null + var file: String? = null + var repository: String? = null + var description: String? = null + @get:JsonProperty("deploy_Path") + var deployPath: String? = null + var properties: MutableMap? = null + var content: String? = null + @Deprecated("Mapping content is define by the Type") + var mappingContent: String? = null +} + + +/* +3.5.7 Import definition +An import definition is used within a TOSCA Service Template to locate and uniquely name +another TOSCA Service Template file which has type and template definitions to be imported (included) +and referenced within another Service Template. + */ +class ImportDefinition { + @get:JsonIgnore + var id: String? = null + lateinit var file: String + var repository: String? = null + @get:JsonProperty("namespace_uri") + var namespaceUri: String? = null + @get:JsonProperty("namespace_prefix") + var namespacePrefix: String? = null +} + +/* +3.5.8 Property definition A property definition defines a named, typed value and related data that can be associated with an +entity defined in this specification (e.g., Node Types, Relationship Types, Capability Types, etc.). +Properties are used by template authors to provide input values to TOSCA entities which indicate their “desired state” when they are +instantiated. The value of a property can be retrieved using the get_property function within TOSCA Service Templates. + */ +class PropertyDefinition { + @get:JsonIgnore + var id: String? = null + var description: String? = null + var required: Boolean? = null + lateinit var type: String + @get:JsonProperty("default") + var defaultValue: JsonNode? = null + var status: String? = null + var constraints: MutableList? = null + @get:JsonProperty("entry_schema") + var entrySchema: EntrySchema? = null + @get:ApiModelProperty(notes = "Property Value, It may be raw JSON or primitive data type values") + var value: JsonNode? = null +} + + +/* +3.5.10 Attribute definition + +An attribute definition defines a named, typed value that can be associated with an entity defined in this +specification (e.g., a Node, Relationship or Capability Type). Specifically, it is used to expose the +“actual state” of some property of a TOSCA entity after it has been deployed and instantiated +(as set by the TOSCA orchestrator). Attribute values can be retrieved via the get_attribute function +from the instance model and used as values to other entities within TOSCA Service Templates. + */ + +class AttributeDefinition { + @get:JsonIgnore + var id: String? = null + var description: String? = null + var required: Boolean? = null + lateinit var type: String + @JsonProperty("default") + var defaultValue: JsonNode? = null + var status: String? = null + var constraints: MutableList? = null + @JsonProperty("entry_schema") + var entrySchema: EntrySchema? = null +} + +/* +3.5.13 Operation definition +An operation definition defines a named function or procedure that can be bound to an implementation artifact (e.g., a script). + */ +class OperationDefinition { + @get:JsonIgnore + var id: String? = null + var description: String? = null + var implementation: Implementation? = null + var inputs: MutableMap? = null + var outputs: MutableMap? = null +} + +class Implementation { + lateinit var primary: String + var dependencies: MutableList? = null +} + +/* +3.5.14 Interface definition +An interface definition defines a named interface that can be associated with a Node or Relationship Type + */ +class InterfaceDefinition { + @get:JsonIgnore + var id: String? = null + var type: String? = null + var operations: MutableMap? = null + var inputs: MutableMap? = null +} + +/* +3.5.15 Event Filter definition +An event filter definition defines criteria for selection of an attribute, for the purpose of monitoring it, within a TOSCA entity, or one its capabilities. + */ +class EventFilterDefinition { + @get:JsonIgnore + var id: String? = null + lateinit var node: String + var requirement: String? = null + var capability: String? = null +} + +/* +3.5.16 Trigger definition TODO +A trigger definition defines the event, condition and action that is used to “trigger” a policy it is associated with. + */ +class TriggerDefinition { + @get:JsonIgnore + var id: String? = null + 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 +} + +/* + 3.5.17 Workflow activity definition + A workflow activity defines an operation to be performed in a TOSCA workflow. Activities allows to: + · Delegate the workflow for a node expected to be provided by the orchestrator + · Set the state of a node + · Call an operation defined on a TOSCA interface of a node, relationship or group + · Inline another workflow defined in the topology (to allow reusability) + */ +class Activity { + var delegate: String? = null + @get:JsonProperty("set_state") + var setState: String? = null + @get:JsonProperty("call_operation") + var callOperation: String? = null + var inlines: ArrayList? = null +} + +/* +3.5.20 Workflow precondition definition +A workflow condition can be used as a filter or precondition to check if a workflow can be processed or not based on the state of the instances of a TOSCA topology deployment. When not met, the workflow will not be triggered. + */ +class PreConditionDefinition { + @get:JsonIgnore + var id: String? = null + lateinit var target: String + @get:JsonProperty("target_relationship") + lateinit var targetRelationship: String + lateinit var condition: ArrayList +} + +/* +3.5.21 Workflow step definition +A workflow step allows to define one or multiple sequenced activities in a workflow and how they are connected to other steps in the workflow. They are the building blocks of a declarative workflow. + */ +class Step { + @get:JsonIgnore + var id: String? = null + var description: String? = null + var target: String? = null + @JsonProperty("target_relationship") + var targetRelationship: String? = null + @JsonProperty("operation_host") + var operationHost: String? = null + var activities: ArrayList? = null + @get:JsonProperty("on_success") + var onSuccess: ArrayList? = null + @get:JsonProperty("on_failure") + var onFailure: ArrayList? = null +} + +/* +3.6.2 Capability definition +A capability definition defines a named, typed set of data that can be associated with Node Type or Node Template to describe a transparent capability or feature of the software component the node describes. + */ + +class CapabilityDefinition { + @get:JsonIgnore + var id: String? = null + lateinit var type: String + var description: String? = null + var properties: MutableMap? = null + @get:JsonProperty("valid_source_types") + var validSourceTypes: MutableList? = null + var occurrences: MutableList? = null +} + +/* +3.6.3 Requirement definition +The Requirement definition describes a named requirement (dependencies) of a TOSCA Node Type or Node template which needs to be fulfilled by a matching Capability definition declared by another TOSCA modelable entity. The requirement definition may itself include the specific name of the fulfilling entity (explicitly) or provide an abstract type, along with additional filtering characteristics, that a TOSCA orchestrator can use to fulfill the capability at runtime (implicitly). + */ +class RequirementDefinition { + @get:JsonIgnore + var id: String? = null + var description: String? = null + var capability: String? = null + var node: String? = null + var relationship: String? = null + var occurrences: MutableList? = null +} + +/* +3.6.4 Artifact Type +An Artifact Type is a reusable entity that defines the type of one or more files that are used to define implementation or deployment artifacts that are referenced by nodes or relationships on their operations. + */ +class ArtifactType : EntityType() { + @get:JsonProperty("mime_type") + var mimeType: String? = null + @get:JsonProperty("file_ext") + var fileExt: MutableList? = null + +} + +/* +3.6.6 Data Type +A Data Type definition defines the schema for new named datatypes in TOSCA. + */ + +class DataType : EntityType() { + var constraints: MutableList? = null +} + +/* +3.6.9 Node Type +A Node Type is a reusable entity that defines the type of one or more Node Templates. As such, a Node Type defines the structure of observable properties via a Properties Definition, the Requirements and Capabilities of the node as well as its supported interfaces. + + */ + +class NodeType : EntityType() { + var capabilities: MutableMap? = null + var requirements: MutableMap? = null + var interfaces: MutableMap? = null + var artifacts: MutableMap? = null +} + +/* +3.6.8 Requirement Type +A Requirement Type is a reusable entity that describes a kind of requirement that a Node Type can declare to expose. The TOSCA Simple Profile seeks to simplify the need for declaring specific Requirement Types from nodes and instead rely upon nodes declaring their features sets using TOSCA Capability Types along with a named Feature notation. + */ + +class RequirementType : EntityType() { + var requirements: MutableMap? = null + var capabilities: MutableMap? = null + var interfaces: MutableMap? = null + var artifacts: MutableMap? = null +} + +/* +3.6.10 Relationship Type +A Relationship Type is a reusable entity that defines the type of one or more relationships between Node Types or Node Templates. +*/ + +class RelationshipType : EntityType() { + var interfaces: MutableMap? = null + @get:JsonProperty("valid_target_types") + var validTargetTypes: ArrayList? = null +} + +/* +3.6.11 Group Type +A Group Type defines logical grouping types for nodes, typically for different management purposes. +Groups can effectively be viewed as logical nodes that are not part of the physical deployment topology + of an application, yet can have capabilities and the ability to attach policies and interfaces + that can be applied (depending on the group type) to its member nodes. + */ + +class GroupType : EntityType() { + var members: MutableList? = null + var requirements: ArrayList? = null + var capabilities: MutableMap? = null + var interfaces: MutableMap? = null + +} + +/* + 3.6.12 Policy Type + A Policy Type defines a type of requirement that affects or governs an application or service’s + topology at some stage of its lifecycle, but is not explicitly part of the topology itself + (i.e., it does not prevent the application or service from being deployed or run if it did not exist). + */ +class PolicyType : EntityType() { + lateinit var targets: MutableList +} + +/* +3.7.1 Capability assignment +A capability assignment allows node template authors to assign values to properties and attributes for a named capability definition that is part of a Node Template’s type definition. + */ +class CapabilityAssignment { + @get:JsonIgnore + var id: String? = null + var attributes: MutableMap? = null + var properties: MutableMap? = null +} + +/* +3.7.4 Relationship Template +A Relationship Template specifies the occurrence of a manageable relationship between node templates as part of an application’s topology model that is defined in a TOSCA Service Template. A Relationship template is an instance of a specified Relationship Type and can provide customized properties, constraints or operations which override the defaults provided by its Relationship Type and its implementations. + */ +class GroupDefinition { + @get:JsonIgnore + var id: String? = null + lateinit var type: String + var description: String? = null + var metadata: MutableMap? = null + var properties: MutableMap? = null + var members = ArrayList() + var interfaces: MutableMap? = null +} + +/* +3.7.6 Policy definition +A policy definition defines a policy that can be associated with a TOSCA topology or top-level entity definition (e.g., group definition, node template, etc.). + */ +class PolicyDefinition { + @get:JsonIgnore + var id: String? = null + lateinit var type: String + var description: String? = null + var metadata: MutableMap? = null + var properties: MutableMap? = null + var targets: MutableList? = null +} + + +/* +3.8 Topology Template definition +This section defines the topology template of a cloud application. The main ingredients of the topology template are node templates representing components of the application and relationship templates representing links between the components. These elements are defined in the nested node_templates section and the nested relationship_templates sections, respectively. Furthermore, a topology template allows for defining input parameters, output parameters as well as grouping of node templates. + */ +class TopologyTemplate { + @get:JsonIgnore + var id: String? = null + var description: String? = null + var inputs: MutableMap? = null + @get:JsonProperty("node_templates") + var nodeTemplates: MutableMap? = null + @get:JsonProperty("relationship_templates") + var relationshipTemplates: MutableMap? = null + var policies: MutableMap? = null + var outputs: MutableMap? = null + @get:JsonProperty("substitution_mappings") + var substitutionMappings: Any? = null + var workflows: MutableMap? = null +} + +class SubstitutionMapping { + @get:JsonProperty("node_type") + lateinit var nodeType: String + lateinit var capabilities: ArrayList + lateinit var requirements: ArrayList +} + +class EntrySchema { + lateinit var type: String + var constraints: MutableList? = null +} + +class InterfaceAssignment { + @get:JsonIgnore + var id: String? = null + var operations: MutableMap? = null + var inputs: MutableMap? = null +} + +/* +3.7.3 Node Template +A Node Template specifies the occurrence of a manageable software component as part of an application’s topology model which is defined in a TOSCA Service Template. A Node template is an instance of a specified Node Type and can provide customized properties, constraints or operations which override the defaults provided by its Node Type and its implementations. + */ + +open class NodeTemplate { + @get:JsonIgnore + var id: String? = null + var description: String? = null + lateinit var type: String + var metadata: MutableMap? = null + var directives: MutableList? = null + //@get:JsonSerialize(using = PropertyDefinitionValueSerializer::class) + var properties: MutableMap? = null + var attributes: MutableMap? = null + var capabilities: MutableMap? = null + var requirements: MutableMap? = null + var interfaces: MutableMap? = null + var artifacts: MutableMap? = null + @get:JsonProperty("node_filter") + var nodeFilter: NodeFilterDefinition? = null + var copy: String? = null +} + +class OperationAssignment { + @get:JsonIgnore + var id: String? = null + var description: String? = null + var implementation: Implementation? = null + var inputs: MutableMap? = null + var outputs: MutableMap? = null +} + +/* +3.7.4 Relationship Template +A Relationship Template specifies the occurrence of a manageable relationship between node templates as part of an application’s topology model that is defined in a TOSCA Service Template. A Relationship template is an instance of a specified Relationship Type and can provide customized properties, constraints or operations which override the defaults provided by its Relationship Type and its implementations. + */ + +class RelationshipTemplate { + var type: String? = null + var description: String? = null + var metadata: MutableMap? = null + var properties: MutableMap? = null + var attributes: MutableMap? = null + var interfaces: MutableMap? = null + var copy: String? = null +} + +/* +3.7.2 Requirement assignment +A Requirement assignment allows template authors to provide either concrete names of TOSCA templates or provide abstract selection criteria for providers to use to find matching TOSCA templates that are used to fulfill a named requirement’s declared TOSCA Node Type. + */ + +class RequirementAssignment { + @get:JsonIgnore + var id: String? = null + var capability: String? = null + var node: String? = null + //Relationship Type or Relationship Template + var relationship: String? = null +} + + +class Workflow { + @get:JsonIgnore + var id: String? = null + var description: String? = null + var steps: MutableMap? = null + var preconditions: ArrayList? = null + var inputs: MutableMap? = null +} + + +class ConditionClause { + var and: ArrayList>? = null + var or: ArrayList>? = null + @get:JsonProperty("assert") + var assertConditions: ArrayList>? = null +} + +/* +3.9 Service Template definition +A TOSCA Service Template (YAML) document contains element definitions of building blocks for cloud application, or complete models of cloud applications. This section describes the top-level structural elements (TOSCA keynames) along with their grammars, which are allowed to appear in a TOSCA Service Template document. + */ + +@JsonPropertyOrder(value = ["toscaDefinitionsVersion", "description", "metadata", "imports", "topologyTemplate"]) +class ServiceTemplate : Cloneable { + @get:JsonIgnore + var id: String? = null + @get:JsonProperty("tosca_definitions_version") + var toscaDefinitionsVersion: String = "controller_blueprint_1_0_0" + var metadata: MutableMap? = null + var description: String? = null + @get:JsonProperty("dsl_definitions") + var dslDefinitions: MutableMap? = null + var repositories: MutableMap? = null + var imports: MutableList? = null + @get:JsonProperty("artifact_types") + var artifactTypes: MutableMap? = null + @get:JsonProperty("data_types") + var dataTypes: MutableMap? = null + @get:JsonProperty("relationship_types") + var relationshipTypes: MutableMap? = null + @get:JsonProperty("node_types") + var nodeTypes: MutableMap? = null + @get:JsonProperty("policy_types") + var policyTypes: MutableMap? = null + @get:JsonProperty("topology_template") + var topologyTemplate: TopologyTemplate? = null + + override public fun clone(): ServiceTemplate { + return super.clone() as ServiceTemplate + } +} + +class ToscaMetaData { + lateinit var toscaMetaFileVersion: String + lateinit var csarVersion: String + lateinit var createdBy: String + lateinit var entityDefinitions: String + var templateTags: String? = null +} + diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BlueprintErrorCode.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BlueprintErrorCode.kt new file mode 100644 index 000000000..bef174b9d --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BlueprintErrorCode.kt @@ -0,0 +1,97 @@ +/* + * Copyright © 2018-2019 Bell Canada 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.core.data + +import java.util.HashMap + +/** + * ErrorCode.java Purpose: Maintain a list of HTTP status codes + * + * @author Steve Siani + * @version 1.0 + */ +enum class ErrorCode (val value: Int, val httpCode: Int) { + + /// TODO: Add more attribute for each needed application protocol + // TODO: Example: INVALID_FILE_EXTENSION(2, 415, 25) + GENERIC_FAILURE(1, 500) { + override fun message(detailMsg: String): String { + return "Generic failure. Details : {$detailMsg}" + } + }, + INVALID_FILE_EXTENSION(2, 415) { + override fun message(detailMsg: String): String { + return "Unexpected file extension. Details : {$detailMsg}" + } + }, + BLUEPRINT_PATH_MISSING(3, 503) { + override fun message(detailMsg: String): String { + return "Blueprint path missing or wrong. Details : {$detailMsg}" + } + }, + BLUEPRINT_WRITING_FAIL(4, 503) { + override fun message(detailMsg: String): String { + return "Fail to write blueprint files. Details : {$detailMsg}" + } + }, + IO_FILE_INTERRUPT(5, 503) { + override fun message(detailMsg: String): String { + return "IO file system interruption. Details : {$detailMsg}" + } + }, + INVALID_REQUEST_FORMAT(6, 400) { + override fun message(detailMsg: String): String { + return "Bad request. Details : {$detailMsg}" + } + }, + UNAUTHORIZED_REQUEST(7, 401) { + override fun message(detailMsg: String): String { + return "The request requires user authentication. Details : {$detailMsg}" + } + }, + REQUEST_NOT_FOUND(8, 404) { + override fun message(detailMsg: String): String { + return "Request mapping doesn't exist. Details : {$detailMsg}" + } + }, + RESOURCE_NOT_FOUND(9, 404) { + override fun message(detailMsg: String): String { + return "No response was found for this request in the server. Details : {$detailMsg}" + } + }, + CONFLICT_ADDING_RESOURCE(10, 409) { + override fun message(detailMsg: String): String { + return "Duplicated entry while saving Blueprint. Details : {$detailMsg}" + } + }; + + abstract fun message(detailMsg: String): String + + companion object { + + private val map = HashMap() + + init { + for (errorCode in ErrorCode.values()) { + map[errorCode.value] = errorCode + } + } + + fun valueOf(value: Int): ErrorCode? { + return if (map.containsKey(value)) map[value] else map[1] + } + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/factory/BluePrintValidatorFactory.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/factory/BluePrintValidatorFactory.kt new file mode 100644 index 000000000..687b86cde --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/factory/BluePrintValidatorFactory.kt @@ -0,0 +1,45 @@ +/* + * 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.core.factory + + +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintValidatorDefaultService +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintValidatorService + +/** + * + * + * @author Brinda Santh + */ + +object BluePrintValidatorFactory { + + var bluePrintValidatorServices: MutableMap = HashMap() + + init { + bluePrintValidatorServices[org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.TYPE_DEFAULT] = BluePrintValidatorDefaultService() + } + + fun register(key:String, bluePrintValidatorService: BluePrintValidatorService){ + bluePrintValidatorServices[key] = bluePrintValidatorService + } + + fun instance(key : String) : BluePrintValidatorService?{ + return bluePrintValidatorServices[key] + } + +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintCatalogService.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintCatalogService.kt new file mode 100755 index 000000000..c99cdf749 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintCatalogService.kt @@ -0,0 +1,59 @@ +/* + * 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.core.interfaces + +import org.jetbrains.annotations.NotNull +import org.jetbrains.annotations.Nullable +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import java.io.File +import java.nio.file.Path + +interface BluePrintCatalogService { + + /** + * Save the CBA to database. + * @param blueprintFile Either a directory, or an archive + * @param validate whether to validate blueprint content. Default true. + * @return The unique blueprint identifier + * @throws BluePrintException if process failed + */ + @NotNull + @Throws(BluePrintException::class) + fun saveToDatabase(@NotNull blueprintFile: File, @Nullable validate: Boolean = true): String + + /** + * Retrieve the CBA from database either archived or extracted. + * @param name Name of the blueprint + * @param version Version of the blueprint + * @param extract true to extract the content, false for archived content. Default to true + * @return Path where CBA is located + * @throws BluePrintException if process failed + */ + @NotNull + @Throws(BluePrintException::class) + fun getFromDatabase(@NotNull name: String, @NotNull version: String, @Nullable extract: Boolean = true): Path + + /** + * Delete the CBA from database. + * @param name Name of the blueprint + * @param version Version of the blueprint + * @throws BluePrintException if process failed + */ + @NotNull + @Throws(BluePrintException::class) + fun deleteFromDatabase(@NotNull name: String, @NotNull version: String) +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintEnhancer.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintEnhancer.kt new file mode 100644 index 000000000..f01f12620 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintEnhancer.kt @@ -0,0 +1,141 @@ +/* + * 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.core.interfaces + +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.core.data.* +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService + +interface BluePrintEnhancer { + fun enhance(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, type: T) +} + +interface BluePrintServiceTemplateEnhancer : BluePrintEnhancer + +interface BluePrintTopologyTemplateEnhancer : BluePrintEnhancer + +interface BluePrintWorkflowEnhancer : BluePrintEnhancer + +interface BluePrintNodeTemplateEnhancer : BluePrintEnhancer + +interface BluePrintNodeTypeEnhancer : BluePrintEnhancer + +interface BluePrintArtifactDefinitionEnhancer : BluePrintEnhancer + +interface BluePrintPolicyTypeEnhancer : BluePrintEnhancer + +interface BluePrintPropertyDefinitionEnhancer : BluePrintEnhancer + +interface BluePrintAttributeDefinitionEnhancer : BluePrintEnhancer + + +interface BluePrintEnhancerService { + + @Throws(BluePrintException::class) + fun enhance(basePath: String, enrichedBasePath: String): BluePrintContext + + @Throws(BluePrintException::class) + fun enhance(basePath: String): BluePrintContext +} + +interface BluePrintTypeEnhancerService { + + fun getServiceTemplateEnhancers(): List + + fun getTopologyTemplateEnhancers(): List + + fun getWorkflowEnhancers(): List + + fun getNodeTemplateEnhancers(): List + + fun getNodeTypeEnhancers(): List + + fun getArtifactDefinitionEnhancers(): List + + fun getPolicyTypeEnhancers(): List + + fun getPropertyDefinitionEnhancers(): List + + fun getAttributeDefinitionEnhancers(): List + + fun enhanceServiceTemplate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, serviceTemplate: ServiceTemplate) { + val enhancers = getServiceTemplateEnhancers() + doEnhancement(bluePrintRuntimeService, name, serviceTemplate, enhancers) + } + + fun enhanceTopologyTemplate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, topologyTemplate: TopologyTemplate) { + val enhancers = getTopologyTemplateEnhancers() + doEnhancement(bluePrintRuntimeService, name, topologyTemplate, enhancers) + } + + fun enhanceWorkflow(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, workflow: Workflow) { + val enhancers = getWorkflowEnhancers() + doEnhancement(bluePrintRuntimeService, name, workflow, enhancers) + } + + fun enhanceNodeTemplate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, nodeTemplate: NodeTemplate) { + val enhancers = getNodeTemplateEnhancers() + doEnhancement(bluePrintRuntimeService, name, nodeTemplate, enhancers) + } + + fun enhanceNodeType(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, nodeType: NodeType) { + val enhancers = getNodeTypeEnhancers() + doEnhancement(bluePrintRuntimeService, name, nodeType, enhancers) + } + + fun enhanceArtifactDefinition(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, artifactDefinition: ArtifactDefinition) { + val enhancers = getArtifactDefinitionEnhancers() + doEnhancement(bluePrintRuntimeService, name, artifactDefinition, enhancers) + } + + fun enhancePolicyType(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, policyType: PolicyType) { + val enhancers = getPolicyTypeEnhancers() + doEnhancement(bluePrintRuntimeService, name, policyType, enhancers) + } + + fun enhancePropertyDefinitions(bluePrintRuntimeService: BluePrintRuntimeService<*>, properties: MutableMap) { + properties.forEach { propertyName, propertyDefinition -> + enhancePropertyDefinition(bluePrintRuntimeService, propertyName, propertyDefinition) + } + } + + fun enhancePropertyDefinition(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, propertyDefinition: PropertyDefinition) { + val enhancers = getPropertyDefinitionEnhancers() + doEnhancement(bluePrintRuntimeService, name, propertyDefinition, enhancers) + } + + fun enhanceAttributeDefinitions(bluePrintRuntimeService: BluePrintRuntimeService<*>, attributes: MutableMap) { + attributes.forEach { attributeName, attributeDefinition -> + enhanceAttributeDefinition(bluePrintRuntimeService, attributeName, attributeDefinition) + } + } + + fun enhanceAttributeDefinition(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, attributeDefinition: AttributeDefinition) { + val enhancers = getAttributeDefinitionEnhancers() + doEnhancement(bluePrintRuntimeService, name, attributeDefinition, enhancers) + } + + @Suppress("UNCHECKED_CAST") + private fun doEnhancement(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, definition: Any, enhancers: List>) { + if (enhancers.isNotEmpty()) { + enhancers.forEach { + it.enhance(bluePrintRuntimeService, name, definition as T) + } + } + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintRepoService.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintRepoService.kt new file mode 100644 index 000000000..e5ba6f4c4 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintRepoService.kt @@ -0,0 +1,47 @@ +/* + * 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.core.interfaces + +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.core.data.* +import java.io.Serializable + +/** + * BluePrintRepoFileService + * @author Brinda Santh + * + */ + +interface BluePrintRepoService : Serializable { + + @Throws(BluePrintException::class) + fun getNodeType(nodeTypeName: String): NodeType + + @Throws(BluePrintException::class) + fun getDataType(dataTypeName: String): DataType + + @Throws(BluePrintException::class) + fun getArtifactType(artifactTypeName: String): ArtifactType + + @Throws(BluePrintException::class) + fun getRelationshipType(relationshipTypeName: String): RelationshipType + + @Throws(BluePrintException::class) + fun getCapabilityDefinition(capabilityDefinitionName: String): CapabilityDefinition + +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintScriptsService.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintScriptsService.kt new file mode 100644 index 000000000..124c167a8 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintScriptsService.kt @@ -0,0 +1,25 @@ +/* + * 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.core.interfaces + +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext + +interface BluePrintScriptsService{ + + fun scriptInstance(blueprintContext: BluePrintContext, scriptClassName: String, + reCompile: Boolean): T +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintFunctionNode.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintFunctionNode.kt new file mode 100644 index 000000000..0b9f1f182 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintFunctionNode.kt @@ -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.core.interfaces + +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException +import java.util.function.Function + + +interface BlueprintFunctionNode : Function { + + fun getName(): String + + @Throws(BluePrintProcessorException::class) + fun prepareRequest(executionRequest: T): T + + @Throws(BluePrintProcessorException::class) + fun process(executionRequest: T) + + @Throws(BluePrintProcessorException::class) + fun recover(runtimeException: RuntimeException, executionRequest: T) + + @Throws(BluePrintProcessorException::class) + fun prepareResponse(): R + +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintValidator.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintValidator.kt new file mode 100644 index 000000000..bea790fd3 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintValidator.kt @@ -0,0 +1,132 @@ +package org.onap.ccsdk.apps.controllerblueprints.core.interfaces + +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.core.data.* +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService + + +interface BluePrintValidator { + + fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, type: T) + +} + + +interface BluePrintServiceTemplateValidator : BluePrintValidator + +interface BluePrintTopologyTemplateValidator : BluePrintValidator + +interface BluePrintArtifactTypeValidator : BluePrintValidator + +interface BluePrintDataTypeValidator : BluePrintValidator + +interface BluePrintNodeTypeValidator : BluePrintValidator + +interface BluePrintNodeTemplateValidator : BluePrintValidator + +interface BluePrintWorkflowValidator : BluePrintValidator + +interface BluePrintPropertyDefinitionValidator : BluePrintValidator + +interface BluePrintAttributeDefinitionValidator : BluePrintValidator + +/** + * Blueprint Validation Interface. + */ +interface BluePrintValidatorService { + + @Throws(BluePrintException::class) + fun validateBluePrints(basePath: String): Boolean + + @Throws(BluePrintException::class) + fun validateBluePrints(bluePrintRuntimeService: BluePrintRuntimeService<*>): Boolean +} + + +interface BluePrintTypeValidatorService { + + fun getServiceTemplateValidators(): List + + fun getDataTypeValidators(): List + + fun getArtifactTypeValidators(): List + + fun getNodeTypeValidators(): List + + fun getTopologyTemplateValidators(): List + + fun getNodeTemplateValidators(): List + + fun getWorkflowValidators(): List + + fun getPropertyDefinitionValidators(): List + + fun getAttributeDefinitionValidators(): List + + fun validateServiceTemplate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, serviceTemplate: ServiceTemplate) { + val validators = getServiceTemplateValidators() + doValidation(bluePrintRuntimeService, name, serviceTemplate, validators) + } + + fun validateArtifactType(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, artifactType: ArtifactType) { + val validators = getArtifactTypeValidators() + doValidation(bluePrintRuntimeService, name, artifactType, validators) + } + + fun validateDataType(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, dataType: DataType) { + val validators = getDataTypeValidators() + doValidation(bluePrintRuntimeService, name, dataType, validators) + } + + fun validateNodeType(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, nodeType: NodeType) { + val validators = getNodeTypeValidators() + doValidation(bluePrintRuntimeService, name, nodeType, validators) + } + + fun validateTopologyTemplate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, topologyTemplate: TopologyTemplate) { + val validators = getTopologyTemplateValidators() + doValidation(bluePrintRuntimeService, name, topologyTemplate, validators) + } + + fun validateNodeTemplate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, nodeTemplate: NodeTemplate) { + val validators = getNodeTemplateValidators() + doValidation(bluePrintRuntimeService, name, nodeTemplate, validators) + } + + fun validateWorkflow(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, workflow: Workflow) { + val validators = getWorkflowValidators() + doValidation(bluePrintRuntimeService, name, workflow, validators) + } + + fun validatePropertyDefinitions(bluePrintRuntimeService: BluePrintRuntimeService<*>, properties: MutableMap) { + properties.forEach { propertyName, propertyDefinition -> + validatePropertyDefinition(bluePrintRuntimeService, propertyName, propertyDefinition) + } + } + + fun validatePropertyDefinition(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, propertyDefinition: PropertyDefinition) { + val validators = getPropertyDefinitionValidators() + doValidation(bluePrintRuntimeService, name, propertyDefinition, validators) + } + + fun validateAttributeDefinitions(bluePrintRuntimeService: BluePrintRuntimeService<*>, attributes: MutableMap) { + attributes.forEach { attributeName, attributeDefinition -> + validateAttributeDefinition(bluePrintRuntimeService, attributeName, attributeDefinition) + } + } + + fun validateAttributeDefinition(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, attributeDefinition: AttributeDefinition) { + val validators = getAttributeDefinitionValidators() + doValidation(bluePrintRuntimeService, name, attributeDefinition, validators) + } + + @Suppress("UNCHECKED_CAST") + private fun doValidation(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, definition: Any, validators: List>) { + validators.forEach { + it.validate(bluePrintRuntimeService, name, definition as T) + } + } +} + + + diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintChainedService.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintChainedService.kt new file mode 100644 index 000000000..3c637bde5 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintChainedService.kt @@ -0,0 +1,117 @@ +/* + * 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.core.service + +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes +import org.onap.ccsdk.apps.controllerblueprints.core.data.* +/** + * + * + * @author Brinda Santh + */ +class BluePrintChainedService { + var bpc : BluePrintContext + + constructor(bpc : BluePrintContext){ + this.bpc = bpc + } + + fun nodeTypeChained(nodeTypeName: String): NodeType { + + val nodeType: NodeType = bpc.nodeTypeByName(nodeTypeName) + val attributes = hashMapOf() + val properties = hashMapOf() + val requirements = hashMapOf() + val capabilities = hashMapOf() + val interfaces = hashMapOf() + val artifacts = hashMapOf() + + recNodeTypesChained(nodeTypeName).forEach { nodeType -> + + val subAttributes = bpc.nodeTypeByName(nodeType.id!!).attributes + if (subAttributes != null) { + attributes.putAll(subAttributes) + } + + val subProperties = bpc.nodeTypeByName(nodeType.id!!).properties + if (subProperties != null) { + properties.putAll(subProperties) + } + + val subRequirements = bpc.nodeTypeByName(nodeType.id!!).requirements + if (subRequirements != null) { + requirements.putAll(subRequirements) + } + val subCapabilities = bpc.nodeTypeByName(nodeType.id!!).capabilities + if (subCapabilities != null) { + capabilities.putAll(subCapabilities) + } + val subInterfaces = bpc.nodeTypeByName(nodeType.id!!).interfaces + if (subInterfaces != null) { + interfaces.putAll(subInterfaces) + } + + val subArtifacts = bpc.nodeTypeByName(nodeType.id!!).artifacts + if (subArtifacts != null) { + artifacts.putAll(subArtifacts) + } + } + nodeType.attributes = attributes + nodeType.properties = properties + nodeType.requirements = requirements + nodeType.capabilities = capabilities + nodeType.interfaces = interfaces + nodeType.artifacts = artifacts + return nodeType + } + + fun nodeTypeChainedProperties(nodeTypeName: String): MutableMap? { + val nodeType = bpc.nodeTypeByName(nodeTypeName) + val properties = hashMapOf() + + recNodeTypesChained(nodeTypeName).forEach { nodeType -> + val subProperties = bpc.nodeTypeByName(nodeType.id!!).properties + if (subProperties != null) { + properties.putAll(subProperties) + } + } + return properties + } + + private fun recNodeTypesChained(nodeTypeName: String, nodeTypes: MutableList? = arrayListOf()): MutableList { + val nodeType: NodeType = bpc.nodeTypeByName(nodeTypeName) + nodeType.id = nodeTypeName + val derivedFrom: String = nodeType.derivedFrom + if (!BluePrintTypes.rootNodeTypes().contains(derivedFrom)) { + recNodeTypesChained(derivedFrom, nodeTypes) + } + nodeTypes!!.add(nodeType) + return nodeTypes + } + + private fun recDataTypesChained(dataTypeName: String, dataTypes: MutableList? = arrayListOf()): MutableList { + val dataType: DataType = bpc.dataTypeByName(dataTypeName)!! + dataType.id = dataTypeName + val derivedFrom: String = dataType.derivedFrom + if (!BluePrintTypes.rootDataTypes().contains(derivedFrom)) { + recDataTypesChained(derivedFrom, dataTypes) + } + dataTypes!!.add(dataType) + return dataTypes + } + +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt new file mode 100644 index 000000000..a0bf054b9 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt @@ -0,0 +1,254 @@ +/* + * 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. + */ +@file:Suppress("unused") + +package org.onap.ccsdk.apps.controllerblueprints.core.service + +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import com.fasterxml.jackson.databind.JsonNode +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants +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 + +/** + * + * + * @author Brinda Santh + */ +class BluePrintContext(val serviceTemplate: ServiceTemplate) { + + private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) + + /** + * Blueprint CBA extracted file location + */ + var rootPath = "." + /** + * Root Definition file path + */ + var entryDefinition = "" + + val imports: List? = serviceTemplate.imports + + val metadata: MutableMap? = serviceTemplate.metadata + + val dataTypes: MutableMap? = serviceTemplate.dataTypes + + val inputs: MutableMap? = serviceTemplate.topologyTemplate?.inputs + + fun blueprintJson(pretty: Boolean = false): String = print("json", pretty) + + private fun print(type: String? = "json", pretty: Boolean = false): String { + return JacksonUtils.getJson(serviceTemplate, pretty) + } + + fun name(): String = metadata?.get(BluePrintConstants.METADATA_TEMPLATE_NAME) + ?: throw BluePrintException("could't get template name from meta data") + + fun version(): String = metadata?.get(BluePrintConstants.METADATA_TEMPLATE_VERSION) + ?: throw BluePrintException("could't get template version from meta data") + + fun author(): String = metadata?.get(BluePrintConstants.METADATA_TEMPLATE_AUTHOR) + ?: throw BluePrintException("could't get template author from meta data") + + // Workflow + val workflows: MutableMap? = serviceTemplate.topologyTemplate?.workflows + + fun workflowByName(workFlowName: String): Workflow = workflows?.get(workFlowName) + ?: throw BluePrintException("could't get workflow($workFlowName)") + + fun workflowInputs(workFlowName: String) = workflowByName(workFlowName).inputs + + fun workflowStepByName(workFlowName: String, stepName: String): Step { + return workflowByName(workFlowName).steps?.get(stepName) + ?: throw BluePrintException("could't get step($stepName) for workflow($workFlowName)") + } + + fun workflowStepNodeTemplate(workFlowName: String, stepName: String): String { + return workflowStepByName(workFlowName, stepName).target + ?: throw BluePrintException("could't get node template name for workflow($workFlowName)'s step($stepName)") + } + + fun workflowFirstStepNodeTemplate(workFlowName: String): String { + val firstStepName = workflowByName(workFlowName).steps?.keys?.first() + ?: throw BluePrintException("could't get first step for workflow($workFlowName)") + return workflowStepNodeTemplate(workFlowName, firstStepName) + } + + fun workflowStepFirstCallOperation(workFlowName: String, stepName: String): String { + return workflowStepByName(workFlowName, stepName).activities?.filter { it.callOperation != null }?.single()?.callOperation + ?: throw BluePrintException("could't get first callOperation for WorkFlow($workFlowName) ") + } + + // Data Type + fun dataTypeByName(name: String): DataType? = dataTypes?.get(name) + + // Artifact Type + val artifactTypes: MutableMap? = serviceTemplate.artifactTypes + + // Policy Types + val policyTypes: MutableMap? = serviceTemplate.policyTypes + + fun policyTypeByName(policyName: String) = policyTypes?.get(policyName) + ?: throw BluePrintException("could't get policy type for the name($policyName)") + + fun policyTypesDerivedFrom(name: String): MutableMap? { + return policyTypes?.filterValues { policyType -> policyType.derivedFrom == name }?.toMutableMap() + } + + fun policyTypesTarget(target: String): MutableMap? { + return policyTypes?.filterValues { it.targets.contains(target) }?.toMutableMap() + } + + fun policyTypesTargetNDerivedFrom(target: String, derivedFrom: String): MutableMap? { + return policyTypesDerivedFrom(derivedFrom)?.filterValues { + it.targets.contains(target) + }?.toMutableMap() + } + + // Node Type Methods + val nodeTypes: MutableMap? = serviceTemplate.nodeTypes + + fun nodeTypeByName(name: String): NodeType = + nodeTypes?.get(name) + ?: throw BluePrintException("could't get node type for the name($name)") + + fun nodeTypeDerivedFrom(name: String): MutableMap? { + return nodeTypes?.filterValues { nodeType -> nodeType.derivedFrom == name }?.toMutableMap() + } + + fun nodeTypeInterface(nodeTypeName: String, interfaceName: String): InterfaceDefinition { + return nodeTypeByName(nodeTypeName).interfaces?.get(interfaceName) + ?: throw BluePrintException("could't get node type($nodeTypeName)'s interface definition($interfaceName)") + } + + fun nodeTypeInterfaceOperation(nodeTypeName: String, interfaceName: String, operationName: String): OperationDefinition { + return nodeTypeInterface(nodeTypeName, interfaceName).operations?.get(operationName) + ?: throw BluePrintException("could't get node type($nodeTypeName)'s interface definition($interfaceName) operation definition($operationName)") + } + + fun interfaceNameForNodeType(nodeTypeName: String): String { + return nodeTypeByName(nodeTypeName).interfaces?.keys?.first() + ?: throw BluePrintException("could't get NodeType($nodeTypeName)'s first InterfaceDefinition name") + } + + fun nodeTypeInterfaceOperationInputs(nodeTypeName: String, interfaceName: String, operationName: String): MutableMap? { + return nodeTypeInterfaceOperation(nodeTypeName, interfaceName, operationName).inputs + } + + fun nodeTypeInterfaceOperationOutputs(nodeTypeName: String, interfaceName: String, operationName: String): MutableMap? { + return nodeTypeInterfaceOperation(nodeTypeName, interfaceName, operationName).outputs + } + + // Node Template Methods + val nodeTemplates: MutableMap? = serviceTemplate.topologyTemplate?.nodeTemplates + + fun nodeTemplateByName(name: String): NodeTemplate = + nodeTemplates?.get(name) ?: throw BluePrintException("could't get node template for the name($name)") + + fun nodeTemplateForNodeType(name: String): MutableMap? { + return nodeTemplates?.filterValues { nodeTemplate -> nodeTemplate.type == name }?.toMutableMap() + } + + fun nodeTemplateNodeType(nodeTemplateName: String): NodeType { + val nodeTemplateType: String = nodeTemplateByName(nodeTemplateName).type + return nodeTypeByName(nodeTemplateType) + } + + fun nodeTemplateProperty(nodeTemplateName: String, propertyName: String): Any? { + return nodeTemplateByName(nodeTemplateName).properties?.get(propertyName) + } + + fun nodeTemplateArtifacts(nodeTemplateName: String): MutableMap? { + return nodeTemplateByName(nodeTemplateName).artifacts + } + + fun nodeTemplateArtifact(nodeTemplateName: String, artifactName: String): ArtifactDefinition { + return nodeTemplateArtifacts(nodeTemplateName)?.get(artifactName) + ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s ArtifactDefinition($artifactName)") + } + + fun nodeTemplateArtifactForArtifactType(nodeTemplateName: String, artifactType: String): ArtifactDefinition { + return nodeTemplateArtifacts(nodeTemplateName)?.filter { it.value.type == artifactType }?.map { it.value }?.get(0) + ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s Artifact Type($artifactType)") + } + + fun nodeTemplateFirstInterface(nodeTemplateName: String): InterfaceAssignment { + return nodeTemplateByName(nodeTemplateName).interfaces?.values?.first() + ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s first InterfaceAssignment") + } + + fun nodeTemplateFirstInterfaceName(nodeTemplateName: String): String { + return nodeTemplateByName(nodeTemplateName).interfaces?.keys?.first() + ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s first InterfaceAssignment name") + } + + fun nodeTemplateFirstInterfaceFirstOperationName(nodeTemplateName: String): String { + return nodeTemplateFirstInterface(nodeTemplateName).operations?.keys?.first() + ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s first InterfaceAssignment's first OperationAssignment name") + } + + fun nodeTemplateInterfaceOperationInputs(nodeTemplateName: String, interfaceName: String, operationName: String): MutableMap? { + return nodeTemplateInterfaceOperation(nodeTemplateName, interfaceName, operationName).inputs + } + + fun nodeTemplateInterfaceOperationOutputs(nodeTemplateName: String, interfaceName: String, operationName: String): MutableMap? { + return nodeTemplateInterfaceOperation(nodeTemplateName, interfaceName, operationName).outputs + } + + fun nodeTemplateInterface(nodeTemplateName: String, interfaceName: String): InterfaceAssignment { + return nodeTemplateByName(nodeTemplateName).interfaces?.get(interfaceName) + ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s InterfaceAssignment($interfaceName)") + } + + fun nodeTemplateInterfaceOperation(nodeTemplateName: String, interfaceName: String, operationName: String): OperationAssignment { + return nodeTemplateInterface(nodeTemplateName, interfaceName).operations?.get(operationName) + ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s InterfaceAssignment($interfaceName) OperationAssignment($operationName)") + } + + fun nodeTemplateCapability(nodeTemplateName: String, capabilityName: String): CapabilityAssignment { + return nodeTemplateByName(nodeTemplateName).capabilities?.get(capabilityName) + ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s CapabilityAssignment($capabilityName)") + } + + fun nodeTemplateRequirement(nodeTemplateName: String, requirementName: String): RequirementAssignment { + return nodeTemplateByName(nodeTemplateName).requirements?.get(requirementName) + ?: throw BluePrintException("could't get NodeTemplate($nodeTemplateName)'s first RequirementAssignment($requirementName)") + } + + fun nodeTemplateRequirementNode(nodeTemplateName: String, requirementName: String): NodeTemplate { + val filteredNodeTemplateName: String = nodeTemplateByName(nodeTemplateName).requirements?.get(requirementName)?.node + ?: throw BluePrintException("could't NodeTemplate for NodeTemplate's($nodeTemplateName) requirement's ($requirementName) ") + return nodeTemplateByName(filteredNodeTemplateName) + } + + fun nodeTemplateCapabilityProperty(nodeTemplateName: String, capabilityName: String, propertyName: String): Any? { + return nodeTemplateCapability(nodeTemplateName, capabilityName).properties?.get(propertyName) + } + + // Chained Functions + + fun nodeTypeChained(nodeTypeName: String): NodeType { + return BluePrintChainedService(this).nodeTypeChained(nodeTypeName) + } + + fun nodeTypeChainedProperties(nodeTypeName: String): MutableMap? { + return BluePrintChainedService(this).nodeTypeChainedProperties(nodeTypeName) + } + +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionService.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionService.kt new file mode 100644 index 000000000..caa02dbce --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionService.kt @@ -0,0 +1,173 @@ +/* + * 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.core.service + +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.node.ArrayNode +import com.fasterxml.jackson.databind.node.ObjectNode +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes +import org.onap.ccsdk.apps.controllerblueprints.core.data.* + +/** + * + * + * @author Brinda Santh + */ +object BluePrintExpressionService { + val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) + + @JvmStatic + fun getExpressionData(propertyAssignmentNode: JsonNode): ExpressionData { + log.trace("Assignment Data/Expression : {}", propertyAssignmentNode) + val expressionData = ExpressionData(valueNode = propertyAssignmentNode) + if (propertyAssignmentNode is ObjectNode) { + + val commands: Set = propertyAssignmentNode.fieldNames().asSequence().toList().intersect(BluePrintTypes.validCommands()) + if (commands.isNotEmpty()) { + expressionData.isExpression = true + expressionData.command = commands.first() + expressionData.expressionNode = propertyAssignmentNode + + when (expressionData.command) { + BluePrintConstants.EXPRESSION_GET_INPUT -> { + expressionData.inputExpression = populateInputExpression(propertyAssignmentNode) + } + BluePrintConstants.EXPRESSION_GET_ATTRIBUTE -> { + expressionData.attributeExpression = populateAttributeExpression(propertyAssignmentNode) + } + BluePrintConstants.EXPRESSION_GET_PROPERTY -> { + expressionData.propertyExpression = populatePropertyExpression(propertyAssignmentNode) + } + BluePrintConstants.EXPRESSION_GET_OPERATION_OUTPUT -> { + expressionData.operationOutputExpression = populateOperationOutputExpression(propertyAssignmentNode) + } + BluePrintConstants.EXPRESSION_GET_ARTIFACT -> { + expressionData.artifactExpression = populateArtifactExpression(propertyAssignmentNode) + } + } + } + } + return expressionData + } + + @JvmStatic + fun populateInputExpression(jsonNode: JsonNode): InputExpression { + return InputExpression(propertyName = jsonNode.first().textValue()) + } + + @JvmStatic + fun populatePropertyExpression(jsonNode: JsonNode): PropertyExpression { + val arrayNode: ArrayNode = jsonNode.first() as ArrayNode + check(arrayNode.size() >= 2) { + throw BluePrintException(String.format("missing property expression, " + + "it should be [ , , , " + + ", ..., ] , but present {}", jsonNode)) + } + var reqOrCapEntityName: String? = null + var propertyName = "" + var subProperty: String? = null + when { + arrayNode.size() == 2 -> propertyName = arrayNode[1].textValue() + arrayNode.size() == 3 -> { + reqOrCapEntityName = arrayNode[1].textValue() + propertyName = arrayNode[2].textValue() + } + arrayNode.size() > 3 -> { + reqOrCapEntityName = arrayNode[1].textValue() + propertyName = arrayNode[2].textValue() + val propertyPaths: List = arrayNode.filterIndexed { index, _ -> + index >= 3 + }.map { it.textValue() } + subProperty = propertyPaths.joinToString("/") + } + } + + return PropertyExpression(modelableEntityName = arrayNode[0].asText(), + reqOrCapEntityName = reqOrCapEntityName, + propertyName = propertyName, + subPropertyName = subProperty + ) + } + + @JvmStatic + fun populateAttributeExpression(jsonNode: JsonNode): AttributeExpression { + val arrayNode: ArrayNode = jsonNode.first() as ArrayNode + check(arrayNode.size() >= 2) { + throw BluePrintException(String.format("missing attribute expression, " + + "it should be [ , , ," + + " , ..., ] , but present {}", jsonNode)) + } + + var reqOrCapEntityName: String? = null + var attributeName = "" + var subAttributeName: String? = null + when { + arrayNode.size() == 2 -> attributeName = arrayNode[1].textValue() + arrayNode.size() == 3 -> { + reqOrCapEntityName = arrayNode[1].textValue() + attributeName = arrayNode[2].textValue() + } + arrayNode.size() > 3 -> { + reqOrCapEntityName = arrayNode[1].textValue() + attributeName = arrayNode[2].textValue() + val propertyPaths: List = arrayNode.filterIndexed { index, _ -> + index >= 3 + }.map { it.textValue() } + subAttributeName = propertyPaths.joinToString("/") + } + } + return AttributeExpression(modelableEntityName = arrayNode[0].asText(), + reqOrCapEntityName = reqOrCapEntityName, + attributeName = attributeName, + subAttributeName = subAttributeName + ) + } + + @JvmStatic + fun populateOperationOutputExpression(jsonNode: JsonNode): OperationOutputExpression { + val arrayNode: ArrayNode = jsonNode.first() as ArrayNode + + check(arrayNode.size() >= 4) { + throw BluePrintException(String.format("missing operation output expression, " + + "it should be (, , , ) , but present {}", jsonNode)) + } + return OperationOutputExpression(modelableEntityName = arrayNode[0].asText(), + interfaceName = arrayNode[1].asText(), + operationName = arrayNode[2].asText(), + propertyName = arrayNode[3].asText() + ) + } + + @JvmStatic + fun populateArtifactExpression(jsonNode: JsonNode): ArtifactExpression { + val arrayNode: ArrayNode = jsonNode.first() as ArrayNode + + check(arrayNode.size() >= 2) { + throw BluePrintException(String.format("missing artifact expression, " + + "it should be [ , , , ] , but present {}", jsonNode)) + } + return ArtifactExpression(modelableEntityName = arrayNode[0].asText(), + artifactName = arrayNode[1].asText(), + location = arrayNode[2]?.asText() ?: "LOCAL_FILE", + remove = arrayNode[3]?.asBoolean() ?: false + ) + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintImportService.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintImportService.kt new file mode 100644 index 000000000..26eb19de1 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintImportService.kt @@ -0,0 +1,96 @@ +/* + * 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.core.service + +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.core.data.ImportDefinition +import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate +import org.onap.ccsdk.apps.controllerblueprints.core.utils.ServiceTemplateUtils +import org.slf4j.Logger +import org.slf4j.LoggerFactory +import java.io.File +import java.net.URL +import java.net.URLDecoder +import java.nio.charset.Charset + +class BluePrintImportService(private val parentServiceTemplate: ServiceTemplate, private val blueprintBasePath: String) { + companion object { + private const val PARENT_SERVICE_TEMPLATE: String = "parent" + } + + private val log: Logger = LoggerFactory.getLogger(this::class.toString()) + + private var importServiceTemplateMap: MutableMap = hashMapOf() + + + fun getImportResolvedServiceTemplate(): ServiceTemplate { + // Populate Imported Service Templates + traverseSchema(PARENT_SERVICE_TEMPLATE, parentServiceTemplate) + + importServiceTemplateMap.forEach { key, serviceTemplate -> + ServiceTemplateUtils.merge(parentServiceTemplate, serviceTemplate) + log.debug("merged service template $key") + } + return parentServiceTemplate + } + + private fun traverseSchema(key: String, serviceTemplate: ServiceTemplate) { + if (key != PARENT_SERVICE_TEMPLATE) { + importServiceTemplateMap[key] = serviceTemplate + } + val imports: List? = serviceTemplate.imports + + imports?.let { + serviceTemplate.imports?.forEach { importDefinition -> + val childServiceTemplate = resolveImportDefinition(importDefinition) + val keyName: String = importDefinition.file + traverseSchema(keyName, childServiceTemplate) + } + } + } + + private fun resolveImportDefinition(importDefinition: ImportDefinition): ServiceTemplate { + var serviceTemplate: ServiceTemplate? = null + val file: String = importDefinition.file + val decodedSystemId: String = URLDecoder.decode(file, Charset.defaultCharset().toString()) + log.trace("file ({}), decodedSystemId ({}) ", file, decodedSystemId) + try { + if (decodedSystemId.startsWith("http", true) + || decodedSystemId.startsWith("https", true)) { + val givenUrl: String = URL(decodedSystemId).toString() + val systemUrl: String = File(".").toURI().toURL().toString() + log.trace("givenUrl ({}), systemUrl ({}) ", givenUrl, systemUrl) + if (givenUrl.startsWith(systemUrl)) { + + } + } else { + if (!decodedSystemId.startsWith("/")) { + importDefinition.file = StringBuilder().append(blueprintBasePath).append(File.separator).append(file).toString() + } + serviceTemplate = ServiceTemplateUtils.getServiceTemplate(importDefinition.file) + } + } catch (e: Exception) { + throw BluePrintException("failed to populate service template for ${importDefinition.file}", e) + } + if (serviceTemplate == null) { + throw BluePrintException("failed to populate service template for : ${importDefinition.file}") + } + return serviceTemplate + } + + +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintParserService.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintParserService.kt new file mode 100644 index 000000000..b1d67ece9 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintParserService.kt @@ -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.core.service + +import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate +import org.onap.ccsdk.apps.controllerblueprints.core.utils.ServiceTemplateUtils +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import java.io.File +import java.io.Serializable + +/** + * + * + * @author Brinda Santh + */ +interface BluePrintParserService : Serializable { + fun readBlueprint(content: String) : BluePrintContext + fun readBlueprintFile(fileName: String) : BluePrintContext + /** + * Read Blueprint from CSAR structure Directory + */ + fun readBlueprintFile(fileName: String, basePath : String) : BluePrintContext +} + +class BluePrintParserDefaultService : BluePrintParserService { + + private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) + + var basePath : String = javaClass.classLoader.getResource(".").path + + override fun readBlueprint(content: String): BluePrintContext { + return BluePrintContext(ServiceTemplateUtils.getServiceTemplateFromContent(content)) + } + + override fun readBlueprintFile(fileName: String): BluePrintContext { + return readBlueprintFile(fileName, basePath ) + } + + override fun readBlueprintFile(fileName: String, basePath : String): BluePrintContext { + val rootFilePath: String = StringBuilder().append(basePath).append(File.separator).append(fileName).toString() + val rootServiceTemplate : ServiceTemplate = ServiceTemplateUtils.getServiceTemplate(rootFilePath) + // TODO("Nested Lookup Implementation based on Import files") + return BluePrintContext(rootServiceTemplate) + } + + +} diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileService.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileService.kt new file mode 100644 index 000000000..5d6ca7573 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileService.kt @@ -0,0 +1,71 @@ +/* + * 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.core.service + +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.core.data.* +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintRepoService +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils + +open class BluePrintRepoFileService(modelTypePath: String) : BluePrintRepoService { + + private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintRepoFileService::class.toString()) + + private val dataTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE) + private val nodeTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE) + private val artifactTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE) + private val capabilityTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_CAPABILITY_TYPE) + private val relationshipTypePath = modelTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(BluePrintConstants.MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE) + private val extension = ".json" + + override fun getDataType(dataTypeName: String): DataType { + val fileName = dataTypePath.plus(BluePrintConstants.PATH_DIVIDER) + .plus(dataTypeName).plus(extension) + return getModelType(fileName, DataType::class.java) + } + + override fun getNodeType(nodeTypeName: String): NodeType { + val fileName = nodeTypePath.plus(BluePrintConstants.PATH_DIVIDER).plus(nodeTypeName).plus(extension) + return getModelType(fileName, NodeType::class.java) + } + + override fun getArtifactType(artifactTypeName: String): ArtifactType { + val fileName = artifactTypePath.plus(BluePrintConstants.PATH_DIVIDER) + .plus(artifactTypeName).plus(extension) + return getModelType(fileName, ArtifactType::class.java) + } + + override fun getRelationshipType(relationshipTypeName: String): RelationshipType { + val fileName = relationshipTypePath.plus(BluePrintConstants.PATH_DIVIDER) + .plus(relationshipTypeName).plus(extension) + return getModelType(fileName, RelationshipType::class.java) + } + + override fun getCapabilityDefinition(capabilityDefinitionName: String): CapabilityDefinition { + val fileName = capabilityTypePath.plus(BluePrintConstants.PATH_DIVIDER) + .plus(capabilityDefinitionName).plus(extension) + return getModelType(fileName, CapabilityDefinition::class.java) + } + + private fun getModelType(fileName: String, valueType: Class): T { + return JacksonUtils.readValueFromFile(fileName, valueType) + ?: throw BluePrintException("couldn't get file($fileName) for type(${valueType.name}") + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt new file mode 100644 index 000000000..5c10f80c9 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt @@ -0,0 +1,501 @@ +/* + * 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.core.service + + +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.node.NullNode +import com.fasterxml.jackson.databind.node.ObjectNode +import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException +import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactDefinition +import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate +import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils + +interface BluePrintRuntimeService { + + fun id(): String + + fun bluePrintContext(): BluePrintContext + + fun getExecutionContext(): T + + fun setExecutionContext(executionContext: T) + + fun put(key: String, value: JsonNode) + + fun get(key: String): JsonNode? + + fun check(key: String): Boolean + + fun cleanRuntime() + + fun getAsString(key: String): String? + + fun getAsBoolean(key: String): Boolean? + + fun getAsInt(key: String): Int? + + fun getAsDouble(key: String): Double? + + fun getBluePrintError(): BluePrintError + + fun setBluePrintError(bluePrintError: BluePrintError) + + fun resolveNodeTemplatePropertyAssignments(nodeTemplateName: String, + propertyDefinitions: MutableMap, + propertyAssignments: MutableMap): MutableMap + + fun resolveNodeTemplateProperties(nodeTemplateName: String): MutableMap + + fun resolveNodeTemplateCapabilityProperties(nodeTemplateName: String, capabilityName: String): MutableMap + + fun resolveNodeTemplateInterfaceOperationInputs(nodeTemplateName: String, interfaceName: String, + operationName: String): MutableMap + + fun resolveNodeTemplateInterfaceOperationOutputs(nodeTemplateName: String, interfaceName: String, + operationName: String): MutableMap + + fun resolveNodeTemplateArtifact(nodeTemplateName: String, artifactName: String): String + + fun resolveNodeTemplateArtifactDefinition(nodeTemplateName: String, artifactName: String): ArtifactDefinition + + fun setInputValue(propertyName: String, propertyDefinition: PropertyDefinition, value: JsonNode) + + fun setWorkflowInputValue(workflowName: String, propertyName: String, propertyDefinition: PropertyDefinition, value: JsonNode) + + fun setNodeTemplatePropertyValue(nodeTemplateName: String, propertyName: String, value: JsonNode) + + fun setNodeTemplateAttributeValue(nodeTemplateName: String, attributeName: String, value: JsonNode) + + fun setNodeTemplateOperationPropertyValue(nodeTemplateName: String, interfaceName: String, + operationName: String, propertyName: String, value: JsonNode) + + fun setNodeTemplateOperationInputValue(nodeTemplateName: String, interfaceName: String, + operationName: String, propertyName: String, value: JsonNode) + + fun setNodeTemplateOperationOutputValue(nodeTemplateName: String, interfaceName: String, + operationName: String, propertyName: String, value: JsonNode) + + fun getInputValue(propertyName: String): JsonNode + + fun getNodeTemplateOperationOutputValue(nodeTemplateName: String, interfaceName: String, + operationName: String, propertyName: String): JsonNode + + fun getNodeTemplatePropertyValue(nodeTemplateName: String, propertyName: String): JsonNode? + + fun getNodeTemplateAttributeValue(nodeTemplateName: String, attributeName: String): JsonNode? + + fun assignInputs(jsonNode: JsonNode) + + fun assignWorkflowInputs(workflowName: String, jsonNode: JsonNode) + + fun getJsonForNodeTemplateAttributeProperties(nodeTemplateName: String, keys: List): JsonNode +} + +/** + * + * + * @author Brinda Santh + */ +open class DefaultBluePrintRuntimeService(private var id: String, private var bluePrintContext: BluePrintContext) + : BluePrintRuntimeService> { + + @Transient + private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintRuntimeService::class.toString()) + + private var store: MutableMap = hashMapOf() + + private var bluePrintError = BluePrintError() + + override fun id(): String { + return id + } + + override fun bluePrintContext(): BluePrintContext { + return bluePrintContext + } + + override fun getExecutionContext(): MutableMap { + return store + } + + @Suppress("UNCHECKED_CAST") + override fun setExecutionContext(executionContext: MutableMap) { + this.store = executionContext + } + + override fun put(key: String, value: JsonNode) { + store[key] = value + } + + override fun get(key: String): JsonNode { + return store[key] ?: throw BluePrintProcessorException("failed to get execution property($key)") + } + + override fun check(key: String): Boolean { + return store.containsKey(key) + } + + override fun cleanRuntime() { + store.clear() + } + + private fun getJsonNode(key: String): JsonNode { + return get(key) + } + + override fun getAsString(key: String): String? { + return get(key).asText() + } + + override fun getAsBoolean(key: String): Boolean? { + return get(key).asBoolean() + } + + override fun getAsInt(key: String): Int? { + return get(key).asInt() + } + + override fun getAsDouble(key: String): Double? { + return get(key).asDouble() + } + + override fun getBluePrintError(): BluePrintError { + return this.bluePrintError + } + + override fun setBluePrintError(bluePrintError: BluePrintError) { + this.bluePrintError = bluePrintError + } + + /** + * Resolve any property assignments for the node + */ + override fun resolveNodeTemplatePropertyAssignments(nodeTemplateName: String, + propertyDefinitions: MutableMap, + propertyAssignments: MutableMap) + : MutableMap { + + val propertyAssignmentValue: MutableMap = hashMapOf() + + propertyDefinitions.forEach { nodeTypePropertyName, nodeTypeProperty -> + // Get the Express or Value for the Node Template + val propertyAssignment: JsonNode? = propertyAssignments[nodeTypePropertyName] + + var resolvedValue: JsonNode = NullNode.getInstance() + if (propertyAssignment != null) { + // Resolve the Expressing + val propertyAssignmentExpression = PropertyAssignmentService(this) + resolvedValue = propertyAssignmentExpression.resolveAssignmentExpression(nodeTemplateName, + nodeTypePropertyName, propertyAssignment) + } else { + // Assign default value to the Operation + nodeTypeProperty.defaultValue?.let { + resolvedValue = JacksonUtils.jsonNodeFromObject(nodeTypeProperty.defaultValue!!) + } + } + // Set for Return of method + propertyAssignmentValue[nodeTypePropertyName] = resolvedValue + } + return propertyAssignmentValue + } + + override fun resolveNodeTemplateProperties(nodeTemplateName: String): MutableMap { + log.info("resolveNodeTemplatePropertyValues for node template ({})", nodeTemplateName) + + val nodeTemplate: NodeTemplate = bluePrintContext.nodeTemplateByName(nodeTemplateName) + + val propertyAssignments: MutableMap = nodeTemplate.properties!! + + // Get the Node Type Definitions + val nodeTypePropertieDefinitions: MutableMap = bluePrintContext + .nodeTypeChainedProperties(nodeTemplate.type)!! + + /** + * Resolve the NodeTemplate Property Assignment Values. + */ + return resolveNodeTemplatePropertyAssignments(nodeTemplateName, nodeTypePropertieDefinitions, + propertyAssignments) + } + + override fun resolveNodeTemplateCapabilityProperties(nodeTemplateName: String, capabilityName: String): + MutableMap { + log.info("resolveNodeTemplateCapabilityProperties for node template($nodeTemplateName) capability " + + "($capabilityName)") + val nodeTemplate: NodeTemplate = bluePrintContext.nodeTemplateByName(nodeTemplateName) + + val propertyAssignments = nodeTemplate.capabilities?.get(capabilityName)?.properties ?: hashMapOf() + + val propertyDefinitions = bluePrintContext.nodeTemplateNodeType(nodeTemplateName) + .capabilities?.get(capabilityName)?.properties ?: hashMapOf() + + /** + * Resolve the Capability Property Assignment Values. + */ + return resolveNodeTemplatePropertyAssignments(nodeTemplateName, propertyDefinitions, + propertyAssignments) + } + + override fun resolveNodeTemplateInterfaceOperationInputs(nodeTemplateName: String, + interfaceName: String, + operationName: String): MutableMap { + log.info("resolveNodeTemplateInterfaceOperationInputs for node template ($nodeTemplateName),interface name " + + "($interfaceName), operationName($operationName)") + + val propertyAssignments: MutableMap = + bluePrintContext.nodeTemplateInterfaceOperationInputs(nodeTemplateName, interfaceName, operationName) + ?: hashMapOf() + + val nodeTypeName = bluePrintContext.nodeTemplateByName(nodeTemplateName).type + + val nodeTypeInterfaceOperationInputs: MutableMap = + bluePrintContext.nodeTypeInterfaceOperationInputs(nodeTypeName, interfaceName, operationName) + ?: hashMapOf() + + log.info("input definition for node template ($nodeTemplateName), values ($propertyAssignments)") + + /** + * Resolve the Property Input Assignment Values. + */ + return resolveNodeTemplatePropertyAssignments(nodeTemplateName, nodeTypeInterfaceOperationInputs, + propertyAssignments) + + } + + + override fun resolveNodeTemplateInterfaceOperationOutputs(nodeTemplateName: String, + interfaceName: String, + operationName: String): MutableMap { + log.info("resolveNodeTemplateInterfaceOperationOutputs for node template ($nodeTemplateName),interface name " + + "($interfaceName), operationName($operationName)") + + val propertyAssignments: MutableMap = + bluePrintContext.nodeTemplateInterfaceOperationOutputs(nodeTemplateName, interfaceName, operationName) + ?: hashMapOf() + + val nodeTypeName = bluePrintContext.nodeTemplateByName(nodeTemplateName).type + + val nodeTypeInterfaceOperationOutputs: MutableMap = + bluePrintContext.nodeTypeInterfaceOperationOutputs(nodeTypeName, interfaceName, operationName) + ?: hashMapOf() + /** + * Resolve the Property Output Assignment Values. + */ + val propertyAssignmentValue = resolveNodeTemplatePropertyAssignments(nodeTemplateName, + nodeTypeInterfaceOperationOutputs, propertyAssignments) + + // Store operation output values into context + propertyAssignmentValue.forEach { key, value -> + setNodeTemplateOperationOutputValue(nodeTemplateName, interfaceName, operationName, key, value) + } + return propertyAssignmentValue + } + + override fun resolveNodeTemplateArtifact(nodeTemplateName: String, artifactName: String): String { + val artifactDefinition: ArtifactDefinition = resolveNodeTemplateArtifactDefinition(nodeTemplateName, artifactName) + val propertyAssignmentExpression = PropertyAssignmentService(this) + return propertyAssignmentExpression.artifactContent(artifactDefinition) + } + + override fun resolveNodeTemplateArtifactDefinition(nodeTemplateName: String, artifactName: String): ArtifactDefinition { + val nodeTemplate = bluePrintContext.nodeTemplateByName(nodeTemplateName) + + return nodeTemplate.artifacts?.get(artifactName) + ?: throw BluePrintProcessorException("failed to get artifat definition($artifactName) from the node " + + "template") + + } + + override fun setInputValue(propertyName: String, propertyDefinition: PropertyDefinition, value: JsonNode) { + val path = StringBuilder(BluePrintConstants.PATH_INPUTS) + .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() + log.trace("setting input path ({}), values ({})", path, value) + put(path, value) + } + + override fun setWorkflowInputValue(workflowName: String, propertyName: String, + propertyDefinition: PropertyDefinition, value: JsonNode) { + val path: String = StringBuilder(BluePrintConstants.PATH_NODE_WORKFLOWS) + .append(BluePrintConstants.PATH_DIVIDER).append(workflowName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INPUTS) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) + .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() + put(path, value) + } + + override fun setNodeTemplatePropertyValue(nodeTemplateName: String, propertyName: String, value: JsonNode) { + + val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES) + .append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) + .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() + put(path, value) + } + + override fun setNodeTemplateAttributeValue(nodeTemplateName: String, attributeName: String, value: JsonNode) { + + val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES) + .append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_ATTRIBUTES) + .append(BluePrintConstants.PATH_DIVIDER).append(attributeName).toString() + put(path, value) + } + + override fun setNodeTemplateOperationPropertyValue(nodeTemplateName: String, interfaceName: String, operationName: String, propertyName: String, + value: JsonNode) { + val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES) + .append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INTERFACES) + .append(BluePrintConstants.PATH_DIVIDER).append(interfaceName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OPERATIONS) + .append(BluePrintConstants.PATH_DIVIDER).append(operationName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) + .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() + log.trace("setting operation property path ({}), values ({})", path, value) + put(path, value) + } + + override fun setNodeTemplateOperationInputValue(nodeTemplateName: String, interfaceName: String, + operationName: String, propertyName: String, + value: JsonNode) { + val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES) + .append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INTERFACES) + .append(BluePrintConstants.PATH_DIVIDER).append(interfaceName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OPERATIONS) + .append(BluePrintConstants.PATH_DIVIDER).append(operationName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INPUTS) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) + .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() + put(path, value) + } + + override fun setNodeTemplateOperationOutputValue(nodeTemplateName: String, interfaceName: String, + operationName: String, propertyName: String, + value: JsonNode) { + val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES) + .append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INTERFACES) + .append(BluePrintConstants.PATH_DIVIDER).append(interfaceName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OPERATIONS) + .append(BluePrintConstants.PATH_DIVIDER).append(operationName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OUTPUTS) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) + .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() + put(path, value) + } + + + override fun getInputValue(propertyName: String): JsonNode { + val path = StringBuilder(BluePrintConstants.PATH_INPUTS) + .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() + return getJsonNode(path) + } + + override fun getNodeTemplateOperationOutputValue(nodeTemplateName: String, interfaceName: String, + operationName: String, propertyName: String): JsonNode { + val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES) + .append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_INTERFACES) + .append(BluePrintConstants.PATH_DIVIDER).append(interfaceName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OPERATIONS) + .append(BluePrintConstants.PATH_DIVIDER).append(operationName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_OUTPUTS) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) + .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() + return getJsonNode(path) + } + + override fun getNodeTemplatePropertyValue(nodeTemplateName: String, propertyName: String): JsonNode { + val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES) + .append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_PROPERTIES) + .append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString() + return getJsonNode(path) + } + + override fun getNodeTemplateAttributeValue(nodeTemplateName: String, attributeName: String): JsonNode { + val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES) + .append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_ATTRIBUTES) + .append(BluePrintConstants.PATH_DIVIDER).append(attributeName).toString() + return getJsonNode(path) + } + + override fun assignInputs(jsonNode: JsonNode) { + log.info("assignInputs from input JSON ({})", jsonNode.toString()) + bluePrintContext.inputs?.forEach { propertyName, property -> + val valueNode: JsonNode = jsonNode.at(BluePrintConstants.PATH_DIVIDER + propertyName) + ?: NullNode.getInstance() + setInputValue(propertyName, property, valueNode) + } + } + + override fun assignWorkflowInputs(workflowName: String, jsonNode: JsonNode) { + log.info("assign workflow {} input value ({})", workflowName, jsonNode.toString()) + + val dynamicInputPropertiesName = "$workflowName-properties" + + bluePrintContext.workflowByName(workflowName).inputs?.forEach { propertyName, property -> + if (propertyName != dynamicInputPropertiesName) { + val valueNode: JsonNode = jsonNode.at(BluePrintConstants.PATH_DIVIDER + propertyName) + ?: NullNode.getInstance() + setInputValue(propertyName, property, valueNode) + } + } + // Load Dynamic data Types + val workflowDynamicInputs: JsonNode? = jsonNode.get(dynamicInputPropertiesName) + + workflowDynamicInputs?.let { + bluePrintContext.dataTypeByName("dt-$dynamicInputPropertiesName")?.properties?.forEach { propertyName, property -> + val valueNode: JsonNode = workflowDynamicInputs.at(BluePrintConstants.PATH_DIVIDER + propertyName) + ?: NullNode.getInstance() + setInputValue(propertyName, property, valueNode) + + } + } + } + + override fun getJsonForNodeTemplateAttributeProperties(nodeTemplateName: String, keys: List): JsonNode { + + val jsonNode: ObjectNode = jacksonObjectMapper().createObjectNode() + val path: String = StringBuilder(BluePrintConstants.PATH_NODE_TEMPLATES) + .append(BluePrintConstants.PATH_DIVIDER).append(nodeTemplateName) + .append(BluePrintConstants.PATH_DIVIDER).append(BluePrintConstants.PATH_ATTRIBUTES) + .append(BluePrintConstants.PATH_DIVIDER).toString() + store.keys.filter { + it.startsWith(path) + }.map { + val key = it.replace(path, "") + if (keys.contains(key)) { + val value = store[it] as JsonNode + jsonNode.set(key, value) + } + } + return jsonNode + } + + +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintTemplateService.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintTemplateService.kt new file mode 100644 index 000000000..d175fddea --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintTemplateService.kt @@ -0,0 +1,94 @@ +/* + * 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.core.service + +import com.fasterxml.jackson.core.io.CharTypes +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.ObjectMapper +import com.fasterxml.jackson.databind.node.JsonNodeFactory +import com.fasterxml.jackson.databind.node.TextNode +import org.apache.commons.lang3.BooleanUtils +import org.apache.commons.lang3.StringUtils +import org.apache.velocity.VelocityContext +import org.apache.velocity.app.Velocity +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils +import java.io.StringWriter + +open class BluePrintTemplateService { + + companion object { + + /** + * Generate Content from Velocity Template and JSON Content. + */ + fun generateContent(template: String, json: String, + ignoreJsonNull: Boolean = false, + additionalContext: MutableMap = hashMapOf()): String { + Velocity.init() + val mapper = ObjectMapper() + val nodeFactory = BluePrintJsonNodeFactory() + mapper.setNodeFactory(nodeFactory) + + val jsonNode = mapper.readValue(json, JsonNode::class.java) + ?: throw BluePrintProcessorException("couldn't get json node from json") + + if (ignoreJsonNull) + JacksonUtils.removeJsonNullNode(jsonNode) + + val velocityContext = VelocityContext() + velocityContext.put("StringUtils", StringUtils::class.java) + velocityContext.put("BooleanUtils", BooleanUtils::class.java) + /** + * Add the Custom Velocity Context API + */ + additionalContext.forEach { name, value -> velocityContext.put(name, value) } + /** + * Add the JSON Data to the context + */ + jsonNode.fields().forEach { entry -> + velocityContext.put(entry.key, entry.value) + } + + val stringWriter = StringWriter() + Velocity.evaluate(velocityContext, stringWriter, "TemplateData", template) + stringWriter.flush() + return stringWriter.toString() + } + } +} + +/** + * Customise JsonNodeFactory adn TextNode, Since it introduces quotes for string data. + */ +open class BluePrintJsonNodeFactory : JsonNodeFactory() { + override fun textNode(text: String): TextNode { + return BluePrintTextNode(text) + } +} + +open class BluePrintTextNode(v: String) : TextNode(v) { + override fun toString(): String { + var len = this._value.length + len = len + 2 + (len shr 4) + val sb = StringBuilder(len) + CharTypes.appendQuoted(sb, this._value) + return sb.toString() + } + +} + diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt new file mode 100644 index 000000000..9ee53146b --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt @@ -0,0 +1,607 @@ +/* + * 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.core.service + +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import com.fasterxml.jackson.databind.JsonNode +import com.google.common.base.Preconditions +import org.apache.commons.lang3.StringUtils +import org.onap.ccsdk.apps.controllerblueprints.core.* +import org.onap.ccsdk.apps.controllerblueprints.core.data.* +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils +import java.io.Serializable + +/** + * + * + * @author Brinda Santh + */ +interface BluePrintValidatorService : Serializable { + + @Throws(BluePrintException::class) + fun validateBlueprint(bluePrintContext: BluePrintContext, properties: MutableMap) + + @Throws(BluePrintException::class) + fun validateBlueprint(serviceTemplate: ServiceTemplate, properties: MutableMap) +} + +open class BluePrintValidatorDefaultService : BluePrintValidatorService { + + val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintValidatorDefaultService::class.toString()) + + lateinit var bluePrintContext: BluePrintContext + lateinit var serviceTemplate: ServiceTemplate + lateinit var properties: MutableMap + var message: StringBuilder = StringBuilder() + private val separator: String = BluePrintConstants.PATH_DIVIDER + var paths: MutableList = arrayListOf() + + @Throws(BluePrintException::class) + override fun validateBlueprint(bluePrintContext: BluePrintContext, properties: MutableMap) { + validateBlueprint(bluePrintContext.serviceTemplate, properties) + } + + @Throws(BluePrintException::class) + override fun validateBlueprint(serviceTemplate: ServiceTemplate, properties: MutableMap) { + this.bluePrintContext = BluePrintContext(serviceTemplate) + this.serviceTemplate = serviceTemplate + this.properties = properties + try { + message.appendln("-> Config Blueprint") + serviceTemplate.metadata?.let { validateMetadata(serviceTemplate.metadata!!) } + serviceTemplate.artifactTypes?.let { validateArtifactTypes(serviceTemplate.artifactTypes!!) } + serviceTemplate.dataTypes?.let { validateDataTypes(serviceTemplate.dataTypes!!) } + serviceTemplate.nodeTypes?.let { validateNodeTypes(serviceTemplate.nodeTypes!!) } + serviceTemplate.topologyTemplate?.let { validateTopologyTemplate(serviceTemplate.topologyTemplate!!) } + } catch (e: Exception) { + log.error("validation failed in the path : {}", paths.joinToString(separator), e) + log.error("validation trace message :{} ", message) + throw BluePrintException(e, + format("failed to validate blueprint on path ({}) with message {}" + , paths.joinToString(separator), e.message)) + } + } + + @Throws(BluePrintException::class) + open fun validateMetadata(metaDataMap: MutableMap) { + paths.add("metadata") + + val templateName = metaDataMap[BluePrintConstants.METADATA_TEMPLATE_NAME] + val templateVersion = metaDataMap[BluePrintConstants.METADATA_TEMPLATE_VERSION] + val templateTags = metaDataMap[BluePrintConstants.METADATA_TEMPLATE_TAGS] + val templateAuthor = metaDataMap[BluePrintConstants.METADATA_TEMPLATE_AUTHOR] + + Preconditions.checkArgument(StringUtils.isNotBlank(templateName), "failed to get template name metadata") + Preconditions.checkArgument(StringUtils.isNotBlank(templateVersion), "failed to get template version metadata") + Preconditions.checkArgument(StringUtils.isNotBlank(templateTags), "failed to get template tags metadata") + Preconditions.checkArgument(StringUtils.isNotBlank(templateAuthor), "failed to get template author metadata") + paths.removeAt(paths.lastIndex) + } + + @Throws(BluePrintException::class) + open fun validateArtifactTypes(artifactTypes: MutableMap) { + paths.add("artifact_types") + artifactTypes.forEach { artifactName, artifactType -> + paths.add(artifactName) + message.appendln("--> Artifact Type :" + paths.joinToString(separator)) + artifactType.properties?.let { validatePropertyDefinitions(artifactType.properties!!) } + paths.removeAt(paths.lastIndex) + } + paths.removeAt(paths.lastIndex) + } + + @Throws(BluePrintException::class) + open fun validateDataTypes(dataTypes: MutableMap) { + paths.add("dataTypes") + dataTypes.forEach { dataTypeName, dataType -> + paths.add(dataTypeName) + message.appendln("--> DataType :" + paths.joinToString(separator)) + dataType.properties?.let { validatePropertyDefinitions(dataType.properties!!) } + paths.removeAt(paths.lastIndex) + } + paths.removeAt(paths.lastIndex) + } + + @Throws(BluePrintException::class) + open fun validateNodeTypes(nodeTypes: MutableMap) { + paths.add("nodeTypes") + nodeTypes.forEach { nodeTypeName, nodeType -> + // Validate Single Node Type + validateNodeType(nodeTypeName, nodeType) + } + paths.removeAt(paths.lastIndex) + } + + @Throws(BluePrintException::class) + open fun validateNodeType(nodeTypeName: String, nodeType: NodeType) { + paths.add(nodeTypeName) + message.appendln("--> Node Type :" + paths.joinToString(separator)) + val derivedFrom: String = nodeType.derivedFrom + //Check Derived From + checkValidNodeTypesDerivedFrom(nodeTypeName, derivedFrom) + + if (!BluePrintTypes.rootNodeTypes().contains(derivedFrom)) { + serviceTemplate.nodeTypes?.get(derivedFrom) + ?: throw BluePrintException(format("Failed to get derivedFrom NodeType({})'s for NodeType({}) ", + derivedFrom, nodeTypeName)) + } + + nodeType.properties?.let { validatePropertyDefinitions(nodeType.properties!!) } + nodeType.capabilities?.let { validateCapabilityDefinitions(nodeTypeName, nodeType) } + nodeType.requirements?.let { validateRequirementDefinitions(nodeTypeName, nodeType) } + nodeType.interfaces?.let { validateInterfaceDefinitions(nodeType.interfaces!!) } + paths.removeAt(paths.lastIndex) + } + + @Throws(BluePrintException::class) + open fun checkValidNodeTypesDerivedFrom(nodeTypeName: String, derivedFrom: String) { + check(BluePrintTypes.validNodeTypeDerivedFroms.contains(derivedFrom)) { + throw BluePrintException(format("Failed to get node type ({})'s derivedFrom({}) definition ", nodeTypeName, derivedFrom)) + } + } + + @Throws(BluePrintException::class) + open fun validateTopologyTemplate(topologyTemplate: TopologyTemplate) { + paths.add("topology") + message.appendln("--> Topology Template") + topologyTemplate.inputs?.let { validateInputs(topologyTemplate.inputs!!) } + topologyTemplate.nodeTemplates?.let { validateNodeTemplates(topologyTemplate.nodeTemplates!!) } + topologyTemplate.workflows?.let { validateWorkFlows(topologyTemplate.workflows!!) } + paths.removeAt(paths.lastIndex) + } + + @Throws(BluePrintException::class) + open fun validateInputs(inputs: MutableMap) { + paths.add("inputs") + message.appendln("---> Input :" + paths.joinToString(separator)) + validatePropertyDefinitions(inputs) + paths.removeAt(paths.lastIndex) + } + + @Throws(BluePrintException::class) + open fun validateNodeTemplates(nodeTemplates: MutableMap) { + paths.add("nodeTemplates") + nodeTemplates.forEach { nodeTemplateName, nodeTemplate -> + validateNodeTemplate(nodeTemplateName, nodeTemplate) + } + paths.removeAt(paths.lastIndex) + } + + @Throws(BluePrintException::class) + open fun validateNodeTemplate(nodeTemplateName: String, nodeTemplate: NodeTemplate) { + paths.add(nodeTemplateName) + message.appendln("---> NodeTemplate :" + paths.joinToString(separator)) + val type: String = nodeTemplate.type + + val nodeType: NodeType = serviceTemplate.nodeTypes?.get(type) + ?: throw BluePrintException(format("Failed to get NodeType({}) definition for NodeTemplate({})", type, nodeTemplateName)) + + nodeTemplate.artifacts?.let { validateArtifactDefinitions(nodeTemplate.artifacts!!) } + nodeTemplate.properties?.let { validatePropertyAssignments(nodeType.properties!!, nodeTemplate.properties!!) } + nodeTemplate.capabilities?.let { validateCapabilityAssignments(nodeType, nodeTemplateName, nodeTemplate) } + nodeTemplate.requirements?.let { validateRequirementAssignments(nodeType, nodeTemplateName, nodeTemplate) } + nodeTemplate.interfaces?.let { validateInterfaceAssignments(nodeType, nodeTemplateName, nodeTemplate) } + paths.removeAt(paths.lastIndex) + } + + @Throws(BluePrintException::class) + open fun validateArtifactDefinitions(artifacts: MutableMap) { + paths.add("artifacts") + artifacts.forEach { artifactDefinitionName, artifactDefinition -> + paths.add(artifactDefinitionName) + message.appendln("Validating artifact " + paths.joinToString(separator)) + val type: String = artifactDefinition.type + ?: throw BluePrintException(format("type is missing for ArtifactDefinition({})", artifactDefinitionName)) + // Check Artifact Type + checkValidArtifactType(artifactDefinitionName, type) + + val file: String = artifactDefinition.file + ?: throw BluePrintException(format("file is missing for ArtifactDefinition({})", artifactDefinitionName)) + + paths.removeAt(paths.lastIndex) + } + paths.removeAt(paths.lastIndex) + } + + @Throws(BluePrintException::class) + open fun validateWorkFlows(workflows: MutableMap) { + paths.add("workflows") + workflows.forEach { workflowName, workflow -> + + // Validate Single workflow + validateWorkFlow(workflowName, workflow) + } + paths.removeAt(paths.lastIndex) + } + + @Throws(BluePrintException::class) + open fun validateWorkFlow(workflowName: String, workflow: Workflow) { + paths.add(workflowName) + message.appendln("---> Workflow :" + paths.joinToString(separator)) + // Step Validation Start + paths.add("steps") + workflow.steps?.forEach { stepName, _ -> + paths.add(stepName) + message.appendln("----> Steps :" + paths.joinToString(separator)) + paths.removeAt(paths.lastIndex) + } + paths.removeAt(paths.lastIndex) + // Step Validation Ends + paths.removeAt(paths.lastIndex) + } + + @Throws(BluePrintException::class) + open fun validatePropertyDefinitions(properties: MutableMap) { + paths.add("properties") + properties.forEach { propertyName, propertyDefinition -> + paths.add(propertyName) + val dataType: String = propertyDefinition.type + when { + BluePrintTypes.validPrimitiveTypes().contains(dataType) -> { + // Do Nothing + } + BluePrintTypes.validCollectionTypes().contains(dataType) -> { + val entrySchemaType: String = propertyDefinition.entrySchema?.type + ?: throw BluePrintException(format("Entry schema for DataType ({}) for the property ({}) not found", dataType, propertyName)) + checkPrimitiveOrComplex(entrySchemaType, propertyName) + } + else -> checkPropertyDataType(dataType, propertyName) + } + message.appendln("property " + paths.joinToString(separator) + " of type " + dataType) + paths.removeAt(paths.lastIndex) + } + paths.removeAt(paths.lastIndex) + } + + @Throws(BluePrintException::class) + open fun validatePropertyAssignments(nodeTypeProperties: MutableMap, + properties: MutableMap) { + properties.forEach { propertyName, propertyAssignment -> + val propertyDefinition: PropertyDefinition = nodeTypeProperties[propertyName] + ?: throw BluePrintException(format("failed to get definition for the property ({})", propertyName)) + + validatePropertyAssignment(propertyName, propertyDefinition, propertyAssignment) + + } + } + + @Throws(BluePrintException::class) + open fun validatePropertyAssignment(propertyName: String, propertyDefinition: PropertyDefinition, + propertyAssignment: JsonNode) { + // Check and Validate if Expression Node + val expressionData = BluePrintExpressionService.getExpressionData(propertyAssignment) + if (!expressionData.isExpression) { + checkPropertyValue(propertyName, propertyDefinition, propertyAssignment) + } + } + + @Throws(BluePrintException::class) + open fun validateCapabilityAssignments(nodeType: NodeType, nodeTemplateName: String, nodeTemplate: NodeTemplate) { + val capabilities = nodeTemplate.capabilities + paths.add("capabilities") + capabilities?.forEach { capabilityName, capabilityAssignment -> + paths.add(capabilityName) + + val capabilityDefinition = nodeType.capabilities?.get(capabilityName) + ?: throw BluePrintException(format("Failed to get NodeTemplate({}) capability definition ({}) " + + "from NodeType({}) ", nodeTemplateName, capabilityName, nodeTemplate.type)) + + validateCapabilityAssignment(nodeTemplateName, capabilityName, capabilityDefinition, capabilityAssignment) + + paths.removeAt(paths.lastIndex) + } + paths.removeAt(paths.lastIndex) + } + + @Throws(BluePrintException::class) + open fun validateCapabilityAssignment(nodeTemplateName: String, capabilityName: String, + capabilityDefinition: CapabilityDefinition, capabilityAssignment: CapabilityAssignment) { + + capabilityAssignment.properties?.let { validatePropertyAssignments(capabilityDefinition.properties!!, capabilityAssignment.properties!!) } + + } + + @Throws(BluePrintException::class) + open fun validateRequirementAssignments(nodeType: NodeType, nodeTemplateName: String, nodeTemplate: NodeTemplate) { + val requirements = nodeTemplate.requirements + paths.add("requirements") + requirements?.forEach { requirementName, requirementAssignment -> + paths.add(requirementName) + val requirementDefinition = nodeType.requirements?.get(requirementName) + ?: throw BluePrintException(format("Failed to get NodeTemplate({}) requirement definition ({}) from" + + " NodeType({}) ", nodeTemplateName, requirementName, nodeTemplate.type)) + // Validate Requirement Assignment + validateRequirementAssignment(nodeTemplateName, requirementName, requirementDefinition, requirementAssignment) + paths.removeAt(paths.lastIndex) + } + paths.removeAt(paths.lastIndex) + + } + + @Throws(BluePrintException::class) + open fun validateRequirementAssignment(nodeTemplateName: String, requirementAssignmentName: String, + requirementDefinition: RequirementDefinition, requirementAssignment: RequirementAssignment) { + log.info("Validating NodeTemplate({}) requirement assignment ({}) ", nodeTemplateName, requirementAssignmentName) + val requirementNodeTemplateName = requirementAssignment.node!! + val capabilityName = requirementAssignment.capability + val relationship = requirementAssignment.relationship!! + + check(BluePrintTypes.validRelationShipDerivedFroms.contains(relationship)) { + throw BluePrintException(format("Failed to get relationship type ({}) for NodeTemplate({})'s requirement({}) ", + relationship, nodeTemplateName, requirementAssignmentName)) + } + + val relationShipNodeTemplate = serviceTemplate.topologyTemplate?.nodeTemplates?.get(requirementNodeTemplateName) + ?: throw BluePrintException(format("Failed to get requirement NodeTemplate({})'s for NodeTemplate({}) requirement({}) ", + requirementNodeTemplateName, nodeTemplateName, requirementAssignmentName)) + + relationShipNodeTemplate.capabilities?.get(capabilityName) + ?: throw BluePrintException(format("Failed to get requirement NodeTemplate({})'s capability({}) for NodeTemplate ({})'s requirement({}) ", + requirementNodeTemplateName, capabilityName, nodeTemplateName, requirementAssignmentName)) + + + } + + @Throws(BluePrintException::class) + open fun validateInterfaceAssignments(nodeType: NodeType, nodeTemplateName: String, nodeTemplate: NodeTemplate) { + + val interfaces = nodeTemplate.interfaces + paths.add("interfaces") + interfaces?.forEach { interfaceAssignmentName, interfaceAssignment -> + paths.add(interfaceAssignmentName) + val interfaceDefinition = nodeType.interfaces?.get(interfaceAssignmentName) + ?: throw BluePrintException(format("Failed to get NodeTemplate({}) interface definition ({}) from" + + " NodeType({}) ", nodeTemplateName, interfaceAssignmentName, nodeTemplate.type)) + + validateInterfaceAssignment(nodeTemplateName, interfaceAssignmentName, interfaceDefinition, + interfaceAssignment) + paths.removeAt(paths.lastIndex) + } + paths.removeAt(paths.lastIndex) + + + } + + @Throws(BluePrintException::class) + open fun validateInterfaceAssignment(nodeTemplateName: String, interfaceAssignmentName: String, + interfaceDefinition: InterfaceDefinition, + interfaceAssignment: InterfaceAssignment) { + + val operations = interfaceAssignment.operations + operations?.let { + validateInterfaceOperationsAssignment(nodeTemplateName, interfaceAssignmentName, interfaceDefinition, + interfaceAssignment) + } + + } + + @Throws(BluePrintException::class) + open fun validateInterfaceOperationsAssignment(nodeTemplateName: String, interfaceAssignmentName: String, + interfaceDefinition: InterfaceDefinition, + interfaceAssignment: InterfaceAssignment) { + + val operations = interfaceAssignment.operations + operations?.let { + it.forEach { operationAssignmentName, operationAssignments -> + + val operationDefinition = interfaceDefinition.operations?.get(operationAssignmentName) + ?: throw BluePrintException(format("Failed to get NodeTemplate({}) operation definition ({}) ", + nodeTemplateName, operationAssignmentName)) + + log.info("Validation NodeTemplate({}) Interface({}) Operation ({})", nodeTemplateName, + interfaceAssignmentName, operationAssignmentName) + + val inputs = operationAssignments.inputs + val outputs = operationAssignments.outputs + + inputs?.forEach { propertyName, propertyAssignment -> + val propertyDefinition = operationDefinition.inputs?.get(propertyName) + ?: throw BluePrintException(format("Failed to get NodeTemplate({}) operation definition ({}) " + + "property definition({})", nodeTemplateName, operationAssignmentName, propertyName)) + // Check the property values with property definition + validatePropertyAssignment(propertyName, propertyDefinition, propertyAssignment) + } + + outputs?.forEach { propertyName, propertyAssignment -> + val propertyDefinition = operationDefinition.outputs?.get(propertyName) + ?: throw BluePrintException(format("Failed to get NodeTemplate({}) operation definition ({}) " + + "output property definition({})", nodeTemplateName, operationAssignmentName, + propertyName)) + // Check the property values with property definition + validatePropertyAssignment(propertyName, propertyDefinition, propertyAssignment) + } + + } + } + + } + + @Throws(BluePrintException::class) + open fun validateCapabilityDefinitions(nodeTypeName: String, nodeType: NodeType) { + val capabilities = nodeType.capabilities + paths.add("capabilities") + capabilities?.forEach { capabilityName, capabilityDefinition -> + paths.add(capabilityName) + + validateCapabilityDefinition(nodeTypeName, nodeType, capabilityName, capabilityDefinition) + + paths.removeAt(paths.lastIndex) + } + paths.removeAt(paths.lastIndex) + } + + @Throws(BluePrintException::class) + open fun validateCapabilityDefinition(nodeTypeName: String, nodeType: NodeType, capabilityName: String, + capabilityDefinition: CapabilityDefinition) { + val capabilityType = capabilityDefinition.type + check(BluePrintTypes.validCapabilityTypes.contains(capabilityType)) { + throw BluePrintException(format("Failed to get CapabilityType({}) for NodeType({})", + capabilityType, nodeTypeName)) + } + } + + @Throws(BluePrintException::class) + open fun validateRequirementDefinitions(nodeName: String, nodeType: NodeType) { + paths.add("requirements") + val requirements = nodeType.requirements + + requirements?.forEach { requirementDefinitionName, requirementDefinition -> + paths.add(requirementDefinitionName) + message.appendln("Validating : " + paths.joinToString(separator)) + validateRequirementDefinition(nodeName, nodeType, requirementDefinitionName, requirementDefinition) + paths.removeAt(paths.lastIndex) + } + paths.removeAt(paths.lastIndex) + } + + @Throws(BluePrintException::class) + open fun validateRequirementDefinition(nodeTypeName: String, nodeType: NodeType, requirementDefinitionName: String, + requirementDefinition: RequirementDefinition) { + + log.info("Validating NodeType({}) RequirementDefinition ({}) ", nodeTypeName, requirementDefinitionName) + val requirementNodeTypeName = requirementDefinition.node!! + val capabilityName = requirementDefinition.capability + val relationship = requirementDefinition.relationship!! + + check(BluePrintTypes.validRelationShipDerivedFroms.contains(relationship)) { + throw BluePrintException(format("Failed to get relationship({}) for NodeType({})'s requirement({}) ", + relationship, nodeTypeName, requirementDefinitionName)) + } + + val relationShipNodeType = serviceTemplate.nodeTypes?.get(requirementNodeTypeName) + ?: throw BluePrintException(format("Failed to get requirement NodeType({})'s for requirement({}) ", + requirementNodeTypeName, requirementDefinitionName)) + + relationShipNodeType.capabilities?.get(capabilityName) + ?: throw BluePrintException(format("Failed to get requirement NodeType({})'s capability({}) for NodeType ({})'s requirement({}) ", + requirementNodeTypeName, capabilityName, nodeTypeName, requirementDefinitionName)) + + } + + + @Throws(BluePrintException::class) + open fun validateInterfaceDefinitions(interfaces: MutableMap) { + paths.add("interfaces") + interfaces.forEach { interfaceName, interfaceDefinition -> + paths.add(interfaceName) + message.appendln("Validating : " + paths.joinToString(separator)) + interfaceDefinition.operations?.let { validateOperationDefinitions(interfaceDefinition.operations!!) } + paths.removeAt(paths.lastIndex) + } + paths.removeAt(paths.lastIndex) + } + + @Throws(BluePrintException::class) + open fun validateOperationDefinitions(operations: MutableMap) { + paths.add("operations") + operations.forEach { opertaionName, operationDefinition -> + paths.add(opertaionName) + message.appendln("Validating : " + paths.joinToString(separator)) + operationDefinition.implementation?.let { validateImplementation(operationDefinition.implementation!!) } + operationDefinition.inputs?.let { validatePropertyDefinitions(operationDefinition.inputs!!) } + operationDefinition.outputs?.let { validatePropertyDefinitions(operationDefinition.outputs!!) } + paths.removeAt(paths.lastIndex) + } + paths.removeAt(paths.lastIndex) + } + + @Throws(BluePrintException::class) + open fun validateImplementation(implementation: Implementation) { + checkNotEmptyOrThrow(implementation.primary) + } + + @Throws(BluePrintException::class) + open fun checkValidArtifactType(artifactDefinitionName: String, artifactTypeName: String) { + + val artifactType = serviceTemplate.artifactTypes?.get(artifactTypeName) + ?: throw BluePrintException("failed to artifactType($artifactTypeName) for ArtifactDefinition($artifactDefinitionName)") + + checkValidArtifactTypeDerivedFrom(artifactTypeName, artifactType.derivedFrom) + } + + @Throws(BluePrintException::class) + open fun checkValidArtifactTypeDerivedFrom(artifactTypeName: String, derivedFrom: String) { + check(BluePrintTypes.validArtifactTypeDerivedFroms.contains(derivedFrom)) { + throw BluePrintException("failed to get artifactType($artifactTypeName)'s derivedFrom($derivedFrom) definition") + } + } + + @Throws(BluePrintException::class) + open fun checkValidDataTypeDerivedFrom(dataTypeName: String, derivedFrom: String) { + check(BluePrintTypes.validDataTypeDerivedFroms.contains(derivedFrom)) { + throw BluePrintException(format("Failed to get DataType({})'s derivedFrom({}) definition ", dataTypeName, derivedFrom)) + } + } + + @Throws(BluePrintException::class) + open fun checkValidRelationshipTypeDerivedFrom(relationshipTypeName: String, derivedFrom: String) { + check(BluePrintTypes.validRelationShipDerivedFroms.contains(derivedFrom)) { + throw BluePrintException(format("Failed to get relationship type ({})'s derivedFrom({}) definition ", relationshipTypeName, derivedFrom)) + } + } + + open fun checkPropertyValue(propertyName: String, propertyDefinition: PropertyDefinition, propertyAssignment: JsonNode) { + val propertyType = propertyDefinition.type + val isValid: Boolean + + if (BluePrintTypes.validPrimitiveTypes().contains(propertyType)) { + isValid = JacksonUtils.checkJsonNodeValueOfPrimitiveType(propertyType, propertyAssignment) + + } else if (BluePrintTypes.validCollectionTypes().contains(propertyType)) { + + val entrySchemaType = propertyDefinition.entrySchema?.type + ?: throw BluePrintException(format("Failed to get EntrySchema type for the collection property ({})", propertyName)) + + if (!BluePrintTypes.validPropertyTypes().contains(entrySchemaType)) { + checkPropertyDataType(entrySchemaType, propertyName) + } + isValid = JacksonUtils.checkJsonNodeValueOfCollectionType(propertyType, propertyAssignment) + } else { + checkPropertyDataType(propertyType, propertyName) + isValid = true + } + + check(isValid) { + throw BluePrintException(format("property({}) defined of type({}) is not comptable with the value ({})", + propertyName, propertyType, propertyAssignment)) + } + } + + private fun checkPropertyDataType(dataTypeName: String, propertyName: String) { + + val dataType = serviceTemplate.dataTypes?.get(dataTypeName) + ?: throw BluePrintException(format("DataType ({}) for the property ({}) not found", dataTypeName, propertyName)) + + checkValidDataTypeDerivedFrom(propertyName, dataType.derivedFrom) + + } + + private fun checkPrimitiveOrComplex(dataType: String, propertyName: String): Boolean { + if (BluePrintTypes.validPrimitiveTypes().contains(dataType) || checkDataType(dataType)) { + return true + } else { + throw BluePrintException(format("DataType({}) for the property({}) is not valid", dataType, propertyName)) + } + } + + private fun checkDataType(key: String): Boolean { + return serviceTemplate.dataTypes?.containsKey(key) ?: false + } + +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt new file mode 100644 index 000000000..81b7acb56 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt @@ -0,0 +1,210 @@ +/* + * 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.core.service + + +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.node.NullNode +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.core.data.* +import org.onap.ccsdk.apps.controllerblueprints.core.format +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils +import org.onap.ccsdk.apps.controllerblueprints.core.utils.ResourceResolverUtils + +/** + * + * + * @author Brinda Santh + */ +class PropertyAssignmentService(var bluePrintRuntimeService: BluePrintRuntimeService>) { + private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) + + private var bluePrintContext: BluePrintContext = bluePrintRuntimeService.bluePrintContext() + +/* + +If Property Assignment is Expression. + Get the Expression + Recursively resolve the expression + */ + + fun resolveAssignmentExpression(nodeTemplateName: String, assignmentName: String, + assignment: JsonNode): JsonNode { + val valueNode: JsonNode + log.trace("Assignment ({})", assignment) + val expressionData = BluePrintExpressionService.getExpressionData(assignment) + + if (expressionData.isExpression) { + valueNode = resolveExpression(nodeTemplateName, assignmentName, expressionData) + } else { + valueNode = expressionData.valueNode + } + return valueNode + } + + fun resolveExpression(nodeTemplateName: String, propName: String, expressionData: ExpressionData): JsonNode { + + var valueNode: JsonNode = NullNode.getInstance() + + if (expressionData.isExpression) { + val command = expressionData.command!! + + when (command) { + BluePrintConstants.EXPRESSION_GET_INPUT -> { + valueNode = bluePrintRuntimeService.getInputValue(expressionData.inputExpression?.propertyName!!) + } + BluePrintConstants.EXPRESSION_GET_ATTRIBUTE -> { + valueNode = resolveAttributeExpression(nodeTemplateName, expressionData.attributeExpression!!) + } + BluePrintConstants.EXPRESSION_GET_PROPERTY -> { + valueNode = resolvePropertyExpression(nodeTemplateName, expressionData.propertyExpression!!) + } + BluePrintConstants.EXPRESSION_GET_OPERATION_OUTPUT -> { + valueNode = resolveOperationOutputExpression(nodeTemplateName, expressionData.operationOutputExpression!!) + } + BluePrintConstants.EXPRESSION_GET_ARTIFACT -> { + valueNode = resolveArtifactExpression(nodeTemplateName, expressionData.artifactExpression!!) + } + BluePrintConstants.EXPRESSION_GET_NODE_OF_TYPE -> { + + } + else -> { + throw BluePrintException(format("for property ({}), command ({}) is not supported ", propName, command)) + } + } + } + return valueNode + } + + /* + get_property: [ , , , + , ..., ] + */ + fun resolveAttributeExpression(nodeTemplateName: String, attributeExpression: AttributeExpression): JsonNode { + val valueNode: JsonNode + + val attributeName = attributeExpression.attributeName + val subAttributeName: String? = attributeExpression.subAttributeName + + var attributeNodeTemplateName = nodeTemplateName + when (attributeExpression.modelableEntityName) { + "ENV" -> { + val environmentValue = System.getProperty(attributeName) + valueNode = JacksonUtils.jsonNode(environmentValue) + } + else -> { + if (!attributeExpression.modelableEntityName.equals("SELF", true)) { + attributeNodeTemplateName = attributeExpression.modelableEntityName + } + /* Enable in ONAP Dublin Release + val nodeTemplateAttributeExpression = bluePrintContext.nodeTemplateByName(attributeNodeTemplateName).attributes?.get(attributeName) + ?: throw BluePrintException(format("failed to get attribute definitions for node template " + + "({})'s property name ({}) ", nodeTemplateName, attributeName)) + + var attributeDefinition: AttributeDefinition = bluePrintContext.nodeTemplateNodeType(attributeNodeTemplateName).attributes?.get(attributeName)!! + + log.info("node template name ({}), property Name ({}) resolved value ({})", attributeNodeTemplateName, attributeName, nodeTemplateAttributeExpression) + */ + + valueNode = bluePrintRuntimeService.getNodeTemplateAttributeValue(attributeNodeTemplateName, attributeName) + ?: throw BluePrintException(format("failed to get node template ({})'s attribute ({}) ", nodeTemplateName, attributeName)) + } + + } +// subPropertyName?.let { +// valueNode = valueNode.at(JsonPointer.valueOf(subPropertyName)) +// } + return valueNode + } + + /* + get_property: [ , , , + , ..., ] + */ + fun resolvePropertyExpression(nodeTemplateName: String, propertyExpression: PropertyExpression): JsonNode { + val valueNode: JsonNode + + val propertyName = propertyExpression.propertyName + val subPropertyName: String? = propertyExpression.subPropertyName + + var propertyNodeTemplateName = nodeTemplateName + if (!propertyExpression.modelableEntityName.equals("SELF", true)) { + propertyNodeTemplateName = propertyExpression.modelableEntityName + } + + val nodeTemplatePropertyExpression = bluePrintContext.nodeTemplateByName(propertyNodeTemplateName).properties?.get(propertyName) + ?: throw BluePrintException(format("failed to get property definitions for node template ({})'s property name ({}) ", nodeTemplateName, propertyName)) + + var propertyDefinition: PropertyDefinition = bluePrintContext.nodeTemplateNodeType(propertyNodeTemplateName).properties?.get(propertyName)!! + + log.info("node template name ({}), property Name ({}) resolved value ({})", propertyNodeTemplateName, propertyName, nodeTemplatePropertyExpression) + + // Check it it is a nested expression + valueNode = resolveAssignmentExpression(propertyNodeTemplateName, propertyName, nodeTemplatePropertyExpression) + +// subPropertyName?.let { +// valueNode = valueNode.at(JsonPointer.valueOf(subPropertyName)) +// } + return valueNode + } + + /* + get_operation_output: , , , + */ + fun resolveOperationOutputExpression(nodeTemplateName: String, operationOutputExpression: OperationOutputExpression): JsonNode { + var outputNodeTemplateName = nodeTemplateName + if (!operationOutputExpression.modelableEntityName.equals("SELF", true)) { + outputNodeTemplateName = operationOutputExpression.modelableEntityName + } + return bluePrintRuntimeService.getNodeTemplateOperationOutputValue(outputNodeTemplateName, + operationOutputExpression.interfaceName, operationOutputExpression.operationName, + operationOutputExpression.propertyName) + } + + /* + get_artifact: [ , , , ] + */ + fun resolveArtifactExpression(nodeTemplateName: String, artifactExpression: ArtifactExpression): JsonNode { + + var artifactNodeTemplateName = nodeTemplateName + if (!artifactExpression.modelableEntityName.equals("SELF", true)) { + artifactNodeTemplateName = artifactExpression.modelableEntityName + } + val artifactDefinition: ArtifactDefinition = bluePrintContext.nodeTemplateByName(artifactNodeTemplateName) + .artifacts?.get(artifactExpression.artifactName) + ?: throw BluePrintException(format("failed to get artifact definitions for node template ({})'s " + + "artifact name ({}) ", nodeTemplateName, artifactExpression.artifactName)) + + return JacksonUtils.jsonNodeFromObject(artifactContent(artifactDefinition)) + } + + fun artifactContent(artifactDefinition: ArtifactDefinition): String { + val bluePrintBasePath: String = bluePrintContext.rootPath + + if (artifactDefinition.repository != null) { + TODO() + } else if (artifactDefinition.file != null) { + return ResourceResolverUtils.getFileContent(artifactDefinition.file!!, bluePrintBasePath) + } + return "" + } +} + diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintArchiveUtils.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintArchiveUtils.kt new file mode 100755 index 000000000..fe7929e85 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintArchiveUtils.kt @@ -0,0 +1,147 @@ +/* + * 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. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.utils + +import kotlinx.coroutines.async +import kotlinx.coroutines.runBlocking +import org.apache.commons.compress.archivers.zip.ZipArchiveEntry +import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream +import org.apache.commons.io.IOUtils +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException +import org.slf4j.LoggerFactory +import java.io.BufferedInputStream +import java.io.File +import java.io.FileInputStream +import java.io.IOException +import java.nio.charset.Charset +import java.util.zip.ZipFile + +class BluePrintArchiveUtils { + + companion object { + private val log = LoggerFactory.getLogger(BluePrintArchiveUtils::class.java) + + fun getFileContent(fileName: String): String = runBlocking { + async { + try { + File(fileName).readText(Charsets.UTF_8) + } catch (e: Exception) { + throw BluePrintException("couldn't find file($fileName)") + } + }.await() + } + + fun compress(source: String, destination: String, absolute: Boolean): Boolean { + val rootDir = File(source) + val saveFile = File(destination) + return compress(rootDir, saveFile, absolute) + } + + /** + * Create a new Zip from a root directory + * + * @param source the base directory + * @param destination the output filename + * @param absolute store absolute filepath (from directory) or only filename + * @return True if OK + */ + fun compress(source: File, destination: File, absolute: Boolean): Boolean { + try { + ZipArchiveOutputStream(destination).use { + recurseFiles(source, source, it, absolute) + } + } catch (e: Exception) { + log.error("Fail to compress folder(:$source) to path(${destination.path}", e) + return false + } + return true + } + + /** + * Recursive traversal to add files + * + * @param root + * @param file + * @param zaos + * @param absolute + * @throws IOException + */ + @Throws(IOException::class) + private fun recurseFiles(root: File, file: File, zaos: ZipArchiveOutputStream, + absolute: Boolean) { + if (file.isDirectory) { + // recursive call + val files = file.listFiles() + for (fileChild in files!!) { + recurseFiles(root, fileChild, zaos, absolute) + } + } else if (!file.name.endsWith(".zip") && !file.name.endsWith(".ZIP")) { + val filename = if (absolute) { + file.absolutePath.substring(root.absolutePath.length) + } else { + file.name + } + val zae = ZipArchiveEntry(filename) + zae.size = file.length() + zaos.putArchiveEntry(zae) + FileInputStream(file).use { IOUtils.copy(it, zaos) } + zaos.closeArchiveEntry() + } + } + + + fun deCompress(zipFile: File, targetPath: String): File { + val zip = ZipFile(zipFile, Charset.defaultCharset()) + val enumeration = zip.entries() + while (enumeration.hasMoreElements()) { + val entry = enumeration.nextElement() + val destFilePath = File(targetPath, entry.name) + destFilePath.parentFile.mkdirs() + + if (entry.isDirectory) + continue + + val bufferedIs = BufferedInputStream(zip.getInputStream(entry)) + bufferedIs.use { + destFilePath.outputStream().buffered(1024).use { bos -> + bufferedIs.copyTo(bos) + } + } + } + + val destinationDir = File(targetPath) + check(destinationDir.isDirectory && destinationDir.exists()) { + throw BluePrintProcessorException("failed to decompress blueprint(${zipFile.absolutePath}) to ($targetPath) ") + } + + return destinationDir + } + + /** + * Get the first item in directory + * + * @param zipFile + * @return string + */ + fun getFirstItemInDirectory(dir: File): String { + return dir.walk().map { it.name }.elementAt(1) + } + } + +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt new file mode 100755 index 000000000..9746bf579 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtils.kt @@ -0,0 +1,253 @@ +/* + * 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. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.utils + +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import kotlinx.coroutines.runBlocking +import org.apache.commons.io.FileUtils +import org.apache.commons.lang3.StringUtils +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.core.data.ErrorCode +import org.onap.ccsdk.apps.controllerblueprints.core.data.ImportDefinition +import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext +import java.io.File +import java.io.FileFilter +import java.nio.file.Files +import java.nio.file.Path +import java.nio.file.Paths +import java.nio.file.StandardOpenOption + + +class BluePrintFileUtils { + companion object { + + private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) + + fun createEmptyBluePrint(basePath: String) { + + val blueprintDir = File(basePath) + FileUtils.deleteDirectory(blueprintDir) + + Files.createDirectories(blueprintDir.toPath()) + + val metaDataDir = File(blueprintDir.absolutePath.plus(File.separator).plus(BluePrintConstants.TOSCA_METADATA_DIR)) + Files.createDirectories(metaDataDir.toPath()) + + val metaFile = File(blueprintDir.absolutePath.plus(File.separator).plus(BluePrintConstants + .TOSCA_METADATA_ENTRY_DEFINITION_FILE)) + Files.write(metaFile.toPath(), getMetaDataContent().toByteArray(), StandardOpenOption.CREATE_NEW) + + val definitionsDir = File(blueprintDir.absolutePath.plus(File.separator).plus(BluePrintConstants.TOSCA_DEFINITIONS_DIR)) + Files.createDirectories(definitionsDir.toPath()) + + val scriptsDir = File(blueprintDir.absolutePath.plus(File.separator).plus(BluePrintConstants.TOSCA_SCRIPTS_DIR)) + Files.createDirectories(scriptsDir.toPath()) + + val plansDir = File(blueprintDir.absolutePath.plus(File.separator).plus(BluePrintConstants.TOSCA_PLANS_DIR)) + Files.createDirectories(plansDir.toPath()) + + val templatesDir = File(blueprintDir.absolutePath.plus(File.separator).plus(BluePrintConstants.TOSCA_TEMPLATES_DIR)) + Files.createDirectories(templatesDir.toPath()) + + } + + fun copyBluePrint(sourcePath: String, targetPath: String) { + val sourceFile = File(sourcePath) + val targetFile = File(targetPath) + sourceFile.copyRecursively(targetFile, true) + } + + fun deleteBluePrintTypes(basePath: String) { + val definitionPath = basePath.plus(File.separator).plus(BluePrintConstants.TOSCA_DEFINITIONS_DIR) + log.info("deleting definition types under : $definitionPath") + + val definitionDir = File(definitionPath) + // Find the Type Definitions + val fileFilter = FileFilter { pathname -> pathname.absolutePath.endsWith("_types.json") } + // Delete the Type Files + definitionDir.listFiles(fileFilter).forEach { + Files.deleteIfExists(it.toPath()) + } + } + + fun writeEnhancedBluePrint(blueprintContext: BluePrintContext) { + + // Write Blueprint Types + writeBluePrintTypes(blueprintContext) + // Re Populate the Imports + populateDefaultImports(blueprintContext) + // Rewrite the Entry Definition Files + writeEntryDefinitionFile(blueprintContext) + + } + + fun writeBluePrintTypes(blueprintContext: BluePrintContext) { + + val basePath = blueprintContext.rootPath + val definitionPath = basePath.plus(File.separator).plus(BluePrintConstants.TOSCA_DEFINITIONS_DIR) + val definitionDir = File(definitionPath) + + check(definitionDir.exists()) { + throw BluePrintException(ErrorCode.BLUEPRINT_PATH_MISSING.value, "couldn't get definition file under " + + "path(${definitionDir.absolutePath})") + } + + blueprintContext.serviceTemplate.dataTypes?.let { + val dataTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_DATA_TYPES, it.toSortedMap(), true) + writeTypeFile(definitionDir.absolutePath, BluePrintConstants.PATH_DATA_TYPES, dataTypesContent) + } + + blueprintContext.serviceTemplate.relationshipTypes?.let { + val nodeTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_RELATIONSHIP_TYPES, it.toSortedMap(), true) + writeTypeFile(definitionDir.absolutePath, BluePrintConstants.PATH_RELATIONSHIP_TYPES, nodeTypesContent) + } + + blueprintContext.serviceTemplate.artifactTypes?.let { + val artifactTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_ARTIFACT_TYPES, it.toSortedMap(), true) + writeTypeFile(definitionDir.absolutePath, BluePrintConstants.PATH_ARTIFACT_TYPES, artifactTypesContent) + } + + blueprintContext.serviceTemplate.nodeTypes?.let { + val nodeTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_NODE_TYPES, it.toSortedMap(), true) + writeTypeFile(definitionDir.absolutePath, BluePrintConstants.PATH_NODE_TYPES, nodeTypesContent) + } + + blueprintContext.serviceTemplate.policyTypes?.let { + val nodeTypesContent = JacksonUtils.getWrappedJson(BluePrintConstants.PATH_POLICY_TYPES, it.toSortedMap(), true) + writeTypeFile(definitionDir.absolutePath, BluePrintConstants.PATH_POLICY_TYPES, nodeTypesContent) + } + } + + private fun populateDefaultImports(blueprintContext: BluePrintContext) { + // Get the Default Types + val types = arrayListOf(BluePrintConstants.PATH_DATA_TYPES, BluePrintConstants.PATH_RELATIONSHIP_TYPES, + BluePrintConstants.PATH_ARTIFACT_TYPES, BluePrintConstants.PATH_NODE_TYPES, + BluePrintConstants.PATH_POLICY_TYPES) + + // Clean Type Imports + cleanImportTypes(blueprintContext.serviceTemplate) + + val imports = mutableListOf() + types.forEach { typeName -> + val import = ImportDefinition() + import.file = BluePrintConstants.TOSCA_DEFINITIONS_DIR.plus("/$typeName.json") + imports.add(import) + } + + blueprintContext.serviceTemplate.imports = imports + } + + fun cleanImportTypes(serviceTemplate: ServiceTemplate) { + // Clean the Type imports + val toDeleteTypes = serviceTemplate.imports?.filter { + it.file.endsWith("_types.json") + } + + if (toDeleteTypes != null && toDeleteTypes.isNotEmpty()) { + serviceTemplate.imports?.removeAll(toDeleteTypes) + } + } + + /** + * Re Generate the Blueprint Service Template Definition file based on BluePrint Context. + */ + private fun writeEntryDefinitionFile(blueprintContext: BluePrintContext) { + + val absoluteEntryDefinitionFile = blueprintContext.rootPath.plus(File.separator).plus(blueprintContext.entryDefinition) + + val serviceTemplate = blueprintContext.serviceTemplate + + // Clone the Service Template + val writeServiceTemplate = serviceTemplate.clone() + writeServiceTemplate.dataTypes = null + writeServiceTemplate.artifactTypes = null + writeServiceTemplate.policyTypes = null + writeServiceTemplate.relationshipTypes = null + writeServiceTemplate.nodeTypes = null + + // Write the Service Template + writeDefinitionFile(absoluteEntryDefinitionFile, JacksonUtils.getJson(writeServiceTemplate, true)) + } + + fun writeDefinitionFile(definitionFileName: String, content: String) = runBlocking { + val definitionFile = File(definitionFileName) + // Delete the File If exists + Files.deleteIfExists(definitionFile.toPath()) + + Files.write(definitionFile.toPath(), content.toByteArray(), StandardOpenOption.CREATE_NEW) + check(definitionFile.exists()) { + throw BluePrintException(ErrorCode.BLUEPRINT_WRITING_FAIL.value, "couldn't write definition file under " + + "path(${definitionFile.absolutePath})") + } + } + + private fun writeTypeFile(definitionPath: String, type: String, content: String) = runBlocking { + val typeFile = File(definitionPath.plus(File.separator).plus("$type.json")) + + Files.write(typeFile.toPath(), content.toByteArray(), StandardOpenOption.CREATE_NEW) + check(typeFile.exists()) { + throw BluePrintException(ErrorCode.BLUEPRINT_WRITING_FAIL.value, "couldn't write $type.json file under " + + "path(${typeFile.absolutePath})") + } + } + + private fun getMetaDataContent(): String { + return "TOSCA-Meta-File-Version: 1.0.0" + + "\nCSAR-Version: " + + "\nCreated-By: " + + "\nEntry-Definitions: Definitions/.json" + + "\nTemplate-Tags: " + } + + + fun getBluePrintFile(fileName: String, targetPath: Path) : File { + val filePath = targetPath.resolve(fileName).toString() + val file = File(filePath) + check(file.exists()) { + throw BluePrintException(ErrorCode.BLUEPRINT_PATH_MISSING.value, "couldn't get definition file under " + + "path(${file.absolutePath})") + } + return file + } + + fun getCbaStorageDirectory(path: String): Path { + check(StringUtils.isNotBlank(path)) { + throw BluePrintException(ErrorCode.BLUEPRINT_PATH_MISSING.value, "couldn't get " + + "Blueprint folder under path($path)") + } + + val fileStorageLocation = Paths.get(path).toAbsolutePath().normalize() + + if (!Files.exists(fileStorageLocation)) + Files.createDirectories(fileStorageLocation) + + return fileStorageLocation + } + + fun stripFileExtension(fileName: String): String { + val dotIndexe = fileName.lastIndexOf('.') + + // In case dot is in first position, we are dealing with a hidden file rather than an extension + return if (dotIndexe > 0) fileName.substring(0, dotIndexe) else fileName + } + + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt new file mode 100644 index 000000000..7764bc192 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt @@ -0,0 +1,144 @@ +/* + * 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.core.utils + + +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import com.fasterxml.jackson.databind.JsonNode +import org.apache.commons.io.FileUtils +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.apps.controllerblueprints.core.asJsonPrimitive +import org.onap.ccsdk.apps.controllerblueprints.core.data.ToscaMetaData +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintImportService +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService +import org.onap.ccsdk.apps.controllerblueprints.core.service.DefaultBluePrintRuntimeService +import java.io.File +import java.nio.charset.Charset + +class BluePrintMetadataUtils { + companion object { + private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) + + + fun toscaMetaData(basePath: String): ToscaMetaData { + val toscaMetaPath = basePath.plus(BluePrintConstants.PATH_DIVIDER) + .plus(BluePrintConstants.TOSCA_METADATA_ENTRY_DEFINITION_FILE) + return toscaMetaDataFromMetaFile(toscaMetaPath) + } + + fun entryDefinitionFile(basePath: String): String { + val toscaMetaPath = basePath.plus(BluePrintConstants.PATH_DIVIDER) + .plus(BluePrintConstants.TOSCA_METADATA_ENTRY_DEFINITION_FILE) + return toscaMetaDataFromMetaFile(toscaMetaPath).entityDefinitions + } + + fun toscaMetaDataFromMetaFile(metaFilePath: String): ToscaMetaData { + val toscaMetaData = ToscaMetaData() + val lines: MutableList = FileUtils.readLines(File(metaFilePath), Charset.defaultCharset()) + lines.forEach { line -> + if (line.contains(":")) { + val keyValue = line.split(":") + if (keyValue.size == 2) { + val value: String = keyValue[1].trim() + when (keyValue[0]) { + "TOSCA-Meta-File-Version" -> toscaMetaData.toscaMetaFileVersion = value + "CSAR-Version" -> toscaMetaData.csarVersion = value + "Created-By" -> toscaMetaData.createdBy = value + "Entry-Definitions" -> toscaMetaData.entityDefinitions = value + "Template-Tags" -> toscaMetaData.templateTags = value + } + } + } + + } + return toscaMetaData + } + + fun getBluePrintRuntime(id: String, blueprintBasePath: String): BluePrintRuntimeService> { + + val bluePrintContext: BluePrintContext = getBluePrintContext(blueprintBasePath) + + val context: MutableMap = hashMapOf() + context[BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] = blueprintBasePath.asJsonPrimitive() + context[BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID] = id.asJsonPrimitive() + + val bluePrintRuntimeService = DefaultBluePrintRuntimeService(id, bluePrintContext) + bluePrintRuntimeService.setExecutionContext(context) + + return bluePrintRuntimeService + } + + fun getBaseEnhancementBluePrintRuntime(id: String, blueprintBasePath: String): BluePrintRuntimeService> { + + val bluePrintContext: BluePrintContext = getBaseEnhancementBluePrintContext(blueprintBasePath) + val context: MutableMap = hashMapOf() + context[BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] = blueprintBasePath.asJsonPrimitive() + context[BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID] = id.asJsonPrimitive() + + val bluePrintRuntimeService = DefaultBluePrintRuntimeService(id, bluePrintContext) + bluePrintRuntimeService.setExecutionContext(context) + + return bluePrintRuntimeService + } + + fun getBluePrintRuntime(id: String, blueprintBasePath: String, executionContext: MutableMap): BluePrintRuntimeService> { + val bluePrintContext: BluePrintContext = getBluePrintContext(blueprintBasePath) + val bluePrintRuntimeService = DefaultBluePrintRuntimeService(id, bluePrintContext) + bluePrintRuntimeService.setExecutionContext(executionContext) + return bluePrintRuntimeService + } + + fun getBluePrintContext(blueprintBasePath: String): BluePrintContext { + + val toscaMetaData: ToscaMetaData = toscaMetaData(blueprintBasePath) + + log.info("Reading blueprint path($blueprintBasePath) and entry definition file (${toscaMetaData.entityDefinitions})") + + return readBlueprintFile(toscaMetaData.entityDefinitions, blueprintBasePath) + } + + private fun getBaseEnhancementBluePrintContext(blueprintBasePath: String): BluePrintContext { + val toscaMetaData: ToscaMetaData = toscaMetaData(blueprintBasePath) + // Clean Type files + BluePrintFileUtils.deleteBluePrintTypes(blueprintBasePath) + val rootFilePath: String = blueprintBasePath.plus(File.separator).plus(toscaMetaData.entityDefinitions) + val rootServiceTemplate = ServiceTemplateUtils.getServiceTemplate(rootFilePath) + + // Clean the Import Definitions + BluePrintFileUtils.cleanImportTypes(rootServiceTemplate) + + val blueprintContext = BluePrintContext(rootServiceTemplate) + blueprintContext.rootPath = blueprintBasePath + blueprintContext.entryDefinition = toscaMetaData.entityDefinitions + return blueprintContext + } + + private fun readBlueprintFile(entityDefinitions: String, basePath: String): BluePrintContext { + val rootFilePath: String = basePath.plus(File.separator).plus(entityDefinitions) + val rootServiceTemplate = ServiceTemplateUtils.getServiceTemplate(rootFilePath) + // Recursively Import Template files + val schemaImportResolverUtils = BluePrintImportService(rootServiceTemplate, basePath) + val completeServiceTemplate = schemaImportResolverUtils.getImportResolvedServiceTemplate() + val blueprintContext = BluePrintContext(completeServiceTemplate) + blueprintContext.rootPath = basePath + blueprintContext.entryDefinition = entityDefinitions + return blueprintContext + } + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintRuntimeUtils.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintRuntimeUtils.kt new file mode 100644 index 000000000..c37d8eeaa --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintRuntimeUtils.kt @@ -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.core.utils + +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.node.NullNode +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext + +/** + * + * + * @author Brinda Santh + */ +object BluePrintRuntimeUtils { + private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) + + fun assignInputsFromFile(bluePrintContext: BluePrintContext, fileName: String, context: MutableMap) { + val jsonNode: JsonNode = JacksonUtils.jsonNodeFromFile(fileName) + return assignInputs(bluePrintContext, jsonNode, context) + } + + fun assignInputsFromClassPathFile(bluePrintContext: BluePrintContext, fileName: String, context: MutableMap) { + val jsonNode = JacksonUtils.jsonNodeFromClassPathFile(fileName) + return assignInputs(bluePrintContext, jsonNode, context) + } + + fun assignInputsFromContent(bluePrintContext: BluePrintContext, content: String, context: MutableMap) { + val jsonNode: JsonNode = JacksonUtils.jsonNode(content) + return assignInputs(bluePrintContext, jsonNode, context) + } + + fun assignInputs(bluePrintContext: BluePrintContext, jsonNode: JsonNode, context: MutableMap) { + log.info("assignInputs from input JSON ({})", jsonNode.toString()) + bluePrintContext.inputs?.forEach { propertyName, _ -> + val valueNode: JsonNode = jsonNode.at("/".plus(propertyName)) ?: NullNode.getInstance() + + val path = BluePrintConstants.PATH_INPUTS.plus(BluePrintConstants.PATH_DIVIDER).plus(propertyName) + log.trace("setting input path ({}), values ({})", path, valueNode) + context[path] = valueNode + } + } + +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtils.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtils.kt new file mode 100644 index 000000000..0522e1f5e --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonReactorUtils.kt @@ -0,0 +1,109 @@ +/* + * 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.core.utils + +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper +import reactor.core.publisher.Mono +import reactor.core.publisher.toMono + +@Deprecated("Reactor will be replaced by coroutines by default") +object JacksonReactorUtils { + private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) + + @JvmStatic + fun getContent(fileName: String): Mono { + return JacksonUtils.getContent(fileName).toMono() + } + + @JvmStatic + fun getClassPathFileContent(fileName: String): Mono { + return JacksonUtils.getClassPathFileContent(fileName).toMono() + } + + @JvmStatic + fun readValue(content: String, valueType: Class): Mono { + return Mono.just(jacksonObjectMapper().readValue(content, valueType)) + } + + @JvmStatic + fun jsonNode(content: String): Mono { + return Mono.just(jacksonObjectMapper().readTree(content)) + } + + @JvmStatic + fun getJson(any: kotlin.Any, pretty: Boolean = false): Mono { + return Mono.just(JacksonUtils.getJson(any, pretty)) + } + + @JvmStatic + fun getListFromJson(content: String, valueType: Class): Mono> { + val objectMapper = jacksonObjectMapper() + val javaType = objectMapper.typeFactory.constructCollectionType(List::class.java, valueType) + return objectMapper.readValue>(content, javaType).toMono() + } + + @JvmStatic + fun readValueFromFile(fileName: String, valueType: Class): Mono { + return getContent(fileName) + .flatMap { content -> + readValue(content, valueType) + } + } + + @JvmStatic + fun readValueFromClassPathFile(fileName: String, valueType: Class): Mono { + return getClassPathFileContent(fileName) + .flatMap { content -> + readValue(content, valueType) + } + } + + @JvmStatic + fun jsonNodeFromFile(fileName: String): Mono { + return getContent(fileName) + .flatMap { content -> + jsonNode(content) + } + } + + @JvmStatic + fun jsonNodeFromClassPathFile(fileName: String): Mono { + return getClassPathFileContent(fileName) + .flatMap { content -> + jsonNode(content) + } + } + + @JvmStatic + fun getListFromFile(fileName: String, valueType: Class): Mono> { + return getContent(fileName) + .flatMap { content -> + getListFromJson(content, valueType) + } + } + + @JvmStatic + fun getListFromClassPathFile(fileName: String, valueType: Class): Mono> { + return getClassPathFileContent(fileName) + .flatMap { content -> + getListFromJson(content, valueType) + } + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt new file mode 100644 index 000000000..75310ee89 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt @@ -0,0 +1,287 @@ +/* + * 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.core.utils + +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import com.fasterxml.jackson.annotation.JsonInclude +import com.fasterxml.jackson.core.type.TypeReference +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializationFeature +import com.fasterxml.jackson.databind.node.ArrayNode +import com.fasterxml.jackson.databind.node.NullNode +import com.fasterxml.jackson.databind.node.ObjectNode +import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.async +import kotlinx.coroutines.runBlocking +import kotlinx.coroutines.withContext +import org.apache.commons.io.IOUtils +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes +import java.io.File +import java.nio.charset.Charset + +/** + * + * + * @author Brinda Santh + */ +class JacksonUtils { + companion object { + private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) + inline fun readValue(content: String): T = + jacksonObjectMapper().readValue(content, T::class.java) + + fun readValue(content: String, valueType: Class): T? { + return jacksonObjectMapper().readValue(content, valueType) + } + + fun readValue(node: JsonNode, valueType: Class): T? { + return jacksonObjectMapper().treeToValue(node, valueType) + } + + fun removeJsonNullNode(node: JsonNode) { + val it = node.iterator() + while (it.hasNext()) { + val child = it.next() + if (child.isNull) { + it.remove() + } else { + removeJsonNullNode(child) + } + } + } + + fun getContent(fileName: String): String = runBlocking { + async { + try { + File(fileName).readText(Charsets.UTF_8) + } catch (e: Exception) { + throw BluePrintException("couldn't get file ($fileName) content : ${e.message}") + } + }.await() + } + + fun getClassPathFileContent(fileName: String): String { + return runBlocking { + withContext(Dispatchers.Default) { + IOUtils.toString(JacksonUtils::class.java.classLoader + .getResourceAsStream(fileName), Charset.defaultCharset()) + } + } + } + + fun readValueFromFile(fileName: String, valueType: Class): T? { + val content: String = getContent(fileName) + return readValue(content, valueType) + } + + fun readValueFromClassPathFile(fileName: String, valueType: Class): T? { + val content: String = getClassPathFileContent(fileName) + return readValue(content, valueType) + } + + fun jsonNodeFromObject(from: kotlin.Any): JsonNode { + return jacksonObjectMapper().convertValue(from, JsonNode::class.java) + } + + fun jsonNodeFromClassPathFile(fileName: String): JsonNode { + val content: String = getClassPathFileContent(fileName) + return jsonNode(content) + } + + fun jsonNodeFromFile(fileName: String): JsonNode { + val content: String = getContent(fileName) + return jsonNode(content) + } + + fun jsonNode(content: String): JsonNode { + return jacksonObjectMapper().readTree(content) + } + + fun getJson(any: kotlin.Any): String { + return getJson(any, false) + } + + fun getWrappedJson(wrapper: String, any: kotlin.Any, pretty: Boolean = false): String { + val wrapperMap = hashMapOf() + wrapperMap[wrapper] = any + return getJson(wrapperMap, pretty) + } + + fun getJson(any: kotlin.Any, pretty: Boolean = false): String { + val objectMapper = jacksonObjectMapper() + objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL) + if (pretty) { + objectMapper.enable(SerializationFeature.INDENT_OUTPUT) + } + return objectMapper.writeValueAsString(any) + } + + fun getJsonNode(any: kotlin.Any?, pretty: Boolean = false): JsonNode { + val objectMapper = jacksonObjectMapper() + objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL) + if (pretty) { + objectMapper.enable(SerializationFeature.INDENT_OUTPUT) + } + return objectMapper.valueToTree(any) + } + + fun getListFromJsonNode(node: JsonNode, valueType: Class): List? { + return getListFromJson(node.toString(), valueType) + } + + fun getListFromJson(content: String, valueType: Class): List? { + val objectMapper = jacksonObjectMapper() + val javaType = objectMapper.typeFactory.constructCollectionType(List::class.java, valueType) + return objectMapper.readValue>(content, javaType) + } + + fun getListFromFile(fileName: String, valueType: Class): List? { + val content: String = getContent(fileName) + return getListFromJson(content, valueType) + } + + fun getListFromClassPathFile(fileName: String, valueType: Class): List? { + val content: String = getClassPathFileContent(fileName) + return getListFromJson(content, valueType) + } + + fun getMapFromJson(content: String, valueType: Class): MutableMap? { + val objectMapper = jacksonObjectMapper() + val typeRef = object : TypeReference>() {} + return objectMapper.readValue(content, typeRef) + } + + fun getMapFromFile(fileName: String, valueType: Class): MutableMap? { + val content: String = getContent(fileName) + return getMapFromJson(content, valueType) + } + + fun getInstanceFromMap(properties: MutableMap, classType: Class): T { + return readValue(getJson(properties), classType) + ?: throw BluePrintProcessorException("failed to transform content ($properties) to type ($classType)") + } + + fun checkJsonNodeValueOfType(type: String, jsonNode: JsonNode): Boolean { + if (BluePrintTypes.validPrimitiveTypes().contains(type.toLowerCase())) { + return checkJsonNodeValueOfPrimitiveType(type, jsonNode) + } else if (BluePrintTypes.validCollectionTypes().contains(type)) { + return checkJsonNodeValueOfCollectionType(type, jsonNode) + } + return false + } + + fun checkIfPrimitiveType(primitiveType: String): Boolean { + return when (primitiveType.toLowerCase()) { + BluePrintConstants.DATA_TYPE_STRING -> true + BluePrintConstants.DATA_TYPE_BOOLEAN -> true + BluePrintConstants.DATA_TYPE_INTEGER -> true + BluePrintConstants.DATA_TYPE_FLOAT -> true + BluePrintConstants.DATA_TYPE_DOUBLE -> true + BluePrintConstants.DATA_TYPE_TIMESTAMP -> true + else -> false + } + } + + fun checkJsonNodeValueOfPrimitiveType(primitiveType: String, jsonNode: JsonNode): Boolean { + return when (primitiveType.toLowerCase()) { + BluePrintConstants.DATA_TYPE_STRING -> jsonNode.isTextual + BluePrintConstants.DATA_TYPE_BOOLEAN -> jsonNode.isBoolean + BluePrintConstants.DATA_TYPE_INTEGER -> jsonNode.isInt + BluePrintConstants.DATA_TYPE_FLOAT -> jsonNode.isDouble + BluePrintConstants.DATA_TYPE_DOUBLE -> jsonNode.isDouble + BluePrintConstants.DATA_TYPE_TIMESTAMP -> jsonNode.isTextual + else -> false + } + } + + fun checkJsonNodeValueOfCollectionType(type: String, jsonNode: JsonNode): Boolean { + return when (type.toLowerCase()) { + BluePrintConstants.DATA_TYPE_LIST -> jsonNode.isArray + BluePrintConstants.DATA_TYPE_MAP -> jsonNode.isContainerNode + else -> false + } + } + + fun populatePrimitiveValues(key: String, value: Any, primitiveType: String, objectNode: ObjectNode) { + when (primitiveType.toLowerCase()) { + BluePrintConstants.DATA_TYPE_BOOLEAN -> objectNode.put(key, value as Boolean) + BluePrintConstants.DATA_TYPE_INTEGER -> objectNode.put(key, value as Int) + BluePrintConstants.DATA_TYPE_FLOAT -> objectNode.put(key, value as Float) + BluePrintConstants.DATA_TYPE_DOUBLE -> objectNode.put(key, value as Double) + BluePrintConstants.DATA_TYPE_TIMESTAMP -> objectNode.put(key, value as String) + else -> objectNode.put(key, value as String) + } + } + + fun populatePrimitiveValues(value: Any, primitiveType: String, arrayNode: ArrayNode) { + when (primitiveType.toLowerCase()) { + BluePrintConstants.DATA_TYPE_BOOLEAN -> arrayNode.add(value as Boolean) + BluePrintConstants.DATA_TYPE_INTEGER -> arrayNode.add(value as Int) + BluePrintConstants.DATA_TYPE_FLOAT -> arrayNode.add(value as Float) + BluePrintConstants.DATA_TYPE_DOUBLE -> arrayNode.add(value as Double) + BluePrintConstants.DATA_TYPE_TIMESTAMP -> arrayNode.add(value as String) + else -> arrayNode.add(value as String) + } + } + + fun populatePrimitiveDefaultValues(key: String, primitiveType: String, objectNode: ObjectNode) { + when (primitiveType.toLowerCase()) { + BluePrintConstants.DATA_TYPE_BOOLEAN -> objectNode.put(key, false) + BluePrintConstants.DATA_TYPE_INTEGER -> objectNode.put(key, 0) + BluePrintConstants.DATA_TYPE_FLOAT -> objectNode.put(key, 0.0) + BluePrintConstants.DATA_TYPE_DOUBLE -> objectNode.put(key, 0.0) + else -> objectNode.put(key, "") + } + } + + fun populatePrimitiveDefaultValuesForArrayNode(primitiveType: String, arrayNode: ArrayNode) { + when (primitiveType.toLowerCase()) { + BluePrintConstants.DATA_TYPE_BOOLEAN -> arrayNode.add(false) + BluePrintConstants.DATA_TYPE_INTEGER -> arrayNode.add(0) + BluePrintConstants.DATA_TYPE_FLOAT -> arrayNode.add(0.0) + BluePrintConstants.DATA_TYPE_DOUBLE -> arrayNode.add(0.0) + else -> arrayNode.add("") + } + } + + fun populateJsonNodeValues(key: String, nodeValue: JsonNode?, type: String, objectNode: ObjectNode) { + if (nodeValue == null || nodeValue is NullNode) { + objectNode.set(key, nodeValue) + } else if (BluePrintTypes.validPrimitiveTypes().contains(type)) { + populatePrimitiveValues(key, nodeValue, type, objectNode) + } else { + objectNode.set(key, nodeValue) + } + } + + fun convertPrimitiveResourceValue(type: String, value: String): JsonNode { + return when (type.toLowerCase()) { + BluePrintConstants.DATA_TYPE_BOOLEAN -> jsonNodeFromObject(java.lang.Boolean.valueOf(value)) + BluePrintConstants.DATA_TYPE_INTEGER -> jsonNodeFromObject(Integer.valueOf(value)) + BluePrintConstants.DATA_TYPE_FLOAT -> jsonNodeFromObject(java.lang.Float.valueOf(value)) + BluePrintConstants.DATA_TYPE_DOUBLE -> jsonNodeFromObject(java.lang.Double.valueOf(value)) + else -> getJsonNode(value) + } + } + + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/ResourceResolverUtils.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/ResourceResolverUtils.kt new file mode 100644 index 000000000..965e965c6 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/ResourceResolverUtils.kt @@ -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.core.utils + +import org.apache.commons.io.FileUtils +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmpty +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import java.io.File +import java.net.URL +import java.nio.charset.Charset +/** + * + * + * @author Brinda Santh + */ +object ResourceResolverUtils { + private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) + + @JvmStatic + fun getFileContent(filename : String, basePath : String?): String { + log.trace("file ({}), basePath ({}) ", filename, basePath) + try{ + var resolvedFileName : String = filename + if(filename.startsWith("http", true) + || filename.startsWith("https", true)){ + val givenUrl : String = URL(filename).toString() + val systemUrl : String = File(".").toURI().toURL().toString() + log.trace("givenUrl ({}), systemUrl ({}) ", givenUrl, systemUrl) + if(givenUrl.startsWith(systemUrl)){ + + } + }else{ + if(!filename.startsWith("/")){ + if (checkNotEmpty(basePath)) { + resolvedFileName = basePath.plus(File.separator).plus(filename) + }else{ + resolvedFileName = javaClass.classLoader.getResource(".").path.plus(filename) + } + } + } + return FileUtils.readFileToString(File(resolvedFileName), Charset.defaultCharset()) + }catch (e : Exception){ + throw BluePrintException(e, "failed to file (%s), basePath (%s) ", filename, basePath) + } + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/ServiceTemplateUtils.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/ServiceTemplateUtils.kt new file mode 100644 index 000000000..933161323 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/ServiceTemplateUtils.kt @@ -0,0 +1,110 @@ +/* + * 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.core.utils + +import org.apache.commons.io.FileUtils +import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate +import org.onap.ccsdk.apps.controllerblueprints.core.data.TopologyTemplate +import java.io.File +import java.nio.charset.Charset + +/** + * + * + * @author Brinda Santh + */ +object ServiceTemplateUtils { + + @JvmStatic + fun getServiceTemplate(fileName: String): ServiceTemplate { + val content: String = FileUtils.readFileToString(File(fileName), Charset.defaultCharset()) + return getServiceTemplateFromContent(content) + } + + + @JvmStatic + fun getServiceTemplateFromContent(content: String): ServiceTemplate { + return JacksonUtils.readValue(content) + } + + fun merge(parentServiceTemplate: ServiceTemplate, toMerge: ServiceTemplate, removeImports: Boolean? = true): ServiceTemplate { + if (removeImports!!) { + parentServiceTemplate.imports = null + toMerge.imports = null + } + + toMerge.metadata?.let { + parentServiceTemplate.metadata = parentServiceTemplate.metadata ?: hashMapOf() + parentServiceTemplate.metadata?.putAll(toMerge.metadata as MutableMap) + } + + toMerge.dslDefinitions?.let { + parentServiceTemplate.dslDefinitions = parentServiceTemplate.dslDefinitions ?: hashMapOf() + parentServiceTemplate.dslDefinitions?.putAll(toMerge.dslDefinitions as MutableMap) + } + + toMerge.dataTypes?.let { + parentServiceTemplate.dataTypes = parentServiceTemplate.dataTypes ?: hashMapOf() + parentServiceTemplate.dataTypes?.putAll(toMerge.dataTypes as MutableMap) + } + + toMerge.nodeTypes?.let { + parentServiceTemplate.nodeTypes = parentServiceTemplate.nodeTypes ?: hashMapOf() + parentServiceTemplate.nodeTypes?.putAll(toMerge.nodeTypes as MutableMap) + } + + toMerge.artifactTypes?.let { + parentServiceTemplate.artifactTypes = parentServiceTemplate.artifactTypes ?: hashMapOf() + parentServiceTemplate.artifactTypes?.putAll(toMerge.artifactTypes as MutableMap) + } + + toMerge.repositories?.let { + parentServiceTemplate.repositories = parentServiceTemplate.repositories ?: hashMapOf() + parentServiceTemplate.repositories?.putAll(toMerge.repositories as MutableMap) + } + + parentServiceTemplate.topologyTemplate = parentServiceTemplate.topologyTemplate ?: TopologyTemplate() + + toMerge.topologyTemplate?.inputs?.let { + parentServiceTemplate.topologyTemplate?.inputs = parentServiceTemplate.topologyTemplate?.inputs ?: hashMapOf() + parentServiceTemplate.topologyTemplate?.inputs?.putAll(parentServiceTemplate.topologyTemplate?.inputs as MutableMap) + } + + toMerge.topologyTemplate?.nodeTemplates?.let { + parentServiceTemplate.topologyTemplate?.nodeTemplates = parentServiceTemplate.topologyTemplate?.nodeTemplates ?: hashMapOf() + parentServiceTemplate.topologyTemplate?.nodeTemplates?.putAll(parentServiceTemplate.topologyTemplate?.nodeTemplates as MutableMap) + } + + toMerge.topologyTemplate?.relationshipTemplates?.let { + parentServiceTemplate.topologyTemplate?.relationshipTemplates = parentServiceTemplate.topologyTemplate?.relationshipTemplates ?: hashMapOf() + parentServiceTemplate.topologyTemplate?.relationshipTemplates?.putAll(parentServiceTemplate.topologyTemplate?.relationshipTemplates as MutableMap) + } + + toMerge.topologyTemplate?.policies?.let { + parentServiceTemplate.topologyTemplate?.policies = parentServiceTemplate.topologyTemplate?.policies ?: hashMapOf() + parentServiceTemplate.topologyTemplate?.policies?.putAll(parentServiceTemplate.topologyTemplate?.policies as MutableMap) + } + + toMerge.topologyTemplate?.workflows?.let { + parentServiceTemplate.topologyTemplate?.workflows = parentServiceTemplate.topologyTemplate?.workflows ?: hashMapOf() + parentServiceTemplate.topologyTemplate?.workflows?.putAll(parentServiceTemplate.topologyTemplate?.workflows as MutableMap) + } + return parentServiceTemplate + } + + +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/TopologicalSortingUtils.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/TopologicalSortingUtils.kt new file mode 100644 index 000000000..b3adab085 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/TopologicalSortingUtils.kt @@ -0,0 +1,131 @@ +/* + * 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.core.utils + +import java.util.* + +/** + * + * + * @author Brinda Santh + */ +class TopologicalSortingUtils { + + private val neighbors: MutableMap> = hashMapOf() + + val isDag: Boolean + get() = topSort() != null + + override fun toString(): String { + val s = StringBuffer() + for (v in neighbors.keys) + s.append("\n " + v + " -> " + neighbors[v]) + return s.toString() + } + + fun getNeighbors(): Map> { + return neighbors + } + + fun add(vertex: V) { + if (neighbors.containsKey(vertex)) + return + neighbors[vertex] = arrayListOf() + } + + operator fun contains(vertex: V): Boolean { + return neighbors.containsKey(vertex) + } + + fun add(from: V, to: V) { + this.add(from) + this.add(to) + neighbors[from]?.add(to) + } + + fun remove(from: V, to: V) { + if (!(this.contains(from) && this.contains(to))) + throw IllegalArgumentException("Nonexistent vertex") + neighbors[from]?.remove(to) + } + + fun outDegree(): Map { + val result: MutableMap = hashMapOf() + for (v in neighbors.keys) + result[v] = neighbors[v]!!.size + return result + } + + + fun inDegree(): MutableMap { + val result = HashMap() + for (v in neighbors.keys) + result[v] = 0 // All in-degrees are 0 + for (from in neighbors.keys) { + for (to in neighbors[from]!!) { + result[to] = result[to]!! + 1 // Increment in-degree + } + } + return result + } + + fun topSort(): List? { + val degree = inDegree() + // Determine all vertices with zero in-degree + val zeroVerts = Stack() // Stack as good as any here + for (v in degree.keys) { + if (degree[v] == 0) zeroVerts.push(v) + } + // Determine the topological order + val result = ArrayList() + while (!zeroVerts.isEmpty()) { + val v = zeroVerts.pop() // Choose a vertex with zero in-degree + result.add(v) // Vertex v is next in topol order + // "Remove" vertex v by updating its neighbors + for (neighbor in neighbors[v]!!) { + degree[neighbor] = degree[neighbor]!! - 1 + // Remember any vertices that now have zero in-degree + if (degree[neighbor] == 0) zeroVerts.push(neighbor) + } + } + // Check that we have used the entire graph (if not, there was a cycle) + return if (result.size != neighbors.size) null else result + } + + + fun bfsDistance(start: V): Map<*, *> { + val distance: MutableMap = hashMapOf() + // Initially, all distance are infinity, except start node + for (v in neighbors.keys) + distance[v] = -1 + distance[start] = 0 + // Process nodes in queue order + val queue = LinkedList() + queue.offer(start) // Place start node in queue + while (!queue.isEmpty()) { + val v = queue.remove() + val vDist = distance[v]!! + // Update neighbors + for (neighbor in neighbors[v]!!) { + if (distance[neighbor] != null) continue // Ignore if already done + distance[neighbor] = vDist + 1 + queue.offer(neighbor) + } + } + return distance + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintArtifactTypeValidatorImpl.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintArtifactTypeValidatorImpl.kt new file mode 100644 index 000000000..e383588ee --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintArtifactTypeValidatorImpl.kt @@ -0,0 +1,33 @@ +/* + * 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.core.validation + +import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactType +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintArtifactTypeValidator +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService + +open class BluePrintArtifactTypeValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintArtifactTypeValidator { + + override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, artifactType: ArtifactType) { + + artifactType.properties?.let { + bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintRuntimeService, artifactType.properties!!) + } + // TODO ("Files Present ") + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintAttributeDefinitionValidatorImpl.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintAttributeDefinitionValidatorImpl.kt new file mode 100644 index 000000000..53a27b53d --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintAttributeDefinitionValidatorImpl.kt @@ -0,0 +1,29 @@ +/* + * 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.core.validation + +import org.onap.ccsdk.apps.controllerblueprints.core.data.AttributeDefinition +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintAttributeDefinitionValidator +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService + +open class BluePrintAttributeDefinitionValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintAttributeDefinitionValidator { + + override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, type: AttributeDefinition) { + //TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintDataTypeValidatorImpl.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintDataTypeValidatorImpl.kt new file mode 100644 index 000000000..980302bf9 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintDataTypeValidatorImpl.kt @@ -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.core.validation + +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import org.onap.ccsdk.apps.controllerblueprints.core.data.DataType +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintDataTypeValidator +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService + +open class BluePrintDataTypeValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintDataTypeValidator { + private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintDataTypeValidatorImpl::class.toString()) + + override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, dataType: DataType) { + log.trace("Validating DataType($name)") + + dataType.properties?.let { + + bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintRuntimeService, dataType.properties!!) + } + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTemplateValidatorImpl.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTemplateValidatorImpl.kt new file mode 100644 index 000000000..0ed87f813 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTemplateValidatorImpl.kt @@ -0,0 +1,298 @@ +/* + * 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.core.validation + +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import com.fasterxml.jackson.databind.JsonNode +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 org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintNodeTemplateValidator +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintExpressionService +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils + + +open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintNodeTemplateValidator { + + private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintNodeTemplateValidatorImpl::class.toString()) + + lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*> + lateinit var bluePrintContext: BluePrintContext + var paths: MutableList = arrayListOf() + + override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String, nodeTemplate: NodeTemplate) { + log.info("Validating NodeTemplate($nodeTemplateName)") + + this.bluePrintRuntimeService = bluePrintRuntimeService + this.bluePrintContext = bluePrintRuntimeService.bluePrintContext() + + paths.add(nodeTemplateName) + + val type: String = nodeTemplate.type + + val nodeType: NodeType = bluePrintContext.serviceTemplate.nodeTypes?.get(type) + ?: throw BluePrintException("Failed to get NodeType($type) definition for NodeTemplate($nodeTemplateName)") + + nodeTemplate.properties?.let { validatePropertyAssignments(nodeType.properties!!, nodeTemplate.properties!!) } + nodeTemplate.capabilities?.let { validateCapabilityAssignments(nodeType, nodeTemplateName, nodeTemplate) } + nodeTemplate.requirements?.let { validateRequirementAssignments(nodeType, nodeTemplateName, nodeTemplate) } + nodeTemplate.interfaces?.let { validateInterfaceAssignments(nodeType, nodeTemplateName, nodeTemplate) } + nodeTemplate.artifacts?.let { validateArtifactDefinitions(nodeTemplate.artifacts!!) } + + paths.removeAt(paths.lastIndex) + } + + @Throws(BluePrintException::class) + open fun validateArtifactDefinitions(artifacts: MutableMap) { + paths.add("artifacts") + artifacts.forEach { artifactDefinitionName, artifactDefinition -> + paths.add(artifactDefinitionName) + val type: String = artifactDefinition.type + ?: throw BluePrintException("type is missing for ArtifactDefinition$artifactDefinitionName)") + // Check Artifact Type + checkValidArtifactType(artifactDefinitionName, type) + + val file: String = artifactDefinition.file + ?: throw BluePrintException("file is missing for ArtifactDefinition($artifactDefinitionName)") + + paths.removeAt(paths.lastIndex) + } + paths.removeAt(paths.lastIndex) + } + + + @Throws(BluePrintException::class) + open fun validatePropertyAssignments(nodeTypeProperties: MutableMap, + properties: MutableMap) { + properties.forEach { propertyName, propertyAssignment -> + val propertyDefinition: PropertyDefinition = nodeTypeProperties[propertyName] + ?: throw BluePrintException("failed to get definition for the property ($propertyName)") + + validatePropertyAssignment(propertyName, propertyDefinition, propertyAssignment) + + } + } + + @Throws(BluePrintException::class) + open fun validatePropertyAssignment(propertyName: String, propertyDefinition: PropertyDefinition, + propertyAssignment: JsonNode) { + // Check and Validate if Expression Node + val expressionData = BluePrintExpressionService.getExpressionData(propertyAssignment) + if (!expressionData.isExpression) { + checkPropertyValue(propertyName, propertyDefinition, propertyAssignment) + } + } + + @Throws(BluePrintException::class) + open fun validateCapabilityAssignments(nodeType: NodeType, nodeTemplateName: String, nodeTemplate: NodeTemplate) { + val capabilities = nodeTemplate.capabilities + paths.add("capabilities") + capabilities?.forEach { capabilityName, capabilityAssignment -> + paths.add(capabilityName) + + val capabilityDefinition = nodeType.capabilities?.get(capabilityName) + ?: throw BluePrintException("Failed to get NodeTemplate($nodeTemplateName) capability definition ($capabilityName) " + + "from NodeType(${nodeTemplate.type})") + + validateCapabilityAssignment(nodeTemplateName, capabilityName, capabilityDefinition, capabilityAssignment) + + paths.removeAt(paths.lastIndex) + } + paths.removeAt(paths.lastIndex) + } + + @Throws(BluePrintException::class) + open fun validateCapabilityAssignment(nodeTemplateName: String, capabilityName: String, + capabilityDefinition: CapabilityDefinition, capabilityAssignment: CapabilityAssignment) { + + capabilityAssignment.properties?.let { validatePropertyAssignments(capabilityDefinition.properties!!, capabilityAssignment.properties!!) } + + } + + @Throws(BluePrintException::class) + open fun validateRequirementAssignments(nodeType: NodeType, nodeTemplateName: String, nodeTemplate: NodeTemplate) { + val requirements = nodeTemplate.requirements + paths.add("requirements") + requirements?.forEach { requirementName, requirementAssignment -> + paths.add(requirementName) + val requirementDefinition = nodeType.requirements?.get(requirementName) + ?: throw BluePrintException("Failed to get NodeTemplate($nodeTemplateName) requirement definition ($requirementName) from" + + " NodeType(${nodeTemplate.type})") + // Validate Requirement Assignment + validateRequirementAssignment(nodeTemplateName, requirementName, requirementDefinition, requirementAssignment) + paths.removeAt(paths.lastIndex) + } + paths.removeAt(paths.lastIndex) + + } + + @Throws(BluePrintException::class) + open fun validateRequirementAssignment(nodeTemplateName: String, requirementAssignmentName: String, + requirementDefinition: RequirementDefinition, requirementAssignment: RequirementAssignment) { + log.info("Validating NodeTemplate({}) requirement assignment ({}) ", nodeTemplateName, requirementAssignmentName) + val requirementNodeTemplateName = requirementAssignment.node!! + val capabilityName = requirementAssignment.capability + val relationship = requirementAssignment.relationship!! + + check(BluePrintTypes.validRelationShipDerivedFroms.contains(relationship)) { + throw BluePrintException("Failed to get relationship type ($relationship) for NodeTemplate($nodeTemplateName)'s requirement($requirementAssignmentName)") + } + + val relationShipNodeTemplate = bluePrintContext.serviceTemplate.topologyTemplate?.nodeTemplates?.get(requirementNodeTemplateName) + ?: throw BluePrintException("Failed to get requirement NodeTemplate($requirementNodeTemplateName)'s " + + "for NodeTemplate($nodeTemplateName) requirement($requirementAssignmentName)") + + relationShipNodeTemplate.capabilities?.get(capabilityName) + ?: throw BluePrintException("Failed to get requirement NodeTemplate($requirementNodeTemplateName)'s " + + "capability($capabilityName) for NodeTemplate ($nodeTemplateName)'s requirement($requirementAssignmentName)") + + + } + + @Throws(BluePrintException::class) + open fun validateInterfaceAssignments(nodeType: NodeType, nodeTemplateName: String, nodeTemplate: NodeTemplate) { + + val interfaces = nodeTemplate.interfaces + paths.add("interfaces") + interfaces?.forEach { interfaceAssignmentName, interfaceAssignment -> + paths.add(interfaceAssignmentName) + val interfaceDefinition = nodeType.interfaces?.get(interfaceAssignmentName) + ?: throw BluePrintException("Failed to get NodeTemplate($nodeTemplateName) interface definition ($interfaceAssignmentName) from" + + " NodeType(${nodeTemplate.type})") + + validateInterfaceAssignment(nodeTemplateName, interfaceAssignmentName, interfaceDefinition, + interfaceAssignment) + paths.removeAt(paths.lastIndex) + } + paths.removeAt(paths.lastIndex) + + + } + + @Throws(BluePrintException::class) + open fun validateInterfaceAssignment(nodeTemplateName: String, interfaceAssignmentName: String, + interfaceDefinition: InterfaceDefinition, + interfaceAssignment: InterfaceAssignment) { + + val operations = interfaceAssignment.operations + operations?.let { + validateInterfaceOperationsAssignment(nodeTemplateName, interfaceAssignmentName, interfaceDefinition, + interfaceAssignment) + } + + } + + @Throws(BluePrintException::class) + open fun validateInterfaceOperationsAssignment(nodeTemplateName: String, interfaceAssignmentName: String, + interfaceDefinition: InterfaceDefinition, + interfaceAssignment: InterfaceAssignment) { + + val operations = interfaceAssignment.operations + operations?.let { + it.forEach { operationAssignmentName, operationAssignments -> + + val operationDefinition = interfaceDefinition.operations?.get(operationAssignmentName) + ?: throw BluePrintException("Failed to get NodeTemplate($nodeTemplateName) operation definition ($operationAssignmentName)") + + log.info("Validation NodeTemplate($nodeTemplateName) Interface($interfaceAssignmentName) Operation ($operationAssignmentName)") + + val inputs = operationAssignments.inputs + val outputs = operationAssignments.outputs + + inputs?.forEach { propertyName, propertyAssignment -> + val propertyDefinition = operationDefinition.inputs?.get(propertyName) + ?: throw BluePrintException("Failed to get NodeTemplate($nodeTemplateName) operation " + + "definition ($operationAssignmentName) property definition($propertyName)") + // Check the property values with property definition + validatePropertyAssignment(propertyName, propertyDefinition, propertyAssignment) + } + + outputs?.forEach { propertyName, propertyAssignment -> + val propertyDefinition = operationDefinition.outputs?.get(propertyName) + ?: throw BluePrintException("Failed to get NodeTemplate($nodeTemplateName) operation definition ($operationAssignmentName) " + + "output property definition($propertyName)") + // Check the property values with property definition + validatePropertyAssignment(propertyName, propertyDefinition, propertyAssignment) + } + + } + } + + } + + open fun checkValidArtifactType(artifactDefinitionName: String, artifactTypeName: String) { + + val artifactType = bluePrintContext.serviceTemplate.artifactTypes?.get(artifactTypeName) + ?: throw BluePrintException("failed to get artifactType($artifactTypeName) for ArtifactDefinition($artifactDefinitionName)") + + checkValidArtifactTypeDerivedFrom(artifactTypeName, artifactType.derivedFrom) + } + + @Throws(BluePrintException::class) + open fun checkValidArtifactTypeDerivedFrom(artifactTypeName: String, derivedFrom: String) { + check(BluePrintTypes.validArtifactTypeDerivedFroms.contains(derivedFrom)) { + throw BluePrintException("failed to get artifactType($artifactTypeName)'s derivedFrom($derivedFrom) definition") + } + } + + open fun checkPropertyValue(propertyName: String, propertyDefinition: PropertyDefinition, propertyAssignment: JsonNode) { + val propertyType = propertyDefinition.type + val isValid: Boolean + + if (BluePrintTypes.validPrimitiveTypes().contains(propertyType)) { + isValid = JacksonUtils.checkJsonNodeValueOfPrimitiveType(propertyType, propertyAssignment) + + } else if (BluePrintTypes.validCollectionTypes().contains(propertyType)) { + + val entrySchemaType = propertyDefinition.entrySchema?.type + ?: throw BluePrintException(format("Failed to get EntrySchema type for the collection property ({})", propertyName)) + + if (!BluePrintTypes.validPropertyTypes().contains(entrySchemaType)) { + checkPropertyDataType(entrySchemaType, propertyName) + } + isValid = JacksonUtils.checkJsonNodeValueOfCollectionType(propertyType, propertyAssignment) + } else { + checkPropertyDataType(propertyType, propertyName) + isValid = true + } + + check(isValid) { + throw BluePrintException("property(propertyName) defined of type(propertyType) is not comptable with the value (propertyAssignment)") + } + } + + private fun checkPropertyDataType(dataTypeName: String, propertyName: String) { + + val dataType = bluePrintContext.serviceTemplate.dataTypes?.get(dataTypeName) + ?: throw BluePrintException("DataType ($dataTypeName) for the property ($propertyName) not found") + + checkValidDataTypeDerivedFrom(propertyName, dataType.derivedFrom) + + } + + private fun checkValidDataTypeDerivedFrom(dataTypeName: String, derivedFrom: String) { + check(BluePrintTypes.validDataTypeDerivedFroms.contains(derivedFrom)) { + throw BluePrintException("Failed to get DataType($dataTypeName)'s derivedFrom($derivedFrom) definition ") + } + } + +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTypeValidatorImpl.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTypeValidatorImpl.kt new file mode 100644 index 000000000..1077f347e --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTypeValidatorImpl.kt @@ -0,0 +1,155 @@ +/* + * 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.core.validation + +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.core.BluePrintTypes +import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmptyOrThrow +import org.onap.ccsdk.apps.controllerblueprints.core.data.* +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintNodeTypeValidator +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService + + +open class BluePrintNodeTypeValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintNodeTypeValidator { + + private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString()) + + lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*> + lateinit var bluePrintContext: BluePrintContext + var paths: MutableList = arrayListOf() + + override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTypeName: String, nodeType: NodeType) { + log.trace("Validating NodeType($nodeTypeName)") + this.bluePrintRuntimeService = bluePrintRuntimeService + this.bluePrintContext = bluePrintRuntimeService.bluePrintContext() + + paths.add(nodeTypeName) + + val derivedFrom: String = nodeType.derivedFrom + //Check Derived From + checkValidNodeTypesDerivedFrom(nodeTypeName, derivedFrom) + + if (!BluePrintTypes.rootNodeTypes().contains(derivedFrom)) { + bluePrintContext.serviceTemplate.nodeTypes?.get(derivedFrom) + ?: throw BluePrintException("Failed to get derivedFrom NodeType($derivedFrom)'s for NodeType($nodeTypeName)") + } + + nodeType.properties?.let { bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintRuntimeService, nodeType.properties!!) } + nodeType.capabilities?.let { validateCapabilityDefinitions(nodeTypeName, nodeType) } + nodeType.requirements?.let { validateRequirementDefinitions(nodeTypeName, nodeType) } + nodeType.interfaces?.let { validateInterfaceDefinitions(nodeType.interfaces!!) } + + paths.removeAt(paths.lastIndex) + } + + fun checkValidNodeTypesDerivedFrom(nodeTypeName: String, derivedFrom: String) { + check(BluePrintTypes.validNodeTypeDerivedFroms.contains(derivedFrom)) { + throw BluePrintException("Failed to get node type ($nodeTypeName)'s derivedFrom($derivedFrom) definition ") + } + } + + open fun validateCapabilityDefinitions(nodeTypeName: String, nodeType: NodeType) { + val capabilities = nodeType.capabilities + paths.add("capabilities") + capabilities?.forEach { capabilityName, capabilityDefinition -> + paths.add(capabilityName) + + validateCapabilityDefinition(nodeTypeName, nodeType, capabilityName, capabilityDefinition) + + paths.removeAt(paths.lastIndex) + } + paths.removeAt(paths.lastIndex) + } + + open fun validateCapabilityDefinition(nodeTypeName: String, nodeType: NodeType, capabilityName: String, + capabilityDefinition: CapabilityDefinition) { + val capabilityType = capabilityDefinition.type + check(BluePrintTypes.validCapabilityTypes.contains(capabilityType)) { + throw BluePrintException("failed to get CapabilityType($capabilityType) for NodeType($nodeTypeName)") + } + } + + open fun validateRequirementDefinitions(nodeName: String, nodeType: NodeType) { + paths.add("requirements") + val requirements = nodeType.requirements + + requirements?.forEach { requirementDefinitionName, requirementDefinition -> + paths.add(requirementDefinitionName) + validateRequirementDefinition(nodeName, nodeType, requirementDefinitionName, requirementDefinition) + paths.removeAt(paths.lastIndex) + } + paths.removeAt(paths.lastIndex) + } + + open fun validateRequirementDefinition(nodeTypeName: String, nodeType: NodeType, requirementDefinitionName: String, + requirementDefinition: RequirementDefinition) { + + log.info("validating NodeType({}) RequirementDefinition ({}) ", nodeTypeName, requirementDefinitionName) + val requirementNodeTypeName = requirementDefinition.node!! + val capabilityName = requirementDefinition.capability + val relationship = requirementDefinition.relationship!! + + check(BluePrintTypes.validRelationShipDerivedFroms.contains(relationship)) { + throw BluePrintException("failed to get relationship($relationship) for NodeType($nodeTypeName)'s requirement($requirementDefinitionName)") + } + + val relationShipNodeType = bluePrintContext.serviceTemplate.nodeTypes?.get(requirementNodeTypeName) + ?: throw BluePrintException("failed to get requirement NodeType($requirementNodeTypeName)'s for requirement($requirementDefinitionName) ") + + relationShipNodeType.capabilities?.get(capabilityName) + ?: throw BluePrintException("failed to get requirement NodeType($requirementNodeTypeName)'s " + + "capability($nodeTypeName) for NodeType ($capabilityName)'s requirement($requirementDefinitionName) ") + + } + + open fun validateInterfaceDefinitions(interfaces: MutableMap) { + paths.add("interfaces") + interfaces.forEach { interfaceName, interfaceDefinition -> + paths.add(interfaceName) + interfaceDefinition.operations?.let { validateOperationDefinitions(interfaceDefinition.operations!!) } + paths.removeAt(paths.lastIndex) + } + paths.removeAt(paths.lastIndex) + } + + open fun validateOperationDefinitions(operations: MutableMap) { + paths.add("operations") + operations.forEach { opertaionName, operationDefinition -> + paths.add(opertaionName) + operationDefinition.implementation?.let { validateImplementation(operationDefinition.implementation!!) } + + operationDefinition.inputs?.let { + bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintRuntimeService, operationDefinition.inputs!!) + } + + operationDefinition.outputs?.let { + bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintRuntimeService, operationDefinition.outputs!!) + } + paths.removeAt(paths.lastIndex) + } + paths.removeAt(paths.lastIndex) + } + + open fun validateImplementation(implementation: Implementation) { + checkNotEmptyOrThrow(implementation.primary) + } + +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintPropertyDefinitionValidatorImpl.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintPropertyDefinitionValidatorImpl.kt new file mode 100644 index 000000000..ca156190c --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintPropertyDefinitionValidatorImpl.kt @@ -0,0 +1,83 @@ +/* + * 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.core.validation + +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.core.BluePrintTypes +import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition +import org.onap.ccsdk.apps.controllerblueprints.core.format +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintPropertyDefinitionValidator +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService + +open class BluePrintPropertyDefinitionValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintPropertyDefinitionValidator { + + private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString()) + + lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*> + + + override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, propertyDefinition: PropertyDefinition) { + this.bluePrintRuntimeService = bluePrintRuntimeService + + + log.trace("Validating PropertyDefinition($name)") + + val dataType: String = propertyDefinition.type + + when { + BluePrintTypes.validPrimitiveTypes().contains(dataType) -> { + // Do Nothing + } + BluePrintTypes.validCollectionTypes().contains(dataType) -> { + val entrySchemaType: String = propertyDefinition.entrySchema?.type + ?: throw BluePrintException(format("Entry schema for DataType ({}) for the property ({}) not found", dataType, name)) + checkPrimitiveOrComplex(entrySchemaType, name) + } + else -> checkPropertyDataType(dataType, name) + } + } + + + private fun checkPrimitiveOrComplex(dataType: String, propertyName: String): Boolean { + if (BluePrintTypes.validPrimitiveTypes().contains(dataType) || checkDataType(dataType)) { + return true + } else { + throw BluePrintException(format("DataType({}) for the property({}) is not valid", dataType, propertyName)) + } + } + + private fun checkPropertyDataType(dataTypeName: String, propertyName: String) { + + val dataType = bluePrintRuntimeService.bluePrintContext().serviceTemplate.dataTypes?.get(dataTypeName) + ?: throw BluePrintException(format("DataType ({}) for the property ({}) not found", dataTypeName, propertyName)) + + checkValidDataTypeDerivedFrom(propertyName, dataType.derivedFrom) + } + + private fun checkDataType(key: String): Boolean { + return bluePrintRuntimeService.bluePrintContext().serviceTemplate.dataTypes?.containsKey(key) ?: false + } + + open fun checkValidDataTypeDerivedFrom(dataTypeName: String, derivedFrom: String) { + check(BluePrintTypes.validDataTypeDerivedFroms.contains(derivedFrom)) { + throw BluePrintException(format("Failed to get DataType({})'s derivedFrom({}) definition ", dataTypeName, derivedFrom)) + } + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintServiceTemplateValidatorImpl.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintServiceTemplateValidatorImpl.kt new file mode 100644 index 000000000..61159cf8b --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintServiceTemplateValidatorImpl.kt @@ -0,0 +1,107 @@ +/* + * 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.core.validation + +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import com.google.common.base.Preconditions +import org.apache.commons.lang3.StringUtils +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError +import org.onap.ccsdk.apps.controllerblueprints.core.data.* +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintServiceTemplateValidator +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService + +open class BluePrintServiceTemplateValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintServiceTemplateValidator { + + private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString()) + + lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*> + lateinit var error: BluePrintError + + var paths: MutableList = arrayListOf() + + override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, serviceTemplate: ServiceTemplate) { + log.trace("Validating Service Template..") + try { + this.bluePrintRuntimeService = bluePrintRuntimeService + this.error = bluePrintRuntimeService.getBluePrintError() + + serviceTemplate.metadata?.let { validateMetadata(serviceTemplate.metadata!!) } + serviceTemplate.dataTypes?.let { validateDataTypes(serviceTemplate.dataTypes!!) } + serviceTemplate.artifactTypes?.let { validateArtifactTypes(serviceTemplate.artifactTypes!!) } + serviceTemplate.nodeTypes?.let { validateNodeTypes(serviceTemplate.nodeTypes!!) } + serviceTemplate.topologyTemplate?.let { validateTopologyTemplate(serviceTemplate.topologyTemplate!!) } + } catch (e: Exception) { + log.error("failed in blueprint service template validation", e) + error.addError(BluePrintConstants.PATH_SERVICE_TEMPLATE, paths.joinToString(BluePrintConstants.PATH_DIVIDER), e.message!!) + } + } + + fun validateMetadata(metaDataMap: MutableMap) { + + paths.add(BluePrintConstants.PATH_METADATA) + + val templateName = metaDataMap[BluePrintConstants.METADATA_TEMPLATE_NAME] + val templateVersion = metaDataMap[BluePrintConstants.METADATA_TEMPLATE_VERSION] + val templateTags = metaDataMap[BluePrintConstants.METADATA_TEMPLATE_TAGS] + val templateAuthor = metaDataMap[BluePrintConstants.METADATA_TEMPLATE_AUTHOR] + + Preconditions.checkArgument(StringUtils.isNotBlank(templateName), "failed to get template name metadata") + Preconditions.checkArgument(StringUtils.isNotBlank(templateVersion), "failed to get template version metadata") + Preconditions.checkArgument(StringUtils.isNotBlank(templateTags), "failed to get template tags metadata") + Preconditions.checkArgument(StringUtils.isNotBlank(templateAuthor), "failed to get template author metadata") + + paths.removeAt(paths.lastIndex) + } + + + fun validateDataTypes(dataTypes: MutableMap) { + + paths.add(BluePrintConstants.PATH_DATA_TYPES) + dataTypes.forEach { dataTypeName, dataType -> + // Validate Single Data Type + bluePrintTypeValidatorService.validateDataType(bluePrintRuntimeService, dataTypeName, dataType) + } + paths.removeAt(paths.lastIndex) + } + + fun validateArtifactTypes(artifactTypes: MutableMap) { + paths.add(BluePrintConstants.PATH_ARTIFACT_TYPES) + artifactTypes.forEach { artifactName, artifactType -> + // Validate Single Artifact Type + bluePrintTypeValidatorService.validateArtifactType(bluePrintRuntimeService, artifactName, artifactType) + } + paths.removeAt(paths.lastIndex) + } + + fun validateNodeTypes(nodeTypes: MutableMap) { + paths.add(BluePrintConstants.PATH_NODE_TYPES) + nodeTypes.forEach { nodeTypeName, nodeType -> + // Validate Single Node Type + bluePrintTypeValidatorService.validateNodeType(bluePrintRuntimeService, nodeTypeName, nodeType) + } + paths.removeAt(paths.lastIndex) + } + + fun validateTopologyTemplate(topologyTemplate: TopologyTemplate) { + paths.add(BluePrintConstants.PATH_TOPOLOGY_TEMPLATE) + bluePrintTypeValidatorService.validateTopologyTemplate(bluePrintRuntimeService, "topologyTemplate", topologyTemplate) + paths.removeAt(paths.lastIndex) + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintTopologyTemplateValidatorImpl.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintTopologyTemplateValidatorImpl.kt new file mode 100644 index 000000000..b87666d2d --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintTopologyTemplateValidatorImpl.kt @@ -0,0 +1,72 @@ +/* + * 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.core.validation + +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.core.data.NodeTemplate +import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition +import org.onap.ccsdk.apps.controllerblueprints.core.data.TopologyTemplate +import org.onap.ccsdk.apps.controllerblueprints.core.data.Workflow +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTopologyTemplateValidator +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService + +open class BluePrintTopologyTemplateValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintTopologyTemplateValidator { + + private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString()) + + lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*> + + override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, topologyTemplate: TopologyTemplate) { + log.trace("Validating Topology Template..") + this.bluePrintRuntimeService = bluePrintRuntimeService + + // Validate Inputs + topologyTemplate.inputs?.let { validateInputs(topologyTemplate.inputs!!) } + // Validate Node Templates + topologyTemplate.nodeTemplates?.let { validateNodeTemplates(topologyTemplate.nodeTemplates!!) } + // Validate Workflow + topologyTemplate.workflows?.let { validateWorkflows(topologyTemplate.workflows!!) } + } + + @Throws(BluePrintException::class) + fun validateInputs(inputs: MutableMap) { + bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintRuntimeService, inputs) + } + + + @Throws(BluePrintException::class) + fun validateNodeTemplates(nodeTemplates: MutableMap) { + + nodeTemplates.forEach { nodeTemplateName, nodeTemplate -> + // Validate Single Node Template + bluePrintTypeValidatorService.validateNodeTemplate(bluePrintRuntimeService, nodeTemplateName, nodeTemplate) + } + } + + @Throws(BluePrintException::class) + open fun validateWorkflows(workflows: MutableMap) { + + workflows.forEach { workflowName, workflow -> + // Validate Single workflow + bluePrintTypeValidatorService.validateWorkflow(bluePrintRuntimeService, workflowName, workflow) + } + } + +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImpl.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImpl.kt new file mode 100644 index 000000000..4f68342eb --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImpl.kt @@ -0,0 +1,48 @@ +/* + * 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.core.validation + +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.core.interfaces.BluePrintTypeValidatorService +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintValidatorService +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService +import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils +import java.util.* + + +open class BluePrintValidatorServiceImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintValidatorService { + + private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintValidatorServiceImpl::class.toString()) + + override fun validateBluePrints(basePath: String): Boolean { + + val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(UUID.randomUUID().toString(), basePath) + return validateBluePrints(bluePrintRuntimeService) + } + + override fun validateBluePrints(bluePrintRuntimeService: BluePrintRuntimeService<*>): Boolean { + + bluePrintTypeValidatorService.validateServiceTemplate(bluePrintRuntimeService, "service_template", + bluePrintRuntimeService.bluePrintContext().serviceTemplate) + if (bluePrintRuntimeService.getBluePrintError().errors.size > 0) { + throw BluePrintException("failed in blueprint validation : ${bluePrintRuntimeService.getBluePrintError().errors.joinToString("\n")}") + } + return true + } +} diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintWorkflowValidatorImpl.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintWorkflowValidatorImpl.kt new file mode 100644 index 000000000..61918fbc9 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintWorkflowValidatorImpl.kt @@ -0,0 +1,76 @@ +/* + * 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.core.validation + +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.apps.controllerblueprints.core.data.Workflow +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintWorkflowValidator +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService + +open class BluePrintWorkflowValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintWorkflowValidator { + + private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString()) + lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*> + + var paths: MutableList = arrayListOf() + + override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, workflowName: String, workflow: Workflow) { + log.info("Validating Workflow($workflowName)") + + this.bluePrintRuntimeService = bluePrintRuntimeService + + + paths.add(workflowName) + paths.joinToString(BluePrintConstants.PATH_DIVIDER) + + // Step Validation Start + paths.add("steps") + workflow.steps?.forEach { stepName, step -> + paths.add(stepName) + paths.joinToString(BluePrintConstants.PATH_DIVIDER) + + // Validate target + step.target?.let { + try { + val nodeTemplate = bluePrintRuntimeService.bluePrintContext().nodeTemplateByName(it) + + val nodeTypeDerivedFrom = bluePrintRuntimeService.bluePrintContext().nodeTemplateNodeType(it).derivedFrom + + check(nodeTypeDerivedFrom == BluePrintConstants.MODEL_TYPE_NODE_DG) { + "NodeType(${nodeTemplate.type}) derived from is '$nodeTypeDerivedFrom', Expected is " + + "'${BluePrintConstants.MODEL_TYPE_NODE_DG}'" + } + } catch (e: Exception) { + bluePrintRuntimeService.getBluePrintError() + .addError("Failed to validate Workflow($workflowName)'s step($stepName)'s " + + "definition", paths.joinToString(BluePrintConstants.PATH_DIVIDER), e.message!!) + } + } + paths.removeAt(paths.lastIndex) + } + paths.removeAt(paths.lastIndex) + // Step Validation Ends + paths.removeAt(paths.lastIndex) + + workflow.inputs?.let { + bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintRuntimeService, workflow.inputs!!) + } + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/resources/META-INF/services/javax.script.ScriptEngineFactory b/ms/controllerblueprints/modules/blueprint-core/src/main/resources/META-INF/services/javax.script.ScriptEngineFactory new file mode 100644 index 000000000..89838f44f --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/resources/META-INF/services/javax.script.ScriptEngineFactory @@ -0,0 +1,17 @@ +# +# 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. +# + +org.jetbrains.kotlin.script.jsr223.KotlinJsr223JvmLocalScriptEngineFactory \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctionsTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctionsTest.kt new file mode 100644 index 000000000..1b315a211 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctionsTest.kt @@ -0,0 +1,35 @@ +/* + * 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.core + +import org.junit.Test +import kotlin.test.assertEquals +/** + * + * + * @author Brinda Santh + */ +class CustomFunctionsTest { + @Test + fun testFormat(): Unit { + val returnValue : String = format("This is {} for times {}", "test", 2) + assertEquals("This is test for times 2", returnValue, "Failed to format String") + + val returnValue1 : String = format("This is test for times 2") + assertEquals("This is test for times 2", returnValue1, "Failed to format empty args") + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/mock/MockBluePrintTypeValidatorService.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/mock/MockBluePrintTypeValidatorService.kt new file mode 100644 index 000000000..4c174f92e --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/mock/MockBluePrintTypeValidatorService.kt @@ -0,0 +1,59 @@ +/* + * 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.core.mock + +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.* +import org.onap.ccsdk.apps.controllerblueprints.core.validation.* + +class MockBluePrintTypeValidatorService : BluePrintTypeValidatorService { + + override fun getServiceTemplateValidators(): List { + return listOf(BluePrintServiceTemplateValidatorImpl(this)) + } + + override fun getDataTypeValidators(): List { + return listOf(BluePrintDataTypeValidatorImpl(this)) + } + + override fun getArtifactTypeValidators(): List { + return listOf(BluePrintArtifactTypeValidatorImpl(this)) + } + + override fun getNodeTypeValidators(): List { + return listOf(BluePrintNodeTypeValidatorImpl(this)) + } + + override fun getTopologyTemplateValidators(): List { + return listOf(BluePrintTopologyTemplateValidatorImpl(this)) + } + + override fun getNodeTemplateValidators(): List { + return listOf(BluePrintNodeTemplateValidatorImpl(this)) + } + + override fun getWorkflowValidators(): List { + return listOf(BluePrintWorkflowValidatorImpl(this)) + } + + override fun getPropertyDefinitionValidators(): List { + return listOf(BluePrintPropertyDefinitionValidatorImpl(this)) + } + + override fun getAttributeDefinitionValidators(): List { + return listOf(BluePrintAttributeDefinitionValidatorImpl(this)) + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContextTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContextTest.kt new file mode 100644 index 000000000..0c4d94f3c --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContextTest.kt @@ -0,0 +1,54 @@ +/* + * 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.core.service + + +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import org.junit.Test +import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils +import kotlin.test.assertNotNull + +/** + * + * + * @author Brinda Santh + */ +class BluePrintContextTest { + + private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) + + val blueprintBasePath: String = ("./../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration") + + @Test + fun testBluePrintContextCreation() { + val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(blueprintBasePath) + assertNotNull(bluePrintContext, "Failed to populate Blueprint context") + } + + @Test + fun testChainedProperty() { + val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(blueprintBasePath) + val nodeType = bluePrintContext.nodeTypeChained("component-resource-assignment") + assertNotNull(nodeType, "Failed to get chained node type") + log.trace("Properties {}", JacksonUtils.getJson(nodeType, true)) + } + + +} diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionServiceTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionServiceTest.kt new file mode 100644 index 000000000..d68892fc1 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionServiceTest.kt @@ -0,0 +1,117 @@ +/* + * 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.core.service + +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper +import org.junit.Test +import org.onap.ccsdk.apps.controllerblueprints.core.data.ExpressionData +import kotlin.test.assertEquals +import kotlin.test.assertNotNull +/** + * + * + * @author Brinda Santh + */ +class BluePrintExpressionServiceTest { + @Test + fun testInputExpression() { + val node : JsonNode = jacksonObjectMapper().readTree("{ \"get_input\" : \"input-name\" }") + val expressionData : ExpressionData = BluePrintExpressionService.getExpressionData(node) + assertNotNull(expressionData, " Failed to populate expression data") + assertEquals(expressionData.isExpression, true, "Failed to identify as expression") + assertNotNull(expressionData.inputExpression, " Failed to populate input expression data") + assertEquals("input-name", expressionData.inputExpression?.propertyName, "Failed to get propertyName from expression data") + } + + @Test + fun testPropertyExpression() { + val node : JsonNode = jacksonObjectMapper().readTree("{ \"get_property\" : [\"SELF\", \"property-name\"] }") + val expressionData : ExpressionData = BluePrintExpressionService.getExpressionData(node) + assertNotNull(expressionData, " Failed to populate expression data") + assertEquals(expressionData.isExpression, true, "Failed to identify as expression") + assertNotNull(expressionData.propertyExpression, " Failed to populate property expression data") + assertEquals("SELF", expressionData.propertyExpression?.modelableEntityName, " Failed to get expected modelableEntityName") + assertEquals("property-name", expressionData.propertyExpression?.propertyName, " Failed to get expected propertyName") + + val node1 : JsonNode = jacksonObjectMapper().readTree("{ \"get_property\" : [\"SELF\", \"\",\"property-name\", \"resource\", \"name\"] }") + val expressionData1 : ExpressionData = BluePrintExpressionService.getExpressionData(node1) + assertNotNull(expressionData1, " Failed to populate expression data") + assertEquals(expressionData1.isExpression, true, "Failed to identify as nested property expression") + assertNotNull(expressionData1.propertyExpression, " Failed to populate nested property expression data") + assertEquals("SELF", expressionData1.propertyExpression?.modelableEntityName, " Failed to get expected modelableEntityName") + assertEquals("property-name", expressionData1.propertyExpression?.propertyName, " Failed to get expected propertyName") + assertEquals("resource/name",expressionData1.propertyExpression?.subPropertyName, " Failed to populate nested subPropertyName expression data") + } + + @Test + fun testAttributeExpression() { + val node : JsonNode = jacksonObjectMapper().readTree("{ \"get_attribute\" : [\"SELF\", \"resource\"] }") + val expressionData : ExpressionData = BluePrintExpressionService.getExpressionData(node) + assertNotNull(expressionData, " Failed to populate expression data") + assertEquals(expressionData.isExpression, true, "Failed to identify as expression") + assertNotNull(expressionData.attributeExpression, " Failed to populate attribute expression data") + assertEquals("SELF", expressionData.attributeExpression?.modelableEntityName, " Failed to get expected modelableEntityName") + assertEquals("resource", expressionData.attributeExpression?.attributeName, " Failed to get expected attributeName") + + val node1 : JsonNode = jacksonObjectMapper().readTree("{ \"get_attribute\" : [\"SELF\", \"\",\"attribute-name\", \"resource\", \"name\"] }") + val expressionData1 : ExpressionData = BluePrintExpressionService.getExpressionData(node1) + assertNotNull(expressionData1, " Failed to populate expression data") + assertEquals(expressionData1.isExpression, true, "Failed to identify as expression") + assertNotNull(expressionData1.attributeExpression, " Failed to populate attribute expression data") + assertEquals("SELF", expressionData1.attributeExpression?.modelableEntityName, " Failed to get expected modelableEntityName") + assertEquals("attribute-name", expressionData1.attributeExpression?.attributeName, " Failed to get expected attributeName") + assertEquals("resource/name",expressionData1.attributeExpression?.subAttributeName, " Failed to populate nested subAttributeName expression data") + } + + + @Test + fun testOutputOperationExpression() { + val node : JsonNode = jacksonObjectMapper().readTree("{ \"get_operation_output\": [\"SELF\", \"interface-name\", \"operation-name\", \"output-property-name\"] }") + val expressionData : ExpressionData = BluePrintExpressionService.getExpressionData(node) + assertNotNull(expressionData, " Failed to populate expression data") + assertEquals(expressionData.isExpression, true, "Failed to identify as expression") + assertNotNull(expressionData.operationOutputExpression, " Failed to populate output expression data") + assertEquals("SELF", expressionData.operationOutputExpression?.modelableEntityName, " Failed to get expected modelableEntityName") + assertEquals("interface-name", expressionData.operationOutputExpression?.interfaceName, " Failed to get expected interfaceName") + assertEquals("operation-name", expressionData.operationOutputExpression?.operationName, " Failed to get expected operationName") + assertEquals("output-property-name", expressionData.operationOutputExpression?.propertyName, " Failed to get expected propertyName") + } + + + @Test + fun testArtifactExpression() { + val node : JsonNode = jacksonObjectMapper().readTree("{ \"get_artifact\" : [\"SELF\", \"artifact-template\"] }") + val expressionData : ExpressionData = BluePrintExpressionService.getExpressionData(node) + assertNotNull(expressionData, " Failed to populate expression data") + assertEquals(expressionData.isExpression, true, "Failed to identify as expression") + assertNotNull(expressionData.artifactExpression, " Failed to populate Artifact expression data") + assertEquals("SELF", expressionData.artifactExpression?.modelableEntityName, " Failed to get expected modelableEntityName") + assertEquals("artifact-template", expressionData.artifactExpression?.artifactName, " Failed to get expected artifactName") + + + val node1 : JsonNode = jacksonObjectMapper().readTree("{ \"get_artifact\" : [\"SELF\", \"artifact-template\", \"location\", true] }") + val expressionData1 : ExpressionData = BluePrintExpressionService.getExpressionData(node1) + assertNotNull(expressionData1, " Failed to populate expression data") + assertEquals(expressionData1.isExpression, true, "Failed to identify as expression") + assertNotNull(expressionData1.artifactExpression, " Failed to populate Artifact expression data") + assertEquals("SELF", expressionData1.artifactExpression?.modelableEntityName, " Failed to get expected modelableEntityName") + assertEquals("artifact-template", expressionData1.artifactExpression?.artifactName, " Failed to get expected artifactName") + assertEquals("location", expressionData1.artifactExpression?.location, " Failed to get expected location") + assertEquals(true, expressionData1.artifactExpression?.remove, " Failed to get expected remove") + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt new file mode 100644 index 000000000..6f942a365 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRepoFileServiceTest.kt @@ -0,0 +1,57 @@ +/* + * 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.core.service + +import org.junit.Test +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import kotlin.test.assertNotNull + +/** + * BluePrintRepoFileServiceTest + * @author Brinda Santh + * + */ +class BluePrintRepoFileServiceTest { + + private val basePath = "load/model_type" + private val bluePrintRepoFileService = BluePrintRepoFileService(basePath) + + @Test + fun testGetDataType() { + val dataType = bluePrintRepoFileService.getDataType("dt-v4-aggregate") + assertNotNull(dataType, "Failed to get DataType from repo") + } + + @Test + fun testGetNodeType() { + val nodeType = bluePrintRepoFileService.getNodeType("component-resource-assignment") + assertNotNull(nodeType, "Failed to get NodeType from repo") + } + + @Test + fun testGetArtifactType() { + val nodeType = bluePrintRepoFileService.getArtifactType("artifact-template-velocity") + assertNotNull(nodeType, "Failed to get ArtifactType from repo") + } + + @Test(expected = BluePrintException::class) + fun testModelNotFound() { + val dataType = bluePrintRepoFileService.getDataType("dt-not-found") + assertNotNull(dataType, "Failed to get DataType from repo") + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt new file mode 100644 index 000000000..7a178758a --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt @@ -0,0 +1,144 @@ +/* + * 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.core.service + +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.node.NullNode +import org.junit.Test +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.apps.controllerblueprints.core.asJsonPrimitive +import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils +import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintRuntimeUtils +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils +import kotlin.test.assertEquals +import kotlin.test.assertNotNull + +/** + * + * + * @author Brinda Santh + */ +class BluePrintRuntimeServiceTest { + private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) + + @Test + fun `test Resolve NodeTemplate Properties`() { + log.info("************************ testResolveNodeTemplateProperties **********************") + + val bluePrintRuntimeService = getBluePrintRuntimeService() + + val inputDataPath = "src/test/resources/data/default-context.json" + + val inputNode: JsonNode = JacksonUtils.jsonNodeFromFile(inputDataPath) + bluePrintRuntimeService.assignInputs(inputNode) + + val propContext: MutableMap = bluePrintRuntimeService + .resolveNodeTemplateProperties("activate-process") + + assertNotNull(propContext, "Failed to populate interface property values") + } + + @Test + fun `test resolve NodeTemplate Capability Properties`() { + log.info("************************ testResolveNodeTemplateRequirementProperties **********************") + val bluePrintRuntimeService = getBluePrintRuntimeService() + + val executionContext = bluePrintRuntimeService.getExecutionContext() + + BluePrintRuntimeUtils.assignInputsFromClassPathFile(bluePrintRuntimeService.bluePrintContext(), + "data/default-context.json", executionContext) + + val capProperties = bluePrintRuntimeService.resolveNodeTemplateCapabilityProperties("sample-netconf-device", + "netconf") + assertNotNull(capProperties, "Failed to populate capability property values") + assertEquals(capProperties["target-ip-address"], JacksonUtils.jsonNodeFromObject("localhost"), "Failed to populate parameter target-ip-address") + assertEquals(capProperties["port-number"], JacksonUtils.jsonNodeFromObject(830), "Failed to populate parameter port-number") + } + + @Test + fun `test Resolve NodeTemplate Interface Operation Inputs`() { + log.info("************************ testResolveNodeTemplateInterfaceOperationInputs **********************") + + val bluePrintRuntimeService = getBluePrintRuntimeService() + + val executionContext = bluePrintRuntimeService.getExecutionContext() + + BluePrintRuntimeUtils.assignInputsFromClassPathFile(bluePrintRuntimeService.bluePrintContext(), + "data/default-context.json", executionContext) + + val inContext: MutableMap = bluePrintRuntimeService + .resolveNodeTemplateInterfaceOperationInputs("resource-assignment", + "ResourceAssignmentComponent", "process") + + assertNotNull(inContext, "Failed to populate interface input property values") + assertEquals(inContext["action-name"], JacksonUtils.jsonNodeFromObject("sample-action"), "Failed to populate parameter action-name") + assertEquals(inContext["request-id"], JacksonUtils.jsonNodeFromObject("12345"), "Failed to populate parameter action-name") + } + + @Test + fun `test Resolve NodeTemplate Interface Operation Outputs`() { + log.info("************************ testResolveNodeTemplateInterfaceOperationOutputs **********************") + + val bluePrintRuntimeService = getBluePrintRuntimeService() + + bluePrintRuntimeService.setNodeTemplateAttributeValue("resource-assignment", "assignment-params", NullNode.getInstance()) + + bluePrintRuntimeService.resolveNodeTemplateInterfaceOperationOutputs("resource-assignment", + "ResourceAssignmentComponent", "process") + + val outputStatus = bluePrintRuntimeService.getNodeTemplateOperationOutputValue("resource-assignment", + "ResourceAssignmentComponent", "process", "status") + assertEquals("success".asJsonPrimitive(), outputStatus, "Failed to get operation property status") + + val outputParams = bluePrintRuntimeService.getNodeTemplateOperationOutputValue("resource-assignment", + "ResourceAssignmentComponent", "process", "resource-assignment-params") + assertEquals(NullNode.getInstance(), outputParams, "Failed to get operation property resource-assignment-params") + + } + + @Test + fun `test NodeTemplate Context Property`() { + log.info("************************ testNodeTemplateContextProperty **********************") + val bluePrintRuntimeService = getBluePrintRuntimeService() + + bluePrintRuntimeService.setNodeTemplateAttributeValue("resource-assignment-ra-component", "context1", + JacksonUtils.jsonNodeFromObject("context1-value")) + bluePrintRuntimeService.setNodeTemplateAttributeValue("resource-assignment-ra-component", "context2", + JacksonUtils.jsonNodeFromObject("context2-value")) + + val keys = listOf("context1", "context2") + + val jsonValueNode = bluePrintRuntimeService.getJsonForNodeTemplateAttributeProperties("resource-assignment-ra-component", keys) + assertNotNull(jsonValueNode, "Failed to get Json for Node Template Context Properties") + log.info("JSON Prepared Value Context {}", jsonValueNode) + + } + + private fun getBluePrintRuntimeService(): BluePrintRuntimeService> { + val blueprintBasePath: String = ("./../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration") + val blueprintRuntime = BluePrintMetadataUtils.getBluePrintRuntime("1234", blueprintBasePath) + val checkBasePath = blueprintRuntime.get(BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH) + + assertEquals(blueprintBasePath.asJsonPrimitive(), checkBasePath, "Failed to get base path after runtime creation") + + return blueprintRuntime + } + +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintTemplateServiceTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintTemplateServiceTest.kt new file mode 100644 index 000000000..663a3751a --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintTemplateServiceTest.kt @@ -0,0 +1,35 @@ +/* + * 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.core.service + +import org.junit.Test +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils +import kotlin.test.assertNotNull + +class BluePrintTemplateServiceTest { + + @Test + fun testGenerateContent() { + + val template = JacksonUtils.getClassPathFileContent("templates/base-config-template.vtl") + val json = JacksonUtils.getClassPathFileContent("templates/base-config-data.json") + + val content = BluePrintTemplateService.generateContent(template, json) + assertNotNull(content, "failed to generate content for velocity template") + + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorDefaultServiceTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorDefaultServiceTest.kt new file mode 100644 index 000000000..861f7d095 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorDefaultServiceTest.kt @@ -0,0 +1,50 @@ +/* + * 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.core.service + +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import org.junit.Before +import org.junit.Test +import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils + +/** + * + * + * @author Brinda Santh + */ +class BluePrintValidatorDefaultServiceTest { + private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) + + @Before + fun setUp(): Unit { + + } + + @Test + fun testValidateBluePrint() { + + val blueprintBasePath: String = ("./../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration") + val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(blueprintBasePath) + val properties: MutableMap = hashMapOf() + + val validatorService = BluePrintValidatorDefaultService() + validatorService.validateBlueprint(bluePrintContext.serviceTemplate, properties) + log.info("Validation Message {}", properties) + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtilsTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtilsTest.kt new file mode 100644 index 000000000..528f2c6f2 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintFileUtilsTest.kt @@ -0,0 +1,60 @@ +/* + * 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.core.utils + +import kotlinx.coroutines.runBlocking +import org.junit.Test +import java.io.File +import java.nio.file.Paths +import kotlin.test.assertTrue + + +class BluePrintFileUtilsTest { + + @Test + fun testNewBlueprint() = runBlocking { + val targetPath: String = Paths.get("target").toUri().toURL().path.plus("/bp-new-test") + BluePrintFileUtils.createEmptyBluePrint(targetPath) + + } + + @Test + fun testBlueprintCopy() = runBlocking { + val sourcePath: String = "./../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration" + + val targetPath: String = Paths.get("target").toUri().toURL().path.plus("/bp-copy-test") + + val targetDir = File(targetPath) + targetDir.deleteOnExit() + // Copy the BP file + BluePrintFileUtils.copyBluePrint(sourcePath, targetDir.absolutePath) + + assertTrue(targetDir.exists(), "faield to copy blueprint to ${targetDir.absolutePath}") + + // Delete Type Files + BluePrintFileUtils.deleteBluePrintTypes(targetDir.absolutePath) + + // Generate the Type Files + val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(sourcePath) + bluePrintContext.rootPath = targetDir.absolutePath + + BluePrintFileUtils.writeBluePrintTypes(bluePrintContext) + + + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt new file mode 100644 index 000000000..80daad5d8 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt @@ -0,0 +1,41 @@ +/* + * 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.core.utils + + +import org.junit.Test +import org.onap.ccsdk.apps.controllerblueprints.core.data.ToscaMetaData +import kotlin.test.assertNotNull + +class BluePrintMetadataUtilsTest { + + @Test + fun testToscaMetaData(){ + + val basePath : String = "./../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration" + + val toscaMetaData : ToscaMetaData = BluePrintMetadataUtils.toscaMetaData(basePath) + assertNotNull(toscaMetaData, "Missing Tosca Definition Object") + assertNotNull(toscaMetaData.toscaMetaFileVersion, "Missing Tosca Metadata Version") + assertNotNull(toscaMetaData.csarVersion, "Missing CSAR version") + assertNotNull(toscaMetaData.createdBy, "Missing Created by") + assertNotNull(toscaMetaData.entityDefinitions, "Missing Tosca Entity Definition") + assertNotNull(toscaMetaData.templateTags, "Missing Template Tags") + + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtilsTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtilsTest.kt new file mode 100644 index 000000000..12156d659 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtilsTest.kt @@ -0,0 +1,78 @@ +/* + * 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.core.utils + +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import org.junit.Test +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants +import kotlin.test.assertNotNull +import kotlin.test.assertTrue + +/** + * JacksonUtilsTest + * @author Brinda Santh + * ${DATA} + */ +class JacksonUtilsTest { + + private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString()) + + @Test + fun testJsonNodeFromClassPathFile() { + val filePath = "data/default-context.json" + JacksonUtils.jsonNodeFromClassPathFile(filePath) + } + + @Test + fun testJsonNodeFromFile() { + val filePath = "src/test/resources/data/default-context.json" + JacksonUtils.jsonNodeFromFile(filePath) + } + + @Test + fun testGetListFromJson() { + val content = "[\"good\",\"boy\" ]" + val nodeType = JacksonUtils.getListFromJson(content, String::class.java) + assertNotNull(nodeType, "Failed to get String array from content") + } + + + @Test + fun testJsonValue() { + val filePath = "data/alltype-data.json" + val rootJson = JacksonUtils.jsonNodeFromClassPathFile(filePath) + assertNotNull(rootJson, "Failed to get all type data json node") + val intValue = rootJson.get("intValue") + assertTrue(JacksonUtils.checkJsonNodeValueOfType(BluePrintConstants.DATA_TYPE_INTEGER, intValue), "Failed to get as int value") + val floatValue = rootJson.get("floatValue") + assertTrue(JacksonUtils.checkJsonNodeValueOfType(BluePrintConstants.DATA_TYPE_FLOAT, floatValue), "Failed to get as float value") + val stringValue = rootJson.get("stringValue") + assertTrue(JacksonUtils.checkJsonNodeValueOfType(BluePrintConstants.DATA_TYPE_STRING, stringValue), "Failed to get as string value") + val booleanValue = rootJson.get("booleanValue") + assertTrue(JacksonUtils.checkJsonNodeValueOfType(BluePrintConstants.DATA_TYPE_BOOLEAN, booleanValue), "Failed to get as boolean value") + val arrayStringValue = rootJson.get("arrayStringValue") + assertTrue(JacksonUtils.checkJsonNodeValueOfType(BluePrintConstants.DATA_TYPE_LIST, arrayStringValue), "Failed to get as List value") + val mapValue = rootJson.get("mapValue") + assertTrue(JacksonUtils.checkJsonNodeValueOfType(BluePrintConstants.DATA_TYPE_MAP, mapValue), "Failed to get as Map value") + + assertTrue(!JacksonUtils.checkJsonNodeValueOfType(BluePrintConstants.DATA_TYPE_LIST, stringValue), "Negative type failed") + + + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/TopologicalSortingUtilsTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/TopologicalSortingUtilsTest.kt new file mode 100644 index 000000000..5999dbfa5 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/TopologicalSortingUtilsTest.kt @@ -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.core.utils + +import org.junit.Test + +class TopologicalSortingUtilsTest { + + @Test + fun testSorting(): Unit { + val graph: TopologicalSortingUtils = TopologicalSortingUtils() + graph.add("bundle-id", "bundle-mac") + graph.add("bundle-id", "bundle-ip") + graph.add("bundle-mac", "bundle-ip") + graph.add("bundle-ip", "bundle-mac") + + println("The current graph: " + graph) + println("In-degrees: " + graph.inDegree()) + println("Out-degrees: " + graph.outDegree()) + println("A topological sort of the vertices: " + graph.topSort()) + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImplTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImplTest.kt new file mode 100644 index 000000000..cfcbd9b2f --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintValidatorServiceImplTest.kt @@ -0,0 +1,100 @@ +/* + * 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.core.validation + +import io.mockk.every +import io.mockk.mockk +import org.junit.Test +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError +import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate +import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeType +import org.onap.ccsdk.apps.controllerblueprints.core.data.Step +import org.onap.ccsdk.apps.controllerblueprints.core.data.Workflow +import org.onap.ccsdk.apps.controllerblueprints.core.mock.MockBluePrintTypeValidatorService +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext +import org.onap.ccsdk.apps.controllerblueprints.core.service.DefaultBluePrintRuntimeService +import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils +import kotlin.test.assertEquals +import kotlin.test.assertTrue + +class BluePrintValidatorServiceImplTest { + + private val blueprintBasePath: String = ("./../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration") + private val bluePrintRuntime = BluePrintMetadataUtils.getBluePrintRuntime("1234", blueprintBasePath) + private val mockBluePrintTypeValidatorService = MockBluePrintTypeValidatorService() + private val defaultBluePrintValidatorService = BluePrintValidatorServiceImpl(mockBluePrintTypeValidatorService) + private val workflowValidator = BluePrintWorkflowValidatorImpl(mockBluePrintTypeValidatorService) + + @Test + fun testValidateOfType() { + val valid = defaultBluePrintValidatorService.validateBluePrints(bluePrintRuntime) + assertTrue(valid, "failed in blueprint Validation") + } + + @Test + fun testValidateWorkflowFailToFoundNodeTemplate() { + val workflowName = "resource-assignment" + + val step = Step() + step.target = "TestCaseFailNoNodeTemplate" + val workflow = Workflow() + workflow.steps = mutableMapOf("test" to step) + workflowValidator.validate(bluePrintRuntime, workflowName, workflow) + + assertEquals(1, bluePrintRuntime.getBluePrintError().errors.size) + assertEquals("Failed to validate Workflow(resource-assignment)'s step(test)'s definition : resource-assignment/steps/test : could't get node template for the name(TestCaseFailNoNodeTemplate)", bluePrintRuntime.getBluePrintError().errors[0]) + } + + @Test + fun testValidateWorkflowFailNodeTemplateNotDgGeneric() { + val workflowName = "resource-assignment" + val nodeTemplateName = "resource-assignment-process" + + val nodeTemplate = mockk() + every { nodeTemplate.type } returns "TestNodeType" + + val nodeType = mockk() + every { nodeType.derivedFrom } returns "tosca.nodes.TEST" + + val blueprintContext = mockk() + every { blueprintContext.nodeTemplateByName(nodeTemplateName) } returns nodeTemplate + every { blueprintContext.nodeTemplateNodeType(nodeTemplateName) } returns nodeType + + val bluePrintRuntime = mockk("1234") + + every { bluePrintRuntime.getBluePrintError() } returns BluePrintError() + every { bluePrintRuntime.bluePrintContext() } returns blueprintContext + + val step = Step() + step.target = nodeTemplateName + val workflow = Workflow() + workflow.steps = mutableMapOf("test" to step) + workflowValidator.validate(bluePrintRuntime, workflowName, workflow) + + assertEquals(1, bluePrintRuntime.getBluePrintError().errors.size) + assertEquals("Failed to validate Workflow(resource-assignment)'s step(test)'s definition : resource-assignment/steps/test : NodeType(TestNodeType) derived from is 'tosca.nodes.TEST', Expected is 'tosca.nodes.DG'", bluePrintRuntime.getBluePrintError().errors[0]) + } + + @Test + fun testValidateWorkflowSuccess() { + val workflowName = "resource-assignment" + workflowValidator.validate(bluePrintRuntime, workflowName, bluePrintRuntime.bluePrintContext().workflowByName(workflowName)) + } + +} + diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/componentnode/default.json b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/componentnode/default.json new file mode 100644 index 000000000..a1982631b --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/componentnode/default.json @@ -0,0 +1,100 @@ +{ + "metadata": { + "template_author": "bs2796", + "vendor": "Juniper", + "os": "XXX", + "service-type": "AVPN", + "vnf-type": "VRR", + "action": "Base Configuration", + "sub-action": "Generate Configuration", + "template_name": "VRR-baseconfiguration", + "template_version": "1.0.0" + }, + "topology_template": { + "inputs": { + "service-instance-id": { + "required": true, + "type": "string" + }, + "vnf-id": { + "required": true, + "type": "string" + }, + "service": { + "required": true, + "type": "string" + }, + "region": { + "required": true, + "type": "string" + }, + "bundle-id": { + "required": true, + "type": "string" + }, + "bundle-mac": { + "required": true, + "type": "string" + } + }, + "node_templates": { + "generate-configuration": { + "type": "mock-component-generateConfig", + "interfaces": { + "org-onap-ccsdk-config-params-service-MockComponentNode": { + "operations": { + "process": { + "inputs": { + "entity-type": "vnf-type", + "template-content": "sample-template", + "entity-id": { "get_input" : "vnf-id" } + }, + "outputs": { + "mergedData": "merged Data", + "status": "status" + } + } + } + } + } + } + } + }, + "node_types": { + "mock-component-generateConfig": { + "interfaces": { + "org-onap-ccsdk-config-params-service-MockComponentNode": { + "operations": { + "process": { + "inputs": { + "entity-type": { + "required": false, + "type": "string" + }, + "template-content": { + "required": false, + "type": "string" + }, + "entity-id": { + "required": true, + "type": "string" + } + }, + "outputs": { + "generated-config": { + "required": true, + "type": "string" + }, + "status": { + "required": true, + "type": "string" + } + } + } + } + } + }, + "derived_from": "tosca.nodes.Component" + } + } +} diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/data/alltype-data.json b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/data/alltype-data.json new file mode 100644 index 000000000..055b09658 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/data/alltype-data.json @@ -0,0 +1,10 @@ +{ + "intValue" : 1, + "floatValue" : 1.34, + "booleanValue" : true, + "stringValue" : "sample-String", + "timeValue" : "2018-09-29", + "arrayStringValue" : ["one", "two"], + "mapValue" : {"profile_name1":"profile_name1", + "profile_name2":"profile_name2"} +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/data/default-context.json b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/data/default-context.json new file mode 100644 index 000000000..3968626b8 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/data/default-context.json @@ -0,0 +1,7 @@ +{ + "request-id" : "12345", + "hostname" : "localhost", + "template_name": "baseconfiguration", + "template_version": "1.0.0", + "action-name" : "sample-action" +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/dictionary/dictionary_schema.json b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/dictionary/dictionary_schema.json new file mode 100644 index 000000000..cac8770af --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/dictionary/dictionary_schema.json @@ -0,0 +1,261 @@ +{ + "type": "object", + "properties": { + "resource-path": { + "type": "string", + "required": true + }, + "description": { + "type": "string" + }, + "updated-by": { + "type": "string" + }, + "data-type": { + "type": "string", + "required": true + }, + "source": { + "type": "object", + "required": true, + "properties": { + "input": { + "type": "object", + "properties": { + "key": { + "type": "string" + } + } + }, + "component": { + "type": "object", + "properties": { + "name": { + "type": "string", + "required": true + }, + "input-key-mapping": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "output-key-mapping": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + }, + "default": { + "type": "any" + }, + "aai": { + "type": "any" + }, + "primary-config-data": { + "type": "object", + "properties": { + "path": { + "type": "string", + "required": true + }, + "url-path": { + "type": "string", + "required": true + }, + "input-key-mapping": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "type": { + "type": "string", + "required": true + }, + "output-key-mapping": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "base": { + "type": "string", + "required": true + } + } + }, + "network-resource-discovery": { + "type": "object", + "properties": { + "input-key-mapping": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "output-key-mapping": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + }, + "primary-db": { + "type": "object", + "properties": { + "query": { + "type": "string", + "required": true + }, + "input-key-mapping": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "type": { + "type": "string", + "required": true + }, + "output-key-mapping": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "base": { + "type": "string", + "required": true + } + } + }, + "policy": { + "type": "object", + "properties": { + "input-key-mapping": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "output-key-mapping": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + } + } + }, + "candidate-dependency": { + "type": "object", + "properties": { + "input": { + "type": "object", + "properties": { + "names": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "component": { + "type": "object", + "properties": { + "names": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "aai": { + "type": "object", + "properties": { + "names": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "primary-config-data": { + "type": "object", + "properties": { + "names": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "network-resource-discovery": { + "type": "object", + "properties": { + "names": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "primary-db": { + "type": "object", + "properties": { + "names": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "policy": { + "type": "object", + "properties": { + "names": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + } + }, + "tags": { + "type": "string" + }, + "default": { + "type": "any" + }, + "name": { + "type": "string", + "required": true + }, + "valid-values": { + "type": "string" + }, + "resource-type": { + "type": "string", + "required": true + }, + "sample-value": { + "type": "string" + }, + "entry-schema": { + "type": "string" + } + } +} diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/properties/convert.json b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/properties/convert.json new file mode 100644 index 000000000..f7893ce53 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/properties/convert.json @@ -0,0 +1,36 @@ +{ + "type": "sdnc-component-getResourceAssignment", + "interfaces": { + "ResourceAssignmentService": { + "operations": { + "getResourceAssignment": { + "inputs": { + "assignment-mappings": [ + { + "name": "service-name", + "mapping-field": "service", + "mapping-category": "SDN", + "required": true + }, + { + "name": "region-name", + "mapping-field": "region", + "mapping-category": "SDN", + "required": true + } + ], + "pre-data": { + "get_input": "get-resource-assignment.config-params" + }, + "prifix": "get-resource-assignment" + }, + "outputs": { + "resource-assignment-status": "success", + "resource-assignment-params": "{ \"set_value\" : \"get-resource-assignment.config-params" + } + } + } + } + } +} + diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/properties/default.json b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/properties/default.json new file mode 100644 index 000000000..9f17574e7 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/properties/default.json @@ -0,0 +1,16 @@ +{ + "default": { "get_input" : "loopback-default" }, + "domain": "ethernet", + "criteria": [ + { + "value": "attga301me1", + "type": "complex", + "nodeString": "layer3-service-list[].service-data.l3sdn-vnf-fields.vnf-name" + }, + { + "value": { "get_input" : "host-ip-address" }, + "type": "simple", + "nodeString": "layer3-service-list[].service-data.l3sdn-vnf-fields.vnf-name" + } + ] +} diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/scripts/SampleBlueprintFunctionNode.kts b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/scripts/SampleBlueprintFunctionNode.kts new file mode 100644 index 000000000..44cc957d2 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/scripts/SampleBlueprintFunctionNode.kts @@ -0,0 +1,44 @@ +/* + * 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. + */ + +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BlueprintFunctionNode + +open class SampleBlueprintFunctionNode : BlueprintFunctionNode{ + + override fun getName(): String { + return "Kotlin-Script-Function-Node" + } + + override fun prepareRequest(executionRequest: String): String { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun process(executionRequest: String) { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun recover(runtimeException: RuntimeException, executionRequest: String) { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun prepareResponse(): String { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun apply(t: String): String { + return "$t-status" + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/templates/base-config-data.json b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/templates/base-config-data.json new file mode 100755 index 000000000..2acc6fcdd --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/templates/base-config-data.json @@ -0,0 +1,36 @@ +{ + "node0_hostname": "sdnc-host", + "node0_backup_router_address": "2001:1890:1253::192:168:100:1", + "servers": [ + "Server1", + "Server2", + "Server3" + ], + "tacplus-servers": [ + { + "tacplus-server-name": "tacplus-server-name1", + "tacplus-server-source-address": "enc-dsdsasa1" + }, + { + "tacplus-server-name": "tacplus-server-name2", + "tacplus-server-source-address": "enc-dsdsasa2" + } + ], + "classes": [ + { + "name": "superuser-class", + "idle-timeout": 5, + "permissions": "all" + }, + { + "name": "tacacs-adv-class", + "idle-timeout": 5 + }, + { + "name": "tacacs-base-class", + "idle-timeout": 5 + } + ], + "system-password": "teamops-system-password", + "root-password": "teamops-root-password" +} diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/templates/base-config-template.vtl b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/templates/base-config-template.vtl new file mode 100755 index 000000000..f7b1269b3 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/templates/base-config-template.vtl @@ -0,0 +1,61 @@ + + 15.1X49-D50.3 + + node0 + + #foreach($server in ${servers}) + $StringUtils.upperCase("$server") + #end + + + ${node0_hostname} + +
${node0_backup_router_address}
+ $node0_backup_router_address +
+ #foreach($tacplus-server in ${tacplus-servers}) + + $tacplus-server.tacplus-server-name + $tacplus-server.tacplus-server-source-address + + #end + + ONAP information assets + #foreach($class in ${classes}) + + $class.name + $class.idle-timeout + #if ($class.permissions) + $class.permissions + #end + + #end + + readonly + Read Only Account Access + 1001 + tacacs-base-class + + + readwrite + Read - Write Account Access + 1002 + tacacs-adv-class + + ${system-password} + + + + readwrite + Emergency Access Only + 1000 + superuser-class + + ${root-password} + + + +
+
+
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-validation/pom.xml b/ms/controllerblueprints/modules/blueprint-validation/pom.xml index d175eecf2..4ae2870e2 100644 --- a/ms/controllerblueprints/modules/blueprint-validation/pom.xml +++ b/ms/controllerblueprints/modules/blueprint-validation/pom.xml @@ -37,7 +37,7 @@
org.onap.ccsdk.apps.controllerblueprints - core + blueprint-core org.onap.ccsdk.apps.controllerblueprints diff --git a/ms/controllerblueprints/modules/db-resources/pom.xml b/ms/controllerblueprints/modules/db-resources/pom.xml index c09d96c10..b2f4370be 100644 --- a/ms/controllerblueprints/modules/db-resources/pom.xml +++ b/ms/controllerblueprints/modules/db-resources/pom.xml @@ -32,7 +32,7 @@ org.onap.ccsdk.apps.controllerblueprints - core + blueprint-core org.springframework.boot diff --git a/ms/controllerblueprints/modules/pom.xml b/ms/controllerblueprints/modules/pom.xml index 834db24eb..1ef81ea4c 100644 --- a/ms/controllerblueprints/modules/pom.xml +++ b/ms/controllerblueprints/modules/pom.xml @@ -1,6 +1,7 @@ + + 4.0.0 + + org.onap.ccsdk.apps.controllerblueprints + modules + 0.4.1-SNAPSHOT + + resource-dict + Controller Blueprints Resource Dictionary + + + + org.onap.ccsdk.apps.controllerblueprints + blueprint-core + + + org.jetbrains.kotlin + kotlin-test-junit + test + + + + + diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinition.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinition.kt new file mode 100644 index 000000000..d141ed0cb --- /dev/null +++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinition.kt @@ -0,0 +1,100 @@ +/* + * 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. + * 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 + +import com.fasterxml.jackson.annotation.JsonFormat +import com.fasterxml.jackson.annotation.JsonProperty +import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate +import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition +import java.io.Serializable +import java.util.* + +open class ResourceDefinition { + + @JsonProperty(value = "name", required = true) + lateinit var name: String + + @JsonProperty(value = "property", required = true) + lateinit var property: PropertyDefinition + + var tags: String? = null + + @JsonProperty(value = "updated-by") + lateinit var updatedBy: String + + @JsonProperty(value = "sources", required = true) + lateinit var sources: MutableMap +} + +open class ResourceAssignment { + + @JsonProperty(value = "name", required = true) + lateinit var name: String + + @JsonProperty(value = "property") + var property: PropertyDefinition? = null + + @JsonProperty("input-param") + var inputParameter: Boolean = false + + @JsonProperty("dictionary-name") + var dictionaryName: String? = null + + @JsonProperty("dictionary-source") + var dictionarySource: String? = null + + @JsonProperty("dependencies") + var dependencies: MutableList? = null + + @JsonProperty("version") + var version: Int = 0 + + @JsonProperty("status") + var status: String? = null + + @JsonProperty("message") + var message: String? = null + + @JsonProperty("updated-date") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") + var updatedDate: Date? = null + + @JsonProperty("updated-by") + var updatedBy: String? = null + + override fun toString(): String { + return StringBuilder() + .append("[") + .append("name=", name) + .append(", dictionaryName=", dictionaryName) + .append(", dictionarySource=", dictionarySource) + .append("]") + .toString() + } +} + +/** + * Interface for Source Definitions (ex Input Source, + * Default Source, Database Source, Rest Sources, etc) + */ +interface ResourceSource : Serializable + + +open class ResourceSourceMapping { + lateinit var resourceSourceMappings: MutableMap +} diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt new file mode 100644 index 000000000..aa06c9da0 --- /dev/null +++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt @@ -0,0 +1,38 @@ +/* + * 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.resource.dict + +/** + * ResourceDictionaryConstants + * + * @author Brinda Santh + */ +object ResourceDictionaryConstants { + const val SOURCE_INPUT = "input" + const val SOURCE_DEFAULT = "default" + const val SOURCE_PRIMARY_CONFIG_DATA = "primary-config-data" + const val SOURCE_PRIMARY_DB = "primary-db" + + const val MODEL_DIR_RESOURCE_DEFINITION: String = "resource_dictionary" + + const val PROPERTY_TYPE = "type" + const val PROPERTY_INPUT_KEY_MAPPING = "input-key-mapping" + const val PROPERTY_OUTPUT_KEY_MAPPING = "output-key-mapping" + const val PROPERTY_KEY_DEPENDENCIES = "key-dependencies" + + const val PATH_RESOURCE_DEFINITION_TYPE = "resource_definition_types" +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactory.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactory.kt new file mode 100644 index 000000000..876aca9f7 --- /dev/null +++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactory.kt @@ -0,0 +1,47 @@ +/* + * 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.factory + +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.core.format +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceSourceMapping + +/** + * ResourceSourceMappingFactory. + * + * @author Brinda Santh + */ +object ResourceSourceMappingFactory { + + private val resourceSourceMappings: MutableMap = hashMapOf() + + fun registerSourceMapping(sourceInstance: String, nodeTypeName: String) { + resourceSourceMappings[sourceInstance] = nodeTypeName + } + + fun getRegisterSourceMapping(sourceInstance: String): String { + return resourceSourceMappings[sourceInstance] + ?: throw BluePrintException(format("failed to get source({}) mapping", sourceInstance)) + } + + fun getRegisterSourceMapping(): ResourceSourceMapping { + val resourceSourceMapping = ResourceSourceMapping() + resourceSourceMapping.resourceSourceMappings = resourceSourceMappings + return resourceSourceMapping + } +} + diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt new file mode 100644 index 000000000..d71fbbf80 --- /dev/null +++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt @@ -0,0 +1,163 @@ +/* + * 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.resource.dict.service + +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import org.apache.commons.collections.CollectionUtils +import org.apache.commons.lang3.StringUtils +import org.apache.commons.lang3.text.StrBuilder +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.core.format +import org.onap.ccsdk.apps.controllerblueprints.core.utils.TopologicalSortingUtils +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.factory.ResourceSourceMappingFactory +import java.io.Serializable + +/** + * ResourceAssignmentValidationService. + * + * @author Brinda Santh + */ +interface ResourceAssignmentValidationService : Serializable { + + @Throws(BluePrintException::class) + fun validate(resourceAssignments: List): Boolean +} + +/** + * ResourceAssignmentValidationServiceImpl. + * + * @author Brinda Santh + */ +open class ResourceAssignmentValidationServiceImpl : ResourceAssignmentValidationService { + private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceAssignmentValidationServiceImpl::class.java) + + open var resourceAssignmentMap: Map = hashMapOf() + open val validationMessage = StrBuilder() + + override fun validate(resourceAssignments: List): Boolean { + try { + validateSources(resourceAssignments) + validateTemplateNDictionaryKeys(resourceAssignments) + validateCyclicDependency(resourceAssignments) + if (StringUtils.isNotBlank(validationMessage)) { + throw BluePrintException("Resource Assignment Validation Failure") + } + } catch (e: Exception) { + throw BluePrintException("Resource Assignment Validation :" + validationMessage.toString(), e) + } + return true + } + + open fun validateSources(resourceAssignments: List) { + log.info("validating resource assignment sources") + // Check the Resource Assignment Source(Dynamic Instance) is valid. + resourceAssignments.forEach { resourceAssignment -> + try { + ResourceSourceMappingFactory.getRegisterSourceMapping(resourceAssignment.dictionarySource!!) + } catch (e: BluePrintException) { + validationMessage.appendln(e.message + format(" for resource assignment({})", resourceAssignment.name)) + } + } + } + + open fun validateTemplateNDictionaryKeys(resourceAssignments: List) { + + resourceAssignmentMap = resourceAssignments.map { it.name to it }.toMap() + + // Check the Resource Assignment has Duplicate Key Names + val duplicateKeyNames = resourceAssignments.groupBy { it.name } + .filter { it.value.size > 1 } + .map { it.key } + + if (duplicateKeyNames.isNotEmpty()) { + validationMessage.appendln(String.format("Duplicate Assignment Template Keys (%s) is Present", duplicateKeyNames)) + } + + // Check the Resource Assignment has Duplicate Dictionary Names + val duplicateDictionaryKeyNames = resourceAssignments.groupBy { it.dictionaryName } + .filter { it.value.size > 1 } + .map { it.key } + if (duplicateDictionaryKeyNames.isNotEmpty()) { + validationMessage.appendln(String.format("Duplicate Assignment Dictionary Keys (%s) is Present", duplicateDictionaryKeyNames)) + } + + // Collect all the dependencies as a single list + val dependenciesNames = resourceAssignments.mapNotNull { it.dependencies }.flatten() + + // Check all the dependencies keys have Resource Assignment mappings. + val notPresentDictionaries = dependenciesNames.filter { !resourceAssignmentMap.containsKey(it) }.distinct() + if (notPresentDictionaries.isNotEmpty()) { + validationMessage.appendln(String.format("No assignments for Dictionary Keys (%s)", notPresentDictionaries)) + } + + if (StringUtils.isNotBlank(validationMessage)) { + throw BluePrintException("Resource Assignment Validation Failure") + } + } + + open fun validateCyclicDependency(resourceAssignments: List) { + val startResourceAssignment = ResourceAssignment() + startResourceAssignment.name = "*" + + val topologySorting = TopologicalSortingUtils() + + resourceAssignmentMap.map { it.value }.map { resourceAssignment -> + if (CollectionUtils.isNotEmpty(resourceAssignment.dependencies)) { + resourceAssignment.dependencies!!.map { + log.info("Topological Graph link from {} to {}", it, resourceAssignment.name) + topologySorting.add(resourceAssignmentMap[it]!!, resourceAssignment) + } + } else { + topologySorting.add(startResourceAssignment, resourceAssignment) + } + } + + if (!topologySorting.isDag) { + val graph = getTopologicalGraph(topologySorting) + validationMessage.appendln("Cyclic Dependency :$graph") + } + } + + open fun getTopologicalGraph(topologySorting: TopologicalSortingUtils): String { + val s = StringBuilder() + val neighbors = topologySorting.getNeighbors() + + neighbors.forEach { v, vs -> + if (v.name == "*") { + s.append("\n * -> [") + for (resourceAssignment in vs) { + s.append("(" + resourceAssignment.dictionaryName + ":" + resourceAssignment.name + + "),") + } + s.append("]") + } else { + s.append("\n (" + v.dictionaryName + ":" + v.name + ") -> [") + for (resourceAssignment in vs) { + s.append("(" + resourceAssignment.dictionaryName + ":" + resourceAssignment.name + + "),") + } + s.append("]") + } + } + return s.toString() + } + + +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt new file mode 100644 index 000000000..9541a7b89 --- /dev/null +++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt @@ -0,0 +1,113 @@ +/* + * 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. + * 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.service + +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import com.fasterxml.jackson.databind.JsonNode +import com.google.common.base.Preconditions +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes +import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate +import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeType +import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition +import org.onap.ccsdk.apps.controllerblueprints.core.format +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintRepoService +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintExpressionService +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition +import java.io.Serializable + +/** + * ResourceDefinitionValidationService. + * + * @author Brinda Santh + */ +interface ResourceDefinitionValidationService : Serializable { + + @Throws(BluePrintException::class) + fun validate(resourceDefinition: ResourceDefinition) + +} + +/** + * ResourceDefinitionValidationService. + * + * @author Brinda Santh + */ +open class ResourceDefinitionValidationServiceImpl(private val bluePrintRepoService: BluePrintRepoService) : ResourceDefinitionValidationService { + + private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceDefinitionValidationService::class.java) + + override fun validate(resourceDefinition: ResourceDefinition) { + Preconditions.checkNotNull(resourceDefinition, "Failed to get Resource Definition") + log.trace("Validating Resource Dictionary Definition {}", resourceDefinition.name) + + resourceDefinition.sources.forEach { name, nodeTemplate -> + val sourceType = nodeTemplate.type + + val sourceNodeType = bluePrintRepoService.getNodeType(sourceType) + + // Validate Property Name, expression, values and Data Type + validateNodeTemplateProperties(nodeTemplate, sourceNodeType) + } + } + + + open fun validateNodeTemplateProperties(nodeTemplate: NodeTemplate, nodeType: NodeType) { + nodeTemplate.properties?.let { validatePropertyAssignments(nodeType.properties!!, nodeTemplate.properties!!) } + } + + + open fun validatePropertyAssignments(nodeTypeProperties: MutableMap, + properties: MutableMap) { + properties.forEach { propertyName, propertyAssignment -> + val propertyDefinition: PropertyDefinition = nodeTypeProperties[propertyName] + ?: throw BluePrintException(format("failed to get definition for the property ({})", propertyName)) + // Check and Validate if Expression Node + val expressionData = BluePrintExpressionService.getExpressionData(propertyAssignment) + if (!expressionData.isExpression) { + checkPropertyValue(propertyDefinition, propertyName, propertyAssignment) + } else { + throw BluePrintException(format("property({}) of expression ({}) is not supported", + propertyName, propertyAssignment)) + } + } + } + + open fun checkPropertyValue(propertyDefinition: PropertyDefinition, propertyName: String, propertyAssignment: JsonNode) { + val propertyType = propertyDefinition.type + val isValid: Boolean + + if (BluePrintTypes.validPrimitiveTypes().contains(propertyType)) { + isValid = JacksonUtils.checkJsonNodeValueOfPrimitiveType(propertyType, propertyAssignment) + + } else if (BluePrintTypes.validCollectionTypes().contains(propertyType)) { + + isValid = JacksonUtils.checkJsonNodeValueOfCollectionType(propertyType, propertyAssignment) + } else { + bluePrintRepoService.getDataType(propertyType) + isValid = true + } + + check(isValid) { + throw BluePrintException(format("property({}) defined of type({}) is not compatable with the value ({})", + propertyName, propertyType, propertyAssignment)) + } + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtils.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtils.kt new file mode 100644 index 000000000..cd92f42c0 --- /dev/null +++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtils.kt @@ -0,0 +1,109 @@ +/* + * 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.utils + +import com.att.eelf.configuration.EELFLogger +import org.apache.commons.collections.CollectionUtils +import org.onap.ccsdk.apps.controllerblueprints.core.utils.TopologicalSortingUtils +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment +import com.att.eelf.configuration.EELFManager +import java.util.ArrayList +/** + * BulkResourceSequencingUtils. + * + * @author Brinda Santh + */ +object BulkResourceSequencingUtils { + private val log: EELFLogger = EELFManager.getInstance().getLogger(BulkResourceSequencingUtils::class.java) + + @JvmStatic + fun process(resourceAssignments: MutableList): List> { + val resourceAssignmentMap: MutableMap = hashMapOf() + val sequenceBatchResourceAssignment = ArrayList>() + log.info("Assignments ({})", resourceAssignments) + // Prepare Map + resourceAssignments.forEach { resourceAssignment -> + log.trace("Processing Key ({})", resourceAssignment.name) + resourceAssignmentMap.put(resourceAssignment.name, resourceAssignment) + } + + val startResourceAssignment = ResourceAssignment() + startResourceAssignment.name = "*" + + // Preepare Sorting Map + val topologySorting = TopologicalSortingUtils() + resourceAssignmentMap.forEach { _, resourceAssignment -> + if (CollectionUtils.isNotEmpty(resourceAssignment.dependencies)) { + for (dependency in resourceAssignment.dependencies!!) { + topologySorting.add(resourceAssignmentMap[dependency]!!, resourceAssignment) + } + } else { + topologySorting.add(startResourceAssignment, resourceAssignment) + } + } + + val sequencedResourceAssignments: MutableList = topologySorting.topSort()!! as MutableList + log.info("Sorted Sequenced Assignments ({})", sequencedResourceAssignments) + + var batchResourceAssignment: MutableList? = null + var batchAssignmentName: MutableList? = null + + // Prepare Sorting + sequencedResourceAssignments.forEachIndexed { index, resourceAssignment -> + + var previousResourceAssignment: ResourceAssignment? = null + + if (index > 0) { + previousResourceAssignment = sequencedResourceAssignments[index - 1] + } + + var dependencyPresence = false + if (batchAssignmentName != null && resourceAssignment.dependencies != null) { + dependencyPresence = CollectionUtils.containsAny(batchAssignmentName, resourceAssignment.dependencies) + } + + log.trace("({}) -> Checking ({}), with ({}), result ({})", resourceAssignment.name, + batchAssignmentName, resourceAssignment.dependencies, dependencyPresence) + + if (previousResourceAssignment != null && resourceAssignment.dictionarySource != null + && resourceAssignment.dictionarySource!!.equals(previousResourceAssignment.dictionarySource, true) + && !dependencyPresence) { + batchResourceAssignment!!.add(resourceAssignment) + batchAssignmentName!!.add(resourceAssignment.name) + } else { + if (batchResourceAssignment != null) { + sequenceBatchResourceAssignment.add(batchResourceAssignment!!) + log.trace("Created old Set ({})", batchAssignmentName) + } + batchResourceAssignment = arrayListOf() + batchResourceAssignment!!.add(resourceAssignment) + + batchAssignmentName = arrayListOf() + batchAssignmentName!!.add(resourceAssignment.name) + } + + if (index == sequencedResourceAssignments.size - 1) { + log.trace("Created old Set ({})", batchAssignmentName) + sequenceBatchResourceAssignment.add(batchResourceAssignment!!) + } + } + log.info("Batched Sequence : ({})", sequenceBatchResourceAssignment) + + return sequenceBatchResourceAssignment + } + +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt new file mode 100644 index 000000000..1aeda0ba1 --- /dev/null +++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt @@ -0,0 +1,94 @@ +/* + * 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.resource.dict.utils + +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.node.NullNode +import org.apache.commons.collections.MapUtils +import org.apache.commons.lang3.StringUtils +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException +import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate +import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintFileUtils +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.ResourceDefinition +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants +import java.io.File + + +object ResourceDictionaryUtils { + private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceDictionaryUtils::class.java) + + @JvmStatic + fun populateSourceMapping(resourceAssignment: ResourceAssignment, + resourceDefinition: ResourceDefinition) { + + if (StringUtils.isBlank(resourceAssignment.dictionarySource)) { + + if (MapUtils.isNotEmpty(resourceDefinition.sources)) { + val source = findFirstSource(resourceDefinition.sources) + + // Populate and Assign First Source + if (StringUtils.isNotBlank(source)) { + // Set Dictionary Source + resourceAssignment.dictionarySource = source + } else { + resourceAssignment.dictionarySource = ResourceDictionaryConstants.SOURCE_INPUT + } + log.info("auto map resourceAssignment : {}", resourceAssignment) + } else { + resourceAssignment.dictionarySource = ResourceDictionaryConstants.SOURCE_INPUT + } + } + } + + @JvmStatic + fun findFirstSource(sources: Map): String? { + var source: String? = null + if (MapUtils.isNotEmpty(sources)) { + source = sources.keys.stream().findFirst().get() + } + return source + } + + @JvmStatic + fun assignInputs(data: JsonNode, context: MutableMap) { + log.trace("assignInputs from input JSON ({})", data.toString()) + data.fields().forEach { field -> + val valueNode: JsonNode = data.at("/".plus(field.key)) ?: NullNode.getInstance() + + val path = BluePrintConstants.PATH_INPUTS.plus(BluePrintConstants.PATH_DIVIDER).plus(field.key) + log.trace("setting path ({}), values ({})", path, valueNode) + context[path] = valueNode + } + } + + fun getResourceAssignmentFromFile(filePath: String): List { + return JacksonUtils.getListFromFile(filePath, ResourceAssignment::class.java) + ?: throw BluePrintProcessorException("couldn't get ResourceAssignment definitions for the file($filePath)") + } + + fun writeResourceDefinitionTypes(basePath: String, resourceDefinitionMap: Map) { + val typePath = basePath.plus(File.separator).plus(BluePrintConstants.TOSCA_DEFINITIONS_DIR) + .plus(File.separator).plus("${ResourceDictionaryConstants.PATH_RESOURCE_DEFINITION_TYPE}.json") + val resourceDefinitionContent = JacksonUtils.getJson(resourceDefinitionMap.toSortedMap(), true) + BluePrintFileUtils.writeDefinitionFile(typePath, resourceDefinitionContent) + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java new file mode 100644 index 000000000..d059d1ba5 --- /dev/null +++ b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDefinitionTest.java @@ -0,0 +1,60 @@ +/* + * 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.resource.dict; + +import org.junit.Assert; +import org.junit.Test; +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + +public class ResourceDefinitionTest { + private EELFLogger log = EELFManager.getInstance().getLogger(ResourceDefinitionTest.class); + private String basePath = "load/resource_dictionary"; + + @Test + public void testDictionaryDefinitionInputSource(){ + + String fileName = basePath + "/input-source.json"; + ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class); + Assert.assertNotNull("Failed to populate dictionaryDefinition for input type", resourceDefinition); + } + + @Test + public void testDictionaryDefinitionDefaultSource(){ + + String fileName = basePath + "/default-source.json"; + ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class); + Assert.assertNotNull("Failed to populate dictionaryDefinition for default type", resourceDefinition); + } + + @Test + public void testDictionaryDefinitionDBSource(){ + + String fileName = basePath + "/primary-db-source.json"; + ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class); + Assert.assertNotNull("Failed to populate dictionaryDefinition for primary-db type", resourceDefinition); + } + + @Test + public void testDictionaryDefinitionMDSALSource(){ + String fileName = basePath + "/mdsal-source.json"; + ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class); + Assert.assertNotNull("Failed to populate dictionaryDefinition for mdsal type", resourceDefinition); + } +} diff --git a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactoryTest.java b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactoryTest.java new file mode 100644 index 000000000..3950ae367 --- /dev/null +++ b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/factory/ResourceSourceMappingFactoryTest.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.resource.dict.factory; + +import org.junit.Test; +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceSourceMapping; +import org.springframework.util.Assert; + +public class ResourceSourceMappingFactoryTest { + + @Test + public void testRegisterResourceMapping() { + + ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("primary-db", "source-primary-db"); + ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("input", "source-input"); + ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("default", "source-default"); + ResourceSourceMappingFactory.INSTANCE.registerSourceMapping("primary-config-data", "source-rest"); + + String nodeTypeName = ResourceSourceMappingFactory.INSTANCE.getRegisterSourceMapping("primary-db"); + Assert.notNull(nodeTypeName, "Failed to get primary-db mapping"); + + ResourceSourceMapping resourceSourceMapping = ResourceSourceMappingFactory.INSTANCE.getRegisterSourceMapping(); + Assert.notNull(resourceSourceMapping, "Failed to get resource source mapping"); + Assert.notNull(resourceSourceMapping.getResourceSourceMappings(), "Failed to get resource source mappings"); + + } + +} diff --git a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.kt new file mode 100644 index 000000000..8905dab60 --- /dev/null +++ b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationServiceTest.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.resource.dict.service + +import com.att.eelf.configuration.EELFLogger +import org.junit.Assert +import org.junit.Test +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment +import com.att.eelf.configuration.EELFManager +import org.junit.Before +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.ResourceDictionaryTestUtils + +/** + * ResourceAssignmentValidationServiceTest. + * + * @author Brinda Santh + */ +class ResourceAssignmentValidationServiceTest { + private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceAssignmentValidationServiceTest::class.java) + @Before + fun setUp() { + // Setup dummy Source Instance Mapping + ResourceDictionaryTestUtils.setUpResourceSourceMapping() + } + + @Test + fun testValidateSuccess() { + log.info("**************** testValidateSuccess *****************") + val assignments = JacksonUtils.getListFromClassPathFile("validation/success.json", ResourceAssignment::class.java) + val resourceAssignmentValidator = ResourceAssignmentValidationServiceImpl() + val result = resourceAssignmentValidator.validate(assignments!!) + Assert.assertTrue("Failed to Validate", result) + } + + @Test(expected = BluePrintException::class) + fun testValidateDuplicate() { + log.info(" **************** testValidateDuplicate *****************") + val assignments = JacksonUtils.getListFromClassPathFile("validation/duplicate.json", ResourceAssignment::class.java) + val resourceAssignmentValidator = ResourceAssignmentValidationServiceImpl() + resourceAssignmentValidator.validate(assignments!!) + } + + @Test(expected = BluePrintException::class) + fun testValidateCyclic() { + log.info(" **************** testValidateCyclic *****************") + val assignments = JacksonUtils.getListFromClassPathFile("validation/cyclic.json", ResourceAssignment::class.java) + val resourceAssignmentValidator = ResourceAssignmentValidationServiceImpl() + resourceAssignmentValidator.validate(assignments!!) + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationServiceTest.java b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationServiceTest.java new file mode 100644 index 000000000..7f040b2e2 --- /dev/null +++ b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationServiceTest.java @@ -0,0 +1,56 @@ +/* + * 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.resource.dict.service; + +import org.junit.Assert; +import org.junit.Test; +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoFileService; +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils; +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition; + +public class ResourceDefinitionValidationServiceTest { + private String basePath = "load/model_type"; + private String dictionaryPath = "load/resource_dictionary"; + private BluePrintRepoFileService bluePrintRepoFileService = new BluePrintRepoFileService(basePath); + + @Test + public void testValidateSource() throws Exception { + + String inputFileName = dictionaryPath + "/input-source.json"; + testValidate(inputFileName); + + String dbFileName = dictionaryPath + "/primary-db-source.json"; + testValidate(dbFileName); + + String defaultFileName = dictionaryPath + "/default-source.json"; + testValidate(defaultFileName); + + String restFileName = dictionaryPath + "/mdsal-source.json"; + testValidate(restFileName); + } + + private void testValidate(String fileName) throws Exception { + + ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class); + Assert.assertNotNull("Failed to populate dictionaryDefinition for type", resourceDefinition); + + ResourceDefinitionValidationService resourceDictionaryValidationService = + new ResourceDefinitionValidationServiceImpl(bluePrintRepoFileService); + resourceDictionaryValidationService.validate(resourceDefinition); + Assert.assertNotNull(String.format("Failed to populate dictionaryDefinition for : %s", fileName), resourceDefinition); + } +} diff --git a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtilsTest.java b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtilsTest.java new file mode 100644 index 000000000..c1b9f5007 --- /dev/null +++ b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/BulkResourceSequencingUtilsTest.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.resource.dict.utils; + +import org.junit.Assert; +import org.junit.Test; +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils; +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment; +import java.util.List; +/** + * BulkResourceSequencingUtils. + * + * @author Brinda Santh + */ +public class BulkResourceSequencingUtilsTest { + + @Test + public void testProcess(){ + List assignments = JacksonUtils.Companion.getListFromClassPathFile("validation/success.json", ResourceAssignment.class); + Assert.assertNotNull("failed to get ResourceAssignment from validation/success.json ", assignments); + BulkResourceSequencingUtils.process(assignments); + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java new file mode 100644 index 000000000..e4ddac131 --- /dev/null +++ b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtilsTest.java @@ -0,0 +1,99 @@ +/* + * 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.resource.dict.utils; + + +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.data.NodeTemplate; +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.ResourceDefinition; +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + +import java.util.HashMap; +import java.util.Map; +/** + * ResourceDictionaryUtilsTest. + * + * @author Brinda Santh + */ +public class ResourceDictionaryUtilsTest { + private static final EELFLogger log = EELFManager.getInstance().getLogger(ResourceDictionaryUtilsTest.class); + + @Test + public void testPopulateSourceMapping() { + + ResourceAssignment resourceAssignment = new ResourceAssignment(); + resourceAssignment.setName("sample-assignment"); + ResourceDefinition resourceDefinition = new ResourceDefinition(); + Map sources = new HashMap<>(); + resourceDefinition.setSources(sources); + // To Check Empty Source + ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, resourceDefinition); + Assert.assertEquals("Expected Empty source Input, but.", ResourceDictionaryConstants.SOURCE_INPUT, resourceAssignment.getDictionarySource()); + + // To Check First Source + resourceAssignment.setDictionarySource(null); + sources.put(ResourceDictionaryConstants.SOURCE_DEFAULT, new NodeTemplate()); + ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, resourceDefinition); + Assert.assertEquals("Expected First source Default, but.", ResourceDictionaryConstants.SOURCE_DEFAULT, resourceAssignment.getDictionarySource()); + + // To Check Assigned Source + resourceAssignment.setDictionarySource(ResourceDictionaryConstants.SOURCE_PRIMARY_DB); + ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, resourceDefinition); + Assert.assertEquals("Expected Assigned source DB, but.", ResourceDictionaryConstants.SOURCE_PRIMARY_DB, resourceAssignment.getDictionarySource()); + + } + + @Test + public void testFindFirstSource() { + //To check if Empty Source + Map sources = new HashMap<>(); + String firstSource = ResourceDictionaryUtils.findFirstSource(sources); + Assert.assertNull("Source populated, which is not expected.", firstSource); + + // TO check the first Source + sources.put(ResourceDictionaryConstants.SOURCE_INPUT, new NodeTemplate()); + String inputFirstSource = ResourceDictionaryUtils.findFirstSource(sources); + Assert.assertEquals("Expected source Input, but.", ResourceDictionaryConstants.SOURCE_INPUT, inputFirstSource); + + // TO check the multiple Source + sources.put(ResourceDictionaryConstants.SOURCE_PRIMARY_DB, new NodeTemplate()); + String multipleFirstSource = ResourceDictionaryUtils.findFirstSource(sources); + Assert.assertEquals("Expected source Input, but.", ResourceDictionaryConstants.SOURCE_INPUT, multipleFirstSource); + + } + + @Test + public void testAssignInputs() { + JsonNode data = JacksonUtils.Companion.jsonNodeFromClassPathFile("data/resource-assignment-input.json"); + Map context = new HashMap<>(); + ResourceDictionaryUtils.assignInputs(data, context); + String path = BluePrintConstants.PATH_INPUTS.concat(BluePrintConstants.PATH_DIVIDER).concat("mapValue"); + log.info("populated context {}", context); + Assert.assertTrue(String.format("failed to get variable : %s",path),context.containsKey(path)); + + } + + +} diff --git a/ms/controllerblueprints/modules/resource-dict/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryTestUtils.kt b/ms/controllerblueprints/modules/resource-dict/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryTestUtils.kt new file mode 100644 index 000000000..ed2bfc0a1 --- /dev/null +++ b/ms/controllerblueprints/modules/resource-dict/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryTestUtils.kt @@ -0,0 +1,30 @@ +/* + * 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.utils + +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.factory.ResourceSourceMappingFactory + +object ResourceDictionaryTestUtils { + + @JvmStatic + fun setUpResourceSourceMapping() { + ResourceSourceMappingFactory.registerSourceMapping("primary-db", "source-primary-db") + ResourceSourceMappingFactory.registerSourceMapping("input", "source-input") + ResourceSourceMappingFactory.registerSourceMapping("default", "source-default") + ResourceSourceMappingFactory.registerSourceMapping("primary-config-data", "source-rest") + } +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/resource-dict/src/test/resources/data/resource-assignment-input.json b/ms/controllerblueprints/modules/resource-dict/src/test/resources/data/resource-assignment-input.json new file mode 100644 index 000000000..d79c90682 --- /dev/null +++ b/ms/controllerblueprints/modules/resource-dict/src/test/resources/data/resource-assignment-input.json @@ -0,0 +1,10 @@ +{ + "intValue" : 1, + "floatValue" : 1.34, + "booleanValue" : true, + "stringValue" : "sample-String", + "timeValue" : "2018-09-29", + "arrayStringValue" : ["one", "two"], + "mapValue" : {"profile_name1":"profile_name1", + "profile_name2":"profile_name2"} +} \ No newline at end of file diff --git a/ms/controllerblueprints/modules/resource-dict/src/test/resources/validation/cyclic.json b/ms/controllerblueprints/modules/resource-dict/src/test/resources/validation/cyclic.json new file mode 100644 index 000000000..3bfa4167d --- /dev/null +++ b/ms/controllerblueprints/modules/resource-dict/src/test/resources/validation/cyclic.json @@ -0,0 +1,111 @@ +[ + { + "name": "vnf-id", + "input-param": true, + "property": { + "type": "string", + "required": true + }, + "dictionary-name": "vnf-id", + "dictionary-source": "input", + "dependencies": [] + }, + { + "name": "service-instance-id", + "input-param": true, + "property": { + "type": "string", + "required": true + }, + "dictionary-name": "service-instance-id", + "dictionary-source": "input", + "dependencies": [] + }, + { + "name": "bundle-id", + "input-param": true, + "property": { + "type": "string", + "required": true + }, + "dictionary-name": "bundle-id", + "dictionary-source": "primary-config-data", + "dependencies": [ + "vnf-id" + ] + }, + { + "name": "bundle-ip", + "input-param": true, + "property": { + "type": "string", + "required": true + }, + "dictionary-name": "bundle-ip", + "dictionary-source": "primary-config-data", + "dependencies": [ + "vnf-id" + ] + }, + { + "name": "bundle-mac", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "bundle-mac", + "dictionary-source": "primary-config-data", + "dependencies": [ + "vnf-id", + "bundle-id" + ] + }, + { + "name": "managed-ip", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "managed-ip", + "dictionary-source": "primary-config-data", + "dependencies": [ + "loopback-ip" + ] + }, + { + "name": "vnf-name", + "input-param": true, + "property": { + "type": "string", + "required": true + }, + "dictionary-name": "vnf-name", + "dictionary-source": "input", + "dependencies": [] + }, + { + "name": "managed-ip1", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "managed-ip1", + "dictionary-source": "primary-config-data", + "dependencies": [ + "loopback-ip" + ] + }, + { + "name": "loopback-ip", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "loopback-ip", + "dictionary-source": "primary-db", + "dependencies": [ + "bundle-mac", + "managed-ip1" + ] + } +] diff --git a/ms/controllerblueprints/modules/resource-dict/src/test/resources/validation/duplicate.json b/ms/controllerblueprints/modules/resource-dict/src/test/resources/validation/duplicate.json new file mode 100644 index 000000000..473920d6d --- /dev/null +++ b/ms/controllerblueprints/modules/resource-dict/src/test/resources/validation/duplicate.json @@ -0,0 +1,110 @@ +[ + { + "name": "vnf-id", + "input-param": true, + "property": { + "type": "string", + "required": true + }, + "dictionary-name": "vnf-id", + "dictionary-source": "input", + "dependencies": [] + }, + { + "name": "service-instance-id", + "input-param": true, + "property": { + "type": "string", + "required": true + }, + "dictionary-name": "service-instance-id", + "dictionary-source": "input", + "dependencies": [] + }, + { + "name": "bundle-id", + "input-param": true, + "property": { + "type": "string", + "required": true + }, + "dictionary-name": "bundle-id", + "dictionary-source": "primary-config-data", + "dependencies": [ + "vnf-id" + ] + }, + { + "name": "bundle-ip", + "input-param": true, + "property": { + "type": "string", + "required": true + }, + "dictionary-name": "bundle-ip", + "dictionary-source": "primary-config-data", + "dependencies": [ + "vnf-id" + ] + }, + { + "name": "bundle-mac", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "bundle-mac", + "dictionary-source": "primary-config-data", + "dependencies": [ + "vnf-id", + "bundle-id" + ] + }, + { + "name": "bundle-mac", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "bundle-mac", + "dictionary-source": "primary-config-data", + "dependencies": [ + "loopback-ip" + ] + }, + { + "name": "vnf-name", + "input-param": true, + "property": { + "type": "string", + "required": true + }, + "dictionary-name": "vnf-name", + "dictionary-source": "input", + "dependencies": [] + }, + { + "name": "managed-ip1", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "managed-ip1", + "dictionary-source": "primary-config-data", + "dependencies": [ + "loopback-ip" + ] + }, + { + "name": "loopback-ip", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "loopback-ip", + "dictionary-source": "primary-db", + "dependencies": [ + "bundle-mac" + ] + } +] diff --git a/ms/controllerblueprints/modules/resource-dict/src/test/resources/validation/success.json b/ms/controllerblueprints/modules/resource-dict/src/test/resources/validation/success.json new file mode 100644 index 000000000..f8fe623fd --- /dev/null +++ b/ms/controllerblueprints/modules/resource-dict/src/test/resources/validation/success.json @@ -0,0 +1,110 @@ +[ + { + "name": "vnf-id", + "input-param": true, + "property": { + "type": "string", + "required": true + }, + "dictionary-name": "vnf-id", + "dictionary-source": "input", + "dependencies": [] + }, + { + "name": "service-instance-id", + "input-param": true, + "property": { + "type": "string", + "required": true + }, + "dictionary-name": "service-instance-id", + "dictionary-source": "input", + "dependencies": [] + }, + { + "name": "bundle-id", + "input-param": true, + "property": { + "type": "string", + "required": true + }, + "dictionary-name": "bundle-id", + "dictionary-source": "primary-config-data", + "dependencies": [ + "vnf-id" + ] + }, + { + "name": "bundle-ip", + "input-param": true, + "property": { + "type": "string", + "required": true + }, + "dictionary-name": "bundle-ip", + "dictionary-source": "primary-config-data", + "dependencies": [ + "vnf-id" + ] + }, + { + "name": "bundle-mac", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "bundle-mac", + "dictionary-source": "primary-config-data", + "dependencies": [ + "vnf-id", + "bundle-id" + ] + }, + { + "name": "managed-ip", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "managed-ip", + "dictionary-source": "primary-config-data", + "dependencies": [ + "loopback-ip" + ] + }, + { + "name": "vnf-name", + "input-param": true, + "property": { + "type": "string", + "required": true + }, + "dictionary-name": "vnf-name", + "dictionary-source": "input", + "dependencies": [] + }, + { + "name": "managed-ip1", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "managed-ip1", + "dictionary-source": "primary-config-data", + "dependencies": [ + "loopback-ip" + ] + }, + { + "name": "loopback-ip", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "loopback-ip", + "dictionary-source": "primary-db", + "dependencies": [ + "bundle-mac" + ] + } +] diff --git a/ms/controllerblueprints/parent/pom.xml b/ms/controllerblueprints/parent/pom.xml index 8cbc98e03..f29e50147 100644 --- a/ms/controllerblueprints/parent/pom.xml +++ b/ms/controllerblueprints/parent/pom.xml @@ -16,7 +16,8 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License. --> - + 4.0.0 org.onap.ccsdk.apps @@ -41,6 +42,7 @@ 1.4.197 1.2.2 1.7.4 + 1.9
@@ -91,12 +93,17 @@ commons-io 2.6 + + org.apache.commons + commons-compress + 1.15 + org.apache.velocity velocity 1.7 - + com.google.guava guava ${guava.version} @@ -142,8 +149,8 @@ ${kotlin.version} - org.jetbrains.kotlin - kotlinx-couroutines-core + org.jetbrains.kotlinx + kotlinx-coroutines-core ${kotlin.couroutines.version} @@ -205,7 +212,7 @@ org.onap.ccsdk.apps.controllerblueprints - core + blueprint-core ${project.version} @@ -240,6 +247,12 @@ + + io.mockk + mockk + ${mockk.version} + test + org.powermock powermock-api-mockito2 @@ -252,6 +265,12 @@ ${kotlin.version} test + + org.jetbrains.kotlinx + kotlinx-coroutines-test + ${kotlin.couroutines.version} + test + io.grpc grpc-testing @@ -273,7 +292,7 @@ org.apache.commons commons-lang3 - + commons-collections commons-collections @@ -282,6 +301,10 @@ commons-io commons-io + + org.apache.commons + commons-compress + com.jayway.jsonpath json-path @@ -302,14 +325,43 @@ org.jetbrains.kotlin kotlin-stdlib + + org.jetbrains.kotlin + kotlin-script-util + org.jetbrains.kotlin kotlin-stdlib-jdk8 + + org.jetbrains.kotlinx + kotlinx-coroutines-core + + + org.jetbrains.kotlinx + kotlinx-coroutines-reactor + com.fasterxml.jackson.module jackson-module-kotlin + + + io.grpc + grpc-netty + + + io.grpc + grpc-protobuf + + + io.grpc + grpc-stub + + + com.google.protobuf + protobuf-java-util + -- cgit 1.2.3-korg From 03fe8619e5e5f0545b8138565ea2dae7dd6abf48 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh" Date: Mon, 18 Feb 2019 15:10:25 -0500 Subject: Add component function scripting service Change-Id: I7c5b49617823dd623566fb4be4d431012420e17c Issue-ID: CCSDK-959 Signed-off-by: Muthuramalingam, Brinda Santh --- .../org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt | 1 + ms/controllerblueprints/parent/pom.xml | 1 + 2 files changed, 2 insertions(+) (limited to 'ms/controllerblueprints/parent') diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt index 8724a9f3f..d89e95471 100644 --- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt @@ -154,6 +154,7 @@ object BluePrintConstants { const val TOSCA_SCRIPTS_DIR: String = "Scripts" const val TOSCA_MAPPINGS_DIR: String = "Mappings" const val TOSCA_TEMPLATES_DIR: String = "Templates" + const val TOSCA_ENVIRONMENTS_DIR: String = "Environments" const val TOSCA_SCRIPTS_KOTLIN_DIR: String = "$TOSCA_SCRIPTS_DIR/kotlin" const val TOSCA_SCRIPTS_JYTHON_DIR: String = "$TOSCA_SCRIPTS_DIR/python" diff --git a/ms/controllerblueprints/parent/pom.xml b/ms/controllerblueprints/parent/pom.xml index f29e50147..ea7b4e40b 100644 --- a/ms/controllerblueprints/parent/pom.xml +++ b/ms/controllerblueprints/parent/pom.xml @@ -29,6 +29,7 @@ Controller Blueprints Parent pom + 1.8 2.1.2.RELEASE 5.1.4.RELEASE 1.3.20 -- cgit 1.2.3-korg From d266712c2ef530b66eee6d40d4acaf3e652a8eee Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh" Date: Wed, 27 Feb 2019 20:47:17 -0500 Subject: Upgrade spring and kotlin versions Change-Id: Ie02db28a857f6aa53eed0d578407c09fb57298a0 Issue-ID: CCSDK-1111 Signed-off-by: Muthuramalingam, Brinda Santh --- ms/controllerblueprints/parent/pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'ms/controllerblueprints/parent') diff --git a/ms/controllerblueprints/parent/pom.xml b/ms/controllerblueprints/parent/pom.xml index ea7b4e40b..f59effc46 100644 --- a/ms/controllerblueprints/parent/pom.xml +++ b/ms/controllerblueprints/parent/pom.xml @@ -30,10 +30,10 @@ pom 1.8 - 2.1.2.RELEASE - 5.1.4.RELEASE - 1.3.20 - 1.3.20 + 2.1.3.RELEASE + 5.1.5.RELEASE + 1.3.21 + 1.3.21 1.1.1 1.18.0 3.6.1 -- cgit 1.2.3-korg From fcfc57138b81b220d729392d3241a14ead418e5a Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Thu, 14 Mar 2019 13:55:01 -0400 Subject: Prepare for release 0.4.1 Prepare to create release version 0.4.1 by using released version of parent pom Change-Id: Icf8432e14626a55b916b6f4d4a8992b79c29eff7 Issue-ID: CCSDK-1156 Signed-off-by: Timoney, Dan (dt5972) --- ms/controllerblueprints/modules/blueprint-core/pom.xml | 7 +------ ms/controllerblueprints/modules/blueprint-scripts/pom.xml | 7 ++----- ms/controllerblueprints/parent/pom.xml | 3 +-- 3 files changed, 4 insertions(+), 13 deletions(-) (limited to 'ms/controllerblueprints/parent') diff --git a/ms/controllerblueprints/modules/blueprint-core/pom.xml b/ms/controllerblueprints/modules/blueprint-core/pom.xml index 9461b2ca5..ca47b59a1 100644 --- a/ms/controllerblueprints/modules/blueprint-core/pom.xml +++ b/ms/controllerblueprints/modules/blueprint-core/pom.xml @@ -15,11 +15,7 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License. --> - - + 4.0.0 org.onap.ccsdk.apps.controllerblueprints @@ -73,4 +69,3 @@ - diff --git a/ms/controllerblueprints/modules/blueprint-scripts/pom.xml b/ms/controllerblueprints/modules/blueprint-scripts/pom.xml index e0858d202..cb2c33ed8 100644 --- a/ms/controllerblueprints/modules/blueprint-scripts/pom.xml +++ b/ms/controllerblueprints/modules/blueprint-scripts/pom.xml @@ -14,10 +14,7 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License. --> - - + modules org.onap.ccsdk.apps.controllerblueprints @@ -60,4 +57,4 @@ - \ No newline at end of file + diff --git a/ms/controllerblueprints/parent/pom.xml b/ms/controllerblueprints/parent/pom.xml index f59effc46..9ba4a2d40 100644 --- a/ms/controllerblueprints/parent/pom.xml +++ b/ms/controllerblueprints/parent/pom.xml @@ -16,8 +16,7 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License. --> - + 4.0.0 org.onap.ccsdk.apps -- cgit 1.2.3-korg From 9b8aec2337c30ae01c54917059f46d4b6cac1362 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Tue, 19 Mar 2019 16:31:51 -0400 Subject: Compile against Fluorine SR2 Updated to compile against Fluorine SR2 Change-Id: I434068531ce4a661a04c20201e0fddf3f6b92f47 Issue-ID: CCSDK-1156 Signed-off-by: Timoney, Dan (dt5972) --- ms/controllerblueprints/application/pom.xml | 2 +- ms/controllerblueprints/distribution/pom.xml | 2 +- ms/controllerblueprints/modules/blueprint-core/pom.xml | 2 +- ms/controllerblueprints/modules/blueprint-scripts/pom.xml | 2 +- ms/controllerblueprints/modules/blueprint-validation/pom.xml | 2 +- ms/controllerblueprints/modules/db-resources/pom.xml | 2 +- ms/controllerblueprints/modules/pom.xml | 2 +- ms/controllerblueprints/modules/resource-dict/pom.xml | 2 +- ms/controllerblueprints/modules/service/pom.xml | 2 +- ms/controllerblueprints/parent/pom.xml | 2 +- ms/controllerblueprints/pom.xml | 4 ++-- 11 files changed, 12 insertions(+), 12 deletions(-) (limited to 'ms/controllerblueprints/parent') diff --git a/ms/controllerblueprints/application/pom.xml b/ms/controllerblueprints/application/pom.xml index a01a61347..4a7335496 100644 --- a/ms/controllerblueprints/application/pom.xml +++ b/ms/controllerblueprints/application/pom.xml @@ -21,7 +21,7 @@ org.onap.ccsdk.apps.controllerblueprints parent - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT ../parent application diff --git a/ms/controllerblueprints/distribution/pom.xml b/ms/controllerblueprints/distribution/pom.xml index c73d15b6e..4a1b60496 100755 --- a/ms/controllerblueprints/distribution/pom.xml +++ b/ms/controllerblueprints/distribution/pom.xml @@ -20,7 +20,7 @@ org.onap.ccsdk.apps.controllerblueprints parent - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT ../parent distribution diff --git a/ms/controllerblueprints/modules/blueprint-core/pom.xml b/ms/controllerblueprints/modules/blueprint-core/pom.xml index ca47b59a1..ee321b712 100644 --- a/ms/controllerblueprints/modules/blueprint-core/pom.xml +++ b/ms/controllerblueprints/modules/blueprint-core/pom.xml @@ -20,7 +20,7 @@ org.onap.ccsdk.apps.controllerblueprints modules - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT blueprint-core Controller Blueprints Core diff --git a/ms/controllerblueprints/modules/blueprint-scripts/pom.xml b/ms/controllerblueprints/modules/blueprint-scripts/pom.xml index cb2c33ed8..81f0cc774 100644 --- a/ms/controllerblueprints/modules/blueprint-scripts/pom.xml +++ b/ms/controllerblueprints/modules/blueprint-scripts/pom.xml @@ -18,7 +18,7 @@ modules org.onap.ccsdk.apps.controllerblueprints - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT 4.0.0 blueprint-scripts diff --git a/ms/controllerblueprints/modules/blueprint-validation/pom.xml b/ms/controllerblueprints/modules/blueprint-validation/pom.xml index 59b0e095a..7ac6a020e 100644 --- a/ms/controllerblueprints/modules/blueprint-validation/pom.xml +++ b/ms/controllerblueprints/modules/blueprint-validation/pom.xml @@ -21,7 +21,7 @@ org.onap.ccsdk.apps.controllerblueprints modules - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT blueprint-validation Controller Blueprints Validation Service diff --git a/ms/controllerblueprints/modules/db-resources/pom.xml b/ms/controllerblueprints/modules/db-resources/pom.xml index b2f4370be..d1c3c44c3 100644 --- a/ms/controllerblueprints/modules/db-resources/pom.xml +++ b/ms/controllerblueprints/modules/db-resources/pom.xml @@ -21,7 +21,7 @@ org.onap.ccsdk.apps.controllerblueprints modules - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT db-resources Controller Blueprints DB Resources diff --git a/ms/controllerblueprints/modules/pom.xml b/ms/controllerblueprints/modules/pom.xml index 1ef81ea4c..9275921e4 100644 --- a/ms/controllerblueprints/modules/pom.xml +++ b/ms/controllerblueprints/modules/pom.xml @@ -20,7 +20,7 @@ org.onap.ccsdk.apps.controllerblueprints parent - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT ../parent modules diff --git a/ms/controllerblueprints/modules/resource-dict/pom.xml b/ms/controllerblueprints/modules/resource-dict/pom.xml index edffdfb6b..22533dbed 100644 --- a/ms/controllerblueprints/modules/resource-dict/pom.xml +++ b/ms/controllerblueprints/modules/resource-dict/pom.xml @@ -21,7 +21,7 @@ org.onap.ccsdk.apps.controllerblueprints modules - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT resource-dict Controller Blueprints Resource Dictionary diff --git a/ms/controllerblueprints/modules/service/pom.xml b/ms/controllerblueprints/modules/service/pom.xml index 73fe0739b..7ca7e0db0 100644 --- a/ms/controllerblueprints/modules/service/pom.xml +++ b/ms/controllerblueprints/modules/service/pom.xml @@ -21,7 +21,7 @@ org.onap.ccsdk.apps.controllerblueprints modules - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT service Controller Blueprints Service diff --git a/ms/controllerblueprints/parent/pom.xml b/ms/controllerblueprints/parent/pom.xml index 9ba4a2d40..44a5ec843 100644 --- a/ms/controllerblueprints/parent/pom.xml +++ b/ms/controllerblueprints/parent/pom.xml @@ -21,7 +21,7 @@ org.onap.ccsdk.apps controllerblueprints - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT org.onap.ccsdk.apps.controllerblueprints parent diff --git a/ms/controllerblueprints/pom.xml b/ms/controllerblueprints/pom.xml index 6d6dae6ba..398082338 100644 --- a/ms/controllerblueprints/pom.xml +++ b/ms/controllerblueprints/pom.xml @@ -18,12 +18,12 @@ org.onap.ccsdk.apps ccsdk-apps-ms - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT 4.0.0 controllerblueprints Controller Blueprints Root - 0.4.1-SNAPSHOT + 0.4.2-SNAPSHOT ControllerBlueprints UTF-8 -- cgit 1.2.3-korg