-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new files and mappings to Endringsmelding service
Removed the TranslittereringUtil file and added several new classes to handle mapping and service consumption functionality. New logic is distributed over twelve newly introduced files, which include the FoedselsmeldingRequestMapper and KjoennFraIdentUtility. Additionally, several configuration adjustments were made in application-dev.yml and Consumers.java.
- Loading branch information
Showing
44 changed files
with
1,197 additions
and
185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
.../src/main/java/no/nav/testnav/endringsmeldingservice/consumer/AdresseServiceConsumer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package no.nav.testnav.endringsmeldingservice.consumer; | ||
|
||
import no.nav.testnav.endringsmeldingservice.config.Consumers; | ||
import no.nav.testnav.endringsmeldingservice.consumer.command.VegadresseServiceCommand; | ||
import no.nav.testnav.libs.dto.adresseservice.v1.VegadresseDTO; | ||
import no.nav.testnav.libs.reactivesecurity.exchange.TokenExchange; | ||
import no.nav.testnav.libs.securitycore.domain.ServerProperties; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.web.reactive.function.client.WebClient; | ||
import reactor.core.publisher.Mono; | ||
|
||
import java.util.List; | ||
|
||
@Service | ||
public class AdresseServiceConsumer { | ||
private final WebClient webClient; | ||
private final TokenExchange tokenExchange; | ||
private final ServerProperties serverProperties; | ||
|
||
public AdresseServiceConsumer( | ||
TokenExchange tokenExchange, | ||
Consumers consumers) { | ||
this.tokenExchange = tokenExchange; | ||
serverProperties = consumers.getAdresseService(); | ||
this.webClient = WebClient | ||
.builder() | ||
.baseUrl(serverProperties.getUrl()) | ||
.build(); | ||
} | ||
|
||
public Mono<List<VegadresseDTO>> getVegadresse() { | ||
|
||
return tokenExchange.exchange(serverProperties) | ||
.flatMapMany(token -> new VegadresseServiceCommand(webClient, token.getTokenValue()).call()) | ||
.collectList(); | ||
|
||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
.../main/java/no/nav/testnav/endringsmeldingservice/consumer/GenererNavnServiceConsumer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package no.nav.testnav.endringsmeldingservice.consumer; | ||
|
||
import no.nav.testnav.endringsmeldingservice.config.Consumers; | ||
import no.nav.testnav.endringsmeldingservice.consumer.command.GenererNavnServiceCommand; | ||
import no.nav.testnav.libs.dto.generernavnservice.v1.NavnDTO; | ||
import no.nav.testnav.libs.reactivesecurity.exchange.TokenExchange; | ||
import no.nav.testnav.libs.securitycore.domain.ServerProperties; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.web.reactive.function.client.WebClient; | ||
import reactor.core.publisher.Mono; | ||
|
||
import java.util.List; | ||
|
||
@Service | ||
public class GenererNavnServiceConsumer { | ||
|
||
private final WebClient webClient; | ||
private final TokenExchange tokenExchange; | ||
private final ServerProperties serverProperties; | ||
|
||
public GenererNavnServiceConsumer( | ||
TokenExchange tokenExchange, | ||
Consumers consumers) { | ||
this.tokenExchange = tokenExchange; | ||
serverProperties = consumers.getGenererNavnService(); | ||
this.webClient = WebClient | ||
.builder() | ||
.baseUrl(serverProperties.getUrl()) | ||
.build(); | ||
} | ||
|
||
public Mono<List<NavnDTO>> getNavn() { | ||
|
||
return tokenExchange.exchange(serverProperties) | ||
.flatMapMany(token -> new GenererNavnServiceCommand(webClient, 1, token.getTokenValue()).call()) | ||
.collectList(); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
...rvice/src/main/java/no/nav/testnav/endringsmeldingservice/consumer/IdentPoolConsumer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package no.nav.testnav.endringsmeldingservice.consumer; | ||
|
||
import no.nav.testnav.endringsmeldingservice.config.Consumers; | ||
import no.nav.testnav.endringsmeldingservice.consumer.command.IdentpoolPostCommand; | ||
import no.nav.testnav.endringsmeldingservice.consumer.dto.HentIdenterRequest; | ||
import no.nav.testnav.libs.reactivesecurity.exchange.TokenExchange; | ||
import no.nav.testnav.libs.securitycore.domain.ServerProperties; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.web.reactive.function.client.WebClient; | ||
import reactor.core.publisher.Mono; | ||
|
||
import java.util.List; | ||
|
||
@Service | ||
public class IdentPoolConsumer { | ||
|
||
private final WebClient webClient; | ||
private final TokenExchange tokenExchange; | ||
private final ServerProperties serverProperties; | ||
|
||
public IdentPoolConsumer( | ||
TokenExchange tokenExchange, | ||
Consumers consumers) { | ||
this.tokenExchange = tokenExchange; | ||
serverProperties = consumers.getIdentPool(); | ||
this.webClient = WebClient | ||
.builder() | ||
.baseUrl(serverProperties.getUrl()) | ||
.build(); | ||
} | ||
|
||
public Mono<List<String>> acquireIdents(HentIdenterRequest request) { | ||
|
||
return tokenExchange.exchange(serverProperties) | ||
.flatMap(token -> new IdentpoolPostCommand(webClient, request, | ||
token.getTokenValue()).call()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...ava/no/nav/testnav/endringsmeldingservice/consumer/command/GenererNavnServiceCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package no.nav.testnav.endringsmeldingservice.consumer.command; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import no.nav.testnav.libs.dto.generernavnservice.v1.NavnDTO; | ||
import no.nav.testnav.libs.reactivecore.utils.WebClientFilter; | ||
import org.springframework.http.HttpHeaders; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.web.reactive.function.client.WebClient; | ||
import reactor.core.publisher.Flux; | ||
import reactor.util.retry.Retry; | ||
|
||
import java.time.Duration; | ||
import java.util.concurrent.Callable; | ||
|
||
@RequiredArgsConstructor | ||
public class GenererNavnServiceCommand implements Callable<Flux<NavnDTO>> { | ||
|
||
private static final String NAVN_URL = "/api/v1/navn"; | ||
|
||
private final WebClient webClient; | ||
private final Integer antall; | ||
private final String token; | ||
|
||
@Override | ||
public Flux<NavnDTO> call() { | ||
|
||
return webClient | ||
.get() | ||
.uri(builder -> builder.path(NAVN_URL).queryParam("antall", antall).build()) | ||
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) | ||
.header(HttpHeaders.AUTHORIZATION, "Bearer " + token) | ||
.retrieve() | ||
.bodyToFlux(NavnDTO.class) | ||
.doOnError(WebClientFilter::logErrorMessage) | ||
.retryWhen(Retry.backoff(3, Duration.ofSeconds(5)) | ||
.filter(WebClientFilter::is5xxException)); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
...va/no/nav/testnav/endringsmeldingservice/consumer/command/GetAdressehistorikkCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package no.nav.testnav.endringsmeldingservice.consumer.command; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import no.nav.testnav.libs.data.tpsmessagingservice.v1.AdressehistorikkDTO; | ||
import no.nav.testnav.libs.data.tpsmessagingservice.v1.AdressehistorikkRequest; | ||
import no.nav.testnav.libs.reactivecore.utils.WebClientFilter; | ||
import org.springframework.http.HttpHeaders; | ||
import org.springframework.web.reactive.function.BodyInserters; | ||
import org.springframework.web.reactive.function.client.WebClient; | ||
import reactor.core.publisher.Flux; | ||
import reactor.util.retry.Retry; | ||
|
||
import java.time.Duration; | ||
import java.util.Set; | ||
import java.util.concurrent.Callable; | ||
|
||
@RequiredArgsConstructor | ||
public class GetAdressehistorikkCommand implements Callable<Flux<AdressehistorikkDTO>> { | ||
|
||
private static final String ADRESSE_HIST_URL = "/api/v1/personer/adressehistorikk"; | ||
private static final String MILJOER = "miljoer"; | ||
|
||
private final WebClient webClient; | ||
private final AdressehistorikkRequest request; | ||
private final Set<String> miljoer; | ||
private final String token; | ||
|
||
@Override | ||
public Flux<AdressehistorikkDTO> call() { | ||
|
||
return webClient | ||
.post() | ||
.uri(builder -> builder.path(ADRESSE_HIST_URL) | ||
.queryParam(MILJOER, miljoer) | ||
.build()) | ||
.header(HttpHeaders.AUTHORIZATION, "Bearer " + token) | ||
.body(BodyInserters.fromValue(request)) | ||
.retrieve() | ||
.bodyToFlux(AdressehistorikkDTO.class) | ||
.retryWhen(Retry.backoff(3, Duration.ofSeconds(5)) | ||
.filter(WebClientFilter::is5xxException)) | ||
.doOnError(WebClientFilter::logErrorMessage); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...ain/java/no/nav/testnav/endringsmeldingservice/consumer/command/GetPersondataCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package no.nav.testnav.endringsmeldingservice.consumer.command; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import no.nav.testnav.libs.data.tpsmessagingservice.v1.PersonMiljoeDTO; | ||
import no.nav.testnav.libs.reactivecore.utils.WebClientFilter; | ||
import org.springframework.http.HttpHeaders; | ||
import org.springframework.web.reactive.function.client.WebClient; | ||
import reactor.core.publisher.Flux; | ||
import reactor.util.retry.Retry; | ||
|
||
import java.time.Duration; | ||
import java.util.Set; | ||
import java.util.concurrent.Callable; | ||
|
||
@RequiredArgsConstructor | ||
public class GetPersondataCommand implements Callable<Flux<PersonMiljoeDTO>> { | ||
|
||
private static final String PERSON_DATA_URL = "/api/v1/personer/{ident}"; | ||
private static final String MILJOER = "miljoer"; | ||
|
||
private final WebClient webClient; | ||
private final String ident; | ||
private final Set<String> miljoer; | ||
private final String token; | ||
|
||
@Override | ||
public Flux<PersonMiljoeDTO> call() { | ||
|
||
return webClient | ||
.get() | ||
.uri(builder -> builder.path(PERSON_DATA_URL) | ||
.queryParam(MILJOER, miljoer) | ||
.build(ident)) | ||
.header(HttpHeaders.AUTHORIZATION, "Bearer " + token) | ||
.retrieve() | ||
.bodyToFlux(PersonMiljoeDTO.class) | ||
.retryWhen(Retry.backoff(3, Duration.ofSeconds(5)) | ||
.filter(WebClientFilter::is5xxException)) | ||
.doOnError(WebClientFilter::logErrorMessage); | ||
} | ||
} |
Oops, something went wrong.