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;
}
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;
}
Aggregations