use of org.dataportabilityproject.transfer.smugmug.photos.model.SmugMugAlbumResponse in project data-transfer-project by google.
the class SmugMugPhotosImporter method importSingleAlbum.
@VisibleForTesting
void importSingleAlbum(UUID jobId, String folder, PhotoAlbum inputAlbum) throws IOException {
// Set up album
Map<String, String> json = new HashMap<>();
String niceName = "Copy-" + inputAlbum.getName().replace(' ', '-');
json.put("UrlName", niceName);
// Allow conflicting names to be changed
json.put("AutoRename", "true");
json.put("Name", "Copy of " + inputAlbum.getName());
// All imported content is private by default.
json.put("Privacy", "Private");
HttpContent content = new JsonHttpContent(new JacksonFactory(), json);
// Upload album
SmugMugResponse<SmugMugAlbumResponse> response = smugMugInterface.postRequest(folder + "!albums", content, ImmutableMap.of(), new TypeReference<SmugMugResponse<SmugMugAlbumResponse>>() {
});
checkState(response.getResponse() != null, "Response is null");
checkState(response.getResponse().getAlbum() != null, "Album is null");
// Put new album ID in job store so photos can be assigned to correct album
// TODO(olsona): thread safety!
TempPhotosData tempPhotosData = jobStore.findData(TempPhotosData.class, jobId);
if (tempPhotosData == null) {
tempPhotosData = new TempPhotosData(jobId);
jobStore.create(jobId, tempPhotosData);
}
tempPhotosData.addAlbumId(inputAlbum.getId(), response.getResponse().getAlbum().getAlbumKey());
}
Aggregations