From: Aron Roberts Date: Tue, 4 Mar 2014 02:35:31 +0000 (-0800) Subject: CSPACE-6329: Fixed path. Added missing Jaxen library dependency. X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=c98de948c3cde8e7b84d2d6dd5d1eab6468f9ab0;p=tmp%2Fjakarta-migration.git CSPACE-6329: Fixed path. Added missing Jaxen library dependency. --- diff --git a/services/common-api/pom.xml b/services/common-api/pom.xml index ebc32d66b..92d6afcef 100644 --- a/services/common-api/pom.xml +++ b/services/common-api/pom.xml @@ -28,6 +28,14 @@ testng provided + + + + jaxen + jaxen + 1.1.1 + + 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 d46bb6563..7971a95c0 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 @@ -161,33 +161,32 @@ public class ServiceMain { File prototypeNuxeoConfigFile = new File(getNuxeoConfigDir() + File.separator + getNuxeoProtoConfigFilename()); logger.warn("Prototype Nuxeo config file path=" + prototypeNuxeoConfigFile.getCanonicalPath()); - if (! prototypeNuxeoConfigFile.canRead()) { - // FIXME: Handle this error appropriately here. - } - logger.warn("Can read prototype Nuxeo config file."); - Document prototypeDoc = XmlTools.fileToXMLDocument(prototypeNuxeoConfigFile); - // FIXME: Can the variable below reasonably be made a class variable? Its value - // is used in at least one other method in this class. - Hashtable tenantBindingTypeMap = tenantBindingConfigReader.getTenantBindings(); - for (TenantBindingType tbt : tenantBindingTypeMap.values()) { - List repositoryNameList = ConfigUtils.getRepositoryNameList(tbt); - if (repositoryNameList != null && repositoryNameList.isEmpty() == false) { - Document repoDoc = null; - for (String repositoryName : repositoryNameList) { - 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()); - // 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. - repoDoc = null; + if (prototypeNuxeoConfigFile.canRead()) { + logger.warn("Can read prototype Nuxeo config file."); + Document prototypeDoc = XmlTools.fileToXMLDocument(prototypeNuxeoConfigFile); + // FIXME: Can the variable below reasonably be made a class variable? Its value + // is used in at least one other method in this class. + Hashtable tenantBindingTypeMap = tenantBindingConfigReader.getTenantBindings(); + for (TenantBindingType tbt : tenantBindingTypeMap.values()) { + List repositoryNameList = ConfigUtils.getRepositoryNameList(tbt); + if (repositoryNameList != null && repositoryNameList.isEmpty() == false) { + Document repoDoc = null; + for (String repositoryName : repositoryNameList) { + 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()); + // 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. + repoDoc = null; + } } } } @@ -404,7 +403,7 @@ public class ServiceMain { } public String getNuxeoConfigDir() { - return getServerRootDir() + JEEServerDeployment.NUXEO_SERVER_CONFIG_DIR; + return getServerRootDir() + File.separator + JEEServerDeployment.NUXEO_SERVER_CONFIG_DIR; } public String getNuxeoProtoConfigFilename() { diff --git a/services/common/src/main/java/org/collectionspace/services/common/XmlTools.java b/services/common/src/main/java/org/collectionspace/services/common/XmlTools.java index b51e672c1..ca958aee0 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/XmlTools.java +++ b/services/common/src/main/java/org/collectionspace/services/common/XmlTools.java @@ -138,13 +138,19 @@ public class XmlTools { if (Tools.isBlank(xpathExpr) || Tools.isBlank(attributeName)) { return doc; } - Node node = doc.selectSingleNode(xpathExpr); - if ((node == null) || (node.getNodeType() != Node.ELEMENT_NODE)) { + try { + Node node = doc.selectSingleNode(xpathExpr); + if ((node == null) || (node.getNodeType() != Node.ELEMENT_NODE)) { + return doc; + } + Element element = (Element) node; + element.addAttribute(attributeName, attributeValue); + return doc; + } catch (Exception e) { + System.out.println(e.getStackTrace()); + } finally { return doc; } - Element element = (Element) node; - element.addAttribute(attributeName, attributeValue); - return doc; } public static String prettyPrint(String xml) throws Exception {