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