Search in sources :

Example 1 with LdapZimlet

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);
        }
    }
}
Also used : Account(com.zimbra.cs.account.Account) GuestAccount(com.zimbra.cs.account.GuestAccount) LdapAccount(com.zimbra.cs.account.ldap.entry.LdapAccount) Group(com.zimbra.cs.account.Group) DynamicGroup(com.zimbra.cs.account.DynamicGroup) LdapDynamicGroup(com.zimbra.cs.account.ldap.entry.LdapDynamicGroup) LdapAlwaysOnCluster(com.zimbra.cs.account.ldap.entry.LdapAlwaysOnCluster) InMemoryLdapServer(com.zimbra.cs.ldap.unboundid.InMemoryLdapServer) LdapServer(com.zimbra.cs.account.ldap.entry.LdapServer) Server(com.zimbra.cs.account.Server) LdapUCService(com.zimbra.cs.account.ldap.entry.LdapUCService) UCService(com.zimbra.cs.account.UCService) LdapAlwaysOnCluster(com.zimbra.cs.account.ldap.entry.LdapAlwaysOnCluster) AlwaysOnCluster(com.zimbra.cs.account.AlwaysOnCluster) LdapZimlet(com.zimbra.cs.account.ldap.entry.LdapZimlet) LdapCos(com.zimbra.cs.account.ldap.entry.LdapCos) LdapDomain(com.zimbra.cs.account.ldap.entry.LdapDomain) Domain(com.zimbra.cs.account.Domain) XMPPComponent(com.zimbra.cs.account.XMPPComponent) LdapXMPPComponent(com.zimbra.cs.account.ldap.entry.LdapXMPPComponent)

Example 2 with LdapZimlet

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;
}
Also used : Zimlet(com.zimbra.cs.account.Zimlet) LdapZimlet(com.zimbra.cs.account.ldap.entry.LdapZimlet) AccountServiceException(com.zimbra.cs.account.AccountServiceException) AuthFailedServiceException(com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException) ServiceException(com.zimbra.common.service.ServiceException) ZSearchResultEnumeration(com.zimbra.cs.ldap.ZSearchResultEnumeration) LdapZimlet(com.zimbra.cs.account.ldap.entry.LdapZimlet) ArrayList(java.util.ArrayList) ZSearchResultEntry(com.zimbra.cs.ldap.ZSearchResultEntry)

Example 3 with LdapZimlet

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);
    }
}
Also used : ZLdapContext(com.zimbra.cs.ldap.ZLdapContext) AccountServiceException(com.zimbra.cs.account.AccountServiceException) AuthFailedServiceException(com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException) ServiceException(com.zimbra.common.service.ServiceException) LdapZimlet(com.zimbra.cs.account.ldap.entry.LdapZimlet)

Example 4 with LdapZimlet

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);
    }
}
Also used : AccountServiceException(com.zimbra.cs.account.AccountServiceException) AuthFailedServiceException(com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException) ServiceException(com.zimbra.common.service.ServiceException) LdapEntryNotFoundException(com.zimbra.cs.ldap.LdapException.LdapEntryNotFoundException) LdapZimlet(com.zimbra.cs.account.ldap.entry.LdapZimlet) ZAttributes(com.zimbra.cs.ldap.ZAttributes) ZimletException(com.zimbra.cs.zimlet.ZimletException)

Aggregations

LdapZimlet (com.zimbra.cs.account.ldap.entry.LdapZimlet)4 ServiceException (com.zimbra.common.service.ServiceException)3 AccountServiceException (com.zimbra.cs.account.AccountServiceException)3 AuthFailedServiceException (com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException)3 Account (com.zimbra.cs.account.Account)1 AlwaysOnCluster (com.zimbra.cs.account.AlwaysOnCluster)1 Domain (com.zimbra.cs.account.Domain)1 DynamicGroup (com.zimbra.cs.account.DynamicGroup)1 Group (com.zimbra.cs.account.Group)1 GuestAccount (com.zimbra.cs.account.GuestAccount)1 Server (com.zimbra.cs.account.Server)1 UCService (com.zimbra.cs.account.UCService)1 XMPPComponent (com.zimbra.cs.account.XMPPComponent)1 Zimlet (com.zimbra.cs.account.Zimlet)1 LdapAccount (com.zimbra.cs.account.ldap.entry.LdapAccount)1 LdapAlwaysOnCluster (com.zimbra.cs.account.ldap.entry.LdapAlwaysOnCluster)1 LdapCos (com.zimbra.cs.account.ldap.entry.LdapCos)1 LdapDomain (com.zimbra.cs.account.ldap.entry.LdapDomain)1 LdapDynamicGroup (com.zimbra.cs.account.ldap.entry.LdapDynamicGroup)1 LdapServer (com.zimbra.cs.account.ldap.entry.LdapServer)1