Package org.restlet.representation

Examples of org.restlet.representation.InputRepresentation


                    image[i] = (byte)(i + 1);
                }
                ByteArrayInputStream inputStream = new ByteArrayInputStream(image);

                from("restlet:http://0.0.0.0:" + portNum + "/images/{symbol}?restletMethods=get")
                    .setBody().constant(new InputRepresentation(inputStream, MediaType.IMAGE_PNG, 10));
            }
        };
    }
View Full Code Here


            // its already a restlet response, so dont do anything
            LOG.debug("Using existing Restlet Response from exchange body: {}", body);
        } else if (body instanceof Representation) {
            response.setEntity(out.getBody(Representation.class));
        } else if (body instanceof InputStream) {
            response.setEntity(new InputRepresentation(out.getBody(InputStream.class), mediaType));
        } else if (body instanceof File) {
            response.setEntity(new FileRepresentation(out.getBody(File.class), mediaType));
        } else {
            // fallback and use string
            String text = out.getBody(String.class);
View Full Code Here

            response.setEntity("", MediaType.TEXT_PLAIN);
        } else if (body instanceof Response) {
            // its already a restlet response, so dont do anything
            LOG.debug("Using existing Restlet Response from exchange body: {}", body);
        } else if (body instanceof InputStream) {
            response.setEntity(new InputRepresentation(out.getBody(InputStream.class), mediaType));
        } else if (body instanceof File) {
            response.setEntity(new FileRepresentation(out.getBody(File.class), mediaType));
        } else {
            // fallback and use string
            String text = out.getBody(String.class);
View Full Code Here

        {
            // TODO There's probably a helper somewhere that can do this more nicely
            if( getRequest().getOriginalRef().getLastSegment().equals( "sparqlhtml.xsl" ) )
            {
                InputStream resourceAsStream = getClass().getResourceAsStream( "sparqlhtml.xsl" );
                return new InputRepresentation( resourceAsStream, MediaType.TEXT_XML );
            }

            Form form;
            if( getRequest().getMethod().equals( Method.POST ) )
            {
                form = new Form(getRequest().getEntity());
            }
            else
            {
                form = getRequest().getResourceRef().getQueryAsForm();
            }

            final RepositoryConnection conn = repository.getConnection();

            String queryStr = form.getFirstValue( "query" );

            if( queryStr == null )
            {
                InputStream resourceAsStream = getClass().getResourceAsStream( "sparqlform.html" );
                return new InputRepresentation( resourceAsStream, MediaType.TEXT_HTML );
            }

            Query query = getQuery( repository, conn, queryStr );

            if( query instanceof TupleQuery )
View Full Code Here

            // its already a restlet response, so dont do anything
            LOG.debug("Using existing Restlet Response from exchange body: {}", body);
        } else if (body instanceof Representation) {
            response.setEntity(out.getBody(Representation.class));
        } else if (body instanceof InputStream) {
            response.setEntity(new InputRepresentation(out.getBody(InputStream.class), mediaType));
        } else if (body instanceof File) {
            response.setEntity(new FileRepresentation(out.getBody(File.class), mediaType));
        } else {
            // fallback and use string
            String text = out.getBody(String.class);
View Full Code Here

            response.setEntity("", MediaType.TEXT_PLAIN);
        } else if (body instanceof Response) {
            // its already a restlet response, so dont do anything
            LOG.debug("Using existing Restlet Response from exchange body: {}", body);
        } else if (body instanceof InputStream) {
            response.setEntity(new InputRepresentation(out.getBody(InputStream.class), mediaType));
        } else if (body instanceof File) {
            response.setEntity(new FileRepresentation(out.getBody(File.class), mediaType));
        } else {
            // fallback and use string
            String text = out.getBody(String.class);
View Full Code Here

    }
    else if (form != null && form instanceof InputStream) {
      is = (InputStream) form;
    }
    if (is != null) {
      InputRepresentation output = new InputRepresentation(is);
      return output;
   
    } else if (form != null){
      throw new ActivitiException("The form for process definition '" + processDefinitionId + "' failed to render.");
   
View Full Code Here

    }
    else if (form != null && form instanceof InputStream) {
      is = (InputStream) form;
    }
    if (is != null) {
      InputRepresentation output = new InputRepresentation(is);
      return output;
   
    } else if (form != null){
      throw new ActivitiException("The form for task '" + taskId + "' cannot be rendered using the rest api.");
   
View Full Code Here

        processDefinition.getDeploymentId(), processDefinition.getDiagramResourceName());

    if (definitionImageStream == null) {
      throw new ActivitiException("Diagram resource could not be found");
    }
    return new InputRepresentation(definitionImageStream, MediaType.IMAGE_PNG);
  }
View Full Code Here

      if(contentType.contains(";")) {
        contentType = contentType.substring(0, contentType.indexOf(";"));
      }
      mediatType = MediaType.valueOf(contentType);
    }
    InputRepresentation output = new InputRepresentation(picture.getInputStream(), mediatType);
    getResponse().getCacheDirectives().add(CacheDirective.maxAge(28800));
   
    return output;
  }
View Full Code Here

TOP

Related Classes of org.restlet.representation.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.