Search in sources :

Example 1 with MultipartOutputFilter

use of org.apache.cxf.jaxrs.ext.multipart.MultipartOutputFilter in project cxf by apache.

the class MultipartProvider method writeTo.

public void writeTo(Object obj, Class<?> type, Type genericType, Annotation[] anns, MediaType mt, MultivaluedMap<String, Object> headers, OutputStream os) throws IOException, WebApplicationException {
    List<Attachment> handlers = convertToDataHandlers(obj, type, genericType, anns, mt);
    if (mc.get(AttachmentUtils.OUT_FILTERS) != null) {
        List<MultipartOutputFilter> filters = CastUtils.cast((List<?>) mc.get(AttachmentUtils.OUT_FILTERS));
        for (MultipartOutputFilter filter : filters) {
            filter.filter(handlers);
        }
    }
    mc.put(MultipartBody.OUTBOUND_MESSAGE_ATTACHMENTS, handlers);
    handlers.get(0).getDataHandler().writeTo(os);
}
Also used : MultipartOutputFilter(org.apache.cxf.jaxrs.ext.multipart.MultipartOutputFilter) Attachment(org.apache.cxf.jaxrs.ext.multipart.Attachment)

Example 2 with MultipartOutputFilter

use of org.apache.cxf.jaxrs.ext.multipart.MultipartOutputFilter in project cxf by apache.

the class AttachmentUtils method addMultipartOutFilter.

public static void addMultipartOutFilter(MultipartOutputFilter filter) {
    Message m = JAXRSUtils.getCurrentMessage();
    List<MultipartOutputFilter> outFilters = CastUtils.cast((List<?>) m.get(OUT_FILTERS));
    if (outFilters == null) {
        outFilters = new ArrayList<>();
        m.put(OUT_FILTERS, outFilters);
    }
    outFilters.add(filter);
}
Also used : Message(org.apache.cxf.message.Message) MultipartOutputFilter(org.apache.cxf.jaxrs.ext.multipart.MultipartOutputFilter)

Example 3 with MultipartOutputFilter

use of org.apache.cxf.jaxrs.ext.multipart.MultipartOutputFilter in project tomee by apache.

the class MultipartProvider method writeTo.

public void writeTo(Object obj, Class<?> type, Type genericType, Annotation[] anns, MediaType mt, MultivaluedMap<String, Object> headers, OutputStream os) throws IOException, WebApplicationException {
    List<Attachment> handlers = convertToDataHandlers(obj, type, genericType, anns, mt);
    if (mc.get(AttachmentUtils.OUT_FILTERS) != null) {
        List<MultipartOutputFilter> filters = CastUtils.cast((List<?>) mc.get(AttachmentUtils.OUT_FILTERS));
        for (MultipartOutputFilter filter : filters) {
            filter.filter(handlers);
        }
    }
    mc.put(MultipartBody.OUTBOUND_MESSAGE_ATTACHMENTS, handlers);
    handlers.get(0).getDataHandler().writeTo(os);
}
Also used : MultipartOutputFilter(org.apache.cxf.jaxrs.ext.multipart.MultipartOutputFilter) Attachment(org.apache.cxf.jaxrs.ext.multipart.Attachment)

Aggregations

MultipartOutputFilter (org.apache.cxf.jaxrs.ext.multipart.MultipartOutputFilter)3 Attachment (org.apache.cxf.jaxrs.ext.multipart.Attachment)2 Message (org.apache.cxf.message.Message)1