013e714407d311a828ca4b831018131401ca36c1
[ccsdk/features.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : CCSDK
4  * ================================================================================
5  * Copyright (C) 2021 Wipro Limited.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.ccsdk.features.sdnr.northbound.addCMHandle;
22
23 import com.google.common.base.Preconditions;
24 import com.google.common.util.concurrent.ListenableFuture;
25
26 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
27 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
28 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
29 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev210615.AddCMHandleInput;
30 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev210615.AddCMHandleOutput;
31 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev210615.CMHandleAPIService;
32 import org.opendaylight.yangtools.yang.common.RpcResult;
33 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
34 import org.slf4j.Logger;
35 import org.slf4j.LoggerFactory;
36
37 public class AddCMHandleProvider implements CMHandleAPIService {
38
39     private static final Logger LOG = LoggerFactory.getLogger(AddCMHandleProvider.class);
40
41     private final String appName = "addCMHandle";
42
43     private final DataBroker dataBroker;
44     private final RpcProviderRegistry rpcProviderRegistry;
45     private RpcRegistration<CMHandleAPIService> serviceRegistration;
46
47     private static final String SDNC_CONFIG_DIR = "SDNC_CONFIG_DIR";
48     private static final String PROPERTIES_FILE_NAME = "cm-handle.properties";
49     private static final String PARSING_ERROR =
50             "Could not create the request message to send to the server; no message will be sent";
51
52     public AddCMHandleProvider(final DataBroker dataBroker, RpcProviderRegistry rpcProviderRegistry) {
53         this.dataBroker = dataBroker;
54         this.rpcProviderRegistry = rpcProviderRegistry;
55     }
56
57     /**
58      * Method called when the blueprint container is created.
59      */
60     public void init() {
61         serviceRegistration = rpcProviderRegistry.addRpcImplementation(CMHandleAPIService.class, this);
62
63         LOG.debug("Initializing provider for " + appName);
64
65         Preconditions.checkNotNull(dataBroker, "dataBroker must be set");
66
67         String propDir = System.getenv(SDNC_CONFIG_DIR);
68         if (propDir == null) {
69             LOG.error("Environment variable SDNC_CONFIG_DIR is not set");
70             propDir = "/opt/onap/ccsdk/data/properties/";
71         } else if (!propDir.endsWith("/")) {
72             propDir = propDir + "/";
73         }
74
75         LOG.debug("Initialization complete for " + appName);
76     }
77
78     /**
79      * Method called when the blueprint container is destroyed.
80      */
81     public void close() {
82         LOG.debug("AddCMHandleProvider Closed");
83     }
84
85     @Override
86     public ListenableFuture<RpcResult<AddCMHandleOutput>> addCMHandle(AddCMHandleInput input) {
87
88         return null;
89     }
90 }