use of com.zimbra.cs.account.Group in project zm-mailbox by Zimbra.
the class LdapProvisioning method extendLifeInCacheOrFlush.
public void extendLifeInCacheOrFlush(Entry entry) {
if (entry instanceof Account) {
accountCache.replace((Account) entry);
} else if (entry instanceof LdapCos) {
cosCache.replace((LdapCos) entry);
} else if (entry instanceof Domain) {
domainCache.replace((Domain) entry);
} else if (entry instanceof Server) {
serverCache.replace((Server) entry);
} else if (entry instanceof UCService) {
ucServiceCache.replace((UCService) entry);
} else if (entry instanceof XMPPComponent) {
xmppComponentCache.replace((XMPPComponent) entry);
} else if (entry instanceof LdapZimlet) {
zimletCache.replace((LdapZimlet) entry);
} else if (entry instanceof LdapAlwaysOnCluster) {
alwaysOnClusterCache.replace((AlwaysOnCluster) entry);
} else if (entry instanceof Group) {
/*
* DLs returned by Provisioning.get(DistributionListBy) and
* DLs/dynamic groups returned by Provisioning.getGroup(DistributionListBy)
* are "not" cached.
*
* DLs returned by Provisioning.getDLBasic(DistributionListBy) and
* DLs/dynamic groups returned by Provisioning.getGroupBasic(DistributionListBy)
* "are" cached.
*
* Need to flush out the cached entries if the instance being modified is not
* in cache. (i.e. the instance being modified was obtained by get/getGroup)
*/
Group modifiedInstance = (Group) entry;
Group cachedInstance = getGroupFromCache(DistributionListBy.id, modifiedInstance.getId());
if (cachedInstance != null && modifiedInstance != cachedInstance) {
groupCache.remove(cachedInstance);
}
}
}
use of com.zimbra.cs.account.Group in project zm-mailbox by Zimbra.
the class LdapProvisioning method getGroupBasic.
/*
* like getGroup(DistributionListBy keyType, String key)
* the difference are:
* - cached
* - entry returned only contains minimal group attrs
* - entry returned does not contain members (the member or zimbraMailForwardingAddress attribute)
*/
@Override
public Group getGroupBasic(Key.DistributionListBy keyType, String key) throws ServiceException {
Group group = getGroupFromCache(keyType, key);
if (group != null) {
return group;
}
// fetch from LDAP
group = getGroupInternal(keyType, key, true, false);
// cache it
if (group != null) {
putInGroupCache(group);
}
return group;
}
use of com.zimbra.cs.account.Group in project zm-mailbox by Zimbra.
the class LdapProvisioning method cleanGroupMembersCache.
private void cleanGroupMembersCache(Group group) {
/*
* Fully loaded DLs(containing members attribute) are not cached
* (those obtained via Provisioning.getGroup().
*
* if the modified instance (the instance being passed in) is not the same
* instance in cache, clean the group members cache on the cached instance
*/
Group cachedInstance = getGroupFromCache(DistributionListBy.id, group.getId());
if (cachedInstance != null && group != cachedInstance) {
cachedInstance.removeCachedData(EntryCacheDataKey.GROUP_MEMBERS);
}
// also always clean it on the modified instance
group.removeCachedData(EntryCacheDataKey.GROUP_MEMBERS);
}
use of com.zimbra.cs.account.Group in project zm-mailbox by Zimbra.
the class SoapProvisioning method getGroups.
@Override
public List<Group> getGroups(Account acct, boolean directOnly, Map<String, String> via) throws ServiceException {
ArrayList<Group> result = new ArrayList<Group>();
GetAccountMembershipResponse resp = invokeJaxb(new GetAccountMembershipRequest(getSelector(acct)));
for (DLInfo dlInfo : resp.getDlList()) {
String viaList = dlInfo.getVia();
if (directOnly && viaList != null) {
continue;
}
Group group = makeGroup(dlInfo);
if (via != null && viaList != null) {
via.put(group.getName(), viaList);
}
result.add(group);
}
return result;
}
use of com.zimbra.cs.account.Group in project zm-mailbox by Zimbra.
the class BUG_66387 method fixAccount.
private void fixAccount(String name, String[] allowFromAddresses) throws ServiceException {
++numInspected;
Account account = prov.get(AccountBy.name, name);
if (account == null) {
// this shouldn't happen
printer.println("Account " + name + " not found! Skipping.");
return;
}
boolean modified = false;
printer.println("# Account: " + account.getName());
String[] addrs = account.getAllowFromAddress();
printer.println(" Current value = " + StringUtil.join(", ", addrs));
Set<String> remainingAddrs = new HashSet<String>();
for (String addr : addrs) {
NamedEntry entry = lookupEntry(addr);
if (entry instanceof Account) {
if (!entry.getId().equalsIgnoreCase(account.getId())) {
doGrant(entry, account, addr);
modified = true;
} else {
printer.println(" - removing redundant address " + addr);
modified = true;
}
} else if (entry instanceof Group) {
doGrant(entry, account, addr);
modified = true;
} else {
remainingAddrs.add(addr);
}
}
if (modified) {
Map<String, Object> attrsMap = new HashMap<String, Object>();
if (!remainingAddrs.isEmpty()) {
String[] remaining = remainingAddrs.toArray(new String[0]);
attrsMap.put(Provisioning.A_zimbraAllowFromAddress, remaining);
printer.println(" New value = " + StringUtil.join(", ", remaining));
} else {
attrsMap.put(Provisioning.A_zimbraAllowFromAddress, "");
printer.println(" New value = <unset>");
}
prov.modifyAttrs(account, attrsMap, false, false);
++numFixed;
} else {
printer.println(" No change needed");
}
printer.println();
}
Aggregations