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.datachange;
24 import java.util.Properties;
26 import org.opendaylight.yang.gen.v1.org.openecomp.sdnc.datachange.rev150519.DataChangeNotificationOutputBuilder;
27 import org.openecomp.sdnc.sli.SvcLogicException;
28 import org.openecomp.sdnc.sli.provider.MdsalHelper;
29 import org.openecomp.sdnc.sli.provider.SvcLogicService;
30 import org.osgi.framework.BundleContext;
31 import org.osgi.framework.FrameworkUtil;
32 import org.osgi.framework.ServiceReference;
33 import org.slf4j.Logger;
34 import org.slf4j.LoggerFactory;
36 public class DataChangeClient {
38 private static final Logger LOG = LoggerFactory
39 .getLogger(DataChangeClient.class);
41 private SvcLogicService svcLogic = null;
43 public DataChangeClient()
45 BundleContext bctx = FrameworkUtil.getBundle(SvcLogicService.class).getBundleContext();
47 // Get SvcLogicService reference
48 ServiceReference sref = bctx.getServiceReference(SvcLogicService.NAME);
51 svcLogic = (SvcLogicService) bctx.getService(sref);
56 LOG.warn("Cannot find service reference for "+SvcLogicService.NAME);
61 public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException
63 return(svcLogic.hasGraph(module, rpc, version, mode));
66 public Properties execute(String module, String rpc, String version, String mode, DataChangeNotificationOutputBuilder serviceData)
67 throws SvcLogicException {
69 Properties parms = new Properties();
71 return execute(module,rpc,version, mode,serviceData,parms);
74 public Properties execute(String module, String rpc, String version, String mode, DataChangeNotificationOutputBuilder serviceData, Properties parms)
75 throws SvcLogicException {
77 parms = MdsalHelper.toProperties(parms, serviceData);
79 if (LOG.isDebugEnabled())
81 LOG.debug("Parameters passed to SLI");
83 for (Object key : parms.keySet()) {
84 String parmName = (String) key;
85 String parmValue = parms.getProperty(parmName);
87 LOG.debug(parmName+" = "+parmValue);
92 Properties respProps = svcLogic.execute(module, rpc, version, mode, parms);
94 if (LOG.isDebugEnabled())
96 LOG.debug("Parameters returned by SLI");
98 for (Object key : respProps.keySet()) {
99 String parmName = (String) key;
100 String parmValue = respProps.getProperty(parmName);
102 LOG.debug(parmName+" = "+parmValue);
106 if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
110 MdsalHelper.toBuilder(respProps, serviceData);