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

📄 importmvnforum.java

📁 解觖java技术中后台无法上传数给的情况
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
        digester.addCallMethod("*/Category/CategoryDesc", "setCategoryDesc", 0);
        digester.addCallMethod("*/Category/CategoryCreationDate", "setCategoryCreationDate", 0);
        digester.addCallMethod("*/Category/CategoryModifiedDate", "setCategoryModifiedDate", 0);
        digester.addCallMethod("*/Category/CategoryOrder", "setCategoryOrder", 0);
        digester.addCallMethod("*/Category/CategoryOption", "setCategoryOption", 0);
        digester.addCallMethod("*/Category/CategoryStatus", "setCategoryStatus", 0);

        digester.addCallMethod("*/Category/CategoryWatchList/CategoryWatch", "addCategoryWatch", 7);
        digester.addCallParam("*/Category/CategoryWatchList/CategoryWatch/MemberName", 0);
        digester.addCallParam("*/Category/CategoryWatchList/CategoryWatch/WatchType", 1);
        digester.addCallParam("*/Category/CategoryWatchList/CategoryWatch/WatchOption", 2);
        digester.addCallParam("*/Category/CategoryWatchList/CategoryWatch/WatchStatus", 3);
        digester.addCallParam("*/Category/CategoryWatchList/CategoryWatch/WatchCreationDate", 4);
        digester.addCallParam("*/Category/CategoryWatchList/CategoryWatch/WatchLastSentDate", 5);
        digester.addCallParam("*/Category/CategoryWatchList/CategoryWatch/WatchEndDate", 6);


        digester.addObjectCreate("*/Forum", MvnForumForumXML.class);
        digester.addCallMethod("*/Forum", "addForum");
        //digester.addSetTop("*/Forum", "setParentCategory");
        SetParentRule forumParentRule = new SetParentRule("setParentCategory");
        digester.addRule("*/Forum", forumParentRule);
        digester.addCallMethod("*/Forum/LastPostMemberName", "setForumLastPostMemberName", 0);
        digester.addCallMethod("*/Forum/ForumName", "setForumName", 0);
        digester.addCallMethod("*/Forum/ForumDesc", "setForumDesc", 0);
        digester.addCallMethod("*/Forum/ForumCreationDate", "setForumCreationDate", 0);
        digester.addCallMethod("*/Forum/ForumModifiedDate", "setForumModifiedDate", 0);
        digester.addCallMethod("*/Forum/ForumLastPostDate", "setForumLastPostDate", 0);
        digester.addCallMethod("*/Forum/ForumOrder", "setForumOrder", 0);
        digester.addCallMethod("*/Forum/ForumType", "setForumType", 0);
        digester.addCallMethod("*/Forum/ForumFormatOption", "setForumFormatOption", 0);
        digester.addCallMethod("*/Forum/ForumOption", "setForumOption", 0);
        digester.addCallMethod("*/Forum/ForumStatus", "setForumStatus", 0);
        digester.addCallMethod("*/Forum/ForumModerationMode", "setForumModerationMode", 0);
        digester.addCallMethod("*/Forum/ForumPassword", "setForumPassword", 0);
        digester.addCallMethod("*/Forum/ForumThreadCount", "setForumThreadCount", 0);
        digester.addCallMethod("*/Forum/ForumPostCount", "setForumPostCount", 0);

        digester.addCallMethod("*/Forum/MemberForumPermissionList/MemberForumPermission", "addMemberForumPermission", 2);
        digester.addCallParam("*/Forum/MemberForumPermissionList/MemberForumPermission/MemberName", 0);
        digester.addCallParam("*/Forum/MemberForumPermissionList/MemberForumPermission/ForumPermission", 1);

        digester.addCallMethod("*/Forum/GroupForumPermissionList/GroupForumPermission", "addGroupForumPermission", 2);
        digester.addCallParam("*/Forum/GroupForumPermissionList/GroupForumPermission/GroupName", 0);
        digester.addCallParam("*/Forum/GroupForumPermissionList/GroupForumPermission/ForumPermission", 1);

        //digester.addCallMethod("*/Forum/GuestForumPermissionList/ForumPermission", "addGuestForumPermission", 0);
        //digester.addCallMethod("*/Forum/RegisteredMembersForumPermissionList/ForumPermission", "addRegisteredMembersForumPermission", 0);

        digester.addCallMethod("*/Forum/ForumWatchList/ForumWatch", "addForumWatch", 7);
        digester.addCallParam("*/Forum/ForumWatchList/ForumWatch/MemberName", 0);
        digester.addCallParam("*/Forum/ForumWatchList/ForumWatch/WatchType", 1);
        digester.addCallParam("*/Forum/ForumWatchList/ForumWatch/WatchOption", 2);
        digester.addCallParam("*/Forum/ForumWatchList/ForumWatch/WatchStatus", 3);
        digester.addCallParam("*/Forum/ForumWatchList/ForumWatch/WatchCreationDate", 4);
        digester.addCallParam("*/Forum/ForumWatchList/ForumWatch/WatchLastSentDate", 5);
        digester.addCallParam("*/Forum/ForumWatchList/ForumWatch/WatchEndDate", 6);


        digester.addObjectCreate("*/Thread", MvnForumThreadXML.class);
        //digester.addSetTop("*/Thread", "setParentForum");
        SetParentRule threadParentRule = new SetParentRule("setParentForum");
        digester.addRule("*/Thread", threadParentRule);
        digester.addCallMethod("*/Thread", "addThread");
        digester.addCallMethod("*/Thread/MemberName", "setThreadMemberName", 0);
        digester.addCallMethod("*/Thread/LastPostMemberName", "setThreadLastPostMemberName", 0);
        digester.addCallMethod("*/Thread/ThreadTopic", "setThreadTopic", 0);
        digester.addCallMethod("*/Thread/ThreadBody", "setThreadBody", 0);
        digester.addCallMethod("*/Thread/ThreadVoteCount", "setThreadVoteCount", 0);
        digester.addCallMethod("*/Thread/ThreadVoteTotalStars", "setThreadVoteTotalStars", 0);
        digester.addCallMethod("*/Thread/ThreadCreationDate", "setThreadCreationDate", 0);
        digester.addCallMethod("*/Thread/ThreadLastPostDate", "setThreadLastPostDate", 0);
        digester.addCallMethod("*/Thread/ThreadType", "setThreadType", 0);
        digester.addCallMethod("*/Thread/ThreadOption", "setThreadOption", 0);
        digester.addCallMethod("*/Thread/ThreadStatus", "setThreadStatus", 0);
        digester.addCallMethod("*/Thread/ThreadHasPoll", "setThreadHasPoll", 0);
        digester.addCallMethod("*/Thread/ThreadViewCount", "setThreadViewCount", 0);
        digester.addCallMethod("*/Thread/ThreadReplyCount", "setThreadReplyCount", 0);
        digester.addCallMethod("*/Thread/ThreadIcon", "setThreadIcon", 0);
        digester.addCallMethod("*/Thread/ThreadDuration", "setThreadDuration", 0);

        digester.addCallMethod("*/Thread/ThreadWatchList/ThreadWatch", "addThreadWatch", 7);
        digester.addCallParam("*/Thread/ThreadWatchList/ThreadWatch/MemberName", 0);
        digester.addCallParam("*/Thread/ThreadWatchList/ThreadWatch/WatchType", 1);
        digester.addCallParam("*/Thread/ThreadWatchList/ThreadWatch/WatchOption", 2);
        digester.addCallParam("*/Thread/ThreadWatchList/ThreadWatch/WatchStatus", 3);
        digester.addCallParam("*/Thread/ThreadWatchList/ThreadWatch/WatchCreationDate", 4);
        digester.addCallParam("*/Thread/ThreadWatchList/ThreadWatch/WatchLastSentDate", 5);
        digester.addCallParam("*/Thread/ThreadWatchList/ThreadWatch/WatchEndDate", 6);

        digester.addCallMethod("*/Thread/FavoriteThreadList/FavoriteThread", "addFavoriteThread", 5);
        digester.addCallParam("*/Thread/FavoriteThreadList/FavoriteThread/MemberName", 0);
        digester.addCallParam("*/Thread/FavoriteThreadList/FavoriteThread/FavoriteCreationDate", 1);
        digester.addCallParam("*/Thread/FavoriteThreadList/FavoriteThread/FavoriteType", 2);
        digester.addCallParam("*/Thread/FavoriteThreadList/FavoriteThread/FavoriteOption", 3);
        digester.addCallParam("*/Thread/FavoriteThreadList/FavoriteThread/FavoriteStatus", 4);


        digester.addObjectCreate("*/Post", MvnForumPostXML.class);
        //digester.addSetTop("*/Post", "setParentThreadOrPost");
        SetParentRule postParentRule = new SetParentRule("setParentThreadOrPost");
        digester.addRule("*/Post", postParentRule);
        digester.addCallMethod("*/Post", "addPost");
        digester.addCallMethod("*/Post/MemberName", "setPostMemberName", 0);
        digester.addCallMethod("*/Post/LastEditMemberName", "setPostLastEditMemberName", 0);
        digester.addCallMethod("*/Post/PostTopic", "setPostTopic", 0);
        digester.addCallMethod("*/Post/PostBody", "setPostBody", 0);
        digester.addCallMethod("*/Post/PostCreationDate", "setPostCreationDate", 0);
        digester.addCallMethod("*/Post/PostLastEditDate", "setPostLastEditDate", 0);
        digester.addCallMethod("*/Post/PostCreationIP", "setPostCreationIP", 0);
        digester.addCallMethod("*/Post/PostLastEditIP", "setPostLastEditIP", 0);
        digester.addCallMethod("*/Post/PostEditCount", "setPostEditCount", 0);
        digester.addCallMethod("*/Post/PostFormatOption", "setPostFormatOption", 0);
        digester.addCallMethod("*/Post/PostOption", "setPostOption", 0);
        digester.addCallMethod("*/Post/PostStatus", "setPostStatus", 0);
        digester.addCallMethod("*/Post/PostIcon", "setPostIcon", 0);
        digester.addCallMethod("*/Post/PostAttachCount", "setPostAttachCount", 0);


        digester.addObjectCreate("*/Attachment", MvnForumAttachmentXML.class);
        digester.addSetProperties("*/Attachment", "id", "attachmentId");
        //digester.addSetTop("*/Attachment", "setParentPost");
        SetParentRule attachmentParentRule = new SetParentRule("setParentPost");
        digester.addRule("*/Attachment", attachmentParentRule);
        digester.addCallMethod("*/Attachment", "addAttachment");
        digester.addCallMethod("*/Attachment/MemberName", "setAttachMemberName", 0);
        digester.addCallMethod("*/Attachment/AttachFilename", "setAttachFilename", 0);
        digester.addCallMethod("*/Attachment/AttachFileSize", "setAttachFileSize", 0);
        digester.addCallMethod("*/Attachment/AttachMimeType", "setAttachMimeType", 0);
        digester.addCallMethod("*/Attachment/AttachDesc", "setAttachDesc", 0);
        digester.addCallMethod("*/Attachment/AttachCreationIP", "setAttachCreationIP", 0);
        digester.addCallMethod("*/Attachment/AttachCreationDate", "setAttachCreationDate", 0);
        digester.addCallMethod("*/Attachment/AttachModifiedDate", "setAttachModifiedDate", 0);
        digester.addCallMethod("*/Attachment/AttachDownloadCount", "setAttachDownloadCount", 0);
        digester.addCallMethod("*/Attachment/AttachOption", "setAttachOption", 0);
        digester.addCallMethod("*/Attachment/AttachStatus", "setAttachStatus", 0);


        /* At this point, on top of stack we have only the root MvnForumXML object */


        digester.addCallMethod("mvnforum/RankList/Rank", "addRank", 6);
        digester.addCallParam("mvnforum/RankList/Rank/RankMinPosts", 0);
        digester.addCallParam("mvnforum/RankList/Rank/RankLevel", 1);
        digester.addCallParam("mvnforum/RankList/Rank/RankTitle", 2);
        digester.addCallParam("mvnforum/RankList/Rank/RankImage", 3);
        digester.addCallParam("mvnforum/RankList/Rank/RankType", 4);
        digester.addCallParam("mvnforum/RankList/Rank/RankOption", 5);


        /* ==================================================================
         * This was the main part of file - XML processing rules for Digester
         * ==================================================================
         */

        digester.parse(inputFile);

        try {
            MvnForumXML.finishImport();
        } catch (CreateException e) {
            throw new ImportException(e.getMessage(), e); //just rethrow
        } catch (DuplicateKeyException e) {
            throw new ImportException(e.getMessage(), e); //just rethrow
        } catch (ObjectNotFoundException e) {
            throw new ImportException(e.getMessage(), e); //just rethrow
        } catch (DatabaseException e) {
            throw new ImportException(e.getMessage(), e); //just rethrow
        } catch (ForeignKeyNotFoundException e) {
            throw new ImportException(e.getMessage(), e); //just rethrow
        } catch (BadInputException e) {
            throw new ImportException(e.getMessage(), e); //just rethrow
        }
    }

    /**
     * Adds <code>message</code> to the output stream that was setup in
     * {@link #importXml(File, HttpServletRequest, HttpServletResponse, int, String, Calendar, String, boolean, int)}.
     * <br/>This method was made public to be available to MVN Forum XML processing classes.
     *
     * @param message Message to be written to output.
     * @see com.mvnforum.admin.ImportWebHelper#addMessage(java.lang.String)
     *
     */
    public static void addMessage(String message) {
        ImportWebHelper.addMessage(message);
    }

    /**
     * Adds important (bold) <code>message</code> to the output stream that was setup in
     * {@link #importXml(File, HttpServletRequest, HttpServletResponse, int, String, Calendar, String, boolean, int)}.
     * <br/>This method was made public to be available to MVN Forum XML processing classes.
     *
     * @param message Message to be written to output.
     * @see com.mvnforum.admin.ImportWebHelper#addImportantMessage(java.lang.String)
     *
     */
    public static void addImportantMessage(String message) {
        ImportWebHelper.addImportantMessage(message);
    }

    /**
     * Ensure that default entries in MVN Forum (admin and virtual guest members, rank titles,
     * <code>Registered Members</code> group, ...) are created.<br/>
     * This method was made public to be available to MVN Forum XML processing classes.<br/>
     * Since these defaults will be imported from XML (they are supposed to be
     * in the XML), this method won't do anything. At the end of import, defaults
     * will be checked and created in case XML didn't contain them.
     *
     * @see com.mvnforum.admin.ImportWebHelper#addMessage(java.lang.String)
     *
     */
    public static void createDefaultContents()
        throws CreateException, DuplicateKeyException, ObjectNotFoundException,
        DatabaseException, ForeignKeyNotFoundException {
        //don't create any database entries now
        /* This method overrides ImportWebHelper.createDefaultContents().
         * It's used in MVNForumXML constructor.
         * But, in case of error, ImportWebHandler.finalErrorHandling will be
         * called, and it uses ImportWebHelper.createDefaultContents() version
         * of this method (so, in that case, all neccessary default contents
         * will be created).
         */
    }

    private static void handleSuccess(HttpServletRequest request) {
        addSuccessMessage();
        endHtml();
    }

    //it's possible I called this method with e==null
    private static void handleFatalError(String message, Exception e,
             boolean clearIfError, HttpServletRequest request)
        throws ImportException {

        if (e==null) log.error(message);
        else log.error(message, e);
        if ((e==null) || (e.getMessage()==null)) addErrorMessage(message);
        else addErrorMessage(message+"<br/>Cause: "+e.getMessage());
        //try to clear the database and rollback to valid empty state with "admin" member
        ImportWebHelper.addFinalErrorHandling(request, clearIfError);
        endHtml();
        if (e==null) throw new ImportException(message);
        else throw new ImportException(message, e);
    }
}

⌨️ 快捷键说明

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