From: Aron Roberts Date: Tue, 4 Mar 2014 22:52:04 +0000 (-0800) Subject: CSPACE-6329: All fields believed to now be edited, with some currently using placehol... X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=8c2d566e8aadb8d58b1d72b18a1c221c0e65f714;p=tmp%2Fjakarta-migration.git CSPACE-6329: All fields believed to now be edited, with some currently using placeholder content for values. --- diff --git a/services/common-api/src/main/java/org/collectionspace/services/common/api/JEEServerDeployment.java b/services/common-api/src/main/java/org/collectionspace/services/common/api/JEEServerDeployment.java index a66a24464..3f4210bb2 100644 --- a/services/common-api/src/main/java/org/collectionspace/services/common/api/JEEServerDeployment.java +++ b/services/common-api/src/main/java/org/collectionspace/services/common/api/JEEServerDeployment.java @@ -14,7 +14,8 @@ public interface JEEServerDeployment { public final static String NUXEO_SERVER_DIR = "nuxeo-server"; public final static String NUXEO_CONFIG_DIR = "config"; public final static String NUXEO_SERVER_CONFIG_DIR = NUXEO_SERVER_DIR + File.separator + NUXEO_CONFIG_DIR; - public final static String NUXEO_PROTOTYPE_CONFIG_FILENAME = "proto-repo-config.xml"; + public final static String NUXEO_REPO_CONFIG_FILENAME_SUFFIX = "-repo-config.xml"; + public final static String NUXEO_PROTOTYPE_CONFIG_FILENAME = "proto" + NUXEO_REPO_CONFIG_FILENAME_SUFFIX; public final static String NUXEO_PLUGINS_DIR = "plugins"; public final static String NUXEO_SERVER_PLUGINS_DIR = NUXEO_SERVER_DIR + File.separator + NUXEO_PLUGINS_DIR; } diff --git a/services/common/src/main/java/org/collectionspace/services/common/ServiceMain.java b/services/common/src/main/java/org/collectionspace/services/common/ServiceMain.java index bdba40bbd..1d32ede7e 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/ServiceMain.java +++ b/services/common/src/main/java/org/collectionspace/services/common/ServiceMain.java @@ -21,6 +21,7 @@ import javax.sql.DataSource; import org.collectionspace.authentication.AuthN; import org.collectionspace.services.common.api.JEEServerDeployment; +import org.collectionspace.services.common.api.Tools; import org.collectionspace.services.common.authorization_mgt.AuthorizationCommon; import org.collectionspace.services.common.config.ConfigReader; import org.collectionspace.services.common.config.ConfigUtils; @@ -69,8 +70,14 @@ public class ServiceMain { private UriTemplateRegistry uriTemplateRegistry = new UriTemplateRegistry(); private static final String SERVER_HOME_PROPERTY = "catalina.home"; - private static final boolean USE_APP_GENERATED_CONFIG = true; - + private static final boolean USE_APP_GENERATED_CONFIG = true; + + private static final String COMPONENT_EXTENSION_XPATH = "/component/extension[@point='%s']"; + private static final String REPOSITORY_EXTENSION_POINT_XPATH = + String.format(COMPONENT_EXTENSION_XPATH, "repository"); + private static final String REPOSITORIES_EXTENSION_POINT_XPATH = + String.format(COMPONENT_EXTENSION_XPATH, "repositories"); + private ServiceMain() { //empty } @@ -171,19 +178,50 @@ public class ServiceMain { List repositoryNameList = ConfigUtils.getRepositoryNameList(tbt); if (repositoryNameList != null && repositoryNameList.isEmpty() == false) { Document repoDoc = null; + final String PLACEHOLDER = "placeholder"; for (String repositoryName : repositoryNameList) { + if (Tools.isBlank(repositoryName)) { + continue; + } + // FIXME: Remove this and other, similar log statements before merging. logger.warn("Repository name=" + repositoryName); repoDoc = (Document) prototypeDoc.clone(); - logger.warn("Before attribute edits=\n" + repoDoc.asXML()); - // FIXME: Set up constants and/or methods for XPath expressions, element and attribute names - repoDoc = XmlTools.setAttributeValue(repoDoc, "/component/extension[@point='repository']/repository", "name", repositoryName); - logger.warn("After first attribute edit=\n" + repoDoc.asXML()); - repoDoc = XmlTools.setAttributeValue(repoDoc, "/component/extension[@point='repository']/repository/repository", "name", repositoryName); - logger.warn("After second attribute edit=\n" + repoDoc.asXML()); - repoDoc = XmlTools.setAttributeValue(repoDoc, "/component/extension[@point='repositories']/repository", "name", repositoryName); - logger.warn("After third attribute edit=\n" + repoDoc.asXML()); - repoDoc = XmlTools.setElementValue(repoDoc, "/component/extension[@point='repository']/repository/repository/property[@name='DatabaseName']", repositoryName); - logger.warn("After first element edit=\n" + repoDoc.asXML()); + logger.warn("Before edits=\n" + repoDoc.asXML()); + // Text substitutions within first extension point + repoDoc = XmlTools.setAttributeValue(repoDoc, + REPOSITORY_EXTENSION_POINT_XPATH + "/repository", "name", repositoryName); + logger.warn("After edit=\n" + repoDoc.asXML()); + repoDoc = XmlTools.setAttributeValue(repoDoc, + REPOSITORY_EXTENSION_POINT_XPATH + "/repository/repository", "name", repositoryName); + logger.warn("After edit=\n" + repoDoc.asXML()); + repoDoc = XmlTools.setElementValue(repoDoc, + REPOSITORY_EXTENSION_POINT_XPATH + "/repository/repository/xa-datasource", PLACEHOLDER); + logger.warn("After edit=\n" + repoDoc.asXML()); + repoDoc = XmlTools.setElementValue(repoDoc, + REPOSITORY_EXTENSION_POINT_XPATH + "/repository/repository/property[@name='URL']", PLACEHOLDER); + logger.warn("After edit=\n" + repoDoc.asXML()); + repoDoc = XmlTools.setElementValue(repoDoc, + REPOSITORY_EXTENSION_POINT_XPATH + "/repository/repository/property[@name='ServerName']", PLACEHOLDER); + logger.warn("After edit=\n" + repoDoc.asXML()); + repoDoc = XmlTools.setElementValue(repoDoc, + REPOSITORY_EXTENSION_POINT_XPATH + "/repository/repository/property[@name='DatabaseName']", repositoryName); + logger.warn("After edit=\n" + repoDoc.asXML()); + repoDoc = XmlTools.setElementValue(repoDoc, + REPOSITORY_EXTENSION_POINT_XPATH + "/repository/repository/property[@name='User']", PLACEHOLDER); + logger.warn("After edit=\n" + repoDoc.asXML()); + repoDoc = XmlTools.setElementValue(repoDoc, + REPOSITORY_EXTENSION_POINT_XPATH + "/repository/repository/property[@name='Password']", PLACEHOLDER); + logger.warn("After edit=\n" + repoDoc.asXML()); + // Text substitutions within second extension point + repoDoc = XmlTools.setElementValue(repoDoc, + REPOSITORIES_EXTENSION_POINT_XPATH + "/documentation", PLACEHOLDER); + logger.warn("After edit=\n" + repoDoc.asXML()); + repoDoc = XmlTools.setAttributeValue(repoDoc, + REPOSITORIES_EXTENSION_POINT_XPATH + "/repository", "name", repositoryName); + logger.warn("After edit=\n" + repoDoc.asXML()); + repoDoc = XmlTools.setAttributeValue(repoDoc, + REPOSITORIES_EXTENSION_POINT_XPATH + "/repository", "label", PLACEHOLDER); + logger.warn("After edit=\n" + repoDoc.asXML()); // FIXME: Edit additional element and/or attribute values. // FIXME: Emit serialized XML and write it to an appropriately named file // in the Nuxeo server config directory. @@ -415,6 +453,10 @@ public class ServiceMain { return JEEServerDeployment.NUXEO_PROTOTYPE_CONFIG_FILENAME; } + public String getNuxeoConfigFilename(String reponame) { + return reponame + JEEServerDeployment.NUXEO_REPO_CONFIG_FILENAME_SUFFIX; + } + /** * @return the server resources path */