2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T 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.openecomp.sdnc.asdcapi;
24 import java.util.Properties;
26 import org.openecomp.sdnc.sli.SvcLogicException;
27 import org.openecomp.sdnc.sli.provider.SvcLogicService;
28 import org.osgi.framework.BundleContext;
29 import org.osgi.framework.FrameworkUtil;
30 import org.osgi.framework.ServiceReference;
31 import org.slf4j.Logger;
32 import org.slf4j.LoggerFactory;
34 public class AsdcApiSliClient {
36 private static final Logger LOG = LoggerFactory
37 .getLogger(AsdcApiSliClient.class);
39 private SvcLogicService svcLogic = null;
41 public AsdcApiSliClient()
43 BundleContext bctx = FrameworkUtil.getBundle(SvcLogicService.class).getBundleContext();
45 // Get SvcLogicService reference
46 ServiceReference sref = bctx.getServiceReference(SvcLogicService.NAME);
49 svcLogic = (SvcLogicService) bctx.getService(sref);
53 LOG.warn("Cannot find service reference for "+SvcLogicService.NAME);
58 public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException
60 return(svcLogic.hasGraph(module, rpc, version, mode));
64 public Properties execute(String module, String rpc, String version, String mode, Properties parms)
65 throws SvcLogicException {
68 if (LOG.isDebugEnabled())
70 LOG.debug("Parameters passed to SLI");
72 for (Object key : parms.keySet()) {
73 String parmName = (String) key;
74 String parmValue = parms.getProperty(parmName);
76 LOG.debug(parmName+" = "+parmValue);
81 Properties respProps = svcLogic.execute(module, rpc, version, mode, parms);
83 if (LOG.isDebugEnabled())
85 LOG.debug("Parameters returned by SLI");
87 for (Object key : respProps.keySet()) {
88 String parmName = (String) key;
89 String parmValue = respProps.getProperty(parmName);
91 LOG.debug(parmName+" = "+parmValue);
96 if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
98 if (!respProps.containsKey("error-code")) {
99 respProps.setProperty("error-code", "500");
102 if (!respProps.containsKey("error-code")) {
103 respProps.setProperty("error-code", "200");