01: /*
02: * Copyright (C) 2006 Methodhead Software LLC. All rights reserved.
03: *
04: * This file is part of TransferCM.
05: *
06: * TransferCM is free software; you can redistribute it and/or modify it under the
07: * terms of the GNU General Public License as published by the Free Software
08: * Foundation; either version 2 of the License, or (at your option) any later
09: * version.
10: *
11: * TransferCM is distributed in the hope that it will be useful, but WITHOUT ANY
12: * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14: * details.
15: *
16: * You should have received a copy of the GNU General Public License along with
17: * TransferCM; if not, write to the Free Software Foundation, Inc., 51 Franklin St,
18: * Fifth Floor, Boston, MA 02110-1301 USA
19: */
20:
21: package com.methodhead.transfer;
22:
23: import org.apache.struts.action.Action;
24: import org.apache.struts.action.ActionMapping;
25: import org.apache.struts.action.ActionForm;
26: import org.apache.struts.action.DynaActionForm;
27: import org.apache.struts.action.ActionForward;
28:
29: import javax.servlet.http.HttpServletRequest;
30: import javax.servlet.http.HttpServletResponse;
31:
32: import com.methodhead.auth.AuthUtil;
33: import com.methodhead.auth.AuthUser;
34: import com.methodhead.auth.AuthAction;
35: import com.methodhead.util.OperationContext;
36: import com.methodhead.util.StrutsUtil;
37:
38: public class AboutAction extends AuthAction {
39:
40: // constructors /////////////////////////////////////////////////////////////
41:
42: // constants ////////////////////////////////////////////////////////////////
43:
44: // classes //////////////////////////////////////////////////////////////////
45:
46: // methods //////////////////////////////////////////////////////////////////
47:
48: protected ActionForward doAbout(OperationContext op,
49: TransferPolicy policy) {
50:
51: //
52: // authorized?
53: //
54: String msg = policy.isAboutAuthorized(op);
55: if (msg != null) {
56: StrutsUtil.addMessage(op.request, msg, null, null, null);
57: return op.mapping.findForward("accessDenied");
58: }
59:
60: return op.mapping.findForward("form");
61: }
62:
63: public ActionForward doExecute(ActionMapping mapping,
64: ActionForm form, HttpServletRequest request,
65: HttpServletResponse response) throws Exception {
66:
67: //
68: // get some things we'll need
69: //
70: DynaActionForm dynaForm = (DynaActionForm) form;
71: TransferPolicy policy = (TransferPolicy) StrutsUtil
72: .getPolicy(mapping);
73: AuthUser user = AuthUtil.getUser(request);
74:
75: OperationContext op = new OperationContext(mapping, dynaForm,
76: request, response, user);
77:
78: //
79: // execute the appopriate method
80: //
81: if (mapping.getPath().equals("/about")) {
82: return doAbout(op, policy);
83: }
84:
85: throw new Exception("Unexpected mapping path \""
86: + mapping.getPath() + "\"");
87: }
88:
89: // properties ///////////////////////////////////////////////////////////////
90:
91: // attributes ///////////////////////////////////////////////////////////////
92: }
|