use of org.locationtech.geogig.web.api.ResponseWriter in project GeoGig by boundlessgeo.
the class RemoteWebOp method remoteList.
private void remoteList(CommandContext context, final Context geogig) {
final List<Remote> remotes = geogig.command(RemoteListOp.class).call();
context.setResponseContent(new CommandResponse() {
@Override
public void write(ResponseWriter out) throws Exception {
out.start();
out.writeRemoteListResponse(remotes, verbose);
out.finish();
}
});
}
use of org.locationtech.geogig.web.api.ResponseWriter in project GeoGig by boundlessgeo.
the class RemoteWebOp method remoteAdd.
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();
context.setResponseContent(new CommandResponse() {
@Override
public void write(ResponseWriter out) throws Exception {
out.start();
out.writeElement("name", remote.getName());
out.finish();
}
});
} catch (RemoteException e) {
context.setResponseContent(CommandResponse.error(e.statusCode.toString()));
} catch (Exception e) {
context.setResponseContent(CommandResponse.error("Aborting Remote Add"));
}
}
Aggregations