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;
}
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());
}
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;
}
Aggregations