@Override public void delete(String eventId, CalendarSettings calendarSettings) { googleCalendarClient = getOrCreateGoogleCalendarClient(); if (googleCalendarClient != null) { String calendarId = settingsService.getSettings().getCalendarSettings().getGoogleCalendarSettings().getCalendarId(); try { googleCalendarClient.events().delete(calendarId, eventId).execute(); LOG.info(String.format("Event %s has been deleted in calendar '%s'.", eventId, calendarId)); } catch (IOException ex) { LOG.warn(String.format("Could not delete event %s in calendar '%s'", eventId, calendarId), ex); mailService.sendCalendarDeleteErrorNotification(calendarId, eventId, ex.getMessage()); } } }
@Override public void deleteAppointment(final AppointmentDto appointment) throws IOException { final GoogleAppointmentDto googleAppointmentDto = (GoogleAppointmentDto) appointment; client.events().delete(calendarId, googleAppointmentDto.getGoogleId()).execute(); LOG.info("Deleted Google appointment " + appointment.getSummary()); }
/** * Deletes an event from the calendar. * * @param settings Guild settings * @param eventId The ID of the event to delete. * @return <code>true</code> if successfully deleted, otherwise <code>false</code>. */ public static Boolean deleteEvent(GuildSettings settings, String eventId) { //TODO: Support multiple calendars... String calendarId = DatabaseManager.getManager().getMainCalendar(settings.getGuildID()).getCalendarAddress(); try { Calendar service = CalendarAuth.getCalendarService(settings); try { service.events().delete(calendarId, eventId).execute(); } catch (Exception e) { //Failed to delete event... return false; } DatabaseManager.getManager().deleteAnnouncementsForEvent(settings.getGuildID(), eventId); DatabaseManager.getManager().deleteEventData(eventId); return true; } catch (Exception e) { System.out.println("Something weird happened when deleting an event!"); Logger.getLogger().exception(null, "Failed to delete event.", e, EventUtils.class); e.printStackTrace(); } return false; }