use of org.eclipse.rdf4j.rio.RDFParserRegistry in project AJAN-service by aantakli.
the class RDFConsumer method readFrom.
@Override
public Model readFrom(final Class<Model> t, final Type type, final Annotation[] annts, final MediaType mt, final MultivaluedMap<String, String> mm, final InputStream in) throws IOException, WebApplicationException {
RDFParserRegistry registry = RDFParserRegistry.getInstance();
Optional<RDFFormat> format = registry.getFileFormatForMIMEType(mt.toString());
if (!format.isPresent()) {
String msg = "Can not consume RDF of mimetype + " + mt.toString();
Response response = Response.status(Response.Status.BAD_REQUEST).type(MediaType.TEXT_PLAIN).entity(msg).build();
throw new WebApplicationException(response);
}
Model input = Rio.parse(in, TURTLE_BASE_URI, format.get());
return AgentUtil.setMessageInformation(input, mm);
}
use of org.eclipse.rdf4j.rio.RDFParserRegistry in project AJAN-service by aantakli.
the class MAJANServiceHandler method getRDFFormat.
private RDFFormat getRDFFormat(String contentType) {
RDFParserRegistry registry = RDFParserRegistry.getInstance();
Optional<RDFFormat> format = registry.getFileFormatForMIMEType(contentType);
if (!format.isPresent()) {
return null;
}
return format.get();
}
use of org.eclipse.rdf4j.rio.RDFParserRegistry in project AJAN-service by aantakli.
the class RDFConsumer method isReadable.
@Override
public boolean isReadable(final Class<?> type, final Type type1, final Annotation[] antns, final MediaType mt) {
if (!type.isAssignableFrom(Model.class)) {
return false;
}
RDFParserRegistry registry = RDFParserRegistry.getInstance();
Optional<RDFFormat> format = registry.getFileFormatForMIMEType(mt.toString());
return format.isPresent();
}
Aggregations