use of net.fortuna.ical4j.data.CalendarBuilder in project OpenOLAT by OpenOLAT.
the class ICalServlet method getOutlookVTimeZone.
/**
* Load the VTimeZone for Outlook. ical4j use a static map to reuse the TimeZone objects, we need to load
* and save our specialized TimeZone in a separate map.
*/
private VTimeZone getOutlookVTimeZone(final String id) throws IOException, ParserException {
return outlookVTimeZones.computeIfAbsent(id, (timeZoneId) -> {
try {
URL resource = ResourceLoader.getResource("zoneinfo-outlook/" + id + ".ics");
CalendarBuilder builder = new CalendarBuilder();
Calendar calendar = builder.build(resource.openStream());
VTimeZone vTimeZone = (VTimeZone) calendar.getComponent(Component.VTIMEZONE);
return vTimeZone;
} catch (Exception e) {
log.error("", e);
return null;
}
});
}
use of net.fortuna.ical4j.data.CalendarBuilder in project zm-mailbox by Zimbra.
the class ZoneInfo2iCalendar method makeOldTimeZonesMap.
private static Map<String, VTimeZone> makeOldTimeZonesMap(Params params) {
Map<String, VTimeZone> oldTimeZones = Maps.newHashMap();
if (null != params.oldTimezonesFileName) {
try (FileInputStream fin = new FileInputStream(params.oldTimezonesFileName)) {
CalendarBuilder builder = new CalendarBuilder();
net.fortuna.ical4j.model.Calendar calendar = builder.build(fin, "UTF-8");
for (Iterator i = calendar.getComponents().iterator(); i.hasNext(); ) {
Component component = (Component) i.next();
if (Component.VTIMEZONE.equals(component.getName())) {
VTimeZone vtz = (VTimeZone) component;
Property tzprop = vtz.getProperties().getProperty(Property.TZID);
if (null != tzprop) {
oldTimeZones.put(tzprop.getValue(), vtz);
}
}
}
} catch (IOException | ParserException e) {
System.err.println("Problem loading old timezones.ics - ignoring it. " + e.getMessage());
}
}
return oldTimeZones;
}
use of net.fortuna.ical4j.data.CalendarBuilder in project openolat by klemens.
the class CalendarImportTest method testImportWeekFromOutlook.
@Test
public void testImportWeekFromOutlook() throws IOException, ParserException {
InputStream in = CalendarImportTest.class.getResourceAsStream("BB_7.ics");
CalendarBuilder builder = new CalendarBuilder();
Calendar calendar = builder.build(in);
assertNotNull(calendar);
}
use of net.fortuna.ical4j.data.CalendarBuilder in project openolat by klemens.
the class CalendarImportTest method testImportAllFromOutlook.
@Test
public void testImportAllFromOutlook() throws IOException, ParserException {
InputStream in = CalendarImportTest.class.getResourceAsStream("BB_Alles.ics");
CalendarBuilder builder = new CalendarBuilder();
Calendar calendar = builder.build(in);
assertNotNull(calendar);
}
use of net.fortuna.ical4j.data.CalendarBuilder in project openolat by klemens.
the class CalendarImportTest method testImportMonthFromOutlook.
@Test
public void testImportMonthFromOutlook() throws IOException, ParserException {
InputStream in = CalendarImportTest.class.getResourceAsStream("BB_30.ics");
CalendarBuilder builder = new CalendarBuilder();
Calendar calendar = builder.build(in);
assertNotNull(calendar);
}
Aggregations