List<CalendarConfig> configs = new ArrayList<CalendarConfig>();
do {
final long then = System.currentTimeMillis();
final Calendar.CalendarList.List list = calendar.calendarList().list().setPageToken(pageToken);
final String query = list.getUriTemplate();
CalendarList calendarList = null;
try {
calendarList = list.execute();
countSuccessfulApiCall(updateInfo.apiKey, updateInfo.objectTypes, then, query);
} catch (IOException e) {
countFailedApiCall(updateInfo.apiKey, updateInfo.objectTypes, then, query, ExceptionUtils.getStackTrace(e),
list.getLastStatusCode(), list.getLastStatusMessage());
}
if (calendarList==null) throw new Exception("Could not get calendar list, apiKeyId=" + updateInfo.apiKey.getId());
List<CalendarListEntry> items = calendarList.getItems();
for (CalendarListEntry item : items) {
existingCalendarIds.remove(item.getId());
remoteCalendars.add(item);
configs.add(entry2Config(item));
}
pageToken = calendarList.getNextPageToken();
} while (pageToken != null);
initChannelMapping(updateInfo.apiKey, configs);
updateInfo.setContext(REMOTE_CALLENDARS_KEY, remoteCalendars);