From 29587a674bea2eba79ee20ef5c9d8192b189b9bd Mon Sep 17 00:00:00 2001 From: Aron Roberts Date: Mon, 1 Apr 2013 20:22:33 -0700 Subject: [PATCH] CSPACE-5943: Initial attempt at reflecting tenant bindings configuration settings on whether to include a starting wildcard in partial term matches, as yet untested. --- .../client/java/RepositoryJavaClientImpl.java | 35 +++++++++++++------ 1 file changed, 24 insertions(+), 11 deletions(-) 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 ea900db80..781b0b58a 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 @@ -76,7 +76,11 @@ import org.nuxeo.runtime.transaction.TransactionRuntimeException; // import org.apache.chemistry.opencmis.commons.server.CallContext; import org.apache.chemistry.opencmis.server.impl.CallContextImpl; +import org.collectionspace.services.common.ServiceMain; import org.collectionspace.services.common.api.Tools; +import org.collectionspace.services.common.config.TenantBindingConfigReaderImpl; +import org.collectionspace.services.common.config.TenantBindingUtils; +import org.collectionspace.services.config.tenant.TenantBindingType; import org.nuxeo.ecm.core.opencmis.impl.server.NuxeoCmisService; import org.nuxeo.ecm.core.opencmis.impl.server.NuxeoRepository; @@ -955,18 +959,25 @@ 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 + + // 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); + TenantBindingConfigReaderImpl tReader = + ServiceMain.getInstance().getTenantBindingConfigReader(); + TenantBindingType tenantBinding = tReader.getTenantBinding(ctx.getTenantId()); + String usesStartingWildcard = TenantBindingUtils.getPropertyValue(tenantBinding, + IQueryManager.TENANT_USES_STARTING_WILDCARD_FOR_PARTIAL_TERM); + // 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, or "starting" + // character position in the partial term value.) + if (Tools.notBlank(usesStartingWildcard) && usesStartingWildcard.equalsIgnoreCase(Boolean.FALSE.toString())) { + partialTerm = handleProvidedStartingWildcard(partialTerm); + // Otherwise, automatically insert a leading wildcard + } else { + partialTerm = JDBCTools.SQL_WILDCARD + partialTerm; + } // Automatically insert a trailing wildcard params.add(partialTerm + JDBCTools.SQL_WILDCARD); // Value for replaceable parameter 1 in the query @@ -1643,8 +1654,10 @@ public class RepositoryJavaClientImpl implements RepositoryClient