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);
}
}
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);
}
}
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;
}
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;
}
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;
}
Aggregations