Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
event type fra header?
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-olaveide committed May 25, 2023
1 parent 0cb696b commit 399d82c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ package no.nav.aap.api.søknad.mellomlagring
import com.fasterxml.jackson.databind.ObjectMapper
import com.google.cloud.spring.pubsub.support.BasicAcknowledgeablePubsubMessage
import com.google.cloud.spring.pubsub.support.GcpPubSubHeaders.*
import com.google.cloud.storage.NotificationInfo.EventType
import com.google.cloud.storage.NotificationInfo.EventType.OBJECT_DELETE
import com.google.cloud.storage.NotificationInfo.EventType.OBJECT_FINALIZE
import com.nimbusds.openid.connect.sdk.claims.LogoutTokenClaimsSet.EVENT_TYPE
import org.springframework.integration.annotation.Transformer
import org.springframework.messaging.handler.annotation.Header
import no.nav.aap.api.søknad.mellomlagring.GCPBucketEventTransformer.GCPEventType.ENDELIG_SLETTET
Expand All @@ -26,12 +24,13 @@ class GCPBucketEventTransformer(private val mapper: ObjectMapper) {

@Transformer
fun payload(@Header(ORIGINAL_MESSAGE) msg : BasicAcknowledgeablePubsubMessage) =
msg.pubsubMessage.let {
val md = it.metadata(mapper)
log.trace("Metadata er {}", md)
when (it.eventType()) {
OBJECT_FINALIZE -> if (it.førstegangsOpprettelse()) MellomlagringsHendelse(OPPRETTET, md) else MellomlagringsHendelse(OPPDATERT, md)
OBJECT_DELETE -> if (it.endeligSlettet()) MellomlagringsHendelse(ENDELIG_SLETTET, md) else MellomlagringsHendelse(IGNORERT, md)
msg.pubsubMessage.let { m ->
val md = m.metadata(mapper).also {
log.trace("Metadata er {}", it)
}
when (m.eventType()) {
OBJECT_FINALIZE -> if (m.førstegangsOpprettelse()) MellomlagringsHendelse(OPPRETTET, md) else MellomlagringsHendelse(OPPDATERT, md)
OBJECT_DELETE -> if (m.endeligSlettet()) MellomlagringsHendelse(ENDELIG_SLETTET, md) else MellomlagringsHendelse(IGNORERT, md)
else -> MellomlagringsHendelse(IGNORERT)
}.also {
log.trace("Event oversatt til {}", it)
Expand Down

This file was deleted.

0 comments on commit 399d82c

Please sign in to comment.