Search in sources :

Example 1 with Callback

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);
    }
}
Also used : SetCalendarItem(com.zimbra.cs.redolog.op.SetCalendarItem) AllAccountsRedoCommitCallback(com.zimbra.cs.session.AllAccountsRedoCommitCallback) Callback(com.zimbra.cs.mailbox.CalendarItem.Callback) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ConcurrentLinkedHashMap(com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap) HashMap(java.util.HashMap) FixCalendarItemTZ(com.zimbra.cs.redolog.op.FixCalendarItemTZ) ICalTimeZone(com.zimbra.common.calendar.ICalTimeZone) RefreshMountpoint(com.zimbra.cs.redolog.op.RefreshMountpoint) TargetConstraint(com.zimbra.cs.mailbox.MailItem.TargetConstraint) CreateMountpoint(com.zimbra.cs.redolog.op.CreateMountpoint)

Aggregations

ConcurrentLinkedHashMap (com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap)1 ICalTimeZone (com.zimbra.common.calendar.ICalTimeZone)1 Callback (com.zimbra.cs.mailbox.CalendarItem.Callback)1 TargetConstraint (com.zimbra.cs.mailbox.MailItem.TargetConstraint)1 CreateMountpoint (com.zimbra.cs.redolog.op.CreateMountpoint)1 FixCalendarItemTZ (com.zimbra.cs.redolog.op.FixCalendarItemTZ)1 RefreshMountpoint (com.zimbra.cs.redolog.op.RefreshMountpoint)1 SetCalendarItem (com.zimbra.cs.redolog.op.SetCalendarItem)1 AllAccountsRedoCommitCallback (com.zimbra.cs.session.AllAccountsRedoCommitCallback)1 HashMap (java.util.HashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1