Exemplo n.º 1
0
  @RequestMapping("list")
  public @ResponseBody List<String> list() throws IOException {
    List<String> ret = Lists.newArrayList();

    String pageToken = null;
    do {
      com.google.api.services.calendar.model.CalendarList calendarList =
          googleCalendarService.calendarList().list().setPageToken(pageToken).execute();
      List<CalendarListEntry> items = calendarList.getItems();

      for (CalendarListEntry calendarListEntry : items) {
        ret.add(calendarListEntry.getSummary());
      }
      pageToken = calendarList.getNextPageToken();
    } while (pageToken != null);
    return ret;
  }
Exemplo n.º 2
0
  private String findAchievoCalendarId() throws IOException {
    String pageToken = null;
    do {
      com.google.api.services.calendar.model.CalendarList calendarList =
          googleCalendarService.calendarList().list().setPageToken(pageToken).execute();
      List<CalendarListEntry> items = calendarList.getItems();

      for (CalendarListEntry calendarListEntry : items) {

        if (CalendarConstants.CALENDAR_ID_ACHIEVO.equals(calendarListEntry.getSummary())) {
          return calendarListEntry.getId();
        }
      }
      pageToken = calendarList.getNextPageToken();
    } while (pageToken != null);
    return null;
  }
Exemplo n.º 3
0
  public Calendar getCalendars(String name) throws IOException {
    View.header("Show Calendars");
    CalendarList feed = client.calendarList().list().execute();

    Calendar calendar = null;

    for (CalendarListEntry entry : feed.getItems()) {
      System.out.println();
      System.out.println("-----------------------------------------------");
      if (entry.getSummary().matches(name)) {

        calendar = client.calendars().get(entry.getId()).execute();
        return calendar;
      }
    }
    return null;
  }
 @Override
 protected void doInBackground() throws IOException {
   CalendarList calList =
       GoogleCalendar.getInstance()
           .client
           .calendarList()
           .list()
           .setFields("items(id,summary)")
           .execute();
   List<CalendarListEntry> list = calList.getItems();
   // ArrayList<String> names = new ArrayList<String>();
   for (CalendarListEntry entry : list) {
     // names.add(entry.getSummary());
     activity.calIdSummary.put(entry.getSummary(), entry.getId());
   }
   activity.selectACalendar();
 }
  private void loadHistory(UpdateInfo updateInfo, boolean incremental) throws Exception {
    Calendar calendar = getCalendar(updateInfo.apiKey);
    String pageToken = null;
    long apiKeyId = updateInfo.apiKey.getId();
    settingsService.getConnectorSettings(updateInfo.apiKey.getId());
    List<String> existingCalendarIds = getExistingCalendarIds(apiKeyId);
    List<CalendarListEntry> remoteCalendars = new ArrayList<CalendarListEntry>();
    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);

    for (CalendarListEntry remoteCalendar : remoteCalendars)
      loadCalendarHistory(calendar, remoteCalendar, updateInfo, incremental);
    deleteCalendars(apiKeyId, existingCalendarIds);
  }