private void remoteAdd(CommandContext context, final Context geogig) { if (remoteName == null || remoteName.trim().isEmpty()) { throw new CommandSpecException("No remote was specified."); } else if (remoteURL == null || remoteURL.trim().isEmpty()) { throw new CommandSpecException("No URL was specified."); } final Remote remote; try { remote = geogig.command(RemoteAddOp.class).setName(remoteName).setURL(remoteURL) .setUserName(username).setPassword(password).call(); } catch (RemoteException re) { throw new CommandSpecException(re.statusCode.toString(), HttpStatus.BAD_REQUEST); } context.setResponseContent(new CommandResponse() { @Override public void write(ResponseWriter out) throws Exception { out.start(); out.writeElement("name", remote.getName()); out.finish(); } }); }
private void remoteUpdate(CommandContext context, final Context geogig) { if (remoteName == null || remoteName.trim().isEmpty()) { throw new CommandSpecException("No remote was specified."); } else if (remoteURL == null || remoteURL.trim().isEmpty()) { throw new CommandSpecException("No URL was specified."); } final Remote newRemote; if (newName != null && !newName.trim().isEmpty() && !newName.equals(remoteName)) { newRemote = geogig.command(RemoteAddOp.class).setName(newName).setURL(remoteURL) .setUserName(username).setPassword(password).call(); geogig.command(RemoteRemoveOp.class).setName(remoteName).call(); } else { geogig.command(RemoteRemoveOp.class).setName(remoteName).call(); newRemote = geogig.command(RemoteAddOp.class).setName(remoteName).setURL(remoteURL) .setUserName(username).setPassword(password).call(); } context.setResponseContent(new CommandResponse() { @Override public void write(ResponseWriter out) throws Exception { out.start(); out.writeElement("name", newRemote.getName()); out.finish(); } }); }
private Remote addRemote(Repository clone) { final boolean sparse = clone.isSparse(); if (sparse) { checkArgument(this.branch.isPresent(), "No branch specified for sparse clone."); } {// won't be necessary once ClopeOp actually creates the clone repo Optional<Remote> remote = clone.command(RemoteResolve.class).setName(remoteName).call(); if (remote.isPresent()) { clone.command(RemoteRemoveOp.class).setName(remoteName).call(); } } final @Nullable String branch = this.branch.orNull(); Remote remote = clone.command(RemoteAddOp.class)// .setName(remoteName)// .setURL(remoteURI.toString())// .setMapped(sparse)// .setUserName(username)// .setPassword(password)// .setBranch(branch).// call(); return remote; }
/** * 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); } } }
cmd.setURL(ri.getURL()); cmd.setUserName(ri.getUserName()); cmd.setPassword(ri.getPassword()); try { cmd.call(); .setURL(ri.getURL()) .setUserName(ri.getUserName()) .setPassword(ri.getPassword()); addop.call(); } catch (RuntimeException e) {