Package org.apache.wink.common.internal.http

Examples of org.apache.wink.common.internal.http.ContentDispositionHeader


                        MediaType mediaType,
                        MultivaluedMap<String, Object> httpHeaders,
                        OutputStream entityStream) throws IOException, WebApplicationException {

        // set content disposition. This will enable browsers to open excel
        ContentDispositionHeader contentDispositionHeader =
            ContentDispositionHeader.createContentDispositionHeader(MediaTypeUtils.CSV);
        contentDispositionHeader.setFileName("representation");
        httpHeaders
            .putSingle(CONTENT_DISPOSITION_HEADER, header.toString(contentDispositionHeader));

        Charset charset = Charset.forName(ProviderUtils.getCharset(mediaType));
        OutputStreamWriter writer = new OutputStreamWriter(entityStream, charset);
View Full Code Here


* Unit test of ContentDispositionHelper
*/
public class ContentDispositionHeaderDelegateTest extends TestCase {

    public void testDispositionAttachmentFilename() {
        ContentDispositionHeader contentDispositionHeader = new ContentDispositionHeader();
        contentDispositionHeader.setAttachment(true);
        contentDispositionHeader.setFileName("fileName.xml");
        HeaderDelegate<ContentDispositionHeader> headerDelegate =
            RuntimeDelegate.getInstance().createHeaderDelegate(ContentDispositionHeader.class);
        String header = headerDelegate.toString(contentDispositionHeader);

        assertEquals("header value", "attachment; filename=\"fileName.xml\"", header);
View Full Code Here

        assertEquals("header value", "attachment; filename=\"fileName.xml\"", header);
    }

    public void testDispositionInlineFilename() {
        ContentDispositionHeader contentDispositionHeader = new ContentDispositionHeader();
        contentDispositionHeader.setAttachment(false);
        contentDispositionHeader.setFileName("fileName.xml");
        HeaderDelegate<ContentDispositionHeader> headerDelegate =
            RuntimeDelegate.getInstance().createHeaderDelegate(ContentDispositionHeader.class);
        String header = headerDelegate.toString(contentDispositionHeader);

        assertEquals("header value", "inline; filename=\"fileName.xml\"", header);
View Full Code Here

        assertEquals("header value", "inline; filename=\"fileName.xml\"", header);
    }

    public void testDispositionInlineNoFilename() {
        ContentDispositionHeader contentDispositionHeader = new ContentDispositionHeader();
        contentDispositionHeader.setAttachment(false);
        HeaderDelegate<ContentDispositionHeader> headerDelegate =
            RuntimeDelegate.getInstance().createHeaderDelegate(ContentDispositionHeader.class);
        String header = headerDelegate.toString(contentDispositionHeader);
        assertEquals("header value", "inline", header);
    }
View Full Code Here

                        MediaType mediaType,
                        MultivaluedMap<String, Object> httpHeaders,
                        OutputStream entityStream) throws IOException, WebApplicationException {

        // set content disposition. This will enable browsers to open excel
        ContentDispositionHeader contentDispositionHeader =
            ContentDispositionHeader.createContentDispositionHeader(MediaTypeUtils.CSV);
        contentDispositionHeader.setFileName("representation"); //$NON-NLS-1$
        httpHeaders
            .putSingle(CONTENT_DISPOSITION_HEADER, header.toString(contentDispositionHeader));

        Charset charset = Charset.forName(ProviderUtils.getCharset(mediaType));
        OutputStreamWriter writer = new OutputStreamWriter(entityStream, charset);
View Full Code Here

                        MediaType mediaType,
                        MultivaluedMap<String, Object> httpHeaders,
                        OutputStream entityStream) throws IOException, WebApplicationException {

        // set content disposition. This will enable browsers to open excel
        ContentDispositionHeader contentDispositionHeader =
            ContentDispositionHeader.createContentDispositionHeader(MediaTypeUtils.CSV_TYPE);
        contentDispositionHeader.setFileName("representation"); //$NON-NLS-1$
        httpHeaders
            .putSingle(CONTENT_DISPOSITION_HEADER, header.toString(contentDispositionHeader));

        Charset charset = Charset.forName(ProviderUtils.getCharset(mediaType));
        OutputStreamWriter writer = new OutputStreamWriter(entityStream, charset);
View Full Code Here

* Unit test of ContentDispositionHelper
*/
public class ContentDispositionHeaderDelegateTest extends TestCase {

    public void testDispositionAttachmentFilename() {
        ContentDispositionHeader contentDispositionHeader = new ContentDispositionHeader();
        contentDispositionHeader.setAttachment(true);
        contentDispositionHeader.setFileName("fileName.xml");
        HeaderDelegate<ContentDispositionHeader> headerDelegate =
            RuntimeDelegate.getInstance().createHeaderDelegate(ContentDispositionHeader.class);
        String header = headerDelegate.toString(contentDispositionHeader);

        assertEquals("header value", "attachment; filename=\"fileName.xml\"", header);
View Full Code Here

        assertEquals("header value", "attachment; filename=\"fileName.xml\"", header);
    }

    public void testDispositionInlineFilename() {
        ContentDispositionHeader contentDispositionHeader = new ContentDispositionHeader();
        contentDispositionHeader.setAttachment(false);
        contentDispositionHeader.setFileName("fileName.xml");
        HeaderDelegate<ContentDispositionHeader> headerDelegate =
            RuntimeDelegate.getInstance().createHeaderDelegate(ContentDispositionHeader.class);
        String header = headerDelegate.toString(contentDispositionHeader);

        assertEquals("header value", "inline; filename=\"fileName.xml\"", header);
View Full Code Here

        assertEquals("header value", "inline; filename=\"fileName.xml\"", header);
    }

    public void testDispositionInlineNoFilename() {
        ContentDispositionHeader contentDispositionHeader = new ContentDispositionHeader();
        contentDispositionHeader.setAttachment(false);
        HeaderDelegate<ContentDispositionHeader> headerDelegate =
            RuntimeDelegate.getInstance().createHeaderDelegate(ContentDispositionHeader.class);
        String header = headerDelegate.toString(contentDispositionHeader);
        assertEquals("header value", "inline", header);
    }
View Full Code Here

TOP

Related Classes of org.apache.wink.common.internal.http.ContentDispositionHeader

Copyright © 2018 www.massapicom. 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.