Package com.google.api.client.googleapis.batch

Examples of com.google.api.client.googleapis.batch.BatchRequest


      View.display(feed);
    }

    private static void addCalendarsUsingBatch() throws IOException {
      View.header("Add Calendars using Batch");
      BatchRequest batch = client.batch();

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

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

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

      // Create 2 Calendar Entries to insert.
      Calendar entry1 = new Calendar().setSummary("Calendar for Testing 1");
      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();
    }
View Full Code Here


      View.display(feed);
    }

    private static 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>() {

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

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

      batch.execute();
    }
View Full Code Here

   *        request or {@code null} for none
   * @return newly created Batch request
   */
  @SuppressWarnings("deprecation")
  public BatchRequest batch(HttpRequestInitializer httpRequestInitializer) {
    BatchRequest batch =
        new BatchRequest(getRequestFactory().getTransport(), httpRequestInitializer);
    GenericUrl baseUrl;
    if (isBaseUrlUsed()) {
      baseUrl = new GenericUrl(getBaseUrl());
      baseUrl.setPathParts(Arrays.asList("", "batch"));
    } else {
      baseUrl = new GenericUrl(getRootUrl() + "batch");
    }
    batch.setBatchUrl(baseUrl);
    return batch;
  }
View Full Code Here

TOP

Related Classes of com.google.api.client.googleapis.batch.BatchRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.