use of org.openrdf.rio.RDFHandlerException in project qi4j-sdk by Qi4j.
the class EntityResource method representRdfXml.
private Representation representRdfXml(final EntityState entity) throws ResourceException {
Representation representation = new WriterRepresentation(MediaType.APPLICATION_RDF_XML) {
@Override
public void write(Writer writer) throws IOException {
try {
Iterable<Statement> statements = entitySerializer.serialize(entity);
new RdfXmlSerializer().serialize(statements, writer);
} catch (RDFHandlerException e) {
throw new IOException(e);
}
}
};
representation.setCharacterSet(CharacterSet.UTF_8);
return representation;
}
use of org.openrdf.rio.RDFHandlerException in project gocd by gocd.
the class SesameGraph method dumpTriplesNotInContext.
private void dumpTriplesNotInContext(Writer writer) {
try {
writer.append("Statements not in any context: \n");
} catch (IOException e) {
throw new RuntimeException(e);
}
RDFXMLWriter xmlWriter = new RDFXMLWriter(writer);
xmlWriter.startRDF();
try {
RepositoryResult<Statement> result = conn.getStatements(null, null, null, false);
while (result.hasNext()) {
Statement statement = result.next();
if (statement.getContext() == null) {
xmlWriter.handleStatement(statement);
}
}
} catch (RepositoryException | RDFHandlerException e) {
throw new RuntimeException(e);
} finally {
try {
xmlWriter.endRDF();
} catch (RDFHandlerException e) {
throw new RuntimeException(e);
}
}
}
Aggregations