@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; PhotoModel that = (PhotoModel) o; return Objects.equal(getTitle(), that.getTitle()) && Objects.equal(getFetchableUrl(), that.getFetchableUrl()) && Objects.equal(getDescription(), that.getDescription()) && Objects.equal(getMediaType(), that.getMediaType()) && Objects.equal(getDataId(), that.getDataId()) && Objects.equal(getAlbumId(), that.getAlbumId()); } }
if (photoModel.getDataId() != null) { inputStream = jobStore.getStream(jobId, photoModel.getDataId()); } else if (photoModel.getFetchableUrl() != null) { inputStream = new URL(photoModel.getFetchableUrl()).openStream(); } else { return;
@VisibleForTesting void importSinglePhoto(UUID jobId, PhotoModel inputPhoto, SmugMugInterface smugMugInterface) throws IOException { // Find album to upload photo to TempPhotosData tempPhotosData = jobStore.findData(jobId, createCacheKey(), TempPhotosData.class); checkState( tempPhotosData != null, "cached temp photos data for %s is null", inputPhoto.getAlbumId()); String newAlbumUri = tempPhotosData.lookupNewAlbumId(inputPhoto.getAlbumId()); checkState( !Strings.isNullOrEmpty(newAlbumUri), "Cached album URI for %s is null", inputPhoto.getAlbumId()); InputStream inputStream; if (inputPhoto.isInTempStore()) { inputStream = jobStore.getStream(jobId, inputPhoto.getFetchableUrl()); } else { inputStream = smugMugInterface.getImageAsStream(inputPhoto.getFetchableUrl()); } SmugMugImageUploadResponse response = smugMugInterface.uploadImage(inputPhoto, newAlbumUri, inputStream); }
inputStream = jobStore.getStream(jobId, inputPhoto.getFetchableUrl()); } else { inputStream = imageStreamProvider.get(inputPhoto.getFetchableUrl());
true); InputStream inputStream = smugMugInterface.getImageAsStream(model.getFetchableUrl()); jobStore.create(jobId, model.getFetchableUrl(), inputStream);
@Test public void toCommonPhoto() { Photo photo = FlickrTestUtils.initializePhoto(PHOTO_TITLE, FETCHABLE_URL, PHOTO_DESCRIPTION, MEDIA_TYPE); PhotoModel photoModel = FlickrPhotosExporter.toCommonPhoto(photo, ALBUM_ID); assertThat(photoModel.getAlbumId()).isEqualTo(ALBUM_ID); assertThat(photoModel.getFetchableUrl()).isEqualTo(FETCHABLE_URL); assertThat(photoModel.getTitle()).isEqualTo(PHOTO_TITLE); assertThat(photoModel.getDescription()).isEqualTo(PHOTO_DESCRIPTION); assertThat(photoModel.getMediaType()).isEqualTo("image/jpeg"); }
private String uploadPhoto(PhotoModel photo) throws IOException, FlickrException { BufferedInputStream inStream = imageStreamProvider.get(photo.getFetchableUrl()); UploadMetaData uploadMetaData = new UploadMetaData() .setAsync(false) .setPublicFlag(false) .setFriendFlag(false) .setFamilyFlag(false) .setTitle(COPY_PREFIX + photo.getTitle()) .setDescription(photo.getDescription()); return uploader.upload(inStream, uploadMetaData); }
@Override public ImportResult importItem( UUID jobId, TokenSecretAuthData authData, PhotosContainerResource data) { Twitter twitterApi = TwitterApiWrapper.getInstance(appCredentials, authData); // Twitter doesn't support an 'Albums' concept, so that information is just lost. for (PhotoModel image : data.getPhotos()) { try { StatusUpdate update = new StatusUpdate(image.getDescription()); InputStreamContent content = new InputStreamContent(null, getImageAsStream(image.getFetchableUrl())); update.media(image.getTitle(), content.getInputStream()); twitterApi.tweets().updateStatus(update); } catch (IOException | TwitterException e) { monitor.severe(() -> "Error importing twitter photo", e); return new ImportResult(e); } } return new ImportResult(ResultType.OK); }