Search in sources :

Example 1 with Rectangle

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

the class CreateNote 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 t = request.getElement(MailConstants.E_NOTE);
    ItemId iidFolder = new ItemId(t.getAttribute(MailConstants.A_FOLDER), zsc);
    String content = t.getAttribute(MailConstants.E_CONTENT);
    byte color = (byte) t.getAttributeLong(MailConstants.A_COLOR, MailItem.DEFAULT_COLOR);
    String strBounds = t.getAttribute(MailConstants.A_BOUNDS, null);
    Rectangle bounds = new Rectangle(strBounds);
    Note note = mbox.createNote(octxt, content, bounds, color, iidFolder.getId());
    Element response = zsc.createElement(MailConstants.CREATE_NOTE_RESPONSE);
    if (note != null)
        ToXML.encodeNote(response, ifmt, octxt, note);
    return response;
}
Also used : OperationContext(com.zimbra.cs.mailbox.OperationContext) Mailbox(com.zimbra.cs.mailbox.Mailbox) ItemIdFormatter(com.zimbra.cs.service.util.ItemIdFormatter) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) Element(com.zimbra.common.soap.Element) Note(com.zimbra.cs.mailbox.Note) Rectangle(com.zimbra.cs.mailbox.Note.Rectangle) ItemId(com.zimbra.cs.service.util.ItemId)

Example 2 with Rectangle

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

the class NoteAction method handleNote.

private String handleNote(Map<String, Object> context, Element request, String operation) throws ServiceException {
    Element action = request.getElement(MailConstants.E_ACTION);
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    Mailbox mbox = getRequestedMailbox(zsc);
    OperationContext octxt = getOperationContext(zsc, context);
    ItemId iid = new ItemId(action.getAttribute(MailConstants.A_ID), zsc);
    if (operation.equals(OP_EDIT)) {
        String content = action.getAttribute(MailConstants.E_CONTENT);
        mbox.editNote(octxt, iid.getId(), content);
    } else if (operation.equals(OP_REPOSITION)) {
        String strBounds = action.getAttribute(MailConstants.A_BOUNDS, null);
        mbox.repositionNote(octxt, iid.getId(), new Rectangle(strBounds));
    } else
        throw ServiceException.INVALID_REQUEST("unknown operation: " + operation, null);
    return new ItemIdFormatter(zsc).formatItemId(iid);
}
Also used : OperationContext(com.zimbra.cs.mailbox.OperationContext) Mailbox(com.zimbra.cs.mailbox.Mailbox) ItemIdFormatter(com.zimbra.cs.service.util.ItemIdFormatter) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) Element(com.zimbra.common.soap.Element) Rectangle(com.zimbra.cs.mailbox.Note.Rectangle) ItemId(com.zimbra.cs.service.util.ItemId)

Aggregations

Element (com.zimbra.common.soap.Element)2 Mailbox (com.zimbra.cs.mailbox.Mailbox)2 Rectangle (com.zimbra.cs.mailbox.Note.Rectangle)2 OperationContext (com.zimbra.cs.mailbox.OperationContext)2 ItemId (com.zimbra.cs.service.util.ItemId)2 ItemIdFormatter (com.zimbra.cs.service.util.ItemIdFormatter)2 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)2 Note (com.zimbra.cs.mailbox.Note)1