Search in sources :

Example 11 with RepositoryConfigException

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

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;
}
Also used : IOException(java.io.IOException) RepositoryConfigException(org.eclipse.rdf4j.repository.config.RepositoryConfigException) File(java.io.File)

Aggregations

RepositoryConfigException (org.eclipse.rdf4j.repository.config.RepositoryConfigException)12 IOException (java.io.IOException)4 File (java.io.File)3 RepositoryConfig (org.eclipse.rdf4j.repository.config.RepositoryConfig)3 Model (org.eclipse.rdf4j.model.Model)2 TreeModel (org.eclipse.rdf4j.model.impl.TreeModel)2 ModelException (org.eclipse.rdf4j.model.util.ModelException)2 RepositoryFactory (org.eclipse.rdf4j.repository.config.RepositoryFactory)2 RepositoryImplConfig (org.eclipse.rdf4j.repository.config.RepositoryImplConfig)2 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 URISyntaxException (java.net.URISyntaxException)1 HttpClientDependent (org.eclipse.rdf4j.http.client.HttpClientDependent)1 RDF4JProtocolSession (org.eclipse.rdf4j.http.client.RDF4JProtocolSession)1 SessionManagerDependent (org.eclipse.rdf4j.http.client.SessionManagerDependent)1 IRI (org.eclipse.rdf4j.model.IRI)1 Value (org.eclipse.rdf4j.model.Value)1 FederatedServiceResolverClient (org.eclipse.rdf4j.query.algebra.evaluation.federation.FederatedServiceResolverClient)1