Search in sources :

Example 1 with RepositoryConfig

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()));
}
Also used : SailRepositoryConfig(org.eclipse.rdf4j.repository.sail.config.SailRepositoryConfig) ProxyRepositoryConfig(org.eclipse.rdf4j.repository.sail.config.ProxyRepositoryConfig) RepositoryConfig(org.eclipse.rdf4j.repository.config.RepositoryConfig) RepositoryConnection(org.eclipse.rdf4j.repository.RepositoryConnection) TreeModel(org.eclipse.rdf4j.model.impl.TreeModel) Model(org.eclipse.rdf4j.model.Model) TreeModel(org.eclipse.rdf4j.model.impl.TreeModel) Test(org.junit.Test)

Example 2 with RepositoryConfig

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"));
}
Also used : SailRepositoryConfig(org.eclipse.rdf4j.repository.sail.config.SailRepositoryConfig) ProxyRepositoryConfig(org.eclipse.rdf4j.repository.sail.config.ProxyRepositoryConfig) RepositoryConfig(org.eclipse.rdf4j.repository.config.RepositoryConfig) RepositoryConnection(org.eclipse.rdf4j.repository.RepositoryConnection) TreeModel(org.eclipse.rdf4j.model.impl.TreeModel) Model(org.eclipse.rdf4j.model.Model) TreeModel(org.eclipse.rdf4j.model.impl.TreeModel) Test(org.junit.Test)

Example 3 with RepositoryConfig

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());
}
Also used : SailRepositoryConfig(org.eclipse.rdf4j.repository.sail.config.SailRepositoryConfig) ProxyRepositoryConfig(org.eclipse.rdf4j.repository.sail.config.ProxyRepositoryConfig) RepositoryConfig(org.eclipse.rdf4j.repository.config.RepositoryConfig) RepositoryConnection(org.eclipse.rdf4j.repository.RepositoryConnection) TreeModel(org.eclipse.rdf4j.model.impl.TreeModel) Model(org.eclipse.rdf4j.model.Model) TreeModel(org.eclipse.rdf4j.model.impl.TreeModel) Resource(org.eclipse.rdf4j.model.Resource) Test(org.junit.Test)

Example 4 with RepositoryConfig

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;
}
Also used : RepositoryConfig(org.eclipse.rdf4j.repository.config.RepositoryConfig) Model(org.eclipse.rdf4j.model.Model) LinkedHashModel(org.eclipse.rdf4j.model.impl.LinkedHashModel) LinkedHashModel(org.eclipse.rdf4j.model.impl.LinkedHashModel) SimpleValueFactory(org.eclipse.rdf4j.model.impl.SimpleValueFactory)

Example 5 with RepositoryConfig

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);
}
Also used : RepositoryConfig(org.eclipse.rdf4j.repository.config.RepositoryConfig) RepositoryImplConfig(org.eclipse.rdf4j.repository.config.RepositoryImplConfig) RepositoryFactory(org.eclipse.rdf4j.repository.config.RepositoryFactory) RepositoryConfigException(org.eclipse.rdf4j.repository.config.RepositoryConfigException)

Aggregations

RepositoryConfig (org.eclipse.rdf4j.repository.config.RepositoryConfig)12 Model (org.eclipse.rdf4j.model.Model)5 TreeModel (org.eclipse.rdf4j.model.impl.TreeModel)4 RepositoryConnection (org.eclipse.rdf4j.repository.RepositoryConnection)4 ProxyRepositoryConfig (org.eclipse.rdf4j.repository.sail.config.ProxyRepositoryConfig)4 SailRepositoryConfig (org.eclipse.rdf4j.repository.sail.config.SailRepositoryConfig)4 RepositoryConfigException (org.eclipse.rdf4j.repository.config.RepositoryConfigException)3 Test (org.junit.Test)3 File (java.io.File)2 RepositoryException (org.eclipse.rdf4j.repository.RepositoryException)2 FileInputStream (java.io.FileInputStream)1 FilenameFilter (java.io.FilenameFilter)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 MalformedURLException (java.net.MalformedURLException)1 ArrayList (java.util.ArrayList)1 Resource (org.eclipse.rdf4j.model.Resource)1 LinkedHashModel (org.eclipse.rdf4j.model.impl.LinkedHashModel)1 SimpleValueFactory (org.eclipse.rdf4j.model.impl.SimpleValueFactory)1 DelegatingRepository (org.eclipse.rdf4j.repository.DelegatingRepository)1