diff options
Diffstat (limited to 'ms_specific_proxyservice/src/main')
-rw-r--r-- | ms_specific_proxyservice/src/main/java/at/asitplus/eidas/specific/proxy/logger/AdvancedStatisticLogger.java | 45 |
1 files changed, 25 insertions, 20 deletions
diff --git a/ms_specific_proxyservice/src/main/java/at/asitplus/eidas/specific/proxy/logger/AdvancedStatisticLogger.java b/ms_specific_proxyservice/src/main/java/at/asitplus/eidas/specific/proxy/logger/AdvancedStatisticLogger.java index 55833b8b..1d7e1f73 100644 --- a/ms_specific_proxyservice/src/main/java/at/asitplus/eidas/specific/proxy/logger/AdvancedStatisticLogger.java +++ b/ms_specific_proxyservice/src/main/java/at/asitplus/eidas/specific/proxy/logger/AdvancedStatisticLogger.java @@ -36,6 +36,8 @@ import lombok.extern.slf4j.Slf4j; @Slf4j public class AdvancedStatisticLogger implements IStatisticLogger { + private static final String SUCCES_CODE = "success.00"; + private static final String SUCCES_MSG = "success"; private static final String DATEFORMATER = "yyyy.MM.dd-HH:mm:ss,SSS"; private static final String DEFAULT_NO_IDP_ID = "no idpId available"; @@ -58,6 +60,8 @@ public class AdvancedStatisticLogger implements IStatisticLogger { public void logSuccessOperation(IRequest protocolRequest, IAuthData authData, boolean isSsoSession) { final StatisticLogEntry entry = buildCoreEntry(protocolRequest); entry.setSuccess(SuccessEntry.builder() + .statusCode(SUCCES_CODE) + .statusMessage(SUCCES_MSG) .spSector(protocolRequest.getServiceProviderConfiguration().getAreaSpecificTargetIdentifier()) .spCountry(protocolRequest.getServiceProviderConfiguration().getConfigurationValue( MsProxyServiceConstants.CONIG_PROPS_CONNECTOR_COUNTRYCODE)) @@ -76,8 +80,19 @@ public class AdvancedStatisticLogger implements IStatisticLogger { @Override public void logErrorOperation(Throwable throwable, IRequest errorRequest) { - final StatisticLogEntry entry = buildCoreEntry(errorRequest); - entry.setError(new ErrorEntry(messageService.getResponseErrorCode(throwable), throwable.getMessage())); + final StatisticLogEntry entry = buildCoreEntry(errorRequest); + entry.setSuccess(SuccessEntry.builder() + .statusCode(messageService.getResponseErrorCode(throwable)) + .statusMessage(throwable.getMessage()) + .spSector(errorRequest.getServiceProviderConfiguration() != null + ? errorRequest.getServiceProviderConfiguration().getAreaSpecificTargetIdentifier() + : "") + .spCountry(errorRequest.getServiceProviderConfiguration() != null + ? errorRequest.getServiceProviderConfiguration().getConfigurationValue( + MsProxyServiceConstants.CONIG_PROPS_CONNECTOR_COUNTRYCODE) + : "") + .citizenCountryCode("AT") + .build()); writeEntryToLog(entry); } @@ -124,7 +139,7 @@ public class AdvancedStatisticLogger implements IStatisticLogger { @Getter @Setter @RequiredArgsConstructor - @JsonInclude(Include.NON_NULL) + @JsonInclude(Include.ALWAYS) private static class StatisticLogEntry { @JsonSerialize(using = LocalDateTimeSerializer.class) @@ -141,18 +156,21 @@ public class AdvancedStatisticLogger implements IStatisticLogger { @JsonProperty("result") private SuccessEntry success; - - @JsonProperty("error") - private ErrorEntry error; } @Getter @Setter @Builder - @JsonInclude(Include.NON_NULL) + @JsonInclude(Include.ALWAYS) private static class SuccessEntry { + @JsonProperty("code") + private final String statusCode; + + @JsonProperty("msg") + private final String statusMessage; + @JsonProperty("spSector") private final String spSector; @@ -166,17 +184,4 @@ public class AdvancedStatisticLogger implements IStatisticLogger { private final MandateProcess withMandates; } - - @Getter - @Setter - @RequiredArgsConstructor - private static class ErrorEntry { - - @JsonProperty("code") - private final String errorCode; - - @JsonProperty("msg") - private final String errorMessage; - - } } |