/** * Returns the representation wrapping the given stream. * * @param stream * The response input stream. * @return The wrapping representation. */ protected Representation getRepresentation(InputStream stream) { return new InputRepresentation(stream, null); }
/** * Sets the input stream to use. * * @param stream * The input stream to use. */ public void setStream(InputStream stream) { this.stream = stream; setAvailable(stream != null); }
/** * Constructor. * * @param inputStream * The representation's stream. * @param mediaType * The representation's media type. * @param expectedSize * The expected input stream size. */ public InputRepresentation(InputStream inputStream, MediaType mediaType, long expectedSize) { super(mediaType); setSize(expectedSize); setTransient(true); setStream(inputStream); }
InputRepresentation inputRepresentation = new InputRepresentation(inputStream, mediaType); inputRepresentation.setMediaType(MediaType.APPLICATION_OCTET_STREAM);
@Override public InputStream getStream() throws IOException { if (Edition.CURRENT != Edition.GWT) { final InputStream result = this.stream; setStream(null); return result; } return this.stream; }
@Override public InputStream getStream() throws IOException { // if (Edition.CURRENT != Edition.GWT) { final InputStream result = this.stream; setStream(null); return result; // } // // return this.stream; }
@Override public Representation getRepresentation(MediaType defaultMediaType, int timeToLive) { final InputStream ris = getServletContext().getResourceAsStream(path); return (ris == null) ? null : new InputRepresentation(ris, defaultMediaType); }
/** * Constructor. * * @param inputStream * The representation's stream. * @param mediaType * The representation's media type. * @param expectedSize * The expected input stream size. */ public InputRepresentation(InputStream inputStream, MediaType mediaType, long expectedSize) { super(mediaType); setSize(expectedSize); setTransient(true); setStream(inputStream); }
/** * Sets the input stream to use. * * @param stream * The input stream to use. */ public void setStream(InputStream stream) { this.stream = stream; setAvailable(stream != null); }
@Override protected Representation get() throws ResourceException { String path = UmlgURLDecoder.decode(getQueryValue("path")); if (path.endsWith("SVG") || path.endsWith("svg")) { return new InputRepresentation(Thread.currentThread().getContextClassLoader().getResourceAsStream(path), MediaType.IMAGE_SVG); } else { return new InputRepresentation(Thread.currentThread().getContextClassLoader().getResourceAsStream(path), MediaType.IMAGE_PNG); } }
@Override public void setInputStream(InputStream stream) { getRequest().setEntity(new InputRepresentation(stream)); }
/** * @param mediaType * @param entityStream * @return */ static Form getForm(MediaType mediaType, InputStream entityStream) { Form form = new Form(new InputRepresentation(entityStream, toRestletMediaType(mediaType))); Request.getCurrent().setEntity(form.getWebRepresentation()); return form; }
@Override public Object readFrom(Class<Object> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException { Representation sourceRepresentation = new InputRepresentation(entityStream, toRestletMediaType(mediaType)); return getConverterService().toObject(sourceRepresentation, type, null); }
@Put public String store(Representation input) throws Exception { // Create a factory for disk-based file items RestletFileUpload fileUpload = new RestletFileUpload( new DiskFileItemFactory()); List<FileItem> fileItems = fileUpload.parseRepresentation(input); for (FileItem fileItem : fileItems) { if (fileItem.isFormField()) { System.out.println(fileItem.getFieldName() + "=" + fileItem.getString()); } else { Representation attachment = new InputRepresentation( fileItem.getInputStream()); attachment.write(System.out); } } return "Mail updated!"; } }
@Put public String store(Representation input) throws Exception { // Create a factory for disk-based file items RestletFileUpload fileUpload = new RestletFileUpload( new DiskFileItemFactory()); List<FileItem> fileItems = fileUpload.parseRepresentation(input); for (FileItem fileItem : fileItems) { if (fileItem.isFormField()) { System.out.println(fileItem.getFieldName() + "=" + fileItem.getString()); } else { Representation attachment = new InputRepresentation( fileItem.getInputStream()); attachment.write(System.out); } } return "Mail updated!"; } }
new InputRepresentation(entityStream, org.restlet.data.MediaType.APPLICATION_WWW_FORM); Form form = new Form(representation);
result = source.getStream(); } else if (InputRepresentation.class.isAssignableFrom(target)) { result = new InputRepresentation(source.getStream()); } else if (Reader.class.isAssignableFrom(target)) { result = source.getReader();
Representation output = new InputRepresentation( url.openStream(), metadataService.getDefaultMediaType());
Representation output = new InputRepresentation( inputStream, metadataService.getDefaultMediaType());
InputRepresentation xslRep = new InputRepresentation( wadl2htmlXsltUrl.openStream(), MediaType.APPLICATION_W3C_XSLT);