public synchronized List<MailItem> getModifiedItems(OperationContext octxt, byte type, long lastSync) throws ServiceException { if (type == MailItem.TYPE_UNKNOWN) return null; else if (lastSync >= getLastChangeID()) return Collections.emptyList();  List<MailItem> modified = new ArrayList<MailItem>(); boolean success = false; try { beginTransaction("getModifiedItems", octxt);  if (type == MailItem.TYPE_TAG) { if (hasFullAccess()) for (Map.Entry<Object, Tag> entry : mTagCache.entrySet()) if (entry.getKey() instanceof String) { Tag tag = entry.getValue(); if (tag.getModifiedSequence() > lastSync && !(tag instanceof Flag)) modified.add(tag); } } else if (type == MailItem.TYPE_FOLDER || type == MailItem.TYPE_SEARCHFOLDER || type == MailItem.TYPE_MOUNTPOINT) { for (Folder subfolder : mFolderCache.values()) if (type == MailItem.TYPE_FOLDER || subfolder.getType() == type) if (subfolder.getModifiedSequence() > lastSync && subfolder.canAccess(ACL.RIGHT_READ)) modified.add(subfolder); Collections.sort(modified); } else { List<MailItem.UnderlyingData> dataList = DbMailItem.getModifiedItems(this, type, lastSync); if (dataList == null) return null; for (MailItem.UnderlyingData data : dataList) if (data != null) modified.add(getItem(data)); } success = true; return modified; } finally { endTransaction(success); }
public synchronized Pair<List<MailItem>,List<Integer>> getModifiedItems(OperationContext octxt, long lastSync) throws ServiceException { return getModifiedItems(octxt, lastSync, MailItem.TYPE_UNKNOWN, null);
    public synchronized List<MailItem> getModifiedItems(OperationContext octxt, byte type, long lastSync) throws ServiceException {        if (type == MailItem.TYPE_UNKNOWN)            return null;        else if (lastSync >= getLastChangeID())            return Collections.emptyList();        List<MailItem> modified = new ArrayList<MailItem>();        boolean success = false;        try {            beginTransaction("getModifiedItems", octxt);            if (type == MailItem.TYPE_TAG) {                if (hasFullAccess())                    for (Map.Entry<Object, Tag> entry : mTagCache.entrySet())                        if (entry.getKey() instanceof String) {                            Tag tag = entry.getValue();                            if (tag.getModifiedSequence() > lastSync && !(tag instanceof Flag))                                modified.add(tag);                        }            } else if (type == MailItem.TYPE_FOLDER || type == MailItem.TYPE_SEARCHFOLDER || type == MailItem.TYPE_MOUNTPOINT) {                for (Folder subfolder : mFolderCache.values())                    if (type == MailItem.TYPE_FOLDER || subfolder.getType() == type)                        if (subfolder.getModifiedSequence() > lastSync && subfolder.canAccess(ACL.RIGHT_READ))                            modified.add(subfolder);                Collections.sort(modified);            } else {                List<MailItem.UnderlyingData> dataList = DbMailItem.getModifiedItems(this, type, lastSync);                if (dataList == null)                    return null;                for (MailItem.UnderlyingData data : dataList)                    if (data != null)                        modified.add(getItem(data));            }            success = true;            return modified;        } finally {            endTransaction(success);        }    }