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/.gitignore8
-rw-r--r--appc-directed-graph/dg-loader/features/.gitignore8
-rw-r--r--appc-directed-graph/dg-loader/features/pom.xml104
-rw-r--r--appc-directed-graph/dg-loader/features/src/main/resources/features.xml39
-rw-r--r--appc-directed-graph/dg-loader/pom.xml77
-rw-r--r--appc-directed-graph/dg-loader/provider/.gitignore8
-rw-r--r--appc-directed-graph/dg-loader/provider/pom.xml126
-rw-r--r--appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGLoaderActivator.java58
-rw-r--r--appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGXMLActivate.java128
-rw-r--r--appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGXMLGenerator.java128
-rw-r--r--appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGXMLLoad.java114
-rw-r--r--appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGXMLLoadNActivate.java168
-rw-r--r--appc-directed-graph/dg-loader/provider/src/main/resources/adaptor.properties25
-rw-r--r--appc-directed-graph/dg-loader/provider/src/main/resources/js/dg_xml2json.js165
-rw-r--r--appc-directed-graph/dg-loader/provider/src/main/resources/scripts/dg_load_activate.sh49
15 files changed, 1205 insertions, 0 deletions
diff --git a/appc-directed-graph/dg-loader/.gitignore b/appc-directed-graph/dg-loader/.gitignore
new file mode 100644
index 000000000..841e8d948
--- /dev/null
+++ b/appc-directed-graph/dg-loader/.gitignore
@@ -0,0 +1,8 @@
+# Eclipse
+.classpath
+.project
+.settings/
+
+# Maven
+log/
+target/
diff --git a/appc-directed-graph/dg-loader/features/.gitignore b/appc-directed-graph/dg-loader/features/.gitignore
new file mode 100644
index 000000000..841e8d948
--- /dev/null
+++ b/appc-directed-graph/dg-loader/features/.gitignore
@@ -0,0 +1,8 @@
+# Eclipse
+.classpath
+.project
+.settings/
+
+# Maven
+log/
+target/
diff --git a/appc-directed-graph/dg-loader/features/pom.xml b/appc-directed-graph/dg-loader/features/pom.xml
new file mode 100644
index 000000000..cc44b3020
--- /dev/null
+++ b/appc-directed-graph/dg-loader/features/pom.xml
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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>
+ <parent>
+ <groupId>org.openecomp.appc.plugins</groupId>
+ <artifactId>dg-loader</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>dg-loader-features</artifactId>
+ <name>Directed Graph Loader - Features</name>
+
+ <packaging>jar</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.appc.plugins</groupId>
+ <artifactId>dg-loader-provider</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <version>2.6</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>features-mdsal</artifactId>
+ <version>${odl.mdsal.version}</version>
+ <classifier>features</classifier>
+ <type>xml</type>
+
+ <scope>runtime</scope>
+ </dependency>
+
+
+ <!-- dependency for opendaylight-karaf-empty for use by testing -->
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>opendaylight-karaf-empty</artifactId>
+ <version>${odl.karaf.empty.distro.version}</version>
+ <type>zip</type>
+ </dependency>
+
+
+ <dependency>
+ <!-- Required for launching the feature tests -->
+ <groupId>org.opendaylight.odlparent</groupId>
+ <artifactId>features-test</artifactId>
+ <version>${odl.commons.opendaylight.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <resources>
+ <resource>
+ <filtering>true</filtering>
+ <directory>src/main/resources</directory>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-resources-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>filter</id>
+ <goals>
+ <goal>resources</goal>
+ </goals>
+ <phase>generate-resources</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-artifacts</id>
+ <goals>
+ <goal>attach-artifact</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <artifacts>
+ <artifact>
+ <file>${project.build.directory}/classes/${features.file}</file>
+ <type>xml</type>
+ <classifier>features</classifier>
+ </artifact>
+ </artifacts>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
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
new file mode 100644
index 000000000..2d4a65438
--- /dev/null
+++ b/appc-directed-graph/dg-loader/features/src/main/resources/features.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ ONAP : APP-C
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ ================================================================================
+ 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.
+ ============LICENSE_END=========================================================
+ -->
+
+
+<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">
+
+ <repository>mvn:org.opendaylight.mdsal/features-mdsal/${odl.mdsal.version}/xml/features</repository>
+ <feature name='sdnc-dg-loader' description="SDNC DG Loader"
+ version='${project.version}'>
+ <!-- Most applications will have a dependency on the ODL MD-SAL Broker -->
+ <feature version="${odl.controller.mdsal.version}">odl-mdsal-broker</feature>
+ <feature version='${openecomp.sdnc.sli.version}'>sdnc-sli</feature>
+ <bundle>mvn:commons-lang/commons-lang/2.6</bundle>
+ <bundle>wrap:mvn:com.att.eelf/eelf-core/${eelf.version}</bundle>
+ <bundle>mvn:ch.qos.logback/logback-core/${logback.version}</bundle>
+ <bundle>mvn:ch.qos.logback/logback-classic/${logback.version}</bundle>
+ <bundle>mvn:org.openecomp.appc.plugins/dg-loader-provider/${project.version}</bundle>
+ </feature>
+</features>
diff --git a/appc-directed-graph/dg-loader/pom.xml b/appc-directed-graph/dg-loader/pom.xml
new file mode 100644
index 000000000..557969331
--- /dev/null
+++ b/appc-directed-graph/dg-loader/pom.xml
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+ <parent>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-directed-graph</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.openecomp.appc.plugins</groupId>
+ <artifactId>dg-loader</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+
+ <name>Directed Graph Loader Node</name>
+ <description>Common Utilities for DG</description>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <java.version.source>1.8</java.version.source>
+ <java.version.target>1.8</java.version.target>
+ <odl.mdsal.version>2.1.1-Boron-SR1</odl.mdsal.version>
+ <odl.controller.mdsal.version>1.4.1-Boron-SR1</odl.controller.mdsal.version>
+ <logback.version>1.1.1</logback.version>
+ <common.collections.version>3.2.1</common.collections.version>
+ <common.io.version>2.5</common.io.version>
+ <jettison.version>1.3.7</jettison.version>
+ <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>
+ </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>
+ </modules>
+</project>
diff --git a/appc-directed-graph/dg-loader/provider/.gitignore b/appc-directed-graph/dg-loader/provider/.gitignore
new file mode 100644
index 000000000..841e8d948
--- /dev/null
+++ b/appc-directed-graph/dg-loader/provider/.gitignore
@@ -0,0 +1,8 @@
+# Eclipse
+.classpath
+.project
+.settings/
+
+# Maven
+log/
+target/
diff --git a/appc-directed-graph/dg-loader/provider/pom.xml b/appc-directed-graph/dg-loader/provider/pom.xml
new file mode 100644
index 000000000..3bd0ae9d2
--- /dev/null
+++ b/appc-directed-graph/dg-loader/provider/pom.xml
@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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>
+ <parent>
+ <groupId>org.openecomp.appc.plugins</groupId>
+ <artifactId>dg-loader</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>dg-loader-provider</artifactId>
+ <packaging>bundle</packaging>
+ <name>Directed Graph Loader - Provider</name>
+ <url>http://maven.apache.org</url>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.sdnc.core</groupId>
+ <artifactId>sli-provider</artifactId>
+ <version>${sdnctl.sli.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <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>
+ <version>${bundle.plugin.version}</version>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>org.openecomp.sdnc.dg.loader</Bundle-SymbolicName>
+ <Bundle-Activator>org.openecomp.sdnc.dg.loader.DGLoaderActivator</Bundle-Activator>
+ <Export-Package>org.openecomp.sdnc.dg.loader</Export-Package>
+ <Import-Package>*</Import-Package>
+ <DynamicImport-Package>*</DynamicImport-Package>
+ </instructions>
+ <manifestLocation>${project.basedir}/src/main/resources/META-INF</manifestLocation>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <version>2.4.1</version>
+ <configuration>
+ <descriptorRefs>
+ <descriptorRef>jar-with-dependencies</descriptorRef>
+ </descriptorRefs>
+ <finalName>dg-loader</finalName>
+ <archive>
+ <manifest>
+ <mainClass>org.openecomp.sdnc.dg.loader.DGXMLLoadNActivate</mainClass>
+ </manifest>
+ </archive>
+ <attach>false</attach>
+ </configuration>
+ <executions>
+ <execution>
+ <id>make-assembly</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+ <pluginManagement>
+ <plugins>
+ <!--This plugin's configuration is used to store Eclipse m2e settings
+ only. It has no influence on the Maven build itself. -->
+ <plugin>
+ <groupId>org.eclipse.m2e</groupId>
+ <artifactId>lifecycle-mapping</artifactId>
+ <version>1.0.0</version>
+ <configuration>
+ <lifecycleMappingMetadata>
+ <pluginExecutions>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>
+ com.brocade.developer
+ </groupId>
+ <artifactId>
+ providermodule-plugin
+ </artifactId>
+ <versionRange>
+ [1.2.0.100-SNAPSHOT,)
+ </versionRange>
+ <goals>
+ <goal>process</goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <ignore />
+ </action>
+ </pluginExecution>
+ </pluginExecutions>
+ </lifecycleMappingMetadata>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+</project>
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
new file mode 100644
index 000000000..dd56e6cc1
--- /dev/null
+++ b/appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGLoaderActivator.java
@@ -0,0 +1,58 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.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{
+
+ private List<ServiceRegistration> registrations = new LinkedList<ServiceRegistration>();
+
+
+ private static final EELFLogger log = EELFManager.getInstance().getLogger(DGLoaderActivator.class);
+
+ @Override
+ public void start(BundleContext ctx) throws Exception
+ {
+
+
+
+ }
+ @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
new file mode 100644
index 000000000..1cb446a83
--- /dev/null
+++ b/appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGXMLActivate.java
@@ -0,0 +1,128 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.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.openecomp.sdnc.sli.SvcLogicGraph;
+import org.openecomp.sdnc.sli.SvcLogicStore;
+import org.openecomp.sdnc.sli.SvcLogicStoreFactory;
+import org.slf4j.Logger;
+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);
+ }
+ }
+
+
+
+}
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
new file mode 100644
index 000000000..3ffef14fe
--- /dev/null
+++ b/appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGXMLGenerator.java
@@ -0,0 +1,128 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.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;
+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();
+ }
+
+ }
+
+}
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
new file mode 100644
index 000000000..5e9673079
--- /dev/null
+++ b/appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGXMLLoad.java
@@ -0,0 +1,114 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.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.openecomp.sdnc.sli.SvcLogicException;
+import org.openecomp.sdnc.sli.SvcLogicParser;
+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";
+
+ 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);
+ }
+ }
+
+ 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 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);
+ }
+ }
+
+}
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
new file mode 100644
index 000000000..1373143cf
--- /dev/null
+++ b/appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGXMLLoadNActivate.java
@@ -0,0 +1,168 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.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.openecomp.sdnc.sli.SvcLogicException;
+import org.openecomp.sdnc.sli.SvcLogicGraph;
+import org.openecomp.sdnc.sli.SvcLogicParser;
+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);
+ }
+ }
+
+}
diff --git a/appc-directed-graph/dg-loader/provider/src/main/resources/adaptor.properties b/appc-directed-graph/dg-loader/provider/src/main/resources/adaptor.properties
new file mode 100644
index 000000000..367d25db0
--- /dev/null
+++ b/appc-directed-graph/dg-loader/provider/src/main/resources/adaptor.properties
@@ -0,0 +1,25 @@
+###
+# ============LICENSE_START=======================================================
+# ONAP : APP-C
+# ================================================================================
+# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+# ================================================================================
+# 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.
+# ============LICENSE_END=========================================================
+###
+
+adaptorName=
+vSphere.url=
+vSphere.user=
+vSphere.passwd=
+org.xml.sax.driver=org.apache.xerces.parsers.SAXParser
diff --git a/appc-directed-graph/dg-loader/provider/src/main/resources/js/dg_xml2json.js b/appc-directed-graph/dg-loader/provider/src/main/resources/js/dg_xml2json.js
new file mode 100644
index 000000000..052d75d21
--- /dev/null
+++ b/appc-directed-graph/dg-loader/provider/src/main/resources/js/dg_xml2json.js
@@ -0,0 +1,165 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+
+var dgconverter = new Object();
+
+dgconverter.getNodeToXml = function (inputNodeSet) {
+ var exportableNodeSet = JSON.parse(inputNodeSet);
+ //uses inputNodeSet if passed otherwise build the latest nodeSet
+
+ //$("#btn-deploy").removeClass("disabled");
+
+ function getDgStartNode(nodeList) {
+ for (var i = 0; i < nodeList.length; i++) {
+ if (nodeList[i].type == 'dgstart' && nodeList[i].wires != null && nodeList[i].wires != undefined) {
+ return nodeList[i];
+ }
+ }
+ return null;
+ }
+
+
+ function getNode(id) {
+ for (var i = 0; i < exportableNodeSet.length; i++) {
+ if (exportableNodeSet[i].id == id) {
+ return exportableNodeSet[i];
+ }
+ }
+ return null;
+ }
+
+ function getStartTag(node) {
+ var startTag = "";
+ var xmlStr = "";
+ if (node != null && node.type != 'dgstart') {
+ xmlStr = node.xml;
+ var regex = /(<)([\w-]+)(.*)?/;
+ var match = regex.exec(xmlStr);
+ if (match != null) {
+ if (match[1] != undefined && match[2] != undefined) {
+ startTag = match[2];
+ }
+ } else {
+ console.log("startTag not found.");
+ }
+ }
+ return startTag;
+ }
+
+ // if (inputNodeSet == null || inputNodeSet == undefined) {
+ // exportableNodeSet = getCurrentFlowNodeSet();
+ // } else {
+ // exportableNodeSet = JSON.parse(inputNodeSet);
+ // }
+ var dgstartNode = getDgStartNode(exportableNodeSet);
+
+ var level = 0;
+ var fullXmlStr = "";
+
+ printXml(dgstartNode);
+
+
+ function printXml(node) {
+ var xmlStr = "";
+ var startTag = "";
+ if (node != null && node.type != 'dgstart') {
+ var comments = node.comments;
+ if (comments != null && comments != "") {
+ //if xml comments field already has the <!-- and --> remove them
+ comments = comments.replace("<!--", "");
+ comments = comments.replace("-->", "");
+ xmlStr = "<!--" + comments + "-->";
+ }
+ xmlStr += node.xml;
+ startTag = getStartTag(node);
+ //special handling for break node
+ if(xmlStr != undefined && xmlStr != null && xmlStr.trim() == "<break>"){
+ fullXmlStr += "<break/>";
+ }else{
+ fullXmlStr +=xmlStr;
+ }
+ /*
+ if(level > 0){
+ var spacing = Array(level).join(" ");
+ xmlStr=xmlStr.replace(/\n/g,spacing);
+ fullXmlStr +=xmlStr;
+
+ console.log(xmlStr);
+ }else{
+ fullXmlStr +=xmlStr;
+ console.log(xmlStr);
+ }
+ */
+ }
+
+ //console.log("startTag:" + startTag);
+
+ var wiredNodes = [];
+ var wiredNodesArr = [];
+ if (node != null && node.wires != null && node.wires[0] != null && node.wires[0] != undefined && node.wires[0].length > 0) {
+ wiredNodes = node.wires[0];
+ //console.log("Before sort");
+ for (var k = 0; wiredNodes != undefined && wiredNodes != null && k < wiredNodes.length; k++) {
+ wiredNodesArr.push(getNode(wiredNodes[k]));
+ }
+ //console.dir(wiredNodesArr);
+ //sort based on y position
+ wiredNodesArr.sort(function (a, b) {
+ return a.y - b.y;
+ });
+ //console.log("After sort");
+ //console.dir(wiredNodesArr);
+ }
+
+ for (var k = 0; wiredNodesArr != null && k < wiredNodesArr.length; k++) {
+ level++;
+ var nd = wiredNodesArr[k];
+ printXml(nd);
+ }
+
+ //append end tag
+ if (startTag != "") {
+ if(startTag != "break"){
+ fullXmlStr += "</" + startTag + ">";
+ }
+ /*
+ if(level >0){
+ var spacing = Array(level).join(" ");
+ fullXmlStr += spacing + "</" + startTag + ">";
+ console.log(spacing + "</" + startTag + ">");
+ }else{
+ fullXmlStr += "</" + startTag + ">";
+ console.log("</" + startTag + ">");
+ }
+ */
+ }
+
+ /*if(level>0){
+ level=level-1;
+ }
+ */
+ //console.log("endTag:" + startTag);
+ //console.log("xml:" + fullXmlStr);
+ }
+ //console.log("fullXmlStr:" + fullXmlStr);
+ return fullXmlStr;
+};
+
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
new file mode 100644
index 000000000..7d34a45f9
--- /dev/null
+++ b/appc-directed-graph/dg-loader/provider/src/main/resources/scripts/dg_load_activate.sh
@@ -0,0 +1,49 @@
+#!/bin/bash
+
+###
+# ============LICENSE_START=======================================================
+# ONAP : APP-C
+# ================================================================================
+# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+# ================================================================================
+# 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.
+# ============LICENSE_END=========================================================
+###
+
+export BVC_DIR=/opt/app/bvc
+export DG_DIR=${BVC_DIR}/dg
+
+if (( "$#" != 1 ))
+then
+ echo "DG JSON Directory is Missing"
+exit 1
+fi
+
+export DG_JSON_DIR=$1
+echo "Processing DG JSON directory : ${DG_JSON_DIR}"
+
+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
+
+################## 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
+
+################## 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
+
+exit 0