Skip to content

MODINVOSTO-216. Add old object for EDIT audit events for Invoice, Invoice Line#270

Merged
SerhiiNosko merged 4 commits into
masterfrom
MODINVOSTO-216
Jun 29, 2026
Merged

MODINVOSTO-216. Add old object for EDIT audit events for Invoice, Invoice Line#270
SerhiiNosko merged 4 commits into
masterfrom
MODINVOSTO-216

Conversation

@SerhiiNosko

@SerhiiNosko SerhiiNosko commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Purpose

https://folio-org.atlassian.net/browse/MODINVOSTO-216

Approach

Provide a brief technical summary of the changes.

Testing

Payload for create events
image
Payload for edit events
image
Both Create and Edit events render good on UI as previously
image


Pre-Review Checklist

  • Self-reviewed Code — Reviewed code for issues, unnecessary parts, and overall quality.
  • Change Notes — NEWS.md updated with clear description and issue key.
  • Testing — Confirmed changes were tested locally or on dev environment.
  • Logging: Confirmed that logging is appropriately handled.
  • Breaking Changes — Handled all required actions if changes affect API, DB, or interface versions.
    • API/schema changes
    • Interface version updates
    • DB schema changes / migration scripts
  • New Properties / Environment Variables — Updated README.md if new configs were added.

@SerhiiNosko SerhiiNosko requested a review from a team as a code owner June 26, 2026 11:54
@SerhiiNosko SerhiiNosko added the ai label Jun 26, 2026
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);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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<>() {};
  }

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

switched to DatabindCodec.mapper()

@sonarqubecloud

Copy link
Copy Markdown

@SerhiiNosko SerhiiNosko merged commit 24f6f24 into master Jun 29, 2026
18 checks passed
@SerhiiNosko SerhiiNosko deleted the MODINVOSTO-216 branch June 29, 2026 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants