Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/maven/com.github.tomakehurst-wi…
Browse files Browse the repository at this point in the history
…remock-jre8-standalone-2.35.1
  • Loading branch information
ma10s authored Sep 15, 2023
2 parents 9d36391 + 8095a96 commit ac244aa
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
package no.nav.familie.ef.mottak.api

import no.nav.familie.ef.mottak.service.EttersendingService
import no.nav.familie.ef.mottak.task.ArkiverEttersendingTask
import no.nav.familie.log.IdUtils
import no.nav.familie.log.mdc.MDCConstants
import no.nav.familie.prosessering.domene.Status
import no.nav.familie.prosessering.internal.TaskService
import no.nav.security.token.support.core.api.ProtectedWithClaims
import org.slf4j.MDC
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
Expand All @@ -12,15 +18,36 @@ import java.util.UUID
@RestController
@RequestMapping(path = ["/api/forvaltning"])
@ProtectedWithClaims(issuer = "azuread")
class ForvaltningController(private val ettersendingService: EttersendingService) {
class ForvaltningController(private val ettersendingService: EttersendingService, private val taskService: TaskService,) {

@PostMapping("/ettersending/splitt")
fun trekkUtVedleggFraEttersending(@RequestBody ettersendingVedleggId: EttersendingVedleggId): ResponseEntity<String> {
val nyEttersendingId = ettersendingService.trekkUtEttersendingTilEgenTaskForVedlegg(ettersendingVedleggId.id)
return ResponseEntity.ok("Opprettet ny ettersending med id: $nyEttersendingId")
}

@PostMapping("/ettersending/nycallid")
fun settNyCallIdPåTaskForEttersending(@RequestBody taskId: TaskId): ResponseEntity<String> {

val task = taskService.findById(taskId.id)
require(task.type == ArkiverEttersendingTask.TYPE)
require(task.status == Status.FEILET || task.status == Status.MANUELL_OPPFØLGING) {"Kan ikke legge på ny callId på task når status er ${task.status}"}
val generateId = IdUtils.generateId()
task.metadata.apply {
this["callId"] = generateId
}
MDC.put(MDCConstants.MDC_CALL_ID, generateId)
taskService.save(task)
return ResponseEntity.ok("Endret callId på task til: $generateId")
}

}


data class TaskId(
val id: Long,
)

data class EttersendingVedleggId(
val id: UUID,
)

This file was deleted.

0 comments on commit ac244aa

Please sign in to comment.