@@ -47,8 +47,7 @@ public AnnotationList getAnnotationList(String identifier, String name, String c
47
47
throw new ResolvingException ("No annotation list for name " + annotationListName );
48
48
}
49
49
try {
50
- return objectMapper .readValue (
51
- fileResourceService .getAsString (resource , StandardCharsets .UTF_8 ), AnnotationList .class );
50
+ return objectMapper .readValue (getResourceJson (resource ), AnnotationList .class );
52
51
} catch (IOException ex ) {
53
52
LOGGER .error ("Could not retrieve annotation list {}" , annotationListName , ex );
54
53
throw new InvalidDataException (
@@ -69,8 +68,7 @@ public Collection getCollection(String name)
69
68
throw new ResolvingException ("No collection for name " + name );
70
69
}
71
70
try {
72
- return objectMapper .readValue (
73
- fileResourceService .getAsString (resource , StandardCharsets .UTF_8 ), Collection .class );
71
+ return objectMapper .readValue (getResourceJson (resource ), Collection .class );
74
72
} catch (IOException ex ) {
75
73
LOGGER .info ("Could not retrieve collection {}" , collectionName , ex );
76
74
throw new InvalidDataException (
@@ -89,8 +87,7 @@ public Manifest getManifest(String identifier)
89
87
throw new ResolvingException ("No manifest for identifier " + identifier );
90
88
}
91
89
try {
92
- return objectMapper .readValue (
93
- fileResourceService .getAsString (resource , StandardCharsets .UTF_8 ), Manifest .class );
90
+ return objectMapper .readValue (getResourceJson (resource ), Manifest .class );
94
91
} catch (IOException ex ) {
95
92
LOGGER .error ("Manifest {} can not be parsed" , identifier , ex );
96
93
throw new InvalidDataException ("Manifest " + identifier + " can not be parsed" , ex );
@@ -120,4 +117,9 @@ private Instant getResourceModificationDate(String identifier)
120
117
throw new ResolvingException ("No manifest for identifier " + identifier );
121
118
}
122
119
}
120
+
121
+ protected String getResourceJson (FileResource resource )
122
+ throws ResourceIOException , ResourceNotFoundException {
123
+ return fileResourceService .getAsString (resource , StandardCharsets .UTF_8 );
124
+ }
123
125
}
0 commit comments