Examples of ContentDisposition


Examples of com.dotcms.repackage.com.sun.jersey.core.header.ContentDisposition

    Contentlet contentlet=new Contentlet();
   
    Map<String, Object> map = new HashMap<String, Object>();
   
    for(BodyPart part : multipart.getBodyParts()) {
      ContentDisposition cd=part.getContentDisposition();
      String name=cd!=null && cd.getParameters().containsKey("name") ? cd.getParameters().get("name") : "";

      if(part.getMediaType().equals(MediaType.APPLICATION_JSON_TYPE) || name.equals("json")) {
        try {
          processJSON(contentlet,part.getEntityAs(InputStream.class));
        } catch (JSONException e) {
View Full Code Here

Examples of com.sun.jersey.core.header.ContentDisposition

    public ContentDisposition getContentDisposition() {
        if (cd == null) {
            String scd = headers.getFirst("Content-Disposition");
            if (scd != null) {
                try {
                    cd = new ContentDisposition(scd, false);
                } catch (ParseException ex) {
                    throw new IllegalArgumentException("Error parsing content disposition: " + scd, ex);
                }
            }
        }
View Full Code Here

Examples of com.sun.xml.messaging.saaj.packaging.mime.internet.ContentDisposition

          break;
        } else {
          List<String> contentDisposition = mimeAttach.getHeader(JSONCodec.CONTENT_DISPOSITION_HEADER);
          if(contentDisposition != null && contentDisposition.size() > 0){
            try {
              ContentDisposition disp = new ContentDisposition(contentDisposition.get(0));
              if(disp.getParameter("name") != null && disp.getParameter("name").equals(JSON_PARAM_NAME)){
                jsonPart = mimeAttach;
                break;
              }
            } catch (ParseException e) {}
          }
View Full Code Here

Examples of com.sun.xml.messaging.saaj.packaging.mime.internet.ContentDisposition

    if(this.attachments != null){
      for(MIMEPart mimePart : this.attachments){
        List<String> contentDisposition = mimePart.getHeader(JSONCodec.CONTENT_DISPOSITION_HEADER);
        if(contentDisposition != null && contentDisposition.size() > 0){
          try {
            ContentDisposition disp = new ContentDisposition(contentDisposition.get(0));
            if(disp.getParameter("name") != null && disp.getParameter("name").equals(propertyName)){
              if(clazz.isAssignableFrom(DataHandler.class))
                return new DataHandler(new MimePartDataSource(new MimeBodyPart(mimePart.read())));
              else if(clazz.isAssignableFrom(javax.xml.transform.Source.class))
                return new StreamSource(mimePart.read());
            }
View Full Code Here

Examples of javax.mail.internet.ContentDisposition

        MockHttpServletResponse response = new MockHttpServletResponse();
        resolution.applyHeaders(response);
        resolution.stream(response);
        Assert.assertEquals(data, response.getOutputBytes());

        ContentDisposition disposition = getContentDisposition(response);
        if (attachment) {
            if (filename == null) {
                Assert.assertNotNull(disposition);
                Assert.assertEquals("attachment", disposition.getDisposition());
                Assert.assertNull(disposition.getParameter("filename"));
            }
            else {
                Assert.assertNotNull(disposition);
                Assert.assertEquals("attachment", disposition.getDisposition());
                Assert.assertNotNull(disposition.getParameter("filename"));
            }
        }
        else {
            if (filename == null) {
                Assert.assertNull(disposition);
            }
            else {
                Assert.assertNotNull(disposition);
                Assert.assertEquals("attachment", disposition.getDisposition());
                Assert.assertNotNull(disposition.getParameter("filename"));
            }
        }
    }
View Full Code Here

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

                                                Message m,
                                                boolean decode) {
        List<Attachment> atts = body.getAllAttachments();
        checkNumberOfParts(m, atts.size());
        for (Attachment a : atts) {
            ContentDisposition cd = a.getContentDisposition();
            if (cd != null && !MULTIPART_FORM_DATA_TYPE.equalsIgnoreCase(cd.getType())) {
                continue;
            }
            String cdName = cd == null ? null : cd.getParameter("name");
            String contentId = a.getContentId();
            String name = StringUtils.isEmpty(cdName) ? contentId : cdName.replace("\"", "").replace("'", "");
            if (StringUtils.isEmpty(name)) {
                throw new WebApplicationException(400);
            }
View Full Code Here

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

        HTTPConduit conduit = WebClient.getConfig(client).getHttpConduit();
        conduit.getClient().setReceiveTimeout(1000000);
        conduit.getClient().setConnectionTimeout(1000000);
        client.type("multipart/form-data").accept("multipart/form-data");
       
        ContentDisposition cd = new ContentDisposition("attachment;filename=java.jpg");
        Attachment att = new Attachment("image", is1, cd);
       
        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"));
    }
View Full Code Here

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

        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"));
    }
View Full Code Here

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

        HTTPConduit conduit = WebClient.getConfig(client).getHttpConduit();
        conduit.getClient().setReceiveTimeout(1000000);
        conduit.getClient().setConnectionTimeout(1000000);
        client.type("multipart/form-data").accept("multipart/form-data");
       
        ContentDisposition cd = new ContentDisposition("attachment;filename=java.jpg");
        MultivaluedMap<String, String> headers = new MetadataMap<String, String>();
        headers.putSingle("Content-ID", "image");
        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.ContentDisposition

        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("form-data;name=file;filename=java.jpg", cd2.toString());
        assertEquals("java.jpg", cd2.getParameter("filename"));
    }
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.