Skip to content

Commit

Permalink
Merge branch 'master' into change/common_testing_internal
Browse files Browse the repository at this point in the history
  • Loading branch information
rfc3092 committed Feb 21, 2025
2 parents a9cb754 + f5ff6f5 commit 4c83003
Show file tree
Hide file tree
Showing 34 changed files with 808 additions and 473 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,12 @@ private Flux<String> getErrors(Set<String> miljoer, Throwable throwable) {
@Override
public void release(List<String> identer) {

// Pensjonforvalter / POPP, AP, UT støtter pt ikke sletting
// Pensjonforvalter AP, UT støtter pt ikke sletting

pensjonforvalterConsumer.sletteTpForhold(identer);
pensjonforvalterConsumer.slettePensjonsavtale(identer);
pensjonforvalterConsumer.sletteAfpOffentlig(identer);
pensjonforvalterConsumer.slettePoppinntekt(identer);
}

private String prepInitStatus(Set<String> miljoer) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package no.nav.dolly.bestilling.pensjonforvalter;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.sun.jna.Function;
import lombok.extern.slf4j.Slf4j;
import no.nav.dolly.bestilling.ConsumerStatus;
import no.nav.dolly.bestilling.pensjonforvalter.command.AnnullerSamboerCommand;
Expand All @@ -19,6 +20,7 @@
import no.nav.dolly.bestilling.pensjonforvalter.command.PensjonHentVedtakCommand;
import no.nav.dolly.bestilling.pensjonforvalter.command.SletteAfpOffentligCommand;
import no.nav.dolly.bestilling.pensjonforvalter.command.SlettePensjonsavtaleCommand;
import no.nav.dolly.bestilling.pensjonforvalter.command.SlettePoppInntektCommand;
import no.nav.dolly.bestilling.pensjonforvalter.command.SletteTpForholdCommand;
import no.nav.dolly.bestilling.pensjonforvalter.domain.AfpOffentligRequest;
import no.nav.dolly.bestilling.pensjonforvalter.domain.AlderspensjonRequest;
Expand Down Expand Up @@ -69,30 +71,30 @@ public PensjonforvalterConsumer(
.build();
}

@Timed(name = "providers", tags = { "operation", "pen_getMiljoer" })
@Timed(name = "providers", tags = {"operation", "pen_getMiljoer"})
public Mono<Set<String>> getMiljoer() {

return tokenService.exchange(serverProperties)
.flatMap(token -> new HentMiljoerCommand(webClient, token.getTokenValue()).call());
}

@Timed(name = "providers", tags = { "operation", "popp_lagreInntekt" })
@Timed(name = "providers", tags = {"operation", "popp_lagreInntekt"})
public Flux<PensjonforvalterResponse> lagreInntekter(PensjonPoppInntektRequest pensjonPoppInntektRequest) {

return tokenService.exchange(serverProperties)
.flatMapMany(token -> new LagrePoppInntektCommand(webClient, token.getTokenValue(),
pensjonPoppInntektRequest).call());
}

@Timed(name = "providers", tags = { "operation", "popp_lagreGenerertInntekt" })
@Timed(name = "providers", tags = {"operation", "popp_lagreGenerertInntekt"})
public Flux<PensjonforvalterResponse> lagreGenererteInntekter(PensjonPoppGenerertInntektRequest pensjonPoppGenerertInntektRequest) {

return tokenService.exchange(serverProperties)
.flatMapMany(token -> new LagreGenerertPoppInntektCommand(webClient, token.getTokenValue(),
pensjonPoppGenerertInntektRequest).call());
}

@Timed(name = "providers", tags = { "operation", "pen_opprettPerson" })
@Timed(name = "providers", tags = {"operation", "pen_opprettPerson"})
public Flux<PensjonforvalterResponse> opprettPerson(PensjonPersonRequest pensjonPersonRequest,
Set<String> miljoer) {

Expand All @@ -102,15 +104,15 @@ public Flux<PensjonforvalterResponse> opprettPerson(PensjonPersonRequest pensjon
.doOnNext(response -> log.info("Opprettet person for {}: {}", pensjonPersonRequest.getFnr(), response));
}

@Timed(name = "providers", tags = { "operation", "pen_hentSamboer" })
@Timed(name = "providers", tags = {"operation", "pen_hentSamboer"})
public Flux<PensjonSamboerResponse> hentSamboer(String ident, String miljoe) {

return tokenService.exchange(serverProperties)
.flatMapMany(token -> new HentSamboerCommand(webClient, ident, miljoe, token.getTokenValue()).call())
.doOnNext(response -> log.info("Pensjon samboer for {} i {} hentet {}", ident, miljoe, response));
}

@Timed(name = "providers", tags = { "operation", "pen_opprettSamboer" })
@Timed(name = "providers", tags = {"operation", "pen_opprettSamboer"})
public Flux<PensjonforvalterResponse> lagreSamboer(PensjonSamboerRequest pensjonSamboerRequest,
String miljoe) {
log.info("Oppretter samboerskap i pensjon: {}", pensjonSamboerRequest);
Expand All @@ -119,36 +121,36 @@ public Flux<PensjonforvalterResponse> lagreSamboer(PensjonSamboerRequest pensjon
.flatMapMany(token -> new LagreSamboerCommand(webClient, pensjonSamboerRequest, miljoe, token.getTokenValue()).call());
}

@Timed(name = "providers", tags = { "operation", "pen_opprettSamboer" })
@Timed(name = "providers", tags = {"operation", "pen_opprettSamboer"})
public Flux<PensjonforvalterResponse> annullerSamboer(String periodeId, String miljoe) {

return tokenService.exchange(serverProperties)
.flatMapMany(token -> new AnnullerSamboerCommand(webClient, periodeId, miljoe, token.getTokenValue()).call());
}

@Timed(name = "providers", tags = { "operation", "pen_lagreAlderspensjon" })
@Timed(name = "providers", tags = {"operation", "pen_lagreAlderspensjon"})
public Flux<PensjonforvalterResponse> lagreAlderspensjon(AlderspensjonRequest request) {

return tokenService.exchange(serverProperties)
.flatMapMany(token ->
new LagreAlderspensjonCommand(webClient, token.getTokenValue(), request).call());
}

@Timed(name = "providers", tags = { "operation", "pen_lagreUforetrygd" })
@Timed(name = "providers", tags = {"operation", "pen_lagreUforetrygd"})
public Flux<PensjonforvalterResponse> lagreUforetrygd(PensjonUforetrygdRequest request) {

return tokenService.exchange(serverProperties)
.flatMapMany(token -> new LagreUforetrygdCommand(webClient, token.getTokenValue(), request).call());
}

@Timed(name = "providers", tags = { "operation", "pen_lagreTpForhold" })
@Timed(name = "providers", tags = {"operation", "pen_lagreTpForhold"})
public Flux<PensjonforvalterResponse> lagreTpForhold(PensjonTpForholdRequest pensjonTpForholdRequest) {

return tokenService.exchange(serverProperties)
.flatMapMany(token -> new LagreTpForholdCommand(webClient, token.getTokenValue(), pensjonTpForholdRequest).call());
}

@Timed(name = "providers", tags = { "operation", "pen_sletteTpForhold" })
@Timed(name = "providers", tags = {"operation", "pen_sletteTpForhold"})
public void sletteTpForhold(List<String> identer) {

tokenService.exchange(serverProperties)
Expand All @@ -160,21 +162,21 @@ public void sletteTpForhold(List<String> identer) {
.subscribe(response -> log.info("Slettet mot PESYS (tp) i alle miljoer"));
}

@Timed(name = "providers", tags = { "operation", "pen_lagreTpYtelse" })
@Timed(name = "providers", tags = {"operation", "pen_lagreTpYtelse"})
public Flux<PensjonforvalterResponse> lagreTpYtelse(PensjonTpYtelseRequest pensjonTpYtelseRequest) {

return tokenService.exchange(serverProperties)
.flatMapMany(token -> new LagreTpYtelseCommand(webClient, token.getTokenValue(), pensjonTpYtelseRequest).call());
}

@Timed(name = "providers", tags = { "operation", "pen_lagrePensjpnsavtale" })
@Timed(name = "providers", tags = {"operation", "pen_lagrePensjpnsavtale"})
public Flux<PensjonforvalterResponse> lagrePensjonsavtale(PensjonsavtaleRequest pensjonsavtaleRequest) {

return tokenService.exchange(serverProperties)
.flatMapMany(token -> new LagrePensjonsavtaleCommand(webClient, pensjonsavtaleRequest, token.getTokenValue()).call());
}

@Timed(name = "providers", tags = { "operation", "pen_slettePensjpnsavtale" })
@Timed(name = "providers", tags = {"operation", "pen_slettePensjpnsavtale"})
public void slettePensjonsavtale(List<String> identer) {

tokenService.exchange(serverProperties)
Expand All @@ -184,7 +186,18 @@ public void slettePensjonsavtale(List<String> identer) {
.subscribe(resultat -> log.info("Slettet pensjonsavtaler (PEN), alle miljøer"));
}

@Timed(name = "providers", tags = { "operation", "pen_hentVedtak" })
@Timed(name = "providers", tags = {"operation", "pen_slettePoppinntekt"})
public void slettePoppinntekt(List<String> identer) {

tokenService.exchange(serverProperties)
.flatMap(token -> Flux.from(new HentMiljoerCommand(webClient, token.getTokenValue()).call())
.flatMap(miljoer -> Flux.fromIterable(identer)
.flatMap(ident -> new SlettePoppInntektCommand(webClient, ident, miljoer, token.getTokenValue()).call()))
.collectList())
.subscribe(resultat -> log.info("Slettet POPP-inntekt, alle miljøer"));
}

@Timed(name = "providers", tags = {"operation", "pen_hentVedtak"})
public Flux<PensjonVedtakResponse> hentVedtak(String ident, String miljoe) {

return tokenService.exchange(serverProperties)
Expand All @@ -193,14 +206,14 @@ public Flux<PensjonVedtakResponse> hentVedtak(String ident, String miljoe) {
ident, miljoe, response));
}

@Timed(name = "providers", tags = { "operation", "pen_lagreAfpOffentlig" })
@Timed(name = "providers", tags = {"operation", "pen_lagreAfpOffentlig"})
public Flux<PensjonforvalterResponse> lagreAfpOffentlig(AfpOffentligRequest afpOffentligRequest, String ident, String miljoe) {

return tokenService.exchange(serverProperties)
.flatMapMany(token -> new LagreAfpOffentligCommand(webClient, afpOffentligRequest, ident, miljoe, token.getTokenValue()).call());
}

@Timed(name = "providers", tags = { "operation", "pen_sletteAfpOffentlig" })
@Timed(name = "providers", tags = {"operation", "pen_sletteAfpOffentlig"})
public void sletteAfpOffentlig(List<String> identer) {

tokenService.exchange(serverProperties)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package no.nav.dolly.bestilling.pensjonforvalter.command;

import lombok.RequiredArgsConstructor;
import no.nav.dolly.bestilling.pensjonforvalter.domain.PensjonforvalterResponse;
import no.nav.testnav.libs.reactivecore.utils.WebClientFilter;
import no.nav.testnav.libs.securitycore.config.UserConstant;
import org.springframework.http.HttpStatus;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.concurrent.Callable;

import static no.nav.dolly.domain.CommonKeysAndUtils.CONSUMER;
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.TokenXUtil.getUserJwt;
import static org.springframework.http.HttpHeaders.AUTHORIZATION;

@RequiredArgsConstructor
public class SlettePoppInntektCommand implements Callable<Flux<PensjonforvalterResponse>> {

private static final String POPP_DELETE_URL = "/api/v1/popp/person";

private final WebClient webClient;
private final String ident;
private final Set<String> miljoer;
private final String token;

public Flux<PensjonforvalterResponse> call() {

return webClient
.delete()
.uri(uriBuilder -> uriBuilder
.path(POPP_DELETE_URL)
.queryParam("miljoer", miljoer)
.build())
.header("pid", ident)
.header(AUTHORIZATION, "Bearer " + token)
.header(UserConstant.USER_HEADER_JWT, getUserJwt())
.header(HEADER_NAV_CALL_ID, generateCallId())
.header(HEADER_NAV_CONSUMER_ID, CONSUMER)
.retrieve()
.bodyToFlux(PensjonforvalterResponse.class)
.doOnError(WebClientFilter::logErrorMessage)
.onErrorResume(Exception.class, error -> Mono.empty());
}
}
2 changes: 1 addition & 1 deletion apps/dolly-backend/src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<encoder class="no.nav.testnav.libs.servletcore.logging.TestnavLogbackEncoder">
<maxStackTraceLength>-1</maxStackTraceLength>
<addCauses>true</addCauses>
<stackTraceIncludePrefix>-</stackTraceIncludePrefix>
<!-- <stackTraceIncludePrefix>-</stackTraceIncludePrefix>-->
<!-- <throwableConverter class="net.logstash.logback.stacktrace.ShortenedThrowableConverter">-->
<!-- <rootCauseFirst>true</rootCauseFirst>-->
<!-- -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,6 @@ public class DollyFrontendApplicationStarter {
private final AccessService accessService;
private final UserJwtExchange userJwtExchange;
private final Consumers consumers;

public static void main(String[] args) {
new SpringApplicationBuilder(DollyFrontendApplicationStarter.class)
.initializers(new NaisEnvironmentApplicationContextInitializer())
.run(args);
}

private final GatewayFilter removeCookiesFilter = (exchange, chain) -> {
ServerWebExchange modifiedExchange = exchange.mutate()
.request(r -> r.headers(headers -> headers.remove(HttpHeaders.COOKIE)))
Expand Down Expand Up @@ -108,6 +101,12 @@ public RouteLocator customRouteLocator(RouteLocatorBuilder builder) {
.build();
}

public static void main(String[] args) {
new SpringApplicationBuilder(DollyFrontendApplicationStarter.class)
.initializers(new NaisEnvironmentApplicationContextInitializer())
.run(args);
}

private GatewayFilter addAuthenticationHeaderFilterFrom(ServerProperties serverProperties) {
return new AddAuthenticationHeaderToRequestGatewayFilterFactory()
.apply(exchange -> {
Expand Down
Loading

0 comments on commit 4c83003

Please sign in to comment.