use of org.locationtech.geogig.remote.IRemoteRepo in project GeoGig by boundlessgeo.
the class RemoteWebOp method remotePing.
private void remotePing(CommandContext context, final Context geogig) {
Optional<Remote> remote = geogig.command(RemoteResolve.class).setName(remoteName).call();
final boolean remotePingResponse;
if (remote.isPresent()) {
Optional<IRemoteRepo> remoteRepo = RemoteUtils.newRemote(GlobalContextBuilder.builder.build(), remote.get(), null, null);
Ref ref = null;
if (remoteRepo.isPresent()) {
try {
remoteRepo.get().open();
ref = remoteRepo.get().headRef();
remoteRepo.get().close();
} catch (IOException e) {
// Do nothing, we will write the response later.
}
}
remotePingResponse = ref != null;
} else {
remotePingResponse = false;
}
context.setResponseContent(new CommandResponse() {
@Override
public void write(ResponseWriter out) throws Exception {
out.start();
out.writeRemotePingResponse(remotePingResponse);
out.finish();
}
});
}
Aggregations