Advertisement
Guest User

Untitled

a guest
May 24th, 2014
332
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.13 KB | None | 0 0
  1. diff --git a/pom.xml b/pom.xml
  2. index 20bfbfe..a700b9f 100644
  3. --- a/pom.xml
  4. +++ b/pom.xml
  5. @@ -3,7 +3,7 @@
  6. <modelVersion>4.0.0</modelVersion>
  7. <groupId>ru.andreymarkelov.atlas.plugins</groupId>
  8. <artifactId>requestedfields</artifactId>
  9. - <version>1.1.8</version>
  10. + <version>1.1.8.3</version>
  11. <packaging>atlassian-plugin</packaging>
  12.  
  13. <organization>
  14. @@ -15,12 +15,30 @@
  15. <description>Feed select list options using HTTP via JSON or XML</description>
  16.  
  17. <dependencies>
  18. + <dependency>
  19. + <groupId>net.sf.saxon</groupId>
  20. + <artifactId>Saxon-HE</artifactId>
  21. + <version>9.4</version>
  22. + <exclusions>
  23. + <exclusion>
  24. + <artifactId>xml-apis</artifactId>
  25. + <groupId>xml-apis</groupId>
  26. + </exclusion>
  27. + <!-- exclusion>
  28. + <artifactId>xerces</artifactId>
  29. + <groupId>xercesImpl</groupId>
  30. + </exclusion>
  31. + <exclusion>
  32. + <artifactId>xalan</artifactId>
  33. + <groupId>xalan</groupId>
  34. + </exclusion-->
  35. + </exclusions>
  36. + </dependency>
  37. <dependency>
  38. - <groupId>net.sf.saxon</groupId>
  39. - <artifactId>Saxon-HE</artifactId>
  40. - <version>9.4</version>
  41. + <groupId>dom4j</groupId>
  42. + <artifactId>dom4j</artifactId>
  43. + <version>1.6.1</version>
  44. </dependency>
  45. -
  46. <dependency>
  47. <groupId>com.atlassian.jira</groupId>
  48. <artifactId>jira-api</artifactId>
  49. @@ -113,7 +131,7 @@
  50. </build>
  51.  
  52. <properties>
  53. - <jira.version>5.2.8</jira.version>
  54. + <jira.version>5.2.4</jira.version>
  55. <!-- <jira.version>6.2-OD-01</jira.version> -->
  56. <amps.version>4.1.6</amps.version>
  57. <useFastdevCli>false</useFastdevCli>
  58. diff --git a/src/main/java/ru/andreymarkelov/atlas/plugins/requestedfiedls/UniversalNamespaceCache.java b/src/main/java/ru/andreymarkelov/atlas/plugins/requestedfiedls/UniversalNamespaceCache.java
  59. index a267ad7..5b379df 100644
  60. --- a/src/main/java/ru/andreymarkelov/atlas/plugins/requestedfiedls/UniversalNamespaceCache.java
  61. +++ b/src/main/java/ru/andreymarkelov/atlas/plugins/requestedfiedls/UniversalNamespaceCache.java
  62. @@ -2,7 +2,7 @@ package ru.andreymarkelov.atlas.plugins.requestedfiedls;
  63.  
  64. //This is from http://www.ibm.com/developerworks/java/library/x-nmspccontext/
  65. // written by Holger Kraus
  66. -// reworked for saxon interfaces by Árpád Magosányi
  67. +// reworked for saxon interfaces by Arpad Magosanyi
  68.  
  69. import java.util.HashMap;
  70. import java.util.Iterator;
  71. @@ -35,11 +35,6 @@ public class UniversalNamespaceCache implements NamespaceContext {
  72. public UniversalNamespaceCache(XdmNode source, boolean toplevelOnly) {
  73.  
  74. examineNode(source, toplevelOnly);
  75. - System.out.println("The list of the cached namespaces:");
  76. - for (String key : prefix2Uri.keySet()) {
  77. - System.out
  78. - .println("prefix " + key + ": uri " + prefix2Uri.get(key));
  79. - }
  80. }
  81.  
  82. /**
  83. @@ -52,10 +47,8 @@ public class UniversalNamespaceCache implements NamespaceContext {
  84. */
  85. private void examineNode(XdmNode source, boolean attributesOnly) {
  86. XdmSequenceIterator attributes = source.axisIterator(Axis.NAMESPACE);
  87. - System.out.printf("source=%s\nkind=%s\nattrs=%s\n",source.getUnderlyingNode(), source.getNodeKind(), attributes.hasNext());
  88. while (attributes.hasNext()) {
  89. NamespaceNode attribute = (NamespaceNode) ((XdmNode) attributes.next()).getUnderlyingNode();
  90. - System.out.printf("att=%s\n", attribute);
  91. storeAttribute(attribute);
  92. }
  93.  
  94. @@ -63,7 +56,6 @@ public class UniversalNamespaceCache implements NamespaceContext {
  95. XdmSequenceIterator chields = source.axisIterator(Axis.CHILD);
  96. while (chields.hasNext()) {
  97. XdmNode chield = (XdmNode) chields.next();
  98. - System.out.printf("chield:%s\n", chield);
  99. if(chield.getNodeKind() == XdmNodeKind.ELEMENT)
  100. examineNode((XdmNode) chield, false);
  101. }
  102. @@ -79,8 +71,6 @@ public class UniversalNamespaceCache implements NamespaceContext {
  103. */
  104. private void storeAttribute(NamespaceNode attribute) {
  105. // examine the attributes in namespace xmlns
  106. - System.out.printf("prefix=%s\n",attribute.getLocalPart());
  107. - System.out.printf("uri=%s\n",attribute.getStringValue());
  108. putInCache(attribute.getLocalPart(),attribute.getStringValue());
  109. }
  110.  
  111. diff --git a/src/main/java/ru/andreymarkelov/atlas/plugins/requestedfiedls/XmlHttpRunner.java b/src/main/java/ru/andreymarkelov/atlas/plugins/requestedfiedls/XmlHttpRunner.java
  112. index 095d158..c889e64 100644
  113. --- a/src/main/java/ru/andreymarkelov/atlas/plugins/requestedfiedls/XmlHttpRunner.java
  114. +++ b/src/main/java/ru/andreymarkelov/atlas/plugins/requestedfiedls/XmlHttpRunner.java
  115. @@ -1,28 +1,25 @@
  116. package ru.andreymarkelov.atlas.plugins.requestedfiedls;
  117.  
  118. +import java.io.InputStream;
  119. import java.util.ArrayList;
  120. import java.util.Collections;
  121. import java.util.List;
  122.  
  123. -import javax.xml.parsers.DocumentBuilderFactory;
  124. -import javax.xml.transform.stream.StreamSource;
  125. +import javax.xml.transform.sax.SAXSource;
  126.  
  127. -import net.sf.saxon.om.NodeInfo;
  128. -import net.sf.saxon.s9api.Axis;
  129. +import net.sf.saxon.s9api.DocumentBuilder;
  130. import net.sf.saxon.s9api.Processor;
  131. import net.sf.saxon.s9api.XPathCompiler;
  132. import net.sf.saxon.s9api.XPathExecutable;
  133. import net.sf.saxon.s9api.XPathSelector;
  134. import net.sf.saxon.s9api.XdmItem;
  135. import net.sf.saxon.s9api.XdmNode;
  136. -import net.sf.saxon.tree.tiny.TinyElementImpl;
  137.  
  138. import org.apache.commons.io.IOUtils;
  139. import org.apache.commons.lang.StringUtils;
  140. import org.slf4j.Logger;
  141. import org.slf4j.LoggerFactory;
  142. -import org.w3c.dom.Document;
  143. -import org.w3c.dom.Node;
  144. +import org.xml.sax.InputSource;
  145.  
  146. public class XmlHttpRunner {
  147. private static final Logger log = LoggerFactory.getLogger(XmlHttpRunner.class);
  148. @@ -50,11 +47,12 @@ public class XmlHttpRunner {
  149. try {
  150. String xml = httpService.call(data.getReqData());
  151. List<String> vals = new ArrayList<String>();
  152. - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
  153. - factory.setNamespaceAware(true);
  154. Processor proc = new Processor(false);
  155. - net.sf.saxon.s9api.DocumentBuilder s9builder = proc.newDocumentBuilder();
  156. - XdmNode source = proc.newDocumentBuilder().build(new StreamSource(IOUtils.toInputStream(xml)));
  157. + DocumentBuilder docbuilder = proc.newDocumentBuilder();
  158. + InputStream inputStream = IOUtils.toInputStream(xml);
  159. + InputSource inputSource = new InputSource(inputStream);
  160. + SAXSource streamSource = new SAXSource(inputSource);
  161. + XdmNode source = docbuilder.build(streamSource);
  162.  
  163. XPathCompiler compiler = proc.newXPathCompiler();
  164.  
  165. @@ -69,7 +67,6 @@ public class XmlHttpRunner {
  166. selector.setContextItem(source);
  167. selector.evaluate();
  168. for (XdmItem item : selector) {
  169. - System.out.printf("item=%s\n", item);
  170. String nodeText = item.getStringValue();
  171. if (!StringUtils.isEmpty(nodeText)) {
  172. vals.add(nodeText);
  173. diff --git a/src/test/java/ru/andreymarkelov/atlas/plugins/requestedfiedls/XmlHttpRunnerTest.java b/src/test/java/ru/andreymarkelov/atlas/plugins/requestedfiedls/XmlHttpRunnerTest.java
  174. index 95854ef..1ff8450 100644
  175. --- a/src/test/java/ru/andreymarkelov/atlas/plugins/requestedfiedls/XmlHttpRunnerTest.java
  176. +++ b/src/test/java/ru/andreymarkelov/atlas/plugins/requestedfiedls/XmlHttpRunnerTest.java
  177. @@ -110,7 +110,7 @@ public class XmlHttpRunnerTest {
  178. Object defValue = "Default Value";
  179. XmlHttpRunner runner = new XmlHttpRunner(data, defValue, mockSender);
  180. HttpRunnerData returned = runner.getData();
  181. - System.out.printf("returned: %s\n", returned);
  182. + //System.out.printf("returned: %s\n", returned);
  183. assertEquals(expected, returned.getVals());
  184. }
  185. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement