ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(getItemServiceName(), queryParams);
String itemcsid = lookupItemCSID(itemspecifier, parentcsid, "getReferencingObjects(item)", "GET_ITEM_REF_OBJS", ctx);
- String serviceType = ServiceBindingUtils.SERVICE_TYPE_PROCEDURE;
- List<String> list = queryParams.remove(ServiceBindingUtils.SERVICE_TYPE_PROP);
- if (list != null) {
- serviceType = list.get(0);
+ List<String> serviceTypes = queryParams.remove(ServiceBindingUtils.SERVICE_TYPE_PROP);
+ if(serviceTypes == null || serviceTypes.isEmpty()) {
+ serviceTypes = ServiceBindingUtils.getCommonServiceTypes();
}
- // Could be smarter about using the list from above, and/or allowing multiple
- ArrayList<String> serviceTypes = new ArrayList<String>(1);
- serviceTypes.add(serviceType);
// Note that we have to create the service context for the Items, not the main service
// We omit the parentShortId, only needed when doing a create...
public AuthorityRefDocList getReferencingObjects(
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
- ArrayList<String> serviceTypes,
+ List<String> serviceTypes,
String propertyName,
String itemcsid) throws Exception {
AuthorityRefDocList authRefDocList = null;
<types:key>authRef</types:key>
<types:value>taxonomicIdentGroupList/*/institution</types:value>
</types:item>
+ <!--
<types:item xmlns:types="http://collectionspace.org/services/common/types">
<types:key>authRef</types:key>
<types:value>annotationGroupList/*/annotationAuthor</types:value>
</types:item>
+ -->
</service:properties>
<service:content contentType="application/xml">
<service:xmlContent namespaceURI="http://collectionspace.org/services/collectionobject/domain/naturalhistory" schemaLocation="http://collectionspace.org/services/collectionobject/domain/naturalhistory http://collectionspace.org/services/collectionobject/domain/collectionobjects_naturalhistory.xsd" />
import java.util.ArrayList;\r
import java.util.List;\r
import java.util.Map;\r
+import java.util.regex.Matcher;\r
+import java.util.regex.Pattern;\r
+import java.util.regex.PatternSyntaxException;\r
\r
import org.collectionspace.services.common.config.PropertyItemUtils;\r
import org.collectionspace.services.common.service.ObjectPartType;\r
public static final String SERVICE_TYPE_AUTHORITY = "authority";\r
public static final String SERVICE_TYPE_UTILITY = "utility";\r
public static final String SERVICE_TYPE_SECURITY = "security";\r
+ \r
+ private static final String TENANT_EXTENSION_PATTERN = "(.*)"+ServiceContext.TENANT_SUFFIX+"[\\d]+$";\r
+ private static final String TENANT_REPLACEMENT_PATTERN = "$1";\r
+ private static Pattern tenantSuffixPattern = null;\r
\r
private static final Logger logger = LoggerFactory.getLogger(ServiceBindingUtils.class);\r
\r
return result;\r
}\r
\r
+ public static String getUnqualifiedTenantDocType(String docType) {\r
+ try {\r
+ if(tenantSuffixPattern == null ) {\r
+ tenantSuffixPattern = Pattern.compile(TENANT_EXTENSION_PATTERN);\r
+ }\r
+ Matcher tenantSuffixMatcher = tenantSuffixPattern.matcher(docType);\r
+ return tenantSuffixMatcher.replaceFirst(TENANT_REPLACEMENT_PATTERN);\r
+ } catch (PatternSyntaxException pe) {\r
+ logger.warn("TENANT_EXTENSION_PATTERN regex pattern '" + TENANT_EXTENSION_PATTERN\r
+ + "' could not be compiled: " + pe.getMessage());\r
+ // If reached, method will return a value of false.\r
+ }\r
+ return docType;\r
+ }\r
+ \r
// TODO consider building up a hashTable of the properties for each\r
// service binding. There will be generic properties, as well as\r
// properties on each part. Could build up a key from tenant id, \r
AuthorityRefDocList.AuthorityRefDocItem ilistItem;\r
\r
String docType = docModel.getDocumentType().getName();\r
+ docType = ServiceBindingUtils.getUnqualifiedTenantDocType(docType);\r
ServiceBindingType sb = queriedServiceBindings.get(docType);\r
if (sb == null) {\r
throw new RuntimeException(\r
DocumentModel itemDocModel = NuxeoUtils.getDocFromCsid(ctx, this.getRepositorySession(), itemCsid); //null if not found.
if (itemDocModel != null) {
String itemDocType = itemDocModel.getDocumentType().getName();
+ itemDocType = ServiceBindingUtils.getUnqualifiedTenantDocType(itemDocType);
if (Tools.isBlank(documentType)) {
item.setDocumentType(itemDocType);
}
HashMap<String,Object> properties = new HashMap<String,Object>();
try {
- String doctype = (String) subjectOrObjectDocModel.getType();
+ String doctype = subjectOrObjectDocModel.getDocumentType().getName();
+ doctype = ServiceBindingUtils.getUnqualifiedTenantDocType(doctype);
properties.put((fSubject?RelationJAXBSchema.SUBJECT_DOCTYPE:RelationJAXBSchema.OBJECT_DOCTYPE),
doctype);
while (iter.hasNext()) {
DocumentModel docModel = iter.next();
String docType = docModel.getDocumentType().getName();
+ docType = ServiceBindingUtils.getUnqualifiedTenantDocType(docType);
ServiceBindingType sb = queriedServiceBindings.get(docType);
if (sb == null) {
throw new RuntimeException(