欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

jive回复主题,post a reply threadJSPCacheF# 

程序员文章站 2022-07-06 19:57:57
...
post.jsp line 80
i
f (reply); {
     	thread = forum.getThread(threadID);;
        // a message ID might not be passed in. If this is the case, we're
        // replying to the root message so get the message ID from the root
        // message of the thread
        if (messageID == -1L); {
            parentMessage = thread.getRootMessage();;
            messageID = parentMessage.getID();;
        } else {
            parentMessage = thread.getMessage(messageID);;
        }
	}

得到parentMessage 以后,就可以在parentMessage 后添加节点了(reply)
// if this is a reply, add it to the thread
			if (reply); {
				thread.addMessage(parentMessage,newMessage);;
			} 

thread.addMessage()
public void addMessage(ForumMessage parentMessage, ForumMessage newMessage);
            throws UnauthorizedException
    {
        // Get the underlying DbForumMessage object.
        DbForumMessage dbMessage = null;
        if (newMessage instanceof ForumMessageProxy); {
            ForumMessageProxy proxyMessage = (ForumMessageProxy);newMessage;
            dbMessage = (DbForumMessage);proxyMessage.getProxiedForumMessage();;
        }
        else {
            dbMessage = (DbForumMessage);newMessage;
        }
        DbForum dbForum = null;

        boolean abortTransaction = false;
        Connection con = null;
        try {
            con = ConnectionManager.getTransactionConnection();;
[b] 
            // Insert the message into the database.
           dbMessage.insertIntoDb(this, parentMessage.getID();, con);;
}[/b]
            // Check the moderation value of the message. If the value is above
            // the visible threshold for the forum, then update the modified
            // date of the thread and forum. Otherwise, we'll wait to update
            // the modified dates to when the message is moderated to be visible.
            dbForum = factory.cacheManager.forumCache.get(forumID);;
            if (newMessage.getModerationValue(); >=
                    dbForum.getModerationMinMessageValue(););
            {
                long modifiedDate = newMessage.getModifiedDate();.getTime();;
                updateModifiedDate(modifiedDate, con);;
                dbForum.updateModifiedDate(modifiedDate, con);;
            }
        }
        catch( Exception e ); {
            e.printStackTrace();;
            abortTransaction = true;
        }
        finally {
            ConnectionManager.closeTransactionConnection(con, abortTransaction);;
        }

        // Thread count has been modified, remove thread and forum from cache.
        factory.cacheManager.threadCache.remove(this.id);;
        factory.cacheManager.forumCache.remove(this.forumID);;

        // Expire the userMessageCountCache if this message was not posted
        // anonymously.
        if (!newMessage.isAnonymous();); {
            factory.userMessageCountCache.remove(newMessage.getUser();.getID(););;
        }

        // If above the moderation threshold...
        if (newMessage.getModerationValue(); >=
                    dbForum.getModerationMinMessageValue(););
        {
            // Notify the watch manager that the thread has been updated.
            factory.watchManager.notifyWatches(this);;
            // Notify the gateway manager of a new message.
//            dbForum.getGatewayManager();.exportData(dbMessage);;
        }
    }


DBforumThread insertIntoDb(DbForumThread thread, long parentMessageID,

   
 private static final String INSERT_MESSAGE =
        "INSERT INTO bisMessage(messageID, parentMessageID, threadID, forumID, " +
        "userID, subject, body, modValue, rewardPoints, creationDate, modifiedDate); " +
        "VALUES(?,?,?,?,?,?,?,?,?,?,?);";