Skip to content

Commit f47bc2b

Browse files
morpheus-87jbaiter
authored andcommitted
Add method removed in #144
1 parent 8cfa19e commit f47bc2b

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/main/java/de/digitalcollections/iiif/hymir/presentation/backend/PresentationRepositoryImpl.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ public AnnotationList getAnnotationList(String identifier, String name, String c
4747
throw new ResolvingException("No annotation list for name " + annotationListName);
4848
}
4949
try {
50-
return objectMapper.readValue(
51-
fileResourceService.getAsString(resource, StandardCharsets.UTF_8), AnnotationList.class);
50+
return objectMapper.readValue(getResourceJson(resource), AnnotationList.class);
5251
} catch (IOException ex) {
5352
LOGGER.error("Could not retrieve annotation list {}", annotationListName, ex);
5453
throw new InvalidDataException(
@@ -69,8 +68,7 @@ public Collection getCollection(String name)
6968
throw new ResolvingException("No collection for name " + name);
7069
}
7170
try {
72-
return objectMapper.readValue(
73-
fileResourceService.getAsString(resource, StandardCharsets.UTF_8), Collection.class);
71+
return objectMapper.readValue(getResourceJson(resource), Collection.class);
7472
} catch (IOException ex) {
7573
LOGGER.info("Could not retrieve collection {}", collectionName, ex);
7674
throw new InvalidDataException(
@@ -89,8 +87,7 @@ public Manifest getManifest(String identifier)
8987
throw new ResolvingException("No manifest for identifier " + identifier);
9088
}
9189
try {
92-
return objectMapper.readValue(
93-
fileResourceService.getAsString(resource, StandardCharsets.UTF_8), Manifest.class);
90+
return objectMapper.readValue(getResourceJson(resource), Manifest.class);
9491
} catch (IOException ex) {
9592
LOGGER.error("Manifest {} can not be parsed", identifier, ex);
9693
throw new InvalidDataException("Manifest " + identifier + " can not be parsed", ex);
@@ -120,4 +117,9 @@ private Instant getResourceModificationDate(String identifier)
120117
throw new ResolvingException("No manifest for identifier " + identifier);
121118
}
122119
}
120+
121+
protected String getResourceJson(FileResource resource)
122+
throws ResourceIOException, ResourceNotFoundException {
123+
return fileResourceService.getAsString(resource, StandardCharsets.UTF_8);
124+
}
123125
}

0 commit comments

Comments
 (0)