aboutsummaryrefslogtreecommitdiffstats
path: root/ms
diff options
context:
space:
mode:
Diffstat (limited to 'ms')
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/pom.xml10
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfComponentFunction.kt13
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutorTest.kt22
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/test/resources/application-test.properties32
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/pom.xml9
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt109
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt10
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt429
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionRepository.kt25
-rwxr-xr-xms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionResult.kt69
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionResultService.kt64
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessor.kt5
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceAssignmentProcessor.kt (renamed from ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/PrimaryDataResourceResolutionProcessor.kt)88
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessor.kt10
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessor.kt8
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt71
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt35
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt6
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt16
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/application-test.properties7
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/payload/requests/sample-resourceresolution-request.json1
-rw-r--r--ms/blueprintsprocessor/functions/restconf-executor/pom.xml5
-rw-r--r--ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/restconf/executor/RestconfComponentFunction.kt11
-rw-r--r--ms/blueprintsprocessor/functions/restconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/restconf/executor/ComponentRestconfExecutorTest.kt30
-rw-r--r--ms/blueprintsprocessor/functions/restconf-executor/src/test/resources/application-test.properties32
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BluePrintDBLibConfiguration.kt14
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/DBLibGenericService.kt72
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/PrimaryDBLibGenericService.kt28
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/PrimaryDatabaseConfiguration.kt12
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/pom.xml21
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/validation/BluePrintRuntimeValidatorService.kt (renamed from ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/validation/BluePrintDesignTimeRuntimeValidatorService.kt)19
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/mock/Mock.kt14
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/validation/BluePrintRuntimeValidatorServiceTest.kt44
-rwxr-xr-xms/blueprintsprocessor/parent/pom.xml8
-rw-r--r--ms/cds-sdc-listener/application/pom.xml58
-rw-r--r--ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerApplication.java19
-rw-r--r--ms/cds-sdc-listener/distribution/pom.xml106
-rw-r--r--ms/cds-sdc-listener/pom.xml28
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt20
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/factory/BluePrintValidatorFactory.kt45
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt3
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt1
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt17
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt16
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorDefaultServiceTest.kt50
-rw-r--r--ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintArtifactDefinitionValidatorImpl.kt2
-rw-r--r--ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintDesignTimeValidatorService.kt33
-rw-r--r--ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintPropertyDefinitionValidatorImpl.kt3
-rw-r--r--ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintValidationConfiguration.kt24
-rw-r--r--ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/extension/ArtifactMappingResourceValidator.kt2
-rw-r--r--ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/extension/ResourceDefinitionValidation.kt44
-rw-r--r--ms/controllerblueprints/modules/blueprint-validation/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintDesignTimeValidatorServiceTest.kt7
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt2
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt16
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt113
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt6
-rw-r--r--ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationServiceTest.java56
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ResourceDictionaryValidator.java60
-rw-r--r--ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidator.java147
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoServiceImpl.kt12
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImpl.kt15
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintNodeTemplateEnhancerImpl.kt17
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintPropertyDefinitionEnhancerImpl.kt6
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceDefinitionEnhancerService.kt76
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/handler/ResourceDictionaryHandler.kt22
-rw-r--r--ms/controllerblueprints/parent/pom.xml8
-rw-r--r--ms/pom.xml1
67 files changed, 1324 insertions, 1060 deletions
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/pom.xml b/ms/blueprintsprocessor/functions/netconf-executor/pom.xml
index df566de4..e77a6e3b 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/pom.xml
+++ b/ms/blueprintsprocessor/functions/netconf-executor/pom.xml
@@ -14,7 +14,8 @@
~ 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">
+<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>
<groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
<artifactId>functions</artifactId>
@@ -47,5 +48,10 @@
<artifactId>jsch</artifactId>
<version>0.1.54</version>
</dependency>
- </dependencies>
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
</project>
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfComponentFunction.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfComponentFunction.kt
index 26e51ec0..05a97c39 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfComponentFunction.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfComponentFunction.kt
@@ -25,9 +25,8 @@ import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
abstract class NetconfComponentFunction : AbstractComponentFunction() {
-
open fun resourceResolutionService(): ResourceResolutionService =
- functionDependencyInstanceAsType(ResourceResolutionConstants.SERVICE_RESOURCE_RESOLUTION)
+ functionDependencyInstanceAsType(ResourceResolutionConstants.SERVICE_RESOURCE_RESOLUTION)
// Called from python script
fun initializeNetconfConnection(requirementName: String): NetconfDevice {
@@ -39,6 +38,14 @@ abstract class NetconfComponentFunction : AbstractComponentFunction() {
return bluePrintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, artifactName)
}
+ fun getDynamicProperties(key: String): JsonNode {
+ return operationInputs["dynamic-properties"]!!.get(key)
+ }
+
+ fun resolveFromDatabase(resolutionKey: String, artifactName: String): String {
+ return resourceResolutionService().resolveFromDatabase(bluePrintRuntimeService, artifactName, resolutionKey)
+ }
+
fun resolveAndGenerateMessage(artifactMapping: String, artifactTemplate: String): String {
return resourceResolutionService().resolveResources(bluePrintRuntimeService, nodeTemplateName,
artifactMapping, artifactTemplate)
@@ -46,7 +53,7 @@ abstract class NetconfComponentFunction : AbstractComponentFunction() {
fun resolveAndGenerateMessage(artifactPrefix: String): String {
return resourceResolutionService().resolveResources(bluePrintRuntimeService, nodeTemplateName,
- artifactPrefix)
+ artifactPrefix, mapOf())
}
private fun deviceProperties(requirementName: String): DeviceInfo {
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutorTest.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutorTest.kt
index 6ed3a6d9..e2b90199 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutorTest.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutorTest.kt
@@ -22,28 +22,26 @@ import com.fasterxml.jackson.databind.JsonNode
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.functions.resource.resolution.ResourceResolutionServiceImpl
-import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.ComponentFunctionScriptingService
-import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.scripts.BlueprintJythonService
-import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.scripts.PythonExecutorProperty
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.asJsonNode
import org.onap.ccsdk.apps.controllerblueprints.core.putJsonElement
import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
-import org.onap.ccsdk.apps.controllerblueprints.scripts.BluePrintScriptsServiceImpl
import org.springframework.beans.factory.annotation.Autowired
-import org.springframework.test.context.ContextConfiguration
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration
+import org.springframework.context.annotation.ComponentScan
+import org.springframework.test.annotation.DirtiesContext
import org.springframework.test.context.TestPropertySource
import org.springframework.test.context.junit4.SpringRunner
@RunWith(SpringRunner::class)
-@ContextConfiguration(classes = [BlueprintJythonService::class, PythonExecutorProperty::class,
- BluePrintScriptsServiceImpl::class, ComponentFunctionScriptingService::class,
- ComponentNetconfExecutor::class, JsonParserService::class, ResourceResolutionServiceImpl::class])
+@EnableAutoConfiguration
+@ComponentScan(basePackages = ["org.onap.ccsdk.apps.blueprintsprocessor", "org.onap.ccsdk.apps.controllerblueprints"])
+@DirtiesContext
@TestPropertySource(properties =
["blueprints.processor.functions.python.executor.modulePaths=./../../../../components/scripts/python/ccsdk_netconf,./../../../../components/scripts/python/ccsdk_blueprints",
- "blueprints.processor.functions.python.executor.executionPath=./../../../../components/scripts/python/ccsdk_netconf"])
+ "blueprints.processor.functions.python.executor.executionPath=./../../../../components/scripts/python/ccsdk_netconf"],
+ locations = ["classpath:application-test.properties"])
class ComponentNetconfExecutorTest {
@Autowired
@@ -54,10 +52,10 @@ class ComponentNetconfExecutorTest {
fun testComponentNetconfExecutor() {
val executionServiceInput = JacksonUtils.readValueFromClassPathFile("requests/sample-activate-request.json",
- ExecutionServiceInput::class.java)!!
+ ExecutionServiceInput::class.java)!!
val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
- "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+ "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
val executionContext = bluePrintRuntimeService.getExecutionContext()
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/test/resources/application-test.properties b/ms/blueprintsprocessor/functions/netconf-executor/src/test/resources/application-test.properties
new file mode 100644
index 00000000..6d8b62ff
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/test/resources/application-test.properties
@@ -0,0 +1,32 @@
+#
+# Copyright © 2017-2018 AT&T Intellectual Property.
+#
+# Modifications Copyright © 2019 IBM, Bell Canada.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+blueprintsprocessor.db.primary.url=jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1
+blueprintsprocessor.db.primary.username=sa
+blueprintsprocessor.db.primary.password=
+blueprintsprocessor.db.primary.driverClassName=org.h2.Driver
+blueprintsprocessor.db.primary.hibernateHbm2ddlAuto=create-drop
+blueprintsprocessor.db.primary.hibernateDDLAuto=update
+blueprintsprocessor.db.primary.hibernateNamingStrategy=org.hibernate.cfg.ImprovedNamingStrategy
+blueprintsprocessor.db.primary.hibernateDialect=org.hibernate.dialect.H2Dialect
+# Controller Blueprints Core Configuration
+blueprintsprocessor.blueprintDeployPath=./target/blueprints/deploy
+blueprintsprocessor.blueprintArchivePath=./target/blueprints/archive
+
+# Python executor
+blueprints.processor.functions.python.executor.executionPath=./../../../../components/scripts/python/ccsdk_blueprints
+blueprints.processor.functions.python.executor.modulePaths=./../../../../components/scripts/python/ccsdk_blueprints
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/pom.xml b/ms/blueprintsprocessor/functions/resource-resolution/pom.xml
index c9f4c588..9d56829a 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/pom.xml
+++ b/ms/blueprintsprocessor/functions/resource-resolution/pom.xml
@@ -29,11 +29,10 @@
<description>Blueprints Processor Function - Resource Resolution</description>
<dependencies>
- <!--<dependency>
- <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
- <artifactId>db-resources</artifactId>
- <version>${project.version}</version>
- </dependency>-->
+ <dependency>
+ <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
+ <artifactId>db-lib</artifactId>
+ </dependency>
<dependency>
<groupId>org.onap.ccsdk.apps.blueprintsprocessor.functions</groupId>
<artifactId>python-executor</artifactId>
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt
index 53a2153a..819fe3f8 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt
@@ -1,49 +1,62 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution
-
-import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
-import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
-import org.onap.ccsdk.apps.controllerblueprints.core.asJsonNode
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
-import org.springframework.beans.factory.config.ConfigurableBeanFactory
-import org.springframework.context.annotation.Scope
-import org.springframework.stereotype.Component
-
-@Component("component-resource-resolution")
-@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-open class ResourceResolutionComponent(private val resourceResolutionService: ResourceResolutionService) : AbstractComponentFunction() {
-
- override fun process(executionRequest: ExecutionServiceInput) {
-
- val artifactPrefixNamesNode = getOperationInput(ResourceResolutionConstants.INPUT_ARTIFACT_PREFIX_NAMES)
-
- val artifactPrefixNames = JacksonUtils.getListFromJsonNode(artifactPrefixNamesNode, String::class.java)
- ?: throw BluePrintProcessorException("couldn't transform ${artifactPrefixNamesNode.asText()} to string array")
-
- val resolvedParamContents = resourceResolutionService.resolveResources(bluePrintRuntimeService, nodeTemplateName, artifactPrefixNames)
-
- // Set Output Attributes
- bluePrintRuntimeService.setNodeTemplateAttributeValue(nodeTemplateName,
- ResourceResolutionConstants.OUTPUT_ASSIGNMENT_PARAMS, resolvedParamContents.asJsonNode())
- }
-
- override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
- }
+/*
+ * 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.resource.resolution
+
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.apps.controllerblueprints.core.asJsonNode
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
+import org.springframework.stereotype.Component
+
+@Component("component-resource-resolution")
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+open class ResourceResolutionComponent(private val resourceResolutionService: ResourceResolutionService) :
+ AbstractComponentFunction() {
+
+ override fun process(executionRequest: ExecutionServiceInput) {
+
+ val properties: MutableMap<String, Any> = mutableMapOf()
+
+ try {
+ val key = getOperationInput(ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_KEY)
+ val storeResult = getOperationInput(ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_STORE_RESULT)
+ properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_KEY] = key.asText()
+ properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_STORE_RESULT] = storeResult.asBoolean()
+ } catch (e: BluePrintProcessorException) {
+ // NoOp - these property aren't mandatory, so don't fail the process if not provided.
+ }
+
+ val artifactPrefixNamesNode = getOperationInput(ResourceResolutionConstants.INPUT_ARTIFACT_PREFIX_NAMES)
+ val artifactPrefixNames = JacksonUtils.getListFromJsonNode(artifactPrefixNamesNode, String::class.java)
+
+ val resolvedParamContents = resourceResolutionService.resolveResources(bluePrintRuntimeService,
+ nodeTemplateName,
+ artifactPrefixNames,
+ properties)
+
+ // Set Output Attributes
+ bluePrintRuntimeService.setNodeTemplateAttributeValue(nodeTemplateName,
+ ResourceResolutionConstants.OUTPUT_ASSIGNMENT_PARAMS, resolvedParamContents.asJsonNode())
+ }
+
+ override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt
index ca92e96d..b57b88b7 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt
@@ -1,5 +1,6 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2019 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,14 +17,15 @@
package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution
-class ResourceResolutionConstants {
- companion object {
- const val SERVICE_RESOURCE_RESOLUTION = "resource-resolution-service"
+object ResourceResolutionConstants {
+ const val SERVICE_RESOURCE_RESOLUTION = "resource-resolution-service"
const val PREFIX_RESOURCE_RESOLUTION_PROCESSOR = "rr-processor-"
const val INPUT_ARTIFACT_PREFIX_NAMES = "artifact-prefix-names"
const val OUTPUT_ASSIGNMENT_PARAMS = "assignment-params"
const val FILE_NAME_RESOURCE_DEFINITION_TYPES = "resources_definition_types.json"
- }
+ const val RESOURCE_RESOLUTION_INPUT_KEY = "resolution-key";
+ const val RESOURCE_RESOLUTION_INPUT_STORE_RESULT = "store-result";
+
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt
index 48415efa..c1282344 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt
@@ -1,202 +1,227 @@
-/*
- * 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.blueprintsprocessor.functions.resource.resolution
-
-import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor.ResourceAssignmentProcessor
-import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
-import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmptyOrThrow
-import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
-import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintTemplateService
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.BulkResourceSequencingUtils
-import org.slf4j.LoggerFactory
-import org.springframework.context.ApplicationContext
-import org.springframework.stereotype.Service
-import java.io.File
-
-interface ResourceResolutionService {
-
- fun registeredResourceSources(): List<String>
-
- fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
- artifactNames: List<String>): MutableMap<String, String>
-
- fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
- artifactPrefix: String): String
-
- fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
- artifactMapping: String, artifactTemplate: String?): String
-
- fun resolveResourceAssignments(blueprintRuntimeService: BluePrintRuntimeService<*>,
- resourceDictionaries: MutableMap<String, ResourceDefinition>,
- resourceAssignments: MutableList<ResourceAssignment>,
- identifierName: String)
-}
-
-@Service(ResourceResolutionConstants.SERVICE_RESOURCE_RESOLUTION)
-open class ResourceResolutionServiceImpl(private var applicationContext: ApplicationContext) :
- ResourceResolutionService {
-
- private val log = LoggerFactory.getLogger(ResourceResolutionService::class.java)
-
- override fun registeredResourceSources(): List<String> {
- return applicationContext.getBeanNamesForType(ResourceAssignmentProcessor::class.java)
- .filter { it.startsWith(ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR) }
- .map { it.substringAfter(ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR) }
- }
-
- override fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
- artifactNames: List<String>): MutableMap<String, String> {
-
- val resolvedParams: MutableMap<String, String> = hashMapOf()
- artifactNames.forEach { artifactName ->
- val resolvedContent = resolveResources(bluePrintRuntimeService, nodeTemplateName, artifactName)
- resolvedParams[artifactName] = resolvedContent
- }
- return resolvedParams
- }
-
- override fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
- artifactPrefix: String): String {
-
- // Velocity Artifact Definition Name
- val artifactTemplate = "$artifactPrefix-template"
- // Resource Assignment Artifact Definition Name
- val artifactMapping = "$artifactPrefix-mapping"
-
- return resolveResources(bluePrintRuntimeService, nodeTemplateName, artifactMapping, artifactTemplate)
- }
-
-
- override fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
- artifactMapping: String, artifactTemplate: String?): String {
-
- var resolvedContent = ""
- log.info("Resolving resource for template artifact($artifactTemplate) with resource assignment artifact($artifactMapping)")
-
- val identifierName = artifactTemplate ?: "no-template"
-
- val resourceAssignmentContent = bluePrintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, artifactMapping)
-
- val resourceAssignments: MutableList<ResourceAssignment> = JacksonUtils.getListFromJson(resourceAssignmentContent, ResourceAssignment::class.java)
- as? MutableList<ResourceAssignment>
- ?: throw BluePrintProcessorException("couldn't get Dictionary Definitions")
-
- // Get the Resource Dictionary Name
- val dictionaryFile = bluePrintRuntimeService.bluePrintContext().rootPath.plus(File.separator)
- .plus(BluePrintConstants.TOSCA_DEFINITIONS_DIR).plus(File.separator)
- .plus(ResourceResolutionConstants.FILE_NAME_RESOURCE_DEFINITION_TYPES)
-
- val resourceDictionaries: MutableMap<String, ResourceDefinition> = JacksonUtils.getMapFromFile(dictionaryFile, ResourceDefinition::class.java)
- ?: throw BluePrintProcessorException("couldn't get Dictionary Definitions")
-
- // Resolve resources
- resolveResourceAssignments(bluePrintRuntimeService, resourceDictionaries, resourceAssignments, identifierName)
-
- val resolvedParamJsonContent = ResourceAssignmentUtils.generateResourceDataForAssignments(resourceAssignments.toList())
-
- // Check Template is there
- if (artifactTemplate != null) {
- val templateContent = bluePrintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, artifactTemplate)
- resolvedContent = BluePrintTemplateService.generateContent(templateContent, resolvedParamJsonContent)
- } else {
- resolvedContent = resolvedParamJsonContent
- }
- return resolvedContent
- }
-
- /**
- * Iterate the Batch, get the Resource Assignment, dictionary Name, Look for the Resource definition for the
- * name, then get the type of the Resource Definition, Get the instance for the Resource Type and process the
- * request.
- */
- override fun resolveResourceAssignments(blueprintRuntimeService: BluePrintRuntimeService<*>,
- resourceDictionaries: MutableMap<String, ResourceDefinition>,
- resourceAssignments: MutableList<ResourceAssignment>,
- identifierName: String) {
-
- val bulkSequenced = BulkResourceSequencingUtils.process(resourceAssignments)
- val resourceAssignmentRuntimeService = ResourceAssignmentUtils.transformToRARuntimeService(blueprintRuntimeService, identifierName)
-
- bulkSequenced.map { batchResourceAssignments ->
- batchResourceAssignments.filter { it.name != "*" && it.name != "start" }
- .forEach { resourceAssignment ->
- val dictionaryName = resourceAssignment.dictionaryName
- val dictionarySource = resourceAssignment.dictionarySource
- /**
- * Get the Processor name
- */
- val processorName = processorName(dictionaryName!!, dictionarySource!!,
- resourceDictionaries)
-
- val resourceAssignmentProcessor = applicationContext.getBean(processorName) as? ResourceAssignmentProcessor
- ?: throw BluePrintProcessorException("failed to get resource processor for name($processorName) " +
- "for resource assignment(${resourceAssignment.name})")
- try {
- // Set BluePrint Runtime Service
- resourceAssignmentProcessor.raRuntimeService = resourceAssignmentRuntimeService
- // Set Resource Dictionaries
- resourceAssignmentProcessor.resourceDictionaries = resourceDictionaries
- // Invoke Apply Method
- resourceAssignmentProcessor.apply(resourceAssignment)
- } catch (e: RuntimeException) {
- resourceAssignmentProcessor.recover(e, resourceAssignment)
- throw BluePrintProcessorException(e)
- }
- }
- }
- }
-
-
- /**
- * If the Source instance is "input", then it is not mandatory to have source Resource Definition, So it can
- * derive the default input processor.
- */
- private fun processorName(dictionaryName: String, dictionarySource: String,
- resourceDictionaries: MutableMap<String, ResourceDefinition>): String {
- var processorName: String? = null
- when (dictionarySource) {
- "input" -> {
- processorName = "${ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR}source-input"
- }
- "default" -> {
- processorName = "${ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR}source-default"
- }
- else -> {
- val resourceDefinition = resourceDictionaries[dictionaryName]
- ?: throw BluePrintProcessorException("couldn't get resource dictionary definition for $dictionaryName")
-
- val resourceSource = resourceDefinition.sources[dictionarySource]
- ?: throw BluePrintProcessorException("couldn't get resource definition $dictionaryName source($dictionarySource)")
-
- processorName = ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR
- .plus(resourceSource.type)
- }
- }
- checkNotEmptyOrThrow(processorName,
- "couldn't get processor name for resource dictionary definition($dictionaryName) source" +
- "($dictionarySource)")
-
- return processorName
-
- }
-}
+/*
+ * 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.blueprintsprocessor.functions.resource.resolution
+
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.db.ResourceResolutionResultService
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor.ResourceAssignmentProcessor
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmptyOrThrow
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintTemplateService
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.BulkResourceSequencingUtils
+import org.slf4j.LoggerFactory
+import org.springframework.context.ApplicationContext
+import org.springframework.stereotype.Service
+import java.io.File
+
+interface ResourceResolutionService {
+
+ fun registeredResourceSources(): List<String>
+
+ fun resolveFromDatabase(bluePrintRuntimeService: BluePrintRuntimeService<*>, artifactTemplate: String,
+ resolutionKey: String): String
+
+ fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
+ artifactNames: List<String>, properties: Map<String, Any>): MutableMap<String, String>
+
+ fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
+ artifactPrefix: String, properties: Map<String, Any>): String
+
+ fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
+ artifactMapping: String, artifactTemplate: String?): String
+
+ fun resolveResourceAssignments(blueprintRuntimeService: BluePrintRuntimeService<*>,
+ resourceDictionaries: MutableMap<String, ResourceDefinition>,
+ resourceAssignments: MutableList<ResourceAssignment>,
+ identifierName: String)
+}
+
+@Service(ResourceResolutionConstants.SERVICE_RESOURCE_RESOLUTION)
+open class ResourceResolutionServiceImpl(private var applicationContext: ApplicationContext,
+ private var resolutionResultService: ResourceResolutionResultService) :
+ ResourceResolutionService {
+
+ private val log = LoggerFactory.getLogger(ResourceResolutionService::class.java)
+
+ override fun registeredResourceSources(): List<String> {
+ return applicationContext.getBeanNamesForType(ResourceAssignmentProcessor::class.java)
+ .filter { it.startsWith(ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR) }
+ .map { it.substringAfter(ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR) }
+ }
+
+ override fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
+ artifactNames: List<String>,
+ properties: Map<String, Any>): MutableMap<String, String> {
+
+ val resolvedParams: MutableMap<String, String> = hashMapOf()
+ artifactNames.forEach { artifactName ->
+ val resolvedContent = resolveResources(bluePrintRuntimeService, nodeTemplateName, artifactName, properties)
+ resolvedParams[artifactName] = resolvedContent
+ }
+ return resolvedParams
+ }
+
+ override fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
+ artifactPrefix: String, properties: Map<String, Any>): String {
+
+ // Velocity Artifact Definition Name
+ val artifactTemplate = "$artifactPrefix-template"
+ // Resource Assignment Artifact Definition Name
+ val artifactMapping = "$artifactPrefix-mapping"
+
+ val result = resolveResources(bluePrintRuntimeService, nodeTemplateName, artifactMapping, artifactTemplate)
+
+ if (properties.containsKey(ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_STORE_RESULT)
+ && properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_STORE_RESULT] as Boolean) {
+ resolutionResultService.write(properties, result, bluePrintRuntimeService, artifactPrefix)
+ }
+
+ return result
+ }
+
+ override fun resolveFromDatabase(bluePrintRuntimeService: BluePrintRuntimeService<*>, artifactTemplate: String,
+ resolutionKey: String): String {
+ return resolutionResultService.read(bluePrintRuntimeService, artifactTemplate, resolutionKey)
+ }
+
+ override fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
+ artifactMapping: String, artifactTemplate: String?): String {
+
+ var resolvedContent = ""
+ log.info("Resolving resource for template artifact($artifactTemplate) with resource assignment artifact($artifactMapping)")
+
+ val identifierName = artifactTemplate ?: "no-template"
+
+ val resourceAssignmentContent =
+ bluePrintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, artifactMapping)
+
+ val resourceAssignments: MutableList<ResourceAssignment> =
+ JacksonUtils.getListFromJson(resourceAssignmentContent, ResourceAssignment::class.java)
+ as? MutableList<ResourceAssignment>
+ ?: throw BluePrintProcessorException("couldn't get Dictionary Definitions")
+
+ // Get the Resource Dictionary Name
+ val dictionaryFile = bluePrintRuntimeService.bluePrintContext().rootPath.plus(File.separator)
+ .plus(BluePrintConstants.TOSCA_DEFINITIONS_DIR).plus(File.separator)
+ .plus(ResourceResolutionConstants.FILE_NAME_RESOURCE_DEFINITION_TYPES)
+
+ val resourceDictionaries: MutableMap<String, ResourceDefinition> =
+ JacksonUtils.getMapFromFile(dictionaryFile, ResourceDefinition::class.java)
+ ?: throw BluePrintProcessorException("couldn't get Dictionary Definitions")
+
+ // Resolve resources
+ resolveResourceAssignments(bluePrintRuntimeService, resourceDictionaries, resourceAssignments, identifierName)
+
+ val resolvedParamJsonContent =
+ ResourceAssignmentUtils.generateResourceDataForAssignments(resourceAssignments.toList())
+
+ // Check Template is there
+ if (artifactTemplate != null) {
+ val templateContent =
+ bluePrintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, artifactTemplate)
+ resolvedContent = BluePrintTemplateService.generateContent(templateContent, resolvedParamJsonContent)
+ } else {
+ resolvedContent = resolvedParamJsonContent
+ }
+
+ return resolvedContent
+ }
+
+ /**
+ * Iterate the Batch, get the Resource Assignment, dictionary Name, Look for the Resource definition for the
+ * name, then get the type of the Resource Definition, Get the instance for the Resource Type and process the
+ * request.
+ */
+ override fun resolveResourceAssignments(blueprintRuntimeService: BluePrintRuntimeService<*>,
+ resourceDictionaries: MutableMap<String, ResourceDefinition>,
+ resourceAssignments: MutableList<ResourceAssignment>,
+ identifierName: String) {
+
+ val bulkSequenced = BulkResourceSequencingUtils.process(resourceAssignments)
+ val resourceAssignmentRuntimeService =
+ ResourceAssignmentUtils.transformToRARuntimeService(blueprintRuntimeService, identifierName)
+
+ bulkSequenced.map { batchResourceAssignments ->
+ batchResourceAssignments.filter { it.name != "*" && it.name != "start" }
+ .forEach { resourceAssignment ->
+ val dictionaryName = resourceAssignment.dictionaryName
+ val dictionarySource = resourceAssignment.dictionarySource
+ /**
+ * Get the Processor name
+ */
+ val processorName = processorName(dictionaryName!!, dictionarySource!!,
+ resourceDictionaries)
+
+ val resourceAssignmentProcessor =
+ applicationContext.getBean(processorName) as? ResourceAssignmentProcessor
+ ?: throw BluePrintProcessorException("failed to get resource processor for name($processorName) " +
+ "for resource assignment(${resourceAssignment.name})")
+ try {
+ // Set BluePrint Runtime Service
+ resourceAssignmentProcessor.raRuntimeService = resourceAssignmentRuntimeService
+ // Set Resource Dictionaries
+ resourceAssignmentProcessor.resourceDictionaries = resourceDictionaries
+ // Invoke Apply Method
+ resourceAssignmentProcessor.apply(resourceAssignment)
+ } catch (e: RuntimeException) {
+ resourceAssignmentProcessor.recover(e, resourceAssignment)
+ throw BluePrintProcessorException(e)
+ }
+ }
+ }
+ }
+
+
+ /**
+ * If the Source instance is "input", then it is not mandatory to have source Resource Definition, So it can
+ * derive the default input processor.
+ */
+ private fun processorName(dictionaryName: String, dictionarySource: String,
+ resourceDictionaries: MutableMap<String, ResourceDefinition>): String {
+ var processorName: String? = null
+ when (dictionarySource) {
+ "input" -> {
+ processorName = "${ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR}source-input"
+ }
+ "default" -> {
+ processorName = "${ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR}source-default"
+ }
+ else -> {
+ val resourceDefinition = resourceDictionaries[dictionaryName]
+ ?: throw BluePrintProcessorException("couldn't get resource dictionary definition for $dictionaryName")
+
+ val resourceSource = resourceDefinition.sources[dictionarySource]
+ ?: throw BluePrintProcessorException("couldn't get resource definition $dictionaryName source($dictionarySource)")
+
+ processorName = ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR
+ .plus(resourceSource.type)
+ }
+ }
+ checkNotEmptyOrThrow(processorName,
+ "couldn't get processor name for resource dictionary definition($dictionaryName) source" +
+ "($dictionarySource)")
+
+ return processorName
+
+ }
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionRepository.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionRepository.kt
new file mode 100644
index 00000000..e50c578d
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionRepository.kt
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2019 Bell Canada.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.db
+
+import org.springframework.data.jpa.repository.JpaRepository
+
+interface ResourceResolutionRepository : JpaRepository<ResourceResolutionResult, String> {
+
+ fun findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactName(key: String, blueprintName: String?,
+ blueprintVersion: String?,
+ artifactName: String): ResourceResolutionResult
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionResult.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionResult.kt
new file mode 100755
index 00000000..814fba5e
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionResult.kt
@@ -0,0 +1,69 @@
+/*
+ * Copyright © 2019 Bell Canada
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.db
+
+import com.fasterxml.jackson.annotation.JsonFormat
+import org.hibernate.annotations.Proxy
+import org.springframework.data.annotation.LastModifiedDate
+import org.springframework.data.jpa.domain.support.AuditingEntityListener
+import java.io.Serializable
+import java.util.*
+import javax.persistence.Column
+import javax.persistence.Entity
+import javax.persistence.EntityListeners
+import javax.persistence.Id
+import javax.persistence.Lob
+import javax.persistence.Table
+import javax.persistence.Temporal
+import javax.persistence.TemporalType
+
+@EntityListeners(AuditingEntityListener::class)
+@Entity
+@Table(name = "RESOURCE_RESOLUTION_RESULT")
+@Proxy(lazy = false)
+class ResourceResolutionResult : Serializable {
+
+ @Id
+ @Column(name = "resource_resolution_result_id")
+ var id: String? = null
+
+ @Column(name = "resolution_key", nullable = false)
+ var resolutionKey: String? = null
+
+ @Column(name = "blueprint_name", nullable = false)
+ var blueprintName: String? = null
+
+ @Column(name = "blueprint_version", nullable = false)
+ var blueprintVersion: String? = null
+
+ @Column(name = "artifact_name", nullable = false)
+ var artifactName: String? = null
+
+ @Lob
+ @Column(name = "result", nullable = false)
+ var result: String? = null
+
+ @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
+ @LastModifiedDate
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name = "creation_date")
+ var createdDate = Date()
+
+ companion object {
+ private const val serialVersionUID = 1L
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionResultService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionResultService.kt
new file mode 100644
index 00000000..448782a8
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionResultService.kt
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2019 Bell Canada.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.db
+
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceResolutionConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+import org.springframework.dao.DataIntegrityViolationException
+import org.springframework.stereotype.Service
+import java.util.*
+
+@Service
+class ResourceResolutionResultService(private val resourceResolutionRepository: ResourceResolutionRepository) {
+
+ fun write(properties: Map<String, Any>, result: String, bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ artifactPrefix: String) {
+
+ val metadata = bluePrintRuntimeService.bluePrintContext().metadata!!
+
+ val resourceResolutionResult = ResourceResolutionResult()
+ resourceResolutionResult.id = UUID.randomUUID().toString()
+ resourceResolutionResult.artifactName = artifactPrefix
+ resourceResolutionResult.blueprintVersion = metadata[BluePrintConstants.METADATA_TEMPLATE_VERSION]
+ resourceResolutionResult.blueprintName = metadata[BluePrintConstants.METADATA_TEMPLATE_NAME]
+ resourceResolutionResult.resolutionKey =
+ properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_KEY].toString()
+ resourceResolutionResult.result = result
+
+ try {
+ resourceResolutionRepository.saveAndFlush(resourceResolutionResult)
+ } catch (ex: DataIntegrityViolationException) {
+ throw BluePrintException("Failed to store resource resolution result.", ex)
+ }
+ }
+
+ fun read(bluePrintRuntimeService: BluePrintRuntimeService<*>, artifactPrefix: String,
+ resolutionKey: String): String {
+
+ val metadata = bluePrintRuntimeService.bluePrintContext().metadata!!
+
+ val blueprintVersion = metadata[BluePrintConstants.METADATA_TEMPLATE_VERSION]
+ val blueprintName = metadata[BluePrintConstants.METADATA_TEMPLATE_NAME]
+
+ return resourceResolutionRepository.findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactName(
+ resolutionKey,
+ blueprintName,
+ blueprintVersion,
+ artifactPrefix).result!!
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessor.kt
index c6b7d77e..c2dbd731 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessor.kt
@@ -19,6 +19,7 @@
package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.CapabilityResourceSource
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR
import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.scripts.BlueprintJythonService
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
@@ -32,7 +33,7 @@ import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Service
import java.io.File
-@Service("rr-processor-source-capability")
+@Service("${PREFIX_RESOURCE_RESOLUTION_PROCESSOR}source-capability")
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
open class CapabilityResourceResolutionProcessor(private var applicationContext: ApplicationContext,
private val bluePrintScriptsService: BluePrintScriptsService,
@@ -40,7 +41,7 @@ open class CapabilityResourceResolutionProcessor(private var applicationContext:
ResourceAssignmentProcessor() {
override fun getName(): String {
- return "resource-assignment-processor-capability"
+ return "${PREFIX_RESOURCE_RESOLUTION_PROCESSOR}source-capability"
}
override fun process(resourceAssignment: ResourceAssignment) {
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/PrimaryDataResourceResolutionProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceAssignmentProcessor.kt
index 3922c376..39be14c9 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/PrimaryDataResourceResolutionProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceAssignmentProcessor.kt
@@ -18,38 +18,35 @@
package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor
import com.fasterxml.jackson.databind.node.JsonNodeFactory
-import org.onap.ccsdk.apps.blueprintsprocessor.db.primary.PrimaryDBLibGenericService
+import org.onap.ccsdk.apps.blueprintsprocessor.db.primary.DBLibGenericService
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.DatabaseResourceSource
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes
-import org.onap.ccsdk.apps.controllerblueprints.core.checkEqualsOrThrow
-import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmptyOrThrow
-import org.onap.ccsdk.apps.controllerblueprints.core.nullToEmpty
-import org.onap.ccsdk.apps.controllerblueprints.core.returnNotEmptyOrThrow
+import org.onap.ccsdk.apps.controllerblueprints.core.*
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.config.ConfigurableBeanFactory
import org.springframework.context.annotation.Scope
+import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate
import org.springframework.stereotype.Service
import java.util.*
/**
- * PrimaryDataResourceResolutionProcessor
+ * DatabaseResourceAssignmentProcessor
*
* @author Kapil Singal
*/
-@Service("rr-processor-source-primary-db")
+@Service("${PREFIX_RESOURCE_RESOLUTION_PROCESSOR}source-primary-db")
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-open class PrimaryDataResourceResolutionProcessor(private val primaryDBLibGenericService: PrimaryDBLibGenericService)
+open class DatabaseResourceAssignmentProcessor(private val dBLibGenericService: DBLibGenericService)
: ResourceAssignmentProcessor() {
- private val logger = LoggerFactory.getLogger(PrimaryDataResourceResolutionProcessor::class.java)
+ private val logger = LoggerFactory.getLogger(DatabaseResourceAssignmentProcessor::class.java)
override fun getName(): String {
- return "rr-processor-source-primary-db"
+ return "${PREFIX_RESOURCE_RESOLUTION_PROCESSOR}source-primary-db"
}
override fun process(resourceAssignment: ResourceAssignment) {
@@ -62,26 +59,22 @@ open class PrimaryDataResourceResolutionProcessor(private val primaryDBLibGeneri
logger.info("primary-db source template key (${resourceAssignment.name}) found from input and value is ($value)")
ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, value)
} catch (e: BluePrintProcessorException) {
- // Else, get from DB
val dName = resourceAssignment.dictionaryName
val dSource = resourceAssignment.dictionarySource
val resourceDefinition = resourceDictionaries[dName]
- ?: throw BluePrintProcessorException("couldn't get resource dictionary definition for $dName")
+ ?: throw BluePrintProcessorException("couldn't get resource dictionary definition for $dName")
val resourceSource = resourceDefinition.sources[dSource]
- ?: throw BluePrintProcessorException("couldn't get resource definition $dName source($dSource)")
- val resourceSourceProperties =
- checkNotNull(resourceSource.properties) { "failed to get source properties for $dName " }
- val sourceProperties =
- JacksonUtils.getInstanceFromMap(resourceSourceProperties, DatabaseResourceSource::class.java)
+ ?: throw BluePrintProcessorException("couldn't get resource definition $dName source($dSource)")
+ val resourceSourceProperties = checkNotNull(resourceSource.properties) { "failed to get source properties for $dName " }
+ val sourceProperties = JacksonUtils.getInstanceFromMap(resourceSourceProperties, DatabaseResourceSource::class.java)
- val sql =
- checkNotNull(sourceProperties.query) { "failed to get request query for $dName under $dSource properties" }
- val inputKeyMapping =
- checkNotNull(sourceProperties.inputKeyMapping) { "failed to get input-key-mappings for $dName under $dSource properties" }
+ val sql = checkNotNull(sourceProperties.query) { "failed to get request query for $dName under $dSource properties" }
+ val inputKeyMapping = checkNotNull(sourceProperties.inputKeyMapping) { "failed to get input-key-mappings for $dName under $dSource properties" }
logger.info("$dSource dictionary information : ($sql), ($inputKeyMapping), (${sourceProperties.outputKeyMapping})")
+ val jdbcTemplate = blueprintDBLibService(sourceProperties)
- val rows = primaryDBLibGenericService.query(sql, populateNamedParameter(inputKeyMapping))
+ val rows = jdbcTemplate.queryForList(sql, populateNamedParameter(inputKeyMapping))
if (rows.isNullOrEmpty()) {
logger.warn("Failed to get $dSource result for dictionary name ($dName) the query ($sql)")
} else {
@@ -93,16 +86,24 @@ open class PrimaryDataResourceResolutionProcessor(private val primaryDBLibGeneri
ResourceAssignmentUtils.assertTemplateKeyValueNotNull(resourceAssignment)
} catch (e: Exception) {
ResourceAssignmentUtils.setFailedResourceDataValue(resourceAssignment, e.message)
- throw BluePrintProcessorException("Failed in template key ($resourceAssignment) assignments with: ${e.message}",
- e)
+ throw BluePrintProcessorException("Failed in template key ($resourceAssignment) assignments with: ${e.message}", e)
}
}
+ private fun blueprintDBLibService(sourceProperties: DatabaseResourceSource): NamedParameterJdbcTemplate {
+ return if (checkNotEmpty(sourceProperties.endpointSelector!!)) {
+ val dbPropertiesJson = raRuntimeService.resolveDSLExpression(sourceProperties.endpointSelector!!)
+ dBLibGenericService.remoteJdbcTemplate(dbPropertiesJson)
+ } else {
+ dBLibGenericService.primaryJdbcTemplate()
+ }
+
+ }
+
@Throws(BluePrintProcessorException::class)
private fun validate(resourceAssignment: ResourceAssignment) {
checkNotEmptyOrThrow(resourceAssignment.name, "resource assignment template key is not defined")
- checkNotEmptyOrThrow(resourceAssignment.dictionaryName,
- "resource assignment dictionary name is not defined for template key (${resourceAssignment.name})")
+ checkNotEmptyOrThrow(resourceAssignment.dictionaryName, "resource assignment dictionary name is not defined for template key (${resourceAssignment.name})")
checkEqualsOrThrow(ResourceDictionaryConstants.SOURCE_PRIMARY_DB, resourceAssignment.dictionarySource) {
"resource assignment source is not ${ResourceDictionaryConstants.SOURCE_PRIMARY_DB} but it is ${resourceAssignment.dictionarySource}"
}
@@ -111,35 +112,32 @@ open class PrimaryDataResourceResolutionProcessor(private val primaryDBLibGeneri
private fun populateNamedParameter(inputKeyMapping: Map<String, String>): Map<String, Any> {
val namedParameters = HashMap<String, Any>()
inputKeyMapping.forEach {
- val expressionValue = raRuntimeService.getDictionaryStore(it.value)
+ val expressionValue = raRuntimeService.getDictionaryStore(it.value).textValue()
logger.trace("Reference dictionary key (${it.key}) resulted in value ($expressionValue)")
- namedParameters[it.key] = expressionValue.asText()
+ namedParameters[it.key] = expressionValue
}
logger.info("Parameter information : ({})", namedParameters)
return namedParameters
}
@Throws(BluePrintProcessorException::class)
- private fun populateResource(resourceAssignment: ResourceAssignment, sourceProperties: DatabaseResourceSource,
- rows: List<Map<String, Any>>) {
+ private fun populateResource(resourceAssignment: ResourceAssignment, sourceProperties: DatabaseResourceSource, rows: List<Map<String, Any>>) {
val dName = resourceAssignment.dictionaryName
val dSource = resourceAssignment.dictionarySource
val type = nullToEmpty(resourceAssignment.property?.type)
- val outputKeyMapping =
- checkNotNull(sourceProperties.outputKeyMapping) { "failed to get output-key-mappings for $dName under $dSource properties" }
+ val outputKeyMapping = checkNotNull(sourceProperties.outputKeyMapping) { "failed to get output-key-mappings for $dName under $dSource properties" }
logger.info("Response processing type($type)")
// Primitive Types
- when (type) {
+ when(type) {
in BluePrintTypes.validPrimitiveTypes() -> {
val dbColumnValue = rows[0][outputKeyMapping[dName]]
logger.info("For template key (${resourceAssignment.name}) setting value as ($dbColumnValue)")
ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, dbColumnValue)
}
in BluePrintTypes.validCollectionTypes() -> {
- val entrySchemaType =
- returnNotEmptyOrThrow(resourceAssignment.property?.entrySchema?.type) { "Entry schema is not defined for dictionary ($dName) info" }
+ val entrySchemaType = returnNotEmptyOrThrow(resourceAssignment.property?.entrySchema?.type) { "Entry schema is not defined for dictionary ($dName) info" }
var arrayNode = JsonNodeFactory.instance.arrayNode()
rows.forEach {
if (entrySchemaType in BluePrintTypes.validPrimitiveTypes()) {
@@ -150,12 +148,8 @@ open class PrimaryDataResourceResolutionProcessor(private val primaryDBLibGeneri
val arrayChildNode = JsonNodeFactory.instance.objectNode()
for (mapping in outputKeyMapping.entries) {
val dbColumnValue = checkNotNull(it[mapping.key])
- val propertyTypeForDataType =
- ResourceAssignmentUtils.getPropertyType(raRuntimeService, entrySchemaType, mapping.key)
- JacksonUtils.populatePrimitiveValues(mapping.key,
- dbColumnValue,
- propertyTypeForDataType,
- arrayChildNode)
+ val propertyTypeForDataType = ResourceAssignmentUtils.getPropertyType(raRuntimeService, entrySchemaType, mapping.key)
+ JacksonUtils.populatePrimitiveValues(mapping.key, dbColumnValue, propertyTypeForDataType, arrayChildNode)
}
arrayNode.add(arrayChildNode)
}
@@ -170,12 +164,8 @@ open class PrimaryDataResourceResolutionProcessor(private val primaryDBLibGeneri
var objectNode = JsonNodeFactory.instance.objectNode()
for (mapping in outputKeyMapping.entries) {
val dbColumnValue = checkNotNull(row[mapping.key])
- val propertyTypeForDataType =
- ResourceAssignmentUtils.getPropertyType(raRuntimeService, type, mapping.key)
- JacksonUtils.populatePrimitiveValues(mapping.key,
- dbColumnValue,
- propertyTypeForDataType,
- objectNode)
+ val propertyTypeForDataType = ResourceAssignmentUtils.getPropertyType(raRuntimeService, type, mapping.key)
+ JacksonUtils.populatePrimitiveValues(mapping.key, dbColumnValue, propertyTypeForDataType, objectNode)
}
logger.info("For template key (${resourceAssignment.name}) setting value as ($objectNode)")
ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, objectNode)
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessor.kt
index a8e0ad80..528705f1 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessor.kt
@@ -17,6 +17,8 @@
package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor
+import com.fasterxml.jackson.databind.JsonNode
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
@@ -30,20 +32,20 @@ import org.springframework.stereotype.Service
*
* @author Kapil Singal
*/
-@Service("rr-processor-source-default")
+@Service("${PREFIX_RESOURCE_RESOLUTION_PROCESSOR}source-default")
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
open class DefaultResourceResolutionProcessor : ResourceAssignmentProcessor() {
private val logger = LoggerFactory.getLogger(DefaultResourceResolutionProcessor::class.java)
override fun getName(): String {
- return "rr-processor-source-default"
+ return "${PREFIX_RESOURCE_RESOLUTION_PROCESSOR}source-default"
}
override fun process(resourceAssignment: ResourceAssignment) {
try {
// Check if It has Input
- var value: Any?
+ var value: JsonNode?
try {
value = raRuntimeService.getInputValue(resourceAssignment.name)
} catch (e: BluePrintProcessorException) {
@@ -60,7 +62,7 @@ open class DefaultResourceResolutionProcessor : ResourceAssignmentProcessor() {
} catch (e: Exception) {
ResourceAssignmentUtils.setFailedResourceDataValue(resourceAssignment, e.message)
throw BluePrintProcessorException("Failed in template key ($resourceAssignment) assignments with: ${e.message}",
- e)
+ e)
}
}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessor.kt
index ed6b09fc..a6622228 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessor.kt
@@ -17,7 +17,9 @@
package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor
+import com.fasterxml.jackson.databind.node.MissingNode
import com.fasterxml.jackson.databind.node.NullNode
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmpty
@@ -32,14 +34,14 @@ import org.springframework.stereotype.Service
*
* @author Kapil Singal
*/
-@Service("rr-processor-source-input")
+@Service("${PREFIX_RESOURCE_RESOLUTION_PROCESSOR}source-input")
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
open class InputResourceResolutionProcessor : ResourceAssignmentProcessor() {
private val logger = LoggerFactory.getLogger(InputResourceResolutionProcessor::class.java)
override fun getName(): String {
- return "rr-processor-source-input"
+ return "${PREFIX_RESOURCE_RESOLUTION_PROCESSOR}source-input"
}
override fun process(resourceAssignment: ResourceAssignment) {
@@ -47,7 +49,7 @@ open class InputResourceResolutionProcessor : ResourceAssignmentProcessor() {
if (checkNotEmpty(resourceAssignment.name)) {
val value = raRuntimeService.getInputValue(resourceAssignment.name)
// if value is null don't call setResourceDataValue to populate the value
- if (value != null && value !is NullNode) {
+ if (value !is MissingNode && value !is NullNode) {
logger.info("input source template key (${resourceAssignment.name}) found from input and value is ($value)")
ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, value)
}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt
index 4daa46e5..37b4774a 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt
@@ -19,13 +19,21 @@ package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.pr
import com.fasterxml.jackson.databind.node.ArrayNode
import com.fasterxml.jackson.databind.node.JsonNodeFactory
+import com.fasterxml.jackson.databind.node.MissingNode
import com.fasterxml.jackson.databind.node.NullNode
import com.fasterxml.jackson.databind.node.ObjectNode
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.RestResourceSource
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils
import org.onap.ccsdk.apps.blueprintsprocessor.rest.service.BluePrintRestLibPropertyService
import org.onap.ccsdk.apps.blueprintsprocessor.rest.service.BlueprintWebClientService
-import org.onap.ccsdk.apps.controllerblueprints.core.*
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes
+import org.onap.ccsdk.apps.controllerblueprints.core.checkEqualsOrThrow
+import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmpty
+import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmptyOrThrow
+import org.onap.ccsdk.apps.controllerblueprints.core.nullToEmpty
+import org.onap.ccsdk.apps.controllerblueprints.core.returnNotEmptyOrThrow
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants
@@ -39,7 +47,7 @@ import org.springframework.stereotype.Service
*
* @author Kapil Singal
*/
-@Service("rr-processor-source-rest")
+@Service("${PREFIX_RESOURCE_RESOLUTION_PROCESSOR}source-rest")
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
open class RestResourceResolutionProcessor(private val blueprintRestLibPropertyService: BluePrintRestLibPropertyService)
: ResourceAssignmentProcessor() {
@@ -47,7 +55,7 @@ open class RestResourceResolutionProcessor(private val blueprintRestLibPropertyS
private val logger = LoggerFactory.getLogger(RestResourceResolutionProcessor::class.java)
override fun getName(): String {
- return "rr-processor-source-rest"
+ return "${PREFIX_RESOURCE_RESOLUTION_PROCESSOR}source-rest"
}
override fun process(resourceAssignment: ResourceAssignment) {
@@ -56,28 +64,32 @@ open class RestResourceResolutionProcessor(private val blueprintRestLibPropertyS
// Check if It has Input
val value = raRuntimeService.getInputValue(resourceAssignment.name)
- if (value != null && value !is NullNode) {
+ if (value !is MissingNode && value !is NullNode) {
logger.info("primary-db source template key (${resourceAssignment.name}) found from input and value is ($value)")
ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, value)
} else {
val dName = resourceAssignment.dictionaryName
val dSource = resourceAssignment.dictionarySource
val resourceDefinition = resourceDictionaries[dName]
- ?: throw BluePrintProcessorException("couldn't get resource dictionary definition for $dName")
+ ?: throw BluePrintProcessorException("couldn't get resource dictionary definition for $dName")
val resourceSource = resourceDefinition.sources[dSource]
- ?: throw BluePrintProcessorException("couldn't get resource definition $dName source($dSource)")
- val resourceSourceProperties = checkNotNull(resourceSource.properties) { "failed to get source properties for $dName " }
- val sourceProperties = JacksonUtils.getInstanceFromMap(resourceSourceProperties, RestResourceSource::class.java)
-
- val urlPath = checkNotNull(sourceProperties.urlPath) { "failed to get request urlPath for $dName under $dSource properties" }
+ ?: throw BluePrintProcessorException("couldn't get resource definition $dName source($dSource)")
+ val resourceSourceProperties =
+ checkNotNull(resourceSource.properties) { "failed to get source properties for $dName " }
+ val sourceProperties =
+ JacksonUtils.getInstanceFromMap(resourceSourceProperties, RestResourceSource::class.java)
+
+ val urlPath =
+ checkNotNull(sourceProperties.urlPath) { "failed to get request urlPath for $dName under $dSource properties" }
val path = nullToEmpty(sourceProperties.path)
- val inputKeyMapping = checkNotNull(sourceProperties.inputKeyMapping) { "failed to get input-key-mappings for $dName under $dSource properties" }
+ val inputKeyMapping =
+ checkNotNull(sourceProperties.inputKeyMapping) { "failed to get input-key-mappings for $dName under $dSource properties" }
logger.info("$dSource dictionary information : ($urlPath), ($inputKeyMapping), (${sourceProperties.outputKeyMapping})")
// Get the Rest Client Service
val restClientService = blueprintWebClientService(resourceAssignment, sourceProperties)
val response = restClientService.getResource(urlPath, String::class.java)
- if (response.isNotBlank()) {
+ if (response.isBlank()) {
logger.warn("Failed to get $dSource result for dictionary name ($dName) using urlPath ($urlPath)")
} else {
populateResource(resourceAssignment, sourceProperties, response, path)
@@ -87,7 +99,8 @@ open class RestResourceResolutionProcessor(private val blueprintRestLibPropertyS
ResourceAssignmentUtils.assertTemplateKeyValueNotNull(resourceAssignment)
} catch (e: Exception) {
ResourceAssignmentUtils.setFailedResourceDataValue(resourceAssignment, e.message)
- throw BluePrintProcessorException("Failed in template key ($resourceAssignment) assignments with: ${e.message}", e)
+ throw BluePrintProcessorException("Failed in template key ($resourceAssignment) assignments with: ${e.message}",
+ e)
}
}
@@ -102,16 +115,19 @@ open class RestResourceResolutionProcessor(private val blueprintRestLibPropertyS
}
@Throws(BluePrintProcessorException::class)
- private fun populateResource(resourceAssignment: ResourceAssignment, sourceProperties: RestResourceSource, restResponse: String, path: String) {
+ private fun populateResource(resourceAssignment: ResourceAssignment, sourceProperties: RestResourceSource,
+ restResponse: String, path: String) {
val dName = resourceAssignment.dictionaryName
val dSource = resourceAssignment.dictionarySource
val type = nullToEmpty(resourceAssignment.property?.type)
lateinit var entrySchemaType: String
- val outputKeyMapping = checkNotNull(sourceProperties.outputKeyMapping) { "failed to get output-key-mappings for $dName under $dSource properties" }
+ val outputKeyMapping =
+ checkNotNull(sourceProperties.outputKeyMapping) { "failed to get output-key-mappings for $dName under $dSource properties" }
logger.info("Response processing type($type)")
- val responseNode = checkNotNull(JacksonUtils.jsonNode(restResponse).at(path)) { "Failed to find path ($path) in response ($restResponse)" }
+ val responseNode =
+ checkNotNull(JacksonUtils.jsonNode(restResponse).at(path)) { "Failed to find path ($path) in response ($restResponse)" }
logger.info("populating value for output mapping ($outputKeyMapping), from json ($responseNode)")
@@ -122,7 +138,8 @@ open class RestResourceResolutionProcessor(private val blueprintRestLibPropertyS
}
in BluePrintTypes.validCollectionTypes() -> {
// Array Types
- entrySchemaType = returnNotEmptyOrThrow(resourceAssignment.property?.entrySchema?.type) { "Entry schema is not defined for dictionary ($dName) info" }
+ entrySchemaType =
+ returnNotEmptyOrThrow(resourceAssignment.property?.entrySchema?.type) { "Entry schema is not defined for dictionary ($dName) info" }
val arrayNode = responseNode as ArrayNode
if (entrySchemaType !in BluePrintTypes.validPrimitiveTypes()) {
@@ -131,9 +148,13 @@ open class RestResourceResolutionProcessor(private val blueprintRestLibPropertyS
val arrayChildNode = JsonNodeFactory.instance.objectNode()
outputKeyMapping.map {
val responseKeyValue = responseSingleJsonNode.get(it.key)
- val propertyTypeForDataType = ResourceAssignmentUtils.getPropertyType(raRuntimeService, entrySchemaType, it.key)
+ val propertyTypeForDataType =
+ ResourceAssignmentUtils.getPropertyType(raRuntimeService, entrySchemaType, it.key)
logger.info("For List Type Resource: key (${it.key}), value ($responseKeyValue), type ({$propertyTypeForDataType})")
- JacksonUtils.populateJsonNodeValues(it.value, responseKeyValue, propertyTypeForDataType, arrayChildNode)
+ JacksonUtils.populateJsonNodeValues(it.value,
+ responseKeyValue,
+ propertyTypeForDataType,
+ arrayChildNode)
}
arrayNode.add(arrayChildNode)
}
@@ -147,7 +168,8 @@ open class RestResourceResolutionProcessor(private val blueprintRestLibPropertyS
val objectNode = responseNode as ObjectNode
outputKeyMapping.map {
val responseKeyValue = responseNode.get(it.key)
- val propertyTypeForDataType = ResourceAssignmentUtils.getPropertyType(raRuntimeService, entrySchemaType, it.key)
+ val propertyTypeForDataType =
+ ResourceAssignmentUtils.getPropertyType(raRuntimeService, entrySchemaType, it.key)
logger.info("For List Type Resource: key (${it.key}), value ($responseKeyValue), type ({$propertyTypeForDataType})")
JacksonUtils.populateJsonNodeValues(it.value, responseKeyValue, propertyTypeForDataType, objectNode)
}
@@ -162,11 +184,14 @@ open class RestResourceResolutionProcessor(private val blueprintRestLibPropertyS
@Throws(BluePrintProcessorException::class)
private fun validate(resourceAssignment: ResourceAssignment) {
checkNotEmptyOrThrow(resourceAssignment.name, "resource assignment template key is not defined")
- checkNotEmptyOrThrow(resourceAssignment.dictionaryName, "resource assignment dictionary name is not defined for template key (${resourceAssignment.name})")
- checkEqualsOrThrow(ResourceDictionaryConstants.SOURCE_PRIMARY_CONFIG_DATA, resourceAssignment.dictionarySource) {
+ checkNotEmptyOrThrow(resourceAssignment.dictionaryName,
+ "resource assignment dictionary name is not defined for template key (${resourceAssignment.name})")
+ checkEqualsOrThrow(ResourceDictionaryConstants.SOURCE_PRIMARY_CONFIG_DATA,
+ resourceAssignment.dictionarySource) {
"resource assignment source is not ${ResourceDictionaryConstants.SOURCE_PRIMARY_CONFIG_DATA} but it is ${resourceAssignment.dictionarySource}"
}
- checkNotEmptyOrThrow(resourceAssignment.dictionaryName, "resource assignment dictionary name is not defined for template key (${resourceAssignment.name})")
+ checkNotEmptyOrThrow(resourceAssignment.dictionaryName,
+ "resource assignment dictionary name is not defined for template key (${resourceAssignment.name})")
}
override fun recover(runtimeException: RuntimeException, resourceAssignment: ResourceAssignment) {
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt
index 1c9a905f..b5b126ab 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt
@@ -1,5 +1,6 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2019 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,13 +24,7 @@ import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.databind.node.NullNode
import com.fasterxml.jackson.databind.node.ObjectNode
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceAssignmentRuntimeService
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes
-import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmpty
-import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmptyOrThrow
-import org.onap.ccsdk.apps.controllerblueprints.core.nullToEmpty
-import org.onap.ccsdk.apps.controllerblueprints.core.returnNotEmptyOrThrow
+import org.onap.ccsdk.apps.controllerblueprints.core.*
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
@@ -40,9 +35,11 @@ class ResourceAssignmentUtils {
private val logger: EELFLogger = EELFManager.getInstance().getLogger(ResourceAssignmentUtils::class.toString())
+ // TODO("Modify Value type from Any to JsonNode")
@Synchronized
@Throws(BluePrintProcessorException::class)
- fun setResourceDataValue(resourceAssignment: ResourceAssignment, raRuntimeService: ResourceAssignmentRuntimeService, value: Any?) {
+ fun setResourceDataValue(resourceAssignment: ResourceAssignment,
+ raRuntimeService: ResourceAssignmentRuntimeService, value: Any?) {
val resourceProp = checkNotNull(resourceAssignment.property) { "Failed in setting resource value for resource mapping $resourceAssignment" }
checkNotEmptyOrThrow(resourceAssignment.name, "Failed in setting resource value for resource mapping $resourceAssignment")
@@ -111,10 +108,10 @@ class ResourceAssignmentUtils {
@Synchronized
@Throws(BluePrintProcessorException::class)
fun generateResourceDataForAssignments(assignments: List<ResourceAssignment>): String {
- var result = "{}"
+ val result: String
try {
val mapper = ObjectMapper()
- val root = mapper.readTree(result)
+ val root: ObjectNode = mapper.createObjectNode()
assignments.forEach {
if (checkNotEmpty(it.name) && it.property != null) {
@@ -122,23 +119,7 @@ class ResourceAssignmentUtils {
val type = nullToEmpty(it.property?.type).toLowerCase()
val value = it.property?.value
logger.info("Generating Resource name ($rName), type ($type), value ($value)")
-
- when (value) {
- null -> (root as ObjectNode).set(rName, null)
- is JsonNode -> (root as ObjectNode).set(rName, value)
- else -> {
- when (type) {
- BluePrintConstants.DATA_TYPE_TIMESTAMP -> (root as ObjectNode).put(rName, value as String)
- BluePrintConstants.DATA_TYPE_STRING -> (root as ObjectNode).put(rName, value as String)
- BluePrintConstants.DATA_TYPE_BOOLEAN -> (root as ObjectNode).put(rName, value as Boolean)
- BluePrintConstants.DATA_TYPE_INTEGER -> (root as ObjectNode).put(rName, value as Int)
- BluePrintConstants.DATA_TYPE_FLOAT -> (root as ObjectNode).put(rName, value as Float)
- else -> {
- (root as ObjectNode).set(rName, JacksonUtils.getJsonNode(value))
- }
- }
- }
- }
+ root.set(rName, value)
}
}
result = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(root)
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt
index c3b10184..b3e3e4ed 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt
@@ -25,7 +25,7 @@ import org.onap.ccsdk.apps.blueprintsprocessor.core.BlueprintPropertyConfigurati
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
import org.onap.ccsdk.apps.blueprintsprocessor.core.utils.PayloadUtils
import org.onap.ccsdk.apps.blueprintsprocessor.db.BluePrintDBLibConfiguration
-import org.onap.ccsdk.apps.blueprintsprocessor.db.primary.PrimaryDBLibGenericService
+import org.onap.ccsdk.apps.blueprintsprocessor.db.primary.DBLibGenericService
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor.*
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.asJsonNode
@@ -43,8 +43,8 @@ import org.springframework.test.context.junit4.SpringRunner
@RunWith(SpringRunner::class)
@ContextConfiguration(classes = [ResourceResolutionServiceImpl::class,
InputResourceResolutionProcessor::class, DefaultResourceResolutionProcessor::class,
- PrimaryDataResourceResolutionProcessor::class, RestResourceResolutionProcessor::class,
- CapabilityResourceResolutionProcessor::class, PrimaryDBLibGenericService::class,
+ DatabaseResourceAssignmentProcessor::class, RestResourceResolutionProcessor::class,
+ CapabilityResourceResolutionProcessor::class, DBLibGenericService::class,
BlueprintPropertyConfiguration::class, BluePrintProperties::class,
BluePrintDBLibConfiguration::class, BluePrintLoadConfiguration::class])
@TestPropertySource(locations = ["classpath:application-test.properties"])
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt
index 6d2d3f2d..905c8e0b 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt
@@ -25,8 +25,12 @@ import org.onap.ccsdk.apps.blueprintsprocessor.core.BlueprintPropertyConfigurati
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
import org.onap.ccsdk.apps.blueprintsprocessor.core.utils.PayloadUtils
import org.onap.ccsdk.apps.blueprintsprocessor.db.BluePrintDBLibConfiguration
-import org.onap.ccsdk.apps.blueprintsprocessor.db.primary.PrimaryDBLibGenericService
-import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor.*
+import org.onap.ccsdk.apps.blueprintsprocessor.db.primary.DBLibGenericService
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor.CapabilityResourceResolutionProcessor
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor.DatabaseResourceAssignmentProcessor
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor.DefaultResourceResolutionProcessor
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor.InputResourceResolutionProcessor
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor.RestResourceResolutionProcessor
import org.onap.ccsdk.apps.controllerblueprints.core.config.BluePrintLoadConfiguration
import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
@@ -48,8 +52,8 @@ import kotlin.test.assertTrue
@RunWith(SpringRunner::class)
@ContextConfiguration(classes = [ResourceResolutionServiceImpl::class,
InputResourceResolutionProcessor::class, DefaultResourceResolutionProcessor::class,
- PrimaryDataResourceResolutionProcessor::class, RestResourceResolutionProcessor::class,
- CapabilityResourceResolutionProcessor::class, PrimaryDBLibGenericService::class,
+ DatabaseResourceAssignmentProcessor::class, RestResourceResolutionProcessor::class,
+ CapabilityResourceResolutionProcessor::class, DBLibGenericService::class,
BlueprintPropertyConfiguration::class, BluePrintProperties::class,
BluePrintDBLibConfiguration::class, BluePrintLoadConfiguration::class])
@TestPropertySource(locations = ["classpath:application-test.properties"])
@@ -67,7 +71,7 @@ class ResourceResolutionServiceTest {
val sources = resourceResolutionService.registeredResourceSources()
assertNotNull(sources, "failed to get registered sources")
assertTrue(sources.containsAll(arrayListOf("source-input", "source-default", "source-primary-db",
- "source-rest")), "failed to get registered sources")
+ "source-rest")), "failed to get registered sources : $sources")
}
@Test
@@ -85,7 +89,7 @@ class ResourceResolutionServiceTest {
// Prepare Inputs
PayloadUtils.prepareInputsFromWorkflowPayload(bluePrintRuntimeService, executionServiceInput.payload, "resource-assignment")
- resourceResolutionService.resolveResources(bluePrintRuntimeService, "resource-assignment", "baseconfig")
+ resourceResolutionService.resolveResources(bluePrintRuntimeService, "resource-assignment", "baseconfig", mapOf())
}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/application-test.properties b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/application-test.properties
index e2785c8a..3f37d1b9 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/application-test.properties
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/application-test.properties
@@ -35,4 +35,9 @@ blueprintsprocessor.restclient.primary-config-data.token=sampletoken
# Python executor
blueprints.processor.functions.python.executor.executionPath=./../../../../components/scripts/python/ccsdk_blueprints
-blueprints.processor.functions.python.executor.modulePaths=./../../../../components/scripts/python/ccsdk_blueprints \ No newline at end of file
+blueprints.processor.functions.python.executor.modulePaths=./../../../../components/scripts/python/ccsdk_blueprints
+
+
+# CBA examples for tests cases
+controllerblueprints.loadBlueprintsExamplesPath=./../../../../components/model-catalog/blueprint-model/test-blueprint
+controllerblueprints.loadBluePrintPaths=./../../../../components/model-catalog/blueprint-model/test-blueprint \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/payload/requests/sample-resourceresolution-request.json b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/payload/requests/sample-resourceresolution-request.json
index c4fe4eab..6a7b4c2a 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/payload/requests/sample-resourceresolution-request.json
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/payload/requests/sample-resourceresolution-request.json
@@ -19,6 +19,7 @@
"resource-assignment-request": {
"resource-assignment-properties": {
"request-id": "1234",
+ "profile_name": "1.0.0",
"service-instance-id": "siid_1234",
"vnf-id": "vnf_1234",
"action-name": "assign-activate",
diff --git a/ms/blueprintsprocessor/functions/restconf-executor/pom.xml b/ms/blueprintsprocessor/functions/restconf-executor/pom.xml
index cee90b6e..b87b2948 100644
--- a/ms/blueprintsprocessor/functions/restconf-executor/pom.xml
+++ b/ms/blueprintsprocessor/functions/restconf-executor/pom.xml
@@ -34,6 +34,11 @@
<groupId>org.onap.ccsdk.apps.blueprintsprocessor.functions</groupId>
<artifactId>resource-resolution</artifactId>
</dependency>
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
diff --git a/ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/restconf/executor/RestconfComponentFunction.kt b/ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/restconf/executor/RestconfComponentFunction.kt
index c6afc3b8..c3f2253a 100644
--- a/ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/restconf/executor/RestconfComponentFunction.kt
+++ b/ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/restconf/executor/RestconfComponentFunction.kt
@@ -17,6 +17,7 @@
package org.onap.ccsdk.apps.blueprintsprocessor.functions.restconf.executor
+import com.fasterxml.jackson.databind.JsonNode
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceResolutionConstants
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceResolutionService
import org.onap.ccsdk.apps.blueprintsprocessor.rest.RestLibConstants
@@ -38,6 +39,14 @@ abstract class RestconfComponentFunction : AbstractComponentFunction() {
return bluePrintRestLibPropertyService().blueprintWebClientService(selector)
}
+ fun getDynamicProperties(key: String): JsonNode {
+ return operationInputs["dynamic-properties"]!!.get(key)
+ }
+
+ fun resolveFromDatabase(resolutionKey: String, artifactName: String): String {
+ return resourceResolutionService().resolveFromDatabase(bluePrintRuntimeService, artifactName, resolutionKey)
+ }
+
fun generateMessage(artifactName: String): String {
return bluePrintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, artifactName)
}
@@ -49,6 +58,6 @@ abstract class RestconfComponentFunction : AbstractComponentFunction() {
fun resolveAndGenerateMessage(artifactPrefix: String): String {
return resourceResolutionService().resolveResources(bluePrintRuntimeService, nodeTemplateName,
- artifactPrefix)
+ artifactPrefix, mapOf())
}
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/restconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/restconf/executor/ComponentRestconfExecutorTest.kt b/ms/blueprintsprocessor/functions/restconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/restconf/executor/ComponentRestconfExecutorTest.kt
index c8a2090b..5d903bc7 100644
--- a/ms/blueprintsprocessor/functions/restconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/restconf/executor/ComponentRestconfExecutorTest.kt
+++ b/ms/blueprintsprocessor/functions/restconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/restconf/executor/ComponentRestconfExecutorTest.kt
@@ -23,42 +23,35 @@ import io.mockk.every
import io.mockk.mockk
import org.junit.Test
import org.junit.runner.RunWith
-import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintProperties
-import org.onap.ccsdk.apps.blueprintsprocessor.core.BlueprintPropertyConfiguration
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.blueprintsprocessor.functions.resource.resolution.ResourceResolutionServiceImpl
-import org.onap.ccsdk.apps.blueprintsprocessor.rest.service.BluePrintRestLibPropertyService
-import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.ComponentFunctionScriptingService
-import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.scripts.BlueprintJythonService
-import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.scripts.PythonExecutorProperty
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.asJsonNode
import org.onap.ccsdk.apps.controllerblueprints.core.asJsonPrimitive
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
import org.onap.ccsdk.apps.controllerblueprints.core.service.DefaultBluePrintRuntimeService
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
-import org.onap.ccsdk.apps.controllerblueprints.scripts.BluePrintScriptsServiceImpl
import org.springframework.beans.factory.annotation.Autowired
-import org.springframework.test.context.ContextConfiguration
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration
+import org.springframework.context.annotation.ComponentScan
+import org.springframework.test.annotation.DirtiesContext
import org.springframework.test.context.TestPropertySource
import org.springframework.test.context.junit4.SpringRunner
import kotlin.test.assertNotNull
-
@RunWith(SpringRunner::class)
-@ContextConfiguration(classes = [RestconfExecutorConfiguration::class, ComponentRestconfExecutor::class,
- BlueprintJythonService::class, PythonExecutorProperty::class, BluePrintRestLibPropertyService::class,
- BlueprintPropertyConfiguration::class, BluePrintProperties::class, BluePrintScriptsServiceImpl::class,
- ResourceResolutionServiceImpl::class, ComponentFunctionScriptingService::class])
+@EnableAutoConfiguration
+@ComponentScan(basePackages = ["org.onap.ccsdk.apps.blueprintsprocessor", "org.onap.ccsdk.apps.controllerblueprints"])
+@DirtiesContext
@TestPropertySource(properties =
["server.port=9111",
"blueprintsprocessor.restconfEnabled=true",
"blueprintsprocessor.restclient.odlPrimary.type=basic-auth",
"blueprintsprocessor.restclient.odlPrimary.url=http://127.0.0.1:9111",
"blueprintsprocessor.restclient.odlPrimary.userId=sampleuser",
- "blueprintsprocessor.restclient.odlPrimary.token=sampletoken"])
+ "blueprintsprocessor.restclient.odlPrimary.token=sampletoken"],
+ locations = ["classpath:application-test.properties"])
class ComponentRestconfExecutorTest {
@Autowired
@@ -85,7 +78,8 @@ class ComponentRestconfExecutorTest {
operationInputs[BluePrintConstants.PROPERTY_CURRENT_INTERFACE] = "interfaceName".asJsonPrimitive()
operationInputs[BluePrintConstants.PROPERTY_CURRENT_OPERATION] = "operationName".asJsonPrimitive()
operationInputs[ComponentRestconfExecutor.SCRIPT_TYPE] = BluePrintConstants.SCRIPT_INTERNAL.asJsonPrimitive()
- operationInputs[ComponentRestconfExecutor.SCRIPT_CLASS_REFERENCE] = "InternalSimpleRestconf_cba\$TestRestconfConfigure".asJsonPrimitive()
+ operationInputs[ComponentRestconfExecutor.SCRIPT_CLASS_REFERENCE] =
+ "InternalSimpleRestconf_cba\$TestRestconfConfigure".asJsonPrimitive()
operationInputs[ComponentRestconfExecutor.INSTANCE_DEPENDENCIES] = JacksonUtils.jsonNode("[]") as ArrayNode
val blueprintContext = mockk<BluePrintContext>()
@@ -93,13 +87,13 @@ class ComponentRestconfExecutorTest {
every { bluePrintRuntime.get("sample-step-step-inputs") } returns operationInputs.asJsonNode()
every {
bluePrintRuntime.resolveNodeTemplateInterfaceOperationInputs("activate-restconf",
- "interfaceName", "operationName")
+ "interfaceName", "operationName")
} returns operationInputs
val operationOutputs = hashMapOf<String, JsonNode>()
every {
bluePrintRuntime.resolveNodeTemplateInterfaceOperationOutputs("activate-restconf",
- "interfaceName", "operationName")
+ "interfaceName", "operationName")
} returns operationOutputs
every { bluePrintRuntime.put("sample-step-step-outputs", any()) } returns Unit
diff --git a/ms/blueprintsprocessor/functions/restconf-executor/src/test/resources/application-test.properties b/ms/blueprintsprocessor/functions/restconf-executor/src/test/resources/application-test.properties
new file mode 100644
index 00000000..6d8b62ff
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/restconf-executor/src/test/resources/application-test.properties
@@ -0,0 +1,32 @@
+#
+# Copyright © 2017-2018 AT&T Intellectual Property.
+#
+# Modifications Copyright © 2019 IBM, Bell Canada.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+blueprintsprocessor.db.primary.url=jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1
+blueprintsprocessor.db.primary.username=sa
+blueprintsprocessor.db.primary.password=
+blueprintsprocessor.db.primary.driverClassName=org.h2.Driver
+blueprintsprocessor.db.primary.hibernateHbm2ddlAuto=create-drop
+blueprintsprocessor.db.primary.hibernateDDLAuto=update
+blueprintsprocessor.db.primary.hibernateNamingStrategy=org.hibernate.cfg.ImprovedNamingStrategy
+blueprintsprocessor.db.primary.hibernateDialect=org.hibernate.dialect.H2Dialect
+# Controller Blueprints Core Configuration
+blueprintsprocessor.blueprintDeployPath=./target/blueprints/deploy
+blueprintsprocessor.blueprintArchivePath=./target/blueprints/archive
+
+# Python executor
+blueprints.processor.functions.python.executor.executionPath=./../../../../components/scripts/python/ccsdk_blueprints
+blueprints.processor.functions.python.executor.modulePaths=./../../../../components/scripts/python/ccsdk_blueprints
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BluePrintDBLibConfiguration.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BluePrintDBLibConfiguration.kt
index 0bdee9be..276ece13 100644
--- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BluePrintDBLibConfiguration.kt
+++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BluePrintDBLibConfiguration.kt
@@ -37,5 +37,19 @@ open class BluePrintDBLibConfiguration(private var bluePrintProperties: BluePrin
class DBLibConstants {
companion object {
const val PREFIX_DB_PRIMARY: String = "blueprintsprocessor.db.primary"
+
+ //list of database
+ const val MARIA_DB: String = "maria-db"
+ const val MYSQL_DB: String = "mysql-db"
+ const val ORACLE_DB: String = "oracle-db"
+ const val POSTGRES_DB: String = "postgres-db"
+
+ //List of database drivers
+ const val DRIVER_MARIA_DB = "org.mariadb.jdbc.Driver"
+ const val DRIVER_MYSQL_DB = "com.mysql.jdbc.Driver"
+ const val DRIVER_ORACLE_DB = "oracle.jdbc.driver.OracleDriver"
+ const val DRIVER_POSTGRES_DB = "org.postgresql.Driver"
+
+
}
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/DBLibGenericService.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/DBLibGenericService.kt
new file mode 100644
index 00000000..af7ab054
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/DBLibGenericService.kt
@@ -0,0 +1,72 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.db.primary
+
+import com.fasterxml.jackson.databind.JsonNode
+import org.onap.ccsdk.apps.blueprintsprocessor.db.AbstractDBLibGenericService
+import org.onap.ccsdk.apps.blueprintsprocessor.db.DBLibConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import org.springframework.boot.jdbc.DataSourceBuilder
+import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate
+import org.springframework.stereotype.Service
+
+@Service
+open class DBLibGenericService(primaryNamedParameterJdbcTemplate: NamedParameterJdbcTemplate)
+ : AbstractDBLibGenericService(primaryNamedParameterJdbcTemplate) {
+
+ fun primaryJdbcTemplate():NamedParameterJdbcTemplate{
+ return namedParameterJdbcTemplate()
+ }
+
+ fun remoteJdbcTemplate(jsonNode: JsonNode): NamedParameterJdbcTemplate {
+ val type = jsonNode.get("type").textValue()
+ val driverDB: String
+
+ return when (type) {
+ DBLibConstants.MARIA_DB -> {
+ driverDB = DBLibConstants.DRIVER_MARIA_DB
+ jdbcTemplate(jsonNode, driverDB)
+ }
+ DBLibConstants.MYSQL_DB -> {
+ driverDB = DBLibConstants.DRIVER_MYSQL_DB
+ jdbcTemplate(jsonNode, driverDB)
+ }
+ DBLibConstants.ORACLE_DB -> {
+ driverDB = DBLibConstants.DRIVER_ORACLE_DB
+ jdbcTemplate(jsonNode, driverDB)
+ }
+ DBLibConstants.POSTGRES_DB -> {
+ driverDB = DBLibConstants.DRIVER_POSTGRES_DB
+ jdbcTemplate(jsonNode, driverDB)
+ }
+ else -> {
+ throw BluePrintProcessorException("Rest adaptor($type) is not supported")
+ }
+ }
+ }
+
+ fun jdbcTemplate(jsonNode: JsonNode, driver: String): NamedParameterJdbcTemplate {
+ val dataSourceBuilder = DataSourceBuilder
+ .create()
+ .username(jsonNode.get("username").textValue())
+ .password(jsonNode.get("password").textValue())
+ .url(jsonNode.get("url").textValue())
+ .driverClassName(driver)
+ .build()
+ return NamedParameterJdbcTemplate(dataSourceBuilder)
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/PrimaryDBLibGenericService.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/PrimaryDBLibGenericService.kt
deleted file mode 100644
index 0e0f1e9c..00000000
--- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/PrimaryDBLibGenericService.kt
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.apps.blueprintsprocessor.db.primary
-
-import org.onap.ccsdk.apps.blueprintsprocessor.db.AbstractDBLibGenericService
-import org.onap.ccsdk.apps.blueprintsprocessor.db.BluePrintDBLibGenericService
-import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate
-import org.springframework.stereotype.Service
-
-@Service
-open class PrimaryDBLibGenericService(private val primaryNamedParameterJdbcTemplate: NamedParameterJdbcTemplate)
- : AbstractDBLibGenericService(primaryNamedParameterJdbcTemplate) {
-
-} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/PrimaryDatabaseConfiguration.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/PrimaryDatabaseConfiguration.kt
index 98b6221d..4039b053 100644
--- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/PrimaryDatabaseConfiguration.kt
+++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/PrimaryDatabaseConfiguration.kt
@@ -33,9 +33,9 @@ import javax.sql.DataSource
@Configuration
@EnableJpaRepositories(
- basePackages = ["org.onap.ccsdk.apps.blueprintsprocessor.db.primary"],
- entityManagerFactoryRef = "primaryEntityManager",
- transactionManagerRef = "primaryTransactionManager"
+ basePackages = ["org.onap.ccsdk.apps.blueprintsprocessor.*"],
+ entityManagerFactoryRef = "primaryEntityManager",
+ transactionManagerRef = "primaryTransactionManager"
)
open class PrimaryDatabaseConfiguration(private val primaryDataSourceProperties: PrimaryDataSourceProperties) {
val log = LoggerFactory.getLogger(PrimaryDatabaseConfiguration::class.java)!!
@@ -45,10 +45,8 @@ open class PrimaryDatabaseConfiguration(private val primaryDataSourceProperties:
open fun primaryEntityManager(): LocalContainerEntityManagerFactoryBean {
val em = LocalContainerEntityManagerFactoryBean()
em.dataSource = primaryDataSource()
- em.setPackagesToScan("org.onap.ccsdk.apps.blueprintsprocessor.db.primary")
-
- val vendorAdapter = HibernateJpaVendorAdapter()
- em.jpaVendorAdapter = vendorAdapter
+ em.setPackagesToScan("org.onap.ccsdk.apps.blueprintsprocessor.*")
+ em.jpaVendorAdapter = HibernateJpaVendorAdapter()
val properties = HashMap<String, Any>()
properties["hibernate.hbm2ddl.auto"] = primaryDataSourceProperties.hibernateHbm2ddlAuto
properties["hibernate.dialect"] = primaryDataSourceProperties.hibernateDialect
diff --git a/ms/blueprintsprocessor/modules/inbounds/pom.xml b/ms/blueprintsprocessor/modules/inbounds/pom.xml
index 1384b8a1..d7c0cc4f 100644
--- a/ms/blueprintsprocessor/modules/inbounds/pom.xml
+++ b/ms/blueprintsprocessor/modules/inbounds/pom.xml
@@ -45,6 +45,17 @@
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
+ <!-- Test Dependencies -->
+ <dependency>
+ <groupId>io.mockk</groupId>
+ <artifactId>mockk</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-api-mockito2</artifactId>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
@@ -55,8 +66,14 @@
<artifactId>kotlin-test-junit</artifactId>
</dependency>
<dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-api-mockito2</artifactId>
+ <groupId>org.jetbrains.kotlinx</groupId>
+ <artifactId>kotlinx-coroutines-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>io.projectreactor</groupId>
+ <artifactId>reactor-test</artifactId>
+ <scope>test</scope>
</dependency>
</dependencies>
</project>
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/validation/BluePrintDesignTimeRuntimeValidatorService.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/validation/BluePrintRuntimeValidatorService.kt
index 08d2c3b5..100bd320 100644
--- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/validation/BluePrintDesignTimeRuntimeValidatorService.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/validation/BluePrintRuntimeValidatorService.kt
@@ -16,23 +16,12 @@
package org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api.validation
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
-import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
import org.onap.ccsdk.apps.controllerblueprints.validation.BluePrintDesignTimeValidatorService
+import org.onap.ccsdk.apps.controllerblueprints.validation.extension.ResourceDefinitionValidator
import org.springframework.stereotype.Service
@Service
-open class BluePrintRuntimeValidatorService(
- private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintDesignTimeValidatorService(bluePrintTypeValidatorService) {
-
- override fun validateBluePrints(bluePrintRuntimeService: BluePrintRuntimeService<*>): Boolean {
-
- bluePrintTypeValidatorService.validateServiceTemplate(bluePrintRuntimeService, "service_template",
- bluePrintRuntimeService.bluePrintContext().serviceTemplate)
- if (bluePrintRuntimeService.getBluePrintError().errors.size > 0) {
- throw BluePrintException("failed in blueprint validation : ${bluePrintRuntimeService.getBluePrintError().errors.joinToString("\n")}")
- }
- return true
- }
-} \ No newline at end of file
+open class BluePrintRuntimeValidatorService(bluePrintTypeValidatorService: BluePrintTypeValidatorService,
+ resourceDefinitionValidator: ResourceDefinitionValidator)
+ : BluePrintDesignTimeValidatorService(bluePrintTypeValidatorService, resourceDefinitionValidator)
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/mock/Mock.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/mock/Mock.kt
index c54e6176..19c624bc 100644
--- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/mock/Mock.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/mock/Mock.kt
@@ -15,7 +15,9 @@
*/
package org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api.mock
+import io.mockk.mockk
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor.ResourceAssignmentProcessor
import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction
import org.onap.ccsdk.apps.controllerblueprints.core.asJsonPrimitive
import org.slf4j.LoggerFactory
@@ -45,4 +47,16 @@ class MockComponentFunction : AbstractComponentFunction() {
override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
log.info("Recovering component..")
}
+}
+
+open class MockResourceSource {
+ @Bean(name = [
+ "rr-processor-source-input",
+ "rr-processor-source-default",
+ "rr-processor-source-primary-db",
+ "rr-processor-source-rest"])
+ open fun sourceInstance(): ResourceAssignmentProcessor {
+ return mockk<ResourceAssignmentProcessor>()
+ }
+
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/validation/BluePrintRuntimeValidatorServiceTest.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/validation/BluePrintRuntimeValidatorServiceTest.kt
new file mode 100644
index 00000000..1cafead7
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/validation/BluePrintRuntimeValidatorServiceTest.kt
@@ -0,0 +1,44 @@
+/*
+ * Copyright © 2019 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.blueprintsprocessor.selfservice.api.validation
+
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api.mock.MockResourceSource
+import org.onap.ccsdk.apps.controllerblueprints.validation.BluePrintValidationConfiguration
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.test.context.ContextConfiguration
+import org.springframework.test.context.junit4.SpringRunner
+import kotlin.test.assertNotNull
+
+@RunWith(SpringRunner::class)
+@ContextConfiguration(classes = [BluePrintRuntimeValidatorService::class,
+ BluePrintValidationConfiguration::class, MockResourceSource::class])
+class BluePrintRuntimeValidatorServiceTest {
+
+ @Autowired
+ lateinit var bluePrintRuntimeValidatorService: BluePrintRuntimeValidatorService
+
+ @Test
+ fun testBlueprintRuntimeValidation() {
+ val blueprintBasePath = "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ assertNotNull(bluePrintRuntimeValidatorService, " failed to initilize bluePrintRuntimeValidatorService")
+
+ bluePrintRuntimeValidatorService.validateBluePrints(blueprintBasePath)
+
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/parent/pom.xml b/ms/blueprintsprocessor/parent/pom.xml
index cad5a4b3..045ce711 100755
--- a/ms/blueprintsprocessor/parent/pom.xml
+++ b/ms/blueprintsprocessor/parent/pom.xml
@@ -32,10 +32,10 @@
<description>Blueprints Processor Parent</description>
<properties>
<kotlin.compiler.jvmTarget>1.8</kotlin.compiler.jvmTarget>
- <spring.boot.version>2.1.2.RELEASE</spring.boot.version>
- <spring.version>5.1.4.RELEASE</spring.version>
- <kotlin.version>1.3.20</kotlin.version>
- <kotlin.maven.version>1.3.20</kotlin.maven.version>
+ <spring.boot.version>2.1.3.RELEASE</spring.boot.version>
+ <spring.version>5.1.5.RELEASE</spring.version>
+ <kotlin.version>1.3.21</kotlin.version>
+ <kotlin.maven.version>1.3.21</kotlin.maven.version>
<kotlin.couroutines.version>1.1.1</kotlin.couroutines.version>
<grpc.version>1.18.0</grpc.version>
<protobuff.java.utils.version>3.6.1</protobuff.java.utils.version>
diff --git a/ms/cds-sdc-listener/application/pom.xml b/ms/cds-sdc-listener/application/pom.xml
new file mode 100644
index 00000000..a5e6f1e5
--- /dev/null
+++ b/ms/cds-sdc-listener/application/pom.xml
@@ -0,0 +1,58 @@
+<!--
+ ~ Copyright (C) 2019 Bell Canada. All rights reserved.
+ ~
+ ~ NOTICE: All the intellectual and technical concepts contained herein are
+ ~ proprietary to Bell Canada and are protected by trade secret or copyright law.
+ ~ Unauthorized copying of this file, via any medium is strictly prohibited.
+ -->
+<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>
+ <groupId>org.onap.ccsdk.parent</groupId>
+ <artifactId>spring-boot-1-starter-parent</artifactId>
+ <version>1.2.1-SNAPSHOT</version>
+ <relativePath />
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>application</artifactId>
+ <name>CDS-SDC Listener Application </name>
+
+ <dependencies>
+ <!-- Spring boot -->
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-web</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-devtools</artifactId>
+ <optional>true</optional>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>repackage</id>
+ <goals>
+ <goal>repackage</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerApplication.java b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerApplication.java
new file mode 100644
index 00000000..661f8cb5
--- /dev/null
+++ b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerApplication.java
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2019 Bell Canada. All rights reserved.
+ *
+ * NOTICE: All the intellectual and technical concepts contained herein are
+ * proprietary to Bell Canada and are protected by trade secret or copyright law.
+ * Unauthorized copying of this file, via any medium is strictly prohibited.
+ */
+
+package org.onap.ccsdk.apps.cdssdclistener;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class CdsSdcListenerApplication {
+ public static void main(String[] args) {
+ SpringApplication.run(CdsSdcListenerApplication.class, args);
+ }
+}
diff --git a/ms/cds-sdc-listener/distribution/pom.xml b/ms/cds-sdc-listener/distribution/pom.xml
new file mode 100644
index 00000000..9ff555fc
--- /dev/null
+++ b/ms/cds-sdc-listener/distribution/pom.xml
@@ -0,0 +1,106 @@
+<!--
+ ~ Copyright (C) 2019 Bell Canada. All rights reserved.
+ ~
+ ~ NOTICE: All the intellectual and technical concepts contained herein are
+ ~ proprietary to Bell Canada and are protected by trade secret or copyright law.
+ ~ Unauthorized copying of this file, via any medium is strictly prohibited.
+ -->
+<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>cds-sdc-listener</artifactId>
+ <groupId>org.onap.ccsdk.apps</groupId>
+ <version>0.4.1-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>distribution</artifactId>
+ <name>CDS-SDC Listener Distribution</name>
+
+ <properties>
+ <image.name>onap/ccsdk-cdssdclistener</image.name>
+ <docker.push.phase>deploy</docker.push.phase>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-resources-plugin</artifactId>
+ <version>2.6</version>
+ <executions>
+ <execution>
+ <id>copy-dockerfile</id>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <phase>validate</phase>
+ <configuration>
+ <outputDirectory>${basedir}/target/docker-stage</outputDirectory>
+ <resources>
+ <resource>
+ <directory>src/main/docker</directory>
+ <includes>
+ <include>*</include>
+ </includes>
+ <filtering>true</filtering>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>docker</id>
+ <build>
+ <plugins>
+ <plugin>
+ <!-- Maven plugin for managing docker images and containers -->
+ <groupId>io.fabric8</groupId>
+ <artifactId>docker-maven-plugin</artifactId>
+ <version>0.26.1</version>
+ <inherited>false</inherited>
+ <configuration>
+ <images>
+ <image>
+ <name>${image.name}</name>
+ <build>
+ <cleanup>try</cleanup>
+ <dockerFileDir>${basedir}/target/docker-stage</dockerFileDir>
+ <imagetags>
+ <imageTag>${project.version}</imageTag>
+ <imageTag>${project.version}-STAGING-${maven.build.timestamp}</imageTag>
+ </imagetags>
+ </build>
+ </image>
+ </images>
+ <verbose>true</verbose>
+ </configuration>
+ <executions>
+ <execution>
+ <id>generate-images</id>
+ <phase>package</phase>
+ <goals>
+ <goal>build</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>push-images</id>
+ <phase>${docker.push.phase}</phase>
+ <goals>
+ <goal>build</goal>
+ <goal>push</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+</project> \ No newline at end of file
diff --git a/ms/cds-sdc-listener/pom.xml b/ms/cds-sdc-listener/pom.xml
new file mode 100644
index 00000000..3998f5f2
--- /dev/null
+++ b/ms/cds-sdc-listener/pom.xml
@@ -0,0 +1,28 @@
+<!--
+ ~ Copyright (C) 2019 Bell Canada. All rights reserved.
+ ~
+ ~ NOTICE: All the intellectual and technical concepts contained herein are
+ ~ proprietary to Bell Canada and are protected by trade secret or copyright law.
+ ~ Unauthorized copying of this file, via any medium is strictly prohibited.
+ -->
+<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>ccsdk-apps-ms</artifactId>
+ <groupId>org.onap.ccsdk.apps</groupId>
+ <version>0.4.1-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>cds-sdc-listener</artifactId>
+ <name>CDS-SDC Listener Root</name>
+ <description>A microservice to get the cba file from SDC and store it into database at runtime</description>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>application</module>
+ <module>distribution</module>
+ </modules>
+
+</project> \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt
index b2f1b727..cf400fa7 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt
@@ -98,16 +98,9 @@ object BluePrintTypes {
@JvmStatic
fun validPropertyTypes(): List<String> {
val validTypes: MutableList<String> = arrayListOf()
- validTypes.add(BluePrintConstants.DATA_TYPE_STRING)
- validTypes.add(BluePrintConstants.DATA_TYPE_INTEGER)
- validTypes.add(BluePrintConstants.DATA_TYPE_FLOAT)
- validTypes.add(BluePrintConstants.DATA_TYPE_DOUBLE)
- validTypes.add(BluePrintConstants.DATA_TYPE_BOOLEAN)
- validTypes.add(BluePrintConstants.DATA_TYPE_TIMESTAMP)
- validTypes.add(BluePrintConstants.DATA_TYPE_NULL)
- validTypes.add(BluePrintConstants.DATA_TYPE_LIST)
- validTypes.add(BluePrintConstants.DATA_TYPE_MAP)
- validTypes.add(BluePrintConstants.DATA_TYPE_JSON)
+ validTypes.addAll(validPrimitiveTypes())
+ validTypes.addAll(validComplexTypes())
+ validTypes.addAll(validCollectionTypes())
return validTypes
}
@@ -125,6 +118,13 @@ object BluePrintTypes {
}
@JvmStatic
+ fun validComplexTypes(): List<String> {
+ val validTypes: MutableList<String> = arrayListOf()
+ validTypes.add(BluePrintConstants.DATA_TYPE_JSON)
+ return validTypes
+ }
+
+ @JvmStatic
fun validCollectionTypes(): List<String> {
val validTypes: MutableList<String> = arrayListOf()
validTypes.add(BluePrintConstants.DATA_TYPE_LIST)
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/factory/BluePrintValidatorFactory.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/factory/BluePrintValidatorFactory.kt
deleted file mode 100644
index 687b86cd..00000000
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/factory/BluePrintValidatorFactory.kt
+++ /dev/null
@@ -1,45 +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.core.factory
-
-
-import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintValidatorDefaultService
-import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintValidatorService
-
-/**
- *
- *
- * @author Brinda Santh
- */
-
-object BluePrintValidatorFactory {
-
- var bluePrintValidatorServices: MutableMap<String, BluePrintValidatorService> = HashMap()
-
- init {
- bluePrintValidatorServices[org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants.TYPE_DEFAULT] = BluePrintValidatorDefaultService()
- }
-
- fun register(key:String, bluePrintValidatorService: BluePrintValidatorService){
- bluePrintValidatorServices[key] = bluePrintValidatorService
- }
-
- fun instance(key : String) : BluePrintValidatorService?{
- return bluePrintValidatorServices[key]
- }
-
-} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt
index 80ad3f2a..c5828073 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt
@@ -29,7 +29,6 @@ import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactDefinition
import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate
import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition
import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import java.io.File
interface BluePrintRuntimeService<T> {
@@ -234,7 +233,7 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
} else {
// Assign default value to the Operation
nodeTypeProperty.defaultValue?.let {
- resolvedValue = JacksonUtils.jsonNodeFromObject(nodeTypeProperty.defaultValue!!)
+ resolvedValue = nodeTypeProperty.defaultValue!!
}
}
// Set for Return of method
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt
index 9ee53146..06602a17 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt
@@ -41,6 +41,7 @@ interface BluePrintValidatorService : Serializable {
fun validateBlueprint(serviceTemplate: ServiceTemplate, properties: MutableMap<String, Any>)
}
+@Deprecated("Decomposed implementation moved to blueprint-validation module")
open class BluePrintValidatorDefaultService : BluePrintValidatorService {
val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintValidatorDefaultService::class.toString())
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt
index fa5e1647..c34a769e 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt
@@ -97,12 +97,9 @@ class BluePrintMetadataUtils {
val bluePrintContext: BluePrintContext = getBluePrintContext(blueprintBasePath)
- val context: MutableMap<String, JsonNode> = hashMapOf()
- context[BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] = blueprintBasePath.asJsonPrimitive()
- context[BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID] = id.asJsonPrimitive()
-
val bluePrintRuntimeService = DefaultBluePrintRuntimeService(id, bluePrintContext)
- bluePrintRuntimeService.setExecutionContext(context)
+ bluePrintRuntimeService.put(BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH, blueprintBasePath.asJsonPrimitive())
+ bluePrintRuntimeService.put(BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID, id.asJsonPrimitive())
return bluePrintRuntimeService
}
@@ -110,12 +107,10 @@ class BluePrintMetadataUtils {
fun getBaseEnhancementBluePrintRuntime(id: String, blueprintBasePath: String): BluePrintRuntimeService<MutableMap<String, JsonNode>> {
val bluePrintContext: BluePrintContext = getBaseEnhancementBluePrintContext(blueprintBasePath)
- val context: MutableMap<String, JsonNode> = hashMapOf()
- context[BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH] = blueprintBasePath.asJsonPrimitive()
- context[BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID] = id.asJsonPrimitive()
val bluePrintRuntimeService = DefaultBluePrintRuntimeService(id, bluePrintContext)
- bluePrintRuntimeService.setExecutionContext(context)
+ bluePrintRuntimeService.put(BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH, blueprintBasePath.asJsonPrimitive())
+ bluePrintRuntimeService.put(BluePrintConstants.PROPERTY_BLUEPRINT_PROCESS_ID, id.asJsonPrimitive())
return bluePrintRuntimeService
}
@@ -123,6 +118,10 @@ class BluePrintMetadataUtils {
fun getBluePrintRuntime(id: String, blueprintBasePath: String, executionContext: MutableMap<String, JsonNode>): BluePrintRuntimeService<MutableMap<String, JsonNode>> {
val bluePrintContext: BluePrintContext = getBluePrintContext(blueprintBasePath)
val bluePrintRuntimeService = DefaultBluePrintRuntimeService(id, bluePrintContext)
+ executionContext.forEach{
+ bluePrintRuntimeService.put(it.key,it.value)
+ }
+
bluePrintRuntimeService.setExecutionContext(executionContext)
return bluePrintRuntimeService
}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt
index 1bc25005..932f0edc 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt
@@ -68,12 +68,14 @@ class JacksonUtils {
}
}
- fun getContent(fileName: String): String = runBlocking {
+ fun getContent(fileName: String): String = getContent(File(fileName))
+
+ fun getContent(file: File): String = runBlocking {
async {
try {
- File(fileName).readText(Charsets.UTF_8)
+ file.readText(Charsets.UTF_8)
} catch (e: Exception) {
- throw BluePrintException("couldn't get file ($fileName) content : ${e.message}")
+ throw BluePrintException("couldn't get file (${file.absolutePath}) content : ${e.message}")
}
}.await()
}
@@ -167,17 +169,19 @@ class JacksonUtils {
return getListFromJson(content, valueType)
}
- fun <T> getMapFromJson(content: String, valueType: Class<T>): MutableMap<String, T>? {
+ fun <T> getMapFromJson(content: String, valueType: Class<T>): MutableMap<String, T> {
val objectMapper = jacksonObjectMapper()
val mapType = objectMapper.typeFactory.constructMapType(Map::class.java, String::class.java, valueType)
return objectMapper.readValue(content, mapType)
}
- fun <T> getMapFromFile(fileName: String, valueType: Class<T>): MutableMap<String, T>? {
- val content: String = getContent(fileName)
+ fun <T> getMapFromFile(file: File, valueType: Class<T>): MutableMap<String, T> {
+ val content: String = getContent(file)
return getMapFromJson(content, valueType)
}
+ fun <T> getMapFromFile(fileName: String, valueType: Class<T>): MutableMap<String, T> = getMapFromFile(File(fileName), valueType)
+
fun <T> getInstanceFromMap(properties: MutableMap<String, JsonNode>, classType: Class<T>): T {
return readValue(getJson(properties), classType)
?: throw BluePrintProcessorException("failed to transform content ($properties) to type ($classType)")
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorDefaultServiceTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorDefaultServiceTest.kt
deleted file mode 100644
index be360d90..00000000
--- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorDefaultServiceTest.kt
+++ /dev/null
@@ -1,50 +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.core.service
-
-import com.att.eelf.configuration.EELFLogger
-import com.att.eelf.configuration.EELFManager
-import org.junit.Before
-import org.junit.Test
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
-
-/**
- *
- *
- * @author Brinda Santh
- */
-class BluePrintValidatorDefaultServiceTest {
- private val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())
-
- @Before
- fun setUp(): Unit {
-
- }
-
- @Test
- fun testValidateBluePrint() {
-
- val blueprintBasePath: String = ("./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
- val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(blueprintBasePath)
- val properties: MutableMap<String, Any> = hashMapOf()
-
- val validatorService = BluePrintValidatorDefaultService()
- validatorService.validateBlueprint(bluePrintContext.serviceTemplate, properties)
- log.info("Validation Message {}", properties)
- }
-} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintArtifactDefinitionValidatorImpl.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintArtifactDefinitionValidatorImpl.kt
index 8072f283..a3625e40 100644
--- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintArtifactDefinitionValidatorImpl.kt
+++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintArtifactDefinitionValidatorImpl.kt
@@ -49,7 +49,7 @@ open class BluePrintArtifactDefinitionValidatorImpl(
paths.add(name)
val type: String = artifactDefinition.type
- log.info("Validation ArtifactDefinition of type {$type}")
+ log.trace("Validation ArtifactDefinition of type {$type}")
// Check Artifact Type
checkValidArtifactType(name, type)
diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintDesignTimeValidatorService.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintDesignTimeValidatorService.kt
index 84073ff2..c8985774 100644
--- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintDesignTimeValidatorService.kt
+++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintDesignTimeValidatorService.kt
@@ -19,17 +19,25 @@ package org.onap.ccsdk.apps.controllerblueprints.validation
import com.att.eelf.configuration.EELFLogger
import com.att.eelf.configuration.EELFManager
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintValidatorService
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants
+import org.onap.ccsdk.apps.controllerblueprints.validation.extension.ResourceDefinitionValidator
import org.springframework.stereotype.Service
+import java.io.File
import java.util.*
@Service
-open class BluePrintDesignTimeValidatorService(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintValidatorService {
+open class BluePrintDesignTimeValidatorService(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService,
+ private val resourceDefinitionValidator: ResourceDefinitionValidator)
+ : BluePrintValidatorService {
private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintDesignTimeValidatorService::class.toString())
@@ -43,9 +51,32 @@ open class BluePrintDesignTimeValidatorService(private val bluePrintTypeValidato
bluePrintTypeValidatorService.validateServiceTemplate(bluePrintRuntimeService, "service_template",
bluePrintRuntimeService.bluePrintContext().serviceTemplate)
+
+ // Validate Resource Definitions
+ validateResourceDefinitions(bluePrintRuntimeService)
+
if (bluePrintRuntimeService.getBluePrintError().errors.size > 0) {
throw BluePrintException("failed in blueprint validation : ${bluePrintRuntimeService.getBluePrintError().errors.joinToString("\n")}")
}
return true
}
+
+ private fun validateResourceDefinitions(bluePrintRuntimeService: BluePrintRuntimeService<*>) {
+ // Validate Resource Dictionary
+ val blueprintBasePath = bluePrintRuntimeService.bluePrintContext().rootPath
+
+ val resourceDefinitionsPath = blueprintBasePath.plus(File.separator)
+ .plus(BluePrintConstants.TOSCA_DEFINITIONS_DIR).plus(File.separator)
+ .plus("${ResourceDictionaryConstants.PATH_RESOURCE_DEFINITION_TYPE}.json")
+
+ val resourceDefinitionFile = File(resourceDefinitionsPath)
+
+ if (resourceDefinitionFile.exists()) {
+ val resourceDefinitionMap = JacksonUtils.getMapFromFile(resourceDefinitionFile, ResourceDefinition::class.java)
+
+ resourceDefinitionMap?.forEach { resourceDefinitionName, resourceDefinition ->
+ resourceDefinitionValidator.validate(bluePrintRuntimeService, resourceDefinitionName, resourceDefinition)
+ }
+ }
+ }
}
diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintPropertyDefinitionValidatorImpl.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintPropertyDefinitionValidatorImpl.kt
index 7d81ba62..62a82286 100644
--- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintPropertyDefinitionValidatorImpl.kt
+++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintPropertyDefinitionValidatorImpl.kt
@@ -51,6 +51,9 @@ open class BluePrintPropertyDefinitionValidatorImpl(private val bluePrintTypeVal
BluePrintTypes.validPrimitiveTypes().contains(dataType) -> {
// Do Nothing
}
+ BluePrintTypes.validComplexTypes().contains(dataType) -> {
+ // Do Nothing
+ }
BluePrintTypes.validCollectionTypes().contains(dataType) -> {
val entrySchemaType: String = propertyDefinition.entrySchema?.type
?: throw BluePrintException(format("Entry schema for DataType ({}) for the property ({}) not found", dataType, name))
diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintValidationConfiguration.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintValidationConfiguration.kt
new file mode 100644
index 00000000..bad14791
--- /dev/null
+++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintValidationConfiguration.kt
@@ -0,0 +1,24 @@
+/*
+ * Copyright © 2019 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.validation
+
+import org.springframework.context.annotation.ComponentScan
+import org.springframework.context.annotation.Configuration
+
+@Configuration
+@ComponentScan
+open class BluePrintValidationConfiguration \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/extension/ArtifactMappingResourceValidator.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/extension/ArtifactMappingResourceValidator.kt
index 6fe4fa36..002dd9fb 100644
--- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/extension/ArtifactMappingResourceValidator.kt
+++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/extension/ArtifactMappingResourceValidator.kt
@@ -40,7 +40,7 @@ open class ArtifactMappingResourceValidator(private val bluePrintTypeValidatorSe
val bluePrintContext = bluePrintRuntimeService.bluePrintContext()
val file: String = artifactDefinition.file
val completePath = bluePrintContext.rootPath.plus(File.separator).plus(file)
- log.info("Validation artifact-mapping-resource($completePath)")
+ log.trace("Validation artifact-mapping-resource($completePath)")
val resourceAssignment = JacksonUtils.getListFromFile(completePath, ResourceAssignment::class.java)
val resourceAssignmentValidationService = ResourceAssignmentValidationServiceImpl()
resourceAssignmentValidationService.validate(resourceAssignment)
diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/extension/ResourceDefinitionValidation.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/extension/ResourceDefinitionValidation.kt
new file mode 100644
index 00000000..6975ec61
--- /dev/null
+++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/extension/ResourceDefinitionValidation.kt
@@ -0,0 +1,44 @@
+/*
+ * Copyright © 2019 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.validation.extension
+
+import com.att.eelf.configuration.EELFLogger
+import com.att.eelf.configuration.EELFManager
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintValidator
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
+import org.springframework.stereotype.Service
+
+interface ResourceDefinitionValidator : BluePrintValidator<ResourceDefinition>
+
+@Service
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+open class ResourceDefinitionValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : ResourceDefinitionValidator {
+
+ private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceDefinitionValidatorImpl::class.java)
+
+ override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String,
+ resourceDefinition: ResourceDefinition) {
+ log.trace("validating resource definition($name)")
+ resourceDefinition.sources.forEach { name, nodeTemplate ->
+ bluePrintTypeValidatorService.validateNodeTemplate(bluePrintRuntimeService, name, nodeTemplate)
+ }
+ }
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintDesignTimeValidatorServiceTest.kt b/ms/controllerblueprints/modules/blueprint-validation/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintDesignTimeValidatorServiceTest.kt
index 43c3e0e3..3fc918e6 100644
--- a/ms/controllerblueprints/modules/blueprint-validation/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintDesignTimeValidatorServiceTest.kt
+++ b/ms/controllerblueprints/modules/blueprint-validation/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintDesignTimeValidatorServiceTest.kt
@@ -1,5 +1,6 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2019 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,6 +28,7 @@ import org.onap.ccsdk.apps.controllerblueprints.core.data.Workflow
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
import org.onap.ccsdk.apps.controllerblueprints.core.service.DefaultBluePrintRuntimeService
import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
+import org.onap.ccsdk.apps.controllerblueprints.validation.extension.ResourceDefinitionValidator
import kotlin.test.assertEquals
import kotlin.test.assertTrue
@@ -35,11 +37,14 @@ class BluePrintDesignTimeValidatorServiceTest {
private val blueprintBasePath: String = ("./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
private val bluePrintRuntime = BluePrintMetadataUtils.getBluePrintRuntime("1234", blueprintBasePath)
private val mockBluePrintTypeValidatorService = MockBluePrintTypeValidatorService()
- private val defaultBluePrintValidatorService = BluePrintDesignTimeValidatorService(mockBluePrintTypeValidatorService)
+ private val resourceDefinitionValidator = mockk<ResourceDefinitionValidator>()
+ private val defaultBluePrintValidatorService = BluePrintDesignTimeValidatorService(mockBluePrintTypeValidatorService, resourceDefinitionValidator)
private val workflowValidator = BluePrintWorkflowValidatorImpl(mockBluePrintTypeValidatorService)
@Test
fun testValidateOfType() {
+ every { resourceDefinitionValidator.validate(bluePrintRuntime, any(), any()) } returns Unit
+
val valid = defaultBluePrintValidatorService.validateBluePrints(bluePrintRuntime)
assertTrue(valid, "failed in blueprint Validation")
}
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt
index d33a2f04..62ed4047 100644
--- a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceDictionaryConstants.kt
@@ -24,7 +24,7 @@ package org.onap.ccsdk.apps.controllerblueprints.resource.dict
object ResourceDictionaryConstants {
const val SOURCE_INPUT = "input"
const val SOURCE_DEFAULT = "default"
- const val SOURCE_PRIMARY_CONFIG_DATA = "primary-config-data"
+ const val SOURCE_PRIMARY_CONFIG_DATA = "rest"
const val SOURCE_PRIMARY_DB = "primary-db"
const val MODEL_DIR_RESOURCE_DEFINITION: String = "resource_dictionary"
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt
index d71fbbf8..b35bca74 100644
--- a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceAssignmentValidationService.kt
@@ -23,10 +23,8 @@ import org.apache.commons.collections.CollectionUtils
import org.apache.commons.lang3.StringUtils
import org.apache.commons.lang3.text.StrBuilder
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
-import org.onap.ccsdk.apps.controllerblueprints.core.format
import org.onap.ccsdk.apps.controllerblueprints.core.utils.TopologicalSortingUtils
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.factory.ResourceSourceMappingFactory
import java.io.Serializable
/**
@@ -53,7 +51,6 @@ open class ResourceAssignmentValidationServiceImpl : ResourceAssignmentValidatio
override fun validate(resourceAssignments: List<ResourceAssignment>): Boolean {
try {
- validateSources(resourceAssignments)
validateTemplateNDictionaryKeys(resourceAssignments)
validateCyclicDependency(resourceAssignments)
if (StringUtils.isNotBlank(validationMessage)) {
@@ -65,17 +62,6 @@ open class ResourceAssignmentValidationServiceImpl : ResourceAssignmentValidatio
return true
}
- open fun validateSources(resourceAssignments: List<ResourceAssignment>) {
- log.info("validating resource assignment sources")
- // Check the Resource Assignment Source(Dynamic Instance) is valid.
- resourceAssignments.forEach { resourceAssignment ->
- try {
- ResourceSourceMappingFactory.getRegisterSourceMapping(resourceAssignment.dictionarySource!!)
- } catch (e: BluePrintException) {
- validationMessage.appendln(e.message + format(" for resource assignment({})", resourceAssignment.name))
- }
- }
- }
open fun validateTemplateNDictionaryKeys(resourceAssignments: List<ResourceAssignment>) {
@@ -121,7 +107,7 @@ open class ResourceAssignmentValidationServiceImpl : ResourceAssignmentValidatio
resourceAssignmentMap.map { it.value }.map { resourceAssignment ->
if (CollectionUtils.isNotEmpty(resourceAssignment.dependencies)) {
resourceAssignment.dependencies!!.map {
- log.info("Topological Graph link from {} to {}", it, resourceAssignment.name)
+ log.trace("Topological Graph link from {} to {}", it, resourceAssignment.name)
topologySorting.add(resourceAssignmentMap[it]!!, resourceAssignment)
}
} else {
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt
deleted file mode 100644
index 9541a7b8..00000000
--- a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationService.kt
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright © 2018 IBM.
- * Modifications Copyright © 2017-2018 AT&T Intellectual Property.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.apps.controllerblueprints.resource.dict.service
-
-import com.att.eelf.configuration.EELFLogger
-import com.att.eelf.configuration.EELFManager
-import com.fasterxml.jackson.databind.JsonNode
-import com.google.common.base.Preconditions
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes
-import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate
-import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeType
-import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition
-import org.onap.ccsdk.apps.controllerblueprints.core.format
-import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintRepoService
-import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintExpressionService
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition
-import java.io.Serializable
-
-/**
- * ResourceDefinitionValidationService.
- *
- * @author Brinda Santh
- */
-interface ResourceDefinitionValidationService : Serializable {
-
- @Throws(BluePrintException::class)
- fun validate(resourceDefinition: ResourceDefinition)
-
-}
-
-/**
- * ResourceDefinitionValidationService.
- *
- * @author Brinda Santh
- */
-open class ResourceDefinitionValidationServiceImpl(private val bluePrintRepoService: BluePrintRepoService) : ResourceDefinitionValidationService {
-
- private val log: EELFLogger = EELFManager.getInstance().getLogger(ResourceDefinitionValidationService::class.java)
-
- override fun validate(resourceDefinition: ResourceDefinition) {
- Preconditions.checkNotNull(resourceDefinition, "Failed to get Resource Definition")
- log.trace("Validating Resource Dictionary Definition {}", resourceDefinition.name)
-
- resourceDefinition.sources.forEach { name, nodeTemplate ->
- val sourceType = nodeTemplate.type
-
- val sourceNodeType = bluePrintRepoService.getNodeType(sourceType)
-
- // Validate Property Name, expression, values and Data Type
- validateNodeTemplateProperties(nodeTemplate, sourceNodeType)
- }
- }
-
-
- open fun validateNodeTemplateProperties(nodeTemplate: NodeTemplate, nodeType: NodeType) {
- nodeTemplate.properties?.let { validatePropertyAssignments(nodeType.properties!!, nodeTemplate.properties!!) }
- }
-
-
- open fun validatePropertyAssignments(nodeTypeProperties: MutableMap<String, PropertyDefinition>,
- properties: MutableMap<String, JsonNode>) {
- properties.forEach { propertyName, propertyAssignment ->
- val propertyDefinition: PropertyDefinition = nodeTypeProperties[propertyName]
- ?: throw BluePrintException(format("failed to get definition for the property ({})", propertyName))
- // Check and Validate if Expression Node
- val expressionData = BluePrintExpressionService.getExpressionData(propertyAssignment)
- if (!expressionData.isExpression) {
- checkPropertyValue(propertyDefinition, propertyName, propertyAssignment)
- } else {
- throw BluePrintException(format("property({}) of expression ({}) is not supported",
- propertyName, propertyAssignment))
- }
- }
- }
-
- open fun checkPropertyValue(propertyDefinition: PropertyDefinition, propertyName: String, propertyAssignment: JsonNode) {
- val propertyType = propertyDefinition.type
- val isValid: Boolean
-
- if (BluePrintTypes.validPrimitiveTypes().contains(propertyType)) {
- isValid = JacksonUtils.checkJsonNodeValueOfPrimitiveType(propertyType, propertyAssignment)
-
- } else if (BluePrintTypes.validCollectionTypes().contains(propertyType)) {
-
- isValid = JacksonUtils.checkJsonNodeValueOfCollectionType(propertyType, propertyAssignment)
- } else {
- bluePrintRepoService.getDataType(propertyType)
- isValid = true
- }
-
- check(isValid) {
- throw BluePrintException(format("property({}) defined of type({}) is not compatable with the value ({})",
- propertyName, propertyType, propertyAssignment))
- }
- }
-} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt
index 1aeda0ba..69ee1cfd 100644
--- a/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt
+++ b/ms/controllerblueprints/modules/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceDictionaryUtils.kt
@@ -85,6 +85,12 @@ object ResourceDictionaryUtils {
?: throw BluePrintProcessorException("couldn't get ResourceAssignment definitions for the file($filePath)")
}
+ fun writeResourceDefinitionTypes(basePath: String, resourceDefinitions: List<ResourceDefinition>) {
+ val resourceDefinitionMap = resourceDefinitions.map { it.name to it }.toMap()
+ writeResourceDefinitionTypes(basePath, resourceDefinitionMap)
+
+ }
+
fun writeResourceDefinitionTypes(basePath: String, resourceDefinitionMap: Map<String, ResourceDefinition>) {
val typePath = basePath.plus(File.separator).plus(BluePrintConstants.TOSCA_DEFINITIONS_DIR)
.plus(File.separator).plus("${ResourceDictionaryConstants.PATH_RESOURCE_DEFINITION_TYPE}.json")
diff --git a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationServiceTest.java b/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationServiceTest.java
deleted file mode 100644
index 7f040b2e..00000000
--- a/ms/controllerblueprints/modules/resource-dict/src/test/java/org/onap/ccsdk/apps/controllerblueprints/resource/dict/service/ResourceDefinitionValidationServiceTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright © 2018 IBM.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.apps.controllerblueprints.resource.dict.service;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRepoFileService;
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition;
-
-public class ResourceDefinitionValidationServiceTest {
- private String basePath = "load/model_type";
- private String dictionaryPath = "load/resource_dictionary";
- private BluePrintRepoFileService bluePrintRepoFileService = new BluePrintRepoFileService(basePath);
-
- @Test
- public void testValidateSource() throws Exception {
-
- String inputFileName = dictionaryPath + "/input-source.json";
- testValidate(inputFileName);
-
- String dbFileName = dictionaryPath + "/primary-db-source.json";
- testValidate(dbFileName);
-
- String defaultFileName = dictionaryPath + "/default-source.json";
- testValidate(defaultFileName);
-
- String restFileName = dictionaryPath + "/mdsal-source.json";
- testValidate(restFileName);
- }
-
- private void testValidate(String fileName) throws Exception {
-
- ResourceDefinition resourceDefinition = JacksonUtils.Companion.readValueFromFile(fileName, ResourceDefinition.class);
- Assert.assertNotNull("Failed to populate dictionaryDefinition for type", resourceDefinition);
-
- ResourceDefinitionValidationService resourceDictionaryValidationService =
- new ResourceDefinitionValidationServiceImpl(bluePrintRepoFileService);
- resourceDictionaryValidationService.validate(resourceDefinition);
- Assert.assertNotNull(String.format("Failed to populate dictionaryDefinition for : %s", fileName), resourceDefinition);
- }
-}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ResourceDictionaryValidator.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ResourceDictionaryValidator.java
deleted file mode 100644
index 57330d90..00000000
--- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ResourceDictionaryValidator.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.apps.controllerblueprints.service.validator;
-
-import com.google.common.base.Preconditions;
-import org.apache.commons.lang3.StringUtils;
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary;
-
-/**
- * ResourceDictionaryValidator.java Purpose: Provide Validation Service for Model Type Resource
- * Dictionary Validator
- *
- * @author Brinda Santh
- * @version 1.0
- */
-public class ResourceDictionaryValidator {
-
- private ResourceDictionaryValidator() {}
-
- /**
- * This is a validateResourceDictionary method
- *
- * @param resourceDictionary
- * @return boolean
- *
- */
- public static boolean validateResourceDictionary(ResourceDictionary resourceDictionary) {
-
- Preconditions.checkNotNull(resourceDictionary,"ResourceDictionary Information is missing." );
-
- Preconditions.checkArgument( StringUtils.isNotBlank(resourceDictionary.getName()),
- "DataDictionary Alias Name Information is missing.");
- Preconditions.checkNotNull( resourceDictionary.getDefinition(),
- "DataDictionary Definition Information is missing.");
- Preconditions.checkArgument( StringUtils.isNotBlank(resourceDictionary.getDescription()),
- "DataDictionary Description Information is missing.");
- Preconditions.checkArgument( StringUtils.isNotBlank(resourceDictionary.getTags()),
- "DataDictionary Tags Information is missing.");
- Preconditions.checkArgument( StringUtils.isNotBlank(resourceDictionary.getUpdatedBy()),
- "DataDictionary Updated By Information is missing.");
- return true;
-
- }
-
-}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidator.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidator.java
deleted file mode 100644
index 5d15e087..00000000
--- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/validator/ServiceTemplateValidator.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onap.ccsdk.apps.controllerblueprints.service.validator;
-
-import com.google.common.base.Preconditions;
-import org.apache.commons.collections.MapUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.jetbrains.annotations.NotNull;
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants;
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
-import org.onap.ccsdk.apps.controllerblueprints.core.ConfigModelConstant;
-import org.onap.ccsdk.apps.controllerblueprints.core.data.CapabilityAssignment;
-import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate;
-import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;
-import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintValidatorDefaultService;
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceAssignmentValidationService;
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceAssignmentValidationServiceImpl;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * ServiceTemplateValidator.java Purpose: Provide Configuration Generator ServiceTemplateValidator
- *
- * @author Brinda Santh
- * @version 1.0
- */
-
-public class ServiceTemplateValidator extends BluePrintValidatorDefaultService {
-
- StringBuilder message = new StringBuilder();
- private Map<String, String> metaData = new HashMap<>();
-
- /**
- * This is a validateServiceTemplate
- *
- * @param serviceTemplateContent serviceTemplateContent
- * @return boolean
- * @throws BluePrintException BluePrintException
- */
- public boolean validateServiceTemplate(String serviceTemplateContent) throws BluePrintException {
- if (StringUtils.isNotBlank(serviceTemplateContent)) {
- ServiceTemplate serviceTemplate =
- JacksonUtils.Companion.readValue(serviceTemplateContent, ServiceTemplate.class);
- return validateServiceTemplate(serviceTemplate);
- } else {
- throw new BluePrintException(
- "Service Template Content is (" + serviceTemplateContent + ") not Defined.");
- }
- }
-
- /**
- * This is a validateServiceTemplate
- *
- * @param serviceTemplate serviceTemplate
- * @return boolean
- * @throws BluePrintException BluePrintException
- */
- @SuppressWarnings("squid:S00112")
- public boolean validateServiceTemplate(ServiceTemplate serviceTemplate) throws BluePrintException {
- Map<String, Object> properties = new HashMap<>();
- super.validateBlueprint(serviceTemplate, properties);
- return true;
- }
-
- /**
- * This is a getMetaData to get the key information during the
- *
- * @return Map<String , String>
- */
- public Map<String, String> getMetaData() {
- return metaData;
- }
-
- @Override
- public void validateMetadata(@NotNull Map<String, String> metaDataMap) throws BluePrintException {
-
- Preconditions.checkNotNull(serviceTemplate.getMetadata(), "Service Template Metadata Information is missing.");
- super.validateMetadata(metaDataMap);
-
- this.metaData.putAll(serviceTemplate.getMetadata());
- }
-
-
- @Override
- public void validateNodeTemplate(@NotNull String nodeTemplateName, @NotNull NodeTemplate nodeTemplate)
- throws BluePrintException {
- super.validateNodeTemplate(nodeTemplateName, nodeTemplate);
- validateNodeTemplateCustom(nodeTemplateName, nodeTemplate);
-
- }
-
- @Deprecated()
- private void validateNodeTemplateCustom(@NotNull String nodeTemplateName, @NotNull NodeTemplate nodeTemplate)
- throws BluePrintException {
- String derivedFrom = getBluePrintContext().nodeTemplateNodeType(nodeTemplateName).getDerivedFrom();
-
- if (BluePrintConstants.MODEL_TYPE_NODE_ARTIFACT.equals(derivedFrom)) {
- List<ResourceAssignment> resourceAssignment = getResourceAssignments(nodeTemplate);
- ResourceAssignmentValidationService resourceAssignmentValidationService = new ResourceAssignmentValidationServiceImpl();
- resourceAssignmentValidationService.validate(resourceAssignment);
- }
- }
-
- private List<ResourceAssignment> getResourceAssignments(@NotNull NodeTemplate nodeTemplate) {
-
- List<ResourceAssignment> resourceAssignment = null;
-
- if (MapUtils.isNotEmpty(nodeTemplate.getCapabilities())) {
-
- CapabilityAssignment capabilityAssignment =
- nodeTemplate.getCapabilities().get(ConfigModelConstant.CAPABILITY_PROPERTY_MAPPING);
- if (capabilityAssignment != null && capabilityAssignment.getProperties() != null) {
- Object mappingObject =
- capabilityAssignment.getProperties().get(ConfigModelConstant.CAPABILITY_PROPERTY_MAPPING);
- if (mappingObject != null) {
- String mappingContent = JacksonUtils.Companion.getJson(mappingObject);
- Preconditions.checkArgument(StringUtils.isNotBlank(mappingContent),
- String.format("Failed to get capability mapping property (%s) ", ConfigModelConstant.CAPABILITY_PROPERTY_MAPPING));
-
- resourceAssignment = JacksonUtils.Companion.getListFromJson(mappingContent, ResourceAssignment.class);
-
- Preconditions.checkNotNull(resourceAssignment,
- String.format("Failed to get resource assignment info from the content (%s) ", mappingContent));
- }
- }
- }
- return resourceAssignment;
- }
-}
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoServiceImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoServiceImpl.kt
index f856b9ef..88589eb7 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoServiceImpl.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintRepoServiceImpl.kt
@@ -1,5 +1,6 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2019 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,21 +25,10 @@ import org.onap.ccsdk.apps.controllerblueprints.core.data.*
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintRepoService
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceAssignmentValidationServiceImpl
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionValidationServiceImpl
import org.onap.ccsdk.apps.controllerblueprints.service.repository.ModelTypeRepository
import org.onap.ccsdk.apps.controllerblueprints.service.repository.ResourceDictionaryRepository
import org.springframework.stereotype.Service
-// Resource Dictionary Validation Services
-
-@Service
-class DefaultResourceAssignmentValidationService : ResourceAssignmentValidationServiceImpl()
-
-@Service
-class DefalutResourceDefinitionValidationService(bluePrintRepoService: BluePrintRepoService)
- : ResourceDefinitionValidationServiceImpl(bluePrintRepoService)
-
interface ResourceDefinitionRepoService : BluePrintRepoService {
@Throws(BluePrintException::class)
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImpl.kt
index 63171de6..fb49dc46 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImpl.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImpl.kt
@@ -23,9 +23,9 @@ import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintEnhancerService
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
-import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintFileUtils
import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.ResourceDictionaryUtils
import org.springframework.stereotype.Service
import java.util.*
@@ -56,11 +56,15 @@ open class BluePrintEnhancerServiceImpl(private val bluePrintTypeEnhancerService
bluePrintTypeEnhancerService.enhanceServiceTemplate(blueprintRuntimeService, "service_template",
blueprintRuntimeService.bluePrintContext().serviceTemplate)
+ log.info("##### Enhancing blueprint Resource Definitions")
+ val resourceDefinitions = resourceDefinitionEnhancerService.enhance(bluePrintTypeEnhancerService,
+ blueprintRuntimeService)
+
// Write the Enhanced Blueprint Definitions
BluePrintFileUtils.writeEnhancedBluePrint(blueprintRuntimeService.bluePrintContext())
- // Enhance Resource Dictionary
- enhanceResourceDefinition(blueprintRuntimeService)
+ // Write the Enhanced Blueprint Resource Definitions
+ ResourceDictionaryUtils.writeResourceDefinitionTypes(basePath, resourceDefinitions)
if (blueprintRuntimeService.getBluePrintError().errors.isNotEmpty()) {
throw BluePrintException(blueprintRuntimeService.getBluePrintError().errors.toString())
@@ -73,10 +77,5 @@ open class BluePrintEnhancerServiceImpl(private val bluePrintTypeEnhancerService
return blueprintRuntimeService.bluePrintContext()
}
- private fun enhanceResourceDefinition(blueprintRuntimeService: BluePrintRuntimeService<*>) {
- log.info("##### Enhancing blueprint Resource Definitions")
- resourceDefinitionEnhancerService.enhance(blueprintRuntimeService)
- }
-
}
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintNodeTemplateEnhancerImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintNodeTemplateEnhancerImpl.kt
index fb6c06af..0765f903 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintNodeTemplateEnhancerImpl.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintNodeTemplateEnhancerImpl.kt
@@ -1,5 +1,6 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2019 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,15 +19,13 @@ 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.data.NodeTemplate
-import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeType
-import org.onap.ccsdk.apps.controllerblueprints.core.format
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintNodeTemplateEnhancer
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintRepoService
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+import org.onap.ccsdk.apps.controllerblueprints.service.utils.BluePrintEnhancerUtils
import org.springframework.beans.factory.config.ConfigurableBeanFactory
import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Service
@@ -51,7 +50,7 @@ open class BluePrintNodeTemplateEnhancerImpl(private val bluePrintRepoService: B
val nodeTypeName = nodeTemplate.type
// Get NodeType from Repo and Update Service Template
- val nodeType = populateNodeType(nodeTypeName)
+ val nodeType = BluePrintEnhancerUtils.populateNodeType(bluePrintContext, bluePrintRepoService, nodeTypeName)
// Enrich NodeType
bluePrintTypeEnhancerService.enhanceNodeType(bluePrintRuntimeService, nodeTypeName, nodeType)
@@ -60,16 +59,6 @@ open class BluePrintNodeTemplateEnhancerImpl(private val bluePrintRepoService: B
enhanceNodeTemplateArtifactDefinition(name, nodeTemplate)
}
-
- open fun populateNodeType(nodeTypeName: String): NodeType {
-
- val nodeType = bluePrintContext.serviceTemplate.nodeTypes?.get(nodeTypeName)
- ?: bluePrintRepoService.getNodeType(nodeTypeName)
- ?: throw BluePrintException(format("Couldn't get NodeType({}) from repo.", nodeTypeName))
- bluePrintContext.serviceTemplate.nodeTypes?.put(nodeTypeName, nodeType)
- return nodeType
- }
-
open fun enhanceNodeTemplateArtifactDefinition(nodeTemplateName: String, nodeTemplate: NodeTemplate) {
nodeTemplate.artifacts?.forEach { artifactDefinitionName, artifactDefinition ->
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintPropertyDefinitionEnhancerImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintPropertyDefinitionEnhancerImpl.kt
index 1ae558fa..1675e8cd 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintPropertyDefinitionEnhancerImpl.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintPropertyDefinitionEnhancerImpl.kt
@@ -1,5 +1,6 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2019 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -43,8 +44,9 @@ open class BluePrintPropertyDefinitionEnhancerImpl(private val bluePrintRepoServ
this.bluePrintContext = bluePrintRuntimeService.bluePrintContext()
val propertyType = propertyDefinition.type
- if (BluePrintTypes.validPrimitiveTypes().contains(propertyType)) {
-
+ if (BluePrintTypes.validPrimitiveTypes().contains(propertyType)
+ || BluePrintTypes.validComplexTypes().contains(propertyType)) {
+ // Do Nothing,
} else if (BluePrintTypes.validCollectionTypes().contains(propertyType)) {
val entrySchema = propertyDefinition.entrySchema
?: throw BluePrintException("Entry Schema is missing for collection property($name)")
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceDefinitionEnhancerService.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceDefinitionEnhancerService.kt
index 43eb019e..6171687f 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceDefinitionEnhancerService.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceDefinitionEnhancerService.kt
@@ -23,18 +23,21 @@ import kotlinx.coroutines.Deferred
import kotlinx.coroutines.async
import kotlinx.coroutines.runBlocking
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeEnhancerService
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.ResourceDictionaryUtils
import org.onap.ccsdk.apps.controllerblueprints.service.ResourceDefinitionRepoService
+import org.onap.ccsdk.apps.controllerblueprints.service.utils.BluePrintEnhancerUtils
import org.springframework.stereotype.Service
interface ResourceDefinitionEnhancerService {
@Throws(BluePrintException::class)
- fun enhance(bluePrintRuntimeService: BluePrintRuntimeService<*>)
+ fun enhance(bluePrintTypeEnhancerService: BluePrintTypeEnhancerService,
+ bluePrintRuntimeService: BluePrintRuntimeService<*>): List<ResourceDefinition>
}
@Service
@@ -45,7 +48,6 @@ class ResourceDefinitionEnhancerServiceImpl(private val resourceDefinitionRepoSe
companion object {
const val ARTIFACT_TYPE_MAPPING_SOURCE: String = "artifact-mapping-resource"
- const val PROPERTY_DEPENDENCY_NODE_TEMPLATES = "dependency-node-templates"
}
// Enhance the Resource Definition
@@ -53,15 +55,21 @@ class ResourceDefinitionEnhancerServiceImpl(private val resourceDefinitionRepoSe
// 2. Get all the Unique Resource assignments from all mapping files
// 3. Collect the Resource Definition for Resource Assignment names from database.
// 4. Create the Resource Definition under blueprint base path.
- override fun enhance(bluePrintRuntimeService: BluePrintRuntimeService<*>) {
+ override fun enhance(bluePrintTypeEnhancerService: BluePrintTypeEnhancerService,
+ bluePrintRuntimeService: BluePrintRuntimeService<*>): List<ResourceDefinition> {
+
+ var resourceDefinitions: List<ResourceDefinition> = mutableListOf()
val blueprintContext = bluePrintRuntimeService.bluePrintContext()
val mappingFiles = getAllResourceMappingFiles(blueprintContext)
log.info("resources assignment files ($mappingFiles)")
if (mappingFiles != null) {
- getResourceDefinition(blueprintContext, mappingFiles)
+ resourceDefinitions = getResourceDefinition(blueprintContext, mappingFiles)
+ // Enriching Resource Definition Sources
+ enrichResourceDefinitionSources(bluePrintRuntimeService.bluePrintContext(), resourceDefinitions)
}
+ return resourceDefinitions
}
// Get all the Mapping files from all node templates.
@@ -80,42 +88,54 @@ class ResourceDefinitionEnhancerServiceImpl(private val resourceDefinitionRepoSe
}
// Convert file content to ResourceAssignments asynchronously
- private fun getResourceDefinition(blueprintContext: BluePrintContext, files: List<String>) {
- runBlocking {
- val blueprintBasePath = blueprintContext.rootPath
- val deferredResourceAssignments = mutableListOf<Deferred<List<ResourceAssignment>>>()
- for (file in files) {
- log.info("processing file ($file)")
- deferredResourceAssignments += async {
- ResourceDictionaryUtils.getResourceAssignmentFromFile("$blueprintBasePath/$file")
- }
- }
-
- val resourceAssignments = mutableListOf<ResourceAssignment>()
- for (deferredResourceAssignment in deferredResourceAssignments) {
- resourceAssignments.addAll(deferredResourceAssignment.await())
+ private fun getResourceDefinition(blueprintContext: BluePrintContext, files: List<String>) = runBlocking {
+ val blueprintBasePath = blueprintContext.rootPath
+ val deferredResourceAssignments = mutableListOf<Deferred<List<ResourceAssignment>>>()
+ for (file in files) {
+ log.info("processing file ($file)")
+ deferredResourceAssignments += async {
+ ResourceDictionaryUtils.getResourceAssignmentFromFile("$blueprintBasePath/$file")
}
+ }
- val distinctResourceAssignments = resourceAssignments.distinctBy { it.name }
- generateResourceDictionaryFile(blueprintBasePath, distinctResourceAssignments)
- //log.info("distinct Resource assignment ($distinctResourceAssignments)")
+ val resourceAssignments = mutableListOf<ResourceAssignment>()
+ for (deferredResourceAssignment in deferredResourceAssignments) {
+ resourceAssignments.addAll(deferredResourceAssignment.await())
}
+
+ val distinctResourceAssignments = resourceAssignments.distinctBy { it.name }
+ generateResourceDictionary(blueprintBasePath, distinctResourceAssignments)
+ //log.info("distinct Resource assignment ($distinctResourceAssignments)")
}
+
// Read the Resource Definitions from the Database and write to type file.
- private fun generateResourceDictionaryFile(blueprintBasePath: String, resourceAssignments: List<ResourceAssignment>) {
+ private fun generateResourceDictionary(blueprintBasePath: String, resourceAssignments: List<ResourceAssignment>)
+ : List<ResourceDefinition> {
val resourceKeys = resourceAssignments.mapNotNull { it.dictionaryName }.distinct().sorted()
log.info("distinct resource keys ($resourceKeys)")
//TODO("Optimise DB single Query to multiple Query")
- // Collect the Resource Definition from database and convert to map to save in file
- val resourceDefinitionMap = resourceKeys.map { resourceKey ->
+ return resourceKeys.map { resourceKey ->
getResourceDefinition(resourceKey)
- }.map { it.name to it }.toMap()
+ }
+ }
- // Recreate the Resource Definition File
- ResourceDictionaryUtils.writeResourceDefinitionTypes(blueprintBasePath, resourceDefinitionMap)
- log.info("resource definition file created successfully")
+ private fun enrichResourceDefinitionSources(bluePrintContext: BluePrintContext,
+ resourceDefinitions: List<ResourceDefinition>) {
+ val sources = resourceDefinitions
+ .map { it.sources }
+ .map {
+ it.values
+ .map { nodeTemplate ->
+ nodeTemplate.type
+ }
+ }
+ .flatten().distinct()
+ log.info("Enriching Resource Definition sources Node Template: $sources")
+ sources.forEach {
+ BluePrintEnhancerUtils.populateNodeType(bluePrintContext, resourceDefinitionRepoService, it)
+ }
}
// Get the Resource Definition from Database
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/handler/ResourceDictionaryHandler.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/handler/ResourceDictionaryHandler.kt
index c2493148..ec7d8aeb 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/handler/ResourceDictionaryHandler.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/handler/ResourceDictionaryHandler.kt
@@ -1,5 +1,6 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2019 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,17 +21,15 @@ import com.google.common.base.Preconditions
import org.apache.commons.collections.CollectionUtils
import org.apache.commons.lang3.StringUtils
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmptyOrThrow
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceSourceMapping
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.factory.ResourceSourceMappingFactory
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionValidationService
import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary
import org.onap.ccsdk.apps.controllerblueprints.service.repository.ResourceDictionaryRepository
-import org.onap.ccsdk.apps.controllerblueprints.service.validator.ResourceDictionaryValidator
import org.springframework.stereotype.Service
@Service
-class ResourceDictionaryHandler(private val resourceDictionaryRepository: ResourceDictionaryRepository,
- private val resourceDictionaryValidationService: ResourceDefinitionValidationService) {
+class ResourceDictionaryHandler(private val resourceDictionaryRepository: ResourceDictionaryRepository) {
/**
@@ -86,7 +85,8 @@ class ResourceDictionaryHandler(private val resourceDictionaryRepository: Resour
val resourceDefinition = resourceDictionary.definition
Preconditions.checkNotNull(resourceDefinition, "failed to get resource definition from content")
// Validate the Resource Definitions
- resourceDictionaryValidationService.validate(resourceDefinition)
+ //TODO( Save Validator)
+ //validate(resourceDefinition)
resourceDictionary.tags = resourceDefinition.tags
resourceDefinition.updatedBy = resourceDictionary.updatedBy
@@ -98,7 +98,7 @@ class ResourceDictionaryHandler(private val resourceDictionaryRepository: Resour
resourceDictionary.entrySchema = propertyDefinition.entrySchema!!.type
}
- ResourceDictionaryValidator.validateResourceDictionary(resourceDictionary)
+ validateResourceDictionary(resourceDictionary)
val dbResourceDictionaryData = resourceDictionaryRepository.findByName(resourceDictionary.name)
if (dbResourceDictionaryData.isPresent) {
@@ -135,4 +135,14 @@ class ResourceDictionaryHandler(private val resourceDictionaryRepository: Resour
fun getResourceSourceMapping(): ResourceSourceMapping {
return ResourceSourceMappingFactory.getRegisterSourceMapping()
}
+
+ private fun validateResourceDictionary(resourceDictionary: ResourceDictionary): Boolean {
+ checkNotEmptyOrThrow(resourceDictionary.name, "DataDictionary Definition name is missing.")
+ checkNotNull(resourceDictionary.definition) { "DataDictionary Definition Information is missing." }
+ checkNotEmptyOrThrow(resourceDictionary.description, "DataDictionary Definition Information is missing.")
+ checkNotEmptyOrThrow(resourceDictionary.tags, "DataDictionary Definition tags is missing.")
+ checkNotEmptyOrThrow(resourceDictionary.updatedBy, "DataDictionary Definition updatedBy is missing.")
+ return true
+
+ }
} \ No newline at end of file
diff --git a/ms/controllerblueprints/parent/pom.xml b/ms/controllerblueprints/parent/pom.xml
index ea7b4e40..f59effc4 100644
--- a/ms/controllerblueprints/parent/pom.xml
+++ b/ms/controllerblueprints/parent/pom.xml
@@ -30,10 +30,10 @@
<packaging>pom</packaging>
<properties>
<kotlin.compiler.jvmTarget>1.8</kotlin.compiler.jvmTarget>
- <spring.boot.version>2.1.2.RELEASE</spring.boot.version>
- <spring.version>5.1.4.RELEASE</spring.version>
- <kotlin.version>1.3.20</kotlin.version>
- <kotlin.maven.version>1.3.20</kotlin.maven.version>
+ <spring.boot.version>2.1.3.RELEASE</spring.boot.version>
+ <spring.version>5.1.5.RELEASE</spring.version>
+ <kotlin.version>1.3.21</kotlin.version>
+ <kotlin.maven.version>1.3.21</kotlin.maven.version>
<kotlin.couroutines.version>1.1.1</kotlin.couroutines.version>
<grpc.version>1.18.0</grpc.version>
<protobuff.java.utils.version>3.6.1</protobuff.java.utils.version>
diff --git a/ms/pom.xml b/ms/pom.xml
index 0a9aa7e5..21e3507b 100644
--- a/ms/pom.xml
+++ b/ms/pom.xml
@@ -39,5 +39,6 @@
<module>blueprintsprocessor</module>
<module>neng</module>
<module>vlantag-api</module>
+ <module>cds-sdc-listener</module>
</modules>
</project>