use of com.zimbra.cs.account.ldap.entry.LdapZimlet 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.LdapZimlet in project zm-mailbox by Zimbra.
the class LdapProvisioning method listAllZimlets.
@Override
public List<Zimlet> listAllZimlets() throws ServiceException {
List<Zimlet> result = new ArrayList<Zimlet>();
try {
ZSearchResultEnumeration ne = helper.searchDir(mDIT.zimletBaseDN(), filterFactory.allZimlets(), ZSearchControls.SEARCH_CTLS_SUBTREE());
while (ne.hasMore()) {
ZSearchResultEntry sr = ne.next();
result.add(new LdapZimlet(sr.getDN(), sr.getAttributes(), this));
}
ne.close();
} catch (ServiceException e) {
throw ServiceException.FAILURE("unable to list all zimlets", e);
}
Collections.sort(result);
return result;
}
use of com.zimbra.cs.account.ldap.entry.LdapZimlet in project zm-mailbox by Zimbra.
the class LdapProvisioning method deleteZimlet.
@Override
public void deleteZimlet(String name) throws ServiceException {
ZLdapContext zlc = null;
try {
zlc = LdapClient.getContext(LdapServerType.MASTER, LdapUsage.DELETE_ZIMLET);
LdapZimlet zimlet = (LdapZimlet) getZimlet(name, zlc, true);
if (zimlet != null) {
zimletCache.remove(zimlet);
zlc.deleteEntry(zimlet.getDN());
}
} catch (ServiceException e) {
throw ServiceException.FAILURE("unable to delete zimlet: " + name, e);
} finally {
LdapClient.closeContext(zlc);
}
}
use of com.zimbra.cs.account.ldap.entry.LdapZimlet in project zm-mailbox by Zimbra.
the class LdapProvisioning method getZimlet.
private Zimlet getZimlet(String name, ZLdapContext initZlc, boolean useZimletCache) throws ServiceException {
LdapZimlet zimlet = null;
if (useZimletCache) {
zimlet = zimletCache.getByName(name);
}
if (zimlet != null) {
return zimlet;
}
try {
String dn = mDIT.zimletNameToDN(name);
ZAttributes attrs = helper.getAttributes(initZlc, LdapServerType.REPLICA, LdapUsage.GET_ZIMLET, dn, null);
zimlet = new LdapZimlet(dn, attrs, this);
if (useZimletCache) {
ZimletUtil.reloadZimlet(name);
// put LdapZimlet into the cache after successful ZimletUtil.reloadZimlet()
zimletCache.put(zimlet);
}
return zimlet;
} catch (LdapEntryNotFoundException e) {
return null;
} catch (ServiceException ne) {
throw ServiceException.FAILURE("unable to get zimlet: " + name, ne);
} catch (ZimletException ze) {
throw ServiceException.FAILURE("unable to load zimlet: " + name, ze);
}
}
Aggregations