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;
}
}
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)) {
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();
}
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;
}
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);
}
objectMapper.setSerializationInclusion(Include.NON_EMPTY);
return objectMapper.writeValueAsString(obj);
} catch (JsonProcessingException e) {
+ logger.error("Exception while processing json {}", e.getMessage());
return "{}";
}
}