327d50ac42a3b32e18cd32f228af63e7f5ac689a
[ccsdk/cds.git] /
1 /*
2  *  Copyright © 2018 IBM.
3  *  Modifications Copyright © 2017-2018 AT&T Intellectual Property.
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.apps.controllerblueprints.resource.dict
19
20 import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BlueprintFunctionNode
21 import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
22 import org.slf4j.LoggerFactory
23
24 abstract class ResourceAssignmentProcessor : BlueprintFunctionNode<ResourceAssignment, ResourceAssignment> {
25
26     private val log = LoggerFactory.getLogger(ResourceAssignmentProcessor::class.java)
27
28     private var bluePrintRuntimeService: BluePrintRuntimeService<*>? = null
29
30     open fun setBlueprintRuntimeService(bluePrintRuntimeService: BluePrintRuntimeService<*>) {
31         this.bluePrintRuntimeService = bluePrintRuntimeService
32     }
33
34     open fun getBlueprintRuntimeService(): BluePrintRuntimeService<*> {
35         return this.bluePrintRuntimeService!!
36     }
37
38     override fun prepareRequest(resourceAssignment: ResourceAssignment): ResourceAssignment {
39         log.info("prepareRequest...")
40         return resourceAssignment
41     }
42
43     override fun prepareResponse(): ResourceAssignment {
44         log.info("Preparing Response...")
45         return ResourceAssignment()
46     }
47
48     override fun apply(executionServiceInput: ResourceAssignment): ResourceAssignment {
49         prepareRequest(executionServiceInput)
50         process(executionServiceInput)
51         return prepareResponse()
52     }
53
54     override abstract fun process(executionRequest: ResourceAssignment)
55
56     override abstract fun recover(runtimeException: RuntimeException, executionRequest: ResourceAssignment)
57 }