Appends a URL query parameter to a URL @param url the original URL @param param the parameter(s) to append, separated by "&" @return the string version of the resulting URL
(String url, String param)
| 797 | * @return the string version of the resulting URL |
| 798 | */ |
| 799 | public static String appendParam(String url, String param) { |
| 800 | String[] pa = param.split("&"); |
| 801 | StringBuilder urlBuilder = new StringBuilder(url); |
| 802 | for (String p : pa) { |
| 803 | if (p.trim().isEmpty()) { |
| 804 | continue; |
| 805 | } |
| 806 | String[] kv = p.split("="); |
| 807 | if (kv.length == 2) { |
| 808 | urlBuilder |
| 809 | .append(urlBuilder.toString().contains("?") ? "&" : "?") |
| 810 | .append(kv[0]) |
| 811 | .append("=") |
| 812 | .append(kv[1]); |
| 813 | } else { |
| 814 | warn("Skipping param " + p + " which is not on form key=value"); |
| 815 | } |
| 816 | } |
| 817 | url = urlBuilder.toString(); |
| 818 | return url; |
| 819 | } |
| 820 | |
| 821 | /** Opens the file and posts its contents to the solrUrl, writes to response to output. */ |
| 822 | public void postFile(Path file, OutputStream output, String type) |