String tokens[] = null; if (token != null) { tokens = token.split(":"); if (tokens.length != 2) tokens = null; } if (tokens == null) tokens = new String[] {null, null};  results = searchZimbraGal(d, n, maxResults/2, tokens[0], false); SearchGalResult ldapResults = searchLdapGal(d, n, maxResults/2, tokens[1], false);
results = searchZimbraGal(d, n, maxResults/2, token, false); SearchGalResult ldapResults = searchLdapGal(d, n, maxResults/2, token, false);
    public SearchGalResult searchGal(Domain d, String n,                                     Provisioning.GAL_SEARCH_TYPE type,                                     String token)    throws ServiceException {        // escape user-supplied string        n = LdapUtil.escapeSearchFilterArg(n);        int maxResults = token != null ? 0 : d.getIntAttr(Provisioning.A_zimbraGalMaxResults, DEFAULT_GAL_MAX_RESULTS);        if (type == Provisioning.GAL_SEARCH_TYPE.CALENDAR_RESOURCE)            return searchResourcesGal(d, n, maxResults, token, false);        String mode = d.getAttr(Provisioning.A_zimbraGalMode);        SearchGalResult results = null;        if (mode == null || mode.equals(Provisioning.GM_ZIMBRA)) {            results = searchZimbraGal(d, n, maxResults, token, false);        } else if (mode.equals(Provisioning.GM_LDAP)) {            results = searchLdapGal(d, n, maxResults, token, false);        } else if (mode.equals(Provisioning.GM_BOTH)) {            String tokens[] = null;            if (token != null) {                tokens = token.split(":");                if (tokens.length != 2) tokens = null;            }            if (tokens == null) tokens = new String[] {null, null};                             results = searchZimbraGal(d, n, maxResults/2, tokens[0], false);            SearchGalResult ldapResults = searchLdapGal(d, n, maxResults/2, tokens[1], false);            if (ldapResults != null) {                results.matches.addAll(ldapResults.matches);                results.token = LdapUtil.getLaterTimestamp(results.token, ldapResults.token);            }        } else {            results = searchZimbraGal(d, n, maxResults, token, false);        }        if (results == null) results = new SearchGalResult();        if (results.matches == null) results.matches = new ArrayList<GalContact>();        if (type == Provisioning.GAL_SEARCH_TYPE.ALL) {            SearchGalResult resourceResults = null;            if (maxResults == 0)                resourceResults = searchResourcesGal(d, n, 0, token, false);            else {                int room = maxResults - results.matches.size();                if (room > 0)                    resourceResults = searchResourcesGal(d, n, room, token, false);            }            if (resourceResults != null) {                results.matches.addAll(resourceResults.matches);                results.token = LdapUtil.getLaterTimestamp(results.token, resourceResults.token);            }        }        return results;    }