Search in sources :

Example 51 with UriInfo

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;
}
Also used : ContainerRequest(org.glassfish.jersey.server.ContainerRequest) UriInfo(javax.ws.rs.core.UriInfo)

Example 52 with UriInfo

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);
}
Also used : UriInfo(javax.ws.rs.core.UriInfo) Test(org.junit.Test)

Example 53 with UriInfo

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);
}
Also used : UriInfo(javax.ws.rs.core.UriInfo) Test(org.junit.Test)

Example 54 with UriInfo

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 "));
}
Also used : UriInfo(javax.ws.rs.core.UriInfo) Test(org.junit.Test)

Example 55 with UriInfo

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);
}
Also used : UriInfo(javax.ws.rs.core.UriInfo) Test(org.junit.Test)

Aggregations

UriInfo (javax.ws.rs.core.UriInfo)86 Response (javax.ws.rs.core.Response)44 Test (org.junit.Test)43 URI (java.net.URI)31 Test (org.testng.annotations.Test)21 Request (org.apache.atlas.catalog.Request)12 ResourceProvider (org.apache.atlas.catalog.ResourceProvider)12 TaxonomyResourceProvider (org.apache.atlas.catalog.TaxonomyResourceProvider)12 MetadataService (org.apache.atlas.services.MetadataService)12 AtlasTypeDefStore (org.apache.atlas.store.AtlasTypeDefStore)12 HttpServletRequest (javax.servlet.http.HttpServletRequest)11 ArrayList (java.util.ArrayList)10 Map (java.util.Map)10 MediaType (javax.ws.rs.core.MediaType)10 Api (io.swagger.annotations.Api)8 ApiOperation (io.swagger.annotations.ApiOperation)8 ApiParam (io.swagger.annotations.ApiParam)8 ApiResponse (io.swagger.annotations.ApiResponse)8 ApiResponses (io.swagger.annotations.ApiResponses)8 InputStream (java.io.InputStream)8