/** * @return the name of the repository * @see org.locationtech.geogig.repository.AbstractGeoGigOp#call() */ @Override protected String _call() { Optional<String> repoName = configDb.get("repo.name"); if (repoName.isPresent()) { return repoName.get(); } URI repoURI = repository().getLocation(); RepositoryResolver resolver = RepositoryResolver.lookup(repoURI); return resolver.getName(repoURI); } }
@Override public void open() throws RepositoryConnectionException { if (remoteRepo == null) { remoteRepo = RepositoryResolver.load(remoteRepoLocation); } }
/** * Resolve the config database using the provided parameters. * * @param repoURI the repository URI * @param repoContext the repository context * @param rootUri {@code true} if {@code repoURI} represents a root URI to a group of * repositories * @return the config database */ public static ConfigDatabase resolveConfigDatabase(URI repoURI, Context repoContext, boolean rootUri) { RepositoryResolver initializer = RepositoryResolver.lookup(repoURI); return initializer.getConfigDatabase(repoURI, repoContext, rootUri); }
/** * Calls on {@link ResolveGeogigURI} to get the repository's URI, looks up the proper * {@link RepsitoryResolver} through the provided SPI mechanism, and calls * {@link RepositoryResolver#delete(URI)} to delete the repo. * <p> * Precondition: {#link #isOpen()} must return {code false} */ public static void delete(URI repoURI) throws Exception { RepositoryResolver resolver = RepositoryResolver.lookup(repoURI); resolver.delete(repoURI); } }
/** * @param repositoryLocation the URI with the location of the repository to load * @return a {@link Repository} loaded from the given URI, already {@link Repository#open() * open} * @throws IllegalArgumentException if no registered {@link RepositoryResolver} implementation * can load the repository at the given location * @throws RepositoryConnectionException if the repository can't be opened */ public static Repository load(URI repositoryLocation) throws RepositoryConnectionException { RepositoryResolver initializer = RepositoryResolver.lookup(repositoryLocation); Repository repository = initializer.open(repositoryLocation); return repository; }
/** * @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; }
targetArg = args.get(1); } else { RepositoryResolver remoteResolver = RepositoryResolver.lookup(remoteURI); targetArg = remoteResolver.getName(remoteURI); cloneURI = RepositoryResolver.resolveRepoUriFromString(platform, targetArg); } catch (URISyntaxException e) { throw new CommandFailedException("Can't parse target URI '" + targetArg + "'", RepositoryResolver cloneInitializer = RepositoryResolver.lookup(cloneURI); if (cloneInitializer.repoExists(cloneURI)) { URI resolvedURI = cloneURI; if ("file".equals(cloneURI.getScheme())) { cloneInitializer.initialize(cloneURI, cloneContext); cli.setPlatform(cloneContext.platform());
} else { try { uri = RepositoryResolver.resolveRepoUriFromString(platform, repoURI); globalOnly = false; } catch (URISyntaxException e) { final RepositoryResolver resolver = RepositoryResolver.lookup(uri); final boolean repoExists = resolver.repoExists(uri); try (ConfigDatabase config = resolver.getConfigDatabase(uri, context, globalOnly)) { if (!globalOnly && repoExists) { unaliased = config.get(configParam);
final RepositoryResolver repoInitializer = RepositoryResolver.lookup(repoURI); final boolean repoExisted = repoInitializer.repoExists(repoURI); repoInitializer.initialize(repoURI, context()); if (!repoExisted) { try (ConfigDatabase configDB = repoInitializer.getConfigDatabase(repoURI, context)) { PluginDefaults defaults = context.pluginDefaults();
private void verifyFileRepositoryResolver(final boolean isAvailable, final URI uri) { if (isAvailable) { // assert Resolver is available for "test" scheme assertTrue("FileRepositoryResolver should be available", RepositoryResolver.resolverAvailableForURIScheme("file")); // assert Resolver can be looked up for URI assertNotNull("FileRepositoryResolver should be available", RepositoryResolver.lookup(uri)); } else { // assert Resolver is not available for "test" scheme assertFalse("FileRepositoryResolver should not be available", RepositoryResolver.resolverAvailableForURIScheme("file")); // assert Resolver can not be looked up for URI try { RepositoryResolver.lookup(uri); fail("FileRepositoryResolver should not be available"); } catch (IllegalArgumentException iae) { // expected } catch (Throwable t) { // unexpected fail("Unexpected error: " + t.getMessage()); } } }
public String getRepoName() { if (this.location != null) { if (this.repoName == null) { // lookup the resolver if (RepositoryResolver.resolverAvailableForURIScheme(this.location.getScheme())) { RepositoryResolver resolver = RepositoryResolver.lookup(this.location); this.repoName = resolver.getName(this.location); } } } return this.repoName; }
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(); } }
RepositoryInfo repo = validatable.getValue(); final URI location = repo.getLocation(); final RepositoryResolver resolver = RepositoryResolver.lookup(location); final String scheme = location.getScheme(); final boolean nameExists = try { if (isNew) { if (resolver.repoExists(location)) { error.addKey("errRepositoryExists"); resolver.open(location);
public MultiRepositoryProvider(final URI rootRepoURI) { checkNotNull(rootRepoURI, "root repo URI is null"); resolver = RepositoryResolver.lookup(rootRepoURI); this.rootRepoURI = rootRepoURI; try { this.repositories = buildCache(); } catch (IOException e) { throw Throwables.propagate(e); } }
final String newRepoName = hints.get(Hints.REPOSITORY_NAME).get().toString(); final URI parentUri = new File(parentDir).getCanonicalFile().toURI(); final RepositoryResolver resolver = RepositoryResolver.lookup(parentUri); URI repoURI = resolver.buildRepoURI(parentUri, newRepoName); hints.uri(repoURI); } else if (dbName != null && dbPassword != null) {
protected @Override void runInternal(GeogigCLI cli) throws IOException { checkParameter(!baseuri.isEmpty(), "Usage: geogig ls-repos <base URI> (e.g. geogig ls-repos postgresql://localhost:5432/geogig_db?user=...&password=...)"); URI baseURI = baseuri.get(0); RepositoryResolver resolver = RepositoryResolver.lookup(baseURI); List<String> repoNames = new ArrayList<>(resolver.listRepoNamesUnderRootURI(baseURI)); Collections.sort(repoNames); Console console = cli.getConsole(); if (verbose) { logVerbose(console, baseURI, repoNames, resolver); } else { for (String name : repoNames) { console.println(name); } } }
URI repoURI = RepositoryResolver.resolveRepoUriFromString(geogig.getPlatform(), rootUri); ConfigDatabase configDb = RepositoryResolver.resolveConfigDatabase(repoURI, geogig.getContext(), true); configOp.setConfigDatabase(configDb);
private RepoInfo toRepoInfo(RepositoryResolver resolver, URI rootRepoURI, String repoName) { URI repoURI = resolver.buildRepoURI(rootRepoURI, repoName); Repository repo; try { repo = resolver.open(repoURI); } catch (RepositoryConnectionException e) { throw new CommandFailedException(e); } try { return toRepoInfo(repoName, repo); } finally { repo.close(); } }
private URI resolveRemoteURI(final Platform platform) { final URI remoteURI; final String remoteArg = args.get(0); try { remoteURI = RepositoryResolver.resolveRepoUriFromString(platform, remoteArg); } catch (URISyntaxException e) { throw new CommandFailedException("Can't parse remote URI '" + remoteArg + "'", true); } return remoteURI.normalize(); } }
/** * Gets a config database for a single repository. * * @param repoURI the repository URI * @param repoContext the repository context * @return the config database */ public ConfigDatabase getConfigDatabase(URI repoURI, Context repoContext) { return getConfigDatabase(repoURI, repoContext, false); }