1 package org.onap.sdnc.northbound;
3 import java.util.Properties;
5 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
6 import org.onap.ccsdk.sli.core.sli.provider.SvcLogicService;
7 import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.preload.data.PreloadDataBuilder;
8 import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.data.ServiceDataBuilder;
9 import org.osgi.framework.BundleContext;
10 import org.osgi.framework.FrameworkUtil;
11 import org.osgi.framework.ServiceReference;
12 import org.slf4j.Logger;
13 import org.slf4j.LoggerFactory;
15 public class GenericResourceApiSvcLogicServiceClient {
17 private static final Logger LOG = LoggerFactory
18 .getLogger(GenericResourceApiSvcLogicServiceClient.class);
20 private SvcLogicService svcLogic = null;
22 public GenericResourceApiSvcLogicServiceClient()
24 BundleContext bctx = FrameworkUtil.getBundle(SvcLogicService.class).getBundleContext();
26 // Get SvcLogicService reference
27 ServiceReference sref = bctx.getServiceReference(SvcLogicService.NAME);
30 svcLogic = (SvcLogicService) bctx.getService(sref);
35 LOG.warn("Cannot find service reference for "+SvcLogicService.NAME);
40 public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException
42 return(svcLogic.hasGraph(module, rpc, version, mode));
45 public Properties execute(String module, String rpc, String version, String mode, ServiceDataBuilder serviceData)
46 throws SvcLogicException {
48 Properties parms = new Properties();
50 return execute(module,rpc,version, mode,serviceData,parms);
53 public Properties execute(String module, String rpc, String version, String mode, PreloadDataBuilder serviceData)
54 throws SvcLogicException {
56 Properties parms = new Properties();
58 return execute(module,rpc,version, mode,serviceData,parms);
62 public Properties execute(String module, String rpc, String version, String mode, ServiceDataBuilder serviceData, Properties parms)
63 throws SvcLogicException {
65 parms = GenericResourceApiUtil.toProperties(parms, serviceData);
67 if (LOG.isDebugEnabled())
69 LOG.debug("Parameters passed to SLI");
71 for (Object key : parms.keySet()) {
72 String parmName = (String) key;
73 String parmValue = parms.getProperty(parmName);
75 LOG.debug(parmName+" = "+parmValue);
80 Properties respProps = svcLogic.execute(module, rpc, version, mode, parms);
82 if (LOG.isDebugEnabled())
84 LOG.debug("Parameters returned by SLI");
86 for (Object key : respProps.keySet()) {
87 String parmName = (String) key;
88 String parmValue = respProps.getProperty(parmName);
90 LOG.debug(parmName+" = "+parmValue);
94 if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
98 GenericResourceApiUtil.toBuilder(respProps, serviceData);
104 public Properties execute(String module, String rpc, String version, String mode, PreloadDataBuilder serviceData, Properties parms)
105 throws SvcLogicException {
107 parms = GenericResourceApiUtil.toProperties(parms, serviceData);
109 if (LOG.isDebugEnabled())
111 LOG.debug("Parameters passed to SLI");
113 for (Object key : parms.keySet()) {
114 String parmName = (String) key;
115 String parmValue = parms.getProperty(parmName);
117 LOG.debug(parmName+" = "+parmValue);
122 Properties respProps = svcLogic.execute(module, rpc, version, mode, parms);
124 if (LOG.isDebugEnabled())
126 LOG.debug("Parameters returned by SLI");
128 for (Object key : respProps.keySet()) {
129 String parmName = (String) key;
130 String parmValue = respProps.getProperty(parmName);
132 LOG.debug(parmName+" = "+parmValue);
136 if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
140 GenericResourceApiUtil.toBuilder(respProps, serviceData);