Search in sources :

Example 91 with DistributionList

use of com.zimbra.cs.account.DistributionList in project zm-mailbox by Zimbra.

the class TestLdapProvRenameDomain method verifyMemberOf.

private void verifyMemberOf(int memberType, int dlTypes, int domainIdx) throws Exception {
    for (int i = 0; i < NUM_OBJS(memberType); i++) {
        String name = OBJ_NAME(memberType, i, domainIdx);
        NamedEntry entry = getEntryByName(memberType, name);
        assertNotNull(entry);
        Set<String> expectedNames = new HashSet<String>();
        for (int d = 0; d < NUM_DOMAINS; d++) {
            int dIdx = DOMAIN_INDEX_AFTER_RENAME(d);
            if ((dlTypes & OBJ_DL_NESTED) != 0) {
                for (int dlIdx = 0; dlIdx < NUM_DLS_NESTED; dlIdx++) expectedNames.add(new Names.IDNName(NESTED_DL_NAME(dlIdx, dIdx)).aName());
            }
            if ((dlTypes & OBJ_DL_TOP) != 0) {
                for (int dlIdx = 0; dlIdx < NUM_DLS_TOP; dlIdx++) expectedNames.add(new Names.IDNName(TOP_DL_NAME(dlIdx, dIdx)).aName());
            }
        // todo: DYNAMIC GROUP
        }
        HashMap<String, String> via = new HashMap<String, String>();
        List lists;
        if (memberType == OBJ_ACCT) {
            lists = prov.getDistributionLists((Account) entry, false, via);
        } else {
            lists = prov.getDistributionLists((DistributionList) entry, false, via);
        }
        Set<String> actualNames = namedEntryListToNameSet(lists, UnicodeOrACE.ACE);
        // dumpStrings(expectedNames);
        // dumpStrings(actualNames);
        Verify.verifyEquals(expectedNames, actualNames);
    }
}
Also used : Names(com.zimbra.qa.unittest.prov.Names) NamedEntry(com.zimbra.cs.account.NamedEntry) Account(com.zimbra.cs.account.Account) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) DistributionList(com.zimbra.cs.account.DistributionList) List(java.util.List) HashSet(java.util.HashSet) DistributionList(com.zimbra.cs.account.DistributionList)

Example 92 with DistributionList

use of com.zimbra.cs.account.DistributionList in project zm-mailbox by Zimbra.

the class TestLdapProvRenameDomain method verifyHasMembers.

private void verifyHasMembers(int dlType, int memberTypes, int domainIdx) throws Exception {
    for (int dlIdx = 0; dlIdx < NUM_OBJS(dlType); dlIdx++) {
        String name = OBJ_NAME(dlType, dlIdx, domainIdx);
        DistributionList dl = prov.get(Key.DistributionListBy.name, name);
        assertNotNull(dl);
        Set<String> expectedNames = new HashSet<String>();
        for (int d = 0; d < NUM_DOMAINS; d++) {
            int dIdx = DOMAIN_INDEX_AFTER_RENAME(d);
            if ((memberTypes & OBJ_ACCT) != 0) {
                for (int i = 0; i < NUM_ACCOUNTS; i++) {
                    Set<String> names = ACCOUNT_NAMES(i, dIdx, true);
                    for (String n : names) {
                        expectedNames.add(new Names.IDNName(n).uName());
                    }
                }
            }
            if ((memberTypes & OBJ_DL_NESTED) != 0) {
                for (int i = 0; i < NUM_DLS_NESTED; i++) {
                    Set<String> names = NESTED_DL_NAMES(i, dIdx, true);
                    for (String n : names) {
                        expectedNames.add(new Names.IDNName(n).uName());
                    }
                }
            }
            if ((memberTypes & OBJ_DL_TOP) != 0) {
                for (int i = 0; i < NUM_DLS_TOP; i++) {
                    Set<String> names = TOP_DL_NAMES(i, dIdx, true);
                    for (String n : names) {
                        expectedNames.add(new Names.IDNName(n).uName());
                    }
                }
            }
        // TODO: DYNAMIC GROUP
        }
        // if we are verifying using SoapProvisioning, members contains unicode addrs,
        // because they are converted in SOAP handlers.
        // if we are verifying using LdapProvisioning, members contains ACE addrs, which 
        // are values stored in LDAP.  convert them to unicode for verifying.
        String[] members = dl.getAllMembers();
        Set<String> actualNames = new HashSet<String>(Arrays.asList(members));
        if (prov instanceof LdapProvisioning) {
            Set<String> actualNamesUnicode = Sets.newHashSet();
            for (String addr : actualNames) {
                String addrUnicode = IDNUtil.toUnicode(addr);
                actualNamesUnicode.add(addrUnicode);
            }
            actualNames = actualNamesUnicode;
        }
        // dumpStrings("expectedNames", expectedNames);
        // dumpStrings("actualNames", actualNames);
        Verify.verifyEquals(expectedNames, actualNames);
    }
}
Also used : LdapProvisioning(com.zimbra.cs.account.ldap.LdapProvisioning) DistributionList(com.zimbra.cs.account.DistributionList) HashSet(java.util.HashSet)

Example 93 with DistributionList

use of com.zimbra.cs.account.DistributionList in project zm-mailbox by Zimbra.

the class SoapProvisioning method getDistributionLists.

@Override
public List<DistributionList> getDistributionLists(Account acct, boolean directOnly, Map<String, String> via) throws ServiceException {
    ArrayList<DistributionList> result = new ArrayList<DistributionList>();
    GetAccountMembershipResponse resp = invokeJaxb(new GetAccountMembershipRequest(getSelector(acct)));
    for (DLInfo dlInfo : resp.getDlList()) {
        String viaList = dlInfo.getVia();
        if (directOnly && viaList != null)
            continue;
        DistributionList dl = new SoapDistributionList(dlInfo, this);
        if (via != null && viaList != null)
            via.put(dl.getName(), viaList);
        result.add(dl);
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) DLInfo(com.zimbra.soap.admin.type.DLInfo) DistributionList(com.zimbra.cs.account.DistributionList)

Example 94 with DistributionList

use of com.zimbra.cs.account.DistributionList in project zm-mailbox by Zimbra.

the class SoapProvisioning method getAllDistributionLists.

@Override
public List<DistributionList> getAllDistributionLists(Domain d) throws ServiceException {
    ArrayList<DistributionList> result = new ArrayList<DistributionList>();
    GetAllDistributionListsResponse resp = invokeJaxb(new GetAllDistributionListsRequest(getSelector(d)));
    for (DistributionListInfo dl : resp.getDls()) {
        result.add(new SoapDistributionList(dl, this));
    }
    return result;
}
Also used : DistributionListInfo(com.zimbra.soap.admin.type.DistributionListInfo) ArrayList(java.util.ArrayList) DistributionList(com.zimbra.cs.account.DistributionList)

Example 95 with DistributionList

use of com.zimbra.cs.account.DistributionList in project zm-mailbox by Zimbra.

the class SoapProvisioning method getDistributionLists.

@Override
public List<DistributionList> getDistributionLists(DistributionList list, boolean directOnly, Map<String, String> via) throws ServiceException {
    ArrayList<DistributionList> result = new ArrayList<DistributionList>();
    GetDistributionListMembershipRequest req = new GetDistributionListMembershipRequest(getSelector(list), null, null);
    GetDistributionListMembershipResponse resp = invokeJaxb(req);
    for (DistributionListMembershipInfo dlMemInfo : resp.getDls()) {
        String viaList = dlMemInfo.getVia();
        if (directOnly && viaList != null)
            continue;
        DistributionList dl = new SoapDistributionList(dlMemInfo, this);
        if (via != null && viaList != null) {
            via.put(dl.getName(), viaList);
        }
        result.add(dl);
    }
    return result;
}
Also used : DistributionListMembershipInfo(com.zimbra.soap.admin.type.DistributionListMembershipInfo) ArrayList(java.util.ArrayList) DistributionList(com.zimbra.cs.account.DistributionList)

Aggregations

DistributionList (com.zimbra.cs.account.DistributionList)120 Account (com.zimbra.cs.account.Account)58 Domain (com.zimbra.cs.account.Domain)43 HashMap (java.util.HashMap)24 Test (org.junit.Test)24 Provisioning (com.zimbra.cs.account.Provisioning)22 NamedEntry (com.zimbra.cs.account.NamedEntry)18 HashSet (java.util.HashSet)18 ArrayList (java.util.ArrayList)14 ServiceException (com.zimbra.common.service.ServiceException)13 AccountServiceException (com.zimbra.cs.account.AccountServiceException)13 Right (com.zimbra.cs.account.accesscontrol.Right)12 DynamicGroup (com.zimbra.cs.account.DynamicGroup)10 LdapDistributionList (com.zimbra.cs.account.ldap.entry.LdapDistributionList)10 Group (com.zimbra.cs.account.Group)9 GuestAccount (com.zimbra.cs.account.GuestAccount)9 LdapProv (com.zimbra.cs.account.ldap.LdapProv)8 List (java.util.List)7 Entry (com.zimbra.cs.account.Entry)6 LdapEntry (com.zimbra.cs.account.ldap.entry.LdapEntry)6