private boolean isSupported(Class<?> type, Type genericType, Annotation[] anns, MediaType mt) { return mediaTypeSupported(mt) && (WELL_KNOWN_MULTIPART_CLASSES.contains(type) || Collection.class.isAssignableFrom(type) || Map.class.isAssignableFrom(type) && type != MultivaluedMap.class || AnnotationUtils.getAnnotation(anns, Multipart.class) != null || PropertyUtils.isTrue(mc.getContextualProperty(SUPPORT_TYPE_AS_MULTIPART))); }
private boolean isSupported(Class<?> type, Type genericType, Annotation[] anns, MediaType mt) { if (DataHandler.class.isAssignableFrom(type) || DataSource.class.isAssignableFrom(type) || Attachment.class.isAssignableFrom(type) || MultipartBody.class.isAssignableFrom(type) || mediaTypeSupported(mt) || isSupportedFormDataType(type, mt)) { if (type == InputStream.class && AnnotationUtils.getAnnotation(anns, Multipart.class) == null && MessageUtils.isTrue(mc.getContextualProperty(JAXRSUtils.DEFAULT_PROVIDERS_FOR_SIMPLE_TYPES))) { return false; } return true; } return false; }
if (multipart != null) { if (collectionExpected && !mediaTypeSupported(multipart.getContentType()) && !PropertyUtils.isTrue(mc.getContextualProperty(SINGLE_PART_IS_COLLECTION))) { List<Attachment> allMultiparts = AttachmentUtils.getMatchingAttachments(id, infos);
if (multipart != null) { if (collectionExpected && !mediaTypeSupported(multipart.getContentType()) && !MessageUtils.isTrue(mc.getContextualProperty(SINGLE_PART_IS_COLLECTION))) { List<Attachment> allMultiparts = AttachmentUtils.getMatchingAttachments(id, infos);
private <T> Object fromAttachment(Attachment multipart, Class<T> c, Type t, Annotation[] anns) throws IOException { if (DataHandler.class.isAssignableFrom(c)) { return multipart.getDataHandler(); } else if (DataSource.class.isAssignableFrom(c)) { return multipart.getDataHandler().getDataSource(); } else if (Attachment.class.isAssignableFrom(c)) { return multipart; } else { if (mediaTypeSupported(multipart.getContentType())) { mc.put("org.apache.cxf.multipart.embedded", true); mc.put("org.apache.cxf.multipart.embedded.ctype", multipart.getContentType()); mc.put("org.apache.cxf.multipart.embedded.input", multipart.getDataHandler().getInputStream()); anns = new Annotation[]{}; } MessageBodyReader<T> r = mc.getProviders().getMessageBodyReader(c, t, anns, multipart.getContentType()); if (r != null) { InputStream is = multipart.getDataHandler().getInputStream(); return r.readFrom(c, t, anns, multipart.getContentType(), multipart.getHeaders(), is); } } return null; }
private <T> Object fromAttachment(Attachment multipart, Class<T> c, Type t, Annotation anns[]) throws IOException { if (DataHandler.class.isAssignableFrom(c)) { return multipart.getDataHandler(); } else if (DataSource.class.isAssignableFrom(c)) { return multipart.getDataHandler().getDataSource(); } else if (Attachment.class.isAssignableFrom(c)) { return multipart; } else { if (mediaTypeSupported(multipart.getContentType())) { mc.put("org.apache.cxf.multipart.embedded", true); mc.put("org.apache.cxf.multipart.embedded.ctype", multipart.getContentType()); mc.put("org.apache.cxf.multipart.embedded.input", multipart.getDataHandler().getInputStream()); anns = new Annotation[]{}; } MessageBodyReader<T> r = mc.getProviders().getMessageBodyReader(c, t, anns, multipart.getContentType()); if (r != null) { InputStream is = multipart.getDataHandler().getInputStream(); is = decodeIfNeeded(multipart, is); return r.readFrom(c, t, anns, multipart.getContentType(), multipart.getHeaders(), is); } } return null; }