use of com.zimbra.soap.mail.message.FolderActionResponse in project zm-mailbox by Zimbra.
the class TestPurge method testFolderRetentionPolicy.
/**
* Tests the SOAP API for setting retention policy on a folder.
*/
@Test
public void testFolderRetentionPolicy() throws Exception {
ZMailbox mbox = TestUtil.getZMailbox(USER_NAME);
ZFolder folder = TestUtil.createFolder(mbox, "/" + NAME_PREFIX + "-testFolderRetentionPolicy");
// Set user keep policy for folder.
FolderActionSelector action = new FolderActionSelector(folder.getId(), "retentionpolicy");
RetentionPolicy rp = new RetentionPolicy(Arrays.asList(Policy.newUserPolicy("30d")), null);
action.setRetentionPolicy(rp);
FolderActionRequest req = new FolderActionRequest(action);
FolderActionResponse res = mbox.invokeJaxb(req);
Assert.assertEquals("retentionpolicy", res.getAction().getOperation());
Assert.assertEquals(folder.getId(), res.getAction().getId());
// Make sure that the retention policy is now set.
folder = mbox.getFolderById(folder.getId());
rp = folder.getRetentionPolicy();
Assert.assertEquals(1, rp.getKeepPolicy().size());
Assert.assertEquals(0, rp.getPurgePolicy().size());
Policy p = rp.getKeepPolicy().get(0);
Assert.assertEquals(Policy.Type.USER, p.getType());
Assert.assertEquals("30d", p.getLifetime());
// Turn off keep policy and set purge policy.
action = new FolderActionSelector(folder.getId(), "retentionpolicy");
rp = new RetentionPolicy(null, Arrays.asList(Policy.newUserPolicy("45d")));
action.setRetentionPolicy(rp);
req = new FolderActionRequest(action);
res = mbox.invokeJaxb(req);
Assert.assertEquals("retentionpolicy", res.getAction().getOperation());
Assert.assertEquals(folder.getId(), res.getAction().getId());
// Make sure that the retention policy is now set.
folder = mbox.getFolderById(folder.getId());
rp = folder.getRetentionPolicy();
Assert.assertEquals(0, rp.getKeepPolicy().size());
Assert.assertEquals(1, rp.getPurgePolicy().size());
p = rp.getPurgePolicy().get(0);
Assert.assertEquals(Policy.Type.USER, p.getType());
Assert.assertEquals("45d", p.getLifetime());
// Start a new session and make sure that the retention policy is still returned.
mbox = TestUtil.getZMailbox(USER_NAME);
folder = mbox.getFolderById(folder.getId());
Assert.assertTrue(folder.getRetentionPolicy().isSet());
}
use of com.zimbra.soap.mail.message.FolderActionResponse in project zm-mailbox by Zimbra.
the class TestJaxbProvisioning method grantAccess.
public void grantAccess(Account acct, String id, String granteeType, String granteeName, String perm) {
FolderActionSelector selector = new FolderActionSelector(id, "grant");
ActionGrantSelector grant = new ActionGrantSelector(perm, granteeType);
grant.setDisplayName(granteeName);
selector.setGrant(grant);
FolderActionRequest req = new FolderActionRequest(selector);
try {
FolderActionResponse resp = prov.invokeJaxbOnTargetAccount(req, acct.getId());
Assert.assertNotNull(String.format("FolderActionResponse for account %s", acct.getName()), resp);
} catch (ServiceException e) {
Assert.fail("Unexpected exception while granting access " + e);
}
}
use of com.zimbra.soap.mail.message.FolderActionResponse in project zm-mailbox by Zimbra.
the class TestShareNotifications method testMultipleCalendarShareNotifications.
public void testMultipleCalendarShareNotifications() 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 newCal2 = TestUtil.createFolder(mbox, CAL_NAME2, ZFolder.View.appointment);
String calendarId2 = newCal2.getId();
action = new FolderActionSelector(calendarId2, "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(calendarId2));
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()));
}
use of com.zimbra.soap.mail.message.FolderActionResponse in project zm-mailbox by Zimbra.
the class TestShareNotifications method testCalendarShareNotification.
public void testCalendarShareNotification() 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());
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);
shares = waitForShareNotifications(recipientMbox, 1, 1000);
assertTrue("should have exactly one share notification", shares.size() == 1);
assertNotNull("share grantor is null", shares.get(0).getGrantor());
assertTrue("share grantor is not " + senderAccount.getMail(), senderAccount.getMail().equalsIgnoreCase(shares.get(0).getGrantor().getEmail()));
}
use of com.zimbra.soap.mail.message.FolderActionResponse in project zm-mailbox by Zimbra.
the class TestShareNotifications method testContactShareNotification.
public void testContactShareNotification() 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 newContactsFolder = TestUtil.createFolder(mbox, CAL_NAME1, ZFolder.View.contact);
String contactsFolderId = newContactsFolder.getId();
FolderActionSelector action = new FolderActionSelector(contactsFolderId, "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(contactsFolderId));
shareNotificationReq.addEmailAddress(new EmailAddrInfo(recipientAccount.getMail()));
SendShareNotificationResponse resp = mbox.invokeJaxb(shareNotificationReq);
assertNotNull("ShareNotificationResponse is null", resp);
shares = waitForShareNotifications(recipientMbox, 1, 1000);
assertEquals("should have exactly one share notification", 1, 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()));
}
Aggregations