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.GetA1PolicyTypeOutputBuilder;
28 import org.slf4j.Logger;
29 import org.slf4j.LoggerFactory;
31 public class A1AdapterClient {
33 private static final Logger LOG = LoggerFactory.getLogger(A1AdapterClient.class);
35 private SvcLogicService svcLogicService = null;
37 public A1AdapterClient(final SvcLogicService svcLogicService) {
38 this.svcLogicService = svcLogicService;
41 public boolean hasGraph(String module, String rpc, String version, String mode)
42 throws SvcLogicException {
43 return svcLogicService.hasGraph(module, rpc, version, mode);
46 public Properties execute(String module, String rpc, String version, String mode,
47 GetA1PolicyTypeOutputBuilder serviceData, Properties parms) throws SvcLogicException {
49 localProp = MdsalHelper.toProperties(parms, serviceData);
50 if (LOG.isDebugEnabled()) {
51 LOG.debug("Parameters passed to SLI");
53 for (Object key : localProp.keySet()) {
54 String parmName = (String) key;
55 String parmValue = localProp.getProperty(parmName);
57 LOG.debug(parmName + " = " + parmValue);
60 Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
61 if (LOG.isDebugEnabled()) {
62 LOG.debug("Parameters returned by SLI");
63 for (Object key : respProps.keySet()) {
64 String parmName = (String) key;
65 String parmValue = respProps.getProperty(parmName);
66 LOG.debug(parmName + " = " + parmValue);
69 if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
72 MdsalHelper.toBuilder(respProps, serviceData);