From: Richard Millet Date: Thu, 18 Jul 2013 05:14:19 +0000 (-0700) Subject: CSPACE-5678-D: Adding more support for backward compat with old merging model. X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=65aa382ba44cbfb026f8e5f656416d7e2de7b018;p=tmp%2Fjakarta-migration.git CSPACE-5678-D: Adding more support for backward compat with old merging model. --- diff --git a/.gitignore b/.gitignore index 6224def26..18704a9c0 100644 --- a/.gitignore +++ b/.gitignore @@ -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 index 000000000..783708d19 --- /dev/null +++ b/services/common/src/main/cspace/config/services/tenants/core/core-tenant-bindings.delta.xml @@ -0,0 +1,10 @@ + + + + + + + + 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 index 000000000..2a58b41b1 --- /dev/null +++ b/services/common/src/main/cspace/config/services/tenants/lifesci/lifesci-tenant-bindings.delta.xml @@ -0,0 +1,116 @@ + + + + + + + + + + + + + taxon + collectionobjects_naturalhistory + taxonomicIdentGroupList/[0]/taxon + + + + + + + + + + + authRef + taxonomicIdentGroupList/*/taxon + + + authRef + associatedTaxaGroupList/*/taxon + + + authRef + taxonomicIdentGroupList/*/identBy + + + authRef + taxonomicIdentGroupList/*/institution + + + + + + + + + + + + + + + true + + + + + + + + + + + entityType + persons_naturalhistory + entityType + + + + + + + + + + + + + + authRef + affiliatedPersonOrgGroupList/*/affiliatedPersonOrg + + + authRef + orgContactNames|orgContactName + + + termRef + affiliatedPersonOrgGroupList/*/affiliatedPersonOrgType + + + termRef + nameTypes|nameType + + + termRef + nameSource + + + termRef + entityType + + + + + + + + + diff --git a/services/common/src/main/java/org/collectionspace/services/common/config/TenantBindingConfigReaderImpl.java b/services/common/src/main/java/org/collectionspace/services/common/config/TenantBindingConfigReaderImpl.java index 8e778db28..05504aa1b 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/config/TenantBindingConfigReaderImpl.java +++ b/services/common/src/main/java/org/collectionspace/services/common/config/TenantBindingConfigReaderImpl.java @@ -58,9 +58,10 @@ import org.slf4j.LoggerFactory; */ public class TenantBindingConfigReaderImpl extends AbstractConfigReaderImpl> { - 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 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 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