8e26588b818d77aa315322e9446b7b150ae69903
[ccsdk/cds.git] /
1 /*
2  * Copyright © 2017-2018 AT&T Intellectual Property.
3  * Modifications Copyright © 2018 IBM.
4  *
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
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
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.
16  */
17
18 @file:Suppress("unused")
19 package org.onap.ccsdk.apps.controllerblueprints.validation
20
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
29 import java.util.*
30
31 @Service
32 class BluePrintTypeValidatorDefaultService(private val bluePrintTypeValidatorService: BluePrintTypeValidatorService)
33     : BluePrintValidatorService {
34
35     private val log: EELFLogger = EELFManager.getInstance().getLogger(BluePrintValidatorServiceImpl::class.toString())
36
37     override fun validateBluePrints(basePath: String): Boolean {
38
39         log.info("validating blueprint($basePath)")
40         val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(UUID.randomUUID().toString(), basePath)
41         return validateBluePrints(bluePrintRuntimeService)
42     }
43
44     override fun validateBluePrints(bluePrintRuntimeService: BluePrintRuntimeService<*>): Boolean {
45
46         bluePrintTypeValidatorService.validateServiceTemplate(bluePrintRuntimeService, "service_template",
47                 bluePrintRuntimeService.bluePrintContext().serviceTemplate)
48
49         if (bluePrintRuntimeService.getBluePrintError().errors.size > 0) {
50             throw BluePrintException("failed in blueprint validation : ${bluePrintRuntimeService.getBluePrintError().errors.joinToString("\n")}")
51         }
52         return true
53     }
54 }
55
56 // Core Validator Services
57
58 @Service
59 class DefaultBluePrintServiceTemplateValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService)
60     : BluePrintServiceTemplateValidatorImpl(bluePrintTypeValidatorService)
61
62 @Service
63 class DefaultBluePrintDataTypeValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService)
64     : BluePrintDataTypeValidatorImpl(bluePrintTypeValidatorService)
65
66 @Service
67 class DefaultBluePrintArtifactTypeValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService)
68     : BluePrintArtifactTypeValidatorImpl(bluePrintTypeValidatorService)
69
70 @Service
71 class DefaultBluePrintNodeTypeValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService)
72     : BluePrintNodeTypeValidatorImpl(bluePrintTypeValidatorService)
73
74 @Service
75 class DefaultBluePrintTopologyTemplateValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService)
76     : BluePrintTopologyTemplateValidatorImpl(bluePrintTypeValidatorService)
77
78 @Service
79 class DefaulBluePrintNodeTemplateValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService)
80     : BluePrintNodeTemplateValidatorImpl(bluePrintTypeValidatorService)
81
82 @Service
83 class DefaultBluePrintWorkflowValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService)
84     : BluePrintWorkflowValidatorImpl(bluePrintTypeValidatorService)
85
86 @Service
87 class DefaultBluePrintPropertyDefinitionValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService)
88     : BluePrintPropertyDefinitionValidatorImpl(bluePrintTypeValidatorService)
89
90 @Service
91 class DefaultBluePrintAttributeDefinitionValidator(bluePrintTypeValidatorService: BluePrintTypeValidatorService)
92     : BluePrintAttributeDefinitionValidatorImpl(bluePrintTypeValidatorService)