From: Aron Roberts Date: Tue, 2 Apr 2013 00:26:38 +0000 (-0700) Subject: CSPACE-5943: Handle user-provided leading wildcards. X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=634c4a17ef9919ba7c358dfb930a885a433de407;p=tmp%2Fjakarta-migration.git CSPACE-5943: Handle user-provided leading wildcards. --- diff --git a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RepositoryJavaClientImpl.java b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RepositoryJavaClientImpl.java index 943aad425..ccbed7a5a 100644 --- a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RepositoryJavaClientImpl.java +++ b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RepositoryJavaClientImpl.java @@ -919,17 +919,23 @@ public class RepositoryJavaClientImpl implements RepositoryClient queryParams = ctx.getQueryParams(); - final String partialTerm = queryParams.getFirst(IQueryManager.SEARCH_TYPE_PARTIALTERM); + String partialTerm = queryParams.getFirst(IQueryManager.SEARCH_TYPE_PARTIALTERM); + // FIXME: Resolve how to handle the case where the partial term + // query parameter is included in the request, but has been given an + // empty (blank) value. Then implement that here, if current behavior + // does not match the required behavior. + // + // (We're currently returning all records in that case.) + // FIXME: Get all of the following values from appropriate external constants. - // At present, these are duplicated in both RepositoryJavaClientImpl + // + // At present, the two constants below are duplicated in both RepositoryJavaClientImpl // and in AuthorityItemDocumentModelHandler. final String TERM_GROUP_TABLE_NAME_PARAM = "TERM_GROUP_TABLE_NAME"; final String IN_AUTHORITY_PARAM = "IN_AUTHORITY"; - final String PARENT_WILDCARD = "_ALL_"; // Get this from AuthorityResource or equivalent - - // FIXME: Replace this placeholder query with an actual query resulting - // from CSPACE-5945 work + // Get this from a constant in AuthorityResource or equivalent + final String PARENT_WILDCARD = "_ALL_"; // Start with the default query String selectStatement = @@ -949,6 +955,18 @@ public class RepositoryJavaClientImpl implements RepositoryClient params = new ArrayList<>(); + // Handle user-provided leading wildcard characters, in the + // configuration where a leading wildcard is not automatically inserted. + // (The user-provided wildcard must be in the first character position + // in the partial term value.) + // + // FIXME: Read tenant bindings configuration to determine whether + // to automatically insert leading, as well as trailing, wildcards + // into the term matching string. + // + // FIXME: Get this value from an existing constant, if available + final String USER_SUPPLIED_WILDCARD = "*"; + partialTerm = handleProvidedLeadingWildcard(partialTerm, USER_SUPPLIED_WILDCARD); params.add(partialTerm + JDBCTools.SQL_WILDCARD); // Value for replaceable parameter 1 in the query // Restrict the query to filter out deleted records, if requested @@ -1006,7 +1024,11 @@ public class RepositoryJavaClientImpl implements RepositoryClient