Search in sources :

Example 1 with XMPPComponent

use of com.zimbra.cs.account.XMPPComponent in project zm-mailbox by Zimbra.

the class LdapProvisioning method getAllXMPPComponents.

@Override
public List<XMPPComponent> getAllXMPPComponents() throws ServiceException {
    List<XMPPComponent> result = new ArrayList<XMPPComponent>();
    try {
        String base = mDIT.xmppcomponentBaseDN();
        ZLdapFilter filter = filterFactory.allXMPPComponents();
        ZSearchResultEnumeration ne = helper.searchDir(base, filter, ZSearchControls.SEARCH_CTLS_SUBTREE());
        while (ne.hasMore()) {
            ZSearchResultEntry sr = ne.next();
            LdapXMPPComponent x = new LdapXMPPComponent(sr.getDN(), sr.getAttributes(), this);
            result.add(x);
        }
        ne.close();
    } catch (ServiceException e) {
        throw ServiceException.FAILURE("unable to list all XMPPComponents", e);
    }
    if (result.size() > 0) {
        xmppComponentCache.put(result, true);
    }
    Collections.sort(result);
    return result;
}
Also used : ZLdapFilter(com.zimbra.cs.ldap.ZLdapFilter) 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) ArrayList(java.util.ArrayList) LdapXMPPComponent(com.zimbra.cs.account.ldap.entry.LdapXMPPComponent) XMPPComponent(com.zimbra.cs.account.XMPPComponent) LdapXMPPComponent(com.zimbra.cs.account.ldap.entry.LdapXMPPComponent) ZSearchResultEntry(com.zimbra.cs.ldap.ZSearchResultEntry)

Example 2 with XMPPComponent

use of com.zimbra.cs.account.XMPPComponent 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 3 with XMPPComponent

use of com.zimbra.cs.account.XMPPComponent in project zm-mailbox by Zimbra.

the class LdapProvisioning method getXMPPComponentById.

private XMPPComponent getXMPPComponentById(String zimbraId, ZLdapContext zlc, boolean nocache) throws ServiceException {
    if (zimbraId == null)
        return null;
    XMPPComponent x = null;
    if (!nocache)
        x = xmppComponentCache.getById(zimbraId);
    if (x == null) {
        x = getXMPPComponentByQuery(filterFactory.xmppComponentById(zimbraId), zlc);
        xmppComponentCache.put(x);
    }
    return x;
}
Also used : XMPPComponent(com.zimbra.cs.account.XMPPComponent) LdapXMPPComponent(com.zimbra.cs.account.ldap.entry.LdapXMPPComponent)

Example 4 with XMPPComponent

use of com.zimbra.cs.account.XMPPComponent in project zm-mailbox by Zimbra.

the class SoapProvisioning method getAllXMPPComponents.

@Override
public List<XMPPComponent> getAllXMPPComponents() throws ServiceException {
    XMLElement req = new XMLElement(AdminConstants.GET_ALL_XMPPCOMPONENTS_REQUEST);
    Element response = invoke(req);
    List<XMPPComponent> toRet = new ArrayList<XMPPComponent>();
    for (Element e : response.listElements(AdminConstants.E_XMPP_COMPONENT)) {
        toRet.add(new SoapXMPPComponent(e, this));
    }
    return toRet;
}
Also used : Element(com.zimbra.common.soap.Element) XMLElement(com.zimbra.common.soap.Element.XMLElement) ArrayList(java.util.ArrayList) XMLElement(com.zimbra.common.soap.Element.XMLElement) XMPPComponent(com.zimbra.cs.account.XMPPComponent)

Example 5 with XMPPComponent

use of com.zimbra.cs.account.XMPPComponent in project zm-mailbox by Zimbra.

the class TestACLGrant method getXMPPComponent.

private XMPPComponent getXMPPComponent() throws ServiceException {
    XMPPComponent xmppCpnt = mProv.get(XMPPComponentBy.name, XMPP_COMPONENT_NAME);
    if (xmppCpnt == null) {
        Map<String, Object> attrs = new HashMap<String, Object>();
        attrs.put(Provisioning.A_zimbraXMPPComponentCategory, "whatever");
        attrs.put(Provisioning.A_zimbraXMPPComponentClassName, "whatever");
        attrs.put(Provisioning.A_zimbraXMPPComponentType, "whatever");
        xmppCpnt = mProv.createXMPPComponent(XMPP_COMPONENT_NAME, getDomain(), getServer(), attrs);
    }
    return xmppCpnt;
}
Also used : HashMap(java.util.HashMap) XMPPComponent(com.zimbra.cs.account.XMPPComponent)

Aggregations

XMPPComponent (com.zimbra.cs.account.XMPPComponent)20 Element (com.zimbra.common.soap.Element)5 LdapXMPPComponent (com.zimbra.cs.account.ldap.entry.LdapXMPPComponent)5 Provisioning (com.zimbra.cs.account.Provisioning)4 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)4 HashMap (java.util.HashMap)4 Key (com.zimbra.common.account.Key)3 AccountServiceException (com.zimbra.cs.account.AccountServiceException)3 Server (com.zimbra.cs.account.Server)3 XMPPComponentBy (com.zimbra.common.account.Key.XMPPComponentBy)2 ServiceException (com.zimbra.common.service.ServiceException)2 AuthFailedServiceException (com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException)2 Domain (com.zimbra.cs.account.Domain)2 ArrayList (java.util.ArrayList)2 DomainBy (com.zimbra.common.account.Key.DomainBy)1 XMLElement (com.zimbra.common.soap.Element.XMLElement)1 Account (com.zimbra.cs.account.Account)1 AlwaysOnCluster (com.zimbra.cs.account.AlwaysOnCluster)1 DynamicGroup (com.zimbra.cs.account.DynamicGroup)1 Group (com.zimbra.cs.account.Group)1