use of org.eclipse.rdf4j.repository.config.RepositoryConfigException 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.RepositoryConfigException in project rdf4j by eclipse.
the class LocalRepositoryManager method removeRepository.
private boolean removeRepository(String repositoryID, boolean updateSystem) {
boolean removed = updateSystem ? super.removeRepository(repositoryID) : false;
File dataDir = getRepositoryDir(repositoryID);
if (dataDir.isDirectory()) {
logger.debug("Cleaning up data dir {} for repository {}", dataDir.getAbsolutePath(), repositoryID);
try {
FileUtil.deleteDir(dataDir);
} catch (IOException e) {
throw new RepositoryConfigException(e);
}
return true;
}
return removed;
}
Aggregations