List<EventVO> events = new ArrayList<EventVO>();
Calendar icalendar = new CalendarBuilder().build(ical);
List<Component> components = icalendar.getComponents();
for(Component comp : components)
{
EventVO event = new EventVO();
if(log.isDebugEnabled())
log.debug("import component: " + comp);
if(comp instanceof VEvent) //only VEvent are parsed
{
if(comp.getProperties().getProperty((Property.DESCRIPTION)) != null)
event.setDescription(comp.getProperties().getProperty(Property.DESCRIPTION).getValue());
if(comp.getProperties().getProperty((Property.SUMMARY)) != null)
event.setTitle(comp.getProperties().getProperty(Property.SUMMARY).getValue());
else
event.setTitle("XXX");
if(comp.getProperties().getProperty((Property.DTSTART)) != null)
if(comp.getProperties().getProperty(Property.DTSTART).getParameter("VALUE") != null
&& comp.getProperties().getProperty(Property.DTSTART).getParameter("VALUE").getValue().equals("DATE"))
{
event.setStartDate(new Date(comp.getProperties().getProperty(Property.DTSTART).getValue()));
event.setAllDay(true);
}
else
event.setStartDate(new DateTime(comp.getProperties().getProperty(Property.DTSTART).getValue()));
if(comp.getProperties().getProperty((Property.DTEND)) != null)
if(comp.getProperties().getProperty(Property.DTEND).getParameter("VALUE") != null
&& comp.getProperties().getProperty(Property.DTEND).getParameter("VALUE").getValue().equals("DATE"))
{
event.setEndDate(new Date(comp.getProperties().getProperty(Property.DTEND).getValue()));
}
else
event.setEndDate(new DateTime(comp.getProperties().getProperty(Property.DTEND).getValue()));
else
event.setEndDate(event.getStartDate());
if(comp.getProperties().getProperty(Property.RRULE) != null)
readRecur(comp.getProperties().getProperty(Property.RRULE).getValue(),event);
else
event.setRecurrenceType(RecurrenceType.NONE);
if(comp.getProperties().getProperty("X-OC-ID") != null)
event.setId(Integer.parseInt(comp.getProperties().getProperty("X-OC-ID").getValue()));
else if(comp.getProperties().getProperty(Property.UID) != null && comp.getProperties().getProperty(Property.UID).getValue().endsWith("@opencustomner"))
event.setId(Integer.parseInt(comp.getProperties().getProperty(Property.UID).getValue().split("@")[0]));
events.add(event);
if(log.isDebugEnabled())
log.debug("event parsed: " + event);
}
else