Skip to content

Commit

Permalink
update infra model and set value on response
Browse files Browse the repository at this point in the history
  • Loading branch information
Sander14121 committed Jul 12, 2024
1 parent cb4b93e commit 2ea9b39
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -27,27 +28,30 @@ protected PersonopplysningEventPublisher(WebClient webClient, AdapterProperties
}

@Override
@Scheduled(initialDelay = 5000, fixedDelay = 50000)
@Scheduled(initialDelay = 5000, fixedDelay = 5000)
public void doCheckForNewEvents() {
checkForNewEvents();
}

@Override
protected void handleEvent(RequestFintEvent requestFintEvent, PersonopplysningResource personopplysningResource) {
ResponseFintEvent<PersonopplysningResource> 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<PersonopplysningResource> createSyncpageEntry(PersonopplysningResource savedResource) {
return SyncPageEntry.of(savedResource.getSystemId().getIdentifikatorverdi(), savedResource);
}

}

0 comments on commit 2ea9b39

Please sign in to comment.