Search in sources :

Example 1 with LdapCos

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);
        }
    }
}
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 LdapCos

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;
    }
}
Also used : AccountServiceException(com.zimbra.cs.account.AccountServiceException) AuthFailedServiceException(com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException) ServiceException(com.zimbra.common.service.ServiceException) HashMap(java.util.HashMap) LdapCos(com.zimbra.cs.account.ldap.entry.LdapCos) Cos(com.zimbra.cs.account.Cos)

Example 3 with LdapCos

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

Example 4 with LdapCos

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;
}
Also used : LdapCos(com.zimbra.cs.account.ldap.entry.LdapCos)

Example 5 with LdapCos

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

Aggregations

LdapCos (com.zimbra.cs.account.ldap.entry.LdapCos)8 ServiceException (com.zimbra.common.service.ServiceException)6 AccountServiceException (com.zimbra.cs.account.AccountServiceException)6 AuthFailedServiceException (com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException)6 Cos (com.zimbra.cs.account.Cos)3 ZLdapContext (com.zimbra.cs.ldap.ZLdapContext)2 ZSearchResultEntry (com.zimbra.cs.ldap.ZSearchResultEntry)2 ZSearchResultEnumeration (com.zimbra.cs.ldap.ZSearchResultEnumeration)2 ArrayList (java.util.ArrayList)2 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 LdapAccount (com.zimbra.cs.account.ldap.entry.LdapAccount)1 LdapAlwaysOnCluster (com.zimbra.cs.account.ldap.entry.LdapAlwaysOnCluster)1