/**
* $RCSfile: DbForum.java,v $
* $Revision: 1.1.1.1 $
* $Date: 2002/09/09 13:50:52 $
*
* New Jive from Jdon.com.
*
* This software is the proprietary information of CoolServlets, Inc.
* Use is subject to license terms.
*/
package com.jivesoftware.forum.database;
import java.util.*;
import java.util.Date;
import java.sql.*;
import java.io.*;
import com.jivesoftware.forum.*;
import com.jivesoftware.util.*;
/**
* Database implementation of the Forum interface. It loads and stores forum
* information from a a database.
*
* @see Forum
*/
public class DbForum implements Forum, Cacheable {
/** DATABASE QUERIES **/
private static final String ALL_THREADS =
"SELECT threadID from jiveThread WHERE forumID=?";
private static final String ADD_THREAD =
"UPDATE jiveThread set forumID=? WHERE threadID=?";
private static final String MOVE_MESSAGES =
"UPDATE jiveMessage set forumID=? WHERE threadID=?";
protected static final String DELETE_THREAD =
"DELETE FROM jiveThread WHERE threadID=?";
private static final String DELETE_THREAD_PROPERTIES =
"DELETE FROM jiveThreadProp WHERE threadID=?";
private static final String LOAD_PROPERTIES =
"SELECT name, propValue FROM jiveForumProp WHERE forumID=?";
private static final String DELETE_PROPERTY =
"DELETE FROM jiveForumProp WHERE forumID=? AND name=?";
private static final String DELETE_PROPERTIES =
"DELETE FROM jiveForumProp WHERE forumID=?";
private static final String INSERT_PROPERTY =
"INSERT INTO jiveForumProp(forumID,name,propValue) VALUES(?,?,?)";
private static final String LOAD_FORUM =
"SELECT forumID, name, description, modDefaultThreadVal, " +
"modDefaultMsgVal, modMinThreadVal, modMinMsgVal, modifiedDate, " +
"creationDate FROM jiveForum WHERE forumID=?";
private static final String ADD_FORUM =
"INSERT INTO jiveForum(forumID, name, description, modDefaultThreadVal, " +
"modDefaultMsgVal, modMinThreadVal, modMinMsgVal, modifiedDate, creationDate)" +
" VALUES (?,?,?,?,?,?,?,?,?)";
private static final String SAVE_FORUM =
"UPDATE jiveForum SET name=?, description=?, modDefaultThreadVal=?, " +
"modDefaultMsgVal=?, modMinThreadVal=?, modMinMsgVal=?, " +
"modifiedDate=?, creationDate=? WHERE forumID=?";
private static final String UPDATE_FORUM_MODIFIED_DATE =
"UPDATE jiveForum SET modifiedDate=? WHERE forumID=?";
private static final String POPULAR_THREADS =
"SELECT threadID, count(1) AS msgCount FROM jiveMessage WHERE " +
"modifiedDate > ? AND forumID=? GROUP BY threadID ORDER BY msgCount DESC";
private static final String POPULAR_THREADS_ORACLE =
"SELECT /*+ INDEX (jiveMessage jiveMessage_mDate_idx) */ threadID, " +
"count(1) AS msgCount FROM jiveMessage WHERE modifiedDate > ? " +
"AND forumID=? GROUP BY threadID ORDER BY msgCount DESC";
/*
// Note, the above query includes hints for Oracle, which are necessary
// so that modified date index will always be used. This is a great
// tradeoff when the time window you're looking at is not excessively
// large. MySQL also handles the query very quickly. If your own db
// needs a hint, you may want to edit the sql logic to add it.
*/
/**
* Controls whether extended properties should be lazily loaded (not loaded
* until requested). If the properties are infrequently used, this provides
* a great speedup in initial object loading time. However, if your
* application does use extended properties all the time, you may wish to
* turn lazy loading off, as it's actually faster in total db lookup time
* to load everything at once.
*/
private static final boolean LAZY_PROP_LOADING = true;
/**
* Number of threadID's per cache block.
*/
public static final int THREAD_BLOCK_SIZE = 200;
/**
* Number of messageID's per cache block.
*/
public static final int MESSAGE_BLOCK_SIZE = 100;
// Constant for an empty bock. This is returned in the case that there are
// no results when trying to load a thread or message block.
private static final long[] EMPTY_BLOCK = new long[0];
// A ResultFilter is used to filter and sort the values that are returned
// from the threads() and messages() methods. We use a default
private static final ResultFilter DEFAULT_THREAD_FILTER =
ResultFilter.createDefaultThreadFilter();
private static final ResultFilter DEFAULT_MESSAGE_FILTER =
ResultFilter.createDefaultMessageFilter();
/**
* Cache for lists of thread id's. The default size is 16K, which should
* let us hold about 2000 thread id's in memory at once. If you have a lot
* of memory and very large forums, you may wish to make the size of this
* cache considerably larger.
*/
protected Cache threadListCache = new Cache(16*1024, JiveGlobals.HOUR * 6);
/**
* Cache for lists of message id's. The default size is 8K, which should
* let us hold about 100 message id's in memory at once. If you have a lot
* of memory and very large forums, you may wish to make the size of this
* cache considerably larger.
*/
protected Cache messageListCache = new Cache(8*1024, JiveGlobals.HOUR * 6);
/**
* Cache for thread counts. Default size is 256 bytes.
*/
protected Cache threadCountCache = new Cache(256, JiveGlobals.HOUR * 6);
/**
* Cache for message counts. Default size is 256 bytes.
*/
protected Cache messageCountCache = new Cache(256, JiveGlobals.HOUR * 6);
private long id = -1;
private String name;
private String description;
private java.util.Date creationDate;
private java.util.Date modifiedDate;
private int modDefaultThreadValue = 1;
private int modDefaultMessageValue = 1;
private int modMinThreadValue = 1 ;
private int modMinMessageValue = 1;
private Map properties;
private DbForumFactory factory;
private long[] popularThreads = null;
private DbFilterManager filterManager;
/**
* Creates a new forum with the specified name and description.
*
* @param name the name of the forum.
* @param description the description of the forum.
* @param factory the DbForumFactory the forum is a part of.
*/
protected DbForum(String name, String description, DbForumFactory factory) {
this.id = SequenceManager.nextID(JiveGlobals.FORUM);
this.name = name;
this.description = description;
long now = System.currentTimeMillis();
creationDate = new java.util.Date(now);
modifiedDate = new java.util.Date(now);
this.factory = factory;
insertIntoDb();
properties = new Hashtable();
init();
}
/**
* Loads a forum with the specified id.
*/
protected DbForum(long id, DbForumFactory factory)
throws ForumNotFoundException
{
this.id = id;
this.factory = factory;
loadFromDb();
init();
}
private void init() {
filterManager = new DbFilterManager(this.id, factory);
}
//FROM THE FORUM INTERFACE//
public long getID() {
return id;
}
public String getName() {
return name;
}
public void setName(String name) throws ForumAlreadyExistsException {
// If the new name is the same as the current name, do nothing.
if (this.name.equals(name)) {
return;
}
// If a forum with the new name already exists, throw an exception.
try {
// Check to make sure that's
没有合适的资源?快使用搜索试试~ 我知道了~
jive 2.5 源代码
共1223个文件
class:434个
jsp:172个
java:170个
4星 · 超过85%的资源 需积分: 10 17 下载量 161 浏览量
2010-03-06
20:11:07
上传
评论
收藏 3.41MB ZIP 举报
温馨提示
jive 2.5 源代码,里面包含有如何安装jive.
资源推荐
资源详情
资源评论
收起资源包目录
jive 2.5 源代码 (1223个子文件)
build.bat 46B
DbForum.class 32KB
DbForum.class 32KB
DbForumThread.class 25KB
DbForumThread.class 25KB
DbForumFactory.class 19KB
DbForumFactory.class 19KB
DbGroup.class 17KB
DbGroup.class 17KB
DbForumMessage.class 16KB
DbForumMessage.class 16KB
DbUser.class 15KB
DbUser.class 15KB
SkinUtils.class 15KB
SkinUtils.class 15KB
DbDataImport.class 14KB
DbDataImport.class 14KB
DbSearchManager.class 14KB
DbSearchManager.class 14KB
DbDataExport.class 14KB
DbDataExport.class 14KB
DbPermissionsManager.class 14KB
DbPermissionsManager.class 14KB
DbWatchManager.class 12KB
DbWatchManager.class 12KB
JavaCodeViewer.class 12KB
JavaCodeViewer.class 12KB
JavaCodeViewer.class 11KB
JavaCodeViewer.class 11KB
JavaCodeHighlighter.class 11KB
JavaCodeHighlighter.class 11KB
DbFilterManager.class 10KB
DbFilterManager.class 10KB
DefaultConnectionProvider$ConnectionPool.class 10KB
DefaultConnectionProvider$ConnectionPool.class 10KB
StringUtils.class 10KB
StringUtils.class 10KB
DbUserManager.class 10KB
DbUserManager.class 10KB
DbRewardManager.class 10KB
DbRewardManager.class 10KB
LongHashMap.class 9KB
LongHashMap.class 9KB
ProfiledConnection.class 9KB
ProfiledConnection.class 9KB
ForumFactoryProxy.class 9KB
ForumFactoryProxy.class 9KB
ForumProxy.class 8KB
ForumProxy.class 8KB
DbQuery.class 8KB
DbQuery.class 8KB
DbDataImport$MessageHandler.class 8KB
DbDataImport$MessageHandler.class 8KB
ConnectionManager.class 8KB
ConnectionManager.class 8KB
DisplayUtil.class 8KB
DisplayUtil.class 8KB
DbGroupManager.class 7KB
DbGroupManager.class 7KB
CodeViewer.class 7KB
CodeViewer.class 7KB
DbTreeWalker.class 6KB
DbTreeWalker.class 6KB
DbDataImport$ForumHandler.class 6KB
DbDataImport$ForumHandler.class 6KB
QuoteFilter.class 6KB
QuoteFilter.class 6KB
RandomStrg.class 6KB
RandomStrg.class 6KB
PreparedStatementAdapter.class 6KB
PreparedStatementAdapter.class 6KB
ForumThreadProxy.class 6KB
ForumThreadProxy.class 6KB
DbDataImport$UserHandler.class 6KB
DbDataImport$UserHandler.class 6KB
DefaultConnectionProvider.class 6KB
DefaultConnectionProvider.class 6KB
ConnectionAdapter.class 6KB
ConnectionAdapter.class 6KB
JNDIDataSourceProvider.class 5KB
JNDIDataSourceProvider.class 5KB
DatabaseCacheManager.class 5KB
DatabaseCacheManager.class 5KB
Emoticon.class 5KB
Emoticon.class 5KB
UploadImg.class 5KB
UploadImg.class 5KB
MultipartFormHandle.class 5KB
MultipartFormHandle.class 5KB
JiveGlobals.class 5KB
JiveGlobals.class 5KB
WatchManagerProxy.class 5KB
WatchManagerProxy.class 5KB
StatementAdapter.class 5KB
StatementAdapter.class 5KB
ForumMessageProxy.class 5KB
ForumMessageProxy.class 5KB
XMLProperties.class 5KB
XMLProperties.class 5KB
BeanUtils.class 5KB
共 1223 条
- 1
- 2
- 3
- 4
- 5
- 6
- 13
资源评论
- 翱翔的翱2012-11-11确实不错,看过收获很大
youjinglili
- 粉丝: 0
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功