Search in sources :

Example 1 with Comment

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

the class AddComment method handle.

@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    Mailbox mbox = getRequestedMailbox(zsc);
    OperationContext octxt = getOperationContext(zsc, context);
    String creator = zsc.getAuthtokenAccountId();
    Element c = request.getElement(MailConstants.E_COMMENT);
    String itemId = c.getAttribute(MailConstants.A_PARENT_ID);
    String text = c.getAttribute(MailConstants.A_TEXT);
    ItemId iid = new ItemId(itemId, zsc);
    Comment comment = mbox.createComment(octxt, iid.getId(), text, creator);
    Element response = zsc.createElement(MailConstants.ADD_COMMENT_RESPONSE);
    response.addElement(MailConstants.E_COMMENT).addAttribute(MailConstants.A_ID, comment.getId());
    return response;
}
Also used : OperationContext(com.zimbra.cs.mailbox.OperationContext) Comment(com.zimbra.cs.mailbox.Comment) Mailbox(com.zimbra.cs.mailbox.Mailbox) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) Element(com.zimbra.common.soap.Element) ItemId(com.zimbra.cs.service.util.ItemId)

Example 2 with Comment

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

the class GetComments method handle.

public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    Mailbox mbox = getRequestedMailbox(zsc);
    OperationContext octxt = getOperationContext(zsc, context);
    ItemIdFormatter ifmt = new ItemIdFormatter(zsc);
    Element c = request.getElement(MailConstants.E_COMMENT);
    String itemId = c.getAttribute(MailConstants.A_PARENT_ID);
    ItemId iid = new ItemId(itemId, zsc);
    Element response = zsc.createElement(MailConstants.GET_COMMENTS_RESPONSE);
    HashSet<Account> accounts = new HashSet<Account>();
    for (Comment comment : mbox.getComments(octxt, iid.getId(), 0, -1)) {
        accounts.add(comment.getCreatorAccount());
        ToXML.encodeComment(response, ifmt, octxt, comment);
    }
    for (Account a : accounts) {
        Element user = response.addElement(MailConstants.A_USER);
        user.addAttribute(MailConstants.A_ID, a.getId());
        user.addAttribute(MailConstants.A_EMAIL, a.getName());
        user.addAttribute(MailConstants.A_NAME, a.getDisplayName());
    }
    return response;
}
Also used : OperationContext(com.zimbra.cs.mailbox.OperationContext) Account(com.zimbra.cs.account.Account) Comment(com.zimbra.cs.mailbox.Comment) Mailbox(com.zimbra.cs.mailbox.Mailbox) ItemIdFormatter(com.zimbra.cs.service.util.ItemIdFormatter) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) Element(com.zimbra.common.soap.Element) ItemId(com.zimbra.cs.service.util.ItemId) HashSet(java.util.HashSet)

Aggregations

Element (com.zimbra.common.soap.Element)2 Comment (com.zimbra.cs.mailbox.Comment)2 Mailbox (com.zimbra.cs.mailbox.Mailbox)2 OperationContext (com.zimbra.cs.mailbox.OperationContext)2 ItemId (com.zimbra.cs.service.util.ItemId)2 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)2 Account (com.zimbra.cs.account.Account)1 ItemIdFormatter (com.zimbra.cs.service.util.ItemIdFormatter)1 HashSet (java.util.HashSet)1