use of com.zimbra.soap.mail.type.RetentionPolicy in project zm-mailbox by Zimbra.
the class RetentionPolicyManager method getCompleteRetentionPolicy.
public RetentionPolicy getCompleteRetentionPolicy(Account acct, RetentionPolicy rp) throws ServiceException {
// Check CoS first, if not found get from Config
RetentionPolicy retentionPolicy = RetentionPolicyManager.getInstance().getSystemRetentionPolicy(acct);
retentionPolicy = RetentionPolicyManager.getInstance().getCompleteRetentionPolicy(retentionPolicy, rp);
return retentionPolicy;
}
use of com.zimbra.soap.mail.type.RetentionPolicy in project zm-mailbox by Zimbra.
the class RetentionPolicyManager method getSystemRetentionPolicy.
public RetentionPolicy getSystemRetentionPolicy(Account acct) throws ServiceException {
// Check CoS first, if not found get from Config
RetentionPolicy retentionPolicy = null;
Cos cos = acct.getCOS();
if (cos != null)
retentionPolicy = RetentionPolicyManager.getInstance().getSystemRetentionPolicy(cos);
if (retentionPolicy == null || !retentionPolicy.isSet()) {
Config config = Provisioning.getInstance().getConfig();
retentionPolicy = RetentionPolicyManager.getInstance().getSystemRetentionPolicy(config);
}
return retentionPolicy;
}
use of com.zimbra.soap.mail.type.RetentionPolicy in project zm-mailbox by Zimbra.
the class RetentionPolicyManager method deleteSystemPolicy.
/**
* Deletes the system policy with the given id.
* @return {@code true} if the policy was successfully deleted, {@code false}
* if no policy exists with the given id
*/
public boolean deleteSystemPolicy(Entry entry, String id) throws ServiceException {
synchronized (entry) {
SystemPolicy sp = getCachedSystemPolicy(entry);
Policy p = sp.keep.remove(id);
if (p == null) {
p = sp.purge.remove(id);
}
if (p != null) {
saveSystemPolicy(entry, new RetentionPolicy(sp.keep.values(), sp.purge.values()));
return true;
}
}
return false;
}
use of com.zimbra.soap.mail.type.RetentionPolicy in project zm-mailbox by Zimbra.
the class PurgeTest method invalidFolderMessageLifetime.
@Test
public void invalidFolderMessageLifetime() throws Exception {
Mailbox mbox = MailboxManager.getInstance().getMailboxByAccountId(MockProvisioning.DEFAULT_ACCOUNT_ID);
Folder folder = mbox.createFolder(null, "/invalidFolderMessageLifetime", new Folder.FolderOptions().setDefaultView(MailItem.Type.MESSAGE));
Policy p = Policy.newUserPolicy("45x");
RetentionPolicy purgePolicy = new RetentionPolicy(null, Arrays.asList(p));
try {
mbox.setRetentionPolicy(null, folder.getId(), MailItem.Type.FOLDER, purgePolicy);
fail("Invalid time interval should not have been accepted.");
} catch (ServiceException e) {
}
}
use of com.zimbra.soap.mail.type.RetentionPolicy in project zm-mailbox by Zimbra.
the class PurgeTest method modifyCosSystemPolicy.
@Test
public void modifyCosSystemPolicy() throws Exception {
Map<String, Object> attrs = new HashMap<String, Object>();
Cos cos = Provisioning.getInstance().createCos("testcos", attrs);
RetentionPolicyManager mgr = RetentionPolicyManager.getInstance();
Policy keep1 = mgr.createSystemKeepPolicy(cos, "keep1", "300d");
Policy keep2 = mgr.createSystemKeepPolicy(cos, "keep2", "400d");
Policy purge1 = mgr.createSystemPurgePolicy(cos, "purge1", "500d");
Policy purge2 = mgr.createSystemPurgePolicy(cos, "purge2", "500d");
assertEquals(keep1, mgr.getPolicyById(cos, keep1.getId()));
assertEquals(keep2, mgr.getPolicyById(cos, keep2.getId()));
assertEquals(purge1, mgr.getPolicyById(cos, purge1.getId()));
assertEquals(purge2, mgr.getPolicyById(cos, purge2.getId()));
// Test modify.
mgr.modifySystemPolicy(cos, keep1.getId(), "new keep1", "301d");
Policy newKeep1 = mgr.getPolicyById(cos, keep1.getId());
assertFalse(keep1.equals(newKeep1));
assertEquals(keep1.getId(), newKeep1.getId());
assertEquals("new keep1", newKeep1.getName());
assertEquals("301d", newKeep1.getLifetime());
// Test delete.
assertTrue(mgr.deleteSystemPolicy(cos, purge2.getId()));
assertNull(mgr.getPolicyById(cos, purge2.getId()));
RetentionPolicy rp = mgr.getSystemRetentionPolicy(cos);
assertEquals(2, rp.getKeepPolicy().size());
assertEquals(1, rp.getPurgePolicy().size());
}
Aggregations