Skip to content

Commit

Permalink
deploy #deploy-altinn3-tilgang-service-prod #deploy-altinn3-tilgang-s…
Browse files Browse the repository at this point in the history
…ervice
  • Loading branch information
krharum committed Dec 19, 2024
1 parent d47d5c8 commit e2d641a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion apps/altinn3-tilgang-service/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ sonarqube {
}

dependencies {
implementation "no.nav.testnav.libs:data-transfer-objects"
implementation "no.nav.testnav.libs:reactive-core"
implementation "no.nav.testnav.libs:reactive-security"
implementation "no.nav.testnav.libs:data-transfer-objects"

implementation "org.springframework.boot:spring-boot-starter-data-r2dbc"
implementation "org.springframework.boot:spring-boot-starter-oauth2-resource-server"
Expand Down
2 changes: 1 addition & 1 deletion apps/altinn3-tilgang-service/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ rootProject.name = 'altinn3-tilgang-service'

includeBuild "../../plugins/java"

includeBuild '../../libs/data-transfer-objects'
includeBuild '../../libs/reactive-core'
includeBuild '../../libs/reactive-security'
includeBuild '../../libs/data-transfer-objects'

develocity {
buildScan {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
import lombok.extern.slf4j.Slf4j;
import no.nav.testnav.altinn3tilgangservice.consumer.altinn.AltinnConsumer;
import no.nav.testnav.altinn3tilgangservice.consumer.altinn.dto.AuthorizedPartyDTO;
import no.nav.testnav.altinn3tilgangservice.domain.Organisasjon;
import no.nav.testnav.libs.dto.altinn3.v1.OrganisasjonDTO;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.util.function.Tuple2;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;

@Slf4j
@Service
Expand All @@ -23,23 +23,22 @@ public class AltinnBrukerTilgangService {

public Flux<OrganisasjonDTO> getPersonOrganisasjonTilgang(String ident) {

return altinnConsumer.getAuthorizedParties(ident)
.flatMap(authorizedParty -> getUnitsAndSubunits(new ArrayList<>(), authorizedParty))
.flatMap(Flux::fromIterable);
return Flux.zip(
altinnConsumer.getAuthorizedParties(ident),
altinnConsumer.getOrganisasjoner().collectList())
.flatMap(this::getOrganisasjon);
}

private Mono<List<OrganisasjonDTO>> getUnitsAndSubunits(List<OrganisasjonDTO> organisasjoner,
AuthorizedPartyDTO authorizedParties) {
private Mono<OrganisasjonDTO> getOrganisasjon(Tuple2<AuthorizedPartyDTO, List<Organisasjon>> organisasjoner) {

organisasjoner.addAll(Stream.of(authorizedParties)
.filter(part -> part.getAuthorizedResources().contains(DOLLY_RESOURCE))
return Mono.just(organisasjoner.getT1())
.filter(party -> party.getAuthorizedResources().contains(DOLLY_RESOURCE))
.filter(party -> organisasjoner.getT2().stream()
.anyMatch(organisasjon -> organisasjon.getOrganisasjonsnummer().equals(party.getOrganizationNumber())))
.map(part -> OrganisasjonDTO.builder()
.navn(part.getName())
.organisasjonsnummer(part.getOrganizationNumber())
.organisasjonsform(part.getUnitType())
.build())
.toList());

return Mono.just(organisasjoner);
.build());
}
}

0 comments on commit e2d641a

Please sign in to comment.