/** * @return the configured repository or {@code null} if no repository is found on the current * directory */ public synchronized @Nullable Repository getRepository() { if (repository != null) { return repository; } final Optional<URI> repoLocation = command(ResolveGeogigURI.class).call(); if (repoLocation.isPresent()) { if (RepositoryResolver.lookup(repoLocation.get()).repoExists(repoLocation.get())) { repository = context.repository(); try { repository.open(); } catch (RepositoryConnectionException e) { throw new RuntimeException(e); } } } return repository; }
/** * @return the configured repository or {@code null} if no repository is found on the current * directory */ public synchronized Repository getRepository() { if (repository != null) { return repository; } final Optional<URI> repoLocation = command(ResolveGeogigURI.class).call(); if (repoLocation.isPresent()) { try { if (RepositoryResolver.lookup(repoLocation.get()).repoExists(repoLocation.get())) { repository = context.repository(); repository.open(); } } catch (Exception e) { throw Throwables.propagate(e); } } return repository; }
final boolean exists = repositoryResolver.repoExists(repoURI); Repository repository = context.repository(); if (exists) {
final boolean repoExists = resolver.repoExists(uri); try (ConfigDatabase config = resolver.getConfigDatabase(uri, context, globalOnly)) { if (!globalOnly && repoExists) {
final boolean repoExists = resolver.repoExists(uri); try (ConfigDatabase config = resolver.getConfigDatabase(uri, context, globalOnly)) { if (!globalOnly && repoExists) {
private static Optional<Repository> createGeoGIG(RepositoryResolver defaultResolver, URI rootRepoURI, String repositoryName, Map<String, String> parameters) { try { final Hints hints = InitRequestUtil.createHintsFromParameters(repositoryName, parameters); Optional<Serializable> repositoryUri = hints.get(Hints.REPOSITORY_URL); if (!repositoryUri.isPresent()) { URI repoURI = defaultResolver.buildRepoURI(rootRepoURI, repositoryName); hints.set(Hints.REPOSITORY_URL, repoURI); repositoryUri = hints.get(Hints.REPOSITORY_URL); } final URI repoUri = URI.create(repositoryUri.get().toString()); final RepositoryResolver resolver = RepositoryResolver.lookup(repoUri); final Repository repository = GlobalContextBuilder.builder().build(hints).repository(); if (resolver.repoExists(repoUri)) { // open it repository.open(); } // now build the repo with the Hints return Optional.fromNullable(repository); } catch (Exception ex) { Throwables.propagate(ex); } return Optional.absent(); } }
private static Optional<Repository> importGeogig( String repositoryName, Map<String, String> parameters) { // if the request is a POST, and the request path ends in "importExistingRepo" try { final Hints hints = InitRequestUtil.createHintsFromParameters(repositoryName, parameters); // now build the repo with the Hints RepositoryInfo repoInfo = new RepositoryInfo(); // set the repo location from the URI if (!hints.get(Hints.REPOSITORY_URL).isPresent()) { return Optional.absent(); } URI uri = new URI(hints.get(Hints.REPOSITORY_URL).get().toString()); repoInfo.setLocation(uri); // check to see if repo is initialized RepositoryResolver repoResolver = RepositoryResolver.lookup(uri); if (!repoResolver.repoExists(uri)) { return Optional.absent(); } // save the repo, this will set a UUID RepositoryManager.get().save(repoInfo); return Optional.of(RepositoryManager.get().getRepository(repoInfo.getId())); } catch (IOException | URISyntaxException e) { Throwables.propagate(e); } catch (RepositoryConnectionException e) { e.printStackTrace(); } return Optional.absent(); } }
@Then("^the repository shall exist$") public void the_repository_shall_exist() throws Throwable { List<String> output = localRepo.runAndParseCommand(true, "rev-parse", "--resolve-geogig-uri"); assertEquals(output.toString(), 1, output.size()); String location = output.get(0); assertNotNull(location); URI repoURI = resolveURI(location); boolean repoExists = RepositoryResolver.lookup(repoURI).repoExists(repoURI); assertTrue("Repository not found: " + repoURI, repoExists); }
try { if (isNew) { if (resolver.repoExists(location)) { error.addKey("errRepositoryExists");
@Then("^the repository shall exist$") public void the_repository_shall_exist() throws Throwable { List<String> output = localRepo.runAndParseCommand(true, "rev-parse", "--resolve-geogig-uri"); assertEquals(output.toString(), 1, output.size()); String location = output.get(0); assertNotNull(location); URI repoURI = resolveURI(location); boolean repoExists = RepositoryResolver.lookup(repoURI).repoExists(repoURI); assertTrue("Repository not found: " + repoURI, repoExists); }
@Then("^the repository shall exist$") public void the_repository_shall_exist() throws Throwable { List<String> output = localRepo.runAndParseCommand(true, "rev-parse", "--resolve-geogig-uri"); assertEquals(output.toString(), 1, output.size()); String location = output.get(0); assertNotNull(location); URI repoURI = resolveURI(location); boolean repoExists = RepositoryResolver.lookup(repoURI).repoExists(repoURI); assertTrue("Repository not found: " + repoURI, repoExists); }
/** * @see org.geotools.data.DataStoreFactorySpi#createNewDataStore(java.util.Map) */ @Override public GeoGigDataStore createNewDataStore(Map<String, Serializable> params) throws IOException { String defaultNamespace = (String) DEFAULT_NAMESPACE.lookUp(params); URI repositoryRoot = resolveURI((String) REPOSITORY.lookUp(params)); RepositoryResolver initializer = RepositoryResolver.lookup(repositoryRoot); if (initializer.repoExists(repositoryRoot)) { throw new IOException("Repository already exists " + repositoryRoot); } Hints hints = new Hints().uri(repositoryRoot); Context context = GlobalContextBuilder.builder().build(hints); GeoGIG geogig = new GeoGIG(context); Repository repository; try { repository = geogig.getOrCreateRepository(); Preconditions.checkState(repository != null); } catch (RuntimeException e) { throw new IOException(e); } GeoGigDataStore store = new GeoGigDataStore(repository); if (defaultNamespace != null) { store.setNamespaceURI(defaultNamespace); } return store; }
if (!resolver.repoExists(location)) { error.addKey("errRepositoryDoesntExist");
private void create(final RepositoryInfo repoInfo) { URI repoURI = repoInfo.getLocation(); RepositoryResolver resolver = RepositoryResolver.lookup(repoURI); if (!resolver.repoExists(repoURI)) { Hints hints = new Hints(); hints.set(Hints.REPOSITORY_URL, repoURI); hints.set(Hints.REPOSITORY_NAME, repoInfo.getRepoName()); Context context = GlobalContextBuilder.builder().build(hints); GeoGIG geogig = new GeoGIG(context); try { Repository repository = geogig.command(InitOp.class).call(); Preconditions.checkState(repository != null); } finally { geogig.close(); } } }
@Then("^the repository at \"([^\"]*)\" shall not exist$") public void the_repository_at_shall_not_exist(String repoUri) throws Throwable { repoUri = replaceKnownVariables(repoUri); URI uri = resolveURI(repoUri); boolean exists = RepositoryResolver.lookup(uri).repoExists(uri); assertFalse("Repository exists: " + uri, exists); }
@Then("^the repository at \"([^\"]*)\" shall exist$") public void the_repository_at_shall_exist(String repoUri) throws Throwable { repoUri = replaceKnownVariables(repoUri); URI uri = resolveURI(repoUri); boolean exists = RepositoryResolver.lookup(uri).repoExists(uri); assertTrue("Repository does not exist: " + uri, exists); }
@Then("^the repository at \"([^\"]*)\" shall exist$") public void the_repository_at_shall_exist(String repoUri) throws Throwable { repoUri = replaceKnownVariables(repoUri); URI uri = resolveURI(repoUri); boolean exists = RepositoryResolver.lookup(uri).repoExists(uri); assertTrue("Repository does not exist: " + uri, exists); }
@Then("^the repository at \"([^\"]*)\" shall exist$") public void the_repository_at_shall_exist(String repoUri) throws Throwable { repoUri = replaceKnownVariables(repoUri); URI uri = resolveURI(repoUri); boolean exists = RepositoryResolver.lookup(uri).repoExists(uri); assertTrue("Repository does not exist: " + uri, exists); }
@Then("^the repository at \"([^\"]*)\" shall not exist$") public void the_repository_at_shall_not_exist(String repoUri) throws Throwable { repoUri = replaceKnownVariables(repoUri); URI uri = resolveURI(repoUri); boolean exists = RepositoryResolver.lookup(uri).repoExists(uri); assertFalse("Repository exists: " + uri, exists); }
@Then("^the repository at \"([^\"]*)\" shall not exist$") public void the_repository_at_shall_not_exist(String repoUri) throws Throwable { repoUri = replaceKnownVariables(repoUri); URI uri = resolveURI(repoUri); boolean exists = RepositoryResolver.lookup(uri).repoExists(uri); assertFalse("Repository exists: " + uri, exists); }