use of com.zimbra.cs.gal.GalSearchParams in project zm-mailbox by Zimbra.
the class TestLdapProvGal method searchGal.
@Test
public void searchGal() throws Exception {
SKIP_FOR_INMEM_LDAP_SERVER(SkipTestReason.DN_SUBTREE_MATCH_FILTER);
int NUM_ACCTS = 10;
int SIZE_LIMIT = 5;
Account user = null;
for (int i = 0; i < NUM_ACCTS; i++) {
String ACCT_NAME_LOCALPART = Names.makeAccountNameLocalPart(genAcctNameLocalPart(String.valueOf(i)));
Account acct = createAccount(ACCT_NAME_LOCALPART);
// use the first one as the user
if (user == null) {
user = acct;
}
}
GalSearchType type = GalSearchType.account;
String query = "searchGal";
GalSearchParams params = new GalSearchParams(user);
SearchGalResult result = SearchGalResult.newSearchGalResult(null);
params.setOp(GalOp.search);
params.setType(type);
params.createSearchConfig(GalSearchConfig.GalType.zimbra);
params.setQuery(query);
params.setLimit(SIZE_LIMIT);
params.setGalResult(result);
prov.searchGal(params);
assertEquals(SIZE_LIMIT, result.getMatches().size());
assertTrue(result.getHadMore());
result = prov.searchGal(domain, query, type, 0, null);
assertEquals(NUM_ACCTS, result.getMatches().size());
assertFalse(result.getHadMore());
}
use of com.zimbra.cs.gal.GalSearchParams in project zm-mailbox by Zimbra.
the class ContactAutoComplete method queryGal.
private void queryGal(String str, AutoCompleteResult result) {
ZimbraLog.gal.debug("querying gal");
GalSearchParams params = new GalSearchParams(mRequestedAcct, mZsc);
params.setQuery(str);
params.setType(mSearchType);
params.setLimit(200);
params.setNeedCanExpand(mNeedCanExpand);
params.setResultCallback(new AutoCompleteCallback(str, result, params));
try {
try {
GalSearchControl gal = new GalSearchControl(params);
gal.autocomplete();
} catch (ServiceException e) {
if (ServiceException.PERM_DENIED.equals(e.getCode())) {
// do not log stack
ZimbraLog.gal.debug("cannot autocomplete gal: %s", e.getMessage());
} else {
throw e;
}
}
} catch (Exception e) {
ZimbraLog.gal.warn("cannot autocomplete gal", e);
return;
}
}
Aggregations