use of org.datatransferproject.datatransfer.google.blogger.GoogleBloggerImporter in project data-transfer-project by google.
the class BloggerTransferExtension method initialize.
@Override
public void initialize(ExtensionContext context) {
// times.
if (initialized) {
return;
}
Monitor monitor = context.getMonitor();
AppCredentials appCredentials;
try {
appCredentials = context.getService(AppCredentialStore.class).getAppCredentials("GOOGLEBLOGGER_KEY", "GOOGLEBLOGGER_SECRET");
} catch (IOException e) {
monitor.info(() -> "Unable to retrieve Google AppCredentials. " + "Did you set GOOGLEBLOGGER_KEY and GOOGLEBLOGGER_SECRET?");
return;
}
HttpTransport httpTransport = context.getService(HttpTransport.class);
JsonFactory jsonFactory = context.getService(JsonFactory.class);
// Create the GoogleCredentialFactory with the given {@link AppCredentials}.
GoogleCredentialFactory credentialFactory = new GoogleCredentialFactory(httpTransport, jsonFactory, appCredentials, monitor);
ImmutableMap.Builder<String, Importer> importerBuilder = ImmutableMap.builder();
importerBuilder.put("SOCIAL-POSTS", new GoogleBloggerImporter(credentialFactory));
importerMap = importerBuilder.build();
ImmutableMap.Builder<String, Exporter> exporterBuilder = ImmutableMap.builder();
exporterMap = exporterBuilder.build();
initialized = true;
}
Aggregations