summaryrefslogtreecommitdiffstats
path: root/appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGXMLLoad.java
diff options
context:
space:
mode:
Diffstat (limited to 'appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGXMLLoad.java')
-rw-r--r--appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGXMLLoad.java130
1 files changed, 62 insertions, 68 deletions
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);
+ }
+ }
}