From 3a6f14121311b874528bd7c5422db38dc183bb15 Mon Sep 17 00:00:00 2001 From: "Kristen.Herum" Date: Thu, 19 Dec 2024 14:49:15 +0100 Subject: [PATCH] Refactor to process subunits for authorized parties. #deploy-altinn3-tilgang-service-prod #deploy-altinn3-tilgang-service Changed the handling of authorized parties to include subunits by flattening the structure. Updated methods to use `Flux` for better reactive stream handling and improved filtering logic. This ensures more accurate processing of organizational access data. --- .../service/AltinnBrukerTilgangService.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/apps/altinn3-tilgang-service/src/main/java/no/nav/testnav/altinn3tilgangservice/service/AltinnBrukerTilgangService.java b/apps/altinn3-tilgang-service/src/main/java/no/nav/testnav/altinn3tilgangservice/service/AltinnBrukerTilgangService.java index 581ba8f8ff5..0a4dfe7b207 100644 --- a/apps/altinn3-tilgang-service/src/main/java/no/nav/testnav/altinn3tilgangservice/service/AltinnBrukerTilgangService.java +++ b/apps/altinn3-tilgang-service/src/main/java/no/nav/testnav/altinn3tilgangservice/service/AltinnBrukerTilgangService.java @@ -14,9 +14,6 @@ import java.util.List; -import static org.apache.commons.lang3.BooleanUtils.isFalse; -import static org.apache.commons.lang3.StringUtils.isNotBlank; - @Slf4j @Service @RequiredArgsConstructor @@ -28,14 +25,16 @@ public class AltinnBrukerTilgangService { public Flux getPersonOrganisasjonTilgang(String ident) { return Flux.zip( - altinnConsumer.getAuthorizedParties(ident), + altinnConsumer.getAuthorizedParties(ident).collectList(), altinnConsumer.getOrganisasjoner().collectList()) .flatMap(this::getOrganisasjon); } - private Mono getOrganisasjon(Tuple2> organisasjoner) { + private Flux getOrganisasjon(Tuple2, List> organisasjoner) { - return Mono.just(organisasjoner.getT1()) + return Flux.fromIterable(organisasjoner.getT1()) + .map(AuthorizedPartyDTO::getSubunits) + .flatMap(Flux::fromIterable) .filter(party -> party.getAuthorizedResources().contains(DOLLY_RESOURCE)) .filter(party -> organisasjoner.getT2().stream() .anyMatch(organisasjon -> organisasjon.getOrganisasjonsnummer().equals(party.getOrganizationNumber()))) @@ -62,8 +61,8 @@ public Mono getPersonOrganisasjonDetaljertTilgang(String ident) { private Flux getTilpassetOrganisasjon(Tuple2, List> organisasjoner) { return Flux.fromIterable(organisasjoner.getT1()) - .filter(party -> isNotBlank(party.getOrganizationNumber()) && isNotBlank(party.getName())) - .filter(party -> isFalse(party.getIsDeleted())) + .map(AuthorizedPartyDTO::getSubunits) + .flatMap(Flux::fromIterable) .map(party -> PersonDTO.OrganisasjonDTO.builder() .navn(party.getName()) .organisasjonsnummer(party.getOrganizationNumber())