use of org.eclipse.rdf4j.repository.Repository in project rdf4j by eclipse.
the class RepositoryManager method removeRepositoryConfig.
/**
* Removes the configuration for the specified repository from the manager's system repository if such a
* configuration is present. Returns <tt>true</tt> if the system repository actually contained the
* specified repository configuration.
*
* @param repositoryID
* The ID of the repository whose configuration needs to be removed.
* @throws RepositoryException
* If the manager failed to update it's system repository.
* @throws RepositoryConfigException
* If the manager doesn't know how to remove a configuration due to inconsistent configuration
* data in the system repository. For example, this happens when there are multiple existing
* configurations with the concerning ID.
* @deprecated since 2.6.7. Use {@link #removeRepository(String repositoryID)} instead.
*/
@Deprecated
public boolean removeRepositoryConfig(String repositoryID) throws RepositoryException, RepositoryConfigException {
logger.debug("Removing repository configuration for {}.", repositoryID);
boolean isRemoved = hasRepositoryConfig(repositoryID);
synchronized (initializedRepositories) {
// update SYSTEM repository if there is one for 2.2 compatibility
Repository systemRepository = getSystemRepository();
if (systemRepository != null) {
RepositoryConfigUtil.removeRepositoryConfigs(systemRepository, repositoryID);
}
if (isRemoved) {
logger.debug("Shutdown repository {} after removal of configuration.", repositoryID);
Repository repository = initializedRepositories.remove(repositoryID);
if (repository != null && repository.isInitialized()) {
repository.shutDown();
}
try {
cleanUpRepository(repositoryID);
} catch (IOException e) {
throw new RepositoryException("Unable to clean up resources for removed repository " + repositoryID, e);
}
}
}
return isRemoved;
}
use of org.eclipse.rdf4j.repository.Repository in project rdf4j by eclipse.
the class ContextAwareConnectionTest method testIncludeInferred.
@Test
public void testIncludeInferred() throws Exception {
RepositoryConnection stub = new RepositoryConnectionStub();
Repository repo = stub.getRepository();
ContextAwareConnection a = new ContextAwareConnection(repo, stub);
ContextAwareConnection b = new ContextAwareConnection(repo, a);
b.setIncludeInferred(true);
assertTrue(b.isIncludeInferred());
assertTrue(a.isIncludeInferred());
}
use of org.eclipse.rdf4j.repository.Repository in project rdf4j by eclipse.
the class ContextAwareConnectionTest method testQuery.
@Test
public void testQuery() throws Exception {
RepositoryConnection stub = new RepositoryConnectionStub() {
@Override
public Query prepareQuery(QueryLanguage ql, String query, String baseURI) throws MalformedQueryException, RepositoryException {
assertEquals(SPARQL, ql);
assertEquals(queryString, query);
return new QueryStub() {
@Override
public void setDataset(Dataset dataset) {
Set<IRI> contexts = Collections.singleton(context);
assertEquals(contexts, dataset.getDefaultGraphs());
super.setDataset(dataset);
}
};
}
};
Repository repo = stub.getRepository();
ContextAwareConnection con = new ContextAwareConnection(repo, stub);
con.setReadContexts(context);
con.setQueryLanguage(SERQL);
con.prepareQuery(SPARQL, queryString, null);
}
use of org.eclipse.rdf4j.repository.Repository in project rdf4j by eclipse.
the class InterceptorTest method testRemove.
@Test
public void testRemove() throws Exception {
ValueFactory vf = SimpleValueFactory.getInstance();
final IRI uri = vf.createIRI("http://example.com/");
final RepositoryConnection stub = new RepositoryConnectionStub() {
protected void removeWithoutCommit(Resource subject, IRI predicate, Value object, Resource... contexts) throws RepositoryException {
fail();
}
};
Repository repo = stub.getRepository();
InterceptingRepositoryConnection con = new InterceptingRepositoryConnectionWrapper(repo, stub);
con.addRepositoryConnectionInterceptor(new RepositoryConnectionInterceptorAdapter() {
public boolean remove(RepositoryConnection conn, Resource subject, IRI predicate, Value object, Resource... contexts) {
assertEquals(stub, conn);
assertEquals(uri, subject);
assertEquals(uri, predicate);
assertEquals(uri, object);
assertEquals(0, contexts.length);
return true;
}
});
con.remove(con.getValueFactory().createStatement(uri, uri, uri));
}
use of org.eclipse.rdf4j.repository.Repository in project rdf4j by eclipse.
the class NotifyingTest method testUpdate.
@Test
public void testUpdate() throws Exception {
final Update updateStub = new UpdateStub();
final RepositoryConnection stub = new RepositoryConnectionStub() {
public Update prepareUpdate(QueryLanguage ql, String query, String baseURI) throws MalformedQueryException, RepositoryException {
return updateStub;
}
};
Repository repo = stub.getRepository();
NotifyingRepositoryConnection con = new NotifyingRepositoryConnectionWrapper(repo, stub);
con.addRepositoryConnectionListener(new RepositoryConnectionListenerAdapter() {
public void execute(RepositoryConnection conn, QueryLanguage ql, String update, String baseURI, Update operation) {
assertEquals(stub, conn);
assertEquals(SPARQL, ql);
assertEquals("DELETE DATA { <> <> <> }", update);
assertEquals("http://example.com/", baseURI);
assertEquals(updateStub, operation);
}
});
Update update = con.prepareUpdate(SPARQL, "DELETE DATA { <> <> <> }", "http://example.com/");
update.execute();
}
Aggregations