context.setParticipantId(new ParticipantId(participantId));
OAuthCredentials cred = new OAuthCredentials(refreshToken, accessToken);
context.setOAuthCredentials(cred);
OAuthRequestHelper helper = new OAuthRequestHelper(clientId, clientSecret, context);
OAuthedFetchService oauthService = new OAuthedFetchService(httpClient, helper);
RobotApi api = new RobotApi(oauthService, WAVE_RPC);
try {
List<String> waves = includeList;
if (waves.isEmpty()) {
waves = getAllWavesList(api);
}
int processedCount = 0;
int errorCount = 0;
for (String waveId : waves) {
try {
if (excludeList.contains(waveId)) {
System.out.println("Skipping wave " + waveId + "...");
continue;
}
for (WaveletId waveletId : api.getWaveView(WaveId.deserialise(waveId))) {
long fromVersion = 0;
for (int fetchNum = 0;; fetchNum++) {
System.out.println("Exporting wavelet " + waveId + ":" + waveletId.serialise()
+ " from version " + fromVersion + " ...");
JSONObject json = api.fetchWaveWithDeltas(WaveId.deserialise(waveId),
waveletId, fromVersion);
JSONArray rawDeltas = json.getJSONObject("data").getJSONArray("rawDeltas");
if (rawDeltas.length() == 0) {
break;
}