use of com.google.api.services.blogger.Blogger in project data-transfer-project by google.
the class GoogleBloggerImporter method importItem.
@Override
public ImportResult importItem(UUID jobId, IdempotentImportExecutor idempotentExecutor, TokensAndUrlAuthData authData, SocialActivityContainerResource data) throws Exception {
Blogger blogger = getOrCreateBloggerService(authData);
BlogList blogList = blogger.blogs().listByUser("self").execute();
// NB: we are just publishing everything to the first blog, which is a bit of a hack,
// but there is no API to create a new blog.
String blogId = blogList.getItems().get(0).getId();
for (SocialActivityModel activity : data.getActivities()) {
if (activity.getType() == SocialActivityType.NOTE || activity.getType() == SocialActivityType.POST) {
try {
insertActivity(idempotentExecutor, data.getActor(), activity, blogId, authData);
} catch (IOException | RuntimeException e) {
throw new IOException("Couldn't import: " + activity, e);
}
}
}
return new ImportResult(ResultType.OK);
}
Aggregations