2 * Copyright © 2017-2018 AT&T Intellectual Property.
3 * Modifications Copyright © 2018 IBM.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 @file:Suppress("unused")
19 package org.onap.ccsdk.apps.controllerblueprints.validation
21 import com.att.eelf.configuration.EELFLogger
22 import com.att.eelf.configuration.EELFManager
23 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
24 import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService
25 import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintValidatorService
26 import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
27 import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
28 import org.springframework.stereotype.Service
32 class BluePrintTypeValidatorDefaultService(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService)
33 : BluePrintValidatorService {
35 private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintValidatorServiceImpl::class.toString())
37 override fun validateBluePrints(basePath: String): Boolean {
39 log.info("validating blueprint($basePath)")
40 val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(UUID.randomUUID().toString(), basePath)
41 return validateBluePrints(bluePrintRuntimeService)
44 override fun validateBluePrints(bluePrintRuntimeService: BluePrintRuntimeService<*>): Boolean {
46 bluePrintTypeValidatorService.validateServiceTemplate(bluePrintRuntimeService, "service_template",
47 bluePrintRuntimeService.bluePrintContext().serviceTemplate)
49 if (bluePrintRuntimeService.getBluePrintError().errors.size > 0) {
50 throw BluePrintException("failed in blueprint validation : ${bluePrintRuntimeService.getBluePrintError().errors.joinToString("\n")}")
56 // Core Validator Services
59 class DefaultBluePrintServiceTemplateValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService)
60 : BluePrintServiceTemplateValidatorImpl(bluePrintTypeValidatorService)
63 class DefaultBluePrintDataTypeValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService)
64 : BluePrintDataTypeValidatorImpl(bluePrintTypeValidatorService)
67 class DefaultBluePrintArtifactTypeValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService)
68 : BluePrintArtifactTypeValidatorImpl(bluePrintTypeValidatorService)
71 class DefaultBluePrintNodeTypeValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService)
72 : BluePrintNodeTypeValidatorImpl(bluePrintTypeValidatorService)
75 class DefaultBluePrintTopologyTemplateValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService)
76 : BluePrintTopologyTemplateValidatorImpl(bluePrintTypeValidatorService)
79 class DefaulBluePrintNodeTemplateValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService)
80 : BluePrintNodeTemplateValidatorImpl(bluePrintTypeValidatorService)
83 class DefaultBluePrintWorkflowValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService)
84 : BluePrintWorkflowValidatorImpl(bluePrintTypeValidatorService)
87 class DefaultBluePrintPropertyDefinitionValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService)
88 : BluePrintPropertyDefinitionValidatorImpl(bluePrintTypeValidatorService)
91 class DefaultBluePrintAttributeDefinitionValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService)
92 : BluePrintAttributeDefinitionValidatorImpl(bluePrintTypeValidatorService)