summaryrefslogtreecommitdiffstats
path: root/appc-directed-graph
diff options
context:
space:
mode:
authorSkip Wonnell <skip@att.com>2017-12-17 16:13:56 -0600
committerPatrick Brady <pb071s@att.com>2017-12-19 16:42:22 +0000
commit9c44fb1cb83f5368fba40438a7b1fa1a45e27b58 (patch)
treef8eefa85bf2cd496ff041c9b0a7c6213430bcdd7 /appc-directed-graph
parent320159500963f61fbfe45cfc719fe1581d10a984 (diff)
Move dg-loader files to org.onap package
Issue-ID: APPC-13 Change-Id: I5bab561f243f31bca633882b9291b147e24bea9e Signed-off-by: Skip Wonnell <skip@att.com>
Diffstat (limited to 'appc-directed-graph')
-rw-r--r--appc-directed-graph/appc-dgraph/provider/.gitignore1
-rw-r--r--appc-directed-graph/appc-dgraph/provider/pom.xml2
-rw-r--r--appc-directed-graph/dg-loader/provider/.gitignore1
-rw-r--r--appc-directed-graph/dg-loader/provider/src/main/java/org/onap/sdnc/dg/loader/DGLoaderActivator.java21
-rw-r--r--appc-directed-graph/dg-loader/provider/src/main/java/org/onap/sdnc/dg/loader/DGXMLActivate.java61
-rw-r--r--appc-directed-graph/dg-loader/provider/src/main/java/org/onap/sdnc/dg/loader/DGXMLGenerator.java63
-rw-r--r--appc-directed-graph/dg-loader/provider/src/main/java/org/onap/sdnc/dg/loader/DGXMLLoad.java47
-rw-r--r--appc-directed-graph/dg-loader/provider/src/main/java/org/onap/sdnc/dg/loader/DGXMLLoadNActivate.java94
-rw-r--r--appc-directed-graph/dg-loader/provider/src/main/resources/scripts/dg_load_activate.sh6
-rw-r--r--appc-directed-graph/dg-loader/provider/src/test/java/org/onap/sdnc/dg/loader/DGLoaderTest.java98
-rw-r--r--appc-directed-graph/dg-loader/provider/src/test/java/org/onap/sdnc/dg/loader/MockDGXMLActivate.java5
-rw-r--r--appc-directed-graph/dg-loader/provider/src/test/java/org/onap/sdnc/dg/loader/MockDGXMLLoad.java8
-rw-r--r--appc-directed-graph/dg-loader/provider/src/test/java/org/onap/sdnc/dg/loader/MockDGXMLLoadNActivate.java7
-rw-r--r--appc-directed-graph/dg-loader/provider/src/test/java/org/onap/sdnc/dg/loader/MockSvcLogicDblibStore.java36
-rw-r--r--appc-directed-graph/dg-loader/provider/src/test/java/org/onap/sdnc/dg/loader/MockSvcLogicFactory.java7
15 files changed, 237 insertions, 220 deletions
diff --git a/appc-directed-graph/appc-dgraph/provider/.gitignore b/appc-directed-graph/appc-dgraph/provider/.gitignore
index 468fdf614..e0b88df5e 100644
--- a/appc-directed-graph/appc-dgraph/provider/.gitignore
+++ b/appc-directed-graph/appc-dgraph/provider/.gitignore
@@ -7,3 +7,4 @@
log/
target/
/bin/
+/target-ide/
diff --git a/appc-directed-graph/appc-dgraph/provider/pom.xml b/appc-directed-graph/appc-dgraph/provider/pom.xml
index 31d472e2c..e2a9f0caa 100644
--- a/appc-directed-graph/appc-dgraph/provider/pom.xml
+++ b/appc-directed-graph/appc-dgraph/provider/pom.xml
@@ -94,7 +94,7 @@
</execution>
</executions>
<configuration>
- <mainClass>org.openecomp.sdnc.dg.loader.DGXMLGenerator</mainClass>
+ <mainClass>org.onap.sdnc.dg.loader.DGXMLGenerator</mainClass>
<arguments>
<argument>${project.basedir}/src/main/resources/json</argument>
<argument>${project.basedir}/src/main/resources/xml</argument>
diff --git a/appc-directed-graph/dg-loader/provider/.gitignore b/appc-directed-graph/dg-loader/provider/.gitignore
index 841e8d948..ba6a00995 100644
--- a/appc-directed-graph/dg-loader/provider/.gitignore
+++ b/appc-directed-graph/dg-loader/provider/.gitignore
@@ -6,3 +6,4 @@
# Maven
log/
target/
+/target-ide/
diff --git a/appc-directed-graph/dg-loader/provider/src/main/java/org/onap/sdnc/dg/loader/DGLoaderActivator.java b/appc-directed-graph/dg-loader/provider/src/main/java/org/onap/sdnc/dg/loader/DGLoaderActivator.java
index 99f7f8b6c..db437a9b2 100644
--- a/appc-directed-graph/dg-loader/provider/src/main/java/org/onap/sdnc/dg/loader/DGLoaderActivator.java
+++ b/appc-directed-graph/dg-loader/provider/src/main/java/org/onap/sdnc/dg/loader/DGLoaderActivator.java
@@ -18,37 +18,34 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.sdnc.dg.loader;
+package org.onap.sdnc.dg.loader;
import java.util.LinkedList;
import java.util.List;
-
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
-
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
-public class DGLoaderActivator implements BundleActivator{
+public class DGLoaderActivator implements BundleActivator {
private List<ServiceRegistration> registrations = new LinkedList<ServiceRegistration>();
- private static final EELFLogger log = EELFManager.getInstance().getLogger(DGLoaderActivator.class);
+ private static final EELFLogger log =
+ EELFManager.getInstance().getLogger(DGLoaderActivator.class);
@Override
- public void start(BundleContext ctx) throws Exception
- {
+ public void start(BundleContext ctx) throws Exception {
+
-
}
+
@Override
- public void stop(BundleContext arg0) throws Exception
- {
- for (ServiceRegistration registration: registrations)
- {
+ public void stop(BundleContext arg0) throws Exception {
+ for (ServiceRegistration registration : registrations) {
registration.unregister();
registration = null;
}
diff --git a/appc-directed-graph/dg-loader/provider/src/main/java/org/onap/sdnc/dg/loader/DGXMLActivate.java b/appc-directed-graph/dg-loader/provider/src/main/java/org/onap/sdnc/dg/loader/DGXMLActivate.java
index 6af447742..9050fa061 100644
--- a/appc-directed-graph/dg-loader/provider/src/main/java/org/onap/sdnc/dg/loader/DGXMLActivate.java
+++ b/appc-directed-graph/dg-loader/provider/src/main/java/org/onap/sdnc/dg/loader/DGXMLActivate.java
@@ -22,12 +22,11 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.sdnc.dg.loader;
+package org.onap.sdnc.dg.loader;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
-
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.onap.ccsdk.sli.core.sli.SvcLogicGraph;
@@ -44,63 +43,70 @@ public class DGXMLActivate {
private final SvcLogicStore store;
public static String STRING_ENCODING = "utf-8";
- public DGXMLActivate(String propfile) throws Exception{
- if(StringUtils.isBlank(propfile)){
+ public DGXMLActivate(String propfile) throws Exception {
+ if (StringUtils.isBlank(propfile)) {
throw new Exception(propfile + " Profile file is not defined");
}
this.store = SvcLogicStoreFactory.getSvcLogicStore(propfile);
}
-
+
protected DGXMLActivate(SvcLogicStore store) {
this.store = store;
}
public void activateDg(String activateFilePath) throws Exception {
- logger.info("******************** Activating DG into Database *****************************");
+ logger.info(
+ "******************** Activating DG into Database *****************************");
try {
List<String> errors = new ArrayList<String>();
- if(this.store != null){
+ if (this.store != null) {
File activateFile = new File(activateFilePath);
- if(activateFile != null && activateFile.isFile()){
- List<String> fileLines = FileUtils.readLines(activateFile,STRING_ENCODING);
- if(fileLines != null ){
+ if (activateFile != null && activateFile.isFile()) {
+ List<String> fileLines = FileUtils.readLines(activateFile, STRING_ENCODING);
+ if (fileLines != null) {
for (String line : fileLines) {
- if(line != null && ! line.trim().startsWith("#")){
+ if (line != null && !line.trim().startsWith("#")) {
String lineArray[] = line.trim().split(":");
try {
- if(lineArray != null && lineArray.length >= 4){
+ if (lineArray != null && lineArray.length >= 4) {
String module = lineArray[0];
String rpc = lineArray[1];
String version = lineArray[2];
String mode = lineArray[3];
- if(StringUtils.isNotBlank(module) && StringUtils.isNotBlank(rpc)
- && StringUtils.isNotBlank(version) && StringUtils.isNotBlank(mode)){
+ if (StringUtils.isNotBlank(module)
+ && StringUtils.isNotBlank(rpc)
+ && StringUtils.isNotBlank(version)
+ && StringUtils.isNotBlank(mode)) {
logger.info("Activating DG :" + line);
- SvcLogicGraph graph = this.store.fetch(module, rpc, version, mode);
- if(graph != null){
- logger.info("Found Graph :" + line + " Activating ...");
+ SvcLogicGraph graph =
+ this.store.fetch(module, rpc, version, mode);
+ if (graph != null) {
+ logger.info(
+ "Found Graph :" + line + " Activating ...");
this.store.activate(graph);
- }else{
- throw new Exception("Failed to fetch from Database");
+ } else {
+ throw new Exception(
+ "Failed to fetch from Database");
}
}
}
} catch (Exception e) {
e.printStackTrace();
- errors.add("Failed to Activate "+line + ", "+e.getMessage());
+ errors.add(
+ "Failed to Activate " + line + ", " + e.getMessage());
}
}
}
}
- }else{
+ } else {
throw new Exception(activateFile + " is not a valid Activate file Path");
}
- }else{
+ } else {
throw new Exception("Failed to initialise SvcLogicStore");
}
- if(errors.size() > 0){
+ if (errors.size() > 0) {
throw new Exception(errors.toString());
}
} catch (Exception e) {
@@ -114,18 +120,19 @@ public class DGXMLActivate {
String activateFile = null;
String propertyPath = null;
- if(args != null && args.length >= 2){
+ if (args != null && args.length >= 2) {
activateFile = args[0];
propertyPath = args[1];
- }else{
- throw new Exception("Sufficient inputs for DGXMLActivate are missing <activatefile> <dbPropertyfile>");
+ } else {
+ throw new Exception(
+ "Sufficient inputs for DGXMLActivate are missing <activatefile> <dbPropertyfile>");
}
DGXMLActivate dgXmlActivate = new DGXMLActivate(propertyPath);
dgXmlActivate.activateDg(activateFile);
} catch (Exception e) {
e.printStackTrace();
- }finally {
+ } finally {
System.exit(1);
}
}
diff --git a/appc-directed-graph/dg-loader/provider/src/main/java/org/onap/sdnc/dg/loader/DGXMLGenerator.java b/appc-directed-graph/dg-loader/provider/src/main/java/org/onap/sdnc/dg/loader/DGXMLGenerator.java
index 60fcd5ba8..0d60a7135 100644
--- a/appc-directed-graph/dg-loader/provider/src/main/java/org/onap/sdnc/dg/loader/DGXMLGenerator.java
+++ b/appc-directed-graph/dg-loader/provider/src/main/java/org/onap/sdnc/dg/loader/DGXMLGenerator.java
@@ -18,15 +18,14 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.sdnc.dg.loader;
+package org.onap.sdnc.dg.loader;
+
import java.io.File;
import java.util.ArrayList;
import java.util.List;
-
import javax.script.Invocable;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
-
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
@@ -41,8 +40,9 @@ public class DGXMLGenerator {
public static String JS_METHOD_GET_NODE_TO_XML = "getNodeToXml";
public static String GENERATOR_TEMPLATE_FILE = "js/dg_xml2json.js";
- public void generateXMLFromJSON(String jsonPath, String xmlpath, String propertyPath) throws Exception {
- try{
+ public void generateXMLFromJSON(String jsonPath, String xmlpath, String propertyPath)
+ throws Exception {
+ try {
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName("JavaScript");
if (!(engine instanceof Invocable)) {
@@ -50,52 +50,57 @@ public class DGXMLGenerator {
return;
}
Invocable inv = (Invocable) engine;
- // engine.eval(new FileReader(DGXMLGenerator.class.getClassLoader().getResource(GENERATOR_TEMPLATE_FILE).getPath()));
- String js = IOUtils.toString(DGXMLGenerator.class.getClassLoader().getResourceAsStream(GENERATOR_TEMPLATE_FILE),STRING_ENCODING);
+ // engine.eval(new
+ // FileReader(DGXMLGenerator.class.getClassLoader().getResource(GENERATOR_TEMPLATE_FILE).getPath()));
+ String js = IOUtils.toString(DGXMLGenerator.class.getClassLoader()
+ .getResourceAsStream(GENERATOR_TEMPLATE_FILE), STRING_ENCODING);
engine.eval(js);
Object dgconverter = engine.get(JS_INTERFACE_DG_CONVERTOR);
List<File> files = new ArrayList<File>();
- if(dgconverter != null){
+ if (dgconverter != null) {
File jsonPathFile = new File(jsonPath);
- if(jsonPathFile.isDirectory()){
- String[] extensions = new String[] { "json", "JSON" };
+ if (jsonPathFile.isDirectory()) {
+ String[] extensions = new String[] {"json", "JSON"};
files = (List<File>) FileUtils.listFiles(jsonPathFile, extensions, true);
- }else if(jsonPathFile.isFile()){
+ } else if (jsonPathFile.isFile()) {
files.add(jsonPathFile);
- }else{
- throw new Exception("Failed to get the nature of the JSON path :"+ jsonPath);
+ } else {
+ throw new Exception("Failed to get the nature of the JSON path :" + jsonPath);
}
- logger.info("JSON Files identified "+ files.size());
+ logger.info("JSON Files identified " + files.size());
- if(files.size() > 0){
+ if (files.size() > 0) {
boolean isXmlPathDeleted = FileUtils.deleteQuietly(new File(xmlpath));
- logger.info("Cleaning old DG XML under : " + xmlpath + ", delete status :" + isXmlPathDeleted);
+ logger.info("Cleaning old DG XML under : " + xmlpath + ", delete status :"
+ + isXmlPathDeleted);
for (File file : files) {
- String dgJson = FileUtils.readFileToString(file,STRING_ENCODING);
+ String dgJson = FileUtils.readFileToString(file, STRING_ENCODING);
logger.info("Generating XML from :" + file.getName());
- String xmlFileName = xmlpath +"/"+file.getName().replace(".json", ".xml");
+ String xmlFileName =
+ xmlpath + "/" + file.getName().replace(".json", ".xml");
- Object dgXMl = inv.invokeMethod(dgconverter, JS_METHOD_GET_NODE_TO_XML, dgJson);
+ Object dgXMl =
+ inv.invokeMethod(dgconverter, JS_METHOD_GET_NODE_TO_XML, dgJson);
// Write the XML File
- if(dgXMl != null){
+ if (dgXMl != null) {
File xmlFile = new File(xmlFileName);
FileUtils.writeStringToFile(xmlFile, dgXMl.toString(), STRING_ENCODING);
logger.info("Generated XML File under :" + xmlFile.getCanonicalPath());
}
}
- }else{
+ } else {
logger.info("No JSON Files to generate XML");
}
- }else{
+ } else {
logger.error("Couldn't get Java Script Engine..");
}
- }catch (Exception e) {
- logger.error("Failed to generate generateXMLFromJSON :"+e.getMessage());
+ } catch (Exception e) {
+ logger.error("Failed to generate generateXMLFromJSON :" + e.getMessage());
}
}
@@ -107,19 +112,19 @@ public class DGXMLGenerator {
String xmlPath = null;
String propertyPath = null;
// Generate, GenerateLoad, GenerateLoadActivate
- //args = new String[]{"src/main/resources/json","src/test/resources/xml"};
- logger.info("DGXML Conversion Started with arguments :"+ args[0] +":"+ args[1]);
- if(args != null && args.length >= 2){
+ // args = new String[]{"src/main/resources/json","src/test/resources/xml"};
+ logger.info("DGXML Conversion Started with arguments :" + args[0] + ":" + args[1]);
+ if (args != null && args.length >= 2) {
jsonPath = args[0];
xmlPath = args[1];
- }else{
+ } else {
throw new Exception("Sufficient inputs are missing <jsonPath> <xmlPath>");
}
application.generateXMLFromJSON(jsonPath, xmlPath, propertyPath);
logger.info("DGXML Conversion Completed...");
} catch (Exception e) {
- logger.error("Failed in DG XML Generation :"+e.getMessage());
+ logger.error("Failed in DG XML Generation :" + e.getMessage());
e.printStackTrace();
}
diff --git a/appc-directed-graph/dg-loader/provider/src/main/java/org/onap/sdnc/dg/loader/DGXMLLoad.java b/appc-directed-graph/dg-loader/provider/src/main/java/org/onap/sdnc/dg/loader/DGXMLLoad.java
index 1b6116cc3..ced6b007c 100644
--- a/appc-directed-graph/dg-loader/provider/src/main/java/org/onap/sdnc/dg/loader/DGXMLLoad.java
+++ b/appc-directed-graph/dg-loader/provider/src/main/java/org/onap/sdnc/dg/loader/DGXMLLoad.java
@@ -22,17 +22,15 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.sdnc.dg.loader;
+package org.onap.sdnc.dg.loader;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
-
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
import org.onap.ccsdk.sli.core.sli.SvcLogicException;
import org.onap.ccsdk.sli.core.sli.SvcLogicParser;
import org.onap.ccsdk.sli.core.sli.SvcLogicStore;
@@ -43,48 +41,50 @@ public class DGXMLLoad {
private final SvcLogicStore store;
public static String STRING_ENCODING = "utf-8";
- public DGXMLLoad(String propfile) throws Exception{
- if(StringUtils.isBlank(propfile)){
+ public DGXMLLoad(String propfile) throws Exception {
+ if (StringUtils.isBlank(propfile)) {
throw new Exception(propfile + " Profile file is not defined");
}
this.store = SvcLogicStoreFactory.getSvcLogicStore(propfile);
}
protected DGXMLLoad(SvcLogicStore store) throws Exception {
- this.store=store;
+ this.store = store;
}
-
- public void loadDGXMLFile(String dgXMLpath) throws SvcLogicException{
- if(dgXMLpath != null ){
+
+ public void loadDGXMLFile(String dgXMLpath) throws SvcLogicException {
+ if (dgXMLpath != null) {
SvcLogicParser.load(dgXMLpath, this.store);
}
}
private void loadDGXMLDir(String xmlPath) throws Exception {
try {
- logger.info("******************** Loading DG into Database *****************************");
+ logger.info(
+ "******************** Loading DG into Database *****************************");
List<String> errors = new ArrayList<String>();
- if(this.store != null){
+ if (this.store != null) {
File xmlDir = new File(xmlPath);
- if(xmlDir != null && xmlDir.isDirectory()){
- String[] extensions = new String[] { "xml", "XML" };
+ if (xmlDir != null && xmlDir.isDirectory()) {
+ String[] extensions = new String[] {"xml", "XML"};
List<File> files = (List<File>) FileUtils.listFiles(xmlDir, extensions, true);
for (File file : files) {
logger.info("Loading DG XML file :" + file.getCanonicalPath());
- try{
+ try {
SvcLogicParser.load(file.getCanonicalPath(), this.store);
- }catch (Exception e) {
- errors.add("Failed to load XML "+file.getCanonicalPath() + ", Exception : "+e.getMessage());
+ } catch (Exception e) {
+ errors.add("Failed to load XML " + file.getCanonicalPath()
+ + ", Exception : " + e.getMessage());
}
}
- }else{
+ } else {
throw new Exception(xmlPath + " is not a valid XML Directory");
}
- }else{
+ } else {
throw new Exception("Failed to initialise SvcLogicStore");
}
- if(errors.size() > 0){
+ if (errors.size() > 0) {
throw new Exception(errors.toString());
}
} catch (Exception e) {
@@ -97,17 +97,18 @@ public class DGXMLLoad {
String xmlPath = null;
String propertyPath = null;
- if(args != null && args.length >= 2){
+ if (args != null && args.length >= 2) {
xmlPath = args[0];
propertyPath = args[1];
- }else{
- throw new Exception("Sufficient inputs for DGXMLLoadNActivate are missing <xmlpath> <dbPropertyfile>");
+ } else {
+ throw new Exception(
+ "Sufficient inputs for DGXMLLoadNActivate are missing <xmlpath> <dbPropertyfile>");
}
DGXMLLoad dgXMLLoadDB = new DGXMLLoad(propertyPath);
dgXMLLoadDB.loadDGXMLDir(xmlPath);
} catch (Exception e) {
e.printStackTrace();
- }finally {
+ } finally {
System.exit(1);
}
}
diff --git a/appc-directed-graph/dg-loader/provider/src/main/java/org/onap/sdnc/dg/loader/DGXMLLoadNActivate.java b/appc-directed-graph/dg-loader/provider/src/main/java/org/onap/sdnc/dg/loader/DGXMLLoadNActivate.java
index 54f109177..490a1f9bb 100644
--- a/appc-directed-graph/dg-loader/provider/src/main/java/org/onap/sdnc/dg/loader/DGXMLLoadNActivate.java
+++ b/appc-directed-graph/dg-loader/provider/src/main/java/org/onap/sdnc/dg/loader/DGXMLLoadNActivate.java
@@ -22,17 +22,15 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.sdnc.dg.loader;
+package org.onap.sdnc.dg.loader;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
-
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
import org.onap.ccsdk.sli.core.sli.SvcLogicException;
import org.onap.ccsdk.sli.core.sli.SvcLogicGraph;
import org.onap.ccsdk.sli.core.sli.SvcLogicParser;
@@ -44,48 +42,50 @@ public class DGXMLLoadNActivate {
private final SvcLogicStore store;
public static String STRING_ENCODING = "utf-8";
- public DGXMLLoadNActivate(String propfile) throws Exception{
- if(StringUtils.isBlank(propfile)){
+ public DGXMLLoadNActivate(String propfile) throws Exception {
+ if (StringUtils.isBlank(propfile)) {
throw new Exception(propfile + " Profile file is not defined");
}
this.store = SvcLogicStoreFactory.getSvcLogicStore(propfile);
}
protected DGXMLLoadNActivate(SvcLogicStore store) {
- this.store=store;
+ this.store = store;
}
- public void loadDGXMLFile(String dgXMLpath) throws SvcLogicException{
- if(dgXMLpath != null ){
+ public void loadDGXMLFile(String dgXMLpath) throws SvcLogicException {
+ if (dgXMLpath != null) {
SvcLogicParser.load(dgXMLpath, this.store);
}
}
private void loadDGXMLDir(String xmlPath) throws Exception {
try {
- logger.info("******************** Loading DG into Database *****************************");
+ logger.info(
+ "******************** Loading DG into Database *****************************");
List<String> errors = new ArrayList<String>();
- if(this.store != null){
+ if (this.store != null) {
File xmlDir = new File(xmlPath);
- if(xmlDir.isDirectory()){
- String[] extensions = new String[] { "xml", "XML" };
+ if (xmlDir.isDirectory()) {
+ String[] extensions = new String[] {"xml", "XML"};
List<File> files = (List<File>) FileUtils.listFiles(xmlDir, extensions, true);
for (File file : files) {
logger.info("Loading DG XML file :" + file.getCanonicalPath());
- try{
+ try {
SvcLogicParser.load(file.getCanonicalPath(), this.store);
- }catch (Exception e) {
- errors.add("Failed to load XML "+file.getCanonicalPath() + ", Exception : "+e.getMessage());
+ } catch (Exception e) {
+ errors.add("Failed to load XML " + file.getCanonicalPath()
+ + ", Exception : " + e.getMessage());
}
}
- }else{
+ } else {
throw new Exception(xmlPath + " is not a valid XML Directory");
}
- }else{
+ } else {
throw new Exception("Failed to initialise SvcLogicStore");
}
- if(errors.size() > 0){
+ if (errors.size() > 0) {
throw new Exception(errors.toString());
}
} catch (Exception e) {
@@ -94,50 +94,57 @@ public class DGXMLLoadNActivate {
}
public void activateDg(String activateFilePath) throws Exception {
- logger.info("******************** Activating DG into Database *****************************");
+ logger.info(
+ "******************** Activating DG into Database *****************************");
try {
List<String> errors = new ArrayList<String>();
- if(this.store != null){
+ if (this.store != null) {
File activateFile = new File(activateFilePath);
- if(activateFile.isFile()){
- List<String> fileLines = FileUtils.readLines(activateFile,STRING_ENCODING);
- if(fileLines != null ){
+ if (activateFile.isFile()) {
+ List<String> fileLines = FileUtils.readLines(activateFile, STRING_ENCODING);
+ if (fileLines != null) {
for (String line : fileLines) {
- if(line != null && ! line.trim().startsWith("#")){
+ if (line != null && !line.trim().startsWith("#")) {
String lineArray[] = line.trim().split(":");
try {
- if(lineArray != null && lineArray.length >= 4){
+ if (lineArray != null && lineArray.length >= 4) {
String module = lineArray[0];
String rpc = lineArray[1];
String version = lineArray[2];
String mode = lineArray[3];
- if(StringUtils.isNotBlank(module) && StringUtils.isNotBlank(rpc)
- && StringUtils.isNotBlank(version) && StringUtils.isNotBlank(mode)){
+ if (StringUtils.isNotBlank(module)
+ && StringUtils.isNotBlank(rpc)
+ && StringUtils.isNotBlank(version)
+ && StringUtils.isNotBlank(mode)) {
logger.info("Activating DG :" + line);
- SvcLogicGraph graph = this.store.fetch(module, rpc, version, mode);
- if(graph != null){
- logger.info("Found Graph :" + line + " Activating ...");
+ SvcLogicGraph graph =
+ this.store.fetch(module, rpc, version, mode);
+ if (graph != null) {
+ logger.info(
+ "Found Graph :" + line + " Activating ...");
this.store.activate(graph);
- }else{
- throw new Exception("Failed to fetch from Database");
+ } else {
+ throw new Exception(
+ "Failed to fetch from Database");
}
}
}
} catch (Exception e) {
e.printStackTrace();
- errors.add("Failed to Activate "+line + ", "+e.getMessage());
+ errors.add(
+ "Failed to Activate " + line + ", " + e.getMessage());
}
}
}
}
- }else{
+ } else {
throw new Exception(activateFile + " is not a valid Activate file Path");
}
- }else{
+ } else {
throw new Exception("Failed to initialise SvcLogicStore");
}
- if(errors.size() > 0){
+ if (errors.size() > 0) {
throw new Exception(errors.toString());
}
} catch (Exception e) {
@@ -152,23 +159,26 @@ public class DGXMLLoadNActivate {
String propertyPath = null;
String activateFile = null;
- if(args != null && args.length >= 3){
+ if (args != null && args.length >= 3) {
xmlPath = args[0];
activateFile = args[1];
propertyPath = args[2];
- }else{
- throw new Exception("Sufficient inputs for DGXMLLoadNActivate are missing <xmlpath> <activatefile> <dbPropertyfile>");
+ } else {
+ throw new Exception(
+ "Sufficient inputs for DGXMLLoadNActivate are missing <xmlpath> <activatefile> <dbPropertyfile>");
}
- //propertyPath = "/Users/bs2796/0Source/ecomp/bvc-3.2.2/others/properties/dblib.properties";
- //xmlPath = DGXMLLoadNActivate.class.getClassLoader().getResource(".").getPath() +"/xml" ;
+ // propertyPath =
+ // "/Users/bs2796/0Source/ecomp/bvc-3.2.2/others/properties/dblib.properties";
+ // xmlPath = DGXMLLoadNActivate.class.getClassLoader().getResource(".").getPath()
+ // +"/xml" ;
DGXMLLoadNActivate dgXMLLoadDB = new DGXMLLoadNActivate(propertyPath);
dgXMLLoadDB.loadDGXMLDir(xmlPath);
dgXMLLoadDB.activateDg(activateFile);
} catch (Exception e) {
e.printStackTrace();
- }finally {
+ } finally {
System.exit(1);
}
}
diff --git a/appc-directed-graph/dg-loader/provider/src/main/resources/scripts/dg_load_activate.sh b/appc-directed-graph/dg-loader/provider/src/main/resources/scripts/dg_load_activate.sh
index e92efce90..da117361b 100644
--- a/appc-directed-graph/dg-loader/provider/src/main/resources/scripts/dg_load_activate.sh
+++ b/appc-directed-graph/dg-loader/provider/src/main/resources/scripts/dg_load_activate.sh
@@ -39,12 +39,12 @@ cd ${DG_JSON_DIR}
rm -rf ${DG_JSON_DIR}/xml
################## To Genetare XML from JSON ########################
-$JAVA_HOME/bin/java -cp ${DG_DIR}/lib/dg-loader-provider.jar org.openecomp.sdnc.dg.loader.DGXMLGenerator ${DG_JSON_DIR} ${DG_JSON_DIR}/xml
+$JAVA_HOME/bin/java -cp ${DG_DIR}/lib/dg-loader-provider.jar org.onap.sdnc.dg.loader.DGXMLGenerator ${DG_JSON_DIR} ${DG_JSON_DIR}/xml
################## To Load DG XML ########################
-$JAVA_HOME/bin/java -cp ${DG_DIR}/lib/dg-loader-provider.jar org.openecomp.sdnc.dg.loader.DGXMLLoad ${DG_JSON_DIR}/xml ${BVC_DIR}/properties/dblib.properties
+$JAVA_HOME/bin/java -cp ${DG_DIR}/lib/dg-loader-provider.jar org.onap.sdnc.dg.loader.DGXMLLoad ${DG_JSON_DIR}/xml ${BVC_DIR}/properties/dblib.properties
################## To Activate ########################
-$JAVA_HOME/bin/java -cp ${DG_DIR}/lib/dg-loader-provider.jar org.openecomp.sdnc.dg.loader.DGXMLActivate ${DG_JSON_DIR}/dg_activate.txt ${BVC_DIR}/properties/dblib.properties
+$JAVA_HOME/bin/java -cp ${DG_DIR}/lib/dg-loader-provider.jar org.onap.sdnc.dg.loader.DGXMLActivate ${DG_JSON_DIR}/dg_activate.txt ${BVC_DIR}/properties/dblib.properties
exit 0
diff --git a/appc-directed-graph/dg-loader/provider/src/test/java/org/onap/sdnc/dg/loader/DGLoaderTest.java b/appc-directed-graph/dg-loader/provider/src/test/java/org/onap/sdnc/dg/loader/DGLoaderTest.java
index 084929bc7..ea83213fc 100644
--- a/appc-directed-graph/dg-loader/provider/src/test/java/org/onap/sdnc/dg/loader/DGLoaderTest.java
+++ b/appc-directed-graph/dg-loader/provider/src/test/java/org/onap/sdnc/dg/loader/DGLoaderTest.java
@@ -22,31 +22,19 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.sdnc.dg.loader;
-
-import static org.junit.Assert.*;
+package org.onap.sdnc.dg.loader;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
-import java.util.Properties;
-
import org.apache.commons.io.FileUtils;
-import org.eclipse.osgi.framework.internal.core.BundleContextImpl;
-import org.eclipse.osgi.framework.internal.core.BundleHost;
-import org.junit.Rule;
import org.junit.Test;
-import org.mockito.Mockito;
-import org.onap.ccsdk.sli.core.sli.ConfigurationException;
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;
-import org.onap.ccsdk.sli.core.sli.SvcLogicStore;
-import org.onap.ccsdk.sli.core.sli.SvcLogicStoreFactory;
-import org.osgi.framework.BundleContext;
import org.powermock.reflect.Whitebox;
-import org.powermock.*;
public class DGLoaderTest {
-
+
@Test
public void testXMLGenerator() throws Exception {
DGXMLGenerator application = new DGXMLGenerator();
@@ -54,58 +42,58 @@ public class DGLoaderTest {
String xmlPath = null;
String propertyPath = "somePath";
// Generate, GenerateLoad, GenerateLoadActivate
- String []args = new String[]{"src/test/resources/json","src/test/resources/xml"};
- //logger.info("DGXML Conversion Started with arguments :"+ args[0] +":"+ args[1]);
- if(args != null && args.length >= 2){
+ String[] args = new String[] {"src/test/resources/json", "src/test/resources/xml"};
+ // logger.info("DGXML Conversion Started with arguments :"+ args[0] +":"+ args[1]);
+ if (args != null && args.length >= 2) {
jsonPath = args[0];
xmlPath = args[1];
}
-
+
application.generateXMLFromJSON(jsonPath, xmlPath, propertyPath);
- File dir=new File("src/test/resources/xml");
- String extensions[]=new String[] {"xml","XML"};
+ File dir = new File("src/test/resources/xml");
+ String extensions[] = new String[] {"xml", "XML"};
List<File> files = new ArrayList<File>();
- files=(List<File>) FileUtils.listFiles(dir, extensions, true);
+ files = (List<File>) FileUtils.listFiles(dir, extensions, true);
assertNotNull(files.get(0));
assertNotNull(files.get(0).getName());
}
-
+
@Test
public void testXMLGeneratorMain() throws Exception {
- String []args = new String[]{"src/test/resources/json","src/test/resources/xml"};
+ String[] args = new String[] {"src/test/resources/json", "src/test/resources/xml"};
DGXMLGenerator.main(args);
- File dir=new File("src/test/resources/xml");
- String extensions[]=new String[] {"xml","XML"};
+ File dir = new File("src/test/resources/xml");
+ String extensions[] = new String[] {"xml", "XML"};
List<File> files = new ArrayList<File>();
- files=(List<File>) FileUtils.listFiles(dir, extensions, true);
+ files = (List<File>) FileUtils.listFiles(dir, extensions, true);
assertNotNull(files.get(0));
assertNotNull(files.get(0).getName());
}
-
+
@Test
public void testDGLoader() throws Exception {
String propertyPath = "src/test/resources/dummy.properties";
String xmlPath = "src/test/resources/xml/Appc_UniTest.xml";
DGXMLLoad dgXMLLoad = new MockDGXMLLoad();
dgXMLLoad.loadDGXMLFile(xmlPath);
- }
-
+ }
+
@Test
public void testDGLoaderWithDir() throws Exception {
String propertyPath = "src/test/resources/dummy.properties";
String xmlPath = "src/test/resources/xml";
DGXMLLoad dgXMLLoad = new MockDGXMLLoad();
- Whitebox.invokeMethod(dgXMLLoad, "loadDGXMLDir",xmlPath);
+ Whitebox.invokeMethod(dgXMLLoad, "loadDGXMLDir", xmlPath);
}
-
+
@Test
public void testDGLoaderWithDirThrowsException() throws Exception {
String propertyPath = "src/test/resources/dummy.properties";
String xmlPath = "src/test/resources/xml/xml";
DGXMLLoad dgXMLLoad = new MockDGXMLLoad();
- Whitebox.invokeMethod(dgXMLLoad, "loadDGXMLDir",xmlPath);
+ Whitebox.invokeMethod(dgXMLLoad, "loadDGXMLDir", xmlPath);
}
-
+
@Test
public void testDGActivate() throws Exception {
String propertyPath = "src/test/resources/dummy.properties";
@@ -114,7 +102,7 @@ public class DGLoaderTest {
dgXMLActivate.activateDg(activateFilePath);
}
-
+
@Test
public void testDGActivateThrowsException() throws Exception {
String propertyPath = "src/test/resources/dummy.properties";
@@ -123,7 +111,7 @@ public class DGLoaderTest {
dgXMLActivate.activateDg(activateFilePath);
}
-
+
@Test
public void testDGLoadNActivate() throws Exception {
String propertyPath = "src/test/resources/dummy.properties";
@@ -133,7 +121,7 @@ public class DGLoaderTest {
dgXMLLoadNActivate.loadDGXMLFile(xmlPath);
dgXMLLoadNActivate.activateDg(activateFilePath);
}
-
+
@Test
public void testDGLoadNActivateThrowsException() throws Exception {
String propertyPath = "src/test/resources/dummy.properties";
@@ -143,21 +131,21 @@ public class DGLoaderTest {
dgXMLLoadNActivate.loadDGXMLFile(xmlPath);
dgXMLLoadNActivate.activateDg(activateFilePath);
}
-
+
@Test
public void testDGLoadNActivateloadDGXMLDir() throws Exception {
String xmlPath = "src/test/resources/xml";
DGXMLLoadNActivate dgXMLLoadNActivate = new MockDGXMLLoadNActivate();
- Whitebox.invokeMethod(dgXMLLoadNActivate,"loadDGXMLDir",xmlPath);
- }
-
-
+ Whitebox.invokeMethod(dgXMLLoadNActivate, "loadDGXMLDir", xmlPath);
+ }
+
+
public void testDGLoadNActivateloadDGXMLDirThrowsException() throws Exception {
String xmlPath = "src/test/resources/someDir";
DGXMLLoadNActivate dgXMLLoadNActivate = new MockDGXMLLoadNActivate();
- Whitebox.invokeMethod(dgXMLLoadNActivate,"loadDGXMLDir",xmlPath);
- }
-
+ Whitebox.invokeMethod(dgXMLLoadNActivate, "loadDGXMLDir", xmlPath);
+ }
+
@Test
public void testDGLoaderActivator() throws Exception {
String xmlPath = "src/test/resources/xml";
@@ -167,22 +155,22 @@ public class DGLoaderTest {
assertTrue(true);
}
- @Test (expected=Exception.class)
+ @Test(expected = Exception.class)
public void testDGActivateConstructorThrowsException() throws Exception {
- String somePath="";
+ String somePath = "";
DGXMLActivate dgXMLActivate = new DGXMLActivate(somePath);
}
-
- @Test (expected=Exception.class)
+
+ @Test(expected = Exception.class)
public void testDGXMLLoadConstructorThrowsException() throws Exception {
- String somePath="";
+ String somePath = "";
DGXMLLoad dgXMLLoad = new DGXMLLoad(somePath);
}
-
- @Test (expected=Exception.class)
+
+ @Test(expected = Exception.class)
public void testDGLoadNActivateConstructorThrowsException() throws Exception {
- String somePath="";
+ String somePath = "";
DGXMLLoadNActivate dgXMLLoadNActivate = new DGXMLLoadNActivate(somePath);
}
-
+
}
diff --git a/appc-directed-graph/dg-loader/provider/src/test/java/org/onap/sdnc/dg/loader/MockDGXMLActivate.java b/appc-directed-graph/dg-loader/provider/src/test/java/org/onap/sdnc/dg/loader/MockDGXMLActivate.java
index 41f1d09f8..09de23285 100644
--- a/appc-directed-graph/dg-loader/provider/src/test/java/org/onap/sdnc/dg/loader/MockDGXMLActivate.java
+++ b/appc-directed-graph/dg-loader/provider/src/test/java/org/onap/sdnc/dg/loader/MockDGXMLActivate.java
@@ -22,12 +22,13 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.sdnc.dg.loader;
+package org.onap.sdnc.dg.loader;
import org.onap.ccsdk.sli.core.sli.SvcLogicStore;
public class MockDGXMLActivate extends DGXMLActivate {
- private final static SvcLogicStore storeChild=MockSvcLogicFactory.getMockSvcLogicStore();;
+ private final static SvcLogicStore storeChild = MockSvcLogicFactory.getMockSvcLogicStore();;
+
MockDGXMLActivate() throws Exception {
super(storeChild);
}
diff --git a/appc-directed-graph/dg-loader/provider/src/test/java/org/onap/sdnc/dg/loader/MockDGXMLLoad.java b/appc-directed-graph/dg-loader/provider/src/test/java/org/onap/sdnc/dg/loader/MockDGXMLLoad.java
index 27336d38d..bbca6af6d 100644
--- a/appc-directed-graph/dg-loader/provider/src/test/java/org/onap/sdnc/dg/loader/MockDGXMLLoad.java
+++ b/appc-directed-graph/dg-loader/provider/src/test/java/org/onap/sdnc/dg/loader/MockDGXMLLoad.java
@@ -22,14 +22,14 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.sdnc.dg.loader;
+package org.onap.sdnc.dg.loader;
-import org.mockito.internal.util.reflection.Whitebox;
import org.onap.ccsdk.sli.core.sli.SvcLogicStore;
-public class MockDGXMLLoad extends DGXMLLoad{
+public class MockDGXMLLoad extends DGXMLLoad {
+
+ private final static SvcLogicStore storeChild = MockSvcLogicFactory.getMockSvcLogicStore();;
- private final static SvcLogicStore storeChild=MockSvcLogicFactory.getMockSvcLogicStore();;
MockDGXMLLoad() throws Exception {
super(storeChild);
}
diff --git a/appc-directed-graph/dg-loader/provider/src/test/java/org/onap/sdnc/dg/loader/MockDGXMLLoadNActivate.java b/appc-directed-graph/dg-loader/provider/src/test/java/org/onap/sdnc/dg/loader/MockDGXMLLoadNActivate.java
index f60e6ab12..dd3590a78 100644
--- a/appc-directed-graph/dg-loader/provider/src/test/java/org/onap/sdnc/dg/loader/MockDGXMLLoadNActivate.java
+++ b/appc-directed-graph/dg-loader/provider/src/test/java/org/onap/sdnc/dg/loader/MockDGXMLLoadNActivate.java
@@ -22,13 +22,14 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.sdnc.dg.loader;
+package org.onap.sdnc.dg.loader;
import org.onap.ccsdk.sli.core.sli.SvcLogicStore;
public class MockDGXMLLoadNActivate extends DGXMLLoadNActivate {
- private final static SvcLogicStore storeChild=MockSvcLogicFactory.getMockSvcLogicStore();;
- MockDGXMLLoadNActivate() throws Exception {
+ private final static SvcLogicStore storeChild = MockSvcLogicFactory.getMockSvcLogicStore();;
+
+ MockDGXMLLoadNActivate() throws Exception {
super(storeChild);
}
}
diff --git a/appc-directed-graph/dg-loader/provider/src/test/java/org/onap/sdnc/dg/loader/MockSvcLogicDblibStore.java b/appc-directed-graph/dg-loader/provider/src/test/java/org/onap/sdnc/dg/loader/MockSvcLogicDblibStore.java
index fdfe0ab1b..f3c10725e 100644
--- a/appc-directed-graph/dg-loader/provider/src/test/java/org/onap/sdnc/dg/loader/MockSvcLogicDblibStore.java
+++ b/appc-directed-graph/dg-loader/provider/src/test/java/org/onap/sdnc/dg/loader/MockSvcLogicDblibStore.java
@@ -22,11 +22,9 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.sdnc.dg.loader;
+package org.onap.sdnc.dg.loader;
import java.util.Properties;
-
-import org.onap.ccsdk.sli.core.sli.SvcLogicDblibStore;
import org.onap.ccsdk.sli.core.sli.SvcLogicException;
import org.onap.ccsdk.sli.core.sli.SvcLogicGraph;
import org.onap.ccsdk.sli.core.sli.SvcLogicStore;
@@ -34,53 +32,61 @@ import org.onap.ccsdk.sli.core.sli.SvcLogicStore;
public class MockSvcLogicDblibStore implements SvcLogicStore {
@Override
- public boolean hasGraph(String module, String rpc, String version,
- String mode) {
+ public boolean hasGraph(String module, String rpc, String version, String mode) {
return true;
}
+
@Override
- public SvcLogicGraph fetch(String module, String rpc, String version,
- String mode) throws SvcLogicException {
- SvcLogicGraph retVal=new SvcLogicGraph();
+ public SvcLogicGraph fetch(String module, String rpc, String version, String mode)
+ throws SvcLogicException {
+ SvcLogicGraph retVal = new SvcLogicGraph();
retVal.setMode("sync");
retVal.setModule("Appc");
retVal.setRpc("unitTestDG");
retVal.setVersion("4.0.0");
return retVal;
-
+
}
+
@Override
public void store(SvcLogicGraph graph) throws SvcLogicException {
}
+
@Override
public void init(Properties props) throws SvcLogicException {
// TODO Auto-generated method stub
-
+
}
+
@Override
public void registerNodeType(String nodeType) throws SvcLogicException {
// TODO Auto-generated method stub
-
+
}
+
@Override
public void unregisterNodeType(String nodeType) throws SvcLogicException {
// TODO Auto-generated method stub
-
+
}
+
@Override
public boolean isValidNodeType(String nodeType) throws SvcLogicException {
// TODO Auto-generated method stub
return true;
}
+
@Override
- public void delete(String module, String rpc, String version, String mode) throws SvcLogicException {
+ public void delete(String module, String rpc, String version, String mode)
+ throws SvcLogicException {
// TODO Auto-generated method stub
-
+
}
+
@Override
public void activate(SvcLogicGraph graph) throws SvcLogicException {
// TODO Auto-generated method stub
-
+
}
}
diff --git a/appc-directed-graph/dg-loader/provider/src/test/java/org/onap/sdnc/dg/loader/MockSvcLogicFactory.java b/appc-directed-graph/dg-loader/provider/src/test/java/org/onap/sdnc/dg/loader/MockSvcLogicFactory.java
index 82f75a0f8..8a0343ae3 100644
--- a/appc-directed-graph/dg-loader/provider/src/test/java/org/onap/sdnc/dg/loader/MockSvcLogicFactory.java
+++ b/appc-directed-graph/dg-loader/provider/src/test/java/org/onap/sdnc/dg/loader/MockSvcLogicFactory.java
@@ -22,15 +22,14 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.sdnc.dg.loader;
+package org.onap.sdnc.dg.loader;
import org.onap.ccsdk.sli.core.sli.SvcLogicStore;
import org.onap.ccsdk.sli.core.sli.SvcLogicStoreFactory;
-import org.onap.ccsdk.sli.core.sli.SvcLogicDblibStore;
public class MockSvcLogicFactory extends SvcLogicStoreFactory {
static SvcLogicStore getMockSvcLogicStore() {
- SvcLogicStore store=new MockSvcLogicDblibStore();
- return store;
+ SvcLogicStore store = new MockSvcLogicDblibStore();
+ return store;
}
}