From dbc94a4dbbfa234b1395ef6d30a41a1d4d60997c Mon Sep 17 00:00:00 2001 From: Hknots Date: Thu, 28 Nov 2024 14:37:32 +0100 Subject: [PATCH] dont send entity if the operationType is validate --- .../event/response/ResponseEventService.java | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/main/java/no/fintlabs/provider/event/response/ResponseEventService.java b/src/main/java/no/fintlabs/provider/event/response/ResponseEventService.java index 141c55c..c820915 100644 --- a/src/main/java/no/fintlabs/provider/event/response/ResponseEventService.java +++ b/src/main/java/no/fintlabs/provider/event/response/ResponseEventService.java @@ -4,6 +4,7 @@ import lombok.extern.slf4j.Slf4j; import no.fintlabs.adapter.models.event.RequestFintEvent; import no.fintlabs.adapter.models.event.ResponseFintEvent; +import no.fintlabs.adapter.operation.OperationType; import no.fintlabs.kafka.entity.topic.EntityTopicNameParameters; import no.fintlabs.provider.datasync.EntityProducerKafka; import no.fintlabs.provider.event.request.RequestEventService; @@ -39,14 +40,21 @@ public void handleEvent(ResponseFintEvent responseFintEvent) throws NoRequestFou responseEventTopicProducer.sendEvent(responseFintEvent, requestEvent); - entityProducerKafka.sendEntity( - EntityTopicNameParameters.builder() - .orgId(responseFintEvent.getOrgId()) - .domainContext(FINT_CORE) - .resource("%s-%s-%s".formatted(requestEvent.getDomainName(), requestEvent.getPackageName(), requestEvent.getResourceName())) - .build(), - responseFintEvent.getValue(), - responseFintEvent.getCorrId() - ); + if (eventIsNotValidate(responseFintEvent)) { + entityProducerKafka.sendEntity( + EntityTopicNameParameters.builder() + .orgId(responseFintEvent.getOrgId()) + .domainContext(FINT_CORE) + .resource("%s-%s-%s".formatted(requestEvent.getDomainName(), requestEvent.getPackageName(), requestEvent.getResourceName())) + .build(), + responseFintEvent.getValue(), + responseFintEvent.getCorrId() + ); + } + } + + private boolean eventIsNotValidate(ResponseFintEvent responseFintEvent) { + return !responseFintEvent.getOperationType().equals(OperationType.VALIDATE); } + }