-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* EY-4839 Nytt endepunkt for å la EESSI opprette oppgave hos oss * småfikser og readme
- Loading branch information
1 parent
6ccd4f0
commit 6fe8fd1
Showing
12 changed files
with
137 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
apps/etterlatte-api/src/main/kotlin/no/nav/etterlatte/oppgave/OppgaveKlient.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package no.nav.etterlatte.oppgave | ||
|
||
import com.typesafe.config.Config | ||
import io.ktor.client.HttpClient | ||
import io.ktor.client.call.body | ||
import io.ktor.client.plugins.ClientRequestException | ||
import io.ktor.client.request.accept | ||
import io.ktor.client.request.post | ||
import io.ktor.client.request.setBody | ||
import io.ktor.http.ContentType | ||
import io.ktor.http.HttpStatusCode | ||
import io.ktor.http.contentType | ||
import no.nav.etterlatte.behandling.sak.BehandlingManglendeTilgang | ||
import no.nav.etterlatte.behandling.sak.BehandlingUgyldigForespoersel | ||
import no.nav.etterlatte.libs.common.oppgave.NyOppgaveDto | ||
import no.nav.etterlatte.libs.common.oppgave.OppgaveIntern | ||
import no.nav.etterlatte.libs.common.sak.SakId | ||
import org.slf4j.LoggerFactory | ||
|
||
class OppgaveKlient( | ||
config: Config, | ||
private val httpClient: HttpClient, | ||
) { | ||
private val logger = LoggerFactory.getLogger(this::class.java) | ||
private val behandlingUrl = "${config.getString("behandling.url")}/api" | ||
|
||
suspend fun opprettOppgave( | ||
sakId: SakId, | ||
oppgave: NyOppgaveDto, | ||
): OppgaveIntern { | ||
logger.info("Oppretter ny oppgave på sak $sakId") | ||
|
||
return try { | ||
httpClient | ||
.post("$behandlingUrl/oppgaver/sak/${sakId.sakId}/opprett") { | ||
accept(ContentType.Application.Json) | ||
contentType(ContentType.Application.Json) | ||
setBody(oppgave) | ||
}.body<OppgaveIntern>() | ||
} catch (e: ClientRequestException) { | ||
logger.error("Det oppstod en feil ved opprettelse av oppgave for sak $sakId") | ||
|
||
when (e.response.status) { | ||
HttpStatusCode.Unauthorized -> throw BehandlingManglendeTilgang("Oppgave: Ikke tilgang") | ||
HttpStatusCode.BadRequest -> throw BehandlingUgyldigForespoersel("Oppgave: Ugyldig forespørsel") | ||
else -> throw e | ||
} | ||
} | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
apps/etterlatte-api/src/main/kotlin/no/nav/etterlatte/oppgave/OppgaveRoute.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package no.nav.etterlatte.oppgave | ||
|
||
import io.ktor.server.application.call | ||
import io.ktor.server.application.install | ||
import io.ktor.server.request.receive | ||
import io.ktor.server.routing.Route | ||
import io.ktor.server.routing.post | ||
import io.ktor.server.routing.route | ||
import no.nav.etterlatte.AuthorizationPlugin | ||
import no.nav.etterlatte.libs.common.oppgave.NyOppgaveDto | ||
import no.nav.etterlatte.libs.common.oppgave.OppgaveKilde | ||
import no.nav.etterlatte.libs.common.oppgave.OppgaveType | ||
import no.nav.etterlatte.libs.common.sak.SakId | ||
|
||
fun Route.oppgaveRoute(oppgaveService: OppgaveService) { | ||
route("/api/v1/oppgave") { | ||
route("/journalfoering") { | ||
install(AuthorizationPlugin) { | ||
accessPolicyRolesEllerAdGrupper = setOf("opprett-jfr-oppgave") | ||
} | ||
|
||
post { | ||
val request = call.receive<OpprettJournalfoeringOppgave>() | ||
|
||
oppgaveService.opprettOppgave( | ||
sakId = request.sakId, | ||
NyOppgaveDto( | ||
oppgaveKilde = OppgaveKilde.EESSI, | ||
oppgaveType = OppgaveType.JOURNALFOERING, | ||
merknad = request.beskrivelse, | ||
referanse = request.journalpostId, | ||
), | ||
) | ||
} | ||
} | ||
} | ||
} | ||
|
||
internal data class OpprettJournalfoeringOppgave( | ||
val sakId: SakId, | ||
val journalpostId: String, | ||
val beskrivelse: String, | ||
) |
21 changes: 21 additions & 0 deletions
21
apps/etterlatte-api/src/main/kotlin/no/nav/etterlatte/oppgave/OppgaveService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package no.nav.etterlatte.oppgave | ||
|
||
import no.nav.etterlatte.libs.common.oppgave.NyOppgaveDto | ||
import no.nav.etterlatte.libs.common.oppgave.OppgaveIntern | ||
import no.nav.etterlatte.libs.common.sak.SakId | ||
import org.slf4j.LoggerFactory | ||
|
||
class OppgaveService( | ||
private val oppgaveKlient: OppgaveKlient, | ||
) { | ||
private val logger = LoggerFactory.getLogger(this::class.java) | ||
|
||
suspend fun opprettOppgave( | ||
sakId: SakId, | ||
nyOppgave: NyOppgaveDto, | ||
): OppgaveIntern { | ||
logger.info("Oppretter ny oppgave for sak $sakId") | ||
|
||
return oppgaveKlient.opprettOppgave(sakId, nyOppgave) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters