Package net.sourceforge.stripes.examples.bugzooky.biz

Examples of net.sourceforge.stripes.examples.bugzooky.biz.Attachment


    @DefaultHandler
    public Resolution getAttachment() {
        BugManager bm = new BugManager();
        Bug bug = bm.getBug(this.bugId);
        Attachment attachment = bug.getAttachments().get(this.attachmentIndex);

        // Uses a StreamingResolution to send the file contents back to the user.
        // Note the use of the chained .setFilename() method, which causes the
        // browser to [prompt to] save the "file" instead of displaying it in browser
        return new StreamingResolution
                (attachment.getContentType(), new ByteArrayInputStream(attachment.getData()))
                    .setFilename(attachment.getName());
    }
View Full Code Here


    public Resolution save() throws IOException {
        BugManager bm = new BugManager();

        Bug newBug = populateBug(this.bug);
        if (this.newAttachment != null) {
            Attachment attachment = new Attachment();
            attachment.setName(this.newAttachment.getFileName());
            attachment.setSize(this.newAttachment.getSize());
            attachment.setContentType(this.newAttachment.getContentType());

            byte[] data = new byte[(int) this.newAttachment.getSize()];
            InputStream in = this.newAttachment.getInputStream();
            in.read(data);
            attachment.setData(data);
            newBug.addAttachment(attachment);
        }

        bm.saveOrUpdate(newBug);
View Full Code Here

    public Resolution save() throws IOException {
        BugManager bm = new BugManager();

        Bug bug = getBug();
        if (this.newAttachment != null) {
            Attachment attachment = new Attachment();
            attachment.setName(this.newAttachment.getFileName());
            attachment.setSize(this.newAttachment.getSize());
            attachment.setContentType(this.newAttachment.getContentType());

            byte[] data = new byte[(int) this.newAttachment.getSize()];
            InputStream in = this.newAttachment.getInputStream();
            in.read(data);
            attachment.setData(data);
            bug.addAttachment(attachment);
        }

        // Set the open date for new bugs
        if (bug.getOpenDate() == null)
View Full Code Here

    public Integer getAttachmentIndex() { return attachmentIndex; }
    public void setAttachmentIndex(Integer attachmentIndex) { this.attachmentIndex = attachmentIndex; }

    @DefaultHandler
    public Resolution getAttachment() {
        Attachment attachment = getBug().getAttachments().get(this.attachmentIndex);

        // Uses a StreamingResolution to send the file contents back to the user.
        // Note the use of the chained .setFilename() method, which causes the
        // browser to [prompt to] save the "file" instead of displaying it in browser
        return new StreamingResolution(attachment.getContentType(),
                new ByteArrayInputStream(attachment.getData())).setFilename(attachment.getName());
    }
View Full Code Here

TOP

Related Classes of net.sourceforge.stripes.examples.bugzooky.biz.Attachment

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.