use of com.zimbra.cs.account.Cos in project zm-mailbox by Zimbra.
the class TestDataSource method tearDown.
@After
public void tearDown() throws Exception {
TestUtil.deleteTestData(USER_NAME, NAME_PREFIX);
// Reset original polling intervals.
Cos cos = account.getCOS();
account.setDataSourcePollingInterval(mOriginalAccountPollingInterval);
account.setDataSourcePop3PollingInterval(mOriginalAccountPop3PollingInterval);
account.setDataSourceImapPollingInterval(mOriginalAccountImapPollingInterval);
cos.setDataSourcePollingInterval(mOriginalCosPollingInterval);
cos.setDataSourcePop3PollingInterval(mOriginalCosPop3PollingInterval);
cos.setDataSourceImapPollingInterval(mOriginalCosImapPollingInterval);
cleanUp();
}
use of com.zimbra.cs.account.Cos in project zm-mailbox by Zimbra.
the class TestCountObjects method setUp.
@Override
@Before
public void setUp() throws Exception {
// create domain
Map<String, Object> attrs = new HashMap<String, Object>();
Domain domain = mProv.createDomain(DOMAIN_NAME, attrs);
assertNotNull(domain);
testDomainIDs.add(domain.getId());
// create some accounts
for (int i = 0; i < 10; i++) {
Map<String, Object> acctAttrs = new HashMap<String, Object>();
Account acct = mProv.createAccount("count-test-acc" + i + "@" + DOMAIN_NAME, PASSWORD, acctAttrs);
assertNotNull(acct);
testAccountIDs.add(acct.getId());
mProv.addAlias(acct, "count-test-alias" + i + "@" + DOMAIN_NAME);
}
// create some DLs
for (int i = 0; i < 10; i++) {
Map<String, Object> acctAttrs = new HashMap<String, Object>();
DistributionList dl = mProv.createDistributionList("count-test-DL" + i + "@" + DOMAIN_NAME, acctAttrs);
assertNotNull(dl);
testDLIDs.add(dl.getId());
}
// create some COSes
for (int i = 0; i < 10; i++) {
Map<String, Object> cosAttrs = new HashMap<String, Object>();
Cos cos = mProv.createCos("count-test-cos" + i + "-" + DOMAIN_NAME, cosAttrs);
assertNotNull(cos);
testCOSIDs.add(cos.getId());
}
// create domain admin account
DOMAIN_ADMIN_USER_EMAIL = DOMAIN_ADMIN_USER + "@" + DOMAIN_NAME;
attrs = new HashMap<String, Object>();
attrs.put(Provisioning.A_zimbraIsDelegatedAdminAccount, ProvisioningConstants.TRUE);
Account acct = mProv.createAccount(DOMAIN_ADMIN_USER_EMAIL, PASSWORD, attrs);
assertNotNull(acct);
mProv.grantRight(TargetType.domain.getCode(), TargetBy.name, DOMAIN_NAME, com.zimbra.cs.account.accesscontrol.GranteeType.GT_USER.getCode(), GranteeBy.name, DOMAIN_ADMIN_USER_EMAIL, null, RightConsts.RT_domainAdminRights, null);
testAccountIDs.add(acct.getId());
// create delegated admin account that does not have a permission to
// count accounts, but has permission to count distribution lists
ROGUE_ADMIN_USER_EMAIL = ROGUE_ADMIN_USER + "@" + DOMAIN_NAME;
attrs = new HashMap<String, Object>();
attrs.put(Provisioning.A_zimbraIsDelegatedAdminAccount, ProvisioningConstants.TRUE);
acct = mProv.createAccount(ROGUE_ADMIN_USER_EMAIL, PASSWORD, attrs);
assertNotNull(acct);
mProv.grantRight(TargetType.domain.getCode(), TargetBy.name, DOMAIN_NAME, com.zimbra.cs.account.accesscontrol.GranteeType.GT_USER.getCode(), GranteeBy.name, ROGUE_ADMIN_USER_EMAIL, null, RightConsts.RT_countDistributionList, null);
testAccountIDs.add(acct.getId());
}
use of com.zimbra.cs.account.Cos in project zm-mailbox by Zimbra.
the class ProvTestUtil method createCos.
public Cos createCos(String cosName, Map<String, Object> attrs) throws Exception {
Cos cos = prov.get(Key.CosBy.name, cosName);
assertNull(cos);
if (attrs == null) {
attrs = new HashMap<String, Object>();
}
cos = prov.createCos(cosName, attrs);
assertNotNull(cos);
flushCache(CacheEntryType.cos, CacheEntryBy.id, cos.getId());
cos = prov.get(Key.CosBy.name, cosName);
assertNotNull(cos);
assertEquals(cosName.toLowerCase(), cos.getName().toLowerCase());
createdEntries.add(cos);
return cos;
}
use of com.zimbra.cs.account.Cos in project zm-mailbox by Zimbra.
the class GetInfo method doCos.
static void doCos(Account acct, Element response) throws ServiceException {
Cos cos = Provisioning.getInstance().getCOS(acct);
if (cos != null) {
Element eCos = response.addUniqueElement(AccountConstants.E_COS);
eCos.addAttribute(AccountConstants.A_ID, cos.getId());
eCos.addAttribute(AccountConstants.A_NAME, cos.getName());
}
}
use of com.zimbra.cs.account.Cos in project zm-mailbox by Zimbra.
the class ZimletUtil method listZimletsInCos.
/**
*
* Print the Zimlet COS ACL for all the Zimlets.
*
* @throws ZimletException
*/
public static void listZimletsInCos() throws ServiceException, ZimletException {
Provisioning prov = Provisioning.getInstance();
for (Cos cos : prov.getAllCos()) {
System.out.println(" " + cos.getName() + ":");
String[] zimlets = getAvailableZimlets(cos).getZimletNamesAsArray();
Arrays.sort(zimlets);
for (int i = 0; i < zimlets.length; i++) {
System.out.println("\t" + zimlets[i]);
}
}
}
Aggregations