Search in sources :

Example 41 with UriBuilder

use of com.linkedin.jersey.api.uri.UriBuilder in project rest.li by linkedin.

the class UpdateRequestUriBuilder method getUriBuilderWithoutQueryParams.

@Override
protected UriBuilder getUriBuilderWithoutQueryParams() {
    UpdateRequest<?> updateRequest = getRequest();
    UriBuilder b = super.getUriBuilderWithoutQueryParams();
    appendKeyToPath(b, updateRequest.getId());
    return b;
}
Also used : UriBuilder(com.linkedin.jersey.api.uri.UriBuilder)

Example 42 with UriBuilder

use of com.linkedin.jersey.api.uri.UriBuilder in project rest.li by linkedin.

the class RestUtils method buildPaginatedUri.

private static String buildPaginatedUri(final URI requestUri, final int start, final Integer count) {
    UriBuilder builder = UriBuilder.fromUri(requestUri);
    builder.replaceQueryParam("start", String.valueOf(start));
    builder.replaceQueryParam("count", String.valueOf(count));
    return builder.build().toString();
}
Also used : UriBuilder(com.linkedin.jersey.api.uri.UriBuilder)

Example 43 with UriBuilder

use of com.linkedin.jersey.api.uri.UriBuilder in project rest.li by linkedin.

the class PartialUpdateRequestUriBuilder method getUriBuilderWithoutQueryParams.

@Override
protected UriBuilder getUriBuilderWithoutQueryParams() {
    PartialUpdateRequest<?> partialUpdateRequest = getRequest();
    UriBuilder b = super.getUriBuilderWithoutQueryParams();
    appendKeyToPath(b, partialUpdateRequest.getId());
    return b;
}
Also used : UriBuilder(com.linkedin.jersey.api.uri.UriBuilder)

Example 44 with UriBuilder

use of com.linkedin.jersey.api.uri.UriBuilder in project rest.li by linkedin.

the class TestUriParamUtils method addSortedParams.

@Test
public void addSortedParams() {
    DataMap queryParams = new DataMap();
    DataMap aParamMap = new DataMap();
    aParamMap.put("someField", "someValue");
    aParamMap.put("foo", "bar");
    aParamMap.put("empty", new DataMap());
    DataList bParamList = new DataList();
    bParamList.add("x");
    bParamList.add("y");
    bParamList.add("z");
    queryParams.put("aParam", aParamMap);
    queryParams.put("bParam", bParamList);
    UriBuilder uriBuilder = new UriBuilder();
    URIParamUtils.addSortedParams(uriBuilder, queryParams);
    String query = uriBuilder.build().getQuery();
    Assert.assertEquals(query, "aParam=(empty:(),foo:bar,someField:someValue)&bParam=List(x,y,z)");
}
Also used : DataList(com.linkedin.data.DataList) UriBuilder(com.linkedin.jersey.api.uri.UriBuilder) DataMap(com.linkedin.data.DataMap) Test(org.testng.annotations.Test)

Example 45 with UriBuilder

use of com.linkedin.jersey.api.uri.UriBuilder in project rest.li by linkedin.

the class BatchCreateResponseBuilder method getLocationUri.

// construct location uri for each created entity id
private String getLocationUri(Request request, Object id, Object altKey, ProtocolVersion protocolVersion) {
    if (id == null) {
        // location uri is only set if object key is returned
        return null;
    }
    String stringKey = URIParamUtils.encodeKeyForUri(id, UriComponent.Type.PATH_SEGMENT, protocolVersion);
    UriBuilder uribuilder = UriBuilder.fromUri(request.getURI());
    uribuilder.path(stringKey);
    uribuilder.replaceQuery(null);
    if (altKey != null) {
        // add altkey param to location URI
        uribuilder.queryParam(RestConstants.ALT_KEY_PARAM, altKey);
    }
    return uribuilder.build((Object) null).toString();
}
Also used : UriBuilder(com.linkedin.jersey.api.uri.UriBuilder)

Aggregations

UriBuilder (com.linkedin.jersey.api.uri.UriBuilder)45 DataMap (com.linkedin.data.DataMap)9 URI (java.net.URI)6 Test (org.testng.annotations.Test)5 DataList (com.linkedin.data.DataList)3 ProtocolVersion (com.linkedin.restli.common.ProtocolVersion)2 AnyRecord (com.linkedin.restli.internal.server.methods.AnyRecord)2 CreateKVResponse (com.linkedin.restli.server.CreateKVResponse)2 CreateResponse (com.linkedin.restli.server.CreateResponse)2 ResourceContext (com.linkedin.restli.server.ResourceContext)2 RestLiServiceException (com.linkedin.restli.server.RestLiServiceException)2 HashMap (java.util.HashMap)2 MaskMap (com.linkedin.data.schema.MaskMap)1 RecordTemplate (com.linkedin.data.template.RecordTemplate)1 RestRequest (com.linkedin.r2.message.rest.RestRequest)1 RestRequestBuilder (com.linkedin.r2.message.rest.RestRequestBuilder)1 IdResponse (com.linkedin.restli.common.IdResponse)1 QueryParamsDataMap (com.linkedin.restli.internal.common.QueryParamsDataMap)1 ServerResourceContext (com.linkedin.restli.internal.server.ServerResourceContext)1 ArrayList (java.util.ArrayList)1