use of org.datatransferproject.spi.cloud.storage.TemporaryPerJobDataStore 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;
}
use of org.datatransferproject.spi.cloud.storage.TemporaryPerJobDataStore 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;
}
use of org.datatransferproject.spi.cloud.storage.TemporaryPerJobDataStore 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.spi.cloud.storage.TemporaryPerJobDataStore in project data-transfer-project by google.
the class GoogleVideosImporterTest method setUp.
@Before
public void setUp() throws Exception {
// Create files so we can accurately check the length of file counting
TemporaryPerJobDataStore dataStore = mock(TemporaryPerJobDataStore.class);
TemporaryFolder folder = new TemporaryFolder();
folder.create();
File file1 = folder.newFile();
Files.write(new byte[32], file1);
File file2 = folder.newFile();
Files.write(new byte[32], file2);
when(dataStore.getTempFileFromInputStream(any(), any(), any())).thenReturn(file1, file2);
streamProvider = mock(ImageStreamProvider.class);
when(streamProvider.getConnection(any())).thenReturn(mock(HttpURLConnection.class));
googleVideosImporter = new GoogleVideosImporter(null, dataStore, mock(Monitor.class), streamProvider);
}
use of org.datatransferproject.spi.cloud.storage.TemporaryPerJobDataStore 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;
}
Aggregations