Fix sonars in policy-api
[policy/api.git] / main / src / main / java / org / onap / policy / api / main / parameters / ApiParameterHandler.java
index 4cee10a..019a012 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, 2021 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.parameters;
 
-import com.google.gson.Gson;
 import com.google.gson.GsonBuilder;
-import org.onap.policy.common.logging.flexlogger.FlexLogger;
-import org.onap.policy.common.logging.flexlogger.Logger;
-import org.onap.policy.common.parameters.GroupValidationResult;
-import org.onap.policy.api.main.PolicyApiException;
-import org.onap.policy.api.main.startstop.ApiCommandLineArguments;
-
 import java.io.FileReader;
+import org.onap.policy.api.main.exception.PolicyApiException;
+import org.onap.policy.api.main.startstop.ApiCommandLineArguments;
+import org.onap.policy.common.parameters.ValidationResult;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * This class handles reading, parsing and validating of policy api parameters from JSON files.
  */
 public class ApiParameterHandler {
-    private static final Logger LOGGER = FlexLogger.getLogger(ApiParameterHandler.class);
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(ApiParameterHandler.class);
 
     /**
      * Read the parameters from the parameter file.
@@ -50,13 +52,12 @@ public class ApiParameterHandler {
         // Read the parameters
         try {
             // Read the parameters from JSON using Gson
-            final Gson gson = new GsonBuilder().create();
+            final var gson = new GsonBuilder().create();
             apiParameterGroup = gson.fromJson(new FileReader(arguments.getFullConfigurationFilePath()),
                     ApiParameterGroup.class);
         } catch (final Exception e) {
             final String errorMessage = "error reading parameters from \"" + arguments.getConfigurationFilePath()
                     + "\"\n" + "(" + e.getClass().getSimpleName() + "):" + e.getMessage();
-            LOGGER.error(errorMessage, e);
             throw new PolicyApiException(errorMessage, e);
         }
 
@@ -68,7 +69,7 @@ public class ApiParameterHandler {
         }
 
         // validate the parameters
-        final GroupValidationResult validationResult = apiParameterGroup.validate();
+        final ValidationResult validationResult = apiParameterGroup.validate();
         if (!validationResult.isValid()) {
             String returnMessage =
                     "validation error(s) on parameters from \"" + arguments.getConfigurationFilePath() + "\"\n";