-
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.
Merge branch 'master' into feature/frontend-oppdatering
- Loading branch information
Showing
106 changed files
with
3,440 additions
and
162 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: levende-arbeidsforhold-service | ||
|
||
on: | ||
push: | ||
paths: | ||
- libs/kafka-config/** | ||
- libs/avro-schema/** | ||
- libs/security-core/** | ||
- libs/servlet-core/** | ||
- libs/servlet-insecure-security/** | ||
- libs/reactive-core/** | ||
- apps/levende-arbeidsforhold-service/** | ||
- .github/workflows/app.levende-arbeidsforhold-service.yml | ||
|
||
jobs: | ||
workflow: | ||
uses: ./.github/workflows/common.workflow.backend.yml | ||
with: | ||
working-directory: "apps/levende-arbeidsforhold-service" | ||
deploy-tag: "#deploy-levende-arbeidsforhold-service" | ||
permissions: | ||
contents: read | ||
id-token: write | ||
secrets: inherit |
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
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
66 changes: 66 additions & 0 deletions
66
...ain/java/no/nav/dolly/bestilling/pensjonforvalter/command/LagrePensjonsavtaleCommand.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,66 @@ | ||
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.dolly.bestilling.pensjonforvalter.domain.PensjonsavtaleRequest; | ||
import no.nav.testnav.libs.reactivecore.utils.WebClientFilter; | ||
import org.springframework.web.reactive.function.client.WebClient; | ||
import reactor.core.publisher.Flux; | ||
import reactor.core.publisher.Mono; | ||
import reactor.util.retry.Retry; | ||
|
||
import java.time.Duration; | ||
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 org.springframework.http.HttpHeaders.AUTHORIZATION; | ||
|
||
@Slf4j | ||
@RequiredArgsConstructor | ||
public class LagrePensjonsavtaleCommand implements Callable<Flux<PensjonforvalterResponse>> { | ||
|
||
private static final String PENSJONSAVTALE_URL = "/api/v2/pensjonsavtale/opprett"; | ||
|
||
private final WebClient webClient; | ||
private final PensjonsavtaleRequest pensjonsavtaleRequest; | ||
private final String token; | ||
|
||
@Override | ||
public Flux<PensjonforvalterResponse> call() { | ||
|
||
var callId = generateCallId(); | ||
log.info("Pensjonsavtale lagre inntekt {}, callId: {}", pensjonsavtaleRequest, callId); | ||
|
||
return webClient.post() | ||
.uri(uriBuilder -> uriBuilder.path(PENSJONSAVTALE_URL).build()) | ||
.header(AUTHORIZATION, "Bearer " + token) | ||
.header(HEADER_NAV_CALL_ID, callId) | ||
.header(HEADER_NAV_CONSUMER_ID, CONSUMER) | ||
.bodyValue(pensjonsavtaleRequest) | ||
.retrieve() | ||
.bodyToFlux(PensjonforvalterResponse.class) | ||
.doOnError(WebClientFilter::logErrorMessage) | ||
.retryWhen(Retry.backoff(3, Duration.ofSeconds(5)) | ||
.filter(WebClientFilter::is5xxException)) | ||
.onErrorResume(error -> | ||
Mono.just(PensjonforvalterResponse.builder() | ||
.status(pensjonsavtaleRequest.getMiljoer().stream() | ||
.map(miljoe -> PensjonforvalterResponse.ResponseEnvironment.builder() | ||
.miljo(miljoe) | ||
.response(PensjonforvalterResponse.Response.builder() | ||
.httpStatus(PensjonforvalterResponse.HttpStatus.builder() | ||
.status(WebClientFilter.getStatus(error).value()) | ||
.reasonPhrase(WebClientFilter.getStatus(error).getReasonPhrase()) | ||
.build()) | ||
.message(WebClientFilter.getMessage(error)) | ||
.path(PENSJONSAVTALE_URL) | ||
.build()) | ||
.build()) | ||
.toList()) | ||
.build())); | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
...in/java/no/nav/dolly/bestilling/pensjonforvalter/command/SlettePensjonsavtaleCommand.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,56 @@ | ||
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; | ||
import org.springframework.web.reactive.function.client.WebClient; | ||
import reactor.core.publisher.Flux; | ||
import reactor.core.publisher.Mono; | ||
import reactor.util.retry.Retry; | ||
|
||
import java.time.Duration; | ||
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; | ||
|
||
@Slf4j | ||
@RequiredArgsConstructor | ||
public class SlettePensjonsavtaleCommand implements Callable<Flux<PensjonforvalterResponse>> { | ||
|
||
private static final String PENSJON_TP_PERSON_FORHOLD_URL = "/api/v1/pensjonsavtale/delete"; | ||
|
||
private final WebClient webClient; | ||
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_CONSUMER_ID, CONSUMER) | ||
.header("ident", ident) | ||
.retrieve() | ||
.bodyToFlux(PensjonforvalterResponse.class) | ||
.retryWhen(Retry.backoff(3, Duration.ofSeconds(5)) | ||
.filter(WebClientFilter::is5xxException)) | ||
.doOnError(WebClientFilter::logErrorMessage) | ||
.onErrorResume(Exception.class, error -> Mono.empty()); | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
.../src/main/java/no/nav/dolly/bestilling/pensjonforvalter/domain/PensjonsavtaleRequest.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,57 @@ | ||
package no.nav.dolly.bestilling.pensjonforvalter.domain; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import static java.util.Objects.isNull; | ||
|
||
@Data | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class PensjonsavtaleRequest { | ||
|
||
public enum AvtaleKategori { | ||
NONE, UNKNOWN, INDIVIDUELL_ORDNING, PRIVAT_AFP, | ||
PRIVAT_TJENESTEPENSJON, OFFENTLIG_TJENESTEPENSJON, FOLKETRYGD | ||
} | ||
|
||
private String ident; | ||
private String produktBetegnelse; | ||
private AvtaleKategori avtaleKategori; | ||
private List<OpprettUtbetalingsperiodeDTO> utbetalingsperioder; | ||
private List<String> miljoer; | ||
|
||
public List<OpprettUtbetalingsperiodeDTO> getUtbetalingsperioder() { | ||
|
||
if (isNull(utbetalingsperioder)) { | ||
utbetalingsperioder = new ArrayList<>(); | ||
} | ||
return utbetalingsperioder; | ||
} | ||
|
||
public List<String> getMiljoer() { | ||
|
||
if (isNull(miljoer)) { | ||
miljoer = new ArrayList<>(); | ||
} | ||
return miljoer; | ||
} | ||
|
||
@Data | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class OpprettUtbetalingsperiodeDTO { | ||
private Integer startAlderAar; | ||
private Integer startAlderMaaned; | ||
private Integer sluttAlderAar; | ||
private Integer sluttAlderMaaned; | ||
private Integer aarligUtbetaling; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...n/java/no/nav/dolly/bestilling/pensjonforvalter/mapper/PensjonsavtaleMappingStrategy.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,33 @@ | ||
package no.nav.dolly.bestilling.pensjonforvalter.mapper; | ||
|
||
import ma.glasnost.orika.CustomMapper; | ||
import ma.glasnost.orika.MapperFactory; | ||
import ma.glasnost.orika.MappingContext; | ||
import no.nav.dolly.bestilling.pensjonforvalter.domain.PensjonsavtaleRequest; | ||
import no.nav.dolly.domain.resultset.pensjon.PensjonData; | ||
import no.nav.dolly.mapper.MappingStrategy; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.Set; | ||
|
||
@Component | ||
public class PensjonsavtaleMappingStrategy implements MappingStrategy { | ||
|
||
@Override | ||
public void register(MapperFactory factory) { | ||
factory.classMap(PensjonData.Pensjonsavtale.class, PensjonsavtaleRequest.class) | ||
.customize(new CustomMapper<>() { | ||
@Override | ||
public void mapAtoB(PensjonData.Pensjonsavtale pensjonsavtale, PensjonsavtaleRequest pensjonsavtaleRequest, MappingContext context) { | ||
|
||
var ident = (String) context.getProperty("ident"); | ||
var miljoer = (Set<String>) context.getProperty("miljoer"); | ||
|
||
pensjonsavtaleRequest.setIdent(ident); | ||
pensjonsavtaleRequest.setMiljoer(miljoer.stream().toList()); | ||
} | ||
}) | ||
.byDefault() | ||
.register(); | ||
} | ||
} |
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
Oops, something went wrong.