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: TopicAction.java,v $
031: * Revision 1.3 2005/04/10 20:31:58 colinmacleod
032: * Added new themes.
033: * Changed id type to String.
034: * Changed i tag to em and b tag to strong.
035: * Improved PicoContainerFactory with NanoContainer scripts.
036: *
037: * Revision 1.2 2005/04/09 17:19:46 colinmacleod
038: * Changed copyright text to GPL v2 explicitly.
039: *
040: * Revision 1.1.1.1 2005/03/10 17:52:05 colinmacleod
041: * Restructured ivata op around Hibernate/PicoContainer.
042: * Renamed ivata groupware.
043: *
044: * Revision 1.11 2004/12/31 18:27:44 colinmacleod
045: * Added MaskFactory to constructor of MaskAction.
046: *
047: * Revision 1.10 2004/12/23 21:01:29 colinmacleod
048: * Updated Struts to v1.2.4.
049: * Changed base classes to use ivata masks.
050: *
051: * Revision 1.9 2004/11/12 18:19:15 colinmacleod
052: * Change action and form classes to extend MaskAction, MaskForm respectively.
053: *
054: * Revision 1.8 2004/11/12 15:57:16 colinmacleod
055: * Removed dependencies on SSLEXT.
056: * Moved Persistence classes to ivata masks.
057: *
058: * Revision 1.7 2004/11/03 15:31:51 colinmacleod
059: * Change method interfaces to remove log.
060: *
061: * Revision 1.6 2004/07/29 20:51:04 colinmacleod
062: * Commented out topic rights amendment.
063: *
064: * Revision 1.5 2004/07/13 19:47:29 colinmacleod
065: * Moved project to POJOs from EJBs.
066: * Applied PicoContainer to services layer (replacing session EJBs).
067: * Applied Hibernate to persistence layer (replacing entity EJBs).
068: *
069: * Revision 1.4 2004/03/21 21:16:29 colinmacleod
070: * Shortened name to ivata op.
071: *
072: * Revision 1.3 2004/02/10 19:57:24 colinmacleod
073: * Changed email address.
074: *
075: * Revision 1.2 2004/02/01 22:07:31 colinmacleod
076: * Added full names to author tags
077: *
078: * Revision 1.1.1.1 2004/01/27 20:58:42 colinmacleod
079: * Moved ivata openportal to SourceForge..
080: *
081: * Revision 1.3 2003/10/28 13:16:14 jano
082: * commiting library,
083: * still fixing compile and building openGroupware project
084: *
085: * Revision 1.2 2003/10/15 14:16:53 colin
086: * fixing for XDoclet
087: *
088: * Revision 1.3 2003/08/21 13:29:43 jano
089: * we have new structure of userGroups
090: * and
091: * another frontend for maintan rights for item in topics
092: * Revision 1.2 2003/03/03 16:57:12 colin
093: * converted localization to automatic paths
094: * added labels
095: * added mandatory fieldName attribute
096: *
097: * Revision 1.1 2003/02/24 19:09:24 colin
098: * moved to business
099: * -----------------------------------------------------------------------------
100: */
101: package com.ivata.groupware.business.library.struts;
102:
103: import javax.servlet.http.HttpServletRequest;
104: import javax.servlet.http.HttpServletResponse;
105: import javax.servlet.http.HttpSession;
106:
107: import org.apache.struts.action.ActionErrors;
108: import org.apache.struts.action.ActionForm;
109: import org.apache.struts.action.ActionMapping;
110:
111: import com.ivata.groupware.admin.security.server.SecuritySession;
112: import com.ivata.groupware.business.library.Library;
113: import com.ivata.groupware.business.library.right.LibraryRights;
114: import com.ivata.groupware.business.library.topic.TopicDO;
115: import com.ivata.mask.MaskFactory;
116: import com.ivata.mask.util.SystemException;
117: import com.ivata.mask.web.struts.MaskAction;
118: import com.ivata.mask.web.struts.MaskAuthenticator;
119:
120: /**
121: * <p><code>Action</code> invoked whenever
122: * <code>/library/topicModify.jsp</code> is submitted.</p>
123: *
124: *
125: * @since 2002-11-22
126: * @author Jan Boros <janboros@sourceforge.net>
127: * @version $Revision: 1.3 $
128: */
129: public class TopicAction extends MaskAction {
130: Library library;
131: LibraryRights libraryRights;
132:
133: /**
134: * TODO
135: * @param library
136: * @param libraryRights
137: * @param maskFactory This factory is needed to access the masks and groups
138: * of masks.
139: * @param authenticator used to confirm whether or not the
140: * user should be allowed to continue, in the <code>execute</code> method.
141: */
142: public TopicAction(Library library, LibraryRights libraryRights,
143: MaskFactory maskFactory, MaskAuthenticator authenticator) {
144: super (maskFactory, authenticator);
145: this .library = library;
146: this .libraryRights = libraryRights;
147: }
148:
149: /**
150: * <p>This method is called if the ok or apply buttons are
151: * pressed.</p>
152: *
153: * @param mapping current action mapping from <em>Struts</em> config.
154: * @param log valid logging object to write messages to.
155: * @param errors valid errors object to append errors to. If there are
156: * any errors, the action will return to the input.
157: * @param form optional ActionForm bean for this request (if any)
158: * @param request non-HTTP request we are processing
159: * @param response The non-HTTP response we are creating
160: * @param session returned from the <code>request</code> parameter.
161: * @param userName valid, non-null user name from session.
162: * @param settings valid, non-null settings from session.
163: * @param ok <code>true</code> if the ok button was pressed, otherwise
164: * <code>false</code> if the apply button was pressed.
165: * @exception SystemException if there is any problem which
166: * prevents processing. It will result in the webapp being forwarded
167: * to
168: * the standard error page.
169: * @return this method returns the string used to identify the correct
170: * <em>Struts</em> <code>ActionForward</code> which should follow this
171: * page, or <code>null</code> if it should return to the input.
172: *
173: */
174: public String onConfirm(final ActionMapping mapping,
175: final ActionErrors errors, final ActionForm form,
176: final HttpServletRequest request,
177: final HttpServletResponse response,
178: final HttpSession session, final String defaultForward)
179: throws SystemException {
180: TopicForm topicForm = (TopicForm) form;
181: TopicDO topic = topicForm.getTopic();
182: SecuritySession securitySession = (SecuritySession) session
183: .getAttribute("securitySession");
184:
185: // if I have not ID , so it's new TOPIC
186: if (topic.getId() == null) {
187: topic = library.addTopic(securitySession, topic);
188: } else {
189: topic = library.amendTopic(securitySession, topic);
190: }
191:
192: // amend RIGHTS for TOPIC
193: /* TODO
194: try {
195: libraryRights.amendViewRightsForTopic(securitySession, topic.getId(),
196: new java.util.Vector(java.util.Arrays.asList(
197: topicForm.getRightsView())));
198: libraryRights.amendAmendRightsForTopic(securitySession, topic.getId(),
199: new java.util.Vector(java.util.Arrays.asList(
200: topicForm.getRightsAmend())));
201: libraryRights.amendRemoveRightsForTopic(securitySession, topic.getId(),
202: new java.util.Vector(java.util.Arrays.asList(
203: topicForm.getRightsRemove())));
204: } catch (SystemException e) {
205: throw new SystemException(e);
206: }
207: */
208: request.setAttribute("openerPage",
209: "/library/topicItems.jsp?topicId=" + topic.getId());
210:
211: return defaultForward;
212: }
213:
214: /**
215: * <p>This method is called if the delete (confirm, not warn) button
216: * is pressed.</p>
217: * @param mapping current action mapping from <em>Struts</em> config.
218: * @param errors valid errors object to append errors to. If there are
219: * any errors, the action will return to the input.
220: * @param form optional ActionForm bean for this request (if any)
221: * @param request non-HTTP request we are processing
222: * @param response The non-HTTP response we are creating
223: * @param session returned from the <code>request</code> parameter.
224: * @param log valid logging object to write messages to.
225: * @param userName valid, non-null user name from session.
226: * @param settings valid, non-null settings from session.
227: *
228: * @exception SystemException if there is any problem which
229: * prevents processing. It will result in the webapp being forwarded
230: * to
231: * the standard error page.
232: * @return this method returns the string used to identify the correct
233: * <em>Struts</em> <code>ActionForward</code> which should follow this
234: * page, or <code>null</code> if it should return to the input.
235: *
236: */
237: public String onDelete(final ActionMapping mapping,
238: final ActionErrors errors, final ActionForm form,
239: final HttpServletRequest request,
240: final HttpServletResponse response,
241: final HttpSession session, final String defaultForward)
242: throws SystemException {
243: TopicForm topicForm = (TopicForm) form;
244: TopicDO topic = topicForm.getTopic();
245: SecuritySession securitySession = (SecuritySession) session
246: .getAttribute("securitySession");
247:
248: library.removeTopic(securitySession, topic);
249: request.setAttribute("openerPage", "/library/topic.jsp");
250:
251: return null;
252: }
253:
254: /**
255: * <p>Called when the clear button is pressed, or after an ok or
256: * delete button, where the session should be restored to its default
257: * state.</p>
258: *
259: * @param mapping The ActionMapping used to select this instance.
260: * @param log valid logging object to write messages to.
261: * @param errors valid errors object to append errors to. If there are
262: * any errors, the action will return to the input.
263: * @param form optional ActionForm bean for this request (if any)
264: * @param request non-HTTP request we are processing
265: * @param response The non-HTTP response we are creating
266: * @param session returned from the <code>request</code> parameter.
267: * @param userName valid, non-null user name from session.
268: * @param settings valid, non-null settings from session.
269: * @exception SystemException if there is any problem which
270: * prevents processing. It will result in the webapp being forwarded
271: * to
272: * the standard error page.
273: */
274: public void clear(final ActionMapping mapping,
275: final ActionErrors errors, final ActionForm form,
276: final HttpServletRequest request,
277: final HttpServletResponse response,
278: final HttpSession session) throws SystemException {
279: session.removeAttribute("topicTab_activeTab");
280: session.removeAttribute("libraryTopicForm");
281: }
282: }
|