?? favoritethreadwebhandler.java
字號:
/*
* $Header: /cvsroot/mvnforum/mvnforum/src/com/mvnforum/user/FavoriteThreadWebHandler.java,v 1.5 2004/03/25 02:59:13 minhnn Exp $
* $Author: minhnn $
* $Revision: 1.5 $
* $Date: 2004/03/25 02:59:13 $
*
* ====================================================================
*
* Copyright (C) 2002-2004 by MyVietnam.net
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or any later version.
*
* All copyright notices regarding mvnForum MUST remain intact
* in the scripts and in the outputted HTML.
* The "powered by" text/logo with a link back to
* http://www.mvnForum.com and http://www.MyVietnam.net in the
* footer of the pages MUST remain visible when the pages
* are viewed on the internet or intranet.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* Support can be obtained from support forums at:
* http://www.mvnForum.com/mvnforum/index
*
* Correspondence and Marketing Questions can be sent to:
* info@MyVietnam.net
*
* @author: Minh Nguyen minhnn@MyVietnam.net
* @author: Mai Nguyen mai.nh@MyVietnam.net
*/
package com.mvnforum.user;
import java.sql.Timestamp;
import javax.servlet.http.HttpServletRequest;
import com.mvnforum.MVNForumConfig;
import com.mvnforum.auth.*;
import com.mvnforum.db.*;
import net.myvietnam.mvncore.exception.*;
import net.myvietnam.mvncore.util.DateUtil;
import net.myvietnam.mvncore.util.ParamUtil;
class FavoriteThreadWebHandler {
private OnlineUserManager userManager = OnlineUserManager.getInstance();
FavoriteThreadWebHandler() {
}
void processAdd(HttpServletRequest request)
throws BadInputException, CreateException, DatabaseException, DuplicateKeyException, ForeignKeyNotFoundException,
ObjectNotFoundException, AuthenticationException, AssertionException {
OnlineUser onlineUser = userManager.getOnlineUser(request);
MVNForumPermission permission = onlineUser.getPermission();
permission.ensureIsAuthenticated();
int memberID = onlineUser.getMemberID();
// check to make sure that this user doesnt exceed his favorite max
int currentFavoriteCount = DAOFactory.getFavoriteThreadDAO().getNumberOfBeans_inMember(memberID);
int maxFavorites = MVNForumConfig.getMaxFavoriteThread();
if (currentFavoriteCount >= maxFavorites) {
//@todo: choose a better exception class
throw new BadInputException("You have already use all your favorite quota (" + maxFavorites + ").");
}
Timestamp now = DateUtil.getCurrentGMTTimestamp();
int threadID = ParamUtil.getParameterInt(request, "thread");
Timestamp favoriteCreationDate = now;
int favoriteType = 0;//@todo implement it later
int favoriteOption = 0;//@todo implement it later
int favoriteStatus = 0;//@todo implement it later
ThreadBean threadBean = DAOFactory.getThreadDAO().getBean(threadID);
int forumID = threadBean.getForumID();
ForumCache.getInstance().getBean(forumID).ensureNotDisabledForum();
// now check permission the this user have the readPost permission
permission.ensureCanReadPost(forumID);
// has the permission now, then insert to database
try {
DAOFactory.getFavoriteThreadDAO().create(memberID, threadID, forumID,
favoriteCreationDate, favoriteType, favoriteOption,
favoriteStatus);
} catch (DuplicateKeyException ex) {
// already add favorite thread, just ignore
}
}
public void processDelete(HttpServletRequest request)
throws BadInputException, DatabaseException, ObjectNotFoundException,
AuthenticationException, AssertionException {
OnlineUser onlineUser = userManager.getOnlineUser(request);
MVNForumPermission permission = onlineUser.getPermission();
permission.ensureIsAuthenticated();
// primary key column(s)
int memberID = onlineUser.getMemberID();
int threadID = ParamUtil.getParameterInt(request, "thread");
DAOFactory.getFavoriteThreadDAO().delete(memberID, threadID);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -