|
3 | 3 | import static it.gov.pagopa.payments.utils.CommonUtil.deNull; |
4 | 4 |
|
5 | 5 | import com.fasterxml.jackson.core.JsonProcessingException; |
| 6 | +import com.fasterxml.jackson.databind.JsonNode; |
6 | 7 | import com.fasterxml.jackson.databind.ObjectMapper; |
| 8 | +import com.fasterxml.jackson.databind.node.ObjectNode; |
7 | 9 | import it.gov.pagopa.payments.exception.AppError; |
8 | 10 | import it.gov.pagopa.payments.model.ProblemJson; |
9 | 11 | import java.lang.reflect.Method; |
@@ -42,6 +44,7 @@ public class LoggingAspect { |
42 | 44 | public static final String REQUEST_ID = "requestId"; |
43 | 45 | public static final String OPERATION_ID = "operationId"; |
44 | 46 | public static final String ARGS = "args"; |
| 47 | + private static final ObjectMapper objectMapper = new ObjectMapper(); |
45 | 48 |
|
46 | 49 | final HttpServletRequest httRequest; |
47 | 50 |
|
@@ -92,6 +95,11 @@ private static Map<String, String> getParams(ProceedingJoinPoint joinPoint) { |
92 | 95 | var paramName = parameter.getName(); |
93 | 96 | var arg = joinPoint.getArgs()[i++]; |
94 | 97 | arg = jaxToString(arg); |
| 98 | + |
| 99 | + if(method.getName().equals("paSendRTV2") || method.getName().equals("paSendRT")) { |
| 100 | + arg = removeValueKey(deNull(arg)); |
| 101 | + } |
| 102 | + |
95 | 103 | params.put(paramName, deNull(arg)); |
96 | 104 | } |
97 | 105 | return params; |
@@ -183,4 +191,19 @@ private static Object jaxToString(Object arg) { |
183 | 191 | } |
184 | 192 | return arg; |
185 | 193 | } |
| 194 | + |
| 195 | + private static String removeValueKey(String json) { |
| 196 | + try { |
| 197 | + JsonNode rootNode = objectMapper.readTree(json); |
| 198 | + System.out.println(rootNode); |
| 199 | + |
| 200 | + if (rootNode.isObject()) { |
| 201 | + ((ObjectNode) rootNode).replace("value", null); |
| 202 | + } |
| 203 | + |
| 204 | + return objectMapper.writeValueAsString(rootNode); |
| 205 | + } catch (JsonProcessingException e) { |
| 206 | + return json; |
| 207 | + } |
| 208 | + } |
186 | 209 | } |
0 commit comments