aboutsummaryrefslogtreecommitdiffstats
path: root/ms
diff options
context:
space:
mode:
Diffstat (limited to 'ms')
-rw-r--r--ms/blueprintsprocessor/.gitignore1
-rw-r--r--ms/blueprintsprocessor/application/pom.xml4
-rw-r--r--ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/SwaggerConfig.java15
-rw-r--r--ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/WebConfig.java14
-rw-r--r--ms/blueprintsprocessor/functions/pom.xml1
-rw-r--r--ms/blueprintsprocessor/functions/python-executor/pom.xml41
-rw-r--r--ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/ComponentJythonExecutor.kt83
-rw-r--r--ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/JythonExecutionService.kt51
-rw-r--r--ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/PythonExecutorConfiguration.kt36
-rw-r--r--ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/utils/PythonExecutorUtils.kt77
-rw-r--r--ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/ComponentJythonExecutorTest.kt76
-rw-r--r--ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/utils/PythonExecutorUtilsTest.kt52
-rw-r--r--ms/blueprintsprocessor/functions/python-executor/src/test/resources/logback-test.xml35
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/pom.xml4
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt2
-rw-r--r--ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt8
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt34
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintDGExecutionService.kt71
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintSvcLogicService.kt17
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/WorkflowServiceConfiguration.kt7
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/executor/ComponentExecuteNodeExecutor.kt2
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintDGExecutionServiceTest.kt53
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintServiceLogicTest.kt14
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/mock/MockComponentFunction.kt3
-rw-r--r--ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/execution-input/default-input.json20
-rw-r--r--ms/blueprintsprocessor/parent/pom.xml58
-rw-r--r--ms/controllerblueprints/application/etc/logback.xml2
-rw-r--r--ms/controllerblueprints/application/opt/app/onap/config/application-dev.properties2
-rw-r--r--ms/controllerblueprints/application/opt/app/onap/config/application.properties2
-rw-r--r--ms/controllerblueprints/application/pom.xml53
-rw-r--r--ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/ApplicationExceptionHandler.java74
-rw-r--r--ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/SwaggerConfig.java7
-rw-r--r--ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/WebConfig.java11
-rw-r--r--ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/filters/ApplicationLoggingFilter.java91
-rw-r--r--ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/filters/CorsFilter.java64
-rw-r--r--ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/security/ApplicationBasicAuthenticationEntryPoint.java43
-rw-r--r--ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/security/ApplicationSecurityConfigurerAdapter.java74
-rw-r--r--ms/controllerblueprints/application/src/test/resources/application.properties2
-rw-r--r--ms/controllerblueprints/modules/service/pom.xml4
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java12
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelValidatorService.java2
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/DataBaseInitService.java648
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/SchemaGeneratorService.java2
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/SwaggerGenerator.java12
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModelContent.java1
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ModelType.java3
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ResourceDictionary.java3
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/repository/ConfigModelContentRepository.java1
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRest.java1
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java1
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java11
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ServiceTemplateRest.java4
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/utils/ConfigModelUtils.java1
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerService.kt39
-rw-r--r--ms/controllerblueprints/modules/service/src/test/resources/enhance/enhance-template.json4
-rw-r--r--ms/controllerblueprints/modules/service/src/test/resources/enhance/enhanced-template.json15
-rw-r--r--ms/controllerblueprints/parent/pom.xml12
-rw-r--r--ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/persistence/ApplicationConfig.java11
-rw-r--r--ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/persistence/NamePersister.java2
-rw-r--r--ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicyReader.java11
-rw-r--r--ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/service/SpringServiceImpl.java3
-rw-r--r--ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/service/rs/RestServiceImpl.java14
-rw-r--r--ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/service/extinf/impl/PolicyFinderServiceImpl.java4
-rw-r--r--ms/vlantag-api/src/main/java/org/onap/ccsdk/apps/ms/vlantagapi/extinf/pm/PolicyManagerClient.java2
64 files changed, 1310 insertions, 717 deletions
diff --git a/ms/blueprintsprocessor/.gitignore b/ms/blueprintsprocessor/.gitignore
index b25ff7b0..983e231d 100644
--- a/ms/blueprintsprocessor/.gitignore
+++ b/ms/blueprintsprocessor/.gitignore
@@ -15,6 +15,7 @@
**/target/*
**/logs/*
**/tokens/*
+**/lib/cachedir/**
# Added for Intellij IDEA IDE
**/debug-logs/*
diff --git a/ms/blueprintsprocessor/application/pom.xml b/ms/blueprintsprocessor/application/pom.xml
index 086a9883..4e652d50 100644
--- a/ms/blueprintsprocessor/application/pom.xml
+++ b/ms/blueprintsprocessor/application/pom.xml
@@ -36,10 +36,6 @@
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-web</artifactId>
- </dependency>
<!-- North Bound -->
<dependency>
<groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
diff --git a/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/SwaggerConfig.java b/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/SwaggerConfig.java
index 0b5f6227..3537a91d 100644
--- a/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/SwaggerConfig.java
+++ b/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/SwaggerConfig.java
@@ -1,5 +1,6 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,16 +20,12 @@ package org.onap.ccsdk.apps.blueprintsprocessor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.ComponentScan;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.web.bind.annotation.RequestMapping;
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;
@@ -40,13 +37,11 @@ import java.util.Set;
*
* @author Brinda Santh 8/13/2018
*/
-@Configuration
-@EnableSwagger2
+//@Configuration
+//@EnableSwagger2
+@SuppressWarnings("unused")
+@Deprecated
public class SwaggerConfig {
- private static final Set<String> DEFAULT_PRODUCES_AND_CONSUMES =
- new HashSet<String>(Arrays.asList("application/json",
- "application/xml"));
- private static Logger log = LoggerFactory.getLogger(SwaggerConfig.class);
@Bean
public Docket api() {
diff --git a/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/WebConfig.java b/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/WebConfig.java
index f1b8f9d6..796a2d79 100644
--- a/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/WebConfig.java
+++ b/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/WebConfig.java
@@ -1,5 +1,6 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,10 +17,7 @@
package org.onap.ccsdk.apps.blueprintsprocessor;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration;
-import org.springframework.format.FormatterRegistry;
import org.springframework.web.reactive.config.*;
/**
@@ -29,6 +27,7 @@ import org.springframework.web.reactive.config.*;
*/
@Configuration
public class WebConfig extends WebFluxConfigurationSupport {
+ @Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("swagger-ui.html")
.addResourceLocations("classpath:/META-INF/resources/");
@@ -36,4 +35,13 @@ 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/blueprintsprocessor/functions/pom.xml b/ms/blueprintsprocessor/functions/pom.xml
index 50ea7b0e..efd550dd 100644
--- a/ms/blueprintsprocessor/functions/pom.xml
+++ b/ms/blueprintsprocessor/functions/pom.xml
@@ -31,6 +31,7 @@
<description>Blueprints Processor Functions POM</description>
<modules>
<module>resource-resolution</module>
+ <module>python-executor</module>
</modules>
<dependencies>
diff --git a/ms/blueprintsprocessor/functions/python-executor/pom.xml b/ms/blueprintsprocessor/functions/python-executor/pom.xml
new file mode 100644
index 00000000..4f9cc745
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/python-executor/pom.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <artifactId>functions</artifactId>
+ <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
+ <version>0.4.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.onap.ccsdk.apps.blueprintsprocessor.functions</groupId>
+ <artifactId>python-executor</artifactId>
+ <name>Blueprints Processor Function - Python Executor</name>
+ <description>Blueprints Processor Function - Python Executor</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.python</groupId>
+ <artifactId>jython-standalone</artifactId>
+ </dependency>
+ </dependencies>
+
+
+</project> \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/ComponentJythonExecutor.kt b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/ComponentJythonExecutor.kt
new file mode 100644
index 00000000..2965cb5d
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/ComponentJythonExecutor.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.blueprintsprocessor.functions.python.executor
+
+import org.apache.commons.io.FilenameUtils
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.utils.PythonExecutorUtils
+import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmptyNThrow
+import org.onap.ccsdk.apps.controllerblueprints.core.data.OperationAssignment
+import org.slf4j.LoggerFactory
+import org.springframework.stereotype.Component
+
+@Component("component-jython-executor")
+class ComponentJythonExecutor(private val pythonExecutorProperty: PythonExecutorProperty) : AbstractComponentFunction() {
+
+ private val log = LoggerFactory.getLogger(ComponentJythonExecutor::class.java)
+
+ private var componentFunction: AbstractComponentFunction? = null
+
+
+ override fun process(executionServiceInput: ExecutionServiceInput) {
+
+ log.info("Processing : ${executionServiceInput.metadata}")
+ checkNotNull(bluePrintRuntimeService) { "failed to get bluePrintRuntimeService" }
+
+ val bluePrintContext = bluePrintRuntimeService!!.bluePrintContext()
+
+ val operationAssignment: OperationAssignment = bluePrintContext
+ .nodeTemplateInterfaceOperation(nodeTemplateName, interfaceName, operationName)
+
+ val blueprintBasePath: String = bluePrintRuntimeService!!.get(BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH)?.asText()
+ ?: throw BluePrintProcessorException("python execute path is missing for node template ($nodeTemplateName)")
+
+ val artifactName: String = operationAssignment.implementation?.primary
+ ?: throw BluePrintProcessorException("missing primary field to get artifact name for node template ($nodeTemplateName)")
+
+ val artifactDefinition = bluePrintRuntimeService!!.resolveNodeTemplateArtifactDefinition(nodeTemplateName, artifactName)
+
+ val pythonFileName = artifactDefinition.file
+ ?: throw BluePrintProcessorException("missing file name for node template ($nodeTemplateName)'s artifactName($artifactName)")
+
+ val pythonClassName = FilenameUtils.getBaseName(pythonFileName)
+
+ val content: String? = bluePrintRuntimeService!!.resolveNodeTemplateArtifact(nodeTemplateName, artifactName)
+
+ checkNotEmptyNThrow(content, "artifact ($artifactName) content is empty")
+
+ val pythonPath: MutableList<String> = operationAssignment.implementation?.dependencies ?: arrayListOf()
+ pythonPath.add(blueprintBasePath)
+ pythonPath.addAll(pythonExecutorProperty.modulePaths)
+
+ val properties: MutableMap<String, Any> = hashMapOf()
+ properties["log"] = log
+
+ componentFunction = PythonExecutorUtils.getPythonComponent(pythonExecutorProperty.executionPath,
+ pythonPath, content, pythonClassName, properties)
+
+ componentFunction!!.process(executionServiceInput)
+
+ }
+
+ override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
+ componentFunction!!.recover(runtimeException, executionRequest)
+ }
+
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/JythonExecutionService.kt b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/JythonExecutionService.kt
new file mode 100644
index 00000000..dc372af4
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/JythonExecutionService.kt
@@ -0,0 +1,51 @@
+/*
+ * 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.blueprintsprocessor.functions.python.executor
+
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.utils.PythonExecutorUtils
+import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction
+import org.slf4j.LoggerFactory
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.context.ApplicationContext
+import org.springframework.stereotype.Service
+
+@Service
+class JythonExecutionService(private val pythonExecutorProperty: PythonExecutorProperty) {
+
+
+ private val log = LoggerFactory.getLogger(ComponentJythonExecutor::class.java)
+
+ @Autowired
+ lateinit var applicationContext: ApplicationContext
+
+
+ fun processJythonNodeTemplate(pythonClassName: String, content: String, pythonPath: MutableList<String>,
+ jythonContextInstance: MutableMap<String, Any>,
+ dependencyInstanceNames: List<String>): AbstractComponentFunction {
+
+
+ dependencyInstanceNames.forEach { instanceName ->
+ jythonContextInstance[instanceName] = applicationContext.getBean(instanceName)
+
+ }
+
+ return PythonExecutorUtils.getPythonComponent(pythonExecutorProperty.executionPath,
+ pythonPath, content, pythonClassName, jythonContextInstance)
+
+ }
+
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/PythonExecutorConfiguration.kt b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/PythonExecutorConfiguration.kt
new file mode 100644
index 00000000..dd80fb0a
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/PythonExecutorConfiguration.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.blueprintsprocessor.functions.python.executor
+
+import org.springframework.beans.factory.annotation.Value
+import org.springframework.boot.context.properties.EnableConfigurationProperties
+import org.springframework.context.annotation.ComponentScan
+import org.springframework.context.annotation.Configuration
+
+@Configuration
+@ComponentScan
+@EnableConfigurationProperties
+open class PythonExecutorConfiguration
+
+@Configuration
+open class PythonExecutorProperty {
+ @Value("\${blueprints.processor.functions.python.executor.executionPath}")
+ lateinit var executionPath: String
+ @Value("#{'\${blueprints.processor.functions.python.executor.modulePaths}'.split(',')}")
+ lateinit var modulePaths: List<String>
+
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/utils/PythonExecutorUtils.kt b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/utils/PythonExecutorUtils.kt
new file mode 100644
index 00000000..66c919d4
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/utils/PythonExecutorUtils.kt
@@ -0,0 +1,77 @@
+/*
+ * 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.blueprintsprocessor.functions.python.executor.utils
+
+import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction
+import org.python.core.PyObject
+import org.python.util.PythonInterpreter
+import org.slf4j.LoggerFactory
+import java.util.*
+
+class PythonExecutorUtils {
+ companion object {
+
+ private val log = LoggerFactory.getLogger(PythonExecutorUtils::class.java)
+
+ fun getPythonComponent(executePath: String, pythonPath: MutableList<String>, content: String?, interfaceName: String,
+ properties: MutableMap<String, Any>): AbstractComponentFunction {
+
+ initPython(executePath, pythonPath, arrayListOf())
+ val pythonInterpreter = PythonInterpreter()
+
+ properties.forEach { (name, value) ->
+ pythonInterpreter.set(name, value)
+ }
+
+ pythonInterpreter.exec("import sys")
+
+ content?.let {
+ pythonInterpreter.exec(content)
+ }
+
+ val initCommand = interfaceName.plus(" = ").plus(interfaceName).plus("()")
+ pythonInterpreter.exec(initCommand)
+ val pyObject: PyObject = pythonInterpreter.get(interfaceName)
+
+ log.info("Component Object {}", pyObject)
+
+ return pyObject.__tojava__(AbstractComponentFunction::class.java) as AbstractComponentFunction
+ }
+
+ private fun initPython(executablePath: String,
+ pythonPath: MutableList<String>, argv: MutableList<String>) {
+
+ val props = Properties()
+ // Build up the python.path
+ val sb = StringBuilder()
+ sb.append(System.getProperty("java.class.path"))
+
+ for (p in pythonPath) {
+ sb.append(":").append(p)
+ }
+ log.debug("Paths : $sb")
+
+ props["python.import.site"] = "true"
+ props.setProperty("python.path", sb.toString())
+ props.setProperty("python.verbose", "error")
+ props.setProperty("python.executable", executablePath)
+
+ PythonInterpreter.initialize(System.getProperties(), props, argv.toTypedArray())
+ }
+
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/ComponentJythonExecutorTest.kt b/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/ComponentJythonExecutorTest.kt
new file mode 100644
index 00000000..1ce8d05b
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/ComponentJythonExecutorTest.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.blueprintsprocessor.functions.python.executor
+
+import com.fasterxml.jackson.databind.JsonNode
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ActionIdentifiers
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.CommonHeader
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.putJsonElement
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.test.context.ContextConfiguration
+import org.springframework.test.context.TestPropertySource
+import org.springframework.test.context.junit4.SpringRunner
+
+@RunWith(SpringRunner::class)
+@ContextConfiguration(classes = [PythonExecutorConfiguration::class, PythonExecutorProperty::class])
+@TestPropertySource(properties =
+["blueprints.processor.functions.python.executor.modulePaths=./../../../../components/scripts/python/ccsdk_blueprints",
+ "blueprints.processor.functions.python.executor.executionPath=./../../../../components/scripts/python/ccsdk_blueprints"])
+
+class ComponentJythonExecutorTest {
+
+ @Autowired
+ lateinit var componentJythonExecutor: ComponentJythonExecutor
+
+
+ @Test
+ fun testPythonComponentInjection() {
+
+ val executionServiceInput = ExecutionServiceInput()
+ val commonHeader = CommonHeader()
+ commonHeader.requestId = "1234"
+ executionServiceInput.commonHeader = commonHeader
+
+ val actionIdentifiers = ActionIdentifiers()
+ actionIdentifiers.blueprintName = "baseconfiguration"
+ actionIdentifiers.blueprintVersion = "1.0.0"
+ actionIdentifiers.actionName = "activate"
+ executionServiceInput.actionIdentifiers = actionIdentifiers
+
+
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(commonHeader.requestId,
+ "./../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration")
+
+ componentJythonExecutor.bluePrintRuntimeService = bluePrintRuntimeService
+
+
+ val metaData: MutableMap<String, JsonNode> = hashMapOf()
+ metaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_STEP, "resource-assignment-py")
+ metaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, "resource-assignment-py")
+ metaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_INTERFACE, "ResourceAssignmentComponent")
+ metaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_OPERATION, "process")
+ executionServiceInput.metadata = metaData
+
+ componentJythonExecutor.apply(executionServiceInput)
+
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/utils/PythonExecutorUtilsTest.kt b/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/utils/PythonExecutorUtilsTest.kt
new file mode 100644
index 00000000..6197c4b2
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/utils/PythonExecutorUtilsTest.kt
@@ -0,0 +1,52 @@
+/*
+ * 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.blueprintsprocessor.functions.python.executor.utils
+
+import org.junit.Test
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
+import org.slf4j.LoggerFactory
+import kotlin.test.assertNotNull
+
+
+class PythonExecutorUtilsTest {
+
+ private val log = LoggerFactory.getLogger(PythonExecutorUtils::class.java)
+
+ @Test
+ fun testGetPythonComponent() {
+
+ val pythonPath: MutableList<String> = arrayListOf()
+ pythonPath.add("./../../../../components/scripts/python/ccsdk_blueprints")
+
+ val properties: MutableMap<String, Any> = hashMapOf()
+ properties["logger"] = log
+
+ val content = JacksonUtils.getContent("./../../../../components/scripts/python/ccsdk_blueprints/sample_blueprint_component.py")
+
+ val abstractComponentFunction = PythonExecutorUtils.getPythonComponent("/home/brindasanth/onap/apps/components/scripts/python/ccsdk_blueprints", pythonPath, content,
+ "SampleBlueprintComponent", properties)
+
+ assertNotNull(abstractComponentFunction, "failed to get python component")
+
+ abstractComponentFunction.process(ExecutionServiceInput())
+
+ }
+
+
+}
+
diff --git a/ms/blueprintsprocessor/functions/python-executor/src/test/resources/logback-test.xml b/ms/blueprintsprocessor/functions/python-executor/src/test/resources/logback-test.xml
new file mode 100644
index 00000000..a816a06c
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/python-executor/src/test/resources/logback-test.xml
@@ -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.
+ -->
+
+<configuration>
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <!-- encoders are assigned the type
+ ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
+ <encoder>
+ <pattern>%d{HH:mm:ss.SSS} %-5level %logger{100} - %msg%n</pattern>
+ </encoder>
+ </appender>
+
+
+ <logger name="org.springframework" level="warn"/>
+ <logger name="org.hibernate" level="info"/>
+ <logger name="org.onap.ccsdk.apps.blueprintsprocessor" level="info"/>
+
+ <root level="warn">
+ <appender-ref ref="STDOUT"/>
+ </root>
+
+</configuration>
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/pom.xml b/ms/blueprintsprocessor/functions/resource-resolution/pom.xml
index a2d3bb85..858be70c 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/pom.xml
+++ b/ms/blueprintsprocessor/functions/resource-resolution/pom.xml
@@ -25,7 +25,7 @@
<groupId>org.onap.ccsdk.apps.blueprintsprocessor.functions</groupId>
<artifactId>resource-resolution</artifactId>
<packaging>jar</packaging>
- <name>Blueprints Processor Resolution Service</name>
- <description>Blueprints Processor Resolution Service</description>
+ <name>Blueprints Processor Function - Resource Resolution</name>
+ <description>Blueprints Processor Function - Resource Resolution</description>
</project>
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt
index 155b3b03..9e735cf0 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt
@@ -47,8 +47,6 @@ class ResourceResolutionService {
resourceResolutionOutput.commonHeader = resourceResolutionInput.commonHeader
resourceResolutionOutput.resourceAssignments = resourceResolutionInput.resourceAssignments
- val context = hashMapOf<String, Any>()
-
process(resourceResolutionOutput.resourceAssignments)
val status = Status()
diff --git a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt
index 45f684f1..427063e4 100644
--- a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt
+++ b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt
@@ -22,6 +22,7 @@ import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.node.ObjectNode
import io.swagger.annotations.ApiModelProperty
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
+import java.util.*
/**
* BlueprintProcessorData
@@ -87,7 +88,7 @@ open class ActionIdentifiers {
open class CommonHeader {
@get:ApiModelProperty(required = true, example = "2012-04-23T18:25:43.511Z")
@get:JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
- lateinit var timestamp: String
+ var timestamp: Date = Date()
@get:ApiModelProperty(required = true)
lateinit var originatorId: String
@get:ApiModelProperty(required = true)
@@ -107,6 +108,11 @@ open class Flags {
open class Status {
@get:ApiModelProperty(required = true)
var code: Int = 200
+ @get:ApiModelProperty(required = true)
+ var eventType: String = "EVENT-ACTION-RESPONSE"
+ @get:ApiModelProperty(required = true, example = "2012-04-23T18:25:43.511Z")
+ @get:JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
+ var timestamp: Date = Date()
@get:ApiModelProperty(required = false)
var errorMessage: String? = null
@get:ApiModelProperty(required = true)
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt
index 9a0d1f91..dfdf6259 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt
@@ -19,7 +19,10 @@ package org.onap.ccsdk.apps.blueprintsprocessor.services.execution
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceOutput
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.getAsString
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BlueprintFunctionNode
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
import org.slf4j.LoggerFactory
/**
@@ -29,14 +32,39 @@ import org.slf4j.LoggerFactory
abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServiceInput, ExecutionServiceOutput> {
private val log = LoggerFactory.getLogger(AbstractComponentFunction::class.java)
- override fun prepareRequest(executionRequest: ExecutionServiceInput): ExecutionServiceInput {
+ var executionServiceInput: ExecutionServiceInput? = null
+ var executionServiceOutput = ExecutionServiceOutput()
+ var bluePrintRuntimeService: BluePrintRuntimeService<*>? = null
+ var processId: String = ""
+ var workflowName: String = ""
+ var stepName: String = ""
+ var interfaceName: String = ""
+ var operationName: String = ""
+ var nodeTemplateName: String = ""
+
+
+ override fun prepareRequest(executionServiceInput: ExecutionServiceInput): ExecutionServiceInput {
+
+ this.executionServiceInput = this.executionServiceInput
+
+ processId = executionServiceInput.commonHeader.requestId
+ workflowName = executionServiceInput.actionIdentifiers.actionName
+
+ val metadata = executionServiceInput.metadata
+ stepName = metadata.getAsString(BluePrintConstants.PROPERTY_CURRENT_STEP)
+ nodeTemplateName = metadata.getAsString(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE)
+ interfaceName = metadata.getAsString(BluePrintConstants.PROPERTY_CURRENT_INTERFACE)
+ operationName = metadata.getAsString(BluePrintConstants.PROPERTY_CURRENT_OPERATION)
+
+ checkNotNull(bluePrintRuntimeService) { "failed to prepare blueprint runtime" }
+
log.info("prepareRequest...")
- return executionRequest
+ return executionServiceInput
}
override fun prepareResponse(): ExecutionServiceOutput {
log.info("Preparing Response...")
- return ExecutionServiceOutput()
+ return this.executionServiceOutput
}
override fun apply(executionServiceInput: ExecutionServiceInput): ExecutionServiceOutput {
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintDGExecutionService.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintDGExecutionService.kt
new file mode 100644
index 00000000..993f10ee
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintDGExecutionService.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.blueprintsprocessor.services.workflow
+
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceOutput
+import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.utils.SvcGraphUtils
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+import org.slf4j.LoggerFactory
+import org.springframework.stereotype.Service
+import java.io.File
+
+
+interface BlueprintDGExecutionService {
+
+ fun executeDirectedGraph(bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ executionServiceInput: ExecutionServiceInput): ExecutionServiceOutput
+
+}
+
+@Service
+class DefaultBlueprintDGExecutionService(val blueprintSvcLogicService: BlueprintSvcLogicService) : BlueprintDGExecutionService {
+
+ private val log = LoggerFactory.getLogger(DefaultBlueprintDGExecutionService::class.java)
+
+ override fun executeDirectedGraph(bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ executionServiceInput: ExecutionServiceInput): ExecutionServiceOutput {
+
+ val bluePrintContext = bluePrintRuntimeService.bluePrintContext()
+
+ val workflowName = executionServiceInput.actionIdentifiers.actionName
+
+ // Get the DG Node Template
+ val nodeTemplateName = bluePrintContext.workflowFirstStepNodeTemplate(workflowName)
+
+ log.info("Executing workflow($workflowName) directed graph NodeTemplate($nodeTemplateName)")
+
+ // Get the DG file info
+ val artifactDefinition = bluePrintContext.nodeTemplateArtifactForArtifactType(nodeTemplateName,
+ WorkflowServiceConstants.ARTIFACT_TYPE_DIRECTED_GRAPH)
+
+ // Populate the DG Path
+ val dgFilePath = bluePrintRuntimeService.getAsString(BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH)
+ .plus(File.separator).plus(artifactDefinition.file)
+
+ log.info("Executing directed graph ($dgFilePath)")
+
+ // Create DG instance
+ val graph = SvcGraphUtils.getSvcGraphFromFile(dgFilePath)
+
+ // Execute the DG
+ return blueprintSvcLogicService.execute(graph, bluePrintRuntimeService, executionServiceInput) as ExecutionServiceOutput
+
+ }
+
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintSvcLogicService.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintSvcLogicService.kt
index 8750d98b..ab7d7385 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintSvcLogicService.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintSvcLogicService.kt
@@ -36,7 +36,7 @@ interface BlueprintSvcLogicService : SvcLogicService {
fun unRegisterExecutors(name: String)
- fun execute(graph: SvcLogicGraph, bluePrintRuntimeService: BluePrintRuntimeService<*>): Any
+ fun execute(graph: SvcLogicGraph, bluePrintRuntimeService: BluePrintRuntimeService<*>, input: Any): Any
@Deprecated("Populate Graph Dynamically from Blueprints, No need to get from Database Store ")
override fun getStore(): SvcLogicStore {
@@ -93,10 +93,11 @@ class DefaultBlueprintSvcLogicService : BlueprintSvcLogicService {
}
}
- override fun execute(graph: SvcLogicGraph, bluePrintRuntimeService: BluePrintRuntimeService<*>): Any {
- //Initialise BlueprintSvcLogic Context
+ override fun execute(graph: SvcLogicGraph, bluePrintRuntimeService: BluePrintRuntimeService<*>, input: Any): Any {
+ //Initialise BlueprintSvcLogic Context with Blueprint Runtime Service and Input Request
val blueprintSvcLogicContext = BlueprintSvcLogicContext()
blueprintSvcLogicContext.setBluePrintRuntimeService(bluePrintRuntimeService)
+ blueprintSvcLogicContext.setRequest(input)
// Execute the Graph
execute(graph, blueprintSvcLogicContext)
// Get the Response
@@ -125,12 +126,6 @@ class DefaultBlueprintSvcLogicService : BlueprintSvcLogicService {
override fun execute(graph: SvcLogicGraph, svcLogicContext: SvcLogicContext): SvcLogicContext {
MDC.put("currentGraph", graph.toString())
- val ctx = svcLogicContext as BlueprintSvcLogicContext
-
- val blueprintRuntimeService = ctx.getBluePrintService()
-
- log.info("Blueprint Runtime Service : ${blueprintRuntimeService}")
-
var curNode: SvcLogicNode? = graph.getRootNode()
log.info("About to execute graph {}", graph.toString())
@@ -138,7 +133,7 @@ class DefaultBlueprintSvcLogicService : BlueprintSvcLogicService {
while (curNode != null) {
MDC.put("nodeId", curNode.nodeId.toString() + " (" + curNode.nodeType + ")")
log.info("About to execute node # {} ({})", curNode.nodeId, curNode.nodeType)
- val nextNode = this.executeNode(curNode, ctx)
+ val nextNode = this.executeNode(curNode, svcLogicContext)
curNode = nextNode
}
} catch (var5: ExitNodeException) {
@@ -147,6 +142,6 @@ class DefaultBlueprintSvcLogicService : BlueprintSvcLogicService {
MDC.remove("nodeId")
MDC.remove("currentGraph")
- return ctx
+ return svcLogicContext
}
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/WorkflowServiceConfiguration.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/WorkflowServiceConfiguration.kt
index b9c041e9..b3186e84 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/WorkflowServiceConfiguration.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/WorkflowServiceConfiguration.kt
@@ -21,6 +21,11 @@ import org.springframework.context.annotation.Configuration
@Configuration
@ComponentScan
-open class WorkflowServiceConfiguration {
+open class WorkflowServiceConfiguration
+
+class WorkflowServiceConstants {
+ companion object {
+ const val ARTIFACT_TYPE_DIRECTED_GRAPH = "artifact-directed-graph"
+ }
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/executor/ComponentExecuteNodeExecutor.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/executor/ComponentExecuteNodeExecutor.kt
index 125a1ff6..ace9f278 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/executor/ComponentExecuteNodeExecutor.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/executor/ComponentExecuteNodeExecutor.kt
@@ -60,6 +60,8 @@ open class ComponentExecuteNodeExecutor : ExecuteNodeExecutor() {
log.info("executing node template($nodeTemplateName) component($componentName)")
// Get the Component Instance
val plugin = this.getComponentFunction(componentName)
+ // Set the Blueprint Service
+ plugin.bluePrintRuntimeService = ctx.getBluePrintService()
val executionInput = ctx.getRequest() as ExecutionServiceInput
// Get the Request from the Context and Set to the Function Input and Invoke the function
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintDGExecutionServiceTest.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintDGExecutionServiceTest.kt
new file mode 100644
index 00000000..46bb6f08
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintDGExecutionServiceTest.kt
@@ -0,0 +1,53 @@
+/*
+ * 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.blueprintsprocessor.services.workflow
+
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.executor.ComponentExecuteNodeExecutor
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
+import org.slf4j.LoggerFactory
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.test.context.ContextConfiguration
+import org.springframework.test.context.junit4.SpringRunner
+
+@RunWith(SpringRunner::class)
+@ContextConfiguration(classes = [WorkflowServiceConfiguration::class, ComponentExecuteNodeExecutor::class])
+class BlueprintDGExecutionServiceTest {
+
+ private val log = LoggerFactory.getLogger(BlueprintServiceLogicTest::class.java)
+
+ @Autowired
+ lateinit var blueprintDGExecutionService: BlueprintDGExecutionService
+
+
+ @Test
+ fun testExecuteDirectedGraph() {
+
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
+ "./../../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration")
+
+ val executionServiceInput = JacksonUtils.readValueFromClassPathFile("execution-input/default-input.json", ExecutionServiceInput::class.java)!!
+
+ blueprintDGExecutionService.executeDirectedGraph(bluePrintRuntimeService, executionServiceInput)
+
+ }
+
+
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintServiceLogicTest.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintServiceLogicTest.kt
index 5c90852e..341b6f84 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintServiceLogicTest.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintServiceLogicTest.kt
@@ -22,6 +22,7 @@ import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInp
import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.executor.ComponentExecuteNodeExecutor
import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.utils.SvcGraphUtils
import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.test.context.ContextConfiguration
@@ -36,6 +37,8 @@ class BlueprintServiceLogicTest {
val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
"./../../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration")
+ val executionServiceInput = JacksonUtils.readValueFromClassPathFile("execution-input/default-input.json", ExecutionServiceInput::class.java)!!
+
@Autowired
lateinit var blueprintSvcLogicService: BlueprintSvcLogicService
@@ -43,20 +46,15 @@ class BlueprintServiceLogicTest {
fun testExecuteGraphWithSingleComponent() {
val graph = SvcGraphUtils.getSvcGraphFromClassPathFile("service-logic/one-component.xml")
- val svcLogicContext = BlueprintSvcLogicContext()
- svcLogicContext.setBluePrintRuntimeService(bluePrintRuntimeService)
- svcLogicContext.setRequest(ExecutionServiceInput())
- blueprintSvcLogicService.execute(graph, svcLogicContext)
+ blueprintSvcLogicService.execute(graph, bluePrintRuntimeService, executionServiceInput)
}
@Test
fun testExecuteGraphWithMultipleComponents() {
val graph = SvcGraphUtils.getSvcGraphFromClassPathFile("service-logic/two-component.xml")
- val svcLogicContext = BlueprintSvcLogicContext()
- svcLogicContext.setBluePrintRuntimeService(bluePrintRuntimeService)
- svcLogicContext.setRequest(ExecutionServiceInput())
- blueprintSvcLogicService.execute(graph, svcLogicContext)
+ blueprintSvcLogicService.execute(graph, bluePrintRuntimeService, executionServiceInput)
}
+
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/mock/MockComponentFunction.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/mock/MockComponentFunction.kt
index 5aa90130..747be76c 100644
--- a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/mock/MockComponentFunction.kt
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/mock/MockComponentFunction.kt
@@ -17,6 +17,7 @@
package org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.mock
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceOutput
import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction
import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.executor.ComponentExecuteNodeExecutor
import org.slf4j.LoggerFactory
@@ -38,6 +39,8 @@ class MockComponentFunction : AbstractComponentFunction() {
override fun process(executionRequest: ExecutionServiceInput) {
log.info("Processing component..")
+
+ this.executionServiceOutput = ExecutionServiceOutput()
}
override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/execution-input/default-input.json b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/execution-input/default-input.json
new file mode 100644
index 00000000..20401fd1
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/execution-input/default-input.json
@@ -0,0 +1,20 @@
+{
+ "commonHeader" : {
+ "originatorId" : "System",
+ "requestId" : "1234",
+ "subRequestId" : "1234-12234"
+ },
+ "actionIdentifiers" : {
+ "blueprintName" : "baseconfiguration",
+ "blueprintVersion" : "1.0.0",
+ "actionName" : "activate",
+ "mode" : "sync"
+ },
+ "payload" : { },
+ "metadata" : {
+ "current-node-template" : "resource-assignment-py",
+ "current-step" : "resource-assignment-py",
+ "current-operation" : "process",
+ "current-interface" : "ResourceAssignmentComponent"
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/parent/pom.xml b/ms/blueprintsprocessor/parent/pom.xml
index 761fdc72..3ad3fef3 100644
--- a/ms/blueprintsprocessor/parent/pom.xml
+++ b/ms/blueprintsprocessor/parent/pom.xml
@@ -30,14 +30,16 @@
<name>Blueprints Processor Parent</name>
<description>Blueprints Processor Parent</description>
<properties>
- <spring.boot.version>2.0.6.RELEASE</spring.boot.version>
- <spring.version>5.0.10.RELEASE</spring.version>
+ <spring.boot.version>2.1.1.RELEASE</spring.boot.version>
+ <spring.version>5.1.3.RELEASE</spring.version>
<kotlin.version>1.3.10</kotlin.version>
- <kotlin.maven.version>1.3.0</kotlin.maven.version>
+ <kotlin.maven.version>1.3.10</kotlin.maven.version>
<kotlin.couroutines.version>1.0.1</kotlin.couroutines.version>
+ <grpc.version>1.16.1</grpc.version>
<eelf.version>1.0.0</eelf.version>
<sli.version>0.3.1</sli.version>
<guava.version>26.0-jre</guava.version>
+ <jython.version>2.7.1</jython.version>
<springfox.swagger2.version>2.9.2</springfox.swagger2.version>
<h2database.version>1.4.197</h2database.version>
<onap.logger.slf4j>1.2.2</onap.logger.slf4j>
@@ -73,8 +75,8 @@
<version>${kotlin.version}</version>
</dependency>
<dependency>
- <groupId>org.jetbrains.kotlin</groupId>
- <artifactId>kotlinx-couroutines-core</artifactId>
+ <groupId>org.jetbrains.kotlinx</groupId>
+ <artifactId>kotlinx-coroutines-core</artifactId>
<version>${kotlin.couroutines.version}</version>
</dependency>
<dependency>
@@ -93,6 +95,28 @@
<version>${kotlin.version}</version>
</dependency>
+ <!-- GRPC Dependencies -->
+ <dependency>
+ <groupId>io.grpc</groupId>
+ <artifactId>grpc-core</artifactId>
+ <version>${grpc.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>io.grpc</groupId>
+ <artifactId>grpc-netty</artifactId>
+ <version>${grpc.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>io.grpc</groupId>
+ <artifactId>grpc-protobuf</artifactId>
+ <version>${grpc.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>io.grpc</groupId>
+ <artifactId>grpc-stub</artifactId>
+ <version>${grpc.version}</version>
+ </dependency>
+
<!-- SLI Version -->
<dependency>
<groupId>org.onap.ccsdk.sli.core</groupId>
@@ -228,6 +252,11 @@
<artifactId>guava</artifactId>
<version>${guava.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.python</groupId>
+ <artifactId>jython-standalone</artifactId>
+ <version>${jython.version}</version>
+ </dependency>
<!-- Database -->
<dependency>
@@ -249,6 +278,12 @@
<version>${kotlin.version}</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>io.grpc</groupId>
+ <artifactId>grpc-testing</artifactId>
+ <version>${grpc.version}</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</dependencyManagement>
@@ -297,6 +332,19 @@
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-kotlin</artifactId>
</dependency>
+ <!-- GRPC Dependencies -->
+ <dependency>
+ <groupId>io.grpc</groupId>
+ <artifactId>grpc-netty</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.grpc</groupId>
+ <artifactId>grpc-protobuf</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.grpc</groupId>
+ <artifactId>grpc-stub</artifactId>
+ </dependency>
</dependencies>
<build>
diff --git a/ms/controllerblueprints/application/etc/logback.xml b/ms/controllerblueprints/application/etc/logback.xml
index 6639705e..01ae4f6c 100644
--- a/ms/controllerblueprints/application/etc/logback.xml
+++ b/ms/controllerblueprints/application/etc/logback.xml
@@ -16,7 +16,7 @@
<configuration>
- <property name="localPattern" value="%d{HH:mm:ss.SSS} %-5level %logger{100} - %msg%n" />
+ <property name="localPattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{100} - %msg%n" />
<property name="defaultPattern" value="%date{ISO8601,UTC}|%X{RequestID}|%X{ServiceInstanceId}|%thread|%X{VirtualServerName}|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}|%X{ClassName}|%X{Timer}| %msg%n" />
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 e0920870..8741fab2 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 0160ee5f..aae37011 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 bf1c7525..bb0f7686 100644
--- a/ms/controllerblueprints/application/pom.xml
+++ b/ms/controllerblueprints/application/pom.xml
@@ -31,7 +31,7 @@
<artifactId>application</artifactId>
<name>Controller Blueprints Application</name>
<properties>
- <swagger.directory>${basedir}/src/main/resources/swagger-ui/dist</swagger.directory>
+ <swagger.directory>${basedir}/target/src/main/resources/swagger-ui</swagger.directory>
<java.version>1.8</java.version>
<name.space>org.onap.ccsdk.apps</name.space> <!-- <name.space>${namespace}</name.space> -->
<serviceArtifactName>controllerblueprints</serviceArtifactName>
@@ -205,9 +205,56 @@
<target>1.8</target>
</configuration>
</plugin>
+ <plugin>
+ <groupId>com.github.kongchen</groupId>
+ <artifactId>swagger-maven-plugin</artifactId>
+ <version>3.1.7</version>
+ <configuration>
+ <apiSources>
+ <apiSource>
+ <springmvc>true</springmvc>
+ <locations>org.onap.ccsdk.apps.controllerblueprints.service.rs
+ </locations>
+ <schemes>
+ <scheme>http</scheme>
+ <scheme>https</scheme>
+ </schemes>
+ <basePath>/api/v1</basePath>
+ <info>
+ <title>Controller Blueprints</title>
+ <version>${project.version}</version>
+ <description>
+ Controller blueprints API for VNF Self Service.
+ </description>
+ <termsOfService>
+ Terms of service
+ </termsOfService>
+ <contact>
+ <email>brindasanth@gmail.com</email>
+ <name>Brinda Santh</name>
+ <url>http://onap.com</url>
+ </contact>
+ <license>
+ <url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
+ <name>Apache 2.0</name>
+ </license>
+ </info>
+ <swaggerDirectory>${swagger.directory}</swaggerDirectory>
+ </apiSource>
+ </apiSources>
+ </configuration>
+ <executions>
+ <execution>
+ <phase>compile</phase>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
-
-
+
+
</project>
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 78706d57..00000000
--- 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<ErrorMessage> 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<ErrorMessage> 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<ErrorMessage> 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<ErrorMessage> 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 8b96f04a..b9c0bd19 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 83f5f19e..45faa1b5 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 44761177..367ea7d9 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<Void> 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 b97fa178..00000000
--- 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 e3df3a62..00000000
--- 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 3a39d782..334574f7 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 62ef2a74..0e878976 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 cd95abf9..017cfde4 100644
--- a/ms/controllerblueprints/modules/service/pom.xml
+++ b/ms/controllerblueprints/modules/service/pom.xml
@@ -48,10 +48,6 @@
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-web</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java
index ef3b4a48..7ea81da0 100644
--- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java
@@ -17,6 +17,8 @@
package org.onap.ccsdk.apps.controllerblueprints.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.collections.MapUtils;
@@ -25,13 +27,14 @@ import org.jetbrains.annotations.NotNull;
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
import org.onap.ccsdk.apps.controllerblueprints.core.ConfigModelConstant;
import org.onap.ccsdk.apps.controllerblueprints.core.data.*;
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionRepoService;
-import org.onap.ccsdk.apps.controllerblueprints.service.enhancer.BluePrintEnhancerDefaultService;
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionRepoService;
+import org.onap.ccsdk.apps.controllerblueprints.service.enhancer.BluePrintEnhancerDefaultService;
import org.onap.ccsdk.apps.controllerblueprints.service.enhancer.ResourceAssignmentEnhancerService;
+import org.springframework.beans.factory.config.ConfigurableBeanFactory;
+import org.springframework.context.annotation.Scope;
+import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.stereotype.Service;
import java.util.HashMap;
@@ -45,6 +48,7 @@ import java.util.Map;
*/
@Service
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE, proxyMode = ScopedProxyMode.TARGET_CLASS)
public class BluePrintEnhancerService extends BluePrintEnhancerDefaultService {
private static EELFLogger log = EELFManager.getInstance().getLogger(BluePrintEnhancerService.class);
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelValidatorService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelValidatorService.java
index 21b00f8c..3abdc04d 100644
--- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelValidatorService.java
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelValidatorService.java
@@ -30,7 +30,7 @@ import org.springframework.stereotype.Service;
* @author Brinda Santh
* @version 1.0
*/
-
+@Deprecated
@Service
public class ConfigModelValidatorService {
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 a1a9b9ca..a4b874ee 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
@@ -1,323 +1,325 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.apps.controllerblueprints.service;
-
-import com.google.common.base.Preconditions;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.text.StrBuilder;
-import org.jetbrains.annotations.NotNull;
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants;
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
-import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactType;
-import org.onap.ccsdk.apps.controllerblueprints.core.data.DataType;
-import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeType;
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition;
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary;
-import org.onap.ccsdk.apps.controllerblueprints.service.utils.ConfigModelUtils;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
-import org.springframework.boot.context.event.ApplicationReadyEvent;
-import org.springframework.context.event.EventListener;
-import org.springframework.core.io.Resource;
-import org.springframework.core.io.support.ResourcePatternResolver;
-import org.springframework.stereotype.Component;
-import java.io.IOException;
-import java.nio.charset.Charset;
-import java.util.List;
-
-/**
- * DataBaseInitService.java Purpose: Provide DataBaseInitService Service
- *
- * @author Brinda Santh
- * @version 1.0
- */
-
-@Component
-@ConditionalOnProperty(name = "blueprints.load.initial-data", havingValue = "true")
-public class DataBaseInitService {
-
- private static EELFLogger log = EELFManager.getInstance().getLogger(DataBaseInitService.class);
- private ModelTypeService modelTypeService;
- private ResourceDictionaryService resourceDictionaryService;
- private ConfigModelService configModelService;
- private String updateBySystem = "System";
-
- @Value("${load.dataTypePath}")
- private String dataTypePath;
- @Value("${load.nodeTypePath}")
- private String nodeTypePath;
- @Value("${load.artifactTypePath}")
- private String artifactTypePath;
- @Value("${load.resourceDictionaryPath}")
- private String resourceDictionaryPath;
- @Value("${load.blueprintsPath}")
- private String bluePrintsPath;
-
- @Autowired
- private ResourcePatternResolver resourceLoader;
-
- /**
- * This is a DataBaseInitService, used to load the initial data
- *
- * @param modelTypeService modelTypeService
- * @param resourceDictionaryService resourceDictionaryService
- * @param configModelService configModelService
- */
- public DataBaseInitService(ModelTypeService modelTypeService, ResourceDictionaryService resourceDictionaryService,
- ConfigModelService configModelService) {
- this.modelTypeService = modelTypeService;
- this.resourceDictionaryService = resourceDictionaryService;
- this.configModelService = configModelService;
- log.info("DataBaseInitService started...");
-
- }
-
- @SuppressWarnings("unused")
- @EventListener(ApplicationReadyEvent.class)
- private void initDatabase() {
- log.info("loading dataTypePath from DIR : {}", dataTypePath);
- log.info("loading nodeTypePath from DIR : {}", nodeTypePath);
- log.info("loading artifactTypePath from DIR : {}", artifactTypePath);
- log.info("loading resourceDictionaryPath from DIR : {}", resourceDictionaryPath);
- log.info("loading bluePrintsPath from DIR : {}", bluePrintsPath);
-
- loadModelType();
- loadResourceDictionary();
- }
-
- private void loadModelType() {
- log.info(" *************************** loadModelType **********************");
- try {
- Resource[] dataTypefiles = getPathResources(dataTypePath, ".json");
- StrBuilder errorBuilder = new StrBuilder();
- for (Resource file : dataTypefiles) {
- if (file != null) {
- loadDataType(file, errorBuilder);
- }
- }
-
- Resource[] nodeTypefiles = getPathResources(nodeTypePath, ".json");
- for (Resource file : nodeTypefiles) {
- if (file != null) {
- loadNodeType(file, errorBuilder);
- }
- }
-
-
- Resource[] artifactTypefiles = getPathResources(artifactTypePath, ".json");
-
- for (Resource file : artifactTypefiles) {
- if (file != null) {
- loadArtifactType(file, errorBuilder);
- }
- }
-
-
- if (!errorBuilder.isEmpty()) {
- log.error(errorBuilder.toString());
- }
- } catch (Exception e) {
- log.error("Failed in Data type loading", e);
- }
- }
-
- private void loadResourceDictionary() {
- log.info(
- " *************************** loadResourceDictionary **********************");
- try {
- Resource[] dataTypefiles = getPathResources(resourceDictionaryPath, ".json");
-
- StrBuilder errorBuilder = new StrBuilder();
- String fileName;
- for (Resource file : dataTypefiles) {
- try {
- fileName = file.getFilename();
- log.trace("Loading : {}", fileName);
- String definitionContent = getResourceContent(file);
- ResourceDefinition resourceDefinition =
- JacksonUtils.readValue(definitionContent, ResourceDefinition.class);
- if (resourceDefinition != null) {
- Preconditions.checkNotNull(resourceDefinition.getProperty(), "Failed to get Property Definition");
- ResourceDictionary resourceDictionary = new ResourceDictionary();
- resourceDictionary.setName(resourceDefinition.getName());
- resourceDictionary.setDefinition(resourceDefinition);
-
- Preconditions.checkNotNull(resourceDefinition.getProperty(), "Property field is missing");
- resourceDictionary.setDescription(resourceDefinition.getProperty().getDescription());
- resourceDictionary.setDataType(resourceDefinition.getProperty().getType());
- if(resourceDefinition.getProperty().getEntrySchema() != null){
- resourceDictionary.setEntrySchema(resourceDefinition.getProperty().getEntrySchema().getType());
- }
- resourceDictionary.setUpdatedBy(resourceDefinition.getUpdatedBy());
- if (StringUtils.isBlank(resourceDefinition.getTags())) {
- resourceDictionary.setTags(
- resourceDefinition.getName() + ", " + resourceDefinition.getUpdatedBy()
- + ", " + resourceDefinition.getUpdatedBy());
-
- } else {
- resourceDictionary.setTags(resourceDefinition.getTags());
- }
- resourceDictionaryService.saveResourceDictionary(resourceDictionary);
-
- log.trace(" Loaded successfully : {}", file.getFilename());
- } else {
- throw new BluePrintException("couldn't get dictionary from content information");
- }
- } catch (Exception e) {
- log.error("Exception", e);
- errorBuilder.appendln("Dictionary loading Errors : " + file.getFilename() + ":" + e.getMessage());
- }
- }
- if (!errorBuilder.isEmpty()) {
- log.error(errorBuilder.toString());
- }
-
-
- } catch (Exception e) {
- log.error(
- "Failed in Resource dictionary loading", e);
- }
- }
-
- private void loadBlueprints() {
- log.info("*************************** loadServiceTemplate **********************");
- try {
- List<String> serviceTemplateDirs = ConfigModelUtils.getBlueprintNames(bluePrintsPath);
- if (CollectionUtils.isNotEmpty(serviceTemplateDirs)) {
- StrBuilder errorBuilder = new StrBuilder();
- for (String fileName : serviceTemplateDirs) {
- try {
- String bluePrintPath = this.bluePrintsPath.concat("/").concat(fileName);
- log.debug("***** Loading service template : {}", bluePrintPath);
- ConfigModel configModel = ConfigModelUtils.getConfigModel(bluePrintPath);
-
- configModel = this.configModelService.saveConfigModel(configModel);
-
- log.info("Publishing : {}", configModel.getId());
-
- this.configModelService.publishConfigModel(configModel.getId());
-
- log.info("Loaded service template successfully: {}", fileName);
-
- } catch (Exception e) {
- log.error("Exception", e);
- errorBuilder.appendln("load config model " + fileName + " error : " + e.getMessage());
- }
- }
-
- if (!errorBuilder.isEmpty()) {
- log.error(errorBuilder.toString());
- }
- }
- } catch (Exception e) {
- log.error("Failed in Service Template loading", e);
- }
- }
-
- private void loadNodeType(Resource file, StrBuilder errorBuilder) {
- try {
- log.trace("Loading Node Type : {}", file.getFilename());
- String nodeKey = file.getFilename().replace(".json", "");
- String definitionContent = getResourceContent(file);
- NodeType nodeType = JacksonUtils.readValue(definitionContent, NodeType.class);
- Preconditions.checkNotNull(nodeType, String.format("failed to get node type from file : %s", file.getFilename()));
- ModelType modelType = new ModelType();
- modelType.setDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE);
- modelType.setDerivedFrom(nodeType.getDerivedFrom());
- modelType.setDescription(nodeType.getDescription());
- modelType.setDefinition(JacksonUtils.jsonNode(definitionContent));
- modelType.setModelName(nodeKey);
- modelType.setVersion(nodeType.getVersion());
- modelType.setUpdatedBy(updateBySystem);
- modelType.setTags(nodeKey + "," + BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE + ","
- + nodeType.getDerivedFrom());
- modelTypeService.saveModel(modelType);
- log.trace("Loaded Node Type successfully : {}", file.getFilename());
- } catch (Exception e) {
- log.error("Exception", e);
- errorBuilder.appendln("Node type loading error : " + file.getFilename() + ":" + e.getMessage());
- }
- }
-
- private void loadDataType(@NotNull Resource file, StrBuilder errorBuilder) {
- try {
- log.trace("Loading Data Type: {}", file.getFilename());
- String dataKey = file.getFilename().replace(".json", "");
- String definitionContent = getResourceContent(file);
- DataType dataType = JacksonUtils.readValue(definitionContent, DataType.class);
- Preconditions.checkNotNull(dataType, String.format("failed to get data type from file : %s", file.getFilename()));
- ModelType modelType = new ModelType();
- modelType.setDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE);
- modelType.setDerivedFrom(dataType.getDerivedFrom());
- modelType.setDescription(dataType.getDescription());
- modelType.setDefinition(JacksonUtils.jsonNode(definitionContent));
- modelType.setModelName(dataKey);
- modelType.setVersion(dataType.getVersion());
- modelType.setUpdatedBy(updateBySystem);
- modelType.setTags(dataKey + "," + dataType.getDerivedFrom() + ","
- + BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE);
- modelTypeService.saveModel(modelType);
- log.trace(" Loaded Data Type successfully : {}", file.getFilename());
- } catch (Exception e) {
- log.error("Exception", e);
- errorBuilder.appendln("Data type loading error : " + file.getFilename() + ":" + e.getMessage());
- }
- }
-
- private void loadArtifactType(Resource file, StrBuilder errorBuilder) {
- try {
- log.trace("Loading Artifact Type: {}", file.getFilename());
- String dataKey = file.getFilename().replace(".json", "");
- String definitionContent = getResourceContent(file);
- ArtifactType artifactType = JacksonUtils.readValue(definitionContent, ArtifactType.class);
- Preconditions.checkNotNull(artifactType, String.format("failed to get artifact type from file : %s", file.getFilename()));
- ModelType modelType = new ModelType();
- modelType.setDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE);
- modelType.setDerivedFrom(artifactType.getDerivedFrom());
- modelType.setDescription(artifactType.getDescription());
- modelType.setDefinition(JacksonUtils.jsonNode(definitionContent));
- modelType.setModelName(dataKey);
- modelType.setVersion(artifactType.getVersion());
- modelType.setUpdatedBy(updateBySystem);
- modelType.setTags(dataKey + "," + artifactType.getDerivedFrom() + ","
- + BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE);
- modelTypeService.saveModel(modelType);
- log.trace("Loaded Artifact Type successfully : {}", file.getFilename());
- } catch (Exception e) {
- log.error("Exception", e);
- errorBuilder.appendln("Artifact type loading error : " + file.getFilename() + ":" + e.getMessage());
- }
- }
-
- private Resource[] getPathResources(String path, String extension) throws IOException {
- return resourceLoader.getResources("file:" + path + "/*" + extension);
- }
-
- private String getResourceContent(Resource resource) throws IOException {
- return IOUtils.toString(resource.getInputStream(), Charset.defaultCharset());
- }
-
-}
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service;
+
+import com.google.common.base.Preconditions;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.text.StrBuilder;
+import org.jetbrains.annotations.NotNull;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactType;
+import org.onap.ccsdk.apps.controllerblueprints.core.data.DataType;
+import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeType;
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;
+import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary;
+import org.onap.ccsdk.apps.controllerblueprints.service.utils.ConfigModelUtils;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.boot.context.event.ApplicationReadyEvent;
+import org.springframework.context.event.EventListener;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.support.ResourcePatternResolver;
+import org.springframework.stereotype.Component;
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.util.List;
+
+/**
+ * DataBaseInitService.java Purpose: Provide DataBaseInitService Service
+ *
+ * @author Brinda Santh
+ * @version 1.0
+ */
+@Deprecated
+@Component
+@ConditionalOnProperty(name = "blueprints.load.initial-data", havingValue = "true")
+public class DataBaseInitService {
+
+ private static EELFLogger log = EELFManager.getInstance().getLogger(DataBaseInitService.class);
+ private ModelTypeService modelTypeService;
+ private ResourceDictionaryService resourceDictionaryService;
+ private ConfigModelService configModelService;
+ private String updateBySystem = "System";
+ private static final String JSON_EXTN= ".json";
+ private static final String EXCEPTION= "Exception";
+
+ @Value("${load.dataTypePath}")
+ private String dataTypePath;
+ @Value("${load.nodeTypePath}")
+ private String nodeTypePath;
+ @Value("${load.artifactTypePath}")
+ private String artifactTypePath;
+ @Value("${load.resourceDictionaryPath}")
+ private String resourceDictionaryPath;
+ @Value("${load.blueprintsPath}")
+ private String bluePrintsPath;
+
+ @Autowired
+ private ResourcePatternResolver resourceLoader;
+
+ /**
+ * This is a DataBaseInitService, used to load the initial data
+ *
+ * @param modelTypeService modelTypeService
+ * @param resourceDictionaryService resourceDictionaryService
+ * @param configModelService configModelService
+ */
+ public DataBaseInitService(ModelTypeService modelTypeService, ResourceDictionaryService resourceDictionaryService,
+ ConfigModelService configModelService) {
+ this.modelTypeService = modelTypeService;
+ this.resourceDictionaryService = resourceDictionaryService;
+ this.configModelService = configModelService;
+ log.info("DataBaseInitService started...");
+
+ }
+
+ @SuppressWarnings("unused")
+ @EventListener(ApplicationReadyEvent.class)
+ private void initDatabase() {
+ log.info("loading dataTypePath from DIR : {}", dataTypePath);
+ log.info("loading nodeTypePath from DIR : {}", nodeTypePath);
+ log.info("loading artifactTypePath from DIR : {}", artifactTypePath);
+ log.info("loading resourceDictionaryPath from DIR : {}", resourceDictionaryPath);
+ log.info("loading bluePrintsPath from DIR : {}", bluePrintsPath);
+
+ loadModelType();
+ loadResourceDictionary();
+ }
+
+ private void loadModelType() {
+ log.info(" *************************** loadModelType **********************");
+ try {
+ Resource[] dataTypefiles = getPathResources(dataTypePath, JSON_EXTN);
+ StrBuilder errorBuilder = new StrBuilder();
+ for (Resource file : dataTypefiles) {
+ if (file != null) {
+ loadDataType(file, errorBuilder);
+ }
+ }
+
+ Resource[] nodeTypefiles = getPathResources(nodeTypePath, JSON_EXTN);
+ for (Resource file : nodeTypefiles) {
+ if (file != null) {
+ loadNodeType(file, errorBuilder);
+ }
+ }
+
+
+ Resource[] artifactTypefiles = getPathResources(artifactTypePath, JSON_EXTN);
+
+ for (Resource file : artifactTypefiles) {
+ if (file != null) {
+ loadArtifactType(file, errorBuilder);
+ }
+ }
+
+
+ if (!errorBuilder.isEmpty()) {
+ log.error(errorBuilder.toString());
+ }
+ } catch (Exception e) {
+ log.error("Failed in Data type loading", e);
+ }
+ }
+
+ private void loadResourceDictionary() {
+ log.info(
+ " *************************** loadResourceDictionary **********************");
+ try {
+ Resource[] dataTypefiles = getPathResources(resourceDictionaryPath, JSON_EXTN);
+
+ StrBuilder errorBuilder = new StrBuilder();
+ String fileName;
+ for (Resource file : dataTypefiles) {
+ try {
+ fileName = file.getFilename();
+ log.trace("Loading : {}", fileName);
+ String definitionContent = getResourceContent(file);
+ ResourceDefinition resourceDefinition =
+ JacksonUtils.readValue(definitionContent, ResourceDefinition.class);
+ if (resourceDefinition != null) {
+ Preconditions.checkNotNull(resourceDefinition.getProperty(), "Failed to get Property Definition");
+ ResourceDictionary resourceDictionary = new ResourceDictionary();
+ resourceDictionary.setName(resourceDefinition.getName());
+ resourceDictionary.setDefinition(resourceDefinition);
+
+ Preconditions.checkNotNull(resourceDefinition.getProperty(), "Property field is missing");
+ resourceDictionary.setDescription(resourceDefinition.getProperty().getDescription());
+ resourceDictionary.setDataType(resourceDefinition.getProperty().getType());
+ if(resourceDefinition.getProperty().getEntrySchema() != null){
+ resourceDictionary.setEntrySchema(resourceDefinition.getProperty().getEntrySchema().getType());
+ }
+ resourceDictionary.setUpdatedBy(resourceDefinition.getUpdatedBy());
+ if (StringUtils.isBlank(resourceDefinition.getTags())) {
+ resourceDictionary.setTags(
+ resourceDefinition.getName() + ", " + resourceDefinition.getUpdatedBy()
+ + ", " + resourceDefinition.getUpdatedBy());
+
+ } else {
+ resourceDictionary.setTags(resourceDefinition.getTags());
+ }
+ resourceDictionaryService.saveResourceDictionary(resourceDictionary);
+
+ log.trace(" Loaded successfully : {}", file.getFilename());
+ } else {
+ throw new BluePrintException("couldn't get dictionary from content information");
+ }
+ } catch (Exception e) {
+ log.error(EXCEPTION, e);
+ errorBuilder.appendln("Dictionary loading Errors : " + file.getFilename() + ":" + e.getMessage());
+ }
+ }
+ if (!errorBuilder.isEmpty()) {
+ log.error(errorBuilder.toString());
+ }
+
+
+ } catch (Exception e) {
+ log.error(
+ "Failed in Resource dictionary loading", e);
+ }
+ }
+
+ private void loadBlueprints() {
+ log.info("*************************** loadServiceTemplate **********************");
+ try {
+ List<String> serviceTemplateDirs = ConfigModelUtils.getBlueprintNames(bluePrintsPath);
+ if (CollectionUtils.isNotEmpty(serviceTemplateDirs)) {
+ StrBuilder errorBuilder = new StrBuilder();
+ for (String fileName : serviceTemplateDirs) {
+ try {
+ String bluePrintPath = this.bluePrintsPath.concat("/").concat(fileName);
+ log.debug("***** Loading service template : {}", bluePrintPath);
+ ConfigModel configModel = ConfigModelUtils.getConfigModel(bluePrintPath);
+
+ configModel = this.configModelService.saveConfigModel(configModel);
+
+ log.info("Publishing : {}", configModel.getId());
+
+ this.configModelService.publishConfigModel(configModel.getId());
+
+ log.info("Loaded service template successfully: {}", fileName);
+
+ } catch (Exception e) {
+ log.error(EXCEPTION, e);
+ errorBuilder.appendln("load config model " + fileName + " error : " + e.getMessage());
+ }
+ }
+
+ if (!errorBuilder.isEmpty()) {
+ log.error(errorBuilder.toString());
+ }
+ }
+ } catch (Exception e) {
+ log.error("Failed in Service Template loading", e);
+ }
+ }
+
+ private void loadNodeType(Resource file, StrBuilder errorBuilder) {
+ try {
+ log.trace("Loading Node Type : {}", file.getFilename());
+ String nodeKey = file.getFilename().replace(JSON_EXTN, "");
+ String definitionContent = getResourceContent(file);
+ NodeType nodeType = JacksonUtils.readValue(definitionContent, NodeType.class);
+ Preconditions.checkNotNull(nodeType, String.format("failed to get node type from file : %s", file.getFilename()));
+ ModelType modelType = new ModelType();
+ modelType.setDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE);
+ modelType.setDerivedFrom(nodeType.getDerivedFrom());
+ modelType.setDescription(nodeType.getDescription());
+ modelType.setDefinition(JacksonUtils.jsonNode(definitionContent));
+ modelType.setModelName(nodeKey);
+ modelType.setVersion(nodeType.getVersion());
+ modelType.setUpdatedBy(updateBySystem);
+ modelType.setTags(nodeKey + "," + BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE + ","
+ + nodeType.getDerivedFrom());
+ modelTypeService.saveModel(modelType);
+ log.trace("Loaded Node Type successfully : {}", file.getFilename());
+ } catch (Exception e) {
+ log.error(EXCEPTION, e);
+ errorBuilder.appendln("Node type loading error : " + file.getFilename() + ":" + e.getMessage());
+ }
+ }
+
+ private void loadDataType(@NotNull Resource file, StrBuilder errorBuilder) {
+ try {
+ log.trace("Loading Data Type: {}", file.getFilename());
+ String dataKey = file.getFilename().replace(JSON_EXTN, "");
+ String definitionContent = getResourceContent(file);
+ DataType dataType = JacksonUtils.readValue(definitionContent, DataType.class);
+ Preconditions.checkNotNull(dataType, String.format("failed to get data type from file : %s", file.getFilename()));
+ ModelType modelType = new ModelType();
+ modelType.setDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE);
+ modelType.setDerivedFrom(dataType.getDerivedFrom());
+ modelType.setDescription(dataType.getDescription());
+ modelType.setDefinition(JacksonUtils.jsonNode(definitionContent));
+ modelType.setModelName(dataKey);
+ modelType.setVersion(dataType.getVersion());
+ modelType.setUpdatedBy(updateBySystem);
+ modelType.setTags(dataKey + "," + dataType.getDerivedFrom() + ","
+ + BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE);
+ modelTypeService.saveModel(modelType);
+ log.trace(" Loaded Data Type successfully : {}", file.getFilename());
+ } catch (Exception e) {
+ log.error(EXCEPTION, e);
+ errorBuilder.appendln("Data type loading error : " + file.getFilename() + ":" + e.getMessage());
+ }
+ }
+
+ private void loadArtifactType(Resource file, StrBuilder errorBuilder) {
+ try {
+ log.trace("Loading Artifact Type: {}", file.getFilename());
+ String dataKey = file.getFilename().replace(JSON_EXTN, "");
+ String definitionContent = getResourceContent(file);
+ ArtifactType artifactType = JacksonUtils.readValue(definitionContent, ArtifactType.class);
+ Preconditions.checkNotNull(artifactType, String.format("failed to get artifact type from file : %s", file.getFilename()));
+ ModelType modelType = new ModelType();
+ modelType.setDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE);
+ modelType.setDerivedFrom(artifactType.getDerivedFrom());
+ modelType.setDescription(artifactType.getDescription());
+ modelType.setDefinition(JacksonUtils.jsonNode(definitionContent));
+ modelType.setModelName(dataKey);
+ modelType.setVersion(artifactType.getVersion());
+ modelType.setUpdatedBy(updateBySystem);
+ modelType.setTags(dataKey + "," + artifactType.getDerivedFrom() + ","
+ + BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE);
+ modelTypeService.saveModel(modelType);
+ log.trace("Loaded Artifact Type successfully : {}", file.getFilename());
+ } catch (Exception e) {
+ log.error(EXCEPTION, e);
+ errorBuilder.appendln("Artifact type loading error : " + file.getFilename() + ":" + e.getMessage());
+ }
+ }
+
+ private Resource[] getPathResources(String path, String extension) throws IOException {
+ return resourceLoader.getResources("file:" + path + "/*" + extension);
+ }
+
+ private String getResourceContent(Resource resource) throws IOException {
+ return IOUtils.toString(resource.getInputStream(), Charset.defaultCharset());
+ }
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/main/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 04a95fd1..ff8b07a9 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/common/SwaggerGenerator.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/SwaggerGenerator.java
index 81f7d701..77de8e7c 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,5 +1,6 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -40,6 +41,7 @@ import java.util.*;
public class SwaggerGenerator {
private ServiceTemplate serviceTemplate;
+ public static final String INPUTS="inputs";
/**
* This is a SwaggerGenerator constructor
@@ -54,8 +56,7 @@ public class SwaggerGenerator {
* @return String
*/
public String generateSwagger() {
- String swaggerContent = null;
-
+
Swagger swagger = new Swagger().info(getInfo());
swagger.setPaths(getPaths());
@@ -86,7 +87,7 @@ public class SwaggerGenerator {
List<Parameter> parameters = new ArrayList<>();
Parameter in = new BodyParameter().schema(new RefModel("#/definitions/inputs"));
in.setRequired(true);
- in.setName("inputs");
+ in.setName(INPUTS);
parameters.add(in);
post.setParameters(parameters);
@@ -107,18 +108,17 @@ public class SwaggerGenerator {
Map<String, Model> models = new HashMap<>();
ModelImpl inputmodel = new ModelImpl();
- inputmodel.setTitle("inputs");
+ inputmodel.setTitle(INPUTS);
serviceTemplate.getTopologyTemplate().getInputs().forEach((propertyName, property) -> {
Property defProperty = getPropery(propertyName, property);
inputmodel.property(propertyName, defProperty);
});
- models.put("inputs", inputmodel);
+ models.put(INPUTS, inputmodel);
if (MapUtils.isNotEmpty(serviceTemplate.getDataTypes())) {
serviceTemplate.getDataTypes().forEach((name, dataType) -> {
ModelImpl model = new ModelImpl();
model.setDescription(dataType.getDescription());
- // model.setType("object");
if (dataType != null && MapUtils.isNotEmpty(dataType.getProperties())) {
dataType.getProperties().forEach((propertyName, property) -> {
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 71904fb3..56135471 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/domain/ModelType.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ModelType.java
index d8fea60e..33c7ae42 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() {
- String buffer = "[" + ", modelName = " + modelName +
+ return "[" + ", modelName = " + modelName +
", derivedFrom = " + derivedFrom +
", definitionType = " + definitionType +
", description = " + description +
@@ -93,7 +93,6 @@ public class ModelType implements Serializable {
", updatedBy = " + updatedBy +
", tags = " + tags +
"]";
- return buffer;
}
public String getModelName() {
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ResourceDictionary.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ResourceDictionary.java
index 42c8e83b..5352d9c9 100644
--- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ResourceDictionary.java
+++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ResourceDictionary.java
@@ -78,7 +78,7 @@ public class ResourceDictionary implements Serializable {
@Override
public String toString() {
- String buffer = "[" + ", name = " + name +
+ return "[" + ", name = " + name +
", dataType = " + dataType +
", entrySchema = " + entrySchema +
", definition =" + definition +
@@ -87,7 +87,6 @@ public class ResourceDictionary implements Serializable {
", tags = " + tags +
", creationDate = " + creationDate +
"]";
- return buffer;
}
public String getName() {
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 733cbbdb..81c26373 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<ConfigModelContent, Long> {
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 95e551b1..b025b2ff 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 0f485a08..69c20925 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 287d413c..932cdfac 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 {
@@ -47,13 +48,12 @@ public class ResourceDictionaryRest {
@PostMapping(path = "", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody
- ResourceDictionary saveResourceDictionary(@RequestBody ResourceDictionary dataDictionary)
- throws BluePrintException {
+ ResourceDictionary saveResourceDictionary(@RequestBody ResourceDictionary dataDictionary) {
return resourceDictionaryService.saveResourceDictionary(dataDictionary);
}
@DeleteMapping(path = "/{name}")
- public void deleteResourceDictionaryByName(@PathVariable(value = "name") String name) throws BluePrintException {
+ public void deleteResourceDictionaryByName(@PathVariable(value = "name") String name) {
resourceDictionaryService.deleteResourceDictionary(name);
}
@@ -65,14 +65,13 @@ public class ResourceDictionaryRest {
@PostMapping(path = "/by-names", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody
- List<ResourceDictionary> searchResourceDictionaryByNames(@RequestBody List<String> names)
- throws BluePrintException {
+ List<ResourceDictionary> searchResourceDictionaryByNames(@RequestBody List<String> names) {
return resourceDictionaryService.searchResourceDictionaryByNames(names);
}
@GetMapping(path = "/search/{tags}", produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody
- List<ResourceDictionary> searchResourceDictionaryByTags(@PathVariable(value = "tags") String tags) throws BluePrintException {
+ List<ResourceDictionary> searchResourceDictionaryByTags(@PathVariable(value = "tags") String tags) {
return resourceDictionaryService.searchResourceDictionaryByTags(tags);
}
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 caa6bba4..4c34881a 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 {
@@ -74,8 +75,7 @@ public class ServiceTemplateRest {
@PostMapping(path = "/resource-assignment/generate", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody
- List<ResourceAssignment> generateResourceAssignments(@RequestBody ConfigModelContent templateContent)
- throws BluePrintException {
+ List<ResourceAssignment> generateResourceAssignments(@RequestBody ConfigModelContent templateContent) {
return serviceTemplateService.generateResourceAssignments(templateContent);
}
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 e9ee1bc0..3c6b14ba 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/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerService.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerService.kt
index 46709c5f..2c13d864 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerService.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerService.kt
@@ -17,14 +17,16 @@
package org.onap.ccsdk.apps.controllerblueprints.service.enhancer
+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.*
import org.onap.ccsdk.apps.controllerblueprints.core.format
-import com.att.eelf.configuration.EELFLogger
-import com.att.eelf.configuration.EELFManager
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoService
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonReactorUtils
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintFileUtils
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
import java.io.Serializable
/**
@@ -35,13 +37,13 @@ import java.io.Serializable
interface BluePrintEnhancerService : Serializable {
@Throws(BluePrintException::class)
- fun enhance(content: String): ServiceTemplate
+ fun enhance(basePath: String, enrichedBasePath: String): BluePrintContext
/**
- * Read Blueprint from CSAR structure Directory
+ * Read Blueprint from CBA structure Directory
*/
@Throws(BluePrintException::class)
- fun enhance(fileName: String, basePath: String): ServiceTemplate
+ fun enhance(basePath: String): BluePrintContext
@Throws(BluePrintException::class)
fun enhance(serviceTemplate: ServiceTemplate): ServiceTemplate
@@ -62,16 +64,19 @@ open class BluePrintEnhancerDefaultService(val bluePrintRepoService: BluePrintRe
lateinit var serviceTemplate: ServiceTemplate
- @Throws(BluePrintException::class)
- override fun enhance(content: String): ServiceTemplate {
- return JacksonReactorUtils.readValueFromFile(content, ServiceTemplate::class.java).map { serviceTemplate ->
- enhance(serviceTemplate!!)
- }.block()!!
+ override fun enhance(basePath: String, enrichedBasePath: String): BluePrintContext {
+ BluePrintFileUtils.copyBluePrint(basePath, enrichedBasePath)
+ BluePrintFileUtils.deleteBluePrintTypes(enrichedBasePath)
+ val enhancedBluePrintContext = enhance(enrichedBasePath)
+ BluePrintFileUtils.writeBluePrintTypes(enhancedBluePrintContext)
+ return enhancedBluePrintContext
}
@Throws(BluePrintException::class)
- override fun enhance(fileName: String, basePath: String): ServiceTemplate {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ override fun enhance(basePath: String): BluePrintContext {
+ val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(basePath)
+ enhance(bluePrintContext.serviceTemplate)
+ return bluePrintContext
}
@Throws(BluePrintException::class)
@@ -88,10 +93,12 @@ open class BluePrintEnhancerDefaultService(val bluePrintRepoService: BluePrintRe
serviceTemplate.artifactTypes?.clear()
serviceTemplate.nodeTypes?.clear()
serviceTemplate.dataTypes?.clear()
+ serviceTemplate.policyTypes?.clear()
- serviceTemplate.artifactTypes = HashMap()
- serviceTemplate.nodeTypes = HashMap()
- serviceTemplate.dataTypes = HashMap()
+ serviceTemplate.artifactTypes = mutableMapOf()
+ serviceTemplate.nodeTypes = mutableMapOf()
+ serviceTemplate.dataTypes = mutableMapOf()
+ serviceTemplate.policyTypes = mutableMapOf()
}
diff --git a/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhance-template.json b/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhance-template.json
index 782ed505..b066dad6 100644
--- a/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhance-template.json
+++ b/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhance-template.json
@@ -64,7 +64,7 @@
}
},
"interfaces": {
- "org-openecomp-sdnc-netconf-adaptor-service-NetconfExecutorNode": {
+ "NetconfExecutorComponent": {
"operations": {
"process": {
"inputs": {
@@ -114,7 +114,7 @@
"component-node": {}
},
"interfaces": {
- "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode": {
+ "ResourceAssignmentComponent": {
"operations": {
"process": {
"inputs": {
diff --git a/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhanced-template.json b/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhanced-template.json
index d49ab8fe..5e41a507 100644
--- a/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhanced-template.json
+++ b/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhanced-template.json
@@ -336,7 +336,7 @@
}
},
"interfaces" : {
- "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode" : {
+ "ResourceAssignmentComponent" : {
"operations" : {
"process" : {
"inputs" : {
@@ -395,6 +395,11 @@
},
"derived_from" : "tosca.nodes.Component"
},
+ "tosca.nodes.component.Jython" : {
+ "description" : "This is Jython Component",
+ "version" : "1.0.0",
+ "derived_from" : "tosca.nodes.Root"
+ },
"tosca.nodes.DG" : {
"description" : "This is Directed Graph Node Type",
"version" : "1.0.0",
@@ -548,7 +553,7 @@
}
},
"interfaces" : {
- "org-openecomp-sdnc-netconf-adaptor-service-NetconfExecutorNode" : {
+ "NetconfExecutorComponent" : {
"operations" : {
"process" : {
"inputs" : {
@@ -609,7 +614,7 @@
}
}
},
- "derived_from" : "tosca.nodes.Component"
+ "derived_from" : "tosca.nodes.component.Jython"
}
},
"topology_template" : {
@@ -671,7 +676,7 @@
}
},
"interfaces" : {
- "org-openecomp-sdnc-netconf-adaptor-service-NetconfExecutorNode" : {
+ "NetconfExecutorComponent" : {
"operations" : {
"process" : {
"implementation" : {
@@ -715,7 +720,7 @@
"component-node" : { }
},
"interfaces" : {
- "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode" : {
+ "ResourceAssignmentComponent" : {
"operations" : {
"process" : {
"inputs" : {
diff --git a/ms/controllerblueprints/parent/pom.xml b/ms/controllerblueprints/parent/pom.xml
index e69a947b..309b2283 100644
--- a/ms/controllerblueprints/parent/pom.xml
+++ b/ms/controllerblueprints/parent/pom.xml
@@ -28,10 +28,10 @@
<name>Controller Blueprints Parent</name>
<packaging>pom</packaging>
<properties>
- <spring.boot.version>2.0.6.RELEASE</spring.boot.version>
- <spring.version>5.0.10.RELEASE</spring.version>
+ <spring.boot.version>2.1.1.RELEASE</spring.boot.version>
+ <spring.version>5.1.3.RELEASE</spring.version>
<kotlin.version>1.3.10</kotlin.version>
- <kotlin.maven.version>1.3.0</kotlin.maven.version>
+ <kotlin.maven.version>1.3.10</kotlin.maven.version>
<kotlin.couroutines.version>1.0.1</kotlin.couroutines.version>
<eelf.version>1.0.0</eelf.version>
<guava.version>26.0-jre</guava.version>
@@ -170,6 +170,12 @@
<version>${kotlin.version}</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>io.grpc</groupId>
+ <artifactId>grpc-testing</artifactId>
+ <version>${grpc.version}</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</dependencyManagement>
diff --git a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/persistence/ApplicationConfig.java b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/persistence/ApplicationConfig.java
index f68add72..0bdf40ae 100644
--- a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/persistence/ApplicationConfig.java
+++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/persistence/ApplicationConfig.java
@@ -4,6 +4,9 @@
* ================================================================================
* Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * *================================================================================
+ * Modifications Copyright (C) 2018 IBM.
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -45,6 +48,9 @@ import org.springframework.orm.jpa.JpaVendorAdapter;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
import org.springframework.transaction.annotation.EnableTransactionManagement;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
/**
* Manages the overall configuration of the application related to persistence.
@@ -57,6 +63,7 @@ public class ApplicationConfig {
@Autowired
private Environment environment;
+ private Logger logger = LoggerFactory.getLogger(ApplicationConfig.class);
@SuppressWarnings("rawtypes")
void debugProperties() {
@@ -66,8 +73,8 @@ public class ApplicationConfig {
.filter(ps -> ps instanceof EnumerablePropertySource)
.map(ps -> ((EnumerablePropertySource) ps).getPropertyNames())
.flatMap(Arrays::<String>stream)
- .forEach(propName -> props.setProperty(propName, this.environment.getProperty(propName)));
- System.out.println("Properties: " + props);
+ .forEach(propName -> props.setProperty(propName, this.environment.getProperty(propName)));
+ logger.info("Properties: " + props);
}
/**
diff --git a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/persistence/NamePersister.java b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/persistence/NamePersister.java
index cd07a46e..1dd6cebb 100644
--- a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/persistence/NamePersister.java
+++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/persistence/NamePersister.java
@@ -36,7 +36,7 @@ public class NamePersister {
/**
* Persist the given name.
*/
- public void persist(GeneratedName name) throws Exception {
+ public void persist(GeneratedName name) {
repository.save(name);
}
diff --git a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicyReader.java b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicyReader.java
index 09a6e49b..181bb7a3 100644
--- a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicyReader.java
+++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicyReader.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (C) 2018 IBM.
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -95,7 +97,7 @@ public abstract class PolicyReader implements PolicyFinder {
Map<String, ?> theModel = null;
if (namingModels != null) {
for (Map<String, ?> model : namingModels) {
- Object val = model.get("naming-type");
+ Object val = model.get(NAMING_TYPE);
if (val != null) {
if (namingType.equalsIgnoreCase(val.toString())) {
theModel = model;
@@ -106,7 +108,7 @@ public abstract class PolicyReader implements PolicyFinder {
if (theModel == null) {
namingType = relaxedNamingType(namingType);
for (Map<String, ?> model : namingModels) {
- Object val = model.get("naming-type");
+ Object val = model.get(NAMING_TYPE);
if (val != null) {
String relaxedVal = relaxedNamingType(val.toString());
if (namingType.equalsIgnoreCase(relaxedVal)) {
@@ -124,8 +126,6 @@ public abstract class PolicyReader implements PolicyFinder {
* Finds the naming-operation from the given naming-model.
*/
public static String namingOperation(Map<String, ?> namimgModel) {
- //String propValue = value(namimgModel, "name-operation");
- //return propValue;
return value(namimgModel, "name-operation");
}
@@ -162,7 +162,7 @@ public abstract class PolicyReader implements PolicyFinder {
* Finds the naming-type from the given naming-model.
*/
public static String namingType(Map<String, ?> namimgModelOrElement) {
- return value(namimgModelOrElement, "naming-type");
+ return value(namimgModelOrElement, NAMING_TYPE);
}
/**
@@ -299,7 +299,6 @@ public abstract class PolicyReader implements PolicyFinder {
Map<String, Object> getPolicy(String jsonString) throws Exception {
ObjectMapper mapper = new ObjectMapper();
- // Map<String, Object> jsonObject = mapper.readValue(jsonString, new TypeReference<Map<String, Object>>() {});
return mapper.readValue(jsonString, new TypeReference<Map<String, Object>>() {});
}
diff --git a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/service/SpringServiceImpl.java b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/service/SpringServiceImpl.java
index 01c8324d..c5cabe51 100644
--- a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/service/SpringServiceImpl.java
+++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/service/SpringServiceImpl.java
@@ -115,7 +115,7 @@ public class SpringServiceImpl implements SpringService {
List<Map<String, String>> allElements = new ArrayList<>();
Map<String, Map<String, ?>> policyCache = new HashMap<>();
List<Map<String, String>> generatedNames = new ArrayList<>();
- List<String> earlierNamingTypes = new ArrayList<String>();
+ List<String> earlierNamingTypes = new ArrayList<>();
validateRequest(request);
if (request.getElements() != null && !request.getElements().isEmpty()) {
allElements.addAll(request.getElements());
@@ -226,6 +226,7 @@ public class SpringServiceImpl implements SpringService {
}
void validateRequest(NameGenRequest request) throws Exception {
+ // this method does nothing
}
private PolicyFinder findPolicyFinderImpl(NameGenRequest request) {
diff --git a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/service/rs/RestServiceImpl.java b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/service/rs/RestServiceImpl.java
index e52e0016..3746756e 100644
--- a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/service/rs/RestServiceImpl.java
+++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/service/rs/RestServiceImpl.java
@@ -42,7 +42,9 @@ import org.springframework.web.bind.annotation.RequestBody;
public class RestServiceImpl implements RestService {
private static Logger log = Logger.getLogger(RestServiceImpl.class.getName());
private static final String INTERNAL_ERROR_MSG = "Internal error occured while processing the request.";
-
+ private static final String ERROR="error";
+
+
@Autowired SpringService service;
/**
@@ -67,11 +69,11 @@ public class RestServiceImpl implements RestService {
return buildResponse(resp);
} catch (NengException e) {
log.warning(e.getMessage());
- response.put("error", buildErrorResponse("NELGEN-0003", e.getMessage()));
+ response.put(ERROR, buildErrorResponse("NELGEN-0003", e.getMessage()));
return buildErrorResponse(response);
} catch (Exception e) {
log.warning(e.getMessage());
- response.put("error", buildErrorResponse("err-0500", INTERNAL_ERROR_MSG));
+ response.put(ERROR, buildErrorResponse("err-0500", INTERNAL_ERROR_MSG));
return buildErrorResponse(response);
}
}
@@ -88,11 +90,11 @@ public class RestServiceImpl implements RestService {
return buildResponse(resp);
} catch (NengException e) {
log.warning(e.getMessage());
- response.put("error", buildErrorResponse("NELGEN-0002", e.getMessage()));
+ response.put(ERROR, buildErrorResponse("NELGEN-0002", e.getMessage()));
return buildErrorResponse(response);
} catch (Exception e) {
log.warning(e.getMessage());
- response.put("error", buildErrorResponse("err-0500", INTERNAL_ERROR_MSG));
+ response.put(ERROR, buildErrorResponse("err-0500", INTERNAL_ERROR_MSG));
return buildErrorResponse(response);
}
}
@@ -120,7 +122,7 @@ public class RestServiceImpl implements RestService {
return buildResponse(response);
} catch (Exception e) {
log.warning(e.getMessage());
- response.put("error", buildErrorResponse("err-0500", e.getMessage()));
+ response.put(ERROR, buildErrorResponse("err-0500", e.getMessage()));
return buildErrorResponse(response);
}
}
diff --git a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/service/extinf/impl/PolicyFinderServiceImpl.java b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/service/extinf/impl/PolicyFinderServiceImpl.java
index e93675bf..b30ac0e6 100644
--- a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/service/extinf/impl/PolicyFinderServiceImpl.java
+++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/service/extinf/impl/PolicyFinderServiceImpl.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (C) 2018 IBM.
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -74,7 +76,7 @@ public class PolicyFinderServiceImpl implements PolicyFinder {
if (response instanceof List) {
@SuppressWarnings("unchecked")
List<Map<String, Object>> policyList = (List<Map<String, Object>>) response;
- return ((policyList != null && policyList.size() > 0) ? policyList.get(0) : null);
+ return ((!policyList.isEmpty()) ? policyList.get(0) : null);
} else {
return null;
}
diff --git a/ms/vlantag-api/src/main/java/org/onap/ccsdk/apps/ms/vlantagapi/extinf/pm/PolicyManagerClient.java b/ms/vlantag-api/src/main/java/org/onap/ccsdk/apps/ms/vlantagapi/extinf/pm/PolicyManagerClient.java
index 2378584e..f312cc36 100644
--- a/ms/vlantag-api/src/main/java/org/onap/ccsdk/apps/ms/vlantagapi/extinf/pm/PolicyManagerClient.java
+++ b/ms/vlantag-api/src/main/java/org/onap/ccsdk/apps/ms/vlantagapi/extinf/pm/PolicyManagerClient.java
@@ -93,6 +93,7 @@ public class PolicyManagerClient {
result = response.getBody();
} catch (RestClientException rce) {
+ log.error(rce.getMessage());
throw new VlantagApiException(rce.getLocalizedMessage());
}
return result;
@@ -118,6 +119,7 @@ public class PolicyManagerClient {
requestObject.setPolicyName(policyName);
retVal = extractResourceModelsFromResponse(getConfigUsingPost(requestObject));
} catch (IOException e) {
+ log.error(e.getMessage());
throw new VlantagApiException(e);
}
return retVal;