Search in sources :

Example 1 with RDFInserter

use of org.eclipse.rdf4j.repository.util.RDFInserter in project rdf4j by eclipse.

the class AbstractRepositoryConnection method add.

@Override
public void add(File file, String baseURI, RDFFormat dataFormat, Resource... contexts) throws IOException, RDFParseException, RepositoryException {
    OpenRDFUtil.verifyContextNotNull(contexts);
    RDFInserter rdfInserter = new RDFInserter(this);
    rdfInserter.enforceContext(contexts);
    boolean localTransaction = startLocalTransaction();
    try {
        RDFLoader loader = new RDFLoader(getParserConfig(), getValueFactory());
        loader.load(file, baseURI, dataFormat, rdfInserter);
        conditionalCommit(localTransaction);
    } catch (RDFHandlerException e) {
        conditionalRollback(localTransaction);
        // RDFInserter only throws wrapped RepositoryExceptions
        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.eclipse.rdf4j.rio.RDFHandlerException) RDFInserter(org.eclipse.rdf4j.repository.util.RDFInserter) IOException(java.io.IOException) RDFLoader(org.eclipse.rdf4j.repository.util.RDFLoader) RDFParseException(org.eclipse.rdf4j.rio.RDFParseException)

Example 2 with RDFInserter

use of org.eclipse.rdf4j.repository.util.RDFInserter in project rdf4j by eclipse.

the class AbstractRepositoryConnection method add.

@Override
public void add(InputStream in, String baseURI, RDFFormat dataFormat, Resource... contexts) throws IOException, RDFParseException, RepositoryException {
    OpenRDFUtil.verifyContextNotNull(contexts);
    RDFInserter rdfInserter = new RDFInserter(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);
        // RDFInserter only throws wrapped RepositoryExceptions
        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.eclipse.rdf4j.rio.RDFHandlerException) RDFInserter(org.eclipse.rdf4j.repository.util.RDFInserter) IOException(java.io.IOException) RDFLoader(org.eclipse.rdf4j.repository.util.RDFLoader) RDFParseException(org.eclipse.rdf4j.rio.RDFParseException)

Example 3 with RDFInserter

use of org.eclipse.rdf4j.repository.util.RDFInserter in project rdf4j by eclipse.

the class AbstractRepositoryConnection method add.

@Override
public void add(URL url, String baseURI, RDFFormat dataFormat, Resource... contexts) throws IOException, RDFParseException, RepositoryException {
    OpenRDFUtil.verifyContextNotNull(contexts);
    RDFInserter rdfInserter = new RDFInserter(this);
    rdfInserter.enforceContext(contexts);
    boolean localTransaction = startLocalTransaction();
    try {
        RDFLoader loader = new RDFLoader(getParserConfig(), getValueFactory());
        loader.load(url, baseURI, dataFormat, rdfInserter);
        conditionalCommit(localTransaction);
    } catch (RDFHandlerException e) {
        conditionalRollback(localTransaction);
        // RDFInserter only throws wrapped RepositoryExceptions
        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.eclipse.rdf4j.rio.RDFHandlerException) RDFInserter(org.eclipse.rdf4j.repository.util.RDFInserter) IOException(java.io.IOException) RDFLoader(org.eclipse.rdf4j.repository.util.RDFLoader) RDFParseException(org.eclipse.rdf4j.rio.RDFParseException)

Example 4 with RDFInserter

use of org.eclipse.rdf4j.repository.util.RDFInserter in project rdf4j by eclipse.

the class AbstractRepositoryConnection method add.

@Override
public void add(Reader reader, String baseURI, RDFFormat dataFormat, Resource... contexts) throws IOException, RDFParseException, RepositoryException {
    OpenRDFUtil.verifyContextNotNull(contexts);
    RDFInserter rdfInserter = new RDFInserter(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);
        // RDFInserter only throws wrapped RepositoryExceptions
        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.eclipse.rdf4j.rio.RDFHandlerException) RDFInserter(org.eclipse.rdf4j.repository.util.RDFInserter) IOException(java.io.IOException) RDFLoader(org.eclipse.rdf4j.repository.util.RDFLoader) RDFParseException(org.eclipse.rdf4j.rio.RDFParseException)

Aggregations

IOException (java.io.IOException)4 RDFInserter (org.eclipse.rdf4j.repository.util.RDFInserter)4 RDFLoader (org.eclipse.rdf4j.repository.util.RDFLoader)4 RDFHandlerException (org.eclipse.rdf4j.rio.RDFHandlerException)4 RDFParseException (org.eclipse.rdf4j.rio.RDFParseException)4