Added changes to make the list of preloaded policy types configurable
[policy/api.git] / main / src / main / java / org / onap / policy / api / main / startstop / Main.java
index a533bed..23dcd26 100644 (file)
@@ -1,6 +1,9 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
+ * ONAP Policy API
+ * ================================================================================
+ * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (C) 2019 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.
 
 package org.onap.policy.api.main.startstop;
 
-import org.onap.policy.api.main.PolicyApiException;
-import org.onap.policy.common.logging.flexlogger.FlexLogger;
-import org.onap.policy.common.logging.flexlogger.Logger;
+import java.util.Arrays;
+import org.onap.policy.api.main.exception.PolicyApiException;
 import org.onap.policy.api.main.parameters.ApiParameterGroup;
 import org.onap.policy.api.main.parameters.ApiParameterHandler;
-
-import java.util.Arrays;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * This class initiates ONAP Policy Framework policy api.
  *
  */
 public class Main {
-    private static final Logger LOGGER = FlexLogger.getLogger(Main.class);
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(Main.class);
 
     // The policy api Activator that activates the policy api service
     private ApiActivator activator;
@@ -48,7 +51,7 @@ public class Main {
      */
     public Main(final String[] args) {
         final String argumentString = Arrays.toString(args);
-        LOGGER.info("Starting policy api service with arguments - " + argumentString);
+        LOGGER.info("Starting policy api service with arguments - {}", argumentString);
 
         // Check the arguments
         final ApiCommandLineArguments arguments = new ApiCommandLineArguments();
@@ -75,6 +78,14 @@ public class Main {
             return;
         }
 
+        // Initialize database
+        try {
+            new ApiDatabaseInitializer().initializeApiDatabase(parameterGroup);
+        } 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);
 
@@ -82,8 +93,7 @@ public class Main {
         try {
             activator.initialize();
         } catch (final PolicyApiException e) {
-            LOGGER.error("start of policy api service failed, used parameters are " + Arrays.toString(args),
-                    e);
+            LOGGER.error("start of policy api service failed, used parameters are {} ", argumentString, e);
             return;
         }