Skip to content

Commit

Permalink
Merge branch 'master' into bugfix/sortering-av-gruppe
Browse files Browse the repository at this point in the history
  • Loading branch information
krharum authored Jan 24, 2025
2 parents 71f2ab9 + df3884a commit 1c461ae
Show file tree
Hide file tree
Showing 35 changed files with 146 additions and 122 deletions.
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 @@ -7,6 +7,7 @@
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 reactor.core.publisher.Mono;
import reactor.util.retry.Retry;

Expand Down Expand Up @@ -38,11 +39,11 @@ public Mono<ArbeidsplassenCVStatusDTO> call() {
.retrieve()
.toBodilessEntity()
.map(status -> ArbeidsplassenCVStatusDTO.builder()
.status(HttpStatus.valueOf(status.getStatusCode().value()))
.build())
.doOnError(WebClientFilter::logErrorMessage)
.doOnError(throwable -> Mono.empty())
.status(HttpStatus.valueOf(status.getStatusCode().value()))
.build())
.doOnError(throwable -> !(throwable instanceof WebClientResponseException.NotFound), WebClientFilter::logErrorMessage)
.retryWhen(Retry.backoff(3, Duration.ofSeconds(5))
.filter(WebClientFilter::is5xxException));
.filter(WebClientFilter::is5xxException))
.onErrorResume(WebClientResponseException.NotFound.class::isInstance, throwable -> Mono.empty());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,14 @@ public Flux<ClientFuture> gjenopprett(RsDollyUtvidetBestilling bestilling, Dolly
@Override
public void release(List<String> identer) {

identer.forEach(ident -> fullmaktConsumer.getFullmaktData(List.of(ident)).subscribe(
fullmakter -> fullmakter.getFullmakt()
.forEach(fullmakt -> fullmaktConsumer
.deleteFullmaktData(ident, fullmakt.getFullmaktId()).subscribe())));
Flux.fromIterable(identer)
.flatMap(ident -> fullmaktConsumer.getFullmaktData(List.of(ident))
.map(FullmaktResponse::getFullmakt)
.flatMap(Flux::fromIterable)
.map(FullmaktResponse.Fullmakt::getFullmaktId)
.flatMap(fullmaktsId -> fullmaktConsumer.deleteFullmaktData(ident, fullmaktsId)))
.collectList()
.subscribe(result -> log.info("Fullmakt, slettet {} identer", identer.size()));
}

private ClientFuture futurePersist(BestillingProgress progress, String status) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import no.nav.dolly.metrics.Timed;
import no.nav.testnav.libs.securitycore.domain.ServerProperties;
import no.nav.testnav.libs.standalone.servletsecurity.exchange.TokenExchange;
import org.springframework.http.ResponseEntity;
import org.springframework.http.HttpStatusCode;
import org.springframework.stereotype.Service;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Flux;
Expand Down Expand Up @@ -67,7 +67,7 @@ public Flux<FullmaktResponse> getFullmaktData(List<String> identer) {
}

@Timed(name = "providers", tags = { "operation", "fullmakt_getData" })
public Mono<ResponseEntity<Void>> deleteFullmaktData(String ident, Integer fullmaktId) {
public Mono<HttpStatusCode> deleteFullmaktData(String ident, Integer fullmaktId) {

return tokenService.exchange(serverProperties)
.flatMap(token -> new DeleteFullmaktDataCommand(webClient, ident, fullmaktId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import no.nav.testnav.libs.reactivecore.utils.WebClientFilter;
import no.nav.testnav.libs.securitycore.config.UserConstant;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatusCode;
import org.springframework.http.ResponseEntity;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Mono;
Expand All @@ -21,7 +22,7 @@

@Slf4j
@RequiredArgsConstructor
public class DeleteFullmaktDataCommand implements Callable<Mono<ResponseEntity<Void>>> {
public class DeleteFullmaktDataCommand implements Callable<Mono<HttpStatusCode>> {

private static final String DELETE_FULLMAKT_URL = "/api/fullmakt/{fullmaktId}";

Expand All @@ -30,7 +31,7 @@ public class DeleteFullmaktDataCommand implements Callable<Mono<ResponseEntity<V
private final Integer fullmaktId;
private final String token;

public Mono<ResponseEntity<Void>> call() {
public Mono<HttpStatusCode> call() {

return webClient.get()
.uri(uriBuilder -> uriBuilder
Expand All @@ -43,6 +44,7 @@ public Mono<ResponseEntity<Void>> call() {
.header(UserConstant.USER_HEADER_JWT, getUserJwt())
.retrieve()
.toBodilessEntity()
.map(ResponseEntity::getStatusCode)
.doOnError(WebClientFilter::logErrorMessage)
.doOnSuccess(response -> log.info("Fullmakt with id {} deleted for person with ident {}", fullmaktId, ident))
.retryWhen(Retry.backoff(3, Duration.ofSeconds(5))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import no.nav.testnav.libs.securitycore.config.UserConstant;
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.Flux;
import reactor.util.retry.Retry;

Expand Down Expand Up @@ -42,9 +43,9 @@ public Flux<FullmaktResponse> call() {
.header(UserConstant.USER_HEADER_JWT, getUserJwt())
.retrieve()
.bodyToFlux(FullmaktResponse.class)
.doOnError(WebClientFilter::logErrorMessage)
.doOnError(throwable -> !(throwable instanceof WebClientResponseException.NotFound), WebClientFilter::logErrorMessage)
.retryWhen(Retry.backoff(3, Duration.ofSeconds(5))
.filter(WebClientFilter::is5xxException))
.doOnError(WebClientFilter::logErrorMessage);
.onErrorResume(WebClientResponseException.NotFound.class::isInstance, throwable -> Flux.empty());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
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 reactor.core.publisher.Mono;
import reactor.util.retry.Retry;

Expand Down Expand Up @@ -45,7 +46,8 @@ public Mono<DeleteResponse> call() {
.ident(ident)
.status(HttpStatus.valueOf(resultat.getStatusCode().value()))
.build())
.doOnError(WebClientFilter::logErrorMessage)
.doOnError(throwable -> !(throwable instanceof WebClientResponseException.BadRequest),
WebClientFilter::logErrorMessage)
.onErrorResume(error -> Mono.just(DeleteResponse.builder()
.ident(ident)
.status(WebClientFilter.getStatus(error))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
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 reactor.core.publisher.Mono;
import reactor.util.retry.Retry;

Expand Down Expand Up @@ -49,7 +50,7 @@ public Mono<DigitalKontaktdataResponse> call() {
.map(response -> DigitalKontaktdataResponse.builder()
.status(HttpStatus.valueOf(response.getStatusCode().value()))
.build())
.doOnError(WebClientFilter::logErrorMessage)
.doOnError(throwable -> !(throwable instanceof WebClientResponseException.NotFound), WebClientFilter::logErrorMessage)
.onErrorResume(error -> Mono.just(DigitalKontaktdataResponse.builder()
.status(WebClientFilter.getStatus(error))
.melding(WebClientFilter.getMessage(error))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,16 @@ public Flux<ClientFuture> gjenopprett(RsDollyUtvidetBestilling bestilling, Dolly
@Override
public void release(List<String> identer) {

Flux<MedlData> medlemskapAvvisRequests = medlConsumer.getMedlemskapsperioder(identer).map(medlDataResponse -> {
var gjeldendeMedlemskapsperiode = mapperFacade.map(medlDataResponse, MedlData.class);
gjeldendeMedlemskapsperiode.setStatus(STATUS_AVVIST);
gjeldendeMedlemskapsperiode.setStatusaarsak(STATUSAARSAK_FEILREGISTRERT);
medlConsumer.getMedlemskapsperioder(identer)
.map(medlDataResponse -> {

return gjeldendeMedlemskapsperiode;
});
var gjeldendeMedlemskapsperiode = mapperFacade.map(medlDataResponse, MedlData.class);
gjeldendeMedlemskapsperiode.setStatus(STATUS_AVVIST);
gjeldendeMedlemskapsperiode.setStatusaarsak(STATUSAARSAK_FEILREGISTRERT);

medlConsumer.deleteMedlemskapsperioder(medlemskapAvvisRequests)
return gjeldendeMedlemskapsperiode;
})
.flatMap(medlConsumer::deleteMedlemskapsperioder)
.collectList()
.subscribe(response -> log.info("Sletting utført mot Medl"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,23 @@ public MedlConsumer(
.build();
}

@Timed(name = "providers", tags = { "operation", "medl_createMedlemskapsperiode" })
@Timed(name = "providers", tags = {"operation", "medl_createMedlemskapsperiode"})
public Mono<MedlPostResponse> createMedlemskapsperiode(MedlData medlData) {

log.info("Medlemskapsperiode opprett {}", medlData);
return tokenService.exchange(serverProperties)
.flatMap(token -> new MedlPostCommand(webClient, medlData, token.getTokenValue()).call());
}

@Timed(name = "providers", tags = { "operation", "medl_deleteMedlemskapsperioder" })
public Flux<MedlPostResponse> deleteMedlemskapsperioder(Flux<MedlData> medlDataRequests) {
@Timed(name = "providers", tags = {"operation", "medl_deleteMedlemskapsperioder"})
public Flux<MedlPostResponse> deleteMedlemskapsperioder(MedlData medldata) {

return tokenService.exchange(serverProperties)
.flatMapMany(token ->
medlDataRequests.flatMap(medlData ->
new MedlPutCommand(webClient, medlData, token.getTokenValue()).call()));
new MedlPutCommand(webClient, medldata, token.getTokenValue()).call());
}

@Timed(name = "providers", tags = { "operation", "medl_getMedlemskapsperiode" })
@Timed(name = "providers", tags = {"operation", "medl_getMedlemskapsperiode"})
public Flux<MedlDataResponse> getMedlemskapsperioder(List<String> identer) {

return tokenService.exchange(serverProperties)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import no.nav.testnav.libs.securitycore.config.UserConstant;
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.Flux;
import reactor.util.retry.Retry;

Expand Down Expand Up @@ -35,9 +36,9 @@ public Flux<MedlDataResponse> call() {
.header(UserConstant.USER_HEADER_JWT, getUserJwt())
.retrieve()
.bodyToFlux(MedlDataResponse.class)
.doOnError(WebClientFilter::logErrorMessage)
.doOnError(throwable -> !(throwable instanceof WebClientResponseException.NotFound), WebClientFilter::logErrorMessage)
.retryWhen(Retry.backoff(3, Duration.ofSeconds(5))
.filter(WebClientFilter::is5xxException))
.doOnError(WebClientFilter::logErrorMessage);
.onErrorResume(WebClientResponseException.NotFound.class::isInstance, throwable -> Flux.empty());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public Flux<Void> call() {
.retryWhen(Retry.backoff(3, Duration.ofSeconds(5))
.filter(WebClientFilter::is5xxException))
.onErrorMap(TimeoutException.class, e -> new HttpTimeoutException("Timeout on DELETE of ident %s".formatted(ident)))
.doOnError(WebClientFilter::logErrorMessage)
.doOnError(throwable -> !(throwable instanceof WebClientResponseException.NotFound), WebClientFilter::logErrorMessage)
.onErrorResume(throwable -> throwable instanceof WebClientResponseException.NotFound,
throwable -> Flux.empty());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package no.nav.dolly.bestilling.pensjonforvalter.command;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import no.nav.dolly.bestilling.pensjonforvalter.domain.PensjonforvalterResponse;
import no.nav.testnav.libs.reactivecore.utils.WebClientFilter;
import no.nav.testnav.libs.securitycore.config.UserConstant;
Expand All @@ -19,7 +18,6 @@
import static no.nav.dolly.util.TokenXUtil.getUserJwt;
import static org.springframework.http.HttpHeaders.AUTHORIZATION;

@Slf4j
@RequiredArgsConstructor
public class SletteAfpOffentligCommand implements Callable<Mono<PensjonforvalterResponse>> {

Expand All @@ -30,20 +28,16 @@ public class SletteAfpOffentligCommand implements Callable<Mono<Pensjonforvalter
private final String miljoe;
private final String token;


public Mono<PensjonforvalterResponse> call() {

var callId = generateCallId();
log.info("Pensjon slette AFP-Offentlig callId: {}", callId);

return webClient
.delete()
.uri(uriBuilder -> uriBuilder
.path(AFP_OFFENTLIG_URL)
.build(miljoe, ident))
.header(AUTHORIZATION, "Bearer " + token)
.header(UserConstant.USER_HEADER_JWT, getUserJwt())
.header(HEADER_NAV_CALL_ID, callId)
.header(HEADER_NAV_CALL_ID, generateCallId())
.header(HEADER_NAV_CONSUMER_ID, CONSUMER)
.retrieve()
.toBodilessEntity()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package no.nav.dolly.bestilling.pensjonforvalter.command;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import no.nav.dolly.bestilling.pensjonforvalter.domain.PensjonforvalterResponse;
import no.nav.testnav.libs.reactivecore.utils.WebClientFilter;
import no.nav.testnav.libs.securitycore.config.UserConstant;
Expand All @@ -20,7 +19,6 @@
import static no.nav.dolly.util.TokenXUtil.getUserJwt;
import static org.springframework.http.HttpHeaders.AUTHORIZATION;

@Slf4j
@RequiredArgsConstructor
public class SlettePensjonsavtaleCommand implements Callable<Flux<PensjonforvalterResponse>> {

Expand All @@ -30,20 +28,16 @@ public class SlettePensjonsavtaleCommand implements Callable<Flux<Pensjonforvalt
private final String ident;
private final String token;


public Flux<PensjonforvalterResponse> call() {

var callId = generateCallId();
log.info("Pensjon slette pensjonsavtale callId: {}", callId);

return webClient
.delete()
.uri(uriBuilder -> uriBuilder
.path(PENSJON_TP_PERSON_FORHOLD_URL)
.build())
.header(AUTHORIZATION, "Bearer " + token)
.header(UserConstant.USER_HEADER_JWT, getUserJwt())
.header(HEADER_NAV_CALL_ID, callId)
.header(HEADER_NAV_CALL_ID, generateCallId())
.header(HEADER_NAV_CONSUMER_ID, CONSUMER)
.header("ident", ident)
.retrieve()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package no.nav.dolly.bestilling.pensjonforvalter.command;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import no.nav.dolly.bestilling.pensjonforvalter.domain.PensjonforvalterResponse;
import no.nav.testnav.libs.reactivecore.utils.WebClientFilter;
import no.nav.testnav.libs.securitycore.config.UserConstant;
Expand All @@ -21,7 +20,6 @@
import static no.nav.dolly.util.TokenXUtil.getUserJwt;
import static org.springframework.http.HttpHeaders.AUTHORIZATION;

@Slf4j
@RequiredArgsConstructor
public class SletteTpForholdCommand implements Callable<Flux<PensjonforvalterResponse>> {

Expand All @@ -35,9 +33,6 @@ public class SletteTpForholdCommand implements Callable<Flux<PensjonforvalterRes

public Flux<PensjonforvalterResponse> call() {

var callId = generateCallId();
log.info("Pensjon slette TP-forhold callId: {}", callId);

return webClient
.delete()
.uri(uriBuilder -> uriBuilder
Expand All @@ -46,7 +41,7 @@ public Flux<PensjonforvalterResponse> call() {
.build())
.header(AUTHORIZATION, "Bearer " + token)
.header(UserConstant.USER_HEADER_JWT, getUserJwt())
.header(HEADER_NAV_CALL_ID, callId)
.header(HEADER_NAV_CALL_ID, generateCallId())
.header(HEADER_NAV_CONSUMER_ID, CONSUMER)
.header("pid", ident)
.retrieve()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import no.nav.testnav.libs.securitycore.config.UserConstant;
import org.springframework.http.HttpStatus;
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;

Expand Down Expand Up @@ -46,7 +47,7 @@ public Mono<SigrunstubResponse> call() {
.ident(ident)
.status(HttpStatus.valueOf(resultat.getStatusCode().value()))
.build())
.doOnError(WebClientFilter::logErrorMessage)
.doOnError(throwable -> !(throwable instanceof WebClientResponseException.NotFound), WebClientFilter::logErrorMessage)
.onErrorResume(error -> Mono.just(SigrunstubResponse.builder()
.ident(ident)
.status(WebClientFilter.getStatus(error))
Expand Down
Loading

0 comments on commit 1c461ae

Please sign in to comment.