01: /*
02: * This program is free software; you can redistribute it and/or modify
03: * it under the terms of the GNU General Public License as published by
04: * the Free Software Foundation; either version 2 of the License, or
05: * (at your option) any later version.
06: *
07: * This program is distributed in the hope that it will be useful,
08: * but WITHOUT ANY WARRANTY; without even the implied warranty of
09: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10: * GNU Library General Public License for more details.
11: *
12: * You should have received a copy of the GNU General Public License
13: * along with this program; if not, write to the Free Software
14: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15: */
16: package dlog4j.action;
17:
18: import javax.servlet.http.HttpServletRequest;
19: import javax.servlet.http.HttpServletResponse;
20:
21: import org.apache.struts.action.ActionErrors;
22: import org.apache.struts.action.ActionForm;
23: import org.apache.struts.action.ActionForward;
24: import org.apache.struts.action.ActionMapping;
25:
26: import dlog4j.Globals;
27: import dlog4j.formbean.UserForm;
28:
29: /**
30: * 管理类Action的基类
31: * @author Winter Lau
32: */
33: public class AdminActionBase extends DlogActionBase {
34:
35: /**
36: * 该方法覆盖了父类的功能,验证用户身份的有效性
37: */
38: public ActionForward execute(ActionMapping mapping,
39: ActionForm form, HttpServletRequest req,
40: HttpServletResponse res) throws Exception {
41: UserForm user = getLoginUser(req);
42: if (user == null || !user.isAdmin())
43: return mapping.findForward("admin_access_deny");
44:
45: ActionForward forward = null;
46: //统一validate
47: if (form != null) {
48: ActionErrors errors = form.validate(mapping, req);
49: if (errors != null && !errors.isEmpty()) {
50: saveErrors(req, errors);
51: forward = mapping.getInputForward();
52: }
53: }
54: if (forward == null)
55: forward = super .execute(mapping, form, req, res);
56: //处理resin 3.0.x 的兼容性问题 -> jspe小服务程序
57: if (!forward.getRedirect()) {
58: //传递要forward的路径给jspe小服务程序
59: req
60: .setAttribute(Globals.ACTION_PATH_KEY, forward
61: .getPath());
62: }
63: return forward;
64: }
65:
66: }
|