use of org.datatransferproject.transfer.koofr.common.KoofrClient in project data-transfer-project by google.
the class KoofrPhotosImporter method importItem.
@Override
public ImportResult importItem(UUID jobId, IdempotentImportExecutor idempotentImportExecutor, TokensAndUrlAuthData authData, PhotosContainerResource resource) throws Exception {
KoofrClient koofrClient = koofrClientFactory.create(authData);
monitor.debug(() -> String.format("%s: Importing %s albums and %s photos before transmogrification", jobId, resource.getAlbums().size(), resource.getPhotos().size()));
// Make the data Koofr compatible
resource.transmogrify(transmogrificationConfig);
monitor.debug(() -> String.format("%s: Importing %s albums and %s photos after transmogrification", jobId, resource.getAlbums().size(), resource.getPhotos().size()));
for (PhotoAlbum album : resource.getAlbums()) {
// Create a Koofr folder and then save the id with the mapping data
idempotentImportExecutor.executeAndSwallowIOExceptions(album.getId(), album.getName(), () -> createAlbumFolder(album, koofrClient));
}
for (PhotoModel photoModel : resource.getPhotos()) {
idempotentImportExecutor.executeAndSwallowIOExceptions(IdempotentImportExecutorHelper.getPhotoIdempotentId(photoModel), photoModel.getTitle(), () -> importSinglePhoto(photoModel, jobId, idempotentImportExecutor, koofrClient));
}
return ImportResult.OK;
}
use of org.datatransferproject.transfer.koofr.common.KoofrClient in project data-transfer-project by google.
the class KoofrVideosImporter method importItem.
@Override
public ImportResult importItem(UUID jobId, IdempotentImportExecutor idempotentImportExecutor, TokensAndUrlAuthData authData, VideosContainerResource resource) throws Exception {
KoofrClient koofrClient = koofrClientFactory.create(authData);
monitor.debug(() -> String.format("%s: Importing %s albums and %s videos", jobId, resource.getAlbums().size(), resource.getVideos().size()));
for (VideoAlbum album : resource.getAlbums()) {
// Create a Koofr folder and then save the id with the mapping data
idempotentImportExecutor.executeAndSwallowIOExceptions(album.getId(), album.getName(), () -> createAlbumFolder(album, koofrClient));
}
for (VideoModel videoModel : resource.getVideos()) {
String id;
if (videoModel.getAlbumId() == null) {
id = videoModel.getDataId();
} else {
id = videoModel.getAlbumId() + "-" + videoModel.getDataId();
}
idempotentImportExecutor.executeAndSwallowIOExceptions(id, videoModel.getName(), () -> importSingleVideo(videoModel, jobId, idempotentImportExecutor, koofrClient));
}
return ImportResult.OK;
}
use of org.datatransferproject.transfer.koofr.common.KoofrClient in project data-transfer-project by google.
the class KoofrPhotosExporter method export.
@Override
public ExportResult<PhotosContainerResource> export(UUID jobId, TokensAndUrlAuthData authData, Optional<ExportInformation> exportInformation) throws CopyExceptionWithFailureReason {
Preconditions.checkNotNull(authData);
KoofrClient koofrClient = koofrClientFactory.create(authData);
KoofrMediaExport export = new KoofrMediaExport(koofrClient, monitor);
try {
export.export();
List<PhotoAlbum> exportAlbums = export.getPhotoAlbums();
List<PhotoModel> exportPhotos = export.getPhotos();
PhotosContainerResource containerResource = new PhotosContainerResource(exportAlbums, exportPhotos);
return new ExportResult<>(ExportResult.ResultType.END, containerResource, null);
} catch (IOException e) {
return new ExportResult<>(e);
}
}
use of org.datatransferproject.transfer.koofr.common.KoofrClient in project data-transfer-project by google.
the class KoofrVideosExporter method export.
@Override
public ExportResult<VideosContainerResource> export(UUID jobId, TokensAndUrlAuthData authData, Optional<ExportInformation> exportInformation) throws CopyExceptionWithFailureReason {
Preconditions.checkNotNull(authData);
KoofrClient koofrClient = koofrClientFactory.create(authData);
KoofrMediaExport export = new KoofrMediaExport(koofrClient, monitor);
try {
export.export();
List<VideoAlbum> exportAlbums = export.getVideoAlbums();
List<VideoModel> exportVideos = export.getVideos();
VideosContainerResource containerResource = new VideosContainerResource(exportAlbums, exportVideos);
return new ExportResult<>(ExportResult.ResultType.END, containerResource, null);
} catch (IOException e) {
return new ExportResult<>(e);
}
}
Aggregations