summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xdblib/features/src/main/resources/features.xml4
-rwxr-xr-xdblib/provider/pom.xml6
-rwxr-xr-xfilters/provider/pom.xml8
-rwxr-xr-xsli/common/pom.xml6
-rw-r--r--sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/CommonConstants.java13
-rw-r--r--sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicAtom.java92
-rw-r--r--sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicContext.java6
-rw-r--r--sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java296
-rw-r--r--sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicStoreFactory.java14
-rw-r--r--sli/features/src/main/resources/features.xml2
-rwxr-xr-xsliPluginUtils/provider/pom.xml2
11 files changed, 198 insertions, 251 deletions
diff --git a/dblib/features/src/main/resources/features.xml b/dblib/features/src/main/resources/features.xml
index 5f339cba0..36d794139 100755
--- a/dblib/features/src/main/resources/features.xml
+++ b/dblib/features/src/main/resources/features.xml
@@ -10,9 +10,9 @@
<feature name='sdnc-dblib' description="sdnc-dblib" version='${project.version}'>
<!-- Most applications will have a dependency on the ODL MD-SAL Broker -->
<feature version="${odl.mdsal.version}">odl-mdsal-broker</feature>
- <bundle>wrap:mvn:org.apache.tomcat/tomcat-jdbc/${tomcat-jdbc.version}/$DynamicImport-Package=com.mysql.*&amp;overwrite=merge</bundle>
+ <bundle>wrap:mvn:org.apache.tomcat/tomcat-jdbc/${tomcat-jdbc.version}/$DynamicImport-Package=org.mariadb.*&amp;overwrite=merge</bundle>
<bundle>mvn:org.onap.ccsdk.sli.core/dblib-provider/${project.version}</bundle>
- <bundle>mvn:mysql/mysql-connector-java/${mysql.connector.version}</bundle>
+ <bundle>mvn:org/mariadb/jdbc/mariadb-java-client/${mariadb.connector.version}</bundle>
</feature>
</features>
diff --git a/dblib/provider/pom.xml b/dblib/provider/pom.xml
index 07fc61ab1..765f73798 100755
--- a/dblib/provider/pom.xml
+++ b/dblib/provider/pom.xml
@@ -47,6 +47,11 @@
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.connector.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.mariadb.jdbc</groupId>
+ <artifactId>mariadb-java-client</artifactId>
+ <version>${mariadb.connector.version}</version>
+ </dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jdbc</artifactId>
@@ -76,6 +81,7 @@
<instructions>
<Bundle-SymbolicName>org.onap.ccsdk.sli.core.dblib</Bundle-SymbolicName>
<Export-Package>org.onap.ccsdk.sli.core.dblib;version=${project.version}</Export-Package>
+ <Import-Package>*,org.mariadb.jdbc</Import-Package>
<Embed-Transitive>true</Embed-Transitive>
</instructions>
</configuration>
diff --git a/filters/provider/pom.xml b/filters/provider/pom.xml
index a59071937..e6d91c903 100755
--- a/filters/provider/pom.xml
+++ b/filters/provider/pom.xml
@@ -54,13 +54,7 @@
<artifactId>sli-common</artifactId>
<version>${project.version}</version>
</dependency>
-<!--
- <dependency>
- <groupId>mysql</groupId>
- <artifactId>mysql-connector-java</artifactId>
- <version>${mysql.connector.version}</version>
- </dependency>
--->
+
</dependencies>
<build>
diff --git a/sli/common/pom.xml b/sli/common/pom.xml
index c367dd779..e6bac8ada 100755
--- a/sli/common/pom.xml
+++ b/sli/common/pom.xml
@@ -84,9 +84,9 @@
<version>${equinox.osgi.version}</version>
</dependency>
<dependency>
- <groupId>mysql</groupId>
- <artifactId>mysql-connector-java</artifactId>
- <version>${mysql.connector.version}</version>
+ <groupId>org.mariadb.jdbc</groupId>
+ <artifactId>mariadb-java-client</artifactId>
+ <version>${mariadb.connector.version}</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/CommonConstants.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/CommonConstants.java
index d30b2b626..b1a7320d7 100644
--- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/CommonConstants.java
+++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/CommonConstants.java
@@ -23,5 +23,16 @@ package org.onap.ccsdk.sli.core.sli;
public interface CommonConstants {
- public static final String SERVICE_LOGIC_STATUS = "SvcLogic.status";
+ String SERVICE_LOGIC_STATUS = "SvcLogic.status";
+ String JDBC_CONN_ERR = "no jdbc connection";
+ String JDBC_STATEMENT_ERR = "could not prepare statement ";
+ String SVCLOGIC_TABLE = ".SVC_LOGIC";
+ String JDBC_SELECT_COUNT = "SELECT count(*) FROM ";
+ String RESULTSET_CLOSE_ERR = "ResultSet close error: ";
+ String JDBC_SELECT_GRAPGH = "SELECT graph FROM ";
+ String JDBC_INSERT = "INSERT INTO ";
+ String JDBC_DELETE = "DELETE FROM ";
+ String JDBC_UPDATE = "UPDATE ";
+ String JDBC_GRAPH_QUERY = " WHERE module = ? AND rpc = ? AND mode = ? AND version = ?";
+ String JDBC_ACTIVE_GRAPH_QUERY = " WHERE module = ? AND rpc = ? AND mode = ? AND active = 'Y'";
}
diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicAtom.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicAtom.java
index 5e19a52c6..b9ad19e25 100644
--- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicAtom.java
+++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicAtom.java
@@ -8,9 +8,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -22,7 +22,7 @@
package org.onap.ccsdk.sli.core.sli;
public class SvcLogicAtom extends SvcLogicExpression {
-
+
public enum AtomType {
NUMBER,
STRING,
@@ -30,7 +30,7 @@ public class SvcLogicAtom extends SvcLogicExpression {
CONTEXT_VAR
}
-
+
private AtomType atomType;
private String atom;
@@ -39,9 +39,9 @@ public class SvcLogicAtom extends SvcLogicExpression {
{
this.atomType = AtomType.valueOf(atomType);
this.atom = atom;
-
+
}
-
+
public SvcLogicAtom(String atom)
{
@@ -73,9 +73,9 @@ public class SvcLogicAtom extends SvcLogicExpression {
{
this.atomType = AtomType.IDENTIFIER;
this.atom = atom;
-
+
}
-
+
}
}
}
@@ -83,7 +83,7 @@ public class SvcLogicAtom extends SvcLogicExpression {
public AtomType getAtomType() {
return atomType;
}
-
+
public void setAtomType(String newType)
{
atomType = AtomType.valueOf(newType);
@@ -92,9 +92,9 @@ public class SvcLogicAtom extends SvcLogicExpression {
public String getAtom() {
return atom;
}
-
-
-
+
+
+
public void setAtomType(AtomType atomType) {
this.atomType = atomType;
}
@@ -110,27 +110,27 @@ public class SvcLogicAtom extends SvcLogicExpression {
StringBuffer sbuff = new StringBuffer();
switch(getAtomType())
{
- case CONTEXT_VAR:
- sbuff.append("$");
- case IDENTIFIER:
- boolean needDot = false;
- for (SvcLogicExpression term: this.getOperands())
- {
- if (needDot)
+ case CONTEXT_VAR:
+ sbuff.append("$");
+ case IDENTIFIER:
+ boolean needDot = false;
+ for (SvcLogicExpression term: this.getOperands())
{
- sbuff.append(".");
+ if (needDot)
+ {
+ sbuff.append(".");
+ }
+ sbuff.append(term.toString());
+ needDot = true;
}
- sbuff.append(term.toString());
- needDot = true;
- }
- return(sbuff.toString());
- case STRING:
- case NUMBER:
- default:
- return(atom);
+ return sbuff.toString();
+ case STRING:
+ case NUMBER:
+ default:
+ return atom;
}
}
-
+
public String asParsedExpr()
{
// simplify debugging output for NUMBER type
@@ -139,32 +139,32 @@ public class SvcLogicAtom extends SvcLogicExpression {
}
StringBuffer sbuff = new StringBuffer();
-
+
sbuff.append("(atom");
sbuff.append("<");
sbuff.append(atomType.toString());
sbuff.append(">");
-
+
switch(atomType)
{
- case IDENTIFIER:
- case CONTEXT_VAR:
- for (SvcLogicExpression term : getOperands())
- {
+ case IDENTIFIER:
+ case CONTEXT_VAR:
+ for (SvcLogicExpression term : getOperands())
+ {
+ sbuff.append(" ");
+ sbuff.append(term.asParsedExpr());
+
+ }
+ break;
+ default:
sbuff.append(" ");
- sbuff.append(term.asParsedExpr());
-
- }
- break;
- default:
- sbuff.append(" ");
- sbuff.append(atom);
+ sbuff.append(atom);
}
-
+
sbuff.append(")");
- return(sbuff.toString());
+ return sbuff.toString();
}
-
-
+
+
}
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 232774396..aca904d14 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
@@ -212,7 +212,7 @@ public class SvcLogicContext {
if (ctxVarName.indexOf('[') == -1) {
// Ctx variable contains no arrays
- return (this.getAttribute(ctxVarName));
+ return getAttribute(ctxVarName);
}
// Resolve any array references
@@ -225,7 +225,7 @@ public class SvcLogicContext {
if (endBracketLoc == -1) {
// Missing end bracket ... give up parsing
LOG.warn("Variable reference {} seems to be missing a ']'", ctxVarName);
- return (this.getAttribute(ctxVarName));
+ return getAttribute(ctxVarName);
}
String idxVarName = ctxVarParts[i].substring(1, endBracketLoc);
@@ -242,7 +242,7 @@ public class SvcLogicContext {
}
}
- return (this.getAttribute(sbuff.toString()));
+ return getAttribute(sbuff.toString());
}
}
diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java
index b4b77660d..71926e415 100644
--- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java
+++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java
@@ -8,9 +8,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,7 +23,6 @@ package org.onap.ccsdk.sli.core.sli;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
-import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.sql.Blob;
@@ -42,8 +41,7 @@ import org.slf4j.LoggerFactory;
public class SvcLogicJdbcStore implements SvcLogicStore {
- private static final Logger LOG = LoggerFactory
- .getLogger(SvcLogicJdbcStore.class);
+ private static final Logger LOG = LoggerFactory.getLogger(SvcLogicJdbcStore.class);
private String dbUrl = null;
private String dbName = null;
@@ -78,19 +76,16 @@ public class SvcLogicJdbcStore implements SvcLogicStore {
Driver dvr = new com.mysql.jdbc.Driver();
if (dvr.acceptsURL(dbUrl))
{
- LOG.debug("Driver com.mysql.jdbc.Driver accepts "+dbUrl);
+ LOG.debug("Driver com.mysql.jdbc.Driver accepts {}", dbUrl);
}
else
{
- LOG.warn("Driver com.mysql.jdbc.Driver does not accept "+dbUrl);
+ LOG.warn("Driver com.mysql.jdbc.Driver does not accept {}", dbUrl);
}
} catch (SQLException e1) {
LOG.error("Caught exception trying to load com.mysql.jdbc.Driver", e1);
-
-
}
-
try
{
this.dbConn = DriverManager.getConnection(dbUrl, jdbcProps);
@@ -105,9 +100,7 @@ public class SvcLogicJdbcStore implements SvcLogicStore {
private void createTable() throws ConfigurationException
{
-
- DatabaseMetaData dbm = null;
-
+ DatabaseMetaData dbm;
try {
dbm = dbConn.getMetaData();
@@ -117,108 +110,84 @@ public class SvcLogicJdbcStore implements SvcLogicStore {
}
// See if table SVC_LOGIC exists. If not, create it.
+ Statement stmt = null;
try
{
-
ResultSet tables = dbm.getTables(null, null, "SVC_LOGIC", null);
if (tables.next()) {
- // Table exists
+ LOG.debug("SVC_LOGIC table already exists");
}
else {
-
- String crTableCmd = "CREATE TABLE "+dbName+".SVC_LOGIC ("
- + "module varchar(80) NOT NULL,"
- + "rpc varchar(80) NOT NULL,"
- + "version varchar(40) NOT NULL,"
- + "mode varchar(5) NOT NULL,"
- + "active varchar(1) NOT NULL,"
- + "graph BLOB,"
- + "CONSTRAINT P_SVC_LOGIC PRIMARY KEY(module, rpc, version, mode))";
-
- Statement stmt = null;
- ConfigurationException myExc = null;
- try
- {
- stmt = dbConn.createStatement();
- stmt.executeUpdate(crTableCmd);
- }
- catch (SQLException e1)
- {
- myExc = new ConfigurationException("cannot create SVC_LOGIC table", e1);
- }
- finally
- {
- if (stmt != null)
- {
- stmt.close();
- }
- }
-
- if (myExc != null)
- {
- throw myExc;
- }
+ String crTableCmd = "CREATE TABLE "+dbName+".SVC_LOGIC ("
+ + "module varchar(80) NOT NULL,"
+ + "rpc varchar(80) NOT NULL,"
+ + "version varchar(40) NOT NULL,"
+ + "mode varchar(5) NOT NULL,"
+ + "active varchar(1) NOT NULL,"
+ + "graph BLOB,"
+ + "CONSTRAINT P_SVC_LOGIC PRIMARY KEY(module, rpc, version, mode))";
+
+ stmt = dbConn.createStatement();
+ stmt.executeUpdate(crTableCmd);
}
}
catch (Exception e)
{
throw new ConfigurationException("could not create SVC_LOGIC table", e);
}
+ finally
+ {
+ if (stmt != null) {
+ try {
+ stmt.close();
+ } catch (SQLException e) {
+ LOG.error("Statement close error ", e);
+ }
+ }
+ }
// See if NODE_TYPES table exists and, if not, create it
-
+ stmt = null;
try
{
-
ResultSet tables = dbm.getTables(null, null, "NODE_TYPES", null);
if (tables.next()) {
- // Table exists
+ LOG.debug("NODE_TYPES table already exists");
}
else {
+ String crTableCmd = "CREATE TABLE "+dbName+".NODE_TYPES ("
+ + "nodetype varchar(80) NOT NULL,"
+ + "CONSTRAINT P_NODE_TYPES PRIMARY KEY(nodetype))";
- String crTableCmd = "CREATE TABLE "+dbName+".NODE_TYPES ("
- + "nodetype varchar(80) NOT NULL,"
- + "CONSTRAINT P_NODE_TYPES PRIMARY KEY(nodetype))";
+ stmt = dbConn.createStatement();
- Statement stmt = null;
- ConfigurationException myExc = null;
- try
- {
- stmt = dbConn.createStatement();
- stmt.executeUpdate(crTableCmd);
- }
- catch (SQLException e1)
- {
- myExc = new ConfigurationException("cannot create SVC_LOGIC table", e1);
- }
- finally
- {
- if (stmt != null)
- {
- stmt.close();
- }
- }
-
- if (myExc != null)
- {
- throw myExc;
- }
+ stmt.executeUpdate(crTableCmd);
}
}
catch (Exception e)
{
throw new ConfigurationException("could not create SVC_LOGIC table", e);
}
+ finally
+ {
+ if (stmt != null) {
+ try {
+ stmt.close();
+ } catch (SQLException e) {
+ LOG.error("Statement close error ", e);
+ }
+ }
+ }
}
private void prepStatements() throws ConfigurationException
{
// Prepare statements
- String hasVersionGraphSql = "SELECT count(*) FROM "+dbName+".SVC_LOGIC"
- + " WHERE module = ? AND rpc = ? AND mode = ? AND version = ?";
+ String hasVersionGraphSql = CommonConstants.JDBC_SELECT_COUNT + dbName + CommonConstants.SVCLOGIC_TABLE
+ + CommonConstants.JDBC_GRAPH_QUERY;
try
{
@@ -226,12 +195,12 @@ public class SvcLogicJdbcStore implements SvcLogicStore {
}
catch (Exception e)
{
- throw new ConfigurationException("could not prepare statement "+hasVersionGraphSql, e);
+ throw new ConfigurationException(CommonConstants.JDBC_STATEMENT_ERR + hasVersionGraphSql, e);
}
- String hasActiveGraphSql = "SELECT count(*) FROM "+dbName+".SVC_LOGIC"
- + " WHERE module = ? AND rpc = ? AND mode = ? AND active = 'Y'";
+ String hasActiveGraphSql = CommonConstants.JDBC_SELECT_COUNT + dbName + CommonConstants.SVCLOGIC_TABLE
+ + CommonConstants.JDBC_ACTIVE_GRAPH_QUERY;
try
{
@@ -239,12 +208,12 @@ public class SvcLogicJdbcStore implements SvcLogicStore {
}
catch (Exception e)
{
- throw new ConfigurationException("could not prepare statement "+hasVersionGraphSql, e);
+ throw new ConfigurationException(CommonConstants.JDBC_STATEMENT_ERR + hasVersionGraphSql, e);
}
- String fetchVersionGraphSql = "SELECT graph FROM "+dbName+".SVC_LOGIC"
- + " WHERE module = ? AND rpc = ? AND mode = ? AND version = ?";
+ String fetchVersionGraphSql = CommonConstants.JDBC_SELECT_GRAPGH + dbName+CommonConstants.SVCLOGIC_TABLE
+ + CommonConstants.JDBC_GRAPH_QUERY;
try
{
@@ -252,12 +221,12 @@ public class SvcLogicJdbcStore implements SvcLogicStore {
}
catch (Exception e)
{
- throw new ConfigurationException("could not prepare statement "+fetchVersionGraphSql, e);
+ throw new ConfigurationException(CommonConstants.JDBC_STATEMENT_ERR + fetchVersionGraphSql, e);
}
- String fetchActiveGraphSql = "SELECT graph FROM "+dbName+".SVC_LOGIC"
- + " WHERE module = ? AND rpc = ? AND mode = ? AND active = 'Y'";
+ String fetchActiveGraphSql = CommonConstants.JDBC_SELECT_GRAPGH + dbName + CommonConstants.SVCLOGIC_TABLE
+ + CommonConstants.JDBC_ACTIVE_GRAPH_QUERY;
try
{
@@ -265,12 +234,12 @@ public class SvcLogicJdbcStore implements SvcLogicStore {
}
catch (Exception e)
{
- throw new ConfigurationException("could not prepare statement "+fetchVersionGraphSql, e);
+ throw new ConfigurationException(CommonConstants.JDBC_STATEMENT_ERR + fetchVersionGraphSql, e);
}
- String storeGraphSql = "INSERT INTO "+dbName+".SVC_LOGIC (module, rpc, version, mode, active, graph)"
- + " VALUES(?, ?, ?, ?, ?, ?)";
+ String storeGraphSql = CommonConstants.JDBC_INSERT+dbName
+ + ".SVC_LOGIC (module, rpc, version, mode, active, graph) VALUES(?, ?, ?, ?, ?, ?)";
try
{
@@ -278,10 +247,11 @@ public class SvcLogicJdbcStore implements SvcLogicStore {
}
catch (Exception e)
{
- throw new ConfigurationException("could not prepare statement "+storeGraphSql, e);
+ throw new ConfigurationException(CommonConstants.JDBC_STATEMENT_ERR + storeGraphSql, e);
}
- String deleteGraphSql = "DELETE FROM "+dbName+".SVC_LOGIC WHERE module = ? AND rpc = ? AND version = ? AND mode = ?";
+ String deleteGraphSql = CommonConstants.JDBC_DELETE+dbName
+ + ".SVC_LOGIC WHERE module = ? AND rpc = ? AND version = ? AND mode = ?";
try
{
@@ -289,10 +259,11 @@ public class SvcLogicJdbcStore implements SvcLogicStore {
}
catch (Exception e)
{
- throw new ConfigurationException("could not prepare statement "+deleteGraphSql, e);
+ throw new ConfigurationException(CommonConstants.JDBC_STATEMENT_ERR + deleteGraphSql, e);
}
- String deactivateSql = "UPDATE "+dbName+".SVC_LOGIC SET active = 'N' WHERE module = ? AND rpc = ? AND mode = ?";
+ String deactivateSql = CommonConstants.JDBC_UPDATE + dbName
+ +".SVC_LOGIC SET active = 'N' WHERE module = ? AND rpc = ? AND mode = ?";
try
{
@@ -300,10 +271,11 @@ public class SvcLogicJdbcStore implements SvcLogicStore {
}
catch (Exception e)
{
- throw new ConfigurationException("could not prepare statement "+deactivateSql, e);
+ throw new ConfigurationException(CommonConstants.JDBC_STATEMENT_ERR + deactivateSql, e);
}
- String activateSql = "UPDATE "+dbName+".SVC_LOGIC SET active = 'Y' WHERE module = ? AND rpc = ? AND version = ? AND mode = ?";
+ String activateSql = CommonConstants.JDBC_UPDATE + dbName
+ +".SVC_LOGIC SET active = 'Y' WHERE module = ? AND rpc = ? AND version = ? AND mode = ?";
try
{
@@ -311,37 +283,37 @@ public class SvcLogicJdbcStore implements SvcLogicStore {
}
catch (Exception e)
{
- throw new ConfigurationException("could not prepare statement "+activateSql, e);
+ throw new ConfigurationException(CommonConstants.JDBC_STATEMENT_ERR + activateSql, e);
}
- String registerNodeSql = "INSERT INTO "+dbName+".NODE_TYPES (nodetype) VALUES(?)";
+ String registerNodeSql = CommonConstants.JDBC_INSERT + dbName + ".NODE_TYPES (nodetype) VALUES(?)";
try
{
registerNodeStmt = dbConn.prepareStatement(registerNodeSql);
}
catch (Exception e)
{
- throw new ConfigurationException("could not prepare statement "+registerNodeSql, e);
+ throw new ConfigurationException(CommonConstants.JDBC_STATEMENT_ERR + registerNodeSql, e);
}
- String unregisterNodeSql = "DELETE FROM "+dbName+".NODE_TYPES WHERE nodetype = ?";
+ String unregisterNodeSql = CommonConstants.JDBC_DELETE + dbName + ".NODE_TYPES WHERE nodetype = ?";
try
{
unregisterNodeStmt = dbConn.prepareStatement(unregisterNodeSql);
}
catch (Exception e)
{
- throw new ConfigurationException("could not prepare statement "+unregisterNodeSql, e);
+ throw new ConfigurationException(CommonConstants.JDBC_STATEMENT_ERR + unregisterNodeSql, e);
}
- String validateNodeSql = "SELECT count(*) FROM "+dbName+".NODE_TYPES WHERE nodetype = ?";
+ String validateNodeSql = CommonConstants.JDBC_SELECT_COUNT + dbName + ".NODE_TYPES WHERE nodetype = ?";
try
{
validateNodeStmt = dbConn.prepareStatement(validateNodeSql);
}
catch (Exception e)
{
- throw new ConfigurationException("could not prepare statement "+validateNodeSql, e);
+ throw new ConfigurationException(CommonConstants.JDBC_STATEMENT_ERR + validateNodeSql, e);
}
}
@@ -365,6 +337,7 @@ public class SvcLogicJdbcStore implements SvcLogicStore {
}
+ @Override
public void init(Properties props) throws ConfigurationException {
@@ -413,14 +386,15 @@ public class SvcLogicJdbcStore implements SvcLogicStore {
}
}
catch (SQLException e)
- {}
+ {
+ LOG.error("Not a valid db connection: ", e);
+ }
- return(isValid);
+ return isValid;
}
-public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException {
-
-
+ @Override
+ public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException {
if (!isDbConnValid())
{
@@ -430,16 +404,14 @@ public boolean hasGraph(String module, String rpc, String version, String mode)
if (!isDbConnValid())
{
- throw new ConfigurationException("no jdbc connection");
+ throw new ConfigurationException(CommonConstants.JDBC_CONN_ERR);
}
}
-
-
boolean retval = false;
ResultSet results = null;
- PreparedStatement hasGraphStmt = null;
+ PreparedStatement hasGraphStmt;
if (version == null)
{
hasGraphStmt = hasActiveGraphStmt;
@@ -449,8 +421,6 @@ public boolean hasGraph(String module, String rpc, String version, String mode)
hasGraphStmt = hasVersionGraphStmt;
}
-
-
try
{
hasGraphStmt.setString(1, module);
@@ -489,26 +459,24 @@ public boolean hasGraph(String module, String rpc, String version, String mode)
{
try
{
-
results.close();
}
catch (SQLException x)
- {}
+ {
+ LOG.error(CommonConstants.RESULTSET_CLOSE_ERR, x);
+ }
}
}
-
- return(retval);
-
+ return retval;
}
+ @Override
public SvcLogicGraph fetch(String module, String rpc, String version, String mode) throws SvcLogicException {
-
-
if (!isDbConnValid())
{
@@ -517,16 +485,14 @@ public boolean hasGraph(String module, String rpc, String version, String mode)
if (!isDbConnValid())
{
- throw new ConfigurationException("no jdbc connection");
+ throw new ConfigurationException(CommonConstants.JDBC_CONN_ERR);
}
}
-
-
SvcLogicGraph retval = null;
ResultSet results = null;
- PreparedStatement fetchGraphStmt = null;
+ PreparedStatement fetchGraphStmt;
if (version == null)
{
fetchGraphStmt = fetchActiveGraphStmt;
@@ -570,12 +536,8 @@ public boolean hasGraph(String module, String rpc, String version, String mode)
throw new ConfigurationException("invalid type for graph ("+graphObj.getClass().getName());
}
-
- }
- else
- {
- return(null);
}
+
}
catch (Exception e)
{
@@ -590,15 +552,14 @@ public boolean hasGraph(String module, String rpc, String version, String mode)
results.close();
}
catch (SQLException x)
- {}
+ {
+ LOG.error(CommonConstants.RESULTSET_CLOSE_ERR, x);
+ }
}
}
-
- return(retval);
-
-
+ return retval;
}
public void store(SvcLogicGraph graph) throws SvcLogicException {
@@ -612,7 +573,7 @@ public boolean hasGraph(String module, String rpc, String version, String mode)
if (!isDbConnValid())
{
- throw new ConfigurationException("no jdbc connection");
+ throw new ConfigurationException(CommonConstants.JDBC_CONN_ERR);
}
}
@@ -621,15 +582,12 @@ public boolean hasGraph(String module, String rpc, String version, String mode)
throw new SvcLogicException("graph cannot be null");
}
- byte[] graphBytes = null;
-
- ByteArrayOutputStream byteStr = null;
- ObjectOutputStream goutStr = null;
+ byte[] graphBytes;
- try
+ try (ByteArrayOutputStream byteStr = new ByteArrayOutputStream();
+ ObjectOutputStream goutStr = new ObjectOutputStream(byteStr))
{
- byteStr = new ByteArrayOutputStream();
- goutStr = new ObjectOutputStream(byteStr);
+
goutStr.writeObject(graph);
graphBytes = byteStr.toByteArray();
@@ -639,28 +597,6 @@ public boolean hasGraph(String module, String rpc, String version, String mode)
{
throw new SvcLogicException("could not serialize graph", e);
}
- finally
- {
-
- if (goutStr != null)
- {
- try {
- goutStr.close();
- } catch (IOException e) {
-
- }
- }
-
- if (byteStr != null)
- {
- try {
- byteStr.close();
- } catch (IOException e) {
-
- }
- }
- }
-
// If object already stored in database, delete it
if (hasGraph(graph.getModule(), graph.getRpc(), graph.getVersion(), graph.getMode()))
@@ -690,6 +626,7 @@ public boolean hasGraph(String module, String rpc, String version, String mode)
}
}
+ @Override
public void delete(String module, String rpc, String version, String mode) throws SvcLogicException
{
if (!isDbConnValid())
@@ -700,7 +637,7 @@ public boolean hasGraph(String module, String rpc, String version, String mode)
if (!isDbConnValid())
{
- throw new ConfigurationException("no jdbc connection");
+ throw new ConfigurationException(CommonConstants.JDBC_CONN_ERR);
}
}
@@ -724,6 +661,7 @@ public boolean hasGraph(String module, String rpc, String version, String mode)
}
}
+ @Override
public void activate(SvcLogicGraph graph) throws SvcLogicException
{
try
@@ -772,7 +710,7 @@ public boolean hasGraph(String module, String rpc, String version, String mode)
if (!isDbConnValid())
{
- throw new ConfigurationException("no jdbc connection");
+ throw new ConfigurationException(CommonConstants.JDBC_CONN_ERR);
}
}
@@ -808,7 +746,7 @@ public boolean hasGraph(String module, String rpc, String version, String mode)
if (!isDbConnValid())
{
- throw new ConfigurationException("no jdbc connection");
+ throw new ConfigurationException(CommonConstants.JDBC_CONN_ERR);
}
}
@@ -841,7 +779,7 @@ public boolean hasGraph(String module, String rpc, String version, String mode)
if (!isDbConnValid())
{
- throw new ConfigurationException("no jdbc connection");
+ throw new ConfigurationException(CommonConstants.JDBC_CONN_ERR);
}
}
@@ -856,16 +794,13 @@ public boolean hasGraph(String module, String rpc, String version, String mode)
dbConn.commit();
dbConn.setAutoCommit(oldAutoCommit);
- if (results != null)
+ if (results.next())
{
- if (results.next())
- {
- int cnt = results.getInt(1);
+ int cnt = results.getInt(1);
- if (cnt > 0)
- {
- isValid = true;
- }
+ if (cnt > 0)
+ {
+ isValid = true;
}
}
@@ -883,7 +818,9 @@ public boolean hasGraph(String module, String rpc, String version, String mode)
results.close();
}
catch (SQLException x)
- {}
+ {
+ LOG.error(CommonConstants.RESULTSET_CLOSE_ERR, x);
+ }
}
}
@@ -891,5 +828,4 @@ public boolean hasGraph(String module, String rpc, String version, String mode)
return(isValid);
}
-
}
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 11b5fdea4..532ad31b4 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
@@ -8,9 +8,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -43,7 +43,7 @@ public class SvcLogicStoreFactory {
}
try {
- return (getSvcLogicStore(new FileInputStream(propFile)));
+ return getSvcLogicStore(new FileInputStream(propFile));
} catch (Exception e) {
throw new ConfigurationException(
"Could load service store from properties file " + propfile,
@@ -62,7 +62,7 @@ public class SvcLogicStoreFactory {
throw new ConfigurationException("Could not get load properties from input stream", e);
}
- return(getSvcLogicStore(props));
+ return getSvcLogicStore(props);
}
public static SvcLogicStore getSvcLogicStore(Properties props)
@@ -74,8 +74,8 @@ public class SvcLogicStoreFactory {
}
- SvcLogicStore retval = null;
- LOG.debug(String.format("Using org.onap.ccsdk.sli.dbtype=%s", storeType));
+ SvcLogicStore retval;
+ LOG.debug("Using org.onap.ccsdk.sli.dbtype={}", storeType);
if ("jdbc".equalsIgnoreCase(storeType)) {
retval = new SvcLogicJdbcStore();
@@ -90,7 +90,7 @@ public class SvcLogicStoreFactory {
retval.init(props);
- return (retval);
+ return retval;
}
}
diff --git a/sli/features/src/main/resources/features.xml b/sli/features/src/main/resources/features.xml
index fef113317..692d9ff0a 100644
--- a/sli/features/src/main/resources/features.xml
+++ b/sli/features/src/main/resources/features.xml
@@ -33,7 +33,7 @@
<bundle>mvn:org.onap.ccsdk.sli.core/sli-provider/${project.version}</bundle>
<bundle>mvn:org.onap.ccsdk.sli.core/sli-recording/${project.version}</bundle>
<feature>sdnc-dblib</feature>
- <bundle>mvn:mysql/mysql-connector-java/${mysql.connector.version}</bundle>
+ <bundle>mvn:org/mariadb/jdbc/mariadb-java-client/${mariadb.connector.version}</bundle>
</feature>
</features>
diff --git a/sliPluginUtils/provider/pom.xml b/sliPluginUtils/provider/pom.xml
index ad950c0c8..d105036b3 100755
--- a/sliPluginUtils/provider/pom.xml
+++ b/sliPluginUtils/provider/pom.xml
@@ -72,7 +72,7 @@
<Bundle-SymbolicName>org.onap.ccsdk.sli.core.slipluginutils</Bundle-SymbolicName>
<Export-Package>org.onap.ccsdk.sli.core.slipluginutils</Export-Package>
<Import-Package>org.onap.ccsdk.sli.core.*,org.osgi.framework.*,org.slf4j.*,java.net.*</Import-Package>
- <Embed-Dependency>*;scope=compile|runtime;artifactId=!sli-common|org.eclipse.osgi|mysql-connector-java|slf4j-api|jcl-over-slf4j</Embed-Dependency>
+ <Embed-Dependency>*;scope=compile|runtime;artifactId=!sli-common|org.eclipse.osgi|mariadb-java-client|slf4j-api|jcl-over-slf4j</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
</instructions>
</configuration>