public Collection<AppointmentDto> getAllAppointments(final org.joda.time.DateTime startDate,
final org.joda.time.DateTime endDate) throws IOException {
final Collection<AppointmentDto> results = new HashSet<AppointmentDto>();
int page = 1;
LOG.info("Retrieving Google Calendar events page " + page);
Events feed = client.events().list(calendarId).execute();
while (true) {
if (feed.getItems() != null) {
for (final Event event : feed.getItems()) {
final org.joda.time.DateTime eventStartDate = convertToJodaDateTime(event.getStart());
final org.joda.time.DateTime eventEndDate = coalesce(convertToJodaDateTime(event.getEnd()), convertToJodaDateTime(event.getStart()));
if ((eventEndDate.isAfter(startDate) || eventEndDate.isEqual(startDate)) && eventStartDate.isBefore(endDate)) {
results.add(convertToAppointmentDto(event));
}
}
}
final String pageToken = feed.getNextPageToken();
if (pageToken != null && !pageToken.isEmpty()) {
page++;
LOG.info("Retrieving Google Calendar events page " + page);
feed = client.events().list(calendarId).setPageToken(pageToken).execute();
} else {