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);
}
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;
}
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;
}
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;
}
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;
}
Aggregations