From 1b9dc3e4f615e1e16c7659618392fa4546334728 Mon Sep 17 00:00:00 2001 From: Mikolaj Izdebski Date: Fri, 27 Sep 2013 14:36:47 +0200 Subject: [PATCH] Port from werken-xpath to jdom - Resolves: rhbz#875817 --- 0001-Don-t-use-Werken-XPath.patch | 165 ++++++++++++++++++++++++++++++ velocity.spec | 17 ++- 2 files changed, 178 insertions(+), 4 deletions(-) create mode 100644 0001-Don-t-use-Werken-XPath.patch diff --git a/0001-Don-t-use-Werken-XPath.patch b/0001-Don-t-use-Werken-XPath.patch new file mode 100644 index 0000000..b754573 --- /dev/null +++ b/0001-Don-t-use-Werken-XPath.patch @@ -0,0 +1,165 @@ +From 8a9344f55d74a5b809051ae144b3c028499fec0d Mon Sep 17 00:00:00 2001 +From: Mikolaj Izdebski +Date: Sat, 27 Sep 2013 10:53:46 +0200 +Subject: [PATCH] Don't use Werken XPath + +--- + src/java/org/apache/velocity/anakia/AnakiaElement.java | 7 +++++-- + src/java/org/apache/velocity/anakia/NodeList.java | 6 ++++-- + src/java/org/apache/velocity/anakia/XPathCache.java | 9 ++++++--- + src/java/org/apache/velocity/anakia/XPathTool.java | 16 ++++++++++------ + 4 files changed, 25 insertions(+), 13 deletions(-) + +diff --git a/src/java/org/apache/velocity/anakia/AnakiaElement.java b/src/java/org/apache/velocity/anakia/AnakiaElement.java +index c72b653..df13153 100644 +--- a/src/java/org/apache/velocity/anakia/AnakiaElement.java ++++ b/src/java/org/apache/velocity/anakia/AnakiaElement.java +@@ -20,8 +20,10 @@ package org.apache.velocity.anakia; + */ + + import org.jdom.Element; ++import org.jdom.JDOMException; + import org.jdom.Namespace; + import org.jdom.output.XMLOutputter; ++ + import java.util.List; + + /** +@@ -126,10 +128,11 @@ public class AnakiaElement extends Element + * @param xpathExpression the XPath expression you wish to apply + * @return a NodeList representing the nodes that are the result of + * application of the XPath to the current element. It can be empty. ++ * @throws JDOMException + */ +- public NodeList selectNodes(String xpathExpression) ++ public NodeList selectNodes(String xpathExpression) throws JDOMException + { +- return new NodeList(XPathCache.getXPath(xpathExpression).applyTo(this), false); ++ return new NodeList(XPathCache.getXPath(xpathExpression).selectNodes(this), false); + } + + /** +diff --git a/src/java/org/apache/velocity/anakia/NodeList.java b/src/java/org/apache/velocity/anakia/NodeList.java +index daf611d..b303bda 100644 +--- a/src/java/org/apache/velocity/anakia/NodeList.java ++++ b/src/java/org/apache/velocity/anakia/NodeList.java +@@ -35,6 +35,7 @@ import org.jdom.DocType; + import org.jdom.Document; + import org.jdom.Element; + import org.jdom.EntityRef; ++import org.jdom.JDOMException; + import org.jdom.ProcessingInstruction; + import org.jdom.Text; + import org.jdom.output.XMLOutputter; +@@ -289,10 +290,11 @@ public class NodeList implements List, Cloneable + * @param xpathString the XPath expression you wish to apply + * @return a NodeList representing the nodes that are the result of + * application of the XPath to the current node list. It can be empty. ++ * @throws JDOMException + */ +- public NodeList selectNodes(String xpathString) ++ public NodeList selectNodes(String xpathString) throws JDOMException + { +- return new NodeList(XPathCache.getXPath(xpathString).applyTo(nodes), false); ++ return new NodeList(XPathCache.getXPath(xpathString).selectNodes(nodes), false); + } + + // List methods implemented hereafter +diff --git a/src/java/org/apache/velocity/anakia/XPathCache.java b/src/java/org/apache/velocity/anakia/XPathCache.java +index cef43d9..0d633b0 100644 +--- a/src/java/org/apache/velocity/anakia/XPathCache.java ++++ b/src/java/org/apache/velocity/anakia/XPathCache.java +@@ -19,7 +19,9 @@ package org.apache.velocity.anakia; + * under the License. + */ + +-import com.werken.xpath.XPath; ++import org.jdom.JDOMException; ++import org.jdom.xpath.XPath; ++ + import java.util.Map; + import java.util.WeakHashMap; + +@@ -46,8 +48,9 @@ class XPathCache + * A cached object is returned if it already exists for the requested expression. + * @param xpathString the XPath expression to parse + * @return the XPath object that represents the parsed XPath expression. ++ * @throws JDOMException + */ +- static XPath getXPath(String xpathString) ++ static XPath getXPath(String xpathString) throws JDOMException + { + XPath xpath = null; + synchronized(XPATH_CACHE) +@@ -55,7 +58,7 @@ class XPathCache + xpath = (XPath)XPATH_CACHE.get(xpathString); + if(xpath == null) + { +- xpath = new XPath(xpathString); ++ xpath = XPath.newInstance(xpathString); + XPATH_CACHE.put(xpathString, xpath); + } + } +diff --git a/src/java/org/apache/velocity/anakia/XPathTool.java b/src/java/org/apache/velocity/anakia/XPathTool.java +index c9e6178..f85d2c1 100644 +--- a/src/java/org/apache/velocity/anakia/XPathTool.java ++++ b/src/java/org/apache/velocity/anakia/XPathTool.java +@@ -23,6 +23,7 @@ import java.util.List; + + import org.jdom.Document; + import org.jdom.Element; ++import org.jdom.JDOMException; + + /** + * This class adds an entrypoint into XPath functionality, +@@ -88,12 +89,13 @@ public class XPathTool + * @param doc The Document context + * + * @return A list of selected nodes ++ * @throws JDOMException + */ + public NodeList applyTo(String xpathSpec, +- Document doc) ++ Document doc) throws JDOMException + { + //RuntimeSingleton.info("XPathTool::applyTo(String, Document)"); +- return new NodeList(XPathCache.getXPath(xpathSpec).applyTo( doc ), false); ++ return new NodeList(XPathCache.getXPath(xpathSpec).selectNodes( doc ), false); + } + + /** +@@ -103,12 +105,13 @@ public class XPathTool + * @param elem The Element context + * + * @return A list of selected nodes ++ * @throws JDOMException + */ + public NodeList applyTo(String xpathSpec, +- Element elem) ++ Element elem) throws JDOMException + { + //RuntimeSingleton.info("XPathTool::applyTo(String, Element)"); +- return new NodeList(XPathCache.getXPath(xpathSpec).applyTo( elem ), false); ++ return new NodeList(XPathCache.getXPath(xpathSpec).selectNodes( elem ), false); + } + + /** +@@ -118,12 +121,13 @@ public class XPathTool + * @param nodeSet The nodeset context + * + * @return A list of selected nodes ++ * @throws JDOMException + */ + public NodeList applyTo(String xpathSpec, +- List nodeSet) ++ List nodeSet) throws JDOMException + { + //RuntimeSingleton.info("XPathTool::applyTo(String, List)"); +- return new NodeList(XPathCache.getXPath(xpathSpec).applyTo( nodeSet ), false); ++ return new NodeList(XPathCache.getXPath(xpathSpec).selectNodes( nodeSet ), false); + } + } + +-- +1.8.3.1 + diff --git a/velocity.spec b/velocity.spec index 81a402f..10115ea 100644 --- a/velocity.spec +++ b/velocity.spec @@ -30,7 +30,7 @@ Name: velocity Version: 1.7 -Release: 9%{?dist} +Release: 10%{?dist} Epoch: 0 Summary: Java-based template engine License: ASL 2.0 @@ -40,19 +40,19 @@ Source1: http://repo1.maven.org/maven2/org/apache/%{name}/%{name}/%{versi Patch0: 0001-Remove-avalon-logkit.patch Patch2: 0003-Use-system-jars.patch Patch3: 0004-JDBC-41-compat.patch +Patch4: 0001-Don-t-use-Werken-XPath.patch Requires: apache-commons-collections Requires: apache-commons-logging Requires: apache-commons-lang Requires: servlet3 Requires: jakarta-oro -Requires: werken-xpath Requires: junit Requires: hsqldb +Requires: jaxen Requires: jdom Requires: bcel Requires: log4j -BuildRequires: werken-xpath BuildRequires: ant BuildRequires: antlr BuildRequires: junit @@ -63,6 +63,7 @@ BuildRequires: apache-commons-logging BuildRequires: apache-commons-lang BuildRequires: servlet3 BuildRequires: jakarta-oro +BuildRequires: jaxen BuildRequires: jdom BuildRequires: bcel BuildRequires: log4j @@ -140,6 +141,10 @@ cp %{SOURCE1} ./pom.xml %patch3 -p1 +# Use jdom instead of werken-xpath +%patch4 -p1 +%pom_remove_dep werken-xpath: + # ----------------------------------------------------------------------------- %build @@ -152,9 +157,9 @@ tomcat-servlet-api \ junit \ jakarta-oro \ log4j \ +jaxen \ jdom \ bcel \ -werken-xpath \ hsqldb \ junit) ant \ @@ -206,6 +211,10 @@ install -pD -T -m 644 pom.xml %{buildroot}%{_mavenpomdir}/JPP-%{name}.pom %{_datadir}/%{name} %changelog +* Sat Sep 21 2013 Mikolaj Izdebski - 0:1.7-10 +- Port from werken-xpath to jdom +- Resolves: rhbz#875817 + * Mon Aug 05 2013 Michal Srb - 0:1.7-9 - Fix FTBFS (Resolves: #992852)