Skip to content

Commit

Permalink
Merge pull request #1314 from navikt/microfrontend-minside
Browse files Browse the repository at this point in the history
Listens to behandling events, sends message to microfrontend topic wh…
  • Loading branch information
oyvind-wedoe authored Jan 30, 2025
2 parents faafd6f + 05faaec commit 7970128
Show file tree
Hide file tree
Showing 13 changed files with 311 additions and 31 deletions.
2 changes: 2 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ val verapdfVersion = "1.26.2"
val klageKodeverkVersion = "1.9.13"
val commonsFileupload2JakartaVersion = "2.0.0-M1"
val otelVersion = "1.45.0"
val mikrofrontendSelectorVersion = "3.0.0"

plugins {
val kotlinVersion = "2.1.0"
Expand Down Expand Up @@ -99,6 +100,7 @@ dependencies {
}
implementation("org.apache.pdfbox:pdfbox:$pdfboxVersion")
implementation("org.apache.tika:tika-core:$tikaVersion")
implementation("no.nav.tms.mikrofrontend.selector:builder:$mikrofrontendSelectorVersion")


testImplementation("org.springframework.boot:spring-boot-starter-test") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import java.util.*

@RestController
@ProtectedWithClaims(issuer = SecurityConfiguration.ISSUER_AAD)
@RequestMapping("/internal")
class AdminController(
private val adminService: AdminService,
private val innloggetSaksbehandlerService: InnloggetSaksbehandlerService,
Expand All @@ -25,7 +26,7 @@ class AdminController(
private val logger = getLogger(javaClass.enclosingClass)
}

@PostMapping("/internal/kafkaadmin/refill", produces = ["application/json"])
@PostMapping("/kafkaadmin/refill", produces = ["application/json"])
@ResponseStatus(HttpStatus.OK)
fun refillKafka() {
azureGateway.getDataOmInnloggetSaksbehandler()
Expand All @@ -43,7 +44,7 @@ class AdminController(
}
}

@PostMapping("/internal/dvh/resend", produces = ["application/json"])
@PostMapping("/dvh/resend", produces = ["application/json"])
@ResponseStatus(HttpStatus.OK)
fun resendStatsToDVH() {
logger.debug("resendStatsToDVH is called")
Expand All @@ -57,7 +58,7 @@ class AdminController(
}
}

@PostMapping("/internal/generatemissingankeitrygderetten", produces = ["application/json"])
@PostMapping("/generatemissingankeitrygderetten", produces = ["application/json"])
@ResponseStatus(HttpStatus.OK)
fun generateMissingAnkeITrygderetten() {
logger.debug("generateMissingAnkeITrygderetten is called")
Expand All @@ -71,7 +72,7 @@ class AdminController(
}
}

@PostMapping("/internal/isskjermet")
@PostMapping("/isskjermet")
@ResponseStatus(HttpStatus.OK)
fun isSkjermet(
@RequestBody input: Fnr
Expand All @@ -82,7 +83,7 @@ class AdminController(
adminService.isSkjermet(input.fnr)
}

@PostMapping("/internal/migratedvhevents")
@PostMapping("/migratedvhevents")
fun migrateDvhEvents() {
logger.debug("migrateDvhEvents is called")
krevAdminTilgang()
Expand All @@ -95,31 +96,31 @@ class AdminController(
}
}

@GetMapping("/internal/invalidregistreringshjemler")
@GetMapping("/invalidregistreringshjemler")
fun getInvalidRegistreringshjemler() {
logger.debug("getInvalidRegistreringshjemler is called")
krevAdminTilgang()

adminService.logInvalidRegistreringshjemler()
}

@GetMapping("/internal/logexpiredusers")
@GetMapping("/logexpiredusers")
fun logExpiredUsers() {
logger.debug("logExpiredUsers is called")
krevAdminTilgang()

adminService.logExpiredUsers()
}

@GetMapping("/internal/logprotected")
@GetMapping("/logprotected")
fun logProtected() {
logger.debug("logProtected is called")
krevAdminTilgang()

adminService.logProtected()
}

@PostMapping("/internal/setsortkeytodua")
@PostMapping("/setsortkeytodua")
fun setSortKeyToDUA() {
logger.debug("setSortKeyToDUA is called")
krevAdminTilgang()
Expand All @@ -132,7 +133,7 @@ class AdminController(
}
}

@GetMapping("/internal/behandlinger/{id}/reindex", produces = ["application/json"])
@GetMapping("/behandlinger/{id}/reindex", produces = ["application/json"])
@ResponseStatus(HttpStatus.OK)
fun reindexBehandling(@PathVariable("id") behandlingId: UUID) {
logger.debug("reindexBehandling is called")
Expand All @@ -146,7 +147,7 @@ class AdminController(
}
}

@GetMapping("/internal/migrateTilbakekreving", produces = ["application/json"])
@GetMapping("/migrateTilbakekreving", produces = ["application/json"])
@ResponseStatus(HttpStatus.OK)
fun migrateTilbakekreving() {
logger.debug("migrateTilbakekreving is called")
Expand All @@ -160,14 +161,50 @@ class AdminController(
}
}

@GetMapping("/internal/merkantil-tasks")
@GetMapping("/merkantil-tasks")
fun getTaskListMerkantil(): List<TaskListMerkantilView> {
logger.debug("getTaskListMerkantil is called")
krevAdminTilgang()

return adminService.getTaskListMerkantil()
}

@GetMapping(value = ["/enableminsidemicrofrontend/{behandlingId}", "/enableminsidemicrofrontend"])
fun enableMinsideMicrofrontends(
@PathVariable("behandlingId") behandlingId: UUID?
) {
logger.debug("{} is called. BehandlingId: {}", ::enableMinsideMicrofrontends.name, behandlingId)
krevAdminTilgang()
try {
if (behandlingId != null) {
adminService.enableMinsideMicrofrontend(behandlingId)
} else {
adminService.enableAllMinsideMicrofrontends()
}
} catch (e: Exception) {
logger.warn("Failed in ${::enableMinsideMicrofrontends.name}", e)
throw e
}
}

@GetMapping(value = ["/disableminsidemicrofrontend/{behandlingId}", "/disableminsidemicrofrontend"])
fun disableMinsideMicrofrontends(
@PathVariable("behandlingId") behandlingId: UUID?
) {
logger.debug("{} is called. BehandlingId: {}", ::disableMinsideMicrofrontends.name, behandlingId)
krevAdminTilgang()
try {
if (behandlingId != null) {
adminService.disableMinsideMicrofrontend(behandlingId)
} else {
adminService.disableAllMinsideMicrofrontends()
}
} catch (e: Exception) {
logger.warn("Failed in ${::disableMinsideMicrofrontends.name}", e)
throw e
}
}

@GetMapping("/internal/evictallcaches", produces = ["application/json"])
@ResponseStatus(HttpStatus.OK)
fun evictAllCAches() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import java.util.*

@Profile("dev-gcp")
@RestController
@RequestMapping("/internal/dev")
class DevOnlyAdminController(
private val adminService: AdminService,
private val tokenUtil: TokenUtil,
Expand All @@ -34,7 +35,7 @@ class DevOnlyAdminController(
}

@Unprotected
@GetMapping("/internal/kafkaadmin/refill", produces = ["application/json"])
@GetMapping("/kafkaadmin/refill", produces = ["application/json"])
@ResponseStatus(HttpStatus.OK)
fun resetElasticIndex() {
try {
Expand All @@ -47,7 +48,7 @@ class DevOnlyAdminController(
}

@Unprotected
@DeleteMapping("/internal/behandlinger/{id}", produces = ["application/json"])
@DeleteMapping("/behandlinger/{id}", produces = ["application/json"])
@ResponseStatus(HttpStatus.OK)
fun deleteBehandling(@PathVariable("id") behandlingId: UUID) {
try {
Expand All @@ -60,7 +61,7 @@ class DevOnlyAdminController(
}

@Unprotected
@GetMapping("/internal/behandlinger/{id}/reindexdev", produces = ["application/json"])
@GetMapping("/behandlinger/{id}/reindexdev", produces = ["application/json"])
@ResponseStatus(HttpStatus.OK)
fun reindexBehandling(@PathVariable("id") behandlingId: UUID) {
try {
Expand All @@ -73,7 +74,7 @@ class DevOnlyAdminController(
}

@Unprotected
@PostMapping("/internal/generatemissingankeitrygderettendev", produces = ["application/json"])
@PostMapping("/generatemissingankeitrygderettendev", produces = ["application/json"])
@ResponseStatus(HttpStatus.OK)
fun generateMissingAnkeITrygderetten() {
logger.debug("generateMissingAnkeITrygderetten is called in dev")
Expand All @@ -87,7 +88,7 @@ class DevOnlyAdminController(
}

@Unprotected
@PostMapping("/internal/isskjermetdev")
@PostMapping("/isskjermetdev")
@ResponseStatus(HttpStatus.OK)
fun isSkjermet(
@RequestBody input: Fnr
Expand All @@ -98,7 +99,7 @@ class DevOnlyAdminController(
}

@Unprotected
@PostMapping("/internal/migratedvh")
@PostMapping("/migratedvh")
fun migrateDvhEvents() {
logger.debug("migrateDvhEvents is called")

Expand All @@ -111,7 +112,7 @@ class DevOnlyAdminController(
}

@Unprotected
@GetMapping("/internal/mytokens")
@GetMapping("/mytokens")
fun getTokens(): Map<String, String> {
return mapOf(
"\ngetAccessTokenFrontendSent\n" to tokenUtil.getAccessTokenFrontendSent(),
Expand All @@ -127,7 +128,7 @@ class DevOnlyAdminController(
summary = "Feilregistrer sak",
description = "Endepunkt for å feilregistrere en klage/anke som ikke skal behandles av klageinstans. Fungerer kun hvis sak ikke er tildelt saksbehandler. Ellers må KA kontaktes."
)
@PostMapping("/internal/feilregistrering")
@PostMapping("/feilregistrering")
fun feilregistrer(
@Parameter(description = "Feilregistrering")
@Valid @RequestBody feilregistrering: ExternalFeilregistreringInput,
Expand All @@ -153,7 +154,7 @@ class DevOnlyAdminController(
}

@Unprotected
@GetMapping("/internal/setsortkeytodua")
@GetMapping("/setsortkeytodua")
fun setSortKeyToDUA() {
logger.debug("setSortKeyToDUA is called in dev")

Expand All @@ -166,7 +167,7 @@ class DevOnlyAdminController(
}

@Unprotected
@GetMapping("/internal/infotrygdsaker/{id}")
@GetMapping("/infotrygdsaker/{id}")
fun getInfotrygdsak(
@PathVariable("id") id: String
): SakFromKlanke {
Expand All @@ -176,7 +177,45 @@ class DevOnlyAdminController(
}

@Unprotected
@GetMapping("/internal/dev/evictallcaches", produces = ["application/json"])
@GetMapping(value = ["/enableminsidemicrofrontend/{behandlingId}", "/enableminsidemicrofrontend"])
fun enableMinsideMicrofrontends(
@PathVariable(required = false, name = "behandlingId") behandlingId: UUID?
) {
logger.debug("{} is called in dev. BehandlingId: {}", ::enableMinsideMicrofrontends.name, behandlingId)

try {
if (behandlingId != null) {
adminService.enableMinsideMicrofrontend(behandlingId)
} else {
adminService.enableAllMinsideMicrofrontends()
}
} catch (e: Exception) {
logger.warn("Failed in ${::enableMinsideMicrofrontends.name}", e)
throw e
}
}

@Unprotected
@GetMapping(value = ["/disableminsidemicrofrontend/{behandlingId}", "/disableminsidemicrofrontend"])
fun disableMinsideMicrofrontends(
@PathVariable(required = false, name = "behandlingId") behandlingId: UUID?
) {
logger.debug("{} is called in dev. BehandlingId: {}", ::disableMinsideMicrofrontends.name, behandlingId)

try {
if (behandlingId != null) {
adminService.disableMinsideMicrofrontend(behandlingId)
} else {
adminService.disableAllMinsideMicrofrontends()
}
} catch (e: Exception) {
logger.warn("Failed in ${::disableMinsideMicrofrontends.name}", e)
throw e
}
}

@Unprotected
@GetMapping("/evictallcaches", produces = ["application/json"])
@ResponseStatus(HttpStatus.OK)
fun evictAllCAches() {
logger.debug("${::evictAllCAches.name} is called")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package no.nav.klage.oppgave.domain.kafka

enum class EventType {
KLAGE_VEDTAK, STATS_DVH, BEHANDLING_EVENT
KLAGE_VEDTAK, STATS_DVH, BEHANDLING_EVENT, MINSIDE_MICROFRONTEND_EVENT
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package no.nav.klage.oppgave.eventlisteners

import no.nav.klage.oppgave.domain.events.BehandlingEndretEvent
import no.nav.klage.oppgave.service.MinsideMicrofrontendService
import no.nav.klage.oppgave.util.getLogger
import org.springframework.stereotype.Service

@Service
class MinsideMicrofrontendEventListener(
private val minsideMicrofrontendService: MinsideMicrofrontendService,
) {

companion object {
@Suppress("JAVA_CLASS_ON_COMPANION")
private val logger = getLogger(javaClass.enclosingClass)
}

//TODO: Uncomment when minside microfrontend is ready
// @EventListener
fun handleMinsideMicrofrontendEvent(behandlingEndretEvent: BehandlingEndretEvent) {
logger.debug(
"Received BehandlingEndretEvent for behandlingId {} in {}",
behandlingEndretEvent.behandling.id,
::handleMinsideMicrofrontendEvent.name
)
minsideMicrofrontendService.process(behandlingEndretEvent)
logger.debug("Processed BehandlingEndretEvent for behandlingId {}", behandlingEndretEvent.behandling.id)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ interface BehandlingRepository : JpaRepository<Behandling, UUID>, JpaSpecificati

fun findByFerdigstillingAvsluttetIsNullAndFerdigstillingAvsluttetAvSaksbehandlerIsNotNullAndFeilregistreringIsNull(): List<Behandling>

fun findByFeilregistreringIsNull(): List<Behandling>

fun findByFerdigstillingIsNull(): List<Behandling>

fun findByFerdigstillingIsNullAndFeilregistreringIsNull(): List<Behandling>
Expand Down
Loading

0 comments on commit 7970128

Please sign in to comment.