ORAN CMNotify Karaf Feature Development
[ccsdk/features.git] / sdnr / northbound / CMNotify / provider / src / main / java / org / onap / ccsdk / features / sdnr / northbound / CMNotify / CMNotifyClient.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * openECOMP : SDN-C
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights
6  *                      reserved.
7  * Modifications Copyright (C) 2020 Nordix Foundation.
8  * ================================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * ============LICENSE_END=========================================================
21  */
22
23 package org.onap.ccsdk.features.sdnr.northbound.CMNotify;
24
25 import java.util.Properties;
26 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
27 import org.onap.ccsdk.sli.core.sli.provider.MdsalHelper;
28 import org.onap.ccsdk.sli.core.sli.provider.SvcLogicService;
29
30 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev200224.NbrlistChangeNotificationOutputBuilder;
31
32 import org.slf4j.Logger;
33 import org.slf4j.LoggerFactory;
34
35 public class CMNotifyClient {
36
37     private static final Logger LOG = LoggerFactory.getLogger(CMNotifyClient.class);
38
39     private SvcLogicService svcLogicService = null;
40
41     public CMNotifyClient(final SvcLogicService svcLogicService) {
42         this.svcLogicService = svcLogicService;
43     }
44
45     public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException {
46         return svcLogicService.hasGraph(module, rpc, version, mode);
47     }
48
49       // Client for NbrlistChangeNotification
50
51     public Properties execute(String module, String rpc, String version, String mode,
52             NbrlistChangeNotificationOutputBuilder serviceData) throws SvcLogicException {
53
54         Properties parms = new Properties();
55
56         return execute(module, rpc, version, mode, serviceData, parms);
57     }
58
59     public Properties execute(String module, String rpc, String version, String mode,
60             NbrlistChangeNotificationOutputBuilder serviceData, Properties parms) throws SvcLogicException {
61         Properties localProp;
62         localProp = MdsalHelper.toProperties(parms, serviceData);
63
64         if (LOG.isDebugEnabled()) {
65             LOG.debug("Parameters passed to SLI");
66
67             for (Object key : localProp.keySet()) {
68                 String parmName = (String) key;
69                 String parmValue = localProp.getProperty(parmName);
70
71                 LOG.debug(parmName + " = " + parmValue);
72
73             }
74         }
75
76         Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
77
78         if (LOG.isDebugEnabled()) {
79             LOG.debug("Parameters returned by SLI");
80
81             for (Object key : respProps.keySet()) {
82                 String parmName = (String) key;
83                 String parmValue = respProps.getProperty(parmName);
84
85                 LOG.debug(parmName + " = " + parmValue);
86
87             }
88         }
89         if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
90             return respProps;
91         }
92
93         MdsalHelper.toBuilder(respProps, serviceData);
94
95         return respProps;
96     }
97
98
99
100 }