use of org.eclipse.rdf4j.repository.RepositoryException in project rdf4j by eclipse.
the class HTTPRepositoryConnection method getContextIDs.
public RepositoryResult<Resource> getContextIDs() throws RepositoryException {
try {
List<Resource> contextList = new ArrayList<Resource>();
TupleQueryResult contextIDs = client.getContextIDs();
try {
while (contextIDs.hasNext()) {
BindingSet bindingSet = contextIDs.next();
Value context = bindingSet.getValue("contextID");
if (context instanceof Resource) {
contextList.add((Resource) context);
}
}
} finally {
contextIDs.close();
}
return createRepositoryResult(contextList);
} catch (QueryEvaluationException e) {
throw new RepositoryException(e);
} catch (IOException e) {
throw new RepositoryException(e);
}
}
use of org.eclipse.rdf4j.repository.RepositoryException in project rdf4j by eclipse.
the class HTTPRepositoryConnection method removeModel.
private void removeModel(Model m) throws RepositoryException {
RDFFormat format = RDFFormat.BINARY;
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
Rio.write(m, out, format);
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
client.removeData(in, null, format);
} catch (RDFHandlerException e) {
throw new RepositoryException("error while writing statement", e);
} catch (RDFParseException e) {
throw new RepositoryException(e);
} catch (IOException e) {
throw new RepositoryException(e);
}
}
use of org.eclipse.rdf4j.repository.RepositoryException in project rdf4j by eclipse.
the class SystemRepository method initialize.
@Override
public void initialize() throws RepositoryException {
super.initialize();
RepositoryConnection con = getConnection();
try {
if (con.isEmpty()) {
logger.debug("Initializing empty {} repository", ID);
con.begin();
con.setNamespace("rdf", RDF.NAMESPACE);
con.setNamespace("sys", RepositoryConfigSchema.NAMESPACE);
con.commit();
RepositoryConfig repConfig = new RepositoryConfig(ID, TITLE, new SystemRepositoryConfig());
RepositoryConfigUtil.updateRepositoryConfigs(con, repConfig);
}
} catch (RepositoryConfigException e) {
throw new RepositoryException(e.getMessage(), e);
} finally {
con.close();
}
}
use of org.eclipse.rdf4j.repository.RepositoryException in project rdf4j by eclipse.
the class LocalRepositoryManager method getRepositoryInfo.
@Override
public RepositoryInfo getRepositoryInfo(String id) {
RepositoryConfig config = getRepositoryConfig(id);
if (config == null) {
return null;
}
RepositoryInfo repInfo = new RepositoryInfo();
repInfo.setId(config.getID());
repInfo.setDescription(config.getTitle());
try {
repInfo.setLocation(getRepositoryDir(config.getID()).toURI().toURL());
} catch (MalformedURLException mue) {
throw new RepositoryException("Location of repository does not resolve to a valid URL", mue);
}
repInfo.setReadable(true);
repInfo.setWritable(true);
return repInfo;
}
use of org.eclipse.rdf4j.repository.RepositoryException in project graal by graphik-team.
the class RDF4jStore method termsByPredicatePosition.
@Override
public CloseableIterator<Term> termsByPredicatePosition(Predicate p, int position) throws AtomSetException {
TupleQuery query = null;
TupleQueryResult results = null;
try {
if (position == 0) {
query = this.connection.prepareTupleQuery(QueryLanguage.SPARQL, "SELECT DISTINCT ?x WHERE { ?x <" + utils.createURI(p) + "> ?y }");
} else if (position == 1) {
query = this.connection.prepareTupleQuery(QueryLanguage.SPARQL, "SELECT DISTINCT ?x WHERE { ?y <" + utils.createURI(p) + "> ?x }");
} else {
throw new WrongArityException("Position should be 0 for subject or 1 for object.");
}
results = query.evaluate();
} catch (RepositoryException e) {
throw new AtomSetException(e);
} catch (MalformedQueryException e) {
throw new AtomSetException(e);
} catch (QueryEvaluationException e) {
throw new AtomSetException(e);
}
return new TermsIterator(results, "x", this.utils);
}
Aggregations