use of com.zimbra.cs.account.ldap.entry.LdapCos 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.ldap.entry.LdapCos in project zm-mailbox by Zimbra.
the class LdapProvisioning method removeServerFromAllCOSes.
private void removeServerFromAllCOSes(String serverId, String serverName, ZLdapContext initZlc) {
List<Cos> coses = null;
try {
coses = searchCOS(filterFactory.cosesByMailHostPool(serverId), initZlc);
for (Cos cos : coses) {
Map<String, String> attrs = new HashMap<String, String>();
attrs.put("-" + Provisioning.A_zimbraMailHostPool, serverId);
ZimbraLog.account.info("Removing " + Provisioning.A_zimbraMailHostPool + " " + serverId + "(" + serverName + ") from cos " + cos.getName());
modifyAttrs(cos, attrs);
// invalidate cached cos
cosCache.remove((LdapCos) cos);
}
} catch (ServiceException se) {
ZimbraLog.account.warn("unable to remove " + serverId + " from all COSes ", se);
return;
}
}
use of com.zimbra.cs.account.ldap.entry.LdapCos in project zm-mailbox by Zimbra.
the class LdapProvisioning method searchCOS.
private List<Cos> searchCOS(ZLdapFilter filter, ZLdapContext initZlc) throws ServiceException {
List<Cos> result = new ArrayList<Cos>();
try {
ZSearchResultEnumeration ne = helper.searchDir(mDIT.cosBaseDN(), filter, ZSearchControls.SEARCH_CTLS_SUBTREE(), initZlc, LdapServerType.REPLICA);
while (ne.hasMore()) {
ZSearchResultEntry sr = ne.next();
result.add(new LdapCos(sr.getDN(), sr.getAttributes(), this));
}
ne.close();
} catch (ServiceException e) {
throw ServiceException.FAILURE("unable to lookup cos via query: " + filter.toFilterString() + " message: " + e.getMessage(), e);
}
return result;
}
use of com.zimbra.cs.account.ldap.entry.LdapCos in project zm-mailbox by Zimbra.
the class LdapProvisioning method getCosById.
private Cos getCosById(String zimbraId, ZLdapContext zlc) throws ServiceException {
if (zimbraId == null)
return null;
LdapCos cos = cosCache.getById(zimbraId);
if (cos == null) {
cos = getCOSByQuery(filterFactory.cosById(zimbraId), zlc);
cosCache.put(cos);
}
return cos;
}
use of com.zimbra.cs.account.ldap.entry.LdapCos in project zm-mailbox by Zimbra.
the class LdapProvisioning method getAllCos.
@Override
public List<Cos> getAllCos() throws ServiceException {
List<Cos> result = new ArrayList<Cos>();
try {
ZSearchResultEnumeration ne = helper.searchDir(mDIT.cosBaseDN(), filterFactory.allCoses(), ZSearchControls.SEARCH_CTLS_SUBTREE());
while (ne.hasMore()) {
ZSearchResultEntry sr = ne.next();
result.add(new LdapCos(sr.getDN(), sr.getAttributes(), this));
}
ne.close();
} catch (ServiceException e) {
throw ServiceException.FAILURE("unable to list all COS", e);
}
Collections.sort(result);
return result;
}
Aggregations