Search in sources :

Example 1 with Monitor

use of org.datatransferproject.api.launcher.Monitor 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 Monitor

use of org.datatransferproject.api.launcher.Monitor 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 Monitor

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

the class JettyRestExtension method initialize.

@Override
public void initialize(ExtensionContext context) {
    Monitor monitor = context.getMonitor();
    JettyMonitor.setDelegate(monitor);
    KeyStore keyStore = context.getService(KeyStore.class);
    boolean useHttps = context.getSetting("useHttps", true);
    transport = new JettyTransport(keyStore, useHttps, monitor);
    binder = new JerseyTransportBinder(transport);
    context.registerService(TransportBinder.class, binder);
}
Also used : JettyTransport(org.datatransferproject.transport.jettyrest.http.JettyTransport) Monitor(org.datatransferproject.api.launcher.Monitor) JettyMonitor(org.datatransferproject.transport.jettyrest.http.JettyMonitor) JerseyTransportBinder(org.datatransferproject.transport.jettyrest.rest.JerseyTransportBinder) KeyStore(java.security.KeyStore)

Example 4 with Monitor

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

the class TwitterTransferExtension method initialize.

@Override
public void initialize(ExtensionContext context) {
    Monitor monitor = context.getMonitor();
    monitor.debug(() -> "Starting Twitter initialization");
    if (initialized) {
        monitor.severe(() -> "TwitterTransferExtension already initialized.");
        return;
    }
    AppCredentials appCredentials;
    try {
        appCredentials = context.getService(AppCredentialStore.class).getAppCredentials(TWITTER_KEY, TWITTER_SECRET);
    } catch (IOException e) {
        monitor.info(() -> format("Unable to retrieve Twitter AppCredentials. Did you set %s and %s?", TWITTER_KEY, TWITTER_SECRET), e);
        return;
    }
    exporter = new TwitterPhotosExporter(appCredentials, monitor);
    importer = new TwitterPhotosImporter(appCredentials, monitor);
    initialized = true;
}
Also used : Monitor(org.datatransferproject.api.launcher.Monitor) AppCredentials(org.datatransferproject.types.transfer.auth.AppCredentials) IOException(java.io.IOException)

Example 5 with Monitor

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

the class ApiMain method main.

/**
 * Starts the api server, currently the reference implementation.
 */
public static void main(String[] args) {
    Monitor monitor = loadMonitor();
    monitor.info(() -> "Starting API Server.");
    Thread.setDefaultUncaughtExceptionHandler((thread, t) -> monitor.severe(() -> "Uncaught exception in thread: " + thread.getName(), t));
    ApiMain apiMain = new ApiMain(monitor);
    apiMain.initializeHttp();
    apiMain.start();
}
Also used : MonitorLoader.loadMonitor(org.datatransferproject.launcher.monitor.MonitorLoader.loadMonitor) Monitor(org.datatransferproject.api.launcher.Monitor)

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