]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-4693 - working on using lifesci tenant to prove the merge code works as we...
authorPatrick Schmitz <pschmitz@berkeley.edu>
Tue, 27 Mar 2012 15:48:29 +0000 (08:48 -0700)
committerPatrick Schmitz <pschmitz@berkeley.edu>
Tue, 27 Mar 2012 15:48:29 +0000 (08:48 -0700)
services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java
services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java
services/common/src/main/cspace/config/services/tenants/lifesci/tenant-bindings.delta.xml
services/common/src/main/java/org/collectionspace/services/common/context/ServiceBindingUtils.java
services/common/src/main/java/org/collectionspace/services/common/vocabulary/RefNameServiceUtils.java
services/relation/service/src/main/java/org/collectionspace/services/relation/nuxeo/RelationDocumentModelHandler.java
services/servicegroup/service/src/main/java/org/collectionspace/services/servicegroup/nuxeo/ServiceGroupDocumentModelHandler.java

index b5119587dd078c28af7dc732728a34b7937468ce..07d717397a74d79956cd6affaf4a5677b43864a5 100644 (file)
@@ -743,14 +743,10 @@ public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
             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...
index 0daa61835bf462358f29620f38e2e4da97ffa91f..32f49c4513d2869c242de48072588b1f728b89e0 100644 (file)
@@ -353,7 +353,7 @@ public abstract class AuthorityItemDocumentModelHandler<AICommon>
     
     public AuthorityRefDocList getReferencingObjects(
                ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
-               ArrayList<String> serviceTypes,
+               List<String> serviceTypes,
                String propertyName,
             String itemcsid) throws Exception {
         AuthorityRefDocList authRefDocList = null;
index 2cd346a9de5f5954834efb1e1e6c647ce57f915d..3de2dde8a9db3e565887099e0cb9ac5a96675a76 100644 (file)
                                                <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" />
index 248ad43c880e0a13660d9991c492ed34b8c13933..9d6afc82d53ac0c7f24efcedfed517a1425442ba 100644 (file)
@@ -3,6 +3,9 @@ package org.collectionspace.services.common.context;
 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
@@ -32,6 +35,10 @@ public class ServiceBindingUtils {
        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
@@ -40,6 +47,21 @@ public class ServiceBindingUtils {
        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
index 92a01600658386c36747bda44098d227f0afeb3c..d26682120bd20038b90abac6c210a08c997b8bff 100644 (file)
@@ -436,6 +436,7 @@ public class RefNameServiceUtils {
             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
index ebd2323fcf8cdab4a5582906b5a35f25944afff4..cdf35a9d9c668c539a63bd35febc5a47524f8172 100644 (file)
@@ -261,6 +261,7 @@ public class RelationDocumentModelHandler
         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);
             }
@@ -360,7 +361,8 @@ public class RelationDocumentModelHandler
        
         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);
        
index 207321b810d1608b2ba050d4798bada0732632ba..3eea303d0c9caaffa01b287d385d5f3073d703ec 100644 (file)
@@ -212,6 +212,7 @@ public class ServiceGroupDocumentModelHandler
         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(