Skip to content

Commit

Permalink
f - Legger til nytt endepunkt for å sende sed
Browse files Browse the repository at this point in the history
  • Loading branch information
MariamPervez committed Sep 27, 2024
1 parent 1589f5a commit 4bfd641
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 11 deletions.
46 changes: 35 additions & 11 deletions src/main/kotlin/no/nav/eessi/pensjon/fagmodul/api/EuxController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.http.HttpStatus
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
import org.springframework.web.bind.annotation.*
import org.springframework.web.client.HttpStatusCodeException
import org.springframework.web.server.ResponseStatusException



@RestController
@RequestMapping("/eux")
Expand All @@ -26,30 +26,30 @@ class EuxController(
) {
private val logger = LoggerFactory.getLogger(EuxController::class.java)

private lateinit var paakobledeland: MetricsHelper.Metric
private lateinit var rinaUrl: MetricsHelper.Metric
private lateinit var sedsendt: MetricsHelper.Metric
private lateinit var euxKodeverk: MetricsHelper.Metric
private lateinit var paakobledeland: MetricsHelper.Metric
private lateinit var euxKodeverkLand: MetricsHelper.Metric
private lateinit var euxInstitusjoner: MetricsHelper.Metric
private lateinit var rinaUrl: MetricsHelper.Metric

init {
paakobledeland = metricsHelper.init("paakobledeland", ignoreHttpCodes = listOf(HttpStatus.FORBIDDEN))
rinaUrl = metricsHelper.init("RinaUrl")
sedsendt = metricsHelper.init("sedsendt")
euxKodeverk = metricsHelper.init("euxKodeverk", ignoreHttpCodes = listOf(HttpStatus.FORBIDDEN))
paakobledeland = metricsHelper.init("paakobledeland", ignoreHttpCodes = listOf(HttpStatus.FORBIDDEN))
euxKodeverkLand = metricsHelper.init("euxKodeverkLand", ignoreHttpCodes = listOf(HttpStatus.FORBIDDEN))
euxInstitusjoner = metricsHelper.init("euxInstitusjoner", ignoreHttpCodes = listOf(HttpStatus.FORBIDDEN))
rinaUrl = metricsHelper.init("RinaUrl")
}


val backupList = listOf("AT", "BE", "BG", "CH", "CZ", "DE", "DK", "EE", "ES", "FI", "FR", "HR", "HU", "IE", "IS", "IT", "LI", "LT", "LU", "LV", "MT", "NL", "NO", "PL", "PT", "RO", "SE", "SI", "SK", "UK")


@Unprotected
@GetMapping("/rinaurl")
fun getRinaUrl2020(): ResponseEntity<Map<String, String>> = rinaUrl.measure {
return@measure ResponseEntity.ok(mapOf("rinaUrl" to euxInnhentingService.getRinaUrl()))
}


@Protected
@GetMapping("/countries/{buctype}")
fun getPaakobledeland(@PathVariable(value = "buctype") bucType: BucType): ResponseEntity<String> {
Expand Down Expand Up @@ -84,4 +84,28 @@ class EuxController(
}
}

@Protected
@PostMapping("/buc/{rinasakId}/sed/{dokumentId}/send")
fun sendSeden(
@PathVariable("rinasakId", required = true) rinaSakId: String,
@PathVariable("dokumentId", required = false) dokumentId: String
): ResponseEntity<String> {
return sedsendt.measure {
return@measure try {
val response = euxInnhentingService.sendSed(rinaSakId, dokumentId)
if (response) {
logger.info("Sed er sendt til Rina")
ResponseEntity.ok().body("Sed er sendt til Rina")
} else {
logger.error("Sed ble ikke sendt til Rina")
ResponseEntity.badRequest().body("Sed ble IKKE sendt til Rina")
}
} catch (ex: Exception) {
logger.error("Sed ble ikke sendt til Rina")
ResponseEntity.badRequest().body("Sed ble IKKE sendt til Rina")
}
}
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,12 @@ class EuxInnhentingService (@Value("\${ENV}") private val environment: String,
request.copy(payload = x009.toJson())
} else request
}

fun sendSed(rinaSakId: String, dokumentId: String): Boolean {
logger.info("Sender sed til Rina: $rinaSakId, sedId: $dokumentId")
return euxKlient.sendSed(rinaSakId, dokumentId)
}

/**
* Utvalgt informasjon om en rinasak/Buc.
*/
Expand Down

0 comments on commit 4bfd641

Please sign in to comment.