Examples of FormDataContentDisposition


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

     * Get the control name.
     *
     * @return the control name.
     */
    public String getName() {
        FormDataContentDisposition fdcd = getFormDataContentDisposition();
        if (fdcd == null)
            return null;

        return fdcd.getName();
    }
View Full Code Here

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

    public void setName(String name) {
        if(name == null) {
            throw new IllegalArgumentException("Name can not be null.");
        }
        if (getFormDataContentDisposition() == null) {
            FormDataContentDisposition contentDisposition;
            contentDisposition = FormDataContentDisposition.name(name)
                .build();
            super.setContentDisposition(contentDisposition);
        } else {
            FormDataContentDisposition _cd = getFormDataContentDisposition();
            _cd = FormDataContentDisposition.name(name).
                    fileName(cd.getFileName()).
                    creationDate(cd.getCreationDate()).
                    modificationDate(cd.getModificationDate()).
                    readDate(cd.getReadDate()).
View Full Code Here

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

       
        for (int i = 0; i < mm.getCount(); i++) {
            BodyPart b = mm.getBodyPart(i);
            if (b.getDisposition() != null &&
                    b.getDisposition().equalsIgnoreCase("form-data")) {
                FormDataContentDisposition fdcd = new FormDataContentDisposition(
                        b.getHeader("content-disposition")[0]);
                if (fdcd.getName() != null)
                    m.put(fdcd.getName(), new FormDataBodyPart(b, fdcd));
            }
        }
        return m;
    }
View Full Code Here

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

        for (AttachmentInput attachment : myAttachments) {
          BodyPart bp = new BodyPart(attachment.getInputStream(), MediaType.APPLICATION_OCTET_STREAM_TYPE);
          FormDataContentDisposition.FormDataContentDispositionBuilder dispositionBuilder =
              FormDataContentDisposition.name(FILE_ATTACHMENT_CONTROL_NAME);
          dispositionBuilder.fileName(attachment.getFilename());
          final FormDataContentDisposition formDataContentDisposition = dispositionBuilder.build();
          bp.setContentDisposition(formDataContentDisposition);
          multiPartInput.bodyPart(bp);
        }

        postFileMultiPart(multiPartInput, attachmentsUri);
View Full Code Here

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

        for (AttachmentInput attachment : myAttachments) {
          BodyPart bp = new BodyPart(attachment.getInputStream(), MediaType.APPLICATION_OCTET_STREAM_TYPE);
          FormDataContentDisposition.FormDataContentDispositionBuilder dispositionBuilder =
              FormDataContentDisposition.name(FILE_ATTACHMENT_CONTROL_NAME);
          dispositionBuilder.fileName(attachment.getFilename());
          final FormDataContentDisposition formDataContentDisposition = dispositionBuilder.build();
          bp.setContentDisposition(formDataContentDisposition);
          multiPartInput.bodyPart(bp);
        }

        postFileMultiPart(multiPartInput, attachmentsUri);
View Full Code Here

Examples of org.glassfish.jersey.media.multipart.FormDataContentDisposition

    @Test
    @Override
    public void testCreate() {
        final Date date = new Date();
        FormDataContentDisposition contentDisposition;
        contentDisposition = FormDataContentDisposition.name("testData").fileName("test.file").creationDate(date)
                .modificationDate(date).readDate(date).size(1222).build();
        assertFormDataContentDisposition(contentDisposition, date);
        try {
            final String dateString = HttpDateFormat.getPreferredDateFormat().format(date);
            final String header = contentDispositionType + ";filename=\"test.file\";creation-date=\"" + dateString
                    + "\";modification-date=\"" + dateString + "\";read-date=\"" + dateString + "\";size=1222" + ";name=\"testData\"";

            contentDisposition = new FormDataContentDisposition(contentDisposition.toString());
            assertFormDataContentDisposition(contentDisposition, date);
            contentDisposition = new FormDataContentDisposition(header);
            assertFormDataContentDisposition(contentDisposition, date);
            contentDisposition = new FormDataContentDisposition(HttpHeaderReader.newInstance(header), true);
            assertFormDataContentDisposition(contentDisposition, date);
        }
        catch (final ParseException ex) {
            fail(ex.getMessage());
        }
        try {
            new FormDataContentDisposition((HttpHeaderReader) null, true);
            fail("NullPointerException was expected to be thrown.");
        }
        catch (final ParseException exception) {
            fail(exception.getMessage());
        }
        catch (final NullPointerException exception) {
            //expected
        }
        try {
            new FormDataContentDisposition("form-data;filename=\"test.file\"");
            fail("IllegalArgumentException was expected to be thrown.");
        }
        catch (final ParseException exception) {
            fail(exception.getMessage());
        }
View Full Code Here

Examples of org.glassfish.jersey.media.multipart.FormDataContentDisposition

    @Test
    @Override
    public void testToString() {
        final Date date = new Date();
        final FormDataContentDisposition contentDisposition = FormDataContentDisposition.name("testData")
                .fileName("test.file").creationDate(date).modificationDate(date).
                readDate(date).size(1222).build();
        final String dateString = HttpDateFormat.getPreferredDateFormat().format(date);
        final String header = contentDispositionType + "; filename=\"test.file\"; creation-date=\"" + dateString
                + "\"; modification-date=\"" + dateString + "\"; read-date=\"" + dateString + "\"; size=1222" + "; name=\"testData\"";

        assertEquals(header, contentDisposition.toString());
    }
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.