Search in sources :

Example 1 with ConfigDatabase

use of org.locationtech.geogig.storage.ConfigDatabase in project GeoGig by boundlessgeo.

the class RemoteListOp method _call.

/**
     * Executes the remote-list operation.
     * 
     * @return {@code List<Remote>} of all remotes found in the config database, may be empty.
     */
@Override
protected ImmutableList<Remote> _call() {
    ConfigDatabase config = configDatabase();
    List<String> remotes = config.getAllSubsections("remote");
    List<Remote> allRemotes = new ArrayList<Remote>();
    for (String remoteName : remotes) {
        String remoteSection = "remote." + remoteName;
        Optional<String> remoteFetchURL = config.get(remoteSection + ".url");
        Optional<String> remoteFetch = config.get(remoteSection + ".fetch");
        Optional<String> remoteMapped = config.get(remoteSection + ".mapped");
        Optional<String> remoteMappedBranch = config.get(remoteSection + ".mappedBranch");
        Optional<String> remoteUserName = config.get(remoteSection + ".username");
        Optional<String> remotePassword = config.get(remoteSection + ".password");
        if (remoteFetchURL.isPresent() && remoteFetch.isPresent()) {
            Optional<String> remotePushURL = config.get(remoteSection + ".pushurl");
            allRemotes.add(new Remote(remoteName, remoteFetchURL.get(), remotePushURL.or(remoteFetchURL.get()), remoteFetch.get(), remoteMapped.or("false").equals("true"), remoteMappedBranch.orNull(), remoteUserName.orNull(), remotePassword.orNull()));
        }
    }
    return ImmutableList.copyOf(allRemotes);
}
Also used : ConfigDatabase(org.locationtech.geogig.storage.ConfigDatabase) ArrayList(java.util.ArrayList) Remote(org.locationtech.geogig.api.Remote)

Example 2 with ConfigDatabase

use of org.locationtech.geogig.storage.ConfigDatabase in project GeoGig by boundlessgeo.

the class RemoteResolve method _call.

/**
     * Executes the remote-add operation.
     * 
     * @return the {@link Remote} that was added.
     */
@Override
protected Optional<Remote> _call() {
    if (name == null || name.isEmpty()) {
        throw new RemoteException(StatusCode.MISSING_NAME);
    }
    Optional<Remote> result = Optional.absent();
    ConfigDatabase config = configDatabase();
    List<String> allRemotes = config.getAllSubsections("remote");
    if (allRemotes.contains(name)) {
        String remoteSection = "remote." + name;
        Optional<String> remoteFetchURL = config.get(remoteSection + ".url");
        Optional<String> remoteFetch = config.get(remoteSection + ".fetch");
        Optional<String> remoteMapped = config.get(remoteSection + ".mapped");
        Optional<String> remoteMappedBranch = config.get(remoteSection + ".mappedBranch");
        Optional<String> remoteUserName = config.get(remoteSection + ".username");
        Optional<String> remotePassword = config.get(remoteSection + ".password");
        if (remoteFetchURL.isPresent() && remoteFetch.isPresent()) {
            Optional<String> remotePushURL = config.get(remoteSection + ".pushurl");
            Remote remote = new Remote(name, remoteFetchURL.get(), remotePushURL.or(remoteFetchURL.get()), remoteFetch.get(), remoteMapped.or("false").equals("true"), remoteMappedBranch.orNull(), remoteUserName.orNull(), remotePassword.orNull());
            result = Optional.of(remote);
        }
    }
    return result;
}
Also used : ConfigDatabase(org.locationtech.geogig.storage.ConfigDatabase) Remote(org.locationtech.geogig.api.Remote)

Example 3 with ConfigDatabase

use of org.locationtech.geogig.storage.ConfigDatabase in project GeoGig by boundlessgeo.

the class JEObjectDatabaseTest method createDb.

private ObjectDatabase createDb() {
    ConfigDatabase configDB = new IniFileConfigDatabase(platform);
    JEObjectDatabase db = new JEObjectDatabase_v0_1(configDB, envProvider, hints);
    db.open();
    return db;
}
Also used : IniFileConfigDatabase(org.locationtech.geogig.storage.fs.IniFileConfigDatabase) ConfigDatabase(org.locationtech.geogig.storage.ConfigDatabase) IniFileConfigDatabase(org.locationtech.geogig.storage.fs.IniFileConfigDatabase)

Example 4 with ConfigDatabase

use of org.locationtech.geogig.storage.ConfigDatabase in project GeoGig by boundlessgeo.

the class JEGraphDatabaseV1StressTest method createDatabase.

@Override
protected GraphDatabase createDatabase(TestPlatform platform) {
    File root = platform.pwd();
    Preconditions.checkState(new File(root, ".geogig").exists());
    envProvider = new EnvironmentBuilder(platform);
    ConfigDatabase configDB = new IniFileConfigDatabase(platform);
    return new JEGraphDatabase_v0_1(configDB, envProvider, new Hints());
}
Also used : Hints(org.locationtech.geogig.repository.Hints) ConfigDatabase(org.locationtech.geogig.storage.ConfigDatabase) IniFileConfigDatabase(org.locationtech.geogig.storage.fs.IniFileConfigDatabase) File(java.io.File) IniFileConfigDatabase(org.locationtech.geogig.storage.fs.IniFileConfigDatabase)

Example 5 with ConfigDatabase

use of org.locationtech.geogig.storage.ConfigDatabase in project GeoGig by boundlessgeo.

the class JEGraphDatabaseV1Test method createDatabase.

@Override
protected GraphDatabase createDatabase(Platform platform) throws Exception {
    File root = platform.pwd();
    Preconditions.checkState(new File(root, ".geogig").exists());
    envProvider = new EnvironmentBuilder(platform);
    ConfigDatabase configDB = new IniFileConfigDatabase(platform);
    return new JEGraphDatabase_v0_1(configDB, envProvider, new Hints());
}
Also used : Hints(org.locationtech.geogig.repository.Hints) ConfigDatabase(org.locationtech.geogig.storage.ConfigDatabase) IniFileConfigDatabase(org.locationtech.geogig.storage.fs.IniFileConfigDatabase) File(java.io.File) IniFileConfigDatabase(org.locationtech.geogig.storage.fs.IniFileConfigDatabase)

Aggregations

ConfigDatabase (org.locationtech.geogig.storage.ConfigDatabase)18 File (java.io.File)6 ConfigException (org.locationtech.geogig.api.porcelain.ConfigException)6 IniFileConfigDatabase (org.locationtech.geogig.storage.fs.IniFileConfigDatabase)6 Test (org.junit.Test)4 Remote (org.locationtech.geogig.api.Remote)4 ConfigOp (org.locationtech.geogig.api.porcelain.ConfigOp)4 Hints (org.locationtech.geogig.repository.Hints)4 Platform (org.locationtech.geogig.api.Platform)3 Cache (com.google.common.cache.Cache)1 AbstractModule (com.google.inject.AbstractModule)1 Module (com.google.inject.Module)1 DB (com.mongodb.DB)1 MongoClient (com.mongodb.MongoClient)1 MongoClientURI (com.mongodb.MongoClientURI)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 URISyntaxException (java.net.URISyntaxException)1 URL (java.net.URL)1