Added logging mechanism for user actions.
This commit is contained in:
@@ -5,20 +5,19 @@ import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Type;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.SecureRandom;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.NumberFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.DateTimeParseException;
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.itextpdf.styledxmlparser.jsoup.Jsoup;
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.PropertyAccessor;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import org.apache.commons.collections4.MapUtils;
|
||||
@@ -515,4 +514,36 @@ public class Utils {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String convertEntityToJsonForLogging(Object entity) {
|
||||
|
||||
if(entity == null){
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return mapper.writeValueAsString(entity);
|
||||
} catch (JsonProcessingException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@JsonIgnoreProperties({ "childEntities", "relatedData", "otherRelations" })
|
||||
private abstract static class IgnoreChildEntities {
|
||||
}
|
||||
|
||||
public static <T> T getClonedEntityForData(T entity) {
|
||||
|
||||
if (entity == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
String json = mapper.writeValueAsString(entity);
|
||||
@SuppressWarnings("unchecked") T clonedEntity = (T) mapper.readValue(json, entity.getClass());
|
||||
return clonedEntity;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException("Failed to clone entity", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user