use of com.google.api.services.calendar.model.CalendarList in project data-transfer-project by google.
the class GoogleCalendarExporter method exportCalendars.
private ExportResult<CalendarContainerResource> exportCalendars(TokensAndUrlAuthData authData, Optional<PaginationData> pageData) {
Calendar.CalendarList.List listRequest;
CalendarList listResult;
// Get calendar information
try {
listRequest = getOrCreateCalendarInterface(authData).calendarList().list();
if (pageData.isPresent()) {
StringPaginationToken paginationToken = (StringPaginationToken) pageData.get();
Preconditions.checkState(paginationToken.getToken().startsWith(CALENDAR_TOKEN_PREFIX), "Token is not applicable");
listRequest.setPageToken(((StringPaginationToken) pageData.get()).getToken().substring(CALENDAR_TOKEN_PREFIX.length()));
}
listResult = listRequest.execute();
} catch (IOException e) {
return new ExportResult<>(e);
}
// Set up continuation data
PaginationData nextPageData = null;
if (listResult.getNextPageToken() != null) {
nextPageData = new StringPaginationToken(CALENDAR_TOKEN_PREFIX + listResult.getNextPageToken());
}
ContinuationData continuationData = new ContinuationData(nextPageData);
// Process calendar list
List<CalendarModel> calendarModels = new ArrayList<>(listResult.getItems().size());
for (CalendarListEntry calendarData : listResult.getItems()) {
CalendarModel model = convertToCalendarModel(calendarData);
continuationData.addContainerResource(new IdOnlyContainerResource(calendarData.getId()));
calendarModels.add(model);
}
CalendarContainerResource calendarContainerResource = new CalendarContainerResource(calendarModels, null);
// Get result type
ExportResult.ResultType resultType = ResultType.CONTINUE;
if (calendarModels.isEmpty()) {
resultType = ResultType.END;
}
return new ExportResult<>(resultType, calendarContainerResource, continuationData);
}
use of com.google.api.services.calendar.model.CalendarList in project borg_calendar by mikeberger.
the class GCal method setIds.
private void setIds() throws Exception {
String calname = Prefs.getPref(PrefName.GCAL_CAL_ID);
String taskname = Prefs.getPref(PrefName.GCAL_TASKLIST_ID);
if (calendarId == null) {
CalendarList cals = service.calendarList().list().execute();
for (CalendarListEntry c : cals.getItems()) {
log.fine("Cal Entry: " + c.getSummary() + " : " + c.getId());
if (calname.equals(c.getSummary())) {
calendarId = c.getId();
break;
}
}
}
if (taskList == null) {
TaskLists result = tservice.tasklists().list().execute();
List<TaskList> taskLists = result.getItems();
if (taskLists != null) {
for (TaskList tasklist : taskLists) {
log.fine("TaskList Entry: " + tasklist.getTitle() + " : " + tasklist.getId());
if (taskname.equals(tasklist.getTitle())) {
taskList = tasklist.getId();
break;
}
}
}
}
if (calendarId == null)
throw new Exception("Could not determine calender id matching: " + calname);
if (taskList == null)
throw new Exception("Could not determine task list id matching: " + taskname);
}
use of com.google.api.services.calendar.model.CalendarList in project jbpm-work-items by kiegroup.
the class GetEventsWorkitemHandler method getCalendarIdBySummary.
public String getCalendarIdBySummary(com.google.api.services.calendar.Calendar client, String summary) {
String resultId = null;
try {
CalendarList calendarList = getAllCalendars(client);
List<CalendarListEntry> entryList = calendarList.getItems();
for (CalendarListEntry entry : entryList) {
if (entry.getSummary().equalsIgnoreCase(summary)) {
resultId = entry.getId();
}
}
} catch (Exception e) {
logger.error(MessageFormat.format("Error retrieveing calendars: {0}", e.getMessage()));
}
return resultId;
}
use of com.google.api.services.calendar.model.CalendarList in project syndesis-qe by syndesisio.
the class GoogleCalendarUtils method getCalendarByName.
/**
* Get calendar by its name (aka summary). The first calendar with matching name is being returned.
*
* @param ga Google Account specification
* @param calendarName name of the calendar
* @return Calendar instance with matching name (aka summary)
* @throws IOException when something goes wrong
*/
public Calendar getCalendarByName(String ga, String calendarName) throws IOException {
// Iterate through entries in calendar list
String pageToken = null;
do {
CalendarList calendarList = getClient(ga).calendarList().list().setPageToken(pageToken).execute();
List<CalendarListEntry> items = calendarList.getItems();
for (CalendarListEntry calendarListEntry : items) {
if (calendarListEntry.getSummary().equals(calendarName)) {
return getCalendar(ga, calendarListEntry.getId());
}
}
pageToken = calendarList.getNextPageToken();
} while (pageToken != null);
return null;
}
use of com.google.api.services.calendar.model.CalendarList in project camel by apache.
the class CalendarCalendarListIntegrationTest method isCalendarInList.
protected boolean isCalendarInList(Calendar calendar) {
CalendarList calendarList = requestBody("direct://LIST", null);
java.util.List<CalendarListEntry> items = calendarList.getItems();
boolean found = false;
for (CalendarListEntry calendarListEntry : items) {
if (calendar.getSummary().equals(calendarListEntry.getSummary())) {
found = true;
}
}
return found;
}
Aggregations