/** * Load data from the reader given as first argument into the handler given as second argument. * * @param reader character stream to read the data from; must be plain data in the format given as argument * @param handler handler to add the data to * @param format format to use for creating the parser * @throws RDFParseException * @throws IOException */ public void load(Reader reader, LoaderHandler handler, RDFFormat format) throws RDFParseException, IOException { try { RDFParser parser = createParser(format); parser.setRDFHandler(handler); parser.parse(reader,configuration.getString(LoaderOptions.BASE_URI, "http://localhost/")); } catch (RDFHandlerException e) { log.error("error loading stream data in format {}: {}", format, e.getMessage()); } }
/** * Load data from the inputstream given as first argument into the handler given as second argument. * * @param inStream input byte stream to read the data from; must be plain data in the format given as argument * @param handler handler to add the data to * @param format format to use for creating the parser * @throws RDFParseException * @throws IOException */ public void load(InputStream inStream, LoaderHandler handler, RDFFormat format) throws RDFParseException, IOException { try { RDFParser parser = createParser(format); parser.setRDFHandler(handler); parser.parse(inStream,configuration.getString(LoaderOptions.BASE_URI, "http://localhost/")); } catch (RDFHandlerException e) { log.error("error loading stream data in format {}: {}", format, e.getMessage()); } }
/** * Load data from the inputstream given as first argument into the handler given as second argument. * * @param inStream input byte stream to read the data from; must be plain data in the format given as argument * @param handler handler to add the data to * @param format format to use for creating the parser * @throws RDFParseException * @throws IOException */ public void load(InputStream inStream, LoaderHandler handler, RDFFormat format) throws RDFParseException, IOException { try { RDFParser parser = createParser(format); parser.setRDFHandler(handler); parser.parse(inStream,configuration.getString(LoaderOptions.BASE_URI, "http://localhost/")); } catch (RDFHandlerException e) { log.error("error loading stream data in format {}: {}", format, e.getMessage()); } }
/** * Load data from the reader given as first argument into the handler given as second argument. * * @param reader character stream to read the data from; must be plain data in the format given as argument * @param handler handler to add the data to * @param format format to use for creating the parser * @throws RDFParseException * @throws IOException */ public void load(Reader reader, LoaderHandler handler, RDFFormat format) throws RDFParseException, IOException { try { RDFParser parser = createParser(format); parser.setRDFHandler(handler); parser.parse(reader,configuration.getString(LoaderOptions.BASE_URI, "http://localhost/")); } catch (RDFHandlerException e) { log.error("error loading stream data in format {}: {}", format, e.getMessage()); } }
response.sendError(SC_INTERNAL_SERVER_ERROR, "Serialization error: " + e.getMessage());
public void close() throws IOException { try { if (writingStarted) { endRDF(); } } catch (RDFHandlerException e) { if (e.getCause() instanceof IOException) { throw (IOException)e.getCause(); } else { IOException ioe = new IOException(e.getMessage()); ioe.initCause(e); throw ioe; } } finally { writer.close(); } }
public void parse(URL url) { // Parse the data from inputStream, // resolving any relative URIs against the URL of the source // Set statement and error handler _parser.setParseErrorListener(new RetrieverErrorListener()); _parser.setRDFHandler(this); try { List<String> mimetypes = _parser.getRDFFormat().getMIMETypes(); InputStream input = Util.getDocumentAsInputStream(url.toString(), mimetypes); _parser.parse(input, url.toString()); } catch (RDFParseException e) { _logger.error(e.getMessage(), e); } catch (RDFHandlerException e) { _logger.error(e.getMessage(), e); } catch (HttpException e) { _logger.error(e.getMessage(), e); } catch (IOException e) { _logger.error(e.getMessage(), e); } }
public void load(G g, InputStream inputStream) throws SLIB_Ex_Critic { RDFHandler rdfHandler = new SlibRdfHandler(g); try { logger.info("Parser loaded for: " + parser.getRDFFormat()); parser.setRDFHandler(rdfHandler); logger.info("Parsing RDF file..."); parser.parse(inputStream, ""); } catch (IOException e) { throw new SLIB_Ex_Critic(e.getMessage()); } catch (RDFParseException e) { throw new SLIB_Ex_Critic(e.getMessage()); } catch (RDFHandlerException e) { throw new SLIB_Ex_Critic(e.getMessage()); } }
@Override public void write(OutputStream output) throws IOException, WebApplicationException { try { final RepositoryConnection outputConn = sesameService.getConnection(); try { outputConn.begin(); ldpService.exportResource(outputConn, resource, output, format, preference); outputConn.commit(); } catch (RDFHandlerException e) { outputConn.rollback(); throw new NoLogWebApplicationException(e, createResponse(Response.status(Response.Status.INTERNAL_SERVER_ERROR)).entity(e.getMessage()).build()); } catch (final Throwable t) { outputConn.rollback(); throw t; } finally { outputConn.close(); } } catch (RepositoryException e) { throw new WebApplicationException(e, createResponse(Response.status(Response.Status.INTERNAL_SERVER_ERROR)).entity(e).build()); } } };
public void load(G g, InputStream inputStream) throws SLIB_Ex_Critic { RDFHandler rdfHandler = new SlibRdfHandler(g); try { logger.info("Parser loaded for: " + parser.getRDFFormat()); parser.setRDFHandler(rdfHandler); logger.info("Parsing RDF file..."); parser.parse(inputStream, ""); } catch (IOException e) { throw new SLIB_Ex_Critic(e.getMessage()); } catch (RDFParseException e) { throw new SLIB_Ex_Critic(e.getMessage()); } catch (RDFHandlerException e) { throw new SLIB_Ex_Critic(e.getMessage()); } }
public static void writeDataset(IDataset dataset, OutputStream out) throws IOException { try { TriXWriter w = new TriXWriter(out); w.startRDF(); CloseableIterator<Statement> itr = dataset.getStatements(); while (itr.hasNext()) { Statement stmt = itr.next(); w.handleStatement(stmt); } w.endRDF(); } catch (RDFHandlerException e) { throw new IOException(e.getMessage()); } }
public static boolean toBooleanQueryResult(Iterable<? extends Statement> dawgGraph) throws DAWGTestResultSetParseException { DAWGTestBooleanParser parser = new DAWGTestBooleanParser(); try { parser.startRDF(); for (Statement st : dawgGraph) { parser.handleStatement(st); } parser.endRDF(); return parser.getValue(); } catch (RDFHandlerException e) { throw new DAWGTestResultSetParseException(e.getMessage(), e); } } }
public static boolean toBooleanQueryResult(Iterable<? extends Statement> dawgGraph) throws DAWGTestResultSetParseException { DAWGTestBooleanParser parser = new DAWGTestBooleanParser(); try { parser.startRDF(); for (Statement st : dawgGraph) { parser.handleStatement(st); } parser.endRDF(); return parser.getValue(); } catch (RDFHandlerException e) { throw new DAWGTestResultSetParseException(e.getMessage(), e); } } }
@Override public void export(Format format, Map<String, String> ns2prefix, UID context, OutputStream out){ RDFFormat targetFormat = FormatHelper.getFormat(format); RDFWriter writer = Rio.createWriter(targetFormat, out); try { RepositoryConnection conn = repository.getConnection(); for(Map.Entry<String, String> entry : ns2prefix.entrySet()){ conn.setNamespace(entry.getValue(), entry.getKey()); } try{ if (context != null){ conn.export(writer, valueFactory.createURI(context.getId())); }else{ conn.export(writer); } }finally{ conn.close(); } } catch (StoreException e) { throw new RepositoryException(e.getMessage(), e); } catch (RDFHandlerException e) { throw new RepositoryException(e.getMessage(), e); } }
@Override public void export(Format format, Map<String, String> ns2prefix, UID context, OutputStream out) { RDFFormat targetFormat = FormatHelper.getFormat(format); RDFWriter writer = Rio.createWriter(targetFormat, out); try { RepositoryConnection conn = repository.getConnection(); for (Map.Entry<String, String> entry : ns2prefix.entrySet()) { conn.setNamespace(entry.getValue(), entry.getKey()); } try { if (context != null) { conn.export(writer, valueFactory.createURI(context.getId())); } else { conn.export(writer); } } finally { conn.close(); } } catch (StoreException e) { throw new RepositoryException(e.getMessage(), e); } catch (RDFHandlerException e) { throw new RepositoryException(e.getMessage(), e); } }
@Override public void export(Format format, Map<String, String> ns2prefix, UID context, OutputStream out) { RDFFormat targetFormat = FormatHelper.getFormat(format); RDFWriter writer = Rio.createWriter(targetFormat, out); try { RepositoryConnection conn = repository.getConnection(); for (Map.Entry<String, String> entry : ns2prefix.entrySet()) { conn.setNamespace(entry.getValue(), entry.getKey()); } try { if (context != null) { conn.export(writer, valueFactory.createURI(context.getId())); } else { conn.export(writer); } } finally { conn.close(); } } catch (org.openrdf.repository.RepositoryException e) { throw new RepositoryException(e.getMessage(), e); } catch (RDFHandlerException e) { throw new RepositoryException(e.getMessage(), e); } }
public static TupleQueryResult toTupleQueryResult(Iterable<? extends Statement> dawgGraph) throws DAWGTestResultSetParseException { TupleQueryResultBuilder tqrBuilder = new TupleQueryResultBuilder(); DAWGTestResultSetParser parser = new DAWGTestResultSetParser(tqrBuilder); try { parser.startRDF(); for (Statement st : dawgGraph) { parser.handleStatement(st); } parser.endRDF(); return tqrBuilder.getQueryResult(); } catch (RDFHandlerException e) { throw new DAWGTestResultSetParseException(e.getMessage(), e); } }
public static TupleResult toTupleQueryResult(Iterable<? extends Statement> dawgGraph) throws DAWGTestResultSetParseException { TupleQueryResultBuilder tqrBuilder = new TupleQueryResultBuilder(); DAWGTestResultSetParser parser = new DAWGTestResultSetParser(tqrBuilder); try { parser.startRDF(); for (Statement st : dawgGraph) { parser.handleStatement(st); } parser.endRDF(); return tqrBuilder.getQueryResult(); } catch (RDFHandlerException e) { throw new DAWGTestResultSetParseException(e.getMessage(), e); } }
} catch (RDFHandlerException ex) { throw new IOException("Problem writing RDF: " + ex.getMessage(), ex);
} catch (RDFHandlerException ex) { throw new IOException("Problem writing RDF: " + ex.getMessage(), ex);