From 032ce4ec7c3d7ac138555dfe980ca53ebbf39f01 Mon Sep 17 00:00:00 2001 From: "Singal, Kapil (ks220y)" Date: Thu, 30 Jan 2020 11:23:57 -0500 Subject: Removing blueprints-processor Blueprints-Processor is deprecated, use CCSDK/CDS instead Change-Id: I0abc96061c3c5edc6c5d02bcd6f35e18e31882a7 Issue-ID: CCSDK-2051 Signed-off-by: Singal, Kapil (ks220y) --- blueprints-processor/.gitignore | 30 - .../adaptors/data-adaptor-provider/pom.xml | 119 ---- .../data/adaptor/ConfigDataAdaptorException.java | 50 -- .../data/adaptor/DataAdaptorConstants.java | 76 --- .../data/adaptor/dao/ConfigResourceDao.java | 58 -- .../data/adaptor/dao/ConfigResourceDaoImpl.java | 415 ------------- .../data/adaptor/dao/NamedQueryExecutorDao.java | 57 -- .../adaptor/dao/NamedQueryExecutorDaoImpl.java | 56 -- .../data/adaptor/dao/QueryExecutorDao.java | 54 -- .../data/adaptor/dao/QueryExecutorDaoImpl.java | 53 -- .../data/adaptor/dao/TransactionLogDao.java | 61 -- .../data/adaptor/dao/TransactionLogDaoImpl.java | 90 --- .../features/data/adaptor/db/DataSourceWrap.java | 91 --- .../data/adaptor/domain/ConfigResource.java | 171 ------ .../adaptor/domain/ResourceAssignmentData.java | 157 ----- .../data/adaptor/domain/TransactionLog.java | 98 ---- .../data/adaptor/service/ConfigResourceNode.java | 61 -- .../adaptor/service/ConfigResourceService.java | 143 ----- .../adaptor/service/ConfigResourceServiceImpl.java | 104 ---- .../OSGI-INF/blueprint/impl-blueprint.xml | 70 --- .../org/opendaylight/blueprint/impl-blueprint.xml | 70 --- .../src/main/resources/sql/001_init_ddl.sql | 96 ---- .../data/adaptor/dao/ConfigResourceDaoTest.java | 125 ---- .../adaptor/dao/ConfigTransactionLogDaoTest.java | 79 --- .../data/adaptor/dao/QueryExecutorDaoTest.java | 81 --- .../adaptor/service/ConfigResourceNodeTest.java | 82 --- .../adaptor/service/ConfigResourceServiceTest.java | 188 ------ .../src/test/resources/log4j.properties | 21 - .../test/resources/mappings/service-mapping.json | 11 - .../test/resources/reference/resource_data.json | 3 - .../src/test/resources/sql/schema.sql | 42 -- .../src/test/resources/test-context-h2db.xml | 70 --- .../src/test/resources/test-context.xml | 91 --- blueprints-processor/adaptors/pom.xml | 40 -- .../adaptors/rest-adaptor-provider/pom.xml | 146 ----- .../rest/adaptor/ConfigRestAdaptorConstants.java | 1 - .../rest/adaptor/ConfigRestAdaptorException.java | 50 -- .../features/rest/adaptor/data/RestResponse.java | 76 --- .../service/AbstractConfigRestClientAdapter.java | 274 --------- .../adaptor/service/ConfigRestAdaptorService.java | 92 --- .../service/ConfigRestAdaptorServiceImpl.java | 164 ------ .../service/ConfigRestClientServiceAdapter.java | 38 -- .../service/GenericRestClientAdapterImpl.java | 139 ----- .../adaptor/service/SSLRestClientAdapterImpl.java | 130 ----- .../utils/BasicAuthorizationInterceptor.java | 56 -- .../adaptor/utils/LoggingRequestInterceptor.java | 71 --- .../OSGI-INF/blueprint/impl-blueprint.xml | 32 -- .../blueprints-processor-adaptor.properties | 35 -- .../org/opendaylight/blueprint/impl-blueprint.xml | 32 -- .../AbstractConfigRestClientAdapterTest.java | 56 -- .../service/GenericRestClientServiceTest.java | 118 ---- .../rest/adaptor/service/SSLClientServiceTest.java | 118 ---- .../adaptor/utils/RestTemplateFactoryTest.java | 49 -- .../blueprints-processor-adaptor.properties | 45 -- .../src/test/resources/keystore.client.p12 | Bin 1456 -> 0 bytes .../src/test/resources/truststore.client.jks | Bin 1228 -> 0 bytes .../features/ccsdk-blueprints-processor/pom.xml | 96 ---- .../features/features-blueprints-processor/pom.xml | 44 -- blueprints-processor/features/pom.xml | 38 -- blueprints-processor/installer/.gitignore | 1 - blueprints-processor/installer/pom.xml | 172 ------ .../src/assembly/assemble_installer_zip.xml | 53 -- .../src/assembly/assemble_mvnrepo_zip.xml | 43 -- .../src/main/resources/scripts/install-feature.sh | 36 -- .../plugin/assignment-provider/pom.xml | 144 ----- .../assignment/ConfigAssignmentConstants.java | 37 -- .../assignment/data/ResourceAssignmentData.java | 163 ------ .../assignment/processor/DBResourceProcessor.java | 267 --------- .../processor/DefaultResourceProcessor.java | 107 ---- .../processor/InputResourceProcessor.java | 96 ---- .../processor/MdsalResourceProcessor.java | 239 -------- .../assignment/processor/ProcessorFactory.java | 52 -- .../processor/ResourceAssignmentProcessor.java | 120 ---- .../assignment/service/ConfigAssignmentNode.java | 231 -------- .../service/ConfigAssignmentPersistService.java | 124 ---- .../service/ConfigAssignmentProcessService.java | 238 -------- .../service/ConfigAssignmentService.java | 35 -- .../service/ConfigAssignmentServiceImpl.java | 79 --- .../assignment/service/ConfigAssignmentUtils.java | 301 ---------- .../assignment/service/ConfigPreviewService.java | 119 ---- .../service/ResourceDictionaryService.java | 110 ---- .../assignment/service/ResourceModelService.java | 97 ---- .../OSGI-INF/blueprint/impl-blueprint.xml | 63 -- .../org/opendaylight/blueprint/impl-blueprint.xml | 63 -- .../processor/DBResourceProcessorTest.java | 231 -------- .../processor/DefaultResourceProcessorTest.java | 127 ---- .../processor/InputResourceProcessorTest.java | 178 ------ .../processor/MdsalResourceProcessorTest.java | 268 --------- .../service/ConfigAssignmentNodeTest.java | 246 -------- .../service/ConfigPreviewServiceTest.java | 111 ---- .../service/ConfigResourceAssignmentTestUtils.java | 182 ------ .../service/ResourceAssignmentGenerationTest.java | 110 ---- .../service/ResourceAssignmentValidation.java | 94 --- .../assignment/service/TopologicalSortingTest.java | 60 -- .../assignments/alltype-empty-value-mapping.json | 86 --- .../resources/assignments/alltype-mapping.json | 110 ---- .../resources/assignments/empty-dictionary.json | 1 - .../mapping/Mdsal/array-complex-response.json | 12 - .../Mdsal/array-complex-v4-assigned-response.json | 13 - .../resources/mapping/Mdsal/complex-response.json | 6 - .../resources/mapping/Mdsal/default-pointer.json | 166 ------ .../test/resources/mapping/Mdsal/dt-location.json | 15 - .../mapping/Mdsal/dt-v4-assigned-ip-list.json | 27 - .../mapping/Mdsal/mdsal-array-v4iplist.json | 76 --- .../test/resources/mapping/Mdsal/mdsal-array.json | 42 -- .../resources/mapping/Mdsal/mdsal-complex.json | 38 -- .../test/resources/mapping/Mdsal/mdsal-simple.json | 37 -- .../mapping/Mdsal/resource-assignments-array.json | 15 - .../Mdsal/resource-assignments-complex-simple.json | 12 - .../Mdsal/resource-assignments-complex.json | 12 - .../mapping/Mdsal/resource-assignments-simple.json | 12 - .../resources/mapping/Mdsal/simple-response.json | 3 - .../src/test/resources/mapping/db/db-array.json | 40 -- .../src/test/resources/mapping/db/db-complex.json | 37 -- .../src/test/resources/mapping/db/db-simple.json | 36 -- .../src/test/resources/mapping/db/dt-location.json | 15 - .../mapping/db/resource-assignments-array.json | 15 - .../mapping/db/resource-assignments-complex.json | 12 - .../mapping/db/resource-assignments-simple.json | 12 - .../resources/mapping/default/default-simple.json | 35 -- .../default/resource-assignments-simple.json | 35 -- .../src/test/resources/mapping/dependency.json | 110 ---- .../test/resources/mapping/input/dt-location.json | 15 - .../resources/mapping/input/input-complex.json | 24 - .../test/resources/mapping/input/input-simple.json | 35 -- .../input/resource-assignments-complex.json | 13 - .../mapping/input/resource-assignments-simple.json | 32 -- .../resources/mapping/input/sample-location.json | 4 - .../resources/service_templates/input/input.json | 18 - .../service_templates/input/inputValidateTest.json | 18 - .../service_templates/resource_assignment.json | 407 ------------- .../resource_assignment/resource_assignment.json | 417 -------------- .../velocity/base-config-template.vtl | 40 -- .../vpe-201802-baseconfig/dict.json | 172 ------ .../vpe-201802-baseconfig/input-complex.json | 49 -- .../velocity/base-config-template.vtl | 40 -- .../vpe-201802-baseconfig.json | 639 --------------------- .../src/test/resources/validation/cyclic.json | 111 ---- .../src/test/resources/validation/duplicate.json | 110 ---- .../src/test/resources/validation/success.json | 110 ---- .../plugin/generator-provider/pom.xml | 141 ----- .../generator/ConfigGeneratorConstant.java | 49 -- .../generator/data/ConfigGeneratorInfo.java | 102 ---- .../generator/service/ConfigGeneratorNode.java | 140 ----- .../generator/service/ConfigGeneratorService.java | 33 -- .../service/ConfigGeneratorServiceImpl.java | 143 ----- .../generator/tool/CustomJsonNodeFactory.java | 30 - .../features/generator/tool/CustomTextNode.java | 42 -- .../ccsdk/features/generator/tool/EscapeUtils.java | 82 --- .../OSGI-INF/blueprint/impl-blueprint.xml | 49 -- .../org/opendaylight/blueprint/impl-blueprint.xml | 49 -- .../generator/service/ConfigGeneratorNodeTest.java | 222 ------- .../features/generator/tool/EscapeUtilsTest.java | 51 -- .../resources/service_templates/configdata.json | 36 -- .../service_templates/configdata_with_null.json | 36 -- .../service_templates/generate_configuration.json | 355 ------------ .../velocity/base-config-template.vtl | 61 -- .../velocity/base-config-template_group.vtl | 40 -- blueprints-processor/plugin/model-provider/pom.xml | 166 ------ .../ccsdk/features/model/ConfigModelConstant.java | 145 ----- .../ccsdk/features/model/ConfigModelException.java | 50 -- .../org/onap/ccsdk/features/model/ValidTypes.java | 105 ---- .../features/model/data/ArtifactDefinition.java | 105 ---- .../ccsdk/features/model/data/ArtifactType.java | 102 ---- .../features/model/data/CapabilityAssignment.java | 49 -- .../features/model/data/CapabilityDefinition.java | 88 --- .../features/model/data/ConstraintClause.java | 150 ----- .../onap/ccsdk/features/model/data/DataType.java | 88 --- .../ccsdk/features/model/data/EntrySchema.java | 36 -- .../ccsdk/features/model/data/Implementation.java | 49 -- .../features/model/data/InterfaceAssignment.java | 58 -- .../features/model/data/InterfaceDefinition.java | 58 -- .../ccsdk/features/model/data/NodeTemplate.java | 112 ---- .../onap/ccsdk/features/model/data/NodeType.java | 114 ---- .../features/model/data/OperationAssignment.java | 76 --- .../features/model/data/OperationDefinition.java | 76 --- .../features/model/data/PropertyDefinition.java | 125 ---- .../features/model/data/RelationshipTemplate.java | 56 -- .../features/model/data/RequirementAssignment.java | 67 --- .../features/model/data/RequirementDefinition.java | 85 --- .../features/model/data/ResourceAssignment.java | 165 ------ .../ccsdk/features/model/data/ServiceTemplate.java | 118 ---- .../features/model/data/TopologyTemplate.java | 97 ---- .../onap/ccsdk/features/model/data/Workflow.java | 39 -- .../features/model/data/api/ActionIdentifiers.java | 62 -- .../features/model/data/api/CommonHeader.java | 82 --- .../onap/ccsdk/features/model/data/api/Flags.java | 40 -- .../onap/ccsdk/features/model/data/api/Status.java | 61 -- .../model/data/api/TransactionRequest.java | 45 -- .../model/data/api/TransactionResponse.java | 46 -- .../model/data/dict/ResourceDefinition.java | 83 --- .../model/data/dict/SourcesDefinition.java | 48 -- .../model/data/dict/SourcesProperties.java | 127 ---- .../ccsdk/features/model/domain/ConfigModel.java | 231 -------- .../features/model/domain/ConfigModelContent.java | 91 --- .../features/model/domain/ResourceDictionary.java | 119 ---- .../features/model/service/ComponentNode.java | 41 -- .../model/service/ComponentNodeDelegate.java | 42 -- .../model/service/ComponentNodeService.java | 32 -- .../model/service/ComponentNodeServiceImpl.java | 174 ------ .../model/service/ConfigBlueprintService.java | 100 ---- .../features/model/service/ConfigModelNode.java | 24 - .../features/model/service/ConfigModelService.java | 55 -- .../model/service/ConfigModelServiceImpl.java | 244 -------- .../features/model/utils/ExpressionUtils.java | 191 ------ .../features/model/utils/JsonParserUtils.java | 59 -- .../onap/ccsdk/features/model/utils/JsonUtils.java | 109 ---- .../features/model/utils/NodePropertyUtils.java | 187 ------ .../features/model/utils/PrepareContextUtils.java | 63 -- .../model/utils/ResourceAssignmentUtils.java | 302 ---------- .../model/utils/ResourceDictionaryUtils.java | 119 ---- .../features/model/utils/ServiceTemplateUtils.java | 277 --------- .../model/utils/TopologicalSortingUtils.java | 188 ------ .../features/model/utils/TransformationUtils.java | 429 -------------- .../model/validator/DataTypeValidator.java | 109 ---- .../model/validator/NodeTypeValidator.java | 237 -------- .../validator/PropertyDefinitionValidator.java | 89 --- .../validator/ResourceAssignmentValidator.java | 163 ------ .../model/validator/ServiceTemplateValidator.java | 129 ----- .../model/validator/TopologyTemplateValidator.java | 203 ------- .../OSGI-INF/blueprint/impl-blueprint.xml | 68 --- .../org/opendaylight/blueprint/impl-blueprint.xml | 68 --- .../model/ResourceDictionaryUtilsTest.java | 216 ------- .../features/model/utils/JsonParserUtilsTest.java | 43 -- .../ccsdk/features/model/utils/JsonUtilsTest.java | 103 ---- .../model/utils/ResourceAssignmentUtilsTest.java | 198 ------- .../model/utils/ServiceTemplateUtilsTest.java | 77 --- .../model/utils/TransformationUtilsTest.java | 90 --- .../validator/ServiceTemplateValidationTest.java | 47 -- .../features/params/service/ComponentNodeTest.java | 140 ----- .../params/service/ConfigModelServiceTest.java | 219 ------- .../params/service/ExpressionUtilsTest.java | 76 --- .../features/params/service/MockComponentNode.java | 62 -- .../params/service/ServiceTemplateCreateUtils.java | 193 ------- .../src/test/resources/componentnode/default.json | 100 ---- .../resources/dictionary/dictionary_schema.json | 118 ---- .../src/test/resources/properties/convert.json | 33 -- .../src/test/resources/properties/default.json | 16 - .../test/resources/service_templates/default.json | 591 ------------------- .../ra-content-with-mising-value.json | 265 --------- .../service_templates/resource_assignment.json | 407 ------------- .../velocity/base-config-template.vtl | 1 - .../velocity/licence-template.vtl | 0 .../resources/service_templates/vrr_config.json | 171 ------ blueprints-processor/plugin/pom.xml | 41 -- blueprints-processor/pom.xml | 42 -- 246 files changed, 24820 deletions(-) delete mode 100644 blueprints-processor/.gitignore delete mode 100644 blueprints-processor/adaptors/data-adaptor-provider/pom.xml delete mode 100644 blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/ConfigDataAdaptorException.java delete mode 100644 blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/DataAdaptorConstants.java delete mode 100644 blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/dao/ConfigResourceDao.java delete mode 100644 blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/dao/ConfigResourceDaoImpl.java delete mode 100644 blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/dao/NamedQueryExecutorDao.java delete mode 100644 blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/dao/NamedQueryExecutorDaoImpl.java delete mode 100644 blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/dao/QueryExecutorDao.java delete mode 100644 blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/dao/QueryExecutorDaoImpl.java delete mode 100644 blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/dao/TransactionLogDao.java delete mode 100644 blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/dao/TransactionLogDaoImpl.java delete mode 100644 blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/db/DataSourceWrap.java delete mode 100644 blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/domain/ConfigResource.java delete mode 100644 blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/domain/ResourceAssignmentData.java delete mode 100644 blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/domain/TransactionLog.java delete mode 100644 blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/service/ConfigResourceNode.java delete mode 100644 blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/service/ConfigResourceService.java delete mode 100644 blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/service/ConfigResourceServiceImpl.java delete mode 100644 blueprints-processor/adaptors/data-adaptor-provider/src/main/resources/OSGI-INF/blueprint/impl-blueprint.xml delete mode 100644 blueprints-processor/adaptors/data-adaptor-provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml delete mode 100644 blueprints-processor/adaptors/data-adaptor-provider/src/main/resources/sql/001_init_ddl.sql delete mode 100644 blueprints-processor/adaptors/data-adaptor-provider/src/test/java/org/onap/ccsdk/features/data/adaptor/dao/ConfigResourceDaoTest.java delete mode 100644 blueprints-processor/adaptors/data-adaptor-provider/src/test/java/org/onap/ccsdk/features/data/adaptor/dao/ConfigTransactionLogDaoTest.java delete mode 100644 blueprints-processor/adaptors/data-adaptor-provider/src/test/java/org/onap/ccsdk/features/data/adaptor/dao/QueryExecutorDaoTest.java delete mode 100644 blueprints-processor/adaptors/data-adaptor-provider/src/test/java/org/onap/ccsdk/features/data/adaptor/service/ConfigResourceNodeTest.java delete mode 100644 blueprints-processor/adaptors/data-adaptor-provider/src/test/java/org/onap/ccsdk/features/data/adaptor/service/ConfigResourceServiceTest.java delete mode 100644 blueprints-processor/adaptors/data-adaptor-provider/src/test/resources/log4j.properties delete mode 100644 blueprints-processor/adaptors/data-adaptor-provider/src/test/resources/mappings/service-mapping.json delete mode 100644 blueprints-processor/adaptors/data-adaptor-provider/src/test/resources/reference/resource_data.json delete mode 100644 blueprints-processor/adaptors/data-adaptor-provider/src/test/resources/sql/schema.sql delete mode 100644 blueprints-processor/adaptors/data-adaptor-provider/src/test/resources/test-context-h2db.xml delete mode 100644 blueprints-processor/adaptors/data-adaptor-provider/src/test/resources/test-context.xml delete mode 100644 blueprints-processor/adaptors/pom.xml delete mode 100644 blueprints-processor/adaptors/rest-adaptor-provider/pom.xml delete mode 100644 blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/features/rest/adaptor/ConfigRestAdaptorConstants.java delete mode 100644 blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/features/rest/adaptor/ConfigRestAdaptorException.java delete mode 100644 blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/features/rest/adaptor/data/RestResponse.java delete mode 100644 blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/features/rest/adaptor/service/AbstractConfigRestClientAdapter.java delete mode 100644 blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/features/rest/adaptor/service/ConfigRestAdaptorService.java delete mode 100644 blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/features/rest/adaptor/service/ConfigRestAdaptorServiceImpl.java delete mode 100644 blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/features/rest/adaptor/service/ConfigRestClientServiceAdapter.java delete mode 100644 blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/features/rest/adaptor/service/GenericRestClientAdapterImpl.java delete mode 100644 blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/features/rest/adaptor/service/SSLRestClientAdapterImpl.java delete mode 100644 blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/features/rest/adaptor/utils/BasicAuthorizationInterceptor.java delete mode 100644 blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/features/rest/adaptor/utils/LoggingRequestInterceptor.java delete mode 100644 blueprints-processor/adaptors/rest-adaptor-provider/src/main/resources/OSGI-INF/blueprint/impl-blueprint.xml delete mode 100644 blueprints-processor/adaptors/rest-adaptor-provider/src/main/resources/blueprints-processor-adaptor.properties delete mode 100644 blueprints-processor/adaptors/rest-adaptor-provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml delete mode 100644 blueprints-processor/adaptors/rest-adaptor-provider/src/test/java/org/onap/ccsdk/features/rest/adaptor/service/AbstractConfigRestClientAdapterTest.java delete mode 100644 blueprints-processor/adaptors/rest-adaptor-provider/src/test/java/org/onap/ccsdk/features/rest/adaptor/service/GenericRestClientServiceTest.java delete mode 100644 blueprints-processor/adaptors/rest-adaptor-provider/src/test/java/org/onap/ccsdk/features/rest/adaptor/service/SSLClientServiceTest.java delete mode 100644 blueprints-processor/adaptors/rest-adaptor-provider/src/test/java/org/onap/ccsdk/features/rest/adaptor/utils/RestTemplateFactoryTest.java delete mode 100644 blueprints-processor/adaptors/rest-adaptor-provider/src/test/resources/blueprints-processor-adaptor.properties delete mode 100644 blueprints-processor/adaptors/rest-adaptor-provider/src/test/resources/keystore.client.p12 delete mode 100644 blueprints-processor/adaptors/rest-adaptor-provider/src/test/resources/truststore.client.jks delete mode 100644 blueprints-processor/features/ccsdk-blueprints-processor/pom.xml delete mode 100755 blueprints-processor/features/features-blueprints-processor/pom.xml delete mode 100755 blueprints-processor/features/pom.xml delete mode 100644 blueprints-processor/installer/.gitignore delete mode 100644 blueprints-processor/installer/pom.xml delete mode 100644 blueprints-processor/installer/src/assembly/assemble_installer_zip.xml delete mode 100644 blueprints-processor/installer/src/assembly/assemble_mvnrepo_zip.xml delete mode 100644 blueprints-processor/installer/src/main/resources/scripts/install-feature.sh delete mode 100644 blueprints-processor/plugin/assignment-provider/pom.xml delete mode 100644 blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/ConfigAssignmentConstants.java delete mode 100644 blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/data/ResourceAssignmentData.java delete mode 100644 blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/processor/DBResourceProcessor.java delete mode 100644 blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/processor/DefaultResourceProcessor.java delete mode 100644 blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/processor/InputResourceProcessor.java delete mode 100644 blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/processor/MdsalResourceProcessor.java delete mode 100644 blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/processor/ProcessorFactory.java delete mode 100644 blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/processor/ResourceAssignmentProcessor.java delete mode 100644 blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/service/ConfigAssignmentNode.java delete mode 100644 blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/service/ConfigAssignmentPersistService.java delete mode 100644 blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/service/ConfigAssignmentProcessService.java delete mode 100644 blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/service/ConfigAssignmentService.java delete mode 100644 blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/service/ConfigAssignmentServiceImpl.java delete mode 100644 blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/service/ConfigAssignmentUtils.java delete mode 100644 blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/service/ConfigPreviewService.java delete mode 100644 blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/service/ResourceDictionaryService.java delete mode 100644 blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/service/ResourceModelService.java delete mode 100644 blueprints-processor/plugin/assignment-provider/src/main/resources/OSGI-INF/blueprint/impl-blueprint.xml delete mode 100644 blueprints-processor/plugin/assignment-provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml delete mode 100644 blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/features/assignment/processor/DBResourceProcessorTest.java delete mode 100644 blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/features/assignment/processor/DefaultResourceProcessorTest.java delete mode 100644 blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/features/assignment/processor/InputResourceProcessorTest.java delete mode 100644 blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/features/assignment/processor/MdsalResourceProcessorTest.java delete mode 100644 blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/features/assignment/service/ConfigAssignmentNodeTest.java delete mode 100644 blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/features/assignment/service/ConfigPreviewServiceTest.java delete mode 100644 blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/features/assignment/service/ConfigResourceAssignmentTestUtils.java delete mode 100644 blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/features/assignment/service/ResourceAssignmentGenerationTest.java delete mode 100644 blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/features/assignment/service/ResourceAssignmentValidation.java delete mode 100644 blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/features/assignment/service/TopologicalSortingTest.java delete mode 100644 blueprints-processor/plugin/assignment-provider/src/test/resources/assignments/alltype-empty-value-mapping.json delete mode 100644 blueprints-processor/plugin/assignment-provider/src/test/resources/assignments/alltype-mapping.json delete mode 100644 blueprints-processor/plugin/assignment-provider/src/test/resources/assignments/empty-dictionary.json delete mode 100644 blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/array-complex-response.json delete mode 100644 blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/array-complex-v4-assigned-response.json delete mode 100644 blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/complex-response.json delete mode 100644 blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/default-pointer.json delete mode 100644 blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/dt-location.json delete mode 100644 blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/dt-v4-assigned-ip-list.json delete mode 100644 blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/mdsal-array-v4iplist.json delete mode 100644 blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/mdsal-array.json delete mode 100644 blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/mdsal-complex.json delete mode 100644 blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/mdsal-simple.json delete mode 100644 blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/resource-assignments-array.json delete mode 100644 blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/resource-assignments-complex-simple.json delete mode 100644 blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/resource-assignments-complex.json delete mode 100644 blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/resource-assignments-simple.json delete mode 100644 blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/simple-response.json delete mode 100644 blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/db/db-array.json delete mode 100644 blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/db/db-complex.json delete mode 100644 blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/db/db-simple.json delete mode 100644 blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/db/dt-location.json delete mode 100644 blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/db/resource-assignments-array.json delete mode 100644 blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/db/resource-assignments-complex.json delete mode 100644 blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/db/resource-assignments-simple.json delete mode 100644 blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/default/default-simple.json delete mode 100644 blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/default/resource-assignments-simple.json delete mode 100644 blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/dependency.json delete mode 100644 blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/input/dt-location.json delete mode 100644 blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/input/input-complex.json delete mode 100644 blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/input/input-simple.json delete mode 100644 blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/input/resource-assignments-complex.json delete mode 100644 blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/input/resource-assignments-simple.json delete mode 100644 blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/input/sample-location.json delete mode 100644 blueprints-processor/plugin/assignment-provider/src/test/resources/service_templates/input/input.json delete mode 100644 blueprints-processor/plugin/assignment-provider/src/test/resources/service_templates/input/inputValidateTest.json delete mode 100644 blueprints-processor/plugin/assignment-provider/src/test/resources/service_templates/resource_assignment.json delete mode 100644 blueprints-processor/plugin/assignment-provider/src/test/resources/service_templates/resource_assignment/resource_assignment.json delete mode 100644 blueprints-processor/plugin/assignment-provider/src/test/resources/service_templates/resource_assignment/velocity/base-config-template.vtl delete mode 100644 blueprints-processor/plugin/assignment-provider/src/test/resources/service_templates/vpe-201802-baseconfig/dict.json delete mode 100644 blueprints-processor/plugin/assignment-provider/src/test/resources/service_templates/vpe-201802-baseconfig/input-complex.json delete mode 100644 blueprints-processor/plugin/assignment-provider/src/test/resources/service_templates/vpe-201802-baseconfig/velocity/base-config-template.vtl delete mode 100644 blueprints-processor/plugin/assignment-provider/src/test/resources/service_templates/vpe-201802-baseconfig/vpe-201802-baseconfig.json delete mode 100644 blueprints-processor/plugin/assignment-provider/src/test/resources/validation/cyclic.json delete mode 100644 blueprints-processor/plugin/assignment-provider/src/test/resources/validation/duplicate.json delete mode 100644 blueprints-processor/plugin/assignment-provider/src/test/resources/validation/success.json delete mode 100644 blueprints-processor/plugin/generator-provider/pom.xml delete mode 100644 blueprints-processor/plugin/generator-provider/src/main/java/org/onap/ccsdk/features/generator/ConfigGeneratorConstant.java delete mode 100644 blueprints-processor/plugin/generator-provider/src/main/java/org/onap/ccsdk/features/generator/data/ConfigGeneratorInfo.java delete mode 100644 blueprints-processor/plugin/generator-provider/src/main/java/org/onap/ccsdk/features/generator/service/ConfigGeneratorNode.java delete mode 100644 blueprints-processor/plugin/generator-provider/src/main/java/org/onap/ccsdk/features/generator/service/ConfigGeneratorService.java delete mode 100644 blueprints-processor/plugin/generator-provider/src/main/java/org/onap/ccsdk/features/generator/service/ConfigGeneratorServiceImpl.java delete mode 100644 blueprints-processor/plugin/generator-provider/src/main/java/org/onap/ccsdk/features/generator/tool/CustomJsonNodeFactory.java delete mode 100644 blueprints-processor/plugin/generator-provider/src/main/java/org/onap/ccsdk/features/generator/tool/CustomTextNode.java delete mode 100644 blueprints-processor/plugin/generator-provider/src/main/java/org/onap/ccsdk/features/generator/tool/EscapeUtils.java delete mode 100644 blueprints-processor/plugin/generator-provider/src/main/resources/OSGI-INF/blueprint/impl-blueprint.xml delete mode 100644 blueprints-processor/plugin/generator-provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml delete mode 100644 blueprints-processor/plugin/generator-provider/src/test/java/org/onap/ccsdk/features/generator/service/ConfigGeneratorNodeTest.java delete mode 100644 blueprints-processor/plugin/generator-provider/src/test/java/org/onap/ccsdk/features/generator/tool/EscapeUtilsTest.java delete mode 100644 blueprints-processor/plugin/generator-provider/src/test/resources/service_templates/configdata.json delete mode 100644 blueprints-processor/plugin/generator-provider/src/test/resources/service_templates/configdata_with_null.json delete mode 100644 blueprints-processor/plugin/generator-provider/src/test/resources/service_templates/generate_configuration.json delete mode 100644 blueprints-processor/plugin/generator-provider/src/test/resources/service_templates/velocity/base-config-template.vtl delete mode 100644 blueprints-processor/plugin/generator-provider/src/test/resources/service_templates/velocity/base-config-template_group.vtl delete mode 100644 blueprints-processor/plugin/model-provider/pom.xml delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/ConfigModelConstant.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/ConfigModelException.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/ValidTypes.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/ArtifactDefinition.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/ArtifactType.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/CapabilityAssignment.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/CapabilityDefinition.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/ConstraintClause.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/DataType.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/EntrySchema.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/Implementation.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/InterfaceAssignment.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/InterfaceDefinition.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/NodeTemplate.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/NodeType.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/OperationAssignment.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/OperationDefinition.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/PropertyDefinition.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/RelationshipTemplate.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/RequirementAssignment.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/RequirementDefinition.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/ResourceAssignment.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/ServiceTemplate.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/TopologyTemplate.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/Workflow.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/api/ActionIdentifiers.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/api/CommonHeader.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/api/Flags.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/api/Status.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/api/TransactionRequest.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/api/TransactionResponse.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/dict/ResourceDefinition.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/dict/SourcesDefinition.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/dict/SourcesProperties.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/domain/ConfigModel.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/domain/ConfigModelContent.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/domain/ResourceDictionary.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/service/ComponentNode.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/service/ComponentNodeDelegate.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/service/ComponentNodeService.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/service/ComponentNodeServiceImpl.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/service/ConfigBlueprintService.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/service/ConfigModelNode.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/service/ConfigModelService.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/service/ConfigModelServiceImpl.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/utils/ExpressionUtils.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/utils/JsonParserUtils.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/utils/JsonUtils.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/utils/NodePropertyUtils.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/utils/PrepareContextUtils.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/utils/ResourceAssignmentUtils.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/utils/ResourceDictionaryUtils.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/utils/ServiceTemplateUtils.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/utils/TopologicalSortingUtils.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/utils/TransformationUtils.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/validator/DataTypeValidator.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/validator/NodeTypeValidator.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/validator/PropertyDefinitionValidator.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/validator/ResourceAssignmentValidator.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/validator/ServiceTemplateValidator.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/validator/TopologyTemplateValidator.java delete mode 100644 blueprints-processor/plugin/model-provider/src/main/resources/OSGI-INF/blueprint/impl-blueprint.xml delete mode 100644 blueprints-processor/plugin/model-provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml delete mode 100644 blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/model/ResourceDictionaryUtilsTest.java delete mode 100644 blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/model/utils/JsonParserUtilsTest.java delete mode 100644 blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/model/utils/JsonUtilsTest.java delete mode 100644 blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/model/utils/ResourceAssignmentUtilsTest.java delete mode 100644 blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/model/utils/ServiceTemplateUtilsTest.java delete mode 100644 blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/model/utils/TransformationUtilsTest.java delete mode 100644 blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/model/validator/ServiceTemplateValidationTest.java delete mode 100644 blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/params/service/ComponentNodeTest.java delete mode 100644 blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/params/service/ConfigModelServiceTest.java delete mode 100644 blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/params/service/ExpressionUtilsTest.java delete mode 100644 blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/params/service/MockComponentNode.java delete mode 100644 blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/params/service/ServiceTemplateCreateUtils.java delete mode 100644 blueprints-processor/plugin/model-provider/src/test/resources/componentnode/default.json delete mode 100644 blueprints-processor/plugin/model-provider/src/test/resources/dictionary/dictionary_schema.json delete mode 100644 blueprints-processor/plugin/model-provider/src/test/resources/properties/convert.json delete mode 100644 blueprints-processor/plugin/model-provider/src/test/resources/properties/default.json delete mode 100644 blueprints-processor/plugin/model-provider/src/test/resources/service_templates/default.json delete mode 100644 blueprints-processor/plugin/model-provider/src/test/resources/service_templates/ra-content-with-mising-value.json delete mode 100644 blueprints-processor/plugin/model-provider/src/test/resources/service_templates/resource_assignment.json delete mode 100644 blueprints-processor/plugin/model-provider/src/test/resources/service_templates/velocity/base-config-template.vtl delete mode 100644 blueprints-processor/plugin/model-provider/src/test/resources/service_templates/velocity/licence-template.vtl delete mode 100644 blueprints-processor/plugin/model-provider/src/test/resources/service_templates/vrr_config.json delete mode 100644 blueprints-processor/plugin/pom.xml delete mode 100644 blueprints-processor/pom.xml (limited to 'blueprints-processor') diff --git a/blueprints-processor/.gitignore b/blueprints-processor/.gitignore deleted file mode 100644 index dcf24b513..000000000 --- a/blueprints-processor/.gitignore +++ /dev/null @@ -1,30 +0,0 @@ -# Target dir in all projects -**/target/* -**/target-ide/* - -# Logs dir in all projects -**/logs/* -**/debug-logs/* - -# Added for Intellij IDEA IDE -**/.idea/* - -# Generated models and features -**/bin/* - -# MANIFEST.MF is updated on every clean install -**/src/main/resources/META-INF/ -**/src/main/yang-gen-sal -**/src/main/yang-gen-config - - -**/pom.xml.versionsBackup -**/.flattened-pom.xml -**/.pydevproject -**/.settings -**/.classpath -**/.project - -**/*.class -**/*.prefs -**/*.iml \ No newline at end of file diff --git a/blueprints-processor/adaptors/data-adaptor-provider/pom.xml b/blueprints-processor/adaptors/data-adaptor-provider/pom.xml deleted file mode 100644 index 486fa93cc..000000000 --- a/blueprints-processor/adaptors/data-adaptor-provider/pom.xml +++ /dev/null @@ -1,119 +0,0 @@ - - - - 4.0.0 - - - org.onap.ccsdk.parent - binding-parent - 1.5.2-SNAPSHOT - - - - org.onap.ccsdk.features - blueprints-data-adaptor-provider - 0.7.1-SNAPSHOT - bundle - - ccsdk-features :: blueprints-processor-adaptor :: ${project.artifactId} - http://maven.apache.org - - - ${project.version} - - - - - - org.onap.ccsdk.sli.core - sli-core-artifacts - ${ccsdk.sli.core.version} - pom - import - - - - - - org.apache.commons - commons-lang3 - - - org.onap.ccsdk.sli.core - sli-provider - compile - - - commons-io - commons-io - - - org.mariadb.jdbc - mariadb-java-client - runtime - - - org.springframework - spring-context - - - org.springframework - spring-jdbc - - - com.att.eelf - eelf-core - - - org.springframework - spring-test - test - - - com.h2database - h2 - test - - - junit - junit - test - - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - - -Xdoclint:none - - - - org.apache.felix - maven-bundle-plugin - true - - - ${project.artifactId} - ${project.groupId}.${project.artifactId} - org.onap.ccsdk.features.data.adaptor, - org.onap.ccsdk.features.data.adaptor.dao, - org.onap.ccsdk.features.data.adaptor.db, - org.onap.ccsdk.features.data.adaptor.domain, - org.onap.ccsdk.features.data.adaptor.service - - - - - - - diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/ConfigDataAdaptorException.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/ConfigDataAdaptorException.java deleted file mode 100644 index d76ee4ef9..000000000 --- a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/ConfigDataAdaptorException.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.data.adaptor; - -/** - * ConfigDataAdaptorException.java Purpose: Provide Configuration Data Adaptor Exception - * - * @version 1.0 - */ -public class ConfigDataAdaptorException extends Exception { - - /** - * - */ - private static final long serialVersionUID = 1L; - - /** - * This is a ConfigDataAdaptorException constructor - * - * @param message - */ - public ConfigDataAdaptorException(String message) { - super(message); - } - - /** - * This is a ConfigDataAdaptorException constructor - * - * @param message - */ - public ConfigDataAdaptorException(String message, Throwable cause) { - super(message, cause); - } - -} diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/DataAdaptorConstants.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/DataAdaptorConstants.java deleted file mode 100644 index d88acca9c..000000000 --- a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/DataAdaptorConstants.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.data.adaptor; - -@SuppressWarnings("squid:S1118") -public class DataAdaptorConstants { - - public static final String OUTPUT_STATUS_SUCCESS = "success"; - public static final String OUTPUT_STATUS_FAILURE = "failure"; - - public static final String PROPERTY_ENV_TYPE = "org.onap.ccsdk.features.blueprints.adaptors.envtype"; - public static final String PROPERTY_ENV_PROD = "field"; - public static final String PROPERTY_ENV_SOLO = "solo"; - - public static final String INPUT_PARAM_TAGS = "tags"; - public static final String INPUT_PARAM_CAPABILITY_NAME = "capabilityName"; - public static final String INPUT_PARAM_MESSAGE = "message"; - public static final String INPUT_PARAM_MESSAGE_TYPE = "messageType"; - public static final String OUTPUT_PARAM_STATUS = "status"; - public static final String OUTPUT_PARAM_ERROR_MESSAGE = "error-message"; - public static final String INPUT_PARAM_FILE_CATEGORY = "fileCategory"; - public static final String INPUT_PARAM_VM_INSTANCE = "vmInstance"; - public static final String INPUT_PARAM_ASDC_ARTIFACT_IND = "asdcArtifactInd"; - public static final Object INPUT_PARAM_VNF_ID = "vnfId"; - public static final Object INPUT_PARAM_VM_NAME = "vmName"; - - public static final Object INPUT_PARAM_CONFIG_CONTENT_TYPE = "configContentType"; - - public static final Object INPUT_PARAM_CONFIG_CONTENT = "configContent"; - public static final Object INPUT_PARAM_CONFIG_INDICATOR = "configIndicator"; - - public static final Object CONFIG_CONTENT_TYPE_CONFIGURATION = "Configuration"; - public static final Object CONFIG_CONTENT_TYPE_PARAMETERS = "Parameters"; - public static final Object CONFIG_INDICATOR_PREPARE = "Prepare"; - public static final Object CONFIG_INDICATOR_ACTIVE = "Active"; - - public static final String INPUT_PARAM_RESPONSE_PRIFIX = "response-prefix"; - public static final String INPUT_PARAM_VNF_TYPE = "vnfType"; - public static final String INPUT_PARAM_VNFC_TYPE = "vnfcType"; - public static final String INPUT_PARAM_ACTION = "action"; - public static final String INPUT_PARAM_API_VERSION = "apiVersion"; - - public static final String INPUT_PARAM_FILE_ID = "fileId"; - public static final String INPUT_PARAM_UPLOAD_CONFIG_ID = "uploadConfigId"; - public static final String FILE_CATEGORY_SERVICE_TEMPLATE = "service_template"; - - public static final String ARTIFACT_TYPE_SDNC_MODEL = "SDNC_MODEL"; - - public static final String LOG_MESSAGE_TYPE_LOG = "Log"; - public static final String LOG_MESSAGE_TYPE_COMPONENT = "Component"; - public static final String LOG_MESSAGE_TYPE_REQUEST = "Request"; - public static final String LOG_MESSAGE_TYPE_MODEL = "Model"; - public static final String LOG_MESSAGE_TYPE_DATA = "Data"; - public static final String LOG_MESSAGE_TYPE_CONFIG = "Config"; - - public static final String SELF_SERVICE_STATUS_RECEIVED = "Received"; - public static final String SELF_SERVICE_STATUS_ACKNOWLEDGED = "Acknowledged"; - public static final String SELF_SERVICE_STATUS_REPLIED = "Replied"; - public static final String SELF_SERVICE_STATUS_FAILED = "Failed"; - -} diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/dao/ConfigResourceDao.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/dao/ConfigResourceDao.java deleted file mode 100644 index bc33d51a3..000000000 --- a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/dao/ConfigResourceDao.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.data.adaptor.dao; - -import java.util.List; -import org.onap.ccsdk.features.data.adaptor.domain.ConfigResource; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; - -public interface ConfigResourceDao { - - /** - * Issue a single SQL Insert operation for CONFIG_RESOURCE table via a prepared statement, binding - * the given arguments. - * - * @param transactionLog arguments to bind to the query (mapping it to the PreparedStatement to the - * corresponding SQL type) - * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if there is any problem issuing the insert - */ - public ConfigResource save(ConfigResource configResourceInput) throws SvcLogicException; - - /** - * Issue a single SQL Delete operation for CONFIG_RESOURCE table via a prepared statement, binding - * the given arguments. - * - * @param configResource arguments to bind to the query (mapping it to the PreparedStatement to the - * corresponding SQL type) - * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if there is any problem issuing the insert - */ - public void deleteByConfigResource(ConfigResource configResourceInput) throws SvcLogicException; - - /** - * Query CONFIG_RESOURCE table for given input param to create a prepared statement to bind to the - * query, mapping each row to a Java object via a ConfigResource RowMapper. - * - * @param configResource argument to bind to the query (mapping it to the PreparedStatement to the - * corresponding SQL type) - * @return the result List, containing mapped objects - * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if the query fails - */ - public List findByConfigResource(ConfigResource configResourceInput) throws SvcLogicException; - - public ConfigResource getConfigResource(ConfigResource configResource) throws SvcLogicException; -} diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/dao/ConfigResourceDaoImpl.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/dao/ConfigResourceDaoImpl.java deleted file mode 100644 index 7661e96ee..000000000 --- a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/dao/ConfigResourceDaoImpl.java +++ /dev/null @@ -1,415 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.data.adaptor.dao; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; -import org.apache.commons.lang3.StringUtils; -import org.onap.ccsdk.features.data.adaptor.domain.ConfigResource; -import org.onap.ccsdk.features.data.adaptor.domain.ResourceAssignmentData; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.jdbc.core.RowMapper; -import org.springframework.jdbc.core.RowMapperResultSetExtractor; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -public class ConfigResourceDaoImpl implements ConfigResourceDao { - - private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigResourceDaoImpl.class); - - private JdbcTemplate jdbcTemplate; - - public ConfigResourceDaoImpl(JdbcTemplate jdbcTemplate) { - this.jdbcTemplate = jdbcTemplate; - } - - @Override - public ConfigResource save(ConfigResource configResource) throws SvcLogicException { - - ConfigResource dbConfigResource = checkConfigResource(configResource); - - if (dbConfigResource != null && StringUtils.isNotBlank(dbConfigResource.getConfigResourceId())) { - configResource.setConfigResourceId(dbConfigResource.getConfigResourceId()); - - validateConfigResource(configResource); - - update(configResource); - - saveConfigResourceAssignmentData(configResource); - } else { - String addQuery = "INSERT INTO CONFIG_RESOURCE " - + "( config_resource_id, resource_id, resource_type, service_template_name, service_template_version," - + "template_name, recipe_name, request_id, resource_data, mask_data, status, created_date, updated_by ) " - + "VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )"; - - configResource.setConfigResourceId(configResource.getUniqueId()); - - validateConfigResource(configResource); - - logger.info("saving config resource ({}) ...", configResource); - jdbcTemplate.update(addQuery, configResource.getConfigResourceId(), configResource.getResourceId(), - configResource.getResourceType(), configResource.getServiceTemplateName(), - configResource.getServiceTemplateVersion(), configResource.getTemplateName(), - configResource.getRecipeName(), configResource.getRequestId(), configResource.getResourceData(), - configResource.getMaskData(), configResource.getStatus(), configResource.getCreatedDate(), - configResource.getUpdatedBy()); - - saveConfigResourceAssignmentData(configResource); - } - dbConfigResource = getConfigResource(configResource); - return dbConfigResource; - } - - private void update(ConfigResource configResource) throws SvcLogicException { - if (StringUtils.isNotBlank(configResource.getConfigResourceId())) { - logger.info("updating config resource ({}) ...", configResource); - // Added service_template_name and version in update query to update with 1802 data. - String updateQuery = "UPDATE CONFIG_RESOURCE SET " - + "resource_data = ?, mask_data = ?, created_date = ?, updated_by = ? ,service_template_name = ?, service_template_version = ? " - + "where config_resource_id = ?"; - - jdbcTemplate.update(updateQuery, configResource.getResourceData(), configResource.getMaskData(), - configResource.getCreatedDate(), configResource.getUpdatedBy(), - configResource.getServiceTemplateName(), configResource.getServiceTemplateVersion(), - configResource.getConfigResourceId()); - } else { - throw new SvcLogicException("missing config resource id to update."); - } - } - - private void saveConfigResourceAssignmentData(ConfigResource configResource) { - if (configResource != null && StringUtils.isNotBlank(configResource.getConfigResourceId())) { - List listOfArguments = new ArrayList<>(); - String deleteQuery = "DELETE FROM CONFIG_RESOURCE_ASSIGNMENT_DATA WHERE config_resource_id = ? "; - listOfArguments.add(configResource.getConfigResourceId()); - this.jdbcTemplate.update(deleteQuery, listOfArguments.toArray()); - logger.info("config resource assignment data deleted successfully for the config_resource_id ({})", - configResource.getConfigResourceId()); - - if (configResource.getResourceAssignments() != null) { - List resourceAssignments = configResource.getResourceAssignments(); - for (ResourceAssignmentData resourceAssignmentData : resourceAssignments) { - if (resourceAssignmentData != null) { - resourceAssignmentData.setConfigResourceId(configResource.getConfigResourceId()); - saveResourceAssignmentData(resourceAssignmentData); - } - } - } - } - } - - private ResourceAssignmentData saveResourceAssignmentData(ResourceAssignmentData resourceAssignmentData) { - String addQuery = "INSERT INTO CONFIG_RESOURCE_ASSIGNMENT_DATA " - + "( config_resource_assignment_data_id, config_resource_id, version, updated_by, template_key_name, " - + "resource_name, data_type, entry_schema, resource_value, source, status, message ) " - + "VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )"; - - logger.debug("saving config resource assignment data ({}) ... ", resourceAssignmentData); - jdbcTemplate.update(addQuery, resourceAssignmentData.getId(), resourceAssignmentData.getConfigResourceId(), - resourceAssignmentData.getVersion(), resourceAssignmentData.getUpdatedBy(), - resourceAssignmentData.getTemplateKeyName(), resourceAssignmentData.getResourceName(), - resourceAssignmentData.getDataType(), resourceAssignmentData.getEntrySchema(), - resourceAssignmentData.getResourceValue(), resourceAssignmentData.getSource(), - resourceAssignmentData.getStatus(), resourceAssignmentData.getMessage()); - - return resourceAssignmentData; - } - - @Override - public void deleteByConfigResource(ConfigResource configResourceInput) throws SvcLogicException { - StringBuilder selectArtifactBuffer = new StringBuilder(); - List listOfArguments = new ArrayList<>(); - - selectArtifactBuffer.append("DELETE FROM CONFIG_RESOURCE WHERE config_resource_id = ? "); - listOfArguments.add(configResourceInput.getConfigResourceId()); - - String queryString = selectArtifactBuffer.toString(); - this.jdbcTemplate.update(queryString, listOfArguments.toArray()); - logger.info("config resource ({}) deleted successfully ", configResourceInput); - } - - @SuppressWarnings("squid:S3776") - @Override - public List findByConfigResource(ConfigResource configResourceInput) throws SvcLogicException { - StringBuilder selectArtifactBuffer = new StringBuilder(); - List listOfArguments = new ArrayList<>(); - - selectArtifactBuffer.append("SELECT * FROM CONFIG_RESOURCE WHERE "); - - StringBuilder whereClauseRemaining = new StringBuilder(); - - if (configResourceInput.getServiceTemplateName() != null) { - if (whereClauseRemaining.length() != 0) { - whereClauseRemaining.append("AND "); - } - whereClauseRemaining.append("service_template_name = ? "); - listOfArguments.add(configResourceInput.getServiceTemplateName()); - } - - if (configResourceInput.getServiceTemplateVersion() != null) { - if (whereClauseRemaining.length() != 0) { - whereClauseRemaining.append("AND "); - } - whereClauseRemaining.append("service_template_version = ? "); - listOfArguments.add(configResourceInput.getServiceTemplateVersion()); - } - - if (configResourceInput.getResourceId() != null) { - if (whereClauseRemaining.length() != 0) { - whereClauseRemaining.append("AND "); - } - whereClauseRemaining.append("resource_id = ? "); - listOfArguments.add(configResourceInput.getResourceId()); - } - - if (configResourceInput.getResourceType() != null) { - if (whereClauseRemaining.length() != 0) { - whereClauseRemaining.append("AND "); - } - whereClauseRemaining.append("resource_type = ? "); - listOfArguments.add(configResourceInput.getResourceType()); - } - - if (configResourceInput.getRequestId() != null) { - if (whereClauseRemaining.length() != 0) { - whereClauseRemaining.append("AND "); - } - whereClauseRemaining.append("request_id = ? "); - listOfArguments.add(configResourceInput.getRequestId()); - } - - if (configResourceInput.getTemplateName() != null) { - if (whereClauseRemaining.length() != 0) { - whereClauseRemaining.append("AND "); - } - whereClauseRemaining.append("template_name = ? "); - listOfArguments.add(configResourceInput.getTemplateName()); - } - - if (configResourceInput.getRecipeName() != null) { - if (whereClauseRemaining.length() != 0) { - whereClauseRemaining.append("AND "); - } - whereClauseRemaining.append("recipe_name = ? "); - listOfArguments.add(configResourceInput.getRecipeName()); - } - - String queryString = selectArtifactBuffer.toString() + whereClauseRemaining.toString(); - logger.info("config resource queryString ({})", queryString); - List configResources = - this.jdbcTemplate.query(queryString, listOfArguments.toArray(), new ConfigResourceMapper()); - - List returnConfigResources = new ArrayList<>(); - - if (configResources != null) { - for (ConfigResource configResource : configResources) { - if (configResource != null) { - returnConfigResources.add(getConfigResource(configResource)); - } - } - } - return returnConfigResources; - } - - public ConfigResource checkConfigResource(ConfigResource configResource) { - StringBuilder selectBuffer = new StringBuilder(); - List listOfArguments = new ArrayList<>(); - - selectBuffer.append( - "SELECT * FROM CONFIG_RESOURCE WHERE resource_id = ? AND resource_type = ? AND template_name = ? "); - listOfArguments.add(configResource.getResourceId()); - listOfArguments.add(configResource.getResourceType()); - listOfArguments.add(configResource.getTemplateName()); - return queryOneForObject(selectBuffer.toString(), listOfArguments.toArray(), new ConfigResourceMapper()); - } - - @Override - public ConfigResource getConfigResource(ConfigResource configResource) throws SvcLogicException { - ConfigResource dbConfigResource = checkConfigResource(configResource); - if (dbConfigResource != null && StringUtils.isNotBlank(dbConfigResource.getConfigResourceId())) { - List resourceAssignments = - getResourceAssignmentdata(dbConfigResource.getConfigResourceId()); - configResource.setResourceAssignments(resourceAssignments); - } - return configResource; - } - - private List getResourceAssignmentdata(String configResourceId) { - List listOfArguments = new ArrayList<>(); - String queryString = "SELECT * FROM CONFIG_RESOURCE_ASSIGNMENT_DATA WHERE config_resource_id = ? "; - logger.info("getResourceAssignmentdata queryString ({}), query inputs ({})", queryString, configResourceId); - listOfArguments.add(configResourceId); - return this.jdbcTemplate.query(queryString, listOfArguments.toArray(), new ResourceAssignmentDataMapper()); - } - - @SuppressWarnings("squid:S3776") - private boolean validateConfigResource(ConfigResource configResource) throws SvcLogicException { - if (configResource == null) { - throw new SvcLogicException("config resource information is missing."); - } - - if (StringUtils.isBlank(configResource.getConfigResourceId())) { - throw new SvcLogicException("config resource id is missing."); - } - - if (StringUtils.isBlank(configResource.getResourceType())) { - throw new SvcLogicException("config resource type is missing."); - } - if (StringUtils.isBlank(configResource.getResourceId())) { - throw new SvcLogicException("config resource resource id is missing."); - } - - if (StringUtils.isBlank(configResource.getRecipeName())) { - throw new SvcLogicException("config resource action name is missing."); - } - - if (StringUtils.isBlank(configResource.getTemplateName())) { - throw new SvcLogicException("config resource template name is missing."); - } - - if (configResource.getResourceAssignments() != null) { - List resourceAssignments = configResource.getResourceAssignments(); - for (ResourceAssignmentData resourceAssignmentData : resourceAssignments) { - if (resourceAssignmentData != null) { - resourceAssignmentData.setConfigResourceId(configResource.getConfigResourceId()); - if (StringUtils.isBlank(resourceAssignmentData.getId())) { - resourceAssignmentData.setId(resourceAssignmentData.getUniqueId()); - } - if (resourceAssignmentData.getVersion() == null || resourceAssignmentData.getVersion() == 0) { - resourceAssignmentData.setVersion(1); - } - if (StringUtils.isBlank(resourceAssignmentData.getUpdatedBy())) { - resourceAssignmentData.setUpdatedBy("System"); - } - if (resourceAssignmentData.getStatus() == null) { - logger.warn("{} status is missing and setting to undefined", resourceAssignmentData); - resourceAssignmentData.setStatus("undefined"); - } - if (resourceAssignmentData.getMessage() == null) { - resourceAssignmentData.setMessage(""); - } - if (resourceAssignmentData.getResourceValue() == null) { - resourceAssignmentData.setResourceValue(""); - } - - validateResourceAssignmentData(resourceAssignmentData); - } - } - } - - return true; - } - - private boolean validateResourceAssignmentData(ResourceAssignmentData resourceAssignmentData) - throws SvcLogicException { - if (resourceAssignmentData == null) { - throw new SvcLogicException("resource assignment data information is missing."); - } - if (StringUtils.isBlank(resourceAssignmentData.getConfigResourceId())) { - throw new SvcLogicException("resource assignment data config resource id is missing."); - } - if (resourceAssignmentData.getVersion() == null) { - throw new SvcLogicException( - String.format("resource assignment data (%s) version is missing", resourceAssignmentData)); - } - if (StringUtils.isBlank(resourceAssignmentData.getTemplateKeyName())) { - throw new SvcLogicException(String.format("resource assignment data (%s) template key name is missing", - resourceAssignmentData)); - } - if (StringUtils.isBlank(resourceAssignmentData.getResourceName())) { - throw new SvcLogicException( - String.format("resource assignment data (%s) resource name is missing", resourceAssignmentData)); - } - if (resourceAssignmentData.getResourceValue() == null) { - throw new SvcLogicException( - String.format("resource assignment data (%s) resource value is missing", resourceAssignmentData)); - } - if (StringUtils.isBlank(resourceAssignmentData.getSource())) { - throw new SvcLogicException( - String.format("resource assignment data (%s) source is missing", resourceAssignmentData)); - } - if (StringUtils.isBlank(resourceAssignmentData.getDataType())) { - throw new SvcLogicException( - String.format("resource assignment data (%s) data type is missing", resourceAssignmentData)); - } - if (StringUtils.isBlank(resourceAssignmentData.getStatus())) { - throw new SvcLogicException( - String.format("resource assignment data (%s) status is missing", resourceAssignmentData)); - } - if (resourceAssignmentData.getMessage() == null) { - throw new SvcLogicException( - String.format("resource assignment data (%s) message is missing", resourceAssignmentData)); - } - return true; - } - - private T queryOneForObject(String sql, Object[] args, RowMapper rowMapper) { - List results = this.jdbcTemplate.query(sql, args, new RowMapperResultSetExtractor(rowMapper, 1)); - if (results != null && !results.isEmpty()) { - return results.get(0); - } else { - return null; - } - } - - class ConfigResourceMapper implements RowMapper { - @Override - public ConfigResource mapRow(ResultSet rs, int rowNum) throws SQLException { - ConfigResource configResource = new ConfigResource(); - configResource.setConfigResourceId(rs.getString("config_resource_id")); - configResource.setResourceId(rs.getString("resource_id")); - configResource.setResourceType(rs.getString("resource_type")); - configResource.setServiceTemplateName(rs.getString("service_template_name")); - configResource.setServiceTemplateVersion(rs.getString("service_template_version")); - configResource.setTemplateName(rs.getString("template_name")); - configResource.setRecipeName(rs.getString("recipe_name")); - configResource.setRequestId(rs.getString("request_id")); - configResource.setResourceData(rs.getString("resource_data")); - configResource.setMaskData(rs.getString("mask_data")); - configResource.setStatus(rs.getString("status")); - configResource.setCreatedDate(rs.getDate("created_date")); - configResource.setUpdatedBy(rs.getString("updated_by")); - return configResource; - } - } - - class ResourceAssignmentDataMapper implements RowMapper { - @Override - public ResourceAssignmentData mapRow(ResultSet rs, int rowNum) throws SQLException { - ResourceAssignmentData resourceAssignmentData = new ResourceAssignmentData(); - resourceAssignmentData.setConfigResourceId(rs.getString("config_resource_id")); - resourceAssignmentData.setDataType(rs.getString("data_type")); - resourceAssignmentData.setEntrySchema(rs.getString("entry_schema")); - resourceAssignmentData.setId(rs.getString("config_resource_assignment_data_id")); - resourceAssignmentData.setMessage(rs.getString("message")); - resourceAssignmentData.setResourceName(rs.getString("resource_name")); - resourceAssignmentData.setResourceValue(rs.getString("resource_value")); - resourceAssignmentData.setSource(rs.getString("source")); - resourceAssignmentData.setStatus(rs.getString("status")); - resourceAssignmentData.setTemplateKeyName(rs.getString("template_key_name")); - resourceAssignmentData.setUpdatedBy(rs.getString("updated_by")); - resourceAssignmentData.setUpdatedDate(rs.getTimestamp("updated_date")); - resourceAssignmentData.setVersion(rs.getInt("version")); - return resourceAssignmentData; - } - } - -} diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/dao/NamedQueryExecutorDao.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/dao/NamedQueryExecutorDao.java deleted file mode 100644 index 7a06e234a..000000000 --- a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/dao/NamedQueryExecutorDao.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.data.adaptor.dao; - -import java.util.List; -import java.util.Map; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; - -public interface NamedQueryExecutorDao { - /** - * Return NamedParameterJdbcTemplate object. - */ - public NamedParameterJdbcTemplate getNamedParameterJdbcTemplate() throws SvcLogicException; - - /** - * Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the - * query, expecting a result list. - *

- * The results will be mapped to a List (one entry for each row) of Maps (one entry for each column, - * using the column name as the key). - * - * @param sql SQL query to execute - * @param param map of parameters to bind to the query (leaving it to the PreparedStatement to guess - * the corresponding SQL type) - * @return a List that contains a Map per row - * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if the query fails - */ - public List> query(String sql, Map parameters) throws SvcLogicException; - - /** - * Issue an update via a prepared statement, binding the given arguments. - * - * @param sql SQL containing named parameters - * @param param map of parameters to bind to the query (leaving it to the PreparedStatement to guess - * the corresponding SQL type) - * @return the number of rows affected - * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if there is any problem issuing the update - */ - public int update(String sql, Map parameters) throws SvcLogicException; - -} diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/dao/NamedQueryExecutorDaoImpl.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/dao/NamedQueryExecutorDaoImpl.java deleted file mode 100644 index ac59c5149..000000000 --- a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/dao/NamedQueryExecutorDaoImpl.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.data.adaptor.dao; - -import java.util.List; -import java.util.Map; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -public class NamedQueryExecutorDaoImpl implements NamedQueryExecutorDao { - private static EELFLogger logger = EELFManager.getInstance().getLogger(QueryExecutorDaoImpl.class); - private static final String CLASS_NAME = "NamedQueryExecutorDaoImpl"; - - @Autowired(required = true) - private NamedParameterJdbcTemplate namedParameterJdbcTemplate; - - public NamedQueryExecutorDaoImpl(NamedParameterJdbcTemplate namedParameterJdbcTemplate) { - this.namedParameterJdbcTemplate = namedParameterJdbcTemplate; - logger.info("{} Constructor initialised..", CLASS_NAME); - } - - @Override - public List> query(String sql, Map parameters) throws SvcLogicException { - logger.debug("Query ({}) with parameters ({})", sql, parameters); - return namedParameterJdbcTemplate.queryForList(sql, parameters); - } - - @Override - public NamedParameterJdbcTemplate getNamedParameterJdbcTemplate() { - return namedParameterJdbcTemplate; - } - - @Override - public int update(String sql, Map parameters) throws SvcLogicException { - logger.debug("update ({}) with parameters ({})", sql, parameters); - return namedParameterJdbcTemplate.update(sql, parameters); - } -} diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/dao/QueryExecutorDao.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/dao/QueryExecutorDao.java deleted file mode 100644 index 9077d09f7..000000000 --- a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/dao/QueryExecutorDao.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.data.adaptor.dao; - -import java.util.List; -import java.util.Map; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; - -public interface QueryExecutorDao { - - /** - * Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the - * query, expecting a result list. - *

- * The results will be mapped to a List (one entry for each row) of Maps (one entry for each column, - * using the column name as the key). Each element in the list will be of the form returned by this - * interface's queryForMap() methods. - * - * @param sql SQL query to execute - * @param data arguments to bind to the query (leaving it to the PreparedStatement to guess the - * corresponding SQL type) - * @return a List that contains a Map per row - * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if the query fails - */ - public List> query(String sql, Object[] data) throws SvcLogicException; - - /** - * Issue a single SQL update operation (such as an insert, update or delete statement) via a - * prepared statement, binding the given arguments. - * - * @param sql SQL containing bind parameters - * @param data arguments to bind to the query (leaving it to the PreparedStatement to guess the - * corresponding SQL type) - * @return the number of rows affected - * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if there is any problem issuing the update - */ - public int update(String sql, Object[] data) throws SvcLogicException; - -} diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/dao/QueryExecutorDaoImpl.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/dao/QueryExecutorDaoImpl.java deleted file mode 100644 index f52c4c50f..000000000 --- a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/dao/QueryExecutorDaoImpl.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.data.adaptor.dao; - -import java.util.List; -import java.util.Map; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.jdbc.core.JdbcTemplate; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -public class QueryExecutorDaoImpl implements QueryExecutorDao { - - private static EELFLogger logger = EELFManager.getInstance().getLogger(QueryExecutorDaoImpl.class); - private static final String CLASS_NAME = "QueryExecutorDaoImpl"; - - @Autowired(required = true) - private JdbcTemplate jdbcTemplate; - - public QueryExecutorDaoImpl(JdbcTemplate jdbcTemplate) { - this.jdbcTemplate = jdbcTemplate; - logger.info("{} Constructor initialised..", CLASS_NAME); - } - - @Override - public List> query(String sql, Object[] data) throws SvcLogicException { - logger.debug("Query ({}) with data ({})", sql, data); - return jdbcTemplate.queryForList(sql, data); - } - - @Override - public int update(String sql, Object[] data) throws SvcLogicException { - logger.debug("Query ({}) with data ({})", sql, data); - return jdbcTemplate.update(sql, data); - } - -} diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/dao/TransactionLogDao.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/dao/TransactionLogDao.java deleted file mode 100644 index c0381a989..000000000 --- a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/dao/TransactionLogDao.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.data.adaptor.dao; - -import java.util.List; -import org.onap.ccsdk.features.data.adaptor.domain.TransactionLog; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; - -public interface TransactionLogDao { - - /** - * Issue a single SQL Insert operation for CONFIG_TRANSACTION_LOG table via a prepared statement, - * binding the given arguments. - * - * @param transactionLog arguments to bind to the query (mapping it to the PreparedStatement to the - * corresponding SQL type) - * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if there is any problem issuing the insert - */ - public void save(TransactionLog transactionLog) throws SvcLogicException; - - /** - * Query CONFIG_TRANSACTION_LOG table for given request_id, mapping each row to a Java object via a - * TransactionLog RowMapper. - * - * @param requestId argument to bind to the query (leaving it to the PreparedStatement to guess the - * corresponding SQL type) - * @return the result List, containing mapped objects - * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if the query fails - */ - public List getTransactionsByRequestId(String requestId) throws SvcLogicException; - - /** - * Query CONFIG_TRANSACTION_LOG table for given request_id, mapping each row to a Java object via a - * TransactionLog RowMapper. - * - * @param requestId argument to bind to the query (leaving it to the PreparedStatement to guess the - * corresponding SQL type) - * @param messageType argument to bind to the query (leaving it to the PreparedStatement to guess - * the corresponding SQL type) - * @return the result List, containing mapped objects - * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if the query fails - */ - public List getTransactionsByRequestId(String requestId, String messageType) - throws SvcLogicException; - -} diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/dao/TransactionLogDaoImpl.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/dao/TransactionLogDaoImpl.java deleted file mode 100644 index ea6567e1e..000000000 --- a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/dao/TransactionLogDaoImpl.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.data.adaptor.dao; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.List; -import org.apache.commons.lang3.StringUtils; -import org.onap.ccsdk.features.data.adaptor.domain.TransactionLog; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.jdbc.core.RowMapper; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -public class TransactionLogDaoImpl implements TransactionLogDao { - - private static EELFLogger logger = EELFManager.getInstance().getLogger(TransactionLogDaoImpl.class); - - private JdbcTemplate jdbcTemplate; - - public TransactionLogDaoImpl(JdbcTemplate jdbcTemplate) { - this.jdbcTemplate = jdbcTemplate; - } - - @Override - public void save(TransactionLog transactionLog) throws SvcLogicException { - if (transactionLog != null && StringUtils.isNotBlank(transactionLog.getRequestId())) { - String addSql = - "INSERT INTO CONFIG_TRANSACTION_LOG ( config_transaction_log_id, request_id, message_type, message ) VALUES (?, ?, ?, ?) "; - jdbcTemplate.update(addSql, transactionLog.getUniqueId(), transactionLog.getRequestId(), - transactionLog.getMessageType(), transactionLog.getMessage()); - logger.trace("TransactionLog Updated Successfully for message_type {}", transactionLog.getMessageType()); - } - - } - - @Override - public List getTransactionsByRequestId(String requestId) throws SvcLogicException { - if (StringUtils.isNotBlank(requestId)) { - String selectByRequestIdSql = - "SELECT * FROM CONFIG_TRANSACTION_LOG WHERE request_id = ? ORDER BY creation_date DESC"; - return this.jdbcTemplate.query(selectByRequestIdSql, new Object[] {requestId}, new TransactionLogMapper()); - } else { - throw new SvcLogicException("TransactionLog Request id (" + requestId + ")is missing "); - } - } - - @Override - public List getTransactionsByRequestId(String requestId, String messageType) - throws SvcLogicException { - if (StringUtils.isNotBlank(requestId)) { - String selectByRequestIdSql = - "SELECT * FROM CONFIG_TRANSACTION_LOG WHERE request_id = ? and message_type = ? ORDER BY creation_date DESC"; - return this.jdbcTemplate.query(selectByRequestIdSql, new Object[] {requestId, messageType}, - new TransactionLogMapper()); - } else { - throw new SvcLogicException("TransactionLog Request id (" + requestId + ")is missing "); - } - } - - private static final class TransactionLogMapper implements RowMapper { - @Override - public TransactionLog mapRow(ResultSet rs, int rowNum) throws SQLException { - TransactionLog transactionLog = new TransactionLog(); - transactionLog.setCreationDate(rs.getDate("creation_date")); - transactionLog.setMessage(rs.getString("message")); - transactionLog.setMessageType(rs.getString("message_type")); - transactionLog.setRequestId(rs.getString("request_id")); - transactionLog.setTransactionLogId(rs.getString("config_transaction_log_id")); - return transactionLog; - } - } - -} diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/db/DataSourceWrap.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/db/DataSourceWrap.java deleted file mode 100644 index 5ec3eddca..000000000 --- a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/db/DataSourceWrap.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.data.adaptor.db; - -import java.io.PrintWriter; -import java.sql.Connection; -import java.sql.SQLException; -import java.sql.SQLFeatureNotSupportedException; -import javax.sql.DataSource; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -public class DataSourceWrap implements DataSource { - - private static EELFLogger logger = EELFManager.getInstance().getLogger(DataSourceWrap.class); - - private DataSource dataSource; - - public DataSourceWrap(DataSource dataSource) { - logger.info("Setting Data Source {} ", dataSource); - this.dataSource = dataSource; - } - - @Override - public PrintWriter getLogWriter() throws SQLException { - return dataSource.getLogWriter(); - } - - @Override - public void setLogWriter(PrintWriter out) throws SQLException { - dataSource.setLogWriter(out); - } - - @Override - public void setLoginTimeout(int seconds) throws SQLException { - dataSource.setLoginTimeout(seconds); - } - - @Override - public int getLoginTimeout() throws SQLException { - return dataSource.getLoginTimeout(); - } - - @Override - public java.util.logging.Logger getParentLogger() throws SQLFeatureNotSupportedException { - return dataSource.getParentLogger(); - } - - @Override - public T unwrap(Class iface) throws SQLException { - return dataSource.unwrap(iface); - } - - @Override - public boolean isWrapperFor(Class iface) throws SQLException { - return dataSource.isWrapperFor(iface); - } - - @SuppressWarnings("squid:S2095") - @Override - public Connection getConnection() throws SQLException { - Connection c = dataSource.getConnection(); - logger.trace("getConnection: ({})", c.getClass().getName()); - c.setAutoCommit(true); - return c; - } - - @SuppressWarnings("squid:S2095") - @Override - public Connection getConnection(String username, String pass) throws SQLException { - Connection c = dataSource.getConnection(username, pass); - c.setAutoCommit(true); - return c; - } - -} diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/domain/ConfigResource.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/domain/ConfigResource.java deleted file mode 100644 index 501027021..000000000 --- a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/domain/ConfigResource.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.data.adaptor.domain; - -import java.io.Serializable; -import java.util.Date; -import java.util.List; -import java.util.UUID; - -public class ConfigResource implements Serializable { - /** - * - */ - private static final long serialVersionUID = 1L; - - private String configResourceId; - private String resourceId; - private String resourceType; - private String serviceTemplateName; - private String serviceTemplateVersion; - private String templateName; - private String recipeName; - private String requestId; - private String resourceData; - private String maskData; - private Date createdDate = new Date(); - private String status; - private String updatedBy; - private List resourceAssignments; - - public String getConfigResourceId() { - return configResourceId; - } - - public void setConfigResourceId(String configResourceId) { - this.configResourceId = configResourceId; - } - - public String getResourceId() { - return resourceId; - } - - public void setResourceId(String resourceId) { - this.resourceId = resourceId; - } - - public String getResourceType() { - return resourceType; - } - - public void setResourceType(String resourceType) { - this.resourceType = resourceType; - } - - public String getServiceTemplateName() { - return serviceTemplateName; - } - - public void setServiceTemplateName(String serviceTemplateName) { - this.serviceTemplateName = serviceTemplateName; - } - - public String getServiceTemplateVersion() { - return serviceTemplateVersion; - } - - public void setServiceTemplateVersion(String serviceTemplateVersion) { - this.serviceTemplateVersion = serviceTemplateVersion; - } - - public String getTemplateName() { - return templateName; - } - - public void setTemplateName(String templateName) { - this.templateName = templateName; - } - - public String getRecipeName() { - return recipeName; - } - - public void setRecipeName(String recipeName) { - this.recipeName = recipeName; - } - - public String getRequestId() { - return requestId; - } - - public void setRequestId(String requestId) { - this.requestId = requestId; - } - - public String getResourceData() { - return resourceData; - } - - public void setResourceData(String resourceData) { - this.resourceData = resourceData; - } - - public String getMaskData() { - return maskData; - } - - public void setMaskData(String maskData) { - this.maskData = maskData; - } - - public Date getCreatedDate() { - return createdDate; - } - - public void setCreatedDate(Date createdDate) { - this.createdDate = createdDate; - } - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } - - public String getUpdatedBy() { - return updatedBy; - } - - public void setUpdatedBy(String updatedBy) { - this.updatedBy = updatedBy; - } - - public List getResourceAssignments() { - return resourceAssignments; - } - - public void setResourceAssignments(List resourceAssignments) { - this.resourceAssignments = resourceAssignments; - } - - @Override - public String toString() { - return "ConfigResource [configResourceId=" + configResourceId + ", resourceId=" + resourceId - + ", serviceTemplateName=" + serviceTemplateName + ", serviceTemplateVersion=" + serviceTemplateVersion - + ", resourceType=" + resourceType + ", templateName=" + templateName + ", recipeName=" + recipeName - + ", requestId=" + requestId + ", resourceData= ******** , maskData=" + maskData + ", createdDate=" - + createdDate + ", updatedBy=" + updatedBy + "]"; - } - - public String getUniqueId() { - return UUID.randomUUID().toString(); - } - -} diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/domain/ResourceAssignmentData.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/domain/ResourceAssignmentData.java deleted file mode 100644 index 45e83c27e..000000000 --- a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/domain/ResourceAssignmentData.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.data.adaptor.domain; - -import java.io.Serializable; -import java.util.Date; -import java.util.UUID; - -public class ResourceAssignmentData implements Serializable { - - private static final long serialVersionUID = 1L; - private String id; - private String configResourceId; - private Integer version; - private Date updatedDate = new Date(); - private String updatedBy; - private String templateKeyName; - private String resourceName; - private String dataType; - private String entrySchema; - private String resourceValue; - private String source; - private String status; - private String message; - - public String getUniqueId() { - return UUID.randomUUID().toString(); - } - - @Override - public String toString() { - return "ResourceAssignmentData [id=" + id + ", configResourceId=" + configResourceId + ", version=" + version - + ", updatedDate=" + updatedDate + ", updatedBy=" + updatedBy + ", templateKeyName=" + templateKeyName - + ", resourceName=" + resourceName + ", dataType=" + dataType + ", source=" + source + ", status=" - + status + "]"; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getConfigResourceId() { - return configResourceId; - } - - public void setConfigResourceId(String configResourceId) { - this.configResourceId = configResourceId; - } - - public Integer getVersion() { - return version; - } - - public void setVersion(Integer version) { - this.version = version; - } - - public Date getUpdatedDate() { - return updatedDate; - } - - public void setUpdatedDate(Date updatedDate) { - this.updatedDate = updatedDate; - } - - public String getUpdatedBy() { - return updatedBy; - } - - public void setUpdatedBy(String updatedBy) { - this.updatedBy = updatedBy; - } - - public String getTemplateKeyName() { - return templateKeyName; - } - - public void setTemplateKeyName(String templateKeyName) { - this.templateKeyName = templateKeyName; - } - - public String getResourceName() { - return resourceName; - } - - public void setResourceName(String resourceName) { - this.resourceName = resourceName; - } - - public String getDataType() { - return dataType; - } - - public void setDataType(String dataType) { - this.dataType = dataType; - } - - public String getEntrySchema() { - return entrySchema; - } - - public void setEntrySchema(String entrySchema) { - this.entrySchema = entrySchema; - } - - public String getResourceValue() { - return resourceValue; - } - - public void setResourceValue(String resourceValue) { - this.resourceValue = resourceValue; - } - - public String getSource() { - return source; - } - - public void setSource(String source) { - this.source = source; - } - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - -} diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/domain/TransactionLog.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/domain/TransactionLog.java deleted file mode 100644 index f45fdc64c..000000000 --- a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/domain/TransactionLog.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.data.adaptor.domain; - -import java.io.Serializable; -import java.util.Date; -import java.util.UUID; - -public class TransactionLog implements Serializable { - private static final long serialVersionUID = 1L; - - private String transactionLogId; - private String requestId; - private String messageType; - private Date creationDate; - private String message; - - public TransactionLog() { - - } - - public TransactionLog(String requestId, String messageType, String message) { - this.requestId = requestId; - this.messageType = messageType; - this.message = message; - } - - @Override - public String toString() { - StringBuilder buffer = new StringBuilder("["); - buffer.append("transactionLogId =" + transactionLogId); - buffer.append(", requestId =" + requestId); - buffer.append(", messageType =" + messageType); - buffer.append(", creationDate =" + creationDate); - buffer.append("]"); - return buffer.toString(); - } - - public String getTransactionLogId() { - return transactionLogId; - } - - public void setTransactionLogId(String transactionLogId) { - this.transactionLogId = transactionLogId; - } - - public String getRequestId() { - return requestId; - } - - public void setRequestId(String requestId) { - this.requestId = requestId; - } - - public String getMessageType() { - return messageType; - } - - public void setMessageType(String messageType) { - this.messageType = messageType; - } - - public Date getCreationDate() { - return creationDate; - } - - public void setCreationDate(Date creationDate) { - this.creationDate = creationDate; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - public String getUniqueId() { - return UUID.randomUUID().toString(); - } - -} diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/service/ConfigResourceNode.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/service/ConfigResourceNode.java deleted file mode 100644 index 2eca20731..000000000 --- a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/service/ConfigResourceNode.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.data.adaptor.service; - -import java.util.Map; -import org.apache.commons.lang3.StringUtils; -import org.onap.ccsdk.features.data.adaptor.DataAdaptorConstants; -import org.onap.ccsdk.features.data.adaptor.domain.TransactionLog; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; - -public class ConfigResourceNode implements SvcLogicJavaPlugin { - - private ConfigResourceService configResourceService; - - public ConfigResourceNode(ConfigResourceService configResourceService) { - this.configResourceService = configResourceService; - } - - public void saveConfigTransactionLog(Map inParams, SvcLogicContext ctx) throws SvcLogicException { - String responsePrefix = inParams.get(DataAdaptorConstants.INPUT_PARAM_RESPONSE_PRIFIX); - try { - responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix + ".") : ""; - - String messageType = inParams.get(DataAdaptorConstants.INPUT_PARAM_MESSAGE_TYPE); - String message = inParams.get(DataAdaptorConstants.INPUT_PARAM_MESSAGE); - String requestId = ctx.getAttribute("request-id"); - - TransactionLog transactionLog = new TransactionLog(); - - transactionLog.setMessage(message); - transactionLog.setMessageType(messageType); - transactionLog.setRequestId(requestId); - - configResourceService.save(transactionLog); - - } catch (Exception e) { - ctx.setAttribute(responsePrefix + DataAdaptorConstants.OUTPUT_PARAM_STATUS, - DataAdaptorConstants.OUTPUT_STATUS_FAILURE); - ctx.setAttribute(responsePrefix + DataAdaptorConstants.OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage()); - throw new SvcLogicException("Failed in saveConfigTransactionLog :" + e.getMessage()); - } - } - -} diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/service/ConfigResourceService.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/service/ConfigResourceService.java deleted file mode 100644 index cbd9e9279..000000000 --- a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/service/ConfigResourceService.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.data.adaptor.service; - -import java.util.List; -import java.util.Map; -import org.onap.ccsdk.features.data.adaptor.domain.ConfigResource; -import org.onap.ccsdk.features.data.adaptor.domain.TransactionLog; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; - -public interface ConfigResourceService { - - /** - * Return NamedParameterJdbcTemplate object. - */ - public NamedParameterJdbcTemplate getNamedParameterJdbcTemplate() throws SvcLogicException; - - /** - * Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the - * query, expecting a result list. - *

- * The results will be mapped to a List (one entry for each row) of Maps (one entry for each column, - * using the column name as the key). - * - * @param sql SQL query to execute - * @param param map of parameters to bind to the query (leaving it to the PreparedStatement to guess - * the corresponding SQL type) - * @return a List that contains a Map per row - * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if the query fails - */ - public List> query(String sql, Map param) throws SvcLogicException; - - /** - * Issue an update via a prepared statement, binding the given arguments. - * - * @param sql SQL containing named parameters - * @param param map of parameters to bind to the query (leaving it to the PreparedStatement to guess - * the corresponding SQL type) - * @return the number of rows affected - * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if there is any problem issuing the update - */ - public int update(String sql, Map param) throws SvcLogicException; - - /** - * Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the - * query, expecting a result list. - *

- * The results will be mapped to a List (one entry for each row) of Maps (one entry for each column, - * using the column name as the key). - * - * @param sql SQL query to execute - * @param data arguments to bind to the query (leaving it to the PreparedStatement to guess the - * corresponding SQL type) - * @return a List that contains a Map per row - * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if the query fails - */ - public List> query(String sql, Object[] data) throws SvcLogicException; - - /** - * Issue a single SQL update operation (such as an insert, update or delete statement) via a - * prepared statement, binding the given arguments. - * - * @param sql SQL containing bind parameters - * @param data arguments to bind to the query (leaving it to the PreparedStatement to guess the - * corresponding SQL type) - * @return the number of rows affected - * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if there is any problem issuing the update - */ - public int update(String sql, Object[] data) throws SvcLogicException; - - /** - * Issue a single SQL Insert operation for CONFIG_TRANSACTION_LOG table via a prepared statement, - * binding the given arguments. - * - * @param transactionLog arguments to bind to the query (mapping it to the PreparedStatement to the - * corresponding SQL type) - * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if there is any problem issuing the insert - */ - public void save(TransactionLog transactionLog) throws SvcLogicException; - - /** - * Query CONFIG_TRANSACTION_LOG table for given request_id, mapping each row to a Java object via a - * TransactionLog RowMapper. - * - * @param requestId argument to bind to the query (leaving it to the PreparedStatement to guess the - * corresponding SQL type) - * @return the result List, containing mapped objects - * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if the query fails - */ - public List getTransactionsByRequestId(String requestId) throws SvcLogicException; - - /** - * Query CONFIG_RESOURCE table for given input param to create a prepared statement to bind to the - * query, mapping each row to a Java object via a ConfigResource RowMapper. - * - * @param configResource argument to bind to the query (mapping it to the PreparedStatement to the - * corresponding SQL type) - * @return the result List, containing mapped objects - * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if the query fails - */ - public List getConfigResource(ConfigResource configResource) throws SvcLogicException; - - /** - * Issue a single SQL update operation (insert or update statement) for CONFIG_RESOURCE table via a - * prepared statement, binding the given arguments. - * - * @param configResource arguments to bind to the query (mapping it to the PreparedStatement to the - * corresponding SQL type) - * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if there is any problem issuing the insert - */ - public ConfigResource saveConfigResource(ConfigResource configResource) throws SvcLogicException; - - /** - * Query CONFIG_TRANSACTION_LOG table for given request_id, mapping each row to a Java object via a - * TransactionLog RowMapper. - * - * @param requestId argument to bind to the query (leaving it to the PreparedStatement to guess the - * corresponding SQL type) - * @param messageType argument to bind to the query (leaving it to the PreparedStatement to guess - * the corresponding SQL type) - * @return the result List, containing mapped objects - * @throws org.onap.ccsdk.sli.core.sli.SvcLogicException if the query fails - */ - public List getTransactionsByRequestId(String requestId, String messageType) - throws SvcLogicException; - -} diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/service/ConfigResourceServiceImpl.java b/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/service/ConfigResourceServiceImpl.java deleted file mode 100644 index ab24f16c7..000000000 --- a/blueprints-processor/adaptors/data-adaptor-provider/src/main/java/org/onap/ccsdk/features/data/adaptor/service/ConfigResourceServiceImpl.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.data.adaptor.service; - -import java.util.List; -import java.util.Map; -import org.onap.ccsdk.features.data.adaptor.dao.ConfigResourceDao; -import org.onap.ccsdk.features.data.adaptor.dao.NamedQueryExecutorDao; -import org.onap.ccsdk.features.data.adaptor.dao.QueryExecutorDao; -import org.onap.ccsdk.features.data.adaptor.dao.TransactionLogDao; -import org.onap.ccsdk.features.data.adaptor.domain.ConfigResource; -import org.onap.ccsdk.features.data.adaptor.domain.TransactionLog; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -public class ConfigResourceServiceImpl implements ConfigResourceService { - private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigResourceServiceImpl.class); - private static final String CLASS_NAME = "ConfigResourceServiceImpl"; - - private TransactionLogDao transactionLogDao; - private ConfigResourceDao configResourceDao; - private QueryExecutorDao queryExecutorDao; - private NamedQueryExecutorDao namedQueryExecutorDao; - - @SuppressWarnings("squid:S00107") - public ConfigResourceServiceImpl(TransactionLogDao transactionLogDao, ConfigResourceDao configResourceDao, - QueryExecutorDao queryExecutorDao, NamedQueryExecutorDao namedQueryExecutorDao) { - - logger.info("{} Constuctor Initated...", CLASS_NAME); - this.transactionLogDao = transactionLogDao; - this.configResourceDao = configResourceDao; - this.queryExecutorDao = queryExecutorDao; - this.namedQueryExecutorDao = namedQueryExecutorDao; - } - - @Override - public NamedParameterJdbcTemplate getNamedParameterJdbcTemplate() throws SvcLogicException { - return namedQueryExecutorDao.getNamedParameterJdbcTemplate(); - } - - @Override - public List> query(String sql, Map parameters) throws SvcLogicException { - return namedQueryExecutorDao.query(sql, parameters); - } - - @Override - public int update(String sql, Map parameters) throws SvcLogicException { - return namedQueryExecutorDao.update(sql, parameters); - } - - @Override - public List> query(String sql, Object[] data) throws SvcLogicException { - return queryExecutorDao.query(sql, data); - } - - @Override - public int update(String sql, Object[] data) throws SvcLogicException { - return queryExecutorDao.update(sql, data); - } - - @Override - public void save(TransactionLog transactionLog) throws SvcLogicException { - transactionLogDao.save(transactionLog); - } - - @Override - public List getTransactionsByRequestId(String requestId) throws SvcLogicException { - return transactionLogDao.getTransactionsByRequestId(requestId); - } - - @Override - public List getTransactionsByRequestId(String requestId, String messageType) - throws SvcLogicException { - return transactionLogDao.getTransactionsByRequestId(requestId, messageType); - } - - @Override - public List getConfigResource(ConfigResource configResource) throws SvcLogicException { - return configResourceDao.findByConfigResource(configResource); - } - - @Override - public ConfigResource saveConfigResource(ConfigResource configResource) throws SvcLogicException { - return configResourceDao.save(configResource); - } - -} diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/resources/OSGI-INF/blueprint/impl-blueprint.xml b/blueprints-processor/adaptors/data-adaptor-provider/src/main/resources/OSGI-INF/blueprint/impl-blueprint.xml deleted file mode 100644 index 76459d51d..000000000 --- a/blueprints-processor/adaptors/data-adaptor-provider/src/main/resources/OSGI-INF/blueprint/impl-blueprint.xml +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml b/blueprints-processor/adaptors/data-adaptor-provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml deleted file mode 100644 index 76459d51d..000000000 --- a/blueprints-processor/adaptors/data-adaptor-provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/main/resources/sql/001_init_ddl.sql b/blueprints-processor/adaptors/data-adaptor-provider/src/main/resources/sql/001_init_ddl.sql deleted file mode 100644 index efcd415e3..000000000 --- a/blueprints-processor/adaptors/data-adaptor-provider/src/main/resources/sql/001_init_ddl.sql +++ /dev/null @@ -1,96 +0,0 @@ --- ----------------------------------------------------- --- Dropping tables ( One time ) --- ----------------------------------------------------- - -DROP TABLE sdnctl.CONFIG_RESOURCE_ASSIGNMENT_DATA; -DROP TABLE sdnctl.CONFIG_RESOURCE; -DROP TABLE sdnctl.CONFIG_RESOURCE_RELATION; -DROP TABLE sdnctl.CONFIG_TRANSACTION_LOG - - --- ----------------------------------------------------- --- table sdnctl.CONFIG_TRANSACTION_LOG --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS sdnctl.CONFIG_TRANSACTION_LOG ( - config_transaction_log_id VARCHAR(50) NOT NULL, - request_id VARCHAR(50) NULL DEFAULT NULL, - message_type VARCHAR(100) NULL DEFAULT NULL, - creation_date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - message LONGTEXT NULL DEFAULT NULL, - PRIMARY KEY PK_CONFIG_TRANSACTION_LOG (config_transaction_log_id) - ) ENGINE=InnoDB DEFAULT CHARSET=latin1; - - --- ----------------------------------------------------- --- table sdnctl.CONFIG_RESOURCE --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS sdnctl.CONFIG_RESOURCE ( - config_resource_id VARCHAR(50) NOT NULL, - resource_id VARCHAR(50) NOT NULL, - resource_type VARCHAR(50) NOT NULL, - service_template_name VARCHAR(50) NULL DEFAULT NULL, - service_template_version VARCHAR(50) NULL DEFAULT NULL, - template_name VARCHAR(50) NOT NULL, - recipe_name VARCHAR(50) NOT NULL, - request_id VARCHAR(50) NOT NULL, - resource_data LONGTEXT NULL DEFAULT NULL, - mask_data LONGTEXT NULL DEFAULT NULL, - created_date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - status VARCHAR(20) NOT NULL, - updated_by VARCHAR(50) NOT NULL, - PRIMARY KEY PK_CONFIG_RESOURCE (config_resource_id), - INDEX IX_CONFIG_RESOURCE (created_date desc) - ) ENGINE=InnoDB DEFAULT CHARSET=latin1; - - --- ----------------------------------------------------- --- table sdnctl.CONFIG_RESOURCE_RELATION --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS sdnctl.CONFIG_RESOURCE_RELATION ( - config_resource_relation_id VARCHAR(50) NOT NULL, - resource_id VARCHAR(50) NOT NULL, - related_resource_id VARCHAR(50) NOT NULL, - relation_type VARCHAR(50) NOT NULL DEFAULT 'children', - created_date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_by VARCHAR(50) NOT NULL, - PRIMARY KEY PK_CONFIG_RESOURCE_RELATION (config_resource_relation_id), - INDEX IX_CONFIG_RESOURCE_RELATION (created_date desc), - CONSTRAINT FK_CONFIG_RESOURCE_RELATION_TO_CONFIG_RESOURCE1 - FOREIGN KEY (resource_id) - REFERENCES sdnctl.CONFIG_RESOURCE (config_resource_id) - ON DELETE NO ACTION - ON UPDATE NO ACTION, - CONSTRAINT FK_CONFIG_RESOURCE_RELATION_TO_CONFIG_RESOURCE2 - FOREIGN KEY (related_resource_id) - REFERENCES sdnctl.CONFIG_RESOURCE (config_resource_id) - ON DELETE NO ACTION - ON UPDATE NO ACTION - ) ENGINE=InnoDB DEFAULT CHARSET=latin1; - - --- ----------------------------------------------------- --- table sdnctl.CONFIG_RESOURCE_ASSIGNMENT_DATA --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS sdnctl.CONFIG_RESOURCE_ASSIGNMENT_DATA ( - config_resource_assignment_data_id VARCHAR(50) NOT NULL, - config_resource_id VARCHAR(50) NOT NULL, - version INT(11) NOT NULL, - updated_date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_by VARCHAR(50) NOT NULL, - template_key_name VARCHAR(50) NOT NULL, - resource_name VARCHAR(50) NOT NULL, - data_type VARCHAR(100) NOT NULL, - entry_schema VARCHAR(100) NULL DEFAULT NULL, - resource_value LONGTEXT NOT NULL, - source VARCHAR(50) NOT NULL, - status VARCHAR(50) NOT NULL, - message LONGTEXT NOT NULL, - PRIMARY KEY PK_CONFIG_RESOURCE (config_resource_assignment_data_id), - INDEX IX_CONFIG_RESOURCE (updated_date desc), - CONSTRAINT FK_CONFIG_RESOURCE_ASSIGNMENT_DATA - FOREIGN KEY (config_resource_id) - REFERENCES sdnctl.CONFIG_RESOURCE (config_resource_id) - ON DELETE NO ACTION - ON UPDATE NO ACTION - ) ENGINE=InnoDB DEFAULT CHARSET=latin1; - diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/test/java/org/onap/ccsdk/features/data/adaptor/dao/ConfigResourceDaoTest.java b/blueprints-processor/adaptors/data-adaptor-provider/src/test/java/org/onap/ccsdk/features/data/adaptor/dao/ConfigResourceDaoTest.java deleted file mode 100644 index 99b0c0b7e..000000000 --- a/blueprints-processor/adaptors/data-adaptor-provider/src/test/java/org/onap/ccsdk/features/data/adaptor/dao/ConfigResourceDaoTest.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.data.adaptor.dao; - -import java.nio.charset.Charset; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import org.apache.commons.io.IOUtils; -import org.junit.Assert; -import org.junit.Before; -import org.junit.FixMethodOrder; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.MethodSorters; -import org.onap.ccsdk.features.data.adaptor.domain.ConfigResource; -import org.onap.ccsdk.features.data.adaptor.domain.ResourceAssignmentData; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = {"classpath:test-context-h2db.xml"}) -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class ConfigResourceDaoTest { - - private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigResourceDaoTest.class); - - @Autowired - private ConfigResourceDao configResourceDao; - - @Before - public void initialise() { - - } - - @Test - public void testAssignmentResourceData() throws Exception { - ConfigResource configResource = new ConfigResource(); - String resourceData = IOUtils.toString( - ConfigResourceDaoTest.class.getClassLoader().getResourceAsStream("reference/resource_data.json"), - Charset.defaultCharset()); - - logger.trace("resourceData = " + resourceData); - configResource.setResourceData(resourceData); - configResource.setServiceTemplateName("sample-name"); - configResource.setServiceTemplateVersion("1.0.0"); - configResource.setResourceId("123456"); - configResource.setResourceType("vUSP - vDBE-IPX HUB"); - configResource.setRequestId("123456"); - configResource.setRecipeName("activate-action"); - configResource.setTemplateName("vrr-service-template"); - configResource.setMaskData(null); - configResource.setStatus("success"); - configResource.setCreatedDate(new Date(System.currentTimeMillis())); - configResource.setUpdatedBy("an188a"); - - List resourceAssignments = new ArrayList<>(); - ResourceAssignmentData resourceAssignmentData = new ResourceAssignmentData(); - resourceAssignmentData.setDataType("string"); - resourceAssignmentData.setStatus("success"); - resourceAssignmentData.setMessage("success"); - resourceAssignmentData.setTemplateKeyName("sample"); - resourceAssignmentData.setResourceName("sample"); - // resourceAssignmentData.setResourceValue("sample123"); - resourceAssignmentData.setSource("input"); - resourceAssignments.add(resourceAssignmentData); - configResource.setResourceAssignments(resourceAssignments); - - ConfigResource dbConfigResource = configResourceDao.save(configResource); - logger.info("Saved sucessfully : " + dbConfigResource.toString()); - Assert.assertNotNull("ConfigResource is null", dbConfigResource); - Assert.assertNotNull("Resource Assignment Data is null", dbConfigResource.getResourceAssignments()); - Assert.assertEquals("Resource Assignment Data count missmatch", true, - dbConfigResource.getResourceAssignments().size() > 0); - } - - @Test - public void testConfigResourcesData() throws Exception { - ConfigResource configResourceInput = new ConfigResource(); - configResourceInput.setResourceId("123456"); - List dbConfigResources = configResourceDao.findByConfigResource(configResourceInput); - Assert.assertNotNull("ConfigResources is null", dbConfigResources); - Assert.assertEquals("ConfigResources size missmatch", true, dbConfigResources.size() > 0); - - for (ConfigResource configResource : dbConfigResources) { - Assert.assertNotNull("ConfigResources Assignments is null", configResource.getResourceAssignments()); - Assert.assertTrue("ConfigResources Assignments size miss mathch ", - configResource.getResourceAssignments().size() > 0); - logger.trace("ResourceAssignments = " + configResource.getResourceAssignments()); - } - } - - @Test - public void testDeleteByConfigResource() throws Exception { - ConfigResource configResourceInput = new ConfigResource(); - configResourceInput.setResourceId("123456"); - - List dbConfigResources = configResourceDao.findByConfigResource(configResourceInput); - Assert.assertTrue("ConfigResources is null", !dbConfigResources.isEmpty()); - - configResourceInput.setConfigResourceId(dbConfigResources.get(0).getConfigResourceId()); - configResourceDao.deleteByConfigResource(configResourceInput); - - dbConfigResources = configResourceDao.findByConfigResource(configResourceInput); - Assert.assertTrue("ConfigResources is not null", dbConfigResources.isEmpty()); - } -} diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/test/java/org/onap/ccsdk/features/data/adaptor/dao/ConfigTransactionLogDaoTest.java b/blueprints-processor/adaptors/data-adaptor-provider/src/test/java/org/onap/ccsdk/features/data/adaptor/dao/ConfigTransactionLogDaoTest.java deleted file mode 100644 index 38cd1b20d..000000000 --- a/blueprints-processor/adaptors/data-adaptor-provider/src/test/java/org/onap/ccsdk/features/data/adaptor/dao/ConfigTransactionLogDaoTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.data.adaptor.dao; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.junit.Assert; -import org.junit.Before; -import org.junit.FixMethodOrder; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.MethodSorters; -import org.onap.ccsdk.features.data.adaptor.DataAdaptorConstants; -import org.onap.ccsdk.features.data.adaptor.domain.TransactionLog; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = {"classpath:test-context-h2db.xml"}) -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class ConfigTransactionLogDaoTest { - private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigTransactionLogDaoTest.class); - - @Autowired - private TransactionLogDao transactionLogDao; - - @Autowired - private NamedQueryExecutorDao namedQueryExecutorDao; - - @Before - public void initialise() { - - } - - @Test - public void testQueryExecution() throws Exception { - String requestId = "12345"; - - transactionLogDao - .save(new TransactionLog(requestId, DataAdaptorConstants.LOG_MESSAGE_TYPE_LOG, "Received Request")); - - List result = transactionLogDao.getTransactionsByRequestId(requestId); - logger.info("DB ArtifactReference :" + result); - Assert.assertNotNull("Failed to get Query Result", result); - - List result2 = - transactionLogDao.getTransactionsByRequestId(requestId, DataAdaptorConstants.LOG_MESSAGE_TYPE_LOG); - logger.info("DB ArtifactReference :" + result2); - Assert.assertNotNull("Failed to get Query Result", result2); - - String namedsql = "SELECT * FROM CONFIG_TRANSACTION_LOG WHERE request_id = :request_id"; - Map parameters = new HashMap<>(); - parameters.put("request_id", "12345"); - List> namedresult = namedQueryExecutorDao.query(namedsql, parameters); - logger.info("DB ArtifactReference :" + namedresult); - Assert.assertNotNull("Failed to get Query Result", namedresult); - - } - -} diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/test/java/org/onap/ccsdk/features/data/adaptor/dao/QueryExecutorDaoTest.java b/blueprints-processor/adaptors/data-adaptor-provider/src/test/java/org/onap/ccsdk/features/data/adaptor/dao/QueryExecutorDaoTest.java deleted file mode 100644 index ddc9495a7..000000000 --- a/blueprints-processor/adaptors/data-adaptor-provider/src/test/java/org/onap/ccsdk/features/data/adaptor/dao/QueryExecutorDaoTest.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.data.adaptor.dao; - -import java.util.Date; -import org.junit.Assert; -import org.junit.Before; -import org.junit.FixMethodOrder; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.MethodSorters; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = {"classpath:test-context-h2db.xml"}) -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class QueryExecutorDaoTest { - private static EELFLogger logger = EELFManager.getInstance().getLogger(QueryExecutorDaoTest.class); - - @Autowired - private QueryExecutorDao queryExecutorDao; - - @Before - public void initialise() { - - } - - @Test - public void testInsertQueryExecution() throws Exception { - - String sql = "INSERT INTO CONFIG_RESOURCE" - + "(config_resource_id, resource_id, resource_type, template_name, recipe_name, request_id, resource_data, mask_data, created_date, updated_by) " - + "VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )"; - Object[] data = - new Object[] {"12345", "vUSP - vDBE-IPX HUB", "1234567", "activate-action", "vrr-service-template", - "resource-data", "mask-data", null, new Date(System.currentTimeMillis()), "ab1234"}; - int result = queryExecutorDao.update(sql, data); - logger.info("Updated successfully rows :" + result); - Assert.assertNotNull("Failed to get Query Result", result); - } - - @Test - public void testUpdateQueryExecution() throws Exception { - - String sql = "UPDATE CONFIG_RESOURCE set recipe_name=? where config_resource_id=?"; - Object[] data = new Object[] {"vce-service-template", "12345"}; - int result = queryExecutorDao.update(sql, data); - logger.info("Updated successfully rows :" + result); - Assert.assertNotNull("Failed to get Query Result", result); - } - - @Test - public void testDeleteQueryExecution() throws Exception { - - String sql = "DELETE FROM CONFIG_RESOURCE where config_resource_id=?"; - Object[] data = new Object[] {"12345"}; - int result = queryExecutorDao.update(sql, data); - logger.info("Updated successfully rows :" + result); - Assert.assertNotNull("Failed to get Query Result", result); - } - -} diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/test/java/org/onap/ccsdk/features/data/adaptor/service/ConfigResourceNodeTest.java b/blueprints-processor/adaptors/data-adaptor-provider/src/test/java/org/onap/ccsdk/features/data/adaptor/service/ConfigResourceNodeTest.java deleted file mode 100644 index 05df76ce4..000000000 --- a/blueprints-processor/adaptors/data-adaptor-provider/src/test/java/org/onap/ccsdk/features/data/adaptor/service/ConfigResourceNodeTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.data.adaptor.service; - -import java.util.HashMap; -import java.util.Map; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.onap.ccsdk.features.data.adaptor.DataAdaptorConstants; -import org.onap.ccsdk.features.data.adaptor.dao.ConfigResourceDao; -import org.onap.ccsdk.features.data.adaptor.dao.NamedQueryExecutorDao; -import org.onap.ccsdk.features.data.adaptor.dao.QueryExecutorDao; -import org.onap.ccsdk.features.data.adaptor.dao.TransactionLogDao; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = {"classpath:test-context-h2db.xml"}) -public class ConfigResourceNodeTest { - - ConfigResourceNode configResourceNode; - - ConfigResourceService configResourceService; - - @Autowired - TransactionLogDao transactionLogDao; - - @Autowired - ConfigResourceDao configResourceDao; - - @Autowired - QueryExecutorDao queryExecutorDao; - - @Autowired - NamedQueryExecutorDao namedQueryExecutorDao; - - @Before - public void before() { - configResourceService = new ConfigResourceServiceImpl(transactionLogDao, configResourceDao, queryExecutorDao, - namedQueryExecutorDao); - configResourceNode = new ConfigResourceNode(configResourceService); - } - - @Test - public void testSaveConfigTransactionLog() throws Exception { - Map inParams = new HashMap<>(); - inParams.put(DataAdaptorConstants.INPUT_PARAM_MESSAGE_TYPE, "messageType"); - inParams.put(DataAdaptorConstants.INPUT_PARAM_MESSAGE, "message"); - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("request-id", "requestId12345"); - - configResourceNode.saveConfigTransactionLog(inParams, ctx); - - Assert.assertTrue(!transactionLogDao.getTransactionsByRequestId("requestId12345").isEmpty()); - } - - @Test(expected = SvcLogicException.class) - public void testSaveConfigTransactionLogException() throws Exception { - configResourceNode = new ConfigResourceNode(null); - configResourceNode.saveConfigTransactionLog(new HashMap<>(), new SvcLogicContext()); - } -} diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/test/java/org/onap/ccsdk/features/data/adaptor/service/ConfigResourceServiceTest.java b/blueprints-processor/adaptors/data-adaptor-provider/src/test/java/org/onap/ccsdk/features/data/adaptor/service/ConfigResourceServiceTest.java deleted file mode 100644 index 76d28d1c5..000000000 --- a/blueprints-processor/adaptors/data-adaptor-provider/src/test/java/org/onap/ccsdk/features/data/adaptor/service/ConfigResourceServiceTest.java +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.data.adaptor.service; - -import java.nio.charset.Charset; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import org.apache.commons.io.IOUtils; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.onap.ccsdk.features.data.adaptor.dao.ConfigResourceDao; -import org.onap.ccsdk.features.data.adaptor.dao.ConfigResourceDaoTest; -import org.onap.ccsdk.features.data.adaptor.dao.NamedQueryExecutorDao; -import org.onap.ccsdk.features.data.adaptor.dao.QueryExecutorDao; -import org.onap.ccsdk.features.data.adaptor.dao.TransactionLogDao; -import org.onap.ccsdk.features.data.adaptor.domain.ConfigResource; -import org.onap.ccsdk.features.data.adaptor.domain.ResourceAssignmentData; -import org.onap.ccsdk.features.data.adaptor.domain.TransactionLog; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = {"classpath:test-context-h2db.xml"}) -public class ConfigResourceServiceTest { - - ConfigResourceService configResourceService; - - @Autowired - TransactionLogDao transactionLogDao; - - @Autowired - ConfigResourceDao configResourceDao; - - @Autowired - QueryExecutorDao queryExecutorDao; - - @Autowired - NamedQueryExecutorDao namedQueryExecutorDao; - - @Before - public void before() { - configResourceService = new ConfigResourceServiceImpl(transactionLogDao, configResourceDao, queryExecutorDao, - namedQueryExecutorDao); - } - - @Test - public void testUpdate() throws Exception { - String sql = "INSERT INTO CONFIG_RESOURCE" - + "(config_resource_id, resource_id, resource_type, template_name, recipe_name, request_id, resource_data, mask_data, created_date, updated_by) " - + "VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )"; - Object[] data = - new Object[] {"54321", "vUSP - vDBE-IPX HUB", "1234567", "activate-action", "vrr-service-template", - "resource-data", "mask-data", null, new Date(System.currentTimeMillis()), "ab1234"}; - int result = configResourceService.update(sql, data); - Assert.assertTrue(result == 1); - - sql = "SELECT * FROM CONFIG_RESOURCE WHERE config_resource_id = ?"; - data = new Object[] {"54321"}; - List> queryResult = configResourceService.query(sql, data); - Assert.assertTrue(queryResult.size() == 1); - } - - @Test - public void testSaveAndGetConfigResource() throws Exception { - ConfigResource configResource = new ConfigResource(); - String resourceData = IOUtils.toString( - ConfigResourceDaoTest.class.getClassLoader().getResourceAsStream("reference/resource_data.json"), - Charset.defaultCharset()); - - configResource.setResourceData(resourceData); - configResource.setServiceTemplateName("sample-name"); - configResource.setServiceTemplateVersion("1.0.0"); - configResource.setResourceId("123456"); - configResource.setResourceType("vUSP - vDBE-IPX HUB"); - configResource.setRequestId("123456"); - configResource.setRecipeName("activate-action"); - configResource.setTemplateName("vrr-service-template"); - configResource.setMaskData(null); - configResource.setStatus("success"); - configResource.setCreatedDate(new Date(System.currentTimeMillis())); - configResource.setUpdatedBy("an188a"); - - List resourceAssignments = new ArrayList<>(); - ResourceAssignmentData resourceAssignmentData = new ResourceAssignmentData(); - resourceAssignmentData.setDataType("string"); - resourceAssignmentData.setStatus("success"); - resourceAssignmentData.setMessage("success"); - resourceAssignmentData.setTemplateKeyName("sample"); - resourceAssignmentData.setResourceName("sample"); - // resourceAssignmentData.setResourceValue("sample123"); - resourceAssignmentData.setSource("input"); - resourceAssignments.add(resourceAssignmentData); - configResource.setResourceAssignments(resourceAssignments); - - // save - ConfigResource dbConfigResource = configResourceService.saveConfigResource(configResource); - Assert.assertNotNull("ConfigResource is null", dbConfigResource); - Assert.assertNotNull("Resource Assignment Data is null", dbConfigResource.getResourceAssignments()); - Assert.assertEquals("Resource Assignment Data count missmatch", true, - dbConfigResource.getResourceAssignments().size() > 0); - Assert.assertEquals(configResource.getServiceTemplateVersion(), dbConfigResource.getServiceTemplateVersion()); - - // update - configResource.setServiceTemplateVersion("1.0.1"); - dbConfigResource = configResourceService.saveConfigResource(configResource); - Assert.assertNotNull("ConfigResource is null", dbConfigResource); - Assert.assertNotNull("Resource Assignment Data is null", dbConfigResource.getResourceAssignments()); - Assert.assertEquals("Resource Assignment Data count missmatch", true, - dbConfigResource.getResourceAssignments().size() > 0); - Assert.assertEquals(configResource.getServiceTemplateVersion(), dbConfigResource.getServiceTemplateVersion()); - - // find - ConfigResource configResourceInput = new ConfigResource(); - configResourceInput.setResourceId(configResource.getResourceId()); - configResourceInput.setTemplateName(configResource.getTemplateName()); - configResourceInput.setServiceTemplateName(configResource.getServiceTemplateName()); - configResourceInput.setServiceTemplateVersion(configResource.getServiceTemplateVersion()); - configResourceInput.setRequestId(configResource.getRequestId()); - configResourceInput.setRecipeName(configResource.getRecipeName()); - configResourceInput.setResourceType(configResource.getResourceType()); - List dbConfigResources = configResourceService.getConfigResource(configResourceInput); - Assert.assertNotNull("ConfigResources is null", dbConfigResources); - Assert.assertEquals("ConfigResources size missmatch", true, dbConfigResources.size() > 0); - - for (ConfigResource dbConfigResouce : dbConfigResources) { - Assert.assertNotNull("ConfigResources Assignments is null", dbConfigResouce.getResourceAssignments()); - Assert.assertTrue("ConfigResources Assignments size miss mathch ", - dbConfigResouce.getResourceAssignments().size() > 0); - } - } - - @Test - public void testSaveAndGetTransactionLog() throws Exception { - TransactionLog transactionLog = new TransactionLog(); - transactionLog.setMessage("message"); - transactionLog.setMessageType("messageType"); - transactionLog.setRequestId("requestId"); - - configResourceService.save(transactionLog); - - List transactions = - configResourceService.getTransactionsByRequestId(transactionLog.getRequestId()); - Assert.assertTrue(transactions.size() == 1); - transactions = configResourceService.getTransactionsByRequestId(transactionLog.getRequestId(), - transactionLog.getMessageType()); - Assert.assertTrue(transactions.size() == 1); - } - - @Test - public void testNamedQueryExecutorUpdateNQuery() throws Exception { - Map parameters = new HashMap<>(); - parameters.put("config_transaction_log_id", UUID.randomUUID().toString()); - parameters.put("request_id", "requestId123"); - parameters.put("message_type", "messageType"); - parameters.put("message", "message"); - configResourceService.update( - "INSERT INTO CONFIG_TRANSACTION_LOG ( config_transaction_log_id, request_id, message_type, message ) VALUES (:config_transaction_log_id, :request_id, :message_type, :message) ", - parameters); - - List> result = configResourceService - .query("SELECT * FROM CONFIG_TRANSACTION_LOG WHERE request_id = :request_id", parameters); - - Assert.assertTrue(!result.isEmpty()); - Assert.assertNotNull(configResourceService.getNamedParameterJdbcTemplate()); - } -} diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/test/resources/log4j.properties b/blueprints-processor/adaptors/data-adaptor-provider/src/test/resources/log4j.properties deleted file mode 100644 index 1f83d159a..000000000 --- a/blueprints-processor/adaptors/data-adaptor-provider/src/test/resources/log4j.properties +++ /dev/null @@ -1,21 +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. -### -log4j.rootLogger=INFO, A1 -log4j.appender.A1=org.apache.log4j.ConsoleAppender -log4j.appender.A1.layout=org.apache.log4j.PatternLayout -log4j.appender.A1.layout.ConversionPattern=%d{ISO8601} %5p %t %X{UUID} %c{3}:%L - %m%n -log4j.logger.org.hibernate=INFO diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/test/resources/mappings/service-mapping.json b/blueprints-processor/adaptors/data-adaptor-provider/src/test/resources/mappings/service-mapping.json deleted file mode 100644 index e595e1613..000000000 --- a/blueprints-processor/adaptors/data-adaptor-provider/src/test/resources/mappings/service-mapping.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "resource": { - "name": "bundle-mac", - "searchCriteriaDefintion": { - "sourceSystemResourceResolution": { - "searchCriteriaValue": "$ptnni_equip_name", - "searchCriteriaType": "equipment" - } - } - } -} diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/test/resources/reference/resource_data.json b/blueprints-processor/adaptors/data-adaptor-provider/src/test/resources/reference/resource_data.json deleted file mode 100644 index 32162ecaf..000000000 --- a/blueprints-processor/adaptors/data-adaptor-provider/src/test/resources/reference/resource_data.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "group-name": "AG_AUTORP_NOOVERRIDE" -} diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/test/resources/sql/schema.sql b/blueprints-processor/adaptors/data-adaptor-provider/src/test/resources/sql/schema.sql deleted file mode 100644 index af7f02c51..000000000 --- a/blueprints-processor/adaptors/data-adaptor-provider/src/test/resources/sql/schema.sql +++ /dev/null @@ -1,42 +0,0 @@ - -CREATE TABLE IF NOT EXISTS CONFIG_RESOURCE ( - config_resource_id VARCHAR(50) PRIMARY KEY, - resource_id VARCHAR(50) NOT NULL, - resource_type VARCHAR(50) NOT NULL, - service_template_name VARCHAR(50) NULL DEFAULT NULL, - service_template_version VARCHAR(50) NULL DEFAULT NULL, - template_name VARCHAR(50) NOT NULL, - recipe_name VARCHAR(50) NOT NULL, - request_id VARCHAR(50) NOT NULL, - resource_data LONGTEXT NULL DEFAULT NULL, - mask_data LONGTEXT NULL DEFAULT NULL, - created_date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - status VARCHAR(20) NOT NULL, - updated_by VARCHAR(50) NOT NULL -); - -CREATE TABLE IF NOT EXISTS CONFIG_RESOURCE_ASSIGNMENT_DATA ( - config_resource_assignment_data_id VARCHAR(50) PRIMARY KEY, - config_resource_id VARCHAR(50) NOT NULL, - version INT(11) NOT NULL, - updated_date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_by VARCHAR(50) NOT NULL, - template_key_name VARCHAR(50) NOT NULL, - resource_name VARCHAR(50) NOT NULL, - data_type VARCHAR(100) NOT NULL, - entry_schema VARCHAR(100) NULL DEFAULT NULL, - resource_value LONGTEXT NOT NULL, - source VARCHAR(50) NOT NULL, - status VARCHAR(50) NOT NULL, - message LONGTEXT NOT NULL -); - -CREATE TABLE IF NOT EXISTS CONFIG_TRANSACTION_LOG ( - config_transaction_log_id VARCHAR(50) PRIMARY KEY, - request_id VARCHAR(50) NULL DEFAULT NULL, - message_type VARCHAR(100) NULL DEFAULT NULL, - creation_date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - message LONGTEXT NULL DEFAULT NULL -); - - diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/test/resources/test-context-h2db.xml b/blueprints-processor/adaptors/data-adaptor-provider/src/test/resources/test-context-h2db.xml deleted file mode 100644 index 9e413b099..000000000 --- a/blueprints-processor/adaptors/data-adaptor-provider/src/test/resources/test-context-h2db.xml +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/blueprints-processor/adaptors/data-adaptor-provider/src/test/resources/test-context.xml b/blueprints-processor/adaptors/data-adaptor-provider/src/test/resources/test-context.xml deleted file mode 100644 index 59af664b1..000000000 --- a/blueprints-processor/adaptors/data-adaptor-provider/src/test/resources/test-context.xml +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/blueprints-processor/adaptors/pom.xml b/blueprints-processor/adaptors/pom.xml deleted file mode 100644 index 39176d74c..000000000 --- a/blueprints-processor/adaptors/pom.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - 4.0.0 - - - org.onap.ccsdk.parent - odlparent-lite - 1.5.2-SNAPSHOT - - - - org.onap.ccsdk.features - blueprints-processor-adaptors - 0.7.1-SNAPSHOT - pom - - ccsdk-features :: ${project.artifactId} - Blueprints Processor Adaptors - POM - - - data-adaptor-provider - rest-adaptor-provider - - diff --git a/blueprints-processor/adaptors/rest-adaptor-provider/pom.xml b/blueprints-processor/adaptors/rest-adaptor-provider/pom.xml deleted file mode 100644 index 8c0cf0856..000000000 --- a/blueprints-processor/adaptors/rest-adaptor-provider/pom.xml +++ /dev/null @@ -1,146 +0,0 @@ - - - - 4.0.0 - - - org.onap.ccsdk.parent - binding-parent - 1.5.2-SNAPSHOT - - - - org.onap.ccsdk.features - blueprints-rest-adaptor-provider - 0.7.1-SNAPSHOT - bundle - - ccsdk-features :: blueprints-processor-adaptor :: ${project.artifactId} - http://maven.apache.org - - - - org.apache.commons - commons-lang3 - - - com.fasterxml.jackson.core - jackson-databind - - - com.fasterxml.jackson.core - jackson-core - - - org.apache.httpcomponents - httpcore - - - org.apache.httpcomponents - httpclient - - - org.springframework - spring-web - - - com.att.eelf - eelf-core - - - org.osgi - org.osgi.core - provided - - - junit - junit - test - - - org.powermock - powermock-api-mockito - 1.6.4 - test - - - org.javassist - javassist - 3.21.0-GA - test - - - org.mockito - mockito-core - 1.10.19 - test - - - org.powermock - powermock-module-junit4 - 1.6.4 - test - - - org.powermock - powermock-api-support - 1.6.4 - test - - - org.powermock - powermock-reflect - 1.6.4 - test - - - org.powermock - powermock-core - 1.6.4 - test - - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - - -Xdoclint:none - - - - org.apache.felix - maven-bundle-plugin - true - - - ${project.artifactId} - ${project.groupId}.${project.artifactId} - org.onap.ccsdk.features.rest.adaptor, - org.onap.ccsdk.features.rest.adaptor.data, - org.onap.ccsdk.features.rest.adaptor.service, - org.onap.ccsdk.features.rest.adaptor.utils - - - - - - - diff --git a/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/features/rest/adaptor/ConfigRestAdaptorConstants.java b/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/features/rest/adaptor/ConfigRestAdaptorConstants.java deleted file mode 100644 index adb00a305..000000000 --- a/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/features/rest/adaptor/ConfigRestAdaptorConstants.java +++ /dev/null @@ -1 +0,0 @@ -/* * Copyright © 2017-2018 AT&T Intellectual Property. * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.onap.ccsdk.features.rest.adaptor; public class ConfigRestAdaptorConstants { private ConfigRestAdaptorConstants() { } public static final String SDNC_ROOT_DIR_ENV_VAR_KEY = "SDNC_CONFIG_DIR"; public static final String REST_ADAPTOR_PROPERTIES_FILE_NAME = "blueprints-processor-adaptor.properties"; public static final String PROXY_URL_KEY = "proxyUrl"; public static final String PROXY_URLS_VALUE_SEPARATOR = ","; public static final String AAF_USERNAME_KEY = "aafUserName"; public static final String AAF_PSSWD_KEY = "aafPassword"; public static final String COMMON_SERVICE_VERSION_KEY = "commonServiceVersion"; public static final String PROPERTY_ENV_PROD = "field"; public static final String PROPERTY_ENV_SOLO = "solo"; public static final String REST_ADAPTOR_BASE_PROPERTY = "org.onap.ccsdk.features.blueprints.adaptors."; public static final String REST_ADAPTOR_ENV_TYPE = "envtype"; public static final String REST_ADAPTOR_TYPE_GENERIC = "generic"; public static final String REST_ADAPTOR_TYPE_SSL = "ssl"; public static final String SSL_SERVICE_BASEURL = ".url"; public static final String SSL_SERVICE_APP = ".application"; public static final String SSL_SERVICE_TRUST = ".ssl.trust"; public static final String SSL_SERVICE_TRUST_PSSWD = ".ssl.trust.psswd"; public static final String SSL_SERVICE_KEY = ".ssl.key"; public static final String SSL_SERVICE_KEY_PSSWD = ".ssl.key.psswd"; public static final String SERVICE_TYPE_PROPERTY = ".type"; public static final String SERVICE_EANABLED_PROPERTY = ".enable"; public static final String SERVICE_ENV_PROPERTY = ".env"; public static final String SERVICE_BASEURL_PROPERTY = ".url"; public static final String SERVICE_PROPERTYFILE = ".propertyfile"; public static final String SERVICE_USER_PROPERTY = ".user"; public static final String SERVICE_APPID_PROPERTY = ".appId"; public static final String SERVICE_PSSWD_PROPERTY = ".passwd"; public static final String SERVICE_CLIENTAUTH_PROPERTY = ".clientAuth"; public static final String SERVICE_AUTHORIZATION_PROPERTY = ".authorization"; public static final String SELECTOR_AAI = "aai"; public static final String SELECTOR_ALTS = "alts"; public static final String SELECTOR_EIPAM = "eipam"; public static final String SELECTOR_COSMS = "cosms"; public static final String SELECTOR_RESTCONF = "restconf"; public static final String SELECTOR_MODEL_SERVICE = "modelservice"; public static final String SELECTOR_POLICY_MANAGER = "policymanager"; public static final String SELECTOR_NRD = "networkresourcediscovery"; public static final String SELECTOR_NSM = "nsm"; } \ No newline at end of file diff --git a/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/features/rest/adaptor/ConfigRestAdaptorException.java b/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/features/rest/adaptor/ConfigRestAdaptorException.java deleted file mode 100644 index 163c30423..000000000 --- a/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/features/rest/adaptor/ConfigRestAdaptorException.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.rest.adaptor; - -/** - * ConfigRestAdaptorException.java Purpose: Provide Configuration Rest Adaptor Exception - * - * @version 1.0 - */ -public class ConfigRestAdaptorException extends Exception { - - /** - * - */ - private static final long serialVersionUID = 1L; - - /** - * This is a ConfigRestAdaptorException constructor - * - * @param message - */ - public ConfigRestAdaptorException(String message) { - super(message); - } - - /** - * This is a ConfigRestAdaptorException constructor - * - * @param message - */ - public ConfigRestAdaptorException(String message, Throwable cause) { - super(message, cause); - } - -} diff --git a/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/features/rest/adaptor/data/RestResponse.java b/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/features/rest/adaptor/data/RestResponse.java deleted file mode 100644 index f1a3c7290..000000000 --- a/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/features/rest/adaptor/data/RestResponse.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.rest.adaptor.data; - -import java.util.Map; - -public class RestResponse { - - private String statusCode; - private String body; - private Map parameters; - private Map responseHeaders; - private Map requestHeaders; - - public String getStatusCode() { - return statusCode; - } - - public void setStatusCode(String statusCode) { - this.statusCode = statusCode; - } - - public String getBody() { - return body; - } - - public void setBody(String body) { - this.body = body; - } - - public Map getParameters() { - return parameters; - } - - public void setParameters(Map parameters) { - this.parameters = parameters; - } - - public Map getResponseHeaders() { - return responseHeaders; - } - - public void setResponseHeaders(Map responseHeaders) { - this.responseHeaders = responseHeaders; - } - - public Map getRequestHeaders() { - return requestHeaders; - } - - public void setRequestHeaders(Map requestHeaders) { - this.requestHeaders = requestHeaders; - } - - @Override - public String toString() { - return "RestResponse [statusCode=" + statusCode + ", body=" + body + ", parameters=" + parameters - + ", responseHeaders=" + responseHeaders + ", requestHeaders=" + requestHeaders + "]"; - } - -} diff --git a/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/features/rest/adaptor/service/AbstractConfigRestClientAdapter.java b/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/features/rest/adaptor/service/AbstractConfigRestClientAdapter.java deleted file mode 100644 index 6cc4bdabf..000000000 --- a/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/features/rest/adaptor/service/AbstractConfigRestClientAdapter.java +++ /dev/null @@ -1,274 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - */ - -package org.onap.ccsdk.features.rest.adaptor.service; - -import java.io.FileInputStream; -import java.io.InputStream; -import java.security.KeyStore; -import java.security.cert.X509Certificate; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import javax.net.ssl.SSLContext; -import org.apache.commons.lang3.StringUtils; -import org.apache.http.conn.ssl.NoopHostnameVerifier; -import org.apache.http.conn.ssl.SSLConnectionSocketFactory; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClients; -import org.apache.http.ssl.SSLContextBuilder; -import org.apache.http.ssl.TrustStrategy; -import org.onap.ccsdk.features.rest.adaptor.ConfigRestAdaptorConstants; -import org.onap.ccsdk.features.rest.adaptor.ConfigRestAdaptorException; -import org.onap.ccsdk.features.rest.adaptor.data.RestResponse; -import org.onap.ccsdk.features.rest.adaptor.utils.BasicAuthorizationInterceptor; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; -import org.springframework.http.converter.ByteArrayHttpMessageConverter; -import org.springframework.http.converter.HttpMessageConverter; -import org.springframework.http.converter.ResourceHttpMessageConverter; -import org.springframework.http.converter.StringHttpMessageConverter; -import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; -import org.springframework.http.converter.xml.SourceHttpMessageConverter; -import org.springframework.util.ResourceUtils; -import org.springframework.web.client.HttpClientErrorException; -import org.springframework.web.client.RestTemplate; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -abstract class AbstractConfigRestClientAdapter implements ConfigRestClientServiceAdapter { - - private static EELFLogger logger = EELFManager.getInstance().getLogger(AbstractConfigRestClientAdapter.class); - private static final String MS_INIT_FAIL = "Failed to initialise microservice client restTemplate."; - - protected boolean isRestClientServiceAdapaterEnabled = false; - protected boolean isSSLServiceAdapaterEnabled = true; - - protected Map properties = new ConcurrentHashMap<>(); - protected String serviceSelector; - - protected RestTemplate restTemplate; - - protected AbstractConfigRestClientAdapter(Map properties, String serviceSelector) { - this.properties = properties; - this.serviceSelector = serviceSelector; - setRestClientServiceAdapaterEnabled(); - } - - private void setRestClientServiceAdapaterEnabled() { - String isEnabledProperty = ConfigRestAdaptorConstants.REST_ADAPTOR_BASE_PROPERTY + serviceSelector - + ConfigRestAdaptorConstants.SERVICE_EANABLED_PROPERTY; - String isRestClientServiceAdapaterEnabledStr = properties.get(isEnabledProperty); - logger.info("Service selector ({}) enable status ({}) ", serviceSelector, - isRestClientServiceAdapaterEnabledStr); - if (StringUtils.isNotBlank(isRestClientServiceAdapaterEnabledStr) - && Boolean.parseBoolean(isRestClientServiceAdapaterEnabledStr)) { - isRestClientServiceAdapaterEnabled = true; - } - } - - private List> getMessageConverters() { - List> converters = new ArrayList<>(); - converters.add(new ByteArrayHttpMessageConverter()); - converters.add(new StringHttpMessageConverter()); - converters.add(new ResourceHttpMessageConverter()); - converters.add(new SourceHttpMessageConverter()); - converters.add(new MappingJackson2HttpMessageConverter()); - return converters; - } - - public void initialise(String user, String pass) { - logger.trace("Config rest template factory user ({}) ", user); - - CloseableHttpClient httpClient = - HttpClients.custom().setSSLHostnameVerifier(new NoopHostnameVerifier()).build(); - HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(); - requestFactory.setHttpClient(httpClient); - - restTemplate = new RestTemplate(getMessageConverters()); - restTemplate.setRequestFactory(requestFactory); - if (StringUtils.isNotBlank(user) && StringUtils.isNotBlank(pass)) { - restTemplate.getInterceptors().add(new BasicAuthorizationInterceptor(user, pass)); - } - } - - public void initialiseSSL(String keyStorePath, String trustStorePath, String keyPass, String trustPass) - throws ConfigRestAdaptorException { - logger.trace("SSL rest template factory"); - - TrustStrategy acceptingTrustStrategy = (X509Certificate[] chain, String authType) -> true; - SSLContext sslContext = null; - - try (InputStream keyInput = new FileInputStream(keyStorePath)) { - KeyStore keyStore = KeyStore.getInstance("PKCS12"); - keyStore.load(keyInput, keyPass.toCharArray()); - - logger.info("key loaded successfully"); - sslContext = SSLContextBuilder.create().loadKeyMaterial(keyStore, keyPass.toCharArray()).loadTrustMaterial( - ResourceUtils.getFile(trustStorePath), trustPass.toCharArray(), acceptingTrustStrategy).build(); - } catch (Exception e) { - throw new ConfigRestAdaptorException(e.getMessage()); - } - - SSLConnectionSocketFactory csf = new SSLConnectionSocketFactory(sslContext); - CloseableHttpClient httpClient = HttpClients.custom().setSSLSocketFactory(csf).build(); - HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(httpClient); - - restTemplate = new RestTemplate(getMessageConverters()); - restTemplate.setRequestFactory(requestFactory); - } - - public T getResource(HttpHeaders headers, String url, Class responseType) throws ConfigRestAdaptorException { - ResponseEntity response = exchangeForEntity(headers, url, HttpMethod.GET, null, responseType); - return processResponse(response, url, HttpMethod.GET); - } - - public T postResource(HttpHeaders headers, String url, Object request, Class responseType) - throws ConfigRestAdaptorException { - ResponseEntity response = exchangeForEntity(headers, url, HttpMethod.POST, request, responseType); - return processResponse(response, url, HttpMethod.POST); - } - - public T exchangeResource(HttpHeaders headers, String url, Object request, Class responseType, String method) - throws ConfigRestAdaptorException { - ResponseEntity response = exchangeForEntity(headers, url, HttpMethod.valueOf(method), request, responseType); - return processResponse(response, url, HttpMethod.valueOf(method)); - } - - public RestResponse getResource(HttpHeaders headers, String url) throws ConfigRestAdaptorException { - return exchangeForEntity(headers, url, HttpMethod.GET, null); - } - - public RestResponse postResource(HttpHeaders headers, String url, Object request) - throws ConfigRestAdaptorException { - return exchangeForEntity(headers, url, HttpMethod.POST, request); - } - - public RestResponse exchangeResource(HttpHeaders headers, String url, Object request, String method) - throws ConfigRestAdaptorException { - return exchangeForEntity(headers, url, HttpMethod.valueOf(method), request); - } - - private RestResponse exchangeForEntity(HttpHeaders headers, String url, HttpMethod httpMethod, Object request) - throws ConfigRestAdaptorException { - RestResponse restResponse = new RestResponse(); - restResponse.setRequestHeaders(headers.toSingleValueMap()); - ResponseEntity response = null; - - try { - if (restTemplate == null) { - logger.error(MS_INIT_FAIL); - } else { - logger.debug("Rest Operation: {}", httpMethod); - logger.debug("url : ({})", url); - logger.debug("headers: ({})", headers); - logger.debug("request: ({})", request); - - if (HttpMethod.GET == httpMethod) { - HttpEntity entity = new HttpEntity<>("parameters", headers); - response = restTemplate.exchange(url, httpMethod, entity, String.class); - } else { - HttpEntity entity = new HttpEntity<>(request, headers); - response = restTemplate.exchange(url, httpMethod, entity, String.class); - } - logger.debug("response: ({})", response); - - if (response != null) { - logger.debug("response status code: ({})", response.getStatusCode()); - restResponse.setBody(response.getBody()); - restResponse.setStatusCode(response.getStatusCode().toString()); - restResponse.setResponseHeaders( - response.getHeaders() != null ? response.getHeaders().toSingleValueMap() : null); - return restResponse; - } - throw new ConfigRestAdaptorException("Rest exchangeForEntity failed to perform "); - } - } catch (HttpClientErrorException clientError) { - logger.debug("clientError: ({})", clientError); - restResponse.setBody(StringUtils.isBlank(clientError.getResponseBodyAsString()) ? clientError.getMessage() - : clientError.getResponseBodyAsString()); - restResponse.setStatusCode(clientError.getStatusCode().toString()); - } catch (Exception e) { - throw new ConfigRestAdaptorException( - String.format("httpMethod (%s) for url (%s) resulted in Exception (%s)", httpMethod, url, e)); - } - return restResponse; - } - - private ResponseEntity exchangeForEntity(HttpHeaders headers, String url, HttpMethod httpMethod, - Object request, Class responseType) throws ConfigRestAdaptorException { - ResponseEntity response = null; - - try { - if (restTemplate == null) { - logger.error(MS_INIT_FAIL); - } else { - logger.debug("Rest Operation: {}", httpMethod); - logger.debug("url : ({})", url); - logger.debug("headers: ({})", headers); - logger.debug("request: ({})", request); - - if (HttpMethod.GET == httpMethod) { - HttpEntity entity = new HttpEntity<>("parameters", headers); - response = restTemplate.exchange(url, httpMethod, entity, responseType); - } else { - HttpEntity entity = new HttpEntity<>(request, headers); - response = restTemplate.exchange(url, httpMethod, entity, responseType); - } - logger.debug("response: ({})", response); - - if (response != null) { - logger.debug("response status code: ({})", response.getStatusCode()); - } else { - throw new ConfigRestAdaptorException("exchangeForEntity failed to perform "); - } - } - } catch (Exception e) { - throw new ConfigRestAdaptorException( - String.format("httpMethod (%s) for url (%s) resulted in Exception (%s)", httpMethod, url, e)); - } - return response; - } - - protected synchronized T processResponse(ResponseEntity response, String url, HttpMethod httpMethod) - throws ConfigRestAdaptorException { - if (response != null) { - if ((HttpMethod.DELETE == httpMethod && (response.getStatusCode() == HttpStatus.NO_CONTENT - || response.getStatusCode() == HttpStatus.NOT_FOUND)) - || ((HttpMethod.GET == httpMethod || HttpMethod.PUT == httpMethod || HttpMethod.POST == httpMethod) - && (response.getStatusCode() == HttpStatus.OK - || response.getStatusCode() == HttpStatus.CREATED))) { - return response.getBody(); - } - throw new ConfigRestAdaptorException( - String.format("Rest Operation is failed with response-code (%s) for the URL (%s)", - response.getStatusCode(), url)); - } - throw new ConfigRestAdaptorException(String.format("Rest Operation is failed for the URL (%s)", url)); - } - - protected synchronized String constructUrl(String baseUrl, String path) { - if (StringUtils.isNotBlank(path)) { - return baseUrl + path; - } else { - return baseUrl; - } - } - -} diff --git a/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/features/rest/adaptor/service/ConfigRestAdaptorService.java b/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/features/rest/adaptor/service/ConfigRestAdaptorService.java deleted file mode 100644 index 12e734ad3..000000000 --- a/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/features/rest/adaptor/service/ConfigRestAdaptorService.java +++ /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. - */ - -package org.onap.ccsdk.features.rest.adaptor.service; - -import org.onap.ccsdk.features.rest.adaptor.ConfigRestAdaptorException; -import org.onap.ccsdk.features.rest.adaptor.data.RestResponse; - -public interface ConfigRestAdaptorService { - - /** - * Retrieve an entity by doing a GET on the specified URL. The response is converted and stored in - * defined responseType. - * - * @param selectorName the property selector - * @param path the URI path which will append in baseURL mentioned in selector property - * @param responseType the type of the return value - */ - public T getResource(String selectorName, String path, Class responseType) throws ConfigRestAdaptorException; - - /** - * Create a new resource by POSTing the given object to the URI template, and returns the response - * as defined responseType - * - * @param selectorName the property selector - * @param path the URI path which will append in baseURL mentioned in selector property - * @param request the Object to be POSTed, may be {@code null} - * @param responseType the type of the return value - */ - public T postResource(String selectorName, String path, Object request, Class responseType) - throws ConfigRestAdaptorException; - - /** - * Execute the HTTP method to the given URI template, writing the given request entity to the - * request, and returns the response as defined responseType - * - * @param selectorName the property selector - * @param path the URI path which will append in baseURL mentioned in selector property - * @param request the Object to be POSTed, may be {@code null} - * @param responseType the type of the return value - * @param method the HTTP method (GET, POST, etc) - */ - public T exchangeResource(String selectorName, String path, Object request, Class responseType, - String method) throws ConfigRestAdaptorException; - - /** - * Retrieve an entity by doing a GET on the specified URL. The response is converted and stored in - * defined responseType. - * - * @param selectorName the property selector - * @param path the URI path which will append in baseURL mentioned in selector property - */ - public RestResponse getResource(String selectorName, String path) throws ConfigRestAdaptorException; - - /** - * Create a new resource by POSTing the given object to the URI template, and returns the response - * as defined responseType - * - * @param selectorName the property selector - * @param path the URI path which will append in baseURL mentioned in selector property - * @param request the Object to be POSTed, may be {@code null} - */ - public RestResponse postResource(String selectorName, String path, Object request) - throws ConfigRestAdaptorException; - - /** - * Execute the HTTP method to the given URI template, writing the given request entity to the - * request, and returns the response as defined responseType - * - * @param selectorName the property selector - * @param path the URI path which will append in baseURL mentioned in selector property - * @param request the Object to be POSTed, may be {@code null} - * @param method the HTTP method (GET, POST, etc) - */ - public RestResponse exchangeResource(String selectorName, String path, Object request, String method) - throws ConfigRestAdaptorException; - -} diff --git a/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/features/rest/adaptor/service/ConfigRestAdaptorServiceImpl.java b/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/features/rest/adaptor/service/ConfigRestAdaptorServiceImpl.java deleted file mode 100644 index 0646e1f09..000000000 --- a/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/features/rest/adaptor/service/ConfigRestAdaptorServiceImpl.java +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.rest.adaptor.service; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.util.Map; -import java.util.Properties; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; -import java.util.stream.Collectors; -import org.apache.commons.lang3.StringUtils; -import org.onap.ccsdk.features.rest.adaptor.ConfigRestAdaptorConstants; -import org.onap.ccsdk.features.rest.adaptor.ConfigRestAdaptorException; -import org.onap.ccsdk.features.rest.adaptor.data.RestResponse; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleContext; -import org.osgi.framework.FrameworkUtil; - -public class ConfigRestAdaptorServiceImpl implements ConfigRestAdaptorService { - - private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigRestAdaptorServiceImpl.class); - private Map restProperties = new ConcurrentHashMap<>(); - - public ConfigRestAdaptorServiceImpl() { - this(null); - } - - public ConfigRestAdaptorServiceImpl(final String propertyFilePath) { - loadProps(propertyFilePath); - try { - String envType = restProperties.get(ConfigRestAdaptorConstants.REST_ADAPTOR_BASE_PROPERTY - + ConfigRestAdaptorConstants.REST_ADAPTOR_ENV_TYPE); - - if (!(ConfigRestAdaptorConstants.PROPERTY_ENV_PROD.equalsIgnoreCase(envType) - || ConfigRestAdaptorConstants.PROPERTY_ENV_SOLO.equalsIgnoreCase(envType))) { - ScheduledExecutorService executor = Executors.newScheduledThreadPool(1); - Runnable task = () -> loadProps(propertyFilePath); - executor.scheduleWithFixedDelay(task, 60, 15, TimeUnit.MINUTES); - } - } catch (Exception e) { - logger.error(e.getMessage(), e); - } - } - - - // propertyFilePath is only specified in test case. - private void loadProps(final String propertyFilePath) { - Properties properties = new Properties(); - if (propertyFilePath != null) { - // Loading Default properties - String propertyFile = - propertyFilePath + File.separator + ConfigRestAdaptorConstants.REST_ADAPTOR_PROPERTIES_FILE_NAME; - doLoadFromPath(propertyFile, properties); - } else { - // Try to load config from dir - final String ccsdkConfigDir = - System.getProperty(ConfigRestAdaptorConstants.SDNC_ROOT_DIR_ENV_VAR_KEY) + File.separator - + ConfigRestAdaptorConstants.REST_ADAPTOR_PROPERTIES_FILE_NAME; - try (FileInputStream in = new FileInputStream(ccsdkConfigDir)) { - properties.load(in); - logger.info("Loaded {} properties from file {}", properties.size(), ccsdkConfigDir); - } catch (Exception e) { - // Try to load config from jar - final Bundle bundle = FrameworkUtil.getBundle(ConfigRestAdaptorServiceImpl.class); - final BundleContext ctx = bundle.getBundleContext(); - final URL url = ctx.getBundle() - .getResource(ConfigRestAdaptorConstants.REST_ADAPTOR_PROPERTIES_FILE_NAME); - doLoadFromPath(url.getPath(), properties); - } - } - restProperties.putAll(properties.entrySet().stream() - .collect(Collectors.toMap(e -> e.getKey().toString(), e -> e.getValue().toString()))); - } - - private void doLoadFromPath(final String propertyFile, final Properties properties) { - try (FileInputStream in = new FileInputStream(propertyFile)) { - properties.load(in); - logger.info("Loaded {} properties from file {}", properties.size(), propertyFile); - } catch (Exception e) { - logger.error("Failed to load properties for file: {} " - + ConfigRestAdaptorConstants.REST_ADAPTOR_PROPERTIES_FILE_NAME, e); - } - } - - @Override - public T getResource(String serviceSelector, String path, Class responseType) - throws ConfigRestAdaptorException { - return getRestClientAdapterBySelectorName(serviceSelector).getResource(path, responseType); - } - - @Override - public T postResource(String serviceSelector, String path, Object request, Class responseType) - throws ConfigRestAdaptorException { - return getRestClientAdapterBySelectorName(serviceSelector).postResource(path, request, responseType); - } - - @Override - public T exchangeResource(String serviceSelector, String path, Object request, Class responseType, - String method) throws ConfigRestAdaptorException { - return getRestClientAdapterBySelectorName(serviceSelector).exchangeResource(path, request, responseType, - method); - } - - @Override - public RestResponse getResource(String serviceSelector, String path) throws ConfigRestAdaptorException { - return getRestClientAdapterBySelectorName(serviceSelector).getResource(path); - } - - @Override - public RestResponse postResource(String serviceSelector, String path, Object request) - throws ConfigRestAdaptorException { - return getRestClientAdapterBySelectorName(serviceSelector).postResource(path, request); - } - - @Override - public RestResponse exchangeResource(String serviceSelector, String path, Object request, String method) - throws ConfigRestAdaptorException { - return getRestClientAdapterBySelectorName(serviceSelector).exchangeResource(path, request, method); - } - - private ConfigRestClientServiceAdapter getRestClientAdapterBySelectorName(String serviceSelector) - throws ConfigRestAdaptorException { - String adoptorType = restProperties.get(ConfigRestAdaptorConstants.REST_ADAPTOR_BASE_PROPERTY + serviceSelector - + ConfigRestAdaptorConstants.SERVICE_TYPE_PROPERTY); - if (StringUtils.isNotBlank(adoptorType)) { - if (ConfigRestAdaptorConstants.REST_ADAPTOR_TYPE_GENERIC.equalsIgnoreCase(adoptorType)) { - return new GenericRestClientAdapterImpl(restProperties, serviceSelector); - } else if (ConfigRestAdaptorConstants.REST_ADAPTOR_TYPE_SSL.equalsIgnoreCase(adoptorType)) { - return new SSLRestClientAdapterImpl(restProperties, serviceSelector); - } else { - throw new ConfigRestAdaptorException( - String.format("no implementation for rest adoptor type (%s) for the selector (%s).", - adoptorType, serviceSelector)); - } - } else { - throw new ConfigRestAdaptorException( - String.format("couldn't get rest adoptor type for the selector (%s)", serviceSelector)); - } - } - -} diff --git a/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/features/rest/adaptor/service/ConfigRestClientServiceAdapter.java b/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/features/rest/adaptor/service/ConfigRestClientServiceAdapter.java deleted file mode 100644 index 7ebc0ef48..000000000 --- a/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/features/rest/adaptor/service/ConfigRestClientServiceAdapter.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.rest.adaptor.service; - -import org.onap.ccsdk.features.rest.adaptor.ConfigRestAdaptorException; -import org.onap.ccsdk.features.rest.adaptor.data.RestResponse; - -interface ConfigRestClientServiceAdapter { - - public T getResource(String path, Class responseType) throws ConfigRestAdaptorException; - - public T postResource(String path, Object request, Class responseType) throws ConfigRestAdaptorException; - - public T exchangeResource(String path, Object request, Class responseType, String method) - throws ConfigRestAdaptorException; - - public RestResponse getResource(String path) throws ConfigRestAdaptorException; - - public RestResponse postResource(String path, Object request) throws ConfigRestAdaptorException; - - public RestResponse exchangeResource(String path, Object request, String method) throws ConfigRestAdaptorException; - -} diff --git a/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/features/rest/adaptor/service/GenericRestClientAdapterImpl.java b/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/features/rest/adaptor/service/GenericRestClientAdapterImpl.java deleted file mode 100644 index 6f9840a0b..000000000 --- a/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/features/rest/adaptor/service/GenericRestClientAdapterImpl.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.rest.adaptor.service; - -import java.util.Map; -import java.util.UUID; -import org.apache.commons.lang3.StringUtils; -import org.onap.ccsdk.features.rest.adaptor.ConfigRestAdaptorConstants; -import org.onap.ccsdk.features.rest.adaptor.ConfigRestAdaptorException; -import org.onap.ccsdk.features.rest.adaptor.data.RestResponse; -import org.springframework.http.HttpHeaders; -import org.springframework.http.MediaType; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -public class GenericRestClientAdapterImpl extends AbstractConfigRestClientAdapter { - - private static EELFLogger logger = EELFManager.getInstance().getLogger(GenericRestClientAdapterImpl.class); - private String baseUrl = ""; - - public GenericRestClientAdapterImpl(Map properties, String serviceSelector) - throws ConfigRestAdaptorException { - super(properties, serviceSelector); - init(serviceSelector); - } - - private void init(String serviceSelector) throws ConfigRestAdaptorException { - try { - if (isRestClientServiceAdapaterEnabled) { - String baseUrlProperty = ConfigRestAdaptorConstants.REST_ADAPTOR_BASE_PROPERTY + serviceSelector - + ConfigRestAdaptorConstants.SERVICE_BASEURL_PROPERTY; - String userProperty = ConfigRestAdaptorConstants.REST_ADAPTOR_BASE_PROPERTY + serviceSelector - + ConfigRestAdaptorConstants.SERVICE_USER_PROPERTY; - String passProperty = ConfigRestAdaptorConstants.REST_ADAPTOR_BASE_PROPERTY + serviceSelector - + ConfigRestAdaptorConstants.SERVICE_PSSWD_PROPERTY; - - baseUrl = properties.get(baseUrlProperty); - String userId = properties.get(userProperty); - String pass = properties.get(passProperty); - - initialise(userId, pass); - logger.info("Initialised restconf adaptor service for selector ({})", serviceSelector); - if (restTemplate == null) { - throw new ConfigRestAdaptorException("couldn't initialise rest selector (" + serviceSelector + ")"); - } - } else { - throw new ConfigRestAdaptorException("rest selector (" + serviceSelector + ") is not enabled"); - } - - } catch (Exception e) { - throw new ConfigRestAdaptorException("GenericRestClientServiceAdapter : " + e.getMessage(), e); - } - } - - @Override - public T getResource(String path, Class responseType) throws ConfigRestAdaptorException { - return super.getResource(formHttpHeaders(), constructUrl(baseUrl, path), responseType); - } - - @Override - public T postResource(String path, Object request, Class responseType) throws ConfigRestAdaptorException { - return super.postResource(formHttpHeaders(), constructUrl(baseUrl, path), request, responseType); - } - - @Override - public T exchangeResource(String path, Object request, Class responseType, String method) - throws ConfigRestAdaptorException { - return super.exchangeResource(formHttpHeaders(), constructUrl(baseUrl, path), request, responseType, method); - } - - @Override - public RestResponse getResource(String path) throws ConfigRestAdaptorException { - return super.getResource(formHttpHeaders(), constructUrl(baseUrl, path)); - } - - @Override - public RestResponse postResource(String path, Object request) throws ConfigRestAdaptorException { - return super.postResource(formHttpHeaders(), constructUrl(baseUrl, path), request); - } - - @Override - public RestResponse exchangeResource(String path, Object request, String method) throws ConfigRestAdaptorException { - return super.exchangeResource(formHttpHeaders(), constructUrl(baseUrl, path), request, method); - } - - private HttpHeaders formHttpHeaders() { - - HttpHeaders headers = new HttpHeaders(); - - headers.setContentType(MediaType.APPLICATION_JSON); - headers.add("Accept", MediaType.APPLICATION_JSON_VALUE); - headers.add("X-TransactionId", generateUUID()); - headers.add("X-ECOMP-RequestID", headers.getFirst("X-TransactionId")); - - String appIDPath = ConfigRestAdaptorConstants.REST_ADAPTOR_BASE_PROPERTY + serviceSelector - + ConfigRestAdaptorConstants.SERVICE_APPID_PROPERTY; - String environmentPath = ConfigRestAdaptorConstants.REST_ADAPTOR_BASE_PROPERTY + serviceSelector - + ConfigRestAdaptorConstants.SERVICE_ENV_PROPERTY; - String clientAuthPath = ConfigRestAdaptorConstants.REST_ADAPTOR_BASE_PROPERTY + serviceSelector - + ConfigRestAdaptorConstants.SERVICE_CLIENTAUTH_PROPERTY; - String authorizationPath = ConfigRestAdaptorConstants.REST_ADAPTOR_BASE_PROPERTY + serviceSelector - + ConfigRestAdaptorConstants.SERVICE_AUTHORIZATION_PROPERTY; - - if (StringUtils.isNotBlank(properties.get(appIDPath))) { - headers.add("X-FromAppId", properties.get(appIDPath)); - } - if (StringUtils.isNotBlank(properties.get(clientAuthPath))) { - headers.add("ClientAuth", properties.get(clientAuthPath)); - } - if (StringUtils.isNotBlank(properties.get(authorizationPath))) { - headers.add("Authorization", properties.get(authorizationPath)); - } - if (StringUtils.isNotBlank(properties.get(environmentPath))) { - headers.add("Environment", properties.get(environmentPath)); - } - - return headers; - } - - private synchronized String generateUUID() { - return UUID.randomUUID().toString(); - } - -} diff --git a/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/features/rest/adaptor/service/SSLRestClientAdapterImpl.java b/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/features/rest/adaptor/service/SSLRestClientAdapterImpl.java deleted file mode 100644 index f7ec439d5..000000000 --- a/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/features/rest/adaptor/service/SSLRestClientAdapterImpl.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.rest.adaptor.service; - -import java.util.Map; -import java.util.UUID; -import org.onap.ccsdk.features.rest.adaptor.ConfigRestAdaptorConstants; -import org.onap.ccsdk.features.rest.adaptor.ConfigRestAdaptorException; -import org.onap.ccsdk.features.rest.adaptor.data.RestResponse; -import org.springframework.http.HttpHeaders; -import org.springframework.http.MediaType; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -public class SSLRestClientAdapterImpl extends AbstractConfigRestClientAdapter { - - private static EELFLogger logger = EELFManager.getInstance().getLogger(SSLRestClientAdapterImpl.class); - private String baseUrl = ""; - private String application = ""; - - public SSLRestClientAdapterImpl(Map properties, String serviceSelector) - throws ConfigRestAdaptorException { - super(properties, serviceSelector); - init(serviceSelector); - } - - private void init(String serviceSelector) throws ConfigRestAdaptorException { - try { - if (isSSLServiceAdapaterEnabled) { - - logger.info("Initializing SSL client for selector ({}), properties ({})", serviceSelector, properties); - - String baseUrlProp = ConfigRestAdaptorConstants.REST_ADAPTOR_BASE_PROPERTY + serviceSelector - + ConfigRestAdaptorConstants.SSL_SERVICE_BASEURL; - String applicationProp = ConfigRestAdaptorConstants.REST_ADAPTOR_BASE_PROPERTY + serviceSelector - + ConfigRestAdaptorConstants.SSL_SERVICE_APP; - String keyStorePathProp = ConfigRestAdaptorConstants.REST_ADAPTOR_BASE_PROPERTY + serviceSelector - + ConfigRestAdaptorConstants.SSL_SERVICE_KEY; - String keyStorePassProp = ConfigRestAdaptorConstants.REST_ADAPTOR_BASE_PROPERTY + serviceSelector - + ConfigRestAdaptorConstants.SSL_SERVICE_KEY_PSSWD; - String trustStorePathProp = ConfigRestAdaptorConstants.REST_ADAPTOR_BASE_PROPERTY + serviceSelector - + ConfigRestAdaptorConstants.SSL_SERVICE_TRUST; - String trustStorePassProp = ConfigRestAdaptorConstants.REST_ADAPTOR_BASE_PROPERTY + serviceSelector - + ConfigRestAdaptorConstants.SSL_SERVICE_TRUST_PSSWD; - - baseUrl = properties.get(baseUrlProp); - application = properties.get(applicationProp); - - String keyStorePath = properties.get(keyStorePathProp); - String trustStorePath = properties.get(trustStorePathProp); - String keyStorePass = properties.get(keyStorePassProp); - String trustStorePass = properties.get(trustStorePassProp); - - initialiseSSL(keyStorePath, trustStorePath, keyStorePass, trustStorePass); - logger.info("Initialised SSL Client Service adaptor service for selector ({})", serviceSelector); - if (restTemplate == null) { - throw new ConfigRestAdaptorException( - "couldn't initialise SSL Client selector (" + serviceSelector + ")"); - } - } else { - throw new ConfigRestAdaptorException("SSL Client selector (" + serviceSelector + ") is not enabled"); - } - - } catch (Exception e) { - throw new ConfigRestAdaptorException("SSLRestClientAdapterImpl : " + e.getMessage(), e); - } - } - - @Override - public T getResource(String path, Class responseType) throws ConfigRestAdaptorException { - return super.getResource(formHttpHeaders(), constructUrl(baseUrl, path), responseType); - } - - @Override - public T postResource(String path, Object request, Class responseType) throws ConfigRestAdaptorException { - return super.postResource(formHttpHeaders(), constructUrl(baseUrl, path), request, responseType); - } - - @Override - public T exchangeResource(String path, Object request, Class responseType, String method) - throws ConfigRestAdaptorException { - return super.exchangeResource(formHttpHeaders(), constructUrl(baseUrl, path), request, responseType, method); - } - - @Override - public RestResponse getResource(String path) throws ConfigRestAdaptorException { - return super.getResource(formHttpHeaders(), constructUrl(baseUrl, path)); - } - - @Override - public RestResponse postResource(String path, Object request) throws ConfigRestAdaptorException { - return super.postResource(formHttpHeaders(), constructUrl(baseUrl, path), request); - } - - @Override - public RestResponse exchangeResource(String path, Object request, String method) throws ConfigRestAdaptorException { - return super.exchangeResource(formHttpHeaders(), constructUrl(baseUrl, path), request, method); - } - - private HttpHeaders formHttpHeaders() { - - HttpHeaders headers = new HttpHeaders(); - - headers.setContentType(MediaType.APPLICATION_JSON); - headers.add("Accept", MediaType.APPLICATION_JSON_VALUE); - headers.add("X-FromAppId", application); - headers.add("X-TransactionId", generateUUID()); - - return headers; - } - - private synchronized String generateUUID() { - return UUID.randomUUID().toString(); - } -} diff --git a/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/features/rest/adaptor/utils/BasicAuthorizationInterceptor.java b/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/features/rest/adaptor/utils/BasicAuthorizationInterceptor.java deleted file mode 100644 index c3e2288d1..000000000 --- a/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/features/rest/adaptor/utils/BasicAuthorizationInterceptor.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.rest.adaptor.utils; - -import java.io.IOException; -import java.nio.charset.Charset; -import java.util.Base64; -import org.springframework.http.HttpRequest; -import org.springframework.http.client.ClientHttpRequestExecution; -import org.springframework.http.client.ClientHttpRequestInterceptor; -import org.springframework.http.client.ClientHttpResponse; -import org.springframework.util.Assert; - -public class BasicAuthorizationInterceptor implements ClientHttpRequestInterceptor { - private static final Charset UTF_8 = Charset.forName("UTF-8"); - - private final String username; - - private final String pass; - - /** - * Create a new interceptor which adds a BASIC authorization header for the given username and pass. - * - * @param username the username to use - * @param pass the password to use - */ - public BasicAuthorizationInterceptor(String username, String pass) { - Assert.hasLength(username, "Username must not be empty"); - this.username = username; - this.pass = (pass != null ? pass : ""); - } - - @Override - public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) - throws IOException { - - String token = Base64.getEncoder().encodeToString((this.username + ":" + this.pass).getBytes(UTF_8)); - request.getHeaders().add("Authorization", "Basic " + token); - return execution.execute(request, body); - } -} diff --git a/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/features/rest/adaptor/utils/LoggingRequestInterceptor.java b/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/features/rest/adaptor/utils/LoggingRequestInterceptor.java deleted file mode 100644 index cb618d05a..000000000 --- a/blueprints-processor/adaptors/rest-adaptor-provider/src/main/java/org/onap/ccsdk/features/rest/adaptor/utils/LoggingRequestInterceptor.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.rest.adaptor.utils; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import org.springframework.http.HttpRequest; -import org.springframework.http.client.ClientHttpRequestExecution; -import org.springframework.http.client.ClientHttpRequestInterceptor; -import org.springframework.http.client.ClientHttpResponse; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -public class LoggingRequestInterceptor implements ClientHttpRequestInterceptor { - - private static EELFLogger logger = EELFManager.getInstance().getLogger(LoggingRequestInterceptor.class); - - @Override - public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) - throws IOException { - traceRequest(request, body); - ClientHttpResponse response = execution.execute(request, body); - traceResponse(response); - return response; - } - - @SuppressWarnings({"squid:S2629", "squid:S3457"}) - private void traceRequest(HttpRequest request, byte[] body) throws IOException { - logger.info("===========================request begin================================================"); - logger.info("URI : {}", request.getURI()); - logger.info("Method : {}", request.getMethod()); - logger.info("Headers : {}", request.getHeaders()); - logger.info("Request body: {}", new String(body, "UTF-8")); - logger.debug("==========================request end================================================"); - } - - @SuppressWarnings({"squid:S2629", "squid:S3457"}) - private void traceResponse(ClientHttpResponse response) throws IOException { - StringBuilder inputStringBuilder = new StringBuilder(); - BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(response.getBody(), "UTF-8")); - String line = bufferedReader.readLine(); - while (line != null) { - inputStringBuilder.append(line); - inputStringBuilder.append('\n'); - line = bufferedReader.readLine(); - } - logger.info("============================response begin=========================================="); - logger.info("Status code : {}", response.getStatusCode()); - logger.info("Status text : {}", response.getStatusText()); - logger.info("Headers : {}", response.getHeaders()); - logger.debug("Response body: {}", inputStringBuilder.toString()); - logger.debug("=======================response end================================================="); - } - -} diff --git a/blueprints-processor/adaptors/rest-adaptor-provider/src/main/resources/OSGI-INF/blueprint/impl-blueprint.xml b/blueprints-processor/adaptors/rest-adaptor-provider/src/main/resources/OSGI-INF/blueprint/impl-blueprint.xml deleted file mode 100644 index 8788f6482..000000000 --- a/blueprints-processor/adaptors/rest-adaptor-provider/src/main/resources/OSGI-INF/blueprint/impl-blueprint.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - diff --git a/blueprints-processor/adaptors/rest-adaptor-provider/src/main/resources/blueprints-processor-adaptor.properties b/blueprints-processor/adaptors/rest-adaptor-provider/src/main/resources/blueprints-processor-adaptor.properties deleted file mode 100644 index a3dcf674d..000000000 --- a/blueprints-processor/adaptors/rest-adaptor-provider/src/main/resources/blueprints-processor-adaptor.properties +++ /dev/null @@ -1,35 +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. -### -# -# Configuration file for SDNC Controller Module -# - -org.onap.ccsdk.features.blueprints.adaptors.envtype=solo - -# Config Generator Microservices -org.onap.ccsdk.features.blueprints.adaptors.modelservice.type=generic -org.onap.ccsdk.features.blueprints.adaptors.modelservice.enable=true -org.onap.ccsdk.features.blueprints.adaptors.modelservice.url=http://controller-blueprints:8080/api/v1/ -org.onap.ccsdk.features.blueprints.adaptors.modelservice.user=ccsdkapps -org.onap.ccsdk.features.blueprints.adaptors.modelservice.passwd=ccsdkapps - -# Generic RESTCONF Adaptor -org.onap.ccsdk.features.blueprints.adaptors.restconf.type=generic -org.onap.ccsdk.features.blueprints.adaptors.restconf.enable=true -org.onap.ccsdk.features.blueprints.adaptors.restconf.user=admin -org.onap.ccsdk.features.blueprints.adaptors.restconf.passwd=Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U -org.onap.ccsdk.features.blueprints.adaptors.restconf.url=http://sdnc:8282/restconf/ diff --git a/blueprints-processor/adaptors/rest-adaptor-provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml b/blueprints-processor/adaptors/rest-adaptor-provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml deleted file mode 100644 index 8788f6482..000000000 --- a/blueprints-processor/adaptors/rest-adaptor-provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - diff --git a/blueprints-processor/adaptors/rest-adaptor-provider/src/test/java/org/onap/ccsdk/features/rest/adaptor/service/AbstractConfigRestClientAdapterTest.java b/blueprints-processor/adaptors/rest-adaptor-provider/src/test/java/org/onap/ccsdk/features/rest/adaptor/service/AbstractConfigRestClientAdapterTest.java deleted file mode 100644 index b6891a059..000000000 --- a/blueprints-processor/adaptors/rest-adaptor-provider/src/test/java/org/onap/ccsdk/features/rest/adaptor/service/AbstractConfigRestClientAdapterTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.rest.adaptor.service; - -import java.io.FileInputStream; -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; -import java.util.stream.Collectors; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -public class AbstractConfigRestClientAdapterTest { - - Map properties = new HashMap<>(); - - @Before - public void setup() throws Exception { - String propertyfile = "src/test/resources/blueprints-processor-adaptor.properties"; - - Properties restProperties = new Properties(); - restProperties.load(new FileInputStream(propertyfile)); - - properties.putAll(restProperties.entrySet().stream() - .collect(Collectors.toMap(e -> e.getKey().toString(), e -> e.getValue().toString()))); - } - - @Test - public void testInitGenericRestClient() throws Exception { - ConfigRestClientServiceAdapter genericRestClient = new GenericRestClientAdapterImpl(properties, "modelservice"); - Assert.assertNotNull(genericRestClient); - } - - @Test - public void testInitSSLClient() throws Exception { - ConfigRestClientServiceAdapter sslClient = new SSLRestClientAdapterImpl(properties, "aai"); - Assert.assertNotNull(sslClient); - } - -} diff --git a/blueprints-processor/adaptors/rest-adaptor-provider/src/test/java/org/onap/ccsdk/features/rest/adaptor/service/GenericRestClientServiceTest.java b/blueprints-processor/adaptors/rest-adaptor-provider/src/test/java/org/onap/ccsdk/features/rest/adaptor/service/GenericRestClientServiceTest.java deleted file mode 100644 index 36599cc6f..000000000 --- a/blueprints-processor/adaptors/rest-adaptor-provider/src/test/java/org/onap/ccsdk/features/rest/adaptor/service/GenericRestClientServiceTest.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.rest.adaptor.service; - -import static org.powermock.api.mockito.PowerMockito.mock; -import static org.powermock.api.mockito.PowerMockito.when; -import static org.powermock.api.mockito.PowerMockito.whenNew; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Matchers; -import org.onap.ccsdk.features.rest.adaptor.ConfigRestAdaptorException; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.client.RestTemplate; - -@SuppressWarnings("unchecked") -@RunWith(PowerMockRunner.class) -@PowerMockIgnore("javax.net.ssl.*") -@PrepareForTest({AbstractConfigRestClientAdapter.class}) -public class GenericRestClientServiceTest { - - ConfigRestAdaptorService configRestAdaptorService; - - RestTemplate mockRestTemplate = mock(RestTemplate.class); - - String path = "path"; - - @Before - public void before() throws Exception { - whenNew(RestTemplate.class).withAnyArguments().thenReturn(mockRestTemplate); - - String propertyDir = "src/test/resources"; - configRestAdaptorService = new ConfigRestAdaptorServiceImpl(propertyDir); - } - - @Test - public void testGetResource() throws Exception { - String responseBody = "sampleBodyString"; - ResponseEntity response = new ResponseEntity(responseBody, HttpStatus.OK); - when(mockRestTemplate.exchange(Matchers.endsWith(path), Matchers.eq(HttpMethod.GET), Matchers.any(), - Matchers.any(Class.class))).thenReturn(response); - - String body = configRestAdaptorService.getResource("modelservice", path, String.class); - - Assert.assertEquals(responseBody, body); - } - - @Test - public void testPostResource() throws Exception { - String responseBody = "sampleBodyString"; - ResponseEntity response = new ResponseEntity(responseBody, HttpStatus.OK); - when(mockRestTemplate.exchange(Matchers.endsWith(path), Matchers.eq(HttpMethod.POST), Matchers.any(), - Matchers.any(Class.class))).thenReturn(response); - - String body = configRestAdaptorService.postResource("modelservice", path, null, String.class); - - Assert.assertEquals(responseBody, body); - } - - @Test - public void testExchange() throws Exception { - String responseBody = "sampleBodyString"; - ResponseEntity response = new ResponseEntity(responseBody, HttpStatus.OK); - when(mockRestTemplate.exchange(Matchers.endsWith(path), Matchers.eq(HttpMethod.GET), Matchers.any(), - Matchers.any(Class.class))).thenReturn(response); - - String body = configRestAdaptorService.exchangeResource("modelservice", path, null, String.class, "GET"); - - Assert.assertEquals(responseBody, body); - } - - @Test(expected = ConfigRestAdaptorException.class) - public void testGetResourceError() throws Exception { - ResponseEntity response = new ResponseEntity("", HttpStatus.INTERNAL_SERVER_ERROR); - when(mockRestTemplate.getForEntity(Matchers.endsWith(path), Matchers.any())).thenReturn(response); - - configRestAdaptorService.getResource("modelservice", path, String.class); - } - - @Test(expected = ConfigRestAdaptorException.class) - public void testPostResourceError() throws Exception { - ResponseEntity response = new ResponseEntity("", HttpStatus.INTERNAL_SERVER_ERROR); - when(mockRestTemplate.postForEntity(Matchers.endsWith(path), Matchers.anyObject(), Matchers.any())) - .thenReturn(response); - - configRestAdaptorService.postResource("modelservice", path, null, String.class); - } - - @Test(expected = ConfigRestAdaptorException.class) - public void testExchangeError() throws Exception { - ResponseEntity response = new ResponseEntity("", HttpStatus.INTERNAL_SERVER_ERROR); - when(mockRestTemplate.exchange(Matchers.endsWith(path), Matchers.eq(HttpMethod.GET), Matchers.any(), - Matchers.any(Class.class))).thenReturn(response); - - configRestAdaptorService.exchangeResource("modelservice", path, null, String.class, "GET"); - } -} diff --git a/blueprints-processor/adaptors/rest-adaptor-provider/src/test/java/org/onap/ccsdk/features/rest/adaptor/service/SSLClientServiceTest.java b/blueprints-processor/adaptors/rest-adaptor-provider/src/test/java/org/onap/ccsdk/features/rest/adaptor/service/SSLClientServiceTest.java deleted file mode 100644 index 8e09f1be4..000000000 --- a/blueprints-processor/adaptors/rest-adaptor-provider/src/test/java/org/onap/ccsdk/features/rest/adaptor/service/SSLClientServiceTest.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.rest.adaptor.service; - -import static org.powermock.api.mockito.PowerMockito.mock; -import static org.powermock.api.mockito.PowerMockito.when; -import static org.powermock.api.mockito.PowerMockito.whenNew; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Matchers; -import org.onap.ccsdk.features.rest.adaptor.ConfigRestAdaptorException; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.client.RestTemplate; - -@SuppressWarnings("unchecked") -@RunWith(PowerMockRunner.class) -@PowerMockIgnore("javax.net.ssl.*") -@PrepareForTest({AbstractConfigRestClientAdapter.class}) -public class SSLClientServiceTest { - - ConfigRestAdaptorService configRestAdaptorService; - - RestTemplate mockRestTemplate = mock(RestTemplate.class); - - String path = "path"; - - @Before - public void before() throws Exception { - whenNew(RestTemplate.class).withAnyArguments().thenReturn(mockRestTemplate); - - String propertyDir = "src/test/resources"; - configRestAdaptorService = new ConfigRestAdaptorServiceImpl(propertyDir); - } - - @Test - public void testGetResource() throws Exception { - String responseBody = "sampleBodyString"; - ResponseEntity response = new ResponseEntity(responseBody, HttpStatus.OK); - when(mockRestTemplate.exchange(Matchers.endsWith(path), Matchers.eq(HttpMethod.GET), Matchers.any(), - Matchers.any(Class.class))).thenReturn(response); - - String body = configRestAdaptorService.getResource("aai", path, String.class); - - Assert.assertEquals(responseBody, body); - } - - @Test - public void testPostResource() throws Exception { - String responseBody = "sampleBodyString"; - ResponseEntity response = new ResponseEntity(responseBody, HttpStatus.OK); - when(mockRestTemplate.exchange(Matchers.endsWith(path), Matchers.eq(HttpMethod.POST), Matchers.any(), - Matchers.any(Class.class))).thenReturn(response); - - String body = configRestAdaptorService.postResource("aai", path, null, String.class); - - Assert.assertEquals(responseBody, body); - } - - @Test - public void testExchange() throws Exception { - String responseBody = "sampleBodyString"; - ResponseEntity response = new ResponseEntity(responseBody, HttpStatus.OK); - when(mockRestTemplate.exchange(Matchers.endsWith(path), Matchers.eq(HttpMethod.GET), Matchers.any(), - Matchers.any(Class.class))).thenReturn(response); - - String body = configRestAdaptorService.exchangeResource("aai", path, null, String.class, "GET"); - - Assert.assertEquals(responseBody, body); - } - - @Test(expected = ConfigRestAdaptorException.class) - public void testGetResourceError() throws Exception { - ResponseEntity response = new ResponseEntity("", HttpStatus.INTERNAL_SERVER_ERROR); - when(mockRestTemplate.getForEntity(Matchers.endsWith(path), Matchers.any())).thenReturn(response); - - configRestAdaptorService.getResource("aai", path, String.class); - } - - @Test(expected = ConfigRestAdaptorException.class) - public void testPostResourceError() throws Exception { - ResponseEntity response = new ResponseEntity("", HttpStatus.INTERNAL_SERVER_ERROR); - when(mockRestTemplate.postForEntity(Matchers.endsWith(path), Matchers.anyObject(), Matchers.any())) - .thenReturn(response); - - configRestAdaptorService.postResource("aai", path, null, String.class); - } - - @Test(expected = ConfigRestAdaptorException.class) - public void testExchangeError() throws Exception { - ResponseEntity response = new ResponseEntity("", HttpStatus.INTERNAL_SERVER_ERROR); - when(mockRestTemplate.exchange(Matchers.endsWith(path), Matchers.eq(HttpMethod.GET), Matchers.any(), - Matchers.any(Class.class))).thenReturn(response); - - configRestAdaptorService.exchangeResource("aai", path, null, String.class, "GET"); - } -} diff --git a/blueprints-processor/adaptors/rest-adaptor-provider/src/test/java/org/onap/ccsdk/features/rest/adaptor/utils/RestTemplateFactoryTest.java b/blueprints-processor/adaptors/rest-adaptor-provider/src/test/java/org/onap/ccsdk/features/rest/adaptor/utils/RestTemplateFactoryTest.java deleted file mode 100644 index cee91d297..000000000 --- a/blueprints-processor/adaptors/rest-adaptor-provider/src/test/java/org/onap/ccsdk/features/rest/adaptor/utils/RestTemplateFactoryTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.rest.adaptor.utils; - -import org.onap.ccsdk.features.rest.adaptor.ConfigRestAdaptorConstants; -import org.onap.ccsdk.features.rest.adaptor.ConfigRestAdaptorException; -import org.onap.ccsdk.features.rest.adaptor.service.ConfigRestAdaptorServiceImpl; - -@SuppressWarnings("squid:S2187") -public class RestTemplateFactoryTest { - - public static void main(String[] args) { - - String propertyFile = RestTemplateFactoryTest.class.getClassLoader().getResource(".").getPath(); - System.out.println(" Property : " + propertyFile); - - try { - ConfigRestAdaptorServiceImpl configRestAdaptorServiceImpl = new ConfigRestAdaptorServiceImpl(propertyFile); - String restconfResponse = genericRestGetMDSALOperation(args, configRestAdaptorServiceImpl); - System.out.println("RestTemplateFactoryTest.main Completed with response :" + restconfResponse); - } catch (ConfigRestAdaptorException e) { - e.printStackTrace(); - } - } - - public static String genericRestGetMDSALOperation(String[] args, - ConfigRestAdaptorServiceImpl configRestAdaptorServiceImpl) throws ConfigRestAdaptorException { - String path = "config/Dummy-API:services/service-list/dummy-1234"; - String restconfResponse = configRestAdaptorServiceImpl.getResource(ConfigRestAdaptorConstants.SELECTOR_RESTCONF, - path, String.class); - return restconfResponse; - } - -} diff --git a/blueprints-processor/adaptors/rest-adaptor-provider/src/test/resources/blueprints-processor-adaptor.properties b/blueprints-processor/adaptors/rest-adaptor-provider/src/test/resources/blueprints-processor-adaptor.properties deleted file mode 100644 index 82f4fcb9d..000000000 --- a/blueprints-processor/adaptors/rest-adaptor-provider/src/test/resources/blueprints-processor-adaptor.properties +++ /dev/null @@ -1,45 +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. -### -# -# Configuration file for SDNC Controller Module -# - -org.onap.ccsdk.features.blueprints.adaptors.envtype=solo - -# Config Generator Microservices -org.onap.ccsdk.features.blueprints.adaptors.modelservice.type=generic -org.onap.ccsdk.features.blueprints.adaptors.modelservice.enable=true -org.onap.ccsdk.features.blueprints.adaptors.modelservice.url=http://localhost:8080/configgenerator/service/ -org.onap.ccsdk.features.blueprints.adaptors.modelservice.user=admin -org.onap.ccsdk.features.blueprints.adaptors.modelservice.passwd=admin - -# Generic RESTCONF Adaptor -org.onap.ccsdk.features.blueprints.adaptors.restconf.type=generic -org.onap.ccsdk.features.blueprints.adaptors.restconf.enable=true -org.onap.ccsdk.features.blueprints.adaptors.restconf.user=admin -org.onap.ccsdk.features.blueprints.adaptors.restconf.passwd=admin -org.onap.ccsdk.features.blueprints.adaptors.restconf.url=http://localhost:8181/restconf/ - -# SSL AAI Adaptor -org.onap.ccsdk.features.blueprints.adaptors.aai.propertyfile=aai.properties -org.onap.ccsdk.features.blueprints.adaptors.aai.type=ssl -org.onap.ccsdk.features.blueprints.adaptors.aai.enable=true -org.onap.ccsdk.features.blueprints.adaptors.aai.url=https://localhost:8443/onap-aai/ -org.onap.ccsdk.features.blueprints.adaptors.aai.ssl.trust=src/test/resources/truststore.client.jks -org.onap.ccsdk.features.blueprints.adaptors.aai.ssl.trust.psswd=changeme -org.onap.ccsdk.features.blueprints.adaptors.aai.ssl.key=src/test/resources/keystore.client.p12 -org.onap.ccsdk.features.blueprints.adaptors.aai.ssl.key.psswd=changeme diff --git a/blueprints-processor/adaptors/rest-adaptor-provider/src/test/resources/keystore.client.p12 b/blueprints-processor/adaptors/rest-adaptor-provider/src/test/resources/keystore.client.p12 deleted file mode 100644 index c28c8cb79..000000000 Binary files a/blueprints-processor/adaptors/rest-adaptor-provider/src/test/resources/keystore.client.p12 and /dev/null differ diff --git a/blueprints-processor/adaptors/rest-adaptor-provider/src/test/resources/truststore.client.jks b/blueprints-processor/adaptors/rest-adaptor-provider/src/test/resources/truststore.client.jks deleted file mode 100644 index d38a5e57d..000000000 Binary files a/blueprints-processor/adaptors/rest-adaptor-provider/src/test/resources/truststore.client.jks and /dev/null differ diff --git a/blueprints-processor/features/ccsdk-blueprints-processor/pom.xml b/blueprints-processor/features/ccsdk-blueprints-processor/pom.xml deleted file mode 100644 index 5fff7b09c..000000000 --- a/blueprints-processor/features/ccsdk-blueprints-processor/pom.xml +++ /dev/null @@ -1,96 +0,0 @@ - - - - 4.0.0 - - - org.onap.ccsdk.parent - single-feature-parent - 1.5.2-SNAPSHOT - - - - org.onap.ccsdk.features - ccsdk-blueprints-processor - 0.7.1-SNAPSHOT - feature - - ccsdk-features :: blueprints-processor-features :: ${project.artifactId} - - ${project.version} - - - - - org.opendaylight.controller - odl-mdsal-broker - xml - features - - - - org.onap.ccsdk.sli.core - ccsdk-sli - ${ccsdk.sli.core.version} - xml - features - - - - ${project.groupId} - blueprints-rest-adaptor-provider - ${project.version} - - - ${project.groupId} - blueprints-data-adaptor-provider - ${project.version} - - - ${project.groupId} - blueprints-model-provider - ${project.version} - - - ${project.groupId} - blueprints-generator-provider - ${project.version} - - - ${project.groupId} - blueprints-assignment-provider - ${project.version} - - - - com.fasterxml.jackson.core - jackson-core - - - com.fasterxml.jackson.core - jackson-databind - - - com.fasterxml.jackson.core - jackson-annotations - - - com.fasterxml.jackson.module - jackson-module-jsonSchema - - - diff --git a/blueprints-processor/features/features-blueprints-processor/pom.xml b/blueprints-processor/features/features-blueprints-processor/pom.xml deleted file mode 100755 index cba944ef7..000000000 --- a/blueprints-processor/features/features-blueprints-processor/pom.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - 4.0.0 - - - org.onap.ccsdk.parent - feature-repo-parent - 1.5.2-SNAPSHOT - - - - org.onap.ccsdk.features - features-blueprints-processor - 0.7.1-SNAPSHOT - feature - - ccsdk-features :: blueprints-processor-features :: ${project.artifactId} - - - - ${project.groupId} - ccsdk-blueprints-processor - ${project.version} - xml - features - - - - diff --git a/blueprints-processor/features/pom.xml b/blueprints-processor/features/pom.xml deleted file mode 100755 index b240a8f3b..000000000 --- a/blueprints-processor/features/pom.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - 4.0.0 - - - org.onap.ccsdk.parent - odlparent-lite - 1.5.2-SNAPSHOT - - - - org.onap.ccsdk.features - blueprints-processor-features - 0.7.1-SNAPSHOT - pom - - ccsdk-features :: ${project.artifactId} - - - ccsdk-blueprints-processor - features-blueprints-processor - - diff --git a/blueprints-processor/installer/.gitignore b/blueprints-processor/installer/.gitignore deleted file mode 100644 index ae04cff9d..000000000 --- a/blueprints-processor/installer/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/target-ide/ diff --git a/blueprints-processor/installer/pom.xml b/blueprints-processor/installer/pom.xml deleted file mode 100644 index 8aacd8e4a..000000000 --- a/blueprints-processor/installer/pom.xml +++ /dev/null @@ -1,172 +0,0 @@ - - - - 4.0.0 - - - org.onap.ccsdk.parent - odlparent-lite - 1.5.2-SNAPSHOT - - - - org.onap.ccsdk.features - blueprints-processor-installer - 0.7.1-SNAPSHOT - pom - - ccsdk-features :: ${project.artifactId} - - - blueprints-processor - blueprints-processor-features - mvn:org.onap.ccsdk.features/ccsdk-features/blueprints-processor-features/${project.version}/xml/features - false - - - - - org.onap.ccsdk.features - ccsdk-blueprints-processor - ${project.version} - xml - features - - - * - * - - - - - org.onap.ccsdk.features - blueprints-data-adaptor-provider - ${project.version} - - - org.onap.ccsdk.features - blueprints-rest-adaptor-provider - ${project.version} - - - org.onap.ccsdk.features - blueprints-assignment-provider - ${project.version} - - - org.onap.ccsdk.features - blueprints-generator-provider - ${project.version} - - - org.onap.ccsdk.features - blueprints-model-provider - ${project.version} - - - - - - - maven-assembly-plugin - - - maven-repo-zip - - single - - package - - true - stage/${application.name}-${project.version} - - src/assembly/assemble_mvnrepo_zip.xml - - true - - - - installer-zip - - single - - package - - true - ${application.name}-${project.version}-installer - - src/assembly/assemble_installer_zip.xml - - false - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - copy-dependencies - - copy-dependencies - - prepare-package - - false - ${project.build.directory}/assembly/system - false - true - true - true - false - false - org.onap.ccsdk.features - provided - - - - - - maven-resources-plugin - 2.6 - - - copy-version - - copy-resources - - validate - - ${basedir}/target/stage - - - src/main/resources/scripts - - install-feature.sh - - true - - - - - - - - - diff --git a/blueprints-processor/installer/src/assembly/assemble_installer_zip.xml b/blueprints-processor/installer/src/assembly/assemble_installer_zip.xml deleted file mode 100644 index e803caf46..000000000 --- a/blueprints-processor/installer/src/assembly/assemble_installer_zip.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - installer_zip - - zip - - - - false - - - - target/stage/ - ${application.name} - 755 - - *.sh - - - - target/stage/ - ${application.name} - 644 - - *.sh - - - - - - diff --git a/blueprints-processor/installer/src/assembly/assemble_mvnrepo_zip.xml b/blueprints-processor/installer/src/assembly/assemble_mvnrepo_zip.xml deleted file mode 100644 index 95d191a81..000000000 --- a/blueprints-processor/installer/src/assembly/assemble_mvnrepo_zip.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - repo - - zip - - - - false - - - - target/assembly/ - . - - - - - - - diff --git a/blueprints-processor/installer/src/main/resources/scripts/install-feature.sh b/blueprints-processor/installer/src/main/resources/scripts/install-feature.sh deleted file mode 100644 index 9241bc420..000000000 --- a/blueprints-processor/installer/src/main/resources/scripts/install-feature.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash - -### -# -# Copyright © 2017-2018 AT&T Intellectual Property. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -### - -ODL_HOME=${ODL_HOME:-/opt/opendaylight/current} -ODL_KARAF_CLIENT=${ODL_KARAF_CLIENT:-${ODL_HOME}/bin/client} -INSTALLERDIR=$(dirname $0) - -REPOZIP=${INSTALLERDIR}/${features.boot}-${project.version}.zip - -if [ -f ${REPOZIP} ] -then - unzip -d ${ODL_HOME} ${REPOZIP} -else - echo "ERROR : repo zip ($REPOZIP) not found!" - exit 1 -fi - -${ODL_KARAF_CLIENT} feature:repo-add ${features.repositories} -${ODL_KARAF_CLIENT} feature:install ${features.boot} diff --git a/blueprints-processor/plugin/assignment-provider/pom.xml b/blueprints-processor/plugin/assignment-provider/pom.xml deleted file mode 100644 index e04c175be..000000000 --- a/blueprints-processor/plugin/assignment-provider/pom.xml +++ /dev/null @@ -1,144 +0,0 @@ - - - - 4.0.0 - - - org.onap.ccsdk.parent - binding-parent - 1.5.2-SNAPSHOT - - - - org.onap.ccsdk.features - blueprints-assignment-provider - 0.7.1-SNAPSHOT - bundle - - ccsdk-features :: blueprints-processor-plugin :: ${project.artifactId} - http://maven.apache.org - - - - org.onap.ccsdk.features - blueprints-generator-provider - ${project.version} - - - com.fasterxml.jackson.core - jackson-core - ${jackson.version} - - - com.fasterxml.jackson.core - jackson-databind - ${jackson.version} - - - com.fasterxml.jackson.core - jackson-annotations - ${jackson.version} - - - com.fasterxml.jackson.module - jackson-module-jsonSchema - ${jackson.version} - - - junit - junit - test - - - org.apache.sling - org.apache.sling.testing.osgi-mock - test - - - org.powermock - powermock-api-mockito - 1.6.4 - test - - - org.javassist - javassist - 3.21.0-GA - test - - - org.mockito - mockito-core - 1.10.19 - test - - - org.powermock - powermock-module-junit4 - 1.6.4 - test - - - org.powermock - powermock-api-support - 1.6.4 - test - - - org.powermock - powermock-reflect - 1.6.4 - test - - - org.powermock - powermock-core - 1.6.4 - test - - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - - -Xdoclint:none - - - - org.apache.felix - maven-bundle-plugin - true - - - ${project.artifactId} - ${project.groupId}.${project.artifactId} - org.onap.ccsdk.features.assignment, - org.onap.ccsdk.features.assignment.data, - org.onap.ccsdk.features.assignment.service, - org.onap.ccsdk.features.assignment.processor, - org.onap.ccsdk.features.assignment.processor.custom - - - - - - - diff --git a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/ConfigAssignmentConstants.java b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/ConfigAssignmentConstants.java deleted file mode 100644 index 3052a8611..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/ConfigAssignmentConstants.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.assignment; - -@SuppressWarnings("squid:S1118") -public class ConfigAssignmentConstants { - - public static final String OUTPUT_PARAM_STATUS = "status"; - public static final String OUTPUT_PARAM_RESOURCE_ASSIGNMENT_PARAMS = "resource-assignment-params"; - public static final String OUTPUT_PARAM_MASHED_DATA = "mashed-data"; - public static final String OUTPUT_PARAM_ERROR_MESSAGE = "error-message"; - public static final String OUTPUT_STATUS_SUCCESS = "success"; - public static final String OUTPUT_STATUS_FAILURE = "failure"; - - public static final String INPUT_PARAM_REQUEST_ID = "request-id"; - public static final String INPUT_PARAM_RESOURCE_ID = "resource-id"; - public static final String INPUT_PARAM_RESOURCE_TYPE = "resource-type"; - public static final String INPUT_PARAM_ACTION_NAME = "action-name"; - public static final String INPUT_PARAM_TEMPLATE_NAMES = "template-names"; - public static final String INPUT_PARAM_INPUT_DATA = "input-data"; - -} diff --git a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/data/ResourceAssignmentData.java b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/data/ResourceAssignmentData.java deleted file mode 100644 index 75a1398bd..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/data/ResourceAssignmentData.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.assignment.data; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.onap.ccsdk.features.model.data.ResourceAssignment; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; - -public class ResourceAssignmentData { - - private String requestId; - private boolean reloadModel; - private String resourceType; - private String resourceId; - private String serviceTemplateName; - private String serviceTemplateVersion; - private String actionName; - private String inputData; - private SvcLogicContext svcLogicContext; - private List templateNames; - private Map> templatesResourceAssignments = new HashMap<>(); - private Map templatesContents = new HashMap<>(); - private Map templatesMashedContents = new HashMap<>(); - private Map templatesData = new HashMap<>(); - private Map context = new HashMap<>(); - - public String getRequestId() { - return requestId; - } - - public void setRequestId(String requestId) { - this.requestId = requestId; - } - - public String getResourceType() { - return resourceType; - } - - public void setResourceType(String resourceType) { - this.resourceType = resourceType; - } - - public String getResourceId() { - return resourceId; - } - - public void setResourceId(String resourceId) { - this.resourceId = resourceId; - } - - public String getServiceTemplateName() { - return serviceTemplateName; - } - - public void setServiceTemplateName(String serviceTemplateName) { - this.serviceTemplateName = serviceTemplateName; - } - - public String getServiceTemplateVersion() { - return serviceTemplateVersion; - } - - public void setServiceTemplateVersion(String serviceTemplateVersion) { - this.serviceTemplateVersion = serviceTemplateVersion; - } - - public String getActionName() { - return actionName; - } - - public void setActionName(String actionName) { - this.actionName = actionName; - } - - public String getInputData() { - return inputData; - } - - public void setInputData(String inputData) { - this.inputData = inputData; - } - - public List getTemplateNames() { - return templateNames; - } - - public void setTemplateNames(List templateNames) { - this.templateNames = templateNames; - } - - public Map> getTemplatesResourceAssignments() { - return templatesResourceAssignments; - } - - public void setTemplatesResourceAssignments(Map> templatesResourceAssignments) { - this.templatesResourceAssignments = templatesResourceAssignments; - } - - public Map getTemplatesContents() { - return templatesContents; - } - - public void setTemplatesContents(Map templatesContents) { - this.templatesContents = templatesContents; - } - - public Map getTemplatesMashedContents() { - return templatesMashedContents; - } - - public void setTemplatesMashedContents(Map templatesMashedContents) { - this.templatesMashedContents = templatesMashedContents; - } - - public Map getTemplatesData() { - return templatesData; - } - - public void setTemplatesData(Map templatesData) { - this.templatesData = templatesData; - } - - public Map getContext() { - return context; - } - - public void setContext(Map context) { - this.context = context; - } - - public SvcLogicContext getSvcLogicContext() { - return svcLogicContext; - } - - public void setSvcLogicContext(SvcLogicContext svcLogicContext) { - this.svcLogicContext = svcLogicContext; - } - - public boolean isReloadModel() { - return reloadModel; - } - - public void setReloadModel(boolean reloadModel) { - this.reloadModel = reloadModel; - } -} diff --git a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/processor/DBResourceProcessor.java b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/processor/DBResourceProcessor.java deleted file mode 100644 index 132d03c4f..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/processor/DBResourceProcessor.java +++ /dev/null @@ -1,267 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.assignment.processor; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.collections.MapUtils; -import org.apache.commons.lang3.StringUtils; -import org.onap.ccsdk.features.assignment.service.ConfigAssignmentUtils; -import org.onap.ccsdk.features.data.adaptor.service.ConfigResourceService; -import org.onap.ccsdk.features.model.ConfigModelConstant; -import org.onap.ccsdk.features.model.ConfigModelException; -import org.onap.ccsdk.features.model.ValidTypes; -import org.onap.ccsdk.features.model.data.ResourceAssignment; -import org.onap.ccsdk.features.model.data.dict.ResourceDefinition; -import org.onap.ccsdk.features.model.data.dict.SourcesDefinition; -import org.onap.ccsdk.features.model.service.ComponentNode; -import org.onap.ccsdk.features.model.utils.JsonUtils; -import org.onap.ccsdk.features.model.utils.ResourceAssignmentUtils; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.JsonNodeFactory; -import com.fasterxml.jackson.databind.node.ObjectNode; - -public class DBResourceProcessor implements ComponentNode { - - private static EELFLogger logger = EELFManager.getInstance().getLogger(DBResourceProcessor.class); - private ConfigResourceService configResourceService; - private Map dictionaries; - - public DBResourceProcessor(ConfigResourceService configResourceService) { - this.configResourceService = configResourceService; - } - - @Override - public Boolean preCondition(Map inParams, SvcLogicContext ctx, Map componentContext) - throws SvcLogicException { - return Boolean.TRUE; - } - - @Override - public void preProcess(Map inParams, SvcLogicContext ctx, Map componentContext) - throws SvcLogicException { - // Auto-generated method stub - } - - @Override - public void process(Map inParams, SvcLogicContext ctx) throws SvcLogicException { - // Auto-generated method stub - } - - @SuppressWarnings("unchecked") - @Override - public void process(Map inParams, SvcLogicContext ctx, Map componentContext) - throws SvcLogicException { - try { - List batchResourceAssignment = - (List) componentContext.get(ConfigModelConstant.PROPERTY_RESOURCE_ASSIGNMENTS); - dictionaries = - (Map) componentContext.get(ConfigModelConstant.PROPERTY_DICTIONARIES); - - if (CollectionUtils.isNotEmpty(batchResourceAssignment)) { - for (ResourceAssignment resourceAssignment : batchResourceAssignment) { - processResourceAssignment(ctx, componentContext, resourceAssignment); - } - } - } catch (Exception e) { - throw new SvcLogicException(String.format("DBResourceProcessor Exception : (%s)", e), e); - } - } - - private void processResourceAssignment(SvcLogicContext ctx, Map componentContext, - ResourceAssignment resourceAssignment) throws SvcLogicException, ConfigModelException { - if (resourceAssignment != null) { - try { - validate(resourceAssignment); - - // Check if It has Input - Object value = ConfigAssignmentUtils.getContextKeyValue(ctx, resourceAssignment.getName()); - if (value != null) { - logger.info("db source template key ({}) found from input and value is ({})", - resourceAssignment.getName(), value); - ResourceAssignmentUtils.setResourceDataValue(componentContext, resourceAssignment, value); - return; - } - - ResourceDefinition resourceDefinition = dictionaries.get(resourceAssignment.getDictionaryName()); - SourcesDefinition sourceDb = resourceDefinition.getSources().get("db"); - if (StringUtils.isBlank(sourceDb.getProperties().getQuery())) { - throw new SvcLogicException("db query property is missing"); - } - - String sql = sourceDb.getProperties().getQuery(); - Map inputKeyMapping = sourceDb.getProperties().getInputKeyMapping(); - - logger.info("Db dictionary information : ({}), ({}), ({})", sql, inputKeyMapping, - sourceDb.getProperties().getOutputKeyMapping()); - - Map namedParameters = populateNamedParameter(componentContext, inputKeyMapping); - - logger.info("Parameter information : ({})", namedParameters); - List> rows = configResourceService.query(sql, namedParameters); - if (rows != null && !rows.isEmpty()) { - processDBResults(ctx, componentContext, resourceAssignment, sourceDb, rows); - } else { - logger.warn("Failed to get db result for dictionary name ({}) the query ({})", - resourceAssignment.getDictionaryName(), sql); - } - - // Check the value has populated for mandatory case - ResourceAssignmentUtils.assertTemplateKeyValueNotNull(componentContext, resourceAssignment); - } catch (Exception e) { - ResourceAssignmentUtils.setFailedResourceDataValue(componentContext, resourceAssignment, - e.getMessage()); - throw new SvcLogicException( - String.format("Failed in template key (%s) assignments : (%s)", resourceAssignment, e), e); - } - } else { - // Do Nothing - } - } - - private void validate(ResourceAssignment resourceAssignment) throws SvcLogicException { - if (resourceAssignment == null) { - throw new SvcLogicException("resource assignment is not defined"); - } - - if (StringUtils.isBlank(resourceAssignment.getName())) { - throw new SvcLogicException("resource assignment template key is not defined"); - } - - if (StringUtils.isBlank(resourceAssignment.getDictionaryName())) { - throw new SvcLogicException( - String.format("resource assignment dictionary name is not defined for template key (%s)", - resourceAssignment.getName())); - } - - if (!ConfigModelConstant.SOURCE_DB.equalsIgnoreCase(resourceAssignment.getDictionarySource())) { - throw new SvcLogicException(String.format("resource assignment source is not db, it is (%s)", - resourceAssignment.getDictionarySource())); - } - - ResourceDefinition resourceDefinition = dictionaries.get(resourceAssignment.getDictionaryName()); - if (resourceDefinition == null) { - throw new SvcLogicException(String.format("missing resource dictionary definition for name (%s) ", - resourceAssignment.getDictionaryName())); - } - - if (resourceDefinition.getSources() == null || resourceDefinition.getSources().get("db") == null) { - throw new SvcLogicException(String.format("missing resource dictionary db source definition for name (%s) ", - resourceAssignment.getDictionaryName())); - } - - SourcesDefinition sourceDb = resourceDefinition.getSources().get("db"); - if (StringUtils.isBlank(sourceDb.getProperties().getQuery())) { - throw new SvcLogicException(String.format("Failed to get request Query for dictionary (%s)", - resourceAssignment.getDictionaryName())); - } - - } - - private Map populateNamedParameter(Map componentContext, - Map inputKeyMapping) { - Map namedParameters = new HashMap<>(); - if (MapUtils.isNotEmpty(inputKeyMapping)) { - - for (Map.Entry mapping : inputKeyMapping.entrySet()) { - ResourceDefinition referenceDictionaryDefinition = dictionaries.get(mapping.getValue()); - Object expressionValue = - ResourceAssignmentUtils.getDictionaryKeyValue(componentContext, referenceDictionaryDefinition); - logger.trace("Reference dictionary key ({}), value ({})", mapping.getKey(), expressionValue); - namedParameters.put(mapping.getKey(), expressionValue); - } - } - return namedParameters; - } - - @SuppressWarnings("squid:S3776") - private void processDBResults(SvcLogicContext ctx, Map componentContext, - ResourceAssignment resourceAssignment, SourcesDefinition sourceDb, List> rows) - throws SvcLogicException, ConfigModelException { - - Map outputKeyMapping = sourceDb.getProperties().getOutputKeyMapping(); - String type = resourceAssignment.getProperty().getType(); - String entrySchema = null; - logger.info("Response processing type({})", type); - // Primitive Types - if (ValidTypes.getPrimitivePropertType().contains(type)) { - - Map row = rows.get(0); - String dbColumnName = outputKeyMapping.get(resourceAssignment.getDictionaryName()); - Object dbColumnValue = row.get(dbColumnName); - ResourceAssignmentUtils.setResourceDataValue(componentContext, resourceAssignment, dbColumnValue); - - } else if (ValidTypes.getListPropertType().contains(type)) { - // Array Types - if (resourceAssignment.getProperty().getEntrySchema() != null) { - entrySchema = resourceAssignment.getProperty().getEntrySchema().getType(); - } - - if (StringUtils.isNotBlank(entrySchema)) { - ArrayNode arrayNode = JsonNodeFactory.instance.arrayNode(); - - for (Map row : rows) { - if (ValidTypes.getPrimitivePropertType().contains(entrySchema)) { - String dbColumnName = outputKeyMapping.get(resourceAssignment.getDictionaryName()); - Object dbColumnValue = row.get(dbColumnName); - // Add Array JSON - JsonUtils.populatePrimitiveValues(dbColumnValue, entrySchema, arrayNode); - } else { - ObjectNode arrayChildNode = JsonNodeFactory.instance.objectNode(); - for (Map.Entry mapping : outputKeyMapping.entrySet()) { - Object dbColumnValue = row.get(mapping.getKey()); - String propertyTypeForDataType = - ConfigAssignmentUtils.getPropertyType(ctx, entrySchema, mapping.getKey()); - JsonUtils.populatePrimitiveValues(mapping.getKey(), dbColumnValue, propertyTypeForDataType, - arrayChildNode); - } - arrayNode.add(arrayChildNode); - } - } - // Set the List of Complex Values - ResourceAssignmentUtils.setResourceDataValue(componentContext, resourceAssignment, arrayNode); - } else { - throw new SvcLogicException(String.format("Entry schema is not defined for dictionary (%s) info", - resourceAssignment.getDictionaryName())); - } - } else { - // Complex Types - Map row = rows.get(0); - ObjectNode objectNode = JsonNodeFactory.instance.objectNode(); - for (Map.Entry mapping : outputKeyMapping.entrySet()) { - Object dbColumnValue = row.get(mapping.getKey()); - String propertyTypeForDataType = ConfigAssignmentUtils.getPropertyType(ctx, type, mapping.getKey()); - JsonUtils.populatePrimitiveValues(mapping.getKey(), dbColumnValue, propertyTypeForDataType, objectNode); - } - ResourceAssignmentUtils.setResourceDataValue(componentContext, resourceAssignment, objectNode); - } - } - - @Override - public void postProcess(Map inParams, SvcLogicContext ctx, Map componentContext) - throws SvcLogicException { - // Auto-generated method stub - } - -} diff --git a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/processor/DefaultResourceProcessor.java b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/processor/DefaultResourceProcessor.java deleted file mode 100644 index 563d5b523..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/processor/DefaultResourceProcessor.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.assignment.processor; - -import java.util.List; -import java.util.Map; -import org.apache.commons.lang3.StringUtils; -import org.onap.ccsdk.features.assignment.service.ConfigAssignmentUtils; -import org.onap.ccsdk.features.data.adaptor.service.ConfigResourceService; -import org.onap.ccsdk.features.model.ConfigModelConstant; -import org.onap.ccsdk.features.model.ConfigModelException; -import org.onap.ccsdk.features.model.data.ResourceAssignment; -import org.onap.ccsdk.features.model.service.ComponentNode; -import org.onap.ccsdk.features.model.utils.ResourceAssignmentUtils; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; - -public class DefaultResourceProcessor implements ComponentNode { - - public DefaultResourceProcessor(ConfigResourceService configResourceService) {} - - @Override - public Boolean preCondition(Map inParams, SvcLogicContext ctx, Map componentContext) - throws SvcLogicException { - return Boolean.TRUE; - } - - @Override - public void preProcess(Map inParams, SvcLogicContext ctx, Map componentContext) - throws SvcLogicException { - // Auto-generated method stub - } - - @Override - public void process(Map inParams, SvcLogicContext ctx) throws SvcLogicException { - // Auto-generated method stub - } - - @SuppressWarnings("unchecked") - @Override - public void process(Map inParams, SvcLogicContext ctx, Map componentContext) - throws SvcLogicException { - try { - List batchResourceAssignment = - (List) componentContext.get(ConfigModelConstant.PROPERTY_RESOURCE_ASSIGNMENTS); - - if (batchResourceAssignment != null && !batchResourceAssignment.isEmpty()) { - for (ResourceAssignment resourceAssignment : batchResourceAssignment) { - processResourceAssignment(ctx, componentContext, resourceAssignment); - } - } - } catch (Exception e) { - throw new SvcLogicException(String.format("DefaultResourceProcessor Exception : (%s)", e), e); - } - - } - - private void processResourceAssignment(SvcLogicContext ctx, Map componentContext, - ResourceAssignment resourceAssignment) throws ConfigModelException, SvcLogicException { - if (resourceAssignment != null && StringUtils.isNotBlank(resourceAssignment.getName()) - && resourceAssignment.getProperty() != null) { - try { - // Check if It has Input - Object value = ConfigAssignmentUtils.getContextKeyValue(ctx, resourceAssignment.getName()); - if (value == null) { - value = resourceAssignment.getProperty().getDefaultValue(); - } - - // if value is null don't call setResourceDataValue to populate the value - if (value != null) { - ResourceAssignmentUtils.setResourceDataValue(componentContext, resourceAssignment, value); - } - - // Check the value has populated for mandatory case - ResourceAssignmentUtils.assertTemplateKeyValueNotNull(componentContext, resourceAssignment); - } catch (Exception e) { - ResourceAssignmentUtils.setFailedResourceDataValue(componentContext, resourceAssignment, - e.getMessage()); - throw new SvcLogicException( - String.format("Failed in template key (%s) assignments with : (%s)", resourceAssignment, e), e); - } - } - } - - @Override - public void postProcess(Map inParams, SvcLogicContext ctx, Map componentContext) - throws SvcLogicException { - // Auto-generated method stub - - } - -} diff --git a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/processor/InputResourceProcessor.java b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/processor/InputResourceProcessor.java deleted file mode 100644 index 6c73b08de..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/processor/InputResourceProcessor.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.assignment.processor; - -import java.util.List; -import java.util.Map; -import org.apache.commons.lang3.StringUtils; -import org.onap.ccsdk.features.data.adaptor.service.ConfigResourceService; -import org.onap.ccsdk.features.model.ConfigModelConstant; -import org.onap.ccsdk.features.model.ConfigModelException; -import org.onap.ccsdk.features.model.data.ResourceAssignment; -import org.onap.ccsdk.features.model.service.ComponentNode; -import org.onap.ccsdk.features.model.utils.ResourceAssignmentUtils; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; - -public class InputResourceProcessor implements ComponentNode { - - public InputResourceProcessor(ConfigResourceService configResourceService) {} - - @Override - public Boolean preCondition(Map inParams, SvcLogicContext ctx, Map componentContext) - throws SvcLogicException { - return Boolean.TRUE; - } - - @Override - public void preProcess(Map inParams, SvcLogicContext ctx, Map componentContext) - throws SvcLogicException { - // Auto-generated method stub - } - - @Override - public void process(Map inParams, SvcLogicContext ctx) throws SvcLogicException { - // Auto-generated method stub - } - - @SuppressWarnings("unchecked") - @Override - public void process(Map inParams, SvcLogicContext ctx, Map componentContext) - throws SvcLogicException { - try { - List batchResourceAssignment = - (List) componentContext.get(ConfigModelConstant.PROPERTY_RESOURCE_ASSIGNMENTS); - if (batchResourceAssignment != null && !batchResourceAssignment.isEmpty()) { - for (ResourceAssignment resourceAssignment : batchResourceAssignment) { - processResourceAssignment(ctx, componentContext, resourceAssignment); - } - } - } catch (Exception e) { - throw new SvcLogicException(String.format("InputResourceProcessor Exception : (%s)", e), e); - } - } - - private void processResourceAssignment(SvcLogicContext ctx, Map componentContext, - ResourceAssignment resourceAssignment) throws ConfigModelException, SvcLogicException { - try { - if (StringUtils.isNotBlank(resourceAssignment.getName())) { - String value = ctx.getAttribute(resourceAssignment.getName()); - // if value is null don't call setResourceDataValue to populate the value - if (StringUtils.isNotBlank(value)) { - ResourceAssignmentUtils.setResourceDataValue(componentContext, resourceAssignment, value); - } - } - - // Check the value has populated for mandatory case - ResourceAssignmentUtils.assertTemplateKeyValueNotNull(componentContext, resourceAssignment); - } catch (Exception e) { - ResourceAssignmentUtils.setFailedResourceDataValue(componentContext, resourceAssignment, e.getMessage()); - throw new SvcLogicException( - String.format("Failed in template key (%s) assignments with : (%s)", resourceAssignment, e), e); - } - } - - @Override - public void postProcess(Map inParams, SvcLogicContext ctx, Map componentContext) - throws SvcLogicException { - // Auto-generated method stub - } - -} diff --git a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/processor/MdsalResourceProcessor.java b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/processor/MdsalResourceProcessor.java deleted file mode 100644 index dfc041cee..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/processor/MdsalResourceProcessor.java +++ /dev/null @@ -1,239 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.assignment.processor; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.collections.MapUtils; -import org.apache.commons.lang3.StringUtils; -import org.onap.ccsdk.features.assignment.service.ConfigAssignmentUtils; -import org.onap.ccsdk.features.model.ConfigModelConstant; -import org.onap.ccsdk.features.model.ConfigModelException; -import org.onap.ccsdk.features.model.data.ResourceAssignment; -import org.onap.ccsdk.features.model.data.dict.ResourceDefinition; -import org.onap.ccsdk.features.model.data.dict.SourcesDefinition; -import org.onap.ccsdk.features.model.service.ComponentNode; -import org.onap.ccsdk.features.model.utils.ResourceAssignmentUtils; -import org.onap.ccsdk.features.model.utils.TransformationUtils; -import org.onap.ccsdk.features.rest.adaptor.ConfigRestAdaptorConstants; -import org.onap.ccsdk.features.rest.adaptor.service.ConfigRestAdaptorService; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.fasterxml.jackson.databind.JsonNode; - -public class MdsalResourceProcessor implements ComponentNode { - - private static EELFLogger logger = EELFManager.getInstance().getLogger(MdsalResourceProcessor.class); - private ConfigRestAdaptorService configRestAdaptorService; - private Map dictionaries; - - public MdsalResourceProcessor(ConfigRestAdaptorService configRestAdaptorService) { - this.configRestAdaptorService = configRestAdaptorService; - } - - @Override - public Boolean preCondition(Map inParams, SvcLogicContext ctx, Map componentContext) - throws SvcLogicException { - return Boolean.TRUE; - } - - @Override - public void preProcess(Map inParams, SvcLogicContext ctx, Map componentContext) - throws SvcLogicException { - // Auto-generated method stub - } - - @Override - public void process(Map inParams, SvcLogicContext ctx) throws SvcLogicException { - // Auto-generated method stub - } - - @SuppressWarnings("unchecked") - @Override - public void process(Map inParams, SvcLogicContext ctx, Map componentContext) - throws SvcLogicException { - try { - List batchResourceAssignment = - (List) componentContext.get(ConfigModelConstant.PROPERTY_RESOURCE_ASSIGNMENTS); - dictionaries = - (Map) componentContext.get(ConfigModelConstant.PROPERTY_DICTIONARIES); - - if (CollectionUtils.isNotEmpty(batchResourceAssignment)) { - for (ResourceAssignment resourceAssignment : batchResourceAssignment) { - processResourceAssignmnet(ctx, componentContext, resourceAssignment); - } - } - } catch (Exception e) { - throw new SvcLogicException(String.format("MdsalResourceProcessor Exception : (%s) ", e), e); - } - } - - private void processResourceAssignmnet(SvcLogicContext ctx, Map componentContext, - ResourceAssignment resourceAssignment) throws ConfigModelException, SvcLogicException { - - try { - // Validating Resource Assignment and Dictionary Definition data - validate(resourceAssignment); - - // Check if It has Input - Object value = ConfigAssignmentUtils.getContextKeyValue(ctx, resourceAssignment.getName()); - if (value != null) { - logger.info("mdsal source template key ({}) found from input and value is ({})", - resourceAssignment.getName(), value); - ResourceAssignmentUtils.setResourceDataValue(componentContext, resourceAssignment, value); - return; - } - - ResourceDefinition resourceDefinition = dictionaries.get(resourceAssignment.getDictionaryName()); - SourcesDefinition sourceMdsal = resourceDefinition.getSources().get("mdsal"); - String urlPath = sourceMdsal.getProperties().getUrlPath(); - String path = sourceMdsal.getProperties().getPath(); - Map inputKeyMapping = sourceMdsal.getProperties().getInputKeyMapping(); - Map outputKeyMapping = sourceMdsal.getProperties().getOutputKeyMapping(); - - logger.info( - "mdsal dictionary information : urlpath ({}), path({}), inputKeyMapping ({}), outputKeyMapping ({})", - urlPath, path, inputKeyMapping, outputKeyMapping); - - // Resolving url Variables - Map urlVariables = populateUrlVariables(inputKeyMapping, componentContext); - for (Map.Entry entry : urlVariables.entrySet()) { - urlPath = urlPath.replaceAll("\\$" + entry.getKey(), entry.getValue().toString()); - } - - String restResponse = fetchResourceFromMDSAL(urlPath); - // if restResponse is null don't call processMdsalResults to populate the value - if (StringUtils.isNotBlank(restResponse)) { - // Processing MDSAL Response - processMdsalResults(ctx, componentContext, resourceAssignment, sourceMdsal, restResponse); - } else { - logger.warn("Coudn't get proper mdsal Response content ({}) for Resource Name ({}) for URI ({})", - restResponse, resourceAssignment.getDictionaryName(), urlPath); - } - - // Check the value has populated for mandatory case - ResourceAssignmentUtils.assertTemplateKeyValueNotNull(componentContext, resourceAssignment); - } catch (Exception e) { - ResourceAssignmentUtils.setFailedResourceDataValue(componentContext, resourceAssignment, e.getMessage()); - throw new SvcLogicException( - String.format("Failed in assignments for (%s) with (%s)", resourceAssignment, e), e); - } - } - - private String fetchResourceFromMDSAL(String urlPath) { - String response = null; - try { - response = configRestAdaptorService.getResource(ConfigRestAdaptorConstants.SELECTOR_RESTCONF, urlPath, - String.class); - } catch (Exception e) { - logger.warn("Fetching MDSAL data for URL ({}) failed with Error ({})", urlPath, e); - } - return response; - } - - private void validate(ResourceAssignment resourceAssignment) throws SvcLogicException { - if (resourceAssignment == null) { - throw new SvcLogicException("resource assignment is not defined"); - } - - if (StringUtils.isBlank(resourceAssignment.getName())) { - throw new SvcLogicException("resource assignment template key is not defined"); - } - - if (StringUtils.isBlank(resourceAssignment.getDictionaryName())) { - throw new SvcLogicException( - String.format("resource assignment dictionary name is not defined for template key (%s)", - resourceAssignment.getName())); - } - - if (!ConfigModelConstant.SOURCE_MDSAL.equalsIgnoreCase(resourceAssignment.getDictionarySource())) { - throw new SvcLogicException(String.format("resource assignment source is not mdsal, it is (%s)", - resourceAssignment.getDictionarySource())); - } - - ResourceDefinition resourceDefinition = dictionaries.get(resourceAssignment.getDictionaryName()); - if (resourceDefinition == null) { - throw new SvcLogicException(String.format("missing resource dictionary definition for name (%s) ", - resourceAssignment.getDictionaryName())); - } - - if (StringUtils.isBlank(resourceDefinition.getProperty().getType())) { - throw new SvcLogicException(String.format(String.format("Failed to get dictionary (%s) data type info.", - resourceAssignment.getDictionaryName()))); - } - - if (resourceDefinition.getSources() == null || resourceDefinition.getSources().get("mdsal") == null) { - throw new SvcLogicException( - String.format("missing resource dictionary mdsal source definition for name (%s) ", - resourceAssignment.getDictionaryName())); - } - - SourcesDefinition sourceMdsal = resourceDefinition.getSources().get("mdsal"); - if (StringUtils.isBlank(sourceMdsal.getProperties().getUrlPath())) { - throw new SvcLogicException(String.format("Failed to get request URL Path for dictionary (%s)", - resourceAssignment.getDictionaryName())); - } - - if (StringUtils.isBlank(sourceMdsal.getProperties().getPath())) { - throw new SvcLogicException(String.format("Failed to get request Path for dictionary (%s)", - resourceAssignment.getDictionaryName())); - } - } - - private Map populateUrlVariables(Map inputKeyMapping, - Map componentContext) { - Map urlVariables = new HashMap<>(); - if (MapUtils.isNotEmpty(inputKeyMapping)) { - - for (Map.Entry mapping : inputKeyMapping.entrySet()) { - ResourceDefinition referenceDictionaryDefinition = dictionaries.get(mapping.getValue()); - Object expressionValue = - ResourceAssignmentUtils.getDictionaryKeyValue(componentContext, referenceDictionaryDefinition); - logger.trace("Reference dictionary key ({}), value ({})", mapping.getKey(), expressionValue); - urlVariables.put(mapping.getKey(), expressionValue); - } - } - return urlVariables; - } - - private void processMdsalResults(SvcLogicContext ctx, Map componentContext, - ResourceAssignment resourceAssignment, SourcesDefinition sourceMdsal, String restResponse) - throws SvcLogicException, ConfigModelException { - - Map outputKeyMapping = sourceMdsal.getProperties().getOutputKeyMapping(); - JsonNode responseNode = TransformationUtils.getJsonNodeForString(restResponse); - if (StringUtils.isNotBlank(sourceMdsal.getProperties().getPath())) { - responseNode = responseNode.at(sourceMdsal.getProperties().getPath()); - } - if (responseNode != null) { - ConfigAssignmentUtils.populateValueForOutputMapping(ctx, componentContext, resourceAssignment, - outputKeyMapping, responseNode); - } - } - - @Override - public void postProcess(Map inParams, SvcLogicContext ctx, Map componentContext) - throws SvcLogicException { - // Do Nothing - } - -} diff --git a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/processor/ProcessorFactory.java b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/processor/ProcessorFactory.java deleted file mode 100644 index bb620a1a3..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/processor/ProcessorFactory.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.assignment.processor; - -import org.onap.ccsdk.features.data.adaptor.service.ConfigResourceService; -import org.onap.ccsdk.features.model.ConfigModelConstant; -import org.onap.ccsdk.features.model.service.ComponentNode; -import org.onap.ccsdk.features.model.service.ComponentNodeService; -import org.onap.ccsdk.features.rest.adaptor.service.ConfigRestAdaptorService; - -public class ProcessorFactory { - - private ConfigResourceService configResourceService; - private ConfigRestAdaptorService configRestAdaptorService; - private ComponentNodeService componentNodeService; - - public ProcessorFactory(ConfigResourceService configResourceService, - ConfigRestAdaptorService configRestAdaptorService, ComponentNodeService componentNodeService) { - this.componentNodeService = componentNodeService; - this.configResourceService = configResourceService; - this.configRestAdaptorService = configRestAdaptorService; - } - - public ComponentNode getInstance(String source) { - - if (ConfigModelConstant.SOURCE_DEFAULT.equalsIgnoreCase(source)) { - return new DefaultResourceProcessor(configResourceService); - } else if (ConfigModelConstant.SOURCE_DB.equalsIgnoreCase(source)) { - return new DBResourceProcessor(configResourceService); - } else if (ConfigModelConstant.SOURCE_MDSAL.equalsIgnoreCase(source)) { - return new MdsalResourceProcessor(configRestAdaptorService); - } - // Default - return new InputResourceProcessor(configResourceService); - } - -} diff --git a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/processor/ResourceAssignmentProcessor.java b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/processor/ResourceAssignmentProcessor.java deleted file mode 100644 index 3ee49f085..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/processor/ResourceAssignmentProcessor.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.assignment.processor; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.apache.commons.collections.CollectionUtils; -import org.onap.ccsdk.features.model.data.ResourceAssignment; -import org.onap.ccsdk.features.model.utils.TopologicalSortingUtils; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -public class ResourceAssignmentProcessor { - private static EELFLogger logger = EELFManager.getInstance().getLogger(ResourceAssignmentProcessor.class); - - private List assignments; - private Map resourceAssignmentMap; - - @SuppressWarnings("squid:S1172") - public ResourceAssignmentProcessor(List assignments, SvcLogicContext ctx) { - this.assignments = assignments; - this.resourceAssignmentMap = new HashMap<>(); - } - - @SuppressWarnings("squid:S3776") - public List> process() { - List> sequenceBatchResourceAssignment = new ArrayList<>(); - if (this.assignments != null) { - logger.info("Assignments ({})", this.assignments); - this.assignments.forEach(resourceMapping -> { - if (resourceMapping != null) { - logger.trace("Processing Key ({})", resourceMapping.getName()); - resourceAssignmentMap.put(resourceMapping.getName(), resourceMapping); - } - }); - - TopologicalSortingUtils topologySorting = new TopologicalSortingUtils<>(); - this.resourceAssignmentMap.forEach((mappingKey, mapping) -> { - if (mapping != null) { - if (mapping.getDependencies() != null && !mapping.getDependencies().isEmpty()) { - for (String dependency : mapping.getDependencies()) { - topologySorting.add(resourceAssignmentMap.get(dependency), mapping); - } - } else { - topologySorting.add(null, mapping); - } - } - }); - - List sequencedResourceAssignments = topologySorting.topSort(); - logger.info("Sorted Sequenced Assignments ({})", sequencedResourceAssignments); - - List batchResourceAssignment = null; - List batchAssignmentName = null; - for (int i = 0; i < sequencedResourceAssignments.size(); i++) { - ResourceAssignment resourceAssignment = sequencedResourceAssignments.get(i); - ResourceAssignment previousResourceAssignment = null; - - if (i > 0) { - previousResourceAssignment = sequencedResourceAssignments.get(i - 1); - } - if (resourceAssignment != null) { - - boolean dependencyPresence = false; - if (batchAssignmentName != null && resourceAssignment.getDependencies() != null) { - dependencyPresence = - CollectionUtils.containsAny(batchAssignmentName, resourceAssignment.getDependencies()); - } - - logger.trace("({}) -> Checking ({}), with ({}), result ({})", resourceAssignment.getName(), - batchAssignmentName, resourceAssignment.getDependencies(), dependencyPresence); - - if (previousResourceAssignment != null && resourceAssignment.getDictionarySource() != null - && resourceAssignment.getDictionarySource() - .equalsIgnoreCase(previousResourceAssignment.getDictionarySource()) - && !dependencyPresence) { - batchResourceAssignment.add(resourceAssignment); - batchAssignmentName.add(resourceAssignment.getName()); - } else { - if (batchResourceAssignment != null) { - sequenceBatchResourceAssignment.add(batchResourceAssignment); - logger.trace("Created old Set ({})", batchAssignmentName); - } - batchResourceAssignment = new ArrayList<>(); - batchResourceAssignment.add(resourceAssignment); - - batchAssignmentName = new ArrayList<>(); - batchAssignmentName.add(resourceAssignment.getName()); - } - } - - if (i == (sequencedResourceAssignments.size() - 1)) { - logger.trace("Created old Set ({})", batchAssignmentName); - sequenceBatchResourceAssignment.add(batchResourceAssignment); - } - } - logger.info("Batched Sequence : ({})", sequenceBatchResourceAssignment); - } - return sequenceBatchResourceAssignment; - } - -} diff --git a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/service/ConfigAssignmentNode.java b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/service/ConfigAssignmentNode.java deleted file mode 100644 index aaeadcabd..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/service/ConfigAssignmentNode.java +++ /dev/null @@ -1,231 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.assignment.service; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.apache.commons.collections.MapUtils; -import org.apache.commons.lang3.StringUtils; -import org.onap.ccsdk.features.assignment.ConfigAssignmentConstants; -import org.onap.ccsdk.features.assignment.data.ResourceAssignmentData; -import org.onap.ccsdk.features.data.adaptor.service.ConfigResourceService; -import org.onap.ccsdk.features.generator.service.ConfigGeneratorService; -import org.onap.ccsdk.features.model.ConfigModelConstant; -import org.onap.ccsdk.features.model.service.ComponentNode; -import org.onap.ccsdk.features.model.service.ComponentNodeService; -import org.onap.ccsdk.features.model.service.ConfigModelService; -import org.onap.ccsdk.features.model.utils.TransformationUtils; -import org.onap.ccsdk.features.rest.adaptor.service.ConfigRestAdaptorService; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -public class ConfigAssignmentNode implements ComponentNode { - private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigAssignmentNode.class); - - private ComponentNodeService componentNodeService; - private ConfigResourceService configResourceService; - private ConfigModelService configModelService; - private ConfigRestAdaptorService configRestAdaptorService; - private ConfigGeneratorService configGeneratorService; - - public ConfigAssignmentNode(ConfigResourceService configResourceService, - ConfigRestAdaptorService configRestAdaptorService, ConfigModelService configModelService, - ComponentNodeService componentNodeService, ConfigGeneratorService configGeneratorService) { - logger.info("{} Constrctor Initiated", "ConfigAssignmentNode"); - this.componentNodeService = componentNodeService; - this.configResourceService = configResourceService; - this.configModelService = configModelService; - this.configRestAdaptorService = configRestAdaptorService; - this.configGeneratorService = configGeneratorService; - } - - @Override - public Boolean preCondition(Map inParams, SvcLogicContext ctx, Map componentContext) - throws SvcLogicException { - return Boolean.TRUE; - } - - @Override - public void preProcess(Map inParams, SvcLogicContext ctx, Map componentContext) - throws SvcLogicException { - // Auto-generated method stub - } - - /** - * This method is used to resolve the resources defined in the template. Generic Resource API DG - * calls this execute node. - * - * @param inParams This is the input parameter to process this node - * - *
-    request-id                  (string):           Tracking Id 
-    resource-type               (string):           Resource Type ( ex : vnf-type) 
-    resource-id                 (string):           Resource Id 
-    service-template-name       (string):           Blueprint Name 
-    service-template-version    (string):           Blueprint Version 
-    action-name                 (string): 
-    template-names              (List of string):   Template Names / Artifact Node Names to resolve. ["template1", "template2"] 
-    input-data                  (string):           Input Data in JSON String, for the substitution in the Template. 
-    prifix                      (string):           Return Value selector
-     *        
- * - * @param ctx This is the service logger context, Output will be stored ( - * .resource-assignment-params. : Output Data in JSON String. - * .status .error-message ) - * @throws SvcLogicException On processing error. - */ - - @Override - public void process(Map inParams, SvcLogicContext ctx) throws SvcLogicException { - - final String responsePrefix = StringUtils.isNotBlank(inParams.get(ConfigModelConstant.PROPERTY_SELECTOR)) - ? (inParams.get(ConfigModelConstant.PROPERTY_SELECTOR) + ".") - : ""; - try { - - ResourceAssignmentData resourceAssignmentData = populateResourceData(inParams); - resourceAssignmentData.setSvcLogicContext(ctx); - Map componentContext = new HashMap<>(); - resourceAssignmentData.setContext(componentContext); - resourceAssignmentData.setReloadModel(true); - - ConfigAssignmentProcessService configAssignmentProcessService = - new ConfigAssignmentProcessService(configResourceService, configRestAdaptorService, - configModelService, componentNodeService, configGeneratorService); - configAssignmentProcessService.resolveResources(resourceAssignmentData); - - if (MapUtils.isNotEmpty(resourceAssignmentData.getTemplatesMashedContents())) { - resourceAssignmentData.getTemplatesMashedContents().forEach((templateName, previewContent) -> { - logger.debug("For Template name : ({}),\n Preview Content is : ({})", templateName, previewContent); - ctx.setAttribute( - responsePrefix + ConfigAssignmentConstants.OUTPUT_PARAM_MASHED_DATA + "." + templateName, - previewContent); - }); - } - ctx.setAttribute(responsePrefix + ConfigAssignmentConstants.OUTPUT_PARAM_STATUS, - ConfigAssignmentConstants.OUTPUT_STATUS_SUCCESS); - } catch (Exception e) { - ctx.setAttribute(responsePrefix + ConfigAssignmentConstants.OUTPUT_PARAM_STATUS, - ConfigAssignmentConstants.OUTPUT_STATUS_FAILURE); - ctx.setAttribute(responsePrefix + ConfigAssignmentConstants.OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage()); - throw new SvcLogicException(e.getMessage(), e); - } - } - - @Override - public void process(Map inParams, SvcLogicContext ctx, Map componentContext) - throws SvcLogicException { - - final String responsePrefix = StringUtils.isNotBlank(inParams.get(ConfigModelConstant.PROPERTY_SELECTOR)) - ? (inParams.get(ConfigModelConstant.PROPERTY_SELECTOR) + ".") - : ""; - try { - - ResourceAssignmentData resourceAssignmentData = populateResourceData(inParams); - resourceAssignmentData.setSvcLogicContext(ctx); - resourceAssignmentData.setContext(componentContext); - resourceAssignmentData.setReloadModel(false); - - ConfigAssignmentProcessService configAssignmentProcessService = - new ConfigAssignmentProcessService(configResourceService, configRestAdaptorService, - configModelService, componentNodeService, configGeneratorService); - configAssignmentProcessService.resolveResources(resourceAssignmentData); - ctx.setAttribute(responsePrefix + ConfigAssignmentConstants.OUTPUT_PARAM_STATUS, - ConfigAssignmentConstants.OUTPUT_STATUS_SUCCESS); - - } catch (Exception e) { - ctx.setAttribute(responsePrefix + ConfigAssignmentConstants.OUTPUT_PARAM_STATUS, - ConfigAssignmentConstants.OUTPUT_STATUS_FAILURE); - ctx.setAttribute(responsePrefix + ConfigAssignmentConstants.OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage()); - throw new SvcLogicException(e.getMessage(), e); - } - } - - @Override - public void postProcess(Map inParams, SvcLogicContext ctx, Map componentContext) - throws SvcLogicException { - // Do Nothing - } - - private ResourceAssignmentData populateResourceData(Map inParams) throws SvcLogicException { - validateInputParams(inParams); - - String requestId = inParams.get(ConfigAssignmentConstants.INPUT_PARAM_REQUEST_ID); - String resourceId = inParams.get(ConfigAssignmentConstants.INPUT_PARAM_RESOURCE_ID); - String resourceType = inParams.get(ConfigAssignmentConstants.INPUT_PARAM_RESOURCE_TYPE); - String serviceTemplateName = inParams.get(ConfigModelConstant.SERVICE_TEMPLATE_KEY_ARTIFACT_NAME); - String serviceTemplateVersion = inParams.get(ConfigModelConstant.SERVICE_TEMPLATE_KEY_ARTIFACT_VERSION); - String actionName = inParams.get(ConfigModelConstant.PROPERTY_ACTION_NAME); - String inputData = inParams.get(ConfigAssignmentConstants.INPUT_PARAM_INPUT_DATA); - - String templateNamesStr = inParams.get(ConfigAssignmentConstants.INPUT_PARAM_TEMPLATE_NAMES); - List templateNames = TransformationUtils.getListfromJson(templateNamesStr, String.class); - - ResourceAssignmentData resourceAssignmentData = new ResourceAssignmentData(); - resourceAssignmentData.setRequestId(requestId); - resourceAssignmentData.setResourceId(resourceId); - resourceAssignmentData.setResourceType(resourceType); - resourceAssignmentData.setServiceTemplateName(serviceTemplateName); - resourceAssignmentData.setServiceTemplateVersion(serviceTemplateVersion); - resourceAssignmentData.setActionName(actionName); - resourceAssignmentData.setInputData(inputData); - resourceAssignmentData.setTemplateNames(templateNames); - - return resourceAssignmentData; - } - - private void validateInputParams(Map inParams) throws SvcLogicException { - if (inParams == null) { - throw new SvcLogicException("Input parameters missing"); - } - - String requestId = inParams.get(ConfigAssignmentConstants.INPUT_PARAM_REQUEST_ID); - if (StringUtils.isBlank(requestId)) { - throw new SvcLogicException("Request id parameters missing"); - } - String resourceId = inParams.get(ConfigAssignmentConstants.INPUT_PARAM_RESOURCE_ID); - if (StringUtils.isBlank(resourceId)) { - throw new SvcLogicException("Resource id parameter is missing"); - } - String resourceType = inParams.get(ConfigAssignmentConstants.INPUT_PARAM_RESOURCE_TYPE); - if (StringUtils.isBlank(resourceType)) { - throw new SvcLogicException("Resource type parameter is missing"); - } - String recipeName = inParams.get(ConfigAssignmentConstants.INPUT_PARAM_ACTION_NAME); - if (StringUtils.isBlank(recipeName)) { - throw new SvcLogicException("Action name is parameter is missing"); - } - String templateNames = inParams.get(ConfigAssignmentConstants.INPUT_PARAM_TEMPLATE_NAMES); - if (StringUtils.isBlank(templateNames)) { - throw new SvcLogicException("Template names parameter missing"); - } - String serviceTemplateName = inParams.get(ConfigModelConstant.SERVICE_TEMPLATE_KEY_ARTIFACT_NAME); - if (StringUtils.isBlank(serviceTemplateName)) { - throw new SvcLogicException("Service Template name parameter missing"); - } - String serviceTemplateVersion = inParams.get(ConfigModelConstant.SERVICE_TEMPLATE_KEY_ARTIFACT_VERSION); - if (StringUtils.isBlank(serviceTemplateVersion)) { - throw new SvcLogicException("Service Template version parameter missing"); - } - - } - -} diff --git a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/service/ConfigAssignmentPersistService.java b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/service/ConfigAssignmentPersistService.java deleted file mode 100644 index 44ddf5382..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/service/ConfigAssignmentPersistService.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.assignment.service; - -import java.util.List; -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.lang3.StringUtils; -import org.onap.ccsdk.features.data.adaptor.DataAdaptorConstants; -import org.onap.ccsdk.features.data.adaptor.domain.ConfigResource; -import org.onap.ccsdk.features.data.adaptor.domain.ResourceAssignmentData; -import org.onap.ccsdk.features.data.adaptor.domain.TransactionLog; -import org.onap.ccsdk.features.data.adaptor.service.ConfigResourceService; -import org.onap.ccsdk.features.model.ConfigModelConstant; -import org.onap.ccsdk.features.model.data.ResourceAssignment; -import org.onap.ccsdk.features.model.utils.ResourceAssignmentUtils; -import org.onap.ccsdk.features.model.utils.TransformationUtils; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -public class ConfigAssignmentPersistService { - - private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigAssignmentPersistService.class); - - private ConfigResourceService configResourceService; - - public ConfigAssignmentPersistService(ConfigResourceService configResourceService) { - this.configResourceService = configResourceService; - } - - public void saveResourceMapping( - org.onap.ccsdk.features.assignment.data.ResourceAssignmentData resourceAssignmentData, String templateName, - List resourceAssignments) throws SvcLogicException { - try { - - if (resourceAssignmentData == null) { - throw new SvcLogicException("Resource assignment data is missing"); - } - - if (StringUtils.isBlank(resourceAssignmentData.getRequestId())) { - logger.warn("Request Id ({}) is missing, may be getting request for resource update.", - resourceAssignmentData.getRequestId()); - } - - if (StringUtils.isBlank(resourceAssignmentData.getResourceId())) { - throw new SvcLogicException("Resource Id is missing"); - } - - if (StringUtils.isBlank(resourceAssignmentData.getResourceType())) { - throw new SvcLogicException("Resource type is missing"); - } - - if (StringUtils.isBlank(resourceAssignmentData.getActionName())) { - throw new SvcLogicException("Action name is missing"); - } - - if (StringUtils.isBlank(templateName)) { - throw new SvcLogicException("template name is missing"); - } - - StringBuilder builder = new StringBuilder(); - builder.append("Resource Assignment for Template Name :"); - builder.append(templateName); - builder.append("\n"); - builder.append(TransformationUtils.getJson(resourceAssignments, true)); - - configResourceService.save(new TransactionLog(resourceAssignmentData.getRequestId(), - DataAdaptorConstants.LOG_MESSAGE_TYPE_LOG, builder.toString())); - - // Resource Data should be Regenerated based on the new Updates - String resourceData = ResourceAssignmentUtils.generateResourceDataForAssignments(resourceAssignments); - - List resourceAssignmentDataList = - ConfigAssignmentUtils.convertResoureAssignmentList(resourceAssignments); - - ConfigResource configResource = new ConfigResource(); - configResource.setRequestId(resourceAssignmentData.getRequestId()); - configResource.setServiceTemplateName(resourceAssignmentData.getServiceTemplateName()); - configResource.setServiceTemplateVersion(resourceAssignmentData.getServiceTemplateVersion()); - configResource.setRecipeName(resourceAssignmentData.getActionName()); - configResource.setResourceId(resourceAssignmentData.getResourceId()); - configResource.setResourceType(resourceAssignmentData.getResourceType()); - configResource.setResourceData(resourceData); - configResource.setTemplateName(templateName); - configResource.setStatus(ConfigModelConstant.STATUS_SUCCESS); - configResource.setUpdatedBy(ConfigModelConstant.USER_SYSTEM); - - if (CollectionUtils.isNotEmpty(resourceAssignmentDataList)) { - configResource.setResourceAssignments(resourceAssignmentDataList); - } - configResource = configResourceService.saveConfigResource(configResource); - logger.info("Resource data saved successfully for the template ({}) with resource id ({})", templateName, - configResource.getResourceId()); - - builder = new StringBuilder(); - builder.append("Resource Data Template Name :"); - builder.append(templateName); - builder.append("\n"); - builder.append(resourceData); - configResourceService.save(new TransactionLog(resourceAssignmentData.getRequestId(), - DataAdaptorConstants.LOG_MESSAGE_TYPE_LOG, builder.toString())); - - } catch (Exception e) { - throw new SvcLogicException("ConfigAssignmentPersistService : " + e.getMessage(), e); - } - - } - -} diff --git a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/service/ConfigAssignmentProcessService.java b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/service/ConfigAssignmentProcessService.java deleted file mode 100644 index 61c035960..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/service/ConfigAssignmentProcessService.java +++ /dev/null @@ -1,238 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.assignment.service; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.lang3.StringUtils; -import org.onap.ccsdk.features.assignment.ConfigAssignmentConstants; -import org.onap.ccsdk.features.assignment.data.ResourceAssignmentData; -import org.onap.ccsdk.features.assignment.processor.ProcessorFactory; -import org.onap.ccsdk.features.assignment.processor.ResourceAssignmentProcessor; -import org.onap.ccsdk.features.data.adaptor.service.ConfigResourceService; -import org.onap.ccsdk.features.generator.service.ConfigGeneratorService; -import org.onap.ccsdk.features.model.ConfigModelConstant; -import org.onap.ccsdk.features.model.data.ResourceAssignment; -import org.onap.ccsdk.features.model.data.dict.ResourceDefinition; -import org.onap.ccsdk.features.model.service.ComponentNode; -import org.onap.ccsdk.features.model.service.ComponentNodeService; -import org.onap.ccsdk.features.model.service.ConfigModelService; -import org.onap.ccsdk.features.model.utils.ResourceAssignmentUtils; -import org.onap.ccsdk.features.model.utils.TransformationUtils; -import org.onap.ccsdk.features.rest.adaptor.service.ConfigRestAdaptorService; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -public class ConfigAssignmentProcessService { - - private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigAssignmentProcessService.class); - - private ComponentNodeService componentNodeService; - private ConfigResourceService configResourceService; - private ConfigModelService configModelService; - private ConfigRestAdaptorService configRestAdaptorService; - private ConfigGeneratorService configGeneratorService; - - public ConfigAssignmentProcessService(ConfigResourceService configResourceService, - ConfigRestAdaptorService configRestAdaptorService, ConfigModelService configModelService, - ComponentNodeService componentNodeService, ConfigGeneratorService configGeneratorService) { - this.componentNodeService = componentNodeService; - this.configResourceService = configResourceService; - this.configModelService = configModelService; - this.configRestAdaptorService = configRestAdaptorService; - this.configGeneratorService = configGeneratorService; - } - - @SuppressWarnings("squid:S1141") - public void resolveResources(ResourceAssignmentData resourceAssignmentData) throws SvcLogicException { - try { - validateInputParams(resourceAssignmentData); - - String serviceTemplateName = resourceAssignmentData.getServiceTemplateName(); - String serviceTemplateVersion = resourceAssignmentData.getServiceTemplateVersion(); - String actionName = resourceAssignmentData.getActionName(); - String inputData = resourceAssignmentData.getInputData(); - SvcLogicContext svcLogicContext = resourceAssignmentData.getSvcLogicContext(); - List templateNames = resourceAssignmentData.getTemplateNames(); - - if (resourceAssignmentData.isReloadModel()) { - Map context = new HashMap<>(); - context.put(ConfigModelConstant.PROPERTY_ACTION_NAME, actionName); - context = configModelService.prepareContext(context, inputData, serviceTemplateName, - serviceTemplateVersion); - context.forEach((key, value) -> svcLogicContext.setAttribute(key, value)); - logger.info("List of Resources provided in input: {}", svcLogicContext.toProperties()); - } - - Map componentContext = resourceAssignmentData.getContext(); - - if (CollectionUtils.isNotEmpty(templateNames)) { - // Get the Resource Assignments for templates and Validate the mappings - ResourceModelService resourceModelService = new ResourceModelService(configModelService); - - // Get the Resource Assignment - Map> templatesResourceAssignments = - resourceModelService.getTemplatesResourceAssignments(svcLogicContext, templateNames); - - // Get the Template Contents - Map templatesContents = - resourceModelService.getTemplatesContents(svcLogicContext, templateNames); - - // Process each template - for (String templateName : templateNames) { - List resourceAssignments = templatesResourceAssignments.get(templateName); - String templateContent = templatesContents.get(templateName); - if (resourceAssignments != null) { - String templateData = null; - try { - // Populate the Dictionary - ResourceDictionaryService resourceDictionaryService = - new ResourceDictionaryService(configRestAdaptorService); - Map dictionaries = - resourceDictionaryService.getDataDictionaryDefinitions(resourceAssignments); - - processResourceAssignments(resourceAssignmentData, svcLogicContext, componentContext, - templateName, resourceAssignments, dictionaries); - - logger.info("decrypting config data for templateName {}", templateName); - templateData = - ResourceAssignmentUtils.generateResourceDataForAssignments(resourceAssignments); - } finally { - saveResourceMapping(resourceAssignmentData, templateName, resourceAssignments); - } - - logger.info("generating config preview for templateName {}", templateName); - ConfigPreviewService configPreviewService = new ConfigPreviewService(configResourceService, - configModelService, configGeneratorService); - String mashedData = configPreviewService.generatePreview(templateContent, templateData); - resourceAssignmentData.getTemplatesMashedContents().put(templateName, mashedData); - resourceAssignmentData.getTemplatesData().put(templateName, templateData); - - } else { - // Do nothing for Mapping not found - logger.warn("No resource Assignment mappings to resolve for templateName {}", templateName); - } - } - } - - } catch (Exception e) { - throw new SvcLogicException(e.getMessage(), e); - } - } - - private void processResourceAssignments(ResourceAssignmentData resourceAssignmentData, SvcLogicContext ctx, - Map componentContext, String templateName, List resourceAssignments, - Map dictionaries) throws SvcLogicException { - - String recipeName = resourceAssignmentData.getActionName(); - - ResourceAssignmentProcessor resourceAssignmentProcessor = - new ResourceAssignmentProcessor(resourceAssignments, ctx); - List> sequenceBatchResourceAssignment = resourceAssignmentProcessor.process(); - - logger.debug("Resource dictionary Info ({})", dictionaries); - - if (sequenceBatchResourceAssignment != null) { - componentContext.put(ConfigModelConstant.PROPERTY_ACTION_NAME, recipeName); - componentContext.put(ConfigModelConstant.PROPERTY_TEMPLATE_NAME, templateName); - componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARIES, dictionaries); - for (List batchResourceAssignment : sequenceBatchResourceAssignment) { - - processBatchResourceAssignments(resourceAssignmentData, ctx, componentContext, batchResourceAssignment); - - logger.debug("Batch Resource data status ({})", TransformationUtils.getJson(batchResourceAssignment)); - } - } - } - - private void processBatchResourceAssignments(ResourceAssignmentData resourceAssignmentData, SvcLogicContext ctx, - Map componentContext, List batchResourceAssignment) - throws SvcLogicException { - - if (CollectionUtils.isNotEmpty(batchResourceAssignment)) { - - ResourceAssignment batchFirstResourceAssignment = batchResourceAssignment.get(0); - if (batchFirstResourceAssignment != null - && StringUtils.isNotBlank(batchFirstResourceAssignment.getDictionarySource())) { - String source = batchFirstResourceAssignment.getDictionarySource(); - // Processing their Source - logger.info("Processing source ({}) with batch ({}) ", source, batchResourceAssignment); - componentContext.put(ConfigModelConstant.PROPERTY_RESOURCE_ASSIGNMENTS, batchResourceAssignment); - - ProcessorFactory factory = - new ProcessorFactory(configResourceService, configRestAdaptorService, componentNodeService); - - ComponentNode processor = factory.getInstance(source); - - Map inParams = new HashMap<>(); - inParams.put(ConfigAssignmentConstants.INPUT_PARAM_REQUEST_ID, resourceAssignmentData.getRequestId()); - inParams.put(ConfigAssignmentConstants.INPUT_PARAM_RESOURCE_ID, resourceAssignmentData.getResourceId()); - inParams.put(ConfigAssignmentConstants.INPUT_PARAM_RESOURCE_TYPE, - resourceAssignmentData.getResourceType()); - inParams.put(ConfigAssignmentConstants.INPUT_PARAM_ACTION_NAME, resourceAssignmentData.getActionName()); - inParams.put(ConfigAssignmentConstants.INPUT_PARAM_TEMPLATE_NAMES, - resourceAssignmentData.getTemplateNames().toString()); - processor.process(inParams, ctx, componentContext); - } - } - } - - private void saveResourceMapping(ResourceAssignmentData resourceAssignmentData, String templateName, - List resourceAssignments) throws SvcLogicException { - if (resourceAssignmentData != null && StringUtils.isNotBlank(templateName)) { - - ConfigAssignmentPersistService configAssignmentPersistService = - new ConfigAssignmentPersistService(configResourceService); - configAssignmentPersistService.saveResourceMapping(resourceAssignmentData, templateName, - resourceAssignments); - } - } - - private void validateInputParams(ResourceAssignmentData resourceAssignmentData) throws SvcLogicException { - if (resourceAssignmentData == null) { - throw new SvcLogicException("Input parameters missing"); - } - - String requestId = resourceAssignmentData.getRequestId(); - if (StringUtils.isBlank(requestId)) { - throw new SvcLogicException("Request id parameters missing"); - } - String resourceId = resourceAssignmentData.getResourceId(); - if (StringUtils.isBlank(resourceId)) { - throw new SvcLogicException("Resource id parameter is missing"); - } - String resourceType = resourceAssignmentData.getResourceType(); - if (StringUtils.isBlank(resourceType)) { - throw new SvcLogicException("Resource type parameter is missing"); - } - String actionName = resourceAssignmentData.getActionName(); - if (StringUtils.isBlank(actionName)) { - throw new SvcLogicException("Action name is parameter is missing"); - } - - List templatesNames = resourceAssignmentData.getTemplateNames(); - if (CollectionUtils.isEmpty(templatesNames)) { - throw new SvcLogicException("Template names parameter missing"); - } - } - -} diff --git a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/service/ConfigAssignmentService.java b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/service/ConfigAssignmentService.java deleted file mode 100644 index e3f32171d..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/service/ConfigAssignmentService.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.assignment.service; - -import java.util.List; -import org.onap.ccsdk.features.assignment.data.ResourceAssignmentData; -import org.onap.ccsdk.features.model.data.ResourceAssignment; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; - -public interface ConfigAssignmentService { - - public void resolveResources(ResourceAssignmentData resourceAssignmentData) throws SvcLogicException; - - public void saveResourceMapping(ResourceAssignmentData resourceAssignmentData, String templateName, - List resourceAssignments) throws SvcLogicException; - - public ResourceAssignmentData generateTemplateResourceMash(ResourceAssignmentData resourceAssignmentData) - throws SvcLogicException; - -} diff --git a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/service/ConfigAssignmentServiceImpl.java b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/service/ConfigAssignmentServiceImpl.java deleted file mode 100644 index bb60a23a4..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/service/ConfigAssignmentServiceImpl.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.assignment.service; - -import java.util.List; -import org.onap.ccsdk.features.assignment.data.ResourceAssignmentData; -import org.onap.ccsdk.features.data.adaptor.service.ConfigResourceService; -import org.onap.ccsdk.features.generator.service.ConfigGeneratorService; -import org.onap.ccsdk.features.model.data.ResourceAssignment; -import org.onap.ccsdk.features.model.service.ComponentNodeService; -import org.onap.ccsdk.features.model.service.ConfigModelService; -import org.onap.ccsdk.features.rest.adaptor.service.ConfigRestAdaptorService; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -public class ConfigAssignmentServiceImpl implements ConfigAssignmentService { - - private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigAssignmentServiceImpl.class); - - private ComponentNodeService componentNodeService; - private ConfigResourceService configResourceService; - private ConfigModelService configModelService; - private ConfigRestAdaptorService configRestAdaptorService; - private ConfigGeneratorService configGeneratorService; - - private static final String CLASS_NAME = "ConfigAssignmentServiceImpl"; - - public ConfigAssignmentServiceImpl(ConfigResourceService configResourceService, - ConfigRestAdaptorService configRestAdaptorService, ConfigModelService configModelService, - ComponentNodeService componentNodeService, ConfigGeneratorService configGeneratorService) { - logger.info("{} Constuctor Initated...", CLASS_NAME); - this.componentNodeService = componentNodeService; - this.configResourceService = configResourceService; - this.configModelService = configModelService; - this.configRestAdaptorService = configRestAdaptorService; - this.configGeneratorService = configGeneratorService; - } - - @Override - public void resolveResources(ResourceAssignmentData resourceAssignmentData) throws SvcLogicException { - ConfigAssignmentProcessService configAssignmentProcessService = - new ConfigAssignmentProcessService(configResourceService, configRestAdaptorService, configModelService, - componentNodeService, configGeneratorService); - configAssignmentProcessService.resolveResources(resourceAssignmentData); - } - - @Override - public void saveResourceMapping(ResourceAssignmentData resourceAssignmentData, String templateName, - List resourceAssignments) throws SvcLogicException { - ConfigAssignmentPersistService configAssignmentPersistService = - new ConfigAssignmentPersistService(configResourceService); - configAssignmentPersistService.saveResourceMapping(resourceAssignmentData, templateName, resourceAssignments); - } - - @Override - public ResourceAssignmentData generateTemplateResourceMash(ResourceAssignmentData resourceAssignmentData) - throws SvcLogicException { - ConfigPreviewService configPreviewService = - new ConfigPreviewService(configResourceService, configModelService, configGeneratorService); - return configPreviewService.generateTemplateResourceMash(resourceAssignmentData); - } - -} diff --git a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/service/ConfigAssignmentUtils.java b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/service/ConfigAssignmentUtils.java deleted file mode 100644 index 15221ae64..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/service/ConfigAssignmentUtils.java +++ /dev/null @@ -1,301 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.assignment.service; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.collections.IteratorUtils; -import org.apache.commons.collections.MapUtils; -import org.apache.commons.lang3.StringUtils; -import org.onap.ccsdk.features.data.adaptor.domain.ResourceAssignmentData; -import org.onap.ccsdk.features.model.ConfigModelConstant; -import org.onap.ccsdk.features.model.ConfigModelException; -import org.onap.ccsdk.features.model.ValidTypes; -import org.onap.ccsdk.features.model.data.DataType; -import org.onap.ccsdk.features.model.data.EntrySchema; -import org.onap.ccsdk.features.model.data.PropertyDefinition; -import org.onap.ccsdk.features.model.data.ResourceAssignment; -import org.onap.ccsdk.features.model.data.dict.ResourceDefinition; -import org.onap.ccsdk.features.model.domain.ResourceDictionary; -import org.onap.ccsdk.features.model.utils.JsonUtils; -import org.onap.ccsdk.features.model.utils.ResourceAssignmentUtils; -import org.onap.ccsdk.features.model.utils.TransformationUtils; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import com.att.eelf.configuration.EELFLogger; -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.JsonNodeFactory; -import com.fasterxml.jackson.databind.node.ObjectNode; - -public class ConfigAssignmentUtils { - - private ConfigAssignmentUtils() { - - } - - private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigAssignmentUtils.class); - - public static synchronized Object getContextKeyValue(SvcLogicContext context, String key) { - Object value = null; - if (context != null && key != null && context.getAttributeKeySet().contains(key)) { - String strValue = context.getAttribute(key); - if (StringUtils.isNotBlank(strValue)) { - value = strValue; - } - } - return value; - } - - /* - * Populate the Field property type for the Data type - */ - public static synchronized String getPropertyType(SvcLogicContext ctx, String dataTypeName, String propertyName) - throws SvcLogicException { - String type = ValidTypes.DATA_TYPE_STRING; - try { - if (ctx != null && StringUtils.isNotBlank(dataTypeName) && StringUtils.isNotBlank(propertyName)) { - String dataTypeContent = ctx.getAttribute(ConfigModelConstant.PROPERTY_DATA_TYPES_DOT + dataTypeName); - if (StringUtils.isNotBlank(dataTypeContent)) { - DataType dataType = TransformationUtils.readValue(dataTypeContent, DataType.class); - if (dataType != null && dataType.getProperties() != null - && dataType.getProperties().containsKey(propertyName)) { - PropertyDefinition propertyDefinition = dataType.getProperties().get(propertyName); - if (StringUtils.isNotBlank(propertyDefinition.getType())) { - type = propertyDefinition.getType(); - logger.trace("Data type({})'s property ({}) is ({})", dataTypeName, propertyName, type); - } else { - throw new SvcLogicException(String.format("Couldn't get data type (%s) ", dataTypeName)); - } - } - } else { - throw new SvcLogicException(String.format("Couldn't get data type (%s) content", dataTypeName)); - } - } - } catch (Exception e) { - logger.error("couldn't get data type({})'s property ({}), type ({}), error message ({}).", dataTypeName, - propertyName, type, e.getMessage()); - throw new SvcLogicException(e.getMessage()); - } - return type; - } - - /* - * Populate the Field property type for the Data type - */ - public static synchronized PropertyDefinition getPropertyDefinition(SvcLogicContext ctx, String dataTypeName, - String propertyName) throws SvcLogicException { - PropertyDefinition propertyDefinition = null; - try { - if (ctx != null && StringUtils.isNotBlank(dataTypeName) && StringUtils.isNotBlank(propertyName)) { - String dataTypeContent = ctx.getAttribute(ConfigModelConstant.PROPERTY_DATA_TYPES_DOT + dataTypeName); - if (StringUtils.isNotBlank(dataTypeContent)) { - DataType dataType = TransformationUtils.readValue(dataTypeContent, DataType.class); - if (dataType != null && dataType.getProperties() != null - && dataType.getProperties().containsKey(propertyName)) { - propertyDefinition = dataType.getProperties().get(propertyName); - if (propertyDefinition == null) { - throw new SvcLogicException(String.format("couldn't get data type (%s) ", dataTypeName)); - } - } - } else { - throw new SvcLogicException(String.format("couldn't get data type (%s) content.", dataTypeName)); - } - } - } catch (Exception e) { - throw new SvcLogicException(e.getMessage()); - } - return propertyDefinition; - } - - public static synchronized ResourceDefinition getDictionaryDefinition(Map dictionaries, - String dictionaryName) { - ResourceDefinition resourceDefinition = null; - if (dictionaries != null && StringUtils.isNotBlank(dictionaryName)) { - ResourceDictionary resourceDictionary = dictionaries.get(dictionaryName); - if (resourceDictionary != null && resourceDictionary.getDefinition() != null) { - resourceDefinition = - TransformationUtils.treeToValue(resourceDictionary.getDefinition(), ResourceDefinition.class); - } - } - return resourceDefinition; - } - - @SuppressWarnings("squid:S3776") - public static synchronized void populateValueForOutputMapping(SvcLogicContext ctx, - Map componentContext, ResourceAssignment resourceAssignment, - Map outputKeyMapping, JsonNode responseNode) - throws ConfigModelException, SvcLogicException { - if (resourceAssignment == null) { - throw new SvcLogicException("resourceAssignment is null."); - } - - if (ctx == null) { - throw new SvcLogicException("service logic context is null."); - } - - if (componentContext == null) { - throw new SvcLogicException("component context is null."); - } - - logger.info("populating value for output mapping ({}), from json ({})", outputKeyMapping, responseNode); - String dictionaryName = resourceAssignment.getDictionaryName(); - String type = resourceAssignment.getProperty().getType(); - - String entrySchema = null; - if (ValidTypes.getPrimitivePropertType().contains(type)) { - ResourceAssignmentUtils.setResourceDataValue(componentContext, resourceAssignment, responseNode); - } else if (ValidTypes.getListPropertType().contains(type)) { - // Array Types - if (resourceAssignment.getProperty().getEntrySchema() != null) { - entrySchema = resourceAssignment.getProperty().getEntrySchema().getType(); - } - - if (StringUtils.isNotBlank(entrySchema)) { - ArrayNode arrayNode = JsonNodeFactory.instance.arrayNode(); - if (ValidTypes.getPrimitivePropertType().contains(entrySchema)) { - arrayNode = (ArrayNode) responseNode; - } else if (MapUtils.isNotEmpty(outputKeyMapping)) { - List responseArrayNode = IteratorUtils.toList(responseNode.elements()); - for (JsonNode responseSingleJsonNode : responseArrayNode) { - if (responseSingleJsonNode != null) { - ObjectNode arrayChildNode = JsonNodeFactory.instance.objectNode(); - for (Map.Entry mapping : outputKeyMapping.entrySet()) { - JsonNode responseKeyValue = responseSingleJsonNode.get(mapping.getKey()); - - String propertyTypeForDataType = - ConfigAssignmentUtils.getPropertyType(ctx, entrySchema, mapping.getKey()); - logger.info("For List Type Resource: key ({}), value ({}), type ({})", - mapping.getKey(), responseKeyValue, propertyTypeForDataType); - JsonUtils.populateJsonNodeValues(mapping.getValue(), responseKeyValue, - propertyTypeForDataType, arrayChildNode); - } - arrayNode.add(arrayChildNode); - } - } - } else { - arrayNode = (ArrayNode) responseNode; - } - // Set the List of Complex Values - ResourceAssignmentUtils.setResourceDataValue(componentContext, resourceAssignment, arrayNode); - } else { - throw new SvcLogicException( - String.format("Entry schema is not defined for dictionary (%s) info", dictionaryName)); - } - } else { - // Complex Types - ObjectNode objectNode = null; - if (MapUtils.isNotEmpty(outputKeyMapping)) { - objectNode = JsonNodeFactory.instance.objectNode(); - for (Map.Entry mapping : outputKeyMapping.entrySet()) { - JsonNode responseKeyValue = responseNode.get(mapping.getKey()); - String propertyTypeForDataType = - ConfigAssignmentUtils.getPropertyType(ctx, entrySchema, mapping.getKey()); - logger.info("For Complex Type Resource: key ({}), value ({}), type ({})", mapping.getKey(), - responseKeyValue, propertyTypeForDataType); - JsonUtils.populateJsonNodeValues(mapping.getValue(), responseKeyValue, propertyTypeForDataType, - objectNode); - } - } else { - objectNode = (ObjectNode) responseNode; - } - ResourceAssignmentUtils.setResourceDataValue(componentContext, resourceAssignment, objectNode); - } - } - - @SuppressWarnings("squid:S3776") - public static synchronized List convertResoureAssignmentDataList( - List resourceAssignmentDataList) { - List assignments = new ArrayList<>(); - if (CollectionUtils.isNotEmpty(resourceAssignmentDataList)) { - for (ResourceAssignmentData resourceAssignmentData : resourceAssignmentDataList) { - if (resourceAssignmentData != null) { - ResourceAssignment resourceAssignment = new ResourceAssignment(); - resourceAssignment.setName(resourceAssignmentData.getTemplateKeyName()); - resourceAssignment.setVersion(resourceAssignmentData.getVersion()); - resourceAssignment.setUpdatedBy(resourceAssignmentData.getUpdatedBy()); - resourceAssignment.setUpdatedDate(resourceAssignmentData.getUpdatedDate()); - resourceAssignment.setDictionaryName(resourceAssignmentData.getResourceName()); - resourceAssignment.setDictionarySource(resourceAssignmentData.getSource()); - resourceAssignment.setStatus(resourceAssignmentData.getStatus()); - resourceAssignment.setMessage(resourceAssignmentData.getMessage()); - PropertyDefinition property = new PropertyDefinition(); - property.setType(resourceAssignmentData.getDataType()); - - if (StringUtils.isNotBlank(resourceAssignmentData.getResourceValue())) { - if (ValidTypes.getPrimitivePropertType().contains(resourceAssignmentData.getDataType())) { - property.setValue(resourceAssignmentData.getResourceValue()); - } else { - JsonNode valueNode = - TransformationUtils.getJsonNodeForString(resourceAssignmentData.getResourceValue()); - property.setValue(valueNode); - } - } - if (StringUtils.isNotBlank(resourceAssignmentData.getEntrySchema())) { - EntrySchema entrySchema = new EntrySchema(); - entrySchema.setType(resourceAssignmentData.getEntrySchema()); - property.setEntrySchema(entrySchema); - } else { - property.setEntrySchema(null); - } - resourceAssignment.setProperty(property); - assignments.add(resourceAssignment); - } - } - - } - return assignments; - } - - @SuppressWarnings("squid:S3776") - public static synchronized List convertResoureAssignmentList( - List assignments) { - List resourceAssignmentDataList = new ArrayList<>(); - if (CollectionUtils.isNotEmpty(assignments)) { - for (ResourceAssignment assignment : assignments) { - if (assignment != null) { - ResourceAssignmentData resourceAssignmentData = new ResourceAssignmentData(); - resourceAssignmentData.setTemplateKeyName(assignment.getName()); - resourceAssignmentData.setVersion(assignment.getVersion()); - resourceAssignmentData.setUpdatedBy(assignment.getUpdatedBy()); - resourceAssignmentData.setUpdatedDate(assignment.getUpdatedDate()); - if (assignment.getProperty() != null) { - resourceAssignmentData.setDataType(assignment.getProperty().getType()); - if (assignment.getProperty().getEntrySchema() != null) { - resourceAssignmentData.setEntrySchema(assignment.getProperty().getEntrySchema().getType()); - } - if (assignment.getProperty().getValue() != null) { - String valueContent = TransformationUtils.getJson(assignment.getProperty().getValue()); - resourceAssignmentData.setResourceValue(valueContent); - } - } - resourceAssignmentData.setResourceName(assignment.getDictionaryName()); - resourceAssignmentData.setSource(assignment.getDictionarySource()); - resourceAssignmentData.setStatus(assignment.getStatus()); - resourceAssignmentData.setMessage(assignment.getMessage()); - resourceAssignmentDataList.add(resourceAssignmentData); - } - } - } - return resourceAssignmentDataList; - } - -} diff --git a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/service/ConfigPreviewService.java b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/service/ConfigPreviewService.java deleted file mode 100644 index 071b5a548..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/service/ConfigPreviewService.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.assignment.service; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.lang3.StringUtils; -import org.onap.ccsdk.features.assignment.data.ResourceAssignmentData; -import org.onap.ccsdk.features.data.adaptor.domain.ConfigResource; -import org.onap.ccsdk.features.data.adaptor.service.ConfigResourceService; -import org.onap.ccsdk.features.generator.data.ConfigGeneratorInfo; -import org.onap.ccsdk.features.generator.service.ConfigGeneratorService; -import org.onap.ccsdk.features.model.ConfigModelConstant; -import org.onap.ccsdk.features.model.service.ConfigModelService; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -public class ConfigPreviewService { - private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigAssignmentPersistService.class); - private ConfigResourceService configResourceService; - private ConfigModelService configModelService; - private ConfigGeneratorService configGeneratorService; - - public ConfigPreviewService(ConfigResourceService configResourceService, ConfigModelService configModelService, - ConfigGeneratorService configGeneratorService) { - this.configResourceService = configResourceService; - this.configModelService = configModelService; - this.configGeneratorService = configGeneratorService; - } - - public String generatePreview(String templateContent, String templateData) throws SvcLogicException { - String mashedData = ""; - ConfigGeneratorInfo configGeneratorInfo = - configGeneratorService.generateConfiguration(templateContent, templateData); - if (configGeneratorInfo != null) { - mashedData = configGeneratorInfo.getMashedData(); - } - return mashedData; - } - - public ResourceAssignmentData generateTemplateResourceMash(ResourceAssignmentData resourceAssignmentData) - throws SvcLogicException { - if (resourceAssignmentData == null) { - throw new SvcLogicException("Resource assignment data is missing"); - } - if (StringUtils.isBlank(resourceAssignmentData.getServiceTemplateName())) { - throw new SvcLogicException("Service template name is missing"); - } - if (StringUtils.isBlank(resourceAssignmentData.getServiceTemplateVersion())) { - throw new SvcLogicException("Service template version is missing"); - } - if (StringUtils.isBlank(resourceAssignmentData.getResourceType())) { - throw new SvcLogicException("Resource type is missing"); - } - if (StringUtils.isBlank(resourceAssignmentData.getResourceId())) { - throw new SvcLogicException("Resource Id is missing"); - } - if (StringUtils.isBlank(resourceAssignmentData.getActionName())) { - throw new SvcLogicException("Action name is missing"); - } - - String serviceTemplateName = resourceAssignmentData.getServiceTemplateName(); - String serviceTemplateVersion = resourceAssignmentData.getServiceTemplateVersion(); - String actionName = resourceAssignmentData.getActionName(); - String resourceId = resourceAssignmentData.getResourceId(); - String resourceType = resourceAssignmentData.getResourceType(); - String inputData = "{}"; - - Map context = new HashMap<>(); - context.put(ConfigModelConstant.PROPERTY_ACTION_NAME, actionName); - context = configModelService.prepareContext(context, inputData, serviceTemplateName, serviceTemplateVersion); - - ConfigResource configResourceQuery = new ConfigResource(); - configResourceQuery.setServiceTemplateVersion(serviceTemplateName); - configResourceQuery.setServiceTemplateVersion(serviceTemplateVersion); - configResourceQuery.setRecipeName(actionName); - configResourceQuery.setResourceId(resourceId); - configResourceQuery.setResourceType(resourceType); - - List configResources = configResourceService.getConfigResource(configResourceQuery); - if (CollectionUtils.isNotEmpty(configResources)) { - for (ConfigResource cr : configResources) { - String templateContent = context - .get(ConfigModelConstant.PROPERTY_NODE_TEMPLATES_DOT + cr.getTemplateName() + ".content"); - String templateData = cr.getResourceData(); - String previewContent = generatePreview(templateContent, templateData); - resourceAssignmentData.getTemplatesMashedContents().put(cr.getTemplateName(), previewContent); - logger.info("Preview generated for template name ({}) ", cr.getTemplateName()); - logger.trace("Preview generated for preview ({}) ", previewContent); - } - } else { - logger.info( - "Couldn't get config resource for service template name ({}) service template version ({})" - + " action ({}) resource id ({}) resource type ({})", - serviceTemplateName, serviceTemplateVersion, actionName, resourceId, resourceType); - } - return resourceAssignmentData; - - } - -} diff --git a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/service/ResourceDictionaryService.java b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/service/ResourceDictionaryService.java deleted file mode 100644 index d8692c4c7..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/service/ResourceDictionaryService.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.assignment.service; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.apache.commons.lang3.StringUtils; -import org.onap.ccsdk.features.model.data.ResourceAssignment; -import org.onap.ccsdk.features.model.data.dict.ResourceDefinition; -import org.onap.ccsdk.features.model.domain.ResourceDictionary; -import org.onap.ccsdk.features.model.utils.TransformationUtils; -import org.onap.ccsdk.features.rest.adaptor.ConfigRestAdaptorConstants; -import org.onap.ccsdk.features.rest.adaptor.ConfigRestAdaptorException; -import org.onap.ccsdk.features.rest.adaptor.service.ConfigRestAdaptorService; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -public class ResourceDictionaryService { - - private static EELFLogger logger = EELFManager.getInstance().getLogger(ResourceDictionaryService.class); - private ConfigRestAdaptorService configRestAdaptorService; - - public ResourceDictionaryService(ConfigRestAdaptorService configRestAdaptorService) { - this.configRestAdaptorService = configRestAdaptorService; - } - - @SuppressWarnings("squid:S3776") - public Map getDataDictionaryDefinitions(List resourceAssignments) - throws SvcLogicException { - try { - Map dictionaries = new HashMap<>(); - if (resourceAssignments != null) { - List names = new ArrayList<>(); - for (ResourceAssignment resourceAssignment : resourceAssignments) { - if (resourceAssignment != null && StringUtils.isNotBlank(resourceAssignment.getDictionaryName())) { - if (!names.contains(resourceAssignment.getDictionaryName())) { - names.add(resourceAssignment.getDictionaryName()); - } - if (resourceAssignment.getDependencies() != null - && !resourceAssignment.getDependencies().isEmpty()) { - List dependencieNames = resourceAssignment.getDependencies(); - for (String dependencieName : dependencieNames) { - if (StringUtils.isNotBlank(dependencieName) && !names.contains(dependencieName)) { - names.add(dependencieName); - } - } - } - } - } - queryResourceDictionaryDefinitions(dictionaries, names); - } - return dictionaries; - } catch (Exception e) { - throw new SvcLogicException("Failed in getting resource data dictionary : " + e.getMessage()); - } - - } - - @SuppressWarnings("squid:S3776") - private void queryResourceDictionaryDefinitions(Map dictionaries, List names) - throws SvcLogicException, ConfigRestAdaptorException { - logger.info("Getting resource dictionary definition for the names ({})", names); - if (!names.isEmpty()) { - - String dictionaryContents = configRestAdaptorService.postResource( - ConfigRestAdaptorConstants.SELECTOR_MODEL_SERVICE, "dictionary/by-names", names, String.class); - - if (StringUtils.isNotBlank(dictionaryContents)) { - List dataDictionaries = - TransformationUtils.getListfromJson(dictionaryContents, ResourceDictionary.class); - if (dataDictionaries != null) { - for (ResourceDictionary dataDictionary : dataDictionaries) { - if (dataDictionary != null && StringUtils.isNotBlank(dataDictionary.getName()) - && dataDictionary.getDefinition() != null) { - ResourceDefinition resourceDefinition = TransformationUtils - .treeToValue(dataDictionary.getDefinition(), ResourceDefinition.class); - if (resourceDefinition != null && StringUtils.isNotBlank(resourceDefinition.getName())) { - dictionaries.put(resourceDefinition.getName(), resourceDefinition); - } else { - throw new SvcLogicException( - "Failed in getting resource data dictionary definition for : " - + dataDictionary.getName()); - } - } - } - } - } else { - logger.warn("No resource dictionary definition found for the names ({})", names); - } - } - } -} diff --git a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/service/ResourceModelService.java b/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/service/ResourceModelService.java deleted file mode 100644 index befa36a34..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/main/java/org/onap/ccsdk/features/assignment/service/ResourceModelService.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.assignment.service; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.lang3.StringUtils; -import org.onap.ccsdk.features.model.data.ResourceAssignment; -import org.onap.ccsdk.features.model.service.ConfigModelService; -import org.onap.ccsdk.features.model.utils.TransformationUtils; -import org.onap.ccsdk.features.model.validator.ResourceAssignmentValidator; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -public class ResourceModelService { - private static EELFLogger logger = EELFManager.getInstance().getLogger(ResourceModelService.class); - - private ConfigModelService configModelService; - - public ResourceModelService(ConfigModelService configModelService) { - this.configModelService = configModelService; - } - - public Map getTemplatesContents(SvcLogicContext ctx, List templateNames) - throws SvcLogicException { - Map templatesContents = new HashMap<>(); - try { - if (CollectionUtils.isNotEmpty(templateNames)) { - for (String templateName : templateNames) { - String templateContent = this.configModelService.getNodeTemplateContent(ctx, templateName); - logger.trace("Processing template ({}) with content : {}", templateName, templateContent); - templatesContents.put(templateName, templateContent); - } - } - } catch (Exception e) { - throw new SvcLogicException(e.getMessage()); - } - return templatesContents; - } - - public Map> getTemplatesResourceAssignments(SvcLogicContext ctx, - List templateNames) throws SvcLogicException { - Map> templatesResourceAssignments = new HashMap<>(); - try { - if (CollectionUtils.isNotEmpty(templateNames)) { - for (String templateName : templateNames) { - String resourceMappingContent = this.configModelService.getNodeTemplateMapping(ctx, templateName); - logger.info("Processing template ({}) with resource assignment content : {}", templateName, - resourceMappingContent); - - if (StringUtils.isNotBlank(resourceMappingContent)) { - - List resourceAssignments = - TransformationUtils.getListfromJson(resourceMappingContent, ResourceAssignment.class); - - if (resourceAssignments != null) { - ResourceAssignmentValidator resourceAssignmentValidator = - new ResourceAssignmentValidator(resourceAssignments); - resourceAssignmentValidator.validateResourceAssignment(); - logger.info("Resource assignment validated successfully for the template ({})", - templateName); - templatesResourceAssignments.put(templateName, resourceAssignments); - } else { - throw new SvcLogicException(String.format( - "Failed to convert assignment content (%s) to object", resourceMappingContent)); - } - } else { - // Do nothing, because som e templates may not have mappings - } - } - } - } catch (Exception e) { - throw new SvcLogicException(e.getMessage()); - } - - return templatesResourceAssignments; - } -} diff --git a/blueprints-processor/plugin/assignment-provider/src/main/resources/OSGI-INF/blueprint/impl-blueprint.xml b/blueprints-processor/plugin/assignment-provider/src/main/resources/OSGI-INF/blueprint/impl-blueprint.xml deleted file mode 100644 index f15429dfe..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/main/resources/OSGI-INF/blueprint/impl-blueprint.xml +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/blueprints-processor/plugin/assignment-provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml b/blueprints-processor/plugin/assignment-provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml deleted file mode 100644 index f15429dfe..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/features/assignment/processor/DBResourceProcessorTest.java b/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/features/assignment/processor/DBResourceProcessorTest.java deleted file mode 100644 index a93e6de2e..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/features/assignment/processor/DBResourceProcessorTest.java +++ /dev/null @@ -1,231 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.assignment.processor; - -import static org.mockito.Matchers.any; -import java.io.File; -import java.nio.charset.Charset; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.apache.commons.io.FileUtils; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Matchers; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.MockitoAnnotations; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.runners.MockitoJUnitRunner; -import org.mockito.stubbing.Answer; -import org.onap.ccsdk.features.assignment.service.ConfigResourceAssignmentTestUtils; -import org.onap.ccsdk.features.data.adaptor.domain.TransactionLog; -import org.onap.ccsdk.features.data.adaptor.service.ConfigResourceService; -import org.onap.ccsdk.features.model.ConfigModelConstant; -import org.onap.ccsdk.features.model.data.ResourceAssignment; -import org.onap.ccsdk.features.model.data.dict.ResourceDefinition; -import org.onap.ccsdk.features.model.utils.TransformationUtils; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -@RunWith(MockitoJUnitRunner.class) -public class DBResourceProcessorTest { - - private static EELFLogger logger = EELFManager.getInstance().getLogger(DBResourceProcessorTest.class); - - @Mock - private ConfigResourceService configResourceService; - - @SuppressWarnings("unchecked") - @Before - public void before() { - MockitoAnnotations.initMocks(this); - - try { - Mockito.doAnswer(new Answer() { - @Override - public Void answer(InvocationOnMock invocationOnMock) throws Throwable { - Object[] args = invocationOnMock.getArguments(); - if (args != null) { - logger.trace("Transaction info " + Arrays.asList(args)); - } - return null; - } - }).when(configResourceService).save(any(TransactionLog.class)); - - } catch (SvcLogicException e) { - e.printStackTrace(); - } - } - - @Test - public void testDbSimpleProcess() throws Exception { - logger.info(" ******************************* testDbSimpleProcess ***************************"); - - Mockito.doAnswer(new Answer>>() { - @Override - public List> answer(InvocationOnMock invocationOnMock) throws Throwable { - Object[] args = invocationOnMock.getArguments(); - List> results = new ArrayList<>(); - if (args != null) { - logger.info("Query " + Arrays.asList(args)); - Map record = new HashMap<>(); - record.put("country", "US"); - results.add(record); - } - return results; - } - }).when(configResourceService).query(Matchers.anyString(), Matchers.>any()); - - String recipeName = "sample-recipe"; - - String resourceassignmentContent = FileUtils.readFileToString( - new File("src/test/resources/mapping/db/resource-assignments-simple.json"), Charset.defaultCharset()); - List batchResourceAssignment = - TransformationUtils.getListfromJson(resourceassignmentContent, ResourceAssignment.class); - - String dictionaryContent = FileUtils.readFileToString(new File("src/test/resources/mapping/db/db-simple.json"), - Charset.defaultCharset()); - Map dictionaries = - ConfigResourceAssignmentTestUtils.getMapfromJson(dictionaryContent); - DBResourceProcessor dbResourceProcessor = new DBResourceProcessor(configResourceService); - Map componentContext = new HashMap<>(); - componentContext.put(ConfigModelConstant.PROPERTY_RESOURCE_ASSIGNMENTS, batchResourceAssignment); - componentContext.put(ConfigModelConstant.PROPERTY_ACTION_NAME, recipeName); - componentContext.put(ConfigModelConstant.PROPERTY_TEMPLATE_NAME, "sample-template"); - componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARIES, dictionaries); - - componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + recipeName + ".profile_name", "sample"); - - Map inParams = new HashMap<>(); - SvcLogicContext ctx = new SvcLogicContext(); - dbResourceProcessor.process(inParams, ctx, componentContext); - - logger.info(" Context " + componentContext); - - } - - @Test - public void testDbComplexProcess() throws Exception { - logger.info(" ******************************* testDbComplexProcess ***************************"); - - Mockito.doAnswer(new Answer>>() { - @Override - public List> answer(InvocationOnMock invocationOnMock) throws Throwable { - Object[] args = invocationOnMock.getArguments(); - List> results = new ArrayList<>(); - if (args != null) { - logger.info("Query " + Arrays.asList(args)); - Map record = new HashMap<>(); - record.put("db-country", "US"); - record.put("db-state", "NJ"); - results.add(record); - } - return results; - } - }).when(configResourceService).query(Matchers.anyString(), Matchers.>any()); - - String recipeName = "sample-recipe"; - - String resourceassignmentContent = FileUtils.readFileToString( - new File("src/test/resources/mapping/db/resource-assignments-complex.json"), Charset.defaultCharset()); - List batchResourceAssignment = - TransformationUtils.getListfromJson(resourceassignmentContent, ResourceAssignment.class); - - String dictionaryContent = FileUtils.readFileToString(new File("src/test/resources/mapping/db/db-complex.json"), - Charset.defaultCharset()); - Map dictionaries = - ConfigResourceAssignmentTestUtils.getMapfromJson(dictionaryContent); - DBResourceProcessor dbResourceProcessor = new DBResourceProcessor(configResourceService); - Map componentContext = new HashMap<>(); - componentContext.put(ConfigModelConstant.PROPERTY_RESOURCE_ASSIGNMENTS, batchResourceAssignment); - componentContext.put(ConfigModelConstant.PROPERTY_ACTION_NAME, recipeName); - componentContext.put(ConfigModelConstant.PROPERTY_TEMPLATE_NAME, "sample-template"); - componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARIES, dictionaries); - componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + recipeName + ".profile_name", "sample"); - - Map inParams = new HashMap<>(); - SvcLogicContext ctx = new SvcLogicContext(); - String datatypeContent = FileUtils.readFileToString(new File("src/test/resources/mapping/db/dt-location.json"), - Charset.defaultCharset()); - ctx.setAttribute("data_types.dt-location", datatypeContent); - dbResourceProcessor.process(inParams, ctx, componentContext); - - } - - @Test - public void testDbArrayComplexProcess() throws Exception { - logger.info(" ******************************* testDbArrayComplexProcess ***************************"); - Mockito.doAnswer(new Answer>>() { - @Override - public List> answer(InvocationOnMock invocationOnMock) throws Throwable { - Object[] args = invocationOnMock.getArguments(); - List> results = new ArrayList<>(); - if (args != null) { - logger.info("Query " + Arrays.asList(args)); - Map record = new HashMap<>(); - record.put("db-country", "US"); - record.put("db-state", "NJ"); - results.add(record); - - Map record2 = new HashMap<>(); - record2.put("db-country", "INDIA"); - record2.put("db-state", "TN"); - results.add(record2); - } - return results; - } - }).when(configResourceService).query(Matchers.anyString(), Matchers.>any()); - - String recipeName = "sample-recipe"; - - String resourceassignmentContent = FileUtils.readFileToString( - new File("src/test/resources/mapping/db/resource-assignments-array.json"), Charset.defaultCharset()); - List batchResourceAssignment = - TransformationUtils.getListfromJson(resourceassignmentContent, ResourceAssignment.class); - - String dictionaryContent = FileUtils.readFileToString(new File("src/test/resources/mapping/db/db-array.json"), - Charset.defaultCharset()); - Map dictionaries = - ConfigResourceAssignmentTestUtils.getMapfromJson(dictionaryContent); - DBResourceProcessor dbResourceProcessor = new DBResourceProcessor(configResourceService); - Map componentContext = new HashMap<>(); - componentContext.put(ConfigModelConstant.PROPERTY_RESOURCE_ASSIGNMENTS, batchResourceAssignment); - componentContext.put(ConfigModelConstant.PROPERTY_ACTION_NAME, recipeName); - componentContext.put(ConfigModelConstant.PROPERTY_TEMPLATE_NAME, "sample-template"); - componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARIES, dictionaries); - componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + recipeName + ".profile_name", "sample"); - - Map inParams = new HashMap<>(); - SvcLogicContext ctx = new SvcLogicContext(); - String datatypeContent = FileUtils.readFileToString(new File("src/test/resources/mapping/db/dt-location.json"), - Charset.defaultCharset()); - ctx.setAttribute("data_types.dt-location", datatypeContent); - dbResourceProcessor.process(inParams, ctx, componentContext); - logger.info("Component Context = ({})", componentContext); - Assert.assertNotNull("faile dto populate Array Complex response ", componentContext); - - } - -} diff --git a/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/features/assignment/processor/DefaultResourceProcessorTest.java b/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/features/assignment/processor/DefaultResourceProcessorTest.java deleted file mode 100644 index 16fd6c0bd..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/features/assignment/processor/DefaultResourceProcessorTest.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.assignment.processor; - -import static org.mockito.Matchers.any; -import java.io.File; -import java.nio.charset.Charset; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.apache.commons.io.FileUtils; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.MockitoAnnotations; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.runners.MockitoJUnitRunner; -import org.mockito.stubbing.Answer; -import org.onap.ccsdk.features.assignment.service.ConfigResourceAssignmentTestUtils; -import org.onap.ccsdk.features.data.adaptor.domain.TransactionLog; -import org.onap.ccsdk.features.data.adaptor.service.ConfigResourceService; -import org.onap.ccsdk.features.model.ConfigModelConstant; -import org.onap.ccsdk.features.model.data.ResourceAssignment; -import org.onap.ccsdk.features.model.data.dict.ResourceDefinition; -import org.onap.ccsdk.features.model.utils.TransformationUtils; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -@RunWith(MockitoJUnitRunner.class) -public class DefaultResourceProcessorTest { - - private static EELFLogger logger = EELFManager.getInstance().getLogger(DefaultResourceProcessorTest.class); - - @Mock - private ConfigResourceService configResourceService; - - @SuppressWarnings("unchecked") - @Before - public void before() { - MockitoAnnotations.initMocks(this); - - try { - Mockito.doAnswer(new Answer() { - @Override - public Void answer(InvocationOnMock invocationOnMock) throws Throwable { - Object[] args = invocationOnMock.getArguments(); - if (args != null) { - logger.trace("Transaction info " + Arrays.asList(args)); - } - return null; - } - }).when(configResourceService).save(any(TransactionLog.class)); - - } catch (SvcLogicException e) { - e.printStackTrace(); - } - } - - @Test - public void testDefaultSimpleProcess() throws Exception { - logger.info(" ******************************* testDefaultSimpleProcess ***************************"); - - String recipeName = "sample-recipe"; - - String resourceassignmentContent = FileUtils.readFileToString( - new File("src/test/resources/mapping/default/resource-assignments-simple.json"), - Charset.defaultCharset()); - List batchResourceAssignment = - TransformationUtils.getListfromJson(resourceassignmentContent, ResourceAssignment.class); - - String dictionaryContent = FileUtils.readFileToString( - new File("src/test/resources/mapping/default/default-simple.json"), Charset.defaultCharset()); - Map dictionaries = - ConfigResourceAssignmentTestUtils.getMapfromJson(dictionaryContent); - - DefaultResourceProcessor defaultResourceProcessor = new DefaultResourceProcessor(configResourceService); - Map componentContext = new HashMap<>(); - componentContext.put(ConfigModelConstant.PROPERTY_RESOURCE_ASSIGNMENTS, batchResourceAssignment); - componentContext.put(ConfigModelConstant.PROPERTY_ACTION_NAME, recipeName); - componentContext.put(ConfigModelConstant.PROPERTY_TEMPLATE_NAME, "sample-template"); - componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARIES, dictionaries); - componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + recipeName + ".profile_name", "sample"); - - Map inParams = new HashMap<>(); - SvcLogicContext ctx = new SvcLogicContext(); - defaultResourceProcessor.process(inParams, ctx, componentContext); - logger.trace(" componentContext " + componentContext); - - Assert.assertEquals("Failed to populate default country value ", "US", - componentContext.get(ConfigModelConstant.PROPERTY_RECIPE_KEY_DOT + "sample-recipe.country")); - Assert.assertEquals("Failed to populate default country value ", "US", - componentContext.get(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + "sample-recipe.country")); - - Assert.assertEquals("Failed to populate default port value ", 830, - componentContext.get(ConfigModelConstant.PROPERTY_RECIPE_KEY_DOT + "sample-recipe.port")); - Assert.assertEquals("Failed to populate default port value ", 830, - componentContext.get(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + "sample-recipe.port")); - - Assert.assertEquals("Failed to populate default voip-enabled value ", true, - componentContext.get(ConfigModelConstant.PROPERTY_RECIPE_KEY_DOT + "sample-recipe.voip-enabled")); - Assert.assertEquals("Failed to populate default voip-enabled value ", true, - componentContext.get(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + "sample-recipe.voip-enabled")); - - } - -} diff --git a/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/features/assignment/processor/InputResourceProcessorTest.java b/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/features/assignment/processor/InputResourceProcessorTest.java deleted file mode 100644 index add00d3a9..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/features/assignment/processor/InputResourceProcessorTest.java +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.assignment.processor; - -import static org.mockito.Matchers.any; -import java.io.File; -import java.nio.charset.Charset; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.apache.commons.io.FileUtils; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.MockitoAnnotations; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.runners.MockitoJUnitRunner; -import org.mockito.stubbing.Answer; -import org.onap.ccsdk.features.assignment.service.ConfigResourceAssignmentTestUtils; -import org.onap.ccsdk.features.data.adaptor.domain.TransactionLog; -import org.onap.ccsdk.features.data.adaptor.service.ConfigResourceService; -import org.onap.ccsdk.features.model.ConfigModelConstant; -import org.onap.ccsdk.features.model.data.ResourceAssignment; -import org.onap.ccsdk.features.model.data.dict.ResourceDefinition; -import org.onap.ccsdk.features.model.utils.TransformationUtils; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -@RunWith(MockitoJUnitRunner.class) -public class InputResourceProcessorTest { - - private static EELFLogger logger = EELFManager.getInstance().getLogger(InputResourceProcessorTest.class); - - @Mock - private ConfigResourceService configResourceService; - - @SuppressWarnings("unchecked") - @Before - public void before() { - MockitoAnnotations.initMocks(this); - - try { - Mockito.doAnswer(new Answer() { - @Override - public Void answer(InvocationOnMock invocationOnMock) throws Throwable { - Object[] args = invocationOnMock.getArguments(); - if (args != null) { - logger.trace("Transaction info " + Arrays.asList(args)); - } - return null; - } - }).when(configResourceService).save(any(TransactionLog.class)); - - } catch (SvcLogicException e) { - e.printStackTrace(); - } - } - - @Test - public void testInputSimpleProcess() throws Exception { - logger.info(" ******************************* testInputSimpleProcess ***************************"); - - String recipeName = "sample-recipe"; - - String resourceassignmentContent = FileUtils.readFileToString( - new File("src/test/resources/mapping/input/resource-assignments-simple.json"), - Charset.defaultCharset()); - List batchResourceAssignment = - TransformationUtils.getListfromJson(resourceassignmentContent, ResourceAssignment.class); - - String dictionaryContent = FileUtils.readFileToString( - new File("src/test/resources/mapping/default/default-simple.json"), Charset.defaultCharset()); - Map dictionaries = - ConfigResourceAssignmentTestUtils.getMapfromJson(dictionaryContent); - - InputResourceProcessor inputResourceProcessor = new InputResourceProcessor(configResourceService); - Map componentContext = new HashMap<>(); - componentContext.put(ConfigModelConstant.PROPERTY_RESOURCE_ASSIGNMENTS, batchResourceAssignment); - componentContext.put(ConfigModelConstant.PROPERTY_ACTION_NAME, recipeName); - componentContext.put(ConfigModelConstant.PROPERTY_TEMPLATE_NAME, "sample-template"); - componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARIES, dictionaries); - componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + recipeName + ".profile_name", "sample"); - - Map inParams = new HashMap<>(); - SvcLogicContext ctx = new SvcLogicContext(); - ctx.setAttribute("country", "US"); - ctx.setAttribute("port", "830"); - ctx.setAttribute("voip-enabled", "true"); - - inputResourceProcessor.process(inParams, ctx, componentContext); - logger.trace(" componentContext " + componentContext); - - Assert.assertEquals("Failed to populate default recipe country value ", "US", - componentContext.get(ConfigModelConstant.PROPERTY_RECIPE_KEY_DOT + "sample-recipe.country")); - Assert.assertEquals("Failed to populate default dictionary country value ", "US", - componentContext.get(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + "sample-recipe.country")); - - Assert.assertEquals("Failed to populate default recipe port value ", 830, - componentContext.get(ConfigModelConstant.PROPERTY_RECIPE_KEY_DOT + "sample-recipe.port")); - Assert.assertEquals("Failed to populate default dictionary port value ", 830, - componentContext.get(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + "sample-recipe.port")); - - Assert.assertEquals("Failed to populate default recipe voip-enabled value ", true, - componentContext.get(ConfigModelConstant.PROPERTY_RECIPE_KEY_DOT + "sample-recipe.voip-enabled")); - Assert.assertEquals("Failed to populate default dictionary voip-enabled value ", true, - componentContext.get(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + "sample-recipe.voip-enabled")); - - } - - @Test - public void testInputComplexProcess() throws Exception { - logger.info(" ******************************* testInputComplexProcess ***************************"); - - String recipeName = "sample-recipe"; - - String resourceassignmentContent = FileUtils.readFileToString( - new File("src/test/resources/mapping/input/resource-assignments-complex.json"), - Charset.defaultCharset()); - List batchResourceAssignment = - TransformationUtils.getListfromJson(resourceassignmentContent, ResourceAssignment.class); - - String dictionaryContent = FileUtils.readFileToString( - new File("src/test/resources/mapping/input/input-complex.json"), Charset.defaultCharset()); - Map dictionaries = - ConfigResourceAssignmentTestUtils.getMapfromJson(dictionaryContent); - - InputResourceProcessor inputResourceProcessor = new InputResourceProcessor(configResourceService); - Map componentContext = new HashMap<>(); - componentContext.put(ConfigModelConstant.PROPERTY_RESOURCE_ASSIGNMENTS, batchResourceAssignment); - componentContext.put(ConfigModelConstant.PROPERTY_ACTION_NAME, recipeName); - componentContext.put(ConfigModelConstant.PROPERTY_TEMPLATE_NAME, "sample-template"); - componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARIES, dictionaries); - componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + recipeName + ".profile_name", "sample"); - - Map inParams = new HashMap<>(); - SvcLogicContext ctx = new SvcLogicContext(); - String datatypeContent = FileUtils.readFileToString( - new File("src/test/resources/mapping/input/dt-location.json"), Charset.defaultCharset()); - ctx.setAttribute("data_types.dt-location", datatypeContent); - - String samplelocation = FileUtils.readFileToString( - new File("src/test/resources/mapping/input/sample-location.json"), Charset.defaultCharset()); - ctx.setAttribute("location", samplelocation); - - inputResourceProcessor.process(inParams, ctx, componentContext); - - logger.trace(" componentContext " + componentContext); - logger.trace(" Resource Mapping " + TransformationUtils.getJson(batchResourceAssignment, true)); - - Assert.assertNotNull("Failed to populate input recipe location value ", - componentContext.get(ConfigModelConstant.PROPERTY_RECIPE_KEY_DOT + "sample-recipe.location")); - Assert.assertNotNull("Failed to populate input dictionary location value ", - componentContext.get(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + "sample-recipe.location")); - - } - -} diff --git a/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/features/assignment/processor/MdsalResourceProcessorTest.java b/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/features/assignment/processor/MdsalResourceProcessorTest.java deleted file mode 100644 index 10a43538c..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/features/assignment/processor/MdsalResourceProcessorTest.java +++ /dev/null @@ -1,268 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.assignment.processor; - -import java.io.File; -import java.nio.charset.Charset; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.apache.commons.io.FileUtils; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Matchers; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.runners.MockitoJUnitRunner; -import org.mockito.stubbing.Answer; -import org.onap.ccsdk.features.assignment.service.ConfigResourceAssignmentTestUtils; -import org.onap.ccsdk.features.model.ConfigModelConstant; -import org.onap.ccsdk.features.model.data.ResourceAssignment; -import org.onap.ccsdk.features.model.data.dict.ResourceDefinition; -import org.onap.ccsdk.features.model.utils.TransformationUtils; -import org.onap.ccsdk.features.rest.adaptor.service.ConfigRestAdaptorService; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -@RunWith(MockitoJUnitRunner.class) -public class MdsalResourceProcessorTest { - - private static EELFLogger logger = EELFManager.getInstance().getLogger(MdsalResourceProcessorTest.class); - - @Mock - private ConfigRestAdaptorService configRestAdaptorService; - - @SuppressWarnings("unchecked") - @Before - public void before() { - - } - - @Test - @SuppressWarnings("unchecked") - public void testMdsalSimpleProcess() throws Exception { - logger.info(" ******************************* testMdsalSimpleProcess ***************************"); - - Mockito.doAnswer(new Answer() { - @Override - public String answer(InvocationOnMock invocationOnMock) throws Throwable { - Object[] args = invocationOnMock.getArguments(); - String response = null; - if (args != null) { - response = FileUtils.readFileToString( - new File("src/test/resources/mapping/Mdsal/simple-response.json"), - Charset.defaultCharset()); - logger.info(" Returning response :" + response); - } - return response; - } - }).when(configRestAdaptorService).getResource(Matchers.anyString(), Matchers.anyString(), - Matchers.any(Class.class)); - - String recipeName = "sample-recipe"; - - String resourceassignmentContent = FileUtils.readFileToString( - new File("src/test/resources/mapping/Mdsal/resource-assignments-simple.json"), - Charset.defaultCharset()); - List batchResourceAssignment = - TransformationUtils.getListfromJson(resourceassignmentContent, ResourceAssignment.class); - - String dictionaryContent = FileUtils.readFileToString( - new File("src/test/resources/mapping/Mdsal/mdsal-simple.json"), Charset.defaultCharset()); - Map dictionaries = - ConfigResourceAssignmentTestUtils.getMapfromJson(dictionaryContent); - MdsalResourceProcessor mdsalResourceProcessor = new MdsalResourceProcessor(configRestAdaptorService); - Map componentContext = new HashMap<>(); - componentContext.put(ConfigModelConstant.PROPERTY_RESOURCE_ASSIGNMENTS, batchResourceAssignment); - componentContext.put(ConfigModelConstant.PROPERTY_ACTION_NAME, recipeName); - componentContext.put(ConfigModelConstant.PROPERTY_TEMPLATE_NAME, "sample-template"); - componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARIES, dictionaries); - - componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + recipeName + ".profile_name", "sample"); - - Map inParams = new HashMap<>(); - SvcLogicContext ctx = new SvcLogicContext(); - mdsalResourceProcessor.process(inParams, ctx, componentContext); - - } - - @SuppressWarnings("unchecked") - @Test - public void testMDSALComplexProcess() throws Exception { - logger.info(" ******************************* testMDSALComplexProcess ***************************"); - - Mockito.doAnswer(new Answer() { - @Override - public String answer(InvocationOnMock invocationOnMock) throws Throwable { - Object[] args = invocationOnMock.getArguments(); - String response = null; - if (args != null) { - response = FileUtils.readFileToString( - new File("src/test/resources/mapping/Mdsal/complex-response.json"), - Charset.defaultCharset()); - } - return response; - } - }).when(configRestAdaptorService).getResource(Matchers.anyString(), Matchers.anyString(), - Matchers.any(Class.class)); - - String recipeName = "sample-recipe"; - - String resourceassignmentContent = FileUtils.readFileToString( - new File("src/test/resources/mapping/Mdsal/resource-assignments-complex.json"), - Charset.defaultCharset()); - List batchResourceAssignment = - TransformationUtils.getListfromJson(resourceassignmentContent, ResourceAssignment.class); - - String dictionaryContent = FileUtils.readFileToString( - new File("src/test/resources/mapping/Mdsal/mdsal-complex.json"), Charset.defaultCharset()); - Map dictionaries = - ConfigResourceAssignmentTestUtils.getMapfromJson(dictionaryContent); - MdsalResourceProcessor dbResourceProcessor = new MdsalResourceProcessor(configRestAdaptorService); - Map componentContext = new HashMap<>(); - componentContext.put(ConfigModelConstant.PROPERTY_RESOURCE_ASSIGNMENTS, batchResourceAssignment); - componentContext.put(ConfigModelConstant.PROPERTY_ACTION_NAME, recipeName); - componentContext.put(ConfigModelConstant.PROPERTY_TEMPLATE_NAME, "sample-template"); - componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARIES, dictionaries); - componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + recipeName + ".profile_name", "sample"); - - Map inParams = new HashMap<>(); - SvcLogicContext ctx = new SvcLogicContext(); - String datatypeContent = FileUtils.readFileToString( - new File("src/test/resources/mapping/Mdsal/dt-location.json"), Charset.defaultCharset()); - ctx.setAttribute("data_types.dt-location", datatypeContent); - dbResourceProcessor.process(inParams, ctx, componentContext); - - } - - @Test - @SuppressWarnings("unchecked") - public void testMDSALArrayComplexProcess() throws Exception { - logger.info(" ******************************* testMDSALArrayComplexProcess ***************************"); - - Mockito.doAnswer(new Answer() { - @Override - public String answer(InvocationOnMock invocationOnMock) throws Throwable { - Object[] args = invocationOnMock.getArguments(); - String response = null; - if (args != null) { - response = FileUtils.readFileToString( - new File("src/test/resources/mapping/Mdsal/array-complex-response.json"), - Charset.defaultCharset()); - } - return response; - } - }).when(configRestAdaptorService).getResource(Matchers.anyString(), Matchers.anyString(), - Matchers.any(Class.class)); - - String recipeName = "sample-recipe"; - - String resourceassignmentContent = FileUtils.readFileToString( - new File("src/test/resources/mapping/Mdsal/resource-assignments-array.json"), Charset.defaultCharset()); - List batchResourceAssignment = - TransformationUtils.getListfromJson(resourceassignmentContent, ResourceAssignment.class); - - String dictionaryContent = FileUtils.readFileToString( - new File("src/test/resources/mapping/Mdsal/mdsal-array.json"), Charset.defaultCharset()); - - Map dictionaries = - ConfigResourceAssignmentTestUtils.getMapfromJson(dictionaryContent); - MdsalResourceProcessor dbResourceProcessor = new MdsalResourceProcessor(configRestAdaptorService); - Map componentContext = new HashMap<>(); - componentContext.put(ConfigModelConstant.PROPERTY_RESOURCE_ASSIGNMENTS, batchResourceAssignment); - componentContext.put(ConfigModelConstant.PROPERTY_ACTION_NAME, recipeName); - componentContext.put(ConfigModelConstant.PROPERTY_TEMPLATE_NAME, "sample-template"); - componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARIES, dictionaries); - componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + recipeName + ".profile_name", "sample"); - - Map inParams = new HashMap<>(); - SvcLogicContext ctx = new SvcLogicContext(); - String datatypeContent = FileUtils.readFileToString( - new File("src/test/resources/mapping/Mdsal/dt-location.json"), Charset.defaultCharset()); - ctx.setAttribute("data_types.dt-location", datatypeContent); - dbResourceProcessor.process(inParams, ctx, componentContext); - logger.info("Component Context = ({})", componentContext); - Assert.assertNotNull("failed to populate Array Complex response ", componentContext); - - } - - @Test - @SuppressWarnings("unchecked") - public void testMDSALArraySimpleProcess() throws Exception { - logger.info(" ******************************* testMDSALArrayComplexProcess ***************************"); - - Mockito.doAnswer(new Answer() { - @Override - public String answer(InvocationOnMock invocationOnMock) throws Throwable { - Object[] args = invocationOnMock.getArguments(); - String response = null; - if (args != null) { - response = FileUtils.readFileToString( - new File("src/test/resources/mapping/Mdsal/array-complex-v4-assigned-response.json"), - Charset.defaultCharset()); - } - return response; - } - }).when(configRestAdaptorService).getResource(Matchers.anyString(), Matchers.anyString(), - Matchers.any(Class.class)); - - String recipeName = "sample-recipe"; - - String resourceassignmentContent = FileUtils.readFileToString( - new File("src/test/resources/mapping/Mdsal/resource-assignments-complex-simple.json"), - Charset.defaultCharset()); - List batchResourceAssignment = - TransformationUtils.getListfromJson(resourceassignmentContent, ResourceAssignment.class); - - String dictionaryContent = FileUtils.readFileToString( - new File("src/test/resources/mapping/Mdsal/mdsal-array-v4iplist.json"), Charset.defaultCharset()); - Map dictionaries = - ConfigResourceAssignmentTestUtils.getMapfromJson(dictionaryContent); - MdsalResourceProcessor mdsalResourceProcessor = new MdsalResourceProcessor(configRestAdaptorService); - Map componentContext = new HashMap<>(); - componentContext.put(ConfigModelConstant.PROPERTY_RESOURCE_ASSIGNMENTS, batchResourceAssignment); - componentContext.put(ConfigModelConstant.PROPERTY_ACTION_NAME, recipeName); - componentContext.put(ConfigModelConstant.PROPERTY_TEMPLATE_NAME, "sample-template"); - componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARIES, dictionaries); - componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + recipeName + ".service-instance-id", - "3c8d5a63-a793-4206-a67c-4b2e8e648196"); - componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + recipeName + ".oam-network-role", - "sample"); - componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + recipeName + ".oam-ipv4-ip-type", - "sample"); - componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + recipeName + ".profile_name", "sample"); - componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + recipeName + ".oam-vm-type", "sample"); - - Map inParams = new HashMap<>(); - SvcLogicContext ctx = new SvcLogicContext(); - // String datatypeContent = FileUtils.readFileToString(new - // File("src/test/resources/mapping/Mdsal/dt-v4-assigned-ip-list.json"), Charset.defaultCharset() ); - // ctx.setAttribute("data_types.dt-v4-assigned-ip-list", datatypeContent); - mdsalResourceProcessor.process(inParams, ctx, componentContext); - logger.info("Component Context = ({})", componentContext); - Assert.assertNotNull("failed to populate Array Complex response ", componentContext); - Assert.assertEquals("Compare String ", "10.66.1.152", - componentContext.get(ConfigModelConstant.PROPERTY_RECIPE_KEY_DOT + recipeName + ".v4-ip-prefix")); - - } - -} diff --git a/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/features/assignment/service/ConfigAssignmentNodeTest.java b/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/features/assignment/service/ConfigAssignmentNodeTest.java deleted file mode 100644 index 0fe6c9261..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/features/assignment/service/ConfigAssignmentNodeTest.java +++ /dev/null @@ -1,246 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.assignment.service; - -import java.io.File; -import java.nio.charset.Charset; -import java.util.HashMap; -import java.util.Map; -import org.apache.commons.io.FileUtils; -import org.apache.commons.lang3.StringUtils; -import org.apache.sling.testing.mock.osgi.MockOsgi; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.ccsdk.features.assignment.ConfigAssignmentConstants; -import org.onap.ccsdk.features.data.adaptor.service.ConfigResourceService; -import org.onap.ccsdk.features.generator.service.ConfigGeneratorService; -import org.onap.ccsdk.features.generator.service.ConfigGeneratorServiceImpl; -import org.onap.ccsdk.features.model.ConfigModelConstant; -import org.onap.ccsdk.features.model.service.ComponentNodeDelegate; -import org.onap.ccsdk.features.model.service.ComponentNodeService; -import org.onap.ccsdk.features.model.service.ComponentNodeServiceImpl; -import org.onap.ccsdk.features.model.service.ConfigModelService; -import org.onap.ccsdk.features.model.service.ConfigModelServiceImpl; -import org.onap.ccsdk.features.rest.adaptor.service.ConfigRestAdaptorService; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.osgi.framework.BundleContext; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -@RunWith(MockitoJUnitRunner.class) -public class ConfigAssignmentNodeTest { - - private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigAssignmentNodeTest.class); - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Mock - private ConfigResourceService configResourceService; - - @Mock - private ConfigRestAdaptorService configRestAdaptorService; - - private ConfigModelService configModelService; - - private ComponentNodeService componentNodeService; - - private ConfigGeneratorService configGeneratorService; - - BundleContext bundleContext = MockOsgi.newBundleContext(); - - @SuppressWarnings("unchecked") - @Before - public void before() throws Exception { - MockitoAnnotations.initMocks(this); - /* - * ConfigAssignmentNode configAssignmentNode = new ConfigAssignmentNode(componentNodeService, - * configResourceService, configModelService, configRestAdaptorService, configGeneratorService); - * bundleContext.registerService(ConfigAssignmentNode.class, configAssignmentNode, null); - */ - } - - @Test - public void testResourceAssignment() throws Exception { - ConfigResourceAssignmentTestUtils.injectTransactionLogSaveMock(configResourceService); - - ConfigResourceAssignmentTestUtils.injectConfigModelMock(configRestAdaptorService, "resource_assignment"); - - ConfigResourceAssignmentTestUtils.injectResourceDictionaryMock(configRestAdaptorService, - "assignments/empty-dictionary.json"); - - ConfigResourceAssignmentTestUtils.injectConfigResourceSaveMock(configResourceService); - - componentNodeService = - new ComponentNodeServiceImpl(bundleContext, configResourceService, configRestAdaptorService); - configModelService = new ConfigModelServiceImpl(configRestAdaptorService); - configGeneratorService = new ConfigGeneratorServiceImpl(configResourceService); - - ConfigAssignmentNode configAssignmentNode = new ConfigAssignmentNode(configResourceService, - configRestAdaptorService, configModelService, componentNodeService, configGeneratorService); - - String inputContent = FileUtils.readFileToString( - new File("src/test/resources/service_templates/input/input.json"), Charset.defaultCharset()); - - Map inParams = new HashMap<>(); - inParams.put(ConfigModelConstant.PROPERTY_SELECTOR, "test"); - inParams.put(ConfigAssignmentConstants.INPUT_PARAM_REQUEST_ID, "1234"); - inParams.put(ConfigAssignmentConstants.INPUT_PARAM_RESOURCE_ID, "resourceid-1234"); - inParams.put(ConfigAssignmentConstants.INPUT_PARAM_RESOURCE_TYPE, "vnf-type"); - inParams.put(ConfigModelConstant.SERVICE_TEMPLATE_KEY_ARTIFACT_NAME, "vpe-201802-baseconfig"); - inParams.put(ConfigModelConstant.SERVICE_TEMPLATE_KEY_ARTIFACT_VERSION, "1.0.0"); - inParams.put(ConfigModelConstant.PROPERTY_ACTION_NAME, "resource-assignment-action"); - inParams.put(ConfigAssignmentConstants.INPUT_PARAM_INPUT_DATA, inputContent); - inParams.put(ConfigAssignmentConstants.INPUT_PARAM_TEMPLATE_NAMES, "[\"base-config-template\"]"); - - // Populate the SvcContext ( Simulation) - SvcLogicContext svcLogicContext = new SvcLogicContext(); - Map context = new HashMap<>(); - context.put(ConfigModelConstant.PROPERTY_ACTION_NAME, "resource-assignment-action"); - context = configModelService.prepareContext(context, inputContent, "vpe-201802-baseconfig", "1.0.0"); - context.forEach((key, value) -> svcLogicContext.setAttribute(key, value)); - - Map componentContext = new HashMap<>(); - configAssignmentNode.process(inParams, svcLogicContext, componentContext); - Assert.assertNotNull("Failed to get response status", svcLogicContext.getAttribute("test.status")); - - } - - @Test - public void testSimplePreview() throws Exception { - ConfigResourceAssignmentTestUtils.injectTransactionLogSaveMock(configResourceService); - - ConfigResourceAssignmentTestUtils.injectConfigModelMock(configRestAdaptorService, "resource_assignment"); - - ConfigResourceAssignmentTestUtils.injectResourceDictionaryMock(configRestAdaptorService, - "assignments/empty-dictionary.json"); - - ConfigResourceAssignmentTestUtils.injectConfigResourceSaveMock(configResourceService); - - componentNodeService = - new ComponentNodeServiceImpl(bundleContext, configResourceService, configRestAdaptorService); - configModelService = new ConfigModelServiceImpl(configRestAdaptorService); - configGeneratorService = new ConfigGeneratorServiceImpl(configResourceService); - - ConfigAssignmentNode configAssignmentNode = new ConfigAssignmentNode(configResourceService, - configRestAdaptorService, configModelService, componentNodeService, configGeneratorService); - - String inputContent = FileUtils.readFileToString( - new File("src/test/resources/service_templates/input/input.json"), Charset.defaultCharset()); - - Map inParams = new HashMap<>(); - inParams.put(ConfigModelConstant.PROPERTY_SELECTOR, "test"); - inParams.put(ConfigAssignmentConstants.INPUT_PARAM_REQUEST_ID, "1234"); - inParams.put(ConfigAssignmentConstants.INPUT_PARAM_RESOURCE_ID, "resourceid-1234"); - inParams.put(ConfigAssignmentConstants.INPUT_PARAM_RESOURCE_TYPE, "vnf-type"); - inParams.put(ConfigModelConstant.SERVICE_TEMPLATE_KEY_ARTIFACT_NAME, "vpe-201802-baseconfig"); - inParams.put(ConfigModelConstant.SERVICE_TEMPLATE_KEY_ARTIFACT_VERSION, "1.0.0"); - inParams.put(ConfigModelConstant.PROPERTY_ACTION_NAME, "resource-assignment-action"); - inParams.put(ConfigAssignmentConstants.INPUT_PARAM_INPUT_DATA, inputContent); - inParams.put(ConfigAssignmentConstants.INPUT_PARAM_TEMPLATE_NAMES, "[\"base-config-template\"]"); - SvcLogicContext ctx = new SvcLogicContext(); - configAssignmentNode.process(inParams, ctx); - Assert.assertNotNull("Failed to get response mashed Content", - ctx.getAttribute("test.mashed-data.base-config-template")); - } - - @Test - public void testComplexPreview() throws Exception { - ConfigResourceAssignmentTestUtils.injectTransactionLogSaveMock(configResourceService); - - ConfigResourceAssignmentTestUtils.injectConfigModelMock(configRestAdaptorService, "vpe-201802-baseconfig"); - - ConfigResourceAssignmentTestUtils.injectResourceDictionaryMock(configRestAdaptorService, - "service_templates/vpe-201802-baseconfig/dict.json"); - - ConfigResourceAssignmentTestUtils.injectConfigResourceSaveMock(configResourceService); - - componentNodeService = - new ComponentNodeServiceImpl(bundleContext, configResourceService, configRestAdaptorService); - configModelService = new ConfigModelServiceImpl(configRestAdaptorService); - configGeneratorService = new ConfigGeneratorServiceImpl(configResourceService); - - ConfigAssignmentNode configAssignmentNode = new ConfigAssignmentNode(configResourceService, - configRestAdaptorService, configModelService, componentNodeService, configGeneratorService); - - String inputContent = FileUtils.readFileToString( - new File("src/test/resources/service_templates/vpe-201802-baseconfig/input-complex.json"), - Charset.defaultCharset()); - - Map inParams = new HashMap<>(); - inParams.put(ConfigModelConstant.PROPERTY_SELECTOR, "complex-test"); - inParams.put(ConfigAssignmentConstants.INPUT_PARAM_REQUEST_ID, "request-1234"); - inParams.put(ConfigAssignmentConstants.INPUT_PARAM_RESOURCE_ID, "resourceid-1234"); - inParams.put(ConfigAssignmentConstants.INPUT_PARAM_RESOURCE_TYPE, "vnf-type"); - inParams.put(ConfigModelConstant.SERVICE_TEMPLATE_KEY_ARTIFACT_NAME, "vpe-201802-baseconfig"); - inParams.put(ConfigModelConstant.SERVICE_TEMPLATE_KEY_ARTIFACT_VERSION, "1.0.0"); - inParams.put(ConfigModelConstant.PROPERTY_ACTION_NAME, "resource-assignment-action"); - inParams.put(ConfigAssignmentConstants.INPUT_PARAM_INPUT_DATA, inputContent); - inParams.put(ConfigAssignmentConstants.INPUT_PARAM_TEMPLATE_NAMES, "[\"base-config-template\"]"); - SvcLogicContext ctx = new SvcLogicContext(); - configAssignmentNode.process(inParams, ctx); - Assert.assertNotNull("Failed to get response mashed Content", - ctx.getAttribute("complex-test.mashed-data.base-config-template")); - - } - - @Test - public void inputValidator() { - SvcLogicContext ctx = new SvcLogicContext(); - try { - - logger.info(" ******************************* inputValidator ***************************"); - String serviceTemplateContent = FileUtils.readFileToString( - new File("src/test/resources/service_templates/resource_assignment.json"), - Charset.defaultCharset()); - - String inputcontent = FileUtils.readFileToString( - new File("src/test/resources/service_templates/input/inputValidateTest.json"), - Charset.defaultCharset()); - - Map context = new HashMap<>(); - configModelService.prepareContext(context, inputcontent, serviceTemplateContent); - - // TransformationUtils.printMap(context); - - context.forEach((name, value) -> { - if (StringUtils.isNotBlank(name) && StringUtils.isNotBlank(value)) { - ctx.setAttribute(name, value); - } - }); - - ComponentNodeDelegate componentNodeDelegate = new ComponentNodeDelegate(componentNodeService); - Map inParams = new HashMap<>(); - inParams.put(ConfigModelConstant.PROPERTY_SELECTOR, "resource-assignment"); - componentNodeDelegate.process(inParams, ctx); - Assert.fail(); - } catch (Exception e) { - logger.error("Failed in inputValidator" + e.getMessage()); - logger.info("** ctx.getAttribute Check for **" + ctx.getAttribute("resource-assignment.error-message")); - } - - } - -} diff --git a/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/features/assignment/service/ConfigPreviewServiceTest.java b/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/features/assignment/service/ConfigPreviewServiceTest.java deleted file mode 100644 index be4ca0381..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/features/assignment/service/ConfigPreviewServiceTest.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.assignment.service; - -import java.io.File; -import java.nio.charset.Charset; -import org.apache.commons.io.FileUtils; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.ccsdk.features.assignment.data.ResourceAssignmentData; -import org.onap.ccsdk.features.data.adaptor.domain.ConfigResource; -import org.onap.ccsdk.features.data.adaptor.service.ConfigResourceService; -import org.onap.ccsdk.features.generator.service.ConfigGeneratorService; -import org.onap.ccsdk.features.generator.service.ConfigGeneratorServiceImpl; -import org.onap.ccsdk.features.model.service.ConfigModelService; -import org.onap.ccsdk.features.model.service.ConfigModelServiceImpl; -import org.onap.ccsdk.features.rest.adaptor.service.ConfigRestAdaptorService; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -@RunWith(MockitoJUnitRunner.class) -public class ConfigPreviewServiceTest { - - private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigPreviewServiceTest.class); - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Mock - private ConfigResourceService configResourceService; - - @Mock - private ConfigRestAdaptorService configRestAdaptorService; - - private ConfigModelService configModelService; - private ConfigGeneratorService configGeneratorService; - - @SuppressWarnings("unchecked") - @Before - public void before() throws Exception { - MockitoAnnotations.initMocks(this); - } - - @Test - public void testGenerateTemplateResourceMash() throws Exception { - - ConfigResourceAssignmentTestUtils.injectTransactionLogSaveMock(configResourceService); - - ConfigResourceAssignmentTestUtils.injectConfigModelMock(configRestAdaptorService, "resource_assignment"); - - ConfigResourceAssignmentTestUtils.injectResourceDictionaryMock(configRestAdaptorService, - "assignments/empty-dictionary.json"); - - ConfigResource configResourceQuery = new ConfigResource(); - configResourceQuery.setServiceTemplateVersion("sample-serviceTemplateName"); - configResourceQuery.setServiceTemplateVersion("1.0.0"); - configResourceQuery.setRecipeName("sample-action"); - configResourceQuery.setResourceId("123-resourceId"); - configResourceQuery.setResourceType("sample-resourceType"); - configResourceQuery.setTemplateName("base-config-template"); - String inputContent = FileUtils.readFileToString( - new File("src/test/resources/service_templates/input/input.json"), Charset.defaultCharset()); - configResourceQuery.setResourceData(inputContent); - - ConfigResourceAssignmentTestUtils.injectGetConfigResourceMock(configResourceService, configResourceQuery); - - configModelService = new ConfigModelServiceImpl(configRestAdaptorService); - configGeneratorService = new ConfigGeneratorServiceImpl(configResourceService); - - ConfigPreviewService configPreviewService = - new ConfigPreviewService(configResourceService, configModelService, configGeneratorService); - - ResourceAssignmentData resourceAssignmentData = new ResourceAssignmentData(); - resourceAssignmentData.setResourceId("123-resourceId"); - resourceAssignmentData.setResourceType("sample-resourceType"); - resourceAssignmentData.setServiceTemplateName("sample-serviceTemplateName"); - resourceAssignmentData.setServiceTemplateVersion("1.0.0"); - resourceAssignmentData.setActionName("sample-action"); - - resourceAssignmentData = configPreviewService.generateTemplateResourceMash(resourceAssignmentData); - - Assert.assertNotNull("Failed to get GenerateTemplateResourceMash response.", resourceAssignmentData); - Assert.assertNotNull("Failed to get template mashed contents.", - resourceAssignmentData.getTemplatesMashedContents()); - - Assert.assertNotNull("Failed to get base-config template mashed contents.", - resourceAssignmentData.getTemplatesMashedContents().get("base-config-template")); - } -} diff --git a/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/features/assignment/service/ConfigResourceAssignmentTestUtils.java b/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/features/assignment/service/ConfigResourceAssignmentTestUtils.java deleted file mode 100644 index 97082ae0f..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/features/assignment/service/ConfigResourceAssignmentTestUtils.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.assignment.service; - -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyString; -import java.io.File; -import java.nio.charset.Charset; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import org.apache.commons.io.FileUtils; -import org.apache.commons.io.FilenameUtils; -import org.apache.commons.io.IOUtils; -import org.mockito.Matchers; -import org.mockito.Mockito; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; -import org.onap.ccsdk.features.data.adaptor.domain.ConfigResource; -import org.onap.ccsdk.features.data.adaptor.domain.TransactionLog; -import org.onap.ccsdk.features.data.adaptor.service.ConfigResourceService; -import org.onap.ccsdk.features.model.ConfigModelConstant; -import org.onap.ccsdk.features.model.data.dict.ResourceDefinition; -import org.onap.ccsdk.features.model.domain.ConfigModel; -import org.onap.ccsdk.features.model.domain.ConfigModelContent; -import org.onap.ccsdk.features.rest.adaptor.service.ConfigRestAdaptorService; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; - -public class ConfigResourceAssignmentTestUtils { - - private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigResourceAssignmentTestUtils.class); - - public static void injectTransactionLogSaveMock(ConfigResourceService configResourceService) throws Exception { - Mockito.doAnswer(new Answer() { - @Override - public Void answer(InvocationOnMock invocationOnMock) throws Throwable { - Object[] args = invocationOnMock.getArguments(); - if (args != null) { - logger.trace("Transaction info " + Arrays.asList(args)); - } - return null; - } - }).when(configResourceService).save(any(TransactionLog.class)); - } - - public static void injectConfigModelMock(ConfigRestAdaptorService configRestAdaptorService, - String serviceTemplateName) throws Exception { - - Mockito.doAnswer(new Answer() { - @Override - public org.onap.ccsdk.features.model.domain.ConfigModel answer(InvocationOnMock invocationOnMock) - throws Throwable { - Object[] args = invocationOnMock.getArguments(); - org.onap.ccsdk.features.model.domain.ConfigModel serviceArtifact = null; - if (args != null && args.length == 3) { - - logger.info("Artifact info " + Arrays.asList(args)); - String modelContent = IOUtils.toString( - ConfigResourceAssignmentTestUtils.class.getClassLoader().getResourceAsStream( - "service_templates/" + serviceTemplateName + "/" + serviceTemplateName + ".json"), - Charset.defaultCharset()); - - ConfigModelContent configModelContent = new ConfigModelContent(); - configModelContent.setContent(modelContent); - configModelContent.setContentType(ConfigModelConstant.MODEL_CONTENT_TYPE_TOSCA_JSON); - - List configModelContents = new ArrayList<>(); - configModelContents.add(configModelContent); - - String velocityDir = ConfigResourceAssignmentTestUtils.class.getClassLoader() - .getResource("service_templates/" + serviceTemplateName + "/velocity").getPath(); - - Collection templateFiles = - FileUtils.listFiles(new File(velocityDir), new String[] {"vtl"}, true); - logger.info("Template Files info " + templateFiles); - for (File templateFile : templateFiles) { - String templateContent = FileUtils.readFileToString(templateFile, Charset.defaultCharset()); - ConfigModelContent configModelTemplateContent = new ConfigModelContent(); - configModelTemplateContent.setContent(templateContent); - configModelTemplateContent.setName(FilenameUtils.getBaseName(templateFile.getName())); - configModelTemplateContent.setContentType(ConfigModelConstant.MODEL_CONTENT_TYPE_TEMPLATE); - configModelContents.add(configModelTemplateContent); - } - - serviceArtifact = new org.onap.ccsdk.features.model.domain.ConfigModel(); - serviceArtifact.setArtifactName(String.valueOf(args[0])); - serviceArtifact.setArtifactVersion(String.valueOf(args[1])); - serviceArtifact.setPublished("Y"); - serviceArtifact.setConfigModelContents(configModelContents); - } - - return serviceArtifact; - } - }).when(configRestAdaptorService).getResource(anyString(), anyString(), Matchers.any(Class.class)); - } - - public static void injectResourceDictionaryMock(ConfigRestAdaptorService configRestAdaptorService, - String dictionaryFileName) throws Exception { - - Mockito.doAnswer(new Answer() { - @Override - public String answer(InvocationOnMock invocationOnMock) throws Throwable { - Object[] args = invocationOnMock.getArguments(); - String dictionaties = "[]"; - if (args != null) { - logger.info("getResourceDictionaryByNames " + Arrays.asList(args)); - dictionaties = IOUtils.toString( - ConfigAssignmentNodeTest.class.getClassLoader().getResourceAsStream(dictionaryFileName), - Charset.defaultCharset()); - } - return dictionaties; - } - }).when(configRestAdaptorService).postResource(Matchers.any(), Matchers.any(), Matchers.any(), - Matchers.any(Class.class)); - } - - public static void injectConfigResourceSaveMock(ConfigResourceService configResourceService) throws Exception { - Mockito.doAnswer(new Answer() { - @Override - public ConfigResource answer(InvocationOnMock invocationOnMock) throws Throwable { - Object[] args = invocationOnMock.getArguments(); - ConfigResource configResource = null; - if (args != null) { - configResource = (ConfigResource) args[0]; - logger.info("Config Resource Save info " + configResource); - return configResource; - } - return configResource; - } - }).when(configResourceService).saveConfigResource(any(ConfigResource.class)); - } - - public static void injectGetConfigResourceMock(ConfigResourceService configResourceService, - ConfigResource configResource) throws Exception { - Mockito.doAnswer(new Answer>() { - @Override - public List answer(InvocationOnMock invocationOnMock) throws Throwable { - Object[] args = invocationOnMock.getArguments(); - List configResources = new ArrayList<>(); - if (args != null) { - configResources.add(configResource); - } - return configResources; - } - }).when(configResourceService).getConfigResource(any(ConfigResource.class)); - } - - public static String getFileContent(String filePath) throws Exception { - return IOUtils.toString(ConfigResourceAssignmentTestUtils.class.getClassLoader().getResourceAsStream(filePath), - Charset.defaultCharset()); - } - - public static Map getMapfromJson(String content) { - try { - ObjectMapper mapper = new ObjectMapper(); - return mapper.readValue(content, new TypeReference>() {}); - } catch (Exception e) { - logger.info("getMapfromJson Exception ({})", e); - } - return null; - } -} diff --git a/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/features/assignment/service/ResourceAssignmentGenerationTest.java b/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/features/assignment/service/ResourceAssignmentGenerationTest.java deleted file mode 100644 index 73f0d0941..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/features/assignment/service/ResourceAssignmentGenerationTest.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.assignment.service; - -import java.nio.charset.Charset; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.apache.commons.io.IOUtils; -import org.junit.Assert; -import org.junit.Test; -import org.onap.ccsdk.features.model.ConfigModelConstant; -import org.onap.ccsdk.features.model.ValidTypes; -import org.onap.ccsdk.features.model.data.ResourceAssignment; -import org.onap.ccsdk.features.model.utils.ResourceAssignmentUtils; -import org.onap.ccsdk.features.model.utils.TransformationUtils; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.fasterxml.jackson.databind.JsonNode; - -public class ResourceAssignmentGenerationTest { - - private static EELFLogger logger = EELFManager.getInstance().getLogger(ResourceAssignmentGenerationTest.class); - - @Test - public void testResourceDataSetting() { - try { - logger.info(" **************** testResourceDataSetting *****************"); - String resourceAssignmentContents = IOUtils.toString(TopologicalSortingTest.class.getClassLoader() - .getResourceAsStream("assignments/alltype-empty-value-mapping.json"), Charset.defaultCharset()); - - List assignments = - TransformationUtils.getListfromJson(resourceAssignmentContents, ResourceAssignment.class); - if (assignments != null) { - Map componentContext = new HashMap<>(); - componentContext.put(ConfigModelConstant.PROPERTY_ACTION_NAME, "sample-recipe"); - for (ResourceAssignment resourceAssignment : assignments) { - if (resourceAssignment != null && resourceAssignment.getProperty() != null) { - String type = resourceAssignment.getProperty().getType(); - Object value = null; - if (ValidTypes.DATA_TYPE_STRING.equals(type)) { - value = new String("abcdef"); - } else if (ValidTypes.DATA_TYPE_INTEGER.equals(type)) { - value = new Integer(1234); - } else if (ValidTypes.DATA_TYPE_BOOLEAN.equals(type)) { - value = new Boolean(true); - } else if (ValidTypes.DATA_TYPE_LIST.equals(type)) { - String entityType = resourceAssignment.getProperty().getEntrySchema().getType(); - if (ValidTypes.DATA_TYPE_STRING.equals(entityType)) { - value = "[\"abcd-array\"]"; - } else { - String content = "[{\"name\" : \"abcd-array-complex\"}]"; - JsonNode node = TransformationUtils.getJsonNodeForString(content); - value = node; - } - } else { - String content = "{\"name\" : \"abcd-complex\"}"; - JsonNode node = TransformationUtils.getJsonNodeForString(content); - value = node; - } - ResourceAssignmentUtils.setResourceDataValue(componentContext, resourceAssignment, value); - } - } - String generatedData = ResourceAssignmentUtils.generateResourceDataForAssignments(assignments); - logger.trace("Generated Data " + generatedData); - - Assert.assertNotNull("Failed to generate resource data", generatedData); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Test - public void testGenerateResourceData() { - try { - logger.info(" **************** testGenerateResourceData *****************"); - String resourceAssignmentContents = IOUtils.toString(TopologicalSortingTest.class.getClassLoader() - .getResourceAsStream("assignments/alltype-mapping.json"), Charset.defaultCharset()); - - List assignments = - TransformationUtils.getListfromJson(resourceAssignmentContents, ResourceAssignment.class); - if (assignments != null) { - - String generatedData = ResourceAssignmentUtils.generateResourceDataForAssignments(assignments); - logger.trace("Generated Data " + generatedData); - - Assert.assertNotNull("Failed to generate resource data", generatedData); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - -} diff --git a/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/features/assignment/service/ResourceAssignmentValidation.java b/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/features/assignment/service/ResourceAssignmentValidation.java deleted file mode 100644 index 081315639..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/features/assignment/service/ResourceAssignmentValidation.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.assignment.service; - -import java.io.IOException; -import java.nio.charset.Charset; -import java.util.List; -import org.apache.commons.io.IOUtils; -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.onap.ccsdk.features.model.ConfigModelException; -import org.onap.ccsdk.features.model.data.ResourceAssignment; -import org.onap.ccsdk.features.model.utils.TransformationUtils; -import org.onap.ccsdk.features.model.validator.ResourceAssignmentValidator; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -public class ResourceAssignmentValidation { - private static EELFLogger logger = EELFManager.getInstance().getLogger(ResourceAssignmentValidation.class); - - @Rule - public final ExpectedException exception = ExpectedException.none(); - - @Test - public void testValidateSuccess() { - try { - logger.info(" **************** testValidateSuccess *****************"); - String resourceMapping = IOUtils.toString( - TopologicalSortingTest.class.getClassLoader().getResourceAsStream("validation/success.json"), - Charset.defaultCharset()); - - List assignments = - TransformationUtils.getListfromJson(resourceMapping, ResourceAssignment.class); - if (assignments != null) { - ResourceAssignmentValidator resourceAssignmentValidator = new ResourceAssignmentValidator(assignments); - - boolean result = resourceAssignmentValidator.validateResourceAssignment(); - Assert.assertTrue("Failed to Validate", result); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Test(expected = ConfigModelException.class) - public void testValidateDuplicate() throws IOException, ConfigModelException { - logger.info(" **************** testValidateDuplicate *****************"); - String resourceMapping = IOUtils.toString( - TopologicalSortingTest.class.getClassLoader().getResourceAsStream("validation/duplicate.json"), - Charset.defaultCharset()); - - List assignments = - TransformationUtils.getListfromJson(resourceMapping, ResourceAssignment.class); - if (assignments != null) { - ResourceAssignmentValidator resourceAssignmentValidator = new ResourceAssignmentValidator(assignments); - resourceAssignmentValidator.validateResourceAssignment(); - } - - } - - @Test(expected = ConfigModelException.class) - public void testValidateCyclic() throws IOException, ConfigModelException { - logger.info(" **************** testValidateCyclic *****************"); - String resourceMapping = IOUtils.toString( - TopologicalSortingTest.class.getClassLoader().getResourceAsStream("validation/cyclic.json"), - Charset.defaultCharset()); - - List assignments = - TransformationUtils.getListfromJson(resourceMapping, ResourceAssignment.class); - if (assignments != null) { - ResourceAssignmentValidator resourceAssignmentValidator = new ResourceAssignmentValidator(assignments); - - resourceAssignmentValidator.validateResourceAssignment(); - } - - } -} diff --git a/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/features/assignment/service/TopologicalSortingTest.java b/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/features/assignment/service/TopologicalSortingTest.java deleted file mode 100644 index f6e8871a6..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/test/java/org/onap/ccsdk/features/assignment/service/TopologicalSortingTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.assignment.service; - -import java.nio.charset.Charset; -import java.util.List; -import org.apache.commons.io.IOUtils; -import org.junit.Assert; -import org.junit.Test; -import org.onap.ccsdk.features.assignment.processor.ResourceAssignmentProcessor; -import org.onap.ccsdk.features.model.data.ResourceAssignment; -import org.onap.ccsdk.features.model.utils.TransformationUtils; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -public class TopologicalSortingTest { - private static EELFLogger logger = EELFManager.getInstance().getLogger(TopologicalSortingTest.class); - - @Test - public void testBulkSequencingMapping() { - try { - logger.info(" **************** Bulk Sequencing Default *****************"); - String resourceMapping = IOUtils.toString( - TopologicalSortingTest.class.getClassLoader().getResourceAsStream("mapping/dependency.json"), - Charset.defaultCharset()); - - List assignments = - TransformationUtils.getListfromJson(resourceMapping, ResourceAssignment.class); - if (assignments != null) { - SvcLogicContext ctx = new SvcLogicContext(); - ResourceAssignmentProcessor resourceAssignmentProcessor = - new ResourceAssignmentProcessor(assignments, ctx); - List> sequenceBatchResourceAssignment = resourceAssignmentProcessor.process(); - - Assert.assertNotNull("Failed to populate Sequence Bulk Mappings", sequenceBatchResourceAssignment); - Assert.assertNotEquals("Failed to populate Sequence Bulk Mappings size ", - (sequenceBatchResourceAssignment.size() > 0)); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - -} diff --git a/blueprints-processor/plugin/assignment-provider/src/test/resources/assignments/alltype-empty-value-mapping.json b/blueprints-processor/plugin/assignment-provider/src/test/resources/assignments/alltype-empty-value-mapping.json deleted file mode 100644 index a3d65927b..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/test/resources/assignments/alltype-empty-value-mapping.json +++ /dev/null @@ -1,86 +0,0 @@ -[ - { - "name": "vnf-id-string", - "property": { - "required": true, - "type": "string" - }, - "input-param": true, - "dictionary-name": "vnf-id-string", - "dictionary-source": "input", - "version": 0, - "status": "success", - "updated-by": "System" - }, - { - "name": "vnf-id-integer", - "property": { - "required": true, - "type": "integer" - }, - "input-param": true, - "dictionary-name": "vnf-id-integer", - "dictionary-source": "input", - "version": 0, - "status": "success", - "updated-by": "System" - }, - { - "name": "vnf-boolean", - "property": { - "required": true, - "type": "boolean" - }, - "input-param": true, - "dictionary-name": "vnf-boolean", - "dictionary-source": "input", - "version": 0, - "status": "success", - "updated-by": "System" - }, - { - "name": "vnf-complex", - "property": { - "required": true, - "type": "dt-complex" - }, - "input-param": true, - "dictionary-name": "vnf-complex", - "dictionary-source": "input", - "version": 0, - "status": "success", - "updated-by": "System" - }, - { - "name": "vnf-id-array", - "property": { - "required": true, - "type": "list", - "entry_schema": { - "type": "string" - } - }, - "input-param": true, - "dictionary-name": "vnf-id-array", - "dictionary-source": "input", - "version": 0, - "status": "success", - "updated-by": "System" - }, - { - "name": "vnf-array-complex", - "property": { - "required": true, - "type": "list", - "entry_schema": { - "type": "dt-complex" - } - }, - "input-param": true, - "dictionary-name": "vnf-array-complex", - "dictionary-source": "input", - "version": 0, - "status": "success", - "updated-by": "System" - } -] diff --git a/blueprints-processor/plugin/assignment-provider/src/test/resources/assignments/alltype-mapping.json b/blueprints-processor/plugin/assignment-provider/src/test/resources/assignments/alltype-mapping.json deleted file mode 100644 index 36909da99..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/test/resources/assignments/alltype-mapping.json +++ /dev/null @@ -1,110 +0,0 @@ -[ - { - "name": "vnf-id-string", - "property": { - "required": true, - "type": "string", - "value": "123456" - }, - "input-param": true, - "dictionary-name": "vnf-id-string", - "dictionary-source": "input", - "version": 0, - "status": "success", - "updated-by": "System" - }, - { - "name": "vnf-id-integer", - "property": { - "required": true, - "type": "integer", - "value": 123456 - }, - "input-param": true, - "dictionary-name": "vnf-id-integer", - "dictionary-source": "input", - "version": 0, - "status": "success", - "updated-by": "System" - }, - { - "name": "vnf-boolean", - "property": { - "required": true, - "type": "boolean", - "value": true - }, - "input-param": true, - "dictionary-name": "vnf-boolean", - "dictionary-source": "input", - "version": 0, - "status": "success", - "updated-by": "System" - }, - { - "name": "vnf-complex", - "property": { - "required": true, - "type": "dt-complex", - "value": { - "name": "Brinda", - "location": "Madurai", - "count": 2 - } - }, - "input-param": true, - "dictionary-name": "vnf-complex", - "dictionary-source": "input", - "version": 0, - "status": "success", - "updated-by": "System" - }, - { - "name": "vnf-id-array", - "property": { - "required": true, - "type": "list", - "entry_schema": { - "type": "string" - }, - "value": [ - "A", - "B", - "C" - ] - }, - "input-param": true, - "dictionary-name": "vnf-id-array", - "dictionary-source": "input", - "version": 0, - "status": "success", - "updated-by": "System" - }, - { - "name": "vnf-array-complex", - "property": { - "required": true, - "type": "list", - "entry_schema": { - "type": "dt-complex" - }, - "value": [ - { - "name": "A" - }, - { - "name": "B" - }, - { - "name": "C" - } - ] - }, - "input-param": true, - "dictionary-name": "vnf-array-complex", - "dictionary-source": "input", - "version": 0, - "status": "success", - "updated-by": "System" - } -] diff --git a/blueprints-processor/plugin/assignment-provider/src/test/resources/assignments/empty-dictionary.json b/blueprints-processor/plugin/assignment-provider/src/test/resources/assignments/empty-dictionary.json deleted file mode 100644 index 0637a088a..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/test/resources/assignments/empty-dictionary.json +++ /dev/null @@ -1 +0,0 @@ -[] \ No newline at end of file diff --git a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/array-complex-response.json b/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/array-complex-response.json deleted file mode 100644 index 2dfe89e29..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/array-complex-response.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "locations": [ - { - "mdsal-country": "US", - "mdsal-state": "NJ" - }, - { - "mdsal-country": "INDIA", - "mdsal-state": "TN" - } - ] -} diff --git a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/array-complex-v4-assigned-response.json b/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/array-complex-v4-assigned-response.json deleted file mode 100644 index d7c5546c1..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/array-complex-v4-assigned-response.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "v4-assigned-ip-list": [ - { - "v4-ip-type": "NMLAN", - "ipv4-gateway-prefix": "10.66.1.129", - "v4-ip-prefix": "10.66.1.152", - "v4-ip-prefix-length": 32, - "ip-count": 1, - "v4-ip-source": "EIPAM", - "client-key": "ADIG_19_vnf_name061rej01" - } - ] -} diff --git a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/complex-response.json b/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/complex-response.json deleted file mode 100644 index 1a36100fd..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/complex-response.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "locations": { - "mdsal-country": "US", - "mdsal-state": "NJ" - } -} diff --git a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/default-pointer.json b/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/default-pointer.json deleted file mode 100644 index 47edb1881..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/default-pointer.json +++ /dev/null @@ -1,166 +0,0 @@ -{ - "vnf-topology-information": { - "vnf-assignments": { - "availability-zones": [ - { - "availability-zone": "frkde-esx-az01" - } - ], - "vnf-vms": [ - { - "vm-type": "vre", - "vm-count": 1, - "vm-networks": [ - { - "network-role": "ADIGOam.OAM", - "network-name": "ADIGOAM.OAM", - "v4-assigned-ip-list": [ - { - "v4-ip-type": "NMLAN", - "ipv4-gateway-prefix": "10.66.1.129", - "v4-ip-prefix": "10.66.1.152", - "v4-ip-prefix-length": 32, - "ip-count": 1, - "v4-ip-source": "EIPAM", - "client-key": "ADIG_19_vnf_name061rej01" - } - ], - "network-id": "VPEADIG1d77c-1086-41ec-b7f3-94bb30936807" - }, - { - "network-role": "Internal-Network", - "network-name": "VMX-INTTERNAL056", - "v4-assigned-ip-list": [ - { - "v4-ip-type": "INTERNAL", - "v4-ip-prefix": "128.0.0.1", - "ipv4-prefix-block": "128.0.0.0", - "v4-ip-prefix-length": 24, - "v4-ip-source": "OTHER" - } - ], - "network-forwarding": "l2", - "network-id": "VMX-INT1" - } - ], - "vm-names": [ - { - "vm-name": "ADIG_19_vnf_name061rej", - "vm-uuid": "50d2032d-fe15-4e82-94f3-8b73c566a345" - } - ] - }, - { - "vm-type": "vpfe", - "vm-count": 1, - "vm-networks": [ - { - "network-role": "ADIG_SRIOV_3", - "network-name": "ADIG_SRIOV_3", - "multicast-allow": true, - "broadcast-allow": true, - "network-id": "VPEADIG1d77c-1086-41ec-b7f3-94bb30936810", - "vlan-filter": "[4013,4014]", - "network-macs": [ - { - "mac-address": "dc:38:e1:69:bf:5f" - } - ], - "vlan-strip": false, - "unicast-allow": true - }, - { - "network-role": "ADIG_SRIOV_4", - "network-name": "ADIG_SRIOV_4", - "multicast-allow": true, - "broadcast-allow": true, - "network-id": "VPEADIG1d77c-1086-41ec-b7f3-94bb30936811", - "vlan-filter": "[4013,4014]", - "network-macs": [ - { - "mac-address": "dc:38:e1:69:bf:5f" - } - ], - "vlan-strip": false, - "unicast-allow": true - }, - { - "network-role": "ADIG_SRIOV_1", - "network-name": "ADIG_SRIOV_1", - "multicast-allow": true, - "broadcast-allow": true, - "network-id": "VPEADIG1d77c-1086-41ec-b7f3-94bb30936808", - "vlan-filter": "[4013,4014]", - "network-macs": [ - { - "mac-address": "dc:38:e1:69:bf:5f" - } - ], - "vlan-strip": false, - "unicast-allow": true - }, - { - "network-role": "ADIG_SRIOV_2", - "network-name": "ADIG_SRIOV_2", - "multicast-allow": true, - "broadcast-allow": true, - "network-id": "VPEADIG1d77c-1086-41ec-b7f3-94bb30936809", - "vlan-filter": "[4013,4014]", - "network-macs": [ - { - "mac-address": "dc:38:e1:69:bf:5f" - } - ], - "vlan-strip": false, - "unicast-allow": true - }, - { - "network-role": "Internal-Network", - "network-name": "VMX-INTTERNAL056", - "v4-assigned-ip-list": [ - { - "v4-ip-type": "INTERNAL", - "v4-ip-prefix": "128.0.0.16", - "ipv4-prefix-block": "128.0.0.0", - "v4-ip-prefix-length": 24, - "v4-ip-source": "OTHER" - } - ], - "network-forwarding": "l2", - "network-id": "VMX-INT1" - } - ], - "vm-names": [ - { - "vm-name": "ADIG_19_vnf_name056fej", - "vm-uuid": "d2ce6023-a3ab-412e-bc63-360307aac165" - } - ] - } - ], - "vnf-status": "Deactivated", - "vnf-networks": [ - { - "network-role": "ADIGOam.OAM", - "network-id": "VPEADIG1d77c-1086-41ec-b7f3-94bb30936807" - }, - { - "network-role": "ADIG_SRIOV_3", - "network-id": "VPEADIG1d77c-1086-41ec-b7f3-94bb30936810" - }, - { - "network-role": "ADIG_SRIOV_2", - "network-id": "VPEADIG1d77c-1086-41ec-b7f3-94bb30936809" - }, - { - "network-role": "ADIG_SRIOV_4", - "network-id": "VPEADIG1d77c-1086-41ec-b7f3-94bb30936811" - }, - { - "network-role": "ADIG_SRIOV_1", - "network-id": "VPEADIG1d77c-1086-41ec-b7f3-94bb30936808" - } - ] - } - } -} diff --git a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/dt-location.json b/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/dt-location.json deleted file mode 100644 index 52e0a7967..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/dt-location.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "version": "1.0.0", - "description": "test Data Type", - "properties": { - "country": { - "required": true, - "type": "string" - }, - "state": { - "required": false, - "type": "string" - } - }, - "derived_from": "tosca.datatypes.Root" -} diff --git a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/dt-v4-assigned-ip-list.json b/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/dt-v4-assigned-ip-list.json deleted file mode 100644 index bc8f1d2c2..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/dt-v4-assigned-ip-list.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "version": "1.0.0", - "description": "This is dt-v4-assigned-ip-list Data Type", - "properties": { - "v4-ip-type": { - "required": true, - "type": "string" - }, - "ipv4-gateway-prefix": { - "required": true, - "type": "string" - }, - "v4-ip-prefix": { - "required": true, - "type": "string" - }, - "v4-ip-prefix-length": { - "required": true, - "type": "string" - }, - "v4-ip-source": { - "required": true, - "type": "string" - } - }, - "derived_from": "tosca.datatypes.Root" -} diff --git a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/mdsal-array-v4iplist.json b/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/mdsal-array-v4iplist.json deleted file mode 100644 index 387a5ad2d..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/mdsal-array-v4iplist.json +++ /dev/null @@ -1,76 +0,0 @@ -{ - "v4-ip-prefix": { - "name": "v4-ip-prefix", - "property": { - "type": "string" - }, - "sources": { - "mdsal": { - "type": "source-mdsal", - "properties": { - "url-path": "/restconf/config/L3VNF-API:services/service-list/$service-instance-id/service-data/vnf-topology-information/vnf-assignments/vnf-vms/$oam-ipv4-ip-type/vm-networks/$oam-network-role/v4-assigned-ip-list/$oam-vm-type", - "path": "/v4-assigned-ip-list/0/v4-ip-prefix", - "input-key-mapping": { - "service-instance-id": "service-instance-id", - "oam-network-role": "oam-network-role", - "oam-ipv4-ip-type": "oam-ipv4-ip-type", - "oam-vm-type": "oam-vm-type" - }, - "output-key-mapping": { - "v4-ip-prefix": "v4-ip-prefix" - }, - "key-dependencies": [ - "service-instance-id", - "oam-network-role", - "oam-ipv4-ip-type", - "oam-vm-type" - ] - } - } - } - }, - "service-instance-id": { - "name": "service-instance-id", - "property": { - "type": "string" - }, - "sources": { - "default": { - "type": "source-input" - } - } - }, - "oam-network-role": { - "name": "oam-network-role", - "property": { - "type": "string" - }, - "sources": { - "default": { - "type": "source-input" - } - } - }, - "oam-ipv4-ip-type": { - "name": "oam-ipv4-ip-type", - "property": { - "type": "string" - }, - "sources": { - "default": { - "type": "source-input" - } - } - }, - "oam-vm-type": { - "name": "oam-vm-type", - "property": { - "type": "string" - }, - "sources": { - "default": { - "type": "source-input" - } - } - } -} diff --git a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/mdsal-array.json b/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/mdsal-array.json deleted file mode 100644 index 290a15752..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/mdsal-array.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "locations": { - "name": "locations", - "property": { - "type": "list", - "entry_schema": { - "type": "dt-location" - } - }, - "sources": { - "mdsal": { - "type": "source-mdsal", - "properties": { - "url-path": "/restconf/config/L3VNF-API/services/service-list/$profile_name/12345", - "path": "/locations", - "input-key-mapping": { - "profile_name": "profile_name" - }, - "output-key-mapping": { - "mdsal-country": "country", - "mdsal-state": "state" - }, - "key-dependencies": [ - "profile_name" - ] - } - } - } - }, - "profile_name": { - "name": "profile_name", - "property": { - "type": "string" - }, - "sources": { - "default": { - "type": "source-input" - } - } - } -} - diff --git a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/mdsal-complex.json b/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/mdsal-complex.json deleted file mode 100644 index f5a7d7ef6..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/mdsal-complex.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "location": { - "name": "location", - "property": { - "type": "dt-location" - }, - "sources": { - "mdsal": { - "type": "source-mdsal", - "properties": { - "url-path": "/restconf/config/L3VNF-API/services/service-list/$profile_name/12345", - "path": "/locations", - "input-key-mapping": { - "profile_name": "profile_name" - }, - "output-key-mapping": { - "mdsal-country": "country", - "mdsal-state": "state" - }, - "key-dependencies": [ - "profile_name" - ] - } - } - } - }, - "profile_name": { - "name": "profile_name", - "property": { - "type": "string" - }, - "sources": { - "default": { - "type": "source-input" - } - } - } -} diff --git a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/mdsal-simple.json b/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/mdsal-simple.json deleted file mode 100644 index db7ee7eed..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/mdsal-simple.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "country": { - "name": "country", - "property": { - "type": "string" - }, - "sources": { - "mdsal": { - "type": "source-mdsal", - "properties": { - "url-path": "/restconf/config/L3VNF-API/services/service-list/$profile_name/12345", - "path": "/locations", - "input-key-mapping": { - "profile_name": "profile_name" - }, - "output-key-mapping": { - "country": "country" - }, - "key-dependencies": [ - "profile_name" - ] - } - } - } - }, - "profile_name": { - "name": "profile_name", - "property": { - "type": "string" - }, - "sources": { - "input": { - "type": "source-input" - } - } - } -} diff --git a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/resource-assignments-array.json b/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/resource-assignments-array.json deleted file mode 100644 index 2b5865326..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/resource-assignments-array.json +++ /dev/null @@ -1,15 +0,0 @@ -[ - { - "name": "locations", - "input-param": true, - "property": { - "type": "list", - "entry_schema": { - "type": "dt-location" - } - }, - "dictionary-name": "locations", - "dictionary-source": "mdsal", - "dependencies": [] - } -] diff --git a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/resource-assignments-complex-simple.json b/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/resource-assignments-complex-simple.json deleted file mode 100644 index 15881cfd0..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/resource-assignments-complex-simple.json +++ /dev/null @@ -1,12 +0,0 @@ -[ - { - "name": "v4-ip-prefix", - "input-param": true, - "property": { - "type": "string" - }, - "dictionary-name": "v4-ip-prefix", - "dictionary-source": "mdsal", - "dependencies": [] - } -] diff --git a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/resource-assignments-complex.json b/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/resource-assignments-complex.json deleted file mode 100644 index e42bd9431..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/resource-assignments-complex.json +++ /dev/null @@ -1,12 +0,0 @@ -[ - { - "name": "location", - "input-param": true, - "property": { - "type": "dt-location" - }, - "dictionary-name": "location", - "dictionary-source": "mdsal", - "dependencies": [] - } -] diff --git a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/resource-assignments-simple.json b/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/resource-assignments-simple.json deleted file mode 100644 index 6385e6a8b..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/resource-assignments-simple.json +++ /dev/null @@ -1,12 +0,0 @@ -[ - { - "name": "country", - "input-param": true, - "property": { - "type": "string" - }, - "dictionary-name": "country", - "dictionary-source": "mdsal", - "dependencies": [] - } -] diff --git a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/simple-response.json b/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/simple-response.json deleted file mode 100644 index 8c2bb898f..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/Mdsal/simple-response.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "locations": "US" -} diff --git a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/db/db-array.json b/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/db/db-array.json deleted file mode 100644 index bab783544..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/db/db-array.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "locations": { - "name": "locations", - "property": { - "type": "list", - "entry_schema": { - "type": "dt-location" - } - }, - "sources": { - "db": { - "type": "source-sdnctl-db", - "properties": { - "query": "SELECT db-country, db-state FROM DEVICE_PROFILE WHERE profile_name = :profile_name", - "input-key-mapping": { - "profile_name": "profile_name" - }, - "output-key-mapping": { - "db-country": "country", - "db-state": "state" - }, - "key-dependencies": [ - "profile_name" - ] - } - } - } - }, - "profile_name": { - "name": "profile_name", - "property": { - "type": "string" - }, - "sources": { - "input": { - "type": "source-input" - } - } - } -} \ No newline at end of file diff --git a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/db/db-complex.json b/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/db/db-complex.json deleted file mode 100644 index 7310500e3..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/db/db-complex.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "location": { - "name": "location", - "property": { - "type": "dt-location" - }, - "sources": { - "db": { - "type": "source-sdnctl-db", - "properties": { - "query": "SELECT db-country, db-state FROM DEVICE_PROFILE WHERE profile_name = :profile_name", - "input-key-mapping": { - "profile_name": "profile_name" - }, - "output-key-mapping": { - "db-country": "country", - "db-state": "state" - }, - "key-dependencies": [ - "profile_name" - ] - } - } - } - }, - "profile_name": { - "name": "profile_name", - "property": { - "type": "string" - }, - "sources": { - "input": { - "type": "source-input" - } - } - } -} diff --git a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/db/db-simple.json b/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/db/db-simple.json deleted file mode 100644 index 86d29c751..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/db/db-simple.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "country": { - "name": "country", - "property": { - "type": "string" - }, - "sources": { - "db": { - "type": "source-sdnctl-db", - "properties": { - "query": "SELECT country FROM DEVICE_PROFILE WHERE profile_name = :profile_name", - "input-key-mapping": { - "profile_name": "profile_name" - }, - "output-key-mapping": { - "country": "country" - }, - "key-dependencies": [ - "profile_name" - ] - } - } - } - }, - "profile_name": { - "name": "profile_name", - "property": { - "type": "string" - }, - "sources": { - "input": { - "type": "source-input" - } - } - } -} diff --git a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/db/dt-location.json b/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/db/dt-location.json deleted file mode 100644 index 52e0a7967..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/db/dt-location.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "version": "1.0.0", - "description": "test Data Type", - "properties": { - "country": { - "required": true, - "type": "string" - }, - "state": { - "required": false, - "type": "string" - } - }, - "derived_from": "tosca.datatypes.Root" -} diff --git a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/db/resource-assignments-array.json b/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/db/resource-assignments-array.json deleted file mode 100644 index c82f9addc..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/db/resource-assignments-array.json +++ /dev/null @@ -1,15 +0,0 @@ -[ - { - "name": "locations", - "input-param": true, - "property": { - "type": "list", - "entry_schema": { - "type": "dt-location" - } - }, - "dictionary-name": "locations", - "dictionary-source": "db", - "dependencies": [] - } -] diff --git a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/db/resource-assignments-complex.json b/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/db/resource-assignments-complex.json deleted file mode 100644 index 4cca99bde..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/db/resource-assignments-complex.json +++ /dev/null @@ -1,12 +0,0 @@ -[ - { - "name": "location", - "input-param": true, - "property": { - "type": "dt-location" - }, - "dictionary-name": "location", - "dictionary-source": "db", - "dependencies": [] - } -] diff --git a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/db/resource-assignments-simple.json b/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/db/resource-assignments-simple.json deleted file mode 100644 index 02ce68be4..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/db/resource-assignments-simple.json +++ /dev/null @@ -1,12 +0,0 @@ -[ - { - "name": "country", - "input-param": true, - "property": { - "type": "string" - }, - "dictionary-name": "country", - "dictionary-source": "db", - "dependencies": [] - } -] diff --git a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/default/default-simple.json b/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/default/default-simple.json deleted file mode 100644 index fca0dde83..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/default/default-simple.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "country": { - "name": "country", - "property": { - "type": "string" - }, - "sources": { - "default": { - "type": "source-default" - } - } - }, - "port": { - "name": "port", - "property": { - "type": "integer" - }, - "sources": { - "default": { - "type": "source-default" - } - } - }, - "voip-enabled": { - "name": "voip-enabled", - "property": { - "type": "boolean" - }, - "sources": { - "default": { - "type": "source-default" - } - } - } -} diff --git a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/default/resource-assignments-simple.json b/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/default/resource-assignments-simple.json deleted file mode 100644 index fc92710a5..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/default/resource-assignments-simple.json +++ /dev/null @@ -1,35 +0,0 @@ -[ - { - "name": "country", - "input-param": true, - "property": { - "type": "string", - "default": "US" - }, - "dictionary-name": "country", - "dictionary-source": "default", - "dependencies": [] - }, - { - "name": "port", - "input-param": true, - "property": { - "type": "integer", - "default": 830 - }, - "dictionary-name": "port", - "dictionary-source": "default", - "dependencies": [] - }, - { - "name": "voip-enabled", - "input-param": true, - "property": { - "type": "boolean", - "default": true - }, - "dictionary-name": "voip-enabled", - "dictionary-source": "default", - "dependencies": [] - } -] diff --git a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/dependency.json b/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/dependency.json deleted file mode 100644 index e08539c0d..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/dependency.json +++ /dev/null @@ -1,110 +0,0 @@ -[ - { - "name": "vnf-id", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "vnf-id", - "dictionary-source": "input", - "dependencies": [] - }, - { - "name": "service-instance-id", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "service-instance-id", - "dictionary-source": "input", - "dependencies": [] - }, - { - "name": "bundle-id", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "bundle-id", - "dictionary-source": "mdsal", - "dependencies": [ - "vnf-id" - ] - }, - { - "name": "bundle-ip", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "bundle-ip", - "dictionary-source": "mdsal", - "dependencies": [ - "vnf-id" - ] - }, - { - "name": "bundle-mac", - "input-param": true, - "property": { - "type": "string" - }, - "dictionary-name": "bundle-mac", - "dictionary-source": "mdsal", - "dependencies": [ - "vnf-id", - "bundle-id" - ] - }, - { - "name": "managed-ip", - "input-param": true, - "property": { - "type": "string" - }, - "dictionary-name": "managed-ip", - "dictionary-source": "mdsal", - "dependencies": [ - "loopback-ip" - ] - }, - { - "name": "vnf-name", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "vnf-name", - "dictionary-source": "input", - "dependencies": [] - }, - { - "name": "managed-ip1", - "input-param": true, - "property": { - "type": "string" - }, - "dictionary-name": "managed-ip1", - "dictionary-source": "mdsal", - "dependencies": [ - "loopback-ip" - ] - }, - { - "name": "loopback-ip", - "input-param": true, - "property": { - "type": "string" - }, - "dictionary-name": "loopback-ip", - "dictionary-source": "db", - "dependencies": [ - "bundle-mac" - ] - } -] diff --git a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/input/dt-location.json b/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/input/dt-location.json deleted file mode 100644 index 52e0a7967..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/input/dt-location.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "version": "1.0.0", - "description": "test Data Type", - "properties": { - "country": { - "required": true, - "type": "string" - }, - "state": { - "required": false, - "type": "string" - } - }, - "derived_from": "tosca.datatypes.Root" -} diff --git a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/input/input-complex.json b/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/input/input-complex.json deleted file mode 100644 index 7eabe440a..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/input/input-complex.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "location": { - "name": "location", - "property": { - "type": "dt-location" - }, - "sources": { - "default": { - "type": "source-input" - } - } - }, - "profile_name": { - "name": "profile_name", - "property": { - "type": "string" - }, - "sources": { - "default": { - "type": "source-input" - } - } - } -} diff --git a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/input/input-simple.json b/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/input/input-simple.json deleted file mode 100644 index 7b663f36a..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/input/input-simple.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "country": { - "name": "country", - "property": { - "type": "string" - }, - "sources": { - "default": { - "type": "source-input" - } - } - }, - "port": { - "name": "port", - "property": { - "type": "integer" - }, - "sources": { - "default": { - "type": "source-input" - } - } - }, - "voip-enabled": { - "name": "voip-enabled", - "property": { - "type": "boolean" - }, - "sources": { - "default": { - "type": "source-input" - } - } - } -} diff --git a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/input/resource-assignments-complex.json b/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/input/resource-assignments-complex.json deleted file mode 100644 index 9e17841b4..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/input/resource-assignments-complex.json +++ /dev/null @@ -1,13 +0,0 @@ -[ - { - "name": "location", - "input-param": true, - "property": { - "type": "dt-location", - "required": true - }, - "dictionary-name": "location", - "dictionary-source": "input", - "dependencies": [] - } -] diff --git a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/input/resource-assignments-simple.json b/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/input/resource-assignments-simple.json deleted file mode 100644 index e3b2bcc06..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/input/resource-assignments-simple.json +++ /dev/null @@ -1,32 +0,0 @@ -[ - { - "name": "country", - "input-param": true, - "property": { - "type": "string", - "default": "US" - }, - "dictionary-source": "input", - "dependencies": [] - }, - { - "name": "port", - "input-param": true, - "property": { - "type": "integer", - "default": 830 - }, - "dictionary-source": "input", - "dependencies": [] - }, - { - "name": "voip-enabled", - "input-param": true, - "property": { - "type": "boolean", - "default": true - }, - "dictionary-source": "input", - "dependencies": [] - } -] diff --git a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/input/sample-location.json b/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/input/sample-location.json deleted file mode 100644 index 2f3f1c102..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/test/resources/mapping/input/sample-location.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "country": "US", - "state": "NJ" -} diff --git a/blueprints-processor/plugin/assignment-provider/src/test/resources/service_templates/input/input.json b/blueprints-processor/plugin/assignment-provider/src/test/resources/service_templates/input/input.json deleted file mode 100644 index cd6fac128..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/test/resources/service_templates/input/input.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "api-ver": "2.00", - "originator-id": "MSO", - "request-id": "123456", - "service-instance-id": "ibcx0001vm001", - "service-type": "AVPN", - "vnf-type": "vUSP - vDBE-IPX HUB", - "vnf-id": 123456, - "service-template-name": "VRR-baseconfiguration", - "service-template-version": "1.0.0", - "action-name": "resource-assignment-action", - "group-name": "sample group name", - "bundle-id": "sample bundle id", - "bundle-mac": [ - "Sample bundle mac", - "Sample bundle mac" - ] -} diff --git a/blueprints-processor/plugin/assignment-provider/src/test/resources/service_templates/input/inputValidateTest.json b/blueprints-processor/plugin/assignment-provider/src/test/resources/service_templates/input/inputValidateTest.json deleted file mode 100644 index 354ca577b..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/test/resources/service_templates/input/inputValidateTest.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "api-ver": "2.00", - "originator-id": "MSO", - "request-id": "123456", - "service-instance-id": "ibcx0001vm001", - "service-type": "AVPN", - "vnf-type": "vUSP - vDBE-IPX HUB", - "vnf-id": "", - "service-template-name": "VRR-baseconfiguration", - "service-template-version": "1.0.0", - "action-name": "resource-assignment-action", - "group-name": "sample group name", - "bundle-id": "sample bundle id", - "bundle-mac": [ - "Sample bundle mac", - "Sample bundle mac" - ] -} diff --git a/blueprints-processor/plugin/assignment-provider/src/test/resources/service_templates/resource_assignment.json b/blueprints-processor/plugin/assignment-provider/src/test/resources/service_templates/resource_assignment.json deleted file mode 100644 index cbea6a82c..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/test/resources/service_templates/resource_assignment.json +++ /dev/null @@ -1,407 +0,0 @@ -{ - "metadata": { - "author": "ks220y@att.com", - "service-template-name": "VRR-baseconfiguration", - "service-template-version": "1.0.0", - "release": "1802", - "service-type": "AVPN", - "vnf-type": "VRR" - }, - "topology_template": { - "inputs": { - "request-id": { - "required": true, - "type": "string" - }, - "service-instance-id": { - "required": true, - "type": "string" - }, - "action-name": { - "required": true, - "type": "string" - }, - "scope-type": { - "required": true, - "type": "string" - }, - "hostname": { - "required": true, - "type": "string" - } - }, - "node_templates": { - "base-config-template": { - "type": "artifact-config-template", - "properties": { - "action-names": [ - "resource-assignment-action" - ] - }, - "capabilities": { - "content": { - "properties": { - "content": "db://base-config-template" - } - }, - "mapping": { - "properties": { - "mapping": [ - { - "name": "vnf-id", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "vnf-id", - "dictionary-source": "input" - }, - { - "name": "group-name", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "group-name", - "dictionary-source": "input" - } - ] - } - } - } - }, - "resource-assignment-action": { - "type": "dg-resource-assignment", - "interfaces": { - "CONFIG": { - "operations": { - "ResourceAssignment": { - - } - } - } - }, - "capabilities": { - "dg-node": { - - } - }, - "requirements": { - "component-dependency": { - "capability": "component-node", - "node": "resource-assignment", - "relationship": "tosca.relationships.DependsOn" - } - } - }, - "licence-template": { - "type": "artifact-config-template", - "properties": { - "action-names": [ - "resource-assignment-action" - ] - }, - "capabilities": { - "content": { - "properties": { - "content": "db://licence-template" - } - }, - "mapping": { - "properties": { - "mapping": [ - { - "name": "bundle-id", - "input-param": true, - "property": { - "type": "string" - }, - "dictionary-name": "bundle-id", - "dictionary-source": "input" - }, - { - "name": "bundle-mac", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "bundle-mac", - "dictionary-source": "input" - } - ] - } - } - } - }, - "resource-assignment": { - "type": "component-resource-assignment", - "interfaces": { - "org-onap-ccsdk-features-assignment-service-ConfigAssignmentNode": { - "operations": { - "process": { - "inputs": { - "action-name": "{ \"get_input\" : \"action-name\" }", - "resource-type": "vnf-type", - "template-names": [ - "base-config-template", - "licence-template" - ], - "request-id": "{ \"get_input\" : \"request-id\" }", - "resource-id": "{ \"get_input\" : \"vnf-id\" }" - }, - "outputs": { - "resource-assignment-params": "", - "status": "" - } - } - } - } - }, - "capabilities": { - "component-node": { - - } - } - } - } - }, - "node_types": { - "dg-resource-assignment": { - "description": "This is Resource Assignment Directed Graph", - "version": "1.0.0", - "properties": { - "mode": { - "required": false, - "type": "string", - "default": "sync" - }, - "version": { - "required": false, - "type": "string", - "default": "LATEST" - }, - "is-start-flow": { - "required": false, - "type": "boolean", - "default": "false" - } - }, - "capabilities": { - "dg-node": { - "type": "tosca.capabilities.Node" - }, - "content": { - "type": "tosca.capabilities.Content", - "properties": { - "type": { - "required": false, - "type": "string", - "default": "json" - }, - "content": { - "required": true, - "type": "string" - } - } - } - }, - "requirements": { - "component-dependency": { - "capability": "component-node", - "node": "component-resource-assignment", - "relationship": "tosca.relationships.DependsOn" - } - }, - "interfaces": { - "CONFIG": { - "operations": { - "ResourceAssignment": { - "inputs": { - "params": { - "required": false, - "type": "list", - "entry_schema": { - "type": "datatype-property" - } - } - } - } - } - } - }, - "derived_from": "tosca.nodes.DG" - }, - "component-resource-assignment": { - "description": "This is Resource Assignment Component API", - "version": "1.0.0", - "capabilities": { - "component-node": { - "type": "tosca.capabilities.Node" - } - }, - "interfaces": { - "org-onap-ccsdk-features-assignment-service-ConfigAssignmentNode": { - "operations": { - "process": { - "inputs": { - "action-name": { - "description": "Action Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority", - "required": false, - "type": "string" - }, - "handler-name": { - "description": "Name of the Artifact Node Template, to get the template Content. If template-content is present, then content wont be reterived from the Artifact Node Template.", - "required": true, - "type": "string" - }, - "resource-type": { - "required": false, - "type": "string" - }, - "template-names": { - "description": "Name of the Artifact Node Templates, to get the template Content.", - "required": true, - "type": "list", - "entry_schema": { - "type": "string" - } - }, - "request-id": { - "description": "Request Id used to store the generated configuration, in the database along with the template-name", - "required": true, - "type": "string" - }, - "resource-id": { - "description": "Id used to pull the data content from the data base. Either template-data or resource-id should be present", - "required": true, - "type": "string" - } - }, - "outputs": { - "resource-assignment-params": { - "required": true, - "type": "string" - }, - "status": { - "required": true, - "type": "string" - } - } - } - } - } - }, - "derived_from": "tosca.nodes.Component" - }, - "artifact-config-template": { - "description": "This is Configuration Velocity Template", - "version": "1.0.0", - "properties": { - "action-names": { - "required": true, - "type": "list", - "entry_schema": { - "type": "string" - } - }, - "content": { - "required": false, - "type": "string" - }, - "mapping": { - "required": false, - "type": "list", - "entry_schema": { - "type": "datatype-resource-assignment" - } - } - }, - "capabilities": { - "content": { - "type": "tosca.capabilities.Content", - "properties": { - "content": { - "required": true, - "type": "string" - } - } - }, - "mapping": { - "type": "tosca.capabilities.Mapping", - "properties": { - "mapping": { - "required": false, - "type": "list", - "entry_schema": { - "type": "datatype-resource-assignment" - } - } - } - } - }, - "derived_from": "tosca.nodes.Artifact" - } - }, - "data_types": { - "datatype-resource-assignment": { - "version": "1.0.0", - "description": "This is Resource Assignment Data Type", - "properties": { - "property": { - "required": true, - "type": "datatype-property" - }, - "input-param": { - "required": true, - "type": "boolean" - }, - "dictionary-name": { - "required": false, - "type": "string" - }, - "dictionary-source": { - "required": false, - "type": "string" - }, - "dependencies": { - "required": true, - "type": "list", - "entry_schema": { - "type": "string" - } - } - }, - "derived_from": "tosca.datatypes.Root" - }, - "datatype-property": { - "version": "1.0.0", - "description": "This is Entry point Input Data Type, which is dynamic datatype, The parameter names will be populated during the Design time for each inputs", - "properties": { - "type": { - "required": true, - "type": "string" - }, - "description": { - "required": false, - "type": "string" - }, - "required": { - "required": false, - "type": "boolean" - }, - "default": { - "required": false, - "type": "string" - }, - "entry_schema": { - "required": false, - "type": "string" - } - }, - "derived_from": "tosca.datatypes.Root" - } - } -} diff --git a/blueprints-processor/plugin/assignment-provider/src/test/resources/service_templates/resource_assignment/resource_assignment.json b/blueprints-processor/plugin/assignment-provider/src/test/resources/service_templates/resource_assignment/resource_assignment.json deleted file mode 100644 index 4cbb8fa25..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/test/resources/service_templates/resource_assignment/resource_assignment.json +++ /dev/null @@ -1,417 +0,0 @@ -{ - "metadata": { - "author": "ks220y@att.com", - "service-template-name": "VRR-baseconfiguration", - "service-template-version": "1.0.0", - "release": "1802", - "service-type": "AVPN", - "vnf-type": "VRR" - }, - "topology_template": { - "inputs": { - "request-id": { - "required": true, - "type": "string" - }, - "service-instance-id": { - "required": true, - "type": "string" - }, - "action-name": { - "required": true, - "type": "string" - }, - "scope-type": { - "required": true, - "type": "string" - }, - "hostname": { - "required": true, - "type": "string" - } - }, - "node_templates": { - "base-config-template": { - "type": "artifact-config-template", - "properties": { - "action-names": [ - "resource-assignment-action" - ] - }, - "capabilities": { - "content": { - "properties": { - "content": "db://base-config-template" - } - }, - "mapping": { - "properties": { - "mapping": [ - { - "name": "vnf-id", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "vnf-id", - "dictionary-source": "input" - }, - { - "name": "group-name", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "group-name", - "dictionary-source": "input" - } - ] - } - } - } - }, - "resource-assignment-action": { - "type": "dg-resource-assignment", - "interfaces": { - "CONFIG": { - "operations": { - "ResourceAssignment": { - - } - } - } - }, - "capabilities": { - "dg-node": { - - } - }, - "requirements": { - "component-dependency": { - "capability": "component-node", - "node": "resource-assignment", - "relationship": "tosca.relationships.DependsOn" - } - } - }, - "licence-template": { - "type": "artifact-config-template", - "properties": { - "action-names": [ - "resource-assignment-action" - ] - }, - "capabilities": { - "content": { - "properties": { - "content": "db://licence-template" - } - }, - "mapping": { - "properties": { - "mapping": [ - { - "name": "bundle-id", - "input-param": true, - "property": { - "type": "string" - }, - "dictionary-name": "bundle-id", - "dictionary-source": "input" - }, - { - "name": "bundle-mac", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "bundle-mac", - "dictionary-source": "input" - } - ] - } - } - } - }, - "resource-assignment": { - "type": "component-resource-assignment", - "interfaces": { - "org-onap-ccsdk-features-assignment-service-ConfigAssignmentNode": { - "operations": { - "process": { - "inputs": { - "service-template-name": "VRR-baseconfiguration", - "service-template-version": "1.0.0", - "action-name": "{ \"get_input\" : \"action-name\" }", - "resource-type": "vnf-type", - "template-names": [ - "base-config-template", - "licence-template" - ], - "request-id": "{ \"get_input\" : \"request-id\" }", - "resource-id": "{ \"get_input\" : \"vnf-id\" }" - }, - "outputs": { - "resource-assignment-params": "", - "status": "" - } - } - } - } - }, - "capabilities": { - "component-node": { - - } - } - } - } - }, - "node_types": { - "dg-resource-assignment": { - "description": "This is Resource Assignment Directed Graph", - "version": "1.0.0", - "properties": { - "mode": { - "required": false, - "type": "string", - "default": "sync" - }, - "version": { - "required": false, - "type": "string", - "default": "LATEST" - }, - "is-start-flow": { - "required": false, - "type": "boolean", - "default": "false" - } - }, - "capabilities": { - "dg-node": { - "type": "tosca.capabilities.Node" - }, - "content": { - "type": "tosca.capabilities.Content", - "properties": { - "type": { - "required": false, - "type": "string", - "default": "json" - }, - "content": { - "required": true, - "type": "string" - } - } - } - }, - "requirements": { - "component-dependency": { - "capability": "component-node", - "node": "component-resource-assignment", - "relationship": "tosca.relationships.DependsOn" - } - }, - "interfaces": { - "CONFIG": { - "operations": { - "ResourceAssignment": { - "inputs": { - "params": { - "required": false, - "type": "list", - "entry_schema": { - "type": "datatype-property" - } - } - } - } - } - } - }, - "derived_from": "tosca.nodes.DG" - }, - "component-resource-assignment": { - "description": "This is Resource Assignment Component API", - "version": "1.0.0", - "capabilities": { - "component-node": { - "type": "tosca.capabilities.Node" - } - }, - "interfaces": { - "org-onap-ccsdk-features-assignment-service-ConfigAssignmentNode": { - "operations": { - "process": { - "inputs": { - "action-name": { - "description": "Action Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority", - "required": false, - "type": "string" - }, - "handler-name": { - "description": "Name of the Artifact Node Template, to get the template Content. If template-content is present, then content wont be reterived from the Artifact Node Template.", - "required": true, - "type": "string" - }, - "resource-type": { - "required": false, - "type": "string" - }, - "service-template-name": { - "required": true, - "type": "string" - }, - "service-template-version": { - "required": true, - "type": "string" - }, - "template-names": { - "description": "Name of the Artifact Node Templates, to get the template Content.", - "required": true, - "type": "list", - "entry_schema": { - "type": "string" - } - }, - "request-id": { - "description": "Request Id used to store the generated configuration, in the database along with the template-name", - "required": true, - "type": "string" - }, - "resource-id": { - "description": "Id used to pull the data content from the data base. Either template-data or resource-id should be present", - "required": true, - "type": "string" - } - }, - "outputs": { - "resource-assignment-params": { - "required": true, - "type": "string" - }, - "status": { - "required": true, - "type": "string" - } - } - } - } - } - }, - "derived_from": "tosca.nodes.Component" - }, - "artifact-config-template": { - "description": "This is Configuration Velocity Template", - "version": "1.0.0", - "properties": { - "action-names": { - "required": true, - "type": "list", - "entry_schema": { - "type": "string" - } - }, - "content": { - "required": false, - "type": "string" - }, - "mapping": { - "required": false, - "type": "list", - "entry_schema": { - "type": "datatype-resource-assignment" - } - } - }, - "capabilities": { - "content": { - "type": "tosca.capabilities.Content", - "properties": { - "content": { - "required": true, - "type": "string" - } - } - }, - "mapping": { - "type": "tosca.capabilities.Mapping", - "properties": { - "mapping": { - "required": false, - "type": "list", - "entry_schema": { - "type": "datatype-resource-assignment" - } - } - } - } - }, - "derived_from": "tosca.nodes.Artifact" - } - }, - "data_types": { - "datatype-resource-assignment": { - "version": "1.0.0", - "description": "This is Resource Assignment Data Type", - "properties": { - "property": { - "required": true, - "type": "datatype-property" - }, - "input-param": { - "required": true, - "type": "boolean" - }, - "dictionary-name": { - "required": false, - "type": "string" - }, - "dictionary-source": { - "required": false, - "type": "string" - }, - "dependencies": { - "required": true, - "type": "list", - "entry_schema": { - "type": "string" - } - } - }, - "derived_from": "tosca.datatypes.Root" - }, - "datatype-property": { - "version": "1.0.0", - "description": "This is Entry point Input Data Type, which is dynamic datatype, The parameter names will be populated during the Design time for each inputs", - "properties": { - "type": { - "required": true, - "type": "string" - }, - "description": { - "required": false, - "type": "string" - }, - "required": { - "required": false, - "type": "boolean" - }, - "default": { - "required": false, - "type": "string" - }, - "entry_schema": { - "required": false, - "type": "string" - } - }, - "derived_from": "tosca.datatypes.Root" - } - } -} diff --git a/blueprints-processor/plugin/assignment-provider/src/test/resources/service_templates/resource_assignment/velocity/base-config-template.vtl b/blueprints-processor/plugin/assignment-provider/src/test/resources/service_templates/resource_assignment/velocity/base-config-template.vtl deleted file mode 100644 index 92dba1024..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/test/resources/service_templates/resource_assignment/velocity/base-config-template.vtl +++ /dev/null @@ -1,40 +0,0 @@ - - - - ${group-name} - - - <*> - - - - - - 224.0.1.40/32 - - - 224.0.1.39/32 - - - 224.0.0.0/4 - - - - - - - - - - <*> - - 1000 - - - - - - - - - \ No newline at end of file diff --git a/blueprints-processor/plugin/assignment-provider/src/test/resources/service_templates/vpe-201802-baseconfig/dict.json b/blueprints-processor/plugin/assignment-provider/src/test/resources/service_templates/vpe-201802-baseconfig/dict.json deleted file mode 100644 index f7b09d5af..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/test/resources/service_templates/vpe-201802-baseconfig/dict.json +++ /dev/null @@ -1,172 +0,0 @@ -[ - { - "name": "adiod-unicast-route-reflectors", - "resourcePath": "vnf/protocol/adiod-unicast-route-reflectors", - "resourceType": "ATT", - "dataType": "list", - "entrySchema": "dt-adiod-unicast-route-reflectors", - "definition": "{\r\n \"tags\" : \"ADIOD3\",\r\n \"name\" : \"adiod-unicast-route-reflectors\",\r\n \"description\" : \"dd\",\r\n \"updated-by\" : \"ks220y@att.com\",\r\n \"resource-type\" : \"ATT\",\r\n \"resource-path\" : \"vnf/protocol/adiod-unicast-route-reflectors\",\r\n \"data-type\" : \"list\",\r\n \"entry-schema\" : \"dt-adiod-unicast-route-reflectors\",\r\n \"source\" : {\r\n \"input\" : { },\r\n \"network-resource-discovery\" : {\r\n \"input-key-mapping\" : {\r\n \"complex-code-char8\" : \"complex-code-char8\"\r\n },\r\n \"output-key-mapping\" : {\r\n \"adiod-unicast-route-reflectors\" : \"adiod-unicast-route-reflectors\"\r\n }\r\n }\r\n },\r\n \"candidate-dependency\" : {\r\n \"network-resource-discovery\" : {\r\n \"names\" : [ \"complex-code-char8\" ]\r\n }\r\n }\r\n}", - "description": "dd", - "tags": "ADIOD3", - "creationDate": "2017-11-16T17:31:38.000+0000", - "updatedBy": "ks220y@att.com" - }, - { - "name": "adiod-vpnv4-route-reflectors", - "resourcePath": "vnf/servers/adiod-vpnv4-route-reflectors", - "resourceType": "ATT", - "dataType": "list", - "entrySchema": "dt-adiod-vpnv4-route-reflectors", - "definition": "{\r\n \"tags\" : \"ADIOD3\",\r\n \"name\" : \"adiod-vpnv4-route-reflectors\",\r\n \"description\" : \"To be provided\",\r\n \"updated-by\" : \"ks220y@att.com\",\r\n \"resource-type\" : \"ATT\",\r\n \"resource-path\" : \"vnf/servers/adiod-vpnv4-route-reflectors\",\r\n \"data-type\" : \"list\",\r\n \"entry-schema\" : \"dt-adiod-vpnv4-route-reflectors\",\r\n \"source\" : {\r\n \"input\" : { }\r\n }\r\n}", - "description": "To be provided", - "tags": "ADIOD3", - "creationDate": "2017-11-16T17:31:38.000+0000", - "updatedBy": "ks220y@att.com" - }, - { - "name": "asn-region", - "resourcePath": "vnf/protocols/asn-region", - "resourceType": "ATT", - "dataType": "string", - "definition": "{\r\n \"tags\" : \"ADIOD3\",\r\n \"name\" : \"asn-region\",\r\n \"description\" : \"To be provided\",\r\n \"updated-by\" : \"ks220y@att.com\",\r\n \"resource-type\" : \"ATT\",\r\n \"resource-path\" : \"vnf/protocols/asn-region\",\r\n \"data-type\" : \"string\",\r\n \"source\" : {\r\n \"input\" : { },\r\n \"network-resource-discovery\" : {\r\n \"input-key-mapping\" : {\r\n \"hostname\" : \"hostname\"\r\n },\r\n \"output-key-mapping\" : {\r\n \"asn-region\" : \"asn-region\"\r\n }\r\n }\r\n },\r\n \"candidate-dependency\" : {\r\n \"network-resource-discovery\" : {\r\n \"names\" : [ \"hostname\" ]\r\n }\r\n }\r\n}", - "description": "To be provided", - "tags": "ADIOD3", - "creationDate": "2017-11-17T11:31:29.000+0000", - "updatedBy": "ks220y@att.com" - }, - { - "name": "bundle-id", - "resourcePath": "vnf/interface/bundle-id", - "resourceType": "ATT", - "dataType": "string", - "definition": "{\r\n \"tags\" : \"ADIOD3\",\r\n \"name\" : \"bundle-id\",\r\n \"description\" : \"To be provided\",\r\n \"updated-by\" : \"ks220y@att.com\",\r\n \"resource-type\" : \"ATT\",\r\n \"resource-path\" : \"vnf/interface/bundle-id\",\r\n \"data-type\" : \"string\",\r\n \"source\" : {\r\n \"input\" : { },\r\n \"network-resource-discovery\" : {\r\n \"input-key-mapping\" : {\r\n \"hostname\" : \"hostname\"\r\n },\r\n \"output-key-mapping\" : {\r\n \"bundle-id\" : \"bundle-id\"\r\n }\r\n }\r\n },\r\n \"candidate-dependency\" : {\r\n \"network-resource-discovery\" : {\r\n \"names\" : [ \"hostname\" ]\r\n }\r\n }\r\n}", - "description": "To be provided", - "tags": "ADIOD3", - "creationDate": "2017-11-16T17:31:39.000+0000", - "updatedBy": "ks220y@att.com" - }, - { - "name": "lo0-local-ipv4-address", - "resourcePath": "vnf/interface/lo0-local-ipv4", - "resourceType": "ATT", - "dataType": "ipv4-address", - "definition": "{\r\n \"tags\" : \"ADIOD3\",\r\n \"name\" : \"lo0-local-ipv4-address\",\r\n \"description\" : \"To be provided\",\r\n \"updated-by\" : \"ks220y@att.com\",\r\n \"resource-type\" : \"ATT\",\r\n \"resource-path\" : \"vnf/interface/lo0-local-ipv4\",\r\n \"data-type\" : \"string\",\r\n \"source\" : {\r\n \"input\" : { },\r\n \"network-resource-discovery\" : {\r\n \"input-key-mapping\" : {\r\n \"hostname\" : \"hostname\"\r\n },\r\n \"output-key-mapping\" : {\r\n \"lo0-local-ipv4\" : \"lo0-local-ipv4\"\r\n }\r\n }\r\n },\r\n \"candidate-dependency\" : {\r\n \"network-resource-discovery\" : {\r\n \"names\" : [ \"hostname\" ]\r\n }\r\n }\r\n}", - "description": "To be provided", - "tags": "ADIOD3", - "creationDate": "2017-11-16T17:31:40.000+0000", - "updatedBy": "ks220y@att.com" - }, - { - "name": "lo10-local-ipv4-address", - "resourcePath": "vnf/interface/lo10-local-ipv4", - "resourceType": "ATT", - "dataType": "ipv4-address", - "definition": "{\r\n \"tags\" : \"ADIOD3\",\r\n \"name\" : \"lo10-local-ipv4-address\",\r\n \"description\" : \"To be provided\",\r\n \"updated-by\" : \"ks220y@att.com\",\r\n \"resource-type\" : \"ATT\",\r\n \"resource-path\" : \"vnf/interface/lo10-local-ipv4\",\r\n \"data-type\" : \"string\",\r\n \"source\" : {\r\n \"input\" : { },\r\n \"network-resource-discovery\" : {\r\n \"input-key-mapping\" : {\r\n \"hostname\" : \"hostname\"\r\n },\r\n \"output-key-mapping\" : {\r\n \"lo10-local-ipv4\" : \"lo10-local-ipv4\"\r\n }\r\n }\r\n },\r\n \"candidate-dependency\" : {\r\n \"network-resource-discovery\" : {\r\n \"names\" : [ \"hostname\" ]\r\n }\r\n }\r\n}", - "description": "To be provided", - "tags": "ADIOD3", - "creationDate": "2017-11-16T17:31:41.000+0000", - "updatedBy": "ks220y@att.com" - }, - { - "name": "oam-remote-ipv4-address", - "resourcePath": "vnf/oam-remote-ipv4-address", - "resourceType": "ATT", - "dataType": "string", - "definition": "{\r\n \"tags\" : \"ADIOD3\",\r\n \"name\" : \"oam-remote-ipv4-address\",\r\n \"description\" : \"To be provided\",\r\n \"updated-by\" : \"ks220y@att.com\",\r\n \"resource-type\" : \"ATT\",\r\n \"resource-path\" : \"vnf/oam-remote-ipv4-address\",\r\n \"data-type\" : \"string\",\r\n \"source\" : {\r\n \"input\" : {\r\n \"key\" : \"oam-remote-ipv4-address\"\r\n },\r\n \"mdsal\" : {\r\n \"base\" : \"sdnc-gc\",\r\n \"type\" : \"JSON\",\r\n \"url-path\" : \"/restconf/config/L3VNF-API\",\r\n \"path\" : \"/${services/service-list/$service-instance-id/service-data/vnf-topology-information/vnf-assignments/vnf-vms/$oam-ipv4-ip-type/vm-networks/$oam-network-role/v4-assigned-ip-list/$oam-vm-type\",\r\n \"input-key-mapping\" : {\r\n \"service-instance-id\" : \"service-instance-id\",\r\n \"oam-network-role\" : \"oam-network-role\",\r\n \"oam-ipv4-ip-type\" : \"oam-ipv4-ip-type\",\r\n \"oam-vm-type\" : \"oam-vm-type\"\r\n },\r\n \"output-key-mapping\" : {\r\n \"oam-remote-ipv4-address\" : \"ipv4-gateway-prefix\"\r\n }\r\n }\r\n },\r\n \"candidate-dependency\" : {\r\n \"mdsal\" : {\r\n \"names\" : [ \"service-instance-id\", \"oam-network-role\", \"oam-v4-ip-type \", \"oam-vm-type\" ]\r\n }\r\n }\r\n}", - "description": "To be provided", - "tags": "ADIOD3", - "creationDate": "2017-11-16T10:52:24.000+0000", - "updatedBy": "ks220y@att.com" - }, - { - "name": "ospf-area", - "resourcePath": "/ospf-area", - "resourceType": "ATT", - "dataType": "string", - "definition": "{\r\n \"tags\" : \"ADIOD3\",\r\n \"name\" : \"ospf-area\",\r\n \"description\" : \"ospf-area\",\r\n \"updated-by\" : \"ks220y@att.com\",\r\n \"resource-type\" : \"ATT\",\r\n \"resource-path\" : \"/ospf-area\",\r\n \"data-type\" : \"string\",\r\n \"source\" : {\r\n \"input\" : {\r\n \"key\" : \"ospf-area\"\r\n },\r\n \"network-resource-discovery\" : {\r\n \"input-key-mapping\" : {\r\n \"hostname\" : \"mainResource\"\r\n },\r\n \"output-key-mapping\" : {\r\n \"ospf-area\" : \"ospf-area\"\r\n }\r\n }\r\n }\r\n}", - "description": "ospf-area", - "tags": "ADIOD3", - "creationDate": "2017-11-16T10:52:24.000+0000", - "updatedBy": "ks220y@att.com" - }, - { - "name": "ospf-cost", - "resourcePath": "/ospf-cost", - "resourceType": "ATT", - "dataType": "string", - "definition": "{\r\n \"tags\" : \"ADIOD3\",\r\n \"name\" : \"ospf-cost\",\r\n \"description\" : \"ospf-cost\",\r\n \"updated-by\" : \"ks220y@att.com\",\r\n \"resource-type\" : \"ATT\",\r\n \"resource-path\" : \"/ospf-cost\",\r\n \"data-type\" : \"string\",\r\n \"source\" : {\r\n \"input\" : {\r\n \"key\" : \"ospf-cost\"\r\n },\r\n \"network-resource-discovery\" : {\r\n \"input-key-mapping\" : {\r\n \"hostname\" : \"mainResource\"\r\n },\r\n \"output-key-mapping\" : {\r\n \"ospf-cost\" : \"ospf-cost\"\r\n }\r\n }\r\n }\r\n}", - "description": "ospf-cost", - "tags": "ADIOD3", - "creationDate": "2017-11-16T10:52:25.000+0000", - "updatedBy": "ks220y@att.com" - }, - { - "name": "si-local-ipv4-address", - "resourcePath": "vnf/interface/si-local-ipv4", - "resourceType": "ATT", - "dataType": "string", - "definition": "{\r\n \"tags\" : \"ADIOD3\",\r\n \"name\" : \"si-local-ipv4-address\",\r\n \"description\" : \"To be provided\",\r\n \"updated-by\" : \"ks220y@att.com\",\r\n \"resource-type\" : \"ATT\",\r\n \"resource-path\" : \"vnf/interface/si-local-ipv4\",\r\n \"data-type\" : \"string\",\r\n \"source\" : {\r\n \"input\" : { },\r\n \"network-resource-discovery\" : {\r\n \"input-key-mapping\" : {\r\n \"hostname\" : \"hostname\"\r\n },\r\n \"output-key-mapping\" : {\r\n \"si-local-ipv4\" : \"si-local-ipv4\"\r\n }\r\n }\r\n },\r\n \"candidate-dependency\" : {\r\n \"network-resource-discovery\" : {\r\n \"names\" : [ \"hostname\" ]\r\n }\r\n }\r\n}", - "description": "To be provided", - "tags": "ADIOD3", - "creationDate": "2017-11-16T10:52:25.000+0000", - "updatedBy": "ks220y@att.com" - }, - { - "name": "tacacs-server-ipv4-addresses", - "resourcePath": "vnf/servers/tacacs-server-ipv4-addresses", - "resourceType": "ATT", - "dataType": "list", - "entrySchema": "dt-tacacs-server-ipv4-addresses", - "definition": "{\r\n \"tags\" : \"ADIOD3\",\r\n \"name\" : \"tacacs-server-ipv4-addresses\",\r\n \"description\" : \"to be provided\",\r\n \"updated-by\" : \"ks220y@att.com\",\r\n \"resource-type\" : \"ATT\",\r\n \"resource-path\" : \"vnf/servers/tacacs-server-ipv4-addresses\",\r\n \"data-type\" : \"list\",\r\n \"entry-schema\" : \"dt-tacacs-server-ipv4-addresses\",\r\n \"source\" : {\r\n \"input\" : { },\r\n \"network-resource-discovery\" : {\r\n \"input-key-mapping\" : {\r\n \"region\" : \"region\",\r\n \"complex-code-char8\" : \"complex-code-char8\",\r\n \"tacacs-domain-name\" : \"tacacs-domain-name\"\r\n },\r\n \"output-key-mapping\" : {\r\n \"tacacs-server-ipv4-addresses\" : \"tacacs-server-ipv4-addresses\"\r\n }\r\n }\r\n },\r\n \"candidate-dependency\" : {\r\n \"network-resource-discovery\" : {\r\n \"names\" : [ \"region\", \"complex-code-char8\", \"tacacs-domain-name\" ]\r\n }\r\n }\r\n}", - "description": "to be provided", - "tags": "ADIOD3", - "creationDate": "2017-11-16T17:31:43.000+0000", - "updatedBy": "ks220y@att.com" - }, - { - "name": "uplink-1-unit", - "resourcePath": "vnf/interface/uplink-1-unit", - "resourceType": "ATT", - "dataType": "string", - "definition": "{\r\n \"tags\" : \"ADIOD3\",\r\n \"name\" : \"uplink-1-unit\",\r\n \"description\" : \"To be provided\",\r\n \"updated-by\" : \"ks220y@att.com\",\r\n \"resource-type\" : \"ATT\",\r\n \"resource-path\" : \"vnf/interface/uplink-1-unit\",\r\n \"data-type\" : \"string\",\r\n \"source\" : {\r\n \"input\" : { },\r\n \"network-resource-discovery\" : {\r\n \"input-key-mapping\" : {\r\n \"hostname\" : \"hostname\"\r\n },\r\n \"output-key-mapping\" : {\r\n \"uplink-1-unit\" : \"uplink-1-unit\"\r\n }\r\n }\r\n },\r\n \"candidate-dependency\" : {\r\n \"network-resource-discovery\" : {\r\n \"names\" : [ \"hostname\" ]\r\n }\r\n }\r\n}", - "description": "To be provided", - "tags": "ADIOD3", - "creationDate": "2017-11-16T17:31:44.000+0000", - "updatedBy": "ks220y@att.com" - }, - { - "name": "uplink-2-unit", - "resourcePath": "vnf/interface/uplink-2-unit", - "resourceType": "ATT", - "dataType": "string", - "definition": "{\r\n \"tags\" : \"ADIOD3\",\r\n \"name\" : \"uplink-2-unit\",\r\n \"description\" : \"To be provided\",\r\n \"updated-by\" : \"ks220y@att.com\",\r\n \"resource-type\" : \"ATT\",\r\n \"resource-path\" : \"vnf/interface/uplink-2-unit\",\r\n \"data-type\" : \"string\",\r\n \"source\" : {\r\n \"input\" : { },\r\n \"network-resource-discovery\" : {\r\n \"input-key-mapping\" : {\r\n \"hostname\" : \"hostname\"\r\n },\r\n \"output-key-mapping\" : {\r\n \"uplink-2-unit\" : \"uplink-2-unit\"\r\n }\r\n }\r\n },\r\n \"candidate-dependency\" : {\r\n \"network-resource-discovery\" : {\r\n \"names\" : [ \"hostname\" ]\r\n }\r\n }\r\n}", - "description": "To be provided", - "tags": "ADIOD3", - "creationDate": "2017-11-16T17:31:45.000+0000", - "updatedBy": "ks220y@att.com" - }, - { - "name": "wan-aggregate-ipv4-addresses", - "resourcePath": "vnf/wan-aggregate-ipv4-addresses", - "resourceType": "ATT", - "dataType": "list", - "entrySchema": "dt-v4-aggregate", - "definition": "{\r\n \"tags\" : \"wan-aggregate-ipv4-addresses, tosca.datatypes.Root, data_type, ks220y@att.com\",\r\n \"name\" : \"wan-aggregate-ipv4-addresses\",\r\n \"description\" : \"To be provided\",\r\n \"updated-by\" : \"ks220y@att.com\",\r\n \"resource-type\" : \"ATT\",\r\n \"resource-path\" : \"vnf/wan-aggregate-ipv4-addresses\",\r\n \"data-type\" : \"list\",\r\n \"entry-schema\" : \"dt-v4-aggregate\",\r\n \"source\" : {\r\n \"input\" : { },\r\n \"mdsal\" : {\r\n \"base\" : \"sdnc-gc\",\r\n \"type\" : \"JSON\",\r\n \"url-path\" : \"/restconf/config/L3VNF-API\",\r\n \"path\" : \"/${services/service-list/$service-instance-id/service-data/vnf-topology-information/vnf-assignments/vnf-vms/$oam-ipv4-ip-type/vm-networks/$oam-network-role/v4-assigned-ip-list/$oam-vm-type\",\r\n \"input-key-mapping\" : {\r\n \"service-instance-id\" : \"service-instance-id\",\r\n \"oam-network-role\" : \"oam-network-role\",\r\n \"oam-ipv4-ip-type\" : \"oam-ipv4-ip-type\",\r\n \"oam-vm-type\" : \"oam-vm-type\"\r\n },\r\n \"output-key-mapping\" : {\r\n \"wan-aggregate-ipv4-addresses\" : \"v4-ip-prefix-length\"\r\n }\r\n }\r\n },\r\n \"candidate-dependency\" : {\r\n \"mdsal\" : {\r\n \"names\" : [ \"service-instance-id\", \"oam-network-role\", \"oam-v4-ip-type \", \"oam-vm-type\" ]\r\n }\r\n }\r\n}", - "description": "To be provided", - "tags": "wan-aggregate-ipv4-addresses, tosca.datatypes.Root, data_type, ks220y@att.com", - "creationDate": "2017-11-16T17:31:45.000+0000", - "updatedBy": "ks220y@att.com" - }, - { - "name": "wan-aggregate-ipv6-addresses", - "resourcePath": "vnf/wan-aggregate-ipv6-addresses", - "resourceType": "ATT", - "dataType": "list", - "entrySchema": "dt-v6-aggregate", - "definition": "{\r\n \"tags\" : \"ADIOD3\",\r\n \"name\" : \"wan-aggregate-ipv6-addresses\",\r\n \"description\" : \"To be provided\",\r\n \"updated-by\" : \"ks220y@att.com\",\r\n \"resource-type\" : \"ATT\",\r\n \"resource-path\" : \"vnf/wan-aggregate-ipv6-addresses\",\r\n \"data-type\" : \"list\",\r\n \"entry-schema\" : \"dt-v6-aggregate\",\r\n \"source\" : {\r\n \"input\" : { },\r\n \"mdsal\" : {\r\n \"base\" : \"sdnc-gc\",\r\n \"type\" : \"JSON\",\r\n \"url-path\" : \"/restconf/config/L3VNF-API\",\r\n \"path\" : \"/${services/service-list/$service-instance-id/service-data/vnf-topology-information/vnf-assignments/vnf-vms/VCO\",\r\n \"input-key-mapping\" : {\r\n \"service-instance-id\" : \"service-instance-id\",\r\n \"oam-network-role\" : \"oam-network-role\",\r\n \"oam-ipv4-ip-type\" : \"oam-ipv4-ip-type\",\r\n \"oam-vm-type\" : \"oam-vm-type\"\r\n },\r\n \"output-key-mapping\" : {\r\n \"wan-aggregate-ipv6.addresses\" : \"v4-ip-prefix-length\"\r\n }\r\n }\r\n },\r\n \"candidate-dependency\" : {\r\n \"mdsal\" : {\r\n \"names\" : [ \"service-instance-id\", \"oam-network-role\", \"oam-v4-ip-type \", \"oam-vm-type\" ]\r\n }\r\n }\r\n}", - "description": "To be provided", - "tags": "ADIOD3", - "creationDate": "2017-11-16T17:31:46.000+0000", - "updatedBy": "ks220y@att.com" - } -] diff --git a/blueprints-processor/plugin/assignment-provider/src/test/resources/service_templates/vpe-201802-baseconfig/input-complex.json b/blueprints-processor/plugin/assignment-provider/src/test/resources/service_templates/vpe-201802-baseconfig/input-complex.json deleted file mode 100644 index 70865015c..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/test/resources/service_templates/vpe-201802-baseconfig/input-complex.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "request-id": "1234", - "service-instance-id": "adsfdsf", - "action-name": "resource-assignment-action", - "scope-type": "vnf-type", - "hostname": "sample-host", - "resource-assignment-request": { - "uplink-2-unit": "sample-uplink-2-unit", - "bundle-mac": "sample-bundle-mac", - "wan-aggregate-ipv6-addresses": [ - { - "v6-address": "sample-v6-address", - "v6-plen": "sample-v6-plen" - } - ], - "ospf-area": "sample-ospf-area", - "ospf-cost": 10.0, - "bundle-id": "bundle-id", - "adiod-unicast-route-reflectors": [ - { - "v4-address": "sample-v4-address", - "name": "sample-name" - } - ], - "oam-remote-ipv4-address": "", - "adiod-vpnv4-route-reflectors": [ - { - "v4-address": "sample-v4-address", - "name": "sample-name" - } - ], - "lo10-local-ipv4-address": "sample-lo10-local-ipv4-address", - "wan-aggregate-ipv4-addresses": [ - { - "v4-address": "sample-v4-address", - "v4-plen": 0 - } - ], - "lo0-local-ipv4-address": "sample-lo0-local-ipv4-address", - "uplink-1-unit": "sample-uplink-1-unit", - "tacacs-server-ipv4-addresses": [ - { - "tacacs-server-ipv4-address": "sample-tacacs-server-ipv4-address" - } - ], - "asn-region": "sample-asn-region", - "si-local-ipv4-address": "sample-si-local-ipv4-address" - } -} diff --git a/blueprints-processor/plugin/assignment-provider/src/test/resources/service_templates/vpe-201802-baseconfig/velocity/base-config-template.vtl b/blueprints-processor/plugin/assignment-provider/src/test/resources/service_templates/vpe-201802-baseconfig/velocity/base-config-template.vtl deleted file mode 100644 index 92dba1024..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/test/resources/service_templates/vpe-201802-baseconfig/velocity/base-config-template.vtl +++ /dev/null @@ -1,40 +0,0 @@ - - - - ${group-name} - - - <*> - - - - - - 224.0.1.40/32 - - - 224.0.1.39/32 - - - 224.0.0.0/4 - - - - - - - - - - <*> - - 1000 - - - - - - - - - \ No newline at end of file diff --git a/blueprints-processor/plugin/assignment-provider/src/test/resources/service_templates/vpe-201802-baseconfig/vpe-201802-baseconfig.json b/blueprints-processor/plugin/assignment-provider/src/test/resources/service_templates/vpe-201802-baseconfig/vpe-201802-baseconfig.json deleted file mode 100644 index 7113b70c2..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/test/resources/service_templates/vpe-201802-baseconfig/vpe-201802-baseconfig.json +++ /dev/null @@ -1,639 +0,0 @@ -{ - "metadata": { - "author": "ks220y@att.com", - "service-template-name": "vpe-201802-baseconfig", - "service-template-version": "1.0.0", - "release": "1802", - "service-type": "ADIOD", - "vnf-type": "VPE" - }, - "topology_template": { - "inputs": { - "request-id": { - "required": true, - "type": "string" - }, - "service-instance-id": { - "required": true, - "type": "string" - }, - "action-name": { - "required": true, - "type": "string" - }, - "scope-type": { - "required": true, - "type": "string" - }, - "hostname": { - "required": true, - "type": "string" - }, - "resource-assignment-request": { - "description": "This is Dynamic Data type for the receipe resource-assignment-action.", - "required": false, - "type": "dt-resource-assignment-request" - } - }, - "node_templates": { - "base-config-template": { - "type": "artifact-config-template", - "properties": { - "action-names": [ - "resource-assignment-action" - ] - }, - "capabilities": { - "content": { - "properties": { - "content": "db://base-config-template" - } - }, - "mapping": { - "properties": { - "mapping": [ - { - "name": "wan-aggregate-ipv6-addresses", - "input-param": true, - "property": { - "type": "list", - "entry_schema": { - "type": "dt-v6-aggregate" - } - }, - "dictionary-name": "wan-aggregate-ipv6-addresses", - "dictionary-source": "input" - }, - { - "name": "wan-aggregate-ipv4-addresses", - "input-param": true, - "property": { - "type": "list", - "entry_schema": { - "type": "dt-v4-aggregate" - } - }, - "dictionary-name": "wan-aggregate-ipv4-addresses", - "dictionary-source": "input" - }, - { - "name": "tacacs-server-ipv4-addresses", - "input-param": true, - "property": { - "type": "list", - "entry_schema": { - "type": "dt-tacacs-server-ipv4" - } - }, - "dictionary-name": "tacacs-server-ipv4-addresses", - "dictionary-source": "input" - }, - { - "name": "oam-remote-ipv4-address", - "property": { - "type": "string" - }, - "dictionary-name": "oam-remote-ipv4-address", - "dictionary-source": "input" - }, - { - "name": "si-local-ipv4-address", - "property": { - "type": "string" - }, - "dictionary-name": "si-local-ipv4-address", - "dictionary-source": "input" - }, - { - "name": "lo0-local-ipv4-address", - "property": { - "type": "string" - }, - "dictionary-name": "lo0-local-ipv4-address", - "dictionary-source": "input" - }, - { - "name": "asn-region", - "property": { - "type": "string" - }, - "dictionary-name": "asn-region", - "dictionary-source": "input" - }, - { - "name": "adiod-unicast-route-reflectors", - "input-param": true, - "property": { - "type": "list", - "entry_schema": { - "type": "dt-adiod-unicast-route-reflector" - } - }, - "dictionary-name": "adiod-unicast-route-reflectors", - "dictionary-source": "input" - }, - { - "name": "adiod-vpnv4-route-reflectors", - "input-param": true, - "property": { - "type": "list", - "entry_schema": { - "type": "dt-adiod-vpnv4-route-reflector" - } - }, - "dictionary-name": "adiod-vpnv4-route-reflectors", - "dictionary-source": "input" - }, - { - "name": "bundle-id", - "property": { - "type": "string" - }, - "dictionary-name": "bundle-id", - "dictionary-source": "input" - }, - { - "name": "uplink-1-unit", - "property": { - "type": "string" - }, - "dictionary-name": "uplink-1-unit", - "dictionary-source": "input" - }, - { - "name": "uplink-2-unit", - "property": { - "type": "string" - }, - "dictionary-name": "uplink-2-unit", - "dictionary-source": "input" - }, - { - "name": "ospf-area", - "property": { - "type": "string" - }, - "dictionary-name": "ospf-area", - "dictionary-source": "input" - }, - { - "name": "ospf-cost", - "property": { - "type": "string" - }, - "dictionary-name": "ospf-cost", - "dictionary-source": "input" - }, - { - "name": "lo10-local-ipv4-address", - "property": { - "type": "string" - }, - "dictionary-name": "lo10-local-ipv4-address", - "dictionary-source": "input" - } - ] - } - } - } - }, - "resource-assignment-action": { - "type": "dg-resource-assignment", - "interfaces": { - "CONFIG": { - "operations": { - "ResourceAssignment": { - - } - } - } - }, - "capabilities": { - "dg-node": { - - } - }, - "requirements": { - "component-dependency": { - "capability": "component-node", - "node": "resource-assignment", - "relationship": "tosca.relationships.DependsOn" - } - } - }, - "resource-assignment": { - "type": "component-resource-assignment", - "interfaces": { - "org-onap-ccsdk-features-assignment-service-ConfigAssignmentNode": { - "operations": { - "process": { - "inputs": { - "action-name": "{ \"get_input\" : \"action-name\" }", - "resource-type": "vnf-type", - "template-names": [ - "base-config-template", - "licence-template" - ], - "request-id": "{ \"get_input\" : \"request-id\" }", - "resource-id": "{ \"get_input\" : \"hostname\" }" - }, - "outputs": { - "resource-assignment-params": "", - "status": "" - } - } - } - } - }, - "capabilities": { - "component-node": { - - } - } - } - } - }, - "node_types": { - "dg-resource-assignment": { - "description": "This is Resource Assignment Directed Graph", - "version": "1.0.0", - "properties": { - "mode": { - "required": false, - "type": "string", - "default": "sync" - }, - "version": { - "required": false, - "type": "string", - "default": "LATEST" - }, - "is-start-flow": { - "required": false, - "type": "boolean", - "default": "false" - } - }, - "capabilities": { - "dg-node": { - "type": "tosca.capabilities.Node" - }, - "content": { - "type": "tosca.capabilities.Content", - "properties": { - "type": { - "required": false, - "type": "string", - "default": "json" - }, - "content": { - "required": true, - "type": "string" - } - } - } - }, - "requirements": { - "component-dependency": { - "capability": "component-node", - "node": "component-resource-assignment", - "relationship": "tosca.relationships.DependsOn" - } - }, - "interfaces": { - "CONFIG": { - "operations": { - "ResourceAssignment": { - "inputs": { - "params": { - "required": false, - "type": "list", - "entry_schema": { - "type": "datatype-property" - } - } - } - } - } - } - }, - "derived_from": "tosca.nodes.DG" - }, - "component-resource-assignment": { - "description": "This is Resource Assignment Component API", - "version": "1.0.0", - "capabilities": { - "component-node": { - "type": "tosca.capabilities.Node" - } - }, - "interfaces": { - "org-onap-ccsdk-features-assignment-service-ConfigAssignmentNode": { - "operations": { - "process": { - "inputs": { - "action-name": { - "description": "Action Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority", - "required": false, - "type": "string" - }, - "handler-name": { - "description": "Name of the Artifact Node Template, to get the template Content. If template-content is present, then content wont be reterived from the Artifact Node Template.", - "required": true, - "type": "string" - }, - "resource-type": { - "required": false, - "type": "string" - }, - "template-names": { - "description": "Name of the Artifact Node Templates, to get the template Content.", - "required": true, - "type": "list", - "entry_schema": { - "type": "string" - } - }, - "request-id": { - "description": "Request Id used to store the generated configuration, in the database along with the template-name", - "required": true, - "type": "string" - }, - "resource-id": { - "description": "Id used to pull the data content from the data base. Either template-data or resource-id should be present", - "required": true, - "type": "string" - } - }, - "outputs": { - "resource-assignment-params": { - "required": true, - "type": "string" - }, - "status": { - "required": true, - "type": "string" - } - } - } - } - } - }, - "derived_from": "tosca.nodes.Component" - }, - "artifact-config-template": { - "description": "This is Configuration Velocity Template", - "version": "1.0.0", - "properties": { - "action-names": { - "required": true, - "type": "list", - "entry_schema": { - "type": "string" - } - } - }, - "capabilities": { - "content": { - "type": "tosca.capabilities.Content", - "properties": { - "content": { - "required": true, - "type": "string" - } - } - }, - "mapping": { - "type": "tosca.capabilities.Mapping", - "properties": { - "mapping": { - "required": false, - "type": "list", - "entry_schema": { - "type": "datatype-resource-assignment" - } - } - } - } - }, - "derived_from": "tosca.nodes.Artifact" - } - }, - "data_types": { - "dt-v4-aggregate": { - "version": "1.0.0", - "description": "This is dt-v4-aggregate Data Type", - "properties": { - "v4-address": { - "required": true, - "type": "string" - }, - "v4-plen": { - "required": false, - "type": "integer" - } - }, - "derived_from": "tosca.datatypes.Root" - }, - "dt-tacacs-server-ipv4": { - "version": "1.0.0", - "description": "This is dt-tacacs-server-ipv4 Data Type", - "properties": { - "tacacs-server-ipv4-address": { - "required": true, - "type": "string" - } - }, - "derived_from": "tosca.datatypes.Root" - }, - "dt-adiod-vpnv4-route-reflector": { - "version": "1.0.0", - "description": "This is dt-adiod-unicast-route-reflector Data Type", - "properties": { - "v4-address": { - "required": true, - "type": "string" - }, - "name": { - "required": false, - "type": "string" - } - }, - "derived_from": "tosca.datatypes.Root" - }, - "datatype-resource-assignment": { - "version": "1.0.0", - "description": "This is Resource Assignment Data Type", - "properties": { - "property": { - "required": true, - "type": "datatype-property" - }, - "input-param": { - "required": true, - "type": "boolean" - }, - "dictionary-name": { - "required": false, - "type": "string" - }, - "dictionary-source": { - "required": false, - "type": "string" - }, - "dependencies": { - "required": true, - "type": "list", - "entry_schema": { - "type": "string" - } - }, - "status": { - "required": false, - "type": "string" - }, - "message": { - "required": false, - "type": "string" - }, - "updated-date": { - "required": false, - "type": "string" - }, - "updated-by": { - "required": false, - "type": "string" - } - }, - "derived_from": "tosca.datatypes.Root" - }, - "dt-adiod-unicast-route-reflector": { - "version": "1.0.0", - "description": "This is dt-adiod-unicast-route-reflector Data Type", - "properties": { - "v4-address": { - "required": true, - "type": "string" - }, - "name": { - "required": false, - "type": "string" - } - }, - "derived_from": "tosca.datatypes.Root" - }, - "datatype-property": { - "version": "1.0.0", - "description": "This is Entry point Input Data Type, which is dynamic datatype, The parameter names will be populated during the Design time for each inputs", - "properties": { - "type": { - "required": true, - "type": "string" - }, - "description": { - "required": false, - "type": "string" - }, - "required": { - "required": false, - "type": "boolean" - }, - "default": { - "required": false, - "type": "string" - }, - "entry_schema": { - "required": false, - "type": "string" - } - }, - "derived_from": "tosca.datatypes.Root" - }, - "dt-v6-aggregate": { - "version": "1.0.0", - "description": "This is dt-v6-aggregate Data Type", - "properties": { - "v6-address": { - "required": true, - "type": "string" - }, - "v6-plen": { - "required": false, - "type": "string" - } - }, - "derived_from": "tosca.datatypes.Root" - }, - "dt-resource-assignment-request": { - "version": "1.0.0", - "description": "This is Dynamic Data type definition generated from resource mapping for the config template name base-config-template.", - "properties": { - "uplink-2-unit": { - "type": "string" - }, - "bundle-mac": { - "required": true, - "type": "string" - }, - "wan-aggregate-ipv6-addresses": { - "type": "list", - "entry_schema": { - "type": "dt-v6-aggregate" - } - }, - "ospf-area": { - "type": "string" - }, - "ospf-cost": { - "type": "string" - }, - "bundle-id": { - "type": "string" - }, - "adiod-unicast-route-reflectors": { - "type": "list", - "entry_schema": { - "type": "dt-adiod-unicast-route-reflector" - } - }, - "oam-remote-ipv4-address": { - "type": "string" - }, - "adiod-vpnv4-route-reflectors": { - "type": "list", - "entry_schema": { - "type": "dt-adiod-vpnv4-route-reflector" - } - }, - "lo10-local-ipv4-address": { - "type": "string" - }, - "wan-aggregate-ipv4-addresses": { - "type": "list", - "entry_schema": { - "type": "dt-v4-aggregate" - } - }, - "lo0-local-ipv4-address": { - "type": "string" - }, - "uplink-1-unit": { - "type": "string" - }, - "tacacs-server-ipv4-addresses": { - "type": "list", - "entry_schema": { - "type": "dt-tacacs-server-ipv4" - } - }, - "asn-region": { - "type": "string" - }, - "si-local-ipv4-address": { - "type": "string" - } - }, - "derived_from": "tosca.datatypes.Dynamic" - } - } -} diff --git a/blueprints-processor/plugin/assignment-provider/src/test/resources/validation/cyclic.json b/blueprints-processor/plugin/assignment-provider/src/test/resources/validation/cyclic.json deleted file mode 100644 index fc6357f2d..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/test/resources/validation/cyclic.json +++ /dev/null @@ -1,111 +0,0 @@ -[ - { - "name": "vnf-id", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "vnf-id", - "dictionary-source": "input", - "dependencies": [] - }, - { - "name": "service-instance-id", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "service-instance-id", - "dictionary-source": "input", - "dependencies": [] - }, - { - "name": "bundle-id", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "bundle-id", - "dictionary-source": "mdsal", - "dependencies": [ - "vnf-id" - ] - }, - { - "name": "bundle-ip", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "bundle-ip", - "dictionary-source": "mdsal", - "dependencies": [ - "vnf-id" - ] - }, - { - "name": "bundle-mac", - "input-param": true, - "property": { - "type": "string" - }, - "dictionary-name": "bundle-mac", - "dictionary-source": "mdsal", - "dependencies": [ - "vnf-id", - "bundle-id" - ] - }, - { - "name": "managed-ip", - "input-param": true, - "property": { - "type": "string" - }, - "dictionary-name": "managed-ip", - "dictionary-source": "mdsal", - "dependencies": [ - "loopback-ip" - ] - }, - { - "name": "vnf-name", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "vnf-name", - "dictionary-source": "input", - "dependencies": [] - }, - { - "name": "managed-ip1", - "input-param": true, - "property": { - "type": "string" - }, - "dictionary-name": "managed-ip1", - "dictionary-source": "mdsal", - "dependencies": [ - "loopback-ip" - ] - }, - { - "name": "loopback-ip", - "input-param": true, - "property": { - "type": "string" - }, - "dictionary-name": "loopback-ip", - "dictionary-source": "db", - "dependencies": [ - "bundle-mac", - "managed-ip1" - ] - } -] diff --git a/blueprints-processor/plugin/assignment-provider/src/test/resources/validation/duplicate.json b/blueprints-processor/plugin/assignment-provider/src/test/resources/validation/duplicate.json deleted file mode 100644 index 86909a6a4..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/test/resources/validation/duplicate.json +++ /dev/null @@ -1,110 +0,0 @@ -[ - { - "name": "vnf-id", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "vnf-id", - "dictionary-source": "input", - "dependencies": [] - }, - { - "name": "service-instance-id", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "service-instance-id", - "dictionary-source": "input", - "dependencies": [] - }, - { - "name": "bundle-id", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "bundle-id", - "dictionary-source": "mdsal", - "dependencies": [ - "vnf-id" - ] - }, - { - "name": "bundle-ip", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "bundle-ip", - "dictionary-source": "mdsal", - "dependencies": [ - "vnf-id" - ] - }, - { - "name": "bundle-mac", - "input-param": true, - "property": { - "type": "string" - }, - "dictionary-name": "bundle-mac", - "dictionary-source": "mdsal", - "dependencies": [ - "vnf-id", - "bundle-id" - ] - }, - { - "name": "bundle-mac", - "input-param": true, - "property": { - "type": "string" - }, - "dictionary-name": "bundle-mac", - "dictionary-source": "mdsal", - "dependencies": [ - "loopback-ip" - ] - }, - { - "name": "vnf-name", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "vnf-name", - "dictionary-source": "input", - "dependencies": [] - }, - { - "name": "managed-ip1", - "input-param": true, - "property": { - "type": "string" - }, - "dictionary-name": "managed-ip1", - "dictionary-source": "mdsal", - "dependencies": [ - "loopback-ip" - ] - }, - { - "name": "loopback-ip", - "input-param": true, - "property": { - "type": "string" - }, - "dictionary-name": "loopback-ip", - "dictionary-source": "db", - "dependencies": [ - "bundle-mac" - ] - } -] diff --git a/blueprints-processor/plugin/assignment-provider/src/test/resources/validation/success.json b/blueprints-processor/plugin/assignment-provider/src/test/resources/validation/success.json deleted file mode 100644 index e08539c0d..000000000 --- a/blueprints-processor/plugin/assignment-provider/src/test/resources/validation/success.json +++ /dev/null @@ -1,110 +0,0 @@ -[ - { - "name": "vnf-id", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "vnf-id", - "dictionary-source": "input", - "dependencies": [] - }, - { - "name": "service-instance-id", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "service-instance-id", - "dictionary-source": "input", - "dependencies": [] - }, - { - "name": "bundle-id", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "bundle-id", - "dictionary-source": "mdsal", - "dependencies": [ - "vnf-id" - ] - }, - { - "name": "bundle-ip", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "bundle-ip", - "dictionary-source": "mdsal", - "dependencies": [ - "vnf-id" - ] - }, - { - "name": "bundle-mac", - "input-param": true, - "property": { - "type": "string" - }, - "dictionary-name": "bundle-mac", - "dictionary-source": "mdsal", - "dependencies": [ - "vnf-id", - "bundle-id" - ] - }, - { - "name": "managed-ip", - "input-param": true, - "property": { - "type": "string" - }, - "dictionary-name": "managed-ip", - "dictionary-source": "mdsal", - "dependencies": [ - "loopback-ip" - ] - }, - { - "name": "vnf-name", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "vnf-name", - "dictionary-source": "input", - "dependencies": [] - }, - { - "name": "managed-ip1", - "input-param": true, - "property": { - "type": "string" - }, - "dictionary-name": "managed-ip1", - "dictionary-source": "mdsal", - "dependencies": [ - "loopback-ip" - ] - }, - { - "name": "loopback-ip", - "input-param": true, - "property": { - "type": "string" - }, - "dictionary-name": "loopback-ip", - "dictionary-source": "db", - "dependencies": [ - "bundle-mac" - ] - } -] diff --git a/blueprints-processor/plugin/generator-provider/pom.xml b/blueprints-processor/plugin/generator-provider/pom.xml deleted file mode 100644 index d2a700b45..000000000 --- a/blueprints-processor/plugin/generator-provider/pom.xml +++ /dev/null @@ -1,141 +0,0 @@ - - - - 4.0.0 - - - org.onap.ccsdk.parent - binding-parent - 1.5.2-SNAPSHOT - - - - org.onap.ccsdk.features - blueprints-generator-provider - 0.7.1-SNAPSHOT - bundle - - ccsdk-features :: blueprints-processor-plugin :: ${project.artifactId} - http://maven.apache.org - - - - org.onap.ccsdk.features - blueprints-model-provider - ${project.version} - - - org.onap.ccsdk.features - blueprints-data-adaptor-provider - ${project.version} - - - com.fasterxml.jackson.core - jackson-core - - - com.fasterxml.jackson.core - jackson-databind - - - com.fasterxml.jackson.core - jackson-annotations - - - com.fasterxml.jackson.module - jackson-module-jsonSchema - - - commons-io - commons-io - - - org.apache.velocity - velocity - - - org.powermock - powermock-api-mockito - 1.6.4 - test - - - org.javassist - javassist - 3.21.0-GA - test - - - org.mockito - mockito-core - 1.10.19 - test - - - org.powermock - powermock-module-junit4 - 1.6.4 - test - - - org.powermock - powermock-api-support - 1.6.4 - test - - - org.powermock - powermock-reflect - 1.6.4 - test - - - org.powermock - powermock-core - 1.6.4 - test - - - junit - junit - test - - - - - - - org.apache.felix - maven-bundle-plugin - true - - - ${project.artifactId} - ${project.groupId}.${project.artifactId} - - org.onap.ccsdk.features.generator, - org.onap.ccsdk.features.generator.data, - org.onap.ccsdk.features.generator.service, - org.onap.ccsdk.features.generator.tool - - - - - - - diff --git a/blueprints-processor/plugin/generator-provider/src/main/java/org/onap/ccsdk/features/generator/ConfigGeneratorConstant.java b/blueprints-processor/plugin/generator-provider/src/main/java/org/onap/ccsdk/features/generator/ConfigGeneratorConstant.java deleted file mode 100644 index 06c423b5e..000000000 --- a/blueprints-processor/plugin/generator-provider/src/main/java/org/onap/ccsdk/features/generator/ConfigGeneratorConstant.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.generator; - -public class ConfigGeneratorConstant { - - private ConfigGeneratorConstant() { - - } - - public static final String STRING_ENCODING = "utf-8"; - public static final String Y = "Y"; - public static final String N = "N"; - public static final String DATA_TYPE_TEXT = "TEXT"; - public static final String DATA_TYPE_JSON = "JSON"; - public static final String DATA_TYPE_XML = "XML"; - public static final String DATA_TYPE_SQL = "SQL"; - - public static final String INPUT_PARAM_REQUEST_ID = "request-id"; - public static final String INPUT_PARAM_RESOURCE_ID = "resource-id"; - public static final String INPUT_PARAM_RESOURCE_TYPE = "resource-type"; - public static final String INPUT_PARAM_ACTION_NAME = "action-name"; - public static final String INPUT_PARAM_TEMPLATE_NAME = "template-name"; - public static final String INPUT_PARAM_TEMPLATE_CONTENT = "template-content"; - public static final String INPUT_PARAM_TEMPLATE_DATA = "template-data"; - - public static final String OUTPUT_PARAM_GENERATED_CONFIG = "generated-config"; - public static final String OUTPUT_PARAM_MASK_INFO = "mask-info"; - public static final String OUTPUT_PARAM_STATUS = "status"; - public static final String OUTPUT_PARAM_ERROR_MESSAGE = "error-message"; - public static final String OUTPUT_STATUS_SUCCESS = "success"; - public static final String OUTPUT_STATUS_FAILURE = "failure"; - -} diff --git a/blueprints-processor/plugin/generator-provider/src/main/java/org/onap/ccsdk/features/generator/data/ConfigGeneratorInfo.java b/blueprints-processor/plugin/generator-provider/src/main/java/org/onap/ccsdk/features/generator/data/ConfigGeneratorInfo.java deleted file mode 100644 index 0b7ea0435..000000000 --- a/blueprints-processor/plugin/generator-provider/src/main/java/org/onap/ccsdk/features/generator/data/ConfigGeneratorInfo.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.generator.data; - -public class ConfigGeneratorInfo { - - private String requestId; - private String resourceId; - private String resourceType; - private String templateName; - private String recipeName; - private String resourceData; - private String templateContent; - private String mashedData; - - public String getRequestId() { - return requestId; - } - - public void setRequestId(String requestId) { - this.requestId = requestId; - } - - public String getResourceId() { - return resourceId; - } - - public void setResourceId(String resourceId) { - this.resourceId = resourceId; - } - - public String getResourceType() { - return resourceType; - } - - public void setResourceType(String resourceType) { - this.resourceType = resourceType; - } - - public String getTemplateName() { - return templateName; - } - - public void setTemplateName(String templateName) { - this.templateName = templateName; - } - - public String getRecipeName() { - return recipeName; - } - - public void setRecipeName(String recipeName) { - this.recipeName = recipeName; - } - - public String getResourceData() { - return resourceData; - } - - public void setResourceData(String resourceData) { - this.resourceData = resourceData; - } - - public String getTemplateContent() { - return templateContent; - } - - public void setTemplateContent(String templateContent) { - this.templateContent = templateContent; - } - - public String getMashedData() { - return mashedData; - } - - public void setMashedData(String mashedData) { - this.mashedData = mashedData; - } - - @Override - public String toString() { - return "ConfigGeneratorInfo [requestId=" + requestId + ", resourceId=" + resourceId + ", resourceType=" - + resourceType + ", templateName=" + templateName + ", recipeName=" + recipeName + ", resourceData=" - + resourceData + ", templateContent=" + templateContent + ", mashedData=" + mashedData + "]"; - } - -} diff --git a/blueprints-processor/plugin/generator-provider/src/main/java/org/onap/ccsdk/features/generator/service/ConfigGeneratorNode.java b/blueprints-processor/plugin/generator-provider/src/main/java/org/onap/ccsdk/features/generator/service/ConfigGeneratorNode.java deleted file mode 100644 index 421692b89..000000000 --- a/blueprints-processor/plugin/generator-provider/src/main/java/org/onap/ccsdk/features/generator/service/ConfigGeneratorNode.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.generator.service; - -import java.util.Map; -import org.apache.commons.lang3.StringUtils; -import org.onap.ccsdk.features.data.adaptor.service.ConfigResourceService; -import org.onap.ccsdk.features.generator.ConfigGeneratorConstant; -import org.onap.ccsdk.features.generator.data.ConfigGeneratorInfo; -import org.onap.ccsdk.features.model.ConfigModelConstant; -import org.onap.ccsdk.features.model.service.ComponentNode; -import org.onap.ccsdk.features.model.service.ConfigModelService; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -public class ConfigGeneratorNode implements ComponentNode { - - private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigGeneratorNode.class); - - private ConfigModelService configModelService; - private ConfigResourceService configResourceService; - private ConfigGeneratorService configGeneratorService; - - public ConfigGeneratorNode(ConfigResourceService configResourceService, ConfigModelService configModelService) { - this.configResourceService = configResourceService; - this.configModelService = configModelService; - this.configGeneratorService = new ConfigGeneratorServiceImpl(this.configResourceService); - } - - @Override - public Boolean preCondition(Map inParams, SvcLogicContext ctx, Map componentContext) - throws SvcLogicException { - logger.trace("Received generateConfiguration preCondition call with params : ({})", inParams); - return Boolean.TRUE; - } - - @Override - public void preProcess(Map inParams, SvcLogicContext ctx, Map componentContext) - throws SvcLogicException { - logger.trace("Received generateConfiguration preProcess call with params : ({})", inParams); - } - - @Override - public void process(Map inParams, SvcLogicContext ctx) throws SvcLogicException { - logger.trace("Received generateConfiguration process call with params : ({})", inParams); - } - - @SuppressWarnings("squid:S3776") - @Override - public void process(Map inParams, SvcLogicContext ctx, Map componentContext) - throws SvcLogicException { - logger.trace("Received generateConfiguration process with params : ({})", inParams); - String prifix = inParams.get(ConfigModelConstant.PROPERTY_SELECTOR); - try { - prifix = StringUtils.isNotBlank(prifix) ? (prifix + ".") : ""; - - String templateContent = inParams.get(ConfigGeneratorConstant.INPUT_PARAM_TEMPLATE_CONTENT); - String templateData = inParams.get(ConfigGeneratorConstant.INPUT_PARAM_TEMPLATE_DATA); - String requestId = inParams.get(ConfigGeneratorConstant.INPUT_PARAM_REQUEST_ID); - String resourceId = inParams.get(ConfigGeneratorConstant.INPUT_PARAM_RESOURCE_ID); - String resourceType = inParams.get(ConfigGeneratorConstant.INPUT_PARAM_RESOURCE_TYPE); - String recipeName = inParams.get(ConfigGeneratorConstant.INPUT_PARAM_ACTION_NAME); - String templateName = inParams.get(ConfigGeneratorConstant.INPUT_PARAM_TEMPLATE_NAME); - - ConfigGeneratorInfo configGeneratorInfo = null; - if (StringUtils.isNotBlank(templateContent) && StringUtils.isNotBlank(templateData)) { - configGeneratorInfo = this.configGeneratorService.generateConfiguration(templateContent, templateData); - } else { - if (StringUtils.isBlank(requestId)) { - throw new SvcLogicException("Config Generator Request Id is missing."); - } - if (StringUtils.isBlank(resourceId)) { - throw new SvcLogicException("Config Generator Resource Id is missing."); - } - if (StringUtils.isBlank(resourceType)) { - throw new SvcLogicException("Config Generator Resource Type is missing."); - } - if (StringUtils.isBlank(recipeName)) { - throw new SvcLogicException("Config Generator Action Name is missing."); - } - if (StringUtils.isBlank(templateName)) { - throw new SvcLogicException("Config Generator Template Name Id is missing."); - } - - templateContent = configModelService.getNodeTemplateContent(ctx, templateName); - - if (StringUtils.isBlank(templateContent)) { - throw new SvcLogicException( - "Failed to get the Template Content for the Temaple Name :" + templateName); - } - - configGeneratorInfo = new ConfigGeneratorInfo(); - configGeneratorInfo.setRequestId(requestId); - configGeneratorInfo.setResourceId(resourceId); - configGeneratorInfo.setResourceType(resourceType); - configGeneratorInfo.setRecipeName(recipeName); - configGeneratorInfo.setTemplateName(templateName); - configGeneratorInfo.setTemplateContent(templateContent); - - this.configGeneratorService.generateConfiguration(configGeneratorInfo); - } - if (configGeneratorInfo != null) { - ctx.setAttribute(prifix + ConfigGeneratorConstant.OUTPUT_PARAM_GENERATED_CONFIG, - configGeneratorInfo.getMashedData()); - } - ctx.setAttribute(prifix + ConfigGeneratorConstant.OUTPUT_PARAM_STATUS, - ConfigGeneratorConstant.OUTPUT_STATUS_SUCCESS); - } catch (Exception e) { - ctx.setAttribute(prifix + ConfigGeneratorConstant.OUTPUT_PARAM_STATUS, - ConfigGeneratorConstant.OUTPUT_STATUS_FAILURE); - ctx.setAttribute(prifix + ConfigGeneratorConstant.OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage()); - logger.error("Failed in generateConfiguration ({})", e); - throw new SvcLogicException(e.getMessage()); - } - } - - @Override - public void postProcess(Map inParams, SvcLogicContext ctx, Map componentContext) - throws SvcLogicException { - logger.info("Received generateConfiguration postProcess with params : ({})", inParams); - } - -} diff --git a/blueprints-processor/plugin/generator-provider/src/main/java/org/onap/ccsdk/features/generator/service/ConfigGeneratorService.java b/blueprints-processor/plugin/generator-provider/src/main/java/org/onap/ccsdk/features/generator/service/ConfigGeneratorService.java deleted file mode 100644 index b8a943083..000000000 --- a/blueprints-processor/plugin/generator-provider/src/main/java/org/onap/ccsdk/features/generator/service/ConfigGeneratorService.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.generator.service; - -import org.onap.ccsdk.features.generator.data.ConfigGeneratorInfo; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; - -public interface ConfigGeneratorService { - - public ConfigGeneratorInfo generateConfiguration(String templateContent, String templateData) - throws SvcLogicException; - - public ConfigGeneratorInfo generateConfiguration(String templateContent, String templateData, boolean ignoreNull) - throws SvcLogicException; - - public ConfigGeneratorInfo generateConfiguration(ConfigGeneratorInfo configGeneratorInfo) throws SvcLogicException; - -} diff --git a/blueprints-processor/plugin/generator-provider/src/main/java/org/onap/ccsdk/features/generator/service/ConfigGeneratorServiceImpl.java b/blueprints-processor/plugin/generator-provider/src/main/java/org/onap/ccsdk/features/generator/service/ConfigGeneratorServiceImpl.java deleted file mode 100644 index 6292b8def..000000000 --- a/blueprints-processor/plugin/generator-provider/src/main/java/org/onap/ccsdk/features/generator/service/ConfigGeneratorServiceImpl.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.generator.service; - -import java.io.StringWriter; -import java.util.Iterator; -import java.util.List; -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.lang3.StringUtils; -import org.apache.velocity.VelocityContext; -import org.apache.velocity.app.Velocity; -import org.onap.ccsdk.features.data.adaptor.domain.ConfigResource; -import org.onap.ccsdk.features.data.adaptor.service.ConfigResourceService; -import org.onap.ccsdk.features.generator.data.ConfigGeneratorInfo; -import org.onap.ccsdk.features.generator.tool.CustomJsonNodeFactory; -import org.onap.ccsdk.features.model.utils.TransformationUtils; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; - -public class ConfigGeneratorServiceImpl implements ConfigGeneratorService { - - private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigGeneratorServiceImpl.class); - private static final String CLASS_NAME = "ConfigGeneratorServiceImpl"; - - private ConfigResourceService configResourceService; - - public ConfigGeneratorServiceImpl(ConfigResourceService configResourceService) { - logger.info("{} Constuctor Initated...", CLASS_NAME); - this.configResourceService = configResourceService; - } - - @Override - public ConfigGeneratorInfo generateConfiguration(ConfigGeneratorInfo configGeneratorInfo) throws SvcLogicException { - - if (configGeneratorInfo != null && StringUtils.isNotBlank(configGeneratorInfo.getResourceId()) - && StringUtils.isNotBlank(configGeneratorInfo.getResourceType()) - && StringUtils.isNotBlank(configGeneratorInfo.getRecipeName()) - && StringUtils.isNotBlank(configGeneratorInfo.getTemplateName()) - && StringUtils.isNotBlank(configGeneratorInfo.getTemplateContent())) { - - ConfigResource configResourceQuery = new ConfigResource(); - configResourceQuery.setResourceId(configGeneratorInfo.getResourceId()); - configResourceQuery.setResourceType(configGeneratorInfo.getResourceType()); - configResourceQuery.setTemplateName(configGeneratorInfo.getTemplateName()); - - List configResourceList = configResourceService.getConfigResource(configResourceQuery); - - if (CollectionUtils.isEmpty(configResourceList)) { - throw new SvcLogicException("No Config Resource found"); - } else if (configResourceList.size() > 1) { - throw new SvcLogicException("More than one Config Resource found for specified parameter for" - + " resourceId " + configGeneratorInfo.getResourceId() + ", resourceType " - + configGeneratorInfo.getResourceType() + ", recipeName " + configGeneratorInfo.getRecipeName() - + ", templateName " + configGeneratorInfo.getTemplateName()); - } - - ConfigResource configResource = configResourceList.get(0); - - if (configResource != null && StringUtils.isNotBlank(configResource.getResourceData())) { - configGeneratorInfo.setResourceData(configResource.getResourceData()); - logger.debug("Retrieve ConfigResource Data : ({})", configResource.getResourceData()); - ConfigGeneratorInfo generatorInfo = generateConfiguration(configGeneratorInfo.getTemplateContent(), - configResource.getResourceData()); - if (generatorInfo != null) { - configGeneratorInfo.setMashedData(generatorInfo.getMashedData()); - } - } else { - throw new SvcLogicException( - "Failed to get the Resource Data for the Resource Id :" + configGeneratorInfo.getResourceId() - + " of template :" + configGeneratorInfo.getTemplateName()); - } - } - return configGeneratorInfo; - } - - @Override - public ConfigGeneratorInfo generateConfiguration(String templateContent, String templateData) - throws SvcLogicException { - return generateConfiguration(templateContent, templateData, true); - } - - @Override - public ConfigGeneratorInfo generateConfiguration(String templateContent, String templateData, boolean ignoreNull) - throws SvcLogicException { - ConfigGeneratorInfo configGeneratorInfo = null; - try { - if (StringUtils.isNotBlank(templateContent) && StringUtils.isNotBlank(templateData)) { - configGeneratorInfo = new ConfigGeneratorInfo(); - - Velocity.init(); - - ObjectMapper mapper = new ObjectMapper(); - CustomJsonNodeFactory f = new CustomJsonNodeFactory(); - mapper.setNodeFactory(f); - - JsonNode jsonObj = mapper.readValue(templateData, JsonNode.class); - if (ignoreNull) { - TransformationUtils.removeJsonNullNode(jsonObj); - } - - VelocityContext context = new VelocityContext(); - context.put("StringUtils", org.apache.commons.lang3.StringUtils.class); - context.put("BooleanUtils", org.apache.commons.lang3.BooleanUtils.class); - - Iterator ii = jsonObj.fieldNames(); - while (ii.hasNext()) { - String key = ii.next(); - JsonNode node = jsonObj.get(key); - logger.info("Adding key ({}) with value ({})", key, node); - context.put(key, node); - } - - StringWriter writer = new StringWriter(); - Velocity.evaluate(context, writer, "TemplateData", templateContent); - writer.flush(); - configGeneratorInfo.setMashedData(writer.toString()); - } - } catch (Exception e) { - logger.error("Failed to generate Configuration ({})", e.getMessage()); - throw new SvcLogicException(e.getMessage(), e); - } - return configGeneratorInfo; - } - -} diff --git a/blueprints-processor/plugin/generator-provider/src/main/java/org/onap/ccsdk/features/generator/tool/CustomJsonNodeFactory.java b/blueprints-processor/plugin/generator-provider/src/main/java/org/onap/ccsdk/features/generator/tool/CustomJsonNodeFactory.java deleted file mode 100644 index f20cef2a6..000000000 --- a/blueprints-processor/plugin/generator-provider/src/main/java/org/onap/ccsdk/features/generator/tool/CustomJsonNodeFactory.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.generator.tool; - -import com.fasterxml.jackson.databind.node.JsonNodeFactory; -import com.fasterxml.jackson.databind.node.TextNode; - -public class CustomJsonNodeFactory extends JsonNodeFactory { - - @Override - public TextNode textNode(String text) { - return new CustomTextNode(text); - } - -} diff --git a/blueprints-processor/plugin/generator-provider/src/main/java/org/onap/ccsdk/features/generator/tool/CustomTextNode.java b/blueprints-processor/plugin/generator-provider/src/main/java/org/onap/ccsdk/features/generator/tool/CustomTextNode.java deleted file mode 100644 index 1a62dd6a9..000000000 --- a/blueprints-processor/plugin/generator-provider/src/main/java/org/onap/ccsdk/features/generator/tool/CustomTextNode.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.generator.tool; - -import com.fasterxml.jackson.core.io.CharTypes; -import com.fasterxml.jackson.databind.node.TextNode; - -public class CustomTextNode extends TextNode { - - public CustomTextNode(String v) { - super(v); - } - - @Override - public String toString() { - int len = textValue().length(); - len = len + 2 + (len >> 4); - StringBuilder sb = new StringBuilder(len); - appendQuoted(sb, textValue()); - return sb.toString(); - } - - protected static void appendQuoted(StringBuilder sb, String content) { - CharTypes.appendQuoted(sb, content); - } - -} diff --git a/blueprints-processor/plugin/generator-provider/src/main/java/org/onap/ccsdk/features/generator/tool/EscapeUtils.java b/blueprints-processor/plugin/generator-provider/src/main/java/org/onap/ccsdk/features/generator/tool/EscapeUtils.java deleted file mode 100644 index d3246e045..000000000 --- a/blueprints-processor/plugin/generator-provider/src/main/java/org/onap/ccsdk/features/generator/tool/EscapeUtils.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.generator.tool; - -import org.apache.commons.lang3.StringUtils; - -@SuppressWarnings("squid:S1118") -public class EscapeUtils { - - public static String escapeSql(String str) { - if (str == null) { - return null; - } - String[] searchList = new String[] {"'", "\\"}; - String[] replacementList = new String[] {"''", "\\\\"}; - return StringUtils.replaceEach(str, searchList, replacementList); - } - - // For Generic Purpose - public static String escapeSequence(String s) { - if (s == null) { - return null; - } - - int length = s.length(); - int newLength = length; - for (int i = 0; i < length; i++) { - char c = s.charAt(i); - switch (c) { - case '\\': - case '\"': - case '\'': - case '\0': - newLength += 1; - break; - default: - // do nothing - } - } - if (length == newLength) { - // nothing to escape in the string - return s; - } - StringBuilder sb = new StringBuilder(newLength); - for (int i = 0; i < length; i++) { - char c = s.charAt(i); - switch (c) { - case '\\': - sb.append("\\\\"); - break; - case '\"': - sb.append("\\\""); - break; - case '\'': - sb.append("\\\'"); - break; - case '\0': - sb.append("\\0"); - break; - default: - sb.append(c); - } - } - return sb.toString(); - } - -} diff --git a/blueprints-processor/plugin/generator-provider/src/main/resources/OSGI-INF/blueprint/impl-blueprint.xml b/blueprints-processor/plugin/generator-provider/src/main/resources/OSGI-INF/blueprint/impl-blueprint.xml deleted file mode 100644 index 78cb28189..000000000 --- a/blueprints-processor/plugin/generator-provider/src/main/resources/OSGI-INF/blueprint/impl-blueprint.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/blueprints-processor/plugin/generator-provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml b/blueprints-processor/plugin/generator-provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml deleted file mode 100644 index 78cb28189..000000000 --- a/blueprints-processor/plugin/generator-provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/blueprints-processor/plugin/generator-provider/src/test/java/org/onap/ccsdk/features/generator/service/ConfigGeneratorNodeTest.java b/blueprints-processor/plugin/generator-provider/src/test/java/org/onap/ccsdk/features/generator/service/ConfigGeneratorNodeTest.java deleted file mode 100644 index 2054ee681..000000000 --- a/blueprints-processor/plugin/generator-provider/src/test/java/org/onap/ccsdk/features/generator/service/ConfigGeneratorNodeTest.java +++ /dev/null @@ -1,222 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.generator.service; - -import static org.mockito.Matchers.any; -import java.nio.charset.Charset; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.apache.commons.io.IOUtils; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.MockitoAnnotations; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.runners.MockitoJUnitRunner; -import org.mockito.stubbing.Answer; -import org.onap.ccsdk.features.data.adaptor.domain.ConfigResource; -import org.onap.ccsdk.features.data.adaptor.domain.TransactionLog; -import org.onap.ccsdk.features.data.adaptor.service.ConfigResourceService; -import org.onap.ccsdk.features.generator.ConfigGeneratorConstant; -import org.onap.ccsdk.features.model.ConfigModelConstant; -import org.onap.ccsdk.features.model.service.ConfigModelService; -import org.onap.ccsdk.features.model.service.ConfigModelServiceImpl; -import org.onap.ccsdk.features.model.utils.TransformationUtils; -import org.onap.ccsdk.features.rest.adaptor.service.ConfigRestAdaptorService; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -@RunWith(MockitoJUnitRunner.class) -public class ConfigGeneratorNodeTest { - - private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigGeneratorNodeTest.class); - - @Mock - private ConfigResourceService configResourceService; - - @Mock - private ConfigRestAdaptorService configRestAdaptorService; - - private ConfigModelService configModelService; - - @Before - public void setUp() throws Exception { - - configModelService = new ConfigModelServiceImpl(configRestAdaptorService); - - MockitoAnnotations.initMocks(this); - - try { - Mockito.doAnswer(new Answer() { - @Override - public Void answer(InvocationOnMock invocationOnMock) throws Throwable { - Object[] args = invocationOnMock.getArguments(); - if (args != null) { - logger.trace("Transaction info " + Arrays.asList(args)); - } - return null; - } - }).when(configResourceService).save(any(TransactionLog.class)); - - Mockito.doAnswer(new Answer>() { - @Override - public List answer(InvocationOnMock invocationOnMock) throws Throwable { - List configResources = new ArrayList<>(); - Object[] args = invocationOnMock.getArguments(); - if (args != null) { - logger.trace("Transaction info " + Arrays.asList(args)); - String resourceData = IOUtils.toString(ConfigGeneratorNodeTest.class.getClassLoader() - .getResourceAsStream("service_templates/configdata.json"), Charset.defaultCharset()); - ConfigResource configResource = (ConfigResource) args[0]; - configResource.setRecipeName("Sample-recipe"); - configResource.setResourceData(resourceData); - configResources.add(configResource); - } - return configResources; - } - }).when(configResourceService).getConfigResource(any(ConfigResource.class)); - - } catch (SvcLogicException e) { - e.printStackTrace(); - } - } - - @Test - public void testInputTemplateContentNData() throws Exception { - - ConfigGeneratorNode configGeneratorNode = new ConfigGeneratorNode(configResourceService, configModelService); - - Map inParams = new HashMap(); - inParams.put(ConfigModelConstant.PROPERTY_SELECTOR, "test"); - - String jsonData = IOUtils.toString( - ConfigGeneratorNodeTest.class.getClassLoader().getResourceAsStream("service_templates/configdata.json"), - Charset.defaultCharset()); - inParams.put(ConfigGeneratorConstant.INPUT_PARAM_TEMPLATE_DATA, jsonData); - - String templateData = IOUtils.toString(ConfigGeneratorNodeTest.class.getClassLoader() - .getResourceAsStream("service_templates/velocity/base-config-template.vtl"), Charset.defaultCharset()); - inParams.put(ConfigGeneratorConstant.INPUT_PARAM_TEMPLATE_CONTENT, templateData); - - SvcLogicContext ctx = new SvcLogicContext(); - Map componentContext = new HashMap<>(); - configGeneratorNode.process(inParams, ctx, componentContext); - Assert.assertEquals("Failed to generate Configuration Status as Failure", - ConfigGeneratorConstant.OUTPUT_STATUS_SUCCESS, - ctx.getAttribute("test." + ConfigGeneratorConstant.OUTPUT_PARAM_STATUS)); - Assert.assertNotNull("Failed to generate Configuration", - ctx.getAttribute("test." + ConfigGeneratorConstant.OUTPUT_PARAM_GENERATED_CONFIG)); - - logger.trace("Generated Configuration:\n " - + ctx.getAttribute("test." + ConfigGeneratorConstant.OUTPUT_PARAM_GENERATED_CONFIG)); - logger.trace("Generated Configuration:\n " - + ctx.getAttribute("test." + ConfigGeneratorConstant.OUTPUT_PARAM_MASK_INFO)); - - } - - @Test - public void testInputTemplateWithNullData() throws Exception { - - ConfigGeneratorNode configGeneratorNode = new ConfigGeneratorNode(configResourceService, configModelService); - - Map inParams = new HashMap(); - inParams.put(ConfigModelConstant.PROPERTY_SELECTOR, "test"); - - String jsonData = IOUtils.toString(ConfigGeneratorNodeTest.class.getClassLoader() - .getResourceAsStream("service_templates/configdata_with_null.json"), Charset.defaultCharset()); - inParams.put(ConfigGeneratorConstant.INPUT_PARAM_TEMPLATE_DATA, jsonData); - - String templateData = IOUtils.toString(ConfigGeneratorNodeTest.class.getClassLoader() - .getResourceAsStream("service_templates/velocity/base-config-template.vtl"), Charset.defaultCharset()); - inParams.put(ConfigGeneratorConstant.INPUT_PARAM_TEMPLATE_CONTENT, templateData); - - SvcLogicContext ctx = new SvcLogicContext(); - Map componentContext = new HashMap<>(); - configGeneratorNode.process(inParams, ctx, componentContext); - Assert.assertEquals("Failed to generate Configuration Status as Failure", - ConfigGeneratorConstant.OUTPUT_STATUS_SUCCESS, - ctx.getAttribute("test." + ConfigGeneratorConstant.OUTPUT_PARAM_STATUS)); - Assert.assertNotNull("Failed to generate Configuration", - ctx.getAttribute("test." + ConfigGeneratorConstant.OUTPUT_PARAM_GENERATED_CONFIG)); - - logger.trace("Generated Configuration:\n " - + ctx.getAttribute("test." + ConfigGeneratorConstant.OUTPUT_PARAM_GENERATED_CONFIG)); - logger.trace("Generated Configuration:\n " - + ctx.getAttribute("test." + ConfigGeneratorConstant.OUTPUT_PARAM_MASK_INFO)); - - } - - @Test - public void testDBTemplateContentNData() throws Exception { - - String fileContent = IOUtils.toString(ConfigGeneratorNodeTest.class.getClassLoader() - .getResourceAsStream("service_templates/generate_configuration.json"), Charset.defaultCharset()); - - String baseConfigTemplateContent = IOUtils.toString(ConfigGeneratorNodeTest.class.getClassLoader() - .getResourceAsStream("service_templates/velocity/base-config-template.vtl"), Charset.defaultCharset()); - - Map context = new HashMap<>(); - context = configModelService.convertServiceTemplate2Properties(fileContent, context); - - context.put("node_templates.base-config-template.content", baseConfigTemplateContent); - - Assert.assertNotNull("Failed to Prepare Context : ", context); - - context.put("request-id", "12345"); - context.put("vnf-id", "vnf12345"); - context.put("action-name", "config-generator-action"); - - Map inparams = new HashMap(); - inparams.put(ConfigModelConstant.PROPERTY_SELECTOR, "generate-configuration"); - - SvcLogicContext inputContext = new SvcLogicContext(); - context.forEach((name, value) -> { - inputContext.setAttribute(name, value); - }); - - TransformationUtils.printMap(context); - configModelService.assignInParamsFromModel(inputContext, inparams); - ConfigGeneratorNode configGeneratorNode = new ConfigGeneratorNode(configResourceService, configModelService); - - Map componentContext = new HashMap<>(); - configGeneratorNode.process(inparams, inputContext, componentContext); - - Assert.assertEquals("Failed to generate Configuration Status as Failure", - ConfigGeneratorConstant.OUTPUT_STATUS_SUCCESS, - inputContext.getAttribute("generate-configuration." + ConfigGeneratorConstant.OUTPUT_PARAM_STATUS)); - Assert.assertNotNull("Failed to generate Configuration", inputContext - .getAttribute("generate-configuration." + ConfigGeneratorConstant.OUTPUT_PARAM_GENERATED_CONFIG)); - - logger.trace("Generated Configuration:\n " + inputContext - .getAttribute("generate-configuration." + ConfigGeneratorConstant.OUTPUT_PARAM_GENERATED_CONFIG)); - } - - @Test - public void testTemplateContentNDataForMask() throws Exception { - - } - -} diff --git a/blueprints-processor/plugin/generator-provider/src/test/java/org/onap/ccsdk/features/generator/tool/EscapeUtilsTest.java b/blueprints-processor/plugin/generator-provider/src/test/java/org/onap/ccsdk/features/generator/tool/EscapeUtilsTest.java deleted file mode 100644 index 17dcf7d07..000000000 --- a/blueprints-processor/plugin/generator-provider/src/test/java/org/onap/ccsdk/features/generator/tool/EscapeUtilsTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.generator.tool; - -import org.junit.Assert; -import org.junit.Test; - -public class EscapeUtilsTest { - - @Test - public void testEscapeSql() { - Assert.assertEquals("", EscapeUtils.escapeSql("")); - Assert.assertEquals("text", EscapeUtils.escapeSql("text")); - - Assert.assertEquals("''", EscapeUtils.escapeSql("'")); - Assert.assertEquals("\\\\", EscapeUtils.escapeSql("\\")); - - Assert.assertEquals("text''text", EscapeUtils.escapeSql("text'text")); - Assert.assertEquals("text\\\\text", EscapeUtils.escapeSql("text\\text")); - } - - @Test - public void testEscapeSequence() { - Assert.assertEquals("", EscapeUtils.escapeSequence("")); - Assert.assertEquals("text", EscapeUtils.escapeSequence("text")); - - Assert.assertEquals("\\\'", EscapeUtils.escapeSequence("'")); - Assert.assertEquals("\\\"", EscapeUtils.escapeSequence("\"")); - Assert.assertEquals("\\\\", EscapeUtils.escapeSequence("\\")); - - Assert.assertEquals("text\\\'text", EscapeUtils.escapeSequence("text'text")); - Assert.assertEquals("text\\\"text", EscapeUtils.escapeSequence("text\"text")); - Assert.assertEquals("text\\\\text", EscapeUtils.escapeSequence("text\\text")); - } - -} diff --git a/blueprints-processor/plugin/generator-provider/src/test/resources/service_templates/configdata.json b/blueprints-processor/plugin/generator-provider/src/test/resources/service_templates/configdata.json deleted file mode 100644 index 13d355cbc..000000000 --- a/blueprints-processor/plugin/generator-provider/src/test/resources/service_templates/configdata.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "node0_hostname": "appc-host", - "node0_backup_router_address": "2001:2001:2001:2001:2001:2001:2001:2001", - "servers": [ - "Server1", - "Server2", - "Server3" - ], - "tacplus-servers": [ - { - "tacplus-server-name": "tacplus-server-name1", - "tacplus-server-source-address": "enc-dsdsasa1" - }, - { - "tacplus-server-name": "tacplus-server-name2", - "tacplus-server-source-address": "enc-dsdsasa2" - } - ], - "classes": [ - { - "name": "superuser-class", - "idle-timeout": 5, - "permissions": "all" - }, - { - "name": "tacacs-adv-class", - "idle-timeout": 5 - }, - { - "name": "tacacs-base-class", - "idle-timeout": 5 - } - ], - "system-password": "teamops-system-password", - "root-password": "teamops-root-password" -} diff --git a/blueprints-processor/plugin/generator-provider/src/test/resources/service_templates/configdata_with_null.json b/blueprints-processor/plugin/generator-provider/src/test/resources/service_templates/configdata_with_null.json deleted file mode 100644 index d08acb17c..000000000 --- a/blueprints-processor/plugin/generator-provider/src/test/resources/service_templates/configdata_with_null.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "node0_hostname": null, - "node0_backup_router_address": "2001:2001:2001:2001:2001:2001:2001:2001", - "servers": [ - "Server1", - "Server2", - "Server3" - ], - "tacplus-servers": [ - { - "tacplus-server-name": null, - "tacplus-server-source-address": "enc-dsdsasa1" - }, - { - "tacplus-server-name": "tacplus-server-name2", - "tacplus-server-source-address": "enc-dsdsasa2" - } - ], - "classes": [ - { - "name": "superuser-class", - "idle-timeout": 5, - "permissions": "all" - }, - { - "name": "tacacs-adv-class", - "idle-timeout": 5 - }, - { - "name": "tacacs-base-class", - "idle-timeout": 5 - } - ], - "system-password": "teamops-system-password", - "root-password": "teamops-root-password" -} \ No newline at end of file diff --git a/blueprints-processor/plugin/generator-provider/src/test/resources/service_templates/generate_configuration.json b/blueprints-processor/plugin/generator-provider/src/test/resources/service_templates/generate_configuration.json deleted file mode 100644 index 326d2e8ec..000000000 --- a/blueprints-processor/plugin/generator-provider/src/test/resources/service_templates/generate_configuration.json +++ /dev/null @@ -1,355 +0,0 @@ -{ - "metadata": { - "author": "ks220y@att.com", - "service-template-name": "VRR-baseconfiguration", - "service-template-version": "1.0.0", - "service-type": "AVPN", - "vnf-type": "VRR", - "action": "Base Configuration", - "sub-action": "Generate Configuration" - }, - "topology_template": { - "inputs": { - "request-id": { - "required": true, - "type": "string" - }, - "service-instance-id": { - "required": true, - "type": "string" - }, - "vnf-id": { - "required": true, - "type": "string" - } - }, - "node_templates": { - "base-config-template": { - "type": "artifact-config-template", - "properties": { - "action-names": [ - "resource-assignment-action" - ] - }, - "capabilities": { - "content": { - "properties": { - "content": "db://base-config-template" - } - }, - "mapping": { - "properties": { - "mapping": [ - { - "name": "bundle-id", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "bundle-id", - "dictionary-source": "mdsal" - }, - { - "name": "bundle-mac", - "input-param": true, - "property": { - "type": "string" - }, - "dictionary-name": "bundle-mac", - "dictionary-source": "db" - } - ] - } - } - } - }, - "generate-configuration": { - "type": "component-config-generator", - "interfaces": { - "org-onap-ccsdk-features-generator-service-ConfigGeneratorNode": { - "operations": { - "process": { - "inputs": { - "resource-type": "vnf-type", - "request-id": "{ \"get_attribute\" : \"request-id\" }", - "resource-id": "{ \"get_input\" : \"vnf-id\" }", - "action-name": "{ \"get_attribute\" : \"action-name\" }", - "template-name": "base-config-template" - }, - "outputs": { - "generated-config": "", - "status": "" - } - } - } - } - }, - "capabilities": { - "component-node": { - - } - } - }, - "config-generator-action": { - "type": "dg-config-generator", - "interfaces": { - "CONFIG": { - "operations": { - "GenerateConfiguration": { - - } - } - } - }, - "capabilities": { - "dg-node": { - - } - }, - "requirements": { - "component-dependency": { - "capability": "component-node", - "node": "generate-configuration", - "relationship": "tosca.relationships.DependsOn" - } - } - } - } - }, - "node_types": { - "artifact-config-template": { - "description": "This is Configuration Velocity Template", - "version": "1.0.0", - "properties": { - "action-names": { - "required": true, - "type": "list", - "entry_schema": { - "type": "string" - } - } - }, - "capabilities": { - "content": { - "type": "tosca.capabilities.Content", - "properties": { - "content": { - "required": true, - "type": "string" - } - } - }, - "mapping": { - "type": "tosca.capabilities.Mapping", - "properties": { - "mapping": { - "required": false, - "type": "list", - "entry_schema": { - "type": "datatype-resource-assignment" - } - } - } - } - }, - "derived_from": "tosca.nodes.Artifact" - }, - "component-config-generator": { - "description": "This is Generate Configuration Component API", - "version": "1.0.0", - "capabilities": { - "component-node": { - "type": "tosca.capabilities.Node" - } - }, - "interfaces": { - "org-onap-ccsdk-features-generator-service-ConfigGeneratorNode": { - "operations": { - "process": { - "inputs": { - "template-data": { - "description": "Conditional : JSON string which is used to mash with template. Either template-data or ( resource-id and resource-type ) should be present", - "required": false, - "type": "string" - }, - "template-content": { - "description": "Conditional : Dynamic Template used to generate Configuration.", - "required": false, - "type": "string" - }, - "resource-type": { - "description": "Conditional : resource-type used to pull the data content from the data base. Either template-data or ( resource-id and resource-type ) should be present", - "required": false, - "type": "string" - }, - "request-id": { - "description": "Request Id used to store the generated configuration, in the database along with the template-name", - "required": true, - "type": "string" - }, - "resource-id": { - "description": "Conditional : Id used to pull the data content from the data base. Either template-data or ( resource-id and resource-type ) should be present", - "required": false, - "type": "string" - }, - "action-name": { - "description": "Conditional : Action Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority", - "required": false, - "type": "string" - }, - "template-name": { - "description": "Conditional : Name of the Artifact Node Template, to get the template Content. If template-content is present, then content wont be reterived from the Artifact Node Template.", - "required": true, - "type": "string" - } - }, - "outputs": { - "generated-config": { - "description": "Generated Configuration for the Template adn Resource Data", - "required": true, - "type": "string" - }, - "mask-info": { - "description": "If template contains mask encription keys, then this mask-info field will be generated, This JSON Content alligns to the bean org.onap.ccsdk.features.model.data.custom.MaskInfo ", - "required": false, - "type": "string" - }, - "status": { - "description": "Status of the Component Execution ( success or failure )", - "required": true, - "type": "string" - } - } - } - } - } - }, - "derived_from": "tosca.nodes.Component" - }, - "dg-config-generator": { - "description": "This is Activate DG for Config Generator Directed Graph", - "version": "1.0.0", - "properties": { - "mode": { - "required": false, - "type": "string", - "default": "sync" - }, - "version": { - "required": false, - "type": "string", - "default": "LATEST" - }, - "is-start-flow": { - "required": false, - "type": "boolean", - "default": "false" - } - }, - "capabilities": { - "dg-node": { - "type": "tosca.capabilities.Node" - }, - "content": { - "type": "tosca.capabilities.Content", - "properties": { - "type": { - "required": false, - "type": "string", - "default": "json" - }, - "content": { - "required": true, - "type": "string" - } - } - } - }, - "requirements": { - "component-dependency": { - "capability": "component-node", - "node": "component-config-generator", - "relationship": "tosca.relationships.DependsOn" - } - }, - "interfaces": { - "CONFIG": { - "operations": { - "GenerateConfiguration": { - "inputs": { - "params": { - "required": false, - "type": "list", - "entry_schema": { - "type": "datatype-property" - } - } - } - } - } - } - }, - "derived_from": "tosca.nodes.DG" - } - }, - "data_types": { - "datatype-resource-assignment": { - "version": "1.0.0", - "description": "This is Resource Assignment Data Type", - "properties": { - "property": { - "required": true, - "type": "datatype-property" - }, - "input-param": { - "required": true, - "type": "boolean" - }, - "dictionary-name": { - "required": false, - "type": "string" - }, - "dictionary-source": { - "required": false, - "type": "string" - }, - "dependencies": { - "required": true, - "type": "list", - "entry_schema": { - "type": "string" - } - } - }, - "derived_from": "tosca.datatypes.Root" - }, - "datatype-property": { - "version": "1.0.0", - "description": "This is Entry point Input Data Type, which is dynamic datatype, The parameter names will be populated during the Design time for each inputs", - "properties": { - "type": { - "required": true, - "type": "string" - }, - "description": { - "required": false, - "type": "string" - }, - "required": { - "required": false, - "type": "boolean" - }, - "default": { - "required": false, - "type": "string" - }, - "entry_schema": { - "required": false, - "type": "string" - } - }, - "derived_from": "tosca.datatypes.Root" - } - } -} diff --git a/blueprints-processor/plugin/generator-provider/src/test/resources/service_templates/velocity/base-config-template.vtl b/blueprints-processor/plugin/generator-provider/src/test/resources/service_templates/velocity/base-config-template.vtl deleted file mode 100644 index e0ea400c6..000000000 --- a/blueprints-processor/plugin/generator-provider/src/test/resources/service_templates/velocity/base-config-template.vtl +++ /dev/null @@ -1,61 +0,0 @@ - - 15.1X49-D50.3 - - node0 - - #foreach($server in ${servers}) - $StringUtils.upperCase("$server") - #end - - - ${node0_hostname} - -
${node0_backup_router_address}
- $node0_backup_router_address -
- #foreach($tacplus-server in ${tacplus-servers}) - - $tacplus-server.tacplus-server-name - $tacplus-server.tacplus-server-source-address - - #end - - AT&T information assets - #foreach($class in ${classes}) - - $class.name - $class.idle-timeout - #if ($class.permissions) - $class.permissions - #end - - #end - - readonly - Read Only Account Access - 1001 - tacacs-base-class - - - readwrite - Read - Write Account Access - 1002 - tacacs-adv-class - - ${system-password} - - - - readwrite - Emergency Access Only - 1000 - superuser-class - - ${root-password} - - - -
-
-
\ No newline at end of file diff --git a/blueprints-processor/plugin/generator-provider/src/test/resources/service_templates/velocity/base-config-template_group.vtl b/blueprints-processor/plugin/generator-provider/src/test/resources/service_templates/velocity/base-config-template_group.vtl deleted file mode 100644 index 92dba1024..000000000 --- a/blueprints-processor/plugin/generator-provider/src/test/resources/service_templates/velocity/base-config-template_group.vtl +++ /dev/null @@ -1,40 +0,0 @@ - - - - ${group-name} - - - <*> - - - - - - 224.0.1.40/32 - - - 224.0.1.39/32 - - - 224.0.0.0/4 - - - - - - - - - - <*> - - 1000 - - - - - - - - - \ No newline at end of file diff --git a/blueprints-processor/plugin/model-provider/pom.xml b/blueprints-processor/plugin/model-provider/pom.xml deleted file mode 100644 index f1770ae7c..000000000 --- a/blueprints-processor/plugin/model-provider/pom.xml +++ /dev/null @@ -1,166 +0,0 @@ - - - - 4.0.0 - - - org.onap.ccsdk.parent - binding-parent - 1.5.2-SNAPSHOT - - - - org.onap.ccsdk.features - blueprints-model-provider - 0.7.1-SNAPSHOT - bundle - - ccsdk-features :: blueprints-processor-plugin :: ${project.artifactId} - http://maven.apache.org - - - - com.fasterxml.jackson.core - jackson-core - - - com.fasterxml.jackson.core - jackson-databind - - - com.fasterxml.jackson.core - jackson-annotations - - - com.fasterxml.jackson.module - jackson-module-jsonSchema - - - com.jayway.jsonpath - json-path - - - org.onap.ccsdk.features - blueprints-rest-adaptor-provider - ${project.version} - - - org.onap.ccsdk.features - blueprints-data-adaptor-provider - ${project.version} - - - org.powermock - powermock-api-mockito - 1.6.4 - test - - - org.javassist - javassist - 3.21.0-GA - test - - - org.mockito - mockito-core - 1.10.19 - test - - - org.powermock - powermock-module-junit4 - 1.6.4 - test - - - org.powermock - powermock-api-support - 1.6.4 - test - - - org.powermock - powermock-reflect - 1.6.4 - test - - - org.powermock - powermock-core - 1.6.4 - test - - - org.powermock - powermock-module-junit4 - test - - - org.apache.sling - org.apache.sling.testing.osgi-mock - test - - - junit - junit - test - - - commons-collections - commons-collections - - - org.osgi - org.osgi.core - provided - - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - - -Xdoclint:none - - - - org.apache.felix - maven-bundle-plugin - true - - - ${project.artifactId} - ${project.groupId}.${project.artifactId} - org.onap.ccsdk.features.model, - org.onap.ccsdk.features.model.data, - org.onap.ccsdk.features.model.data.api, - org.onap.ccsdk.features.model.data.dict, - org.onap.ccsdk.features.model.domain, - org.onap.ccsdk.features.model.service, - org.onap.ccsdk.features.model.utils, - org.onap.ccsdk.features.model.validator - - - - - - - diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/ConfigModelConstant.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/ConfigModelConstant.java deleted file mode 100644 index 02e4553b3..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/ConfigModelConstant.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model; - -public class ConfigModelConstant { - - private ConfigModelConstant() { - - } - - public static final String STATUS_CODE_SUCCESS = "200"; - public static final String STATUS_CODE_FAILURE = "400"; - - public static final String STATUS_SUCCESS = "success"; - public static final String STATUS_FAILURE = "failure"; - public static final String STATUS_SKIPPED = "skipped"; - - public static final String CONFIG_STATUS_PENDING = "pending"; - public static final String CONFIG_STATUS_FAILED = "failed"; - public static final String CONFIG_STATUS_SUCCESS = "success"; - - public static final String USER_SYSTEM = "System"; - public static final String PROTOCOL_NETCONF = "netconf"; - - public static final String MODEL_CONTENT_TYPE_TOSCA_JSON = "TOSCA_JSON"; - public static final String MODEL_CONTENT_TYPE_TOSCA_YAML = "TOSCA_YAML"; - public static final String MODEL_CONTENT_TYPE_TEMPLATE = "TEMPLATE"; - public static final String MODEL_CONTENT_TYPE_YANG = "YANG"; - public static final String MODEL_CONTENT_TYPE_SCHEMA = "SCHEMA"; - - public static final String SERVICE_TEMPLATE_KEY_ARTIFACT_AUTHOR = "author"; - public static final String SERVICE_TEMPLATE_KEY_ARTIFACT_NAME = "service-template-name"; - public static final String SERVICE_TEMPLATE_KEY_ARTIFACT_VERSION = "service-template-version"; - - public static final String MODEL_DEFINITION_TYPE_NODE_TYPE = "node_type"; - public static final String MODEL_DEFINITION_TYPE_CAPABILITY_TYPE = "capability_type"; - public static final String MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE = "relationship_type"; - public static final String MODEL_DEFINITION_TYPE_DATA_TYPE = "data_type"; - public static final String MODEL_DEFINITION_TYPE_ARTIFACT_TYPE = "artifact_type"; - - public static final String MODEL_TYPE_DATA_TYPE = "tosca.datatypes.Root"; - public static final String MODEL_TYPE_DATA_TYPE_DYNAMIC = "tosca.datatypes.Dynamic"; - public static final String MODEL_TYPE_NODE_TYPE = "tosca.nodes.Root"; - - public static final String MODEL_TYPE_NODE_DG = "tosca.nodes.DG"; - public static final String MODEL_TYPE_NODE_COMPONENT = "tosca.nodes.Component"; - public static final String MODEL_TYPE_NODE_COMPONENT_PYTHON = "tosca.nodes.Component.Python"; - public static final String MODEL_TYPE_NODE_VNF = "tosca.nodes.Vnf"; - public static final String MODEL_TYPE_NODE_ARTIFACT = "tosca.nodes.Artifact"; - - public static final String MODEL_TYPE_ARTIFACT_TEMPLATE = "tosca.artifact.Template"; - public static final String MODEL_TYPE_ARTIFACT_LICENCE = "tosca.artifacts.Licence"; - - public static final String MODEL_TYPE_RELATIONSHIPS_DEPENDS_ON = "tosca.relationships.DependsOn"; - public static final String MODEL_TYPE_RELATIONSHIPS_HOSTED_ON = "tosca.relationships.HostedOn"; - public static final String MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO = "tosca.relationships.ConnectsTo"; - public static final String MODEL_TYPE_RELATIONSHIPS_ATTACH_TO = "tosca.relationships.AttachesTo"; - public static final String MODEL_TYPE_RELATIONSHIPS_ROUTES_TO = "tosca.relationships.RoutesTo"; - - public static final String NODE_TEMPLATE_TYPE_ARTIFACT_CONFIG_TEMPLATE = "artifact-config-template"; - - public static final String CAPABILITY_PROPERTY_MAPPING = "mapping"; - public static final String CAPABILITY_PROPERTY_CONTENT = "content"; - - public static final String SOURCE_INPUT = "input"; - public static final String SOURCE_DEFAULT = "default"; - public static final String SOURCE_MDSAL = "mdsal"; - public static final String SOURCE_DB = "db"; - public static final String SOURCE_COMPONENT = "component"; - - public static final String PROPERTY_STATUS = "status"; - public static final String PROPERTY_ERROR_CODE = "error-code"; - public static final String PROPERTY_ERROR_MESSAGE = "error-message"; - - public static final String PROPERTY_REQUEST_INPUT = "request-input"; - public static final String PROPERTY_REQUEST_HEADER = "request-header"; - public static final String PROPERTY_REQUEST_PAYLOAD = "request-payload"; - - public static final String PROPERTY_RESPONSE_PAYLOAD = "response-payload"; - public static final String PROPERTY_RESPONSE_JSON_NODE = "response-json-node"; - - public static final String PROPERTY_PAYLOAD = "payload"; - public static final String PROPERTY_INPUTS = "inputs"; - public static final String PROPERTY_ORGINATOR_ID = "originator-id"; - public static final String PROPERTY_API_VERSION = "api-ver"; - public static final String PROPERTY_REQUEST_ID = "request-id"; - public static final String PROPERTY_SUB_REQUEST_ID = "sub-request-id"; - public static final String PROPERTY_REQUEST = "request"; - public static final String PROPERTY_RECIPE = "action"; - - public static final String PROPERTY_SELECTOR = "prifix"; - public static final String PROPERTY_NODE_TEMPLATES = "node_templates"; - public static final String PROPERTY_NODE_TYPES = "node_types"; - public static final String PROPERTY_DATA_TYPES = "data_types"; - public static final String PROPERTY_ACTION_NAME = "action-name"; - public static final String PROPERTY_ACTION_PREFIX = "action-prefix"; - public static final String PROPERTY_TEMPLATE_NAME = "template-name"; - - public static final String PROPERTY_CURRENT_INTERFACE = "current-interface"; - public static final String PROPERTY_CURRENT_OPERATION = "current-operation"; - public static final String PROPERTY_CURRENT_IMPLEMENTATION = "current-implementation"; - public static final String PROPERTY_CURRENT_NODETYPE_DERIVED_FROM = "current-node-type-derived-from"; - public static final String PROPERTY_CURRENT_RESOURCE_ASSIGNMENT = "current-resource-assignment"; - public static final String PROPERTY_CURRENT_DICTIONARY_DEFINITION = "current-dictionary-definition"; - public static final String PROPERTY_RESOURCE_ASSIGNMENTS_DATA = "resource-assignments-data"; - - public static final String PROPERTY_RECIPE_NAMES = "action-names"; - public static final String PROPERTY_DICTIONARIES = "dictionaries"; - public static final String PROPERTY_RESOURCE_ASSIGNMENTS = "resource-assignments"; - public static final String PROPERTY_RESOURCE_KEY = "resource-key"; - public static final String PROPERTY_RESOURCE_NAME = "resource-name"; - public static final String PROPERTY_RESERVATION_ID = "reservation-id"; - - public static final String PROPERTY_NODE_TEMPLATES_DOT = "node_templates."; - public static final String PROPERTY_NODE_TYPES_DOT = "node_types."; - public static final String PROPERTY_DATA_TYPES_DOT = "data_types."; - public static final String PROPERTY_INPUTS_DOT = "inputs."; - public static final String PROPERTY_ARTIFACTS_DOT = "artifacts."; - public static final String PROPERTY_DICTIONARY_KEY_DOT = "dictionary-key."; - public static final String PROPERTY_TEMPLATE_KEY_DOT = "template-key."; - public static final String PROPERTY_RECIPE_KEY_DOT = "recipe-key."; - - public static final String PROPERTY_DOT_STATUS = ".status"; - public static final String PROPERTY_DOT_ERROR_MESSAGE = ".error-message"; - - public static final String EXPRESSION_GET_INPUT = "get_input"; - public static final String EXPRESSION_GET_ATTRIBUTE = "get_attribute"; - public static final String EXPRESSION_SET_VALUE = "set_value"; - -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/ConfigModelException.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/ConfigModelException.java deleted file mode 100644 index aa71c265a..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/ConfigModelException.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model; - -/** - * ConfigGeneratorException.java Purpose: Provide Configuration Generator ConfigGeneratorException - * - * @version 1.0 - */ -public class ConfigModelException extends Exception { - - /** - * - */ - private static final long serialVersionUID = 1L; - - /** - * This is a ConfigGeneratorException constructor - * - * @param message - */ - public ConfigModelException(String message) { - super(message); - } - - /** - * This is a ConfigGeneratorException constructor - * - * @param message - */ - public ConfigModelException(String message, Throwable cause) { - super(message, cause); - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/ValidTypes.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/ValidTypes.java deleted file mode 100644 index 1be6089d5..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/ValidTypes.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model; - -import java.util.ArrayList; -import java.util.List; - -/** - * ValidTypes.java Purpose: Provide Configuration Generator ValidTypes - * - * @version 1.0 - */ -public class ValidTypes { - - public static final String DATA_TYPE_STRING = "string"; - public static final String DATA_TYPE_INTEGER = "integer"; - public static final String DATA_TYPE_FLOAT = "float"; - public static final String DATA_TYPE_BOOLEAN = "boolean"; - public static final String DATA_TYPE_TIMESTAMP = "timestamp"; - public static final String DATA_TYPE_NULL = "null"; - public static final String DATA_TYPE_LIST = "list"; - public static final String DATA_TYPE_LONGTEXT = "longtext"; - - private ValidTypes() { - - } - - public static List getValidModelTypes() { - List validTypes = new ArrayList<>(); - validTypes.add(ConfigModelConstant.MODEL_DEFINITION_TYPE_DATA_TYPE); - validTypes.add(ConfigModelConstant.MODEL_DEFINITION_TYPE_NODE_TYPE); - validTypes.add(ConfigModelConstant.MODEL_DEFINITION_TYPE_CAPABILITY_TYPE); - validTypes.add(ConfigModelConstant.MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE); - return validTypes; - } - - public static List getValidNodeTypes() { - List validTypes = new ArrayList<>(); - validTypes.add(ConfigModelConstant.MODEL_TYPE_NODE_DG); - validTypes.add(ConfigModelConstant.MODEL_TYPE_NODE_COMPONENT); - validTypes.add(ConfigModelConstant.MODEL_TYPE_NODE_VNF); - validTypes.add(ConfigModelConstant.MODEL_TYPE_NODE_ARTIFACT); - return validTypes; - } - - public static List getValidDerivedFrom() { - List validTypes = new ArrayList<>(); - validTypes.add(ConfigModelConstant.MODEL_TYPE_DATA_TYPE_DYNAMIC); - validTypes.add(ConfigModelConstant.MODEL_TYPE_DATA_TYPE); - validTypes.add(ConfigModelConstant.MODEL_TYPE_NODE_TYPE); - return validTypes; - } - - public static List getValidDataTypeDerivedFrom() { - List validTypes = new ArrayList<>(); - validTypes.add(ConfigModelConstant.MODEL_TYPE_DATA_TYPE_DYNAMIC); - validTypes.add(ConfigModelConstant.MODEL_TYPE_DATA_TYPE); - return validTypes; - } - - public static List getValidPropertType() { - List validTypes = new ArrayList<>(); - validTypes.add(DATA_TYPE_STRING); - validTypes.add(DATA_TYPE_INTEGER); - validTypes.add(DATA_TYPE_FLOAT); - validTypes.add(DATA_TYPE_BOOLEAN); - validTypes.add(DATA_TYPE_TIMESTAMP); - validTypes.add(DATA_TYPE_NULL); - validTypes.add(DATA_TYPE_LIST); - return validTypes; - } - - public static List getPrimitivePropertType() { - List validTypes = new ArrayList<>(); - validTypes.add(DATA_TYPE_STRING); - validTypes.add(DATA_TYPE_INTEGER); - validTypes.add(DATA_TYPE_FLOAT); - validTypes.add(DATA_TYPE_BOOLEAN); - validTypes.add(DATA_TYPE_TIMESTAMP); - validTypes.add(DATA_TYPE_NULL); - return validTypes; - } - - public static List getListPropertType() { - List validTypes = new ArrayList<>(); - validTypes.add(DATA_TYPE_LIST); - return validTypes; - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/ArtifactDefinition.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/ArtifactDefinition.java deleted file mode 100644 index a26209425..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/ArtifactDefinition.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.data; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * ArtifactDefinition.java Purpose: Provide ArtifactDefinition TOSCO Model POJO bean. - * - * @version 1.0 - */ -public class ArtifactDefinition { - @JsonIgnore - private String id; - private String type; - private String file; - private String repository; - private String description; - @JsonProperty("deploy_Path") - private String deployPath; - // Used for Template Type - private String content; - private String mappingContent; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getFile() { - return file; - } - - public void setFile(String file) { - this.file = file; - } - - public String getRepository() { - return repository; - } - - public void setRepository(String repository) { - this.repository = repository; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getDeployPath() { - return deployPath; - } - - public void setDeployPath(String deployPath) { - this.deployPath = deployPath; - } - - public String getContent() { - return content; - } - - public void setContent(String content) { - this.content = content; - } - - public String getMappingContent() { - return mappingContent; - } - - public void setMappingContent(String mappingContent) { - this.mappingContent = mappingContent; - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/ArtifactType.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/ArtifactType.java deleted file mode 100644 index 3add0a3f5..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/ArtifactType.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.data; - -import java.util.List; -import java.util.Map; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class ArtifactType { - @JsonIgnore - private String id; - private String description; - private String version; - private Map metadata; - @JsonProperty("derived_from") - private String derivedFrom; - private Map properties; - @JsonProperty("mime_type") - private String mimeType; - @JsonProperty("file_ext") - private List fileExt; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - public Map getMetadata() { - return metadata; - } - - public void setMetadata(Map metadata) { - this.metadata = metadata; - } - - public String getDerivedFrom() { - return derivedFrom; - } - - public void setDerivedFrom(String derivedFrom) { - this.derivedFrom = derivedFrom; - } - - public Map getProperties() { - return properties; - } - - public void setProperties(Map properties) { - this.properties = properties; - } - - public String getMimeType() { - return mimeType; - } - - public void setMimeType(String mimeType) { - this.mimeType = mimeType; - } - - public List getFileExt() { - return fileExt; - } - - public void setFileExt(List fileExt) { - this.fileExt = fileExt; - } -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/CapabilityAssignment.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/CapabilityAssignment.java deleted file mode 100644 index f40388ce0..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/CapabilityAssignment.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.data; - -import java.util.Map; -import com.fasterxml.jackson.annotation.JsonIgnore; - -/** - * CapabilityAssignment.java Purpose: Provide CapabilityAssignment TOSCO Model POJO bean. - * - * @version 1.0 - */ -public class CapabilityAssignment { - @JsonIgnore - private String id; - private Map properties; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public Map getProperties() { - return properties; - } - - public void setProperties(Map properties) { - this.properties = properties; - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/CapabilityDefinition.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/CapabilityDefinition.java deleted file mode 100644 index 467e9bbdc..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/CapabilityDefinition.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.data; - -import java.util.List; -import java.util.Map; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * CapabilityDefinition.java Purpose: Provide CapabilityDefinition TOSCO Model POJO bean. - * - * @version 1.0 - */ -public class CapabilityDefinition { - @JsonIgnore - private String id; - private String type; - private String description; - private Map properties; - @JsonProperty("valid_source_types") - private List validSourceTypes; - private List occurrences; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public Map getProperties() { - return properties; - } - - public void setProperties(Map properties) { - this.properties = properties; - } - - public List getValidSourceTypes() { - return validSourceTypes; - } - - public void setValidSourceTypes(List validSourceTypes) { - this.validSourceTypes = validSourceTypes; - } - - public List getOccurrences() { - return occurrences; - } - - public void setOccurrences(List occurrences) { - this.occurrences = occurrences; - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/ConstraintClause.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/ConstraintClause.java deleted file mode 100644 index 2066e8f7a..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/ConstraintClause.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.data; - -import java.util.List; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * ConstraintClause.java Purpose: 3.5.2 Constraint clause. - * - * @version 1.0 - */ -public class ConstraintClause { - @JsonProperty("equal") - private Object equal; - - @JsonProperty("greater_than") - private Object greaterThan; - - @JsonProperty("greater_or_equal") - private Object greaterOrEqual; - - @JsonProperty("less_than") - private Object lessThan; - - @JsonProperty("less_or_equal") - private Object lessOrEqual; - - @JsonProperty("in_range") - private Object inRange; - - @JsonProperty("valid_values") - private List validValues; - - @JsonProperty("length") - private Object length; - - @JsonProperty("min_length") - private Object minLength; - - @JsonProperty("max_length") - private Object maxLength; - - @JsonProperty("pattern") - private String pattern; - - public Object getEqual() { - return equal; - } - - public void setEqual(Object equal) { - this.equal = equal; - } - - public Object getGreaterThan() { - return greaterThan; - } - - public void setGreaterThan(Object greaterThan) { - this.greaterThan = greaterThan; - } - - public Object getGreaterOrEqual() { - return greaterOrEqual; - } - - public void setGreaterOrEqual(Object greaterOrEqual) { - this.greaterOrEqual = greaterOrEqual; - } - - public Object getLessThan() { - return lessThan; - } - - public void setLessThan(Object lessThan) { - this.lessThan = lessThan; - } - - public Object getLessOrEqual() { - return lessOrEqual; - } - - public void setLessOrEqual(Object lessOrEqual) { - this.lessOrEqual = lessOrEqual; - } - - public Object getInRange() { - return inRange; - } - - public void setInRange(Object inRange) { - this.inRange = inRange; - } - - public List getValidValues() { - return validValues; - } - - public void setValidValues(List validValues) { - this.validValues = validValues; - } - - public Object getLength() { - return length; - } - - public void setLength(Object length) { - this.length = length; - } - - public Object getMinLength() { - return minLength; - } - - public void setMinLength(Object minLength) { - this.minLength = minLength; - } - - public Object getMaxLength() { - return maxLength; - } - - public void setMaxLength(Object maxLength) { - this.maxLength = maxLength; - } - - public String getPattern() { - return pattern; - } - - public void setPattern(String pattern) { - this.pattern = pattern; - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/DataType.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/DataType.java deleted file mode 100644 index 6df6ba2a8..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/DataType.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.data; - -import java.util.List; -import java.util.Map; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * DataType.java Purpose: Provide DataType TOSCO Model POJO bean. - * - * @version 1.0 - */ -public class DataType { - @JsonIgnore - private String id; - private String version; - private String description; - @JsonProperty("derived_from") - private String derivedFrom; - private List> constraints; - private Map properties; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getDerivedFrom() { - return derivedFrom; - } - - public void setDerivedFrom(String derivedFrom) { - this.derivedFrom = derivedFrom; - } - - public List> getConstraints() { - return constraints; - } - - public void setConstraints(List> constraints) { - this.constraints = constraints; - } - - public Map getProperties() { - return properties; - } - - public void setProperties(Map properties) { - this.properties = properties; - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/EntrySchema.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/EntrySchema.java deleted file mode 100644 index 663442161..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/EntrySchema.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.data; - -/** - * EntrySchema.java Purpose: Provide EntrySchema TOSCO Model POJO bean. - * - * @version 1.0 - */ -public class EntrySchema { - private String type; - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/Implementation.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/Implementation.java deleted file mode 100644 index 46facdb69..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/Implementation.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.data; - -import java.util.List; -import com.fasterxml.jackson.annotation.JsonIgnore; - -/** - * Implementation.java Purpose: Provide Operation Implementation TOSCO Model POJO bean. - * - * @version 1.0 - */ -public class Implementation { - @JsonIgnore - private String primary; - private List dependencies; - - public String getPrimary() { - return primary; - } - - public void setPrimary(String primary) { - this.primary = primary; - } - - public List getDependencies() { - return dependencies; - } - - public void setDependencies(List dependencies) { - this.dependencies = dependencies; - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/InterfaceAssignment.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/InterfaceAssignment.java deleted file mode 100644 index 9007dd027..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/InterfaceAssignment.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.data; - -import java.util.Map; -import com.fasterxml.jackson.annotation.JsonIgnore; - -/** - * InterfaceAssignment.java Purpose: Provide InterfaceAssignment TOSCO Model POJO bean. - * - * @version 1.0 - */ -public class InterfaceAssignment { - @JsonIgnore - private String id; - private String type; - private Map operations; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public Map getOperations() { - return operations; - } - - public void setOperations(Map operations) { - this.operations = operations; - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/InterfaceDefinition.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/InterfaceDefinition.java deleted file mode 100644 index bcd0ef375..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/InterfaceDefinition.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.data; - -import java.util.Map; -import com.fasterxml.jackson.annotation.JsonIgnore; - -/** - * InterfaceAssignment.java Purpose: Provide InterfaceAssignment TOSCO Model POJO bean. - * - * @version 1.0 - */ -public class InterfaceDefinition { - @JsonIgnore - private String id; - private String type; - private Map operations; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public Map getOperations() { - return operations; - } - - public void setOperations(Map operations) { - this.operations = operations; - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/NodeTemplate.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/NodeTemplate.java deleted file mode 100644 index c62b719e3..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/NodeTemplate.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.data; - -import java.util.Map; -import com.fasterxml.jackson.annotation.JsonIgnore; - -/** - * NodeTemplate.java Purpose: Provide NodeTemplate TOSCO Model POJO bean. - * - * @version 1.0 - */ -public class NodeTemplate { - @JsonIgnore - private String id; - private String description; - private String type; - private Map metadata; - private Map properties; - private Map interfaces; - private Map artifacts; - private Map capabilities; - private Map requirements; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public Map getMetadata() { - return metadata; - } - - public void setMetadata(Map metadata) { - this.metadata = metadata; - } - - public Map getProperties() { - return properties; - } - - public void setProperties(Map properties) { - this.properties = properties; - } - - public Map getInterfaces() { - return interfaces; - } - - public void setInterfaces(Map interfaces) { - this.interfaces = interfaces; - } - - public Map getArtifacts() { - return artifacts; - } - - public void setArtifacts(Map artifacts) { - this.artifacts = artifacts; - } - - public Map getCapabilities() { - return capabilities; - } - - public void setCapabilities(Map capabilities) { - this.capabilities = capabilities; - } - - public Map getRequirements() { - return requirements; - } - - public void setRequirements(Map requirements) { - this.requirements = requirements; - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/NodeType.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/NodeType.java deleted file mode 100644 index f97910995..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/NodeType.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.data; - -import java.util.Map; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * NodeType.java Purpose: Provide NodeType TOSCO Model POJO bean. - * - * @version 1.0 - */ -public class NodeType { - @JsonIgnore - private String id; - private String description; - private String version; - private Map metadata; - @JsonProperty("derived_from") - private String derivedFrom; - private Map properties; - private Map capabilities; - private Map requirements; - private Map interfaces; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - public Map getMetadata() { - return metadata; - } - - public void setMetadata(Map metadata) { - this.metadata = metadata; - } - - public String getDerivedFrom() { - return derivedFrom; - } - - public void setDerivedFrom(String derivedFrom) { - this.derivedFrom = derivedFrom; - } - - public Map getProperties() { - return properties; - } - - public void setProperties(Map properties) { - this.properties = properties; - } - - public Map getCapabilities() { - return capabilities; - } - - public void setCapabilities(Map capabilities) { - this.capabilities = capabilities; - } - - public Map getRequirements() { - return requirements; - } - - public void setRequirements(Map requirements) { - this.requirements = requirements; - } - - public Map getInterfaces() { - return interfaces; - } - - public void setInterfaces(Map interfaces) { - this.interfaces = interfaces; - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/OperationAssignment.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/OperationAssignment.java deleted file mode 100644 index cbb14067d..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/OperationAssignment.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.data; - -import java.util.Map; -import com.fasterxml.jackson.annotation.JsonIgnore; - -/** - * OperationAssignment.java Purpose: Provide OperationAssignment TOSCO Model POJO bean. - * - * @version 1.0 - */ -public class OperationAssignment { - @JsonIgnore - private String id; - private String description; - private String implementation; - private Map inputs; - private Map outputs; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getImplementation() { - return implementation; - } - - public void setImplementation(String implementation) { - this.implementation = implementation; - } - - public Map getInputs() { - return inputs; - } - - public void setInputs(Map inputs) { - this.inputs = inputs; - } - - public Map getOutputs() { - return outputs; - } - - public void setOutputs(Map outputs) { - this.outputs = outputs; - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/OperationDefinition.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/OperationDefinition.java deleted file mode 100644 index eeb333500..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/OperationDefinition.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.data; - -import java.util.Map; -import com.fasterxml.jackson.annotation.JsonIgnore; - -/** - * OperationDefinition.java Purpose: Provide OperationDefinition TOSCO Model POJO bean. - * - * @version 1.0 - */ -public class OperationDefinition { - @JsonIgnore - private String id; - private String description; - private Implementation implementation; - private Map inputs; - private Map outputs; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public Implementation getImplementation() { - return implementation; - } - - public void setImplementation(Implementation implementation) { - this.implementation = implementation; - } - - public Map getInputs() { - return inputs; - } - - public void setInputs(Map inputs) { - this.inputs = inputs; - } - - public Map getOutputs() { - return outputs; - } - - public void setOutputs(Map outputs) { - this.outputs = outputs; - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/PropertyDefinition.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/PropertyDefinition.java deleted file mode 100644 index a300d2386..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/PropertyDefinition.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.data; - -import java.util.HashMap; -import java.util.List; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * PropertyDefinition.java Purpose: Provide PropertyDefinition TOSCO Model POJO bean. - * - * @version 1.0 - */ -public class PropertyDefinition { - @JsonIgnore - private String id; - private String description; - private Boolean required; - private String type; - @JsonProperty("default") - private Object defaultValue; - private String status; - private List> constraints; - @JsonProperty("entry_schema") - private EntrySchema entrySchema; - private Object value; - - @Override - public String toString() { - StringBuilder builder = new StringBuilder("["); - builder.append(" type :" + getType()); - builder.append(", value :" + getValue()); - builder.append("]"); - return builder.toString(); - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public Boolean getRequired() { - return required; - } - - public void setRequired(Boolean required) { - this.required = required; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public Object getDefaultValue() { - return defaultValue; - } - - public void setDefaultValue(Object defaultValue) { - this.defaultValue = defaultValue; - } - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } - - public List> getConstraints() { - return constraints; - } - - public void setConstraints(List> constraints) { - this.constraints = constraints; - } - - public EntrySchema getEntrySchema() { - return entrySchema; - } - - public void setEntrySchema(EntrySchema entrySchema) { - this.entrySchema = entrySchema; - } - - public Object getValue() { - return value; - } - - public void setValue(Object value) { - this.value = value; - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/RelationshipTemplate.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/RelationshipTemplate.java deleted file mode 100644 index 172d5a846..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/RelationshipTemplate.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.data; - -import java.util.Map; - -/** - * RelationshipTemplate.java Purpose: Provide RelationshipTemplate TOSCO Model POJO bean. - * - * @version 1.0 - */ -public class RelationshipTemplate { - private String description; - private String type; - private Map properties; - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public Map getProperties() { - return properties; - } - - public void setProperties(Map properties) { - this.properties = properties; - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/RequirementAssignment.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/RequirementAssignment.java deleted file mode 100644 index c26de45e5..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/RequirementAssignment.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.data; - -import com.fasterxml.jackson.annotation.JsonIgnore; - -/** - * RequirementAssignment.java Purpose: Provide RequirementAssignment TOSCO Model POJO bean. - * - * @version 1.0 - */ -public class RequirementAssignment { - @JsonIgnore - private String id; - private String capability; - private String node; - // Relationship Type or Relationship Template - private String relationship; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getCapability() { - return capability; - } - - public void setCapability(String capability) { - this.capability = capability; - } - - public String getNode() { - return node; - } - - public void setNode(String node) { - this.node = node; - } - - public String getRelationship() { - return relationship; - } - - public void setRelationship(String relationship) { - this.relationship = relationship; - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/RequirementDefinition.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/RequirementDefinition.java deleted file mode 100644 index 623a76031..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/RequirementDefinition.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.data; - -import java.util.List; -import com.fasterxml.jackson.annotation.JsonIgnore; - -/** - * RequirementDefinition.java Purpose: Provide RequirementDefinition TOSCO Model POJO bean. - * - * @version 1.0 - */ -public class RequirementDefinition { - @JsonIgnore - private String id; - private String description; - private String capability; - private String node; - private String relationship; - private List occurrences; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getCapability() { - return capability; - } - - public void setCapability(String capability) { - this.capability = capability; - } - - public String getNode() { - return node; - } - - public void setNode(String node) { - this.node = node; - } - - public String getRelationship() { - return relationship; - } - - public void setRelationship(String relationship) { - this.relationship = relationship; - } - - public List getOccurrences() { - return occurrences; - } - - public void setOccurrences(List occurrences) { - this.occurrences = occurrences; - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/ResourceAssignment.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/ResourceAssignment.java deleted file mode 100644 index 9f852c11c..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/ResourceAssignment.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.data; - -import java.util.Date; -import java.util.List; -import com.fasterxml.jackson.annotation.JsonFormat; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * ResourceAssignment.java Purpose: Provide ResourceAssignment Custom TOSCO Model POJO bean. - * - * @version 1.0 - */ -public class ResourceAssignment { - - private String name; - - @JsonProperty("property") - private PropertyDefinition property; - - @JsonProperty("input-param") - private Boolean inputParameter; - - @JsonProperty("dictionary-name") - private String dictionaryName; - - @JsonProperty("dictionary-source") - private String dictionarySource; - - @JsonProperty("dependencies") - private List dependencies; - - @JsonProperty("version") - private int version; - - @JsonProperty("status") - private String status; - - @JsonProperty("message") - private String message; - - @JsonProperty("updated-date") - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") - private Date updatedDate; - - @JsonProperty("updated-by") - private String updatedBy; - - @Override - public String toString() { - StringBuilder builder = new StringBuilder("["); - builder.append("name = " + name); - builder.append(", source = " + dictionarySource); - if (dependencies != null) { - builder.append(", dependencies = " + dependencies); - } - builder.append("]"); - return builder.toString(); - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public PropertyDefinition getProperty() { - return property; - } - - public void setProperty(PropertyDefinition property) { - this.property = property; - } - - public Boolean getInputParameter() { - return inputParameter; - } - - public void setInputParameter(Boolean inputParameter) { - this.inputParameter = inputParameter; - } - - public String getDictionaryName() { - return dictionaryName; - } - - public void setDictionaryName(String dictionaryName) { - this.dictionaryName = dictionaryName; - } - - public String getDictionarySource() { - return dictionarySource; - } - - public void setDictionarySource(String dictionarySource) { - this.dictionarySource = dictionarySource; - } - - public List getDependencies() { - return dependencies; - } - - public void setDependencies(List dependencies) { - this.dependencies = dependencies; - } - - public int getVersion() { - return version; - } - - public void setVersion(int version) { - this.version = version; - } - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - public Date getUpdatedDate() { - return updatedDate; - } - - public void setUpdatedDate(Date updatedDate) { - this.updatedDate = updatedDate; - } - - public String getUpdatedBy() { - return updatedBy; - } - - public void setUpdatedBy(String updatedBy) { - this.updatedBy = updatedBy; - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/ServiceTemplate.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/ServiceTemplate.java deleted file mode 100644 index f66d73727..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/ServiceTemplate.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.data; - -import java.util.Map; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * ServiceTemplate.java Purpose: Provide ServiceTemplate TOSCO Model POJO bean. - * - * @version 1.0 - */ -public class ServiceTemplate { - @JsonIgnore - private String id; - @JsonProperty("tosca_definitions_version") - private String toscaDefinitionsVersion; - private Map metadata; - private String description; - @JsonProperty("dsl_definitions") - private Map dslDefinitions; - @JsonProperty("topology_template") - private TopologyTemplate topologyTemplate; - @JsonProperty("artifact_types") - private Map artifactTypes; - @JsonProperty("node_types") - private Map nodeTypes; - @JsonProperty("data_types") - private Map dataTypes; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getToscaDefinitionsVersion() { - return toscaDefinitionsVersion; - } - - public void setToscaDefinitionsVersion(String toscaDefinitionsVersion) { - this.toscaDefinitionsVersion = toscaDefinitionsVersion; - } - - public Map getMetadata() { - return metadata; - } - - public void setMetadata(Map metadata) { - this.metadata = metadata; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public Map getDslDefinitions() { - return dslDefinitions; - } - - public void setDslDefinitions(Map dslDefinitions) { - this.dslDefinitions = dslDefinitions; - } - - public TopologyTemplate getTopologyTemplate() { - return topologyTemplate; - } - - public void setTopologyTemplate(TopologyTemplate topologyTemplate) { - this.topologyTemplate = topologyTemplate; - } - - public Map getNodeTypes() { - return nodeTypes; - } - - public void setNodeTypes(Map nodeTypes) { - this.nodeTypes = nodeTypes; - } - - public Map getDataTypes() { - return dataTypes; - } - - public void setDataTypes(Map dataTypes) { - this.dataTypes = dataTypes; - } - - public Map getArtifactTypes() { - return artifactTypes; - } - - public void setArtifactTypes(Map artifactTypes) { - this.artifactTypes = artifactTypes; - } -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/TopologyTemplate.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/TopologyTemplate.java deleted file mode 100644 index 1f609386a..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/TopologyTemplate.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.data; - -import java.util.Map; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * TopologyTemplate.java Purpose: Provide TopologyTemplate TOSCO Model POJO bean. - * - * @version 1.0 - */ -public class TopologyTemplate { - @JsonIgnore - private String id; - private String description; - private Map inputs; - @JsonProperty("node_templates") - private Map nodeTemplates; - @JsonProperty("relationship_templates") - private Map relationshipTemplates; - private Map capabilities; - private Map workflows; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public Map getInputs() { - return inputs; - } - - public void setInputs(Map inputs) { - this.inputs = inputs; - } - - public Map getNodeTemplates() { - return nodeTemplates; - } - - public void setNodeTemplates(Map nodeTemplates) { - this.nodeTemplates = nodeTemplates; - } - - public Map getRelationshipTemplates() { - return relationshipTemplates; - } - - public void setRelationshipTemplates(Map relationshipTemplates) { - this.relationshipTemplates = relationshipTemplates; - } - - public Map getCapabilities() { - return capabilities; - } - - public void setCapabilities(Map capabilities) { - this.capabilities = capabilities; - } - - public Map getWorkflows() { - return workflows; - } - - public void setWorkflows(Map workflows) { - this.workflows = workflows; - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/Workflow.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/Workflow.java deleted file mode 100644 index 09742a3d0..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/Workflow.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.data; - -import com.fasterxml.jackson.annotation.JsonIgnore; - -/** - * Workflow.java Purpose: Provide Workflow TOSCO Model POJO bean. - * - * @version 1.0 - */ -public class Workflow { - @JsonIgnore - private String id; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/api/ActionIdentifiers.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/api/ActionIdentifiers.java deleted file mode 100644 index 2b54a2c8b..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/api/ActionIdentifiers.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.data.api; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class ActionIdentifiers { - @JsonProperty("service-template-name") - private String serviceTemplateName; - @JsonProperty("service-template-version") - private String serviceTemplateVersion; - @JsonProperty("action-name") - private String actionName; - private String mode; - - public String getServiceTemplateName() { - return serviceTemplateName; - } - - public void setServiceTemplateName(String serviceTemplateName) { - this.serviceTemplateName = serviceTemplateName; - } - - public String getServiceTemplateVersion() { - return serviceTemplateVersion; - } - - public void setServiceTemplateVersion(String serviceTemplateVersion) { - this.serviceTemplateVersion = serviceTemplateVersion; - } - - public String getActionName() { - return actionName; - } - - public void setActionName(String actionName) { - this.actionName = actionName; - } - - public String getMode() { - return mode; - } - - public void setMode(String mode) { - this.mode = mode; - } -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/api/CommonHeader.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/api/CommonHeader.java deleted file mode 100644 index 4a4011ef1..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/api/CommonHeader.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.data.api; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class CommonHeader { - - private String timestamp; - @JsonProperty("api-ver") - private String apiVer; - @JsonProperty("originator-id") - private String originatorId; - @JsonProperty("request-id") - private String requestId; - @JsonProperty("sub-request-id") - private String subRequestId; - private Flags flags; - - public String getTimestamp() { - return timestamp; - } - - public void setTimestamp(String timestamp) { - this.timestamp = timestamp; - } - - public String getApiVer() { - return apiVer; - } - - public void setApiVer(String apiVer) { - this.apiVer = apiVer; - } - - public String getOriginatorId() { - return originatorId; - } - - public void setOriginatorId(String originatorId) { - this.originatorId = originatorId; - } - - public String getRequestId() { - return requestId; - } - - public void setRequestId(String requestId) { - this.requestId = requestId; - } - - public String getSubRequestId() { - return subRequestId; - } - - public void setSubRequestId(String subRequestId) { - this.subRequestId = subRequestId; - } - - public Flags getFlags() { - return flags; - } - - public void setFlags(Flags flags) { - this.flags = flags; - } -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/api/Flags.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/api/Flags.java deleted file mode 100644 index b1f2a9399..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/api/Flags.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.data.api; - -public class Flags { - private boolean force; - private Integer ttl; - - public boolean isForce() { - return force; - } - - public void setForce(boolean force) { - this.force = force; - } - - public Integer getTtl() { - return ttl; - } - - public void setTtl(Integer ttl) { - this.ttl = ttl; - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/api/Status.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/api/Status.java deleted file mode 100644 index 2cdd839d6..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/api/Status.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.data.api; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class Status { - - private Integer code; - @JsonProperty("error-message") - private String errorMessage; - private String message; - private String completed; - - public Integer getCode() { - return code; - } - - public void setCode(Integer code) { - this.code = code; - } - - public String getErrorMessage() { - return errorMessage; - } - - public void setErrorMessage(String errorMessage) { - this.errorMessage = errorMessage; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - public String getCompleted() { - return completed; - } - - public void setCompleted(String completed) { - this.completed = completed; - } -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/api/TransactionRequest.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/api/TransactionRequest.java deleted file mode 100644 index 56148eeef..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/api/TransactionRequest.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.data.api; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class TransactionRequest { - - @JsonProperty("transaction-request-id") - private String transactionRequestId; - @JsonProperty("message-type") - private String messageType; - - public String getTransactionRequestId() { - return transactionRequestId; - } - - public void setTransactionRequestId(String transactionRequestId) { - this.transactionRequestId = transactionRequestId; - } - - public String getMessageType() { - return messageType; - } - - public void setMessageType(String messageType) { - this.messageType = messageType; - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/api/TransactionResponse.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/api/TransactionResponse.java deleted file mode 100644 index cc935e813..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/api/TransactionResponse.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.data.api; - -import java.util.List; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class TransactionResponse { - - @JsonProperty("transaction-request-id") - private String transactionRequestId; - @JsonProperty("event-message") - private List eventMessage; - - public String getTransactionRequestId() { - return transactionRequestId; - } - - public void setTransactionRequestId(String transactionRequestId) { - this.transactionRequestId = transactionRequestId; - } - - public List getEventMessage() { - return eventMessage; - } - - public void setEventMessage(List eventMessage) { - this.eventMessage = eventMessage; - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/dict/ResourceDefinition.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/dict/ResourceDefinition.java deleted file mode 100644 index 25605fcd2..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/dict/ResourceDefinition.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.data.dict; - -import java.util.Map; -import org.onap.ccsdk.features.model.data.PropertyDefinition; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonIgnoreProperties(ignoreUnknown = true) -public class ResourceDefinition { - - @JsonProperty(value = "name", required = true) - private String name; - - @JsonProperty(value = "tags") - private String tags; - - @JsonProperty(value = "property") - private PropertyDefinition property; - - @JsonProperty(value = "updated-by") - private String updatedBy; - - @JsonProperty(value = "sources", required = true) - private Map sourcesDefinition; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public PropertyDefinition getProperty() { - return property; - } - - public void setProperty(PropertyDefinition property) { - this.property = property; - } - - public String getTags() { - return tags; - } - - public void setTags(String tags) { - this.tags = tags; - } - - public String getUpdatedBy() { - return updatedBy; - } - - public void setUpdatedBy(String updatedBy) { - this.updatedBy = updatedBy; - } - - public Map getSources() { - return sourcesDefinition; - } - - public void setSources(Map sourcesDefinition) { - this.sourcesDefinition = sourcesDefinition; - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/dict/SourcesDefinition.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/dict/SourcesDefinition.java deleted file mode 100644 index 0ce7eda37..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/dict/SourcesDefinition.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.data.dict; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonIgnoreProperties(ignoreUnknown = true) -public class SourcesDefinition { - - @JsonProperty(value = "type", required = true) - private String type; - - @JsonProperty(value = "properties", required = true) - private SourcesProperties properties; - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public SourcesProperties getProperties() { - return properties; - } - - public void setProperties(SourcesProperties properties) { - this.properties = properties; - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/dict/SourcesProperties.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/dict/SourcesProperties.java deleted file mode 100644 index 696e1516d..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/data/dict/SourcesProperties.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.data.dict; - -import java.util.List; -import java.util.Map; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonIgnoreProperties(ignoreUnknown = true) -public class SourcesProperties { - - @JsonProperty(value = "key") - private String key; - - @JsonProperty(value = "type") - private String type; - - @JsonProperty(value = "query") - private String query; - - @JsonProperty(value = "url-path") - private String urlPath; - - @JsonProperty(value = "expression-type") - private String expressionType; - - @JsonProperty(value = "path") - private String path; - - @JsonProperty("input-key-mapping") - private Map inputKeyMapping; - - @JsonProperty("output-key-mapping") - private Map outputKeyMapping; - - @JsonProperty("key-dependencies") - private List dependencies; - - public String getKey() { - return key; - } - - public void setKey(String key) { - this.key = key; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getQuery() { - return query; - } - - public void setQuery(String query) { - this.query = query; - } - - public String getUrlPath() { - return urlPath; - } - - public void setUrlPath(String urlPath) { - this.urlPath = urlPath; - } - - public String getPath() { - return path; - } - - public void setExpressionType(String expressionType) { - this.expressionType = expressionType; - } - - public String getExpressionType() { - return expressionType; - } - - public void setPath(String path) { - this.path = path; - } - - public Map getInputKeyMapping() { - return inputKeyMapping; - } - - public void setInputKeyMapping(Map inputKeyMapping) { - this.inputKeyMapping = inputKeyMapping; - } - - public Map getOutputKeyMapping() { - return outputKeyMapping; - } - - public void setOutputKeyMapping(Map outputKeyMapping) { - this.outputKeyMapping = outputKeyMapping; - } - - public List getDependencies() { - return dependencies; - } - - public void setDependencies(List dependencies) { - this.dependencies = dependencies; - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/domain/ConfigModel.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/domain/ConfigModel.java deleted file mode 100644 index 66de05b0e..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/domain/ConfigModel.java +++ /dev/null @@ -1,231 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.domain; - -import java.io.Serializable; -import java.util.Date; -import java.util.List; -import com.fasterxml.jackson.annotation.JsonFormat; - -public class ConfigModel implements Serializable { - - private Long id; - private String serviceUUID; - private String distributionId; - private String serviceName; - private String serviceDescription; - private String resourceUUID; - private String resourceInstanceName; - private String resourceName; - private String resourceVersion; - private String resourceType; - private String artifactUUId; - private String artifactType; - private String artifactVersion; - private String artifactDescription; - private Integer internalVersion; - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") - private Date createdDate = new Date(); - private String artifactName; - private String published; - private String updatedBy; - private String tags; - @SuppressWarnings("squid:S1948") - private List configModelContents; - - @Override - public String toString() { - StringBuilder buffer = new StringBuilder("["); - buffer.append("id = " + id); - buffer.append(", artifactType = " + artifactType); - buffer.append(", artifactVersion = " + artifactVersion); - buffer.append(", artifactName = " + artifactName); - buffer.append(", active = " + published); - buffer.append("]"); - return buffer.toString(); - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getServiceUUID() { - return serviceUUID; - } - - public void setServiceUUID(String serviceUUID) { - this.serviceUUID = serviceUUID; - } - - public String getDistributionId() { - return distributionId; - } - - public void setDistributionId(String distributionId) { - this.distributionId = distributionId; - } - - public String getServiceName() { - return serviceName; - } - - public void setServiceName(String serviceName) { - this.serviceName = serviceName; - } - - public String getServiceDescription() { - return serviceDescription; - } - - public void setServiceDescription(String serviceDescription) { - this.serviceDescription = serviceDescription; - } - - public String getResourceUUID() { - return resourceUUID; - } - - public void setResourceUUID(String resourceUUID) { - this.resourceUUID = resourceUUID; - } - - public String getResourceInstanceName() { - return resourceInstanceName; - } - - public void setResourceInstanceName(String resourceInstanceName) { - this.resourceInstanceName = resourceInstanceName; - } - - public String getResourceName() { - return resourceName; - } - - public void setResourceName(String resourceName) { - this.resourceName = resourceName; - } - - public String getResourceVersion() { - return resourceVersion; - } - - public void setResourceVersion(String resourceVersion) { - this.resourceVersion = resourceVersion; - } - - public String getResourceType() { - return resourceType; - } - - public void setResourceType(String resourceType) { - this.resourceType = resourceType; - } - - public String getArtifactUUId() { - return artifactUUId; - } - - public void setArtifactUUId(String artifactUUId) { - this.artifactUUId = artifactUUId; - } - - public String getArtifactType() { - return artifactType; - } - - public void setArtifactType(String artifactType) { - this.artifactType = artifactType; - } - - public String getArtifactVersion() { - return artifactVersion; - } - - public void setArtifactVersion(String artifactVersion) { - this.artifactVersion = artifactVersion; - } - - public String getArtifactDescription() { - return artifactDescription; - } - - public void setArtifactDescription(String artifactDescription) { - this.artifactDescription = artifactDescription; - } - - public Integer getInternalVersion() { - return internalVersion; - } - - public void setInternalVersion(Integer internalVersion) { - this.internalVersion = internalVersion; - } - - public Date getCreatedDate() { - return createdDate; - } - - public void setCreatedDate(Date createdDate) { - this.createdDate = createdDate; - } - - public String getArtifactName() { - return artifactName; - } - - public void setArtifactName(String artifactName) { - this.artifactName = artifactName; - } - - public String getPublished() { - return published; - } - - public void setPublished(String published) { - this.published = published; - } - - public String getUpdatedBy() { - return updatedBy; - } - - public void setUpdatedBy(String updatedBy) { - this.updatedBy = updatedBy; - } - - public String getTags() { - return tags; - } - - public void setTags(String tags) { - this.tags = tags; - } - - public List getConfigModelContents() { - return configModelContents; - } - - public void setConfigModelContents(List configModelContents) { - this.configModelContents = configModelContents; - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/domain/ConfigModelContent.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/domain/ConfigModelContent.java deleted file mode 100644 index cba2570ea..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/domain/ConfigModelContent.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.domain; - -import java.util.Date; -import com.fasterxml.jackson.annotation.JsonFormat; - -public class ConfigModelContent { - - private Long id; - private String name; - private String contentType; - private String description; - private String content; - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") - private Date creationDate = new Date(); - - @Override - public String toString() { - StringBuilder buffer = new StringBuilder("["); - buffer.append("id = " + id); - buffer.append(", name = " + name); - buffer.append(", type = " + contentType); - buffer.append("]"); - return buffer.toString(); - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getContentType() { - return contentType; - } - - public void setContentType(String type) { - this.contentType = type; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getContent() { - return content; - } - - public void setContent(String content) { - this.content = content; - } - - public Date getCreationDate() { - return creationDate; - } - - public void setCreationDate(Date creationDate) { - this.creationDate = creationDate; - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/domain/ResourceDictionary.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/domain/ResourceDictionary.java deleted file mode 100644 index d97d3a395..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/domain/ResourceDictionary.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.domain; - -import com.fasterxml.jackson.databind.JsonNode; -import java.io.Serializable; -import java.util.Date; - -public class ResourceDictionary implements Serializable { - private static final long serialVersionUID = 1L; - private Long id; - private String name; - private String dataType; - private String entrySchema; - private JsonNode definition; - private String description; - private String tags; - private Date creationDate; - private String updatedBy; - - @Override - public String toString() { - StringBuilder buffer = new StringBuilder("["); - buffer.append("name = " + name); - buffer.append(", dataType = " + dataType); - buffer.append(", entrySchema = " + entrySchema); - buffer.append(", creationDate = " + creationDate); - buffer.append("]"); - return buffer.toString(); - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getDataType() { - return dataType; - } - - public void setDataType(String dataType) { - this.dataType = dataType; - } - - public String getEntrySchema() { - return entrySchema; - } - - public void setEntrySchema(String entrySchema) { - this.entrySchema = entrySchema; - } - - public JsonNode getDefinition() { - return definition; - } - - public void setDefinition(JsonNode definition) { - this.definition = definition; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getTags() { - return tags; - } - - public void setTags(String tags) { - this.tags = tags; - } - - public Date getCreationDate() { - return creationDate; - } - - public void setCreationDate(Date creationDate) { - this.creationDate = creationDate; - } - - public String getUpdatedBy() { - return updatedBy; - } - - public void setUpdatedBy(String updatedBy) { - this.updatedBy = updatedBy; - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/service/ComponentNode.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/service/ComponentNode.java deleted file mode 100644 index 92ccee223..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/service/ComponentNode.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.service; - -import java.util.Map; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; - -public interface ComponentNode extends SvcLogicJavaPlugin { - - public Boolean preCondition(Map inParams, SvcLogicContext ctx, Map componentContext) - throws SvcLogicException; - - public void preProcess(Map inParams, SvcLogicContext ctx, Map componentContext) - throws SvcLogicException; - - public void process(Map inParams, SvcLogicContext ctx) throws SvcLogicException; - - public void process(Map inParams, SvcLogicContext ctx, Map componentContext) - throws SvcLogicException; - - public void postProcess(Map inParams, SvcLogicContext ctx, Map componentContext) - throws SvcLogicException; - -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/service/ComponentNodeDelegate.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/service/ComponentNodeDelegate.java deleted file mode 100644 index 4b9743fb7..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/service/ComponentNodeDelegate.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.service; - -import java.util.Map; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -public class ComponentNodeDelegate implements SvcLogicJavaPlugin { - - private static EELFLogger logger = EELFManager.getInstance().getLogger(ComponentNodeDelegate.class); - private ComponentNodeService componentNodeService; - - public ComponentNodeDelegate(ComponentNodeService componentNodeService) { - logger.info("{} Constructor Initiated", "ComponentNodeDelegate"); - this.componentNodeService = componentNodeService; - - } - - public void process(Map inParams, SvcLogicContext ctx) throws SvcLogicException { - this.componentNodeService.process(inParams, ctx, null); - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/service/ComponentNodeService.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/service/ComponentNodeService.java deleted file mode 100644 index 12efc6569..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/service/ComponentNodeService.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.service; - -import java.util.Map; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; - -public interface ComponentNodeService { - - public void process(Map inParams, SvcLogicContext ctx, Map componentContext) - throws SvcLogicException; - - public ComponentNode getComponentNodeInterface(String pluginName, String componentType) throws SvcLogicException; - - public ComponentNode getComponentNode(SvcLogicContext ctx, String selectorName) throws SvcLogicException; -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/service/ComponentNodeServiceImpl.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/service/ComponentNodeServiceImpl.java deleted file mode 100644 index df0dae10f..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/service/ComponentNodeServiceImpl.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.service; - -import java.util.HashMap; -import java.util.Map; -import org.apache.commons.lang3.StringUtils; -import org.onap.ccsdk.features.data.adaptor.DataAdaptorConstants; -import org.onap.ccsdk.features.data.adaptor.domain.TransactionLog; -import org.onap.ccsdk.features.data.adaptor.service.ConfigResourceService; -import org.onap.ccsdk.features.model.ConfigModelConstant; -import org.onap.ccsdk.features.model.data.InterfaceAssignment; -import org.onap.ccsdk.features.model.data.NodeTemplate; -import org.onap.ccsdk.features.model.utils.TransformationUtils; -import org.onap.ccsdk.features.rest.adaptor.service.ConfigRestAdaptorService; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -public class ComponentNodeServiceImpl implements ComponentNodeService { - - private static EELFLogger logger = EELFManager.getInstance().getLogger(ComponentNodeServiceImpl.class); - - private BundleContext bcontext; - private ConfigResourceService configResourceService; - private ConfigModelService configModelService; - - public ComponentNodeServiceImpl(BundleContext blueprintBundleContext, ConfigResourceService configResourceService, - ConfigRestAdaptorService configRestAdaptorService) { - logger.info("{} Constructor Initiated", "ComponentNodeServiceImpl"); - this.bcontext = blueprintBundleContext; - this.configResourceService = configResourceService; - this.configModelService = new ConfigModelServiceImpl(configRestAdaptorService); - } - - @Override - public void process(Map inParams, SvcLogicContext ctx, Map componentContext) - throws SvcLogicException { - String requestId = null; - String selector = null; - try { - selector = inParams.get(ConfigModelConstant.PROPERTY_SELECTOR); - requestId = ctx.getAttribute(ConfigModelConstant.PROPERTY_REQUEST_ID); - - logger.info("Component execution started with input params ({})", inParams); - configModelService.assignInParamsFromModel(ctx, inParams); - - String currentInterface = inParams.get(ConfigModelConstant.PROPERTY_CURRENT_INTERFACE); - String currentNodeDerivedFrom = inParams.get(ConfigModelConstant.PROPERTY_CURRENT_NODETYPE_DERIVED_FROM); - - configResourceService.save(new TransactionLog(requestId, DataAdaptorConstants.LOG_MESSAGE_TYPE_COMPONENT, - String.format("Executing Component (%s) derived from (%s) with Params : (%s) ", currentInterface, - currentNodeDerivedFrom, inParams))); - - ComponentNode handler = getComponentNodeInterface(currentInterface, currentNodeDerivedFrom); - - if (handler == null) { - throw new SvcLogicException( - String.format("Could not find Component for Interface %s", currentInterface)); - } - if (componentContext == null) { - componentContext = new HashMap<>(); - } - - logger.debug("Executing component ({})", currentInterface); - - if (handler.preCondition(inParams, ctx, componentContext)) { - handler.preProcess(inParams, ctx, componentContext); - handler.process(inParams, ctx, componentContext); - handler.postProcess(inParams, ctx, componentContext); - logger.debug("Executed component ({}) successfully.", currentInterface); - configResourceService - .save(new TransactionLog(requestId, DataAdaptorConstants.LOG_MESSAGE_TYPE_COMPONENT, - String.format("Component (%s) executed successfully. ", currentInterface))); - - ctx.setAttribute(selector + ConfigModelConstant.PROPERTY_DOT_STATUS, - ConfigModelConstant.STATUS_SUCCESS); - } else { - logger.info("Skipped component execution ({})", handler.getClass()); - configResourceService - .save(new TransactionLog(requestId, DataAdaptorConstants.LOG_MESSAGE_TYPE_COMPONENT, - String.format("Skipping component (%s) execution.", handler.getClass()))); - ctx.setAttribute(selector + ConfigModelConstant.PROPERTY_DOT_STATUS, - ConfigModelConstant.STATUS_SKIPPED); - } - - configModelService.assignOutParamsFromModel(ctx, inParams); - ctx.setStatus(ConfigModelConstant.STATUS_SUCCESS); - } catch (Exception e) { - logger.error(String.format("Failed in component (%s) execution for request id (%s) with error %s", selector, - requestId, e.getMessage())); - configResourceService.save(new TransactionLog(requestId, DataAdaptorConstants.LOG_MESSAGE_TYPE_COMPONENT, - String.format("Failed in component (%s) execution for request id (%s) with error %s", selector, - requestId, e.getMessage()))); - - ctx.setAttribute(selector + ConfigModelConstant.PROPERTY_DOT_STATUS, ConfigModelConstant.STATUS_FAILURE); - ctx.setAttribute(selector + ConfigModelConstant.PROPERTY_DOT_ERROR_MESSAGE, e.getMessage()); - ctx.setAttribute(ConfigModelConstant.PROPERTY_ERROR_MESSAGE, e.getMessage()); - ctx.setStatus(ConfigModelConstant.STATUS_FAILURE); - throw new SvcLogicException(e.getMessage(), e); - } - } - - @Override - public ComponentNode getComponentNodeInterface(String pluginName, String componentType) throws SvcLogicException { - - logger.info("Searching for component node plugin ({}) component type ({})", pluginName, componentType); - - if (StringUtils.isBlank(pluginName)) { - throw new SvcLogicException( - String.format("Could not get Interface Name from Service Template : %s ", pluginName)); - } - - pluginName = pluginName.replace("-", "."); - ServiceReference sref = bcontext.getServiceReference(pluginName); - - if (sref == null) { - throw new SvcLogicException( - String.format("Could not find service reference object for plugin %s", pluginName)); - } - return (ComponentNode) bcontext.getService(sref); - } - - @Override - public ComponentNode getComponentNode(SvcLogicContext ctx, String componentKey) throws SvcLogicException { - - if (StringUtils.isBlank(componentKey)) { - logger.warn("Can't get node template content for a component key ({})", componentKey); - return null; - } - - String nodeTemplateContent = ctx.getAttribute(ConfigModelConstant.PROPERTY_NODE_TEMPLATES_DOT + componentKey); - logger.info("Processing component template : ({})", nodeTemplateContent); - - if (StringUtils.isBlank(nodeTemplateContent)) { - logger.warn("Couldn't get node template content for component key ({})", componentKey); - return null; - } - - NodeTemplate nodeTemplate = TransformationUtils.readValue(nodeTemplateContent, NodeTemplate.class); - if (nodeTemplate == null || StringUtils.isBlank(nodeTemplate.getType())) { - logger.warn("Failed to convert content ({}) to node template.", nodeTemplateContent); - return null; - } - - ComponentNode componentNode = null; - for (Map.Entry nodeTemplateInterface : nodeTemplate.getInterfaces().entrySet()) { - if (nodeTemplateInterface != null && nodeTemplateInterface.getValue() != null) { - String pluginName = nodeTemplateInterface.getKey(); - componentNode = getComponentNodeInterface(pluginName, ConfigModelConstant.MODEL_TYPE_NODE_COMPONENT); - } - } - return componentNode; - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/service/ConfigBlueprintService.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/service/ConfigBlueprintService.java deleted file mode 100644 index 701dffce9..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/service/ConfigBlueprintService.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.service; - -import java.util.List; -import java.util.Map; -import org.apache.commons.lang3.StringUtils; -import org.onap.ccsdk.features.model.ConfigModelConstant; -import org.onap.ccsdk.features.model.domain.ConfigModel; -import org.onap.ccsdk.features.model.domain.ConfigModelContent; -import org.onap.ccsdk.features.model.utils.PrepareContextUtils; -import org.onap.ccsdk.features.rest.adaptor.ConfigRestAdaptorConstants; -import org.onap.ccsdk.features.rest.adaptor.ConfigRestAdaptorException; -import org.onap.ccsdk.features.rest.adaptor.service.ConfigRestAdaptorService; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -public class ConfigBlueprintService { - - private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigBlueprintService.class); - - private final ConfigRestAdaptorService configRestAdaptorService; - - public ConfigBlueprintService(ConfigRestAdaptorService configRestAdaptorService) { - this.configRestAdaptorService = configRestAdaptorService; - } - - public Map prepareContext(Map context, String input, String serviceTemplateName, - String serviceTemplateVersion) throws SvcLogicException { - try { - PrepareContextUtils prepareContextUtils = new PrepareContextUtils(); - String serviceTemplateContent = getServiceModel(context, serviceTemplateName, serviceTemplateVersion); - - if (StringUtils.isBlank(serviceTemplateContent)) { - throw new SvcLogicException(String.format("Failed to get the Service Template (%s), version (%s)", - serviceTemplateName, serviceTemplateVersion)); - } - - return prepareContextUtils.prepareContext(context, input, serviceTemplateContent); - } catch (Exception e) { - throw new SvcLogicException(e.getMessage(), e); - } - } - - @SuppressWarnings("squid:S3776") - private String getServiceModel(Map context, String serviceTemplateName, - String serviceTemplateVersion) throws SvcLogicException, ConfigRestAdaptorException { - String content = null; - - logger.info("Getting service template ({}) of version ({}) ", serviceTemplateName, serviceTemplateVersion); - - String path = "config-model/by-name/" + serviceTemplateName + "/version/" + serviceTemplateVersion; - - ConfigModel configModel = configRestAdaptorService - .getResource(ConfigRestAdaptorConstants.SELECTOR_MODEL_SERVICE, path, ConfigModel.class); - - if (configModel == null || configModel.getConfigModelContents() == null - || configModel.getConfigModelContents().isEmpty()) { - throw new SvcLogicException("Service template model is missing for service template name (" - + serviceTemplateName + "), service template version (" + serviceTemplateVersion + ") "); - } else { - if (configModel.getPublished() == null || !configModel.getPublished().equalsIgnoreCase("Y")) { - throw new SvcLogicException(String.format( - "Service template model is not published for service template (%s) ", serviceTemplateName)); - } - - List configModelContents = configModel.getConfigModelContents(); - for (ConfigModelContent configModelContent : configModelContents) { - if (configModelContent != null) { - if (ConfigModelConstant.MODEL_CONTENT_TYPE_TOSCA_JSON.equals(configModelContent.getContentType())) { - content = configModelContent.getContent(); - } else if (ConfigModelConstant.MODEL_CONTENT_TYPE_TEMPLATE - .equals(configModelContent.getContentType())) { - context.put(ConfigModelConstant.PROPERTY_NODE_TEMPLATES_DOT + configModelContent.getName() - + ".content", configModelContent.getContent()); - } - } - } - logger.trace("Service model data : {} ", content); - } - return content; - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/service/ConfigModelNode.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/service/ConfigModelNode.java deleted file mode 100644 index cb652bd68..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/service/ConfigModelNode.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.service; - -import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; - -public class ConfigModelNode implements SvcLogicJavaPlugin { - -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/service/ConfigModelService.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/service/ConfigModelService.java deleted file mode 100644 index 38ade14de..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/service/ConfigModelService.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.service; - -import java.util.List; -import java.util.Map; -import org.onap.ccsdk.features.model.data.ServiceTemplate; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; - -public interface ConfigModelService { - - public Boolean validateServiceTemplate(ServiceTemplate serviceTemplate) throws SvcLogicException; - - public Map prepareContext(Map context, String input, String serviceTemplateName, - String serviceTemplateVersion) throws SvcLogicException; - - public Map prepareContext(Map context, String input, String serviceTemplateContent) - throws SvcLogicException; - - public Map convertJson2properties(Map context, String jsonContent, - List blockKeys) throws SvcLogicException; - - public Map convertServiceTemplate2Properties(String serviceTemplateContent, - final Map context) throws SvcLogicException; - - public Map convertServiceTemplate2Properties(ServiceTemplate serviceTemplate, - final Map context) throws SvcLogicException; - - public SvcLogicContext assignInParamsFromModel(final SvcLogicContext context, final Map inParams) - throws SvcLogicException; - - public SvcLogicContext assignOutParamsFromModel(final SvcLogicContext context, final Map inParams) - throws SvcLogicException; - - public String getNodeTemplateContent(final SvcLogicContext context, String templateName) throws SvcLogicException; - - public String getNodeTemplateMapping(final SvcLogicContext context, String templateName) throws SvcLogicException; - -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/service/ConfigModelServiceImpl.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/service/ConfigModelServiceImpl.java deleted file mode 100644 index 231f76af9..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/service/ConfigModelServiceImpl.java +++ /dev/null @@ -1,244 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.service; - -import java.util.List; -import java.util.Map; -import org.apache.commons.lang3.StringUtils; -import org.onap.ccsdk.features.model.ConfigModelConstant; -import org.onap.ccsdk.features.model.ConfigModelException; -import org.onap.ccsdk.features.model.data.CapabilityAssignment; -import org.onap.ccsdk.features.model.data.NodeTemplate; -import org.onap.ccsdk.features.model.data.NodeType; -import org.onap.ccsdk.features.model.data.ServiceTemplate; -import org.onap.ccsdk.features.model.utils.NodePropertyUtils; -import org.onap.ccsdk.features.model.utils.PrepareContextUtils; -import org.onap.ccsdk.features.model.utils.ServiceTemplateUtils; -import org.onap.ccsdk.features.model.utils.TransformationUtils; -import org.onap.ccsdk.features.model.validator.ServiceTemplateValidator; -import org.onap.ccsdk.features.rest.adaptor.service.ConfigRestAdaptorService; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -public class ConfigModelServiceImpl implements ConfigModelService { - - private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigModelServiceImpl.class); - private static final String CLASS_NAME = "ConfigModelServiceImpl"; - - private final ConfigRestAdaptorService configRestAdaptorService; - - public ConfigModelServiceImpl(ConfigRestAdaptorService configRestAdaptorService) { - logger.info("{} Constuctor Initated...", CLASS_NAME); - this.configRestAdaptorService = configRestAdaptorService; - } - - @Override - public Boolean validateServiceTemplate(ServiceTemplate serviceTemplate) throws SvcLogicException { - try { - ServiceTemplateValidator serviceTemplateValidator = new ServiceTemplateValidator(); - return serviceTemplateValidator.validateServiceTemplate(serviceTemplate); - } catch (ConfigModelException e) { - throw new SvcLogicException(e.getMessage()); - } - } - - @Override - public Map prepareContext(Map context, String input, String serviceTemplateName, - String serviceTemplateVersion) throws SvcLogicException { - - ConfigBlueprintService configBlueprintService = new ConfigBlueprintService(configRestAdaptorService); - return configBlueprintService.prepareContext(context, input, serviceTemplateName, serviceTemplateVersion); - } - - @Override - public Map prepareContext(Map context, String input, String serviceTemplateContent) - throws SvcLogicException { - try { - PrepareContextUtils prepareContextUtils = new PrepareContextUtils(); - return prepareContextUtils.prepareContext(context, input, serviceTemplateContent); - } catch (Exception e) { - throw new SvcLogicException(e.getMessage()); - } - } - - @Override - public Map convertJson2properties(Map context, String jsonContent, - List blockKeys) throws SvcLogicException { - try { - return TransformationUtils.convertJson2Properties(context, jsonContent, blockKeys); - } catch (Exception e) { - throw new SvcLogicException(e.getMessage()); - } - } - - @Override - public Map convertServiceTemplate2Properties(String serviceTemplateContent, - final Map context) throws SvcLogicException { - try { - ServiceTemplateUtils serviceTemplateUtils = new ServiceTemplateUtils(); - return serviceTemplateUtils.convertServiceTemplate2Properties(serviceTemplateContent, context); - } catch (Exception e) { - throw new SvcLogicException(e.getMessage()); - } - } - - @Override - public Map convertServiceTemplate2Properties(ServiceTemplate serviceTemplate, - final Map context) throws SvcLogicException { - try { - ServiceTemplateUtils serviceTemplateUtils = new ServiceTemplateUtils(); - return serviceTemplateUtils.convertServiceTemplate2Properties(serviceTemplate, context); - } catch (Exception e) { - throw new SvcLogicException(e.getMessage()); - } - } - - @SuppressWarnings("squid:S3776") - @Override - public SvcLogicContext assignInParamsFromModel(final SvcLogicContext context, final Map inParams) - throws SvcLogicException { - logger.debug("Processing component input param ({})", inParams); - try { - if (context != null && inParams != null && inParams.containsKey(ConfigModelConstant.PROPERTY_SELECTOR)) { - String componentKey = inParams.get(ConfigModelConstant.PROPERTY_SELECTOR); - if (StringUtils.isNotBlank(componentKey)) { - String nodeTemplateContent = - context.getAttribute(ConfigModelConstant.PROPERTY_NODE_TEMPLATES_DOT + componentKey); - logger.info("Processing node template content ({})", nodeTemplateContent); - if (StringUtils.isNotBlank(nodeTemplateContent)) { - NodeTemplate nodeTemplate = - TransformationUtils.readValue(nodeTemplateContent, NodeTemplate.class); - if (nodeTemplate != null && StringUtils.isNotBlank(nodeTemplate.getType())) { - String nodeTypeContent = context - .getAttribute(ConfigModelConstant.PROPERTY_NODE_TYPES_DOT + nodeTemplate.getType()); - NodeType nodetype = TransformationUtils.readValue(nodeTypeContent, NodeType.class); - if (nodetype != null) { - inParams.put(ConfigModelConstant.PROPERTY_CURRENT_NODETYPE_DERIVED_FROM, - nodetype.getDerivedFrom()); - NodePropertyUtils nodePropertyUtils = new NodePropertyUtils(context, inParams); - nodePropertyUtils.assignInParamsFromModel(nodetype, nodeTemplate); - } else { - throw new SvcLogicException( - String.format("Failed to get node type (%s) for node template (%s).", - nodeTemplate.getType(), componentKey)); - } - - } else { - throw new SvcLogicException(String - .format("Failed to convert content (%s) to node template.", nodeTemplateContent)); - } - } else { - throw new SvcLogicException(String - .format("Couldn't get node template content for component key (%s).", componentKey)); - } - } else { - throw new SvcLogicException( - String.format("Couldn't get component key (prefix) from inparam (%s)", inParams)); - } - } - } catch (Exception e) { - throw new SvcLogicException(e.getMessage()); - } - return context; - } - - @Override - public SvcLogicContext assignOutParamsFromModel(final SvcLogicContext context, final Map inParams) - throws SvcLogicException { - try { - if (context != null && inParams != null && inParams.containsKey(ConfigModelConstant.PROPERTY_SELECTOR)) { - String componentKey = inParams.get(ConfigModelConstant.PROPERTY_SELECTOR); - logger.info("Processing component output for prefix key ({})", componentKey); - if (StringUtils.isNotBlank(componentKey)) { - String nodeTemplateContent = - context.getAttribute(ConfigModelConstant.PROPERTY_NODE_TEMPLATES_DOT + componentKey); - if (StringUtils.isNotBlank(nodeTemplateContent)) { - NodeTemplate nodeTemplate = - TransformationUtils.readValue(nodeTemplateContent, NodeTemplate.class); - if (nodeTemplate != null && StringUtils.isNotBlank(nodeTemplate.getType())) { - String nodeTypeContent = context - .getAttribute(ConfigModelConstant.PROPERTY_NODE_TYPES_DOT + nodeTemplate.getType()); - NodeType nodetype = TransformationUtils.readValue(nodeTypeContent, NodeType.class); - NodePropertyUtils nodePropertyUtils = new NodePropertyUtils(context, inParams); - nodePropertyUtils.assignOutParamsFromModel(nodetype, nodeTemplate); - } - } - } - } - } catch (Exception e) { - throw new SvcLogicException(e.getMessage()); - } - return context; - } - - @Override - public String getNodeTemplateContent(final SvcLogicContext context, String templateName) throws SvcLogicException { - String content = null; - try { - if (context != null && StringUtils.isNotBlank(templateName)) { - logger.info("Processing Artifact Node Template for content : ({})", templateName); - content = context - .getAttribute(ConfigModelConstant.PROPERTY_NODE_TEMPLATES_DOT + templateName + ".content"); - } - } catch (Exception e) { - throw new SvcLogicException(e.getMessage()); - } - return content; - } - - @SuppressWarnings("squid:S3776") - @Override - public String getNodeTemplateMapping(final SvcLogicContext context, String templateName) throws SvcLogicException { - String mapping = null; - try { - if (context != null && StringUtils.isNotBlank(templateName)) { - logger.info("Processing artifact node template for mapping : ({})", templateName); - if (StringUtils.isNotBlank(templateName)) { - String nodeTemplateContent = - context.getAttribute(ConfigModelConstant.PROPERTY_NODE_TEMPLATES_DOT + templateName); - if (StringUtils.isNotBlank(nodeTemplateContent)) { - - NodeTemplate nodeTemplate = - TransformationUtils.readValue(nodeTemplateContent, NodeTemplate.class); - - if (nodeTemplate != null && nodeTemplate.getCapabilities() != null && nodeTemplate - .getCapabilities().containsKey(ConfigModelConstant.CAPABILITY_PROPERTY_MAPPING)) { - - CapabilityAssignment capability = - nodeTemplate.getCapabilities().get(ConfigModelConstant.CAPABILITY_PROPERTY_MAPPING); - if (capability.getProperties() != null) { - List mappingList = (List) capability.getProperties() - .get(ConfigModelConstant.CAPABILITY_PROPERTY_MAPPING); - if (mappingList != null) { - mapping = TransformationUtils.getJson(mappingList); - } - - } - } - } - } - } - } catch (Exception e) { - throw new SvcLogicException(e.getMessage()); - } - return mapping; - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/utils/ExpressionUtils.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/utils/ExpressionUtils.java deleted file mode 100644 index cdc8fc330..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/utils/ExpressionUtils.java +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.utils; - -import java.io.IOException; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import org.apache.commons.lang3.StringUtils; -import org.onap.ccsdk.features.model.ConfigModelConstant; -import org.onap.ccsdk.features.model.data.PropertyDefinition; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ObjectNode; - -public class ExpressionUtils { - private static EELFLogger logger = EELFManager.getInstance().getLogger(ExpressionUtils.class); - - private final SvcLogicContext context; - private final Map inParams; - - public ExpressionUtils(final SvcLogicContext context, final Map inParams) { - this.context = context; - this.inParams = inParams; - } - - public void populatePropertAssignmentsWithPrefix(String prefix, Map typeProperties, - Map templateProperties) throws IOException { - if (typeProperties != null && templateProperties != null) { - ObjectMapper mapper = new ObjectMapper(); - String templatejsonContent = mapper.writeValueAsString(templateProperties); - logger.debug("Expression inputs ({}).", templatejsonContent); - - JsonNode rootArray = mapper.readTree(templatejsonContent); - processJsonExpression(rootArray); - if (rootArray != null) { - Map prefixParams = new HashMap<>(); - TransformationUtils.convertJson2RootProperties(prefixParams, rootArray); - logger.info("Resolved inputs ({}).", rootArray); - prefixParams.forEach((key, value) -> { - this.inParams.put(prefix + "." + key, value); - }); - } - } - } - - public void populatePropertAssignments(Map typeProperties, - Map templateProperties) throws IOException { - if (typeProperties != null && templateProperties != null) { - ObjectMapper mapper = new ObjectMapper(); - String templatejsonContent = mapper.writeValueAsString(templateProperties); - logger.info("Expression inputs ({}).", templatejsonContent); - - JsonNode rootArray = mapper.readTree(templatejsonContent); - processJsonExpression(rootArray); - TransformationUtils.convertJson2RootProperties(this.inParams, rootArray); - logger.info("Resolved inputs ({}).", rootArray); - - } - } - - public void populateOutPropertAssignments(Map typeProperties, - Map templateProperties) throws IOException { - if (typeProperties != null && templateProperties != null) { - ObjectMapper mapper = new ObjectMapper(); - String templatejsonContent = mapper.writeValueAsString(templateProperties); - logger.info("Expression outputs ({}).", templatejsonContent); - - JsonNode rootArray = mapper.readTree(templatejsonContent); - processJsonExpression(rootArray); - logger.info("Resolved outputs ({}).", rootArray); - } - } - - public void processJsonExpression(JsonNode rootArray) throws IOException { - if (rootArray != null) { - Iterator> fields = rootArray.fields(); - while (fields.hasNext()) { - Map.Entry entry = fields.next(); - processJsonNode(rootArray, entry.getKey(), entry.getValue()); - } - } - } - - private void processJsonNode(JsonNode parentNode, String nodeName, JsonNode node) throws IOException { - if (node == null) { - // Do Nothing - } else if (node.isArray()) { - String[] a = new String[node.size()]; - - for (int i = 0; i < a.length; i++) { - processJsonNode(null, null, node.get(i)); - } - } else if (node.isObject()) { - - Iterator> fields = node.fields(); - while (fields.hasNext()) { - Map.Entry entry = fields.next(); - processJsonNode(node, entry.getKey(), entry.getValue()); - } - } else if (node.isTextual()) { - boolean expression = checkExpressionContent(node.asText()); - if (expression) { - processExpressionContent(parentNode, nodeName, node); - } - } - } - - private boolean checkExpressionContent(String content) { - return (StringUtils.isNotBlank(content) && (content.contains(ConfigModelConstant.EXPRESSION_GET_INPUT) - || content.contains(ConfigModelConstant.EXPRESSION_GET_ATTRIBUTE) - || content.contains(ConfigModelConstant.EXPRESSION_SET_VALUE))); - } - - @SuppressWarnings("squid:S3776") - private void processExpressionContent(JsonNode parentNode, String nodeName, JsonNode node) throws IOException { - - if (node != null && StringUtils.isNotBlank(node.asText())) { - String content = node.asText(); - ObjectMapper mapper = new ObjectMapper(); - Map expressionMap = mapper.readValue(content, Map.class); - boolean isExpressionNode = false; - - if (expressionMap != null) { - String expressionValue = null; - String expressionKey = null; - - if (expressionMap.containsKey(ConfigModelConstant.EXPRESSION_GET_INPUT)) { - isExpressionNode = true; - expressionKey = expressionMap.get(ConfigModelConstant.EXPRESSION_GET_INPUT); - expressionValue = resolveGetInputExpression(expressionKey, context); - if (expressionValue == null) { - expressionValue = resolveGetInputExpression("inputs." + expressionKey + ".default", context); - } - } else if (expressionMap.containsKey(ConfigModelConstant.EXPRESSION_GET_ATTRIBUTE)) { - isExpressionNode = true; - expressionValue = - context.getAttribute(expressionMap.get(ConfigModelConstant.EXPRESSION_GET_ATTRIBUTE)); - } else if (expressionMap.containsKey(ConfigModelConstant.EXPRESSION_SET_VALUE)) { - isExpressionNode = true; - expressionKey = expressionMap.get(ConfigModelConstant.EXPRESSION_SET_VALUE); - expressionValue = context.getAttribute(expressionKey); - - if (StringUtils.isNotBlank(expressionKey)) { - context.setAttribute(expressionKey, expressionValue); - } - } - - if (isExpressionNode && expressionValue == null) { - ((ObjectNode) parentNode).put(nodeName, ""); - } - if (StringUtils.isNotBlank(expressionValue)) { - if (expressionValue.trim().startsWith("[") || expressionValue.trim().startsWith("{")) { - JsonNode valueNode = mapper.readTree(expressionValue); - ((ObjectNode) parentNode).put(nodeName, valueNode); - } else { - ((ObjectNode) parentNode).put(nodeName, expressionValue); - } - } - logger.debug("expression ({}), expression key ({}), expression Value ({})", expressionMap, - expressionKey, expressionValue); - } - } - } - - private String resolveGetInputExpression(String key, final SvcLogicContext context) { - if (StringUtils.isNotBlank(key) && context != null) { - return context.getAttribute(key); - } - return null; - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/utils/JsonParserUtils.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/utils/JsonParserUtils.java deleted file mode 100644 index d9cc3507f..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/utils/JsonParserUtils.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.utils; - -import static com.jayway.jsonpath.JsonPath.using; -import java.util.List; -import com.fasterxml.jackson.databind.JsonNode; -import com.jayway.jsonpath.Configuration; -import com.jayway.jsonpath.Option; -import com.jayway.jsonpath.spi.json.JacksonJsonNodeJsonProvider; -import com.jayway.jsonpath.spi.mapper.JacksonMappingProvider; - -@SuppressWarnings("squid:S1118") -public class JsonParserUtils { - - public static final Configuration JACKSON_JSON_NODE_CONFIGURATION = Configuration.builder() - .mappingProvider(new JacksonMappingProvider()).jsonProvider(new JacksonJsonNodeJsonProvider()).build(); - - public static final Configuration PATH_CONFIGURATION = Configuration.builder().options(Option.AS_PATH_LIST).build(); - - public static List paths(String jsonContent, String expression) { - return using(PATH_CONFIGURATION).parse(jsonContent).read(expression); - } - - public static List paths(JsonNode jsonNode, String expression) { - return paths(jsonNode.toString(), expression); - } - - public static JsonNode parse(String jsonContent, String expression) { - return using(JACKSON_JSON_NODE_CONFIGURATION).parse(jsonContent).read(expression); - } - - public static JsonNode parse(JsonNode jsonNode, String expression) { - return parse(jsonNode.toString(), expression); - } - - public static JsonNode parseNSet(String jsonContent, String expression, JsonNode value) { - return using(JACKSON_JSON_NODE_CONFIGURATION).parse(jsonContent).set(expression, value).json(); - } - - public static JsonNode parseNSet(JsonNode jsonNode, String expression, JsonNode valueNode) { - return parseNSet(jsonNode.toString(), expression, valueNode); - } -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/utils/JsonUtils.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/utils/JsonUtils.java deleted file mode 100644 index 2db4b4875..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/utils/JsonUtils.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.utils; - -import org.onap.ccsdk.features.model.ValidTypes; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.NullNode; -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * JsonUtils.java Purpose: Provide Configuration Generator JsonUtils Information - * - * @version 1.0 - */ -public class JsonUtils { - - private JsonUtils() { - - } - - public static void populatePrimitiveValues(String key, Object value, String primitiveType, ObjectNode objectNode) { - if (ValidTypes.DATA_TYPE_BOOLEAN.equals(primitiveType)) { - objectNode.put(key, (Boolean) value); - } else if (ValidTypes.DATA_TYPE_INTEGER.equals(primitiveType)) { - objectNode.put(key, (Integer) value); - } else if (ValidTypes.DATA_TYPE_FLOAT.equals(primitiveType)) { - objectNode.put(key, (Float) value); - } else if (ValidTypes.DATA_TYPE_TIMESTAMP.equals(primitiveType)) { - objectNode.put(key, (String) value); - } else { - objectNode.put(key, (String) value); - } - } - - public static void populatePrimitiveValues(Object value, String primitiveType, ArrayNode objectNode) { - if (ValidTypes.DATA_TYPE_BOOLEAN.equals(primitiveType)) { - objectNode.add((Boolean) value); - } else if (ValidTypes.DATA_TYPE_INTEGER.equals(primitiveType)) { - objectNode.add((Integer) value); - } else if (ValidTypes.DATA_TYPE_FLOAT.equals(primitiveType)) { - objectNode.add((Float) value); - } else if (ValidTypes.DATA_TYPE_TIMESTAMP.equals(primitiveType)) { - objectNode.add((String) value); - } else { - objectNode.add((String) value); - } - } - - public static void populatePrimitiveDefaultValues(String key, String primitiveType, ObjectNode objectNode) { - if (ValidTypes.DATA_TYPE_BOOLEAN.equals(primitiveType)) { - objectNode.put(key, false); - } else if (ValidTypes.DATA_TYPE_INTEGER.equals(primitiveType)) { - objectNode.put(key, 0); - } else if (ValidTypes.DATA_TYPE_FLOAT.equals(primitiveType)) { - objectNode.put(key, 0.0); - } else { - objectNode.put(key, ""); - } - } - - public static void populatePrimitiveDefaultValuesForArrayNode(String primitiveType, ArrayNode arrayNode) { - if (ValidTypes.DATA_TYPE_BOOLEAN.equals(primitiveType)) { - arrayNode.add(false); - } else if (ValidTypes.DATA_TYPE_INTEGER.equals(primitiveType)) { - arrayNode.add(0); - } else if (ValidTypes.DATA_TYPE_FLOAT.equals(primitiveType)) { - arrayNode.add(0.0); - } else { - arrayNode.add(""); - } - } - - public static void populateJsonNodeValues(String key, JsonNode nodeValue, String type, ObjectNode objectNode) { - if (nodeValue == null || nodeValue instanceof NullNode) { - objectNode.put(key, nodeValue); - } else if (ValidTypes.getPrimitivePropertType().contains(type)) { - if (ValidTypes.DATA_TYPE_BOOLEAN.equals(type)) { - objectNode.put(key, nodeValue.asBoolean()); - } else if (ValidTypes.DATA_TYPE_INTEGER.equals(type)) { - objectNode.put(key, nodeValue.asInt()); - } else if (ValidTypes.DATA_TYPE_FLOAT.equals(type)) { - objectNode.put(key, nodeValue.floatValue()); - } else if (ValidTypes.DATA_TYPE_TIMESTAMP.equals(type)) { - objectNode.put(key, nodeValue.asText()); - } else { - objectNode.put(key, nodeValue.asText()); - } - } else { - objectNode.set(key, nodeValue); - } - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/utils/NodePropertyUtils.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/utils/NodePropertyUtils.java deleted file mode 100644 index 0feb8b5a7..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/utils/NodePropertyUtils.java +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.utils; - -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import org.apache.commons.lang3.StringUtils; -import org.onap.ccsdk.features.model.ConfigModelConstant; -import org.onap.ccsdk.features.model.data.CapabilityAssignment; -import org.onap.ccsdk.features.model.data.CapabilityDefinition; -import org.onap.ccsdk.features.model.data.InterfaceAssignment; -import org.onap.ccsdk.features.model.data.InterfaceDefinition; -import org.onap.ccsdk.features.model.data.NodeTemplate; -import org.onap.ccsdk.features.model.data.NodeType; -import org.onap.ccsdk.features.model.data.OperationAssignment; -import org.onap.ccsdk.features.model.data.OperationDefinition; -import org.onap.ccsdk.features.model.data.PropertyDefinition; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -public class NodePropertyUtils { - - private static EELFLogger logger = EELFManager.getInstance().getLogger(NodePropertyUtils.class); - private final SvcLogicContext context; - private final Map inParams; - private ExpressionUtils jsonExpressionUtils; - - public NodePropertyUtils(final SvcLogicContext context, final Map inParams) { - this.context = context; - this.inParams = inParams; - jsonExpressionUtils = new ExpressionUtils(this.context, this.inParams); - } - - @SuppressWarnings("squid:S3776") - public SvcLogicContext assignInParamsFromModel(NodeType nodetype, NodeTemplate nodeTemplate) throws IOException { - if (nodeTemplate != null) { - Map inputs = null; - // Populate the Type inputs - Map nodeTypeinputs = new HashMap<>(); - for (Map.Entry nodeTypeInterface : nodetype.getInterfaces().entrySet()) { - if (nodeTypeInterface != null && nodeTypeInterface.getValue() != null) { - for (Map.Entry nodeTypeOperation : nodeTypeInterface.getValue() - .getOperations().entrySet()) { - nodeTypeinputs = nodeTypeOperation.getValue().getInputs(); - logger.trace("Populated node type input ({}).", nodeTypeinputs); - } - } - } - - if (!nodeTypeinputs.isEmpty()) { - // Populate the Template inputs - for (Map.Entry nodeTemplateInterface : nodeTemplate.getInterfaces() - .entrySet()) { - if (nodeTemplateInterface != null && nodeTemplateInterface.getValue() != null) { - this.inParams.put(ConfigModelConstant.PROPERTY_CURRENT_INTERFACE, - nodeTemplateInterface.getKey()); - for (Map.Entry nodeTemplateOperation : nodeTemplateInterface - .getValue().getOperations().entrySet()) { - if (nodeTemplateOperation != null) { - this.inParams.put(ConfigModelConstant.PROPERTY_CURRENT_OPERATION, - nodeTemplateOperation.getKey()); - if (StringUtils.isNotBlank(nodeTemplateOperation.getValue().getImplementation())) { - this.inParams.put(ConfigModelConstant.PROPERTY_CURRENT_IMPLEMENTATION, - nodeTemplateOperation.getValue().getImplementation()); - } - inputs = nodeTemplateOperation.getValue().getInputs(); - logger.trace("Populated node template input({}).", inputs); - // Assign Default Values & Types - jsonExpressionUtils.populatePropertAssignments(nodeTypeinputs, inputs); - } - } - } - } - } - - if (nodeTemplate.getRequirements() != null && !nodeTemplate.getRequirements().isEmpty()) { - assignInParamsFromRequirementModel(nodeTemplate, context, inParams); - } - } - return context; - } - - @SuppressWarnings("squid:S3776") - public SvcLogicContext assignOutParamsFromModel(NodeType nodetype, NodeTemplate nodeTemplate) throws IOException { - - if (nodeTemplate != null) { - Map outputs = null; - // Populate the Type Outputs - Map nodeTypeOutputs = new HashMap<>(); - - for (Map.Entry nodeTypeInterface : nodetype.getInterfaces().entrySet()) { - if (nodeTypeInterface != null && nodeTypeInterface.getValue() != null) { - for (Map.Entry nodeTypeOperation : nodeTypeInterface.getValue() - .getOperations().entrySet()) { - nodeTypeOutputs = nodeTypeOperation.getValue().getOutputs(); - logger.info("Populated node type output ({}).", nodeTypeOutputs); - } - } - } - - if (!nodeTypeOutputs.isEmpty()) { - // Populate the Template Outputs - for (Map.Entry nodeTemplateInterface : nodeTemplate.getInterfaces() - .entrySet()) { - if (nodeTemplateInterface != null && nodeTemplateInterface.getValue() != null) { - for (Map.Entry nodeTemplateOperation : nodeTemplateInterface - .getValue().getOperations().entrySet()) { - outputs = nodeTemplateOperation.getValue().getOutputs(); - logger.info("Populated node template output ({}).", outputs); - // Assign Default Values & Types - jsonExpressionUtils.populateOutPropertAssignments(nodeTypeOutputs, outputs); - // TO DO - } - } - } - } - } - return context; - } - - @SuppressWarnings({"squid:S3776", "squid:S00112"}) - public SvcLogicContext assignInParamsFromRequirementModel(NodeTemplate nodeTemplate, final SvcLogicContext context, - final Map inParams) { - if (nodeTemplate != null && nodeTemplate.getRequirements() != null && context != null && inParams != null) { - nodeTemplate.getRequirements().forEach((requrementKey, requirement) -> { - if (requirement != null && StringUtils.isNotBlank(requirement.getNode()) - && StringUtils.isNotBlank(requirement.getCapability())) { - String requirementNodeTemplateContent = context - .getAttribute(ConfigModelConstant.PROPERTY_NODE_TEMPLATES_DOT + requirement.getNode()); - logger.info("Processing requirement node ({}) template content ({}) ", requirement.getNode(), - requirementNodeTemplateContent); - NodeTemplate requirementNodeTemplate = - TransformationUtils.readValue(requirementNodeTemplateContent, NodeTemplate.class); - if (requirementNodeTemplate != null && requirementNodeTemplate.getCapabilities() != null) { - String nodeTypeContent = context.getAttribute( - ConfigModelConstant.PROPERTY_NODE_TYPES_DOT + requirementNodeTemplate.getType()); - NodeType nodeType = TransformationUtils.readValue(nodeTypeContent, NodeType.class); - if (nodeType != null && nodeType.getCapabilities() != null - && nodeType.getCapabilities().containsKey(requirement.getCapability())) { - CapabilityDefinition capabilityDefinition = - nodeType.getCapabilities().get(requirement.getCapability()); - if (capabilityDefinition != null) { - CapabilityAssignment capabilityAssignment = - requirementNodeTemplate.getCapabilities().get(requirement.getCapability()); - try { - assignInParamsFromCapabilityModel(requrementKey, capabilityDefinition, - capabilityAssignment, context); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - } - } - } - }); - } - return context; - } - - public SvcLogicContext assignInParamsFromCapabilityModel(String requirementName, - CapabilityDefinition capabilityDefinition, CapabilityAssignment capabilityAssignment, - final SvcLogicContext context) throws IOException { - if (capabilityAssignment != null && capabilityAssignment.getProperties() != null) { - jsonExpressionUtils.populatePropertAssignmentsWithPrefix(requirementName, - capabilityDefinition.getProperties(), capabilityAssignment.getProperties()); - } - return context; - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/utils/PrepareContextUtils.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/utils/PrepareContextUtils.java deleted file mode 100644 index 34c465cea..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/utils/PrepareContextUtils.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.utils; - -import java.util.HashMap; -import java.util.Map; -import org.apache.commons.lang3.StringUtils; -import org.onap.ccsdk.features.model.ConfigModelConstant; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -public class PrepareContextUtils { - - private static EELFLogger logger = EELFManager.getInstance().getLogger(PrepareContextUtils.class); - - public Map prepareContext(Map context, String input, String serviceTemplateContent) - throws Exception { - if (StringUtils.isNotBlank(serviceTemplateContent)) { - - if (context == null) { - context = new HashMap<>(); - } - if (StringUtils.isNotBlank(input)) { - TransformationUtils.convertJson2RootProperties(context, input); - } - - String recipeName = context.get(ConfigModelConstant.PROPERTY_ACTION_NAME); - if (StringUtils.isNotBlank(recipeName)) { - String recipeInputName = - recipeName.replace(ConfigModelConstant.PROPERTY_RECIPE, ConfigModelConstant.PROPERTY_REQUEST); - String recipeInput = context.get(recipeInputName); - if (StringUtils.isNotBlank(recipeInput)) { - // Un necessary to hold the Recipe Request, It is already in input - context.remove(recipeInputName); - context.remove(ConfigModelConstant.PROPERTY_PAYLOAD); - TransformationUtils.convertJson2RootProperties(context, recipeInput); - logger.info("Converted recipe ({}) request inputs to context.", recipeName); - } - } - - ServiceTemplateUtils serviceTemplateUtils = new ServiceTemplateUtils(); - serviceTemplateUtils.convertServiceTemplate2Properties(serviceTemplateContent, context); - } - return context; - - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/utils/ResourceAssignmentUtils.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/utils/ResourceAssignmentUtils.java deleted file mode 100644 index c68c52c3f..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/utils/ResourceAssignmentUtils.java +++ /dev/null @@ -1,302 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.utils; - -import java.util.Date; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import org.apache.commons.lang3.BooleanUtils; -import org.apache.commons.lang3.StringUtils; -import org.onap.ccsdk.features.model.ConfigModelConstant; -import org.onap.ccsdk.features.model.ConfigModelException; -import org.onap.ccsdk.features.model.ValidTypes; -import org.onap.ccsdk.features.model.data.ResourceAssignment; -import org.onap.ccsdk.features.model.data.dict.ResourceDefinition; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.NullNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import com.google.common.base.Preconditions; - -public class ResourceAssignmentUtils { - - private ResourceAssignmentUtils() { - - } - - private static EELFLogger logger = EELFManager.getInstance().getLogger(ResourceAssignmentUtils.class); - - public static String getArtifactNodeContent(String nodeTemplateName, Map context) { - Preconditions.checkArgument(StringUtils.isNotBlank(nodeTemplateName), - "getArtifactNodeContent missing template name"); - return (String) context.get(ConfigModelConstant.PROPERTY_NODE_TEMPLATES_DOT + nodeTemplateName + ".content"); - } - - public static List getArtifactNodeMapping(String nodeTemplateName, - Map context) { - Preconditions.checkArgument(StringUtils.isNotBlank(nodeTemplateName), - "getArtifactNodeMapping missing template name"); - List resourceAssignments = null; - String resourceMappingContent = - (String) context.get(ConfigModelConstant.PROPERTY_NODE_TEMPLATES_DOT + nodeTemplateName + ".mapping"); - if (StringUtils.isNotBlank(resourceMappingContent)) { - resourceAssignments = TransformationUtils.getListfromJson(resourceMappingContent, ResourceAssignment.class); - - } else { - logger.warn("missing mapping content for node template ({})", nodeTemplateName); - } - return resourceAssignments; - } - - // Not used Any whre - public static synchronized void cleanContextTemplateNDictionaryKeys(Map componentContext) { - String recipeName = (String) componentContext.get(ConfigModelConstant.PROPERTY_ACTION_NAME); - Set removeSet = new HashSet<>(); - componentContext.forEach((key, value) -> { - if (StringUtils.isNotBlank(key) - && (key.startsWith(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + recipeName + ".") - || key.startsWith(ConfigModelConstant.PROPERTY_RECIPE_KEY_DOT + recipeName + "."))) { - removeSet.add(key); - } - }); - componentContext.keySet().removeAll(removeSet); - } - - public static synchronized Object getDictionaryKeyValue(Map componentContext, - ResourceAssignment resourceMapping) { - Object value = null; - if (resourceMapping != null && componentContext != null) { - String recipeName = (String) componentContext.get(ConfigModelConstant.PROPERTY_ACTION_NAME); - String dictionaryKeyName = resourceMapping.getDictionaryName(); - value = componentContext - .get(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + recipeName + "." + dictionaryKeyName); - } - return value; - } - - public static synchronized Object getDictionaryKeyValue(Map componentContext, - ResourceDefinition resourceDictionary) { - Object value = null; - if (resourceDictionary != null && componentContext != null) { - String recipeName = (String) componentContext.get(ConfigModelConstant.PROPERTY_ACTION_NAME); - String dictionaryKeyName = resourceDictionary.getName(); - value = componentContext - .get(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + recipeName + "." + dictionaryKeyName); - } - return value; - } - - public static synchronized Object getTemplateKeyValue(Map componentContext, - ResourceAssignment resourceMapping) { - Object value = null; - if (resourceMapping != null && componentContext != null) { - String recipeName = (String) componentContext.get(ConfigModelConstant.PROPERTY_ACTION_NAME); - String templateKeyName = resourceMapping.getName(); - value = componentContext - .get(ConfigModelConstant.PROPERTY_RECIPE_KEY_DOT + recipeName + "." + templateKeyName); - } - return value; - } - - public static synchronized void setResourceDataValue(Map componentContext, - ResourceAssignment resourceAssignment, Object value) throws ConfigModelException { - - if (resourceAssignment != null && StringUtils.isNotBlank(resourceAssignment.getName()) - && resourceAssignment.getProperty() != null) { - - String recipeName = (String) componentContext.get(ConfigModelConstant.PROPERTY_ACTION_NAME); - String templateKeyName = resourceAssignment.getName(); - String dictionaryKeyName = resourceAssignment.getDictionaryName(); - - if (StringUtils.isBlank(dictionaryKeyName)) { - resourceAssignment.setDictionaryName(templateKeyName); - dictionaryKeyName = templateKeyName; - logger.warn("Missing dictionary key, setting with template key ({}) as dictionary key ({})", - templateKeyName, dictionaryKeyName); - } - String type = resourceAssignment.getProperty().getType(); - try { - if (StringUtils.isNotBlank(type)) { - Object convertedValue = convertResourceValue(type, value); - - componentContext.put( - ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + recipeName + "." + dictionaryKeyName, - convertedValue); - componentContext.put( - ConfigModelConstant.PROPERTY_RECIPE_KEY_DOT + recipeName + "." + templateKeyName, - convertedValue); - - logger.trace("Setting Resource Value ({}) for Resource Name ({}) of type ({}) ", convertedValue, - dictionaryKeyName, type); - - resourceAssignment.getProperty().setValue(convertedValue); - resourceAssignment.setUpdatedDate(new Date()); - resourceAssignment.setUpdatedBy(ConfigModelConstant.USER_SYSTEM); - resourceAssignment.setStatus(ConfigModelConstant.STATUS_SUCCESS); - } - } catch (Exception e) { - throw new ConfigModelException(String.format( - "Failed in setting value for template key (%s) and dictionary key (%s) of type (%s) with error message (%s)", - templateKeyName, dictionaryKeyName, type, e.getMessage())); - } - } else { - throw new ConfigModelException( - String.format("Failed in setting resource value for resource mapping (%s)", resourceAssignment)); - } - } - - private static Object convertResourceValue(String type, Object value) { - Object convertedValue = null; - - if (value == null || value instanceof NullNode) { - logger.info("Returning {} value from convertResourceValue", value); - return null; - } - - if (ValidTypes.getPrimitivePropertType().contains(type)) { - convertedValue = convertPrimitiveResourceValue(type, value); - } else { - // Case where Resource is non-primitive type - if (value instanceof JsonNode || value instanceof ObjectNode || value instanceof ArrayNode) { - convertedValue = value; - } else if (value instanceof String) { - convertedValue = TransformationUtils.getJsonNodeForString((String) value); - } else { - convertedValue = TransformationUtils.getJsonNodeForObject(value); - } - } - return convertedValue; - } - - @SuppressWarnings("squid:S3776") - private static Object convertPrimitiveResourceValue(String type, Object value) { - Object convertedValue = value; - - if (value instanceof ArrayNode) { - if (ValidTypes.DATA_TYPE_BOOLEAN.equalsIgnoreCase(type)) { - convertedValue = ((ArrayNode) value).asBoolean(); - } else if (ValidTypes.DATA_TYPE_INTEGER.equalsIgnoreCase(type)) { - convertedValue = ((ArrayNode) value).asInt(); - } else if (ValidTypes.DATA_TYPE_FLOAT.equalsIgnoreCase(type)) { - convertedValue = Float.valueOf(((ArrayNode) value).toString()); - } else { - convertedValue = ((ArrayNode) value).toString(); - } - } else if (value instanceof JsonNode) { - if (ValidTypes.DATA_TYPE_BOOLEAN.equalsIgnoreCase(type)) { - convertedValue = ((JsonNode) value).asBoolean(); - } else if (ValidTypes.DATA_TYPE_INTEGER.equalsIgnoreCase(type)) { - convertedValue = ((JsonNode) value).asInt(); - } else if (ValidTypes.DATA_TYPE_FLOAT.equalsIgnoreCase(type)) { - convertedValue = Float.valueOf(((JsonNode) value).asText()); - } else { - convertedValue = ((JsonNode) value).asText(); - } - } else if (value instanceof String) { - if (ValidTypes.DATA_TYPE_BOOLEAN.equalsIgnoreCase(type)) { - convertedValue = Boolean.valueOf((String) value); - } else if (ValidTypes.DATA_TYPE_INTEGER.equalsIgnoreCase(type)) { - convertedValue = Integer.valueOf((String) value); - } else if (ValidTypes.DATA_TYPE_FLOAT.equalsIgnoreCase(type)) { - convertedValue = Float.valueOf((String) value); - } - } - logger.info("Returning value ({}) from convertPrimitiveResourceValue", convertedValue); - return convertedValue; - } - - @SuppressWarnings("squid:S1172") - public static synchronized void setFailedResourceDataValue(Map componentContext, - ResourceAssignment resourceAssignment, String message) { - setFailedResourceDataValue(resourceAssignment, message); - } - - public static synchronized void setFailedResourceDataValue(ResourceAssignment resourceAssignment, String message) { - if (resourceAssignment != null && StringUtils.isNotBlank(resourceAssignment.getName()) - && resourceAssignment.getProperty() != null) { - resourceAssignment.setUpdatedDate(new Date()); - resourceAssignment.setStatus(ConfigModelConstant.STATUS_FAILURE); - resourceAssignment.setUpdatedBy(ConfigModelConstant.USER_SYSTEM); - resourceAssignment.setMessage(message); - } - } - - public static synchronized void assertTemplateKeyValueNotNull(Map componentContext, - ResourceAssignment resourceAssignment) throws ConfigModelException { - if (resourceAssignment != null && resourceAssignment.getProperty() != null - && BooleanUtils.isTrue(resourceAssignment.getProperty().getRequired()) - && getTemplateKeyValue(componentContext, resourceAssignment) == null) { - logger.error("failed to populate mandatory resource mapping ({})", resourceAssignment); - throw new ConfigModelException( - String.format("failed to populate mandatory resource mapping (%s)", resourceAssignment)); - } - } - - @SuppressWarnings({"squid:S3776", "squid:S1141"}) - public static synchronized String generateResourceDataForAssignments(List assignments) - throws ConfigModelException { - String result = "{}"; - try { - ObjectMapper mapper = new ObjectMapper(); - JsonNode root = mapper.readTree(result); - for (ResourceAssignment resourceMapping : assignments) { - if (resourceMapping != null && resourceMapping.getName() != null - && resourceMapping.getProperty() != null) { - - String type = resourceMapping.getProperty().getType(); - Object value = resourceMapping.getProperty().getValue(); - logger.info("Generating Resource name ({}), type ({}), value ({})", resourceMapping.getName(), type, - value); - if (value == null) { - ((ObjectNode) root).set(resourceMapping.getName(), null); - } else if (value instanceof JsonNode) { - ((ObjectNode) root).put(resourceMapping.getName(), (JsonNode) value); - } else if (ValidTypes.DATA_TYPE_STRING.equalsIgnoreCase(type)) { - ((ObjectNode) root).put(resourceMapping.getName(), (String) value); - } else if (ValidTypes.DATA_TYPE_BOOLEAN.equalsIgnoreCase(type)) { - ((ObjectNode) root).put(resourceMapping.getName(), (Boolean) value); - } else if (ValidTypes.DATA_TYPE_INTEGER.equalsIgnoreCase(type)) { - ((ObjectNode) root).put(resourceMapping.getName(), (Integer) value); - } else if (ValidTypes.DATA_TYPE_FLOAT.equalsIgnoreCase(type)) { - ((ObjectNode) root).put(resourceMapping.getName(), (Float) value); - } else if (ValidTypes.DATA_TYPE_TIMESTAMP.equalsIgnoreCase(type)) { - ((ObjectNode) root).put(resourceMapping.getName(), (String) value); - } else { - JsonNode jsonNode = TransformationUtils.getJsonNodeForObject(value); - if (jsonNode != null) { - ((ObjectNode) root).put(resourceMapping.getName(), jsonNode); - } else { - ((ObjectNode) root).set(resourceMapping.getName(), null); - } - } - } - } - result = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(root); - logger.info("Generated Resource Param Data ({})", result); - } catch (Exception e) { - throw new ConfigModelException(e.getMessage(), e); - } - return result; - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/utils/ResourceDictionaryUtils.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/utils/ResourceDictionaryUtils.java deleted file mode 100644 index 080171ef6..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/utils/ResourceDictionaryUtils.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.utils; - -import java.util.Map; -import java.util.Optional; -import java.util.function.Supplier; -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.collections.MapUtils; -import org.apache.commons.lang3.StringUtils; -import org.onap.ccsdk.features.model.ConfigModelConstant; -import org.onap.ccsdk.features.model.data.PropertyDefinition; -import org.onap.ccsdk.features.model.data.ResourceAssignment; -import org.onap.ccsdk.features.model.data.dict.ResourceDefinition; -import org.onap.ccsdk.features.model.data.dict.SourcesDefinition; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -/** - * ResourceDictionaryUtils.java Purpose to provide ResourceDictionaryUtils - * - * @version 1.0 - */ -public class ResourceDictionaryUtils { - - private ResourceDictionaryUtils() { - // Do nothing - } - - private static EELFLogger logger = EELFManager.getInstance().getLogger(ResourceDictionaryUtils.class); - - /** - * This Method is to assign the source name to the Dictionary Definition Check to see if the source - * definition is not present then assign, if more than one source then assign only one source. - * - * @param resourceAssignment - * @param resourceDefinition - */ - @SuppressWarnings("squid:S3776") - public static void populateSourceMapping(ResourceAssignment resourceAssignment, - ResourceDefinition resourceDefinition) { - - if (resourceAssignment != null && resourceDefinition != null - && StringUtils.isBlank(resourceAssignment.getDictionarySource())) { - - setProperty(resourceAssignment, resourceDefinition); - Map sourcesDefinition = resourceDefinition.getSources(); - - if (sourcesDefinition != null && MapUtils.isNotEmpty(sourcesDefinition) && sourcesDefinition.size() == 1) { - if (sourcesDefinition.get("input") != null) { - resourceAssignment.setDictionarySource(ConfigModelConstant.SOURCE_INPUT); - } else if (sourcesDefinition.get("default") != null) { - resourceAssignment.setDictionarySource(ConfigModelConstant.SOURCE_DEFAULT); - } else if (sourcesDefinition.get("db") != null) { - resourceAssignment.setDictionarySource(ConfigModelConstant.SOURCE_DB); - if (resolve(() -> sourcesDefinition.get("db").getProperties().getDependencies()).isPresent() - && CollectionUtils - .isNotEmpty(sourcesDefinition.get("db").getProperties().getDependencies())) { - resourceAssignment - .setDependencies(sourcesDefinition.get("db").getProperties().getDependencies()); - } - } else if (sourcesDefinition.get("mdsal") != null) { - resourceAssignment.setDictionarySource(ConfigModelConstant.SOURCE_MDSAL); - if (resolve(() -> sourcesDefinition.get("mdsal").getProperties().getDependencies()).isPresent() - && CollectionUtils - .isNotEmpty(sourcesDefinition.get("mdsal").getProperties().getDependencies())) { - resourceAssignment - .setDependencies(sourcesDefinition.get("mdsal").getProperties().getDependencies()); - } - } - logger.info("automapped resourceAssignment : {}", resourceAssignment); - } - } - } - - public static Optional resolve(Supplier resolver) { - try { - T result = resolver.get(); - return Optional.ofNullable(result); - } catch (NullPointerException e) { - return Optional.empty(); - } - } - - /** - * Overriding ResourceAssignment Properties with properties defined in Dictionary - */ - private static void setProperty(ResourceAssignment resourceAssignment, ResourceDefinition resourceDefinition) { - if (StringUtils.isNotBlank(resourceDefinition.getProperty().getType())) { - PropertyDefinition property = resourceAssignment.getProperty(); - if (property == null) { - property = new PropertyDefinition(); - } - if (resourceDefinition.getProperty() != null) { - property.setType(resourceDefinition.getProperty().getType()); - if (resourceDefinition.getProperty().getEntrySchema() != null) { - property.setEntrySchema(resourceDefinition.getProperty().getEntrySchema()); - } - resourceAssignment.setProperty(property); - } - } - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/utils/ServiceTemplateUtils.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/utils/ServiceTemplateUtils.java deleted file mode 100644 index c63719875..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/utils/ServiceTemplateUtils.java +++ /dev/null @@ -1,277 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.utils; - -import java.util.Map; -import org.apache.commons.collections.MapUtils; -import org.apache.commons.lang3.StringUtils; -import org.onap.ccsdk.features.model.ConfigModelConstant; -import org.onap.ccsdk.features.model.data.InterfaceAssignment; -import org.onap.ccsdk.features.model.data.InterfaceDefinition; -import org.onap.ccsdk.features.model.data.NodeTemplate; -import org.onap.ccsdk.features.model.data.NodeType; -import org.onap.ccsdk.features.model.data.OperationAssignment; -import org.onap.ccsdk.features.model.data.OperationDefinition; -import org.onap.ccsdk.features.model.data.ServiceTemplate; -import org.onap.ccsdk.features.model.data.TopologyTemplate; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -public class ServiceTemplateUtils { - private static EELFLogger logger = EELFManager.getInstance().getLogger(ServiceTemplateUtils.class); - - public Map convertServiceTemplate2Properties(String serviceTemplateContent, - final Map context) { - if (StringUtils.isNotBlank(serviceTemplateContent)) { - ServiceTemplate serviceTemplate = - TransformationUtils.readValue(serviceTemplateContent, ServiceTemplate.class); - convertServiceTemplate2Properties(serviceTemplate, context); - } - return context; - } - - public Map convertServiceTemplate2Properties(ServiceTemplate serviceTemplate, - final Map context) { - if (serviceTemplate != null) { - convertServiceTemplateMetadata2Properties(serviceTemplate, context); - convertServiceTemplateInputs2Properties(serviceTemplate, context); - convertDataTypes2Properties(serviceTemplate, context); - convertNode2Properties(serviceTemplate, context); - } - return context; - } - - public Map convertServiceTemplateMetadata2Properties(ServiceTemplate serviceTemplate, - final Map context) { - - if (serviceTemplate != null && serviceTemplate.getMetadata() != null) { - serviceTemplate.getMetadata().forEach((metaDataKey, metadata) -> { - context.put(metaDataKey, metadata); - }); - } - return context; - } - - public Map convertServiceTemplateInputs2Properties(ServiceTemplate serviceTemplate, - final Map context) { - - if (serviceTemplate != null && serviceTemplate.getTopologyTemplate() != null - && serviceTemplate.getTopologyTemplate().getInputs() != null) { - - serviceTemplate.getTopologyTemplate().getInputs().forEach((paramKey, parameterDefinition) -> { - if (parameterDefinition != null) { - context.put(ConfigModelConstant.PROPERTY_INPUTS_DOT + paramKey + ".type", - parameterDefinition.getType()); - if (parameterDefinition.getRequired()) { - context.put(ConfigModelConstant.PROPERTY_INPUTS_DOT + paramKey + ".required", - String.valueOf(parameterDefinition.getRequired())); - } - if (parameterDefinition.getDefaultValue() != null) { - context.put(ConfigModelConstant.PROPERTY_INPUTS_DOT + paramKey + ".default", - String.valueOf(parameterDefinition.getDefaultValue())); - } - } - }); - } - return context; - } - - public Map convertDataTypes2Properties(ServiceTemplate serviceTemplate, - final Map context) { - if (serviceTemplate != null && serviceTemplate.getDataTypes() != null) { - serviceTemplate.getDataTypes().forEach((dataTypeKey, dataType) -> { - logger.trace("Populating Data Type Key : ({})", dataTypeKey); - String dataTypeContent = TransformationUtils.getJson(dataType); - context.put("data_types." + dataTypeKey, dataTypeContent); - }); - } - return context; - } - - public Map convertNode2Properties(ServiceTemplate serviceTemplate, - final Map context) { - - if (serviceTemplate != null && serviceTemplate.getNodeTypes() != null - && serviceTemplate.getTopologyTemplate() != null - && serviceTemplate.getTopologyTemplate().getNodeTemplates() != null) { - - serviceTemplate.getTopologyTemplate().getNodeTemplates().forEach((nodeTemplateKey, nodeTemplate) -> { - if (nodeTemplate != null && StringUtils.isNotBlank(nodeTemplate.getType())) { - String nodeTypeKey = nodeTemplate.getType(); - logger.trace("Populating Node Type Key : ({}) for Node Template : ({})", nodeTypeKey, - nodeTemplateKey); - String nodeTemplateContent = TransformationUtils.getJson(nodeTemplate); - context.put("node_templates." + nodeTemplateKey, nodeTemplateContent); - if (serviceTemplate.getNodeTypes().containsKey(nodeTypeKey)) { - NodeType nodeType = serviceTemplate.getNodeTypes().get(nodeTypeKey); - String nodeTypeContent = TransformationUtils.getJson(nodeType); - context.put("node_types." + nodeTypeKey, nodeTypeContent); - String nodeDerivedFrom = nodeType.getDerivedFrom(); - if (ConfigModelConstant.MODEL_TYPE_NODE_DG.equalsIgnoreCase(nodeDerivedFrom)) { - populateDGNodeProperties(nodeTemplateKey, nodeTemplate, context, nodeDerivedFrom); - } - } - // Populate the Artifact Definitions - populateNodeTemplateArtifacts(nodeTemplateKey, nodeTemplate, context); - } - }); - } - return context; - } - - @SuppressWarnings("squid:S1172") - public Map populateVnfNodeProperties(String nodeTemplateKey, NodeTemplate nodeTemplate, - final Map context, String nodeDerivedFrom) { - if (nodeTemplate != null && nodeTemplate.getCapabilities() != null) { - nodeTemplate.getCapabilities().forEach((capabilityKey, capability) -> { - capability.getProperties().forEach((propertyKey, property) -> { - context.put(nodeTemplateKey + "." + capabilityKey + "." + propertyKey, String.valueOf(property)); - }); - }); - } - - return context; - } - - public Map populateNodeTemplateArtifacts(String nodeTemplateKey, NodeTemplate nodeTemplate, - final Map context) { - if (MapUtils.isNotEmpty(nodeTemplate.getArtifacts())) { - nodeTemplate.getArtifacts().forEach((artifactName, artifact) -> { - if (StringUtils.isNotBlank(artifactName) && artifact != null) { - logger.trace("Populating Node Template Artifacts ({}) for Node Template ({})", artifactName, - nodeTemplateKey); - String fileKeyName = ConfigModelConstant.PROPERTY_NODE_TEMPLATES_DOT + nodeTemplateKey + "." - + ConfigModelConstant.PROPERTY_ARTIFACTS_DOT + artifactName + ".file"; - String deployKeyName = ConfigModelConstant.PROPERTY_NODE_TEMPLATES_DOT + nodeTemplateKey + "." - + ConfigModelConstant.PROPERTY_ARTIFACTS_DOT + artifactName + ".deploy_path"; - String contentKeyName = ConfigModelConstant.PROPERTY_NODE_TEMPLATES_DOT + nodeTemplateKey + "." - + ConfigModelConstant.PROPERTY_ARTIFACTS_DOT + artifactName + ".content"; - context.put(fileKeyName, artifact.getFile()); - context.put(deployKeyName, artifact.getDeployPath()); - context.put(contentKeyName, artifact.getContent()); - } - }); - } - return context; - } - - public Map populateDGNodeProperties(String nodeTemplateKey, NodeTemplate nodeTemplate, - final Map context, String nodeDerivedFrom) { - if (nodeTemplate != null && nodeTemplate.getInterfaces() != null) { - - if (nodeTemplate.getProperties() != null) { - nodeTemplate.getProperties().forEach((propKey, propValue) -> { - if (propKey != null && propValue != null) { - context.put("dg." + nodeTemplateKey + "." + propKey, String.valueOf(propValue)); - } - }); - } - - nodeTemplate.getInterfaces().forEach((interfaceKey, interfaceDefinition) -> { - - interfaceDefinition.getOperations().forEach((operationKey, operation) -> { - if (ConfigModelConstant.MODEL_TYPE_NODE_DG.equalsIgnoreCase(nodeDerivedFrom)) { - context.put("dg." + nodeTemplateKey + ".module", interfaceKey); - context.put("dg." + nodeTemplateKey + ".flow", operationKey); - } - }); - }); - } - return context; - } - - public SvcLogicContext getInterfaceOpertationDefinition(ServiceTemplate serviceTemplate, - final SvcLogicContext context) { - - if (serviceTemplate != null && serviceTemplate.getNodeTypes() != null - && serviceTemplate.getTopologyTemplate() != null - && serviceTemplate.getTopologyTemplate().getNodeTemplates() != null) { - - TopologyTemplate topologyTemplates = serviceTemplate.getTopologyTemplate(); - // Copy Definition to Template - copyNodeType2Template(serviceTemplate.getNodeTypes(), topologyTemplates.getNodeTemplates()); - - topologyTemplates.getNodeTemplates().forEach((templateKey, nodeTemplate) -> { - - if (StringUtils.isNotBlank(templateKey) && nodeTemplate != null - && nodeTemplate.getInterfaces() != null) { - - nodeTemplate.getInterfaces().forEach((interfaceKey, interfaceDefinition) -> { - if (StringUtils.isNotBlank(interfaceKey) && interfaceDefinition != null) { - interfaceDefinition.getOperations().forEach((operationKey, operation) -> { - String definitionKey = interfaceKey + "." + operationKey; - String definitionContent = TransformationUtils.getJson(operation); - context.setAttribute(definitionKey, definitionContent); - // Set the Operation & Method Params - }); - } - }); - } - }); - } - return context; - } - - public void copyNodeType2Template(Map nodeTypes, Map nodeTemplates) { - if (nodeTypes != null && nodeTemplates != null) { - - nodeTemplates.forEach((templateKey, nodeTemplate) -> { - if (StringUtils.isNotBlank(templateKey) && nodeTemplate != null) { - String type = nodeTemplate.getType(); - // Check the Node Template Type is Present - if (StringUtils.isNotBlank(type) && nodeTypes.containsKey(type)) { - NodeType nodeType = nodeTypes.get(type); - logger.trace("Checking Node Type Content : ({})", TransformationUtils.getJson(nodeType)); - copyNodeTypeInterface2Template(nodeType.getInterfaces(), nodeTemplate.getInterfaces()); - } - } - }); - } - } - - public void copyNodeTypeInterface2Template(Map nodeTypeInterfaces, - Map nodeTemplateInterfaces) { - if (nodeTypeInterfaces != null && nodeTemplateInterfaces != null) { - - nodeTemplateInterfaces.forEach((interfaceKey, nodeTemplateinterface) -> { - InterfaceDefinition nodeTypeInterface = nodeTypeInterfaces.get(interfaceKey); - logger.trace("Checking Interface Type Content : ({})", TransformationUtils.getJson(nodeTypeInterface)); - if (nodeTypeInterface != null && nodeTemplateinterface != null) { - copyNodeTypeOperation2Template(nodeTypeInterface.getOperations(), - nodeTemplateinterface.getOperations()); - } - }); - } - } - - public void copyNodeTypeOperation2Template(Map nodeTypeOperations, - Map nodeTemplateOperations) { - if (nodeTypeOperations != null && nodeTemplateOperations != null) { - - nodeTemplateOperations.forEach((operationKey, nodeTemplateOperation) -> { - OperationDefinition nodeTypeInterfaceOperation = nodeTypeOperations.get(operationKey); - if (nodeTypeInterfaceOperation != null && nodeTemplateOperation != null) { - logger.info("Checking Operation Type Content : " + operationKey + " : " - + TransformationUtils.getJson(nodeTypeInterfaceOperation)); - } - }); - } - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/utils/TopologicalSortingUtils.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/utils/TopologicalSortingUtils.java deleted file mode 100644 index 4f16a0c5f..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/utils/TopologicalSortingUtils.java +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.utils; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Queue; -import java.util.Stack; - -public class TopologicalSortingUtils { - - /** - * The implementation here is basically an adjacency list, but instead of an array of lists, a Map - * is used to map each vertex to its list of adjacent vertices. - */ - private Map> neighbors = new HashMap<>(); - - /** - * String representation of graph. - */ - @Override - public String toString() { - StringBuilder s = new StringBuilder(); - neighbors.forEach((v, vs) -> s.append("\n " + v + " -> " + vs)); - return s.toString(); - } - - public Map> getNeighbors() { - return neighbors; - } - - /** - * Add a vertex to the graph. Nothing happens if vertex is already in graph. - */ - public void add(V vertex) { - if (neighbors.containsKey(vertex)) - return; - neighbors.put(vertex, new ArrayList()); - } - - /** - * True iff graph contains vertex. - */ - public boolean contains(V vertex) { - return neighbors.containsKey(vertex); - } - - /** - * Add an edge to the graph; if either vertex does not exist, it's added. This implementation allows - * the creation of multi-edges and self-loops. - */ - public void add(V from, V to) { - this.add(from); - this.add(to); - neighbors.get(from).add(to); - } - - /** - * Remove an edge from the graph. Nothing happens if no such edge. - * - * @throws IllegalArgumentException if either vertex doesn't exist. - */ - public void remove(V from, V to) { - if (!(this.contains(from) && this.contains(to))) - throw new IllegalArgumentException("Nonexistent vertex"); - neighbors.get(from).remove(to); - } - - /** - * Report (as a Map) the out-degree of each vertex. - */ - public Map outDegree() { - Map result = new HashMap<>(); - neighbors.forEach((v, vs) -> result.put(v, vs.size())); - return result; - } - - /** - * Report (as a Map) the in-degree of each vertex. - */ - public Map inDegree() { - Map result = new HashMap<>(); - for (V v : neighbors.keySet()) - result.put(v, 0); // All in-degrees are 0 - - neighbors.forEach((from, vs) -> vs.forEach(to -> result.put(to, result.get(to) + 1) // Increment in-degree - )); - - return result; - } - - /** - * Report (as a List) the topological sort of the vertices; null for no such sort. - */ - @SuppressWarnings({"squid:S1149", "squid:S1168"}) - public List topSort() { - Map degree = inDegree(); - // Determine all vertices with zero in-degree - Stack zeroVerts = new Stack<>(); // Stack as good as any here - - degree.forEach((v, vs) -> { - if (vs == 0) - zeroVerts.push(v); - }); - - // Determine the topological order - List result = new ArrayList<>(); - while (!zeroVerts.isEmpty()) { - V v = zeroVerts.pop(); // Choose a vertex with zero in-degree - result.add(v); // Vertex v is next in topol order - // "Remove" vertex v by updating its neighbors - for (V neighbor : neighbors.get(v)) { - degree.put(neighbor, degree.get(neighbor) - 1); - // Remember any vertices that now have zero in-degree - if (degree.get(neighbor) == 0) - zeroVerts.push(neighbor); - } - } - // Check that we have used the entire graph (if not, there was a cycle) - if (result.size() != neighbors.size()) - return null; - return result; - } - - /** - * True iff graph is a dag (directed acyclic graph). - */ - public boolean isDag() { - return topSort() != null; - } - - /** - * Report (as a Map) the bfs distance to each vertex from the start vertex. The distance is an - * Integer; the value null is used to represent infinity (implying that the corresponding node - * cannot be reached). - */ - public Map bfsDistance(V start) { - Map distance = new HashMap<>(); - // Initially, all distance are infinity, except start node - for (V v : neighbors.keySet()) - distance.put(v, null); - distance.put(start, 0); - // Process nodes in queue order - Queue queue = new LinkedList<>(); - queue.offer(start); // Place start node in queue - while (!queue.isEmpty()) { - V v = queue.remove(); - int vDist = distance.get(v); - // Update neighbors - for (V neighbor : neighbors.get(v)) { - if (distance.get(neighbor) != null) - continue; // Ignore if already done - distance.put(neighbor, vDist + 1); - queue.offer(neighbor); - } - } - return distance; - } - - /** - * Main program (for testing). public static void main (String[] args) { // Create a Graph with - * Integer nodes TopologicalSortingUtils graph = new TopologicalSortingUtils(); - * graph.add("bundle-id", "bundle-mac"); graph.add("bundle-id", "bundle-ip"); - * graph.add("bundle-mac", "bundle-ip"); graph.add("bundle-ip", "bundle-mac"); - * System.out.println("The current graph: " + graph); System.out.println("In-degrees: " + - * graph.inDegree()); System.out.println("Out-degrees: " + graph.outDegree()); System.out.println("A - * topological sort of the vertices: " + graph.topSort()); System.out.println("The graph " + - * (graph.isDag()?"is":"is not") + " a dag"); } - */ -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/utils/TransformationUtils.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/utils/TransformationUtils.java deleted file mode 100644 index 138745ccf..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/utils/TransformationUtils.java +++ /dev/null @@ -1,429 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.utils; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.TreeMap; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.type.CollectionType; -import com.fasterxml.jackson.module.jsonSchema.JsonSchema; -import com.fasterxml.jackson.module.jsonSchema.JsonSchemaGenerator; - -/** - * TransformationUtils.java Purpose: Provide Configuration Generator TransformationUtils Information - * - * @version 1.0 - */ -public class TransformationUtils { - - private static EELFLogger logger = EELFManager.getInstance().getLogger(TransformationUtils.class); - - private TransformationUtils() { - - } - - /** - * This is a getJson method - * - * @param configparameters - * @return String - */ - public static String getJson(Map configparameters) { - String jsonContent = null; - try { - ObjectMapper mapper = new ObjectMapper(); - jsonContent = mapper.writeValueAsString(configparameters); - } catch (JsonProcessingException e) { - logger.warn(e.getMessage()); - } - return jsonContent; - } - - /** - * This is a getJsonNode method - * - * @param configparameters - * @return String - */ - public static JsonNode getJsonNode(Map configparameters) { - JsonNode jsonContent = null; - try { - ObjectMapper mapper = new ObjectMapper(); - jsonContent = mapper.valueToTree(configparameters); - } catch (Exception e) { - logger.warn(e.getMessage()); - } - return jsonContent; - } - - /** - * This is a getJson method - * - * @param instance - * @param pretty - * @return Map - */ - public static String getJson(Object instance, boolean pretty) { - try { - ObjectMapper mapper = new ObjectMapper(); - mapper.setSerializationInclusion(Include.NON_NULL); - if (pretty) { - mapper.enable(SerializationFeature.INDENT_OUTPUT); - } - return mapper.writeValueAsString(instance); - } catch (JsonProcessingException e) { - logger.warn(e.getMessage()); - } - return null; - } - - /** - * This is a getJson method - * - * @param instance - * @return String - */ - public static String getJson(Object instance) { - return getJson(instance, false); - } - - /** - * This is a getJsonNodeForobject method - * - * @param instance - * @return JsonNode - */ - public static JsonNode getJsonNodeForObject(Object instance) { - try { - ObjectMapper mapper = new ObjectMapper(); - mapper.setSerializationInclusion(Include.NON_NULL); - return mapper.convertValue(instance, JsonNode.class); - } catch (Exception e) { - logger.warn(e.getMessage()); - } - return null; - } - - /** - * This is a getJsonNodeForString method - * - * @param content - * @return JsonNode - */ - public static JsonNode getJsonNodeForString(String content) { - try { - ObjectMapper mapper = new ObjectMapper(); - mapper.setSerializationInclusion(Include.NON_NULL); - return mapper.readTree(content); - } catch (Exception e) { - logger.warn(e.getMessage()); - } - return null; - } - - /** - * This is a getMapfromJson method - * - * @param content - * @return Map - */ - public static Map getMapfromJson(String content) { - try { - ObjectMapper mapper = new ObjectMapper(); - return mapper.readValue(content, new TypeReference>() {}); - } catch (Exception e) { - logger.warn("failed in getMapfromJson for the content ({}) with error message ({}).", content, - e.getMessage()); - } - return null; - } - - /** - * This is a getMapfromJson method - * - * @param content - * @return Map - */ - public static Map getMapfromJsonString(String content) { - try { - ObjectMapper mapper = new ObjectMapper(); - return mapper.readValue(content, new TypeReference>() {}); - } catch (Exception e) { - logger.warn("failed in getMapfromJson for the content ({}) with error message ({}).", content, - e.getMessage()); - } - return null; - } - - /** - * This is a getListfromJson method - * - * @param content - * @return Map - */ - @SuppressWarnings("squid:S1168") - public static List getListfromJson(String content, Class valueType) { - try { - ObjectMapper mapper = new ObjectMapper(); - CollectionType javaType = mapper.getTypeFactory().constructCollectionType(List.class, valueType); - return mapper.readValue(content, javaType); - } catch (Exception e) { - logger.warn("failed in getListfromJson for the content ({}) with error message ({}).", content, - e.getMessage()); - } - return null; - } - - /** - * This is a getJsonSchema method - * - * @param valueType - * @return String - */ - public static String getJsonSchema(Class clazz) { - try { - ObjectMapper mapper = new ObjectMapper(); - JsonSchemaGenerator schemaGen = new JsonSchemaGenerator(mapper); - JsonSchema schema = schemaGen.generateSchema(clazz); - return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(schema); - - } catch (Exception e) { - logger.warn("failed in getJsonSchema with error message ({}).", e.getMessage()); - } - return null; - } - - /** - * This is a readValue method - * - * @param content - * @param valueType - * @return - */ - - public static T readValue(String content, Class valueType) { - try { - ObjectMapper mapper = new ObjectMapper(); - return mapper.readValue(content, valueType); - } catch (Exception e) { - logger.warn("failed in readValue for the content ({}) with error message ({}).", content, e.getMessage()); - } - return null; - } - - /** - * @param node - * @param valueType - * @param - * @return - */ - public static T treeToValue(JsonNode node, Class valueType) { - try { - ObjectMapper mapper = new ObjectMapper(); - return mapper.treeToValue(node, valueType); - } catch (Exception e) { - logger.warn("failed in readValue for the content ({}) with error message ({}).", node, e.getMessage()); - } - return null; - } - - /** - * @param node - * @param valueType - * @param - * @return List - */ - public static List treeToListValue(JsonNode node, Class valueType) { - List resultList = new ArrayList<>(); - if (node instanceof ArrayNode) { - for (JsonNode subnode : node) { - if (subnode != null) { - resultList.add(treeToValue(subnode, valueType)); - } - } - } - return resultList; - } - - /** - * This is a removeJsonNullNode method - * - * @param node - */ - public static void removeJsonNullNode(JsonNode node) { - Iterator it = node.iterator(); - while (it.hasNext()) { - JsonNode child = it.next(); - if (child.isNull()) { - it.remove(); - } else { - removeJsonNullNode(child); - } - } - } - - public static void printProperty(Properties property) { - if (property != null) { - Map sortedMap = new TreeMap(property); - StringBuilder buffer = new StringBuilder(); - sortedMap.entrySet().forEach(message -> { - buffer.append("\n" + message.toString()); - }); - logger.debug("Property : ({})", buffer); - } - } - - public static void printMap(Map map) { - if (map != null) { - Map sortedMap = new TreeMap(map); - StringBuilder buffer = new StringBuilder(); - sortedMap.entrySet().forEach(message -> { - buffer.append("\n" + message.toString()); - }); - logger.debug("Map: ({})", buffer); - } - } - - @SuppressWarnings("squid:S00112") - public static Map convertJson2RootProperties(Map context, String jsonContent) - throws Exception { - if (context == null) { - context = new HashMap<>(); - } - - ObjectMapper mapper = new ObjectMapper(); - JsonNode rootArray = mapper.readTree(jsonContent); - return convertJson2RootProperties(context, rootArray); - } - - public static Map convertJson2RootProperties(Map context, JsonNode rootArray) { - Map sortedMap = null; - - if (context == null) { - context = new HashMap<>(); - } - if (rootArray != null) { - Iterator> fields = rootArray.fields(); - while (fields.hasNext()) { - Map.Entry entry = fields.next(); - if (entry != null && entry.getValue() != null) { - if (entry.getValue().isTextual()) { - context.put(entry.getKey(), entry.getValue().textValue()); - } else { - context.put(entry.getKey(), entry.getValue().toString()); - } - } - } - } - sortedMap = new TreeMap<>(context); - return sortedMap; - } - - @SuppressWarnings("squid:S00112") - public static Map convertJson2Properties(Map context, String jsonContent, - List blockKeys) throws Exception { - Map sortedMap = null; - - if (context == null) { - context = new HashMap<>(); - } - - ObjectMapper mapper = new ObjectMapper(); - JsonNode rootArray = mapper.readTree(jsonContent); - - if (rootArray != null) { - Iterator> fields = rootArray.fields(); - while (fields.hasNext()) { - Map.Entry entry = fields.next(); - processJsonNode(context, blockKeys, entry.getKey(), entry.getValue()); - } - } - sortedMap = new TreeMap<>(context); - return sortedMap; - } - - public static Map convertJson2Properties(Map context, JsonNode rootArray, - List blockKeys) throws IOException { - Map sortedMap = null; - - if (context == null) { - context = new HashMap<>(); - } - - if (blockKeys == null) { - blockKeys = new ArrayList<>(); - } - - if (rootArray != null) { - Iterator> fields = rootArray.fields(); - while (fields.hasNext()) { - Map.Entry entry = fields.next(); - processJsonNode(context, blockKeys, entry.getKey(), entry.getValue()); - } - } - sortedMap = new TreeMap<>(context); - return sortedMap; - } - - private static void processJsonNode(Map propertyMap, List blockKeys, String nodeName, - JsonNode node) throws IOException { - - logger.trace("Block Key ({})", nodeName); - if (node == null) { - return; - } - - String keyName = null; - if (blockKeys != null && blockKeys.contains(nodeName)) { - if (node.isArray() || node.isObject()) { - propertyMap.put(nodeName, node.toString()); - } else { - propertyMap.put(nodeName, node.asText()); - } - } else if (node.isArray()) { - for (int i = 0; i < node.size(); i++) { - keyName = nodeName + "[" + i + "]"; - processJsonNode(propertyMap, blockKeys, keyName, node.get(i)); - } - } else if (node.isObject()) { - Iterator> fields = node.fields(); - while (fields.hasNext()) { - Map.Entry entry = fields.next(); - keyName = nodeName + "." + entry.getKey(); - processJsonNode(propertyMap, blockKeys, keyName, entry.getValue()); - } - } else { - propertyMap.put(nodeName, node.asText()); - } - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/validator/DataTypeValidator.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/validator/DataTypeValidator.java deleted file mode 100644 index 32d546eed..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/validator/DataTypeValidator.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.validator; - -import java.util.HashMap; -import java.util.Map; -import org.apache.commons.lang3.StringUtils; -import org.onap.ccsdk.features.model.ConfigModelException; -import org.onap.ccsdk.features.model.ValidTypes; -import org.onap.ccsdk.features.model.data.DataType; -import org.onap.ccsdk.features.model.data.PropertyDefinition; -import org.onap.ccsdk.features.model.data.ServiceTemplate; - -/** - * DataTypeValidator.java Purpose: Provide Configuration Generator DataTypeValidator - * - * @version 1.0 - */ -public class DataTypeValidator { - - private StringBuilder message; - private Map stDataTypes; - private ServiceTemplate serviceTemplate; - private PropertyDefinitionValidator propertyDefinitionValidator; - - /** - * This is a DataTypeValidator - * - * @param serviceTemplate - * @throws ConfigModelException - */ - public DataTypeValidator(ServiceTemplate serviceTemplate, StringBuilder message) throws ConfigModelException { - this.serviceTemplate = serviceTemplate; - this.message = message; - propertyDefinitionValidator = new PropertyDefinitionValidator(this.message); - stDataTypes = new HashMap<>(); - loadInitial(); - - } - - private void loadInitial() { - if (serviceTemplate != null && serviceTemplate.getDataTypes() != null) { - message.append("\n DataTypes" + serviceTemplate.getDataTypes()); - serviceTemplate.getDataTypes().forEach((dataTypeKey, dataType) -> { - stDataTypes.put(dataTypeKey, dataType); - message.append("\n Data Type (" + dataTypeKey + ") loaded successfully."); - }); - } - } - - /** - * This is a validateDataTypes - * - * @return boolean - * @throws ConfigModelException - */ - @SuppressWarnings("squid:S00112") - public boolean validateDataTypes() { - if (serviceTemplate != null && serviceTemplate.getDataTypes() != null) { - - serviceTemplate.getDataTypes().forEach((dataTypeKey, dataType) -> { - if (dataType != null) { - try { - String derivedFrom = dataType.getDerivedFrom(); - checkValidDerivedType(dataTypeKey, derivedFrom); - checkValidProperties(dataTypeKey, dataType.getProperties()); - } catch (ConfigModelException e) { - throw new RuntimeException(e); - } - - } - - }); - } - return true; - } - - private boolean checkValidDerivedType(String dataTypeName, String derivedFrom) throws ConfigModelException { - - if (StringUtils.isBlank(derivedFrom) || !ValidTypes.getValidDataTypeDerivedFrom().contains(derivedFrom)) { - throw new ConfigModelException(derivedFrom + " is not a valid derived type for Data type " + dataTypeName); - } - return true; - } - - private boolean checkValidProperties(String dataTypeName, Map properties) { - if (properties != null) { - message.append("\n validation Data Type (" + dataTypeName + ") Property."); - propertyDefinitionValidator.validatePropertyDefinition(stDataTypes, properties); - } - return true; - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/validator/NodeTypeValidator.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/validator/NodeTypeValidator.java deleted file mode 100644 index 4cb9ae14d..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/validator/NodeTypeValidator.java +++ /dev/null @@ -1,237 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.validator; - -import java.util.HashMap; -import java.util.Map; -import org.apache.commons.lang3.StringUtils; -import org.onap.ccsdk.features.model.ConfigModelConstant; -import org.onap.ccsdk.features.model.ConfigModelException; -import org.onap.ccsdk.features.model.ValidTypes; -import org.onap.ccsdk.features.model.data.CapabilityDefinition; -import org.onap.ccsdk.features.model.data.DataType; -import org.onap.ccsdk.features.model.data.InterfaceDefinition; -import org.onap.ccsdk.features.model.data.NodeType; -import org.onap.ccsdk.features.model.data.OperationDefinition; -import org.onap.ccsdk.features.model.data.PropertyDefinition; -import org.onap.ccsdk.features.model.data.RequirementDefinition; -import org.onap.ccsdk.features.model.data.ServiceTemplate; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -/** - * NodeTypeValidator.java Purpose: Provide Configuration Generator NodeTypeValidator - * - * @version 1.0 - */ -public class NodeTypeValidator { - private static EELFLogger logger = EELFManager.getInstance().getLogger(NodeTypeValidator.class); - private StringBuilder message; - private Map stDataTypes; - private Map stNodeTypes; - private ServiceTemplate serviceTemplate; - private PropertyDefinitionValidator propertyDefinitionValidator; - - /** - * This is a NodeTypeValidator - * - * @param serviceTemplate - * @throws ConfigModelException - */ - public NodeTypeValidator(ServiceTemplate serviceTemplate, StringBuilder message) throws ConfigModelException { - this.serviceTemplate = serviceTemplate; - this.message = message; - propertyDefinitionValidator = new PropertyDefinitionValidator(this.message); - stDataTypes = new HashMap<>(); - stNodeTypes = new HashMap<>(); - loadInitial(); - - } - - private void loadInitial() { - if (serviceTemplate != null) { - - if (serviceTemplate.getDataTypes() != null) { - serviceTemplate.getDataTypes().forEach((dataTypeKey, dataType) -> { - stDataTypes.put(dataTypeKey, dataType); - logger.trace("Data Type ({}) loaded successfully.", dataTypeKey); - }); - } - - if (serviceTemplate.getNodeTypes() != null) { - serviceTemplate.getNodeTypes().forEach((nodeTypeKey, nodeType) -> { - stNodeTypes.put(nodeTypeKey, nodeType); - logger.trace("NodeType Type ({}) loaded successfully.", nodeTypeKey); - }); - } - - } - - } - - /** - * This is a validateNodeTypes to validate the Node Type - * - * @return boolean - * @throws ConfigModelException - */ - @SuppressWarnings({"squid:S00112", "squid:S3776"}) - public boolean validateNodeTypes() { - if (serviceTemplate != null && serviceTemplate.getNodeTypes() != null) { - serviceTemplate.getNodeTypes().forEach((nodeTypeKey, nodeType) -> { - if (nodeType != null) { - message.append("\n ***** Validation Node Type (" + nodeTypeKey + "), derived from (" - + nodeType.getDerivedFrom() + ")"); - try { - validateNodeType(ConfigModelConstant.MODEL_DEFINITION_TYPE_NODE_TYPE, - nodeType.getDerivedFrom()); - - if (nodeType.getProperties() != null) { - checkValidProperties(nodeType.getProperties()); - } - - if (nodeType.getCapabilities() != null) { - validateNodeTypeCapabilities(nodeType.getCapabilities()); - } - - if (nodeType.getInterfaces() != null) { - validateNodeTypeInterface(nodeType.getInterfaces()); - } - - if (nodeType.getRequirements() != null) { - validateNodeTypeRequirement(nodeType.getRequirements()); - } - - } catch (ConfigModelException e) { - logger.error(e.getMessage()); - throw new RuntimeException(e.getMessage()); - } - - } - }); - } - return true; - } - - private boolean validateNodeType(String definitionType, String derivedFrom) throws ConfigModelException { - boolean valid = true; - if (!ConfigModelConstant.MODEL_DEFINITION_TYPE_DATA_TYPE.equalsIgnoreCase(definitionType) - && !ValidTypes.getValidNodeTypes().contains(derivedFrom)) { - throw new ConfigModelException("Not Valid Model Type (" + derivedFrom + ")"); - } - return valid; - } - - private boolean checkValidProperties(Map properties) { - if (properties != null) { - propertyDefinitionValidator.validatePropertyDefinition(stDataTypes, properties); - } - return true; - } - - @SuppressWarnings("squid:S00112") - private boolean validateNodeTypeCapabilities(Map capabilities) { - if (capabilities != null) { - capabilities.forEach((capabilityKey, capability) -> { - if (capability != null) { - Map properties = capability.getProperties(); - message.append("\n Validation Capability (" + capabilityKey + ") properties :"); - propertyDefinitionValidator.validatePropertyDefinition(stDataTypes, properties); - } - }); - } - return true; - } - - @SuppressWarnings("squid:S00112") - private boolean validateNodeTypeInterface(Map interfaces) { - if (interfaces != null) { - interfaces.forEach((interfaceKey, interfaceDefinition) -> { - if (interfaceDefinition != null && interfaceDefinition.getOperations() != null) { - validateNodeTypeInterfaceOperation(interfaceDefinition.getOperations()); - } - }); - } - return true; - } - - @SuppressWarnings("squid:S00112") - private boolean validateNodeTypeInterfaceOperation(Map operations) { - if (operations != null) { - operations.forEach((operationKey, operation) -> { - if (operation != null) { - Map inputs = operation.getInputs(); - message.append("\n Validation Operation (" + operationKey + ") Inputs :"); - propertyDefinitionValidator.validatePropertyDefinition(stDataTypes, inputs); - message.append("\n Validation Operation (" + operationKey + ") output :"); - Map outputs = operation.getOutputs(); - propertyDefinitionValidator.validatePropertyDefinition(stDataTypes, outputs); - } - }); - } - return true; - } - - @SuppressWarnings("squid:S00112") - private boolean validateNodeTypeRequirement(Map requirements) { - if (requirements != null) { - requirements.forEach((requirementKey, requirement) -> { - if (requirement != null) { - String nodeTypeName = requirement.getNode(); - String capabilityName = requirement.getCapability(); - try { - checkCapabilityPresentInNodeType(nodeTypeName, capabilityName); - } catch (ConfigModelException e) { - throw new RuntimeException(e); - } - } - }); - } - return true; - } - - private boolean checkCapabilityPresentInNodeType(String nodeTypeName, String capabilityName) - throws ConfigModelException { - if (StringUtils.isNotBlank(nodeTypeName) && StringUtils.isNotBlank(capabilityName)) { - - if (!stNodeTypes.containsKey(nodeTypeName)) { - throw new ConfigModelException(nodeTypeName + " Node Type not Defined."); - } else { - message.append("\n Node Type (" + nodeTypeName + ") Defined."); - } - - NodeType relationalNodeType = stNodeTypes.get(nodeTypeName); - - if (relationalNodeType.getCapabilities() == null) { - throw new ConfigModelException( - "Node Type (" + nodeTypeName + "), doesn't have Capability Definitions."); - } - - if (!relationalNodeType.getCapabilities().containsKey(capabilityName)) { - throw new ConfigModelException("Node Type (" + nodeTypeName + ") doesn't have (" + capabilityName - + ") Capability Definitions."); - } else { - message.append( - "\n Node Type (" + nodeTypeName + ") has (" + capabilityName + ") Capability Definitions."); - } - - } - return true; - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/validator/PropertyDefinitionValidator.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/validator/PropertyDefinitionValidator.java deleted file mode 100644 index 080fee2b6..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/validator/PropertyDefinitionValidator.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.validator; - -import java.util.Map; -import org.apache.commons.lang3.StringUtils; -import org.onap.ccsdk.features.model.ConfigModelException; -import org.onap.ccsdk.features.model.ValidTypes; -import org.onap.ccsdk.features.model.data.DataType; -import org.onap.ccsdk.features.model.data.PropertyDefinition; - -/** - * PropertyDefinitionValidator.java Purpose: Provide Configuration Generator - * PropertyDefinitionValidator - * - * @version 1.0 - */ -public class PropertyDefinitionValidator { - - StringBuilder message = new StringBuilder(); - - public PropertyDefinitionValidator(StringBuilder message) { - this.message = message; - - } - - /** - * This is a validatePropertyDefinition stored in database - * - * @param stDataTypes - * @param properties - * @return boolean - * @throws ConfigModelException - */ - @SuppressWarnings({"squid:S00112", "squid:S3776", "squid:S1192"}) - public boolean validatePropertyDefinition(Map stDataTypes, - Map properties) { - - if (stDataTypes != null && properties != null) { - properties.forEach((propertyKey, prop) -> { - if (propertyKey != null && prop != null) { - try { - String propertType = prop.getType(); - message.append("\n Validating (" + propertyKey + ") " + prop); - - if (!ValidTypes.getValidPropertType().contains(propertType) - && !stDataTypes.containsKey(propertType)) { - throw new ConfigModelException("Data Type (" + propertyKey + ") -> type(" + propertType - + ") is not a valid type."); - } else if (ValidTypes.getListPropertType().contains(propertType)) { - if (prop.getEntrySchema() == null || StringUtils.isBlank(prop.getEntrySchema().getType())) { - throw new ConfigModelException("Data Type (" + propertyKey + ") -> type (" + propertType - + ") Entity Schema is not defined."); - } - - String entitySchemaType = prop.getEntrySchema().getType(); - - if (!ValidTypes.getValidPropertType().contains(entitySchemaType) - && !stDataTypes.containsKey(entitySchemaType)) { - message.append("\n Present Data Type " + stDataTypes); - throw new ConfigModelException("Data Type (" + propertyKey + ") -> type(" + propertType - + ") -> entitySchema(" + entitySchemaType + ") is not defined."); - } - } - } catch (ConfigModelException e) { - throw new RuntimeException(e); - } - } - }); - } - return true; - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/validator/ResourceAssignmentValidator.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/validator/ResourceAssignmentValidator.java deleted file mode 100644 index 8f2efd110..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/validator/ResourceAssignmentValidator.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.validator; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import org.apache.commons.lang3.StringUtils; -import org.onap.ccsdk.features.model.ConfigModelConstant; -import org.onap.ccsdk.features.model.ConfigModelException; -import org.onap.ccsdk.features.model.data.CapabilityAssignment; -import org.onap.ccsdk.features.model.data.NodeTemplate; -import org.onap.ccsdk.features.model.data.ResourceAssignment; -import org.onap.ccsdk.features.model.utils.TopologicalSortingUtils; -import org.onap.ccsdk.features.model.utils.TransformationUtils; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -public class ResourceAssignmentValidator { - private static EELFLogger logger = EELFManager.getInstance().getLogger(ResourceAssignmentValidator.class); - private List assignments; - private Map resourceAssignmentMap = new HashMap<>(); - private StringBuilder validationMessage = new StringBuilder(); - - public ResourceAssignmentValidator(NodeTemplate nodeTemplate) throws ConfigModelException { - - if (nodeTemplate != null && nodeTemplate.getCapabilities() != null) { - CapabilityAssignment capabilityAssignment = - nodeTemplate.getCapabilities().get(ConfigModelConstant.CAPABILITY_PROPERTY_MAPPING); - if (capabilityAssignment != null && capabilityAssignment.getProperties() != null) { - Object mappingObject = - capabilityAssignment.getProperties().get(ConfigModelConstant.CAPABILITY_PROPERTY_MAPPING); - if (mappingObject != null) { - String mappingContent = TransformationUtils.getJson(mappingObject); - if (StringUtils.isNotBlank(mappingContent)) { - this.assignments = - TransformationUtils.getListfromJson(mappingContent, ResourceAssignment.class); - } else { - validationMessage - .append(String.format("Failed to transform Mapping Content (%s) ", mappingContent)); - throw new ConfigModelException( - String.format("Failed to transform Mapping Content (%s) ", mappingContent)); - } - } - } - } - } - - public ResourceAssignmentValidator(List assignments) { - this.assignments = assignments; - } - - /** - * This is a validateResourceAssignment to validate the Topology Template - * - * @return boolean - * @throws ConfigModelException - */ - public boolean validateResourceAssignment() throws ConfigModelException { - if (assignments != null && !assignments.isEmpty()) { - validateDuplicateDictionaryKeys(); - validateCyclicDependencty(); - if (validationMessage.length() > 0) { - logger.error("Resourece Assignment Validation : {}", validationMessage); - throw new ConfigModelException("Resourece Assignment Validation :" + validationMessage.toString()); - } - } - return true; - } - - @SuppressWarnings("squid:S3776") - private void validateDuplicateDictionaryKeys() { - this.assignments.forEach(resourceMapping -> { - if (resourceMapping != null) { - if (!resourceAssignmentMap.containsKey(resourceMapping.getName())) { - resourceAssignmentMap.put(resourceMapping.getName(), resourceMapping); - } else { - validationMessage.append(String.format("Duplicate Assignment Template Key (%s) is Present", - resourceMapping.getName())); - } - } - }); - - if (!assignments.isEmpty()) { - Set uniqueSet = new HashSet<>(); - for (ResourceAssignment resourceAssignment : assignments) { - if (resourceAssignment != null) { - boolean added = uniqueSet.add(resourceAssignment.getDictionaryName()); - if (!added) { - validationMessage.append( - String.format("Duplicate Assignment Dictionary Key (%s) present with Template Key (%s)", - resourceAssignment.getDictionaryName(), resourceAssignment.getName())); - } - } - } - } - } - - private void validateCyclicDependencty() { - TopologicalSortingUtils topologySorting = new TopologicalSortingUtils<>(); - this.resourceAssignmentMap.forEach((mappingKey, mapping) -> { - if (mapping != null) { - if (mapping.getDependencies() != null && !mapping.getDependencies().isEmpty()) { - for (String dependency : mapping.getDependencies()) { - topologySorting.add(resourceAssignmentMap.get(dependency), mapping); - } - } else { - topologySorting.add(null, mapping); - } - } - }); - - if (!topologySorting.isDag()) { - String graph = getTopologicalGraph(topologySorting); - validationMessage.append("Cyclic Dependency :" + graph); - } - } - - public String getTopologicalGraph(TopologicalSortingUtils topologySorting) { - StringBuilder s = new StringBuilder(); - if (topologySorting != null) { - Map> neighbors = topologySorting.getNeighbors(); - - neighbors.forEach((v, vs) -> { - if (v == null) { - s.append("\n * -> ["); - List links = vs; - for (ResourceAssignment resourceAssignment : links) { - s.append("(" + resourceAssignment.getDictionaryName() + ":" + resourceAssignment.getName() - + "),"); - } - s.append("]"); - } else { - s.append("\n (" + v.getDictionaryName() + ":" + v.getName() + ") -> ["); - List links = vs; - for (ResourceAssignment resourceAssignment : links) { - s.append("(" + resourceAssignment.getDictionaryName() + ":" + resourceAssignment.getName() - + "),"); - } - s.append("]"); - } - }); - } - return s.toString(); - } -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/validator/ServiceTemplateValidator.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/validator/ServiceTemplateValidator.java deleted file mode 100644 index f503427c8..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/validator/ServiceTemplateValidator.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.validator; - -import java.util.HashMap; -import java.util.Map; -import org.apache.commons.lang3.StringUtils; -import org.onap.ccsdk.features.model.ConfigModelConstant; -import org.onap.ccsdk.features.model.ConfigModelException; -import org.onap.ccsdk.features.model.data.ServiceTemplate; -import org.onap.ccsdk.features.model.utils.TransformationUtils; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -/** - * ServiceTemplateValidator.java Purpose: Provide Configuration Generator ServiceTemplateValidator - * - * @version 1.0 - */ - -public class ServiceTemplateValidator { - - private static EELFLogger logger = EELFManager.getInstance().getLogger(ServiceTemplateValidator.class); - - private Map metaData = new HashMap<>(); - - StringBuilder message = new StringBuilder(); - - /** - * This is a validateServiceTemplate - * - * @param serviceTemplateContent - * @return boolean - * @throws ConfigModelException - */ - @SuppressWarnings("squid:S00112") - public boolean validateServiceTemplate(String serviceTemplateContent) throws ConfigModelException { - if (StringUtils.isNotBlank(serviceTemplateContent)) { - ServiceTemplate serviceTemplate = - TransformationUtils.readValue(serviceTemplateContent, ServiceTemplate.class); - return validateServiceTemplate(serviceTemplate); - } else { - throw new ConfigModelException( - "Service Template Content is (" + serviceTemplateContent + ") not Defined."); - } - } - - /** - * This is a validateServiceTemplate - * - * @param serviceTemplate - * @return boolean - * @throws ConfigModelException - */ - @SuppressWarnings("squid:S00112") - public boolean validateServiceTemplate(ServiceTemplate serviceTemplate) throws ConfigModelException { - if (serviceTemplate != null) { - try { - validateMetaData(serviceTemplate); - (new DataTypeValidator(serviceTemplate, message)).validateDataTypes(); - (new NodeTypeValidator(serviceTemplate, message)).validateNodeTypes(); - (new TopologyTemplateValidator(serviceTemplate, message)).validateTopologyTemplate(); - logger.debug("Validation Message : {}", message); - } catch (Exception e) { - throw new ConfigModelException( - "Validation Failed " + e.toString() + ",Message Trace : \n" + message.toString()); - } - - } else { - throw new ConfigModelException("Service Template is not defined."); - } - return true; - } - - /** - * This is a getMetaData to get the key information during the - * - * @return Map - */ - public Map getMetaData() { - return metaData; - } - - private void validateMetaData(ServiceTemplate serviceTemplate) throws ConfigModelException { - if (serviceTemplate.getMetadata() != null) { - this.metaData.putAll(serviceTemplate.getMetadata()); - - String author = serviceTemplate.getMetadata().get(ConfigModelConstant.SERVICE_TEMPLATE_KEY_ARTIFACT_AUTHOR); - String serviceTemplateName = - serviceTemplate.getMetadata().get(ConfigModelConstant.SERVICE_TEMPLATE_KEY_ARTIFACT_NAME); - String serviceTemplateVersion = - serviceTemplate.getMetadata().get(ConfigModelConstant.SERVICE_TEMPLATE_KEY_ARTIFACT_VERSION); - - if (StringUtils.isBlank(author)) { - throw new ConfigModelException("Service Template Metadata (author) Information is missing."); - } - - if (StringUtils.isBlank(serviceTemplateName)) { - throw new ConfigModelException( - "Service Template Metadata (service-template-name) Information is missing."); - } - - if (StringUtils.isBlank(serviceTemplateVersion)) { - throw new ConfigModelException( - "Service Template Metadata (service-template-version) Information is missing."); - } - - } else { - throw new ConfigModelException("Service Template Metadata Information is missing."); - } - - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/validator/TopologyTemplateValidator.java b/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/validator/TopologyTemplateValidator.java deleted file mode 100644 index c735a54cd..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/java/org/onap/ccsdk/features/model/validator/TopologyTemplateValidator.java +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.validator; - -import java.util.HashMap; -import java.util.Map; -import org.apache.commons.lang3.StringUtils; -import org.onap.ccsdk.features.model.ConfigModelConstant; -import org.onap.ccsdk.features.model.ConfigModelException; -import org.onap.ccsdk.features.model.data.DataType; -import org.onap.ccsdk.features.model.data.NodeTemplate; -import org.onap.ccsdk.features.model.data.NodeType; -import org.onap.ccsdk.features.model.data.PropertyDefinition; -import org.onap.ccsdk.features.model.data.RequirementAssignment; -import org.onap.ccsdk.features.model.data.ServiceTemplate; -import org.onap.ccsdk.features.model.data.TopologyTemplate; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -/** - * TopologyTemplateValidator.java Purpose: Provide Configuration Generator TopologyTemplateValidator - * - * @version 1.0 - */ -public class TopologyTemplateValidator { - private static EELFLogger logger = EELFManager.getInstance().getLogger(TopologyTemplateValidator.class); - private StringBuilder message; - private Map stDataTypes; - private Map stNodeTypes; - private Map stNodeTemplates; - private ServiceTemplate serviceTemplate; - private PropertyDefinitionValidator propertyDefinitionValidator; - - /** - * This is a TopologyTemplateValidator - * - * @param serviceTemplate - * @throws ConfigModelException - */ - public TopologyTemplateValidator(ServiceTemplate serviceTemplate, StringBuilder message) { - this.serviceTemplate = serviceTemplate; - this.message = message; - propertyDefinitionValidator = new PropertyDefinitionValidator(this.message); - stDataTypes = new HashMap<>(); - stNodeTypes = new HashMap<>(); - stNodeTemplates = new HashMap<>(); - loadInitial(); - } - - private void loadInitial() { - if (serviceTemplate != null) { - - if (serviceTemplate.getDataTypes() != null) { - serviceTemplate.getDataTypes().forEach((dataTypeKey, dataType) -> { - stDataTypes.put(dataTypeKey, dataType); - logger.trace("Data Type ({}) loaded successfully.", dataTypeKey); - }); - } - - if (serviceTemplate.getNodeTypes() != null) { - serviceTemplate.getNodeTypes().forEach((nodeTypeKey, nodeType) -> { - stNodeTypes.put(nodeTypeKey, nodeType); - logger.trace("Node Type ({}) loaded successfully.", nodeTypeKey); - }); - } - - if (serviceTemplate.getTopologyTemplate() != null) { - TopologyTemplate topologyTemplate = serviceTemplate.getTopologyTemplate(); - - if (topologyTemplate.getNodeTemplates() != null) { - topologyTemplate.getNodeTemplates().forEach((nodeTemplateKey, nodeTemplate) -> { - stNodeTemplates.put(nodeTemplateKey, nodeTemplate); - logger.trace("Node Template ({}) Type loaded successfully.", nodeTemplateKey); - }); - } - } - } - - } - - /** - * This is a validateTopologyTemplate to validate the Topology Template - * - * @return boolean - * @throws ConfigModelException - */ - public boolean validateTopologyTemplate() { - if (serviceTemplate != null && serviceTemplate.getTopologyTemplate() != null) { - - checkValidInputProperties(serviceTemplate.getTopologyTemplate().getInputs()); - - validateNodeTemplates(serviceTemplate.getTopologyTemplate().getNodeTemplates()); - } - return true; - } - - private boolean checkValidInputProperties(Map properties) { - if (properties != null) { - message.append("\n Validation topology template input properties :"); - propertyDefinitionValidator.validatePropertyDefinition(stDataTypes, properties); - } - return true; - } - - @SuppressWarnings({"squid:S00112", "squid:S3776"}) - private boolean validateNodeTemplates(Map nodeTemplates) { - if (nodeTemplates != null) { - nodeTemplates.forEach((nodeTemplateKey, nodeTemplate) -> { - if (nodeTemplate != null) { - message.append("\n ##### Validation Node Template (" + nodeTemplateKey + "), of type (" - + nodeTemplate.getType() + ")"); - - String nodeTypeName = nodeTemplate.getType(); - if (!stNodeTypes.containsKey(nodeTypeName)) { - throw new RuntimeException("Node Type (" + nodeTypeName + ")not Defined."); - } - - if (nodeTemplate.getRequirements() != null) { - validateNodeTemplateRequirement(nodeTemplate.getRequirements()); - } - - // Validate Resource Assignments - NodeType nodeType = stNodeTypes.get(nodeTypeName); - if (nodeType != null - && ConfigModelConstant.MODEL_TYPE_NODE_ARTIFACT.equals(nodeType.getDerivedFrom())) { - logger.info("Validating Resource Assignment NodeTemplate ({}).", nodeTemplateKey); - ResourceAssignmentValidator resourceAssignmentValidator; - try { - resourceAssignmentValidator = new ResourceAssignmentValidator(nodeTemplate); - resourceAssignmentValidator.validateResourceAssignment(); - } catch (ConfigModelException e) { - throw new RuntimeException(e); - } - - } - } - }); - } - return true; - } - - @SuppressWarnings("squid:S00112") - private boolean validateNodeTemplateRequirement(Map requirements) { - if (requirements != null) { - requirements.forEach((requirementKey, requirement) -> { - if (requirement != null) { - String requirementnodeTypeName = requirement.getNode(); - String capabilityName = requirement.getCapability(); - try { - checkCapabilityPresentInNodeTemplate(requirementnodeTypeName, capabilityName); - } catch (ConfigModelException e) { - throw new RuntimeException(e); - } - } - }); - } - return true; - } - - private boolean checkCapabilityPresentInNodeTemplate(String nodeTemplateName, String capabilityName) - throws ConfigModelException { - if (StringUtils.isNotBlank(nodeTemplateName) && StringUtils.isNotBlank(capabilityName)) { - - if (!stNodeTemplates.containsKey(nodeTemplateName)) { - throw new ConfigModelException(nodeTemplateName + " Node Template not Defined."); - } else { - message.append("\n Node Template (" + nodeTemplateName + ") Defined."); - } - - NodeTemplate relationalNodeType = stNodeTemplates.get(nodeTemplateName); - - if (relationalNodeType.getCapabilities() == null) { - throw new ConfigModelException( - "Node Template (" + nodeTemplateName + "), doesn't have Capability Definitions."); - } - - if (!relationalNodeType.getCapabilities().containsKey(capabilityName)) { - throw new ConfigModelException("Node Type (" + nodeTemplateName + ") doesn't have (" + capabilityName - + ") Capability Definitions."); - } else { - message.append("\n Node Template (" + nodeTemplateName + ") has (" + capabilityName - + ") Capability Definitions."); - } - - } - return true; - } -} diff --git a/blueprints-processor/plugin/model-provider/src/main/resources/OSGI-INF/blueprint/impl-blueprint.xml b/blueprints-processor/plugin/model-provider/src/main/resources/OSGI-INF/blueprint/impl-blueprint.xml deleted file mode 100644 index 5a07f94c6..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/resources/OSGI-INF/blueprint/impl-blueprint.xml +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/blueprints-processor/plugin/model-provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml b/blueprints-processor/plugin/model-provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml deleted file mode 100644 index 5a07f94c6..000000000 --- a/blueprints-processor/plugin/model-provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/model/ResourceDictionaryUtilsTest.java b/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/model/ResourceDictionaryUtilsTest.java deleted file mode 100644 index 760c245fd..000000000 --- a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/model/ResourceDictionaryUtilsTest.java +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model; - -import java.util.Arrays; -import java.util.HashMap; -import org.junit.Assert; -import org.junit.Test; -import org.onap.ccsdk.features.model.data.PropertyDefinition; -import org.onap.ccsdk.features.model.data.ResourceAssignment; -import org.onap.ccsdk.features.model.data.dict.ResourceDefinition; -import org.onap.ccsdk.features.model.data.dict.SourcesDefinition; -import org.onap.ccsdk.features.model.data.dict.SourcesProperties; -import org.onap.ccsdk.features.model.utils.ResourceDictionaryUtils; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -public class ResourceDictionaryUtilsTest { - private static EELFLogger logger = EELFManager.getInstance().getLogger(ResourceDictionaryUtilsTest.class); - - @Test - public void validateSingleInputSource() { - try { - logger.info(" **************** Validating validateSingleInputSource *****************"); - ResourceAssignment resourceAssignment = new ResourceAssignment(); - resourceAssignment.setName("test-input-key"); - - PropertyDefinition propertyDefinition = new PropertyDefinition(); - propertyDefinition.setType(ValidTypes.DATA_TYPE_STRING); - - SourcesProperties sourcesProp = new SourcesProperties(); - sourcesProp.setDependencies(Arrays.asList(new String[] {"vnf-id", "vnf-name"})); - - SourcesDefinition sourceDef = new SourcesDefinition(); - sourceDef.setProperties(sourcesProp); - - HashMap sources = new HashMap<>(); - sources.put("input", sourceDef); - - ResourceDefinition resourceDefinition = new ResourceDefinition(); - resourceDefinition.setProperty(propertyDefinition); - resourceDefinition.setSources(sources); - - ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, resourceDefinition); - - Assert.assertNotNull("Resource assignment input sourceName is missing ", - resourceAssignment.getDictionarySource()); - Assert.assertNotNull("Resource assignment input sourceName property is missing ", - resourceAssignment.getProperty()); - Assert.assertNotNull("Resource assignment input sourceName property type is missing ", - resourceAssignment.getProperty().getType()); - - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Test - public void validateSingleDbSource() { - try { - logger.info(" **************** Validating validateSingleDbSource *****************"); - ResourceAssignment resourceAssignment = new ResourceAssignment(); - resourceAssignment.setName("test-db-key"); - - PropertyDefinition propertyDefinition = new PropertyDefinition(); - propertyDefinition.setType(ValidTypes.DATA_TYPE_STRING); - - SourcesProperties sourcesProp = new SourcesProperties(); - sourcesProp.setDependencies(Arrays.asList(new String[] {"vnf-id", "vnf-name"})); - - SourcesDefinition sourceDef = new SourcesDefinition(); - sourceDef.setProperties(sourcesProp); - - HashMap sources = new HashMap<>(); - sources.put("db", sourceDef); - - ResourceDefinition resourceDefinition = new ResourceDefinition(); - resourceDefinition.setProperty(propertyDefinition); - resourceDefinition.setSources(sources); - - ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, resourceDefinition); - Assert.assertNotNull("Resource assignment db sourceName sourceName is missing ", - resourceAssignment.getDictionarySource()); - Assert.assertNotNull("Resource assignment db sourceName sourceName property is missing ", - resourceAssignment.getProperty()); - Assert.assertNotNull("Resource assignment db sourceName sourceName property type is missing ", - resourceAssignment.getProperty().getType()); - - Assert.assertNotNull("Resource assignment db dependecy is missing ", resourceAssignment.getDependencies()); - Assert.assertEquals("Resource assignment db dependecy count mismatch ", 2, - resourceAssignment.getDependencies().size()); - - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Test - public void validateMultiSource() { - try { - logger.info(" **************** Validating validateMultiSource *****************"); - ResourceAssignment resourceAssignment = new ResourceAssignment(); - resourceAssignment.setName("test-multi-key"); - - PropertyDefinition propertyDefinition = new PropertyDefinition(); - propertyDefinition.setType(ValidTypes.DATA_TYPE_STRING); - - SourcesProperties sourcesProp = new SourcesProperties(); - sourcesProp.setDependencies(Arrays.asList(new String[] {"vnf-id", "vnf-name"})); - - SourcesDefinition sourceDef = new SourcesDefinition(); - sourceDef.setProperties(sourcesProp); - - HashMap sources = new HashMap<>(); - sources.put("input", sourceDef); - sources.put("mdsal", sourceDef); - - ResourceDefinition resourceDefinition = new ResourceDefinition(); - resourceDefinition.setProperty(propertyDefinition); - resourceDefinition.setSources(sources); - - ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, resourceDefinition); - Assert.assertNotNull("Resource assignment db sourceName sourceName property is missing ", - resourceAssignment.getProperty()); - Assert.assertNotNull("Resource assignment db sourceName sourceName property type is missing ", - resourceAssignment.getProperty().getType()); - Assert.assertNull("Resource assignment multi sourceName sourceName definition is present ", - resourceAssignment.getDictionarySource()); - Assert.assertNull("Resource assignment multi sourceName dependecy is present ", - resourceAssignment.getDependencies()); - - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Test - public void testSourceDefault() { - logger.info(" **************** Validating testSourceDefault *****************"); - ResourceAssignment resourceAssignment = new ResourceAssignment(); - resourceAssignment.setName("test-input-key"); - - PropertyDefinition propertyDefinition = new PropertyDefinition(); - propertyDefinition.setType(ValidTypes.DATA_TYPE_STRING); - - SourcesProperties sourcesProp = new SourcesProperties(); - sourcesProp.setDependencies(Arrays.asList(new String[] {"vnf-id", "vnf-name"})); - - SourcesDefinition sourceDef = new SourcesDefinition(); - sourceDef.setProperties(sourcesProp); - - HashMap sources = new HashMap<>(); - sources.put("default", sourceDef); - - ResourceDefinition resourceDefinition = new ResourceDefinition(); - resourceDefinition.setProperty(propertyDefinition); - resourceDefinition.setSources(sources); - - ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, resourceDefinition); - - Assert.assertNotNull("Resource assignment default sourceName is missing ", - resourceAssignment.getDictionarySource()); - Assert.assertNotNull("Resource assignment default sourceName property is missing ", - resourceAssignment.getProperty()); - Assert.assertNotNull("Resource assignment default sourceName property type is missing ", - resourceAssignment.getProperty().getType()); - } - - @Test - public void testSourceMdsal() { - logger.info(" **************** Validating testSourceMdsal *****************"); - ResourceAssignment resourceAssignment = new ResourceAssignment(); - resourceAssignment.setName("test-input-key"); - - PropertyDefinition propertyDefinition = new PropertyDefinition(); - propertyDefinition.setType(ValidTypes.DATA_TYPE_STRING); - - SourcesProperties sourcesProp = new SourcesProperties(); - sourcesProp.setDependencies(Arrays.asList(new String[] {"vnf-id", "vnf-name"})); - - SourcesDefinition sourceDef = new SourcesDefinition(); - sourceDef.setProperties(sourcesProp); - - HashMap sources = new HashMap<>(); - sources.put("mdsal", sourceDef); - - ResourceDefinition resourceDefinition = new ResourceDefinition(); - resourceDefinition.setProperty(propertyDefinition); - resourceDefinition.setSources(sources); - - ResourceDictionaryUtils.populateSourceMapping(resourceAssignment, resourceDefinition); - - Assert.assertNotNull("Resource assignment mdsal sourceName is missing ", - resourceAssignment.getDictionarySource()); - Assert.assertNotNull("Resource assignment mdsal sourceName property is missing ", - resourceAssignment.getProperty()); - Assert.assertNotNull("Resource assignment mdsal sourceName property type is missing ", - resourceAssignment.getProperty().getType()); - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/model/utils/JsonParserUtilsTest.java b/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/model/utils/JsonParserUtilsTest.java deleted file mode 100644 index 8ff1ff8de..000000000 --- a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/model/utils/JsonParserUtilsTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.utils; - -import org.junit.Assert; -import org.junit.Test; -import com.fasterxml.jackson.databind.JsonNode; - -public class JsonParserUtilsTest { - - @Test - public void testParse() { - final String jsonExample = "{\"key\":\"value\"}"; - - JsonNode rootJsonNode = JsonParserUtils.parse(jsonExample, "$"); - Assert.assertEquals(jsonExample, rootJsonNode.toString()); - - JsonNode keyJsonNode = JsonParserUtils.parse(rootJsonNode, "$['key']"); - Assert.assertEquals("value", keyJsonNode.asText()); - - Assert.assertEquals(jsonExample, - JsonParserUtils.parseNSet("{\"key\":\"NOT_VALUE\"}", "$['key']", keyJsonNode).toString()); - - rootJsonNode = JsonParserUtils.parse("{\"key\":\"NOT_VALUE\"}", "$"); - Assert.assertEquals(jsonExample, JsonParserUtils.parseNSet(rootJsonNode, "$['key']", keyJsonNode).toString()); - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/model/utils/JsonUtilsTest.java b/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/model/utils/JsonUtilsTest.java deleted file mode 100644 index 96d5f89f5..000000000 --- a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/model/utils/JsonUtilsTest.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.utils; - -import static org.junit.Assert.assertTrue; -import org.junit.Test; -import org.onap.ccsdk.features.model.ValidTypes; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.JsonNodeFactory; -import com.fasterxml.jackson.databind.node.ObjectNode; - -public class JsonUtilsTest { - - @Test - public void testPopulatePrimitiveValues() { - ObjectNode objectNode = JsonNodeFactory.instance.objectNode(); - JsonUtils.populatePrimitiveValues("key1", "value", "", objectNode); - JsonUtils.populatePrimitiveValues("key2", true, ValidTypes.DATA_TYPE_BOOLEAN, objectNode); - JsonUtils.populatePrimitiveValues("key3", 1, ValidTypes.DATA_TYPE_INTEGER, objectNode); - JsonUtils.populatePrimitiveValues("key4", 1.1f, ValidTypes.DATA_TYPE_FLOAT, objectNode); - JsonUtils.populatePrimitiveValues("key5", "13213123131", ValidTypes.DATA_TYPE_TIMESTAMP, objectNode); - - assertTrue("value".equals(objectNode.get("key1").asText())); - assertTrue(objectNode.get("key2").asBoolean()); - assertTrue(objectNode.get("key3").asInt() == 1); - assertTrue(objectNode.get("key4").floatValue() == 1.1f); - assertTrue("13213123131".equals(objectNode.get("key5").asText())); - } - - @Test - public void testPopulatePrimitiveValuesArrayNode() { - ArrayNode objectNode = JsonNodeFactory.instance.arrayNode(); - JsonUtils.populatePrimitiveValues("value", "", objectNode); - JsonUtils.populatePrimitiveValues(true, ValidTypes.DATA_TYPE_BOOLEAN, objectNode); - JsonUtils.populatePrimitiveValues(1, ValidTypes.DATA_TYPE_INTEGER, objectNode); - JsonUtils.populatePrimitiveValues(1.1f, ValidTypes.DATA_TYPE_FLOAT, objectNode); - JsonUtils.populatePrimitiveValues("13213123131", ValidTypes.DATA_TYPE_TIMESTAMP, objectNode); - - assertTrue(objectNode.size() == 5); - } - - @Test - public void testPopulatePrimitiveDefaultValues() { - ObjectNode objectNode = JsonNodeFactory.instance.objectNode(); - JsonUtils.populatePrimitiveDefaultValues("key1", "", objectNode); - JsonUtils.populatePrimitiveDefaultValues("key2", ValidTypes.DATA_TYPE_BOOLEAN, objectNode); - JsonUtils.populatePrimitiveDefaultValues("key3", ValidTypes.DATA_TYPE_INTEGER, objectNode); - JsonUtils.populatePrimitiveDefaultValues("key4", ValidTypes.DATA_TYPE_FLOAT, objectNode); - - assertTrue("".equals(objectNode.get("key1").asText())); - assertTrue(objectNode.get("key2").asBoolean() == false); - assertTrue(objectNode.get("key3").asInt() == 0); - assertTrue(objectNode.get("key4").floatValue() == 0.0f); - } - - @Test - public void testPopulatePrimitiveDefaultValuesForArrayNode() { - ArrayNode objectNode = JsonNodeFactory.instance.arrayNode(); - JsonUtils.populatePrimitiveDefaultValuesForArrayNode("", objectNode); - JsonUtils.populatePrimitiveDefaultValuesForArrayNode(ValidTypes.DATA_TYPE_BOOLEAN, objectNode); - JsonUtils.populatePrimitiveDefaultValuesForArrayNode(ValidTypes.DATA_TYPE_INTEGER, objectNode); - JsonUtils.populatePrimitiveDefaultValuesForArrayNode(ValidTypes.DATA_TYPE_FLOAT, objectNode); - - assertTrue(objectNode.size() == 4); - } - - @Test - public void testPopulateJsonNodeValues() { - ObjectNode objectNode = JsonNodeFactory.instance.objectNode(); - JsonUtils.populateJsonNodeValues("key1", JsonNodeFactory.instance.textNode("value"), - ValidTypes.DATA_TYPE_STRING, objectNode); - JsonUtils.populateJsonNodeValues("key2", JsonNodeFactory.instance.booleanNode(true), - ValidTypes.DATA_TYPE_BOOLEAN, objectNode); - JsonUtils.populateJsonNodeValues("key3", JsonNodeFactory.instance.numberNode(1), ValidTypes.DATA_TYPE_INTEGER, - objectNode); - JsonUtils.populateJsonNodeValues("key4", JsonNodeFactory.instance.numberNode(1.1f), ValidTypes.DATA_TYPE_FLOAT, - objectNode); - JsonUtils.populateJsonNodeValues("key5", JsonNodeFactory.instance.textNode("13213123131"), - ValidTypes.DATA_TYPE_TIMESTAMP, objectNode); - assertTrue(objectNode.get("key2").asBoolean()); - - assertTrue("value".equals(objectNode.get("key1").asText())); - assertTrue(objectNode.get("key2").asBoolean()); - assertTrue(objectNode.get("key3").asInt() == 1); - assertTrue(objectNode.get("key4").floatValue() == 1.1f); - assertTrue("13213123131".equals(objectNode.get("key5").asText())); - } -} diff --git a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/model/utils/ResourceAssignmentUtilsTest.java b/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/model/utils/ResourceAssignmentUtilsTest.java deleted file mode 100644 index 60ef24049..000000000 --- a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/model/utils/ResourceAssignmentUtilsTest.java +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.utils; - -import static org.junit.Assert.assertTrue; -import java.io.File; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.junit.Test; -import org.onap.ccsdk.features.model.ConfigModelConstant; -import org.onap.ccsdk.features.model.ConfigModelException; -import org.onap.ccsdk.features.model.ValidTypes; -import org.onap.ccsdk.features.model.data.PropertyDefinition; -import org.onap.ccsdk.features.model.data.ResourceAssignment; -import org.onap.ccsdk.features.model.data.dict.ResourceDefinition; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; - -public class ResourceAssignmentUtilsTest { - - @Test - public void testGetArtifactNodeContent() { - String nodeTemplateName = "nodeTemplateNmae"; - String templateContent = "content"; - Map context = new HashMap(); - context.put(ConfigModelConstant.PROPERTY_NODE_TEMPLATES_DOT + nodeTemplateName + ".content", templateContent); - - String retrievedContent = ResourceAssignmentUtils.getArtifactNodeContent(nodeTemplateName, context); - - assertTrue(templateContent.equals(retrievedContent)); - } - - @Test - public void testGetArtifactNodeMapping() { - String nodeTemplateName = "nodeTemplateNmae"; - String templateContent = "[]"; - Map context = new HashMap(); - context.put(ConfigModelConstant.PROPERTY_NODE_TEMPLATES_DOT + nodeTemplateName + ".mapping", templateContent); - - List map = ResourceAssignmentUtils.getArtifactNodeMapping(nodeTemplateName, context); - assertTrue(map.size() == 0); - } - - @Test - public void testCleanContextTemplateNDictionaryKeys() { - String recipeName = "recipe"; - Map componentContext = new HashMap(); - componentContext.put(ConfigModelConstant.PROPERTY_ACTION_NAME, recipeName); - componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + recipeName + ".", "value1"); - componentContext.put(ConfigModelConstant.PROPERTY_RECIPE_KEY_DOT + recipeName + ".", "value2"); - ResourceAssignmentUtils.cleanContextTemplateNDictionaryKeys(componentContext); - - assertTrue(componentContext.size() == 1); - } - - @Test - public void testGetDictionaryKeyValue() { - String recipeName = "recipe"; - String dictionaryName = "dictionaryKey"; - Map componentContext = new HashMap(); - componentContext.put(ConfigModelConstant.PROPERTY_ACTION_NAME, recipeName); - componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + recipeName + "." + dictionaryName, - "value1"); - ResourceAssignment resourceAssignment = new ResourceAssignment(); - resourceAssignment.setDictionaryName(dictionaryName); - - String value = (String) ResourceAssignmentUtils.getDictionaryKeyValue(componentContext, resourceAssignment); - assertTrue("value1".equals(value)); - } - - @Test - public void testGetDictionaryKeyValueWithDictionaryDefinition() { - String recipeName = "recipe"; - String dictionaryName = "dictionaryKey"; - Map componentContext = new HashMap(); - componentContext.put(ConfigModelConstant.PROPERTY_ACTION_NAME, recipeName); - componentContext.put(ConfigModelConstant.PROPERTY_DICTIONARY_KEY_DOT + recipeName + "." + dictionaryName, - "value1"); - ResourceDefinition resourceDefinition = new ResourceDefinition(); - resourceDefinition.setName(dictionaryName); - - String value = (String) ResourceAssignmentUtils.getDictionaryKeyValue(componentContext, resourceDefinition); - assertTrue("value1".equals(value)); - } - - @Test - public void testGetTemplateKeyValue() { - String recipeName = "recipe"; - String templateKeyName = "templateKey"; - Map componentContext = new HashMap(); - componentContext.put(ConfigModelConstant.PROPERTY_ACTION_NAME, recipeName); - componentContext.put(ConfigModelConstant.PROPERTY_RECIPE_KEY_DOT + recipeName + "." + templateKeyName, - "value1"); - ResourceAssignment resourceAssignment = new ResourceAssignment(); - resourceAssignment.setName(templateKeyName); - - String value = (String) ResourceAssignmentUtils.getTemplateKeyValue(componentContext, resourceAssignment); - assertTrue("value1".equals(value)); - } - - @Test - public void testSetResourceDataValue() throws Exception { - String recipeName = "recipe"; - Map componentContext = new HashMap(); - componentContext.put(ConfigModelConstant.PROPERTY_ACTION_NAME, recipeName); - - ResourceAssignment resourceAssignment = createResourceAssignment("name1", ValidTypes.DATA_TYPE_STRING, null); - Object value = "value"; - ResourceAssignmentUtils.setResourceDataValue(componentContext, resourceAssignment, value); - assertTrue(value.equals(resourceAssignment.getProperty().getValue())); - - resourceAssignment = createResourceAssignment("name1", ValidTypes.DATA_TYPE_INTEGER, null); - value = "1"; - ResourceAssignmentUtils.setResourceDataValue(componentContext, resourceAssignment, value); - assertTrue((int) resourceAssignment.getProperty().getValue() == 1); - - resourceAssignment = createResourceAssignment("name1", ValidTypes.DATA_TYPE_BOOLEAN, null); - value = "true"; - ResourceAssignmentUtils.setResourceDataValue(componentContext, resourceAssignment, value); - assertTrue((boolean) resourceAssignment.getProperty().getValue()); - - resourceAssignment = createResourceAssignment("name1", ValidTypes.DATA_TYPE_FLOAT, null); - value = "1.1"; - ResourceAssignmentUtils.setResourceDataValue(componentContext, resourceAssignment, value); - assertTrue((float) resourceAssignment.getProperty().getValue() == 1.1f); - } - - @Test - public void testSetFailedResourceDataValue() throws Exception { - ResourceAssignment resourceAssignment = createResourceAssignment("name1", ValidTypes.DATA_TYPE_STRING, "value"); - String message = "message"; - ResourceAssignmentUtils.setFailedResourceDataValue(null, resourceAssignment, message); - - assertTrue(message.equals(resourceAssignment.getMessage())); - assertTrue(ConfigModelConstant.STATUS_FAILURE.equals(resourceAssignment.getStatus())); - } - - @Test(expected = ConfigModelException.class) - public void testAssertTemplateKeyValueNotNull() throws Exception { - Map componentContext = null; - ResourceAssignment resourceAssignment = createResourceAssignment("name1", ValidTypes.DATA_TYPE_STRING, "value"); - ResourceAssignmentUtils.assertTemplateKeyValueNotNull(componentContext, resourceAssignment); - } - - @Test - public void testGenerateResourceDataForAssignments() throws Exception { - List assignments = new ArrayList(); - assignments.add(createResourceAssignment("name1", ValidTypes.DATA_TYPE_STRING, "string")); - assignments.add(createResourceAssignment("name2", ValidTypes.DATA_TYPE_BOOLEAN, true)); - assignments.add(createResourceAssignment("name3", ValidTypes.DATA_TYPE_INTEGER, 1)); - assignments.add(createResourceAssignment("name4", ValidTypes.DATA_TYPE_FLOAT, 1.1f)); - assignments.add(createResourceAssignment("name5", ValidTypes.DATA_TYPE_TIMESTAMP, "1523908097735")); - assignments.add(createResourceAssignment("name6", "", new HashMap())); - ResourceAssignmentUtils.generateResourceDataForAssignments(assignments); - } - - public void testResourceAssignmentForNullEmptyValues() throws Exception { - - ObjectMapper mapper = new ObjectMapper(); - JsonNode raContent = - mapper.readTree(new File("src/test/resources/service_templates/ra-content-with-mising-value.json")); - - List assignments = - mapper.readValue(raContent.toString(), new TypeReference>() {}); - - ResourceAssignmentUtils.generateResourceDataForAssignments(assignments); - } - - private ResourceAssignment createResourceAssignment(String name, String dataType, Object value) { - PropertyDefinition property = new PropertyDefinition(); - property.setType(dataType); - property.setValue(value); - property.setRequired(true); - ResourceAssignment ra = new ResourceAssignment(); - ra.setName(name); - ra.setProperty(property); - return ra; - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/model/utils/ServiceTemplateUtilsTest.java b/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/model/utils/ServiceTemplateUtilsTest.java deleted file mode 100644 index 525dda4e1..000000000 --- a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/model/utils/ServiceTemplateUtilsTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.utils; - -import java.util.HashMap; -import java.util.Map; -import org.junit.Assert; -import org.junit.Test; -import org.onap.ccsdk.features.model.data.ArtifactDefinition; -import org.onap.ccsdk.features.model.data.CapabilityAssignment; -import org.onap.ccsdk.features.model.data.NodeTemplate; - -public class ServiceTemplateUtilsTest { - - ServiceTemplateUtils serviceTemplateUtils = new ServiceTemplateUtils(); - - @Test - public void testPopulateVnfNodeProperties() { - NodeTemplate nodeTemplate = createNodeTemplate(); - - String nodeTemplateKey = "nodeTemplateKey"; - Map context = new HashMap(); - - Map result = - serviceTemplateUtils.populateVnfNodeProperties(nodeTemplateKey, nodeTemplate, context, null); - - Assert.assertTrue(result.size() > 0); - } - - @Test - public void testPopulateNodeTemplateArtifacts() { - String nodeTemplateKey = "nodeTemplateKey"; - NodeTemplate nodeTemplate = createNodeTemplate(); - Map context = new HashMap(); - - Map result = - serviceTemplateUtils.populateNodeTemplateArtifacts(nodeTemplateKey, nodeTemplate, context); - - Assert.assertTrue(result.size() > 0); - } - - private NodeTemplate createNodeTemplate() { - NodeTemplate nodeTemplate = new NodeTemplate(); - Map properties = new HashMap(); - properties.put("prop1", "value"); - CapabilityAssignment capabilityAssignment = new CapabilityAssignment(); - capabilityAssignment.setProperties(properties); - Map capabilities = new HashMap(); - capabilities.put("key", capabilityAssignment); - nodeTemplate.setCapabilities(capabilities); - - ArtifactDefinition artifactDefinition = new ArtifactDefinition(); - artifactDefinition.setFile("file"); - artifactDefinition.setDeployPath("deployPath"); - artifactDefinition.setContent("content"); - Map artifacts = new HashMap(); - artifacts.put("artifactName1", artifactDefinition); - nodeTemplate.setArtifacts(artifacts); - - return nodeTemplate; - } -} diff --git a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/model/utils/TransformationUtilsTest.java b/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/model/utils/TransformationUtilsTest.java deleted file mode 100644 index f73bc1af2..000000000 --- a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/model/utils/TransformationUtilsTest.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.utils; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import java.util.HashMap; -import java.util.Map; -import org.junit.Test; -import com.fasterxml.jackson.databind.JsonNode; - -public class TransformationUtilsTest { - - @Test - public void testGetJson() { - Map configparameters = new HashMap(); - configparameters.put("key", "value"); - String json = TransformationUtils.getJson(configparameters); - assertTrue("{\"key\":\"value\"}".equals(json)); - } - - @Test - public void testGetJsonNodeForString() { - String content = "{\"key\":\"value\"}"; - JsonNode jsonNodeForString = TransformationUtils.getJsonNodeForString(content); - assertNotNull(jsonNodeForString); - } - - @Test - public void testGetMapfromJson() { - String content = "{\"key\":\"value\"}"; - Map mapfromJson = TransformationUtils.getMapfromJson(content); - assertTrue(mapfromJson.size() == 1); - assertTrue("value".equals(mapfromJson.get("key"))); - } - - @Test - public void testGetMapfromJsonString() { - String content = "{\"key\":\"value\"}"; - Map mapfromJson = TransformationUtils.getMapfromJsonString(content); - assertTrue(mapfromJson.size() == 1); - assertTrue("value".equals(mapfromJson.get("key"))); - } - - @Test - public void testConvertJson2RootProperties() throws Exception { - Map context = new HashMap(); - String jsonContent = "{\"key\":\"value\"}"; - Map convertJson2RootProperties = - TransformationUtils.convertJson2RootProperties(context, jsonContent); - assertTrue(convertJson2RootProperties.size() == 1); - assertTrue("value".equals(convertJson2RootProperties.get("key"))); - } - - @SuppressWarnings("unchecked") - @Test - public void testGetJsonNodeAndTreeToValueAndConvertJson2Properties() throws Exception { - Map configparameters = new HashMap(); - configparameters.put("key", "value"); - JsonNode jsonNode = TransformationUtils.getJsonNode(configparameters); - assertNotNull(jsonNode); - - Map result = TransformationUtils.treeToValue(jsonNode, HashMap.class); - assertTrue("value".equals(result.get("key"))); - - result = TransformationUtils.convertJson2Properties(null, jsonNode, null); - assertTrue("value".equals(result.get("key"))); - } - - @Test - public void testGetJsonSchema() { - String jsonSchema = TransformationUtils.getJsonSchema(String.class); - assertNotNull(jsonSchema); - } -} diff --git a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/model/validator/ServiceTemplateValidationTest.java b/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/model/validator/ServiceTemplateValidationTest.java deleted file mode 100644 index 72a49ebc7..000000000 --- a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/model/validator/ServiceTemplateValidationTest.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.model.validator; - -import java.nio.charset.Charset; -import org.apache.commons.io.IOUtils; -import org.junit.Test; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -public class ServiceTemplateValidationTest { - private static EELFLogger logger = EELFManager.getInstance().getLogger(ServiceTemplateValidationTest.class); - - @Test - public void validateServiceTemplate() { - try { - logger.info(" **************** Validating Default *****************"); - String serviceTemplateContent = IOUtils.toString(ServiceTemplateValidationTest.class.getClassLoader() - .getResourceAsStream("service_templates/default.json"), Charset.defaultCharset()); - ServiceTemplateValidator serviceTemplateValidator = new ServiceTemplateValidator(); - serviceTemplateValidator.validateServiceTemplate(serviceTemplateContent); - logger.info(" **************** Reqource Assignment *****************"); - serviceTemplateContent = IOUtils.toString(ServiceTemplateValidationTest.class.getClassLoader() - .getResourceAsStream("service_templates/resource_assignment.json"), Charset.defaultCharset()); - serviceTemplateValidator.validateServiceTemplate(serviceTemplateContent); - } catch (Exception e) { - e.printStackTrace(); - } - - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/params/service/ComponentNodeTest.java b/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/params/service/ComponentNodeTest.java deleted file mode 100644 index 9c048f48e..000000000 --- a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/params/service/ComponentNodeTest.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.params.service; - -import static org.mockito.Matchers.any; -import java.io.File; -import java.nio.charset.Charset; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import org.apache.commons.io.FileUtils; -import org.apache.commons.lang3.StringUtils; -import org.apache.sling.testing.mock.osgi.MockOsgi; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.MockitoAnnotations; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.runners.MockitoJUnitRunner; -import org.mockito.stubbing.Answer; -import org.onap.ccsdk.features.data.adaptor.domain.TransactionLog; -import org.onap.ccsdk.features.data.adaptor.service.ConfigResourceService; -import org.onap.ccsdk.features.model.ConfigModelConstant; -import org.onap.ccsdk.features.model.service.ComponentNodeDelegate; -import org.onap.ccsdk.features.model.service.ComponentNodeServiceImpl; -import org.onap.ccsdk.features.model.service.ConfigModelService; -import org.onap.ccsdk.features.model.service.ConfigModelServiceImpl; -import org.onap.ccsdk.features.model.utils.TransformationUtils; -import org.onap.ccsdk.features.rest.adaptor.service.ConfigRestAdaptorService; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.osgi.framework.BundleContext; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -@RunWith(MockitoJUnitRunner.class) -public class ComponentNodeTest { - private static EELFLogger logger = EELFManager.getInstance().getLogger(ComponentNodeTest.class); - @Mock - private ConfigResourceService configResourceService; - - @Mock - private ConfigRestAdaptorService configRestAdaptorService; - - BundleContext bundleContext = MockOsgi.newBundleContext(); - - @Before - public void before() { - MockitoAnnotations.initMocks(this); - - MockComponentNode mockSvcLogicPlugin = new MockComponentNode(); - bundleContext.registerService(MockComponentNode.class, mockSvcLogicPlugin, null); - - try { - Mockito.doAnswer(new Answer() { - @Override - public Void answer(InvocationOnMock invocationOnMock) throws Throwable { - Object[] args = invocationOnMock.getArguments(); - if (args != null) { - logger.trace("Transaction info " + Arrays.asList(args)); - } - return null; - } - }).when(configResourceService).save(any(TransactionLog.class)); - } catch (SvcLogicException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - @After - public void after() { - - } - - @Test - public void testProcess() { - - try { - String serviceTemplateContent = FileUtils.readFileToString( - new File("src/test/resources/componentnode/default.json"), Charset.defaultCharset()); - ConfigModelService configModelService = new ConfigModelServiceImpl(configRestAdaptorService); - - Map map = new HashMap<>(); - configModelService.convertServiceTemplate2Properties(serviceTemplateContent, map); - - SvcLogicContext ctx = new SvcLogicContext(); - map.forEach((name, value) -> { - if (StringUtils.isNotBlank(name) && StringUtils.isNotBlank(value)) { - ctx.setAttribute(name, value); - } - }); - ctx.setAttribute("vnf-id", "1234"); - - ComponentNodeServiceImpl componentNodeService = - new ComponentNodeServiceImpl(bundleContext, configResourceService, configRestAdaptorService); - - ComponentNodeDelegate componentNodeDelegate = new ComponentNodeDelegate(componentNodeService); - Map inParams = new HashMap<>(); - inParams.put(ConfigModelConstant.PROPERTY_SELECTOR, "generate-configuration"); - - componentNodeDelegate.process(inParams, ctx); - TransformationUtils.printMap(inParams); - - } catch (Exception e) { - e.printStackTrace(); - } - - } - - @Test(expected = SvcLogicException.class) - public void testFailure() throws Exception { - ComponentNodeServiceImpl componentNodeService = - new ComponentNodeServiceImpl(bundleContext, configResourceService, configRestAdaptorService); - ComponentNodeDelegate componentNodeDelegate = new ComponentNodeDelegate(componentNodeService); - - Map inParams = new HashMap(); - inParams.put(ConfigModelConstant.PROPERTY_SELECTOR, "generate-configuration"); - SvcLogicContext ctx = new SvcLogicContext(); - componentNodeDelegate.process(inParams, ctx); - } -} diff --git a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/params/service/ConfigModelServiceTest.java b/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/params/service/ConfigModelServiceTest.java deleted file mode 100644 index 3e62fafd0..000000000 --- a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/params/service/ConfigModelServiceTest.java +++ /dev/null @@ -1,219 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.params.service; - -import static org.junit.Assert.fail; -import java.io.File; -import java.nio.charset.Charset; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.apache.commons.io.FileUtils; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Matchers; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.ccsdk.features.model.ConfigModelConstant; -import org.onap.ccsdk.features.model.data.ServiceTemplate; -import org.onap.ccsdk.features.model.domain.ConfigModel; -import org.onap.ccsdk.features.model.domain.ConfigModelContent; -import org.onap.ccsdk.features.model.service.ConfigModelService; -import org.onap.ccsdk.features.model.service.ConfigModelServiceImpl; -import org.onap.ccsdk.features.rest.adaptor.service.ConfigRestAdaptorService; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -@RunWith(MockitoJUnitRunner.class) -public class ConfigModelServiceTest { - - private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigModelServiceTest.class); - - @Mock - private ConfigRestAdaptorService configRestAdaptorService; - - @Test - public void testConfigAssignmentInputOutputParams() throws Exception { - - String fileContent = FileUtils.readFileToString( - new File("src/test/resources/service_templates/resource_assignment.json"), Charset.defaultCharset()); - - Map context = new HashMap<>(); - ConfigModelServiceImpl configModelServiceImpl = new ConfigModelServiceImpl(configRestAdaptorService); - context = configModelServiceImpl.convertServiceTemplate2Properties(fileContent, context); - - Assert.assertNotNull("Failed to Prepare Context : ", context); - - context.put("request-id", "12345"); - context.put("vnf-id", "vnf12345"); - - Map inparams = new HashMap(); - inparams.put(ConfigModelConstant.PROPERTY_SELECTOR, "resource-assignment"); - - SvcLogicContext inputContext = new SvcLogicContext(); - context.forEach((name, value) -> { - inputContext.setAttribute(name, value); - }); - - // TransformationUtils.printProperty(inputContext.toProperties()); - - configModelServiceImpl.assignInParamsFromModel(inputContext, inparams); - Assert.assertNotNull("In Param is Null : ", inparams); - Assert.assertNotNull("Failed to get entity-id in Inparms : ", inparams.get("resource-id")); - Assert.assertEquals("Failed to get entity-id vlaue in Inparms ", String.valueOf("vnf12345"), - inparams.get("resource-id")); - Assert.assertNotNull("Failed to get request-id in Inparms : ", inparams.get("request-id")); - Assert.assertEquals("Failed to get request-id vlaue in Inparms ", String.valueOf("12345"), - inparams.get("request-id")); - - configModelServiceImpl.assignOutParamsFromModel(inputContext, inparams); - logger.info("*************** Output Params *************"); - // TransformationUtils.printProperty(inputContext.toProperties()); - - } - - @Test - public void testConvertServiceTemplate2PropertiesComplex() throws Exception { - String fileContent = FileUtils.readFileToString( - new File("src/test/resources/service_templates/resource_assignment.json"), Charset.defaultCharset()); - - Map context = new HashMap<>(); - context.put("host-password", "1234"); - context.put("host-ip-address", "[123.23.34.45, 123.23.34.45]"); - - ConfigModelServiceImpl configModelServiceImpl = new ConfigModelServiceImpl(configRestAdaptorService); - configModelServiceImpl.convertServiceTemplate2Properties(fileContent, context); - - // TransformationUtils.printMap(context); - - Map inparams = new HashMap(); - inparams.put(ConfigModelConstant.PROPERTY_SELECTOR, "resource-assignment"); - logger.info("Before Input Result: " + inparams); - - SvcLogicContext inputContext = new SvcLogicContext(); - context.forEach((name, value) -> { - inputContext.setAttribute(name, value); - }); - - configModelServiceImpl.assignInParamsFromModel(inputContext, inparams); - logger.info("----------Input Result: " + inparams); - - inputContext.setAttribute("assignment-params", "default-assigned"); - configModelServiceImpl.assignOutParamsFromModel(inputContext, inparams); - - // TransformationUtils.printProperty(inputContext.toProperties()); - - } - - @Test - public void testGetNodeTemplateContent() throws Exception { - String templateContent = "{\"id\":\"id\"}"; - SvcLogicContext context = new SvcLogicContext(); - context.setAttribute(ConfigModelConstant.PROPERTY_NODE_TEMPLATES_DOT + templateContent + ".content", - templateContent); - - ConfigModelServiceImpl configModelServiceImpl = new ConfigModelServiceImpl(configRestAdaptorService); - String content = configModelServiceImpl.getNodeTemplateContent(context, templateContent); - - Assert.assertEquals(content, templateContent); - } - - @Test - public void testGetNodeTemplateMapping() throws Exception { - String templateContent = "{\"capabilities\":{\"mapping\":{\"properties\":{\"mapping\":[\"test\"]}}}}"; - SvcLogicContext context = new SvcLogicContext(); - context.setAttribute(ConfigModelConstant.PROPERTY_NODE_TEMPLATES_DOT + templateContent, templateContent); - - ConfigModelServiceImpl configModelServiceImpl = new ConfigModelServiceImpl(configRestAdaptorService); - configModelServiceImpl.getNodeTemplateMapping(context, templateContent); - // Assert.assertEquals(content, templateContent); - } - - @Test - public void testValidateServiceTemplate() throws Exception { - ConfigModelServiceImpl configModelServiceImpl = new ConfigModelServiceImpl(configRestAdaptorService); - ServiceTemplate serviceTemplate = new ServiceTemplate(); - - try { - configModelServiceImpl.validateServiceTemplate(null); - fail("Should have thrown exception"); - } catch (SvcLogicException e) { - } - - try { - configModelServiceImpl.validateServiceTemplate(serviceTemplate); - fail("Should have thrown exception"); - } catch (SvcLogicException e) { - } - - Map metadata = new HashMap(); - metadata.put(ConfigModelConstant.SERVICE_TEMPLATE_KEY_ARTIFACT_AUTHOR, "author"); - metadata.put(ConfigModelConstant.SERVICE_TEMPLATE_KEY_ARTIFACT_NAME, "name"); - metadata.put(ConfigModelConstant.SERVICE_TEMPLATE_KEY_ARTIFACT_VERSION, "version"); - serviceTemplate.setMetadata(metadata); - - Assert.assertTrue(configModelServiceImpl.validateServiceTemplate(serviceTemplate)); - } - - @Test - public void testPrepareContext() throws Exception { - Mockito.when(configRestAdaptorService.getResource(Matchers.anyString(), Matchers.anyString(), Matchers.any())) - .thenReturn(createConfigModel()); - - String input = "{\"action-name\": \"resource-assignment-action\"}"; - ConfigModelService configModelService = new ConfigModelServiceImpl(configRestAdaptorService); - - Map ctx = - configModelService.prepareContext(null, input, "serviceTemplateName", "serviceTemplateVersion"); - Assert.assertEquals("resource-assignment-action", ctx.get(ConfigModelConstant.PROPERTY_ACTION_NAME)); - - ctx = configModelService.prepareContext(null, input, "{}"); - Assert.assertEquals("resource-assignment-action", ctx.get(ConfigModelConstant.PROPERTY_ACTION_NAME)); - } - - @Test - public void testConvertServiceTemplate2Properties() throws Exception { - Map metadata = new HashMap(); - metadata.put("key", "value"); - ServiceTemplate serviceTemplate = new ServiceTemplate(); - serviceTemplate.setMetadata(metadata); - Map context = new HashMap(); - - ConfigModelService configModelService = new ConfigModelServiceImpl(configRestAdaptorService); - Map ctx = configModelService.convertServiceTemplate2Properties(serviceTemplate, context); - - Assert.assertEquals("value", ctx.get("key")); - } - - private ConfigModel createConfigModel() { - ConfigModel configModel = new ConfigModel(); - List configModelContents = new ArrayList(); - ConfigModelContent configModelContent = new ConfigModelContent(); - configModelContent.setContentType(ConfigModelConstant.MODEL_CONTENT_TYPE_TOSCA_JSON); - configModelContent.setContent("{\"description\": \"description\"}"); - configModelContents.add(configModelContent); - configModel.setConfigModelContents(configModelContents); - configModel.setPublished("Y"); - return configModel; - } -} diff --git a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/params/service/ExpressionUtilsTest.java b/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/params/service/ExpressionUtilsTest.java deleted file mode 100644 index a1e273a84..000000000 --- a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/params/service/ExpressionUtilsTest.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.params.service; - -import java.io.File; -import java.nio.charset.Charset; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.apache.commons.io.FileUtils; -import org.junit.Test; -import org.onap.ccsdk.features.model.utils.ExpressionUtils; -import org.onap.ccsdk.features.model.utils.TransformationUtils; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; - -public class ExpressionUtilsTest { - private static EELFLogger logger = EELFManager.getInstance().getLogger(ExpressionUtilsTest.class); - - @Test - public void testProcessJsonExpression() throws Exception { - String fileContent = FileUtils.readFileToString(new File("src/test/resources/properties/default.json"), - Charset.defaultCharset()); - - SvcLogicContext context = new SvcLogicContext(); - context.setAttribute("host-password", "1234"); - context.setAttribute("host-ip-address", "[\"123.23.34.45\", \"123.23.34.45\"]"); - context.setAttribute("loopback-default", "[\"Sample\", \"Brinda\"]"); - - Map inparams = new HashMap(); - ExpressionUtils jsonExpressionUtils = new ExpressionUtils(context, inparams); - ObjectMapper mapper = new ObjectMapper(); - JsonNode rootArray = mapper.readTree(fileContent); - jsonExpressionUtils.processJsonExpression(rootArray); - - } - - @Test - public void testJson2Property() throws Exception { - String fileContent = FileUtils.readFileToString(new File("src/test/resources/properties/convert.json"), - Charset.defaultCharset()); - - List blockKeys = new ArrayList(); - blockKeys.add( - "interfaces.ResourceAssignmentService.operations.getResourceAssignment.inputs.assignment-mappings"); - blockKeys.add("interfaces.ResourceAssignmentService.operations.getResourceAssignment.outputs"); - blockKeys.add("type"); - - Map workflowMap = new HashMap<>(); - Map propertyMap = - TransformationUtils.convertJson2Properties(workflowMap, fileContent, blockKeys); - - TransformationUtils.printMap(propertyMap); - - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/params/service/MockComponentNode.java b/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/params/service/MockComponentNode.java deleted file mode 100644 index e779a361a..000000000 --- a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/params/service/MockComponentNode.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.params.service; - -import java.util.Map; -import org.onap.ccsdk.features.model.service.ComponentNode; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -public class MockComponentNode implements ComponentNode { - private static EELFLogger logger = EELFManager.getInstance().getLogger(MockComponentNode.class); - - @Override - public Boolean preCondition(Map inParams, SvcLogicContext ctx, Map componentContext) - throws SvcLogicException { - logger.info("Received preCondition "); - componentContext.put("test-key", "test"); - return true; - } - - @Override - public void process(Map inParams, SvcLogicContext ctx) throws SvcLogicException { - - } - - @Override - public void process(Map inParams, SvcLogicContext ctx, Map componentContext) - throws SvcLogicException { - logger.info("Received Request " + componentContext); - } - - @Override - public void preProcess(Map inParams, SvcLogicContext ctx, Map componentContext) - throws SvcLogicException { - logger.info("Received preProcess "); - - } - - @Override - public void postProcess(Map inParams, SvcLogicContext ctx, Map componentContext) - throws SvcLogicException { - logger.info("Received postProcess "); - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/params/service/ServiceTemplateCreateUtils.java b/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/params/service/ServiceTemplateCreateUtils.java deleted file mode 100644 index 5c89d45ae..000000000 --- a/blueprints-processor/plugin/model-provider/src/test/java/org/onap/ccsdk/features/params/service/ServiceTemplateCreateUtils.java +++ /dev/null @@ -1,193 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.onap.ccsdk.features.params.service; - -import java.io.File; -import java.io.IOException; -import java.nio.charset.Charset; -import java.util.HashMap; -import java.util.Map; -import org.apache.commons.io.FileUtils; -import org.apache.commons.lang3.StringUtils; -import org.onap.ccsdk.features.model.ConfigModelConstant; -import org.onap.ccsdk.features.model.data.DataType; -import org.onap.ccsdk.features.model.data.NodeTemplate; -import org.onap.ccsdk.features.model.data.NodeType; -import org.onap.ccsdk.features.model.data.ServiceTemplate; -import org.onap.ccsdk.features.model.data.TopologyTemplate; -import org.onap.ccsdk.features.model.data.dict.ResourceDefinition; -import org.onap.ccsdk.features.model.utils.TransformationUtils; - -public class ServiceTemplateCreateUtils { - - public void createNodeTypes(String serviceTemplateFileName) throws IOException { - if (StringUtils.isNotBlank(serviceTemplateFileName)) { - String fileContent = - FileUtils.readFileToString(new File(serviceTemplateFileName), Charset.defaultCharset()); - if (StringUtils.isNotBlank(fileContent)) { - // System.out.println("NodeTypeCreateUtils.createNodeTypes()" +fileContent ); - ServiceTemplate serviceTemplate = TransformationUtils.readValue(fileContent, ServiceTemplate.class); - - String formattedServiceTemplateContent = TransformationUtils.getJson(serviceTemplate, true); - - FileUtils.writeStringToFile(new File("src/test/resources/service_templates/default.json"), - formattedServiceTemplateContent, Charset.defaultCharset()); - - createVrrNodeTemplate(serviceTemplate); - createDictionarySchema(); - - } - } - } - - public void createNodeTypes(ServiceTemplate serviceTemplate) throws IOException { - - if (serviceTemplate != null && serviceTemplate.getNodeTypes() != null) { - serviceTemplate.getNodeTypes().forEach((nodeTypeKey, node_types) -> { - - if (node_types != null && StringUtils.isNotBlank(node_types.getDerivedFrom())) { - - try { - String fileName = "src/test/resources/node_types/"; - if (ConfigModelConstant.MODEL_TYPE_NODE_VNF.equalsIgnoreCase(node_types.getDerivedFrom())) { - fileName = fileName + "vnf/" + nodeTypeKey + ".json"; - } - if (ConfigModelConstant.MODEL_TYPE_NODE_DG.equalsIgnoreCase(node_types.getDerivedFrom())) { - fileName = fileName + "dg/" + nodeTypeKey + ".json"; - } - if (ConfigModelConstant.MODEL_TYPE_NODE_COMPONENT - .equalsIgnoreCase(node_types.getDerivedFrom())) { - fileName = fileName + "component/" + nodeTypeKey + ".json"; - } - String content = TransformationUtils.getJson(node_types, true); - FileUtils.write(new File(fileName), content, Charset.defaultCharset()); - } catch (IOException e) { - e.printStackTrace(); - } - - } - System.out.println("NodeTypeCreateUtils.createNodeTypes()" + nodeTypeKey); - }); - } - - } - - public void createResourceAssignmentNodeTemplate(ServiceTemplate serviceTemplate) throws IOException { - if (serviceTemplate != null) { - ServiceTemplate workingServiceTemplate = new ServiceTemplate(); - workingServiceTemplate.setMetadata(serviceTemplate.getMetadata()); - - Map data_types = new HashMap(); - data_types.put("datatype-property", serviceTemplate.getDataTypes().get("datatype-property")); - data_types.put("datatype-resource-assignment", - serviceTemplate.getDataTypes().get("datatype-resource-assignment")); - - workingServiceTemplate.setDataTypes(data_types); - - TopologyTemplate topology_template = new TopologyTemplate(); - Map node_templates = new HashMap(); - - Map node_Templates = serviceTemplate.getTopologyTemplate().getNodeTemplates(); - - node_templates.put("base-config-template", node_Templates.get("base-config-template")); - node_templates.put("licence-template", node_Templates.get("licence-template")); - - node_templates.put("resource-assignment-action", node_Templates.get("resource-assignment-action")); - node_templates.put("resource-assignment", node_Templates.get("resource-assignment")); - - topology_template.setNodeTemplates(node_templates); - topology_template.setInputs(serviceTemplate.getTopologyTemplate().getInputs()); - - Map node_types = new HashMap(); - node_types.put("artifact-config-template", serviceTemplate.getNodeTypes().get("artifact-config-template")); - node_types.put("dg-resource-assignment", serviceTemplate.getNodeTypes().get("dg-resource-assignment")); - node_types.put("component-resource-assignment", - serviceTemplate.getNodeTypes().get("component-resource-assignment")); - - workingServiceTemplate.setNodeTypes(node_types); - workingServiceTemplate.setTopologyTemplate(topology_template); - - String workingServiceTemplateConmtent = TransformationUtils.getJson(workingServiceTemplate, true); - - FileUtils.writeStringToFile(new File("src/test/resources/service_templates/resource_assignment.json"), - workingServiceTemplateConmtent, Charset.defaultCharset()); - - File lcmFile = new File( - "../../../northbound/selfservice-api/provider/src/test/resources/service_templates/resource_assignment.json"); - FileUtils.writeStringToFile(lcmFile, workingServiceTemplateConmtent, Charset.defaultCharset()); - - File resourceAssignmetFile = new File( - "../../../plugin/assignment/provider/src/test/resources/service_templates/resource_assignment.json"); - FileUtils.writeStringToFile(resourceAssignmetFile, workingServiceTemplateConmtent, - Charset.defaultCharset()); - - System.out.println("NodeTypeCreateUtils.createNodeTemplate() :" + workingServiceTemplateConmtent); - } - - } - - public void createVrrNodeTemplate(ServiceTemplate serviceTemplate) throws IOException { - if (serviceTemplate != null) { - ServiceTemplate workingServiceTemplate = new ServiceTemplate(); - workingServiceTemplate.setMetadata(serviceTemplate.getMetadata()); - - TopologyTemplate topology_template = new TopologyTemplate(); - Map node_templates = new HashMap(); - - Map node_Templates = serviceTemplate.getTopologyTemplate().getNodeTemplates(); - - node_templates.put("resource-assignment-action", node_Templates.get("resource-assignment-action")); - node_templates.put("resource-assignment", node_Templates.get("resource-assignment")); - - node_templates.put("activate-action", node_Templates.get("activate-action")); - node_templates.put("base-config-template", node_Templates.get("base-config-template")); - node_templates.put("licence-template", node_Templates.get("licence-template")); - node_templates.put("vrr-netconf-device", node_Templates.get("vrr-netconf-device")); - node_templates.put("get-netconf-config", node_Templates.get("get-netconf-config")); - node_templates.put("edit-netconf-config", node_Templates.get("edit-netconf-config")); - node_templates.put("transaction-netconf-baseconfig", node_Templates.get("transaction-netconf-baseconfig")); - - topology_template.setNodeTemplates(node_templates); - topology_template.setInputs(serviceTemplate.getTopologyTemplate().getInputs()); - - workingServiceTemplate.setTopologyTemplate(topology_template); - - String workingServiceTemplateContent = TransformationUtils.getJson(workingServiceTemplate, true); - - FileUtils.writeStringToFile(new File("src/test/resources/service_templates/vrr_config.json"), - workingServiceTemplateContent, Charset.defaultCharset()); - - } - } - - public void createDictionarySchema() throws IOException { - String schema = TransformationUtils.getJsonSchema(ResourceDefinition.class); - FileUtils.writeStringToFile(new File("src/test/resources/dictionary/dictionary_schema.json"), schema, - Charset.defaultCharset()); - } - - public static void main(String[] args) { - try { - ServiceTemplateCreateUtils utils = new ServiceTemplateCreateUtils(); - utils.createNodeTypes("src/test/resources/service_templates/default.json"); - } catch (Exception e) { - // TODO: handle exception - } - } - -} diff --git a/blueprints-processor/plugin/model-provider/src/test/resources/componentnode/default.json b/blueprints-processor/plugin/model-provider/src/test/resources/componentnode/default.json deleted file mode 100644 index e538b0c48..000000000 --- a/blueprints-processor/plugin/model-provider/src/test/resources/componentnode/default.json +++ /dev/null @@ -1,100 +0,0 @@ -{ - "metadata": { - "author": "ks220y@att.com", - "vendor": "Juniper", - "os": "XXX", - "service-type": "AVPN", - "vnf-type": "VRR", - "action": "Base Configuration", - "sub-action": "Generate Configuration", - "service-template-name": "VRR-baseconfiguration", - "service-template-version": "1.0.0" - }, - "topology_template": { - "inputs": { - "service-instance-id": { - "required": true, - "type": "string" - }, - "vnf-id": { - "required": true, - "type": "string" - }, - "service": { - "required": true, - "type": "string" - }, - "region": { - "required": true, - "type": "string" - }, - "bundle-id": { - "required": true, - "type": "string" - }, - "bundle-mac": { - "required": true, - "type": "string" - } - }, - "node_templates": { - "generate-configuration": { - "type": "mock-component-generateConfig", - "interfaces": { - "org-onap-ccsdk-features-params-service-MockComponentNode": { - "operations": { - "process": { - "inputs": { - "entity-type": "vnf-type", - "template-content": "sample-template", - "entity-id": "{ \"get_input\" : \"vnf-id\" }" - }, - "outputs": { - "mergedData": "merged Data", - "status": "status" - } - } - } - } - } - } - } - }, - "node_types": { - "mock-component-generateConfig": { - "interfaces": { - "org-onap-ccsdk-features-params-service-MockComponentNode": { - "operations": { - "process": { - "inputs": { - "entity-type": { - "required": false, - "type": "string" - }, - "template-content": { - "required": false, - "type": "string" - }, - "entity-id": { - "required": true, - "type": "string" - } - }, - "outputs": { - "generated-config": { - "required": true, - "type": "string" - }, - "status": { - "required": true, - "type": "string" - } - } - } - } - } - }, - "derived_from": "tosca.nodes.Component" - } - } -} diff --git a/blueprints-processor/plugin/model-provider/src/test/resources/dictionary/dictionary_schema.json b/blueprints-processor/plugin/model-provider/src/test/resources/dictionary/dictionary_schema.json deleted file mode 100644 index 809db7dea..000000000 --- a/blueprints-processor/plugin/model-provider/src/test/resources/dictionary/dictionary_schema.json +++ /dev/null @@ -1,118 +0,0 @@ -{ - "type": "object", - "properties": { - "resource-path": { - "tags": { - "type": "string" - }, - "name": { - "type": "string", - "required": true - }, - "type": "string", - "required": true - }, - "property": { - "type": "object", - "properties": { - "default": { - "type": "any" - }, - "entry_schema": { - "type": "object", - "properties": { - "type": { - "type": "string" - } - } - }, - "description": { - "type": "string" - }, - "type": { - "type": "string" - }, - "constraints": { - "type": "array", - "items": { - "type": "object", - "additionalProperties": { - "type": "any" - } - } - }, - "value": { - "type": "any" - }, - "required": { - "type": "boolean" - }, - "status": { - "type": "string" - } - } - }, - "resource-type": { - "type": "string", - "required": true - }, - "updated-by": { - "type": "string" - }, - "sources": { - "type": "object", - "required": true, - "additionalProperties": { - "type": "object", - "properties": { - "type": { - "type": "string", - "required": true - }, - "properties": { - "type": "object", - "required": true, - "properties": { - "type": { - "type": "string" - }, - "name": { - "type": "string" - }, - "key": { - "type": "string" - }, - "path": { - "type": "string" - }, - "url-path": { - "type": "string" - }, - "query": { - "type": "string" - }, - "input-key-mapping": { - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "output-key-mapping": { - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "key-dependencies": { - "type": "array", - "items": { - "type": "string" - } - } - } - } - } - } - } - } -} \ No newline at end of file diff --git a/blueprints-processor/plugin/model-provider/src/test/resources/properties/convert.json b/blueprints-processor/plugin/model-provider/src/test/resources/properties/convert.json deleted file mode 100644 index cb7d08e44..000000000 --- a/blueprints-processor/plugin/model-provider/src/test/resources/properties/convert.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "type": "sdnc-component-getResourceAssignment", - "interfaces": { - "ResourceAssignmentService": { - "operations": { - "getResourceAssignment": { - "inputs": { - "assignment-mappings": [ - { - "name": "service-name", - "mapping-field": "service", - "mapping-category": "SDN", - "required": true - }, - { - "name": "region-name", - "mapping-field": "region", - "mapping-category": "SDN", - "required": true - } - ], - "pre-data": "{ \"get_attribute\" : \"get-resource-assignment.config-params\" }", - "prifix": "get-resource-assignment" - }, - "outputs": { - "resource-assignment-status": "success", - "resource-assignment-params": "{ \"set_value\" : \"get-resource-assignment.config-params\" }" - } - } - } - } - } -} diff --git a/blueprints-processor/plugin/model-provider/src/test/resources/properties/default.json b/blueprints-processor/plugin/model-provider/src/test/resources/properties/default.json deleted file mode 100644 index 335a68759..000000000 --- a/blueprints-processor/plugin/model-provider/src/test/resources/properties/default.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "default": "{ \"get_input\" : \"loopback-default\" }", - "domain": "ethernet", - "criteria": [ - { - "value": "dummy301me1", - "type": "complex", - "nodeString": "layer3-service-list[].service-data.l3sdn-vnf-fields.vnf-name" - }, - { - "value": "{ \"get_input\" : \"host-ip-address\" }", - "type": "simple", - "nodeString": "layer3-service-list[].service-data.l3sdn-vnf-fields.vnf-name" - } - ] -} diff --git a/blueprints-processor/plugin/model-provider/src/test/resources/service_templates/default.json b/blueprints-processor/plugin/model-provider/src/test/resources/service_templates/default.json deleted file mode 100644 index e53f0f6cd..000000000 --- a/blueprints-processor/plugin/model-provider/src/test/resources/service_templates/default.json +++ /dev/null @@ -1,591 +0,0 @@ -{ - "metadata" : { - "author" : "ks220y@att.com", - "service-template-name" : "VRR-baseconfiguration", - "service-template-version" : "1.0.0", - "release" : "1802", - "service-type" : "AVPN", - "vnf-type" : "VRR" - }, - "tosca_definitions_version" : "sdn_config_1_0_0", - "topology_template" : { - "inputs" : { - "request-id" : { - "required" : true, - "type" : "string" - }, - "service-instance-id" : { - "required" : true, - "type" : "string" - }, - "action-name" : { - "required" : true, - "type" : "string" - }, - "scope-type" : { - "required" : true, - "type" : "string" - }, - "hostname" : { - "required" : true, - "type" : "string" - } - }, - "node_templates" : { - "base-config-template" : { - "type" : "artifact-config-template", - "properties" : { - "action-names" : [ "resource-assignment-action" ] - }, - "capabilities" : { - "content" : { - "properties" : { - "content" : "db://base-config-template" - } - }, - "mapping" : { - "properties" : { - "mapping" : [ { - "name" : "vnf-id", - "input-param" : true, - "property" : { - "type" : "string", - "required" : true - }, - "dictionary-name" : "vnf-id", - "dictionary-source" : "input" - }, { - "name" : "group-name", - "input-param" : true, - "property" : { - "type" : "string", - "required" : true - }, - "dictionary-name" : "group-name", - "dictionary-source" : "input" - } ] - } - } - } - }, - "licence-template" : { - "type" : "artifact-config-template", - "properties" : { - "action-names" : [ "resource-assignment-action" ] - }, - "capabilities" : { - "content" : { - "properties" : { - "content" : "db://licence-template" - } - }, - "mapping" : { - "properties" : { - "mapping" : [ { - "name" : "bundle-id", - "input-param" : true, - "property" : { - "type" : "string" - }, - "dictionary-name" : "bundle-id", - "dictionary-source" : "input" - }, { - "name" : "bundle-mac", - "input-param" : true, - "property" : { - "type" : "string", - "required" : true - }, - "dictionary-name" : "bundle-mac", - "dictionary-source" : "input" - } ] - } - } - } - }, - "resource-assignment-action" : { - "type" : "dg-resource-assignment", - "interfaces" : { - "CONFIG" : { - "operations" : { - "ResourceAssignment" : { } - } - } - }, - "capabilities" : { - "dg-node" : { } - }, - "requirements" : { - "component-dependency" : { - "capability" : "component-node", - "node" : "resource-assignment", - "relationship" : "tosca.relationships.DependsOn" - } - } - }, - "config-generator-action" : { - "type" : "dg-config-generator", - "interfaces" : { - "CONFIG" : { - "operations" : { - "GenerateConfiguration" : { } - } - } - }, - "capabilities" : { - "dg-node" : { } - }, - "requirements" : { - "component-dependency" : { - "capability" : "component-node", - "node" : "generate-configuration", - "relationship" : "tosca.relationships.DependsOn" - } - } - }, - "resource-assignment" : { - "type" : "component-resource-assignment", - "interfaces" : { - "org-onap-ccsdk-features-assignment-service-ConfigAssignmentNode" : { - "operations" : { - "process" : { - "inputs" : { - "action-name" : "{ \"get_input\" : \"action-name\" }", - "resource-type" : "vnf-type", - "template-names" : [ "base-config-template", "licence-template" ], - "request-id" : "{ \"get_input\" : \"request-id\" }", - "resource-id" : "{ \"get_input\" : \"vnf-id\" }" - }, - "outputs" : { - "resource-assignment-params" : "", - "status" : "" - } - } - } - } - }, - "capabilities" : { - "component-node" : { } - } - }, - "generate-configuration" : { - "type" : "component-config-generator", - "interfaces" : { - "org-onap-ccsdk-features-generator-service-ConfigGeneratorNode" : { - "operations" : { - "process" : { - "inputs" : { - "action-name" : "{ \"get_input\" : \"action-name\" }", - "resource-type" : "vnf-type", - "request-id" : "{ \"get_input\" : \"request-id\" }", - "resource-id" : "{ \"get_input\" : \"vnf-id\" }", - "template-name" : "base-config-template" - }, - "outputs" : { - "generated-config" : "", - "status" : "" - } - } - } - } - }, - "capabilities" : { - "component-node" : { } - } - } - } - }, - "artifact_types" : { - "artifact-template-velocity" : { - "description" : " Velocity Template used for Configuration", - "version" : "1.0.0", - "derived_from" : "tosca.artifacts.Implementation", - "file_ext" : [ "vtl" ] - }, - "artifact-mapping-resource" : { - "description" : " Velocity Template Resource Mapping File used along with Configuration template", - "version" : "1.0.0", - "derived_from" : "tosca.artifacts.Implementation", - "file_ext" : [ "json" ] - }, - "artifact-script-python" : { - "description" : " Python Script Template used for Configuration", - "version" : "1.0.0", - "derived_from" : "tosca.artifacts.Implementation", - "file_ext" : [ "py" ] - } - }, - "node_types" : { - "dg-resource-assignment" : { - "description" : "This is Resource Assignment Directed Graph", - "version" : "1.0.0", - "properties" : { - "mode" : { - "required" : false, - "type" : "string", - "default" : "sync" - }, - "version" : { - "required" : false, - "type" : "string", - "default" : "LATEST" - }, - "is-start-flow" : { - "required" : false, - "type" : "boolean", - "default" : "false" - } - }, - "capabilities" : { - "dg-node" : { - "type" : "tosca.capabilities.Node" - }, - "content" : { - "type" : "tosca.capabilities.Content", - "properties" : { - "type" : { - "required" : false, - "type" : "string", - "default" : "json" - }, - "content" : { - "required" : true, - "type" : "string" - } - } - } - }, - "requirements" : { - "component-dependency" : { - "capability" : "component-node", - "node" : "component-resource-assignment", - "relationship" : "tosca.relationships.DependsOn" - } - }, - "interfaces" : { - "CONFIG" : { - "operations" : { - "ResourceAssignment" : { - "inputs" : { - "params" : { - "required" : false, - "type" : "list", - "entry_schema" : { - "type" : "datatype-property" - } - } - } - } - } - } - }, - "derived_from" : "tosca.nodes.DG" - }, - "dg-config-generator" : { - "description" : "This is Activate DG for Config Generator Directed Graph", - "version" : "1.0.0", - "properties" : { - "mode" : { - "required" : false, - "type" : "string", - "default" : "sync" - }, - "version" : { - "required" : false, - "type" : "string", - "default" : "LATEST" - }, - "is-start-flow" : { - "required" : false, - "type" : "boolean", - "default" : "false" - } - }, - "capabilities" : { - "dg-node" : { - "type" : "tosca.capabilities.Node" - }, - "content" : { - "type" : "tosca.capabilities.Content", - "properties" : { - "type" : { - "required" : false, - "type" : "string", - "default" : "json" - }, - "content" : { - "required" : true, - "type" : "string" - } - } - } - }, - "requirements" : { - "component-dependency" : { - "capability" : "component-node", - "node" : "component-config-generator", - "relationship" : "tosca.relationships.DependsOn" - } - }, - "interfaces" : { - "CONFIG" : { - "operations" : { - "GenerateConfiguration" : { - "inputs" : { - "params" : { - "required" : false, - "type" : "list", - "entry_schema" : { - "type" : "datatype-property" - } - } - } - } - } - } - }, - "derived_from" : "tosca.nodes.DG" - }, - "artifact-config-template" : { - "description" : "This is Configuration Velocity Template", - "version" : "1.0.0", - "properties" : { - "action-names" : { - "required" : true, - "type" : "list", - "entry_schema" : { - "type" : "string" - } - }, - "content" : { - "required" : false, - "type" : "string" - }, - "mapping" : { - "required" : false, - "type" : "list", - "entry_schema" : { - "type" : "datatype-resource-assignment" - } - } - }, - "capabilities" : { - "content" : { - "type" : "tosca.capabilities.Content", - "properties" : { - "content" : { - "required" : true, - "type" : "string" - } - } - }, - "mapping" : { - "type" : "tosca.capabilities.Mapping", - "properties" : { - "mapping" : { - "required" : false, - "type" : "list", - "entry_schema" : { - "type" : "datatype-resource-assignment" - } - } - } - } - }, - "derived_from" : "tosca.nodes.Artifact" - }, - "component-resource-assignment" : { - "description" : "This is Resource Assignment Component API", - "version" : "1.0.0", - "capabilities" : { - "component-node" : { - "type" : "tosca.capabilities.Node" - } - }, - "interfaces" : { - "org-onap-ccsdk-features-assignment-service-ConfigAssignmentNode" : { - "operations" : { - "process" : { - "inputs" : { - "action-name" : { - "description" : "Action Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority", - "required" : false, - "type" : "string" - }, - "handler-name" : { - "description" : "Name of the Artifact Node Template, to get the template Content. If template-content is present, then content wont be reterived from the Artifact Node Template.", - "required" : true, - "type" : "string" - }, - "resource-type" : { - "required" : false, - "type" : "string" - }, - "template-names" : { - "description" : "Name of the Artifact Node Templates, to get the template Content.", - "required" : true, - "type" : "list", - "entry_schema" : { - "type" : "string" - } - }, - "request-id" : { - "description" : "Request Id used to store the generated configuration, in the database along with the template-name", - "required" : true, - "type" : "string" - }, - "resource-id" : { - "description" : "Id used to pull the data content from the data base. Either template-data or resource-id should be present", - "required" : true, - "type" : "string" - } - }, - "outputs" : { - "resource-assignment-params" : { - "required" : true, - "type" : "string" - }, - "status" : { - "required" : true, - "type" : "string" - } - } - } - } - } - }, - "derived_from" : "tosca.nodes.Component" - }, - "component-config-generator" : { - "description" : "This is Generate Configuration Component API", - "version" : "1.0.0", - "capabilities" : { - "component-node" : { - "type" : "tosca.capabilities.Node" - } - }, - "interfaces" : { - "org-onap-ccsdk-features-generator-service-ConfigGeneratorNode" : { - "operations" : { - "process" : { - "inputs" : { - "template-data" : { - "description" : "Conditional : JSON string which is used to mash with template. Either template-data or ( resource-id and resource-type ) should be present", - "required" : false, - "type" : "string" - }, - "action-name" : { - "description" : "Conditional : Action Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority", - "required" : false, - "type" : "string" - }, - "template-content" : { - "description" : "Conditional : Dynamic Template used to generate Configuration.", - "required" : false, - "type" : "string" - }, - "resource-type" : { - "description" : "Conditional : resource-type used to pull the data content from the data base. Either template-data or ( resource-id and resource-type ) should be present", - "required" : false, - "type" : "string" - }, - "request-id" : { - "description" : "Request Id used to store the generated configuration, in the database along with the template-name", - "required" : true, - "type" : "string" - }, - "resource-id" : { - "description" : "Conditional : Id used to pull the data content from the data base. Either template-data or ( resource-id and resource-type ) should be present", - "required" : false, - "type" : "string" - }, - "template-name" : { - "description" : "Conditional : Name of the Artifact Node Template, to get the template Content. If template-content is present, then content wont be reterived from the Artifact Node Template.", - "required" : true, - "type" : "string" - } - }, - "outputs" : { - "generated-config" : { - "description" : "Generated Configuration for the Template adn Resource Data", - "required" : true, - "type" : "string" - }, - "mask-info" : { - "description" : "If template contains mask encription keys, then this mask-info field will be generated, This JSON Content alligns to the bean org.onap.ccsdk.features.model.data.custom.MaskInfo ", - "required" : false, - "type" : "string" - }, - "status" : { - "description" : "Status of the Component Execution ( success or failure )", - "required" : true, - "type" : "string" - } - } - } - } - } - }, - "derived_from" : "tosca.nodes.Component" - } - }, - "data_types" : { - "datatype-resource-assignment" : { - "version" : "1.0.0", - "description" : "This is Resource Assignment Data Type", - "properties" : { - "property" : { - "required" : true, - "type" : "datatype-property" - }, - "input-param" : { - "required" : true, - "type" : "boolean" - }, - "dictionary-name" : { - "required" : false, - "type" : "string" - }, - "dictionary-source" : { - "required" : false, - "type" : "string" - }, - "dependencies" : { - "required" : true, - "type" : "list", - "entry_schema" : { - "type" : "string" - } - } - }, - "derived_from" : "tosca.datatypes.Root" - }, - "datatype-property" : { - "version" : "1.0.0", - "description" : "This is Entry point Input Data Type, which is dynamic datatype, The parameter names will be populated during the Design time for each inputs", - "properties" : { - "type" : { - "required" : true, - "type" : "string" - }, - "description" : { - "required" : false, - "type" : "string" - }, - "required" : { - "required" : false, - "type" : "boolean" - }, - "default" : { - "required" : false, - "type" : "string" - }, - "entry_schema" : { - "required" : false, - "type" : "string" - } - }, - "derived_from" : "tosca.datatypes.Root" - } - } -} \ No newline at end of file diff --git a/blueprints-processor/plugin/model-provider/src/test/resources/service_templates/ra-content-with-mising-value.json b/blueprints-processor/plugin/model-provider/src/test/resources/service_templates/ra-content-with-mising-value.json deleted file mode 100644 index 72332d1b3..000000000 --- a/blueprints-processor/plugin/model-provider/src/test/resources/service_templates/ra-content-with-mising-value.json +++ /dev/null @@ -1,265 +0,0 @@ -[ - { - "name": "security-manager-resource-key", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "security-manager-resource-key", - "dictionary-source": "input" - }, - { - "name": "security-manager-resource-name", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "security-manager-resource-name", - "dictionary-source": "input" - }, - { - "name": "snmp-server-ipv4-addresses", - "input-param": true, - "property": { - "type": "list", - "required": true, - "entry_schema": { - "type": "string" - } - }, - "dictionary-name": "snmp-server-ipv4-addresses", - "dictionary-source": "network-resource-discovery", - "dependencies": [ - "asn-region", - "complex-code" - ] - }, - { - "name": "snmp-community", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "snmp-community", - "dictionary-source": "nsm", - "dependencies": [ - "security-manager-resource-name", - "security-manager-resource-key" - ], - "version": 0 - }, - { - "name": "lo0-local-ipv4-address", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "value": { - - }, - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "lo0-local-ipv4-address", - "dictionary-source": "network-resource-discovery", - "dependencies": [ - "hostname" - ], - "version": 0 - }, - { - "name": "adig-urlb-route-reflectors", - "property": { - "description": "", - "required": true, - "type": "list", - "status": "", - "constraints": [ - { - - } - ], - "value": { - - }, - "entry_schema": { - "type": "dt-adig-urlb-route-reflectors" - } - }, - "input-param": false, - "dictionary-name": "adig-urlb-route-reflectors", - "dictionary-source": "network-resource-discovery", - "dependencies": [ - "region" - ], - "version": 0 - }, - { - "name": "bundle-id", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "value": { - - }, - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "bundle-id", - "dictionary-source": "network-resource-discovery", - "dependencies": [ - "hostname" - ], - "version": 0 - }, - { - "name": "uplink-1-unit", - "property": { - "description": "", - "required": true, - "type": "integer", - "status": "", - "constraints": [ - { - - } - ], - "value": { - - }, - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "uplink-1-unit", - "dictionary-source": "network-resource-discovery", - "dependencies": [ - "hostname" - ], - "version": 0 - }, - { - "name": "uplink-2-unit", - "property": { - "description": "", - "required": true, - "type": "integer", - "status": "", - "constraints": [ - { - - } - ], - "value": { - - }, - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "uplink-2-unit", - "dictionary-source": "network-resource-discovery", - "dependencies": [ - "hostname" - ], - "version": 0 - }, - { - "name": "lo10-local-ipv4-address", - "property": { - "description": "", - "required": true, - "type": "string", - "status": "", - "constraints": [ - { - - } - ], - "value": { - - }, - "entry_schema": { - "type": "" - } - }, - "input-param": false, - "dictionary-name": "lo10-local-ipv4-address", - "dictionary-source": "network-resource-discovery", - "dependencies": [ - "hostname" - ], - "version": 0 - }, - { - "name": "complex-code", - "property": { - "required": true, - "type": "string" - }, - "dictionary-name": "complex-code", - "dictionary-source": "network-resource-discovery", - "dependencies": [ - "hostname" - ], - "version": 0 - }, - { - "name": "country-code", - "property": { - "required": true, - "type": "string" - }, - "dictionary-name": "country-code", - "dictionary-source": "network-resource-discovery", - "dependencies": [ - "hostname" - ], - "version": 0 - }, - { - "name": "hostname", - "property": { - "required": true, - "type": "string" - }, - "dictionary-name": "hostname", - "dictionary-source": "input", - "version": 0 - }, - { - "name": "region", - "property": { - "required": true, - "type": "string" - }, - "dictionary-name": "region", - "dictionary-source": "network-resource-discovery", - "dependencies": [ - "hostname" - ], - "version": 0 - } -] \ No newline at end of file diff --git a/blueprints-processor/plugin/model-provider/src/test/resources/service_templates/resource_assignment.json b/blueprints-processor/plugin/model-provider/src/test/resources/service_templates/resource_assignment.json deleted file mode 100644 index cbea6a82c..000000000 --- a/blueprints-processor/plugin/model-provider/src/test/resources/service_templates/resource_assignment.json +++ /dev/null @@ -1,407 +0,0 @@ -{ - "metadata": { - "author": "ks220y@att.com", - "service-template-name": "VRR-baseconfiguration", - "service-template-version": "1.0.0", - "release": "1802", - "service-type": "AVPN", - "vnf-type": "VRR" - }, - "topology_template": { - "inputs": { - "request-id": { - "required": true, - "type": "string" - }, - "service-instance-id": { - "required": true, - "type": "string" - }, - "action-name": { - "required": true, - "type": "string" - }, - "scope-type": { - "required": true, - "type": "string" - }, - "hostname": { - "required": true, - "type": "string" - } - }, - "node_templates": { - "base-config-template": { - "type": "artifact-config-template", - "properties": { - "action-names": [ - "resource-assignment-action" - ] - }, - "capabilities": { - "content": { - "properties": { - "content": "db://base-config-template" - } - }, - "mapping": { - "properties": { - "mapping": [ - { - "name": "vnf-id", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "vnf-id", - "dictionary-source": "input" - }, - { - "name": "group-name", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "group-name", - "dictionary-source": "input" - } - ] - } - } - } - }, - "resource-assignment-action": { - "type": "dg-resource-assignment", - "interfaces": { - "CONFIG": { - "operations": { - "ResourceAssignment": { - - } - } - } - }, - "capabilities": { - "dg-node": { - - } - }, - "requirements": { - "component-dependency": { - "capability": "component-node", - "node": "resource-assignment", - "relationship": "tosca.relationships.DependsOn" - } - } - }, - "licence-template": { - "type": "artifact-config-template", - "properties": { - "action-names": [ - "resource-assignment-action" - ] - }, - "capabilities": { - "content": { - "properties": { - "content": "db://licence-template" - } - }, - "mapping": { - "properties": { - "mapping": [ - { - "name": "bundle-id", - "input-param": true, - "property": { - "type": "string" - }, - "dictionary-name": "bundle-id", - "dictionary-source": "input" - }, - { - "name": "bundle-mac", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "bundle-mac", - "dictionary-source": "input" - } - ] - } - } - } - }, - "resource-assignment": { - "type": "component-resource-assignment", - "interfaces": { - "org-onap-ccsdk-features-assignment-service-ConfigAssignmentNode": { - "operations": { - "process": { - "inputs": { - "action-name": "{ \"get_input\" : \"action-name\" }", - "resource-type": "vnf-type", - "template-names": [ - "base-config-template", - "licence-template" - ], - "request-id": "{ \"get_input\" : \"request-id\" }", - "resource-id": "{ \"get_input\" : \"vnf-id\" }" - }, - "outputs": { - "resource-assignment-params": "", - "status": "" - } - } - } - } - }, - "capabilities": { - "component-node": { - - } - } - } - } - }, - "node_types": { - "dg-resource-assignment": { - "description": "This is Resource Assignment Directed Graph", - "version": "1.0.0", - "properties": { - "mode": { - "required": false, - "type": "string", - "default": "sync" - }, - "version": { - "required": false, - "type": "string", - "default": "LATEST" - }, - "is-start-flow": { - "required": false, - "type": "boolean", - "default": "false" - } - }, - "capabilities": { - "dg-node": { - "type": "tosca.capabilities.Node" - }, - "content": { - "type": "tosca.capabilities.Content", - "properties": { - "type": { - "required": false, - "type": "string", - "default": "json" - }, - "content": { - "required": true, - "type": "string" - } - } - } - }, - "requirements": { - "component-dependency": { - "capability": "component-node", - "node": "component-resource-assignment", - "relationship": "tosca.relationships.DependsOn" - } - }, - "interfaces": { - "CONFIG": { - "operations": { - "ResourceAssignment": { - "inputs": { - "params": { - "required": false, - "type": "list", - "entry_schema": { - "type": "datatype-property" - } - } - } - } - } - } - }, - "derived_from": "tosca.nodes.DG" - }, - "component-resource-assignment": { - "description": "This is Resource Assignment Component API", - "version": "1.0.0", - "capabilities": { - "component-node": { - "type": "tosca.capabilities.Node" - } - }, - "interfaces": { - "org-onap-ccsdk-features-assignment-service-ConfigAssignmentNode": { - "operations": { - "process": { - "inputs": { - "action-name": { - "description": "Action Name to get from Database, Either (message & mask-info ) or ( resource-id & resource-type & action-name & template-name ) should be present. Message will be given higest priority", - "required": false, - "type": "string" - }, - "handler-name": { - "description": "Name of the Artifact Node Template, to get the template Content. If template-content is present, then content wont be reterived from the Artifact Node Template.", - "required": true, - "type": "string" - }, - "resource-type": { - "required": false, - "type": "string" - }, - "template-names": { - "description": "Name of the Artifact Node Templates, to get the template Content.", - "required": true, - "type": "list", - "entry_schema": { - "type": "string" - } - }, - "request-id": { - "description": "Request Id used to store the generated configuration, in the database along with the template-name", - "required": true, - "type": "string" - }, - "resource-id": { - "description": "Id used to pull the data content from the data base. Either template-data or resource-id should be present", - "required": true, - "type": "string" - } - }, - "outputs": { - "resource-assignment-params": { - "required": true, - "type": "string" - }, - "status": { - "required": true, - "type": "string" - } - } - } - } - } - }, - "derived_from": "tosca.nodes.Component" - }, - "artifact-config-template": { - "description": "This is Configuration Velocity Template", - "version": "1.0.0", - "properties": { - "action-names": { - "required": true, - "type": "list", - "entry_schema": { - "type": "string" - } - }, - "content": { - "required": false, - "type": "string" - }, - "mapping": { - "required": false, - "type": "list", - "entry_schema": { - "type": "datatype-resource-assignment" - } - } - }, - "capabilities": { - "content": { - "type": "tosca.capabilities.Content", - "properties": { - "content": { - "required": true, - "type": "string" - } - } - }, - "mapping": { - "type": "tosca.capabilities.Mapping", - "properties": { - "mapping": { - "required": false, - "type": "list", - "entry_schema": { - "type": "datatype-resource-assignment" - } - } - } - } - }, - "derived_from": "tosca.nodes.Artifact" - } - }, - "data_types": { - "datatype-resource-assignment": { - "version": "1.0.0", - "description": "This is Resource Assignment Data Type", - "properties": { - "property": { - "required": true, - "type": "datatype-property" - }, - "input-param": { - "required": true, - "type": "boolean" - }, - "dictionary-name": { - "required": false, - "type": "string" - }, - "dictionary-source": { - "required": false, - "type": "string" - }, - "dependencies": { - "required": true, - "type": "list", - "entry_schema": { - "type": "string" - } - } - }, - "derived_from": "tosca.datatypes.Root" - }, - "datatype-property": { - "version": "1.0.0", - "description": "This is Entry point Input Data Type, which is dynamic datatype, The parameter names will be populated during the Design time for each inputs", - "properties": { - "type": { - "required": true, - "type": "string" - }, - "description": { - "required": false, - "type": "string" - }, - "required": { - "required": false, - "type": "boolean" - }, - "default": { - "required": false, - "type": "string" - }, - "entry_schema": { - "required": false, - "type": "string" - } - }, - "derived_from": "tosca.datatypes.Root" - } - } -} diff --git a/blueprints-processor/plugin/model-provider/src/test/resources/service_templates/velocity/base-config-template.vtl b/blueprints-processor/plugin/model-provider/src/test/resources/service_templates/velocity/base-config-template.vtl deleted file mode 100644 index ce7745bb7..000000000 --- a/blueprints-processor/plugin/model-provider/src/test/resources/service_templates/velocity/base-config-template.vtl +++ /dev/null @@ -1 +0,0 @@ -This is sample Base Configuration for ${bundle-id} for ${bundle-mac} \ No newline at end of file diff --git a/blueprints-processor/plugin/model-provider/src/test/resources/service_templates/velocity/licence-template.vtl b/blueprints-processor/plugin/model-provider/src/test/resources/service_templates/velocity/licence-template.vtl deleted file mode 100644 index e69de29bb..000000000 diff --git a/blueprints-processor/plugin/model-provider/src/test/resources/service_templates/vrr_config.json b/blueprints-processor/plugin/model-provider/src/test/resources/service_templates/vrr_config.json deleted file mode 100644 index 8c87f2d34..000000000 --- a/blueprints-processor/plugin/model-provider/src/test/resources/service_templates/vrr_config.json +++ /dev/null @@ -1,171 +0,0 @@ -{ - "metadata": { - "author": "ks220y@att.com", - "service-template-name": "VRR-baseconfiguration", - "service-template-version": "1.0.0", - "release": "1802", - "service-type": "AVPN", - "vnf-type": "VRR" - }, - "topology_template": { - "inputs": { - "request-id": { - "required": true, - "type": "string" - }, - "service-instance-id": { - "required": true, - "type": "string" - }, - "action-name": { - "required": true, - "type": "string" - }, - "scope-type": { - "required": true, - "type": "string" - }, - "hostname": { - "required": true, - "type": "string" - } - }, - "node_templates": { - "base-config-template": { - "type": "artifact-config-template", - "properties": { - "action-names": [ - "resource-assignment-action" - ] - }, - "capabilities": { - "content": { - "properties": { - "content": "db://base-config-template" - } - }, - "mapping": { - "properties": { - "mapping": [ - { - "name": "vnf-id", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "vnf-id", - "dictionary-source": "input" - }, - { - "name": "group-name", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "group-name", - "dictionary-source": "input" - } - ] - } - } - } - }, - "resource-assignment-action": { - "type": "dg-resource-assignment", - "interfaces": { - "CONFIG": { - "operations": { - "ResourceAssignment": { - - } - } - } - }, - "capabilities": { - "dg-node": { - - } - }, - "requirements": { - "component-dependency": { - "capability": "component-node", - "node": "resource-assignment", - "relationship": "tosca.relationships.DependsOn" - } - } - }, - "licence-template": { - "type": "artifact-config-template", - "properties": { - "action-names": [ - "resource-assignment-action" - ] - }, - "capabilities": { - "content": { - "properties": { - "content": "db://licence-template" - } - }, - "mapping": { - "properties": { - "mapping": [ - { - "name": "bundle-id", - "input-param": true, - "property": { - "type": "string" - }, - "dictionary-name": "bundle-id", - "dictionary-source": "input" - }, - { - "name": "bundle-mac", - "input-param": true, - "property": { - "type": "string", - "required": true - }, - "dictionary-name": "bundle-mac", - "dictionary-source": "input" - } - ] - } - } - } - }, - "resource-assignment": { - "type": "component-resource-assignment", - "interfaces": { - "org-onap-ccsdk-features-assignment-service-ConfigAssignmentNode": { - "operations": { - "process": { - "inputs": { - "action-name": "{ \"get_input\" : \"action-name\" }", - "resource-type": "vnf-type", - "template-names": [ - "base-config-template", - "licence-template" - ], - "request-id": "{ \"get_input\" : \"request-id\" }", - "resource-id": "{ \"get_input\" : \"vnf-id\" }" - }, - "outputs": { - "resource-assignment-params": "", - "status": "" - } - } - } - } - }, - "capabilities": { - "component-node": { - - } - } - } - } - } -} \ No newline at end of file diff --git a/blueprints-processor/plugin/pom.xml b/blueprints-processor/plugin/pom.xml deleted file mode 100644 index f6fe034b2..000000000 --- a/blueprints-processor/plugin/pom.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - 4.0.0 - - - org.onap.ccsdk.parent - odlparent-lite - 1.5.2-SNAPSHOT - - - - org.onap.ccsdk.features - blueprints-processor-plugin - 0.7.1-SNAPSHOT - pom - - ccsdk-features :: ${project.artifactId} - Blueprints Processor Plugins - POM - - - model-provider - assignment-provider - generator-provider - - diff --git a/blueprints-processor/pom.xml b/blueprints-processor/pom.xml deleted file mode 100644 index 35cb0c76b..000000000 --- a/blueprints-processor/pom.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - 4.0.0 - - - org.onap.ccsdk.parent - odlparent-lite - 1.5.2-SNAPSHOT - - - - org.onap.ccsdk.features - blueprints-processor - 0.7.1-SNAPSHOT - pom - - ccsdk-features :: ${project.artifactId} - Blueprints Processor Blueprints Processor - - - adaptors - plugin - features - installer - - -- cgit 1.2.3-korg