summaryrefslogtreecommitdiffstats
path: root/appc-directed-graph/dg-loader
diff options
context:
space:
mode:
Diffstat (limited to 'appc-directed-graph/dg-loader')
-rw-r--r--appc-directed-graph/dg-loader/features/src/main/resources/features.xml1
-rw-r--r--appc-directed-graph/dg-loader/pom.xml61
-rw-r--r--appc-directed-graph/dg-loader/provider/pom.xml31
-rw-r--r--appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGLoaderActivator.java32
-rw-r--r--appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGXMLActivate.java173
-rw-r--r--appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGXMLGenerator.java180
-rw-r--r--appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGXMLLoad.java130
-rw-r--r--appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGXMLLoadNActivate.java256
-rw-r--r--appc-directed-graph/dg-loader/provider/src/main/resources/scripts/dg_load_activate.sh1
9 files changed, 431 insertions, 434 deletions
diff --git a/appc-directed-graph/dg-loader/features/src/main/resources/features.xml b/appc-directed-graph/dg-loader/features/src/main/resources/features.xml
index 2d4a65438..49bf35811 100644
--- a/appc-directed-graph/dg-loader/features/src/main/resources/features.xml
+++ b/appc-directed-graph/dg-loader/features/src/main/resources/features.xml
@@ -20,6 +20,7 @@
-->
+
<features name="sdnc-dg-loader-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
diff --git a/appc-directed-graph/dg-loader/pom.xml b/appc-directed-graph/dg-loader/pom.xml
index 557969331..40b3b90ec 100644
--- a/appc-directed-graph/dg-loader/pom.xml
+++ b/appc-directed-graph/dg-loader/pom.xml
@@ -1,4 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ ONAP : APPC
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ ================================================================================
+ Copyright (C) 2017 Amdocs
+ =============================================================================
+ 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.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ ============LICENSE_END=========================================================
+ -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
@@ -31,45 +54,9 @@
<openecomp.sdnc.sli.version>1.1.0</openecomp.sdnc.sli.version>
<openecomp.sdnc.dblib.version>1.1.0</openecomp.sdnc.dblib.version>
<openecomp.sdnc.sql-resource.version>1.1.0</openecomp.sdnc.sql-resource.version>
+ <licenseDir>${project.parent.parent.basedir}</licenseDir>
</properties>
- <dependencyManagement>
-
- <dependencies>
- <dependency>
- <groupId>org.openecomp.appc.plugins</groupId>
- <artifactId>dg-loader.features</artifactId>
- <classifier>features</classifier>
- <type>xml</type>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.openecomp.appc.plugins</groupId>
- <artifactId>dg-loader.provider</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.openecomp.sdnc.core</groupId>
- <artifactId>sli-common</artifactId>
- <version>${sdnctl.sli.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.openecomp.sdnc.core</groupId>
- <artifactId>sli-provider</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.openecomp.sdnc.core</groupId>
- <artifactId>dblib-provider</artifactId>
- <version>${sdnctl.dblib.version}</version>
- </dependency>
-
- </dependencies>
- </dependencyManagement>
-
<modules>
<module>features</module>
<module>provider</module>
diff --git a/appc-directed-graph/dg-loader/provider/pom.xml b/appc-directed-graph/dg-loader/provider/pom.xml
index 3bd0ae9d2..587c92aae 100644
--- a/appc-directed-graph/dg-loader/provider/pom.xml
+++ b/appc-directed-graph/dg-loader/provider/pom.xml
@@ -1,4 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ ONAP : APPC
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ ================================================================================
+ Copyright (C) 2017 Amdocs
+ =============================================================================
+ 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.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ ============LICENSE_END=========================================================
+ -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -9,8 +32,7 @@
</parent>
<artifactId>dg-loader-provider</artifactId>
<packaging>bundle</packaging>
- <name>Directed Graph Loader - Provider</name>
- <url>http://maven.apache.org</url>
+ <name>APPC Directed Graph Loader - Provider</name>
<dependencies>
<dependency>
@@ -22,25 +44,20 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
- <version>${common.io.version}</version>
</dependency>
<dependency>
<groupId>com.att.eelf</groupId>
<artifactId>eelf-core</artifactId>
- <version>${eelf.version}</version>
</dependency>
-
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
-
</dependencies>
<build>
<plugins>
-
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
diff --git a/appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGLoaderActivator.java b/appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGLoaderActivator.java
index dd56e6cc1..99f7f8b6c 100644
--- a/appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGLoaderActivator.java
+++ b/appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGLoaderActivator.java
@@ -32,27 +32,27 @@ import com.att.eelf.configuration.EELFManager;
public class DGLoaderActivator implements BundleActivator{
- private List<ServiceRegistration> registrations = new LinkedList<ServiceRegistration>();
+ 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
- {
+ @Override
+ public void start(BundleContext ctx) throws Exception
+ {
-
+
- }
- @Override
- public void stop(BundleContext arg0) throws Exception
- {
- for (ServiceRegistration registration: registrations)
- {
- registration.unregister();
- registration = null;
- }
+ }
+ @Override
+ 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/openecomp/sdnc/dg/loader/DGXMLActivate.java b/appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGXMLActivate.java
index 1cb446a83..b37400ba7 100644
--- a/appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGXMLActivate.java
+++ b/appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGXMLActivate.java
@@ -36,93 +36,90 @@ import org.slf4j.LoggerFactory;
public class DGXMLActivate {
- private final static Logger logger = LoggerFactory.getLogger(DGXMLLoadNActivate.class);
- private final SvcLogicStore store;
- public static String STRING_ENCODING = "utf-8";
-
- public DGXMLActivate(String propfile) throws Exception{
- if(StringUtils.isBlank(propfile)){
- throw new Exception(propfile + " Profile file is not defined");
- }
- this.store = SvcLogicStoreFactory.getSvcLogicStore(propfile);
- }
-
-
- public void activateDg(String activateFilePath) throws Exception {
- logger.info("******************** Activating DG into Database *****************************");
- try {
- List<String> errors = new ArrayList<String>();
- 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 ){
- for (String line : fileLines) {
- if(line != null && ! line.trim().startsWith("#")){
- String lineArray[] = line.trim().split(":");
- try {
- 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)){
- logger.info("Activating DG :" + line);
- 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");
- }
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- errors.add("Failed to Activate "+line + ", "+e.getMessage());
- }
- }
- }
- }
- }else{
- throw new Exception(activateFile + " is not a valid Activate file Path");
- }
- }else{
- throw new Exception("Failed to initialise SvcLogicStore");
- }
-
- if(errors.size() > 0){
- throw new Exception(errors.toString());
- }
- } catch (Exception e) {
- logger.error(e.getMessage());
- }
- }
-
-
- public static void main(String[] args) {
- try {
-
- String activateFile = null;
- String propertyPath = null;
-
- if(args != null && args.length >= 2){
- activateFile = args[0];
- propertyPath = args[1];
- }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 {
- System.exit(1);
- }
- }
-
-
+ private final static Logger logger = LoggerFactory.getLogger(DGXMLLoadNActivate.class);
+ private final SvcLogicStore store;
+ public static String STRING_ENCODING = "utf-8";
+
+ public DGXMLActivate(String propfile) throws Exception{
+ if(StringUtils.isBlank(propfile)){
+ throw new Exception(propfile + " Profile file is not defined");
+ }
+ this.store = SvcLogicStoreFactory.getSvcLogicStore(propfile);
+ }
+
+
+ public void activateDg(String activateFilePath) throws Exception {
+ logger.info("******************** Activating DG into Database *****************************");
+ try {
+ List<String> errors = new ArrayList<String>();
+ 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 ){
+ for (String line : fileLines) {
+ if(line != null && ! line.trim().startsWith("#")){
+ String lineArray[] = line.trim().split(":");
+ try {
+ 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)){
+ logger.info("Activating DG :" + line);
+ 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");
+ }
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ errors.add("Failed to Activate "+line + ", "+e.getMessage());
+ }
+ }
+ }
+ }
+ }else{
+ throw new Exception(activateFile + " is not a valid Activate file Path");
+ }
+ }else{
+ throw new Exception("Failed to initialise SvcLogicStore");
+ }
+
+ if(errors.size() > 0){
+ throw new Exception(errors.toString());
+ }
+ } catch (Exception e) {
+ logger.error(e.getMessage());
+ }
+ }
+
+
+ public static void main(String[] args) {
+ try {
+ String activateFile = null;
+ String propertyPath = null;
+
+ if(args != null && args.length >= 2){
+ activateFile = args[0];
+ propertyPath = args[1];
+ }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 {
+ System.exit(1);
+ }
+ }
}
diff --git a/appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGXMLGenerator.java b/appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGXMLGenerator.java
index 3ffef14fe..60fcd5ba8 100644
--- a/appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGXMLGenerator.java
+++ b/appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGXMLGenerator.java
@@ -34,95 +34,95 @@ import org.slf4j.LoggerFactory;
public class DGXMLGenerator {
- private final static Logger logger = LoggerFactory.getLogger(DGXMLGenerator.class);
-
- public static String STRING_ENCODING = "utf-8";
- public static String JS_INTERFACE_DG_CONVERTOR = "dgconverter";
- 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{
- ScriptEngineManager manager = new ScriptEngineManager();
- ScriptEngine engine = manager.getEngineByName("JavaScript");
- if (!(engine instanceof Invocable)) {
- logger.error("Invoking methods is not supported.");
- 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(js);
-
- Object dgconverter = engine.get(JS_INTERFACE_DG_CONVERTOR);
-
- List<File> files = new ArrayList<File>();
- if(dgconverter != null){
- File jsonPathFile = new File(jsonPath);
- if(jsonPathFile.isDirectory()){
- String[] extensions = new String[] { "json", "JSON" };
- files = (List<File>) FileUtils.listFiles(jsonPathFile, extensions, true);
- }else if(jsonPathFile.isFile()){
- files.add(jsonPathFile);
- }else{
- throw new Exception("Failed to get the nature of the JSON path :"+ jsonPath);
- }
-
- logger.info("JSON Files identified "+ files.size());
-
- if(files.size() > 0){
- boolean isXmlPathDeleted = FileUtils.deleteQuietly(new File(xmlpath));
- logger.info("Cleaning old DG XML under : " + xmlpath + ", delete status :" + isXmlPathDeleted);
-
- for (File file : files) {
- String dgJson = FileUtils.readFileToString(file,STRING_ENCODING);
- logger.info("Generating XML from :" + file.getName());
- String xmlFileName = xmlpath +"/"+file.getName().replace(".json", ".xml");
-
- Object dgXMl = inv.invokeMethod(dgconverter, JS_METHOD_GET_NODE_TO_XML, dgJson);
- // Write the XML File
- if(dgXMl != null){
- File xmlFile = new File(xmlFileName);
- FileUtils.writeStringToFile(xmlFile, dgXMl.toString(), STRING_ENCODING);
- logger.info("Generated XML File under :" + xmlFile.getCanonicalPath());
- }
- }
-
- }else{
- logger.info("No JSON Files to generate XML");
- }
- }else{
- logger.error("Couldn't get Java Script Engine..");
- }
- }catch (Exception e) {
- logger.error("Failed to generate generateXMLFromJSON :"+e.getMessage());
- }
- }
-
-
- public static void main(String[] args) {
- try {
- DGXMLGenerator application = new DGXMLGenerator();
- String jsonPath = null;
- 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){
- jsonPath = args[0];
- xmlPath = args[1];
- }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());
- e.printStackTrace();
- }
-
- }
+ private final static Logger logger = LoggerFactory.getLogger(DGXMLGenerator.class);
+
+ public static String STRING_ENCODING = "utf-8";
+ public static String JS_INTERFACE_DG_CONVERTOR = "dgconverter";
+ 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{
+ ScriptEngineManager manager = new ScriptEngineManager();
+ ScriptEngine engine = manager.getEngineByName("JavaScript");
+ if (!(engine instanceof Invocable)) {
+ logger.error("Invoking methods is not supported.");
+ 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(js);
+
+ Object dgconverter = engine.get(JS_INTERFACE_DG_CONVERTOR);
+
+ List<File> files = new ArrayList<File>();
+ if(dgconverter != null){
+ File jsonPathFile = new File(jsonPath);
+ if(jsonPathFile.isDirectory()){
+ String[] extensions = new String[] { "json", "JSON" };
+ files = (List<File>) FileUtils.listFiles(jsonPathFile, extensions, true);
+ }else if(jsonPathFile.isFile()){
+ files.add(jsonPathFile);
+ }else{
+ throw new Exception("Failed to get the nature of the JSON path :"+ jsonPath);
+ }
+
+ logger.info("JSON Files identified "+ files.size());
+
+ if(files.size() > 0){
+ boolean isXmlPathDeleted = FileUtils.deleteQuietly(new File(xmlpath));
+ logger.info("Cleaning old DG XML under : " + xmlpath + ", delete status :" + isXmlPathDeleted);
+
+ for (File file : files) {
+ String dgJson = FileUtils.readFileToString(file,STRING_ENCODING);
+ logger.info("Generating XML from :" + file.getName());
+ String xmlFileName = xmlpath +"/"+file.getName().replace(".json", ".xml");
+
+ Object dgXMl = inv.invokeMethod(dgconverter, JS_METHOD_GET_NODE_TO_XML, dgJson);
+ // Write the XML File
+ if(dgXMl != null){
+ File xmlFile = new File(xmlFileName);
+ FileUtils.writeStringToFile(xmlFile, dgXMl.toString(), STRING_ENCODING);
+ logger.info("Generated XML File under :" + xmlFile.getCanonicalPath());
+ }
+ }
+
+ }else{
+ logger.info("No JSON Files to generate XML");
+ }
+ }else{
+ logger.error("Couldn't get Java Script Engine..");
+ }
+ }catch (Exception e) {
+ logger.error("Failed to generate generateXMLFromJSON :"+e.getMessage());
+ }
+ }
+
+
+ public static void main(String[] args) {
+ try {
+ DGXMLGenerator application = new DGXMLGenerator();
+ String jsonPath = null;
+ 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){
+ jsonPath = args[0];
+ xmlPath = args[1];
+ }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());
+ e.printStackTrace();
+ }
+
+ }
}
diff --git a/appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGXMLLoad.java b/appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGXMLLoad.java
index 5e9673079..b7651bbe5 100644
--- a/appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGXMLLoad.java
+++ b/appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGXMLLoad.java
@@ -35,80 +35,74 @@ import org.openecomp.sdnc.sli.SvcLogicStore;
import org.openecomp.sdnc.sli.SvcLogicStoreFactory;
public class DGXMLLoad {
- private final static Logger logger = LoggerFactory.getLogger(DGXMLLoad.class);
- private final SvcLogicStore store;
- public static String STRING_ENCODING = "utf-8";
+ private final static Logger logger = LoggerFactory.getLogger(DGXMLLoad.class);
+ private final SvcLogicStore store;
+ public static String STRING_ENCODING = "utf-8";
- public DGXMLLoad(String propfile) throws Exception{
- if(StringUtils.isBlank(propfile)){
- throw new Exception(propfile + " Profile file is not defined");
- }
- this.store = SvcLogicStoreFactory.getSvcLogicStore(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);
+ }
- public void loadDGXMLFile(String dgXMLpath) throws SvcLogicException{
- if(dgXMLpath != null ){
- SvcLogicParser.load(dgXMLpath, this.store);
- }
- }
+ 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 *****************************");
- List<String> errors = new ArrayList<String>();
- if(this.store != null){
- File xmlDir = new File(xmlPath);
- 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{
- SvcLogicParser.load(file.getCanonicalPath(), this.store);
- }catch (Exception e) {
- errors.add("Failed to load XML "+file.getCanonicalPath() + ", Exception : "+e.getMessage());
- }
- }
- }else{
- throw new Exception(xmlPath + " is not a valid XML Directory");
- }
- }else{
- throw new Exception("Failed to initialise SvcLogicStore");
- }
+ private void loadDGXMLDir(String xmlPath) throws Exception {
+ try {
+ logger.info("******************** Loading DG into Database *****************************");
+ List<String> errors = new ArrayList<String>();
+ if(this.store != null){
+ File xmlDir = new File(xmlPath);
+ 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{
+ SvcLogicParser.load(file.getCanonicalPath(), this.store);
+ }catch (Exception e) {
+ errors.add("Failed to load XML "+file.getCanonicalPath() + ", Exception : "+e.getMessage());
+ }
+ }
+ }else{
+ throw new Exception(xmlPath + " is not a valid XML Directory");
+ }
+ }else{
+ throw new Exception("Failed to initialise SvcLogicStore");
+ }
- if(errors.size() > 0){
- throw new Exception(errors.toString());
- }
- } catch (Exception e) {
- logger.error(e.getMessage());
- }
- }
+ if(errors.size() > 0){
+ throw new Exception(errors.toString());
+ }
+ } catch (Exception e) {
+ logger.error(e.getMessage());
+ }
+ }
-
+ public static void main(String[] args) {
+ try {
+ String xmlPath = null;
+ String propertyPath = null;
+ if(args != null && args.length >= 2){
+ xmlPath = args[0];
+ propertyPath = args[1];
+ }else{
+ throw new Exception("Sufficient inputs for DGXMLLoadNActivate are missing <xmlpath> <dbPropertyfile>");
+ }
- public static void main(String[] args) {
- try {
- String xmlPath = null;
- String propertyPath = null;
-
- if(args != null && args.length >= 2){
- xmlPath = args[0];
- propertyPath = args[1];
- }else{
- throw new Exception("Sufficient inputs for DGXMLLoadNActivate are missing <xmlpath> <dbPropertyfile>");
- }
-
- //propertyPath = "/Users/bs2796/0Source/ecomp/bvc-3.2.2/others/properties/dblib.properties";
- //xmlPath = DGXMLLoadNActivate.class.getClassLoader().getResource(".").getPath() +"/xml" ;
-
- DGXMLLoad dgXMLLoadDB = new DGXMLLoad(propertyPath);
- dgXMLLoadDB.loadDGXMLDir(xmlPath);
- } catch (Exception e) {
- e.printStackTrace();
- }finally {
- System.exit(1);
- }
- }
+ DGXMLLoad dgXMLLoadDB = new DGXMLLoad(propertyPath);
+ dgXMLLoadDB.loadDGXMLDir(xmlPath);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }finally {
+ System.exit(1);
+ }
+ }
}
diff --git a/appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGXMLLoadNActivate.java b/appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGXMLLoadNActivate.java
index 1373143cf..f5eb2441f 100644
--- a/appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGXMLLoadNActivate.java
+++ b/appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGXMLLoadNActivate.java
@@ -36,133 +36,133 @@ import org.openecomp.sdnc.sli.SvcLogicStore;
import org.openecomp.sdnc.sli.SvcLogicStoreFactory;
public class DGXMLLoadNActivate {
- private final static Logger logger = LoggerFactory.getLogger(DGXMLLoadNActivate.class);
- private final SvcLogicStore store;
- public static String STRING_ENCODING = "utf-8";
-
- public DGXMLLoadNActivate(String propfile) throws Exception{
- if(StringUtils.isBlank(propfile)){
- throw new Exception(propfile + " Profile file is not defined");
- }
- this.store = SvcLogicStoreFactory.getSvcLogicStore(propfile);
- }
-
- 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 *****************************");
- List<String> errors = new ArrayList<String>();
- if(this.store != null){
- File xmlDir = new File(xmlPath);
- 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{
- SvcLogicParser.load(file.getCanonicalPath(), this.store);
- }catch (Exception e) {
- errors.add("Failed to load XML "+file.getCanonicalPath() + ", Exception : "+e.getMessage());
- }
- }
- }else{
- throw new Exception(xmlPath + " is not a valid XML Directory");
- }
- }else{
- throw new Exception("Failed to initialise SvcLogicStore");
- }
-
- if(errors.size() > 0){
- throw new Exception(errors.toString());
- }
- } catch (Exception e) {
- logger.error(e.getMessage());
- }
- }
-
- public void activateDg(String activateFilePath) throws Exception {
- logger.info("******************** Activating DG into Database *****************************");
- try {
- List<String> errors = new ArrayList<String>();
- 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 ){
- for (String line : fileLines) {
- if(line != null && ! line.trim().startsWith("#")){
- String lineArray[] = line.trim().split(":");
- try {
- 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)){
- logger.info("Activating DG :" + line);
- 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");
- }
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- errors.add("Failed to Activate "+line + ", "+e.getMessage());
- }
- }
- }
- }
- }else{
- throw new Exception(activateFile + " is not a valid Activate file Path");
- }
- }else{
- throw new Exception("Failed to initialise SvcLogicStore");
- }
-
- if(errors.size() > 0){
- throw new Exception(errors.toString());
- }
- } catch (Exception e) {
- logger.error(e.getMessage());
- }
- }
-
-
- public static void main(String[] args) {
- try {
- String xmlPath = null;
- String propertyPath = null;
- String activateFile = null;
-
- 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>");
- }
-
- //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 {
- System.exit(1);
- }
- }
+ private final static Logger logger = LoggerFactory.getLogger(DGXMLLoadNActivate.class);
+ private final SvcLogicStore store;
+ public static String STRING_ENCODING = "utf-8";
+
+ public DGXMLLoadNActivate(String propfile) throws Exception{
+ if(StringUtils.isBlank(propfile)){
+ throw new Exception(propfile + " Profile file is not defined");
+ }
+ this.store = SvcLogicStoreFactory.getSvcLogicStore(propfile);
+ }
+
+ 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 *****************************");
+ List<String> errors = new ArrayList<String>();
+ if(this.store != null){
+ File xmlDir = new File(xmlPath);
+ 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{
+ SvcLogicParser.load(file.getCanonicalPath(), this.store);
+ }catch (Exception e) {
+ errors.add("Failed to load XML "+file.getCanonicalPath() + ", Exception : "+e.getMessage());
+ }
+ }
+ }else{
+ throw new Exception(xmlPath + " is not a valid XML Directory");
+ }
+ }else{
+ throw new Exception("Failed to initialise SvcLogicStore");
+ }
+
+ if(errors.size() > 0){
+ throw new Exception(errors.toString());
+ }
+ } catch (Exception e) {
+ logger.error(e.getMessage());
+ }
+ }
+
+ public void activateDg(String activateFilePath) throws Exception {
+ logger.info("******************** Activating DG into Database *****************************");
+ try {
+ List<String> errors = new ArrayList<String>();
+ 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 ){
+ for (String line : fileLines) {
+ if(line != null && ! line.trim().startsWith("#")){
+ String lineArray[] = line.trim().split(":");
+ try {
+ 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)){
+ logger.info("Activating DG :" + line);
+ 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");
+ }
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ errors.add("Failed to Activate "+line + ", "+e.getMessage());
+ }
+ }
+ }
+ }
+ }else{
+ throw new Exception(activateFile + " is not a valid Activate file Path");
+ }
+ }else{
+ throw new Exception("Failed to initialise SvcLogicStore");
+ }
+
+ if(errors.size() > 0){
+ throw new Exception(errors.toString());
+ }
+ } catch (Exception e) {
+ logger.error(e.getMessage());
+ }
+ }
+
+
+ public static void main(String[] args) {
+ try {
+ String xmlPath = null;
+ String propertyPath = null;
+ String activateFile = null;
+
+ 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>");
+ }
+
+ //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 {
+ 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 7d34a45f9..e92efce90 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
@@ -20,6 +20,7 @@
# ============LICENSE_END=========================================================
###
+
export BVC_DIR=/opt/app/bvc
export DG_DIR=${BVC_DIR}/dg