KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > methodhead > transfer > AboutAction


1 /*
2  * Copyright (C) 2006 Methodhead Software LLC. All rights reserved.
3  *
4  * This file is part of TransferCM.
5  *
6  * TransferCM is free software; you can redistribute it and/or modify it under the
7  * terms of the GNU General Public License as published by the Free Software
8  * Foundation; either version 2 of the License, or (at your option) any later
9  * 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 JavaDoc;
30 import javax.servlet.http.HttpServletResponse JavaDoc;
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
39 extends
40   AuthAction {
41
42   // constructors /////////////////////////////////////////////////////////////
43

44   // constants ////////////////////////////////////////////////////////////////
45

46   // classes //////////////////////////////////////////////////////////////////
47

48   // methods //////////////////////////////////////////////////////////////////
49

50   protected ActionForward doAbout(
51     OperationContext op,
52     TransferPolicy policy ) {
53
54     //
55
// authorized?
56
//
57
String JavaDoc msg = policy.isAboutAuthorized( op );
58     if ( msg != null ) {
59       StrutsUtil.addMessage( op.request, msg, null, null, null );
60       return op.mapping.findForward( "accessDenied" );
61     }
62
63     return op.mapping.findForward( "form" );
64   }
65
66   public ActionForward doExecute(
67     ActionMapping mapping,
68     ActionForm form,
69     HttpServletRequest JavaDoc request,
70     HttpServletResponse JavaDoc response )
71   throws
72     Exception JavaDoc {
73
74     //
75
// get some things we'll need
76
//
77
DynaActionForm dynaForm = ( DynaActionForm )form;
78     TransferPolicy policy = ( TransferPolicy )StrutsUtil.getPolicy( mapping );
79     AuthUser user = AuthUtil.getUser( request );
80
81     OperationContext op =
82       new OperationContext( mapping, dynaForm, request, response, user );
83
84     //
85
// execute the appopriate method
86
//
87
if ( mapping.getPath().equals( "/about" ) ) {
88       return doAbout( op, policy );
89     }
90
91     throw
92       new Exception JavaDoc( "Unexpected mapping path \"" + mapping.getPath() + "\"" );
93   }
94
95   // properties ///////////////////////////////////////////////////////////////
96

97   // attributes ///////////////////////////////////////////////////////////////
98
}
99
Popular Tags