2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.ccsdk.features.sdnr.northbound.addCMHandle;
23 import com.google.common.base.Preconditions;
24 import com.google.common.util.concurrent.ListenableFuture;
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;
37 public class AddCMHandleProvider implements CMHandleAPIService {
39 private static final Logger LOG = LoggerFactory.getLogger(AddCMHandleProvider.class);
41 private final String appName = "addCMHandle";
43 private final DataBroker dataBroker;
44 private final RpcProviderRegistry rpcProviderRegistry;
45 private RpcRegistration<CMHandleAPIService> serviceRegistration;
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";
52 public AddCMHandleProvider(final DataBroker dataBroker, RpcProviderRegistry rpcProviderRegistry) {
53 this.dataBroker = dataBroker;
54 this.rpcProviderRegistry = rpcProviderRegistry;
58 * Method called when the blueprint container is created.
61 serviceRegistration = rpcProviderRegistry.addRpcImplementation(CMHandleAPIService.class, this);
63 LOG.debug("Initializing provider for " + appName);
65 Preconditions.checkNotNull(dataBroker, "dataBroker must be set");
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 + "/";
75 LOG.debug("Initialization complete for " + appName);
79 * Method called when the blueprint container is destroyed.
82 LOG.debug("AddCMHandleProvider Closed");
86 public ListenableFuture<RpcResult<AddCMHandleOutput>> addCMHandle(AddCMHandleInput input) {