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
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ This service provides **IIIF** manifest generation from **DSpace RDF** and/or **
<details>
<summary>Example Cantaloupe custom delegate</summary>

```
require 'base64'
class CustomDelegate
##
Expand Down Expand Up @@ -102,6 +103,7 @@ This service provides **IIIF** manifest generation from **DSpace RDF** and/or **
return uri
end
end
```

</details>

Expand Down
18 changes: 13 additions & 5 deletions src/main/java/edu/tamu/iiif/service/AbstractManifestService.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,19 @@ protected Model getRdfModel(String url) throws NotFoundException {
return createRdfModel(getRdf(url));
}

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();
private String getRdf(String url) throws NotFoundException {
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()) {
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());
logger.debug("Error while requesting RDF for {}: {}", url, e.getMessage(), e);
}
throw new NotFoundException("RDF not found! " + url);
}
Expand Down
Loading