001: /*
002: * Copyright (c) 2001 - 2005 ivata limited.
003: * All rights reserved.
004: * -----------------------------------------------------------------------------
005: * ivata groupware may be redistributed under the GNU General Public
006: * License as published by the Free Software Foundation;
007: * version 2 of the License.
008: *
009: * These programs are free software; you can redistribute them and/or
010: * modify them under the terms of the GNU General Public License
011: * as published by the Free Software Foundation; version 2 of the License.
012: *
013: * These programs are distributed in the hope that they will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
016: *
017: * See the GNU General Public License in the file LICENSE.txt for more
018: * details.
019: *
020: * If you would like a copy of the GNU General Public License write to
021: *
022: * Free Software Foundation, Inc.
023: * 59 Temple Place - Suite 330
024: * Boston, MA 02111-1307, USA.
025: *
026: *
027: * To arrange commercial support and licensing, contact ivata at
028: * http://www.ivata.com/contact.jsp
029: * -----------------------------------------------------------------------------
030: * $Log: ResetAction.java,v $
031: * Revision 1.5 2005/10/03 10:21:14 colinmacleod
032: * Fixed some style and javadoc issues.
033: *
034: * Revision 1.4 2005/10/02 14:08:57 colinmacleod
035: * Added/improved log4j logging.
036: *
037: * Revision 1.3 2005/04/10 20:09:46 colinmacleod
038: * Added new themes.
039: * Changed id type to String.
040: * Changed i tag to em and b tag to strong.
041: * Improved PicoContainerFactory with NanoContainer scripts.
042: *
043: * Revision 1.2 2005/04/09 17:19:50 colinmacleod
044: * Changed copyright text to GPL v2 explicitly.
045: *
046: * Revision 1.1.1.1 2005/03/10 17:49:57 colinmacleod
047: * Restructured ivata op around Hibernate/PicoContainer.
048: * Renamed ivata groupware.
049: *
050: * Revision 1.2 2004/12/31 18:53:26 colinmacleod
051: * Added MaskFactory to constructor of MaskAction.
052: *
053: * Revision 1.1 2004/12/29 14:09:32 colinmacleod
054: * Changed subproject name from masks to mask
055: *
056: * -----------------------------------------------------------------------------
057: */
058: package com.ivata.groupware.mask.struts;
059:
060: import org.apache.log4j.Logger;
061:
062: import java.io.IOException;
063:
064: import javax.servlet.ServletContext;
065: import javax.servlet.http.HttpServletRequest;
066: import javax.servlet.http.HttpServletResponse;
067: import javax.servlet.http.HttpSession;
068:
069: import org.apache.struts.action.ActionForm;
070: import org.apache.struts.action.ActionMapping;
071: import org.sourceforge.clientsession.ClientSession;
072:
073: import com.ivata.groupware.container.PicoContainerFactory;
074: import com.ivata.groupware.container.struts.PicoRequestProcessorImplementation;
075: import com.ivata.mask.MaskFactory;
076: import com.ivata.mask.util.SystemException;
077: import com.ivata.mask.web.struts.MaskAction;
078: import com.ivata.mask.web.struts.MaskAuthenticator;
079:
080: /**
081: * <p>
082: * This action is useful for debugging - it reload the ivata masks
083: * configuration, which is a good thing if you need to change the
084: * <code>ivataMasks.xml</code> file after testing some new feature.
085: * </p>
086: * <p>
087: * <strong>Note:</strong>
088: * You should disable this action on a production system (by commenting out the
089: * line in the <strong>Struts</strong> config file
090: * (<code>struts-config.xml</code>).
091: * </p>
092: *
093: * @since ivata groupware 0.10 (2004-12-29)
094: * @author Colin MacLeod
095: * <a href='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
096: * @version $Revision: 1.5 $
097: */
098: public class ResetAction extends MaskAction {
099: /**
100: * Logger for this class.
101: */
102: private static final Logger logger = Logger
103: .getLogger(ResetAction.class);
104:
105: /**
106: * <p>
107: * Construct the action to reset masks.
108: * </p>
109: *
110: * @param maskFactory This factory is needed to access the masks and groups
111: * of masks.
112: * @param authenticator used to confirm whether or not the
113: * user should be allowed to continue, in the <code>execute</code> method.
114: */
115: public ResetAction(MaskFactory maskFactory,
116: MaskAuthenticator authenticator) {
117: super (maskFactory, authenticator);
118: }
119:
120: /**
121: * <p>
122: * Resets the ivata masks implementation. Should be disabled on a production
123: * system (see comments above).
124: * </p>
125: *
126: * @param mapping current action mapping from <em>Struts</em> config.
127: * @param form optional ActionForm bean for this request (if any)
128: * @param request non-HTTP request we are processing
129: * @param response The non-HTTP response we are creating
130: * @param session returned from the <code>request</code> parameter.
131: * @param log valid logging object to write messages to.
132: * @param userName current user name from session. .
133: * @param settings valid, non-null settings from session.
134: * @exception SystemException if there is any problem which
135: * prevents processing. It will result in the webapp being forwarded
136: * to
137: * the standard error page.
138: * @return this method returns the string used to identify the correct
139: * <em>Struts</em> <code>ActionForward</code> which should follow this
140: * page, or <code>null</code> if it should return to the input.
141: *
142: */
143: public String execute(final ActionMapping mapping,
144: final ActionForm form, final HttpServletRequest request,
145: final HttpServletResponse response,
146: final HttpSession session, ClientSession clientSession)
147: throws SystemException {
148: if (logger.isDebugEnabled()) {
149: logger.debug("execute(ActionMapping mapping = " + mapping
150: + ", ActionForm form = " + form
151: + ", HttpServletRequest request = " + request
152: + ", HttpServletResponse response = " + response
153: + ", HttpSession session = " + session
154: + ", ClientSession clientSession = "
155: + clientSession + ") - start");
156: }
157:
158: MaskFactory maskFactory = PicoContainerFactory.getInstance()
159: .getMaskFactory();
160: ServletContext context = servlet.getServletContext();
161: try {
162: maskFactory
163: .readConfiguration(context
164: .getResourceAsStream(PicoRequestProcessorImplementation.MASKS_FILE_NAME));
165: } catch (IOException e) {
166: logger
167: .error(
168: "execute(ActionMapping, ActionErrors, ActionForm, HttpServletRequest, HttpServletResponse, HttpSession, ClientSession)",
169: e);
170:
171: throw new SystemException(e);
172: }
173:
174: // this action goes nowhere afterwards! (it's just for debugging)
175:
176: if (logger.isDebugEnabled()) {
177: logger
178: .debug("execute(ActionMapping, ActionErrors, ActionForm, HttpServletRequest, HttpServletResponse, HttpSession, ClientSession) - end - return value = "
179: + null);
180: }
181: return null;
182: }
183: }
|