2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2020 Nordix Foundation.
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 package org.onap.ccsdk.features.a1.adapter;
23 import java.util.Properties;
24 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
25 import org.onap.ccsdk.sli.core.sli.provider.MdsalHelper;
26 import org.onap.ccsdk.sli.core.sli.provider.SvcLogicService;
27 import org.opendaylight.yang.gen.v1.org.onap.a1.adapter.rev200122.DeleteA1PolicyOutputBuilder;
28 import org.opendaylight.yang.gen.v1.org.onap.a1.adapter.rev200122.GetA1PolicyOutputBuilder;
29 import org.opendaylight.yang.gen.v1.org.onap.a1.adapter.rev200122.GetA1PolicyStatusOutputBuilder;
30 import org.opendaylight.yang.gen.v1.org.onap.a1.adapter.rev200122.GetA1PolicyTypeOutputBuilder;
31 import org.opendaylight.yang.gen.v1.org.onap.a1.adapter.rev200122.PutA1PolicyOutputBuilder;
32 import org.slf4j.Logger;
33 import org.slf4j.LoggerFactory;
35 public class A1AdapterClient {
37 private static final Logger LOG = LoggerFactory.getLogger(A1AdapterClient.class);
39 private SvcLogicService svcLogicService = null;
41 public A1AdapterClient(final SvcLogicService svcLogicService) {
42 this.svcLogicService = svcLogicService;
45 public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException {
46 return svcLogicService.hasGraph(module, rpc, version, mode);
49 public Properties execute(String module, String rpc, String version, String mode,
50 GetA1PolicyTypeOutputBuilder serviceData, Properties parms) throws SvcLogicException {
52 localProp = MdsalHelper.toProperties(parms, serviceData);
53 if (LOG.isDebugEnabled()) {
54 LOG.debug("Parameters passed to SLI");
56 for (Object key : localProp.keySet()) {
57 String parmName = (String) key;
58 String parmValue = localProp.getProperty(parmName);
60 LOG.debug(parmName + " = " + parmValue);
63 Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
64 if (LOG.isDebugEnabled()) {
65 LOG.debug("Parameters returned by SLI");
66 for (Object key : respProps.keySet()) {
67 String parmName = (String) key;
68 String parmValue = respProps.getProperty(parmName);
69 LOG.debug(parmName + " = " + parmValue);
72 if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
75 MdsalHelper.toBuilder(respProps, serviceData);
79 public Properties execute(String module, String rpc, String version, String mode,
80 GetA1PolicyStatusOutputBuilder serviceData, Properties parms) throws SvcLogicException {
82 localProp = MdsalHelper.toProperties(parms, serviceData);
83 if (LOG.isDebugEnabled()) {
84 LOG.debug("Parameters passed to SLI");
86 for (Object key : localProp.keySet()) {
87 String parmName = (String) key;
88 String parmValue = localProp.getProperty(parmName);
90 LOG.debug(parmName + " = " + parmValue);
93 Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
94 if (LOG.isDebugEnabled()) {
95 LOG.debug("Parameters returned by SLI");
96 for (Object key : respProps.keySet()) {
97 String parmName = (String) key;
98 String parmValue = respProps.getProperty(parmName);
99 LOG.debug(parmName + " = " + parmValue);
102 if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
105 MdsalHelper.toBuilder(respProps, serviceData);
109 public Properties execute(String module, String rpc, String version, String mode,
110 GetA1PolicyOutputBuilder serviceData, Properties parms) throws SvcLogicException {
111 Properties localProp;
112 localProp = MdsalHelper.toProperties(parms, serviceData);
113 if (LOG.isDebugEnabled()) {
114 LOG.debug("Parameters passed to SLI");
116 for (Object key : localProp.keySet()) {
117 String parmName = (String) key;
118 String parmValue = localProp.getProperty(parmName);
120 LOG.debug(parmName + " = " + parmValue);
123 Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
124 if (LOG.isDebugEnabled()) {
125 LOG.debug("Parameters returned by SLI");
126 for (Object key : respProps.keySet()) {
127 String parmName = (String) key;
128 String parmValue = respProps.getProperty(parmName);
129 LOG.debug(parmName + " = " + parmValue);
132 if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
135 MdsalHelper.toBuilder(respProps, serviceData);
139 public Properties execute(String module, String rpc, String version, String mode,
140 DeleteA1PolicyOutputBuilder serviceData, Properties parms) throws SvcLogicException {
141 Properties localProp;
142 localProp = MdsalHelper.toProperties(parms, serviceData);
143 if (LOG.isDebugEnabled()) {
144 LOG.debug("Parameters passed to SLI");
146 for (Object key : localProp.keySet()) {
147 String parmName = (String) key;
148 String parmValue = localProp.getProperty(parmName);
150 LOG.debug(parmName + " = " + parmValue);
153 Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
154 if (LOG.isDebugEnabled()) {
155 LOG.debug("Parameters returned by SLI");
156 for (Object key : respProps.keySet()) {
157 String parmName = (String) key;
158 String parmValue = respProps.getProperty(parmName);
159 LOG.debug(parmName + " = " + parmValue);
162 if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
165 MdsalHelper.toBuilder(respProps, serviceData);
169 public Properties execute(String module, String rpc, String version, String mode,
170 PutA1PolicyOutputBuilder serviceData, Properties parms) throws SvcLogicException {
171 Properties localProp;
172 localProp = MdsalHelper.toProperties(parms, serviceData);
173 if (LOG.isDebugEnabled()) {
174 LOG.debug("Parameters passed to SLI");
176 for (Object key : localProp.keySet()) {
177 String parmName = (String) key;
178 String parmValue = localProp.getProperty(parmName);
180 LOG.debug(parmName + " = " + parmValue);
183 Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
184 if (LOG.isDebugEnabled()) {
185 LOG.debug("Parameters returned by SLI");
186 for (Object key : respProps.keySet()) {
187 String parmName = (String) key;
188 String parmValue = respProps.getProperty(parmName);
189 LOG.debug(parmName + " = " + parmValue);
192 if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
195 MdsalHelper.toBuilder(respProps, serviceData);