Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle REST client exception for unsupported URL #134

Merged
4 commits merged into from
Aug 4, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions src/main/java/edu/tamu/iiif/service/AbstractManifestService.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,22 @@ protected Model getRdfModel(String url) throws NotFoundException {
}

protected String getRdf(String url) throws NotFoundException {
Optional<String> rdf = Optional.ofNullable(restTemplate.getForObject(url, String.class));
if (rdf.isPresent()) {
logger.debug("RDF for {}: \n{}\n", url, rdf.get());
return rdf.get();
try {
if (logger.isDebugEnabled()) {
logger.info("Requesting RDF for {}", url);
This conversation was marked as resolved.
Show resolved Hide resolved
}
Optional<String> rdf = Optional.ofNullable(restTemplate.getForObject(url, String.class));
if (rdf.isPresent()) {
if (logger.isDebugEnabled()) {
This conversation was marked as resolved.
Show resolved Hide resolved
logger.debug("RDF for {}: \n{}\n", url, rdf.get());
}
return rdf.get();
}
} catch (RestClientException e) {
logger.error("Failed to get RDF for {}: {}", url, e.getMessage());
if (logger.isDebugEnabled()) {
This conversation was marked as resolved.
Show resolved Hide resolved
logger.debug("Error while requesting RDF for {}: {}", url, e.getMessage(), e);
}
}
throw new NotFoundException("RDF not found! " + url);
}
Expand Down
Loading