Skip to content

Commit

Permalink
Merge branch 'master' into feature/brregstub-reverse-proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
krharum authored Feb 26, 2025
2 parents 3938cbc + 5adcfac commit 5a35fc7
Show file tree
Hide file tree
Showing 105 changed files with 3,327 additions and 629 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/app.dolly-search-service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: dolly-search-service

on:
push:
paths:
- "plugins/**"
- "libs/data-transfer-search-objects/**"
- "libs/reactive-core/**"
- "libs/security-core/**"
- "libs/servlet-core/**"
- "libs/servlet-security/**"
- "libs/testing/**"
- "apps/dolly-search-service/**"
- ".github/workflows/app.dolly-search-service.yml"

jobs:
workflow:
uses: ./.github/workflows/common.workflow.backend.yml
with:
working-directory: "apps/dolly-search-service"
deploy-tag: "#deploy-dolly-search-service"
permissions:
contents: read
id-token: write
secrets: inherit
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,12 @@
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;

import no.nav.testnav.libs.servletcore.config.ApplicationCoreConfig;
import no.nav.testnav.libs.database.config.FlywayConfiguration;
import no.nav.testnav.libs.database.config.VaultHikariConfiguration;

@Configuration
@EnableJpaAuditing
@EnableJpaRepositories(basePackages = "no.nav.brregstub.database.repository")
@Import({
ApplicationCoreConfig.class,
VaultHikariConfiguration.class,
FlywayConfiguration.class,
ApplicationCoreConfig.class
})
public class AppConfig {
}
5 changes: 2 additions & 3 deletions apps/brreg-stub/src/main/resources/application-prod.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

spring:
config:
import: "vault://"
flyway:
locations: classpath:db/migration/postgresql
datasource:
Expand Down Expand Up @@ -30,5 +31,3 @@ spring:
role: testnav-brregstub-admin
backend: postgresql/preprod-fss
fail-fast: true
config:
import: vault://
1 change: 1 addition & 0 deletions apps/dolly-backend/config.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ spec:
- application: testnav-arbeidsforhold-service
- application: testnav-arbeidsplassencv-proxy
- application: testnav-arbeidssoekerregisteret-proxy
- application: testnav-dolly-search-service
- application: testnav-inntektsmelding-service
- application: testnav-kodeverk-service
- application: testnav-miljoer-service
Expand Down
6 changes: 4 additions & 2 deletions apps/dolly-backend/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,24 @@ spec:
accessPolicy:
inbound:
rules:

- application: dolly-frontend
- application: dolly-idporten
- application: etterlatte-testdata
namespace: etterlatte
- application: testnav-batch-bestilling-service
- application: testnav-dollystatus
- application: testnav-helsepersonell-service
- application: testnav-oversikt-frontend
- application: testnav-tenor-search-service
- application: etterlatte-testdata
namespace: etterlatte
outbound:
rules:
- application: generer-navn-service
- application: testnav-amelding-service
- application: testnav-arbeidsforhold-service
- application: testnav-arbeidsplassencv-proxy
- application: testnav-arbeidssoekerregisteret-proxy
- application: testnav-dolly-search-service
- application: testnav-inntektsmelding-service
- application: testnav-kodeverk-service
- application: testnav-miljoer-service
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ public static void main(String[] args) {
.initializers(new NaisEnvironmentApplicationContextInitializer())
.run(args);
}
}
}
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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,5 @@ public class Consumers {
private ServerProperties testnavSkattekortService;
private ServerProperties yrkesskadeProxy;
private ServerProperties arbeidssoekerregisteretProxy;
private ServerProperties dollySearchService;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@
import lombok.NoArgsConstructor;
import no.nav.dolly.elastic.ElasticBestilling;

import java.util.ArrayList;
import java.util.List;

import static java.util.Objects.isNull;

@Data
@Builder
@NoArgsConstructor
Expand All @@ -20,6 +23,22 @@ public class SearchResponse {
private Float score;
private String took;
private List<String> identer;
private List<ElasticBestilling> bestillinger;
private List<ElasticBestilling> registre;
private String error;

public List<String> getIdenter() {

if (isNull(identer)) {
identer = new ArrayList<>();
}
return identer;
}

public List<ElasticBestilling> getRegistre() {

if (isNull(registre)) {
registre = new ArrayList<>();
}
return registre;
}
}
Loading

0 comments on commit 5a35fc7

Please sign in to comment.