use of com.zimbra.cs.db.DbDataSource.DataSourceItem in project zm-mailbox by Zimbra.
the class ImapFolder method getNewMessageIds.
public List<Integer> getNewMessageIds() throws ServiceException {
Collection<DataSourceItem> mappings = getMappingsAndFlags(ds, getItemId());
Mailbox mbox = DataSourceManager.getInstance().getMailbox(ds);
List<Integer> allIds = mbox.listItemIds(mbox.getOperationContext(), MailItem.Type.MESSAGE, getItemId());
List<Integer> newIds = new ArrayList<Integer>();
loop: for (Integer id : allIds) {
for (DataSourceItem mapping : mappings) {
if (mapping.itemId == id) {
mappings.remove(mapping);
continue loop;
}
}
newIds.add(id);
}
return newIds;
}
use of com.zimbra.cs.db.DbDataSource.DataSourceItem in project zm-mailbox by Zimbra.
the class ImapFolder method getMessages.
public ImapMessageCollection getMessages() throws ServiceException {
Collection<DataSourceItem> mappings = getMappingsAndFlags(ds, getItemId());
ImapMessageCollection imc = new ImapMessageCollection();
for (DataSourceItem mapping : mappings) imc.add(new ImapMessage(ds, mapping));
return imc;
}
use of com.zimbra.cs.db.DbDataSource.DataSourceItem in project zm-mailbox by Zimbra.
the class ImapFolder method getFolders.
public static ImapFolderCollection getFolders(DataSource ds) throws ServiceException {
Collection<DataSourceItem> mappings = getMappings(ds, ds.getFolderId());
ImapFolderCollection ifc = new ImapFolderCollection();
if (mappings.size() == 0) {
Mailbox mbox = DataSourceManager.getInstance().getMailbox(ds);
ZimbraLog.datasource.info("Upgrading IMAP data for %s", ds.getName());
DbDataSource.deleteAllMappings(ds);
try {
for (ImapFolder folderTracker : DbImapFolder.getImapFolders(mbox, ds)) {
folderTracker.add();
for (ImapMessage msgTracker : DbImapMessage.getImapMessages(mbox, ds, folderTracker)) {
msgTracker.add();
}
}
} catch (Exception e) {
DbDataSource.deleteAllMappings(ds);
throw ServiceException.FAILURE("IMAP data upgrade failed for " + ds.getName(), e);
}
mappings = getMappings(ds, ds.getFolderId());
DbImapFolder.deleteImapData(mbox, ds.getId());
}
for (DataSourceItem mapping : mappings) ifc.add(new ImapFolder(ds, mapping));
return ifc;
}
Aggregations