Jersey 2: Fix curly braces in query parameters
Jersey parses URI query parameters in order to expand templates; A template
placeholder is an identifier enclosed in curly braces.
To be able to use curly braces in URI query parameters, an indirection is required.
The query parameter will hold a template placeholder which will expand to
the real value of the query parameter which can contain curly braces;
This value will not be expanded further.
References:
https://jakartaee.github.io/rest/apidocs/2.1.6/javax/ws/rs/client/WebTarget.html#queryParam(java.lang.String,java.lang.Object...)
https://jakartaee.github.io/rest/apidocs/2.1.6/javax/ws/rs/client/WebTarget.html#resolveTemplate(java.lang.String,java.lang.Object)
diff --git a/full/src/test/java/de/ids_mannheim/korap/rewrite/QueryRewriteTest.java b/full/src/test/java/de/ids_mannheim/korap/rewrite/QueryRewriteTest.java
index 810ef7b..130741d 100644
--- a/full/src/test/java/de/ids_mannheim/korap/rewrite/QueryRewriteTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/rewrite/QueryRewriteTest.java
@@ -24,8 +24,9 @@
throws KustvaktException, Exception {
Response response = target().path(API_VERSION).path("search")
- .queryParam("q", "[orth=der]{%23examplequery} Baum")
+ .queryParam("q", "{q}")
.queryParam("ql", "poliqarp")
+ .resolveTemplate("q", "[orth=der]{#examplequery} Baum")
.request()
.get();
@@ -40,8 +41,9 @@
throws KustvaktException, Exception {
Response response = target().path(API_VERSION).path("search")
- .queryParam("q", "[orth=der]{%23system-q} Baum")
+ .queryParam("q", "{q}")
.queryParam("ql", "poliqarp")
+ .resolveTemplate("q", "[orth=der]{#system-q} Baum")
.request()
.get();
@@ -56,8 +58,9 @@
// Added in the database migration sql for tests
Response response = target().path(API_VERSION).path("search")
- .queryParam("q", "[orth=der]{%23dory/dory-q} Baum")
+ .queryParam("q", "{q}")
.queryParam("ql", "poliqarp")
+ .resolveTemplate("q", "[orth=der]{#dory/dory-q} Baum")
.request()
.header(Attributes.AUTHORIZATION, HttpAuthorizationHandler
.createBasicAuthorizationHeaderValue("dory", "pass"))