Skip to content

Commit

Permalink
Merge pull request #1262 from Zimbra/bugfix/ZCS-11349
Browse files Browse the repository at this point in the history
ZCS:-11349: Toggle off/on direct searches for autocomplete
  • Loading branch information
gautamdg authored May 17, 2022
2 parents 942c64e + b387b3c commit 36756e5
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 15 deletions.
3 changes: 3 additions & 0 deletions common/src/java/com/zimbra/common/localconfig/LC.java
Original file line number Diff line number Diff line change
Expand Up @@ -1488,6 +1488,9 @@ public enum PUBLIC_SHARE_VISIBILITY { samePrimaryDomain, all, none };
// TODO: ZCS-11319 move the following from LC to LDAP property.
// space-separated list of logout urls that are known to handle token de-registration.
public static final KnownKey zimbra_web_client_logoff_urls = KnownKey.newKey("");

// ZCS-11349: Toggle off/on fallback to ldap search
public static final KnownKey zimbra_gal_fallback_ldap_search_enabled = KnownKey.newKey(true);

static {
// Automatically set the key name with the variable name.
Expand Down
41 changes: 26 additions & 15 deletions store/src/java/com/zimbra/cs/gal/GalSearchControl.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
import com.zimbra.soap.ZimbraSoapContext;
import com.zimbra.soap.admin.type.DataSourceType;
import com.zimbra.soap.type.GalSearchType;
import com.zimbra.common.localconfig.LC;

public class GalSearchControl {
private GalSearchParams mParams;
Expand Down Expand Up @@ -130,10 +131,15 @@ public void autocomplete() throws ServiceException {
}
}
// fallback to ldap search
String query = Strings.nullToEmpty(mParams.getQuery());
mParams.setQuery(query.replaceFirst("[*]*$", "*"));
mParams.getResultCallback().reset(mParams);
ldapSearch();
// ZCS-11349: Toggle off/on fallback to ldap search
if (LC.zimbra_gal_fallback_ldap_search_enabled.booleanValue()) {
String query = Strings.nullToEmpty(mParams.getQuery());
mParams.setQuery(query.replaceFirst("[*]*$", "*"));
mParams.getResultCallback().reset(mParams);
ldapSearch();
} else {
ZimbraLog.gal.debug("toggle off fallback to ldap search");
}
}

public void search() throws ServiceException {
Expand All @@ -156,19 +162,24 @@ public void search(boolean wildCardSearch) throws ServiceException {
galAcct = getGalSyncAccount();
accountSearch(galAcct, true);
} catch (GalAccountNotConfiguredException e) {
query = Strings.nullToEmpty(query);
// fallback to ldap search
if (wildCardSearch) {
if (!query.endsWith("*")) {
query = query + "*";
}
if (!query.startsWith("*")) {
query = "*" + query;
// ZCS-11349: Toggle off/on fallback to ldap search
if (LC.zimbra_gal_fallback_ldap_search_enabled.booleanValue()) {
query = Strings.nullToEmpty(query);
// fallback to ldap search
if (wildCardSearch) {
if (!query.endsWith("*")) {
query = query + "*";
}
if (!query.startsWith("*")) {
query = "*" + query;
}
}
mParams.setQuery(query);
mParams.getResultCallback().reset(mParams);
ldapSearch();
} else {
ZimbraLog.gal.debug("toggle off fallback to ldap search");
}
mParams.setQuery(query);
mParams.getResultCallback().reset(mParams);
ldapSearch();
}
}

Expand Down

0 comments on commit 36756e5

Please sign in to comment.