Examples of MultipartBody


Examples of org.apache.cxf.jaxrs.ext.multipart.MultipartBody

                HttpServletRequest request = (HttpServletRequest)m.get(AbstractHTTPDestination.HTTP_REQUEST);
                FormUtils.populateMapFromString(params, m, (String)body, enc, decode, request);
            } else {
                if (mt != null && "multipart".equalsIgnoreCase(mt.getType())
                    && MediaType.MULTIPART_FORM_DATA_TYPE.isCompatible(mt)) {
                    MultipartBody body = AttachmentUtils.getMultipartBody(mc);
                    FormUtils.populateMapFromMultipart(params, body, m, decode);
                } else {
                    org.apache.cxf.common.i18n.Message errorMsg =
                        new org.apache.cxf.common.i18n.Message("WRONG_FORM_MEDIA_TYPE",
                                                               BUNDLE,
View Full Code Here

Examples of org.apache.cxf.jaxrs.ext.multipart.MultipartBody

            newAttachments.add(new Attachment(a, new ProvidersImpl(inMessage)));
        }
        MediaType mt = embeddedAttachment
            ? (MediaType)inMessage.get("org.apache.cxf.multipart.embedded.ctype")
            : getHttpHeaders().getMediaType();
        MultipartBody body = new MultipartBody(newAttachments, mt, false);
        inMessage.put(propertyName, body);
        return body;
    }
View Full Code Here

Examples of org.apache.cxf.jaxrs.ext.multipart.MultipartBody

            newAttachments.add(new Attachment(a, new ProvidersImpl(inMessage)));
        }
        MediaType mt = embeddedAttachment
            ? (MediaType)inMessage.get("org.apache.cxf.multipart.embedded.ctype")
            : getHttpHeaders().getMediaType();
        MultipartBody body = new MultipartBody(newAttachments, mt, false);
        inMessage.put(propertyName, body);
        return body;
    }
View Full Code Here

Examples of org.apache.cxf.jaxrs.ext.multipart.MultipartBody

                map.put(a.getContentType().toString(), fromAttachment(a, actual, actual, anns));
            }
            return map;
        }
        if (MultipartBody.class.isAssignableFrom(c)) {
            return new MultipartBody(infos);
        }
       
        Multipart id = AnnotationUtils.getAnnotation(anns, Multipart.class);
        Attachment multipart = AttachmentUtils.getMultipart(id, mt, infos);
        if (multipart != null) {
View Full Code Here

Examples of org.apache.cxf.jaxrs.ext.multipart.MultipartBody

        if (is == null) {
            return null;
        }
        try {
            if (mt.isCompatible(MediaType.MULTIPART_FORM_DATA_TYPE)) {
                MultipartBody body = AttachmentUtils.getMultipartBody(mc);
                if (MultipartBody.class.isAssignableFrom(clazz)) {
                    return clazz.cast(body);
                } else if (Attachment.class.isAssignableFrom(clazz)) {
                    return clazz.cast(body.getRootAttachment());
               
            }
           
            MultivaluedMap<String, String> params = createMap(clazz);
            populateMap(params, annotations, is, mt, !keepEncoded(annotations));
View Full Code Here

Examples of org.apache.cxf.jaxrs.ext.multipart.MultipartBody

                               Annotation[] anns,
                               InputStream is,
                               MediaType mt,
                               boolean decode) {
        if (mt.isCompatible(MediaType.MULTIPART_FORM_DATA_TYPE)) {
            MultipartBody body =
                AttachmentUtils.getMultipartBody(mc, attachmentDir, attachmentThreshold, attachmentMaxSize);
            FormUtils.populateMapFromMultipart(params, body, PhaseInterceptorChain.getCurrentMessage(),
                                               decode);
        } else {
            String enc = HttpUtils.getEncoding(mt, "UTF-8");
View Full Code Here

Examples of org.apache.cxf.jaxrs.ext.multipart.MultipartBody

                HttpServletRequest request = (HttpServletRequest)m.get(AbstractHTTPDestination.HTTP_REQUEST);
                FormUtils.populateMapFromString(params, m, body, enc, decode, request);
            } else {
                if ("multipart".equalsIgnoreCase(mt.getType())
                    && MediaType.MULTIPART_FORM_DATA_TYPE.isCompatible(mt)) {
                    MultipartBody body = AttachmentUtils.getMultipartBody(mc);
                    FormUtils.populateMapFromMultipart(params, body, m, decode);
                } else {
                    org.apache.cxf.common.i18n.Message errorMsg =
                        new org.apache.cxf.common.i18n.Message("WRONG_FORM_MEDIA_TYPE",
                                                               BUNDLE,
View Full Code Here

Examples of org.apache.cxf.jaxrs.ext.multipart.MultipartBody

   
    private void doTestGetBookAsPlainContent(String address) throws Exception {
        WebClient wc = WebClient.create(address);
        WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(10000000);
        wc.accept("multipart/mixed");
        MultipartBody book = wc.get(MultipartBody.class);
        Book b = book.getRootAttachment().getObject(Book.class);
        assertEquals(888L, b.getId());
    }
View Full Code Here

Examples of org.apache.cxf.jaxrs.ext.multipart.MultipartBody

        headers.putSingle("Content-Disposition", cd.toString());
        headers.putSingle("Content-Location", "http://host/bar");
        headers.putSingle("custom-header", "custom");
        Attachment att = new Attachment(is1, headers);
       
        MultipartBody body = new MultipartBody(att);
        MultipartBody body2 = client.post(body, MultipartBody.class);
        InputStream is2 = body2.getRootAttachment().getDataHandler().getInputStream();
        byte[] image1 = IOUtils.readBytesFromStream(
            getClass().getResourceAsStream("/org/apache/cxf/systest/jaxrs/resources/java.jpg"));
        byte[] image2 = IOUtils.readBytesFromStream(is2);
        assertTrue(Arrays.equals(image1, image2));
        ContentDisposition cd2 = body2.getRootAttachment().getContentDisposition();
        assertEquals("attachment;filename=java.jpg", cd2.toString());
        assertEquals("java.jpg", cd2.getParameter("filename"));
        assertEquals("http://host/location", body2.getRootAttachment().getHeader("Content-Location"));
    }
View Full Code Here

Examples of org.apache.cxf.jaxrs.ext.multipart.MultipartBody

        MultivaluedMap<String, String> headers = new MetadataMap<String, String>();
        headers.putSingle("Content-Disposition", cd.toString());
        Attachment att = new Attachment(new ByteArrayInputStream("file name with semicolon".getBytes()),
                                        headers);
       
        MultipartBody body = new MultipartBody(att);
        String partContent = client.post(body, String.class);
        assertEquals("file name with semicolon, filename:" + "a;txt", partContent);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.