Search in sources :

Example 1 with SmugMugUserResponse

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));
}
Also used : SmugMugUserResponse(org.dataportabilityproject.serviceProviders.smugmug.model.SmugMugUserResponse) ArrayList(java.util.ArrayList) Resource(org.dataportabilityproject.dataModels.Resource) IdOnlyResource(org.dataportabilityproject.shared.IdOnlyResource) PhotosModelWrapper(org.dataportabilityproject.dataModels.photos.PhotosModelWrapper) IdOnlyResource(org.dataportabilityproject.shared.IdOnlyResource) SmugmugAlbumsResponse(org.dataportabilityproject.serviceProviders.smugmug.model.SmugmugAlbumsResponse) ContinuationInformation(org.dataportabilityproject.dataModels.ContinuationInformation) SmugMugAlbum(org.dataportabilityproject.serviceProviders.smugmug.model.SmugMugAlbum) PhotoAlbum(org.dataportabilityproject.dataModels.photos.PhotoAlbum) StringPaginationToken(org.dataportabilityproject.shared.StringPaginationToken)

Example 2 with SmugMugUserResponse

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);
    }
}
Also used : SmugMugUserResponse(org.dataportabilityproject.serviceProviders.smugmug.model.SmugMugUserResponse) PhotoModel(org.dataportabilityproject.dataModels.photos.PhotoModel) PhotoAlbum(org.dataportabilityproject.dataModels.photos.PhotoAlbum)

Aggregations

PhotoAlbum (org.dataportabilityproject.dataModels.photos.PhotoAlbum)2 SmugMugUserResponse (org.dataportabilityproject.serviceProviders.smugmug.model.SmugMugUserResponse)2 ArrayList (java.util.ArrayList)1 ContinuationInformation (org.dataportabilityproject.dataModels.ContinuationInformation)1 Resource (org.dataportabilityproject.dataModels.Resource)1 PhotoModel (org.dataportabilityproject.dataModels.photos.PhotoModel)1 PhotosModelWrapper (org.dataportabilityproject.dataModels.photos.PhotosModelWrapper)1 SmugMugAlbum (org.dataportabilityproject.serviceProviders.smugmug.model.SmugMugAlbum)1 SmugmugAlbumsResponse (org.dataportabilityproject.serviceProviders.smugmug.model.SmugmugAlbumsResponse)1 IdOnlyResource (org.dataportabilityproject.shared.IdOnlyResource)1 StringPaginationToken (org.dataportabilityproject.shared.StringPaginationToken)1