Search in sources :

Example 6 with Monitor

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

the class DataTypesActionTest method testHandle.

@Test
public void testHandle() {
    AuthServiceProviderRegistry registry = mock(AuthServiceProviderRegistry.class);
    Set<String> dataTypes = new HashSet<>(Arrays.asList("CONTACTS", "PHOTOS"));
    when(registry.getTransferDataTypes()).thenReturn(dataTypes);
    DataTypesAction dataTypesAction = new DataTypesAction(registry, new Monitor() {
    });
    GetDataTypes request = mock(GetDataTypes.class);
    DataTypes actual = dataTypesAction.handle(request);
    Assert.assertEquals(actual.getDataTypes(), dataTypes);
}
Also used : Monitor(org.datatransferproject.api.launcher.Monitor) AuthServiceProviderRegistry(org.datatransferproject.spi.api.auth.AuthServiceProviderRegistry) GetDataTypes(org.datatransferproject.types.client.datatype.GetDataTypes) HashSet(java.util.HashSet) DataTypes(org.datatransferproject.types.client.datatype.DataTypes) GetDataTypes(org.datatransferproject.types.client.datatype.GetDataTypes) Test(org.junit.Test)

Example 7 with Monitor

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

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

Example 9 with Monitor

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

the class InstagramTransferExtension method initialize.

@Override
public void initialize(ExtensionContext context) {
    if (initialized) {
        Monitor monitor = context.getMonitor();
        monitor.severe(() -> "InstagramTransferExtension already initialized");
        return;
    }
    ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    HttpTransport httpTransport = context.getService(HttpTransport.class);
    exporter = new InstagramPhotoExporter(mapper, httpTransport);
    initialized = true;
}
Also used : HttpTransport(com.google.api.client.http.HttpTransport) InstagramPhotoExporter(org.datatransferproject.transfer.instagram.photos.InstagramPhotoExporter) Monitor(org.datatransferproject.api.launcher.Monitor) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 10 with Monitor

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

the class FlickrTransferExtension method initialize.

@Override
public void initialize(ExtensionContext context) {
    if (initialized)
        return;
    jobStore = context.getService(TemporaryPerJobDataStore.class);
    Monitor monitor = context.getMonitor();
    try {
        appCredentials = context.getService(AppCredentialStore.class).getAppCredentials(FLICKR_KEY, FLICKR_SECRET);
    } catch (Exception e) {
        monitor.info(() -> format("Unable to retrieve Flickr AppCredentials. Did you set %s and %s?", FLICKR_KEY, FLICKR_SECRET), e);
        initialized = false;
        return;
    }
    TransferServiceConfig serviceConfig = context.getService(TransferServiceConfig.class);
    importer = new FlickrPhotosImporter(appCredentials, jobStore, monitor, serviceConfig);
    exporter = new FlickrPhotosExporter(appCredentials, serviceConfig);
    initialized = true;
}
Also used : FlickrPhotosImporter(org.datatransferproject.datatransfer.flickr.photos.FlickrPhotosImporter) TemporaryPerJobDataStore(org.datatransferproject.spi.cloud.storage.TemporaryPerJobDataStore) Monitor(org.datatransferproject.api.launcher.Monitor) FlickrPhotosExporter(org.datatransferproject.datatransfer.flickr.photos.FlickrPhotosExporter) TransferServiceConfig(org.datatransferproject.types.transfer.serviceconfig.TransferServiceConfig)

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