<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
- <scope>compile</scope>
- </dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.mariadb.jdbc</groupId>
- <artifactId>mariadb-java-client</artifactId>
- <type>jar</type>
- <scope>compile</scope>
</dependency>
<dependency>
<groupId>org.onap.ccsdk.sli.core</groupId>
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.opendaylight.mdsal.binding.model.ietf</groupId>
- <artifactId>rfc6991</artifactId>
- </dependency>
- <dependency>
- <groupId>org.onap.logging-analytics</groupId>
- <artifactId>logging-slf4j</artifactId>
- <version>1.5.0</version>
- </dependency>
-
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-core-api</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-binding-api</artifactId>
- </dependency>
-
+ <groupId>org.onap.logging-analytics</groupId>
+ <artifactId>logging-slf4j</artifactId>
+ <version>1.5.0</version>
+ </dependency>
<!-- Testing Dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
-
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
import java.util.ArrayList;
import java.util.Date;
import java.util.Properties;
-
import javax.sql.rowset.CachedRowSet;
-
import org.onap.ccsdk.sli.core.dblib.DbLibService;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.ServiceReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
LOG.info(INCOMING_PROPERTY_NAME + ": " + incomingEnabled);
LOG.info(OUTGOING_PROPERTY_NAME + ": " + outgoingEnabled);
-
- if (dbLibService != null)
- return;
-
- BundleContext bctx = FrameworkUtil.getBundle(MessageWriter.class).getBundleContext();
-
- ServiceReference sref = bctx.getServiceReference(DBLIB_SERVICE);
-
- if (sref == null) {
- LOG.warn("Could not find service reference for DBLIB service (" + DBLIB_SERVICE + ")");
- } else {
- dbLibService = (DbLibService) bctx.getService(sref);
- if (dbLibService == null) {
- LOG.warn("Could not find service reference for DBLIB service (" + DBLIB_SERVICE + ")");
- }
- }
}
public static void saveOutgoingRequest(
import java.util.Map;
import java.util.Properties;
import java.util.Set;
-
-import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
private HashMap<String, String> attributes;
- private DOMDataBroker domDataBroker;
-
private String status = "success";
public SvcLogicContext()
}
}
-
-
- public DOMDataBroker getDomDataBroker() {
- return domDataBroker;
- }
-
- public void setDomDataBroker(DOMDataBroker domDataBroker) {
- this.domDataBroker = domDataBroker;
- }
-
public String getAttribute(String name)
{
if (attributes.containsKey(name))
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.sql.Blob;
import java.util.ArrayList;
import java.util.Properties;
import javax.sql.rowset.CachedRowSet;
-import org.onap.ccsdk.sli.core.dblib.DBResourceManager;
import org.onap.ccsdk.sli.core.dblib.DbLibService;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.ServiceReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class SvcLogicDblibStore implements SvcLogicStore {
-
- private static final String SDNC_CONFIG_DIR = "SDNC_CONFIG_DIR";
-
private static final Logger LOG = LoggerFactory.getLogger(SvcLogicDblibStore.class);
-
- private static final String DBLIB_SERVICE = "org.onap.ccsdk.sli.core.dblib.DbLibService";
-
private DbLibService dbSvc;
- public SvcLogicDblibStore()
- {
- // Does nothing, but needed so that argumentless constructor
- // still works.
- }
-
public SvcLogicDblibStore(DbLibService dbsvc) {
this.dbSvc = dbsvc;
}
- public SvcLogicDblibStore(Properties props) {
- try {
- dbSvc = new DBResourceManager(props);
- JavaSingleton.setInstance(dbSvc);
- } catch (Exception e) {
- LOG.warn("Caught exception trying to create DBResourceManager", e);
- }
- }
-
public Connection getConnection() throws SQLException {
return(dbSvc.getConnection());
}
@Override
public void init(Properties props) throws ConfigurationException {
-
- dbSvc = getDbLibService();
if(dbSvc == null) {
LOG.error("SvcLogic cannot acquire DBLIB_SERVICE");
return;
}
}
- private DbLibService getDbLibService() {
-
- if (dbSvc != null) {
- return dbSvc;
- }
-
- // Get DbLibService interface object.
- ServiceReference sref = null;
- BundleContext bctx = null;
-
- Bundle bundle = FrameworkUtil.getBundle(SvcLogicDblibStore.class);
-
- if (bundle != null) {
- bctx = bundle.getBundleContext();
-
- if (bctx != null) {
- sref = bctx.getServiceReference(DBLIB_SERVICE);
- }
-
- if (sref == null) {
- LOG.warn("Could not find service reference for DBLIB service ({})", DBLIB_SERVICE);
- } else {
- dbSvc = (DbLibService) bctx.getService(sref);
- if (dbSvc == null) {
-
- LOG.warn("Could not find service reference for DBLIB service ({})", DBLIB_SERVICE);
- }
- }
- }
-
- // initialize a stand-alone instance of dblib resource
- else {
- // Try to create a DbLibService object from dblib properties
- if(JavaSingleton.getInstance() == null){
- Properties dblibProps = new Properties();
-
- String propDir = System.getenv(SDNC_CONFIG_DIR);
- if (propDir == null) {
-
- propDir = "/opt/sdnc/data/properties";
- }
- String propPath = propDir + "/dblib.properties";
-
- File propFile = new File(propPath);
-
- if (!propFile.exists()) {
-
- LOG.warn("Missing configuration properties file : {}", propFile);
- return null;
- }
-
- try {
-
- dblibProps.load(new FileInputStream(propFile));
- } catch (Exception e) {
- LOG.warn(
- "Could not load properties file " + propPath, e);
- return null;
-
- }
-
- try {
- dbSvc = new DBResourceManager(dblibProps);
- JavaSingleton.setInstance(dbSvc);
- } catch (Exception e) {
- LOG.warn("Caught exception trying to create DBResourceManager", e);
- }
- } else {
- dbSvc = JavaSingleton.getInstance();
- }
- }
- return dbSvc;
- }
-
-
- static class JavaSingleton {
- /* Private constructor */
- private JavaSingleton() {
- /* the body of the constructor here */
- }
-
- /* instance of the singleton declaration */
- private static volatile DbLibService INSTANCE ;
-
- /* Access point to the unique instance of the singleton */
- public static DbLibService getInstance() {
- return INSTANCE;
- }
-
- public static void setInstance(DbLibService dbresource) {
- INSTANCE = dbresource;
- }
- }
-
-
@Override
public void activate(String module, String rpc, String version, String mode) throws SvcLogicException {
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
-
import org.antlr.v4.runtime.ANTLRInputStream;
import org.antlr.v4.runtime.CharStream;
import org.antlr.v4.runtime.CommonTokenStream;
return(listener.getParsedExpr());
}
-
- public static void main(String argv[]) {
-
- System.setProperty(org.slf4j.impl.SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "debug");
-
- StringBuffer sbuff = new StringBuffer();
-
- for (int i = 0 ; i < argv.length ; i++)
- {
- if (sbuff.length() > 0)
- {
- sbuff.append(" ");
- }
- sbuff.append(argv[i]);
- }
-
- try {
- SvcLogicExpressionFactory.parse(sbuff.toString());
- } catch (IOException e) {
- LOG.error("Exception in SvcLogicExpressionFactory.parse",e);
- }
- }
}
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Properties;
-
+import org.onap.ccsdk.sli.core.dblib.DBResourceManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
retval = new SvcLogicJdbcStore();
} else if ("dblib".equalsIgnoreCase(storeType)) {
- retval = new SvcLogicDblibStore();
+ retval = new SvcLogicDblibStore(new DBResourceManager(props));
} else {
throw new ConfigurationException("unsupported dbtype (" + storeType
+ ")");
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
-
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;
-
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.onap.ccsdk.sli.core.dblib.DBResourceManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
props.load(propStr);
- SvcLogicDblibStore dblibStore = new SvcLogicDblibStore(props);
+ SvcLogicDblibStore dblibStore = new SvcLogicDblibStore(new DBResourceManager(props));
Connection dbConn = dblibStore.getConnection();
<groupId>org.opendaylight.controller</groupId>
<artifactId>sal-binding-api</artifactId>
</dependency>
-
+ <dependency>
+ <groupId>org.opendaylight.mdsal.binding.model.ietf</groupId>
+ <artifactId>rfc6991</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-core-api</artifactId>
+ </dependency>
<!-- Testing Dependencies -->
<dependency>
<groupId>junit</groupId>
* ============LICENSE_END=========================================================
*/
-package org.onap.ccsdk.sli.core.sli;
+package org.onap.ccsdk.sli.core.sli.provider;
import java.io.PrintStream;
import java.io.FileDescriptor;
@Override
public Properties execute(String module, String rpc, String version, String mode, Properties props)
throws SvcLogicException {
- return (execute(module, rpc, version, mode, props, null));
- }
-
- @Override
- public Properties execute(String module, String rpc, String version, String mode, Properties props,
- DOMDataBroker domDataBroker) throws SvcLogicException {
SvcLogicGraph graph = store.fetch(module, rpc, version, mode);
if (graph == null) {
ctx.setAttribute(CURRENT_GRAPH, graph.toString());
// To support legacy code we should not stop populating X-ECOMP-RequestID
ctx.setAttribute("X-ECOMP-RequestID", MDC.get(ONAPLogConstants.MDCs.REQUEST_ID));
- ctx.setDomDataBroker(domDataBroker);
execute(graph, ctx);
return (ctx.toProperties());
}
+ @Override
+ @Deprecated
+ // DomDataBroker is not being used, this should be removed eventually
+ public Properties execute(String module, String rpc, String version, String mode, Properties props,
+ DOMDataBroker domDataBroker) throws SvcLogicException {
+ return (execute(module, rpc, version, mode, props));
+ }
+
@Override
public SvcLogicStore getStore() throws SvcLogicException {
// Create and initialize SvcLogicStore object - used to access
20 * ===================================================================
21 *
22 */
-package org.onap.ccsdk.sli.core.sli;
+package org.onap.ccsdk.sli.core.sli.provider;
import java.util.Enumeration;
import java.util.LinkedList;
import java.util.Properties;
import org.junit.Test;
+import org.onap.ccsdk.sli.core.sli.provider.PrintYangToProp;
import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInput.Mode;
import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.TestResultsBuilder;
<name>ccsdk-sli-core :: sli :: ${project.artifactId}</name>
<description>SLI Recording is an OSGi bundle that implements recording service for the service logic record node.</description>
- <properties>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- </properties>
-
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.onap.ccsdk.sli.core</groupId>
- <artifactId>dblib-provider</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
<dependencies>
<dependency>
<groupId>org.onap.ccsdk.sli.core</groupId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- <scope>provided</scope>
- </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>jcl-over-slf4j</artifactId>
- </dependency>
-
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<scope>compile</scope>
</dependency>
-
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-binding-api</artifactId>
- </dependency>
-
<!-- Testing Dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
-
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
-
</dependencies>
</project>