From: Aron Roberts Date: Thu, 4 Apr 2013 20:33:33 +0000 (-0700) Subject: CSPACE-5943: Added stub code for restricting by tenant ID, where needed. Explicitly... X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=b9f929a2bdab6a2469775d12f64496c5a75c9d4e;p=tmp%2Fjakarta-migration.git CSPACE-5943: Added stub code for restricting by tenant ID, where needed. Explicitly handle cases where partial term query parameter value is blank. Multiple improvements to comments and log statements. --- 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 aa42de7db..ef460e73d 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 @@ -918,20 +918,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient queryParams = ctx.getQueryParams(); - 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 ("...?pt=") Then implement the required - // behavior here, if current behavior does not match what is required. - // - // (We're currently returning all records in that case.) - + // FIXME: Get all of the following values from appropriate external constants. // // At present, the two constants below are duplicated in both RepositoryJavaClientImpl @@ -952,15 +939,34 @@ public class RepositoryJavaClientImpl implements RepositoryClient queryParams = ctx.getQueryParams(); + String partialTerm = queryParams.getFirst(IQueryManager.SEARCH_TYPE_PARTIALTERM); + // If the value of the partial term query parameter is blank ('pt='), + // return all records, subject to restriction by any limit clause + if (Tools.isBlank(partialTerm)) { + whereClause = ""; + } else { + // Otherwise, return records that match the supplied partial term + whereClause = " WHERE (termgroup.termdisplayname ILIKE ?) "; + } + // FIXME: At present, we are planning to order results in code, + // by sorting the returned list of DocumentModels. + // + // To implement the orderByClause below in SQL, rather than in code; + // e.g. via 'ORDER BY termgroup.termdisplayname', that column must be + // returned by the SELECT statement. + String orderByClause = ""; + + String limitClause; TenantBindingConfigReaderImpl tReader = ServiceMain.getInstance().getTenantBindingConfigReader(); TenantBindingType tenantBinding = tReader.getTenantBinding(ctx.getTenantId()); String maxListItemsLimit = TenantBindingUtils.getPropertyValue(tenantBinding, IQueryManager.MAX_LIST_ITEMS_RETURNED_LIMIT_ON_JDBC_QUERIES); - String limitClause = + limitClause = " LIMIT " + getMaxItemsLimitOnJdbcQueries(maxListItemsLimit); // implicit int-to-String conversion List params = new ArrayList<>(); @@ -1010,16 +1016,40 @@ public class RepositoryJavaClientImpl implements RepositoryClient docIds = new HashSet<>(); try (CachedRowSet crs = JDBCTools.executePreparedQuery(jdbcFilterQueryBuilder, dataSourceName, repositoryName, sql)) { @@ -1053,7 +1083,7 @@ public class RepositoryJavaClientImpl implements RepositoryClient