|
29 | 29 | import org.phoebus.security.store.SecureStore; |
30 | 30 | import org.phoebus.security.tokens.AuthenticationScope; |
31 | 31 | import org.phoebus.security.tokens.ScopedAuthenticationToken; |
| 32 | +import org.phoebus.util.http.QueryParamsHelper; |
32 | 33 |
|
33 | 34 | import javax.ws.rs.core.MultivaluedMap; |
34 | 35 | import java.net.CookieHandler; |
35 | 36 | import java.net.CookieManager; |
36 | 37 | import java.net.CookiePolicy; |
37 | 38 | import java.net.URI; |
| 39 | +import java.net.URLEncoder; |
38 | 40 | import java.net.http.HttpClient; |
39 | 41 | import java.net.http.HttpRequest; |
40 | 42 | import java.net.http.HttpResponse; |
| 43 | +import java.nio.charset.StandardCharsets; |
41 | 44 | import java.time.Duration; |
42 | 45 | import java.util.Base64; |
43 | 46 | import java.util.List; |
@@ -461,7 +464,7 @@ public CompositeSnapshot updateCompositeSnapshot(CompositeSnapshot compositeSnap |
461 | 464 | public SearchResult search(MultivaluedMap<String, String> searchParams) { |
462 | 465 | try { |
463 | 466 | HttpRequest request = HttpRequest.newBuilder() |
464 | | - .uri(URI.create(Preferences.jmasarServiceUrl + "/search?" + mapToQueryParams(searchParams))) |
| 467 | + .uri(URI.create(Preferences.jmasarServiceUrl + "/search?" + QueryParamsHelper.mapToQueryParams(searchParams))) |
465 | 468 | .header("Content-Type", CONTENT_TYPE_JSON) |
466 | 469 | .GET() |
467 | 470 | .build(); |
@@ -697,17 +700,4 @@ private HttpResponse<String> getCall(String relativeUrl) { |
697 | 700 | throw new RuntimeException(e); |
698 | 701 | } |
699 | 702 | } |
700 | | - |
701 | | - private String mapToQueryParams(MultivaluedMap<String, String> map) { |
702 | | - StringBuilder stringBuilder = new StringBuilder(); |
703 | | - map.keySet().forEach(k -> { |
704 | | - List<String> value = map.get(k); |
705 | | - if (value != null && !value.isEmpty()) { |
706 | | - stringBuilder.append(k).append("="); |
707 | | - stringBuilder.append(String.join(",", value)); |
708 | | - stringBuilder.append("&"); |
709 | | - } |
710 | | - }); |
711 | | - return stringBuilder.toString(); |
712 | | - } |
713 | 703 | } |
0 commit comments