@Override protected void runInternal(GeogigCLI cli) throws InvalidParameterException, CommandFailedException, IOException { Repository repo = cli.getGeogig().getRepository(); int treesRebuilt = repo.command(BuildFullHistoryIndexOp.class)// .setTreeRefSpec(treeRefSpec)// .setAttributeName(attribute)// .setProgressListener(cli.getProgressListener())// .call(); cli.getConsole().println(treesRebuilt + " trees were rebuilt."); } }
public void configureRepository() throws Exception { geogigCLI.close(); URI uri = repositoryURI; Preconditions.checkState(uri != null, "repository URI not set"); geogigCLI.setPlatform(platform); geogigCLI.setRepositoryURI(uri.toString()); }
public CLIContext(URI repoURI, TestPlatform platform) { checkNotNull(repoURI); checkNotNull(platform); this.repositoryURI = repoURI; this.platform = platform; stdIn = new ByteArrayInputStream(new byte[0]); stdOut = new ByteArrayOutputStream(); consoleReader = new Console(stdIn, stdOut).disableAnsi(); geogigCLI = new GeogigCLI(consoleReader); geogigCLI.setPlatform(platform); }
@VisibleForTesting public synchronized GeoGIG getGeogig(Hints hints) { close(); GeoGIG geogig = loadRepository(hints); setGeogig(geogig); return geogig; }
@Override public void run() { if (cli.isRunning()) { System.err.println("Forced shut down, wait for geogig to be closed..."); System.err.flush(); geogig.getProgressListener().cancel(); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } geogig.close(); System.err.println("geogig closed."); System.err.flush(); } } });
final Platform platform = cli.getPlatform(); final URI remoteURI = resolveRemoteURI(platform); final String targetArg; cli.setRepositoryURI(cloneURI.toString()); Context cloneContext = cli.getGeogigInjector(); cloneInitializer.initialize(cloneURI, cloneContext); cli.setPlatform(cloneContext.platform()); Console console = cli.getConsole(); .setProgressListener(cli.getProgressListener());
final GeogigCLI cli = new GeogigCLI(console); cli.setRepositoryURI(repoURI); cli.setPlatform(platform); exitCode = runFromStdIn(cli, stdin); } else { exitCode = cli.execute(cliArgs); if (exitCode != 0 || cli.isExitOnFinish()) { cli.close(); return cli.isExitOnFinish() ? exitCode : Integer.MIN_VALUE;
private AutoCloseableIterator<DiffEntry> buildEntries(GeogigCLI cli, String oldVersion, String newVersion) { DiffOp diff = cli.getGeogig().command(DiffOp.class); diff.setOldVersion(oldVersion).setNewVersion(newVersion).setCompareIndex(cached); AutoCloseableIterator<DiffEntry> entries; if (paths.isEmpty()) { entries = diff.setProgressListener(cli.getProgressListener()).call(); } else { entries = AutoCloseableIterator.emptyIterator(); for (String path : paths) { AutoCloseableIterator<DiffEntry> moreEntries = diff.setFilter(path) .setProgressListener(cli.getProgressListener()).call(); entries = AutoCloseableIterator.concat(entries, moreEntries); } } return entries; }
if (cli.getRepositoryURI() == null) { File currDir = cli.getPlatform().pwd(); targetURI = currDir.getAbsoluteFile().getCanonicalFile().toURI(); } else { targetURI = URI.create(cli.getRepositoryURI()); Preconditions.checkArgument(cli.getRepositoryURI() == null, "--repo <uri> argument and <location> argument are mutually exclusive. Provide only one"); File f = new File(providedUri); if (!f.isAbsolute()) { f = new File(cli.getPlatform().pwd(), providedUri); : new File(uri); if (!file.isAbsolute()) { File currDir = cli.getPlatform().pwd(); file = new File(currDir, providedUri).getCanonicalFile(); GeoGIG geogig = cli.newGeoGIG(hints); try { repository = geogig.command(InitOp.class).setConfig(suppliedConfiguration).call(); + " Geogig repository in " + locationStr; cli.getConsole().println(message);
if (cli.getGeogig() != null && cli.getGeogig().isOpen()) { if (loc != null || multiRepo) { throw new CommandFailedException("Cannot specify a repository or serve multiple repositories from within a repository."); provider = new SingleRepositoryProvider(cli.getGeogig().getRepository()); } else { URI repoURI = null; try { repoURI = RepositoryResolver.resolveRepoUriFromString(cli.getPlatform(), loc == null ? "." : loc); } catch (URISyntaxException e) { throw new CommandFailedException("Unable to parse the root repository URI.", e); cli.getConsole().println( String.format("Starting server on port %d, use CTRL+C to exit.", port)); server.start();
private void listTags(GeogigCLI cli) { GeoGIG geogig = cli.getGeogig(); ImmutableList<RevTag> tags = geogig.command(TagListOp.class).call(); for (RevTag tag : tags) { try { cli.getConsole().println(tag.getName()); } catch (IOException e) { throw new RuntimeException(e); } } } }
@Given("^the repository has a truncated graph database$") public void the_repository_has_a_truncated_graph_database() throws Throwable { Repository repository = localRepo.geogigCLI.getGeogig().getRepository(); repository.graphDatabase().truncate(); }
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); List<String> statements = new CreateDDL().setBaseURI(baseURI).call(); for (String st : statements) { cli.getConsole().println(st); } } }
GeogigCLI geogigCLI = new GeogigCLI(geogig, console); geogigCLI.setPlatform(platform); geogigCLI.disableProgressListener(); final int exitCode = geogigCLI.execute(args);
@Then("^if I change to the respository subdirectory \"([^\"]*)\"$") public void if_I_change_to_the_respository_subdirectory(String subdirSpec) throws Throwable { String[] subdirs = subdirSpec.split("/"); File dir = localRepo.platform.pwd(); for (String subdir : subdirs) { dir = new File(dir, subdir); } assertTrue(dir.exists()); localRepo.platform.setWorkingDir(dir); localRepo.geogigCLI.close(); localRepo.geogigCLI.setRepositoryURI(dir.toURI().toString()); }
/** * Constructs and returns a new read-write geogig facade, which will not be managed by this * GeogigCLI instance, so the calling code is responsible for closing/disposing it after usage * * @return the constructed GeoGIG. */ public GeoGIG newGeoGIG() { return newGeoGIG(Hints.readWrite()); }
public synchronized void dispose() { if (geogigCLI != null) { geogigCLI.close(); geogigCLI = null; } if (consoleReader != null) { consoleReader = null; } }
public static void main(String... args) { Stopwatch sw = Stopwatch.createStarted(); GlobalContextBuilder.builder(new PluginsContextBuilder()); URI base = URI.create("postgresql://localhost:5432/test?user=postgres&password=geo123"); ProgressListener listener = new GeogigCLI(new Console()).getProgressListener(); new PGDatabaseUpgrade().setBaseURI(base).setProgressListener(listener).call(); System.err.println("done in " + sw.stop()); }
int retCode = cli.execute(args); if (0 != retCode) { return retCode;