Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/github_actions/docker/login-actio…
Browse files Browse the repository at this point in the history
…n-3.0.0
  • Loading branch information
stigebil authored Jan 25, 2024
2 parents 4fada2f + 660f2d2 commit c554e25
Show file tree
Hide file tree
Showing 25 changed files with 574 additions and 68 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/build-and-deploy-preprod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ jobs:
permissions:
packages: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-java@v3
- uses: actions/setup-java@v4
with:
java-version: 17
java-version: 21
distribution: 'temurin'
cache: 'maven'
- name: Bygg med maven + sonar
Expand Down Expand Up @@ -49,9 +49,9 @@ jobs:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Deploy til dev-fss team namespace
uses: nais/deploy/actions/deploy@v1
uses: nais/deploy/actions/deploy@v2
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
CLUSTER: dev-fss
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/build-and-deploy-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ jobs:
permissions:
packages: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-java@v3
- uses: actions/setup-java@v4
with:
java-version: 17
java-version: 21
distribution: 'temurin'
cache: 'maven'
- name: Bygg med maven
Expand Down Expand Up @@ -49,15 +49,15 @@ jobs:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Deploy til dev-fss team namespace
uses: nais/deploy/actions/deploy@v1
uses: nais/deploy/actions/deploy@v2
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
CLUSTER: dev-fss
RESOURCE: app-preprod.yaml
- name: Deploy til prod-fss team namespace
uses: nais/deploy/actions/deploy@v1
uses: nais/deploy/actions/deploy@v2
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
CLUSTER: prod-fss
Expand Down
90 changes: 90 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ "main" ]

jobs:
analyze:
name: Analyze
# Runner size impacts CodeQL analysis time. To learn more, please see:
# - https://gh.io/recommended-hardware-resources-for-running-codeql
# - https://gh.io/supported-runners-and-hardware-resources
# - https://gh.io/using-larger-runners
# Consider using larger runners for possible analysis time improvements.
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
permissions:
# required for all workflows
security-events: write

# only required for workflows in private repositories
actions: read
contents: read

strategy:
fail-fast: false
matrix:
language: [ 'java-kotlin' ]
# CodeQL supports [ 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' ]
# Use only 'java-kotlin' to analyze code written in Java, Kotlin or both
# Use only 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

steps:
- name: Checkout repository
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality


# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Sett opp java
uses: actions/setup-java@v4
with:
java-version: 21
distribution: 'temurin'
cache: 'maven'
- name: Bygg med maven
env:
GITHUB_USERNAME: x-access-token
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: mvn -B --no-transfer-progress compile --settings .m2/maven-settings.xml


# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ghcr.io/navikt/baseimages/temurin:17-appdynamics
FROM ghcr.io/navikt/baseimages/temurin:21-appdynamics

ENV APPD_ENABLED=true
ENV APP_NAME=familie-oppdrag
Expand Down
4 changes: 1 addition & 3 deletions app-preprod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,7 @@ spec:
external:
- host: b27apvl220.preprod.local
ports:
- name: mq
port: 1413
protocol: TCP
- port: 1413
env:
- name: SPRING_PROFILES_ACTIVE
value: preprod
Expand Down
4 changes: 1 addition & 3 deletions app-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ spec:
external:
- host: mpls02.adeo.no
ports:
- name: mq
port: 1414
protocol: TCP
- port: 1414
env:
- name: SPRING_PROFILES_ACTIVE
value: prod
Expand Down
16 changes: 8 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.1.2</version>
<version>3.2.2</version>
</parent>

<properties>
<revision>1.0</revision>
<sha1/>
<changelist>-SNAPSHOT</changelist>
<jvmTarget>17</jvmTarget>
<kotlin.version>1.9.0</kotlin.version>
<jvmTarget>21</jvmTarget>
<kotlin.version>1.9.22</kotlin.version>
<main-class>no.nav.familie.oppdrag.LauncherKt</main-class>
<felles.version>2.20230508082643_6b28bd8</felles.version>
<kontrakter.version>3.0_20230808083340_ced4750</kontrakter.version>
<token-validation-spring.version>3.1.2</token-validation-spring.version>
<kontrakter.version>3.0_20240122110213_5591a29</kontrakter.version>
<token-validation-spring.version>3.2.0</token-validation-spring.version>

<!--
denne må oppdateres manuellt då eks `mvn versions:update-properties` henter versjon 2023.
Expand All @@ -43,10 +43,10 @@
</sonar.coverage.exclusions>
<!--suppress UnresolvedMavenProperty Ligger som secret i github-->
<sonar.login>${SONAR_LOGIN}</sonar.login>
<spring-cloud.version>2022.0.4</spring-cloud.version>
<testcontainers.version>1.18.3</testcontainers.version>
<spring-cloud.version>2023.0.0</spring-cloud.version>
<testcontainers.version>1.19.3</testcontainers.version>
<tjenestespesifikasjoner.version>1.0_20230718100517_1e1beb0</tjenestespesifikasjoner.version>
<springdoc.version>2.2.0</springdoc.version>
<springdoc.version>2.3.0</springdoc.version>

</properties>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package no.nav.familie.oppdrag.repository

import java.util.UUID
import org.springframework.data.annotation.Id
import org.springframework.data.relational.core.mapping.Table

@Table("tidligere_kjoerte_grensesnittavstemminger")
class TidligereKjørtGrensesnittavstemming(
@Id val id: UUID
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package no.nav.familie.oppdrag.repository

import java.util.Optional
import java.util.UUID
import org.springframework.data.repository.CrudRepository
import org.springframework.stereotype.Repository

@Repository
interface TidligereKjørteGrensesnittavstemmingerRepository : InsertUpdateRepository<TidligereKjørtGrensesnittavstemming>,
CrudRepository<TidligereKjørtGrensesnittavstemming, UUID>
23 changes: 22 additions & 1 deletion src/main/kotlin/no/nav/familie/oppdrag/rest/OppdragController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import no.nav.familie.oppdrag.common.RessursUtils.notFound
import no.nav.familie.oppdrag.common.RessursUtils.ok
import no.nav.familie.oppdrag.iverksetting.OppdragMapper
import no.nav.familie.oppdrag.service.OppdragAlleredeSendtException
import no.nav.familie.oppdrag.service.OppdragHarAlleredeKvitteringException
import no.nav.familie.oppdrag.service.OppdragService
import no.nav.security.token.support.core.api.ProtectedWithClaims
import org.springframework.beans.factory.annotation.Autowired
Expand Down Expand Up @@ -76,7 +77,7 @@ class OppdragController(
}

@PostMapping("resend")
fun resentOppdrag(
fun resendOppdrag(
@Valid @RequestBody
oppdragId: OppdragId,
) {
Expand All @@ -98,4 +99,24 @@ class OppdragController(
},
)
}

@PostMapping(consumes = [MediaType.APPLICATION_JSON_VALUE], path = ["/oppdrag/manuell-kvittering"])
fun opprettManuellKvitteringPåOppdrag(
@Valid @RequestBody
oppdragId: OppdragId,
): ResponseEntity<Ressurs<OppdragStatus>> {
return Result.runCatching { oppdragService.opprettManuellKvitteringPåOppdrag(oppdragId) }
.fold(
onFailure = {
if (it is OppdragHarAlleredeKvitteringException) {
conflict("Oppdrag med id $oppdragId er allerede kvittert ut.")
} else {
illegalState("Klarte ikke opprette manuell kvittering for oppdrag med id $oppdragId", it)
}
},
onSuccess = {
ok(it.status, it.kvitteringsmelding?.beskrMelding ?: "Savner kvitteringsmelding")
},
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@ import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Value
import org.springframework.stereotype.Service
import java.time.LocalDateTime
import no.nav.familie.oppdrag.repository.TidligereKjørtGrensesnittavstemming
import no.nav.familie.oppdrag.repository.TidligereKjørteGrensesnittavstemmingerRepository
import kotlin.jvm.optionals.getOrNull

@Service
class GrensesnittavstemmingService(
private val avstemmingSender: AvstemmingSender,
private val oppdragLagerRepository: OppdragLagerRepository,
private val tidligereKjørteGrensesnittavstemmingerRepository: TidligereKjørteGrensesnittavstemmingerRepository,
@Value("\${grensesnitt.antall:7000}") private val antall: Int,
) {

Expand All @@ -31,7 +35,15 @@ class GrensesnittavstemmingService(
}

fun utførGrensesnittavstemming(request: GrensesnittavstemmingRequest) {
val (fagsystem: String, fra: LocalDateTime, til: LocalDateTime) = request
val (fagsystem: String, fra: LocalDateTime, til: LocalDateTime, avstemmingId) = request

val erGrensesnittavstemmingKjørtPåSammeAvstemmingId =
avstemmingId?.let { tidligereKjørteGrensesnittavstemmingerRepository.findById(it).getOrNull() } != null
if (erGrensesnittavstemmingKjørtPåSammeAvstemmingId) {
LOG.info("Grensesnittavstemming er allerede fullført for $avstemmingId og vil ikke bli kjørt på nytt")
return
}

var page = 0
var antallOppdragSomSkalAvstemmes = 0
var oppdragSomSkalAvstemmes =
Expand All @@ -55,6 +67,10 @@ class GrensesnittavstemmingService(
avstemmingSender.sendGrensesnittAvstemming(totalmelding)
avstemmingSender.sendGrensesnittAvstemming(avstemmingMapper.lagSluttmelding())

if (avstemmingId != null) {
tidligereKjørteGrensesnittavstemmingerRepository.insert(TidligereKjørtGrensesnittavstemming(avstemmingId))
}

LOG.info(
"Fullført grensesnittavstemming for id: ${avstemmingMapper.avstemmingId}" +
" antallOppdragSomSkalAvstemmes=$antallOppdragSomSkalAvstemmes",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ interface OppdragService {
fun opprettOppdrag(utbetalingsoppdrag: Utbetalingsoppdrag, oppdrag: Oppdrag, versjon: Int)
fun hentStatusForOppdrag(oppdragId: OppdragId): OppdragLager
fun resendOppdrag(oppdragId: OppdragId)
fun opprettManuellKvitteringPåOppdrag(oppdragId: OppdragId): OppdragLager
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ class OppdragServiceE2E(
throw NotImplementedError("Ikke implementert")
}

override fun opprettManuellKvitteringPåOppdrag(oppdragId: OppdragId): OppdragLager {
throw NotImplementedError("Ikke implementert")
}

companion object {

val LOG = LoggerFactory.getLogger(OppdragServiceE2E::class.java)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import no.nav.familie.oppdrag.iverksetting.Jaxb
import no.nav.familie.oppdrag.iverksetting.OppdragSender
import no.nav.familie.oppdrag.repository.OppdragLager
import no.nav.familie.oppdrag.repository.OppdragLagerRepository
import no.trygdeetaten.skjema.oppdrag.Mmel
import no.trygdeetaten.skjema.oppdrag.Oppdrag
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
Expand Down Expand Up @@ -52,10 +53,31 @@ class OppdragServiceImpl(
oppdragSender.sendOppdrag(oppdragXml)
}

@Transactional
override fun opprettManuellKvitteringPåOppdrag(oppdragId: OppdragId): OppdragLager {
val oppdrag = oppdragLagerRepository.hentOppdrag(oppdragId)

if (oppdrag.status != OppdragStatus.LAGT_PÅ_KØ) {
throw OppdragHarAlleredeKvitteringException("Oppdrag med id $oppdragId er allerede kvittert ut.")
}

val manuellKvittering = Mmel().apply { beskrMelding = "Manuelt kvittert ut" }

oppdragLagerRepository.oppdaterKvitteringsmelding(
oppdragId = oppdragId,
oppdragStatus = OppdragStatus.KVITTERT_OK,
kvittering = manuellKvittering,
versjon = oppdrag.versjon + 1,
)

return oppdrag
}

companion object {

val LOG = LoggerFactory.getLogger(OppdragServiceImpl::class.java)
}
}

class OppdragAlleredeSendtException() : RuntimeException()
class OppdragHarAlleredeKvitteringException(melding: String) : RuntimeException(melding)
2 changes: 1 addition & 1 deletion src/main/resources/application-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ no.nav.security.jwt:

spring:
datasource:
url: jdbc:postgresql://A01DBVL011.adeo.no:5432/familie-oppdrag
url: jdbc:postgresql://A01DBVL035.adeo.no:5432/familie-oppdrag-15

OPPDRAG_SERVICE_URL: https://wasapp.adeo.no/cics/services/simulerFpServiceWSBinding
SECURITYTOKENSERVICE_URL: https://sts.adeo.no/SecurityTokenServiceProvider/
Expand Down
Loading

0 comments on commit c554e25

Please sign in to comment.