use of com.linkedin.restli.common.multiplexer.IndividualRequestMap in project rest.li by linkedin.
the class MultiplexedRequestHandlerImpl method extractIndividualRequests.
/**
* Extracts individual requests from the given REST request.
*
* @return a non-empty map of individual requests
* @throws RestException if the payload of the RestRequest is ill-formed, contains no individual requests, or contains
* more than allowable individual requests.
*/
private IndividualRequestMap extractIndividualRequests(RestRequest restRequest) throws RestException {
validateHeaders(restRequest);
DataMap data = DataMapUtils.readMap(restRequest);
MultiplexedRequestContent multiplexedRequestContent = DataTemplateUtil.wrap(data, MultiplexedRequestContent.class);
IndividualRequestMap individualRequests = multiplexedRequestContent.getRequests();
int totalCount = totalRequestCount(individualRequests);
if (totalCount == 0) {
throw RestException.forError(HttpStatus.S_400_BAD_REQUEST.getCode(), "No individual requests to process");
}
if (totalCount > _maximumRequestsNumber) {
throw RestException.forError(HttpStatus.S_400_BAD_REQUEST.getCode(), "The server is configured to serve up to " + _maximumRequestsNumber + " requests, but received " + totalCount);
}
return individualRequests;
}
Aggregations