Search in sources :

Example 1 with ViewableContextException

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);
    }
}
Also used : ResolvedViewable(org.glassfish.jersey.server.mvc.spi.ResolvedViewable) WebApplicationException(javax.ws.rs.WebApplicationException) NotFoundException(javax.ws.rs.NotFoundException) ViewableContextException(org.glassfish.jersey.server.mvc.spi.ViewableContextException) ProcessingException(javax.ws.rs.ProcessingException)

Aggregations

NotFoundException (javax.ws.rs.NotFoundException)1 ProcessingException (javax.ws.rs.ProcessingException)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 ResolvedViewable (org.glassfish.jersey.server.mvc.spi.ResolvedViewable)1 ViewableContextException (org.glassfish.jersey.server.mvc.spi.ViewableContextException)1