// TODO: This probably does not support https:// -> http://
// redirections
@Override
    protected void parseSynchronusly() throws IOException {
        final Optional<RDFFormat> formatByMimeType = getContentType().flatMap(Rio::getParserFormatForMIMEType);
        final String base = getBase().map(IRI::getIRIString).orElse(null);
        final ParserConfig parserConfig = getParserConfig();
        // TODO: Should we need to set anything?
        final RDFLoader loader = new RDFLoader(parserConfig, rdf4jTermFactory.getValueFactory());
        final RDFHandler rdfHandler = makeRDFHandler();
        if (getSourceFile().isPresent()) {
            // NOTE: While we could have used
            // loader.load(sourcePath.toFile()
            // if the path fs provider == FileSystems.getDefault(),
            // that RDFLoader method does not use absolute path
            // as the base URI, so to be consistent
            // we'll always do it with our own input stream
            //
            // That means we may have to guess format by extensions:
            final Optional<RDFFormat> formatByFilename = getSourceFile().map(Path::getFileName).map(Path::toString)
                    .flatMap(Rio::getParserFormatForFileName);
            // TODO: for the excited.. what about the extension after following
            // symlinks?
            final RDFFormat format = formatByMimeType.orElse(formatByFilename.orElse(null));
            try (InputStream in = Files.newInputStream(getSourceFile().get())) {
                loader.load(in, base, format, rdfHandler);
            }
        } else if (getSourceIri().isPresent()) {
            try {
                // TODO: Handle international IRIs properly
                // (Unicode support for for hostname, path and query)
                final URL url = new URL(getSourceIri().get().getIRIString());
                // TODO: This probably does not support https:// -> http://
                // redirections
                loader.load(url, base, formatByMimeType.orElse(null), makeRDFHandler());
            } catch (final MalformedURLException ex) {
                throw new IOException("Can't handle source URL: " + getSourceIri().get(), ex);
            }
        }
        // must be getSourceInputStream then, this is guaranteed by
        // super.checkSource();
        loader.load(getSourceInputStream().get(), base, formatByMimeType.orElse(null), rdfHandler);
    }
// (Unicode support for for hostname, path and query)
final URL url = new URL(getSourceIri().get().getIRIString());
// TODO: This probably does not support https:// -> http://
// redirections
loader.load(url, base, formatByMimeType.orElse(null), makeRDFHandler());
} catch (final MalformedURLException ex) {
// symlinks?
final RDFFormat format = formatByMimeType.orElse(formatByFilename.orElse(null));
try (InputStream in = Files.newInputStream(getSourceFile().get())) {
loader.load(in, base, format, rdfHandler);
}
} else if (getSourceIri().isPresent()) {
try {
// TODO: Handle international IRIs properly
// (Unicode support for for hostname, path and query)
final URL url = new URL(getSourceIri().get().getIRIString());
// TODO: This probably does not support https:// -> http://
// redirections
loader.load(url, base, formatByMimeType.orElse(null), makeRDFHandler());
} catch (final MalformedURLException ex) {
throw new IOException("Can't handle source URL: " + getSourceIri().get(), ex);
}
}
// must be getSourceInputStream then, this is guaranteed by
// super.checkSource();
loader.load(getSourceInputStream().get(), base, formatByMimeType.orElse(null), rdfHandler);
}
// loader.load(sourcePath.toFile()
// if the path fs provider == FileSystems.getDefault(),
// that RDFLoader method does not use absolute path
// as the base URI, so to be consistent
// we'll always do it with our own input stream
//
// That means we may have to guess format by extensions:
final Optional<RDFFormat> formatByFilename = getSourceFile().map(Path::getFileName).map(Path::toString)
.flatMap(Rio::getParserFormatForFileName);
// TODO: for the excited.. what about the extension after following
// symlinks?
final RDFFormat format = formatByMimeType.orElse(formatByFilename.orElse(null));
try (InputStream in = Files.newInputStream(getSourceFile().get())) {
loader.load(in, base, format, rdfHandler);
}
} else if (getSourceIri().isPresent()) {
try {
// TODO: Handle international IRIs properly
// (Unicode support for for hostname, path and query)
final URL url = new URL(getSourceIri().get().getIRIString());
// TODO: This probably does not support https:// -> http://
// redirections
loader.load(url, base, formatByMimeType.orElse(null), makeRDFHandler());
} catch (final MalformedURLException ex) {
throw new IOException("Can't handle source URL: " + getSourceIri().get(), ex);
}
}
// must be getSourceInputStream then, this is guaranteed by
// super.checkSource();
loader.load(getSourceInputStream().get(), base, formatByMimeType.orElse(null), rdfHandler);
}