Ejemplo n.º 1
1
  public Calendar addCalendarsUsingBatch(String nameCalendar) throws IOException {
    View.header("Add Calendars using Batch");
    BatchRequest batch = client.batch();

    // Create the callback.
    JsonBatchCallback<Calendar> callback =
        new JsonBatchCallback<Calendar>() {

          public void onSuccess(Calendar calendar, GoogleHeaders responseHeaders) {
            View.display(calendar);
            addedCalendarsUsingBatch.add(calendar);
          }

          @Override
          public void onFailure(GoogleJsonError e, GoogleHeaders responseHeaders) {
            System.out.println("Error Message: " + e.getMessage());
          }
        };

    // Create 2 Calendar Entries to insert.
    Calendar entry1 = new Calendar().setSummary(nameCalendar);
    client.calendars().insert(entry1).queue(batch, callback);

    //    Calendar entry2 = new Calendar().setSummary("Calendar for Testing 2");
    //    client.calendars().insert(entry2).queue(batch, callback);

    batch.execute();
    return entry1;
  }
Ejemplo n.º 2
1
 public Calendar updateCalendar(Calendar calendar) throws IOException {
   View.header("Update Calendar");
   Calendar entry = new Calendar();
   entry.setSummary("Updated Calendar for Testing");
   Calendar result = client.calendars().patch(calendar.getId(), entry).execute();
   View.display(result);
   return result;
 }
Ejemplo n.º 3
1
 public Calendar addCalendar() throws IOException {
   View.header("Add Calendar");
   Calendar entry = new Calendar();
   entry.setSummary("My agenda");
   Calendar result = client.calendars().insert(entry).execute();
   View.display(result);
   return result;
 }
Ejemplo n.º 4
1
  public void deleteCalendarsUsingBatch() throws IOException {
    View.header("Delete Calendars Using Batch");
    BatchRequest batch = client.batch();
    for (Calendar calendar : addedCalendarsUsingBatch) {
      client
          .calendars()
          .delete(calendar.getId())
          .queue(
              batch,
              new JsonBatchCallback<Void>() {

                public void onSuccess(Void content, GoogleHeaders responseHeaders) {
                  System.out.println("Delete is successful!");
                }

                @Override
                public void onFailure(GoogleJsonError e, GoogleHeaders responseHeaders) {
                  System.out.println("Error Message: " + e.getMessage());
                }
              });
    }

    batch.execute();
  }
Ejemplo n.º 5
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;
  }
Ejemplo n.º 6
0
 public void deleteCalendar(Calendar calendar) throws IOException {
   View.header("Delete Calendar");
   client.calendars().delete(calendar.getId()).execute();
 }