use of com.zimbra.cs.redolog.op.MoveItem in project zm-mailbox by Zimbra.
the class Mailbox method moveInternal.
private void moveInternal(OperationContext octxt, int[] itemIds, MailItem.Type type, int targetId, TargetConstraint tcon) throws ServiceException {
MoveItem redoRecorder = new MoveItem(mId, itemIds, type, targetId, tcon);
boolean success = false;
try {
beginTransaction("move", octxt, redoRecorder);
setOperationTargetConstraint(tcon);
Folder target = getFolderById(targetId);
MailItem[] items = getItemById(itemIds, type);
for (MailItem item : items) {
checkItemChangeID(item);
}
int oldUIDNEXT = target.getImapUIDNEXT();
boolean resetUIDNEXT = false;
for (MailItem item : items) {
// train the spam filter if necessary...
trainSpamFilter(octxt, item, target, "move");
// ...do the move...
boolean moved = item.move(target);
// ...and determine whether the move needs to cause an UIDNEXT change
if (moved && !resetUIDNEXT && isTrackingImap() && (item instanceof Conversation || item instanceof Message || item instanceof Contact)) {
resetUIDNEXT = true;
}
}
// if this operation should cause the target folder's UIDNEXT value to change but it hasn't yet, do it here
if (resetUIDNEXT && oldUIDNEXT == target.getImapUIDNEXT()) {
MoveItem redoPlayer = (MoveItem) currentChange().getRedoPlayer();
redoRecorder.setUIDNEXT(getNextItemId(redoPlayer == null ? ID_AUTO_INCREMENT : redoPlayer.getUIDNEXT()));
target.updateUIDNEXT();
}
success = true;
} finally {
endTransaction(success);
}
}
Aggregations