Search in sources :

Example 31 with Monitor

use of org.datatransferproject.api.launcher.Monitor in project data-transfer-project by google.

the class FacebookTransferExtension method initialize.

@Override
public void initialize(ExtensionContext context) {
    if (initialized)
        return;
    AppCredentials appCredentials;
    final Monitor monitor = context.getMonitor();
    try {
        appCredentials = context.getService(AppCredentialStore.class).getAppCredentials("FACEBOOK_KEY", "FACEBOOK_SECRET");
    } catch (IOException e) {
        monitor.info(() -> "Unable to retrieve Facebook AppCredentials. Did you set FACEBOOK_KEY and FACEBOOK_SECRET?", e);
        return;
    }
    ImmutableMap.Builder<String, Importer> importerBuilder = ImmutableMap.builder();
    importerBuilder.put("VIDEOS", new FacebookVideosImporter(appCredentials));
    importerMap = importerBuilder.build();
    ImmutableMap.Builder<String, Exporter> exporterBuilder = ImmutableMap.builder();
    exporterBuilder.put("PHOTOS", new FacebookPhotosExporter(appCredentials, monitor, context.getService(TemporaryPerJobDataStore.class)));
    exporterBuilder.put("VIDEOS", new FacebookVideosExporter(appCredentials, monitor));
    exporterMap = exporterBuilder.build();
    initialized = true;
}
Also used : Monitor(org.datatransferproject.api.launcher.Monitor) AppCredentials(org.datatransferproject.types.transfer.auth.AppCredentials) FacebookPhotosExporter(org.datatransferproject.transfer.facebook.photos.FacebookPhotosExporter) FacebookVideosExporter(org.datatransferproject.transfer.facebook.videos.FacebookVideosExporter) FacebookVideosImporter(org.datatransferproject.transfer.facebook.videos.FacebookVideosImporter) IOException(java.io.IOException) Exporter(org.datatransferproject.spi.transfer.provider.Exporter) FacebookVideosExporter(org.datatransferproject.transfer.facebook.videos.FacebookVideosExporter) FacebookPhotosExporter(org.datatransferproject.transfer.facebook.photos.FacebookPhotosExporter) ImmutableMap(com.google.common.collect.ImmutableMap) Importer(org.datatransferproject.spi.transfer.provider.Importer) FacebookVideosImporter(org.datatransferproject.transfer.facebook.videos.FacebookVideosImporter)

Example 32 with Monitor

use of org.datatransferproject.api.launcher.Monitor in project data-transfer-project by google.

the class DeezerTransferExtension method initialize.

@Override
public void initialize(ExtensionContext context) {
    if (initialized) {
        Monitor monitor = context.getMonitor();
        monitor.severe(() -> "DeezerTransferExtension already initialized");
        return;
    }
    Monitor monitor = context.getMonitor();
    HttpTransport httpTransport = context.getService(HttpTransport.class);
    TransferServiceConfig transferServiceConfig = context.getService(TransferServiceConfig.class);
    exporter = new DeezerPlaylistExporter(monitor, httpTransport, transferServiceConfig);
    importer = new DeezerPlaylistImporter(monitor, httpTransport, transferServiceConfig);
    initialized = true;
}
Also used : HttpTransport(com.google.api.client.http.HttpTransport) DeezerPlaylistExporter(org.datatransferproject.transfer.deezer.playlists.DeezerPlaylistExporter) Monitor(org.datatransferproject.api.launcher.Monitor) TransferServiceConfig(org.datatransferproject.types.transfer.serviceconfig.TransferServiceConfig) DeezerPlaylistImporter(org.datatransferproject.transfer.deezer.playlists.DeezerPlaylistImporter)

Aggregations

Monitor (org.datatransferproject.api.launcher.Monitor)32 IOException (java.io.IOException)10 AppCredentials (org.datatransferproject.types.transfer.auth.AppCredentials)10 Before (org.junit.Before)10 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)8 HttpTransport (com.google.api.client.http.HttpTransport)7 ImmutableMap (com.google.common.collect.ImmutableMap)7 Importer (org.datatransferproject.spi.transfer.provider.Importer)7 TemporaryPerJobDataStore (org.datatransferproject.spi.cloud.storage.TemporaryPerJobDataStore)6 JsonFactory (com.google.api.client.json.JsonFactory)5 JobStore (org.datatransferproject.spi.cloud.storage.JobStore)5 Exporter (org.datatransferproject.spi.transfer.provider.Exporter)5 TokensAndUrlAuthData (org.datatransferproject.types.transfer.auth.TokensAndUrlAuthData)5 OkHttpClient (okhttp3.OkHttpClient)4 KoofrClientFactory (org.datatransferproject.transfer.koofr.common.KoofrClientFactory)4 JacksonFactory (com.google.api.client.json.jackson2.JacksonFactory)3 MockWebServer (okhttp3.mockwebserver.MockWebServer)3 GoogleCredentialFactory (org.datatransferproject.datatransfer.google.common.GoogleCredentialFactory)3 KoofrClient (org.datatransferproject.transfer.koofr.common.KoofrClient)3 Optional (java.util.Optional)2