Package org.restlet.data

Examples of org.restlet.data.MediaType


    }
    protected File handleFileUpload(String store, String format, File directory) {
        getResponse().setStatus(Status.SUCCESS_ACCEPTED);

        MediaType mediaType = getRequest().getEntity().getMediaType();
        if(LOGGER.isLoggable(Level.INFO))
            LOGGER.info("PUT file, mimetype: " + mediaType );

        File uploadedFile = null;
        try {
View Full Code Here


            }
        }
       
        if ( ext != null ) {
            //lookup the media type matching the extension
            MediaType mt = MediaTypes.getMediaTypeForExtension( ext );
            if ( mt != null ) {
                df = lookupFormat(mt);
            }
        }
       
View Full Code Here

     * The format is located by looking up <pre>getRequest().getEntity().getMediaType()</pre> from
     * the list created by {@link #createSupportedFormats()}.
     * </p>
     */
    protected DataFormat getFormatPostOrPut() {
        MediaType type = getRequest().getEntity().getMediaType();
        if ( type != null ) {
            //DataFormat format = getFormats().get( type.toString() );
            DataFormat format = lookupFormat( type );
            /*
            if ( format == null ) {
View Full Code Here

        // return flow context
        return flowContext;
    }

    protected MediaType convertStringToMediaType(String mediaTypeName) {
        MediaType mt = null;
        try {
            mt = (MediaType) MediaType.class.getField(mediaTypeName).get(MediaType.class);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (NoSuchFieldException e) {
View Full Code Here

        String body = exchange.getIn().getBody(String.class);
        Form form = new Form();
        // add the body as the key in the form with null value
        form.add(body, null);

        MediaType mediaType = exchange.getIn().getHeader(Exchange.CONTENT_TYPE, MediaType.class);
        if (mediaType == null) {
            mediaType = MediaType.APPLICATION_WWW_FORM;
        }

        if (LOG.isDebugEnabled()) {
View Full Code Here

        } else {
            out = exchange.getOut();
        }

        // get content type
        MediaType mediaType = out.getHeader(Exchange.CONTENT_TYPE, MediaType.class);
        if (mediaType == null) {
            Object body = out.getBody();
            mediaType = MediaType.TEXT_PLAIN;
            if (body instanceof String) {
                mediaType = MediaType.TEXT_PLAIN;
View Full Code Here

        int responseCode = response.getStatus().getCode();
        exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, responseCode);

        if (response.getEntity() != null) {
            // get content type
            MediaType mediaType = response.getEntity().getMediaType();
            if (mediaType != null) {
                exchange.getOut().setHeader(Exchange.CONTENT_TYPE, mediaType.toString());
            }

            // get content text
            String text = response.getEntity().getText();
            if (LOG.isDebugEnabled()) {
View Full Code Here

                response = createDocument(TYPE_SIGNON, opEndpoint,
                        localId.toString());
            }
        }

        MediaType xrds = new MediaType("application/xrds+xml");
        return new DomRepresentation(xrds, response);
    }
View Full Code Here

            return;
        }
        Response response = get(MediaType.TEXT_ALL);
        sysOutEntityIfError(response);
        Representation representation = response.getEntity();
        final MediaType mediaType = representation.getMediaType();
        assertEquals(Status.SUCCESS_OK, response.getStatus());
        assertTrue(mediaType.equals(MediaType.TEXT_PLAIN, true)
                || mediaType.equals(MediaType.TEXT_HTML, true));

        response = get(MediaType.TEXT_PLAIN);
        sysOutEntityIfError(response);
        assertTrue(response.getStatus().isSuccess());
        representation = response.getEntity();
View Full Code Here

     * @param feedType
     *            The source feed type.
     * @return The result media type or null.
     */
    public static MediaType getMediaType(String feedType) {
        MediaType result = null;

        if (feedType != null) {
            result = feedType.startsWith("atom") ? MediaType.APPLICATION_ATOM
                    : MediaType.APPLICATION_RSS;
        }
View Full Code Here

TOP

Related Classes of org.restlet.data.MediaType

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.