Search in sources :

Example 51 with NoSuchItemException

use of com.zimbra.cs.mailbox.MailServiceException.NoSuchItemException in project zm-mailbox by Zimbra.

the class Mailbox method createTagInternal.

Tag createTagInternal(int tagId, String name, Color color, boolean listed) throws ServiceException {
    try {
        Tag tag = getTagByName(name);
        if (!listed) {
            // want an implicitly-created tag but there's already a listed tag, so just return it unchanged
            return tag;
        } else if (tag.isListed()) {
            // can't have two listed tags with the same name
            throw MailServiceException.ALREADY_EXISTS(name);
        }
        // promote an implicitly-created tag to a listed tag
        markItemCreated(tag);
        tag.setListed();
        if (!name.equals(tag.getName())) {
            tag.rename(name);
        }
        tag.setColor(color);
        return tag;
    } catch (NoSuchItemException nsie) {
        // no conflict, so just create the new tag as requested
        return Tag.create(this, getNextItemId(tagId), name, color, listed);
    }
}
Also used : AlterItemTag(com.zimbra.cs.redolog.op.AlterItemTag) CreateTag(com.zimbra.cs.redolog.op.CreateTag) DbTag(com.zimbra.cs.db.DbTag) NoSuchItemException(com.zimbra.cs.mailbox.MailServiceException.NoSuchItemException)

Example 52 with NoSuchItemException

use of com.zimbra.cs.mailbox.MailServiceException.NoSuchItemException in project zm-mailbox by Zimbra.

the class SaveDraft method generateResponse.

protected Element generateResponse(ZimbraSoapContext zsc, ItemIdFormatter ifmt, OperationContext octxt, Mailbox mbox, Message msg, boolean wantImapUid, boolean wantModSeq) {
    Element response = zsc.createElement(MailConstants.SAVE_DRAFT_RESPONSE);
    try {
        int fields = ToXML.NOTIFY_FIELDS;
        if (wantImapUid) {
            fields |= Change.IMAP_UID;
        }
        if (wantModSeq) {
            fields |= Change.MODSEQ;
        }
        ToXML.encodeMessageAsMP(response, ifmt, octxt, msg, null, -1, true, true, null, true, false, false, MsgContent.full, fields);
    } catch (NoSuchItemException nsie) {
        ZimbraLog.soap.info("draft was deleted while serializing response; omitting <m> from response");
    } catch (ServiceException e) {
        ZimbraLog.soap.warn("problem serializing draft structure to response", e);
    }
    return response;
}
Also used : ServiceException(com.zimbra.common.service.ServiceException) MailServiceException(com.zimbra.cs.mailbox.MailServiceException) Element(com.zimbra.common.soap.Element) NoSuchItemException(com.zimbra.cs.mailbox.MailServiceException.NoSuchItemException)

Aggregations

NoSuchItemException (com.zimbra.cs.mailbox.MailServiceException.NoSuchItemException)52 ServiceException (com.zimbra.common.service.ServiceException)21 Mailbox (com.zimbra.cs.mailbox.Mailbox)18 MailServiceException (com.zimbra.cs.mailbox.MailServiceException)16 ItemId (com.zimbra.cs.service.util.ItemId)12 Test (org.junit.Test)11 Account (com.zimbra.cs.account.Account)10 OperationContext (com.zimbra.cs.mailbox.OperationContext)10 Element (com.zimbra.common.soap.Element)9 MailItem (com.zimbra.cs.mailbox.MailItem)9 Folder (com.zimbra.cs.mailbox.Folder)8 IOException (java.io.IOException)8 MimeMessage (javax.mail.internet.MimeMessage)8 ZimbraMailItem (com.zimbra.common.mailbox.ZimbraMailItem)7 AccountServiceException (com.zimbra.cs.account.AccountServiceException)6 Mountpoint (com.zimbra.cs.mailbox.Mountpoint)6 ParsedMessage (com.zimbra.cs.mime.ParsedMessage)6 ArrayList (java.util.ArrayList)6 DbMailItem (com.zimbra.cs.db.DbMailItem)5 DbTag (com.zimbra.cs.db.DbTag)5