aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2018-12-11 17:32:21 +0000
committerGerrit Code Review <gerrit@onap.org>2018-12-11 17:32:21 +0000
commit68e4c4aeb00d9b4719cbb054e4b15481910e3ae0 (patch)
tree795db15fc3a425350203b73479efcff0f7566025
parent6d022160fd982ce7e932c3f41cbc73fe1463f445 (diff)
parent1141bf4d7f7c641aecdc12c085a7410bbe713bb8 (diff)
Merge "Implement Resource Resolution Services"
-rw-r--r--components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt12
-rw-r--r--components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json3
-rw-r--r--components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/baseconfig-mapping.json39
-rw-r--r--components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json8
-rw-r--r--components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_dictionary_types.json62
-rw-r--r--components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_dictionaty_types.json3
-rw-r--r--components/model-catalog/definition-type/starter-type/node_type/component-resource-assignment.json12
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt23
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConfiguration.kt26
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt3
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt91
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/DataBaseResourceAssignmentProcessor.kt1
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/DefaultResourceAssignmentProcessor.kt1
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/InputResourceAssignmentProcessor.kt1
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/ResourceAssignmentProcessor.kt (renamed from components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceAssignmentProcessor.kt)20
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/SimpleRestResourceAssignmentProcessor.kt1
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt68
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt31
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/payload/requests/sample-resourceresolution-request.json12
-rw-r--r--ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt23
-rw-r--r--ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/utils/PayloadUtils.kt47
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/resource/api/ResourceResolutionController.java16
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt5
23 files changed, 399 insertions, 109 deletions
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt
index f53f8615..40210142 100644
--- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt
+++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt
@@ -122,6 +122,11 @@ object JacksonUtils {
}
@JvmStatic
+ fun <T> getListFromJsonNode(node: JsonNode, valueType: Class<T>): List<T>? {
+ return getListFromJson(node.toString(), valueType)
+ }
+
+ @JvmStatic
fun <T> getListFromJson(content: String, valueType: Class<T>): List<T>? {
val objectMapper = jacksonObjectMapper()
val javaType = objectMapper.typeFactory.constructCollectionType(List::class.java, valueType)
@@ -149,6 +154,13 @@ object JacksonUtils {
}
@JvmStatic
+ fun <T> getMapFromFile(fileName: String, valueType: Class<T>): MutableMap<String, T>? {
+ val content: String = FileUtils.readFileToString(File(fileName), Charset.defaultCharset())
+ ?: throw BluePrintException(format("Failed to read json file : {}", fileName))
+ return getMapFromJson(content, valueType)
+ }
+
+ @JvmStatic
fun checkJsonNodeValueOfType(type: String, jsonNode: JsonNode): Boolean {
if (BluePrintTypes.validPrimitiveTypes().contains(type)) {
return checkJsonNodeValueOfPrimitiveType(type, jsonNode)
diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json
index e5f0c9c0..446932d5 100644
--- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json
+++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json
@@ -136,6 +136,9 @@
"resource-id": {
"get_input": "hostname"
},
+ "artifact-prefix-names": [
+ "baseconfig"
+ ],
"template-content": {
"get_artifact": [
"SELF",
diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/baseconfig-mapping.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/baseconfig-mapping.json
index caee773b..c457086c 100644
--- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/baseconfig-mapping.json
+++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/baseconfig-mapping.json
@@ -1,3 +1,36 @@
-{
- "assignments": "Sample Assignments"
-} \ No newline at end of file
+[
+ {
+ "name": "service-instance-id",
+ "input-param": true,
+ "property": {
+ "type": "string"
+ },
+ "dictionary-name": "service-instance-id",
+ "dictionary-source": "input",
+ "dependencies": [
+ ]
+ },
+ {
+ "name": "vnf-id",
+ "input-param": true,
+ "property": {
+ "type": "string"
+ },
+ "dictionary-name": "vnf-id",
+ "dictionary-source": "input",
+ "dependencies": []
+ },
+ {
+ "name": "vnf_name",
+ "input-param": false,
+ "property": {
+ "type": "string"
+ },
+ "dictionary-name": "vnf_name",
+ "dictionary-source": "mdsal",
+ "dependencies": [
+ "service-instance-id",
+ "vnf-id"
+ ]
+ }
+]
diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json
index 2723510a..6e8d839e 100644
--- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json
+++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json
@@ -69,6 +69,14 @@
"required": true,
"type": "string"
},
+ "artifact-prefix-names": {
+ "required": false,
+ "description": "Template , Resource Assignment Artifact Prefix names",
+ "type": "list",
+ "entry_schema": {
+ "type": "string"
+ }
+ },
"template-content": {
"description": "Id used to pull the data content from the data base. Either template-data or resource-id should be present",
"required": true,
diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_dictionary_types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_dictionary_types.json
new file mode 100644
index 00000000..557f6efc
--- /dev/null
+++ b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_dictionary_types.json
@@ -0,0 +1,62 @@
+{
+ "service-instance-id": {
+ "name": "service-instance-id",
+ "tags": "service-instance-id, tosca.datatypes.Root, data_type",
+ "updated-by": "Singal, Kapil <ks220y@att.com>",
+ "property": {
+ "description": "To be provided",
+ "type": "string"
+ },
+ "sources": {
+ "input": {
+ "type": "source-input",
+ "properties": {}
+ }
+ }
+ },
+ "vnf-id": {
+ "name": "vnf-id",
+ "tags": "vnf-id",
+ "updated-by": "Singal, Kapil <ks220y@att.com>",
+ "property": {
+ "description": "vnf-id",
+ "type": "string"
+ },
+ "sources": {
+ "input": {
+ "type": "source-input",
+ "properties": {}
+ }
+ }
+ },
+ "vnf_name": {
+ "name": "vnf_name",
+ "tags": "vnf_name",
+ "updated-by": "Singal, Kapil <ks220y@att.com>",
+ "property": {
+ "description": "vnf_name",
+ "type": "string"
+ },
+ "sources": {
+ "mdsal": {
+ "type": "source-rest",
+ "properties": {
+ "type": "JSON",
+ "url-path": "config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/vnf_name",
+ "path": "/param/0/value",
+ "input-key-mapping": {
+ "service-instance-id": "service-instance-id",
+ "vnf-id": "vnf-id"
+ },
+ "output-key-mapping": {
+ "vnf_name": "value"
+ },
+ "key-dependencies": [
+ "service-instance-id",
+ "vnf-id"
+ ]
+ }
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_dictionaty_types.json b/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_dictionaty_types.json
deleted file mode 100644
index 0e0dcd23..00000000
--- a/components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_dictionaty_types.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
-
-} \ No newline at end of file
diff --git a/components/model-catalog/definition-type/starter-type/node_type/component-resource-assignment.json b/components/model-catalog/definition-type/starter-type/node_type/component-resource-assignment.json
index a29a875c..51d70ede 100644
--- a/components/model-catalog/definition-type/starter-type/node_type/component-resource-assignment.json
+++ b/components/model-catalog/definition-type/starter-type/node_type/component-resource-assignment.json
@@ -11,12 +11,12 @@
"operations": {
"process": {
"inputs": {
- "template-name": {
+ "template-name": {
"description": "Service Template Name.",
"required": true,
"type": "string"
},
- "template-version": {
+ "template-version": {
"description": "Service Template Version.",
"required": true,
"type": "string"
@@ -34,6 +34,14 @@
"type": "string"
}
},
+ "artifact-prefix-names": {
+ "required": false,
+ "description": "Template , Resource Assignment Artifact Prefix names",
+ "type": "list",
+ "entry_schema": {
+ "type": "string"
+ }
+ },
"request-id": {
"description": "Request Id, Unique Id for the request.",
"required": true,
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 32696c57..e5feb257 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
@@ -18,15 +18,34 @@ 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.annotation.Autowired
import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.ApplicationContext
import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Component
@Component("component-resource-resolution")
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-open class ResourceResolutionComponent : AbstractComponentFunction() {
+open class ResourceResolutionComponent(private val resourceResolutionService: ResourceResolutionService) : AbstractComponentFunction() {
+
+ @Autowired
+ private lateinit var applicationContext: ApplicationContext
+
override fun process(executionRequest: ExecutionServiceInput) {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+
+ val artifactPrefixNamesNode = getOperationInput(ResourceResolutionConstants.INPUT_ARTIFACT_PREFIX_NAMES)
+
+ val artifactPrefixNames = JacksonUtils.getListFromJsonNode(artifactPrefixNamesNode, String::class.java)
+ ?: throw BluePrintProcessorException("coundn'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) {
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConfiguration.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConfiguration.kt
new file mode 100644
index 00000000..4c24ac69
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConfiguration.kt
@@ -0,0 +1,26 @@
+/*
+ * 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.springframework.context.annotation.ComponentScan
+import org.springframework.context.annotation.Configuration
+
+@Configuration
+@ComponentScan
+open class ResourceResolutionConfiguration
+
+
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 aea3313c..3211d6e8 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
@@ -19,6 +19,9 @@ package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution
class ResourceResolutionConstants {
companion object {
const val PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR = "resource-assignment-processor-"
+ const val INPUT_ARTIFACT_PREFIX_NAMES = "artifact-prefix-names"
+ const val OUTPUT_ASSIGNMENT_PARAMS = "assignment-params"
+ const val FILE_NAME_RESOURCE_DICTIONARY_TYPES = "resources_dictionary_types.json"
}
} \ 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 2b76b78a..c3cf0097 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
@@ -17,16 +17,19 @@
package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution
-import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionInput
-import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionOutput
-import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.Status
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor.ResourceAssignmentProcessor
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+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
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor
+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.beans.factory.annotation.Autowired
import org.springframework.context.ApplicationContext
import org.springframework.stereotype.Service
+import java.io.File
/**
* ResourceResolutionService
@@ -37,33 +40,76 @@ import org.springframework.stereotype.Service
@Service
class ResourceResolutionService {
+ private val log = LoggerFactory.getLogger(ResourceResolutionService::class.java)
@Autowired
private lateinit var applicationContext: ApplicationContext
- fun resolveResource(resourceResolutionInput: ResourceResolutionInput): ResourceResolutionOutput {
- val resourceResolutionOutput = ResourceResolutionOutput()
- resourceResolutionOutput.actionIdentifiers = resourceResolutionInput.actionIdentifiers
- resourceResolutionOutput.commonHeader = resourceResolutionInput.commonHeader
- resourceResolutionOutput.resourceAssignments = resourceResolutionInput.resourceAssignments
+ fun registeredResourceSources(): List<String> {
+ return applicationContext.getBeanNamesForType(ResourceAssignmentProcessor::class.java)
+ .filter { it.startsWith(ResourceResolutionConstants.PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR) }
+ .map { it.substringAfter(ResourceResolutionConstants.PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR) }
+ }
- process(resourceResolutionOutput.resourceAssignments)
- val status = Status()
- status.code = 200
- status.message = "Success"
- resourceResolutionOutput.status = status
+ fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
+ artifactNames: List<String>): MutableMap<String, String> {
- return resourceResolutionOutput
+ val resolvedParams: MutableMap<String, String> = hashMapOf()
+ artifactNames.forEach { artifactName ->
+ val resolvedContent = resolveResources(bluePrintRuntimeService, nodeTemplateName, artifactName)
+ resolvedParams[artifactName] = resolvedContent
+ }
+ return resolvedParams
}
- fun registeredResourceSources(): List<String> {
- return applicationContext.getBeanNamesForType(ResourceAssignmentProcessor::class.java)
- .filter { it.startsWith(ResourceResolutionConstants.PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR) }
- .map { it.substringAfter(ResourceResolutionConstants.PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR) }
+
+ fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String, artifactName: String): String {
+
+ var resolvedContent = ""
+ // Velocity Artifact Definition Name
+ val templateArtifactName = "$artifactName-template"
+ // Resource Assignment Artifact Definition Name
+ val mappingArtifactName = "$artifactName-mapping"
+
+ log.info("Resolving resource for template artifact($templateArtifactName) with resource assignment artifact($mappingArtifactName)")
+
+ val resourceAssignmentContent = bluePrintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, mappingArtifactName)
+
+ 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_DICTIONARY_TYPES)
+
+ val resourceDictionaries: MutableMap<String, ResourceDefinition> = JacksonUtils.getMapFromFile(dictionaryFile, ResourceDefinition::class.java)
+ ?: throw BluePrintProcessorException("couldn't get Dictionary Definitions")
+
+ executeProcessors(bluePrintRuntimeService, resourceDictionaries, resourceAssignments)
+
+ // Check Template is there
+ val templateContent = bluePrintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, mappingArtifactName)
+
+ // TODO ("Generate Param JSON from Resource Assignment")
+ val resolvedParamJsonContent = "{}"
+
+ if (templateContent.isNotEmpty()) {
+ // TODO ( "Mash Data and Content")
+ resolvedContent = "Mashed Content"
+
+ } else {
+ resolvedContent = resolvedParamJsonContent
+ }
+ return resolvedContent
}
- fun process(resourceAssignments: MutableList<ResourceAssignment>) {
+
+ fun executeProcessors(bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ resourceDictionaries: MutableMap<String, ResourceDefinition>,
+ resourceAssignments: MutableList<ResourceAssignment>) {
val bulkSequenced = BulkResourceSequencingUtils.process(resourceAssignments)
@@ -77,6 +123,10 @@ class ResourceResolutionService {
?: throw BluePrintProcessorException("failed to get resource processor for instance name($processorInstanceName) " +
"for resource assignment(${resourceAssignment.name})")
try {
+ // Set BluePrint Runtime Service
+ resourceAssignmentProcessor.bluePrintRuntimeService = bluePrintRuntimeService
+ // Set Resource Dictionaries
+ resourceAssignmentProcessor.resourceDictionaries = resourceDictionaries
// Invoke Apply Method
resourceAssignmentProcessor.apply(resourceAssignment)
} catch (e: RuntimeException) {
@@ -86,4 +136,5 @@ class ResourceResolutionService {
}
}
}
+
}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/DataBaseResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/DataBaseResourceAssignmentProcessor.kt
index bdb79d30..12120341 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/DataBaseResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/DataBaseResourceAssignmentProcessor.kt
@@ -18,7 +18,6 @@
package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor
import org.springframework.stereotype.Service
/**
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/DefaultResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/DefaultResourceAssignmentProcessor.kt
index 5419c0f6..58c9e1d8 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/DefaultResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/DefaultResourceAssignmentProcessor.kt
@@ -18,7 +18,6 @@
package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor
import org.springframework.stereotype.Service
/**
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/InputResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/InputResourceAssignmentProcessor.kt
index 2b36add0..10332484 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/InputResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/InputResourceAssignmentProcessor.kt
@@ -18,7 +18,6 @@
package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor
import org.springframework.stereotype.Service
/**
diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/ResourceAssignmentProcessor.kt
index 327d50ac..2b19c8b8 100644
--- a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/ResourceAssignmentProcessor.kt
@@ -15,28 +15,32 @@
* limitations under the License.
*/
-package org.onap.ccsdk.apps.controllerblueprints.resource.dict
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BlueprintFunctionNode
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.slf4j.LoggerFactory
abstract class ResourceAssignmentProcessor : BlueprintFunctionNode<ResourceAssignment, ResourceAssignment> {
private val log = LoggerFactory.getLogger(ResourceAssignmentProcessor::class.java)
- private var bluePrintRuntimeService: BluePrintRuntimeService<*>? = null
+ var bluePrintRuntimeService: BluePrintRuntimeService<*>? = null
+
+ var resourceDictionaries: Map<String, ResourceDefinition> = hashMapOf()
- open fun setBlueprintRuntimeService(bluePrintRuntimeService: BluePrintRuntimeService<*>) {
- this.bluePrintRuntimeService = bluePrintRuntimeService
- }
- open fun getBlueprintRuntimeService(): BluePrintRuntimeService<*> {
- return this.bluePrintRuntimeService!!
+ open fun resourceDefinition(name: String): ResourceDefinition {
+ return resourceDictionaries.get(name)
+ ?: throw BluePrintProcessorException("couldn't get resource definition($name)")
}
override fun prepareRequest(resourceAssignment: ResourceAssignment): ResourceAssignment {
- log.info("prepareRequest...")
+ log.info("prepareRequest for ${resourceAssignment.name}, dictionary(${resourceAssignment.dictionaryName})," +
+ "source(${resourceAssignment.dictionarySource})")
return resourceAssignment
}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/SimpleRestResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/SimpleRestResourceAssignmentProcessor.kt
index d778c232..c6732627 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/SimpleRestResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/SimpleRestResourceAssignmentProcessor.kt
@@ -18,7 +18,6 @@
package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor
import org.springframework.stereotype.Service
/**
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
new file mode 100644
index 00000000..57217d0d
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt
@@ -0,0 +1,68 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution
+
+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.core.utils.PayloadUtils
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor.DataBaseResourceAssignmentProcessor
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor.DefaultResourceAssignmentProcessor
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor.InputResourceAssignmentProcessor
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor.SimpleRestResourceAssignmentProcessor
+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.springframework.beans.factory.annotation.Autowired
+import org.springframework.test.context.ContextConfiguration
+import org.springframework.test.context.junit4.SpringRunner
+
+@RunWith(SpringRunner::class)
+@ContextConfiguration(classes = [ResourceResolutionComponent::class, ResourceResolutionService::class,
+ InputResourceAssignmentProcessor::class, DefaultResourceAssignmentProcessor::class,
+ DataBaseResourceAssignmentProcessor::class, SimpleRestResourceAssignmentProcessor::class])
+class ResourceResolutionComponentTest {
+
+ @Autowired
+ lateinit var resourceResolutionComponent: ResourceResolutionComponent
+
+ @Test
+ fun testProcess() {
+
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
+ "./../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration")
+
+ val executionServiceInput = JacksonUtils.readValueFromClassPathFile("payload/requests/sample-resourceresolution-request.json",
+ ExecutionServiceInput::class.java)!!
+
+ // Prepare Inputs
+ PayloadUtils.prepareInputsFromWorkflowPayload(bluePrintRuntimeService, executionServiceInput.payload, "resource-assignment")
+
+ val stepMetaData: MutableMap<String, JsonNode> = hashMapOf()
+ stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, "resource-assignment")
+ stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_INTERFACE, "ResourceAssignmentComponent")
+ stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_OPERATION, "process")
+ bluePrintRuntimeService.put("resource-assignment-step-inputs", stepMetaData.asJsonNode())
+
+ resourceResolutionComponent.bluePrintRuntimeService = bluePrintRuntimeService
+ resourceResolutionComponent.stepName = "resource-assignment"
+ resourceResolutionComponent.apply(executionServiceInput)
+ }
+} \ No newline at end of file
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 238d1b0a..df560076 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
@@ -16,25 +16,18 @@
package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution
-import com.fasterxml.jackson.databind.node.ObjectNode
-import org.apache.commons.collections.CollectionUtils
-import org.apache.commons.io.FileUtils
import org.junit.Assert
import org.junit.Test
import org.junit.runner.RunWith
-import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionInput
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor.DataBaseResourceAssignmentProcessor
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor.DefaultResourceAssignmentProcessor
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor.InputResourceAssignmentProcessor
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor.SimpleRestResourceAssignmentProcessor
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.test.context.ContextConfiguration
import org.springframework.test.context.junit4.SpringRunner
-import java.io.File
-import java.nio.charset.Charset
import kotlin.test.assertNotNull
import kotlin.test.assertTrue
@@ -68,26 +61,10 @@ class ResourceResolutionServiceTest {
Assert.assertNotNull("failed to create ResourceResolutionService", resourceResolutionService)
- val resourceResolutionInputContent = FileUtils.readFileToString(
- File("src/test/resources/payload/requests/sample-resourceresolution-request.json"), Charset.defaultCharset())
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
+ "./../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration")
- val resourceResolutionInput = JacksonUtils.readValue(resourceResolutionInputContent, ResourceResolutionInput::class.java)
- Assert.assertNotNull("failed to populate resourceResolutionInput request ", resourceResolutionInput)
-
- val resourceAssignmentContent = FileUtils.readFileToString(
- File("src/test/resources/mapping/db/resource-assignments-simple.json"), Charset.defaultCharset())
- val batchResourceAssignment = JacksonUtils.getListFromJson(resourceAssignmentContent, ResourceAssignment::class.java)
-
- Assert.assertTrue("failed to create ResourceAssignment from file", CollectionUtils.isNotEmpty(batchResourceAssignment))
- resourceResolutionInput!!.resourceAssignments = batchResourceAssignment as MutableList<ResourceAssignment>
-
- val inputContent = JacksonUtils.jsonNodeFromFile("src/test/resources/payload/inputs/input.json") as ObjectNode
- Assert.assertNotNull("failed to populate input payload ", inputContent)
- resourceResolutionInput.payload = inputContent
- log.info("ResourceResolutionInput : {}", JacksonUtils.getJson(resourceResolutionInput, true))
-
- val resourceResolutionOutput = resourceResolutionService.resolveResource(resourceResolutionInput)
- Assert.assertNotNull("failed to populate output", resourceResolutionOutput)
+ resourceResolutionService.resolveResources(bluePrintRuntimeService, "resource-assignment", "baseconfig")
}
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 e8830a8a..7889a7e4 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
@@ -16,7 +16,13 @@
"timestamp": "2012-04-23T18:25:43.511Z"
},
"payload": {
- },
- "resourceAssignments": [
- ]
+ "resource-assignment-request": {
+ "resource-assignment-properties": {
+ "request-id": "1234",
+ "action-name": "assign-activate",
+ "scope-type": "vnf-type",
+ "hostname": "localhost"
+ }
+ }
+ }
}
diff --git a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt
index 3cad6271..b0483dc3 100644
--- a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt
+++ b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt
@@ -20,7 +20,6 @@ package org.onap.ccsdk.apps.blueprintsprocessor.core.api.data
import com.fasterxml.jackson.annotation.JsonFormat
import com.fasterxml.jackson.databind.node.ObjectNode
import io.swagger.annotations.ApiModelProperty
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
import java.util.*
/**
@@ -29,28 +28,6 @@ import java.util.*
* DATE : 8/15/2018
*/
-open class ResourceResolutionInput {
- @get:ApiModelProperty(required = true)
- lateinit var commonHeader: CommonHeader
- @get:ApiModelProperty(required = true)
- lateinit var actionIdentifiers: ActionIdentifiers
- @get:ApiModelProperty(required = true)
- lateinit var resourceAssignments: MutableList<ResourceAssignment>
- @get:ApiModelProperty(required = true)
- lateinit var payload: ObjectNode
-}
-
-open class ResourceResolutionOutput {
- @get:ApiModelProperty(required = true)
- lateinit var commonHeader: CommonHeader
- @get:ApiModelProperty(required = true)
- lateinit var actionIdentifiers: ActionIdentifiers
- @get:ApiModelProperty(required = true)
- lateinit var status: Status
- @get:ApiModelProperty(required = true)
- lateinit var resourceAssignments: MutableList<ResourceAssignment>
-}
-
open class ExecutionServiceInput {
@get:ApiModelProperty(required = true)
lateinit var commonHeader: CommonHeader
diff --git a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/utils/PayloadUtils.kt b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/utils/PayloadUtils.kt
new file mode 100644
index 00000000..31dca33b
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/utils/PayloadUtils.kt
@@ -0,0 +1,47 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.core.utils
+
+import com.fasterxml.jackson.databind.JsonNode
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+
+
+class PayloadUtils {
+
+ companion object {
+
+ fun prepareInputsFromWorkflowPayload(bluePrintRuntimeService: BluePrintRuntimeService<*>, payload: JsonNode, workflowName: String) {
+ val input = payload.get("$workflowName-request")
+ bluePrintRuntimeService.assignWorkflowInputs(workflowName, input)
+ }
+
+ fun prepareDynamicInputsFromWorkflowPayload(bluePrintRuntimeService: BluePrintRuntimeService<*>, payload: JsonNode, workflowName: String) {
+ val input = payload.get("$workflowName-request")
+ val propertyFields = input.get("$workflowName-properties")
+ prepareDynamicInputsFromComponentPayload(bluePrintRuntimeService, propertyFields)
+ }
+
+ fun prepareDynamicInputsFromComponentPayload(bluePrintRuntimeService: BluePrintRuntimeService<*>, payload: JsonNode) {
+ payload.fields().forEach { property ->
+ val path = StringBuilder(BluePrintConstants.PATH_INPUTS)
+ .append(BluePrintConstants.PATH_DIVIDER).append(property.key).toString()
+ bluePrintRuntimeService.put(path, property.value)
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/resource/api/ResourceResolutionController.java b/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/resource/api/ResourceResolutionController.java
index 0f3b4a82..fb833a57 100644
--- a/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/resource/api/ResourceResolutionController.java
+++ b/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/resource/api/ResourceResolutionController.java
@@ -16,12 +16,12 @@
package org.onap.ccsdk.apps.blueprintsprocessor.resource.api;
-import io.swagger.annotations.ApiOperation;
-import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionInput;
-import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionOutput;
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceResolutionService;
import org.springframework.http.MediaType;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;
/**
@@ -45,12 +45,4 @@ public class ResourceResolutionController {
Mono<String> ping() {
return Mono.just("Success");
}
-
- @RequestMapping(path = "/resolve-mapping", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
- @ApiOperation(value = "Resolve Resource Mappings",
- notes = "Also returns a link to retrieve all students with rel - all-students")
- public @ResponseBody
- Mono<ResourceResolutionOutput> resolveResource(@RequestBody ResourceResolutionInput resourceResolutionInput) {
- return Mono.just(resourceResolutionService.resolveResource(resourceResolutionInput));
- }
}
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt
index c6ce4657..87a925f9 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt
@@ -19,11 +19,11 @@ package org.onap.ccsdk.apps.blueprintsprocessor.services.execution
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.node.JsonNodeFactory
-import com.fasterxml.jackson.databind.node.NullNode
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceOutput
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.Status
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.apps.controllerblueprints.core.asJsonNode
import org.onap.ccsdk.apps.controllerblueprints.core.getAsString
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BlueprintFunctionNode
@@ -118,6 +118,7 @@ abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServic
}
fun getOperationInput(key: String): JsonNode {
- return operationInputs[key] ?: NullNode.instance
+ return operationInputs[key]
+ ?: throw BluePrintProcessorException("couldn't get the operation input($key) value.")
}
} \ No newline at end of file