From 17bbf8be295cb8e2cfc4faf466ada9c899089c63 Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Wed, 30 Oct 2019 14:07:38 +0000 Subject: [PATCH] remove ODL/karaf from common Don't let sli common use odl or karaf classes Issue-ID: CCSDK-1723 Signed-off-by: Smokowski, Kevin (ks6305) Change-Id: I740fa32b9c40a7efdf7ef9ce25b26cf43353c559 --- sli/common/pom.xml | 40 +------ .../org/onap/ccsdk/sli/core/sli/MessageWriter.java | 21 ---- .../onap/ccsdk/sli/core/sli/SvcLogicContext.java | 14 --- .../ccsdk/sli/core/sli/SvcLogicDblibStore.java | 125 --------------------- .../sli/core/sli/SvcLogicExpressionFactory.java | 23 ---- .../ccsdk/sli/core/sli/SvcLogicStoreFactory.java | 4 +- .../ccsdk/sli/core/sli/ITCaseSvcLogicParser.java | 5 +- sli/provider/pom.xml | 9 +- .../sli/core/sli/provider}/PrintYangToProp.java | 2 +- .../sli/core/sli/provider/SvcLogicServiceImpl.java | 15 +-- .../core/sli/provider}/PrintYangToPropTest.java | 3 +- sli/recording/pom.xml | 32 ------ 12 files changed, 27 insertions(+), 266 deletions(-) rename sli/{common/src/main/java/org/onap/ccsdk/sli/core/sli => provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider}/PrintYangToProp.java (99%) rename sli/{common/src/test/java/org/onap/ccsdk/sli/core/sli => provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider}/PrintYangToPropTest.java (98%) diff --git a/sli/common/pom.xml b/sli/common/pom.xml index 7b4adb8b..2166760d 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -38,25 +38,9 @@ org.slf4j slf4j-api - - org.slf4j - slf4j-simple - compile - org.apache.commons commons-lang3 - - - org.osgi - org.osgi.core - provided - - - org.mariadb.jdbc - mariadb-java-client - jar - compile org.onap.ccsdk.sli.core @@ -70,32 +54,16 @@ test - org.opendaylight.mdsal.binding.model.ietf - rfc6991 - - - org.onap.logging-analytics - logging-slf4j - 1.5.0 - - - - org.opendaylight.controller - sal-core-api - - - - org.opendaylight.controller - sal-binding-api - - + org.onap.logging-analytics + logging-slf4j + 1.5.0 + junit junit test - org.mockito mockito-core diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MessageWriter.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MessageWriter.java index 0e39896e..5ededb9e 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MessageWriter.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/MessageWriter.java @@ -28,13 +28,8 @@ import java.text.SimpleDateFormat; 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; @@ -96,22 +91,6 @@ public class MessageWriter { 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( diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java index aca904d1..b592c15f 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java @@ -25,8 +25,6 @@ import java.util.HashMap; 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; @@ -42,8 +40,6 @@ public class SvcLogicContext { private HashMap attributes; - private DOMDataBroker domDataBroker; - private String status = "success"; public SvcLogicContext() @@ -68,16 +64,6 @@ public class SvcLogicContext { } } - - - public DOMDataBroker getDomDataBroker() { - return domDataBroker; - } - - public void setDomDataBroker(DOMDataBroker domDataBroker) { - this.domDataBroker = domDataBroker; - } - public String getAttribute(String name) { if (attributes.containsKey(name)) diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java index 94ffcd99..dc3a560e 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java @@ -23,8 +23,6 @@ package org.onap.ccsdk.sli.core.sli; 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; @@ -35,52 +33,24 @@ import java.sql.SQLException; 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; @@ -334,101 +304,6 @@ public class SvcLogicDblibStore implements SvcLogicStore { } } - 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 { diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExpressionFactory.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExpressionFactory.java index 9e9bfe0d..727c84b1 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExpressionFactory.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicExpressionFactory.java @@ -24,7 +24,6 @@ package org.onap.ccsdk.sli.core.sli; 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; @@ -72,27 +71,5 @@ public class SvcLogicExpressionFactory { 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); - } - } } diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStoreFactory.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStoreFactory.java index 532ad31b..b73925dd 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStoreFactory.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStoreFactory.java @@ -25,7 +25,7 @@ import java.io.File; 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; @@ -81,7 +81,7 @@ public class SvcLogicStoreFactory { retval = new SvcLogicJdbcStore(); } else if ("dblib".equalsIgnoreCase(storeType)) { - retval = new SvcLogicDblibStore(); + retval = new SvcLogicDblibStore(new DBResourceManager(props)); } else { throw new ConfigurationException("unsupported dbtype (" + storeType + ")"); diff --git a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java index 6f303a59..50eb917f 100644 --- a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java +++ b/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java @@ -26,7 +26,6 @@ package org.onap.ccsdk.sli.core.sli; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; - import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; @@ -38,12 +37,12 @@ import java.sql.ResultSet; 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; @@ -155,7 +154,7 @@ public class ITCaseSvcLogicParser { props.load(propStr); - SvcLogicDblibStore dblibStore = new SvcLogicDblibStore(props); + SvcLogicDblibStore dblibStore = new SvcLogicDblibStore(new DBResourceManager(props)); Connection dbConn = dblibStore.getConnection(); diff --git a/sli/provider/pom.xml b/sli/provider/pom.xml index 265831da..95099ed2 100755 --- a/sli/provider/pom.xml +++ b/sli/provider/pom.xml @@ -70,7 +70,14 @@ org.opendaylight.controller sal-binding-api - + + org.opendaylight.mdsal.binding.model.ietf + rfc6991 + + + org.opendaylight.controller + sal-core-api + junit diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/PrintYangToProp.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/PrintYangToProp.java similarity index 99% rename from sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/PrintYangToProp.java rename to sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/PrintYangToProp.java index 5df136fd..a7f383f2 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/PrintYangToProp.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/PrintYangToProp.java @@ -21,7 +21,7 @@ * ============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; diff --git a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java index 9e91b751..49d0a382 100755 --- a/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java +++ b/sli/provider/src/main/java/org/onap/ccsdk/sli/core/sli/provider/SvcLogicServiceImpl.java @@ -64,12 +64,6 @@ public class SvcLogicServiceImpl extends SvcLogicServiceImplBase implements SvcL @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) { @@ -84,11 +78,18 @@ public class SvcLogicServiceImpl extends SvcLogicServiceImplBase implements SvcL 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 diff --git a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/PrintYangToPropTest.java b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/PrintYangToPropTest.java similarity index 98% rename from sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/PrintYangToPropTest.java rename to sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/PrintYangToPropTest.java index 14b4dcb7..50b7926a 100644 --- a/sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/PrintYangToPropTest.java +++ b/sli/provider/src/test/java/org/onap/ccsdk/sli/core/sli/provider/PrintYangToPropTest.java @@ -20,7 +20,7 @@ 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; @@ -28,6 +28,7 @@ import java.util.List; 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; diff --git a/sli/recording/pom.xml b/sli/recording/pom.xml index 76862c49..f37f42ad 100755 --- a/sli/recording/pom.xml +++ b/sli/recording/pom.xml @@ -17,20 +17,6 @@ ccsdk-sli-core :: sli :: ${project.artifactId} SLI Recording is an OSGi bundle that implements recording service for the service logic record node. - - UTF-8 - - - - - - org.onap.ccsdk.sli.core - dblib-provider - ${project.version} - - - - org.onap.ccsdk.sli.core @@ -38,43 +24,25 @@ ${project.version} compile - - org.osgi - org.osgi.core - provided - org.slf4j slf4j-api - - org.slf4j - jcl-over-slf4j - - commons-lang commons-lang compile - - - org.opendaylight.controller - sal-binding-api - - junit junit test - org.mockito mockito-core test - -- 2.16.6