use of com.linkedin.data.ByteString in project rest.li by linkedin.
the class MultiplexedRequestHandlerImpl method aggregateResponses.
private static RestResponse aggregateResponses(IndividualResponseMap responses, Map<String, HttpCookie> responseCookies) {
MultiplexedResponseContent aggregatedResponseContent = new MultiplexedResponseContent();
aggregatedResponseContent.setResponses(responses);
ByteString aggregatedResponseData = DataMapUtils.mapToByteString(aggregatedResponseContent.data(), Collections.singletonMap(RestConstants.HEADER_CONTENT_TYPE, RestConstants.HEADER_VALUE_APPLICATION_JSON));
return new RestResponseBuilder().setStatus(HttpStatus.S_200_OK.getCode()).setEntity(aggregatedResponseData).setCookies(CookieUtil.encodeSetCookies(new ArrayList<>(responseCookies.values()))).build();
}
use of com.linkedin.data.ByteString in project rest.li by linkedin.
the class SyntheticRequestCreationTask method getBodyAsByteString.
private static ByteString getBodyAsByteString(IndividualRequest individualRequest) throws MimeTypeParseException, IOException {
IndividualBody body = individualRequest.getBody(GetMode.NULL);
ByteString entity = ByteString.empty();
if (body != null) {
entity = DataMapConverter.dataMapToByteString(individualRequest.getHeaders(), body.data());
}
return entity;
}
use of com.linkedin.data.ByteString in project rest.li by linkedin.
the class IndividualResponseConversionTask method toIndividualResponse.
private static IndividualResponse toIndividualResponse(String id, RestResponse restResponse) throws MimeTypeParseException, IOException {
IndividualResponse individualResponse = new IndividualResponse();
individualResponse.setStatus(restResponse.getStatus());
individualResponse.setHeaders(new StringMap(restResponse.getHeaders()));
ByteString entity = restResponse.getEntity();
if (!entity.isEmpty()) {
// TODO Avoid converting bytes to datamap here. Individual response should have only the bytes.
individualResponse.setBody(new IndividualBody(DataMapConverter.bytesToDataMap(restResponse.getHeaders(), entity)));
}
return individualResponse;
}
use of com.linkedin.data.ByteString in project rest.li by linkedin.
the class UnstructuredDataReactiveCollectionResource method get.
@Override
public void get(String key, @CallbackParam Callback<UnstructuredDataReactiveResult> callback) {
Writer<ByteString> writer = new SingletonWriter<>(ByteString.copy(UNSTRUCTURED_DATA_BYTES));
UnstructuredDataReactiveResult result = new UnstructuredDataReactiveResult(EntityStreams.newEntityStream(writer), MIME_TYPE);
callback.onSuccess(result);
}
use of com.linkedin.data.ByteString in project rest.li by linkedin.
the class TestSchemaSampleDataGenerator method testFixedSchema.
@Test
public void testFixedSchema() {
final FixedDataSchema schema = (FixedDataSchema) DataTemplateUtil.getSchema(FixedMD5.class);
final ByteString value = (ByteString) SchemaSampleDataGenerator.buildData(schema, _spec);
Assert.assertSame(value.length(), schema.getSize());
}
Aggregations