\r
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput\r
import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction\r
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException\r
+import org.onap.ccsdk.apps.controllerblueprints.core.asJsonNode\r
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils\r
+import org.springframework.beans.factory.annotation.Autowired\r
import org.springframework.beans.factory.config.ConfigurableBeanFactory\r
+import org.springframework.context.ApplicationContext\r
import org.springframework.context.annotation.Scope\r
import org.springframework.stereotype.Component\r
\r
@Component("component-resource-resolution")\r
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)\r
-open class ResourceResolutionComponent : AbstractComponentFunction() {\r
+open class ResourceResolutionComponent(private val resourceResolutionService: ResourceResolutionService) : AbstractComponentFunction() {\r
+\r
+ @Autowired\r
+ private lateinit var applicationContext: ApplicationContext\r
+\r
override fun process(executionRequest: ExecutionServiceInput) {\r
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.\r
+\r
+ val artifactPrefixNamesNode = getOperationInput(ResourceResolutionConstants.INPUT_ARTIFACT_PREFIX_NAMES)\r
+\r
+ val artifactPrefixNames = JacksonUtils.getListFromJsonNode(artifactPrefixNamesNode, String::class.java)\r
+ ?: throw BluePrintProcessorException("coundn't transform ${artifactPrefixNamesNode.asText()} to string array")\r
+\r
+ val resolvedParamContents = resourceResolutionService.resolveResources(bluePrintRuntimeService!!, nodeTemplateName, artifactPrefixNames)\r
+\r
+ // Set Output Attributes\r
+ bluePrintRuntimeService!!.setNodeTemplateAttributeValue(nodeTemplateName,\r
+ ResourceResolutionConstants.OUTPUT_ASSIGNMENT_PARAMS, resolvedParamContents.asJsonNode())\r
}\r
\r
override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {\r
--- /dev/null
+/*
+ * 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
+
+
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
\r
package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution\r
\r
-import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionInput\r
-import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionOutput\r
-import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.Status\r
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor.ResourceAssignmentProcessor\r
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants\r
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException\r
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService\r
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils\r
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment\r
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor\r
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition\r
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.BulkResourceSequencingUtils\r
+import org.slf4j.LoggerFactory\r
import org.springframework.beans.factory.annotation.Autowired\r
import org.springframework.context.ApplicationContext\r
import org.springframework.stereotype.Service\r
+import java.io.File\r
\r
/**\r
* ResourceResolutionService\r
@Service\r
class ResourceResolutionService {\r
\r
+ private val log = LoggerFactory.getLogger(ResourceResolutionService::class.java)\r
\r
@Autowired\r
private lateinit var applicationContext: ApplicationContext\r
\r
- fun resolveResource(resourceResolutionInput: ResourceResolutionInput): ResourceResolutionOutput {\r
- val resourceResolutionOutput = ResourceResolutionOutput()\r
- resourceResolutionOutput.actionIdentifiers = resourceResolutionInput.actionIdentifiers\r
- resourceResolutionOutput.commonHeader = resourceResolutionInput.commonHeader\r
- resourceResolutionOutput.resourceAssignments = resourceResolutionInput.resourceAssignments\r
+ fun registeredResourceSources(): List<String> {\r
+ return applicationContext.getBeanNamesForType(ResourceAssignmentProcessor::class.java)\r
+ .filter { it.startsWith(ResourceResolutionConstants.PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR) }\r
+ .map { it.substringAfter(ResourceResolutionConstants.PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR) }\r
+ }\r
\r
- process(resourceResolutionOutput.resourceAssignments)\r
\r
- val status = Status()\r
- status.code = 200\r
- status.message = "Success"\r
- resourceResolutionOutput.status = status\r
+ fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,\r
+ artifactNames: List<String>): MutableMap<String, String> {\r
\r
- return resourceResolutionOutput\r
+ val resolvedParams: MutableMap<String, String> = hashMapOf()\r
+ artifactNames.forEach { artifactName ->\r
+ val resolvedContent = resolveResources(bluePrintRuntimeService, nodeTemplateName, artifactName)\r
+ resolvedParams[artifactName] = resolvedContent\r
+ }\r
+ return resolvedParams\r
}\r
\r
- fun registeredResourceSources(): List<String> {\r
- return applicationContext.getBeanNamesForType(ResourceAssignmentProcessor::class.java)\r
- .filter { it.startsWith(ResourceResolutionConstants.PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR) }\r
- .map { it.substringAfter(ResourceResolutionConstants.PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR) }\r
+\r
+ fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String, artifactName: String): String {\r
+\r
+ var resolvedContent = ""\r
+ // Velocity Artifact Definition Name\r
+ val templateArtifactName = "$artifactName-template"\r
+ // Resource Assignment Artifact Definition Name\r
+ val mappingArtifactName = "$artifactName-mapping"\r
+\r
+ log.info("Resolving resource for template artifact($templateArtifactName) with resource assignment artifact($mappingArtifactName)")\r
+\r
+ val resourceAssignmentContent = bluePrintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, mappingArtifactName)\r
+\r
+ val resourceAssignments: MutableList<ResourceAssignment> = JacksonUtils.getListFromJson(resourceAssignmentContent, ResourceAssignment::class.java)\r
+ as? MutableList<ResourceAssignment>\r
+ ?: throw BluePrintProcessorException("couldn't get Dictionary Definitions")\r
+\r
+ // Get the Resource Dictionary Name\r
+ val dictionaryFile = bluePrintRuntimeService.bluePrintContext().rootPath.plus(File.separator)\r
+ .plus(BluePrintConstants.TOSCA_DEFINITIONS_DIR).plus(File.separator)\r
+ .plus(ResourceResolutionConstants.FILE_NAME_RESOURCE_DICTIONARY_TYPES)\r
+\r
+ val resourceDictionaries: MutableMap<String, ResourceDefinition> = JacksonUtils.getMapFromFile(dictionaryFile, ResourceDefinition::class.java)\r
+ ?: throw BluePrintProcessorException("couldn't get Dictionary Definitions")\r
+\r
+ executeProcessors(bluePrintRuntimeService, resourceDictionaries, resourceAssignments)\r
+\r
+ // Check Template is there\r
+ val templateContent = bluePrintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, mappingArtifactName)\r
+\r
+ // TODO ("Generate Param JSON from Resource Assignment")\r
+ val resolvedParamJsonContent = "{}"\r
+\r
+ if (templateContent.isNotEmpty()) {\r
+ // TODO ( "Mash Data and Content")\r
+ resolvedContent = "Mashed Content"\r
+\r
+ } else {\r
+ resolvedContent = resolvedParamJsonContent\r
+ }\r
+ return resolvedContent\r
}\r
\r
- fun process(resourceAssignments: MutableList<ResourceAssignment>) {\r
+\r
+ fun executeProcessors(bluePrintRuntimeService: BluePrintRuntimeService<*>,\r
+ resourceDictionaries: MutableMap<String, ResourceDefinition>,\r
+ resourceAssignments: MutableList<ResourceAssignment>) {\r
\r
val bulkSequenced = BulkResourceSequencingUtils.process(resourceAssignments)\r
\r
?: throw BluePrintProcessorException("failed to get resource processor for instance name($processorInstanceName) " +\r
"for resource assignment(${resourceAssignment.name})")\r
try {\r
+ // Set BluePrint Runtime Service\r
+ resourceAssignmentProcessor.bluePrintRuntimeService = bluePrintRuntimeService\r
+ // Set Resource Dictionaries\r
+ resourceAssignmentProcessor.resourceDictionaries = resourceDictionaries\r
// Invoke Apply Method\r
resourceAssignmentProcessor.apply(resourceAssignment)\r
} catch (e: RuntimeException) {\r
}\r
}\r
}\r
+\r
}\r
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
/**
package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor\r
\r
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment\r
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor\r
import org.springframework.stereotype.Service\r
\r
/**\r
package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolutionprocessor\r
\r
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment\r
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor\r
import org.springframework.stereotype.Service\r
\r
/**\r
--- /dev/null
+/*
+ * 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.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)
+
+ var bluePrintRuntimeService: BluePrintRuntimeService<*>? = null
+
+ var resourceDictionaries: Map<String, ResourceDefinition> = hashMapOf()
+
+
+ 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 for ${resourceAssignment.name}, dictionary(${resourceAssignment.dictionaryName})," +
+ "source(${resourceAssignment.dictionarySource})")
+ return resourceAssignment
+ }
+
+ override fun prepareResponse(): ResourceAssignment {
+ log.info("Preparing Response...")
+ return ResourceAssignment()
+ }
+
+ override fun apply(executionServiceInput: ResourceAssignment): ResourceAssignment {
+ prepareRequest(executionServiceInput)
+ process(executionServiceInput)
+ return prepareResponse()
+ }
+
+ override abstract fun process(executionRequest: ResourceAssignment)
+
+ override abstract fun recover(runtimeException: RuntimeException, executionRequest: ResourceAssignment)
+}
\ No newline at end of file
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
/**
--- /dev/null
+/*
+ * 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
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
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")
}
"timestamp": "2012-04-23T18:25:43.511Z"\r
},\r
"payload": {\r
- },\r
- "resourceAssignments": [\r
- ]\r
+ "resource-assignment-request": {\r
+ "resource-assignment-properties": {\r
+ "request-id": "1234",\r
+ "action-name": "assign-activate",\r
+ "scope-type": "vnf-type",\r
+ "hostname": "localhost"\r
+ }\r
+ }\r
+ }\r
}\r
import com.fasterxml.jackson.annotation.JsonFormat\r
import com.fasterxml.jackson.databind.node.ObjectNode\r
import io.swagger.annotations.ApiModelProperty\r
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment\r
import java.util.*\r
\r
/**\r
* DATE : 8/15/2018\r
*/\r
\r
-open class ResourceResolutionInput {\r
- @get:ApiModelProperty(required = true)\r
- lateinit var commonHeader: CommonHeader\r
- @get:ApiModelProperty(required = true)\r
- lateinit var actionIdentifiers: ActionIdentifiers\r
- @get:ApiModelProperty(required = true)\r
- lateinit var resourceAssignments: MutableList<ResourceAssignment>\r
- @get:ApiModelProperty(required = true)\r
- lateinit var payload: ObjectNode\r
-}\r
-\r
-open class ResourceResolutionOutput {\r
- @get:ApiModelProperty(required = true)\r
- lateinit var commonHeader: CommonHeader\r
- @get:ApiModelProperty(required = true)\r
- lateinit var actionIdentifiers: ActionIdentifiers\r
- @get:ApiModelProperty(required = true)\r
- lateinit var status: Status\r
- @get:ApiModelProperty(required = true)\r
- lateinit var resourceAssignments: MutableList<ResourceAssignment>\r
-}\r
-\r
open class ExecutionServiceInput {\r
@get:ApiModelProperty(required = true)\r
lateinit var commonHeader: CommonHeader\r
--- /dev/null
+/*
+ * 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
\r
package org.onap.ccsdk.apps.blueprintsprocessor.resource.api;\r
\r
-import io.swagger.annotations.ApiOperation;\r
-import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionInput;\r
-import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionOutput;\r
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceResolutionService;\r
import org.springframework.http.MediaType;\r
-import org.springframework.web.bind.annotation.*;\r
+import org.springframework.web.bind.annotation.RequestMapping;\r
+import org.springframework.web.bind.annotation.RequestMethod;\r
+import org.springframework.web.bind.annotation.ResponseBody;\r
+import org.springframework.web.bind.annotation.RestController;\r
import reactor.core.publisher.Mono;\r
\r
/**\r
Mono<String> ping() {\r
return Mono.just("Success");\r
}\r
-\r
- @RequestMapping(path = "/resolve-mapping", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)\r
- @ApiOperation(value = "Resolve Resource Mappings",\r
- notes = "Also returns a link to retrieve all students with rel - all-students")\r
- public @ResponseBody\r
- Mono<ResourceResolutionOutput> resolveResource(@RequestBody ResourceResolutionInput resourceResolutionInput) {\r
- return Mono.just(resourceResolutionService.resolveResource(resourceResolutionInput));\r
- }\r
}\r
\r
import com.fasterxml.jackson.databind.JsonNode\r
import com.fasterxml.jackson.databind.node.JsonNodeFactory\r
-import com.fasterxml.jackson.databind.node.NullNode\r
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput\r
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceOutput\r
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.Status\r
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants\r
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException\r
import org.onap.ccsdk.apps.controllerblueprints.core.asJsonNode\r
import org.onap.ccsdk.apps.controllerblueprints.core.getAsString\r
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BlueprintFunctionNode\r
}\r
\r
fun getOperationInput(key: String): JsonNode {\r
- return operationInputs[key] ?: NullNode.instance\r
+ return operationInputs[key]\r
+ ?: throw BluePrintProcessorException("couldn't get the operation input($key) value.")\r
}\r
}
\ No newline at end of file