亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? attachmentwebhandler.java

?? java servlet著名論壇源代碼
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
            // have permission, just do nothing, that is dont check the max day contraint
        } else if ( (logonMemberID==authorID) && onlineUser.isMember() ) {
            // same author, but not guest
            // check date here, usually must not older than 1 days
            Timestamp postDate = postBean.getPostCreationDate();
            /** @todo config maxDays */
            int maxDays = 1;
            if ( (now.getTime() - postDate.getTime()) > (DateUtil.DAY * maxDays) ) {
                /** @todo choose a better Exception here */
                throw new BadInputException("You cannot attach a file to a post which is older than " + maxDays + " days.");
            }
            /** @todo check status of this post */
            /*
            if (postBean.getPostStatus() == ?) {
                throw new BadInputException("Cannot attach a file to disabled post.");
            }*/
        } else {//not an author, so this user must have Edit Permission
            //@todo is this the correct permission checking ??? Igor: yes it is
            permission.ensureCanEditPost(forumID);// this method ALWAYS throws AuthenticationException
        }

        // now all contraints/permission have been checked
        // values that we can init now
        String attachCreationIP     = request.getRemoteAddr();
        Timestamp attachCreationDate= now;
        Timestamp attachModifiedDate= now;
        int attachDownloadCount     = 0;
        int attachOption            = 0;// check it
        int attachStatus            = 0;// check it

        int attachID = DAOFactory.getAttachmentDAO().createAttachment(postID, logonMemberID, attachFilename,
                                         attachFileSize, attachMimeType, attachDesc,
                                         attachCreationIP, attachCreationDate, attachModifiedDate,
                                         attachDownloadCount, attachOption, attachStatus);

        try {
            String filename = AttachmentUtil.getAttachFilenameOnDisk(attachID);
            log.debug("Attach filename to save to file system = " + filename);
            attachFileItem.write(filename);
        } catch (Exception ex) {
            log.error("Cannot save the attachment file", ex);
            DAOFactory.getAttachmentDAO().delete(attachID);
            throw new IOException("Cannot save the attachment file to the file system.");
        }

        // we dont want the exception to throw below this
        int attachCount = DAOFactory.getAttachmentDAO().getNumberOfBeans_inPost(postID);
        DAOFactory.getPostDAO().updateAttachCount(postID, attachCount);

        request.setAttribute("ForumID", String.valueOf(forumID));
        request.setAttribute("ThreadID", String.valueOf(postBean.getThreadID()));
        request.setAttribute("PostID", String.valueOf(postID));
        request.setAttribute("offset", String.valueOf(offset));
        request.setAttribute("AttachMore", new Boolean(attachMore));
    }

    void prepareDelete(HttpServletRequest request)
        throws ObjectNotFoundException, BadInputException, DatabaseException, AuthenticationException, AssertionException {

        OnlineUser onlineUser = userManager.getOnlineUser(request);
        MVNForumPermission permission = onlineUser.getPermission();

        // primary key column(s)
        int attachID = ParamUtil.getParameterInt(request, "attach");

        AttachmentBean attachmentBean = DAOFactory.getAttachmentDAO().getBean(attachID);
        int postID = attachmentBean.getPostID();
        PostBean postBean = DAOFactory.getPostDAO().getPost(postID);

        // now, check the permission
        permission.ensureCanDeletePost(postBean.getForumID());

        ForumCache.getInstance().getBean(postBean.getForumID()).ensureNotDisabledForum();

        request.setAttribute("AttachmentBean", attachmentBean);
        request.setAttribute("PostBean", postBean);
    }

    void processDelete(HttpServletRequest request)
        throws BadInputException, DatabaseException, AuthenticationException, AssertionException, ObjectNotFoundException {

        OnlineUser onlineUser = userManager.getOnlineUser(request);
        MVNForumPermission permission = onlineUser.getPermission();

        // user must have been authenticated before he can delete
        permission.ensureIsAuthenticated();

        // primary key column(s)
        int attachID = ParamUtil.getParameterInt(request, "attach");

        AttachmentBean attachmentBean = DAOFactory.getAttachmentDAO().getBean(attachID);
        int postID = attachmentBean.getPostID();

        PostBean postBean = DAOFactory.getPostDAO().getPost(postID);

        ForumCache.getInstance().getBean(postBean.getForumID()).ensureNotDisabledForum();

        // now, check the permission
        permission.ensureCanDeletePost(postBean.getForumID());

        // now check the password
        MyUtil.ensureCorrectCurrentPassword(request);

        // delete in database
        DAOFactory.getAttachmentDAO().delete(attachID);

        // delete on disk
        AttachmentUtil.deleteAttachFilenameOnDisk(attachID);

        // we dont want the exception to throw below this
        int attachCount = DAOFactory.getAttachmentDAO().getNumberOfBeans_inPost(postID);
        DAOFactory.getPostDAO().updateAttachCount(postID, attachCount);

        int threadID = postBean.getThreadID();
        request.setAttribute("ThreadID", String.valueOf(threadID));
    }

    /*
     * @todo find a way to cache the file based on the http protocal
     * @todo check permission
     */
    void downloadAttachment(HttpServletRequest request, HttpServletResponse response)
        throws BadInputException, DatabaseException, ObjectNotFoundException, IOException,
        AuthenticationException, AssertionException  {

        OnlineUser onlineUser = userManager.getOnlineUser(request);
        MVNForumPermission permission = onlineUser.getPermission();

        int attachID  = ParamUtil.getParameterInt(request, "attach");
        AttachmentBean attachBean = DAOFactory.getAttachmentDAO().getBean(attachID);

        int postID = attachBean.getPostID();
        PostBean postBean = DAOFactory.getPostDAO().getPost(postID);
        int forumID = postBean.getForumID();
        ForumCache.getInstance().getBean(forumID).ensureNotDisabledForum();
        ForumCache.getInstance().getBean(forumID).ensureNotLockedForum();

        permission.ensureCanGetAttachment(forumID);

        InputStream inputStream = null;
        OutputStream outputStream = null;
        try {
            String attachFilename = AttachmentUtil.getAttachFilenameOnDisk(attachID);
            try {
                inputStream = new FileInputStream(attachFilename);
            } catch (IOException ex) {
                // we dont want to show the filename on file system in the original exception for security
                log.error("Cannot open attach file on file system with attach id = " + attachID, ex);
                throw new IOException("Cannot open attach file on file system with attach id = " + attachID + ". Please report this error to the Web site Administrator.");
            }
            byte[]buffer = FileUtil.getBytes(inputStream);
            inputStream.close();
            inputStream = null;// no close twice

            // we should not call this method after done the outputStream
            // because we dont want exception after download
            DAOFactory.getAttachmentDAO().increaseDownloadCount(attachID);

            outputStream = response.getOutputStream();
            response.setContentType(attachBean.getAttachMimeType());
            response.setHeader("Location", attachBean.getAttachFilename());

            // now use Cache-Control if the MIME type are image
            if (attachBean.getAttachMimeType().startsWith("image/")) {
                int cacheTime = DateUtil.DAY * 30 / 1000;// 30 days
                response.setHeader("Cache-Control", "max-age=" + cacheTime);
            }

            //added by Dejan
            response.setHeader("Content-Disposition", "attachment; filename=" + attachBean.getAttachFilename());

            outputStream.write(buffer);
            outputStream.flush();
            outputStream.close();
            outputStream = null;// no close twice
        } catch (IOException ex) {
            throw ex;
        } finally {
            if (inputStream != null) {
                try {
                    inputStream.close();
                } catch (IOException ex) { }
            }
            if (outputStream != null) {
                try {
                    outputStream.close();
                } catch (IOException ex) { }
            }
        }
    }

    /**
     * NOTE: This method should be called before any attemp to delete a post
     * because it require the post is exited
     * After calling this method, go ahead and delete the post
     */
    static void deleteAttachments_inPost(int postID) throws DatabaseException {

        // First, try to delete attachment in database
        Collection attachmentBeans = DAOFactory.getAttachmentDAO().getBeans_inPost(postID);
        DAOFactory.getAttachmentDAO().delete_inPost(postID);

        //now delete files on disk
        for (Iterator iter = attachmentBeans.iterator(); iter.hasNext(); ) {
            AttachmentBean attachmentBean = (AttachmentBean)iter.next();
            AttachmentUtil.deleteAttachFilenameOnDisk(attachmentBean.getAttachID());
        }
    }

    /**
     * NOTE: This method should be called before any attemp to delete a thread
     * because it require the thread is exited
     * After calling this method, go ahead and delete the thread
     */
    static void deleteAttachments_inThread(int threadID) throws DatabaseException {

        // First, try to delete attachment in database
        Collection attachmentBeans = DAOFactory.getAttachmentDAO().getBeans_inThread(threadID);

        //now delete files on disk
        for (Iterator iter = attachmentBeans.iterator(); iter.hasNext(); ) {
            AttachmentBean attachmentBean = (AttachmentBean)iter.next();
            int attachID = attachmentBean.getAttachID();
            AttachmentUtil.deleteAttachFilenameOnDisk(attachID);
            try {
                DAOFactory.getAttachmentDAO().delete(attachID);
            } catch (Exception ex) {
                log.warn("Cannot delete attachment (id = " + attachID + ") in database", ex);
            }
        }
    }

}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩不卡一区二区| 日韩欧美一级片| 狠狠色综合日日| 五月天激情综合| 亚洲综合免费观看高清完整版在线 | 亚洲黄色在线视频| 日韩毛片在线免费观看| 中文字幕色av一区二区三区| 国产精品国产三级国产普通话蜜臀| 国产欧美日韩在线观看| 国产精品成人网| 亚洲激情图片qvod| 亚洲午夜三级在线| 日本亚洲欧美天堂免费| 韩国成人在线视频| 99麻豆久久久国产精品免费| 色综合久久久久综合体桃花网| 欧美日韩不卡一区二区| 精品久久久久久最新网址| 国产日本欧洲亚洲| 亚洲专区一二三| 日本不卡的三区四区五区| 国产一区二区三区免费在线观看| 成人一区二区三区中文字幕| 色综合久久久久| 日韩视频免费观看高清完整版在线观看 | 夜夜嗨av一区二区三区中文字幕 | 正在播放亚洲一区| 久久久国产综合精品女国产盗摄| 国产精品久久三区| 手机精品视频在线观看| 懂色av中文一区二区三区| 欧美三级电影在线观看| 久久欧美一区二区| 亚洲在线一区二区三区| 美女被吸乳得到大胸91| 成人97人人超碰人人99| 7777女厕盗摄久久久| 亚洲欧美综合另类在线卡通| 午夜欧美视频在线观看| 粉嫩绯色av一区二区在线观看| 欧美色视频一区| 国产精品视频yy9299一区| 日本午夜精品视频在线观看 | 欧美日韩精品一区二区三区四区 | 亚洲国产精品一区二区久久 | 精品99999| 亚洲国产裸拍裸体视频在线观看乱了 | 国产精品不卡视频| 亚洲国产裸拍裸体视频在线观看乱了 | 奇米一区二区三区av| 91免费视频观看| 国产视频亚洲色图| 美女网站色91| 日韩一区二区三区av| 亚洲视频1区2区| 国产一区二区精品久久| 日韩欧美综合在线| 亚洲午夜精品网| 99久久久无码国产精品| 久久久精品国产99久久精品芒果| 午夜伦理一区二区| 欧美日韩五月天| 亚洲电影视频在线| 欧美色图天堂网| 夜夜嗨av一区二区三区四季av| 91亚洲资源网| 中文字幕欧美三区| 成人一区二区在线观看| 久久亚洲一级片| 国产美女娇喘av呻吟久久| 欧美电视剧在线看免费| 麻豆91精品视频| 日韩三级伦理片妻子的秘密按摩| 一区二区三区产品免费精品久久75| 成人av网站在线| 国产精品女人毛片| hitomi一区二区三区精品| 国产精品久久久久一区二区三区共| 久久电影网站中文字幕 | 日本亚洲欧美天堂免费| 在线综合视频播放| 久久精品国产99国产| 91精品国产一区二区| 久久99国产乱子伦精品免费| 538prom精品视频线放| 久久精品999| 久久综合九色综合97_久久久| 极品少妇xxxx偷拍精品少妇| 亚洲精品在线一区二区| 不卡电影免费在线播放一区| 亚洲婷婷国产精品电影人久久| 欧美最猛黑人xxxxx猛交| 午夜av一区二区| 精品欧美乱码久久久久久| 丰满少妇久久久久久久| 亚洲色大成网站www久久九九| 欧美丝袜丝交足nylons| 久久99精品国产.久久久久| 国产欧美中文在线| 在线观看亚洲a| 激情都市一区二区| 亚洲精品第1页| 精品福利av导航| 91麻豆国产福利在线观看| 亚洲成人精品一区| 久久精品人人爽人人爽| 欧美唯美清纯偷拍| 精品在线一区二区三区| 亚洲人精品午夜| 日韩欧美不卡在线观看视频| 国产成人精品免费在线| 亚洲福利国产精品| 亚洲精品一区二区三区蜜桃下载| 成人网男人的天堂| 欧美aⅴ一区二区三区视频| 国产精品国产三级国产aⅴ原创| 色天天综合久久久久综合片| 久久精品国产精品亚洲红杏| 国产日韩欧美电影| 欧美丰满少妇xxxxx高潮对白| 成人一区二区三区中文字幕| 亚洲aⅴ怡春院| 国产精品久线在线观看| 日韩限制级电影在线观看| 99久久综合99久久综合网站| 韩国女主播成人在线| 亚洲主播在线观看| 亚洲欧美色一区| 欧美成人vps| 欧美性一二三区| 91最新地址在线播放| 国产成人福利片| 精品一区二区国语对白| 天天操天天干天天综合网| 亚洲精品五月天| 1000部国产精品成人观看| 欧美激情综合网| 久久色成人在线| 欧美成人video| 日韩欧美高清dvd碟片| 91精品在线麻豆| 制服丝袜av成人在线看| 欧美日本不卡视频| 欧美日韩亚洲综合| 欧美性受xxxx| 欧美日韩一区二区三区高清 | 成人高清在线视频| 国产精品亚洲视频| 国产91精品入口| 成人妖精视频yjsp地址| 国产经典欧美精品| voyeur盗摄精品| www.欧美.com| 91成人在线观看喷潮| 在线观看视频一区二区| 欧美日韩不卡在线| 日韩欧美国产小视频| 日韩免费高清电影| 国产人妖乱国产精品人妖| 中文字幕在线视频一区| 亚洲视频一区二区在线观看| 亚洲男人的天堂av| 午夜精品在线看| 日韩成人午夜电影| 日韩高清国产一区在线| 麻豆精品久久精品色综合| 看电视剧不卡顿的网站| 国产成人自拍网| 一本一道久久a久久精品综合蜜臀| 91麻豆福利精品推荐| 欧美日韩一区成人| 日韩午夜激情视频| 久久久久久久久久久久久夜| 亚洲色图丝袜美腿| 亚洲免费观看高清完整版在线观看| 亚洲色大成网站www久久九九| 亚洲成人动漫在线观看| 国产一区二区按摩在线观看| 99国产精品一区| 日韩一区二区三区三四区视频在线观看 | 日本高清不卡一区| 欧美草草影院在线视频| 国产精品久久久久久久久搜平片 | 欧美激情一区二区三区蜜桃视频| 亚洲欧美一区二区视频| 视频一区在线视频| av不卡一区二区三区| 日韩一区二区在线播放| 国产精品久久久久久久久免费丝袜| 一卡二卡三卡日韩欧美| 韩国女主播一区二区三区| 色欧美片视频在线观看| 精品av久久707| 三级在线观看一区二区| 972aa.com艺术欧美| 精品日韩一区二区三区| 国产精品蜜臀av| 精品亚洲国产成人av制服丝袜| 91一区一区三区|