Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/maven/org.codehaus.mojo-build-hel…
Browse files Browse the repository at this point in the history
…per-maven-plugin-3.5.0
  • Loading branch information
s148719 authored Sep 18, 2024
2 parents 3401d74 + 84b3e6e commit 520c4e0
Show file tree
Hide file tree
Showing 15 changed files with 240 additions and 241 deletions.
3 changes: 3 additions & 0 deletions .nais/feature.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ azure:
- application: bidrag-dokument-forsendelse-feature
namespace: bidrag
cluster: dev-gcp
- application: bidrag-behandling-feature
namespace: bidrag
cluster: dev-gcp
ingresses:
- https://bidrag-dokument-feature.dev.adeo.no/
- https://bidrag-dokument-feature.dev.intern.nav.no/
Expand Down
3 changes: 3 additions & 0 deletions .nais/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ azure:
- application: bidrag-dokument-forsendelse
namespace: bidrag
cluster: dev-gcp
- application: bidrag-behandling
namespace: bidrag
cluster: dev-gcp
ingresses:
- https://bidrag-dokument.nais.preprod.local/
- https://bidrag-dokument.dev.adeo.no/
Expand Down
2 changes: 1 addition & 1 deletion .nais/nais.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ spec:
cpu: 2000m
memory: 3000Mi
requests:
cpu: 200m
cpu: 100m
memory: 1500Mi
ingresses:
{{#each ingresses as |url|}}
Expand Down
4 changes: 3 additions & 1 deletion .nais/prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ azure:
- application: bidrag-dokument-forsendelse
namespace: bidrag
cluster: prod-gcp
- application: bidrag-behandling
namespace: bidrag
cluster: prod-gcp
ingresses:
- https://bidrag-dokument.nais.adeo.no/
- https://bidrag-dokument.intern.nav.no/
- https://bidrag-dokument.prod-fss.nais.io
- https://bidrag-dokument.prod-fss-pub.nais.io
env:
STS_ACCEPTED_AUDIENCE: srvbdarkivering,srvbisys
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,4 @@ kubectl exec --tty deployment/bidrag-dokument printenv | grep -E 'AZURE_|TOKEN_X

Deretter kan tokenet brukes til å logge inn på
swagger-ui http://localhost:8080/bidrag-dokument/swagger-ui/index.html og teste ut ulike api kall
2
18 changes: 8 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.0</version>
<version>3.2.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

Expand All @@ -25,9 +25,7 @@
<kotlin.version>1.9.22</kotlin.version>

<!-- dependent versions other than from spring-boot -->
<bidrag-commons.version>20231002151454_eab4a7b</bidrag-commons.version>
<bidrag-commons-test.version>1.20230504132526_a72fa41</bidrag-commons-test.version>
<bidrag-transport.version>20231010134706_52d8d27</bidrag-transport.version>
<bidrag-felles.version>2024.08.19.124814</bidrag-felles.version>
<logback.encoder.version>7.4</logback.encoder.version>
<springdoc-openapi-ui.version>2.3.0</springdoc-openapi-ui.version>
<springframework-cloud.version>4.1.0</springframework-cloud.version>
Expand Down Expand Up @@ -104,13 +102,13 @@

<dependency>
<groupId>no.nav.bidrag</groupId>
<artifactId>bidrag-commons</artifactId>
<version>${bidrag-commons.version}</version>
<artifactId>bidrag-commons-felles</artifactId>
<version>${bidrag-felles.version}</version>
</dependency>
<dependency>
<groupId>no.nav.bidrag</groupId>
<artifactId>bidrag-transport</artifactId>
<version>${bidrag-transport.version}</version>
<artifactId>bidrag-transport-felles</artifactId>
<version>${bidrag-felles.version}</version>
</dependency>
<!--Sikkerhet-->
<dependency>
Expand Down Expand Up @@ -232,8 +230,8 @@
</dependency>
<dependency>
<groupId>no.nav.bidrag</groupId>
<artifactId>bidrag-commons-test</artifactId>
<version>${bidrag-commons-test.version}</version>
<artifactId>bidrag-commons-test-felles</artifactId>
<version>${bidrag-felles.version}</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,16 @@ class BidragDokumentConsumer(
private val rootUri: String,
private val metricsRegistry: MeterRegistry,
) {
fun finnAvvik(saksnummer: String?, journalpostId: String?): HttpResponse<List<AvvikType>> {
val path: String = if (saksnummer != null) {
String.format(PATH_AVVIK_PA_JOURNALPOST_MED_SAK_PARAM, journalpostId, saksnummer)
} else {
String.format(PATH_AVVIK_PA_JOURNALPOST, journalpostId)
}
fun finnAvvik(
saksnummer: String?,
journalpostId: String?,
): HttpResponse<List<AvvikType>> {
val path: String =
if (saksnummer != null) {
String.format(PATH_AVVIK_PA_JOURNALPOST_MED_SAK_PARAM, journalpostId, saksnummer)
} else {
String.format(PATH_AVVIK_PA_JOURNALPOST, journalpostId)
}
val avviksResponse =
restTemplate.exchange(path, HttpMethod.GET, null, typereferansenErListeMedAvvikstyper())
return HttpResponse(avviksResponse)
Expand All @@ -51,22 +55,27 @@ class BidragDokumentConsumer(
avvikshendelse: Avvikshendelse?,
): HttpResponse<BehandleAvvikshendelseResponse> {
val path = String.format("$PATH_JOURNALPOST_UTEN_SAK/avvik", journalpostId)
val avviksResponse = restTemplate
.exchange(
path,
HttpMethod.POST,
HttpEntity(avvikshendelse, createEnhetHeader(enhetsnummer)),
BehandleAvvikshendelseResponse::class.java,
)
val avviksResponse =
restTemplate
.exchange(
path,
HttpMethod.POST,
HttpEntity(avvikshendelse, createEnhetHeader(enhetsnummer)),
BehandleAvvikshendelseResponse::class.java,
)
return HttpResponse(avviksResponse)
}

fun hentJournalpost(saksnummer: String?, id: String?): HttpResponse<JournalpostResponse> {
val url: String = if (saksnummer == null) {
String.format(PATH_JOURNALPOST, id)
} else {
String.format(PATH_JOURNALPOST_MED_SAKPARAM, id, saksnummer)
}
fun hentJournalpost(
saksnummer: String?,
id: String?,
): HttpResponse<JournalpostResponse> {
val url: String =
if (saksnummer == null) {
String.format(PATH_JOURNALPOST, id)
} else {
String.format(PATH_JOURNALPOST_MED_SAKPARAM, id, saksnummer)
}
val journalpostExchange =
restTemplate.exchange(url, HttpMethod.GET, null, JournalpostResponse::class.java)
return HttpResponse(journalpostExchange)
Expand All @@ -79,12 +88,14 @@ class BidragDokumentConsumer(
val uriBuilder = UriComponentsBuilder.fromPath(String.format(PATH_JOURNAL, saksnummer))
fagomrade.forEach { uriBuilder.queryParam(PARAM_FAGOMRADE, it) }
val uri = uriBuilder.toUriString()
log.info { "Henter journalposter for sak $saksnummer" }
val timer = metricsRegistry.timer("finnJournalposter", "service", name)
return try {
val journalposterFraArkiv = timer.recordCallable {
restTemplate
.exchange(uri, HttpMethod.GET, null, typereferansenErListeMedJournalposter())
}!!
val journalposterFraArkiv =
timer.recordCallable {
restTemplate
.exchange(uri, HttpMethod.GET, null, typereferansenErListeMedJournalposter())
}!!
journalposterFraArkiv.body ?: emptyList()
} catch (e: HttpStatusCodeException) {
log.error(e) {
Expand All @@ -107,24 +118,26 @@ class BidragDokumentConsumer(
endreJournalpostCommand: EndreJournalpostCommand,
): HttpResponse<Void> {
val path = String.format(PATH_JOURNALPOST_UTEN_SAK, endreJournalpostCommand.journalpostId)
val endretJournalpostResponse = restTemplate
.exchange(
path,
HttpMethod.PATCH,
HttpEntity(endreJournalpostCommand, createEnhetHeader(enhet)),
Void::class.java,
)
val endretJournalpostResponse =
restTemplate
.exchange(
path,
HttpMethod.PATCH,
HttpEntity(endreJournalpostCommand, createEnhetHeader(enhet)),
Void::class.java,
)
return HttpResponse(endretJournalpostResponse)
}

fun opprett(opprettJournalpostRequest: OpprettJournalpostRequest): HttpResponse<OpprettJournalpostResponse> {
val endretJournalpostResponse = restTemplate
.exchange(
PATH_OPPRETT_JOURNALPOST,
HttpMethod.POST,
HttpEntity(opprettJournalpostRequest),
OpprettJournalpostResponse::class.java,
)
val endretJournalpostResponse =
restTemplate
.exchange(
PATH_OPPRETT_JOURNALPOST,
HttpMethod.POST,
HttpEntity(opprettJournalpostRequest),
OpprettJournalpostResponse::class.java,
)
return HttpResponse(endretJournalpostResponse)
}

Expand All @@ -139,13 +152,14 @@ class BidragDokumentConsumer(
uriBuilder = uriBuilder.queryParam(PARAM_BATCHID, batchId)
}
val uri = uriBuilder.toUriString()
val distribuerJournalpostResponse = restTemplate
.exchange(
uri,
HttpMethod.POST,
HttpEntity(distribuerJournalpostRequest),
DistribuerJournalpostResponse::class.java,
)
val distribuerJournalpostResponse =
restTemplate
.exchange(
uri,
HttpMethod.POST,
HttpEntity(distribuerJournalpostRequest),
DistribuerJournalpostResponse::class.java,
)
return HttpResponse(distribuerJournalpostResponse)
}

Expand Down Expand Up @@ -255,6 +269,7 @@ class BidragDokumentConsumer(
const val PATH_HENT_DOKUMENT = "/dokument/%s"
const val PATH_HENT_DOKUMENT_REFERANSE = "/dokumentreferanse/%s"
const val PATH_HENT_DOKUMENT_ER_FERDIGSTILT = "/dokumentreferanse/%s/erFerdigstilt"

private fun typereferansenErListeMedJournalposter(): ParameterizedTypeReference<List<JournalpostDto>> {
return object : ParameterizedTypeReference<List<JournalpostDto>>() {}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class JournalpostController(private val journalpostService: JournalpostService)
val journalposter = journalpostService.finnJournalposter(saksnummer, fagomrade)
.filter { if (bareFarskapUtelukket) it.erFarskapUtelukketEllerBidragJournalpostMedTemaFar() else !it.erFarskapUtelukketEllerBidragJournalpostMedTemaFar() }

return ResponseEntity(journalposter, HttpStatus.OK)
return ResponseEntity.ok(journalposter)
}

@GetMapping("/journal/{journalpostIdForKildesystem}")
Expand All @@ -112,7 +112,7 @@ class JournalpostController(private val journalpostService: JournalpostService)
@Parameter(name = "saksnummer", description = "journalposten tilhører sak")
@RequestParam(required = false)
saksnummer: String?,
): ResponseEntity<JournalpostResponse?> {
): ResponseEntity<JournalpostResponse> {
var journalpostId = journalpostIdForKildesystem
if (!Strings.isNullOrEmpty(journalpostIdForKildesystem) && journalpostIdForKildesystem.contains(
":",
Expand All @@ -134,8 +134,7 @@ class JournalpostController(private val journalpostService: JournalpostService)
)
}
log.info("Henter journalpost $journalpostId for saksnummer $saksnummer")
val response = journalpostService.hentJournalpost(saksnummer, kildesystemIdenfikator)
return response.clearContentHeaders().responseEntity
return journalpostService.hentJournalpost(saksnummer, kildesystemIdenfikator)
}

@GetMapping("/journal/{journalpostIdForKildesystem}/avvik")
Expand Down Expand Up @@ -174,7 +173,7 @@ class JournalpostController(private val journalpostService: JournalpostService)
HttpStatus.BAD_REQUEST,
)
} else {
journalpostService.finnAvvik(saksnummer, kildesystemIdenfikator).responseEntity
journalpostService.finnAvvik(saksnummer, kildesystemIdenfikator)
}
}

Expand Down Expand Up @@ -245,7 +244,7 @@ class JournalpostController(private val journalpostService: JournalpostService)
enhet,
kildesystemIdenfikator,
avvikshendelse,
).responseEntity
)
}
}

Expand Down Expand Up @@ -300,7 +299,7 @@ class JournalpostController(private val journalpostService: JournalpostService)
endreJournalpostCommand.copy(
journalpostId = journalpostIdForKildesystem,
),
).responseEntity
)
}

@PostMapping("/journalpost/{arkivSystem}")
Expand All @@ -323,7 +322,7 @@ class JournalpostController(private val journalpostService: JournalpostService)
@PathVariable arkivSystem: ArkivSystem,
): ResponseEntity<OpprettJournalpostResponse> {
sikkerLogg.info("Oppretter journalpost $opprettJournalpostRequest for arkivsystem $arkivSystem")
return journalpostService.opprett(opprettJournalpostRequest, arkivSystem).responseEntity
return journalpostService.opprett(opprettJournalpostRequest, arkivSystem)
}

@PostMapping("/journal/distribuer/{joarkJournalpostId}")
Expand Down Expand Up @@ -365,7 +364,7 @@ class JournalpostController(private val journalpostService: JournalpostService)
batchId,
kildesystemIdenfikator,
distribuerJournalpostRequest ?: DistribuerJournalpostRequest(),
).responseEntity
)
}

@GetMapping("/journal/distribuer/{journalpostId}/enabled")
Expand Down Expand Up @@ -399,7 +398,7 @@ class JournalpostController(private val journalpostService: JournalpostService)
.header(HttpHeaders.WARNING, msgBadRequest)
.build()
}
return journalpostService.kanDistribuereJournalpost(kildesystemIdenfikator).responseEntity
return journalpostService.kanDistribuereJournalpost(kildesystemIdenfikator)
}

@GetMapping("/journal/distribuer/info/{journalpostId}")
Expand Down
Loading

0 comments on commit 520c4e0

Please sign in to comment.