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(); } }
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(); } }
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(); } }
private SymRef getHead(GeoGIG geogig) { final Ref currentHead = geogig.command(RefParse.class).setName(Ref.HEAD).call().get(); if (!(currentHead instanceof SymRef)) { throw new CommandFailedException("Cannot run on a dettached HEAD"); } return (SymRef) currentHead; }
protected DataStore getDataStore(String geoJSON) throws FileNotFoundException, IOException { try { File geoJsonfile = new File(geoJSON); checkParameter(geoJsonfile.exists(), "File does not exist '%s'", geoJsonfile); InputStream in = new FileInputStream(geoJsonfile); FeatureJSON fjson = new FeatureJSON(); @SuppressWarnings("rawtypes") FeatureCollection fc = fjson.readFeatureCollection(in); MemoryDataStore dataStore = new MemoryDataStore(); dataStore.addFeatures((SimpleFeatureIterator) fc.features()); return dataStore; } catch (IOException ioe) { throw new CommandFailedException("Error opening GeoJSON: " + ioe.getMessage(), ioe); } }
protected DataStore getDataStore(String geoJSON) throws FileNotFoundException, IOException { try { File geoJsonfile = new File(geoJSON); checkParameter(geoJsonfile.exists(), "File does not exist '%s'", geoJsonfile); InputStream in = new FileInputStream(geoJsonfile); FeatureJSON fjson = new FeatureJSON(); @SuppressWarnings("rawtypes") FeatureCollection fc = fjson.readFeatureCollection(in); MemoryDataStore dataStore = new MemoryDataStore(); dataStore.addFeatures((SimpleFeatureIterator) fc.features()); return dataStore; } catch (IOException ioe) { throw new CommandFailedException("Error opening GeoJSON: " + ioe.getMessage(), ioe); } }
protected DataStore getDataStore(String geoJSON) throws FileNotFoundException, IOException { try { File geoJsonfile = new File(geoJSON); checkParameter(geoJsonfile.exists(), "File does not exist '%s'", geoJsonfile); InputStream in = new FileInputStream(geoJsonfile); FeatureJSON fjson = new FeatureJSON(); @SuppressWarnings("rawtypes") FeatureCollection fc = fjson.readFeatureCollection(in); MemoryDataStore dataStore = new MemoryDataStore(); dataStore.addFeatures((SimpleFeatureIterator) fc.features()); return dataStore; } catch (IOException ioe) { throw new CommandFailedException("Error opening GeoJSON: " + ioe.getMessage(), ioe); } }
@Override public void runInternal(GeogigCLI cli) { final GeoGIG geogig = cli.getGeogig(); checkParameter(commits.size() > 0, "No commits specified."); checkParameter(commits.size() < 2, "Too many commits specified."); CherryPickOp cherryPick = geogig.command(CherryPickOp.class); Optional<ObjectId> commitId; commitId = geogig.command(RevParse.class).setRefSpec(commits.get(0)).call(); checkParameter(commitId.isPresent(), "Commit not found '%s'", commits.get(0)); cherryPick.setCommit(Suppliers.ofInstance(commitId.get())); try { cherryPick.call(); } catch (ConflictsException e) { throw new CommandFailedException(e.getMessage(), true); } } }
@Override public void runInternal(GeogigCLI cli) { final GeoGIG geogig = cli.getGeogig(); checkParameter(commits.size() > 0, "No commits specified."); checkParameter(commits.size() < 2, "Too many commits specified."); CherryPickOp cherryPick = geogig.command(CherryPickOp.class); Optional<ObjectId> commitId; commitId = geogig.command(RevParse.class).setRefSpec(commits.get(0)).call(); checkParameter(commitId.isPresent(), "Commit not found '%s'", commits.get(0)); cherryPick.setCommit(Suppliers.ofInstance(commitId.get())); try { cherryPick.call(); } catch (ConflictsException e) { throw new CommandFailedException(e.getMessage(), true); } } }
@Override public void runInternal(GeogigCLI cli) { final GeoGIG geogig = cli.getGeogig(); checkParameter(commits.size() > 0, "No commits specified."); checkParameter(commits.size() < 2, "Too many commits specified."); CherryPickOp cherryPick = geogig.command(CherryPickOp.class); Optional<ObjectId> commitId; commitId = geogig.command(RevParse.class).setRefSpec(commits.get(0)).call(); checkParameter(commitId.isPresent(), "Commit not found '%s'", commits.get(0)); cherryPick.setCommit(Suppliers.ofInstance(commitId.get())); try { cherryPick.call(); } catch (ConflictsException e) { throw new CommandFailedException(e.getMessage(), true); } } }
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(); } }
@Override public void runInternal(final GeogigCLI cli) throws IOException { String ref; if (refList.isEmpty()) { ref = null; } else { ref = refList.get(0); } final Function<Object, CharSequence> printFunctor = verbose ? VERBOSE_FORMATTER : FORMATTER; Console console = cli.getConsole(); Listener listener = new PrintListener(console, printFunctor); try { cli.getGeogig().command(WalkGraphOp.class).setReference(ref).setListener(listener) .call(); } catch (IllegalArgumentException | IllegalStateException e) { throw new CommandFailedException(e.getMessage(), true); } finally { console.flush(); } }
@Override public void runInternal(final GeogigCLI cli) throws IOException { String ref; if (refList.isEmpty()) { ref = null; } else { ref = refList.get(0); } final Function<Object, CharSequence> printFunctor = verbose ? VERBOSE_FORMATTER : FORMATTER; Console console = cli.getConsole(); Listener listener = new PrintListener(console, printFunctor); try { cli.getGeogig().command(WalkGraphOp.class).setReference(ref).setListener(listener) .call(); } catch (IllegalArgumentException | IllegalStateException e) { throw new CommandFailedException(e.getMessage(), true); } finally { console.flush(); } }
@Override protected GeopkgImportResult callInternal() { GeopkgImportResult result; try { result = command(GeopkgAuditImport.class).setDatabase(geopackage) .setAuthorName(authorName).setAuthorEmail(authorEmail) .setCommitMessage(commitMessage).setTable(table).call(); } catch (IllegalArgumentException | IllegalStateException e) { throw new CommandFailedException(e.getMessage(), e); } return result; } }
@Override protected void runInternal(GeogigCLI cli) throws InvalidParameterException, CommandFailedException, IOException { Repository repository = cli.getGeogig().getRepository(); File databaseFile = new File(commonArgs.database); Preconditions.checkArgument(databaseFile.exists(), "Database file not found."); ProgressListener listener = cli.getProgressListener(); try { GeopkgImportResult result = repository.command(GeopkgAuditImport.class) .setDatabase(databaseFile).setCommitMessage(commitMessage).setTable(table) .setProgressListener(listener).call(); cli.getConsole().println("Import successful."); cli.getConsole().println("Changes committed and merge at " + result.newCommit.getId()); result.close(); } catch (IllegalArgumentException | IllegalStateException e) { throw new CommandFailedException(e.getMessage(), e); } }
@Override protected void runInternal(GeogigCLI cli) throws InvalidParameterException, CommandFailedException, IOException { Repository repository = cli.getGeogig().getRepository(); File databaseFile = new File(commonArgs.database); Preconditions.checkArgument(databaseFile.exists(), "Database file not found."); ProgressListener listener = cli.getProgressListener(); try { GeopkgImportResult result = repository.command(GeopkgAuditImport.class) .setDatabase(databaseFile).setCommitMessage(commitMessage).setTable(table) .setProgressListener(listener).call(); cli.getConsole().println("Import successful."); cli.getConsole().println("Changes committed and merge at " + result.newCommit.getId()); result.close(); } catch (IllegalArgumentException | IllegalStateException | MergeConflictsException e) { throw new CommandFailedException(e.getMessage(), e); } }
@Override protected void runInternal(GeogigCLI cli) throws InvalidParameterException, CommandFailedException, IOException { Repository repository = cli.getGeogig().getRepository(); File databaseFile = new File(commonArgs.database); Preconditions.checkArgument(databaseFile.exists(), "Database file not found."); ProgressListener listener = cli.getProgressListener(); try { GeopkgImportResult result = repository.command(GeopkgAuditImport.class) .setDatabase(databaseFile).setCommitMessage(commitMessage).setTable(table) .setProgressListener(listener).call(); cli.getConsole().println("Import successful."); cli.getConsole().println("Changes committed and merge at " + result.getNewCommit().getId()); result.close(); } catch (IllegalArgumentException | IllegalStateException e) { throw new CommandFailedException(e.getMessage(), e); } }
@Override protected void runInternal(GeogigCLI cli) throws InvalidParameterException, CommandFailedException, IOException { Repository repo = cli.getGeogig().getRepository(); try { repo.command(DropIndexOp.class)// .setTreeRefSpec(treeRefSpec)// .setAttributeName(attribute)// .setProgressListener(cli.getProgressListener())// .call(); } catch (IllegalStateException e) { throw new CommandFailedException(e); } catch (IllegalArgumentException e) { throw new InvalidParameterException(e.getMessage(), e); } cli.getConsole().println("Index successfully dropped."); } }
@Override protected void runInternal(GeogigCLI cli) throws InvalidParameterException, CommandFailedException, IOException { Repository repo = cli.getGeogig().getRepository(); try { repo.command(DropIndexOp.class)// .setTreeRefSpec(treeRefSpec)// .setAttributeName(attribute)// .setProgressListener(cli.getProgressListener())// .call(); } catch (IllegalStateException e) { throw new CommandFailedException(e); } catch (IllegalArgumentException e) { throw new InvalidParameterException(e.getMessage(), e); } cli.getConsole().println("Index successfully dropped."); } }
@Override protected void runInternal(GeogigCLI cli) throws InvalidParameterException, CommandFailedException, IOException { Repository repo = cli.getGeogig().getRepository(); try { int treesRebuilt = repo.command(BuildFullHistoryIndexOp.class)// .setTreeRefSpec(treeRefSpec)// .setAttributeName(attribute)// .setMissingOnly(onlyMissing)// .setProgressListener(cli.getProgressListener())// .call(); cli.getConsole().println(treesRebuilt + " trees were rebuilt."); } catch (IllegalStateException e) { throw new CommandFailedException(e); } catch (IllegalArgumentException e) { throw new InvalidParameterException(e.getMessage(), e); } } }