use of com.zimbra.cs.account.ldap.entry.LdapAlwaysOnCluster 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.LdapAlwaysOnCluster in project zm-mailbox by Zimbra.
the class LdapProvisioning method deleteAlwaysOnCluster.
@Override
public void deleteAlwaysOnCluster(String zimbraId) throws ServiceException {
LdapAlwaysOnCluster cluster = (LdapAlwaysOnCluster) getAlwaysOnClusterByIdInternal(zimbraId);
if (cluster == null)
throw AccountServiceException.NO_SUCH_ALWAYSONCLUSTER(zimbraId);
ZLdapContext zlc = null;
try {
zlc = LdapClient.getContext(LdapServerType.MASTER, LdapUsage.DELETE_ALWAYSONCLUSTER);
zlc.deleteEntry(cluster.getDN());
alwaysOnClusterCache.remove(cluster);
} catch (ServiceException e) {
throw ServiceException.FAILURE("unable to purge alwaysOnCluster: " + zimbraId, e);
} finally {
LdapClient.closeContext(zlc);
}
}
use of com.zimbra.cs.account.ldap.entry.LdapAlwaysOnCluster in project zm-mailbox by Zimbra.
the class LdapProvisioning method getAllAlwaysOnClusters.
@Override
public List<AlwaysOnCluster> getAllAlwaysOnClusters() throws ServiceException {
List<AlwaysOnCluster> result = new ArrayList<AlwaysOnCluster>();
ZLdapFilter filter = filterFactory.allAlwaysOnClusters();
try {
ZSearchResultEnumeration ne = helper.searchDir(mDIT.alwaysOnClusterBaseDN(), filter, ZSearchControls.SEARCH_CTLS_SUBTREE());
while (ne.hasMore()) {
ZSearchResultEntry sr = ne.next();
LdapAlwaysOnCluster c = new LdapAlwaysOnCluster(sr.getDN(), sr.getAttributes(), null, this);
result.add(c);
}
ne.close();
} catch (ServiceException e) {
throw ServiceException.FAILURE("unable to list all alwaysOnClusters", e);
}
if (result.size() > 0)
alwaysOnClusterCache.put(result, true);
Collections.sort(result);
return result;
}
use of com.zimbra.cs.account.ldap.entry.LdapAlwaysOnCluster in project zm-mailbox by Zimbra.
the class LdapProvisioning method getAlwaysOnClusterByName.
private AlwaysOnCluster getAlwaysOnClusterByName(String name, boolean nocache) throws ServiceException {
if (!nocache) {
AlwaysOnCluster c = alwaysOnClusterCache.getByName(name);
if (c != null)
return c;
}
try {
String dn = mDIT.alwaysOnClusterNameToDN(name);
ZAttributes attrs = helper.getAttributes(LdapUsage.GET_ALWAYSONCLUSTER, dn);
LdapAlwaysOnCluster c = new LdapAlwaysOnCluster(dn, attrs, null, this);
alwaysOnClusterCache.put(c);
return c;
} catch (LdapEntryNotFoundException e) {
return null;
} catch (ServiceException e) {
throw ServiceException.FAILURE("unable to lookup alwaysOnCluster by name: " + name + " message: " + e.getMessage(), e);
}
}
Aggregations