From 3854151c6f07ae1bb4c68ce114aae247011f98c8 Mon Sep 17 00:00:00 2001 From: "Muthuramalingam, Brinda Santh(bs2796)" Date: Thu, 13 Dec 2018 15:10:35 -0500 Subject: Add blueprint runtime service to validator Change-Id: I0e4375e422b55002f1666ee9e61a1469482f77d2 Issue-ID: CCSDK-757 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) --- .../validator/BluePrintTypeValidatorServiceImpl.kt | 66 +++++++++++++ .../validator/BluePrintValidatorDefaultService.kt | 103 +++++++++++++++++++++ 2 files changed, 169 insertions(+) create mode 100644 ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/BluePrintTypeValidatorServiceImpl.kt create mode 100644 ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/BluePrintValidatorDefaultService.kt (limited to 'ms/controllerblueprints/modules/service/src/main/kotlin') diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/BluePrintTypeValidatorServiceImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/BluePrintTypeValidatorServiceImpl.kt new file mode 100644 index 000000000..9d4797ff9 --- /dev/null +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/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.service.validator + +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 { + return context.getBeansOfType(BluePrintServiceTemplateValidator::class.java).mapNotNull { it.value } + } + + override fun getDataTypeValidators(): List { + return context.getBeansOfType(BluePrintDataTypeValidator::class.java).mapNotNull { it.value } + } + + override fun getArtifactTypeValidators(): List { + return context.getBeansOfType(BluePrintArtifactTypeValidator::class.java).mapNotNull { it.value } + } + + override fun getNodeTypeValidators(): List { + return context.getBeansOfType(BluePrintNodeTypeValidator::class.java).mapNotNull { it.value } + } + + override fun getTopologyTemplateValidators(): List { + return context.getBeansOfType(BluePrintTopologyTemplateValidator::class.java).mapNotNull { it.value } + } + + override fun getNodeTemplateValidators(): List { + return context.getBeansOfType(BluePrintNodeTemplateValidator::class.java).mapNotNull { it.value } + } + + override fun getWorkflowValidators(): List { + return context.getBeansOfType(BluePrintWorkflowValidator::class.java).mapNotNull { it.value } + } + + override fun getPropertyDefinitionValidators(): List { + return context.getBeansOfType(BluePrintPropertyDefinitionValidator::class.java).mapNotNull { it.value } + } + + override fun getAttributeDefinitionValidators(): List { + return context.getBeansOfType(BluePrintAttributeDefinitionValidator::class.java).mapNotNull { it.value } + } +} + diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/BluePrintValidatorDefaultService.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/BluePrintValidatorDefaultService.kt new file mode 100644 index 000000000..89f4d9e38 --- /dev/null +++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/validator/BluePrintValidatorDefaultService.kt @@ -0,0 +1,103 @@ +/* + * 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.service.validator + +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.BluePrintRepoService +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.* +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceAssignmentValidationServiceImpl +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.service.ResourceDefinitionValidationServiceImpl +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) + +// Resource Dictionary Validation Services + +@Service +class DefaultResourceAssignmentValidationService : ResourceAssignmentValidationServiceImpl() + +@Service +class DefalutResourceDefinitionValidationService(bluePrintRepoService: BluePrintRepoService) + : ResourceDefinitionValidationServiceImpl(bluePrintRepoService) \ No newline at end of file -- cgit 1.2.3-korg