Skip to content

Commit

Permalink
Merge pull request #83 from abes-esr/CDE-396-cas-de-non-reponse-des-w…
Browse files Browse the repository at this point in the history
…ebservices-online-id-2-ppn-et-print-id-2-ppn-et-dat-2-ppn-pe-aussi-en-test

gestion cas "Aucune notice ne correspond à la recherche"
  • Loading branch information
jvk88511334 authored Mar 28, 2024
2 parents a268c8f + 8c93d89 commit 2fa3df1
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/main/java/fr/abes/bestppn/service/WsService.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Service;
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestTemplate;

Expand Down Expand Up @@ -95,15 +97,18 @@ private ResultWsSudocDto getResultWsSudocDto(String type, String id, @Nullable S
ResultWsSudocDto result = new ResultWsSudocDto();
try {
result = mapper.readValue((provider != null && !provider.isEmpty()) ? getRestCall(url, type, id, provider) : getRestCall(url, type, id), ResultWsSudocDto.class);
} catch (RestClientException ex) {
log.info("URL : {} / id : {} / provider : {} : Erreur dans l'acces au webservice.", url, id, provider);
throw ex;
} catch (IllegalArgumentException ex) {
if (ex.getMessage().equals("argument \"content\" is null")) {
} catch (HttpClientErrorException ex) {
if (ex.getStatusCode() == HttpStatus.BAD_REQUEST && ex.getMessage().contains("Aucune notice ne correspond à la recherche")) {
log.info("Aucuns ppn correspondant à l'identifiant " + id);
} else {
log.info("URL : {} / id : {} / provider : {} : Erreur dans l'acces au webservice.", url, id, provider);
throw ex;
}
} catch (RestClientException ex) {
log.info("URL : {} / id : {} / provider : {} : Erreur dans l'acces au webservice.", url, id, provider);
throw ex;
} catch (IllegalArgumentException ex) {
throw ex;
} catch (JsonProcessingException ex) {
throw new RestClientException(ex.getMessage());
} finally {
Expand Down

0 comments on commit 2fa3df1

Please sign in to comment.