Package org.restlet.resource

Examples of org.restlet.resource.InputRepresentation


                // Return the entry content
                MetadataService metadataService = getMetadataService(request);
                InputStream ris = getServletContext().getResourceAsStream(
                        basePath);
                if (ris != null) {
                    output = new InputRepresentation(ris, metadataService
                            .getDefaultMediaType());
                    output.setIdentifier(request.getResourceRef());
                    updateMetadata(metadataService, entry, output);

                    // See if the Servlet context specified a particular Mime
View Full Code Here


     */
    public Representation getResponseEntity() {
        Representation result = null;

        if (getResponseStream() != null) {
            result = new InputRepresentation(getResponseStream(), null);
        } else if (getResponseChannel() != null) {
            result = new ReadableRepresentation(getResponseChannel(), null);
        } else if (getMethod().equals(Method.HEAD.getName())) {
            result = new Representation() {
                @Override
View Full Code Here

            int timeToLive) {
        Representation result = null;

        InputStream ris = getServletContext().getResourceAsStream(path);
        if (ris != null) {
            result = new InputRepresentation(ris, defaultMediaType);
            // Sets the modification date
            String realPath = getServletContext().getRealPath(path);
            if (realPath != null) {
                File file = new File(realPath);
                if (file != null) {
View Full Code Here

        // Return the entry content
        MetadataService metadataService = getMetadataService(request);
        InputStream ris = getServletContext().getResourceAsStream(
            basePath);
        if (ris != null) {
          output = new InputRepresentation(ris, metadataService
              .getDefaultMediaType());
          output.setIdentifier(request.getResourceRef());
          updateMetadata(metadataService, entry, output);

          // See if the Servlet context specified a particular Mime
View Full Code Here

    public void handlePost() {
        final Request request = getRequest();
        final String resource = RESTUtils.getStringAttribute(getRequest(), "resource");
        checkArgument("run-command".equals(resource), "Invalid entry point. Expected: run-command.");
        JsonParser parser = new JsonParser();
        InputRepresentation entityAsObject = (InputRepresentation) request.getEntity();
        JsonObject json;
        try {
            InputStream stream = entityAsObject.getStream();
            InputStreamReader reader = new InputStreamReader(stream);
            json = (JsonObject) parser.parse(reader);
        } catch (Exception e) {
            throw Throwables.propagate(e);
        }
View Full Code Here

        // Create the result representation
        final InputStream requestStream = getRequestEntityStream(contentLength);
        final ReadableByteChannel requestChannel = getRequestEntityChannel(contentLength);

        if (requestStream != null) {
            result = new InputRepresentation(requestStream, null, contentLength);
        } else if (requestChannel != null) {
            result = new ReadableRepresentation(requestChannel, null,
                    contentLength);
        }
View Full Code Here

                // Return the entry content
                MetadataService metadataService = getMetadataService(request);
                InputStream ris = getServletContext().getResourceAsStream(
                        basePath);
                if (ris != null) {
                    output = new InputRepresentation(ris, metadataService
                            .getDefaultMediaType());
                    output.setIdentifier(request.getResourceRef());
                    updateMetadata(metadataService, entry, output);

                    // See if the Servlet context specified a particular Mime
View Full Code Here

    protected Request newRequestPOST(String path, String body, String contentType) {
        Request request = new Request();
        request.setMethod( Method.POST );
        request.setResourceRef( "http://localhost/" + path );
        request.setEntity(
            new InputRepresentation( new ByteArrayInputStream( body.getBytes() ), new MediaType( contentType ) )
        );
        return request;
    }
View Full Code Here

        // Create the result representation
        final InputStream requestStream = getRequestEntityStream(contentLength);
        final ReadableByteChannel requestChannel = getRequestEntityChannel(contentLength);

        if (requestStream != null) {
            result = new InputRepresentation(requestStream, null, contentLength);
        } else if (requestChannel != null) {
            result = new ReadableRepresentation(requestChannel, null,
                    contentLength);
        }
View Full Code Here

     * @param stream
     *            The response input stream.
     * @return The wrapping representation.
     */
    protected Representation getRepresentation(InputStream stream) {
        return new InputRepresentation(stream, null);
    }
View Full Code Here

TOP

Related Classes of org.restlet.resource.InputRepresentation

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.