Search in sources :

Example 21 with Cos

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();
}
Also used : Cos(com.zimbra.cs.account.Cos) After(org.junit.After)

Example 22 with Cos

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());
}
Also used : Account(com.zimbra.cs.account.Account) HashMap(java.util.HashMap) Cos(com.zimbra.cs.account.Cos) Domain(com.zimbra.cs.account.Domain) DistributionList(com.zimbra.cs.account.DistributionList) Before(org.junit.Before)

Example 23 with Cos

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;
}
Also used : Cos(com.zimbra.cs.account.Cos)

Example 24 with 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());
    }
}
Also used : Cos(com.zimbra.cs.account.Cos) Element(com.zimbra.common.soap.Element)

Example 25 with Cos

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]);
        }
    }
}
Also used : Cos(com.zimbra.cs.account.Cos) Provisioning(com.zimbra.cs.account.Provisioning) SoapProvisioning(com.zimbra.cs.account.soap.SoapProvisioning)

Aggregations

Cos (com.zimbra.cs.account.Cos)97 Provisioning (com.zimbra.cs.account.Provisioning)32 HashMap (java.util.HashMap)26 Account (com.zimbra.cs.account.Account)23 SoapProvisioning (com.zimbra.cs.account.soap.SoapProvisioning)15 ServiceException (com.zimbra.common.service.ServiceException)14 AccountServiceException (com.zimbra.cs.account.AccountServiceException)14 Element (com.zimbra.common.soap.Element)12 Domain (com.zimbra.cs.account.Domain)11 LdapCos (com.zimbra.cs.account.ldap.entry.LdapCos)9 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)8 Test (org.junit.Test)7 AuthFailedServiceException (com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException)6 Config (com.zimbra.cs.account.Config)5 ZAttrProvisioning (com.zimbra.common.account.ZAttrProvisioning)4 Server (com.zimbra.cs.account.Server)4 Zimlet (com.zimbra.cs.account.Zimlet)4 LdapProvisioning (com.zimbra.cs.account.ldap.LdapProvisioning)4 RetentionPolicy (com.zimbra.soap.mail.type.RetentionPolicy)4 GuestAccount (com.zimbra.cs.account.GuestAccount)3