From b73795b7ca26bbcdb3a84b3129384d51defd3f0c Mon Sep 17 00:00:00 2001 From: Richard Millet Date: Mon, 15 Jul 2013 16:38:05 -0700 Subject: [PATCH] CSPACE-5678-D: Adding support for new Application generated tenant-specific prototype service bindings. --- .../config/TenantBindingConfigReaderImpl.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) 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 6f1e41f20..8e778db28 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 @@ -175,7 +175,7 @@ public class TenantBindingConfigReaderImpl JEEServerDeployment.TENANT_BINDINGS_PROTOTYPE_FILENAME); List tenantDirs = getDirectories(tenantsRootDir); - tenantBindingTypeList = readTenantConfigs(protoBindingsFile, tenantDirs); + tenantBindingTypeList = readTenantConfigs(protoBindingsFile, tenantDirs, useAppGeneratedBindings); for (TenantBindingType tenantBinding : tenantBindingTypeList) { if(tenantBindings.get(tenantBinding.getId()) != null) { @@ -237,17 +237,29 @@ public class TenantBindingConfigReaderImpl * @return A list of tenant bindings. * @throws IOException Signals that an I/O exception has occurred. */ - List readTenantConfigs(File protoBindingsFile, List tenantDirList) throws IOException { - List result = new ArrayList(); + List readTenantConfigs(File protoBindingsDir, List tenantDirList, boolean useAppGeneratedBindings) throws IOException { + List result = new ArrayList(); + // // Iterate through a list of directories. // for (File tenantDir : tenantDirList) { boolean found = false; String errMessage = null; + + File tenantBindingsProtoFile = null; + 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 { + tenantBindingsProtoFile = new File(protoBindingsDir + File.separator + + JEEServerDeployment.TENANT_BINDINGS_PROTOTYPE_FILENAME); + } + File configFile = new File(tenantDir.getAbsoluteFile() + File.separator + getFileName()); if (configFile.exists() == true) { - InputStream tenantBindingsStream = this.merge(protoBindingsFile, configFile); + InputStream tenantBindingsStream = this.merge(tenantBindingsProtoFile, configFile); TenantBindingConfig tenantBindingConfig = null; try { tenantBindingConfig = (TenantBindingConfig) parse(tenantBindingsStream, -- 2.47.3