use of javax.ws.rs.core.UriInfo in project jersey by jersey.
the class JsonWithPaddingInterceptor method getCallbackName.
/**
* Returns a JavaScript callback name to wrap the JSON entity into. The callback name is determined from the {@link JSONP}
* annotation.
*
* @param jsonp {@link JSONP} annotation to determine the callback name from.
* @return a JavaScript callback name.
*/
private String getCallbackName(final JSONP jsonp) {
String callback = jsonp.callback();
if (!"".equals(jsonp.queryParam())) {
final ContainerRequest containerRequest = containerRequestProvider.get();
final UriInfo uriInfo = containerRequest.getUriInfo();
final MultivaluedMap<String, String> queryParameters = uriInfo.getQueryParameters();
final List<String> queryParameter = queryParameters.get(jsonp.queryParam());
callback = (queryParameter != null && !queryParameter.isEmpty()) ? queryParameter.get(0) : callback;
}
return callback;
}
use of javax.ws.rs.core.UriInfo in project jersey by jersey.
the class UriRoutingContextTest method testGetQueryParametersMultipleAmpersand.
/**
* Migrated Jersey 1.x {@code com.sun.jersey.impl.QueryParametersHttpRequestTest}.
*/
@Test
public void testGetQueryParametersMultipleAmpersand() throws Exception {
final UriInfo ui = createContext("/widgets/10?&&%20=%20&&&", "GET");
MultivaluedMap<String, String> p = ui.getQueryParameters();
assertEquals(p.size(), 1);
}
use of javax.ws.rs.core.UriInfo in project jersey by jersey.
the class UriRoutingContextTest method testGetQueryParametersSingleAmpersand.
/**
* Migrated Jersey 1.x {@code com.sun.jersey.impl.QueryParametersHttpRequestTest}.
*/
@Test
public void testGetQueryParametersSingleAmpersand() throws Exception {
final UriInfo ui = createContext("/widgets/10?&", "GET");
MultivaluedMap<String, String> p = ui.getQueryParameters();
assertEquals(p.size(), 0);
}
use of javax.ws.rs.core.UriInfo in project jersey by jersey.
the class UriRoutingContextTest method testGetQueryParametersWhiteSpace.
/**
* Migrated Jersey 1.x {@code com.sun.jersey.impl.QueryParametersHttpRequestTest}.
*/
@Test
public void testGetQueryParametersWhiteSpace() throws Exception {
final UriInfo ui = createContext("/widgets/10?x+=+1%20&%20y+=+2", "GET");
MultivaluedMap<String, String> p = ui.getQueryParameters();
assertEquals(" 1 ", p.getFirst("x "));
assertEquals(" 2", p.getFirst(" y "));
}
use of javax.ws.rs.core.UriInfo in project jersey by jersey.
the class UriRoutingContextTest method testGetQueryParametersInterspersedAmpersand.
/**
* Migrated Jersey 1.x {@code com.sun.jersey.impl.QueryParametersHttpRequestTest}.
*/
@Test
public void testGetQueryParametersInterspersedAmpersand() throws Exception {
final UriInfo ui = createContext("/widgets/10?a=1&&b=2", "GET");
MultivaluedMap<String, String> p = ui.getQueryParameters();
assertEquals(p.size(), 2);
}
Aggregations