use of org.glassfish.jersey.server.mvc.spi.ViewableContextException in project jersey by jersey.
the class ViewableMessageBodyWriter method writeTo.
@Override
public void writeTo(final Viewable viewable, final Class<?> type, final Type genericType, final Annotation[] annotations, final MediaType mediaType, final MultivaluedMap<String, Object> httpHeaders, final OutputStream entityStream) throws IOException, WebApplicationException {
try {
final ResolvedViewable resolvedViewable = resolve(viewable);
if (resolvedViewable == null) {
final String message = LocalizationMessages.TEMPLATE_NAME_COULD_NOT_BE_RESOLVED(viewable.getTemplateName());
throw new WebApplicationException(new ProcessingException(message), Response.Status.NOT_FOUND);
}
httpHeaders.putSingle(HttpHeaders.CONTENT_TYPE, resolvedViewable.getMediaType());
resolvedViewable.writeTo(entityStream, httpHeaders);
} catch (ViewableContextException vce) {
throw new NotFoundException(vce);
}
}
Aggregations