use of fi.otavanopisto.muikku.plugins.calendar.model.UserCalendar in project muikku by otavanopisto.
the class CalendarController method createCalendarEvent.
public CalendarEvent createCalendarEvent(UserCalendar userCalendar, String summary, String description, CalendarEventStatus status, Date start, TimeZone startTimeZone, Date end, TimeZone endTimeZone, List<CalendarEventAttendee> attendees, List<CalendarEventReminder> reminders, String recurrence, boolean allDay, Map<String, String> extendedProperties) throws CalendarServiceException {
CalendarServiceProvider provider = getCalendarServiceProvider(userCalendar.getCalendarProvider());
Calendar calendar = provider.findCalendar(userCalendar.getCalendarId());
if (calendar == null) {
throw new CalendarServiceException("Could not find calendar for user calendar #" + userCalendar.getId());
}
return provider.createEvent(calendar.getId(), summary, description, status, attendees, new DefaultCalendarEventTemporalField(start, startTimeZone), new DefaultCalendarEventTemporalField(end, endTimeZone), reminders, recurrence, allDay);
}
use of fi.otavanopisto.muikku.plugins.calendar.model.UserCalendar in project muikku by otavanopisto.
the class CalendarController method listCalendarEvents.
public List<fi.otavanopisto.muikku.calendar.CalendarEvent> listCalendarEvents(UserCalendar userCalendar, OffsetDateTime timeMin, OffsetDateTime timeMax) throws CalendarServiceException {
CalendarServiceProvider provider = getCalendarServiceProvider(userCalendar.getCalendarProvider());
Calendar calendar = provider.findCalendar(userCalendar.getCalendarId());
if (calendar == null) {
throw new CalendarServiceException("Could not find calendar for user calendar #" + userCalendar.getId());
}
if (timeMin != null || timeMax != null) {
return provider.listEvents(timeMin, timeMax, calendar.getId());
} else {
return provider.listEvents(calendar.getId());
}
}
use of fi.otavanopisto.muikku.plugins.calendar.model.UserCalendar in project muikku by otavanopisto.
the class CalendarController method deleteCalendarEvent.
public void deleteCalendarEvent(UserCalendar userCalendar, String eventId) throws CalendarServiceException {
CalendarServiceProvider provider = getCalendarServiceProvider(userCalendar.getCalendarProvider());
Calendar calendar = provider.findCalendar(userCalendar.getCalendarId());
if (calendar == null) {
throw new CalendarServiceException("Could not find calendar for user calendar #" + userCalendar.getId());
}
provider.deleteEvent(calendar, eventId);
}
use of fi.otavanopisto.muikku.plugins.calendar.model.UserCalendar in project muikku by otavanopisto.
the class CalendarController method deleteCalendar.
public void deleteCalendar(UserCalendar userCalendar) throws CalendarServiceException {
CalendarServiceProvider provider = getCalendarServiceProvider(userCalendar.getCalendarProvider());
Calendar calendar = provider.findCalendar(userCalendar.getCalendarId());
if (calendar == null) {
throw new CalendarServiceException("Could not find calendar for user calendar #" + userCalendar.getId());
}
provider.deleteCalendar(calendar);
}
use of fi.otavanopisto.muikku.plugins.calendar.model.UserCalendar in project muikku by otavanopisto.
the class CalendarRESTService method createEvent.
@POST
@Path("/calendars/{CALID:[0-9]*}/events/")
@RESTPermitUnimplemented
public Response createEvent(@PathParam("CALID") Long calendarId, CalendarEvent event) {
if (!sessionController.isLoggedIn()) {
return Response.status(Response.Status.FORBIDDEN).build();
}
if (event == null) {
return Response.status(Response.Status.BAD_REQUEST).entity("Event payload is missing").build();
}
if (calendarId == null) {
return Response.status(Response.Status.NOT_FOUND).build();
}
if (StringUtils.isBlank(event.getSummary())) {
return Response.status(Response.Status.BAD_REQUEST).entity("Event summarys is required").build();
}
if (event.getStatus() == null) {
return Response.status(Response.Status.BAD_REQUEST).entity("Event status is required").build();
}
UserCalendar userCalendar = calendarController.findUserCalendar(calendarId);
if (userCalendar == null) {
return Response.status(Response.Status.NOT_FOUND).build();
}
if (!userCalendar.getUserId().equals(sessionController.getLoggedUserEntity().getId())) {
return Response.status(Response.Status.FORBIDDEN).build();
}
try {
List<fi.otavanopisto.muikku.calendar.CalendarEventAttendee> attendees = createEventAttendeeListFromRestModel(event.getAttendees());
List<fi.otavanopisto.muikku.calendar.CalendarEventReminder> reminders = createEventReminderListFromRestModel(event.getReminders());
fi.otavanopisto.muikku.calendar.CalendarEvent calendarEvent = calendarController.createCalendarEvent(userCalendar, event.getSummary(), event.getDescription(), event.getStatus(), event.getStart(), event.getStartTimeZone(), event.getEnd(), event.getEndTimeZone(), attendees, reminders, event.getRecurrence(), event.isAllDay(), event.getExtendedProperties());
return Response.ok(createEventRestModel(userCalendar, calendarEvent)).build();
} catch (CalendarServiceException e) {
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build();
}
}
Aggregations