try {
ImmutableList.Builder<SnapshotInfo> snapshotInfoBuilder = ImmutableList.builder();
if (snapshotIds.length > 0) {
for (SnapshotId snapshotId : snapshotIds) {
snapshotInfoBuilder.add(new SnapshotInfo(snapshotsService.snapshot(snapshotId)));
}
} else {
ImmutableList<Snapshot> snapshots = snapshotsService.snapshots(request.repository());
for (Snapshot snapshot : snapshots) {
snapshotInfoBuilder.add(new SnapshotInfo(snapshot));
}
}
listener.onResponse(new GetSnapshotsResponse(snapshotInfoBuilder.build()));
} catch (Throwable t) {
listener.onFailure(t);