use of org.datatransferproject.types.transfer.auth.AppCredentials in project data-transfer-project by google.
the class MicrosoftTransferExtension method initialize.
@Override
public void initialize(ExtensionContext context) {
// times.
if (initialized)
return;
TemporaryPerJobDataStore jobStore = context.getService(TemporaryPerJobDataStore.class);
HttpTransport httpTransport = context.getService(HttpTransport.class);
JsonFactory jsonFactory = context.getService(JsonFactory.class);
TransformerService transformerService = new TransformerServiceImpl();
OkHttpClient client = new OkHttpClient.Builder().build();
ObjectMapper mapper = new ObjectMapper();
AppCredentials appCredentials;
try {
appCredentials = context.getService(AppCredentialStore.class).getAppCredentials("MICROSOFT_KEY", "MICROSOFT_SECRET");
} catch (IOException e) {
Monitor monitor = context.getMonitor();
monitor.info(() -> "Unable to retrieve Microsoft AppCredentials. Did you set MICROSOFT_KEY and MICROSOFT_SECRET?");
return;
}
// Create the MicrosoftCredentialFactory with the given {@link AppCredentials}.
MicrosoftCredentialFactory credentialFactory = new MicrosoftCredentialFactory(httpTransport, jsonFactory, appCredentials);
Monitor monitor = context.getMonitor();
ImmutableMap.Builder<String, Importer> importBuilder = ImmutableMap.builder();
importBuilder.put(CONTACTS, new MicrosoftContactsImporter(BASE_GRAPH_URL, client, mapper, transformerService));
importBuilder.put(CALENDAR, new MicrosoftCalendarImporter(BASE_GRAPH_URL, client, mapper, transformerService));
importBuilder.put(PHOTOS, new MicrosoftPhotosImporter(BASE_GRAPH_URL, client, mapper, jobStore, monitor, credentialFactory));
importerMap = importBuilder.build();
ImmutableMap.Builder<String, Exporter> exporterBuilder = ImmutableMap.builder();
exporterBuilder.put(CONTACTS, new MicrosoftContactsExporter(BASE_GRAPH_URL, client, mapper, transformerService));
exporterBuilder.put(CALENDAR, new MicrosoftCalendarExporter(BASE_GRAPH_URL, client, mapper, transformerService));
exporterBuilder.put(PHOTOS, new MicrosoftPhotosExporter(credentialFactory, jsonFactory, monitor));
exporterBuilder.put(OFFLINE_DATA, new MicrosoftOfflineDataExporter(BASE_GRAPH_URL, client, mapper));
exporterMap = exporterBuilder.build();
initialized = true;
}
use of org.datatransferproject.types.transfer.auth.AppCredentials in project data-transfer-project by google.
the class KoofrTransferExtension method initialize.
@Override
public void initialize(ExtensionContext context) {
// rather than throwing if called multiple times.
if (initialized)
return;
JobStore jobStore = context.getService(JobStore.class);
HttpTransport httpTransport = context.getService(HttpTransport.class);
JsonFactory jsonFactory = context.getService(JsonFactory.class);
OkHttpClient client = new OkHttpClient.Builder().build();
ObjectMapper mapper = new ObjectMapper();
AppCredentials appCredentials;
try {
appCredentials = context.getService(AppCredentialStore.class).getAppCredentials("KOOFR_KEY", "KOOFR_SECRET");
} catch (IOException e) {
Monitor monitor = context.getMonitor();
monitor.info(() -> "Unable to retrieve Koofr AppCredentials. Did you set KOOFR_KEY and KOOFR_SECRET?");
return;
}
// Create the KoofrCredentialFactory with the given {@link AppCredentials}.
KoofrCredentialFactory credentialFactory = new KoofrCredentialFactory(httpTransport, jsonFactory, appCredentials);
Monitor monitor = context.getMonitor();
int fileUploadReadTimeout = context.getSetting("koofrFileUploadReadTimeout", 60000);
int fileUploadWriteTimeout = context.getSetting("koofrFileUploadWriteTimeout", 60000);
monitor.info(() -> format("Configuring Koofr HTTP file upload client with read timeout %d ms and write timeout %d ms", fileUploadReadTimeout, fileUploadWriteTimeout));
OkHttpClient fileUploadClient = client.newBuilder().readTimeout(fileUploadReadTimeout, TimeUnit.MILLISECONDS).writeTimeout(fileUploadReadTimeout, TimeUnit.MILLISECONDS).build();
KoofrClientFactory koofrClientFactory = new KoofrClientFactory(BASE_API_URL, client, fileUploadClient, mapper, monitor, credentialFactory);
ImmutableMap.Builder<String, Importer> importBuilder = ImmutableMap.builder();
importBuilder.put(PHOTOS, new KoofrPhotosImporter(koofrClientFactory, monitor, jobStore));
importBuilder.put(VIDEOS, new KoofrVideosImporter(koofrClientFactory, monitor));
importerMap = importBuilder.build();
ImmutableMap.Builder<String, Exporter> exportBuilder = ImmutableMap.builder();
exportBuilder.put(PHOTOS, new KoofrPhotosExporter(koofrClientFactory, monitor));
exportBuilder.put(VIDEOS, new KoofrVideosExporter(koofrClientFactory, monitor));
exporterMap = exportBuilder.build();
initialized = true;
}
use of org.datatransferproject.types.transfer.auth.AppCredentials in project data-transfer-project by google.
the class RememberTheMilkAuthServiceExtension method initialize.
@Override
public void initialize(ExtensionContext context) {
if (initialized)
return;
AppCredentials appCredentials;
try {
appCredentials = context.getService(AppCredentialStore.class).getAppCredentials(RTM_KEY, RTM_SECRET);
} catch (IOException e) {
Monitor monitor = context.getMonitor();
monitor.info(() -> format("Unable to retrieve RememberTheMilk AppCredentials. Did you set %s and %s?", RTM_KEY, RTM_SECRET), e);
return;
}
Monitor monitor = context.getMonitor();
importAuthDataGenerator = new RememberTheMilkAuthDataGenerator(appCredentials, AuthMode.IMPORT, monitor);
exportAuthDataGenerator = new RememberTheMilkAuthDataGenerator(appCredentials, AuthMode.EXPORT, monitor);
initialized = true;
}
use of org.datatransferproject.types.transfer.auth.AppCredentials in project data-transfer-project by google.
the class RememberTheMilkTransferExtension method initialize.
@Override
public void initialize(ExtensionContext context) {
if (initialized)
return;
AppCredentials credentials;
try {
credentials = context.getService(AppCredentialStore.class).getAppCredentials(RTM_KEY, RTM_SECRET);
} catch (IOException e) {
Monitor monitor = context.getMonitor();
monitor.info(() -> format("Unable to retrieve RememberTheMilk AppCredentials. Did you set %s and %s?", RTM_KEY, RTM_SECRET), e);
return;
}
Monitor monitor = context.getMonitor();
exporter = new RememberTheMilkTasksExporter(credentials);
importer = new RememberTheMilkTasksImporter(credentials, monitor);
initialized = true;
}
use of org.datatransferproject.types.transfer.auth.AppCredentials in project data-transfer-project by google.
the class SpotifyTransferExtension method initialize.
@Override
public void initialize(ExtensionContext context) {
if (initialized) {
Monitor monitor = context.getMonitor();
monitor.severe(() -> "SpotifyTransferExtension already initialized");
return;
}
AppCredentials appCredentials;
try {
appCredentials = context.getService(AppCredentialStore.class).getAppCredentials("SPOTIFY_KEY", "SPOTIFY_SECRET");
} catch (IOException e) {
Monitor monitor = context.getMonitor();
monitor.info(() -> "Unable to retrieve Spotify AppCredentials. " + "Did you set SPOTIFY_KEY and SPOTIFY_SECRET?");
return;
}
Monitor monitor = context.getMonitor();
SpotifyApi spotifyApi = new SpotifyApi.Builder().setClientId(appCredentials.getKey()).setClientSecret(appCredentials.getSecret()).build();
exporter = new SpotifyPlaylistExporter(monitor, spotifyApi);
importer = new SpotifyPlaylistImporter(monitor, spotifyApi);
initialized = true;
}
Aggregations