Search in sources :

Example 36 with UriBuilder

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

the class DeleteRequestUriBuilder method build.

@Override
public URI build() {
    DeleteRequest<?> deleteRequest = getRequest();
    UriBuilder b = UriBuilder.fromUri(buildBaseUriWithPrefix());
    appendKeyToPath(b, deleteRequest.getId());
    appendQueryParams(b);
    return b.build();
}
Also used : UriBuilder(com.linkedin.jersey.api.uri.UriBuilder)

Example 37 with UriBuilder

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

the class TestQueryParamsUtil method testMaskTreeProjectionParams.

@Test
public void testMaskTreeProjectionParams() {
    Map<String, Object> queryParams = new HashMap<>();
    MaskMap fieldsMask = TestRecord.createMask().withId().withMessage();
    queryParams.put(RestConstants.FIELDS_PARAM, fieldsMask.getDataMap());
    DataMap pagingMask = new DataMap();
    pagingMask.put("paging", MaskMap.POSITIVE_MASK);
    queryParams.put(RestConstants.PAGING_FIELDS_PARAM, pagingMask);
    DataMap metaDataMask = new DataMap();
    metaDataMask.put("metadata", MaskMap.POSITIVE_MASK);
    queryParams.put(RestConstants.METADATA_FIELDS_PARAM, metaDataMask);
    DataMap dataMap = QueryParamsUtil.convertToDataMap(queryParams, Collections.emptyMap(), AllProtocolVersions.LATEST_PROTOCOL_VERSION, (paramName, pathSpecs) -> null);
    Assert.assertSame(dataMap.get(RestConstants.FIELDS_PARAM), fieldsMask.getDataMap());
    Assert.assertSame(dataMap.get(RestConstants.PAGING_FIELDS_PARAM), pagingMask);
    Assert.assertSame(dataMap.get(RestConstants.METADATA_FIELDS_PARAM), metaDataMask);
    UriBuilder uriBuilder = new UriBuilder();
    URIParamUtils.addSortedParams(uriBuilder, dataMap);
    String uri = uriBuilder.build().getQuery();
    Assert.assertEquals(uri, "fields=message,id&metadataFields=metadata&pagingFields=paging");
}
Also used : HashMap(java.util.HashMap) MaskMap(com.linkedin.data.schema.MaskMap) UriBuilder(com.linkedin.jersey.api.uri.UriBuilder) DataMap(com.linkedin.data.DataMap) Test(org.testng.annotations.Test)

Example 38 with UriBuilder

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

the class BatchFindRequestUriBuilder method getUriBuilderWithoutQueryParams.

@Override
protected UriBuilder getUriBuilderWithoutQueryParams() {
    UriBuilder b = super.getUriBuilderWithoutQueryParams();
    appendAssocKeys(b);
    return b;
}
Also used : UriBuilder(com.linkedin.jersey.api.uri.UriBuilder)

Example 39 with UriBuilder

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

the class ActionRequestUriBuilder method getUriBuilderWithoutQueryParams.

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

Example 40 with UriBuilder

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

the class DeleteRequestUriBuilder method getUriBuilderWithoutQueryParams.

@Override
protected UriBuilder getUriBuilderWithoutQueryParams() {
    DeleteRequest<?> deleteRequest = getRequest();
    UriBuilder b = super.getUriBuilderWithoutQueryParams();
    appendKeyToPath(b, deleteRequest.getId());
    return b;
}
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