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: FramesListAction.java,v $
031: * Revision 1.4 2005/10/14 14:26:26 colinmacleod
032: * Removed createListForm - now handled by request processor.
033: * Changed menu frame URI to the action (not the JSP page).
034: *
035: * Revision 1.3 2005/10/03 10:21:14 colinmacleod
036: * Fixed some style and javadoc issues.
037: *
038: * Revision 1.2 2005/10/02 14:08:57 colinmacleod
039: * Added/improved log4j logging.
040: *
041: * Revision 1.1 2005/09/29 14:04:05 colinmacleod
042: * Generalized frames model of ivata masks - initially for use in ivata cms.
043: *
044: */
045: package com.ivata.groupware.mask.struts;
046:
047: import javax.servlet.http.HttpServletRequest;
048: import javax.servlet.http.HttpServletResponse;
049: import javax.servlet.http.HttpSession;
050:
051: import org.apache.log4j.Logger;
052: import org.apache.struts.action.ActionForm;
053: import org.apache.struts.action.ActionMapping;
054: import org.sourceforge.clientsession.ClientSession;
055:
056: import com.ivata.mask.MaskFactory;
057: import com.ivata.mask.persistence.PersistenceManager;
058: import com.ivata.mask.util.StringHandling;
059: import com.ivata.mask.util.SystemException;
060: import com.ivata.mask.web.struts.ListAction;
061: import com.ivata.mask.web.struts.MaskAuthenticator;
062:
063: /**
064: * Overridden to populate the extra fields of the frames list form.
065: *
066: * @since ivata groupware 1.0 (18-Sep-2005)
067: * @author Colin MacLeod
068: * <a href='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
069: * @version $Revision: 1.4 $
070: */
071: public class FramesListAction extends ListAction {
072: /**
073: * This suffix is appended to the <em>Struts</em> path to get the full path
074: * to the action. There <em>must</em> be a more generic way! If you know,
075: * please <a href='mailto:colin.macleod@ivata.com'>tell me</a>.
076: */
077: private static final String ACTION_SUFFIX = ".action";
078: /**
079: * Ending for dependent value objects - to strip off.
080: */
081: private static final String DO_SUFFIX = "DO";
082:
083: /**
084: * Logger for this class.
085: */
086: private static final Logger logger = Logger
087: .getLogger(FramesListAction.class);
088:
089: /**
090: * For display - strip the "DO" from the end of the class name.
091: *
092: * @param className Class name to be converted.
093: * @return <code>className</code> minus "DO" ending, if present.
094: */
095: public static String getDefaultClassName(final String className) {
096: if (logger.isDebugEnabled()) {
097: logger.debug("getDefaultClassName(String className = "
098: + className + ") - start");
099: }
100: int dotPos = className.lastIndexOf('.');
101: int end = className.length();
102: if (className.endsWith(DO_SUFFIX)) {
103: end -= 2;
104: }
105: String returnString = className.substring(dotPos + 1, end);
106: if (logger.isDebugEnabled()) {
107: logger
108: .debug("getDefaultClassName(String) - end - return value = "
109: + returnString);
110: }
111: return returnString;
112: }
113:
114: /**
115: * {@inheritDoc}
116: *
117: * @param persistenceManagerParam {@inheritDoc}
118: * @param maskFactoryParam {@inheritDoc}
119: * @param authenticatorParam {@inheritDoc}
120: */
121: public FramesListAction(
122: final PersistenceManager persistenceManagerParam,
123: final MaskFactory maskFactoryParam,
124: final MaskAuthenticator authenticatorParam) {
125: super (persistenceManagerParam, maskFactoryParam,
126: authenticatorParam);
127: }
128:
129: /**
130: * {@inheritDoc}
131: *
132: * @param mappingParam {@inheritDoc}
133: * @param formParam {@inheritDoc}
134: * @param requestParam {@inheritDoc}
135: * @param responseParam {@inheritDoc}
136: * @param sessionParam {@inheritDoc}
137: * @param clientSessionParam {@inheritDoc}
138: * @return {@inheritDoc}
139: * @throws SystemException {@inheritDoc}
140: */
141: public String execute(final ActionMapping mappingParam,
142: final ActionForm formParam,
143: final HttpServletRequest requestParam,
144: final HttpServletResponse responseParam,
145: final HttpSession sessionParam,
146: final ClientSession clientSessionParam)
147: throws SystemException {
148: if (logger.isDebugEnabled()) {
149: logger.debug("execute(ActionMapping mappingParam = "
150: + mappingParam + ", ActionForm formParam = "
151: + formParam
152: + ", HttpServletRequest requestParam = "
153: + requestParam
154: + ", HttpServletResponse responseParam = "
155: + responseParam + ", HttpSession sessionParam = "
156: + sessionParam + ", ClientSession clientSession = "
157: + clientSessionParam + ") - start");
158: }
159:
160: String forward = super .execute(mappingParam, formParam,
161: requestParam, responseParam, sessionParam,
162: clientSessionParam);
163: // check the createListForm method is called, or we already have a
164: // suitable form
165: assert (formParam instanceof FramesListForm);
166: FramesListForm framesListForm = (FramesListForm) formParam;
167:
168: assert (!StringHandling.isNullOrEmpty(mappingParam.getPath()));
169: framesListForm.setMenuFrameURI(mappingParam.getPath()
170: + ACTION_SUFFIX);
171:
172: if (logger.isDebugEnabled()) {
173: logger.debug("execute - end - return value = " + forward);
174: }
175: return forward;
176: }
177: }
|