use of org.locationtech.geogig.api.porcelain.RemoteException in project GeoGig by boundlessgeo.
the class RemoteWebOp method remoteRemove.
private void remoteRemove(CommandContext context, final Context geogig) {
if (remoteName == null || remoteName.trim().isEmpty()) {
throw new CommandSpecException("No remote was specified.");
}
final Remote remote;
try {
remote = geogig.command(RemoteRemoveOp.class).setName(remoteName).call();
} catch (RemoteException e) {
context.setResponseContent(CommandResponse.error(e.statusCode.toString()));
return;
} catch (Exception e) {
context.setResponseContent(CommandResponse.error("Aborting Remote Remove"));
return;
}
context.setResponseContent(new CommandResponse() {
@Override
public void write(ResponseWriter out) throws Exception {
out.start();
out.writeElement("name", remote.getName());
out.finish();
}
});
}
use of org.locationtech.geogig.api.porcelain.RemoteException in project GeoGig by boundlessgeo.
the class RemoteWebOp method remoteUpdate.
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;
try {
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();
}
});
} catch (RemoteException e) {
context.setResponseContent(CommandResponse.error(e.statusCode.toString()));
} catch (Exception e) {
context.setResponseContent(CommandResponse.error("Aborting Remote Update"));
}
}
use of org.locationtech.geogig.api.porcelain.RemoteException 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