You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

FetchReleaseNotesTickets.java 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*
  2. * Copyright 2000-2014 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.buildhelpers;
  17. import java.io.IOException;
  18. import java.io.InputStream;
  19. import java.net.MalformedURLException;
  20. import java.net.URL;
  21. import java.net.URLConnection;
  22. import java.util.ArrayList;
  23. import java.util.List;
  24. import org.apache.commons.io.IOUtils;
  25. public class FetchReleaseNotesTickets {
  26. private static final String queryURL = "http://dev.vaadin.com/query?status=pending-release&status=released&@milestone@&resolution=fixed&col=id&col=summary&col=owner&col=type&col=priority&col=component&col=version&col=bfptime&col=fv&format=tab&order=id";
  27. private static final String ticketTemplate = "<tr>"
  28. + "@badge@" //
  29. + "<td class=\"ticket\"><a href=\"http://dev.vaadin.com/ticket/@ticket@\">#@ticket@</a></td>" //
  30. + "<td>@description@</td>" //
  31. + "</tr>"; //
  32. public static void main(String[] args) throws IOException {
  33. String versionsProperty = System.getProperty("vaadin.version");
  34. if (versionsProperty == null || versionsProperty.equals("")) {
  35. usage();
  36. }
  37. String milestone = "";
  38. List<String> versions = new ArrayList<String>();
  39. for (String version : versionsProperty.split(" ")) {
  40. if (version.endsWith(".0") || version.matches(".*\\.rc\\d+")) {
  41. // Find all prerelease versions for final or rc
  42. // Strip potential rc prefix
  43. version = version.replaceAll("\\.rc\\d+$", "");
  44. versions.addAll(findPrereleaseVersions(version));
  45. } else {
  46. versions.add(version);
  47. }
  48. }
  49. for (String version : versions) {
  50. if (!milestone.equals("")) {
  51. milestone += "&amp;";
  52. }
  53. milestone += "milestone=Vaadin+" + version;
  54. }
  55. printMilestone(milestone);
  56. }
  57. private static List<String> findPrereleaseVersions(String baseVersion) {
  58. List<String> versions = new ArrayList<String>();
  59. for (int i = 0; i < 50; i++) {
  60. versions.add(baseVersion + ".alpha" + i);
  61. }
  62. for (int i = 0; i < 10; i++) {
  63. versions.add(baseVersion + ".beta" + i);
  64. }
  65. for (int i = 0; i < 10; i++) {
  66. versions.add(baseVersion + ".rc" + i);
  67. }
  68. return versions;
  69. }
  70. private static void printMilestone(String milestone)
  71. throws MalformedURLException, IOException {
  72. URL url = new URL(queryURL.replace("@milestone@", milestone));
  73. URLConnection connection = url.openConnection();
  74. InputStream urlStream = connection.getInputStream();
  75. List<String> tickets = IOUtils.readLines(urlStream);
  76. for (String ticket : tickets) {
  77. // Omit BOM
  78. if (!ticket.isEmpty() && ticket.charAt(0) == 65279) {
  79. ticket = ticket.substring(1);
  80. }
  81. String[] fields = ticket.split("\t");
  82. if ("id".equals(fields[0])) {
  83. // This is the header
  84. continue;
  85. }
  86. String summary = fields[1];
  87. if (summary.startsWith("\"") && summary.endsWith("\"")) {
  88. // If a summary starts with " and ends with " then all quotes in
  89. // the summary are encoded as double quotes
  90. summary = summary.substring(1, summary.length() - 1);
  91. summary = summary.replace("\"\"", "\"");
  92. }
  93. String badge = "<td></td>";
  94. if (fields.length >= 8 && !fields[7].equals("")) {
  95. badge = "<td class=\"bfp\"><span class=\"bfp\">Priority</span></td>";
  96. } else if (fields.length >= 9 && fields[8].equalsIgnoreCase("true")) {
  97. badge = "<td class=\"fv\"><span class=\"fv\">Vote</span></td>";
  98. }
  99. System.out.println(ticketTemplate.replace("@ticket@", fields[0])
  100. .replace("@description@", summary)
  101. .replace("@badge@", badge));
  102. }
  103. urlStream.close();
  104. }
  105. private static void usage() {
  106. System.err.println("Usage: "
  107. + FetchReleaseNotesTickets.class.getSimpleName()
  108. + " -Dvaadin.version=<version>");
  109. System.exit(1);
  110. }
  111. }