Language: Java
Client Lib: gdata.java-1.0.11

Problem: When compiling and running CalenderClient.java in the sample
directory you will get Null Pointer Exceptions when calling method
printAclList(CalendarService service). This is caused by the fact that
the ACL List is only available to owners of a specific calendar. If
your calendar list contains other calendars (read only such as US
Holiday list) the sample application will NPE out.

Solution: Simply check if you are the owner of the Calendar. This is
the modified method:

  /**
   * Prints the access control lists for each of the user's calendars.
   *
   * @param service An authenticated CalendarService object.
   * @throws ServiceException If the service is unable to handle the
request.
   * @throws IOException If the URL is malformed.
   */
  private static void printAclList(CalendarService service) throws
      ServiceException, IOException {
    CalendarFeed calendarFeed =
        service.getFeed(new URL(METAFEED_URL), CalendarFeed.class);

    // After accessing the meta-feed, get the ACL link for each
calendar.
    System.out.println("Access control lists for your calendars:");
    for (CalendarEntry calEntry : calendarFeed.getEntries()) {
        // As only the owner gets to see the ACL link we should check
for our AccessLevel
        if
(calEntry.getAccessLevel().getValue().equalsIgnoreCase("owner")) {
              System.out.println("\tCalendar \"" +
calEntry.getTitle().getPlainText() +
                  "\":");
              Link link =
calEntry.getLink(AclNamespace.LINK_REL_ACCESS_CONTROL_LIST,
                  Link.Type.ATOM);

              // For each calendar, retrieve its ACL feed.
              AclFeed aclFeed = service.getFeed(new URL(link.getHref()),
AclFeed.class);
              for (AclEntry aclEntry : aclFeed.getEntries()) {
                System.out.println("\t\tScope: Type=" +
aclEntry.getScope().getType() +
                    " (" + aclEntry.getScope().getValue() + ")");
                System.out.println("\t\tRole: " +
aclEntry.getRole().getValue());
              }
        }
    }
  }


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Calendar Data API" group.
To post to this group, send email to 
[email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/google-calendar-help-dataapi?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to