diff --git a/build.gradle b/build.gradle index c035282..6603b18 100644 --- a/build.gradle +++ b/build.gradle @@ -37,7 +37,7 @@ dependencies { implementation 'io.netty:netty-resolver-dns-native-macos:4.1.86.Final:osx-aarch_64' - implementation 'no.fintlabs:fint-core-infra-models:1.1.1' + implementation 'no.fintlabs:fint-core-infra-models:1.1.2' implementation 'no.fintlabs:fint-core-adapter-common:0.1.3-rc-1' implementation "no.fint:fint-personvern-resource-model-java:${apiVersion}" implementation "no.fint:fint-felles-resource-model-java:${apiVersion}" diff --git a/src/main/java/no/fintlabs/model/personopplysning/event/PersonopplysningEventPublisher.java b/src/main/java/no/fintlabs/model/personopplysning/event/PersonopplysningEventPublisher.java index 5a95c6d..6cbceea 100644 --- a/src/main/java/no/fintlabs/model/personopplysning/event/PersonopplysningEventPublisher.java +++ b/src/main/java/no/fintlabs/model/personopplysning/event/PersonopplysningEventPublisher.java @@ -5,6 +5,7 @@ import no.fint.model.resource.personvern.kodeverk.PersonopplysningResource; import no.fintlabs.adapter.config.AdapterProperties; import no.fintlabs.adapter.events.EventPublisher; +import no.fintlabs.adapter.models.OperationType; import no.fintlabs.adapter.models.RequestFintEvent; import no.fintlabs.adapter.models.ResponseFintEvent; import no.fintlabs.adapter.models.SyncPageEntry; @@ -27,7 +28,7 @@ protected PersonopplysningEventPublisher(WebClient webClient, AdapterProperties } @Override - @Scheduled(initialDelay = 5000, fixedDelay = 50000) + @Scheduled(initialDelay = 5000, fixedDelay = 5000) public void doCheckForNewEvents() { checkForNewEvents(); } @@ -35,19 +36,22 @@ public void doCheckForNewEvents() { @Override protected void handleEvent(RequestFintEvent requestFintEvent, PersonopplysningResource personopplysningResource) { ResponseFintEvent response = createResponse(requestFintEvent); - if (response.getValue() == null) { - log.error("this bitch empty"); - } else if (personopplysningResourceValidator.isResourceValid(response.getValue().getResource())) { + response.setOperationType(OperationType.CREATE); + response.setValue(createSyncpageEntry(personopplysningResource)); + if (personopplysningResourceValidator.isResourceValid(personopplysningResource)) { PersonopplysningResource savedResource = repository.saveResources(response.getValue().getResource(), requestFintEvent); response.setValue(createSyncpageEntry(savedResource)); + submit(response); } else { response.setFailed(true); response.setErrorMessage("Failed to handle event"); + submit(response); } - submit(response); + log.info(response.getCorrId()); } private SyncPageEntry createSyncpageEntry(PersonopplysningResource savedResource) { return SyncPageEntry.of(savedResource.getSystemId().getIdentifikatorverdi(), savedResource); } + }