8
8
import no .nav .testnav .libs .reactivecore .web .WebClientHeader ;
9
9
import org .springframework .web .reactive .function .client .WebClient ;
10
10
import org .springframework .web .reactive .function .client .WebClientResponseException ;
11
+ import reactor .core .publisher .Flux ;
11
12
import reactor .core .publisher .Mono ;
12
13
13
14
import java .util .concurrent .Callable ;
18
19
19
20
@ RequiredArgsConstructor
20
21
@ Slf4j
21
- public class GetFullmaktDataCommand implements Callable <Mono <FullmaktPostResponse .Fullmakt >> {
22
+ public class GetFullmaktDataCommand implements Callable <Flux <FullmaktPostResponse .Fullmakt >> {
22
23
23
24
private static final String HENT_FULLMAKT_URL = "/api/fullmaktsgiver" ;
24
25
25
26
private final WebClient webClient ;
26
27
private final String ident ;
27
28
private final String token ;
28
29
29
- public Mono <FullmaktPostResponse .Fullmakt > call () {
30
+ public Flux <FullmaktPostResponse .Fullmakt > call () {
30
31
return webClient
31
32
.get ()
32
33
.uri (uriBuilder -> uriBuilder
@@ -37,15 +38,14 @@ public Mono<FullmaktPostResponse.Fullmakt> call() {
37
38
.header ("fnr" , ident )
38
39
.headers (WebClientHeader .bearer (token ))
39
40
.retrieve ()
40
- .bodyToMono (FullmaktPostResponse .Fullmakt .class )
41
+ .bodyToFlux (FullmaktPostResponse .Fullmakt .class )
41
42
.doOnError (WebClientError .logTo (log ))
42
43
.onErrorResume (throwable -> {
43
44
var description = WebClientError .describe (throwable );
44
45
return Mono .just (FullmaktPostResponse .Fullmakt .builder ()
45
46
.status (description .getStatus ().getReasonPhrase ())
46
47
.build ());
47
48
})
48
-
49
49
.onErrorResume (WebClientResponseException .NotFound .class ::isInstance , throwable -> Mono .empty ());
50
50
}
51
51
}
0 commit comments