⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 threadwebhandler.java

📁 解觖java技术中后台无法上传数给的情况
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
        int totalPosts = forumBean.getForumPostCount();

        int pendingThreadCount = 0;
        int threadsWithPendingPostsCount = 0;
        if (permission.canModerateThread(forumID)) {
            pendingThreadCount = DAOFactory.getThreadDAO().getNumberOfDisableThreads_inForum(forumID);
            threadsWithPendingPostsCount = DAOFactory.getThreadDAO().getNumberOfEnableThreadsWithPendingPosts_inForum(forumID);
        }

        Collection allThreadBeans = new ArrayList();

        Collection globalAnnounces = ThreadCache.getInstance().getEnableGlobalAnnouncements();
        allThreadBeans.addAll(globalAnnounces);
        Collection announcements = ThreadCache.getInstance().getEnableForumAnnouncements_inForum(forumID);
        allThreadBeans.addAll(announcements);
        if (offset == 0) {
            Collection stickies = ThreadCache.getInstance().getEnableStickies_inForum(forumID);
            allThreadBeans.addAll(stickies);
        }
        allThreadBeans.addAll(threadBeans);

        request.setAttribute("ThreadBeans", allThreadBeans);
        request.setAttribute("TotalThreads", new Integer(totalThreads));
        request.setAttribute("TotalNormalThreads", new Integer(totalNormalThreads));
        request.setAttribute("TotalPosts", new Integer(totalPosts));
        request.setAttribute("PendingThreadCount", new Integer(pendingThreadCount));
        request.setAttribute("ThreadsWithPendingPostsCount", new Integer(threadsWithPendingPostsCount));
    }

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

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

        Locale locale = I18nUtil.getLocaleInRequest(request);

        // for sort and order stuff
        String sort  = GenericParamUtil.getParameter(request, "sort");
        String order = GenericParamUtil.getParameter(request, "order");
        if (sort.length() == 0) sort = "ThreadLastPostDate";
        if (order.length()== 0) order = "DESC";

        int postsPerPage = onlineUser.getPostsPerPage();
        int offset = 0;
        try {
            offset = GenericParamUtil.getParameterInt(request, "offset");
        } catch (BadInputException e) {
            // do nothing
        }

        int totalThreads = DAOFactory.getThreadDAO().getNumberOfEnableThreads();
        if (offset > totalThreads) {
            String localizedMessage = MVNForumResourceBundle.getString(locale, "mvncore.exception.BadInputException.offset_greater_than_total_rows");
            throw new BadInputException(localizedMessage);
            //throw new BadInputException("The offset is not allowed to be greater than total rows.");
        }

        Collection threadBeans = DAOFactory.getThreadDAO().getEnableThreads_withSortSupport_limit(offset, postsPerPage, sort, order);

        // now remove thread that current user does not have permission
        for (Iterator iterator = threadBeans.iterator(); iterator.hasNext(); ) {
            ThreadBean threadBean = (ThreadBean)iterator.next();
            int currentForumID = threadBean.getForumID();
            if (permission.canReadPost(currentForumID) == false) {
                iterator.remove();
            } else if (ForumCache.getInstance().getBean(currentForumID).getForumStatus() == ForumBean.FORUM_STATUS_DISABLED) {
                iterator.remove();
            }
        }

        request.setAttribute("ThreadBeans", threadBeans);
        request.setAttribute("TotalThreads", new Integer(totalThreads));
    }

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

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

        // user must have been authenticated before he can view pending/disabled threads
        permission.ensureIsAuthenticated();
        permission.ensureCanModerateThreadInAnyForum();

        Locale locale = I18nUtil.getLocaleInRequest(request);

        // for sort and order stuff
        String sort  = GenericParamUtil.getParameter(request, "sort");
        String order = GenericParamUtil.getParameter(request, "order");
        if (sort.length() == 0) sort = "ThreadLastPostDate";
        if (order.length()== 0) order = "DESC";

        int postsPerPage = onlineUser.getPostsPerPage();
        int offset = 0;
        try {
            offset = GenericParamUtil.getParameterInt(request, "offset");
        } catch (BadInputException e) {
            // do nothing
        }

        int totalThreads = DAOFactory.getThreadDAO().getNumberOfDisableThreads();
        if (offset > totalThreads) {
            String localizedMessage = MVNForumResourceBundle.getString(locale, "mvncore.exception.BadInputException.offset_greater_than_total_rows");
            throw new BadInputException(localizedMessage);
            //throw new BadInputException("The offset is not allowed to be greater than total rows.");
        }

        Collection threadBeans = DAOFactory.getThreadDAO().getDisableBeans_withSortSupport_limit(offset, postsPerPage, sort, order);

        // now remove thread that current user does not have permission
        for (Iterator iterator = threadBeans.iterator(); iterator.hasNext(); ) {
            ThreadBean threadBean = (ThreadBean)iterator.next();
            int currentForumID = threadBean.getForumID();
            if (permission.canModerateThread(currentForumID) == false) {
                iterator.remove();
            } else if (ForumCache.getInstance().getBean(currentForumID).getForumStatus() == ForumBean.FORUM_STATUS_DISABLED) {
                iterator.remove();
            }
        }

        request.setAttribute("ThreadBeans", threadBeans);
        request.setAttribute("TotalThreads", new Integer(totalThreads));
    }

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

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

        // user must have been authenticated before he can view pending/disabled threads
        permission.ensureIsAuthenticated();
        permission.ensureCanModerateThreadInAnyForum();

        Collection pendingThreadBeans = DAOFactory.getThreadDAO().getDisableBeans_withSortSupport_limit(0, 10000, "ThreadLastPostDate", "DESC");
        // now remove thread that current user does not have permission
        for (Iterator iterator = pendingThreadBeans.iterator(); iterator.hasNext(); ) {
            ThreadBean threadBean = (ThreadBean)iterator.next();
            if (permission.canModerateThread(threadBean.getForumID()) == false) {
                iterator.remove();
            }
        }

        Collection threadWithPendingPostsBeans = DAOFactory.getThreadDAO().getEnableThreadsWithPendingPosts_withSortSupport_limit(0, 10000, "ForumID", "DESC");
        for (Iterator iterator = threadWithPendingPostsBeans.iterator(); iterator.hasNext(); ) {
            ThreadBean threadBean = (ThreadBean)iterator.next();
            if (permission.canModerateThread(threadBean.getForumID()) == false) {
                iterator.remove();
            } else {
                Collection pendingPosts = DAOFactory.getPostDAO().getDisablePosts_inThread_limit(threadBean.getThreadID(), 0, 10000);
                threadBean.setPendingPosts(pendingPosts);
            }
        }

        request.setAttribute("PendingThreadBeans", pendingThreadBeans);
        request.setAttribute("ThreadWithPendingPostsBeans", threadWithPendingPostsBeans);
    }

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

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

        // user must have been authenticated before he can view enable threads with pending posts
        permission.ensureIsAuthenticated();
        permission.ensureCanModerateThreadInAnyForum();

        Locale locale = I18nUtil.getLocaleInRequest(request);

        // for sort and order stuff
        String sort  = GenericParamUtil.getParameter(request, "sort");
        String order = GenericParamUtil.getParameter(request, "order");
        if (sort.length() == 0) sort = "ThreadLastPostDate";
        if (order.length()== 0) order = "DESC";

        int postsPerPage = onlineUser.getPostsPerPage();
        int offset = 0;
        try {
            offset = GenericParamUtil.getParameterInt(request, "offset");
        } catch (BadInputException e) {
            // do nothing
        }

        int totalThreads = DAOFactory.getThreadDAO().getNumberOfEnableThreadsWithPendingPosts();
        if (offset > totalThreads) {
            String localizedMessage = MVNForumResourceBundle.getString(locale, "mvncore.exception.BadInputException.offset_greater_than_total_rows");
            throw new BadInputException(localizedMessage);
            //throw new BadInputException("The offset is not allowed to be greater than total rows.");
        }

        Collection threadBeans = DAOFactory.getThreadDAO().getEnableThreadsWithPendingPosts_withSortSupport_limit(offset, postsPerPage, sort, order);

        // now remove thread that current user does not have permission
        for (Iterator iterator = threadBeans.iterator(); iterator.hasNext(); ) {
            ThreadBean threadBean = (ThreadBean)iterator.next();
            int currentForumID = threadBean.getForumID();
            if (permission.canModerateThread(currentForumID) == false) {
                iterator.remove();
            } else if (ForumCache.getInstance().getBean(currentForumID).getForumStatus() == ForumBean.FORUM_STATUS_DISABLED) {
                iterator.remove();
            }
        }

        request.setAttribute("ThreadBeans", threadBeans);
        request.setAttribute("TotalThreads", new Integer(totalThreads));
    }

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

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

        // user must have been authenticated before he can view enable threads with pending posts
        permission.ensureIsAuthenticated();

        int forumID = GenericParamUtil.getParameterInt(request, "forum");
        permission.ensureCanModerateThread(forumID);

        ForumCache.getInstance().getBean(forumID).ensureNotDisabledForum();

        Locale locale = I18nUtil.getLocaleInRequest(request);

        // for sort and order stuff
        String sort  = GenericParamUtil.getParameter(request, "sort");
        String order = GenericParamUtil.getParameter(request, "order");
        if (sort.length() == 0) sort = "ThreadLastPostDate";
        if (order.length()== 0) order = "DESC";

        int postsPerPage = onlineUser.getPostsPerPage();
        int offset = 0;
        try {
            offset = GenericParamUtil.getParameterInt(request, "offset");
        } catch (BadInputException e) {
            // do nothing
        }

        int totalThreads = DAOFactory.getThreadDAO().getNumberOfEnableThreadsWithPendingPosts_inForum(forumID);
        if (offset > totalThreads) {
            String localizedMessage = MVNForumResourceBundle.getString(locale, "mvncore.exception.BadInputException.offset_greater_than_total_rows");
            throw new BadInputException(localizedMessage);
            //throw new BadInputException("The offset is not allowed to be greater than total rows.");
        }

        Collection threadBeans = DAOFactory.getThreadDAO().getEnableThreadsWithPendingPosts_inForum_withSortSupport_limit(forumID, offset, postsPerPage, sort, order);

        request.setAttribute("ThreadBeans", threadBeans);
        request.setAttribute("TotalThreads", new Integer(totalThreads));
    }

    public void prepareModerationControlPanel(GenericRequest request)
        throws DatabaseException, DatabaseException, AssertionException, DatabaseException, AuthenticationException {

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

        // user must have been authenticated before he can view enable threads with pending posts
        permission.ensureIsAuthenticated();
        permission.ensureCanModerateThreadInAnyForum();

        Collection forumBeans = ForumCache.getInstance().getBeans();
        for (Iterator iter = forumBeans.iterator(); iter.hasNext(); ) {
            ForumBean forumBean = (ForumBean)iter.next();
            int forumID = forumBean.getForumID();

            int pendingThreadCount = 0;
            int threadsWithPendingPostsCount = 0;
            int pendingPostCount = 0;

            if (permission.canModerateThread(forumID) && (forumBean.getForumStatus() != ForumBean.FORUM_STATUS_DISABLED) ) {
                pendingThreadCount = DAOFactory.getThreadDAO().getNumberOfDisableThreads_inForum(forumID);
                threadsWithPendingPostsCount = DAOFactory.getThreadDAO().getNumberOfEnableThreadsWithPendingPosts_inForum(forumID);
                pendingPostCount = DAOFactory.getPostDAO().getNumberOfDisablePosts_inForum(forumID);
            }

            // note that if user does not have permission on this forum, then the value is 0
            forumBean.setPendingThreadCount(pendingThreadCount);
            forumBean.setThreadsWithPendingPostsCount(threadsWithPendingPostsCount);
            forumBean.setPendingPostCount(pendingPostCount);
        }

        int pendingThreadCount = DAOFactory.getThreadDAO().getNumberOfDisableThreads();
        int threadsWithPendingPostsCount = DAOFactory.getThreadDAO().getNumberOfEnableThreadsWithPendingPosts();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -