Examples of DownloadStream


Examples of com.vaadin.server.DownloadStream

            ImageIO.write(image, "png", imagebuffer);

            // Return a stream from the buffer.
            ByteArrayInputStream istream = new ByteArrayInputStream(
                    imagebuffer.toByteArray());
            DownloadStream downloadStream = new DownloadStream(istream,
                    "image/png", "generatedFile.png");

            if (relativeUri.startsWith("myresource_download")) {
                downloadStream.setParameter("Content-Disposition",
                        "attachment; filename=\"downloadedPNG.png\"");
            }
            downloadStream.writeResponse(request, response);
            return true;
        } catch (IOException e) {
            return false;
        }
    }
View Full Code Here

Examples of com.vaadin.server.DownloadStream

            ImageIO.write(image, "png", imagebuffer);

            // Return a stream from the buffer.
            ByteArrayInputStream istream = new ByteArrayInputStream(
                    imagebuffer.toByteArray());
            new DownloadStream(istream, null, null).writeResponse(request,
                    response);
            return true;
        } catch (IOException e) {
            return false;
        }
View Full Code Here

Examples of com.vaadin.server.DownloadStream

        Matcher matcher = Pattern.compile("(\\d+)(/.*)?").matcher(path);
        if (!matcher.matches()) {
            return super.handleConnectorRequest(request, response, path);
        }

        DownloadStream stream;

        VaadinSession session = getSession();
        session.lock();
        try {
            List<URLReference> sources = getState().sources;

            int sourceIndex = Integer.parseInt(matcher.group(1));

            if (sourceIndex < 0 || sourceIndex >= sources.size()) {
                getLogger().log(Level.WARNING,
                        "Requested source index {0} is out of bounds",
                        sourceIndex);
                return false;
            }

            URLReference reference = sources.get(sourceIndex);
            ConnectorResource resource = (ConnectorResource) ResourceReference
                    .getResource(reference);
            stream = resource.getStream();
        } finally {
            session.unlock();
        }

        stream.writeResponse(request, response);
        return true;
    }
View Full Code Here

Examples of com.vaadin.server.DownloadStream

        Matcher matcher = Pattern.compile("(\\d+)(/.*)?").matcher(path);
        if (!matcher.matches()) {
            return super.handleConnectorRequest(request, response, path);
        }

        DownloadStream stream;

        VaadinSession session = getSession();
        session.lock();
        try {
            List<URLReference> sources = getState().sources;

            int sourceIndex = Integer.parseInt(matcher.group(1));

            if (sourceIndex < 0 || sourceIndex >= sources.size()) {
                getLogger().log(Level.WARNING,
                        "Requested source index {0} is out of bounds",
                        sourceIndex);
                return false;
            }

            URLReference reference = sources.get(sourceIndex);
            ConnectorResource resource = (ConnectorResource) ResourceReference
                    .getResource(reference);
            stream = resource.getStream();
        } finally {
            session.unlock();
        }

        stream.writeResponse(request, response);
        return true;
    }
View Full Code Here

Examples of com.vaadin.terminal.DownloadStream

            // Handles the resource request
            final String key = this.context.getURLKey(context, relativeUri);
            final ApplicationResource resource = keyResourceMap.get(key);
            if (resource != null) {
                DownloadStream stream = resource.getStream();
                if (stream != null) {
                    stream.setCacheTime(resource.getCacheTime());
                    return stream;
                } else {
                    return null;
                }
            } else {
View Full Code Here

Examples of com.vaadin.terminal.DownloadStream

     * @return A {@code DownloadStream} that one of the URI handlers returned,
     *         null if no {@code DownloadStream} was returned.
     */
    public DownloadStream handleURI(URL context, String relativeUri) {

        DownloadStream result = null;
        if (uriHandlerList != null) {
            Object[] handlers;
            synchronized (uriHandlerList) {
                handlers = uriHandlerList.toArray();
            }
            for (int i = 0; i < handlers.length; i++) {
                final DownloadStream ds = ((URIHandler) handlers[i]).handleURI(
                        context, relativeUri);
                if (ds != null) {
                    if (result != null) {
                        throw new RuntimeException("handleURI for " + context
                                + " uri: '" + relativeUri
View Full Code Here

Examples of com.vaadin.terminal.DownloadStream

     */
    protected boolean handleURI(CommunicationManager applicationManager,
            Window window, HttpServletRequest request,
            HttpServletResponse response) throws IOException {
        // Handles the URI
        DownloadStream download = applicationManager.handleURI(window, request,
                response, this);

        // A download request
        if (download != null) {
            // Client downloads an resource
View Full Code Here

Examples of com.vaadin.terminal.DownloadStream

    private boolean handleURI(PortletCommunicationManager applicationManager,
            Window window, ResourceRequest request, ResourceResponse response)
            throws IOException {
        // Handles the URI
        DownloadStream download = applicationManager.handleURI(window, request,
                response, this);

        // A download request
        if (download != null) {
            // Client downloads an resource
View Full Code Here

Examples of com.vaadin.terminal.DownloadStream

                        return gzipEnabled ? "graph.svgz" : "graph.svg";
                    }
                }

                public DownloadStream getStream() {
                    DownloadStream downloadStream = new DownloadStream(
                            getByteStream(), getMIMEType(), getFilename());
                    if (gzipEnabled && mode == RenderingMode.SVG) {
                        downloadStream.setParameter("Content-Encoding", "gzip");
                    }
                    return downloadStream;
                }

                public String getMIMEType() {
View Full Code Here

Examples of com.vaadin.terminal.DownloadStream

     */
    protected boolean handleURI(CommunicationManager applicationManager,
            Window window, HttpServletRequest request,
            HttpServletResponse response) throws IOException {
        // Handles the URI
        DownloadStream download = applicationManager.handleURI(window, request,
                response, this);

        // A download request
        if (download != null) {
            // Client downloads an resource
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.