use of com.zimbra.cs.account.DistributionList in project zm-mailbox by Zimbra.
the class CollectAllEffectiveRights method setupShapeTest2.
private static void setupShapeTest2() throws ServiceException {
Provisioning prov = Provisioning.getInstance();
// create test
String domainName = "test.com";
Domain domain = prov.createDomain(domainName, new HashMap<String, Object>());
DistributionList groupA = prov.createDistributionList("groupA@" + domainName, new HashMap<String, Object>());
DistributionList groupB = prov.createDistributionList("groupB@" + domainName, new HashMap<String, Object>());
DistributionList groupC = prov.createDistributionList("groupC@" + domainName, new HashMap<String, Object>());
DistributionList groupD = prov.createDistributionList("groupD@" + domainName, new HashMap<String, Object>());
String pw = "test123";
Account A = prov.createAccount("A@" + domainName, pw, null);
Account B = prov.createAccount("B@" + domainName, pw, null);
Account C = prov.createAccount("C@" + domainName, pw, null);
Account D = prov.createAccount("D@" + domainName, pw, null);
groupA.addMembers(new String[] { A.getName(), groupB.getName() });
groupB.addMembers(new String[] { B.getName(), groupC.getName() });
groupC.addMembers(new String[] { C.getName(), groupD.getName() });
groupD.addMembers(new String[] { D.getName() });
}
use of com.zimbra.cs.account.DistributionList in project zm-mailbox by Zimbra.
the class CollectAllEffectiveRights method shapeTest2.
private static void shapeTest2() throws ServiceException {
setupShapeTest2();
Provisioning prov = Provisioning.getInstance();
// create test
Set<DistributionList> groupsWithGrants = new HashSet<DistributionList>();
String domainName = "test.com";
groupsWithGrants.add(prov.get(DistributionListBy.name, "groupA@" + domainName));
groupsWithGrants.add(prov.get(DistributionListBy.name, "groupB@" + domainName));
groupsWithGrants.add(prov.get(DistributionListBy.name, "groupC@" + domainName));
groupsWithGrants.add(prov.get(DistributionListBy.name, "groupD@" + domainName));
Set<GroupShape> accountShapes = new HashSet<GroupShape>();
Set<GroupShape> calendarResourceShapes = new HashSet<GroupShape>();
Set<GroupShape> distributionListShapes = new HashSet<GroupShape>();
for (DistributionList group : groupsWithGrants) {
// group is an AclGroup, which contains only upward membership, not downward membership.
// re-get the DistributionList object, which has the downward membership.
DistributionList dl = prov.get(DistributionListBy.id, group.getId());
AllGroupMembers allMembers = allGroupMembers(dl);
GroupShape.shapeMembers(TargetType.account, accountShapes, allMembers);
GroupShape.shapeMembers(TargetType.calresource, calendarResourceShapes, allMembers);
GroupShape.shapeMembers(TargetType.dl, distributionListShapes, allMembers);
}
int count = 1;
for (GroupShape shape : accountShapes) {
System.out.println("\n" + count++);
for (String group : shape.getGroups()) System.out.println("group " + group);
for (String member : shape.getMembers()) System.out.println(" " + member);
}
}
use of com.zimbra.cs.account.DistributionList in project zm-mailbox by Zimbra.
the class AccountStatus method handleAccountStatusClosed.
private void handleAccountStatusClosed(Account account) throws ServiceException {
Provisioning prov = Provisioning.getInstance();
String status = account.getAccountStatus(prov);
if (status.equals(Provisioning.ACCOUNT_STATUS_CLOSED)) {
ZimbraLog.misc.info("removing account address and all its aliases from all distribution lists");
String[] addrToRemove = new String[] { account.getName() };
Set<String> dlIds = prov.getDistributionLists(account);
for (String dlId : dlIds) {
DistributionList dl = prov.get(Key.DistributionListBy.id, dlId);
if (dl != null) {
try {
// will remove all members that are aliases of the account too
prov.removeMembers(dl, addrToRemove);
} catch (ServiceException se) {
if (AccountServiceException.NO_SUCH_MEMBER.equals(se.getCode())) {
ZimbraLog.misc.debug("Member not found in dlist; skipping", se);
} else {
throw se;
}
}
}
}
}
}
use of com.zimbra.cs.account.DistributionList in project zm-mailbox by Zimbra.
the class AdminGroup method postModify.
@Override
public void postModify(CallbackContext context, String attrName, Entry entry) {
if (!(entry instanceof DistributionList))
return;
Provisioning prov = Provisioning.getInstance();
if (!(prov instanceof LdapProv))
return;
DistributionList group = (DistributionList) entry;
((LdapProv) prov).removeFromCache(group);
}
use of com.zimbra.cs.account.DistributionList in project zm-mailbox by Zimbra.
the class DisplayName method preModify.
@Override
public void preModify(CallbackContext context, String attrName, Object value, Map attrsToModify, Entry entry) throws ServiceException {
if (!((entry instanceof Account) || (entry instanceof DistributionList)))
return;
String displayName;
// update cn only if we are not unsetting display name(cn is required for ZIMBRA_DEFAULT_PERSON_OC)
SingleValueMod mod = singleValueMod(attrName, value);
if (mod.unsetting())
return;
else
displayName = mod.value();
String namingRdnAttr = null;
Provisioning prov = Provisioning.getInstance();
if (prov instanceof LdapProv) {
namingRdnAttr = ((LdapProv) prov).getDIT().getNamingRdnAttr(entry);
}
// update cn only if it is not the naming attr
if (// non LdapProvisioning, pass thru
namingRdnAttr == null || !namingRdnAttr.equals(Provisioning.A_cn)) {
if (!attrsToModify.containsKey(Provisioning.A_cn)) {
attrsToModify.put(Provisioning.A_cn, displayName);
}
}
}
Aggregations