org.apache.jena.datatypes.DatatypeFormatException Java Examples
The following examples show how to use
org.apache.jena.datatypes.DatatypeFormatException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SourcePlan.java From sparql-generate with Apache License 2.0 | 5 votes |
final protected Binding exec( final Binding binding, final Context context) { LOG.debug("Start " + this); Objects.nonNull(binding); // generate the source URI. final String sourceUri = getActualSource(binding); final String acceptHeader = getAcceptHeader(binding); LOG.trace("... resolved to SOURCE <" + sourceUri + "> ACCEPT " + acceptHeader + " AS " + var); final LookUpRequest request = new LookUpRequest(sourceUri, acceptHeader); final SPARQLExtStreamManager sm = (SPARQLExtStreamManager) context.get(SysRIOT.sysStreamManager); Objects.requireNonNull(sm); final TypedInputStream stream = sm.open(request); if (stream == null) { LOG.info("Exec SOURCE <" + sourceUri + "> ACCEPT " + acceptHeader + " AS " + var + " returned nothing."); return BindingFactory.binding(binding); } try (InputStream in = stream.getInputStream()) { final String literal = IOUtils.toString(in, "UTF-8"); final RDFDatatype dt; if (stream.getMediaType() != null && stream.getMediaType().getContentType() != null) { dt = tm.getSafeTypeByName("http://www.iana.org/assignments/media-types/" + stream.getMediaType().getContentType()); } else { dt = tm.getSafeTypeByName("http://www.w3.org/2001/XMLSchema#string"); } final Node n = NodeFactory.createLiteral(literal, dt); LOG.debug("Exec " + this + " returned. " + "Enable TRACE level for more."); if (LOG.isTraceEnabled()) { LOG.trace("Exec " + this + " returned\n" + LogUtils.compress(n)); } return BindingFactory.binding(binding, var, n); } catch (IOException | DatatypeFormatException ex) { LOG.warn("Exception while looking up " + sourceUri + ":", ex); return BindingFactory.binding(binding); } }
Example #2
Source File: DatatypeFormatExceptionMapper.java From Processor with Apache License 2.0 | 5 votes |
@Override public Response toResponse(DatatypeFormatException ex) { return getResponseBuilder(DatasetFactory.create(toResource(ex, Response.Status.BAD_REQUEST, ResourceFactory.createResource("http://www.w3.org/2011/http-statusCodes#BadRequest")). getModel())). status(Response.Status.BAD_REQUEST). build(); }