summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicDblibStore.java39
-rw-r--r--sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicJdbcStore.java40
-rw-r--r--sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicLoader.java8
-rw-r--r--sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java13
-rw-r--r--sli/common/src/test/java/org/onap/ccsdk/sli/core/sli/ITCaseSvcLogicParser.java4
5 files changed, 44 insertions, 60 deletions
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 864652b40..3ade88f4f 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
@@ -34,9 +34,7 @@ import java.sql.ResultSet;
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;
@@ -98,9 +96,6 @@ public class SvcLogicDblibStore implements SvcLogicStore {
@Override
public boolean hasGraph(String module, String rpc, String version,
String mode) throws SvcLogicException {
-
-
-
boolean retval = false;
CachedRowSet results = null;
String hasVersionGraphSql = "SELECT count(*) FROM SVC_LOGIC"
@@ -236,8 +231,8 @@ public class SvcLogicDblibStore implements SvcLogicStore {
- String storeGraphSql = "INSERT INTO SVC_LOGIC (module, rpc, version, mode, active, graph)"
- + " VALUES(?, ?, ?, ?, ?, ?)";
+ String storeGraphSql = "INSERT INTO SVC_LOGIC (module, rpc, version, mode, active, graph, md5sum)"
+ + " VALUES(?, ?, ?, ?, ?, ?, ?)";
if (graph == null) {
throw new SvcLogicException("graph cannot be null");
@@ -264,23 +259,22 @@ public class SvcLogicDblibStore implements SvcLogicStore {
}
Connection dbConn = null;
- PreparedStatement storeGraphStmt = null;
+ PreparedStatement storeGraphStmt = null;
try {
- dbConn = dbSvc.getConnection();
- boolean oldAutoCommit = dbConn.getAutoCommit();
+ dbConn = dbSvc.getConnection();
+ boolean oldAutoCommit = dbConn.getAutoCommit();
dbConn.setAutoCommit(false);
- storeGraphStmt = dbConn.prepareStatement(storeGraphSql);
+ storeGraphStmt = dbConn.prepareStatement(storeGraphSql);
storeGraphStmt.setString(1, graph.getModule());
storeGraphStmt.setString(2, graph.getRpc());
storeGraphStmt.setString(3, graph.getVersion());
storeGraphStmt.setString(4, graph.getMode());
storeGraphStmt.setString(5, "N");
storeGraphStmt.setBlob(6, new ByteArrayInputStream(graphBytes));
-
+ storeGraphStmt.setString(7, graph.getMd5sum());
storeGraphStmt.executeUpdate();
dbConn.commit();
-
- dbConn.setAutoCommit(oldAutoCommit);
+ dbConn.setAutoCommit(oldAutoCommit);
} catch (Exception e) {
throw new SvcLogicException("Could not write object to database", e);
} finally {
@@ -306,12 +300,9 @@ public class SvcLogicDblibStore implements SvcLogicStore {
public void delete(String module, String rpc, String version, String mode)
throws SvcLogicException {
-
-
-
String deleteGraphSql = "DELETE FROM SVC_LOGIC WHERE module = ? AND rpc = ? AND version = ? AND mode = ?";
- ArrayList<String> args = new ArrayList<>();
+ ArrayList<String> args = new ArrayList<String>();
args.add(module);
args.add(rpc);
@@ -326,25 +317,19 @@ public class SvcLogicDblibStore implements SvcLogicStore {
}
public void activate(SvcLogicGraph graph) throws SvcLogicException {
-
-
String deactivateSql = "UPDATE SVC_LOGIC SET active = 'N' WHERE module = ? AND rpc = ? AND mode = ?";
-
String activateSql = "UPDATE SVC_LOGIC SET active = 'Y' WHERE module = ? AND rpc = ? AND mode = ? AND version = ?";
- ArrayList<String> args = new ArrayList<>();
+ ArrayList<String> args = new ArrayList<String>();
args.add(graph.getModule());
args.add(graph.getRpc());
args.add(graph.getMode());
try {
-
dbSvc.writeData(deactivateSql, args, null);
-
args.add(graph.getVersion());
dbSvc.writeData(activateSql, args, null);
-
} catch (Exception e) {
throw new SvcLogicException("Could not activate graph", e);
}
@@ -444,10 +429,10 @@ public class SvcLogicDblibStore implements SvcLogicStore {
}
}
+
@Override
public void activate(String module, String rpc, String version, String mode) throws SvcLogicException {
-
String deactivateSql = "UPDATE SVC_LOGIC SET active = 'N' WHERE module = ? AND rpc = ? AND mode = ?";
String activateSql = "UPDATE SVC_LOGIC SET active = 'Y' WHERE module = ? AND rpc = ? AND mode = ? AND version = ?";
@@ -467,7 +452,7 @@ public class SvcLogicDblibStore implements SvcLogicStore {
} catch (Exception e) {
throw new SvcLogicException("Could not activate graph", e);
- }
+ }
}
}
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 0e7d05a6e..5db2a8c91 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
@@ -58,10 +58,6 @@ public class SvcLogicJdbcStore implements SvcLogicStore {
private PreparedStatement deactivateStmt = null;
private PreparedStatement activateStmt = null;
- private PreparedStatement registerNodeStmt = null;
- private PreparedStatement unregisterNodeStmt = null;
- private PreparedStatement validateNodeStmt = null;
-
private void getConnection() throws ConfigurationException {
Properties jdbcProps = new Properties();
@@ -109,7 +105,9 @@ public class SvcLogicJdbcStore implements SvcLogicStore {
} 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,"
+ + "active varchar(1) NOT NULL,graph BLOB,"
+ + "modified_timestamp timestamp DEFAULT NULL,"
+ + "md5sum varchar(128) DEFAULT NULL,"
+ "CONSTRAINT P_SVC_LOGIC PRIMARY KEY(module, rpc, version, mode))";
stmt = dbConn.createStatement();
@@ -199,7 +197,7 @@ public class SvcLogicJdbcStore implements SvcLogicStore {
}
String storeGraphSql = CommonConstants.JDBC_INSERT + dbName
- + ".SVC_LOGIC (module, rpc, version, mode, active, graph) VALUES(?, ?, ?, ?, ?, ?)";
+ + ".SVC_LOGIC (module, rpc, version, mode, active, graph, md5sum) VALUES(?, ?, ?, ?, ?, ?, ?)";
try {
storeGraphStmt = dbConn.prepareStatement(storeGraphSql);
@@ -233,27 +231,6 @@ public class SvcLogicJdbcStore implements SvcLogicStore {
} catch (Exception e) {
throw new ConfigurationException(CommonConstants.JDBC_STATEMENT_ERR + activateSql, e);
}
-
- String registerNodeSql = CommonConstants.JDBC_INSERT + dbName + ".NODE_TYPES (nodetype) VALUES(?)";
- try {
- registerNodeStmt = dbConn.prepareStatement(registerNodeSql);
- } catch (Exception e) {
- throw new ConfigurationException(CommonConstants.JDBC_STATEMENT_ERR + registerNodeSql, e);
- }
-
- String unregisterNodeSql = CommonConstants.JDBC_DELETE + dbName + ".NODE_TYPES WHERE nodetype = ?";
- try {
- unregisterNodeStmt = dbConn.prepareStatement(unregisterNodeSql);
- } catch (Exception e) {
- throw new ConfigurationException(CommonConstants.JDBC_STATEMENT_ERR + unregisterNodeSql, e);
- }
-
- String validateNodeSql = CommonConstants.JDBC_SELECT_COUNT + dbName + ".NODE_TYPES WHERE nodetype = ?";
- try {
- validateNodeStmt = dbConn.prepareStatement(validateNodeSql);
- } catch (Exception e) {
- throw new ConfigurationException(CommonConstants.JDBC_STATEMENT_ERR + validateNodeSql, e);
- }
}
private void initDbResources() throws ConfigurationException {
@@ -489,16 +466,17 @@ public class SvcLogicJdbcStore implements SvcLogicStore {
try {
boolean oldAutoCommit = dbConn.getAutoCommit();
dbConn.setAutoCommit(false);
- storeGraphStmt.setString(1, graph.getModule());
- storeGraphStmt.setString(2, graph.getRpc());
+ storeGraphStmt.setString(1, graph.getModule());
+ storeGraphStmt.setString(2, graph.getRpc());
storeGraphStmt.setString(3, graph.getVersion());
storeGraphStmt.setString(4, graph.getMode());
storeGraphStmt.setString(5, "N");
- storeGraphStmt.setBlob(6, new ByteArrayInputStream(graphBytes));
+ storeGraphStmt.setBlob(6, new ByteArrayInputStream(graphBytes));
+ storeGraphStmt.setString(7, graph.getMd5sum());
storeGraphStmt.executeUpdate();
dbConn.commit();
-
+
dbConn.setAutoCommit(oldAutoCommit);
} catch (Exception e) {
throw new SvcLogicException("Could not write object to database", e);
diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicLoader.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicLoader.java
index 37d7faae0..d50c371c0 100644
--- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicLoader.java
+++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicLoader.java
@@ -164,5 +164,13 @@ public class SvcLogicLoader {
}
return raw;
}
+
+ public void bulkActivate() {
+ Path activationFile = Paths.get(directoryRoot);
+ List<Path> pathList = new ArrayList<Path>(1);
+ pathList.add(activationFile);
+ List<ActivationEntry> activationEntries = processActivationFiles(pathList);
+ activateGraphs(activationEntries);
+ }
}
diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java
index 2804f6205..5cb7ac5e2 100644
--- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java
+++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicParser.java
@@ -417,6 +417,17 @@ public class SvcLogicParser {
} else {
SvcLogicParser.usage();
}
+ } else if ("bulkActivate".equalsIgnoreCase(argv[0])) {
+ if (argv.length == 3) {
+ SvcLogicLoader loader = new SvcLogicLoader(argv[1], argv[2]);
+ try {
+ loader.bulkActivate();
+ } catch (Exception e) {
+ LOGGER.error(e.getMessage(), e);
+ }
+ } else {
+ SvcLogicParser.usage();
+ }
}
System.exit(0);
@@ -557,7 +568,7 @@ public class SvcLogicParser {
System.err.println(" OR SvcLogicParser activate <module> <rpc> <version> <mode>");
System.err.println(" OR SvcLogicParser validate <file path to graph> <prop-file>");
System.err.println(" OR SvcLogicParser install <service-logic directory path> <prop-file>");
-
+ System.err.println(" OR SvcLogicParser bulkActivate <path to activation file> <prop-file>");
System.exit(1);
}
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 6ee18e922..f5cbf50b0 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
@@ -165,7 +165,9 @@ public class ITCaseSvcLogicParser {
} 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,"
+ + "active varchar(1) NOT NULL,graph BLOB,"
+ + "modified_timestamp timestamp DEFAULT NULL,"
+ + "md5sum varchar(128) DEFAULT NULL,"
+ "CONSTRAINT P_SVC_LOGIC PRIMARY KEY(module, rpc, version, mode))";
stmt = dbConn.createStatement();