From 3db18e89329a6ee6af67fa771d36520f1bd7b21d Mon Sep 17 00:00:00 2001 From: Patrick Schmitz Date: Sat, 3 Dec 2011 01:47:53 +0000 Subject: [PATCH] CSPACE-3017 Made keyword search quietly absorb * chars. --- .../services/common/ResourceBase.java | 15 ++- .../query/nuxeo/QueryManagerNuxeoImpl.java | 105 +++++------------- 2 files changed, 38 insertions(+), 82 deletions(-) diff --git a/services/common/src/main/java/org/collectionspace/services/common/ResourceBase.java b/services/common/src/main/java/org/collectionspace/services/common/ResourceBase.java index 29b72a352..3bf2cbb45 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/ResourceBase.java +++ b/services/common/src/main/java/org/collectionspace/services/common/ResourceBase.java @@ -27,6 +27,7 @@ import org.collectionspace.services.client.IQueryManager; import org.collectionspace.services.client.PoxPayloadIn; import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.common.api.RefName; +import org.collectionspace.services.common.api.Tools; import org.collectionspace.services.common.authorityref.AuthorityRefList; import org.collectionspace.services.common.context.MultipartServiceContextImpl; import org.collectionspace.services.common.context.ServiceBindingUtils; @@ -277,10 +278,16 @@ public abstract class ResourceBase // perform a keyword search if (keywords != null && !keywords.isEmpty()) { String whereClause = QueryManager.createWhereClauseFromKeywords(keywords); - DocumentFilter documentFilter = handler.getDocumentFilter(); - documentFilter.appendWhereClause(whereClause, IQueryManager.SEARCH_QUALIFIER_AND); - if (logger.isDebugEnabled()) { - logger.debug("The WHERE clause is: " + documentFilter.getWhereClause()); + if(Tools.isEmpty(whereClause)) { + if (logger.isDebugEnabled()) { + logger.debug("The WHERE clause is empty for keywords: ["+keywords+"]"); + } + } else { + DocumentFilter documentFilter = handler.getDocumentFilter(); + documentFilter.appendWhereClause(whereClause, IQueryManager.SEARCH_QUALIFIER_AND); + if (logger.isDebugEnabled()) { + logger.debug("The WHERE clause is: " + documentFilter.getWhereClause()); + } } } if (advancedSearch != null && !advancedSearch.isEmpty()) { diff --git a/services/common/src/main/java/org/collectionspace/services/common/query/nuxeo/QueryManagerNuxeoImpl.java b/services/common/src/main/java/org/collectionspace/services/common/query/nuxeo/QueryManagerNuxeoImpl.java index 151f745fb..470476f25 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/query/nuxeo/QueryManagerNuxeoImpl.java +++ b/services/common/src/main/java/org/collectionspace/services/common/query/nuxeo/QueryManagerNuxeoImpl.java @@ -65,7 +65,7 @@ public class QueryManagerNuxeoImpl implements IQueryManager { private static Pattern kwdTokenizer = Pattern.compile("(?:(['\"])(.*?)(?\\\\\\\\)*\\1|([^ ]+))"); private static Pattern unescapedDblQuotes = Pattern.compile("(?