diff options
author | Alexis de Talhouët <adetalhouet89@gmail.com> | 2019-01-07 16:33:02 -0500 |
---|---|---|
committer | Alexis de Talhouët <alexis.de_talhouet@bell.ca> | 2019-01-09 22:11:43 +0000 |
commit | 7f6c527bac8c0c60a2988e59ff7251178f904cdd (patch) | |
tree | 5fc60442bc92250646ad9b104fb04174a44fc1e1 /ms/controllerblueprints/modules/blueprint-validation/src | |
parent | 88734c15a7822df7d27c23bcb08a3e808dd6634b (diff) |
Add support for blueprintprocessor runtime DB
- created db-resources module to store controller blueprint
related controller blueprint repository and entities. Also
create an abstract BlueprintCatalogServiceImpl so it can be
used both by controllerblueprint and blueprintprocessor
- created blueprint-validation to store the implementation
of the validation interface.
- change controllerblueprint service to levrage db-resources
- implement CatalogService for blueprintprocessor db-lib by
using db-resources.
Change-Id: I0539e414e4ff3b7a6edf0f6304d6cbc5e6eac404
Issue-ID: CCSDK-664
Signed-off-by: Alexis de Talhouët <adetalhouet89@gmail.com>
Diffstat (limited to 'ms/controllerblueprints/modules/blueprint-validation/src')
2 files changed, 166 insertions, 0 deletions
diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/blueprint/validation/BluePrintTypeValidatorServiceImpl.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/blueprint/validation/BluePrintTypeValidatorServiceImpl.kt new file mode 100644 index 000000000..76dfa73e3 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/blueprint/validation/BluePrintTypeValidatorServiceImpl.kt @@ -0,0 +1,66 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.blueprint.validation + +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.* +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.context.ApplicationContext +import org.springframework.stereotype.Service + +@Service +class BluePrintTypeValidatorServiceImpl : BluePrintTypeValidatorService { + + @Autowired + private lateinit var context: ApplicationContext + + override fun getServiceTemplateValidators(): List<BluePrintServiceTemplateValidator> { + return context.getBeansOfType(BluePrintServiceTemplateValidator::class.java).mapNotNull { it.value } + } + + override fun getDataTypeValidators(): List<BluePrintDataTypeValidator> { + return context.getBeansOfType(BluePrintDataTypeValidator::class.java).mapNotNull { it.value } + } + + override fun getArtifactTypeValidators(): List<BluePrintArtifactTypeValidator> { + return context.getBeansOfType(BluePrintArtifactTypeValidator::class.java).mapNotNull { it.value } + } + + override fun getNodeTypeValidators(): List<BluePrintNodeTypeValidator> { + return context.getBeansOfType(BluePrintNodeTypeValidator::class.java).mapNotNull { it.value } + } + + override fun getTopologyTemplateValidators(): List<BluePrintTopologyTemplateValidator> { + return context.getBeansOfType(BluePrintTopologyTemplateValidator::class.java).mapNotNull { it.value } + } + + override fun getNodeTemplateValidators(): List<BluePrintNodeTemplateValidator> { + return context.getBeansOfType(BluePrintNodeTemplateValidator::class.java).mapNotNull { it.value } + } + + override fun getWorkflowValidators(): List<BluePrintWorkflowValidator> { + return context.getBeansOfType(BluePrintWorkflowValidator::class.java).mapNotNull { it.value } + } + + override fun getPropertyDefinitionValidators(): List<BluePrintPropertyDefinitionValidator> { + return context.getBeansOfType(BluePrintPropertyDefinitionValidator::class.java).mapNotNull { it.value } + } + + override fun getAttributeDefinitionValidators(): List<BluePrintAttributeDefinitionValidator> { + return context.getBeansOfType(BluePrintAttributeDefinitionValidator::class.java).mapNotNull { it.value } + } +} + diff --git a/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/blueprint/validation/BluePrintValidatorDefaultService.kt b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/blueprint/validation/BluePrintValidatorDefaultService.kt new file mode 100644 index 000000000..2993b3d35 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-validation/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/blueprint/validation/BluePrintValidatorDefaultService.kt @@ -0,0 +1,100 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.blueprint.validation + +import com.att.eelf.configuration.EELFLogger +import com.att.eelf.configuration.EELFManager +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService +import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintValidatorService +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService +import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils +import org.onap.ccsdk.apps.controllerblueprints.core.validation.BluePrintArtifactTypeValidatorImpl +import org.onap.ccsdk.apps.controllerblueprints.core.validation.BluePrintAttributeDefinitionValidatorImpl +import org.onap.ccsdk.apps.controllerblueprints.core.validation.BluePrintDataTypeValidatorImpl +import org.onap.ccsdk.apps.controllerblueprints.core.validation.BluePrintNodeTemplateValidatorImpl +import org.onap.ccsdk.apps.controllerblueprints.core.validation.BluePrintNodeTypeValidatorImpl +import org.onap.ccsdk.apps.controllerblueprints.core.validation.BluePrintPropertyDefinitionValidatorImpl +import org.onap.ccsdk.apps.controllerblueprints.core.validation.BluePrintServiceTemplateValidatorImpl +import org.onap.ccsdk.apps.controllerblueprints.core.validation.BluePrintTopologyTemplateValidatorImpl +import org.onap.ccsdk.apps.controllerblueprints.core.validation.BluePrintValidatorServiceImpl +import org.onap.ccsdk.apps.controllerblueprints.core.validation.BluePrintWorkflowValidatorImpl +import org.springframework.stereotype.Service +import java.util.* + +@Service +class BluePrintTypeValidatorDefaultService(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService) + : BluePrintValidatorService { + + private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintValidatorServiceImpl::class.toString()) + + override fun validateBluePrints(basePath: String): Boolean { + + log.info("validating blueprint($basePath)") + val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(UUID.randomUUID().toString(), basePath) + return validateBluePrints(bluePrintRuntimeService) + } + + override fun validateBluePrints(bluePrintRuntimeService: BluePrintRuntimeService<*>): Boolean { + + bluePrintTypeValidatorService.validateServiceTemplate(bluePrintRuntimeService, "service_template", + bluePrintRuntimeService.bluePrintContext().serviceTemplate) + + if (bluePrintRuntimeService.getBluePrintError().errors.size > 0) { + throw BluePrintException("failed in blueprint validation : ${bluePrintRuntimeService.getBluePrintError().errors.joinToString("\n")}") + } + return true + } +} + +// Core Validator Services + +@Service +class DefaultBluePrintServiceTemplateValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService) + : BluePrintServiceTemplateValidatorImpl(bluePrintTypeValidatorService) + +@Service +class DefaultBluePrintDataTypeValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService) + : BluePrintDataTypeValidatorImpl(bluePrintTypeValidatorService) + +@Service +class DefaultBluePrintArtifactTypeValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService) + : BluePrintArtifactTypeValidatorImpl(bluePrintTypeValidatorService) + +@Service +class DefaultBluePrintNodeTypeValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService) + : BluePrintNodeTypeValidatorImpl(bluePrintTypeValidatorService) + +@Service +class DefaultBluePrintTopologyTemplateValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService) + : BluePrintTopologyTemplateValidatorImpl(bluePrintTypeValidatorService) + +@Service +class DefaulBluePrintNodeTemplateValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService) + : BluePrintNodeTemplateValidatorImpl(bluePrintTypeValidatorService) + +@Service +class DefaultBluePrintWorkflowValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService) + : BluePrintWorkflowValidatorImpl(bluePrintTypeValidatorService) + +@Service +class DefaulBluePrintPropertyDefinitionValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService) + : BluePrintPropertyDefinitionValidatorImpl(bluePrintTypeValidatorService) + +@Service +class DefaultBluePrintAttributeDefinitionValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService) + : BluePrintAttributeDefinitionValidatorImpl(bluePrintTypeValidatorService)
\ No newline at end of file |