From 39ad17e19c7cf49c1b3ef475d9cf9a4fd3f1b6e8 Mon Sep 17 00:00:00 2001 From: Arindam Mondal Date: Mon, 10 Jun 2019 17:26:09 +0900 Subject: Sonar fix use logger +) Add logger to report exception-->VTPModelBase.java ++) Format logger-->FileUtil.java Issue-ID: VNFSDK-416 Change-Id: I6e7b13fd504aba37ca6a08119f4f0ed2674d4243 Signed-off-by: Arindam Mondal --- .../java/org/onap/vnfsdk/marketplace/common/FileUtil.java | 14 +++++++------- .../src/main/java/org/onap/vtp/VTPModelBase.java | 5 +++++ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/FileUtil.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/FileUtil.java index 3ea5e410..7789e55c 100644 --- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/FileUtil.java +++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vnfsdk/marketplace/common/FileUtil.java @@ -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 Object readJsonDatafFromFile(String fileAbsPath, Class 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; } diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/VTPModelBase.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/VTPModelBase.java index f9ec6b5c..599fb774 100644 --- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/VTPModelBase.java +++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/VTPModelBase.java @@ -16,11 +16,15 @@ 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 "{}"; } } -- cgit 1.2.3-korg