use of com.google.api.services.plus.model.Activity in project data-transfer-project by google.
the class GooglePlusExporter method export.
@Override
public ExportResult<SocialActivityContainerResource> export(UUID jobId, TokensAndUrlAuthData authData, Optional<ExportInformation> exportInformation) throws IOException {
Plus plus = getOrCreatePeopleService(authData);
Plus.Activities.List listActivities = plus.activities().list("me", "public");
if (exportInformation.isPresent()) {
StringPaginationToken pageToken = (StringPaginationToken) exportInformation.get().getPaginationData();
listActivities.setPageToken(pageToken.getToken());
}
ActivityFeed activityFeed = listActivities.execute();
List<Activity> activities = activityFeed.getItems();
ContinuationData continuationData = null;
SocialActivityContainerResource results = null;
if (activities != null && !activities.isEmpty()) {
List<SocialActivityModel> activityModels = new ArrayList<>();
Activity.Actor actor = activities.get(0).getActor();
SocialActivityActor parsedActor = new SocialActivityActor(actor.getUrl(), actor.getDisplayName(), actor.getUrl());
if (!Strings.isNullOrEmpty(activityFeed.getNextPageToken())) {
continuationData = new ContinuationData(new StringPaginationToken(activityFeed.getNextPageToken()));
}
for (Activity activity : activities) {
try {
activityModels.add(postToActivityModel(activity));
} catch (RuntimeException e) {
throw new IOException("Problem exporting: " + activity, e);
}
}
results = new SocialActivityContainerResource(jobId.toString(), parsedActor, activityModels);
}
return new ExportResult<>(continuationData == null ? ResultType.END : ResultType.CONTINUE, results, continuationData);
}
Aggregations