PageRenderTime 44ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/projects/ivatagroupware-0.11.3/library/src/java/com/ivata/groupware/business/library/struts/TopicForm.java

https://gitlab.com/essere.lab.public/qualitas.class-corpus
Java | 450 lines | 122 code | 39 blank | 289 comment | 15 complexity | 4f168ba27417cee4e5ff16b7d41bbdc3 MD5 | raw file
  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: TopicForm.java,v $
  31. * Revision 1.3 2005/04/10 20:31:58 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:46 colinmacleod
  38. * Changed copyright text to GPL v2 explicitly.
  39. *
  40. * Revision 1.1.1.1 2005/03/10 17:52:01 colinmacleod
  41. * Restructured ivata op around Hibernate/PicoContainer.
  42. * Renamed ivata groupware.
  43. *
  44. * Revision 1.7 2004/12/23 21:01:29 colinmacleod
  45. * Updated Struts to v1.2.4.
  46. * Changed base classes to use ivata masks.
  47. *
  48. * Revision 1.6 2004/11/12 18:19:15 colinmacleod
  49. * Change action and form classes to extend MaskAction, MaskForm respectively.
  50. *
  51. * Revision 1.5 2004/07/13 19:47:29 colinmacleod
  52. * Moved project to POJOs from EJBs.
  53. * Applied PicoContainer to services layer (replacing session EJBs).
  54. * Applied Hibernate to persistence layer (replacing entity EJBs).
  55. *
  56. * Revision 1.4 2004/03/21 21:16:29 colinmacleod
  57. * Shortened name to ivata op.
  58. *
  59. * Revision 1.3 2004/02/10 19:57:24 colinmacleod
  60. * Changed email address.
  61. *
  62. * Revision 1.2 2004/02/01 22:07:31 colinmacleod
  63. * Added full names to author tags
  64. *
  65. * Revision 1.1.1.1 2004/01/27 20:58:42 colinmacleod
  66. * Moved ivata openportal to SourceForge..
  67. *
  68. * Revision 1.2 2003/10/15 14:16:53 colin
  69. * fixing for XDoclet
  70. *
  71. * Revision 1.3 2003/08/21 13:29:43 jano
  72. * we have new structure of userGroups
  73. * and
  74. * another frontend for maintan rights for item in topics
  75. * Revision 1.2 2003/03/03 16:57:12 colin
  76. * converted localization to automatic paths
  77. * added labels
  78. * added mandatory fieldName attribute
  79. *
  80. * Revision 1.1 2003/02/24 19:09:24 colin
  81. * moved to business
  82. *
  83. * Revision 1.9 2003/02/04 17:43:50 colin
  84. * copyright notice
  85. *
  86. * Revision 1.8 2003/01/08 10:39:39 jano
  87. * we changed interface of libraryBeans, we are using libraryRightBean for amending rights and for finding out
  88. * -----------------------------------------------------------------------------
  89. */
  90. package com.ivata.groupware.business.library.struts;
  91. import javax.servlet.http.HttpServletRequest;
  92. import javax.servlet.http.HttpSession;
  93. import org.apache.struts.action.ActionMapping;
  94. import com.ivata.groupware.admin.security.server.SecuritySession;
  95. import com.ivata.groupware.business.library.Library;
  96. import com.ivata.groupware.business.library.topic.TopicDO;
  97. import com.ivata.mask.Mask;
  98. import com.ivata.mask.validation.ValidationErrors;
  99. import com.ivata.mask.web.struts.DialogForm;
  100. /**
  101. * <p>Contains details of a topic which is being changed, or where the
  102. * user (group) rights are being altered..</p>
  103. *
  104. * @since 2002-11-22
  105. * @author Jan Boros <janboros@sourceforge.net>
  106. * @version $Revision: 1.3 $
  107. */
  108. public class TopicForm extends DialogForm {
  109. /**
  110. * <p>
  111. * Defines the base class of all objects in the value object list.
  112. * </p>
  113. */
  114. private Class baseClass;
  115. /**
  116. * Library - used in validation.
  117. */
  118. private Library library;
  119. /**
  120. * <p>
  121. * Mask containing all the field definitions for this list.
  122. * </p>
  123. */
  124. private Mask mask;
  125. /**
  126. * <p>Contains an array of all of the group ids for groups who have
  127. * the right to <strong>add</strong> library items to this topic.</p>
  128. */
  129. private Integer[] rightsAddItem;
  130. /**
  131. * <p>Contains an array of all of the group ids for groups who have
  132. * the right to <strong>amend</strong> this topic.</p>
  133. */
  134. private Integer[] rightsAmend;
  135. /**
  136. * <p>Contains an array of all of the group ids for groups who have
  137. * the right to <strong>amend</strong> library items which have this topic.</p>
  138. */
  139. private Integer[] rightsAmendItem;
  140. /**
  141. * <p>Contains an array of all of the group ids for groups who have
  142. * the right to <strong>remove</strong> this topic.</p>
  143. */
  144. private Integer[] rightsRemove;
  145. /**
  146. * <p>Contains an array of all of the group ids for groups who have
  147. * the right to <strong>remove</strong> library items with this topic.</p>
  148. */
  149. private Integer[] rightsRemoveItem;
  150. /**
  151. * <p>Contains an array of all of the group ids for groups who have
  152. * the right to <strong>view</strong> this topic.</p>
  153. */
  154. private Integer[] rightsView;
  155. /**
  156. * <p>Contains an array of all of the group ids for groups who have
  157. * the right to <strong>view</strong> library items with this topic.</p>
  158. */
  159. private Integer[] rightsViewItem;
  160. /**
  161. * <p>Contains details of the topic which is currently being modified.</p>
  162. */
  163. private TopicDO topic;
  164. /**
  165. * <p>which TAB is active.</p>
  166. */
  167. private Integer topicTab_activeTab;
  168. public TopicForm(final Library libraryParam) {
  169. this.library = libraryParam;
  170. }
  171. /**
  172. * TODO
  173. *
  174. * @see com.ivata.mask.web.struts.MaskForm#clear()
  175. */
  176. protected void clear() {
  177. rightsAddItem = new Integer[] { };
  178. rightsAmend = new Integer[] { };
  179. rightsAmendItem = new Integer[] { };
  180. rightsRemove = new Integer[] { };
  181. rightsRemoveItem = new Integer[] { };
  182. rightsView = new Integer[] { };
  183. rightsViewItem = new Integer[] { };
  184. topic = new TopicDO();
  185. topicTab_activeTab = null;
  186. }
  187. /**
  188. * <p>
  189. * Defines the base class of all objects in the value object list.
  190. * </p>
  191. *
  192. * @return base class of all objects in the value object list.
  193. */
  194. public final Class getBaseClass() {
  195. return baseClass;
  196. }
  197. /**
  198. * <p>
  199. * Mask containing all the field definitions for this list.
  200. * </p>
  201. *
  202. * @return mask containing all the field definitions for this list.
  203. */
  204. public final Mask getMask() {
  205. return mask;
  206. }
  207. /**
  208. * <p>Contains an array of all of the group ids for groups who have
  209. * the right to <strong>add</strong> library items to this topic.</p>
  210. *
  211. * @return the current value of rightsAddItem.
  212. */
  213. public final Integer[] getRightsAddItem() {
  214. return this.rightsAddItem;
  215. }
  216. /**
  217. * <p>Contains an array of all of the group ids for groups who have
  218. * the right to <strong>amend</strong> library items which have this topic.</p>
  219. *
  220. * @return the current value of rightsAmend.
  221. */
  222. public final Integer[] getRightsAmend() {
  223. return this.rightsAmend;
  224. }
  225. /**
  226. * <p>Contains an array of all of the group ids for groups who have
  227. * the right to <strong>amend</strong> library items which have this topic.</p>
  228. *
  229. * @return the current value of rightsAmendItem.
  230. */
  231. public final Integer[] getRightsAmendItem() {
  232. return this.rightsAmendItem;
  233. }
  234. /**
  235. * <p>Contains an array of all of the group ids for groups who have
  236. * the right to <strong>remove</strong> library items with this topic.</p>
  237. *
  238. * @return the current value of groups who can remove from this topic.
  239. */
  240. public final Integer[] getRightsRemove() {
  241. return this.rightsRemove;
  242. }
  243. /**
  244. * <p>Contains an array of all of the group ids for groups who have
  245. * the right to <strong>remove</strong> library items with this topic.</p>
  246. *
  247. * @return the current value of rightsRemoveItem.
  248. */
  249. public final Integer[] getRightsRemoveItem() {
  250. return this.rightsRemoveItem;
  251. }
  252. /**
  253. * <p>Contains an array of all of the group ids for groups who have
  254. * the right to <strong>view</strong> library items with this topic.</p>
  255. *
  256. * @return the current value of groups who can view this topic.
  257. */
  258. public final Integer[] getRightsView() {
  259. return rightsView;
  260. }
  261. /**
  262. * <p>Contains an array of all of the group ids for groups who have
  263. * the right to <strong>view</strong> library items with this topic.</p>
  264. *
  265. * @return the current value of rightsViewItem.
  266. */
  267. public final Integer[] getRightsViewItem() {
  268. return this.rightsViewItem;
  269. }
  270. /**
  271. * <p>Contains details of the topic which is currently being modified.</p>
  272. *
  273. * @return the current value of topic.
  274. */
  275. public final TopicDO getTopic() {
  276. return topic;
  277. }
  278. /**
  279. * <p>which TAB is active.</p>
  280. *
  281. * @return the current value of topicTab_activeTab.
  282. */
  283. public final Integer getTopicTab_activeTab() {
  284. return this.topicTab_activeTab;
  285. }
  286. /**
  287. * <p>Reset all bean properties to their default state. This method
  288. * is called before the properties are repopulated by the controller
  289. * servlet.<p>
  290. *
  291. * @param mapping The mapping used to select this instance
  292. * @param request The servlet request we are processing
  293. */
  294. public void reset(final ActionMapping mapping,
  295. final HttpServletRequest request) {
  296. // I have to clear arrays because STRUTS is not doing that
  297. // meybe we neew to CHAGE tree select tag
  298. Integer[] tmpRights = { };
  299. int tab = ((this.topicTab_activeTab == null) ? 0
  300. : this.topicTab_activeTab.intValue());
  301. if ((tab == 1) && (request.getParameterValues("rightsView") == null)) {
  302. this.setRightsView(tmpRights);
  303. } else if ((tab == 2) &&
  304. (request.getParameterValues("rightsAmend") == null)) {
  305. this.setRightsAmend(tmpRights);
  306. } else if ((tab == 3) &&
  307. (request.getParameterValues("rightsRemove") == null)) {
  308. this.setRightsRemove(tmpRights);
  309. }
  310. // if you didn't click delete butoon so don't show delete message if user want to delete topic
  311. if (request.getParameterValues("deleteWarn") == null) {
  312. this.setDeleteWarn(null);
  313. }
  314. }
  315. /**
  316. * <p>Contains an array of all of the group ids for groups who have
  317. * the right to <strong>add</strong> library items to this topic.</p>
  318. *
  319. * @param rightsAddItem the new value of rightsAddItem.
  320. */
  321. public final void setRightsAddItem(final Integer[] rightsAddItem) {
  322. this.rightsAddItem = rightsAddItem;
  323. }
  324. /**
  325. * <p>Contains an array of all of the group ids for groups who have
  326. * the right to <strong>amend</strong> library items which have this topic.</p>
  327. *
  328. * @param rightsAmend the new value of rightsAmend.
  329. */
  330. public final void setRightsAmend(final Integer[] rightsAmend) {
  331. this.rightsAmend = rightsAmend;
  332. }
  333. /**
  334. * <p>Contains an array of all of the group ids for groups who have
  335. * the right to <strong>amend</strong> library items which have this topic.</p>
  336. *
  337. * @param rightsAmendItem the new value of rightsAmendItem.
  338. */
  339. public final void setRightsAmendItem(final Integer[] rightsAmendItem) {
  340. this.rightsAmendItem = rightsAmendItem;
  341. }
  342. /**
  343. * <p>Contains an array of all of the group ids for groups who have
  344. * the right to <strong>remove</strong> library items with this topic.</p>
  345. *
  346. * @param rightsRemove the new value of groups who can remove from
  347. * this topic.
  348. */
  349. public final void setRightsRemove(final Integer[] rightsRemove) {
  350. this.rightsRemove = rightsRemove;
  351. }
  352. /**
  353. * <p>Contains an array of all of the group ids for groups who have
  354. * the right to <strong>remove</strong> library items with this topic.</p>
  355. *
  356. * @param rightsRemoveItem the new value of rightsRemoveItem.
  357. */
  358. public final void setRightsRemoveItem(final Integer[] rightsRemoveItem) {
  359. this.rightsRemoveItem = rightsRemoveItem;
  360. }
  361. /**
  362. * <p>Contains an array of all of the group ids for groups who have
  363. * the right to <strong>view</strong> library items with this topic.</p>
  364. *
  365. * @param rightsView the new value of groups who can view this topic.
  366. */
  367. public final void setRightsView(final Integer[] rightsView) {
  368. this.rightsView = rightsView;
  369. }
  370. /**
  371. * <p>Contains an array of all of the group ids for groups who have
  372. * the right to <strong>view</strong> library items with this topic.</p>
  373. *
  374. * @param rightsViewItem the new value of rightsViewItem.
  375. */
  376. public final void setRightsViewItem(final Integer[] rightsViewItem) {
  377. this.rightsViewItem = rightsViewItem;
  378. }
  379. /**
  380. * <p>Contains details of the topic which is currently being modified.</p>
  381. *
  382. * @param topic the new value of topic.
  383. */
  384. public final void setTopic(final TopicDO topic) {
  385. this.topic = topic;
  386. }
  387. /**
  388. * <p>which TAB is active.</p>
  389. *
  390. * @param topicTab_activeTab the new value of topicTab_activeTab.
  391. */
  392. public final void setTopicTab_activeTab(final Integer topicTab_activeTab) {
  393. this.topicTab_activeTab = topicTab_activeTab;
  394. }
  395. /**
  396. * <p>Call the corresponding server-side validation, handle possible
  397. * exceptions and return any errors generated.</p>
  398. *
  399. * @param mapping The mapping used to select this instance
  400. * @param request The servlet request we are processing
  401. * @return <code>ActionMessages</code> collection containing all
  402. * validation errors, or <code>null</code> if there were no errors.
  403. * @see com.ivata.mask.web.struts.MaskForm#validate(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpSession)
  404. */
  405. public ValidationErrors validate(final HttpServletRequest request,
  406. final HttpSession session) {
  407. SecuritySession securitySession = (SecuritySession)
  408. session.getAttribute("securitySession");
  409. return library.validate(securitySession, topic);
  410. }
  411. }