Search in sources :

Example 6 with SendShareNotificationRequest

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

the class TestShareNotifications method testContactAndCalendarShareNotifications.

public void testContactAndCalendarShareNotifications() throws Exception {
    Account senderAccount = TestUtil.createAccount(SENDER_NAME);
    Account recipientAccount = TestUtil.createAccount(RECIPIENT_NAME);
    ZMailbox mbox = TestUtil.getZMailbox(SENDER_NAME);
    // check that there are no share notifications in the recipient's mailbox
    ZMailbox recipientMbox = TestUtil.getZMailbox(RECIPIENT_NAME);
    List<ShareNotificationInfo> shares = waitForShareNotifications(recipientMbox, 0, 100);
    assertEquals("Recipient should have exactly 0 share notification", 0, shares.size());
    // create and share the first calendar
    ZFolder newCal = TestUtil.createFolder(mbox, CAL_NAME1, ZFolder.View.appointment);
    String calendarId = newCal.getId();
    FolderActionSelector action = new FolderActionSelector(calendarId, "grant");
    ActionGrantSelector grant = new ActionGrantSelector("r", "usr");
    grant.setDisplayName(recipientAccount.getName());
    grant.setPassword("");
    action.setGrant(grant);
    FolderActionRequest folderActionReq = new FolderActionRequest(action);
    FolderActionResponse folderActionResp = mbox.invokeJaxb(folderActionReq);
    assertNotNull("FolderActionResponse is null", folderActionResp);
    SendShareNotificationRequest shareNotificationReq = new SendShareNotificationRequest();
    shareNotificationReq.setItem(new com.zimbra.soap.type.Id(calendarId));
    shareNotificationReq.addEmailAddress(new EmailAddrInfo(recipientAccount.getMail()));
    SendShareNotificationResponse resp = mbox.invokeJaxb(shareNotificationReq);
    assertNotNull("ShareNotificationResponse is null", resp);
    // create and share the second calendar
    ZFolder newContactsFolder = TestUtil.createFolder(mbox, CONTACTS_NAME1, ZFolder.View.contact);
    String contactsFolderId = newContactsFolder.getId();
    action = new FolderActionSelector(contactsFolderId, "grant");
    grant = new ActionGrantSelector("r", "usr");
    grant.setDisplayName(recipientAccount.getName());
    grant.setPassword("");
    action.setGrant(grant);
    folderActionReq = new FolderActionRequest(action);
    folderActionResp = mbox.invokeJaxb(folderActionReq);
    assertNotNull("FolderActionResponse is null", folderActionResp);
    shareNotificationReq = new SendShareNotificationRequest();
    shareNotificationReq.setItem(new com.zimbra.soap.type.Id(contactsFolderId));
    shareNotificationReq.addEmailAddress(new EmailAddrInfo(recipientAccount.getMail()));
    resp = mbox.invokeJaxb(shareNotificationReq);
    assertNotNull("ShareNotificationResponse is null", resp);
    shares = waitForShareNotifications(recipientMbox, 2, 1000);
    assertEquals("should have exactly two share notification", 2, shares.size());
    assertNotNull("share grantor is null", shares.get(0).getGrantor());
    assertTrue("share grantor is not " + senderAccount.getMail(), senderAccount.getMail().equalsIgnoreCase(shares.get(0).getGrantor().getEmail()));
}
Also used : Account(com.zimbra.cs.account.Account) FolderActionResponse(com.zimbra.soap.mail.message.FolderActionResponse) SendShareNotificationResponse(com.zimbra.soap.mail.message.SendShareNotificationResponse) ActionGrantSelector(com.zimbra.soap.mail.type.ActionGrantSelector) FolderActionSelector(com.zimbra.soap.mail.type.FolderActionSelector) ZMailbox(com.zimbra.client.ZMailbox) ShareNotificationInfo(com.zimbra.soap.mail.type.ShareNotificationInfo) FolderActionRequest(com.zimbra.soap.mail.message.FolderActionRequest) EmailAddrInfo(com.zimbra.soap.mail.type.EmailAddrInfo) ZFolder(com.zimbra.client.ZFolder) SendShareNotificationRequest(com.zimbra.soap.mail.message.SendShareNotificationRequest)

Example 7 with SendShareNotificationRequest

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

the class ExpireGrantsTask method sendGrantExpiryNotification.

private static void sendGrantExpiryNotification(ZMailbox zMbox, int itemId, String address) throws ServiceException {
    SendShareNotificationRequest req = new SendShareNotificationRequest();
    req.setEmailAddresses(Sets.newHashSet(new EmailAddrInfo(address)));
    req.setAction(SendShareNotificationRequest.Action.expire);
    req.setItem(new Id(Integer.toString(itemId)));
    zMbox.invokeJaxb(req);
}
Also used : EmailAddrInfo(com.zimbra.soap.mail.type.EmailAddrInfo) SendShareNotificationRequest(com.zimbra.soap.mail.message.SendShareNotificationRequest) Id(com.zimbra.soap.type.Id)

Aggregations

SendShareNotificationRequest (com.zimbra.soap.mail.message.SendShareNotificationRequest)7 EmailAddrInfo (com.zimbra.soap.mail.type.EmailAddrInfo)7 Account (com.zimbra.cs.account.Account)6 ZMailbox (com.zimbra.client.ZMailbox)5 ZFolder (com.zimbra.client.ZFolder)4 FolderActionRequest (com.zimbra.soap.mail.message.FolderActionRequest)4 FolderActionResponse (com.zimbra.soap.mail.message.FolderActionResponse)4 SendShareNotificationResponse (com.zimbra.soap.mail.message.SendShareNotificationResponse)4 ActionGrantSelector (com.zimbra.soap.mail.type.ActionGrantSelector)4 FolderActionSelector (com.zimbra.soap.mail.type.FolderActionSelector)4 ShareNotificationInfo (com.zimbra.soap.mail.type.ShareNotificationInfo)4 ServiceException (com.zimbra.common.service.ServiceException)2 Element (com.zimbra.common.soap.Element)1 Domain (com.zimbra.cs.account.Domain)1 Group (com.zimbra.cs.account.Group)1 MailTarget (com.zimbra.cs.account.MailTarget)1 NamedEntry (com.zimbra.cs.account.NamedEntry)1 Provisioning (com.zimbra.cs.account.Provisioning)1 ShareInfoData (com.zimbra.cs.account.ShareInfoData)1 MailItem (com.zimbra.cs.mailbox.MailItem)1