KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > mvnforum > admin > RankWebHandler


1 /*
2  * $Header: /cvsroot/mvnforum/mvnforum/src/com/mvnforum/admin/RankWebHandler.java,v 1.12 2006/04/14 17:05:26 minhnn Exp $
3  * $Author: minhnn $
4  * $Revision: 1.12 $
5  * $Date: 2006/04/14 17:05:26 $
6  *
7  * ====================================================================
8  *
9  * Copyright (C) 2002-2006 by MyVietnam.net
10  *
11  * All copyright notices regarding mvnForum MUST remain
12  * intact in the scripts and in the outputted HTML.
13  * The "powered by" text/logo with a link back to
14  * http://www.mvnForum.com and http://www.MyVietnam.net in
15  * the footer of the pages MUST remain visible when the pages
16  * are viewed on the internet or intranet.
17  *
18  * This program is free software; you can redistribute it and/or modify
19  * it under the terms of the GNU General Public License as published by
20  * the Free Software Foundation; either version 2 of the License, or
21  * any later version.
22  *
23  * This program is distributed in the hope that it will be useful,
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26  * GNU General Public License for more details.
27  *
28  * You should have received a copy of the GNU General Public License
29  * along with this program; if not, write to the Free Software
30  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31  *
32  * Support can be obtained from support forums at:
33  * http://www.mvnForum.com/mvnforum/index
34  *
35  * Correspondence and Marketing Questions can be sent to:
36  * info at MyVietnam net
37  *
38  * @author: Minh Nguyen
39  * @author: Mai Nguyen
40  */

41 package com.mvnforum.admin;
42
43 import com.mvnforum.MyUtil;
44 import com.mvnforum.auth.*;
45 import com.mvnforum.db.DAOFactory;
46 import com.mvnforum.db.RankBean;
47 import net.myvietnam.mvncore.exception.*;
48 import net.myvietnam.mvncore.util.GenericParamUtil;
49 import net.myvietnam.mvncore.web.GenericRequest;
50 import net.myvietnam.mvncore.web.GenericResponse;
51
52 public class RankWebHandler {
53
54     private OnlineUserManager onlineUserManager = OnlineUserManager.getInstance();
55
56     public RankWebHandler() {
57     }
58
59     public void processAdd(GenericRequest request, GenericResponse response)
60         throws BadInputException, CreateException, DatabaseException,
61         DuplicateKeyException, AuthenticationException, AssertionException {
62
63         OnlineUser onlineUser = onlineUserManager.getOnlineUser(request);
64         MVNForumPermission permission = onlineUser.getPermission();
65         permission.ensureCanAdminSystem();
66
67         MyUtil.saveVNTyperMode(request, response);
68
69         int rankMinPosts= GenericParamUtil.getParameterInt(request, "RankMinPosts");
70         String JavaDoc rankTitle= GenericParamUtil.getParameterSafe(request, "RankTitle", true);
71
72         // reserved for future
73
int rankLevel = 0;
74         String JavaDoc rankImage= "";
75         int rankType = 0;
76         int rankOption = 0;
77
78         DAOFactory.getRankDAO().create(rankMinPosts, rankLevel, rankTitle,
79                                        rankImage, rankType, rankOption);
80     }
81
82     public void prepareEdit(GenericRequest request)
83         throws BadInputException, DatabaseException, ObjectNotFoundException,
84         AuthenticationException, AssertionException {
85
86         OnlineUser onlineUser = onlineUserManager.getOnlineUser(request);
87         MVNForumPermission permission = onlineUser.getPermission();
88         permission.ensureCanAdminSystem();
89
90         // primary key column(s)
91
int rankID = GenericParamUtil.getParameterInt(request, "rank");
92
93         RankBean rankBean = DAOFactory.getRankDAO().getRank(rankID);
94
95         request.setAttribute("RankBean", rankBean);
96     }
97
98     public void prepareList(GenericRequest request)
99         throws DatabaseException, AuthenticationException, AssertionException {
100
101         OnlineUser onlineUser = onlineUserManager.getOnlineUser(request);
102         MVNForumPermission permission = onlineUser.getPermission();
103         permission.ensureCanAdminSystem();
104     }
105
106     public void processUpdate(GenericRequest request, GenericResponse response)
107         throws BadInputException, DatabaseException, DuplicateKeyException,
108         ObjectNotFoundException, AuthenticationException, AssertionException {
109
110         OnlineUser onlineUser = onlineUserManager.getOnlineUser(request);
111         MVNForumPermission permission = onlineUser.getPermission();
112         permission.ensureCanAdminSystem();
113
114         MyUtil.saveVNTyperMode(request, response);
115
116         // primary key column(s)
117
int rankID = GenericParamUtil.getParameterInt(request, "RankID");
118
119         // column(s) to update
120
int rankMinPosts= GenericParamUtil.getParameterInt(request, "RankMinPosts");
121         String JavaDoc rankTitle= GenericParamUtil.getParameterSafe(request, "RankTitle", true);
122
123         //reserved for future
124
int rankLevel = 0;
125         String JavaDoc rankImage= "";
126         int rankType = 0;
127         int rankOption = 0;
128
129         DAOFactory.getRankDAO().update(rankID, // primary key
130
rankMinPosts, rankLevel, rankTitle,
131                              rankImage, rankType, rankOption);
132     }
133
134     public void processDelete(GenericRequest request)
135         throws BadInputException, DatabaseException, ObjectNotFoundException,
136         AuthenticationException, AssertionException {
137
138         OnlineUser onlineUser = onlineUserManager.getOnlineUser(request);
139         MVNForumPermission permission = onlineUser.getPermission();
140         permission.ensureCanAdminSystem();
141
142         // primary key column(s)
143
int rankID = GenericParamUtil.getParameterInt(request, "rank");
144
145         DAOFactory.getRankDAO().delete(rankID);
146     }
147
148 }
149
Popular Tags