Search in sources :

Example 6 with RepositoryConfig

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

the class SystemRepository method initialize.

@Override
public void initialize() throws RepositoryException {
    super.initialize();
    RepositoryConnection con = getConnection();
    try {
        if (con.isEmpty()) {
            logger.debug("Initializing empty {} repository", ID);
            con.begin();
            con.setNamespace("rdf", RDF.NAMESPACE);
            con.setNamespace("sys", RepositoryConfigSchema.NAMESPACE);
            con.commit();
            RepositoryConfig repConfig = new RepositoryConfig(ID, TITLE, new SystemRepositoryConfig());
            RepositoryConfigUtil.updateRepositoryConfigs(con, repConfig);
        }
    } catch (RepositoryConfigException e) {
        throw new RepositoryException(e.getMessage(), e);
    } finally {
        con.close();
    }
}
Also used : RepositoryConnection(org.eclipse.rdf4j.repository.RepositoryConnection) RepositoryConfig(org.eclipse.rdf4j.repository.config.RepositoryConfig) RepositoryException(org.eclipse.rdf4j.repository.RepositoryException) RepositoryConfigException(org.eclipse.rdf4j.repository.config.RepositoryConfigException)

Example 7 with RepositoryConfig

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

the class LocalRepositoryManager method getRepositoryInfo.

@Override
public RepositoryInfo getRepositoryInfo(String id) {
    RepositoryConfig config = getRepositoryConfig(id);
    if (config == null) {
        return null;
    }
    RepositoryInfo repInfo = new RepositoryInfo();
    repInfo.setId(config.getID());
    repInfo.setDescription(config.getTitle());
    try {
        repInfo.setLocation(getRepositoryDir(config.getID()).toURI().toURL());
    } catch (MalformedURLException mue) {
        throw new RepositoryException("Location of repository does not resolve to a valid URL", mue);
    }
    repInfo.setReadable(true);
    repInfo.setWritable(true);
    return repInfo;
}
Also used : RepositoryConfig(org.eclipse.rdf4j.repository.config.RepositoryConfig) MalformedURLException(java.net.MalformedURLException) RepositoryException(org.eclipse.rdf4j.repository.RepositoryException)

Example 8 with RepositoryConfig

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

the class TypeFilteringRepositoryManager method getRepositoryConfig.

@Override
public RepositoryConfig getRepositoryConfig(String repositoryID) throws RepositoryConfigException, RepositoryException {
    RepositoryConfig result = delegate.getRepositoryConfig(repositoryID);
    if (result != null) {
        if (!isCorrectType(result)) {
            logger.debug("Surpressing retrieval of repository {}: repository type {} did not match expected type {}", new Object[] { result.getID(), result.getRepositoryImplConfig().getType(), type });
            result = null;
        }
    }
    return result;
}
Also used : RepositoryConfig(org.eclipse.rdf4j.repository.config.RepositoryConfig)

Example 9 with RepositoryConfig

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

the class LocalRepositoryManager method upgrade.

private synchronized void upgrade() {
    File repositoriesDir = resolvePath(REPOSITORIES_DIR);
    String[] dirs = repositoriesDir.list(new FilenameFilter() {

        public boolean accept(File repositories, String name) {
            File dataDir = new File(repositories, name);
            return dataDir.isDirectory() && new File(dataDir, CFG_FILE).exists();
        }
    });
    if (dirs != null && dirs.length > 0) {
        // already upgraded
        return;
    }
    SystemRepository systemRepository = getSystemRepository();
    if (systemRepository == null) {
        // no legacy SYSTEM
        return;
    }
    Set<String> ids = RepositoryConfigUtil.getRepositoryIDs(systemRepository);
    List<RepositoryConfig> configs = new ArrayList<RepositoryConfig>();
    for (String id : ids) {
        configs.add(getRepositoryConfig(id));
    }
    for (RepositoryConfig config : configs) {
        addRepositoryConfig(config);
    }
}
Also used : RepositoryConfig(org.eclipse.rdf4j.repository.config.RepositoryConfig) FilenameFilter(java.io.FilenameFilter) ArrayList(java.util.ArrayList) File(java.io.File)

Example 10 with RepositoryConfig

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

the class LocalRepositoryManager method createRepository.

@Override
protected Repository createRepository(String id) throws RepositoryConfigException, RepositoryException {
    Repository repository = null;
    RepositoryConfig repConfig = getRepositoryConfig(id);
    if (repConfig != null) {
        repConfig.validate();
        repository = createRepositoryStack(repConfig.getRepositoryImplConfig());
        repository.setDataDir(getRepositoryDir(id));
        repository.initialize();
    }
    return repository;
}
Also used : RepositoryConfig(org.eclipse.rdf4j.repository.config.RepositoryConfig) Repository(org.eclipse.rdf4j.repository.Repository) DelegatingRepository(org.eclipse.rdf4j.repository.DelegatingRepository)

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