Catalog alignment
[sdc.git] / asdctool / src / main / java / org / openecomp / sdc / asdctool / main / DataSchemaMenu.java
index d2d5e77..4b3496f 100644 (file)
@@ -35,67 +35,70 @@ public class DataSchemaMenu {
 
        private static Logger log = Logger.getLogger(DataSchemaMenu.class.getName());
 
-    public static void main(String[] args) {
+       public static void main(String[] args) {
 
                String operation = args[0];
 
-        String appConfigDir = args[1];
+               String appConfigDir = args[1];
 
-        if (args == null || args.length < 2) {
-            usageAndExit();
-        }
+               if (args == null || args.length < 2) {
+                       usageAndExit();
+               }
 
-        ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), appConfigDir);
-        ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
+               ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), appConfigDir);
+               ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
+
+               try {
 
         SdcSchemaBuilder sdcSchemaBuilder = new SdcSchemaBuilder(new SdcSchemaUtils(),
             ConfigurationManager.getConfigurationManager().getConfiguration()::getCassandraConfig);
 
-        switch (operation.toLowerCase()) {
-            case "create-cassandra-structures":
-                log.debug("Start create cassandra keyspace, tables and indexes");
+                       switch (operation.toLowerCase()) {
+                       case "create-cassandra-structures":
+                               log.debug("Start create cassandra keyspace, tables and indexes");
                 if (sdcSchemaBuilder.createSchema()) {
-                    log.debug("create cassandra keyspace, tables and indexes successfull");
-                    System.exit(0);
-                } else {
-                    log.debug("create cassandra keyspace, tables and indexes failed");
-                    System.exit(2);
-                }
-                break;
+                                       log.debug("create cassandra keyspace, tables and indexes successfull");
+                                       System.exit(0);
+                               } else {
+                                       log.debug("create cassandra keyspace, tables and indexes failed");
+                                       System.exit(2);
+                               }
             case "create-janusgraph-structures":
                 log.debug("Start create janusgraph keyspace");
                 String janusGraphCfg = 2 == args.length ? configurationManager.getConfiguration().getJanusGraphCfgFile() : args[2];
                 if (JanusGraphInitializer.createGraph(janusGraphCfg)) {
                     log.debug("create janusgraph keyspace successfull");
-                    System.exit(0);
-                } else {
+                                       System.exit(0);
+                               } else {
                     log.debug("create janusgraph keyspace failed");
-                    System.exit(2);
-                }
-                break;
-            case "clean-cassndra":
-                log.debug("Start clean keyspace, tables");
+                                       System.exit(2);
+                               }
+                       case "clean-cassndra":
+                               log.debug("Start clean keyspace, tables");
                 if (sdcSchemaBuilder.deleteSchema()) {
-                    log.debug(" successfull");
-                    System.exit(0);
-                } else {
-                    log.debug(" failed");
-                    System.exit(2);
-                }
-                break;
-            default:
-                usageAndExit();
-                break;
-        }
-    }
+                                       log.debug(" successfull");
+                                       System.exit(0);
+                               } else {
+                                       log.debug(" failed");
+                                       System.exit(2);
+                               }
+                       default:
+                               usageAndExit();
+                       }
+               } catch (Throwable t) {
+                       t.printStackTrace();
+                       log.debug("create cassandra keyspace, tables and indexes failed");
+                       System.exit(3);
+               }
+       }
 
-    private static void usageAndExit() {
-        DataSchemeUsage();
-        System.exit(1);
-    }
+       private static void usageAndExit() {
+               DataSchemeUsage();
+               System.exit(1);
+       }
 
-    private static void DataSchemeUsage() {
-        System.out.println("Usage: create-cassandra-structures <configuration dir> ");
+       private static void DataSchemeUsage() {
+               System.out.println("Usage: create-cassandra-structures <configuration dir> ");
         System.out.println("Usage: create-janusgraph-structures <configuration dir> ");
-    }
+       }
 }