2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights
7 * Modifications Copyright © 2018 IBM.
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
13 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
23 package org.onap.ccsdk.features.sdnr.northbound.ranSlice;
26 import java.util.Properties;
28 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
29 import org.onap.ccsdk.sli.core.sli.provider.SvcLogicService;
30 import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
31 import org.slf4j.Logger;
32 import org.slf4j.LoggerFactory;
34 public class RANSliceClient {
36 private static final Logger LOG = LoggerFactory.getLogger(RANSliceClient.class);
38 private final SvcLogicService svcLogicService;
40 private String ErrorCode = "error-code";
42 public RANSliceClient(final SvcLogicService svcLogicService) {
43 this.svcLogicService = svcLogicService;
46 public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException
48 return svcLogicService.hasGraph(module, rpc, version, mode);
52 public Properties execute(String module, String rpc, String version, String mode, Properties parms, DOMDataBroker dataBroker)
53 throws SvcLogicException {
56 if (LOG.isDebugEnabled())
58 LOG.debug("Parameters passed to SLI");
60 for (Object key : parms.keySet()) {
61 String parmName = (String) key;
62 String parmValue = parms.getProperty(parmName);
64 LOG.debug(parmName+" = "+parmValue);
69 Properties respProps = svcLogicService.execute(module, rpc, version, mode, parms, dataBroker);
71 if (LOG.isDebugEnabled())
73 LOG.debug("Parameters returned by SLI");
75 for (Object key : respProps.keySet()) {
76 String parmName = (String) key;
77 String parmValue = respProps.getProperty(parmName);
79 LOG.debug(parmName+" = "+parmValue);
84 if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
86 if (!respProps.containsKey(ErrorCode)) {
87 respProps.setProperty(ErrorCode, "500");
90 if (!respProps.containsKey(ErrorCode)) {
91 respProps.setProperty(ErrorCode, "200");