use of com.linkedin.restli.internal.server.response.RestLiResponse in project rest.li by linkedin.
the class ExampleRequestResponseGenerator method buildResponse.
private RestResponse buildResponse(Object responseEntity, ResourceMethodDescriptor method, RestRequest restRequest) {
try {
RequestContext requestContext = new RequestContext();
ServerResourceContext context = new ResourceContextImpl(new PathKeysImpl(), restRequest, requestContext);
RestUtils.validateRequestHeadersAndUpdateResourceContext(restRequest.getHeaders(), Collections.emptySet(), context, requestContext);
method.setResourceModel(_resourceModel);
final RoutingResult routingResult = new RoutingResult(context, method);
RestLiResponseData<?> responseData = _responseHandler.buildRestLiResponseData(restRequest, routingResult, responseEntity);
RestLiResponse restLiResponse = _responseHandler.buildPartialResponse(routingResult, responseData);
return ResponseUtils.buildResponse(routingResult, restLiResponse);
} catch (RestLiSyntaxException e) {
throw new ExampleGenerationException("Internal error during example generation", e);
} catch (IOException e) {
throw new ExampleGenerationException("Unable to build example response", e);
}
}
use of com.linkedin.restli.internal.server.response.RestLiResponse in project rest.li by linkedin.
the class FilterChainCallbackImpl method onResponseSuccess.
@Override
public void onResponseSuccess(final RestLiResponseData<?> responseData) {
markOnResponseTimings(_method.getContext().getRawRequestContext());
RestLiResponse partialResponse;
try {
partialResponse = _responseHandler.buildPartialResponse(_method, responseData);
} catch (Throwable th) {
LOGGER.error("Unexpected error while building the success response. Converting to error response.", th);
_wrappedCallback.onError(new RestLiResponseException(th, buildErrorResponse(th, responseData)));
return;
}
_wrappedCallback.onSuccess(partialResponse);
}
Aggregations