Search in sources :

Example 16 with ConfigDatabase

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

the class RemoteRemoveOp method _call.

/**
     * Executes the remote-remove operation.
     * 
     * @return the {@link Remote} that was removed, or {@link Optional#absent()} if the remote
     *         didn't exist.
     */
@Override
protected Remote _call() {
    if (name == null || name.isEmpty()) {
        throw new RemoteException(StatusCode.MISSING_NAME);
    }
    ConfigDatabase config = configDatabase();
    List<String> allRemotes = config.getAllSubsections("remote");
    if (!allRemotes.contains(name)) {
        throw new RemoteException(StatusCode.REMOTE_NOT_FOUND);
    }
    Remote remote = null;
    String remoteSection = "remote." + name;
    Optional<String> remoteFetchURL = config.get(remoteSection + ".url");
    Optional<String> remoteFetch = config.get(remoteSection + ".fetch");
    Optional<String> remotePushURL = Optional.absent();
    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()) {
        remotePushURL = config.get(remoteSection + ".pushurl");
    }
    remote = new Remote(name, remoteFetchURL.or(""), remotePushURL.or(remoteFetchURL.or("")), remoteFetch.or(""), remoteMapped.or("false").equals("true"), remoteMappedBranch.orNull(), remoteUserName.orNull(), remotePassword.orNull());
    config.removeSection(remoteSection);
    // Remove refs
    final ImmutableSet<Ref> localRemoteRefs = command(LsRemote.class).retrieveLocalRefs(true).setRemote(Suppliers.ofInstance(Optional.of(remote))).call();
    for (Ref localRef : localRemoteRefs) {
        command(UpdateRef.class).setDelete(true).setName(localRef.getName()).call();
    }
    return remote;
}
Also used : Ref(org.locationtech.geogig.api.Ref) UpdateRef(org.locationtech.geogig.api.plumbing.UpdateRef) ConfigDatabase(org.locationtech.geogig.storage.ConfigDatabase) LsRemote(org.locationtech.geogig.api.plumbing.LsRemote) Remote(org.locationtech.geogig.api.Remote) LsRemote(org.locationtech.geogig.api.plumbing.LsRemote) UpdateRef(org.locationtech.geogig.api.plumbing.UpdateRef)

Example 17 with ConfigDatabase

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

the class JEGraphDatabaseV2Test 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_2(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 18 with ConfigDatabase

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

the class MongoGraphDatabaseTest method createDatabase.

@Override
protected MongoGraphDatabase createDatabase(Platform platform) throws Exception {
    final IniMongoProperties properties = new IniMongoProperties();
    final String uri = properties.get("mongodb.uri", String.class).or("mongodb://localhost:27017/");
    final String database = properties.get("mongodb.database", String.class).or("geogig");
    MongoClient client = new MongoClient(new MongoClientURI(uri));
    DB db = client.getDB(database);
    db.dropDatabase();
    MongoConnectionManager manager = new MongoConnectionManager();
    ConfigDatabase config = new TestConfigDatabase(platform);
    MongoGraphDatabase mongoGraphDatabase = new MongoGraphDatabase(manager, config);
    return mongoGraphDatabase;
}
Also used : MongoClient(com.mongodb.MongoClient) MongoGraphDatabase(org.locationtech.geogig.storage.mongo.MongoGraphDatabase) ConfigDatabase(org.locationtech.geogig.storage.ConfigDatabase) MongoClientURI(com.mongodb.MongoClientURI) MongoConnectionManager(org.locationtech.geogig.storage.mongo.MongoConnectionManager) DB(com.mongodb.DB)

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