use of org.eclipse.rdf4j.repository.config.RepositoryConfig in project rdf4j by eclipse.
the class LocalRepositoryManagerTest method testRemoveFromSystemRepository.
@Test
public void testRemoveFromSystemRepository() {
RepositoryConfig config = manager.getRepositoryConfig(TEST_REPO);
manager.addRepositoryConfig(new RepositoryConfig(SystemRepository.ID, new SystemRepositoryConfig()));
manager.shutDown();
manager = new LocalRepositoryManager(datadir);
manager.initialize();
try (RepositoryConnection con = manager.getSystemRepository().getConnection()) {
Model model = new TreeModel();
config.setID("changed");
config.export(model, con.getValueFactory().createBNode());
con.begin();
con.add(model, con.getValueFactory().createBNode());
con.commit();
}
assertTrue(manager.hasRepositoryConfig("changed"));
try (RepositoryConnection con = manager.getSystemRepository().getConnection()) {
con.begin();
con.clear(RepositoryConfigUtil.getContext(con, config.getID()));
con.commit();
}
assertFalse(manager.hasRepositoryConfig(config.getID()));
}
use of org.eclipse.rdf4j.repository.config.RepositoryConfig in project rdf4j by eclipse.
the class LocalRepositoryManagerTest method testAddToSystemRepository.
@Test
public void testAddToSystemRepository() {
RepositoryConfig config = manager.getRepositoryConfig(TEST_REPO);
manager.addRepositoryConfig(new RepositoryConfig(SystemRepository.ID, new SystemRepositoryConfig()));
manager.shutDown();
manager = new LocalRepositoryManager(datadir);
manager.initialize();
try (RepositoryConnection con = manager.getSystemRepository().getConnection()) {
Model model = new TreeModel();
config.setID("changed");
config.export(model, con.getValueFactory().createBNode());
con.begin();
con.add(model, con.getValueFactory().createBNode());
con.commit();
}
assertTrue(manager.hasRepositoryConfig("changed"));
}
use of org.eclipse.rdf4j.repository.config.RepositoryConfig in project rdf4j by eclipse.
the class LocalRepositoryManagerTest method testModifySystemRepository.
@Test
public void testModifySystemRepository() {
RepositoryConfig config = manager.getRepositoryConfig(TEST_REPO);
manager.addRepositoryConfig(new RepositoryConfig(SystemRepository.ID, new SystemRepositoryConfig()));
manager.shutDown();
manager = new LocalRepositoryManager(datadir);
manager.initialize();
try (RepositoryConnection con = manager.getSystemRepository().getConnection()) {
Model model = new TreeModel();
config.setTitle("Changed");
config.export(model, con.getValueFactory().createBNode());
Resource ctx = RepositoryConfigUtil.getContext(con, config.getID());
con.begin();
con.clear(ctx);
con.add(model, ctx == null ? con.getValueFactory().createBNode() : ctx);
con.commit();
}
assertEquals("Changed", manager.getRepositoryConfig(TEST_REPO).getTitle());
}
use of org.eclipse.rdf4j.repository.config.RepositoryConfig in project rdf4j by eclipse.
the class RepositoryManager method isSafeToRemove.
/**
* Checks on whether the given repository is referred to by a
* {@link org.eclipse.rdf4j.repository.sail.ProxyRepository} configuration.
*
* @param repositoryID
* id to check
* @return true if there is no existing proxy reference to the given id, false otherwise
* @throws RepositoryException
*/
public boolean isSafeToRemove(String repositoryID) throws RepositoryException {
SimpleValueFactory vf = SimpleValueFactory.getInstance();
for (String id : getRepositoryIDs()) {
RepositoryConfig config = getRepositoryConfig(id);
Model model = new LinkedHashModel();
config.export(model, vf.createBNode());
if (model.contains(null, PROXIED_ID, vf.createLiteral(repositoryID))) {
return false;
}
}
return true;
}
use of org.eclipse.rdf4j.repository.config.RepositoryConfig in project rdf4j by eclipse.
the class SystemRepository method createDelegate.
/*---------*
* Methods *
*---------*/
private Repository createDelegate() {
RepositoryConfig repoConfig = getSystemConfig();
if (repoConfig == null) {
throw new RepositoryConfigException("Could not find SYSTEM configuration");
}
repoConfig.validate();
RepositoryImplConfig config = repoConfig.getRepositoryImplConfig();
RepositoryFactory factory = RepositoryRegistry.getInstance().get(config.getType()).orElseThrow(() -> new RepositoryConfigException("Repository type not in classpath: " + config.getType()));
return factory.getRepository(config);
}
Aggregations