2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019-2020 Fujitsu Limited Intellectual Property. All rights
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.sdnc.northbound;
24 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 import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.optical.service.rev191206.OpticalServiceCreateOutputBuilder;
30 import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.optical.service.rev191206.OpticalServiceDeleteOutputBuilder;
31 import org.slf4j.Logger;
32 import org.slf4j.LoggerFactory;
34 public class OpticalServiceClient {
36 private static final Logger LOG = LoggerFactory.getLogger(OpticalServiceClient.class);
38 private SvcLogicService svcLogicService = null;
40 public OpticalServiceClient(final SvcLogicService svcLogicService) {
41 this.svcLogicService = svcLogicService;
44 public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException {
45 return svcLogicService.hasGraph(module, rpc, version, mode);
48 public Properties execute(String module, String rpc, String version, String mode,
49 OpticalServiceCreateOutputBuilder serviceData) throws SvcLogicException {
51 Properties parms = new Properties();
53 return execute(module, rpc, version, mode, serviceData, parms);
56 public Properties execute(String module, String rpc, String version, String mode,
57 OpticalServiceCreateOutputBuilder serviceData, Properties parms) throws SvcLogicException {
60 localProp = MdsalHelper.toProperties(parms, serviceData);
62 if (LOG.isDebugEnabled()) {
63 LOG.debug("Parameters passed to SLI");
65 for (Object key : localProp.keySet()) {
66 String parmName = (String) key;
67 String parmValue = localProp.getProperty(parmName);
69 LOG.debug(parmName + " = " + parmValue);
74 Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
76 if (LOG.isDebugEnabled()) {
77 LOG.debug("Parameters returned by SLI");
79 for (Object key : respProps.keySet()) {
80 String parmName = (String) key;
81 String parmValue = respProps.getProperty(parmName);
83 LOG.debug(parmName + " = " + parmValue);
87 if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
91 MdsalHelper.toBuilder(respProps, serviceData);
96 public Properties execute(String module, String rpc, String version, String mode,
97 OpticalServiceDeleteOutputBuilder serviceData) throws SvcLogicException {
99 Properties parms = new Properties();
101 return execute(module, rpc, version, mode, serviceData, parms);
104 public Properties execute(String module, String rpc, String version, String mode,
105 OpticalServiceDeleteOutputBuilder serviceData, Properties parms) throws SvcLogicException {
107 Properties localProp;
108 localProp = MdsalHelper.toProperties(parms, serviceData);
110 if (LOG.isDebugEnabled()) {
111 LOG.debug("Parameters passed to SLI");
113 for (Object key : localProp.keySet()) {
114 String parmName = (String) key;
115 String parmValue = localProp.getProperty(parmName);
117 LOG.debug(parmName + " = " + parmValue);
122 Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
124 if (LOG.isDebugEnabled()) {
125 LOG.debug("Parameters returned by SLI");
127 for (Object key : respProps.keySet()) {
128 String parmName = (String) key;
129 String parmValue = respProps.getProperty(parmName);
131 LOG.debug(parmName + " = " + parmValue);
135 if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
139 MdsalHelper.toBuilder(respProps, serviceData);