]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-5678-D: Adding more support for backward compat with old merging model.
authorRichard Millet <richard.millet@berkeley.edu>
Thu, 18 Jul 2013 05:14:19 +0000 (22:14 -0700)
committerRichard Millet <richard.millet@berkeley.edu>
Thu, 18 Jul 2013 05:14:19 +0000 (22:14 -0700)
.gitignore
services/common/src/main/cspace/config/services/tenants/core/core-tenant-bindings.delta.xml [new file with mode: 0644]
services/common/src/main/cspace/config/services/tenants/lifesci/lifesci-tenant-bindings.delta.xml [new file with mode: 0644]
services/common/src/main/java/org/collectionspace/services/common/config/TenantBindingConfigReaderImpl.java

index 6224def2606ab10fafa5311a90d1816fd7258cff..18704a9c0b3b2afb169a4c0f8b5f1db6dcde1e1f 100644 (file)
@@ -1,3 +1,9 @@
+3rdparty/nuxeo/nuxeo-platform-listener/updateobjectlocationonmove/.classpath
+3rdparty/nuxeo/nuxeo-platform-listener/updateobjectlocationonmove/.project
+3rdparty/nuxeo/nuxeo-platform-listener/updateobjectlocationonmove/.settings/
+3rdparty/nuxeo/nuxeo-platform-listener/updaterelationsondelete/.classpath
+3rdparty/nuxeo/nuxeo-platform-listener/updaterelationsondelete/.project
+3rdparty/nuxeo/nuxeo-platform-listener/updaterelationsondelete/.settings/
 3rdparty/nuxeo/nuxeo-platform-listener/.project
 3rdparty/nuxeo/nuxeo-platform-listener/.settings/
 services/JaxRsServiceProvider/.settings/.jsdtscope
diff --git a/services/common/src/main/cspace/config/services/tenants/core/core-tenant-bindings.delta.xml b/services/common/src/main/cspace/config/services/tenants/core/core-tenant-bindings.delta.xml
new file mode 100644 (file)
index 0000000..783708d
--- /dev/null
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<tenant:TenantBindingConfig
+       xmlns:merge='http://xmlmerge.el4j.elca.ch'
+       xmlns:tenant='http://collectionspace.org/services/config/tenant'>
+                
+    <tenant:tenantBinding id="1" name="core.collectionspace.org" displayName="CollectionSpace Core Demo Tenant" version="0.1">
+        <tenant:repositoryDomain name="default-domain" storageName="core-domain" repositoryClient="nuxeo-java" />
+    </tenant:tenantBinding>
+                      
+</tenant:TenantBindingConfig>
diff --git a/services/common/src/main/cspace/config/services/tenants/lifesci/lifesci-tenant-bindings.delta.xml b/services/common/src/main/cspace/config/services/tenants/lifesci/lifesci-tenant-bindings.delta.xml
new file mode 100644 (file)
index 0000000..2a58b41
--- /dev/null
@@ -0,0 +1,116 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<tenant:TenantBindingConfig xmlns:merge="http://xmlmerge.el4j.elca.ch" xmlns:tenant="http://collectionspace.org/services/config/tenant">
+
+       <tenant:tenantBinding id="2" name="lifesci.collectionspace.org" displayName="Life Sciences/Natural History Demo Tenant" version="0.1">
+
+               <tenant:repositoryDomain name="default-domain" storageName="lifesci_domain" repositoryName="lifesci_domain" repositoryClient="nuxeo-java"/>
+
+               <tenant:serviceBindings merge:matcher="id" id="CollectionObjects">
+                       <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/config/service">
+                               <service:params>
+                                       <service:ListResultsFields>
+                                               <service:ListResultField merge:matcher="skip" merge:action="insert">
+                                                       <service:element>taxon</service:element>
+                                                       <service:schema>collectionobjects_naturalhistory</service:schema>
+                                                       <service:xpath>taxonomicIdentGroupList/[0]/taxon</service:xpath>
+                                               </service:ListResultField>
+                                       </service:ListResultsFields>
+                               </service:params>
+                       </service:DocHandlerParams>
+
+                       <service:object xmlns:service="http://collectionspace.org/services/config/service">
+                               <service:part id="3" merge:matcher="skip" merge:action="insert" control_group="Managed" versionable="true" auditable="false" label="collectionobjects_naturalhistory" updated="" order="3">
+                                       <!-- Include authRefs for fields in the added schema -->
+                                       <service:properties>
+                                               <types:item xmlns:types="http://collectionspace.org/services/config/types">
+                                                       <types:key>authRef</types:key>
+                                                       <types:value>taxonomicIdentGroupList/*/taxon</types:value>
+                                               </types:item>
+                                               <types:item xmlns:types="http://collectionspace.org/services/config/types">
+                                                       <types:key>authRef</types:key>
+                                                       <types:value>associatedTaxaGroupList/*/taxon</types:value>
+                                               </types:item>
+                                               <types:item xmlns:types="http://collectionspace.org/services/config/types">
+                                                       <types:key>authRef</types:key>
+                                                       <types:value>taxonomicIdentGroupList/*/identBy</types:value>
+                                               </types:item>
+                                               <types:item xmlns:types="http://collectionspace.org/services/config/types">
+                                                       <types:key>authRef</types:key>
+                                                       <types:value>taxonomicIdentGroupList/*/institution</types:value>
+                                               </types:item>
+                                               <!--
+                                       <types:item xmlns:types="http://collectionspace.org/services/config/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"/>
+                                       </service:content>
+                               </service:part>
+                       </service:object>
+
+               </tenant:serviceBindings>
+
+               <tenant:serviceBindings merge:matcher="id" id="Movements">
+                       <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/config/service">
+                               <service:params>
+                                       <service:SupportsVersioning>true</service:SupportsVersioning>
+                                       <service:ListResultsFields merge:action="preserve"/>
+                               </service:params>
+                       </service:DocHandlerParams>
+               </tenant:serviceBindings>
+
+               <tenant:serviceBindings merge:matcher="id" id="Persons">
+                       <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/config/service">
+                               <service:params>
+                                       <service:ListResultsFields>
+                                               <service:ListResultField merge:matcher="skip" merge:action="insert">
+                                                       <service:element>entityType</service:element>
+                                                       <service:schema>persons_naturalhistory</service:schema>
+                                                       <service:xpath>entityType</service:xpath>
+                                               </service:ListResultField>
+                                       </service:ListResultsFields>
+                               </service:params>
+                       </service:DocHandlerParams>
+
+                       <service:object xmlns:service="http://collectionspace.org/services/config/service">
+                               <service:part id="3" merge:matcher="skip" merge:action="insert" control_group="Managed" versionable="true" auditable="false" label="persons_naturalhistory" updated="" order="3">
+                                       <service:content contentType="application/xml">
+                                               <service:xmlContent namespaceURI="http://collectionspace.org/services/person/domain/naturalhistory" schemaLocation="http://collectionspace.org/services/person/domain/naturalhistory http://collectionspace.org/services/person/domain/persons_naturalhistory.xsd"/>
+                                       </service:content>
+                                       <service:properties>
+                                               <!-- See CSPACE-3938 for potential additional authRef and termRef entries -->
+                                               <types:item xmlns:types="http://collectionspace.org/services/config/types">
+                                                       <types:key>authRef</types:key>
+                                                       <types:value>affiliatedPersonOrgGroupList/*/affiliatedPersonOrg</types:value>
+                                               </types:item>
+                                               <types:item xmlns:types="http://collectionspace.org/services/config/types">
+                                                       <types:key>authRef</types:key>
+                                                       <types:value>orgContactNames|orgContactName</types:value>
+                                               </types:item>
+                                               <types:item xmlns:types="http://collectionspace.org/services/config/types">
+                                                       <types:key>termRef</types:key>
+                                                       <types:value>affiliatedPersonOrgGroupList/*/affiliatedPersonOrgType</types:value>
+                                               </types:item>
+                                               <types:item xmlns:types="http://collectionspace.org/services/config/types">
+                                                       <types:key>termRef</types:key>
+                                                       <types:value>nameTypes|nameType</types:value>
+                                               </types:item>
+                                               <types:item xmlns:types="http://collectionspace.org/services/config/types">
+                                                       <types:key>termRef</types:key>
+                                                       <types:value>nameSource</types:value>
+                                               </types:item>
+                                               <types:item xmlns:types="http://collectionspace.org/services/config/types">
+                                                       <types:key>termRef</types:key>
+                                                       <types:value>entityType</types:value>
+                                               </types:item>
+                                       </service:properties>
+                               </service:part>
+                       </service:object>
+               </tenant:serviceBindings>
+
+       </tenant:tenantBinding>
+
+</tenant:TenantBindingConfig>
index 8e778db28338f4f0dd5a3d0f5915f8b793fd1ae0..05504aa1b4f1616a90612eefa79a8345a3ecb097 100644 (file)
@@ -58,9 +58,10 @@ import org.slf4j.LoggerFactory;
  */
 public class TenantBindingConfigReaderImpl
         extends AbstractConfigReaderImpl<List<TenantBindingType>> {
-    final private static String TENANT_BINDINGS_ERROR = "Tenant bindings error: ";
+    final private static String TENANT_BINDINGS_ERROR = "Tenant bindings error(s) for tenant: ";
     final private static String TENANT_BINDINGS_DELTA_FILENAME = JEEServerDeployment.TENANT_BINDINGS_FILENAME_PREFIX + ".delta.xml";
     final private static String MERGED_SUFFIX = ".merged.xml";
+       private static final String NO_SERVICE_BINDINGS_FOUND_ERR = "No Service bindings found.";
     
     final Logger logger = LoggerFactory.getLogger(TenantBindingConfigReaderImpl.class);
     private List<TenantBindingType> tenantBindingTypeList;
@@ -88,6 +89,17 @@ public class TenantBindingConfigReaderImpl
         return TENANT_BINDINGS_DELTA_FILENAME;
     }
     
+    private String getFileName(String tenantName, boolean useAppGeneratedBindings) {
+       String result = getFileName();
+       
+       if (useAppGeneratedBindings == true) {
+               result = tenantName + "-" + result;
+       }
+       
+       return result;
+    }
+    
+    
        protected File getTenantsRootDir() {
                File result = null;
                String errMessage = null;
@@ -171,14 +183,15 @@ public class TenantBindingConfigReaderImpl
                throw new Exception("Cound not find tenant bindings root directory: " +
                                tenantRootDirPath);
         }
-        File protoBindingsFile = new File(tenantRootDirPath + File.separator +
-                       JEEServerDeployment.TENANT_BINDINGS_PROTOTYPE_FILENAME);
         
         List<File> tenantDirs = getDirectories(tenantsRootDir);
-        tenantBindingTypeList = readTenantConfigs(protoBindingsFile, tenantDirs, useAppGeneratedBindings);
+        tenantBindingTypeList = readTenantConfigs(new File(tenantRootDirPath), tenantDirs, useAppGeneratedBindings);
+        if (tenantBindingTypeList == null || tenantBindingTypeList.size() < 1) {
+               throw new Exception(NO_SERVICE_BINDINGS_FOUND_ERR);
+        }
         
         for (TenantBindingType tenantBinding : tenantBindingTypeList) {
-               if(tenantBindings.get(tenantBinding.getId()) != null) {
+               if (tenantBindings.get(tenantBinding.getId()) != null) {
                        TenantBindingType tenantBindingOld = tenantBindings.get(tenantBinding.getId());
                 logger.error("Ignoring duplicate binding definition for tenant id=" 
                                + tenantBinding.getId()
@@ -248,8 +261,8 @@ public class TenantBindingConfigReaderImpl
                        String errMessage = null;
                        
                        File tenantBindingsProtoFile = null;
+                       String tenantName = tenantDir.getName(); // By convention, the directory name should be the tenant name
                        if (useAppGeneratedBindings == true) {
-                               String tenantName = tenantDir.getName(); // By convention, the directory name should be the tenant name
                                tenantBindingsProtoFile = new File(protoBindingsDir.getAbsolutePath() + File.separator + tenantName +
                                                "-" + JEEServerDeployment.TENANT_BINDINGS_PROTOTYPE_FILENAME);
                        } else {
@@ -257,37 +270,42 @@ public class TenantBindingConfigReaderImpl
                                        JEEServerDeployment.TENANT_BINDINGS_PROTOTYPE_FILENAME);                                
                        }
                        
-                       File configFile = new File(tenantDir.getAbsoluteFile() + File.separator + getFileName());
-                       if (configFile.exists() == true) {
-                       InputStream tenantBindingsStream = this.merge(tenantBindingsProtoFile, configFile);
-                       TenantBindingConfig tenantBindingConfig = null;
-                       try {
-                                       tenantBindingConfig = (TenantBindingConfig) parse(tenantBindingsStream,
-                                                       TenantBindingConfig.class);
-                       } catch (Exception e) {
-                               logger.error("Could not parse the merged tenant bindings.", e);
-                       }
-                               if (tenantBindingConfig != null) {
-                                       TenantBindingType binding = tenantBindingConfig.getTenantBinding();
-                                       if (binding != null) {
-                                               result.add(binding);
-                                               found = true;
-                                               if (logger.isInfoEnabled() == true) {
-                                                       logger.info("Parsed tenant configureation for: " + binding.getDisplayName());
+                       if (tenantBindingsProtoFile.exists() == true) {
+                               File configFile = new File(tenantDir.getAbsoluteFile() + File.separator + getFileName(tenantName, useAppGeneratedBindings));
+                               if (configFile.exists() == true) {
+                               InputStream tenantBindingsStream = this.merge(tenantBindingsProtoFile, configFile);
+                               TenantBindingConfig tenantBindingConfig = null;
+                               try {
+                                               tenantBindingConfig = (TenantBindingConfig) parse(tenantBindingsStream,
+                                                               TenantBindingConfig.class);
+                               } catch (Exception e) {
+                                       logger.error("Could not parse the merged tenant bindings.", e);
+                               }
+                                       if (tenantBindingConfig != null) {
+                                               TenantBindingType binding = tenantBindingConfig.getTenantBinding();
+                                               if (binding != null) {
+                                                       result.add(binding);
+                                                       found = true;
+                                                       if (logger.isInfoEnabled() == true) {
+                                                               logger.info("Parsed tenant configureation for: " + binding.getDisplayName());
+                                                       }
+                                               } else {
+                                                       errMessage = "Cound not parse the tentant bindings in: ";
                                                }
                                        } else {
-                                               errMessage = "Cound not parse the tentant bindings in: ";
+                                               errMessage = "Could not parse the tenant bindings file: ";                              
                                        }
                                } else {
-                                       errMessage = "Could not parse the tenant bindings file: ";                              
+                                       errMessage = "Expected to, but could not, find the tenant delta configuration file: " + configFile.getAbsolutePath();
                                }
                        } else {
-                               errMessage = "Cound not find a tenant configuration file: ";
+                               errMessage = "Expected to, but could not, find the tenant proto configuration file: " + tenantBindingsProtoFile.getAbsolutePath();
                        }
+                       
                        if (found == false) {
                                if (logger.isErrorEnabled() == true) {
                                        errMessage = errMessage != null ? errMessage : TENANT_BINDINGS_ERROR;
-                                       logger.error(errMessage + configFile.getAbsolutePath());
+                                       logger.error(errMessage + tenantName);
                                }
                        }
                } // else-for