use of org.locationtech.geogig.api.plumbing.ResolveGeogigDir in project GeoGig by boundlessgeo.
the class FileRefDatabase method getAll.
/**
* @return all references under the specified namespace
*/
@Override
public Map<String, String> getAll(String namespace) {
Preconditions.checkNotNull(namespace);
File refsRoot;
try {
Optional<URL> envHome = new ResolveGeogigDir(platform).call();
refsRoot = new File(envHome.get().toURI());
} catch (Exception e) {
throw Throwables.propagate(e);
}
if (namespace.endsWith("/")) {
namespace = namespace.substring(0, namespace.length() - 1);
}
Map<String, String> refs = Maps.newTreeMap();
findRefs(refsRoot, namespace, refs);
return ImmutableMap.copyOf(refs);
}
use of org.locationtech.geogig.api.plumbing.ResolveGeogigDir in project GeoGig by boundlessgeo.
the class FileRefDatabase method create.
/**
* Creates the reference database.
*/
@Override
public void create() {
Optional<URL> envHome = new ResolveGeogigDir(platform).call();
checkState(envHome.isPresent(), "Not inside a geogig directory");
final URL envURL = envHome.get();
if (!"file".equals(envURL.getProtocol())) {
throw new UnsupportedOperationException("This References Database works only against file system repositories. " + "Repository location: " + envURL.toExternalForm());
}
File repoDir;
try {
repoDir = new File(envURL.toURI());
} catch (URISyntaxException e) {
throw Throwables.propagate(e);
}
File refs = new File(repoDir, "refs");
if (!refs.exists() && !refs.mkdir()) {
throw new IllegalStateException("Cannot create refs directory '" + refs.getAbsolutePath() + "'");
}
}
use of org.locationtech.geogig.api.plumbing.ResolveGeogigDir in project GeoGig by boundlessgeo.
the class FileObjectDatabase method open.
/**
* Opens the database for use by GeoGig.
*/
@Override
public void open() {
if (isOpen()) {
return;
}
final Optional<URL> repoUrl = new ResolveGeogigDir(platform).call();
checkState(repoUrl.isPresent(), "Can't find geogig repository home");
try {
dataRoot = new File(new File(repoUrl.get().toURI()), databaseName);
} catch (URISyntaxException e) {
throw Throwables.propagate(e);
}
if (!dataRoot.exists() && !dataRoot.mkdirs()) {
throw new IllegalStateException("Can't create environment: " + dataRoot.getAbsolutePath());
}
if (!dataRoot.isDirectory()) {
throw new IllegalStateException("Environment but is not a directory: " + dataRoot.getAbsolutePath());
}
if (!dataRoot.canWrite()) {
throw new IllegalStateException("Environment is not writable: " + dataRoot.getAbsolutePath());
}
dataRootPath = dataRoot.getAbsolutePath();
}
use of org.locationtech.geogig.api.plumbing.ResolveGeogigDir in project GeoGig by boundlessgeo.
the class HeapGraphDatabase method open.
@Override
public void open() {
if (isOpen()) {
return;
}
Optional<URL> url = new ResolveGeogigDir(platform).call();
if (url.isPresent()) {
synchronized (graphs) {
URL key = url.get();
if (!graphs.containsKey(key)) {
graphs.put(key, new Ref(new Graph()));
}
graph = graphs.get(key).acquire();
}
} else {
graph = new Graph();
}
}
Aggregations