Skip to content

Commit

Permalink
Remove warning
Browse files Browse the repository at this point in the history
  • Loading branch information
flexable777 committed Dec 9, 2020
1 parent c5ef700 commit bf84658
Showing 1 changed file with 0 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package no.nav.klage.oppgave.api

import no.nav.klage.oppgave.domain.OppgaverQueryParams
import no.nav.klage.oppgave.domain.OppgaverSearchCriteria
import no.nav.klage.oppgave.domain.Tilganger
import no.nav.klage.oppgave.exceptions.NotOwnEnhetException
import no.nav.klage.oppgave.repositories.SaksbehandlerRepository
import no.nav.klage.oppgave.util.getLogger
Expand Down Expand Up @@ -35,23 +34,11 @@ class OppgaverQueryParamsMapper(private val saksbehandlerRepository: Saksbehandl

private fun validateAndGetEnhetId(navIdent: String, enhetId: String): String {
val tilgangerForSaksbehandler = saksbehandlerRepository.getTilgangerForSaksbehandler(navIdent)
logWarningIMoreThanOneEnhet(navIdent, tilgangerForSaksbehandler)

if (tilgangerForSaksbehandler.enheter.none { e -> e.enhetId == enhetId }) {
throw NotOwnEnhetException("$navIdent is not part of enhet $enhetId")
}
return enhetId
}

private fun logWarningIMoreThanOneEnhet(navIdent: String, tilgangerForSaksbehandler: Tilganger) {
if (tilgangerForSaksbehandler.enheter.size > 1) {
logger.warn(
"Saksbehandler ({}) had more than one enhet: {}. Only using {}.",
navIdent,
tilgangerForSaksbehandler.enheter.map { it.enhetId },
tilgangerForSaksbehandler.enheter.first().enhetId
)
}
}

}

0 comments on commit bf84658

Please sign in to comment.