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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? attachmentwebhandler.java

?? 解觖java技術中后臺無法上傳數給的情況
?? JAVA
?? 第 1 頁 / 共 3 頁
字號:
    }

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

        OnlineUser onlineUser = userManager.getOnlineUser(request);
        MVNForumPermission permission = onlineUser.getPermission();
        Locale locale = I18nUtil.getLocaleInRequest(request);
        // user must have been authenticated before he can delete
        permission.ensureIsAuthenticated();

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

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

        PostBean postBean = null;
        try {
            postBean = DAOFactory.getPostDAO().getPost(postID);// can throw DatabaseException
        } catch (ObjectNotFoundException ex) {
            String localizedMessage = MVNForumResourceBundle.getString(locale, "mvncore.exception.ObjectNotFoundException.postid_not_exists", new Object[] {new Integer(postID)});
            throw new ObjectNotFoundException(localizedMessage);
        }

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

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

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

        // delete on disk
        //AttachmentUtil.deleteAttachFilenameOnDisk(attachID);
        BinaryStorage binaryStorage = ManagerFactory.getBinaryStorage();
        try {
            binaryStorage.deleteData(BinaryStorage.CATEGORY_POST_ATTACHMENT, String.valueOf(attachID), null);
        } catch (IOException ex) {
            log.error("Cannot delete file", ex);
            // actually this exception is never existed
        }
        
        // delete in database
        DAOFactory.getAttachmentDAO().delete(attachID);

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

        // Now update the post because the attachment count in this post is changed
        postBean.setPostAttachCount(attachCount);
        PostIndexer.scheduleUpdatePostTask(postBean);

        int threadID = postBean.getThreadID();
        int attachCountInThread = DAOFactory.getAttachmentDAO().getNumberOfAttachments_inThread(threadID);
        DAOFactory.getThreadDAO().updateThreadAttachCount(threadID, attachCountInThread);

        // Now clear the cache
        PostCache.getInstance().clear();

        request.setAttribute("ThreadID", String.valueOf(threadID));
    }

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

        Locale locale = I18nUtil.getLocaleInRequest(request);
        OnlineUser onlineUser = userManager.getOnlineUser(request);
        MVNForumPermission permission = onlineUser.getPermission();

        int attachID = ParamUtil.getParameterInt(request, "attach");
        AttachmentBean attachBean = null;
        try {
            attachBean = DAOFactory.getAttachmentDAO().getAttachment(attachID);
        } catch (ObjectNotFoundException e) {
            String localizedMessage = MVNForumResourceBundle.getString(locale, "mvncore.exception.ObjectNotFoundException.attachmentid_not_exists", new Object[] {new Integer(attachID)});
            throw new ObjectNotFoundException(localizedMessage);
        }

        int postID = attachBean.getPostID();

        PostBean postBean = DAOFactory.getPostDAO().getPost(postID);
        int forumID = postBean.getForumID();
        ForumCache.getInstance().getBean(forumID).ensureNotDisabledForum();
        //ForumCache.getInstance().getBean(forumID).ensureNotLockedForum(); // lock forum should allow download

        if (MVNForumConfig.getEnableGuestViewImageAttachment() &&
            attachBean.getAttachMimeType().startsWith("image/")) {
            // When guest can view image attachment AND this attachment is image
            // This is for security, at least in this case user must have permission to view post
            permission.ensureCanReadPost(forumID);
        } else {
            // Please note that user does not have to have read permission
            permission.ensureCanGetAttachment(forumID);
        }

        BinaryStorage binaryStorage = ManagerFactory.getBinaryStorage();
        InputStream inputStream = binaryStorage.getInputStream(BinaryStorage.CATEGORY_POST_ATTACHMENT, String.valueOf(attachID), null);

        /*
        String attachFilename = AttachmentUtil.getAttachFilenameOnDisk(attachID);
        File attachFile = new File(attachFilename);
        if ((!attachFile.exists()) || (!attachFile.isFile())) {
            log.error("Can't find a file " + attachFile + " to be downloaded (or maybe it's directory).");
            String localizedMessage = MVNForumResourceBundle.getString(locale, "java.io.IOException.not_exist_or_not_file_to_be_downloaded");
            throw new IOException(localizedMessage + " (AttachID=" + attachID + ")");
            //throw new IOException("Can't find a file to be downloaded (or maybe it's directory).");
        }
        */

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

        OutputStream outputStream = null;
        try {
            response.setContentType(attachBean.getAttachMimeType());
            response.setHeader("Location", attachBean.getAttachFilename());

            // now use Cache-Control if the MIME type are image
            if (attachBean.getAttachMimeType().startsWith("image/")) {
                long 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());

            // now, the header inited, just write the file content on the output
            outputStream = response.getOutputStream();
            //write using popFile when the file size's so large
            try {
                //FileUtil.popFile(attachFile, outputStream);
                IOUtils.copy(inputStream, outputStream);
            } catch (IOException ex) {
                // CANNOT throw Exception after we output to the response
                log.error("Error while trying to send attachment file from server: attachID = " + attachID + ".", ex);
            }
            //log.debug("Downloading attachment using FileUtil.popFile method");

            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 {

        BinaryStorage binaryStorage = ManagerFactory.getBinaryStorage();

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

        //now delete files on disk
        for (Iterator iter = attachmentBeans.iterator(); iter.hasNext(); ) {
            AttachmentBean attachmentBean = (AttachmentBean)iter.next();
            int attachID = attachmentBean.getAttachID();
            //AttachmentUtil.deleteAttachFilenameOnDisk(attachmentBean.getAttachID());
            try {
                binaryStorage.deleteData(BinaryStorage.CATEGORY_POST_ATTACHMENT, String.valueOf(attachID), null);
            } catch (IOException ex) {
                log.error("Cannot delete file", ex);
                // actually this exception is never existed
            }
        }
    }

    /**
     * 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 {

        BinaryStorage binaryStorage = ManagerFactory.getBinaryStorage();

        // First, try to delete attachment in database
        Collection attachmentBeans = DAOFactory.getAttachmentDAO().getAttachments_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 {
                binaryStorage.deleteData(BinaryStorage.CATEGORY_POST_ATTACHMENT, String.valueOf(attachID), null);
            } catch (IOException ex) {
                log.error("Cannot delete file", ex);
                // actually this exception is never existed
            }
            try {
                DAOFactory.getAttachmentDAO().delete(attachID);
            } catch (Exception ex) {
                log.warn("Cannot delete attachment (id = " + attachID + ") in database", ex);
            }
        }
    }

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
一区二区三区免费看视频| 91精品国产美女浴室洗澡无遮挡| 久久蜜桃香蕉精品一区二区三区| 麻豆国产91在线播放| 欧美一区二区三区日韩视频| 久久国产日韩欧美精品| 久久综合五月天婷婷伊人| 国产一区二区福利| 国产精品九色蝌蚪自拍| 色av一区二区| 日av在线不卡| 中文字幕在线一区免费| 欧美综合天天夜夜久久| 日本不卡视频在线| www国产成人| 色婷婷精品大在线视频| 蜜臀久久久99精品久久久久久| 久久久噜噜噜久久人人看 | 久久综合久久综合亚洲| 粉嫩高潮美女一区二区三区| 亚洲欧美一区二区久久| 欧美疯狂做受xxxx富婆| 国产一区二区三区在线观看精品 | 7878成人国产在线观看| 极品瑜伽女神91| 亚洲欧美日韩小说| 欧美一区二区在线视频| 国产aⅴ精品一区二区三区色成熟| 亚洲精品国产高清久久伦理二区| 91精品国产综合久久精品性色| 国产伦精品一区二区三区免费迷| 亚洲人成网站影音先锋播放| 欧美一区二区在线免费观看| eeuss鲁片一区二区三区在线观看| 视频一区二区三区在线| 国产精品欧美久久久久无广告| 欧美丝袜丝交足nylons图片| 国产一区二区福利视频| 丝袜美腿一区二区三区| 亚洲同性同志一二三专区| 日韩欧美的一区二区| 色综合激情五月| 国产精品一级黄| 日本不卡123| 一区二区三区精品久久久| 久久精品夜色噜噜亚洲aⅴ| 欧洲国产伦久久久久久久| 国产白丝精品91爽爽久久| 日本91福利区| 天天爽夜夜爽夜夜爽精品视频| 国产日本亚洲高清| 精品日本一线二线三线不卡| 欧美日韩国产一二三| 成人av免费在线观看| 国产一区二区免费看| 免费观看久久久4p| 丝袜a∨在线一区二区三区不卡| 中文字幕在线不卡| 中文在线一区二区 | 成人激情黄色小说| 久久国产尿小便嘘嘘尿| 日产欧产美韩系列久久99| 亚洲综合在线观看视频| 国产精品福利一区二区三区| 亚洲国产精品二十页| 久久亚洲捆绑美女| 26uuu精品一区二区三区四区在线| 欧美二区三区91| 欧美亚洲综合色| 欧美中文字幕一区二区三区亚洲| 成人毛片视频在线观看| 国产成人小视频| 成人网男人的天堂| 粉嫩13p一区二区三区| 国产成人精品一区二区三区四区 | 国产精品一级二级三级| 精品夜夜嗨av一区二区三区| 麻豆成人在线观看| 理论电影国产精品| 国模娜娜一区二区三区| 国内精品免费**视频| 国产精品一区二区你懂的| 国产福利不卡视频| 成人开心网精品视频| av男人天堂一区| 97se亚洲国产综合自在线不卡| 91麻豆精东视频| 91黄色免费看| 欧美男生操女生| 欧美电影免费观看高清完整版| 亚洲精品一线二线三线| 久久这里只精品最新地址| 欧美成人乱码一区二区三区| 久久久久97国产精华液好用吗| 久久久久久久久久久久久久久99| 中文字幕av资源一区| 亚洲激情在线播放| 午夜久久久影院| 久久国产精品色婷婷| 国产精品资源站在线| 成人av网站在线| 欧美日本国产一区| 精品久久久久一区二区国产| 国产拍欧美日韩视频二区| 1024亚洲合集| 青草av.久久免费一区| 国产成人av电影| 色综合天天综合网天天看片| 欧美日韩一区 二区 三区 久久精品| 91精品一区二区三区久久久久久 | 精品一区二区三区视频 | www.欧美日韩| 欧美日韩一二三| 久久亚洲精华国产精华液 | 99视频在线精品| 欧美日韩一区二区三区高清| 精品国产欧美一区二区| 国产精品久久久久久久久久免费看| 一区二区三区免费观看| 韩国成人福利片在线播放| 一本一本大道香蕉久在线精品| 日韩一区二区影院| 一区视频在线播放| 精品影视av免费| 91久久免费观看| 国产性色一区二区| 五月天网站亚洲| 99riav久久精品riav| 精品国产一区二区三区不卡 | 国产精品一区免费视频| 欧美三级午夜理伦三级中视频| 久久久777精品电影网影网| 亚洲小少妇裸体bbw| 成人永久看片免费视频天堂| 欧美一区二区视频在线观看 | 欧美另类一区二区三区| 国产精品美女久久久久久2018| 日韩二区三区四区| 欧洲人成人精品| 日韩一区日韩二区| 国产在线不卡视频| 91精品国产综合久久香蕉的特点 | 亚洲欧美日韩国产另类专区| 久久99久久精品| 在线91免费看| 亚洲最快最全在线视频| 白白色亚洲国产精品| 精品福利在线导航| 日韩专区欧美专区| 欧美视频在线不卡| 亚洲摸摸操操av| 91在线精品一区二区| 国产欧美日韩三级| 国产伦精品一区二区三区视频青涩| 欧美一区二区三区四区五区| 一区二区三区四区蜜桃| 91在线免费播放| 国产精品免费久久久久| 国产91精品久久久久久久网曝门| 精品国内片67194| 久久99久久99精品免视看婷婷| 6080日韩午夜伦伦午夜伦| 亚洲福利视频一区| 欧美性xxxxxxxx| 亚洲一本大道在线| 欧美性受极品xxxx喷水| 亚洲自拍与偷拍| 欧美日韩国产影片| 蜜桃精品视频在线| 精品伦理精品一区| 国产专区欧美精品| 欧美高清在线一区二区| 成人黄色在线网站| 日韩一区在线免费观看| 91天堂素人约啪| 亚洲蜜臀av乱码久久精品蜜桃| 91丝袜美女网| 亚洲电影一区二区三区| 欧美蜜桃一区二区三区| 日韩av中文字幕一区二区| 日韩视频国产视频| 国模大尺度一区二区三区| 国产欧美一区二区精品性| www.亚洲国产| 亚洲一区二区视频在线观看| 欧美日韩免费一区二区三区 | 风间由美性色一区二区三区| 国产女主播视频一区二区| av一区二区久久| 亚洲与欧洲av电影| 欧美一级高清片| 国产一区二区不卡老阿姨| 国产精品精品国产色婷婷| 欧美性xxxxxx少妇| 精品在线免费观看| 国产精品国产精品国产专区不片 | 99久久精品国产毛片| 亚洲综合一区二区| 日韩视频在线一区二区| 成人蜜臀av电影|