use of org.locationtech.geogig.api.porcelain.ConfigException in project GeoGig by boundlessgeo.
the class MeteredCommandHook method pre.
@Override
public <C extends AbstractGeoGigOp<?>> C pre(C command) throws CannotRunGeogigOperationException {
Boolean enabled;
if (command.context().repository() == null) {
return command;
}
ConfigDatabase configDb = command.context().configDatabase();
try {
enabled = configDb.get(METRICS_ENABLED, Boolean.class).or(Boolean.FALSE);
} catch (ConfigException e) {
if (StatusCode.INVALID_LOCATION.equals(e.statusCode)) {
enabled = Boolean.FALSE;
} else {
throw e;
}
}
if (!enabled.booleanValue()) {
return command;
}
final Platform platform = command.context().platform();
final long startTime = platform.currentTimeMillis();
final long nanoTime = platform.nanoTime();
final String name = command.getClass().getSimpleName();
CallStack stack = CallStack.push(name, startTime, nanoTime);
command.getClientData().put("metrics.callStack", stack);
return command;
}
use of org.locationtech.geogig.api.porcelain.ConfigException in project GeoGig by boundlessgeo.
the class ConfigOpTest method testGetDefaultWithNoLocalRepository.
@Test
public void testGetDefaultWithNoLocalRepository() {
ConfigDatabase database = mock(ConfigDatabase.class);
when(database.get(anyString())).thenThrow(new ConfigException(StatusCode.INVALID_LOCATION));
when(database.getGlobal(anyString())).thenReturn(Optional.of("value"));
ConfigOp config = new ConfigOp(database);
config.setScope(ConfigScope.DEFAULT).setAction(ConfigAction.CONFIG_GET).setName("section.key").setValue(null).call();
}
use of org.locationtech.geogig.api.porcelain.ConfigException in project GeoGig by boundlessgeo.
the class ConfigOpTest method testListDefaultWithNoLocalRepository.
@Test
public void testListDefaultWithNoLocalRepository() {
ConfigDatabase database = mock(ConfigDatabase.class);
when(database.getAll()).thenThrow(new ConfigException(StatusCode.INVALID_LOCATION));
ConfigOp config = new ConfigOp(database);
config.setScope(ConfigScope.DEFAULT).setAction(ConfigAction.CONFIG_LIST).setName(null).setValue(null).call();
}
use of org.locationtech.geogig.api.porcelain.ConfigException 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.api.porcelain.ConfigException 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();
}
Aggregations