- Timestamp:
- 2019-07-23T14:39:03+02:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/Mediawiki.java
r14641 r15261 46 46 public Optional<String> findExistingPage(List<String> pages) 47 47 throws IOException, ParserConfigurationException, SAXException, XPathExpressionException { 48 List<String> distinctPages = pages.stream().distinct().collect(Collectors.toList()); 48 49 // find a page that actually exists in the wiki 49 50 // API documentation: https://wiki.openstreetmap.org/w/api.php?action=help&modules=query 50 final URL url = new URL(baseUrl + "/w/api.php?action=query&format=xml&titles=" + pages.stream()51 final URL url = new URL(baseUrl + "/w/api.php?action=query&format=xml&titles=" + distinctPages.stream() 51 52 .map(Utils::encodeUrl) 52 .collect(Collectors.joining( "|"))53 .collect(Collectors.joining(Utils.encodeUrl("|"))) 53 54 ); 54 55 final HttpClient.Response conn = HttpClient.create(url).connect(); … … 59 60 conn.disconnect(); 60 61 final XPath xPath = XPathFactory.newInstance().newXPath(); 61 for (String page : pages) {62 for (String page : distinctPages) { 62 63 String normalized = xPath.evaluate("/api/query/normalized/n[@from='" + page + "']/@to", document); 63 64 if (normalized == null || normalized.isEmpty()) {
Note:
See TracChangeset
for help on using the changeset viewer.