use of org.dataportabilityproject.serviceProviders.smugmug.model.SmugMugAlbumImage in project data-transfer-project by google.
the class SmugMugPhotoService method getImages.
private PhotosModelWrapper getImages(IdOnlyResource resource, Optional<PaginationInformation> paginationInformation) throws IOException {
List<PhotoModel> photos = new ArrayList<>();
String url;
if (paginationInformation.isPresent()) {
url = ((StringPaginationToken) paginationInformation.get()).getId();
} else {
String id = resource.getId();
url = "/api/v2/album/" + id + "!images";
}
StringPaginationToken pageToken = null;
SmugMugResponse<SmugMugAlbumInfoResponse> albumInfoResponse = makeAlbumInfoRequest(url);
if (albumInfoResponse.getResponse().getImages() != null) {
for (SmugMugAlbumImage image : albumInfoResponse.getResponse().getImages()) {
String title = image.getTitle();
if (Strings.isNullOrEmpty(title)) {
title = image.getFileName();
}
try {
photos.add(new PhotoModel(title, this.authConsumer.sign(image.getArchivedUri()), image.getCaption(), image.getFormat(), resource.getId()));
} catch (OAuthException e) {
throw new IOException("Couldn't sign: " + image.getArchivedUri(), e);
}
}
if (albumInfoResponse.getResponse().getPageInfo().getNextPage() != null) {
pageToken = new StringPaginationToken(albumInfoResponse.getResponse().getPageInfo().getNextPage());
}
}
return new PhotosModelWrapper(null, photos, new ContinuationInformation(null, pageToken));
}
Aggregations