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); } }
/** * Executes the export command using the provided options. */ @Override protected void runInternal(GeogigCLI cli) throws IOException { Preconditions.checkNotNull(mappingFile != null, "A data mapping file must be specified"); if (args == null || args.isEmpty() || args.size() != 1) { printUsage(cli); throw new CommandFailedException(); } String shapefile = args.get(0); final File file = new File(shapefile); final Mapping mapping = Mapping.fromFile(mappingFile); List<MappingRule> rules = mapping.getRules(); checkParameter(!rules.isEmpty(), "No rules are defined in the specified mapping"); for (MappingRule rule : rules) { File targetFile = file; if (rules.size() > 1) { String name = getNameWithoutExtension(file.getName()) + "_" + rule.getName() + ".shp"; targetFile = new File(file.getParentFile(), name); } exportRule(rule, cli, targetFile); } }
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); } }
/** * Executes the export command using the provided options. */ @Override protected void runInternal(GeogigCLI cli) throws IOException { if (args.size() != 2) { printUsage(cli); throw new CommandFailedException(); } final String sourceTreeIsh = args.get(0); final String targetTableName = args.get(1); checkParameter(targetTableName != null && !targetTableName.isEmpty(), "No table name specified"); DataStore dataStore = getDataStore(); try { exportInternal(cli, sourceTreeIsh, targetTableName, dataStore); } finally { dataStore.dispose(); } }
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); } }
/** * Executes the export command using the provided options. */ @Override protected void runInternal(GeogigCLI cli) throws IOException { if (args.size() != 2) { printUsage(cli); throw new CommandFailedException(); } final String sourceTreeIsh = args.get(0); final String targetTableName = args.get(1); checkParameter(targetTableName != null && !targetTableName.isEmpty(), "No table name specified"); DataStore dataStore = getDataStore(); try { exportInternal(cli, sourceTreeIsh, targetTableName, dataStore); } finally { dataStore.dispose(); } }
/** * Executes the export command using the provided options. */ @Override protected void runInternal(GeogigCLI cli) throws IOException { if (args.size() != 2) { printUsage(cli); throw new CommandFailedException(); } final String sourceTreeIsh = args.get(0); final String targetTableName = args.get(1); checkParameter(targetTableName != null && !targetTableName.isEmpty(), "No table name specified"); DataStore dataStore = getDataStore(); try { exportInternal(cli, sourceTreeIsh, targetTableName, dataStore); } finally { dataStore.dispose(); } }
/** * Executes the remote remove command. */ @Override public void runInternal(GeogigCLI cli) { if (params == null || params.size() != 1) { printUsage(cli); throw new CommandFailedException(); } try { cli.getGeogig().command(RemoteRemoveOp.class).setName(params.get(0)).call(); } catch (RemoteException e) { switch (e.statusCode) { case REMOTE_NOT_FOUND: throw new InvalidParameterException( "Could not find a remote called '" + params.get(0) + "'.", e); default: throw new CommandFailedException(e.getMessage(), e); } } }
/** * Executes the remote remove command. */ @Override public void runInternal(GeogigCLI cli) { if (params == null || params.size() != 1) { printUsage(cli); throw new CommandFailedException(); } try { cli.getGeogig().command(RemoteRemoveOp.class).setName(params.get(0)).call(); } catch (RemoteException e) { switch (e.statusCode) { case REMOTE_NOT_FOUND: throw new InvalidParameterException( "Could not find a remote called '" + params.get(0) + "'.", e); default: throw new CommandFailedException(e.getMessage(), e); } } }
/** * Executes the remote remove command. */ @Override public void runInternal(GeogigCLI cli) { if (params == null || params.size() != 1) { printUsage(cli); throw new CommandFailedException(); } try { cli.getGeogig().command(RemoteRemoveOp.class).setName(params.get(0)).call(); } catch (RemoteException e) { switch (e.statusCode) { case REMOTE_NOT_FOUND: throw new InvalidParameterException( "Could not find a remote called '" + params.get(0) + "'.", e); default: throw new CommandFailedException(e.getMessage(), e); } } }
@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); } } }
/** * Executes the remote add command using the provided options. */ @Override public void runInternal(GeogigCLI cli) { if (params == null || params.size() != 2) { printUsage(cli); throw new CommandFailedException(); } try { cli.getGeogig().command(RemoteAddOp.class).setName(params.get(0)).setURL(params.get(1)) .setBranch(branch).setUserName(username).setPassword(password).call(); } catch (RemoteException e) { switch (e.statusCode) { case REMOTE_ALREADY_EXISTS: throw new InvalidParameterException( "Could not add, a remote called '" + params.get(0) + "' already exists.", e); default: throw new CommandFailedException(e); } } }
/** * Executes the remote add command using the provided options. */ @Override public void runInternal(GeogigCLI cli) { if (params == null || params.size() != 2) { printUsage(cli); throw new CommandFailedException(); } try { cli.getGeogig().command(RemoteAddOp.class).setName(params.get(0)).setURL(params.get(1)) .setBranch(branch).setUserName(username).setPassword(password).call(); } catch (RemoteException e) { switch (e.statusCode) { case REMOTE_ALREADY_EXISTS: throw new InvalidParameterException( "Could not add, a remote called '" + params.get(0) + "' already exists.", e); default: throw new CommandFailedException(e); } } }
/** * Executes the remote add command using the provided options. */ @Override public void runInternal(GeogigCLI cli) { if (params == null || params.size() != 2) { printUsage(cli); throw new CommandFailedException(); } try { cli.getGeogig().command(RemoteAddOp.class).setName(params.get(0)).setURL(params.get(1)) .setBranch(branch).setUserName(username).setPassword(password).call(); } catch (RemoteException e) { switch (e.statusCode) { case REMOTE_ALREADY_EXISTS: throw new InvalidParameterException( "Could not add, a remote called '" + params.get(0) + "' already exists.", e); default: throw new CommandFailedException(e); } } }