Skip to content
Snippets Groups Projects
Commit 520b8dc2 authored by srosse's avatar srosse
Browse files

FXOLAT-298: improve support of ical exported calendars

parent 66dacd50
No related branches found
No related tags found
No related merge requests found
...@@ -23,6 +23,7 @@ package org.olat.commons.calendar; ...@@ -23,6 +23,7 @@ package org.olat.commons.calendar;
import net.fortuna.ical4j.model.TimeZone; import net.fortuna.ical4j.model.TimeZone;
import net.fortuna.ical4j.model.TimeZoneRegistry; import net.fortuna.ical4j.model.TimeZoneRegistry;
import net.fortuna.ical4j.model.TimeZoneRegistryFactory; import net.fortuna.ical4j.model.TimeZoneRegistryFactory;
import net.fortuna.ical4j.util.CompatibilityHints;
import org.olat.core.configuration.AbstractOLATModule; import org.olat.core.configuration.AbstractOLATModule;
import org.olat.core.configuration.PersistedProperties; import org.olat.core.configuration.PersistedProperties;
...@@ -45,7 +46,8 @@ public class CalendarModule extends AbstractOLATModule { ...@@ -45,7 +46,8 @@ public class CalendarModule extends AbstractOLATModule {
public void init() { public void init() {
//some computers have no Internet access, the host can be down and we must get the default time zone //some computers have no Internet access, the host can be down and we must get the default time zone
System.setProperty("net.fortuna.ical4j.timezone.update.enabled", "false"); System.setProperty("net.fortuna.ical4j.timezone.update.enabled", "false");
System.setProperty("ical4j.unfolding.relaxed", "true"); System.setProperty(CompatibilityHints.KEY_RELAXED_UNFOLDING, "true");
System.setProperty(CompatibilityHints.KEY_RELAXED_PARSING, "true");
String defaultTimeZoneID = java.util.TimeZone.getDefault().getID(); String defaultTimeZoneID = java.util.TimeZone.getDefault().getID();
timeZoneRegistry = TimeZoneRegistryFactory.getInstance().createRegistry(); timeZoneRegistry = TimeZoneRegistryFactory.getInstance().createRegistry();
defaultTimeZone = timeZoneRegistry.getTimeZone(defaultTimeZoneID); defaultTimeZone = timeZoneRegistry.getTimeZone(defaultTimeZoneID);
......
...@@ -14,6 +14,7 @@ import net.fortuna.ical4j.model.TimeZone; ...@@ -14,6 +14,7 @@ import net.fortuna.ical4j.model.TimeZone;
import net.fortuna.ical4j.model.TimeZoneRegistry; import net.fortuna.ical4j.model.TimeZoneRegistry;
import net.fortuna.ical4j.model.TimeZoneRegistryFactory; import net.fortuna.ical4j.model.TimeZoneRegistryFactory;
import net.fortuna.ical4j.model.parameter.Value; import net.fortuna.ical4j.model.parameter.Value;
import net.fortuna.ical4j.util.CompatibilityHints;
import net.fortuna.ical4j.util.Dates; import net.fortuna.ical4j.util.Dates;
import net.fortuna.ical4j.util.TimeZones; import net.fortuna.ical4j.util.TimeZones;
...@@ -69,5 +70,17 @@ public class CalendarImportTest { ...@@ -69,5 +70,17 @@ public class CalendarImportTest {
Calendar calendar = builder.build(in); Calendar calendar = builder.build(in);
assertNotNull(calendar); assertNotNull(calendar);
} }
@Test
public void testImportFromFGiCal() throws IOException, ParserException {
//default settings in olat
System.setProperty(CompatibilityHints.KEY_RELAXED_UNFOLDING, "true");
System.setProperty(CompatibilityHints.KEY_RELAXED_PARSING, "true");
InputStream in = CalendarImportTest.class.getResourceAsStream("EMAIL.ics");
CalendarBuilder builder = new CalendarBuilder();
Calendar calendar = builder.build(in);
assertNotNull(calendar);
}
} }
BEGIN:VCALENDAR
METHOD:PUBLISH
VERSION:2.0
X-WR-CALNAME:FG-Office
PRODID:-//Apple Inc.//iCal 5.0.1//EN
X-APPLE-CALENDAR-COLOR:#0E61B9
X-WR-TIMEZONE:Europe/Zurich
CALSCALE:GREGORIAN
BEGIN:VTIMEZONE
TZID:Europe/Berlin
BEGIN:DAYLIGHT
TZOFFSETFROM:+0100
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU
DTSTART:19810329T020000
TZNAME:CEST
TZOFFSETTO:+0200
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:+0200
RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU
DTSTART:19961027T030000
TZNAME:CET
TZOFFSETTO:+0100
END:STANDARD
END:VTIMEZONE
BEGIN:VTIMEZONE
TZID:America/New_York
BEGIN:DAYLIGHT
TZOFFSETFROM:-0500
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
DTSTART:20070311T020000
TZNAME:EDT
TZOFFSETTO:-0400
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:-0400
RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
DTSTART:20071104T020000
TZNAME:EST
TZOFFSETTO:-0500
END:STANDARD
END:VTIMEZONE
BEGIN:VTIMEZONE
TZID:Europe/Zurich
BEGIN:DAYLIGHT
TZOFFSETFROM:+0100
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU
DTSTART:19810329T020000
TZNAME:CEST
TZOFFSETTO:+0200
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:+0200
RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU
DTSTART:19961027T030000
TZNAME:CET
TZOFFSETTO:+0100
END:STANDARD
END:VTIMEZONE
BEGIN:VTIMEZONE
TZID:America/Chicago
BEGIN:DAYLIGHT
TZOFFSETFROM:-0600
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
DTSTART:20070311T020000
TZNAME:CDT
TZOFFSETTO:-0500
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:-0500
RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
DTSTART:20071104T020000
TZNAME:CST
TZOFFSETTO:-0600
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
CREATED:20111108T162555Z
UID:61993671-1958-418D-A84B-264BA4E21670
DTEND;TZID=Europe/Zurich:20111109T093000
ATTENDEE;CN="Florian Gnägi";CUTYPE=INDIVIDUAL;EMAIL="gnaegi@frentix.com"
;PARTSTAT=ACCEPTED;ROLE=REQ-PARTICIPANT:mailto:gnaegi@frentix.com
ATTENDEE;CN="Christian Franck";CUTYPE=INDIVIDUAL;PARTSTAT=ACCEPTED:mailt
o:Christian.Franck@frentix.com
TRANSP:OPAQUE
SUMMARY:Besprechung wg. USU und Becker
DTSTART;TZID=Europe/Zurich:20111109T090000
DTSTAMP:20111108T162634Z
ORGANIZER;CN="Christian Franck";SCHEDULE-AGENT=CLIENT:mailto:Christian.F
ranck@frentix.com
SEQUENCE:4
END:VEVENT
BEGIN:VEVENT
CREATED:20111109T120320Z
UID:46A80CEF-2660-4A23-8ADE-FF960901B987
DTEND;TZID=Europe/Zurich:20111116T120000
TRANSP:OPAQUE
SUMMARY:Physio
DTSTART;TZID=Europe/Zurich:20111116T113000
DTSTAMP:20111109T124426Z
SEQUENCE:1
BEGIN:VALARM
X-WR-ALARMUID:A554BE09-0C97-4B9F-A22C-4A055132D5F1
TRIGGER:-PT30M
DESCRIPTION:Event reminder
ACTION:DISPLAY
END:VALARM
END:VEVENT
BEGIN:VEVENT
CREATED:20111109T162022Z
UID:341906F7-2863-45AF-B3F1-02767F6225BF
DTEND;TZID=Europe/Zurich:20111107T201500
TRANSP:OPAQUE
SUMMARY:Neues Ereignis
DTSTART;TZID=Europe/Zurich:20111107T200000
DTSTAMP:20111109T162022Z
SEQUENCE:0
END:VEVENT
END:VCALENDAR
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment