use of com.zimbra.cs.gal.GalSearchParams in project zm-mailbox by Zimbra.
the class LdapProvisioning method searchGal.
@Override
public SearchGalResult searchGal(Domain domain, String query, GalSearchType type, int limit, GalContact.Visitor visitor) throws ServiceException {
SearchGalResult searchResult = SearchGalResult.newSearchGalResult(visitor);
GalSearchParams params = new GalSearchParams(domain, null);
params.setQuery(query);
params.setType(type);
params.setOp(GalOp.search);
params.setLimit(limit);
params.setGalResult(searchResult);
LdapOnlyGalSearchResultCallback callback = new LdapOnlyGalSearchResultCallback(params, visitor);
params.setResultCallback(callback);
GalSearchControl gal = new GalSearchControl(params);
gal.ldapSearch();
return searchResult;
}
use of com.zimbra.cs.gal.GalSearchParams in project zm-mailbox by Zimbra.
the class SearchGal method handle.
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
String domainName = request.getAttribute(AdminConstants.A_DOMAIN);
Provisioning prov = Provisioning.getInstance();
Domain domain = prov.get(Key.DomainBy.name, domainName);
if (domain == null)
throw AccountServiceException.NO_SUCH_DOMAIN(domainName);
checkDomainRight(zsc, domain, Admin.R_accessGAL);
String name = request.getAttribute(AdminConstants.E_NAME, "");
int limit = (int) request.getAttributeLong(AdminConstants.A_LIMIT, 0);
String typeStr = request.getAttribute(AdminConstants.A_TYPE, GalSearchType.account.name());
GalSearchType type = GalSearchType.fromString(typeStr);
String galAcctId = request.getAttribute(AccountConstants.A_GAL_ACCOUNT_ID, null);
String token = request.getAttribute(AdminConstants.A_TOKEN, null);
GalSearchParams params = new GalSearchParams(domain, zsc);
if (token != null)
params.setToken(token);
params.setType(type);
params.setRequest(request);
params.setQuery(name);
params.setLimit(limit);
params.setResponseName(AdminConstants.SEARCH_GAL_RESPONSE);
if (galAcctId != null)
params.setGalSyncAccount(Provisioning.getInstance().getAccountById(galAcctId));
params.setResultCallback(new SearchGal.AdminGalCallback(params));
GalSearchControl gal = new GalSearchControl(params);
if (token != null)
gal.sync();
else
gal.search();
return params.getResultCallback().getResponse();
}
use of com.zimbra.cs.gal.GalSearchParams in project zm-mailbox by Zimbra.
the class SearchGal method searchGal.
private static Element searchGal(ZimbraSoapContext zsc, Account account, Element request) throws ServiceException {
// if searhc by ref is requested, honor it
String ref = request.getAttribute(AccountConstants.A_REF, null);
// otherwise require a query
String name = null;
if (ref == null) {
name = request.getAttribute(AccountConstants.E_NAME);
}
EntrySearchFilter filter = GalExtraSearchFilter.parseSearchFilter(request);
String typeStr = request.getAttribute(AccountConstants.A_TYPE, "all");
GalSearchType type = GalSearchType.fromString(typeStr);
boolean needCanExpand = request.getAttributeBool(AccountConstants.A_NEED_EXP, false);
boolean needIsOwner = request.getAttributeBool(AccountConstants.A_NEED_IS_OWNER, false);
MemberOfSelector needIsMember = MemberOfSelector.fromString(request.getAttribute(AccountConstants.A_NEED_IS_MEMBER, MemberOfSelector.none.name()));
// internal attr, for proxied GSA search from GetSMIMEPublicCerts only
boolean needSMIMECerts = request.getAttributeBool(AccountConstants.A_NEED_SMIME_CERTS, false);
String galAcctId = request.getAttribute(AccountConstants.A_GAL_ACCOUNT_ID, null);
GalSearchParams params = new GalSearchParams(account, zsc);
if (ref == null) {
params.setQuery(name);
} else {
// search GAL by ref, which is a dn
params.setSearchEntryByDn(ref);
}
params.setType(type);
params.setRequest(request);
params.setNeedCanExpand(needCanExpand);
params.setNeedIsOwner(needIsOwner);
params.setNeedIsMember(needIsMember);
params.setNeedSMIMECerts(needSMIMECerts);
params.setResponseName(AccountConstants.SEARCH_GAL_RESPONSE);
if (galAcctId != null) {
params.setGalSyncAccount(Provisioning.getInstance().getAccountById(galAcctId));
}
if (filter != null) {
params.setExtraQueryCallback(new SearchGalExtraQueryCallback(filter));
}
// also note that mailbox search has a hard limit of 1000
if (request.getAttribute(MailConstants.A_QUERY_LIMIT, null) == null) {
request.addAttribute(MailConstants.A_QUERY_LIMIT, 100);
}
/* do not support specified attrs yet
String attrsStr = request.getAttribute(AccountConstants.A_ATTRS, null);
String[] attrs = attrsStr == null ? null : attrsStr.split(",");
Set<String> attrsSet = attrs == null ? null : new HashSet<String>(Arrays.asList(attrs));
*/
params.setResultCallback(new SearchGalResultCallback(params, filter, null));
GalSearchControl gal = new GalSearchControl(params);
gal.search();
return params.getResultCallback().getResponse();
}
use of com.zimbra.cs.gal.GalSearchParams in project zm-mailbox by Zimbra.
the class SyncGal method handle.
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
disableJettyTimeout(context);
ZimbraSoapContext zsc = getZimbraSoapContext(context);
Account account = getRequestedAccount(getZimbraSoapContext(context));
if (!canAccessAccount(zsc, account))
throw ServiceException.PERM_DENIED("can not access account");
String tokenAttr = request.getAttribute(MailConstants.A_TOKEN, "");
String galAcctId = request.getAttribute(AccountConstants.A_GAL_ACCOUNT_ID, null);
boolean idOnly = request.getAttributeBool(AccountConstants.A_ID_ONLY, false);
int limit = request.getAttributeInt(MailConstants.A_LIMIT, 0);
GalSearchParams params = new GalSearchParams(account, zsc);
params.setType(GalSearchType.all);
ZimbraLog.gal.debug("SyncGalRequest token: %s limit: %d", tokenAttr, limit);
params.setToken(tokenAttr);
params.setRequest(request);
params.setResponseName(AccountConstants.SYNC_GAL_RESPONSE);
params.setIdOnly(idOnly);
params.setUserAgent(zsc.getUserAgent());
params.setLimit(limit);
if (galAcctId != null)
params.setGalSyncAccount(Provisioning.getInstance().getAccountById(galAcctId));
params.setResultCallback(new SyncGalCallback(params));
GalSearchControl gal = new GalSearchControl(params);
gal.sync();
return params.getResultCallback().getResponse();
}
use of com.zimbra.cs.gal.GalSearchParams in project zm-mailbox by Zimbra.
the class AutoCompleteGal method handle.
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
Account account = getRequestedAccount(getZimbraSoapContext(context));
if (!canAccessAccount(zsc, account))
throw ServiceException.PERM_DENIED("can not access account");
String name = request.getAttribute(AccountConstants.E_NAME);
String typeStr = request.getAttribute(AccountConstants.A_TYPE, "account");
GalSearchType type = GalSearchType.fromString(typeStr);
boolean needCanExpand = request.getAttributeBool(AccountConstants.A_NEED_EXP, false);
String galAcctId = request.getAttribute(AccountConstants.A_GAL_ACCOUNT_ID, null);
GalSearchParams params = new GalSearchParams(account, zsc);
params.setType(type);
params.setRequest(request);
params.setQuery(name);
params.setLimit(account.getContactAutoCompleteMaxResults());
params.setNeedCanExpand(needCanExpand);
params.setResponseName(AccountConstants.AUTO_COMPLETE_GAL_RESPONSE);
if (galAcctId != null)
params.setGalSyncAccount(Provisioning.getInstance().getAccountById(galAcctId));
GalSearchControl gal = new GalSearchControl(params);
gal.autocomplete();
return params.getResultCallback().getResponse();
}
Aggregations