Skip to content
Snippets Groups Projects
Commit ba6bb869 authored by Thorsten Vitt's avatar Thorsten Vitt
Browse files

Fail PDF generation early on objects with unsupported format

parent befe68da
No related branches found
No related tags found
No related merge requests found
......@@ -77,11 +77,16 @@ public Response get(@PathParam("uri") final URI uri,
mapping, true);
rewriter.configure(URI.create("internal:tei#tei"));
rewriter.recordMissingReferences();
final TGOSupplier<InputStream> textSupplier = repository.read(uri, sid);
final String rootObjectFormat = textSupplier.getMetadata().getGeneric().getProvided().getFormat();
if (!rootObjectFormat.startsWith("text/xml"))
return GenericExceptionMapper.toResponse(Status.UNSUPPORTED_MEDIA_TYPE, "PDF generation currently supports only text/xml documents. The requested document, " + uri + ", has an invalid document type, however:", rootObjectFormat);
final FileBackedOutputStream buffer = new FileBackedOutputStream(
1024 * 1024);
final TGOSupplier<InputStream> textSupplier = repository.read(uri, sid);
rewriter.rewrite(textSupplier.getInput(), buffer);
// now download the missing references if applicable, add
// them to the mapping
final Set<String> linkedURIs = rewriter.getMissingReferences();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment