Skip to content

Commit

Permalink
dont send entity if the operationType is validate
Browse files Browse the repository at this point in the history
  • Loading branch information
hknots committed Nov 28, 2024
1 parent d304cb3 commit dbc94a4
Showing 1 changed file with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

}

0 comments on commit dbc94a4

Please sign in to comment.