summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/activation-blueprint.json9
-rwxr-xr-xcomponents/model-catalog/blueprint-model/test-blueprint/capability_python/Scripts/python/SampleRAProcessor.py22
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/activation-blueprint.json228
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/artifact_types.json28
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/data_types.json23
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/node_types.json168
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/policy_types.json3
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/relationship_types.json9
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/resources_definition_types.json16
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Plans/CONFIG_configAssign.xml19
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Plans/CONFIG_configure.xml19
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Scripts/RestconfAssignConfig.kts1
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Scripts/RestconfConfigure.kts1
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/capability_restconf/TOSCA-Metada/TOSCA.meta5
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/config-assign-pnf-mapping.json16
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/config-assign-restconf-configlet-template.vtl19
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/configure-pnf-mapping.json38
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/configure-restconf-mount-template.vtl14
-rw-r--r--components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/configure-restconf-unmount-template.vtl1
-rw-r--r--components/model-catalog/definition-type/starter-type/node_type/source-capability.json14
-rw-r--r--components/model-catalog/proto-definition/proto/BluePrintCommon.proto9
-rw-r--r--components/scripts/python/ccsdk_blueprints/abstract_ra_processor.py56
-rw-r--r--components/scripts/python/ccsdk_blueprints/sample_ra_processor_function.py10
-rwxr-xr-xms/blueprintsprocessor/application/pom.xml8
-rw-r--r--ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/BlueprintGRPCServer.java13
-rw-r--r--ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/BlueprintHttpServer.java8
-rw-r--r--ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/BlueprintProcessorApplication.java5
-rw-r--r--ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/WebConfig.java47
-rw-r--r--ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/security/AuthenticationManager.java40
-rw-r--r--ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/security/BasicAuthServerInterceptor.java97
-rw-r--r--ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/security/SecurityConfiguration.java59
-rw-r--r--ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/security/SecurityContextRepository.java75
-rwxr-xr-xms/blueprintsprocessor/application/src/main/resources/application.properties3
-rw-r--r--ms/blueprintsprocessor/application/src/test/resources/application.properties6
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt2
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt58
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt11
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessor.kt (renamed from ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessor.kt)37
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessor.kt (renamed from ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceAssignmentProcessor.kt)26
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessor.kt (renamed from ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/InputResourceAssignmentProcessor.kt)13
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/PrimaryDataResourceResolutionProcessor.kt (renamed from ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/PrimaryDataResourceAssignmentProcessor.kt)80
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt10
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt (renamed from ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/SimpleRestResourceAssignmentProcessor.kt)28
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt12
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt6
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt9
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt (renamed from ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessorTest.kt)20
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/capability/jython-resource-definitions.json4
-rw-r--r--ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/scripts/InternalSimpleRestconf.cba.kts29
-rwxr-xr-xms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BlueprintProcessorCatalogServiceImpl.kt5
-rw-r--r--ms/blueprintsprocessor/modules/commons/db-lib/src/test/resources/test-cba.zipbin9189 -> 9302 bytes
-rw-r--r--ms/blueprintsprocessor/modules/commons/dmaap-lib/pom.xml76
-rw-r--r--ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/dmaap/DmaapEventPublisher.kt181
-rw-r--r--ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/dmaap/EnvironmentContext.kt56
-rw-r--r--ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/dmaap/EventPublisher.kt39
-rw-r--r--ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/resources/event.properties26
-rw-r--r--ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/resources/producer.properties52
-rw-r--r--ms/blueprintsprocessor/modules/commons/dmaap-lib/src/test/kotlin/org/ccsdk/apps/blueprintprocessor/dmaap/TestDmaapEventPublisher.kt118
-rw-r--r--ms/blueprintsprocessor/modules/commons/dmaap-lib/src/test/resources/logback-test.xml40
-rw-r--r--ms/blueprintsprocessor/modules/commons/dmaap-lib/src/test/resources/preferredRoute.txt22
-rwxr-xr-xms/blueprintsprocessor/modules/commons/pom.xml1
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BluePrintRestLibPropertyService.kt33
-rwxr-xr-xms/blueprintsprocessor/modules/inbounds/selfservice-api/pom.xml11
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintManagementGRPCHandler.kt5
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandler.kt7
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt5
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt20
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/utils/BluePrintMappings.kt56
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/validation/BluePrintDesignTimeRuntimeValidatorService.kt38
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceHandlerTest.kt3
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/utils/BluePrintMappingTests.kt46
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/test-cba.zipbin9189 -> 9302 bytes
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/pom.xml7
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt8
-rwxr-xr-xms/blueprintsprocessor/parent/pom.xml10
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt13
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt6
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctions.kt21
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintExpressionData.kt7
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt13
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintValidator.kt33
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt7
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionService.kt24
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt49
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt27
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt23
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt13
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionServiceTest.kt50
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt14
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt24
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/test/resources/environments/Environments/environment1.properties2
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/test/resources/environments/Environments/environment2.properties2
-rw-r--r--ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintArtifactDefinitionValidatorImpl.kt97
-rw-r--r--ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintArtifactTypeValidatorImpl.kt4
-rw-r--r--ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintAttributeDefinitionValidatorImpl.kt63
-rw-r--r--ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintDataTypeValidatorImpl.kt8
-rw-r--r--ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintDesignTimeValidatorService.kt (renamed from ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintValidatorServiceImpl.kt)7
-rw-r--r--ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintNodeTemplateValidatorImpl.kt59
-rw-r--r--ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintNodeTypeValidatorImpl.kt15
-rw-r--r--ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintPropertyDefinitionValidatorImpl.kt6
-rw-r--r--ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintServiceTemplateValidatorImpl.kt5
-rw-r--r--ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintTopologyTemplateValidatorImpl.kt6
-rw-r--r--ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintTypeValidatorServiceImpl.kt56
-rw-r--r--ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintValidatorDefaultService.kt92
-rw-r--r--ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintWorkflowValidatorImpl.kt5
-rw-r--r--ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/extension/ArtifactMappingResourceValidator.kt48
-rw-r--r--ms/controllerblueprints/modules/blueprint-validation/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintDesignTimeValidatorServiceTest.kt (renamed from ms/controllerblueprints/modules/blueprint-validation/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintValidatorServiceImplTest.kt)4
-rw-r--r--ms/controllerblueprints/modules/blueprint-validation/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/MockBluePrintTypeValidatorService.kt17
-rw-r--r--ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImplTest.kt17
109 files changed, 2606 insertions, 530 deletions
diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/activation-blueprint.json b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/activation-blueprint.json
index c21f4c9d..138260fe 100644
--- a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/activation-blueprint.json
+++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/activation-blueprint.json
@@ -24,6 +24,15 @@
"file": "Definitions/policy_types.json"
}
],
+ "dsl_definitions" : {
+ "dynamic-rest-source": {
+ "type" : "basic-type",
+ "url" : "http://localhost:8080",
+ "userId" : {
+ "get_input": "rest-user-name"
+ }
+ }
+ },
"topology_template": {
"inputs": {
"request-id": {
diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_python/Scripts/python/SampleRAProcessor.py b/components/model-catalog/blueprint-model/test-blueprint/capability_python/Scripts/python/SampleRAProcessor.py
index 30b9ff95..acf12b33 100755
--- a/components/model-catalog/blueprint-model/test-blueprint/capability_python/Scripts/python/SampleRAProcessor.py
+++ b/components/model-catalog/blueprint-model/test-blueprint/capability_python/Scripts/python/SampleRAProcessor.py
@@ -7,23 +7,11 @@ class SampleRAProcessor(AbstractRAProcessor):
def __init__(self):
AbstractRAProcessor.__init__(self)
- def process(self, execution_request):
-
- AbstractRAProcessor.process(self, execution_request)
- print "Processing calling..." + PROPERTY_BLUEPRINT_BASE_PATH
- if self.ra_valid is True:
- value = self.resolve_values_script(execution_request, self.value_to_resolve)
- self.set_resource_data_value(execution_request, value)
- else:
- raise BluePrintProcessorException("Error on resource assignment. Message = " + self.error_message)
+ def process(self, resource_assignment):
+ print "Processing calling.." + PROPERTY_BLUEPRINT_BASE_PATH
+ self.set_resource_data_value(resource_assignment, "")
return None
- def recover(self, runtime_exception, execution_request):
- AbstractRAProcessor.recover(self, runtime_exception, execution_request)
- print "Recovering calling..." + PROPERTY_BLUEPRINT_BASE_PATH
+ def recover(self, runtime_exception, resource_assignment):
+ print "Recovering calling.." + PROPERTY_BLUEPRINT_BASE_PATH
return None
-
- def resolve_values_script(self, execution_request, value_to_resolve):
- # TODO : DO business logic here
- print "Resolve value for " + value_to_resolve + " here..."
- return "test_python"
diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/activation-blueprint.json b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/activation-blueprint.json
new file mode 100644
index 00000000..96ae88e5
--- /dev/null
+++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/activation-blueprint.json
@@ -0,0 +1,228 @@
+<!-- QUESTION
+ lines 74-78 and 157-161: if I have to resolve the variables I need based on
+ the pnf id, do I need to specify a restconf-connection? Another point, the
+ connection is aimed to ODL, not to the PNF, so I am not sure what to fill
+ for this model (lines 122-137)
+-->
+{
+ "tosca_definitions_version" : "controller_blueprint_1_0_0",
+ "metadata" : {
+ "template_author" : "Rodrigo Ottero",
+ "author-email" : "rodrigo.ottero@est.tech",
+ "user-groups" : "ADMIN, OPERATION",
+ "template_name" : "pnf restconf",
+ "template_version" : "1.0.0",
+ "template_tags" : "pnf, restconf, config, configuration"
+ },
+ "imports" : [ {
+ "file" : "Definitions/data_types.json"
+ }, {
+ "file" : "Definitions/relationship_types.json"
+ }, {
+ "file" : "Definitions/artifact_types.json"
+ }, {
+ "file" : "Definitions/node_types.json"
+ }, {
+ "file" : "Definitions/policy_types.json"
+ } ],
+ "topology_template" : {
+ "inputs" : {
+ "serviceInstanceId" : {
+ "required" : true,
+ "type" : "string"
+ },
+ "identifier" : {
+ "required" : true,
+ "type" : "string"
+ }
+ },
+ "workflows" : {
+ "config-assign" : {
+ "steps" : {
+ "activate-process" : {
+ "description" : "Create a configlet",
+ "target" : "config-assign-process",
+ "activities" : [ {
+ "call_operation" : ""
+ } ]
+ }
+ },
+ "inputs" : {
+ "config-assign-properties" : {
+ "description" : "Dynamic PropertyDefinition for workflow(config-assign).",
+ "required" : true,
+ "type" : "dt-config-assign-properties"
+ }
+ }
+ },
+ "configure" : {
+ "steps" : {
+ "activate-process" : {
+ "description" : "Send a configlet to the pnf",
+ "target" : "configure-process",
+ "activities" : [ {
+ "call_operation" : ""
+ } ]
+ }
+ },
+ "inputs" : {
+ "configure-properties" : {
+ "description" : "Dynamic PropertyDefinition for workflow(configure).",
+ "required" : true,
+ "type" : "dt-configure-properties"
+ }
+ }
+ }
+ },
+ "node_templates" : {
+ "config-assign-process" : {
+ "type" : "dg-generic",
+ "properties" : {
+ "content" : {
+ "get_artifact" : [ "SELF", "dg-config-assign-process" ]
+ },
+ "dependency-node-templates" : [ "config-assign" ]
+ },
+ "artifacts" : {
+ "dg-config-assign-process" : {
+ "type" : "artifact-directed-graph",
+ "file" : "Plans/CONFIG_configAssign.xml"
+ }
+ }
+ },
+ "config-assign" : {
+ "type" : "component-restconf-executor",
+ "requirements" : {
+ "restconf-connection" : {
+ "capability" : "restconf",
+ "node" : "sample-restconf-server",
+ "relationship" : "tosca.relationships.ConnectsTo"
+ }
+ },
+ "interfaces" : {
+ "ComponentRestconfExecutor" : {
+ "operations" : {
+ "process" : {
+ "implementation" : {
+ "primary" : "component-script"
+ },
+ "inputs" : {
+ "script-type" : "kotlin",
+ "script-class-reference" : "Scripts/kotlin/RestconfAssignConfig.kts",
+ "instance-dependencies" : [ ],
+ "artifact-prefix-names": [
+ "config-assign"
+ ]
+ },
+ "outputs" : {
+ "response-data" : "",
+ "status" : ""
+ }
+ }
+ }
+ }
+ },
+ "artifacts" : {
+ "config-assign-template" : {
+ "type" : "artifact-template-velocity",
+ "file" : "Templates/config-assign-restconf-configlet-template.vtl"
+ },
+ "config-assign-mapping" : {
+ "type" : "artifact-mapping-resource",
+ "file" : "Templates/config-assign-pnf-mapping.json"
+ },
+ "component-script" : {
+ "type" : "artifact-script-kotlin",
+ "file" : "Scripts/kotlin/RestconfAssignConfig.py"
+ }
+ }
+ },
+ "configure-process" : {
+ "type" : "dg-generic",
+ "properties" : {
+ "content" : {
+ "get_artifact" : [ "SELF", "dg-configure-process" ]
+ },
+ "dependency-node-templates" : [ "configure" ]
+ },
+ "artifacts" : {
+ "dg-config-assign-process" : {
+ "type" : "artifact-directed-graph",
+ "file" : "Plans/CONFIG_configure.xml"
+ }
+ }
+ },
+ "configure" : {
+ "type" : "component-restconf-executor",
+ "requirements" : {
+ "restconf-connection" : {
+ "capability" : "restconf",
+ "node" : "sample-restconf-server",
+ "relationship" : "tosca.relationships.ConnectsTo"
+ }
+ },
+ "interfaces" : {
+ "ComponentRestconfExecutor" : {
+ "operations" : {
+ "process" : {
+ "implementation" : {
+ "primary" : "component-script"
+ },
+ "inputs" : {
+ "script-type" : "kotlin",
+ "script-class-reference" : "Scripts/kotlin/RestconfConfigure.kts",
+ "instance-dependencies" : [ ],
+ "artifact-prefix-names": [
+ "configure-restconf-mount", "configure-restconf-unmount"
+ ]
+ },
+ "outputs" : {
+ "response-data" : "",
+ "status" : ""
+ }
+ }
+ }
+ }
+ },
+ "artifacts" : {
+ "configure-mount-template" : {
+ "type" : "artifact-template-velocity",
+ "file" : "Templates/configure-restconf-mount-template.vtl"
+ },
+ "configure-unmount-template" : {
+ "type" : "artifact-template-velocity",
+ "file" : "Templates/configure-restconf-unmount-template.vtl"
+ },
+ "configure-mapping" : {
+ "type" : "artifact-mapping-resource",
+ "file" : "Templates/configure-pnf-mapping.json"
+ },
+ "component-script" : {
+ "type" : "artifact-script-kotlin",
+ "file" : "Scripts/kotlin/RestconfConfigure.py"
+ }
+ }
+ },
+ "sample-restconf-device" : {
+ "type" : "pnf-netconf-device",
+ "capabilities" : {
+ "restconf" : {
+ "properties" : {
+ "login-key" : {
+ "get_input" : "password"
+ },
+ "login-account" : {
+ "get_input" : "username"
+ },
+ "target-ip-address" : {
+ "get_input" : "ip"
+ },
+ "port-number" : 830,
+ "connection-time-out" : 5
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/artifact_types.json b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/artifact_types.json
new file mode 100644
index 00000000..aa5295e4
--- /dev/null
+++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/artifact_types.json
@@ -0,0 +1,28 @@
+{
+ "artifact_types" : {
+ "artifact-directed-graph" : {
+ "description" : "Directed Graph File",
+ "version" : "1.0.0",
+ "derived_from" : "tosca.artifacts.Implementation",
+ "file_ext" : [ "json", "xml" ]
+ },
+ "artifact-mapping-resource" : {
+ "description" : "Resource Mapping File used along with Configuration template",
+ "version" : "1.0.0",
+ "derived_from" : "tosca.artifacts.Implementation",
+ "file_ext" : [ "json" ]
+ },
+ "artifact-script-jython" : {
+ "description" : "Jython Script File",
+ "version" : "1.0.0",
+ "derived_from" : "tosca.artifacts.Implementation",
+ "file_ext" : [ "py" ]
+ },
+ "artifact-template-velocity" : {
+ "description" : " Velocity Template used for Configuration",
+ "version" : "1.0.0",
+ "derived_from" : "tosca.artifacts.Implementation",
+ "file_ext" : [ "vtl" ]
+ }
+ }
+} \ No newline at end of file
diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/data_types.json b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/data_types.json
new file mode 100644
index 00000000..d9153f3f
--- /dev/null
+++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/data_types.json
@@ -0,0 +1,23 @@
+{
+ "data_types" : {
+ "dt-assign-activate-properties" : {
+ "description" : "Dynamic DataType definition for workflow(assign-activate).",
+ "version" : "1.0.0",
+ "properties" : {
+ "hostname" : {
+ "type" : "string"
+ },
+ "ip": {
+ "type": "string"
+ },
+ "username": {
+ "type": "string"
+ },
+ "password": {
+ "type": "string"
+ }
+ },
+ "derived_from" : "tosca.datatypes.Dynamic"
+ }
+ }
+} \ No newline at end of file
diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/node_types.json b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/node_types.json
new file mode 100644
index 00000000..c8e3e6a9
--- /dev/null
+++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/node_types.json
@@ -0,0 +1,168 @@
+{
+ "node_types" : {
+ "component-restconf-executor" : {
+ "description" : "This is Restconf Configuration Component API",
+ "version" : "1.0.0",
+ "capabilities" : {
+ "component-node" : {
+ "type" : "tosca.capabilities.Node"
+ }
+ },
+ "requirements" : {
+ "restconf-connection" : {
+ "capability" : "restconf",
+ "node" : "pnf-restconf-device",
+ "relationship" : "tosca.relationships.ConnectsTo"
+ }
+ },
+ "interfaces" : {
+ "ComponentRestconfExecutor" : {
+ "operations" : {
+ "process" : {
+ "inputs" : {
+ "script-type" : {
+ "description" : "Script type, kotlin type is supported",
+ "required" : true,
+ "type" : "string",
+ "constraints" : [ {
+ "valid_values" : [ "kotlin", "jython", "internal" ]
+ } ],
+ "default" : "internal"
+ },
+ "script-class-reference" : {
+ "description" : "Kotlin Script class name or jython script name.",
+ "required" : true,
+ "type" : "string"
+ },
+ "instance-dependencies" : {
+ "description" : "Instance names to inject to Jython or Kotlin Script.",
+ "required" : true,
+ "type" : "list",
+ "entry_schema" : {
+ "type" : "string"
+ }
+ }
+ },
+ "outputs" : {
+ "response-data" : {
+ "description" : "Execution Response Data in JSON format.",
+ "required" : false,
+ "type" : "string"
+ },
+ "status" : {
+ "description" : "Status of the Component Execution ( success or failure )",
+ "required" : true,
+ "type" : "string"
+ }
+ }
+ }
+ }
+ }
+ },
+ "derived_from" : "tosca.nodes.Component"
+ },
+ "dg-generic" : {
+ "description" : "This is Generic Directed Graph Type",
+ "version" : "1.0.0",
+ "properties" : {
+ "content" : {
+ "required" : true,
+ "type" : "string"
+ },
+ "dependency-node-templates" : {
+ "description" : "Dependent Step Components NodeTemplate name.",
+ "required" : true,
+ "type" : "list",
+ "entry_schema" : {
+ "type" : "string"
+ }
+ }
+ },
+ "derived_from" : "tosca.nodes.DG"
+ },
+ "source-input" : {
+ "description" : "This is Input Resource Source Node Type",
+ "version" : "1.0.0",
+ "properties" : {
+ "key" : {
+ "required" : false,
+ "type" : "string"
+ },
+ "key-dependencies" : {
+ "required" : true,
+ "type" : "list",
+ "entry_schema" : {
+ "type" : "string"
+ }
+ }
+ },
+ "derived_from" : "tosca.nodes.ResourceSource"
+ },
+ "tosca.nodes.Component" : {
+ "description" : "This is default Component Node",
+ "version" : "1.0.0",
+ "derived_from" : "tosca.nodes.Root"
+ },
+ "tosca.nodes.DG" : {
+ "description" : "This is Directed Graph Node Type",
+ "version" : "1.0.0",
+ "derived_from" : "tosca.nodes.Root"
+ },
+ "tosca.nodes.ResourceSource" : {
+ "description" : "TOSCA base type for Resource Sources",
+ "version" : "1.0.0",
+ "derived_from" : "tosca.nodes.Root"
+ },
+ "tosca.nodes.Vnf" : {
+ "description" : "This is VNF Node Type",
+ "version" : "1.0.0",
+ "derived_from" : "tosca.nodes.Root"
+ },
+ "tosca.nodes.Pnf": {
+ "description": "This is the PNF Node Type",
+ "version": "1.0.0",
+ "derived_from": "tosca.nodes.Root"
+ },
+ "pnf-restconf-device" : {
+ "description" : "This is a PNF Device with Restconf Capability",
+ "version" : "1.0.0",
+ "capabilities" : {
+ "netconf" : {
+ "type" : "tosca.capabilities.Restconf",
+ "properties" : {
+ "login-key" : {
+ "required" : true,
+ "type" : "string",
+ "default" : "sdnc"
+ },
+ "login-account" : {
+ "required" : true,
+ "type" : "string",
+ "default" : "sdnc-tacacs"
+ },
+ "source" : {
+ "required" : false,
+ "type" : "string",
+ "default" : "npm"
+ },
+ "target-ip-address" : {
+ "required" : true,
+ "type" : "string"
+ },
+ "port-number" : {
+ "required" : true,
+ "type" : "integer",
+ "default" : 830
+ },
+ "connection-time-out" : {
+ "required" : false,
+ "type" : "integer",
+ "default" : 30
+ }
+ }
+ }
+ },
+ "derived_from" : "tosca.nodes.Pnf"
+ }
+ }
+} \ No newline at end of file
diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/policy_types.json b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/policy_types.json
new file mode 100644
index 00000000..1e44cc70
--- /dev/null
+++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/policy_types.json
@@ -0,0 +1,3 @@
+{
+ "policy_types" : { }
+} \ No newline at end of file
diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/relationship_types.json b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/relationship_types.json
new file mode 100644
index 00000000..027bfc0f
--- /dev/null
+++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/relationship_types.json
@@ -0,0 +1,9 @@
+{
+ "relationship_types" : {
+ "tosca.relationships.ConnectsTo" : {
+ "description" : "Relationship tosca.relationships.ConnectsTo",
+ "version" : "1.0.0",
+ "derived_from" : "tosca.relationships.Root"
+ }
+ }
+} \ No newline at end of file
diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/resources_definition_types.json b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/resources_definition_types.json
new file mode 100644
index 00000000..b77f451a
--- /dev/null
+++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Definitions/resources_definition_types.json
@@ -0,0 +1,16 @@
+{
+ "hostname" : {
+ "tags" : "hostname",
+ "name" : "hostname",
+ "property" : {
+ "description" : "hostname",
+ "type" : "string"
+ },
+ "updated-by" : "Singal, Kapil <ks220y@att.com>",
+ "sources" : {
+ "input" : {
+ "type" : "source-input"
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Plans/CONFIG_configAssign.xml b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Plans/CONFIG_configAssign.xml
new file mode 100644
index 00000000..417f72de
--- /dev/null
+++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Plans/CONFIG_configAssign.xml
@@ -0,0 +1,19 @@
+<!-- QUESTION:
+ is the usage of <method rpc="ResourceAssignAndActivate" mode="sync">
+ correct in the context of CCSDK-926? -->
+
+<?xml version="1.0" encoding="UTF-8"?>
+<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="ResourceAssignAndActivate" mode="sync">
+ <block atomic="true">
+ <execute plugin="config-assign" method="process">
+ <outcome value="failure">
+ <return status="failure" />
+ </outcome>
+ <outcome value="success">
+ <return status="success" />
+ </outcome>
+ </execute>
+ </block>
+ </method>
+</service-logic>
diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Plans/CONFIG_configure.xml b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Plans/CONFIG_configure.xml
new file mode 100644
index 00000000..94fe6dde
--- /dev/null
+++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Plans/CONFIG_configure.xml
@@ -0,0 +1,19 @@
+<!-- QUESTION:
+ is the usage of <method rpc="ResourceAssignAndActivate" mode="sync">
+ correct in the context of CCSDK-926? -->
+
+<?xml version="1.0" encoding="UTF-8"?>
+<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="ResourceAssignAndActivate" mode="sync">
+ <block atomic="true">
+ <execute plugin="configure" method="process">
+ <outcome value="failure">
+ <return status="failure" />
+ </outcome>
+ <outcome value="success">
+ <return status="success" />
+ </outcome>
+ </execute>
+ </block>
+ </method>
+</service-logic>
diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Scripts/RestconfAssignConfig.kts b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Scripts/RestconfAssignConfig.kts
new file mode 100644
index 00000000..a0990367
--- /dev/null
+++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Scripts/RestconfAssignConfig.kts
@@ -0,0 +1 @@
+TBD
diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Scripts/RestconfConfigure.kts b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Scripts/RestconfConfigure.kts
new file mode 100644
index 00000000..a0990367
--- /dev/null
+++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Scripts/RestconfConfigure.kts
@@ -0,0 +1 @@
+TBD
diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/TOSCA-Metada/TOSCA.meta b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/TOSCA-Metada/TOSCA.meta
new file mode 100644
index 00000000..6ac9caf5
--- /dev/null
+++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/TOSCA-Metada/TOSCA.meta
@@ -0,0 +1,5 @@
+TOSCA-Meta-File-Version: 1.0.0
+CSAR-Version: 1.0
+Created-By: Rodrigo Ottero
+Entry-Definitions: Definitions/activation-blueprint.json
+Template-Tags: activation-blueprint
diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/config-assign-pnf-mapping.json b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/config-assign-pnf-mapping.json
new file mode 100644
index 00000000..85533abc
--- /dev/null
+++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/config-assign-pnf-mapping.json
@@ -0,0 +1,16 @@
+<!-- QUESTION:
+ when using dictionary-source as capability, what else needs to be defined?
+ because odl_host will come from the application.properties entry -->
+[
+ {
+ "name": "odl_host",
+ "input-param": true,
+ "property": {
+ "type": "string"
+ },
+ "dictionary-name": "odl_host",
+ "dictionary-source": "capability",
+ "dependencies": [
+ ]
+ }
+]
diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/config-assign-restconf-configlet-template.vtl b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/config-assign-restconf-configlet-template.vtl
new file mode 100644
index 00000000..e3d7a671
--- /dev/null
+++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/config-assign-restconf-configlet-template.vtl
@@ -0,0 +1,19 @@
+<yang-patch xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-patch">
+<patch-id>example-patch</patch-id>
+<comment>Example patch</comment>
+<edit>
+ <edit-id>edit1</edit-id>
+ <operation>create</operation>
+ <target>/car-entry</target>
+ <value>
+ <car-entry xmlns="urn:opendaylight:params:xml:ns:yang:controller:config:sal-clustering-it:car">
+ <id>0</id>
+ </car-entry>
+ </value>
+</edit>
+<edit>
+ <edit-id>edit2</edit-id>
+ <operation>delete</operation>
+ <target>/car-entry/0</target>
+</edit>
+</yang-patch>
diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/configure-pnf-mapping.json b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/configure-pnf-mapping.json
new file mode 100644
index 00000000..123680c0
--- /dev/null
+++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/configure-pnf-mapping.json
@@ -0,0 +1,38 @@
+<!-- QUESTION:
+ when using dictionary-source as capability, what else needs to be defined?
+ because these variables will be obtained based on the pnf_id -->
+[
+ {
+ "name": "pnf_id",
+ "input-param": true,
+ "property": {
+ "type": "string"
+ },
+ "dictionary-name": "pnf_id",
+ "dictionary-source": "capability",
+ "dependencies": [
+ ]
+ },
+ {
+ "name": "pnf_ip",
+ "input-param": true,
+ "property": {
+ "type": "string"
+ },
+ "dictionary-name": "pnf_ip",
+ "dictionary-source": "capability",
+ "dependencies": [
+ ]
+ },
+ {
+ "name": "pnf_ip_port",
+ "input-param": true,
+ "property": {
+ "type": "string"
+ },
+ "dictionary-name": "pnf_ip_port",
+ "dictionary-source": "capability",
+ "dependencies": [
+ ]
+ }
+]
diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/configure-restconf-mount-template.vtl b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/configure-restconf-mount-template.vtl
new file mode 100644
index 00000000..17f7a367
--- /dev/null
+++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/configure-restconf-mount-template.vtl
@@ -0,0 +1,14 @@
+<node xmlns="urn:TBD:params:xml:ns:yang:network-topology">
+ <node-id>$pnf_id</node-id>
+ <key-based xmlns="urn:opendaylight:netconf-node-topology">
+ <key-id xmlns="urn:opendaylight:netconf-node-topology">ODL-private-key</key-id>
+ <username xmlns="urn:opendaylight:netconf-node-topology">netconf</username>
+ </key-based>
+ <host xmlns="urn:opendaylight:netconf-node-topology">$pnf_ip</host>
+ <port xmlns="urn:opendaylight:netconf-node-topology">$pnf_ip_port</port>
+ <tcp-only xmlns="urn:opendaylight:netconf-node-topology">false</tcp-only>
+ <protocol xmlns="urn:opendaylight:netconf-node-topology">
+ <name xmlns="urn:opendaylight:netconf-node-topology">TLS</name>
+ </protocol>
+ <max-connection-attempts xmlns="urn:opendaylight:netconf-node-topology">2</max-connection-attempts>
+</node>
diff --git a/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/configure-restconf-unmount-template.vtl b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/configure-restconf-unmount-template.vtl
new file mode 100644
index 00000000..a0990367
--- /dev/null
+++ b/components/model-catalog/blueprint-model/test-blueprint/capability_restconf/Templates/configure-restconf-unmount-template.vtl
@@ -0,0 +1 @@
+TBD
diff --git a/components/model-catalog/definition-type/starter-type/node_type/source-capability.json b/components/model-catalog/definition-type/starter-type/node_type/source-capability.json
index 4d9488cb..e0c44064 100644
--- a/components/model-catalog/definition-type/starter-type/node_type/source-capability.json
+++ b/components/model-catalog/definition-type/starter-type/node_type/source-capability.json
@@ -2,22 +2,22 @@
"description": "This is Component Resource Source Node Type",
"version": "1.0.0",
"properties": {
- "type": {
+ "script-type": {
"required": true,
"type": "string",
- "default": "KOTLIN-COMPONENT",
+ "default": "kotlin",
"constraints": [
{
"valid_values": [
- "KOTLIN-COMPONENT",
- "JAVA-COMPONENT",
- "JYTHON-COMPONENT"
+ "kotlin",
+ "internal",
+ "jython"
]
}
]
},
- "instance-name": {
- "description": "Capability component instance reference name for JAVA-COMPONENT, Script Class name for KOTLIN-COMPONENT.",
+ "script-class-reference": {
+ "description": "Capability reference name for internal and kotlin, for jython script file path",
"required": true,
"type": "string"
},
diff --git a/components/model-catalog/proto-definition/proto/BluePrintCommon.proto b/components/model-catalog/proto-definition/proto/BluePrintCommon.proto
index 0f17783a..de92bdc1 100644
--- a/components/model-catalog/proto-definition/proto/BluePrintCommon.proto
+++ b/components/model-catalog/proto-definition/proto/BluePrintCommon.proto
@@ -26,6 +26,13 @@ message Status {
int32 code = 1;
string errorMessage = 2;
string message = 3;
- string eventType = 4;
+ EventType eventType = 4;
string timestamp = 5;
+}
+
+enum EventType {
+ EVENT_COMPONENT_FAILURE = 0;
+ EVENT_COMPONENT_PROCESSING = 1;
+ EVENT_COMPONENT_NOTIFICATION = 2;
+ EVENT_COMPONENT_EXECUTED = 3;
} \ No newline at end of file
diff --git a/components/scripts/python/ccsdk_blueprints/abstract_ra_processor.py b/components/scripts/python/ccsdk_blueprints/abstract_ra_processor.py
index 2cacaf52..6489b1e7 100644
--- a/components/scripts/python/ccsdk_blueprints/abstract_ra_processor.py
+++ b/components/scripts/python/ccsdk_blueprints/abstract_ra_processor.py
@@ -1,49 +1,29 @@
-from org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor import ResourceAssignmentProcessor
-from blueprint_constants import *
-from org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.utils import ResourceAssignmentUtils
-from org.onap.ccsdk.apps.controllerblueprints.core import BluePrintProcessorException
-from java.lang import Exception
+from org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor import \
+ ResourceAssignmentProcessor
+from org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.utils import \
+ ResourceAssignmentUtils
+from org.onap.ccsdk.apps.controllerblueprints.core import \
+ BluePrintProcessorException
class AbstractRAProcessor(ResourceAssignmentProcessor):
- def __init__(self):
- ResourceAssignmentProcessor.__init__(self)
- self.status = PROPERTY_BLUEPRINT_STATUS_SUCCESS
- self.error_message = None
- self.ra_valid = False
- self.value_to_resolve = None
-
- def process(self, execution_request):
- print "Processing calling from parent..."
- try:
- self.ra_valid = self.validate(execution_request)
- self.value_to_resolve = execution_request.name
- except Exception, e:
- self.status = PROPERTY_BLUEPRINT_STATUS_FAILURE
- self.error_message = "Get Running python scripting Failure :" + e.getMessage()
+ def process(self, resource_assignment):
+ print "Processing.."
+ return None
- def recover(self, runtime_exception, execution_request):
- print "Recovering calling from parent.."
+ def recover(self, runtime_exception, resource_assignment):
+ print "Recovering.."
return None
- def set_resource_data_value(self, execution_request, value):
+ def set_resource_data_value(self, resource_assignment, value):
try:
if value is not None:
- ResourceAssignmentUtils.Companion.setResourceDataValue(execution_request, self.raRuntimeService, value)
+ ResourceAssignmentUtils.Companion.setResourceDataValue(
+ resource_assignment, self.raRuntimeService, value)
else:
- ResourceAssignmentUtils.Companion.setFailedResourceDataValue(execution_request, "Fail to resole value")
+ ResourceAssignmentUtils.Companion.setFailedResourceDataValue(
+ resource_assignment, "Fail to resolve value")
except BluePrintProcessorException, err:
- raise BluePrintProcessorException("Error on resource assignment. Message = " + err.message)
-
- return None
-
- @staticmethod
- def validate(ra):
- if ra.name is None or ra.name is None:
- raise Exception("Failed getting value for template key (" + ra.name + ") and " +
- "dictionary key (" + ra.dictionaryName +
- ") of type (" + ra.type + ")")
- else:
- pass
- return True
+ raise BluePrintProcessorException(
+ "Error on resource assignment. Message = " + err.message)
diff --git a/components/scripts/python/ccsdk_blueprints/sample_ra_processor_function.py b/components/scripts/python/ccsdk_blueprints/sample_ra_processor_function.py
index 6ec5d82a..fa821082 100644
--- a/components/scripts/python/ccsdk_blueprints/sample_ra_processor_function.py
+++ b/components/scripts/python/ccsdk_blueprints/sample_ra_processor_function.py
@@ -4,15 +4,11 @@ from blueprint_constants import *
class SampleRAProcessorFunction(AbstractRAProcessor):
- def __init__(self):
- AbstractRAProcessor.__init__(self)
-
- def process(self, execution_request):
- AbstractRAProcessor.process(self, execution_request)
+ def process(self, resource_assignment):
print "Processing calling.." + PROPERTY_BLUEPRINT_BASE_PATH
+ self.set_resource_data_value(resource_assignment, "")
return None
- def recover(self, runtime_exception, execution_request):
- AbstractRAProcessor.recover(self, runtime_exception, execution_request)
+ def recover(self, runtime_exception, resource_assignment):
print "Recovering calling.." + PROPERTY_BLUEPRINT_BASE_PATH
return None
diff --git a/ms/blueprintsprocessor/application/pom.xml b/ms/blueprintsprocessor/application/pom.xml
index 83dc7061..f42cdfad 100755
--- a/ms/blueprintsprocessor/application/pom.xml
+++ b/ms/blueprintsprocessor/application/pom.xml
@@ -17,7 +17,8 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
@@ -40,6 +41,11 @@
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-security</artifactId>
+ </dependency>
+
<!-- North Bound -->
<dependency>
<groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
diff --git a/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/BlueprintGRPCServer.java b/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/BlueprintGRPCServer.java
index 86fdccd4..3ac1a6e6 100644
--- 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
@@ -18,6 +18,7 @@ package org.onap.ccsdk.apps.blueprintsprocessor;
import io.grpc.Server;
import io.grpc.ServerBuilder;
+import org.onap.ccsdk.apps.blueprintsprocessor.security.BasicAuthServerInterceptor;
import org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api.BluePrintManagementGRPCHandler;
import org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api.BluePrintProcessingGRPCHandler;
import org.slf4j.Logger;
@@ -37,9 +38,10 @@ public class BlueprintGRPCServer implements ApplicationListener<ContextRefreshed
@Autowired
private BluePrintProcessingGRPCHandler bluePrintProcessingGRPCHandler;
-
@Autowired
private BluePrintManagementGRPCHandler bluePrintManagementGRPCHandler;
+ @Autowired
+ private BasicAuthServerInterceptor authInterceptor;
@Value("${blueprintsprocessor.grpcPort}")
private Integer grpcPort;
@@ -49,10 +51,11 @@ public class BlueprintGRPCServer implements ApplicationListener<ContextRefreshed
try {
log.info("Starting Blueprint Processor GRPC Starting..");
Server server = ServerBuilder
- .forPort(grpcPort)
- .addService(bluePrintProcessingGRPCHandler)
- .addService(bluePrintManagementGRPCHandler)
- .build();
+ .forPort(grpcPort)
+ .intercept(authInterceptor)
+ .addService(bluePrintProcessingGRPCHandler)
+ .addService(bluePrintManagementGRPCHandler)
+ .build();
server.start();
log.info("Blueprint Processor GRPC server started and ready to serve on port({})...", server.getPort());
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
index b00c4627..9561b78d 100644
--- 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
@@ -16,23 +16,21 @@
package org.onap.ccsdk.apps.blueprintsprocessor;
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
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}")
diff --git a/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/BlueprintProcessorApplication.java b/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/BlueprintProcessorApplication.java
index 241d920a..3f8dc375 100644
--- a/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/BlueprintProcessorApplication.java
+++ b/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/BlueprintProcessorApplication.java
@@ -21,7 +21,6 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
-import org.springframework.web.reactive.config.EnableWebFlux;
/**
* BlueprintProcessorApplication
@@ -30,10 +29,10 @@ import org.springframework.web.reactive.config.EnableWebFlux;
*/
@SpringBootApplication
@EnableAutoConfiguration(exclude = {DataSourceAutoConfiguration.class})
-@EnableWebFlux
@ComponentScan(basePackages = {"org.onap.ccsdk.apps.controllerblueprints",
- "org.onap.ccsdk.apps.blueprintsprocessor"})
+ "org.onap.ccsdk.apps.blueprintsprocessor"})
public class BlueprintProcessorApplication {
+
public static void main(String[] args) {
SpringApplication.run(BlueprintProcessorApplication.class, args);
}
diff --git a/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/WebConfig.java b/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/WebConfig.java
index 796a2d79..47c7b722 100644
--- a/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/WebConfig.java
+++ b/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/WebConfig.java
@@ -17,8 +17,17 @@
package org.onap.ccsdk.apps.blueprintsprocessor;
+import org.onap.ccsdk.apps.blueprintsprocessor.security.AuthenticationManager;
+import org.onap.ccsdk.apps.blueprintsprocessor.security.SecurityContextRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
-import org.springframework.web.reactive.config.*;
+import org.springframework.http.HttpMethod;
+import org.springframework.security.config.web.server.ServerHttpSecurity;
+import org.springframework.security.web.server.SecurityWebFilterChain;
+import org.springframework.web.reactive.config.CorsRegistry;
+import org.springframework.web.reactive.config.ResourceHandlerRegistry;
+import org.springframework.web.reactive.config.WebFluxConfigurationSupport;
/**
* WebConfig
@@ -27,21 +36,43 @@ import org.springframework.web.reactive.config.*;
*/
@Configuration
public class WebConfig extends WebFluxConfigurationSupport {
- @Override
+
+ @Autowired
+ private AuthenticationManager authenticationManager;
+
+ @Autowired
+ private SecurityContextRepository securityContextRepository;
+
+ @Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("swagger-ui.html")
- .addResourceLocations("classpath:/META-INF/resources/");
+ .addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**")
- .addResourceLocations("classpath:/META-INF/resources/webjars/");
+ .addResourceLocations("classpath:/META-INF/resources/webjars/");
}
@Override
public void addCorsMappings(CorsRegistry corsRegistry) {
corsRegistry.addMapping("/**")
- .allowedOrigins("*")
- .allowedMethods("*")
- .allowedHeaders("DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range")
- .maxAge(3600);
+ .allowedOrigins("*")
+ .allowedMethods("*")
+ .allowedHeaders("*")
+ .maxAge(3600);
+ }
+
+
+ @Bean
+ public SecurityWebFilterChain securitygWebFilterChain(ServerHttpSecurity http) {
+ return http.csrf().disable()
+ .formLogin().disable()
+ .httpBasic().disable()
+ .authenticationManager(authenticationManager)
+ .securityContextRepository(securityContextRepository)
+ .authorizeExchange()
+ .pathMatchers(HttpMethod.OPTIONS).permitAll()
+ .anyExchange().authenticated()
+ .and().build();
+
}
}
diff --git a/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/security/AuthenticationManager.java b/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/security/AuthenticationManager.java
new file mode 100644
index 00000000..726be2ce
--- /dev/null
+++ b/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/security/AuthenticationManager.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2019 Bell Canada.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+* limitations under the License.
+ */
+package org.onap.ccsdk.apps.blueprintsprocessor.security;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.security.authentication.AuthenticationProvider;
+import org.springframework.security.authentication.ReactiveAuthenticationManager;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.AuthenticationException;
+import reactor.core.publisher.Mono;
+
+@Configuration
+public class AuthenticationManager implements ReactiveAuthenticationManager {
+
+ @Autowired
+ private AuthenticationProvider authenticationProvider;
+
+ @Override
+ public Mono<Authentication> authenticate(Authentication authentication) {
+ try {
+ return Mono.just(authenticationProvider.authenticate(authentication));
+ } catch (AuthenticationException e) {
+ return Mono.error(e);
+ }
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/security/BasicAuthServerInterceptor.java b/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/security/BasicAuthServerInterceptor.java
new file mode 100644
index 00000000..db0bfce4
--- /dev/null
+++ b/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/security/BasicAuthServerInterceptor.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2019 Bell Canada.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.ccsdk.apps.blueprintsprocessor.security;
+
+import com.google.common.base.Strings;
+import io.grpc.Metadata;
+import io.grpc.ServerCall;
+import io.grpc.ServerCallHandler;
+import io.grpc.ServerInterceptor;
+import io.grpc.Status;
+import java.nio.charset.StandardCharsets;
+import java.util.Base64;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.authentication.BadCredentialsException;
+import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.AuthenticationException;
+import org.springframework.security.core.context.SecurityContextHolder;
+import org.springframework.stereotype.Component;
+
+@Component
+public class BasicAuthServerInterceptor implements ServerInterceptor {
+
+ private static Logger log = LoggerFactory.getLogger(BasicAuthServerInterceptor.class);
+
+ @Autowired
+ private AuthenticationManager authenticationManager;
+
+
+ @Override
+ public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(
+ ServerCall<ReqT, RespT> call,
+ Metadata headers,
+ ServerCallHandler<ReqT, RespT> next) {
+ String authHeader = headers.get(Metadata.Key.of("Authorization", Metadata.ASCII_STRING_MARSHALLER));
+
+ if (Strings.isNullOrEmpty(authHeader)) {
+ throw Status.UNAUTHENTICATED.withDescription("Missing required authentication").asRuntimeException();
+
+ }
+
+ try {
+ String[] tokens = decodeBasicAuth(authHeader);
+ String username = tokens[0];
+
+ log.info("Basic Authentication Authorization header found for user: {}", username);
+
+ Authentication authRequest = new UsernamePasswordAuthenticationToken(username, tokens[1]);
+ Authentication authResult = authenticationManager.authenticate(authRequest).block();
+
+ log.info("Authentication success: {}", authResult);
+
+ SecurityContextHolder.getContext().setAuthentication(authResult);
+
+ } catch (AuthenticationException e) {
+ SecurityContextHolder.clearContext();
+
+ log.info("Authentication request failed: {}", e.getMessage());
+
+ throw Status.UNAUTHENTICATED.withDescription(e.getMessage()).withCause(e).asRuntimeException();
+ }
+
+ return next.startCall(call, headers);
+ }
+
+ private String[] decodeBasicAuth(String authHeader) {
+ String basicAuth;
+ try {
+ basicAuth = new String(Base64.getDecoder().decode(authHeader.substring(6).getBytes(StandardCharsets.UTF_8)),
+ StandardCharsets.UTF_8);
+ } catch (IllegalArgumentException | IndexOutOfBoundsException e) {
+ throw new BadCredentialsException("Failed to decode basic authentication token");
+ }
+
+ int delim = basicAuth.indexOf(':');
+ if (delim == -1) {
+ throw new BadCredentialsException("Failed to decode basic authentication token");
+ }
+
+ return new String[]{basicAuth.substring(0, delim), basicAuth.substring(delim + 1)};
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/security/SecurityConfiguration.java b/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/security/SecurityConfiguration.java
new file mode 100644
index 00000000..7ddc42cc
--- /dev/null
+++ b/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/security/SecurityConfiguration.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2019 Bell Canada.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.ccsdk.apps.blueprintsprocessor.security;
+
+import java.util.Collections;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.security.authentication.AuthenticationProvider;
+import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
+import org.springframework.security.core.authority.SimpleGrantedAuthority;
+import org.springframework.security.core.userdetails.User;
+import org.springframework.security.core.userdetails.UserDetails;
+import org.springframework.security.core.userdetails.UserDetailsService;
+import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
+import org.springframework.security.crypto.password.PasswordEncoder;
+import org.springframework.security.provisioning.InMemoryUserDetailsManager;
+
+@Configuration
+public class SecurityConfiguration {
+
+ @Value("${security.user.name}")
+ private String username;
+
+ @Value("${security.user.password}")
+ private String password;
+
+ @Bean
+ public UserDetailsService inMemoryUserService() {
+ UserDetails user = new User(username, password,
+ Collections.singletonList(new SimpleGrantedAuthority("USER")));
+ return new InMemoryUserDetailsManager(user);
+ }
+
+ @Bean
+ public PasswordEncoder passwordEncoder() {
+ return new BCryptPasswordEncoder();
+ }
+
+ @Bean
+ public AuthenticationProvider inMemoryAuthenticationProvider() {
+ DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
+ provider.setUserDetailsService(inMemoryUserService());
+ return provider;
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/security/SecurityContextRepository.java b/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/security/SecurityContextRepository.java
new file mode 100644
index 00000000..f9e184a1
--- /dev/null
+++ b/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/security/SecurityContextRepository.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2019 Bell Canada.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.ccsdk.apps.blueprintsprocessor.security;
+
+import java.nio.charset.StandardCharsets;
+import java.util.Base64;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.server.reactive.ServerHttpRequest;
+import org.springframework.security.authentication.BadCredentialsException;
+import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.context.SecurityContext;
+import org.springframework.security.core.context.SecurityContextImpl;
+import org.springframework.security.web.server.context.ServerSecurityContextRepository;
+import org.springframework.stereotype.Component;
+import org.springframework.web.server.ServerWebExchange;
+import reactor.core.publisher.Mono;
+
+@Component
+public class SecurityContextRepository implements ServerSecurityContextRepository {
+
+ @Autowired
+ private AuthenticationManager authenticationManager;
+
+ @Override
+ public Mono<Void> save(ServerWebExchange swe, SecurityContext sc) {
+ throw new UnsupportedOperationException("Not supported.");
+ }
+
+ @Override
+ public Mono<SecurityContext> load(ServerWebExchange swe) {
+ ServerHttpRequest request = swe.getRequest();
+ String authHeader = request.getHeaders().getFirst(HttpHeaders.AUTHORIZATION);
+ if (authHeader != null && authHeader.startsWith("Basic")) {
+ String[] tokens = decodeBasicAuth(authHeader);
+ String username = tokens[0];
+ String password = tokens[1];
+ Authentication auth = new UsernamePasswordAuthenticationToken(username, password);
+ return this.authenticationManager.authenticate(auth).map(SecurityContextImpl::new);
+ } else {
+ return Mono.empty();
+ }
+ }
+
+ private String[] decodeBasicAuth(String authHeader) {
+ String basicAuth;
+ try {
+ basicAuth = new String(Base64.getDecoder().decode(authHeader.substring(6).getBytes(StandardCharsets.UTF_8)),
+ StandardCharsets.UTF_8);
+ } catch (IllegalArgumentException | IndexOutOfBoundsException e) {
+ throw new BadCredentialsException("Failed to decode basic authentication token");
+ }
+
+ int delim = basicAuth.indexOf(':');
+ if (delim == -1) {
+ throw new BadCredentialsException("Failed to decode basic authentication token");
+ }
+
+ return new String[]{basicAuth.substring(0, delim), basicAuth.substring(delim + 1)};
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/application/src/main/resources/application.properties b/ms/blueprintsprocessor/application/src/main/resources/application.properties
index cfef4f82..e955c97c 100755
--- a/ms/blueprintsprocessor/application/src/main/resources/application.properties
+++ b/ms/blueprintsprocessor/application/src/main/resources/application.properties
@@ -36,3 +36,6 @@ blueprintsprocessor.db.primary.hibernateDialect=org.hibernate.dialect.MySQL5Inno
# Python executor
blueprints.processor.functions.python.executor.executionPath=/opt/app/onap/scripts/jython/ccsdk_blueprints
blueprints.processor.functions.python.executor.modulePaths=/opt/app/onap/scripts/jython/ccsdk_blueprints,/opt/app/onap/scripts/jython/ccsdk_netconf
+
+security.user.password: {bcrypt}$2a$10$duaUzVUVW0YPQCSIbGEkQOXwafZGwQ/b32/Ys4R1iwSSawFgz7QNu
+security.user.name: ccsdkapps
diff --git a/ms/blueprintsprocessor/application/src/test/resources/application.properties b/ms/blueprintsprocessor/application/src/test/resources/application.properties
index 2b5bea10..39302451 100644
--- a/ms/blueprintsprocessor/application/src/test/resources/application.properties
+++ b/ms/blueprintsprocessor/application/src/test/resources/application.properties
@@ -17,6 +17,9 @@
#
# Web server config
server.port=8080
+blueprintsprocessor.grpcEnable=false
+blueprintsprocessor.httpPort=8080
+blueprintsprocessor.grpcPort=9111
# Blueprint Processor File Execution and Handling Properties
blueprintsprocessor.blueprintDeployPath=/opt/app/onap/blueprints/deploy
blueprintsprocessor.blueprintArchivePath=/opt/app/onap/blueprints/archive
@@ -32,3 +35,6 @@ blueprintsprocessor.db.primary.hibernateDialect=org.hibernate.dialect.H2Dialect
# Python executor
blueprints.processor.functions.python.executor.executionPath=/opt/app/onap/scripts/jython
blueprints.processor.functions.python.executor.modulePaths=/opt/app/onap/scripts/jython
+
+security.user.password: {bcrypt}$2a$10$duaUzVUVW0YPQCSIbGEkQOXwafZGwQ/b32/Ys4R1iwSSawFgz7QNu
+security.user.name: ccsdkapps
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt
index 5765609b..ca92e96d 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt
@@ -20,7 +20,7 @@ class ResourceResolutionConstants {
companion object {
const val SERVICE_RESOURCE_RESOLUTION = "resource-resolution-service"
- const val PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR = "resource-assignment-processor-"
+ const val PREFIX_RESOURCE_RESOLUTION_PROCESSOR = "rr-processor-"
const val INPUT_ARTIFACT_PREFIX_NAMES = "artifact-prefix-names"
const val OUTPUT_ASSIGNMENT_PARAMS = "assignment-params"
const val FILE_NAME_RESOURCE_DEFINITION_TYPES = "resources_definition_types.json"
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt
index 24401ccf..48415efa 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt
@@ -21,6 +21,7 @@ import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.pro
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmptyOrThrow
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintTemplateService
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
@@ -59,8 +60,8 @@ open class ResourceResolutionServiceImpl(private var applicationContext: Applica
override fun registeredResourceSources(): List<String> {
return applicationContext.getBeanNamesForType(ResourceAssignmentProcessor::class.java)
- .filter { it.startsWith(ResourceResolutionConstants.PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR) }
- .map { it.substringAfter(ResourceResolutionConstants.PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR) }
+ .filter { it.startsWith(ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR) }
+ .map { it.substringAfter(ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR) }
}
override fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
@@ -123,6 +124,11 @@ open class ResourceResolutionServiceImpl(private var applicationContext: Applica
return resolvedContent
}
+ /**
+ * Iterate the Batch, get the Resource Assignment, dictionary Name, Look for the Resource definition for the
+ * name, then get the type of the Resource Definition, Get the instance for the Resource Type and process the
+ * request.
+ */
override fun resolveResourceAssignments(blueprintRuntimeService: BluePrintRuntimeService<*>,
resourceDictionaries: MutableMap<String, ResourceDefinition>,
resourceAssignments: MutableList<ResourceAssignment>,
@@ -133,12 +139,17 @@ open class ResourceResolutionServiceImpl(private var applicationContext: Applica
bulkSequenced.map { batchResourceAssignments ->
batchResourceAssignments.filter { it.name != "*" && it.name != "start" }
- .map { resourceAssignment ->
+ .forEach { resourceAssignment ->
+ val dictionaryName = resourceAssignment.dictionaryName
val dictionarySource = resourceAssignment.dictionarySource
- val processorInstanceName = ResourceResolutionConstants.PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR.plus(dictionarySource)
-
- val resourceAssignmentProcessor = applicationContext.getBean(processorInstanceName) as? ResourceAssignmentProcessor
- ?: throw BluePrintProcessorException("failed to get resource processor for instance name($processorInstanceName) " +
+ /**
+ * Get the Processor name
+ */
+ val processorName = processorName(dictionaryName!!, dictionarySource!!,
+ resourceDictionaries)
+
+ val resourceAssignmentProcessor = applicationContext.getBean(processorName) as? ResourceAssignmentProcessor
+ ?: throw BluePrintProcessorException("failed to get resource processor for name($processorName) " +
"for resource assignment(${resourceAssignment.name})")
try {
// Set BluePrint Runtime Service
@@ -155,4 +166,37 @@ open class ResourceResolutionServiceImpl(private var applicationContext: Applica
}
}
+
+ /**
+ * If the Source instance is "input", then it is not mandatory to have source Resource Definition, So it can
+ * derive the default input processor.
+ */
+ private fun processorName(dictionaryName: String, dictionarySource: String,
+ resourceDictionaries: MutableMap<String, ResourceDefinition>): String {
+ var processorName: String? = null
+ when (dictionarySource) {
+ "input" -> {
+ processorName = "${ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR}source-input"
+ }
+ "default" -> {
+ processorName = "${ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR}source-default"
+ }
+ else -> {
+ val resourceDefinition = resourceDictionaries[dictionaryName]
+ ?: throw BluePrintProcessorException("couldn't get resource dictionary definition for $dictionaryName")
+
+ val resourceSource = resourceDefinition.sources[dictionarySource]
+ ?: throw BluePrintProcessorException("couldn't get resource definition $dictionaryName source($dictionarySource)")
+
+ processorName = ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR
+ .plus(resourceSource.type)
+ }
+ }
+ checkNotEmptyOrThrow(processorName,
+ "couldn't get processor name for resource dictionary definition($dictionaryName) source" +
+ "($dictionarySource)")
+
+ return processorName
+
+ }
}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt
index 0f1267cb..1c357446 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceSourceProperties.kt
@@ -36,6 +36,8 @@ open class DefaultResourceSource : ResourceSourceProperties() {
open class DatabaseResourceSource : ResourceSourceProperties() {
lateinit var type: String
+ @get:JsonProperty("endpoint-selector")
+ var endpointSelector: String? = null
lateinit var query: String
@get:JsonProperty("input-key-mapping")
var inputKeyMapping: MutableMap<String, String>? = null
@@ -47,6 +49,8 @@ open class DatabaseResourceSource : ResourceSourceProperties() {
open class RestResourceSource : ResourceSourceProperties() {
lateinit var type: String
+ @get:JsonProperty("endpoint-selector")
+ var endpointSelector: String? = null
@get:JsonProperty("url-path")
lateinit var urlPath: String
lateinit var path: String
@@ -61,9 +65,10 @@ open class RestResourceSource : ResourceSourceProperties() {
}
open class CapabilityResourceSource : ResourceSourceProperties() {
- lateinit var type: String
- @get:JsonProperty("instance-name")
- lateinit var instanceName: String
+ @get:JsonProperty("script-type")
+ lateinit var scriptType: String
+ @get:JsonProperty("script-class-reference")
+ lateinit var scriptClassReference: String
@get:JsonProperty("instance-dependencies")
var instanceDependencies: List<String>? = null
@get:JsonProperty("key-dependencies")
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessor.kt
index 489645fd..c6b7d77e 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessor.kt
@@ -18,30 +18,27 @@
package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor
-import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.scripts.BlueprintJythonService
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.CapabilityResourceSource
+import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.scripts.BlueprintJythonService
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintScriptsService
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.config.ConfigurableBeanFactory
import org.springframework.context.ApplicationContext
+import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Service
import java.io.File
-@Service("resource-assignment-processor-capability")
-open class CapabilityResourceAssignmentProcessor(private var applicationContext: ApplicationContext,
+@Service("rr-processor-source-capability")
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+open class CapabilityResourceResolutionProcessor(private var applicationContext: ApplicationContext,
private val bluePrintScriptsService: BluePrintScriptsService,
private val bluePrintJythonService: BlueprintJythonService) :
ResourceAssignmentProcessor() {
- companion object {
- const val CAPABILITY_TYPE_KOTLIN_COMPONENT = "KOTLIN-COMPONENT"
- const val CAPABILITY_TYPE_JAVA_COMPONENT = "JAVA-COMPONENT"
- const val CAPABILITY_TYPE_JYTHON_COMPONENT = "JYTHON-COMPONENT"
- }
-
override fun getName(): String {
return "resource-assignment-processor-capability"
}
@@ -62,28 +59,28 @@ open class CapabilityResourceAssignmentProcessor(private var applicationContext:
val capabilityResourceSourceProperty = JacksonUtils
.getInstanceFromMap(resourceSourceProps, CapabilityResourceSource::class.java)
- val instanceType = capabilityResourceSourceProperty.type
- val instanceName = capabilityResourceSourceProperty.instanceName
+ val scriptType = capabilityResourceSourceProperty.scriptType
+ val scriptClassReference = capabilityResourceSourceProperty.scriptClassReference
var componentResourceAssignmentProcessor: ResourceAssignmentProcessor? = null
- when (instanceType) {
- CAPABILITY_TYPE_KOTLIN_COMPONENT -> {
- componentResourceAssignmentProcessor = getKotlinResourceAssignmentProcessorInstance(instanceName,
+ when (scriptType) {
+ BluePrintConstants.SCRIPT_KOTLIN -> {
+ componentResourceAssignmentProcessor = getKotlinResourceAssignmentProcessorInstance(scriptClassReference,
capabilityResourceSourceProperty.instanceDependencies)
}
- CAPABILITY_TYPE_JAVA_COMPONENT -> {
+ BluePrintConstants.SCRIPT_INTERNAL -> {
// Initialize Capability Resource Assignment Processor
- componentResourceAssignmentProcessor = applicationContext.getBean(instanceName, ResourceAssignmentProcessor::class.java)
+ componentResourceAssignmentProcessor = applicationContext.getBean(scriptClassReference, ResourceAssignmentProcessor::class.java)
}
- CAPABILITY_TYPE_JYTHON_COMPONENT -> {
- val content = getJythonContent(instanceName)
- componentResourceAssignmentProcessor = getJythonResourceAssignmentProcessorInstance(instanceName,
+ BluePrintConstants.SCRIPT_JYTHON -> {
+ val content = getJythonContent(scriptClassReference)
+ componentResourceAssignmentProcessor = getJythonResourceAssignmentProcessorInstance(scriptClassReference,
content, capabilityResourceSourceProperty.instanceDependencies)
}
}
- checkNotNull(componentResourceAssignmentProcessor) { "failed to get capability resource assignment processor($instanceName)" }
+ checkNotNull(componentResourceAssignmentProcessor) { "failed to get capability resource assignment processor($scriptClassReference)" }
// Assign Current Blueprint runtime and ResourceDictionaries
componentResourceAssignmentProcessor.raRuntimeService = raRuntimeService
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessor.kt
index e389f362..a8e0ad80 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/DefaultResourceResolutionProcessor.kt
@@ -17,34 +17,37 @@
package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor
-import com.fasterxml.jackson.databind.node.NullNode
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
import org.slf4j.LoggerFactory
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Service
/**
- * DefaultResourceAssignmentProcessor
+ * DefaultResourceResolutionProcessor
*
* @author Kapil Singal
*/
-@Service("resource-assignment-processor-default")
-open class DefaultResourceAssignmentProcessor : ResourceAssignmentProcessor() {
+@Service("rr-processor-source-default")
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+open class DefaultResourceResolutionProcessor : ResourceAssignmentProcessor() {
- private val logger = LoggerFactory.getLogger(DefaultResourceAssignmentProcessor::class.java)
+ private val logger = LoggerFactory.getLogger(DefaultResourceResolutionProcessor::class.java)
override fun getName(): String {
- return "resource-assignment-processor-default"
+ return "rr-processor-source-default"
}
override fun process(resourceAssignment: ResourceAssignment) {
try {
// Check if It has Input
- var value: Any? = raRuntimeService.getInputValue(resourceAssignment.name)
-
- // If value is null get it from default source
- if (value == null || value is NullNode) {
+ var value: Any?
+ try {
+ value = raRuntimeService.getInputValue(resourceAssignment.name)
+ } catch (e: BluePrintProcessorException) {
+ // If value is null get it from default source
logger.info("Looking for defaultValue as couldn't find value in input For template key (${resourceAssignment.name})")
value = resourceAssignment.property?.defaultValue
}
@@ -56,7 +59,8 @@ open class DefaultResourceAssignmentProcessor : ResourceAssignmentProcessor() {
ResourceAssignmentUtils.assertTemplateKeyValueNotNull(resourceAssignment)
} catch (e: Exception) {
ResourceAssignmentUtils.setFailedResourceDataValue(resourceAssignment, e.message)
- throw BluePrintProcessorException("Failed in template key ($resourceAssignment) assignments with: ${e.message}", e)
+ throw BluePrintProcessorException("Failed in template key ($resourceAssignment) assignments with: ${e.message}",
+ e)
}
}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/InputResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessor.kt
index 5757de2a..ed6b09fc 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/InputResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/InputResourceResolutionProcessor.kt
@@ -23,20 +23,23 @@ import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmpty
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
import org.slf4j.LoggerFactory
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Service
/**
- * InputResourceAssignmentProcessor
+ * InputResourceResolutionProcessor
*
* @author Kapil Singal
*/
-@Service("resource-assignment-processor-input")
-open class InputResourceAssignmentProcessor : ResourceAssignmentProcessor() {
+@Service("rr-processor-source-input")
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+open class InputResourceResolutionProcessor : ResourceAssignmentProcessor() {
- private val logger = LoggerFactory.getLogger(InputResourceAssignmentProcessor::class.java)
+ private val logger = LoggerFactory.getLogger(InputResourceResolutionProcessor::class.java)
override fun getName(): String {
- return "resource-assignment-processor-input"
+ return "rr-processor-source-input"
}
override fun process(resourceAssignment: ResourceAssignment) {
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/PrimaryDataResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/PrimaryDataResourceResolutionProcessor.kt
index 876c75fa..3922c376 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/PrimaryDataResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/PrimaryDataResourceResolutionProcessor.kt
@@ -18,32 +18,38 @@
package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor
import com.fasterxml.jackson.databind.node.JsonNodeFactory
-import com.fasterxml.jackson.databind.node.MissingNode
-import com.fasterxml.jackson.databind.node.NullNode
import org.onap.ccsdk.apps.blueprintsprocessor.db.primary.PrimaryDBLibGenericService
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.DatabaseResourceSource
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils
-import org.onap.ccsdk.apps.controllerblueprints.core.*
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes
+import org.onap.ccsdk.apps.controllerblueprints.core.checkEqualsOrThrow
+import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmptyOrThrow
+import org.onap.ccsdk.apps.controllerblueprints.core.nullToEmpty
+import org.onap.ccsdk.apps.controllerblueprints.core.returnNotEmptyOrThrow
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants
import org.slf4j.LoggerFactory
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Service
import java.util.*
/**
- * PrimaryDataResourceAssignmentProcessor
+ * PrimaryDataResourceResolutionProcessor
*
* @author Kapil Singal
*/
-@Service("resource-assignment-processor-primary-db")
-open class PrimaryDataResourceAssignmentProcessor(private val primaryDBLibGenericService: PrimaryDBLibGenericService)
+@Service("rr-processor-source-primary-db")
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+open class PrimaryDataResourceResolutionProcessor(private val primaryDBLibGenericService: PrimaryDBLibGenericService)
: ResourceAssignmentProcessor() {
- private val logger = LoggerFactory.getLogger(PrimaryDataResourceAssignmentProcessor::class.java)
+ private val logger = LoggerFactory.getLogger(PrimaryDataResourceResolutionProcessor::class.java)
override fun getName(): String {
- return "resource-assignment-processor-primary-db"
+ return "rr-processor-source-primary-db"
}
override fun process(resourceAssignment: ResourceAssignment) {
@@ -51,22 +57,27 @@ open class PrimaryDataResourceAssignmentProcessor(private val primaryDBLibGeneri
validate(resourceAssignment)
// Check if It has Input
- val value = raRuntimeService.getInputValue(resourceAssignment.name)
- if (value !is NullNode && value !is MissingNode) {
+ try {
+ val value = raRuntimeService.getInputValue(resourceAssignment.name)
logger.info("primary-db source template key (${resourceAssignment.name}) found from input and value is ($value)")
ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, value)
- } else {
+ } catch (e: BluePrintProcessorException) {
+ // Else, get from DB
val dName = resourceAssignment.dictionaryName
val dSource = resourceAssignment.dictionarySource
val resourceDefinition = resourceDictionaries[dName]
- ?: throw BluePrintProcessorException("couldn't get resource dictionary definition for $dName")
+ ?: throw BluePrintProcessorException("couldn't get resource dictionary definition for $dName")
val resourceSource = resourceDefinition.sources[dSource]
- ?: throw BluePrintProcessorException("couldn't get resource definition $dName source($dSource)")
- val resourceSourceProperties = checkNotNull(resourceSource.properties) { "failed to get source properties for $dName " }
- val sourceProperties = JacksonUtils.getInstanceFromMap(resourceSourceProperties, DatabaseResourceSource::class.java)
+ ?: throw BluePrintProcessorException("couldn't get resource definition $dName source($dSource)")
+ val resourceSourceProperties =
+ checkNotNull(resourceSource.properties) { "failed to get source properties for $dName " }
+ val sourceProperties =
+ JacksonUtils.getInstanceFromMap(resourceSourceProperties, DatabaseResourceSource::class.java)
- val sql = checkNotNull(sourceProperties.query) { "failed to get request query for $dName under $dSource properties" }
- val inputKeyMapping = checkNotNull(sourceProperties.inputKeyMapping) { "failed to get input-key-mappings for $dName under $dSource properties" }
+ val sql =
+ checkNotNull(sourceProperties.query) { "failed to get request query for $dName under $dSource properties" }
+ val inputKeyMapping =
+ checkNotNull(sourceProperties.inputKeyMapping) { "failed to get input-key-mappings for $dName under $dSource properties" }
logger.info("$dSource dictionary information : ($sql), ($inputKeyMapping), (${sourceProperties.outputKeyMapping})")
@@ -82,14 +93,16 @@ open class PrimaryDataResourceAssignmentProcessor(private val primaryDBLibGeneri
ResourceAssignmentUtils.assertTemplateKeyValueNotNull(resourceAssignment)
} catch (e: Exception) {
ResourceAssignmentUtils.setFailedResourceDataValue(resourceAssignment, e.message)
- throw BluePrintProcessorException("Failed in template key ($resourceAssignment) assignments with: ${e.message}", e)
+ throw BluePrintProcessorException("Failed in template key ($resourceAssignment) assignments with: ${e.message}",
+ e)
}
}
@Throws(BluePrintProcessorException::class)
private fun validate(resourceAssignment: ResourceAssignment) {
checkNotEmptyOrThrow(resourceAssignment.name, "resource assignment template key is not defined")
- checkNotEmptyOrThrow(resourceAssignment.dictionaryName, "resource assignment dictionary name is not defined for template key (${resourceAssignment.name})")
+ checkNotEmptyOrThrow(resourceAssignment.dictionaryName,
+ "resource assignment dictionary name is not defined for template key (${resourceAssignment.name})")
checkEqualsOrThrow(ResourceDictionaryConstants.SOURCE_PRIMARY_DB, resourceAssignment.dictionarySource) {
"resource assignment source is not ${ResourceDictionaryConstants.SOURCE_PRIMARY_DB} but it is ${resourceAssignment.dictionarySource}"
}
@@ -100,30 +113,33 @@ open class PrimaryDataResourceAssignmentProcessor(private val primaryDBLibGeneri
inputKeyMapping.forEach {
val expressionValue = raRuntimeService.getDictionaryStore(it.value)
logger.trace("Reference dictionary key (${it.key}) resulted in value ($expressionValue)")
- namedParameters[it.key] = expressionValue
+ namedParameters[it.key] = expressionValue.asText()
}
logger.info("Parameter information : ({})", namedParameters)
return namedParameters
}
@Throws(BluePrintProcessorException::class)
- private fun populateResource(resourceAssignment: ResourceAssignment, sourceProperties: DatabaseResourceSource, rows: List<Map<String, Any>>) {
+ private fun populateResource(resourceAssignment: ResourceAssignment, sourceProperties: DatabaseResourceSource,
+ rows: List<Map<String, Any>>) {
val dName = resourceAssignment.dictionaryName
val dSource = resourceAssignment.dictionarySource
val type = nullToEmpty(resourceAssignment.property?.type)
- val outputKeyMapping = checkNotNull(sourceProperties.outputKeyMapping) { "failed to get output-key-mappings for $dName under $dSource properties" }
+ val outputKeyMapping =
+ checkNotNull(sourceProperties.outputKeyMapping) { "failed to get output-key-mappings for $dName under $dSource properties" }
logger.info("Response processing type($type)")
// Primitive Types
- when(type) {
+ when (type) {
in BluePrintTypes.validPrimitiveTypes() -> {
val dbColumnValue = rows[0][outputKeyMapping[dName]]
logger.info("For template key (${resourceAssignment.name}) setting value as ($dbColumnValue)")
ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, dbColumnValue)
}
in BluePrintTypes.validCollectionTypes() -> {
- val entrySchemaType = returnNotEmptyOrThrow(resourceAssignment.property?.entrySchema?.type) { "Entry schema is not defined for dictionary ($dName) info" }
+ val entrySchemaType =
+ returnNotEmptyOrThrow(resourceAssignment.property?.entrySchema?.type) { "Entry schema is not defined for dictionary ($dName) info" }
var arrayNode = JsonNodeFactory.instance.arrayNode()
rows.forEach {
if (entrySchemaType in BluePrintTypes.validPrimitiveTypes()) {
@@ -134,8 +150,12 @@ open class PrimaryDataResourceAssignmentProcessor(private val primaryDBLibGeneri
val arrayChildNode = JsonNodeFactory.instance.objectNode()
for (mapping in outputKeyMapping.entries) {
val dbColumnValue = checkNotNull(it[mapping.key])
- val propertyTypeForDataType = ResourceAssignmentUtils.getPropertyType(raRuntimeService, entrySchemaType, mapping.key)
- JacksonUtils.populatePrimitiveValues(mapping.key, dbColumnValue, propertyTypeForDataType, arrayChildNode)
+ val propertyTypeForDataType =
+ ResourceAssignmentUtils.getPropertyType(raRuntimeService, entrySchemaType, mapping.key)
+ JacksonUtils.populatePrimitiveValues(mapping.key,
+ dbColumnValue,
+ propertyTypeForDataType,
+ arrayChildNode)
}
arrayNode.add(arrayChildNode)
}
@@ -150,8 +170,12 @@ open class PrimaryDataResourceAssignmentProcessor(private val primaryDBLibGeneri
var objectNode = JsonNodeFactory.instance.objectNode()
for (mapping in outputKeyMapping.entries) {
val dbColumnValue = checkNotNull(row[mapping.key])
- val propertyTypeForDataType = ResourceAssignmentUtils.getPropertyType(raRuntimeService, type, mapping.key)
- JacksonUtils.populatePrimitiveValues(mapping.key, dbColumnValue, propertyTypeForDataType, objectNode)
+ val propertyTypeForDataType =
+ ResourceAssignmentUtils.getPropertyType(raRuntimeService, type, mapping.key)
+ JacksonUtils.populatePrimitiveValues(mapping.key,
+ dbColumnValue,
+ propertyTypeForDataType,
+ objectNode)
}
logger.info("For template key (${resourceAssignment.name}) setting value as ($objectNode)")
ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, objectNode)
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt
index b07155a3..9b7c70aa 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt
@@ -57,9 +57,13 @@ abstract class ResourceAssignmentProcessor : BlueprintFunctionNode<ResourceAssig
return ResourceAssignment()
}
- override fun apply(executionServiceInput: ResourceAssignment): ResourceAssignment {
- prepareRequest(executionServiceInput)
- process(executionServiceInput)
+ override fun apply(resourceAssignment: ResourceAssignment): ResourceAssignment {
+ try {
+ prepareRequest(resourceAssignment)
+ process(resourceAssignment)
+ } catch (runtimeException: RuntimeException) {
+ recover(runtimeException, resourceAssignment)
+ }
return prepareResponse()
}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/SimpleRestResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt
index a264ba50..4daa46e5 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/SimpleRestResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt
@@ -24,26 +24,30 @@ import com.fasterxml.jackson.databind.node.ObjectNode
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.RestResourceSource
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils
import org.onap.ccsdk.apps.blueprintsprocessor.rest.service.BluePrintRestLibPropertyService
+import org.onap.ccsdk.apps.blueprintsprocessor.rest.service.BlueprintWebClientService
import org.onap.ccsdk.apps.controllerblueprints.core.*
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDictionaryConstants
import org.slf4j.LoggerFactory
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Service
/**
- * SimpleRestResourceAssignmentProcessor
+ * RestResourceResolutionProcessor
*
* @author Kapil Singal
*/
-@Service("resource-assignment-processor-primary-config-data")
-open class SimpleRestResourceAssignmentProcessor(private val blueprintRestLibPropertyService: BluePrintRestLibPropertyService)
+@Service("rr-processor-source-rest")
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+open class RestResourceResolutionProcessor(private val blueprintRestLibPropertyService: BluePrintRestLibPropertyService)
: ResourceAssignmentProcessor() {
- private val logger = LoggerFactory.getLogger(SimpleRestResourceAssignmentProcessor::class.java)
+ private val logger = LoggerFactory.getLogger(RestResourceResolutionProcessor::class.java)
override fun getName(): String {
- return "resource-assignment-processor-primary-config-data"
+ return "rr-processor-source-rest"
}
override fun process(resourceAssignment: ResourceAssignment) {
@@ -70,8 +74,8 @@ open class SimpleRestResourceAssignmentProcessor(private val blueprintRestLibPro
val inputKeyMapping = checkNotNull(sourceProperties.inputKeyMapping) { "failed to get input-key-mappings for $dName under $dSource properties" }
logger.info("$dSource dictionary information : ($urlPath), ($inputKeyMapping), (${sourceProperties.outputKeyMapping})")
- // TODO("Dynamic Rest Client Service, call (blueprintDynamicWebClientService || blueprintWebClientService")
- val restClientService = blueprintRestLibPropertyService.blueprintWebClientService("primary-config-data")
+ // Get the Rest Client Service
+ val restClientService = blueprintWebClientService(resourceAssignment, sourceProperties)
val response = restClientService.getResource(urlPath, String::class.java)
if (response.isNotBlank()) {
logger.warn("Failed to get $dSource result for dictionary name ($dName) using urlPath ($urlPath)")
@@ -87,6 +91,16 @@ open class SimpleRestResourceAssignmentProcessor(private val blueprintRestLibPro
}
}
+ open fun blueprintWebClientService(resourceAssignment: ResourceAssignment,
+ restResourceSource: RestResourceSource): BlueprintWebClientService {
+ return if (checkNotEmpty(restResourceSource.endpointSelector)) {
+ val restPropertiesJson = raRuntimeService.resolveDSLExpression(restResourceSource.endpointSelector!!)
+ blueprintRestLibPropertyService.blueprintWebClientService(restPropertiesJson)
+ } else {
+ blueprintRestLibPropertyService.blueprintWebClientService(resourceAssignment.dictionarySource!!)
+ }
+ }
+
@Throws(BluePrintProcessorException::class)
private fun populateResource(resourceAssignment: ResourceAssignment, sourceProperties: RestResourceSource, restResponse: String, path: String) {
val dName = resourceAssignment.dictionaryName
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt
index 93b93fec..1c9a905f 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt
@@ -23,7 +23,13 @@ import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.databind.node.NullNode
import com.fasterxml.jackson.databind.node.ObjectNode
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceAssignmentRuntimeService
-import org.onap.ccsdk.apps.controllerblueprints.core.*
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes
+import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmpty
+import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmptyOrThrow
+import org.onap.ccsdk.apps.controllerblueprints.core.nullToEmpty
+import org.onap.ccsdk.apps.controllerblueprints.core.returnNotEmptyOrThrow
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
@@ -41,13 +47,13 @@ class ResourceAssignmentUtils {
val resourceProp = checkNotNull(resourceAssignment.property) { "Failed in setting resource value for resource mapping $resourceAssignment" }
checkNotEmptyOrThrow(resourceAssignment.name, "Failed in setting resource value for resource mapping $resourceAssignment")
- if (checkNotEmpty(resourceAssignment.dictionaryName)) {
+ if (resourceAssignment.dictionaryName.isNullOrEmpty()) {
resourceAssignment.dictionaryName = resourceAssignment.name
logger.warn("Missing dictionary key, setting with template key (${resourceAssignment.name}) as dictionary key (${resourceAssignment.dictionaryName})")
}
try {
- if (checkNotEmpty(resourceProp.type)) {
+ if (resourceProp.type.isNotEmpty()) {
val convertedValue = convertResourceValue(resourceProp.type, value)
logger.info("Setting Resource Value ($convertedValue) for Resource Name (${resourceAssignment.dictionaryName}) of type (${resourceProp.type})")
setResourceValue(resourceAssignment, raRuntimeService, convertedValue)
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt
index fbecb55c..c3b10184 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentTest.kt
@@ -42,9 +42,9 @@ import org.springframework.test.context.junit4.SpringRunner
@RunWith(SpringRunner::class)
@ContextConfiguration(classes = [ResourceResolutionServiceImpl::class,
- InputResourceAssignmentProcessor::class, DefaultResourceAssignmentProcessor::class,
- PrimaryDataResourceAssignmentProcessor::class, SimpleRestResourceAssignmentProcessor::class,
- CapabilityResourceAssignmentProcessor::class, PrimaryDBLibGenericService::class,
+ InputResourceResolutionProcessor::class, DefaultResourceResolutionProcessor::class,
+ PrimaryDataResourceResolutionProcessor::class, RestResourceResolutionProcessor::class,
+ CapabilityResourceResolutionProcessor::class, PrimaryDBLibGenericService::class,
BlueprintPropertyConfiguration::class, BluePrintProperties::class,
BluePrintDBLibConfiguration::class, BluePrintLoadConfiguration::class])
@TestPropertySource(locations = ["classpath:application-test.properties"])
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt
index d0d3a13f..6d2d3f2d 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt
@@ -47,9 +47,9 @@ import kotlin.test.assertTrue
*/
@RunWith(SpringRunner::class)
@ContextConfiguration(classes = [ResourceResolutionServiceImpl::class,
- InputResourceAssignmentProcessor::class, DefaultResourceAssignmentProcessor::class,
- PrimaryDataResourceAssignmentProcessor::class, SimpleRestResourceAssignmentProcessor::class,
- CapabilityResourceAssignmentProcessor::class, PrimaryDBLibGenericService::class,
+ InputResourceResolutionProcessor::class, DefaultResourceResolutionProcessor::class,
+ PrimaryDataResourceResolutionProcessor::class, RestResourceResolutionProcessor::class,
+ CapabilityResourceResolutionProcessor::class, PrimaryDBLibGenericService::class,
BlueprintPropertyConfiguration::class, BluePrintProperties::class,
BluePrintDBLibConfiguration::class, BluePrintLoadConfiguration::class])
@TestPropertySource(locations = ["classpath:application-test.properties"])
@@ -66,7 +66,8 @@ class ResourceResolutionServiceTest {
fun testRegisteredSource() {
val sources = resourceResolutionService.registeredResourceSources()
assertNotNull(sources, "failed to get registered sources")
- assertTrue(sources.containsAll(arrayListOf("input", "default", "primary-db", "primary-config-data")), "failed to get registered sources")
+ assertTrue(sources.containsAll(arrayListOf("source-input", "source-default", "source-primary-db",
+ "source-rest")), "failed to get registered sources")
}
@Test
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessorTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt
index 0dbd0f6e..f779054e 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessorTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt
@@ -20,9 +20,9 @@ package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.pr
import org.junit.Test
import org.junit.runner.RunWith
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceAssignmentRuntimeService
import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.scripts.BlueprintJythonService
import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.scripts.PythonExecutorProperty
-import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceAssignmentRuntimeService
import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition
import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
@@ -36,15 +36,15 @@ import org.springframework.test.context.junit4.SpringRunner
import kotlin.test.assertNotNull
@RunWith(SpringRunner::class)
-@ContextConfiguration(classes = [CapabilityResourceAssignmentProcessor::class, BluePrintScriptsServiceImpl::class,
+@ContextConfiguration(classes = [CapabilityResourceResolutionProcessor::class, BluePrintScriptsServiceImpl::class,
BlueprintJythonService::class, PythonExecutorProperty::class, MockCapabilityService::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 CapabilityResourceAssignmentProcessorTest {
+class CapabilityResourceResolutionProcessorTest {
@Autowired
- lateinit var capabilityResourceAssignmentProcessor: CapabilityResourceAssignmentProcessor
+ lateinit var capabilityResourceResolutionProcessor: CapabilityResourceResolutionProcessor
@Test
fun `test kotlin capability`() {
@@ -54,15 +54,15 @@ class CapabilityResourceAssignmentProcessorTest {
val resourceAssignmentRuntimeService = ResourceAssignmentRuntimeService("1234", bluePrintContext)
- capabilityResourceAssignmentProcessor.raRuntimeService = resourceAssignmentRuntimeService
- capabilityResourceAssignmentProcessor.resourceDictionaries = hashMapOf()
+ capabilityResourceResolutionProcessor.raRuntimeService = resourceAssignmentRuntimeService
+ capabilityResourceResolutionProcessor.resourceDictionaries = hashMapOf()
val scriptPropertyInstances: MutableMap<String, Any> = mutableMapOf()
scriptPropertyInstances["mock-service1"] = MockCapabilityService()
scriptPropertyInstances["mock-service2"] = MockCapabilityService()
- val resourceAssignmentProcessor = capabilityResourceAssignmentProcessor
+ val resourceAssignmentProcessor = capabilityResourceResolutionProcessor
.getKotlinResourceAssignmentProcessorInstance(
"ResourceAssignmentProcessor_cba\$ScriptResourceAssignmentProcessor", scriptPropertyInstances)
@@ -90,14 +90,14 @@ class CapabilityResourceAssignmentProcessorTest {
val resourceAssignmentRuntimeService = ResourceAssignmentRuntimeService("1234", bluePrintContext)
- capabilityResourceAssignmentProcessor.raRuntimeService = resourceAssignmentRuntimeService
+ capabilityResourceResolutionProcessor.raRuntimeService = resourceAssignmentRuntimeService
val resourceDefinition = JacksonUtils
.readValueFromClassPathFile("mapping/capability/jython-resource-definitions.json",
ResourceDefinition::class.java)!!
val resourceDefinitions: MutableMap<String, ResourceDefinition> = mutableMapOf()
resourceDefinitions[resourceDefinition.name] = resourceDefinition
- capabilityResourceAssignmentProcessor.resourceDictionaries = resourceDefinitions
+ capabilityResourceResolutionProcessor.resourceDictionaries = resourceDefinitions
val resourceAssignment = ResourceAssignment().apply {
name = "service-instance-id"
@@ -108,7 +108,7 @@ class CapabilityResourceAssignmentProcessorTest {
}
}
- val processorName = capabilityResourceAssignmentProcessor.apply(resourceAssignment)
+ val processorName = capabilityResourceResolutionProcessor.apply(resourceAssignment)
assertNotNull(processorName, "couldn't get Jython script resource assignment processor name")
}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/capability/jython-resource-definitions.json b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/capability/jython-resource-definitions.json
index d3780e0a..fe89291c 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/capability/jython-resource-definitions.json
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/capability/jython-resource-definitions.json
@@ -10,8 +10,8 @@
"capability": {
"type": "source-capability",
"properties": {
- "type": "JYTHON-COMPONENT",
- "instance-name": "SampleRAProcessor",
+ "script-type": "jython",
+ "script-class-reference": "SampleRAProcessor",
"instance-dependencies": []
}
}
diff --git a/ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/scripts/InternalSimpleRestconf.cba.kts b/ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/scripts/InternalSimpleRestconf.cba.kts
index 1c4ba9b6..dbbebe52 100644
--- a/ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/scripts/InternalSimpleRestconf.cba.kts
+++ b/ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/scripts/InternalSimpleRestconf.cba.kts
@@ -13,9 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+@file:Suppress("unused") //TODO remove this line!
+
+import com.fasterxml.jackson.databind.node.ObjectNode
+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.restconf.executor.RestconfComponentFunction
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.slf4j.LoggerFactory
open class EditConfigure : RestconfComponentFunction() {
@@ -27,7 +33,7 @@ open class EditConfigure : RestconfComponentFunction() {
}
override fun process(executionRequest: ExecutionServiceInput) {
- val webClientService = restClientService("odlparent")
+ //val webClientService = restClientService("odlparent")
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
@@ -46,12 +52,15 @@ open class MountNEditConfigure : RestconfComponentFunction() {
override fun process(executionRequest: ExecutionServiceInput) {
val webClientService = restClientService("odlparent")
+ println("foi?")
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
+
+
}
/**
@@ -72,4 +81,20 @@ open class TestRestconfConfigure : RestconfComponentFunction() {
override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
log.info("recovering..")
}
-} \ No newline at end of file
+}
+
+
+
+println("zzzzzzzzzzzzz")
+val x = MountNEditConfigure()
+println(x.getName())
+val executionServiceInput = ExecutionServiceInput().apply {
+ commonHeader = CommonHeader().apply {
+ requestId = "1234"
+ }
+ actionIdentifiers = ActionIdentifiers().apply {
+ actionName = "activate"
+ }
+ payload = JacksonUtils.jsonNode("{}") as ObjectNode
+}
+x.process(executionServiceInput); \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BlueprintProcessorCatalogServiceImpl.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BlueprintProcessorCatalogServiceImpl.kt
index 33d0d96d..e94bcff5 100755
--- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BlueprintProcessorCatalogServiceImpl.kt
+++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/db/BlueprintProcessorCatalogServiceImpl.kt
@@ -1,6 +1,7 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
* Modifications Copyright © 2019 Bell Canada.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -40,10 +41,10 @@ import java.nio.file.Paths
* Similar/Duplicate implementation in [org.onap.ccsdk.apps.controllerblueprints.service.load.ControllerBlueprintCatalogServiceImpl]
*/
@Service
-class BlueprintProcessorCatalogServiceImpl(bluePrintValidatorService: BluePrintValidatorService,
+class BlueprintProcessorCatalogServiceImpl(bluePrintRuntimeValidatorService: BluePrintValidatorService,
private val blueprintConfig: BluePrintCoreConfiguration,
private val blueprintModelRepository: BlueprintProcessorModelRepository)
- : BlueprintCatalogServiceImpl(bluePrintValidatorService) {
+ : BlueprintCatalogServiceImpl(bluePrintRuntimeValidatorService) {
private val log = LoggerFactory.getLogger(BlueprintProcessorCatalogServiceImpl::class.toString())
diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/test/resources/test-cba.zip b/ms/blueprintsprocessor/modules/commons/db-lib/src/test/resources/test-cba.zip
index a62d4bfb..90748240 100644
--- a/ms/blueprintsprocessor/modules/commons/db-lib/src/test/resources/test-cba.zip
+++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/test/resources/test-cba.zip
Binary files differ
diff --git a/ms/blueprintsprocessor/modules/commons/dmaap-lib/pom.xml b/ms/blueprintsprocessor/modules/commons/dmaap-lib/pom.xml
new file mode 100644
index 00000000..0dd3da35
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/dmaap-lib/pom.xml
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ ============LICENSE_START=======================================================
+ ~ ONAP - CDS
+ ~ ================================================================================
+ ~ Copyright (C) 2019 Huawei Technologies Co., Ltd. All rights reserved.
+ ~ ================================================================================
+ ~ 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.
+ ~ ============LICENSE_END=========================================================
+ -->
+<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.1-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>dmaap-lib</artifactId>
+ <packaging>jar</packaging>
+ <name>Blueprints Processor Dmaap Lib</name>
+ <description>Blueprints Processor Dmaap Lib</description>
+
+ <properties>
+ <dmaap.client.version>1.1.5</dmaap.client.version>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.dmaap.messagerouter.dmaapclient</groupId>
+ <artifactId>dmaapClient</artifactId>
+ <version>${dmaap.client.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-webflux</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.glassfish.jersey.inject</groupId>
+ <artifactId>jersey-hk2</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.ws.rs</groupId>
+ <artifactId>javax.ws.rs-api</artifactId>
+ <version>2.1-m07</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jetbrains.kotlin</groupId>
+ <artifactId>kotlin-test-junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/dmaap/DmaapEventPublisher.kt b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/dmaap/DmaapEventPublisher.kt
new file mode 100644
index 00000000..7c686f08
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/dmaap/DmaapEventPublisher.kt
@@ -0,0 +1,181 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - CDS
+ * ================================================================================
+ * Copyright (C) 2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.dmaap
+
+import com.att.nsa.mr.client.MRBatchingPublisher
+import com.att.nsa.mr.client.MRClientFactory
+import com.att.nsa.mr.client.MRPublisher
+import org.slf4j.LoggerFactory
+import org.springframework.boot.context.properties.bind.Binder
+import org.springframework.boot.context.properties.source.ConfigurationPropertySources
+import org.springframework.context.annotation.Configuration
+import org.springframework.context.annotation.PropertySource
+import org.springframework.context.annotation.PropertySources
+import org.springframework.core.env.ConfigurableEnvironment
+import org.springframework.core.env.Environment
+import org.springframework.core.io.support.ResourcePropertySource
+import java.io.IOException
+import java.util.Properties
+import java.util.concurrent.TimeUnit
+
+/**
+ * Representation of DMaap event publisher, to create a session with the
+ * message router and send messages when asked for. The producer.properties
+ * is used for creating a session. In order to overwrite the parameters such
+ * as host, topic, username and password, the event.properties can be used.
+ *
+ * compName : Name of the component appended in the event.properties file
+ * to overwrite.
+ * (E.g., so.topic=cds_so : In this "so" is the component name)
+ */
+@Configuration
+@PropertySources(PropertySource("classpath:event.properties",
+ "classpath:producer.properties"))
+open class DmaapEventPublisher(compName: String = ""): EventPublisher {
+
+ /**
+ * Static variable for logging.
+ */
+ companion object {
+ var log = LoggerFactory.getLogger(DmaapEventPublisher::class.java)!!
+ }
+
+ /**
+ * The component name used in defining the event.properties file.
+ */
+ private var cName:String? = null
+
+ /**
+ * List of topics for a given message to be sent.
+ */
+ var topics = mutableListOf<String>()
+
+ /**
+ * List of clients formed for the list of topics where the messages has to
+ * be sent.
+ */
+ var clients = mutableListOf<MRBatchingPublisher>()
+
+ /**
+ * The populated values from producer.properties which are overwritten
+ * by the event.properties values according to the component information.
+ */
+ var prodProps: Properties = Properties()
+
+
+ init {
+ cName = compName
+ }
+
+ /**
+ * Loads the producer.properties file and populates all the parameters
+ * and then loads the event.properties file and populates the finalized
+ * parameters such as host, topic, username and password if available for
+ * the specified component. With this updated producer.properties, for
+ * each topic a client will be created.
+ */
+ private fun loadPropertiesInfo() {
+ if (prodProps.isEmpty) {
+ parseEventProps(cName!!)
+ addClients()
+ }
+ }
+
+ /**
+ * Adds clients for each topic into a client list.
+ */
+ private fun addClients() {
+ for (topic in topics) {
+ prodProps.setProperty("topic", topic)
+ val client = MRClientFactory.createBatchingPublisher(prodProps)
+ clients.add(client)
+ }
+ }
+
+ /**
+ * Parses the event.properties file and update it into the producer
+ * .properties, where both the files are loaded and stored.
+ */
+ private fun parseEventProps(cName: String) {
+ val env = EnvironmentContext.env as Environment
+ val propSrc = ConfigurationPropertySources.get(env)
+ val proProps = (env as ConfigurableEnvironment).propertySources.get(
+ "class path resource [producer.properties]")
+
+ if (proProps != null) {
+ val entries = (proProps as ResourcePropertySource).source.entries
+ for (e in entries) {
+ prodProps.put(e.key, e.value)
+ }
+ } else {
+ log.info("Unable to load the producer.properties file")
+ }
+
+ val eProps = Binder(propSrc).bind(cName, Properties::class.java).get()
+ val top = eProps.get("topic").toString()
+ if (top != "") {
+ topics.addAll(top.split(","))
+ }
+ prodProps.putAll(eProps)
+ }
+
+ /**
+ * Sends message to the sessions created by the information provided in
+ * the producer.properties file.
+ */
+ override fun sendMessage(partition: String , messages: Collection<String>):
+ Boolean {
+ loadPropertiesInfo()
+ var success = true
+ val dmaapMsgs = mutableListOf<MRPublisher.message>()
+ for (m in messages) {
+ dmaapMsgs.add(MRPublisher.message(partition, m))
+ }
+ for (client in clients) {
+ log.info("Sending messages to the DMaap Server")
+ try {
+ client.send(dmaapMsgs)
+ } catch (e: IOException) {
+ log.error(e.message, e)
+ success = false
+ }
+ }
+ return success
+ }
+
+ /**
+ * Closes the opened session that was used for sending messages.
+ */
+ override fun close(timeout: Long) {
+ log.debug("Closing the DMaap producer clients")
+ if (!clients.isEmpty()) {
+ for (client in clients) {
+ try {
+ client.close(timeout, TimeUnit.SECONDS)
+ } catch (e : IOException) {
+ log.warn("Unable to cleanly close the connection from " +
+ "the client $client", e)
+ }
+ }
+ }
+ }
+
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/dmaap/EnvironmentContext.kt b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/dmaap/EnvironmentContext.kt
new file mode 100644
index 00000000..1d2a28ce
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/dmaap/EnvironmentContext.kt
@@ -0,0 +1,56 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - CDS
+ * ================================================================================
+ * Copyright (C) 2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.dmaap
+
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.core.env.Environment
+import org.springframework.stereotype.Component
+import javax.annotation.PostConstruct
+
+/**
+ * Abstraction of environment context information component.
+ */
+@Component
+class EnvironmentContext {
+
+ /**
+ * Environment information.
+ */
+ companion object {
+ var env: Environment? = null
+ }
+
+ /**
+ * Environment auto-wired information.
+ */
+ @Autowired
+ var environment: Environment? = null
+
+ /**
+ * Initiates the static variable after the instantiation takes place to
+ * the auto-wired variable.
+ */
+ @PostConstruct
+ private fun initStaticContext() {
+ env = environment
+ }
+
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/dmaap/EventPublisher.kt b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/dmaap/EventPublisher.kt
new file mode 100644
index 00000000..7d02e806
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/dmaap/EventPublisher.kt
@@ -0,0 +1,39 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - CDS
+ * ================================================================================
+ * Copyright (C) 2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.dmaap
+
+/**
+ * Abstraction of a publisher, to send messages with the given partition in a
+ * session and closing the same.
+ */
+interface EventPublisher {
+
+ /**
+ * Sends messages through a session on a given partition.
+ */
+ fun sendMessage(partition: String, messages: Collection<String>): Boolean
+
+ /**
+ * Closes the session with the given time.
+ */
+ fun close(timeout: Long)
+
+}
diff --git a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/resources/event.properties b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/resources/event.properties
new file mode 100644
index 00000000..be764d84
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/resources/event.properties
@@ -0,0 +1,26 @@
+#
+# ============LICENSE_START=======================================================
+# ONAP - CDS
+# ================================================================================
+# Copyright (C) 2019 Huawei Technologies Co., Ltd. All rights reserved.
+# ================================================================================
+# 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.
+# ============LICENSE_END=========================================================
+#
+
+
+so.topic=cds_so
+so.username=admin
+so.password=admin
+so.host=10.12.6.236:30226
+
diff --git a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/resources/producer.properties b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/resources/producer.properties
new file mode 100644
index 00000000..c3c228ba
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/main/resources/producer.properties
@@ -0,0 +1,52 @@
+#
+# ============LICENSE_START=======================================================
+# ONAP - CDS
+# ================================================================================
+# Copyright (C) 2019 Huawei Technologies Co., Ltd. All rights reserved.
+# ================================================================================
+# 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.
+# ============LICENSE_END=========================================================
+#
+
+#TransportType-Specify which way user want to use. I.e. <HTTPAAF,DME2,HTTPAUTH >
+TransportType=HTTPNOAUTH
+Latitude =50.000000
+Longitude =-100.000000
+Version =3.1
+ServiceName =dmaap-v1.dev.dmaap.dt.saat.acsi.att.com/events
+Environment =TEST
+Partner=BOT_R
+routeOffer=MR1
+SubContextPath =/
+Protocol =http
+MethodType =POST
+username =admin
+password =admin
+contenttype = application/json
+authKey=01234567890abcde:01234567890abcdefghijklmn
+authDate=2016-07-20T11:30:56-0700
+host=10.12.6.236:30227
+topic=org.onap.appc.UNIT-TEST
+partition=1
+maxBatchSize=100
+maxAgeMs=250
+AFT_DME2_EXCHANGE_REQUEST_HANDLERS=com.att.nsa.test.PreferredRouteRequestHandler
+AFT_DME2_EXCHANGE_REPLY_HANDLERS=com.att.nsa.test.PreferredRouteReplyHandler
+AFT_DME2_REQ_TRACE_ON=true
+AFT_ENVIRONMENT=AFTUAT
+AFT_DME2_EP_CONN_TIMEOUT=15000
+AFT_DME2_ROUNDTRIP_TIMEOUT_MS=240000
+AFT_DME2_EP_READ_TIMEOUT_MS=50000
+sessionstickinessrequired=NO
+DME2preferredRouterFilePath=src/test/resources/preferredRoute.txt
+MessageSentThreadOccurance=50
diff --git a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/test/kotlin/org/ccsdk/apps/blueprintprocessor/dmaap/TestDmaapEventPublisher.kt b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/test/kotlin/org/ccsdk/apps/blueprintprocessor/dmaap/TestDmaapEventPublisher.kt
new file mode 100644
index 00000000..ac888218
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/test/kotlin/org/ccsdk/apps/blueprintprocessor/dmaap/TestDmaapEventPublisher.kt
@@ -0,0 +1,118 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP - CDS
+ * ================================================================================
+ * Copyright (C) 2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.ccsdk.apps.blueprintprocessor.dmaap
+
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.onap.ccsdk.apps.blueprintsprocessor.dmaap.DmaapEventPublisher
+import org.onap.ccsdk.apps.blueprintsprocessor.dmaap.EnvironmentContext
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration
+import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
+import org.springframework.boot.test.context.SpringBootTest
+import org.springframework.http.HttpStatus
+import org.springframework.http.ResponseEntity
+import org.springframework.test.context.ContextConfiguration
+import org.springframework.test.context.TestPropertySource
+import org.springframework.test.context.junit4.SpringRunner
+import org.springframework.web.bind.annotation.PathVariable
+import org.springframework.web.bind.annotation.PostMapping
+import org.springframework.web.bind.annotation.RequestMapping
+import org.springframework.web.bind.annotation.RestController
+import kotlin.test.assertEquals
+import kotlin.test.assertNotNull
+
+/**
+ * Unit test cases for DMaap publisher code.
+ */
+@RunWith(SpringRunner::class)
+@EnableAutoConfiguration(exclude = [DataSourceAutoConfiguration::class])
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
+@ContextConfiguration(classes = [EnvironmentContext::class, TestController::class,
+ DmaapEventPublisher::class])
+@TestPropertySource(properties = ["server.port=9111","aai.topic=cds_aai",
+ "aai.username=admin","aai.password=admin","aai.host=127.0.0.1:9111",
+ "mul.topic=cds_mul_1,cds_mul_2", "mul.username=admin","mul.password=admin",
+ "mul.host=127.0.0.1:9111"])
+class TestDmaapEventPublisher {
+
+ /**
+ * Tests the event properties being set properly and sent as request.
+ */
+ @Test
+ fun testEventProperties() {
+ val strList = mutableListOf<String>()
+ val pub = DmaapEventPublisher(compName = "aai")
+ strList.add("{\n" +
+ " \"a\" : \"hello\"\n" +
+ "}")
+ pub.sendMessage("1", strList)
+ pub.close(2)
+ pub.prodProps
+ assertNotNull(pub.prodProps, "The property file updation failed")
+ assertEquals(pub.prodProps.get("topic"), "cds_aai")
+ assertEquals(pub.prodProps.get("username"), "admin")
+ assertEquals(pub.prodProps.get("password"), "admin")
+ assertEquals(pub.prodProps.get("host"), "127.0.0.1:9111")
+ }
+
+ /**
+ * Tests the event properties with multiple topics.
+ */
+ @Test
+ fun testMultiTopicProperties() {
+ val strList = mutableListOf<String>()
+ val pub = DmaapEventPublisher(compName = "mul")
+ strList.add("{\n" +
+ " \"a\" : \"hello\"\n" +
+ "}")
+ pub.sendMessage("1", strList)
+ pub.close(2)
+ var tops = pub.topics
+ assertNotNull(pub.prodProps, "The property file updation failed")
+ assertEquals(tops[0], "cds_mul_1")
+ assertEquals(tops[1], "cds_mul_2")
+ //assertEquals(pub.topics.contains("cds_mul_2`"), true)
+ assertEquals(pub.prodProps.get("username"), "admin")
+ assertEquals(pub.prodProps.get("password"), "admin")
+ assertEquals(pub.prodProps.get("host"), "127.0.0.1:9111")
+ }
+}
+
+/**
+ * Rest controller for testing the client request that is sent.
+ */
+@RestController
+@RequestMapping(path = ["/events"])
+open class TestController {
+
+ /**
+ * Accepts request for a topic and sends a message as response.
+ */
+ @PostMapping(path = ["/{topic}"])
+ fun postTopic(@PathVariable(value = "topic") topic : String):
+ ResponseEntity<Any> {
+ var a = "{\n" +
+ " \"message\" : \"The message is published into $topic " +
+ "topic\"\n" +
+ "}"
+ return ResponseEntity(a, HttpStatus.OK)
+ }
+}
diff --git a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/test/resources/logback-test.xml b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/test/resources/logback-test.xml
new file mode 100644
index 00000000..0f76057a
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/test/resources/logback-test.xml
@@ -0,0 +1,40 @@
+<!--
+ ~ ============LICENSE_START=======================================================
+ ~ ONAP - CDS
+ ~ ================================================================================
+ ~ Copyright (C) 2019 Huawei Technologies Co., Ltd. All rights reserved.
+ ~ ================================================================================
+ ~ 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.
+ ~ ============LICENSE_END=========================================================
+ -->
+
+
+<configuration>
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <!-- encoders are assigned the type
+ ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
+ <encoder>
+ <pattern>%d{HH:mm:ss.SSS} %-5level %logger{100} - %msg%n</pattern>
+ </encoder>
+ </appender>
+
+ <logger name="org.springframework.test" level="warn"/>
+ <logger name="org.springframework" level="warn"/>
+ <logger name="org.hibernate" level="info"/>
+ <logger name="org.onap.ccsdk.apps.blueprintsprocessor" level="info"/>
+
+ <root level="warn">
+ <appender-ref ref="STDOUT"/>
+ </root>
+
+</configuration>
diff --git a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/test/resources/preferredRoute.txt b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/test/resources/preferredRoute.txt
new file mode 100644
index 00000000..7e6ed8bd
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/test/resources/preferredRoute.txt
@@ -0,0 +1,22 @@
+# ============LICENSE_START==========================================
+# ONAP : APPC
+# ===================================================================
+# Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+# ===================================================================
+#
+# Unless otherwise specified, all software contained herein is licensed
+# under the Apache License, Version 2.0 (the License);
+# you may not use this software 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.
+#
+# ECOMP is a trademark and service mark of AT&T Intellectual Property.
+# ============LICENSE_END============================================
+preferredRouteKey=MR1
diff --git a/ms/blueprintsprocessor/modules/commons/pom.xml b/ms/blueprintsprocessor/modules/commons/pom.xml
index 8d900a89..9d5dc51c 100755
--- a/ms/blueprintsprocessor/modules/commons/pom.xml
+++ b/ms/blueprintsprocessor/modules/commons/pom.xml
@@ -33,6 +33,7 @@
<module>db-lib</module>
<module>rest-lib</module>
<module>core</module>
+ <module>dmaap-lib</module>
</modules>
<dependencies>
<dependency>
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
index 47577b39..705caa2e 100644
--- 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
@@ -17,15 +17,16 @@
package org.onap.ccsdk.apps.blueprintsprocessor.rest.service
+import com.fasterxml.jackson.databind.JsonNode
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.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.springframework.stereotype.Service
@Service(RestLibConstants.SERVICE_BLUEPRINT_REST_LIB_PROPERTY)
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) {
@@ -47,19 +48,39 @@ open class BluePrintRestLibPropertyService(private var bluePrintProperties: Blue
}
}
- @Throws(BluePrintProcessorException::class)
+ fun restClientProperties(jsonNode: JsonNode): RestClientProperties {
+ val type = jsonNode.get("type").textValue()
+ return when (type) {
+ RestLibConstants.TYPE_BASIC_AUTH -> {
+ JacksonUtils.readValue(jsonNode, BasicAuthRestClientProperties::class.java)!!
+ }
+ RestLibConstants.TYPE_SSL_BASIC_AUTH -> {
+ JacksonUtils.readValue(jsonNode, SSLBasicAuthRestClientProperties::class.java)!!
+ }
+ RestLibConstants.TYPE_DME2_PROXY -> {
+ JacksonUtils.readValue(jsonNode, DME2RestClientProperties::class.java)!!
+ }
+ RestLibConstants.TYPE_POLICY_MANAGER -> {
+ JacksonUtils.readValue(jsonNode, PolicyManagerRestClientProperties::class.java)!!
+ }
+ else -> {
+ throw BluePrintProcessorException("Rest adaptor($type) is not supported")
+ }
+ }
+ }
+
+
fun blueprintWebClientService(selector: String): BlueprintWebClientService {
val prefix = "blueprintsprocessor.restclient.$selector"
val restClientProperties = restClientProperties(prefix)
return blueprintWebClientService(restClientProperties)
}
-
- fun blueprintDynamicWebClientService(sourceType: String, selector: String): BlueprintWebClientService {
- TODO()
+ fun blueprintWebClientService(jsonNode: JsonNode): BlueprintWebClientService {
+ val restClientProperties = restClientProperties(jsonNode)
+ return blueprintWebClientService(restClientProperties)
}
- @Throws(BluePrintProcessorException::class)
fun blueprintWebClientService(restClientProperties: RestClientProperties): BlueprintWebClientService {
when (restClientProperties) {
is BasicAuthRestClientProperties -> {
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/pom.xml b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/pom.xml
index 4a305358..f538a152 100755
--- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/pom.xml
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/pom.xml
@@ -32,6 +32,12 @@
<description>Blueprints Processor Selfservice API</description>
<dependencies>
+
+ <dependency>
+ <groupId>org.springframework.security</groupId>
+ <artifactId>spring-security-core</artifactId>
+ </dependency>
+
<dependency>
<groupId>org.onap.ccsdk.apps.components</groupId>
<artifactId>proto-definition</artifactId>
@@ -39,10 +45,13 @@
</dependency>
<dependency>
<groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
- <version>${project.version}</version>
<artifactId>blueprint-core</artifactId>
</dependency>
<dependency>
+ <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
+ <artifactId>blueprint-validation</artifactId>
+ </dependency>
+ <dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-testing</artifactId>
</dependency>
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
index fb0bc567..d689187e 100644
--- 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
@@ -28,16 +28,18 @@ import org.onap.ccsdk.apps.controllerblueprints.management.api.BluePrintManageme
import org.onap.ccsdk.apps.controllerblueprints.management.api.BluePrintManagementOutput
import org.onap.ccsdk.apps.controllerblueprints.management.api.BluePrintManagementServiceGrpc
import org.slf4j.LoggerFactory
+import org.springframework.security.access.prepost.PreAuthorize
import org.springframework.stereotype.Service
import java.io.File
@Service
-class BluePrintManagementGRPCHandler(private val bluePrintCoreConfiguration: BluePrintCoreConfiguration,
+open class BluePrintManagementGRPCHandler(private val bluePrintCoreConfiguration: BluePrintCoreConfiguration,
private val bluePrintCatalogService: BluePrintCatalogService)
: BluePrintManagementServiceGrpc.BluePrintManagementServiceImplBase() {
private val log = LoggerFactory.getLogger(BluePrintManagementGRPCHandler::class.java)
+ @PreAuthorize("hasRole('USER')")
override fun uploadBlueprint(request: BluePrintManagementInput, responseObserver: StreamObserver<BluePrintManagementOutput>) {
val blueprintName = request.blueprintName
val blueprintVersion = request.blueprintVersion
@@ -61,6 +63,7 @@ class BluePrintManagementGRPCHandler(private val bluePrintCoreConfiguration: Blu
}
}
+ @PreAuthorize("hasRole('USER')")
override fun removeBlueprint(request: BluePrintManagementInput, responseObserver: StreamObserver<BluePrintManagementOutput>) {
val blueprintName = request.blueprintName
val blueprintVersion = request.blueprintVersion
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
index cf6776c5..aadbec83 100644
--- 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
@@ -23,22 +23,23 @@ import org.onap.ccsdk.apps.controllerblueprints.processing.api.BluePrintProcessi
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.security.access.prepost.PreAuthorize
import org.springframework.stereotype.Service
@Service
-class BluePrintProcessingGRPCHandler(private val bluePrintCoreConfiguration: BluePrintCoreConfiguration,
+open class BluePrintProcessingGRPCHandler(private val bluePrintCoreConfiguration: BluePrintCoreConfiguration,
private val executionServiceHandler: ExecutionServiceHandler)
: BluePrintProcessingServiceGrpc.BluePrintProcessingServiceImplBase() {
private val log = LoggerFactory.getLogger(BluePrintProcessingGRPCHandler::class.java)
+ @PreAuthorize("hasRole('USER')")
override fun process(
responseObserver: StreamObserver<ExecutionServiceOutput>): StreamObserver<ExecutionServiceInput> {
return object : StreamObserver<ExecutionServiceInput> {
override fun onNext(executionServiceInput: ExecutionServiceInput) {
try {
- val inputPayload = executionServiceInput.payload
- executionServiceHandler.process(executionServiceInput.toJava(), responseObserver, inputPayload)
+ executionServiceHandler.process(executionServiceInput.toJava(), responseObserver)
} catch (e: Exception) {
onError(e)
}
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt
index 6477c067..16f0fa86 100644
--- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceController.kt
@@ -23,6 +23,7 @@ import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceOut
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.http.MediaType
import org.springframework.http.codec.multipart.FilePart
+import org.springframework.security.access.prepost.PreAuthorize
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
@@ -34,7 +35,7 @@ import reactor.core.publisher.Mono
@RestController
@RequestMapping("/api/v1/execution-service")
-class ExecutionServiceController {
+open class ExecutionServiceController {
@Autowired
lateinit var executionServiceHandler: ExecutionServiceHandler
@@ -48,6 +49,7 @@ class ExecutionServiceController {
@PostMapping(path = ["/upload"], consumes = [MediaType.MULTIPART_FORM_DATA_VALUE])
@ApiOperation(value = "Upload CBA", notes = "Takes a File and load it in the runtime database")
@ResponseBody
+ @PreAuthorize("hasRole('USER')")
fun upload(@RequestPart("file") parts: Mono<FilePart>): Mono<String> {
return parts
.filter { it is FilePart }
@@ -59,6 +61,7 @@ class ExecutionServiceController {
@ApiOperation(value = "Resolve Resource Mappings",
notes = "Takes the blueprint information and process as per the payload")
@ResponseBody
+ @PreAuthorize("hasRole('USER')")
fun process(@RequestBody executionServiceInput: ExecutionServiceInput): ExecutionServiceOutput {
if (executionServiceInput.actionIdentifiers.mode == ACTION_MODE_ASYNC) {
throw IllegalStateException("Can't process async request through the REST endpoint. Use gRPC for async processing.")
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
index 262c33f9..5278c17e 100644
--- 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
@@ -16,7 +16,7 @@
package org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api
-import com.google.protobuf.Struct
+import com.fasterxml.jackson.databind.node.JsonNodeFactory
import io.grpc.stub.StreamObserver
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
@@ -30,6 +30,7 @@ import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.Status
import org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api.utils.saveCBAFile
import org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api.utils.toProto
import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.BlueprintDGExecutionService
+import org.onap.ccsdk.apps.controllerblueprints.common.api.EventType
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintCatalogService
@@ -60,25 +61,24 @@ class ExecutionServiceHandler(private val bluePrintCoreConfiguration: BluePrintC
}
fun process(executionServiceInput: ExecutionServiceInput,
- responseObserver: StreamObserver<org.onap.ccsdk.apps.controllerblueprints.processing.api.ExecutionServiceOutput>,
- inputPayload: Struct) {
+ responseObserver: StreamObserver<org.onap.ccsdk.apps.controllerblueprints.processing.api.ExecutionServiceOutput>) {
when {
executionServiceInput.actionIdentifiers.mode == ACTION_MODE_ASYNC -> {
GlobalScope.launch(Dispatchers.Default) {
val executionServiceOutput = doProcess(executionServiceInput)
- responseObserver.onNext(executionServiceOutput.toProto(inputPayload))
+ responseObserver.onNext(executionServiceOutput.toProto())
responseObserver.onCompleted()
}
- responseObserver.onNext(response(executionServiceInput).toProto(inputPayload))
+ responseObserver.onNext(response(executionServiceInput).toProto())
}
executionServiceInput.actionIdentifiers.mode == ACTION_MODE_SYNC -> {
val executionServiceOutput = doProcess(executionServiceInput)
- responseObserver.onNext(executionServiceOutput.toProto(inputPayload))
+ responseObserver.onNext(executionServiceOutput.toProto())
responseObserver.onCompleted()
}
else -> responseObserver.onNext(response(executionServiceInput,
"Failed to process request, 'actionIdentifiers.mode' not specified. Valid value are: 'sync' or 'async'.",
- true).toProto(inputPayload));
+ true).toProto());
}
}
@@ -108,16 +108,16 @@ class ExecutionServiceHandler(private val bluePrintCoreConfiguration: BluePrintC
val executionServiceOutput = ExecutionServiceOutput()
executionServiceOutput.commonHeader = executionServiceInput.commonHeader
executionServiceOutput.actionIdentifiers = executionServiceInput.actionIdentifiers
- executionServiceOutput.payload = executionServiceInput.payload
+ executionServiceOutput.payload = JsonNodeFactory.instance.objectNode()
val status = Status()
status.errorMessage = errorMessage
if (failure) {
- status.eventType = "EVENT-COMPONENT-FAILURE"
+ status.eventType = EventType.EVENT_COMPONENT_FAILURE.name
status.code = 500
status.message = BluePrintConstants.STATUS_FAILURE
} else {
- status.eventType = "EVENT-COMPONENT-PROCESSING"
+ status.eventType = EventType.EVENT_COMPONENT_PROCESSING.name
status.code = 200
status.message = BluePrintConstants.STATUS_PROCESSING
}
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/utils/BluePrintMappings.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/utils/BluePrintMappings.kt
index c8ce1c30..c344ca00 100644
--- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/utils/BluePrintMappings.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/utils/BluePrintMappings.kt
@@ -15,15 +15,16 @@
*/
package org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api.utils
-import com.fasterxml.jackson.databind.node.JsonNodeFactory
import com.fasterxml.jackson.databind.node.ObjectNode
import com.google.common.base.Strings
import com.google.protobuf.Struct
-import com.google.protobuf.Value
+import com.google.protobuf.util.JsonFormat
import org.onap.ccsdk.apps.controllerblueprints.common.api.ActionIdentifiers
import org.onap.ccsdk.apps.controllerblueprints.common.api.CommonHeader
+import org.onap.ccsdk.apps.controllerblueprints.common.api.EventType
import org.onap.ccsdk.apps.controllerblueprints.common.api.Flag
import org.onap.ccsdk.apps.controllerblueprints.common.api.Status
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.apps.controllerblueprints.processing.api.ExecutionServiceInput
import org.onap.ccsdk.apps.controllerblueprints.processing.api.ExecutionServiceOutput
import java.text.SimpleDateFormat
@@ -31,47 +32,6 @@ import java.util.*
private val formatter = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
-// STRUCT
-
-fun Struct.toJava(): ObjectNode {
- val objectNode = JsonNodeFactory.instance.objectNode()
- return getNode(objectNode)
-}
-
-fun Struct.getNode(objectNode: ObjectNode): ObjectNode {
- this.fieldsMap.forEach {
- when (it.value.kindCase.name) {
- "BOOL_VALUE" -> objectNode.put(it.key, it.value.boolValue)
- "KIND_NOT_SET" -> objectNode.put(it.key, it.value.toByteArray())
- "LIST_VALUE" -> {
- val arrayNode = JsonNodeFactory.instance.arrayNode()
- it.value.listValue.valuesList.forEach { arrayNode.addPOJO(it.getValue()) }
- objectNode.put(it.key, arrayNode)
- }
- "NULL_VALUE" -> objectNode.put(it.key, JsonNodeFactory.instance.nullNode())
- "NUMBER_VALUE" -> objectNode.put(it.key, it.value.numberValue)
- "STRING_VALUE" -> objectNode.put(it.key, it.value.stringValue)
- "STRUCT_VALUE" -> objectNode.put(it.key, it.value.structValue.getNode(JsonNodeFactory.instance.objectNode()))
- }
- }
- return objectNode
-}
-
-fun Value.getValue(): Any {
- return when (this.kindCase.name) {
- "BOOL_VALUE" -> this.boolValue
- "KIND_NOT_SET" -> this.toByteArray()
- "LIST_VALUE" -> listOf(this.listValue.valuesList.forEach { it.getValue() })
- "NULL_VALUE" -> JsonNodeFactory.instance.nullNode()
- "NUMBER_VALUE" -> this.numberValue
- "STRING_VALUE" -> this.stringValue
- "STRUCT_VALUE" -> this.structValue.getNode(JsonNodeFactory.instance.objectNode())
- else -> {
- "undefined"
- }
- }
-}
-
// ACTION IDENTIFIER
fun org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ActionIdentifiers.toProto(): ActionIdentifiers {
@@ -142,7 +102,7 @@ fun org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.Status.toProto(): Stat
status.errorMessage = this.errorMessage ?: ""
status.message = this.message
status.timestamp = this.timestamp.toString()
- status.eventType = this.eventType
+ status.eventType = EventType.valueOf(this.eventType)
return status.build()
}
@@ -152,17 +112,19 @@ fun ExecutionServiceInput.toJava(): org.onap.ccsdk.apps.blueprintsprocessor.core
val executionServiceInput = org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput()
executionServiceInput.actionIdentifiers = this.actionIdentifiers.toJava()
executionServiceInput.commonHeader = this.commonHeader.toJava()
- executionServiceInput.payload = this.payload.toJava()
+ executionServiceInput.payload = JacksonUtils.jsonNode(JsonFormat.printer().print(this.payload)) as ObjectNode
return executionServiceInput
}
// EXECUTION OUPUT
-fun org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceOutput.toProto(payload: Struct): ExecutionServiceOutput {
+fun org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceOutput.toProto(): ExecutionServiceOutput {
val executionServiceOuput = ExecutionServiceOutput.newBuilder()
executionServiceOuput.actionIdentifiers = this.actionIdentifiers.toProto()
executionServiceOuput.commonHeader = this.commonHeader.toProto()
executionServiceOuput.status = this.status.toProto()
- executionServiceOuput.payload = payload
+ val struct = Struct.newBuilder()
+ JsonFormat.parser().merge(JacksonUtils.getJson(this.payload), struct)
+ executionServiceOuput.payload = struct.build()
return executionServiceOuput.build()
} \ 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/validation/BluePrintDesignTimeRuntimeValidatorService.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/validation/BluePrintDesignTimeRuntimeValidatorService.kt
new file mode 100644
index 00000000..08d2c3b5
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/validation/BluePrintDesignTimeRuntimeValidatorService.kt
@@ -0,0 +1,38 @@
+/*
+ * Copyright © 2018 IBM.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api.validation
+
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+import org.onap.ccsdk.apps.controllerblueprints.validation.BluePrintDesignTimeValidatorService
+import org.springframework.stereotype.Service
+
+@Service
+open class BluePrintRuntimeValidatorService(
+ private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintDesignTimeValidatorService(bluePrintTypeValidatorService) {
+
+ override fun validateBluePrints(bluePrintRuntimeService: BluePrintRuntimeService<*>): Boolean {
+
+ bluePrintTypeValidatorService.validateServiceTemplate(bluePrintRuntimeService, "service_template",
+ bluePrintRuntimeService.bluePrintContext().serviceTemplate)
+ if (bluePrintRuntimeService.getBluePrintError().errors.size > 0) {
+ throw BluePrintException("failed in blueprint validation : ${bluePrintRuntimeService.getBluePrintError().errors.joinToString("\n")}")
+ }
+ return true
+ }
+} \ No newline at end of file
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
index de120148..b730472e 100644
--- 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
@@ -24,6 +24,7 @@ import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInp
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintCatalogService
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.boot.autoconfigure.security.SecurityProperties
import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest
import org.springframework.context.annotation.ComponentScan
import org.springframework.core.io.ByteArrayResource
@@ -39,7 +40,7 @@ import kotlin.test.assertTrue
@RunWith(SpringRunner::class)
@WebFluxTest
-@ContextConfiguration(classes = [ExecutionServiceHandler::class, BluePrintCoreConfiguration::class, BluePrintCatalogService::class])
+@ContextConfiguration(classes = [ExecutionServiceHandler::class, BluePrintCoreConfiguration::class, BluePrintCatalogService::class, SecurityProperties::class])
@ComponentScan(basePackages = ["org.onap.ccsdk.apps.blueprintsprocessor", "org.onap.ccsdk.apps.controllerblueprints"])
@TestPropertySource(locations = ["classpath:application-test.properties"])
class ExecutionServiceHandlerTest {
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/utils/BluePrintMappingTests.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/utils/BluePrintMappingTests.kt
index 2e4ba275..770e4a9b 100644
--- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/utils/BluePrintMappingTests.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/utils/BluePrintMappingTests.kt
@@ -1,17 +1,12 @@
package org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api.utils
-import com.fasterxml.jackson.databind.ObjectMapper
-import com.google.protobuf.ListValue
-import com.google.protobuf.NullValue
-import com.google.protobuf.Struct
-import com.google.protobuf.Value
-import com.google.protobuf.util.JsonFormat
import org.junit.Assert
import org.junit.Test
import org.junit.runner.RunWith
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.Flags
import org.onap.ccsdk.apps.controllerblueprints.common.api.ActionIdentifiers
import org.onap.ccsdk.apps.controllerblueprints.common.api.CommonHeader
+import org.onap.ccsdk.apps.controllerblueprints.common.api.EventType
import org.onap.ccsdk.apps.controllerblueprints.common.api.Flag
import org.springframework.test.context.junit4.SpringRunner
import java.text.SimpleDateFormat
@@ -53,7 +48,7 @@ class BluePrintMappingsTest {
val status = org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.Status()
status.code = 400
status.errorMessage = "Concurrent modification exception"
- status.eventType = "Update"
+ status.eventType = EventType.EVENT_COMPONENT_PROCESSING.name
status.message = "Error uploading data"
status.timestamp = dateForTest
return status
@@ -66,7 +61,7 @@ class BluePrintMappingsTest {
Assert.assertEquals(status.code, status2.code)
Assert.assertEquals(status.errorMessage, status2.errorMessage)
- Assert.assertEquals(status.eventType, status2.eventType)
+ Assert.assertEquals(status.eventType, status2.eventType.name)
Assert.assertEquals(status.message, status2.message)
Assert.assertEquals(status.timestamp.toString(), status2.timestamp)
}
@@ -134,39 +129,4 @@ class BluePrintMappingsTest {
Assert.assertEquals(actionIdentifiers.blueprintVersion, actionIdentifiers2.blueprintVersion)
Assert.assertEquals(actionIdentifiers.mode, actionIdentifiers2.mode)
}
-
- @Test
- fun testStructToJava() {
- val struct = Struct.newBuilder().putAllFields(createValues()).build()
- val struct2 = struct.toJava()
-
- val mapper = ObjectMapper()
-
- Assert.assertEquals(JsonFormat.printer().print(struct).replace(" ", "").replace("\r",""),
- mapper.writerWithDefaultPrettyPrinter().writeValueAsString(struct2).replace(" ", "").replace("\r",""))
- }
-
- fun createValues(): Map<String, Value> {
- val map = mutableMapOf<String, Value>()
-
- val boolValue = Value.newBuilder().setBoolValue(true).build()
- val stringValue = Value.newBuilder().setStringValue("string").build()
- val doubleValue = Value.newBuilder().setNumberValue(Double.MAX_VALUE).build()
- val jsonValue = Value.newBuilder().setStringValue("{\"bblah\": \"bbblo\"}").build()
- val listValue = Value.newBuilder().setListValue(ListValue.newBuilder().addValues(boolValue).addValues(boolValue).build()).build()
- val nullValue = Value.newBuilder().setNullValue(NullValue.NULL_VALUE).build()
-
- map.put("bool", boolValue)
- map.put("string", stringValue)
- map.put("doublbe", doubleValue)
- map.put("json", jsonValue)
- map.put("list", listValue)
- map.put("null", nullValue)
-
- val structValue = Value.newBuilder().setStructValue(Struct.newBuilder().putAllFields(map).build()).build()
-
- map.put("struct", structValue)
-
- return map
- }
} \ No newline at end of file
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
index a62d4bfb..90748240 100644
--- 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
Binary files differ
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/pom.xml b/ms/blueprintsprocessor/modules/services/execution-service/pom.xml
index 283a8a66..df68b952 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/pom.xml
+++ b/ms/blueprintsprocessor/modules/services/execution-service/pom.xml
@@ -15,7 +15,8 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
@@ -57,6 +58,10 @@
<groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
<artifactId>resource-dict</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.apps.components</groupId>
+ <artifactId>proto-definition</artifactId>
+ </dependency>
<dependency>
<groupId>org.onap.ccsdk.sli.core</groupId>
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt
index 930dc074..a67e006a 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt
@@ -23,12 +23,14 @@ import com.fasterxml.jackson.databind.node.JsonNodeFactory
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceOutput
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.Status
+import org.onap.ccsdk.apps.controllerblueprints.common.api.EventType
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.apps.controllerblueprints.core.asJsonNode
import org.onap.ccsdk.apps.controllerblueprints.core.getAsString
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BlueprintFunctionNode
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.slf4j.LoggerFactory
/**
@@ -100,7 +102,7 @@ abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServic
log.info("Preparing Response...")
executionServiceOutput.commonHeader = executionServiceInput.commonHeader
executionServiceOutput.actionIdentifiers = executionServiceInput.actionIdentifiers
- executionServiceOutput.payload = executionServiceInput.payload
+
// Resolve the Output Expression
val stepOutputs = bluePrintRuntimeService
@@ -108,9 +110,11 @@ abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServic
bluePrintRuntimeService.put("$stepName-step-outputs", stepOutputs.asJsonNode())
+ executionServiceOutput.payload = JacksonUtils.objectNodeFromObject(stepOutputs)
+
// Populate Status
val status = Status()
- status.eventType = "EVENT-COMPONENT-EXECUTED"
+ status.eventType = EventType.EVENT_COMPONENT_EXECUTED.name
status.code = 200
status.message = BluePrintConstants.STATUS_SUCCESS
executionServiceOutput.status = status
diff --git a/ms/blueprintsprocessor/parent/pom.xml b/ms/blueprintsprocessor/parent/pom.xml
index ab418f47..cad5a4b3 100755
--- a/ms/blueprintsprocessor/parent/pom.xml
+++ b/ms/blueprintsprocessor/parent/pom.xml
@@ -212,6 +212,11 @@
<artifactId>protobuf-java-util</artifactId>
<version>${protobuff.java.utils.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.apps.components</groupId>
+ <artifactId>proto-definition</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<!-- SLI Version -->
<dependency>
@@ -339,6 +344,11 @@
<artifactId>blueprint-scripts</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
+ <artifactId>blueprint-validation</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<!-- Database -->
<dependency>
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt
index d89e9547..e3545dff 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt
@@ -132,6 +132,7 @@ object BluePrintConstants {
const val MODEL_TYPE_CAPABILITY_TYPE_SSH = "tosca.capabilities.Ssh"
const val MODEL_TYPE_CAPABILITY_TYPE_SFTP = "tosca.capabilities.Sftp"
+ const val EXPRESSION_DSL_REFERENCE: String = "*"
const val EXPRESSION_GET_INPUT: String = "get_input"
const val EXPRESSION_GET_ATTRIBUTE: String = "get_attribute"
const val EXPRESSION_GET_ARTIFACT: String = "get_artifact"
@@ -158,7 +159,11 @@ object BluePrintConstants {
const val TOSCA_SCRIPTS_KOTLIN_DIR: String = "$TOSCA_SCRIPTS_DIR/kotlin"
const val TOSCA_SCRIPTS_JYTHON_DIR: String = "$TOSCA_SCRIPTS_DIR/python"
- const val METADATA_USER_GROUPS = "user-groups"
+ const val PROPERTY_ENV = "ENV"
+ const val PROPERTY_APP = "APP"
+ const val PROPERTY_BPP = "BPP"
+ const val PROPERTY_SELF = "SELF"
+
const val METADATA_TEMPLATE_NAME = "template_name"
const val METADATA_TEMPLATE_VERSION = "template_version"
const val METADATA_TEMPLATE_AUTHOR = "template_author"
@@ -173,11 +178,5 @@ object BluePrintConstants {
const val PROPERTY_CURRENT_IMPLEMENTATION = "current-implementation"
const val PROPERTY_EXECUTION_REQUEST = "execution-request"
- const val OPERATION_PROCESS = "process"
- const val OPERATION_PREPARE = "prepare"
-
- const val BLUEPRINT_RETRIEVE_TYPE_DB = "db"
- const val BLUEPRINT_RETRIEVE_TYPE_FILE = "file"
- const val BLUEPRINT_RETRIEVE_TYPE_REPO = "repo"
} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt
index 0889fddc..b2f1b727 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt
@@ -32,7 +32,6 @@ object BluePrintTypes {
BluePrintConstants.MODEL_TYPE_NODE_DG,
BluePrintConstants.MODEL_TYPE_NODE_COMPONENT,
BluePrintConstants.MODEL_TYPE_NODE_VNF,
- BluePrintConstants.MODEL_TYPE_NODE_ARTIFACT,
BluePrintConstants.MODEL_TYPE_NODE_RESOURCE_SOURCE,
BluePrintConstants.MODEL_TYPE_NODES_COMPONENT_JAVA,
BluePrintConstants.MODEL_TYPE_NODES_COMPONENT_BUNDLE,
@@ -54,7 +53,6 @@ object BluePrintTypes {
BluePrintConstants.MODEL_TYPE_DATA_TYPE_DYNAMIC
)
- @Deprecated("This has to move to Relationship Types Model Drive")
@JvmStatic
val validRelationShipDerivedFroms: MutableList<String> = arrayListOf(
BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_ROOT,
@@ -65,7 +63,6 @@ object BluePrintTypes {
BluePrintConstants.MODEL_TYPE_RELATIONSHIPS_ROUTES_TO
)
- @Deprecated("This has to move to Capability Types Model Drive")
@JvmStatic
val validCapabilityTypes: MutableList<String> = arrayListOf(
BluePrintConstants.MODEL_TYPE_CAPABILITIES_ROOT,
@@ -144,7 +141,8 @@ object BluePrintTypes {
@JvmStatic
fun validCommands(): List<String> {
- return listOf(BluePrintConstants.EXPRESSION_GET_INPUT,
+ return listOf(BluePrintConstants.EXPRESSION_DSL_REFERENCE,
+ BluePrintConstants.EXPRESSION_GET_INPUT,
BluePrintConstants.EXPRESSION_GET_ATTRIBUTE,
BluePrintConstants.EXPRESSION_GET_PROPERTY,
BluePrintConstants.EXPRESSION_GET_ARTIFACT,
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctions.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctions.kt
index 0b9c142b..7d98c42d 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctions.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctions.kt
@@ -17,10 +17,7 @@
package org.onap.ccsdk.apps.controllerblueprints.core
import com.fasterxml.jackson.databind.JsonNode
-import com.fasterxml.jackson.databind.node.BooleanNode
-import com.fasterxml.jackson.databind.node.DoubleNode
-import com.fasterxml.jackson.databind.node.IntNode
-import com.fasterxml.jackson.databind.node.TextNode
+import com.fasterxml.jackson.databind.node.*
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.slf4j.helpers.MessageFormatter
import java.io.File
@@ -76,6 +73,22 @@ fun <T : Any> MutableMap<String, *>.castValue(key: String, valueType: KClass<T>)
}
}
+/**
+ * Convert Json to map of json node, the root fields will be map keys
+ */
+fun JsonNode.rootFieldsToMap(): MutableMap<String, JsonNode> {
+ if (this is ObjectNode) {
+ val propertyMap: MutableMap<String, JsonNode> = hashMapOf()
+ this.fields().forEach {
+ propertyMap[it.key] = it.value
+ }
+ return propertyMap
+ } else {
+ throw BluePrintException("json node should be Object Node Type")
+ }
+}
+
+
fun MutableMap<String, JsonNode>.putJsonElement(key: String, value: Any) {
when (value) {
is JsonNode ->
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintExpressionData.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintExpressionData.kt
index 96f549db..6a8df801 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintExpressionData.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintExpressionData.kt
@@ -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.
@@ -13,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+@file:Suppress("unused")
package org.onap.ccsdk.apps.controllerblueprints.core.data
@@ -27,6 +29,7 @@ data class ExpressionData(
var isExpression: Boolean = false,
var valueNode: JsonNode,
var expressionNode: ObjectNode? = null,
+ var dslExpression: DSLExpression? = null,
var inputExpression: InputExpression? = null,
var propertyExpression: PropertyExpression? = null,
var attributeExpression: AttributeExpression? = null,
@@ -67,4 +70,8 @@ data class OperationOutputExpression(
val propertyName: String
)
+data class DSLExpression(
+ val propertyName: String
+)
+
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt
index c4376d5e..aab4e7c7 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/data/BluePrintModel.kt
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+@file:Suppress("unused")
package org.onap.ccsdk.apps.controllerblueprints.core.data
@@ -117,16 +118,13 @@ or Node Template and used by orchestration engine to facilitate deployment and i
class ArtifactDefinition {
@get:JsonIgnore
var id: String? = null
- var type: String? = null
- var file: String? = null
+ lateinit var type: String
+ lateinit var file: String
var repository: String? = null
var description: String? = null
@get:JsonProperty("deploy_Path")
var deployPath: String? = null
var properties: MutableMap<String, JsonNode>? = null
- var content: String? = null
- @Deprecated("Mapping content is define by the Type")
- var mappingContent: String? = null
}
@@ -582,7 +580,8 @@ class ConditionClause {
A TOSCA Service Template (YAML) document contains element definitions of building blocks for cloud application, or complete models of cloud applications. This section describes the top-level structural elements (TOSCA keynames) along with their grammars, which are allowed to appear in a TOSCA Service Template document.
*/
-@JsonPropertyOrder(value = ["toscaDefinitionsVersion", "description", "metadata", "imports", "topologyTemplate"])
+@JsonPropertyOrder(value = ["toscaDefinitionsVersion", "description", "metadata", "imports", "dsl_definitions",
+ "topologyTemplate"])
class ServiceTemplate : Cloneable {
@get:JsonIgnore
var id: String? = null
@@ -591,7 +590,7 @@ class ServiceTemplate : Cloneable {
var metadata: MutableMap<String, String>? = null
var description: String? = null
@get:JsonProperty("dsl_definitions")
- var dslDefinitions: MutableMap<String, Any>? = null
+ var dslDefinitions: MutableMap<String, JsonNode>? = null
var repositories: MutableMap<String, RepositoryDefinition>? = null
var imports: MutableList<ImportDefinition>? = null
@get:JsonProperty("artifact_types")
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintValidator.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintValidator.kt
index bea790fd..a485c677 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintValidator.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BlueprintValidator.kt
@@ -1,3 +1,20 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.onap.ccsdk.apps.controllerblueprints.core.interfaces
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
@@ -18,6 +35,8 @@ interface BluePrintTopologyTemplateValidator : BluePrintValidator<TopologyTempla
interface BluePrintArtifactTypeValidator : BluePrintValidator<ArtifactType>
+interface BluePrintArtifactDefinitionValidator : BluePrintValidator<ArtifactDefinition>
+
interface BluePrintDataTypeValidator : BluePrintValidator<DataType>
interface BluePrintNodeTypeValidator : BluePrintValidator<NodeType>
@@ -45,12 +64,20 @@ interface BluePrintValidatorService {
interface BluePrintTypeValidatorService {
+ fun <T : BluePrintValidator<*>> bluePrintValidator(referenceName: String, classType: Class<T>): T?
+
+ fun <T : BluePrintValidator<*>> bluePrintValidators(referenceNamePrefix: String, classType: Class<T>): List<T>?
+
+ fun <T : BluePrintValidator<*>> bluePrintValidators(classType: Class<T>): List<T>?
+
fun getServiceTemplateValidators(): List<BluePrintServiceTemplateValidator>
fun getDataTypeValidators(): List<BluePrintDataTypeValidator>
fun getArtifactTypeValidators(): List<BluePrintArtifactTypeValidator>
+ fun getArtifactDefinitionsValidators(): List<BluePrintArtifactDefinitionValidator>
+
fun getNodeTypeValidators(): List<BluePrintNodeTypeValidator>
fun getTopologyTemplateValidators(): List<BluePrintTopologyTemplateValidator>
@@ -73,6 +100,12 @@ interface BluePrintTypeValidatorService {
doValidation(bluePrintRuntimeService, name, artifactType, validators)
}
+ fun validateArtifactDefinition(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String,
+ artifactDefinition: ArtifactDefinition) {
+ val validators = getArtifactDefinitionsValidators()
+ doValidation(bluePrintRuntimeService, name, artifactDefinition, validators)
+ }
+
fun validateDataType(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, dataType: DataType) {
val validators = getDataTypeValidators()
doValidation(bluePrintRuntimeService, name, dataType, validators)
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt
index a0bf054b..e2211f7e 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt
@@ -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.
@@ -45,6 +46,8 @@ class BluePrintContext(val serviceTemplate: ServiceTemplate) {
val imports: List<ImportDefinition>? = serviceTemplate.imports
+ val dslDefinitions = serviceTemplate.dslDefinitions
+
val metadata: MutableMap<String, String>? = serviceTemplate.metadata
val dataTypes: MutableMap<String, DataType>? = serviceTemplate.dataTypes
@@ -95,6 +98,10 @@ class BluePrintContext(val serviceTemplate: ServiceTemplate) {
?: throw BluePrintException("could't get first callOperation for WorkFlow($workFlowName) ")
}
+ // DSL
+ fun dslPropertiesByName(name: String): JsonNode = dslDefinitions?.get(name)
+ ?: throw BluePrintException("could't get policy type for the dsl($name)")
+
// Data Type
fun dataTypeByName(name: String): DataType? = dataTypes?.get(name)
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionService.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionService.kt
index caa02dbc..f23659ce 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionService.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionService.kt
@@ -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.
@@ -21,6 +22,7 @@ import com.att.eelf.configuration.EELFManager
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.node.ArrayNode
import com.fasterxml.jackson.databind.node.ObjectNode
+import com.fasterxml.jackson.databind.node.TextNode
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes
@@ -35,11 +37,20 @@ object BluePrintExpressionService {
val log: EELFLogger = EELFManager.getInstance().getLogger(this::class.toString())
@JvmStatic
+ fun checkContainsExpression(propertyAssignmentNode: JsonNode): Boolean {
+ val json = propertyAssignmentNode.toString()
+ // FIXME("Check if any Optimisation needed")
+ return (json.contains(BluePrintConstants.EXPRESSION_GET_INPUT)
+ || json.contains(BluePrintConstants.EXPRESSION_GET_ATTRIBUTE)
+ || json.contains(BluePrintConstants.EXPRESSION_GET_PROPERTY))
+
+ }
+
+ @JvmStatic
fun getExpressionData(propertyAssignmentNode: JsonNode): ExpressionData {
log.trace("Assignment Data/Expression : {}", propertyAssignmentNode)
val expressionData = ExpressionData(valueNode = propertyAssignmentNode)
if (propertyAssignmentNode is ObjectNode) {
-
val commands: Set<String> = propertyAssignmentNode.fieldNames().asSequence().toList().intersect(BluePrintTypes.validCommands())
if (commands.isNotEmpty()) {
expressionData.isExpression = true
@@ -64,11 +75,22 @@ object BluePrintExpressionService {
}
}
}
+ } else if (propertyAssignmentNode is TextNode
+ && propertyAssignmentNode.textValue().startsWith(BluePrintConstants.EXPRESSION_DSL_REFERENCE)) {
+ expressionData.isExpression = true
+ expressionData.command = BluePrintConstants.EXPRESSION_DSL_REFERENCE
+ expressionData.dslExpression = populateDSLExpression(propertyAssignmentNode)
}
return expressionData
}
@JvmStatic
+ fun populateDSLExpression(jsonNode: TextNode): DSLExpression {
+ return DSLExpression(propertyName = jsonNode.textValue()
+ .removePrefix(BluePrintConstants.EXPRESSION_DSL_REFERENCE))
+ }
+
+ @JvmStatic
fun populateInputExpression(jsonNode: JsonNode): InputExpression {
return InputExpression(propertyName = jsonNode.first().textValue())
}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt
index 5c10f80c..80ad3f2a 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeService.kt
@@ -24,13 +24,13 @@ import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.node.NullNode
import com.fasterxml.jackson.databind.node.ObjectNode
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintError
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.apps.controllerblueprints.core.*
import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactDefinition
import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeTemplate
import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
+import java.io.File
interface BluePrintRuntimeService<T> {
@@ -62,6 +62,8 @@ interface BluePrintRuntimeService<T> {
fun setBluePrintError(bluePrintError: BluePrintError)
+ fun loadEnvironments(type: String, fileName: String)
+
fun resolveNodeTemplatePropertyAssignments(nodeTemplateName: String,
propertyDefinitions: MutableMap<String, PropertyDefinition>,
propertyAssignments: MutableMap<String, JsonNode>): MutableMap<String, JsonNode>
@@ -81,6 +83,8 @@ interface BluePrintRuntimeService<T> {
fun resolveNodeTemplateArtifactDefinition(nodeTemplateName: String, artifactName: String): ArtifactDefinition
+ fun resolveDSLExpression(dslPropertyName: String): JsonNode
+
fun setInputValue(propertyName: String, propertyDefinition: PropertyDefinition, value: JsonNode)
fun setWorkflowInputValue(workflowName: String, propertyName: String, propertyDefinition: PropertyDefinition, value: JsonNode)
@@ -129,6 +133,16 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
private var bluePrintError = BluePrintError()
+ init {
+ /**
+ * Load Blueprint Environments Properties
+ */
+ val absoluteEnvFilePath = bluePrintContext.rootPath.plus(File.separator)
+ .plus(BluePrintConstants.TOSCA_ENVIRONMENTS_DIR)
+ loadEnvironments(BluePrintConstants.PROPERTY_BPP, absoluteEnvFilePath)
+
+ }
+
override fun id(): String {
return id
}
@@ -190,6 +204,13 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
this.bluePrintError = bluePrintError
}
+ override fun loadEnvironments(type: String, fileName: String) {
+ BluePrintMetadataUtils.environmentFileProperties(fileName).forEach { key, value ->
+ setNodeTemplateAttributeValue(type, key.toString(), value.toString()
+ .asJsonPrimitive())
+ }
+ }
+
/**
* Resolve any property assignments for the node
*/
@@ -328,6 +349,28 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
}
+ /**
+ * Read the DSL Property reference, If there is any expression, then resolve those expression and return as Json
+ * Type
+ */
+ override fun resolveDSLExpression(dslPropertyName: String): JsonNode {
+ val propertyAssignments = bluePrintContext.dslPropertiesByName(dslPropertyName)
+ return if (BluePrintExpressionService.checkContainsExpression(propertyAssignments)
+ && propertyAssignments is ObjectNode) {
+
+ val rootKeyMap = propertyAssignments.rootFieldsToMap()
+ val propertyAssignmentValue: MutableMap<String, JsonNode> = hashMapOf()
+ rootKeyMap.forEach { propertyName, propertyValue ->
+ val propertyAssignmentExpression = PropertyAssignmentService(this)
+ propertyAssignmentValue[propertyName] = propertyAssignmentExpression
+ .resolveAssignmentExpression("DSL", propertyName, propertyValue)
+ }
+ propertyAssignmentValue.asJsonNode()
+ } else {
+ propertyAssignments
+ }
+ }
+
override fun setInputValue(propertyName: String, propertyDefinition: PropertyDefinition, value: JsonNode) {
val path = StringBuilder(BluePrintConstants.PATH_INPUTS)
.append(BluePrintConstants.PATH_DIVIDER).append(propertyName).toString()
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt
index cb75e2c2..7905b8fb 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt
@@ -24,6 +24,7 @@ import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.node.NullNode
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.apps.controllerblueprints.core.asJsonPrimitive
import org.onap.ccsdk.apps.controllerblueprints.core.data.*
import org.onap.ccsdk.apps.controllerblueprints.core.format
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
@@ -84,6 +85,9 @@ If Property Assignment is Expression.
BluePrintConstants.EXPRESSION_GET_ARTIFACT -> {
valueNode = resolveArtifactExpression(nodeTemplateName, expressionData.artifactExpression!!)
}
+ BluePrintConstants.EXPRESSION_DSL_REFERENCE -> {
+ valueNode = bluePrintRuntimeService.resolveDSLExpression(expressionData.dslExpression!!.propertyName)
+ }
BluePrintConstants.EXPRESSION_GET_NODE_OF_TYPE -> {
}
@@ -106,13 +110,27 @@ If Property Assignment is Expression.
val subAttributeName: String? = attributeExpression.subAttributeName
var attributeNodeTemplateName = nodeTemplateName
+ /**
+ * Attributes are dynamic runtime properties information. There are multiple types of Attributes,
+ * ENV : Environment Variables
+ * APP : Application properties ( ie Spring resolved properties )
+ * BPP : Blueprint Properties, Specific to Blue Print execution.
+ * SELF : Current Node Template properties.
+ */
when (attributeExpression.modelableEntityName) {
- "ENV" -> {
+ BluePrintConstants.PROPERTY_ENV -> {
val environmentValue = System.getProperty(attributeName)
- valueNode = JacksonUtils.jsonNode(environmentValue)
+ valueNode = environmentValue.asJsonPrimitive()
+ }
+ BluePrintConstants.PROPERTY_APP -> {
+ TODO("Get property from application properties")
+ }
+ BluePrintConstants.PROPERTY_BPP -> {
+ valueNode = bluePrintRuntimeService.getNodeTemplateAttributeValue(BluePrintConstants.PROPERTY_BPP, attributeName)
+ ?: throw BluePrintException("failed to get env attribute name ($attributeName) ")
}
else -> {
- if (!attributeExpression.modelableEntityName.equals("SELF", true)) {
+ if (!attributeExpression.modelableEntityName.equals(BluePrintConstants.PROPERTY_SELF, true)) {
attributeNodeTemplateName = attributeExpression.modelableEntityName
}
@@ -143,7 +161,8 @@ If Property Assignment is Expression.
val subPropertyName: String? = propertyExpression.subPropertyName
var propertyNodeTemplateName = nodeTemplateName
- if (!propertyExpression.modelableEntityName.equals("SELF", true)) {
+
+ if (!propertyExpression.modelableEntityName.equals(BluePrintConstants.PROPERTY_SELF, true)) {
propertyNodeTemplateName = propertyExpression.modelableEntityName
}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt
index 7764bc19..fa5e1647 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtils.kt
@@ -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.
@@ -30,6 +31,7 @@ import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeSer
import org.onap.ccsdk.apps.controllerblueprints.core.service.DefaultBluePrintRuntimeService
import java.io.File
import java.nio.charset.Charset
+import java.util.*
class BluePrintMetadataUtils {
companion object {
@@ -48,6 +50,27 @@ class BluePrintMetadataUtils {
return toscaMetaDataFromMetaFile(toscaMetaPath).entityDefinitions
}
+ fun bluePrintEnvProperties(basePath: String): Properties {
+ val blueprintsEnvFilePath = basePath.plus(File.separator)
+ .plus(BluePrintConstants.TOSCA_ENVIRONMENTS_DIR)
+ return environmentFileProperties(blueprintsEnvFilePath)
+ }
+
+ fun environmentFileProperties(pathName: String): Properties {
+ val properties = Properties()
+ val envDir = File(pathName)
+ // Verify if the environment directory exists
+ if (envDir.exists() && envDir.isDirectory) {
+ //Find all available environment files
+ envDir.listFiles()
+ .filter { it.name.endsWith(".properties") }
+ .forEach {
+ properties.load(it.inputStream())
+ }
+ }
+ return properties
+ }
+
fun toscaMetaDataFromMetaFile(metaFilePath: String): ToscaMetaData {
val toscaMetaData = ToscaMetaData()
val lines: MutableList<String> = FileUtils.readLines(File(metaFilePath), Charset.defaultCharset())
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt
index 9bf9d13c..1bc25005 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt
@@ -19,7 +19,6 @@ package org.onap.ccsdk.apps.controllerblueprints.core.utils
import com.att.eelf.configuration.EELFLogger
import com.att.eelf.configuration.EELFManager
import com.fasterxml.jackson.annotation.JsonInclude
-import com.fasterxml.jackson.core.type.TypeReference
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.SerializationFeature
import com.fasterxml.jackson.databind.node.ArrayNode
@@ -98,6 +97,10 @@ class JacksonUtils {
return readValue(content, valueType)
}
+ fun objectNodeFromObject(from: kotlin.Any): ObjectNode {
+ return jacksonObjectMapper().convertValue(from, ObjectNode::class.java)
+ }
+
fun jsonNodeFromObject(from: kotlin.Any): JsonNode {
return jacksonObjectMapper().convertValue(from, JsonNode::class.java)
}
@@ -144,22 +147,22 @@ class JacksonUtils {
return objectMapper.valueToTree(any)
}
- fun <T> getListFromJsonNode(node: JsonNode, valueType: Class<T>): List<T>? {
+ fun <T> getListFromJsonNode(node: JsonNode, valueType: Class<T>): List<T> {
return getListFromJson(node.toString(), valueType)
}
- fun <T> getListFromJson(content: String, valueType: Class<T>): List<T>? {
+ fun <T> getListFromJson(content: String, valueType: Class<T>): List<T> {
val objectMapper = jacksonObjectMapper()
val javaType = objectMapper.typeFactory.constructCollectionType(List::class.java, valueType)
return objectMapper.readValue<List<T>>(content, javaType)
}
- fun <T> getListFromFile(fileName: String, valueType: Class<T>): List<T>? {
+ fun <T> getListFromFile(fileName: String, valueType: Class<T>): List<T> {
val content: String = getContent(fileName)
return getListFromJson(content, valueType)
}
- fun <T> getListFromClassPathFile(fileName: String, valueType: Class<T>): List<T>? {
+ fun <T> getListFromClassPathFile(fileName: String, valueType: Class<T>): List<T> {
val content: String = getClassPathFileContent(fileName)
return getListFromJson(content, valueType)
}
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionServiceTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionServiceTest.kt
index d68892fc..58910055 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionServiceTest.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintExpressionServiceTest.kt
@@ -1,5 +1,6 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,9 +20,11 @@ package org.onap.ccsdk.apps.controllerblueprints.core.service
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import org.junit.Test
+import org.onap.ccsdk.apps.controllerblueprints.core.asJsonPrimitive
import org.onap.ccsdk.apps.controllerblueprints.core.data.ExpressionData
import kotlin.test.assertEquals
import kotlin.test.assertNotNull
+
/**
*
*
@@ -30,8 +33,8 @@ import kotlin.test.assertNotNull
class BluePrintExpressionServiceTest {
@Test
fun testInputExpression() {
- val node : JsonNode = jacksonObjectMapper().readTree("{ \"get_input\" : \"input-name\" }")
- val expressionData : ExpressionData = BluePrintExpressionService.getExpressionData(node)
+ val node: JsonNode = jacksonObjectMapper().readTree("{ \"get_input\" : \"input-name\" }")
+ val expressionData: ExpressionData = BluePrintExpressionService.getExpressionData(node)
assertNotNull(expressionData, " Failed to populate expression data")
assertEquals(expressionData.isExpression, true, "Failed to identify as expression")
assertNotNull(expressionData.inputExpression, " Failed to populate input expression data")
@@ -40,49 +43,49 @@ class BluePrintExpressionServiceTest {
@Test
fun testPropertyExpression() {
- val node : JsonNode = jacksonObjectMapper().readTree("{ \"get_property\" : [\"SELF\", \"property-name\"] }")
- val expressionData : ExpressionData = BluePrintExpressionService.getExpressionData(node)
+ val node: JsonNode = jacksonObjectMapper().readTree("{ \"get_property\" : [\"SELF\", \"property-name\"] }")
+ val expressionData: ExpressionData = BluePrintExpressionService.getExpressionData(node)
assertNotNull(expressionData, " Failed to populate expression data")
assertEquals(expressionData.isExpression, true, "Failed to identify as expression")
assertNotNull(expressionData.propertyExpression, " Failed to populate property expression data")
assertEquals("SELF", expressionData.propertyExpression?.modelableEntityName, " Failed to get expected modelableEntityName")
assertEquals("property-name", expressionData.propertyExpression?.propertyName, " Failed to get expected propertyName")
- val node1 : JsonNode = jacksonObjectMapper().readTree("{ \"get_property\" : [\"SELF\", \"\",\"property-name\", \"resource\", \"name\"] }")
- val expressionData1 : ExpressionData = BluePrintExpressionService.getExpressionData(node1)
+ val node1: JsonNode = jacksonObjectMapper().readTree("{ \"get_property\" : [\"SELF\", \"\",\"property-name\", \"resource\", \"name\"] }")
+ val expressionData1: ExpressionData = BluePrintExpressionService.getExpressionData(node1)
assertNotNull(expressionData1, " Failed to populate expression data")
assertEquals(expressionData1.isExpression, true, "Failed to identify as nested property expression")
assertNotNull(expressionData1.propertyExpression, " Failed to populate nested property expression data")
assertEquals("SELF", expressionData1.propertyExpression?.modelableEntityName, " Failed to get expected modelableEntityName")
assertEquals("property-name", expressionData1.propertyExpression?.propertyName, " Failed to get expected propertyName")
- assertEquals("resource/name",expressionData1.propertyExpression?.subPropertyName, " Failed to populate nested subPropertyName expression data")
+ assertEquals("resource/name", expressionData1.propertyExpression?.subPropertyName, " Failed to populate nested subPropertyName expression data")
}
@Test
fun testAttributeExpression() {
- val node : JsonNode = jacksonObjectMapper().readTree("{ \"get_attribute\" : [\"SELF\", \"resource\"] }")
- val expressionData : ExpressionData = BluePrintExpressionService.getExpressionData(node)
+ val node: JsonNode = jacksonObjectMapper().readTree("{ \"get_attribute\" : [\"SELF\", \"resource\"] }")
+ val expressionData: ExpressionData = BluePrintExpressionService.getExpressionData(node)
assertNotNull(expressionData, " Failed to populate expression data")
assertEquals(expressionData.isExpression, true, "Failed to identify as expression")
assertNotNull(expressionData.attributeExpression, " Failed to populate attribute expression data")
assertEquals("SELF", expressionData.attributeExpression?.modelableEntityName, " Failed to get expected modelableEntityName")
assertEquals("resource", expressionData.attributeExpression?.attributeName, " Failed to get expected attributeName")
- val node1 : JsonNode = jacksonObjectMapper().readTree("{ \"get_attribute\" : [\"SELF\", \"\",\"attribute-name\", \"resource\", \"name\"] }")
- val expressionData1 : ExpressionData = BluePrintExpressionService.getExpressionData(node1)
+ val node1: JsonNode = jacksonObjectMapper().readTree("{ \"get_attribute\" : [\"SELF\", \"\",\"attribute-name\", \"resource\", \"name\"] }")
+ val expressionData1: ExpressionData = BluePrintExpressionService.getExpressionData(node1)
assertNotNull(expressionData1, " Failed to populate expression data")
assertEquals(expressionData1.isExpression, true, "Failed to identify as expression")
assertNotNull(expressionData1.attributeExpression, " Failed to populate attribute expression data")
assertEquals("SELF", expressionData1.attributeExpression?.modelableEntityName, " Failed to get expected modelableEntityName")
assertEquals("attribute-name", expressionData1.attributeExpression?.attributeName, " Failed to get expected attributeName")
- assertEquals("resource/name",expressionData1.attributeExpression?.subAttributeName, " Failed to populate nested subAttributeName expression data")
+ assertEquals("resource/name", expressionData1.attributeExpression?.subAttributeName, " Failed to populate nested subAttributeName expression data")
}
@Test
fun testOutputOperationExpression() {
- val node : JsonNode = jacksonObjectMapper().readTree("{ \"get_operation_output\": [\"SELF\", \"interface-name\", \"operation-name\", \"output-property-name\"] }")
- val expressionData : ExpressionData = BluePrintExpressionService.getExpressionData(node)
+ val node: JsonNode = jacksonObjectMapper().readTree("{ \"get_operation_output\": [\"SELF\", \"interface-name\", \"operation-name\", \"output-property-name\"] }")
+ val expressionData: ExpressionData = BluePrintExpressionService.getExpressionData(node)
assertNotNull(expressionData, " Failed to populate expression data")
assertEquals(expressionData.isExpression, true, "Failed to identify as expression")
assertNotNull(expressionData.operationOutputExpression, " Failed to populate output expression data")
@@ -95,8 +98,8 @@ class BluePrintExpressionServiceTest {
@Test
fun testArtifactExpression() {
- val node : JsonNode = jacksonObjectMapper().readTree("{ \"get_artifact\" : [\"SELF\", \"artifact-template\"] }")
- val expressionData : ExpressionData = BluePrintExpressionService.getExpressionData(node)
+ val node: JsonNode = jacksonObjectMapper().readTree("{ \"get_artifact\" : [\"SELF\", \"artifact-template\"] }")
+ val expressionData: ExpressionData = BluePrintExpressionService.getExpressionData(node)
assertNotNull(expressionData, " Failed to populate expression data")
assertEquals(expressionData.isExpression, true, "Failed to identify as expression")
assertNotNull(expressionData.artifactExpression, " Failed to populate Artifact expression data")
@@ -104,8 +107,8 @@ class BluePrintExpressionServiceTest {
assertEquals("artifact-template", expressionData.artifactExpression?.artifactName, " Failed to get expected artifactName")
- val node1 : JsonNode = jacksonObjectMapper().readTree("{ \"get_artifact\" : [\"SELF\", \"artifact-template\", \"location\", true] }")
- val expressionData1 : ExpressionData = BluePrintExpressionService.getExpressionData(node1)
+ val node1: JsonNode = jacksonObjectMapper().readTree("{ \"get_artifact\" : [\"SELF\", \"artifact-template\", \"location\", true] }")
+ val expressionData1: ExpressionData = BluePrintExpressionService.getExpressionData(node1)
assertNotNull(expressionData1, " Failed to populate expression data")
assertEquals(expressionData1.isExpression, true, "Failed to identify as expression")
assertNotNull(expressionData1.artifactExpression, " Failed to populate Artifact expression data")
@@ -114,4 +117,15 @@ class BluePrintExpressionServiceTest {
assertEquals("location", expressionData1.artifactExpression?.location, " Failed to get expected location")
assertEquals(true, expressionData1.artifactExpression?.remove, " Failed to get expected remove")
}
+
+ @Test
+ fun testDSLExpression() {
+ val node: JsonNode = "*dynamic-rest-source".asJsonPrimitive()
+ val expressionData: ExpressionData = BluePrintExpressionService.getExpressionData(node)
+ assertNotNull(expressionData, " Failed to populate expression data")
+ assertEquals(expressionData.isExpression, true, "Failed to identify as expression")
+ assertNotNull(expressionData.dslExpression, " Failed to populate dsl expression data")
+ assertEquals("dynamic-rest-source", expressionData.dslExpression!!.propertyName,
+ " Failed to populate dsl property name")
+ }
} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt
index 92e9247a..c0bfd0f5 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt
@@ -24,6 +24,7 @@ import com.fasterxml.jackson.databind.node.NullNode
import org.junit.Test
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.asJsonPrimitive
+import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition
import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintRuntimeUtils
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
@@ -139,6 +140,19 @@ class BluePrintRuntimeServiceTest {
}
+ @Test
+ fun `test Resolve DSL Properties`() {
+ log.info("************************ resolveDSLExpression **********************")
+
+ val bluePrintRuntimeService = getBluePrintRuntimeService()
+
+ bluePrintRuntimeService.setInputValue("rest-user-name", PropertyDefinition(), "sample-username"
+ .asJsonPrimitive())
+
+ val resolvedJsonNode: JsonNode = bluePrintRuntimeService.resolveDSLExpression("dynamic-rest-source")
+ assertNotNull(resolvedJsonNode, "Failed to populate dsl property values")
+ }
+
private fun getBluePrintRuntimeService(): BluePrintRuntimeService<MutableMap<String, JsonNode>> {
val blueprintBasePath: String = ("./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
val blueprintRuntime = BluePrintMetadataUtils.getBluePrintRuntime("1234", blueprintBasePath)
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt
index 599bb3be..366ce4a8 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/BluePrintMetadataUtilsTest.kt
@@ -20,16 +20,18 @@ package org.onap.ccsdk.apps.controllerblueprints.core.utils
import org.junit.Test
import org.onap.ccsdk.apps.controllerblueprints.core.data.ToscaMetaData
+import kotlin.test.assertEquals
import kotlin.test.assertNotNull
+import kotlin.test.assertNull
class BluePrintMetadataUtilsTest {
-
+
@Test
- fun testToscaMetaData(){
+ fun testToscaMetaData() {
- val basePath : String = "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ val basePath: String = "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
- val toscaMetaData : ToscaMetaData = BluePrintMetadataUtils.toscaMetaData(basePath)
+ val toscaMetaData: ToscaMetaData = BluePrintMetadataUtils.toscaMetaData(basePath)
assertNotNull(toscaMetaData, "Missing Tosca Definition Object")
assertNotNull(toscaMetaData.toscaMetaFileVersion, "Missing Tosca Metadata Version")
assertNotNull(toscaMetaData.csarVersion, "Missing CSAR version")
@@ -38,4 +40,18 @@ class BluePrintMetadataUtilsTest {
assertNotNull(toscaMetaData.templateTags, "Missing Template Tags")
}
+
+ @Test
+ fun environmentDataTest() {
+ val environmentPath = "./src/test/resources/environments"
+
+ val properties = BluePrintMetadataUtils.bluePrintEnvProperties(environmentPath)
+
+ assertNotNull(properties, "Could not read the properties")
+ assertEquals(properties.getProperty("blueprintsprocessor.database.alt1.username"), "username1", "failed 1")
+ assertEquals(properties.getProperty("blueprintsprocessor.database.alt1.password"), "password1", "failed 2")
+ assertEquals(properties.getProperty("blueprintsprocessor.database.alt2.username"), "username2", "failed 3")
+ assertEquals(properties.getProperty("blueprintsprocessor.database.alt2.password"), "password2", "failed 4")
+ assertNull(properties.getProperty("blueprintsprocessor.database.alt3.password"), "failed 5")
+ }
} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/environments/Environments/environment1.properties b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/environments/Environments/environment1.properties
new file mode 100644
index 00000000..d735087b
--- /dev/null
+++ b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/environments/Environments/environment1.properties
@@ -0,0 +1,2 @@
+blueprintsprocessor.database.alt1.username=username1
+blueprintsprocessor.database.alt1.password=password1 \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/environments/Environments/environment2.properties b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/environments/Environments/environment2.properties
new file mode 100644
index 00000000..5530a8f8
--- /dev/null
+++ b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/environments/Environments/environment2.properties
@@ -0,0 +1,2 @@
+blueprintsprocessor.database.alt2.username=username2
+blueprintsprocessor.database.alt2.password=password2 \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintArtifactDefinitionValidatorImpl.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintArtifactDefinitionValidatorImpl.kt
new file mode 100644
index 00000000..4ea5ab5b
--- /dev/null
+++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintArtifactDefinitionValidatorImpl.kt
@@ -0,0 +1,97 @@
+/*
+ * Copyright © 2018 IBM.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.validation
+
+import com.att.eelf.configuration.EELFLogger
+import com.att.eelf.configuration.EELFManager
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes
+import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactDefinition
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintArtifactDefinitionValidator
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
+import org.springframework.stereotype.Service
+import java.io.File
+
+@Service("default-artifact-definition-validator")
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+open class BluePrintArtifactDefinitionValidatorImpl(
+ private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintArtifactDefinitionValidator {
+
+ private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintArtifactDefinitionValidatorImpl::class.toString())
+
+ lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
+ lateinit var bluePrintContext: BluePrintContext
+ var paths: MutableList<String> = arrayListOf()
+
+ override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String,
+ artifactDefinition: ArtifactDefinition) {
+
+ this.bluePrintRuntimeService = bluePrintRuntimeService
+ this.bluePrintContext = bluePrintRuntimeService.bluePrintContext()
+
+ paths.add(name)
+ val type: String = artifactDefinition.type
+ log.info("Validation ArtifactDefinition of type {$type}")
+ // Check Artifact Type
+ checkValidArtifactType(name, type)
+
+ val file: String = artifactDefinition.file
+
+ val completePath = bluePrintContext.rootPath.plus(File.separator).plus(file)
+
+ check(File(completePath).exists()) {
+ throw BluePrintException("couldn't file ($completePath)")
+ }
+
+ // Perform Extension Validation
+ validateExtension("$type-artifact-definition-validator", name, artifactDefinition)
+
+ paths.removeAt(paths.lastIndex)
+ }
+
+ open fun checkValidArtifactType(artifactDefinitionName: String, artifactTypeName: String) {
+
+ val artifactType = bluePrintContext.serviceTemplate.artifactTypes?.get(artifactTypeName)
+ ?: throw BluePrintException("failed to get artifactType($artifactTypeName) for ArtifactDefinition($artifactDefinitionName)")
+
+ checkValidArtifactTypeDerivedFrom(artifactTypeName, artifactType.derivedFrom)
+ }
+
+ @Throws(BluePrintException::class)
+ open fun checkValidArtifactTypeDerivedFrom(artifactTypeName: String, derivedFrom: String) {
+ check(BluePrintTypes.validArtifactTypeDerivedFroms.contains(derivedFrom)) {
+ throw BluePrintException("failed to get artifactType($artifactTypeName)'s derivedFrom($derivedFrom) definition")
+ }
+ }
+
+ private fun validateExtension(referencePrefix: String, name: String, artifactDefinition: ArtifactDefinition) {
+
+ val customValidators = bluePrintTypeValidatorService
+ .bluePrintValidators(referencePrefix, BluePrintArtifactDefinitionValidator::class.java)
+
+ customValidators?.let {
+ it.forEach { validator ->
+ validator.validate(bluePrintRuntimeService, name, artifactDefinition)
+ }
+
+ }
+ }
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintArtifactTypeValidatorImpl.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintArtifactTypeValidatorImpl.kt
index b893c77d..4824d2e9 100644
--- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintArtifactTypeValidatorImpl.kt
+++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintArtifactTypeValidatorImpl.kt
@@ -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.
@@ -20,7 +21,9 @@ import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactType
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintArtifactTypeValidator
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+import org.springframework.stereotype.Service
+@Service("default-artifact-type-validator")
open class BluePrintArtifactTypeValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintArtifactTypeValidator {
override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, artifactType: ArtifactType) {
@@ -28,6 +31,5 @@ open class BluePrintArtifactTypeValidatorImpl(private val bluePrintTypeValidator
artifactType.properties?.let {
bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintRuntimeService, artifactType.properties!!)
}
- // TODO ("Files Present ")
}
} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintAttributeDefinitionValidatorImpl.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintAttributeDefinitionValidatorImpl.kt
index 19e8f0bf..11dbf058 100644
--- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintAttributeDefinitionValidatorImpl.kt
+++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintAttributeDefinitionValidatorImpl.kt
@@ -1,5 +1,6 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,14 +17,72 @@
package org.onap.ccsdk.apps.controllerblueprints.validation
+import com.att.eelf.configuration.EELFLogger
+import com.att.eelf.configuration.EELFManager
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes
import org.onap.ccsdk.apps.controllerblueprints.core.data.AttributeDefinition
+import org.onap.ccsdk.apps.controllerblueprints.core.format
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintAttributeDefinitionValidator
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
+import org.springframework.stereotype.Service
+@Service("default-attribute-definition-validator")
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
open class BluePrintAttributeDefinitionValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintAttributeDefinitionValidator {
- override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, type: AttributeDefinition) {
- //TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+
+ private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString())
+
+ lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
+
+
+ override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String,
+ attributeDefinition: AttributeDefinition) {
+
+ log.trace("Validating AttributeDefinition($name)")
+ this.bluePrintRuntimeService = bluePrintRuntimeService
+ val dataType: String = attributeDefinition.type
+
+ when {
+ BluePrintTypes.validPrimitiveTypes().contains(dataType) -> {
+ // Do Nothing
+ }
+ BluePrintTypes.validCollectionTypes().contains(dataType) -> {
+ val entrySchemaType: String = attributeDefinition.entrySchema?.type
+ ?: throw BluePrintException("Entry schema for DataType ($dataType) for the property ($name) not found")
+ checkPrimitiveOrComplex(entrySchemaType, name)
+ }
+ else -> checkPropertyDataType(dataType, name)
+ }
+ }
+
+ private fun checkPrimitiveOrComplex(dataType: String, propertyName: String): Boolean {
+ if (BluePrintTypes.validPrimitiveTypes().contains(dataType) || checkDataType(dataType)) {
+ return true
+ } else {
+ throw BluePrintException("DataType($dataType) for the attribute($propertyName) is not valid")
+ }
+ }
+
+ private fun checkPropertyDataType(dataTypeName: String, propertyName: String) {
+
+ val dataType = bluePrintRuntimeService.bluePrintContext().serviceTemplate.dataTypes?.get(dataTypeName)
+ ?: throw BluePrintException(format("DataType ({}) for the property ({}) not found", dataTypeName, propertyName))
+
+ checkValidDataTypeDerivedFrom(propertyName, dataType.derivedFrom)
+ }
+
+ private fun checkDataType(key: String): Boolean {
+ return bluePrintRuntimeService.bluePrintContext().serviceTemplate.dataTypes?.containsKey(key) ?: false
+ }
+
+ open fun checkValidDataTypeDerivedFrom(dataTypeName: String, derivedFrom: String) {
+ check(BluePrintTypes.validDataTypeDerivedFroms.contains(derivedFrom)) {
+ throw BluePrintException("Failed to get DataType($dataTypeName)'s derivedFrom($derivedFrom) definition ")
+ }
}
} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintDataTypeValidatorImpl.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintDataTypeValidatorImpl.kt
index 6ee41774..1494bbc4 100644
--- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintDataTypeValidatorImpl.kt
+++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintDataTypeValidatorImpl.kt
@@ -1,5 +1,6 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,19 +17,16 @@
package org.onap.ccsdk.apps.controllerblueprints.validation
-import com.att.eelf.configuration.EELFLogger
-import com.att.eelf.configuration.EELFManager
import org.onap.ccsdk.apps.controllerblueprints.core.data.DataType
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintDataTypeValidator
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+import org.springframework.stereotype.Service
+@Service("default-data-type-validator")
open class BluePrintDataTypeValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintDataTypeValidator {
- private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintDataTypeValidatorImpl::class.toString())
override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, dataType: DataType) {
- log.trace("Validating DataType($name)")
-
dataType.properties?.let {
bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintRuntimeService, dataType.properties!!)
diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintValidatorServiceImpl.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintDesignTimeValidatorService.kt
index 5620cb77..84073ff2 100644
--- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintValidatorServiceImpl.kt
+++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintDesignTimeValidatorService.kt
@@ -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.
@@ -23,12 +24,14 @@ import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeVal
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintValidatorService
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
+import org.springframework.stereotype.Service
import java.util.*
-open class BluePrintValidatorServiceImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintValidatorService {
+@Service
+open class BluePrintDesignTimeValidatorService(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintValidatorService {
- private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintValidatorServiceImpl::class.toString())
+ private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintDesignTimeValidatorService::class.toString())
override fun validateBluePrints(basePath: String): Boolean {
diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintNodeTemplateValidatorImpl.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintNodeTemplateValidatorImpl.kt
index af0f88aa..ded1f384 100644
--- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintNodeTemplateValidatorImpl.kt
+++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintNodeTemplateValidatorImpl.kt
@@ -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.
@@ -29,8 +30,13 @@ import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintExpressionService
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
+import org.springframework.stereotype.Service
+@Service("default-node-template-validator")
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintNodeTemplateValidator {
private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintNodeTemplateValidatorImpl::class.toString())
@@ -39,25 +45,28 @@ open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidator
lateinit var bluePrintContext: BluePrintContext
var paths: MutableList<String> = arrayListOf()
- override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String, nodeTemplate: NodeTemplate) {
- log.info("Validating NodeTemplate($nodeTemplateName)")
+ override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String, nodeTemplate: NodeTemplate) {
+ log.info("Validating NodeTemplate($name)")
this.bluePrintRuntimeService = bluePrintRuntimeService
this.bluePrintContext = bluePrintRuntimeService.bluePrintContext()
- paths.add(nodeTemplateName)
+ paths.add(name)
val type: String = nodeTemplate.type
val nodeType: NodeType = bluePrintContext.serviceTemplate.nodeTypes?.get(type)
- ?: throw BluePrintException("Failed to get NodeType($type) definition for NodeTemplate($nodeTemplateName)")
+ ?: throw BluePrintException("Failed to get NodeType($type) definition for NodeTemplate($name)")
nodeTemplate.properties?.let { validatePropertyAssignments(nodeType.properties!!, nodeTemplate.properties!!) }
- nodeTemplate.capabilities?.let { validateCapabilityAssignments(nodeType, nodeTemplateName, nodeTemplate) }
- nodeTemplate.requirements?.let { validateRequirementAssignments(nodeType, nodeTemplateName, nodeTemplate) }
- nodeTemplate.interfaces?.let { validateInterfaceAssignments(nodeType, nodeTemplateName, nodeTemplate) }
+ nodeTemplate.capabilities?.let { validateCapabilityAssignments(nodeType, name, nodeTemplate) }
+ nodeTemplate.requirements?.let { validateRequirementAssignments(nodeType, name, nodeTemplate) }
+ nodeTemplate.interfaces?.let { validateInterfaceAssignments(nodeType, name, nodeTemplate) }
nodeTemplate.artifacts?.let { validateArtifactDefinitions(nodeTemplate.artifacts!!) }
+ // Perform Extension Validation
+ validateExtension("$type-node-template-validator", name, nodeTemplate)
+
paths.removeAt(paths.lastIndex)
}
@@ -65,16 +74,8 @@ open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidator
open fun validateArtifactDefinitions(artifacts: MutableMap<String, ArtifactDefinition>) {
paths.add("artifacts")
artifacts.forEach { artifactDefinitionName, artifactDefinition ->
- paths.add(artifactDefinitionName)
- val type: String = artifactDefinition.type
- ?: throw BluePrintException("type is missing for ArtifactDefinition$artifactDefinitionName)")
- // Check Artifact Type
- checkValidArtifactType(artifactDefinitionName, type)
-
- val file: String = artifactDefinition.file
- ?: throw BluePrintException("file is missing for ArtifactDefinition($artifactDefinitionName)")
-
- paths.removeAt(paths.lastIndex)
+ bluePrintTypeValidatorService.validateArtifactDefinition(bluePrintRuntimeService,
+ artifactDefinitionName, artifactDefinition)
}
paths.removeAt(paths.lastIndex)
}
@@ -239,21 +240,6 @@ open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidator
}
- open fun checkValidArtifactType(artifactDefinitionName: String, artifactTypeName: String) {
-
- val artifactType = bluePrintContext.serviceTemplate.artifactTypes?.get(artifactTypeName)
- ?: throw BluePrintException("failed to get artifactType($artifactTypeName) for ArtifactDefinition($artifactDefinitionName)")
-
- checkValidArtifactTypeDerivedFrom(artifactTypeName, artifactType.derivedFrom)
- }
-
- @Throws(BluePrintException::class)
- open fun checkValidArtifactTypeDerivedFrom(artifactTypeName: String, derivedFrom: String) {
- check(BluePrintTypes.validArtifactTypeDerivedFroms.contains(derivedFrom)) {
- throw BluePrintException("failed to get artifactType($artifactTypeName)'s derivedFrom($derivedFrom) definition")
- }
- }
-
open fun checkPropertyValue(propertyName: String, propertyDefinition: PropertyDefinition, propertyAssignment: JsonNode) {
val propertyType = propertyDefinition.type
val isValid: Boolean
@@ -295,4 +281,13 @@ open class BluePrintNodeTemplateValidatorImpl(private val bluePrintTypeValidator
}
}
+ private fun validateExtension(referencePrefix: String, name: String, nodeTemplate: NodeTemplate) {
+ val customValidator = bluePrintTypeValidatorService
+ .bluePrintValidator(referencePrefix, BluePrintNodeTemplateValidator::class.java)
+
+ customValidator?.let {
+ it.validate(bluePrintRuntimeService, name, nodeTemplate)
+ }
+ }
+
} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintNodeTypeValidatorImpl.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintNodeTypeValidatorImpl.kt
index eb2f0102..1108c1b5 100644
--- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintNodeTypeValidatorImpl.kt
+++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintNodeTypeValidatorImpl.kt
@@ -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.
@@ -26,8 +27,13 @@ import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintNodeTyp
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
+import org.springframework.stereotype.Service
+@Service("default-node-type-validator")
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
open class BluePrintNodeTypeValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintNodeTypeValidator {
private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString())
@@ -52,7 +58,14 @@ open class BluePrintNodeTypeValidatorImpl(private val bluePrintTypeValidatorServ
?: throw BluePrintException("Failed to get derivedFrom NodeType($derivedFrom)'s for NodeType($nodeTypeName)")
}
- nodeType.properties?.let { bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintRuntimeService, nodeType.properties!!) }
+ nodeType.attributes?.let {
+ bluePrintTypeValidatorService.validateAttributeDefinitions(bluePrintRuntimeService, nodeType.attributes!!)
+ }
+
+ nodeType.properties?.let {
+ bluePrintTypeValidatorService.validatePropertyDefinitions(bluePrintRuntimeService, nodeType.properties!!)
+ }
+
nodeType.capabilities?.let { validateCapabilityDefinitions(nodeTypeName, nodeType) }
nodeType.requirements?.let { validateRequirementDefinitions(nodeTypeName, nodeType) }
nodeType.interfaces?.let { validateInterfaceDefinitions(nodeType.interfaces!!) }
diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintPropertyDefinitionValidatorImpl.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintPropertyDefinitionValidatorImpl.kt
index 2f328716..7d81ba62 100644
--- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintPropertyDefinitionValidatorImpl.kt
+++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintPropertyDefinitionValidatorImpl.kt
@@ -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.
@@ -25,7 +26,12 @@ import org.onap.ccsdk.apps.controllerblueprints.core.format
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintPropertyDefinitionValidator
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
+import org.springframework.stereotype.Service
+@Service("default-property-definition-validator")
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
open class BluePrintPropertyDefinitionValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintPropertyDefinitionValidator {
private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString())
diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintServiceTemplateValidatorImpl.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintServiceTemplateValidatorImpl.kt
index 8d49f291..37d3d1bd 100644
--- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintServiceTemplateValidatorImpl.kt
+++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintServiceTemplateValidatorImpl.kt
@@ -26,7 +26,12 @@ import org.onap.ccsdk.apps.controllerblueprints.core.data.*
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintServiceTemplateValidator
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
+import org.springframework.stereotype.Service
+@Service("default-service-template-validator")
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
open class BluePrintServiceTemplateValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintServiceTemplateValidator {
private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString())
diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintTopologyTemplateValidatorImpl.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintTopologyTemplateValidatorImpl.kt
index 9f9ad1fa..841d86ea 100644
--- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintTopologyTemplateValidatorImpl.kt
+++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintTopologyTemplateValidatorImpl.kt
@@ -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.
@@ -26,7 +27,12 @@ import org.onap.ccsdk.apps.controllerblueprints.core.data.Workflow
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTopologyTemplateValidator
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
+import org.springframework.stereotype.Service
+@Service("default-topology-template-validator")
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
open class BluePrintTopologyTemplateValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintTopologyTemplateValidator {
private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString())
diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintTypeValidatorServiceImpl.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintTypeValidatorServiceImpl.kt
index e9bfc613..d8c008ff 100644
--- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintTypeValidatorServiceImpl.kt
+++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintTypeValidatorServiceImpl.kt
@@ -1,5 +1,6 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,6 +17,7 @@
package org.onap.ccsdk.apps.controllerblueprints.validation
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.*
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.context.ApplicationContext
@@ -24,43 +26,79 @@ import org.springframework.stereotype.Service
@Service
class BluePrintTypeValidatorServiceImpl : BluePrintTypeValidatorService {
+ companion object {
+ const val PREFIX_DEFAULT = "default"
+ }
+
@Autowired
private lateinit var context: ApplicationContext
+ override fun <T : BluePrintValidator<*>> bluePrintValidator(referenceName: String, classType: Class<T>): T? {
+ return if (context.containsBean(referenceName)) {
+ context.getBean(referenceName, classType)
+ } else {
+ null
+ }
+ }
+
+ override fun <T : BluePrintValidator<*>> bluePrintValidators(referenceNamePrefix: String, classType: Class<T>): List<T>? {
+ return context.getBeansOfType(classType)
+ .filter { it.key.startsWith(referenceNamePrefix) }
+ .mapNotNull { it.value }
+ }
+
+ override fun <T : BluePrintValidator<*>> bluePrintValidators(classType: Class<T>): List<T>? {
+ return context.getBeansOfType(classType).mapNotNull { it.value }
+ }
+
override fun getServiceTemplateValidators(): List<BluePrintServiceTemplateValidator> {
- return context.getBeansOfType(BluePrintServiceTemplateValidator::class.java).mapNotNull { it.value }
+ return bluePrintValidators(PREFIX_DEFAULT, BluePrintServiceTemplateValidator::class.java)
+ ?: throw BluePrintProcessorException("failed to get default ServiceTemplate validators")
}
override fun getDataTypeValidators(): List<BluePrintDataTypeValidator> {
- return context.getBeansOfType(BluePrintDataTypeValidator::class.java).mapNotNull { it.value }
+ return bluePrintValidators(PREFIX_DEFAULT, BluePrintDataTypeValidator::class.java)
+ ?: throw BluePrintProcessorException("failed to get default DataType validators")
}
override fun getArtifactTypeValidators(): List<BluePrintArtifactTypeValidator> {
- return context.getBeansOfType(BluePrintArtifactTypeValidator::class.java).mapNotNull { it.value }
+ return bluePrintValidators(PREFIX_DEFAULT, BluePrintArtifactTypeValidator::class.java)
+ ?: throw BluePrintProcessorException("failed to get default ArtifactType validators")
+ }
+
+ override fun getArtifactDefinitionsValidators(): List<BluePrintArtifactDefinitionValidator> {
+ return bluePrintValidators(PREFIX_DEFAULT, BluePrintArtifactDefinitionValidator::class.java)
+ ?: throw BluePrintProcessorException("failed to get default ArtifactDefinition validators")
}
override fun getNodeTypeValidators(): List<BluePrintNodeTypeValidator> {
- return context.getBeansOfType(BluePrintNodeTypeValidator::class.java).mapNotNull { it.value }
+ return bluePrintValidators(PREFIX_DEFAULT, BluePrintNodeTypeValidator::class.java)
+ ?: throw BluePrintProcessorException("failed to get default NodeType validators")
}
override fun getTopologyTemplateValidators(): List<BluePrintTopologyTemplateValidator> {
- return context.getBeansOfType(BluePrintTopologyTemplateValidator::class.java).mapNotNull { it.value }
+ return bluePrintValidators(PREFIX_DEFAULT, BluePrintTopologyTemplateValidator::class.java)
+ ?: throw BluePrintProcessorException("failed to get default TopologyTemplate validators")
}
override fun getNodeTemplateValidators(): List<BluePrintNodeTemplateValidator> {
- return context.getBeansOfType(BluePrintNodeTemplateValidator::class.java).mapNotNull { it.value }
+ return bluePrintValidators(PREFIX_DEFAULT, BluePrintNodeTemplateValidator::class.java)
+ ?: throw BluePrintProcessorException("failed to get default NodeTemplate validators")
}
override fun getWorkflowValidators(): List<BluePrintWorkflowValidator> {
- return context.getBeansOfType(BluePrintWorkflowValidator::class.java).mapNotNull { it.value }
+ return bluePrintValidators(PREFIX_DEFAULT, BluePrintWorkflowValidator::class.java)
+ ?: throw BluePrintProcessorException("failed to get default Workflow validators")
}
override fun getPropertyDefinitionValidators(): List<BluePrintPropertyDefinitionValidator> {
- return context.getBeansOfType(BluePrintPropertyDefinitionValidator::class.java).mapNotNull { it.value }
+ return bluePrintValidators(PREFIX_DEFAULT, BluePrintPropertyDefinitionValidator::class.java)
+ ?: throw BluePrintProcessorException("failed to get default PropertyDefinition validators")
}
override fun getAttributeDefinitionValidators(): List<BluePrintAttributeDefinitionValidator> {
- return context.getBeansOfType(BluePrintAttributeDefinitionValidator::class.java).mapNotNull { it.value }
+ return bluePrintValidators(PREFIX_DEFAULT, BluePrintAttributeDefinitionValidator::class.java)
+ ?: throw BluePrintProcessorException("failed to get default AttributeDefinition validators")
}
}
diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintValidatorDefaultService.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintValidatorDefaultService.kt
deleted file mode 100644
index 8e26588b..00000000
--- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintValidatorDefaultService.kt
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-@file:Suppress("unused")
-package org.onap.ccsdk.apps.controllerblueprints.validation
-
-import com.att.eelf.configuration.EELFLogger
-import com.att.eelf.configuration.EELFManager
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
-import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
-import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintValidatorService
-import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
-import org.springframework.stereotype.Service
-import java.util.*
-
-@Service
-class BluePrintTypeValidatorDefaultService(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService)
- : BluePrintValidatorService {
-
- private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintValidatorServiceImpl::class.toString())
-
- override fun validateBluePrints(basePath: String): Boolean {
-
- log.info("validating blueprint($basePath)")
- val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(UUID.randomUUID().toString(), basePath)
- return validateBluePrints(bluePrintRuntimeService)
- }
-
- override fun validateBluePrints(bluePrintRuntimeService: BluePrintRuntimeService<*>): Boolean {
-
- bluePrintTypeValidatorService.validateServiceTemplate(bluePrintRuntimeService, "service_template",
- bluePrintRuntimeService.bluePrintContext().serviceTemplate)
-
- if (bluePrintRuntimeService.getBluePrintError().errors.size > 0) {
- throw BluePrintException("failed in blueprint validation : ${bluePrintRuntimeService.getBluePrintError().errors.joinToString("\n")}")
- }
- return true
- }
-}
-
-// Core Validator Services
-
-@Service
-class DefaultBluePrintServiceTemplateValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService)
- : BluePrintServiceTemplateValidatorImpl(bluePrintTypeValidatorService)
-
-@Service
-class DefaultBluePrintDataTypeValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService)
- : BluePrintDataTypeValidatorImpl(bluePrintTypeValidatorService)
-
-@Service
-class DefaultBluePrintArtifactTypeValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService)
- : BluePrintArtifactTypeValidatorImpl(bluePrintTypeValidatorService)
-
-@Service
-class DefaultBluePrintNodeTypeValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService)
- : BluePrintNodeTypeValidatorImpl(bluePrintTypeValidatorService)
-
-@Service
-class DefaultBluePrintTopologyTemplateValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService)
- : BluePrintTopologyTemplateValidatorImpl(bluePrintTypeValidatorService)
-
-@Service
-class DefaulBluePrintNodeTemplateValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService)
- : BluePrintNodeTemplateValidatorImpl(bluePrintTypeValidatorService)
-
-@Service
-class DefaultBluePrintWorkflowValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService)
- : BluePrintWorkflowValidatorImpl(bluePrintTypeValidatorService)
-
-@Service
-class DefaultBluePrintPropertyDefinitionValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService)
- : BluePrintPropertyDefinitionValidatorImpl(bluePrintTypeValidatorService)
-
-@Service
-class DefaultBluePrintAttributeDefinitionValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService)
- : BluePrintAttributeDefinitionValidatorImpl(bluePrintTypeValidatorService) \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintWorkflowValidatorImpl.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintWorkflowValidatorImpl.kt
index 612ec691..851a7c60 100644
--- a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintWorkflowValidatorImpl.kt
+++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintWorkflowValidatorImpl.kt
@@ -23,7 +23,12 @@ import org.onap.ccsdk.apps.controllerblueprints.core.data.Workflow
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintWorkflowValidator
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
+import org.springframework.stereotype.Service
+@Service("default-workflow-validator")
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
open class BluePrintWorkflowValidatorImpl(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) : BluePrintWorkflowValidator {
private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintServiceTemplateValidatorImpl::class.toString())
diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/extension/ArtifactMappingResourceValidator.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/extension/ArtifactMappingResourceValidator.kt
new file mode 100644
index 00000000..6fe4fa36
--- /dev/null
+++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/extension/ArtifactMappingResourceValidator.kt
@@ -0,0 +1,48 @@
+/*
+ * Copyright © 2018 IBM.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.validation.extension
+
+import com.att.eelf.configuration.EELFLogger
+import com.att.eelf.configuration.EELFManager
+import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactDefinition
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintArtifactDefinitionValidator
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceAssignmentValidationServiceImpl
+import org.springframework.stereotype.Service
+import java.io.File
+
+@Service("artifact-mapping-resource-artifact-definition-validator")
+open class ArtifactMappingResourceValidator(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService)
+ : BluePrintArtifactDefinitionValidator {
+
+ private val log: EELFLogger = EELFManager.getInstance().getLogger(ArtifactMappingResourceValidator::class.toString())
+
+ override fun validate(bluePrintRuntimeService: BluePrintRuntimeService<*>, name: String,
+ artifactDefinition: ArtifactDefinition) {
+
+ val bluePrintContext = bluePrintRuntimeService.bluePrintContext()
+ val file: String = artifactDefinition.file
+ val completePath = bluePrintContext.rootPath.plus(File.separator).plus(file)
+ log.info("Validation artifact-mapping-resource($completePath)")
+ val resourceAssignment = JacksonUtils.getListFromFile(completePath, ResourceAssignment::class.java)
+ val resourceAssignmentValidationService = ResourceAssignmentValidationServiceImpl()
+ resourceAssignmentValidationService.validate(resourceAssignment)
+ }
+} \ No newline at end of file
diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintValidatorServiceImplTest.kt b/ms/controllerblueprints/modules/blueprint-validation/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintDesignTimeValidatorServiceTest.kt
index f5d157dd..43c3e0e3 100644
--- a/ms/controllerblueprints/modules/blueprint-validation/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintValidatorServiceImplTest.kt
+++ b/ms/controllerblueprints/modules/blueprint-validation/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/BluePrintDesignTimeValidatorServiceTest.kt
@@ -30,12 +30,12 @@ import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtil
import kotlin.test.assertEquals
import kotlin.test.assertTrue
-class BluePrintValidatorServiceImplTest {
+class BluePrintDesignTimeValidatorServiceTest {
private val blueprintBasePath: String = ("./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
private val bluePrintRuntime = BluePrintMetadataUtils.getBluePrintRuntime("1234", blueprintBasePath)
private val mockBluePrintTypeValidatorService = MockBluePrintTypeValidatorService()
- private val defaultBluePrintValidatorService = BluePrintValidatorServiceImpl(mockBluePrintTypeValidatorService)
+ private val defaultBluePrintValidatorService = BluePrintDesignTimeValidatorService(mockBluePrintTypeValidatorService)
private val workflowValidator = BluePrintWorkflowValidatorImpl(mockBluePrintTypeValidatorService)
@Test
diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/MockBluePrintTypeValidatorService.kt b/ms/controllerblueprints/modules/blueprint-validation/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/MockBluePrintTypeValidatorService.kt
index 971099ca..65574c22 100644
--- a/ms/controllerblueprints/modules/blueprint-validation/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/MockBluePrintTypeValidatorService.kt
+++ b/ms/controllerblueprints/modules/blueprint-validation/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/validation/MockBluePrintTypeValidatorService.kt
@@ -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.
@@ -20,6 +21,18 @@ import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.*
class MockBluePrintTypeValidatorService : BluePrintTypeValidatorService {
+ override fun <T : BluePrintValidator<*>> bluePrintValidator(referenceName: String, classType: Class<T>): T? {
+ return null
+ }
+
+ override fun <T : BluePrintValidator<*>> bluePrintValidators(referenceNamePrefix: String, classType: Class<T>): List<T>? {
+ return null
+ }
+
+ override fun <T : BluePrintValidator<*>> bluePrintValidators(classType: Class<T>): List<T>? {
+ return null
+ }
+
override fun getServiceTemplateValidators(): List<BluePrintServiceTemplateValidator> {
return listOf(BluePrintServiceTemplateValidatorImpl(this))
}
@@ -32,6 +45,10 @@ class MockBluePrintTypeValidatorService : BluePrintTypeValidatorService {
return listOf(BluePrintArtifactTypeValidatorImpl(this))
}
+ override fun getArtifactDefinitionsValidators(): List<BluePrintArtifactDefinitionValidator> {
+ return listOf(BluePrintArtifactDefinitionValidatorImpl(this))
+ }
+
override fun getNodeTypeValidators(): List<BluePrintNodeTypeValidator> {
return listOf(BluePrintNodeTypeValidatorImpl(this))
}
diff --git a/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImplTest.kt b/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImplTest.kt
index 8d32413f..ccacee02 100644
--- a/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImplTest.kt
+++ b/ms/controllerblueprints/modules/service/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImplTest.kt
@@ -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.
@@ -38,22 +39,22 @@ import java.nio.file.Paths
class BluePrintEnhancerServiceImplTest {
@Autowired
- private val modelTypeLoadService: ModelTypeLoadService? = null
+ lateinit var modelTypeLoadService: ModelTypeLoadService
@Autowired
- private val resourceDictionaryLoadService: ResourceDictionaryLoadService? = null
+ lateinit var resourceDictionaryLoadService: ResourceDictionaryLoadService
@Autowired
- private val bluePrintEnhancerService: BluePrintEnhancerService? = null
+ lateinit var bluePrintEnhancerService: BluePrintEnhancerService
@Autowired
- private val bluePrintValidatorService: BluePrintValidatorService? = null
+ lateinit var bluePrintValidatorService: BluePrintValidatorService
@Before
fun init() {
runBlocking {
- modelTypeLoadService!!.loadPathModelType("./../../../../components/model-catalog/definition-type/starter-type")
- resourceDictionaryLoadService!!.loadPathResourceDictionary("./../../../../components/model-catalog/resource-dictionary/starter-dictionary")
+ modelTypeLoadService.loadPathModelType("./../../../../components/model-catalog/definition-type/starter-type")
+ resourceDictionaryLoadService.loadPathResourceDictionary("./../../../../components/model-catalog/resource-dictionary/starter-dictionary")
}
}
@@ -65,11 +66,11 @@ class BluePrintEnhancerServiceImplTest {
val targetPath = Paths.get("target", "bp-enhance").toUri().path
- val bluePrintContext = bluePrintEnhancerService!!.enhance(basePath, targetPath)
+ val bluePrintContext = bluePrintEnhancerService.enhance(basePath, targetPath)
Assert.assertNotNull("failed to get blueprintContext ", bluePrintContext)
// Validate the Generated BluePrints
- val valid = bluePrintValidatorService!!.validateBluePrints(targetPath)
+ val valid = bluePrintValidatorService.validateBluePrints(targetPath)
Assert.assertTrue("blueprint validation failed ", valid)
}
} \ No newline at end of file