use of com.zimbra.cs.imap.ImapParseException.ImapMaximumSizeExceededException in project zm-mailbox by Zimbra.
the class ImapHandler method doAPPEND.
private boolean doAPPEND(String tag, ImapPath path, List<AppendMessage> appends) throws IOException, ImapException {
checkCommandThrottle(new AppendCommand(path, appends));
if (!checkState(tag, State.AUTHENTICATED)) {
return true;
}
ImapMailboxStore mboxStore = null;
List<Integer> createdIds = new ArrayList<Integer>(appends.size());
StringBuilder appendHint = extensionEnabled("UIDPLUS") ? new StringBuilder() : null;
OperationContext octxt = getContextOrNull();
try {
if (!path.isVisible()) {
throw ImapServiceException.FOLDER_NOT_VISIBLE(path.asImapPath());
} else if (!path.isWritable(ACL.RIGHT_INSERT)) {
throw ImapServiceException.FOLDER_NOT_WRITABLE(path.asImapPath());
}
mboxStore = path.getOwnerImapMailboxStore();
mboxStore.checkAppendMessageFlags(octxt, appends);
FolderStore folderStore = path.getFolder();
// Append message parts and check message content size
for (AppendMessage append : appends) {
append.checkContent();
}
for (AppendMessage append : appends) {
int id = append.storeContent(mboxStore, folderStore);
if (id > 0) {
createdIds.add(id);
}
}
int uvv = folderStore.getUIDValidity();
if (appendHint != null && uvv > 0) {
appendHint.append("[APPENDUID ").append(uvv).append(' ').append(ImapFolder.encodeSubsequence(createdIds)).append("] ");
}
} catch (ZClientUploadSizeLimitExceededException zcusle) {
ZimbraLog.imap.debug("upload limit hit", zcusle);
throw new ImapMaximumSizeExceededException(tag, "message");
} catch (ServiceException e) {
for (AppendMessage append : appends) {
append.cleanup();
}
if (null != mboxStore) {
mboxStore.deleteMessages(octxt, createdIds);
}
String msg = "APPEND failed";
if (e.getCode().equals(MailServiceException.NO_SUCH_FOLDER)) {
ZimbraLog.imap.info("APPEND failed: no such folder: " + path);
// of the text of the tagged NO response."
if (path.isCreatable()) {
msg = "[TRYCREATE] APPEND failed: no such mailbox";
}
} else if (e.getCode().equals(MailServiceException.INVALID_NAME)) {
ZimbraLog.imap.info("APPEND failed: " + e.getMessage());
} else if (e.getCode().equals(ImapServiceException.FOLDER_NOT_VISIBLE)) {
ZimbraLog.imap.info("APPEND failed: folder not visible: " + path);
} else if (e.getCode().equals(ImapServiceException.FOLDER_NOT_WRITABLE)) {
ZimbraLog.imap.info("APPEND failed: folder not writable: " + path);
} else if (e.getCode().equals(MailServiceException.QUOTA_EXCEEDED)) {
ZimbraLog.imap.info("APPEND failed: quota exceeded");
} else {
ZimbraLog.imap.warn("APPEND failed", e);
}
sendNO(tag, msg);
return canContinue(e);
}
sendNotifications(true, false);
sendOK(tag, (appendHint == null ? "" : appendHint.toString()) + "APPEND completed");
return true;
}
Aggregations