Examples of InputRepresentation


Examples of org.restlet.representation.InputRepresentation

     */
    static Form getForm(MediaType mediaType, InputStream entityStream) {
        org.restlet.data.MediaType restletMediaType = Converter
                .toRestletMediaType(mediaType);
        final Form form;
        form = new Form(new InputRepresentation(entityStream, restletMediaType));
        saveToThreadsRequest(form);
        return form;
    }
View Full Code Here

Examples of org.restlet.representation.InputRepresentation

        URL wadl2htmlXsltUrl = Engine
                .getResource("org/restlet/ext/wadl/wadl2html.xslt");

        if (wadl2htmlXsltUrl != null) {
            try {
                InputRepresentation xslRep = new InputRepresentation(
                        wadl2htmlXsltUrl.openStream(),
                        MediaType.APPLICATION_W3C_XSLT);
                representation = new TransformRepresentation(Context
                        .getCurrent(), this, xslRep);
                representation.setMediaType(MediaType.TEXT_HTML);
View Full Code Here

Examples of org.restlet.representation.InputRepresentation

                        log.info("Updating "+file);
                        // update existing media
                        try {
                           FileInputStream is = new FileInputStream(file);
                           EntryClient client = feedClient.getEntryClient(entry);
                           status = client.updateMedia(new InputRepresentation(is,entry.getMediaContent().getMediaType()));
                           is.close();
                        } catch (IOException ex) {
                           log.log(Level.SEVERE,"Cannot update "+file+" due to I/O exception.",ex);
                        }
                        entries.remove(file.getName());
                     } else {
                        log.info("Creating "+file);
                        // create new media
                        try {
                           FileInputStream is = new FileInputStream(file);
                           int extPos = file.getName().lastIndexOf('.');
                           String ext = extPos<0 ? null : file.getName().substring(extPos+1);
                           Metadata metadata = ext==null ? null : metadataService.getMetadata(ext);
                           MediaType type = metadata==null ? MediaType.APPLICATION_OCTET_STREAM : MediaType.valueOf(metadata.getName());
                           Entry mediaEntry = feedClient.createMedia(file.getName(),new InputRepresentation(is,type));
                           is.close();
                        } catch (StatusException ex) {
                           log.log(Level.SEVERE,"Cannot create media entry from "+file+" due to status "+ex.getStatus().getCode(),ex);
                        } catch (Exception ex) {
                           log.log(Level.SEVERE,"Cannot create media entry from "+file+" due to exception.",ex);
View Full Code Here

Examples of org.restlet.representation.InputRepresentation

               appHeaders.add("slug",filename);
               appRequest.getAttributes().put("org.restlet.http.headers",appHeaders);
            }
           
            // setup body
            appRequest.setEntity(new InputRepresentation(is,MediaType.valueOf(headers.get("Content-Type"))));
           
            // make request
            Response appResponse = new Response(appRequest);
            client.handle(appRequest,appResponse);
View Full Code Here

Examples of org.restlet.representation.InputRepresentation

      if (url==null) {
         return null;
      } else {
         try {
            InputStream is = url.openStream();
            return new InputRepresentation(is,type);
         } catch (IOException ex) {
            getLogger().log(Level.SEVERE,"Cannot open resource "+url,ex);
            return null;
         }
      }
View Full Code Here

Examples of org.restlet.representation.InputRepresentation

   public Status storeMedia(String path,UUID feedId,String name,MediaType type,InputStream data)
      throws IOException
   {
      Reference mediaRef = makeMediaReference(path,name);
     
      Response response = put(mediaRef,new InputRepresentation(data,type));
        
      boolean success = response.getStatus().isSuccess();
      boolean hasEntity = response.isEntityAvailable();
      if (!success) {
         Representation rep = response.getEntity();
View Full Code Here

Examples of org.restlet.representation.InputRepresentation

      }
      InputStream is = baseClass.getResourceAsStream(path);
      if (is==null) {
         return null;
      } else {
         return new InputRepresentation(is,type);
      }
   }
View Full Code Here

Examples of org.restlet.representation.InputRepresentation

            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

Examples of org.restlet.representation.InputRepresentation

            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

Examples of org.restlet.representation.InputRepresentation

            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
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.