MODINVOSTO-216. Add old object for EDIT audit events for Invoice, Invoice Line#270
Merged
Conversation
Comment on lines
+80
to
+94
| <T> AuditEntityWrapper<T> decodePayload(String payload, Class<T> entityClass) { | ||
| var mapper = ObjectMapperTool.getMapper(); | ||
| try { | ||
| var wrapperType = mapper.getTypeFactory().constructParametricType(AuditEntityWrapper.class, entityClass); | ||
| AuditEntityWrapper<T> wrapper = mapper.readValue(payload, wrapperType); | ||
| if (wrapper.getEntity() != null) { | ||
| return wrapper; | ||
| } | ||
| } catch (Exception ignored) { | ||
| // fall through to legacy decoding | ||
| } | ||
| log.warn("decodePayload:: Falling back to legacy (bare-entity) outbox payload decoding"); | ||
| T entity = Json.decodeValue(payload, entityClass); | ||
| return AuditEntityWrapper.of(entity, null); | ||
| } |
Contributor
There was a problem hiding this comment.
I'd suggest injecting DatabindCodec and using it for decoding, as we usually copy our serialization and deserialization config to this codec during API initialization:
Suggested change
| <T> AuditEntityWrapper<T> decodePayload(String payload, Class<T> entityClass) { | |
| var mapper = ObjectMapperTool.getMapper(); | |
| try { | |
| var wrapperType = mapper.getTypeFactory().constructParametricType(AuditEntityWrapper.class, entityClass); | |
| AuditEntityWrapper<T> wrapper = mapper.readValue(payload, wrapperType); | |
| if (wrapper.getEntity() != null) { | |
| return wrapper; | |
| } | |
| } catch (Exception ignored) { | |
| // fall through to legacy decoding | |
| } | |
| log.warn("decodePayload:: Falling back to legacy (bare-entity) outbox payload decoding"); | |
| T entity = Json.decodeValue(payload, entityClass); | |
| return AuditEntityWrapper.of(entity, null); | |
| } | |
| private <T> AuditEntityWrapper<T> decodeOutboxPayload(String payload, Class<T> entityClass) { | |
| try { | |
| AuditEntityWrapper<T> wrapper = databindCodec.fromString(payload, AuditUtils.typeReference()); | |
| if (wrapper.entity() != null && entityClass.isAssignableFrom(wrapper.entity().getClass())) | |
| return wrapper; | |
| } catch (Exception ignored) { | |
| log.debug("decodeOutboxPayload:: Failed to decode payload: {}", payload); | |
| } | |
| log.info("decodeOutboxPayload:: Falling back to decode payload as {}", entityClass.getSimpleName()); | |
| T entity = databindCodec.fromString(payload, entityClass); | |
| return AuditEntityWrapper.of(entity); | |
| } |
AuditUtils.typeReference():
public static <T> TypeReference<AuditEntityWrapper<T>> typeReference() {
return new TypeReference<>() {};
}
Contributor
Author
There was a problem hiding this comment.
switched to DatabindCodec.mapper()
|
Saba-Zedginidze-EPAM
approved these changes
Jun 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Purpose
https://folio-org.atlassian.net/browse/MODINVOSTO-216
Approach
Provide a brief technical summary of the changes.
Testing
Payload for create events



Payload for edit events
Both Create and Edit events render good on UI as previously
Pre-Review Checklist