From d7400624fa9b9daca77e16f4651822b2205020c2 Mon Sep 17 00:00:00 2001 From: akulikov Date: Tue, 30 May 2023 14:51:43 +0300 Subject: [PATCH] http://jira.mfd.msk:8088/browse/CLS-283 log unknown properties --- .../reports/services/ReportService.java | 21 +++++++++++++++++++ .../messaging/domain/BaseRequest.java | 17 +++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/clearing-parent/reports-service/src/main/java/ru/spcex/clearing/reports/services/ReportService.java b/clearing-parent/reports-service/src/main/java/ru/spcex/clearing/reports/services/ReportService.java index 3dac2987a..a90f6d274 100644 --- a/clearing-parent/reports-service/src/main/java/ru/spcex/clearing/reports/services/ReportService.java +++ b/clearing-parent/reports-service/src/main/java/ru/spcex/clearing/reports/services/ReportService.java @@ -118,6 +118,9 @@ public class ReportService extends QueueConsumer implements InitializingBean { if (requestInfoUpdate != null) return null; ReportRequest req = userRequest.getRequestPayload(); + + logUnknownProperties(userRequest); + log.debug("Create report type {}...", req.getReportId()); List> builders = reportBuildersWithoutParams.get( @@ -150,6 +153,9 @@ public class ReportService extends QueueConsumer implements InitializingBean { if (requestInfoUpdate != null) return null; ReportRequestWithSessionId req = userRequest.getRequestPayload(); + + logUnknownProperties(userRequest); + log.debug("Create report type {}...", req.getReportId()); List> builders = reportBuildersWithSessionIdParam.get( @@ -184,6 +190,9 @@ public class ReportService extends QueueConsumer implements InitializingBean { if (requestInfoUpdate != null) return null; ReportRequestWithSessionIdList req = userRequest.getRequestPayload(); + + logUnknownProperties(userRequest); + log.debug("Create report type {}...", req.getReportId()); List> builders = reportBuildersWithSessionIdListParam.get( @@ -218,6 +227,9 @@ public class ReportService extends QueueConsumer implements InitializingBean { if (requestInfoUpdate != null) return null; ReportRequestWithPeriod req = userRequest.getRequestPayload(); + + logUnknownProperties(userRequest); + log.debug("Create report type {}...", req.getReportId()); List> builders = reportBuildersWithPeriodParams.get( @@ -254,6 +266,8 @@ public class ReportService extends QueueConsumer implements InitializingBean { Long sessionId = userRequest.getRequestPayload().getSessionId(); + logUnknownProperties(userRequest); + int cntErrors = 0; List outFilenames = new ArrayList<>(); @@ -333,4 +347,11 @@ public class ReportService extends QueueConsumer implements InitializingBean { return null; } + private void logUnknownProperties(BaseRequest request) { + Map unknownProperties = request.getUnknownProperties(); + for (Map.Entry unknownProperty : unknownProperties.entrySet()) { + log.warn("Unknown property in request {} = {}", unknownProperty.getKey(), unknownProperty.getValue()); + } + } + } diff --git a/platform-parent/platform-messaging/src/main/java/ru/spcex/clearing/platform/messaging/domain/BaseRequest.java b/platform-parent/platform-messaging/src/main/java/ru/spcex/clearing/platform/messaging/domain/BaseRequest.java index 8fd44bef4..e97fb4513 100644 --- a/platform-parent/platform-messaging/src/main/java/ru/spcex/clearing/platform/messaging/domain/BaseRequest.java +++ b/platform-parent/platform-messaging/src/main/java/ru/spcex/clearing/platform/messaging/domain/BaseRequest.java @@ -1,9 +1,13 @@ package ru.spcex.clearing.platform.messaging.domain; +import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; import ru.spcex.platform.classes.base.interfaces.WithId; +import java.util.HashMap; +import java.util.Map; + public class BaseRequest implements WithId { /** * Идентификатор запроса @@ -27,9 +31,17 @@ public class BaseRequest implements WithId { @JsonProperty private Long userId; + @JsonIgnore + private final Map unknownProperties = new HashMap<>(); + @JsonIgnore private byte[] correlationId; + @JsonAnySetter + public void add(String key, Object value) { + unknownProperties.put(key, value); + } + @Override public Long getId() { return id; @@ -70,4 +82,9 @@ public class BaseRequest implements WithId { public void setCorrelationId(byte[] correlationId) { this.correlationId = correlationId; } + + public Map getUnknownProperties() { + return unknownProperties; + } + }