more logging
This commit is contained in:
parent
f080312a59
commit
0f8aadf6f4
|
@ -3,6 +3,7 @@ package org.opencdmp.deposit.zenodorepository.service.zenodo;
|
|||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import gr.cite.tools.exception.MyApplicationException;
|
||||
import gr.cite.tools.logging.LoggerService;
|
||||
import gr.cite.tools.logging.MapLogEntry;
|
||||
import org.opencdmp.commonmodels.models.FileEnvelopeModel;
|
||||
import org.opencdmp.commonmodels.models.dmp.DmpModel;
|
||||
import org.opencdmp.depositbase.repository.DepositConfiguration;
|
||||
|
@ -205,6 +206,9 @@ public class ZenodoDepositServiceImpl implements ZenodoDepositService {
|
|||
try {
|
||||
//Forth, update the new deposit's metadata
|
||||
String updateUrl = links.get(ZENODO_LINKS_SELF) + "?access_token=" + zenodoToken;
|
||||
logger.debug(new MapLogEntry("Deposit New Version")
|
||||
.And("url", updateUrl)
|
||||
.And("body", deposit));
|
||||
zenodoClient.put().uri(updateUrl)
|
||||
.headers(httpHeaders -> {
|
||||
httpHeaders.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
|
||||
|
@ -242,6 +246,9 @@ public class ZenodoDepositServiceImpl implements ZenodoDepositService {
|
|||
private LinkedHashMap<String, String> deposit(String zenodoToken, String zenodoUrl, WebClient zenodoClient, ZenodoDeposit deposit) {
|
||||
Map<String, Object> createResponse;
|
||||
String createUrl = zenodoUrl + "deposit/depositions" + "?access_token=" + zenodoToken;
|
||||
logger.debug(new MapLogEntry("Deposit")
|
||||
.And("url", createUrl)
|
||||
.And("body", deposit));
|
||||
createResponse = zenodoClient.post().uri(createUrl).headers(httpHeaders -> {
|
||||
httpHeaders.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
|
||||
httpHeaders.setContentType(MediaType.APPLICATION_JSON);
|
||||
|
@ -254,6 +261,8 @@ public class ZenodoDepositServiceImpl implements ZenodoDepositService {
|
|||
}
|
||||
|
||||
private String publish(WebClient webClient, String publishUrl){
|
||||
logger.debug(new MapLogEntry("publish")
|
||||
.And("url", publishUrl));
|
||||
Map<String, Object> publishResponse = webClient.post().uri(publishUrl).bodyValue("").exchangeToMono(mono ->
|
||||
mono.statusCode().isError() ?
|
||||
mono.createException().flatMap(Mono::error) :
|
||||
|
@ -291,6 +300,10 @@ public class ZenodoDepositServiceImpl implements ZenodoDepositService {
|
|||
map.add(REDIRECT_URI, depositConfiguration.getRedirectUri());
|
||||
|
||||
try {
|
||||
logger.debug(new MapLogEntry("Get Access Token")
|
||||
.And("url", depositConfiguration.getRepositoryAccessTokenUrl())
|
||||
.And("body", map));
|
||||
|
||||
Map<String, Object> values = client.post().uri(depositConfiguration.getRepositoryAccessTokenUrl()).bodyValue(map).exchangeToMono(mono ->
|
||||
mono.statusCode().isError() ?
|
||||
mono.createException().flatMap(Mono::error) :
|
||||
|
@ -361,8 +374,7 @@ public class ZenodoDepositServiceImpl implements ZenodoDepositService {
|
|||
|
||||
private static ExchangeFilterFunction logRequest() {
|
||||
return ExchangeFilterFunction.ofRequestProcessor(clientRequest -> {
|
||||
logger.debug("Request: {} {}", clientRequest.method(), clientRequest.url());
|
||||
clientRequest.headers().forEach((name, values) -> values.forEach(value -> logger.debug("{}={}", name, value)));
|
||||
logger.debug(new MapLogEntry("Request").And("method", clientRequest.method()).And("url", clientRequest.url()));
|
||||
return Mono.just(clientRequest);
|
||||
});
|
||||
}
|
||||
|
@ -372,9 +384,7 @@ public class ZenodoDepositServiceImpl implements ZenodoDepositService {
|
|||
if (response.statusCode().isError()) {
|
||||
return response.mutate().build().bodyToMono(String.class)
|
||||
.flatMap(body -> {
|
||||
logger.error("Request: {} {}", response.request().getMethod(), response.request().getURI());
|
||||
response.request().getHeaders().forEach((name, values) -> values.forEach(value -> logger.error("{}={}", name, value)));
|
||||
logger.error("Response: {} {}", response.statusCode(), body);
|
||||
logger.error(new MapLogEntry("Response").And("method", response.request().getMethod()).And("url", response.request().getURI()).And("status", response.statusCode()).And("body", body));
|
||||
return Mono.just(response);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue