Skip to content

Commit

Permalink
Merge branch 'master' into bugfix/endringsmelding-404
Browse files Browse the repository at this point in the history
# Conflicts:
#	apps/endringsmelding-service/src/main/java/no/nav/testnav/endringsmeldingservice/consumer/TpsMessagingConsumer.java
  • Loading branch information
stigus committed Mar 21, 2024
2 parents 2c5f1ab + d48b5e0 commit 7bb7c55
Show file tree
Hide file tree
Showing 325 changed files with 6,459 additions and 1,933 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/app.ereg-batch-status-service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
workflow:
uses: ./.github/workflows/common.workflow.backend.yml
with:
cluster: "dev-fss"
cluster: "dev-gcp"
working-directory: "apps/ereg-batch-status-service"
deploy-tag: "#deploy-ereg-batch-status-service"
permissions:
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/proxy.modapp-ereg-proxy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: modapp-ereg-proxy

on:
push:
paths:
- 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*.idea/
*target/
*.iml
*.http

# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

Expand Down
2 changes: 2 additions & 0 deletions apps/adresse-service/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ spec:
- application: app-1
namespace: plattformsikkerhet
cluster: dev-gcp
- application: testnav-endringsmelding-service
cluster: dev-gcp
outbound:
external:
- host: testnav-pdl-proxy.dev-fss-pub.nais.io
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ public static void main(String[] args) {

SpringApplication.run(DollyBackendApplicationStarter.class, args);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public Flux<ClientFuture> gjenopprett(RsDollyUtvidetBestilling bestilling, Dolly
var initStatus = miljoer.stream()
.map(miljo -> String.format("%s:%s", miljo, getInfoVenter(SYSTEM)))
.collect(Collectors.joining(","));

transactionHelperService.persister(progress, BestillingProgress::getAaregStatus,
BestillingProgress::setAaregStatus, initStatus);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import no.nav.testnav.libs.dto.ameldingservice.v1.VirksomhetDTO;
import no.nav.testnav.libs.securitycore.domain.ServerProperties;
import no.nav.testnav.libs.standalone.servletsecurity.exchange.TokenExchange;
import org.slf4j.event.Level;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import org.springframework.web.reactive.function.client.WebClient;
Expand All @@ -30,7 +31,6 @@ public class AmeldingConsumer {

private static final String JURIDISK_ENHET_IKKE_FUNNET = "Feil= Juridisk enhet for organisasjon(ene): %s ble ikke funnet i miljø";
private static final DateTimeFormatter YEAR_MONTH = DateTimeFormatter.ofPattern("yyyy-MM");

private final TokenExchange tokenService;
private final WebClient webClient;
private final ServerProperties serverProperties;
Expand All @@ -41,8 +41,8 @@ public AmeldingConsumer(
Consumers consumers,
ObjectMapper objectMapper,
ErrorStatusDecoder errorStatusDecoder,
WebClient.Builder webClientBuilder
) {
WebClient.Builder webClientBuilder) {

this.tokenService = tokenService;
serverProperties = consumers.getTestnavAmeldingService();
this.webClient = webClientBuilder
Expand All @@ -52,7 +52,7 @@ public AmeldingConsumer(
this.errorStatusDecoder = errorStatusDecoder;
}

@Timed(name = "providers", tags = { "operation", "amelding_put" })
@Timed(name = "providers", tags = {"operation", "amelding_put"})
public Flux<String> sendAmeldinger(List<AMeldingDTO> ameldinger, String miljoe) {

return tokenService.exchange(serverProperties)
Expand All @@ -67,9 +67,13 @@ public Flux<String> sendAmeldinger(List<AMeldingDTO> ameldinger, String miljoe)
log.info("Sender Amelding {} til miljø {}: {}",
amelding.getKalendermaaned().format(YEAR_MONTH), miljoe, Json.pretty(amelding));
return new AmeldingPutCommand(webClient, amelding, miljoe, token.getTokenValue()).call()
.doOnNext(status -> log.info("Ameldingstatus: {}", status.getStatusCode()))
.map(status -> status.getStatusCode().is2xxSuccessful() ? "OK" :
errorStatusDecoder.getErrorText(HttpStatus.valueOf(status.getStatusCode().value()), status.getBody()));
errorStatusDecoder.getErrorText(HttpStatus.valueOf(status.getStatusCode().value()), status.getBody()))
.doOnNext(status ->
log.atLevel("OK".equals(status) ? Level.INFO : Level.ERROR)
.log("Ameldingstatus: {}, miljoe: {}, kalendermåned: {}, organisasjon: {}",
status, miljoe, amelding.getKalendermaaned(),
amelding.getOpplysningspliktigOrganisajonsnummer()));
}
}));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import reactor.core.publisher.Mono;

import java.util.Collection;
import java.util.Comparator;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
Expand All @@ -25,7 +26,7 @@
@Slf4j
public class AmeldingService {

private static final String STATUS_ELEMENT = "%s: arbforhold=1$%s";
private static final String STATUS_ELEMENT = "%s:Amelding$%s";

private final AmeldingConsumer ameldingConsumer;
private final MapperFacade mapperFacade;
Expand All @@ -34,7 +35,7 @@ public class AmeldingService {
public Mono<String> sendAmelding(RsDollyUtvidetBestilling bestilling, DollyPerson dollyPerson,
Set<String> miljoer) {

var orgnumre = bestilling.getAareg().get(0).getAmelding().stream()
var orgnumre = bestilling.getAareg().getFirst().getAmelding().stream()
.map(RsAmeldingRequest::getArbeidsforhold)
.flatMap(Collection::stream)
.map(RsArbeidsforholdAareg::getArbeidsgiver)
Expand All @@ -46,14 +47,15 @@ public Mono<String> sendAmelding(RsDollyUtvidetBestilling bestilling, DollyPerso
.filter(OrganisasjonDTO::isFunnet)
.collect(Collectors.toMap(OrganisasjonDTO::getOrgnummer, OrganisasjonDTO::getJuridiskEnhet))
.flatMapMany(organisasjon ->
prepareAmeldinger(bestilling.getAareg().get(0), dollyPerson.getIdent(),
prepareAmeldinger(bestilling.getAareg().getFirst(), dollyPerson.getIdent(),
organisasjon, miljoe))
.collect(Collectors.joining(",")))
.flatMap(Flux::from)
.collect(Collectors.joining(","));
}

private Flux<String> prepareAmeldinger(RsAareg aareg, String ident, Map<String, String> organisasjon, String miljoe) {
private Flux<String> prepareAmeldinger(RsAareg aareg, String ident, Map<String, String> organisasjon,
String miljoe) {

var context = new MappingContext.Factory().getContext();
context.setProperty("personIdent", ident);
Expand All @@ -62,9 +64,10 @@ private Flux<String> prepareAmeldinger(RsAareg aareg, String ident, Map<String,

return Flux.fromIterable(aareg.getAmelding())
.map(aamelding -> mapperFacade.map(aamelding, AMeldingDTO.class, context))
.sort(Comparator.comparing(AMeldingDTO::getKalendermaaned))
.collectList()
.flatMapMany(reultat -> ameldingConsumer.sendAmeldinger(reultat, miljoe)
.flatMapMany(ameldinger -> ameldingConsumer.sendAmeldinger(ameldinger, miljoe)
.distinct()
.map(status -> String.format(STATUS_ELEMENT, miljoe, status)));
.map(status -> STATUS_ELEMENT.formatted(miljoe, status)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
Expand Down Expand Up @@ -54,16 +55,21 @@ public void mapAtoB(RsAmeldingRequest rsAmelding,
amelding.setKalendermaaned(LocalDate.of(Integer.parseInt(date[0]), Integer.parseInt(date[1]), 1));
var opplysningsPliktig = (Map<String, String>) context.getProperty("opplysningspliktig");

amelding.setOpplysningspliktigOrganisajonsnummer(opplysningsPliktig.get(rsAmelding.getArbeidsforhold().get(0).getArbeidsgiver().getOrgnummer()));
amelding.setOpplysningspliktigOrganisajonsnummer(opplysningsPliktig.get(rsAmelding.getArbeidsforhold()
.getFirst().getArbeidsgiver().getOrgnummer()));

var virksomheter = mapperFacade.mapAsList(rsAmelding.getArbeidsforhold(), Virksomhet.class, context);
virksomheter.forEach(virksomhet -> {
var arbForholdId = new AtomicInteger(0);
virksomhet.getPersoner()
.forEach(person -> person.getArbeidsforhold()
.forEach(arbeidsforhold -> arbeidsforhold
.setArbeidsforholdId(Integer.toString(arbForholdId.incrementAndGet()))));
});
var arbeidsForholdIder = new HashMap<String, AtomicInteger>();
virksomheter
.forEach(virksomhet -> virksomhet.getPersoner().forEach(person ->
arbeidsForholdIder.put(virksomhet.getOrganisajonsnummer()+person.getIdent(),
new AtomicInteger(0))));
virksomheter.forEach(virksomhet -> virksomhet.getPersoner()
.forEach(person -> person.getArbeidsforhold()
.forEach(arbeidsforhold -> arbeidsforhold
.setArbeidsforholdId(Integer.toString(
arbeidsForholdIder.get(virksomhet.getOrganisajonsnummer()+person.getIdent())
.incrementAndGet())))));
var ameldingVirksomheter = virksomheter.stream().map(virksomhet ->
VirksomhetDTO.builder()
.organisajonsnummer(virksomhet.getOrganisajonsnummer())
Expand Down Expand Up @@ -94,12 +100,14 @@ public void mapAtoB(RsArbeidsforholdAareg rsArbeidsforholdAareg, Virksomhet virk
getDate(rsArbeidsforholdAareg.getAnsettelsesPeriode().getTom()) : null)
.antallTimerPerUke(
!rsArbeidsforholdAareg.getAntallTimerForTimeloennet().isEmpty() ?
rsArbeidsforholdAareg.getAntallTimerForTimeloennet().get(0).getAntallTimer().floatValue() :
rsArbeidsforholdAareg.getAntallTimerForTimeloennet()
.getFirst().getAntallTimer().floatValue() :
getAvtaltArbeidstidPerUke(rsArbeidsforholdAareg))
.arbeidsforholdType((String) context.getProperty("arbeidsforholdstype"))
.arbeidstidsordning(rsArbeidsforholdAareg.getArbeidsavtale().getArbeidstidsordning())
.fartoey(nonNull(rsArbeidsforholdAareg.getFartoy()) && !rsArbeidsforholdAareg.getFartoy().isEmpty() ?
mapperFacade.map(rsArbeidsforholdAareg.getFartoy().get(0), FartoeyDTO.class) : null)
mapperFacade.map(rsArbeidsforholdAareg.getFartoy()
.getFirst(), FartoeyDTO.class) : null)
.inntekter(
(nonNull(rsArbeidsforholdAareg.getUtenlandsopphold()) &&
!rsArbeidsforholdAareg.getUtenlandsopphold().isEmpty()) ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@
import org.springframework.http.ResponseEntity;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Mono;
import reactor.netty.http.client.HttpClientRequest;
import reactor.util.retry.Retry;

import java.time.Duration;
import java.util.concurrent.Callable;

import static no.nav.dolly.util.RequestTimeout.REQUEST_DURATION;

@RequiredArgsConstructor
public class AmeldingPutCommand implements Callable<Mono<ResponseEntity<String>>> {

Expand All @@ -31,6 +34,10 @@ public Mono<ResponseEntity<String>> call() {
return webClient.put()
.uri(uriBuilder -> uriBuilder.path(AMELDING_URL)
.build())
.httpRequest(httpRequest -> {
HttpClientRequest reactorRequest = httpRequest.getNativeRequest();
reactorRequest.responseTimeout(Duration.ofSeconds(REQUEST_DURATION));
})
.header(HttpHeaders.AUTHORIZATION, "Bearer " + token)
.header(UserConstant.USER_HEADER_JWT, TokenXUtil.getUserJwt())
.header(MILJOE, miljo)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@
import org.springframework.web.reactive.function.BodyInserters;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Flux;
import reactor.netty.http.client.HttpClientRequest;
import reactor.util.retry.Retry;

import java.net.http.HttpTimeoutException;
import java.time.Duration;
import java.util.concurrent.Callable;

import static no.nav.dolly.util.RequestTimeout.REQUEST_DURATION;
import static no.nav.dolly.util.TokenXUtil.getUserJwt;

@Slf4j
Expand All @@ -37,6 +39,10 @@ public Flux<PdlResponse> call() {
return webClient
.put()
.uri(PDL_FORVALTER_PERSONER_URL, ident)
.httpRequest(httpRequest -> {
HttpClientRequest reactorRequest = httpRequest.getNativeRequest();
reactorRequest.responseTimeout(Duration.ofSeconds(REQUEST_DURATION));
})
.header(HttpHeaders.AUTHORIZATION, "Bearer " + token)
.header(UserConstant.USER_HEADER_JWT, getUserJwt())
.contentType(MediaType.APPLICATION_JSON)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@
import org.springframework.web.reactive.function.BodyInserters;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Flux;
import reactor.netty.http.client.HttpClientRequest;
import reactor.util.retry.Retry;

import java.net.http.HttpTimeoutException;
import java.time.Duration;
import java.util.concurrent.Callable;

import static no.nav.dolly.util.RequestTimeout.REQUEST_DURATION;
import static no.nav.dolly.util.TokenXUtil.getUserJwt;

@Slf4j
Expand All @@ -36,6 +38,10 @@ public Flux<PdlResponse> call() {
return webClient
.post()
.uri(PDL_FORVALTER_PERSONER_URL)
.httpRequest(httpRequest -> {
HttpClientRequest reactorRequest = httpRequest.getNativeRequest();
reactorRequest.responseTimeout(Duration.ofSeconds(REQUEST_DURATION));
})
.header(HttpHeaders.AUTHORIZATION, "Bearer " + token)
.header(UserConstant.USER_HEADER_JWT, getUserJwt())
.contentType(MediaType.APPLICATION_JSON)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@
import org.springframework.http.MediaType;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Flux;
import reactor.netty.http.client.HttpClientRequest;
import reactor.util.retry.Retry;

import java.net.http.HttpTimeoutException;
import java.time.Duration;
import java.util.concurrent.Callable;

import static no.nav.dolly.util.RequestTimeout.REQUEST_DURATION;
import static no.nav.dolly.util.TokenXUtil.getUserJwt;

@RequiredArgsConstructor
Expand All @@ -36,6 +38,10 @@ public Flux<PdlResponse> call() {
.uri(uriBuilder -> uriBuilder.path(PDL_FORVALTER_ORDRE_URL)
.queryParam(EXCLUDE_EKSTERNE_PERSONER, ekskluderEksternePersoner)
.build(ident))
.httpRequest(httpRequest -> {
HttpClientRequest reactorRequest = httpRequest.getNativeRequest();
reactorRequest.responseTimeout(Duration.ofSeconds(REQUEST_DURATION));
})
.header(HttpHeaders.AUTHORIZATION, "Bearer " + token)
.header(UserConstant.USER_HEADER_JWT, getUserJwt())
.contentType(MediaType.APPLICATION_JSON)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.netty.http.client.HttpClientRequest;
import reactor.util.retry.Retry;

import java.time.Duration;
Expand All @@ -18,6 +19,7 @@
import static no.nav.dolly.domain.CommonKeysAndUtils.HEADER_NAV_CALL_ID;
import static no.nav.dolly.domain.CommonKeysAndUtils.HEADER_NAV_CONSUMER_ID;
import static no.nav.dolly.util.CallIdUtil.generateCallId;
import static no.nav.dolly.util.RequestTimeout.REQUEST_DURATION;
import static org.springframework.http.HttpHeaders.AUTHORIZATION;

@Slf4j
Expand All @@ -40,6 +42,10 @@ public Flux<PensjonforvalterResponse> call() {
.path(alderspensjonRequest instanceof AlderspensjonVedtakRequest ?
PENSJON_AP_VEDTAK_URL : PENSJON_AP_SOKNAD_URL)
.build())
.httpRequest(httpRequest -> {
HttpClientRequest reactorRequest = httpRequest.getNativeRequest();
reactorRequest.responseTimeout(Duration.ofSeconds(REQUEST_DURATION));
})
.header(AUTHORIZATION, "Bearer " + token)
.header(HEADER_NAV_CALL_ID, generateCallId())
.header(HEADER_NAV_CONSUMER_ID, CONSUMER)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.netty.http.client.HttpClientRequest;
import reactor.util.retry.Retry;

import java.time.Duration;
Expand All @@ -17,6 +18,7 @@
import static no.nav.dolly.domain.CommonKeysAndUtils.HEADER_NAV_CALL_ID;
import static no.nav.dolly.domain.CommonKeysAndUtils.HEADER_NAV_CONSUMER_ID;
import static no.nav.dolly.util.CallIdUtil.generateCallId;
import static no.nav.dolly.util.RequestTimeout.REQUEST_DURATION;
import static org.springframework.http.HttpHeaders.AUTHORIZATION;

@Slf4j
Expand All @@ -35,6 +37,10 @@ public Flux<PensjonforvalterResponse> call() {
.uri(uriBuilder -> uriBuilder
.path(POPP_INNTEKT_URL)
.build())
.httpRequest(httpRequest -> {
HttpClientRequest reactorRequest = httpRequest.getNativeRequest();
reactorRequest.responseTimeout(Duration.ofSeconds(REQUEST_DURATION));
})
.header(AUTHORIZATION, "Bearer " + token)
.header(HEADER_NAV_CALL_ID, generateCallId())
.header(HEADER_NAV_CONSUMER_ID, CONSUMER)
Expand Down
Loading

0 comments on commit 7bb7c55

Please sign in to comment.