@Override public void close() throws IOException { try { if (writingStarted) { endRDF(); } } catch (RDFHandlerException e) { if (e.getCause() != null && e.getCause() instanceof IOException) { throw (IOException)e.getCause(); } else { throw new IOException(e); } } finally { nodeStack.clear(); predicateStack.clear(); writer.close(); } }
@Override public void close() throws IOException { try { if (writingStarted) { endRDF(); } } catch (RDFHandlerException e) { if (e.getCause() != null && e.getCause() instanceof IOException) { throw (IOException)e.getCause(); } else { throw new IOException(e); } } finally { nodeStack.clear(); predicateStack.clear(); writer.close(); } }
@Override public void close() throws IOException { try { if (writingStarted) { endRDF(); } } catch (RDFHandlerException e) { if (e.getCause() != null && e.getCause() instanceof IOException) { throw (IOException)e.getCause(); } else { throw new IOException(e); } } finally { nodeStack.clear(); predicateStack.clear(); writer.close(); } }
@Override public void flush() throws IOException { if (writingStarted) { if (!headerWritten) { writeHeader(); } try { flushPendingStatements(); } catch (RDFHandlerException e) { if (e.getCause() != null && e.getCause() instanceof IOException) { throw (IOException)e.getCause(); } else { throw new IOException(e); } } writer.flush(); } }
@Override public void flush() throws IOException { if (writingStarted) { if (!headerWritten) { writeHeader(); } try { flushPendingStatements(); } catch (RDFHandlerException e) { if (e.getCause() != null && e.getCause() instanceof IOException) { throw (IOException)e.getCause(); } else { throw new IOException(e); } } writer.flush(); } }
@Override public void flush() throws IOException { if (writingStarted) { if (!headerWritten) { writeHeader(); } try { flushPendingStatements(); } catch (RDFHandlerException e) { if (e.getCause() != null && e.getCause() instanceof IOException) { throw (IOException)e.getCause(); } else { throw new IOException(e); } } writer.flush(); } }
@Override protected void removeWithoutCommit(Resource subject, IRI predicate, Value object, Resource... contexts) throws RepositoryException { IRI[] archiveContexts = getArchiveContexts(); if (archiveContexts.length > 0) { RDFHandler handler = new RDFInserter(getDelegate()); try { getDelegate().exportStatements(subject, predicate, object, true, handler, archiveContexts); } catch (RDFHandlerException e) { if (e.getCause() instanceof RepositoryException) { throw (RepositoryException)e.getCause(); } throw new AssertionError(e); } } if (isAllContext(contexts)) { getDelegate().remove(subject, predicate, object, getRemoveContexts()); } else { getDelegate().remove(subject, predicate, object, contexts); } }
@Override protected void removeWithoutCommit(Resource subject, IRI predicate, Value object, Resource... contexts) throws RepositoryException { IRI[] archiveContexts = getArchiveContexts(); if (archiveContexts.length > 0) { RDFHandler handler = new RDFInserter(getDelegate()); try { getDelegate().exportStatements(subject, predicate, object, true, handler, archiveContexts); } catch (RDFHandlerException e) { if (e.getCause() instanceof RepositoryException) { throw (RepositoryException)e.getCause(); } throw new AssertionError(e); } } if (isAllContext(contexts)) { getDelegate().remove(subject, predicate, object, getRemoveContexts()); } else { getDelegate().remove(subject, predicate, object, contexts); } }
@Override protected void removeWithoutCommit(Resource subject, IRI predicate, Value object, Resource... contexts) throws RepositoryException { IRI[] archiveContexts = getArchiveContexts(); if (archiveContexts.length > 0) { RDFHandler handler = new RDFInserter(getDelegate()); try { getDelegate().exportStatements(subject, predicate, object, true, handler, archiveContexts); } catch (RDFHandlerException e) { if (e.getCause() instanceof RepositoryException) { throw (RepositoryException)e.getCause(); } throw new AssertionError(e); } } if (isAllContext(contexts)) { getDelegate().remove(subject, predicate, object, getRemoveContexts()); } else { getDelegate().remove(subject, predicate, object, contexts); } }
@Override public void importRdf(CachedLog input, String baseUri, String defaultGraph, RdfProcessor rdfProcessor) throws RdfProcessingFailedException, RdfProcessingParseException { try { RDFFormat format = Rio.getParserFormatForMIMEType(input.getMimeType().toString()) .orElseThrow( () -> new UnsupportedRDFormatException(input.getMimeType() + " is not a supported rdf type.") ); RDFParser rdfParser = Rio.createParser(format); rdfParser.setPreserveBNodeIDs(true); rdfParser.setRDFHandler(new TimRdfHandler(rdfProcessor, defaultGraph, input.getFile().getName())); rdfParser.parse(input.getReader(), baseUri); } catch (IOException e) { throw new RdfProcessingFailedException(e); } catch (RDFParseException e) { throw new Rdf4jRdfProcessingParseException(e, input); } catch (UnsupportedRDFormatException e) { throw new RdfProcessingFailedException(e); } catch (RDFHandlerException e) { if (e.getCause() instanceof RdfProcessingFailedException) { throw (RdfProcessingFailedException) e.getCause(); } else { throw new RdfProcessingFailedException(e); } } } }
protected void executeLoad(Load load, UpdateContext uc) throws IOException, RDFParseException, SailException { Value source = load.getSource().getValue(); Value graph = load.getGraph() != null ? load.getGraph().getValue() : null; URL sourceURL = new URL(source.stringValue()); RDFSailInserter rdfInserter = new RDFSailInserter(con, vf, uc); if (graph != null) { rdfInserter.enforceContext((Resource)graph); } try { loader.load(sourceURL, source.stringValue(), null, rdfInserter); } catch (RDFHandlerException e) { // RDFSailInserter only throws wrapped SailExceptions throw (SailException)e.getCause(); } }
@Override public void add(final InputStream in, final String baseURI, final RDFFormat dataFormat, final Resource... contexts) throws IOException, RDFParseException, RepositoryException { OpenRDFUtil.verifyContextNotNull(contexts); final CombineContextsRdfInserter rdfInserter = new CombineContextsRdfInserter(this); rdfInserter.enforceContext(contexts); final boolean localTransaction = startLocalTransaction(); try { final RDFLoader loader = new RDFLoader(getParserConfig(), getValueFactory()); loader.load(in, baseURI, dataFormat, rdfInserter); conditionalCommit(localTransaction); } catch (final RDFHandlerException e) { conditionalRollback(localTransaction); throw ((RepositoryException) e.getCause()); } catch (final IOException | RuntimeException e) { conditionalRollback(localTransaction); throw e; } }
@Override public void add(final Reader reader, final String baseURI, final RDFFormat dataFormat, final Resource... contexts) throws IOException, RDFParseException, RepositoryException { OpenRDFUtil.verifyContextNotNull(contexts); final CombineContextsRdfInserter rdfInserter = new CombineContextsRdfInserter(this); rdfInserter.enforceContext(contexts); final boolean localTransaction = startLocalTransaction(); try { final RDFLoader loader = new RDFLoader(getParserConfig(), getValueFactory()); loader.load(reader, baseURI, dataFormat, rdfInserter); conditionalCommit(localTransaction); } catch (final RDFHandlerException e) { conditionalRollback(localTransaction); throw ((RepositoryException) e.getCause()); } catch (final IOException | RuntimeException e) { conditionalRollback(localTransaction); throw e; } } }
throw (RepositoryException)e.getCause();
throw (RepositoryException)e.getCause();
throw (RepositoryException)e.getCause();
throw (RepositoryException)e.getCause();
throw (RepositoryException)e.getCause();
throw (RepositoryException)e.getCause();
throw (RepositoryException)e.getCause();