@Test void testMalformedInput() { final ByteArrayInputStream in = new ByteArrayInputStream("<> <ex:test> a Literal\" . ".getBytes(UTF_8)); assertThrows(TrellisRuntimeException.class, () -> service.read(in, TURTLE, null), "No exception on malformed input!"); }
@Override public Stream<Triple> read(final InputStream input, final RDFSyntax syntax, final String base) { requireNonNull(input, "The input stream may not be null!"); requireNonNull(syntax, "The syntax value may not be null!"); try { final org.apache.jena.graph.Graph graph = createDefaultGraph(); final Lang lang = JenaCommonsRDF.toJena(syntax).orElseThrow(() -> new TrellisRuntimeException("Unsupported RDF Syntax: " + syntax.mediaType())); RDFParser.source(input).lang(lang).base(base).parse(graph); final Set<String> namespaces = new HashSet<>(nsService.getNamespaces().values()); graph.getPrefixMapping().getNsPrefixMap().forEach((prefix, namespace) -> { if (shouldAddNamespace(namespaces, namespace, base)) { LOGGER.debug("Setting prefix ({}) for namespace {}", prefix, namespace); nsService.setPrefix(prefix, namespace); } }); return JenaCommonsRDF.fromJena(graph).stream().map(Triple.class::cast); } catch (final RiotException | AtlasException | IllegalArgumentException ex) { throw new TrellisRuntimeException(ex); } }
JenaIOService implements IOService { @Override public Stream<Triple> read(final InputStream input, final RDFSyntax syntax, final String base) { requireNonNull(input, "The input stream may not be null!"); requireNonNull(syntax, "The syntax value may not be null!"); try { final org.apache.jena.graph.Graph graph = createDefaultGraph(); final Lang lang = JenaCommonsRDF.toJena(syntax).orElseThrow(() -> new TrellisRuntimeException("Unsupported RDF Syntax: " + syntax.mediaType())); RDFParser.source(input).lang(lang).base(base).parse(graph); final Set<String> namespaces = new HashSet<>(nsService.getNamespaces().values()); graph.getPrefixMapping().getNsPrefixMap().forEach((prefix, namespace) -> { if (shouldAddNamespace(namespaces, namespace, base)) { LOGGER.debug("Setting prefix ({}) for namespace {}", prefix, namespace); nsService.setPrefix(prefix, namespace); } }); return JenaCommonsRDF.fromJena(graph).stream().map(Triple.class::cast); } catch (final RiotException | AtlasException | IllegalArgumentException ex) { throw new TrellisRuntimeException(ex); } } }
JenaIOService implements IOService { @Override public Stream<Triple> read(final InputStream input, final RDFSyntax syntax, final String base) { requireNonNull(input, "The input stream may not be null!"); requireNonNull(syntax, "The syntax value may not be null!"); try { final org.apache.jena.graph.Graph graph = createDefaultGraph(); final Lang lang = JenaCommonsRDF.toJena(syntax).orElseThrow(() -> new TrellisRuntimeException("Unsupported RDF Syntax: " + syntax.mediaType())); RDFParser.source(input).lang(lang).base(base).parse(graph); final Set<String> namespaces = new HashSet<>(nsService.getNamespaces().values()); graph.getPrefixMapping().getNsPrefixMap().forEach((prefix, namespace) -> { if (shouldAddNamespace(namespaces, namespace, base)) { LOGGER.debug("Setting prefix ({}) for namespace {}", prefix, namespace); nsService.setPrefix(prefix, namespace); } }); return JenaCommonsRDF.fromJena(graph).stream().map(Triple.class::cast); } catch (final RiotException | AtlasException | IllegalArgumentException ex) { throw new TrellisRuntimeException(ex); } } JenaIOService();  JenaIOService(final NamespaceService namespaceService);  JenaIOService(final NamespaceService namespaceService, final RDFaWriterService htmlSerializer); @Inject  JenaIOService(final NamespaceService namespaceService,
            final RDFaWriterService htmlSerializer,
            @TrellisProfileCache final CacheService<String, String> cache); private  JenaIOService(final NamespaceService namespaceService, final RDFaWriterService htmlSerializer,
            final CacheService<String, String> cache, final Config config);  JenaIOService(final NamespaceService namespaceService, final RDFaWriterService htmlSerializer,
            final CacheService<String, String> cache, final String allowedContexts, final String allowedContextDomains,
            final boolean relativeIRIs);  JenaIOService(final NamespaceService namespaceService, final RDFaWriterService htmlSerializer,
            final CacheService<String, String> cache, final Set<String> allowedContexts,
            final Set<String> allowedContextDomains, final boolean relativeIRIs); }
JenaIOService implements IOService { @Override public Stream<Triple> read(final InputStream input, final RDFSyntax syntax, final String base) { requireNonNull(input, "The input stream may not be null!"); requireNonNull(syntax, "The syntax value may not be null!"); try { final org.apache.jena.graph.Graph graph = createDefaultGraph(); final Lang lang = JenaCommonsRDF.toJena(syntax).orElseThrow(() -> new TrellisRuntimeException("Unsupported RDF Syntax: " + syntax.mediaType())); RDFParser.source(input).lang(lang).base(base).parse(graph); final Set<String> namespaces = new HashSet<>(nsService.getNamespaces().values()); graph.getPrefixMapping().getNsPrefixMap().forEach((prefix, namespace) -> { if (shouldAddNamespace(namespaces, namespace, base)) { LOGGER.debug("Setting prefix ({}) for namespace {}", prefix, namespace); nsService.setPrefix(prefix, namespace); } }); return JenaCommonsRDF.fromJena(graph).stream().map(Triple.class::cast); } catch (final RiotException | AtlasException | IllegalArgumentException ex) { throw new TrellisRuntimeException(ex); } } JenaIOService();  JenaIOService(final NamespaceService namespaceService);  JenaIOService(final NamespaceService namespaceService, final RDFaWriterService htmlSerializer); @Inject  JenaIOService(final NamespaceService namespaceService,
            final RDFaWriterService htmlSerializer,
            @TrellisProfileCache final CacheService<String, String> cache); private  JenaIOService(final NamespaceService namespaceService, final RDFaWriterService htmlSerializer,
            final CacheService<String, String> cache, final Config config);  JenaIOService(final NamespaceService namespaceService, final RDFaWriterService htmlSerializer,
            final CacheService<String, String> cache, final String allowedContexts, final String allowedContextDomains,
            final boolean relativeIRIs);  JenaIOService(final NamespaceService namespaceService, final RDFaWriterService htmlSerializer,
            final CacheService<String, String> cache, final Set<String> allowedContexts,
            final Set<String> allowedContextDomains, final boolean relativeIRIs); @Override List<RDFSyntax> supportedReadSyntaxes(); @Override List<RDFSyntax> supportedWriteSyntaxes(); @Override List<RDFSyntax> supportedUpdateSyntaxes(); @Override void write(final Stream<Triple> triples, final OutputStream output, final RDFSyntax syntax,
            final String baseUrl, final IRI... profiles); @Override Stream<Triple> read(final InputStream input, final RDFSyntax syntax, final String base); @Override void update(final Graph graph, final String update, final RDFSyntax syntax, final String base); }
JenaIOService implements IOService { @Override public Stream<Triple> read(final InputStream input, final RDFSyntax syntax, final String base) { requireNonNull(input, "The input stream may not be null!"); requireNonNull(syntax, "The syntax value may not be null!"); try { final org.apache.jena.graph.Graph graph = createDefaultGraph(); final Lang lang = JenaCommonsRDF.toJena(syntax).orElseThrow(() -> new TrellisRuntimeException("Unsupported RDF Syntax: " + syntax.mediaType())); RDFParser.source(input).lang(lang).base(base).parse(graph); final Set<String> namespaces = new HashSet<>(nsService.getNamespaces().values()); graph.getPrefixMapping().getNsPrefixMap().forEach((prefix, namespace) -> { if (shouldAddNamespace(namespaces, namespace, base)) { LOGGER.debug("Setting prefix ({}) for namespace {}", prefix, namespace); nsService.setPrefix(prefix, namespace); } }); return JenaCommonsRDF.fromJena(graph).stream().map(Triple.class::cast); } catch (final RiotException | AtlasException | IllegalArgumentException ex) { throw new TrellisRuntimeException(ex); } } JenaIOService();  JenaIOService(final NamespaceService namespaceService);  JenaIOService(final NamespaceService namespaceService, final RDFaWriterService htmlSerializer); @Inject  JenaIOService(final NamespaceService namespaceService,
            final RDFaWriterService htmlSerializer,
            @TrellisProfileCache final CacheService<String, String> cache); private  JenaIOService(final NamespaceService namespaceService, final RDFaWriterService htmlSerializer,
            final CacheService<String, String> cache, final Config config);  JenaIOService(final NamespaceService namespaceService, final RDFaWriterService htmlSerializer,
            final CacheService<String, String> cache, final String allowedContexts, final String allowedContextDomains,
            final boolean relativeIRIs);  JenaIOService(final NamespaceService namespaceService, final RDFaWriterService htmlSerializer,
            final CacheService<String, String> cache, final Set<String> allowedContexts,
            final Set<String> allowedContextDomains, final boolean relativeIRIs); @Override List<RDFSyntax> supportedReadSyntaxes(); @Override List<RDFSyntax> supportedWriteSyntaxes(); @Override List<RDFSyntax> supportedUpdateSyntaxes(); @Override void write(final Stream<Triple> triples, final OutputStream output, final RDFSyntax syntax,
            final String baseUrl, final IRI... profiles); @Override Stream<Triple> read(final InputStream input, final RDFSyntax syntax, final String base); @Override void update(final Graph graph, final String update, final RDFSyntax syntax, final String base); static final String CONFIG_IO_JSONLD_PROFILES; static final String CONFIG_IO_JSONLD_DOMAINS; static final String CONFIG_IO_RELATIVE_IRIS; }