readConfig();\r
setDataSources();\r
propagateConfiguredProperties();\r
- \r
- // Ensure that Nuxeo repository config files exist for each repository\r
- // specified in tenant bindings.\r
- \r
- // Get the prototype copy of the Nuxeo repository config file.\r
- // This file will then be cloned, creating a separate config file\r
- // for each repository.\r
- File prototypeNuxeoConfigFile =\r
- new File(getNuxeoConfigDir() + File.separator + getNuxeoProtoConfigFilename());\r
- logger.warn("Prototype Nuxeo config file path=" + prototypeNuxeoConfigFile.getCanonicalPath());\r
- if (! prototypeNuxeoConfigFile.canRead()) {\r
- String msg = String.format("Could not find and/or read the prototype Nuxeo config file '%s'",\r
- prototypeNuxeoConfigFile.getCanonicalPath());\r
- throw new RuntimeException(msg);\r
- }\r
- logger.warn("Can read prototype Nuxeo config file.");\r
- Document prototypeConfigDoc = XmlTools.fileToXMLDocument(prototypeNuxeoConfigFile);\r
- Document repositoryConfigDoc = null;\r
- // FIXME: Can the variable below reasonably be made a class variable? Its value\r
- // is used in at least one other method in this class.\r
- Hashtable<String, TenantBindingType> tenantBindingTypeMap = tenantBindingConfigReader.getTenantBindings();\r
- for (TenantBindingType tbt : tenantBindingTypeMap.values()) {\r
- List<String> repositoryNameList = ConfigUtils.getRepositoryNameList(tbt);\r
- logger.warn("Getting repository name(s) for tenant " + tbt.getName());\r
- if (repositoryNameList == null || repositoryNameList.isEmpty() == true) {\r
- logger.warn(String.format("Could not get repository name(s) for tenant %s", tbt.getName()));\r
- continue;\r
- } else {\r
- for (String repositoryName : repositoryNameList) {\r
- if (Tools.isBlank(repositoryName)) {\r
- continue;\r
- }\r
- logger.warn(String.format("Repository name is %s", repositoryName));\r
- repositoryConfigDoc = (Document) prototypeConfigDoc.clone();\r
- // Update the newly-cloned repository config file by inserting\r
- // values specific to the current repo.\r
- repositoryConfigDoc = updateRepositoryConfigDoc(repositoryConfigDoc, repositoryName);\r
- logger.warn("repositoryConfigDoc=\n" + repositoryConfigDoc.asXML());\r
- // Write this repository config file to the Nuxeo server config directory.\r
- File repofile = new File(getNuxeoConfigDir() + File.separator +\r
- repositoryName + JEEServerDeployment.NUXEO_REPO_CONFIG_FILENAME_SUFFIX);\r
- logger.warn(String.format("Repository config filepath is %s", repofile.getAbsolutePath()));\r
- XmlTools.xmlDocumentToFile(repositoryConfigDoc, repofile);\r
- }\r
- }\r
- }\r
- \r
+ createOrUpdateNuxeoRepositoryConfigFiles();\r
+ \r
//\r
// Start up and initialize our embedded Nuxeo server instance\r
//\r
return uriTemplateRegistry;\r
}\r
\r
+ /**\r
+ * Ensure that Nuxeo repository configuration files exist for each repository\r
+ * specified in tenant bindings. Create or update these files, as needed.\r
+ */\r
+ private void createOrUpdateNuxeoRepositoryConfigFiles() throws Exception {\r
+ \r
+ // Get the prototype copy of the Nuxeo repository config file.\r
+ File prototypeNuxeoConfigFile =\r
+ new File(getNuxeoConfigDir() + File.separator + getNuxeoProtoConfigFilename());\r
+ // FIXME: Consider checking for the presence of existing configuration files,\r
+ // rather than always failing outright if the prototype file for creating\r
+ // new or updated files can't be located.\r
+ if (! prototypeNuxeoConfigFile.canRead()) {\r
+ String msg = String.format("Could not find and/or read the prototype Nuxeo config file '%s'",\r
+ prototypeNuxeoConfigFile.getCanonicalPath());\r
+ throw new RuntimeException(msg);\r
+ }\r
+ if (logger.isTraceEnabled()) {\r
+ logger.trace("Found and can read prototype Nuxeo config file at path %s", prototypeNuxeoConfigFile.getAbsolutePath());\r
+ }\r
+ Document prototypeConfigDoc = XmlTools.fileToXMLDocument(prototypeNuxeoConfigFile);\r
+ Document repositoryConfigDoc = null;\r
+ // FIXME: Can the variable below reasonably be made a class variable? Its value\r
+ // is used in at least one other method in this class.\r
+ Hashtable<String, TenantBindingType> tenantBindingTypeMap = tenantBindingConfigReader.getTenantBindings();\r
+ for (TenantBindingType tbt : tenantBindingTypeMap.values()) {\r
+ List<String> repositoryNameList = ConfigUtils.getRepositoryNameList(tbt);\r
+ if (logger.isTraceEnabled()) {\r
+ logger.trace("Getting repository name(s) for tenant " + tbt.getName());\r
+ }\r
+ if (repositoryNameList == null || repositoryNameList.isEmpty() == true) {\r
+ logger.warn(String.format("Could not get repository name(s) for tenant %s", tbt.getName()));\r
+ continue;\r
+ } else {\r
+ for (String repositoryName : repositoryNameList) {\r
+ if (Tools.isBlank(repositoryName)) {\r
+ continue;\r
+ }\r
+ if (logger.isTraceEnabled()) {\r
+ logger.trace(String.format("Repository name is %s", repositoryName));\r
+ }\r
+ // FIXME: As per above, we might check for the presence of an existing\r
+ // config file for this repository and, if present, not fail even if\r
+ // the code below fails to update that file on any given system startup.\r
+ //\r
+ // Clone the prototype copy of the Nuxeo repository config file,\r
+ // thus creating a separate config file for the current repository.\r
+ repositoryConfigDoc = (Document) prototypeConfigDoc.clone();\r
+ // Update this config file by inserting values pertinent to the\r
+ // current repository.\r
+ repositoryConfigDoc = updateRepositoryConfigDoc(repositoryConfigDoc, repositoryName);\r
+ if (logger.isTraceEnabled()) {\r
+ logger.trace("Updated Nuxeo repo config file contents=\n" + repositoryConfigDoc.asXML());\r
+ }\r
+ // Write this config file to the Nuxeo server config directory.\r
+ File repofile = new File(getNuxeoConfigDir() + File.separator +\r
+ repositoryName + JEEServerDeployment.NUXEO_REPO_CONFIG_FILENAME_SUFFIX);\r
+ if (logger.isTraceEnabled()) {\r
+ logger.trace(String.format("Attempting to write Nuxeo repo config file to %s", repofile.getAbsolutePath()));\r
+ }\r
+ XmlTools.xmlDocumentToFile(repositoryConfigDoc, repofile);\r
+ }\r
+ }\r
+ }\r
+ }\r
+ \r
private Document updateRepositoryConfigDoc(Document repoConfigDoc, String repositoryName) {\r
// FIXME: Remove this temporary placeholder variable used only during development.\r
final String PLACEHOLDER = "placeholder";\r
return repoConfigDoc;\r
}\r
\r
-\r
}\r