Package com.google.gdata.client.calendar

Examples of com.google.gdata.client.calendar.CalendarService


   * interactions with the Calendar data API's event feed.
   *
   * @param args Must be length 2 and contain a valid username/password
   */
  public static void main(String[] args) {
    CalendarService myService = new CalendarService("exampleCo-exampleApp-1");

    // Set username and password from command-line arguments.
    if (args.length != 2) {
      usage();
      return;
    }

    String userName = args[0];
    String userPassword = args[1];

    // Create the necessary URL objects.
    try {
      metafeedUrl = new URL(METAFEED_URL_BASE + userName);
      eventFeedUrl = new URL(METAFEED_URL_BASE + userName
          + EVENT_FEED_URL_SUFFIX);
    } catch (MalformedURLException e) {
      // Bad URL
      System.err.println("Uh oh - you've got an invalid URL.");
      e.printStackTrace();
      return;
    }

    try {
      myService.setUserCredentials(userName, userPassword);

      // Demonstrate retrieving a list of the user's calendars.
      printUserCalendars(myService);

      // Demonstrate various feed queries.
View Full Code Here


        e.printStackTrace();
        return;
    }

    // Create CalendarService and authenticate using ClientLogin
    CalendarService service = new CalendarService("demo-CalendarFeedDemo-1");

    try {
      service.setUserCredentials(userName, userPassword);
    } catch (AuthenticationException e) {
      // Invalid credentials
      e.printStackTrace();
    }
View Full Code Here

     * @param accessToken OAuth access token.
     * @param accessTokenSecret OAuth access token secret.
     * @return list of names of a user's public and private calendars.
     */
    public List<String> getCalendarNames(String accessToken, String accessTokenSecret) throws Exception {
        CalendarService calendarService = new CalendarService("apache-camel-2.3");
        OAuthParameters params = getOAuthParams(accessToken, accessTokenSecret);
        calendarService.setOAuthCredentials(params, new OAuthHmacSha1Signer());
        URL feedUrl = new URL("http://www.google.com/calendar/feeds/default/");
        CalendarFeed resultFeed = calendarService.getFeed(feedUrl, CalendarFeed.class);

        ArrayList<String> result = new ArrayList<String>();
        for (int i = 0; i < resultFeed.getEntries().size(); i++) {
            CalendarEntry entry = resultFeed.getEntries().get(i);
            result.add(entry.getTitle().getPlainText());
View Full Code Here

     * @param accessToken OAuth access token.
     * @param accessTokenSecret OAuth access token secret.
     * @return list of names of a user's public and private calendars.
     */
    public List<String> getCalendarNames(String accessToken, String accessTokenSecret) throws Exception {
        CalendarService calendarService = new CalendarService("apache-camel-2.3");
        OAuthParameters params = getOAuthParams(accessToken, accessTokenSecret);
        calendarService.setOAuthCredentials(params, new OAuthHmacSha1Signer());
        URL feedUrl = new URL("http://www.google.com/calendar/feeds/default/");
        CalendarFeed resultFeed = calendarService.getFeed(feedUrl, CalendarFeed.class);

        List<String> result = new ArrayList<String>();
        for (int i = 0; i < resultFeed.getEntries().size(); i++) {
            CalendarEntry entry = resultFeed.getEntries().get(i);
            result.add(entry.getTitle().getPlainText());
View Full Code Here

            String password = googleSettingsForProject.get(
                "password").toString();
            String calendarId = googleSettingsForProject.get(
                "calendarId").toString();

            CalendarService service = new CalendarService(
                "Dashboard");
            service.setUserCredentials(username, password);

            CalendarQuery calendarQuery = new CalendarQuery(
                new URL(
                    "https://www.google.com/calendar/feeds/default/owncalendars/full"));
            CalendarFeed calendarFeed = service.query(
                calendarQuery, CalendarFeed.class);
            for (CalendarEntry curCalendar : calendarFeed
                .getEntries()) {
              if (curCalendar.getId().endsWith(
                  calendarId.replaceAll("@", "%40"))
View Full Code Here

        String password = googleSettingsForProject.get("password")
            .toString();
        String calendarId = googleSettingsForProject.get("calendarId")
            .toString();

        CalendarService service = new CalendarService("Dashboard");
        service.setUserCredentials(username, password);

        URL feedUrl = new URL("http://www.google.com/calendar/feeds/"
            + calendarId + "/private/full");

        try {
          CalendarQuery myQuery = new CalendarQuery(feedUrl);
          Calendar cal = Calendar.getInstance();
          myQuery.setMinimumStartTime(dateToGDateTime(cal.getTime()));
          cal.add(Calendar.MONTH, 3);
          myQuery.setMaximumStartTime(dateToGDateTime(cal.getTime()));
          cal.add(Calendar.MONTH, -2);
          myQuery.setMaxResults(100);
          myQuery.setIntegerCustomParameter("max-results", 100);

          // Send the request and receive the response:
          CalendarEventFeed resultFeed = service.query(myQuery,
              CalendarEventFeed.class);

          for (CalendarEventEntry eventEntry : resultFeed
              .getEntries()) {
            for (When curTime : eventEntry.getTimes()) {
View Full Code Here

     * @return the newly created entry
     * @throws ServiceException
     * @throws IOException
     */
    private CalendarEventEntry createCalendarEvent(String username, String password, String url, CalendarEventEntry event) throws IOException, ServiceException {
      CalendarService myService = new CalendarService("openHAB");
        myService.setUserCredentials(username, password);
      URL feedUrl = new URL(url);
       
      return myService.insert(feedUrl, event);
   
View Full Code Here

       
   
    try {
      URL feedUrl = new URL(url);
     
      CalendarService myService = new CalendarService("openHAB");
            if (!StringUtils.isBlank(username) && !StringUtils.isBlank(password)) {
        myService.setUserCredentials(username, password);
            }
               
      CalendarQuery myQuery = new CalendarQuery(feedUrl);
      DateTime start = DateTime.now();
      DateTime end   = new DateTime(DateTime.now().getValue() + (2 * refreshInterval));
     
      myQuery.setMinimumStartTime(start);
      myQuery.setMaximumStartTime(end);
     
      // add the fulltext filter if it has been configured
      if (StringUtils.isNotBlank(filter)) {
        myQuery.setFullTextQuery(filter);
      }
 
      logger.debug("Downloading calendar feed for time interval: {} to  {} ", start, end);
      CalendarEventFeed feed = myService.getFeed(myQuery, CalendarEventFeed.class);
      if (feed != null) {
        checkIfFullCalendarFeed(feed.getEntries());
      }
     
      return feed;
View Full Code Here

TOP

Related Classes of com.google.gdata.client.calendar.CalendarService

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.