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);
}
}
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)));
}
Aggregations