Search in sources :

Example 6 with CalendarFileInfos

use of org.olat.commons.calendar.model.CalendarFileInfos in project openolat by klemens.

the class ICalServlet method generateAggregatedCalendar.

/**
 * Collect all the calendars, update the URL properties and the UUID.
 *
 * @param identity
 * @param request
 * @param response
 * @throws IOException
 */
private void generateAggregatedCalendar(Identity identity, HttpServletRequest request, HttpServletResponse response) throws IOException {
    PersonalCalendarManager homeCalendarManager = CoreSpringFactory.getImpl(PersonalCalendarManager.class);
    if (identity == null) {
        response.sendError(HttpServletResponse.SC_NOT_FOUND);
    } else {
        List<CalendarFileInfos> iCalFiles = homeCalendarManager.getListOfCalendarsFiles(identity);
        DBFactory.getInstance().commitAndCloseSession();
        Agent agent = getAgent(request);
        Writer out = response.getWriter();
        out.write(Calendar.BEGIN);
        out.write(':');
        out.write(Calendar.VCALENDAR);
        out.write(Strings.LINE_SEPARATOR);
        out.write(Version.VERSION_2_0.toString());
        out.write(CalScale.GREGORIAN.toString());
        outputTTL(agent, out);
        Set<String> timezoneIds = new HashSet<>();
        int numOfFiles = iCalFiles.size();
        for (int i = 0; i < numOfFiles; i++) {
            outputCalendar(iCalFiles.get(i), out, agent, timezoneIds);
        }
        if (agent == Agent.outlook) {
            outputTimeZoneForOutlook(timezoneIds, out);
        }
        out.write(Calendar.END);
        out.write(':');
        out.write(Calendar.VCALENDAR);
    }
}
Also used : CalendarFileInfos(org.olat.commons.calendar.model.CalendarFileInfos) Writer(java.io.Writer) HashSet(java.util.HashSet)

Aggregations

CalendarFileInfos (org.olat.commons.calendar.model.CalendarFileInfos)6 File (java.io.File)4 ArrayList (java.util.ArrayList)4 HashSet (java.util.HashSet)4 Writer (java.io.Writer)2 CalendarKey (org.olat.commons.calendar.model.CalendarKey)2 CalendarUserConfiguration (org.olat.commons.calendar.model.CalendarUserConfiguration)2 ImportedCalendar (org.olat.commons.calendar.model.ImportedCalendar)2 BusinessGroup (org.olat.group.BusinessGroup)2 SearchBusinessGroupParams (org.olat.group.model.SearchBusinessGroupParams)2 RepositoryEntry (org.olat.repository.RepositoryEntry)2