use of org.bedework.util.calendar.XmlCalendarBuilder in project bw-calendar-engine by Bedework.
the class IcalTranslator method fromIcal.
/**
* Convert the Icalendar reader to a Collection of Calendar objects
*
* @param col collection the entities will live in - possibly null
* @param rdr
* @param contentType
* @param diff True if we should assume we are updating existing events.
* @param mergeAttendees True if we should only update our own attendee.
* @return Icalendar
* @throws CalFacadeException
*/
public Icalendar fromIcal(final BwCalendar col, final Reader rdr, final String contentType, final boolean diff, final boolean mergeAttendees) throws CalFacadeException {
try {
Icalendar ic = new Icalendar();
setSystemProperties();
Calendar cal;
if ((contentType != null) && contentType.equals("application/calendar+xml")) {
XmlCalendarBuilder bldr = new XmlCalendarBuilder(ic);
cal = bldr.build(rdr);
} else if ((contentType != null) && contentType.equals("application/calendar+json")) {
JsonCalendarBuilder bldr = new JsonCalendarBuilder(ic);
cal = bldr.build(rdr);
} else {
CalendarBuilder bldr = new CalendarBuilder(new CalendarParserImpl(), ic);
UnfoldingReader ufrdr = new UnfoldingReader(rdr, true);
cal = bldr.build(ufrdr);
}
return makeIc(col, ic, cal, diff, mergeAttendees);
} catch (CalFacadeException cfe) {
throw cfe;
} catch (ParserException pe) {
if (debug) {
error(pe);
}
throw new IcalMalformedException(pe.getMessage());
} catch (Throwable t) {
throw new CalFacadeException(t);
}
}
Aggregations