Merge "fixed sonar issue in AssignVlanTagResponse"
authorDan Timoney <dtimoney@att.com>
Tue, 11 Dec 2018 17:37:55 +0000 (17:37 +0000)
committerGerrit Code Review <gerrit@onap.org>
Tue, 11 Dec 2018 17:37:55 +0000 (17:37 +0000)
124 files changed:
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctions.kt
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintFunctionNode.kt
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintArchiveUtils.kt [new file with mode: 0644]
components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt
components/model-catalog/api-definition/proto/BluePrintManagement.proto [new file with mode: 0644]
components/model-catalog/api-definition/proto/BluePrintProcessing.proto [new file with mode: 0644]
components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/activation-blueprint.json
components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/baseconfig-mapping.json
components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/data_types.json
components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/node_types.json
components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_dictionary_types.json [new file with mode: 0644]
components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Definitions/resources_dictionaty_types.json [deleted file]
components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/CONFIG_ActivateNetconf_1.0.0.xml
components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/CONFIG_AssignActivateNetconf_1.0.0.xml [moved from ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/service-logic/two-component.xml with 94% similarity]
components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration/Plans/CONFIG_ResourceAssignment_1.0.0.xml [moved from ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/service-logic/one-component.xml with 95% similarity]
components/model-catalog/definition-type/starter-type/node_type/component-resource-assignment.json
components/parent/pom.xml
ms/blueprintsprocessor/.gitignore
ms/blueprintsprocessor/application/pom.xml
ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/BlueprintGRPCServer.java [new file with mode: 0644]
ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/BlueprintHttpServer.java [new file with mode: 0644]
ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/SwaggerConfig.java
ms/blueprintsprocessor/application/src/main/resources/application.properties
ms/blueprintsprocessor/application/src/test/java/org/onap/ccsdk/apps/blueprintsprocessor/BlueprintProcessorApplicationTest.java
ms/blueprintsprocessor/application/src/test/resources/application.properties [new file with mode: 0644]
ms/blueprintsprocessor/functions/netconf-executor/pom.xml [new file with mode: 0644]
ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutor.kt [new file with mode: 0644]
ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/JsonParserService.kt [moved from ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionConstants.kt with 73% similarity]
ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfExecutorConfiguration.kt [new file with mode: 0644]
ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfRpcService.kt [new file with mode: 0644]
ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutorTest.kt [new file with mode: 0644]
ms/blueprintsprocessor/functions/netconf-executor/src/test/resources/logback-test.xml [new file with mode: 0644]
ms/blueprintsprocessor/functions/pom.xml
ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/ComponentJythonExecutor.kt
ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/JythonExecutionService.kt
ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/PythonExecutorConfiguration.kt
ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/ComponentJythonExecutorTest.kt
ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/mock/MockInstanceConfiguration.kt [new file with mode: 0644]
ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt [new file with mode: 0644]
ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConfiguration.kt [new file with mode: 0644]
ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt [new file with mode: 0644]
ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt [new file with mode: 0644]
ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/DataBaseResourceAssignmentProcessor.kt [moved from ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DataBaseResourceAssignmentProcessor.kt with 86% similarity]
ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/DefaultResourceAssignmentProcessor.kt [moved from ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DefaultResourceAssignmentProcessor.kt with 83% similarity]
ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/InputResourceAssignmentProcessor.kt [moved from ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/InputResourceAssignmentProcessor.kt with 84% similarity]
ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/ResourceAssignmentProcessor.kt [moved from components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/ResourceAssignmentProcessor.kt with 66% similarity]
ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolutionprocessor/SimpleRestResourceAssignmentProcessor.kt [moved from ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/SimpleRestResourceAssignmentProcessor.kt with 86% similarity]
ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionComponent.kt [deleted file]
ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt [deleted file]
ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt [new file with mode: 0644]
ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt [new file with mode: 0644]
ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionServiceTest.kt [deleted file]
ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/payload/requests/sample-resourceresolution-request.json
ms/blueprintsprocessor/modules/commons/core/pom.xml
ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintCoreConfiguration.kt [new file with mode: 0644]
ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintProperties.kt [new file with mode: 0644]
ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt
ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ResourceAssignmentProcessorFactory.kt [deleted file]
ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/interfaces/BluePrintCatalogService.kt [new file with mode: 0644]
ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/utils/PayloadUtils.kt [new file with mode: 0644]
ms/blueprintsprocessor/modules/commons/db-lib/pom.xml
ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BluePrintDBLibConfiguration.kt [new file with mode: 0644]
ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BluePrintDBLibData.kt [new file with mode: 0644]
ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BluePrintDBLibGenericService.kt [new file with mode: 0644]
ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/PrimaryDatabaseConfiguration.kt [new file with mode: 0644]
ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/service/PrimaryDBLibGenericService.kt [new file with mode: 0644]
ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/PrimaryDatabaseConfigurationTest.kt [new file with mode: 0644]
ms/blueprintsprocessor/modules/commons/db-lib/src/test/resources/application-test.properties [new file with mode: 0644]
ms/blueprintsprocessor/modules/commons/db-lib/src/test/resources/logback-test.xml [new file with mode: 0644]
ms/blueprintsprocessor/modules/commons/pom.xml
ms/blueprintsprocessor/modules/commons/rest-lib/pom.xml
ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibConfiguration.kt [new file with mode: 0644]
ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibData.kt [new file with mode: 0644]
ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BasicAuthRestClientService.kt [new file with mode: 0644]
ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BluePrintRestLibPropertyService.kt [new file with mode: 0644]
ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BlueprintWebClientService.kt [new file with mode: 0644]
ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/DME2ProxyRestClientService.kt [new file with mode: 0644]
ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/SSLBasicAuthRestClientService.kt [new file with mode: 0644]
ms/blueprintsprocessor/modules/commons/rest-lib/src/main/resources/application.properties [new file with mode: 0644]
ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/RestPropertyPlaceHolderConfigurationTest.kt [new file with mode: 0644]
ms/blueprintsprocessor/modules/commons/rest-lib/src/test/resources/logback-test.xml [new file with mode: 0644]
ms/blueprintsprocessor/modules/inbounds/pom.xml
ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/resource/api/ResourceResolutionController.java
ms/blueprintsprocessor/modules/inbounds/selfservice-api/pom.xml
ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintCatalogServiceImpl.kt [new file with mode: 0644]
ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintManagementGRPCHandler.kt [new file with mode: 0644]
ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandler.kt [new file with mode: 0644]
ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt [new file with mode: 0644]
ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintManagementGRPCHandlerTest.kt [new file with mode: 0644]
ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandlerTest.kt [new file with mode: 0644]
ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceHandlerTest.kt [new file with mode: 0644]
ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/mock/SelfServiceApiMocks.kt [new file with mode: 0644]
ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/application-test.properties [new file with mode: 0644]
ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/execution-input/default-input.json [new file with mode: 0644]
ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/execution-input/sample-payload.json [new file with mode: 0644]
ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/logback.xml [new file with mode: 0644]
ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/test-cba.zip [new file with mode: 0644]
ms/blueprintsprocessor/modules/services/execution-service/pom.xml
ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt
ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintDGExecutionService.kt
ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/executor/ComponentExecuteNodeExecutor.kt
ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintDGExecutionServiceTest.kt
ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintServiceLogicTest.kt
ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/mock/MockComponentFunction.kt
ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/execution-input/assign-activate-input.json [new file with mode: 0644]
ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/execution-input/default-input.json [deleted file]
ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/execution-input/resource-assignment-input.json [new file with mode: 0644]
ms/blueprintsprocessor/parent/pom.xml
ms/controllerblueprints/application/src/main/java/org/onap/ccsdk/apps/controllerblueprints/SwaggerConfig.java
ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/BluePrintEnhancerService.java
ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelCreateService.java
ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/ConfigModelService.java
ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceAssignmentEnhancerServiceTest.java
ms/controllerblueprints/parent/pom.xml
ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/Application.java
ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicySequence.java
ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/policy/PropertyOperator.java
ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/service/rs/RestServiceImpl.java
ms/vlantag-api/src/main/java/org/onap/ccsdk/apps/ms/vlantagapi/core/extinf/pm/model/PolicyEngineResponse.java
ms/vlantag-api/src/main/java/org/onap/ccsdk/apps/ms/vlantagapi/core/model/AssignVlanTagRequest.java

index 0517e90..167496e 100644 (file)
@@ -29,6 +29,9 @@ object BluePrintConstants {
     const val RESPONSE_HEADER_PATCH_VERSION: String = "X-PatchVersion"\r
     const val RESPONSE_HEADER_LATEST_VERSION: String = "X-LatestVersion"\r
 \r
+    const val STATUS_SUCCESS: String = "success"\r
+    const val STATUS_FAILURE: String = "failure"\r
+\r
     const val TYPE_DEFAULT: String = "default"\r
 \r
     const val DATA_TYPE_STRING: String = "string"\r
index c32e15f..4d1d9b6 100644 (file)
@@ -49,6 +49,10 @@ fun Double.asJsonPrimitive(): DoubleNode {
     return DoubleNode.valueOf(this)\r
 }\r
 \r
+fun MutableMap<String, *>.asJsonNode(): JsonNode {\r
+    return JacksonUtils.jsonNodeFromObject(this)\r
+}\r
+\r
 fun format(message: String, vararg args: Any?): String {\r
     if (args != null && args.isNotEmpty()) {\r
         return MessageFormatter.arrayFormat(message, args).message\r
@@ -75,17 +79,17 @@ fun <T : Any> MutableMap<String, *>.castValue(key: String, valueType: KClass<T>)
 fun MutableMap<String, JsonNode>.putJsonElement(key: String, value: Any) {\r
     when (value) {\r
         is JsonNode ->\r
-            this.put(key, value)\r
+            this[key] = value\r
         is String ->\r
-            this.put(key, TextNode(value))\r
+            this[key] = TextNode(value)\r
         is Boolean ->\r
-            this.put(key, BooleanNode.valueOf(value))\r
+            this[key] = BooleanNode.valueOf(value)\r
         is Int ->\r
-            this.put(key, IntNode.valueOf(value.toInt()))\r
+            this[key] = IntNode.valueOf(value.toInt())\r
         is Double ->\r
-            this.put(key, DoubleNode.valueOf(value.toDouble()))\r
+            this[key] = DoubleNode.valueOf(value.toDouble())\r
         else ->\r
-            this.put(key, JacksonUtils.jsonNodeFromObject(value))\r
+            this[key] = JacksonUtils.jsonNodeFromObject(value)\r
     }\r
 }\r
 \r
@@ -97,6 +101,14 @@ fun MutableMap<String, JsonNode>.getAsBoolean(key: String): Boolean {
     return this[key]?.asBoolean() ?: throw BluePrintException("couldn't find value for key($key)")\r
 }\r
 \r
+fun MutableMap<String, JsonNode>.getAsInt(key: String): Int {\r
+    return this[key]?.asInt() ?: throw BluePrintException("couldn't find value for key($key)")\r
+}\r
+\r
+fun MutableMap<String, JsonNode>.getAsDouble(key: String): Double {\r
+    return this[key]?.asDouble() ?: throw BluePrintException("couldn't find value for key($key)")\r
+}\r
+\r
 // Checks\r
 \r
 fun checkNotEmpty(value: String?): Boolean {\r
index cce6d90..84af3f9 100644 (file)
@@ -57,6 +57,8 @@ class BluePrintContext(val serviceTemplate: ServiceTemplate) {
     fun workflowByName(workFlowName: String): Workflow = workflows?.get(workFlowName)\r
             ?: throw BluePrintException("could't get workflow($workFlowName)")\r
 \r
+    fun workflowInputs(workFlowName: String) = workflowByName(workFlowName).inputs\r
+\r
     fun workflowStepByName(workFlowName: String, stepName: String): Step {\r
         return workflowByName(workFlowName).steps?.get(stepName)\r
                 ?: throw BluePrintException("could't get step($stepName) for workflow($workFlowName)")\r
index 84ba104..448a06a 100644 (file)
@@ -25,7 +25,6 @@ import com.fasterxml.jackson.databind.node.NullNode
 import com.fasterxml.jackson.databind.node.ObjectNode\r
 import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper\r
 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants\r
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException\r
 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException\r
 import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactDefinition\r
 import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate\r
@@ -211,15 +210,13 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
 \r
         val propertyAssignments: MutableMap<String, Any> =\r
                 bluePrintContext.nodeTemplateInterfaceOperationInputs(nodeTemplateName, interfaceName, operationName) as? MutableMap<String, Any>\r
-                        ?: throw BluePrintException(String.format("failed to get input definitions for node template (%s), " +\r
-                                "interface name (%s), operationName(%s)", nodeTemplateName, interfaceName, operationName))\r
+                        ?: hashMapOf()\r
 \r
         val nodeTypeName = bluePrintContext.nodeTemplateByName(nodeTemplateName).type\r
 \r
         val nodeTypeInterfaceOperationInputs: MutableMap<String, PropertyDefinition> =\r
                 bluePrintContext.nodeTypeInterfaceOperationInputs(nodeTypeName, interfaceName, operationName)\r
-                        ?: throw BluePrintException(String.format("failed to get input definitions for node type (%s), " +\r
-                                "interface name (%s), operationName(%s)", nodeTypeName, interfaceName, operationName))\r
+                        ?: hashMapOf()\r
 \r
         log.info("input definition for node template ({}), values ({})", nodeTemplateName, propertyAssignments)\r
 \r
@@ -258,15 +255,13 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
 \r
         val propertyAssignments: MutableMap<String, Any> =\r
                 bluePrintContext.nodeTemplateInterfaceOperationOutputs(nodeTemplateName, interfaceName, operationName) as? MutableMap<String, Any>\r
-                        ?: throw BluePrintException(String.format("failed to get output definitions for node template (%s), " +\r
-                                "interface name (%s), operationName(%s)", nodeTemplateName, interfaceName, operationName))\r
+                        ?: hashMapOf()\r
 \r
         val nodeTypeName = bluePrintContext.nodeTemplateByName(nodeTemplateName).type\r
 \r
         val nodeTypeInterfaceOperationOutputs: MutableMap<String, PropertyDefinition> =\r
                 bluePrintContext.nodeTypeInterfaceOperationOutputs(nodeTypeName, interfaceName, operationName)\r
-                        ?: throw BluePrintException(String.format("failed to get input definitions for node type (%s), " +\r
-                                "interface name (%s), operationName(%s)", nodeTypeName, interfaceName, operationName))\r
+                        ?: hashMapOf()\r
 \r
         // Iterate Node Type Properties\r
         nodeTypeInterfaceOperationOutputs.forEach { nodeTypePropertyName, nodeTypeProperty ->\r
@@ -435,10 +430,25 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
     override fun assignWorkflowInputs(workflowName: String, jsonNode: JsonNode) {\r
         log.info("assign workflow {} input value ({})", workflowName, jsonNode.toString())\r
 \r
+        val dynamicInputPropertiesName = "$workflowName-properties"\r
+\r
         bluePrintContext.workflowByName(workflowName).inputs?.forEach { propertyName, property ->\r
-            val valueNode: JsonNode = jsonNode.at(BluePrintConstants.PATH_DIVIDER + propertyName)\r
-                    ?: NullNode.getInstance()\r
-            setInputValue(propertyName, property, valueNode)\r
+            if (propertyName != dynamicInputPropertiesName) {\r
+                val valueNode: JsonNode = jsonNode.at(BluePrintConstants.PATH_DIVIDER + propertyName)\r
+                        ?: NullNode.getInstance()\r
+                setInputValue(propertyName, property, valueNode)\r
+            }\r
+        }\r
+\r
+        val workflowDynamicInputs: JsonNode? = jsonNode.get(dynamicInputPropertiesName)\r
+\r
+        workflowDynamicInputs?.let {\r
+            bluePrintContext.dataTypeByName(dynamicInputPropertiesName)?.properties?.forEach { propertyName, property ->\r
+                val valueNode: JsonNode = workflowDynamicInputs.at(BluePrintConstants.PATH_DIVIDER + propertyName)\r
+                        ?: NullNode.getInstance()\r
+                setInputValue(propertyName, property, valueNode)\r
+\r
+            }\r
         }\r
     }\r
 \r
index 947eb41..36c141f 100644 (file)
@@ -197,8 +197,7 @@ If Property Assignment is Expression.
     }\r
 \r
     fun artifactContent(artifactDefinition: ArtifactDefinition): String {\r
-        val bluePrintBasePath: String = bluePrintRuntimeService.get(BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH)?.asText()\r
-                ?: throw BluePrintException("failed to get property (${BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH}) from getStore")\r
+        val bluePrintBasePath: String = bluePrintContext.rootPath\r
 \r
         if (artifactDefinition.repository != null) {\r
             TODO()\r
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintArchiveUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintArchiveUtils.kt
new file mode 100644 (file)
index 0000000..f02524f
--- /dev/null
@@ -0,0 +1,148 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.core.utils
+
+import org.apache.commons.compress.archivers.zip.ZipArchiveEntry
+import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream
+import org.apache.commons.io.IOUtils
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import java.io.*
+import java.nio.charset.Charset
+import java.util.zip.ZipFile
+
+class BluePrintArchiveUtils {
+
+    companion object {
+
+
+        fun compress(source: String, destination: String, absolute: Boolean): Boolean {
+            val rootDir = File(source)
+            val saveFile = File(destination)
+            return compress(rootDir, saveFile, absolute)
+        }
+
+        /**
+         * Create a new Zip from a root directory
+         *
+         * @param directory the base directory
+         * @param filename the output filename
+         * @param absolute store absolute filepath (from directory) or only filename
+         * @return True if OK
+         */
+        fun compress(source: File, destination: File, absolute: Boolean): Boolean {
+            // recursive call
+            val zaos: ZipArchiveOutputStream
+            try {
+                zaos = ZipArchiveOutputStream(FileOutputStream(destination))
+            } catch (e: FileNotFoundException) {
+                return false
+            }
+
+            try {
+                recurseFiles(source, source, zaos, absolute)
+            } catch (e2: IOException) {
+                try {
+                    zaos.close()
+                } catch (e: IOException) {
+                    // ignore
+                }
+
+                return false
+            }
+
+            try {
+                zaos.finish()
+            } catch (e1: IOException) {
+                // ignore
+            }
+
+            try {
+                zaos.flush()
+            } catch (e: IOException) {
+                // ignore
+            }
+
+            try {
+                zaos.close()
+            } catch (e: IOException) {
+                // ignore
+            }
+
+            return true
+        }
+
+        /**
+         * Recursive traversal to add files
+         *
+         * @param root
+         * @param file
+         * @param zaos
+         * @param absolute
+         * @throws IOException
+         */
+        @Throws(IOException::class)
+        private fun recurseFiles(root: File, file: File, zaos: ZipArchiveOutputStream,
+                                 absolute: Boolean) {
+            if (file.isDirectory) {
+                // recursive call
+                val files = file.listFiles()
+                for (file2 in files!!) {
+                    recurseFiles(root, file2, zaos, absolute)
+                }
+            } else if (!file.name.endsWith(".zip") && !file.name.endsWith(".ZIP")) {
+                var filename: String? = null
+                if (absolute) {
+                    filename = file.absolutePath.substring(root.absolutePath.length)
+                } else {
+                    filename = file.name
+                }
+                val zae = ZipArchiveEntry(filename)
+                zae.setSize(file.length())
+                zaos.putArchiveEntry(zae)
+                val fis = FileInputStream(file)
+                IOUtils.copy(fis, zaos)
+                zaos.closeArchiveEntry()
+            }
+        }
+
+
+        fun deCompress(zipFile: File, targetPath: String): File {
+            val zip = ZipFile(zipFile, Charset.defaultCharset())
+            val enumeration = zip.entries()
+            while (enumeration.hasMoreElements()) {
+                val entry = enumeration.nextElement()
+                val destFilePath = File(targetPath, entry.name)
+                destFilePath.parentFile.mkdirs()
+                if (entry.isDirectory)
+                    continue
+                val bufferedIs = BufferedInputStream(zip.getInputStream(entry))
+                bufferedIs.use {
+                    destFilePath.outputStream().buffered(1024).use { bos ->
+                        bufferedIs.copyTo(bos)
+                    }
+                }
+            }
+
+            val destinationDir = File(targetPath)
+            check(destinationDir.isDirectory && destinationDir.exists()) {
+                throw BluePrintProcessorException("failed to decompress blueprint(${zipFile.absolutePath}) to ($targetPath) ")
+            }
+            return destinationDir
+        }
+    }
+
+}
\ No newline at end of file
index f53f861..4021014 100644 (file)
@@ -121,6 +121,11 @@ object JacksonUtils {
         return objectMapper.writeValueAsString(any)\r
     }\r
 \r
+    @JvmStatic\r
+    fun <T> getListFromJsonNode(node: JsonNode, valueType: Class<T>): List<T>? {\r
+        return getListFromJson(node.toString(), valueType)\r
+    }\r
+\r
     @JvmStatic\r
     fun <T> getListFromJson(content: String, valueType: Class<T>): List<T>? {\r
         val objectMapper = jacksonObjectMapper()\r
@@ -148,6 +153,13 @@ object JacksonUtils {
         return objectMapper.readValue(content, typeRef)\r
     }\r
 \r
+    @JvmStatic\r
+    fun <T> getMapFromFile(fileName: String, valueType: Class<T>): MutableMap<String, T>? {\r
+        val content: String = FileUtils.readFileToString(File(fileName), Charset.defaultCharset())\r
+                ?: throw BluePrintException(format("Failed to read json file : {}", fileName))\r
+        return getMapFromJson(content, valueType)\r
+    }\r
+\r
     @JvmStatic\r
     fun checkJsonNodeValueOfType(type: String, jsonNode: JsonNode): Boolean {\r
         if (BluePrintTypes.validPrimitiveTypes().contains(type)) {\r
diff --git a/components/model-catalog/api-definition/proto/BluePrintManagement.proto b/components/model-catalog/api-definition/proto/BluePrintManagement.proto
new file mode 100644 (file)
index 0000000..55f9466
--- /dev/null
@@ -0,0 +1,56 @@
+syntax = "proto3";
+option java_multiple_files = true;
+package org.onap.ccsdk.apps.controllerblueprints.management.api;
+
+message BluePrintUploadInput {
+    CommonHeader commonHeader = 1;
+    string blueprintName = 2;
+    string blueprintVersion = 3;
+    FileChunk fileChunk = 4;
+}
+
+message FileChunk {
+    bytes chunk = 1;
+}
+
+message BluePrintUploadOutput {
+    CommonHeader commonHeader = 1;
+    Status status = 3;
+}
+
+message BluePrintRemoveInput {
+    CommonHeader commonHeader = 1;
+    string blueprintName = 2;
+    string blueprintVersion = 3;
+}
+
+message BluePrintRemoveOutput {
+    CommonHeader commonHeader = 1;
+    Status status = 3;
+}
+
+message CommonHeader {
+    string timestamp = 1;
+    string originatorId = 23;
+    string requestId = 3;
+    string subRequestId = 4;
+}
+
+message ActionIdentifiers {
+    string blueprintName = 1;
+    string blueprintVersion = 2;
+    string actionName = 3;
+    string mode = 4;
+}
+
+message Status {
+    string timestamp = 1;
+    int32 code = 2;
+    string message = 3;
+    string errorMessage = 4;
+}
+
+service BluePrintManagementService {
+    rpc uploadBlueprint (BluePrintUploadInput) returns (BluePrintUploadOutput);
+    rpc removeBlueprint (BluePrintRemoveInput) returns (BluePrintRemoveOutput);
+}
diff --git a/components/model-catalog/api-definition/proto/BluePrintProcessing.proto b/components/model-catalog/api-definition/proto/BluePrintProcessing.proto
new file mode 100644 (file)
index 0000000..8fa4a13
--- /dev/null
@@ -0,0 +1,49 @@
+syntax = "proto3";
+import "google/protobuf/struct.proto";
+option java_multiple_files = true;
+package org.onap.ccsdk.apps.controllerblueprints.processing.api;
+
+message ExecutionServiceInput {
+    CommonHeader commonHeader = 1;
+    ActionIdentifiers actionIdentifiers = 2;
+    google.protobuf.Struct payload = 3;
+}
+
+message ExecutionServiceOutput {
+    CommonHeader commonHeader = 1;
+    ActionIdentifiers actionIdentifiers = 2;
+    Status status = 3;
+    google.protobuf.Struct payload = 4;
+}
+
+message CommonHeader {
+    string timestamp = 1;
+    string originatorId = 23;
+    string requestId = 3;
+    string subRequestId = 4;
+    Flag flag = 5;
+}
+
+message Flag {
+    bool isForce = 1;
+    int32 ttl = 2;
+}
+
+message ActionIdentifiers {
+    string blueprintName = 1;
+    string blueprintVersion = 2;
+    string actionName = 3;
+    string mode = 4;
+}
+
+message Status {
+    int32 code = 1;
+    string errorMessage = 2;
+    string message = 3;
+    string eventType = 4;
+    string timestamp = 5;
+}
+
+service BluePrintProcessingService {
+    rpc process (ExecutionServiceInput) returns (stream ExecutionServiceOutput);
+}
index 04e0efc..446932d 100644 (file)
       }
     },
     "node_templates": {
+      "resource-assignment-process": {
+        "type": "dg-activate",
+        "properties": {
+          "process-name": {
+            "get_input": "action-name"
+          },
+          "version": {
+            "get_property": [
+              "SELF",
+              "process-name"
+            ]
+          },
+          "content": {
+            "get_artifact": [
+              "SELF",
+              "dg-resource-assignment-process"
+            ]
+          }
+        },
+        "artifacts": {
+          "dg-resource-assignment-process": {
+            "type": "artifact-directed-graph",
+            "file": "Plans/CONFIG_ResourceAssignment_1.0.0.xml"
+          }
+        }
+      },
       "activate-process": {
         "type": "dg-activate",
         "properties": {
           }
         }
       },
+      "assign-activate-process": {
+        "type": "dg-activate",
+        "properties": {
+          "process-name": {
+            "get_input": "action-name"
+          },
+          "version": {
+            "get_property": [
+              "SELF",
+              "process-name"
+            ]
+          },
+          "content": {
+            "get_artifact": [
+              "SELF",
+              "dg-assign-activate-process"
+            ]
+          }
+        },
+        "artifacts": {
+          "dg-assign-activate-process": {
+            "type": "artifact-directed-graph",
+            "file": "Plans/CONFIG_AssignActivateNetconf_1.0.0.xml"
+          }
+        }
+      },
       "resource-assignment": {
         "type": "component-resource-assignment",
         "properties": {
                   "resource-id": {
                     "get_input": "hostname"
                   },
+                  "artifact-prefix-names": [
+                    "baseconfig"
+                  ],
                   "template-content": {
                     "get_artifact": [
                       "SELF",
                 "implementation": {
                   "primary": "component-script"
                 },
+                "inputs": {
+                  "instance-dependencies": [
+                    "json-parser-service",
+                    "netconf-rpc-service"
+                  ]
+                },
                 "outputs": {
                   "response-data": "",
                   "status": ""
     "workflows": {
       "resource-assignment": {
         "inputs": {
-          "request-id": {
-            "required": true,
-            "type": "string"
-          },
-          "action-name": {
-            "required": true,
-            "type": "string"
-          },
-          "scope-type": {
+          "resource-assignment-properties": {
             "required": true,
-            "type": "string"
-          },
-          "hostname": {
-            "required": true,
-            "type": "string"
+            "type": "resource-assignment-properties"
           }
         },
         "steps": {
           "call-resource-assignment": {
             "description": "Resource Assignment Workflow",
-            "target": "resource-assignment",
+            "target": "resource-assignment-process",
             "activities": [
               {
-                "call_operation": "ResourceAssignmentComponent.process"
+                "call_operation": "CONFIG.ResourceAssignment"
               }
             ]
           }
       },
       "activate": {
         "inputs": {
-          "request-id": {
-            "required": true,
-            "type": "string"
-          },
-          "action-name": {
+          "activate-properties": {
             "required": true,
-            "type": "string"
-          },
-          "scope-type": {
-            "required": true,
-            "type": "string"
-          },
-          "hostname": {
-            "required": true,
-            "type": "string"
+            "type": "activate-properties"
           }
         },
         "steps": {
             "target": "activate-process",
             "activities": [
               {
-                "call_operation": "ResourceAssignmentComponent.process"
+                "call_operation": "CONFIG.ActivateProcess"
+              }
+            ]
+          }
+        }
+      },
+      "assign-activate": {
+        "inputs": {
+          "assign-activate-properties": {
+            "required": true,
+            "type": "assign-activate-properties"
+          }
+        },
+        "steps": {
+          "activate-process": {
+            "description": "Resource Assign and Netconf Activation Workflow",
+            "target": "assign-activate-process",
+            "activities": [
+              {
+                "call_operation": "CONFIG.AssignActivateProcess"
               }
             ]
           }
index caee773..c457086 100644 (file)
@@ -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"
+    ]
+  }
+]
index 6ca1ffd..569b668 100644 (file)
         }
       },
       "derived_from": "tosca.datatypes.Root"
+    },
+    "activate-properties": {
+      "description": "This is Dynamically generated data type for workflow activate",
+      "version": "1.0.0",
+      "properties": {
+        "request-id": {
+          "required": true,
+          "type": "string"
+        },
+        "action-name": {
+          "required": true,
+          "type": "string"
+        },
+        "scope-type": {
+          "required": true,
+          "type": "string"
+        },
+        "hostname": {
+          "required": true,
+          "type": "string"
+        }
+      },
+      "derived_from": "tosca.datatypes.Root"
+    },
+    "resource-assignment-properties": {
+      "description": "This is Dynamically generated data type for workflow activate",
+      "version": "1.0.0",
+      "properties": {
+        "request-id": {
+          "required": true,
+          "type": "string"
+        },
+        "action-name": {
+          "required": true,
+          "type": "string"
+        },
+        "scope-type": {
+          "required": true,
+          "type": "string"
+        },
+        "hostname": {
+          "required": true,
+          "type": "string"
+        }
+      },
+      "derived_from": "tosca.datatypes.Root"
+    },
+    "assign-activate-properties": {
+      "description": "This is Dynamically generated data type for workflow assign-activate",
+      "version": "1.0.0",
+      "properties": {
+        "request-id": {
+          "required": true,
+          "type": "string"
+        },
+        "action-name": {
+          "required": true,
+          "type": "string"
+        },
+        "scope-type": {
+          "required": true,
+          "type": "string"
+        },
+        "hostname": {
+          "required": true,
+          "type": "string"
+        }
+      },
+      "derived_from": "tosca.datatypes.Root"
     }
   }
 }
\ No newline at end of file
index 139ebb1..6e8d839 100644 (file)
@@ -1,7 +1,7 @@
 {
   "node_types": {
     "dg-activate": {
-      "description": "This is BPMN Activate node type",
+      "description": "This is Generic Directed Graph Type",
       "version": "1.0.0",
       "properties": {
         "content": {
                   "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,
         "JythonExecutorComponent": {
           "operations": {
             "process": {
+              "inputs": {
+                "instance-dependencies": {
+                  "required": true,
+                  "description": "Instance Names to Inject to Jython Script.",
+                  "type": "list",
+                  "entry_schema": {
+                    "type": "string"
+                  }
+                }
+              },
               "outputs": {
                 "response-data": {
                   "description": "Execution Response Data in JSON format.",
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 (file)
index 0000000..557f6ef
--- /dev/null
@@ -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 (file)
index 0e0dcd2..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-{
-
-}
\ No newline at end of file
index d256bbd..2f6d2ed 100644 (file)
@@ -19,7 +19,7 @@
         xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.onap.org/sdnc/svclogic ./svclogic.xsd' module='CONFIG' version='1.0.0'>
     <method rpc='ActivateNetconf' mode='sync'>
         <block atomic="true">
-            <execute plugin="resource-assignment" method="process">
+            <execute plugin="activate-jython" method="process">
                 <outcome value='failure'>
                     <return status="failure">
                     </return>
@@ -25,7 +25,7 @@
                     </return>
                 </outcome>
                 <outcome value='success'>
-                    <execute plugin="resource-assignment-py" method="process">
+                    <execute plugin="activate-jython" method="process">
                         <outcome value='failure'>
                             <return status="failure">
                             </return>
@@ -17,7 +17,7 @@
 <service-logic
         xmlns='http://www.onap.org/sdnc/svclogic'
         xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.onap.org/sdnc/svclogic ./svclogic.xsd' module='CONFIG' version='1.0.0'>
-    <method rpc='ActivateNetconf' mode='sync'>
+    <method rpc='ResourceAssignment' mode='sync'>
         <block atomic="true">
             <execute plugin="resource-assignment" method="process">
                  <outcome value='failure'>
index a29a875..51d70ed 100644 (file)
       "operations": {\r
         "process": {\r
           "inputs": {\r
-           "template-name": {\r
+            "template-name": {\r
               "description": "Service Template Name.",\r
               "required": true,\r
               "type": "string"\r
             },\r
-           "template-version": {\r
+            "template-version": {\r
               "description": "Service Template Version.",\r
               "required": true,\r
               "type": "string"\r
                 "type": "string"\r
               }\r
             },\r
+            "artifact-prefix-names": {\r
+              "required": false,\r
+              "description": "Template , Resource Assignment Artifact Prefix names",\r
+              "type": "list",\r
+              "entry_schema": {\r
+                "type": "string"\r
+              }\r
+            },\r
             "request-id": {\r
               "description": "Request Id, Unique Id for the request.",\r
               "required": true,\r
index 8a779c1..03656eb 100644 (file)
@@ -35,6 +35,7 @@
         <kotlin.maven.version>1.3.10</kotlin.maven.version>
         <kotlin.couroutines.version>1.0.1</kotlin.couroutines.version>
         <grpc.version>1.16.1</grpc.version>
+        <protobuff.java.utils.version>3.6.1</protobuff.java.utils.version>
         <eelf.version>1.0.0</eelf.version>
         <guava.version>26.0-jre</guava.version>
         <springfox.swagger2.version>2.9.2</springfox.swagger2.version>
                 <artifactId>commons-io</artifactId>
                 <version>2.6</version>
             </dependency>
+            <dependency>
+                <groupId>org.apache.commons</groupId>
+                <artifactId>commons-compress</artifactId>
+                <version>1.15</version>
+            </dependency>
             <dependency>
                 <groupId>org.apache.velocity</groupId>
                 <artifactId>velocity</artifactId>
                 <artifactId>grpc-stub</artifactId>
                 <version>${grpc.version}</version>
             </dependency>
+            <dependency>
+                <groupId>com.google.protobuf</groupId>
+                <artifactId>protobuf-java-util</artifactId>
+                <version>${protobuff.java.utils.version}</version>
+            </dependency>
 
 
             <!-- Database -->
             <groupId>commons-io</groupId>
             <artifactId>commons-io</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-compress</artifactId>
+        </dependency>
         <dependency>
             <groupId>com.jayway.jsonpath</groupId>
             <artifactId>json-path</artifactId>
             <groupId>com.fasterxml.jackson.module</groupId>
             <artifactId>jackson-module-kotlin</artifactId>
         </dependency>
+        <!-- GRPC Dependencies -->
+        <dependency>
+            <groupId>io.grpc</groupId>
+            <artifactId>grpc-netty</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>io.grpc</groupId>
+            <artifactId>grpc-protobuf</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>io.grpc</groupId>
+            <artifactId>grpc-stub</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.google.protobuf</groupId>
+            <artifactId>protobuf-java-util</artifactId>
+        </dependency>
+
     </dependencies>
 
     <build>
index 983e231..f72f78a 100644 (file)
@@ -25,6 +25,7 @@
 **/.springBeans
 **/.directory
 
+**/transaction.log
 **/*versionsBackup
 **/blackDuckHub*
 **/*.jsonld
\ No newline at end of file
index 4e652d5..796cde6 100644 (file)
             <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
             <artifactId>selfservice-api</artifactId>
         </dependency>
+        <dependency>
+            <groupId>com.h2database</groupId>
+            <artifactId>h2</artifactId>
+        </dependency>
         <dependency>
             <groupId>org.powermock</groupId>
             <artifactId>powermock-api-mockito2</artifactId>
diff --git a/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/BlueprintGRPCServer.java b/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/BlueprintGRPCServer.java
new file mode 100644 (file)
index 0000000..86fdccd
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * 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;
+
+import io.grpc.Server;
+import io.grpc.ServerBuilder;
+import org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api.BluePrintManagementGRPCHandler;
+import org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api.BluePrintProcessingGRPCHandler;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.context.ApplicationListener;
+import org.springframework.context.event.ContextRefreshedEvent;
+import org.springframework.stereotype.Component;
+
+@ConditionalOnProperty(name = "blueprintsprocessor.grpcEnable", havingValue = "true")
+@Component
+public class BlueprintGRPCServer implements ApplicationListener<ContextRefreshedEvent> {
+
+    private static Logger log = LoggerFactory.getLogger(BlueprintGRPCServer.class);
+
+    @Autowired
+    private BluePrintProcessingGRPCHandler bluePrintProcessingGRPCHandler;
+
+    @Autowired
+    private BluePrintManagementGRPCHandler bluePrintManagementGRPCHandler;
+
+    @Value("${blueprintsprocessor.grpcPort}")
+    private Integer grpcPort;
+
+    @Override
+    public void onApplicationEvent(ContextRefreshedEvent event) {
+        try {
+            log.info("Starting Blueprint Processor GRPC Starting..");
+            Server server = ServerBuilder
+                    .forPort(grpcPort)
+                    .addService(bluePrintProcessingGRPCHandler)
+                    .addService(bluePrintManagementGRPCHandler)
+                    .build();
+
+            server.start();
+            log.info("Blueprint Processor GRPC server started and ready to serve on port({})...", server.getPort());
+            server.awaitTermination();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+}
diff --git a/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/BlueprintHttpServer.java b/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/BlueprintHttpServer.java
new file mode 100644 (file)
index 0000000..b00c462
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * 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;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.boot.web.embedded.netty.NettyReactiveWebServerFactory;
+import org.springframework.boot.web.reactive.server.ReactiveWebServerFactory;
+import org.springframework.boot.web.server.WebServer;
+import org.springframework.http.server.reactive.HttpHandler;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+
+@ConditionalOnProperty(name = "blueprintsprocessor.grpcEnable", havingValue = "true")
+@Component
+public class BlueprintHttpServer {
+    private static Logger log = LoggerFactory.getLogger(BlueprintHttpServer.class);
+
+    @Value("${blueprintsprocessor.httpPort}")
+    private Integer httpPort;
+
+    @Autowired
+    HttpHandler httpHandler;
+
+    WebServer http;
+
+    @PostConstruct
+    public void start() {
+        ReactiveWebServerFactory factory = new NettyReactiveWebServerFactory(httpPort);
+        this.http = factory.getWebServer(this.httpHandler);
+        this.http.start();
+    }
+
+    @PreDestroy
+    public void stop() {
+        this.http.stop();
+    }
+}
index 3537a91..810480e 100644 (file)
@@ -17,8 +17,7 @@
 \r
 package org.onap.ccsdk.apps.blueprintsprocessor;\r
 \r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
+\r
 import org.springframework.context.annotation.Bean;\r
 import springfox.documentation.builders.PathSelectors;\r
 import springfox.documentation.builders.RequestHandlerSelectors;\r
@@ -27,10 +26,7 @@ import springfox.documentation.service.Contact;
 import springfox.documentation.spi.DocumentationType;\r
 import springfox.documentation.spring.web.plugins.Docket;\r
 \r
-import java.util.Arrays;\r
 import java.util.Collections;\r
-import java.util.HashSet;\r
-import java.util.Set;\r
 \r
 /**\r
  * SwaggerConfig\r
index f30a7f1..fa1a1e6 100644 (file)
@@ -1,5 +1,5 @@
 #\r
-#  Copyright © 2017-2018 AT&T Intellectual Property.\r
+#  Copyright  2017-2018 AT&T Intellectual Property.\r
 #\r
 #  Licensed under the Apache License, Version 2.0 (the "License");\r
 #  you may not use this file except in compliance with the License.\r
 #  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
 #  See the License for the specific language governing permissions and\r
 #  limitations under the License.\r
-#
\ No newline at end of file
+#\r
+#logging.level.web=DEBUG\r
+blueprintsprocessor.grpcEnable=false\r
+blueprintsprocessor.httpPort=8080\r
+blueprintsprocessor.grpcPort=9111\r
+# Blueprint Processor File Execution and Handling Properties\r
+blueprintsprocessor.blueprintDeployPath=/opt/app/onap/blueprints/deploy\r
+blueprintsprocessor.blueprintArchivePath=/opt/app/onap/blueprints/archive\r
+# Primary Database Configuration\r
+blueprintsprocessor.db.primary.url=jdbc:mysql://localhost:3306/sdnctl\r
+blueprintsprocessor.db.primary.username=sdnctl\r
+blueprintsprocessor.db.primary.password=sdnctl\r
+blueprintsprocessor.db.primary.driverClassName=org.mariadb.jdbc.Driver\r
+blueprintsprocessor.db.primary.hibernateHbm2ddlAuto=validate\r
+blueprintsprocessor.db.primary.hibernateDDLAuto=none\r
+blueprintsprocessor.db.primary.hibernateNamingStrategy=org.hibernate.cfg.ImprovedNamingStrategy\r
+blueprintsprocessor.db.primary.hibernateDialect=org.hibernate.dialect.MySQL5InnoDBDialect
\ No newline at end of file
index 3cba1f9..8a4ebd0 100644 (file)
@@ -22,6 +22,7 @@ import org.junit.Before;
 import org.junit.Test;\r
 import org.junit.runner.RunWith;\r
 import org.springframework.beans.factory.annotation.Autowired;\r
+import org.springframework.boot.test.context.SpringBootTest;\r
 import org.springframework.context.ApplicationContext;\r
 import org.springframework.test.context.ContextConfiguration;\r
 import org.springframework.test.context.junit4.SpringRunner;\r
@@ -35,8 +36,8 @@ import org.springframework.test.context.junit4.SpringRunner;
 \r
 @RunWith(SpringRunner.class)\r
 @ContextConfiguration(classes = BlueprintProcessorApplication.class)\r
-//@SpringBootTest(classes = BlueprintProcessorApplication.class,\r
-//        webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)\r
+@SpringBootTest(classes = BlueprintProcessorApplication.class,\r
+        webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)\r
 public class BlueprintProcessorApplicationTest {\r
 \r
     @Autowired\r
@@ -48,7 +49,7 @@ public class BlueprintProcessorApplicationTest {
     }\r
 \r
     @Test\r
-    public void testSample(){\r
+    public void testSample() {\r
         Assert.assertNotNull("Failed to create Application Context ", context);\r
     }\r
 \r
diff --git a/ms/blueprintsprocessor/application/src/test/resources/application.properties b/ms/blueprintsprocessor/application/src/test/resources/application.properties
new file mode 100644 (file)
index 0000000..f896ee0
--- /dev/null
@@ -0,0 +1,27 @@
+#
+# 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.
+#
+# Blueprint Processor File Execution and Handling Properties
+blueprintsprocessor.blueprintDeployPath=/opt/app/onap/blueprints/deploy
+blueprintsprocessor.blueprintArchivePath=/opt/app/onap/blueprints/archive
+# Primary Database Configuration
+blueprintsprocessor.db.primary.url=jdbc:h2:mem:testdb;DB_CLOSE_ON_EXIT=FALSE
+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
\ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/pom.xml b/ms/blueprintsprocessor/functions/netconf-executor/pom.xml
new file mode 100644 (file)
index 0000000..94103b5
--- /dev/null
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Copyright © 2017-2018 AT&T Intellectual Property.
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
+        <artifactId>functions</artifactId>
+        <version>0.4.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.onap.ccsdk.apps.blueprintsprocessor.functions</groupId>
+    <artifactId>netconf-executor</artifactId>
+    <name>Blueprints Processor Function - Netconf Executor</name>
+    <description>Blueprints Processor Function - Netconf Executor</description>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.onap.ccsdk.apps.blueprintsprocessor.functions</groupId>
+            <artifactId>python-executor</artifactId>
+        </dependency>
+    </dependencies>
+
+
+</project>
\ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutor.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutor.kt
new file mode 100644 (file)
index 0000000..e0fd735
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * 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.netconf.executor
+
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.ComponentJythonExecutor
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.PythonExecutorProperty
+import org.slf4j.LoggerFactory
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
+import org.springframework.stereotype.Component
+
+@Component("component-netconf-executor")
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+open class ComponentNetconfExecutor(private val netconfExecutorConfiguration: NetconfExecutorConfiguration,
+                                    private val pythonExecutorProperty: PythonExecutorProperty)
+    : ComponentJythonExecutor(pythonExecutorProperty) {
+
+    private val log = LoggerFactory.getLogger(ComponentJythonExecutor::class.java)
+
+    override fun process(executionServiceInput: ExecutionServiceInput) {
+        super.process(executionServiceInput)
+    }
+}
\ No newline at end of file
  * limitations under the License.
  */
 
-package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor
 
-class ResourceResolutionConstants {
-    companion object {
-        const val PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR = "resource-assignment-processor-"
+import org.springframework.stereotype.Service
 
-    }
+@Service("json-parser-service")
+class JsonParserService {
 
 }
\ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfExecutorConfiguration.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfExecutorConfiguration.kt
new file mode 100644 (file)
index 0000000..267a49a
--- /dev/null
@@ -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.netconf.executor
+
+import org.springframework.boot.context.properties.EnableConfigurationProperties
+import org.springframework.context.annotation.ComponentScan
+import org.springframework.context.annotation.Configuration
+
+@Configuration
+@ComponentScan
+@EnableConfigurationProperties
+open class NetconfExecutorConfiguration
\ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfRpcService.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfRpcService.kt
new file mode 100644 (file)
index 0000000..f481810
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * 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.netconf.executor
+
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
+import org.springframework.stereotype.Service
+
+@Service("netconf-rpc-service")
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+class NetconfRpcService {
+
+}
\ No newline at end of file
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
new file mode 100644 (file)
index 0000000..05f6a2d
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * 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.netconf.executor
+
+import com.fasterxml.jackson.databind.JsonNode
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ActionIdentifiers
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.CommonHeader
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.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.springframework.beans.factory.annotation.Autowired
+import org.springframework.test.context.ContextConfiguration
+import org.springframework.test.context.TestPropertySource
+import org.springframework.test.context.junit4.SpringRunner
+
+@RunWith(SpringRunner::class)
+@ContextConfiguration(classes = [NetconfExecutorConfiguration::class, PythonExecutorProperty::class])
+@TestPropertySource(properties =
+["blueprints.processor.functions.python.executor.modulePaths=./../../../../components/scripts/python/ccsdk_blueprints",
+    "blueprints.processor.functions.python.executor.executionPath=./../../../../components/scripts/python/ccsdk_blueprints"])
+class ComponentNetconfExecutorTest {
+
+    @Autowired
+    lateinit var componentNetconfExecutor: ComponentNetconfExecutor
+
+    @Test
+    fun testComponentNetconfExecutor() {
+
+        val executionServiceInput = ExecutionServiceInput()
+        val commonHeader = CommonHeader()
+        commonHeader.requestId = "1234"
+        executionServiceInput.commonHeader = commonHeader
+
+        val actionIdentifiers = ActionIdentifiers()
+        actionIdentifiers.blueprintName = "baseconfiguration"
+        actionIdentifiers.blueprintVersion = "1.0.0"
+        actionIdentifiers.actionName = "activate"
+        executionServiceInput.actionIdentifiers = actionIdentifiers
+
+
+        val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(commonHeader.requestId,
+                "./../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration")
+
+        componentNetconfExecutor.bluePrintRuntimeService = bluePrintRuntimeService
+
+
+        val stepMetaData: MutableMap<String, JsonNode> = hashMapOf()
+        stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, "activate-jython")
+        stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_INTERFACE, "JythonExecutorComponent")
+        stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_OPERATION, "process")
+        // Set Step Inputs in Blueprint Runtime Service
+        bluePrintRuntimeService.put("activate-jython-step-inputs", stepMetaData.asJsonNode())
+
+        componentNetconfExecutor.bluePrintRuntimeService = bluePrintRuntimeService
+        componentNetconfExecutor.stepName = "activate-jython"
+
+        componentNetconfExecutor.apply(executionServiceInput)
+
+    }
+}
+
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/test/resources/logback-test.xml b/ms/blueprintsprocessor/functions/netconf-executor/src/test/resources/logback-test.xml
new file mode 100644 (file)
index 0000000..f9ec9fe
--- /dev/null
@@ -0,0 +1,35 @@
+<!--\r
+  ~ Copyright © 2017-2018 AT&T Intellectual Property.\r
+  ~\r
+  ~ Licensed under the Apache License, Version 2.0 (the "License");\r
+  ~ you may not use this file except in compliance with the License.\r
+  ~ You may obtain a copy of the License at\r
+  ~\r
+  ~     http://www.apache.org/licenses/LICENSE-2.0\r
+  ~\r
+  ~ Unless required by applicable law or agreed to in writing, software\r
+  ~ distributed under the License is distributed on an "AS IS" BASIS,\r
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+  ~ See the License for the specific language governing permissions and\r
+  ~ limitations under the License.\r
+  -->\r
+\r
+<configuration>\r
+    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">\r
+        <!-- encoders are assigned the type\r
+             ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->\r
+        <encoder>\r
+            <pattern>%d{HH:mm:ss.SSS} %-5level %logger{100} - %msg%n</pattern>\r
+        </encoder>\r
+    </appender>\r
+\r
+    <logger name="org.springframework.test" level="warn"/>\r
+    <logger name="org.springframework" level="warn"/>\r
+    <logger name="org.hibernate" level="info"/>\r
+    <logger name="org.onap.ccsdk.apps.blueprintsprocessor" level="info"/>\r
+\r
+    <root level="warn">\r
+        <appender-ref ref="STDOUT"/>\r
+    </root>\r
+\r
+</configuration>\r
index efd550d..e4f8c84 100644 (file)
@@ -32,6 +32,7 @@
     <modules>
         <module>resource-resolution</module>
         <module>python-executor</module>
+        <module>netconf-executor</module>
     </modules>
 
     <dependencies>
index 2965cb5..166af0f 100644 (file)
 
 package org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor
 
+import com.fasterxml.jackson.databind.node.ArrayNode
 import org.apache.commons.io.FilenameUtils
 import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
 import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.utils.PythonExecutorUtils
 import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
 import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmptyNThrow
 import org.onap.ccsdk.apps.controllerblueprints.core.data.OperationAssignment
 import org.slf4j.LoggerFactory
+import org.springframework.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-jython-executor")
-class ComponentJythonExecutor(private val pythonExecutorProperty: PythonExecutorProperty) : AbstractComponentFunction() {
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+open class ComponentJythonExecutor(private val pythonExecutorProperty: PythonExecutorProperty) : AbstractComponentFunction() {
 
     private val log = LoggerFactory.getLogger(ComponentJythonExecutor::class.java)
 
     private var componentFunction: AbstractComponentFunction? = null
 
+    @Autowired
+    lateinit var applicationContext: ApplicationContext
 
-    override fun process(executionServiceInput: ExecutionServiceInput) {
-
-        log.info("Processing : ${executionServiceInput.metadata}")
-        checkNotNull(bluePrintRuntimeService) { "failed to get bluePrintRuntimeService" }
-
+    fun populateJythonComponentInstance(executionServiceInput: ExecutionServiceInput) {
         val bluePrintContext = bluePrintRuntimeService!!.bluePrintContext()
 
         val operationAssignment: OperationAssignment = bluePrintContext
                 .nodeTemplateInterfaceOperation(nodeTemplateName, interfaceName, operationName)
 
-        val blueprintBasePath: String = bluePrintRuntimeService!!.get(BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH)?.asText()
-                ?: throw BluePrintProcessorException("python execute path is missing for node template ($nodeTemplateName)")
+        val blueprintBasePath: String = bluePrintContext.rootPath
 
         val artifactName: String = operationAssignment.implementation?.primary
                 ?: throw BluePrintProcessorException("missing primary field to get artifact name for node template ($nodeTemplateName)")
@@ -66,12 +68,30 @@ class ComponentJythonExecutor(private val pythonExecutorProperty: PythonExecutor
         pythonPath.add(blueprintBasePath)
         pythonPath.addAll(pythonExecutorProperty.modulePaths)
 
-        val properties: MutableMap<String, Any> = hashMapOf()
-        properties["log"] = log
+        val jythonInstances: MutableMap<String, Any> = hashMapOf()
+        jythonInstances["log"] = LoggerFactory.getLogger(nodeTemplateName)
+
+        val instanceDependenciesNode: ArrayNode = operationInputs[PythonExecutorConstants.INPUT_INSTANCE_DEPENDENCIES] as? ArrayNode
+                ?: throw BluePrintProcessorException("Failed to get property(${PythonExecutorConstants.INPUT_INSTANCE_DEPENDENCIES})")
+
+        instanceDependenciesNode.forEach { instanceName ->
+            jythonInstances[instanceName.textValue()] = applicationContext.getBean(instanceName.textValue())
+        }
 
         componentFunction = PythonExecutorUtils.getPythonComponent(pythonExecutorProperty.executionPath,
-                pythonPath, content, pythonClassName, properties)
+                pythonPath, content, pythonClassName, jythonInstances)
+    }
+
+
+    override fun process(executionServiceInput: ExecutionServiceInput) {
+
+        log.info("Processing : ${operationInputs}")
+        checkNotNull(bluePrintRuntimeService) { "failed to get bluePrintRuntimeService" }
+
+        // Populate Component Instance
+        populateJythonComponentInstance(executionServiceInput)
 
+        // Invoke Jython Component Script
         componentFunction!!.process(executionServiceInput)
 
     }
index dc372af..6618d13 100644 (file)
@@ -33,10 +33,11 @@ class JythonExecutionService(private val pythonExecutorProperty: PythonExecutorP
     lateinit var applicationContext: ApplicationContext
 
 
-    fun processJythonNodeTemplate(pythonClassName: String, content: String, pythonPath: MutableList<String>,
-                                  jythonContextInstance: MutableMap<String, Any>,
-                                  dependencyInstanceNames: List<String>): AbstractComponentFunction {
+    fun getJythonComponentFunction(pythonClassName: String, content: String, pythonPath: MutableList<String>,
+                                   jythonContextInstance: MutableMap<String, Any>,
+                                   dependencyInstanceNames: List<String>): AbstractComponentFunction {
 
+        pythonPath.addAll(pythonExecutorProperty.modulePaths)
 
         dependencyInstanceNames.forEach { instanceName ->
             jythonContextInstance[instanceName] = applicationContext.getBean(instanceName)
index dd80fb0..be7374c 100644 (file)
@@ -33,4 +33,10 @@ open class PythonExecutorProperty {
     @Value("#{'\${blueprints.processor.functions.python.executor.modulePaths}'.split(',')}")
     lateinit var modulePaths: List<String>
 
+}
+
+class PythonExecutorConstants {
+    companion object {
+        const val INPUT_INSTANCE_DEPENDENCIES = "instance-dependencies"
+    }
 }
\ No newline at end of file
index 1ce8d05..07591a5 100644 (file)
@@ -23,6 +23,7 @@ import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ActionIdentifiers
 import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.CommonHeader
 import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.asJsonNode
 import org.onap.ccsdk.apps.controllerblueprints.core.putJsonElement
 import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
 import org.springframework.beans.factory.annotation.Autowired
@@ -35,13 +36,11 @@ import org.springframework.test.context.junit4.SpringRunner
 @TestPropertySource(properties =
 ["blueprints.processor.functions.python.executor.modulePaths=./../../../../components/scripts/python/ccsdk_blueprints",
     "blueprints.processor.functions.python.executor.executionPath=./../../../../components/scripts/python/ccsdk_blueprints"])
-
 class ComponentJythonExecutorTest {
 
     @Autowired
     lateinit var componentJythonExecutor: ComponentJythonExecutor
 
-
     @Test
     fun testPythonComponentInjection() {
 
@@ -60,15 +59,14 @@ class ComponentJythonExecutorTest {
         val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(commonHeader.requestId,
                 "./../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration")
 
-        componentJythonExecutor.bluePrintRuntimeService = bluePrintRuntimeService
+        val stepMetaData: MutableMap<String, JsonNode> = hashMapOf()
+        stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, "activate-jython")
+        stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_INTERFACE, "JythonExecutorComponent")
+        stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_OPERATION, "process")
+        bluePrintRuntimeService.put("activate-jython-step-inputs", stepMetaData.asJsonNode())
 
-
-        val metaData: MutableMap<String, JsonNode> = hashMapOf()
-        metaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_STEP, "resource-assignment-py")
-        metaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, "resource-assignment-py")
-        metaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_INTERFACE, "ResourceAssignmentComponent")
-        metaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_OPERATION, "process")
-        executionServiceInput.metadata = metaData
+        componentJythonExecutor.bluePrintRuntimeService = bluePrintRuntimeService
+        componentJythonExecutor.stepName = "activate-jython"
 
         componentJythonExecutor.apply(executionServiceInput)
 
diff --git a/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/mock/MockInstanceConfiguration.kt b/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/mock/MockInstanceConfiguration.kt
new file mode 100644 (file)
index 0000000..41250e0
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.mock
+
+import org.springframework.context.annotation.Bean
+import org.springframework.context.annotation.Configuration
+
+@Configuration
+open class MockInstanceConfiguration {
+    @Bean(name = ["json-parser-service", "netconf-rpc-service"])
+    open fun createComponentFunction(): MockJythonService {
+        return MockJythonService()
+    }
+}
+
+class MockJythonService {
+
+}
\ 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/ResourceResolutionComponent.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt
new file mode 100644 (file)
index 0000000..e5feb25
--- /dev/null
@@ -0,0 +1,54 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution\r
+\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(private val resourceResolutionService: ResourceResolutionService) : AbstractComponentFunction() {\r
+\r
+    @Autowired\r
+    private lateinit var applicationContext: ApplicationContext\r
+\r
+    override fun process(executionRequest: ExecutionServiceInput) {\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
+        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.\r
+    }\r
+}
\ 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/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 (file)
index 0000000..4c24ac6
--- /dev/null
@@ -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
new file mode 100644 (file)
index 0000000..3211d6e
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * 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
+
+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
new file mode 100644 (file)
index 0000000..c3cf009
--- /dev/null
@@ -0,0 +1,140 @@
+/*\r
+ *  Copyright © 2017-2018 AT&T Intellectual Property.\r
+ *  Modifications Copyright © 2018 IBM.\r
+ *\r
+ *  Licensed under the Apache License, Version 2.0 (the "License");\r
+ *  you may not use this file except in compliance with the License.\r
+ *  You may obtain a copy of the License at\r
+ *\r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ *  Unless required by applicable law or agreed to in writing, software\r
+ *  distributed under the License is distributed on an "AS IS" BASIS,\r
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ *  See the License for the specific language governing permissions and\r
+ *  limitations under the License.\r
+ */\r
+\r
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution\r
+\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.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
+ * @author Brinda Santh\r
+ * 8/14/2018\r
+ */\r
+\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 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
+\r
+    fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,\r
+                         artifactNames: List<String>): MutableMap<String, String> {\r
+\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
+\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
+\r
+    fun executeProcessors(bluePrintRuntimeService: BluePrintRuntimeService<*>,\r
+                          resourceDictionaries: MutableMap<String, ResourceDefinition>,\r
+                          resourceAssignments: MutableList<ResourceAssignment>) {\r
+\r
+        val bulkSequenced = BulkResourceSequencingUtils.process(resourceAssignments)\r
+\r
+        bulkSequenced.map { batchResourceAssignments ->\r
+            batchResourceAssignments.filter { it.name != "*" && it.name != "start" }\r
+                    .map { resourceAssignment ->\r
+                        val dictionarySource = resourceAssignment.dictionarySource\r
+                        val processorInstanceName = ResourceResolutionConstants.PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR.plus(dictionarySource)\r
+\r
+                        val resourceAssignmentProcessor = applicationContext.getBean(processorInstanceName) as? ResourceAssignmentProcessor\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
+                            resourceAssignmentProcessor.recover(e, resourceAssignment)\r
+                            throw BluePrintProcessorException(e)\r
+                        }\r
+                    }\r
+        }\r
+    }\r
+\r
+}\r
  *  limitations under the License.
  */
 
-package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor
+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
 
 /**
@@ -29,6 +28,10 @@ import org.springframework.stereotype.Service
 @Service("resource-assignment-processor-db")
 open class DataBaseResourceAssignmentProcessor : ResourceAssignmentProcessor(){
 
+    override fun getName(): String {
+        return "resource-assignment-processor-db"
+    }
+
     override fun process(executionRequest: ResourceAssignment) {
     }
 
  *  limitations under the License.\r
  */\r
 \r
-package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor\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
@@ -29,6 +28,10 @@ import org.springframework.stereotype.Service
 @Service("resource-assignment-processor-default")\r
 open class DefaultResourceAssignmentProcessor : ResourceAssignmentProcessor() {\r
 \r
+    override fun getName(): String {\r
+        return "resource-assignment-processor-default"\r
+    }\r
+\r
     override fun process(executionRequest: ResourceAssignment) {\r
     }\r
 \r
  *  limitations under the License.\r
  */\r
 \r
-package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor\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
@@ -29,6 +28,10 @@ import org.springframework.stereotype.Service
 @Service("resource-assignment-processor-input")\r
 open class InputResourceAssignmentProcessor : ResourceAssignmentProcessor() {\r
 \r
+    override fun getName(): String {\r
+        return "resource-assignment-processor-input"\r
+    }\r
+\r
     override fun process(executionRequest: ResourceAssignment) {\r
     }\r
 \r
  *  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
     }
 
  *  limitations under the License.
  */
 
-package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor
+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
 
 /**
@@ -29,6 +28,10 @@ import org.springframework.stereotype.Service
 @Service("resource-assignment-processor-mdsal")
 open class SimpleRestResourceAssignmentProcessor : ResourceAssignmentProcessor() {
 
+    override fun getName(): String {
+        return "resource-assignment-processor-mdsal"
+    }
+
     override fun process(executionRequest: ResourceAssignment) {
     }
 
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionComponent.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionComponent.kt
deleted file mode 100644 (file)
index a485fa6..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution\r
-\r
-import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput\r
-import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction\r
-import org.springframework.stereotype.Component\r
-\r
-@Component("component-resource-resolution")\r
-open class ResourceResolutionComponent : AbstractComponentFunction() {\r
-    override fun process(executionRequest: ExecutionServiceInput) {\r
-        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.\r
-    }\r
-\r
-    override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {\r
-        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.\r
-    }\r
-}
\ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt
deleted file mode 100644 (file)
index 9e735cf..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/*\r
- *  Copyright © 2017-2018 AT&T Intellectual Property.\r
- *  Modifications Copyright © 2018 IBM.\r
- *\r
- *  Licensed under the Apache License, Version 2.0 (the "License");\r
- *  you may not use this file except in compliance with the License.\r
- *  You may obtain a copy of the License at\r
- *\r
- *      http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- *  Unless required by applicable law or agreed to in writing, software\r
- *  distributed under the License is distributed on an "AS IS" BASIS,\r
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- *  See the License for the specific language governing permissions and\r
- *  limitations under the License.\r
- */\r
-\r
-package org.onap.ccsdk.apps.blueprintsprocessor.services.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.controllerblueprints.core.BluePrintProcessorException\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.utils.BulkResourceSequencingUtils\r
-import org.springframework.beans.factory.annotation.Autowired\r
-import org.springframework.context.ApplicationContext\r
-import org.springframework.stereotype.Service\r
-\r
-/**\r
- * ResourceResolutionService\r
- * @author Brinda Santh\r
- * 8/14/2018\r
- */\r
-\r
-@Service\r
-class ResourceResolutionService {\r
-\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
-\r
-        process(resourceResolutionOutput.resourceAssignments)\r
-\r
-        val status = Status()\r
-        status.code = 200\r
-        status.message = "Success"\r
-        resourceResolutionOutput.status = status\r
-\r
-        return resourceResolutionOutput\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
-\r
-    fun process(resourceAssignments: MutableList<ResourceAssignment>) {\r
-\r
-        val bulkSequenced = BulkResourceSequencingUtils.process(resourceAssignments)\r
-\r
-        bulkSequenced.map { batchResourceAssignments ->\r
-            batchResourceAssignments.filter { it.name != "*" && it.name != "start" }\r
-                    .map { resourceAssignment ->\r
-                        val dictionarySource = resourceAssignment.dictionarySource\r
-                        val processorInstanceName = ResourceResolutionConstants.PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR.plus(dictionarySource)\r
-\r
-                        val resourceAssignmentProcessor = applicationContext.getBean(processorInstanceName) as? ResourceAssignmentProcessor\r
-                                ?: throw BluePrintProcessorException("failed to get resource processor for instance name($processorInstanceName) " +\r
-                                        "for resource assignment(${resourceAssignment.name})")\r
-                        try {\r
-                            // Invoke Apply Method\r
-                            resourceAssignmentProcessor.apply(resourceAssignment)\r
-                        } catch (e: RuntimeException) {\r
-                            resourceAssignmentProcessor.recover(e, resourceAssignment)\r
-                            throw BluePrintProcessorException(e)\r
-                        }\r
-                    }\r
-        }\r
-    }\r
-}\r
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 (file)
index 0000000..57217d0
--- /dev/null
@@ -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
new file mode 100644 (file)
index 0000000..df56007
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution
+
+import org.junit.Assert
+import org.junit.Test
+import org.junit.runner.RunWith
+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.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 kotlin.test.assertNotNull
+import kotlin.test.assertTrue
+
+/**
+ * ResourceResolutionServiceTest
+ *
+ * @author Brinda Santh DATE : 8/15/2018
+ */
+@RunWith(SpringRunner::class)
+@ContextConfiguration(classes = [ResourceResolutionService::class,
+    InputResourceAssignmentProcessor::class, DefaultResourceAssignmentProcessor::class,
+    DataBaseResourceAssignmentProcessor::class, SimpleRestResourceAssignmentProcessor::class])
+class ResourceResolutionServiceTest {
+
+    private val log = LoggerFactory.getLogger(ResourceResolutionServiceTest::class.java)
+
+    @Autowired
+    lateinit var resourceResolutionService: ResourceResolutionService
+
+
+    @Test
+    fun testRegisteredSource() {
+        val sources = resourceResolutionService.registeredResourceSources()
+        assertNotNull(sources, "failed to get registered sources")
+        assertTrue(sources.containsAll(arrayListOf("input", "default", "db", "mdsal")), "failed to get registered sources")
+    }
+
+    @Test
+    @Throws(Exception::class)
+    fun testResolveResource() {
+
+        Assert.assertNotNull("failed to create ResourceResolutionService", resourceResolutionService)
+
+        val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
+                "./../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration")
+
+        resourceResolutionService.resolveResources(bluePrintRuntimeService, "resource-assignment", "baseconfig")
+
+    }
+
+}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionServiceTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionServiceTest.kt
deleted file mode 100644 (file)
index a7d573c..0000000
+++ /dev/null
@@ -1,95 +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.services.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.core.factory.ResourceAssignmentProcessorFactory
-import org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor.DataBaseResourceAssignmentProcessor
-import org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor.DefaultResourceAssignmentProcessor
-import org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor.InputResourceAssignmentProcessor
-import org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor.SimpleRestResourceAssignmentProcessor
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
-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
-
-/**
- * ResourceResolutionServiceTest
- *
- * @author Brinda Santh DATE : 8/15/2018
- */
-@RunWith(SpringRunner::class)
-@ContextConfiguration(classes = [ResourceResolutionService::class, ResourceAssignmentProcessorFactory::class,
-    InputResourceAssignmentProcessor::class, DefaultResourceAssignmentProcessor::class,
-    DataBaseResourceAssignmentProcessor::class, SimpleRestResourceAssignmentProcessor::class])
-class ResourceResolutionServiceTest {
-
-    private val log = LoggerFactory.getLogger(ResourceResolutionServiceTest::class.java)
-
-    @Autowired
-    lateinit var resourceResolutionService: ResourceResolutionService
-
-
-    @Test
-    fun testRegisteredSource() {
-        val sources = resourceResolutionService.registeredResourceSources()
-        assertNotNull(sources, "failed to get registered sources")
-        assertTrue(sources.containsAll(arrayListOf("input", "default", "db", "mdsal")), "failed to get registered sources")
-    }
-
-    @Test
-    @Throws(Exception::class)
-    fun testResolveResource() {
-
-        Assert.assertNotNull("failed to create ResourceResolutionService", resourceResolutionService)
-
-        val resourceResolutionInputContent = FileUtils.readFileToString(
-                File("src/test/resources/payload/requests/sample-resourceresolution-request.json"), Charset.defaultCharset())
-
-        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)
-
-    }
-
-}
index e8830a8..7889a7e 100644 (file)
     "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
index 626a27a..5e0c966 100644 (file)
     <packaging>jar</packaging>
     <name>Blueprints Processor Core</name>
     <description>Blueprints Processor Core</description>
-
     <dependencies>
         <dependency>
-            <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
-            <artifactId>db-lib</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
-            <artifactId>rest-lib</artifactId>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-webflux</artifactId>
         </dependency>
     </dependencies>
 </project>
diff --git a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintCoreConfiguration.kt b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintCoreConfiguration.kt
new file mode 100644 (file)
index 0000000..07e494a
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.core
+
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.beans.factory.annotation.Value
+import org.springframework.boot.context.properties.bind.Binder
+import org.springframework.boot.context.properties.source.ConfigurationPropertySources
+import org.springframework.context.annotation.Bean
+import org.springframework.context.annotation.Configuration
+import org.springframework.core.env.Environment
+
+
+@Configuration
+open class BluePrintCoreConfiguration {
+
+    @Value("\${blueprintsprocessor.blueprintDeployPath}")
+    lateinit var deployPath: String
+
+    @Value("\${blueprintsprocessor.blueprintArchivePath}")
+    lateinit var archivePath: String
+
+}
+
+@Configuration
+open class BlueprintPropertyConfiguration {
+    @Autowired
+    lateinit var environment: Environment
+
+    @Bean
+    open fun bluePrintPropertyBinder(): Binder {
+        val configurationPropertySource = ConfigurationPropertySources.get(environment)
+        return Binder(configurationPropertySource)
+    }
+}
\ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintProperties.kt b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/BluePrintProperties.kt
new file mode 100644 (file)
index 0000000..10b8ceb
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.core
+
+import org.springframework.boot.context.properties.bind.Bindable
+import org.springframework.boot.context.properties.bind.Binder
+import org.springframework.stereotype.Service
+
+@Service
+open class BluePrintProperties(var bluePrintPropertyBinder: Binder) {
+
+    fun <T> propertyBeanType(prefix: String, type: Class<T>): T {
+        return bluePrintPropertyBinder.bind(prefix, Bindable.of(type)).get()
+    }
+}
\ No newline at end of file
index 427063e..b0483dc 100644 (file)
 package org.onap.ccsdk.apps.blueprintsprocessor.core.api.data\r
 \r
 import com.fasterxml.jackson.annotation.JsonFormat\r
-import com.fasterxml.jackson.databind.JsonNode\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
@@ -30,28 +28,6 @@ import java.util.*
  * 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
@@ -59,7 +35,6 @@ open class ExecutionServiceInput {
     lateinit var actionIdentifiers: ActionIdentifiers\r
     @get:ApiModelProperty(required = true)\r
     lateinit var payload: ObjectNode\r
-    var metadata: MutableMap<String, JsonNode> = hashMapOf()\r
 }\r
 \r
 open class ExecutionServiceOutput {\r
@@ -71,7 +46,6 @@ open class ExecutionServiceOutput {
     var status: Status = Status()\r
     @get:ApiModelProperty(required = true)\r
     lateinit var payload: ObjectNode\r
-    var metadata: MutableMap<String, JsonNode> = hashMapOf()\r
 }\r
 \r
 open class ActionIdentifiers {\r
diff --git a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ResourceAssignmentProcessorFactory.kt b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ResourceAssignmentProcessorFactory.kt
deleted file mode 100644 (file)
index 80ad0e6..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/*\r
- *  Copyright © 2017-2018 AT&T Intellectual Property.\r
- *  Modifications Copyright © 2018 IBM.\r
- *\r
- *  Licensed under the Apache License, Version 2.0 (the "License");\r
- *  you may not use this file except in compliance with the License.\r
- *  You may obtain a copy of the License at\r
- *\r
- *      http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- *  Unless required by applicable law or agreed to in writing, software\r
- *  distributed under the License is distributed on an "AS IS" BASIS,\r
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- *  See the License for the specific language governing permissions and\r
- *  limitations under the License.\r
- */\r
-\r
-package org.onap.ccsdk.apps.blueprintsprocessor.core.factory\r
-\r
-import com.att.eelf.configuration.EELFManager\r
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor\r
-import org.springframework.context.ApplicationContext\r
-import org.springframework.context.ApplicationContextAware\r
-import org.springframework.context.annotation.Configuration\r
-\r
-/**\r
- * ResourceAssignmentProcessorFactory\r
- *\r
- * @author Brinda Santh\r
- */\r
-@Configuration\r
-open class ResourceAssignmentProcessorFactory : ApplicationContextAware {\r
-\r
-    private val log = EELFManager.getInstance().getLogger(ResourceAssignmentProcessorFactory::class.java)\r
-\r
-    var resourceAssignmentProcessors: MutableMap<String, ResourceAssignmentProcessor> = hashMapOf()\r
-\r
-    fun getInstance(instanceName: String): ResourceAssignmentProcessor? {\r
-        log.trace("looking for Resource Assignment Processor : {}", instanceName)\r
-        return resourceAssignmentProcessors.get(instanceName)\r
-    }\r
-\r
-    fun injectInstance(instanceName: String, resourceAssignmentProcessor: ResourceAssignmentProcessor) {\r
-        this.resourceAssignmentProcessors[instanceName] = resourceAssignmentProcessor\r
-    }\r
-\r
-    override fun setApplicationContext(context: ApplicationContext) {\r
-        resourceAssignmentProcessors = context.getBeansOfType(ResourceAssignmentProcessor::class.java)\r
-        log.info("Injected Resource Assignment Processor : {}", resourceAssignmentProcessors)\r
-    }\r
-}
\ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/interfaces/BluePrintCatalogService.kt b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/interfaces/BluePrintCatalogService.kt
new file mode 100644 (file)
index 0000000..6484796
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * 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.interfaces
+
+interface BluePrintCatalogService {
+    /**
+     * Get the Blueprint from Data Base and Download it under working directory and return the path path
+     */
+    fun prepareBluePrint(name: String, version: String): String
+}
\ No newline at end of file
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 (file)
index 0000000..31dca33
--- /dev/null
@@ -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
index 0139e74..4b11f83 100644 (file)
   ~  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">
-       <modelVersion>4.0.0</modelVersion>
-       <parent>
-               <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
-               <artifactId>commons</artifactId>
-               <version>0.4.0-SNAPSHOT</version>
-       </parent>
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
+        <artifactId>commons</artifactId>
+        <version>0.4.0-SNAPSHOT</version>
+    </parent>
 
-       <artifactId>db-lib</artifactId>
-       <packaging>jar</packaging>
-       <name>Blueprints Processor DB Lib</name>
-       <description>Blueprints Processor DB Lib</description>
+    <artifactId>db-lib</artifactId>
+    <packaging>jar</packaging>
+    <name>Blueprints Processor DB Lib</name>
+    <description>Blueprints Processor DB Lib</description>
 
-       <dependencies>
-
-               <dependency>
-                       <groupId>org.springframework.boot</groupId>
-                       <artifactId>spring-boot-starter-data-jpa</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>javax.validation</groupId>
-                       <artifactId>validation-api</artifactId>
-               </dependency>
-
-               <dependency>
-                       <groupId>com.h2database</groupId>
-                       <artifactId>h2</artifactId>
-               </dependency>
+    <dependencies>
+        <dependency>
+            <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
+            <artifactId>core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-jpa</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>javax.validation</groupId>
+            <artifactId>validation-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.h2database</groupId>
+            <artifactId>h2</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.mariadb.jdbc</groupId>
+            <artifactId>mariadb-java-client</artifactId>
+        </dependency>
         <dependency>
             <groupId>org.hibernate</groupId>
             <artifactId>hibernate-testing</artifactId>
             <scope>test</scope>
         </dependency>
-
-       </dependencies>
+    </dependencies>
 
 </project>
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
new file mode 100644 (file)
index 0000000..0bdee9b
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * 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
+
+import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintProperties
+import org.springframework.boot.context.properties.EnableConfigurationProperties
+import org.springframework.context.annotation.Bean
+import org.springframework.context.annotation.ComponentScan
+import org.springframework.context.annotation.Configuration
+
+@Configuration
+@ComponentScan
+@EnableConfigurationProperties
+open class BluePrintDBLibConfiguration(private var bluePrintProperties: BluePrintProperties) {
+
+    @Bean("primary-database-properties")
+    open fun getPrimaryProperties(): PrimaryDataSourceProperties {
+        return bluePrintProperties.propertyBeanType(DBLibConstants.PREFIX_DB_PRIMARY,
+                PrimaryDataSourceProperties::class.java)
+    }
+}
+
+class DBLibConstants {
+    companion object {
+        const val PREFIX_DB_PRIMARY: String = "blueprintsprocessor.db.primary"
+    }
+}
\ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BluePrintDBLibData.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BluePrintDBLibData.kt
new file mode 100644 (file)
index 0000000..a16e556
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.db
+
+
+open class PrimaryDataSourceProperties {
+    lateinit var url: String
+    lateinit var username: String
+    lateinit var password: String
+    lateinit var driverClassName: String
+    lateinit var hibernateHbm2ddlAuto: String
+    lateinit var hibernateDDLAuto: String
+    lateinit var hibernateNamingStrategy: String
+    lateinit var hibernateDialect: String
+}
\ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BluePrintDBLibGenericService.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BluePrintDBLibGenericService.kt
new file mode 100644 (file)
index 0000000..86420f9
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * 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
+
+import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate
+
+interface BluePrintDBLibGenericService {
+
+    fun namedParameterJdbcTemplate(): NamedParameterJdbcTemplate
+
+    fun query(sql: String, params: Map<String, Any>): List<Map<String, Any>>
+
+    fun update(sql: String, params: Map<String, Any>): Int
+}
\ 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
new file mode 100644 (file)
index 0000000..bf76e21
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.db.primary
+
+import org.onap.ccsdk.apps.blueprintsprocessor.db.PrimaryDataSourceProperties
+import org.slf4j.LoggerFactory
+import org.springframework.context.annotation.Bean
+import org.springframework.context.annotation.Configuration
+import org.springframework.context.annotation.Primary
+import org.springframework.data.jpa.repository.config.EnableJpaRepositories
+import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate
+import org.springframework.jdbc.datasource.DriverManagerDataSource
+import org.springframework.orm.jpa.JpaTransactionManager
+import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean
+import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter
+import org.springframework.transaction.PlatformTransactionManager
+import java.util.*
+import javax.sql.DataSource
+
+@Configuration
+@EnableJpaRepositories(
+        basePackages = ["org.onap.ccsdk.apps.blueprintsprocessor.db.primary"],
+        entityManagerFactoryRef = "primaryEntityManager",
+        transactionManagerRef = "primaryTransactionManager"
+)
+open class PrimaryDatabaseConfiguration(private val primaryDataSourceProperties: PrimaryDataSourceProperties) {
+    val log = LoggerFactory.getLogger(PrimaryDatabaseConfiguration::class.java)!!
+
+    @Primary
+    @Bean("primaryEntityManager")
+    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
+        val properties = HashMap<String, Any>()
+        properties["hibernate.hbm2ddl.auto"] = primaryDataSourceProperties.hibernateHbm2ddlAuto
+        properties["hibernate.dialect"] = primaryDataSourceProperties.hibernateDialect
+        em.jpaPropertyMap = properties
+        return em
+    }
+
+    @Primary
+    @Bean("primaryDataSource")
+    open fun primaryDataSource(): DataSource {
+        val dataSource = DriverManagerDataSource()
+        dataSource.setDriverClassName(primaryDataSourceProperties.driverClassName)
+        dataSource.url = primaryDataSourceProperties.url
+        dataSource.username = primaryDataSourceProperties.username
+        dataSource.password = primaryDataSourceProperties.password
+        return dataSource
+    }
+
+    @Primary
+    @Bean("primaryTransactionManager")
+    open fun primaryTransactionManager(): PlatformTransactionManager {
+        val transactionManager = JpaTransactionManager()
+        transactionManager.entityManagerFactory = primaryEntityManager().getObject()
+        log.info("Initialised Primary Transaction Manager for url ${primaryDataSourceProperties.url}")
+        return transactionManager
+    }
+
+    @Bean("primaryNamedParameterJdbcTemplate")
+    open fun primaryNamedParameterJdbcTemplate(primaryDataSource: DataSource): NamedParameterJdbcTemplate {
+        return NamedParameterJdbcTemplate(primaryDataSource)
+    }
+
+}
\ 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/service/PrimaryDBLibGenericService.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/service/PrimaryDBLibGenericService.kt
new file mode 100644 (file)
index 0000000..87f32ef
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * 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.service
+
+import org.onap.ccsdk.apps.blueprintsprocessor.db.BluePrintDBLibGenericService
+import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate
+import org.springframework.stereotype.Service
+
+@Service
+class PrimaryDBLibGenericService(private val primaryNamedParameterJdbcTemplate: NamedParameterJdbcTemplate)
+    : BluePrintDBLibGenericService {
+
+    override fun namedParameterJdbcTemplate(): NamedParameterJdbcTemplate {
+        return primaryNamedParameterJdbcTemplate
+    }
+
+    override fun query(sql: String, params: Map<String, Any>): List<Map<String, Any>> {
+        return primaryNamedParameterJdbcTemplate.queryForList(sql, params)
+    }
+
+    override fun update(sql: String, params: Map<String, Any>): Int {
+        return primaryNamedParameterJdbcTemplate.update(sql, params)
+    }
+}
\ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/PrimaryDatabaseConfigurationTest.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/primary/PrimaryDatabaseConfigurationTest.kt
new file mode 100644 (file)
index 0000000..aa48c8e
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.db.primary
+
+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.db.BluePrintDBLibConfiguration
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.test.context.ContextConfiguration
+import org.springframework.test.context.TestPropertySource
+import org.springframework.test.context.junit4.SpringRunner
+import javax.sql.DataSource
+import kotlin.test.assertNotNull
+
+@RunWith(SpringRunner::class)
+@ContextConfiguration(classes = [BlueprintPropertyConfiguration::class, BluePrintProperties::class,
+    BluePrintDBLibConfiguration::class])
+@TestPropertySource(locations = ["classpath:application-test.properties"])
+class PrimaryDatabaseConfigurationTest {
+
+    @Autowired
+    lateinit var primaryDataSource: DataSource
+
+    @Test
+    fun testPrimaryDatabaseConfiguration() {
+        assertNotNull(primaryDataSource, " failed to create primary data source")
+    }
+}
\ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/test/resources/application-test.properties b/ms/blueprintsprocessor/modules/commons/db-lib/src/test/resources/application-test.properties
new file mode 100644 (file)
index 0000000..672ff80
--- /dev/null
@@ -0,0 +1,24 @@
+# suppress inspection "UnusedProperty" for whole file
+#
+# 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.
+#
+blueprintsprocessor.db.primary.url=jdbc:h2:mem:testdb;DB_CLOSE_ON_EXIT=FALSE
+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
\ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/test/resources/logback-test.xml b/ms/blueprintsprocessor/modules/commons/db-lib/src/test/resources/logback-test.xml
new file mode 100644 (file)
index 0000000..f9ec9fe
--- /dev/null
@@ -0,0 +1,35 @@
+<!--\r
+  ~ Copyright © 2017-2018 AT&T Intellectual Property.\r
+  ~\r
+  ~ Licensed under the Apache License, Version 2.0 (the "License");\r
+  ~ you may not use this file except in compliance with the License.\r
+  ~ You may obtain a copy of the License at\r
+  ~\r
+  ~     http://www.apache.org/licenses/LICENSE-2.0\r
+  ~\r
+  ~ Unless required by applicable law or agreed to in writing, software\r
+  ~ distributed under the License is distributed on an "AS IS" BASIS,\r
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+  ~ See the License for the specific language governing permissions and\r
+  ~ limitations under the License.\r
+  -->\r
+\r
+<configuration>\r
+    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">\r
+        <!-- encoders are assigned the type\r
+             ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->\r
+        <encoder>\r
+            <pattern>%d{HH:mm:ss.SSS} %-5level %logger{100} - %msg%n</pattern>\r
+        </encoder>\r
+    </appender>\r
+\r
+    <logger name="org.springframework.test" level="warn"/>\r
+    <logger name="org.springframework" level="warn"/>\r
+    <logger name="org.hibernate" level="info"/>\r
+    <logger name="org.onap.ccsdk.apps.blueprintsprocessor" level="info"/>\r
+\r
+    <root level="warn">\r
+        <appender-ref ref="STDOUT"/>\r
+    </root>\r
+\r
+</configuration>\r
index 7bfec58..f38ccab 100644 (file)
             <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
             <artifactId>resource-dict</artifactId>
         </dependency>
+        <!-- Test Dependencies -->
+        <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>
+            <scope>test</scope>
+        </dependency>
         <dependency>
             <groupId>org.jetbrains.kotlin</groupId>
             <artifactId>kotlin-test-junit</artifactId>
index 6dfe111..da6194a 100644 (file)
   ~  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">
-       <modelVersion>4.0.0</modelVersion>
-       <parent>
-               <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
-               <artifactId>commons</artifactId>
-               <version>0.4.0-SNAPSHOT</version>
-       </parent>
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
+        <artifactId>commons</artifactId>
+        <version>0.4.0-SNAPSHOT</version>
+    </parent>
 
-       <artifactId>rest-lib</artifactId>
-       <packaging>jar</packaging>
-       <name>Blueprints Processor Rest Lib</name>
-       <description>Blueprints Processor Rest Lib</description>
-       <dependencies>
-               <dependency>
-                       <groupId>org.springframework.boot</groupId>
-                       <artifactId>spring-boot-starter-webflux</artifactId>
-               </dependency>
-       </dependencies>
+    <artifactId>rest-lib</artifactId>
+    <packaging>jar</packaging>
+    <name>Blueprints Processor Rest Lib</name>
+    <description>Blueprints Processor Rest Lib</description>
+    <dependencies>
+        <dependency>
+            <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
+            <artifactId>core</artifactId>
+        </dependency>
+    </dependencies>
 
 </project>
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibConfiguration.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibConfiguration.kt
new file mode 100644 (file)
index 0000000..50d69ae
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.rest
+
+import org.springframework.boot.context.properties.EnableConfigurationProperties
+import org.springframework.context.annotation.ComponentScan
+import org.springframework.context.annotation.Configuration
+
+@Configuration
+@ComponentScan
+@EnableConfigurationProperties
+open class BluePrintRestLibConfiguration
+
+
+class RestLibConstants {
+    companion object {
+        const val TYPE_BASIC_AUTH = "basic-auth"
+        const val TYPE_SSL_BASIC_AUTH = "ssl-basic-auth"
+        const val TYPE_DME2_PROXY = "dme2-proxy"
+        const val TYPE_POLICY_MANAGER = "policy-manager"
+    }
+}
\ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibData.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibData.kt
new file mode 100644 (file)
index 0000000..faf4fd4
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * 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.rest
+
+open class RestClientProperties {
+    lateinit var type: String
+    lateinit var url: String
+    lateinit var userId: String
+}
+
+open class BasicAuthRestClientProperties : RestClientProperties() {
+    var passwd: String? = null
+}
+
+open class SSLBasicAuthRestClientProperties : RestClientProperties() {
+    lateinit var sslTrust: String
+    lateinit var sslTrustPasswd: String
+    lateinit var sslKey: String
+    lateinit var sslKeyPasswd: String
+}
+
+open class DME2RestClientProperties : RestClientProperties() {
+    lateinit var service: String
+    lateinit var subContext: String
+    lateinit var version: String
+    lateinit var envContext: String
+    lateinit var routeOffer: String
+    var partner: String? = null
+    lateinit var appId: String
+}
+
+open class PolicyManagerRestClientProperties : RestClientProperties() {
+    lateinit var env: String
+    lateinit var clientAuth: String
+    lateinit var authorisation: String
+}
\ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BasicAuthRestClientService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BasicAuthRestClientService.kt
new file mode 100644 (file)
index 0000000..b79034b
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * 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.rest.service
+
+import org.onap.ccsdk.apps.blueprintsprocessor.rest.RestClientProperties
+import org.springframework.web.reactive.function.client.WebClient
+
+
+class BasicAuthRestClientService(restClientProperties: RestClientProperties) : BlueprintWebClientService {
+
+    override fun webClient(): WebClient {
+        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+    }
+
+    override fun <T> getResource(path: String, responseType: Class<T>): T {
+        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+    }
+
+    override fun <T> postResource(path: String, request: Any, responseType: Class<T>): T {
+        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+    }
+
+    override fun <T> exchangeResource(methodType: String, path: String, request: Any, responseType: Class<T>): T {
+        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/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BluePrintRestLibPropertyService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BluePrintRestLibPropertyService.kt
new file mode 100644 (file)
index 0000000..21d080d
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * 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.rest.service
+
+import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintProperties
+import org.onap.ccsdk.apps.blueprintsprocessor.rest.*
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import org.springframework.stereotype.Service
+
+@Service
+open class BluePrintRestLibPropertyService(private var bluePrintProperties: BluePrintProperties) {
+
+    @Throws(BluePrintProcessorException::class)
+    fun restClientProperties(prefix: String): RestClientProperties {
+        val type = bluePrintProperties.propertyBeanType("$prefix.type", String::class.java)
+        return when (type) {
+            RestLibConstants.TYPE_BASIC_AUTH -> {
+                basicAuthRestClientProperties(prefix)
+            }
+            RestLibConstants.TYPE_SSL_BASIC_AUTH -> {
+                sslBasicAuthRestClientProperties(prefix)
+            }
+            RestLibConstants.TYPE_DME2_PROXY -> {
+                dme2ProxyClientProperties(prefix)
+            }
+            RestLibConstants.TYPE_POLICY_MANAGER -> {
+                policyManagerRestClientProperties(prefix)
+            }
+            else -> {
+                throw BluePrintProcessorException("Rest adaptor($type) is not supported")
+            }
+        }
+    }
+
+    @Throws(BluePrintProcessorException::class)
+    fun blueprintWebClientService(selector: String): BlueprintWebClientService {
+        val prefix = "blueprintsprocessor.restclient.$selector"
+        val beanProperties = restClientProperties(prefix)
+        when (beanProperties) {
+            is BasicAuthRestClientProperties -> {
+                return BasicAuthRestClientService(beanProperties)
+            }
+            is SSLBasicAuthRestClientProperties -> {
+                return SSLBasicAuthRestClientService(beanProperties)
+            }
+            is DME2RestClientProperties -> {
+                return DME2ProxyRestClientService(beanProperties)
+            }
+            else -> {
+                throw BluePrintProcessorException("couldn't get rest service for selector($selector)")
+            }
+        }
+
+    }
+
+    fun basicAuthRestClientProperties(prefix: String): BasicAuthRestClientProperties {
+        return bluePrintProperties.propertyBeanType(prefix, BasicAuthRestClientProperties::class.java)
+    }
+
+    fun sslBasicAuthRestClientProperties(prefix: String): SSLBasicAuthRestClientProperties {
+        return bluePrintProperties.propertyBeanType(prefix, SSLBasicAuthRestClientProperties::class.java)
+    }
+
+    fun dme2ProxyClientProperties(prefix: String): DME2RestClientProperties {
+        return bluePrintProperties.propertyBeanType(prefix, DME2RestClientProperties::class.java)
+    }
+
+    fun policyManagerRestClientProperties(prefix: String): PolicyManagerRestClientProperties {
+        return bluePrintProperties.propertyBeanType(prefix, PolicyManagerRestClientProperties::class.java)
+    }
+}
+
+
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BlueprintWebClientService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BlueprintWebClientService.kt
new file mode 100644 (file)
index 0000000..232f4bb
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * 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.rest.service
+
+import org.springframework.web.reactive.function.client.WebClient
+
+interface BlueprintWebClientService {
+
+    fun webClient(): WebClient
+
+    fun <T> getResource(path: String, responseType: Class<T>): T
+
+    fun <T> postResource(path: String, request: Any, responseType: Class<T>): T
+
+    fun <T> exchangeResource(methodType: String, path: String, request: Any, responseType: Class<T>): T
+
+}
+
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/DME2ProxyRestClientService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/DME2ProxyRestClientService.kt
new file mode 100644 (file)
index 0000000..bd46ced
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * 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.rest.service
+
+import org.onap.ccsdk.apps.blueprintsprocessor.rest.RestClientProperties
+import org.springframework.web.reactive.function.client.WebClient
+
+class DME2ProxyRestClientService(restClientProperties: RestClientProperties) : BlueprintWebClientService {
+    override fun webClient(): WebClient {
+        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+    }
+
+    override fun <T> getResource(path: String, responseType: Class<T>): T {
+        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+    }
+
+    override fun <T> postResource(path: String, request: Any, responseType: Class<T>): T {
+        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+    }
+
+    override fun <T> exchangeResource(methodType: String, path: String, request: Any, responseType: Class<T>): T {
+        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/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/SSLBasicAuthRestClientService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/SSLBasicAuthRestClientService.kt
new file mode 100644 (file)
index 0000000..8b4add1
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * 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.rest.service
+
+import org.onap.ccsdk.apps.blueprintsprocessor.rest.RestClientProperties
+import org.springframework.web.reactive.function.client.WebClient
+
+class SSLBasicAuthRestClientService(restClientProperties: RestClientProperties) : BlueprintWebClientService {
+    override fun webClient(): WebClient {
+        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+    }
+
+    override fun <T> getResource(path: String, responseType: Class<T>): T {
+        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+    }
+
+    override fun <T> postResource(path: String, request: Any, responseType: Class<T>): T {
+        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+    }
+
+    override fun <T> exchangeResource(methodType: String, path: String, request: Any, responseType: Class<T>): T {
+        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/modules/commons/rest-lib/src/main/resources/application.properties b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/resources/application.properties
new file mode 100644 (file)
index 0000000..2ce8714
--- /dev/null
@@ -0,0 +1,16 @@
+#\r
+#  Copyright © 2017-2018 AT&T Intellectual Property.\r
+#\r
+#  Licensed under the Apache License, Version 2.0 (the "License");\r
+#  you may not use this file except in compliance with the License.\r
+#  You may obtain a copy of the License at\r
+#\r
+#      http://www.apache.org/licenses/LICENSE-2.0\r
+#\r
+#  Unless required by applicable law or agreed to in writing, software\r
+#  distributed under the License is distributed on an "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+#  See the License for the specific language governing permissions and\r
+#  limitations under the License.\r
+#\r
+\r
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/RestPropertyPlaceHolderConfigurationTest.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/RestPropertyPlaceHolderConfigurationTest.kt
new file mode 100644 (file)
index 0000000..d5e2743
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * 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.rest.service
+
+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.rest.BluePrintRestLibConfiguration
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.test.context.ContextConfiguration
+import org.springframework.test.context.TestPropertySource
+import org.springframework.test.context.junit4.SpringRunner
+import kotlin.test.assertNotNull
+
+
+@RunWith(SpringRunner::class)
+@ContextConfiguration(classes = [BluePrintRestLibConfiguration::class, BlueprintPropertyConfiguration::class, BluePrintProperties::class])
+@TestPropertySource(properties =
+["blueprintsprocessor.restclient.sample.type=basic-auth",
+    "blueprintsprocessor.restclient.sample.url=http://localhost:8080",
+    "blueprintsprocessor.restclient.sample.userId=sampleuser"])
+
+class RestPropertyPlaceHolderConfigurationTest {
+
+    @Autowired
+    lateinit var bluePrintRestLibPropertyService: BluePrintRestLibPropertyService
+
+    @Test
+    fun testRestClientProperties() {
+        val properties = bluePrintRestLibPropertyService.restClientProperties("blueprintsprocessor.restclient.sample")
+        assertNotNull(properties, "failed to create property bean")
+        assertNotNull(properties.url, "failed to get url property in property bean")
+    }
+
+    @Test
+    fun testBlueprintWebClientService() {
+        val blueprintWebClientService = bluePrintRestLibPropertyService.blueprintWebClientService("sample")
+        assertNotNull(blueprintWebClientService, "failed to create blueprintWebClientService")
+    }
+
+}
+
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/resources/logback-test.xml b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/resources/logback-test.xml
new file mode 100644 (file)
index 0000000..f9ec9fe
--- /dev/null
@@ -0,0 +1,35 @@
+<!--\r
+  ~ Copyright © 2017-2018 AT&T Intellectual Property.\r
+  ~\r
+  ~ Licensed under the Apache License, Version 2.0 (the "License");\r
+  ~ you may not use this file except in compliance with the License.\r
+  ~ You may obtain a copy of the License at\r
+  ~\r
+  ~     http://www.apache.org/licenses/LICENSE-2.0\r
+  ~\r
+  ~ Unless required by applicable law or agreed to in writing, software\r
+  ~ distributed under the License is distributed on an "AS IS" BASIS,\r
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+  ~ See the License for the specific language governing permissions and\r
+  ~ limitations under the License.\r
+  -->\r
+\r
+<configuration>\r
+    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">\r
+        <!-- encoders are assigned the type\r
+             ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->\r
+        <encoder>\r
+            <pattern>%d{HH:mm:ss.SSS} %-5level %logger{100} - %msg%n</pattern>\r
+        </encoder>\r
+    </appender>\r
+\r
+    <logger name="org.springframework.test" level="warn"/>\r
+    <logger name="org.springframework" level="warn"/>\r
+    <logger name="org.hibernate" level="info"/>\r
+    <logger name="org.onap.ccsdk.apps.blueprintsprocessor" level="info"/>\r
+\r
+    <root level="warn">\r
+        <appender-ref ref="STDOUT"/>\r
+    </root>\r
+\r
+</configuration>\r
index e26af0f..91912c8 100644 (file)
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-actuator</artifactId>
         </dependency>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.jetbrains.kotlin</groupId>
+            <artifactId>kotlin-test-junit</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.powermock</groupId>
+            <artifactId>powermock-api-mockito2</artifactId>
+        </dependency>
     </dependencies>
 </project>
index 8aeb415..fb833a5 100644 (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.services.resolution.ResourceResolutionService;\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
@@ -45,12 +45,4 @@ public class ResourceResolutionController {
     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
index a4c7aaf..f319ca4 100644 (file)
   ~  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">
-       <modelVersion>4.0.0</modelVersion>
-       <parent>
-               <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
-               <artifactId>inbounds</artifactId>
-               <version>0.4.0-SNAPSHOT</version>
-       </parent>
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
+        <artifactId>inbounds</artifactId>
+        <version>0.4.0-SNAPSHOT</version>
+    </parent>
 
-       <artifactId>selfservice-api</artifactId>
-       <packaging>jar</packaging>
-       <name>Blueprints Processor Selfservice API</name>
-       <description>Blueprints Processor Selfservice API</description>
+    <artifactId>selfservice-api</artifactId>
+    <packaging>jar</packaging>
+    <name>Blueprints Processor Selfservice API</name>
+    <description>Blueprints Processor Selfservice API</description>
+
+    <dependencies>
+        <dependency>
+            <groupId>io.grpc</groupId>
+            <artifactId>grpc-testing</artifactId>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <extensions>
+            <extension>
+                <groupId>kr.motd.maven</groupId>
+                <artifactId>os-maven-plugin</artifactId>
+                <version>1.6.1</version>
+            </extension>
+        </extensions>
+        <plugins>
+            <plugin>
+                <groupId>org.xolstice.maven.plugins</groupId>
+                <artifactId>protobuf-maven-plugin</artifactId>
+                <version>0.6.1</version>
+                <configuration>
+                    <protocArtifact>
+                        com.google.protobuf:protoc:3.5.1-1:exe:${os.detected.classifier}
+                    </protocArtifact>
+                    <pluginId>grpc-java</pluginId>
+                    <pluginArtifact>
+                        io.grpc:protoc-gen-grpc-java:1.16.1:exe:${os.detected.classifier}
+                    </pluginArtifact>
+                    <protoSourceRoot>./../../../../../components/model-catalog/api-definition</protoSourceRoot>
+                </configuration>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>compile</goal>
+                            <goal>compile-custom</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
 
 </project>
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintCatalogServiceImpl.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintCatalogServiceImpl.kt
new file mode 100644 (file)
index 0000000..01c9a39
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api
+
+import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintCoreConfiguration
+import org.onap.ccsdk.apps.blueprintsprocessor.core.interfaces.BluePrintCatalogService
+import org.springframework.stereotype.Service
+import java.io.File
+
+@Service
+class BluePrintCatalogServiceImpl(private val bluePrintCoreConfiguration: BluePrintCoreConfiguration) : BluePrintCatalogService {
+
+    override fun prepareBluePrint(name: String, version: String): String {
+        //TODO("Get the Blueprint from the DB")
+        return bluePrintCoreConfiguration.deployPath.plus(File.separator)
+                .plus(name).plus(File.separator).plus(version)
+
+    }
+}
\ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintManagementGRPCHandler.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintManagementGRPCHandler.kt
new file mode 100644 (file)
index 0000000..17191f3
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * 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.selfservice.api
+
+import io.grpc.stub.StreamObserver
+import org.apache.commons.io.FileUtils
+import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintCoreConfiguration
+import org.onap.ccsdk.apps.controllerblueprints.management.api.*
+import org.slf4j.LoggerFactory
+import org.springframework.stereotype.Service
+import java.io.File
+
+@Service
+class BluePrintManagementGRPCHandler(private val bluePrintCoreConfiguration: BluePrintCoreConfiguration)
+    : BluePrintManagementServiceGrpc.BluePrintManagementServiceImplBase() {
+
+    private val log = LoggerFactory.getLogger(BluePrintManagementGRPCHandler::class.java)
+
+    override fun uploadBlueprint(request: BluePrintUploadInput, responseObserver: StreamObserver<BluePrintUploadOutput>) {
+        val response = BluePrintUploadOutput.newBuilder().setCommonHeader(request.commonHeader).build()
+        try {
+            val blueprintName = request.blueprintName
+            val blueprintVersion = request.blueprintVersion
+            val filePath = "${bluePrintCoreConfiguration.archivePath}/$blueprintName/$blueprintVersion"
+            val blueprintDir = File(filePath)
+
+            log.info("Re-creating blueprint directory(${blueprintDir.absolutePath})")
+            FileUtils.deleteDirectory(blueprintDir)
+            FileUtils.forceMkdir(blueprintDir)
+
+            val file = File("${blueprintDir.absolutePath}/$blueprintName.zip")
+            log.info("Writing CBA File under :${file.absolutePath}")
+
+            val fileChunk = request.fileChunk
+
+            file.writeBytes(fileChunk.chunk.toByteArray()).apply {
+                log.info("CBA file(${file.absolutePath} written successfully")
+            }
+        } catch (e: Exception) {
+            log.error("failed to upload file ", e)
+        }
+        responseObserver.onNext(response)
+        responseObserver.onCompleted()
+    }
+
+    override fun removeBlueprint(request: BluePrintRemoveInput?, responseObserver: StreamObserver<BluePrintRemoveOutput>?) {
+        //TODO
+    }
+}
\ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandler.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandler.kt
new file mode 100644 (file)
index 0000000..2a5983d
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api
+
+import com.google.protobuf.util.JsonFormat
+import io.grpc.stub.StreamObserver
+import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintCoreConfiguration
+import org.onap.ccsdk.apps.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc
+import org.onap.ccsdk.apps.controllerblueprints.processing.api.ExecutionServiceInput
+import org.onap.ccsdk.apps.controllerblueprints.processing.api.ExecutionServiceOutput
+import org.slf4j.LoggerFactory
+import org.springframework.stereotype.Service
+
+@Service
+class BluePrintProcessingGRPCHandler(private val bluePrintCoreConfiguration: BluePrintCoreConfiguration)
+    : BluePrintProcessingServiceGrpc.BluePrintProcessingServiceImplBase() {
+    private val log = LoggerFactory.getLogger(BluePrintProcessingGRPCHandler::class.java)
+
+    override fun process(request: ExecutionServiceInput,
+                         responseObserver: StreamObserver<ExecutionServiceOutput>) {
+
+        val json = JsonFormat.printer().print(request)
+
+        //log.info("Received GRPC request ${json}")
+        //TODO( Handle Processing Response")
+        val response = ExecutionServiceOutput.newBuilder().setCommonHeader(request.commonHeader).build()
+        responseObserver.onNext(response)
+        responseObserver.onCompleted()
+    }
+}
\ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt
new file mode 100644 (file)
index 0000000..aa44a06
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api
+
+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.interfaces.BluePrintCatalogService
+import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.BlueprintDGExecutionService
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
+import org.slf4j.LoggerFactory
+import org.springframework.stereotype.Service
+
+@Service
+class ExecutionServiceHandler(private val bluePrintCatalogService: BluePrintCatalogService,
+                              private val blueprintDGExecutionService: BlueprintDGExecutionService) {
+
+    private val log = LoggerFactory.getLogger(ExecutionServiceHandler::class.toString())
+
+    fun process(executionServiceInput: ExecutionServiceInput): ExecutionServiceOutput {
+
+        val requestId = executionServiceInput.commonHeader.requestId
+        log.info("processing request id $requestId")
+
+        val actionIdentifiers = executionServiceInput.actionIdentifiers
+
+        val blueprintName = actionIdentifiers.blueprintName
+        val blueprintVersion = actionIdentifiers.blueprintVersion
+
+        val basePath = bluePrintCatalogService.prepareBluePrint(blueprintName, blueprintVersion)
+        log.info("blueprint base path $basePath")
+
+        val blueprintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(requestId, basePath)
+
+        return blueprintDGExecutionService.executeDirectedGraph(blueprintRuntimeService, executionServiceInput)
+    }
+
+
+}
\ 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/BluePrintManagementGRPCHandlerTest.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintManagementGRPCHandlerTest.kt
new file mode 100644 (file)
index 0000000..c870bf7
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api
+
+import com.google.protobuf.ByteString
+import io.grpc.testing.GrpcServerRule
+import org.apache.commons.io.FileUtils
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintCoreConfiguration
+import org.onap.ccsdk.apps.controllerblueprints.management.api.BluePrintManagementServiceGrpc
+import org.onap.ccsdk.apps.controllerblueprints.management.api.BluePrintUploadInput
+import org.onap.ccsdk.apps.controllerblueprints.management.api.CommonHeader
+import org.onap.ccsdk.apps.controllerblueprints.management.api.FileChunk
+import org.slf4j.LoggerFactory
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.test.context.ContextConfiguration
+import org.springframework.test.context.TestPropertySource
+import org.springframework.test.context.junit4.SpringRunner
+import java.io.File
+import java.nio.file.Paths
+import kotlin.test.AfterTest
+import kotlin.test.BeforeTest
+import kotlin.test.assertNotNull
+import kotlin.test.assertTrue
+
+@RunWith(SpringRunner::class)
+@ContextConfiguration(classes = [BluePrintManagementGRPCHandler::class, BluePrintCoreConfiguration::class])
+@TestPropertySource(locations = ["classpath:application-test.properties"])
+class BluePrintManagementGRPCHandlerTest {
+
+    private val log = LoggerFactory.getLogger(BluePrintProcessingGRPCHandlerTest::class.java)!!
+
+    @get:Rule
+    val grpcServerRule = GrpcServerRule().directExecutor()
+
+    @Autowired
+    lateinit var bluePrintManagementGRPCHandler: BluePrintManagementGRPCHandler
+
+    @BeforeTest
+    fun init() {
+        // Create a server, add service, start, and register for automatic graceful shutdown.
+        grpcServerRule.serviceRegistry.addService(bluePrintManagementGRPCHandler)
+    }
+
+    @AfterTest
+    fun cleanDir() {
+        FileUtils.deleteDirectory(File("./target/blueprints"))
+    }
+
+    @Test
+    fun testFileUpload() {
+        val blockingStub = BluePrintManagementServiceGrpc.newBlockingStub(grpcServerRule.channel)
+
+        val file = Paths.get("./src/test/resources/test-cba.zip").toFile()
+        assertTrue(file.exists(), "couldnt get file ${file.absolutePath}")
+
+        val commonHeader = CommonHeader.newBuilder()
+                .setTimestamp("2012-04-23T18:25:43.511Z")
+                .setOriginatorId("System")
+                .setRequestId("1234")
+                .setSubRequestId("1234-56").build()
+
+        val fileChunk = FileChunk.newBuilder().setChunk(ByteString.copyFrom(file.inputStream().readBytes()))
+                .build()
+
+        val input = BluePrintUploadInput.newBuilder()
+                .setCommonHeader(commonHeader)
+                .setBlueprintName("sample")
+                .setBlueprintVersion("1.0.0")
+                .setFileChunk(fileChunk)
+                .build()
+
+        val output = blockingStub.uploadBlueprint(input)
+        assertNotNull(output, "failed to get upload response")
+    }
+}
\ 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/BluePrintProcessingGRPCHandlerTest.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandlerTest.kt
new file mode 100644 (file)
index 0000000..6d5d633
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api
+
+
+import com.google.protobuf.util.JsonFormat
+import io.grpc.testing.GrpcServerRule
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintCoreConfiguration
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
+import org.onap.ccsdk.apps.controllerblueprints.processing.api.CommonHeader
+import org.onap.ccsdk.apps.controllerblueprints.processing.api.BluePrintProcessingServiceGrpc
+import org.onap.ccsdk.apps.controllerblueprints.processing.api.ExecutionServiceInput
+import org.slf4j.LoggerFactory
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.test.context.ContextConfiguration
+import org.springframework.test.context.TestPropertySource
+import org.springframework.test.context.junit4.SpringRunner
+import kotlin.test.BeforeTest
+import kotlin.test.assertNotNull
+
+@RunWith(SpringRunner::class)
+@ContextConfiguration(classes = [BluePrintProcessingGRPCHandler::class, BluePrintCoreConfiguration::class])
+@TestPropertySource(locations = ["classpath:application-test.properties"])
+class BluePrintProcessingGRPCHandlerTest {
+
+    private val log = LoggerFactory.getLogger(BluePrintProcessingGRPCHandlerTest::class.java)!!
+
+    @get:Rule
+    val grpcServerRule = GrpcServerRule().directExecutor()
+
+    @Autowired
+    lateinit var bluePrintProcessingGRPCHandler: BluePrintProcessingGRPCHandler
+
+    @BeforeTest
+    fun init() {
+        // Create a server, add service, start, and register for automatic graceful shutdown.
+        grpcServerRule.serviceRegistry.addService(bluePrintProcessingGRPCHandler)
+    }
+
+    @Test
+    fun testSelfServiceGRPCHandler() {
+
+        val blockingStub = BluePrintProcessingServiceGrpc.newBlockingStub(grpcServerRule.channel)
+
+        val commonHeader = CommonHeader.newBuilder()
+                .setTimestamp("2012-04-23T18:25:43.511Z")
+                .setOriginatorId("System")
+                .setRequestId("1234")
+                .setSubRequestId("1234-56").build()
+
+        val jsonContent = JacksonUtils.getClassPathFileContent("execution-input/sample-payload.json")
+        val payloadBuilder = ExecutionServiceInput.newBuilder().payloadBuilder
+        JsonFormat.parser().merge(jsonContent, payloadBuilder)
+
+        val input = ExecutionServiceInput.newBuilder()
+                .setCommonHeader(commonHeader)
+                .setPayload(payloadBuilder.build())
+                .build()
+
+        val response = blockingStub.process(input)
+        assertNotNull(response, "Response is null")
+    }
+
+}
\ 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/ExecutionServiceHandlerTest.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceHandlerTest.kt
new file mode 100644 (file)
index 0000000..e9e1030
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * 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.selfservice.api
+
+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.selfservice.api.mock.MockBluePrintCatalogService
+import org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api.mock.MockBlueprintDGExecutionService
+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 = [MockBluePrintCatalogService::class,
+    MockBlueprintDGExecutionService::class, ExecutionServiceHandler::class])
+class ExecutionServiceHandlerTest {
+
+    @Autowired
+    lateinit var executionServiceHandler: ExecutionServiceHandler
+
+    @Test
+    fun testProcess() {
+        val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
+                "./../../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration")
+
+        val executionServiceInput = JacksonUtils.readValueFromClassPathFile("execution-input/default-input.json", ExecutionServiceInput::class.java)!!
+        executionServiceHandler.process(executionServiceInput)
+
+    }
+
+}
+
+
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/mock/SelfServiceApiMocks.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/mock/SelfServiceApiMocks.kt
new file mode 100644 (file)
index 0000000..bc200f4
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * 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.selfservice.api.mock
+
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceOutput
+import org.onap.ccsdk.apps.blueprintsprocessor.core.interfaces.BluePrintCatalogService
+import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.BlueprintDGExecutionService
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+import org.springframework.stereotype.Service
+import kotlin.test.assertNotNull
+
+@Service
+class MockBlueprintDGExecutionService : BlueprintDGExecutionService {
+    override fun executeDirectedGraph(bluePrintRuntimeService: BluePrintRuntimeService<*>, executionServiceInput: ExecutionServiceInput): ExecutionServiceOutput {
+
+        assertNotNull(executionServiceInput, "failed to get executionServiceInput")
+
+        val executionServiceOutput = ExecutionServiceOutput()
+        executionServiceOutput.commonHeader = executionServiceInput.commonHeader
+        return executionServiceOutput
+    }
+}
+
+@Service
+class MockBluePrintCatalogService : BluePrintCatalogService {
+    override fun prepareBluePrint(name: String, version: String): String {
+        assertNotNull(name, "failed to get blueprint Name")
+        assertNotNull(version, "failed to get blueprint version")
+        return "./../../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration"
+    }
+}
\ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/application-test.properties b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/application-test.properties
new file mode 100644 (file)
index 0000000..edb5102
--- /dev/null
@@ -0,0 +1,17 @@
+#
+# Copyright © 2017-2018 AT&T Intellectual Property.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+blueprintsprocessor.blueprintDeployPath=./target/blueprints/deploy
+blueprintsprocessor.blueprintArchivePath=./target/blueprints/archive
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/execution-input/default-input.json b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/execution-input/default-input.json
new file mode 100644 (file)
index 0000000..47ace85
--- /dev/null
@@ -0,0 +1,23 @@
+{
+  "commonHeader": {
+    "originatorId": "System",
+    "requestId": "1234",
+    "subRequestId": "1234-12234"
+  },
+  "actionIdentifiers": {
+    "blueprintName": "baseconfiguration",
+    "blueprintVersion": "1.0.0",
+    "actionName": "activate",
+    "mode": "sync"
+  },
+  "payload": {
+    "activate-request": {
+      "activate-properties": {
+        "request-id": "1234",
+        "action-name": "activate",
+        "scope-type": "vnf-type",
+        "hostname": "localhost"
+      }
+    }
+  }
+}
\ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/execution-input/sample-payload.json b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/execution-input/sample-payload.json
new file mode 100644 (file)
index 0000000..07046aa
--- /dev/null
@@ -0,0 +1,10 @@
+{
+  "activate-request": {
+    "activate-properties": {
+      "request-id": "1234",
+      "action-name": "activate",
+      "scope-type": "vnf-type",
+      "hostname": "localhost"
+    }
+  }
+}
\ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/logback.xml b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/logback.xml
new file mode 100644 (file)
index 0000000..a816a06
--- /dev/null
@@ -0,0 +1,35 @@
+<!--\r
+  ~ Copyright © 2017-2018 AT&T Intellectual Property.\r
+  ~\r
+  ~ Licensed under the Apache License, Version 2.0 (the "License");\r
+  ~ you may not use this file except in compliance with the License.\r
+  ~ You may obtain a copy of the License at\r
+  ~\r
+  ~     http://www.apache.org/licenses/LICENSE-2.0\r
+  ~\r
+  ~ Unless required by applicable law or agreed to in writing, software\r
+  ~ distributed under the License is distributed on an "AS IS" BASIS,\r
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+  ~ See the License for the specific language governing permissions and\r
+  ~ limitations under the License.\r
+  -->\r
+\r
+<configuration>\r
+    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">\r
+        <!-- encoders are assigned the type\r
+             ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->\r
+        <encoder>\r
+            <pattern>%d{HH:mm:ss.SSS} %-5level %logger{100} - %msg%n</pattern>\r
+        </encoder>\r
+    </appender>\r
+\r
+\r
+    <logger name="org.springframework" level="warn"/>\r
+    <logger name="org.hibernate" level="info"/>\r
+    <logger name="org.onap.ccsdk.apps.blueprintsprocessor" level="info"/>\r
+\r
+    <root level="warn">\r
+        <appender-ref ref="STDOUT"/>\r
+    </root>\r
+\r
+</configuration>\r
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/test-cba.zip b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/test-cba.zip
new file mode 100644 (file)
index 0000000..a62d4bf
Binary files /dev/null and b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/test-cba.zip differ
index 4f0e6c0..f9e5191 100644 (file)
             <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
             <artifactId>core</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
+            <artifactId>db-lib</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
+            <artifactId>rest-lib</artifactId>
+        </dependency>
         <dependency>
             <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
             <artifactId>resource-dict</artifactId>
index dfdf625..87a925f 100644 (file)
 package org.onap.ccsdk.apps.blueprintsprocessor.services.execution\r
 \r
 \r
+import com.fasterxml.jackson.databind.JsonNode\r
+import com.fasterxml.jackson.databind.node.JsonNodeFactory\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
 import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService\r
@@ -30,6 +35,7 @@ import org.slf4j.LoggerFactory
  * @author Brinda Santh\r
  */\r
 abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServiceInput, ExecutionServiceOutput> {\r
+    @Transient\r
     private val log = LoggerFactory.getLogger(AbstractComponentFunction::class.java)\r
 \r
     var executionServiceInput: ExecutionServiceInput? = null\r
@@ -41,29 +47,67 @@ abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServic
     var interfaceName: String = ""\r
     var operationName: String = ""\r
     var nodeTemplateName: String = ""\r
+    var operationInputs: MutableMap<String, JsonNode> = hashMapOf()\r
 \r
+    override fun getName(): String {\r
+        return stepName\r
+    }\r
 \r
     override fun prepareRequest(executionServiceInput: ExecutionServiceInput): ExecutionServiceInput {\r
+        checkNotNull(bluePrintRuntimeService) { "failed to prepare blueprint runtime" }\r
+\r
+        check(stepName.isNotEmpty()) { "failed to assign step name" }\r
 \r
-        this.executionServiceInput = this.executionServiceInput\r
+        this.executionServiceInput = executionServiceInput\r
 \r
         processId = executionServiceInput.commonHeader.requestId\r
+        check(processId.isNotEmpty()) { "couldn't get process id for step($stepName)" }\r
+\r
         workflowName = executionServiceInput.actionIdentifiers.actionName\r
+        check(workflowName.isNotEmpty()) { "couldn't get action name for step($stepName)" }\r
 \r
-        val metadata = executionServiceInput.metadata\r
-        stepName = metadata.getAsString(BluePrintConstants.PROPERTY_CURRENT_STEP)\r
-        nodeTemplateName = metadata.getAsString(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE)\r
-        interfaceName = metadata.getAsString(BluePrintConstants.PROPERTY_CURRENT_INTERFACE)\r
-        operationName = metadata.getAsString(BluePrintConstants.PROPERTY_CURRENT_OPERATION)\r
+        log.info("preparing request id($processId) for workflow($workflowName) step($stepName)")\r
 \r
-        checkNotNull(bluePrintRuntimeService) { "failed to prepare blueprint runtime" }\r
+        val operationInputs = bluePrintRuntimeService!!.get("$stepName-step-inputs")\r
+                ?: JsonNodeFactory.instance.objectNode()\r
+\r
+        operationInputs.fields().forEach {\r
+            this.operationInputs[it.key] = it.value\r
+        }\r
+\r
+        nodeTemplateName = this.operationInputs.getAsString(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE)\r
+        check(nodeTemplateName.isNotEmpty()) { "couldn't get NodeTemplate name for step($stepName)" }\r
+\r
+        interfaceName = this.operationInputs.getAsString(BluePrintConstants.PROPERTY_CURRENT_INTERFACE)\r
+        check(interfaceName.isNotEmpty()) { "couldn't get Interface name for step($stepName)" }\r
+\r
+        operationName = this.operationInputs.getAsString(BluePrintConstants.PROPERTY_CURRENT_OPERATION)\r
+        check(operationName.isNotEmpty()) { "couldn't get Operation name for step($stepName)" }\r
+\r
+\r
+        val operationResolvedProperties = bluePrintRuntimeService!!.resolveNodeTemplateInterfaceOperationInputs(nodeTemplateName, interfaceName, operationName)\r
+\r
+        this.operationInputs.putAll(operationResolvedProperties)\r
 \r
-        log.info("prepareRequest...")\r
         return executionServiceInput\r
     }\r
 \r
     override fun prepareResponse(): ExecutionServiceOutput {\r
         log.info("Preparing Response...")\r
+        executionServiceOutput.commonHeader = executionServiceInput!!.commonHeader\r
+\r
+        // Resolve the Output Expression\r
+        val stepOutputs = bluePrintRuntimeService!!\r
+                .resolveNodeTemplateInterfaceOperationOutputs(nodeTemplateName, interfaceName, operationName)\r
+\r
+        bluePrintRuntimeService!!.put("$stepName-step-outputs", stepOutputs.asJsonNode())\r
+\r
+        // Populate Status\r
+        val status = Status()\r
+        status.eventType = "EVENT-COMPONENT-EXECUTED"\r
+        status.code = 200\r
+        status.message = BluePrintConstants.STATUS_SUCCESS\r
+        executionServiceOutput.status = status\r
         return this.executionServiceOutput\r
     }\r
 \r
@@ -72,4 +116,9 @@ abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServic
         process(executionServiceInput)\r
         return prepareResponse()\r
     }\r
+\r
+    fun getOperationInput(key: String): JsonNode {\r
+        return operationInputs[key]\r
+                ?: throw BluePrintProcessorException("couldn't get the operation input($key) value.")\r
+    }\r
 }
\ No newline at end of file
index 993f10e..9bb562b 100644 (file)
@@ -19,7 +19,6 @@ package org.onap.ccsdk.apps.blueprintsprocessor.services.workflow
 import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
 import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceOutput
 import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.utils.SvcGraphUtils
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
 import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
 import org.slf4j.LoggerFactory
 import org.springframework.stereotype.Service
@@ -55,14 +54,17 @@ class DefaultBlueprintDGExecutionService(val blueprintSvcLogicService: Blueprint
                 WorkflowServiceConstants.ARTIFACT_TYPE_DIRECTED_GRAPH)
 
         // Populate the DG Path
-        val dgFilePath = bluePrintRuntimeService.getAsString(BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH)
-                .plus(File.separator).plus(artifactDefinition.file)
+        val dgFilePath = bluePrintContext.rootPath.plus(File.separator).plus(artifactDefinition.file)
 
         log.info("Executing directed graph ($dgFilePath)")
 
         // Create DG instance
         val graph = SvcGraphUtils.getSvcGraphFromFile(dgFilePath)
 
+        // Assign Workflow inputs
+        val input = executionServiceInput.payload.get("$workflowName-request")
+        bluePrintRuntimeService.assignWorkflowInputs(workflowName, input)
+
         // Execute the DG
         return blueprintSvcLogicService.execute(graph, bluePrintRuntimeService, executionServiceInput) as ExecutionServiceOutput
 
index ace9f27..e514a1f 100644 (file)
 
 package org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.executor
 
+import com.fasterxml.jackson.databind.JsonNode
 import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
 import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction
 import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.BlueprintSvcLogicContext
+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.sli.core.sli.SvcLogicContext
 import org.onap.ccsdk.sli.core.sli.SvcLogicException
 import org.onap.ccsdk.sli.core.sli.SvcLogicNode
@@ -57,13 +61,27 @@ open class ComponentExecuteNodeExecutor : ExecuteNodeExecutor() {
             // Get the Component Name, NodeTemplate type is mapped to Component Name
             val componentName = blueprintContext.nodeTemplateByName(nodeTemplateName).type
 
-            log.info("executing node template($nodeTemplateName) component($componentName)")
+            val interfaceName = blueprintContext.nodeTemplateFirstInterfaceName(nodeTemplateName)
+
+            val operationName = blueprintContext.nodeTemplateFirstInterfaceFirstOperationName(nodeTemplateName)
+
+            log.info("executing node template($nodeTemplateName) component($componentName) interface($interfaceName) operation($operationName)")
             // Get the Component Instance
             val plugin = this.getComponentFunction(componentName)
             // Set the Blueprint Service
             plugin.bluePrintRuntimeService = ctx.getBluePrintService()
+            plugin.stepName = nodeTemplateName
 
             val executionInput = ctx.getRequest() as ExecutionServiceInput
+
+            // Populate Step Meta Data
+            val stepInputs: MutableMap<String, JsonNode> = hashMapOf()
+            stepInputs.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, nodeTemplateName)
+            stepInputs.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_INTERFACE, interfaceName)
+            stepInputs.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_OPERATION, operationName)
+
+            plugin.bluePrintRuntimeService!!.put("$nodeTemplateName-step-inputs", stepInputs.asJsonNode())
+
             // Get the Request from the Context and Set to the Function Input and Invoke the function
             val executionOutput = plugin.apply(executionInput)
 
index 46bb6f0..2d0dff5 100644 (file)
@@ -43,7 +43,7 @@ class BlueprintDGExecutionServiceTest {
         val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
                 "./../../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration")
 
-        val executionServiceInput = JacksonUtils.readValueFromClassPathFile("execution-input/default-input.json", ExecutionServiceInput::class.java)!!
+        val executionServiceInput = JacksonUtils.readValueFromClassPathFile("execution-input/resource-assignment-input.json", ExecutionServiceInput::class.java)!!
 
         blueprintDGExecutionService.executeDirectedGraph(bluePrintRuntimeService, executionServiceInput)
 
index 341b6f8..7312d2d 100644 (file)
@@ -20,13 +20,16 @@ import org.junit.Test
 import org.junit.runner.RunWith
 import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
 import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.executor.ComponentExecuteNodeExecutor
-import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.utils.SvcGraphUtils
+import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.mock.PrototypeComponentFunction
+import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.mock.SingletonComponentFunction
 import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
 import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
 import org.slf4j.LoggerFactory
 import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.context.ApplicationContext
 import org.springframework.test.context.ContextConfiguration
 import org.springframework.test.context.junit4.SpringRunner
+import kotlin.test.assertEquals
 
 @RunWith(SpringRunner::class)
 @ContextConfiguration(classes = [WorkflowServiceConfiguration::class, ComponentExecuteNodeExecutor::class])
@@ -34,27 +37,57 @@ class BlueprintServiceLogicTest {
 
     private val log = LoggerFactory.getLogger(BlueprintServiceLogicTest::class.java)
 
-    val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
-            "./../../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration")
-
-    val executionServiceInput = JacksonUtils.readValueFromClassPathFile("execution-input/default-input.json", ExecutionServiceInput::class.java)!!
+    @Autowired
+    lateinit var applicationContext: ApplicationContext
 
     @Autowired
-    lateinit var blueprintSvcLogicService: BlueprintSvcLogicService
+    lateinit var blueprintDGExecutionService: BlueprintDGExecutionService
 
     @Test
     fun testExecuteGraphWithSingleComponent() {
 
-        val graph = SvcGraphUtils.getSvcGraphFromClassPathFile("service-logic/one-component.xml")
-        blueprintSvcLogicService.execute(graph, bluePrintRuntimeService, executionServiceInput)
+        val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
+                "./../../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration")
+
+        val executionServiceInput = JacksonUtils.readValueFromClassPathFile("execution-input/resource-assignment-input.json", ExecutionServiceInput::class.java)!!
+
+
+        blueprintDGExecutionService.executeDirectedGraph(bluePrintRuntimeService, executionServiceInput)
 
     }
 
     @Test
     fun testExecuteGraphWithMultipleComponents() {
-        val graph = SvcGraphUtils.getSvcGraphFromClassPathFile("service-logic/two-component.xml")
-        blueprintSvcLogicService.execute(graph, bluePrintRuntimeService, executionServiceInput)
 
+        val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
+                "./../../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration")
+
+        val executionServiceInput = JacksonUtils.readValueFromClassPathFile("execution-input/assign-activate-input.json", ExecutionServiceInput::class.java)!!
+
+        blueprintDGExecutionService.executeDirectedGraph(bluePrintRuntimeService, executionServiceInput)
+
+    }
+
+    @Test
+    fun testSingleton() {
+        val singleton1 = applicationContext.getBean(SingletonComponentFunction::class.java)
+        singleton1.stepName = "step1"
+        val singleton2 = applicationContext.getBean(SingletonComponentFunction::class.java)
+        assertEquals(singleton1.stepName, singleton2.stepName, " failed to get singleton data")
+    }
+
+    @Test
+    fun testProtoTypeFunction() {
+        val stepName1 = "step1"
+        val stepName2 = "step2"
+        val proto1 = applicationContext.getBean(PrototypeComponentFunction::class.java)
+        proto1.stepName = stepName1
+
+        val proto2 = applicationContext.getBean(PrototypeComponentFunction::class.java)
+        proto2.stepName = stepName2
+
+        assertEquals(stepName1, proto1.stepName, " Failed to match the step1 name")
+        assertEquals(stepName2, proto2.stepName, " Failed to match the step2 name")
     }
 
 }
\ No newline at end of file
index 747be76..1d738ee 100644 (file)
 package org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.mock
 
 import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
-import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceOutput
 import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction
-import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.executor.ComponentExecuteNodeExecutor
+import org.onap.ccsdk.apps.controllerblueprints.core.asJsonPrimitive
 import org.slf4j.LoggerFactory
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
 import org.springframework.context.annotation.Bean
 import org.springframework.context.annotation.Configuration
+import org.springframework.context.annotation.Scope
+import org.springframework.stereotype.Component
 
 @Configuration
 open class MockComponentConfiguration {
 
-    @Bean(name = ["component-resource-assignment", "component-netconf-executor"])
+    @Bean(name = ["component-resource-assignment", "component-netconf-executor", "component-jython-executor"])
     open fun createComponentFunction(): AbstractComponentFunction {
         return MockComponentFunction()
     }
@@ -35,12 +37,43 @@ open class MockComponentConfiguration {
 
 class MockComponentFunction : AbstractComponentFunction() {
 
-    private val log = LoggerFactory.getLogger(ComponentExecuteNodeExecutor::class.java)
+    private val log = LoggerFactory.getLogger(MockComponentFunction::class.java)
 
     override fun process(executionRequest: ExecutionServiceInput) {
-        log.info("Processing component..")
+        log.info("Processing component : ${operationInputs}")
 
-        this.executionServiceOutput = ExecutionServiceOutput()
+        bluePrintRuntimeService!!.setNodeTemplateAttributeValue(nodeTemplateName,
+                "assignment-params", "params".asJsonPrimitive())
+    }
+
+    override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
+        log.info("Recovering component..")
+    }
+}
+
+@Component("singleton-function")
+@Scope(value = ConfigurableBeanFactory.SCOPE_SINGLETON)
+class SingletonComponentFunction : AbstractComponentFunction() {
+
+    private val log = LoggerFactory.getLogger(MockComponentFunction::class.java)
+
+    override fun process(executionRequest: ExecutionServiceInput) {
+        log.info("Processing component : ${operationInputs}")
+    }
+
+    override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
+        log.info("Recovering component..")
+    }
+}
+
+@Component("prototype-function")
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+class PrototypeComponentFunction : AbstractComponentFunction() {
+
+    private val log = LoggerFactory.getLogger(MockComponentFunction::class.java)
+
+    override fun process(executionRequest: ExecutionServiceInput) {
+        log.info("Processing component : ${operationInputs}")
     }
 
     override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/execution-input/assign-activate-input.json b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/execution-input/assign-activate-input.json
new file mode 100644 (file)
index 0000000..d63b1d3
--- /dev/null
@@ -0,0 +1,23 @@
+{
+  "commonHeader": {
+    "originatorId": "System",
+    "requestId": "1234",
+    "subRequestId": "1234-12234"
+  },
+  "actionIdentifiers": {
+    "blueprintName": "baseconfiguration",
+    "blueprintVersion": "1.0.0",
+    "actionName": "assign-activate",
+    "mode": "sync"
+  },
+  "payload": {
+    "assign-activate-request": {
+      "assign-activate-properties": {
+        "request-id": "1234",
+        "action-name": "assign-activate",
+        "scope-type": "vnf-type",
+        "hostname": "localhost"
+      }
+    }
+  }
+}
\ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/execution-input/default-input.json b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/execution-input/default-input.json
deleted file mode 100644 (file)
index 20401fd..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-{
-  "commonHeader" : {
-    "originatorId" : "System",
-    "requestId" : "1234",
-    "subRequestId" : "1234-12234"
-  },
-  "actionIdentifiers" : {
-    "blueprintName" : "baseconfiguration",
-    "blueprintVersion" : "1.0.0",
-    "actionName" : "activate",
-    "mode" : "sync"
-  },
-  "payload" : { },
-  "metadata" : {
-    "current-node-template" : "resource-assignment-py",
-    "current-step" : "resource-assignment-py",
-    "current-operation" : "process",
-    "current-interface" : "ResourceAssignmentComponent"
-  }
-}
\ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/execution-input/resource-assignment-input.json b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/execution-input/resource-assignment-input.json
new file mode 100644 (file)
index 0000000..ce7bc8e
--- /dev/null
@@ -0,0 +1,23 @@
+{
+  "commonHeader": {
+    "originatorId": "System",
+    "requestId": "1234",
+    "subRequestId": "1234-12234"
+  },
+  "actionIdentifiers": {
+    "blueprintName": "baseconfiguration",
+    "blueprintVersion": "1.0.0",
+    "actionName": "resource-assignment",
+    "mode": "sync"
+  },
+  "payload": {
+    "resource-assignment-request": {
+      "resource-assignment-properties": {
+        "request-id": "1234",
+        "action-name": "resource-assignment",
+        "scope-type": "vnf-type",
+        "hostname": "localhost"
+      }
+    }
+  }
+}
\ No newline at end of file
index 3ad3fef..d8a47ef 100644 (file)
@@ -36,6 +36,7 @@
         <kotlin.maven.version>1.3.10</kotlin.maven.version>
         <kotlin.couroutines.version>1.0.1</kotlin.couroutines.version>
         <grpc.version>1.16.1</grpc.version>
+        <protobuff.java.utils.version>3.6.1</protobuff.java.utils.version>
         <eelf.version>1.0.0</eelf.version>
         <sli.version>0.3.1</sli.version>
         <guava.version>26.0-jre</guava.version>
                 <artifactId>grpc-stub</artifactId>
                 <version>${grpc.version}</version>
             </dependency>
+            <dependency>
+                <groupId>com.google.protobuf</groupId>
+                <artifactId>protobuf-java-util</artifactId>
+                <version>${protobuff.java.utils.version}</version>
+            </dependency>
 
             <!-- SLI Version -->
             <dependency>
                 <artifactId>resource-resolution</artifactId>
                 <version>${project.version}</version>
             </dependency>
+            <dependency>
+                <groupId>org.onap.ccsdk.apps.blueprintsprocessor.functions</groupId>
+                <artifactId>python-executor</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>org.onap.ccsdk.apps.blueprintsprocessor.functions</groupId>
+                <artifactId>netconf-executor</artifactId>
+                <version>${project.version}</version>
+            </dependency>
 
             <!-- Application Component Dependency -->
             <dependency>
             <groupId>io.grpc</groupId>
             <artifactId>grpc-stub</artifactId>
         </dependency>
+        <dependency>
+            <groupId>com.google.protobuf</groupId>
+            <artifactId>protobuf-java-util</artifactId>
+        </dependency>
     </dependencies>
 
     <build>
index b9c0bd1..f9dbf6d 100644 (file)
@@ -1,5 +1,6 @@
 /*
  *  Copyright © 2017-2018 AT&T Intellectual Property.
+ *  Modifications Copyright © 2018 IBM.
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
 
 package org.onap.ccsdk.apps.controllerblueprints;
 
-import com.google.common.collect.Lists;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 import org.jetbrains.annotations.NotNull;
 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Bean;
 import org.springframework.http.HttpStatus;
 import org.springframework.web.bind.annotation.RequestMethod;
+
+import com.google.common.collect.Lists;
+
 import springfox.documentation.builders.PathSelectors;
 import springfox.documentation.builders.RequestHandlerSelectors;
 import springfox.documentation.builders.ResponseMessageBuilder;
@@ -34,11 +42,6 @@ import springfox.documentation.service.ResponseMessage;
 import springfox.documentation.spi.DocumentationType;
 import springfox.documentation.spring.web.plugins.Docket;
 
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
 /**
  * SwaggerConfig
  *
index 7ea81da..aaa45e1 100644 (file)
@@ -34,7 +34,6 @@ import org.onap.ccsdk.apps.controllerblueprints.service.enhancer.BluePrintEnhanc
 import org.onap.ccsdk.apps.controllerblueprints.service.enhancer.ResourceAssignmentEnhancerService;\r
 import org.springframework.beans.factory.config.ConfigurableBeanFactory;\r
 import org.springframework.context.annotation.Scope;\r
-import org.springframework.context.annotation.ScopedProxyMode;\r
 import org.springframework.stereotype.Service;\r
 \r
 import java.util.HashMap;\r
@@ -48,7 +47,7 @@ import java.util.Map;
  */\r
 \r
 @Service\r
-@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE, proxyMode = ScopedProxyMode.TARGET_CLASS)\r
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)\r
 public class BluePrintEnhancerService extends BluePrintEnhancerDefaultService {\r
 \r
     private static EELFLogger log = EELFManager.getInstance().getLogger(BluePrintEnhancerService.class);\r
index 3c92f7e..1875a80 100644 (file)
@@ -127,7 +127,7 @@ public class ConfigModelCreateService {
             String artifactName = configModel.getArtifactName();\r
             String artifactVersion = configModel.getArtifactVersion();\r
             String author = configModel.getUpdatedBy();\r
-            // configModel.setTags(artifactName);\r
+            \r
 \r
             if (StringUtils.isBlank(author)) {\r
                 throw new BluePrintException("Artifact Author is missing in the Service Template");\r
index a2f653c..b2fff26 100644 (file)
@@ -55,6 +55,7 @@ public class ConfigModelService {
     private ConfigModelRepository configModelRepository;\r
     private ConfigModelContentRepository configModelContentRepository;\r
     private ConfigModelCreateService configModelCreateService;\r
+    private static final String CONFIG_MODEL_ID_FAILURE_MSG= "failed to get config model id(%d) from repo";\r
 \r
     /**\r
      * This is a ConfigModelService constructor.\r
@@ -174,7 +175,7 @@ public class ConfigModelService {
         if (dbConfigModel.isPresent()) {\r
             configModel = dbConfigModel.get();\r
         } else {\r
-            throw new BluePrintException(String.format("failed to get config model id(%d) from repo", id));\r
+            throw new BluePrintException(String.format(CONFIG_MODEL_ID_FAILURE_MSG, id));\r
         }\r
 \r
         return configModel;\r
@@ -232,7 +233,7 @@ public class ConfigModelService {
                 }\r
             }\r
         } else {\r
-            throw new BluePrintException(String.format("failed to get config model id(%d) from repo", id));\r
+            throw new BluePrintException(String.format(CONFIG_MODEL_ID_FAILURE_MSG, id));\r
         }\r
 \r
         return cloneConfigModel;\r
@@ -252,7 +253,7 @@ public class ConfigModelService {
             configModelContentRepository.deleteByConfigModel(dbConfigModel.get());\r
             configModelRepository.delete(dbConfigModel.get());\r
         } else {\r
-            throw new BluePrintException(String.format("failed to get config model id(%d) from repo", id));\r
+            throw new BluePrintException(String.format(CONFIG_MODEL_ID_FAILURE_MSG, id));\r
         }\r
     }\r
 \r
index 2e58b53..1ba3257 100644 (file)
@@ -20,7 +20,6 @@ import com.att.eelf.configuration.EELFLogger;
 import com.att.eelf.configuration.EELFManager;\r
 import org.junit.Assert;\r
 import org.junit.Before;\r
-import org.junit.Test;\r
 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;\r
 import org.onap.ccsdk.apps.controllerblueprints.core.data.ServiceTemplate;\r
 import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonReactorUtils;\r
index 309b228..b913431 100644 (file)
@@ -33,6 +33,8 @@
         <kotlin.version>1.3.10</kotlin.version>
         <kotlin.maven.version>1.3.10</kotlin.maven.version>
         <kotlin.couroutines.version>1.0.1</kotlin.couroutines.version>
+        <grpc.version>1.16.1</grpc.version>
+        <protobuff.java.utils.version>3.6.1</protobuff.java.utils.version>
         <eelf.version>1.0.0</eelf.version>
         <guava.version>26.0-jre</guava.version>
         <springfox.swagger2.version>2.9.2</springfox.swagger2.version>
                 <version>${kotlin.version}</version>
             </dependency>
 
+            <!-- GRPC Dependencies -->
+            <dependency>
+                <groupId>io.grpc</groupId>
+                <artifactId>grpc-core</artifactId>
+                <version>${grpc.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>io.grpc</groupId>
+                <artifactId>grpc-netty</artifactId>
+                <version>${grpc.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>io.grpc</groupId>
+                <artifactId>grpc-protobuf</artifactId>
+                <version>${grpc.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>io.grpc</groupId>
+                <artifactId>grpc-stub</artifactId>
+                <version>${grpc.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>com.google.protobuf</groupId>
+                <artifactId>protobuf-java-util</artifactId>
+                <version>${protobuff.java.utils.version}</version>
+            </dependency>
+
             <!-- Database -->
             <dependency>
                 <groupId>com.h2database</groupId>
index 1287a27..561273b 100644 (file)
@@ -3,6 +3,7 @@
  * ONAP : CCSDK.apps
  * ================================================================================
  * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2018 IBM.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -70,7 +71,6 @@ public class Application extends SpringBootServletInitializer {
             String[] beanNames = ctx.getBeanDefinitionNames();
             Arrays.sort(beanNames);
             for (String beanName : beanNames) {
-                System.out.println(beanName);
                 log.info(beanName);
             }
             log.info("################################");
index 526f67c..f70b063 100644 (file)
@@ -3,13 +3,14 @@
  * ONAP : CCSDK.apps
  * ================================================================================
  * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2018 IBM.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      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.
 
 package org.onap.ccsdk.apps.ms.neng.core.policy;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 /**
  * Represents a sequence object in the policy, as a POJO.
  */
 public class PolicySequence {
     /**
-     * The type of the policy sequence. 
+     * The type of the policy sequence.
      */
-    public enum Type { 
-        ALPHA, NUMERIC 
+    public enum Type {
+        ALPHA, NUMERIC
     }
 
     private long startValue;
@@ -41,6 +44,8 @@ public class PolicySequence {
     private String key;
     private String value;
     private Long lastReleaseSeqNumTried;
+    private Logger logger = LoggerFactory.getLogger(PolicySequence.class);
+
 
     public long getStartValue() {
         return startValue;
@@ -79,6 +84,7 @@ public class PolicySequence {
                 try {
                     this.maxValue = Long.valueOf(this.maxValueString, base);
                 } catch (Exception e) {
+                    logger.error("Exception",e);
                     this.maxValue = null;
                 }
             }
index 8fd3012..2a73a27 100644 (file)
@@ -128,7 +128,6 @@ public class PropertyOperator {
         if (mapped == null) {
             mapped = camelConverted(recipeItem);
         }
-        //String value = applyJavaOperation(null, recipeItem, mapped);
         return applyJavaOperation(null, recipeItem, mapped);
     }
     
index 3746756..95afea2 100644 (file)
@@ -4,6 +4,8 @@
  * ================================================================================
  * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
+ * Modifications Copyright (C) 2018 IBM.
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -43,7 +45,7 @@ public class RestServiceImpl implements RestService {
     private static Logger log = Logger.getLogger(RestServiceImpl.class.getName());
     private static final String INTERNAL_ERROR_MSG = "Internal error occured while processing the request.";
     private static final String ERROR="error";
-    
+    private static final String ERROR_500="err-0500";
     
     @Autowired SpringService service;
 
@@ -73,7 +75,7 @@ public class RestServiceImpl implements RestService {
             return buildErrorResponse(response);
         } catch (Exception e) {
             log.warning(e.getMessage());
-            response.put(ERROR, buildErrorResponse("err-0500", INTERNAL_ERROR_MSG));
+            response.put(ERROR, buildErrorResponse(ERROR_500, INTERNAL_ERROR_MSG));
             return buildErrorResponse(response);
         }
     }
@@ -94,7 +96,7 @@ public class RestServiceImpl implements RestService {
             return buildErrorResponse(response);
         } catch (Exception e) {
             log.warning(e.getMessage());
-            response.put(ERROR, buildErrorResponse("err-0500", INTERNAL_ERROR_MSG));
+            response.put(ERROR, buildErrorResponse(ERROR_500, INTERNAL_ERROR_MSG));
             return buildErrorResponse(response);
         }
     }
@@ -122,7 +124,7 @@ public class RestServiceImpl implements RestService {
             return buildResponse(response);
         } catch (Exception e) {
             log.warning(e.getMessage());
-            response.put(ERROR, buildErrorResponse("err-0500", e.getMessage()));
+            response.put(ERROR, buildErrorResponse(ERROR_500, e.getMessage()));
             return buildErrorResponse(response);
         }
     }
index 0707cd3..96e9935 100644 (file)
@@ -1,5 +1,6 @@
 /*******************************************************************************\r
  * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
  * \r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
@@ -64,7 +65,7 @@ public class PolicyEngineResponse implements Serializable {
        private String property;\r
        \r
        public PolicyEngineResponse() {\r
-               \r
+               // this method does nothing\r
        }\r
 \r
        public String getPolicyConfigMessage() {\r
index 4b7a714..79c5818 100644 (file)
@@ -1,5 +1,6 @@
 /*******************************************************************************\r
  * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2017-2018 AT&T Intellectual Property.\r
  * \r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
@@ -33,7 +34,7 @@ import io.swagger.annotations.ApiModelProperty;
  */\r
 public class AssignVlanTagRequest {\r
        \r
-       private @Valid List<AssignVlanTagRequestInput> input = new ArrayList<AssignVlanTagRequestInput>();\r
+       private @Valid List<AssignVlanTagRequestInput> input = new ArrayList<>();\r
 \r
          /**\r
           **/\r