LastModified lastMod = new LastModified(new DateTime(kEvent.getLastModified()));
vEvent.getProperties().add(lastMod);
}
// Uid
PropertyList vEventProperties = vEvent.getProperties();
vEventProperties.add(new Uid(kEvent.getID()));
// clazz
switch (kEvent.getClassification()) {
case KalendarEvent.CLASS_PRIVATE: vEventProperties.add(ICAL_CLASS_PRIVATE); break;
case KalendarEvent.CLASS_PUBLIC: vEventProperties.add(ICAL_CLASS_PUBLIC); break;
case KalendarEvent.CLASS_X_FREEBUSY: vEventProperties.add(ICAL_CLASS_X_FREEBUSY); break;
default: vEventProperties.add(ICAL_CLASS_PRIVATE); break;
}
// location
if (kEvent.getLocation() != null) {
vEventProperties.add(new Location(kEvent.getLocation()));
}
// event links
List kalendarEventLinks = kEvent.getKalendarEventLinks();
if ((kalendarEventLinks != null) && !kalendarEventLinks.isEmpty()) {
for (Iterator iter = kalendarEventLinks.iterator(); iter.hasNext();) {
KalendarEventLink link = (KalendarEventLink) iter.next();
StringBuilder linkEncoded = new StringBuilder(200);
linkEncoded.append(link.getProvider());
linkEncoded.append("§");
linkEncoded.append(link.getId());
linkEncoded.append("§");
linkEncoded.append(link.getDisplayName());
linkEncoded.append("§");
linkEncoded.append(link.getURI());
linkEncoded.append("§");
linkEncoded.append(link.getIconCssClass());
XProperty linkProperty = new XProperty(ICAL_X_OLAT_LINK, linkEncoded.toString());
vEventProperties.add(linkProperty);
}
}
if (kEvent.getComment() != null) {
vEventProperties.add(new XProperty(ICAL_X_OLAT_COMMENT, kEvent.getComment()));
}
if (kEvent.getNumParticipants() != null) {
vEventProperties.add(new XProperty(ICAL_X_OLAT_NUMPARTICIPANTS, Integer.toString(kEvent.getNumParticipants())));
}
if (kEvent.getParticipants() != null) {
StringBuffer strBuf = new StringBuffer();
String[] participants = kEvent.getParticipants();
for ( String participant : participants ) {
strBuf.append(participant);
strBuf.append("§");
}
vEventProperties.add(new XProperty(ICAL_X_OLAT_PARTICIPANTS, strBuf.toString()));
}
if (kEvent.getSourceNodeId() != null) {
vEventProperties.add(new XProperty(ICAL_X_OLAT_SOURCENODEID, kEvent.getSourceNodeId()));
}
// recurrence
String recurrence = kEvent.getRecurrenceRule();
if(recurrence != null && !recurrence.equals("")) {
try {
Recur recur = new Recur(recurrence);
RRule rrule = new RRule(recur);
vEventProperties.add(rrule);
} catch (ParseException e) {
Tracing.createLoggerFor(getClass()).error("cannot create recurrence rule: " + recurrence.toString(), e);
}
}
// recurrence exclusions
String recurrenceExc = kEvent.getRecurrenceExc();
if(recurrenceExc != null && !recurrenceExc.equals("")) {
ExDate exdate = new ExDate();
try {
exdate.setValue(recurrenceExc);
vEventProperties.add(exdate);
} catch (ParseException e) {
e.printStackTrace();
}
}