Skip to content

Commit

Permalink
Skilete ut regel for inngang i egen modul.
Browse files Browse the repository at this point in the history
Konverterte enums til interface + object.
  • Loading branch information
nilsmsa committed Jun 28, 2024
1 parent 5c97829 commit 6f82afb
Show file tree
Hide file tree
Showing 93 changed files with 2,487 additions and 1,124 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/api-start-stopp.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
name: Api Start stopp
on:
push:
branches:
- main
paths:
- 'apps/api-start-stopp-perioder/**'
- 'lib/kafka-key-generator-client/**'
- 'domain/**'
- 'lib/**'
- '.github/workflows/api-start-stopp.yml'
- 'gradle/**'
- 'settings.gradle.kts'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/hendelselogg-backup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ on:
push:
paths:
- 'apps/hendelselogg-backup/**'
- 'lib/kafka/**'
- 'lib/hoplite-config/**'
- 'lib/**'
- 'domain/**'
- '.github/workflows/hendelselogg-backup.yaml'
- 'gradle/**'
- 'settings.gradle.kts'
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/hendelseprosessor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ name: Hendelseprosessor

on:
push:
branches:
- main
paths:
- 'apps/hendelseprosessor/**'
- 'lib/kafka-key-generator-client/**'
- 'lib/**'
- 'domain/**'
- '.github/workflows/hendelseprosessor.yaml'
- 'gradle/**'
- 'settings.gradle.kts'
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/utgang-formidlingsgruppe-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ name: Formidlingsgruppe - Utgang

on:
push:
branches:
- main
paths:
- 'apps/utgang-formidlingsgruppe/**'
- 'lib/kafka-key-generator-client/**'
- 'domain/main-avro-schema/**'
- 'lib/**'
- 'domain/**'
- '.github/workflows/utgang-formidlingsgruppe-deploy.yaml'
- 'gradle/**'
- 'settings.gradle.kts'
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/utgang-pdl-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ name: PDL - Utgang

on:
push:
branches:
- main
paths:
- 'apps/utgang-pdl/**'
- '.github/workflows/utgang-pdl-deploy.yaml'
- 'lib/kafka-key-generator-client/**'
- 'domain/main-avro-schema-classes/**'
- 'lib/**'
- 'domain/**'
- 'gradle/**'
- 'settings.gradle.kts'
- 'gradle.properties'
Expand Down
1 change: 1 addition & 0 deletions apps/api-start-stopp-perioder/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ dependencies {
implementation(project(":lib:kafka"))
implementation(project(":lib:hoplite-config"))
implementation(project(":lib:kafka-key-generator-client"))
implementation(project(":domain:arbeidssoeker-regler"))
implementation(hoplite.hopliteCore)
implementation(hoplite.hopliteToml)
implementation(hoplite.hopliteYaml)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package no.nav.paw.arbeidssokerregisteret

import no.nav.paw.arbeidssokerregisteret.application.authfaktka.*
import no.nav.paw.arbeidssokerregisteret.application.authfaktka.AuthOpplysning.*
import no.nav.paw.arbeidssokerregisteret.intern.v1.vo.Opplysning

fun authOpplysningTilHendelseOpplysning(opplysning: AuthOpplysning): Opplysning =
when (opplysning) {
IkkeSammeSomInnloggerBruker -> Opplysning.IKKE_SAMME_SOM_INNLOGGER_BRUKER
SammeSomInnloggetBruker -> Opplysning.SAMME_SOM_INNLOGGET_BRUKER
TokenXPidIkkeFunnet -> Opplysning.TOKENX_PID_IKKE_FUNNET
AnsattIkkeTilgang -> Opplysning.ANSATT_IKKE_TILGANG
AnsattTilgang -> Opplysning.ANSATT_TILGANG
IkkeAnsatt -> Opplysning.IKKE_ANSATT
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package no.nav.paw.arbeidssokerregisteret.application

import arrow.core.Either
import arrow.core.raise.either
import no.nav.paw.arbeidssoekerregisteret.api.opplysningermottatt.models.Feil
import no.nav.paw.arbeidssoekerregisteret.api.opplysningermottatt.models.OpplysningerRequest
import no.nav.paw.arbeidssokerregisteret.RequestScope
import no.nav.paw.arbeidssokerregisteret.api.extensions.getId
import no.nav.paw.arbeidssokerregisteret.domain.http.ValidationErrorResult
import no.nav.paw.arbeidssokerregisteret.domain.http.ValidationResult
import no.nav.paw.arbeidssokerregisteret.domain.http.ValidationResultOk
import no.nav.paw.arbeidssokerregisteret.domain.http.validerOpplysninger
import no.nav.paw.arbeidssokerregisteret.domain.http.validering.validerOpplysninger
import no.nav.paw.arbeidssokerregisteret.intern.v1.Hendelse
import no.nav.paw.config.kafka.sendDeferred
import no.nav.paw.kafkakeygenerator.client.KafkaKeysClient
Expand All @@ -23,30 +23,31 @@ class OpplysningerRequestHandler(
private val logger = LoggerFactory.getLogger(this::class.java)

context(RequestScope)
suspend fun opprettBrukeropplysninger(opplysningerRequest: OpplysningerRequest): Either<out IkkeTilgang, out ValidationResult> {
val identitetsnummer = opplysningerRequest.getId()

val validerTilgangResultat = requestValidator.validerTilgang(identitetsnummer)

if (validerTilgangResultat is IkkeTilgang) {
return Left(validerTilgangResultat)
}

val validerOpplysninger = validerOpplysninger(opplysningerRequest.opplysningerOmArbeidssoeker)

if (validerOpplysninger is ValidationErrorResult) {
return Right(validerOpplysninger)
suspend fun opprettBrukeropplysninger(opplysningerRequest: OpplysningerRequest): Either<Feil, Unit> =
either {
val identitetsnummer = opplysningerRequest.getId()
requestValidator.validerTilgang(identitetsnummer)
.mapLeft { problem ->
Feil(
melding = problem.regel.beskrivelse,
feilKode = Feil.FeilKode.IKKE_TILGANG
)
}.bind()
validerOpplysninger(opplysningerRequest.opplysningerOmArbeidssoeker)
.mapLeft { validationErrorResult ->
Feil(
melding = validationErrorResult.message,
feilKode = Feil.FeilKode.FEIL_VED_LESING_AV_FORESPORSEL
)
}.bind()
val (id, key) = kafkaKeysClient.getIdAndKey(identitetsnummer.verdi)
val hendelse = opplysningerHendelse(id, opplysningerRequest)
val record = ProducerRecord(
hendelseTopic,
key,
hendelse
)
val recordMetadata = producer.sendDeferred(record).await()
logger.trace("Sendte melding til kafka: type={}, offset={}", hendelse.hendelseType, recordMetadata.offset())
}
val (id, key) = kafkaKeysClient.getIdAndKey(identitetsnummer.verdi)

val hendelse = opplysningerHendelse(id, opplysningerRequest)
val record = ProducerRecord(
hendelseTopic,
key,
hendelse
)
val recordMetadata = producer.sendDeferred(record).await()
logger.trace("Sendte melding til kafka: type={}, offset={}", hendelse.hendelseType, recordMetadata.offset())
return Right(ValidationResultOk)
}
}

This file was deleted.

This file was deleted.

Loading

0 comments on commit 6f82afb

Please sign in to comment.