Package org.jresearch.gossip.beans.forum.attachment

Examples of org.jresearch.gossip.beans.forum.attachment.FileData


     * @return @throws
     *         SQLException
     * @throws SystemException
     */
    public FileData getAttachment(int id) throws SQLException, SystemException {
        FileData fd = new FileData();
        fd.setInfo(getAttachmentInfo(id));
        IFileProcessor fProc = getFileProcessor(IFileProcConst.ATTACH_FILE_PROCESSOR);
        byte[] data = fProc.getFileData(IFileProcConst.ATTACH_KEY_PREFIX + id);
        if (data == null) {
            data = new byte[0];
        }
        fd.setData(data);
        return fd;

    }
View Full Code Here


        try {
            for (int i = 0; i < files.length; i++) {
                int id = ((Integer) keyGen.generateKey(
                        IKeyGenConst.KEY_NAMES[IKeyGenConst.KEY_ATTACH],
                        connection)).intValue();
                FileData fd = files[i];
                st.setInt(1, id);
                st.setString(2, fd.getInfo().getContentType());
                st.setString(3, fd.getInfo().getName());
                st.setString(4, fd.getInfo().getDescription());
                st.setInt(5, fd.getInfo().getSize());
                st.setInt(6, fd.getInfo().getMessageId());
                st.execute();

                fProc.saveFileData(fd.getData(),
                        IFileProcConst.ATTACH_KEY_PREFIX + id);
            }
        } finally {
            st.close();
            connection.close();
View Full Code Here

        User user = (User) session.getAttribute(IConst.SESSION.USER_KEY);
        ForumDAO dao = ForumDAO.getInstance();
        ProcessAttachForm paForm = (ProcessAttachForm) form;
        if (Configurator.getInstance().getBoolean(
                IConst.CONFIG.ENABLE_FILE_UPLOAD)) {
            FileData fData = dao
                    .getAttachment(Integer.parseInt(paForm.getId()));
            response.setContentType(IConst.JSP.JPG_CONTENT_TYPE);
            ServletOutputStream out = response.getOutputStream();
            ByteArrayInputStream b = new ByteArrayInputStream(fData.getData());
            BufferedImage img = ImageIO.read(b);
            if (img == null) { throw new SystemException(
                    "Unable to parse image"); }
            PictureGenerator.getInstance().prepareImageThumbnail(img, out);
        } else {
View Full Code Here

        ForumDAO dao = ForumDAO.getInstance();

        FileData[] filedata = new FileData[files[0].size()];
        //populate filedata
        for (int i = 0; i < filedata.length; i++) {
            FileData fdata = new FileData();
            FileDataInfo finfo = new FileDataInfo();
            FormFile file = (FormFile) files[0].get(i);

            finfo.setContentType(file.getContentType());
            fdata.setData(file.getFileData());

            finfo.setDescription((String) files[1].get(i));
            finfo.setMessageId(mid);
            finfo.setName(file.getFileName());
            finfo.setSize(file.getFileSize());

            fdata.setInfo(finfo);

            filedata[i] = fdata;
        }
        //save filedata
        dao.saveAttachments(filedata);
View Full Code Here

        User user = (User) session.getAttribute(IConst.SESSION.USER_KEY);
        ForumDAO dao = ForumDAO.getInstance();
        ProcessAttachForm paForm = (ProcessAttachForm) form;
        if (Configurator.getInstance().getBoolean(
                IConst.CONFIG.ENABLE_FILE_UPLOAD)) {
            FileData fData = dao
                    .getAttachment(Integer.parseInt(paForm.getId()));
            String mime = fData.getInfo().getContentType();
            response.setContentType(mime);
            if (!(IConst.JSP.JPG_CONTENT_TYPE.equals(mime)
                    || IConst.JSP.GIF_CONTENT_TYPE.equals(mime) || IConst.JSP.PNG_CONTENT_TYPE
                    .equals(mime))) {
                response.setHeader("Content-disposition",
                        "attachment;filename=\"" + fData.getInfo().getName()
                                + "\"");
            }
            response.addHeader("Content-description", fData.getInfo()
                    .getDescription());
            ServletOutputStream outStream = response.getOutputStream();
            outStream.write(fData.getData());
            outStream.flush();
            outStream.close();
        } else {
            return (mapping.findForward(IConst.TOKEN.DENIED));
        }
View Full Code Here

TOP

Related Classes of org.jresearch.gossip.beans.forum.attachment.FileData

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.