@Test void testWriteInvalidSyntax() { when(mockSyntax.mediaType()).thenReturn("fake/mediatype"); final ByteArrayOutputStream out = new ByteArrayOutputStream(); final Stream<Triple> triples = getTriples(); assertThrows(TrellisRuntimeException.class, () -> service.write(triples, out, mockSyntax, identifier), "No exception thrown with invalid write syntax!"); }
@Override public void write(final Stream<Triple> triples, final OutputStream output, final RDFSyntax syntax, final String baseUrl, final IRI... profiles) { requireNonNull(triples, "The triples stream may not be null!"); requireNonNull(output, "The output stream may not be null!"); requireNonNull(syntax, "The RDF syntax value may not be null!"); try { if (RDFA.equals(syntax)) { writeHTML(triples, output, baseUrl); } else { final Lang lang = JenaCommonsRDF.toJena(syntax).orElseThrow(() -> new TrellisRuntimeException("Invalid content type: " + syntax.mediaType())); final RDFFormat format = defaultSerialization(lang); if (format != null) { LOGGER.debug("Writing stream-based RDF: {}", format); final StreamRDF stream = getWriterStream(output, format, null); stream.start(); nsService.getNamespaces().forEach(stream::prefix); if (shouldUseRelativeIRIs(relativeIRIs, profiles)) { stream.base(baseUrl); } triples.map(JenaCommonsRDF::toJena).forEachOrdered(stream::triple); stream.finish(); } else { LOGGER.debug("Writing buffered RDF: {}", lang); final org.apache.jena.graph.Graph graph = createDefaultGraph(); graph.getPrefixMapping().setNsPrefixes(nsService.getNamespaces()); triples.map(JenaCommonsRDF::toJena).forEachOrdered(graph::add); if (JSONLD.equals(lang)) { writeJsonLd(output, DatasetGraphFactory.create(graph), profiles); } else { RDFDataMgr.write(output, graph, lang); } } } } catch (final AtlasException ex) { throw new TrellisRuntimeException(ex); } }
JenaIOService implements IOService { @Override public void write(final Stream<Triple> triples, final OutputStream output, final RDFSyntax syntax, final String baseUrl, final IRI... profiles) { requireNonNull(triples, "The triples stream may not be null!"); requireNonNull(output, "The output stream may not be null!"); requireNonNull(syntax, "The RDF syntax value may not be null!"); try { if (RDFA.equals(syntax)) { writeHTML(triples, output, baseUrl); } else { final Lang lang = JenaCommonsRDF.toJena(syntax).orElseThrow(() -> new TrellisRuntimeException("Invalid content type: " + syntax.mediaType())); final RDFFormat format = defaultSerialization(lang); if (format != null) { LOGGER.debug("Writing stream-based RDF: {}", format); final StreamRDF stream = getWriterStream(output, format, null); stream.start(); nsService.getNamespaces().forEach(stream::prefix); if (shouldUseRelativeIRIs(relativeIRIs, profiles)) { stream.base(baseUrl); } triples.map(JenaCommonsRDF::toJena).forEachOrdered(stream::triple); stream.finish(); } else { LOGGER.debug("Writing buffered RDF: {}", lang); final org.apache.jena.graph.Graph graph = createDefaultGraph(); graph.getPrefixMapping().setNsPrefixes(nsService.getNamespaces()); triples.map(JenaCommonsRDF::toJena).forEachOrdered(graph::add); if (JSONLD.equals(lang)) { writeJsonLd(output, DatasetGraphFactory.create(graph), profiles); } else { RDFDataMgr.write(output, graph, lang); } } } } catch (final AtlasException ex) { throw new TrellisRuntimeException(ex); } } }
JenaIOService implements IOService { @Override public void write(final Stream<Triple> triples, final OutputStream output, final RDFSyntax syntax, final String baseUrl, final IRI... profiles) { requireNonNull(triples, "The triples stream may not be null!"); requireNonNull(output, "The output stream may not be null!"); requireNonNull(syntax, "The RDF syntax value may not be null!"); try { if (RDFA.equals(syntax)) { writeHTML(triples, output, baseUrl); } else { final Lang lang = JenaCommonsRDF.toJena(syntax).orElseThrow(() -> new TrellisRuntimeException("Invalid content type: " + syntax.mediaType())); final RDFFormat format = defaultSerialization(lang); if (format != null) { LOGGER.debug("Writing stream-based RDF: {}", format); final StreamRDF stream = getWriterStream(output, format, null); stream.start(); nsService.getNamespaces().forEach(stream::prefix); if (shouldUseRelativeIRIs(relativeIRIs, profiles)) { stream.base(baseUrl); } triples.map(JenaCommonsRDF::toJena).forEachOrdered(stream::triple); stream.finish(); } else { LOGGER.debug("Writing buffered RDF: {}", lang); final org.apache.jena.graph.Graph graph = createDefaultGraph(); graph.getPrefixMapping().setNsPrefixes(nsService.getNamespaces()); triples.map(JenaCommonsRDF::toJena).forEachOrdered(graph::add); if (JSONLD.equals(lang)) { writeJsonLd(output, DatasetGraphFactory.create(graph), profiles); } else { RDFDataMgr.write(output, graph, lang); } } } } catch (final AtlasException 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 void write(final Stream<Triple> triples, final OutputStream output, final RDFSyntax syntax, final String baseUrl, final IRI... profiles) { requireNonNull(triples, "The triples stream may not be null!"); requireNonNull(output, "The output stream may not be null!"); requireNonNull(syntax, "The RDF syntax value may not be null!"); try { if (RDFA.equals(syntax)) { writeHTML(triples, output, baseUrl); } else { final Lang lang = JenaCommonsRDF.toJena(syntax).orElseThrow(() -> new TrellisRuntimeException("Invalid content type: " + syntax.mediaType())); final RDFFormat format = defaultSerialization(lang); if (format != null) { LOGGER.debug("Writing stream-based RDF: {}", format); final StreamRDF stream = getWriterStream(output, format, null); stream.start(); nsService.getNamespaces().forEach(stream::prefix); if (shouldUseRelativeIRIs(relativeIRIs, profiles)) { stream.base(baseUrl); } triples.map(JenaCommonsRDF::toJena).forEachOrdered(stream::triple); stream.finish(); } else { LOGGER.debug("Writing buffered RDF: {}", lang); final org.apache.jena.graph.Graph graph = createDefaultGraph(); graph.getPrefixMapping().setNsPrefixes(nsService.getNamespaces()); triples.map(JenaCommonsRDF::toJena).forEachOrdered(graph::add); if (JSONLD.equals(lang)) { writeJsonLd(output, DatasetGraphFactory.create(graph), profiles); } else { RDFDataMgr.write(output, graph, lang); } } } } catch (final AtlasException 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 void write(final Stream<Triple> triples, final OutputStream output, final RDFSyntax syntax, final String baseUrl, final IRI... profiles) { requireNonNull(triples, "The triples stream may not be null!"); requireNonNull(output, "The output stream may not be null!"); requireNonNull(syntax, "The RDF syntax value may not be null!"); try { if (RDFA.equals(syntax)) { writeHTML(triples, output, baseUrl); } else { final Lang lang = JenaCommonsRDF.toJena(syntax).orElseThrow(() -> new TrellisRuntimeException("Invalid content type: " + syntax.mediaType())); final RDFFormat format = defaultSerialization(lang); if (format != null) { LOGGER.debug("Writing stream-based RDF: {}", format); final StreamRDF stream = getWriterStream(output, format, null); stream.start(); nsService.getNamespaces().forEach(stream::prefix); if (shouldUseRelativeIRIs(relativeIRIs, profiles)) { stream.base(baseUrl); } triples.map(JenaCommonsRDF::toJena).forEachOrdered(stream::triple); stream.finish(); } else { LOGGER.debug("Writing buffered RDF: {}", lang); final org.apache.jena.graph.Graph graph = createDefaultGraph(); graph.getPrefixMapping().setNsPrefixes(nsService.getNamespaces()); triples.map(JenaCommonsRDF::toJena).forEachOrdered(graph::add); if (JSONLD.equals(lang)) { writeJsonLd(output, DatasetGraphFactory.create(graph), profiles); } else { RDFDataMgr.write(output, graph, lang); } } } } catch (final AtlasException 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; }