Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Jackson object mapper, readers and writers at class level #7251

Merged
merged 12 commits into from
Jan 25, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void sendEvent(AssetConsumerOutTopicEvent event) throws InvalidParameterE
try
{
String eventString = OBJECT_WRITER.writeValueAsString(event);
super.sendEvent(eventString);
super.sendEvent(eventString).join();

if (super.auditLog != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void sendEvent(AssetManagerOutTopicEvent event) throws InvalidParameterEx
try
{
String eventString = OBJECT_WRITER.writeValueAsString(event);
super.sendEvent(eventString);
super.sendEvent(eventString).join();

if (super.auditLog != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void sendEvent(AssetOwnerOutTopicEvent event) throws InvalidParameterExce
try
{
String eventString = OBJECT_WRITER.writeValueAsString(event);
super.sendEvent(eventString);
super.sendEvent(eventString).join();

if (super.auditLog != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void sendEvent(CommunityProfileOutboundEvent event) throws InvalidParamet
try
{
String eventString = OBJECT_WRITER.writeValueAsString(event);
super.sendEvent(eventString);
super.sendEvent(eventString).join();

if (super.auditLog != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ public void sendEvent(DataEngineEventHeader event) throws InvalidParameterExcept

try
{

String eventString = OBJECT_WRITER.writeValueAsString(event);
super.sendEvent(eventString);
super.sendEvent(eventString).join();

if (super.auditLog != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void sendEvent(DataManagerOutboundEvent event) throws InvalidParameterExc
try
{
String eventString = OBJECT_WRITER.writeValueAsString(event);
super.sendEvent(eventString);
super.sendEvent(eventString).join();

if (super.auditLog != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void sendEvent(DigitalArchitectureOutTopicEvent event) throws InvalidPara
try
{
String eventString = OBJECT_WRITER.writeValueAsString(event);
super.sendEvent(eventString);
super.sendEvent(eventString).join();

if (super.auditLog != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void sendEvent(GovernanceEngineEvent event) throws InvalidParameterExcept
try
{
String eventString = OBJECT_WRITER.writeValueAsString(event);
super.sendEvent(eventString);
super.sendEvent(eventString).join();

if (super.auditLog != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void sendEvent(ITInfrastructureOutTopicEvent event) throws InvalidParamet
try
{
String eventString = OBJECT_WRITER.writeValueAsString(event);
super.sendEvent(eventString);
super.sendEvent(eventString).join();

if (super.auditLog != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void sendEvent(SecurityManagerOutTopicEvent event) throws InvalidParamete
try
{
String eventString = OBJECT_WRITER.writeValueAsString(event);
super.sendEvent(eventString);
super.sendEvent(eventString).join();

if (super.auditLog != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void sendEvent(SecurityOfficerEvent event) throws InvalidParameterExcepti
try
{
String eventString = OBJECT_WRITER.writeValueAsString(event);
super.sendEvent(eventString);
super.sendEvent(eventString).join();

if (super.auditLog != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void sendEvent(StewardshipActionOutTopicEvent event) throws InvalidParame
try
{
String eventString = OBJECT_WRITER.writeValueAsString(event);
super.sendEvent(eventString);
super.sendEvent(eventString).join();

if (super.auditLog != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -423,44 +423,7 @@ private CompletableFuture<Boolean> sendEvent(OMRSEventV1 event,
final String methodName = "sendEvent";
if (event != null)
{
try
{

String eventString = OBJECT_WRITER.writeValueAsString(event);

if ((auditLog != null) && (logEvent))
{
auditLog.logMessage(methodName,
OMRSAuditCode.OUTBOUND_TOPIC_EVENT.getMessageDefinition(event.getEventCategory().getName(),
topicName),
eventString);
}

for (OpenMetadataTopicConnector eventBusConnector : eventBusConnectors)
{
if (eventBusConnector != null)
{
eventBusConnector.sendEvent(eventString);
}
}
}
catch (ConnectorCheckedException exc)
{
log.debug("Unable to send event: " + exc.getMessage());

throw exc;
}
catch (Exception exc)
{
log.debug("Unexpected error sending event: " + exc.getMessage());

throw new ConnectorCheckedException(OMRSErrorCode.OMRS_TOPIC_SEND_EVENT_FAILED.getMessageDefinition(connectionName,
event.toString(),
exc.getMessage()),
this.getClass().getName(),
methodName,
exc);
}
return CompletableFuture.supplyAsync(() -> sendEventTask(event, logEvent));
}
else
{
Expand All @@ -480,7 +443,7 @@ private boolean sendEventTask(OMRSEventV1 event,
{
ObjectMapper objectMapper = new ObjectMapper();
lpalashevski marked this conversation as resolved.
Show resolved Hide resolved

String eventString = objectMapper.writeValueAsString(event);
String eventString = OBJECT_WRITER.writeValueAsString(event);

if ((auditLog != null) && logEvent)
{
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.