From 453f448ae101551b5bb05aefc069d58cc3c035ef Mon Sep 17 00:00:00 2001 From: Aron Roberts Date: Tue, 26 Mar 2013 16:16:49 -0700 Subject: [PATCH] CSPACE-5947,CSPACE-5948: Document types are now unqualified before looking up services bindings or URI templates. --- .../services/imports/TemplateExpander.java | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/services/imports/service/src/main/java/org/collectionspace/services/imports/TemplateExpander.java b/services/imports/service/src/main/java/org/collectionspace/services/imports/TemplateExpander.java index 73c85e8d6..c3e340590 100644 --- a/services/imports/service/src/main/java/org/collectionspace/services/imports/TemplateExpander.java +++ b/services/imports/service/src/main/java/org/collectionspace/services/imports/TemplateExpander.java @@ -44,6 +44,7 @@ import org.collectionspace.services.common.api.RefName; import org.collectionspace.services.common.api.RefNameUtils; import org.collectionspace.services.common.api.Tools; import org.collectionspace.services.common.config.TenantBindingConfigReaderImpl; +import org.collectionspace.services.common.context.ServiceBindingUtils; import org.collectionspace.services.config.service.DocHandlerParams; import org.collectionspace.services.config.service.ListResultField; import org.collectionspace.services.config.service.ServiceBindingType; @@ -237,7 +238,7 @@ public class TemplateExpander { String partTmpl) throws Exception { String uri = ""; UriTemplateRegistry registry = ServiceMain.getInstance().getUriTemplateRegistry(); - UriTemplateRegistryKey key = new UriTemplateRegistryKey(tenantId, docType); + UriTemplateRegistryKey key = new UriTemplateRegistryKey(tenantId, ServiceBindingUtils.getUnqualifiedTenantDocType(docType)); StoredValuesUriTemplate template = registry.get(key); if (template != null) { Map additionalValues = new HashMap(); @@ -411,12 +412,20 @@ public class TemplateExpander { } private static String getServiceName(String tenantId, String serviceType) { - ServiceBindingType serviceBinding = tReader.getServiceBindingForDocType(tenantId, serviceType); + ServiceBindingType serviceBinding = tReader.getServiceBindingForDocType(tenantId, ServiceBindingUtils.getUnqualifiedTenantDocType(serviceType)); + if (serviceBinding == null) { + logger.warn("Could not obtain service binding for tenant " + tenantId + " with document type " + serviceType); + return ""; + } return serviceBinding.getName(); } private static boolean serviceSupportsHierarchy(String tenantId, String serviceType) { - ServiceBindingType serviceBinding = tReader.getServiceBindingForDocType(tenantId, serviceType); + ServiceBindingType serviceBinding = tReader.getServiceBindingForDocType(tenantId, ServiceBindingUtils.getUnqualifiedTenantDocType(serviceType)); + if (serviceBinding == null) { + logger.warn("Could not obtain service binding for tenant " + tenantId + " with document type " + serviceType); + return false; + } DocHandlerParams params = serviceBinding.getDocHandlerParams(); if (params == null || params.getParams() == null || params.getParams().isSupportsHierarchy() == null) { return false; @@ -427,7 +436,11 @@ public class TemplateExpander { private static String getRefNameDisplayNameXpath(String tenantId, String serviceType) { String displayNameXPath = ""; - ServiceBindingType serviceBinding = tReader.getServiceBindingForDocType(tenantId, serviceType); + ServiceBindingType serviceBinding = tReader.getServiceBindingForDocType(tenantId, ServiceBindingUtils.getUnqualifiedTenantDocType(serviceType)); + if (serviceBinding == null) { + logger.warn("Could not obtain service binding for tenant " + tenantId + " with document type " + serviceType); + return ""; + } DocHandlerParams params = serviceBinding.getDocHandlerParams(); if (params == null || params.getParams() == null) { return displayNameXPath; -- 2.47.3