Search in sources :

Example 1 with TemporaryPerJobDataStore

use of org.datatransferproject.spi.cloud.storage.TemporaryPerJobDataStore in project data-transfer-project by google.

the class DaybookTransferExtension method initialize.

@Override
public void initialize(ExtensionContext context) {
    Monitor monitor = context.getMonitor();
    if (initialized) {
        monitor.severe(() -> "DaybookTransferExtension is already initialized");
        return;
    }
    ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    OkHttpClient client = context.getService(OkHttpClient.class);
    TemporaryPerJobDataStore jobStore = context.getService(TemporaryPerJobDataStore.class);
    ImmutableMap.Builder<String, Importer> importerBuilder = ImmutableMap.builder();
    importerBuilder.put("PHOTOS", new DaybookPhotosImporter(monitor, client, mapper, jobStore, BASE_URL));
    importerBuilder.put("SOCIAL-POSTS", new DaybookPostsImporter(monitor, client, mapper, BASE_URL));
    importerMap = importerBuilder.build();
    initialized = true;
}
Also used : TemporaryPerJobDataStore(org.datatransferproject.spi.cloud.storage.TemporaryPerJobDataStore) Monitor(org.datatransferproject.api.launcher.Monitor) OkHttpClient(okhttp3.OkHttpClient) DaybookPostsImporter(org.datatransferproject.transfer.daybook.social.DaybookPostsImporter) DaybookPhotosImporter(org.datatransferproject.transfer.daybook.photos.DaybookPhotosImporter) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ImmutableMap(com.google.common.collect.ImmutableMap) DaybookPostsImporter(org.datatransferproject.transfer.daybook.social.DaybookPostsImporter) DaybookPhotosImporter(org.datatransferproject.transfer.daybook.photos.DaybookPhotosImporter) Importer(org.datatransferproject.spi.transfer.provider.Importer)

Example 2 with TemporaryPerJobDataStore

use of org.datatransferproject.spi.cloud.storage.TemporaryPerJobDataStore in project data-transfer-project by google.

the class BackblazeTransferExtension method initialize.

@Override
public void initialize(ExtensionContext context) {
    Monitor monitor = context.getMonitor();
    monitor.debug(() -> "Starting Backblaze initialization");
    if (initialized) {
        monitor.severe(() -> "BackblazeTransferExtension already initialized.");
        return;
    }
    TemporaryPerJobDataStore jobStore = context.getService(TemporaryPerJobDataStore.class);
    ImmutableMap.Builder<String, Importer> importerBuilder = ImmutableMap.builder();
    BackblazeDataTransferClientFactory backblazeDataTransferClientFactory = new BackblazeDataTransferClientFactory(monitor);
    ImageStreamProvider isProvider = new ImageStreamProvider();
    importerBuilder.put("PHOTOS", new BackblazePhotosImporter(monitor, jobStore, isProvider, backblazeDataTransferClientFactory));
    importerBuilder.put("VIDEOS", new BackblazeVideosImporter(monitor, jobStore, isProvider, backblazeDataTransferClientFactory));
    importerMap = importerBuilder.build();
    initialized = true;
}
Also used : BackblazeDataTransferClientFactory(org.datatransferproject.datatransfer.backblaze.common.BackblazeDataTransferClientFactory) TemporaryPerJobDataStore(org.datatransferproject.spi.cloud.storage.TemporaryPerJobDataStore) BackblazePhotosImporter(org.datatransferproject.datatransfer.backblaze.photos.BackblazePhotosImporter) Monitor(org.datatransferproject.api.launcher.Monitor) ImageStreamProvider(org.datatransferproject.transfer.ImageStreamProvider) BackblazeVideosImporter(org.datatransferproject.datatransfer.backblaze.videos.BackblazeVideosImporter) ImmutableMap(com.google.common.collect.ImmutableMap) BackblazeVideosImporter(org.datatransferproject.datatransfer.backblaze.videos.BackblazeVideosImporter) BackblazePhotosImporter(org.datatransferproject.datatransfer.backblaze.photos.BackblazePhotosImporter) Importer(org.datatransferproject.spi.transfer.provider.Importer)

Example 3 with TemporaryPerJobDataStore

use of org.datatransferproject.spi.cloud.storage.TemporaryPerJobDataStore in project data-transfer-project by google.

the class SmugMugTransferExtension method initialize.

@Override
public void initialize(ExtensionContext context) {
    Monitor monitor = context.getMonitor();
    if (initialized) {
        monitor.severe(() -> "SmugMugTransferExtension already initailized.");
        return;
    }
    TemporaryPerJobDataStore jobStore = context.getService(TemporaryPerJobDataStore.class);
    AppCredentials appCredentials;
    try {
        appCredentials = context.getService(AppCredentialStore.class).getAppCredentials(SMUGMUG_KEY, SMUGMUG_SECRET);
    } catch (IOException e) {
        monitor.info(() -> format("Unable to retrieve SmugMug AppCredentials. Did you set %s and %s?", SMUGMUG_KEY, SMUGMUG_SECRET), e);
        return;
    }
    ObjectMapper mapper = context.getService(TypeManager.class).getMapper();
    exporter = new SmugMugPhotosExporter(appCredentials, mapper, jobStore, monitor);
    importer = new SmugMugPhotosImporter(jobStore, appCredentials, mapper, monitor);
    initialized = true;
}
Also used : TemporaryPerJobDataStore(org.datatransferproject.spi.cloud.storage.TemporaryPerJobDataStore) Monitor(org.datatransferproject.api.launcher.Monitor) AppCredentials(org.datatransferproject.types.transfer.auth.AppCredentials) TypeManager(org.datatransferproject.api.launcher.TypeManager) SmugMugPhotosImporter(org.datatransferproject.transfer.smugmug.photos.SmugMugPhotosImporter) SmugMugPhotosExporter(org.datatransferproject.transfer.smugmug.photos.SmugMugPhotosExporter) IOException(java.io.IOException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 4 with TemporaryPerJobDataStore

use of org.datatransferproject.spi.cloud.storage.TemporaryPerJobDataStore in project data-transfer-project by google.

the class GoogleVideosImporterTest method setUp.

@Before
public void setUp() throws Exception {
    // Create files so we can accurately check the length of file counting
    TemporaryPerJobDataStore dataStore = mock(TemporaryPerJobDataStore.class);
    TemporaryFolder folder = new TemporaryFolder();
    folder.create();
    File file1 = folder.newFile();
    Files.write(new byte[32], file1);
    File file2 = folder.newFile();
    Files.write(new byte[32], file2);
    when(dataStore.getTempFileFromInputStream(any(), any(), any())).thenReturn(file1, file2);
    streamProvider = mock(ImageStreamProvider.class);
    when(streamProvider.getConnection(any())).thenReturn(mock(HttpURLConnection.class));
    googleVideosImporter = new GoogleVideosImporter(null, dataStore, mock(Monitor.class), streamProvider);
}
Also used : TemporaryPerJobDataStore(org.datatransferproject.spi.cloud.storage.TemporaryPerJobDataStore) HttpURLConnection(java.net.HttpURLConnection) TemporaryFolder(org.junit.rules.TemporaryFolder) ImageStreamProvider(org.datatransferproject.transfer.ImageStreamProvider) File(java.io.File) Before(org.junit.Before)

Example 5 with TemporaryPerJobDataStore

use of org.datatransferproject.spi.cloud.storage.TemporaryPerJobDataStore in project data-transfer-project by google.

the class ImgurTransferExtension method initialize.

@Override
public void initialize(ExtensionContext context) {
    Monitor monitor = context.getMonitor();
    if (initialized) {
        monitor.severe(() -> "ImgurTransferExtension is already initialized");
        return;
    }
    ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    OkHttpClient client = context.getService(OkHttpClient.class);
    TemporaryPerJobDataStore jobStore = context.getService(TemporaryPerJobDataStore.class);
    exporter = new ImgurPhotosExporter(monitor, client, mapper, jobStore, BASE_URL);
    importer = new ImgurPhotosImporter(monitor, client, mapper, jobStore, BASE_URL);
    initialized = true;
}
Also used : TemporaryPerJobDataStore(org.datatransferproject.spi.cloud.storage.TemporaryPerJobDataStore) Monitor(org.datatransferproject.api.launcher.Monitor) OkHttpClient(okhttp3.OkHttpClient) ImgurPhotosImporter(org.datatransferproject.datatransfer.imgur.photos.ImgurPhotosImporter) ImgurPhotosExporter(org.datatransferproject.datatransfer.imgur.photos.ImgurPhotosExporter) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

TemporaryPerJobDataStore (org.datatransferproject.spi.cloud.storage.TemporaryPerJobDataStore)7 Monitor (org.datatransferproject.api.launcher.Monitor)5 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 ImmutableMap (com.google.common.collect.ImmutableMap)3 OkHttpClient (okhttp3.OkHttpClient)3 Importer (org.datatransferproject.spi.transfer.provider.Importer)3 ImageStreamProvider (org.datatransferproject.transfer.ImageStreamProvider)3 AppCredentials (org.datatransferproject.types.transfer.auth.AppCredentials)3 IOException (java.io.IOException)2 HttpURLConnection (java.net.HttpURLConnection)2 Before (org.junit.Before)2 HttpTransport (com.google.api.client.http.HttpTransport)1 JsonFactory (com.google.api.client.json.JsonFactory)1 Album (com.restfb.types.Album)1 Photo (com.restfb.types.Photo)1 File (java.io.File)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 TypeManager (org.datatransferproject.api.launcher.TypeManager)1 BackblazeDataTransferClientFactory (org.datatransferproject.datatransfer.backblaze.common.BackblazeDataTransferClientFactory)1