use of com.zimbra.cs.account.DistributionList in project zm-mailbox by Zimbra.
the class LdapProvisioning method renameAddressesInAllDistributionLists.
protected void renameAddressesInAllDistributionLists(Map<String, String> changedPairs) {
String[] oldAddrs = changedPairs.keySet().toArray(new String[0]);
String[] newAddrs = changedPairs.values().toArray(new String[0]);
List<DistributionList> lists = null;
Map<String, String[]> attrs = null;
try {
lists = getAllDistributionListsForAddresses(oldAddrs, false);
} catch (ServiceException se) {
ZimbraLog.account.warn("unable to rename addr " + oldAddrs.toString() + " in all DLs ", se);
return;
}
for (DistributionList list : lists) {
// removeMember/addMember might have to update an entry's zimbraMemberId twice
if (attrs == null) {
attrs = new HashMap<String, String[]>();
attrs.put("-" + Provisioning.A_zimbraMailForwardingAddress, oldAddrs);
attrs.put("+" + Provisioning.A_zimbraMailForwardingAddress, newAddrs);
}
try {
modifyAttrs(list, attrs);
//list.removeMember(oldName)
//list.addMember(newName);
} catch (ServiceException se) {
// log warning an continue
ZimbraLog.account.warn("unable to rename " + oldAddrs.toString() + " to " + newAddrs.toString() + " in DL " + list.getName(), se);
}
}
}
use of com.zimbra.cs.account.DistributionList in project zm-mailbox by Zimbra.
the class SoapProvisioning method getDistributionLists.
private Set<String> getDistributionLists(Account acct, boolean directOnly) throws ServiceException {
Set<String> dls = new HashSet<String>();
List<DistributionList> lists = getDistributionLists(acct, directOnly, null);
for (DistributionList dl : lists) {
dls.add(dl.getId());
}
dls = Collections.unmodifiableSet(dls);
return dls;
}
use of com.zimbra.cs.account.DistributionList in project zm-mailbox by Zimbra.
the class TestGroups method setUp.
@Override
public void setUp() throws Exception {
ldapProv = (LdapProvisioning) Provisioning.getInstance();
if (soapProv == null) {
soapProv = TestUtil.newSoapProvisioning();
}
tearDown();
domain = createDomain(domainName);
domain1 = createDomain(domainName1);
domain2 = createDomain(domainName2);
for (int cnt = 1; cnt <= NUM_COS; cnt++) {
createCos(String.format(cosPatt, cnt));
}
groups.clear();
for (int cnt = 1; cnt <= NUM_CUSTOM_DL; cnt++) {
TestUtil.deleteAccount(String.format(customDLPatt, cnt));
Group grp = createCustomDynamicGroupWhoseMembersShareCOS(String.format(customDLPatt, cnt), String.format(cosPatt, cnt));
groups.put(grp.getId(), grp);
}
List<String> staticMembers = Lists.newArrayList();
List<String> dynamicMembers = Lists.newArrayList();
for (int cnt = 1; cnt <= NUM_ACCOUNTS; cnt++) {
int cosChoice = cnt % NUM_COS + 1;
createAccountAsMemberOfCOS(String.format(acctPatt, cnt), String.format(cosPatt, cosChoice));
if (cnt % 2 == 0) {
staticMembers.add(String.format(acctPatt, cnt));
}
if (cnt % 3 == 0) {
dynamicMembers.add(String.format(acctPatt, cnt));
}
}
createAccountWithAlias(acctWithAlias, acctAlias);
createAccountWithAlias(acctWithAlias2, acctAlias2);
staticMembers.add(acctAlias);
DistributionList dlalias = createDistributionList(dlWithAlias);
dlalias.addAlias(dlAlias);
DistributionList dlalias2 = createDistributionList(dlWithAlias2);
dlalias2.addAlias(dlAlias2);
String[] aliasmems = { dlAlias2 };
dlalias.addMembers(aliasmems);
String[] aliasmems2 = { acctAlias, acctAlias2 };
dlalias2.addMembers(aliasmems2);
for (int cnt = 1; cnt <= NUM_NORMAL_DL; cnt++) {
DistributionList dl = createDistributionList(String.format(normalDLPatt, cnt));
groups.put(dl.getId(), dl);
dl.addMembers(staticMembers.toArray(new String[staticMembers.size()]));
for (String mem : staticMembers) {
ZimbraLog.test.info("SETUP Distribution List %s has member acct=%s", dl.getName(), mem);
}
}
for (int cnt = 1; cnt <= NUM_DYNAMIC_DL; cnt++) {
Group grp = createDynamicGroup(String.format(dynamicDLPatt, cnt));
groups.put(grp.getId(), grp);
ldapProv.addGroupMembers(grp, dynamicMembers.toArray(new String[dynamicMembers.size()]));
for (String mem : dynamicMembers) {
ZimbraLog.test.info("SETUP Dynamic Group %s has member acct=%s", grp.getName(), mem);
}
}
String groupName = String.format(customDLPatt, 1);
// account4 should match this
// account2 should NOT match this
// account3 should NOT match this
ldapProv.grantRight("domain", /* targetType */
TargetBy.name, /* targetBy */
domain.getName(), /* target */
"grp", /* granteeType */
GranteeSelector.GranteeBy.name, /* granteeBy */
groupName, /* grantee */
null, /* secret */
RightConsts.RT_createDistList, /* right */
null);
ZimbraLog.test.info("SETUP Granted %s to Group %s for dom=%s", RightConsts.RT_createDistList, groupName, domain.getName());
// account4 should match this
// account2 should match this
// account3 should NOT match this
groupName = String.format(normalDLPatt, 1);
ldapProv.grantRight("domain", /* targetType */
TargetBy.name, /* targetBy */
domain1.getName(), /* target */
"grp", /* granteeType */
GranteeSelector.GranteeBy.name, /* granteeBy */
groupName, /* grantee */
null, /* secret */
RightConsts.RT_createDistList, /* right */
null);
ZimbraLog.test.info("SETUP Granted %s to Group %s for dom=%s", RightConsts.RT_createDistList, groupName, domain.getName());
ldapProv.grantRight("domain", /* targetType */
TargetBy.name, /* targetBy */
domain.getName(), /* target */
"grp", /* granteeType */
GranteeSelector.GranteeBy.name, /* granteeBy */
groupName, /* grantee */
null, /* secret */
RightConsts.RT_sendToDistList, /* right */
null);
ZimbraLog.test.info("SETUP Granted %s to Group %s for dom=%s", RightConsts.RT_sendToDistList, groupName, domain.getName());
// account4 should NOT match this
// account2 should NOT match this
// account3 should match this
groupName = String.format(dynamicDLPatt, 1);
ldapProv.grantRight("domain", /* targetType */
TargetBy.name, /* targetBy */
domain2.getName(), /* target */
"grp", /* granteeType */
GranteeSelector.GranteeBy.name, /* granteeBy */
groupName, /* grantee */
null, /* secret */
RightConsts.RT_createDistList, /* right */
null);
ZimbraLog.test.info("SETUP Granted %s to Group %s for dom=%s", RightConsts.RT_createDistList, groupName, domain.getName());
// account4 should NOT match this
// account2 should NOT match this
// account3 should match this
groupName = String.format(dynamicDLPatt, 2);
ldapProv.grantRight("domain", /* targetType */
TargetBy.name, /* targetBy */
domain2.getName(), /* target */
"grp", /* granteeType */
GranteeSelector.GranteeBy.name, /* granteeBy */
groupName, /* grantee */
null, /* secret */
RightConsts.RT_sendToDistList, /* right */
null);
ZimbraLog.test.info("SETUP Granted %s to Group %s for dom=%s", RightConsts.RT_sendToDistList, groupName, domain.getName());
}
use of com.zimbra.cs.account.DistributionList in project zm-mailbox by Zimbra.
the class TestGalGroupMembers method cleanupZimbraDomain.
private static void cleanupZimbraDomain() throws Exception {
Provisioning prov = Provisioning.getInstance();
GalTestUtil.disableGalSyncAccount(prov, ZIMBRA_DOMAIN);
// delete the test user
String userAddr = TestUtil.getAddress(USER, ZIMBRA_DOMAIN);
Account userAcct = prov.get(AccountBy.name, userAddr);
if (prov.get(AccountBy.name, userAddr) != null) {
prov.deleteAccount(userAcct.getId());
}
for (ZimbraGroupMembers member : ZimbraGroupMembers.values()) {
if (member.isZimbraAccount()) {
String addr = member.getAddress();
Account acct = prov.get(AccountBy.name, addr);
if (acct != null) {
prov.deleteAccount(acct.getId());
}
}
}
String groupAddr = TestUtil.getAddress(ZIMBRA_GROUP, ZIMBRA_DOMAIN);
DistributionList group = prov.get(Key.DistributionListBy.name, groupAddr);
if (group != null) {
prov.deleteDistributionList(group.getId());
}
Domain domain = prov.get(Key.DomainBy.name, ZIMBRA_DOMAIN);
if (domain != null) {
ZimbraLog.test.info("Deleting domain " + ZIMBRA_DOMAIN);
prov.deleteDomain(domain.getId());
}
}
use of com.zimbra.cs.account.DistributionList in project zm-mailbox by Zimbra.
the class TestGalGroupMembers method cleanupExternalDomain.
private static void cleanupExternalDomain() throws Exception {
Provisioning prov = Provisioning.getInstance();
String groupAddr = TestUtil.getAddress(EXTERNAL_GROUP, EXTERNAL_DOMAIN);
DistributionList group = prov.get(Key.DistributionListBy.name, groupAddr);
if (group != null) {
prov.deleteDistributionList(group.getId());
}
Domain domain = prov.get(Key.DomainBy.name, EXTERNAL_DOMAIN);
if (domain != null) {
ZimbraLog.test.info("Deleting domain " + EXTERNAL_DOMAIN);
prov.deleteDomain(domain.getId());
}
}
Aggregations