private static RDFFormat getFormat(String format) { return RDFParserRegistry.getInstance().getFileFormatForMIMEType(format); } }
private static RDFFormat getFormat(String format) { return RDFParserRegistry.getInstance().getFileFormatForMIMEType(format); } }
mimeType = mimeType.substring(0, semiColonIdx); format = RDFParserRegistry.getInstance().getFileFormatForMIMEType(mimeType);
/** * Parse the HTTP response entity returned by the web service call and return its contents as a Sesame RDF * repository. The content type returned by the web service is passed as argument to help the implementation * decide how to parse the data. * * * @param resourceUri * @param triples *@param in input stream as returned by the remote webservice * @param contentType content type as returned in the HTTP headers of the remote webservice @return an RDF repository containing an RDF representation of the dataset located at the remote resource. * @throws java.io.IOException in case an error occurs while reading the input stream */ @Override public List<String> parseResponse(final String resourceUri, String requestUrl, Model triples, InputStream in, String contentType) throws DataRetrievalException { RDFFormat format = RDFParserRegistry.getInstance().getFileFormatForMIMEType(contentType, RDFFormat.RDFXML); try { ModelCommons.add(triples, in, resourceUri, format, new Predicate<Statement>() { @Override public boolean test(Statement param) { return StringUtils.equals(param.getSubject().stringValue(), resourceUri); } }); return Collections.emptyList(); } catch (RDFParseException e) { throw new DataRetrievalException("parse error while trying to parse remote RDF content",e); } catch (IOException e) { throw new DataRetrievalException("I/O error while trying to read remote RDF content",e); } }
/** * Parse the HTTP response entity returned by the web service call and return its contents as a Sesame RDF * repository. The content type returned by the web service is passed as argument to help the implementation * decide how to parse the data. * * * @param resourceUri * @param triples *@param in input stream as returned by the remote webservice * @param contentType content type as returned in the HTTP headers of the remote webservice @return an RDF repository containing an RDF representation of the dataset located at the remote resource. * @throws java.io.IOException in case an error occurs while reading the input stream */ @Override public List<String> parseResponse(final String resourceUri, String requestUrl, Model triples, InputStream in, String contentType) throws DataRetrievalException { RDFFormat format = RDFParserRegistry.getInstance().getFileFormatForMIMEType(contentType, RDFFormat.RDFXML); try { ModelCommons.add(triples, in, resourceUri, format, new Predicate<Statement>() { @Override public boolean test(Statement param) { return StringUtils.equals(param.getSubject().stringValue(), resourceUri); } }); return Collections.emptyList(); } catch (RDFParseException e) { throw new DataRetrievalException("parse error while trying to parse remote RDF content",e); } catch (IOException e) { throw new DataRetrievalException("I/O error while trying to read remote RDF content",e); } }
private RDFParser getParser(HttpMethod response) { for (Header header : response.getResponseHeaders("Content-Type")) { for (HeaderElement headerEl : header.getElements()) { String mimeType = headerEl.getName(); if (mimeType != null) { RDFFormat format = registry .getFileFormatForMIMEType(mimeType); RDFParserFactory factory = registry.get(format); if (factory != null) return factory.getParser(); } } } throw new UnsupportedQueryResultFormatException( "No parser factory available for this graph query result format"); } }