use of nl.knaw.huygens.timbuctoo.v5.rdfio.implementations.rdf4j.parsers.TimRdfHandler in project timbuctoo by HuygensING.
the class Rdf4jRdfParser method importRdf.
@Override
public void importRdf(CachedLog input, String baseUri, String defaultGraph, RdfProcessor rdfProcessor) throws RdfProcessingFailedException {
try {
RDFFormat format = Rio.getParserFormatForMIMEType(input.getMimeType().toString()).orElseThrow(() -> new UnsupportedRDFormatException(input.getMimeType() + " is not a supported rdf type."));
RDFParser rdfParser = Rio.createParser(format);
rdfParser.setPreserveBNodeIDs(true);
rdfParser.setRDFHandler(new TimRdfHandler(rdfProcessor, defaultGraph, input.getFile().getName()));
rdfParser.parse(input.getReader(), baseUri);
} catch (IOException | RDFParseException | UnsupportedRDFormatException e) {
throw new RdfProcessingFailedException(e);
} catch (RDFHandlerException e) {
if (e.getCause() instanceof RdfProcessingFailedException) {
throw (RdfProcessingFailedException) e.getCause();
} else {
throw new RdfProcessingFailedException(e);
}
}
}
Aggregations