KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ivata > groupware > mask > struts > ResetAction


1 /*
2  * Copyright (c) 2001 - 2005 ivata limited.
3  * All rights reserved.
4  * -----------------------------------------------------------------------------
5  * ivata groupware may be redistributed under the GNU General Public
6  * License as published by the Free Software Foundation;
7  * version 2 of the License.
8  *
9  * These programs are free software; you can redistribute them and/or
10  * modify them under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; version 2 of the License.
12  *
13  * These programs are distributed in the hope that they will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  *
17  * See the GNU General Public License in the file LICENSE.txt for more
18  * details.
19  *
20  * If you would like a copy of the GNU General Public License write to
21  *
22  * Free Software Foundation, Inc.
23  * 59 Temple Place - Suite 330
24  * Boston, MA 02111-1307, USA.
25  *
26  *
27  * To arrange commercial support and licensing, contact ivata at
28  * http://www.ivata.com/contact.jsp
29  * -----------------------------------------------------------------------------
30  * $Log: ResetAction.java,v $
31  * Revision 1.3 2005/04/10 20:09:46 colinmacleod
32  * Added new themes.
33  * Changed id type to String.
34  * Changed i tag to em and b tag to strong.
35  * Improved PicoContainerFactory with NanoContainer scripts.
36  *
37  * Revision 1.2 2005/04/09 17:19:50 colinmacleod
38  * Changed copyright text to GPL v2 explicitly.
39  *
40  * Revision 1.1.1.1 2005/03/10 17:49:57 colinmacleod
41  * Restructured ivata op around Hibernate/PicoContainer.
42  * Renamed ivata groupware.
43  *
44  * Revision 1.2 2004/12/31 18:53:26 colinmacleod
45  * Added MaskFactory to constructor of MaskAction.
46  *
47  * Revision 1.1 2004/12/29 14:09:32 colinmacleod
48  * Changed subproject name from masks to mask
49  *
50  * -----------------------------------------------------------------------------
51  */

52 package com.ivata.groupware.mask.struts;
53
54 import java.io.IOException JavaDoc;
55
56 import javax.servlet.ServletContext JavaDoc;
57 import javax.servlet.http.HttpServletRequest JavaDoc;
58 import javax.servlet.http.HttpServletResponse JavaDoc;
59 import javax.servlet.http.HttpSession JavaDoc;
60
61 import org.apache.struts.action.ActionErrors;
62 import org.apache.struts.action.ActionForm;
63 import org.apache.struts.action.ActionMapping;
64
65 import com.ivata.groupware.container.PicoContainerFactory;
66 import com.ivata.groupware.container.struts.PicoRequestProcessorImplementation;
67 import com.ivata.mask.MaskFactory;
68 import com.ivata.mask.util.SystemException;
69 import com.ivata.mask.web.struts.MaskAction;
70 import com.ivata.mask.web.struts.MaskAuthenticator;
71
72 /**
73  * <p>
74  * This action is useful for debugging - it reload the ivata masks
75  * configuration, which is a good thing if you need to change the
76  * <code>ivataMasks.xml</code> file after testing some new feature.
77  * </p>
78  * <p>
79  * <strong>Note:</strong>
80  * You should disable this action on a production system (by commenting out the
81  * line in the <strong>Struts</strong> config file
82  * (<code>struts-config.xml</code>).
83  * </p>
84  *
85  * @since ivata groupware 0.10 (2004-12-29)
86  * @author Colin MacLeod
87  * <a HREF='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
88  * @version $Revision: 1.3 $
89  */

90 public class ResetAction extends MaskAction {
91     /**
92      * <p>
93      * Construct the action to reset masks.
94      * </p>
95      *
96      * @param maskFactory This factory is needed to access the masks and groups
97      * of masks.
98      * @param authenticator used to confirm whether or not the
99      * user should be allowed to continue, in the <code>execute</code> method.
100      */

101     public ResetAction(MaskFactory maskFactory, MaskAuthenticator authenticator) {
102         super(maskFactory, authenticator);
103     }
104
105     /**
106      * <p>
107      * Resets the ivata masks implementation. Should be disabled on a production
108      * system (see comments above).
109      * </p>
110      *
111      * @param mapping current action mapping from <em>Struts</em> config.
112      * @param log valid logging object to write messages to.
113      * @param errors valid errors object to append errors to. If there are
114      * any errors, the action will return to the input.
115      * @param form optional ActionForm bean for this request (if any)
116      * @param request non-HTTP request we are processing
117      * @param response The non-HTTP response we are creating
118      * @param session returned from the <code>request</code> parameter.
119      * @param userName current user name from session. .
120      * @param settings valid, non-null settings from session.
121      * @exception SystemException if there is any problem which
122      * prevents processing. It will result in the webapp being forwarded
123      * to
124      * the standard error page.
125      * @return this method returns the string used to identify the correct
126      * <em>Struts</em> <code>ActionForward</code> which should follow this
127      * page, or <code>null</code> if it should return to the input.
128      *
129      */

130     public String JavaDoc execute(final ActionMapping mapping,
131             final ActionErrors errors,
132             final ActionForm form,
133             final HttpServletRequest JavaDoc request,
134             final HttpServletResponse JavaDoc response,
135             final HttpSession JavaDoc session)
136                 throws SystemException {
137
138         MaskFactory maskFactory = PicoContainerFactory.getInstance()
139             .getMaskFactory();
140         ServletContext JavaDoc context = servlet.getServletContext();
141         try {
142             maskFactory.readConfiguration(context.getResourceAsStream(
143                     PicoRequestProcessorImplementation.MASKS_FILE_NAME));
144         } catch (IOException JavaDoc e) {
145             throw new SystemException(e);
146         }
147
148         // this action goes nowhere afterwards! (it's just for debugging)
149
return null;
150     }
151 }
152
Popular Tags