Search in sources :

Example 6 with Exporter

use of org.datatransferproject.spi.transfer.provider.Exporter 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)

Aggregations

Exporter (org.datatransferproject.spi.transfer.provider.Exporter)6 ImmutableMap (com.google.common.collect.ImmutableMap)5 IOException (java.io.IOException)5 Monitor (org.datatransferproject.api.launcher.Monitor)5 Importer (org.datatransferproject.spi.transfer.provider.Importer)5 AppCredentials (org.datatransferproject.types.transfer.auth.AppCredentials)5 HttpTransport (com.google.api.client.http.HttpTransport)4 JsonFactory (com.google.api.client.json.JsonFactory)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 OkHttpClient (okhttp3.OkHttpClient)2 GoogleCredentialFactory (org.datatransferproject.datatransfer.google.common.GoogleCredentialFactory)2 JobStore (org.datatransferproject.spi.cloud.storage.JobStore)2 AuthTestDriver (org.datatransferproject.auth.microsoft.harness.AuthTestDriver)1 GoogleBloggerImporter (org.datatransferproject.datatransfer.google.blogger.GoogleBloggerImporter)1 GoogleCalendarExporter (org.datatransferproject.datatransfer.google.calendar.GoogleCalendarExporter)1 GoogleCalendarImporter (org.datatransferproject.datatransfer.google.calendar.GoogleCalendarImporter)1 GoogleContactsExporter (org.datatransferproject.datatransfer.google.contacts.GoogleContactsExporter)1 GoogleContactsImporter (org.datatransferproject.datatransfer.google.contacts.GoogleContactsImporter)1 DriveExporter (org.datatransferproject.datatransfer.google.drive.DriveExporter)1 DriveImporter (org.datatransferproject.datatransfer.google.drive.DriveImporter)1