Search in sources :

Example 1 with CombineContextsRdfInserter

use of org.apache.rya.rdftriplestore.utils.CombineContextsRdfInserter in project incubator-rya by apache.

the class RyaSailRepositoryConnection method add.

@Override
public void add(InputStream in, String baseURI, RDFFormat dataFormat, Resource... contexts) throws IOException, RDFParseException, RepositoryException {
    OpenRDFUtil.verifyContextNotNull(contexts);
    CombineContextsRdfInserter rdfInserter = new CombineContextsRdfInserter(this);
    rdfInserter.enforceContext(contexts);
    boolean localTransaction = startLocalTransaction();
    try {
        RDFLoader loader = new RDFLoader(getParserConfig(), getValueFactory());
        loader.load(in, baseURI, dataFormat, rdfInserter);
        conditionalCommit(localTransaction);
    } catch (RDFHandlerException e) {
        conditionalRollback(localTransaction);
        throw ((RepositoryException) e.getCause());
    } catch (RDFParseException e) {
        conditionalRollback(localTransaction);
        throw e;
    } catch (IOException e) {
        conditionalRollback(localTransaction);
        throw e;
    } catch (RuntimeException e) {
        conditionalRollback(localTransaction);
        throw e;
    }
}
Also used : RDFHandlerException(org.openrdf.rio.RDFHandlerException) CombineContextsRdfInserter(org.apache.rya.rdftriplestore.utils.CombineContextsRdfInserter) RepositoryException(org.openrdf.repository.RepositoryException) IOException(java.io.IOException) RDFLoader(org.openrdf.repository.util.RDFLoader) RDFParseException(org.openrdf.rio.RDFParseException)

Example 2 with CombineContextsRdfInserter

use of org.apache.rya.rdftriplestore.utils.CombineContextsRdfInserter in project incubator-rya by apache.

the class RyaSailRepositoryConnection method add.

@Override
public void add(Reader reader, String baseURI, RDFFormat dataFormat, Resource... contexts) throws IOException, RDFParseException, RepositoryException {
    OpenRDFUtil.verifyContextNotNull(contexts);
    CombineContextsRdfInserter rdfInserter = new CombineContextsRdfInserter(this);
    rdfInserter.enforceContext(contexts);
    boolean localTransaction = startLocalTransaction();
    try {
        RDFLoader loader = new RDFLoader(getParserConfig(), getValueFactory());
        loader.load(reader, baseURI, dataFormat, rdfInserter);
        conditionalCommit(localTransaction);
    } catch (RDFHandlerException e) {
        conditionalRollback(localTransaction);
        throw ((RepositoryException) e.getCause());
    } catch (RDFParseException e) {
        conditionalRollback(localTransaction);
        throw e;
    } catch (IOException e) {
        conditionalRollback(localTransaction);
        throw e;
    } catch (RuntimeException e) {
        conditionalRollback(localTransaction);
        throw e;
    }
}
Also used : RDFHandlerException(org.openrdf.rio.RDFHandlerException) CombineContextsRdfInserter(org.apache.rya.rdftriplestore.utils.CombineContextsRdfInserter) RepositoryException(org.openrdf.repository.RepositoryException) IOException(java.io.IOException) RDFLoader(org.openrdf.repository.util.RDFLoader) RDFParseException(org.openrdf.rio.RDFParseException)

Aggregations

IOException (java.io.IOException)2 CombineContextsRdfInserter (org.apache.rya.rdftriplestore.utils.CombineContextsRdfInserter)2 RepositoryException (org.openrdf.repository.RepositoryException)2 RDFLoader (org.openrdf.repository.util.RDFLoader)2 RDFHandlerException (org.openrdf.rio.RDFHandlerException)2 RDFParseException (org.openrdf.rio.RDFParseException)2