Sonar fix use logger 28/89628/1
authorArindam Mondal <arind.mondal@samsung.com>
Mon, 10 Jun 2019 08:26:09 +0000 (17:26 +0900)
committerarind.mondal <arind.mondal@samsung.com>
Mon, 10 Jun 2019 08:26:35 +0000 (17:26 +0900)
+) Add logger to report exception-->VTPModelBase.java
++) Format logger-->FileUtil.java

Issue-ID: VNFSDK-416
Change-Id: I6e7b13fd504aba37ca6a08119f4f0ed2674d4243
Signed-off-by: Arindam Mondal <arind.mondal@samsung.com>
vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/FileUtil.java
vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/VTPModelBase.java

index 3ea5e41..7789e55 100644 (file)
@@ -87,13 +87,13 @@ public final class FileUtil {
                boolean isFileExist = file.exists();
                if (!isFileExist) {
                        if (isFileDeleted) {
-                               logger.info("delete " + hintInfo + file.getAbsolutePath());
+                               logger.info("delete {} {}" ,hintInfo, file.getAbsolutePath());
                        } else {
                                isFileDeleted = true;
-                               logger.info("file not exist. no need delete " + hintInfo + file.getAbsolutePath());
+                               logger.info("file not exist. no need delete {} {}" ,hintInfo , file.getAbsolutePath());
                        }
                } else {
-                       logger.info("fail to delete " + hintInfo + file.getAbsolutePath());
+                       logger.info("fail to delete {} {} " , hintInfo , file.getAbsolutePath());
                }
                return isFileDeleted;
        }
@@ -151,7 +151,7 @@ public final class FileUtil {
        }
 
        public static boolean writeJsonDatatoFile(String fileAbsPath, Object obj) {
-               logger.info("Write JsonData to file :" + fileAbsPath);
+               logger.info("Write JsonData to file : {} " , fileAbsPath);
 
                boolean bResult = false;
                if (checkFileExists(fileAbsPath)) {
@@ -174,11 +174,11 @@ public final class FileUtil {
 
        public static <T> Object readJsonDatafFromFile(String fileAbsPath, Class<T> clazz) {
                if (!checkFileExists(fileAbsPath)) {
-                       logger.info("read JsonData from file , file not found :" + fileAbsPath);
+                       logger.info("read JsonData from file , file not found : {}" ,fileAbsPath);
                        return null;
                }
 
-               logger.info("read JsonData from file :" + fileAbsPath);
+               logger.info("read JsonData from file : {}" , fileAbsPath);
 
                T obj = null;
                ObjectMapper mapper = new ObjectMapper();
@@ -246,7 +246,7 @@ public final class FileUtil {
                }
 
                if (MAX_PACKAGE_SIZE < fileData.length()) {
-                       logger.error("File size is greater than 50 MB", fileData.length());
+                       logger.error("File size is greater than 50 MB {}", fileData.length());
                        return false;
                }
 
index f9ec6b5..599fb77 100644 (file)
 
 package org.onap.vtp;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import com.fasterxml.jackson.annotation.JsonInclude.Include;
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
 
 public class VTPModelBase {
+    public static final Logger logger = LoggerFactory.getLogger(VTPModelBase.class);
+
     public String toJsonString() {
         return toJsonString(this);
     }
@@ -32,6 +36,7 @@ public class VTPModelBase {
             objectMapper.setSerializationInclusion(Include.NON_EMPTY);
             return objectMapper.writeValueAsString(obj);
         } catch (JsonProcessingException e) {
+            logger.error("Exception while processing json {}", e.getMessage());
             return "{}";
         }
     }