use of org.locationtech.geogig.storage.ConfigDatabase in project GeoGig by boundlessgeo.
the class ConfigOpTest method testListLocalWithNoLocalRepository.
@Test
public void testListLocalWithNoLocalRepository() {
ConfigDatabase database = mock(ConfigDatabase.class);
when(database.getAll()).thenThrow(new ConfigException(StatusCode.INVALID_LOCATION));
ConfigOp config = new ConfigOp(database);
exception.expect(ConfigException.class);
config.setScope(ConfigScope.LOCAL).setAction(ConfigAction.CONFIG_LIST).setName(null).setValue(null).call();
}
use of org.locationtech.geogig.storage.ConfigDatabase in project GeoGig by boundlessgeo.
the class ConfigOpTest method testGetLocalWithNoLocalRepository.
@Test
public void testGetLocalWithNoLocalRepository() {
ConfigDatabase database = mock(ConfigDatabase.class);
when(database.get(anyString())).thenThrow(new ConfigException(StatusCode.INVALID_LOCATION));
ConfigOp config = new ConfigOp(database);
exception.expect(ConfigException.class);
config.setScope(ConfigScope.LOCAL).setAction(ConfigAction.CONFIG_GET).setName("section.key").setValue(null).call();
}
use of org.locationtech.geogig.storage.ConfigDatabase in project GeoGig by boundlessgeo.
the class CachingModuleTest method setUp.
@Before
public void setUp() throws Exception {
odbCache = mock(Cache.class);
indexCache = mock(Cache.class);
final ObjectDatabaseCacheFactory odbCacheFac = mock(ObjectDatabaseCacheFactory.class);
when(odbCacheFac.get()).thenReturn(odbCache);
final StagingDatabaseCacheFactory indexCacheFac = mock(StagingDatabaseCacheFactory.class);
when(indexCacheFac.get()).thenReturn(indexCache);
File workingDirectory = tmpFolder.getRoot();
final Platform platform = new TestPlatform(workingDirectory);
Module module = new AbstractModule() {
@Override
protected void configure() {
bind(Context.class).to(GuiceInjector.class).in(Scopes.SINGLETON);
Multibinder.newSetBinder(binder(), Decorator.class);
bind(DecoratorProvider.class).in(Scopes.SINGLETON);
DataStreamSerializationFactoryV1 sfac = DataStreamSerializationFactoryV1.INSTANCE;
bind(ObjectSerializingFactory.class).toInstance(sfac);
bind(ObjectDatabase.class).to(HeapObjectDatabse.class).in(Scopes.SINGLETON);
bind(StagingDatabase.class).to(HeapStagingDatabase.class).in(Scopes.SINGLETON);
ConfigDatabase config = new IniFileConfigDatabase(platform);
bind(ConfigDatabase.class).toInstance(config);
bind(ObjectDatabaseCacheFactory.class).toInstance(odbCacheFac);
bind(StagingDatabaseCacheFactory.class).toInstance(indexCacheFac);
}
};
Context injector = Guice.createInjector(Modules.override(new CachingModule()).with(module)).getInstance(org.locationtech.geogig.api.Context.class);
odb = injector.objectDatabase();
index = injector.stagingDatabase();
odb.open();
index.open();
odb.put(o1);
odb.put(o2);
odb.put(o3);
index.put(s1);
index.put(s2);
index.put(s3);
}
use of org.locationtech.geogig.storage.ConfigDatabase in project GeoGig by boundlessgeo.
the class CacheFactory method getConfig.
@SuppressWarnings("unchecked")
private <T> T getConfig(final String keyword, final T defaultValue) {
final String kw = configKeywordPrefix + "." + keyword;
ConfigDatabase configDatabase = configDb.get();
try {
Optional<? extends Object> value = configDatabase.get(kw, defaultValue.getClass());
if (value.isPresent()) {
LOGGER.trace("Got cache config property {} = {}", kw, value.get());
return (T) value.get();
}
} catch (ConfigException e) {
return defaultValue;
}
return defaultValue;
}
use of org.locationtech.geogig.storage.ConfigDatabase in project GeoGig by boundlessgeo.
the class RemoteAddOp method _call.
/**
* Executes the remote-add operation.
*
* @return the {@link Remote} that was added.
*/
@Override
protected Remote _call() {
if (name == null || name.isEmpty()) {
throw new RemoteException(StatusCode.MISSING_NAME);
}
if (url == null || url.isEmpty()) {
throw new RemoteException(StatusCode.MISSING_URL);
}
if (branch == null || branch.isEmpty()) {
branch = "*";
}
ConfigDatabase config = configDatabase();
List<String> allRemotes = config.getAllSubsections("remote");
if (allRemotes.contains(name)) {
throw new RemoteException(StatusCode.REMOTE_ALREADY_EXISTS);
}
String configSection = "remote." + name;
String fetch = "+" + Ref.HEADS_PREFIX + branch + ":" + Ref.REMOTES_PREFIX + name + "/" + branch;
config.put(configSection + ".url", url);
config.put(configSection + ".fetch", fetch);
if (mapped) {
config.put(configSection + ".mapped", "true");
config.put(configSection + ".mappedBranch", branch);
}
if (username != null) {
config.put(configSection + ".username", username);
}
if (password != null) {
password = Remote.encryptPassword(password);
config.put(configSection + ".password", password);
}
return new Remote(name, url, url, fetch, mapped, branch, username, password);
}
Aggregations