Search in sources :

Example 1 with NamedFilter

use of com.zimbra.cs.gal.GalFilter.NamedFilter in project zm-mailbox by Zimbra.

the class GalSearchConfig method loadZimbraConfig.

protected void loadZimbraConfig(Domain domain, GalOp op, GalSearchType stype) throws ServiceException {
    mRules = new LdapGalMapRules(domain, true);
    mOp = op;
    NamedFilter filterName = null;
    switch(op) {
        case sync:
            filterName = (stype == GalSearchType.all) ? NamedFilter.zimbraSync : (stype == GalSearchType.resource) ? NamedFilter.zimbraResourceSync : (stype == GalSearchType.group) ? NamedFilter.zimbraGroupSync : NamedFilter.zimbraAccountSync;
            break;
        case search:
            filterName = (stype == GalSearchType.all) ? NamedFilter.zimbraSearch : (stype == GalSearchType.resource) ? NamedFilter.zimbraResources : (stype == GalSearchType.group) ? NamedFilter.zimbraGroups : NamedFilter.zimbraAccounts;
            mTokenizeKey = domain.getAttr(Provisioning.A_zimbraGalTokenizeSearchKey, null);
            break;
        case autocomplete:
            filterName = (stype == GalSearchType.all) ? NamedFilter.zimbraAutoComplete : (stype == GalSearchType.resource) ? NamedFilter.zimbraResourceAutoComplete : (stype == GalSearchType.group) ? NamedFilter.zimbraGroupAutoComplete : NamedFilter.zimbraAccountAutoComplete;
            mTokenizeKey = domain.getAttr(Provisioning.A_zimbraGalTokenizeAutoCompleteKey, null);
            break;
    }
    String filter = null;
    if (filterName != null) {
        filter = GalSearchConfig.getFilterDef(filterName);
    }
    if (filter == null && op == GalOp.sync) {
        filter = GalFilter.DEFAULT_SYNC_FILTER;
    }
    mAuthMech = Provisioning.LDAP_AM_SIMPLE;
    if (filter == null) {
        filter = "";
    } else if (!filter.startsWith("(")) {
        filter = "(" + filter + ")";
    }
    String dnSubtreeMatchFilter = null;
    String searchBaseRaw = ZimbraGalSearchBase.getSearchBaseRaw(domain, op);
    if (ZimbraGalSearchBase.PredefinedSearchBase.DOMAIN.name().equals(searchBaseRaw)) {
        dnSubtreeMatchFilter = ((LdapDomain) domain).getDnSubtreeMatchFilter().toFilterString();
    }
    if (dnSubtreeMatchFilter == null) {
        dnSubtreeMatchFilter = "";
    }
    mFilter = "(&" + filter + "(!(zimbraHideInGal=TRUE))(!(zimbraIsSystemResource=TRUE))" + dnSubtreeMatchFilter + ")";
    mSearchBase = ZimbraGalSearchBase.getSearchBase(domain, op);
    mGalType = GalType.zimbra;
    mTimestampFormat = LdapDateUtil.ZIMBRA_LDAP_GENERALIZED_TIME_FORMAT_LEGACY;
    mPageSize = 1000;
}
Also used : LdapGalMapRules(com.zimbra.cs.account.ldap.LdapGalMapRules) LdapDomain(com.zimbra.cs.account.ldap.entry.LdapDomain) NamedFilter(com.zimbra.cs.gal.GalFilter.NamedFilter)

Aggregations

LdapGalMapRules (com.zimbra.cs.account.ldap.LdapGalMapRules)1 LdapDomain (com.zimbra.cs.account.ldap.entry.LdapDomain)1 NamedFilter (com.zimbra.cs.gal.GalFilter.NamedFilter)1