diff --git a/.github/workflows/app.ereg-batch-status-service.yml b/.github/workflows/app.ereg-batch-status-service.yml deleted file mode 100644 index 750485f41f1..00000000000 --- a/.github/workflows/app.ereg-batch-status-service.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: ereg-batch-status-service - -on: - push: - paths: - - "plugins/**" - - "libs/data-transfer-objects/**" - - "libs/reactive-core/**" - - "libs/servlet-core/**" - - "libs/servlet-security/**" - - "apps/ereg-batch-status-service/**" - - ".github/workflows/app.ereg-batch-status-service.yml" - -jobs: - workflow: - uses: ./.github/workflows/common.workflow.backend.yml - with: - cluster: "dev-gcp" - working-directory: "apps/ereg-batch-status-service" - deploy-tag: "#deploy-ereg-batch-status-service" - permissions: - contents: read - id-token: write - secrets: inherit diff --git a/.github/workflows/proxy.modapp-ereg-proxy.yml b/.github/workflows/proxy.modapp-ereg-proxy.yml deleted file mode 100644 index 51cc7d2df5a..00000000000 --- a/.github/workflows/proxy.modapp-ereg-proxy.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: modapp-ereg-proxy - -on: - push: - paths: - - "plugins/**" - - "libs/reactive-core/**" - - "libs/reactive-proxy/**" - - "libs/reactive-security/**" - - "libs/security-core/**" - - "proxies/modapp-ereg-proxy/**" - - ".github/workflows/proxy.modapp-ereg-proxy.yml" - -jobs: - workflow: - uses: ./.github/workflows/common.workflow.backend.yml - with: - cluster: "dev-fss" - working-directory: "proxies/modapp-ereg-proxy" - deploy-tag: "#deploy-proxy" - permissions: - contents: read - id-token: write - secrets: inherit diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/DollyBackendApplicationStarter.java b/apps/dolly-backend/src/main/java/no/nav/dolly/DollyBackendApplicationStarter.java index f0ef428e58d..6af8668f777 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/DollyBackendApplicationStarter.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/DollyBackendApplicationStarter.java @@ -10,4 +10,4 @@ public static void main(String[] args) { SpringApplication.run(DollyBackendApplicationStarter.class, args); } -} +} \ No newline at end of file diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/organisasjonforvalter/OrganisasjonConsumer.java b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/organisasjonforvalter/OrganisasjonConsumer.java index 2eb3f95ca40..9a31762819b 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/organisasjonforvalter/OrganisasjonConsumer.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/organisasjonforvalter/OrganisasjonConsumer.java @@ -19,6 +19,7 @@ import org.springframework.stereotype.Service; import org.springframework.web.reactive.function.client.WebClient; import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; import reactor.util.retry.Retry; import java.time.Duration; @@ -67,7 +68,7 @@ public Flux hentOrganisasjon(List orgnumre) { .flatMapMany(token -> new GetOrganisasjonCommand(webClient, orgnumre, token.getTokenValue()).call()); } - @Timed(name = "providers", tags = {"operation", "organisasjon-hent"}) + @Timed(name = "providers", tags = {"operation", "organisasjon-status-hent"}) public OrganisasjonDeployStatus hentOrganisasjonStatus(List orgnumre) { var navCallId = getNavCallId(); log.info("Organisasjon hent request sendt, callId: {}, consumerId: {}", navCallId, CONSUMER); @@ -85,8 +86,9 @@ public OrganisasjonDeployStatus hentOrganisasjonStatus(List orgnumre) { .header(HEADER_NAV_CONSUMER_ID, CONSUMER) .retrieve() .bodyToMono(OrganisasjonDeployStatus.class) - .retryWhen(Retry.backoff(3, Duration.ofSeconds(5)) - .filter(WebClientFilter::is5xxException))) + .doOnError(WebClientFilter::logErrorMessage) + .onErrorResume(throwable -> Mono.empty()) + ) .block(); } diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/organisasjonforvalter/command/GetOrganisasjonCommand.java b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/organisasjonforvalter/command/GetOrganisasjonCommand.java index a69e12e3491..9ffd0b43654 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/organisasjonforvalter/command/GetOrganisasjonCommand.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/organisasjonforvalter/command/GetOrganisasjonCommand.java @@ -37,6 +37,7 @@ public Flux call() { .bodyToFlux(OrganisasjonDetaljer.class) .doOnError(WebClientFilter::logErrorMessage) .retryWhen(Retry.backoff(3, Duration.ofSeconds(5)) - .filter(WebClientFilter::is5xxException)); + .filter(WebClientFilter::is5xxException)) + .onErrorResume(throwable -> Flux.empty()); } } diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/mapper/BestillingOrganisasjonStatusMapper.java b/apps/dolly-backend/src/main/java/no/nav/dolly/mapper/BestillingOrganisasjonStatusMapper.java index 7a672c3f6e0..4154ea2282b 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/mapper/BestillingOrganisasjonStatusMapper.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/mapper/BestillingOrganisasjonStatusMapper.java @@ -14,6 +14,7 @@ import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; import static java.util.Objects.isNull; +import static java.util.Objects.nonNull; import static no.nav.dolly.domain.resultset.SystemTyper.ORGANISASJON_FORVALTER; @NoArgsConstructor(access = AccessLevel.PRIVATE) @@ -29,8 +30,6 @@ public static List buildOrganisasjonStatusMap(Organ List.of(progress.getOrganisasjonsforvalterStatus() .replace(",q", "$q") - .replace(",t", "$t") - .replace(",u", "$u") .split("\\$")).forEach(status -> { String[] environMsg = status.split(":", 2); if (environMsg.length < 2) { @@ -65,9 +64,11 @@ public static List buildOrganisasjonStatusMap(Organ } private static String getOrgStatusDetailForMiljo(List orgStatuser, String miljo) { - return orgStatuser.stream() - .filter(orgStatus -> orgStatus.getEnvironment().equals(miljo)) - .findFirst().orElseGet(OrganisasjonDeployStatus.OrgStatus::new) - .getDetails(); + + return nonNull(orgStatuser) ? orgStatuser.stream() + .filter(orgStatus -> miljo.equals(orgStatus.getEnvironment())) + .map(status -> "%s %s".formatted(status.getDetails(), + status.getDetails().contains("feil") ? status.getError() : "")) + .findFirst().orElse("") : ""; } } diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/service/OrganisasjonBestillingService.java b/apps/dolly-backend/src/main/java/no/nav/dolly/service/OrganisasjonBestillingService.java index c3d62a0478f..bb0b8e70505 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/service/OrganisasjonBestillingService.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/service/OrganisasjonBestillingService.java @@ -27,6 +27,7 @@ import org.springframework.web.reactive.function.client.WebClientResponseException; import reactor.core.publisher.Flux; +import java.util.Arrays; import java.util.Collection; import java.util.Comparator; import java.util.List; @@ -92,7 +93,7 @@ public RsOrganisasjonBestillingStatus fetchBestillingStatusById(Long bestillingI } return RsOrganisasjonBestillingStatus.builder() - .status(BestillingOrganisasjonStatusMapper.buildOrganisasjonStatusMap(bestillingProgress, nonNull(orgStatusList) ? orgStatusList : emptyList())) + .status(BestillingOrganisasjonStatusMapper.buildOrganisasjonStatusMap(bestillingProgress, orgStatusList)) .bestilling(jsonBestillingMapper.mapOrganisasjonBestillingRequest(bestilling.getBestKriterier())) .sistOppdatert(bestilling.getSistOppdatert()) .organisasjonNummer(bestillingProgress.getOrganisasjonsnummer()) @@ -249,12 +250,15 @@ private void updateBestilling(OrganisasjonBestilling bestilling, List bestilling.setFeil(feil); - var ferdig = orgStatus.stream() - .anyMatch(o -> DEPLOY_ENDED_STATUS_LIST.stream().anyMatch(status -> status.equals(o.getStatus()))); + var ferdig = !orgStatus.isEmpty() && orgStatus.stream() + .allMatch(o -> DEPLOY_ENDED_STATUS_LIST.stream() + .anyMatch(status -> status.equals(o.getStatus()))) && + Arrays.stream(bestilling.getMiljoer().split(",")) + .allMatch(miljoe -> orgStatus.stream() + .anyMatch(o -> o.getEnvironment().equals(miljoe))); bestilling.setFerdig(ferdig); bestilling.setSistOppdatert(now()); - } private String forvalterStatusDetails(OrgStatus orgStatus) { @@ -274,17 +278,21 @@ private List getOrgforvalterStatus(OrganisasjonBestilling bestilling, log.info("Status for org deploy på org: {} - {}", bestillingProgress.getOrganisasjonsnummer(), organisasjonDeployStatus); - var orgStatus = organisasjonDeployStatus.getOrgStatus() - .getOrDefault(bestillingProgress.getOrganisasjonsnummer(), emptyList()); + if (nonNull(organisasjonDeployStatus)) { + var orgStatus = organisasjonDeployStatus.getOrgStatus() + .getOrDefault(bestillingProgress.getOrganisasjonsnummer(), emptyList()); - updateBestilling(bestilling, orgStatus); + updateBestilling(bestilling, orgStatus); - var forvalterStatus = orgStatus.stream() - .map(org -> org.getEnvironment() + ":" + forvalterStatusDetails(org)) - .collect(Collectors.joining(",")); - bestillingProgress.setOrganisasjonsforvalterStatus(forvalterStatus); + var forvalterStatus = orgStatus.stream() + .map(org -> org.getEnvironment() + ":" + forvalterStatusDetails(org)) + .collect(Collectors.joining(",")); + bestillingProgress.setOrganisasjonsforvalterStatus(forvalterStatus); + return orgStatus; - return orgStatus; + } else { + return emptyList(); + } } private String toJson(Object object) { diff --git a/apps/dolly-backend/src/main/resources/application-local.yaml b/apps/dolly-backend/src/main/resources/application-local.yaml index 204ee224f7e..0d82f5cf55b 100644 --- a/apps/dolly-backend/src/main/resources/application-local.yaml +++ b/apps/dolly-backend/src/main/resources/application-local.yaml @@ -12,11 +12,8 @@ spring: enabled: false datasource: url: jdbc:postgresql://localhost:5432/dolly-test - username: postgres - hikari: - maximum-pool-size: 3 - minimum-idle: 1 driver-class-name: org.postgresql.Driver + username: postgres management: endpoints: diff --git a/apps/ereg-batch-status-service/Dockerfile b/apps/ereg-batch-status-service/Dockerfile deleted file mode 100644 index 4a36f93546f..00000000000 --- a/apps/ereg-batch-status-service/Dockerfile +++ /dev/null @@ -1,8 +0,0 @@ -FROM ghcr.io/navikt/baseimages/temurin:21 -LABEL maintainer="Team Dolly" - -ENV JAVA_OPTS="-Dspring.profiles.active=prod" - -ADD /build/libs/app.jar /app/app.jar - -EXPOSE 8080 diff --git a/apps/ereg-batch-status-service/README.md b/apps/ereg-batch-status-service/README.md deleted file mode 100644 index 030a76d60dc..00000000000 --- a/apps/ereg-batch-status-service/README.md +++ /dev/null @@ -1,19 +0,0 @@ -# Ereg Batch-status Service -App for å hente ut batch status. - -## Swagger -Swagger finnes under [/swagger](https://testnav-ereg-batch-status-service.intern.dev.nav.no/swagger) -endepunktet til applikasjonen. - -## Lokal kjøring -Ha naisdevice kjørende og kjør EregBatchServiceServiceApplicationStarter med følgende argumenter: -``` --Dspring.cloud.vault.token=[kopier token fra vault] --Dspring.profiles.active=dev -``` - -### Utviklerimage -I utviklerimage brukes ikke naisdevice og du må legge til følgende ekstra argumenter: -``` --Djavax.net.ssl.trustStore=[path til lokal truststore] --Djavax.net.ssl.trustStorePassword=[passord til lokal truststore] -``` diff --git a/apps/ereg-batch-status-service/build.gradle b/apps/ereg-batch-status-service/build.gradle deleted file mode 100644 index d0262742b65..00000000000 --- a/apps/ereg-batch-status-service/build.gradle +++ /dev/null @@ -1,30 +0,0 @@ -plugins { - id "dolly-apps" -} - -sonarqube { - properties { - property "sonar.projectKey", "testnav-ereg-batch-status-service" - property "sonar.projectName", "testnav-ereg-batch-status-service" - } -} - -dependencies { - - - implementation 'no.nav.testnav.libs:data-transfer-objects' - implementation 'no.nav.testnav.libs:reactive-core' - implementation 'no.nav.testnav.libs:reactive-security' - implementation 'no.nav.testnav.libs:security-core' - - implementation 'org.springframework.boot:spring-boot-starter-oauth2-client' - implementation 'org.springframework.boot:spring-boot-starter-oauth2-resource-server' - implementation 'org.springframework.boot:spring-boot-starter-security' - - implementation 'org.springframework.cloud:spring-cloud-starter-gateway' - - implementation "org.springdoc:springdoc-openapi-starter-webflux-ui:$versions.springdoc" - implementation "io.swagger.core.v3:swagger-annotations-jakarta:$versions.swagger" - - testImplementation 'org.springframework.cloud:spring-cloud-contract-wiremock' -} diff --git a/apps/ereg-batch-status-service/config.yml b/apps/ereg-batch-status-service/config.yml deleted file mode 100644 index 05ff669ed3e..00000000000 --- a/apps/ereg-batch-status-service/config.yml +++ /dev/null @@ -1,61 +0,0 @@ -apiVersion: "nais.io/v1alpha1" -kind: "Application" -metadata: - name: ereg-batch-status-service - namespace: dolly - labels: - team: dolly -spec: - image: "{{image}}" - port: 8080 - webproxy: true - accessPolicy: - inbound: - rules: - - application: team-dolly-lokal-app - cluster: dev-gcp - - application: testnav-oversikt-frontend - cluster: dev-gcp - - application: organisasjon-bestilling-service - cluster: dev-gcp - outbound: - external: - - host: testnav-modapp-ereg-proxy.dev-fss-pub.nais.io - tokenx: - enabled: true - azure: - application: - allowAllUsers: true - enabled: true - tenant: nav.no - liveness: - path: /internal/isAlive - initialDelay: 4 - periodSeconds: 5 - failureThreshold: 500 - observability: - logging: - destinations: - - id: elastic - autoInstrumentation: - enabled: true - runtime: java - readiness: - path: /internal/isReady - initialDelay: 4 - periodSeconds: 5 - failureThreshold: 500 - prometheus: - enabled: true - path: /internal/metrics - replicas: - min: 1 - max: 1 - resources: - requests: - cpu: 200m - memory: 1024Mi - limits: - memory: 2048Mi - ingresses: - - "https://testnav-ereg-batch-status-service.intern.dev.nav.no" \ No newline at end of file diff --git a/apps/ereg-batch-status-service/gradle/wrapper/gradle-wrapper.jar b/apps/ereg-batch-status-service/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 7454180f2ae..00000000000 Binary files a/apps/ereg-batch-status-service/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/apps/ereg-batch-status-service/gradle/wrapper/gradle-wrapper.properties b/apps/ereg-batch-status-service/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 48c0a02ca41..00000000000 --- a/apps/ereg-batch-status-service/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/apps/ereg-batch-status-service/gradlew b/apps/ereg-batch-status-service/gradlew deleted file mode 100755 index 3da45c161b0..00000000000 --- a/apps/ereg-batch-status-service/gradlew +++ /dev/null @@ -1,234 +0,0 @@ -#!/bin/sh - -# -# Copyright ? 2015-2021 the original authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -############################################################################## -# -# Gradle start up script for POSIX generated by Gradle. -# -# Important for running: -# -# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is -# noncompliant, but you have some other compliant shell such as ksh or -# bash, then to run this script, type that shell name before the whole -# command line, like: -# -# ksh Gradle -# -# Busybox and similar reduced shells will NOT work, because this script -# requires all of these POSIX shell features: -# * functions; -# * expansions ?$var?, ?${var}?, ?${var:-default}?, ?${var+SET}?, -# ?${var#prefix}?, ?${var%suffix}?, and ?$( cmd )?; -# * compound commands having a testable exit status, especially ?case?; -# * various built-in commands including ?command?, ?set?, and ?ulimit?. -# -# Important for patching: -# -# (2) This script targets any POSIX shell, so it avoids extensions provided -# by Bash, Ksh, etc; in particular arrays are avoided. -# -# The "traditional" practice of packing multiple parameters into a -# space-separated string is a well documented source of bugs and security -# problems, so this is (mostly) avoided, by progressively accumulating -# options in "$@", and eventually passing that to Java. -# -# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, -# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; -# see the in-line comments for details. -# -# There are tweaks for specific operating systems such as AIX, CygWin, -# Darwin, MinGW, and NonStop. -# -# (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt -# within the Gradle project. -# -# You can find Gradle at https://github.com/gradle/gradle/. -# -############################################################################## - -# Attempt to set APP_HOME - -# Resolve links: $0 may be a link -app_path=$0 - -# Need this for daisy-chained symlinks. -while - APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path - [ -h "$app_path" ] -do - ls=$( ls -ld "$app_path" ) - link=${ls#*' -> '} - case $link in #( - /*) app_path=$link ;; #( - *) app_path=$APP_HOME$link ;; - esac -done - -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" -APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD=maximum - -warn () { - echo "$*" -} >&2 - -die () { - echo - echo "$*" - echo - exit 1 -} >&2 - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "$( uname )" in #( - CYGWIN* ) cygwin=true ;; #( - Darwin* ) darwin=true ;; #( - MSYS* | MINGW* ) msys=true ;; #( - NONSTOP* ) nonstop=true ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD=$JAVA_HOME/jre/sh/java - else - JAVACMD=$JAVA_HOME/bin/java - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then - case $MAX_FD in #( - max*) - MAX_FD=$( ulimit -H -n ) || - warn "Could not query maximum file descriptor limit" - esac - case $MAX_FD in #( - '' | soft) :;; #( - *) - ulimit -n "$MAX_FD" || - warn "Could not set maximum file descriptor limit to $MAX_FD" - esac -fi - -# Collect all arguments for the java command, stacking in reverse order: -# * args from the command line -# * the main class name -# * -classpath -# * -D...appname settings -# * --module-path (only if needed) -# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. - -# For Cygwin or MSYS, switch paths to Windows format before running java -if "$cygwin" || "$msys" ; then - APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) - - JAVACMD=$( cygpath --unix "$JAVACMD" ) - - # Now convert the arguments - kludge to limit ourselves to /bin/sh - for arg do - if - case $arg in #( - -*) false ;; # don't mess with options #( - /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath - [ -e "$t" ] ;; #( - *) false ;; - esac - then - arg=$( cygpath --path --ignore --mixed "$arg" ) - fi - # Roll the args list around exactly as many times as the number of - # args, so each arg winds up back in the position where it started, but - # possibly modified. - # - # NB: a `for` loop captures its iteration list before it begins, so - # changing the positional parameters here affects neither the number of - # iterations, nor the values presented in `arg`. - shift # remove old arg - set -- "$@" "$arg" # push replacement arg - done -fi - -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. - -set -- \ - "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ - "$@" - -# Use "xargs" to parse quoted args. -# -# With -n1 it outputs one arg per line, with the quotes and backslashes removed. -# -# In Bash we could simply go: -# -# readarray ARGS < <( xargs -n1 <<<"$var" ) && -# set -- "${ARGS[@]}" "$@" -# -# but POSIX shell has neither arrays nor command substitution, so instead we -# post-process each arg (as a line of input to sed) to backslash-escape any -# character that might be a shell metacharacter, then use eval to reverse -# that process (while maintaining the separation between arguments), and wrap -# the whole thing up as a single "set" statement. -# -# This will of course break if any of these variables contains a newline or -# an unmatched quote. -# - -eval "set -- $( - printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | - xargs -n1 | - sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | - tr '\n' ' ' - )" '"$@"' - -exec "$JAVACMD" "$@" diff --git a/apps/ereg-batch-status-service/gradlew.bat b/apps/ereg-batch-status-service/gradlew.bat deleted file mode 100644 index ac1b06f9382..00000000000 --- a/apps/ereg-batch-status-service/gradlew.bat +++ /dev/null @@ -1,89 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/apps/ereg-batch-status-service/gradlewUpdate.sh b/apps/ereg-batch-status-service/gradlewUpdate.sh deleted file mode 100755 index e5ee6361152..00000000000 --- a/apps/ereg-batch-status-service/gradlewUpdate.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -gradle wrapper \ No newline at end of file diff --git a/apps/ereg-batch-status-service/settings.gradle b/apps/ereg-batch-status-service/settings.gradle deleted file mode 100644 index bcd8fc92ccc..00000000000 --- a/apps/ereg-batch-status-service/settings.gradle +++ /dev/null @@ -1,19 +0,0 @@ -plugins { - id "com.gradle.develocity" version "3.17.4" -} - -rootProject.name = 'ereg-batch-status-service' - -includeBuild "../../plugins/java" - -includeBuild '../../libs/data-transfer-objects' -includeBuild '../../libs/reactive-core' -includeBuild '../../libs/reactive-security' -includeBuild '../../libs/security-core' - -develocity { - buildScan { - termsOfUseUrl = "https://gradle.com/terms-of-service" - termsOfUseAgree = "yes" - } -} \ No newline at end of file diff --git a/apps/ereg-batch-status-service/src/main/java/no/nav/registre/testnorge/eregbatchstatusservice/EregbatchStatusServiceApplicationStarter.java b/apps/ereg-batch-status-service/src/main/java/no/nav/registre/testnorge/eregbatchstatusservice/EregbatchStatusServiceApplicationStarter.java deleted file mode 100644 index c0cae1737a9..00000000000 --- a/apps/ereg-batch-status-service/src/main/java/no/nav/registre/testnorge/eregbatchstatusservice/EregbatchStatusServiceApplicationStarter.java +++ /dev/null @@ -1,11 +0,0 @@ -package no.nav.registre.testnorge.eregbatchstatusservice; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class EregbatchStatusServiceApplicationStarter { - public static void main(String[] args) { - SpringApplication.run(EregbatchStatusServiceApplicationStarter.class, args); - } -} \ No newline at end of file diff --git a/apps/ereg-batch-status-service/src/main/java/no/nav/registre/testnorge/eregbatchstatusservice/config/ApplicationConfig.java b/apps/ereg-batch-status-service/src/main/java/no/nav/registre/testnorge/eregbatchstatusservice/config/ApplicationConfig.java deleted file mode 100644 index 6e6b082290c..00000000000 --- a/apps/ereg-batch-status-service/src/main/java/no/nav/registre/testnorge/eregbatchstatusservice/config/ApplicationConfig.java +++ /dev/null @@ -1,19 +0,0 @@ -package no.nav.registre.testnorge.eregbatchstatusservice.config; - -import no.nav.testnav.libs.reactivecore.config.CoreConfig; -import no.nav.testnav.libs.reactivesecurity.config.SecureOAuth2ServerToServerConfiguration; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.web.reactive.config.EnableWebFlux; - - -@Configuration -@EnableWebFlux -@Import({ - CoreConfig.class, - SecurityConfig.class, - SecureOAuth2ServerToServerConfiguration.class -}) -public class ApplicationConfig { - -} diff --git a/apps/ereg-batch-status-service/src/main/java/no/nav/registre/testnorge/eregbatchstatusservice/config/Consumers.java b/apps/ereg-batch-status-service/src/main/java/no/nav/registre/testnorge/eregbatchstatusservice/config/Consumers.java deleted file mode 100644 index a39eadfc259..00000000000 --- a/apps/ereg-batch-status-service/src/main/java/no/nav/registre/testnorge/eregbatchstatusservice/config/Consumers.java +++ /dev/null @@ -1,29 +0,0 @@ -package no.nav.registre.testnorge.eregbatchstatusservice.config; - -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import no.nav.testnav.libs.securitycore.domain.ServerProperties; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Configuration; - -import static lombok.AccessLevel.PACKAGE; - -/** - * Samler alle placeholders for ulike {@code consumers.*}-konfigurasjon her, dvs. subklasser av {@code ServerProperties}. - *

- * Husk at Spring Boot bruker relaxed binding - * mellom configuration properties og field names. - * - * @see ServerProperties - */ -@Configuration -@ConfigurationProperties(prefix = "consumers") -@NoArgsConstructor(access = PACKAGE) -@Getter -@Setter(PACKAGE) -public class Consumers { - - private ServerProperties modappEregProxy; - -} diff --git a/apps/ereg-batch-status-service/src/main/java/no/nav/registre/testnorge/eregbatchstatusservice/config/DevConfig.java b/apps/ereg-batch-status-service/src/main/java/no/nav/registre/testnorge/eregbatchstatusservice/config/DevConfig.java deleted file mode 100644 index 2fb05ce0a2a..00000000000 --- a/apps/ereg-batch-status-service/src/main/java/no/nav/registre/testnorge/eregbatchstatusservice/config/DevConfig.java +++ /dev/null @@ -1,36 +0,0 @@ -package no.nav.registre.testnorge.eregbatchstatusservice.config; - -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; -import org.springframework.vault.annotation.VaultPropertySource; -import org.springframework.vault.authentication.ClientAuthentication; -import org.springframework.vault.authentication.TokenAuthentication; -import org.springframework.vault.client.VaultEndpoint; -import org.springframework.vault.config.AbstractVaultConfiguration; - -import static io.micrometer.common.util.StringUtils.isBlank; - -@Configuration -@Profile("dev") -@VaultPropertySource(value = "secret/dolly/lokal", ignoreSecretNotFound = false) -public class DevConfig extends AbstractVaultConfiguration { - - private static final String VAULT_TOKEN = "spring.cloud.vault.token"; - - @Override - public VaultEndpoint vaultEndpoint() { - return VaultEndpoint.create("vault.adeo.no", 443); - } - - @Override - public ClientAuthentication clientAuthentication() { - if (System.getenv().containsKey("VAULT_TOKEN")) { - System.setProperty(VAULT_TOKEN, System.getenv("VAULT_TOKEN")); - } - var token = System.getProperty(VAULT_TOKEN); - if (isBlank(token)) { - throw new IllegalArgumentException("Påkrevet property 'spring.cloud.vault.token' er ikke satt."); - } - return new TokenAuthentication(System.getProperty(VAULT_TOKEN)); - } -} \ No newline at end of file diff --git a/apps/ereg-batch-status-service/src/main/java/no/nav/registre/testnorge/eregbatchstatusservice/config/OpenApiConfig.java b/apps/ereg-batch-status-service/src/main/java/no/nav/registre/testnorge/eregbatchstatusservice/config/OpenApiConfig.java deleted file mode 100644 index d72806f2a12..00000000000 --- a/apps/ereg-batch-status-service/src/main/java/no/nav/registre/testnorge/eregbatchstatusservice/config/OpenApiConfig.java +++ /dev/null @@ -1,48 +0,0 @@ -package no.nav.registre.testnorge.eregbatchstatusservice.config; - -import io.swagger.v3.oas.models.Components; -import io.swagger.v3.oas.models.OpenAPI; -import io.swagger.v3.oas.models.info.Contact; -import io.swagger.v3.oas.models.info.Info; -import io.swagger.v3.oas.models.info.License; -import io.swagger.v3.oas.models.security.SecurityRequirement; -import io.swagger.v3.oas.models.security.SecurityScheme; -import no.nav.testnav.libs.reactivecore.config.ApplicationProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.http.HttpHeaders; - -import java.util.Arrays; - -@Configuration -public class OpenApiConfig { - - @Bean - public OpenAPI openApi(ApplicationProperties applicationProperties) { - return new OpenAPI() - .components(new Components().addSecuritySchemes("bearer-jwt", new SecurityScheme() - .type(SecurityScheme.Type.HTTP) - .scheme("bearer") - .bearerFormat("JWT") - .in(SecurityScheme.In.HEADER) - .name(HttpHeaders.AUTHORIZATION) - )) - .addSecurityItem( - new SecurityRequirement().addList("bearer-jwt", Arrays.asList("read", "write"))) - .info(new Info() - .title(applicationProperties.getName()) - .version(applicationProperties.getVersion()) - .description(applicationProperties.getDescription()) - .termsOfService("https://nav.no") - .contact(new Contact() - .url("https://nav-it.slack.com/archives/CA3P9NGA2") - .email("dolly@nav.no") - .name("Team Dolly") - ) - .license(new License() - .name("MIT License") - .url("https://opensource.org/licenses/MIT") - ) - ); - } -} \ No newline at end of file diff --git a/apps/ereg-batch-status-service/src/main/java/no/nav/registre/testnorge/eregbatchstatusservice/config/SecurityConfig.java b/apps/ereg-batch-status-service/src/main/java/no/nav/registre/testnorge/eregbatchstatusservice/config/SecurityConfig.java deleted file mode 100644 index 8edc18ab66e..00000000000 --- a/apps/ereg-batch-status-service/src/main/java/no/nav/registre/testnorge/eregbatchstatusservice/config/SecurityConfig.java +++ /dev/null @@ -1,41 +0,0 @@ -package no.nav.registre.testnorge.eregbatchstatusservice.config; - -import lombok.RequiredArgsConstructor; -import no.nav.testnav.libs.reactivesecurity.manager.JwtReactiveAuthenticationManager; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; -import org.springframework.security.config.annotation.method.configuration.EnableReactiveMethodSecurity; -import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity; -import org.springframework.security.config.web.server.ServerHttpSecurity; -import org.springframework.security.web.server.SecurityWebFilterChain; - -@Configuration -@EnableWebFluxSecurity -@EnableReactiveMethodSecurity -@RequiredArgsConstructor -@Profile({ "prod", "dev" }) -public class SecurityConfig { - - private final JwtReactiveAuthenticationManager jwtReactiveAuthenticationManager; - - @Bean - public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity httpSecurity) { - - return httpSecurity - .csrf(ServerHttpSecurity.CsrfSpec::disable) - .authorizeExchange(authorizeConfig -> authorizeConfig.pathMatchers( - "/internal/**", - "/webjars/**", - "/swagger-resources/**", - "/v3/api-docs/**", - "/swagger-ui/**", - "/swagger", - "/error", - "/swagger-ui.html" - ).permitAll().anyExchange().authenticated()) - .oauth2ResourceServer(oauth2RSConfig -> oauth2RSConfig.jwt(jwtSpec -> jwtSpec.authenticationManager(jwtReactiveAuthenticationManager))) - .build(); - } -} - diff --git a/apps/ereg-batch-status-service/src/main/java/no/nav/registre/testnorge/eregbatchstatusservice/consumer/EregConsumer.java b/apps/ereg-batch-status-service/src/main/java/no/nav/registre/testnorge/eregbatchstatusservice/consumer/EregConsumer.java deleted file mode 100644 index b5ed69cfced..00000000000 --- a/apps/ereg-batch-status-service/src/main/java/no/nav/registre/testnorge/eregbatchstatusservice/consumer/EregConsumer.java +++ /dev/null @@ -1,37 +0,0 @@ -package no.nav.registre.testnorge.eregbatchstatusservice.consumer; - -import lombok.extern.slf4j.Slf4j; -import no.nav.registre.testnorge.eregbatchstatusservice.config.Consumers; -import no.nav.registre.testnorge.eregbatchstatusservice.consumer.command.GetBatchStatusCommand; -import no.nav.testnav.libs.reactivesecurity.exchange.TokenExchange; -import no.nav.testnav.libs.securitycore.domain.ServerProperties; -import org.springframework.stereotype.Component; -import org.springframework.web.reactive.function.client.WebClient; -import reactor.core.publisher.Mono; - -@Slf4j -@Component -public class EregConsumer { - private final ServerProperties serverProperties; - private final WebClient webClient; - private final TokenExchange tokenService; - - - public EregConsumer(TokenExchange tokenService, - Consumers consumers - ) { - - this.tokenService = tokenService; - this.serverProperties = consumers.getModappEregProxy(); - this.webClient = WebClient.builder() - .baseUrl(consumers.getModappEregProxy().getUrl()) - .build(); - } - - public Mono getStatusKode(String miljo, Long id) { - return tokenService - .exchange(serverProperties) - .flatMap(accessToken -> - new GetBatchStatusCommand(webClient, miljo, id, accessToken.getTokenValue()).call()); - } -} \ No newline at end of file diff --git a/apps/ereg-batch-status-service/src/main/java/no/nav/registre/testnorge/eregbatchstatusservice/consumer/command/GetBatchStatusCommand.java b/apps/ereg-batch-status-service/src/main/java/no/nav/registre/testnorge/eregbatchstatusservice/consumer/command/GetBatchStatusCommand.java deleted file mode 100644 index cf5cc38f465..00000000000 --- a/apps/ereg-batch-status-service/src/main/java/no/nav/registre/testnorge/eregbatchstatusservice/consumer/command/GetBatchStatusCommand.java +++ /dev/null @@ -1,45 +0,0 @@ -package no.nav.registre.testnorge.eregbatchstatusservice.consumer.command; - -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import no.nav.registre.testnorge.eregbatchstatusservice.util.WebClientFilter; -import org.springframework.http.HttpStatus; -import org.springframework.http.HttpStatusCode; -import org.springframework.web.reactive.function.client.WebClient; -import org.springframework.web.server.ResponseStatusException; -import reactor.core.publisher.Mono; -import reactor.util.retry.Retry; - -import java.time.Duration; -import java.util.concurrent.Callable; - -import static org.springframework.http.HttpHeaders.AUTHORIZATION; - -@RequiredArgsConstructor -@Slf4j -public class GetBatchStatusCommand implements Callable> { - private final WebClient webClient; - private final String miljoe; - private final Long id; - private final String token; - - @Override - public Mono call() { - return webClient - .get() - .uri(builder -> builder.path("/{miljoe}/ereg/internal/batch/poll/{id}").build(miljoe, id)) - .header(AUTHORIZATION, "Bearer " + token) - .retrieve() - .onStatus(HttpStatusCode::is4xxClientError, clientResponse -> { - if (clientResponse.statusCode().equals(HttpStatus.UNAUTHORIZED)) { - log.error("Unauthorized error occurred when calling modapp-ereg-proxy"); - return Mono.error(new ResponseStatusException(HttpStatus.NOT_FOUND, "Resource not found")); - } - log.error("Client error occurred when calling modapp-ereg-proxy"); - return Mono.error(new ResponseStatusException(clientResponse.statusCode(), "Client error occurred")); - }) - .bodyToMono(Long.class) - .retryWhen(Retry.backoff(3, Duration.ofSeconds(5)) - .filter(WebClientFilter::is5xxException)); - } -} diff --git a/apps/ereg-batch-status-service/src/main/java/no/nav/registre/testnorge/eregbatchstatusservice/filter/SwaggerWebFilter.java b/apps/ereg-batch-status-service/src/main/java/no/nav/registre/testnorge/eregbatchstatusservice/filter/SwaggerWebFilter.java deleted file mode 100644 index 6141d2e2409..00000000000 --- a/apps/ereg-batch-status-service/src/main/java/no/nav/registre/testnorge/eregbatchstatusservice/filter/SwaggerWebFilter.java +++ /dev/null @@ -1,23 +0,0 @@ -package no.nav.registre.testnorge.eregbatchstatusservice.filter; - -import org.springframework.stereotype.Component; -import org.springframework.web.server.ServerWebExchange; -import org.springframework.web.server.WebFilter; -import org.springframework.web.server.WebFilterChain; -import reactor.core.publisher.Mono; - -@Component -public class SwaggerWebFilter implements WebFilter { - @Override - public Mono filter(ServerWebExchange exchange, WebFilterChain chain) { - if (exchange.getRequest().getURI().getPath().equals("/swagger")) { - return chain - .filter(exchange.mutate() - .request(exchange.getRequest() - .mutate().path("/swagger-ui.html").build()) - .build()); - } - - return chain.filter(exchange); - } -} \ No newline at end of file diff --git a/apps/ereg-batch-status-service/src/main/java/no/nav/registre/testnorge/eregbatchstatusservice/provider/BatchStatusController.java b/apps/ereg-batch-status-service/src/main/java/no/nav/registre/testnorge/eregbatchstatusservice/provider/BatchStatusController.java deleted file mode 100644 index 4086e65f040..00000000000 --- a/apps/ereg-batch-status-service/src/main/java/no/nav/registre/testnorge/eregbatchstatusservice/provider/BatchStatusController.java +++ /dev/null @@ -1,32 +0,0 @@ -package no.nav.registre.testnorge.eregbatchstatusservice.provider; - -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import no.nav.registre.testnorge.eregbatchstatusservice.consumer.EregConsumer; -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.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.reactive.function.client.WebClientResponseException; -import reactor.core.publisher.Mono; - -@Slf4j -@RequiredArgsConstructor -@RestController -@RequestMapping("/api/v1/batch/items") -public class BatchStatusController { - private final EregConsumer eregConsumer; - - @GetMapping("/{id}") - public ResponseEntity> getStatusKode(@RequestHeader("miljoe") String miljo, @PathVariable("id") Long id) { - try { - var status = eregConsumer.getStatusKode(miljo, id); - return ResponseEntity.ok(status); - } catch (WebClientResponseException e) { - log.error(e.getMessage(), e); - return ResponseEntity.notFound().build(); - } - } -} diff --git a/apps/ereg-batch-status-service/src/main/java/no/nav/registre/testnorge/eregbatchstatusservice/util/WebClientFilter.java b/apps/ereg-batch-status-service/src/main/java/no/nav/registre/testnorge/eregbatchstatusservice/util/WebClientFilter.java deleted file mode 100644 index c0adef3ad40..00000000000 --- a/apps/ereg-batch-status-service/src/main/java/no/nav/registre/testnorge/eregbatchstatusservice/util/WebClientFilter.java +++ /dev/null @@ -1,14 +0,0 @@ -package no.nav.registre.testnorge.eregbatchstatusservice.util; - -import lombok.experimental.UtilityClass; -import org.springframework.web.reactive.function.client.WebClientResponseException; - -@UtilityClass -public class WebClientFilter { - - public static boolean is5xxException(Throwable throwable) { - - return throwable instanceof WebClientResponseException wce && - wce.getStatusCode().is5xxServerError(); - } -} diff --git a/apps/ereg-batch-status-service/src/main/resources/application-dev.yml b/apps/ereg-batch-status-service/src/main/resources/application-dev.yml deleted file mode 100644 index f05debbd219..00000000000 --- a/apps/ereg-batch-status-service/src/main/resources/application-dev.yml +++ /dev/null @@ -1 +0,0 @@ -TOKEN_X_ISSUER: dummy \ No newline at end of file diff --git a/apps/ereg-batch-status-service/src/main/resources/application.yml b/apps/ereg-batch-status-service/src/main/resources/application.yml deleted file mode 100644 index 37422dfcf14..00000000000 --- a/apps/ereg-batch-status-service/src/main/resources/application.yml +++ /dev/null @@ -1,57 +0,0 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - -spring: - cloud: - vault: - enabled: false - main: - banner-mode: off - application: - name: ereg-batch-status-service - version: application.version.todo - description: Tjeneste for å hente ut batch status fra EREG. - security: - oauth2: - resourceserver: - aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys - accepted-audience: ${azure.app.client.id}, api://${azure.app.client.id} - tokenx: - issuer-uri: ${TOKEN_X_ISSUER} - jwk-set-uri: ${TOKEN_X_JWKS_URI} - accepted-audience: ${TOKEN_X_CLIENT_ID} - -springdoc: - swagger-ui: - disable-swagger-default-url: true - url: /v3/api-docs - -consumers: - modapp-ereg-proxy: - name: testnav-modapp-ereg-proxy - namespace: dolly - url: https://testnav-modapp-ereg-proxy.dev-fss-pub.nais.io - cluster: dev-fss - -management: - endpoints: - enabled-by-default: true - web: - base-path: /internal - exposure.include: prometheus,heapdump,health - path-mapping: - prometheus: metrics - endpoint: - prometheus.enabled: true - heapdump.enabled: true - prometheus: - metrics: - export: - enabled: true -server: - servlet: - encoding: - charset: UTF-8 - error: - include-message: always \ No newline at end of file diff --git a/apps/ereg-batch-status-service/src/main/resources/logback-spring.xml b/apps/ereg-batch-status-service/src/main/resources/logback-spring.xml deleted file mode 100644 index 7b0b3b1cca1..00000000000 --- a/apps/ereg-batch-status-service/src/main/resources/logback-spring.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - true - - 10280 - 20 - ^sun\.reflect\..*\.invoke - ^net\.sf\.cglib\.proxy\.MethodProxy\.invoke - java\.util\.concurrent\..* - org\.apache\.catalina\..* - org\.apache\.coyote\..* - org\.apache\.tomcat\..* - - - - - - - - - - - - - %d{HH:mm:ss.SSS} | %5p | %logger{25} | %m%n - - utf8 - - - - - - - - - \ No newline at end of file diff --git a/apps/ereg-batch-status-service/src/test/java/no/nav/registre/testnorge/eregbatchstatusservice/ApplicationContextTest.java b/apps/ereg-batch-status-service/src/test/java/no/nav/registre/testnorge/eregbatchstatusservice/ApplicationContextTest.java deleted file mode 100644 index 18f54a546de..00000000000 --- a/apps/ereg-batch-status-service/src/test/java/no/nav/registre/testnorge/eregbatchstatusservice/ApplicationContextTest.java +++ /dev/null @@ -1,20 +0,0 @@ -package no.nav.registre.testnorge.eregbatchstatusservice; - -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.oauth2.jwt.JwtDecoder; -import org.springframework.test.context.ActiveProfiles; - -@SpringBootTest -@ActiveProfiles("test") -class ApplicationContextTest { - - @MockBean - public JwtDecoder jwtDecoder; - - @Test - @SuppressWarnings("java:S2699") - void load_app_context() { - } -} diff --git a/apps/ereg-batch-status-service/src/test/resources/application-test.properties b/apps/ereg-batch-status-service/src/test/resources/application-test.properties deleted file mode 100644 index e5e55886152..00000000000 --- a/apps/ereg-batch-status-service/src/test/resources/application-test.properties +++ /dev/null @@ -1 +0,0 @@ -TOKEN_X_ISSUER=dummy \ No newline at end of file diff --git a/apps/organisasjon-bestilling-service/config.yml b/apps/organisasjon-bestilling-service/config.yml index def6bb55621..db774afd77f 100644 --- a/apps/organisasjon-bestilling-service/config.yml +++ b/apps/organisasjon-bestilling-service/config.yml @@ -33,9 +33,6 @@ spec: - application: testnav-organisasjon-mottak-service cluster: dev-gcp outbound: - rules: - - application: ereg-batch-status-service - cluster: dev-gcp external: - host: testnorge-batch-adeo-proxy.dev-fss-pub.nais.io gcp: diff --git a/apps/organisasjon-bestilling-service/src/main/java/no/nav/testnav/apps/organisasjonbestillingservice/OrganisasjonBestillingServiceApplicationStarter.java b/apps/organisasjon-bestilling-service/src/main/java/no/nav/testnav/apps/organisasjonbestillingservice/OrganisasjonBestillingServiceApplicationStarter.java index 79ad740d359..9088b2f93eb 100644 --- a/apps/organisasjon-bestilling-service/src/main/java/no/nav/testnav/apps/organisasjonbestillingservice/OrganisasjonBestillingServiceApplicationStarter.java +++ b/apps/organisasjon-bestilling-service/src/main/java/no/nav/testnav/apps/organisasjonbestillingservice/OrganisasjonBestillingServiceApplicationStarter.java @@ -9,4 +9,4 @@ public class OrganisasjonBestillingServiceApplicationStarter { public static void main(String[] args) { SpringApplication.run(OrganisasjonBestillingServiceApplicationStarter.class, args); } -} +} \ No newline at end of file diff --git a/apps/organisasjon-bestilling-service/src/main/java/no/nav/testnav/apps/organisasjonbestillingservice/config/Consumers.java b/apps/organisasjon-bestilling-service/src/main/java/no/nav/testnav/apps/organisasjonbestillingservice/config/Consumers.java index e2efb76d5a7..341f3b8ceba 100644 --- a/apps/organisasjon-bestilling-service/src/main/java/no/nav/testnav/apps/organisasjonbestillingservice/config/Consumers.java +++ b/apps/organisasjon-bestilling-service/src/main/java/no/nav/testnav/apps/organisasjonbestillingservice/config/Consumers.java @@ -24,7 +24,5 @@ @Setter(PACKAGE) public class Consumers { - private ServerProperties eregBatchStatusService; private ServerProperties jenkins; - } diff --git a/apps/organisasjon-bestilling-service/src/main/java/no/nav/testnav/apps/organisasjonbestillingservice/config/SecurityConfig.java b/apps/organisasjon-bestilling-service/src/main/java/no/nav/testnav/apps/organisasjonbestillingservice/config/SecurityConfig.java index 919c6410571..69d657e5dad 100644 --- a/apps/organisasjon-bestilling-service/src/main/java/no/nav/testnav/apps/organisasjonbestillingservice/config/SecurityConfig.java +++ b/apps/organisasjon-bestilling-service/src/main/java/no/nav/testnav/apps/organisasjonbestillingservice/config/SecurityConfig.java @@ -8,6 +8,7 @@ import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer; +import org.springframework.security.config.annotation.web.configurers.HeadersConfigurer; import org.springframework.security.config.http.SessionCreationPolicy; import org.springframework.security.web.SecurityFilterChain; @@ -15,7 +16,7 @@ @Order(1) @EnableWebSecurity @Configuration -@Profile({ "prod", "dev" }) +@Profile({"prod", "dev"}) public class SecurityConfig { @Bean @@ -24,17 +25,21 @@ public SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Excepti httpSecurity.sessionManagement(sessionConfig -> sessionConfig.sessionCreationPolicy(SessionCreationPolicy.STATELESS)) .csrf(AbstractHttpConfigurer::disable) .authorizeHttpRequests(authorizeConfig -> authorizeConfig.requestMatchers( - "/internal/**", - "/webjars/**", - "/swagger-resources/**", - "/v3/api-docs/**", - "/swagger-ui/**", - "/swagger", - "/error", - "/swagger-ui.html" - ).permitAll().requestMatchers("/api/**").fullyAuthenticated()) + "/internal/**", + "/webjars/**", + "/swagger-resources/**", + "/v3/api-docs/**", + "/swagger-ui/**", + "/swagger", + "/error", + "/swagger-ui.html", + "/h2/**", + "/member/**") + .permitAll() + .requestMatchers("/api/**") + .fullyAuthenticated()) + .headers(headers -> headers.frameOptions(HeadersConfigurer.FrameOptionsConfig::disable)) .oauth2ResourceServer(oauth2RSConfig -> oauth2RSConfig.jwt(Customizer.withDefaults())); - return httpSecurity.build(); } } diff --git a/apps/organisasjon-bestilling-service/src/main/java/no/nav/testnav/apps/organisasjonbestillingservice/consumer/EregBatchStatusConsumer.java b/apps/organisasjon-bestilling-service/src/main/java/no/nav/testnav/apps/organisasjonbestillingservice/consumer/EregBatchStatusConsumer.java deleted file mode 100644 index 689d95aebd1..00000000000 --- a/apps/organisasjon-bestilling-service/src/main/java/no/nav/testnav/apps/organisasjonbestillingservice/consumer/EregBatchStatusConsumer.java +++ /dev/null @@ -1,51 +0,0 @@ -package no.nav.testnav.apps.organisasjonbestillingservice.consumer; - -import no.nav.testnav.apps.organisasjonbestillingservice.config.Consumers; -import no.nav.testnav.apps.organisasjonbestillingservice.consumer.command.GetEregBatchStatusCommand; -import no.nav.testnav.apps.organisasjonbestillingservice.domain.v2.Order; -import no.nav.testnav.libs.securitycore.domain.ServerProperties; -import no.nav.testnav.libs.servletsecurity.exchange.TokenExchange; -import org.springframework.stereotype.Component; -import org.springframework.web.reactive.function.client.WebClient; - -@Component -public class EregBatchStatusConsumer { - private final WebClient webClient; - private final TokenExchange tokenExchange; - private final ServerProperties serverProperties; - - public EregBatchStatusConsumer( - Consumers consumers, - TokenExchange tokenExchange - ) { - serverProperties = consumers.getEregBatchStatusService(); - this.tokenExchange = tokenExchange; - this.webClient = WebClient - .builder() - .baseUrl(serverProperties.getUrl()) - .build(); - } - - public Long getStatusKode(no.nav.testnav.apps.organisasjonbestillingservice.domain.v1.Order order) { - var accessToken = tokenExchange.exchange(serverProperties).block(); - var command = new GetEregBatchStatusCommand( - webClient, - order.getBatchId(), - accessToken.getTokenValue(), - order.getMiljo() - ); - return command.call(); - } - - public Long getStatusKode(Order order) { - var accessToken = tokenExchange.exchange(serverProperties).block(); - var command = new GetEregBatchStatusCommand( - webClient, - order.getBatchId(), - accessToken.getTokenValue(), - order.getMiljo() - ); - return command.call(); - } - -} diff --git a/apps/organisasjon-bestilling-service/src/main/java/no/nav/testnav/apps/organisasjonbestillingservice/consumer/command/GetEregBatchStatusCommand.java b/apps/organisasjon-bestilling-service/src/main/java/no/nav/testnav/apps/organisasjonbestillingservice/consumer/command/GetEregBatchStatusCommand.java deleted file mode 100644 index e480b8ab753..00000000000 --- a/apps/organisasjon-bestilling-service/src/main/java/no/nav/testnav/apps/organisasjonbestillingservice/consumer/command/GetEregBatchStatusCommand.java +++ /dev/null @@ -1,40 +0,0 @@ -package no.nav.testnav.apps.organisasjonbestillingservice.consumer.command; - -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpStatus; -import org.springframework.web.reactive.function.client.WebClient; -import org.springframework.web.reactive.function.client.WebClientResponseException; -import org.springframework.web.server.ResponseStatusException; -import reactor.util.retry.Retry; - -import java.time.Duration; -import java.util.concurrent.Callable; - -@Slf4j -@RequiredArgsConstructor -public class GetEregBatchStatusCommand implements Callable { - private final WebClient webClient; - private final Long batchId; - private final String token; - private final String miljo; - - @Override - public Long call() { - try { - return webClient.get() - .uri(uriBuilder -> uriBuilder.path("/api/v1/batch/items/{id}").build(batchId)) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + token) - .header("miljoe", miljo) - .retrieve() - .bodyToMono(Long.class) - .retryWhen(Retry.backoff(3, Duration.ofSeconds(5)) - .filter(throwable -> throwable instanceof WebClientResponseException.GatewayTimeout)) - .block(); - } catch (Exception e) { - log.error("Failed to get status for batch with id: " + batchId, e); - throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Resource not found", e); - } - } -} \ No newline at end of file diff --git a/apps/organisasjon-bestilling-service/src/main/java/no/nav/testnav/apps/organisasjonbestillingservice/controller/v1/OrderController.java b/apps/organisasjon-bestilling-service/src/main/java/no/nav/testnav/apps/organisasjonbestillingservice/controller/v1/OrderController.java index 042981526b7..cc54a9ddabd 100644 --- a/apps/organisasjon-bestilling-service/src/main/java/no/nav/testnav/apps/organisasjonbestillingservice/controller/v1/OrderController.java +++ b/apps/organisasjon-bestilling-service/src/main/java/no/nav/testnav/apps/organisasjonbestillingservice/controller/v1/OrderController.java @@ -59,25 +59,6 @@ public ResponseEntity updateBestilling(@PathVariable("uuid") String return ResponseEntity.created(uri).build(); } - @GetMapping("/{uuid}/items") - public ResponseEntity> getItems(@PathVariable("uuid") String uuid) { - log.info("Henter status for uuid: {}.", uuid); - var items = service.getStatusBy(uuid); - if (items == null) { - return ResponseEntity.noContent().build(); - } - return ResponseEntity.ok(items); - } - - @GetMapping("/{uuid}/items/{id}") - public ResponseEntity getItem(@PathVariable("id") Long id) { - var item = service.getStatusBy(id); - if (item == null) { - return ResponseEntity.notFound().build(); - } - return ResponseEntity.ok(item); - } - @DeleteMapping("/{uuid}") public ResponseEntity delete(@PathVariable("uuid") String uuid) { service.delete(uuid); diff --git a/apps/organisasjon-bestilling-service/src/main/java/no/nav/testnav/apps/organisasjonbestillingservice/service/v1/OrderService.java b/apps/organisasjon-bestilling-service/src/main/java/no/nav/testnav/apps/organisasjonbestillingservice/service/v1/OrderService.java index 9e3122b222e..82ee29bf8b1 100644 --- a/apps/organisasjon-bestilling-service/src/main/java/no/nav/testnav/apps/organisasjonbestillingservice/service/v1/OrderService.java +++ b/apps/organisasjon-bestilling-service/src/main/java/no/nav/testnav/apps/organisasjonbestillingservice/service/v1/OrderService.java @@ -2,26 +2,21 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import no.nav.testnav.apps.organisasjonbestillingservice.domain.v1.Order; +import no.nav.testnav.apps.organisasjonbestillingservice.repository.v1.OrderRepository; +import no.nav.testnav.apps.organisasjonbestillingservice.repository.v1.model.OrderModel; +import no.nav.testnav.libs.dto.organisajonbestilling.v1.Status; import org.springframework.stereotype.Service; -import java.util.List; import java.util.Set; import java.util.stream.Collectors; import java.util.stream.StreamSupport; -import no.nav.testnav.apps.organisasjonbestillingservice.consumer.EregBatchStatusConsumer; -import no.nav.testnav.apps.organisasjonbestillingservice.repository.v1.OrderRepository; -import no.nav.testnav.apps.organisasjonbestillingservice.repository.v1.model.OrderModel; -import no.nav.testnav.libs.dto.organisajonbestilling.v1.ItemDTO; -import no.nav.testnav.libs.dto.organisajonbestilling.v1.Status; -import no.nav.testnav.apps.organisasjonbestillingservice.domain.v1.Order; - @Slf4j @Service @RequiredArgsConstructor public class OrderService { private final OrderRepository repository; - private final EregBatchStatusConsumer consumer; public Long create(String uuid) { return repository.save(OrderModel.builder().uuid(uuid).build()).getId(); @@ -38,28 +33,6 @@ public Set getOrderUuids() { .collect(Collectors.toSet()); } - public ItemDTO getStatusBy(Long id) { - var model = repository.findById(id); - if (model.isEmpty()) { - return null; - } - var value = model.get(); - if (value.getBatchId() == null) { - return new ItemDTO(id, Status.NOT_STARTED); - } - var order = new Order(value); - var kode = consumer.getStatusKode(order); - return new ItemDTO(id, toStatus(kode)); - } - - public List getStatusBy(String uuid) { - log.info("Henter status for uuid: {}", uuid); - var list = repository.findBy(uuid); - return list.stream() - .map(value -> getStatusBy(value.getId())) - .collect(Collectors.toList()); - } - public void deleteAll() { repository.deleteAll(); } diff --git a/apps/organisasjon-bestilling-service/src/main/java/no/nav/testnav/apps/organisasjonbestillingservice/service/v2/OrderServiceV2.java b/apps/organisasjon-bestilling-service/src/main/java/no/nav/testnav/apps/organisasjonbestillingservice/service/v2/OrderServiceV2.java index 65b9e3dafdf..1a8c89e5edf 100644 --- a/apps/organisasjon-bestilling-service/src/main/java/no/nav/testnav/apps/organisasjonbestillingservice/service/v2/OrderServiceV2.java +++ b/apps/organisasjon-bestilling-service/src/main/java/no/nav/testnav/apps/organisasjonbestillingservice/service/v2/OrderServiceV2.java @@ -2,7 +2,6 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import no.nav.testnav.apps.organisasjonbestillingservice.consumer.EregBatchStatusConsumer; import no.nav.testnav.apps.organisasjonbestillingservice.consumer.JenkinsConsumer; import no.nav.testnav.apps.organisasjonbestillingservice.domain.v2.Order; import no.nav.testnav.apps.organisasjonbestillingservice.repository.v2.OrderRepositoryV2; @@ -11,12 +10,14 @@ import no.nav.testnav.apps.organisasjonbestillingservice.service.RetryService; import no.nav.testnav.libs.dto.organisajonbestilling.v2.Status; import org.springframework.stereotype.Service; -import org.springframework.web.reactive.function.client.WebClientResponseException; import java.util.List; import java.util.regex.Pattern; import java.util.stream.StreamSupport; +import static java.util.Objects.isNull; +import static java.util.Objects.nonNull; + @Slf4j @Service @RequiredArgsConstructor @@ -25,7 +26,6 @@ public class OrderServiceV2 { private final OrderRepositoryV2 repository; private final JenkinsConsumer jenkinsConsumer; private final RetryService retryService; - private final EregBatchStatusConsumer eregBatchStatusConsumer; public Order save(Order order) { OrderEntity saved = repository.save(order.toEntity()); @@ -56,17 +56,12 @@ public Status getStatus(Long id) { var order = entity.get(); - if (order.getBatchId() != null) { - try { + if (nonNull(order.getBatchId())) { - return getStatusFromBatchId(new Order(order)); - } catch (WebClientResponseException.NotFound e) { - log.info("Fant ikke noen status for org: {}", id); - return null; - } + return Status.PENDING_COMPLETE; } - if (order.getBuildId() == null) { + if (isNull(order.getBuildId())) { return Status.ADDING_TO_QUEUE; } @@ -94,7 +89,7 @@ public Status getStatus(Long id) { return Status.RUNNING; } repository.save(order); - return getStatusFromBatchId(new Order(order)); + return Status.PENDING_COMPLETE; } public List find(String uuid) { @@ -113,10 +108,10 @@ public List findAll() { .toList(); } - private Status getStatusFromBatchId(Order order) { - var statusKode = eregBatchStatusConsumer.getStatusKode(order); - return Status.from(statusKode); - } +// private Status getStatusFromBatchId(Order order) { +// var statusKode = eregBatchStatusConsumer.getStatusKode(order); +// return Status.from(statusKode); +// } private Long findIDFromLog(String value) { log.info("Prøver å hente ut id fra log: {}.", value); diff --git a/apps/organisasjon-bestilling-service/src/main/resources/application-dev.yml b/apps/organisasjon-bestilling-service/src/main/resources/application-dev.yml index b73f614e194..c9b24a44336 100644 --- a/apps/organisasjon-bestilling-service/src/main/resources/application-dev.yml +++ b/apps/organisasjon-bestilling-service/src/main/resources/application-dev.yml @@ -7,10 +7,14 @@ spring: flyway: enabled: true datasource: - url: jdbc:h2:mem:testdb?useUnicode=yes&characterEncoding=UTF-8 + url: jdbc:h2:mem:testdb username: sa password: driverClassName: org.h2.Driver + sql: + init: + mode: always + data-locations: classpath:/db/dev/h2-init-db.sql jpa: properties: hibernate: diff --git a/apps/organisasjon-bestilling-service/src/main/resources/application-prod.yml b/apps/organisasjon-bestilling-service/src/main/resources/application-prod.yml index c6afad02efe..8a908b470e1 100644 --- a/apps/organisasjon-bestilling-service/src/main/resources/application-prod.yml +++ b/apps/organisasjon-bestilling-service/src/main/resources/application-prod.yml @@ -13,6 +13,13 @@ spring: properties: hibernate: dialect: org.hibernate.dialect.PostgreSQLDialect + security: + oauth2: + resourceserver: + tokenx: + issuer-uri: ${TOKEN_X_ISSUER} + jwk-set-uri: ${TOKEN_X_JWKS_URI} + accepted-audience: ${TOKEN_X_CLIENT_ID testnorge: analyse: diff --git a/apps/organisasjon-bestilling-service/src/main/resources/application.yml b/apps/organisasjon-bestilling-service/src/main/resources/application.yml index 65128d8b646..62c18b46b95 100644 --- a/apps/organisasjon-bestilling-service/src/main/resources/application.yml +++ b/apps/organisasjon-bestilling-service/src/main/resources/application.yml @@ -15,10 +15,6 @@ spring: issuer-uri: ${AAD_ISSUER_URI}/v2.0 jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys accepted-audience: ${azure.app.client.id}, api://${azure.app.client.id} - tokenx: - issuer-uri: ${TOKEN_X_ISSUER} - jwk-set-uri: ${TOKEN_X_JWKS_URI} - accepted-audience: ${TOKEN_X_CLIENT_ID} springdoc: swagger-ui: @@ -26,11 +22,6 @@ springdoc: url: /v3/api-docs consumers: - ereg-batch-status-service: - url: http://ereg-batch-status-service.dolly.svc.cluster.local - cluster: dev-gcp - namespace: dolly - name: ereg-batch-status-service jenkins: url: https://testnorge-batch-adeo-proxy.dev-fss-pub.nais.io name: testnorge-batch-adeo-proxy diff --git a/apps/organisasjon-bestilling-service/src/main/resources/db/dev/h2-init-db.sql b/apps/organisasjon-bestilling-service/src/main/resources/db/dev/h2-init-db.sql new file mode 100644 index 00000000000..eb17f62bc56 --- /dev/null +++ b/apps/organisasjon-bestilling-service/src/main/resources/db/dev/h2-init-db.sql @@ -0,0 +1,26 @@ +INSERT INTO public.org_order (id, uuid, queue_id, build_id, batch_id, environment, created_at, updated_at) VALUES (33, '4715177c-c393-4992-9514-eaa1279c586b', 16943, 3809, null, 'q2', '2021-09-14 12:31:21.192000 +00:00', '2021-09-14 12:31:26.544000 +00:00'); +INSERT INTO public.org_order (id, uuid, queue_id, build_id, batch_id, environment, created_at, updated_at) VALUES (34, '711638b8-6881-4ebd-9247-8b611d655c1d', 16944, 3810, null, 'q2', '2021-09-14 12:35:33.919000 +00:00', '2021-09-14 12:35:41.187000 +00:00'); +INSERT INTO public.org_order (id, uuid, queue_id, build_id, batch_id, environment, created_at, updated_at) VALUES (4, '5f69dc00-30a5-41b5-850c-12757ca5f91c', 16889, 3776, null, 'q2', '2021-08-27 07:17:49.236000 +00:00', '2021-08-27 07:17:55.983000 +00:00'); +INSERT INTO public.org_order (id, uuid, queue_id, build_id, batch_id, environment, created_at, updated_at) VALUES (5, '9c0d2193-6553-4e83-a794-22d470a98745', 16890, 3777, null, 'q2', '2021-08-27 07:17:55.850000 +00:00', '2021-08-27 07:18:51.082000 +00:00'); +INSERT INTO public.org_order (id, uuid, queue_id, build_id, batch_id, environment, created_at, updated_at) VALUES (6, 'afcd21ca-f4c7-49fe-807e-02c2e1880ae6', 16894, 3779, null, 'q1', '2021-08-27 11:03:54.582000 +00:00', '2021-08-27 11:04:46.612000 +00:00'); +INSERT INTO public.org_order (id, uuid, queue_id, build_id, batch_id, environment, created_at, updated_at) VALUES (7, 'c6b03e74-176b-49ca-9e7c-91fd047c5617', 16895, 3780, null, 'q2', '2021-08-27 11:03:58.731000 +00:00', '2021-08-27 11:06:12.832000 +00:00'); +INSERT INTO public.org_order (id, uuid, queue_id, build_id, batch_id, environment, created_at, updated_at) VALUES (8, '73c01454-84c6-4bf7-922a-33c5659d27f2', 16897, 3782, null, 'q1', '2021-08-27 11:10:20.171000 +00:00', '2021-08-27 11:11:15.469000 +00:00'); +INSERT INTO public.org_order (id, uuid, queue_id, build_id, batch_id, environment, created_at, updated_at) VALUES (52, 'e17f903c-e2a5-4bf2-9f3b-be55a824f20a', 16973, 3828, 10879, 't4', '2021-09-16 08:50:14.330000 +00:00', '2021-09-16 08:59:00.829000 +00:00'); +INSERT INTO public.org_order (id, uuid, queue_id, build_id, batch_id, environment, created_at, updated_at) VALUES (35, '7fe9d2f1-4387-44b5-a010-2ed5be7fe25f', 16945, 3811, 9986, 'q2', '2021-09-14 12:52:55.763000 +00:00', '2021-09-14 13:06:40.160000 +00:00'); +INSERT INTO public.org_order (id, uuid, queue_id, build_id, batch_id, environment, created_at, updated_at) VALUES (9, '7d0e36d6-6004-43db-bfba-0d6cb7dcd574', 16899, 3784, 9924, 'q2', '2021-08-27 11:28:13.576000 +00:00', '2021-08-27 12:04:24.523000 +00:00'); +INSERT INTO public.org_order (id, uuid, queue_id, build_id, batch_id, environment, created_at, updated_at) VALUES (10, 'b684e180-7a5b-435a-abf2-8f156a69062d', 16898, 3783, 11096, 'q1', '2021-08-27 11:28:13.602000 +00:00', '2021-08-27 12:04:26.103000 +00:00'); +INSERT INTO public.org_order (id, uuid, queue_id, build_id, batch_id, environment, created_at, updated_at) VALUES (11, '1af92aed-4ef5-409c-9acf-b0423f7db3d9', 16900, 3785, 9925, 'q2', '2021-08-27 12:06:17.990000 +00:00', '2021-08-27 12:07:20.888000 +00:00'); +INSERT INTO public.org_order (id, uuid, queue_id, build_id, batch_id, environment, created_at, updated_at) VALUES (12, '7ed106c1-d326-47b3-bdba-4fd83552c313', 16901, 3786, null, 'q1', '2021-08-27 12:06:18.055000 +00:00', '2021-08-27 12:07:27.011000 +00:00'); +INSERT INTO public.org_order (id, uuid, queue_id, build_id, batch_id, environment, created_at, updated_at) VALUES (13, '3dd8e239-0eb4-461a-a429-9d1d27666d74', 16902, 3787, null, 'q2', '2021-08-27 13:01:40.423000 +00:00', '2021-08-27 13:01:45.365000 +00:00'); +INSERT INTO public.org_order (id, uuid, queue_id, build_id, batch_id, environment, created_at, updated_at) VALUES (14, '1cf259f4-499b-4153-84b8-d16d0f6a135e', 16903, 3788, null, 'q1', '2021-08-27 13:01:45.815000 +00:00', '2021-08-27 13:02:47.810000 +00:00'); +INSERT INTO public.org_order (id, uuid, queue_id, build_id, batch_id, environment, created_at, updated_at) VALUES (15, '691b23b9-efa1-4495-b14b-16973c3f93b9', 16904, 3789, null, 'q1', '2021-08-27 13:24:04.826000 +00:00', '2021-08-27 13:24:09.731000 +00:00'); +INSERT INTO public.org_order (id, uuid, queue_id, build_id, batch_id, environment, created_at, updated_at) VALUES (36, '7a58e0c7-3701-435c-9178-26472aa83dd3', 16947, 3812, null, 'q2', '2021-09-14 13:10:37.168000 +00:00', '2021-09-14 13:10:46.505000 +00:00'); +INSERT INTO public.org_order (id, uuid, queue_id, build_id, batch_id, environment, created_at, updated_at) VALUES (16, '7aa03d08-08fe-4df8-94f2-fa86b0d3699f', 16905, 3790, 11100, 'q1', '2021-08-27 13:43:23.789000 +00:00', '2021-08-27 13:44:25.091000 +00:00'); +INSERT INTO public.org_order (id, uuid, queue_id, build_id, batch_id, environment, created_at, updated_at) VALUES (17, '4c122b06-acaa-4380-b8fb-926e1a40d8d3', 16907, 3792, 10917, 'q2', '2021-08-27 13:43:34.930000 +00:00', '2021-08-27 13:46:35.290000 +00:00'); +INSERT INTO public.org_order (id, uuid, queue_id, build_id, batch_id, environment, created_at, updated_at) VALUES (37, '30a5dca9-5797-4cc4-a712-b424b5f34ebb', 16948, 3813, null, 'q2', '2021-09-14 13:12:15.512000 +00:00', '2021-09-14 13:12:26.954000 +00:00'); +INSERT INTO public.org_order (id, uuid, queue_id, build_id, batch_id, environment, created_at, updated_at) VALUES (18, '3d2cc919-fabf-4101-a3fb-4a03ba3224a5', 16908, 3793, 9928, 'q2', '2021-08-27 13:56:29.650000 +00:00', '2021-08-27 13:57:30.774000 +00:00'); +INSERT INTO public.org_order (id, uuid, queue_id, build_id, batch_id, environment, created_at, updated_at) VALUES (19, 'fd06f312-78bc-45e4-bc63-4b1396493331', 16909, 3794, 11101, 'q1', '2021-08-27 13:56:29.736000 +00:00', '2021-08-27 13:59:26.728000 +00:00'); +INSERT INTO public.org_order (id, uuid, queue_id, build_id, batch_id, environment, created_at, updated_at) VALUES (20, 'e459d26a-eb1a-47be-8777-77e742a7391b', 16910, 3795, null, 'q1', '2021-08-30 07:14:52.809000 +00:00', '2021-08-30 07:14:57.938000 +00:00'); +INSERT INTO public.org_order (id, uuid, queue_id, build_id, batch_id, environment, created_at, updated_at) VALUES (21, '645d4455-01bf-43c2-a639-28e6c6de8203', 16911, 3796, null, 'q2', '2021-08-30 07:15:05.266000 +00:00', '2021-08-30 07:15:58.455000 +00:00'); +INSERT INTO public.org_order (id, uuid, queue_id, build_id, batch_id, environment, created_at, updated_at) VALUES (23, 'e516cc05-c6dc-4e86-8bb6-c9f2218d34b5', 16919, 3799, null, 'q1', '2021-09-02 13:30:20.002000 +00:00', '2021-09-02 13:32:07.402000 +00:00'); +commit; \ No newline at end of file diff --git a/apps/organisasjon-forvalter/build.gradle b/apps/organisasjon-forvalter/build.gradle index 50db6abb5e5..fbe57eb5f33 100644 --- a/apps/organisasjon-forvalter/build.gradle +++ b/apps/organisasjon-forvalter/build.gradle @@ -23,7 +23,7 @@ dependencies { implementation 'no.nav.testnav.libs:security-core' implementation 'no.nav.testnav.libs:database' implementation 'no.nav.testnav.libs:servlet-security' - implementation 'no.nav.testnav.libs:commands' + implementation 'no.nav.testnav.libs:reactive-core' implementation 'no.nav.testnav.libs:data-transfer-objects' implementation 'org.springframework.boot:spring-boot-starter-oauth2-resource-server' diff --git a/apps/organisasjon-forvalter/settings.gradle b/apps/organisasjon-forvalter/settings.gradle index a196306f3e1..dd5c7f21ef4 100644 --- a/apps/organisasjon-forvalter/settings.gradle +++ b/apps/organisasjon-forvalter/settings.gradle @@ -7,13 +7,13 @@ rootProject.name = 'organisasjon-forvalter' includeBuild "../../plugins/java" includeBuild '../../libs/avro-schema' -includeBuild '../../libs/commands' includeBuild '../../libs/data-transfer-objects' includeBuild '../../libs/database' includeBuild '../../libs/kafka-config' includeBuild '../../libs/kafka-producers' includeBuild '../../libs/security-core' includeBuild '../../libs/servlet-core' +includeBuild '../../libs/reactive-core' includeBuild '../../libs/servlet-security' includeBuild '../../libs/testing' diff --git a/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/config/CacheConfig.java b/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/config/CacheConfig.java deleted file mode 100644 index 88ecb981685..00000000000 --- a/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/config/CacheConfig.java +++ /dev/null @@ -1,21 +0,0 @@ -package no.nav.organisasjonforvalter.config; - -import org.springframework.cache.CacheManager; -import org.springframework.cache.annotation.EnableCaching; -import org.springframework.cache.concurrent.ConcurrentMapCacheManager; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -@Configuration -@EnableCaching -public class CacheConfig { - - public static final String CACHE_EREG_IMPORT = "org-importert"; - public static final String CACHE_BEDRIFT = "underenheter"; - public static final String CACHE_MILJOER = "miljoer"; - - @Bean - public CacheManager cacheManager() { - return new ConcurrentMapCacheManager(CACHE_EREG_IMPORT, CACHE_BEDRIFT, CACHE_MILJOER); - } -} diff --git a/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/config/SecurityConfig.java b/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/config/SecurityConfig.java index 4878925bb89..5fb41d16c9e 100644 --- a/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/config/SecurityConfig.java +++ b/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/config/SecurityConfig.java @@ -8,6 +8,7 @@ import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer; +import org.springframework.security.config.annotation.web.configurers.HeadersConfigurer; import org.springframework.security.config.http.SessionCreationPolicy; import org.springframework.security.web.SecurityFilterChain; @@ -15,7 +16,7 @@ @Order(1) @EnableWebSecurity @Configuration -@Profile({ "prod", "local" }) +@Profile({"prod", "local"}) public class SecurityConfig { @Bean @@ -24,15 +25,18 @@ public SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Excepti httpSecurity.sessionManagement(sessionConfig -> sessionConfig.sessionCreationPolicy(SessionCreationPolicy.STATELESS)) .csrf(AbstractHttpConfigurer::disable) .authorizeHttpRequests(authorizeConfig -> authorizeConfig.requestMatchers( - "/internal/**", - "/webjars/**", - "/swagger-resources/**", - "/v3/api-docs/**", - "/swagger-ui/**", - "/swagger", - "/error", - "/swagger-ui.html" - ).permitAll().requestMatchers("/api/**").fullyAuthenticated()) + "/internal/**", + "/webjars/**", + "/swagger-resources/**", + "/v3/api-docs/**", + "/swagger-ui/**", + "/swagger", + "/error", + "/swagger-ui.html") + .permitAll() + .requestMatchers("/api/**") + .fullyAuthenticated()) + .headers(headers -> headers.frameOptions(HeadersConfigurer.FrameOptionsConfig::disable)) .oauth2ResourceServer(oauth2RSConfig -> oauth2RSConfig.jwt(Customizer.withDefaults())); return httpSecurity.build(); diff --git a/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/consumer/GenererNavnServiceConsumer.java b/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/consumer/GenererNavnServiceConsumer.java index 93226c6a644..e04b155cd30 100644 --- a/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/consumer/GenererNavnServiceConsumer.java +++ b/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/consumer/GenererNavnServiceConsumer.java @@ -2,22 +2,16 @@ import lombok.extern.slf4j.Slf4j; import no.nav.organisasjonforvalter.config.Consumers; -import no.nav.testnav.libs.commands.generernavnservice.v1.GenererNavnCommand; +import no.nav.organisasjonforvalter.consumer.command.GenererNavnCommand; import no.nav.testnav.libs.securitycore.domain.ServerProperties; import no.nav.testnav.libs.servletsecurity.exchange.TokenExchange; -import org.springframework.http.HttpStatus; import org.springframework.stereotype.Service; -import org.springframework.web.client.HttpClientErrorException; import org.springframework.web.reactive.function.client.WebClient; -import org.springframework.web.reactive.function.client.WebClientResponseException; -import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; import static java.lang.String.format; -import static java.lang.System.currentTimeMillis; -import static java.util.Objects.requireNonNull; @Slf4j @Service @@ -40,30 +34,16 @@ public GenererNavnServiceConsumer( public List getOrgName(Integer antall) { - long startTime = currentTimeMillis(); - try { - var accessToken = tokenExchange.exchange(serverProperties); - var navn = new GenererNavnCommand(webClient, accessToken.block().getTokenValue(), antall).call(); - - log.info("Generer-navn-service svarte etter {} ms", currentTimeMillis() - startTime); - return Arrays.stream(navn) - .map(value -> format("%s %s", value.getAdjektiv(), value.getSubstantiv())) - .collect(Collectors.toList()); - - } catch (WebClientResponseException e) { - log.error(e.getMessage(), e); - throw new HttpClientErrorException(e.getStatusCode(), requireNonNull(e.getMessage())); - - } catch (RuntimeException e) { - - log.error(e.getMessage(), e); - throw new HttpClientErrorException(HttpStatus.GATEWAY_TIMEOUT, e.getMessage()); - } + return tokenExchange.exchange(serverProperties) + .flatMapMany(token -> new GenererNavnCommand(webClient, antall, token.getTokenValue()).call()) + .map(value -> format("%s %s", value.getAdjektiv(), value.getSubstantiv())) + .collect(Collectors.toList()) + .block(); } public String getOrgName() { List orgName = getOrgName(1); - return orgName.isEmpty() ? null : orgName.get(0); + return orgName.isEmpty() ? null : orgName.getFirst(); } } diff --git a/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/consumer/MiljoerServiceConsumer.java b/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/consumer/MiljoerServiceConsumer.java index e6cb117a184..11a478c19b1 100644 --- a/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/consumer/MiljoerServiceConsumer.java +++ b/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/consumer/MiljoerServiceConsumer.java @@ -5,16 +5,15 @@ import no.nav.organisasjonforvalter.consumer.command.MiljoerServiceCommand; import no.nav.testnav.libs.securitycore.domain.ServerProperties; import no.nav.testnav.libs.servletsecurity.exchange.TokenExchange; -import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Service; import org.springframework.web.reactive.function.client.WebClient; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; +import java.time.Duration; +import java.util.Arrays; import java.util.Set; import java.util.stream.Collectors; -import java.util.stream.Stream; - -import static java.util.Collections.emptySet; -import static no.nav.organisasjonforvalter.config.CacheConfig.CACHE_MILJOER; @Slf4j @Service @@ -35,19 +34,16 @@ public MiljoerServiceConsumer( this.tokenExchange = tokenExchange; } - @Cacheable(CACHE_MILJOER) public Set getOrgMiljoer() { - try { - return Stream.of(tokenExchange.exchange(serverProperties) - .flatMap(token -> - new MiljoerServiceCommand(webClient, token.getTokenValue()).call()).block()) - .filter(env -> !env.equals("u5") && !env.equals("qx")) - .collect(Collectors.toSet()); - - } catch (RuntimeException e) { - log.error("Feilet å hente miljøer fra miljoer-service", e); - return emptySet(); - } + return tokenExchange.exchange(serverProperties) + .flatMap(token -> + new MiljoerServiceCommand(webClient, token.getTokenValue()).call()) + .map(miljoer -> Flux.fromIterable(Arrays.asList(miljoer)) + .filter(env -> !env.equals("t13") && !env.equals("qx")) + .collect(Collectors.toSet())) + .flatMap(Mono::from) + .cache(Duration.ofMinutes(5)) + .block(); } } diff --git a/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/consumer/OrganisasjonBestillingConsumer.java b/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/consumer/OrganisasjonBestillingConsumer.java index 2a05f8976a6..3311898bf6c 100644 --- a/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/consumer/OrganisasjonBestillingConsumer.java +++ b/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/consumer/OrganisasjonBestillingConsumer.java @@ -1,7 +1,7 @@ package no.nav.organisasjonforvalter.consumer; +import lombok.extern.slf4j.Slf4j; import no.nav.organisasjonforvalter.config.Consumers; -import no.nav.organisasjonforvalter.consumer.command.OrganisasjonBestillingCommand; import no.nav.organisasjonforvalter.consumer.command.OrganisasjonBestillingIdsCommand; import no.nav.organisasjonforvalter.consumer.command.OrganisasjonBestillingStatusCommand; import no.nav.organisasjonforvalter.dto.responses.BestillingStatus; @@ -9,10 +9,10 @@ import no.nav.testnav.libs.securitycore.domain.ServerProperties; import no.nav.testnav.libs.servletsecurity.exchange.TokenExchange; import org.springframework.stereotype.Service; - import org.springframework.web.reactive.function.client.WebClient; import reactor.core.publisher.Flux; +@Slf4j @Service public class OrganisasjonBestillingConsumer { @@ -35,7 +35,9 @@ public Flux getBestillingStatus(Status status) { return Flux.from(tokenExchange.exchange(serverProperties) .flatMap(token -> new OrganisasjonBestillingStatusCommand(webClient, status, - token.getTokenValue()).call())); + token.getTokenValue()).call())) + .doOnNext(response -> + log.info("Mottatt response fra Organisasjon-Bestilling-Service: {}",response)); } public Flux getBestillingId(Status status) { @@ -44,14 +46,4 @@ public Flux getBestillingId(Status status) { .flatMap(token -> new OrganisasjonBestillingIdsCommand(webClient, status, token.getTokenValue()).call())); } - - public BestillingStatus getBestillingStatus(String uuid) { - - return tokenExchange.exchange(serverProperties) - .flatMap(token -> new OrganisasjonBestillingCommand(webClient, Status.builder() - .uuid(uuid) - .build(), - token.getTokenValue()).call()) - .block(); - } } diff --git a/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/consumer/OrganisasjonServiceConsumer.java b/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/consumer/OrganisasjonServiceConsumer.java index 3bf3779ccd2..2affeb18fd8 100644 --- a/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/consumer/OrganisasjonServiceConsumer.java +++ b/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/consumer/OrganisasjonServiceConsumer.java @@ -1,30 +1,20 @@ package no.nav.organisasjonforvalter.consumer; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; import lombok.extern.slf4j.Slf4j; import no.nav.organisasjonforvalter.config.Consumers; -import no.nav.testnav.libs.commands.organisasjonservice.v1.GetOrganisasjonCommand; +import no.nav.organisasjonforvalter.consumer.command.OrganisasjonServiceCommand; import no.nav.testnav.libs.dto.organisasjon.v1.OrganisasjonDTO; import no.nav.testnav.libs.securitycore.domain.ServerProperties; import no.nav.testnav.libs.servletsecurity.exchange.TokenExchange; import org.springframework.stereotype.Service; - import org.springframework.web.reactive.function.client.WebClient; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; import java.util.Map; -import java.util.Optional; import java.util.Set; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; import java.util.stream.Collectors; -import static java.lang.System.currentTimeMillis; -import static java.util.Objects.nonNull; - @Slf4j @Service public class OrganisasjonServiceConsumer { @@ -32,7 +22,6 @@ public class OrganisasjonServiceConsumer { private final TokenExchange tokenExchange; private final WebClient webClient; private final ServerProperties serverProperties; - private final ExecutorService executorService; public OrganisasjonServiceConsumer( Consumers consumers, @@ -42,107 +31,20 @@ public OrganisasjonServiceConsumer( .baseUrl(serverProperties.getUrl()) .build(); this.tokenExchange = tokenExchange; - this.executorService = Executors.newFixedThreadPool(serverProperties.getThreads()); - } - - public Optional getStatus(String orgnummer, String miljoe) { - - try { - return getStatus(Set.of(orgnummer), Set.of(miljoe)).get(miljoe).get(orgnummer); - } catch (RuntimeException e) { - log.error(e.getMessage(), e); - return Optional.empty(); - } - } - - public Map>> getStatus(Set orgnummer, Set miljoer) { - - long startTime = currentTimeMillis(); - - var token = tokenExchange.exchange(serverProperties).block().getTokenValue(); - - var completables = miljoer.stream() - .map(miljoe -> OrgFutureDTO.builder() - .miljoe(miljoe) - .futureDto(orgnummer.stream() - .map(orgnr -> FutureDTO.builder() - .orgnr(orgnr) - .completableFuture( - CompletableFuture.supplyAsync(() -> - new GetOrganisasjonCommand(webClient, token, orgnr, miljoe).call(), - executorService)) - .build()) - .collect(Collectors.toMap(entry -> entry.getOrgnr(), entry -> entry.getCompletableFuture()))) - .build()) - .collect(Collectors.toMap(entry -> entry.getMiljoe(), entry -> entry.getFutureDto())); - - var organisasjoner = completables.keySet().stream() - .map(miljoe -> MiljoeOrgnrOrgDTO.builder() - .miljoe(miljoe) - .orgnrOrgDTO( - completables.get(miljoe).keySet().stream() - .map(orgnr -> - OrganisasjonServiceConsumer.OrgnrOrgDTO.builder() - .orgnr(orgnr) - .organisasjonDTO(resolveCompleteable(completables.get(miljoe).get(orgnr))) - .build()) - .collect(Collectors.toMap(entry -> entry.getOrgnr(), entry -> entry.getOrganisasjonDTO()))) - .build()) - .collect(Collectors.toMap(entry -> entry.getMiljoe(), entry -> entry.getOrgnrOrgDTO())); - - log.info("Organisasjon-Service svarte med funnet etter {} ms", currentTimeMillis() - startTime); - - return organisasjoner; - } - - private Optional resolveCompleteable(CompletableFuture future) { - - try { - var result = future.get(); - return nonNull(result) ? Optional.of(result) : Optional.empty(); - } catch (Exception e) { - log.error(e.getMessage(), e); - return Optional.empty(); - } - } - - @Data - @Builder - @NoArgsConstructor - @AllArgsConstructor - private static class OrgFutureDTO { - - private String miljoe; - private Map> futureDto; - } - - @Data - @Builder - @NoArgsConstructor - @AllArgsConstructor - private static class FutureDTO { - - private String orgnr; - private CompletableFuture completableFuture; } - @Data - @Builder - @NoArgsConstructor - @AllArgsConstructor - private static class MiljoeOrgnrOrgDTO { + public Flux> getStatus(String orgnummer, String miljoe) { - private String miljoe; - private Map> orgnrOrgDTO; + return getStatus(Set.of(orgnummer), Set.of(miljoe)); } - @Data - @Builder - @NoArgsConstructor - @AllArgsConstructor - private static class OrgnrOrgDTO { + public Flux> getStatus(Set orgnummere, Set miljoer) { - private String orgnr; - private Optional organisasjonDTO; + return tokenExchange.exchange(serverProperties) + .flatMapMany(token -> Flux.fromIterable(miljoer) + .map(miljoe -> Flux.fromIterable(orgnummere) + .flatMap(orgnr -> new OrganisasjonServiceCommand(webClient, orgnr, miljoe, token.getTokenValue()).call()) + .collect(Collectors.toMap(orgMap -> miljoe, orgMap -> orgMap)))) + .flatMap(Mono::flux); } } diff --git a/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/consumer/command/AdresseServiceCommand.java b/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/consumer/command/AdresseServiceCommand.java index 76981d582a1..0f0d3168aea 100644 --- a/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/consumer/command/AdresseServiceCommand.java +++ b/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/consumer/command/AdresseServiceCommand.java @@ -1,8 +1,8 @@ package no.nav.organisasjonforvalter.consumer.command; import lombok.RequiredArgsConstructor; -import no.nav.testnav.libs.commands.utils.WebClientFilter; import no.nav.testnav.libs.dto.adresseservice.v1.VegadresseDTO; +import no.nav.testnav.libs.reactivecore.utils.WebClientFilter; import org.springframework.http.HttpHeaders; import org.springframework.web.reactive.function.client.WebClient; import reactor.core.publisher.Mono; @@ -28,6 +28,7 @@ public Mono call() { .header(HttpHeaders.AUTHORIZATION, "Bearer " + token) .retrieve() .bodyToMono(VegadresseDTO[].class) + .doOnError(WebClientFilter::logErrorMessage) .retryWhen(Retry.backoff(3, Duration.ofSeconds(5)) .filter(WebClientFilter::is5xxException)); } diff --git a/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/consumer/command/GenererNavnCommand.java b/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/consumer/command/GenererNavnCommand.java new file mode 100644 index 00000000000..3a1dfc82a0d --- /dev/null +++ b/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/consumer/command/GenererNavnCommand.java @@ -0,0 +1,38 @@ +package no.nav.organisasjonforvalter.consumer.command; + +import lombok.RequiredArgsConstructor; +import no.nav.testnav.libs.dto.generernavnservice.v1.NavnDTO; +import no.nav.testnav.libs.reactivecore.utils.WebClientFilter; +import org.springframework.http.HttpHeaders; +import org.springframework.web.reactive.function.client.WebClient; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; +import reactor.util.retry.Retry; + +import java.time.Duration; +import java.util.concurrent.Callable; + +@RequiredArgsConstructor +public class GenererNavnCommand implements Callable> { + + private final WebClient webClient; + private final Integer antall; + private final String accessToken; + + @Override + public Flux call() { + return webClient + .get() + .uri(builder -> builder + .path("/api/v1/navn") + .queryParam("antall", antall) + .build()) + .header(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken) + .retrieve() + .bodyToFlux(NavnDTO.class) + .doOnError(WebClientFilter::logErrorMessage) + .retryWhen(Retry.backoff(3, Duration.ofSeconds(5)) + .filter(WebClientFilter::is5xxException)) + .onErrorResume(throwable -> Mono.empty()); + } +} \ No newline at end of file diff --git a/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/consumer/command/MiljoerServiceCommand.java b/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/consumer/command/MiljoerServiceCommand.java index 00b886b6bd1..6213f155ac8 100644 --- a/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/consumer/command/MiljoerServiceCommand.java +++ b/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/consumer/command/MiljoerServiceCommand.java @@ -1,7 +1,7 @@ package no.nav.organisasjonforvalter.consumer.command; import lombok.RequiredArgsConstructor; -import no.nav.testnav.libs.commands.utils.WebClientFilter; +import no.nav.testnav.libs.reactivecore.utils.WebClientFilter; import org.springframework.http.HttpHeaders; import org.springframework.web.reactive.function.client.WebClient; import reactor.core.publisher.Mono; @@ -27,6 +27,8 @@ public Mono call() { .retrieve() .bodyToMono(String[].class) .retryWhen(Retry.backoff(3, Duration.ofSeconds(5)) - .filter(WebClientFilter::is5xxException)); + .filter(WebClientFilter::is5xxException)) + .doOnError(WebClientFilter::logErrorMessage) + .onErrorResume(throwable -> Mono.empty()); } } diff --git a/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/consumer/command/OrganisasjonBestillingCommand.java b/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/consumer/command/OrganisasjonBestillingCommand.java deleted file mode 100644 index ffd06521def..00000000000 --- a/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/consumer/command/OrganisasjonBestillingCommand.java +++ /dev/null @@ -1,61 +0,0 @@ -package no.nav.organisasjonforvalter.consumer.command; - -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import no.nav.organisasjonforvalter.dto.responses.BestillingStatus; -import no.nav.organisasjonforvalter.jpa.entity.Status; -import no.nav.testnav.libs.commands.utils.WebClientFilter; -import org.springframework.http.HttpHeaders; -import org.springframework.web.reactive.function.client.WebClient; -import org.springframework.web.reactive.function.client.WebClientResponseException; -import reactor.core.publisher.Mono; -import reactor.util.retry.Retry; - -import java.time.Duration; -import java.util.Arrays; -import java.util.concurrent.Callable; - -@Slf4j -@RequiredArgsConstructor -public class OrganisasjonBestillingCommand implements Callable> { - - private static final String STATUS_URL = "/api/v1/order/{uuid}/items"; - - private final WebClient webClient; - private final Status status; - private final String token; - - @Override - public Mono call() { - - return webClient.get() - .uri(STATUS_URL.replace("{uuid}", status.getUuid())) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + token) - .exchange() - .flatMap(response -> response - .bodyToMono(BestillingStatus.ItemDto[].class) - .map(value -> BestillingStatus.builder() - .orgnummer(status.getOrganisasjonsnummer()) - .uuid(status.getUuid()) - .miljoe(status.getMiljoe()) - .itemDtos(Arrays.asList(value)) - .build())) - - .retryWhen(Retry.backoff(3, Duration.ofSeconds(5)) - .filter(WebClientFilter::is5xxException)) - - .doOnError(throwable -> { - log.error(throwable instanceof WebClientResponseException webClientResponseException ? - webClientResponseException.getResponseBodyAsString() : - throwable.getMessage()); - - BestillingStatus.builder() - .uuid(status.getUuid()) - .miljoe(status.getMiljoe()) - .feilmelding(throwable instanceof WebClientResponseException webClientResponseException ? - webClientResponseException.getResponseBodyAsString() : - throwable.getMessage()) - .build(); - }); - } -} \ No newline at end of file diff --git a/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/consumer/command/OrganisasjonBestillingIdsCommand.java b/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/consumer/command/OrganisasjonBestillingIdsCommand.java index 2c800f73b28..1b1f9197b29 100644 --- a/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/consumer/command/OrganisasjonBestillingIdsCommand.java +++ b/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/consumer/command/OrganisasjonBestillingIdsCommand.java @@ -3,16 +3,14 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import no.nav.organisasjonforvalter.jpa.entity.Status; -import no.nav.testnav.libs.commands.utils.WebClientFilter; +import no.nav.testnav.libs.reactivecore.utils.WebClientFilter; import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; import org.springframework.web.reactive.function.client.WebClient; -import org.springframework.web.reactive.function.client.WebClientResponseException; import reactor.core.publisher.Mono; -import reactor.util.retry.Retry; -import java.time.Duration; +import java.util.Arrays; import java.util.concurrent.Callable; -import java.util.stream.Stream; @Slf4j @RequiredArgsConstructor @@ -28,19 +26,25 @@ public class OrganisasjonBestillingIdsCommand implements Callable> public Mono call() { return webClient.get() - .uri(STATUS_URL.replace("{uuid}", status.getUuid())) + .uri(uriBuilder -> uriBuilder.path(STATUS_URL) + .build(status.getUuid())) .header(HttpHeaders.AUTHORIZATION, "Bearer " + token) + .accept(MediaType.APPLICATION_JSON) .retrieve() .bodyToMono(String[].class) - .flatMap(value -> { - status.setBestId(Stream.of(value).findFirst().orElse(null)); - return Mono.just(status); - }) - .retryWhen(Retry.backoff(3, Duration.ofSeconds(5)) - .filter(WebClientFilter::is5xxException)) - .doOnError(throwable -> - log.error(throwable instanceof WebClientResponseException webClientResponseException ? - webClientResponseException.getResponseBodyAsString() : - throwable.getMessage())); + .doOnNext(resultat -> log.info("Melding mottatt {}", Arrays.toString(resultat))) + .map(resultat -> Arrays.stream(resultat) + .mapToInt(Integer::parseInt) + .max() + .orElse(0)) + .doOnNext(resultat -> log.info("Index funnet {}", resultat)) + .map(index -> Status.builder() + .id(status.getId()) + .bestId(index != 0 ? index.toString() : null) + .uuid(status.getUuid()) + .miljoe(status.getMiljoe()) + .organisasjonsnummer(status.getOrganisasjonsnummer()) + .build()) + .doOnError(WebClientFilter::logErrorMessage); } } \ No newline at end of file diff --git a/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/consumer/command/OrganisasjonBestillingStatusCommand.java b/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/consumer/command/OrganisasjonBestillingStatusCommand.java index 0c2ba7eb14b..bfbce4bf1ad 100644 --- a/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/consumer/command/OrganisasjonBestillingStatusCommand.java +++ b/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/consumer/command/OrganisasjonBestillingStatusCommand.java @@ -5,10 +5,9 @@ import no.nav.organisasjonforvalter.dto.responses.BestillingStatus; import no.nav.organisasjonforvalter.dto.responses.StatusDTO; import no.nav.organisasjonforvalter.jpa.entity.Status; -import no.nav.testnav.libs.commands.utils.WebClientFilter; +import no.nav.testnav.libs.reactivecore.utils.WebClientFilter; import org.springframework.http.HttpHeaders; import org.springframework.web.reactive.function.client.WebClient; -import org.springframework.web.reactive.function.client.WebClientResponseException; import reactor.core.publisher.Mono; import reactor.util.retry.Retry; @@ -28,9 +27,12 @@ public class OrganisasjonBestillingStatusCommand implements Callable call() { + log.info("Henter status fra Organisasjon-Bestilling-Service uuid: {} id :{}", + status.getUuid(), status.getBestId()); + return webClient.get() - .uri(STATUS_URL.replace("{uuid}", status.getUuid()) - .replace("{id}", status.getBestId())) + .uri(uriBuilder -> uriBuilder.path(STATUS_URL) + .build(status.getUuid(), status.getBestId())) .header(HttpHeaders.AUTHORIZATION, "Bearer " + token) .retrieve() .bodyToMono(StatusDTO.class) @@ -42,24 +44,13 @@ public Mono call() { .build())) .retryWhen(Retry.backoff(3, Duration.ofSeconds(5)) .filter(WebClientFilter::is5xxException)) - .doOnError(throwable -> log.error(getMessage(throwable))) - .onErrorResume(throwable -> getError(status, getMessage(throwable))); - } - - private static String getMessage(Throwable throwable) { - - return throwable instanceof WebClientResponseException webClientResponseException ? - webClientResponseException.getResponseBodyAsString() : - throwable.getMessage(); - } - - private static Mono getError(Status status, String description) { - - return Mono.just(BestillingStatus.builder() - .orgnummer(status.getOrganisasjonsnummer()) - .uuid(status.getUuid()) - .miljoe(status.getMiljoe()) - .feilmelding(description) - .build()); + .doOnError(WebClientFilter::logErrorMessage) + .onErrorResume(throwable -> + Mono.just(BestillingStatus.builder() + .orgnummer(status.getOrganisasjonsnummer()) + .uuid(status.getUuid()) + .miljoe(status.getMiljoe()) + .feilmelding(WebClientFilter.getMessage(throwable)) + .build())); } } \ No newline at end of file diff --git a/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/consumer/command/OrganisasjonOrgnummerServiceCommand.java b/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/consumer/command/OrganisasjonOrgnummerServiceCommand.java index 2405c489d16..02efac52271 100644 --- a/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/consumer/command/OrganisasjonOrgnummerServiceCommand.java +++ b/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/consumer/command/OrganisasjonOrgnummerServiceCommand.java @@ -1,7 +1,7 @@ package no.nav.organisasjonforvalter.consumer.command; import lombok.RequiredArgsConstructor; -import no.nav.testnav.libs.commands.utils.WebClientFilter; +import no.nav.testnav.libs.reactivecore.utils.WebClientFilter; import org.springframework.http.HttpHeaders; import org.springframework.web.reactive.function.client.WebClient; import reactor.core.publisher.Mono; @@ -28,6 +28,7 @@ public Mono call() { .header("antall", antall.toString()) .retrieve() .bodyToMono(String[].class) + .doOnError(WebClientFilter::logErrorMessage) .retryWhen(Retry.backoff(3, Duration.ofSeconds(5)) .filter(WebClientFilter::is5xxException)); } diff --git a/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/consumer/command/OrganisasjonServiceCommand.java b/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/consumer/command/OrganisasjonServiceCommand.java index aaa7485984f..c8d26cc1a83 100644 --- a/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/consumer/command/OrganisasjonServiceCommand.java +++ b/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/consumer/command/OrganisasjonServiceCommand.java @@ -1,18 +1,21 @@ package no.nav.organisasjonforvalter.consumer.command; import lombok.RequiredArgsConstructor; -import no.nav.testnav.libs.commands.utils.WebClientFilter; +import lombok.extern.slf4j.Slf4j; import no.nav.testnav.libs.dto.organisasjon.v1.OrganisasjonDTO; +import no.nav.testnav.libs.reactivecore.utils.WebClientFilter; import org.springframework.http.HttpHeaders; import org.springframework.web.reactive.function.client.WebClient; +import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.util.retry.Retry; import java.time.Duration; import java.util.concurrent.Callable; +@Slf4j @RequiredArgsConstructor -public class OrganisasjonServiceCommand implements Callable> { +public class OrganisasjonServiceCommand implements Callable> { private static final String STATUS_URL = "/api/v1/organisasjoner/{orgnummer}"; private static final String MILJOE = "miljo"; @@ -23,14 +26,21 @@ public class OrganisasjonServiceCommand implements Callable call() { + public Flux call() { + + log.info("Henter organisasjon {} fra miljø {} ", orgnummer, environment); return webClient.get() - .uri(STATUS_URL.replace("{orgnummer}", orgnummer)) + .uri(uriBuilder -> uriBuilder.path(STATUS_URL) + .build(orgnummer)) .header(HttpHeaders.AUTHORIZATION, "Bearer " + token) .header(MILJOE, environment) .retrieve() - .bodyToMono(OrganisasjonDTO.class) + .bodyToFlux(OrganisasjonDTO.class) + .doOnError(WebClientFilter::logErrorMessage) + .onErrorResume(throwable -> Mono.just(OrganisasjonDTO.builder() + .error(WebClientFilter.getMessage(throwable)) + .build())) .retryWhen(Retry.backoff(3, Duration.ofSeconds(5)) .filter(WebClientFilter::is5xxException)); } diff --git a/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/controller/OrganisasjonController.java b/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/controller/OrganisasjonController.java index 39a2f20cfc3..a91986b3f08 100644 --- a/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/controller/OrganisasjonController.java +++ b/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/controller/OrganisasjonController.java @@ -1,23 +1,8 @@ package no.nav.organisasjonforvalter.controller; -import static java.util.Objects.nonNull; -import static no.nav.organisasjonforvalter.config.CacheConfig.CACHE_BEDRIFT; - import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import lombok.RequiredArgsConstructor; -import org.springframework.cache.annotation.CacheEvict; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import java.util.List; -import java.util.Map; -import java.util.Set; - import no.nav.organisasjonforvalter.dto.requests.BestillingRequest; import no.nav.organisasjonforvalter.dto.requests.DeployRequest; import no.nav.organisasjonforvalter.dto.responses.BestillingResponse; @@ -32,9 +17,22 @@ import no.nav.organisasjonforvalter.service.OrdreStatusService; import no.nav.organisasjonforvalter.service.OrganisasjonService; import no.nav.testnav.libs.servletsecurity.action.GetAuthenticatedId; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +import static java.util.Objects.nonNull; @RestController -@RequestMapping("api/v2/organisasjoner") +@RequestMapping(value = "api/v2/organisasjoner", produces = MediaType.APPLICATION_JSON_VALUE) @RequiredArgsConstructor public class OrganisasjonController { @@ -46,7 +44,6 @@ public class OrganisasjonController { private final DrivervirksomheterService drivervirksomheterService; private final GetAuthenticatedId getAuthenticatedId; - @CacheEvict(value = CACHE_BEDRIFT, allEntries = true) @PostMapping @Operation(description = "Opprett organisasjon med angitte egenskaper") public BestillingResponse createOrganisasjon(@RequestBody BestillingRequest request) { diff --git a/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/dto/responses/StatusDTO.java b/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/dto/responses/StatusDTO.java index 52efbebc79c..1507b2a0594 100644 --- a/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/dto/responses/StatusDTO.java +++ b/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/dto/responses/StatusDTO.java @@ -12,7 +12,7 @@ public class StatusDTO { public enum Status { - NOT_FOUND, ADDING_TO_QUEUE, IN_QUEUE_WAITING_TO_START, RUNNING, COMPLETED, ERROR, FAILED + NOT_FOUND, ADDING_TO_QUEUE, IN_QUEUE_WAITING_TO_START, RUNNING, COMPLETED, PENDING_COMPLETE, ERROR, FAILED } private Status status; diff --git a/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/jpa/repository/StatusRepository.java b/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/jpa/repository/StatusRepository.java index 440b1d4908e..0418af5b6f0 100644 --- a/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/jpa/repository/StatusRepository.java +++ b/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/jpa/repository/StatusRepository.java @@ -6,7 +6,6 @@ import org.springframework.data.repository.query.Param; import java.util.List; -import java.util.Optional; public interface StatusRepository extends CrudRepository { @@ -14,5 +13,5 @@ public interface StatusRepository extends CrudRepository { "where s.id in (select max(u.id) from Status u " + "where u.organisasjonsnummer in (:orgnr) " + "group by u.organisasjonsnummer, u.miljoe)") - Optional> findAllByOrganisasjonsnummer(@Param(value = "orgnr") List organisasjonsnummer); + List findAllByOrganisasjonsnummerIn(@Param("orgnr") List organisasjonsnummer); } diff --git a/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/service/ClearCacheService.java b/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/service/ClearCacheService.java deleted file mode 100644 index 1621369de70..00000000000 --- a/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/service/ClearCacheService.java +++ /dev/null @@ -1,26 +0,0 @@ -package no.nav.organisasjonforvalter.service; - -import lombok.RequiredArgsConstructor; -import org.springframework.cache.CacheManager; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Service; - -import static java.util.Objects.nonNull; -import static no.nav.organisasjonforvalter.config.CacheConfig.CACHE_MILJOER; - -@Service -@RequiredArgsConstructor -public class ClearCacheService { - - private static final long EVERY_HOUR = 60 * 60 * 1000L; - - private final CacheManager cacheManager; - - @Scheduled(fixedRate = EVERY_HOUR) - public void cacheEvictMiljoer() { - - if (nonNull(cacheManager.getCache(CACHE_MILJOER))) { - cacheManager.getCache(CACHE_MILJOER).clear(); - } - } -} diff --git a/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/service/ImportService.java b/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/service/ImportService.java index 1d660078eac..d122c6ab820 100644 --- a/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/service/ImportService.java +++ b/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/service/ImportService.java @@ -1,28 +1,23 @@ package no.nav.organisasjonforvalter.service; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import ma.glasnost.orika.MapperFacade; import no.nav.organisasjonforvalter.consumer.MiljoerServiceConsumer; import no.nav.organisasjonforvalter.consumer.OrganisasjonServiceConsumer; import no.nav.organisasjonforvalter.dto.responses.RsOrganisasjon; -import no.nav.organisasjonforvalter.jpa.entity.Organisasjon; -import no.nav.organisasjonforvalter.jpa.repository.OrganisasjonRepository; -import no.nav.testnav.libs.dto.organisasjon.v1.OrganisasjonDTO; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import reactor.core.publisher.Flux; -import java.util.HashSet; import java.util.Map; -import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; import static java.util.Objects.nonNull; +import static org.apache.commons.lang3.StringUtils.isNotBlank; +@Slf4j @Service @RequiredArgsConstructor public class ImportService { @@ -30,79 +25,22 @@ public class ImportService { private final MiljoerServiceConsumer miljoerServiceConsumer; private final OrganisasjonServiceConsumer organisasjonServiceConsumer; private final MapperFacade mapperFacade; - private final OrganisasjonRepository organisasjonRepository; - - private static Set getAllOrgnr(Organisasjon organisasjon, Set orgnr) { - - orgnr.add(organisasjon.getOrganisasjonsnummer()); - organisasjon.getUnderenheter().forEach(org -> getAllOrgnr(org, orgnr)); - return orgnr; - } @Transactional public Map getOrganisasjoner(String orgnummer, Set miljoer) { - var miljoerAaSjekke = nonNull(miljoer) && - miljoer.stream().anyMatch(miljoe -> - miljoerServiceConsumer.getOrgMiljoer().stream().anyMatch(miljoe2 -> miljoe2.equals(miljoe))) ? - - miljoer.stream().filter(miljoe -> - miljoerServiceConsumer.getOrgMiljoer().stream().anyMatch(miljoe2 -> miljoe2.equals(miljoe))) + var miljoerAaSjekke = nonNull(miljoer) && !miljoer.isEmpty() ? + miljoerServiceConsumer.getOrgMiljoer().stream() + .filter(miljoer::contains) .collect(Collectors.toSet()) : - miljoerServiceConsumer.getOrgMiljoer(); - var dbOrganisasjon = organisasjonRepository.findByOrganisasjonsnummer(orgnummer); - - var organisasjoner = - organisasjonServiceConsumer.getStatus(dbOrganisasjon.isPresent() ? - getAllOrgnr(dbOrganisasjon.get(), new HashSet<>()) : Set.of(orgnummer), miljoerAaSjekke); - - return organisasjoner.keySet().stream() - .filter(env -> !organisasjoner.get(env).entrySet().isEmpty()) - .map(env -> OrganisasjonMiljoe.builder() - .organisasjon(getOrganisasjon(env, orgnummer, organisasjoner)) - .miljoe(env) - .build()) - .filter(org -> nonNull(org.getOrganisasjon())) - .collect(Collectors.toMap(OrganisasjonMiljoe::getMiljoe, OrganisasjonMiljoe::getOrganisasjon)); - } - - private RsOrganisasjon getOrganisasjon(String env, String orgnummer, - Map>> organisasjoner) { - - OrganisasjonDTO organisasjonDto; - if (organisasjoner.get(env).containsKey(orgnummer)) { - if (organisasjoner.get(env).get(orgnummer).isPresent()) { - organisasjonDto = organisasjoner.get(env).get(orgnummer).get(); - } else { - return null; - } - } else { - var organisasjon = organisasjonServiceConsumer.getStatus(orgnummer, env); - if (organisasjon.isPresent()) { - organisasjonDto = organisasjon.get(); - } else { - return null; - } - } - - RsOrganisasjon organisasjon = mapperFacade.map(organisasjonDto, RsOrganisasjon.class); - if (nonNull(organisasjonDto.getDriverVirksomheter())) { - organisasjon.setUnderenheter(organisasjonDto.getDriverVirksomheter().stream() - .map(orgnr -> getOrganisasjon(env, orgnr, organisasjoner)) - .collect(Collectors.toList())); - } - return organisasjon; - } - - @Data - @Builder - @NoArgsConstructor - @AllArgsConstructor - public static class OrganisasjonMiljoe { - - private RsOrganisasjon organisasjon; - private String miljoe; + return organisasjonServiceConsumer.getStatus(Set.of(orgnummer), miljoerAaSjekke) + .map(Map::entrySet) + .flatMap(Flux::fromIterable) + .filter(org -> isNotBlank(org.getValue().getOrgnummer())) + .collect(Collectors.toMap(Map.Entry::getKey, + org -> mapperFacade.map(org.getValue(), RsOrganisasjon.class))) + .block(); } } diff --git a/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/service/OrdreService.java b/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/service/OrdreService.java index 0ab17fd6e90..dfaeb12733d 100644 --- a/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/service/OrdreService.java +++ b/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/service/OrdreService.java @@ -16,13 +16,17 @@ import org.springframework.stereotype.Service; import org.springframework.web.client.HttpClientErrorException; +import java.util.Collection; import java.util.List; +import java.util.Map; import java.util.UUID; import java.util.stream.Collectors; import static java.lang.String.format; +import static java.util.Objects.isNull; import static no.nav.organisasjonforvalter.dto.responses.DeployResponse.Status.ERROR; import static no.nav.organisasjonforvalter.dto.responses.DeployResponse.Status.OK; +import static org.apache.commons.lang3.StringUtils.isBlank; import static org.springframework.http.HttpStatus.BAD_REQUEST; @Slf4j @@ -82,10 +86,19 @@ public DeployResponse deploy(DeployRequest request) { private void deployOrganisasjon(String uuid, Organisasjon organisasjon, String env) { - if (organisasjonServiceConsumer.getStatus(organisasjon.getOrganisasjonsnummer(), env).isEmpty()) { + var orgStatus = organisasjonServiceConsumer.getStatus(organisasjon.getOrganisasjonsnummer(), env) + .collectList() + .block(); + + if (isNull(orgStatus) || orgStatus.stream() + .map(Map::entrySet) + .flatMap(Collection::stream) + .allMatch(org -> isBlank(org.getValue().getOrgnummer()))) { + organisasjonMottakConsumer.opprettOrganisasjon(uuid, organisasjon, env); } else { + organisasjonMottakConsumer.endreOrganisasjon(uuid, organisasjon, env); } } diff --git a/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/service/OrdreStatusService.java b/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/service/OrdreStatusService.java index a0e3cad2b59..121a9dc3c2a 100644 --- a/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/service/OrdreStatusService.java +++ b/apps/organisasjon-forvalter/src/main/java/no/nav/organisasjonforvalter/service/OrdreStatusService.java @@ -1,33 +1,27 @@ package no.nav.organisasjonforvalter.service; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import no.nav.organisasjonforvalter.consumer.OrganisasjonBestillingConsumer; import no.nav.organisasjonforvalter.dto.responses.BestillingStatus; import no.nav.organisasjonforvalter.dto.responses.OrdreResponse; import no.nav.organisasjonforvalter.dto.responses.OrdreResponse.StatusEnv; -import no.nav.organisasjonforvalter.dto.responses.RsOrganisasjon; import no.nav.organisasjonforvalter.dto.responses.StatusDTO; import no.nav.organisasjonforvalter.jpa.repository.StatusRepository; -import org.springframework.http.HttpStatus; import org.springframework.stereotype.Service; -import org.springframework.web.client.HttpClientErrorException; import reactor.core.publisher.Flux; import java.util.ArrayList; +import java.util.Collection; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.stream.Collectors; import static java.util.Objects.nonNull; -import static java.util.stream.Collectors.mapping; -import static java.util.stream.Collectors.toList; import static no.nav.organisasjonforvalter.dto.responses.StatusDTO.Status.ADDING_TO_QUEUE; import static no.nav.organisasjonforvalter.dto.responses.StatusDTO.Status.COMPLETED; +import static no.nav.organisasjonforvalter.dto.responses.StatusDTO.Status.ERROR; +import static no.nav.organisasjonforvalter.dto.responses.StatusDTO.Status.NOT_FOUND; import static org.apache.commons.lang3.StringUtils.isBlank; import static org.apache.commons.lang3.StringUtils.isNotBlank; @@ -42,90 +36,101 @@ public class OrdreStatusService { public OrdreResponse getStatus(List orgnumre) { - var statusMap = statusRepository.findAllByOrganisasjonsnummer(orgnumre) - .orElseThrow(() -> new HttpClientErrorException(HttpStatus.NOT_FOUND, "Ingen status funnet for gitte orgnumre")); + var orgImiljo = orgnumre.stream() + .map(orgnr -> importService.getOrganisasjoner(orgnr, null)) + .toList(); - if (statusMap.stream().anyMatch(status -> isBlank(status.getBestId()))) { - statusMap.stream() - .map(organisasjonBestillingConsumer::getBestillingId) - .reduce(Flux.empty(), Flux::concat) - .collectList() - .block(); - statusRepository.saveAll(statusMap); - } + var statusMap = statusRepository.findAllByOrganisasjonsnummerIn(orgnumre); - var orgStatus = statusMap.stream() - .filter(status -> isNotBlank(status.getBestId())) - .map(organisasjonBestillingConsumer::getBestillingStatus) - .reduce(Flux.empty(), Flux::concat) - .collectList() - .block(); + var orgnrIkkeFunnet = orgnumre.stream() + .filter(orgnr -> statusMap.stream() + .noneMatch(status -> orgnr.equals(status.getOrganisasjonsnummer()))) + .filter(orgnr -> orgImiljo.stream() + .flatMap(iMiljoe -> iMiljoe.values().stream()) + .noneMatch(iMiljo -> orgnr.equals(iMiljo.getOrganisasjonsnummer()))) + .collect(Collectors.toSet()); - var firstOrg = nonNull(orgStatus) ? orgStatus.stream().findFirst().orElse(null) : null; + var oppdatertStatus = statusMap.stream() + .filter(status -> orgnrIkkeFunnet.stream() + .noneMatch(orgnr -> orgnr.equals(status.getOrganisasjonsnummer()))) + .toList(); - var orgIMiljoe = false; + if (oppdatertStatus.stream().anyMatch(status -> isBlank(status.getBestId()))) { - if (nonNull(firstOrg)) { - Map organisasjoner = importService.getOrganisasjoner(firstOrg.getOrgnummer(), Set.of(firstOrg.getMiljoe())); - log.info("Leter etter organisasjoner i miljoe: {}", firstOrg.getMiljoe()); - if (!organisasjoner.isEmpty()) { - log.info("Fant org: {} i miljoe: {}", firstOrg.getOrgnummer(), firstOrg.getMiljoe()); - orgIMiljoe = true; - } - } + oppdatertStatus = Flux.fromIterable(statusMap) + .flatMap(organisasjonBestillingConsumer::getBestillingId) + .collectList() + .block(); - if (statusMap.stream().anyMatch(status -> isBlank(status.getBestId()))) { - orgStatus.addAll(statusMap.stream() - .filter(status -> isBlank(status.getBestId())) - .map(status -> BestillingStatus.builder() - .orgnummer(status.getOrganisasjonsnummer()) - .miljoe(status.getMiljoe()) - .status(StatusDTO.builder() - .status(ADDING_TO_QUEUE) - .description("Bestilling venter på å starte") - .build()) - .build()) - .toList()); + statusRepository.saveAll(oppdatertStatus); } - if (orgIMiljoe) { - return OrdreResponse.builder() - .orgStatus(orgStatus - .stream() - .collect(Collectors.groupingBy(BestillingStatus::getOrgnummer, - mapping(status -> StatusEnv.builder() - .status(COMPLETED) - .details("Fant organisasjon i miljø") - .environment(status.getMiljoe()) - .error(status.getFeilmelding()) - .build(), - toList())))) - .build(); - } + var orgStatus = new ArrayList(); + + orgStatus.addAll(Flux.fromIterable(oppdatertStatus) + .filter(status -> isNotBlank(status.getBestId())) + .filter(status -> orgImiljo.stream() + .map(Map::entrySet) + .flatMap(Collection::stream) + .noneMatch(iMiljo -> status.getMiljoe().equals(iMiljo.getKey()) && + status.getOrganisasjonsnummer().equals(iMiljo.getValue().getOrganisasjonsnummer()))) + .flatMap(organisasjonBestillingConsumer::getBestillingStatus) + .collectList() + .block()); + + orgStatus.addAll(oppdatertStatus.stream() + .filter(status -> isBlank(status.getBestId())) + .filter(status -> orgImiljo.stream() + .map(Map::entrySet) + .flatMap(Collection::stream) + .noneMatch(iMiljo -> status.getMiljoe().equals(iMiljo.getKey()) && + status.getOrganisasjonsnummer().equals(iMiljo.getValue().getOrganisasjonsnummer()))) + .map(status -> BestillingStatus.builder() + .orgnummer(status.getOrganisasjonsnummer()) + .miljoe(status.getMiljoe()) + .status(StatusDTO.builder() + .status(ADDING_TO_QUEUE) + .description("Bestilling venter på å starte") + .build()) + .build()) + .toList()); + + orgStatus.addAll(orgImiljo.stream() + .map(iMiljo -> iMiljo.entrySet().stream() + .map(entry -> BestillingStatus.builder() + .orgnummer(entry.getValue().getOrganisasjonsnummer()) + .status(StatusDTO.builder() + .status(COMPLETED) + .description("Fant organisasjonen i miljø") + .build()) + .miljoe(entry.getKey()) + .build()) + .toList()) + .flatMap(Collection::stream) + .toList()); + + orgStatus.addAll(orgnrIkkeFunnet.stream() + .map(orgnr -> BestillingStatus.builder() + .orgnummer(orgnr) + .status(StatusDTO.builder() + .status(NOT_FOUND) + .description("Ikke funnet") + .build()) + .build()) + .toList()); return OrdreResponse.builder() - .orgStatus((nonNull(orgStatus) ? orgStatus : new ArrayList()) - .stream() - .collect(Collectors.groupingBy(BestillingStatus::getOrgnummer, - mapping(status -> StatusEnv.builder() - .status(nonNull(status.getStatus()) ? - status.getStatus().getStatus() : null) - .details(nonNull(status.getStatus()) ? - status.getStatus().getDescription() : null) - .environment(status.getMiljoe()) - .error(status.getFeilmelding()) - .build(), - toList())))) + .orgStatus(orgStatus.stream() + .collect(Collectors.groupingBy(BestillingStatus::getOrgnummer)) + .entrySet().stream() + .collect(Collectors.toMap(Map.Entry::getKey, org -> org.getValue().stream() + .map(value -> StatusEnv.builder() + .status(nonNull(value.getStatus()) ? value.getStatus().getStatus() : ERROR) + .details(nonNull(value.getStatus()) ? value.getStatus().getDescription() : "Se feilbeskrivelse") + .environment(value.getMiljoe()) + .error(value.getFeilmelding()) + .build()) + .toList()))) .build(); } - - @Data - @NoArgsConstructor - @AllArgsConstructor - public static class DeployEntry { - - private String environment; - private String uuid; - private List lastStatus; - } } diff --git a/apps/organisasjon-forvalter/src/main/resources/application-local.yml b/apps/organisasjon-forvalter/src/main/resources/application-local.yml index ca673c97e3b..3b0bf369372 100644 --- a/apps/organisasjon-forvalter/src/main/resources/application-local.yml +++ b/apps/organisasjon-forvalter/src/main/resources/application-local.yml @@ -1,22 +1,9 @@ spring: - flyway: - enabled: true # Disabled by default as you should probably think twice before running Flyway-migrations - locations: classpath:db/migration - baseline-on-migrate: true datasource: - url: jdbc:postgresql://localhost:5432/organisasjon-forvalter-test - hikari: - maximum-pool-size: 3 - minimum-idle: 1 + url: jdbc:postgresql://localhost:5434/postgres driver-class-name: org.postgresql.Driver - jpa: - properties: - hibernate: - format_sql: true - default-schema: public - show-sql: false - database-platform: org.hibernate.dialect.PostgreSQLDialect + username: postgres cloud: vault: host: vault.adeo.no @@ -29,14 +16,14 @@ spring: consumers: generer-navn-service: - url: https://generer-navn-service.inten.dev.nav.no + url: https://generer-navn-service.intern.dev.nav.no testnav-orgnummer-service: - url: https://testnav-orgnummer-service.inten.dev.nav.no + url: https://testnav-orgnummer-service.intern.dev.nav.no organisasjon-bestilling-service: - url: https://organisasjon-bestilling-service.inten.dev.nav.no + url: https://organisasjon-bestilling-service.intern.dev.nav.no testnav-adresse-service: - url: https://testnav-adresse-service.inten.dev.nav.no + url: https://testnav-adresse-service.intern.dev.nav.no testnav-organisasjon-service: - url: https://testnav-organisasjon-service.inten.dev.nav.no + url: https://testnav-organisasjon-service.intern.dev.nav.no testnav-miljoer-service: - url: https://testnav-miljoer-service.inten.dev.nav.no \ No newline at end of file + url: https://testnav-miljoer-service.intern.dev.nav.no \ No newline at end of file diff --git a/apps/organisasjon-forvalter/src/main/resources/application-prod.yml b/apps/organisasjon-forvalter/src/main/resources/application-prod.yml index 4b8821847b5..5c8f0146c22 100644 --- a/apps/organisasjon-forvalter/src/main/resources/application-prod.yml +++ b/apps/organisasjon-forvalter/src/main/resources/application-prod.yml @@ -1,9 +1,5 @@ spring: - flyway: - enabled: true # Disabled by default as you should probably think twice before running Flyway-migrations - locations: classpath:db/migration - baseline-on-migrate: true datasource: url: jdbc:postgresql://${NAIS_DATABASE_TESTNAV_ORGANISASJON_FORVALTER_ORGANISASJON_FORVALTER_DB_HOST}:${NAIS_DATABASE_TESTNAV_ORGANISASJON_FORVALTER_ORGANISASJON_FORVALTER_DB_PORT}/${NAIS_DATABASE_TESTNAV_ORGANISASJON_FORVALTER_ORGANISASJON_FORVALTER_DB_DATABASE}?user=${NAIS_DATABASE_TESTNAV_ORGANISASJON_FORVALTER_ORGANISASJON_FORVALTER_DB_USERNAME}&password=${NAIS_DATABASE_TESTNAV_ORGANISASJON_FORVALTER_ORGANISASJON_FORVALTER_DB_PASSWORD} driverClassName: org.postgresql.Driver @@ -16,4 +12,11 @@ spring: default-schema: public cloud: vault: - enabled: false \ No newline at end of file + enabled: false + security: + oauth2: + resourceserver: + tokenx: + issuer-uri: ${TOKEN_X_ISSUER} + jwk-set-uri: ${TOKEN_X_JWKS_URI} + accepted-audience: ${TOKEN_X_CLIENT_ID} \ No newline at end of file diff --git a/apps/organisasjon-forvalter/src/main/resources/application.yml b/apps/organisasjon-forvalter/src/main/resources/application.yml index 9cc4dd6812d..ceb680a6b96 100644 --- a/apps/organisasjon-forvalter/src/main/resources/application.yml +++ b/apps/organisasjon-forvalter/src/main/resources/application.yml @@ -5,6 +5,10 @@ spring: name: Testnav-Organisasjon-Forvalter version: 1.0 description: Bestilling, persistering og opphenting av testorganisasjoner + flyway: + enabled: true # Disabled by default as you should probably think twice before running Flyway-migrations + locations: classpath:db/migration + baseline-on-migrate: true security: oauth2: resourceserver: @@ -12,10 +16,6 @@ spring: issuer-uri: ${AAD_ISSUER_URI}/v2.0 jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys accepted-audience: ${azure.app.client.id}, api://${azure.app.client.id} - tokenx: - issuer-uri: ${TOKEN_X_ISSUER} - jwk-set-uri: ${TOKEN_X_JWKS_URI} - accepted-audience: ${TOKEN_X_CLIENT_ID} springdoc: swagger-ui: diff --git a/apps/organisasjon-mottak-service/src/main/resources/application.yml b/apps/organisasjon-mottak-service/src/main/resources/application.yml index 15761dcdecc..ed586798433 100644 --- a/apps/organisasjon-mottak-service/src/main/resources/application.yml +++ b/apps/organisasjon-mottak-service/src/main/resources/application.yml @@ -43,8 +43,6 @@ kafka.groupid: testnav-organisasjon-mottak-service-v1 JENKINS_SERVER_Q1: q1-ereg@b27jbsl01602.preprod.local JENKINS_SERVER_Q2: q2-ereg@b27jbsl01610.preprod.local JENKINS_SERVER_Q4: q4-ereg@b27jbsl01609.preprod.local -JENKINS_SERVER_Q5: q5-ereg@b27jbsl01615.preprod.local -JENKINS_SERVER_T3: t3-ereg@d26jbsl01597.test.local management: endpoints: diff --git a/apps/oversikt-frontend/config.yml b/apps/oversikt-frontend/config.yml index a46246f63ea..53082bdaa3f 100644 --- a/apps/oversikt-frontend/config.yml +++ b/apps/oversikt-frontend/config.yml @@ -28,7 +28,6 @@ spec: rules: - application: dolly-backend - application: dolly-backend-dev - - application: ereg-batch-status-service - application: generer-navn-service - application: organisasjon-bestilling-service - application: synthdata-amelding diff --git a/docs/compose.yaml b/docs/compose.yaml new file mode 100644 index 00000000000..c957309a956 --- /dev/null +++ b/docs/compose.yaml @@ -0,0 +1,30 @@ +services: + postgres-dolly: + container_name: dolly-test + image: postgres:latest + environment: + - POSTGRES_DB=dolly-test + - POSTGRES_HOST_AUTH_METHOD=trust + ports: + - "5432:5432" + restart: always + + postgres-pdl-forvalter: + container_name: pdl-forvalter-test + image: postgres:latest + environment: + - POSTGRES_DB=pdl-forvalter-test + - POSTGRES_HOST_AUTH_METHOD=trust + ports: + - "5433:5432" + restart: always + + postgres-org-forvalter: + container_name: organisasjon-forvalter-test + image: postgres:latest + environment: + - POSTGRES_DB=organisasjon-forvalter-test + - POSTGRES_HOST_AUTH_METHOD=trust + ports: + - "5434:5432" + restart: always \ No newline at end of file diff --git a/libs/commands/src/main/java/no/nav/testnav/libs/commands/utils/WebClientFilter.java b/libs/commands/src/main/java/no/nav/testnav/libs/commands/utils/WebClientFilter.java index 3694c60cd69..2d92b30bcdc 100644 --- a/libs/commands/src/main/java/no/nav/testnav/libs/commands/utils/WebClientFilter.java +++ b/libs/commands/src/main/java/no/nav/testnav/libs/commands/utils/WebClientFilter.java @@ -1,8 +1,10 @@ package no.nav.testnav.libs.commands.utils; import lombok.experimental.UtilityClass; +import lombok.extern.slf4j.Slf4j; import org.springframework.web.reactive.function.client.WebClientResponseException; +@Slf4j @UtilityClass public class WebClientFilter { @@ -11,4 +13,11 @@ public static boolean is5xxException(Throwable throwable) { return throwable instanceof WebClientResponseException wce && wce.getStatusCode().is5xxServerError(); } + + public static void logErrorMessage(Throwable throwable) { + + if (!(throwable instanceof WebClientResponseException)) { + log.error(throwable.getMessage(), throwable); + } + } } \ No newline at end of file diff --git a/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/organisajonbestilling/v2/Status.java b/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/organisajonbestilling/v2/Status.java index c22e2b03845..9b5ad2ae57f 100644 --- a/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/organisajonbestilling/v2/Status.java +++ b/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/organisajonbestilling/v2/Status.java @@ -6,6 +6,7 @@ public enum Status { ADDING_TO_QUEUE, IN_QUEUE_WAITING_TO_START, RUNNING, + PENDING_COMPLETE, COMPLETED, ERROR, FAILED; diff --git a/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/organisajonbestilling/v2/StatusDTO.java b/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/organisajonbestilling/v2/StatusDTO.java index 53f2eab4b61..d786916e06e 100644 --- a/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/organisajonbestilling/v2/StatusDTO.java +++ b/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/organisajonbestilling/v2/StatusDTO.java @@ -23,6 +23,7 @@ private static String getDescription(Status status) { case ERROR -> "Ukjent feil"; case FAILED -> "Ukjent kristisk feil"; case RUNNING -> "Bestillingen blir prosessert av EREG"; + case PENDING_COMPLETE -> "Venter på status av oppretting"; case COMPLETED -> "Bestilling er fullført"; case NOT_FOUND -> "Finner ikke bestilling. Loggene kan ha blitt slettet"; case ADDING_TO_QUEUE -> "Bestillingen venter på tildeling av plass i køen"; diff --git a/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/organisasjon/v1/OrganisasjonDTO.java b/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/organisasjon/v1/OrganisasjonDTO.java index 05920935a7c..b9285723fd7 100644 --- a/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/organisasjon/v1/OrganisasjonDTO.java +++ b/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/organisasjon/v1/OrganisasjonDTO.java @@ -20,6 +20,7 @@ public class OrganisasjonDTO { public static final String NOT_FOUND = "Ikke funnet"; + private final String error; private final String orgnummer; private final String enhetType; private final String navn; @@ -29,17 +30,6 @@ public class OrganisasjonDTO { private final String redigertnavn; private final List driverVirksomheter; - public OrganisasjonDTO(OrganisasjonDTO dto) { - this.orgnummer = dto.getOrgnummer(); - this.enhetType = dto.getEnhetType(); - this.navn = dto.getNavn(); - this.juridiskEnhet = dto.getJuridiskEnhet(); - this.postadresse = dto.getPostadresse(); - this.forretningsadresser = dto.getForretningsadresser(); - this.redigertnavn = dto.getRedigertnavn(); - this.driverVirksomheter = dto.getDriverVirksomheter(); - } - @JsonIgnore public boolean isFunnet() { diff --git a/libs/reactive-proxy/src/main/java/no/nav/testnav/libs/reactiveproxy/config/DevConfig.java b/libs/reactive-proxy/src/main/java/no/nav/testnav/libs/reactiveproxy/config/DevConfig.java index d6b9e8fce29..4a34d70612d 100644 --- a/libs/reactive-proxy/src/main/java/no/nav/testnav/libs/reactiveproxy/config/DevConfig.java +++ b/libs/reactive-proxy/src/main/java/no/nav/testnav/libs/reactiveproxy/config/DevConfig.java @@ -12,7 +12,7 @@ @Configuration @Profile("dev") -@VaultPropertySource(value = "azuread/prod/creds/team-dolly-lokal-app", ignoreSecretNotFound = false) +@VaultPropertySource(value = "secret/dolly/lokal", ignoreSecretNotFound = false) public class DevConfig extends AbstractVaultConfiguration { private static final String VAULT_TOKEN = "spring.cloud.vault.token"; diff --git a/proxies/modapp-ereg-proxy/Dockerfile b/proxies/modapp-ereg-proxy/Dockerfile deleted file mode 100644 index 4a36f93546f..00000000000 --- a/proxies/modapp-ereg-proxy/Dockerfile +++ /dev/null @@ -1,8 +0,0 @@ -FROM ghcr.io/navikt/baseimages/temurin:21 -LABEL maintainer="Team Dolly" - -ENV JAVA_OPTS="-Dspring.profiles.active=prod" - -ADD /build/libs/app.jar /app/app.jar - -EXPOSE 8080 diff --git a/proxies/modapp-ereg-proxy/build.gradle b/proxies/modapp-ereg-proxy/build.gradle deleted file mode 100644 index 329955971cd..00000000000 --- a/proxies/modapp-ereg-proxy/build.gradle +++ /dev/null @@ -1,15 +0,0 @@ -plugins { - id "dolly-proxies" -} - -sonarqube { - properties { - property "sonar.projectKey", "testnav-modapp-ereg-proxy" - property "sonar.projectName", "testnav-modapp-ereg-proxy" - } -} - -dependencies { - implementation 'no.nav.testnav.libs:security-core' - implementation 'no.nav.testnav.libs:reactive-security' -} diff --git a/proxies/modapp-ereg-proxy/config.yml b/proxies/modapp-ereg-proxy/config.yml deleted file mode 100644 index 08e1a2d8f22..00000000000 --- a/proxies/modapp-ereg-proxy/config.yml +++ /dev/null @@ -1,70 +0,0 @@ ---- -apiVersion: nais.io/v1 -kind: AzureAdApplication -metadata: - name: testnav-modapp-ereg-proxy-trygdeetaten - namespace: dolly - labels: - team: dolly -spec: - secretName: azure-trygdeetaten-testnav-modapp-ereg-proxy-trygdeetaten - secretKeyPrefix: "AZURE_TRYGDEETATEN" - tenant: trygdeetaten.no ---- -apiVersion: "nais.io/v1alpha1" -kind: "Application" -metadata: - name: testnav-modapp-ereg-proxy - namespace: dolly - labels: - team: dolly -spec: - image: "{{image}}" - port: 8080 - webproxy: true - tokenx: - enabled: true - azure: - application: - allowAllUsers: true - enabled: true - tenant: nav.no - accessPolicy: - inbound: - rules: - - application: team-dolly-lokal-app - cluster: dev-gcp - - application: testnav-oversikt-frontend - cluster: dev-gcp - - application: ereg-batch-status-service - cluster: dev-gcp - liveness: - path: /internal/isAlive - initialDelay: 4 - periodSeconds: 5 - failureThreshold: 500 - observability: - logging: - destinations: - - id: elastic - autoInstrumentation: - enabled: true - runtime: java - readiness: - path: /internal/isReady - initialDelay: 4 - periodSeconds: 5 - failureThreshold: 500 - replicas: - min: 1 - max: 1 - resources: - requests: - cpu: 200m - memory: 1025Mi - limits: - memory: 2048Mi - envFrom: - - secret: azure-trygdeetaten-testnav-modapp-ereg-proxy-trygdeetaten - ingresses: - - "https://testnav-modapp-ereg-proxy.dev-fss-pub.nais.io" diff --git a/proxies/modapp-ereg-proxy/gradle/wrapper/gradle-wrapper.jar b/proxies/modapp-ereg-proxy/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 7454180f2ae..00000000000 Binary files a/proxies/modapp-ereg-proxy/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/proxies/modapp-ereg-proxy/gradle/wrapper/gradle-wrapper.properties b/proxies/modapp-ereg-proxy/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 48c0a02ca41..00000000000 --- a/proxies/modapp-ereg-proxy/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/proxies/modapp-ereg-proxy/gradlew b/proxies/modapp-ereg-proxy/gradlew deleted file mode 100755 index 3da45c161b0..00000000000 --- a/proxies/modapp-ereg-proxy/gradlew +++ /dev/null @@ -1,234 +0,0 @@ -#!/bin/sh - -# -# Copyright ? 2015-2021 the original authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -############################################################################## -# -# Gradle start up script for POSIX generated by Gradle. -# -# Important for running: -# -# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is -# noncompliant, but you have some other compliant shell such as ksh or -# bash, then to run this script, type that shell name before the whole -# command line, like: -# -# ksh Gradle -# -# Busybox and similar reduced shells will NOT work, because this script -# requires all of these POSIX shell features: -# * functions; -# * expansions ?$var?, ?${var}?, ?${var:-default}?, ?${var+SET}?, -# ?${var#prefix}?, ?${var%suffix}?, and ?$( cmd )?; -# * compound commands having a testable exit status, especially ?case?; -# * various built-in commands including ?command?, ?set?, and ?ulimit?. -# -# Important for patching: -# -# (2) This script targets any POSIX shell, so it avoids extensions provided -# by Bash, Ksh, etc; in particular arrays are avoided. -# -# The "traditional" practice of packing multiple parameters into a -# space-separated string is a well documented source of bugs and security -# problems, so this is (mostly) avoided, by progressively accumulating -# options in "$@", and eventually passing that to Java. -# -# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, -# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; -# see the in-line comments for details. -# -# There are tweaks for specific operating systems such as AIX, CygWin, -# Darwin, MinGW, and NonStop. -# -# (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt -# within the Gradle project. -# -# You can find Gradle at https://github.com/gradle/gradle/. -# -############################################################################## - -# Attempt to set APP_HOME - -# Resolve links: $0 may be a link -app_path=$0 - -# Need this for daisy-chained symlinks. -while - APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path - [ -h "$app_path" ] -do - ls=$( ls -ld "$app_path" ) - link=${ls#*' -> '} - case $link in #( - /*) app_path=$link ;; #( - *) app_path=$APP_HOME$link ;; - esac -done - -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" -APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD=maximum - -warn () { - echo "$*" -} >&2 - -die () { - echo - echo "$*" - echo - exit 1 -} >&2 - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "$( uname )" in #( - CYGWIN* ) cygwin=true ;; #( - Darwin* ) darwin=true ;; #( - MSYS* | MINGW* ) msys=true ;; #( - NONSTOP* ) nonstop=true ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD=$JAVA_HOME/jre/sh/java - else - JAVACMD=$JAVA_HOME/bin/java - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then - case $MAX_FD in #( - max*) - MAX_FD=$( ulimit -H -n ) || - warn "Could not query maximum file descriptor limit" - esac - case $MAX_FD in #( - '' | soft) :;; #( - *) - ulimit -n "$MAX_FD" || - warn "Could not set maximum file descriptor limit to $MAX_FD" - esac -fi - -# Collect all arguments for the java command, stacking in reverse order: -# * args from the command line -# * the main class name -# * -classpath -# * -D...appname settings -# * --module-path (only if needed) -# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. - -# For Cygwin or MSYS, switch paths to Windows format before running java -if "$cygwin" || "$msys" ; then - APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) - - JAVACMD=$( cygpath --unix "$JAVACMD" ) - - # Now convert the arguments - kludge to limit ourselves to /bin/sh - for arg do - if - case $arg in #( - -*) false ;; # don't mess with options #( - /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath - [ -e "$t" ] ;; #( - *) false ;; - esac - then - arg=$( cygpath --path --ignore --mixed "$arg" ) - fi - # Roll the args list around exactly as many times as the number of - # args, so each arg winds up back in the position where it started, but - # possibly modified. - # - # NB: a `for` loop captures its iteration list before it begins, so - # changing the positional parameters here affects neither the number of - # iterations, nor the values presented in `arg`. - shift # remove old arg - set -- "$@" "$arg" # push replacement arg - done -fi - -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. - -set -- \ - "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ - "$@" - -# Use "xargs" to parse quoted args. -# -# With -n1 it outputs one arg per line, with the quotes and backslashes removed. -# -# In Bash we could simply go: -# -# readarray ARGS < <( xargs -n1 <<<"$var" ) && -# set -- "${ARGS[@]}" "$@" -# -# but POSIX shell has neither arrays nor command substitution, so instead we -# post-process each arg (as a line of input to sed) to backslash-escape any -# character that might be a shell metacharacter, then use eval to reverse -# that process (while maintaining the separation between arguments), and wrap -# the whole thing up as a single "set" statement. -# -# This will of course break if any of these variables contains a newline or -# an unmatched quote. -# - -eval "set -- $( - printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | - xargs -n1 | - sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | - tr '\n' ' ' - )" '"$@"' - -exec "$JAVACMD" "$@" diff --git a/proxies/modapp-ereg-proxy/gradlew.bat b/proxies/modapp-ereg-proxy/gradlew.bat deleted file mode 100644 index 107acd32c4e..00000000000 --- a/proxies/modapp-ereg-proxy/gradlew.bat +++ /dev/null @@ -1,89 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/proxies/modapp-ereg-proxy/gradlewUpdate.sh b/proxies/modapp-ereg-proxy/gradlewUpdate.sh deleted file mode 100755 index e5ee6361152..00000000000 --- a/proxies/modapp-ereg-proxy/gradlewUpdate.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -gradle wrapper \ No newline at end of file diff --git a/proxies/modapp-ereg-proxy/settings.gradle b/proxies/modapp-ereg-proxy/settings.gradle deleted file mode 100644 index 0cbbadb0020..00000000000 --- a/proxies/modapp-ereg-proxy/settings.gradle +++ /dev/null @@ -1,19 +0,0 @@ -plugins { - id "com.gradle.develocity" version "3.17.4" -} - -rootProject.name = 'modapp-ereg-proxy' - -includeBuild "../../plugins/java" - -includeBuild '../../libs/reactive-core' -includeBuild '../../libs/reactive-proxy' -includeBuild '../../libs/reactive-security' -includeBuild '../../libs/security-core' - -develocity { - buildScan { - termsOfUseUrl = "https://gradle.com/terms-of-service" - termsOfUseAgree = "yes" - } -} diff --git a/proxies/modapp-ereg-proxy/src/main/java/no/nav/testnav/proxies/modapperegproxy/Consumers.java b/proxies/modapp-ereg-proxy/src/main/java/no/nav/testnav/proxies/modapperegproxy/Consumers.java deleted file mode 100644 index 32e25c534b9..00000000000 --- a/proxies/modapp-ereg-proxy/src/main/java/no/nav/testnav/proxies/modapperegproxy/Consumers.java +++ /dev/null @@ -1,29 +0,0 @@ -package no.nav.testnav.proxies.modapperegproxy; - -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import no.nav.testnav.libs.securitycore.domain.ServerProperties; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Configuration; - -import static lombok.AccessLevel.PACKAGE; - -/** - * Samler alle placeholders for ulike {@code consumers.*}-konfigurasjon her, dvs. subklasser av {@code ServerProperties}. - *

- * Husk at Spring Boot bruker relaxed binding - * mellom configuration properties og field names. - * - * @see ServerProperties - */ -@Configuration -@ConfigurationProperties(prefix = "consumers") -@NoArgsConstructor(access = PACKAGE) -@Getter -@Setter(PACKAGE) -public class Consumers { - - private ServerProperties eregAura; - -} diff --git a/proxies/modapp-ereg-proxy/src/main/java/no/nav/testnav/proxies/modapperegproxy/ModappEregProxyApplicationStarter.java b/proxies/modapp-ereg-proxy/src/main/java/no/nav/testnav/proxies/modapperegproxy/ModappEregProxyApplicationStarter.java deleted file mode 100644 index 4e3b05118bd..00000000000 --- a/proxies/modapp-ereg-proxy/src/main/java/no/nav/testnav/proxies/modapperegproxy/ModappEregProxyApplicationStarter.java +++ /dev/null @@ -1,73 +0,0 @@ -package no.nav.testnav.proxies.modapperegproxy; - -import no.nav.testnav.libs.reactivecore.config.CoreConfig; -import no.nav.testnav.libs.reactiveproxy.config.DevConfig; -import no.nav.testnav.libs.reactiveproxy.config.SecurityConfig; -import no.nav.testnav.libs.securitycore.domain.ServerProperties; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.cloud.gateway.route.Route; -import org.springframework.cloud.gateway.route.RouteLocator; -import org.springframework.cloud.gateway.route.builder.Buildable; -import org.springframework.cloud.gateway.route.builder.PredicateSpec; -import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Import; - -import java.util.Arrays; -import java.util.Map; -import java.util.function.Function; - -@Import({ - CoreConfig.class, - DevConfig.class, - SecurityConfig.class -}) -@SpringBootApplication -public class ModappEregProxyApplicationStarter { - - private static final String[] miljoer = new String[]{ "q1", "q2", "q4" }; - private static final Map miljoeUrlSegment = Map.of( - "q1", "05", - "q2", "10", - "q4", "09" - ); - - @Bean - public RouteLocator customRouteLocator( - RouteLocatorBuilder builder, - Consumers consumers - ) { - var routes = builder.routes(); - Arrays - .asList(miljoer) - .forEach( - miljoe -> { - var properties = forEnvironment(consumers.getEregAura(), miljoeUrlSegment.get(miljoe)); - routes - .route(createRoute(miljoe, properties.getUrl())); - }); - return routes.build(); - } - - public static void main(String[] args) { - SpringApplication.run(ModappEregProxyApplicationStarter.class, args); - } - - private Function> createRoute(String miljo, String url) { - return spec -> spec - .path("/" + miljo + "/**") - .filters(filterSpec -> filterSpec - .rewritePath("/" + miljo + "/(?.*)", "/${segment}") - ).uri(url); - } - - private static ServerProperties forEnvironment(ServerProperties original, String urlSegment) { - return ServerProperties.of( - original.getCluster(), - original.getNamespace(), - original.getName(), - original.getUrl().replace("-MILJOE", urlSegment) - ); - } -} \ No newline at end of file diff --git a/proxies/modapp-ereg-proxy/src/main/resources/application.yml b/proxies/modapp-ereg-proxy/src/main/resources/application.yml deleted file mode 100644 index 4842e668d2b..00000000000 --- a/proxies/modapp-ereg-proxy/src/main/resources/application.yml +++ /dev/null @@ -1,30 +0,0 @@ -AAD_ISSUER_URI: https://login.microsoftonline.com/62366534-1ec3-4962-8869-9b5535279d0b - -spring: - application: - name: testnav-modapp-ereg-proxy - desciption: Proxy for ereg appen i modapp som legger på sikkerhet og redirecter til riktig miljø. - security: - oauth2: - resourceserver: - aad: - issuer-uri: ${AAD_ISSUER_URI}/v2.0 - jwk-set-uri: ${AAD_ISSUER_URI}/discovery/v2.0/keys - accepted-audience: ${azure.app.client.id}, api://${azure.app.client.id} - tokenx: - issuer-uri: ${TOKEN_X_ISSUER} - jwk-set-uri: ${TOKEN_X_JWKS_URI} - accepted-audience: ${TOKEN_X_CLIENT_ID} - cloud: - gateway: - httpclient: - response-timeout: 1200s - vault: - enabled: false - -consumers: - ereg-aura: - name: ereg-aura - namespace: arbeidsforhold - url: https://b27jbsl016-MILJOE.preprod.local:8443 - cluster: dev-fss \ No newline at end of file diff --git a/proxies/modapp-ereg-proxy/src/main/resources/logback-spring.xml b/proxies/modapp-ereg-proxy/src/main/resources/logback-spring.xml deleted file mode 100644 index f874dcc44c1..00000000000 --- a/proxies/modapp-ereg-proxy/src/main/resources/logback-spring.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - true - - 10280 - 20 - ^sun\.reflect\..*\.invoke - ^net\.sf\.cglib\.proxy\.MethodProxy\.invoke - java\.util\.concurrent\..* - org\.apache\.catalina\..* - org\.apache\.coyote\..* - org\.apache\.tomcat\..* - - - - - - - - - - - - - %d{HH:mm:ss.SSS} | %5p | %logger{25} | %m%n - - utf8 - - - - - - - - - \ No newline at end of file diff --git a/proxies/modapp-ereg-proxy/src/test/java/no/nav/testnav/proxies/modapperegproxy/ApplicationContextTest.java b/proxies/modapp-ereg-proxy/src/test/java/no/nav/testnav/proxies/modapperegproxy/ApplicationContextTest.java deleted file mode 100644 index 315981c5591..00000000000 --- a/proxies/modapp-ereg-proxy/src/test/java/no/nav/testnav/proxies/modapperegproxy/ApplicationContextTest.java +++ /dev/null @@ -1,20 +0,0 @@ -package no.nav.testnav.proxies.modapperegproxy; - -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.oauth2.jwt.ReactiveJwtDecoder; -import org.springframework.test.context.ActiveProfiles; - -@SpringBootTest -@ActiveProfiles("test") -class ApplicationContextTest { - - @MockBean - public ReactiveJwtDecoder reactiveJwtDecoder; - - @Test - @SuppressWarnings("java:S2699") - void load_app_context() { - } -} diff --git a/proxies/modapp-ereg-proxy/src/test/resources/application-test.yml b/proxies/modapp-ereg-proxy/src/test/resources/application-test.yml deleted file mode 100644 index 905697c5bae..00000000000 --- a/proxies/modapp-ereg-proxy/src/test/resources/application-test.yml +++ /dev/null @@ -1,11 +0,0 @@ -TOKEN_X_ISSUER: dummy -consumers: - ereg-aura: - url: http://ereg-dummy.dummy.no - cluster: dev-fss - name: ereg-dummy - namespace: dummy -spring: - cloud: - vault: - enabled: false diff --git a/settings.gradle b/settings.gradle index ed26ca80832..8f4dc8b37e0 100644 --- a/settings.gradle +++ b/settings.gradle @@ -37,7 +37,6 @@ includeBuild './proxies/inst-proxy' includeBuild './proxies/kontoregister-person-proxy' includeBuild './proxies/krrstub-proxy' includeBuild './proxies/medl-proxy' -includeBuild './proxies/modapp-ereg-proxy' includeBuild './proxies/norg2-proxy' includeBuild './proxies/pdl-proxy' includeBuild './proxies/pensjon-testdata-facade-proxy' @@ -84,7 +83,6 @@ includeBuild './apps/dolly-frontend' includeBuild './apps/dollystatus' includeBuild './apps/endringsmelding-frontend' includeBuild './apps/endringsmelding-service' -includeBuild './apps/ereg-batch-status-service' includeBuild './apps/faste-data-frontend' includeBuild './apps/generer-arbeidsforhold-populasjon-service' includeBuild './apps/generer-navn-service'