Search in sources :

Example 1 with GoogleCalendar

use of fi.otavanopisto.muikku.plugins.googlecalendar.model.GoogleCalendar in project muikku by otavanopisto.

the class GoogleCalendarClient method listPublicCalendars.

public List<fi.otavanopisto.muikku.calendar.Calendar> listPublicCalendars() throws CalendarServiceException {
    try {
        Calendar client = getClient();
        ArrayList<fi.otavanopisto.muikku.calendar.Calendar> result = new ArrayList<>();
        for (CalendarListEntry entry : client.calendarList().list().execute().getItems()) {
            result.add(new GoogleCalendar(entry.getSummary(), entry.getDescription(), entry.getId(), isWritable(entry)));
        }
        return result;
    } catch (IOException | GeneralSecurityException ex) {
        throw new CalendarServiceException(ex);
    }
}
Also used : CalendarServiceException(fi.otavanopisto.muikku.calendar.CalendarServiceException) CalendarListEntry(com.google.api.services.calendar.model.CalendarListEntry) GoogleCalendar(fi.otavanopisto.muikku.plugins.googlecalendar.model.GoogleCalendar) Calendar(com.google.api.services.calendar.Calendar) GoogleCalendar(fi.otavanopisto.muikku.plugins.googlecalendar.model.GoogleCalendar) GeneralSecurityException(java.security.GeneralSecurityException) ArrayList(java.util.ArrayList) IOException(java.io.IOException)

Example 2 with GoogleCalendar

use of fi.otavanopisto.muikku.plugins.googlecalendar.model.GoogleCalendar in project muikku by otavanopisto.

the class GoogleCalendarClient method createCalendar.

public fi.otavanopisto.muikku.calendar.Calendar createCalendar(String summary, String description) throws CalendarServiceException {
    com.google.api.services.calendar.model.Calendar calendar = new com.google.api.services.calendar.model.Calendar();
    calendar.setSummary(summary);
    calendar.setDescription(description);
    try {
        calendar = getClient().calendars().insert(calendar).execute();
    } catch (IOException | GeneralSecurityException ex) {
        throw new CalendarServiceException(ex);
    }
    return new GoogleCalendar(summary, description, calendar.getId(), true);
}
Also used : GoogleCalendar(fi.otavanopisto.muikku.plugins.googlecalendar.model.GoogleCalendar) Calendar(com.google.api.services.calendar.Calendar) GoogleCalendar(fi.otavanopisto.muikku.plugins.googlecalendar.model.GoogleCalendar) GeneralSecurityException(java.security.GeneralSecurityException) IOException(java.io.IOException) CalendarServiceException(fi.otavanopisto.muikku.calendar.CalendarServiceException)

Aggregations

Calendar (com.google.api.services.calendar.Calendar)2 CalendarServiceException (fi.otavanopisto.muikku.calendar.CalendarServiceException)2 GoogleCalendar (fi.otavanopisto.muikku.plugins.googlecalendar.model.GoogleCalendar)2 IOException (java.io.IOException)2 GeneralSecurityException (java.security.GeneralSecurityException)2 CalendarListEntry (com.google.api.services.calendar.model.CalendarListEntry)1 ArrayList (java.util.ArrayList)1