Search in sources :

Example 1 with Action

use of com.zimbra.soap.mail.message.SendShareNotificationRequest.Action in project zm-mailbox by Zimbra.

the class SendShareNotification method handle.

@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    OperationContext octxt = getOperationContext(zsc, context);
    Account account = getRequestedAccount(zsc);
    Mailbox mbox = MailboxManager.getInstance().getMailboxByAccount(account, false);
    // validate the share specified in the request and build a share info if all is valid
    Collection<ShareInfoData> shareInfos = validateRequest(zsc, context, octxt, mbox, request);
    // grab notes if there is one
    Element eNotes = request.getOptionalElement(MailConstants.E_NOTES);
    Action action = Action.fromString(request.getAttribute(MailConstants.A_ACTION, null));
    String notes = eNotes == null ? null : eNotes.getText();
    // send the messages
    try {
        Account authAccount = getAuthenticatedAccount(zsc);
        Collection<ShareInfoData> sharesWithGroupGrantee = Lists.newArrayList();
        for (ShareInfoData sid : shareInfos) {
            // set aside shares to groups
            if (ACL.GRANTEE_GROUP == sid.getGranteeTypeCode()) {
                sharesWithGroupGrantee.add(sid);
            } else {
                sendNotificationEmail(octxt, mbox, authAccount, account, sid, notes, action, null, null);
            }
        }
        // send to group grantees
        sendNotificationEmailToGroupGrantees(octxt, mbox, authAccount, account, sharesWithGroupGrantee, notes, action);
    } catch (MessagingException e) {
        throw ServiceException.FAILURE("Messaging Exception while sending share notification message", e);
    }
    return zsc.createElement(MailConstants.SEND_SHARE_NOTIFICATION_RESPONSE);
}
Also used : OperationContext(com.zimbra.cs.mailbox.OperationContext) Account(com.zimbra.cs.account.Account) Action(com.zimbra.soap.mail.message.SendShareNotificationRequest.Action) Mailbox(com.zimbra.cs.mailbox.Mailbox) MessagingException(javax.mail.MessagingException) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) ShareInfoData(com.zimbra.cs.account.ShareInfoData) Element(com.zimbra.common.soap.Element)

Aggregations

Element (com.zimbra.common.soap.Element)1 Account (com.zimbra.cs.account.Account)1 ShareInfoData (com.zimbra.cs.account.ShareInfoData)1 Mailbox (com.zimbra.cs.mailbox.Mailbox)1 OperationContext (com.zimbra.cs.mailbox.OperationContext)1 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)1 Action (com.zimbra.soap.mail.message.SendShareNotificationRequest.Action)1 MessagingException (javax.mail.MessagingException)1