Search in sources :

Example 11 with RepositoryConfig

use of org.eclipse.rdf4j.repository.config.RepositoryConfig in project rdf4j by eclipse.

the class LocalRepositoryManager method getRepositoryConfig.

@Override
public synchronized RepositoryConfig getRepositoryConfig(String id) {
    File dataDir = getRepositoryDir(id);
    if (new File(dataDir, CFG_FILE).exists()) {
        File configFile = new File(dataDir, CFG_FILE);
        try (InputStream input = new FileInputStream(configFile)) {
            Model model = Rio.parse(input, configFile.toURI().toString(), CONFIG_FORMAT);
            Set<String> repositoryIDs = RepositoryConfigUtil.getRepositoryIDs(model);
            if (repositoryIDs.isEmpty()) {
                throw new RepositoryConfigException("No repository ID in configuration: " + configFile);
            } else if (repositoryIDs.size() != 1) {
                throw new RepositoryConfigException("Multiple repository IDs in configuration: " + configFile);
            }
            String repositoryID = repositoryIDs.iterator().next();
            if (!id.equals(repositoryID) && !getRepositoryDir(repositoryID).getCanonicalFile().equals(dataDir.getCanonicalFile())) {
                throw new RepositoryConfigException("Wrong repository ID in configuration: " + configFile);
            }
            return RepositoryConfigUtil.getRepositoryConfig(model, repositoryID);
        } catch (IOException e) {
            throw new RepositoryConfigException(e);
        }
    } else if (id.equals(SystemRepository.ID)) {
        return new RepositoryConfig(id, new SystemRepositoryConfig());
    } else {
        return super.getRepositoryConfig(id);
    }
}
Also used : RepositoryConfig(org.eclipse.rdf4j.repository.config.RepositoryConfig) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) TreeModel(org.eclipse.rdf4j.model.impl.TreeModel) Model(org.eclipse.rdf4j.model.Model) IOException(java.io.IOException) RepositoryConfigException(org.eclipse.rdf4j.repository.config.RepositoryConfigException) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 12 with RepositoryConfig

use of org.eclipse.rdf4j.repository.config.RepositoryConfig in project rdf4j by eclipse.

the class LocalRepositoryManagerTest method setUp.

/**
 * @throws java.lang.Exception
 */
@Before
public void setUp() throws Exception {
    datadir = tempDir.newFolder("local-repositorymanager-test");
    manager = new LocalRepositoryManager(datadir);
    manager.initialize();
    // Create configurations for the SAIL stack, and the repository
    // implementation.
    manager.addRepositoryConfig(new RepositoryConfig(TEST_REPO, new SailRepositoryConfig(new MemoryStoreConfig(true))));
    // Create configuration for proxy repository to previous repository.
    manager.addRepositoryConfig(new RepositoryConfig(PROXY_ID, new ProxyRepositoryConfig(TEST_REPO)));
}
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) MemoryStoreConfig(org.eclipse.rdf4j.sail.memory.config.MemoryStoreConfig) ProxyRepositoryConfig(org.eclipse.rdf4j.repository.sail.config.ProxyRepositoryConfig) SailRepositoryConfig(org.eclipse.rdf4j.repository.sail.config.SailRepositoryConfig) Before(org.junit.Before)

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