Preload policy types when api starts up
[policy/api.git] / main / src / main / java / org / onap / policy / api / main / startstop / Main.java
index 97d53ad..4a0fead 100644 (file)
@@ -1,7 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
- * ONAP Policy API 
- * ================================================================================ 
+ * ONAP Policy API
+ * ================================================================================
  * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
  * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
@@ -35,7 +35,7 @@ import org.slf4j.LoggerFactory;
  *
  */
 public class Main {
-    
+
     private static final Logger LOGGER = LoggerFactory.getLogger(Main.class);
 
     // The policy api Activator that activates the policy api service
@@ -78,6 +78,14 @@ public class Main {
             return;
         }
 
+        // Initialize database
+        try {
+            new ApiDatabaseInitializer().initializeApiDatabase(parameterGroup.getDatabaseProviderParameters());
+        } catch (final PolicyApiException e) {
+            LOGGER.error("Preloading policy types into DB failed", e);
+            return;
+        }
+
         // Now, create the activator for the policy api service
         activator = new ApiActivator(parameterGroup);