Removed redundant timeout handling for executeCommand
[ccsdk/cds.git] / ms / blueprintsprocessor / modules / inbounds / designer-api / src / main / kotlin / org / onap / ccsdk / cds / blueprintsprocessor / designer / api / enhancer / BlueprintNodeTemplateEnhancerImpl.kt
1 /*
2  * Copyright © 2017-2018 AT&T Intellectual Property.
3  * Modifications Copyright © 2019 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 package org.onap.ccsdk.cds.blueprintsprocessor.designer.api.enhancer
19
20 import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.utils.BlueprintEnhancerUtils
21 import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeTemplate
22 import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BlueprintNodeTemplateEnhancer
23 import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BlueprintRepoService
24 import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BlueprintTypeEnhancerService
25 import org.onap.ccsdk.cds.controllerblueprints.core.logger
26 import org.onap.ccsdk.cds.controllerblueprints.core.service.BlueprintContext
27 import org.onap.ccsdk.cds.controllerblueprints.core.service.BlueprintRuntimeService
28 import org.springframework.beans.factory.config.ConfigurableBeanFactory
29 import org.springframework.context.annotation.Scope
30 import org.springframework.stereotype.Service
31
32 @Service
33 @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
34 open class BlueprintNodeTemplateEnhancerImpl(
35     private val bluePrintRepoService: BlueprintRepoService,
36     private val bluePrintTypeEnhancerService: BlueprintTypeEnhancerService
37 ) :
38     BlueprintNodeTemplateEnhancer {
39
40     private val log = logger(BlueprintNodeTemplateEnhancerImpl::class)
41
42     lateinit var bluePrintRuntimeService: BlueprintRuntimeService<*>
43     lateinit var bluePrintContext: BlueprintContext
44
45     override fun enhance(bluePrintRuntimeService: BlueprintRuntimeService<*>, name: String, nodeTemplate: NodeTemplate) {
46         log.info("***** Enhancing NodeTemplate($name)")
47         this.bluePrintRuntimeService = bluePrintRuntimeService
48         this.bluePrintContext = bluePrintRuntimeService.bluePrintContext()
49
50         val nodeTypeName = nodeTemplate.type
51         // Get NodeType from Repo and Update Service Template
52         val nodeType = BlueprintEnhancerUtils.populateNodeType(bluePrintContext, bluePrintRepoService, nodeTypeName)
53
54         // Enrich NodeType
55         bluePrintTypeEnhancerService.enhanceNodeType(bluePrintRuntimeService, nodeTypeName, nodeType)
56
57         // Enrich Node Template Artifacts
58         enhanceNodeTemplateArtifactDefinition(name, nodeTemplate)
59     }
60
61     open fun enhanceNodeTemplateArtifactDefinition(nodeTemplateName: String, nodeTemplate: NodeTemplate) {
62
63         nodeTemplate.artifacts?.forEach { artifactDefinitionName, artifactDefinition ->
64             // Enhance Artifacct Definitions
65             bluePrintTypeEnhancerService.enhanceArtifactDefinition(bluePrintRuntimeService, artifactDefinitionName, artifactDefinition)
66         }
67     }
68 }