Search in sources :

Example 1 with CalendarVEventHandler

use of io.lavagna.service.calendarutils.CalendarVEventHandler in project lavagna by digitalfondue.

the class CalendarService method getCalDavCalendar.

public Calendar getCalDavCalendar(String userToken) throws URISyntaxException, ParseException {
    UserWithPermission user;
    try {
        user = findUserFromCalendarToken(userToken);
    } catch (EmptyResultDataAccessException ex) {
        throw new SecurityException("Invalid token");
    }
    if (userRepository.isCalendarFeedDisabled(user)) {
        throw new SecurityException("Calendar feed disabled");
    }
    final Calendar calendar = new Calendar();
    calendar.getProperties().add(new ProdId("-//Lavagna//iCal4j 1.0//EN"));
    calendar.getProperties().add(Version.VERSION_2_0);
    calendar.getProperties().add(CalScale.GREGORIAN);
    calendar.getProperties().add(Method.PUBLISH);
    final List<VEvent> events = new ArrayList<>();
    final String applicationUrl = StringUtils.appendIfMissing(configurationRepository.getValue(Key.BASE_APPLICATION_URL), "/");
    final CalendarEventHandler handler = new CalendarVEventHandler(applicationUrl, cardDataService, userRepository, events);
    // Milestones
    addMilestoneEvents(handler, user);
    // Cards
    addCardEvents(handler, user);
    calendar.getComponents().addAll(events);
    return calendar;
}
Also used : VEvent(net.fortuna.ical4j.model.component.VEvent) StandardCalendarEventHandler(io.lavagna.service.calendarutils.StandardCalendarEventHandler) CalendarEventHandler(io.lavagna.service.calendarutils.CalendarEventHandler) Calendar(net.fortuna.ical4j.model.Calendar) EmptyResultDataAccessException(org.springframework.dao.EmptyResultDataAccessException) ProdId(net.fortuna.ical4j.model.property.ProdId) CalendarVEventHandler(io.lavagna.service.calendarutils.CalendarVEventHandler)

Aggregations

CalendarEventHandler (io.lavagna.service.calendarutils.CalendarEventHandler)1 CalendarVEventHandler (io.lavagna.service.calendarutils.CalendarVEventHandler)1 StandardCalendarEventHandler (io.lavagna.service.calendarutils.StandardCalendarEventHandler)1 Calendar (net.fortuna.ical4j.model.Calendar)1 VEvent (net.fortuna.ical4j.model.component.VEvent)1 ProdId (net.fortuna.ical4j.model.property.ProdId)1 EmptyResultDataAccessException (org.springframework.dao.EmptyResultDataAccessException)1