use of org.dataportabilityproject.serviceProviders.smugmug.model.SmugMugUserResponse in project data-transfer-project by google.
the class SmugMugPhotoService method getAlbums.
private PhotosModelWrapper getAlbums(Optional<PaginationInformation> paginationInformation) throws IOException {
String albumUri;
if (paginationInformation.isPresent()) {
albumUri = ((StringPaginationToken) paginationInformation.get()).getId();
} else {
SmugMugResponse<SmugMugUserResponse> userResponse = makeUserRequest(USER_URL);
albumUri = userResponse.getResponse().getUser().getUris().get("UserAlbums").getUri();
}
List<PhotoAlbum> albums = new ArrayList<>();
List<Resource> resources = new ArrayList<>();
SmugMugResponse<SmugmugAlbumsResponse> albumResponse = makeAlbumRequest(albumUri);
for (SmugMugAlbum album : albumResponse.getResponse().getAlbums()) {
albums.add(new PhotoAlbum(album.getAlbumKey(), album.getTitle(), album.getDescription()));
resources.add(new IdOnlyResource(album.getAlbumKey()));
}
StringPaginationToken pageToken = null;
if (albumResponse.getResponse().getPageInfo() != null && albumResponse.getResponse().getPageInfo().getNextPage() != null) {
pageToken = new StringPaginationToken(albumResponse.getResponse().getPageInfo().getNextPage());
}
return new PhotosModelWrapper(albums, null, new ContinuationInformation(resources, pageToken));
}
use of org.dataportabilityproject.serviceProviders.smugmug.model.SmugMugUserResponse in project data-transfer-project by google.
the class SmugMugPhotoService method importItem.
@Override
public void importItem(PhotosModelWrapper wrapper) throws IOException {
String folder = null;
if (!wrapper.getAlbums().isEmpty()) {
SmugMugResponse<SmugMugUserResponse> userResponse = makeUserRequest(USER_URL);
folder = userResponse.getResponse().getUser().getUris().get("Folder").getUri();
}
for (PhotoAlbum album : wrapper.getAlbums()) {
createAlbum(folder, album);
}
for (PhotoModel photo : wrapper.getPhotos()) {
uploadPhoto(photo);
}
}
Aggregations