]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-6329: Fixed path. Added missing Jaxen library dependency.
authorAron Roberts <aron@socrates.berkeley.edu>
Tue, 4 Mar 2014 02:35:31 +0000 (18:35 -0800)
committerAron Roberts <aron@socrates.berkeley.edu>
Tue, 4 Mar 2014 02:35:31 +0000 (18:35 -0800)
services/common-api/pom.xml
services/common/src/main/java/org/collectionspace/services/common/ServiceMain.java
services/common/src/main/java/org/collectionspace/services/common/XmlTools.java

index ebc32d66bbf62b4046e2f5b0712added8468efca..92d6afcefc4a958d24dd4b85df0789c4870565cf 100644 (file)
             <artifactId>testng</artifactId>\r
             <scope>provided</scope>\r
         </dependency>\r
+        \r
+        <!-- Required for XPath processing using dom4j in XmlTools class -->\r
+        <dependency>\r
+            <groupId>jaxen</groupId>\r
+            <artifactId>jaxen</artifactId>\r
+            <version>1.1.1</version>\r
+        </dependency>\r
+\r
     </dependencies>\r
 \r
 </project>\r
index d46bb65630c25a07d5c5231f9bd3c2eb8d4f70ab..7971a95c0237667f0ce6058f1bda7e1b13ca69a8 100644 (file)
@@ -161,33 +161,32 @@ public class ServiceMain {
         File prototypeNuxeoConfigFile =\r
                 new File(getNuxeoConfigDir() + File.separator + getNuxeoProtoConfigFilename());\r
         logger.warn("Prototype Nuxeo config file path=" + prototypeNuxeoConfigFile.getCanonicalPath());\r
-        if (! prototypeNuxeoConfigFile.canRead()) {\r
-            // FIXME: Handle this error appropriately here.\r
-        }\r
-        logger.warn("Can read prototype Nuxeo config file.");\r
-        Document prototypeDoc = XmlTools.fileToXMLDocument(prototypeNuxeoConfigFile);\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 (repositoryNameList != null && repositoryNameList.isEmpty() == false) {\r
-                Document repoDoc = null;\r
-               for (String repositoryName : repositoryNameList) {\r
-                    logger.warn("Repository name=" + repositoryName);\r
-                    repoDoc = (Document) prototypeDoc.clone();\r
-                    logger.warn("Before attribute edits=\n" + repoDoc.asXML());\r
-                    // FIXME: Set up constants and/or methods for XPath expressions, element and attribute names\r
-                    repoDoc = XmlTools.setAttributeValue(repoDoc, "/component/extension[@point='repository']/repository", "name", repositoryName);\r
-                    logger.warn("After first attribute edit=\n" + repoDoc.asXML());\r
-                    repoDoc = XmlTools.setAttributeValue(repoDoc, "/component/extension[@point='repository']/repository/repository", "name", repositoryName);\r
-                    logger.warn("After second attribute edit=\n" + repoDoc.asXML());\r
-                    repoDoc = XmlTools.setAttributeValue(repoDoc, "/component/extension[@point='repositories']/repository", "name", repositoryName);\r
-                    logger.warn("After third attribute edit=\n" + repoDoc.asXML());\r
-                    // FIXME: Edit additional element and/or attribute values.\r
-                    // FIXME: Emit serialized XML and write it to an appropriately named file\r
-                    // in the Nuxeo server config directory.\r
-                    repoDoc = null;\r
+        if (prototypeNuxeoConfigFile.canRead()) {\r
+            logger.warn("Can read prototype Nuxeo config file.");\r
+            Document prototypeDoc = XmlTools.fileToXMLDocument(prototypeNuxeoConfigFile);\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 (repositoryNameList != null && repositoryNameList.isEmpty() == false) {\r
+                    Document repoDoc = null;\r
+                    for (String repositoryName : repositoryNameList) {\r
+                        logger.warn("Repository name=" + repositoryName);\r
+                        repoDoc = (Document) prototypeDoc.clone();\r
+                        logger.warn("Before attribute edits=\n" + repoDoc.asXML());\r
+                        // FIXME: Set up constants and/or methods for XPath expressions, element and attribute names\r
+                        repoDoc = XmlTools.setAttributeValue(repoDoc, "/component/extension[@point='repository']/repository", "name", repositoryName);\r
+                        logger.warn("After first attribute edit=\n" + repoDoc.asXML());\r
+                        repoDoc = XmlTools.setAttributeValue(repoDoc, "/component/extension[@point='repository']/repository/repository", "name", repositoryName);\r
+                        logger.warn("After second attribute edit=\n" + repoDoc.asXML());\r
+                        repoDoc = XmlTools.setAttributeValue(repoDoc, "/component/extension[@point='repositories']/repository", "name", repositoryName);\r
+                        logger.warn("After third attribute edit=\n" + repoDoc.asXML());\r
+                        // FIXME: Edit additional element and/or attribute values.\r
+                        // FIXME: Emit serialized XML and write it to an appropriately named file\r
+                        // in the Nuxeo server config directory.\r
+                        repoDoc = null;\r
+                    }\r
                 }\r
             }\r
         }\r
@@ -404,7 +403,7 @@ public class ServiceMain {
     }\r
     \r
     public String getNuxeoConfigDir() {\r
-        return getServerRootDir() + JEEServerDeployment.NUXEO_SERVER_CONFIG_DIR;\r
+        return getServerRootDir() + File.separator + JEEServerDeployment.NUXEO_SERVER_CONFIG_DIR;\r
     }\r
     \r
     public String getNuxeoProtoConfigFilename() {\r
index b51e672c117ab03f50090fa61912a1a11734c8b4..ca958aee02276356192ddc56b175183f4773e806 100644 (file)
@@ -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 {