use of com.zimbra.cs.mailbox.CalendarItem.Callback in project zm-mailbox by Zimbra.
the class Mailbox method fixCalendarItemTZ.
/**
* Fix up timezone definitions in an appointment/task. Fixup is
* required when governments change the daylight savings policy.
*
* @param fixupRules rules specifying which timezones to fix and how
* @return number of timezone objects that were modified
*/
public int fixCalendarItemTZ(OperationContext octxt, int calItemId, TimeZoneFixupRules fixupRules) throws ServiceException {
FixCalendarItemTZ redoRecorder = new FixCalendarItemTZ(getId(), calItemId);
boolean success = false;
try {
beginTransaction("fixCalendarItemTimeZone2", octxt, redoRecorder);
CalendarItem calItem = getCalendarItemById(octxt, calItemId);
Map<String, ICalTimeZone> replaced = new HashMap<String, ICalTimeZone>();
int numFixed = fixupRules.fixCalendarItem(calItem, replaced);
if (numFixed > 0) {
ZimbraLog.calendar.info("Fixed " + numFixed + " timezone entries in calendar item " + calItem.getId());
redoRecorder.setReplacementMap(replaced);
markItemModified(calItem, Change.CONTENT | Change.INVITE);
calItem.snapshotRevision();
calItem.saveMetadata();
// Need to uncache and refetch the item because there are fields
// in the appointment/task that reference the old, pre-fix version
// of the timezones. We can either visit them all and update them,
// or simply invalidate the calendar item and refetch it.
uncacheItem(calItemId);
calItem = getCalendarItemById(octxt, calItemId);
success = true;
Callback cb = CalendarItem.getCallback();
if (cb != null) {
cb.modified(calItem);
}
}
return numFixed;
} finally {
endTransaction(success);
}
}
Aggregations