Sonar Fix- Main.java
[dmaap/dbcapi.git] / src / main / java / org / onap / dmaap / dbcapi / server / Main.java
index c3340e6..906337a 100644 (file)
@@ -24,6 +24,7 @@ import java.util.Properties;
 import java.util.UUID;
 
 import org.onap.dmaap.dbcapi.authentication.ApiPerms;
+import org.onap.dmaap.dbcapi.authentication.ApiPolicy;
 import org.onap.dmaap.dbcapi.database.DatabaseClass;
 import org.onap.dmaap.dbcapi.logging.*;
 import org.onap.dmaap.dbcapi.model.Dmaap;
@@ -61,7 +62,7 @@ public class Main extends BaseLoggingClass {
             MDC.put(MDC_SERVER_FQDN, InetAddress.getLocalHost().getHostName());
             MDC.put(MDC_SERVER_IP_ADDRESS, InetAddress.getLocalHost().getHostAddress());
         } catch (Exception e) {
-            e.printStackTrace();
+               errorLogger.error("Error while getting hostname or address", e);
         }
         MDC.put(MDC_INSTANCE_UUID, UUID.randomUUID().toString());
         MDC.put(MDC_ALERT_SEVERITY, "0");
@@ -97,7 +98,8 @@ public class Main extends BaseLoggingClass {
                // for fresh installs, we may come up with no dmaap name so need to have a way for Controller to talk to us
                Singleton<Dmaap> dmaapholder = DatabaseClass.getDmaap();
                String name = dmaapholder.get().getDmaapName();
-               if ( name == null || name.isEmpty()) {
+               ApiPolicy apiPolicy = new ApiPolicy();
+               if ( apiPolicy.getUseAuthClass() && (name == null || name.isEmpty())) {
                        ApiPerms p = new ApiPerms();
                        p.setBootMap();
                }