38 lines
1.5 KiB
Java
38 lines
1.5 KiB
Java
|
package eu.eudat.service.deposit;
|
||
|
|
||
|
import eu.eudat.depositinterface.models.DmpDepositModel;
|
||
|
import eu.eudat.depositinterface.repository.DepositClient;
|
||
|
import eu.eudat.depositinterface.repository.DepositConfiguration;
|
||
|
import org.springframework.core.ParameterizedTypeReference;
|
||
|
import org.springframework.web.reactive.function.client.WebClient;
|
||
|
|
||
|
public class DepositClientImpl implements DepositClient {
|
||
|
|
||
|
private final WebClient depositClient;
|
||
|
|
||
|
public DepositClientImpl(WebClient depositClient) {
|
||
|
this.depositClient = depositClient;
|
||
|
}
|
||
|
|
||
|
|
||
|
@Override
|
||
|
public String deposit(DmpDepositModel dmpDepositModel, String repositoryAccessToken) throws Exception {
|
||
|
return depositClient.post().uri("/", uriBuilder -> uriBuilder.queryParam("authToken", repositoryAccessToken).build()).bodyValue(dmpDepositModel).exchangeToMono(mono -> mono.bodyToMono(String.class)).block();
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public String authenticate(String code) {
|
||
|
return depositClient.get().uri("/authenticate/", uriBuilder -> uriBuilder.queryParam("authToken", code).build()).exchangeToMono(mono -> mono.bodyToMono(String.class)).block();
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public DepositConfiguration getConfiguration() {
|
||
|
return depositClient.get().uri("/configuration").exchangeToMono(mono -> mono.bodyToMono(new ParameterizedTypeReference<DepositConfiguration>() {})).block();
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public String getLogo() {
|
||
|
return depositClient.get().uri("/logo/").exchangeToMono(mono -> mono.bodyToMono(String.class)).block();
|
||
|
}
|
||
|
}
|